tinybase 4.1.2 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("./ui-react");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Ids",c="Table",h=c+"s",m=c+u,b="Row",g=b+"Count",p=b+u,I="Cell",f=I+u,w="Value",C=w+"s",y=w+u,v="currentTarget",k="value",x=e=>l+e,S=Math.floor,T=isFinite,V=(e,t)=>e instanceof t,R=e=>null==e,q=(e,t,s)=>R(e)?s?.():t(e),N=e=>e==a||e==n,L=e=>s(e)==o,M=e=>Array.isArray(e),{PureComponent:E,Fragment:z,createElement:$,useCallback:O,useLayoutEffect:A,useRef:F,useState:J}=e,P=(e,...t)=>R(e)?{}:e(...t),H=(e,t)=>e.forEach(t),B=(e,t)=>e.map(t),D=e=>e.length,Q=e=>0==D(e),j=(e,t,s)=>e.slice(t,s),W=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,U=K.keys,X=K.isFrozen,Y=K.freeze,Z=e=>V(e,K)&&e.constructor==K,_=(e=[])=>K.fromEntries(e),ee=(e,t)=>!R(((e,t)=>q(e,(e=>e[t])))(e,t)),te=(e,t)=>(delete e[t],e),se=(e,t)=>B(K.entries(e),(([e,s])=>t(s,e))),le=e=>Z(e)&&0==(e=>D(U(e)))(e),ae=e=>JSON.stringify(e,((e,t)=>V(t,Map)?K.fromEntries([...t]):t)),ne=JSON.parse,re="tinybaseStoreInspector",oe="TinyBase Store Inspector",ie=["left","top","bottom","right","full"],de="state",ue="sort",ce="open",he="position",me=ce,be="editable",ge=(...e)=>ae(e),pe=(e,t)=>B(e.sort(),t),Ie=(e,s)=>[!!t.useCell(de,e,be,s),O((t=>{s.setCell(de,e,be,(e=>!e)),t.preventDefault()}),[s,e])],fe="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",we='content:url("',Ce=we+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ye='</svg>")',ve=we+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",ke=B([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ye)),xe=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ye,Se=Ce+`<path d='${fe}' />`+ye,Te=Ce+`<path d='${fe}M20 20l60 60' />`+ye,Ve="*::-webkit-scrollbar",Re=((e,t="")=>e.join(t))(se({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ve]:"width:0.5rem;height:0.5rem;",[Ve+"-track"]:"background:#111",[Ve+"-thumb"]:"background:#999;border:1px solid #111",[Ve+"-thumb:hover"]:"background:#fff",[Ve+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ve,..._(B(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",..._(B(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ve,"header>img:nth-of-type(6)":xe,..._(B(ke,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Se,"details[open]>summary img.done":Te,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${re} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${re} ${t}{${e}}`:""))),qe=({s:e})=>{const s=t.useValue(he,e)??1,l=t.useSetValueCallback(me,(()=>!0),[],e);return t.useValue(me,e)?null:$("img",{onClick:l,title:oe,"data-position":s})},Ne=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(de,e,ce,r),i=t.useSetCellCallback(de,e,ce,(e=>e[v].open),[],r);return $("details",{open:o,onToggle:i},$("summary",null,s,a?$("img",{onClick:a,className:l?"done":"edit"}):null),n)},Le=e=>{const t=s(e);return N(t)||t==r&&T(e)?t:void 0},Me=(e,t,s,l,a)=>R(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),Ee=(e,t,s)=>R(s)?e.delValue(t):e.setValue(t,s),ze=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:$e,useMemo:Oe,useState:Ae}=e,Fe="editable",Je=(e,s)=>B(t.useTableCellIds(e,s),(t=>e+"."+t)),Pe=(e,t,s)=>{const l=$e(e,t);return s?l:void 0},He=(...e)=>Oe((()=>e),e),Be=(e,t)=>Oe((()=>({store:e,tableId:t})),[e,t]),De=(e,t)=>Oe((()=>({queries:e,queryId:t})),[e,t]),Qe=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Ae([e,t,l]),h=$e((e=>{c(e),o?.(e)}),[o]),m=Pe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=$e((e=>h([i,d,e])),[h,i,d]),g=!0===r?lt:r;return[[i,d,u],m,Oe((()=>!1===r?null:$(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},je=(e,t,l)=>Oe((()=>{const n=t??e;return _(se(M(n)?_(B(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)}];var n})))}),[t,l,e]),We=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===t?null:$("thead",null,$("tr",null,!1===s?null:$(Ge,{sort:r??[],label:"Id",onClick:o}),se(l,(({label:e},t)=>$(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),$("tbody",null,B(n,(e=>$("tr",{key:e},!1===s?null:$("th",null,e),se(l,(({component:t,getComponentProps:s},l)=>$("td",{key:l},$(t,{...P(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>$("th",{onClick:Pe((()=>n?.(e)),[n,e],n),className:R(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},R(s)||t!=e?null:(s?"↓":"↑")+" ",a),Ke=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return $("tr",null,!1===l?null:$(e.Fragment,null,$("th",null,s),$("th",null,u)),se(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return R(i)?null:$("td",{key:l},$(e,{...P(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Ue=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[o,i]=Ae(),[d,u]=Ae(),[c,h]=Ae(),[m,b]=Ae(),[g,p]=Ae();d!==e&&(i(Le(e)),u(e),h(e+""),b(Number(e)||0),p(!!e));const I=$e(((e,s)=>{s(e),u(e),t(e)}),[t]);return $("div",{className:s},$("button",{className:o,onClick:$e((()=>{if(!l?.()){const e=ze(o,r,n,a),s=ze(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,o])},o),ze(o,$("input",{key:o,value:c,onChange:$e((e=>I(e[v][k]+"",h)),[I])}),$("input",{key:o,type:"number",value:m,onChange:$e((e=>I(Number(e[v][k]||0),b)),[I])}),$("input",{key:o,type:"checkbox",checked:g,onChange:$e((e=>I(!!e[v].checked,p)),[I])})))},Xe=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=Qe(s,l,i,a,n,t.useRowCount(e,r),d,u);return $(We,{...h,params:He(je(t.useTableCellIds(e,r),c,o?tt:t.CellView),Be(r,e),t.useSortedRowIds(e,...m,n,r),m,b,g)})},Ye=({store:e,editable:s=!1,valueComponent:l=(s?st:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>$("table",{className:n},!1===r?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,w))),$("tbody",null,B(t.useValueIds(e),(t=>$("tr",{key:t},!1===o?null:$("th",null,t),$("td",null,$(l,{...P(a,t),valueId:t,store:e}))))))),Ze=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return $(We,{...r,params:He(je(t.useTableCellIds(d,i),n,a?tt:t.CellView),Be(i,d),t.useSliceRowIds(e,s,o))})},_e=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=je([...Je(c,u),...Je(h,u)],n,a?tt:t.CellView),b=He(i,m,c,h,s,d,u);return $("table",{className:r},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(e.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),se(m,(({label:e},t)=>$("th",{key:t},e))))),$("tbody",null,B(t.useRowIds(c,u),(e=>$(Ke,{key:e,localRowId:e,params:b})))))},et=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=Qe(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return $(We,{...c,params:He(je(t.useResultTableCellIds(e,r),d,t.ResultCellView),De(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,b)})},tt=({tableId:e,rowId:s,cellId:l,store:a,className:n})=>$(Ue,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Fe+I,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),st=({valueId:e,store:s,className:l})=>$(Ue,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Fe+w,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),lt=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Pe((()=>t(l-a)),[t,l,a],l>0),i=Pe((()=>t(l+a)),[t,l,a],l+a<s);return $(e.Fragment,null,s>a&&$(e.Fragment,null,$("button",{className:"previous",disabled:0==l,onClick:o},"←"),$("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},at=({indexes:e,indexesId:s,indexId:l,s:a})=>$(Ne,{uniqueId:ge("i",s,l),summary:"Index: "+l,s:a},B(t.useSliceIds(l,e),(t=>$(nt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a})))),nt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=ge("i",t,s,l),[r,o]=Ie(n,a);return $(Ne,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},$(Ze,{sliceId:l,indexId:s,indexes:e,editable:r}))},rt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return R(l)?null:$(Ne,{uniqueId:ge("i",e),summary:"Indexes: "+(e??d),s:s},Q(a)?"No indexes defined":pe(a,(t=>$(at,{indexes:l,indexesId:e,indexId:t,s:s}))))},ot=({metrics:e,metricId:s})=>$("tr",null,$("th",null,s),$("td",null,e?.getTableId(s)),$("td",null,t.useMetric(s,e))),it=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return R(l)?null:$(Ne,{uniqueId:ge("m",e),summary:"Metrics: "+(e??d),s:s},Q(a)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,B(a,(e=>$(ot,{metrics:l,metricId:e}))))))},dt=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=ge("q",s,l),[r,o,i]=ne(t.useCell(de,n,ue,a)??"[]"),d=t.useSetCellCallback(de,n,ue,ae,[],a);return $(Ne,{uniqueId:n,summary:"Query: "+l,s:a},$(et,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ut=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return R(l)?null:$(Ne,{uniqueId:ge("q",e),summary:"Queries: "+(e??d),s:s},Q(a)?"No queries defined":pe(a,(t=>$(dt,{queries:l,queriesId:e,queryId:t,s:s}))))},ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=ge("r",t,s),[n,r]=Ie(a,l);return $(Ne,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},$(_e,{relationshipId:s,relationships:e,editable:n}))},ht=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return R(l)?null:$(Ne,{uniqueId:ge("r",e),summary:"Relationships: "+(e??d),s:s},Q(a)?"No relationships defined":pe(a,(t=>$(ct,{relationships:l,relationshipsId:e,relationshipId:t,s:s}))))},mt=({tableId:e,store:s,storeId:l,s:a})=>{const n=ge("t",l,e),[r,o,i]=ne(t.useCell(de,n,ue,a)??"[]"),d=t.useSetCellCallback(de,n,ue,ae,[],a),[u,h]=Ie(n,a);return $(Ne,{uniqueId:n,summary:c+": "+e,editable:u,handleEditable:h,s:a},$(Xe,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},bt=({store:e,storeId:s,s:l})=>{const a=ge("v",s),[n,r]=Ie(a,l);return Q(t.useValueIds(e))?null:$(Ne,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},$(Ye,{store:e,editable:n}))},gt=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return R(l)?null:$(Ne,{uniqueId:ge("s",e),summary:"Store: "+(e??d),s:s},$(bt,{storeId:e,store:l,s:s}),pe(a,(t=>$(mt,{store:l,storeId:e,tableId:t,s:s}))))},pt=({s:e})=>{const s=F(null),l=F(0),[a,n]=J(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);A((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=S(r)+e.clientWidth&&e.scrollHeight>=S(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=O((t=>{const{scrollLeft:s,scrollTop:a}=t[v];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),g=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return R(d)&&Q(u)&&R(c)&&Q(h)&&R(m)&&Q(b)&&R(g)&&Q(p)&&R(I)&&Q(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:s,onScroll:i},$(gt,{s:e}),B(u,(t=>$(gt,{storeId:t,key:t,s:e}))),$(it,{s:e}),B(h,(t=>$(it,{metricsId:t,key:t,s:e}))),$(rt,{s:e}),B(b,(t=>$(rt,{indexesId:t,key:t,s:e}))),$(ht,{s:e}),B(p,(t=>$(ht,{relationshipsId:t,key:t,s:e}))),$(ut,{s:e}),B(f,(t=>$(ut,{queriesId:t,key:t,s:e}))))};class It extends E{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ft=({s:e})=>{const s=t.useValue(he,e)??1,l=t.useSetValueCallback(me,(()=>!1),[],e),a=t.useSetValueCallback(he,(e=>Number(e[v].dataset.id)),[],e);return $("header",null,$("img",{title:oe}),$("span",null,oe),B(ie,((e,t)=>t==s?null:$("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),$("img",{onClick:l,title:"Close"}))},wt=({s:e})=>{const s=t.useValue(he,e)??1;return t.useValue(me,e)?$("main",{"data-position":s},$(ft,{s:e}),$(It,null,$(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Vt(t).reduce(s,0);var s},yt=e=>e?.size??0,vt=Ct(yt),kt=Ct(vt),xt=Ct(kt),St=(e,t)=>e?.has(t)??!1,Tt=e=>R(e)||0==yt(e),Vt=e=>[...e?.values()??[]],Rt=e=>e.clear(),qt=(e,t)=>e?.forEach(t),Nt=(e,t)=>e?.delete(t),Lt=e=>new Map(e),Mt=e=>[...e?.keys()??[]],Et=(e,t)=>e?.get(t),zt=(e,t)=>qt(e,((e,s)=>t(s,e))),$t=(e,t,s)=>R(s)?(Nt(e,t),e):e?.set(t,s),Ot=(e,t,s)=>(St(e,t)||$t(e,t,s()),Et(e,t)),At=(e,t,s,l=$t)=>(se(t,((t,l)=>s(e,l,t))),zt(e,(s=>ee(t,s)?0:l(e,s))),e),Ft=(e,t,s)=>{const l={};return qt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Jt=(e,t,s)=>Ft(e,(e=>Ft(e,t,s)),le),Pt=(e,t,s)=>Ft(e,(e=>Jt(e,t,s)),le),Ht=(e,t)=>{const s=Lt();return qt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Bt=e=>Ht(e,Ht),Dt=e=>Ht(e,Bt),Qt=(e,t,s,l,a=0)=>q((s?Ot:Et)(e,t[a],a>D(t)-2?s:Lt),(n=>{if(a>D(t)-2)return l?.(n)&&$t(e,t[a]),n;const r=Qt(n,t,s,l,a+1);return Tt(n)&&$t(e,t[a]),r})),jt=Lt(),Wt=Lt(),Gt="storage",Kt=globalThis.window,Ut=e=>new Set(M(e)||R(e)?e:[e]),Xt=(e,t)=>e?.add(t),Yt=/^\d+$/,Zt=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??l+t++,t=>{Yt.test(t)&&D(e)<1e3&&W(e,t)}]},_t=e=>[e,e],es=(e,t=vt)=>t(e[0])+t(e[1]),ts=()=>[Lt(),Lt()],ss=e=>[...e],ls=([e,t])=>e===t,as=(e,t,s)=>R(e)||!Z(e)||le(e)||X(e)?(s?.(),!1):(se(e,((s,l)=>{t(s,l)||te(e,l)})),!le(e)),ns=(e,t,s)=>$t(e,t,Et(e,t)==-s?void 0:s),rs=()=>{let e,t,s=!1,a=!1,n=0;const o=Lt(),u=Lt(),v=Lt(),k=Lt(),S=Lt(),T=Lt(),V=Lt(),M=Lt(),E=Lt(),z=Lt(),$=Lt(),O=Lt(),A=Lt(),F=Lt(),J=Ut(),P=Lt(),Q=Lt(),G=Lt(),K=Lt(),U=ts(),X=ts(),Z=ts(),_=ts(),re=ts(),oe=ts(),ie=ts(),de=ts(),ue=ts(),ce=ts(),he=ts(),me=ts(),be=ts(),ge=ts(),pe=ts(),Ie=Lt(),fe=ts(),[we,Ce,ye,ve]=(e=>{let t;const[s,a]=Zt(),n=Lt();return[(e,a,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return $t(n,d,[e,a,r,o,i]),Xt(Qt(a,r??[l],Ut),d),d},(e,s,...a)=>H(((e,t=[l])=>{const s=[],a=(e,l)=>l==D(t)?W(s,e):null===t[l]?qt(e,(e=>a(e,l+1))):H([t[l],null],(t=>a(Et(e,t),l+1)));return a(e,0),s})(e,s),(e=>qt(e,(e=>Et(n,e)[0](t,...s??[],...a))))),e=>q(Et(n,e),(([,t,s])=>(Qt(t,s??[l],void 0,(t=>(Nt(t,e),Tt(t)?1:0))),$t(n,e),a(e),s))),e=>q(Et(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=D(r);o==D(s)?e(t,...r,...a(r)):R(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),ke=e=>{if(!as(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!N(t)&&t!=r||(Le(e[d])!=t&&te(e,d),0))},xe=(t,s)=>(!e||St($,s)||lt(s))&&as(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>as(l?s:qe(s,e,t),((l,a)=>q(Te(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),Te=(t,s,l,a)=>e?q(Et(Et($,t),l),(e=>Le(a)!=e[i]?lt(t,s,l,a,e[d]):a),(()=>lt(t,s,l,a))):R(Le(a))?lt(t,s,l,a):a,Ve=(e,t)=>as(t?e:Ne(e),((t,s)=>q(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?q(Et(A,e),(t=>Le(s)!=t[i]?at(e,s,t[d]):s),(()=>at(e,s))):R(Le(s))?at(e,s):s,qe=(e,t,s)=>(q(Et(O,t),(([l,a])=>{qt(l,((t,s)=>{ee(e,s)||(e[s]=t)})),qt(a,(l=>{ee(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(qt(F,((t,s)=>{ee(e,s)||(e[s]=t)})),qt(J,(t=>{ee(e,t)||at(t)}))),e),ze=e=>At($,e,((e,t,s)=>{const l=Lt(),a=Ut();At(Ot($,t,Lt),s,((e,t,s)=>{$t(e,t,s),q(s[d],(e=>$t(l,t,e)),(()=>Xt(a,t)))})),$t(O,t,[l,a])}),((e,t)=>{$t($,t),$t(O,t)})),$e=e=>At(A,e,((e,t,s)=>{$t(A,t,s),q(s[d],(e=>$t(F,t,e)),(()=>Xt(J,t)))}),((e,t)=>{$t(A,t),$t(F,t),Nt(J,t)})),Oe=e=>le(e)?us():Kt(e),Ae=e=>At(G,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ge(t))),Fe=(e,t)=>At(Ot(G,e,(()=>(Ye(e,1),$t(P,e,Zt()),$t(Q,e,Lt()),Lt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ke(e,t,s))),Je=(e,t,s,l,a)=>At(Ot(t,s,(()=>(Ze(e,s,1),Lt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ue(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{St(s,l)||_e(e,t,l,1);const n=Et(s,l);a!==n&&(et(e,t,l,n,a),$t(s,l,a))},He=(e,t,s,l,a)=>q(Et(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),Be=e=>le(e)?ms():Yt(e),De=e=>At(K,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{St(K,e)||tt(e,1);const s=Et(K,e);t!==s&&(st(e,s,t),$t(K,e,t))},je=(e,t)=>{const[s]=Et(P,e),l=s(t);return St(Et(G,e),l)?je(e,t):l},We=e=>Et(G,e)??Fe(e,{}),Ge=e=>Fe(e,{}),Ke=(e,t,s)=>{const[,l]=Et(P,e);l(s),Je(e,t,s,{},!0)},Ue=(e,t,s,l,a,n)=>{const r=Et(Et(O,e)?.[0],a);if(!R(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,Et(l,t)),_e(e,s,t,-1),$t(l,t)};R(r)?o(a):zt(l,o),Tt(l)&&(Ze(e,s,-1),Tt($t(t,s))&&(Ye(e,-1),$t(G,e),$t(P,e),$t(Q,e)))},Xe=e=>{const t=Et(F,e);if(!R(t))return Qe(e,t);st(e,Et(K,e)),tt(e,-1),$t(K,e)},Ye=(e,t)=>ns(o,e,t),Ze=(e,t,s)=>ns(Ot(k,e,Lt),t,s)&&$t(v,e,Ot(v,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=Et(Q,e),n=Et(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&ns(Ot(u,e,Lt),s,l),$t(a,s,n!=-l?n+l:null),ns(Ot(Ot(S,e,Lt),t,Lt),s,l)},et=(e,t,s,l,a)=>Ot(Ot(Ot(T,e,Lt),t,Lt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>ns(V,e,t),st=(e,t,s)=>Ot(M,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(W(Ot(Ot(Ot(E,e,Lt),t,Lt),s,(()=>[])),l),a),at=(e,t,s)=>(W(Ot(z,e,(()=>[])),t),s),nt=(e,t,s)=>q(Et(Et(Et(T,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,..._t(Vt(e,t,s))])),rt=e=>q(Et(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,..._t(Gt(e))])),ot=e=>Tt(E)||Tt(he[e])?0:qt(e?Dt(E):E,((t,s)=>qt(t,((t,l)=>qt(t,((t,a)=>Ce(he[e],[s,l,a],t))))))),it=e=>Tt(z)||Tt(me[e])?0:qt(e?Ht(z):z,((t,s)=>Ce(me[e],[s],t))),dt=(e,t,s)=>{if(!Tt(t))return Ce(e,s,(()=>Ft(t))),1},ut=e=>{const t=Tt(ie[e]),s=Tt(ue[e])&&Tt(_[e])&&Tt(re[e])&&Tt(oe[e])&&t&&Tt(X[e]),l=Tt(ce[e])&&Tt(de[e])&&Tt(Z[e])&&Tt(U[e]);if(!s||!l){const a=e?[Ht(o),Bt(u),Ht(v),Bt(k),Dt(S),Dt(T)]:[o,u,v,k,S,T];if(!s){dt(X[e],a[0]),qt(a[1],((t,s)=>dt(_[e],t,[s]))),qt(a[2],((t,s)=>{0!=t&&Ce(re[e],[s],It(s))}));const s=Ut();qt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(Ce(ie[e],[a,null]),Xt(s,a))})),t||qt(a[5],((t,l)=>{if(!St(s,l)){const s=Ut();qt(t,(e=>qt(e,(([t,l],a)=>l!==t?Xt(s,a):Nt(e,a))))),qt(s,(t=>Ce(ie[e],[l,t])))}})),qt(a[4],((t,s)=>qt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;qt(a[5],((s,l)=>{let a;qt(s,((s,n)=>{let r;qt(s,(([s,o],i)=>{o!==s&&(Ce(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&Ce(de[e],[l,n],nt)})),a&&Ce(Z[e],[l],nt)})),t&&Ce(U[e],void 0,nt)}}},ct=e=>{const t=Tt(ge[e]),s=Tt(pe[e])&&Tt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(M)]:[V,M];if(t||dt(ge[e],l[0]),!s){let t;qt(l[1],(([s,l],a)=>{l!==s&&(Ce(pe[e],[a],l,s,rt),t=1)})),t&&Ce(be[e],void 0,rt)}}},ht=(e,...t)=>(ps((()=>e(...B(t,x)))),ws),mt=()=>[Ft(T,((e,t)=>-1===Et(o,t)?null:Ft(e,((e,s)=>-1===Et(Et(k,t),s)?null:Ft(e,(([,e])=>e??null),((e,t)=>ls(t)))),le)),le),Ft(M,(([,e])=>e??null),((e,t)=>ls(t)))],bt=()=>({cellsTouched:s,valuesTouched:a,changedCells:Pt(T,ss,ls),invalidCells:Pt(E),changedValues:Ft(M,ss,ls),invalidValues:Ft(z),changedTableIds:Ft(o),changedRowIds:Jt(k),changedCellIds:Pt(S),changedValueIds:Ft(V)}),gt=()=>Pt(G),pt=()=>Mt(G),It=e=>yt(Et(G,x(e))),ft=e=>Mt(Et(G,x(e))),wt=(e,t,s,l=0,a)=>{return B(j((r=Et(G,x(e)),o=(e,s)=>[R(t)?s:Et(e,x(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),B([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,R(a)?a:l+a),(([,e])=>e));var n,r,o},Ct=(e,t)=>Mt(Et(Et(G,x(e)),x(t))),Vt=(e,t,s)=>Et(Et(Et(G,x(e)),x(t)),x(s)),jt=()=>Ft(K),Wt=()=>Mt(K),Gt=e=>Et(K,x(e)),Kt=e=>ht((()=>(e=>as(e,xe,lt))(e)?Ae(e):0)),Yt=e=>ht((()=>Ve(e)?De(e):0)),os=e=>{try{Oe(ne(e))}catch{}return ws},is=t=>ht((()=>{if((e=as(t,(e=>as(e,ke))))&&(ze(t),!Tt(G))){const e=gt();us(),Kt(e)}})),ds=e=>ht((()=>{if(t=(e=>as(e,ke))(e)){const s=jt();gs(),ms(),t=!0,$e(e),Yt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>St(G,e)?Ge(e):0),e),hs=(e,t)=>ht(((e,t)=>q(Et(G,e),(s=>St(s,t)?Ke(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{ze({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),ps=(e,t)=>{if(-1!=n){Is();const s=e();return fs(t),s}},Is=()=>(-1!=n&&n++,1==n&&Ce(Ie,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Tt(T),a=!Tt(M),n=1,ot(1),s&&ut(1),it(1),a&&ct(1),e?.(mt,bt)&&(qt(T,((e,t)=>qt(e,((e,s)=>qt(e,(([e],l)=>Me(ws,t,s,l,e))))))),qt(M,(([e],t)=>Ee(ws,t,e))),s=a=!1),Ce(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),a&&ct(0),Ce(fe[1],void 0,mt,bt),n=0,s=a=!1,H([o,u,v,k,S,T,E,V,M,z],Rt))),ws),ws={getContent:()=>[gt(),jt()],getTables:gt,getTableIds:pt,getTable:e=>Jt(Et(G,x(e))),getTableCellIds:e=>Mt(Et(Q,x(e))),getRowCount:It,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Ft(Et(Et(G,x(e)),x(t))),getCellIds:Ct,getCell:Vt,getValues:jt,getValueIds:Wt,getValue:Gt,hasTables:()=>!Tt(G),hasTable:e=>St(G,x(e)),hasTableCell:(e,t)=>St(Et(Q,x(e)),x(t)),hasRow:(e,t)=>St(Et(G,x(e)),x(t)),hasCell:(e,t,s)=>St(Et(Et(G,x(e)),x(t)),x(s)),hasValues:()=>!Tt(K),hasValue:e=>St(K,x(e)),getTablesJson:()=>ae(G),getValuesJson:()=>ae(K),getJson:()=>ae([G,K]),getTablesSchemaJson:()=>ae($),getValuesSchemaJson:()=>ae(A),getSchemaJson:()=>ae([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(le(e)?us:Kt)(e),(le(t)?ms:Yt)(t)})),setTables:Kt,setTable:(e,t)=>ht((e=>xe(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>ps((()=>{let l;return Se(e,l,t)&&(e=x(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);se(s,((s,a)=>He(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>q(Te(e,t,s,L(l)?l(Vt(e,t,s)):l),(l=>He(e,We(e),t,s,l)))),e,t,s),setValues:Yt,setPartialValues:e=>ht((()=>Ve(e,1)?se(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>q(Re(e,L(t)?t(Gt(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{se(e[0],((e,t)=>R(e)?cs(t):se(e,((e,s)=>R(e)?hs(t,s):se(e,((e,l)=>Me(ws,t,s,l,e))))))),se(e[1],((e,t)=>Ee(ws,t,e)))})),setTablesJson:os,setValuesJson:e=>{try{Be(ne(e))}catch{}return ws},setJson:e=>{try{const[t,s]=ne(e);Oe(t),Be(s)}catch{os(e)}return ws},setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>q(Et(G,e),(a=>q(Et(a,t),(n=>St(n,s)?Ue(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>St(K,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:ps,startTransaction:Is,finishTransaction:fs,forEachTable:e=>qt(G,((t,s)=>e(s,(e=>qt(t,((t,s)=>e(s,(e=>zt(t,e))))))))),forEachTableCell:(e,t)=>zt(Et(Q,x(e)),t),forEachRow:(e,t)=>qt(Et(G,x(e)),((e,s)=>t(s,(t=>zt(e,t))))),forEachCell:(e,t,s)=>zt(Et(Et(G,x(e)),x(t)),s),forEachValue:e=>zt(K,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,D(i=r)===D(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[pt])},addStartTransactionListener:e=>we(e,Ie),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(ye(e),ws),getListenerStats:()=>({tables:es(U),tableIds:es(X),tableCellIds:es(_),table:es(Z),rowCount:es(re),rowIds:es(oe),sortedRowIds:es(ie),row:es(de,kt),cellIds:es(ue,kt),cell:es(ce,xt),invalidCell:es(he,xt),values:es(be),valueIds:es(ge),value:es(pe),invalidValue:es(me),transaction:vt(Ie)+es(fe)}),createStore:rs,addListener:we,callListeners:Ce};return se({[h]:[0,U],[m]:[0,X],[c]:[1,Z,[pt]],[c+f]:[1,_,[pt]],[g]:[1,re,[pt]],[p]:[1,oe,[pt]],[b]:[2,de,[pt,ft]],[f]:[2,ue,[pt,ft]],[I]:[3,ce,[pt,ft,Ct],e=>_t(Vt(...e))],InvalidCell:[3,he],[C]:[0,be],[y]:[0,ge],[w]:[1,pe,[Wt],e=>_t(Gt(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?j(a,0,e):void 0,s,l)})),Y(ws)},os=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(rs),a=ie.indexOf(e);return t.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;Ot(jt,r,(()=>0)),Ot(Wt,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();le(s)&&le(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(q(o,e.delListener),g),schedule:async(...e)=>(W(Et(Wt,r),...e),await(async()=>{if(!Et(jt,r)){for($t(jt,r,1);!R(i=G(Et(Wt,r)));)try{await i()}catch(e){n?.(e)}$t(jt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Y(g)})(e,(async()=>ne(s.getItem(t))),(async e=>s.setItem(t,ae(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>ne(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,re,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!s}),await e.startAutoSave()})),$(z,null,$("aside",{id:re},$(qe,{s:l}),$(wt,{s:l})),$("style",null,Re))};exports.EditableCellView=tt,exports.EditableValueView=st,exports.RelationshipInHtmlTable=_e,exports.ResultSortedTableInHtmlTable=et,exports.ResultTableInHtmlTable=({queryId:e,queries:s,customCells:l,...a})=>$(We,{...a,params:He(je(t.useResultTableCellIds(e,s),l,t.ResultCellView),De(s,e),t.useResultRowIds(e,s))}),exports.SliceInHtmlTable=Ze,exports.SortedTableInHtmlTable=Xe,exports.SortedTablePaginator=lt,exports.StoreInspector=e=>$(os,{...e}),exports.TableInHtmlTable=({tableId:e,store:s,editable:l,customCells:a,...n})=>$(We,{...n,params:He(je(t.useTableCellIds(e,s),a,l?tt:t.CellView),Be(s,e),t.useRowIds(e,s))}),exports.ValuesInHtmlTable=Ye;
1
+ "use strict";var e=require("react"),t=require("./ui-react");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Ids",c="Table",h=c+"s",m=c+u,b="Row",g=b+"Count",p=b+u,I="Cell",f=I+u,w="Value",C=w+"s",y=w+u,v="currentTarget",k="value",x=e=>l+e,S=Math.floor,T=isFinite,V=(e,t)=>e instanceof t,R=e=>null==e,q=(e,t,s)=>R(e)?s?.():t(e),N=e=>e==a||e==n,L=e=>s(e)==o,M=e=>Array.isArray(e),{PureComponent:E,Fragment:z,createElement:$,useCallback:O,useLayoutEffect:A,useRef:F,useState:J}=e,P=(e,...t)=>R(e)?{}:e(...t),H=(e,t)=>e.forEach(t),B=(e,t)=>e.map(t),D=e=>e.length,Q=e=>0==D(e),j=(e,t,s)=>e.slice(t,s),W=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,U=K.keys,X=K.isFrozen,Y=K.freeze,Z=e=>V(e,K)&&e.constructor==K,_=(e=[])=>K.fromEntries(e),ee=(e,t)=>!R(((e,t)=>q(e,(e=>e[t])))(e,t)),te=(e,t)=>(delete e[t],e),se=(e,t)=>B(K.entries(e),(([e,s])=>t(s,e))),le=e=>Z(e)&&0==(e=>D(U(e)))(e),ae=e=>JSON.stringify(e,((e,t)=>V(t,Map)?K.fromEntries([...t]):t)),ne=JSON.parse,re="tinybaseStoreInspector",oe="TinyBase Store Inspector",ie=["left","top","bottom","right","full"],de="state",ue="sort",ce="open",he="position",me=ce,be="editable",ge=(...e)=>ae(e),pe=(e,t)=>B(e.sort(),t),Ie=(e,s)=>[!!t.useCell(de,e,be,s),O((t=>{s.setCell(de,e,be,(e=>!e)),t.preventDefault()}),[s,e])],fe="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",we='content:url("',Ce=we+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ye='</svg>")',ve=we+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",ke=B([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ye)),xe=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ye,Se=Ce+`<path d='${fe}' />`+ye,Te=Ce+`<path d='${fe}M20 20l60 60' />`+ye,Ve="*::-webkit-scrollbar",Re=`#${re}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(se({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ve]:"width:0.5rem;height:0.5rem;",[Ve+"-track"]:"background:#111",[Ve+"-thumb"]:"background:#999;border:1px solid #111",[Ve+"-thumb:hover"]:"background:#fff",[Ve+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ve,..._(B(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",..._(B(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ve,"header>img:nth-of-type(6)":xe,..._(B(ke,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Se,"details[open]>summary img.done":Te,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")))}`,qe=({s:e})=>{const s=t.useValue(he,e)??1,l=t.useSetValueCallback(me,(()=>!0),[],e);return t.useValue(me,e)?null:$("img",{onClick:l,title:oe,"data-position":s})},Ne=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(de,e,ce,r),i=t.useSetCellCallback(de,e,ce,(e=>e[v].open),[],r);return $("details",{open:o,onToggle:i},$("summary",null,s,a?$("img",{onClick:a,className:l?"done":"edit"}):null),n)},Le=e=>{const t=s(e);return N(t)||t==r&&T(e)?t:void 0},Me=(e,t,s,l,a)=>R(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),Ee=(e,t,s)=>R(s)?e.delValue(t):e.setValue(t,s),ze=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:$e,useMemo:Oe,useState:Ae}=e,Fe="editable",Je=(e,s)=>B(t.useTableCellIds(e,s),(t=>e+"."+t)),Pe=(e,t,s)=>{const l=$e(e,t);return s?l:void 0},He=(...e)=>Oe((()=>e),e),Be=(e,t)=>Oe((()=>({store:e,tableId:t})),[e,t]),De=(e,t)=>Oe((()=>({queries:e,queryId:t})),[e,t]),Qe=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Ae([e,t,l]),h=$e((e=>{c(e),o?.(e)}),[o]),m=Pe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=$e((e=>h([i,d,e])),[h,i,d]),g=!0===r?lt:r;return[[i,d,u],m,Oe((()=>!1===r?null:$(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},je=(e,t,l)=>Oe((()=>{const n=t??e;return _(se(M(n)?_(B(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)}];var n})))}),[t,l,e]),We=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===t?null:$("thead",null,$("tr",null,!1===s?null:$(Ge,{sort:r??[],label:"Id",onClick:o}),se(l,(({label:e},t)=>$(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),$("tbody",null,B(n,(e=>$("tr",{key:e},!1===s?null:$("th",null,e),se(l,(({component:t,getComponentProps:s},l)=>$("td",{key:l},$(t,{...P(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>$("th",{onClick:Pe((()=>n?.(e)),[n,e],n),className:R(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},R(s)||t!=e?null:(s?"↓":"↑")+" ",a),Ke=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return $("tr",null,!1===l?null:$(e.Fragment,null,$("th",null,s),$("th",null,u)),se(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return R(i)?null:$("td",{key:l},$(e,{...P(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Ue=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[o,i]=Ae(),[d,u]=Ae(),[c,h]=Ae(),[m,b]=Ae(),[g,p]=Ae();d!==e&&(i(Le(e)),u(e),h(e+""),b(Number(e)||0),p(!!e));const I=$e(((e,s)=>{s(e),u(e),t(e)}),[t]);return $("div",{className:s},$("button",{className:o,onClick:$e((()=>{if(!l?.()){const e=ze(o,r,n,a),s=ze(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,o])},o),ze(o,$("input",{key:o,value:c,onChange:$e((e=>I(e[v][k]+"",h)),[I])}),$("input",{key:o,type:"number",value:m,onChange:$e((e=>I(Number(e[v][k]||0),b)),[I])}),$("input",{key:o,type:"checkbox",checked:g,onChange:$e((e=>I(!!e[v].checked,p)),[I])})))},Xe=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=Qe(s,l,i,a,n,t.useRowCount(e,r),d,u);return $(We,{...h,params:He(je(t.useTableCellIds(e,r),c,o?tt:t.CellView),Be(r,e),t.useSortedRowIds(e,...m,n,r),m,b,g)})},Ye=({store:e,editable:s=!1,valueComponent:l=(s?st:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>$("table",{className:n},!1===r?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,w))),$("tbody",null,B(t.useValueIds(e),(t=>$("tr",{key:t},!1===o?null:$("th",null,t),$("td",null,$(l,{...P(a,t),valueId:t,store:e}))))))),Ze=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return $(We,{...r,params:He(je(t.useTableCellIds(d,i),n,a?tt:t.CellView),Be(i,d),t.useSliceRowIds(e,s,o))})},_e=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=je([...Je(c,u),...Je(h,u)],n,a?tt:t.CellView),b=He(i,m,c,h,s,d,u);return $("table",{className:r},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(e.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),se(m,(({label:e},t)=>$("th",{key:t},e))))),$("tbody",null,B(t.useRowIds(c,u),(e=>$(Ke,{key:e,localRowId:e,params:b})))))},et=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=Qe(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return $(We,{...c,params:He(je(t.useResultTableCellIds(e,r),d,t.ResultCellView),De(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,b)})},tt=({tableId:e,rowId:s,cellId:l,store:a,className:n})=>$(Ue,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Fe+I,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),st=({valueId:e,store:s,className:l})=>$(Ue,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Fe+w,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),lt=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Pe((()=>t(l-a)),[t,l,a],l>0),i=Pe((()=>t(l+a)),[t,l,a],l+a<s);return $(e.Fragment,null,s>a&&$(e.Fragment,null,$("button",{className:"previous",disabled:0==l,onClick:o},"←"),$("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},at=({indexes:e,indexesId:s,indexId:l,s:a})=>$(Ne,{uniqueId:ge("i",s,l),summary:"Index: "+l,s:a},B(t.useSliceIds(l,e),(t=>$(nt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a})))),nt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=ge("i",t,s,l),[r,o]=Ie(n,a);return $(Ne,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},$(Ze,{sliceId:l,indexId:s,indexes:e,editable:r}))},rt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return R(l)?null:$(Ne,{uniqueId:ge("i",e),summary:"Indexes: "+(e??d),s:s},Q(a)?"No indexes defined":pe(a,(t=>$(at,{indexes:l,indexesId:e,indexId:t,s:s}))))},ot=({metrics:e,metricId:s})=>$("tr",null,$("th",null,s),$("td",null,e?.getTableId(s)),$("td",null,t.useMetric(s,e))),it=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return R(l)?null:$(Ne,{uniqueId:ge("m",e),summary:"Metrics: "+(e??d),s:s},Q(a)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,B(a,(e=>$(ot,{metrics:l,metricId:e}))))))},dt=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=ge("q",s,l),[r,o,i]=ne(t.useCell(de,n,ue,a)??"[]"),d=t.useSetCellCallback(de,n,ue,ae,[],a);return $(Ne,{uniqueId:n,summary:"Query: "+l,s:a},$(et,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ut=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return R(l)?null:$(Ne,{uniqueId:ge("q",e),summary:"Queries: "+(e??d),s:s},Q(a)?"No queries defined":pe(a,(t=>$(dt,{queries:l,queriesId:e,queryId:t,s:s}))))},ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=ge("r",t,s),[n,r]=Ie(a,l);return $(Ne,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},$(_e,{relationshipId:s,relationships:e,editable:n}))},ht=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return R(l)?null:$(Ne,{uniqueId:ge("r",e),summary:"Relationships: "+(e??d),s:s},Q(a)?"No relationships defined":pe(a,(t=>$(ct,{relationships:l,relationshipsId:e,relationshipId:t,s:s}))))},mt=({tableId:e,store:s,storeId:l,s:a})=>{const n=ge("t",l,e),[r,o,i]=ne(t.useCell(de,n,ue,a)??"[]"),d=t.useSetCellCallback(de,n,ue,ae,[],a),[u,h]=Ie(n,a);return $(Ne,{uniqueId:n,summary:c+": "+e,editable:u,handleEditable:h,s:a},$(Xe,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},bt=({store:e,storeId:s,s:l})=>{const a=ge("v",s),[n,r]=Ie(a,l);return Q(t.useValueIds(e))?null:$(Ne,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},$(Ye,{store:e,editable:n}))},gt=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return R(l)?null:$(Ne,{uniqueId:ge("s",e),summary:"Store: "+(e??d),s:s},$(bt,{storeId:e,store:l,s:s}),pe(a,(t=>$(mt,{store:l,storeId:e,tableId:t,s:s}))))},pt=({s:e})=>{const s=F(null),l=F(0),[a,n]=J(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);A((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=S(r)+e.clientWidth&&e.scrollHeight>=S(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=O((t=>{const{scrollLeft:s,scrollTop:a}=t[v];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),g=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return R(d)&&Q(u)&&R(c)&&Q(h)&&R(m)&&Q(b)&&R(g)&&Q(p)&&R(I)&&Q(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:s,onScroll:i},$(gt,{s:e}),B(u,(t=>$(gt,{storeId:t,key:t,s:e}))),$(it,{s:e}),B(h,(t=>$(it,{metricsId:t,key:t,s:e}))),$(rt,{s:e}),B(b,(t=>$(rt,{indexesId:t,key:t,s:e}))),$(ht,{s:e}),B(p,(t=>$(ht,{relationshipsId:t,key:t,s:e}))),$(ut,{s:e}),B(f,(t=>$(ut,{queriesId:t,key:t,s:e}))))};class It extends E{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ft=({s:e})=>{const s=t.useValue(he,e)??1,l=t.useSetValueCallback(me,(()=>!1),[],e),a=t.useSetValueCallback(he,(e=>Number(e[v].dataset.id)),[],e);return $("header",null,$("img",{title:oe}),$("span",null,oe),B(ie,((e,t)=>t==s?null:$("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),$("img",{onClick:l,title:"Close"}))},wt=({s:e})=>{const s=t.useValue(he,e)??1;return t.useValue(me,e)?$("main",{"data-position":s},$(ft,{s:e}),$(It,null,$(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Vt(t).reduce(s,0);var s},yt=e=>e?.size??0,vt=Ct(yt),kt=Ct(vt),xt=Ct(kt),St=(e,t)=>e?.has(t)??!1,Tt=e=>R(e)||0==yt(e),Vt=e=>[...e?.values()??[]],Rt=e=>e.clear(),qt=(e,t)=>e?.forEach(t),Nt=(e,t)=>e?.delete(t),Lt=e=>new Map(e),Mt=e=>[...e?.keys()??[]],Et=(e,t)=>e?.get(t),zt=(e,t)=>qt(e,((e,s)=>t(s,e))),$t=(e,t,s)=>R(s)?(Nt(e,t),e):e?.set(t,s),Ot=(e,t,s)=>(St(e,t)||$t(e,t,s()),Et(e,t)),At=(e,t,s,l=$t)=>(se(t,((t,l)=>s(e,l,t))),zt(e,(s=>ee(t,s)?0:l(e,s))),e),Ft=(e,t,s)=>{const l={};return qt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Jt=(e,t,s)=>Ft(e,(e=>Ft(e,t,s)),le),Pt=(e,t,s)=>Ft(e,(e=>Jt(e,t,s)),le),Ht=(e,t)=>{const s=Lt();return qt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Bt=e=>Ht(e,Ht),Dt=e=>Ht(e,Bt),Qt=(e,t,s,l,a=0)=>q((s?Ot:Et)(e,t[a],a>D(t)-2?s:Lt),(n=>{if(a>D(t)-2)return l?.(n)&&$t(e,t[a]),n;const r=Qt(n,t,s,l,a+1);return Tt(n)&&$t(e,t[a]),r})),jt=Lt(),Wt=Lt(),Gt="storage",Kt=globalThis.window,Ut=e=>new Set(M(e)||R(e)?e:[e]),Xt=(e,t)=>e?.add(t),Yt=/^\d+$/,Zt=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??l+t++,t=>{Yt.test(t)&&D(e)<1e3&&W(e,t)}]},_t=e=>[e,e],es=(e,t=vt)=>t(e[0])+t(e[1]),ts=()=>[Lt(),Lt()],ss=e=>[...e],ls=([e,t])=>e===t,as=(e,t,s)=>R(e)||!Z(e)||le(e)||X(e)?(s?.(),!1):(se(e,((s,l)=>{t(s,l)||te(e,l)})),!le(e)),ns=(e,t,s)=>$t(e,t,Et(e,t)==-s?void 0:s),rs=()=>{let e,t,s=!1,a=!1,n=0;const o=Lt(),u=Lt(),v=Lt(),k=Lt(),S=Lt(),T=Lt(),V=Lt(),M=Lt(),E=Lt(),z=Lt(),$=Lt(),O=Lt(),A=Lt(),F=Lt(),J=Ut(),P=Lt(),Q=Lt(),G=Lt(),K=Lt(),U=ts(),X=ts(),Z=ts(),_=ts(),re=ts(),oe=ts(),ie=ts(),de=ts(),ue=ts(),ce=ts(),he=ts(),me=ts(),be=ts(),ge=ts(),pe=ts(),Ie=Lt(),fe=ts(),[we,Ce,ye,ve]=(e=>{let t;const[s,a]=Zt(),n=Lt();return[(e,a,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return $t(n,d,[e,a,r,o,i]),Xt(Qt(a,r??[l],Ut),d),d},(e,s,...a)=>H(((e,t=[l])=>{const s=[],a=(e,l)=>l==D(t)?W(s,e):null===t[l]?qt(e,(e=>a(e,l+1))):H([t[l],null],(t=>a(Et(e,t),l+1)));return a(e,0),s})(e,s),(e=>qt(e,(e=>Et(n,e)[0](t,...s??[],...a))))),e=>q(Et(n,e),(([,t,s])=>(Qt(t,s??[l],void 0,(t=>(Nt(t,e),Tt(t)?1:0))),$t(n,e),a(e),s))),e=>q(Et(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=D(r);o==D(s)?e(t,...r,...a(r)):R(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),ke=e=>{if(!as(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!N(t)&&t!=r||(Le(e[d])!=t&&te(e,d),0))},xe=(t,s)=>(!e||St($,s)||lt(s))&&as(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>as(l?s:qe(s,e,t),((l,a)=>q(Te(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),Te=(t,s,l,a)=>e?q(Et(Et($,t),l),(e=>Le(a)!=e[i]?lt(t,s,l,a,e[d]):a),(()=>lt(t,s,l,a))):R(Le(a))?lt(t,s,l,a):a,Ve=(e,t)=>as(t?e:Ne(e),((t,s)=>q(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?q(Et(A,e),(t=>Le(s)!=t[i]?at(e,s,t[d]):s),(()=>at(e,s))):R(Le(s))?at(e,s):s,qe=(e,t,s)=>(q(Et(O,t),(([l,a])=>{qt(l,((t,s)=>{ee(e,s)||(e[s]=t)})),qt(a,(l=>{ee(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(qt(F,((t,s)=>{ee(e,s)||(e[s]=t)})),qt(J,(t=>{ee(e,t)||at(t)}))),e),ze=e=>At($,e,((e,t,s)=>{const l=Lt(),a=Ut();At(Ot($,t,Lt),s,((e,t,s)=>{$t(e,t,s),q(s[d],(e=>$t(l,t,e)),(()=>Xt(a,t)))})),$t(O,t,[l,a])}),((e,t)=>{$t($,t),$t(O,t)})),$e=e=>At(A,e,((e,t,s)=>{$t(A,t,s),q(s[d],(e=>$t(F,t,e)),(()=>Xt(J,t)))}),((e,t)=>{$t(A,t),$t(F,t),Nt(J,t)})),Oe=e=>le(e)?us():Kt(e),Ae=e=>At(G,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ge(t))),Fe=(e,t)=>At(Ot(G,e,(()=>(Ye(e,1),$t(P,e,Zt()),$t(Q,e,Lt()),Lt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ke(e,t,s))),Je=(e,t,s,l,a)=>At(Ot(t,s,(()=>(Ze(e,s,1),Lt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ue(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{St(s,l)||_e(e,t,l,1);const n=Et(s,l);a!==n&&(et(e,t,l,n,a),$t(s,l,a))},He=(e,t,s,l,a)=>q(Et(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),Be=e=>le(e)?ms():Yt(e),De=e=>At(K,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{St(K,e)||tt(e,1);const s=Et(K,e);t!==s&&(st(e,s,t),$t(K,e,t))},je=(e,t)=>{const[s]=Et(P,e),l=s(t);return St(Et(G,e),l)?je(e,t):l},We=e=>Et(G,e)??Fe(e,{}),Ge=e=>Fe(e,{}),Ke=(e,t,s)=>{const[,l]=Et(P,e);l(s),Je(e,t,s,{},!0)},Ue=(e,t,s,l,a,n)=>{const r=Et(Et(O,e)?.[0],a);if(!R(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,Et(l,t)),_e(e,s,t,-1),$t(l,t)};R(r)?o(a):zt(l,o),Tt(l)&&(Ze(e,s,-1),Tt($t(t,s))&&(Ye(e,-1),$t(G,e),$t(P,e),$t(Q,e)))},Xe=e=>{const t=Et(F,e);if(!R(t))return Qe(e,t);st(e,Et(K,e)),tt(e,-1),$t(K,e)},Ye=(e,t)=>ns(o,e,t),Ze=(e,t,s)=>ns(Ot(k,e,Lt),t,s)&&$t(v,e,Ot(v,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=Et(Q,e),n=Et(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&ns(Ot(u,e,Lt),s,l),$t(a,s,n!=-l?n+l:null),ns(Ot(Ot(S,e,Lt),t,Lt),s,l)},et=(e,t,s,l,a)=>Ot(Ot(Ot(T,e,Lt),t,Lt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>ns(V,e,t),st=(e,t,s)=>Ot(M,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(W(Ot(Ot(Ot(E,e,Lt),t,Lt),s,(()=>[])),l),a),at=(e,t,s)=>(W(Ot(z,e,(()=>[])),t),s),nt=(e,t,s)=>q(Et(Et(Et(T,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,..._t(Vt(e,t,s))])),rt=e=>q(Et(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,..._t(Gt(e))])),ot=e=>Tt(E)||Tt(he[e])?0:qt(e?Dt(E):E,((t,s)=>qt(t,((t,l)=>qt(t,((t,a)=>Ce(he[e],[s,l,a],t))))))),it=e=>Tt(z)||Tt(me[e])?0:qt(e?Ht(z):z,((t,s)=>Ce(me[e],[s],t))),dt=(e,t,s)=>{if(!Tt(t))return Ce(e,s,(()=>Ft(t))),1},ut=e=>{const t=Tt(ie[e]),s=Tt(ue[e])&&Tt(_[e])&&Tt(re[e])&&Tt(oe[e])&&t&&Tt(X[e]),l=Tt(ce[e])&&Tt(de[e])&&Tt(Z[e])&&Tt(U[e]);if(!s||!l){const a=e?[Ht(o),Bt(u),Ht(v),Bt(k),Dt(S),Dt(T)]:[o,u,v,k,S,T];if(!s){dt(X[e],a[0]),qt(a[1],((t,s)=>dt(_[e],t,[s]))),qt(a[2],((t,s)=>{0!=t&&Ce(re[e],[s],It(s))}));const s=Ut();qt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(Ce(ie[e],[a,null]),Xt(s,a))})),t||qt(a[5],((t,l)=>{if(!St(s,l)){const s=Ut();qt(t,(e=>qt(e,(([t,l],a)=>l!==t?Xt(s,a):Nt(e,a))))),qt(s,(t=>Ce(ie[e],[l,t])))}})),qt(a[4],((t,s)=>qt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;qt(a[5],((s,l)=>{let a;qt(s,((s,n)=>{let r;qt(s,(([s,o],i)=>{o!==s&&(Ce(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&Ce(de[e],[l,n],nt)})),a&&Ce(Z[e],[l],nt)})),t&&Ce(U[e],void 0,nt)}}},ct=e=>{const t=Tt(ge[e]),s=Tt(pe[e])&&Tt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(M)]:[V,M];if(t||dt(ge[e],l[0]),!s){let t;qt(l[1],(([s,l],a)=>{l!==s&&(Ce(pe[e],[a],l,s,rt),t=1)})),t&&Ce(be[e],void 0,rt)}}},ht=(e,...t)=>(ps((()=>e(...B(t,x)))),ws),mt=()=>[Ft(T,((e,t)=>-1===Et(o,t)?null:Ft(e,((e,s)=>-1===Et(Et(k,t),s)?null:Ft(e,(([,e])=>e??null),((e,t)=>ls(t)))),le)),le),Ft(M,(([,e])=>e??null),((e,t)=>ls(t)))],bt=()=>({cellsTouched:s,valuesTouched:a,changedCells:Pt(T,ss,ls),invalidCells:Pt(E),changedValues:Ft(M,ss,ls),invalidValues:Ft(z),changedTableIds:Ft(o),changedRowIds:Jt(k),changedCellIds:Pt(S),changedValueIds:Ft(V)}),gt=()=>Pt(G),pt=()=>Mt(G),It=e=>yt(Et(G,x(e))),ft=e=>Mt(Et(G,x(e))),wt=(e,t,s,l=0,a)=>{return B(j((r=Et(G,x(e)),o=(e,s)=>[R(t)?s:Et(e,x(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),B([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,R(a)?a:l+a),(([,e])=>e));var n,r,o},Ct=(e,t)=>Mt(Et(Et(G,x(e)),x(t))),Vt=(e,t,s)=>Et(Et(Et(G,x(e)),x(t)),x(s)),jt=()=>Ft(K),Wt=()=>Mt(K),Gt=e=>Et(K,x(e)),Kt=e=>ht((()=>(e=>as(e,xe,lt))(e)?Ae(e):0)),Yt=e=>ht((()=>Ve(e)?De(e):0)),os=e=>{try{Oe(ne(e))}catch{}return ws},is=t=>ht((()=>{if((e=as(t,(e=>as(e,ke))))&&(ze(t),!Tt(G))){const e=gt();us(),Kt(e)}})),ds=e=>ht((()=>{if(t=(e=>as(e,ke))(e)){const s=jt();gs(),ms(),t=!0,$e(e),Yt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>St(G,e)?Ge(e):0),e),hs=(e,t)=>ht(((e,t)=>q(Et(G,e),(s=>St(s,t)?Ke(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{ze({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),ps=(e,t)=>{if(-1!=n){Is();const s=e();return fs(t),s}},Is=()=>(-1!=n&&n++,1==n&&Ce(Ie,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Tt(T),a=!Tt(M),n=1,ot(1),s&&ut(1),it(1),a&&ct(1),e?.(mt,bt)&&(qt(T,((e,t)=>qt(e,((e,s)=>qt(e,(([e],l)=>Me(ws,t,s,l,e))))))),qt(M,(([e],t)=>Ee(ws,t,e))),s=a=!1),Ce(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),a&&ct(0),Ce(fe[1],void 0,mt,bt),n=0,s=a=!1,H([o,u,v,k,S,T,E,V,M,z],Rt))),ws),ws={getContent:()=>[gt(),jt()],getTables:gt,getTableIds:pt,getTable:e=>Jt(Et(G,x(e))),getTableCellIds:e=>Mt(Et(Q,x(e))),getRowCount:It,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Ft(Et(Et(G,x(e)),x(t))),getCellIds:Ct,getCell:Vt,getValues:jt,getValueIds:Wt,getValue:Gt,hasTables:()=>!Tt(G),hasTable:e=>St(G,x(e)),hasTableCell:(e,t)=>St(Et(Q,x(e)),x(t)),hasRow:(e,t)=>St(Et(G,x(e)),x(t)),hasCell:(e,t,s)=>St(Et(Et(G,x(e)),x(t)),x(s)),hasValues:()=>!Tt(K),hasValue:e=>St(K,x(e)),getTablesJson:()=>ae(G),getValuesJson:()=>ae(K),getJson:()=>ae([G,K]),getTablesSchemaJson:()=>ae($),getValuesSchemaJson:()=>ae(A),getSchemaJson:()=>ae([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(le(e)?us:Kt)(e),(le(t)?ms:Yt)(t)})),setTables:Kt,setTable:(e,t)=>ht((e=>xe(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>ps((()=>{let l;return Se(e,l,t)&&(e=x(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);se(s,((s,a)=>He(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>q(Te(e,t,s,L(l)?l(Vt(e,t,s)):l),(l=>He(e,We(e),t,s,l)))),e,t,s),setValues:Yt,setPartialValues:e=>ht((()=>Ve(e,1)?se(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>q(Re(e,L(t)?t(Gt(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{se(e[0],((e,t)=>R(e)?cs(t):se(e,((e,s)=>R(e)?hs(t,s):se(e,((e,l)=>Me(ws,t,s,l,e))))))),se(e[1],((e,t)=>Ee(ws,t,e)))})),setTablesJson:os,setValuesJson:e=>{try{Be(ne(e))}catch{}return ws},setJson:e=>{try{const[t,s]=ne(e);Oe(t),Be(s)}catch{os(e)}return ws},setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>q(Et(G,e),(a=>q(Et(a,t),(n=>St(n,s)?Ue(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>St(K,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:ps,startTransaction:Is,finishTransaction:fs,forEachTable:e=>qt(G,((t,s)=>e(s,(e=>qt(t,((t,s)=>e(s,(e=>zt(t,e))))))))),forEachTableCell:(e,t)=>zt(Et(Q,x(e)),t),forEachRow:(e,t)=>qt(Et(G,x(e)),((e,s)=>t(s,(t=>zt(e,t))))),forEachCell:(e,t,s)=>zt(Et(Et(G,x(e)),x(t)),s),forEachValue:e=>zt(K,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,D(i=r)===D(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[pt])},addStartTransactionListener:e=>we(e,Ie),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(ye(e),ws),getListenerStats:()=>({tables:es(U),tableIds:es(X),tableCellIds:es(_),table:es(Z),rowCount:es(re),rowIds:es(oe),sortedRowIds:es(ie),row:es(de,kt),cellIds:es(ue,kt),cell:es(ce,xt),invalidCell:es(he,xt),values:es(be),valueIds:es(ge),value:es(pe),invalidValue:es(me),transaction:vt(Ie)+es(fe)}),createStore:rs,addListener:we,callListeners:Ce};return se({[h]:[0,U],[m]:[0,X],[c]:[1,Z,[pt]],[c+f]:[1,_,[pt]],[g]:[1,re,[pt]],[p]:[1,oe,[pt]],[b]:[2,de,[pt,ft]],[f]:[2,ue,[pt,ft]],[I]:[3,ce,[pt,ft,Ct],e=>_t(Vt(...e))],InvalidCell:[3,he],[C]:[0,be],[y]:[0,ge],[w]:[1,pe,[Wt],e=>_t(Gt(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?j(a,0,e):void 0,s,l)})),Y(ws)},os=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(rs),a=ie.indexOf(e);return t.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;Ot(jt,r,(()=>0)),Ot(Wt,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();le(s)&&le(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(q(o,e.delListener),g),schedule:async(...e)=>(W(Et(Wt,r),...e),await(async()=>{if(!Et(jt,r)){for($t(jt,r,1);!R(i=G(Et(Wt,r)));)try{await i()}catch(e){n?.(e)}$t(jt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Y(g)})(e,(async()=>ne(s.getItem(t))),(async e=>s.setItem(t,ae(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>ne(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,re,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!s}),await e.startAutoSave()})),$(z,null,$("aside",{id:re},$(qe,{s:l}),$(wt,{s:l})),$("style",null,Re))};exports.EditableCellView=tt,exports.EditableValueView=st,exports.RelationshipInHtmlTable=_e,exports.ResultSortedTableInHtmlTable=et,exports.ResultTableInHtmlTable=({queryId:e,queries:s,customCells:l,...a})=>$(We,{...a,params:He(je(t.useResultTableCellIds(e,s),l,t.ResultCellView),De(s,e),t.useResultRowIds(e,s))}),exports.SliceInHtmlTable=Ze,exports.SortedTableInHtmlTable=Xe,exports.SortedTablePaginator=lt,exports.StoreInspector=e=>$(os,{...e}),exports.TableInHtmlTable=({tableId:e,store:s,editable:l,customCells:a,...n})=>$(We,{...n,params:He(je(t.useTableCellIds(e,s),a,l?tt:t.CellView),Be(s,e),t.useRowIds(e,s))}),exports.ValuesInHtmlTable=Ye;
Binary file
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("./ui-react");const l=e=>typeof e,a=l(""),o=l(!0),n=l(0),r="Value",s="currentTarget",i="value",d=isFinite,u=e=>null==e,{PureComponent:m,Fragment:c,createElement:h,useCallback:b,useLayoutEffect:g,useRef:p,useState:w}=e,f=(e,...t)=>u(e)?{}:e(...t),I=(e,t)=>e.map(t),C=Object,y=(e=[])=>C.fromEntries(e),x=(e,t)=>I(C.entries(e),(([e,l])=>t(l,e))),k="tinybaseStoreInspector",v="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',T=R+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',N=R+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",V=I([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=T+"<path d='M20 20l60 60M20 80l60-60' />"+S,$=T+`<path d='${v}' />`+S,M=T+`<path d='${v}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(x({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[q]:"width:0.5rem;height:0.5rem;",[q+"-track"]:"background:#111",[q+"-thumb"]:"background:#999;border:1px solid #111",[q+"-thumb:hover"]:"background:#fff",[q+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+N,...y(I(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...y(I(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":N,"header>img:nth-of-type(6)":z,...y(I(V,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":$,"details[open]>summary img.done":M,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${k} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${k} ${t}{${e}}`:"")));const H=(e,t,l,o)=>e==a?t:e==n?l:o,{useCallback:O,useMemo:B,useState:F}=e,E="editable",P=(e,l)=>I(t.useTableCellIds(e,l),(t=>e+"."+t)),j=(e,t,l)=>{const a=O(e,t);return l?a:void 0},A=(...e)=>B((()=>e),e),L=(e,t)=>B((()=>({store:e,tableId:t})),[e,t]),D=(e,t)=>B((()=>({queries:e,queryId:t})),[e,t]),G=(e,t=!1,l,a=0,o,n,r,s)=>{const[[i,d,u],m]=F([e,t,a]),c=O((e=>{m(e),s?.(e)}),[s]),b=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=O((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],b,B((()=>!1===r?null:h(p,{offset:u,limit:o,total:n,onChange:g})),[r,p,u,o,n,g])]},J=(e,t,o)=>B((()=>{const n=t??e;return y(x(Array.isArray(n)?y(I(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:o,...(n=e,l(n)==a?{label:e}:e)}];var n})))}),[t,o,e]),K=({className:e,headerRow:t,idColumn:l,params:[a,o,n,r,s,i]})=>h("table",{className:e},i?h("caption",null,i):null,!1===t?null:h("thead",null,h("tr",null,!1===l?null:h(Q,{sort:r??[],label:"Id",onClick:s}),x(a,(({label:e},t)=>h(Q,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),h("tbody",null,I(n,(e=>h("tr",{key:e},!1===l?null:h("th",null,e),x(a,(({component:t,getComponentProps:l},a)=>h("td",{key:a},h(t,{...f(l,e,a),...o,rowId:e,cellId:a}))))))))),Q=({cellId:e,sort:[t,l],label:a=e??"",onClick:o})=>h("th",{onClick:j((()=>o?.(e)),[o,e],o),className:u(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},u(l)||t!=e?null:(l?"↓":"↑")+" ",a),U=({localRowId:l,params:[a,o,n,r,s,i,d]})=>{const m=t.useRemoteRowId(s,l,i);return h("tr",null,!1===a?null:h(e.Fragment,null,h("th",null,l),h("th",null,m)),x(o,(({component:e,getComponentProps:t},a)=>{const[o,s]=a.split(".",2),i=o===n?l:o===r?m:null;return u(i)?null:h("td",{key:a},h(e,{...f(t,i,s),store:d,tableId:o,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:r,hasSchema:u})=>{const[m,c]=F(),[b,g]=F(),[p,w]=F(),[f,I]=F(),[C,y]=F();b!==e&&(c((e=>{const t=l(e);return(e=>e==a||e==o)(t)||t==n&&d(e)?t:void 0})(e)),g(e),w(e+""),I(Number(e)||0),y(!!e));const x=O(((e,l)=>{l(e),g(e),t(e)}),[t]);return h("div",{className:r},h("button",{className:m,onClick:O((()=>{if(!u?.()){const e=H(m,n,o,a),l=H(e,p,f,C);c(e),g(l),t(l)}}),[u,t,p,f,C,m])},m),H(m,h("input",{key:m,value:p,onChange:O((e=>x(e[s][i]+"",w)),[x])}),h("input",{key:m,type:"number",value:f,onChange:O((e=>x(Number(e[s][i]||0),I)),[x])}),h("input",{key:m,type:"checkbox",checked:C,onChange:O((e=>x(!!e[s].checked,y)),[x])})))},X=({tableId:e,rowId:l,cellId:a,store:o,className:n})=>h(W,{thing:t.useCell(e,l,a,o),onThingChange:t.useSetCellCallback(e,l,a,(e=>e),[],o),className:n??E+"Cell",hasSchema:t.useStoreOrStoreById(o)?.hasTablesSchema}),Y=({valueId:e,store:l,className:a})=>h(W,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:a??E+r,hasSchema:t.useStoreOrStoreById(l)?.hasValuesSchema}),Z=({onChange:t,total:l,offset:a=0,limit:o=l,singular:n="row",plural:r=n+"s"})=>{(a>l||a<0)&&(a=0,t(0));const s=j((()=>t(a-o)),[t,a,o],a>0),i=j((()=>t(a+o)),[t,a,o],a+o<l);return h(e.Fragment,null,l>o&&h(e.Fragment,null,h("button",{className:"previous",disabled:0==a,onClick:s},"←"),h("button",{className:"next",disabled:a+o>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+o)," of "),l," ",1!=l?r:n)},_=e=>new Map(e);_(),_(),exports.EditableCellView=X,exports.EditableValueView=Y,exports.RelationshipInHtmlTable=({relationshipId:l,relationships:a,editable:o,customCells:n,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(a),l),b=J([...P(m,u),...P(c,u)],n,o?X:t.CellView),g=A(i,b,m,c,l,d,u);return h("table",{className:r},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h(e.Fragment,null,h("th",null,m,".Id"),h("th",null,c,".Id")),x(b,(({label:e},t)=>h("th",{key:t},e))))),h("tbody",null,I(t.useRowIds(m,u),(e=>h(U,{key:e,localRowId:e,params:g})))))},exports.ResultSortedTableInHtmlTable=({queryId:e,cellId:l,descending:a,offset:o,limit:n,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,b,g]=G(l,a,s,o,n,t.useResultRowCount(e,r),i,u);return h(K,{...m,params:A(J(t.useResultTableCellIds(e,r),d,t.ResultCellView),D(r,e),t.useResultSortedRowIds(e,...c,n,r),c,b,g)})},exports.ResultTableInHtmlTable=({queryId:e,queries:l,customCells:a,...o})=>h(K,{...o,params:A(J(t.useResultTableCellIds(e,l),a,t.ResultCellView),D(l,e),t.useResultRowIds(e,l))}),exports.SliceInHtmlTable=({indexId:e,sliceId:l,indexes:a,editable:o,customCells:n,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(a),e);return h(K,{...r,params:A(J(t.useTableCellIds(d,i),n,o?X:t.CellView),L(i,d),t.useSliceRowIds(e,l,s))})},exports.SortedTableInHtmlTable=({tableId:e,cellId:l,descending:a,offset:o,limit:n,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[b,g,p]=G(l,a,i,o,n,t.useRowCount(e,r),d,u);return h(K,{...c,params:A(J(t.useTableCellIds(e,r),m,s?X:t.CellView),L(r,e),t.useSortedRowIds(e,...b,n,r),b,g,p)})},exports.SortedTablePaginator=Z,exports.StoreInspector=e=>null,exports.TableInHtmlTable=({tableId:e,store:l,editable:a,customCells:o,...n})=>h(K,{...n,params:A(J(t.useTableCellIds(e,l),o,a?X:t.CellView),L(l,e),t.useRowIds(e,l))}),exports.ValuesInHtmlTable=({store:e,editable:l=!1,valueComponent:a=(l?Y:t.ValueView),getValueComponentProps:o,className:n,headerRow:s,idColumn:i})=>h("table",{className:n},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h("th",null,"Id"),h("th",null,r))),h("tbody",null,I(t.useValueIds(e),(t=>h("tr",{key:t},!1===i?null:h("th",null,t),h("td",null,h(a,{...f(o,t),valueId:t,store:e})))))));
1
+ "use strict";var e=require("react"),t=require("./ui-react");const l=e=>typeof e,a=l(""),o=l(!0),n=l(0),r="Value",s="currentTarget",i="value",d=isFinite,u=e=>null==e,{PureComponent:m,Fragment:h,createElement:c,useCallback:b,useLayoutEffect:g,useRef:p,useState:w}=e,f=(e,...t)=>u(e)?{}:e(...t),I=(e,t)=>e.map(t),C=Object,k=(e=[])=>C.fromEntries(e),y=(e,t)=>I(C.entries(e),(([e,l])=>t(l,e))),v="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",x='content:url("',R=x+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",T='</svg>")',S=x+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",N=I([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+T)),V=R+"<path d='M20 20l60 60M20 80l60-60' />"+T,z=R+`<path d='${v}' />`+T,M=R+`<path d='${v}M20 20l60 60' />`+T,$="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(y({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[$]:"width:0.5rem;height:0.5rem;",[$+"-track"]:"background:#111",[$+"-thumb"]:"background:#999;border:1px solid #111",[$+"-thumb:hover"]:"background:#fff",[$+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+S,...k(I(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...k(I(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":S,"header>img:nth-of-type(6)":V,...k(I(N,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":z,"details[open]>summary img.done":M,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")));const q=(e,t,l,o)=>e==a?t:e==n?l:o,{useCallback:H,useMemo:O,useState:B}=e,F="editable",E=(e,l)=>I(t.useTableCellIds(e,l),(t=>e+"."+t)),P=(e,t,l)=>{const a=H(e,t);return l?a:void 0},j=(...e)=>O((()=>e),e),A=(e,t)=>O((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>O((()=>({queries:e,queryId:t})),[e,t]),D=(e,t=!1,l,a=0,o,n,r,s)=>{const[[i,d,u],m]=B([e,t,a]),h=H((e=>{m(e),s?.(e)}),[s]),b=P((e=>h([e,e==i&&!d,u])),[h,i,d,u],l),g=H((e=>h([i,d,e])),[h,i,d]),p=!0===r?Y:r;return[[i,d,u],b,O((()=>!1===r?null:c(p,{offset:u,limit:o,total:n,onChange:g})),[r,p,u,o,n,g])]},G=(e,t,o)=>O((()=>{const n=t??e;return k(y(Array.isArray(n)?k(I(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:o,...(n=e,l(n)==a?{label:e}:e)}];var n})))}),[t,o,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,o,n,r,s,i]})=>c("table",{className:e},i?c("caption",null,i):null,!1===t?null:c("thead",null,c("tr",null,!1===l?null:c(K,{sort:r??[],label:"Id",onClick:s}),y(a,(({label:e},t)=>c(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),c("tbody",null,I(n,(e=>c("tr",{key:e},!1===l?null:c("th",null,e),y(a,(({component:t,getComponentProps:l},a)=>c("td",{key:a},c(t,{...f(l,e,a),...o,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:o})=>c("th",{onClick:P((()=>o?.(e)),[o,e],o),className:u(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},u(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:l,params:[a,o,n,r,s,i,d]})=>{const m=t.useRemoteRowId(s,l,i);return c("tr",null,!1===a?null:c(e.Fragment,null,c("th",null,l),c("th",null,m)),y(o,(({component:e,getComponentProps:t},a)=>{const[o,s]=a.split(".",2),i=o===n?l:o===r?m:null;return u(i)?null:c("td",{key:a},c(e,{...f(t,i,s),store:d,tableId:o,rowId:i,cellId:s}))})))},U=({thing:e,onThingChange:t,className:r,hasSchema:u})=>{const[m,h]=B(),[b,g]=B(),[p,w]=B(),[f,I]=B(),[C,k]=B();b!==e&&(h((e=>{const t=l(e);return(e=>e==a||e==o)(t)||t==n&&d(e)?t:void 0})(e)),g(e),w(e+""),I(Number(e)||0),k(!!e));const y=H(((e,l)=>{l(e),g(e),t(e)}),[t]);return c("div",{className:r},c("button",{className:m,onClick:H((()=>{if(!u?.()){const e=q(m,n,o,a),l=q(e,p,f,C);h(e),g(l),t(l)}}),[u,t,p,f,C,m])},m),q(m,c("input",{key:m,value:p,onChange:H((e=>y(e[s][i]+"",w)),[y])}),c("input",{key:m,type:"number",value:f,onChange:H((e=>y(Number(e[s][i]||0),I)),[y])}),c("input",{key:m,type:"checkbox",checked:C,onChange:H((e=>y(!!e[s].checked,k)),[y])})))},W=({tableId:e,rowId:l,cellId:a,store:o,className:n})=>c(U,{thing:t.useCell(e,l,a,o),onThingChange:t.useSetCellCallback(e,l,a,(e=>e),[],o),className:n??F+"Cell",hasSchema:t.useStoreOrStoreById(o)?.hasTablesSchema}),X=({valueId:e,store:l,className:a})=>c(U,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:a??F+r,hasSchema:t.useStoreOrStoreById(l)?.hasValuesSchema}),Y=({onChange:t,total:l,offset:a=0,limit:o=l,singular:n="row",plural:r=n+"s"})=>{(a>l||a<0)&&(a=0,t(0));const s=P((()=>t(a-o)),[t,a,o],a>0),i=P((()=>t(a+o)),[t,a,o],a+o<l);return c(e.Fragment,null,l>o&&c(e.Fragment,null,c("button",{className:"previous",disabled:0==a,onClick:s},"←"),c("button",{className:"next",disabled:a+o>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+o)," of "),l," ",1!=l?r:n)},Z=e=>new Map(e);Z(),Z(),exports.EditableCellView=W,exports.EditableValueView=X,exports.RelationshipInHtmlTable=({relationshipId:l,relationships:a,editable:o,customCells:n,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(a),l),b=G([...E(m,u),...E(h,u)],n,o?W:t.CellView),g=j(i,b,m,h,l,d,u);return c("table",{className:r},!1===s?null:c("thead",null,c("tr",null,!1===i?null:c(e.Fragment,null,c("th",null,m,".Id"),c("th",null,h,".Id")),y(b,(({label:e},t)=>c("th",{key:t},e))))),c("tbody",null,I(t.useRowIds(m,u),(e=>c(Q,{key:e,localRowId:e,params:g})))))},exports.ResultSortedTableInHtmlTable=({queryId:e,cellId:l,descending:a,offset:o,limit:n,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[h,b,g]=D(l,a,s,o,n,t.useResultRowCount(e,r),i,u);return c(J,{...m,params:j(G(t.useResultTableCellIds(e,r),d,t.ResultCellView),L(r,e),t.useResultSortedRowIds(e,...h,n,r),h,b,g)})},exports.ResultTableInHtmlTable=({queryId:e,queries:l,customCells:a,...o})=>c(J,{...o,params:j(G(t.useResultTableCellIds(e,l),a,t.ResultCellView),L(l,e),t.useResultRowIds(e,l))}),exports.SliceInHtmlTable=({indexId:e,sliceId:l,indexes:a,editable:o,customCells:n,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(a),e);return c(J,{...r,params:j(G(t.useTableCellIds(d,i),n,o?W:t.CellView),A(i,d),t.useSliceRowIds(e,l,s))})},exports.SortedTableInHtmlTable=({tableId:e,cellId:l,descending:a,offset:o,limit:n,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...h})=>{const[b,g,p]=D(l,a,i,o,n,t.useRowCount(e,r),d,u);return c(J,{...h,params:j(G(t.useTableCellIds(e,r),m,s?W:t.CellView),A(r,e),t.useSortedRowIds(e,...b,n,r),b,g,p)})},exports.SortedTablePaginator=Y,exports.StoreInspector=e=>null,exports.TableInHtmlTable=({tableId:e,store:l,editable:a,customCells:o,...n})=>c(J,{...n,params:j(G(t.useTableCellIds(e,l),o,a?W:t.CellView),A(l,e),t.useRowIds(e,l))}),exports.ValuesInHtmlTable=({store:e,editable:l=!1,valueComponent:a=(l?X:t.ValueView),getValueComponentProps:o,className:n,headerRow:s,idColumn:i})=>c("table",{className:n},!1===s?null:c("thead",null,c("tr",null,!1===i?null:c("th",null,"Id"),c("th",null,r))),c("tbody",null,I(t.useValueIds(e),(t=>c("tr",{key:t},!1===i?null:c("th",null,t),c("td",null,c(a,{...f(o,t),valueId:t,store:e})))))));
Binary file
@@ -1 +1 @@
1
- "use strict";var e=require("react"),l=require("./ui-react");const t=e=>typeof e,n="",s=t(n),r=t(!0),o=t(0),a=t(t),i="type",u="default",d="Ids",c="Table",h=c+"s",m=c+d,b="Row",p=b+"Count",v=b+d,g="Cell",I=g+d,f="Value",y=f+"s",w=f+d,C="currentTarget",x="value",k=e=>n+e,S=Math.floor,T=isFinite,V=(e,l)=>e instanceof l,R=e=>null==e,O=(e,l,t)=>R(e)?null==t?void 0:t():l(e),q=e=>e==s||e==r,P=e=>t(e)==a,N=e=>Array.isArray(e),{PureComponent:E,Fragment:L,createElement:M,useCallback:j,useLayoutEffect:z,useRef:$,useState:A}=e,F=(e,...l)=>R(e)?{}:e(...l),J=(e,l)=>e.forEach(l),H=(e,l)=>e.map(l),D=e=>e.length,B=e=>0==D(e),Q=(e,l,t)=>e.slice(l,t),W=(e,...l)=>e.push(...l),G=e=>e.shift(),K=Object,U=K.keys,X=K.isFrozen,Y=K.freeze,Z=e=>V(e,K)&&e.constructor==K,_=(e=[])=>K.fromEntries(e),ee=(e,l)=>!R(((e,l)=>O(e,(e=>e[l])))(e,l)),le=(e,l)=>(delete e[l],e),te=(e,l)=>H(K.entries(e),(([e,t])=>l(t,e))),ne=e=>Z(e)&&0==(e=>D(U(e)))(e),se=e=>JSON.stringify(e,((e,l)=>V(l,Map)?K.fromEntries([...l]):l)),re=JSON.parse,oe="tinybaseStoreInspector",ae="TinyBase Store Inspector",ie=["left","top","bottom","right","full"],ue="state",de="sort",ce="open",he="position",me=ce,be="editable",pe=(...e)=>se(e),ve=(e,l)=>H(e.sort(),l),ge=(e,t)=>[!!l.useCell(ue,e,be,t),j((l=>{t.setCell(ue,e,be,(e=>!e)),l.preventDefault()}),[t,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",fe='content:url("',ye=fe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",we='</svg>")',Ce=fe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",xe=H([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>ye+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+we)),ke=ye+"<path d='M20 20l60 60M20 80l60-60' />"+we,Se=ye+`<path d='${Ie}' />`+we,Te=ye+`<path d='${Ie}M20 20l60 60' />`+we;var Ve=Object.defineProperty,Re=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Ee=(e,l,t)=>l in e?Ve(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Le=(e,l)=>{for(var t in l||(l={}))Pe.call(l,t)&&Ee(e,t,l[t]);if(qe)for(var t of qe(l))Ne.call(l,t)&&Ee(e,t,l[t]);return e},Me=(e,l)=>Re(e,Oe(l));const je="*::-webkit-scrollbar",ze=((e,l="")=>e.join(l))(te(Me(Le(Me(Le(Me(Le({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[je]:"width:0.5rem;height:0.5rem;",[je+"-track"]:"background:#111",[je+"-thumb"]:"background:#999;border:1px solid #111",[je+"-thumb:hover"]:"background:#fff",[je+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ce},_(H(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),_(H(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ce,"header>img:nth-of-type(6)":ke}),_(H(xe,((e,l)=>[`header>img[data-id='${l}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Se,"details[open]>summary img.done":Te,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${oe} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,l)=>e?`#${oe} ${l}{${e}}`:""))),$e=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1,s=l.useSetValueCallback(me,(()=>!0),[],e);return l.useValue(me,e)?null:M("img",{onClick:s,title:ae,"data-position":n})},Ae=({uniqueId:e,summary:t,editable:n,handleEditable:s,children:r,s:o})=>{const a=!!l.useCell(ue,e,ce,o),i=l.useSetCellCallback(ue,e,ce,(e=>e[C].open),[],o);return M("details",{open:a,onToggle:i},M("summary",null,t,s?M("img",{onClick:s,className:n?"done":"edit"}):null),r)},Fe=e=>{const l=t(e);return q(l)||l==o&&T(e)?l:void 0},Je=(e,l,t,n,s)=>R(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),He=(e,l,t)=>R(t)?e.delValue(l):e.setValue(l,t),De=(e,l,t,n)=>e==s?l:e==o?t:n;var Be=Object.defineProperty,Qe=Object.defineProperties,We=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,Xe=(e,l,t)=>l in e?Be(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ye=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Xe(e,t,l[t]);if(Ge)for(var t of Ge(l))Ue.call(l,t)&&Xe(e,t,l[t]);return e},Ze=(e,l)=>Qe(e,We(l)),_e=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Ue.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:el,useMemo:ll,useState:tl}=e,nl="editable",sl=(e,t)=>H(l.useTableCellIds(e,t),(l=>e+"."+l)),rl=(e,l,t)=>{const n=el(e,l);return t?n:void 0},ol=(...e)=>ll((()=>e),e),al=(e,l)=>ll((()=>({store:e,tableId:l})),[e,l]),il=(e,l)=>ll((()=>({queries:e,queryId:l})),[e,l]),ul=(e,l=!1,t,n=0,s,r,o,a)=>{const[[i,u,d],c]=tl([e,l,n]),h=el((e=>{c(e),null==a||a(e)}),[a]),m=rl((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=el((e=>h([i,u,e])),[h,i,u]),p=!0===o?Cl:o;return[[i,u,d],m,ll((()=>!1===o?null:M(p,{offset:d,limit:s,total:r,onChange:b})),[o,p,d,s,r,b])]},dl=(e,l,n)=>ll((()=>{const r=null!=l?l:e;return _(te(N(r)?_(H(r,(e=>[e,e]))):r,((e,l)=>{return[l,Ye(Ye({},{label:l,component:n}),(r=e,t(r)==s?{label:e}:e))];var r})))}),[l,n,e]),cl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,o,a,i]})=>M("table",{className:e},i?M("caption",null,i):null,!1===l?null:M("thead",null,M("tr",null,!1===t?null:M(hl,{sort:null!=o?o:[],label:"Id",onClick:a}),te(n,(({label:e},l)=>M(hl,{key:l,cellId:l,label:e,sort:null!=o?o:[],onClick:a}))))),M("tbody",null,H(r,(e=>M("tr",{key:e},!1===t?null:M("th",null,e),te(n,(({component:l,getComponentProps:t},n)=>M("td",{key:n},M(l,Ze(Ye(Ye({},F(t,e,n)),s),{rowId:e,cellId:n})))))))))),hl=({cellId:e,sort:[l,t],label:s=(null!=e?e:n),onClick:r})=>M("th",{onClick:rl((()=>null==r?void 0:r(e)),[r,e],r),className:R(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},R(t)||l!=e?null:(t?"↓":"↑")+" ",s),ml=({localRowId:t,params:[n,s,r,o,a,i,u]})=>{const d=l.useRemoteRowId(a,t,i);return M("tr",null,!1===n?null:M(e.Fragment,null,M("th",null,t),M("th",null,d)),te(s,(({component:e,getComponentProps:l},n)=>{const[s,a]=n.split(".",2),i=s===r?t:s===o?d:null;return R(i)?null:M("td",{key:n},M(e,Ze(Ye({},F(l,i,a)),{store:u,tableId:s,rowId:i,cellId:a})))})))},bl=({thing:e,onThingChange:l,className:t,hasSchema:n})=>{const[a,i]=tl(),[u,d]=tl(),[c,h]=tl(),[m,b]=tl(),[p,v]=tl();u!==e&&(i(Fe(e)),d(e),h(e+""),b(Number(e)||0),v(!!e));const g=el(((e,t)=>{t(e),d(e),l(e)}),[l]);return M("div",{className:t},M("button",{className:a,onClick:el((()=>{if(!(null==n?void 0:n())){const e=De(a,o,r,s),t=De(e,c,m,p);i(e),d(t),l(t)}}),[n,l,c,m,p,a])},a),De(a,M("input",{key:a,value:c,onChange:el((e=>g(e[C][x]+"",h)),[g])}),M("input",{key:a,type:"number",value:m,onChange:el((e=>g(Number(e[C][x]||0),b)),[g])}),M("input",{key:a,type:"checkbox",checked:p,onChange:el((e=>g(!!e[C].checked,v)),[g])})))},pl=e=>{var t=e,{tableId:n,cellId:s,descending:r,offset:o,limit:a,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=t,b=_e(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,v,g]=ul(s,r,d,o,a,l.useRowCount(n,i),c,h);return M(cl,Ze(Ye({},b),{params:ol(dl(l.useTableCellIds(n,i),m,u?yl:l.CellView),al(i,n),l.useSortedRowIds(n,...p,a,i),p,v,g)}))},vl=({store:e,editable:t=!1,valueComponent:n=(t?wl:l.ValueView),getValueComponentProps:s,className:r,headerRow:o,idColumn:a})=>M("table",{className:r},!1===o?null:M("thead",null,M("tr",null,!1===a?null:M("th",null,"Id"),M("th",null,f))),M("tbody",null,H(l.useValueIds(e),(l=>M("tr",{key:l},!1===a?null:M("th",null,l),M("td",null,M(n,Ze(Ye({},F(s,l)),{valueId:l,store:e})))))))),gl=e=>{var t=e,{indexId:n,sliceId:s,indexes:r,editable:o,customCells:a}=t,i=_e(t,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(l.useIndexesOrIndexesById(r),n);return M(cl,Ze(Ye({},i),{params:ol(dl(l.useTableCellIds(c,d),a,o?yl:l.CellView),al(d,c),l.useSliceRowIds(n,s,u))}))},Il=({relationshipId:t,relationships:n,editable:s,customCells:r,className:o,headerRow:a,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(l.useRelationshipsOrRelationshipsById(n),t),m=dl([...sl(c,d),...sl(h,d)],r,s?yl:l.CellView),b=ol(i,m,c,h,t,u,d);return M("table",{className:o},!1===a?null:M("thead",null,M("tr",null,!1===i?null:M(e.Fragment,null,M("th",null,c,".Id"),M("th",null,h,".Id")),te(m,(({label:e},l)=>M("th",{key:l},e))))),M("tbody",null,H(l.useRowIds(c,d),(e=>M(ml,{key:e,localRowId:e,params:b})))))},fl=e=>{var t=e,{queryId:n,cellId:s,descending:r,offset:o,limit:a,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=t,m=_e(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,v]=ul(s,r,u,o,a,l.useResultRowCount(n,i),d,h);return M(cl,Ze(Ye({},m),{params:ol(dl(l.useResultTableCellIds(n,i),c,l.ResultCellView),il(i,n),l.useResultSortedRowIds(n,...b,a,i),b,p,v)}))},yl=({tableId:e,rowId:t,cellId:n,store:s,className:r})=>{var o;return M(bl,{thing:l.useCell(e,t,n,s),onThingChange:l.useSetCellCallback(e,t,n,(e=>e),[],s),className:null!=r?r:nl+g,hasSchema:null==(o=l.useStoreOrStoreById(s))?void 0:o.hasTablesSchema})},wl=({valueId:e,store:t,className:n})=>{var s;return M(bl,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=n?n:nl+f,hasSchema:null==(s=l.useStoreOrStoreById(t))?void 0:s.hasValuesSchema})},Cl=({onChange:l,total:t,offset:n=0,limit:s=t,singular:r="row",plural:o=r+"s"})=>{(n>t||n<0)&&(n=0,l(0));const a=rl((()=>l(n-s)),[l,n,s],n>0),i=rl((()=>l(n+s)),[l,n,s],n+s<t);return M(e.Fragment,null,t>s&&M(e.Fragment,null,M("button",{className:"previous",disabled:0==n,onClick:a},"←"),M("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?o:r)},xl=({indexes:e,indexesId:t,indexId:n,s:s})=>M(Ae,{uniqueId:pe("i",t,n),summary:"Index: "+n,s:s},H(l.useSliceIds(n,e),(l=>M(kl,{indexes:e,indexesId:t,indexId:n,sliceId:l,s:s})))),kl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=pe("i",l,t,n),[o,a]=ge(r,s);return M(Ae,{uniqueId:r,summary:"Slice: "+n,editable:o,handleEditable:a,s:s},M(gl,{sliceId:n,indexId:t,indexes:e,editable:o}))},Sl=({indexesId:e,s:t})=>{const n=l.useIndexes(e),s=l.useIndexIds(n);return R(n)?null:M(Ae,{uniqueId:pe("i",e),summary:"Indexes: "+(null!=e?e:u),s:t},B(s)?"No indexes defined":ve(s,(l=>M(xl,{indexes:n,indexesId:e,indexId:l,s:t}))))},Tl=({metrics:e,metricId:t})=>M("tr",null,M("th",null,t),M("td",null,null==e?void 0:e.getTableId(t)),M("td",null,l.useMetric(t,e))),Vl=({metricsId:e,s:t})=>{const n=l.useMetrics(e),s=l.useMetricIds(n);return R(n)?null:M(Ae,{uniqueId:pe("m",e),summary:"Metrics: "+(null!=e?e:u),s:t},B(s)?"No metrics defined":M("table",null,M("thead",null,M("th",null,"Metric Id"),M("th",null,"Table Id"),M("th",null,"Metric")),M("tbody",null,H(s,(e=>M(Tl,{metrics:n,metricId:e}))))))},Rl=({queries:e,queriesId:t,queryId:n,s:s})=>{var r;const o=pe("q",t,n),[a,i,u]=re(null!=(r=l.useCell(ue,o,de,s))?r:"[]"),d=l.useSetCellCallback(ue,o,de,se,[],s);return M(Ae,{uniqueId:o,summary:"Query: "+n,s:s},M(fl,{queryId:n,queries:e,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},Ol=({queriesId:e,s:t})=>{const n=l.useQueries(e),s=l.useQueryIds(n);return R(n)?null:M(Ae,{uniqueId:pe("q",e),summary:"Queries: "+(null!=e?e:u),s:t},B(s)?"No queries defined":ve(s,(l=>M(Rl,{queries:n,queriesId:e,queryId:l,s:t}))))},ql=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=pe("r",l,t),[r,o]=ge(s,n);return M(Ae,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:o,s:n},M(Il,{relationshipId:t,relationships:e,editable:r}))},Pl=({relationshipsId:e,s:t})=>{const n=l.useRelationships(e),s=l.useRelationshipIds(n);return R(n)?null:M(Ae,{uniqueId:pe("r",e),summary:"Relationships: "+(null!=e?e:u),s:t},B(s)?"No relationships defined":ve(s,(l=>M(ql,{relationships:n,relationshipsId:e,relationshipId:l,s:t}))))},Nl=({tableId:e,store:t,storeId:n,s:s})=>{var r;const o=pe("t",n,e),[a,i,u]=re(null!=(r=l.useCell(ue,o,de,s))?r:"[]"),d=l.useSetCellCallback(ue,o,de,se,[],s),[h,m]=ge(o,s);return M(Ae,{uniqueId:o,summary:c+": "+e,editable:h,handleEditable:m,s:s},M(pl,{tableId:e,store:t,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:h}))},El=({store:e,storeId:t,s:n})=>{const s=pe("v",t),[r,o]=ge(s,n);return B(l.useValueIds(e))?null:M(Ae,{uniqueId:s,summary:y,editable:r,handleEditable:o,s:n},M(vl,{store:e,editable:r}))},Ll=({storeId:e,s:t})=>{const n=l.useStore(e),s=l.useTableIds(n);return R(n)?null:M(Ae,{uniqueId:pe("s",e),summary:"Store: "+(null!=e?e:u),s:t},M(El,{storeId:e,store:n,s:t}),ve(s,(l=>M(Nl,{store:n,storeId:e,tableId:l,s:t}))))},Ml=({s:e})=>{const t=$(null),n=$(0),[s,r]=A(!1),{scrollLeft:o,scrollTop:a}=l.useValues(e);z((()=>{const e=t.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=S(o)+e.clientWidth&&e.scrollHeight>=S(a)+e.clientHeight&&e.scrollTo(o,a)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,o,a]);const i=j((l=>{const{scrollLeft:t,scrollTop:s}=l[C];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=l.useStore(),d=l.useStoreIds(),c=l.useMetrics(),h=l.useMetricsIds(),m=l.useIndexes(),b=l.useIndexesIds(),p=l.useRelationships(),v=l.useRelationshipsIds(),g=l.useQueries(),I=l.useQueriesIds();return R(u)&&B(d)&&R(c)&&B(h)&&R(m)&&B(b)&&R(p)&&B(v)&&R(g)&&B(I)?M("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):M("article",{ref:t,onScroll:i},M(Ll,{s:e}),H(d,(l=>M(Ll,{storeId:l,key:l,s:e}))),M(Vl,{s:e}),H(h,(l=>M(Vl,{metricsId:l,key:l,s:e}))),M(Sl,{s:e}),H(b,(l=>M(Sl,{indexesId:l,key:l,s:e}))),M(Pl,{s:e}),H(v,(l=>M(Pl,{relationshipsId:l,key:l,s:e}))),M(Ol,{s:e}),H(I,(l=>M(Ol,{queriesId:l,key:l,s:e}))))};var jl=Object.defineProperty,zl=(e,l,t)=>(((e,l,t)=>{l in e?jl(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t})(e,"symbol"!=typeof l?l+"":l,t),t);class $l extends E{constructor(e){super(e),zl(this,"componentDidCatch",((e,l)=>console.error(e,l.componentStack))),this.state={e:0}}render(){return this.state.e?M("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl($l,"getDerivedStateFromError",(()=>({e:1})));const Al=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1,s=l.useSetValueCallback(me,(()=>!1),[],e),r=l.useSetValueCallback(he,(e=>Number(e[C].dataset.id)),[],e);return M("header",null,M("img",{title:ae}),M("span",null,ae),H(ie,((e,l)=>l==n?null:M("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),M("img",{onClick:s,title:"Close"}))},Fl=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1;return l.useValue(me,e)?M("main",{"data-position":n},M(Al,{s:e}),M($l,null,M(Ml,{s:e}))):null},Jl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Hl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Jl(Hl),Bl=Jl(Dl),Ql=Jl(Bl),Wl=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>R(e)||0==Hl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Ul=e=>e.clear(),Xl=(e,l)=>null==e?void 0:e.forEach(l),Yl=(e,l)=>null==e?void 0:e.delete(l),Zl=e=>new Map(e),_l=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},et=(e,l)=>null==e?void 0:e.get(l),lt=(e,l)=>Xl(e,((e,t)=>l(t,e))),tt=(e,l,t)=>R(t)?(Yl(e,l),e):null==e?void 0:e.set(l,t),nt=(e,l,t)=>(Wl(e,l)||tt(e,l,t()),et(e,l)),st=(e,l,t,n=tt)=>(te(l,((l,n)=>t(e,n,l))),lt(e,(t=>ee(l,t)?0:n(e,t))),e),rt=(e,l,t)=>{const n={};return Xl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>rt(e,(e=>rt(e,l,t)),ne),at=(e,l,t)=>rt(e,(e=>ot(e,l,t)),ne),it=(e,l)=>{const t=Zl();return Xl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},ut=e=>it(e,it),dt=e=>it(e,ut),ct=(e,l,t,n,s=0)=>O((t?nt:et)(e,l[s],s>D(l)-2?t:Zl),(r=>{if(s>D(l)-2)return(null==n?void 0:n(r))&&tt(e,l[s]),r;const o=ct(r,l,t,n,s+1);return Gl(r)&&tt(e,l[s]),o}));var ht=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const mt=Zl(),bt=Zl();var pt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const vt="storage",gt=globalThis.window,It=e=>new Set(N(e)||R(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),yt=/^\d+$/,wt=()=>{const e=[];let l=0;return[t=>{var s;return null!=(s=t?G(e):null)?s:n+l++},l=>{yt.test(l)&&D(e)<1e3&&W(e,l)}]},Ct=e=>[e,e],xt=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Zl(),Zl()],St=e=>[...e],Tt=([e,l])=>e===l,Vt=(e,l,t)=>R(e)||!Z(e)||ne(e)||X(e)?(null==t||t(),!1):(te(e,((t,n)=>{l(t,n)||le(e,n)})),!ne(e)),Rt=(e,l,t)=>tt(e,l,et(e,l)==-t?void 0:t),Ot=()=>{let e,l,t=!1,s=!1,r=0;const a=Zl(),d=Zl(),C=Zl(),x=Zl(),S=Zl(),T=Zl(),V=Zl(),N=Zl(),E=Zl(),L=Zl(),M=Zl(),j=Zl(),z=Zl(),$=Zl(),A=It(),F=Zl(),B=Zl(),G=Zl(),K=Zl(),U=kt(),X=kt(),Z=kt(),_=kt(),oe=kt(),ae=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ve=kt(),ge=Zl(),Ie=kt(),[fe,ye,we,Ce]=(e=>{let l;const[t,s]=wt(),r=Zl();return[(e,s,o,a=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return tt(r,u,[e,s,o,a,i]),ft(ct(s,null!=o?o:[n],It),u),u},(e,t,...s)=>J(((e,l=[n])=>{const t=[],s=(e,n)=>n==D(l)?W(t,e):null===l[n]?Xl(e,(e=>s(e,n+1))):J([l[n],null],(l=>s(et(e,l),n+1)));return s(e,0),t})(e,t),(e=>Xl(e,(e=>et(r,e)[0](l,...null!=t?t:[],...s))))),e=>O(et(r,e),(([,l,t])=>(ct(l,null!=t?t:[n],void 0,(l=>(Yl(l,e),Gl(l)?1:0))),tt(r,e),s(e),t))),e=>O(et(r,e),(([e,,t=[],n,s])=>{const r=(...o)=>{var a,i;const u=D(o);u==D(t)?e(l,...o,...s(o)):R(t[u])?J(null!=(i=null==(a=n[u])?void 0:a.call(n,...o))?i:[],(e=>r(...o,e))):r(...o,t[u])};r()}))]})(),xe=e=>{if(!Vt(e,((e,l)=>[i,u].includes(l))))return!1;const l=e[i];return!(!q(l)&&l!=o||(Fe(e[u])!=l&&le(e,u),0))},ke=(l,t)=>(!e||Wl(M,t)||nl(t))&&Vt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Vt(n?t:Oe(t,e,l),((n,s)=>O(Te(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Te=(l,t,n,s)=>e?O(et(et(M,l),n),(e=>Fe(s)!=e[i]?nl(l,t,n,s,e[u]):s),(()=>nl(l,t,n,s))):R(Fe(s))?nl(l,t,n,s):s,Ve=(e,l)=>Vt(l?e:qe(e),((l,t)=>O(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?O(et(z,e),(l=>Fe(t)!=l[i]?sl(e,t,l[u]):t),(()=>sl(e,t))):R(Fe(t))?sl(e,t):t,Oe=(e,l,t)=>(O(et(j,l),(([n,s])=>{Xl(n,((l,t)=>{ee(e,t)||(e[t]=l)})),Xl(s,(n=>{ee(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Xl($,((l,t)=>{ee(e,t)||(e[t]=l)})),Xl(A,(l=>{ee(e,l)||sl(l)}))),e),Pe=e=>st(M,e,((e,l,t)=>{const n=Zl(),s=It();st(nt(M,l,Zl),t,((e,l,t)=>{tt(e,l,t),O(t[u],(e=>tt(n,l,e)),(()=>ft(s,l)))})),tt(j,l,[n,s])}),((e,l)=>{tt(M,l),tt(j,l)})),Ne=e=>st(z,e,((e,l,t)=>{tt(z,l,t),O(t[u],(e=>tt($,l,e)),(()=>ft(A,l)))}),((e,l)=>{tt(z,l),tt($,l),Yl(A,l)})),Ee=e=>ne(e)?ql():Sl(e),Le=e=>st(G,e,((e,l,t)=>Me(l,t)),((e,l)=>Ge(l))),Me=(e,l)=>st(nt(G,e,(()=>(Ye(e,1),tt(F,e,wt()),tt(B,e,Zl()),Zl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ke(e,l,t))),je=(e,l,t,n,s)=>st(nt(l,t,(()=>(Ze(e,t,1),Zl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ue(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Wl(t,n)||_e(e,l,n,1);const r=et(t,n);s!==r&&(el(e,l,n,r,s),tt(t,n,s))},$e=(e,l,t,n,s)=>O(et(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>ne(e)?El():Tl(e),De=e=>st(K,e,((e,l,t)=>Be(l,t)),((e,l)=>Xe(l))),Be=(e,l)=>{Wl(K,e)||ll(e,1);const t=et(K,e);l!==t&&(tl(e,t,l),tt(K,e,l))},Qe=(e,l)=>{const[t]=et(F,e),n=t(l);return Wl(et(G,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=et(G,e))?l:Me(e,{})},Ge=e=>Me(e,{}),Ke=(e,l,t)=>{const[,n]=et(F,e);n(t),je(e,l,t,{},!0)},Ue=(e,l,t,n,s,r)=>{var o;const a=et(null==(o=et(j,e))?void 0:o[0],s);if(!R(a)&&!r)return ze(e,t,n,s,a);const i=l=>{el(e,t,l,et(n,l)),_e(e,t,l,-1),tt(n,l)};R(a)?i(s):lt(n,i),Gl(n)&&(Ze(e,t,-1),Gl(tt(l,t))&&(Ye(e,-1),tt(G,e),tt(F,e),tt(B,e)))},Xe=e=>{const l=et($,e);if(!R(l))return Be(e,l);tl(e,et(K,e)),ll(e,-1),tt(K,e)},Ye=(e,l)=>Rt(a,e,l),Ze=(e,l,t)=>Rt(nt(x,e,Zl),l,t)&&tt(C,e,nt(C,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=et(B,e),o=null!=(s=et(r,t))?s:0;(0==o&&1==n||1==o&&-1==n)&&Rt(nt(d,e,Zl),t,n),tt(r,t,o!=-n?o+n:null),Rt(nt(nt(S,e,Zl),l,Zl),t,n)},el=(e,l,t,n,s)=>nt(nt(nt(T,e,Zl),l,Zl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Rt(V,e,l),tl=(e,l,t)=>nt(N,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(W(nt(nt(nt(E,e,Zl),l,Zl),t,(()=>[])),n),s),sl=(e,l,t)=>(W(nt(L,e,(()=>[])),l),t),rl=(e,l,t)=>O(et(et(et(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...Ct(wl(e,l,t))])),ol=e=>O(et(N,e),(([e,l])=>[!0,e,l]),(()=>[!1,...Ct(kl(e))])),al=e=>Gl(E)||Gl(he[e])?0:Xl(e?dt(E):E,((l,t)=>Xl(l,((l,n)=>Xl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Gl(L)||Gl(me[e])?0:Xl(e?it(L):L,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Gl(l))return ye(e,t,(()=>rt(l))),1},dl=e=>{const l=Gl(ie[e]),t=Gl(de[e])&&Gl(_[e])&&Gl(oe[e])&&Gl(ae[e])&&l&&Gl(X[e]),n=Gl(ce[e])&&Gl(ue[e])&&Gl(Z[e])&&Gl(U[e]);if(!t||!n){const s=e?[it(a),ut(d),it(C),ut(x),dt(S),dt(T)]:[a,d,C,x,S,T];if(!t){ul(X[e],s[0]),Xl(s[1],((l,t)=>ul(_[e],l,[t]))),Xl(s[2],((l,t)=>{0!=l&&ye(oe[e],[t],gl(t))}));const t=It();Xl(s[3],((n,s)=>{ul(ae[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Xl(s[5],((l,n)=>{if(!Wl(t,n)){const t=It();Xl(l,(e=>Xl(e,(([l,n],s)=>n!==l?ft(t,s):Yl(e,s))))),Xl(t,(l=>ye(ie[e],[n,l])))}})),Xl(s[4],((l,t)=>Xl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Xl(s[5],((t,n)=>{let s;Xl(t,((t,r)=>{let o;Xl(t,(([t,a],i)=>{a!==t&&(ye(ce[e],[n,r,i],a,t,rl),l=s=o=1)})),o&&ye(ue[e],[n,r],rl)})),s&&ye(Z[e],[n],rl)})),l&&ye(U[e],void 0,rl)}}},cl=e=>{const l=Gl(pe[e]),t=Gl(ve[e])&&Gl(be[e]);if(!l||!t){const n=e?[it(V),it(N)]:[V,N];if(l||ul(pe[e],n[0]),!t){let l;Xl(n[1],(([t,n],s)=>{n!==t&&(ye(ve[e],[s],n,t,ol),l=1)})),l&&ye(be[e],void 0,ol)}}},hl=(e,...l)=>(jl((()=>e(...H(l,k)))),Al),ml=()=>[rt(T,((e,l)=>-1===et(a,l)?null:rt(e,((e,t)=>-1===et(et(x,l),t)?null:rt(e,(([,e])=>null!=e?e:null),((e,l)=>Tt(l)))),ne)),ne),rt(N,(([,e])=>null!=e?e:null),((e,l)=>Tt(l)))],bl=()=>({cellsTouched:t,valuesTouched:s,changedCells:at(T,St,Tt),invalidCells:at(E),changedValues:rt(N,St,Tt),invalidValues:rt(L),changedTableIds:rt(a),changedRowIds:ot(x),changedCellIds:at(S),changedValueIds:rt(V)}),pl=()=>at(G),vl=()=>_l(G),gl=e=>Hl(et(G,k(e))),Il=e=>_l(et(G,k(e))),fl=(e,l,t,n=0,s)=>{return H(Q((o=et(G,k(e)),a=(e,t)=>[R(l)?t:et(e,k(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},H([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,l])=>a(l,e))).sort(r)),n,R(s)?s:n+s),(([,e])=>e));var r,o,a,i},yl=(e,l)=>_l(et(et(G,k(e)),k(l))),wl=(e,l,t)=>et(et(et(G,k(e)),k(l)),k(t)),Cl=()=>rt(K),xl=()=>_l(K),kl=e=>et(K,k(e)),Sl=e=>hl((()=>(e=>Vt(e,ke,nl))(e)?Le(e):0)),Tl=e=>hl((()=>Ve(e)?De(e):0)),Vl=e=>{try{Ee(re(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=Vt(l,(e=>Vt(e,xe))))&&(Pe(l),!Gl(G))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Vt(e,xe))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Wl(G,e)?Ge(e):0),e),Nl=(e,l)=>hl(((e,l)=>O(et(G,e),(t=>Wl(t,l)?Ke(e,t,l):0))),e,l),El=()=>hl((()=>De({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ge,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Gl(T),s=!Gl(N),r=1,al(1),t&&dl(1),il(1),s&&cl(1),(null==e?void 0:e(ml,bl))&&(Xl(T,((e,l)=>Xl(e,((e,t)=>Xl(e,(([e],n)=>Je(Al,l,t,n,e))))))),Xl(N,(([e],l)=>He(Al,l,e))),t=s=!1),ye(Ie[0],void 0,ml,bl),r=-1,al(0),t&&dl(0),il(0),s&&cl(0),ye(Ie[1],void 0,ml,bl),r=0,t=s=!1,J([a,d,C,x,S,T,E,V,N,L],Ul))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:vl,getTable:e=>ot(et(G,k(e))),getTableCellIds:e=>_l(et(B,k(e))),getRowCount:gl,getRowIds:Il,getSortedRowIds:fl,getRow:(e,l)=>rt(et(et(G,k(e)),k(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:xl,getValue:kl,hasTables:()=>!Gl(G),hasTable:e=>Wl(G,k(e)),hasTableCell:(e,l)=>Wl(et(B,k(e)),k(l)),hasRow:(e,l)=>Wl(et(G,k(e)),k(l)),hasCell:(e,l,t)=>Wl(et(et(G,k(e)),k(l)),k(t)),hasValues:()=>!Gl(K),hasValue:e=>Wl(K,k(e)),getTablesJson:()=>se(G),getValuesJson:()=>se(K),getJson:()=>se([G,K]),getTablesSchemaJson:()=>se(M),getValuesSchemaJson:()=>se(z),getSchemaJson:()=>se([M,z]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(ne(e)?ql:Sl)(e),(ne(l)?El:Tl)(l)})),setTables:Sl,setTable:(e,l)=>hl((e=>ke(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>Se(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return Se(e,n,l)&&(e=k(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(Se(e,l,t,1)){const n=We(e);te(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>O(Te(e,l,t,P(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Tl,setPartialValues:e=>hl((()=>Ve(e,1)?te(e,((e,l)=>Be(l,e))):0)),setValue:(e,l)=>hl((e=>O(Re(e,P(l)?l(kl(e)):l),(l=>Be(e,l)))),e),setTransactionChanges:e=>hl((()=>{te(e[0],((e,l)=>R(e)?Pl(l):te(e,((e,t)=>R(e)?Nl(l,t):te(e,((e,n)=>Je(Al,l,t,n,e))))))),te(e[1],((e,l)=>He(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(re(e))}catch(e){}return Al},setJson:e=>{try{const[l,t]=re(e);Ee(l),Ae(t)}catch(l){Vl(e)}return Al},setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>O(et(G,e),(s=>O(et(s,l),(r=>Wl(r,t)?Ue(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Wl(K,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Xl(G,((l,t)=>e(t,(e=>Xl(l,((l,t)=>e(t,(e=>lt(l,e))))))))),forEachTableCell:(e,l)=>lt(et(B,k(e)),l),forEachRow:(e,l)=>Xl(et(G,k(e)),((e,t)=>l(t,(l=>lt(e,l))))),forEachCell:(e,l,t)=>lt(et(et(G,k(e)),k(l)),t),forEachValue:e=>lt(K,e),addSortedRowIdsListener:(e,l,t,n,s,r,o)=>{let a=fl(e,l,t,n,s);return fe((()=>{const o=fl(e,l,t,n,s);var i,u,d;u=a,D(i=o)===D(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(a=o,r(Al,e,l,t,n,s,a))}),ie[o?1:0],[e,l],[vl])},addStartTransactionListener:e=>fe(e,ge),addWillFinishTransactionListener:e=>fe(e,Ie[0]),addDidFinishTransactionListener:e=>fe(e,Ie[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:xt(U),tableIds:xt(X),tableCellIds:xt(_),table:xt(Z),rowCount:xt(oe),rowIds:xt(ae),sortedRowIds:xt(ie),row:xt(ue,Bl),cellIds:xt(de,Bl),cell:xt(ce,Ql),invalidCell:xt(he,Ql),values:xt(be),valueIds:xt(pe),value:xt(ve),invalidValue:xt(me),transaction:Dl(ge)+xt(Ie)}),createStore:Ot,addListener:fe,callListeners:ye};return te({[h]:[0,U],[m]:[0,X],[c]:[1,Z,[vl]],[c+I]:[1,_,[vl]],[p]:[1,oe,[vl]],[v]:[1,ae,[vl]],[b]:[2,ue,[vl,Il]],[I]:[2,de,[vl,Il]],[g]:[3,ce,[vl,Il,yl],e=>Ct(wl(...e))],InvalidCell:[3,he],[y]:[0,be],[w]:[0,pe],[f]:[1,ve,[xl],e=>Ct(kl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>fe(s[e],l[s[e+1]?1:0],e>0?Q(s,0,e):void 0,t,n)})),Y(Al)},qt=({position:e="right",open:t=!1})=>{const n=l.useCreateStore(Ot),s=ie.indexOf(e);return l.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,o=[])=>{let a,i,u,d=0,c=0,h=0,m=0;nt(mt,o,(()=>0)),nt(bt,o,(()=>[]));const b=e=>ht(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ht(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ht(void 0,null,(function*(){return yield b((()=>ht(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ht(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ht(void 0,null,(function*(){if(n){const l=n();yield b((()=>ht(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ht(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ht(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ht(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ht(void 0,null,(function*(){return yield p.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();ne(t)&&ne(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(O(a,e.delListener),p),schedule:(...e)=>ht(void 0,null,(function*(){return W(et(bt,o),...e),yield ht(void 0,null,(function*(){if(!et(mt,o)){for(tt(mt,o,1);!R(i=G(et(bt,o)));)try{yield i()}catch(e){null==r||r(e)}tt(mt,o,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Y(p)})(e,(()=>pt(void 0,null,(function*(){return re(t.getItem(l))}))),(e=>pt(void 0,null,(function*(){return t.setItem(l,se(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>re(n.newValue)))};return gt.addEventListener(vt,n),n}),(e=>gt.removeEventListener(vt,e)),n))(e,oe,sessionStorage,l);var l}),void 0,(e=>{return l=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!t}),yield e.startAutoSave()},new Promise(((e,t)=>{var n=e=>{try{r(l.next(e))}catch(e){t(e)}},s=e=>{try{r(l.throw(e))}catch(e){t(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((l=l.apply(void 0,null)).next())}));var l})),M(L,null,M("aside",{id:oe},M($e,{s:n}),M(Fl,{s:n})),M("style",null,ze))};var Pt=Object.defineProperty,Nt=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Mt=(e,l,t)=>l in e?Pt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;exports.EditableCellView=yl,exports.EditableValueView=wl,exports.RelationshipInHtmlTable=Il,exports.ResultSortedTableInHtmlTable=fl,exports.ResultTableInHtmlTable=e=>{var t=e,{queryId:n,queries:s,customCells:r}=t,o=_e(t,["queryId","queries","customCells"]);return M(cl,Ze(Ye({},o),{params:ol(dl(l.useResultTableCellIds(n,s),r,l.ResultCellView),il(s,n),l.useResultRowIds(n,s))}))},exports.SliceInHtmlTable=gl,exports.SortedTableInHtmlTable=pl,exports.SortedTablePaginator=Cl,exports.StoreInspector=e=>M(qt,((e,l)=>{for(var t in l||(l={}))Et.call(l,t)&&Mt(e,t,l[t]);if(Nt)for(var t of Nt(l))Lt.call(l,t)&&Mt(e,t,l[t]);return e})({},e)),exports.TableInHtmlTable=e=>{var t=e,{tableId:n,store:s,editable:r,customCells:o}=t,a=_e(t,["tableId","store","editable","customCells"]);return M(cl,Ze(Ye({},a),{params:ol(dl(l.useTableCellIds(n,s),o,r?yl:l.CellView),al(s,n),l.useRowIds(n,s))}))},exports.ValuesInHtmlTable=vl;
1
+ "use strict";var e=require("react"),l=require("./ui-react");const t=e=>typeof e,n="",s=t(n),r=t(!0),o=t(0),a=t(t),i="type",u="default",d="Ids",c="Table",h=c+"s",m=c+d,b="Row",p=b+"Count",v=b+d,g="Cell",I=g+d,f="Value",y=f+"s",w=f+d,C="currentTarget",x="value",k=e=>n+e,S=Math.floor,T=isFinite,V=(e,l)=>e instanceof l,R=e=>null==e,O=(e,l,t)=>R(e)?null==t?void 0:t():l(e),q=e=>e==s||e==r,P=e=>t(e)==a,N=e=>Array.isArray(e),{PureComponent:E,Fragment:L,createElement:M,useCallback:j,useLayoutEffect:z,useRef:$,useState:A}=e,F=(e,...l)=>R(e)?{}:e(...l),J=(e,l)=>e.forEach(l),H=(e,l)=>e.map(l),D=e=>e.length,B=e=>0==D(e),Q=(e,l,t)=>e.slice(l,t),W=(e,...l)=>e.push(...l),G=e=>e.shift(),K=Object,U=K.keys,X=K.isFrozen,Y=K.freeze,Z=e=>V(e,K)&&e.constructor==K,_=(e=[])=>K.fromEntries(e),ee=(e,l)=>!R(((e,l)=>O(e,(e=>e[l])))(e,l)),le=(e,l)=>(delete e[l],e),te=(e,l)=>H(K.entries(e),(([e,t])=>l(t,e))),ne=e=>Z(e)&&0==(e=>D(U(e)))(e),se=e=>JSON.stringify(e,((e,l)=>V(l,Map)?K.fromEntries([...l]):l)),re=JSON.parse,oe="tinybaseStoreInspector",ae="TinyBase Store Inspector",ie=["left","top","bottom","right","full"],ue="state",de="sort",ce="open",he="position",me=ce,be="editable",pe=(...e)=>se(e),ve=(e,l)=>H(e.sort(),l),ge=(e,t)=>[!!l.useCell(ue,e,be,t),j((l=>{t.setCell(ue,e,be,(e=>!e)),l.preventDefault()}),[t,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",fe='content:url("',ye=fe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",we='</svg>")',Ce=fe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",xe=H([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>ye+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+we)),ke=ye+"<path d='M20 20l60 60M20 80l60-60' />"+we,Se=ye+`<path d='${Ie}' />`+we,Te=ye+`<path d='${Ie}M20 20l60 60' />`+we;var Ve=Object.defineProperty,Re=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Ee=(e,l,t)=>l in e?Ve(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Le=(e,l)=>{for(var t in l||(l={}))Pe.call(l,t)&&Ee(e,t,l[t]);if(qe)for(var t of qe(l))Ne.call(l,t)&&Ee(e,t,l[t]);return e},Me=(e,l)=>Re(e,Oe(l));const je="*::-webkit-scrollbar",ze=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,l="")=>e.join(l))(te(Me(Le(Me(Le(Me(Le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[je]:"width:0.5rem;height:0.5rem;",[je+"-track"]:"background:#111",[je+"-thumb"]:"background:#999;border:1px solid #111",[je+"-thumb:hover"]:"background:#fff",[je+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ce},_(H(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),_(H(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ce,"header>img:nth-of-type(6)":ke}),_(H(xe,((e,l)=>[`header>img[data-id='${l}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Se,"details[open]>summary img.done":Te,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,l)=>e?`& ${l}{${e}}`:"")))}`,$e=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1,s=l.useSetValueCallback(me,(()=>!0),[],e);return l.useValue(me,e)?null:M("img",{onClick:s,title:ae,"data-position":n})},Ae=({uniqueId:e,summary:t,editable:n,handleEditable:s,children:r,s:o})=>{const a=!!l.useCell(ue,e,ce,o),i=l.useSetCellCallback(ue,e,ce,(e=>e[C].open),[],o);return M("details",{open:a,onToggle:i},M("summary",null,t,s?M("img",{onClick:s,className:n?"done":"edit"}):null),r)},Fe=e=>{const l=t(e);return q(l)||l==o&&T(e)?l:void 0},Je=(e,l,t,n,s)=>R(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),He=(e,l,t)=>R(t)?e.delValue(l):e.setValue(l,t),De=(e,l,t,n)=>e==s?l:e==o?t:n;var Be=Object.defineProperty,Qe=Object.defineProperties,We=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,Xe=(e,l,t)=>l in e?Be(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ye=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Xe(e,t,l[t]);if(Ge)for(var t of Ge(l))Ue.call(l,t)&&Xe(e,t,l[t]);return e},Ze=(e,l)=>Qe(e,We(l)),_e=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Ue.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:el,useMemo:ll,useState:tl}=e,nl="editable",sl=(e,t)=>H(l.useTableCellIds(e,t),(l=>e+"."+l)),rl=(e,l,t)=>{const n=el(e,l);return t?n:void 0},ol=(...e)=>ll((()=>e),e),al=(e,l)=>ll((()=>({store:e,tableId:l})),[e,l]),il=(e,l)=>ll((()=>({queries:e,queryId:l})),[e,l]),ul=(e,l=!1,t,n=0,s,r,o,a)=>{const[[i,u,d],c]=tl([e,l,n]),h=el((e=>{c(e),null==a||a(e)}),[a]),m=rl((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=el((e=>h([i,u,e])),[h,i,u]),p=!0===o?Cl:o;return[[i,u,d],m,ll((()=>!1===o?null:M(p,{offset:d,limit:s,total:r,onChange:b})),[o,p,d,s,r,b])]},dl=(e,l,n)=>ll((()=>{const r=null!=l?l:e;return _(te(N(r)?_(H(r,(e=>[e,e]))):r,((e,l)=>{return[l,Ye(Ye({},{label:l,component:n}),(r=e,t(r)==s?{label:e}:e))];var r})))}),[l,n,e]),cl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,o,a,i]})=>M("table",{className:e},i?M("caption",null,i):null,!1===l?null:M("thead",null,M("tr",null,!1===t?null:M(hl,{sort:null!=o?o:[],label:"Id",onClick:a}),te(n,(({label:e},l)=>M(hl,{key:l,cellId:l,label:e,sort:null!=o?o:[],onClick:a}))))),M("tbody",null,H(r,(e=>M("tr",{key:e},!1===t?null:M("th",null,e),te(n,(({component:l,getComponentProps:t},n)=>M("td",{key:n},M(l,Ze(Ye(Ye({},F(t,e,n)),s),{rowId:e,cellId:n})))))))))),hl=({cellId:e,sort:[l,t],label:s=(null!=e?e:n),onClick:r})=>M("th",{onClick:rl((()=>null==r?void 0:r(e)),[r,e],r),className:R(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},R(t)||l!=e?null:(t?"↓":"↑")+" ",s),ml=({localRowId:t,params:[n,s,r,o,a,i,u]})=>{const d=l.useRemoteRowId(a,t,i);return M("tr",null,!1===n?null:M(e.Fragment,null,M("th",null,t),M("th",null,d)),te(s,(({component:e,getComponentProps:l},n)=>{const[s,a]=n.split(".",2),i=s===r?t:s===o?d:null;return R(i)?null:M("td",{key:n},M(e,Ze(Ye({},F(l,i,a)),{store:u,tableId:s,rowId:i,cellId:a})))})))},bl=({thing:e,onThingChange:l,className:t,hasSchema:n})=>{const[a,i]=tl(),[u,d]=tl(),[c,h]=tl(),[m,b]=tl(),[p,v]=tl();u!==e&&(i(Fe(e)),d(e),h(e+""),b(Number(e)||0),v(!!e));const g=el(((e,t)=>{t(e),d(e),l(e)}),[l]);return M("div",{className:t},M("button",{className:a,onClick:el((()=>{if(!(null==n?void 0:n())){const e=De(a,o,r,s),t=De(e,c,m,p);i(e),d(t),l(t)}}),[n,l,c,m,p,a])},a),De(a,M("input",{key:a,value:c,onChange:el((e=>g(e[C][x]+"",h)),[g])}),M("input",{key:a,type:"number",value:m,onChange:el((e=>g(Number(e[C][x]||0),b)),[g])}),M("input",{key:a,type:"checkbox",checked:p,onChange:el((e=>g(!!e[C].checked,v)),[g])})))},pl=e=>{var t=e,{tableId:n,cellId:s,descending:r,offset:o,limit:a,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=t,b=_e(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,v,g]=ul(s,r,d,o,a,l.useRowCount(n,i),c,h);return M(cl,Ze(Ye({},b),{params:ol(dl(l.useTableCellIds(n,i),m,u?yl:l.CellView),al(i,n),l.useSortedRowIds(n,...p,a,i),p,v,g)}))},vl=({store:e,editable:t=!1,valueComponent:n=(t?wl:l.ValueView),getValueComponentProps:s,className:r,headerRow:o,idColumn:a})=>M("table",{className:r},!1===o?null:M("thead",null,M("tr",null,!1===a?null:M("th",null,"Id"),M("th",null,f))),M("tbody",null,H(l.useValueIds(e),(l=>M("tr",{key:l},!1===a?null:M("th",null,l),M("td",null,M(n,Ze(Ye({},F(s,l)),{valueId:l,store:e})))))))),gl=e=>{var t=e,{indexId:n,sliceId:s,indexes:r,editable:o,customCells:a}=t,i=_e(t,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(l.useIndexesOrIndexesById(r),n);return M(cl,Ze(Ye({},i),{params:ol(dl(l.useTableCellIds(c,d),a,o?yl:l.CellView),al(d,c),l.useSliceRowIds(n,s,u))}))},Il=({relationshipId:t,relationships:n,editable:s,customCells:r,className:o,headerRow:a,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(l.useRelationshipsOrRelationshipsById(n),t),m=dl([...sl(c,d),...sl(h,d)],r,s?yl:l.CellView),b=ol(i,m,c,h,t,u,d);return M("table",{className:o},!1===a?null:M("thead",null,M("tr",null,!1===i?null:M(e.Fragment,null,M("th",null,c,".Id"),M("th",null,h,".Id")),te(m,(({label:e},l)=>M("th",{key:l},e))))),M("tbody",null,H(l.useRowIds(c,d),(e=>M(ml,{key:e,localRowId:e,params:b})))))},fl=e=>{var t=e,{queryId:n,cellId:s,descending:r,offset:o,limit:a,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=t,m=_e(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,v]=ul(s,r,u,o,a,l.useResultRowCount(n,i),d,h);return M(cl,Ze(Ye({},m),{params:ol(dl(l.useResultTableCellIds(n,i),c,l.ResultCellView),il(i,n),l.useResultSortedRowIds(n,...b,a,i),b,p,v)}))},yl=({tableId:e,rowId:t,cellId:n,store:s,className:r})=>{var o;return M(bl,{thing:l.useCell(e,t,n,s),onThingChange:l.useSetCellCallback(e,t,n,(e=>e),[],s),className:null!=r?r:nl+g,hasSchema:null==(o=l.useStoreOrStoreById(s))?void 0:o.hasTablesSchema})},wl=({valueId:e,store:t,className:n})=>{var s;return M(bl,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=n?n:nl+f,hasSchema:null==(s=l.useStoreOrStoreById(t))?void 0:s.hasValuesSchema})},Cl=({onChange:l,total:t,offset:n=0,limit:s=t,singular:r="row",plural:o=r+"s"})=>{(n>t||n<0)&&(n=0,l(0));const a=rl((()=>l(n-s)),[l,n,s],n>0),i=rl((()=>l(n+s)),[l,n,s],n+s<t);return M(e.Fragment,null,t>s&&M(e.Fragment,null,M("button",{className:"previous",disabled:0==n,onClick:a},"←"),M("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?o:r)},xl=({indexes:e,indexesId:t,indexId:n,s:s})=>M(Ae,{uniqueId:pe("i",t,n),summary:"Index: "+n,s:s},H(l.useSliceIds(n,e),(l=>M(kl,{indexes:e,indexesId:t,indexId:n,sliceId:l,s:s})))),kl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=pe("i",l,t,n),[o,a]=ge(r,s);return M(Ae,{uniqueId:r,summary:"Slice: "+n,editable:o,handleEditable:a,s:s},M(gl,{sliceId:n,indexId:t,indexes:e,editable:o}))},Sl=({indexesId:e,s:t})=>{const n=l.useIndexes(e),s=l.useIndexIds(n);return R(n)?null:M(Ae,{uniqueId:pe("i",e),summary:"Indexes: "+(null!=e?e:u),s:t},B(s)?"No indexes defined":ve(s,(l=>M(xl,{indexes:n,indexesId:e,indexId:l,s:t}))))},Tl=({metrics:e,metricId:t})=>M("tr",null,M("th",null,t),M("td",null,null==e?void 0:e.getTableId(t)),M("td",null,l.useMetric(t,e))),Vl=({metricsId:e,s:t})=>{const n=l.useMetrics(e),s=l.useMetricIds(n);return R(n)?null:M(Ae,{uniqueId:pe("m",e),summary:"Metrics: "+(null!=e?e:u),s:t},B(s)?"No metrics defined":M("table",null,M("thead",null,M("th",null,"Metric Id"),M("th",null,"Table Id"),M("th",null,"Metric")),M("tbody",null,H(s,(e=>M(Tl,{metrics:n,metricId:e}))))))},Rl=({queries:e,queriesId:t,queryId:n,s:s})=>{var r;const o=pe("q",t,n),[a,i,u]=re(null!=(r=l.useCell(ue,o,de,s))?r:"[]"),d=l.useSetCellCallback(ue,o,de,se,[],s);return M(Ae,{uniqueId:o,summary:"Query: "+n,s:s},M(fl,{queryId:n,queries:e,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},Ol=({queriesId:e,s:t})=>{const n=l.useQueries(e),s=l.useQueryIds(n);return R(n)?null:M(Ae,{uniqueId:pe("q",e),summary:"Queries: "+(null!=e?e:u),s:t},B(s)?"No queries defined":ve(s,(l=>M(Rl,{queries:n,queriesId:e,queryId:l,s:t}))))},ql=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=pe("r",l,t),[r,o]=ge(s,n);return M(Ae,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:o,s:n},M(Il,{relationshipId:t,relationships:e,editable:r}))},Pl=({relationshipsId:e,s:t})=>{const n=l.useRelationships(e),s=l.useRelationshipIds(n);return R(n)?null:M(Ae,{uniqueId:pe("r",e),summary:"Relationships: "+(null!=e?e:u),s:t},B(s)?"No relationships defined":ve(s,(l=>M(ql,{relationships:n,relationshipsId:e,relationshipId:l,s:t}))))},Nl=({tableId:e,store:t,storeId:n,s:s})=>{var r;const o=pe("t",n,e),[a,i,u]=re(null!=(r=l.useCell(ue,o,de,s))?r:"[]"),d=l.useSetCellCallback(ue,o,de,se,[],s),[h,m]=ge(o,s);return M(Ae,{uniqueId:o,summary:c+": "+e,editable:h,handleEditable:m,s:s},M(pl,{tableId:e,store:t,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:h}))},El=({store:e,storeId:t,s:n})=>{const s=pe("v",t),[r,o]=ge(s,n);return B(l.useValueIds(e))?null:M(Ae,{uniqueId:s,summary:y,editable:r,handleEditable:o,s:n},M(vl,{store:e,editable:r}))},Ll=({storeId:e,s:t})=>{const n=l.useStore(e),s=l.useTableIds(n);return R(n)?null:M(Ae,{uniqueId:pe("s",e),summary:"Store: "+(null!=e?e:u),s:t},M(El,{storeId:e,store:n,s:t}),ve(s,(l=>M(Nl,{store:n,storeId:e,tableId:l,s:t}))))},Ml=({s:e})=>{const t=$(null),n=$(0),[s,r]=A(!1),{scrollLeft:o,scrollTop:a}=l.useValues(e);z((()=>{const e=t.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=S(o)+e.clientWidth&&e.scrollHeight>=S(a)+e.clientHeight&&e.scrollTo(o,a)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,o,a]);const i=j((l=>{const{scrollLeft:t,scrollTop:s}=l[C];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=l.useStore(),d=l.useStoreIds(),c=l.useMetrics(),h=l.useMetricsIds(),m=l.useIndexes(),b=l.useIndexesIds(),p=l.useRelationships(),v=l.useRelationshipsIds(),g=l.useQueries(),I=l.useQueriesIds();return R(u)&&B(d)&&R(c)&&B(h)&&R(m)&&B(b)&&R(p)&&B(v)&&R(g)&&B(I)?M("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):M("article",{ref:t,onScroll:i},M(Ll,{s:e}),H(d,(l=>M(Ll,{storeId:l,key:l,s:e}))),M(Vl,{s:e}),H(h,(l=>M(Vl,{metricsId:l,key:l,s:e}))),M(Sl,{s:e}),H(b,(l=>M(Sl,{indexesId:l,key:l,s:e}))),M(Pl,{s:e}),H(v,(l=>M(Pl,{relationshipsId:l,key:l,s:e}))),M(Ol,{s:e}),H(I,(l=>M(Ol,{queriesId:l,key:l,s:e}))))};var jl=Object.defineProperty,zl=(e,l,t)=>(((e,l,t)=>{l in e?jl(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t})(e,"symbol"!=typeof l?l+"":l,t),t);class $l extends E{constructor(e){super(e),zl(this,"componentDidCatch",((e,l)=>console.error(e,l.componentStack))),this.state={e:0}}render(){return this.state.e?M("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl($l,"getDerivedStateFromError",(()=>({e:1})));const Al=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1,s=l.useSetValueCallback(me,(()=>!1),[],e),r=l.useSetValueCallback(he,(e=>Number(e[C].dataset.id)),[],e);return M("header",null,M("img",{title:ae}),M("span",null,ae),H(ie,((e,l)=>l==n?null:M("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),M("img",{onClick:s,title:"Close"}))},Fl=({s:e})=>{var t;const n=null!=(t=l.useValue(he,e))?t:1;return l.useValue(me,e)?M("main",{"data-position":n},M(Al,{s:e}),M($l,null,M(Ml,{s:e}))):null},Jl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Hl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Jl(Hl),Bl=Jl(Dl),Ql=Jl(Bl),Wl=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>R(e)||0==Hl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Ul=e=>e.clear(),Xl=(e,l)=>null==e?void 0:e.forEach(l),Yl=(e,l)=>null==e?void 0:e.delete(l),Zl=e=>new Map(e),_l=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},et=(e,l)=>null==e?void 0:e.get(l),lt=(e,l)=>Xl(e,((e,t)=>l(t,e))),tt=(e,l,t)=>R(t)?(Yl(e,l),e):null==e?void 0:e.set(l,t),nt=(e,l,t)=>(Wl(e,l)||tt(e,l,t()),et(e,l)),st=(e,l,t,n=tt)=>(te(l,((l,n)=>t(e,n,l))),lt(e,(t=>ee(l,t)?0:n(e,t))),e),rt=(e,l,t)=>{const n={};return Xl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>rt(e,(e=>rt(e,l,t)),ne),at=(e,l,t)=>rt(e,(e=>ot(e,l,t)),ne),it=(e,l)=>{const t=Zl();return Xl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},ut=e=>it(e,it),dt=e=>it(e,ut),ct=(e,l,t,n,s=0)=>O((t?nt:et)(e,l[s],s>D(l)-2?t:Zl),(r=>{if(s>D(l)-2)return(null==n?void 0:n(r))&&tt(e,l[s]),r;const o=ct(r,l,t,n,s+1);return Gl(r)&&tt(e,l[s]),o}));var ht=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const mt=Zl(),bt=Zl();var pt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const vt="storage",gt=globalThis.window,It=e=>new Set(N(e)||R(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),yt=/^\d+$/,wt=()=>{const e=[];let l=0;return[t=>{var s;return null!=(s=t?G(e):null)?s:n+l++},l=>{yt.test(l)&&D(e)<1e3&&W(e,l)}]},Ct=e=>[e,e],xt=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Zl(),Zl()],St=e=>[...e],Tt=([e,l])=>e===l,Vt=(e,l,t)=>R(e)||!Z(e)||ne(e)||X(e)?(null==t||t(),!1):(te(e,((t,n)=>{l(t,n)||le(e,n)})),!ne(e)),Rt=(e,l,t)=>tt(e,l,et(e,l)==-t?void 0:t),Ot=()=>{let e,l,t=!1,s=!1,r=0;const a=Zl(),d=Zl(),C=Zl(),x=Zl(),S=Zl(),T=Zl(),V=Zl(),N=Zl(),E=Zl(),L=Zl(),M=Zl(),j=Zl(),z=Zl(),$=Zl(),A=It(),F=Zl(),B=Zl(),G=Zl(),K=Zl(),U=kt(),X=kt(),Z=kt(),_=kt(),oe=kt(),ae=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ve=kt(),ge=Zl(),Ie=kt(),[fe,ye,we,Ce]=(e=>{let l;const[t,s]=wt(),r=Zl();return[(e,s,o,a=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return tt(r,u,[e,s,o,a,i]),ft(ct(s,null!=o?o:[n],It),u),u},(e,t,...s)=>J(((e,l=[n])=>{const t=[],s=(e,n)=>n==D(l)?W(t,e):null===l[n]?Xl(e,(e=>s(e,n+1))):J([l[n],null],(l=>s(et(e,l),n+1)));return s(e,0),t})(e,t),(e=>Xl(e,(e=>et(r,e)[0](l,...null!=t?t:[],...s))))),e=>O(et(r,e),(([,l,t])=>(ct(l,null!=t?t:[n],void 0,(l=>(Yl(l,e),Gl(l)?1:0))),tt(r,e),s(e),t))),e=>O(et(r,e),(([e,,t=[],n,s])=>{const r=(...o)=>{var a,i;const u=D(o);u==D(t)?e(l,...o,...s(o)):R(t[u])?J(null!=(i=null==(a=n[u])?void 0:a.call(n,...o))?i:[],(e=>r(...o,e))):r(...o,t[u])};r()}))]})(),xe=e=>{if(!Vt(e,((e,l)=>[i,u].includes(l))))return!1;const l=e[i];return!(!q(l)&&l!=o||(Fe(e[u])!=l&&le(e,u),0))},ke=(l,t)=>(!e||Wl(M,t)||nl(t))&&Vt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Vt(n?t:Oe(t,e,l),((n,s)=>O(Te(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Te=(l,t,n,s)=>e?O(et(et(M,l),n),(e=>Fe(s)!=e[i]?nl(l,t,n,s,e[u]):s),(()=>nl(l,t,n,s))):R(Fe(s))?nl(l,t,n,s):s,Ve=(e,l)=>Vt(l?e:qe(e),((l,t)=>O(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?O(et(z,e),(l=>Fe(t)!=l[i]?sl(e,t,l[u]):t),(()=>sl(e,t))):R(Fe(t))?sl(e,t):t,Oe=(e,l,t)=>(O(et(j,l),(([n,s])=>{Xl(n,((l,t)=>{ee(e,t)||(e[t]=l)})),Xl(s,(n=>{ee(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Xl($,((l,t)=>{ee(e,t)||(e[t]=l)})),Xl(A,(l=>{ee(e,l)||sl(l)}))),e),Pe=e=>st(M,e,((e,l,t)=>{const n=Zl(),s=It();st(nt(M,l,Zl),t,((e,l,t)=>{tt(e,l,t),O(t[u],(e=>tt(n,l,e)),(()=>ft(s,l)))})),tt(j,l,[n,s])}),((e,l)=>{tt(M,l),tt(j,l)})),Ne=e=>st(z,e,((e,l,t)=>{tt(z,l,t),O(t[u],(e=>tt($,l,e)),(()=>ft(A,l)))}),((e,l)=>{tt(z,l),tt($,l),Yl(A,l)})),Ee=e=>ne(e)?ql():Sl(e),Le=e=>st(G,e,((e,l,t)=>Me(l,t)),((e,l)=>Ge(l))),Me=(e,l)=>st(nt(G,e,(()=>(Ye(e,1),tt(F,e,wt()),tt(B,e,Zl()),Zl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ke(e,l,t))),je=(e,l,t,n,s)=>st(nt(l,t,(()=>(Ze(e,t,1),Zl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ue(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Wl(t,n)||_e(e,l,n,1);const r=et(t,n);s!==r&&(el(e,l,n,r,s),tt(t,n,s))},$e=(e,l,t,n,s)=>O(et(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>ne(e)?El():Tl(e),De=e=>st(K,e,((e,l,t)=>Be(l,t)),((e,l)=>Xe(l))),Be=(e,l)=>{Wl(K,e)||ll(e,1);const t=et(K,e);l!==t&&(tl(e,t,l),tt(K,e,l))},Qe=(e,l)=>{const[t]=et(F,e),n=t(l);return Wl(et(G,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=et(G,e))?l:Me(e,{})},Ge=e=>Me(e,{}),Ke=(e,l,t)=>{const[,n]=et(F,e);n(t),je(e,l,t,{},!0)},Ue=(e,l,t,n,s,r)=>{var o;const a=et(null==(o=et(j,e))?void 0:o[0],s);if(!R(a)&&!r)return ze(e,t,n,s,a);const i=l=>{el(e,t,l,et(n,l)),_e(e,t,l,-1),tt(n,l)};R(a)?i(s):lt(n,i),Gl(n)&&(Ze(e,t,-1),Gl(tt(l,t))&&(Ye(e,-1),tt(G,e),tt(F,e),tt(B,e)))},Xe=e=>{const l=et($,e);if(!R(l))return Be(e,l);tl(e,et(K,e)),ll(e,-1),tt(K,e)},Ye=(e,l)=>Rt(a,e,l),Ze=(e,l,t)=>Rt(nt(x,e,Zl),l,t)&&tt(C,e,nt(C,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=et(B,e),o=null!=(s=et(r,t))?s:0;(0==o&&1==n||1==o&&-1==n)&&Rt(nt(d,e,Zl),t,n),tt(r,t,o!=-n?o+n:null),Rt(nt(nt(S,e,Zl),l,Zl),t,n)},el=(e,l,t,n,s)=>nt(nt(nt(T,e,Zl),l,Zl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Rt(V,e,l),tl=(e,l,t)=>nt(N,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(W(nt(nt(nt(E,e,Zl),l,Zl),t,(()=>[])),n),s),sl=(e,l,t)=>(W(nt(L,e,(()=>[])),l),t),rl=(e,l,t)=>O(et(et(et(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...Ct(wl(e,l,t))])),ol=e=>O(et(N,e),(([e,l])=>[!0,e,l]),(()=>[!1,...Ct(kl(e))])),al=e=>Gl(E)||Gl(he[e])?0:Xl(e?dt(E):E,((l,t)=>Xl(l,((l,n)=>Xl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Gl(L)||Gl(me[e])?0:Xl(e?it(L):L,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Gl(l))return ye(e,t,(()=>rt(l))),1},dl=e=>{const l=Gl(ie[e]),t=Gl(de[e])&&Gl(_[e])&&Gl(oe[e])&&Gl(ae[e])&&l&&Gl(X[e]),n=Gl(ce[e])&&Gl(ue[e])&&Gl(Z[e])&&Gl(U[e]);if(!t||!n){const s=e?[it(a),ut(d),it(C),ut(x),dt(S),dt(T)]:[a,d,C,x,S,T];if(!t){ul(X[e],s[0]),Xl(s[1],((l,t)=>ul(_[e],l,[t]))),Xl(s[2],((l,t)=>{0!=l&&ye(oe[e],[t],gl(t))}));const t=It();Xl(s[3],((n,s)=>{ul(ae[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Xl(s[5],((l,n)=>{if(!Wl(t,n)){const t=It();Xl(l,(e=>Xl(e,(([l,n],s)=>n!==l?ft(t,s):Yl(e,s))))),Xl(t,(l=>ye(ie[e],[n,l])))}})),Xl(s[4],((l,t)=>Xl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Xl(s[5],((t,n)=>{let s;Xl(t,((t,r)=>{let o;Xl(t,(([t,a],i)=>{a!==t&&(ye(ce[e],[n,r,i],a,t,rl),l=s=o=1)})),o&&ye(ue[e],[n,r],rl)})),s&&ye(Z[e],[n],rl)})),l&&ye(U[e],void 0,rl)}}},cl=e=>{const l=Gl(pe[e]),t=Gl(ve[e])&&Gl(be[e]);if(!l||!t){const n=e?[it(V),it(N)]:[V,N];if(l||ul(pe[e],n[0]),!t){let l;Xl(n[1],(([t,n],s)=>{n!==t&&(ye(ve[e],[s],n,t,ol),l=1)})),l&&ye(be[e],void 0,ol)}}},hl=(e,...l)=>(jl((()=>e(...H(l,k)))),Al),ml=()=>[rt(T,((e,l)=>-1===et(a,l)?null:rt(e,((e,t)=>-1===et(et(x,l),t)?null:rt(e,(([,e])=>null!=e?e:null),((e,l)=>Tt(l)))),ne)),ne),rt(N,(([,e])=>null!=e?e:null),((e,l)=>Tt(l)))],bl=()=>({cellsTouched:t,valuesTouched:s,changedCells:at(T,St,Tt),invalidCells:at(E),changedValues:rt(N,St,Tt),invalidValues:rt(L),changedTableIds:rt(a),changedRowIds:ot(x),changedCellIds:at(S),changedValueIds:rt(V)}),pl=()=>at(G),vl=()=>_l(G),gl=e=>Hl(et(G,k(e))),Il=e=>_l(et(G,k(e))),fl=(e,l,t,n=0,s)=>{return H(Q((o=et(G,k(e)),a=(e,t)=>[R(l)?t:et(e,k(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},H([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,l])=>a(l,e))).sort(r)),n,R(s)?s:n+s),(([,e])=>e));var r,o,a,i},yl=(e,l)=>_l(et(et(G,k(e)),k(l))),wl=(e,l,t)=>et(et(et(G,k(e)),k(l)),k(t)),Cl=()=>rt(K),xl=()=>_l(K),kl=e=>et(K,k(e)),Sl=e=>hl((()=>(e=>Vt(e,ke,nl))(e)?Le(e):0)),Tl=e=>hl((()=>Ve(e)?De(e):0)),Vl=e=>{try{Ee(re(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=Vt(l,(e=>Vt(e,xe))))&&(Pe(l),!Gl(G))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Vt(e,xe))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Wl(G,e)?Ge(e):0),e),Nl=(e,l)=>hl(((e,l)=>O(et(G,e),(t=>Wl(t,l)?Ke(e,t,l):0))),e,l),El=()=>hl((()=>De({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ge,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Gl(T),s=!Gl(N),r=1,al(1),t&&dl(1),il(1),s&&cl(1),(null==e?void 0:e(ml,bl))&&(Xl(T,((e,l)=>Xl(e,((e,t)=>Xl(e,(([e],n)=>Je(Al,l,t,n,e))))))),Xl(N,(([e],l)=>He(Al,l,e))),t=s=!1),ye(Ie[0],void 0,ml,bl),r=-1,al(0),t&&dl(0),il(0),s&&cl(0),ye(Ie[1],void 0,ml,bl),r=0,t=s=!1,J([a,d,C,x,S,T,E,V,N,L],Ul))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:vl,getTable:e=>ot(et(G,k(e))),getTableCellIds:e=>_l(et(B,k(e))),getRowCount:gl,getRowIds:Il,getSortedRowIds:fl,getRow:(e,l)=>rt(et(et(G,k(e)),k(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:xl,getValue:kl,hasTables:()=>!Gl(G),hasTable:e=>Wl(G,k(e)),hasTableCell:(e,l)=>Wl(et(B,k(e)),k(l)),hasRow:(e,l)=>Wl(et(G,k(e)),k(l)),hasCell:(e,l,t)=>Wl(et(et(G,k(e)),k(l)),k(t)),hasValues:()=>!Gl(K),hasValue:e=>Wl(K,k(e)),getTablesJson:()=>se(G),getValuesJson:()=>se(K),getJson:()=>se([G,K]),getTablesSchemaJson:()=>se(M),getValuesSchemaJson:()=>se(z),getSchemaJson:()=>se([M,z]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(ne(e)?ql:Sl)(e),(ne(l)?El:Tl)(l)})),setTables:Sl,setTable:(e,l)=>hl((e=>ke(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>Se(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return Se(e,n,l)&&(e=k(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(Se(e,l,t,1)){const n=We(e);te(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>O(Te(e,l,t,P(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Tl,setPartialValues:e=>hl((()=>Ve(e,1)?te(e,((e,l)=>Be(l,e))):0)),setValue:(e,l)=>hl((e=>O(Re(e,P(l)?l(kl(e)):l),(l=>Be(e,l)))),e),setTransactionChanges:e=>hl((()=>{te(e[0],((e,l)=>R(e)?Pl(l):te(e,((e,t)=>R(e)?Nl(l,t):te(e,((e,n)=>Je(Al,l,t,n,e))))))),te(e[1],((e,l)=>He(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(re(e))}catch(e){}return Al},setJson:e=>{try{const[l,t]=re(e);Ee(l),Ae(t)}catch(l){Vl(e)}return Al},setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>O(et(G,e),(s=>O(et(s,l),(r=>Wl(r,t)?Ue(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Wl(K,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Xl(G,((l,t)=>e(t,(e=>Xl(l,((l,t)=>e(t,(e=>lt(l,e))))))))),forEachTableCell:(e,l)=>lt(et(B,k(e)),l),forEachRow:(e,l)=>Xl(et(G,k(e)),((e,t)=>l(t,(l=>lt(e,l))))),forEachCell:(e,l,t)=>lt(et(et(G,k(e)),k(l)),t),forEachValue:e=>lt(K,e),addSortedRowIdsListener:(e,l,t,n,s,r,o)=>{let a=fl(e,l,t,n,s);return fe((()=>{const o=fl(e,l,t,n,s);var i,u,d;u=a,D(i=o)===D(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(a=o,r(Al,e,l,t,n,s,a))}),ie[o?1:0],[e,l],[vl])},addStartTransactionListener:e=>fe(e,ge),addWillFinishTransactionListener:e=>fe(e,Ie[0]),addDidFinishTransactionListener:e=>fe(e,Ie[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:xt(U),tableIds:xt(X),tableCellIds:xt(_),table:xt(Z),rowCount:xt(oe),rowIds:xt(ae),sortedRowIds:xt(ie),row:xt(ue,Bl),cellIds:xt(de,Bl),cell:xt(ce,Ql),invalidCell:xt(he,Ql),values:xt(be),valueIds:xt(pe),value:xt(ve),invalidValue:xt(me),transaction:Dl(ge)+xt(Ie)}),createStore:Ot,addListener:fe,callListeners:ye};return te({[h]:[0,U],[m]:[0,X],[c]:[1,Z,[vl]],[c+I]:[1,_,[vl]],[p]:[1,oe,[vl]],[v]:[1,ae,[vl]],[b]:[2,ue,[vl,Il]],[I]:[2,de,[vl,Il]],[g]:[3,ce,[vl,Il,yl],e=>Ct(wl(...e))],InvalidCell:[3,he],[y]:[0,be],[w]:[0,pe],[f]:[1,ve,[xl],e=>Ct(kl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>fe(s[e],l[s[e+1]?1:0],e>0?Q(s,0,e):void 0,t,n)})),Y(Al)},qt=({position:e="right",open:t=!1})=>{const n=l.useCreateStore(Ot),s=ie.indexOf(e);return l.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,o=[])=>{let a,i,u,d=0,c=0,h=0,m=0;nt(mt,o,(()=>0)),nt(bt,o,(()=>[]));const b=e=>ht(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ht(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ht(void 0,null,(function*(){return yield b((()=>ht(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ht(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ht(void 0,null,(function*(){if(n){const l=n();yield b((()=>ht(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ht(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ht(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ht(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ht(void 0,null,(function*(){return yield p.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();ne(t)&&ne(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(O(a,e.delListener),p),schedule:(...e)=>ht(void 0,null,(function*(){return W(et(bt,o),...e),yield ht(void 0,null,(function*(){if(!et(mt,o)){for(tt(mt,o,1);!R(i=G(et(bt,o)));)try{yield i()}catch(e){null==r||r(e)}tt(mt,o,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Y(p)})(e,(()=>pt(void 0,null,(function*(){return re(t.getItem(l))}))),(e=>pt(void 0,null,(function*(){return t.setItem(l,se(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>re(n.newValue)))};return gt.addEventListener(vt,n),n}),(e=>gt.removeEventListener(vt,e)),n))(e,oe,sessionStorage,l);var l}),void 0,(e=>{return l=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!t}),yield e.startAutoSave()},new Promise(((e,t)=>{var n=e=>{try{r(l.next(e))}catch(e){t(e)}},s=e=>{try{r(l.throw(e))}catch(e){t(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((l=l.apply(void 0,null)).next())}));var l})),M(L,null,M("aside",{id:oe},M($e,{s:n}),M(Fl,{s:n})),M("style",null,ze))};var Pt=Object.defineProperty,Nt=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Mt=(e,l,t)=>l in e?Pt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;exports.EditableCellView=yl,exports.EditableValueView=wl,exports.RelationshipInHtmlTable=Il,exports.ResultSortedTableInHtmlTable=fl,exports.ResultTableInHtmlTable=e=>{var t=e,{queryId:n,queries:s,customCells:r}=t,o=_e(t,["queryId","queries","customCells"]);return M(cl,Ze(Ye({},o),{params:ol(dl(l.useResultTableCellIds(n,s),r,l.ResultCellView),il(s,n),l.useResultRowIds(n,s))}))},exports.SliceInHtmlTable=gl,exports.SortedTableInHtmlTable=pl,exports.SortedTablePaginator=Cl,exports.StoreInspector=e=>M(qt,((e,l)=>{for(var t in l||(l={}))Et.call(l,t)&&Mt(e,t,l[t]);if(Nt)for(var t of Nt(l))Lt.call(l,t)&&Mt(e,t,l[t]);return e})({},e)),exports.TableInHtmlTable=e=>{var t=e,{tableId:n,store:s,editable:r,customCells:o}=t,a=_e(t,["tableId","store","editable","customCells"]);return M(cl,Ze(Ye({},a),{params:ol(dl(l.useTableCellIds(n,s),o,r?yl:l.CellView),al(s,n),l.useRowIds(n,s))}))},exports.ValuesInHtmlTable=vl;
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("./ui-react");const l=e=>typeof e,r=l(""),o=l(!0),a=l(0),n="Value",s="currentTarget",i="value",d=isFinite,u=e=>null==e,{PureComponent:c,Fragment:m,createElement:h,useCallback:b,useLayoutEffect:p,useRef:g,useState:f}=e,w=(e,...t)=>u(e)?{}:e(...t),v=(e,t)=>e.map(t),I=Object,y=(e=[])=>I.fromEntries(e),C=(e,t)=>v(I.entries(e),(([e,l])=>t(l,e))),x="tinybaseStoreInspector",k="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",O='content:url("',R=O+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',T=O+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",N=v([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+S)),V=R+"<path d='M20 20l60 60M20 80l60-60' />"+S,P=R+`<path d='${k}' />`+S,j=R+`<path d='${k}M20 20l60 60' />`+S;var z=Object.defineProperty,$=Object.defineProperties,q=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,H=(e,t,l)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,B=(e,t)=>{for(var l in t||(t={}))E.call(t,l)&&H(e,l,t[l]);if(M)for(var l of M(t))F.call(t,l)&&H(e,l,t[l]);return e},D=(e,t)=>$(e,q(t));const A="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(C(D(B(D(B(D(B({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[A]:"width:0.5rem;height:0.5rem;",[A+"-track"]:"background:#111",[A+"-thumb"]:"background:#999;border:1px solid #111",[A+"-thumb:hover"]:"background:#fff",[A+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+T},y(v(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),y(v(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":T,"header>img:nth-of-type(6)":V}),y(v(N,((e,t)=>[`header>img[data-id='${t}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":P,"details[open]>summary img.done":j,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${x} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,t)=>e?`#${x} ${t}{${e}}`:"")));const L=(e,t,l,o)=>e==r?t:e==a?l:o;var G=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,X=(e,t,l)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Y=(e,t)=>{for(var l in t||(t={}))U.call(t,l)&&X(e,l,t[l]);if(Q)for(var l of Q(t))W.call(t,l)&&X(e,l,t[l]);return e},Z=(e,t)=>J(e,K(t)),_=(e,t)=>{var l={};for(var r in e)U.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&Q)for(var r of Q(e))t.indexOf(r)<0&&W.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:ee,useMemo:te,useState:le}=e,re="editable",oe=(e,l)=>v(t.useTableCellIds(e,l),(t=>e+"."+t)),ae=(e,t,l)=>{const r=ee(e,t);return l?r:void 0},ne=(...e)=>te((()=>e),e),se=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),ie=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,r=0,o,a,n,s)=>{const[[i,d,u],c]=le([e,t,r]),m=ee((e=>{c(e),null==s||s(e)}),[s]),b=ae((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=ee((e=>m([i,d,e])),[m,i,d]),g=!0===n?fe:n;return[[i,d,u],b,te((()=>!1===n?null:h(g,{offset:u,limit:o,total:a,onChange:p})),[n,g,u,o,a,p])]},ue=(e,t,o)=>te((()=>{const a=null!=t?t:e;return y(C(Array.isArray(a)?y(v(a,(e=>[e,e]))):a,((e,t)=>{return[t,Y(Y({},{label:t,component:o}),(a=e,l(a)==r?{label:e}:e))];var a})))}),[t,o,e]),ce=({className:e,headerRow:t,idColumn:l,params:[r,o,a,n,s,i]})=>h("table",{className:e},i?h("caption",null,i):null,!1===t?null:h("thead",null,h("tr",null,!1===l?null:h(me,{sort:null!=n?n:[],label:"Id",onClick:s}),C(r,(({label:e},t)=>h(me,{key:t,cellId:t,label:e,sort:null!=n?n:[],onClick:s}))))),h("tbody",null,v(a,(e=>h("tr",{key:e},!1===l?null:h("th",null,e),C(r,(({component:t,getComponentProps:l},r)=>h("td",{key:r},h(t,Z(Y(Y({},w(l,e,r)),o),{rowId:e,cellId:r})))))))))),me=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:o})=>h("th",{onClick:ae((()=>null==o?void 0:o(e)),[o,e],o),className:u(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},u(l)||t!=e?null:(l?"↓":"↑")+" ",r),he=({localRowId:l,params:[r,o,a,n,s,i,d]})=>{const c=t.useRemoteRowId(s,l,i);return h("tr",null,!1===r?null:h(e.Fragment,null,h("th",null,l),h("th",null,c)),C(o,(({component:e,getComponentProps:t},r)=>{const[o,s]=r.split(".",2),i=o===a?l:o===n?c:null;return u(i)?null:h("td",{key:r},h(e,Z(Y({},w(t,i,s)),{store:d,tableId:o,rowId:i,cellId:s})))})))},be=({thing:e,onThingChange:t,className:n,hasSchema:u})=>{const[c,m]=le(),[b,p]=le(),[g,f]=le(),[w,v]=le(),[I,y]=le();b!==e&&(m((e=>{const t=l(e);return(e=>e==r||e==o)(t)||t==a&&d(e)?t:void 0})(e)),p(e),f(e+""),v(Number(e)||0),y(!!e));const C=ee(((e,l)=>{l(e),p(e),t(e)}),[t]);return h("div",{className:n},h("button",{className:c,onClick:ee((()=>{if(!(null==u?void 0:u())){const e=L(c,a,o,r),l=L(e,g,w,I);m(e),p(l),t(l)}}),[u,t,g,w,I,c])},c),L(c,h("input",{key:c,value:g,onChange:ee((e=>C(e[s][i]+"",f)),[C])}),h("input",{key:c,type:"number",value:w,onChange:ee((e=>C(Number(e[s][i]||0),v)),[C])}),h("input",{key:c,type:"checkbox",checked:I,onChange:ee((e=>C(!!e[s].checked,y)),[C])})))},pe=({tableId:e,rowId:l,cellId:r,store:o,className:a})=>{var n;return h(be,{thing:t.useCell(e,l,r,o),onThingChange:t.useSetCellCallback(e,l,r,(e=>e),[],o),className:null!=a?a:re+"Cell",hasSchema:null==(n=t.useStoreOrStoreById(o))?void 0:n.hasTablesSchema})},ge=({valueId:e,store:l,className:r})=>{var o;return h(be,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=r?r:re+n,hasSchema:null==(o=t.useStoreOrStoreById(l))?void 0:o.hasValuesSchema})},fe=({onChange:t,total:l,offset:r=0,limit:o=l,singular:a="row",plural:n=a+"s"})=>{(r>l||r<0)&&(r=0,t(0));const s=ae((()=>t(r-o)),[t,r,o],r>0),i=ae((()=>t(r+o)),[t,r,o],r+o<l);return h(e.Fragment,null,l>o&&h(e.Fragment,null,h("button",{className:"previous",disabled:0==r,onClick:s},"←"),h("button",{className:"next",disabled:r+o>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+o)," of "),l," ",1!=l?n:a)};var we=Object.defineProperty,ve=(e,t,l)=>(((e,t,l)=>{t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l})(e,"symbol"!=typeof t?t+"":t,l),l);ve(class extends c{constructor(e){super(e),ve(this,"componentDidCatch",((e,t)=>console.error(e,t.componentStack))),this.state={e:0}}render(){return this.state.e?h("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}},"getDerivedStateFromError",(()=>({e:1})));const Ie=e=>new Map(e);Ie(),Ie(),exports.EditableCellView=pe,exports.EditableValueView=ge,exports.RelationshipInHtmlTable=({relationshipId:l,relationships:r,editable:o,customCells:a,className:n,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(r),l),b=ue([...oe(c,u),...oe(m,u)],a,o?pe:t.CellView),p=ne(i,b,c,m,l,d,u);return h("table",{className:n},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h(e.Fragment,null,h("th",null,c,".Id"),h("th",null,m,".Id")),C(b,(({label:e},t)=>h("th",{key:t},e))))),h("tbody",null,v(t.useRowIds(c,u),(e=>h(he,{key:e,localRowId:e,params:p})))))},exports.ResultSortedTableInHtmlTable=e=>{var l=e,{queryId:r,cellId:o,descending:a,offset:n,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=l,b=_(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=de(o,a,d,n,s,t.useResultRowCount(r,i),u,m);return h(ce,Z(Y({},b),{params:ne(ue(t.useResultTableCellIds(r,i),c,t.ResultCellView),ie(i,r),t.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},exports.ResultTableInHtmlTable=e=>{var l=e,{queryId:r,queries:o,customCells:a}=l,n=_(l,["queryId","queries","customCells"]);return h(ce,Z(Y({},n),{params:ne(ue(t.useResultTableCellIds(r,o),a,t.ResultCellView),ie(o,r),t.useResultRowIds(r,o))}))},exports.SliceInHtmlTable=e=>{var l=e,{indexId:r,sliceId:o,indexes:a,editable:n,customCells:s}=l,i=_(l,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(t.useIndexesOrIndexesById(a),r);return h(ce,Z(Y({},i),{params:ne(ue(t.useTableCellIds(c,u),s,n?pe:t.CellView),se(u,c),t.useSliceRowIds(r,o,d))}))},exports.SortedTableInHtmlTable=e=>{var l=e,{tableId:r,cellId:o,descending:a,offset:n,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:b}=l,p=_(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=de(o,a,u,n,s,t.useRowCount(r,i),c,m);return h(ce,Z(Y({},p),{params:ne(ue(t.useTableCellIds(r,i),b,d?pe:t.CellView),se(i,r),t.useSortedRowIds(r,...g,s,i),g,f,w)}))},exports.SortedTablePaginator=fe,exports.StoreInspector=e=>null,exports.TableInHtmlTable=e=>{var l=e,{tableId:r,store:o,editable:a,customCells:n}=l,s=_(l,["tableId","store","editable","customCells"]);return h(ce,Z(Y({},s),{params:ne(ue(t.useTableCellIds(r,o),n,a?pe:t.CellView),se(o,r),t.useRowIds(r,o))}))},exports.ValuesInHtmlTable=({store:e,editable:l=!1,valueComponent:r=(l?ge:t.ValueView),getValueComponentProps:o,className:a,headerRow:s,idColumn:i})=>h("table",{className:a},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h("th",null,"Id"),h("th",null,n))),h("tbody",null,v(t.useValueIds(e),(t=>h("tr",{key:t},!1===i?null:h("th",null,t),h("td",null,h(r,Z(Y({},w(o,t)),{valueId:t,store:e}))))))));
1
+ "use strict";var e=require("react"),t=require("./ui-react");const l=e=>typeof e,r=l(""),o=l(!0),a=l(0),n="Value",s="currentTarget",i="value",d=isFinite,u=e=>null==e,{PureComponent:c,Fragment:m,createElement:h,useCallback:b,useLayoutEffect:p,useRef:g,useState:f}=e,w=(e,...t)=>u(e)?{}:e(...t),v=(e,t)=>e.map(t),I=Object,y=(e=[])=>I.fromEntries(e),C=(e,t)=>v(I.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",k='content:url("',O=k+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",R='</svg>")',S=k+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",T=v([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>O+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+R)),N=O+"<path d='M20 20l60 60M20 80l60-60' />"+R,V=O+`<path d='${x}' />`+R,P=O+`<path d='${x}M20 20l60 60' />`+R;var j=Object.defineProperty,z=Object.defineProperties,q=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,l)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,H=(e,t)=>{for(var l in t||(t={}))$.call(t,l)&&F(e,l,t[l]);if(M)for(var l of M(t))E.call(t,l)&&F(e,l,t[l]);return e},B=(e,t)=>z(e,q(t));const D="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(C(B(H(B(H(B(H({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[D]:"width:0.5rem;height:0.5rem;",[D+"-track"]:"background:#111",[D+"-thumb"]:"background:#999;border:1px solid #111",[D+"-thumb:hover"]:"background:#fff",[D+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+S},y(v(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),y(v(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":S,"header>img:nth-of-type(6)":N}),y(v(T,((e,t)=>[`header>img[data-id='${t}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":V,"details[open]>summary img.done":P,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,t)=>e?`& ${t}{${e}}`:"")));const A=(e,t,l,o)=>e==r?t:e==a?l:o;var L=Object.defineProperty,G=Object.defineProperties,J=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,W=(e,t,l)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,X=(e,t)=>{for(var l in t||(t={}))Q.call(t,l)&&W(e,l,t[l]);if(K)for(var l of K(t))U.call(t,l)&&W(e,l,t[l]);return e},Y=(e,t)=>G(e,J(t)),Z=(e,t)=>{var l={};for(var r in e)Q.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&K)for(var r of K(e))t.indexOf(r)<0&&U.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:_,useMemo:ee,useState:te}=e,le="editable",re=(e,l)=>v(t.useTableCellIds(e,l),(t=>e+"."+t)),oe=(e,t,l)=>{const r=_(e,t);return l?r:void 0},ae=(...e)=>ee((()=>e),e),ne=(e,t)=>ee((()=>({store:e,tableId:t})),[e,t]),se=(e,t)=>ee((()=>({queries:e,queryId:t})),[e,t]),ie=(e,t=!1,l,r=0,o,a,n,s)=>{const[[i,d,u],c]=te([e,t,r]),m=_((e=>{c(e),null==s||s(e)}),[s]),b=oe((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=_((e=>m([i,d,e])),[m,i,d]),g=!0===n?ge:n;return[[i,d,u],b,ee((()=>!1===n?null:h(g,{offset:u,limit:o,total:a,onChange:p})),[n,g,u,o,a,p])]},de=(e,t,o)=>ee((()=>{const a=null!=t?t:e;return y(C(Array.isArray(a)?y(v(a,(e=>[e,e]))):a,((e,t)=>{return[t,X(X({},{label:t,component:o}),(a=e,l(a)==r?{label:e}:e))];var a})))}),[t,o,e]),ue=({className:e,headerRow:t,idColumn:l,params:[r,o,a,n,s,i]})=>h("table",{className:e},i?h("caption",null,i):null,!1===t?null:h("thead",null,h("tr",null,!1===l?null:h(ce,{sort:null!=n?n:[],label:"Id",onClick:s}),C(r,(({label:e},t)=>h(ce,{key:t,cellId:t,label:e,sort:null!=n?n:[],onClick:s}))))),h("tbody",null,v(a,(e=>h("tr",{key:e},!1===l?null:h("th",null,e),C(r,(({component:t,getComponentProps:l},r)=>h("td",{key:r},h(t,Y(X(X({},w(l,e,r)),o),{rowId:e,cellId:r})))))))))),ce=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:o})=>h("th",{onClick:oe((()=>null==o?void 0:o(e)),[o,e],o),className:u(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},u(l)||t!=e?null:(l?"↓":"↑")+" ",r),me=({localRowId:l,params:[r,o,a,n,s,i,d]})=>{const c=t.useRemoteRowId(s,l,i);return h("tr",null,!1===r?null:h(e.Fragment,null,h("th",null,l),h("th",null,c)),C(o,(({component:e,getComponentProps:t},r)=>{const[o,s]=r.split(".",2),i=o===a?l:o===n?c:null;return u(i)?null:h("td",{key:r},h(e,Y(X({},w(t,i,s)),{store:d,tableId:o,rowId:i,cellId:s})))})))},he=({thing:e,onThingChange:t,className:n,hasSchema:u})=>{const[c,m]=te(),[b,p]=te(),[g,f]=te(),[w,v]=te(),[I,y]=te();b!==e&&(m((e=>{const t=l(e);return(e=>e==r||e==o)(t)||t==a&&d(e)?t:void 0})(e)),p(e),f(e+""),v(Number(e)||0),y(!!e));const C=_(((e,l)=>{l(e),p(e),t(e)}),[t]);return h("div",{className:n},h("button",{className:c,onClick:_((()=>{if(!(null==u?void 0:u())){const e=A(c,a,o,r),l=A(e,g,w,I);m(e),p(l),t(l)}}),[u,t,g,w,I,c])},c),A(c,h("input",{key:c,value:g,onChange:_((e=>C(e[s][i]+"",f)),[C])}),h("input",{key:c,type:"number",value:w,onChange:_((e=>C(Number(e[s][i]||0),v)),[C])}),h("input",{key:c,type:"checkbox",checked:I,onChange:_((e=>C(!!e[s].checked,y)),[C])})))},be=({tableId:e,rowId:l,cellId:r,store:o,className:a})=>{var n;return h(he,{thing:t.useCell(e,l,r,o),onThingChange:t.useSetCellCallback(e,l,r,(e=>e),[],o),className:null!=a?a:le+"Cell",hasSchema:null==(n=t.useStoreOrStoreById(o))?void 0:n.hasTablesSchema})},pe=({valueId:e,store:l,className:r})=>{var o;return h(he,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=r?r:le+n,hasSchema:null==(o=t.useStoreOrStoreById(l))?void 0:o.hasValuesSchema})},ge=({onChange:t,total:l,offset:r=0,limit:o=l,singular:a="row",plural:n=a+"s"})=>{(r>l||r<0)&&(r=0,t(0));const s=oe((()=>t(r-o)),[t,r,o],r>0),i=oe((()=>t(r+o)),[t,r,o],r+o<l);return h(e.Fragment,null,l>o&&h(e.Fragment,null,h("button",{className:"previous",disabled:0==r,onClick:s},"←"),h("button",{className:"next",disabled:r+o>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+o)," of "),l," ",1!=l?n:a)};var fe=Object.defineProperty,we=(e,t,l)=>(((e,t,l)=>{t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l})(e,"symbol"!=typeof t?t+"":t,l),l);we(class extends c{constructor(e){super(e),we(this,"componentDidCatch",((e,t)=>console.error(e,t.componentStack))),this.state={e:0}}render(){return this.state.e?h("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}},"getDerivedStateFromError",(()=>({e:1})));const ve=e=>new Map(e);ve(),ve(),exports.EditableCellView=be,exports.EditableValueView=pe,exports.RelationshipInHtmlTable=({relationshipId:l,relationships:r,editable:o,customCells:a,className:n,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(r),l),b=de([...re(c,u),...re(m,u)],a,o?be:t.CellView),p=ae(i,b,c,m,l,d,u);return h("table",{className:n},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h(e.Fragment,null,h("th",null,c,".Id"),h("th",null,m,".Id")),C(b,(({label:e},t)=>h("th",{key:t},e))))),h("tbody",null,v(t.useRowIds(c,u),(e=>h(me,{key:e,localRowId:e,params:p})))))},exports.ResultSortedTableInHtmlTable=e=>{var l=e,{queryId:r,cellId:o,descending:a,offset:n,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=l,b=Z(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=ie(o,a,d,n,s,t.useResultRowCount(r,i),u,m);return h(ue,Y(X({},b),{params:ae(de(t.useResultTableCellIds(r,i),c,t.ResultCellView),se(i,r),t.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},exports.ResultTableInHtmlTable=e=>{var l=e,{queryId:r,queries:o,customCells:a}=l,n=Z(l,["queryId","queries","customCells"]);return h(ue,Y(X({},n),{params:ae(de(t.useResultTableCellIds(r,o),a,t.ResultCellView),se(o,r),t.useResultRowIds(r,o))}))},exports.SliceInHtmlTable=e=>{var l=e,{indexId:r,sliceId:o,indexes:a,editable:n,customCells:s}=l,i=Z(l,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(t.useIndexesOrIndexesById(a),r);return h(ue,Y(X({},i),{params:ae(de(t.useTableCellIds(c,u),s,n?be:t.CellView),ne(u,c),t.useSliceRowIds(r,o,d))}))},exports.SortedTableInHtmlTable=e=>{var l=e,{tableId:r,cellId:o,descending:a,offset:n,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:b}=l,p=Z(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=ie(o,a,u,n,s,t.useRowCount(r,i),c,m);return h(ue,Y(X({},p),{params:ae(de(t.useTableCellIds(r,i),b,d?be:t.CellView),ne(i,r),t.useSortedRowIds(r,...g,s,i),g,f,w)}))},exports.SortedTablePaginator=ge,exports.StoreInspector=e=>null,exports.TableInHtmlTable=e=>{var l=e,{tableId:r,store:o,editable:a,customCells:n}=l,s=Z(l,["tableId","store","editable","customCells"]);return h(ue,Y(X({},s),{params:ae(de(t.useTableCellIds(r,o),n,a?be:t.CellView),ne(o,r),t.useRowIds(r,o))}))},exports.ValuesInHtmlTable=({store:e,editable:l=!1,valueComponent:r=(l?pe:t.ValueView),getValueComponentProps:o,className:a,headerRow:s,idColumn:i})=>h("table",{className:a},!1===s?null:h("thead",null,h("tr",null,!1===i?null:h("th",null,"Id"),h("th",null,n))),h("tbody",null,v(t.useValueIds(e),(t=>h("tr",{key:t},!1===i?null:h("th",null,t),h("td",null,h(r,Y(X({},w(o,t)),{valueId:t,store:e}))))))));
Binary file