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