tosijs 1.1.0 → 1.1.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 CHANGED
@@ -1,13 +1,13 @@
1
- (()=>{var{defineProperty:$e,getOwnPropertyNames:Uo,getOwnPropertyDescriptor:Ko}=Object,Ro=Object.prototype.hasOwnProperty;var ro=new WeakMap,Vo=(e)=>{var o=ro.get(e),n;if(o)return o;if(o=$e({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")Uo(e).map((r)=>!Ro.call(o,r)&&$e(o,r,{get:()=>e[r],enumerable:!(n=Ko(e,r))||n.enumerable}));return ro.set(e,o),o};var Io=(e,o)=>{for(var n in o)$e(e,n,{get:o[n],enumerable:!0,configurable:!0,set:(r)=>o[n]=()=>r})};var Sn={};Io(Sn,{xinValue:()=>C,xinProxy:()=>Se,xinPath:()=>S,xin:()=>u,version:()=>ge,vars:()=>Ce,varDefault:()=>re,updates:()=>Ge,unobserve:()=>J,touchElement:()=>ke,touch:()=>Q,tosi:()=>se,throttle:()=>ee,svgElements:()=>Ee,settings:()=>W,on:()=>v,observe:()=>Me,mathML:()=>xe,makeComponent:()=>me,invertLuminance:()=>go,initVars:()=>ko,hotReload:()=>Zo,getListItem:()=>Le,getListInstance:()=>Te,getListBinding:()=>ne,getCssVar:()=>we,elements:()=>d,deleteListItem:()=>Jo,debounce:()=>pe,css:()=>O,boxedProxy:()=>ce,boxed:()=>V,blueprintLoader:()=>Oo,blueprint:()=>Ao,bindings:()=>oe,bind:()=>T,StyleSheet:()=>To,MoreMath:()=>xo,Component:()=>D,Color:()=>f,BlueprintLoader:()=>He,Blueprint:()=>le});function H(e){if(e==null||typeof e!=="object")return e;if(e instanceof Set)return new Set(e);else if(Array.isArray(e))return e.map(H);let o={};for(let n in e){let r=e[n];if(e!=null&&typeof e==="object")o[n]=H(r);else o[n]=r}return o}var ze="-xin-data",F=`.${ze}`,De="-xin-event",Fe=`.${De}`,b="xinPath",Y="xinValue",Ye="xinObserve",We="xinBind",Je="xinOn",B=Symbol("list-binding"),fe=Symbol("list-instance"),S=(e)=>{return e&&e[b]||void 0};function C(e){if(typeof e==="object"&&e!==null){let o=e[Y];return o!==void 0?o:e}return e}var j=new WeakMap,X=new WeakMap;var q=(e)=>{let o=e.cloneNode();if(o instanceof Element){let n=X.get(e),r=j.get(e);if(n!=null)X.set(o,H(n));if(r!=null)j.set(o,H(r))}for(let n of Array.from(e instanceof HTMLTemplateElement?e.content.childNodes:e.childNodes))if(n instanceof Element||n instanceof DocumentFragment)o.appendChild(q(n));else o.appendChild(n.cloneNode());return o};var W={debug:!1,perf:!1};var to=Symbol("observer should be removed"),ae=[],de=[],je=!1,qe,Qe;class io{description;test;callback;constructor(e,o){let n=typeof o==="string"?`"${o}"`:`function ${o.name}`,r;if(typeof e==="string")this.test=(t)=>typeof t==="string"&&t!==""&&(e.startsWith(t)||t.startsWith(e)),r=`test = "${e}"`;else if(e instanceof RegExp)this.test=e.test.bind(e),r=`test = "${e.toString()}"`;else if(e instanceof Function)this.test=e,r=`test = function ${e.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${r}, ${n}`,typeof o==="function")this.callback=o;else throw Error("expect callback to be a path or function");ae.push(this)}}var Ge=async()=>{if(qe===void 0)return;await qe},Po=()=>{if(W.perf)console.time("xin async update");let e=Array.from(de);for(let o of e)ae.filter((n)=>{let r;try{r=n.test(o)}catch(t){throw Error(`Listener ${n.description} threw "${t}" at "${o}"`)}if(r===to)return J(n),!1;return r}).forEach((n)=>{let r;try{r=n.callback(o)}catch(t){console.error(`Listener ${n.description} threw "${t}" handling "${o}"`)}if(r===to)J(n)});if(de.splice(0),je=!1,typeof Qe==="function")Qe();if(W.perf)console.timeEnd("xin async update")},Q=(e)=>{let o=typeof e==="string"?e:S(e);if(o===void 0)throw console.error("touch was called on an invalid target",e),Error("touch was called on an invalid target");if(je===!1)qe=new Promise((n)=>{Qe=n}),je=setTimeout(Po);if(de.find((n)=>o.startsWith(n))==null)de.push(o)},G=(e,o)=>{return new io(e,o)},J=(e)=>{let o=ae.indexOf(e);if(o>-1)ae.splice(o,1);else throw Error("unobserve failed, listener not found")};var _={},Ze=null,so=(e)=>{Ze=e},ue=()=>{if(Ze===null)throw Error("xin proxy not initialized");return Ze},Ae=null,Oe=null,co=(e,o)=>{Ae=e,Oe=o},ye=()=>{if(Ae===null)throw Error("bind not initialized");return Ae},he=()=>{if(Oe===null)throw Error("on not initialized");return Oe};var ve=(e,o)=>{let n=new Event(o);e.dispatchEvent(n)},lo=(e)=>{if(e instanceof HTMLInputElement)return e.type;else if(e instanceof HTMLSelectElement&&e.hasAttribute("multiple"))return"multi-select";else return"other"},fo=(e,o)=>{switch(lo(e)){case"radio":e.checked=e.value===o;break;case"checkbox":e.checked=!!o;break;case"date":e.valueAsDate=new Date(o);break;case"multi-select":for(let n of Array.from(e.querySelectorAll("option")))n.selected=o[n.value];break;default:e.value=o}},ao=(e)=>{switch(lo(e)){case"radio":{let o=e.parentElement?.querySelector(`[name="${e.name}"]:checked`);return o!=null?o.value:null}case"checkbox":return e.checked;case"date":return e.valueAsDate?.toISOString();case"multi-select":return Array.from(e.querySelectorAll("option")).reduce((o,n)=>{return o[n.value]=n.selected,o},{});default:return e.value}},{ResizeObserver:mo}=globalThis,N=mo!=null?new mo((e)=>{for(let o of e){let n=o.target;ve(n,"resize")}}):{observe(){},unobserve(){}},Ue=(e,o,n=!0)=>{if(e!=null&&o!=null)if(typeof o==="string")e.textContent=o;else if(Array.isArray(o))o.forEach((r)=>{e.append(r instanceof Node&&n?q(r):r)});else if(o instanceof Node)e.append(n?q(o):o);else throw Error("expect text content or document node")};var pe=(e,o=250)=>{let n;return(...r)=>{if(n!==void 0)clearTimeout(n);n=setTimeout(()=>{e(...r)},o)}},ee=(e,o=250)=>{let n,r=Date.now()-o,t=!1;return(...i)=>{if(clearTimeout(n),n=setTimeout(()=>{e(...i),r=Date.now()},o),!t&&Date.now()-r>=o){t=!0;try{e(...i),r=Date.now()}finally{t=!1}}}};var Bo=(e)=>{try{return JSON.stringify(e)}catch(o){return"{has circular references}"}},Ke=(...e)=>Error(e.map(Bo).join(" "));var _o=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),No=0,en=()=>(parseInt("10000",36)+ ++No).toString(36).slice(-5),on=()=>_o()+en(),Ve=Symbol("delete"),ho=Symbol("new-object"),Re=Symbol("automatic-index");function po(e){if(e==="")return[];if(Array.isArray(e))return e;else{let o=[];while(e.length>0){let n=e.search(/\[[^\]]+\]/);if(n===-1){o.push(e.split("."));break}else{let r=e.slice(0,n);if(e=e.slice(n),r!=="")o.push(r.split("."));if(n=e.indexOf("]")+1,o.push(e.slice(1,n-1)),e.slice(n,n+1)===".")n+=1;e=e.slice(n)}}return o}}var $=new WeakMap;function wo(e,o){if($.get(e)===void 0)$.set(e,{});if($.get(e)[o]===void 0)$.get(e)[o]={};let n=$.get(e)[o];if(o==="_auto_")e.forEach((r,t)=>{if(r[Re]===void 0)r[Re]=on();n[r[Re]+""]=t});else e.forEach((r,t)=>{n[Z(r,o)+""]=t});return n}function nn(e,o){if($.get(e)===void 0||$.get(e)[o]===void 0)return wo(e,o);else return $.get(e)[o]}function rn(e,o,n){n=n+"";let r=nn(e,o)[n];if(r===void 0||Z(e[r],o)+""!==n)r=wo(e,o)[n];return r}function tn(e,o,n){if(e[o]===void 0&&n!==void 0)e[o]=n;return e[o]}function Co(e,o,n,r){let t=o!==""?rn(e,o,n):n;if(r===Ve)return e.splice(t,1),$.delete(e),Symbol("deleted");else if(r===ho){if(o===""&&e[t]===void 0)e[t]={}}else if(r!==void 0)if(t!==void 0)e[t]=r;else if(o!==""&&Z(r,o)+""===n+"")e.push(r),t=e.length-1;else throw Error(`byIdPath insert failed at [${o}=${n}]`);return e[t]}function uo(e){if(!Array.isArray(e))throw Ke("setByPath failed: expected array, found",e)}function yo(e){if(e==null||!(e instanceof Object))throw Ke("setByPath failed: expected Object, found",e)}function Z(e,o){let n=po(o),r=e,t,i,m,s;for(t=0,i=n.length;r!==void 0&&t<i;t++){let c=n[t];if(Array.isArray(c))for(m=0,s=c.length;r!==void 0&&m<s;m++){let l=c[m];r=r[l]}else if(r.length===0){if(r=r[Number(c.slice(1))],c[0]!=="=")return}else if(c.includes("=")){let[l,...a]=c.split("=");r=Co(r,l,a.join("="))}else m=parseInt(c,10),r=r[m]}return r}function bo(e,o,n){let r=e;if(o==="")throw Error("setByPath cannot be used to set the root object");let t=po(o);while(r!=null&&t.length>0){let i=t.shift();if(typeof i==="string"){let m=i.indexOf("=");if(m>-1){if(m===0)yo(r);else uo(r);let s=i.slice(0,m),c=i.slice(m+1);if(r=Co(r,s,c,t.length>0?ho:n),t.length===0)return!0}else{uo(r);let s=parseInt(i,10);if(t.length>0)r=r[s];else{if(n!==Ve){if(r[s]===n)return!1;r[s]=n}else r.splice(s,1);return!0}}}else if(Array.isArray(i)&&i.length>0){yo(r);while(i.length>0){let m=i.shift();if(i.length>0||t.length>0)r=tn(r,m,i.length>0?{}:[]);else{if(n!==Ve){if(r[m]===n)return!1;r[m]=n}else{if(!Object.prototype.hasOwnProperty.call(r,m))return!1;delete r[m]}return!0}}}else throw Error(`setByPath failed, bad path ${o}`)}throw Error(`setByPath(${e}, ${o}, ${n}) failed`)}var oe={value:{toDOM:fo,fromDOM(e){return ao(e)}},text:{toDOM(e,o){e.textContent=o}},enabled:{toDOM(e,o){e.disabled=!o}},disabled:{toDOM(e,o){e.disabled=Boolean(o)}},list:{toDOM(e,o,n){ne(e,o,n).update(o)}}};function x(e){return e.replace(/[A-Z]/g,(o)=>{return`-${o.toLocaleLowerCase()}`})}function Eo(e){return e.replace(/-([a-z])/g,(o,n)=>{return n.toLocaleUpperCase()})}var sn=180/Math.PI,cn=Math.PI/180;function M(e,o,n){return n<e?NaN:o<e?e:o>n?n:o}function z(e,o,n,r=!0){if(r)n=M(0,n,1);return n*(o-e)+e}var xo={RADIANS_TO_DEGREES:sn,DEGREES_TO_RADIANS:cn,clamp:M,lerp:z};function we(e,o=document.body){let n=getComputedStyle(o);if(e.endsWith(")")&&e.startsWith("var("))e=e.slice(4,-1);return n.getPropertyValue(e).trim()}var mn=(e,o,n)=>{return(0.299*e+0.587*o+0.114*n)/255},A=(e)=>("00"+Math.round(Number(e)).toString(16)).slice(-2);class Mo{h;s;l;constructor(e,o,n){e/=255,o/=255,n/=255;let r=Math.max(e,o,n),t=r-Math.min(e,o,n),i=t!==0?r===e?(o-n)/t:r===o?2+(n-e)/t:4+(e-o)/t:0;this.h=60*i<0?60*i+360:60*i,this.s=t!==0?r<=0.5?t/(2*r-t):t/(2-(2*r-t)):0,this.l=(2*r-t)/2}}var P=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class f{r;g;b;a;static fromVar(e,o=document.body){return f.fromCss(we(e,o))}static fromCss(e){let o=e;if(P instanceof HTMLSpanElement)P.style.color="black",P.style.color=e,document.body.appendChild(P),o=getComputedStyle(P).color,P.remove();let[n,r,t,i]=o.match(/[\d.]+/g)||["0","0","0","0"],m=o.startsWith("color(srgb")?255:1;return new f(Number(n)*m,Number(r)*m,Number(t)*m,i==null?1:Number(i))}static fromHsl(e,o,n,r=1){let t,i,m;if(o===0)t=i=m=n;else{let c=(w,L,p)=>{if(p<0)p+=1;if(p>1)p-=1;if(p<0.16666666666666666)return w+(L-w)*6*p;if(p<0.5)return L;if(p<0.6666666666666666)return w+(L-w)*(0.6666666666666666-p)*6;return w},l=n<0.5?n*(1+o):n+o-n*o,a=2*n-l,y=(e%360+360)%360/360;t=c(a,l,y+0.3333333333333333),i=c(a,l,y),m=c(a,l,y-0.3333333333333333)}let s=new f(t*255,i*255,m*255,r);return s.hslCached={h:(e%360+360)%360,s:o,l:n},s}static black=new f(0,0,0);static white=new f(255,255,255);constructor(e,o,n,r=1){this.r=M(0,e,255),this.g=M(0,o,255),this.b=M(0,n,255),this.a=M(0,r,1)}get inverse(){return new f(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:e,s:o,l:n}=this._hsl;return f.fromHsl(e,o,1-n,this.a)}get opaque(){return this.a===1?this:new f(this.r,this.g,this.b,1)}contrasting(e=1){return this.opaque.blend(this.brightness>0.5?f.black:f.white,e)}get rgb(){let{r:e,g:o,b:n}=this;return`rgb(${e.toFixed(0)},${o.toFixed(0)},${n.toFixed(0)})`}get rgba(){let{r:e,g:o,b:n,a:r}=this;return`rgba(${e.toFixed(0)},${o.toFixed(0)},${n.toFixed(0)},${r.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new Mo(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:e,s:o,l:n}=this._hsl;return`hsl(${e.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(n*100).toFixed(0)}%)`}get hsla(){let{h:e,s:o,l:n}=this._hsl;return`hsl(${e.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(n*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let e=this.brightness*255;return new f(e,e,e)}get brightness(){return mn(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+A(this.r)+A(this.g)+A(this.b):"#"+A(this.r)+A(this.g)+A(this.b)+A(Math.floor(255*this.a))}brighten(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,r+e*(1-r),1);return f.fromHsl(o,n,t,this.a)}darken(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,r*(1-e),1);return f.fromHsl(o,n,t,this.a)}saturate(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,n+e*(1-n),1);return f.fromHsl(o,t,r,this.a)}desaturate(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,n*(1-e),1);return f.fromHsl(o,t,r,this.a)}rotate(e){let{h:o,s:n,l:r}=this._hsl,t=(o+360+e)%360;return f.fromHsl(t,n,r,this.a)}opacity(e){let{h:o,s:n,l:r}=this._hsl;return f.fromHsl(o,n,r,e)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(e,o){return new f(z(this.r,e.r,o),z(this.g,e.g,o),z(this.b,e.b,o),z(this.a,e.a,o))}static blendHue(e,o,n){let r=(o-e+720)%360;if(r<180)return e+n*r;else return e-(360-r)*n}mix(e,o){let n=this._hsl,r=e._hsl;return f.fromHsl(n.s===0?r.h:r.s===0?n.h:f.blendHue(n.h,r.h,o),z(n.s,r.s,o),z(n.l,r.l,o),z(this.a,e.a,o))}colorMix(e,o){return f.fromCss(`color-mix(in hsl, ${this.html}, ${e.html} ${(o*100).toFixed(0)}%)`)}}function To(e,o){let n=d.style(O(o));n.id=e,document.head.append(n)}var ln=["animation-iteration-count","flex","flex-base","flex-grow","flex-shrink","opacity","order","tab-size","widows","z-index","zoom"],Ie=(e,o)=>{if(typeof o==="number"&&!ln.includes(e))o=`${o}px`;if(e.startsWith("_"))if(e.startsWith("__"))e="--"+e.substring(2),o=`var(${e}-default, ${o})`;else e="--"+e.substring(1);return{prop:e,value:String(o)}},fn=(e,o,n)=>{if(n===void 0)return"";if(n instanceof f)n=n.html;let r=Ie(o,n);return`${e} ${r.prop}: ${r.value};`},Lo=(e,o,n="")=>{let r=x(e);if(typeof o==="object"&&!(o instanceof f)){let t=Object.keys(o).map((i)=>Lo(i,o[i],`${n} `)).join(`
1
+ (()=>{var{defineProperty:ze,getOwnPropertyNames:vo,getOwnPropertyDescriptor:Ko}=Object,Ro=Object.prototype.hasOwnProperty;var ro=new WeakMap,Io=(e)=>{var o=ro.get(e),n;if(o)return o;if(o=ze({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")vo(e).map((r)=>!Ro.call(o,r)&&ze(o,r,{get:()=>e[r],enumerable:!(n=Ko(e,r))||n.enumerable}));return ro.set(e,o),o};var Vo=(e,o)=>{for(var n in o)ze(e,n,{get:o[n],enumerable:!0,configurable:!0,set:(r)=>o[n]=()=>r})};var Hn={};Vo(Hn,{xinValue:()=>w,xinProxy:()=>ge,xinPath:()=>H,xin:()=>a,version:()=>He,vars:()=>Ce,varDefault:()=>ie,updates:()=>Ze,unobserve:()=>$,touchElement:()=>Se,touch:()=>G,tosi:()=>me,throttle:()=>ne,svgElements:()=>be,settings:()=>J,on:()=>U,observe:()=>Te,mathML:()=>xe,makeComponent:()=>le,invertLuminance:()=>So,initVars:()=>ko,hotReload:()=>Zo,getListItem:()=>ke,getListInstance:()=>Le,getListBinding:()=>te,getCssVar:()=>we,elements:()=>d,deleteListItem:()=>Jo,debounce:()=>pe,css:()=>O,boxedProxy:()=>fe,boxed:()=>I,blueprintLoader:()=>Oo,blueprint:()=>Ao,bindings:()=>re,bind:()=>T,StyleSheet:()=>To,MoreMath:()=>xo,Component:()=>F,Color:()=>l,BlueprintLoader:()=>Xe,Blueprint:()=>ue});function g(e){if(e==null||typeof e!=="object")return e;if(e instanceof Set)return new Set(e);else if(Array.isArray(e))return e.map(g);let o={};for(let n in e){let r=e[n];if(e!=null&&typeof e==="object")o[n]=g(r);else o[n]=r}return o}var De="-xin-data",Y=`.${De}`,Fe="-xin-event",Ye=`.${Fe}`,E="xinPath",W="xinValue",We="xinObserve",Je="xinBind",je="xinOn",B=Symbol("list-binding"),de=Symbol("list-instance"),H=(e)=>{return e&&e[E]||void 0};function w(e){if(typeof e==="object"&&e!==null){let o=e[W];return o!==void 0?o:e}return e}var q=new WeakMap,X=new WeakMap;var Q=(e)=>{let o=e.cloneNode();if(o instanceof Element){let n=X.get(e),r=q.get(e);if(n!=null)X.set(o,g(n));if(r!=null)q.set(o,g(r))}for(let n of Array.from(e instanceof HTMLTemplateElement?e.content.childNodes:e.childNodes))if(n instanceof Element||n instanceof DocumentFragment)o.appendChild(Q(n));else o.appendChild(n.cloneNode());return o};var J={debug:!1,perf:!1};var to=Symbol("observer should be removed"),ae=[],ye=[],qe=!1,Qe,Ge;class io{description;test;callback;constructor(e,o){let n=typeof o==="string"?`"${o}"`:`function ${o.name}`,r;if(typeof e==="string")this.test=(t)=>typeof t==="string"&&t!==""&&(e.startsWith(t)||t.startsWith(e)),r=`test = "${e}"`;else if(e instanceof RegExp)this.test=e.test.bind(e),r=`test = "${e.toString()}"`;else if(e instanceof Function)this.test=e,r=`test = function ${e.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${r}, ${n}`,typeof o==="function")this.callback=o;else throw Error("expect callback to be a path or function");ae.push(this)}}var Ze=async()=>{if(Qe===void 0)return;await Qe},Po=()=>{if(J.perf)console.time("xin async update");let e=Array.from(ye);for(let o of e)ae.filter((n)=>{let r;try{r=n.test(o)}catch(t){throw Error(`Listener ${n.description} threw "${t}" at "${o}"`)}if(r===to)return $(n),!1;return r}).forEach((n)=>{let r;try{r=n.callback(o)}catch(t){console.error(`Listener ${n.description} threw "${t}" handling "${o}"`)}if(r===to)$(n)});if(ye.splice(0),qe=!1,typeof Ge==="function")Ge();if(J.perf)console.timeEnd("xin async update")},G=(e)=>{let o=typeof e==="string"?e:H(e);if(o===void 0)throw console.error("touch was called on an invalid target",e),Error("touch was called on an invalid target");if(qe===!1)Qe=new Promise((n)=>{Ge=n}),qe=setTimeout(Po);if(ye.find((n)=>o.startsWith(n))==null)ye.push(o)},j=(e,o)=>{return new io(e,o)},$=(e)=>{let o=ae.indexOf(e);if(o>-1)ae.splice(o,1);else throw Error("unobserve failed, listener not found")};var _={},Ae=null,so=(e)=>{Ae=e},he=()=>{if(Ae===null)throw Error("xin proxy not initialized");return Ae},Oe=null,Ue=null,co=(e,o)=>{Oe=e,Ue=o},N=()=>{if(Oe===null)throw Error("bind not initialized");return Oe},ee=()=>{if(Ue===null)throw Error("on not initialized");return Ue};var ve=(e,o)=>{let n=new Event(o);e.dispatchEvent(n)},fo=(e)=>{if(e instanceof HTMLInputElement)return e.type;else if(e instanceof HTMLSelectElement&&e.hasAttribute("multiple"))return"multi-select";else return"other"},lo=(e,o)=>{switch(fo(e)){case"radio":e.checked=e.value===o;break;case"checkbox":e.checked=!!o;break;case"date":e.valueAsDate=new Date(o);break;case"multi-select":for(let n of Array.from(e.querySelectorAll("option")))n.selected=o[n.value];break;default:e.value=o}},uo=(e)=>{switch(fo(e)){case"radio":{let o=e.parentElement?.querySelector(`[name="${e.name}"]:checked`);return o!=null?o.value:null}case"checkbox":return e.checked;case"date":return e.valueAsDate?.toISOString();case"multi-select":return Array.from(e.querySelectorAll("option")).reduce((o,n)=>{return o[n.value]=n.selected,o},{});default:return e.value}},{ResizeObserver:mo}=globalThis,oe=mo!=null?new mo((e)=>{for(let o of e){let n=o.target;ve(n,"resize")}}):{observe(){},unobserve(){}},Ke=(e,o,n=!0)=>{if(e!=null&&o!=null)if(typeof o==="string")e.textContent=o;else if(Array.isArray(o))o.forEach((r)=>{e.append(r instanceof Node&&n?Q(r):r)});else if(o instanceof Node)e.append(n?Q(o):o);else throw Error("expect text content or document node")};var pe=(e,o=250)=>{let n;return(...r)=>{if(n!==void 0)clearTimeout(n);n=setTimeout(()=>{e(...r)},o)}},ne=(e,o=250)=>{let n,r=Date.now()-o,t=!1;return(...i)=>{if(clearTimeout(n),n=setTimeout(()=>{e(...i),r=Date.now()},o),!t&&Date.now()-r>=o){t=!0;try{e(...i),r=Date.now()}finally{t=!1}}}};var Bo=(e)=>{try{return JSON.stringify(e)}catch(o){return"{has circular references}"}},Re=(...e)=>Error(e.map(Bo).join(" "));var _o=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),No=0,en=()=>(parseInt("10000",36)+ ++No).toString(36).slice(-5),on=()=>_o()+en(),Ve=Symbol("delete"),ho=Symbol("new-object"),Ie=Symbol("automatic-index");function po(e){if(e==="")return[];if(Array.isArray(e))return e;else{let o=[];while(e.length>0){let n=e.search(/\[[^\]]+\]/);if(n===-1){o.push(e.split("."));break}else{let r=e.slice(0,n);if(e=e.slice(n),r!=="")o.push(r.split("."));if(n=e.indexOf("]")+1,o.push(e.slice(1,n-1)),e.slice(n,n+1)===".")n+=1;e=e.slice(n)}}return o}}var z=new WeakMap;function wo(e,o){if(z.get(e)===void 0)z.set(e,{});if(z.get(e)[o]===void 0)z.get(e)[o]={};let n=z.get(e)[o];if(o==="_auto_")e.forEach((r,t)=>{if(r[Ie]===void 0)r[Ie]=on();n[r[Ie]+""]=t});else e.forEach((r,t)=>{n[Z(r,o)+""]=t});return n}function nn(e,o){if(z.get(e)===void 0||z.get(e)[o]===void 0)return wo(e,o);else return z.get(e)[o]}function rn(e,o,n){n=n+"";let r=nn(e,o)[n];if(r===void 0||Z(e[r],o)+""!==n)r=wo(e,o)[n];return r}function tn(e,o,n){if(e[o]===void 0&&n!==void 0)e[o]=n;return e[o]}function Co(e,o,n,r){let t=o!==""?rn(e,o,n):n;if(r===Ve)return e.splice(t,1),z.delete(e),Symbol("deleted");else if(r===ho){if(o===""&&e[t]===void 0)e[t]={}}else if(r!==void 0)if(t!==void 0)e[t]=r;else if(o!==""&&Z(r,o)+""===n+"")e.push(r),t=e.length-1;else throw Error(`byIdPath insert failed at [${o}=${n}]`);return e[t]}function ao(e){if(!Array.isArray(e))throw Re("setByPath failed: expected array, found",e)}function yo(e){if(e==null||!(e instanceof Object))throw Re("setByPath failed: expected Object, found",e)}function Z(e,o){let n=po(o),r=e,t,i,m,s;for(t=0,i=n.length;r!==void 0&&t<i;t++){let c=n[t];if(Array.isArray(c))for(m=0,s=c.length;r!==void 0&&m<s;m++){let f=c[m];r=r[f]}else if(r.length===0){if(r=r[Number(c.slice(1))],c[0]!=="=")return}else if(c.includes("=")){let[f,...u]=c.split("=");r=Co(r,f,u.join("="))}else m=parseInt(c,10),r=r[m]}return r}function Eo(e,o,n){let r=e;if(o==="")throw Error("setByPath cannot be used to set the root object");let t=po(o);while(r!=null&&t.length>0){let i=t.shift();if(typeof i==="string"){let m=i.indexOf("=");if(m>-1){if(m===0)yo(r);else ao(r);let s=i.slice(0,m),c=i.slice(m+1);if(r=Co(r,s,c,t.length>0?ho:n),t.length===0)return!0}else{ao(r);let s=parseInt(i,10);if(t.length>0)r=r[s];else{if(n!==Ve){if(r[s]===n)return!1;r[s]=n}else r.splice(s,1);return!0}}}else if(Array.isArray(i)&&i.length>0){yo(r);while(i.length>0){let m=i.shift();if(i.length>0||t.length>0)r=tn(r,m,i.length>0?{}:[]);else{if(n!==Ve){if(r[m]===n)return!1;r[m]=n}else{if(!Object.prototype.hasOwnProperty.call(r,m))return!1;delete r[m]}return!0}}}else throw Error(`setByPath failed, bad path ${o}`)}throw Error(`setByPath(${e}, ${o}, ${n}) failed`)}var re={value:{toDOM:lo,fromDOM(e){return uo(e)}},text:{toDOM(e,o){e.textContent=o}},enabled:{toDOM(e,o){e.disabled=!o}},disabled:{toDOM(e,o){e.disabled=Boolean(o)}},list:{toDOM(e,o,n){te(e,o,n).update(o)}}};function x(e){return e.replace(/[A-Z]/g,(o)=>{return`-${o.toLocaleLowerCase()}`})}function bo(e){return e.replace(/-([a-z])/g,(o,n)=>{return n.toLocaleUpperCase()})}var sn=180/Math.PI,cn=Math.PI/180;function M(e,o,n){return n<e?NaN:o<e?e:o>n?n:o}function D(e,o,n,r=!0){if(r)n=M(0,n,1);return n*(o-e)+e}var xo={RADIANS_TO_DEGREES:sn,DEGREES_TO_RADIANS:cn,clamp:M,lerp:D};function we(e,o=document.body){let n=getComputedStyle(o);if(e.endsWith(")")&&e.startsWith("var("))e=e.slice(4,-1);return n.getPropertyValue(e).trim()}var mn=(e,o,n)=>{return(0.299*e+0.587*o+0.114*n)/255},A=(e)=>("00"+Math.round(Number(e)).toString(16)).slice(-2);class Mo{h;s;l;constructor(e,o,n){e/=255,o/=255,n/=255;let r=Math.max(e,o,n),t=r-Math.min(e,o,n),i=t!==0?r===e?(o-n)/t:r===o?2+(n-e)/t:4+(e-o)/t:0;this.h=60*i<0?60*i+360:60*i,this.s=t!==0?r<=0.5?t/(2*r-t):t/(2-(2*r-t)):0,this.l=(2*r-t)/2}}var P=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class l{r;g;b;a;static fromVar(e,o=document.body){return l.fromCss(we(e,o))}static fromCss(e){let o=e;if(P instanceof HTMLSpanElement)P.style.color="black",P.style.color=e,document.body.appendChild(P),o=getComputedStyle(P).color,P.remove();let[n,r,t,i]=o.match(/[\d.]+/g)||["0","0","0","0"],m=o.startsWith("color(srgb")?255:1;return new l(Number(n)*m,Number(r)*m,Number(t)*m,i==null?1:Number(i))}static fromHsl(e,o,n,r=1){let t,i,m;if(o===0)t=i=m=n;else{let c=(C,L,p)=>{if(p<0)p+=1;if(p>1)p-=1;if(p<0.16666666666666666)return C+(L-C)*6*p;if(p<0.5)return L;if(p<0.6666666666666666)return C+(L-C)*(0.6666666666666666-p)*6;return C},f=n<0.5?n*(1+o):n+o-n*o,u=2*n-f,y=(e%360+360)%360/360;t=c(u,f,y+0.3333333333333333),i=c(u,f,y),m=c(u,f,y-0.3333333333333333)}let s=new l(t*255,i*255,m*255,r);return s.hslCached={h:(e%360+360)%360,s:o,l:n},s}static black=new l(0,0,0);static white=new l(255,255,255);constructor(e,o,n,r=1){this.r=M(0,e,255),this.g=M(0,o,255),this.b=M(0,n,255),this.a=M(0,r,1)}get inverse(){return new l(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:e,s:o,l:n}=this._hsl;return l.fromHsl(e,o,1-n,this.a)}get opaque(){return this.a===1?this:new l(this.r,this.g,this.b,1)}contrasting(e=1){return this.opaque.blend(this.brightness>0.5?l.black:l.white,e)}get rgb(){let{r:e,g:o,b:n}=this;return`rgb(${e.toFixed(0)},${o.toFixed(0)},${n.toFixed(0)})`}get rgba(){let{r:e,g:o,b:n,a:r}=this;return`rgba(${e.toFixed(0)},${o.toFixed(0)},${n.toFixed(0)},${r.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new Mo(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:e,s:o,l:n}=this._hsl;return`hsl(${e.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(n*100).toFixed(0)}%)`}get hsla(){let{h:e,s:o,l:n}=this._hsl;return`hsl(${e.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(n*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let e=this.brightness*255;return new l(e,e,e)}get brightness(){return mn(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+A(this.r)+A(this.g)+A(this.b):"#"+A(this.r)+A(this.g)+A(this.b)+A(Math.floor(255*this.a))}brighten(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,r+e*(1-r),1);return l.fromHsl(o,n,t,this.a)}darken(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,r*(1-e),1);return l.fromHsl(o,n,t,this.a)}saturate(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,n+e*(1-n),1);return l.fromHsl(o,t,r,this.a)}desaturate(e){let{h:o,s:n,l:r}=this._hsl,t=M(0,n*(1-e),1);return l.fromHsl(o,t,r,this.a)}rotate(e){let{h:o,s:n,l:r}=this._hsl,t=(o+360+e)%360;return l.fromHsl(t,n,r,this.a)}opacity(e){let{h:o,s:n,l:r}=this._hsl;return l.fromHsl(o,n,r,e)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(e,o){return new l(D(this.r,e.r,o),D(this.g,e.g,o),D(this.b,e.b,o),D(this.a,e.a,o))}static blendHue(e,o,n){let r=(o-e+720)%360;if(r<180)return e+n*r;else return e-(360-r)*n}mix(e,o){let n=this._hsl,r=e._hsl;return l.fromHsl(n.s===0?r.h:r.s===0?n.h:l.blendHue(n.h,r.h,o),D(n.s,r.s,o),D(n.l,r.l,o),D(this.a,e.a,o))}colorMix(e,o){return l.fromCss(`color-mix(in hsl, ${this.html}, ${e.html} ${(o*100).toFixed(0)}%)`)}}function To(e,o){let n=d.style(O(o));n.id=e,document.head.append(n)}var fn=["animation-iteration-count","flex","flex-base","flex-grow","flex-shrink","opacity","order","tab-size","widows","z-index","zoom"],Pe=(e,o)=>{if(typeof o==="number"&&!fn.includes(e))o=`${o}px`;if(e.startsWith("_"))if(e.startsWith("__"))e="--"+e.substring(2),o=`var(${e}-default, ${o})`;else e="--"+e.substring(1);return{prop:e,value:String(o)}},ln=(e,o,n)=>{if(n===void 0)return"";if(n instanceof l)n=n.html;let r=Pe(o,n);return`${e} ${r.prop}: ${r.value};`},Lo=(e,o,n="")=>{let r=x(e);if(typeof o==="object"&&!(o instanceof l)){let t=Object.keys(o).map((i)=>Lo(i,o[i],`${n} `)).join(`
2
2
  `);return`${n} ${e} {
3
3
  ${t}
4
- ${n} }`}else return fn(n,r,o)},O=(e,o="")=>{return Object.keys(e).map((r)=>{let t=e[r];if(typeof t==="string"){if(r==="@import")return`@import url('${t}');`;throw Error("top-level string value only allowed for `@import`")}let i=Object.keys(t).map((m)=>Lo(m,t[m])).join(`
4
+ ${n} }`}else return ln(n,r,o)},O=(e,o="")=>{return Object.keys(e).map((r)=>{let t=e[r];if(typeof t==="string"){if(r==="@import")return`@import url('${t}');`;throw Error("top-level string value only allowed for `@import`")}let i=Object.keys(t).map((m)=>Lo(m,t[m])).join(`
5
5
  `);return`${o}${r} {
6
6
  ${i}
7
7
  }`}).join(`
8
8
 
9
- `)},ko=(e)=>{console.warn("initVars is deprecated. Just use _ and __ prefixes instead.");let o={};for(let n of Object.keys(e)){let r=e[n],t=x(n);o[`--${t}`]=typeof r==="number"&&r!==0?String(r)+"px":r}return o},go=(e)=>{let o={};for(let n of Object.keys(e)){let r=e[n];if(r instanceof f)o[n]=r.inverseLuminance;else if(typeof r==="string"&&r.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))o[n]=f.fromCss(r).inverseLuminance}return o},re=new Proxy({},{get(e,o){if(e[o]===void 0){let n="--"+x(o);e[o]=(r)=>`var(${n}, ${r})`}return e[o]}}),Ce=new Proxy({},{get(e,o){if(o==="default")return re;if(e[o]==null){o=x(o);let[,n,,r,t,i]=o.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",o],m=`--${n}`;if(t!=null){let s=r==null?Number(t)/100:-Number(t)/100;switch(i){case"b":{let c=f.fromVar(m);e[o]=s>0?c.brighten(s).rgba:c.darken(-s).rgba}break;case"s":{let c=f.fromVar(m);e[o]=s>0?c.saturate(s).rgba:c.desaturate(-s).rgba}break;case"h":{let c=f.fromVar(m);e[o]=c.rotate(s*100).rgba}break;case"o":{let c=f.fromVar(m);e[o]=c.opacity(s).rgba}break;case"":e[o]=`calc(var(${m}) * ${s})`;break;default:throw console.error(i),Error(`Unrecognized method ${i} for css variable ${m}`)}}else e[o]=`var(${m})`}return e[o]}});var So="http://www.w3.org/1998/Math/MathML",Ho="http://www.w3.org/2000/svg";var be={},Xo=(e,o,n)=>{let r=Ie(x(o),n);if(r.prop.startsWith("--"))e.style.setProperty(r.prop,r.value);else e.style[o]=r.value},an=(e)=>{return{toDOM(o,n){Xo(o,e,n)}}},$o=(e,o,n)=>{if(o==="style")if(typeof n==="object")for(let r of Object.keys(n))if(S(n[r]))T(e,n[r],an(r));else Xo(e,r,n[r]);else e.setAttribute("style",n);else if(e[o]!==void 0){let{MathMLElement:r}=globalThis;if(e instanceof SVGElement||r!==void 0&&e instanceof r)e.setAttribute(o,n);else e[o]=n}else{let r=x(o);if(r==="class")n.split(" ").forEach((t)=>{e.classList.add(t)});else if(e[r]!==void 0)e[r]=n;else if(typeof n==="boolean")n?e.setAttribute(r,""):e.removeAttribute(r);else e.setAttribute(r,n)}},dn=(e)=>{return{toDOM(o,n){$o(o,e,n)}}},un=(e,o,n)=>{if(o==="apply")n(e);else if(o.match(/^on[A-Z]/)!=null){let r=o.substring(2).toLowerCase();v(e,r,n)}else if(o==="bind")if((typeof n.binding==="string"?oe[n.binding]:n.binding)!==void 0&&n.value!==void 0)T(e,n.value,n.binding instanceof Function?{toDOM:n.binding}:n.binding);else throw Error("bad binding");else if(o.match(/^bind[A-Z]/)!=null){let r=o.substring(4,5).toLowerCase()+o.substring(5),t=oe[r];if(t!==void 0)T(e,n,t);else throw Error(`${o} is not allowed, bindings.${r} is not defined`)}else if(S(n))T(e,n,dn(o));else $o(e,o,n)},Pe=(e,...o)=>{if(be[e]===void 0){let[t,i]=e.split("|");if(i===void 0)be[e]=globalThis.document.createElement(t);else be[e]=globalThis.document.createElementNS(i,t)}let n=be[e].cloneNode(),r={};for(let t of o)if(t instanceof Element||t instanceof DocumentFragment||typeof t==="string"||typeof t==="number")if(n instanceof HTMLTemplateElement)n.content.append(t);else n.append(t);else if(S(t))n.append(d.span({bindText:t}));else Object.assign(r,t);for(let t of Object.keys(r)){let i=r[t];un(n,t,i)}return n},Be=(...e)=>{let o=globalThis.document.createDocumentFragment();for(let n of e)o.append(n);return o},d=new Proxy({fragment:Be},{get(e,o){if(o=o.replace(/[A-Z]/g,(n)=>`-${n.toLocaleLowerCase()}`),e[o]===void 0)e[o]=(...n)=>Pe(o,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}}),Ee=new Proxy({fragment:Be},{get(e,o){if(e[o]===void 0)e[o]=(...n)=>Pe(`${o}|${Ho}`,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}}),xe=new Proxy({fragment:Be},{get(e,o){if(e[o]===void 0)e[o]=(...n)=>Pe(`${o}|${So}`,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}});var yn=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],hn=!0,pn=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,wn=(e)=>pn.test(e),U=(e="",o="")=>{if(e==="")return o;else if(o.match(/^\d+$/)!==null||o.includes("="))return`${e}[${o}]`;else return`${e}.${o}`},Fo=Symbol("boxed-scalar"),Cn={[Fo]:!0};function _e(e,o){if(e!==null&&(typeof e==="object"||typeof e==="function"))return e;return new Proxy(Cn,R(o,!0))}var Ne=()=>new Proxy({},R("^",!0)),zo=!1;function K(){if(!zo)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),zo=!0}var Do=(e)=>{return e!=null&&Fo in e},R=(e,o)=>({get(n,r){if(Do(n)){let s=()=>Z(_,e);switch(r){case"path":return e;case"value":return s();case"valueOf":case"toJSON":return()=>s();case Symbol.toPrimitive:return(c)=>{let l=s();if(c==="number")return Number(l);if(c==="string")return String(l);return l};case"toString":return()=>String(s());case"observe":return(c)=>{let l=G(e,c);return()=>J(l)};case"on":return(c,l)=>he()(c,l,s());case"bind":return(c,l,a)=>{ye()(c,e,l,a)};case"binding":return(c)=>({bind:{value:e,binding:c}});case"listBinding":return(c=({span:a})=>a({bindText:"^"}),l={})=>[{bindList:{value:e,...l}},d.template(c(d,Ne()))];case Y:case"tosiValue":return K(),s();case b:case"tosiPath":return K(),e;case Ye:case"tosiObserve":return K(),(c)=>{let l=G(e,c);return()=>J(l)};case Je:case"tosiOn":return K(),(c,l)=>he()(c,l,s());case We:case"tosiBind":return K(),(c,l,a)=>{ye()(c,e,l,a)};case"tosiBinding":return K(),(c)=>({bind:{value:e,binding:c}});case"tosiListBinding":return K(),(c=({span:a})=>a({bindText:"^"}),l={})=>[{bindList:{value:e,...l}},d.template(c(d,Ne()))]}if(typeof r==="string"&&/^\d+$/.test(r)){let c=s();if(typeof c==="string")return c[parseInt(r,10)]}if(r==="length"){let c=s();if(typeof c==="string")return c.length}return}switch(r){case b:case"tosiPath":return e;case Y:case"tosiValue":return n.valueOf?n.valueOf():n;case Ye:case"tosiObserve":return(s)=>{let c=G(e,s);return()=>J(c)};case Je:case"tosiOn":return(s,c)=>he()(s,c,C(n));case We:case"tosiBind":return(s,c,l)=>{ye()(s,e,c,l)};case"tosiBinding":return(s)=>({bind:{value:e,binding:s}});case"tosiListBinding":return(s=({span:l})=>l({bindText:"^"}),c={})=>[{bindList:{value:e,...c}},d.template(s(d,Ne()))]}if(typeof r==="symbol")return n[r];let t=Object.getOwnPropertyDescriptor(n,r);if(t&&!t.configurable&&!t.writable&&"value"in t)return t.value;let i=r,m=i.match(/^([^.[]+)\.(.+)$/)??i.match(/^([^\]]+)(\[.+)/)??i.match(/^(\[[^\]]+\])\.(.+)$/)??i.match(/^(\[[^\]]+\])\[(.+)$/);if(m!==null){let[,s,c]=m,l=U(e,s),a=Z(n,s);return a!==null&&typeof a==="object"?new Proxy(a,R(l,o))[c]:a}if(i.startsWith("[")&&i.endsWith("]"))i=i.substring(1,i.length-1);if(!Array.isArray(n)&&n[i]!==void 0||Array.isArray(n)&&i.includes("=")){let s;if(i.includes("=")){let[c,l]=i.split("=");s=n.find((a)=>`${Z(a,c)}`===l)}else s=n[i];if(s instanceof Object){let c=U(e,i);return new Proxy(s instanceof Function?s.bind(n):s,R(c,o))}else return o?_e(s,U(e,i)):s}else if(Array.isArray(n)){let s=n[i];return typeof s==="function"?(...c)=>{let l=c.map((y)=>C(y)),a=s.apply(n,l);if(yn.includes(i))Q(e);return a}:typeof s==="object"?new Proxy(s,R(U(e,i),o)):o?_e(s,U(e,i)):s}else return o?_e(n[i],U(e,i)):n[i]},set(n,r,t){t=C(t);let m=r===Y||r==="value"&&Do(n)?e:U(e,r);if(hn&&!wn(m))throw Error(`setting invalid path ${m}`);if(C(u[m])!==t&&bo(_,m,t))Q(m);return!0}}),Me=(e,o)=>{let n=typeof o==="function"?o:u[o];if(typeof n!=="function")throw Error(`observe expects a function or path to a function, ${o} is neither`);return G(e,n)},u=new Proxy(_,R("",!1));so(u);var V=new Proxy(_,R("",!0));var bn=16,En=100;function Yo(e,o){let n=Array.from(e.querySelectorAll(F));if(e.matches(F))n.unshift(e);for(let r of n){let t=X.get(r);for(let i of t){if(i.path.startsWith("^"))i.path=`${o}${i.path.substring(1)}`;if(i.binding.toDOM!=null)i.binding.toDOM(r,u[i.path])}}}class Wo{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(e,o,n={}){if(this.boundElement=e,this.itemToElement=new WeakMap,e.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(e.children[0]instanceof HTMLTemplateElement){let r=e.children[0];if(r.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=q(r.content.children[0])}else this.template=e.children[0],this.template.remove();if(this.options=n,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),n.virtual!=null)if(N.observe(this.boundElement),this._update=ee(()=>{this.update(this.array,!0)},bn),this.boundElement.addEventListener("resize",this._update),n.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}visibleSlice(){let{virtual:e,hiddenProp:o,visibleProp:n}=this.options,r=this.array;if(o!==void 0)r=r.filter((c)=>c[o]!==!0);if(n!==void 0)r=r.filter((c)=>c[n]===!0);if(this.options.filter&&this.needle!==void 0)r=this.options.filter(r,this.needle);let t=0,i=r.length-1,m=0,s=0;if(e!=null&&this.boundElement instanceof HTMLElement){let c=this.boundElement.offsetWidth,l=e.scrollContainer==="window",a,y;if(l){a=window.innerHeight;let I=this.boundElement.getBoundingClientRect();y=Math.max(0,-I.top)}else a=this.boundElement.offsetHeight,y=this.boundElement.scrollTop;if(e.visibleColumns==null)e.visibleColumns=e.width!=null?Math.max(1,Math.floor(c/e.width)):1;let w=Math.ceil(a/e.height)+(e.rowChunkSize||1),L=Math.ceil(r.length/e.visibleColumns),p=e.visibleColumns*w,k=Math.floor(y/e.height);if(k>L-w+1)k=Math.max(0,L-w+1);if(e.rowChunkSize)k-=k%e.rowChunkSize;t=k*e.visibleColumns,i=t+p-1,m=k*e.height,s=Math.max((L-w)*e.height-m,0)}return{items:r,firstItem:t,lastItem:i,topBuffer:m,bottomBuffer:s}}needle;filter=ee((e)=>{if(this.needle!==e)this.needle=e,this.update(this.array)},En);update(e,o){if(e==null)e=[];this.array=e;let{hiddenProp:n,visibleProp:r}=this.options,t=S(e),i=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",i.items.length===0);let m=this._previousSlice,{firstItem:s,lastItem:c,topBuffer:l,bottomBuffer:a}=i;if(n===void 0&&r===void 0&&o===!0&&m!=null&&s===m.firstItem&&c===m.lastItem)return;this._previousSlice=i;let y=0,w=0,L=0;for(let h of Array.from(this.boundElement.children)){if(h===this.listTop||h===this.listBottom)continue;let g=h[fe];if(g==null)h.remove();else{let E=i.items.indexOf(g);if(E<s||E>c)h.remove(),this.itemToElement.delete(g),y++}}this.listTop.style.height=String(l)+"px",this.listBottom.style.height=String(a)+"px";let p=[],{idPath:k}=this.options;for(let h=s;h<=c;h++){let g=i.items[h];if(g===void 0)continue;let E=this.itemToElement.get(C(g));if(E==null){if(L++,E=q(this.template),typeof g==="object")this.itemToElement.set(C(g),E),E[fe]=C(g);if(this.boundElement.insertBefore(E,this.listBottom),k!=null){let Xe=g[k],vo=`${t}[${k}=${Xe}]`;Yo(E,vo)}else{let Xe=`${t}[${h}]`;Yo(E,Xe)}}p.push(E)}let I=null;for(let h of p){if(h.previousElementSibling!==I)if(w++,I?.nextElementSibling!=null)this.boundElement.insertBefore(h,I.nextElementSibling);else this.boundElement.insertBefore(h,this.listBottom);I=h}if(W.perf)console.log(t,"updated",{removed:y,created:L,moved:w})}}var ne=(e,o,n)=>{let r=e[B];if(o&&r===void 0)r=new Wo(e,o,n),e[B]=r;return r},Te=(e)=>{let o;while(!(o=e[fe])&&e&&e.parentElement)e=e.parentElement;return o?{element:e,item:o}:void 0},Le=(e)=>{let o=Te(e);return o?o.item:void 0},Jo=(e)=>{let o=Te(e);if(!o)return console.error("deleteListItem failed, element is not part of a list instance",e),!1;let n=ne(o.element.parentElement);if(!n.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",e.parentElement,n),!1;let r=n.array.indexOf(o.item);if(r>-1)return n.array.splice(r,1),!0;return!1};var{document:te,MutationObserver:jo}=globalThis,ke=(e,o)=>{let n=X.get(e);if(n==null)return;for(let r of n){let{binding:t,options:i}=r,{path:m}=r,{toDOM:s}=t;if(s!=null){if(m.startsWith("^")){let c=Le(e);if(c!=null&&c[b]!=null)m=r.path=`${c[b]}${m.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${m}`,e,"is not part of a list"),Error(`Cannot resolve relative binding ${m}`)}if(o==null||m.startsWith(o))s(e,ue()[m],i)}}};if(jo!=null)new jo((o)=>{o.forEach((n)=>{Array.from(n.addedNodes).forEach((r)=>{if(r instanceof Element)Array.from(r.querySelectorAll(F)).forEach((t)=>ke(t))})})}).observe(te.body,{subtree:!0,childList:!0});G(()=>!0,(e)=>{let o=Array.from(te.querySelectorAll(F));for(let n of o)ke(n,e)});var qo=(e)=>{let o=e.target?.closest(F);while(o!=null){let n=X.get(o);for(let r of n){let{binding:t,path:i}=r,{fromDOM:m}=t;if(m!=null){let s;try{s=m(o,r.options)}catch(c){throw console.error("Cannot get value from",o,"via",r),Error("Cannot obtain value fromDOM")}if(s!=null){let c=ue(),l=c[i];if(l==null)c[i]=s;else{let a=l[b]!=null?l[Y]:l,y=s[b]!=null?s[Y]:s;if(a!==y)c[i]=y}}}}o=o.parentElement.closest(F)}};if(globalThis.document!=null)te.body.addEventListener("change",qo,!0),te.body.addEventListener("input",qo,!0);function T(e,o,n,r){if(e instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let t;if(typeof o==="object"&&o[b]===void 0&&r===void 0){let{value:s}=o;t=typeof s==="string"?s:s[b],r=o,delete r.value}else t=typeof o==="string"?o:o[b];if(t==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:i}=n;e.classList?.add(ze);let m=X.get(e);if(m==null)m=[],X.set(e,m);if(m.push({path:t,binding:n,options:r}),i!=null&&!t.startsWith("^"))Q(t);if(r?.filter&&r?.needle)T(e,r.needle,{toDOM(s,c){console.log({needle:c}),s[B]?.filter(c)}});return e}var Qo=new Set,xn=(e)=>{let o=e?.target?.closest(Fe),n=!1,r=new Proxy(e,{get(i,m){if(m==="stopPropagation")return()=>{e.stopPropagation(),n=!0};else{let s=i[m];return typeof s==="function"?s.bind(i):s}}}),t=new Set;while(!n&&o!=null){let m=j.get(o)[e.type]||t;for(let s of m){if(typeof s==="function")s(r);else{let c=ue()[s];if(typeof c==="function")c(r);else throw Error(`no event handler found at path ${s}`)}if(n)continue}o=o.parentElement!=null?o.parentElement.closest(Fe):null}};function v(e,o,n){let r=j.get(e);if(e.classList.add(De),r==null)r={},j.set(e,r);if(!r[o])r[o]=new Set;if(r[o].add(n),!Qo.has(o))Qo.add(o),te.body.addEventListener(o,xn,!0);return()=>{r[o].delete(n)}}co(T,v);var Mn=0;function eo(){return`custom-elt${(Mn++).toString(36)}`}var Go=0,ie={};function Tn(e,o){let n=ie[e],r=O(o).replace(/:host\b/g,e);ie[e]=n?n+`
10
- `+r:r}function Ln(e){if(ie[e])document.head.append(d.style({id:e+"-component"},ie[e]));delete ie[e]}class D extends HTMLElement{static elements=d;static _elementCreator;instanceId;styleNode;static styleSpec;static styleNode;content=d.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}static StyleNode(e){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),d.style(O(e))}static elementCreator(e={}){let o=this;if(o._elementCreator==null){let{tag:n,styleSpec:r}=e,t=e!=null?n:null;if(t==null)if(typeof o.name==="string"&&o.name!==""){if(t=x(o.name),t.startsWith("-"))t=t.slice(1)}else t=eo();if(customElements.get(t)!=null)console.warn(`${t} is already defined`);if(t.match(/\w+(-\w+)+/)==null)console.warn(`${t} is not a legal tag for a custom-element`),t=eo();while(customElements.get(t)!==void 0)t=eo();if(o._tagName=t,r!==void 0)Tn(t,r);window.customElements.define(t,this,e),o._elementCreator=d[t]}return o._elementCreator}initAttributes(...e){let o={},n={};new MutationObserver((t)=>{let i=!1;if(t.forEach((m)=>{i=!!(m.attributeName&&e.includes(Eo(m.attributeName)))}),i&&this.queueRender!==void 0)this.queueRender(!1)}).observe(this,{attributes:!0}),e.forEach((t)=>{o[t]=H(this[t]);let i=x(t);Object.defineProperty(this,t,{enumerable:!1,get(){if(typeof o[t]==="boolean")return this.hasAttribute(i);else if(this.hasAttribute(i))return typeof o[t]==="number"?parseFloat(this.getAttribute(i)):this.getAttribute(i);else if(n[t]!==void 0)return n[t];else return o[t]},set(m){if(typeof o[t]==="boolean"){if(m!==this[t]){if(m)this.setAttribute(i,"");else this.removeAttribute(i);this.queueRender()}}else if(typeof o[t]==="number"){if(m!==parseFloat(this[t]))this.setAttribute(i,m),this.queueRender()}else if(typeof m==="object"||`${m}`!==`${this[t]}`){if(m===null||m===void 0||typeof m==="object")this.removeAttribute(i);else this.setAttribute(i,m);this.queueRender(),n[t]=m}}})})}initValue(){let e=Object.getOwnPropertyDescriptor(this,"value");if(e===void 0||e.get!==void 0||e.set!==void 0)return;let o=this.hasAttribute("value")?this.getAttribute("value"):H(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return o},set(n){if(o!==n)o=n,this.queueRender(!0)}})}_parts;get parts(){let e=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(o,n){if(o[n]===void 0){let r=e.querySelector(`[part="${n}"]`);if(r==null)r=e.querySelector(n);if(r==null)throw Error(`elementRef "${n}" does not exist!`);r.removeAttribute("data-ref"),o[n]=r}return o[n]}});return this._parts}constructor(){super();Go+=1,this.initAttributes("hidden"),this.instanceId=`${this.tagName.toLocaleLowerCase()}-${Go}`,this._value=H(this.defaultValue)}connectedCallback(){if(Ln(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.onResize!==void 0){if(N.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");this.queueRender()}disconnectedCallback(){N.unobserve(this)}_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)ve(this,"change");this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let e=typeof this.content!=="function",o=typeof this.content==="function"?this.content(d):this.content,{styleSpec:n}=this.constructor,{styleNode:r}=this.constructor;if(n)r=this.constructor.styleNode=d.style(O(n)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),r=this.styleNode;if(r){let t=this.attachShadow({mode:"open"});t.appendChild(r.cloneNode(!0)),Ue(t,o,e)}else if(o!==null){let t=Array.from(this.childNodes);Ue(this,o,e),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let i=Array.from(this.querySelectorAll("slot"));if(i.length>0)i.forEach(oo.replaceSlot);if(t.length>0){let m={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((s)=>{m[s.name]=s}),t.forEach((s)=>{let c=m[""],l=s instanceof Element?m[s.slot]:c;(l!==void 0?l:c).append(s)})}}this._hydrated=!0}}render(){}}class oo extends D{name="";content=null;static replaceSlot(e){let o=document.createElement("xin-slot");if(e.name!=="")o.setAttribute("name",e.name);e.replaceWith(o)}constructor(){super();this.initAttributes("name")}}var Qr=oo.elementCreator({tag:"xin-slot"});var Zo=(e=()=>!0)=>{let o=localStorage.getItem("xin-state");if(o!=null){let r=JSON.parse(o);for(let t of Object.keys(r).filter(e))if(u[t]!==void 0)Object.assign(u[t],r[t]);else u[t]=r[t]}let n=pe(()=>{let r={},t=C(u);for(let i of Object.keys(t).filter(e))r[i]=t[i];localStorage.setItem("xin-state",JSON.stringify(r)),console.log("xin state saved to localStorage")},500);Me(e,n)};var ge="1.1.0";function se(e){return Object.assign(V,e),V}function ce(e){return console.warn("boxedProxy is deprecated, please use tosi() instead"),se(e)}function Se(e,o=!1){if(o)return console.warn("xinProxy(..., true) is deprecated; use tosi(...) instead"),ce(e);return Object.keys(e).forEach((n)=>{u[n]=e[n]}),u}var kn={};async function me(e,o){let{type:n,styleSpec:r}=await o(e,{Color:f,Component:D,elements:d,svgElements:Ee,mathML:xe,varDefault:re,vars:Ce,xin:u,boxed:V,xinProxy:Se,boxedProxy:ce,tosi:se,makeComponent:me,bind:T,on:v,version:ge}),t={type:n,creator:n.elementCreator({tag:e,styleSpec:r})};return kn[e]=t,t}var no={},gn=(e)=>import(e);class le extends D{tag="anon-elt";src="";property="default";loaded;blueprintLoaded=(e)=>{};async packaged(){let{tag:e,src:o,property:n}=this,r=`${e}.${n}:${o}`;if(!this.loaded){if(no[r]===void 0)no[r]=gn(o).then((t)=>{let i=t[n];return me(e,i)});else console.log(`using cached ${e} with signature ${r}`);this.loaded=await no[r],this.blueprintLoaded(this.loaded)}return this.loaded}constructor(){super();this.initAttributes("tag","src","property")}}var Ao=le.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class He extends D{allLoaded=()=>{};constructor(){super()}async load(){let o=Array.from(this.querySelectorAll(le.tagName)).filter((n)=>n.src).map((n)=>n.packaged());await Promise.all(o),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var Oo=He.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
9
+ `)},ko=(e)=>{console.warn("initVars is deprecated. Just use _ and __ prefixes instead.");let o={};for(let n of Object.keys(e)){let r=e[n],t=x(n);o[`--${t}`]=typeof r==="number"&&r!==0?String(r)+"px":r}return o},So=(e)=>{let o={};for(let n of Object.keys(e)){let r=e[n];if(r instanceof l)o[n]=r.inverseLuminance;else if(typeof r==="string"&&r.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))o[n]=l.fromCss(r).inverseLuminance}return o},ie=new Proxy({},{get(e,o){if(e[o]===void 0){let n="--"+x(o);e[o]=(r)=>`var(${n}, ${r})`}return e[o]}}),Ce=new Proxy({},{get(e,o){if(o==="default")return ie;if(e[o]==null){o=x(o);let[,n,,r,t,i]=o.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",o],m=`--${n}`;if(t!=null){let s=r==null?Number(t)/100:-Number(t)/100;switch(i){case"b":{let c=l.fromVar(m);e[o]=s>0?c.brighten(s).rgba:c.darken(-s).rgba}break;case"s":{let c=l.fromVar(m);e[o]=s>0?c.saturate(s).rgba:c.desaturate(-s).rgba}break;case"h":{let c=l.fromVar(m);e[o]=c.rotate(s*100).rgba}break;case"o":{let c=l.fromVar(m);e[o]=c.opacity(s).rgba}break;case"":e[o]=`calc(var(${m}) * ${s})`;break;default:throw console.error(i),Error(`Unrecognized method ${i} for css variable ${m}`)}}else e[o]=`var(${m})`}return e[o]}});var Ho="http://www.w3.org/1998/Math/MathML",go="http://www.w3.org/2000/svg";var Ee={},Xo=(e,o,n)=>{let r=Pe(x(o),n);if(r.prop.startsWith("--"))e.style.setProperty(r.prop,r.value);else e.style[o]=r.value},un=(e)=>{return{toDOM(o,n){Xo(o,e,n)}}},$o=(e,o,n)=>{if(o==="style")if(typeof n==="object")for(let r of Object.keys(n))if(H(n[r]))T(e,n[r],un(r));else Xo(e,r,n[r]);else e.setAttribute("style",n);else if(e[o]!==void 0){let{MathMLElement:r}=globalThis;if(e instanceof SVGElement||r!==void 0&&e instanceof r)e.setAttribute(o,n);else e[o]=n}else{let r=x(o);if(r==="class")n.split(" ").forEach((t)=>{e.classList.add(t)});else if(e[r]!==void 0)e[r]=n;else if(typeof n==="boolean")n?e.setAttribute(r,""):e.removeAttribute(r);else e.setAttribute(r,n)}},dn=(e)=>{return{toDOM(o,n){$o(o,e,n)}}},an=(e,o,n)=>{if(o==="apply")n(e);else if(o.match(/^on[A-Z]/)!=null){let r=o.substring(2).toLowerCase();U(e,r,n)}else if(o==="bind")if((typeof n.binding==="string"?re[n.binding]:n.binding)!==void 0&&n.value!==void 0)T(e,n.value,n.binding instanceof Function?{toDOM:n.binding}:n.binding);else throw Error("bad binding");else if(o.match(/^bind[A-Z]/)!=null){let r=o.substring(4,5).toLowerCase()+o.substring(5),t=re[r];if(t!==void 0)T(e,n,t);else throw Error(`${o} is not allowed, bindings.${r} is not defined`)}else if(H(n))T(e,n,dn(o));else $o(e,o,n)},Be=(e,...o)=>{if(Ee[e]===void 0){let[t,i]=e.split("|");if(i===void 0)Ee[e]=globalThis.document.createElement(t);else Ee[e]=globalThis.document.createElementNS(i,t)}let n=Ee[e].cloneNode(),r={};for(let t of o)if(t instanceof Element||t instanceof DocumentFragment||typeof t==="string"||typeof t==="number")if(n instanceof HTMLTemplateElement)n.content.append(t);else n.append(t);else if(H(t))n.append(d.span({bindText:t}));else Object.assign(r,t);for(let t of Object.keys(r)){let i=r[t];an(n,t,i)}return n},_e=(...e)=>{let o=globalThis.document.createDocumentFragment();for(let n of e)o.append(n);return o},d=new Proxy({fragment:_e},{get(e,o){if(o=o.replace(/[A-Z]/g,(n)=>`-${n.toLocaleLowerCase()}`),e[o]===void 0)e[o]=(...n)=>Be(o,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}}),be=new Proxy({fragment:_e},{get(e,o){if(e[o]===void 0)e[o]=(...n)=>Be(`${o}|${go}`,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}}),xe=new Proxy({fragment:_e},{get(e,o){if(e[o]===void 0)e[o]=(...n)=>Be(`${o}|${Ho}`,...n);return e[o]},set(){throw Error("You may not add new properties to elements")}});var yn=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],hn=!0,pn=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,wn=(e)=>pn.test(e),v=(e="",o="")=>{if(e==="")return o;else if(o.match(/^\d+$/)!==null||o.includes("="))return`${e}[${o}]`;else return`${e}.${o}`},Fo=Symbol("boxed-scalar"),Cn={[Fo]:!0};function Ne(e,o){if(e!==null&&(typeof e==="object"||typeof e==="function"))return e;return new Proxy(Cn,R(o,!0))}var Me=()=>new Proxy({},R("^",!0)),zo=!1;function K(){if(!zo)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),zo=!0}var Do=(e)=>{return e!=null&&Fo in e},R=(e,o)=>({get(n,r){if(Do(n)){let s=()=>Z(_,e);switch(r){case"path":return e;case"value":return s();case"valueOf":case"toJSON":return()=>s();case Symbol.toPrimitive:return(c)=>{let f=s();if(c==="number")return Number(f);if(c==="string")return String(f);return f};case"toString":return()=>String(s());case"observe":return(c)=>{let f=j(e,c);return()=>$(f)};case"on":return(c,f)=>ee()(c,f,s());case"bind":return(c,f,u)=>{N()(c,e,f,u)};case"binding":return(c)=>({bind:{value:e,binding:c}});case"listBinding":return(c=({span:u})=>u({bindText:"^"}),f={})=>[{bindList:{value:e,...f}},d.template(c(d,Me()))];case W:case"tosiValue":return K(),s();case E:case"tosiPath":return K(),e;case We:case"tosiObserve":return K(),(c)=>{let f=j(e,c);return()=>$(f)};case je:case"tosiOn":return K(),(c,f)=>ee()(c,f,s());case Je:case"tosiBind":return K(),(c,f,u)=>{N()(c,e,f,u)};case"tosiBinding":return K(),(c)=>({bind:{value:e,binding:c}});case"tosiListBinding":return K(),(c=({span:u})=>u({bindText:"^"}),f={})=>[{bindList:{value:e,...f}},d.template(c(d,Me()))]}if(typeof r==="string"&&/^\d+$/.test(r)){let c=s();if(typeof c==="string")return c[parseInt(r,10)]}if(r==="length"){let c=s();if(typeof c==="string")return c.length}return}if(o&&!(r in n))switch(r){case"path":return e;case"value":return n.valueOf?n.valueOf():n;case"valueOf":case"toJSON":return()=>n.valueOf?n.valueOf():n;case"observe":return(s)=>{let c=j(e,s);return()=>$(c)};case"on":return(s,c)=>ee()(s,c,w(n));case"bind":return(s,c,f)=>{N()(s,e,c,f)};case"binding":return(s)=>({bind:{value:e,binding:s}});case"listBinding":return(s=({span:f})=>f({bindText:"^"}),c={})=>[{bindList:{value:e,...c}},d.template(s(d,Me()))]}switch(r){case E:case"tosiPath":return e;case W:case"tosiValue":return n.valueOf?n.valueOf():n;case We:case"tosiObserve":return(s)=>{let c=j(e,s);return()=>$(c)};case je:case"tosiOn":return(s,c)=>ee()(s,c,w(n));case Je:case"tosiBind":return(s,c,f)=>{N()(s,e,c,f)};case"tosiBinding":return(s)=>({bind:{value:e,binding:s}});case"tosiListBinding":return(s=({span:f})=>f({bindText:"^"}),c={})=>[{bindList:{value:e,...c}},d.template(s(d,Me()))]}if(typeof r==="symbol")return n[r];let t=Object.getOwnPropertyDescriptor(n,r);if(t&&!t.configurable&&!t.writable&&"value"in t)return t.value;let i=r,m=i.match(/^([^.[]+)\.(.+)$/)??i.match(/^([^\]]+)(\[.+)/)??i.match(/^(\[[^\]]+\])\.(.+)$/)??i.match(/^(\[[^\]]+\])\[(.+)$/);if(m!==null){let[,s,c]=m,f=v(e,s),u=Z(n,s);return u!==null&&typeof u==="object"?new Proxy(u,R(f,o))[c]:u}if(i.startsWith("[")&&i.endsWith("]"))i=i.substring(1,i.length-1);if(!Array.isArray(n)&&n[i]!==void 0||Array.isArray(n)&&i.includes("=")){let s;if(i.includes("=")){let[c,f]=i.split("=");s=n.find((u)=>`${Z(u,c)}`===f)}else s=n[i];if(s instanceof Object){let c=v(e,i);return new Proxy(s instanceof Function?s.bind(n):s,R(c,o))}else return o?Ne(s,v(e,i)):s}else if(Array.isArray(n)){let s=n[i];return typeof s==="function"?(...c)=>{let f=c.map((y)=>w(y)),u=s.apply(n,f);if(yn.includes(i))G(e);return u}:typeof s==="object"?new Proxy(s,R(v(e,i),o)):o?Ne(s,v(e,i)):s}else return o?Ne(n[i],v(e,i)):n[i]},set(n,r,t){t=w(t);let m=r===W||r==="value"&&Do(n)?e:v(e,r);if(hn&&!wn(m))throw Error(`setting invalid path ${m}`);if(w(a[m])!==t&&Eo(_,m,t))G(m);return!0}}),Te=(e,o)=>{let n=typeof o==="function"?o:a[o];if(typeof n!=="function")throw Error(`observe expects a function or path to a function, ${o} is neither`);return j(e,n)},a=new Proxy(_,R("",!1));so(a);var I=new Proxy(_,R("",!0));var En=16,bn=100;function Yo(e,o){let n=Array.from(e.querySelectorAll(Y));if(e.matches(Y))n.unshift(e);for(let r of n){let t=X.get(r);for(let i of t){if(i.path.startsWith("^"))i.path=`${o}${i.path.substring(1)}`;if(i.binding.toDOM!=null)i.binding.toDOM(r,a[i.path])}}}class Wo{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(e,o,n={}){if(this.boundElement=e,this.itemToElement=new WeakMap,e.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(e.children[0]instanceof HTMLTemplateElement){let r=e.children[0];if(r.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=Q(r.content.children[0])}else this.template=e.children[0],this.template.remove();if(this.options=n,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),n.virtual!=null)if(oe.observe(this.boundElement),this._update=ne(()=>{this.update(this.array,!0)},En),this.boundElement.addEventListener("resize",this._update),n.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}visibleSlice(){let{virtual:e,hiddenProp:o,visibleProp:n}=this.options,r=this.array;if(o!==void 0)r=r.filter((c)=>c[o]!==!0);if(n!==void 0)r=r.filter((c)=>c[n]===!0);if(this.options.filter&&this.needle!==void 0)r=this.options.filter(r,this.needle);let t=0,i=r.length-1,m=0,s=0;if(e!=null&&this.boundElement instanceof HTMLElement){let c=this.boundElement.offsetWidth,f=e.scrollContainer==="window",u,y;if(f){u=window.innerHeight;let V=this.boundElement.getBoundingClientRect();y=Math.max(0,-V.top)}else u=this.boundElement.offsetHeight,y=this.boundElement.scrollTop;if(e.visibleColumns==null)e.visibleColumns=e.width!=null?Math.max(1,Math.floor(c/e.width)):1;let C=Math.ceil(u/e.height)+(e.rowChunkSize||1),L=Math.ceil(r.length/e.visibleColumns),p=e.visibleColumns*C,k=Math.floor(y/e.height);if(k>L-C+1)k=Math.max(0,L-C+1);if(e.rowChunkSize)k-=k%e.rowChunkSize;t=k*e.visibleColumns,i=t+p-1,m=k*e.height,s=Math.max((L-C)*e.height-m,0)}return{items:r,firstItem:t,lastItem:i,topBuffer:m,bottomBuffer:s}}needle;filter=ne((e)=>{if(this.needle!==e)this.needle=e,this.update(this.array)},bn);update(e,o){if(e==null)e=[];this.array=e;let{hiddenProp:n,visibleProp:r}=this.options,t=H(e),i=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",i.items.length===0);let m=this._previousSlice,{firstItem:s,lastItem:c,topBuffer:f,bottomBuffer:u}=i;if(n===void 0&&r===void 0&&o===!0&&m!=null&&s===m.firstItem&&c===m.lastItem)return;this._previousSlice=i;let y=0,C=0,L=0;for(let h of Array.from(this.boundElement.children)){if(h===this.listTop||h===this.listBottom)continue;let S=h[de];if(S==null)h.remove();else{let b=i.items.indexOf(S);if(b<s||b>c)h.remove(),this.itemToElement.delete(S),y++}}this.listTop.style.height=String(f)+"px",this.listBottom.style.height=String(u)+"px";let p=[],{idPath:k}=this.options;for(let h=s;h<=c;h++){let S=i.items[h];if(S===void 0)continue;let b=this.itemToElement.get(w(S));if(b==null){if(L++,b=Q(this.template),typeof S==="object")this.itemToElement.set(w(S),b),b[de]=w(S);if(this.boundElement.insertBefore(b,this.listBottom),k!=null){let $e=S[k],Uo=`${t}[${k}=${$e}]`;Yo(b,Uo)}else{let $e=`${t}[${h}]`;Yo(b,$e)}}p.push(b)}let V=null;for(let h of p){if(h.previousElementSibling!==V)if(C++,V?.nextElementSibling!=null)this.boundElement.insertBefore(h,V.nextElementSibling);else this.boundElement.insertBefore(h,this.listBottom);V=h}if(J.perf)console.log(t,"updated",{removed:y,created:L,moved:C})}}var te=(e,o,n)=>{let r=e[B];if(o&&r===void 0)r=new Wo(e,o,n),e[B]=r;return r},Le=(e)=>{let o;while(!(o=e[de])&&e&&e.parentElement)e=e.parentElement;return o?{element:e,item:o}:void 0},ke=(e)=>{let o=Le(e);return o?o.item:void 0},Jo=(e)=>{let o=Le(e);if(!o)return console.error("deleteListItem failed, element is not part of a list instance",e),!1;let n=te(o.element.parentElement);if(!n.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",e.parentElement,n),!1;let r=n.array.indexOf(o.item);if(r>-1)return n.array.splice(r,1),!0;return!1};var{document:se,MutationObserver:jo}=globalThis,Se=(e,o)=>{let n=X.get(e);if(n==null)return;for(let r of n){let{binding:t,options:i}=r,{path:m}=r,{toDOM:s}=t;if(s!=null){if(m.startsWith("^")){let c=ke(e);if(c!=null&&c[E]!=null)m=r.path=`${c[E]}${m.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${m}`,e,"is not part of a list"),Error(`Cannot resolve relative binding ${m}`)}if(o==null||m.startsWith(o))s(e,he()[m],i)}}};if(jo!=null)new jo((o)=>{o.forEach((n)=>{Array.from(n.addedNodes).forEach((r)=>{if(r instanceof Element)Array.from(r.querySelectorAll(Y)).forEach((t)=>Se(t))})})}).observe(se.body,{subtree:!0,childList:!0});j(()=>!0,(e)=>{let o=Array.from(se.querySelectorAll(Y));for(let n of o)Se(n,e)});var qo=(e)=>{let o=e.target?.closest(Y);while(o!=null){let n=X.get(o);for(let r of n){let{binding:t,path:i}=r,{fromDOM:m}=t;if(m!=null){let s;try{s=m(o,r.options)}catch(c){throw console.error("Cannot get value from",o,"via",r),Error("Cannot obtain value fromDOM")}if(s!=null){let c=he(),f=c[i];if(f==null)c[i]=s;else{let u=f[E]!=null?f[W]:f,y=s[E]!=null?s[W]:s;if(u!==y)c[i]=y}}}}o=o.parentElement.closest(Y)}};if(globalThis.document!=null)se.body.addEventListener("change",qo,!0),se.body.addEventListener("input",qo,!0);function T(e,o,n,r){if(e instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let t;if(typeof o==="object"&&o[E]===void 0&&r===void 0){let{value:s}=o;t=typeof s==="string"?s:s[E],r=o,delete r.value}else t=typeof o==="string"?o:o[E];if(t==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:i}=n;e.classList?.add(De);let m=X.get(e);if(m==null)m=[],X.set(e,m);if(m.push({path:t,binding:n,options:r}),i!=null&&!t.startsWith("^"))G(t);if(r?.filter&&r?.needle)T(e,r.needle,{toDOM(s,c){console.log({needle:c}),s[B]?.filter(c)}});return e}var Qo=new Set,xn=(e)=>{let o=e?.target?.closest(Ye),n=!1,r=new Proxy(e,{get(i,m){if(m==="stopPropagation")return()=>{e.stopPropagation(),n=!0};else{let s=i[m];return typeof s==="function"?s.bind(i):s}}}),t=new Set;while(!n&&o!=null){let m=q.get(o)[e.type]||t;for(let s of m){if(typeof s==="function")s(r);else{let c=he()[s];if(typeof c==="function")c(r);else throw Error(`no event handler found at path ${s}`)}if(n)continue}o=o.parentElement!=null?o.parentElement.closest(Ye):null}};function U(e,o,n){let r=q.get(e);if(e.classList.add(Fe),r==null)r={},q.set(e,r);if(!r[o])r[o]=new Set;if(r[o].add(n),!Qo.has(o))Qo.add(o),se.body.addEventListener(o,xn,!0);return()=>{r[o].delete(n)}}co(T,U);var Mn=0;function eo(){return`custom-elt${(Mn++).toString(36)}`}var Go=0,ce={};function Tn(e,o){let n=ce[e],r=O(o).replace(/:host\b/g,e);ce[e]=n?n+`
10
+ `+r:r}function Ln(e){if(ce[e])document.head.append(d.style({id:e+"-component"},ce[e]));delete ce[e]}class F extends HTMLElement{static elements=d;static _elementCreator;instanceId;styleNode;static styleSpec;static styleNode;content=d.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}static StyleNode(e){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),d.style(O(e))}static elementCreator(e={}){let o=this;if(o._elementCreator==null){let{tag:n,styleSpec:r}=e,t=e!=null?n:null;if(t==null)if(typeof o.name==="string"&&o.name!==""){if(t=x(o.name),t.startsWith("-"))t=t.slice(1)}else t=eo();if(customElements.get(t)!=null)console.warn(`${t} is already defined`);if(t.match(/\w+(-\w+)+/)==null)console.warn(`${t} is not a legal tag for a custom-element`),t=eo();while(customElements.get(t)!==void 0)t=eo();if(o._tagName=t,r!==void 0)Tn(t,r);window.customElements.define(t,this,e),o._elementCreator=d[t]}return o._elementCreator}initAttributes(...e){let o={},n={};new MutationObserver((t)=>{let i=!1;if(t.forEach((m)=>{i=!!(m.attributeName&&e.includes(bo(m.attributeName)))}),i&&this.queueRender!==void 0)this.queueRender(!1)}).observe(this,{attributes:!0}),e.forEach((t)=>{o[t]=g(this[t]);let i=x(t);Object.defineProperty(this,t,{enumerable:!1,get(){if(typeof o[t]==="boolean")return this.hasAttribute(i);else if(this.hasAttribute(i))return typeof o[t]==="number"?parseFloat(this.getAttribute(i)):this.getAttribute(i);else if(n[t]!==void 0)return n[t];else return o[t]},set(m){if(typeof o[t]==="boolean"){if(m!==this[t]){if(m)this.setAttribute(i,"");else this.removeAttribute(i);this.queueRender()}}else if(typeof o[t]==="number"){if(m!==parseFloat(this[t]))this.setAttribute(i,m),this.queueRender()}else if(typeof m==="object"||`${m}`!==`${this[t]}`){if(m===null||m===void 0||typeof m==="object")this.removeAttribute(i);else this.setAttribute(i,m);this.queueRender(),n[t]=m}}})})}initValue(){let e=Object.getOwnPropertyDescriptor(this,"value");if(e===void 0||e.get!==void 0||e.set!==void 0)return;let o=this.hasAttribute("value")?this.getAttribute("value"):g(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return o},set(n){if(o!==n)o=n,this.queueRender(!0)}})}_parts;get parts(){let e=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(o,n){if(o[n]===void 0){let r=e.querySelector(`[part="${n}"]`);if(r==null)r=e.querySelector(n);if(r==null)throw Error(`elementRef "${n}" does not exist!`);r.removeAttribute("data-ref"),o[n]=r}return o[n]}});return this._parts}constructor(){super();Go+=1,this.initAttributes("hidden"),this.instanceId=`${this.tagName.toLocaleLowerCase()}-${Go}`,this._value=g(this.defaultValue)}connectedCallback(){if(Ln(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.onResize!==void 0){if(oe.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");this.queueRender()}disconnectedCallback(){oe.unobserve(this)}_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)ve(this,"change");this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let e=typeof this.content!=="function",o=typeof this.content==="function"?this.content(d):this.content,{styleSpec:n}=this.constructor,{styleNode:r}=this.constructor;if(n)r=this.constructor.styleNode=d.style(O(n)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),r=this.styleNode;if(r){let t=this.attachShadow({mode:"open"});t.appendChild(r.cloneNode(!0)),Ke(t,o,e)}else if(o!==null){let t=Array.from(this.childNodes);Ke(this,o,e),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let i=Array.from(this.querySelectorAll("slot"));if(i.length>0)i.forEach(oo.replaceSlot);if(t.length>0){let m={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((s)=>{m[s.name]=s}),t.forEach((s)=>{let c=m[""],f=s instanceof Element?m[s.slot]:c;(f!==void 0?f:c).append(s)})}}this._hydrated=!0}}render(){}}class oo extends F{name="";content=null;static replaceSlot(e){let o=document.createElement("xin-slot");if(e.name!=="")o.setAttribute("name",e.name);e.replaceWith(o)}constructor(){super();this.initAttributes("name")}}var Qr=oo.elementCreator({tag:"xin-slot"});var Zo=(e=()=>!0)=>{let o=localStorage.getItem("xin-state");if(o!=null){let r=JSON.parse(o);for(let t of Object.keys(r).filter(e))if(a[t]!==void 0)Object.assign(a[t],r[t]);else a[t]=r[t]}let n=pe(()=>{let r={},t=w(a);for(let i of Object.keys(t).filter(e))r[i]=t[i];localStorage.setItem("xin-state",JSON.stringify(r)),console.log("xin state saved to localStorage")},500);Te(e,n)};var He="1.1.1";function me(e){return Object.assign(I,e),I}function fe(e){return console.warn("boxedProxy is deprecated, please use tosi() instead"),me(e)}function ge(e,o=!1){if(o)return console.warn("xinProxy(..., true) is deprecated; use tosi(...) instead"),fe(e);return Object.keys(e).forEach((n)=>{a[n]=e[n]}),a}var kn={};async function le(e,o){let{type:n,styleSpec:r}=await o(e,{Color:l,Component:F,elements:d,svgElements:be,mathML:xe,varDefault:ie,vars:Ce,xin:a,boxed:I,xinProxy:ge,boxedProxy:fe,tosi:me,makeComponent:le,bind:T,on:U,version:He}),t={type:n,creator:n.elementCreator({tag:e,styleSpec:r})};return kn[e]=t,t}var no={},Sn=(e)=>import(e);class ue extends F{tag="anon-elt";src="";property="default";loaded;blueprintLoaded=(e)=>{};async packaged(){let{tag:e,src:o,property:n}=this,r=`${e}.${n}:${o}`;if(!this.loaded){if(no[r]===void 0)no[r]=Sn(o).then((t)=>{let i=t[n];return le(e,i)});else console.log(`using cached ${e} with signature ${r}`);this.loaded=await no[r],this.blueprintLoaded(this.loaded)}return this.loaded}constructor(){super();this.initAttributes("tag","src","property")}}var Ao=ue.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class Xe extends F{allLoaded=()=>{};constructor(){super()}async load(){let o=Array.from(this.querySelectorAll(ue.tagName)).filter((n)=>n.src).map((n)=>n.packaged());await Promise.all(o),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var Oo=Xe.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
11
11
 
12
- //# debugId=CA4A9CB4F90E502C64756E2164756E21
12
+ //# debugId=5FA717665E8608B064756E2164756E21
13
13
  //# sourceMappingURL=index.js.map