text: var re=Object.defineProperty,ae=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var Y=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&Y(e,n,t[n]);if(k)for(var n of k(t))j.call(t,n)&&Y(e,n,t[n]);return e},T=(e,t)=>ae(e,oe(t));var K=(e,t)=>{var n={};for(var r in e)P.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&k)for(var r of k(e))t.indexOf(r)<0&&j.call(e,r)&&(n[r]=e[r]);return n};import{j as v,a,r as N,F as J,c as ie}from"./jsx-runtime.a8396eb8.js";import{S as Z,_ as z,a as X,O as _,n as ee,i as le,R as U,u as F,b,c as se,d as de,e as ce}from"./remesh-logger.82eef2ea.js";import{f as me,o as B,c as $,i as ue,m as A}from"./map.4b85a765.js";import{m as H}from"./merge.2c1510c0.js";import{s as pe}from"./switchMap.af31b466.js";import{p as he}from"./mergeAll.4b1c5b5d.js";import{L as ye}from"./list.d814f1ec.js";var te={now:function(){return(te.delegate||performance).now()},delegate:void 0},L={schedule:function(e){var t=requestAnimationFrame,n=cancelAnimationFrame,r=L.delegate;r&&(t=r.requestAnimationFrame,n=r.cancelAnimationFrame);var o=t(function(i){n=void 0,e(i)});return new Z(function(){return n==null?void 0:n(o)})},requestAnimationFrame:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=L.delegate;return((n==null?void 0:n.requestAnimationFrame)||requestAnimationFrame).apply(void 0,z([],X(e)))},cancelAnimationFrame:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=L.delegate;return((n==null?void 0:n.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,z([],X(e)))},delegate:void 0};function Ce(e){return e?ne(e):fe}function ne(e){var t=L.schedule;return new _(function(n){var r=new Z,o=e||te,i=o.now(),c=function(S){var m=o.now();n.next({timestamp:e?m:S,elapsed:m-i}),n.closed||r.add(t(c))};return r.add(t(c)),r})}var fe=ne();function ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=he(e);return me(e,n)}var Se=new _(ee);function ve(e,t){return t===void 0&&(t=le),e=e!=null?e:xe,B(function(n,r){var o,i=!0;n.subscribe($(r,function(c){var S=t(c);(i||!e(o,S))&&(i=!1,o=S,r.next(c))}))})}function xe(e,t){return e===t}function be(){return B(function(e,t){var n,r=!1;e.subscribe($(t,function(o){var i=n;n=o,r&&t.next([i,o]),r=!0}))})}function we(e){return B(function(t,n){ue(e).subscribe($(n,function(){return n.complete()},ee)),!n.closed&&t.subscribe(n)})}const De=U.domain({name:"CounterDomain",impl:e=>{const t=e.state({name:"CounterState",default:0}),n=e.query({name:"CounterQuery",impl:({get:o})=>o(t())}),r=e.command({name:"IncreCommand",impl:({get:o})=>{const i=o(t());return t().new(i+1)}});return{query:{CountQuery:n},command:{IncreCommand:r}}}}),Qe=()=>{const e=F(De()),t=b(e.query.CountQuery());return v("div",{style:{width:400,border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},children:[a("h2",{children:"Counter"}),a("input",{type:"number",readOnly:!0,value:t}),v("label",{children:[a("button",{onClick:()=>{e.command.IncreCommand()},children:"Count "})," "]})]})},Ie=U.domain({name:"TemperatureConverterDomain",impl:e=>{const t=e.state({name:"CelsiusState",default:""}),n=e.query({name:"CelsiusQuery",impl:({get:m})=>m(t())}),r=e.state({name:"FahrenheitState",default:""}),o=e.query({name:"FahrenheitQuery",impl:({get:m})=>m(r())}),i=e.command({name:"ResetBothCommand",impl:()=>[t().new(""),r().new("")]}),c=e.command({name:"UpdateCelsiusCommand",impl:({},m)=>{if(m==="")return i();const p=parseFloat(m);if(Number.isNaN(p))return t().new(m);const C=p*(9/5)+32;return[t().new(m),r().new(C.toString())]}}),S=e.command({name:"UpdateFahrenheitCommand",impl:({},m)=>{if(m==="")return i();const p=parseFloat(m);if(Number.isNaN(p))return r().new(m);const C=(p-32)*(5/9);return[t().new(C.toString()),r().new(m)]}});return{query:{CelsiusQuery:n,FahrenheitQuery:o},command:{UpdateCelsiusCommand:c,UpdateFahrenheitCommand:S}}}}),Fe=()=>{const e=F(Ie()),t=b(e.query.CelsiusQuery()),n=b(e.query.FahrenheitQuery());return v("div",{style:{border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},children:[a("h2",{children:"Temperature Converter"}),v("div",{children:[a("input",{type:"text",value:t,onChange:i=>{e.command.UpdateCelsiusCommand(i.target.value)}}),a("label",{htmlFor:"",children:"Celsius"}),"=",a("input",{type:"text",value:n,onChange:i=>{e.command.UpdateFahrenheitCommand(i.target.value)}}),a("label",{htmlFor:"",children:"Fahrenheit"})]})]})},W=e=>{const t=e.split(".");if(t.length!==3)return null;const n=new Date(`${t[2]}.${t[1]}.${t[0]}`);return n.toString()==="Invalid Date"?null:n},V=e=>{const t=e.toLocaleDateString().split("/");return`${t[2]}.${t[1]}.${t[0]}`},Ue=(e,t)=>e.getFullYear()!==t.getFullYear()?e.getFullYear()-t.getFullYear():e.getMonth()!==t.getMonth()?e.getMonth()-t.getMonth():e.getDate()-t.getDate(),qe=U.domain({name:"FlightBookerDomain",impl:e=>{const t=e.state({name:"OptionState",default:"one-way"}),n=e.query({name:"OptionQuery",impl:({get:u})=>u(t())}),r=e.state({name:"StartDateInputState",default:V(new Date)}),o=e.query({name:"StartDateInputQuery",impl:({get:u})=>u(r())}),i=e.state({name:"EndDateInputState",default:V(new Date)}),c=e.query({name:"EndDateInputQuery",impl:({get:u})=>u(i())}),S=e.query({name:"StartDateQuery",impl:({get:u})=>{const s=u(r());return W(s)}}),m=e.query({name:"EndDateQuery",impl:({get:u})=>{const s=u(i());return W(s)}}),p=e.command({name:"UpdateOptionCommand",impl:({},u)=>t().new(u)}),C=e.command({name:"UpdateStartDateCommand",impl:({},u)=>r().new(u)}),y=e.command({name:"UpdateEndDateCommand",impl:({},u)=>i().new(u)});return{query:{StatusQuery:e.query({name:"StatusQuery",impl:({get:u})=>{const s=u(t()),f=u(S()),d=u(m()),x=f?"valid":"invalid",w=s==="return"?d?"valid":"invalid":"disabled",h=s==="one-way"?f?"enabled":"disabled":!!f&&!!d&&Ue(f,d)<=0?"enabled":"disabled";return{startDate:x,endDate:w,bookButton:h}}}),OptionQuery:n,StartDateQuery:S,EndDateQuery:m,StartDateInputQuery:o,EndDateInputQuery:c},command:{UpdateOptionCommand:p,UpdateStartDateCommand:C,UpdateEndDateCommand:y}}}}),Re=()=>{const e=F(qe()),t=b(e.query.OptionQuery()),n=b(e.query.StatusQuery()),r=b(e.query.StartDateInputQuery()),o=b(e.query.EndDateInputQuery()),i=p=>{e.command.UpdateOptionCommand(p.target.value)},c=p=>{e.command.UpdateStartDateCommand(p.target.value)},S=p=>{e.command.UpdateEndDateCommand(p.target.value)},m=()=>{n.bookButton==="enabled"&&alert(t==="one-way"?`You have booked a one-way flight on ${r}`:`You have booked return flight from ${r} to ${o}`)};return v("div",{style:{width:400,border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},children:[a("h2",{children:"Flight Booker"}),a("div",{children:v("select",{value:t,onChange:i,children:[a("option",{value:"one-way",children:"One-way flight"}),a("option",{value:"return",children:"Return flight"})]})}),a("div",{children:a("input",{type:"text",style:{backgroundColor:n.startDate==="invalid"?"red":""},value:r,onChange:c})}),a("div",{children:a("input",{type:"text",style:{backgroundColor:n.endDate==="invalid"?"red":""},disabled:n.endDate==="disabled",value:o,onChange:S})}),a("div",{children:a("button",{disabled:n.bookButton==="disabled",onClick:m,children:"Book"})})]})},Ee=U.domain({name:"TimerDomain",inspectable:!1,impl:e=>{const t=e.state({name:"DurationState",default:15e3}),n=e.query({name:"DurationQuery",impl:({get:y})=>y(t())}),r=e.state({name:"ElapsedState",default:0}),o=e.query({name:"ElapsedQuery",impl:({get:y})=>y(r())}),i=e.event({name:"StartEvent"}),c=e.event({name:"StopEvent"}),S=e.command({name:"UpdateElapsedCommand",impl:({get:y},l)=>{const u=y(t()),s=y(r());return s>u?c():r().new(s+l)}}),m=e.command({name:"UpdateDurationCommand",impl:({get:y},l)=>{const u=y(r());return l>u?[t().new(l),i()]:t().new(l)}}),p=e.command({name:"ResetElapsedCommand",impl:({})=>[r().new(0),i()]}),C=e.command$({name:"UpdateElapsedByAnimationFramesCommand",impl:({fromEvent:y})=>{const l=y(i).pipe(A(()=>1)),u=y(c).pipe(A(()=>0)),s=H(l,u).pipe(ve(),pe(f=>f===0?Se:Ce().pipe(be(),A(([d,x])=>x.elapsed-d.elapsed),A(d=>S(d)),we(y(c)))));return H(s,ge(i()))}});return e.ignite(()=>C()),{query:{DurationQuery:n,ElapsedQuery:o},command:{ResetElapsedCommand:p,UpdateDurationCommand:m}}}}),ke=()=>{const e=F(Ee()),t=b(e.query.ElapsedQuery()),n=b(e.query.DurationQuery()),r=i=>{const c=parseInt(i.target.value,10);isNaN(c)||e.command.UpdateDurationCommand(c)},o=()=>{e.command.ResetElapsedCommand()};return v("div",{style:{width:400,border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},children:[a("h2",{children:"Timer"}),v("div",{style:{display:"flex"},children:[a("label",{style:{marginRight:10,whiteSpace:"nowrap"},children:"Elapsed Timer:"}),a("div",{style:{width:"100%"},children:a("span",{style:{display:"inline-block",height:10,background:"green",width:`${Math.min(t/n,1)*100}%`,verticalAlign:"middle",borderRadius:5}})})]}),v("div",{children:[t>n?(n/1e3).toFixed(1):(t/1e3).toFixed(1),"s"]}),v("div",{style:{display:"flex"},children:[a("label",{style:{width:100,marginRight:10},children:"Duration:"}),a("input",{style:{width:"100%"},type:"range",min:0,max:3e4,value:n,onChange:r})]}),a("div",{children:a("button",{style:{width:"100% "},onClick:o,children:"Reset Timer"})})]})},Ae=U.domain({name:"CRUDDomain",impl:e=>{let t=0;const n=ye(e,{name:"NameListModule",key:d=>d.id}),r=e.state({name:"FilterPrefixState",default:""}),o=e.query({name:"FilterPrefixQuery",impl:({get:d})=>d(r())}),i=e.command({name:"UpdateFilterPrefixCommand",impl:({},d)=>r().new(d)}),c=e.state({name:"CreatedState",default:{name:"",surname:""}}),S=e.query({name:"CreatedQuery",impl:({get:d})=>d(c())}),m=e.command({name:"UpdateCreatedCommand",impl:({get:d},x)=>{const w=d(c());return c().new(I(I({},w),x))}}),p=e.state({name:"SelectedState",default:null}),C=e.query({name:"SelectedQuery",impl:({get:d})=>d(p())}),y=e.command({name:"SelectItemCommand",impl:({get:d},x)=>{const w=d(p());if(x===null)return w===null?null:p().new(null);if(w&&w.id===x)return p().new(null);const h=d(n.query.ItemQuery(x));return p().new(h)}}),l=e.command({name:"UpdateSelectedNameCommand",impl:({get:d},x)=>{const w=d(p());return w===null?[]:p().new(I(I({},w),x))}}),u=e.query({name:"FilteredListQuery",impl:({get:d})=>{const x=d(r()),w=d(n.query.ItemListQuery());return x===""?w:w.filter(h=>h.surname.startsWith(x))}}),s=e.command({name:"SyncSelectedCommand",impl:({get:d})=>{const x=d(p());return x===null?[]:n.command.UpdateItemCommand(x)}}),f=e.command({name:"CreateNameItemCommand",impl:({get:d})=>{const x=d(c()),w=I({id:`${t++}`},x);return[n.command.AddItemCommand(w),m({name:"",surname:""})]}});return{query:T(I({},n.query),{FilteredListQuery:u,SelectedQuery:C,FilterPrefixQuery:o,CreatedQuery:S}),command:T(I({},n.command),{UpdateFilterPrefixCommand:i,SelectItemCommand:y,UpdateCreatedCommand:m,UpdateSelectedNameCommand:l,CreateNameItemCommand:f,SyncSelectedCommand:s})}}}),O=e=>{const o=e,{onOuterClick:t}=o,n=K(o,["onOuterClick"]),r=N.exports.useRef(null);return N.exports.useEffect(()=>{const i=c=>{var m;if(!((m=c.target)!=null&&m.parentElement))return;!!(r.current&&!r.current.contains(c.target))&&(t==null||t(c))};return document.addEventListener("click",i,!1),()=>{document.removeEventListener("click",i,!1)}},[]),a("div",I({ref:r},n))},Le=()=>{const e=F(Ae()),t=b(e.query.FilteredListQuery()),n=b(e.query.FilterPrefixQuery()),r=b(e.query.CreatedQuery()),o=b(e.query.SelectedQuery()),i=l=>{e.command.UpdateFilterPrefixCommand(l.target.value)},c=l=>{e.command.SelectItemCommand(l)},S=l=>{o?e.command.UpdateSelectedNameCommand({name:l.target.value}):e.command.UpdateCreatedCommand({name:l.target.value})},m=l=>{o?e.command.UpdateSelectedNameCommand({surname:l.target.value}):e.command.UpdateCreatedCommand({surname:l.target.value})},p=()=>{o===null&&e.command.CreateNameItemCommand()},C=()=>{o&&e.command.SyncSelectedCommand()},y=()=>{o&&(e.command.DeleteItemCommand(o.id),e.command.SelectItemCommand(null))};return v(O,{style:{width:400,border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},onOuterClick:()=>{c(null)},children:[a("h2",{children:"CRUD"}),v("div",{children:[a("label",{htmlFor:"",children:"Filter prefix"}),a("input",{type:"text",value:n,onChange:i})]}),v("div",{style:{display:"flex"},children:[a("div",{style:{width:"50%",height:100,border:"1px solid #eaeaea",overflow:"scroll"},children:t.map(l=>{const u=l.name+", "+l.surname;return a("div",{style:{background:(o==null?void 0:o.id)===l.id?"blue":"",color:(o==null?void 0:o.id)===l.id?"white":""},onClick:()=>{c(l.id)},children:u},l.id)})}),v("div",{style:{width:"50%",padding:10},children:[v("div",{children:[a("label",{children:"Name:"}),a("input",{type:"text",value:o?o.name:r.name,onChange:S})]}),v("div",{children:[a("label",{children:"Surname:"}),a("input",{type:"text",value:o?o.surname:r.surname,onChange:m})]})]}),v("div",{children:[a("button",{disabled:o!==null,style:{marginRight:10},onClick:p,children:"Create"}),a("button",{disabled:o===null,style:{marginRight:10},onClick:C,children:"Update"}),a("button",{disabled:o===null,style:{marginRight:10},onClick:y,children:"Delete"})]})]})]})},Te=U.domain({name:"CircleDrawerDomain",impl:e=>{const t=e.state({name:"HistoryState",default:{items:[],currentIndex:-1}}),n=e.query({name:"HistoryQuery",impl:({get:h})=>h(t())}),r=e.command({name:"RecordHistoryStateCommand",impl:({get:h},g)=>{const Q=h(t()),D=Q.items.slice(0,Q.currentIndex+1);if(g.action==="adjust-circle"){const E=D[D.length-1];E.action==="adjust-circle"&&E.index===g.index&&D.pop()}const q=[...D,g],R=q.length-1;return t().new({items:q,currentIndex:R})}}),o=e.state({name:"DrawState",default:{circles:[]}}),i=e.query({name:"DrawQuery",impl:({get:h})=>h(o())}),c=e.command({name:"UndoCommand",impl:({get:h})=>{const g=h(t()),Q=h(m()),D=g.currentIndex-1;return!Q||D<0?[o().new({circles:[]}),t().new({items:g.items,currentIndex:-1})]:[o().new(g.items[D].state),t().new({items:g.items,currentIndex:D})]}}),S=e.command({name:"RedoCommand",impl:({get:h})=>{const g=h(t());if(!h(p()))return[];const D=g.currentIndex+1;return[o().new(g.items[D].state),t().new({items:g.items,currentIndex:D})]}}),m=e.query({name:"CanUndoQuery",impl:({get:h})=>h(t()).currentIndex>=0}),p=e.query({name:"CanRedoQuery",impl:({get:h})=>{const g=h(t());return g.currentIndex<g.items.length-1}}),C=e.state({name:"SelectedIndexState",default:-1}),y=e.query({name:"SelectedIndexQuery",impl:({get:h})=>h(C())}),l=e.command({name:"SetSelectedIndexCommand",impl:({},h)=>C().new(h)}),u=e.query({name:"SelectedCircleInfoQuery",impl:({get:h})=>{const g=h(C()),Q=h(o()).circles;return g===-1?null:{index:g,circle:Q[g]}}}),s=e.command({name:"DrawCommand",impl:({get:h},g)=>{const D={circles:[...h(o()).circles,{position:g.position,diameter:g.diameter}]};return[o().new(D),r({action:"add-circle",state:D})]}}),f=e.command({name:"AdjustCommand",impl:({get:h},g)=>{const q={circles:h(o()).circles.map((R,E)=>E===g.index?{position:R.position,diameter:g.diameter}:R)};return[o().new(q),r({action:"adjust-circle",index:g.index,state:q})]}}),d=e.state({name:"TooltipsState",default:{type:"default"}}),x=e.query({name:"TooltipsQuery",impl:({get:h})=>h(d())}),w=e.command({name:"UpdateTooltipsCommand",impl:({},h)=>d().new(h)});return{query:{HistoryQuery:n,DrawQuery:i,TooltipsQuery:x,SelectedIndexQuery:y,SelectedCircleInfoQuery:u,CanUndoQuery:m,CanRedoQuery:p},command:{DrawCommand:s,AdjustCommand:f,UpdateTooltipsCommand:w,UndoCommand:c,RedoCommand:S,SetSelectedIndexCommand:l}}}}),Ne=(e,t)=>{const{x:n,y:r}=e,{diameter:o,position:i}=t,{x:c,y:S}=i,m=o/2,p=n-c,C=r-S;return p*p+C*C<m*m},Oe=()=>{var u;const e=F(Te()),t=b(e.query.DrawQuery()),n=b(e.query.TooltipsQuery()),r=b(e.query.SelectedCircleInfoQuery()),o=b(e.query.CanUndoQuery()),i=b(e.query.CanRedoQuery()),c=s=>{const f=t.circles.find(x=>Ne(s,x));return f?{index:t.circles.indexOf(f),circle:f}:null},S=s=>{s.preventDefault();const f={x:s.pageX,y:s.pageY},d=c(f);d&&(e.command.SetSelectedIndexCommand(d.index),e.command.UpdateTooltipsCommand({type:"show-tips",index:d.index,circle:d.circle,pageX:s.pageX,pageY:s.pageY}))},m=s=>{if(n.type!=="default")return;const f={x:s.pageX,y:s.pageY};c(f)||e.command.DrawCommand({position:f,diameter:30})},p=s=>{if(n.type!=="default")return;const f={x:s.pageX,y:s.pageY},d=c(f);d?e.command.SetSelectedIndexCommand(d.index):e.command.SetSelectedIndexCommand(-1)},C=()=>{n.type==="show-tips"&&e.command.UpdateTooltipsCommand({type:"open-slider",index:n.index,circle:n.circle,pageX:n.pageX,pageY:n.pageY})},y=()=>{e.command.UpdateTooltipsCommand({type:"default"})},l=s=>{const f=parseInt(s.target.value,10);r&&!isNaN(f)&&e.command.AdjustCommand({index:r.index,diameter:f})};return v("div",{style:{border:"1px solid #eaeaea",boxSizing:"border-box",padding:10},children:[a("h2",{children:"Circle Drawer"}),v("div",{style:{width:400,textAlign:"center",padding:10},children:[a("button",{onClick:()=>e.command.UndoCommand(),style:{margin:"0 10px"},disabled:!o,children:"Undo"}),a("button",{onClick:()=>e.command.RedoCommand(),style:{margin:"0 10px"},disabled:!i,children:"Redo"})]}),a("div",{style:{width:400,height:400,border:"1px solid #eaeaea",boxSizing:"border-box",overflow:"hidden"},onClick:m,onMouseMove:p,children:t.circles.map((s,f)=>a("div",{style:{position:"absolute",left:s.position.x-s.diameter/2,top:s.position.y-s.diameter/2,width:s.diameter,height:s.diameter,borderRadius:s.diameter/2,border:"1px solid #666",backgroundColor:(r==null?void 0:r.index)===f?"#eaeaea":""},onContextMenu:S},s.position.x+"-"+s.position.y+"-"+s.diameter))}),n.type==="show-tips"&&a(O,{style:{position:"absolute",left:n.pageX,top:n.pageY,zIndex:100,background:"#fff",border:"1px solid #666",padding:10},onOuterClick:y,onClick:C,children:"Adjust Diameter"},"show-tips"),n.type==="open-slider"&&v(O,{style:{position:"absolute",left:n.pageX,top:n.pageY,background:"#fff",border:"1px solid #666",zIndex:100,padding:10},onOuterClick:y,children:[a("p",{children:"Adjust Diameter"}),a("div",{children:a("input",{type:"range",value:(u=r==null?void 0:r.circle.diameter)!=null?u:"",min:1,max:150,onChange:l})})]},"open-slider")]})},M=U.domain({name:"CellsDomain",inspectable:!1,impl:e=>{const t=e.state({name:"RowKeyListState",default:[0,1,2,3,4,5,6,7,8,9].map(String)}),n=e.query({name:"RowKeyListQuery",impl:({get:C})=>C(t())}),r=e.state({name:"ColumnKeyListState",default:["A","B","C","D","E","F","G","H","I","J"]}),o=e.query({name:"ColumnKeyListQuery",impl:({get:C})=>C(r())}),i=e.state({name:"CellState",impl:C=>({content:{type:"text",text:""},isEditing:!1})}),c=e.query({name:"CellQuery",impl:({get:C},y)=>{const l=C(i(y));if(l.content.type==="text")return{type:"text",isEditing:l.isEditing,content:l.content.text,displayContent:l.content.text};if(l.content.type==="formula"){const u=Be(l.content.formula),s=f=>Number(C(c(f)).displayContent);return{type:"formula",isEditing:l.isEditing,content:l.content.formula,displayContent:u(s)}}throw new Error("Unknown cell type")}}),S=e.command({name:"SelectCellCommand",impl:({get:C},y)=>{const l=C(i(y));return i(y).new({content:l.content,isEditing:!0})}}),m=e.command({name:"UnselectCellCommand",impl:({get:C},y)=>{const l=C(i(y));return i(y).new({content:l.content,isEditing:!1})}}),p=e.command({name:"SetCellContentCommand",impl:({get:C},{key:y,input:l})=>{const u=C(i(y));return l.startsWith("=")?i(y).new({content:{type:"formula",formula:l},isEditing:u.isEditing}):i(y).new({content:{type:"text",text:l},isEditing:u.isEditing})}});return{query:{CellQuery:c,ColumnKeyListQuery:o,RowKeyListQuery:n},command:{SelectCellCommand:S,UnselectCellCommand:m,SetCellContentCommand:p}}}}),Be=e=>t=>{try{const n=e.slice(1).replace(/\w\d+/g,o=>`get('${o}')`);return new Function("get",`return (${n}).toString()`)(t)}catch{return"-"}},$e=()=>{const e=F(M()),t=b(e.query.ColumnKeyListQuery()),n=b(e.query.RowKeyListQuery());return v("div",{children:[a("h2",{children:"Cells"}),v("table",{style:{borderCollapse:"collapse",border:"1px solid #bbb",textAlign:"center"},children:[a("thead",{children:v("tr",{style:{backgroundColor:"#f6f6f6"},children:[a("th",{style:{width:30,display:"block"}}),t.map(r=>a("th",{style:{maxWidth:80,border:"1px solid #bbb"},children:r},r))]})}),a("tbody",{children:n.map(r=>a("tr",{children:a(Me,{rowKey:r,columnKeyList:t})},r))})]})]})},Me=({columnKeyList:e,rowKey:t})=>{const n=F(M());return v(J,{children:[a("td",{style:{width:30,border:"1px solid #bbb",backgroundColor:"#f6f6f6"},children:t}),e.map(r=>{const o=`${r}${t}`;return a("td",{style:{maxWidth:80,minWidth:80,border:"1px solid #bbb",overflow:"hidden"},onClick:i=>{i.target instanceof HTMLInputElement||n.command.SelectCellCommand(o)},children:a(Ye,{cellKey:o})},o)})]})},Ye=({cellKey:e})=>{const t=F(M()),n=b(t.query.CellQuery(e)),r=o=>{t.command.SetCellContentCommand({key:e,input:o.target.value})};return v(J,{children:[n.isEditing&&a("input",{style:{width:"100%",height:"100%",backgroundColor:"transparent",boxSizing:"border-box",textAlign:"center"},value:n.content,onChange:r,onBlur:()=>{n.isEditing&&t.command.UnselectCellCommand(e)},autoFocus:!0}),!n.isEditing&&n.displayContent]})},Pe=()=>v("div",{children:[a("h1",{children:"7GUIs in React/Remesh/TypeScript"}),a("p",{children:"This is a live version of an implementation (source) of 7GUIs with React, TypeScript and Remesh."}),a("hr",{}),a(Qe,{}),a("hr",{}),a(Fe,{}),a("hr",{}),a(Re,{}),a("hr",{}),a(ke,{}),a("hr",{}),a(Le,{}),a("hr",{}),a(Oe,{}),a("hr",{}),a($e,{})]}),G=document.getElementById("root");if(G){const e=ie(G),t=U.store({inspectors:[se(),de()]});e.render(a(N.exports.StrictMode,{children:a(ce,{store:t,children:a(Pe,{})})}))}
  //# sourceMappingURL=index.a59616a4.js.map
  