tosijs 1.4.0 → 1.4.2
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/README.md +1 -1
- package/dist/blueprint-loader.d.ts +13 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +9 -8
- package/dist/main.js +11 -11
- package/dist/main.js.map +9 -8
- package/dist/module.js +11 -11
- package/dist/module.js.map +9 -8
- package/dist/share.d.ts +13 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[tosijs.net](https://tosijs.net) | [tosijs-ui](https://ui.tosijs.net) | [github](https://github.com/tonioloewald/tosijs) | [npm](https://www.npmjs.com/package/tosijs) | [cdn](https://www.jsdelivr.com/package/npm/tosijs) | [react-tosijs](https://react.tosijs.net) | [discord](https://discord.gg/ramJ9rgky5)
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/tosijs)
|
|
12
|
-
[](https://bundlejs.com/?q=tosijs&badge=)
|
|
13
13
|
[](https://www.jsdelivr.com/package/npm/tosijs)
|
|
14
14
|
|
|
15
15
|
<div style="text-align: center; margin: 20px">
|
|
@@ -10,11 +10,22 @@ export declare class Blueprint extends Component {
|
|
|
10
10
|
blueprintLoaded: (_pkg: XinPackagedComponent) => void;
|
|
11
11
|
packaged(): Promise<XinPackagedComponent>;
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const tosiBlueprint: import("./xin-types").ElementCreator<Blueprint>;
|
|
14
14
|
export declare class BlueprintLoader extends Component {
|
|
15
|
+
allLoaded: () => void;
|
|
16
|
+
private load;
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const tosiLoader: import("./xin-types").ElementCreator<BlueprintLoader>;
|
|
20
|
+
declare class DeprecatedBlueprint extends Blueprint {
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
23
|
+
export declare const blueprint: import("./xin-types").ElementCreator<DeprecatedBlueprint>;
|
|
24
|
+
declare class DeprecatedLoader extends Component {
|
|
15
25
|
allLoaded: () => void;
|
|
16
26
|
constructor();
|
|
17
27
|
private load;
|
|
18
28
|
connectedCallback(): void;
|
|
19
29
|
}
|
|
20
|
-
export declare const blueprintLoader: import("./xin-types").ElementCreator<
|
|
30
|
+
export declare const blueprintLoader: import("./xin-types").ElementCreator<DeprecatedLoader>;
|
|
31
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { elements, svgElements, mathML } from './elements';
|
|
|
10
10
|
export type { ElementsProxy } from './elements-types';
|
|
11
11
|
export { getCssVar } from './get-css-var';
|
|
12
12
|
export { hotReload } from './hot-reload';
|
|
13
|
+
export { share } from './share';
|
|
13
14
|
export { xinPath, xinValue, tosiPath, tosiValue, tosiSetValue, deprecated, warnDeprecated, } from './metadata';
|
|
14
15
|
export { getListInstance, getListItem, getListBinding, deleteListItem, scrollListItemIntoView, } from './list-binding';
|
|
15
16
|
export { makeComponent } from './make-component';
|
|
@@ -19,6 +20,6 @@ export { settings } from './settings';
|
|
|
19
20
|
export { throttle, debounce } from './throttle';
|
|
20
21
|
export { version } from './version';
|
|
21
22
|
export { xin, boxed, observe, unobserve, touch, updates } from './xin';
|
|
22
|
-
export { blueprint, Blueprint, blueprintLoader, BlueprintLoader, } from './blueprint-loader';
|
|
23
|
+
export { tosiBlueprint, tosiLoader, blueprint, Blueprint, blueprintLoader, BlueprintLoader, } from './blueprint-loader';
|
|
23
24
|
export * from './xin-types';
|
|
24
25
|
export { tosi, xinProxy, boxedProxy } from './xin-proxy';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var{defineProperty:Sn,getOwnPropertyNames:To,getOwnPropertyDescriptor:Do}=Object,Yo=Object.prototype.hasOwnProperty;var Jf=new WeakMap,$o=(n)=>{var f=Jf.get(n),o;if(f)return f;if(f=Sn({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")To(n).map((E)=>!Yo.call(f,E)&&Sn(f,E,{get:()=>n[E],enumerable:!(o=Do(n,E))||o.enumerable}));return Jf.set(n,f),f};var Jo=(n,f)=>{for(var o in f)Sn(n,o,{get:f[o],enumerable:!0,configurable:!0,set:(E)=>f[o]=()=>E})};var fE={};Jo(fE,{xinValue:()=>Wf,xinProxy:()=>dn,xinPath:()=>zf,xin:()=>Q,warnDeprecated:()=>d,version:()=>Bn,vars:()=>qn,varDefault:()=>Cn,validateAgainstConstraints:()=>Kn,updates:()=>ff,unobserve:()=>S,touchElement:()=>sn,touch:()=>I,tosiValue:()=>F,tosiSetValue:()=>Gf,tosiPath:()=>z,tosi:()=>Dn,throttle:()=>wn,svgElements:()=>Un,settings:()=>P,scrollListItemIntoView:()=>Lo,onThemePreferencesChange:()=>vf,onStylesheetChange:()=>bf,on:()=>a,observe:()=>cn,mathML:()=>jn,makeComponent:()=>$n,invertLuminance:()=>gf,initVars:()=>pf,hotReload:()=>Ho,getThemePreferences:()=>mf,getListItem:()=>On,getListInstance:()=>An,getListBinding:()=>En,getCssVar:()=>Wn,elements:()=>T,deprecated:()=>Zn,deleteListItem:()=>mo,debounce:()=>zn,css:()=>b,boxedProxy:()=>Yn,boxed:()=>k,blueprintLoader:()=>Xo,blueprint:()=>io,bindings:()=>xn,bind:()=>A,StyleSheet:()=>Nf,MoreMath:()=>uf,Component:()=>O,Color:()=>x,BlueprintLoader:()=>Rn,Blueprint:()=>Jn});function s(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(s);let f={};for(let o in n){let E=n[o];if(n!=null&&typeof n==="object")f[o]=s(E);else f[o]=E}return f}var Vn="-xin-data",u=`.${Vn}`,un="-xin-event",Pn=`.${un}`,r=Symbol.for("xin-path"),B=Symbol.for("xin-value"),_n="xinObserve",bn="xinBind",Nn="xinOn",fn=Symbol("list-binding"),v=Symbol("list-instance"),In=new Map;function Zf(n,f){let o=In.get(n);if(o===void 0)o=new Set,In.set(n,o);o.add(f)}function Qf(n){return In.get(n)}var Ff=new Set;function d(n,f){if(!Ff.has(n))console.warn(f),Ff.add(n)}function Zn(n,f){let o=!1;return(...E)=>{if(!o)console.warn(f),o=!0;return n(...E)}}var z=(n)=>{return n&&n[r]||void 0};function F(n){if(typeof n==="object"&&n!==null){let f=n[B];return f!==void 0?f:n}return n}function Gf(n,f){if(z(n)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");n[B]=f}var zf=Zn(z,"xinPath is deprecated. Use tosiPath instead."),Wf=Zn(F,"xinValue is deprecated. Use tosiValue instead."),g=new WeakMap,K=new WeakMap;var e=(n)=>{let f=n.cloneNode();if(f instanceof Element){let o=K.get(n),E=g.get(n);if(o!=null)K.set(f,s(o));if(E!=null)g.set(f,s(E))}for(let o of Array.from(n instanceof HTMLTemplateElement?n.content.childNodes:n.childNodes))if(o instanceof Element||o instanceof DocumentFragment)f.appendChild(e(o));else f.appendChild(o.cloneNode());return f};var P={debug:!1,perf:!1};var Fo=(n)=>{try{return JSON.stringify(n)}catch(f){return"{has circular references}"}},hn=(...n)=>Error(n.map(Fo).join(" "));var Zo=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),Qo=0,Go=()=>(parseInt("10000",36)+ ++Qo).toString(36).slice(-5),zo=()=>Zo()+Go(),gn=Symbol("delete"),rf=Symbol("new-object"),pn=Symbol("automatic-index");function Uf(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 R=new WeakMap;function jf(n,f){if(R.get(n)===void 0)R.set(n,{});if(R.get(n)[f]===void 0)R.get(n)[f]={};let o=R.get(n)[f];if(f==="_auto_")n.forEach((E,M)=>{if(E[pn]===void 0)E[pn]=zo();o[E[pn]+""]=M});else n.forEach((E,M)=>{o[U(E,f)+""]=M});return o}function Wo(n,f){if(R.get(n)===void 0||R.get(n)[f]===void 0)return jf(n,f);else return R.get(n)[f]}function ko(n,f,o){o=o+"";let E=Wo(n,f)[o];if(E===void 0||U(n[E],f)+""!==o)E=jf(n,f)[o];return E}function qo(n,f,o){if(n[f]===void 0&&o!==void 0)n[f]=o;return n[f]}function Af(n,f,o,E){let M=f!==""?ko(n,f,o):o;if(E===gn)return n.splice(M,1),R.delete(n),Symbol("deleted");else if(E===rf){if(f===""&&n[M]===void 0)n[M]={}}else if(E!==void 0)if(M!==void 0)n[M]=E;else if(f!==""&&U(E,f)+""===o+"")n.push(E),M=n.length-1;else throw Error(`byIdPath insert failed at [${f}=${o}]`);return n[M]}function kf(n){if(!Array.isArray(n))throw hn("setByPath failed: expected array, found",n)}function qf(n){if(n==null||!(n instanceof Object))throw hn("setByPath failed: expected Object, found",n)}function U(n,f){let o=Uf(f),E=n,M,c,L,y;for(M=0,c=o.length;E!==void 0&&M<c;M++){let m=o[M];if(Array.isArray(m))for(L=0,y=m.length;E!==void 0&&L<y;L++){let w=m[L];E=E[w]}else if(E.length===0){if(E=E[Number(m.slice(1))],m[0]!=="=")return}else if(m.includes("=")){let[w,...C]=m.split("=");E=Af(E,w,C.join("="))}else L=parseInt(m,10),E=E[L]}return E}function Of(n,f,o){let E=n;if(f==="")throw Error("setByPath cannot be used to set the root object");let M=Uf(f);while(E!=null&&M.length>0){let c=M.shift();if(typeof c==="string"){let L=c.indexOf("=");if(L>-1){if(L===0)qf(E);else kf(E);let y=c.slice(0,L),m=c.slice(L+1);if(E=Af(E,y,m,M.length>0?rf:o),M.length===0)return!0}else{kf(E);let y=parseInt(c,10);if(M.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(c)&&c.length>0){qf(E);while(c.length>0){let L=c.shift();if(c.length>0||M.length>0)E=qo(E,L,c.length>0?{}:[]);else{if(o!==gn){if(E[L]===o)return!1;E[L]=o}else{if(!Object.prototype.hasOwnProperty.call(E,L))return!1;delete E[L]}return!0}}}else throw Error(`setByPath failed, bad path ${f}`)}throw Error(`setByPath(${n}, ${f}, ${o}) failed`)}var l={},vn=null,sf=(n)=>{vn=n},Qn=()=>{if(vn===null)throw Error("xin proxy not initialized");return vn},en=null,ln=null,Kf=(n,f)=>{en=n,ln=f},mn=()=>{if(en===null)throw Error("bind not initialized");return en},Ln=()=>{if(ln===null)throw Error("on not initialized");return ln};var Bf=Symbol("observer should be removed"),Gn=[],on=[],tn=!1,an,nf;function ro(n,f,o,E){let M=Qf(n);if(M===void 0)return[];let c=[];for(let L of M){let y=U(o,L);if(y!==void 0)c.push(`${n}[${L}=${y}]${E}`)}return c}class df{description;test;callback;constructor(n,f){let o=typeof f==="string"?`"${f}"`:`function ${f.name}`,E;if(typeof n==="string")this.test=(M)=>typeof M==="string"&&M!==""&&(n.startsWith(M)||M.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");Gn.push(this)}}var ff=async()=>{if(an===void 0)return;await an},Uo=()=>{if(P.perf)console.time("xin async update");let n=Array.from(on);on.length=0,tn=!1;for(let f of n)Gn.filter((o)=>{let E;try{E=o.test(f)}catch(M){throw Error(`Listener ${o.description} threw "${M}" at "${f}"`)}if(E===Bf)return S(o),!1;return E}).forEach((o)=>{let E;try{E=o.callback(f)}catch(M){console.error(`Listener ${o.description} threw "${M}" handling "${f}"`)}if(E===Bf)S(o)});if(typeof nf==="function")nf();if(P.perf)console.timeEnd("xin async update")},I=(n)=>{let f=typeof n==="string"?n:z(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(tn===!1)an=new Promise((E)=>{nf=E}),tn=setTimeout(Uo);if(on.find((E)=>f.startsWith(E))==null)on.push(f);let o=f.match(/^(.+)\[(\d+)\](.*)$/);if(o!==null){let[,E,M,c]=o,L=parseInt(M,10),y=U(l,`${E}[${L}]`);if(y!=null){let m=ro(E,L,y,c);for(let w of m)if(on.find((C)=>w.startsWith(C))==null)on.push(w)}}},_=(n,f)=>{return new df(n,f)},S=(n)=>{let f=Gn.indexOf(n);if(f>-1)Gn.splice(f,1);else throw Error("unobserve failed, listener not found")};var of=(n,f)=>{let o=new Event(f);n.dispatchEvent(o)},Sf=(n)=>{if(n instanceof HTMLInputElement)return n.type;else if(n instanceof HTMLSelectElement&&n.hasAttribute("multiple"))return"multi-select";else return"other"},If=(n,f)=>{switch(Sf(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}},Vf=(n)=>{switch(Sf(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:Rf}=globalThis,yn=Rf!=null?new Rf((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?e(E):E)});else if(f instanceof Node)n.append(o?e(f):f);else throw Error("expect text content or document node")};var zn=(n,f=250)=>{let o;return(...E)=>{if(o!==void 0)clearTimeout(o);o=setTimeout(()=>{n(...E)},f)}},wn=(n,f=250)=>{let o,E=Date.now()-f,M=!1;return(...c)=>{if(clearTimeout(o),o=setTimeout(()=>{n(...c),E=Date.now()},f),!M&&Date.now()-E>=f){M=!0;try{n(...c),E=Date.now()}finally{M=!1}}}};var xn={value:{toDOM:If,fromDOM(n){return Vf(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){En(n,f,o).update(f)}}};function W(n){return n.replace(/[A-Z]/g,(f)=>{return`-${f.toLocaleLowerCase()}`})}function Mf(n){return n.replace(/-([a-z])/g,(f,o)=>{return o.toLocaleUpperCase()})}var jo=180/Math.PI,Ao=Math.PI/180;function j(n,f,o){return o<n?NaN:f<n?n:f>o?o:f}function V(n,f,o,E=!0){if(E)o=j(0,o,1);return o*(f-n)+n}var uf={RADIANS_TO_DEGREES:jo,DEGREES_TO_RADIANS:Ao,clamp:j,lerp:V};function Wn(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 Oo=(n,f,o)=>{return(0.299*n+0.587*f+0.114*o)/255},t=(n)=>("00"+Math.round(Number(n)).toString(16)).slice(-2);class Pf{h;s;l;constructor(n,f,o){n/=255,f/=255,o/=255;let E=Math.max(n,f,o),M=E-Math.min(n,f,o),c=M!==0?E===n?(f-o)/M:E===f?2+(o-n)/M:4+(n-f)/M:0;this.h=60*c<0?60*c+360:60*c,this.s=M!==0?E<=0.5?M/(2*E-M):M/(2-(2*E-M)):0,this.l=(2*E-M)/2}}var Mn=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(Wn(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(Mn instanceof HTMLSpanElement)Mn.style.color="black",Mn.style.color=n,document.body.appendChild(Mn),o=getComputedStyle(Mn).color,Mn.remove();let[E,M,c,L]=o.match(/[\d.]+/g)||["0","0","0","0"],y=o.startsWith("color(srgb")?255:1;return new x(Number(E)*y,Number(M)*y,Number(c)*y,L==null?1:Number(L))}static fromHsl(n,f,o,E=1){let M,c,L;if(f===0)M=c=L=o;else{let m=(Y,G,H)=>{if(H<0)H+=1;if(H>1)H-=1;if(H<0.16666666666666666)return Y+(G-Y)*6*H;if(H<0.5)return G;if(H<0.6666666666666666)return Y+(G-Y)*(0.6666666666666666-H)*6;return Y},w=o<0.5?o*(1+f):o+f-o*f,C=2*o-w,i=(n%360+360)%360/360;M=m(C,w,i+0.3333333333333333),c=m(C,w,i),L=m(C,w,i-0.3333333333333333)}let y=new x(M*255,c*255,L*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=j(0,n,255),this.g=j(0,f,255),this.b=j(0,o,255),this.a=j(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 Pf(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 Oo(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+t(this.r)+t(this.g)+t(this.b):"#"+t(this.r)+t(this.g)+t(this.b)+t(Math.floor(255*this.a))}brighten(n){let{h:f,s:o,l:E}=this._hsl,M=j(0,E+n*(1-E),1);return x.fromHsl(f,o,M,this.a)}darken(n){let{h:f,s:o,l:E}=this._hsl,M=j(0,E*(1-n),1);return x.fromHsl(f,o,M,this.a)}saturate(n){let{h:f,s:o,l:E}=this._hsl,M=j(0,o+n*(1-o),1);return x.fromHsl(f,M,E,this.a)}desaturate(n){let{h:f,s:o,l:E}=this._hsl,M=j(0,o*(1-n),1);return x.fromHsl(f,M,E,this.a)}rotate(n){let{h:f,s:o,l:E}=this._hsl,M=(f+360+n)%360;return x.fromHsl(M,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(V(this.r,n.r,f),V(this.g,n.g,f),V(this.b,n.b,f),V(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),V(o.s,E.s,f),V(o.l,E.l,f),V(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:M,method:c}]of x.computedColors)try{let L=x.fromVar(E),y;switch(c){case"b":y=M>0?L.brighten(M):L.darken(-M);break;case"s":y=M>0?L.saturate(M):L.desaturate(-M);break;case"h":y=L.rotate(M*100);break;case"o":y=L.opacity(M);break;default:continue}n.push(` ${o}: ${y.rgba};`)}catch(L){}if(n.length===0)return;let f=`:root {
|
|
2
|
-
${
|
|
1
|
+
(()=>{var{defineProperty:gf,getOwnPropertyNames:IM,getOwnPropertyDescriptor:mM}=Object,BM=Object.prototype.hasOwnProperty;function SM(f){return this[f]}var nM=(f)=>{var E=(kE??=new WeakMap).get(f),M;if(E)return E;if(E=gf({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function"){for(var L of IM(f))if(!BM.call(E,L))gf(E,L,{get:SM.bind(f,L),enumerable:!(M=mM(f,L))||M.enumerable})}return kE.set(f,E),E},kE;var _M=(f)=>f;function cM(f,E){this[f]=_M.bind(null,E)}var PM=(f,E)=>{for(var M in E)gf(f,M,{get:E[M],enumerable:!0,configurable:!0,set:cM.bind(E,M)})};var RL={};PM(RL,{xinValue:()=>SE,xinProxy:()=>uf,xinPath:()=>BE,xin:()=>K,warnDeprecated:()=>m,version:()=>bf,vars:()=>If,varDefault:()=>zf,validateAgainstConstraints:()=>Pf,updates:()=>Zf,unobserve:()=>o,touchElement:()=>cf,touch:()=>B,tosiValue:()=>U,tosiSetValue:()=>mE,tosiPath:()=>O,tosiLoader:()=>jM,tosiBlueprint:()=>AM,tosi:()=>Uf,throttle:()=>Gf,svgElements:()=>Bf,share:()=>KM,settings:()=>g,scrollListItemIntoView:()=>CM,onThemePreferencesChange:()=>MM,onStylesheetChange:()=>tE,on:()=>ff,observe:()=>Jf,mathML:()=>Sf,makeComponent:()=>Of,invertLuminance:()=>EM,initVars:()=>fM,hotReload:()=>DM,getThemePreferences:()=>ZE,getListItem:()=>_f,getListInstance:()=>nf,getListBinding:()=>wf,getCssVar:()=>Vf,elements:()=>z,deprecated:()=>jf,deleteListItem:()=>GM,debounce:()=>Xf,css:()=>s,boxedProxy:()=>qf,boxed:()=>V,blueprintLoader:()=>RM,blueprint:()=>kM,bindings:()=>Cf,bind:()=>n,StyleSheet:()=>eE,MoreMath:()=>rE,Component:()=>_,Color:()=>F,BlueprintLoader:()=>df,Blueprint:()=>Kf});function P(f){if(f==null||typeof f!=="object")return f;if(f instanceof Set)return new Set(f);else if(Array.isArray(f))return f.map(P);let E={};for(let M in f){let L=f[M];if(f!=null&&typeof f==="object")E[M]=P(L);else E[M]=L}return E}var sf="-xin-data",i=`.${sf}`,hf="-xin-event",rf=`.${hf}`,I=Symbol.for("xin-path"),b=Symbol.for("xin-value"),pf="xinObserve",lf="xinBind",tf="xinOn",Lf=Symbol("list-binding"),t=Symbol("list-instance"),vf=new Map;function RE(f,E){let M=vf.get(f);if(M===void 0)M=new Set,vf.set(f,M);M.add(E)}function IE(f){return vf.get(f)}var VE=new Set;function m(f,E){if(!VE.has(f))console.warn(E),VE.add(f)}function jf(f,E){let M=!1;return(...L)=>{if(!M)console.warn(E),M=!0;return f(...L)}}var O=(f)=>{return f&&f[I]||void 0};function U(f){if(typeof f==="object"&&f!==null){let E=f[b];return E!==void 0?E:f}return f}function mE(f,E){if(O(f)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");f[b]=E}var BE=jf(O,"xinPath is deprecated. Use tosiPath instead."),SE=jf(U,"xinValue is deprecated. Use tosiValue instead."),l=new WeakMap,N=new WeakMap;var e=(f)=>{let E=f.cloneNode();if(E instanceof Element){let M=N.get(f),L=l.get(f);if(M!=null)N.set(E,P(M));if(L!=null)l.set(E,P(L))}for(let M of Array.from(f instanceof HTMLTemplateElement?f.content.childNodes:f.childNodes))if(M instanceof Element||M instanceof DocumentFragment)E.appendChild(e(M));else E.appendChild(M.cloneNode());return E};var g={debug:!1,perf:!1};var NM=(f)=>{try{return JSON.stringify(f)}catch(E){return"{has circular references}"}},ef=(...f)=>Error(f.map(NM).join(" "));var bM=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),uM=0,oM=()=>(parseInt("10000",36)+ ++uM).toString(36).slice(-5),dM=()=>bM()+oM(),fE=Symbol("delete"),cE=Symbol("new-object"),af=Symbol("automatic-index");function PE(f){if(f==="")return[];if(Array.isArray(f))return f;else{let E=[];while(f.length>0){let M=f.search(/\[[^\]]+\]/);if(M===-1){E.push(f.split("."));break}else{let L=f.slice(0,M);if(f=f.slice(M),L!=="")E.push(L.split("."));if(M=f.indexOf("]")+1,E.push(f.slice(1,M-1)),f.slice(M,M+1)===".")M+=1;f=f.slice(M)}}return E}}var u=new WeakMap;function NE(f,E){if(u.get(f)===void 0)u.set(f,{});if(u.get(f)[E]===void 0)u.get(f)[E]={};let M=u.get(f)[E];if(E==="_auto_")f.forEach((L,H)=>{if(L[af]===void 0)L[af]=dM();M[L[af]+""]=H});else f.forEach((L,H)=>{M[j(L,E)+""]=H});return M}function iM(f,E){if(u.get(f)===void 0||u.get(f)[E]===void 0)return NE(f,E);else return u.get(f)[E]}function gM(f,E,M){M=M+"";let L=iM(f,E)[M];if(L===void 0||j(f[L],E)+""!==M)L=NE(f,E)[M];return L}function vM(f,E,M){if(f[E]===void 0&&M!==void 0)f[E]=M;return f[E]}function bE(f,E,M,L){let H=E!==""?gM(f,E,M):M;if(L===fE)return f.splice(H,1),u.delete(f),Symbol("deleted");else if(L===cE){if(E===""&&f[H]===void 0)f[H]={}}else if(L!==void 0)if(H!==void 0)f[H]=L;else if(E!==""&&j(L,E)+""===M+"")f.push(L),H=f.length-1;else throw Error(`byIdPath insert failed at [${E}=${M}]`);return f[H]}function nE(f){if(!Array.isArray(f))throw ef("setByPath failed: expected array, found",f)}function _E(f){if(f==null||!(f instanceof Object))throw ef("setByPath failed: expected Object, found",f)}function j(f,E){let M=PE(E),L=f,H,X,J,Y;for(H=0,X=M.length;L!==void 0&&H<X;H++){let w=M[H];if(Array.isArray(w))for(J=0,Y=w.length;L!==void 0&&J<Y;J++){let $=w[J];L=L[$]}else if(L.length===0){if(L=L[Number(w.slice(1))],w[0]!=="=")return}else if(w.includes("=")){let[$,...Z]=w.split("=");L=bE(L,$,Z.join("="))}else J=parseInt(w,10),L=L[J]}return L}function Yf(f,E,M){let L=f;if(E==="")throw Error("setByPath cannot be used to set the root object");let H=PE(E);while(L!=null&&H.length>0){let X=H.shift();if(typeof X==="string"){let J=X.indexOf("=");if(J>-1){if(J===0)_E(L);else nE(L);let Y=X.slice(0,J),w=X.slice(J+1);if(L=bE(L,Y,w,H.length>0?cE:M),H.length===0)return!0}else{nE(L);let Y=parseInt(X,10);if(H.length>0)L=L[Y];else{if(M!==fE){if(L[Y]===M)return!1;L[Y]=M}else L.splice(Y,1);return!0}}}else if(Array.isArray(X)&&X.length>0){_E(L);while(X.length>0){let J=X.shift();if(X.length>0||H.length>0)L=vM(L,J,X.length>0?{}:[]);else{if(M!==fE){if(L[J]===M)return!1;L[J]=M}else{if(!Object.prototype.hasOwnProperty.call(L,J))return!1;delete L[J]}return!0}}}else throw Error(`setByPath failed, bad path ${E}`)}throw Error(`setByPath(${f}, ${E}, ${M}) failed`)}var y={},EE=null,uE=(f)=>{EE=f},yf=()=>{if(EE===null)throw Error("xin proxy not initialized");return EE},ME=null,LE=null,oE=(f,E)=>{ME=f,LE=E},$f=()=>{if(ME===null)throw Error("bind not initialized");return ME},Ff=()=>{if(LE===null)throw Error("on not initialized");return LE};var dE=Symbol("observer should be removed"),kf=[],Hf=[],HE=!1,XE,wE;function sM(f,E,M,L){let H=IE(f);if(H===void 0)return[];let X=[];for(let J of H){let Y=j(M,J);if(Y!==void 0)X.push(`${f}[${J}=${Y}]${L}`)}return X}class iE{description;test;callback;constructor(f,E){let M=typeof E==="string"?`"${E}"`:`function ${E.name}`,L;if(typeof f==="string")this.test=(H)=>typeof H==="string"&&H!==""&&(f.startsWith(H)||H.startsWith(f)),L=`test = "${f}"`;else if(f instanceof RegExp)this.test=f.test.bind(f),L=`test = "${f.toString()}"`;else if(f instanceof Function)this.test=f,L=`test = function ${f.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${L}, ${M}`,typeof E==="function")this.callback=E;else throw Error("expect callback to be a path or function");kf.push(this)}}var Zf=async()=>{if(XE===void 0)return;await XE},hM=()=>{if(g.perf)console.time("xin async update");let f=Array.from(Hf);Hf.length=0,HE=!1;for(let E of f)kf.filter((M)=>{let L;try{L=M.test(E)}catch(H){throw Error(`Listener ${M.description} threw "${H}" at "${E}"`)}if(L===dE)return o(M),!1;return L}).forEach((M)=>{let L;try{L=M.callback(E)}catch(H){console.error(`Listener ${M.description} threw "${H}" handling "${E}"`)}if(L===dE)o(M)});if(typeof wE==="function")wE();if(g.perf)console.timeEnd("xin async update")},B=(f)=>{let E=typeof f==="string"?f:O(f);if(E===void 0)throw console.error("touch was called on an invalid target",f),Error("touch was called on an invalid target");if(HE===!1)XE=new Promise((L)=>{wE=L}),HE=setTimeout(hM);if(Hf.find((L)=>E.startsWith(L))==null)Hf.push(E);let M=E.match(/^(.+)\[(\d+)\](.*)$/);if(M!==null){let[,L,H,X]=M,J=parseInt(H,10),Y=j(y,`${L}[${J}]`);if(Y!=null){let w=sM(L,J,Y,X);for(let $ of w)if(Hf.find((Z)=>$.startsWith(Z))==null)Hf.push($)}}},c=(f,E)=>{return new iE(f,E)},o=(f)=>{let E=kf.indexOf(f);if(E>-1)kf.splice(E,1);else throw Error("unobserve failed, listener not found")};var JE=(f,E)=>{let M=new Event(E);f.dispatchEvent(M)},vE=(f)=>{if(f instanceof HTMLInputElement)return f.type;else if(f instanceof HTMLSelectElement&&f.hasAttribute("multiple"))return"multi-select";else return"other"},sE=(f,E)=>{switch(vE(f)){case"radio":f.checked=f.value===E;break;case"checkbox":f.checked=!!E;break;case"date":f.valueAsDate=new Date(E);break;case"multi-select":for(let M of Array.from(f.querySelectorAll("option")))M.selected=E[M.value];break;default:f.value=E}},hE=(f)=>{switch(vE(f)){case"radio":{let E=f.parentElement?.querySelector(`[name="${f.name}"]:checked`);return E!=null?E.value:null}case"checkbox":return f.checked;case"date":return f.valueAsDate?.toISOString();case"multi-select":return Array.from(f.querySelectorAll("option")).reduce((E,M)=>{return E[M.value]=M.selected,E},{});default:return f.value}},{ResizeObserver:gE}=globalThis,Qf=gE!=null?new gE((f)=>{for(let E of f){let M=E.target;JE(M,"resize")}}):{observe(){},unobserve(){}},YE=(f,E,M=!0)=>{if(f!=null&&E!=null)if(typeof E==="string")f.textContent=E;else if(Array.isArray(E))E.forEach((L)=>{f.append(L instanceof Node&&M?e(L):L)});else if(E instanceof Node)f.append(M?e(E):E);else throw Error("expect text content or document node")};var Xf=(f,E=250)=>{let M;return(...L)=>{if(M!==void 0)clearTimeout(M);M=setTimeout(()=>{f(...L)},E)}},Gf=(f,E=250)=>{let M,L=Date.now()-E,H=!1;return(...X)=>{if(clearTimeout(M),M=setTimeout(()=>{f(...X),L=Date.now()},E),!H&&Date.now()-L>=E){H=!0;try{f(...X),L=Date.now()}finally{H=!1}}}};var Cf={value:{toDOM:sE,fromDOM(f){return hE(f)}},text:{toDOM(f,E){f.textContent=E}},enabled:{toDOM(f,E){f.disabled=!E}},disabled:{toDOM(f,E){f.disabled=Boolean(E)}},list:{toDOM(f,E,M){wf(f,E,M).update(E)}}};function k(f){return f.replace(/[A-Z]/g,(E)=>{return`-${E.toLocaleLowerCase()}`})}function $E(f){return f.replace(/-([a-z])/g,(E,M)=>{return M.toLocaleUpperCase()})}var rM=180/Math.PI,pM=Math.PI/180;function S(f,E,M){return M<f?NaN:E<f?f:E>M?M:E}function d(f,E,M,L=!0){if(L)M=S(0,M,1);return M*(E-f)+f}var rE={RADIANS_TO_DEGREES:rM,DEGREES_TO_RADIANS:pM,clamp:S,lerp:d};function Vf(f,E=document.body){let M=getComputedStyle(E);if(f.endsWith(")")&&f.startsWith("var("))f=f.slice(4,-1);return M.getPropertyValue(f).trim()}var lM=(f,E,M)=>{return(0.299*f+0.587*E+0.114*M)/255},a=(f)=>("00"+Math.round(Number(f)).toString(16)).slice(-2);class pE{h;s;l;constructor(f,E,M){f/=255,E/=255,M/=255;let L=Math.max(f,E,M),H=L-Math.min(f,E,M),X=H!==0?L===f?(E-M)/H:L===E?2+(M-f)/H:4+(f-E)/H:0;this.h=60*X<0?60*X+360:60*X,this.s=H!==0?L<=0.5?H/(2*L-H):H/(2-(2*L-H)):0,this.l=(2*L-H)/2}}var v=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;if(v)v.style.display="none";class F{r;g;b;a;static fromVar(f,E=document.body){return F.fromCss(Vf(f,E))}static fromCss(f){let E=f.match(/^#([0-9a-fA-F]+)$/);if(E){let w=E[1];if(w.length===3)return new F(parseInt(w[0]+w[0],16),parseInt(w[1]+w[1],16),parseInt(w[2]+w[2],16));if(w.length===4)return new F(parseInt(w[0]+w[0],16),parseInt(w[1]+w[1],16),parseInt(w[2]+w[2],16),parseInt(w[3]+w[3],16)/255);if(w.length===6)return new F(parseInt(w.slice(0,2),16),parseInt(w.slice(2,4),16),parseInt(w.slice(4,6),16));if(w.length===8)return new F(parseInt(w.slice(0,2),16),parseInt(w.slice(2,4),16),parseInt(w.slice(4,6),16),parseInt(w.slice(6,8),16)/255)}let M=f;if(v instanceof HTMLSpanElement)v.style.color="black",v.style.color=f,document.body.appendChild(v),M=getComputedStyle(v).color,v.remove();let[L,H,X,J]=M.match(/[\d.]+/g)||["0","0","0","0"],Y=M.startsWith("color(srgb")?255:1;return new F(Number(L)*Y,Number(H)*Y,Number(X)*Y,J==null?1:Number(J))}static fromHsl(f,E,M,L=1){let H,X,J;if(E===0)H=X=J=M;else{let w=(x,A,Q)=>{if(Q<0)Q+=1;if(Q>1)Q-=1;if(Q<0.16666666666666666)return x+(A-x)*6*Q;if(Q<0.5)return A;if(Q<0.6666666666666666)return x+(A-x)*(0.6666666666666666-Q)*6;return x},$=M<0.5?M*(1+E):M+E-M*E,Z=2*M-$,G=(f%360+360)%360/360;H=w(Z,$,G+0.3333333333333333),X=w(Z,$,G),J=w(Z,$,G-0.3333333333333333)}let Y=new F(H*255,X*255,J*255,L);return Y.hslCached={h:(f%360+360)%360,s:E,l:M},Y}static black=new F(0,0,0);static white=new F(255,255,255);constructor(f,E,M,L=1){this.r=S(0,f,255),this.g=S(0,E,255),this.b=S(0,M,255),this.a=S(0,L,1)}get inverse(){return new F(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:f,s:E,l:M}=this._hsl;return F.fromHsl(f,E,1-M,this.a)}get opaque(){return this.a===1?this:new F(this.r,this.g,this.b,1)}contrasting(f=1){return this.opaque.blend(this.brightness>0.5?F.black:F.white,f)}get rgb(){let{r:f,g:E,b:M}=this;return`rgb(${f.toFixed(0)},${E.toFixed(0)},${M.toFixed(0)})`}get rgba(){let{r:f,g:E,b:M,a:L}=this;return`rgba(${f.toFixed(0)},${E.toFixed(0)},${M.toFixed(0)},${L.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 pE(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:f,s:E,l:M}=this._hsl;return`hsl(${f.toFixed(0)}deg ${(E*100).toFixed(0)}% ${(M*100).toFixed(0)}%)`}get hsla(){let{h:f,s:E,l:M}=this._hsl;return`hsl(${f.toFixed(0)}deg ${(E*100).toFixed(0)}% ${(M*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let f=this.brightness*255;return new F(f,f,f)}get brightness(){return lM(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+a(this.r)+a(this.g)+a(this.b):"#"+a(this.r)+a(this.g)+a(this.b)+a(Math.floor(255*this.a))}brighten(f){let{h:E,s:M,l:L}=this._hsl,H=S(0,L+f*(1-L),1);return F.fromHsl(E,M,H,this.a)}darken(f){let{h:E,s:M,l:L}=this._hsl,H=S(0,L*(1-f),1);return F.fromHsl(E,M,H,this.a)}saturate(f){let{h:E,s:M,l:L}=this._hsl,H=S(0,M+f*(1-M),1);return F.fromHsl(E,H,L,this.a)}desaturate(f){let{h:E,s:M,l:L}=this._hsl,H=S(0,M*(1-f),1);return F.fromHsl(E,H,L,this.a)}rotate(f){let{h:E,s:M,l:L}=this._hsl,H=(E+360+f)%360;return F.fromHsl(H,M,L,this.a)}opacity(f){let{h:E,s:M,l:L}=this._hsl;return F.fromHsl(E,M,L,f)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(f,E){return new F(d(this.r,f.r,E),d(this.g,f.g,E),d(this.b,f.b,E),d(this.a,f.a,E))}static blendHue(f,E,M){let L=(E-f+720)%360;if(L<180)return f+M*L;else return f-(360-L)*M}mix(f,E){let M=this._hsl,L=f._hsl;return F.fromHsl(M.s===0?L.h:L.s===0?M.h:F.blendHue(M.h,L.h,E),d(M.s,L.s,E),d(M.l,L.l,E),d(this.a,f.a,E))}colorMix(f,E){return F.fromCss(`color-mix(in hsl, ${this.html}, ${f.html} ${(E*100).toFixed(0)}%)`)}static computedColorStylesheet=null;static computedColors=new Map;static recomputeQueued=!1;static registerComputedColor(f,E,M,L){if(!F.computedColors.has(f))F.computedColors.set(f,{varName:E,scale:M,method:L}),F.queueRecompute()}static queueRecompute(){if(F.recomputeQueued)return;F.recomputeQueued=!0,queueMicrotask(()=>{F.recomputeQueued=!1,F.recomputeColors()})}static recomputeColors(){if(F.computedColors.size===0)return;let f=[];for(let[M,{varName:L,scale:H,method:X}]of F.computedColors)try{let J=F.fromVar(L),Y;switch(X){case"b":Y=H>0?J.brighten(H):J.darken(-H);break;case"s":Y=H>0?J.saturate(H):J.desaturate(-H);break;case"h":Y=J.rotate(H*100);break;case"o":Y=J.opacity(H);break;default:continue}f.push(` ${M}: ${Y.rgba};`)}catch(J){}if(f.length===0)return;let E=`:root {
|
|
2
|
+
${f.join(`
|
|
3
3
|
`)}
|
|
4
|
-
}`;if(
|
|
5
|
-
`);return`${
|
|
6
|
-
${
|
|
7
|
-
${
|
|
8
|
-
`);return`${
|
|
9
|
-
${
|
|
4
|
+
}`;if(F.computedColorStylesheet===null)F.computedColorStylesheet=document.createElement("style"),F.computedColorStylesheet.id="tosijs-computed-colors",document.head.append(F.computedColorStylesheet);F.computedColorStylesheet.textContent=E}}var Rf=new Set,lE=!1;function tM(){if(!lE)lE=!0,Rf.add(()=>F.queueRecompute())}function tE(f){return Rf.add(f),()=>Rf.delete(f)}function eM(){tM();for(let f of Rf)f()}function eE(f,E){let M=U(E),L=z.style(s(M));L.id=f,document.head.append(L);let H=O(E);if(H!==void 0)Jf(H,()=>{L.textContent=s(U(E)),eM()})}var aM=/^(animation-iteration-count|column-count|flex(-grow|-shrink)?|font-weight|line-height|opacity|order|orphans|scale|tab-size|widows|z-index|zoom)$/,FE=(f,E)=>{if(typeof E==="number"&&!aM.test(f))E=`${E}px`;if(f.startsWith("_"))if(f.startsWith("__"))f="--"+f.substring(2),E=`var(${f}-default, ${E})`;else f="--"+f.substring(1);return{prop:f,value:String(E)}},fL=(f,E,M)=>{if(M===void 0)return"";if(M instanceof F)M=M.html;let L=FE(E,M);return`${f} ${L.prop}: ${L.value};`},aE=(f,E,M="")=>{let L=k(f);if(typeof E==="object"&&!(E instanceof F)){let H=Object.keys(E).map((X)=>aE(X,E[X],`${M} `)).join(`
|
|
5
|
+
`);return`${M} ${f} {
|
|
6
|
+
${H}
|
|
7
|
+
${M} }`}else return fL(M,L,E)},s=(f,E="")=>{return Object.keys(f).map((L)=>{let H=f[L];if(typeof H==="string"){if(L==="@import")return`@import url('${H}');`;throw Error("top-level string value only allowed for `@import`")}let X=Object.keys(H).map((J)=>aE(J,H[J])).join(`
|
|
8
|
+
`);return`${E}${L} {
|
|
9
|
+
${X}
|
|
10
10
|
}`}).join(`
|
|
11
11
|
|
|
12
|
-
`)},pf=(n)=>{d("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let f={};for(let o of Object.keys(n)){let E=n[o],M=W(o);f[`--${M}`]=typeof E==="number"&&E!==0?String(E)+"px":E}return f},gf=(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},Cn=new Proxy({},{get(n,f){if(n[f]===void 0){let o="--"+W(f);n[f]=(E)=>`var(${o}, ${E})`}return n[f]}}),qn=new Proxy({},{get(n,f){if(f==="default")return Cn;if(n[f]==null){f=W(f);let[,o,,E,M,c]=f.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",f],L=`--${o}`;if(M!=null){let y=E==null?Number(M)/100:-Number(M)/100;switch(c){case"b":case"s":case"h":case"o":{let m=`--${f}`;x.registerComputedColor(m,L,y,c),n[f]=`var(${m})`}break;case"":n[f]=`calc(var(${L}) * ${y})`;break;default:throw console.error(c),Error(`Unrecognized method ${c} for css variable ${L}`)}}else n[f]=`var(${L})`}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 vf(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((M)=>matchMedia(M));for(let M of E)M.addEventListener("change",o);return()=>{for(let M of E)M.removeEventListener("change",o)}}var ef="http://www.w3.org/1998/Math/MathML",lf="http://www.w3.org/2000/svg";var rn={},tf=(n,f,o)=>{let E=cf(W(f),o);if(E.prop.startsWith("--"))n.style.setProperty(E.prop,E.value);else n.style[f]=E.value},So=(n)=>{return{toDOM(f,o){tf(f,n,o)}}},af=(n,f,o)=>{if(f==="style")if(typeof o==="object")for(let E of Object.keys(o))if(z(o[E]))A(n,o[E],So(E));else tf(n,E,o[E]);else n.setAttribute("style",o);else{let E=W(f),M=n.constructor.observedAttributes;if(M?.includes(f)||M?.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:L}=globalThis;if(n instanceof SVGElement||L!==void 0&&n instanceof L)n.setAttribute(f,o);else n[f]=o}else if(E==="class")o.split(" ").forEach((L)=>{n.classList.add(L)});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)}},Lf={},Io=(n)=>{if(!Lf[n])Lf[n]={toDOM(f,o){af(f,n,o)}};return Lf[n]},Vo=(n,f,o)=>{if(f==="apply")o(n);else if(f.match(/^on[A-Z]/)!=null){let E=f.substring(2).toLowerCase();a(n,E,o)}else if(f==="bind")if((typeof o.binding==="string"?xn[o.binding]:o.binding)!==void 0&&o.value!==void 0)A(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),M=xn[E];if(M!==void 0)A(n,o,M);else throw Error(`${f} is not allowed, bindings.${E} is not defined`)}else if(z(o))A(n,o,Io(f));else af(n,f,o)},yf=(n,...f)=>{if(rn[n]===void 0){let[M,c]=n.split("|");if(c===void 0)rn[n]=globalThis.document.createElement(M);else rn[n]=globalThis.document.createElementNS(c,M)}let o=rn[n].cloneNode(),E={};for(let M of f)if(M instanceof Element||M instanceof DocumentFragment||typeof M==="string"||typeof M==="number")if(o instanceof HTMLTemplateElement)o.content.append(M);else o.append(M);else if(z(M))o.append(T.span({bindText:M}));else Object.assign(E,M);for(let M of Object.keys(E)){let c=E[M];Vo(o,M,c)}return o},wf=(...n)=>{let f=globalThis.document.createDocumentFragment();for(let o of n)f.append(o);return f},T=new Proxy({fragment:wf},{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")}}),Un=new Proxy({fragment:wf},{get(n,f){if(n[f]===void 0)n[f]=(...o)=>yf(`${f}|${lf}`,...o);return n[f]},set(){throw Error("You may not add new properties to elements")}}),jn=new Proxy({fragment:wf},{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")}});var uo=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],Po=!0,_o=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,bo=(n)=>_o.test(n),N=(n="",f="")=>{if(n==="")return f;else if(f.match(/^\d+$/)!==null||f.includes("="))return`${n}[${f}]`;else return`${n}.${f}`},Eo={};function xf(n,f){if(n!==null&&(typeof n==="object"||typeof n==="function"))return n;return new Proxy(Eo,h(f,!0))}var Hn=()=>new Proxy({},h("^",!0)),Cf=(n)=>{let o=n(Hn())?.path;if(!o?.startsWith("^."))throw Error("selector must return a property of the item");return o.substring(2)},Hf=(n,f,o)=>{for(let E=0;E<n.length;E++)if(`${U(n[E],f)}`===`${o}`)return E;return-1},no=(n,f)=>({listFind(o,E){if(o instanceof Element){let L=o;while(L&&!L[v]&&L.parentElement)L=L.parentElement;let y=L?.[v];if(y==null)return;let m=f.indexOf(y);return m!==-1?k[n][m]:void 0}let M=Cf(o),c=Hf(f,M,E);return c!==-1?k[n][c]:void 0},listUpdate(o,E){let M=Cf(o),c=U(E,M),L=Hf(f,M,c);if(L!==-1){let y=k[n][L];for(let m of Object.keys(E))y[m]=E[m];return y}return k[n].push(E),k[n][f.length-1]},listRemove(o,E){let M=Cf(o),c=Hf(f,M,E);if(c===-1)return!1;return k[n].splice(c,1),!0}}),fo=!1;function nn(){if(!fo)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),fo=!0}var oo=(n)=>{return n===Eo},h=(n,f)=>({get(o,E){if(oo(o)){let y=()=>U(l,n);switch(E){case"path":return n;case"value":return y();case"valueOf":case"toJSON":return()=>y();case Symbol.toPrimitive:return(m)=>{let w=y();if(m==="number")return Number(w);if(m==="string")return String(w);return w};case"toString":return()=>String(y());case"touch":return()=>I(n);case"observe":return(m)=>{let w=_(n,m);return()=>S(w)};case"on":return(m,w)=>Ln()(m,w,y());case"bind":return(m,w,C)=>{mn()(m,n,w,C)};case"binding":return(m)=>({bind:{value:n,binding:m}});case"listBinding":return(m=({span:C})=>C({bindText:"^"}),w={})=>[{bindList:{value:n,...w}},T.template(m(T,Hn()))];case"listFind":case"listUpdate":case"listRemove":return no(n,o)[E];case B:case"xinValue":case"tosiValue":return nn(),y();case r:case"xinPath":case"tosiPath":return nn(),n;case _n:case"tosiObserve":return nn(),(m)=>{let w=_(n,m);return()=>S(w)};case Nn:case"tosiOn":return nn(),(m,w)=>Ln()(m,w,y());case bn:case"tosiBind":return nn(),(m,w,C)=>{mn()(m,n,w,C)};case"tosiBinding":return nn(),(m)=>({bind:{value:n,binding:m}});case"tosiListBinding":return nn(),(m=({span:C})=>C({bindText:"^"}),w={})=>[{bindList:{value:n,...w}},T.template(m(T,Hn()))]}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"touch":return()=>I(n);case"observe":return(y)=>{let m=_(n,y);return()=>S(m)};case"on":return(y,m)=>Ln()(y,m,F(o));case"bind":return(y,m,w)=>{mn()(y,n,m,w)};case"binding":return(y)=>({bind:{value:n,binding:y}});case"listBinding":return(y=({span:w})=>w({bindText:"^"}),m={})=>[{bindList:{value:n,...m}},T.template(y(T,Hn()))];case"listFind":case"listUpdate":case"listRemove":return no(n,o)[E]}switch(E){case r:case"xinPath":case"tosiPath":return n;case B:case"xinValue":case"tosiValue":return o.valueOf?o.valueOf():o;case _n:case"xinObserve":case"tosiObserve":return(y)=>{let m=_(n,y);return()=>S(m)};case Nn:case"xinOn":case"tosiOn":return(y,m)=>Ln()(y,m,F(o));case bn:case"xinBind":case"tosiBind":return(y,m,w)=>{mn()(y,n,m,w)};case"tosiBinding":return(y)=>({bind:{value:n,binding:y}});case"tosiListBinding":return(y=({span:w})=>w({bindText:"^"}),m={})=>[{bindList:{value:n,...m}},T.template(y(T,Hn()))]}if(typeof E==="symbol")return o[E];let M=Object.getOwnPropertyDescriptor(o,E);if(M&&!M.configurable&&!M.writable&&"value"in M)return M.value;let c=E,L=c.match(/^([^.[]+)\.(.+)$/)??c.match(/^([^\]]+)(\[.+)/)??c.match(/^(\[[^\]]+\])\.(.+)$/)??c.match(/^(\[[^\]]+\])\[(.+)$/);if(L!==null){let[,y,m]=L,w=N(n,y),C=U(o,y);return C!==null&&typeof C==="object"?new Proxy(C,h(w,f))[m]:C}if(c.startsWith("[")&&c.endsWith("]"))c=c.substring(1,c.length-1);if(!Array.isArray(o)&&o[c]!==void 0||Array.isArray(o)&&c.includes("=")){let y;if(c.includes("=")){let[m,w]=c.split("=");y=o.find((C)=>`${U(C,m)}`===w)}else y=o[c];if(y instanceof Object){let m=N(n,c);return new Proxy(y instanceof Function?y.bind(o):y,h(m,f))}else return f?xf(y,N(n,c)):y}else if(Array.isArray(o)){let y=o[c];return typeof y==="function"?(...m)=>{let w=m.map((i)=>F(i)),C=y.apply(o,w);if(uo.includes(c))I(n);if(C!=null&&typeof C==="object"){if(c==="find"||c==="findLast"||c==="at"){let i=o.indexOf(C);if(i!==-1)return new Proxy(C,h(N(n,String(i)),f))}}return C}:typeof y==="object"?new Proxy(y,h(N(n,c),f)):f?xf(y,N(n,c)):y}else return f?xf(o[c],N(n,c)):o[c]},set(o,E,M){M=F(M);let L=E===B||E==="xinValue"||E==="tosiValue"||E==="value"&&(oo(o)||f)?n:N(n,E);if(Po&&!bo(L))throw Error(`setting invalid path ${L}`);if(F(Q[L])!==M&&Of(l,L,M))I(L);return!0}}),cn=(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 _(n,o)},Q=new Proxy(l,h("",!1));sf(Q);var k=new Proxy(l,h("",!0));var No=16,ho=100;function Mo(n,f){let o=Array.from(n.querySelectorAll(u));if(n.matches(u))o.unshift(n);for(let E of o){let M=K.get(E);for(let c of M){if(c.path.startsWith("^"))c.path=`${f}${c.path.substring(1)}`;if(c.binding.toDOM!=null)c.binding.toDOM(E,Q[c.path])}}}class co{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,f,o={}){if(this.boundElement=n,this.itemToElement=new WeakMap,o.idPath!=null){let E=z(f);if(E!=null)Zf(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=e(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[fn]=this,o.virtual!=null)if(yn.observe(this.boundElement),this._update=wn(()=>{this.update(this.array,!0)},No),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(){if(this._filteredCache!=null)return this._filteredCache;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 this._filteredCache=o,o}visibleSlice(){let{virtual:n}=this.options,f=this.filteredArray(),o=0,E=f.length-1,M=0,c=0;if(n!=null&&this.boundElement instanceof HTMLElement){let L=this.boundElement.offsetWidth,y=n.scrollContainer==="window",m,w;if(y){m=window.innerHeight;let Y=this.boundElement.getBoundingClientRect();w=Math.max(0,-Y.top)}else m=this.boundElement.offsetHeight,w=this.boundElement.scrollTop;let C=n.width!=null?Math.max(1,Math.floor(L/n.width)):n.visibleColumns??1,i=Math.ceil(f.length/C);if(n.minHeight!=null){let Y=n.minHeight,G=Math.ceil(m/Y)+(n.rowChunkSize||1),H=C*G,$=i*Y,D=Math.max(0,$-m),q=D>0?Math.min(1,Math.max(0,w/D)):0,X=Math.max(0,i-G+1),J=q*X,Z=Math.floor(J);if(n.rowChunkSize)Z-=Z%n.rowChunkSize;return o=Z*C,E=o+H-1,M=w,c=Math.max(0,$-w-m),{items:f,firstItem:o,lastItem:E,topBuffer:M,bottomBuffer:c,interpolation:{t:q,position:J,scrollTop:w,viewportHeight:m,totalScrollHeight:$,rowHeight:n.height}}}else{let Y=Math.ceil(m/n.height)+(n.rowChunkSize||1),G=C*Y,H=Math.floor(w/n.height);if(H>i-Y+1)H=Math.max(0,i-Y+1);if(n.rowChunkSize)H-=H%n.rowChunkSize;o=H*C,E=o+G-1,M=H*n.height,c=Math.max((i-Y)*n.height-M,0)}}return{items:f,firstItem:o,lastItem:E,topBuffer:M,bottomBuffer:c}}needle;filter=wn((n)=>{if(this.needle!==n)this.needle=n,this.update(this.array)},ho);update(n,f){if(n==null)n=[];if(this.array=n,!f)this._filteredCache=void 0;let{hiddenProp:o,visibleProp:E}=this.options,M=z(n),c=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",c.items.length===0);let L=this._previousSlice,{firstItem:y,lastItem:m,topBuffer:w,bottomBuffer:C}=c,i=o===void 0&&E===void 0&&f===!0&&L!=null&&y===L.firstItem&&m===L.lastItem;if(i&&c.interpolation==null&&w===L.topBuffer&&C===L.bottomBuffer)return;if(i&&c.interpolation!=null){this._updateInterpolatedBuffers(c);return}this._previousSlice=c;let Y=0,G=0,H=0;for(let X of Array.from(this.boundElement.children)){if(X===this.listTop||X===this.listBottom)continue;let J=X[v];if(J==null)X.remove();else{let Z=c.items.indexOf(J);if(Z<y||Z>m)X.remove(),this.itemToElement.delete(J),Y++}}this.listTop.style.height=String(w)+"px",this.listBottom.style.height=String(C)+"px";let $=[],{idPath:D}=this.options;for(let X=y;X<=m;X++){let J=c.items[X];if(J===void 0)continue;let Z=this.itemToElement.get(F(J));if(Z==null){if(H++,Z=e(this.template),typeof J==="object")this.itemToElement.set(F(J),Z),Z[v]=F(J);if(this.boundElement.insertBefore(Z,this.listBottom),D!=null){let p=J[D],Fn=`${M}[${D}=${p}]`;Mo(Z,Fn)}else{let p=`${M}[${X}]`;Mo(Z,p)}}$.push(Z)}let q=null;for(let X of $){if(X.previousElementSibling!==q)if(G++,q?.nextElementSibling!=null)this.boundElement.insertBefore(X,q.nextElementSibling);else this.boundElement.insertBefore(X,this.listBottom);q=X}if(c.interpolation!=null)this._updateInterpolatedBuffers(c);if(P.perf)console.log(M,"updated",{removed:Y,created:H,moved:G})}_updateInterpolatedBuffers(n){let{t:f,position:o,scrollTop:E,viewportHeight:M,totalScrollHeight:c,rowHeight:L}=n.interpolation,y=0;for(let i of Array.from(this.boundElement.children)){if(i===this.listTop||i===this.listBottom)continue;y+=i.offsetHeight||L}let m=E,w=E+M-y,C=Math.max(0,f*w+(1-f)*m-o%1*L);this.listTop.style.height=String(C)+"px",this.listBottom.style.height=String(Math.max(0,c-C-y))+"px"}}var En=(n,f,o)=>{let E=n[fn];if(f&&E===void 0)E=new co(n,f,o),n[fn]=E;return E},An=(n)=>{let f;while(!(f=n[v])&&n&&n.parentElement)n=n.parentElement;return f?{element:n,item:f}:void 0},On=(n)=>{let f=An(n);return f?f.item:void 0},mo=(n)=>{let f=An(n);if(!f)return console.error("deleteListItem failed, element is not part of a list instance",n),!1;let o=En(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},po={start:"start",middle:"center",end:"end",nearest:"nearest"},Lo=(n,f,o={})=>{let E=En(n);if(E==null)return console.error("scrollListItemIntoView failed, element has no list binding",n),!1;let{position:M="middle"}=o,c=E.filteredArray(),L=F(f)??f,y=c.indexOf(L);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 w=m.width!=null?Math.max(1,Math.floor(n.offsetWidth/m.width)):m.visibleColumns??1,C=Math.floor(y/w),i=m.minHeight??m.height,Y=Math.ceil(c.length/w),G=m.scrollContainer==="window",H=G?window.innerHeight:n.offsetHeight,$;if(m.minHeight!=null){let D=Math.ceil(H/i)+(m.rowChunkSize||1),q=Y*i,X=Math.max(0,q-H),J=Math.max(1,Y-D+1),Z=C/J;switch(M){case"start":$=Z*X;break;case"end":$=Math.max(0,(C-D+1)/J*X);break;case"nearest":{let p=G?Math.max(0,-n.getBoundingClientRect().top):n.scrollTop,Fn=X>0?p/X:0,$f=Math.floor(Fn*J);if(C<$f)$=Z*X;else if(C>=$f+D)$=Math.max(0,(C-D+1)/J*X);else return!0;break}default:{let p=C-Math.floor(D/2);$=Math.max(0,p)/J*X}}}else{let D=C*m.height;switch(M){case"start":$=D;break;case"end":$=D-H+m.height;break;case"nearest":{let q=G?Math.max(0,-n.getBoundingClientRect().top):n.scrollTop;if(D<q)$=D;else if(D+m.height>q+H)$=D-H+m.height;else return!0;break}default:$=D-(H-m.height)/2}}if($=Math.max(0,$),G){let D=n.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:D+$,behavior:"smooth"})}else n.scrollTo({top:$,behavior:"smooth"})}else{let w=E.itemToElement.get(L);if(w==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",f),!1;w.scrollIntoView({block:po[M]??"center",behavior:"smooth"})}return!0};var{document:Xn,MutationObserver:yo}=globalThis,sn=(n,f)=>{let o=K.get(n);if(o==null)return;for(let E of o){let{binding:M,options:c}=E,{path:L}=E,{toDOM:y}=M;if(y!=null){if(L.startsWith("^")){let m=On(n);if(m!=null&&m[r]!=null)L=E.path=`${m[r]}${L.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${L}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${L}`)}if(f==null||L.startsWith(f))y(n,Qn()[L],c)}}};if(yo!=null)new yo((f)=>{f.forEach((o)=>{Array.from(o.addedNodes).forEach((E)=>{if(E instanceof Element)Array.from(E.querySelectorAll(u)).forEach((M)=>sn(M))})})}).observe(Xn.body,{subtree:!0,childList:!0});_(()=>!0,(n)=>{let f=Array.from(Xn.querySelectorAll(u));for(let o of f)sn(o,n)});var wo=(n)=>{let f=n.target?.closest(u);while(f!=null){let o=K.get(f);for(let E of o){let{binding:M,path:c}=E,{fromDOM:L}=M;if(L!=null){let y;try{y=L(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=Qn(),w=m[c];if(w==null)m[c]=y;else{let C=w[r]!=null?w[B]:w,i=y[r]!=null?y[B]:y;if(C!==i)m[c]=i}}}}f=f.parentElement.closest(u)}};if(globalThis.document!=null)Xn.body.addEventListener("change",wo,!0),Xn.body.addEventListener("input",wo,!0);function A(n,f,o,E){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let M;if(typeof f==="object"&&f[r]===void 0&&E===void 0){let{value:y}=f;M=typeof y==="string"?y:y[r],E=f,delete E.value}else M=typeof f==="string"?f:f[r];if(M==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:c}=o;n.classList?.add(Vn);let L=K.get(n);if(L==null)L=[],K.set(n,L);if(L.push({path:M,binding:o,options:E}),c!=null&&!M.startsWith("^"))I(M);if(E?.filter&&E?.needle)A(n,E.needle,{toDOM(y,m){console.log({needle:m}),y[fn]?.filter(m)}});return n}var xo=new Set,go=(n)=>{let f=n?.target?.closest(Pn),o=!1,E=new Proxy(n,{get(c,L){if(L==="stopPropagation")return()=>{n.stopPropagation(),o=!0};else{let y=c[L];return typeof y==="function"?y.bind(c):y}}}),M=new Set;while(!o&&f!=null){let L=g.get(f)[n.type]||M;for(let y of L){if(typeof y==="function")y(E);else{let m=Qn()[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 a(n,f,o){let E=g.get(n);if(n.classList.add(un),E==null)E={},g.set(n,E);if(!E[f])E[f]=new Set;if(E[f].add(o),!xo.has(f))xo.add(f),Xn.body.addEventListener(f,go,!0);return()=>{E[f].delete(o)}}Kf(A,a);function Kn(n,f){if(!n.internals)return;let o={},E="";if(n.hasAttribute("required")&&f==="")o.valueMissing=!0,E="Please fill out this field.";let M=n.getAttribute("minlength");if(M&&f.length<parseInt(M,10))o.tooShort=!0,E=`Please use at least ${M} characters.`;let c=n.getAttribute("maxlength");if(c&&f.length>parseInt(c,10))o.tooLong=!0,E=`Please use no more than ${c} characters.`;let L=n.getAttribute("pattern");if(L&&f!=="")try{if(!new RegExp(`^(?:${L})$`).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 vo=0;function Xf(){return`custom-elt${(vo++).toString(36)}`}var Co=0,Tf=null;function eo(){if(Tf===null)Tf=new MutationObserver((n)=>{let f=new Set;for(let o of n)if(o.type==="attributes"&&o.target instanceof O){let E=o.target,M=Mf(o.attributeName);if(E._legacyTrackedAttrs?.has(M))f.add(E)}for(let o of f)o.queueRender(!1)});return Tf}var Tn={};function lo(n,f){let o=Tn[n],E=b(f).replace(/:host\(([^)]+)\)/g,`${n}$1`).replace(/:host\b/g,n);Tn[n]=o?o+`
|
|
13
|
-
`+E:E}function to(n){if(Tn[n])document.head.append(T.style({id:n+"-component"},Tn[n]));delete Tn[n]}class O extends HTMLElement{static elements=T;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(W)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=T.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"),T.style(b(n))}static elementCreator(n={}){let f=this;if(f._elementCreator==null){let{tag:o,styleSpec:E}=n,M=n!=null?o:null;if(M==null)if(typeof f.name==="string"&&f.name!==""){if(M=W(f.name),M.startsWith("-"))M=M.slice(1)}else M=Xf();if(customElements.get(M)!=null)console.warn(`${M} is already defined`);if(M.match(/\w+(-\w+)+/)==null)console.warn(`${M} is not a legal tag for a custom-element`),M=Xf();while(customElements.get(M)!==void 0)M=Xf();if(f._tagName=M,E!==void 0)lo(M,E);window.customElements.define(M,this,n),f._elementCreator=T[M]}return f._elementCreator}initAttributes(...n){if(d("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let M of n)this._legacyTrackedAttrs.add(M);eo().observe(this,{attributes:!0});let o={},E={};n.forEach((M)=>{o[M]=s(this[M]);let c=W(M);Object.defineProperty(this,M,{enumerable:!1,get(){if(typeof o[M]==="boolean")return this.hasAttribute(c);else if(this.hasAttribute(c))return typeof o[M]==="number"?parseFloat(this.getAttribute(c)):this.getAttribute(c);else if(E[M]!==void 0)return E[M];else return o[M]},set(L){if(typeof o[M]==="boolean"){if(L!==this[M]){if(L)this.setAttribute(c,"");else this.removeAttribute(c);this.queueRender()}}else if(typeof o[M]==="number"){if(L!==parseFloat(this[M]))this.setAttribute(c,L),this.queueRender()}else if(typeof L==="object"||`${L}`!==`${this[M]}`){if(L===null||L===void 0||typeof L==="object")this.removeAttribute(c);else this.setAttribute(c,L);this.queueRender(),E[M]=L}}})})}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"):s(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=Mf(n);if(!this._legacyTrackedAttrs?.has(E))this.queueRender(!1)}constructor(){super();if(Co+=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()}-${Co}`,this._value=s(this.defaultValue)}_setupAttributeAccessors(n){if(!this._attrValues)this._attrValues=new Map;for(let f of Object.keys(n)){let o=W(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 M=this,c=!1;while(M){let L=Object.getOwnPropertyDescriptor(M,f);if(L){if(!L.configurable||L.get||L.set){c=!0;break}break}M=Object.getPrototypeOf(M)}if(c)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:(L)=>{if(typeof E==="boolean"){if(L!==this[f]){if(L)this.setAttribute(o,"");else this.removeAttribute(o);this.queueRender()}}else if(typeof E==="number"){if(L!==parseFloat(this[f]))this.setAttribute(o,L),this.queueRender()}else if(typeof L==="object"||`${L}`!==`${this[f]}`){if(L===null||L===void 0||typeof L==="object")this.removeAttribute(o);else this.setAttribute(o,L);this.queueRender(),this._attrValues.set(f,L)}}})}}connectedCallback(){if(to(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(yn.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(){yn.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(T):this.content,{styleSpec:o}=this.constructor,{styleNode:E}=this.constructor;if(o)E=this.constructor.styleNode=T.style(b(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 M=this.attachShadow({mode:"open"});M.appendChild(E.cloneNode(!0)),Ef(M,f,n)}else if(f!==null){let M=Array.from(this.childNodes);Ef(this,f,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let c=Array.from(this.querySelectorAll("slot"));if(c.length>0)c.forEach(Df.replaceSlot);if(M.length>0){let L={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((y)=>{L[y.name]=y}),M.forEach((y)=>{let m=L[""],w=y instanceof Element?L[y.slot]:m;(w!==void 0?w: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);Kn(this,n)}}class Df 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 FM=Df.elementCreator({tag:"xin-slot"});var Ho=(n=()=>!0)=>{let f=localStorage.getItem("xin-state");if(f!=null){let E=JSON.parse(f);for(let M of Object.keys(E).filter(n))if(Q[M]!==void 0)Object.assign(Q[M],E[M]);else Q[M]=E[M]}let o=zn(()=>{let E={},M=F(Q);for(let c of Object.keys(M).filter(n))E[c]=M[c];localStorage.setItem("xin-state",JSON.stringify(E)),console.log("xin state saved to localStorage")},500);cn(n,o)};var Bn="1.4.0";function Dn(n){return Object.assign(k,n),k}function Yn(n){return d("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),Dn(n)}function dn(n,f=!1){if(f)return d("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),Yn(n);return Object.keys(n).forEach((o)=>{Q[o]=n[o]}),Q}var ao={};async function $n(n,f){let{type:o,styleSpec:E}=await f(n,{Color:x,Component:O,elements:T,svgElements:Un,mathML:jn,varDefault:Cn,vars:qn,xin:Q,boxed:k,xinProxy:dn,boxedProxy:Yn,tosi:Dn,makeComponent:$n,bind:A,on:a,version:Bn}),M={type:o,creator:o.elementCreator({tag:n,styleSpec:E})};return ao[n]=M,M}var Yf={},nE=(n)=>import(n);class Jn 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(Yf[E]===void 0)Yf[E]=nE(f).then((M)=>{let c=M[o];return $n(n,c)});else console.log(`using cached ${n} with signature ${E}`);this.loaded=await Yf[E],this.blueprintLoaded(this.loaded)}return this.loaded}}var io=Jn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class Rn extends O{allLoaded=()=>{};constructor(){super()}async load(){let f=Array.from(this.querySelectorAll(Jn.tagName)).filter((o)=>o.src).map((o)=>o.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var Xo=Rn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
|
|
12
|
+
`)},fM=(f)=>{m("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let E={};for(let M of Object.keys(f)){let L=f[M],H=k(M);E[`--${H}`]=typeof L==="number"&&L!==0?String(L)+"px":L}return E},EM=(f)=>{let E={};for(let M of Object.keys(f)){let L=f[M];if(L instanceof F)E[M]=L.inverseLuminance;else if(typeof L==="string"&&L.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))E[M]=F.fromCss(L).inverseLuminance}return E},zf=new Proxy({},{get(f,E){if(f[E]===void 0){let M="--"+k(E);f[E]=(L)=>`var(${M}, ${L})`}return f[E]}}),If=new Proxy({},{get(f,E){if(E==="default")return zf;if(f[E]==null){E=k(E);let[,M,,L,H,X]=E.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",E],J=`--${M}`;if(H!=null){let Y=L==null?Number(H)/100:-Number(H)/100;switch(X){case"b":case"s":case"h":case"o":{let w=`--${E}`;F.registerComputedColor(w,J,Y,X),f[E]=`var(${w})`}break;case"":f[E]=`calc(var(${J}) * ${Y})`;break;default:throw console.error(X),Error(`Unrecognized method ${X} for css variable ${J}`)}}else f[E]=`var(${J})`}return f[E]}});function ZE(){let f=(E)=>typeof matchMedia<"u"&&matchMedia(E).matches;return{colorScheme:f("(prefers-color-scheme: dark)")?"dark":"light",contrast:f("(prefers-contrast: more)")?"more":f("(prefers-contrast: less)")?"less":f("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:f("(prefers-reduced-motion: reduce)"),reducedTransparency:f("(prefers-reduced-transparency: reduce)"),forcedColors:f("(forced-colors: active)")}}function MM(f){if(typeof matchMedia>"u")return()=>{};let E=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],M=()=>f(ZE()),L=E.map((H)=>matchMedia(H));for(let H of L)H.addEventListener("change",M);return()=>{for(let H of L)H.removeEventListener("change",M)}}var LM="http://www.w3.org/1998/Math/MathML",HM="http://www.w3.org/2000/svg";var mf={},XM=(f,E,M)=>{let L=FE(k(E),M);if(L.prop.startsWith("--"))f.style.setProperty(L.prop,L.value);else f.style[E]=L.value},EL=(f)=>{return{toDOM(E,M){XM(E,f,M)}}},wM=(f,E,M)=>{if(E==="style")if(typeof M==="object")for(let L of Object.keys(M))if(O(M[L]))n(f,M[L],EL(L));else XM(f,L,M[L]);else f.setAttribute("style",M);else{let L=k(E),H=f.constructor.observedAttributes;if(H?.includes(E)||H?.includes(L))if(typeof M==="boolean")M?f.setAttribute(L,""):f.removeAttribute(L);else f.setAttribute(L,M);else if(f[E]!==void 0){let{MathMLElement:J}=globalThis;if(f instanceof SVGElement||J!==void 0&&f instanceof J)f.setAttribute(E,M);else f[E]=M}else if(L==="class")M.split(" ").forEach((J)=>{f.classList.add(J)});else if(f[L]!==void 0)f[L]=M;else if(typeof M==="boolean")M?f.setAttribute(L,""):f.removeAttribute(L);else f.setAttribute(L,M)}},QE={},ML=(f)=>{if(!QE[f])QE[f]={toDOM(E,M){wM(E,f,M)}};return QE[f]},LL=(f,E,M)=>{if(E==="apply")M(f);else if(E.match(/^on[A-Z]/)!=null){let L=E.substring(2).toLowerCase();ff(f,L,M)}else if(E==="bind")if((typeof M.binding==="string"?Cf[M.binding]:M.binding)!==void 0&&M.value!==void 0)n(f,M.value,M.binding instanceof Function?{toDOM:M.binding}:M.binding);else throw Error("bad binding");else if(E.match(/^bind[A-Z]/)!=null){let L=E.substring(4,5).toLowerCase()+E.substring(5),H=Cf[L];if(H!==void 0)n(f,M,H);else throw Error(`${E} is not allowed, bindings.${L} is not defined`)}else if(O(M))n(f,M,ML(E));else wM(f,E,M)},GE=(f,...E)=>{if(mf[f]===void 0){let[H,X]=f.split("|");if(X===void 0)mf[f]=globalThis.document.createElement(H);else mf[f]=globalThis.document.createElementNS(X,H)}let M=mf[f].cloneNode(),L={};for(let H of E)if(H instanceof Element||H instanceof DocumentFragment||typeof H==="string"||typeof H==="number")if(M instanceof HTMLTemplateElement)M.content.append(H);else M.append(H);else if(O(H))M.append(z.span({bindText:H}));else Object.assign(L,H);for(let H of Object.keys(L)){let X=L[H];LL(M,H,X)}return M},CE=(...f)=>{let E=globalThis.document.createDocumentFragment();for(let M of f)E.append(M);return E},z=new Proxy({fragment:CE},{get(f,E){if(E=E.replace(/[A-Z]/g,(M)=>`-${M.toLocaleLowerCase()}`),f[E]===void 0)f[E]=(...M)=>GE(E,...M);return f[E]},set(){throw Error("You may not add new properties to elements")}}),Bf=new Proxy({fragment:CE},{get(f,E){if(f[E]===void 0)f[E]=(...M)=>GE(`${E}|${HM}`,...M);return f[E]},set(){throw Error("You may not add new properties to elements")}}),Sf=new Proxy({fragment:CE},{get(f,E){if(f[E]===void 0)f[E]=(...M)=>GE(`${E}|${LM}`,...M);return f[E]},set(){throw Error("You may not add new properties to elements")}});var HL=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],XL=!0,wL=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,JL=(f)=>wL.test(f),h=(f="",E="")=>{if(f==="")return E;else if(E.match(/^\d+$/)!==null||E.includes("="))return`${f}[${E}]`;else return`${f}.${E}`},FM={};function zE(f,E){if(f!==null&&(typeof f==="object"||typeof f==="function"))return f;return new Proxy(FM,r(E,!0))}var Wf=()=>new Proxy({},r("^",!0)),WE=(f)=>{let M=f(Wf())?.path;if(!M?.startsWith("^."))throw Error("selector must return a property of the item");return M.substring(2)},xE=(f,E,M)=>{for(let L=0;L<f.length;L++)if(`${j(f[L],E)}`===`${M}`)return L;return-1},JM=(f,E)=>({listFind(M,L){if(M instanceof Element){let J=M;while(J&&!J[t]&&J.parentElement)J=J.parentElement;let Y=J?.[t];if(Y==null)return;let w=E.indexOf(Y);return w!==-1?V[f][w]:void 0}let H=WE(M),X=xE(E,H,L);return X!==-1?V[f][X]:void 0},listUpdate(M,L){let H=WE(M),X=j(L,H),J=xE(E,H,X);if(J!==-1){let Y=V[f][J];for(let w of Object.keys(L))Y[w]=L[w];return Y}return V[f].push(L),V[f][E.length-1]},listRemove(M,L){let H=WE(M),X=xE(E,H,L);if(X===-1)return!1;return V[f].splice(X,1),!0}}),YM=!1;function Ef(){if(!YM)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),YM=!0}var $M=(f)=>{return f===FM},r=(f,E)=>({get(M,L){if($M(M)){let Y=()=>j(y,f);switch(L){case"path":return f;case"value":return Y();case"valueOf":case"toJSON":return()=>Y();case Symbol.toPrimitive:return(w)=>{let $=Y();if(w==="number")return Number($);if(w==="string")return String($);return $};case"toString":return()=>String(Y());case"touch":return()=>B(f);case"observe":return(w)=>{let $=c(f,w);return()=>o($)};case"on":return(w,$)=>Ff()(w,$,Y());case"bind":return(w,$,Z)=>{$f()(w,f,$,Z)};case"binding":return(w)=>({bind:{value:f,binding:w}});case"listBinding":return(w=({span:Z})=>Z({bindText:"^"}),$={})=>[{bindList:{value:f,...$}},z.template(w(z,Wf()))];case"listFind":case"listUpdate":case"listRemove":return JM(f,M)[L];case b:case"xinValue":case"tosiValue":return Ef(),Y();case I:case"xinPath":case"tosiPath":return Ef(),f;case pf:case"tosiObserve":return Ef(),(w)=>{let $=c(f,w);return()=>o($)};case tf:case"tosiOn":return Ef(),(w,$)=>Ff()(w,$,Y());case lf:case"tosiBind":return Ef(),(w,$,Z)=>{$f()(w,f,$,Z)};case"tosiBinding":return Ef(),(w)=>({bind:{value:f,binding:w}});case"tosiListBinding":return Ef(),(w=({span:Z})=>Z({bindText:"^"}),$={})=>[{bindList:{value:f,...$}},z.template(w(z,Wf()))]}if(typeof L==="string"&&/^\d+$/.test(L)){let w=Y();if(typeof w==="string")return w[parseInt(L,10)]}if(L==="length"){let w=Y();if(typeof w==="string")return w.length}return}if(E&&!(L in M))switch(L){case"path":return f;case"value":return M.valueOf?M.valueOf():M;case"valueOf":case"toJSON":return()=>M.valueOf?M.valueOf():M;case"touch":return()=>B(f);case"observe":return(Y)=>{let w=c(f,Y);return()=>o(w)};case"on":return(Y,w)=>Ff()(Y,w,U(M));case"bind":return(Y,w,$)=>{$f()(Y,f,w,$)};case"binding":return(Y)=>({bind:{value:f,binding:Y}});case"listBinding":return(Y=({span:$})=>$({bindText:"^"}),w={})=>[{bindList:{value:f,...w}},z.template(Y(z,Wf()))];case"listFind":case"listUpdate":case"listRemove":return JM(f,M)[L]}switch(L){case I:case"xinPath":case"tosiPath":return f;case b:case"xinValue":case"tosiValue":return M.valueOf?M.valueOf():M;case pf:case"xinObserve":case"tosiObserve":return(Y)=>{let w=c(f,Y);return()=>o(w)};case tf:case"xinOn":case"tosiOn":return(Y,w)=>Ff()(Y,w,U(M));case lf:case"xinBind":case"tosiBind":return(Y,w,$)=>{$f()(Y,f,w,$)};case"tosiBinding":return(Y)=>({bind:{value:f,binding:Y}});case"tosiListBinding":return(Y=({span:$})=>$({bindText:"^"}),w={})=>[{bindList:{value:f,...w}},z.template(Y(z,Wf()))]}if(typeof L==="symbol")return M[L];let H=Object.getOwnPropertyDescriptor(M,L);if(H&&!H.configurable&&!H.writable&&"value"in H)return H.value;let X=L,J=X.match(/^([^.[]+)\.(.+)$/)??X.match(/^([^\]]+)(\[.+)/)??X.match(/^(\[[^\]]+\])\.(.+)$/)??X.match(/^(\[[^\]]+\])\[(.+)$/);if(J!==null){let[,Y,w]=J,$=h(f,Y),Z=j(M,Y);return Z!==null&&typeof Z==="object"?new Proxy(Z,r($,E))[w]:Z}if(X.startsWith("[")&&X.endsWith("]"))X=X.substring(1,X.length-1);if(!Array.isArray(M)&&M[X]!==void 0||Array.isArray(M)&&X.includes("=")){let Y;if(X.includes("=")){let[w,$]=X.split("=");Y=M.find((Z)=>`${j(Z,w)}`===$)}else Y=M[X];if(Y instanceof Object){let w=h(f,X);return new Proxy(Y instanceof Function?Y.bind(M):Y,r(w,E))}else return E?zE(Y,h(f,X)):Y}else if(Array.isArray(M)){let Y=M[X];return typeof Y==="function"?(...w)=>{let $=w.map((G)=>U(G)),Z=Y.apply(M,$);if(HL.includes(X))B(f);if(Z!=null&&typeof Z==="object"){if(X==="find"||X==="findLast"||X==="at"){let G=M.indexOf(Z);if(G!==-1)return new Proxy(Z,r(h(f,String(G)),E))}}return Z}:typeof Y==="object"?new Proxy(Y,r(h(f,X),E)):E?zE(Y,h(f,X)):Y}else return E?zE(M[X],h(f,X)):M[X]},set(M,L,H){H=U(H);let J=L===b||L==="xinValue"||L==="tosiValue"||L==="value"&&($M(M)||E)?f:h(f,L);if(XL&&!JL(J))throw Error(`setting invalid path ${J}`);if(U(K[J])!==H&&Yf(y,J,H))B(J);return!0}}),Jf=(f,E)=>{let M=typeof E==="function"?E:K[E];if(typeof M!=="function")throw Error(`observe expects a function or path to a function, ${E} is neither`);return c(f,M)},K=new Proxy(y,r("",!1));uE(K);var V=new Proxy(y,r("",!0));var YL=16,$L=100;function ZM(f,E){let M=Array.from(f.querySelectorAll(i));if(f.matches(i))M.unshift(f);for(let L of M){let H=N.get(L);for(let X of H){if(X.path.startsWith("^"))X.path=`${E}${X.path.substring(1)}`;if(X.binding.toDOM!=null)X.binding.toDOM(L,K[X.path])}}}class QM{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(f,E,M={}){if(this.boundElement=f,this.itemToElement=new WeakMap,M.idPath!=null){let L=O(E);if(L!=null)RE(L,M.idPath)}if(f.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(f.children[0]instanceof HTMLTemplateElement){let L=f.children[0];if(L.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=e(L.content.children[0])}else this.template=f.children[0],this.template.remove();if(this.options=M,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[Lf]=this,M.virtual!=null)if(Qf.observe(this.boundElement),this._update=Gf(()=>{this.update(this.array,!0)},YL),this.boundElement.addEventListener("resize",this._update),M.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){if(this._filteredCache!=null)return this._filteredCache;let{hiddenProp:f,visibleProp:E}=this.options,M=this.array;if(f!==void 0)M=M.filter((L)=>L[f]!==!0);if(E!==void 0)M=M.filter((L)=>L[E]===!0);if(this.options.filter&&this.needle!==void 0)M=this.options.filter(M,this.needle);return this._filteredCache=M,M}visibleSlice(){let{virtual:f}=this.options,E=this.filteredArray(),M=0,L=E.length-1,H=0,X=0;if(f!=null&&this.boundElement instanceof HTMLElement){let J=this.boundElement.offsetWidth,Y=f.scrollContainer==="window",w,$;if(Y){w=window.innerHeight;let x=this.boundElement.getBoundingClientRect();$=Math.max(0,-x.top)}else w=this.boundElement.offsetHeight,$=this.boundElement.scrollTop;let Z=f.width!=null?Math.max(1,Math.floor(J/f.width)):f.visibleColumns??1,G=Math.ceil(E.length/Z);if(f.minHeight!=null){let x=f.minHeight,A=Math.ceil(w/x)+(f.rowChunkSize||1),Q=Z*A,T=G*x,W=Math.max(0,T-w),R=W>0?Math.min(1,Math.max(0,$/W)):0,C=Math.max(0,G-A+1),D=R*C,q=Math.floor(D);if(f.rowChunkSize)q-=q%f.rowChunkSize;return M=q*Z,L=M+Q-1,H=$,X=Math.max(0,T-$-w),{items:E,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:X,interpolation:{t:R,position:D,scrollTop:$,viewportHeight:w,totalScrollHeight:T,rowHeight:f.height}}}else{let x=Math.ceil(w/f.height)+(f.rowChunkSize||1),A=Z*x,Q=Math.floor($/f.height);if(Q>G-x+1)Q=Math.max(0,G-x+1);if(f.rowChunkSize)Q-=Q%f.rowChunkSize;M=Q*Z,L=M+A-1,H=Q*f.height,X=Math.max((G-x)*f.height-H,0)}}return{items:E,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:X}}needle;filter=Gf((f)=>{if(this.needle!==f)this.needle=f,this.update(this.array)},$L);update(f,E){if(f==null)f=[];if(this.array=f,!E)this._filteredCache=void 0;let{hiddenProp:M,visibleProp:L}=this.options,H=O(f),X=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",X.items.length===0);let J=this._previousSlice,{firstItem:Y,lastItem:w,topBuffer:$,bottomBuffer:Z}=X,G=M===void 0&&L===void 0&&E===!0&&J!=null&&Y===J.firstItem&&w===J.lastItem;if(G&&X.interpolation==null&&$===J.topBuffer&&Z===J.bottomBuffer)return;if(G&&X.interpolation!=null){this._updateInterpolatedBuffers(X);return}this._previousSlice=X;let x=0,A=0,Q=0;for(let C of Array.from(this.boundElement.children)){if(C===this.listTop||C===this.listBottom)continue;let D=C[t];if(D==null)C.remove();else{let q=X.items.indexOf(D);if(q<Y||q>w)C.remove(),this.itemToElement.delete(D),x++}}this.listTop.style.height=String($)+"px",this.listBottom.style.height=String(Z)+"px";let T=[],{idPath:W}=this.options;for(let C=Y;C<=w;C++){let D=X.items[C];if(D===void 0)continue;let q=this.itemToElement.get(U(D));if(q==null){if(Q++,q=e(this.template),typeof D==="object")this.itemToElement.set(U(D),q),q[t]=U(D);if(this.boundElement.insertBefore(q,this.listBottom),W!=null){let p=D[W],Af=`${H}[${W}=${p}]`;ZM(q,Af)}else{let p=`${H}[${C}]`;ZM(q,p)}}T.push(q)}let R=null;for(let C of T){if(C.previousElementSibling!==R)if(A++,R?.nextElementSibling!=null)this.boundElement.insertBefore(C,R.nextElementSibling);else this.boundElement.insertBefore(C,this.listBottom);R=C}if(X.interpolation!=null)this._updateInterpolatedBuffers(X);if(g.perf)console.log(H,"updated",{removed:x,created:Q,moved:A})}_updateInterpolatedBuffers(f){let{t:E,position:M,scrollTop:L,viewportHeight:H,totalScrollHeight:X,rowHeight:J}=f.interpolation,Y=0;for(let G of Array.from(this.boundElement.children)){if(G===this.listTop||G===this.listBottom)continue;Y+=G.offsetHeight||J}let w=L,$=L+H-Y,Z=Math.max(0,E*$+(1-E)*w-M%1*J);this.listTop.style.height=String(Z)+"px",this.listBottom.style.height=String(Math.max(0,X-Z-Y))+"px"}}var wf=(f,E,M)=>{let L=f[Lf];if(E&&L===void 0)L=new QM(f,E,M),f[Lf]=L;return L},nf=(f)=>{let E;while(!(E=f[t])&&f&&f.parentElement)f=f.parentElement;return E?{element:f,item:E}:void 0},_f=(f)=>{let E=nf(f);return E?E.item:void 0},GM=(f)=>{let E=nf(f);if(!E)return console.error("deleteListItem failed, element is not part of a list instance",f),!1;let M=wf(E.element.parentElement);if(!M.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",f.parentElement,M),!1;let L=M.array.indexOf(E.item);if(L>-1)return M.array.splice(L,1),!0;return!1},FL={start:"start",middle:"center",end:"end",nearest:"nearest"},CM=(f,E,M={})=>{let L=wf(f);if(L==null)return console.error("scrollListItemIntoView failed, element has no list binding",f),!1;let{position:H="middle"}=M,X=L.filteredArray(),J=U(E)??E,Y=X.indexOf(J);if(Y===-1)return console.error("scrollListItemIntoView failed, item not found in list",E),!1;let{virtual:w}=L.options;if(w!=null&&f instanceof HTMLElement){let $=w.width!=null?Math.max(1,Math.floor(f.offsetWidth/w.width)):w.visibleColumns??1,Z=Math.floor(Y/$),G=w.minHeight??w.height,x=Math.ceil(X.length/$),A=w.scrollContainer==="window",Q=A?window.innerHeight:f.offsetHeight,T;if(w.minHeight!=null){let W=Math.ceil(Q/G)+(w.rowChunkSize||1),R=x*G,C=Math.max(0,R-Q),D=Math.max(1,x-W+1),q=Z/D;switch(H){case"start":T=q*C;break;case"end":T=Math.max(0,(Z-W+1)/D*C);break;case"nearest":{let p=A?Math.max(0,-f.getBoundingClientRect().top):f.scrollTop,Af=C>0?p/C:0,yE=Math.floor(Af*D);if(Z<yE)T=q*C;else if(Z>=yE+W)T=Math.max(0,(Z-W+1)/D*C);else return!0;break}default:{let p=Z-Math.floor(W/2);T=Math.max(0,p)/D*C}}}else{let W=Z*w.height;switch(H){case"start":T=W;break;case"end":T=W-Q+w.height;break;case"nearest":{let R=A?Math.max(0,-f.getBoundingClientRect().top):f.scrollTop;if(W<R)T=W;else if(W+w.height>R+Q)T=W-Q+w.height;else return!0;break}default:T=W-(Q-w.height)/2}}if(T=Math.max(0,T),A){let W=f.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:W+T,behavior:"smooth"})}else f.scrollTo({top:T,behavior:"smooth"})}else{let $=L.itemToElement.get(J);if($==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",E),!1;$.scrollIntoView({block:FL[H]??"center",behavior:"smooth"})}return!0};var{document:xf,MutationObserver:zM}=globalThis,cf=(f,E)=>{let M=N.get(f);if(M==null)return;for(let L of M){let{binding:H,options:X}=L,{path:J}=L,{toDOM:Y}=H;if(Y!=null){if(J.startsWith("^")){let w=_f(f);if(w!=null&&w[I]!=null)J=L.path=`${w[I]}${J.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${J}`,f,"is not part of a list"),Error(`Cannot resolve relative binding ${J}`)}if(E==null||J.startsWith(E))Y(f,yf()[J],X)}}};if(zM!=null)new zM((E)=>{E.forEach((M)=>{Array.from(M.addedNodes).forEach((L)=>{if(L instanceof Element)Array.from(L.querySelectorAll(i)).forEach((H)=>cf(H))})})}).observe(xf.body,{subtree:!0,childList:!0});c(()=>!0,(f)=>{let E=Array.from(xf.querySelectorAll(i));for(let M of E)cf(M,f)});var WM=(f)=>{let E=f.target?.closest(i);while(E!=null){let M=N.get(E);for(let L of M){let{binding:H,path:X}=L,{fromDOM:J}=H;if(J!=null){let Y;try{Y=J(E,L.options)}catch(w){throw console.error("Cannot get value from",E,"via",L),Error("Cannot obtain value fromDOM")}if(Y!=null){let w=yf(),$=w[X];if($==null)w[X]=Y;else{let Z=$[I]!=null?$[b]:$,G=Y[I]!=null?Y[b]:Y;if(Z!==G)w[X]=G}}}}E=E.parentElement.closest(i)}};if(globalThis.document!=null)xf.body.addEventListener("change",WM,!0),xf.body.addEventListener("input",WM,!0);function n(f,E,M,L){if(f instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let H;if(typeof E==="object"&&E[I]===void 0&&L===void 0){let{value:Y}=E;H=typeof Y==="string"?Y:Y[I],L=E,delete L.value}else H=typeof E==="string"?E:E[I];if(H==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:X}=M;f.classList?.add(sf);let J=N.get(f);if(J==null)J=[],N.set(f,J);if(J.push({path:H,binding:M,options:L}),X!=null&&!H.startsWith("^"))B(H);if(L?.filter&&L?.needle)n(f,L.needle,{toDOM(Y,w){console.log({needle:w}),Y[Lf]?.filter(w)}});return f}var xM=new Set,ZL=(f)=>{let E=f?.target?.closest(rf),M=!1,L=new Proxy(f,{get(X,J){if(J==="stopPropagation")return()=>{f.stopPropagation(),M=!0};else{let Y=X[J];return typeof Y==="function"?Y.bind(X):Y}}}),H=new Set;while(!M&&E!=null){let J=l.get(E)[f.type]||H;for(let Y of J){if(typeof Y==="function")Y(L);else{let w=yf()[Y];if(typeof w==="function")w(L);else throw Error(`no event handler found at path ${Y}`)}if(M)continue}E=E.parentElement!=null?E.parentElement.closest(rf):null}};function ff(f,E,M){let L=l.get(f);if(f.classList.add(hf),L==null)L={},l.set(f,L);if(!L[E])L[E]=new Set;if(L[E].add(M),!xM.has(E))xM.add(E),xf.body.addEventListener(E,ZL,!0);return()=>{L[E].delete(M)}}oE(n,ff);function Pf(f,E){if(!f.internals)return;let M={},L="";if(f.hasAttribute("required")&&E==="")M.valueMissing=!0,L="Please fill out this field.";let H=f.getAttribute("minlength");if(H&&E.length<parseInt(H,10))M.tooShort=!0,L=`Please use at least ${H} characters.`;let X=f.getAttribute("maxlength");if(X&&E.length>parseInt(X,10))M.tooLong=!0,L=`Please use no more than ${X} characters.`;let J=f.getAttribute("pattern");if(J&&E!=="")try{if(!new RegExp(`^(?:${J})$`).test(E))M.patternMismatch=!0,L="Please match the requested format."}catch{}if(Object.keys(M).length>0)f.internals.setValidity(M,L,f);else f.internals.setValidity({})}var QL=0;function TE(){return`custom-elt${(QL++).toString(36)}`}var TM=0,DE=null;function GL(){if(DE===null)DE=new MutationObserver((f)=>{let E=new Set;for(let M of f)if(M.type==="attributes"&&M.target instanceof _){let L=M.target,H=$E(M.attributeName);if(L._legacyTrackedAttrs?.has(H))E.add(L)}for(let M of E)M.queueRender(!1)});return DE}var Tf={};function CL(f,E){let M=Tf[f],L=s(E).replace(/:host\(([^)]+)\)/g,`${f}$1`).replace(/:host\b/g,f);Tf[f]=M?M+`
|
|
13
|
+
`+L:L}function zL(f){if(Tf[f])document.head.append(z.style({id:f+"-component"},Tf[f]));delete Tf[f]}class _ extends HTMLElement{static elements=z;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(f){if(this.internals)if(f)this.internals.setValidity({customError:!0},f);else this.internals.setValidity({})}setValidity(f,E,M){this.internals?.setValidity(f,E,M)}setFormValue(f,E){this.internals?.setFormValue(f,E)}static get observedAttributes(){let f=this.initAttributes;if(f)return["hidden",...Object.keys(f).map(k)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=z.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(f){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),z.style(s(f))}static elementCreator(f={}){let E=this;if(!Object.prototype.hasOwnProperty.call(E,"_elementCreator")){let{tag:M,styleSpec:L}=f,H=f!=null?M:null;if(H==null)if(typeof E.name==="string"&&E.name!==""){if(H=k(E.name),H.startsWith("-"))H=H.slice(1)}else H=TE();if(customElements.get(H)!=null)console.warn(`${H} is already defined`);if(H.match(/\w+(-\w+)+/)==null)console.warn(`${H} is not a legal tag for a custom-element`),H=TE();while(customElements.get(H)!==void 0)H=TE();if(E._tagName=H,L!==void 0)CL(H,L);window.customElements.define(H,this,f),E._elementCreator=z[H]}return E._elementCreator}initAttributes(...f){if(m("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let H of f)this._legacyTrackedAttrs.add(H);GL().observe(this,{attributes:!0});let M={},L={};f.forEach((H)=>{M[H]=P(this[H]);let X=k(H);Object.defineProperty(this,H,{enumerable:!1,get(){if(typeof M[H]==="boolean")return this.hasAttribute(X);else if(this.hasAttribute(X))return typeof M[H]==="number"?parseFloat(this.getAttribute(X)):this.getAttribute(X);else if(L[H]!==void 0)return L[H];else return M[H]},set(J){if(typeof M[H]==="boolean"){if(J!==this[H]){if(J)this.setAttribute(X,"");else this.removeAttribute(X);this.queueRender()}}else if(typeof M[H]==="number"){if(J!==parseFloat(this[H]))this.setAttribute(X,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[H]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute(X);else this.setAttribute(X,J);this.queueRender(),L[H]=J}}})})}initValue(){let f=Object.getOwnPropertyDescriptor(this,"value");if(f===void 0||f.get!==void 0||f.set!==void 0)return;let E=this.hasAttribute("value")?this.getAttribute("value"):P(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return E},set(M){if(E!==M)E=M,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let f=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(E,M){if(E[M]===void 0){let L=f.querySelector(`[part="${M}"]`);if(L==null)L=f.querySelector(M);if(L==null)throw Error(`elementRef "${M}" does not exist!`);L.removeAttribute("data-ref"),E[M]=L}return E[M]}});return this._parts}attributeChangedCallback(f,E,M){let L=$E(f);if(!this._legacyTrackedAttrs?.has(L))this.queueRender(!1)}constructor(){super();if(TM+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let f=this.constructor.initAttributes;if(f)this._setupAttributeAccessors(f);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${TM}`,this._value=P(this.defaultValue)}_setupAttributeAccessors(f){if(!this._attrValues)this._attrValues=new Map;for(let E of Object.keys(f)){let M=k(E),L=f[E];if(E==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof L==="object"&&L!==null){console.warn(`${this.tagName}: initAttributes.${E} is an object. Use a regular property instead.`);continue}let H=this,X=!1;while(H){let J=Object.getOwnPropertyDescriptor(H,E);if(J){if(!J.configurable||J.get||J.set){X=!0;break}break}H=Object.getPrototypeOf(H)}if(X)continue;Object.defineProperty(this,E,{enumerable:!1,get:()=>{if(typeof L==="boolean")return this.hasAttribute(M);else if(this.hasAttribute(M))return typeof L==="number"?parseFloat(this.getAttribute(M)):this.getAttribute(M);else if(this._attrValues.has(E))return this._attrValues.get(E);else return L},set:(J)=>{if(typeof L==="boolean"){if(J!==this[E]){if(J)this.setAttribute(M,"");else this.removeAttribute(M);this.queueRender()}}else if(typeof L==="number"){if(J!==parseFloat(this[E]))this.setAttribute(M,J),this.queueRender()}else if(typeof J==="object"||`${J}`!==`${this[E]}`){if(J===null||J===void 0||typeof J==="object")this.removeAttribute(M);else this.setAttribute(M,J);this.queueRender(),this._attrValues.set(E,J)}}})}}connectedCallback(){if(zL(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(Qf.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(){Qf.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(f){if(f)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(f){if(this.value!==void 0&&typeof f==="string")this.value=f}_changeQueued=!1;_renderQueued=!1;queueRender(f=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=f;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued){if(JE(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 f=typeof this.content!=="function",E=typeof this.content==="function"?this.content(z):this.content,{styleSpec:M}=this.constructor,{styleNode:L}=this.constructor;if(M)L=this.constructor.styleNode=z.style(s(M)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),L=this.styleNode;if(L){let H=this.attachShadow({mode:"open"});H.appendChild(L.cloneNode(!0)),YE(H,E,f)}else if(E!==null){let H=Array.from(this.childNodes);YE(this,E,f),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let X=Array.from(this.querySelectorAll("slot"));if(X.length>0)X.forEach(UE.replaceSlot);if(H.length>0){let J={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((Y)=>{J[Y.name]=Y}),H.forEach((Y)=>{let w=J[""],$=Y instanceof Element?J[Y.slot]:w;($!==void 0?$:w).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 f=typeof this.value==="string"?this.value:String(this.value);Pf(this,f)}}class UE extends _{static initAttributes={name:""};content=null;static replaceSlot(f){let E=document.createElement("xin-slot");if(f.name!=="")E.setAttribute("name",f.name);f.replaceWith(E)}}var r0=UE.elementCreator({tag:"xin-slot"});var DM=(f=()=>!0)=>{let E=localStorage.getItem("xin-state");if(E!=null){let L=JSON.parse(E);for(let H of Object.keys(L).filter(f))if(K[H]!==void 0)Object.assign(K[H],L[H]);else K[H]=L[H]}let M=Xf(()=>{let L={},H=U(K);for(let X of Object.keys(H).filter(f))L[X]=H[X];localStorage.setItem("xin-state",JSON.stringify(L)),console.log("xin state saved to localStorage")},500);Jf(f,M)};var WL="tosijs-share",xL="tosijs-share",Df="shared",TL=1,OE=new Set,KE=new Set,qE=new Map,Mf=null,AE="",Nf=null,DL=null;function UM(){if(Nf!=null)return Promise.resolve(Nf);return new Promise((f,E)=>{let M=indexedDB.open(xL,TL);M.onupgradeneeded=()=>{M.result.createObjectStore(Df)},M.onsuccess=()=>{Nf=M.result,f(Nf)},M.onerror=()=>E(M.error)})}var UL={async get(f){let E=await UM();return new Promise((M,L)=>{let X=E.transaction(Df,"readonly").objectStore(Df).get(f);X.onsuccess=()=>M(X.result),X.onerror=()=>L(X.error)})},async set(f,E){let M=await UM();return new Promise((L,H)=>{let X=M.transaction(Df,"readwrite");X.objectStore(Df).put(E,f),X.oncomplete=()=>L(),X.onerror=()=>H(X.error)})}};function qM(){return DL??UL}function qL(f){return f!=null&&f.type==="tosijs-share"&&typeof f.path==="string"}function OM(f){for(let E of OE)if(f===E||f.startsWith(E+"."))return E;return}function OL(f){for(let E of KE)if(f===E||f.startsWith(E+"."))return!0;return!1}function KL(f,E){KE.add(f),Yf(y,f,E),B(f),Zf().then(()=>{KE.delete(f)})}function AL(){if(Mf!=null)return Mf;return AE=crypto.randomUUID(),Mf=new BroadcastChannel(WL),Mf.onmessage=(f)=>{let E=f.data;if(!qL(E))return;if(E.origin===AE)return;if(OM(E.path)===void 0)return;KL(E.path,E.value)},Mf}function jL(f,E){if(Mf==null)return;let M={type:"tosijs-share",path:f,value:E,origin:AE};Mf.postMessage(M)}function yL(f){if(!qE.has(f))qE.set(f,Xf(()=>{let E=j(y,f);qM().set(f,E)},500));qE.get(f)()}async function KM(...f){if(typeof BroadcastChannel>"u")return{restored:[]};AL();let E=[],M=qM();for(let L of f){let H=typeof L==="string"?L:O(L);if(H===void 0)throw Error("share() requires boxed proxies or string paths. Got a non-proxy value.");if(OE.has(H))continue;OE.add(H);let X=await M.get(H);if(X!==void 0)Yf(y,H,X),B(H),E.push(L);else{let J=j(y,H);await M.set(H,J)}c((J)=>J===H||J.startsWith(H+"."),(J)=>{if(OL(J))return;let Y=OM(J);if(Y===void 0)return;let w=j(y,J);jL(J,w),yL(Y)})}return{restored:E}}var bf="1.4.2";function Uf(f){return Object.assign(V,f),V}function qf(f){return m("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),Uf(f)}function uf(f,E=!1){if(E)return m("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),qf(f);return Object.keys(f).forEach((M)=>{K[M]=f[M]}),K}var kL={};async function Of(f,E){let{type:M,styleSpec:L}=await E(f,{Color:F,Component:_,elements:z,svgElements:Bf,mathML:Sf,varDefault:zf,vars:If,xin:K,boxed:V,xinProxy:uf,boxedProxy:qf,tosi:Uf,makeComponent:Of,bind:n,on:ff,version:bf}),H={type:M,creator:M.elementCreator({tag:f,styleSpec:L})};return kL[f]=H,H}var of={":host":{display:"none"}},jE={},VL=(f)=>import(f);class Kf extends _{static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(f)=>{};async packaged(){let{tag:f,src:E,property:M}=this,L=`${f}.${M}:${E}`;if(!this.loaded){if(jE[L]===void 0)jE[L]=VL(E).then((H)=>{let X=H[M];return Of(f,X)});else console.log(`using cached ${f} with signature ${L}`);this.loaded=await jE[L],this.blueprintLoaded(this.loaded)}return this.loaded}}var AM=Kf.elementCreator({tag:"tosi-blueprint",styleSpec:of});class df extends _{allLoaded=()=>{};async load(){let E=Array.from(this.querySelectorAll("tosi-blueprint, xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(E),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var jM=df.elementCreator({tag:"tosi-loader",styleSpec:of});class yM extends Kf{constructor(){super();m("xin-blueprint","<xin-blueprint> is deprecated. Use <tosi-blueprint> instead.")}}var kM=yM.elementCreator({tag:"xin-blueprint",styleSpec:of});class VM extends _{allLoaded=()=>{};constructor(){super();m("xin-loader","<xin-loader> is deprecated. Use <tosi-loader> instead.")}async load(){let E=Array.from(this.querySelectorAll("xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(E),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var RM=VM.elementCreator({tag:"xin-loader",styleSpec:of});})();
|
|
14
14
|
|
|
15
|
-
//# debugId=
|
|
15
|
+
//# debugId=281D8A5CC217BAC964756E2164756E21
|
|
16
16
|
//# sourceMappingURL=index.js.map
|