tosijs 1.0.5 → 1.0.6

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