tosijs 1.5.8 → 1.5.9

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.
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ ${f} }`}else return UL(f,L,M)},t=(E,M="")=>{return Object.keys(E).map((L)=>{let
9
9
  ${$}
10
10
  }`}).join(`
11
11
 
12
- `)},Jf=(E)=>{j("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let M={};for(let f of Object.keys(E)){let L=E[f],H=S(f);M[`--${H}`]=typeof L==="number"&&L!==0?String(L)+"px":L}return M},$f=(E)=>{let M={};for(let f of Object.keys(E)){let L=E[f];if(L instanceof G)M[f]=L.inverseLuminance;else if(typeof L==="string"&&L.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))M[f]=G.fromCss(L).inverseLuminance}return M},KE=new Proxy({},{get(E,M){if(E[M]===void 0){let f="--"+S(M);E[M]=(L)=>`var(${f}, ${L})`}return E[M]}}),SE=new Proxy({},{get(E,M){if(M==="default")return KE;if(E[M]==null){M=S(M);let[,f,,L,H,$]=M.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",M],J=`--${f}`;if(H!=null){let Q=L==null?Number(H)/100:-Number(H)/100;switch($){case"b":case"s":case"h":case"o":{let Z=`--${M}`;G.registerComputedColor(Z,J,Q,$),E[M]=`var(${Z})`}break;case"":E[M]=`calc(var(${J}) * ${Q})`;break;default:throw console.error($),Error(`Unrecognized method ${$} for css variable ${J}`)}}else E[M]=`var(${J})`}return E[M]}});function FM(){let E=(M)=>typeof matchMedia<"u"&&matchMedia(M).matches;return{colorScheme:E("(prefers-color-scheme: dark)")?"dark":"light",contrast:E("(prefers-contrast: more)")?"more":E("(prefers-contrast: less)")?"less":E("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:E("(prefers-reduced-motion: reduce)"),reducedTransparency:E("(prefers-reduced-transparency: reduce)"),forcedColors:E("(forced-colors: active)")}}function Zf(E){if(typeof matchMedia>"u")return()=>{};let M=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],f=()=>E(FM()),L=M.map((H)=>matchMedia(H));for(let H of L)H.addEventListener("change",f);return()=>{for(let H of L)H.removeEventListener("change",f)}}var Qf="http://www.w3.org/1998/Math/MathML",Yf="http://www.w3.org/2000/svg";var xE={},Xf=(E,M,f)=>{let L=GM(S(M),f);if(L.prop.startsWith("--"))E.style.setProperty(L.prop,L.value);else E.style[M]=L.value},DL=(E)=>{return{toDOM(M,f){Xf(M,E,f)}}},zf=(E,M,f)=>{if(M==="style")if(typeof f==="object")for(let L of Object.keys(f))if(A(f[L]))P(E,f[L],DL(L));else Xf(E,L,f[L]);else E.setAttribute("style",f);else{let L=S(M),H=E.constructor.observedAttributes;if(H?.includes(M)||H?.includes(L))if(typeof f==="boolean")f?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,f);else if(E[M]!==void 0){let{MathMLElement:J}=globalThis;if(E instanceof SVGElement||J!==void 0&&E instanceof J)E.setAttribute(M,f);else E[M]=f}else if(L==="class")f.split(" ").forEach((J)=>{E.classList.add(J)});else if(E[L]!==void 0)E[L]=f;else if(typeof f==="boolean")f?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,f)}},XM={},Gf=(E)=>{if(!XM[E])XM[E]={toDOM(M,f){zf(M,E,f)}};return XM[E]},NE=(E,M,f)=>{if(M==="apply")f(E);else if(M.match(/^on[A-Z]/)!=null){let L=M.substring(2).toLowerCase();$E(E,L,f)}else if(M==="bind")if((typeof f.binding==="string"?DE[f.binding]:f.binding)!==void 0&&f.value!==void 0)P(E,f.value,f.binding instanceof Function?{toDOM:f.binding}:f.binding);else throw Error("bad binding");else if(M.match(/^bind[A-Z]/)!=null){let L=M.substring(4,5).toLowerCase()+M.substring(5);if(L!=="value"){let $=L==="text"?"textContent":L==="enabled"?"disabled (with .tosi.take(v => !v))":L==="disabled"?"disabled":L==="list"?".tosi.listBinding()":null;if($)j(`bind${L}`,`bind${M.substring(4)} is deprecated. Use { ${$}: ... } instead.`)}let H=DE[L];if(H!==void 0)P(E,f,H);else throw Error(`${M} is not allowed, bindings.${L} is not defined`)}else if(f!=null&&typeof f==="object"&&f[i])P(E,f,Gf(M));else if(A(f))P(E,f,Gf(M));else zf(E,M,f)},zM=(E,...M)=>{if(xE[E]===void 0){let[H,$]=E.split("|");if($===void 0)xE[E]=globalThis.document.createElement(H);else xE[E]=globalThis.document.createElementNS($,H)}let f=xE[E].cloneNode(),L={};for(let H of M)if(H instanceof Element||H instanceof DocumentFragment||typeof H==="string"||typeof H==="number")if(f instanceof HTMLTemplateElement)f.content.append(H);else f.append(H);else if(A(H))f.append(I.span({bindText:H}));else Object.assign(L,H);for(let H of Object.keys(L)){let $=L[H];NE(f,H,$)}return f},WM=(...E)=>{let M=globalThis.document.createDocumentFragment();for(let f of E)M.append(f);return M},I=new Proxy({fragment:WM},{get(E,M){if(M=M.replace(/[A-Z]/g,(f)=>`-${f.toLocaleLowerCase()}`),E[M]===void 0)E[M]=(...f)=>zM(M,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),yE=new Proxy({fragment:WM},{get(E,M){if(E[M]===void 0)E[M]=(...f)=>zM(`${M}|${Yf}`,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),PE=new Proxy({fragment:WM},{get(E,M){if(E[M]===void 0)E[M]=(...f)=>zM(`${M}|${Qf}`,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),Ff=new WeakSet;function Wf(E,M,f="part"){let L=`[data-${f}]`;for(let H of Array.from(E.querySelectorAll(L))){if(Ff.has(H))continue;let $=H.getAttribute(`data-${f}`);if($==null)continue;let J=M[$];if(J==null)continue;Ff.add(H);for(let Q of Object.keys(J))NE(H,Q,J[Q])}}var KL=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],qL=!0,OL=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,wL=(E)=>OL.test(E),a=(E="",M="")=>{if(E==="")return M;else if(M.match(/^\d+$/)!==null||M.includes("="))return`${E}[${M}]`;else return`${E}.${M}`},mE={};function UM(E,M){if(E!==null&&(typeof E==="object"||typeof E==="function"))return E;return new Proxy(mE,e(M,!0))}var Of=()=>new Proxy({},e("^",!0)),DM=(E)=>{let f=E(Of())?.path;if(!f?.startsWith("^."))throw Error("selector must return a property of the item");return f.substring(2)},KM=(E,M,f)=>{for(let L=0;L<E.length;L++)if(`${C(E[L],M)}`===`${f}`)return L;return-1},AL=(E,M)=>({listFind(f,L){if(f instanceof Element){let J=f;while(J&&!J[s]&&J.parentElement)J=J.parentElement;let Q=J?.[s];if(Q==null)return;let Z=M.indexOf(Q);return Z!==-1?B[E][Z]:void 0}let H=DM(f),$=KM(M,H,L);return $!==-1?B[E][$]:void 0},listUpdate(f,L){let H=DM(f),$=C(L,H),J=KM(M,H,$);if(J!==-1){let Q=B[E][J];for(let Z of Object.keys(L))Q[Z]=L[Z];return Q}return B[E].push(L),B[E][M.length-1]},listRemove(f,L){let H=DM(f),$=KM(M,H,L);if($===-1)return!1;return B[E].splice($,1),!0}}),Uf=!1;function CL(){if(!Uf)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use .tosi.value, .tosi.path, .tosi.observe(), etc. instead."),Uf=!0}var Df=(E)=>{return E===mE},jL=(E,M)=>({get(f,L){switch(L){case"value":return M===mE?C(V,E):M.valueOf?M.valueOf():M;case"path":return E;case"touch":return()=>k(E);case"observe":return(H)=>{let $=g(E,H);return()=>o($)};case"bind":return(H,$,J)=>{iM()(H,E,$,J)};case"on":{let H=M===mE?C(V,E):M.valueOf?M.valueOf():M;return($,J)=>sM()($,J,H)}case"binding":return(H)=>({bind:{value:E,binding:H}});case"listBinding":return(H=({span:J})=>J({bindText:"^"}),$={})=>[{bindList:{value:E,...$}},I.template(H(I,Of()))];case"listFind":case"listUpdate":case"listRemove":return AL(E,Array.isArray(M)?M:[])[L];case"take":return(...H)=>{let $=H[H.length-1],Q=H.slice(0,-1).map((Z)=>typeof Z==="string"?Z:Z[y]);return{[i]:!0,paths:[E,...Q],transform:$}}}return},set(f,L,H){if(L==="value"){if(H=q(H),q(R[E])!==H&&r(V,E,H))k(E);return!0}return!1}}),qE=(E,M)=>new Proxy(M,jL(E,M)),Kf=new Set(["path","value","touch","observe","bind","on","binding","listBinding","listFind","listUpdate","listRemove","take"]),qf=new Map([[y,"path"],["xinPath","path"],["tosiPath","path"],[h,"value"],["xinValue","value"],["tosiValue","value"],[kM,"observe"],["xinObserve","observe"],["tosiObserve","observe"],[_M,"on"],["xinOn","on"],["tosiOn","on"],[BM,"bind"],["xinBind","bind"],["tosiBind","bind"],["tosiBinding","binding"],["tosiListBinding","listBinding"]]),e=(E,M)=>({get(f,L){if((L==="tosi"||L===zE)&&M)return qE(E,f);if(Df(f)){let Z=()=>C(V,E);switch(L){case"valueOf":case"toJSON":return()=>Z();case Symbol.toPrimitive:return(F)=>{let z=Z();if(F==="number")return Number(z);if(F==="string")return String(z);return z};case"toString":return()=>String(Z())}if(Kf.has(L))return qE(E,f)[L];let Y=qf.get(L);if(Y!==void 0)return CL(),qE(E,f)[Y];let X=Z();if(X!=null){let F=Object(X);if(L in F){let z=F[L];return typeof z==="function"?z.bind(F):z}}return}if(M&&(L==="valueOf"||L==="toJSON"))return()=>f.valueOf?f.valueOf():f;if(M&&!(L in f)&&Kf.has(L))return qE(E,f)[L];let H=qf.get(L);if(H!==void 0)return qE(E,f)[H];if(typeof L==="symbol")return f[L];let $=Object.getOwnPropertyDescriptor(f,L);if($&&!$.configurable&&!$.writable&&"value"in $)return $.value;let J=L,Q=J.match(/^([^.[]+)\.(.+)$/)??J.match(/^([^\]]+)(\[.+)/)??J.match(/^(\[[^\]]+\])\.(.+)$/)??J.match(/^(\[[^\]]+\])\[(.+)$/);if(Q!==null){let[,Z,Y]=Q,X=a(E,Z),F=q(C(f,Z));return F!==null&&typeof F==="object"?new Proxy(F,e(X,M))[Y]:F}if(J.startsWith("[")&&J.endsWith("]"))J=J.substring(1,J.length-1);if(!Array.isArray(f)&&f[J]!==void 0||Array.isArray(f)&&J.includes("=")){let Z;if(J.includes("=")){let[Y,X]=J.split("=");Z=f.find((F)=>`${C(F,Y)}`===X)}else Z=f[J];if(Z instanceof Object){Z=q(Z);let Y=a(E,J);return new Proxy(Z instanceof Function?Z.bind(f):Z,e(Y,M))}else return M?UM(Z,a(E,J)):Z}else if(Array.isArray(f)){let Z=f[J];return typeof Z==="function"?(...Y)=>{let X=Y.map((z)=>q(z)),F=Z.apply(f,X);if(KL.includes(J))k(E);if(F!=null&&typeof F==="object"){if(J==="find"||J==="findLast"||J==="at"){let z=f.indexOf(F);if(z!==-1)return new Proxy(F,e(a(E,String(z)),M))}}return F}:typeof Z==="object"?new Proxy(q(Z),e(a(E,J),M)):M?UM(Z,a(E,J)):Z}else{let Z=f[J];if(Z!==null&&typeof Z==="object")Z=q(Z);return M?UM(Z,a(E,J)):Z}},set(f,L,H){if(H=q(H),H!==null&&typeof H==="object")if(Array.isArray(H))for(let Z=0;Z<H.length;Z++)H[Z]=q(H[Z]);else for(let Z of Object.keys(H))H[Z]=q(H[Z]);let J=L===h||L==="xinValue"||L==="tosiValue"||L==="value"&&(Df(f)||M)?E:a(E,L);if(qL&&!wL(J))throw Error(`setting invalid path ${J}`);if(q(R[J])!==H&&r(V,J,H))k(J);return!0}}),XE=(E,M)=>{let f=typeof M==="function"?M:R[M];if(typeof f!=="function")throw Error(`observe expects a function or path to a function, ${M} is neither`);return g(E,f)},R=new Proxy(V,e("",!1));nM(R);var B=new Proxy(V,e("",!0));var VL=16,RL=100;function wf(E,M){let f=Array.from(E.querySelectorAll(n));if(E.matches(n))f.unshift(E);for(let L of f){let H=b.get(L);for(let $ of H){if($.path.startsWith("^"))$.path=`${M}${$.path.substring(1)}`;if($.binding.toDOM!=null)$.binding.toDOM(L,R[$.path])}}}class Af{boundElement;listTop;listBottom;isNamespaced;template;options;itemToElement;idToElement=new Map;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(E,M,f={}){if(this.boundElement=E,this.itemToElement=new WeakMap,f.idPath!=null){let H=A(M);if(H!=null)SM(H,f.idPath)}if(E.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(E.children[0]instanceof HTMLTemplateElement){let H=E.children[0];if(H.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=fE(H.content.children[0])}else this.template=E.children[0],this.template.remove();this.options=f;let L=E.namespaceURI;if(this.isNamespaced=L==="http://www.w3.org/2000/svg"||L==="http://www.w3.org/1998/Math/MathML",this.isNamespaced)this.listTop=null,this.listBottom=null;else this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom);if(this.boundElement[QE]=this,this.isNamespaced&&f.virtual!=null)console.warn("ListBinding: virtual scrolling is not supported in SVG/MathML containers, ignoring virtual option");if(!this.isNamespaced&&f.virtual!=null)if(UE.observe(this.boundElement),this._update=HE(()=>{this.update(this.array,!0)},VL),this.boundElement.addEventListener("resize",this._update),f.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){if(this._filteredCache!=null)return this._filteredCache;let{hiddenProp:E,visibleProp:M}=this.options,f=this.array;if(E!==void 0)f=f.filter((L)=>L[E]!==!0);if(M!==void 0)f=f.filter((L)=>L[M]===!0);if(this.options.filter&&this.needle!==void 0)f=this.options.filter(f,this.needle);return this._filteredCache=f,f}visibleSlice(){let{virtual:E}=this.options,M=this.filteredArray(),f=0,L=M.length-1,H=0,$=0;if(E!=null&&this.boundElement instanceof HTMLElement){let J=this.boundElement.offsetWidth,Q=E.scrollContainer==="window",Z,Y;if(Q){Z=window.innerHeight;let z=this.boundElement.getBoundingClientRect();Y=Math.max(0,-z.top)}else Z=this.boundElement.offsetHeight,Y=this.boundElement.scrollTop;let X=E.width!=null?Math.max(1,Math.floor(J/E.width)):E.visibleColumns??1,F=Math.ceil(M.length/X);if(E.minHeight!=null){let z=E.minHeight,T=Math.ceil(Z/z)+(E.rowChunkSize||1),W=X*T,U=F*z,K=Math.max(0,U-Z),x=K>0?Math.min(1,Math.max(0,Y/K)):0,_=Math.max(0,F-T+1),D=x*_,O=Math.floor(D);if(E.rowChunkSize)O-=O%E.rowChunkSize;return f=O*X,L=f+W-1,H=Y,$=Math.max(0,U-Y-Z),{items:M,firstItem:f,lastItem:L,topBuffer:H,bottomBuffer:$,interpolation:{t:x,position:D,scrollTop:Y,viewportHeight:Z,totalScrollHeight:U,rowHeight:E.height}}}else{let z=Math.ceil(Z/E.height)+(E.rowChunkSize||1),T=X*z,W=Math.floor(Y/E.height);if(W>F-z+1)W=Math.max(0,F-z+1);if(E.rowChunkSize)W-=W%E.rowChunkSize;f=W*X,L=f+T-1,H=W*E.height,$=Math.max((F-z)*E.height-H,0)}}return{items:M,firstItem:f,lastItem:L,topBuffer:H,bottomBuffer:$}}needle;filter=HE((E)=>{if(this.needle!==E)this.needle=E,this.update(this.array)},RL);update(E,M){if(E==null)E=[];if(this.array=E,!M)this._filteredCache=void 0;let{hiddenProp:f,visibleProp:L}=this.options,H=A(E),$=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",$.items.length===0);let J=this._previousSlice,{firstItem:Q,lastItem:Z,topBuffer:Y,bottomBuffer:X}=$,F=f===void 0&&L===void 0&&M===!0&&J!=null&&Q===J.firstItem&&Z===J.lastItem;if(F&&$.interpolation==null&&Y===J.topBuffer&&X===J.bottomBuffer)return;if(F&&$.interpolation!=null){this._updateInterpolatedBuffers($);return}this._previousSlice=$;let z=0,T=0,W=0,{idPath:U}=this.options,K;if(U!=null){K=new Set;for(let D=Q;D<=Z;D++){let O=$.items[D];if(O!==void 0)K.add(String(O[U]))}}for(let D of Array.from(this.boundElement.children)){if(D===this.listTop||D===this.listBottom)continue;let O=D[s];if(O==null)D.remove();else{let w;if(U!=null)w=!K.has(String(O[U]));else{let N=$.items.indexOf(O);w=N<Q||N>Z}if(w){if(D.remove(),this.itemToElement.delete(O),U!=null)this.idToElement.delete(String(O[U]));z++}}}if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(Y)+"px",this.listBottom.style.height=String(X)+"px";let x=[];for(let D=Q;D<=Z;D++){let O=$.items[D];if(O===void 0)continue;let w=this.itemToElement.get(q(O));if(w==null&&U!=null){let N=String(O[U]);if(w=this.idToElement.get(N),w!=null){let EE=q(O);this.itemToElement.set(EE,w),w[s]=EE}}if(w==null){if(W++,w=fE(this.template),typeof O==="object")this.itemToElement.set(q(O),w),w[s]=q(O);if(this.listBottom!=null)this.boundElement.insertBefore(w,this.listBottom);else this.boundElement.append(w);if(U!=null){let N=O[U],EE=`${H}[${U}=${N}]`;wf(w,EE),this.idToElement.set(String(N),w)}else{let N=`${H}[${D}]`;wf(w,N)}}x.push(w)}let _=null;for(let D of x){if(D.previousElementSibling!==_)if(T++,_?.nextElementSibling!=null)this.boundElement.insertBefore(D,_.nextElementSibling);else if(this.listBottom!=null)this.boundElement.insertBefore(D,this.listBottom);else this.boundElement.append(D);_=D}if($.interpolation!=null)this._updateInterpolatedBuffers($);if(p.perf)console.log(H,"updated",{removed:z,created:W,moved:T})}_updateInterpolatedBuffers(E){let{t:M,position:f,scrollTop:L,viewportHeight:H,totalScrollHeight:$,rowHeight:J}=E.interpolation,Q=0;for(let F of Array.from(this.boundElement.children)){if(F===this.listTop||F===this.listBottom)continue;Q+=F.offsetHeight||J}let Z=L,Y=L+H-Q,X=Math.max(0,M*Y+(1-M)*Z-f%1*J);if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(X)+"px",this.listBottom.style.height=String(Math.max(0,$-X-Q))+"px"}}var FE=(E,M,f)=>{let L=E[QE];if(M&&L===void 0)L=new Af(E,M,f),E[QE]=L;return L},bE=(E)=>{let M;while(!(M=E[s])&&E&&E.parentElement)E=E.parentElement;return M?{element:E,item:M}:void 0},cE=(E)=>{let M=bE(E);return M?M.item:void 0},Cf=(E)=>{let M=bE(E);if(!M)return console.error("deleteListItem failed, element is not part of a list instance",E),!1;let f=FE(M.element.parentElement);if(!f.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",E.parentElement,f),!1;let L=f.array.indexOf(M.item);if(L>-1)return f.array.splice(L,1),!0;return!1},TL={start:"start",middle:"center",end:"end",nearest:"nearest"},jf=(E,M,f={})=>{let L=FE(E);if(L==null)return console.error("scrollListItemIntoView failed, element has no list binding",E),!1;let{position:H="middle"}=f,$=L.filteredArray(),J=q(M)??M,Q=$.indexOf(J);if(Q===-1)return console.error("scrollListItemIntoView failed, item not found in list",M),!1;let{virtual:Z}=L.options;if(Z!=null&&E instanceof HTMLElement){let Y=Z.width!=null?Math.max(1,Math.floor(E.offsetWidth/Z.width)):Z.visibleColumns??1,X=Math.floor(Q/Y),F=Z.minHeight??Z.height,z=Math.ceil($.length/Y),T=Z.scrollContainer==="window",W=T?window.innerHeight:E.offsetHeight,U;if(Z.minHeight!=null){let K=Math.ceil(W/F)+(Z.rowChunkSize||1),x=z*F,_=Math.max(0,x-W),D=Math.max(1,z-K+1),O=X/D;switch(H){case"start":U=O*_;break;case"end":U=Math.max(0,(X-K+1)/D*_);break;case"nearest":{let w=T?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop,N=_>0?w/_:0,EE=Math.floor(N*D);if(X<EE)U=O*_;else if(X>=EE+K)U=Math.max(0,(X-K+1)/D*_);else return!0;break}default:{let w=X-Math.floor(K/2);U=Math.max(0,w)/D*_}}}else{let K=X*Z.height;switch(H){case"start":U=K;break;case"end":U=K-W+Z.height;break;case"nearest":{let x=T?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop;if(K<x)U=K;else if(K+Z.height>x+W)U=K-W+Z.height;else return!0;break}default:U=K-(W-Z.height)/2}}if(U=Math.max(0,U),T){let K=E.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:K+U,behavior:"smooth"})}else E.scrollTo({top:U,behavior:"smooth"})}else{let Y=L.itemToElement.get(J);if(Y==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",M),!1;Y.scrollIntoView({block:TL[H]??"center",behavior:"smooth"})}return!0};var{document:OE,MutationObserver:Vf}=globalThis,vE=(E,M)=>{let f=b.get(E);if(f==null)return;for(let L of f){let{binding:H,options:$}=L,{path:J}=L,{toDOM:Q}=H;if(Q!=null){if(J.startsWith("^")){let Z=cE(E);if(Z!=null&&Z[y]!=null)J=L.path=`${Z[y]}${J.substring(1)}`;else{if(E instanceof HTMLElement)console.warn(`Unresolved relative binding "${J}" —`,E,"is not part of a list. If this is a list template, wrap it in a <template>.");continue}}if(M==null||J.startsWith(M))Q(E,WE()[J],$)}}};if(Vf!=null)new Vf((M)=>{M.forEach((f)=>{Array.from(f.addedNodes).forEach((L)=>{if(L instanceof Element)Array.from(L.querySelectorAll(n)).forEach((H)=>vE(H))})})}).observe(OE.body,{subtree:!0,childList:!0});g(()=>!0,(E)=>{let M=Array.from(OE.querySelectorAll(n));for(let f of M)vE(f,E)});var Rf=(E)=>{let M=E.target?.closest(n);while(M!=null){let f=b.get(M);for(let L of f){let{binding:H,path:$}=L,{fromDOM:J}=H;if(J!=null){let Q;try{Q=J(M,L.options)}catch(Z){throw console.error("Cannot get value from",M,"via",L),Error("Cannot obtain value fromDOM")}if(Q!=null){let Z=WE(),Y=Z[$];if(Y==null)Z[$]=Q;else{let X=Y[y]!=null?Y[h]:Y,F=Q[y]!=null?Q[h]:Q;if(X!==F)Z[$]=F}}}}M=M.parentElement.closest(n)}};if(globalThis.document!=null)OE.body.addEventListener("change",Rf,!0),OE.body.addEventListener("input",Rf,!0);function IL(E,M,f,L){let{paths:H,transform:$}=M,{toDOM:J}=f;if(J==null)return E;let Q=null,Z={toDOM(X,F,z){let T=WE(),W=H.map((K)=>T[K]);if(Q!==null&&W.every((K,x)=>K===Q[x]))return;Q=W;let U=$(...W);J(X,U,z)},fromDOM:f.fromDOM};E.classList?.add(TE);let Y=b.get(E);if(Y==null)Y=[],b.set(E,Y);for(let X of H)Y.push({path:X,binding:Z,options:L});if(!H[0].startsWith("^"))k(H[0]);return E}function P(E,M,f,L){if(E instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");if(M!=null&&typeof M==="object"&&M[i])return IL(E,M,f,L);let H;if(typeof M==="object"&&M[y]===void 0&&L===void 0){let{value:Q}=M;H=typeof Q==="string"?Q:Q[y],L=M,delete L.value}else H=typeof M==="string"?M:M[y];if(H==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:$}=f;E.classList?.add(TE);let J=b.get(E);if(J==null)J=[],b.set(E,J);if(J.push({path:H,binding:f,options:L}),$!=null&&!H.startsWith("^"))k(H);if(L?.filter&&L?.needle)P(E,L.needle,{toDOM(Q,Z){console.log({needle:Z}),Q[QE]?.filter(Z)}});return E}var Tf=new Set,kL=(E)=>{let M=E?.target?.closest(lE),f=!1,L=new Proxy(E,{get($,J){if(J==="stopPropagation")return()=>{E.stopPropagation(),f=!0};else{let Q=$[J];return typeof Q==="function"?Q.bind($):Q}}}),H=new Set;while(!f&&M!=null){let J=ME.get(M)[E.type]||H;for(let Q of J){if(typeof Q==="function")Q(L);else{let Z=WE()[Q];if(typeof Z==="function")Z(L);else throw Error(`no event handler found at path ${Q}`)}if(f)continue}M=M.parentElement!=null?M.parentElement.closest(lE):null}};function $E(E,M,f){let L=ME.get(E);if(E.classList.add(oE),L==null)L={},ME.set(E,L);if(!L[M])L[M]=new Set;if(L[M].add(f),!Tf.has(M))Tf.add(M),OE.body.addEventListener(M,kL,!0);return()=>{L[M].delete(f)}}hM(P,$E);function uE(E,M){if(!E.internals)return;let f={},L="";if(E.hasAttribute("required")&&M==="")f.valueMissing=!0,L="Please fill out this field.";let H=E.getAttribute("minlength");if(H&&M.length<parseInt(H,10))f.tooShort=!0,L=`Please use at least ${H} characters.`;let $=E.getAttribute("maxlength");if($&&M.length>parseInt($,10))f.tooLong=!0,L=`Please use no more than ${$} characters.`;let J=E.getAttribute("pattern");if(J&&M!=="")try{if(!new RegExp(`^(?:${J})$`).test(M))f.patternMismatch=!0,L="Please match the requested format."}catch{}if(Object.keys(f).length>0)E.internals.setValidity(f,L,E);else E.internals.setValidity({})}var BL=0;function qM(){return`custom-elt${(BL++).toString(36)}`}var If=0,OM=null;function _L(){if(OM===null)OM=new MutationObserver((E)=>{let M=new Set;for(let f of E)if(f.type==="attributes"&&f.target instanceof m){let L=f.target,H=YM(f.attributeName);if(L._legacyTrackedAttrs?.has(H))M.add(L)}for(let f of M)f.queueRender(!1)});return OM}var wE={};function SL(E,M){let f=wE[E],L=t(M).replace(/:host\(([^)]+)\)/g,`${E}$1`).replace(/:host\b/g,E);wE[E]=f?f+`
13
- `+L:L}function xL(E){if(wE[E])document.head.append(I.style({id:E+"-component"},wE[E]));delete wE[E]}class m extends HTMLElement{static elements=I;static _elementCreator;static initAttributes;static formAssociated;static preferredTagName;static shadowStyleSpec;static lightStyleSpec;static extends;internals;get validity(){return this.internals?.validity}get validationMessage(){return this.internals?.validationMessage??""}get willValidate(){return this.internals?.willValidate??!1}checkValidity(){return this.internals?.checkValidity()??!0}reportValidity(){return this.internals?.reportValidity()??!0}setCustomValidity(E){if(this.internals)if(E)this.internals.setValidity({customError:!0},E);else this.internals.setValidity({})}setValidity(E,M,f){this.internals?.setValidity(E,M,f)}setFormValue(E,M){this.internals?.setFormValue(E,M)}static get observedAttributes(){let E=this.initAttributes;if(E)return["hidden",...Object.keys(E).map(S)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=I.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(E){return console.warn("StyleNode is deprecated, use static shadowStyleSpec instead"),I.style(t(E))}static elementCreator(E={}){let M=this;if(!Object.prototype.hasOwnProperty.call(M,"_elementCreator")){if(E.tag!==void 0)j("elementCreator-tag","Passing tag to elementCreator() is deprecated. Use static preferredTagName instead.");if(E.styleSpec!==void 0)j("elementCreator-styleSpec","Passing styleSpec to elementCreator() is deprecated. Use static lightStyleSpec instead.");if(E.extends!==void 0)j("elementCreator-extends","Passing extends to elementCreator() is deprecated. Use static extends instead.");let f=E.tag??M.preferredTagName;if(f==null)if(typeof M.name==="string"&&M.name!==""){if(f=S(M.name),f.startsWith("-"))f=f.slice(1)}else f=qM();if(customElements.get(f)!=null)console.warn(`${f} is already defined`);if(f.match(/\w+(-\w+)+/)==null)console.warn(`${f} is not a legal tag for a custom-element`),f=qM();while(customElements.get(f)!==void 0)f=qM();M._tagName=f;let L=E.styleSpec??M.lightStyleSpec;if(L!==void 0)SL(f,L);let H=E.extends??M.extends,$=H?{extends:H}:void 0;window.customElements.define(f,this,$),M._elementCreator=I[f]}return M._elementCreator}initAttributes(...E){if(j("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let H of E)this._legacyTrackedAttrs.add(H);_L().observe(this,{attributes:!0});let f={},L={};E.forEach((H)=>{f[H]=v(this[H]);let $=S(H);Object.defineProperty(this,H,{enumerable:!1,get(){if(typeof f[H]==="boolean")return this.hasAttribute($);else if(this.hasAttribute($))return typeof f[H]==="number"?parseFloat(this.getAttribute($)):this.getAttribute($);else if(L[H]!==void 0)return L[H];else return f[H]},set(J){if(typeof f[H]==="boolean"){if(J!==this[H]){if(J)this.setAttribute($,"");else this.removeAttribute($);this.queueRender()}}else if(typeof f[H]==="number"){if(J!==parseFloat(this[H]))this.setAttribute($,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[H]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute($);else this.setAttribute($,J);this.queueRender(),L[H]=J}}})})}initValue(){let E=Object.getOwnPropertyDescriptor(this,"value");if(E===void 0||E.get!==void 0||E.set!==void 0)return;let M=this.hasAttribute("value")?this.getAttribute("value"):v(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return M},set(f){if(M!==f)M=f,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let E=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(M,f){if(M[f]===void 0){let L=E.querySelector(`[part="${f}"]`);if(L==null)L=E.querySelector(f);if(L==null)throw Error(`elementRef "${f}" does not exist!`);L.removeAttribute("data-ref"),M[f]=L}return M[f]}});return this._parts}attributeChangedCallback(E,M,f){let L=YM(E);if(!this._legacyTrackedAttrs?.has(L))this.queueRender(!1)}constructor(){super();if(If+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let E=this.constructor.initAttributes;if(E)this._setupAttributeAccessors(E);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${If}`,this._value=v(this.defaultValue)}_setupAttributeAccessors(E){if(!this._attrValues)this._attrValues=new Map;for(let M of Object.keys(E)){let f=S(M),L=E[M];if(M==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof L==="object"&&L!==null){console.warn(`${this.tagName}: initAttributes.${M} is an object. Use a regular property instead.`);continue}let H=this,$=!1;while(H){let J=Object.getOwnPropertyDescriptor(H,M);if(J){if(!J.configurable||J.get||J.set){$=!0;break}break}H=Object.getPrototypeOf(H)}if($)continue;Object.defineProperty(this,M,{enumerable:!1,get:()=>{if(typeof L==="boolean")return this.hasAttribute(f);else if(this.hasAttribute(f))return typeof L==="number"?parseFloat(this.getAttribute(f)):this.getAttribute(f);else if(this._attrValues.has(M))return this._attrValues.get(M);else return L},set:(J)=>{if(typeof L==="boolean"){if(J!==this[M]){if(J)this.setAttribute(f,"");else this.removeAttribute(f);this.queueRender()}}else if(typeof L==="number"){if(J!==parseFloat(this[M]))this.setAttribute(f,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[M]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute(f);else this.setAttribute(f,J);this.queueRender(),this._attrValues.set(M,J)}}})}}connectedCallback(){if(xL(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.constructor.formAssociated&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.onResize!==void 0){if(UE.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");if(this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this.queueRender()}disconnectedCallback(){UE.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(E){if(E)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(E){if(this.value!==void 0&&typeof E==="string")this.value=E}_changeQueued=!1;_renderQueued=!1;queueRender(E=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=E;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued){if(ZM(this,"change"),this.internals&&this.value!==void 0)this.internals.setFormValue(this.value)}this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let E=typeof this.content!=="function",M=typeof this.content==="function"?this.content(I):this.content;if(Array.isArray(M)){let $={};M=M.filter((J)=>{if(J instanceof Node||typeof J==="string"||typeof J==="number"||A(J))return!0;return Object.assign($,J),!1});for(let J of Object.keys($))NE(this,J,$[J])}let f=this.constructor,L=f.shadowStyleSpec??f.styleSpec;if(f.styleSpec&&!f.shadowStyleSpec)j("static-styleSpec","static styleSpec is deprecated. Use static shadowStyleSpec instead.");let{styleNode:H}=f;if(L)H=f.styleNode=I.style(t(L)),delete f.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecated, use static shadowStyleSpec instead"),H=this.styleNode;if(H){let $=this.attachShadow({mode:"open"});$.appendChild(H.cloneNode(!0)),QM($,M,E)}else if(M!==null){let $=Array.from(this.childNodes);QM(this,M,E),this.isSlotted=this.querySelector("slot,tosi-slot,xin-slot")!==void 0;let J=Array.from(this.querySelectorAll("slot"));if(J.length>0)J.forEach(gE.replaceSlot);if($.length>0){let Q={"":this};Array.from(this.querySelectorAll("tosi-slot,xin-slot")).forEach((Z)=>{Q[Z.name]=Z}),$.forEach((Z)=>{let Y=Q[""],X=Z instanceof Element?Q[Z.slot]:Y;(X!==void 0?X:Y).append(Z)})}}this._hydrated=!0}}render(){if(this._valueChanged&&this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this._valueChanged=!1}validateValue(){if(!this.internals||this.value===void 0)return;let E=typeof this.value==="string"?this.value:String(this.value);uE(this,E)}}class gE extends m{static preferredTagName="tosi-slot";static initAttributes={name:""};content=null;static replaceSlot(E){let M=document.createElement("tosi-slot");if(E.name!=="")M.setAttribute("name",E.name);E.replaceWith(M)}}var kf=gE.elementCreator();class Bf extends m{static preferredTagName="xin-slot";static initAttributes={name:""};content=null;constructor(){super();j("xin-slot","<xin-slot> is deprecated. Use <tosi-slot> instead.")}static replaceSlot=gE.replaceSlot}var _f=Bf.elementCreator();var Sf=(E=()=>!0)=>{let M=localStorage.getItem("xin-state");if(M!=null){let L=JSON.parse(M);for(let H of Object.keys(L).filter(E))if(R[H]!==void 0)Object.assign(R[H],L[H]);else R[H]=L[H]}let f=GE(()=>{let L={},H=q(R);for(let $ of Object.keys(H).filter(E))L[$]=H[$];localStorage.setItem("xin-state",JSON.stringify(L)),console.log("xin state saved to localStorage")},500);XE(E,f)};var NL="tosijs-share",yL="tosijs-share",AE="shared",PL=1,AM=new Set,CM=new Set,wM=new Map,ZE=null,jM="",dE=null,mL=null;function xf(){if(dE!=null)return Promise.resolve(dE);return new Promise((E,M)=>{let f=indexedDB.open(yL,PL);f.onupgradeneeded=()=>{f.result.createObjectStore(AE)},f.onsuccess=()=>{dE=f.result,E(dE)},f.onerror=()=>M(f.error)})}var bL={async get(E){let M=await xf();return new Promise((f,L)=>{let $=M.transaction(AE,"readonly").objectStore(AE).get(E);$.onsuccess=()=>f($.result),$.onerror=()=>L($.error)})},async set(E,M){let f=await xf();return new Promise((L,H)=>{let $=f.transaction(AE,"readwrite");$.objectStore(AE).put(M,E),$.oncomplete=()=>L(),$.onerror=()=>H($.error)})}};function Nf(){return mL??bL}function cL(E){return E!=null&&E.type==="tosijs-share"&&typeof E.path==="string"}function yf(E){for(let M of AM)if(E===M||E.startsWith(M+"."))return M;return}function vL(E){for(let M of CM)if(E===M||E.startsWith(M+"."))return!0;return!1}function uL(E,M){CM.add(E),r(V,E,M),k(E),LE().then(()=>{CM.delete(E)})}function gL(){if(ZE!=null)return ZE;return jM=crypto.randomUUID(),ZE=new BroadcastChannel(NL),ZE.onmessage=(E)=>{let M=E.data;if(!cL(M))return;if(M.origin===jM)return;if(yf(M.path)===void 0)return;uL(M.path,M.value)},ZE}function dL(E,M){if(ZE==null)return;let f={type:"tosijs-share",path:E,value:M,origin:jM};ZE.postMessage(f)}function nL(E){if(!wM.has(E))wM.set(E,GE(()=>{let M=C(V,E);Nf().set(E,M)},500));wM.get(E)()}async function Pf(...E){if(typeof BroadcastChannel>"u")return{restored:[]};gL();let M=[],f=Nf();for(let L of E){let H=typeof L==="string"?L:A(L);if(H===void 0)throw Error("share() requires boxed proxies or string paths. Got a non-proxy value.");if(AM.has(H))continue;AM.add(H);let $=await f.get(H);if($!==void 0)r(V,H,$),k(H),M.push(L);else{let J=C(V,H);await f.set(H,J)}g((J)=>J===H||J.startsWith(H+"."),(J)=>{if(vL(J))return;let Q=yf(J);if(Q===void 0)return;let Z=C(V,J);dL(J,Z),nL(Q)})}return{restored:M}}var VM=new Set;function mf(E,M){for(let f of E)if(M===f||M.startsWith(f+"."))return f;return}function hL(E){for(let M of VM)if(E===M||E.startsWith(M+"."))return!0;return!1}function iL(E,M){VM.add(E),r(V,E,M),k(E),LE().then(()=>{VM.delete(E)})}async function bf(E,M,...f){let L=new Set,H=[],$=[],J=M.throttleInterval??100;await E.connect();let Q=HE(()=>{if(H.length===0)return;let Z=H.splice(0);E.send(Z)},J);E.onReceive((Z)=>{for(let Y of Z){if(mf(L,Y.path)===void 0)continue;iL(Y.path,Y.value)}});for(let Z of f){let Y=typeof Z==="string"?Z:A(Z);if(Y===void 0)throw Error("sync() requires boxed proxies or string paths. Got a non-proxy value.");L.add(Y);let X=g((F)=>F===Y||F.startsWith(Y+"."),(F)=>{if(hL(F))return;if(mf(L,F)===void 0)return;let z=C(V,F);H.push({path:F,value:z}),Q()});$.push(X)}return{disconnect(){for(let Z of $)o(Z);$.length=0,L.clear(),H.length=0,E.disconnect()}}}var nE="1.5.8";function CE(E){return Object.assign(B,E),B}function jE(E){return j("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),CE(E)}var sL=new FinalizationRegistry((E)=>{E()});function cf(E,M){let f=EM();B[f]=E;let L=B[f],H=()=>{delete R[f]};if(M)sL.register(M,H);return[L,H]}function hE(E,M=!1){if(M)return j("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),jE(E);return Object.keys(E).forEach((f)=>{R[f]=E[f]}),R}var pL={};async function VE(E,M){let f=await M(E,{Color:G,Component:m,elements:I,svgElements:yE,mathML:PE,varDefault:KE,vars:SE,xin:R,boxed:B,xinProxy:hE,boxedProxy:jE,tosi:CE,makeComponent:VE,bind:P,on:$E,version:nE}),{type:L}=f;L.preferredTagName=E;let H=f.lightStyleSpec??f.styleSpec;if(H)L.lightStyleSpec=H;let $={type:L,creator:L.elementCreator()};return pL[E]=$,$}var iE={":host":{display:"none"}},RM={},rL=(E)=>import(E);class RE extends m{static preferredTagName="tosi-blueprint";static lightStyleSpec=iE;static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(E)=>{};async packaged(){let{tag:E,src:M,property:f}=this,L=`${E}.${f}:${M}`;if(!this.loaded){if(RM[L]===void 0)RM[L]=rL(M).then((H)=>{let $=H[f];return VE(E,$)});else console.log(`using cached ${E} with signature ${L}`);this.loaded=await RM[L],this.blueprintLoaded(this.loaded)}return this.loaded}}var vf=RE.elementCreator();class sE extends m{static preferredTagName="tosi-loader";static lightStyleSpec=iE;allLoaded=()=>{};async load(){let M=Array.from(this.querySelectorAll("tosi-blueprint, xin-blueprint")).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(M),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var uf=sE.elementCreator();class gf extends RE{static preferredTagName="xin-blueprint";static lightStyleSpec=iE;constructor(){super();j("xin-blueprint","<xin-blueprint> is deprecated. Use <tosi-blueprint> instead.")}}var df=gf.elementCreator();class nf extends m{static preferredTagName="xin-loader";static lightStyleSpec=iE;allLoaded=()=>{};constructor(){super();j("xin-loader","<xin-loader> is deprecated. Use <tosi-loader> instead.")}async load(){let M=Array.from(this.querySelectorAll("xin-blueprint")).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(M),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var hf=nf.elementCreator();})();
12
+ `)},Jf=(E)=>{j("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let M={};for(let f of Object.keys(E)){let L=E[f],H=S(f);M[`--${H}`]=typeof L==="number"&&L!==0?String(L)+"px":L}return M},$f=(E)=>{let M={};for(let f of Object.keys(E)){let L=E[f];if(L instanceof G)M[f]=L.inverseLuminance;else if(typeof L==="string"&&L.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))M[f]=G.fromCss(L).inverseLuminance}return M},KE=new Proxy({},{get(E,M){if(E[M]===void 0){let f="--"+S(M);E[M]=(L)=>`var(${f}, ${L})`}return E[M]}}),SE=new Proxy({},{get(E,M){if(M==="default")return KE;if(E[M]==null){M=S(M);let[,f,,L,H,$]=M.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",M],J=`--${f}`;if(H!=null){let Q=L==null?Number(H)/100:-Number(H)/100;switch($){case"b":case"s":case"h":case"o":{let Z=`--${M}`;G.registerComputedColor(Z,J,Q,$),E[M]=`var(${Z})`}break;case"":E[M]=`calc(var(${J}) * ${Q})`;break;default:throw console.error($),Error(`Unrecognized method ${$} for css variable ${J}`)}}else E[M]=`var(${J})`}return E[M]}});function FM(){let E=(M)=>typeof matchMedia<"u"&&matchMedia(M).matches;return{colorScheme:E("(prefers-color-scheme: dark)")?"dark":"light",contrast:E("(prefers-contrast: more)")?"more":E("(prefers-contrast: less)")?"less":E("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:E("(prefers-reduced-motion: reduce)"),reducedTransparency:E("(prefers-reduced-transparency: reduce)"),forcedColors:E("(forced-colors: active)")}}function Zf(E){if(typeof matchMedia>"u")return()=>{};let M=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],f=()=>E(FM()),L=M.map((H)=>matchMedia(H));for(let H of L)H.addEventListener("change",f);return()=>{for(let H of L)H.removeEventListener("change",f)}}var Qf="http://www.w3.org/1998/Math/MathML",Yf="http://www.w3.org/2000/svg";var xE={},Xf=(E,M,f)=>{let L=GM(S(M),f);if(L.prop.startsWith("--"))E.style.setProperty(L.prop,L.value);else E.style[M]=L.value},DL=(E)=>{return{toDOM(M,f){Xf(M,E,f)}}},zf=(E,M,f)=>{if(M==="style")if(typeof f==="object")for(let L of Object.keys(f))if(A(f[L]))P(E,f[L],DL(L));else Xf(E,L,f[L]);else E.setAttribute("style",f);else{let L=S(M),H=E.constructor.observedAttributes;if(H?.includes(M)||H?.includes(L))if(typeof f==="boolean")f?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,f);else if(E[M]!==void 0){let{MathMLElement:J}=globalThis;if(E instanceof SVGElement||J!==void 0&&E instanceof J)E.setAttribute(M,f);else E[M]=f}else if(L==="class")f.split(" ").forEach((J)=>{E.classList.add(J)});else if(E[L]!==void 0)E[L]=f;else if(typeof f==="boolean")f?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,f)}},XM={},Gf=(E)=>{if(!XM[E])XM[E]={toDOM(M,f){zf(M,E,f)}};return XM[E]},NE=(E,M,f)=>{if(M==="apply")f(E);else if(M.match(/^on[A-Z]/)!=null){let L=M.substring(2).toLowerCase();$E(E,L,f)}else if(M==="bind")if((typeof f.binding==="string"?DE[f.binding]:f.binding)!==void 0&&f.value!==void 0)P(E,f.value,f.binding instanceof Function?{toDOM:f.binding}:f.binding);else throw Error("bad binding");else if(M.match(/^bind[A-Z]/)!=null){let L=M.substring(4,5).toLowerCase()+M.substring(5);if(L!=="value"){let $=L==="text"?"textContent":L==="enabled"?"disabled (with .tosi.take(v => !v))":L==="disabled"?"disabled":L==="list"?".tosi.listBinding()":null;if($)j(`bind${L}`,`bind${M.substring(4)} is deprecated. Use { ${$}: ... } instead.`)}let H=DE[L];if(H!==void 0)P(E,f,H);else throw Error(`${M} is not allowed, bindings.${L} is not defined`)}else if(f!=null&&typeof f==="object"&&f[i])P(E,f,Gf(M));else if(A(f))P(E,f,Gf(M));else zf(E,M,f)},zM=(E,...M)=>{if(xE[E]===void 0){let[H,$]=E.split("|");if($===void 0)xE[E]=globalThis.document.createElement(H);else xE[E]=globalThis.document.createElementNS($,H)}let f=xE[E].cloneNode(),L={};for(let H of M)if(H instanceof Element||H instanceof DocumentFragment||typeof H==="string"||typeof H==="number")if(f instanceof HTMLTemplateElement)f.content.append(H);else f.append(H);else if(A(H))f.append(I.span({bindText:H}));else Object.assign(L,H);for(let H of Object.keys(L)){let $=L[H];NE(f,H,$)}return f},WM=(...E)=>{let M=globalThis.document.createDocumentFragment();for(let f of E)M.append(f);return M},I=new Proxy({fragment:WM},{get(E,M){if(M=M.replace(/[A-Z]/g,(f)=>`-${f.toLocaleLowerCase()}`),E[M]===void 0)E[M]=(...f)=>zM(M,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),yE=new Proxy({fragment:WM},{get(E,M){if(E[M]===void 0)E[M]=(...f)=>zM(`${M}|${Yf}`,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),PE=new Proxy({fragment:WM},{get(E,M){if(E[M]===void 0)E[M]=(...f)=>zM(`${M}|${Qf}`,...f);return E[M]},set(){throw Error("You may not add new properties to elements")}}),Ff=new WeakSet;function Wf(E,M,f="part"){let L=`[data-${f}]`;for(let H of Array.from(E.querySelectorAll(L))){if(Ff.has(H))continue;let $=H.getAttribute(`data-${f}`);if($==null)continue;let J=M[$];if(J==null)continue;Ff.add(H);for(let Q of Object.keys(J))NE(H,Q,J[Q])}}var KL=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],qL=!0,OL=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,wL=(E)=>OL.test(E),a=(E="",M="")=>{if(E==="")return M;else if(M.match(/^\d+$/)!==null||M.includes("="))return`${E}[${M}]`;else return`${E}.${M}`},mE={};function UM(E,M){if(E!==null&&(typeof E==="object"||typeof E==="function"))return E;return new Proxy(mE,e(M,!0))}var Of=()=>new Proxy({},e("^",!0)),DM=(E)=>{let f=E(Of())?.path;if(!f?.startsWith("^."))throw Error("selector must return a property of the item");return f.substring(2)},KM=(E,M,f)=>{for(let L=0;L<E.length;L++)if(`${C(E[L],M)}`===`${f}`)return L;return-1},AL=(E,M)=>({listFind(f,L){if(f instanceof Element){let J=f;while(J&&!J[s]&&J.parentElement)J=J.parentElement;let Q=J?.[s];if(Q==null)return;let Z=M.indexOf(Q);return Z!==-1?B[E][Z]:void 0}let H=DM(f),$=KM(M,H,L);return $!==-1?B[E][$]:void 0},listUpdate(f,L){let H=DM(f),$=C(L,H),J=KM(M,H,$);if(J!==-1){let Q=B[E][J];for(let Z of Object.keys(L))Q[Z]=L[Z];return Q}return B[E].push(L),B[E][M.length-1]},listRemove(f,L){let H=DM(f),$=KM(M,H,L);if($===-1)return!1;return B[E].splice($,1),!0}}),Uf=!1;function CL(){if(!Uf)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use .tosi.value, .tosi.path, .tosi.observe(), etc. instead."),Uf=!0}var Df=(E)=>{return E===mE},jL=(E,M)=>({get(f,L){switch(L){case"value":return M===mE?C(V,E):M.valueOf?M.valueOf():M;case"path":return E;case"touch":return()=>k(E);case"observe":return(H)=>{let $=g(E,H);return()=>o($)};case"bind":return(H,$,J)=>{iM()(H,E,$,J)};case"on":{let H=M===mE?C(V,E):M.valueOf?M.valueOf():M;return($,J)=>sM()($,J,H)}case"binding":return(H)=>({bind:{value:E,binding:H}});case"listBinding":return(H=({span:J})=>J({bindText:"^"}),$={})=>[{bindList:{value:E,...$}},I.template(H(I,Of()))];case"listFind":case"listUpdate":case"listRemove":return AL(E,Array.isArray(M)?M:[])[L];case"take":return(...H)=>{let $=H[H.length-1],Q=H.slice(0,-1).map((Z)=>typeof Z==="string"?Z:Z[y]);return{[i]:!0,paths:[E,...Q],transform:$}}}return},set(f,L,H){if(L==="value"){if(H=q(H),q(R[E])!==H&&r(V,E,H))k(E);return!0}return!1}}),qE=(E,M)=>new Proxy(M,jL(E,M)),Kf=new Set(["path","value","touch","observe","bind","on","binding","listBinding","listFind","listUpdate","listRemove","take"]),qf=new Map([[y,"path"],["xinPath","path"],["tosiPath","path"],[h,"value"],["xinValue","value"],["tosiValue","value"],[kM,"observe"],["xinObserve","observe"],["tosiObserve","observe"],[_M,"on"],["xinOn","on"],["tosiOn","on"],[BM,"bind"],["xinBind","bind"],["tosiBind","bind"],["tosiBinding","binding"],["tosiListBinding","listBinding"]]),e=(E,M)=>({get(f,L){if((L==="tosi"||L===zE)&&M)return qE(E,f);if(Df(f)){let Z=()=>C(V,E);switch(L){case"valueOf":case"toJSON":return()=>Z();case Symbol.toPrimitive:return(F)=>{let z=Z();if(F==="number")return Number(z);if(F==="string")return String(z);return z};case"toString":return()=>String(Z())}if(Kf.has(L))return qE(E,f)[L];let Y=qf.get(L);if(Y!==void 0)return CL(),qE(E,f)[Y];let X=Z();if(X!=null){let F=Object(X);if(L in F){let z=F[L];return typeof z==="function"?z.bind(F):z}}return}if(M&&(L==="valueOf"||L==="toJSON"))return()=>f.valueOf?f.valueOf():f;if(M&&!(L in f)&&Kf.has(L))return qE(E,f)[L];let H=qf.get(L);if(H!==void 0)return qE(E,f)[H];if(typeof L==="symbol")return f[L];let $=Object.getOwnPropertyDescriptor(f,L);if($&&!$.configurable&&!$.writable&&"value"in $)return $.value;let J=L,Q=J.match(/^([^.[]+)\.(.+)$/)??J.match(/^([^\]]+)(\[.+)/)??J.match(/^(\[[^\]]+\])\.(.+)$/)??J.match(/^(\[[^\]]+\])\[(.+)$/);if(Q!==null){let[,Z,Y]=Q,X=a(E,Z),F=q(C(f,Z));return F!==null&&typeof F==="object"?new Proxy(F,e(X,M))[Y]:F}if(J.startsWith("[")&&J.endsWith("]"))J=J.substring(1,J.length-1);if(!Array.isArray(f)&&f[J]!==void 0||Array.isArray(f)&&J.includes("=")){let Z;if(J.includes("=")){let[Y,X]=J.split("=");Z=f.find((F)=>`${C(F,Y)}`===X)}else Z=f[J];if(Z instanceof Object){Z=q(Z);let Y=a(E,J);return new Proxy(Z instanceof Function?Z.bind(f):Z,e(Y,M))}else return M?UM(Z,a(E,J)):Z}else if(Array.isArray(f)){let Z=f[J];return typeof Z==="function"?(...Y)=>{let X=Y.map((z)=>q(z)),F=Z.apply(f,X);if(KL.includes(J))k(E);if(F!=null&&typeof F==="object"){if(J==="find"||J==="findLast"||J==="at"){let z=f.indexOf(F);if(z!==-1)return new Proxy(F,e(a(E,String(z)),M))}}return F}:typeof Z==="object"?new Proxy(q(Z),e(a(E,J),M)):M?UM(Z,a(E,J)):Z}else{let Z=f[J];if(Z!==null&&typeof Z==="object")Z=q(Z);return M?UM(Z,a(E,J)):Z}},set(f,L,H){if(H=q(H),H!==null&&typeof H==="object")if(Array.isArray(H))for(let Z=0;Z<H.length;Z++)H[Z]=q(H[Z]);else for(let Z of Object.keys(H))H[Z]=q(H[Z]);let J=L===h||L==="xinValue"||L==="tosiValue"||L==="value"&&(Df(f)||M)?E:a(E,L);if(qL&&!wL(J))throw Error(`setting invalid path ${J}`);if(q(R[J])!==H&&r(V,J,H))k(J);return!0}}),XE=(E,M)=>{let f=typeof M==="function"?M:R[M];if(typeof f!=="function")throw Error(`observe expects a function or path to a function, ${M} is neither`);return g(E,f)},R=new Proxy(V,e("",!1));nM(R);var B=new Proxy(V,e("",!0));var VL=16,RL=100;function wf(E,M){let f=Array.from(E.querySelectorAll(n));if(E.matches(n))f.unshift(E);for(let L of f){let H=b.get(L);for(let $ of H){if($.path.startsWith("^"))$.path=`${M}${$.path.substring(1)}`;if($.binding.toDOM!=null)$.binding.toDOM(L,R[$.path])}}}class Af{boundElement;listTop;listBottom;isNamespaced;template;options;itemToElement;idToElement=new Map;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(E,M,f={}){if(this.boundElement=E,this.itemToElement=new WeakMap,f.idPath!=null){let H=A(M);if(H!=null)SM(H,f.idPath)}if(E.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(E.children[0]instanceof HTMLTemplateElement){let H=E.children[0];if(H.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=fE(H.content.children[0])}else this.template=E.children[0],this.template.remove();this.options=f;let L=E.namespaceURI;if(this.isNamespaced=L==="http://www.w3.org/2000/svg"||L==="http://www.w3.org/1998/Math/MathML",this.isNamespaced)this.listTop=null,this.listBottom=null;else this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.listTop.setAttribute("role","presentation"),this.listBottom.setAttribute("role","presentation"),this.listTop.setAttribute("aria-hidden","true"),this.listBottom.setAttribute("aria-hidden","true"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom);if(this.boundElement[QE]=this,this.isNamespaced&&f.virtual!=null)console.warn("ListBinding: virtual scrolling is not supported in SVG/MathML containers, ignoring virtual option");if(!this.isNamespaced&&f.virtual!=null)if(UE.observe(this.boundElement),this._update=HE(()=>{this.update(this.array,!0)},VL),this.boundElement.addEventListener("resize",this._update),f.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){if(this._filteredCache!=null)return this._filteredCache;let{hiddenProp:E,visibleProp:M}=this.options,f=this.array;if(E!==void 0)f=f.filter((L)=>L[E]!==!0);if(M!==void 0)f=f.filter((L)=>L[M]===!0);if(this.options.filter&&this.needle!==void 0)f=this.options.filter(f,this.needle);return this._filteredCache=f,f}visibleSlice(){let{virtual:E}=this.options,M=this.filteredArray(),f=0,L=M.length-1,H=0,$=0;if(E!=null&&this.boundElement instanceof HTMLElement){let J=this.boundElement.offsetWidth,Q=E.scrollContainer==="window",Z,Y;if(Q){Z=window.innerHeight;let z=this.boundElement.getBoundingClientRect();Y=Math.max(0,-z.top)}else Z=this.boundElement.offsetHeight,Y=this.boundElement.scrollTop;let X=E.width!=null?Math.max(1,Math.floor(J/E.width)):E.visibleColumns??1,F=Math.ceil(M.length/X);if(E.minHeight!=null){let z=E.minHeight,T=Math.ceil(Z/z)+(E.rowChunkSize||1),W=X*T,U=F*z,K=Math.max(0,U-Z),x=K>0?Math.min(1,Math.max(0,Y/K)):0,_=Math.max(0,F-T+1),D=x*_,O=Math.floor(D);if(E.rowChunkSize)O-=O%E.rowChunkSize;return f=O*X,L=f+W-1,H=Y,$=Math.max(0,U-Y-Z),{items:M,firstItem:f,lastItem:L,topBuffer:H,bottomBuffer:$,interpolation:{t:x,position:D,scrollTop:Y,viewportHeight:Z,totalScrollHeight:U,rowHeight:E.height}}}else{let z=Math.ceil(Z/E.height)+(E.rowChunkSize||1),T=X*z,W=Math.floor(Y/E.height);if(W>F-z+1)W=Math.max(0,F-z+1);if(E.rowChunkSize)W-=W%E.rowChunkSize;f=W*X,L=f+T-1,H=W*E.height,$=Math.max((F-z)*E.height-H,0)}}return{items:M,firstItem:f,lastItem:L,topBuffer:H,bottomBuffer:$}}needle;filter=HE((E)=>{if(this.needle!==E)this.needle=E,this.update(this.array)},RL);update(E,M){if(E==null)E=[];if(this.array=E,!M)this._filteredCache=void 0;let{hiddenProp:f,visibleProp:L}=this.options,H=A(E),$=this.visibleSlice();if(this.boundElement.classList.toggle("-xin-empty-list",$.items.length===0),this.options.virtual!=null)this.boundElement.setAttribute("aria-rowcount",String($.items.length));let J=this._previousSlice,{firstItem:Q,lastItem:Z,topBuffer:Y,bottomBuffer:X}=$,F=f===void 0&&L===void 0&&M===!0&&J!=null&&Q===J.firstItem&&Z===J.lastItem;if(F&&$.interpolation==null&&Y===J.topBuffer&&X===J.bottomBuffer)return;if(F&&$.interpolation!=null){this._updateInterpolatedBuffers($);return}this._previousSlice=$;let z=0,T=0,W=0,{idPath:U}=this.options,K;if(U!=null){K=new Set;for(let D=Q;D<=Z;D++){let O=$.items[D];if(O!==void 0)K.add(String(O[U]))}}for(let D of Array.from(this.boundElement.children)){if(D===this.listTop||D===this.listBottom)continue;let O=D[s];if(O==null)D.remove();else{let w;if(U!=null)w=!K.has(String(O[U]));else{let N=$.items.indexOf(O);w=N<Q||N>Z}if(w){if(D.remove(),this.itemToElement.delete(O),U!=null)this.idToElement.delete(String(O[U]));z++}}}if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(Y)+"px",this.listBottom.style.height=String(X)+"px";let x=[];for(let D=Q;D<=Z;D++){let O=$.items[D];if(O===void 0)continue;let w=this.itemToElement.get(q(O));if(w==null&&U!=null){let N=String(O[U]);if(w=this.idToElement.get(N),w!=null){let EE=q(O);this.itemToElement.set(EE,w),w[s]=EE}}if(w==null){if(W++,w=fE(this.template),typeof O==="object")this.itemToElement.set(q(O),w),w[s]=q(O);if(this.listBottom!=null)this.boundElement.insertBefore(w,this.listBottom);else this.boundElement.append(w);if(U!=null){let N=O[U],EE=`${H}[${U}=${N}]`;wf(w,EE),this.idToElement.set(String(N),w)}else{let N=`${H}[${D}]`;wf(w,N)}}if(this.options.virtual!=null)w.setAttribute("aria-rowindex",String(D+1));x.push(w)}let _=null;for(let D of x){if(D.previousElementSibling!==_)if(T++,_?.nextElementSibling!=null)this.boundElement.insertBefore(D,_.nextElementSibling);else if(this.listBottom!=null)this.boundElement.insertBefore(D,this.listBottom);else this.boundElement.append(D);_=D}if($.interpolation!=null)this._updateInterpolatedBuffers($);if(p.perf)console.log(H,"updated",{removed:z,created:W,moved:T})}_updateInterpolatedBuffers(E){let{t:M,position:f,scrollTop:L,viewportHeight:H,totalScrollHeight:$,rowHeight:J}=E.interpolation,Q=0;for(let F of Array.from(this.boundElement.children)){if(F===this.listTop||F===this.listBottom)continue;Q+=F.offsetHeight||J}let Z=L,Y=L+H-Q,X=Math.max(0,M*Y+(1-M)*Z-f%1*J);if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(X)+"px",this.listBottom.style.height=String(Math.max(0,$-X-Q))+"px"}}var FE=(E,M,f)=>{let L=E[QE];if(M&&L===void 0)L=new Af(E,M,f),E[QE]=L;return L},bE=(E)=>{let M;while(!(M=E[s])&&E&&E.parentElement)E=E.parentElement;return M?{element:E,item:M}:void 0},cE=(E)=>{let M=bE(E);return M?M.item:void 0},Cf=(E)=>{let M=bE(E);if(!M)return console.error("deleteListItem failed, element is not part of a list instance",E),!1;let f=FE(M.element.parentElement);if(!f.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",E.parentElement,f),!1;let L=f.array.indexOf(M.item);if(L>-1)return f.array.splice(L,1),!0;return!1},TL={start:"start",middle:"center",end:"end",nearest:"nearest"},jf=(E,M,f={})=>{let L=FE(E);if(L==null)return console.error("scrollListItemIntoView failed, element has no list binding",E),!1;let{position:H="middle"}=f,$=L.filteredArray(),J=q(M)??M,Q=$.indexOf(J);if(Q===-1)return console.error("scrollListItemIntoView failed, item not found in list",M),!1;let{virtual:Z}=L.options;if(Z!=null&&E instanceof HTMLElement){let Y=Z.width!=null?Math.max(1,Math.floor(E.offsetWidth/Z.width)):Z.visibleColumns??1,X=Math.floor(Q/Y),F=Z.minHeight??Z.height,z=Math.ceil($.length/Y),T=Z.scrollContainer==="window",W=T?window.innerHeight:E.offsetHeight,U;if(Z.minHeight!=null){let K=Math.ceil(W/F)+(Z.rowChunkSize||1),x=z*F,_=Math.max(0,x-W),D=Math.max(1,z-K+1),O=X/D;switch(H){case"start":U=O*_;break;case"end":U=Math.max(0,(X-K+1)/D*_);break;case"nearest":{let w=T?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop,N=_>0?w/_:0,EE=Math.floor(N*D);if(X<EE)U=O*_;else if(X>=EE+K)U=Math.max(0,(X-K+1)/D*_);else return!0;break}default:{let w=X-Math.floor(K/2);U=Math.max(0,w)/D*_}}}else{let K=X*Z.height;switch(H){case"start":U=K;break;case"end":U=K-W+Z.height;break;case"nearest":{let x=T?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop;if(K<x)U=K;else if(K+Z.height>x+W)U=K-W+Z.height;else return!0;break}default:U=K-(W-Z.height)/2}}if(U=Math.max(0,U),T){let K=E.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:K+U,behavior:"smooth"})}else E.scrollTo({top:U,behavior:"smooth"})}else{let Y=L.itemToElement.get(J);if(Y==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",M),!1;Y.scrollIntoView({block:TL[H]??"center",behavior:"smooth"})}return!0};var{document:OE,MutationObserver:Vf}=globalThis,vE=(E,M)=>{let f=b.get(E);if(f==null)return;for(let L of f){let{binding:H,options:$}=L,{path:J}=L,{toDOM:Q}=H;if(Q!=null){if(J.startsWith("^")){let Z=cE(E);if(Z!=null&&Z[y]!=null)J=L.path=`${Z[y]}${J.substring(1)}`;else{if(E instanceof HTMLElement)console.warn(`Unresolved relative binding "${J}" —`,E,"is not part of a list. If this is a list template, wrap it in a <template>.");continue}}if(M==null||J.startsWith(M))Q(E,WE()[J],$)}}};if(Vf!=null)new Vf((M)=>{M.forEach((f)=>{Array.from(f.addedNodes).forEach((L)=>{if(L instanceof Element)Array.from(L.querySelectorAll(n)).forEach((H)=>vE(H))})})}).observe(OE.body,{subtree:!0,childList:!0});g(()=>!0,(E)=>{let M=Array.from(OE.querySelectorAll(n));for(let f of M)vE(f,E)});var Rf=(E)=>{let M=E.target?.closest(n);while(M!=null){let f=b.get(M);for(let L of f){let{binding:H,path:$}=L,{fromDOM:J}=H;if(J!=null){let Q;try{Q=J(M,L.options)}catch(Z){throw console.error("Cannot get value from",M,"via",L),Error("Cannot obtain value fromDOM")}if(Q!=null){let Z=WE(),Y=Z[$];if(Y==null)Z[$]=Q;else{let X=Y[y]!=null?Y[h]:Y,F=Q[y]!=null?Q[h]:Q;if(X!==F)Z[$]=F}}}}M=M.parentElement.closest(n)}};if(globalThis.document!=null)OE.body.addEventListener("change",Rf,!0),OE.body.addEventListener("input",Rf,!0);function IL(E,M,f,L){let{paths:H,transform:$}=M,{toDOM:J}=f;if(J==null)return E;let Q=null,Z={toDOM(X,F,z){let T=WE(),W=H.map((K)=>T[K]);if(Q!==null&&W.every((K,x)=>K===Q[x]))return;Q=W;let U=$(...W);J(X,U,z)},fromDOM:f.fromDOM};E.classList?.add(TE);let Y=b.get(E);if(Y==null)Y=[],b.set(E,Y);for(let X of H)Y.push({path:X,binding:Z,options:L});if(!H[0].startsWith("^"))k(H[0]);return E}function P(E,M,f,L){if(E instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");if(M!=null&&typeof M==="object"&&M[i])return IL(E,M,f,L);let H;if(typeof M==="object"&&M[y]===void 0&&L===void 0){let{value:Q}=M;H=typeof Q==="string"?Q:Q[y],L=M,delete L.value}else H=typeof M==="string"?M:M[y];if(H==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:$}=f;E.classList?.add(TE);let J=b.get(E);if(J==null)J=[],b.set(E,J);if(J.push({path:H,binding:f,options:L}),$!=null&&!H.startsWith("^"))k(H);if(L?.filter&&L?.needle)P(E,L.needle,{toDOM(Q,Z){console.log({needle:Z}),Q[QE]?.filter(Z)}});return E}var Tf=new Set,kL=(E)=>{let M=E?.target?.closest(lE),f=!1,L=new Proxy(E,{get($,J){if(J==="stopPropagation")return()=>{E.stopPropagation(),f=!0};else{let Q=$[J];return typeof Q==="function"?Q.bind($):Q}}}),H=new Set;while(!f&&M!=null){let J=ME.get(M)[E.type]||H;for(let Q of J){if(typeof Q==="function")Q(L);else{let Z=WE()[Q];if(typeof Z==="function")Z(L);else throw Error(`no event handler found at path ${Q}`)}if(f)continue}M=M.parentElement!=null?M.parentElement.closest(lE):null}};function $E(E,M,f){let L=ME.get(E);if(E.classList.add(oE),L==null)L={},ME.set(E,L);if(!L[M])L[M]=new Set;if(L[M].add(f),!Tf.has(M))Tf.add(M),OE.body.addEventListener(M,kL,!0);return()=>{L[M].delete(f)}}hM(P,$E);function uE(E,M){if(!E.internals)return;let f={},L="";if(E.hasAttribute("required")&&M==="")f.valueMissing=!0,L="Please fill out this field.";let H=E.getAttribute("minlength");if(H&&M.length<parseInt(H,10))f.tooShort=!0,L=`Please use at least ${H} characters.`;let $=E.getAttribute("maxlength");if($&&M.length>parseInt($,10))f.tooLong=!0,L=`Please use no more than ${$} characters.`;let J=E.getAttribute("pattern");if(J&&M!=="")try{if(!new RegExp(`^(?:${J})$`).test(M))f.patternMismatch=!0,L="Please match the requested format."}catch{}if(Object.keys(f).length>0)E.internals.setValidity(f,L,E);else E.internals.setValidity({})}var BL=0;function qM(){return`custom-elt${(BL++).toString(36)}`}var If=0,OM=null;function _L(){if(OM===null)OM=new MutationObserver((E)=>{let M=new Set;for(let f of E)if(f.type==="attributes"&&f.target instanceof m){let L=f.target,H=YM(f.attributeName);if(L._legacyTrackedAttrs?.has(H))M.add(L)}for(let f of M)f.queueRender(!1)});return OM}var wE={};function SL(E,M){let f=wE[E],L=t(M).replace(/:host\(([^)]+)\)/g,`${E}$1`).replace(/:host\b/g,E);wE[E]=f?f+`
13
+ `+L:L}function xL(E){if(wE[E])document.head.append(I.style({id:E+"-component"},wE[E]));delete wE[E]}class m extends HTMLElement{static elements=I;static _elementCreator;static initAttributes;static formAssociated;static preferredTagName;static shadowStyleSpec;static lightStyleSpec;static extends;internals;get validity(){return this.internals?.validity}get validationMessage(){return this.internals?.validationMessage??""}get willValidate(){return this.internals?.willValidate??!1}checkValidity(){return this.internals?.checkValidity()??!0}reportValidity(){return this.internals?.reportValidity()??!0}setCustomValidity(E){if(this.internals)if(E)this.internals.setValidity({customError:!0},E);else this.internals.setValidity({})}setValidity(E,M,f){this.internals?.setValidity(E,M,f)}setFormValue(E,M){this.internals?.setFormValue(E,M)}static get observedAttributes(){let E=this.initAttributes;if(E)return["hidden",...Object.keys(E).map(S)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=I.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(E){return console.warn("StyleNode is deprecated, use static shadowStyleSpec instead"),I.style(t(E))}static elementCreator(E={}){let M=this;if(!Object.prototype.hasOwnProperty.call(M,"_elementCreator")){if(E.tag!==void 0)j("elementCreator-tag","Passing tag to elementCreator() is deprecated. Use static preferredTagName instead.");if(E.styleSpec!==void 0)j("elementCreator-styleSpec","Passing styleSpec to elementCreator() is deprecated. Use static lightStyleSpec instead.");if(E.extends!==void 0)j("elementCreator-extends","Passing extends to elementCreator() is deprecated. Use static extends instead.");let f=E.tag??M.preferredTagName;if(f==null)if(typeof M.name==="string"&&M.name!==""){if(f=S(M.name),f.startsWith("-"))f=f.slice(1)}else f=qM();if(customElements.get(f)!=null)console.warn(`${f} is already defined`);if(f.match(/\w+(-\w+)+/)==null)console.warn(`${f} is not a legal tag for a custom-element`),f=qM();while(customElements.get(f)!==void 0)f=qM();M._tagName=f;let L=E.styleSpec??M.lightStyleSpec;if(L!==void 0)SL(f,L);let H=E.extends??M.extends,$=H?{extends:H}:void 0;window.customElements.define(f,this,$),M._elementCreator=I[f]}return M._elementCreator}initAttributes(...E){if(j("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let H of E)this._legacyTrackedAttrs.add(H);_L().observe(this,{attributes:!0});let f={},L={};E.forEach((H)=>{f[H]=v(this[H]);let $=S(H);Object.defineProperty(this,H,{enumerable:!1,get(){if(typeof f[H]==="boolean")return this.hasAttribute($);else if(this.hasAttribute($))return typeof f[H]==="number"?parseFloat(this.getAttribute($)):this.getAttribute($);else if(L[H]!==void 0)return L[H];else return f[H]},set(J){if(typeof f[H]==="boolean"){if(J!==this[H]){if(J)this.setAttribute($,"");else this.removeAttribute($);this.queueRender()}}else if(typeof f[H]==="number"){if(J!==parseFloat(this[H]))this.setAttribute($,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[H]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute($);else this.setAttribute($,J);this.queueRender(),L[H]=J}}})})}initValue(){let E=Object.getOwnPropertyDescriptor(this,"value");if(E===void 0||E.get!==void 0||E.set!==void 0)return;let M=this.hasAttribute("value")?this.getAttribute("value"):v(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return M},set(f){if(M!==f)M=f,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let E=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(M,f){if(M[f]===void 0){let L=E.querySelector(`[part="${f}"]`);if(L==null)L=E.querySelector(f);if(L==null)throw Error(`elementRef "${f}" does not exist!`);L.removeAttribute("data-ref"),M[f]=L}return M[f]}});return this._parts}attributeChangedCallback(E,M,f){let L=YM(E);if(!this._legacyTrackedAttrs?.has(L))this.queueRender(!1)}constructor(){super();if(If+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let E=this.constructor.initAttributes;if(E)this._setupAttributeAccessors(E);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${If}`,this._value=v(this.defaultValue)}_setupAttributeAccessors(E){if(!this._attrValues)this._attrValues=new Map;for(let M of Object.keys(E)){let f=S(M),L=E[M];if(M==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof L==="object"&&L!==null){console.warn(`${this.tagName}: initAttributes.${M} is an object. Use a regular property instead.`);continue}let H=this,$=!1;while(H){let J=Object.getOwnPropertyDescriptor(H,M);if(J){if(!J.configurable||J.get||J.set){$=!0;break}break}H=Object.getPrototypeOf(H)}if($)continue;Object.defineProperty(this,M,{enumerable:!1,get:()=>{if(typeof L==="boolean")return this.hasAttribute(f);else if(this.hasAttribute(f))return typeof L==="number"?parseFloat(this.getAttribute(f)):this.getAttribute(f);else if(this._attrValues.has(M))return this._attrValues.get(M);else return L},set:(J)=>{if(typeof L==="boolean"){if(J!==this[M]){if(J)this.setAttribute(f,"");else this.removeAttribute(f);this.queueRender()}}else if(typeof L==="number"){if(J!==parseFloat(this[M]))this.setAttribute(f,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[M]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute(f);else this.setAttribute(f,J);this.queueRender(),this._attrValues.set(M,J)}}})}}connectedCallback(){if(xL(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.constructor.formAssociated&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.onResize!==void 0){if(UE.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");if(this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this.queueRender()}disconnectedCallback(){UE.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(E){if(E)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(E){if(this.value!==void 0&&typeof E==="string")this.value=E}_changeQueued=!1;_renderQueued=!1;queueRender(E=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=E;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued){if(ZM(this,"change"),this.internals&&this.value!==void 0)this.internals.setFormValue(this.value)}this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let E=typeof this.content!=="function",M=typeof this.content==="function"?this.content(I):this.content;if(Array.isArray(M)){let $={};M=M.filter((J)=>{if(J instanceof Node||typeof J==="string"||typeof J==="number"||A(J))return!0;return Object.assign($,J),!1});for(let J of Object.keys($))NE(this,J,$[J])}let f=this.constructor,L=f.shadowStyleSpec??f.styleSpec;if(f.styleSpec&&!f.shadowStyleSpec)j("static-styleSpec","static styleSpec is deprecated. Use static shadowStyleSpec instead.");let{styleNode:H}=f;if(L)H=f.styleNode=I.style(t(L)),delete f.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecated, use static shadowStyleSpec instead"),H=this.styleNode;if(H){let $=this.attachShadow({mode:"open"});$.appendChild(H.cloneNode(!0)),QM($,M,E)}else if(M!==null){let $=Array.from(this.childNodes);QM(this,M,E),this.isSlotted=this.querySelector("slot,tosi-slot,xin-slot")!==void 0;let J=Array.from(this.querySelectorAll("slot"));if(J.length>0)J.forEach(gE.replaceSlot);if($.length>0){let Q={"":this};Array.from(this.querySelectorAll("tosi-slot,xin-slot")).forEach((Z)=>{Q[Z.name]=Z}),$.forEach((Z)=>{let Y=Q[""],X=Z instanceof Element?Q[Z.slot]:Y;(X!==void 0?X:Y).append(Z)})}}this._hydrated=!0}}render(){if(this._valueChanged&&this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this._valueChanged=!1}validateValue(){if(!this.internals||this.value===void 0)return;let E=typeof this.value==="string"?this.value:String(this.value);uE(this,E)}}class gE extends m{static preferredTagName="tosi-slot";static initAttributes={name:""};content=null;static replaceSlot(E){let M=document.createElement("tosi-slot");if(E.name!=="")M.setAttribute("name",E.name);E.replaceWith(M)}}var kf=gE.elementCreator();class Bf extends m{static preferredTagName="xin-slot";static initAttributes={name:""};content=null;constructor(){super();j("xin-slot","<xin-slot> is deprecated. Use <tosi-slot> instead.")}static replaceSlot=gE.replaceSlot}var _f=Bf.elementCreator();var Sf=(E=()=>!0)=>{let M=localStorage.getItem("xin-state");if(M!=null){let L=JSON.parse(M);for(let H of Object.keys(L).filter(E))if(R[H]!==void 0)Object.assign(R[H],L[H]);else R[H]=L[H]}let f=GE(()=>{let L={},H=q(R);for(let $ of Object.keys(H).filter(E))L[$]=H[$];localStorage.setItem("xin-state",JSON.stringify(L)),console.log("xin state saved to localStorage")},500);XE(E,f)};var NL="tosijs-share",yL="tosijs-share",AE="shared",PL=1,AM=new Set,CM=new Set,wM=new Map,ZE=null,jM="",dE=null,mL=null;function xf(){if(dE!=null)return Promise.resolve(dE);return new Promise((E,M)=>{let f=indexedDB.open(yL,PL);f.onupgradeneeded=()=>{f.result.createObjectStore(AE)},f.onsuccess=()=>{dE=f.result,E(dE)},f.onerror=()=>M(f.error)})}var bL={async get(E){let M=await xf();return new Promise((f,L)=>{let $=M.transaction(AE,"readonly").objectStore(AE).get(E);$.onsuccess=()=>f($.result),$.onerror=()=>L($.error)})},async set(E,M){let f=await xf();return new Promise((L,H)=>{let $=f.transaction(AE,"readwrite");$.objectStore(AE).put(M,E),$.oncomplete=()=>L(),$.onerror=()=>H($.error)})}};function Nf(){return mL??bL}function cL(E){return E!=null&&E.type==="tosijs-share"&&typeof E.path==="string"}function yf(E){for(let M of AM)if(E===M||E.startsWith(M+"."))return M;return}function vL(E){for(let M of CM)if(E===M||E.startsWith(M+"."))return!0;return!1}function uL(E,M){CM.add(E),r(V,E,M),k(E),LE().then(()=>{CM.delete(E)})}function gL(){if(ZE!=null)return ZE;return jM=crypto.randomUUID(),ZE=new BroadcastChannel(NL),ZE.onmessage=(E)=>{let M=E.data;if(!cL(M))return;if(M.origin===jM)return;if(yf(M.path)===void 0)return;uL(M.path,M.value)},ZE}function dL(E,M){if(ZE==null)return;let f={type:"tosijs-share",path:E,value:M,origin:jM};ZE.postMessage(f)}function nL(E){if(!wM.has(E))wM.set(E,GE(()=>{let M=C(V,E);Nf().set(E,M)},500));wM.get(E)()}async function Pf(...E){if(typeof BroadcastChannel>"u")return{restored:[]};gL();let M=[],f=Nf();for(let L of E){let H=typeof L==="string"?L:A(L);if(H===void 0)throw Error("share() requires boxed proxies or string paths. Got a non-proxy value.");if(AM.has(H))continue;AM.add(H);let $=await f.get(H);if($!==void 0)r(V,H,$),k(H),M.push(L);else{let J=C(V,H);await f.set(H,J)}g((J)=>J===H||J.startsWith(H+"."),(J)=>{if(vL(J))return;let Q=yf(J);if(Q===void 0)return;let Z=C(V,J);dL(J,Z),nL(Q)})}return{restored:M}}var VM=new Set;function mf(E,M){for(let f of E)if(M===f||M.startsWith(f+"."))return f;return}function hL(E){for(let M of VM)if(E===M||E.startsWith(M+"."))return!0;return!1}function iL(E,M){VM.add(E),r(V,E,M),k(E),LE().then(()=>{VM.delete(E)})}async function bf(E,M,...f){let L=new Set,H=[],$=[],J=M.throttleInterval??100;await E.connect();let Q=HE(()=>{if(H.length===0)return;let Z=H.splice(0);E.send(Z)},J);E.onReceive((Z)=>{for(let Y of Z){if(mf(L,Y.path)===void 0)continue;iL(Y.path,Y.value)}});for(let Z of f){let Y=typeof Z==="string"?Z:A(Z);if(Y===void 0)throw Error("sync() requires boxed proxies or string paths. Got a non-proxy value.");L.add(Y);let X=g((F)=>F===Y||F.startsWith(Y+"."),(F)=>{if(hL(F))return;if(mf(L,F)===void 0)return;let z=C(V,F);H.push({path:F,value:z}),Q()});$.push(X)}return{disconnect(){for(let Z of $)o(Z);$.length=0,L.clear(),H.length=0,E.disconnect()}}}var nE="1.5.9";function CE(E){return Object.assign(B,E),B}function jE(E){return j("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),CE(E)}var sL=new FinalizationRegistry((E)=>{E()});function cf(E,M){let f=EM();B[f]=E;let L=B[f],H=()=>{delete R[f]};if(M)sL.register(M,H);return[L,H]}function hE(E,M=!1){if(M)return j("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),jE(E);return Object.keys(E).forEach((f)=>{R[f]=E[f]}),R}var pL={};async function VE(E,M){let f=await M(E,{Color:G,Component:m,elements:I,svgElements:yE,mathML:PE,varDefault:KE,vars:SE,xin:R,boxed:B,xinProxy:hE,boxedProxy:jE,tosi:CE,makeComponent:VE,bind:P,on:$E,version:nE}),{type:L}=f;L.preferredTagName=E;let H=f.lightStyleSpec??f.styleSpec;if(H)L.lightStyleSpec=H;let $={type:L,creator:L.elementCreator()};return pL[E]=$,$}var iE={":host":{display:"none"}},RM={},rL=(E)=>import(E);class RE extends m{static preferredTagName="tosi-blueprint";static lightStyleSpec=iE;static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(E)=>{};async packaged(){let{tag:E,src:M,property:f}=this,L=`${E}.${f}:${M}`;if(!this.loaded){if(RM[L]===void 0)RM[L]=rL(M).then((H)=>{let $=H[f];return VE(E,$)});else console.log(`using cached ${E} with signature ${L}`);this.loaded=await RM[L],this.blueprintLoaded(this.loaded)}return this.loaded}}var vf=RE.elementCreator();class sE extends m{static preferredTagName="tosi-loader";static lightStyleSpec=iE;allLoaded=()=>{};async load(){let M=Array.from(this.querySelectorAll("tosi-blueprint, xin-blueprint")).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(M),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var uf=sE.elementCreator();class gf extends RE{static preferredTagName="xin-blueprint";static lightStyleSpec=iE;constructor(){super();j("xin-blueprint","<xin-blueprint> is deprecated. Use <tosi-blueprint> instead.")}}var df=gf.elementCreator();class nf extends m{static preferredTagName="xin-loader";static lightStyleSpec=iE;allLoaded=()=>{};constructor(){super();j("xin-loader","<xin-loader> is deprecated. Use <tosi-loader> instead.")}async load(){let M=Array.from(this.querySelectorAll("xin-blueprint")).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(M),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var hf=nf.elementCreator();})();
14
14
 
15
- //# debugId=5C9396F9176769BF64756E2164756E21
15
+ //# debugId=887F6F4719E2032964756E2164756E21
16
16
  //# sourceMappingURL=index.js.map