tosijs 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ ${f} }`}else return Of(f,i,o)},V=(n,o="")=>{return Object.keys(n).map((i)=>{let
9
9
  ${m}
10
10
  }`}).join(`
11
11
 
12
- `)},eo=(n)=>{q("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let o={};for(let f of Object.keys(n)){let i=n[f],c=$(f);o[`--${c}`]=typeof i==="number"&&i!==0?String(i)+"px":i}return o},bo=(n)=>{let o={};for(let f of Object.keys(n)){let i=n[f];if(i instanceof y)o[f]=i.inverseLuminance;else if(typeof i==="string"&&i.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))o[f]=y.fromCss(i).inverseLuminance}return o},wn=new Proxy({},{get(n,o){if(n[o]===void 0){let f="--"+$(o);n[o]=(i)=>`var(${f}, ${i})`}return n[o]}}),Zn=new Proxy({},{get(n,o){if(o==="default")return wn;if(n[o]==null){o=$(o);let[,f,,i,c,m]=o.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",o],r=`--${f}`;if(c!=null){let w=i==null?Number(c)/100:-Number(c)/100;switch(m){case"b":case"s":case"h":case"o":{let E=`--${o}`;y.registerComputedColor(E,r,w,m),n[o]=`var(${E})`}break;case"":n[o]=`calc(var(${r}) * ${w})`;break;default:throw console.error(m),Error(`Unrecognized method ${m} for css variable ${r}`)}}else n[o]=`var(${r})`}return n[o]}});function co(){let n=(o)=>typeof matchMedia<"u"&&matchMedia(o).matches;return{colorScheme:n("(prefers-color-scheme: dark)")?"dark":"light",contrast:n("(prefers-contrast: more)")?"more":n("(prefers-contrast: less)")?"less":n("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:n("(prefers-reduced-motion: reduce)"),reducedTransparency:n("(prefers-reduced-transparency: reduce)"),forcedColors:n("(forced-colors: active)")}}function Po(n){if(typeof matchMedia>"u")return()=>{};let o=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],f=()=>n(co()),i=o.map((c)=>matchMedia(c));for(let c of i)c.addEventListener("change",f);return()=>{for(let c of i)c.removeEventListener("change",f)}}var _o="http://www.w3.org/1998/Math/MathML",ho="http://www.w3.org/2000/svg";var dn={},po=(n,o,f)=>{let i=io($(o),f);if(i.prop.startsWith("--"))n.style.setProperty(i.prop,i.value);else n.style[o]=i.value},Uf=(n)=>{return{toDOM(o,f){po(o,n,f)}}},No=(n,o,f)=>{if(o==="style")if(typeof f==="object")for(let i of Object.keys(f))if(F(f[i]))Q(n,f[i],Uf(i));else po(n,i,f[i]);else n.setAttribute("style",f);else{let i=$(o),c=n.constructor.observedAttributes;if(c?.includes(o)||c?.includes(i))if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f);else if(n[o]!==void 0){let{MathMLElement:r}=globalThis;if(n instanceof SVGElement||r!==void 0&&n instanceof r)n.setAttribute(o,f);else n[o]=f}else if(i==="class")f.split(" ").forEach((r)=>{n.classList.add(r)});else if(n[i]!==void 0)n[i]=f;else if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f)}},qf=(n)=>{return{toDOM(o,f){No(o,n,f)}}},Af=(n,o,f)=>{if(o==="apply")f(n);else if(o.match(/^on[A-Z]/)!=null){let i=o.substring(2).toLowerCase();p(n,i,f)}else if(o==="bind")if((typeof f.binding==="string"?En[f.binding]:f.binding)!==void 0&&f.value!==void 0)Q(n,f.value,f.binding instanceof Function?{toDOM:f.binding}:f.binding);else throw Error("bad binding");else if(o.match(/^bind[A-Z]/)!=null){let i=o.substring(4,5).toLowerCase()+o.substring(5),c=En[i];if(c!==void 0)Q(n,f,c);else throw Error(`${o} is not allowed, bindings.${i} is not defined`)}else if(F(f))Q(n,f,qf(o));else No(n,o,f)},mo=(n,...o)=>{if(dn[n]===void 0){let[c,m]=n.split("|");if(m===void 0)dn[n]=globalThis.document.createElement(c);else dn[n]=globalThis.document.createElementNS(m,c)}let f=dn[n].cloneNode(),i={};for(let c of o)if(c instanceof Element||c instanceof DocumentFragment||typeof c==="string"||typeof c==="number")if(f instanceof HTMLTemplateElement)f.content.append(c);else f.append(c);else if(F(c))f.append(x.span({bindText:c}));else Object.assign(i,c);for(let c of Object.keys(i)){let m=i[c];Af(f,c,m)}return f},Eo=(...n)=>{let o=globalThis.document.createDocumentFragment();for(let f of n)o.append(f);return o},x=new Proxy({fragment:Eo},{get(n,o){if(o=o.replace(/[A-Z]/g,(f)=>`-${f.toLocaleLowerCase()}`),n[o]===void 0)n[o]=(...f)=>mo(o,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Gn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${ho}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Qn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${_o}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}});var jf=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],uf=!0,Kf=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,Rf=(n)=>Kf.test(n),e=(n="",o="")=>{if(n==="")return o;else if(o.match(/^\d+$/)!==null||o.includes("="))return`${n}[${o}]`;else return`${n}.${o}`},lo={};function ro(n,o){if(n!==null&&(typeof n==="object"||typeof n==="function"))return n;return new Proxy(lo,b(o,!0))}var kn=()=>new Proxy({},b("^",!0)),go=!1;function N(){if(!go)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),go=!0}var to=(n)=>{return n===lo},b=(n,o)=>({get(f,i){if(to(f)){let w=()=>j(nn,n);switch(i){case"path":return n;case"value":return w();case"valueOf":case"toJSON":return()=>w();case Symbol.toPrimitive:return(E)=>{let M=w();if(E==="number")return Number(M);if(E==="string")return String(M);return M};case"toString":return()=>String(w());case"observe":return(E)=>{let M=I(n,E);return()=>u(M)};case"on":return(E,M)=>fn()(E,M,w());case"bind":return(E,M,L)=>{on()(E,n,M,L)};case"binding":return(E)=>({bind:{value:n,binding:E}});case"listBinding":return(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))];case U:case"xinValue":case"tosiValue":return N(),w();case J:case"xinPath":case"tosiPath":return N(),n;case Vn:case"tosiObserve":return N(),(E)=>{let M=I(n,E);return()=>u(M)};case bn:case"tosiOn":return N(),(E,M)=>fn()(E,M,w());case en:case"tosiBind":return N(),(E,M,L)=>{on()(E,n,M,L)};case"tosiBinding":return N(),(E)=>({bind:{value:n,binding:E}});case"tosiListBinding":return N(),(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))]}if(typeof i==="string"&&/^\d+$/.test(i)){let E=w();if(typeof E==="string")return E[parseInt(i,10)]}if(i==="length"){let E=w();if(typeof E==="string")return E.length}return}if(o&&!(i in f))switch(i){case"path":return n;case"value":return f.valueOf?f.valueOf():f;case"valueOf":case"toJSON":return()=>f.valueOf?f.valueOf():f;case"observe":return(w)=>{let E=I(n,w);return()=>u(E)};case"on":return(w,E)=>fn()(w,E,H(f));case"bind":return(w,E,M)=>{on()(w,n,E,M)};case"binding":return(w)=>({bind:{value:n,binding:w}});case"listBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}switch(i){case J:case"xinPath":case"tosiPath":return n;case U:case"xinValue":case"tosiValue":return f.valueOf?f.valueOf():f;case Vn:case"xinObserve":case"tosiObserve":return(w)=>{let E=I(n,w);return()=>u(E)};case bn:case"xinOn":case"tosiOn":return(w,E)=>fn()(w,E,H(f));case en:case"xinBind":case"tosiBind":return(w,E,M)=>{on()(w,n,E,M)};case"tosiBinding":return(w)=>({bind:{value:n,binding:w}});case"tosiListBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}if(typeof i==="symbol")return f[i];let c=Object.getOwnPropertyDescriptor(f,i);if(c&&!c.configurable&&!c.writable&&"value"in c)return c.value;let m=i,r=m.match(/^([^.[]+)\.(.+)$/)??m.match(/^([^\]]+)(\[.+)/)??m.match(/^(\[[^\]]+\])\.(.+)$/)??m.match(/^(\[[^\]]+\])\[(.+)$/);if(r!==null){let[,w,E]=r,M=e(n,w),L=j(f,w);return L!==null&&typeof L==="object"?new Proxy(L,b(M,o))[E]:L}if(m.startsWith("[")&&m.endsWith("]"))m=m.substring(1,m.length-1);if(!Array.isArray(f)&&f[m]!==void 0||Array.isArray(f)&&m.includes("=")){let w;if(m.includes("=")){let[E,M]=m.split("=");w=f.find((L)=>`${j(L,E)}`===M)}else w=f[m];if(w instanceof Object){let E=e(n,m);return new Proxy(w instanceof Function?w.bind(f):w,b(E,o))}else return o?ro(w,e(n,m)):w}else if(Array.isArray(f)){let w=f[m];return typeof w==="function"?(...E)=>{let M=E.map((T)=>H(T)),L=w.apply(f,M);if(jf.includes(m))B(n);if(L!=null&&typeof L==="object"){if(m==="find"||m==="findLast"||m==="at"){let T=f.indexOf(L);if(T!==-1)return new Proxy(L,b(e(n,String(T)),o))}}return L}:typeof w==="object"?new Proxy(w,b(e(n,m),o)):o?ro(w,e(n,m)):w}else return o?ro(f[m],e(n,m)):f[m]},set(f,i,c){c=H(c);let m=i===U||i==="xinValue"||i==="tosiValue"||i==="value"&&(to(f)||o),r=m?n:e(n,i);if(uf&&!Rf(r))throw Error(`setting invalid path ${r}`);if(H(X[r])!==c&&Qo(nn,r,c)){B(r);let E=n.match(/^(.+)\[(\d+)\]$/);if(E!==null){let[,M,L]=E,T=parseInt(L,10),D=m?"":`.${i}`,Y=Wo(M,T,f,D);for(let s of Y)B(s)}}return!0}}),l=(n,o)=>{let f=typeof o==="function"?o:X[o];if(typeof f!=="function")throw Error(`observe expects a function or path to a function, ${o} is neither`);return I(n,f)},X=new Proxy(nn,b("",!1));Oo(X);var g=new Proxy(nn,b("",!0));var Sf=16,Bf=100;function vo(n,o){let f=Array.from(n.querySelectorAll(R));if(n.matches(R))f.unshift(n);for(let i of f){let c=O.get(i);for(let m of c){if(m.path.startsWith("^"))m.path=`${o}${m.path.substring(1)}`;if(m.binding.toDOM!=null)m.binding.toDOM(i,X[m.path])}}}class ao{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,o,f={}){if(this.boundElement=n,this.itemToElement=new WeakMap,f.idPath!=null){let i=F(o);if(i!=null)so(i,f.idPath)}if(n.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(n.children[0]instanceof HTMLTemplateElement){let i=n.children[0];if(i.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=_(i.content.children[0])}else this.template=n.children[0],this.template.remove();if(this.options=f,this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom),f.virtual!=null)if(cn.observe(this.boundElement),this._update=mn(()=>{this.update(this.array,!0)},Sf),this.boundElement.addEventListener("resize",this._update),f.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}visibleSlice(){let{virtual:n,hiddenProp:o,visibleProp:f}=this.options,i=this.array;if(o!==void 0)i=i.filter((E)=>E[o]!==!0);if(f!==void 0)i=i.filter((E)=>E[f]===!0);if(this.options.filter&&this.needle!==void 0)i=this.options.filter(i,this.needle);let c=0,m=i.length-1,r=0,w=0;if(n!=null&&this.boundElement instanceof HTMLElement){let E=this.boundElement.offsetWidth,M=n.scrollContainer==="window",L,T;if(M){L=window.innerHeight;let C=this.boundElement.getBoundingClientRect();T=Math.max(0,-C.top)}else L=this.boundElement.offsetHeight,T=this.boundElement.scrollTop;let D=n.width!=null?Math.max(1,Math.floor(E/n.width)):n.visibleColumns??1,Y=Math.ceil(L/n.height)+(n.rowChunkSize||1),s=Math.ceil(i.length/D),v=D*Y,Z=Math.floor(T/n.height);if(Z>s-Y+1)Z=Math.max(0,s-Y+1);if(n.rowChunkSize)Z-=Z%n.rowChunkSize;c=Z*D,m=c+v-1,r=Z*n.height,w=Math.max((s-Y)*n.height-r,0)}return{items:i,firstItem:c,lastItem:m,topBuffer:r,bottomBuffer:w}}needle;filter=mn((n)=>{if(this.needle!==n)this.needle=n,this.update(this.array)},Bf);update(n,o){if(n==null)n=[];this.array=n;let{hiddenProp:f,visibleProp:i}=this.options,c=F(n),m=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",m.items.length===0);let r=this._previousSlice,{firstItem:w,lastItem:E,topBuffer:M,bottomBuffer:L}=m;if(f===void 0&&i===void 0&&o===!0&&r!=null&&w===r.firstItem&&E===r.lastItem&&M===r.topBuffer&&L===r.bottomBuffer)return;this._previousSlice=m;let T=0,D=0,Y=0;for(let C of Array.from(this.boundElement.children)){if(C===this.listTop||C===this.listBottom)continue;let k=C[Hn];if(k==null)C.remove();else{let d=m.items.indexOf(k);if(d<w||d>E)C.remove(),this.itemToElement.delete(k),T++}}this.listTop.style.height=String(M)+"px",this.listBottom.style.height=String(L)+"px";let s=[],{idPath:v}=this.options;for(let C=w;C<=E;C++){let k=m.items[C];if(k===void 0)continue;let d=this.itemToElement.get(H(k));if(d==null){if(Y++,d=_(this.template),typeof k==="object")this.itemToElement.set(H(k),d),d[Hn]=H(k);if(this.boundElement.insertBefore(d,this.listBottom),v!=null){let un=k[v],Mf=`${c}[${v}=${un}]`;vo(d,Mf)}else{let un=`${c}[${C}]`;vo(d,un)}}s.push(d)}let Z=null;for(let C of s){if(C.previousElementSibling!==Z)if(D++,Z?.nextElementSibling!=null)this.boundElement.insertBefore(C,Z.nextElementSibling);else this.boundElement.insertBefore(C,this.listBottom);Z=C}if(S.perf)console.log(c,"updated",{removed:T,created:Y,moved:D})}}var rn=(n,o,f)=>{let i=n[a];if(o&&i===void 0)i=new ao(n,o,f),n[a]=i;return i},Wn=(n)=>{let o;while(!(o=n[Hn])&&n&&n.parentElement)n=n.parentElement;return o?{element:n,item:o}:void 0},zn=(n)=>{let o=Wn(n);return o?o.item:void 0},nf=(n)=>{let o=Wn(n);if(!o)return console.error("deleteListItem failed, element is not part of a list instance",n),!1;let f=rn(o.element.parentElement);if(!f.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",n.parentElement,f),!1;let i=f.array.indexOf(o.item);if(i>-1)return f.array.splice(i,1),!0;return!1};var{document:Mn,MutationObserver:of}=globalThis,On=(n,o)=>{let f=O.get(n);if(f==null)return;for(let i of f){let{binding:c,options:m}=i,{path:r}=i,{toDOM:w}=c;if(w!=null){if(r.startsWith("^")){let E=zn(n);if(E!=null&&E[J]!=null)r=i.path=`${E[J]}${r.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${r}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${r}`)}if(o==null||r.startsWith(o))w(n,Dn()[r],m)}}};if(of!=null)new of((o)=>{o.forEach((f)=>{Array.from(f.addedNodes).forEach((i)=>{if(i instanceof Element)Array.from(i.querySelectorAll(R)).forEach((c)=>On(c))})})}).observe(Mn.body,{subtree:!0,childList:!0});I(()=>!0,(n)=>{let o=Array.from(Mn.querySelectorAll(R));for(let f of o)On(f,n)});var ff=(n)=>{let o=n.target?.closest(R);while(o!=null){let f=O.get(o);for(let i of f){let{binding:c,path:m}=i,{fromDOM:r}=c;if(r!=null){let w;try{w=r(o,i.options)}catch(E){throw console.error("Cannot get value from",o,"via",i),Error("Cannot obtain value fromDOM")}if(w!=null){let E=Dn(),M=E[m];if(M==null)E[m]=w;else{let L=M[J]!=null?M[U]:M,T=w[J]!=null?w[U]:w;if(L!==T)E[m]=T}}}}o=o.parentElement.closest(R)}};if(globalThis.document!=null)Mn.body.addEventListener("change",ff,!0),Mn.body.addEventListener("input",ff,!0);function Q(n,o,f,i){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let c;if(typeof o==="object"&&o[J]===void 0&&i===void 0){let{value:w}=o;c=typeof w==="string"?w:w[J],i=o,delete i.value}else c=typeof o==="string"?o:o[J];if(c==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:m}=f;n.classList?.add(Sn);let r=O.get(n);if(r==null)r=[],O.set(n,r);if(r.push({path:c,binding:f,options:i}),m!=null&&!c.startsWith("^"))B(c);if(i?.filter&&i?.needle)Q(n,i.needle,{toDOM(w,E){console.log({needle:E}),w[a]?.filter(E)}});return n}var cf=new Set,If=(n)=>{let o=n?.target?.closest(In),f=!1,i=new Proxy(n,{get(m,r){if(r==="stopPropagation")return()=>{n.stopPropagation(),f=!0};else{let w=m[r];return typeof w==="function"?w.bind(m):w}}}),c=new Set;while(!f&&o!=null){let r=P.get(o)[n.type]||c;for(let w of r){if(typeof w==="function")w(i);else{let E=Dn()[w];if(typeof E==="function")E(i);else throw Error(`no event handler found at path ${w}`)}if(f)continue}o=o.parentElement!=null?o.parentElement.closest(In):null}};function p(n,o,f){let i=P.get(n);if(n.classList.add(Bn),i==null)i={},P.set(n,i);if(!i[o])i[o]=new Set;if(i[o].add(f),!cf.has(o))cf.add(o),Mn.body.addEventListener(o,If,!0);return()=>{i[o].delete(f)}}Uo(Q,p);function Un(n,o){if(!n.internals)return;let f={},i="";if(n.hasAttribute("required")&&o==="")f.valueMissing=!0,i="Please fill out this field.";let c=n.getAttribute("minlength");if(c&&o.length<parseInt(c,10))f.tooShort=!0,i=`Please use at least ${c} characters.`;let m=n.getAttribute("maxlength");if(m&&o.length>parseInt(m,10))f.tooLong=!0,i=`Please use no more than ${m} characters.`;let r=n.getAttribute("pattern");if(r&&o!=="")try{if(!new RegExp(`^(?:${r})$`).test(o))f.patternMismatch=!0,i="Please match the requested format."}catch{}if(Object.keys(f).length>0)n.internals.setValidity(f,i,n);else n.internals.setValidity({})}var Vf=0;function wo(){return`custom-elt${(Vf++).toString(36)}`}var mf=0,Mo=null;function ef(){if(Mo===null)Mo=new MutationObserver((n)=>{let o=new Set;for(let f of n)if(f.type==="attributes"&&f.target instanceof W){let i=f.target,c=fo(f.attributeName);if(i._legacyTrackedAttrs?.has(c))o.add(i)}for(let f of o)f.queueRender(!1)});return Mo}var yn={};function bf(n,o){let f=yn[n],i=V(o).replace(/:host\b/g,n);yn[n]=f?f+`
13
- `+i:i}function Pf(n){if(yn[n])document.head.append(x.style({id:n+"-component"},yn[n]));delete yn[n]}class W extends HTMLElement{static elements=x;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,o,f){this.internals?.setValidity(n,o,f)}setFormValue(n,o){this.internals?.setFormValue(n,o)}static get observedAttributes(){let n=this.initAttributes;if(n)return["hidden",...Object.keys(n).map($)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=x.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"),x.style(V(n))}static elementCreator(n={}){let o=this;if(o._elementCreator==null){let{tag:f,styleSpec:i}=n,c=n!=null?f:null;if(c==null)if(typeof o.name==="string"&&o.name!==""){if(c=$(o.name),c.startsWith("-"))c=c.slice(1)}else c=wo();if(customElements.get(c)!=null)console.warn(`${c} is already defined`);if(c.match(/\w+(-\w+)+/)==null)console.warn(`${c} is not a legal tag for a custom-element`),c=wo();while(customElements.get(c)!==void 0)c=wo();if(o._tagName=c,i!==void 0)bf(c,i);window.customElements.define(c,this,n),o._elementCreator=x[c]}return o._elementCreator}initAttributes(...n){if(q("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let c of n)this._legacyTrackedAttrs.add(c);ef().observe(this,{attributes:!0});let f={},i={};n.forEach((c)=>{f[c]=z(this[c]);let m=$(c);Object.defineProperty(this,c,{enumerable:!1,get(){if(typeof f[c]==="boolean")return this.hasAttribute(m);else if(this.hasAttribute(m))return typeof f[c]==="number"?parseFloat(this.getAttribute(m)):this.getAttribute(m);else if(i[c]!==void 0)return i[c];else return f[c]},set(r){if(typeof f[c]==="boolean"){if(r!==this[c]){if(r)this.setAttribute(m,"");else this.removeAttribute(m);this.queueRender()}}else if(typeof f[c]==="number"){if(r!==parseFloat(this[c]))this.setAttribute(m,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[c]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(m);else this.setAttribute(m,r);this.queueRender(),i[c]=r}}})})}initValue(){let n=Object.getOwnPropertyDescriptor(this,"value");if(n===void 0||n.get!==void 0||n.set!==void 0)return;let o=this.hasAttribute("value")?this.getAttribute("value"):z(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return o},set(f){if(o!==f)o=f,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(o,f){if(o[f]===void 0){let i=n.querySelector(`[part="${f}"]`);if(i==null)i=n.querySelector(f);if(i==null)throw Error(`elementRef "${f}" does not exist!`);i.removeAttribute("data-ref"),o[f]=i}return o[f]}});return this._parts}attributeChangedCallback(n,o,f){let i=fo(n);if(!this._legacyTrackedAttrs?.has(i))this.queueRender(!1)}constructor(){super();if(mf+=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()}-${mf}`,this._value=z(this.defaultValue)}_setupAttributeAccessors(n){if(!this._attrValues)this._attrValues=new Map;for(let o of Object.keys(n)){let f=$(o),i=n[o];if(o==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof i==="object"&&i!==null){console.warn(`${this.tagName}: initAttributes.${o} is an object. Use a regular property instead.`);continue}let c=this,m=!1;while(c){let r=Object.getOwnPropertyDescriptor(c,o);if(r){if(!r.configurable||r.get||r.set){m=!0;break}break}c=Object.getPrototypeOf(c)}if(m)continue;Object.defineProperty(this,o,{enumerable:!1,get:()=>{if(typeof i==="boolean")return this.hasAttribute(f);else if(this.hasAttribute(f))return typeof i==="number"?parseFloat(this.getAttribute(f)):this.getAttribute(f);else if(this._attrValues.has(o))return this._attrValues.get(o);else return i},set:(r)=>{if(typeof i==="boolean"){if(r!==this[o]){if(r)this.setAttribute(f,"");else this.removeAttribute(f);this.queueRender()}}else if(typeof i==="number"){if(r!==parseFloat(this[o]))this.setAttribute(f,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[o]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(f);else this.setAttribute(f,r);this.queueRender(),this._attrValues.set(o,r)}}})}}connectedCallback(){if(Pf(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(cn.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(){cn.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(no(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",o=typeof this.content==="function"?this.content(x):this.content,{styleSpec:f}=this.constructor,{styleNode:i}=this.constructor;if(f)i=this.constructor.styleNode=x.style(V(f)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),i=this.styleNode;if(i){let c=this.attachShadow({mode:"open"});c.appendChild(i.cloneNode(!0)),oo(c,o,n)}else if(o!==null){let c=Array.from(this.childNodes);oo(this,o,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let m=Array.from(this.querySelectorAll("slot"));if(m.length>0)m.forEach(yo.replaceSlot);if(c.length>0){let r={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((w)=>{r[w.name]=w}),c.forEach((w)=>{let E=r[""],M=w instanceof Element?r[w.slot]:E;(M!==void 0?M:E).append(w)})}}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);Un(this,n)}}class yo extends W{static initAttributes={name:""};content=null;static replaceSlot(n){let o=document.createElement("xin-slot");if(n.name!=="")o.setAttribute("name",n.name);n.replaceWith(o)}}var Lc=yo.elementCreator({tag:"xin-slot"});var Ef=(n=()=>!0)=>{let o=localStorage.getItem("xin-state");if(o!=null){let i=JSON.parse(o);for(let c of Object.keys(i).filter(n))if(X[c]!==void 0)Object.assign(X[c],i[c]);else X[c]=i[c]}let f=Yn(()=>{let i={},c=H(X);for(let m of Object.keys(c).filter(n))i[m]=c[m];localStorage.setItem("xin-state",JSON.stringify(i)),console.log("xin state saved to localStorage")},500);l(n,f)};var qn="1.3.3";function Ln(n){return Object.assign(g,n),g}function xn(n){return q("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),Ln(n)}function An(n,o=!1){if(o)return q("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),xn(n);return Object.keys(n).forEach((f)=>{X[f]=n[f]}),X}var _f={};async function Tn(n,o){let{type:f,styleSpec:i}=await o(n,{Color:y,Component:W,elements:x,svgElements:Gn,mathML:Qn,varDefault:wn,vars:Zn,xin:X,boxed:g,xinProxy:An,boxedProxy:xn,tosi:Ln,makeComponent:Tn,bind:Q,on:p,version:qn}),c={type:f,creator:f.elementCreator({tag:n,styleSpec:i})};return _f[n]=c,c}var Lo={},hf=(n)=>import(n);class sn extends W{static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(n)=>{};async packaged(){let{tag:n,src:o,property:f}=this,i=`${n}.${f}:${o}`;if(!this.loaded){if(Lo[i]===void 0)Lo[i]=hf(o).then((c)=>{let m=c[f];return Tn(n,m)});else console.log(`using cached ${n} with signature ${i}`);this.loaded=await Lo[i],this.blueprintLoaded(this.loaded)}return this.loaded}}var rf=sn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class jn extends W{allLoaded=()=>{};constructor(){super()}async load(){let o=Array.from(this.querySelectorAll(sn.tagName)).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(o),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var wf=jn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
12
+ `)},eo=(n)=>{q("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let o={};for(let f of Object.keys(n)){let i=n[f],c=$(f);o[`--${c}`]=typeof i==="number"&&i!==0?String(i)+"px":i}return o},bo=(n)=>{let o={};for(let f of Object.keys(n)){let i=n[f];if(i instanceof y)o[f]=i.inverseLuminance;else if(typeof i==="string"&&i.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))o[f]=y.fromCss(i).inverseLuminance}return o},wn=new Proxy({},{get(n,o){if(n[o]===void 0){let f="--"+$(o);n[o]=(i)=>`var(${f}, ${i})`}return n[o]}}),Zn=new Proxy({},{get(n,o){if(o==="default")return wn;if(n[o]==null){o=$(o);let[,f,,i,c,m]=o.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",o],r=`--${f}`;if(c!=null){let w=i==null?Number(c)/100:-Number(c)/100;switch(m){case"b":case"s":case"h":case"o":{let E=`--${o}`;y.registerComputedColor(E,r,w,m),n[o]=`var(${E})`}break;case"":n[o]=`calc(var(${r}) * ${w})`;break;default:throw console.error(m),Error(`Unrecognized method ${m} for css variable ${r}`)}}else n[o]=`var(${r})`}return n[o]}});function co(){let n=(o)=>typeof matchMedia<"u"&&matchMedia(o).matches;return{colorScheme:n("(prefers-color-scheme: dark)")?"dark":"light",contrast:n("(prefers-contrast: more)")?"more":n("(prefers-contrast: less)")?"less":n("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:n("(prefers-reduced-motion: reduce)"),reducedTransparency:n("(prefers-reduced-transparency: reduce)"),forcedColors:n("(forced-colors: active)")}}function Po(n){if(typeof matchMedia>"u")return()=>{};let o=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],f=()=>n(co()),i=o.map((c)=>matchMedia(c));for(let c of i)c.addEventListener("change",f);return()=>{for(let c of i)c.removeEventListener("change",f)}}var _o="http://www.w3.org/1998/Math/MathML",ho="http://www.w3.org/2000/svg";var dn={},po=(n,o,f)=>{let i=io($(o),f);if(i.prop.startsWith("--"))n.style.setProperty(i.prop,i.value);else n.style[o]=i.value},Uf=(n)=>{return{toDOM(o,f){po(o,n,f)}}},No=(n,o,f)=>{if(o==="style")if(typeof f==="object")for(let i of Object.keys(f))if(F(f[i]))Q(n,f[i],Uf(i));else po(n,i,f[i]);else n.setAttribute("style",f);else{let i=$(o),c=n.constructor.observedAttributes;if(c?.includes(o)||c?.includes(i))if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f);else if(n[o]!==void 0){let{MathMLElement:r}=globalThis;if(n instanceof SVGElement||r!==void 0&&n instanceof r)n.setAttribute(o,f);else n[o]=f}else if(i==="class")f.split(" ").forEach((r)=>{n.classList.add(r)});else if(n[i]!==void 0)n[i]=f;else if(typeof f==="boolean")f?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,f)}},qf=(n)=>{return{toDOM(o,f){No(o,n,f)}}},Af=(n,o,f)=>{if(o==="apply")f(n);else if(o.match(/^on[A-Z]/)!=null){let i=o.substring(2).toLowerCase();p(n,i,f)}else if(o==="bind")if((typeof f.binding==="string"?En[f.binding]:f.binding)!==void 0&&f.value!==void 0)Q(n,f.value,f.binding instanceof Function?{toDOM:f.binding}:f.binding);else throw Error("bad binding");else if(o.match(/^bind[A-Z]/)!=null){let i=o.substring(4,5).toLowerCase()+o.substring(5),c=En[i];if(c!==void 0)Q(n,f,c);else throw Error(`${o} is not allowed, bindings.${i} is not defined`)}else if(F(f))Q(n,f,qf(o));else No(n,o,f)},mo=(n,...o)=>{if(dn[n]===void 0){let[c,m]=n.split("|");if(m===void 0)dn[n]=globalThis.document.createElement(c);else dn[n]=globalThis.document.createElementNS(m,c)}let f=dn[n].cloneNode(),i={};for(let c of o)if(c instanceof Element||c instanceof DocumentFragment||typeof c==="string"||typeof c==="number")if(f instanceof HTMLTemplateElement)f.content.append(c);else f.append(c);else if(F(c))f.append(x.span({bindText:c}));else Object.assign(i,c);for(let c of Object.keys(i)){let m=i[c];Af(f,c,m)}return f},Eo=(...n)=>{let o=globalThis.document.createDocumentFragment();for(let f of n)o.append(f);return o},x=new Proxy({fragment:Eo},{get(n,o){if(o=o.replace(/[A-Z]/g,(f)=>`-${f.toLocaleLowerCase()}`),n[o]===void 0)n[o]=(...f)=>mo(o,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Gn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${ho}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}}),Qn=new Proxy({fragment:Eo},{get(n,o){if(n[o]===void 0)n[o]=(...f)=>mo(`${o}|${_o}`,...f);return n[o]},set(){throw Error("You may not add new properties to elements")}});var jf=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],uf=!0,Kf=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,Rf=(n)=>Kf.test(n),e=(n="",o="")=>{if(n==="")return o;else if(o.match(/^\d+$/)!==null||o.includes("="))return`${n}[${o}]`;else return`${n}.${o}`},lo={};function ro(n,o){if(n!==null&&(typeof n==="object"||typeof n==="function"))return n;return new Proxy(lo,b(o,!0))}var kn=()=>new Proxy({},b("^",!0)),go=!1;function N(){if(!go)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),go=!0}var to=(n)=>{return n===lo},b=(n,o)=>({get(f,i){if(to(f)){let w=()=>j(nn,n);switch(i){case"path":return n;case"value":return w();case"valueOf":case"toJSON":return()=>w();case Symbol.toPrimitive:return(E)=>{let M=w();if(E==="number")return Number(M);if(E==="string")return String(M);return M};case"toString":return()=>String(w());case"observe":return(E)=>{let M=I(n,E);return()=>u(M)};case"on":return(E,M)=>fn()(E,M,w());case"bind":return(E,M,L)=>{on()(E,n,M,L)};case"binding":return(E)=>({bind:{value:n,binding:E}});case"listBinding":return(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))];case U:case"xinValue":case"tosiValue":return N(),w();case J:case"xinPath":case"tosiPath":return N(),n;case Vn:case"tosiObserve":return N(),(E)=>{let M=I(n,E);return()=>u(M)};case bn:case"tosiOn":return N(),(E,M)=>fn()(E,M,w());case en:case"tosiBind":return N(),(E,M,L)=>{on()(E,n,M,L)};case"tosiBinding":return N(),(E)=>({bind:{value:n,binding:E}});case"tosiListBinding":return N(),(E=({span:L})=>L({bindText:"^"}),M={})=>[{bindList:{value:n,...M}},x.template(E(x,kn()))]}if(typeof i==="string"&&/^\d+$/.test(i)){let E=w();if(typeof E==="string")return E[parseInt(i,10)]}if(i==="length"){let E=w();if(typeof E==="string")return E.length}return}if(o&&!(i in f))switch(i){case"path":return n;case"value":return f.valueOf?f.valueOf():f;case"valueOf":case"toJSON":return()=>f.valueOf?f.valueOf():f;case"observe":return(w)=>{let E=I(n,w);return()=>u(E)};case"on":return(w,E)=>fn()(w,E,H(f));case"bind":return(w,E,M)=>{on()(w,n,E,M)};case"binding":return(w)=>({bind:{value:n,binding:w}});case"listBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}switch(i){case J:case"xinPath":case"tosiPath":return n;case U:case"xinValue":case"tosiValue":return f.valueOf?f.valueOf():f;case Vn:case"xinObserve":case"tosiObserve":return(w)=>{let E=I(n,w);return()=>u(E)};case bn:case"xinOn":case"tosiOn":return(w,E)=>fn()(w,E,H(f));case en:case"xinBind":case"tosiBind":return(w,E,M)=>{on()(w,n,E,M)};case"tosiBinding":return(w)=>({bind:{value:n,binding:w}});case"tosiListBinding":return(w=({span:M})=>M({bindText:"^"}),E={})=>[{bindList:{value:n,...E}},x.template(w(x,kn()))]}if(typeof i==="symbol")return f[i];let c=Object.getOwnPropertyDescriptor(f,i);if(c&&!c.configurable&&!c.writable&&"value"in c)return c.value;let m=i,r=m.match(/^([^.[]+)\.(.+)$/)??m.match(/^([^\]]+)(\[.+)/)??m.match(/^(\[[^\]]+\])\.(.+)$/)??m.match(/^(\[[^\]]+\])\[(.+)$/);if(r!==null){let[,w,E]=r,M=e(n,w),L=j(f,w);return L!==null&&typeof L==="object"?new Proxy(L,b(M,o))[E]:L}if(m.startsWith("[")&&m.endsWith("]"))m=m.substring(1,m.length-1);if(!Array.isArray(f)&&f[m]!==void 0||Array.isArray(f)&&m.includes("=")){let w;if(m.includes("=")){let[E,M]=m.split("=");w=f.find((L)=>`${j(L,E)}`===M)}else w=f[m];if(w instanceof Object){let E=e(n,m);return new Proxy(w instanceof Function?w.bind(f):w,b(E,o))}else return o?ro(w,e(n,m)):w}else if(Array.isArray(f)){let w=f[m];return typeof w==="function"?(...E)=>{let M=E.map((T)=>H(T)),L=w.apply(f,M);if(jf.includes(m))B(n);if(L!=null&&typeof L==="object"){if(m==="find"||m==="findLast"||m==="at"){let T=f.indexOf(L);if(T!==-1)return new Proxy(L,b(e(n,String(T)),o))}}return L}:typeof w==="object"?new Proxy(w,b(e(n,m),o)):o?ro(w,e(n,m)):w}else return o?ro(f[m],e(n,m)):f[m]},set(f,i,c){c=H(c);let m=i===U||i==="xinValue"||i==="tosiValue"||i==="value"&&(to(f)||o),r=m?n:e(n,i);if(uf&&!Rf(r))throw Error(`setting invalid path ${r}`);if(H(X[r])!==c&&Qo(nn,r,c)){B(r);let E=n.match(/^(.+)\[(\d+)\]$/);if(E!==null){let[,M,L]=E,T=parseInt(L,10),D=m?"":`.${i}`,Y=Wo(M,T,f,D);for(let s of Y)B(s)}}return!0}}),l=(n,o)=>{let f=typeof o==="function"?o:X[o];if(typeof f!=="function")throw Error(`observe expects a function or path to a function, ${o} is neither`);return I(n,f)},X=new Proxy(nn,b("",!1));Oo(X);var g=new Proxy(nn,b("",!0));var Sf=16,Bf=100;function vo(n,o){let f=Array.from(n.querySelectorAll(R));if(n.matches(R))f.unshift(n);for(let i of f){let c=O.get(i);for(let m of c){if(m.path.startsWith("^"))m.path=`${o}${m.path.substring(1)}`;if(m.binding.toDOM!=null)m.binding.toDOM(i,X[m.path])}}}class ao{boundElement;listTop;listBottom;template;options;itemToElement;array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,o,f={}){if(this.boundElement=n,this.itemToElement=new WeakMap,f.idPath!=null){let i=F(o);if(i!=null)so(i,f.idPath)}if(n.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(n.children[0]instanceof HTMLTemplateElement){let i=n.children[0];if(i.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=_(i.content.children[0])}else this.template=n.children[0],this.template.remove();if(this.options=f,this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom),f.virtual!=null)if(cn.observe(this.boundElement),this._update=mn(()=>{this.update(this.array,!0)},Sf),this.boundElement.addEventListener("resize",this._update),f.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}visibleSlice(){let{virtual:n,hiddenProp:o,visibleProp:f}=this.options,i=this.array;if(o!==void 0)i=i.filter((E)=>E[o]!==!0);if(f!==void 0)i=i.filter((E)=>E[f]===!0);if(this.options.filter&&this.needle!==void 0)i=this.options.filter(i,this.needle);let c=0,m=i.length-1,r=0,w=0;if(n!=null&&this.boundElement instanceof HTMLElement){let E=this.boundElement.offsetWidth,M=n.scrollContainer==="window",L,T;if(M){L=window.innerHeight;let C=this.boundElement.getBoundingClientRect();T=Math.max(0,-C.top)}else L=this.boundElement.offsetHeight,T=this.boundElement.scrollTop;let D=n.width!=null?Math.max(1,Math.floor(E/n.width)):n.visibleColumns??1,Y=Math.ceil(L/n.height)+(n.rowChunkSize||1),s=Math.ceil(i.length/D),v=D*Y,Z=Math.floor(T/n.height);if(Z>s-Y+1)Z=Math.max(0,s-Y+1);if(n.rowChunkSize)Z-=Z%n.rowChunkSize;c=Z*D,m=c+v-1,r=Z*n.height,w=Math.max((s-Y)*n.height-r,0)}return{items:i,firstItem:c,lastItem:m,topBuffer:r,bottomBuffer:w}}needle;filter=mn((n)=>{if(this.needle!==n)this.needle=n,this.update(this.array)},Bf);update(n,o){if(n==null)n=[];this.array=n;let{hiddenProp:f,visibleProp:i}=this.options,c=F(n),m=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",m.items.length===0);let r=this._previousSlice,{firstItem:w,lastItem:E,topBuffer:M,bottomBuffer:L}=m;if(f===void 0&&i===void 0&&o===!0&&r!=null&&w===r.firstItem&&E===r.lastItem&&M===r.topBuffer&&L===r.bottomBuffer)return;this._previousSlice=m;let T=0,D=0,Y=0;for(let C of Array.from(this.boundElement.children)){if(C===this.listTop||C===this.listBottom)continue;let k=C[Hn];if(k==null)C.remove();else{let d=m.items.indexOf(k);if(d<w||d>E)C.remove(),this.itemToElement.delete(k),T++}}this.listTop.style.height=String(M)+"px",this.listBottom.style.height=String(L)+"px";let s=[],{idPath:v}=this.options;for(let C=w;C<=E;C++){let k=m.items[C];if(k===void 0)continue;let d=this.itemToElement.get(H(k));if(d==null){if(Y++,d=_(this.template),typeof k==="object")this.itemToElement.set(H(k),d),d[Hn]=H(k);if(this.boundElement.insertBefore(d,this.listBottom),v!=null){let un=k[v],Mf=`${c}[${v}=${un}]`;vo(d,Mf)}else{let un=`${c}[${C}]`;vo(d,un)}}s.push(d)}let Z=null;for(let C of s){if(C.previousElementSibling!==Z)if(D++,Z?.nextElementSibling!=null)this.boundElement.insertBefore(C,Z.nextElementSibling);else this.boundElement.insertBefore(C,this.listBottom);Z=C}if(S.perf)console.log(c,"updated",{removed:T,created:Y,moved:D})}}var rn=(n,o,f)=>{let i=n[a];if(o&&i===void 0)i=new ao(n,o,f),n[a]=i;return i},Wn=(n)=>{let o;while(!(o=n[Hn])&&n&&n.parentElement)n=n.parentElement;return o?{element:n,item:o}:void 0},zn=(n)=>{let o=Wn(n);return o?o.item:void 0},nf=(n)=>{let o=Wn(n);if(!o)return console.error("deleteListItem failed, element is not part of a list instance",n),!1;let f=rn(o.element.parentElement);if(!f.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",n.parentElement,f),!1;let i=f.array.indexOf(o.item);if(i>-1)return f.array.splice(i,1),!0;return!1};var{document:Mn,MutationObserver:of}=globalThis,On=(n,o)=>{let f=O.get(n);if(f==null)return;for(let i of f){let{binding:c,options:m}=i,{path:r}=i,{toDOM:w}=c;if(w!=null){if(r.startsWith("^")){let E=zn(n);if(E!=null&&E[J]!=null)r=i.path=`${E[J]}${r.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${r}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${r}`)}if(o==null||r.startsWith(o))w(n,Dn()[r],m)}}};if(of!=null)new of((o)=>{o.forEach((f)=>{Array.from(f.addedNodes).forEach((i)=>{if(i instanceof Element)Array.from(i.querySelectorAll(R)).forEach((c)=>On(c))})})}).observe(Mn.body,{subtree:!0,childList:!0});I(()=>!0,(n)=>{let o=Array.from(Mn.querySelectorAll(R));for(let f of o)On(f,n)});var ff=(n)=>{let o=n.target?.closest(R);while(o!=null){let f=O.get(o);for(let i of f){let{binding:c,path:m}=i,{fromDOM:r}=c;if(r!=null){let w;try{w=r(o,i.options)}catch(E){throw console.error("Cannot get value from",o,"via",i),Error("Cannot obtain value fromDOM")}if(w!=null){let E=Dn(),M=E[m];if(M==null)E[m]=w;else{let L=M[J]!=null?M[U]:M,T=w[J]!=null?w[U]:w;if(L!==T)E[m]=T}}}}o=o.parentElement.closest(R)}};if(globalThis.document!=null)Mn.body.addEventListener("change",ff,!0),Mn.body.addEventListener("input",ff,!0);function Q(n,o,f,i){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let c;if(typeof o==="object"&&o[J]===void 0&&i===void 0){let{value:w}=o;c=typeof w==="string"?w:w[J],i=o,delete i.value}else c=typeof o==="string"?o:o[J];if(c==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:m}=f;n.classList?.add(Sn);let r=O.get(n);if(r==null)r=[],O.set(n,r);if(r.push({path:c,binding:f,options:i}),m!=null&&!c.startsWith("^"))B(c);if(i?.filter&&i?.needle)Q(n,i.needle,{toDOM(w,E){console.log({needle:E}),w[a]?.filter(E)}});return n}var cf=new Set,If=(n)=>{let o=n?.target?.closest(In),f=!1,i=new Proxy(n,{get(m,r){if(r==="stopPropagation")return()=>{n.stopPropagation(),f=!0};else{let w=m[r];return typeof w==="function"?w.bind(m):w}}}),c=new Set;while(!f&&o!=null){let r=P.get(o)[n.type]||c;for(let w of r){if(typeof w==="function")w(i);else{let E=Dn()[w];if(typeof E==="function")E(i);else throw Error(`no event handler found at path ${w}`)}if(f)continue}o=o.parentElement!=null?o.parentElement.closest(In):null}};function p(n,o,f){let i=P.get(n);if(n.classList.add(Bn),i==null)i={},P.set(n,i);if(!i[o])i[o]=new Set;if(i[o].add(f),!cf.has(o))cf.add(o),Mn.body.addEventListener(o,If,!0);return()=>{i[o].delete(f)}}Uo(Q,p);function Un(n,o){if(!n.internals)return;let f={},i="";if(n.hasAttribute("required")&&o==="")f.valueMissing=!0,i="Please fill out this field.";let c=n.getAttribute("minlength");if(c&&o.length<parseInt(c,10))f.tooShort=!0,i=`Please use at least ${c} characters.`;let m=n.getAttribute("maxlength");if(m&&o.length>parseInt(m,10))f.tooLong=!0,i=`Please use no more than ${m} characters.`;let r=n.getAttribute("pattern");if(r&&o!=="")try{if(!new RegExp(`^(?:${r})$`).test(o))f.patternMismatch=!0,i="Please match the requested format."}catch{}if(Object.keys(f).length>0)n.internals.setValidity(f,i,n);else n.internals.setValidity({})}var Vf=0;function wo(){return`custom-elt${(Vf++).toString(36)}`}var mf=0,Mo=null;function ef(){if(Mo===null)Mo=new MutationObserver((n)=>{let o=new Set;for(let f of n)if(f.type==="attributes"&&f.target instanceof W){let i=f.target,c=fo(f.attributeName);if(i._legacyTrackedAttrs?.has(c))o.add(i)}for(let f of o)f.queueRender(!1)});return Mo}var yn={};function bf(n,o){let f=yn[n],i=V(o).replace(/:host\(([^)]+)\)/g,`${n}$1`).replace(/:host\b/g,n);yn[n]=f?f+`
13
+ `+i:i}function Pf(n){if(yn[n])document.head.append(x.style({id:n+"-component"},yn[n]));delete yn[n]}class W extends HTMLElement{static elements=x;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,o,f){this.internals?.setValidity(n,o,f)}setFormValue(n,o){this.internals?.setFormValue(n,o)}static get observedAttributes(){let n=this.initAttributes;if(n)return["hidden",...Object.keys(n).map($)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=x.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"),x.style(V(n))}static elementCreator(n={}){let o=this;if(o._elementCreator==null){let{tag:f,styleSpec:i}=n,c=n!=null?f:null;if(c==null)if(typeof o.name==="string"&&o.name!==""){if(c=$(o.name),c.startsWith("-"))c=c.slice(1)}else c=wo();if(customElements.get(c)!=null)console.warn(`${c} is already defined`);if(c.match(/\w+(-\w+)+/)==null)console.warn(`${c} is not a legal tag for a custom-element`),c=wo();while(customElements.get(c)!==void 0)c=wo();if(o._tagName=c,i!==void 0)bf(c,i);window.customElements.define(c,this,n),o._elementCreator=x[c]}return o._elementCreator}initAttributes(...n){if(q("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let c of n)this._legacyTrackedAttrs.add(c);ef().observe(this,{attributes:!0});let f={},i={};n.forEach((c)=>{f[c]=z(this[c]);let m=$(c);Object.defineProperty(this,c,{enumerable:!1,get(){if(typeof f[c]==="boolean")return this.hasAttribute(m);else if(this.hasAttribute(m))return typeof f[c]==="number"?parseFloat(this.getAttribute(m)):this.getAttribute(m);else if(i[c]!==void 0)return i[c];else return f[c]},set(r){if(typeof f[c]==="boolean"){if(r!==this[c]){if(r)this.setAttribute(m,"");else this.removeAttribute(m);this.queueRender()}}else if(typeof f[c]==="number"){if(r!==parseFloat(this[c]))this.setAttribute(m,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[c]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(m);else this.setAttribute(m,r);this.queueRender(),i[c]=r}}})})}initValue(){let n=Object.getOwnPropertyDescriptor(this,"value");if(n===void 0||n.get!==void 0||n.set!==void 0)return;let o=this.hasAttribute("value")?this.getAttribute("value"):z(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return o},set(f){if(o!==f)o=f,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(o,f){if(o[f]===void 0){let i=n.querySelector(`[part="${f}"]`);if(i==null)i=n.querySelector(f);if(i==null)throw Error(`elementRef "${f}" does not exist!`);i.removeAttribute("data-ref"),o[f]=i}return o[f]}});return this._parts}attributeChangedCallback(n,o,f){let i=fo(n);if(!this._legacyTrackedAttrs?.has(i))this.queueRender(!1)}constructor(){super();if(mf+=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()}-${mf}`,this._value=z(this.defaultValue)}_setupAttributeAccessors(n){if(!this._attrValues)this._attrValues=new Map;for(let o of Object.keys(n)){let f=$(o),i=n[o];if(o==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof i==="object"&&i!==null){console.warn(`${this.tagName}: initAttributes.${o} is an object. Use a regular property instead.`);continue}let c=this,m=!1;while(c){let r=Object.getOwnPropertyDescriptor(c,o);if(r){if(!r.configurable||r.get||r.set){m=!0;break}break}c=Object.getPrototypeOf(c)}if(m)continue;Object.defineProperty(this,o,{enumerable:!1,get:()=>{if(typeof i==="boolean")return this.hasAttribute(f);else if(this.hasAttribute(f))return typeof i==="number"?parseFloat(this.getAttribute(f)):this.getAttribute(f);else if(this._attrValues.has(o))return this._attrValues.get(o);else return i},set:(r)=>{if(typeof i==="boolean"){if(r!==this[o]){if(r)this.setAttribute(f,"");else this.removeAttribute(f);this.queueRender()}}else if(typeof i==="number"){if(r!==parseFloat(this[o]))this.setAttribute(f,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[o]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(f);else this.setAttribute(f,r);this.queueRender(),this._attrValues.set(o,r)}}})}}connectedCallback(){if(Pf(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(cn.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(){cn.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(no(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",o=typeof this.content==="function"?this.content(x):this.content,{styleSpec:f}=this.constructor,{styleNode:i}=this.constructor;if(f)i=this.constructor.styleNode=x.style(V(f)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),i=this.styleNode;if(i){let c=this.attachShadow({mode:"open"});c.appendChild(i.cloneNode(!0)),oo(c,o,n)}else if(o!==null){let c=Array.from(this.childNodes);oo(this,o,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let m=Array.from(this.querySelectorAll("slot"));if(m.length>0)m.forEach(yo.replaceSlot);if(c.length>0){let r={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((w)=>{r[w.name]=w}),c.forEach((w)=>{let E=r[""],M=w instanceof Element?r[w.slot]:E;(M!==void 0?M:E).append(w)})}}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);Un(this,n)}}class yo extends W{static initAttributes={name:""};content=null;static replaceSlot(n){let o=document.createElement("xin-slot");if(n.name!=="")o.setAttribute("name",n.name);n.replaceWith(o)}}var Lc=yo.elementCreator({tag:"xin-slot"});var Ef=(n=()=>!0)=>{let o=localStorage.getItem("xin-state");if(o!=null){let i=JSON.parse(o);for(let c of Object.keys(i).filter(n))if(X[c]!==void 0)Object.assign(X[c],i[c]);else X[c]=i[c]}let f=Yn(()=>{let i={},c=H(X);for(let m of Object.keys(c).filter(n))i[m]=c[m];localStorage.setItem("xin-state",JSON.stringify(i)),console.log("xin state saved to localStorage")},500);l(n,f)};var qn="1.3.4";function Ln(n){return Object.assign(g,n),g}function xn(n){return q("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),Ln(n)}function An(n,o=!1){if(o)return q("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),xn(n);return Object.keys(n).forEach((f)=>{X[f]=n[f]}),X}var _f={};async function Tn(n,o){let{type:f,styleSpec:i}=await o(n,{Color:y,Component:W,elements:x,svgElements:Gn,mathML:Qn,varDefault:wn,vars:Zn,xin:X,boxed:g,xinProxy:An,boxedProxy:xn,tosi:Ln,makeComponent:Tn,bind:Q,on:p,version:qn}),c={type:f,creator:f.elementCreator({tag:n,styleSpec:i})};return _f[n]=c,c}var Lo={},hf=(n)=>import(n);class sn extends W{static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(n)=>{};async packaged(){let{tag:n,src:o,property:f}=this,i=`${n}.${f}:${o}`;if(!this.loaded){if(Lo[i]===void 0)Lo[i]=hf(o).then((c)=>{let m=c[f];return Tn(n,m)});else console.log(`using cached ${n} with signature ${i}`);this.loaded=await Lo[i],this.blueprintLoaded(this.loaded)}return this.loaded}}var rf=sn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class jn extends W{allLoaded=()=>{};constructor(){super()}async load(){let o=Array.from(this.querySelectorAll(sn.tagName)).filter((f)=>f.src).map((f)=>f.packaged());await Promise.all(o),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var wf=jn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});})();
14
14
 
15
- //# debugId=935DCBB07055FCA864756E2164756E21
15
+ //# debugId=C5869E634A51F25B64756E2164756E21
16
16
  //# sourceMappingURL=index.js.map