tosijs 1.3.4 → 1.3.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/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +5 -5
- package/dist/list-binding.d.ts +5 -0
- package/dist/main.js +8 -8
- package/dist/main.js.map +5 -5
- package/dist/module.js +8 -8
- package/dist/module.js.map +5 -5
- package/dist/version.d.ts +1 -1
- package/dist/xin-types.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { ElementsProxy } from './elements-types';
|
|
|
11
11
|
export { getCssVar } from './get-css-var';
|
|
12
12
|
export { hotReload } from './hot-reload';
|
|
13
13
|
export { xinPath, xinValue, tosiPath, tosiValue, tosiSetValue, deprecated, warnDeprecated, } from './metadata';
|
|
14
|
-
export { getListInstance, getListItem, getListBinding, deleteListItem, } from './list-binding';
|
|
14
|
+
export { getListInstance, getListItem, getListBinding, deleteListItem, scrollListItemIntoView, } from './list-binding';
|
|
15
15
|
export { makeComponent } from './make-component';
|
|
16
16
|
export type { XinBlueprint, XinFactory, XinPackagedComponent, XinComponentSpec, } from './make-component';
|
|
17
17
|
export { MoreMath } from './more-math';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var{defineProperty:Kn,getOwnPropertyNames:yf,getOwnPropertyDescriptor:Lf}=Object,xf=Object.prototype.hasOwnProperty;var xo=new WeakMap,Tf=(n)=>{var o=xo.get(n),f;if(o)return o;if(o=Kn({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")yf(n).map((i)=>!xf.call(o,i)&&Kn(o,i,{get:()=>n[i],enumerable:!(f=Lf(n,i))||f.enumerable}));return xo.set(n,o),o};var sf=(n,o)=>{for(var f in o)Kn(n,f,{get:o[f],enumerable:!0,configurable:!0,set:(i)=>o[f]=()=>i})};var pf={};sf(pf,{xinValue:()=>Fo,xinProxy:()=>An,xinPath:()=>Xo,xin:()=>X,warnDeprecated:()=>q,version:()=>qn,vars:()=>Zn,varDefault:()=>wn,validateAgainstConstraints:()=>Un,updates:()=>tn,unobserve:()=>u,touchElement:()=>On,touch:()=>B,tosiValue:()=>H,tosiSetValue:()=>Co,tosiPath:()=>F,tosi:()=>Ln,throttle:()=>mn,svgElements:()=>Gn,settings:()=>S,onThemePreferencesChange:()=>Po,onStylesheetChange:()=>Bo,on:()=>p,observe:()=>l,mathML:()=>Qn,makeComponent:()=>Tn,invertLuminance:()=>bo,initVars:()=>eo,hotReload:()=>Ef,getThemePreferences:()=>co,getListItem:()=>zn,getListInstance:()=>Wn,getListBinding:()=>rn,getCssVar:()=>$n,elements:()=>x,deprecated:()=>Cn,deleteListItem:()=>nf,debounce:()=>Yn,css:()=>V,boxedProxy:()=>xn,boxed:()=>g,blueprintLoader:()=>wf,blueprint:()=>rf,bindings:()=>En,bind:()=>Q,StyleSheet:()=>Io,MoreMath:()=>Ko,Component:()=>W,Color:()=>y,BlueprintLoader:()=>jn,Blueprint:()=>sn});function z(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(z);let o={};for(let f in n){let i=n[f];if(n!=null&&typeof n==="object")o[f]=z(i);else o[f]=i}return o}var Sn="-xin-data",R=`.${Sn}`,Bn="-xin-event",In=`.${Bn}`,J=Symbol.for("xin-path"),U=Symbol.for("xin-value"),Vn="xinObserve",en="xinBind",bn="xinOn",a=Symbol("list-binding"),Hn=Symbol("list-instance"),Rn=new Map;function so(n,o){let f=Rn.get(n);if(f===void 0)f=new Set,Rn.set(n,f);f.add(o)}function Ho(n){return Rn.get(n)}var To=new Set;function q(n,o){if(!To.has(n))console.warn(o),To.add(n)}function Cn(n,o){let f=!1;return(...i)=>{if(!f)console.warn(o),f=!0;return n(...i)}}var F=(n)=>{return n&&n[J]||void 0};function H(n){if(typeof n==="object"&&n!==null){let o=n[U];return o!==void 0?o:n}return n}function Co(n,o){if(F(n)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");n[U]=o}var Xo=Cn(F,"xinPath is deprecated. Use tosiPath instead."),Fo=Cn(H,"xinValue is deprecated. Use tosiValue instead."),P=new WeakMap,O=new WeakMap;var _=(n)=>{let o=n.cloneNode();if(o instanceof Element){let f=O.get(n),i=P.get(n);if(f!=null)O.set(o,z(f));if(i!=null)P.set(o,z(i))}for(let f of Array.from(n instanceof HTMLTemplateElement?n.content.childNodes:n.childNodes))if(f instanceof Element||f instanceof DocumentFragment)o.appendChild(_(f));else o.appendChild(f.cloneNode());return o};var S={debug:!1,perf:!1};var Hf=(n)=>{try{return JSON.stringify(n)}catch(o){return"{has circular references}"}},Pn=(...n)=>Error(n.map(Hf).join(" "));var Cf=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),Xf=0,Ff=()=>(parseInt("10000",36)+ ++Xf).toString(36).slice(-5),Df=()=>Cf()+Ff(),hn=Symbol("delete"),$o=Symbol("new-object"),_n=Symbol("automatic-index");function Jo(n){if(n==="")return[];if(Array.isArray(n))return n;else{let o=[];while(n.length>0){let f=n.search(/\[[^\]]+\]/);if(f===-1){o.push(n.split("."));break}else{let i=n.slice(0,f);if(n=n.slice(f),i!=="")o.push(i.split("."));if(f=n.indexOf("]")+1,o.push(n.slice(1,f-1)),n.slice(f,f+1)===".")f+=1;n=n.slice(f)}}return o}}var A=new WeakMap;function Zo(n,o){if(A.get(n)===void 0)A.set(n,{});if(A.get(n)[o]===void 0)A.get(n)[o]={};let f=A.get(n)[o];if(o==="_auto_")n.forEach((i,c)=>{if(i[_n]===void 0)i[_n]=Df();f[i[_n]+""]=c});else n.forEach((i,c)=>{f[j(i,o)+""]=c});return f}function Yf(n,o){if(A.get(n)===void 0||A.get(n)[o]===void 0)return Zo(n,o);else return A.get(n)[o]}function $f(n,o,f){f=f+"";let i=Yf(n,o)[f];if(i===void 0||j(n[i],o)+""!==f)i=Zo(n,o)[f];return i}function Jf(n,o,f){if(n[o]===void 0&&f!==void 0)n[o]=f;return n[o]}function Go(n,o,f,i){let c=o!==""?$f(n,o,f):f;if(i===hn)return n.splice(c,1),A.delete(n),Symbol("deleted");else if(i===$o){if(o===""&&n[c]===void 0)n[c]={}}else if(i!==void 0)if(c!==void 0)n[c]=i;else if(o!==""&&j(i,o)+""===f+"")n.push(i),c=n.length-1;else throw Error(`byIdPath insert failed at [${o}=${f}]`);return n[c]}function Do(n){if(!Array.isArray(n))throw Pn("setByPath failed: expected array, found",n)}function Yo(n){if(n==null||!(n instanceof Object))throw Pn("setByPath failed: expected Object, found",n)}function j(n,o){let f=Jo(o),i=n,c,m,r,w;for(c=0,m=f.length;i!==void 0&&c<m;c++){let E=f[c];if(Array.isArray(E))for(r=0,w=E.length;i!==void 0&&r<w;r++){let M=E[r];i=i[M]}else if(i.length===0){if(i=i[Number(E.slice(1))],E[0]!=="=")return}else if(E.includes("=")){let[M,...L]=E.split("=");i=Go(i,M,L.join("="))}else r=parseInt(E,10),i=i[r]}return i}function Qo(n,o,f){let i=n;if(o==="")throw Error("setByPath cannot be used to set the root object");let c=Jo(o);while(i!=null&&c.length>0){let m=c.shift();if(typeof m==="string"){let r=m.indexOf("=");if(r>-1){if(r===0)Yo(i);else Do(i);let w=m.slice(0,r),E=m.slice(r+1);if(i=Go(i,w,E,c.length>0?$o:f),c.length===0)return!0}else{Do(i);let w=parseInt(m,10);if(c.length>0)i=i[w];else{if(f!==hn){if(i[w]===f)return!1;i[w]=f}else i.splice(w,1);return!0}}}else if(Array.isArray(m)&&m.length>0){Yo(i);while(m.length>0){let r=m.shift();if(m.length>0||c.length>0)i=Jf(i,r,m.length>0?{}:[]);else{if(f!==hn){if(i[r]===f)return!1;i[r]=f}else{if(!Object.prototype.hasOwnProperty.call(i,r))return!1;delete i[r]}return!0}}}else throw Error(`setByPath failed, bad path ${o}`)}throw Error(`setByPath(${n}, ${o}, ${f}) failed`)}var ko=Symbol("observer should be removed"),Xn=[],Fn=[],pn=!1,Nn,gn;function Wo(n,o,f,i){let c=Ho(n);if(c===void 0)return[];let m=[];for(let r of c){let w=j(f,r);if(w!==void 0)m.push(`${n}[${r}=${w}]${i}`)}return m}class zo{description;test;callback;constructor(n,o){let f=typeof o==="string"?`"${o}"`:`function ${o.name}`,i;if(typeof n==="string")this.test=(c)=>typeof c==="string"&&c!==""&&(n.startsWith(c)||c.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}, ${f}`,typeof o==="function")this.callback=o;else throw Error("expect callback to be a path or function");Xn.push(this)}}var tn=async()=>{if(Nn===void 0)return;await Nn},Zf=()=>{if(S.perf)console.time("xin async update");let n=Array.from(Fn);Fn.length=0,pn=!1;for(let o of n)Xn.filter((f)=>{let i;try{i=f.test(o)}catch(c){throw Error(`Listener ${f.description} threw "${c}" at "${o}"`)}if(i===ko)return u(f),!1;return i}).forEach((f)=>{let i;try{i=f.callback(o)}catch(c){console.error(`Listener ${f.description} threw "${c}" handling "${o}"`)}if(i===ko)u(f)});if(typeof gn==="function")gn();if(S.perf)console.timeEnd("xin async update")},B=(n)=>{let o=typeof n==="string"?n:F(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(pn===!1)Nn=new Promise((f)=>{gn=f}),pn=setTimeout(Zf);if(Fn.find((f)=>o.startsWith(f))==null)Fn.push(o)},I=(n,o)=>{return new zo(n,o)},u=(n)=>{let o=Xn.indexOf(n);if(o>-1)Xn.splice(o,1);else throw Error("unobserve failed, listener not found")};var nn={},ln=null,Oo=(n)=>{ln=n},Dn=()=>{if(ln===null)throw Error("xin proxy not initialized");return ln},vn=null,an=null,Uo=(n,o)=>{vn=n,an=o},on=()=>{if(vn===null)throw Error("bind not initialized");return vn},fn=()=>{if(an===null)throw Error("on not initialized");return an};var no=(n,o)=>{let f=new Event(o);n.dispatchEvent(f)},Ao=(n)=>{if(n instanceof HTMLInputElement)return n.type;else if(n instanceof HTMLSelectElement&&n.hasAttribute("multiple"))return"multi-select";else return"other"},jo=(n,o)=>{switch(Ao(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 f of Array.from(n.querySelectorAll("option")))f.selected=o[f.value];break;default:n.value=o}},uo=(n)=>{switch(Ao(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,f)=>{return o[f.value]=f.selected,o},{});default:return n.value}},{ResizeObserver:qo}=globalThis,cn=qo!=null?new qo((n)=>{for(let o of n){let f=o.target;no(f,"resize")}}):{observe(){},unobserve(){}},oo=(n,o,f=!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&&f?_(i):i)});else if(o instanceof Node)n.append(f?_(o):o);else throw Error("expect text content or document node")};var Yn=(n,o=250)=>{let f;return(...i)=>{if(f!==void 0)clearTimeout(f);f=setTimeout(()=>{n(...i)},o)}},mn=(n,o=250)=>{let f,i=Date.now()-o,c=!1;return(...m)=>{if(clearTimeout(f),f=setTimeout(()=>{n(...m),i=Date.now()},o),!c&&Date.now()-i>=o){c=!0;try{n(...m),i=Date.now()}finally{c=!1}}}};var En={value:{toDOM:jo,fromDOM(n){return uo(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,f){rn(n,o,f).update(o)}}};function $(n){return n.replace(/[A-Z]/g,(o)=>{return`-${o.toLocaleLowerCase()}`})}function fo(n){return n.replace(/-([a-z])/g,(o,f)=>{return f.toLocaleUpperCase()})}var df=180/Math.PI,Gf=Math.PI/180;function G(n,o,f){return f<n?NaN:o<n?n:o>f?f:o}function K(n,o,f,i=!0){if(i)f=G(0,f,1);return f*(o-n)+n}var Ko={RADIANS_TO_DEGREES:df,DEGREES_TO_RADIANS:Gf,clamp:G,lerp:K};function $n(n,o=document.body){let f=getComputedStyle(o);if(n.endsWith(")")&&n.startsWith("var("))n=n.slice(4,-1);return f.getPropertyValue(n).trim()}var Qf=(n,o,f)=>{return(0.299*n+0.587*o+0.114*f)/255},h=(n)=>("00"+Math.round(Number(n)).toString(16)).slice(-2);class Ro{h;s;l;constructor(n,o,f){n/=255,o/=255,f/=255;let i=Math.max(n,o,f),c=i-Math.min(n,o,f),m=c!==0?i===n?(o-f)/c:i===o?2+(f-n)/c:4+(n-o)/c:0;this.h=60*m<0?60*m+360:60*m,this.s=c!==0?i<=0.5?c/(2*i-c):c/(2-(2*i-c)):0,this.l=(2*i-c)/2}}var t=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class y{r;g;b;a;static fromVar(n,o=document.body){return y.fromCss($n(n,o))}static fromCss(n){let o=n.match(/^#([0-9a-fA-F]+)$/);if(o){let E=o[1];if(E.length===3)return new y(parseInt(E[0]+E[0],16),parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16));if(E.length===4)return new y(parseInt(E[0]+E[0],16),parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16)/255);if(E.length===6)return new y(parseInt(E.slice(0,2),16),parseInt(E.slice(2,4),16),parseInt(E.slice(4,6),16));if(E.length===8)return new y(parseInt(E.slice(0,2),16),parseInt(E.slice(2,4),16),parseInt(E.slice(4,6),16),parseInt(E.slice(6,8),16)/255)}let f=n;if(t instanceof HTMLSpanElement)t.style.color="black",t.style.color=n,document.body.appendChild(t),f=getComputedStyle(t).color,t.remove();let[i,c,m,r]=f.match(/[\d.]+/g)||["0","0","0","0"],w=f.startsWith("color(srgb")?255:1;return new y(Number(i)*w,Number(c)*w,Number(m)*w,r==null?1:Number(r))}static fromHsl(n,o,f,i=1){let c,m,r;if(o===0)c=m=r=f;else{let E=(D,Y,s)=>{if(s<0)s+=1;if(s>1)s-=1;if(s<0.16666666666666666)return D+(Y-D)*6*s;if(s<0.5)return Y;if(s<0.6666666666666666)return D+(Y-D)*(0.6666666666666666-s)*6;return D},M=f<0.5?f*(1+o):f+o-f*o,L=2*f-M,T=(n%360+360)%360/360;c=E(L,M,T+0.3333333333333333),m=E(L,M,T),r=E(L,M,T-0.3333333333333333)}let w=new y(c*255,m*255,r*255,i);return w.hslCached={h:(n%360+360)%360,s:o,l:f},w}static black=new y(0,0,0);static white=new y(255,255,255);constructor(n,o,f,i=1){this.r=G(0,n,255),this.g=G(0,o,255),this.b=G(0,f,255),this.a=G(0,i,1)}get inverse(){return new y(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:n,s:o,l:f}=this._hsl;return y.fromHsl(n,o,1-f,this.a)}get opaque(){return this.a===1?this:new y(this.r,this.g,this.b,1)}contrasting(n=1){return this.opaque.blend(this.brightness>0.5?y.black:y.white,n)}get rgb(){let{r:n,g:o,b:f}=this;return`rgb(${n.toFixed(0)},${o.toFixed(0)},${f.toFixed(0)})`}get rgba(){let{r:n,g:o,b:f,a:i}=this;return`rgba(${n.toFixed(0)},${o.toFixed(0)},${f.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 Ro(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:n,s:o,l:f}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(f*100).toFixed(0)}%)`}get hsla(){let{h:n,s:o,l:f}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(o*100).toFixed(0)}% ${(f*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let n=this.brightness*255;return new y(n,n,n)}get brightness(){return Qf(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+h(this.r)+h(this.g)+h(this.b):"#"+h(this.r)+h(this.g)+h(this.b)+h(Math.floor(255*this.a))}brighten(n){let{h:o,s:f,l:i}=this._hsl,c=G(0,i+n*(1-i),1);return y.fromHsl(o,f,c,this.a)}darken(n){let{h:o,s:f,l:i}=this._hsl,c=G(0,i*(1-n),1);return y.fromHsl(o,f,c,this.a)}saturate(n){let{h:o,s:f,l:i}=this._hsl,c=G(0,f+n*(1-f),1);return y.fromHsl(o,c,i,this.a)}desaturate(n){let{h:o,s:f,l:i}=this._hsl,c=G(0,f*(1-n),1);return y.fromHsl(o,c,i,this.a)}rotate(n){let{h:o,s:f,l:i}=this._hsl,c=(o+360+n)%360;return y.fromHsl(c,f,i,this.a)}opacity(n){let{h:o,s:f,l:i}=this._hsl;return y.fromHsl(o,f,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 y(K(this.r,n.r,o),K(this.g,n.g,o),K(this.b,n.b,o),K(this.a,n.a,o))}static blendHue(n,o,f){let i=(o-n+720)%360;if(i<180)return n+f*i;else return n-(360-i)*f}mix(n,o){let f=this._hsl,i=n._hsl;return y.fromHsl(f.s===0?i.h:i.s===0?f.h:y.blendHue(f.h,i.h,o),K(f.s,i.s,o),K(f.l,i.l,o),K(this.a,n.a,o))}colorMix(n,o){return y.fromCss(`color-mix(in hsl, ${this.html}, ${n.html} ${(o*100).toFixed(0)}%)`)}static computedColorStylesheet=null;static computedColors=new Map;static recomputeQueued=!1;static registerComputedColor(n,o,f,i){if(!y.computedColors.has(n))y.computedColors.set(n,{varName:o,scale:f,method:i}),y.queueRecompute()}static queueRecompute(){if(y.recomputeQueued)return;y.recomputeQueued=!0,queueMicrotask(()=>{y.recomputeQueued=!1,y.recomputeColors()})}static recomputeColors(){if(y.computedColors.size===0)return;let n=[];for(let[f,{varName:i,scale:c,method:m}]of y.computedColors)try{let r=y.fromVar(i),w;switch(m){case"b":w=c>0?r.brighten(c):r.darken(-c);break;case"s":w=c>0?r.saturate(c):r.desaturate(-c);break;case"h":w=r.rotate(c*100);break;case"o":w=r.opacity(c);break;default:continue}n.push(` ${f}: ${w.rgba};`)}catch(r){}if(n.length===0)return;let o=`:root {
|
|
1
|
+
(()=>{var{defineProperty:In,getOwnPropertyNames:Co,getOwnPropertyDescriptor:Ho}=Object,Xo=Object.prototype.hasOwnProperty;var Tf=new WeakMap,ro=(n)=>{var f=Tf.get(n),o;if(f)return f;if(f=In({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")Co(n).map((E)=>!Xo.call(f,E)&&In(f,E,{get:()=>n[E],enumerable:!(o=Ho(n,E))||o.enumerable}));return Tf.set(n,f),f};var To=(n,f)=>{for(var o in f)In(n,o,{get:f[o],enumerable:!0,configurable:!0,set:(E)=>f[o]=()=>E})};var to={};To(to,{xinValue:()=>Zf,xinProxy:()=>Bn,xinPath:()=>Jf,xin:()=>Q,warnDeprecated:()=>d,version:()=>Kn,vars:()=>zn,varDefault:()=>xn,validateAgainstConstraints:()=>dn,updates:()=>ln,unobserve:()=>S,touchElement:()=>jn,touch:()=>V,tosiValue:()=>$,tosiSetValue:()=>$f,tosiPath:()=>k,tosi:()=>Hn,throttle:()=>yn,svgElements:()=>sn,settings:()=>R,scrollListItemIntoView:()=>co,onThemePreferencesChange:()=>pf,onStylesheetChange:()=>Pf,on:()=>v,observe:()=>on,mathML:()=>qn,makeComponent:()=>rn,invertLuminance:()=>Nf,initVars:()=>hf,hotReload:()=>Lo,getThemePreferences:()=>mf,getListItem:()=>An,getListInstance:()=>Un,getListBinding:()=>nn,getCssVar:()=>kn,elements:()=>r,deprecated:()=>Yn,deleteListItem:()=>Eo,debounce:()=>Qn,css:()=>_,boxedProxy:()=>Xn,boxed:()=>l,blueprintLoader:()=>wo,blueprint:()=>xo,bindings:()=>Ln,bind:()=>q,StyleSheet:()=>_f,MoreMath:()=>uf,Component:()=>O,Color:()=>x,BlueprintLoader:()=>Sn,Blueprint:()=>Tn});function U(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(U);let f={};for(let o in n){let E=n[o];if(n!=null&&typeof n==="object")f[o]=U(E);else f[o]=E}return f}var Rn="-xin-data",u=`.${Rn}`,Vn="-xin-event",Pn=`.${Vn}`,W=Symbol.for("xin-path"),j=Symbol.for("xin-value"),_n="xinObserve",bn="xinBind",hn="xinOn",a=Symbol("list-binding"),Dn=Symbol("list-instance"),un=new Map;function Df(n,f){let o=un.get(n);if(o===void 0)o=new Set,un.set(n,o);o.add(f)}function Yf(n){return un.get(n)}var Ff=new Set;function d(n,f){if(!Ff.has(n))console.warn(f),Ff.add(n)}function Yn(n,f){let o=!1;return(...E)=>{if(!o)console.warn(f),o=!0;return n(...E)}}var k=(n)=>{return n&&n[W]||void 0};function $(n){if(typeof n==="object"&&n!==null){let f=n[j];return f!==void 0?f:n}return n}function $f(n,f){if(k(n)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");n[j]=f}var Jf=Yn(k,"xinPath is deprecated. Use tosiPath instead."),Zf=Yn($,"xinValue is deprecated. Use tosiValue instead."),p=new WeakMap,A=new WeakMap;var g=(n)=>{let f=n.cloneNode();if(f instanceof Element){let o=A.get(n),E=p.get(n);if(o!=null)A.set(f,U(o));if(E!=null)p.set(f,U(E))}for(let o of Array.from(n instanceof HTMLTemplateElement?n.content.childNodes:n.childNodes))if(o instanceof Element||o instanceof DocumentFragment)f.appendChild(g(o));else f.appendChild(o.cloneNode());return f};var R={debug:!1,perf:!1};var Fo=(n)=>{try{return JSON.stringify(n)}catch(f){return"{has circular references}"}},Nn=(...n)=>Error(n.map(Fo).join(" "));var Do=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),Yo=0,$o=()=>(parseInt("10000",36)+ ++Yo).toString(36).slice(-5),Jo=()=>Do()+$o(),gn=Symbol("delete"),Gf=Symbol("new-object"),pn=Symbol("automatic-index");function zf(n){if(n==="")return[];if(Array.isArray(n))return n;else{let f=[];while(n.length>0){let o=n.search(/\[[^\]]+\]/);if(o===-1){f.push(n.split("."));break}else{let E=n.slice(0,o);if(n=n.slice(o),E!=="")f.push(E.split("."));if(o=n.indexOf("]")+1,f.push(n.slice(1,o-1)),n.slice(o,o+1)===".")o+=1;n=n.slice(o)}}return f}}var K=new WeakMap;function Wf(n,f){if(K.get(n)===void 0)K.set(n,{});if(K.get(n)[f]===void 0)K.get(n)[f]={};let o=K.get(n)[f];if(f==="_auto_")n.forEach((E,c)=>{if(E[pn]===void 0)E[pn]=Jo();o[E[pn]+""]=c});else n.forEach((E,c)=>{o[B(E,f)+""]=c});return o}function Zo(n,f){if(K.get(n)===void 0||K.get(n)[f]===void 0)return Wf(n,f);else return K.get(n)[f]}function Qo(n,f,o){o=o+"";let E=Zo(n,f)[o];if(E===void 0||B(n[E],f)+""!==o)E=Wf(n,f)[o];return E}function ko(n,f,o){if(n[f]===void 0&&o!==void 0)n[f]=o;return n[f]}function sf(n,f,o,E){let c=f!==""?Qo(n,f,o):o;if(E===gn)return n.splice(c,1),K.delete(n),Symbol("deleted");else if(E===Gf){if(f===""&&n[c]===void 0)n[c]={}}else if(E!==void 0)if(c!==void 0)n[c]=E;else if(f!==""&&B(E,f)+""===o+"")n.push(E),c=n.length-1;else throw Error(`byIdPath insert failed at [${f}=${o}]`);return n[c]}function Qf(n){if(!Array.isArray(n))throw Nn("setByPath failed: expected array, found",n)}function kf(n){if(n==null||!(n instanceof Object))throw Nn("setByPath failed: expected Object, found",n)}function B(n,f){let o=zf(f),E=n,c,m,i,y;for(c=0,m=o.length;E!==void 0&&c<m;c++){let M=o[c];if(Array.isArray(M))for(i=0,y=M.length;E!==void 0&&i<y;i++){let L=M[i];E=E[L]}else if(E.length===0){if(E=E[Number(M.slice(1))],M[0]!=="=")return}else if(M.includes("=")){let[L,...w]=M.split("=");E=sf(E,L,w.join("="))}else i=parseInt(M,10),E=E[i]}return E}function qf(n,f,o){let E=n;if(f==="")throw Error("setByPath cannot be used to set the root object");let c=zf(f);while(E!=null&&c.length>0){let m=c.shift();if(typeof m==="string"){let i=m.indexOf("=");if(i>-1){if(i===0)kf(E);else Qf(E);let y=m.slice(0,i),M=m.slice(i+1);if(E=sf(E,y,M,c.length>0?Gf:o),c.length===0)return!0}else{Qf(E);let y=parseInt(m,10);if(c.length>0)E=E[y];else{if(o!==gn){if(E[y]===o)return!1;E[y]=o}else E.splice(y,1);return!0}}}else if(Array.isArray(m)&&m.length>0){kf(E);while(m.length>0){let i=m.shift();if(m.length>0||c.length>0)E=ko(E,i,m.length>0?{}:[]);else{if(o!==gn){if(E[i]===o)return!1;E[i]=o}else{if(!Object.prototype.hasOwnProperty.call(E,i))return!1;delete E[i]}return!0}}}else throw Error(`setByPath failed, bad path ${f}`)}throw Error(`setByPath(${n}, ${f}, ${o}) failed`)}var Of=Symbol("observer should be removed"),$n=[],Jn=[],en=!1,vn,tn;function Uf(n,f,o,E){let c=Yf(n);if(c===void 0)return[];let m=[];for(let i of c){let y=B(o,i);if(y!==void 0)m.push(`${n}[${i}=${y}]${E}`)}return m}class Af{description;test;callback;constructor(n,f){let o=typeof f==="string"?`"${f}"`:`function ${f.name}`,E;if(typeof n==="string")this.test=(c)=>typeof c==="string"&&c!==""&&(n.startsWith(c)||c.startsWith(n)),E=`test = "${n}"`;else if(n instanceof RegExp)this.test=n.test.bind(n),E=`test = "${n.toString()}"`;else if(n instanceof Function)this.test=n,E=`test = function ${n.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${E}, ${o}`,typeof f==="function")this.callback=f;else throw Error("expect callback to be a path or function");$n.push(this)}}var ln=async()=>{if(vn===void 0)return;await vn},Go=()=>{if(R.perf)console.time("xin async update");let n=Array.from(Jn);Jn.length=0,en=!1;for(let f of n)$n.filter((o)=>{let E;try{E=o.test(f)}catch(c){throw Error(`Listener ${o.description} threw "${c}" at "${f}"`)}if(E===Of)return S(o),!1;return E}).forEach((o)=>{let E;try{E=o.callback(f)}catch(c){console.error(`Listener ${o.description} threw "${c}" handling "${f}"`)}if(E===Of)S(o)});if(typeof tn==="function")tn();if(R.perf)console.timeEnd("xin async update")},V=(n)=>{let f=typeof n==="string"?n:k(n);if(f===void 0)throw console.error("touch was called on an invalid target",n),Error("touch was called on an invalid target");if(en===!1)vn=new Promise((o)=>{tn=o}),en=setTimeout(Go);if(Jn.find((o)=>f.startsWith(o))==null)Jn.push(f)},P=(n,f)=>{return new Af(n,f)},S=(n)=>{let f=$n.indexOf(n);if(f>-1)$n.splice(f,1);else throw Error("unobserve failed, listener not found")};var En={},an=null,jf=(n)=>{an=n},Zn=()=>{if(an===null)throw Error("xin proxy not initialized");return an},nf=null,ff=null,df=(n,f)=>{nf=n,ff=f},cn=()=>{if(nf===null)throw Error("bind not initialized");return nf},Mn=()=>{if(ff===null)throw Error("on not initialized");return ff};var of=(n,f)=>{let o=new Event(f);n.dispatchEvent(o)},Bf=(n)=>{if(n instanceof HTMLInputElement)return n.type;else if(n instanceof HTMLSelectElement&&n.hasAttribute("multiple"))return"multi-select";else return"other"},Sf=(n,f)=>{switch(Bf(n)){case"radio":n.checked=n.value===f;break;case"checkbox":n.checked=!!f;break;case"date":n.valueAsDate=new Date(f);break;case"multi-select":for(let o of Array.from(n.querySelectorAll("option")))o.selected=f[o.value];break;default:n.value=f}},If=(n)=>{switch(Bf(n)){case"radio":{let f=n.parentElement?.querySelector(`[name="${n.name}"]:checked`);return f!=null?f.value:null}case"checkbox":return n.checked;case"date":return n.valueAsDate?.toISOString();case"multi-select":return Array.from(n.querySelectorAll("option")).reduce((f,o)=>{return f[o.value]=o.selected,f},{});default:return n.value}},{ResizeObserver:Kf}=globalThis,mn=Kf!=null?new Kf((n)=>{for(let f of n){let o=f.target;of(o,"resize")}}):{observe(){},unobserve(){}},Ef=(n,f,o=!0)=>{if(n!=null&&f!=null)if(typeof f==="string")n.textContent=f;else if(Array.isArray(f))f.forEach((E)=>{n.append(E instanceof Node&&o?g(E):E)});else if(f instanceof Node)n.append(o?g(f):f);else throw Error("expect text content or document node")};var Qn=(n,f=250)=>{let o;return(...E)=>{if(o!==void 0)clearTimeout(o);o=setTimeout(()=>{n(...E)},f)}},yn=(n,f=250)=>{let o,E=Date.now()-f,c=!1;return(...m)=>{if(clearTimeout(o),o=setTimeout(()=>{n(...m),E=Date.now()},f),!c&&Date.now()-E>=f){c=!0;try{n(...m),E=Date.now()}finally{c=!1}}}};var Ln={value:{toDOM:Sf,fromDOM(n){return If(n)}},text:{toDOM(n,f){n.textContent=f}},enabled:{toDOM(n,f){n.disabled=!f}},disabled:{toDOM(n,f){n.disabled=Boolean(f)}},list:{toDOM(n,f,o){nn(n,f,o).update(f)}}};function G(n){return n.replace(/[A-Z]/g,(f)=>{return`-${f.toLocaleLowerCase()}`})}function cf(n){return n.replace(/-([a-z])/g,(f,o)=>{return o.toLocaleUpperCase()})}var zo=180/Math.PI,Wo=Math.PI/180;function s(n,f,o){return o<n?NaN:f<n?n:f>o?o:f}function I(n,f,o,E=!0){if(E)o=s(0,o,1);return o*(f-n)+n}var uf={RADIANS_TO_DEGREES:zo,DEGREES_TO_RADIANS:Wo,clamp:s,lerp:I};function kn(n,f=document.body){let o=getComputedStyle(f);if(n.endsWith(")")&&n.startsWith("var("))n=n.slice(4,-1);return o.getPropertyValue(n).trim()}var so=(n,f,o)=>{return(0.299*n+0.587*f+0.114*o)/255},e=(n)=>("00"+Math.round(Number(n)).toString(16)).slice(-2);class Rf{h;s;l;constructor(n,f,o){n/=255,f/=255,o/=255;let E=Math.max(n,f,o),c=E-Math.min(n,f,o),m=c!==0?E===n?(f-o)/c:E===f?2+(o-n)/c:4+(n-f)/c:0;this.h=60*m<0?60*m+360:60*m,this.s=c!==0?E<=0.5?c/(2*E-c):c/(2-(2*E-c)):0,this.l=(2*E-c)/2}}var fn=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class x{r;g;b;a;static fromVar(n,f=document.body){return x.fromCss(kn(n,f))}static fromCss(n){let f=n.match(/^#([0-9a-fA-F]+)$/);if(f){let M=f[1];if(M.length===3)return new x(parseInt(M[0]+M[0],16),parseInt(M[1]+M[1],16),parseInt(M[2]+M[2],16));if(M.length===4)return new x(parseInt(M[0]+M[0],16),parseInt(M[1]+M[1],16),parseInt(M[2]+M[2],16),parseInt(M[3]+M[3],16)/255);if(M.length===6)return new x(parseInt(M.slice(0,2),16),parseInt(M.slice(2,4),16),parseInt(M.slice(4,6),16));if(M.length===8)return new x(parseInt(M.slice(0,2),16),parseInt(M.slice(2,4),16),parseInt(M.slice(4,6),16),parseInt(M.slice(6,8),16)/255)}let o=n;if(fn instanceof HTMLSpanElement)fn.style.color="black",fn.style.color=n,document.body.appendChild(fn),o=getComputedStyle(fn).color,fn.remove();let[E,c,m,i]=o.match(/[\d.]+/g)||["0","0","0","0"],y=o.startsWith("color(srgb")?255:1;return new x(Number(E)*y,Number(c)*y,Number(m)*y,i==null?1:Number(i))}static fromHsl(n,f,o,E=1){let c,m,i;if(f===0)c=m=i=o;else{let M=(T,J,C)=>{if(C<0)C+=1;if(C>1)C-=1;if(C<0.16666666666666666)return T+(J-T)*6*C;if(C<0.5)return J;if(C<0.6666666666666666)return T+(J-T)*(0.6666666666666666-C)*6;return T},L=o<0.5?o*(1+f):o+f-o*f,w=2*o-L,H=(n%360+360)%360/360;c=M(w,L,H+0.3333333333333333),m=M(w,L,H),i=M(w,L,H-0.3333333333333333)}let y=new x(c*255,m*255,i*255,E);return y.hslCached={h:(n%360+360)%360,s:f,l:o},y}static black=new x(0,0,0);static white=new x(255,255,255);constructor(n,f,o,E=1){this.r=s(0,n,255),this.g=s(0,f,255),this.b=s(0,o,255),this.a=s(0,E,1)}get inverse(){return new x(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:n,s:f,l:o}=this._hsl;return x.fromHsl(n,f,1-o,this.a)}get opaque(){return this.a===1?this:new x(this.r,this.g,this.b,1)}contrasting(n=1){return this.opaque.blend(this.brightness>0.5?x.black:x.white,n)}get rgb(){let{r:n,g:f,b:o}=this;return`rgb(${n.toFixed(0)},${f.toFixed(0)},${o.toFixed(0)})`}get rgba(){let{r:n,g:f,b:o,a:E}=this;return`rgba(${n.toFixed(0)},${f.toFixed(0)},${o.toFixed(0)},${E.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 Rf(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:n,s:f,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(o*100).toFixed(0)}%)`}get hsla(){let{h:n,s:f,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(o*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let n=this.brightness*255;return new x(n,n,n)}get brightness(){return so(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+e(this.r)+e(this.g)+e(this.b):"#"+e(this.r)+e(this.g)+e(this.b)+e(Math.floor(255*this.a))}brighten(n){let{h:f,s:o,l:E}=this._hsl,c=s(0,E+n*(1-E),1);return x.fromHsl(f,o,c,this.a)}darken(n){let{h:f,s:o,l:E}=this._hsl,c=s(0,E*(1-n),1);return x.fromHsl(f,o,c,this.a)}saturate(n){let{h:f,s:o,l:E}=this._hsl,c=s(0,o+n*(1-o),1);return x.fromHsl(f,c,E,this.a)}desaturate(n){let{h:f,s:o,l:E}=this._hsl,c=s(0,o*(1-n),1);return x.fromHsl(f,c,E,this.a)}rotate(n){let{h:f,s:o,l:E}=this._hsl,c=(f+360+n)%360;return x.fromHsl(c,o,E,this.a)}opacity(n){let{h:f,s:o,l:E}=this._hsl;return x.fromHsl(f,o,E,n)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(n,f){return new x(I(this.r,n.r,f),I(this.g,n.g,f),I(this.b,n.b,f),I(this.a,n.a,f))}static blendHue(n,f,o){let E=(f-n+720)%360;if(E<180)return n+o*E;else return n-(360-E)*o}mix(n,f){let o=this._hsl,E=n._hsl;return x.fromHsl(o.s===0?E.h:E.s===0?o.h:x.blendHue(o.h,E.h,f),I(o.s,E.s,f),I(o.l,E.l,f),I(this.a,n.a,f))}colorMix(n,f){return x.fromCss(`color-mix(in hsl, ${this.html}, ${n.html} ${(f*100).toFixed(0)}%)`)}static computedColorStylesheet=null;static computedColors=new Map;static recomputeQueued=!1;static registerComputedColor(n,f,o,E){if(!x.computedColors.has(n))x.computedColors.set(n,{varName:f,scale:o,method:E}),x.queueRecompute()}static queueRecompute(){if(x.recomputeQueued)return;x.recomputeQueued=!0,queueMicrotask(()=>{x.recomputeQueued=!1,x.recomputeColors()})}static recomputeColors(){if(x.computedColors.size===0)return;let n=[];for(let[o,{varName:E,scale:c,method:m}]of x.computedColors)try{let i=x.fromVar(E),y;switch(m){case"b":y=c>0?i.brighten(c):i.darken(-c);break;case"s":y=c>0?i.saturate(c):i.desaturate(-c);break;case"h":y=i.rotate(c*100);break;case"o":y=i.opacity(c);break;default:continue}n.push(` ${o}: ${y.rgba};`)}catch(i){}if(n.length===0)return;let f=`:root {
|
|
2
2
|
${n.join(`
|
|
3
3
|
`)}
|
|
4
|
-
}`;if(
|
|
5
|
-
`);return`${
|
|
4
|
+
}`;if(x.computedColorStylesheet===null)x.computedColorStylesheet=document.createElement("style"),x.computedColorStylesheet.id="tosijs-computed-colors",document.head.append(x.computedColorStylesheet);x.computedColorStylesheet.textContent=f}}var Gn=new Set,Vf=!1;function qo(){if(!Vf)Vf=!0,Gn.add(()=>x.queueRecompute())}function Pf(n){return Gn.add(n),()=>Gn.delete(n)}function Oo(){qo();for(let n of Gn)n()}function _f(n,f){let o=$(f),E=r.style(_(o));E.id=n,document.head.append(E);let c=k(f);if(c!==void 0)on(c,()=>{E.textContent=_($(f)),Oo()})}var Uo=/^(animation-iteration-count|column-count|flex(-grow|-shrink)?|font-weight|line-height|opacity|order|orphans|scale|tab-size|widows|z-index|zoom)$/,Mf=(n,f)=>{if(typeof f==="number"&&!Uo.test(n))f=`${f}px`;if(n.startsWith("_"))if(n.startsWith("__"))n="--"+n.substring(2),f=`var(${n}-default, ${f})`;else n="--"+n.substring(1);return{prop:n,value:String(f)}},Ao=(n,f,o)=>{if(o===void 0)return"";if(o instanceof x)o=o.html;let E=Mf(f,o);return`${n} ${E.prop}: ${E.value};`},bf=(n,f,o="")=>{let E=G(n);if(typeof f==="object"&&!(f instanceof x)){let c=Object.keys(f).map((m)=>bf(m,f[m],`${o} `)).join(`
|
|
5
|
+
`);return`${o} ${n} {
|
|
6
6
|
${c}
|
|
7
|
-
${
|
|
8
|
-
`);return`${
|
|
7
|
+
${o} }`}else return Ao(o,E,f)},_=(n,f="")=>{return Object.keys(n).map((E)=>{let c=n[E];if(typeof c==="string"){if(E==="@import")return`@import url('${c}');`;throw Error("top-level string value only allowed for `@import`")}let m=Object.keys(c).map((i)=>bf(i,c[i])).join(`
|
|
8
|
+
`);return`${f}${E} {
|
|
9
9
|
${m}
|
|
10
10
|
}`}).join(`
|
|
11
11
|
|
|
12
|
-
`)},eo=(n)=>{q("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let o={};for(let f of Object.keys(n)){let i=n[f],c=$(f);o[`--${c}`]=typeof i==="number"&&i!==0?String(i)+"px":i}return o},bo=(n)=>{let o={};for(let f of Object.keys(n)){let i=n[f];if(i instanceof y)o[f]=i.inverseLuminance;else if(typeof i==="string"&&i.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))o[f]=y.fromCss(i).inverseLuminance}return o},wn=new Proxy({},{get(n,o){if(n[o]===void 0){let f="--"+$(o);n[o]=(i)=>`var(${f}, ${i})`}return n[o]}}),Zn=new Proxy({},{get(n,o){if(o==="default")return wn;if(n[o]==null){o=$(o);let[,f,,i,c,m]=o.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",o],r=`--${f}`;if(c!=null){let w=i==null?Number(c)/100:-Number(c)/100;switch(m){case"b":case"s":case"h":case"o":{let E=`--${o}`;y.registerComputedColor(E,r,w,m),n[o]=`var(${E})`}break;case"":n[o]=`calc(var(${r}) * ${w})`;break;default:throw console.error(m),Error(`Unrecognized method ${m} for css variable ${r}`)}}else n[o]=`var(${r})`}return n[o]}});function co(){let n=(o)=>typeof matchMedia<"u"&&matchMedia(o).matches;return{colorScheme:n("(prefers-color-scheme: dark)")?"dark":"light",contrast:n("(prefers-contrast: more)")?"more":n("(prefers-contrast: less)")?"less":n("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:n("(prefers-reduced-motion: reduce)"),reducedTransparency:n("(prefers-reduced-transparency: reduce)"),forcedColors:n("(forced-colors: active)")}}function Po(n){if(typeof matchMedia>"u")return()=>{};let o=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],f=()=>n(co()),i=o.map((c)=>matchMedia(c));for(let c of i)c.addEventListener("change",f);return()=>{for(let c of i)c.removeEventListener("change",f)}}var _o="http://www.w3.org/1998/Math/MathML",ho="http://www.w3.org/2000/svg";var dn={},po=(n,o,f)=>{let i=io($(o),f);if(i.prop.startsWith("--"))n.style.setProperty(i.prop,i.value);else n.style[o]=i.value},Uf=(n)=>{return{toDOM(o,f){po(o,n,f)}}},No=(n,o,f)=>{if(o==="style")if(typeof f==="object")for(let i of Object.keys(f))if(F(f[i]))Q(n,f[i],Uf(i));else po(n,i,f[i]);else n.setAttribute("style",f);else{let i=$(o),c=n.constructor.observedAttributes;if(c?.includes(o)||c?.includes(i))if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f);else if(n[o]!==void 0){let{MathMLElement:r}=globalThis;if(n instanceof SVGElement||r!==void 0&&n instanceof r)n.setAttribute(o,f);else n[o]=f}else if(i==="class")f.split(" ").forEach((r)=>{n.classList.add(r)});else if(n[i]!==void 0)n[i]=f;else if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f)}},qf=(n)=>{return{toDOM(o,f){No(o,n,f)}}},Af=(n,o,f)=>{if(o==="apply")f(n);else if(o.match(/^on[A-Z]/)!=null){let i=o.substring(2).toLowerCase();p(n,i,f)}else if(o==="bind")if((typeof f.binding==="string"?En[f.binding]:f.binding)!==void 0&&f.value!==void 0)Q(n,f.value,f.binding instanceof Function?{toDOM:f.binding}:f.binding);else throw Error("bad binding");else if(o.match(/^bind[A-Z]/)!=null){let i=o.substring(4,5).toLowerCase()+o.substring(5),c=En[i];if(c!==void 0)Q(n,f,c);else throw Error(`${o} is not allowed, bindings.${i} is not defined`)}else if(F(f))Q(n,f,qf(o));else No(n,o,f)},mo=(n,...o)=>{if(dn[n]===void 0){let[c,m]=n.split("|");if(m===void 0)dn[n]=globalThis.document.createElement(c);else dn[n]=globalThis.document.createElementNS(m,c)}let f=dn[n].cloneNode(),i={};for(let c of o)if(c instanceof Element||c instanceof DocumentFragment||typeof c==="string"||typeof c==="number")if(f instanceof HTMLTemplateElement)f.content.append(c);else f.append(c);else if(F(c))f.append(x.span({bindText:c}));else Object.assign(i,c);for(let c of Object.keys(i)){let m=i[c];Af(f,c,m)}return f},Eo=(...n)=>{let o=globalThis.document.createDocumentFragment();for(let f of n)o.append(f);return o},x=new Proxy({fragment:Eo},{get(n,o){if(o=o.replace(/[A-Z]/g,(f)=>`-${f.toLocaleLowerCase()}`),n[o]===void 0)n[o]=(...f)=>mo(o,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Gn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${ho}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Qn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${_o}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}});var jf=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],uf=!0,Kf=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,Rf=(n)=>Kf.test(n),e=(n="",o="")=>{if(n==="")return o;else if(o.match(/^\d+$/)!==null||o.includes("="))return`${n}[${o}]`;else return`${n}.${o}`},lo={};function ro(n,o){if(n!==null&&(typeof n==="object"||typeof n==="function"))return n;return new Proxy(lo,b(o,!0))}var kn=()=>new Proxy({},b("^",!0)),go=!1;function N(){if(!go)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),go=!0}var to=(n)=>{return n===lo},b=(n,o)=>({get(f,i){if(to(f)){let w=()=>j(nn,n);switch(i){case"path":return n;case"value":return w();case"valueOf":case"toJSON":return()=>w();case Symbol.toPrimitive:return(E)=>{let M=w();if(E==="number")return Number(M);if(E==="string")return String(M);return M};case"toString":return()=>String(w());case"observe":return(E)=>{let M=I(n,E);return()=>u(M)};case"on":return(E,M)=>fn()(E,M,w());case"bind":return(E,M,L)=>{on()(E,n,M,L)};case"binding":return(E)=>({bind:{value:n,binding:E}});case"listBinding":return(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))];case U:case"xinValue":case"tosiValue":return N(),w();case J:case"xinPath":case"tosiPath":return N(),n;case Vn:case"tosiObserve":return N(),(E)=>{let M=I(n,E);return()=>u(M)};case bn:case"tosiOn":return N(),(E,M)=>fn()(E,M,w());case en:case"tosiBind":return N(),(E,M,L)=>{on()(E,n,M,L)};case"tosiBinding":return N(),(E)=>({bind:{value:n,binding:E}});case"tosiListBinding":return N(),(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))]}if(typeof i==="string"&&/^\d+$/.test(i)){let E=w();if(typeof E==="string")return E[parseInt(i,10)]}if(i==="length"){let E=w();if(typeof E==="string")return E.length}return}if(o&&!(i in f))switch(i){case"path":return n;case"value":return f.valueOf?f.valueOf():f;case"valueOf":case"toJSON":return()=>f.valueOf?f.valueOf():f;case"observe":return(w)=>{let E=I(n,w);return()=>u(E)};case"on":return(w,E)=>fn()(w,E,H(f));case"bind":return(w,E,M)=>{on()(w,n,E,M)};case"binding":return(w)=>({bind:{value:n,binding:w}});case"listBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}switch(i){case J:case"xinPath":case"tosiPath":return n;case U:case"xinValue":case"tosiValue":return f.valueOf?f.valueOf():f;case Vn:case"xinObserve":case"tosiObserve":return(w)=>{let E=I(n,w);return()=>u(E)};case bn:case"xinOn":case"tosiOn":return(w,E)=>fn()(w,E,H(f));case en:case"xinBind":case"tosiBind":return(w,E,M)=>{on()(w,n,E,M)};case"tosiBinding":return(w)=>({bind:{value:n,binding:w}});case"tosiListBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}if(typeof i==="symbol")return f[i];let c=Object.getOwnPropertyDescriptor(f,i);if(c&&!c.configurable&&!c.writable&&"value"in c)return c.value;let m=i,r=m.match(/^([^.[]+)\.(.+)$/)??m.match(/^([^\]]+)(\[.+)/)??m.match(/^(\[[^\]]+\])\.(.+)$/)??m.match(/^(\[[^\]]+\])\[(.+)$/);if(r!==null){let[,w,E]=r,M=e(n,w),L=j(f,w);return L!==null&&typeof L==="object"?new Proxy(L,b(M,o))[E]:L}if(m.startsWith("[")&&m.endsWith("]"))m=m.substring(1,m.length-1);if(!Array.isArray(f)&&f[m]!==void 0||Array.isArray(f)&&m.includes("=")){let w;if(m.includes("=")){let[E,M]=m.split("=");w=f.find((L)=>`${j(L,E)}`===M)}else w=f[m];if(w instanceof Object){let E=e(n,m);return new Proxy(w instanceof Function?w.bind(f):w,b(E,o))}else return o?ro(w,e(n,m)):w}else if(Array.isArray(f)){let w=f[m];return typeof w==="function"?(...E)=>{let M=E.map((T)=>H(T)),L=w.apply(f,M);if(jf.includes(m))B(n);if(L!=null&&typeof L==="object"){if(m==="find"||m==="findLast"||m==="at"){let T=f.indexOf(L);if(T!==-1)return new Proxy(L,b(e(n,String(T)),o))}}return L}:typeof w==="object"?new Proxy(w,b(e(n,m),o)):o?ro(w,e(n,m)):w}else return o?ro(f[m],e(n,m)):f[m]},set(f,i,c){c=H(c);let m=i===U||i==="xinValue"||i==="tosiValue"||i==="value"&&(to(f)||o),r=m?n:e(n,i);if(uf&&!Rf(r))throw Error(`setting invalid path ${r}`);if(H(X[r])!==c&&Qo(nn,r,c)){B(r);let E=n.match(/^(.+)\[(\d+)\]$/);if(E!==null){let[,M,L]=E,T=parseInt(L,10),D=m?"":`.${i}`,Y=Wo(M,T,f,D);for(let s of Y)B(s)}}return!0}}),l=(n,o)=>{let f=typeof o==="function"?o:X[o];if(typeof f!=="function")throw Error(`observe expects a function or path to a function, ${o} is neither`);return I(n,f)},X=new Proxy(nn,b("",!1));Oo(X);var g=new Proxy(nn,b("",!0));var Sf=16,Bf=100;function vo(n,o){let f=Array.from(n.querySelectorAll(R));if(n.matches(R))f.unshift(n);for(let i of f){let c=O.get(i);for(let m of c){if(m.path.startsWith("^"))m.path=`${o}${m.path.substring(1)}`;if(m.binding.toDOM!=null)m.binding.toDOM(i,X[m.path])}}}class ao{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,o,f={}){if(this.boundElement=n,this.itemToElement=new WeakMap,f.idPath!=null){let i=F(o);if(i!=null)so(i,f.idPath)}if(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=_(i.content.children[0])}else this.template=n.children[0],this.template.remove();if(this.options=f,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),f.virtual!=null)if(cn.observe(this.boundElement),this._update=mn(()=>{this.update(this.array,!0)},Sf),this.boundElement.addEventListener("resize",this._update),f.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}visibleSlice(){let{virtual:n,hiddenProp:o,visibleProp:f}=this.options,i=this.array;if(o!==void 0)i=i.filter((E)=>E[o]!==!0);if(f!==void 0)i=i.filter((E)=>E[f]===!0);if(this.options.filter&&this.needle!==void 0)i=this.options.filter(i,this.needle);let c=0,m=i.length-1,r=0,w=0;if(n!=null&&this.boundElement instanceof HTMLElement){let E=this.boundElement.offsetWidth,M=n.scrollContainer==="window",L,T;if(M){L=window.innerHeight;let C=this.boundElement.getBoundingClientRect();T=Math.max(0,-C.top)}else L=this.boundElement.offsetHeight,T=this.boundElement.scrollTop;let D=n.width!=null?Math.max(1,Math.floor(E/n.width)):n.visibleColumns??1,Y=Math.ceil(L/n.height)+(n.rowChunkSize||1),s=Math.ceil(i.length/D),v=D*Y,Z=Math.floor(T/n.height);if(Z>s-Y+1)Z=Math.max(0,s-Y+1);if(n.rowChunkSize)Z-=Z%n.rowChunkSize;c=Z*D,m=c+v-1,r=Z*n.height,w=Math.max((s-Y)*n.height-r,0)}return{items:i,firstItem:c,lastItem:m,topBuffer:r,bottomBuffer:w}}needle;filter=mn((n)=>{if(this.needle!==n)this.needle=n,this.update(this.array)},Bf);update(n,o){if(n==null)n=[];this.array=n;let{hiddenProp:f,visibleProp:i}=this.options,c=F(n),m=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",m.items.length===0);let r=this._previousSlice,{firstItem:w,lastItem:E,topBuffer:M,bottomBuffer:L}=m;if(f===void 0&&i===void 0&&o===!0&&r!=null&&w===r.firstItem&&E===r.lastItem&&M===r.topBuffer&&L===r.bottomBuffer)return;this._previousSlice=m;let T=0,D=0,Y=0;for(let C of Array.from(this.boundElement.children)){if(C===this.listTop||C===this.listBottom)continue;let k=C[Hn];if(k==null)C.remove();else{let d=m.items.indexOf(k);if(d<w||d>E)C.remove(),this.itemToElement.delete(k),T++}}this.listTop.style.height=String(M)+"px",this.listBottom.style.height=String(L)+"px";let s=[],{idPath:v}=this.options;for(let C=w;C<=E;C++){let k=m.items[C];if(k===void 0)continue;let d=this.itemToElement.get(H(k));if(d==null){if(Y++,d=_(this.template),typeof k==="object")this.itemToElement.set(H(k),d),d[Hn]=H(k);if(this.boundElement.insertBefore(d,this.listBottom),v!=null){let un=k[v],Mf=`${c}[${v}=${un}]`;vo(d,Mf)}else{let un=`${c}[${C}]`;vo(d,un)}}s.push(d)}let Z=null;for(let C of s){if(C.previousElementSibling!==Z)if(D++,Z?.nextElementSibling!=null)this.boundElement.insertBefore(C,Z.nextElementSibling);else this.boundElement.insertBefore(C,this.listBottom);Z=C}if(S.perf)console.log(c,"updated",{removed:T,created:Y,moved:D})}}var rn=(n,o,f)=>{let i=n[a];if(o&&i===void 0)i=new ao(n,o,f),n[a]=i;return i},Wn=(n)=>{let o;while(!(o=n[Hn])&&n&&n.parentElement)n=n.parentElement;return o?{element:n,item:o}:void 0},zn=(n)=>{let o=Wn(n);return o?o.item:void 0},nf=(n)=>{let o=Wn(n);if(!o)return console.error("deleteListItem failed, element is not part of a list instance",n),!1;let f=rn(o.element.parentElement);if(!f.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",n.parentElement,f),!1;let i=f.array.indexOf(o.item);if(i>-1)return f.array.splice(i,1),!0;return!1};var{document:Mn,MutationObserver:of}=globalThis,On=(n,o)=>{let f=O.get(n);if(f==null)return;for(let i of f){let{binding:c,options:m}=i,{path:r}=i,{toDOM:w}=c;if(w!=null){if(r.startsWith("^")){let E=zn(n);if(E!=null&&E[J]!=null)r=i.path=`${E[J]}${r.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${r}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${r}`)}if(o==null||r.startsWith(o))w(n,Dn()[r],m)}}};if(of!=null)new of((o)=>{o.forEach((f)=>{Array.from(f.addedNodes).forEach((i)=>{if(i instanceof Element)Array.from(i.querySelectorAll(R)).forEach((c)=>On(c))})})}).observe(Mn.body,{subtree:!0,childList:!0});I(()=>!0,(n)=>{let o=Array.from(Mn.querySelectorAll(R));for(let f of o)On(f,n)});var ff=(n)=>{let o=n.target?.closest(R);while(o!=null){let f=O.get(o);for(let i of f){let{binding:c,path:m}=i,{fromDOM:r}=c;if(r!=null){let w;try{w=r(o,i.options)}catch(E){throw console.error("Cannot get value from",o,"via",i),Error("Cannot obtain value fromDOM")}if(w!=null){let E=Dn(),M=E[m];if(M==null)E[m]=w;else{let L=M[J]!=null?M[U]:M,T=w[J]!=null?w[U]:w;if(L!==T)E[m]=T}}}}o=o.parentElement.closest(R)}};if(globalThis.document!=null)Mn.body.addEventListener("change",ff,!0),Mn.body.addEventListener("input",ff,!0);function Q(n,o,f,i){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let c;if(typeof o==="object"&&o[J]===void 0&&i===void 0){let{value:w}=o;c=typeof w==="string"?w:w[J],i=o,delete i.value}else c=typeof o==="string"?o:o[J];if(c==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:m}=f;n.classList?.add(Sn);let r=O.get(n);if(r==null)r=[],O.set(n,r);if(r.push({path:c,binding:f,options:i}),m!=null&&!c.startsWith("^"))B(c);if(i?.filter&&i?.needle)Q(n,i.needle,{toDOM(w,E){console.log({needle:E}),w[a]?.filter(E)}});return n}var cf=new Set,If=(n)=>{let o=n?.target?.closest(In),f=!1,i=new Proxy(n,{get(m,r){if(r==="stopPropagation")return()=>{n.stopPropagation(),f=!0};else{let w=m[r];return typeof w==="function"?w.bind(m):w}}}),c=new Set;while(!f&&o!=null){let r=P.get(o)[n.type]||c;for(let w of r){if(typeof w==="function")w(i);else{let E=Dn()[w];if(typeof E==="function")E(i);else throw Error(`no event handler found at path ${w}`)}if(f)continue}o=o.parentElement!=null?o.parentElement.closest(In):null}};function p(n,o,f){let i=P.get(n);if(n.classList.add(Bn),i==null)i={},P.set(n,i);if(!i[o])i[o]=new Set;if(i[o].add(f),!cf.has(o))cf.add(o),Mn.body.addEventListener(o,If,!0);return()=>{i[o].delete(f)}}Uo(Q,p);function Un(n,o){if(!n.internals)return;let f={},i="";if(n.hasAttribute("required")&&o==="")f.valueMissing=!0,i="Please fill out this field.";let c=n.getAttribute("minlength");if(c&&o.length<parseInt(c,10))f.tooShort=!0,i=`Please use at least ${c} characters.`;let m=n.getAttribute("maxlength");if(m&&o.length>parseInt(m,10))f.tooLong=!0,i=`Please use no more than ${m} characters.`;let r=n.getAttribute("pattern");if(r&&o!=="")try{if(!new RegExp(`^(?:${r})$`).test(o))f.patternMismatch=!0,i="Please match the requested format."}catch{}if(Object.keys(f).length>0)n.internals.setValidity(f,i,n);else n.internals.setValidity({})}var Vf=0;function wo(){return`custom-elt${(Vf++).toString(36)}`}var mf=0,Mo=null;function ef(){if(Mo===null)Mo=new MutationObserver((n)=>{let o=new Set;for(let f of n)if(f.type==="attributes"&&f.target instanceof W){let i=f.target,c=fo(f.attributeName);if(i._legacyTrackedAttrs?.has(c))o.add(i)}for(let f of o)f.queueRender(!1)});return Mo}var yn={};function bf(n,o){let f=yn[n],i=V(o).replace(/:host\(([^)]+)\)/g,`${n}$1`).replace(/:host\b/g,n);yn[n]=f?f+`
|
|
13
|
-
`+
|
|
12
|
+
`)},hf=(n)=>{d("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let f={};for(let o of Object.keys(n)){let E=n[o],c=G(o);f[`--${c}`]=typeof E==="number"&&E!==0?String(E)+"px":E}return f},Nf=(n)=>{let f={};for(let o of Object.keys(n)){let E=n[o];if(E instanceof x)f[o]=E.inverseLuminance;else if(typeof E==="string"&&E.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))f[o]=x.fromCss(E).inverseLuminance}return f},xn=new Proxy({},{get(n,f){if(n[f]===void 0){let o="--"+G(f);n[f]=(E)=>`var(${o}, ${E})`}return n[f]}}),zn=new Proxy({},{get(n,f){if(f==="default")return xn;if(n[f]==null){f=G(f);let[,o,,E,c,m]=f.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",f],i=`--${o}`;if(c!=null){let y=E==null?Number(c)/100:-Number(c)/100;switch(m){case"b":case"s":case"h":case"o":{let M=`--${f}`;x.registerComputedColor(M,i,y,m),n[f]=`var(${M})`}break;case"":n[f]=`calc(var(${i}) * ${y})`;break;default:throw console.error(m),Error(`Unrecognized method ${m} for css variable ${i}`)}}else n[f]=`var(${i})`}return n[f]}});function mf(){let n=(f)=>typeof matchMedia<"u"&&matchMedia(f).matches;return{colorScheme:n("(prefers-color-scheme: dark)")?"dark":"light",contrast:n("(prefers-contrast: more)")?"more":n("(prefers-contrast: less)")?"less":n("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:n("(prefers-reduced-motion: reduce)"),reducedTransparency:n("(prefers-reduced-transparency: reduce)"),forcedColors:n("(forced-colors: active)")}}function pf(n){if(typeof matchMedia>"u")return()=>{};let f=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],o=()=>n(mf()),E=f.map((c)=>matchMedia(c));for(let c of E)c.addEventListener("change",o);return()=>{for(let c of E)c.removeEventListener("change",o)}}var gf="http://www.w3.org/1998/Math/MathML",ef="http://www.w3.org/2000/svg";var Wn={},vf=(n,f,o)=>{let E=Mf(G(f),o);if(E.prop.startsWith("--"))n.style.setProperty(E.prop,E.value);else n.style[f]=E.value},jo=(n)=>{return{toDOM(f,o){vf(f,n,o)}}},tf=(n,f,o)=>{if(f==="style")if(typeof o==="object")for(let E of Object.keys(o))if(k(o[E]))q(n,o[E],jo(E));else vf(n,E,o[E]);else n.setAttribute("style",o);else{let E=G(f),c=n.constructor.observedAttributes;if(c?.includes(f)||c?.includes(E))if(typeof o==="boolean")o?n.setAttribute(E,""):n.removeAttribute(E);else n.setAttribute(E,o);else if(n[f]!==void 0){let{MathMLElement:i}=globalThis;if(n instanceof SVGElement||i!==void 0&&n instanceof i)n.setAttribute(f,o);else n[f]=o}else if(E==="class")o.split(" ").forEach((i)=>{n.classList.add(i)});else if(n[E]!==void 0)n[E]=o;else if(typeof o==="boolean")o?n.setAttribute(E,""):n.removeAttribute(E);else n.setAttribute(E,o)}},Ko=(n)=>{return{toDOM(f,o){tf(f,n,o)}}},Bo=(n,f,o)=>{if(f==="apply")o(n);else if(f.match(/^on[A-Z]/)!=null){let E=f.substring(2).toLowerCase();v(n,E,o)}else if(f==="bind")if((typeof o.binding==="string"?Ln[o.binding]:o.binding)!==void 0&&o.value!==void 0)q(n,o.value,o.binding instanceof Function?{toDOM:o.binding}:o.binding);else throw Error("bad binding");else if(f.match(/^bind[A-Z]/)!=null){let E=f.substring(4,5).toLowerCase()+f.substring(5),c=Ln[E];if(c!==void 0)q(n,o,c);else throw Error(`${f} is not allowed, bindings.${E} is not defined`)}else if(k(o))q(n,o,Ko(f));else tf(n,f,o)},yf=(n,...f)=>{if(Wn[n]===void 0){let[c,m]=n.split("|");if(m===void 0)Wn[n]=globalThis.document.createElement(c);else Wn[n]=globalThis.document.createElementNS(m,c)}let o=Wn[n].cloneNode(),E={};for(let c of f)if(c instanceof Element||c instanceof DocumentFragment||typeof c==="string"||typeof c==="number")if(o instanceof HTMLTemplateElement)o.content.append(c);else o.append(c);else if(k(c))o.append(r.span({bindText:c}));else Object.assign(E,c);for(let c of Object.keys(E)){let m=E[c];Bo(o,c,m)}return o},Lf=(...n)=>{let f=globalThis.document.createDocumentFragment();for(let o of n)f.append(o);return f},r=new Proxy({fragment:Lf},{get(n,f){if(f=f.replace(/[A-Z]/g,(o)=>`-${o.toLocaleLowerCase()}`),n[f]===void 0)n[f]=(...o)=>yf(f,...o);return n[f]},set(){throw Error("You may not add new properties to elements")}}),sn=new Proxy({fragment:Lf},{get(n,f){if(n[f]===void 0)n[f]=(...o)=>yf(`${f}|${ef}`,...o);return n[f]},set(){throw Error("You may not add new properties to elements")}}),qn=new Proxy({fragment:Lf},{get(n,f){if(n[f]===void 0)n[f]=(...o)=>yf(`${f}|${gf}`,...o);return n[f]},set(){throw Error("You may not add new properties to elements")}});var So=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],Io=!0,uo=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,Ro=(n)=>uo.test(n),b=(n="",f="")=>{if(n==="")return f;else if(f.match(/^\d+$/)!==null||f.includes("="))return`${n}[${f}]`;else return`${n}.${f}`},no={};function xf(n,f){if(n!==null&&(typeof n==="object"||typeof n==="function"))return n;return new Proxy(no,h(f,!0))}var On=()=>new Proxy({},h("^",!0)),lf=!1;function t(){if(!lf)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),lf=!0}var af=(n)=>{return n===no},h=(n,f)=>({get(o,E){if(af(o)){let y=()=>B(En,n);switch(E){case"path":return n;case"value":return y();case"valueOf":case"toJSON":return()=>y();case Symbol.toPrimitive:return(M)=>{let L=y();if(M==="number")return Number(L);if(M==="string")return String(L);return L};case"toString":return()=>String(y());case"observe":return(M)=>{let L=P(n,M);return()=>S(L)};case"on":return(M,L)=>Mn()(M,L,y());case"bind":return(M,L,w)=>{cn()(M,n,L,w)};case"binding":return(M)=>({bind:{value:n,binding:M}});case"listBinding":return(M=({span:w})=>w({bindText:"^"}),L={})=>[{bindList:{value:n,...L}},r.template(M(r,On()))];case j:case"xinValue":case"tosiValue":return t(),y();case W:case"xinPath":case"tosiPath":return t(),n;case _n:case"tosiObserve":return t(),(M)=>{let L=P(n,M);return()=>S(L)};case hn:case"tosiOn":return t(),(M,L)=>Mn()(M,L,y());case bn:case"tosiBind":return t(),(M,L,w)=>{cn()(M,n,L,w)};case"tosiBinding":return t(),(M)=>({bind:{value:n,binding:M}});case"tosiListBinding":return t(),(M=({span:w})=>w({bindText:"^"}),L={})=>[{bindList:{value:n,...L}},r.template(M(r,On()))]}if(typeof E==="string"&&/^\d+$/.test(E)){let M=y();if(typeof M==="string")return M[parseInt(E,10)]}if(E==="length"){let M=y();if(typeof M==="string")return M.length}return}if(f&&!(E in o))switch(E){case"path":return n;case"value":return o.valueOf?o.valueOf():o;case"valueOf":case"toJSON":return()=>o.valueOf?o.valueOf():o;case"observe":return(y)=>{let M=P(n,y);return()=>S(M)};case"on":return(y,M)=>Mn()(y,M,$(o));case"bind":return(y,M,L)=>{cn()(y,n,M,L)};case"binding":return(y)=>({bind:{value:n,binding:y}});case"listBinding":return(y=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},r.template(y(r,On()))]}switch(E){case W:case"xinPath":case"tosiPath":return n;case j:case"xinValue":case"tosiValue":return o.valueOf?o.valueOf():o;case _n:case"xinObserve":case"tosiObserve":return(y)=>{let M=P(n,y);return()=>S(M)};case hn:case"xinOn":case"tosiOn":return(y,M)=>Mn()(y,M,$(o));case bn:case"xinBind":case"tosiBind":return(y,M,L)=>{cn()(y,n,M,L)};case"tosiBinding":return(y)=>({bind:{value:n,binding:y}});case"tosiListBinding":return(y=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},r.template(y(r,On()))]}if(typeof E==="symbol")return o[E];let c=Object.getOwnPropertyDescriptor(o,E);if(c&&!c.configurable&&!c.writable&&"value"in c)return c.value;let m=E,i=m.match(/^([^.[]+)\.(.+)$/)??m.match(/^([^\]]+)(\[.+)/)??m.match(/^(\[[^\]]+\])\.(.+)$/)??m.match(/^(\[[^\]]+\])\[(.+)$/);if(i!==null){let[,y,M]=i,L=b(n,y),w=B(o,y);return w!==null&&typeof w==="object"?new Proxy(w,h(L,f))[M]:w}if(m.startsWith("[")&&m.endsWith("]"))m=m.substring(1,m.length-1);if(!Array.isArray(o)&&o[m]!==void 0||Array.isArray(o)&&m.includes("=")){let y;if(m.includes("=")){let[M,L]=m.split("=");y=o.find((w)=>`${B(w,M)}`===L)}else y=o[m];if(y instanceof Object){let M=b(n,m);return new Proxy(y instanceof Function?y.bind(o):y,h(M,f))}else return f?xf(y,b(n,m)):y}else if(Array.isArray(o)){let y=o[m];return typeof y==="function"?(...M)=>{let L=M.map((H)=>$(H)),w=y.apply(o,L);if(So.includes(m))V(n);if(w!=null&&typeof w==="object"){if(m==="find"||m==="findLast"||m==="at"){let H=o.indexOf(w);if(H!==-1)return new Proxy(w,h(b(n,String(H)),f))}}return w}:typeof y==="object"?new Proxy(y,h(b(n,m),f)):f?xf(y,b(n,m)):y}else return f?xf(o[m],b(n,m)):o[m]},set(o,E,c){c=$(c);let m=E===j||E==="xinValue"||E==="tosiValue"||E==="value"&&(af(o)||f),i=m?n:b(n,E);if(Io&&!Ro(i))throw Error(`setting invalid path ${i}`);if($(Q[i])!==c&&qf(En,i,c)){V(i);let M=n.match(/^(.+)\[(\d+)\]$/);if(M!==null){let[,L,w]=M,H=parseInt(w,10),T=m?"":`.${E}`,J=Uf(L,H,o,T);for(let C of J)V(C)}}return!0}}),on=(n,f)=>{let o=typeof f==="function"?f:Q[f];if(typeof o!=="function")throw Error(`observe expects a function or path to a function, ${f} is neither`);return P(n,o)},Q=new Proxy(En,h("",!1));jf(Q);var l=new Proxy(En,h("",!0));var Vo=16,Po=100;function fo(n,f){let o=Array.from(n.querySelectorAll(u));if(n.matches(u))o.unshift(n);for(let E of o){let c=A.get(E);for(let m of c){if(m.path.startsWith("^"))m.path=`${f}${m.path.substring(1)}`;if(m.binding.toDOM!=null)m.binding.toDOM(E,Q[m.path])}}}class oo{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,f,o={}){if(this.boundElement=n,this.itemToElement=new WeakMap,o.idPath!=null){let E=k(f);if(E!=null)Df(E,o.idPath)}if(n.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(n.children[0]instanceof HTMLTemplateElement){let E=n.children[0];if(E.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=g(E.content.children[0])}else this.template=n.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),this.boundElement[a]=this,o.virtual!=null)if(mn.observe(this.boundElement),this._update=yn(()=>{this.update(this.array,!0)},Vo),this.boundElement.addEventListener("resize",this._update),o.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){let{hiddenProp:n,visibleProp:f}=this.options,o=this.array;if(n!==void 0)o=o.filter((E)=>E[n]!==!0);if(f!==void 0)o=o.filter((E)=>E[f]===!0);if(this.options.filter&&this.needle!==void 0)o=this.options.filter(o,this.needle);return o}visibleSlice(){let{virtual:n}=this.options,f=this.filteredArray(),o=0,E=f.length-1,c=0,m=0;if(n!=null&&this.boundElement instanceof HTMLElement){let i=this.boundElement.offsetWidth,y=n.scrollContainer==="window",M,L;if(y){M=window.innerHeight;let T=this.boundElement.getBoundingClientRect();L=Math.max(0,-T.top)}else M=this.boundElement.offsetHeight,L=this.boundElement.scrollTop;let w=n.width!=null?Math.max(1,Math.floor(i/n.width)):n.visibleColumns??1,H=Math.ceil(f.length/w);if(n.minHeight!=null){let T=n.minHeight,J=Math.ceil(M/T)+(n.rowChunkSize||1),C=w*J,D=H*T,F=Math.max(0,D-M),z=F>0?Math.min(1,Math.max(0,L/F)):0,X=Math.max(0,H-J+1),Y=z*X,Z=Math.floor(Y);if(n.rowChunkSize)Z-=Z%n.rowChunkSize;return o=Z*w,E=o+C-1,c=L,m=Math.max(0,D-L-M),{items:f,firstItem:o,lastItem:E,topBuffer:c,bottomBuffer:m,interpolation:{t:z,position:Y,scrollTop:L,viewportHeight:M,totalScrollHeight:D,rowHeight:n.height}}}else{let T=Math.ceil(M/n.height)+(n.rowChunkSize||1),J=w*T,C=Math.floor(L/n.height);if(C>H-T+1)C=Math.max(0,H-T+1);if(n.rowChunkSize)C-=C%n.rowChunkSize;o=C*w,E=o+J-1,c=C*n.height,m=Math.max((H-T)*n.height-c,0)}}return{items:f,firstItem:o,lastItem:E,topBuffer:c,bottomBuffer:m}}needle;filter=yn((n)=>{if(this.needle!==n)this.needle=n,this.update(this.array)},Po);update(n,f){if(n==null)n=[];this.array=n;let{hiddenProp:o,visibleProp:E}=this.options,c=k(n),m=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",m.items.length===0);let i=this._previousSlice,{firstItem:y,lastItem:M,topBuffer:L,bottomBuffer:w}=m,H=o===void 0&&E===void 0&&f===!0&&i!=null&&y===i.firstItem&&M===i.lastItem;if(H&&m.interpolation==null&&L===i.topBuffer&&w===i.bottomBuffer)return;if(H&&m.interpolation!=null){this._updateInterpolatedBuffers(m);return}this._previousSlice=m;let T=0,J=0,C=0;for(let X of Array.from(this.boundElement.children)){if(X===this.listTop||X===this.listBottom)continue;let Y=X[Dn];if(Y==null)X.remove();else{let Z=m.items.indexOf(Y);if(Z<y||Z>M)X.remove(),this.itemToElement.delete(Y),T++}}this.listTop.style.height=String(L)+"px",this.listBottom.style.height=String(w)+"px";let D=[],{idPath:F}=this.options;for(let X=y;X<=M;X++){let Y=m.items[X];if(Y===void 0)continue;let Z=this.itemToElement.get($(Y));if(Z==null){if(C++,Z=g(this.template),typeof Y==="object")this.itemToElement.set($(Y),Z),Z[Dn]=$(Y);if(this.boundElement.insertBefore(Z,this.listBottom),F!=null){let N=Y[F],Fn=`${c}[${F}=${N}]`;fo(Z,Fn)}else{let N=`${c}[${X}]`;fo(Z,N)}}D.push(Z)}let z=null;for(let X of D){if(X.previousElementSibling!==z)if(J++,z?.nextElementSibling!=null)this.boundElement.insertBefore(X,z.nextElementSibling);else this.boundElement.insertBefore(X,this.listBottom);z=X}if(m.interpolation!=null)this._updateInterpolatedBuffers(m);if(R.perf)console.log(c,"updated",{removed:T,created:C,moved:J})}_updateInterpolatedBuffers(n){let{t:f,position:o,scrollTop:E,viewportHeight:c,totalScrollHeight:m,rowHeight:i}=n.interpolation,y=0;for(let H of Array.from(this.boundElement.children)){if(H===this.listTop||H===this.listBottom)continue;y+=H.offsetHeight||i}let M=E,L=E+c-y,w=Math.max(0,f*L+(1-f)*M-o%1*i);this.listTop.style.height=String(w)+"px",this.listBottom.style.height=String(Math.max(0,m-w-y))+"px"}}var nn=(n,f,o)=>{let E=n[a];if(f&&E===void 0)E=new oo(n,f,o),n[a]=E;return E},Un=(n)=>{let f;while(!(f=n[Dn])&&n&&n.parentElement)n=n.parentElement;return f?{element:n,item:f}:void 0},An=(n)=>{let f=Un(n);return f?f.item:void 0},Eo=(n)=>{let f=Un(n);if(!f)return console.error("deleteListItem failed, element is not part of a list instance",n),!1;let o=nn(f.element.parentElement);if(!o.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",n.parentElement,o),!1;let E=o.array.indexOf(f.item);if(E>-1)return o.array.splice(E,1),!0;return!1},_o={start:"start",middle:"center",end:"end",nearest:"nearest"},co=(n,f,o={})=>{let E=nn(n);if(E==null)return console.error("scrollListItemIntoView failed, element has no list binding",n),!1;let{position:c="middle"}=o,m=E.filteredArray(),i=$(f)??f,y=m.indexOf(i);if(y===-1)return console.error("scrollListItemIntoView failed, item not found in list",f),!1;let{virtual:M}=E.options;if(M!=null&&n instanceof HTMLElement){let L=M.width!=null?Math.max(1,Math.floor(n.offsetWidth/M.width)):M.visibleColumns??1,w=Math.floor(y/L),H=M.minHeight??M.height,T=Math.ceil(m.length/L),J=M.scrollContainer==="window",C=J?window.innerHeight:n.offsetHeight,D;if(M.minHeight!=null){let F=Math.ceil(C/H)+(M.rowChunkSize||1),z=T*H,X=Math.max(0,z-C),Y=Math.max(1,T-F+1),Z=w/Y;switch(c){case"start":D=Z*X;break;case"end":D=Math.max(0,(w-F+1)/Y*X);break;case"nearest":{let N=J?Math.max(0,-n.getBoundingClientRect().top):n.scrollTop,Fn=X>0?N/X:0,rf=Math.floor(Fn*Y);if(w<rf)D=Z*X;else if(w>=rf+F)D=Math.max(0,(w-F+1)/Y*X);else return!0;break}default:{let N=w-Math.floor(F/2);D=Math.max(0,N)/Y*X}}}else{let F=w*M.height;switch(c){case"start":D=F;break;case"end":D=F-C+M.height;break;case"nearest":{let z=J?Math.max(0,-n.getBoundingClientRect().top):n.scrollTop;if(F<z)D=F;else if(F+M.height>z+C)D=F-C+M.height;else return!0;break}default:D=F-(C-M.height)/2}}if(D=Math.max(0,D),J){let F=n.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:F+D,behavior:"smooth"})}else n.scrollTo({top:D,behavior:"smooth"})}else{let L=E.itemToElement.get(i);if(L==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",f),!1;L.scrollIntoView({block:_o[c]??"center",behavior:"smooth"})}return!0};var{document:wn,MutationObserver:Mo}=globalThis,jn=(n,f)=>{let o=A.get(n);if(o==null)return;for(let E of o){let{binding:c,options:m}=E,{path:i}=E,{toDOM:y}=c;if(y!=null){if(i.startsWith("^")){let M=An(n);if(M!=null&&M[W]!=null)i=E.path=`${M[W]}${i.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${i}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${i}`)}if(f==null||i.startsWith(f))y(n,Zn()[i],m)}}};if(Mo!=null)new Mo((f)=>{f.forEach((o)=>{Array.from(o.addedNodes).forEach((E)=>{if(E instanceof Element)Array.from(E.querySelectorAll(u)).forEach((c)=>jn(c))})})}).observe(wn.body,{subtree:!0,childList:!0});P(()=>!0,(n)=>{let f=Array.from(wn.querySelectorAll(u));for(let o of f)jn(o,n)});var mo=(n)=>{let f=n.target?.closest(u);while(f!=null){let o=A.get(f);for(let E of o){let{binding:c,path:m}=E,{fromDOM:i}=c;if(i!=null){let y;try{y=i(f,E.options)}catch(M){throw console.error("Cannot get value from",f,"via",E),Error("Cannot obtain value fromDOM")}if(y!=null){let M=Zn(),L=M[m];if(L==null)M[m]=y;else{let w=L[W]!=null?L[j]:L,H=y[W]!=null?y[j]:y;if(w!==H)M[m]=H}}}}f=f.parentElement.closest(u)}};if(globalThis.document!=null)wn.body.addEventListener("change",mo,!0),wn.body.addEventListener("input",mo,!0);function q(n,f,o,E){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let c;if(typeof f==="object"&&f[W]===void 0&&E===void 0){let{value:y}=f;c=typeof y==="string"?y:y[W],E=f,delete E.value}else c=typeof f==="string"?f:f[W];if(c==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:m}=o;n.classList?.add(Rn);let i=A.get(n);if(i==null)i=[],A.set(n,i);if(i.push({path:c,binding:o,options:E}),m!=null&&!c.startsWith("^"))V(c);if(E?.filter&&E?.needle)q(n,E.needle,{toDOM(y,M){console.log({needle:M}),y[a]?.filter(M)}});return n}var io=new Set,bo=(n)=>{let f=n?.target?.closest(Pn),o=!1,E=new Proxy(n,{get(m,i){if(i==="stopPropagation")return()=>{n.stopPropagation(),o=!0};else{let y=m[i];return typeof y==="function"?y.bind(m):y}}}),c=new Set;while(!o&&f!=null){let i=p.get(f)[n.type]||c;for(let y of i){if(typeof y==="function")y(E);else{let M=Zn()[y];if(typeof M==="function")M(E);else throw Error(`no event handler found at path ${y}`)}if(o)continue}f=f.parentElement!=null?f.parentElement.closest(Pn):null}};function v(n,f,o){let E=p.get(n);if(n.classList.add(Vn),E==null)E={},p.set(n,E);if(!E[f])E[f]=new Set;if(E[f].add(o),!io.has(f))io.add(f),wn.body.addEventListener(f,bo,!0);return()=>{E[f].delete(o)}}df(q,v);function dn(n,f){if(!n.internals)return;let o={},E="";if(n.hasAttribute("required")&&f==="")o.valueMissing=!0,E="Please fill out this field.";let c=n.getAttribute("minlength");if(c&&f.length<parseInt(c,10))o.tooShort=!0,E=`Please use at least ${c} characters.`;let m=n.getAttribute("maxlength");if(m&&f.length>parseInt(m,10))o.tooLong=!0,E=`Please use no more than ${m} characters.`;let i=n.getAttribute("pattern");if(i&&f!=="")try{if(!new RegExp(`^(?:${i})$`).test(f))o.patternMismatch=!0,E="Please match the requested format."}catch{}if(Object.keys(o).length>0)n.internals.setValidity(o,E,n);else n.internals.setValidity({})}var ho=0;function wf(){return`custom-elt${(ho++).toString(36)}`}var yo=0,Cf=null;function No(){if(Cf===null)Cf=new MutationObserver((n)=>{let f=new Set;for(let o of n)if(o.type==="attributes"&&o.target instanceof O){let E=o.target,c=cf(o.attributeName);if(E._legacyTrackedAttrs?.has(c))f.add(E)}for(let o of f)o.queueRender(!1)});return Cf}var Cn={};function po(n,f){let o=Cn[n],E=_(f).replace(/:host\(([^)]+)\)/g,`${n}$1`).replace(/:host\b/g,n);Cn[n]=o?o+`
|
|
13
|
+
`+E:E}function go(n){if(Cn[n])document.head.append(r.style({id:n+"-component"},Cn[n]));delete Cn[n]}class O extends HTMLElement{static elements=r;static _elementCreator;static initAttributes;static formAssociated;internals;get validity(){return this.internals?.validity}get validationMessage(){return this.internals?.validationMessage??""}get willValidate(){return this.internals?.willValidate??!1}checkValidity(){return this.internals?.checkValidity()??!0}reportValidity(){return this.internals?.reportValidity()??!0}setCustomValidity(n){if(this.internals)if(n)this.internals.setValidity({customError:!0},n);else this.internals.setValidity({})}setValidity(n,f,o){this.internals?.setValidity(n,f,o)}setFormValue(n,f){this.internals?.setFormValue(n,f)}static get observedAttributes(){let n=this.initAttributes;if(n)return["hidden",...Object.keys(n).map(G)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=r.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(n){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),r.style(_(n))}static elementCreator(n={}){let f=this;if(f._elementCreator==null){let{tag:o,styleSpec:E}=n,c=n!=null?o:null;if(c==null)if(typeof f.name==="string"&&f.name!==""){if(c=G(f.name),c.startsWith("-"))c=c.slice(1)}else c=wf();if(customElements.get(c)!=null)console.warn(`${c} is already defined`);if(c.match(/\w+(-\w+)+/)==null)console.warn(`${c} is not a legal tag for a custom-element`),c=wf();while(customElements.get(c)!==void 0)c=wf();if(f._tagName=c,E!==void 0)po(c,E);window.customElements.define(c,this,n),f._elementCreator=r[c]}return f._elementCreator}initAttributes(...n){if(d("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let c of n)this._legacyTrackedAttrs.add(c);No().observe(this,{attributes:!0});let o={},E={};n.forEach((c)=>{o[c]=U(this[c]);let m=G(c);Object.defineProperty(this,c,{enumerable:!1,get(){if(typeof o[c]==="boolean")return this.hasAttribute(m);else if(this.hasAttribute(m))return typeof o[c]==="number"?parseFloat(this.getAttribute(m)):this.getAttribute(m);else if(E[c]!==void 0)return E[c];else return o[c]},set(i){if(typeof o[c]==="boolean"){if(i!==this[c]){if(i)this.setAttribute(m,"");else this.removeAttribute(m);this.queueRender()}}else if(typeof o[c]==="number"){if(i!==parseFloat(this[c]))this.setAttribute(m,i),this.queueRender()}else if(typeof i==="object"||`${i}`!==`${this[c]}`){if(i===null||i===void 0||typeof i==="object")this.removeAttribute(m);else this.setAttribute(m,i);this.queueRender(),E[c]=i}}})})}initValue(){let n=Object.getOwnPropertyDescriptor(this,"value");if(n===void 0||n.get!==void 0||n.set!==void 0)return;let f=this.hasAttribute("value")?this.getAttribute("value"):U(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return f},set(o){if(f!==o)f=o,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let n=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(f,o){if(f[o]===void 0){let E=n.querySelector(`[part="${o}"]`);if(E==null)E=n.querySelector(o);if(E==null)throw Error(`elementRef "${o}" does not exist!`);E.removeAttribute("data-ref"),f[o]=E}return f[o]}});return this._parts}attributeChangedCallback(n,f,o){let E=cf(n);if(!this._legacyTrackedAttrs?.has(E))this.queueRender(!1)}constructor(){super();if(yo+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let n=this.constructor.initAttributes;if(n)this._setupAttributeAccessors(n);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${yo}`,this._value=U(this.defaultValue)}_setupAttributeAccessors(n){if(!this._attrValues)this._attrValues=new Map;for(let f of Object.keys(n)){let o=G(f),E=n[f];if(f==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof E==="object"&&E!==null){console.warn(`${this.tagName}: initAttributes.${f} is an object. Use a regular property instead.`);continue}let c=this,m=!1;while(c){let i=Object.getOwnPropertyDescriptor(c,f);if(i){if(!i.configurable||i.get||i.set){m=!0;break}break}c=Object.getPrototypeOf(c)}if(m)continue;Object.defineProperty(this,f,{enumerable:!1,get:()=>{if(typeof E==="boolean")return this.hasAttribute(o);else if(this.hasAttribute(o))return typeof E==="number"?parseFloat(this.getAttribute(o)):this.getAttribute(o);else if(this._attrValues.has(f))return this._attrValues.get(f);else return E},set:(i)=>{if(typeof E==="boolean"){if(i!==this[f]){if(i)this.setAttribute(o,"");else this.removeAttribute(o);this.queueRender()}}else if(typeof E==="number"){if(i!==parseFloat(this[f]))this.setAttribute(o,i),this.queueRender()}else if(typeof i==="object"||`${i}`!==`${this[f]}`){if(i===null||i===void 0||typeof i==="object")this.removeAttribute(o);else this.setAttribute(o,i);this.queueRender(),this._attrValues.set(f,i)}}})}}connectedCallback(){if(go(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.constructor.formAssociated&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.onResize!==void 0){if(mn.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");if(this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this.queueRender()}disconnectedCallback(){mn.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(n){if(n)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(n){if(this.value!==void 0&&typeof n==="string")this.value=n}_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){if(of(this,"change"),this.internals&&this.value!==void 0)this.internals.setFormValue(this.value)}this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let n=typeof this.content!=="function",f=typeof this.content==="function"?this.content(r):this.content,{styleSpec:o}=this.constructor,{styleNode:E}=this.constructor;if(o)E=this.constructor.styleNode=r.style(_(o)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),E=this.styleNode;if(E){let c=this.attachShadow({mode:"open"});c.appendChild(E.cloneNode(!0)),Ef(c,f,n)}else if(f!==null){let c=Array.from(this.childNodes);Ef(this,f,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let m=Array.from(this.querySelectorAll("slot"));if(m.length>0)m.forEach(Hf.replaceSlot);if(c.length>0){let i={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((y)=>{i[y.name]=y}),c.forEach((y)=>{let M=i[""],L=y instanceof Element?i[y.slot]:M;(L!==void 0?L:M).append(y)})}}this._hydrated=!0}}render(){if(this._valueChanged&&this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this._valueChanged=!1}validateValue(){if(!this.internals||this.value===void 0)return;let n=typeof this.value==="string"?this.value:String(this.value);dn(this,n)}}class Hf extends O{static initAttributes={name:""};content=null;static replaceSlot(n){let f=document.createElement("xin-slot");if(n.name!=="")f.setAttribute("name",n.name);n.replaceWith(f)}}var rc=Hf.elementCreator({tag:"xin-slot"});var Lo=(n=()=>!0)=>{let f=localStorage.getItem("xin-state");if(f!=null){let E=JSON.parse(f);for(let c of Object.keys(E).filter(n))if(Q[c]!==void 0)Object.assign(Q[c],E[c]);else Q[c]=E[c]}let o=Qn(()=>{let E={},c=$(Q);for(let m of Object.keys(c).filter(n))E[m]=c[m];localStorage.setItem("xin-state",JSON.stringify(E)),console.log("xin state saved to localStorage")},500);on(n,o)};var Kn="1.3.6";function Hn(n){return Object.assign(l,n),l}function Xn(n){return d("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),Hn(n)}function Bn(n,f=!1){if(f)return d("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),Xn(n);return Object.keys(n).forEach((o)=>{Q[o]=n[o]}),Q}var eo={};async function rn(n,f){let{type:o,styleSpec:E}=await f(n,{Color:x,Component:O,elements:r,svgElements:sn,mathML:qn,varDefault:xn,vars:zn,xin:Q,boxed:l,xinProxy:Bn,boxedProxy:Xn,tosi:Hn,makeComponent:rn,bind:q,on:v,version:Kn}),c={type:o,creator:o.elementCreator({tag:n,styleSpec:E})};return eo[n]=c,c}var Xf={},vo=(n)=>import(n);class Tn extends O{static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(n)=>{};async packaged(){let{tag:n,src:f,property:o}=this,E=`${n}.${o}:${f}`;if(!this.loaded){if(Xf[E]===void 0)Xf[E]=vo(f).then((c)=>{let m=c[o];return rn(n,m)});else console.log(`using cached ${n} with signature ${E}`);this.loaded=await Xf[E],this.blueprintLoaded(this.loaded)}return this.loaded}}var xo=Tn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class Sn extends O{allLoaded=()=>{};constructor(){super()}async load(){let f=Array.from(this.querySelectorAll(Tn.tagName)).filter((o)=>o.src).map((o)=>o.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var wo=Sn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
|
|
14
14
|
|
|
15
|
-
//# debugId=
|
|
15
|
+
//# debugId=7ADD567B40CEE87464756E2164756E21
|
|
16
16
|
//# sourceMappingURL=index.js.map
|