tosijs 1.0.10 → 1.0.11

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