@neeloong/form 0.17.0 → 0.19.0

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/index.min.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @neeloong/form v0.17.0
2
+ * @neeloong/form v0.19.0
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
6
- import{Signal as e}from"signal-polyfill";export{Signal}from"signal-polyfill";function t(t,n,r,s){const i=new e.State("boolean"==typeof n?n:null),o="function"==typeof r?new e.Computed((()=>Boolean(r(t)))):new e.State(Boolean(r)),a=()=>{const e=i.get();return null===e?o.get():e},l=s?new e.Computed((()=>s.get()||a())):new e.Computed(a);return[i,l]}const n=e=>"string"==typeof e&&e||null,r=e=>"number"==typeof e&&e||null,s=e=>e instanceof RegExp?e:null,i=Boolean;function o(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(o).filter(i):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const a=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(o).filter(i);return t.length?t:null};function l(t,n,r,s){const i=new e.State(n(r));let o;if("function"==typeof s){const r=s;o=new e.Computed((()=>n(r(t))))}else{const t=n(s);o=new e.Computed((()=>t))}const a=new e.Computed((()=>{const e=i.get();return null===e?o.get():e}));return[i,a]}const c=Symbol();function u(e){const t={[c]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,c,{get:()=>e,configurable:!1,enumerable:!0}),t}let f=null,d=null,h=Object.create(null);function p(e,t){const n=e.type;let r=b;if(!e.array||d&&t?.parent instanceof d)if("string"==typeof n){const e=h[n];e&&(r=e)}else n&&"object"==typeof n&&f&&(r=f);else d&&(r=d);return new r(e,t)}function m(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function g(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Computed((()=>[])),()=>{}];const s=new e.State([]);let i=null;return[function(){i?.abort(),i=new AbortController;const e=i.signal;return s.set([]),Promise.all(r.map((n=>async function(e,n){let r=[];try{r.push(await e(t,n))}catch(e){r.push(e)}const i=r.flat().map(m).filter(Boolean);return!n.aborted&&i.length&&s.set([...s.get(),...i]),i}(n,e)))).then((e=>e.flat()))},new e.Computed((()=>s.get())),()=>{i?.abort(),s.set([])}]}class b{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}static create(e,t={}){return p({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){h[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||u(this)}constructor(i,{null:o,state:c,ref:f,default:d,setValue:h,setState:p,convert:y,onUpdate:v,onUpdateState:w,validator:x,validators:E,index:A,size:$,new:L,parent:O,hidden:S,clearable:C,required:j,disabled:M,readonly:k,removable:N,label:T,description:U,placeholder:B,min:P,max:_,step:I,minLength:q,maxLength:R,pattern:D,values:V}={}){this.schema=i,this.#r.set("object"==typeof c&&c||{});const F=O instanceof b?O:null;var K,G;F&&(this.#s=F,this.#i=F.#i,this.#o=F.#o),this.#a=(K=this,"function"!=typeof(G=d??i.default)?()=>structuredClone(G):()=>structuredClone(G(K)));const H=new e.State(!1);this.#l=H,this.#o=H,this.#c=i.type,this.#u=i.meta,this.#f=i.component;const z=new e.State(Boolean(L));this.#d=z;const Y=F?new e.Computed((()=>F.#h.get()||z.get())):new e.Computed((()=>z.get()));this.#h=Y;const Q=Boolean(i.immutable),W=!1!==i.creatable;this.#p=Q,this.#m=W;const Z=i.readonly,X=new e.State("boolean"==typeof k?k:null);let J;if("function"==typeof Z)J=new e.Computed((()=>Boolean(Z(this))));else{const t=Boolean(Z);J=new e.Computed((()=>t))}const ee=()=>{if(Y.get()?!W:Q)return!0;const e=X.get();return null===e?J.get():e},te=F?F.#g:null;this.#b=X,this.#g=te?new e.Computed((()=>te.get()||ee())):new e.Computed(ee),[this.#y,this.#v]=t(this,S,i.hidden,F?F.#v:null),[this.#w,this.#x]=t(this,C,i.clearable,F?F.#x:null),[this.#E,this.#A]=t(this,j,i.required,F?F.#A:null),[this.#$,this.#L]=t(this,M,i.disabled,F?F.#L:null),[this.#O,this.#S]=l(this,n,T,i.label),[this.#C,this.#j]=l(this,n,U,i.description),[this.#M,this.#k]=l(this,n,B,i.placeholder),[this.#N,this.#T]=l(this,r,P,i.min),[this.#U,this.#B]=l(this,r,_,i.max),[this.#P,this.#_]=l(this,r,I,i.step),[this.#I,this.#q]=l(this,r,q,i.minLength),[this.#R,this.#D]=l(this,r,R,i.maxLength),[this.#V,this.#F]=l(this,s,D,i.pattern),[this.#K,this.#G]=l(this,a,V,i.values),[this.#H,this.#z]=t(this,N,i.removable??!0);const ne=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(m).filter(Boolean)})):new e.Computed((()=>[]))}(this,i.validator,x),[re,se,ie]=g(this,i.validators?.change,E?.change),[oe,ae,le]=g(this,i.validators?.blur,E?.blur);if(this.listen("change",(()=>{re()})),this.listen("blur",(()=>{oe()})),this.#Y=function(...t){const n=t.filter(Boolean);return new e.Computed((()=>n.flatMap((e=>e.get()))))}(ne,se,ae),this.#Q=ne,this.#W=re,this.#Z=oe,this.#X=ie,this.#J=le,$ instanceof e.State||$ instanceof e.Computed?this.#ee=$:this.#ee=new e.State($||0),o)return this.#t=!0,void(this.#n=u(this));this.#n=f||null,this.#te=v||null,this.#ne=w||null,this.#re="function"==typeof h?h:null,this.#se="function"==typeof p?p:null,this.#ie="function"==typeof y?y:null,this.#oe.set(A??"");for(const[e,t]of Object.entries(i.events||{}))"function"==typeof t&&this.listen(e,t)}#a;createDefault(){return this.#a()}#re=null;#se=null;#ie=null;#te=null;#ne=null;#s=null;#i=this;#c;#u;#f;#l=null;#o;get loading(){return this.#o.get()}set loading(e){const t=this.#l;t&&t.set(Boolean(e))}get store(){return this}get parent(){return this.#s}get root(){return this.#i}get type(){return this.#c}get meta(){return this.#u}get component(){return this.#f}#ee;get size(){return this.#ee.get()}#oe=new e.State("");get index(){return this.#oe.get()}set index(e){this.#oe.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#m=!0;get creatable(){return this.#m}#p=!1;get immutable(){return this.#p}#h;#d;get selfNew(){return this.#d.get()}set selfNew(e){this.#d.set(Boolean(e))}get new(){return this.#h.get()}set new(e){this.#d.set(Boolean(e))}#y;#v;get selfHidden(){return this.#y.get()}set selfHidden(e){this.#y.set("boolean"==typeof e?e:null)}get hidden(){return this.#v.get()}set hidden(e){this.#y.set("boolean"==typeof e?e:null)}#w;#x;get selfClearable(){return this.#w.get()}set selfClearable(e){this.#w.set("boolean"==typeof e?e:null)}get clearable(){return this.#x.get()}set clearable(e){this.#w.set("boolean"==typeof e?e:null)}#E;#A;get selfRequired(){return this.#E.get()}set selfRequired(e){this.#E.set("boolean"==typeof e?e:null)}get required(){return this.#A.get()}set required(e){this.#E.set("boolean"==typeof e?e:null)}#$;#L;get selfDisabled(){return this.#$.get()}set selfDisabled(e){this.#$.set("boolean"==typeof e?e:null)}get disabled(){return this.#L.get()}set disabled(e){this.#$.set("boolean"==typeof e?e:null)}#b;#g;get selfReadonly(){return this.#b.get()}set selfReadonly(e){this.#b.set("boolean"==typeof e?e:null)}get readonly(){return this.#g.get()}set readonly(e){this.#b.set("boolean"==typeof e?e:null)}#H;#z;get selfRemovable(){return this.#H.get()}set selfRemovable(e){this.#H.set("boolean"==typeof e?e:null)}get removable(){return this.#z.get()}set removable(e){this.#H.set("boolean"==typeof e?e:null)}#O;#S;get selfLabel(){return this.#O.get()}set selfLabel(e){this.#O.set(n(e))}get label(){return this.#S.get()}set label(e){this.#O.set(n(e))}#C;#j;get selfDescription(){return this.#C.get()}set selfDescription(e){this.#C.set(n(e))}get description(){return this.#j.get()}set description(e){this.#C.set(n(e))}#M;#k;get selfPlaceholder(){return this.#M.get()}set selfPlaceholder(e){this.#M.set(n(e))}get placeholder(){return this.#k.get()}set placeholder(e){this.#M.set(n(e))}#N;#T;get selfMin(){return this.#N.get()}set selfMin(e){this.#N.set(r(e))}get min(){return this.#T.get()}set min(e){this.#N.set(r(e))}#U;#B;get selfMax(){return this.#U.get()}set selfMax(e){this.#U.set(r(e))}get max(){return this.#B.get()}set max(e){this.#U.set(r(e))}#P;#_;get selfStep(){return this.#P.get()}set selfStep(e){this.#P.set(r(e))}get step(){return this.#_.get()}set step(e){this.#P.set(r(e))}#I;#q;get selfMinLength(){return this.#I.get()}set selfMinLength(e){this.#I.set(r(e))}get minLength(){return this.#q.get()}set minLength(e){this.#I.set(r(e))}#R;#D;get selfMaxLength(){return this.#R.get()}set selfMaxLength(e){this.#R.set(r(e))}get maxLength(){return this.#D.get()}set maxLength(e){this.#R.set(r(e))}#V;#F;get selfPattern(){return this.#V.get()}set selfPattern(e){this.#V.set(s(e))}get pattern(){return this.#F.get()}set pattern(e){this.#V.set(s(e))}#K;#G;get selfValues(){return this.#K.get()}set selfValues(e){this.#K.set(a(e))}get values(){return this.#G.get()}set values(e){this.#K.set(a(e))}#Y;#Q;#W;#Z;#X;#J;get errors(){return this.#Y.get()}get error(){return this.#Y.get()[0]}*[Symbol.iterator](){}child(e){return null}#ae=!1;#le=new e.State(null);#ce=new e.State(this.#le.get());#r=new e.State(null);get changed(){return this.#ce.get()===this.#le.get()}get value(){return this.#ce.get()}set value(e){const t=this.#re?.(e),n=void 0===t?e:t;this.#ce.set(n),this.#ae||this.#le.set(n),this.#te?.(n,this.#oe.get(),this),this.#ue()}get state(){return this.#r.get()}set state(e){const t=this.#se?.(e),n=void 0===t?e:t;this.#r.set(n),this.#ne?.(n,this.#oe.get(),this),this.#ue()}#ue(){this.#fe||(this.#fe=!0,queueMicrotask((()=>{const e=this.#ce.get(),t=this.#r.get();this.#de(e,t)})))}reset(e=this.#le.get()){this.#he(e)}#he(e){const t=this.#re?.(e),n=void 0===t?e:t;if(this.#X(),this.#J(),this.#ae=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#he(null);return this.#ce.set(n),this.#le.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#he(r[e]);return this.#ce.set(r),this.#le.set(r),this.#te?.(r,this.#oe.get(),this),r}#fe=!1;#pe(e,t){const[n,r]=this.#ie?.(e,t)||[e,t];return this.#ce.get()===n&&this.#r.get()===r?[n,r]:(this.#ce.set(n),this.#r.set(r),this.#de(n,r))}#de(e,t){this.#fe=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},i=!1;for(const[n,o]of this){const a=e[n],l=t?.[n],[c,u]=o.#pe(a,l);a!==c&&(r[n]=c,i=!0),l!==u&&(s[n]=u,i=!0)}i&&(t=s,n=e=r,this.#ce.set(e),this.#r.set(s))}return this.#ae||(this.#ae=!0,this.#le.set(n)),[e,t]}validate(e){if(!0===e)return Promise.all([this.#Q.get(),this.#W(),this.#Z()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=Array.isArray(e)?e:[],n=[this.validate().then((e=>e?.length?[{path:[...t],store:this,errors:e}]:[]))];for(const[e,r]of this)n.push(r.validate([...t,e]));return Promise.all(n).then((e=>e.flat()))}}class y extends b{get kind(){return"object"}#me;*[Symbol.iterator](){yield*Object.entries(this.#me)}child(e){return this.#me[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i}={}){const o=Object.entries(e.type),a=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i,size:o.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}],default:e.default??(()=>Object.fromEntries(Object.entries(a).map((([e,t])=>[e,t.createDefault()]))))});const l={parent:this,onUpdate:(e,t,n)=>{n===this.#me[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#me[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of o)a[e]=p(t,{...l,index:e});this.#me=a}}f=y;class v extends b{#ge=()=>{throw new Error};#me;get children(){return[...this.#me.get()]}*[Symbol.iterator](){return yield*[...this.#me.get().entries()]}child(e){const t=this.#me.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(n,{parent:r,onUpdate:s,onUpdateState:i,index:o,new:a,addable:l}={}){const c=new e.State([]),u=e=>{const t=Array.isArray(e)&&e.length||0,n=[...c.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#ge(e));n.length=t,r!==t&&c.set(n)};super(n,{index:o,new:a,parent:r,size:new e.Computed((()=>c.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return u(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{u(e),s?.(e,t,n)},onUpdateState:i,default:n.default??[]}),[this.#be,this.#ye]=t(this,l,n.addable??!0),this.#me=c;const f={parent:this,onUpdate:(e,t,n)=>{if(c.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(c.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#ge=(e,t)=>{const r=p(n,{...f,index:e,new:t});return r.index=e,r}}#be;#ye;get selfAddable(){return this.#be.get()}set selfAddable(e){this.#be.set("boolean"==typeof e?e:null)}get addable(){return this.#ye.get()}set addable(e){this.#be.set("boolean"==typeof e?e:null)}insert(e,t=null,n){if(!this.addable)return!1;const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#me.get()],i=Math.max(0,Math.min(Math.floor(e),s.length)),o=this.#ge(i,n);o.new=!0,s.splice(i,0,o);for(let t=e+1;t<s.length;t++)s[t].index=t;const a=[...r];a.splice(i,0,t??o.createDefault());const l=this.state;if(Array.isArray(l)){const e=[...l];e.splice(i,0,{}),this.state=e}return this.#me.set(s),this.value=a,!0}add(e=null){return this.insert(this.#me.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#me.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const i=[...t],[o]=i.splice(r,1),a=this.state;if(Array.isArray(a)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#me.set(n),this.value=i,o}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let i=Math.min(e,t),o=Math.max(e,t);for(let e=i;e<=o;e++)r[e].index=e;const a=[...n],[l]=a.splice(e,1);a.splice(t,0,l);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#me.set(r),this.value=a,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],s=r[e],i=r[t];if(!s||!i)return!1;r[t]=s,r[e]=i,s.index=t,i.index=e;const o=[...n],a=o[e],l=o[t];o[t]=a,o[e]=l;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#me.set(r),this.value=o,!0}}function w(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),s=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;s=!0;const n=x(t);r[e]={params:t.params,children:n?[n]:[]}}function i(e){e.length&&t.push({type:"divergent",children:e.map((([e,t])=>{const n=x(t);return n?"string"!=typeof n&&"fragment"===n.type?[n,e]:[{children:[n]},e]:[{children:[]},e]}))})}for(const r of e){if("string"==typeof r){i(n),n=[],t.push(r);continue}if(r.template){i(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(i(n),n=[]);continue}i(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const s=x(r);s&&t.push(s)}return i(n),s?[{type:"fragment",templates:r,children:t}]:t}function x(e){let t=function(e){const t=e.fragment;if(t&&"string"==typeof t)return{type:"template",template:t,attrs:e.attrs,children:[]};const n=function({text:e,html:t}){return null!=e?{type:"content",value:e}:null!=t?{type:"content",value:t,html:!0}:void 0}(e),r=n?[n]:w(e.children);return!e.name||t?n||{type:"fragment",children:r}:{name:e.name,is:e.is,attrs:e.attrs,events:e.events,classes:e.classes,styles:e.styles,enhancements:e.enhancements,bind:e.bind,comment:e.comment,children:r}}(e),n=e.vars;n.length&&t&&"string"!=typeof t&&(t.vars?t.vars=[...n,...t.vars]:t?t.vars=n:t={type:"fragment",vars:n,children:[]},n=null);const r=e.enum,s=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),s&&(t={type:"value",name:s,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){d=e}(v);const E=/^([+-]?(\d(_?\d)*(\.(\d(_?\d)*)?)?|\.\d(_?\d)*)(?:e[+-]?\d(_?\d)*)|0(b[01](?:_?[01])*|o[0-7](?:_?[0-7])*|x[\dA-F](?:_?[\dA-F])*))$/is;const A={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class $ extends Error{constructor(e,...t){const n=A[e];super("function"==typeof n?n(...t):n),this.code=e}}const L=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,O=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,S=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function C(e,t){const n=e[t];if(n)return n;const r={attrs:Object.create(null),events:Object.create(null)};return e[t]=r,r}function j(e,t){const n=e.replace(/$\s+|\s+$/gs,"");if("null"===n)return{value:null};if("true"===n)return{value:!0};if("false"===n)return{value:!1};const r=function(e){return E.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?S.test(n)?{name:n}:{calc:t(e)}:{value:r}}function M(e,t,n,r,s){const{attrs:i,events:o,classes:a,styles:l,vars:c,params:u,enhancements:f}=e;return function(d,h){const p=d.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=(L.exec(p)||O.exec(p))?.groups;if(!m)throw new $("ATTR",d);const{name:g,enhancement:b}=m,y=m.decorator?.toLowerCase();if(b){if(":"===y)C(f,b).attrs[g]=h?j(h,t):{name:g};else if("@"===y)C(f,b).events[g]=h?S.test(h)?{name:h}:{event:r(h)}:{name:g};else if("!"===y){if("bind"===g)C(f,b).bind=h||!0}else C(f,b).value=j(h,t);return}if(!y)return void(i[g]={value:h});if(":"===y)return void(i[g]=h?j(h,t):{name:g});if("."===y)return void(a[g]=h?j(h,t):{name:g});if("style:"===y)return void(l[g]=j(h,t));if("@"===y)return void(o[g]=h?S.test(h)?{name:h}:{event:r(h)}:{name:g});if("+"===y)return void c.push({...h?j(h,n):{value:void 0},variable:g,init:!0});if("*"===y)return void c.push({...j(h,t),variable:g,init:!1});if("?"===y)return void(u[g]=j(h,t));if("!"!==y)return;switch(g.toString()){case"fragment":e.fragment=h||!0;break;case"else":e.else=!0;break;case"enum":e.enum=h?j(h,t):{value:!0};break;case"sort":e.sort=h?j(h,t):{value:!0};break;case"if":e.if=j(h,t);break;case"text":e.text=j(h,t);break;case"html":s&&(e.html=j(h,t));break;case"template":e.template=h;break;case"bind":e.bind=h||!0;break;case"value":e.value=h;break;case"comment":e.comment=h}}}function k(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:[],params:Object.create(null),enhancements:Object.create(null)}}var N={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const T=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function U(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function B(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function P(...e){console.error(new $(...e))}function _(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in N?N[t]:(P("ENTITY",e),e)}var I=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new $("CALC")},createInit:n=t,createEvent:r=()=>{throw new $("EVENT")},simpleTag:s=new Set,enableHTML:i=!1}={}){const o=[],a={children:o},l=[];let c=null,u=a;function f(){c=l.pop()||null,u=c||a}function d(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&u.children.push(e)}let h={},p=0;function m(t){if(t<=p)return;d(e.substring(p,t).replace(/&#?\w+;/g,_)),p=t}for(;;){const g=e.indexOf("<",p);if(g<0){const j=e.substring(p);j.match(/^\s*$/)||d(j);break}g>p&&m(g);const b=e.charAt(g+1);if("!"===b){let N=g+2,I=">";if("--"===e.slice(g+2,g+4)&&(N+=4,I="--\x3e"),p=e.indexOf(I,N),p<0)break;p++;continue}if("/"===b){p=e.indexOf(">",g+3);let q=e.substring(g+2,p);if(p<0?(q=e.substring(g+2).replace(/[\s<].*/,""),P("UNCOMPLETED",q,c?.name),p=g+1+q.length):q.match(/\s</)&&(q=q.replace(/[\s<].*/,""),P("UNCOMPLETED",q),p=g+1+q.length),c){const R=c.name;if(R===q)f();else{if(R.toLowerCase()!=q.toLowerCase())throw new $("CLOSE",q,c.name);f()}}p++;continue}function y(t){let n=p+1;if(p=e.indexOf(t,n),p<0)throw new $("QUOTE",t);const r=e.slice(n,p).replace(/&#?\w+;/g,_);return p++,r}function v(){let t=e.charAt(p);for(;t<=" "||"€"===t;t=e.charAt(++p));return t}function x(){let t=p,n=e.charAt(p);for(;U(n);)p++,n=e.charAt(p);return e.slice(t,p)}p=g+1;let E=e.charAt(p);switch(E){case"=":throw new $("EQUAL");case'"':case"'":throw new $("ATTR_VALUE");case">":case"/":throw new $("SYMBOL",E);case"":throw new $("EOF")}const A=x(),L=T.exec(A)?.groups;if(!L)throw new $("TAG",A);l.push(c),c=k(L.name,L.is),u.children.push(c),u=c;const O=M(c,t,n,r,i);let S=!0,C=!1;e:for(;S;){let D=v();switch(D){case"":P("EOF"),p++;break e;case">":p++;break e;case"/":C=!0;break e;case'"':case"'":throw new $("ATTR_VALUE");case"=":throw new $("SYMBOL",D)}const V=x();if(!V){P("EOF"),p++;break e}switch(D=v(),D){case"":P("EOF"),p++;break e;case">":O(V,""),p++;break e;case"/":O(V,""),C=!0;break e;case"=":p++;break;case"'":case'"':O(V,y(D));continue;default:O(V,"");continue}switch(D=v(),D){case"":O(V,""),P("EOF"),p++;break e;case">":O(V,""),p++;break e;case"/":O(V,""),C=!0;break e;case"'":case'"':O(V,y(D));continue}O(V,x())}if(C){for(;;){p++;const F=e.charAt(p);if("/"!==F&&!(F<=" "||"€"===F))break}switch(e.charAt(p)){case"=":throw new $("EQUAL");case'"':case"'":throw new $("ATTR_VALUE");case"":P("EOF");break;case">":p++;break;default:throw new $("CLOSE_SYMBOL")}f()}else(s.has(A)||B(e,p,A,h))&&f()}return w(o)}});function q(t){let n=!0;const r=new e.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),s=new e.Computed(t);return r.watch(s),s.get(),()=>{r.unwatch(s)}}function R(e,t,n){let r,s=!1;return q((()=>{const i=e();if(!s)return s=!0,r=i,void(n&&t(i));Object.is(i,r)||(r=i,t(i))}))}const D=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,loading:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,size:!0,error:!0,errors:!0}));function*V(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of D)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof v?(yield[`${t}${n}addable`,{get:()=>e.addable}],yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}]):yield[`${t}${n}addable`,{get:()=>!1}]}function F(e,t,n){for(const[n,r]of t){for(const[t,s]of V(r,n))e[t]=s;for(const[t,s]of V(r,n,"$$"))e[t]=s}}const K={value$:{calc:e=>e?.[c].value},state$:{calc:e=>e?.[c].state}};var G=Object.getOwnPropertyDescriptors(K);function H(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function z(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class Y{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ve[e];if("function"!=typeof t?.get)return;return t.get()}return"function"==typeof t?t(this.getters):n}get({name:t,calc:n,value:r}){if("string"==typeof t){const e=this.#ve[t];if("function"!=typeof e?.get)return;const{get:n,set:r}=e;return{get:n,set:r}}if("function"==typeof n){const t=new e.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return R((()=>this.exec(e)),t,!0)}enum(e){const{name:t,calc:n}=e;if("function"==typeof n)return()=>n(this.getters);if("string"==typeof t){const e=this.#ve[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof b?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ve[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ve[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?D.has(t)?R((()=>s[t]),n,!0):void 0:"value"===t?R((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>R(e,t,!0)}}return Object.fromEntries([...D].map((e=>[`$${e}`,t=>R((()=>n[e]),t,!0)])))}getBindAll(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return{};const{store:n}=t;if(!n){const{get:e,set:n}=t;return{$value:{get:e,set:n}}}return Object.fromEntries([...D].map((e=>[`$${e}`,"value"===e||"state"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])))}bindSet(e,t){const n=this.#ve[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent({name:e,event:t}){if("function"==typeof t)return t;const n=this.#ve[e];if(!n)return null;const{exec:r,calc:s}=n;return"function"==typeof r?r:"function"==typeof s?s:null}constructor(e,t){if(this.store=e,t instanceof Y){this.#we=t.#we;const e=this.#xe;for(const[n,r]of Object.entries(t.#xe))e[n]=r;const n=this.#Ee;for(const[e,r]of Object.entries(t.#Ee))n[e]=r}else F(this.#xe,e),this.#we=function(e){const t=Object.create(null,G);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!H(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof b){for(const[e,s]of V(r,n))t[e]=s;continue}const{get:e,set:s,exec:i,calc:o}=r;"function"!=typeof e?"function"==typeof o||o&&"object"==typeof o?t[n]={calc:o}:("function"==typeof i||o&&"object"==typeof o)&&(t[n]={exec:i}):t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#we;#xe=Object.create(null);#Ee=Object.create(null);store;#Ae=null;#s=null;#$e=null;get#ve(){const e=this.#$e;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#xe,...this.#we,...this.#Ee})),n=this.store,r=this.#s,s=this.#Ae;for(const[e,r]of V(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof v))return yield[`${n}${r}removable`,{get:()=>!1}],yield[`${n}${r}upMovable`,{get:()=>!1}],yield[`${n}${r}downMovable`,{get:()=>!1}],yield[`${n}${r}remove`,{exec:()=>{}}],yield[`${n}${r}upMove`,{exec:()=>{}}],void(yield[`${n}${r}downMove`,{exec:()=>{}}]);yield[`${n}${r}removable`,{get:()=>!e.readonly&&!e.disabled&&!!t.removable}],yield[`${n}${r}upMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n>=e.size-1)}}],yield[`${n}${r}remove`,{exec:()=>{e.readonly||e.disabled||t.removable&&e.remove(Number(t.index))}}],yield[`${n}${r}upMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n>=e.size-1||e.move(n,n+1))}}]}(r,n))t[e]=s;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};return this.#$e=t,t}setStore(e,t,n){const r=new Y(e,this);return t&&(r.#s=t),F(r.#xe,e),n&&(r.#Ae=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Y(t,this);return F(n.#xe,t),n}params(t,n,r,s){let i=this.store;if(!0===s)i=r.store;else if(s){const e=r.#ve[s],t=e?.get&&e.store;t&&(i=t)}if(0===Object.keys(t).length)return this;const o=new Y(i,this);o.#s=this.#s,o.#Ae=this.#Ae;const a=o.#Ee,l=o.#ve;for(const[s,i]of Object.entries(t)){const t=s in n?n[s]:null;if(t){const{name:n,calc:i,value:o}=t;if(n){const e=r.#ve[n];if(!e?.get)continue;if(!e.store){a[s]=l[s]=e;continue}for(const[t,n]of V(e.store,s))a[t]=l[t]=n;continue}if("function"==typeof i){const t=new e.Computed((()=>i(r.getters)));a[s]=l[s]={get:()=>t.get()};continue}a[s]=l[s]={get:()=>o}}else{const{name:t,calc:n,value:r}=i;if("function"==typeof n){const t=o.getters;o.#Le=null;const r=new e.Computed((()=>n(t)));a[s]=l[s]={get:()=>r.get()};continue}if(t){const e=l[t];if(!e?.get)continue;if(!e.store){a[s]=l[s]=e;continue}for(const[t,n]of V(e.store,s))a[t]=l[t]=n;continue}a[s]=l[s]={get:()=>r}}}return o}setObject(e){const t=new Y(this.store,this);return t.#Ae=e,t}set(t){if(!t?.length)return this;const n=new Y(this.store,this);n.#s=this.#s,n.#Ae=this.#Ae;const r=n.#Ee,s=n.#ve;for(const{variable:i,name:o,calc:a,value:l,init:c}of t)if(c){const t=new e.State(l);if("function"==typeof a){const e=n.settable;n.#Oe=null,t.set(a(e))}else if(o){const e=s[o];if(!e?.get)continue;t.set(e.get())}r[i]=s[i]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof a)if(o){const e=s[o];if(!e)continue;if(!e.get||!e.store){r[i]=s[i]=e;continue}for(const[t,n]of V(e.store,i))r[t]=s[t]=n}else r[i]=s[i]={get:()=>l};else{const t=n.getters;n.#Le=null;const o=new e.Computed((()=>a(t)));r[i]=s[i]={get:()=>o.get()}}return n}#Se=null;get all(){const e=this.#Se;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return z(this.store,t),this.#Se=t,t}#Oe=null;get settable(){const e=this.#Oe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return z(this.store,t),this.#Oe=t,t}#Le=null;get getters(){const e=this.#Le;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return z(this.store,t),this.#Le=t,t}}const Q={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function W(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Q?`${s}${Q[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Z{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}}const X={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function J(e,t,n){const r=[];if(t)for(let s=e.shift();s;s=e.shift()){const e=s.indexOf(":"),i=e>=0?s.slice(0,e):s,o=e>=0?s.slice(e+1).split(":"):[],a=i.replace(/^-+/,""),l=(i.length-a.length)%2==1;let c=t[a]||a;if(n)switch(c){case"once":case"passive":case"capture":n[c]=!l;continue}"string"==typeof c&&(c=X[c]),"function"==typeof c&&r.push([c,o,l])}return r}function ee(e,t,n){return r=>{const s=e.all;for(const[e,t,i]of n)if(e(r,t,s)===i)return;t(r,s)}}function te(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function ne(e){return null===(e??null)?"":String(e)}function re(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return ne;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const se={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=ne(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=ne(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=ne(e)}},events:{$value:["change",(e,t)=>t.value]}}};function ie(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:s,props:i}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const o=se[t.toLowerCase()],a=o?.attrs||{},l=o?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=l[e];if(n){const[e,i]=n;r.addEventListener(e,(e=>t(i(e,r))),s)}}if(i)for(const[t,n]of Object.entries(e.attrs))if(s(t,(e=>{if(i.has(t))r[t]=e;else{const n=te(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),i.has(t))r[t]=n;else{const e=te(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.attrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=te(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=a[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=re(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let i=te(n);null!==i&&r.setAttribute(t,i),s(t,(e=>{const n=te(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function oe(e){return null===(e??null)?"":String(e)}function ae(e,t,n,r,s){if(!s){const s=e.insertBefore(document.createTextNode(""),t),i=n.watch(r,(e=>s.textContent=oe(e)));return()=>{s.remove(),i()}}const i=e.insertBefore(document.createComment(""),t),o=e.insertBefore(document.createComment(""),t),a=document.createElement("div");function l(){for(let e=i.nextSibling;e&&e!==o;e=i.nextSibling)e.remove()}const c=n.watch(r,(t=>{l(),function(t){a.innerHTML=t;for(let t=a.firstChild;t;t=i.firstChild)e.insertBefore(t,o)}(oe(t))}));return()=>{c(),l(),i.remove(),o.remove()}}function le(e,t){if("bigint"==typeof e&&"bigint"==typeof t)return Number(e-t);if(!("number"!=typeof e&&"bigint"!=typeof e||"number"!=typeof t&&"bigint"!=typeof t))return Number(e)-Number(t);const n=String(e),r=String(t);return n>r?1:n<r?-1:0}const ce=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ue(e,t,n,r,s){const i=e.children;if(!i.length)return()=>{};const o=t.insertBefore(document.createComment(""),n);let a=null,l=()=>{};const c=R((()=>i.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===a)return;a=e,l(),l=()=>{};const t=e?.[0];t&&(l=s(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),l(),l=()=>{},o.remove())}}function fe(t,n,r,s,i,o,a,l,c){const u=t.bind,f=[...o,t.name],d=c?.(f);if(c&&!d)return()=>{};const{context:h,handler:p}=function(t,n,r,s){const i="string"==typeof t?t:t.tag,{attrs:o,events:a}="string"!=typeof t&&t||{attrs:null,events:null};let l=!1;const c=new e.State(!1);let u=!1;const f=new e.State(!1),d=Object.create(null),h=Object.create(null),p=new Set,m=[],g=new Z;return{context:{events:m,props:o?new Set(Object.entries(o).filter((([,e])=>e.isProp)).map((([e])=>e))):null,attrs:h,watch(e,t){if(l)return()=>{};const n=d[e];if(!n)return()=>{};let r=n.get();const s=R((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return p.add(s),()=>{p.delete(s),s()}},relate(e){if(!r||!s||l)return()=>{};try{const t=s(r,e);return"function"!=typeof t?()=>{}:(p.add(t),()=>{p.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return f.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:i,set(t,n){if(o&&!(t in o))return;let r=d[t];if(r)return void r.set(n);const s=new e.State(n);d[t]=s,Object.defineProperty(h,t,{configurable:!0,enumerable:!0,get:s.get.bind(s)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...s]=e.split(".").filter(Boolean),i=a?a[r].filters:{};if(!i)return;const o={},l=J(s,i,o);m.push([r,ee(n,t,l),o])},destroy(){if(!l){l=!0,c.set(!0);for(const e of p)e();g.emit("destroy")}},mount(){u||(u=!0,f.set(!0),g.emit("init",{events:m}))}}}}(d||t.name,s,s.getStore(u),l),m=d?.attrs,g=m?function(e,t,n,r,s){let i=new Set;for(const[o,a]of Object.entries(r)){if("class"===o||"style"===o)continue;if(o in n){const r=n[o],{name:s,calc:l,value:c}=n[o];if(!s&&!l){e.set(o,c);continue}a.immutable&&e.set(o,t.exec(r)),i.add(t.watch(r,(t=>e.set(o,t))));continue}const r=a.bind;if(!s||!r){e.set(o,a.default);continue}if("string"==typeof r){const n=t.bind(s,r,(t=>e.set(o,t)));n?i.add(n):e.set(o,a.default);continue}if(!Array.isArray(r)){e.set(o,a.default);continue}const[l,c,u]=r;if(!l||"function"!=typeof c)continue;if(!u){const n=!0===s?"":s;i.add(t.watch({name:n},(t=>e.set(o,t)))),e.addEvent(l,((...e)=>{t.all[n]=c(...e)}));continue}const f=t.bind(s,"state",(t=>e.set(o,t)));if(!f)continue;i.add(f);const d=t.bindSet(s,"state");d&&e.addEvent(l,((...e)=>{d(c(...e))}))}return()=>{const e=i;i=new Set;for(const t of e)t()}}(p,s,t.attrs,m,u):function(e,t,n){const r=e.tag;let s=new Set;for(const[i,o]of Object.entries(n)){if("class"===i||"style"===i)continue;const{name:n,calc:a,value:l}=o;if(n||a)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==i.toLocaleLowerCase())s.add(t.watch(o,(t=>e.set(i,t))));else{const n=t.exec(o);e.set(i,n)}else e.set(i,l)}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,s,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=s.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,i]of Object.entries(t.bindAll(n)||{}))"function"==typeof i&&r.add(i((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,s,u),y=d?"function"==typeof d.tag?d.tag(h):ie(h,d.tag,d.is):ie(h,t.name,t.is),v=Array.isArray(y)?y[0]:y,w=Array.isArray(y)?y[1]:v;n.insertBefore(v,r);const x=w?pe(t.children||[],w,null,s,i,o,a,l,c):()=>{},E=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let s=new Set;for(const[r,i]of Object.entries(n))i.value?e.classList.add(r):s.add(R((()=>Boolean(t.exec(i))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!s)return;const e=s;s=null;for(const t of e)t()}}(v,s,t.classes,t.attrs.class),A=function(e,t,n,r){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};if(r){const n=[e.getAttribute("style")||"",t.exec(r)||""].filter(Boolean).join(";");n&&e.setAttribute("style",n)}let s=new Set;for(const[r,i]of Object.entries(n))s.add(R((()=>W(r,t.exec(i))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!s)return;const e=s;s=null;for(const t of e)t()}}(v,s,t.styles,t.attrs.style);p.mount();const $=function(t,n,r,s,i,o){let a=new Set;for(const[l,{attrs:c,value:u,events:f,bind:d}]of Object.entries(n)){if(!ce(s,l))continue;const h=s[l];if("function"!=typeof h)continue;let p=!1;const m=new e.State(!1),g=h?.events,b=[],y=Object.create(null),v=new Set,w=new Z;function x(e,t){if("function"!=typeof t)return;const[n,...s]=e.split(".").filter(Boolean),i=g?g[n].filters:{};if(!i)return;const o={},a=J(s,i,o);b.push([n,ee(r,t,a),o])}function E(){if(!p){p=!0,m.set(!0);for(const e of v)e();w.emit("destroy")}}a.add(E);for(const[$,L]of Object.entries(c)){const O=r.get(L);O&&Object.defineProperty(y,$,{...O,configurable:!0,enumerable:!0})}for(const[S,C]of Object.entries(f)){const j=r.getEvent(C);j&&x(S,j)}if(d){for(const[M,k]of Object.entries(r.getBindAll(d)||{}))Object.defineProperty(y,M,{...k,configurable:!0,enumerable:!0});for(const[N,T]of Object.entries(r.bindEvents(d)||{}))x(N,(e=>T(e)))}const A={get value(){return null},events:b,attrs:y,watch(e,t){if(p)return()=>{};let n=y[e];const r=R((()=>y[e]),(r=>{const s=n;n=r,t(r,s,e)}),!0);return v.add(r),()=>{v.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:i,slot:o,tag:t};if(u){const U=r.get(u);U&&Object.defineProperty(A,"value",{...U,configurable:!0,enumerable:!0})}h(A)}return()=>{const e=a;a=new Set;for(const t of e)t()}}(p.tag,t.enhancements,s,a,v,w);return()=>{$(),p.destroy(),v.remove(),g(),x(),b(),E(),A()}}function de(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const s=Object.create(t);for(const[t,n]of r)s[t]=[n,e];return s}function he(t,n,r,s,i,o,a,l,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=s.set(t.vars),f=de(u,i,t.templates);if("divergent"===t.type)return ue(t,n,r,u,((e,t,s)=>{const f=u.set(t),d=de(f,i,s);return pe(e,n,r,f,d,o,a,l,c)}));if("value"===t.type){const e=u.child(t.name);return e?pe(t.children,n,r,e,f,o,a,l,c):()=>{}}if("enum"===t.type){const s=u.enum(t.value),i=(e,r)=>pe(t.children,n,e,r,f,o,a,l,c);return s instanceof v?function(t,n,r,s,i){const o=t.insertBefore(document.createComment(""),n);let a=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const c=new e.State(0),u=R((()=>r.children),(function(e){if(!o.parentNode)return;let n=o.nextSibling;const u=a;a=new Map,c.set(e.length);for(let o of e){const e=u.get(o);if(!e){const e=t.insertBefore(document.createComment(""),n),l=t.insertBefore(document.createComment(""),n),u=i(l,s.setStore(o,r,{get count(){return c.get()},get key(){return o.index},get index(){return o.index},get item(){return o.value}}));a.set(o,[e,l,u]);continue}if(u.delete(o),a.set(o,e),n===e[0]){n=e[1].nextSibling;continue}let l=e[0];for(;l&&l!==e[1];){const e=l;l=l.nextSibling,t.insertBefore(e,n)}t.insertBefore(e[1],n)}l(u)}),!0);return()=>{o.remove(),l(a),u()}}(n,r,s,u,i,t.sort):s instanceof y?function(e,t,n,r,s,i){const o=[],a=[...n],l=a.length,c=i?a.map((([e,t])=>[e,t,r.setStore(t,n).exec(i)])).sort((([,,e],[,,t])=>le(e,t))).map((([e,t],n)=>[e,t,n])):a.map((([e,t],n)=>[e,t,n]));for(const[e,i,a]of c)o.push(s(t,r.setStore(i,n,{get count(){return l},get key(){return e},get index(){return a},get item(){return i.value}})));return()=>{for(const e of o)e()}}(0,r,s,u,i,t.sort):"function"==typeof s?function(t,n,r,s,i,o){const a=new e.Computed((()=>{const e=r();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t])):Object.entries(e).map((([e,t])=>[t,e])):[]})),l=o?new e.Computed((()=>{const e=a.get();return e.map((([t,n],r)=>[n,t,s.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(o)])).sort((([,,e],[,,t])=>le(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Computed((()=>a.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function f(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const d=new e.State(0),h=R((()=>l.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const o=u;u=[],d.set(n.length);for(const[a,l,c]of n){const n=o.findIndex((e=>e[3]===c)),[f]=n>=0?o.splice(n,1):[];if(!f){const n=t.insertBefore(document.createComment(""),r),o=t.insertBefore(document.createComment(""),r),f=new e.State(a),h=new e.State(l),p=i(o,s.setObject({get count(){return d.get()},get key(){return c},get item(){return f.get()},get index(){return h.get()}}));u.push([n,o,p,c,f,h]);continue}if(u.push(f),f[4].set(a),f[5].set(l),r===f[0]){r=f[1].nextSibling;continue}let h=f[0];for(;h&&h!==f[1];){const e=h;h=h.nextSibling,t.insertBefore(e,r)}t.insertBefore(f[1],r)}f(o)}),!0);return()=>{c.remove(),f(u),h()}}(n,r,s,u,i,t.sort):()=>{}}if("content"===t.type)return ae(n,r,u,t.value,t.html);if("template"===t.type){const e=f[t.template];if(!e)return()=>{};const[s,d]=e,h=d.params(s.params,t.attrs,u,t.bind),p=de(h,i,s.templates);return pe(s.children,n,r,h,p,o,a,l,c)}return"fragment"===t.type?pe(t.children,n,r,u,f,o,a,l,c):fe(t,n,r,u,f,o,a,l,c)}function pe(e,t,n,r,s,i,o,a,l){const c=e.map((e=>he(e,t,n,r,s,i,o,a,l)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function me(e,t,n,{component:r,global:s,relate:i,enhancements:o}={}){return pe(t,n,null,new Y(e,s),Object.create(null),[],o||{},"function"==typeof i?i:null,r)}function ge(e,t,n,r,s){if(n instanceof Element){const o=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===o){const c=n.getAttribute("name")||"",u=c?t.child(c):t;if(!u)return()=>{};const f=u.component;if("function"==typeof f){const h=e(u,f);if(h){const[p,m]=h;return n.replaceWith(p),m}}const d=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(d)),()=>{}}const a=n.getAttribute("nl-form-field");if(a){const g=a.endsWith("[]"),b=g?a.slice(0,a.length-2):a,y=b?t.child(b):t;if(!y)return()=>{};if(n.removeAttribute("nl-form-field"),!g)return ge(e,y,n,r);if(!(y instanceof v))return n.remove(),()=>{};const w=n.parentElement;if(!w)return n.remove(),()=>{};const x=w.insertBefore(document.createComment(""),n)||null;n.remove();let E=new Map;function A(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let $=-1;const L=e=>{if($<0)return;const t=e?Number(e.index):y.children.length;t<0||$<0||$===t||y.move($,t)&&($=t)},O=R((()=>y.children),(t=>{let r=x.nextSibling;const s=E;E=new Map;for(const i of t){const t=s.get(i);if(t)s.delete(i),E.set(i,t),r!==t[0]?w.insertBefore(t[0],r):r=r.nextSibling;else{const t=w.insertBefore(n.cloneNode(!0),r),s=ge(e,i,t,t);t.addEventListener("dragenter",(()=>{L(i)})),t.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&($=Number(i.index))})),t.addEventListener("dragend",(()=>{$=-1})),E.set(i,[t,s])}}A(s)}),!0);return()=>{x.remove(),A(E),O()}}if(null!==n.getAttribute("nl-form-remove")){const S=t.parent;S instanceof v&&n.addEventListener("click",(()=>{S.remove(Number(t.index))}))}null!==n.getAttribute("nl-form-move")&&r instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{r.draggable=!0;const t=n=>{n.pointerId===e&&(r.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))};window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}));const l=n.getAttribute("nl-form-add");if(l){const C=t.child(l);C instanceof v&&n.addEventListener("click",(()=>{C.add({})}))}}if(!(n instanceof Element||n instanceof DocumentFragment))return()=>{};const i=[];for(const j of[...n.children])i.push(ge(e,t,j,r));return()=>{for(const e of i)e()}}function be(e,t,n,r,s){const i=function(e,t){if(!e)return document.createElement("template").content;if("string"==typeof e){const t=document.createElement("template");return t.innerHTML=e,t.content}return t?e:e.cloneNode(!0)}(r,s),o=ge(e,t,i);return n.appendChild(i),o}function ye(e,t,n,r,{columns:s,remove:i,dragenter:o,dragstart:a,dragend:l,deletable:c},u){const f=document.createElement("tbody");f.addEventListener("dragenter",(()=>{o()})),f.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&a()})),f.addEventListener("dragend",l);const d=f.appendChild(document.createElement("tr")),h=[];let p=()=>{};const m=[];if(s.find((e=>Array.isArray(e)&&e.includes("trigger")))){const i=f.appendChild(document.createElement("tr")),o=i.appendChild(document.createElement("td"));o.colSpan=s.length;const[a,l]=xe(e,t,n,r,u);o.appendChild(a),h.push(l),i.hidden=!0,p=function(){if(i.hidden){i.hidden=!1;for(const e of m)e.classList.remove("NeeloongFormGrid-table-line-open"),e.classList.add("NeeloongFormGrid-table-line-close")}else{i.hidden=!0;for(const e of m)e.classList.remove("NeeloongFormGrid-table-line-close"),e.classList.add("NeeloongFormGrid-table-line-open")}}}function g({pointerId:e}){function t(n){n.pointerId===e&&f&&(f.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}f.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}for(const r of s){if(!Array.isArray(r)){const s=d.appendChild(document.createElement("td")),i=e.child(r);if(!i)continue;const[o,a]=we(i,t,n,null,u,!0);h.push(a),s.appendChild(o);continue}const s=d.appendChild(document.createElement("th"));s.classList.add("NeeloongFormGrid-table-line-handle");for(const t of r)switch(t){case"trigger":{const e=s.appendChild(document.createElement("button"));e.classList.add("NeeloongFormGrid-table-line-open"),m.push(e),e.addEventListener("click",p);continue}case"move":{if(!n)continue;const t=s.appendChild(document.createElement("button"));t.classList.add("NeeloongFormGrid-table-move"),t.addEventListener("pointerdown",g),h.push(R((()=>e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"remove":{if(!n)continue;const t=s.appendChild(document.createElement("button"));t.classList.add("NeeloongFormGrid-table-remove"),t.addEventListener("click",i),h.push(R((()=>!c.get()||e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"serial":s.appendChild(document.createElement("span")).classList.add("NeeloongFormGrid-table-serial");continue}}return[f,()=>{for(const e of h)e()}]}function ve(e,t,n,r,s){const i=e.appendChild(document.createElement("tr")),o=[];for(const e of t){if(!Array.isArray(e)){const{width:t,label:n}=e,r=i.appendChild(document.createElement("th"));t&&r.setAttribute("width",t),r.innerText=n;continue}const t=i.appendChild(document.createElement("th"));if(s)for(const s of e)if("add"!==s);else{const e=t.appendChild(document.createElement("button"));e.addEventListener("click",n),e.classList.add("NeeloongFormGrid-table-add"),o.push(R((()=>!r.get()),(t=>{e.disabled=t}),!0))}}return()=>{for(const e of o)e()}}function we(t,n,r,s,i,o=!1){const{type:a,component:l}=t;if(o)return l?n(t,l,i):[document.createElement("div"),()=>{}];const c=[];if(a&&"object"==typeof a){const o=document.createElement("details");o.open=!0;const a=o.appendChild(document.createElement("summary"));if(c.push(q((()=>a.innerText=t.label||""))),c.push(q((()=>o.hidden=t.hidden))),"function"==typeof l){const[e,r]=n(t,l,i);o.appendChild(e),c.push(r)}else if(t instanceof v){const[a,l]=function(t,n,r,s,i){const o=s?.columns,a=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let l=[];if(Array.isArray(o)){const e=new Map(a.map((e=>[e.field,e])));l=o.map((t=>{if("string"==typeof t)return e.get(t)||[];if(!Array.isArray(t))return[];const n=new Set(["add","move","trigger","remove","serial"]);return t.filter((e=>n.delete(e)))})).filter((e=>!Array.isArray(e)||e.length))}l.length||(l=[["add","trigger","move","remove","serial"]]),l.find((e=>!Array.isArray(e)))||l.push(...a.slice(0,3));const c=document.createElement("table");c.className="NeeloongFormGrid-table";const u=c.appendChild(document.createElement("thead")),f=new e.Computed((()=>t.addable)),d={get:()=>r};function h(){t.add({})}function p(e){t.remove(Number(e.index))}let m=-1;function g(e){if(m<0)return;const n=e?Number(e.index):t.children.length;n<0||m<0||m===n||t.move(m,n)&&(m=n)}function b(e){m=Number(e.index)}function y(){m=-1}const v=[];switch(v.push(ve(u,l,h,f,r)),s?.tableFoot){default:case"header":{const e=c.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{g()})),v.push(ve(e,l,h,f,r));break}case"add":{const e=c.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{g()}));const t=e.appendChild(document.createElement("tr")).appendChild(document.createElement("th"));t.colSpan=l.length;const n=t.appendChild(document.createElement("button"));n.addEventListener("click",h),n.classList.add("NeeloongFormGrid-table-foot-add"),v.push(R((()=>!f.get()),(e=>{n.disabled=e}),!0));break}case"none":}const w=u;let x=new Map;function E(e){for(const[t,n]of e.values())n(),t.remove()}const A=l.map((e=>Array.isArray(e)?e:e.field)),$=R((()=>t.children),(function(e){let t=u.nextSibling;const o=x;x=new Map;for(let a of e){const e=o.get(a);if(e)o.delete(a),x.set(a,e),t!==e[0]?c.insertBefore(e[0],t):t=t.nextSibling;else{const[e,o]=ye(a,n,r,s,{columns:A,remove:p.bind(null,a),dragenter:g.bind(null,a),dragstart:b.bind(null,a),dragend:y,deletable:d},i);c.insertBefore(e,t),x.set(a,[e,o])}}E(o)}),!0);return[c,()=>{w.remove(),u.remove(),E(x),$();for(const e of v)e()}]}(t,n,r,s,i);o.appendChild(a),c.push(l)}else{const[e,a]=xe(t,n,r,s,i);o.appendChild(e),c.push(a)}return[o,()=>{for(const e of c)e()}]}const u=document.createElement("div");u.className="NeeloongFormGrid-item",c.push(q((()=>u.hidden=t.hidden)));const{colStart:f,colSpan:d,colEnd:h,rowStart:p,rowSpan:m,rowEnd:g}=s||{};f&&h?u.style.gridColumn=`${f} / ${h}`:f&&d?u.style.gridColumn=`${f} / span ${d}`:d&&(u.style.gridColumn=`span ${d}`),p&&g?u.style.gridRow=`${p} / ${g}`:p&&m?u.style.gridRow=`${p} / span ${m}`:m&&(u.style.gridRow=`span ${m}`);const b=u.appendChild(document.createElement("div"));b.className="NeeloongFormGrid-item-label",c.push(q((()=>b.innerText=t.label||"")));const y=u.appendChild(document.createElement("div"));y.className="NeeloongFormGrid-item-content";const w=u.appendChild(document.createElement("div"));if(w.className="NeeloongFormGrid-item-description",c.push(q((()=>w.innerText=t.description||""))),"function"==typeof l){const[e,r]=n(t,l,i);y.appendChild(e),c.push(r)}return[u,()=>{for(const e of c)e()}]}function xe(e,t,n,r,{parent:s,relate:i}){const o=s instanceof HTMLElement?s:document.createElement("div");o.className="NeeloongFormGrid";const a=[],l=r?.fields;if(l)for(const r of l){const s=e.child(r.field);if(!s)continue;const[l,c]=we(s,t,n,r,{relate:i});o.appendChild(l),a.push(c)}else{const r=[...e].map((([,e])=>e));for(const e of r){const[r,s]=we(e,t,n,null,{relate:i});o.appendChild(r),a.push(s)}}return[o,()=>{for(const e of a)e()}]}function Ee(e,t,n,r,s){return xe(e,n,r,s||null,{parent:t})[1]}export{v as ArrayStore,I as Layout,y as ObjectStore,b as Store,q as effect,me as render,Ee as renderGrid,be as renderHtml,R as watch};
6
+ import{Signal as e}from"signal-polyfill";export{Signal}from"signal-polyfill";function t(t,n,r,s){const o=new e.State("boolean"==typeof n?n:null),i="function"==typeof r?new e.Computed((()=>Boolean(r(t)))):new e.State(Boolean(r)),a=()=>{const e=o.get();return null===e?i.get():e},l=s?new e.Computed((()=>s.get()||a())):new e.Computed(a);return[o,l]}const n=e=>"string"==typeof e&&e||null,r=e=>"number"==typeof e&&e||null,s=e=>e instanceof RegExp?e:null,o=Boolean;function i(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(i).filter(o):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const a=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(i).filter(o);return t.length?t:null};function l(t,n,r,s){const o=new e.State(n(r));let i;if("function"==typeof s){const r=s;i=new e.Computed((()=>n(r(t))))}else{const t=n(s);i=new e.Computed((()=>t))}const a=new e.Computed((()=>{const e=o.get();return null===e?i.get():e}));return[o,a]}const c=Symbol();function u(e){const t={[c]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,c,{get:()=>e,configurable:!1,enumerable:!0}),t}let f=null,d=null,h=Object.create(null);function p(e,t){const n=e.type;let r=b;if(!e.array||d&&t?.parent instanceof d)if("string"==typeof n){const e=h[n];e&&(r=e)}else n&&"object"==typeof n&&f&&(r=f);else d&&(r=d);return new r(e,t)}function m(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function g(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Computed((()=>[])),()=>{}];const s=new e.State([]);let o=null;return[function(){o?.abort(),o=new AbortController;const e=o.signal;return s.set([]),Promise.all(r.map((n=>async function(e,n){let r=[];try{r.push(await e(t,n))}catch(e){r.push(e)}const o=r.flat().map(m).filter(Boolean);return!n.aborted&&o.length&&s.set([...s.get(),...o]),o}(n,e)))).then((e=>e.flat()))},new e.Computed((()=>s.get())),()=>{o?.abort(),s.set([])}]}class b{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}static create(e,t={}){return p({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){h[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||u(this)}constructor(o,{null:i,state:c,ref:f,default:d,setValue:h,setState:p,convert:y,onUpdate:v,onUpdateState:w,validator:x,validators:E,index:A,size:L,new:$,parent:C,hidden:O,clearable:S,required:j,disabled:M,readonly:N,removable:k,label:T,description:B,placeholder:U,min:P,max:q,step:_,minLength:I,maxLength:F,pattern:R,values:D}={}){this.schema=o,this.#r.set("object"==typeof c&&c||{});const V=C instanceof b?C:null;var H,K;V&&(this.#s=V,this.#o=V.#o,this.#i=V.#i),this.#a=(H=this,"function"!=typeof(K=d??o.default)?()=>structuredClone(K):()=>structuredClone(K(H)));const z=new e.State(!1);this.#l=z,this.#i=z,this.#c=o.type,this.#u=o.meta,this.#f=o.component;const Y=new e.State(Boolean($));this.#d=Y;const W=V?new e.Computed((()=>V.#h.get()||Y.get())):new e.Computed((()=>Y.get()));this.#h=W;const Q=Boolean(o.immutable),G=!1!==o.creatable;this.#p=Q,this.#m=G;const Z=o.readonly,X=new e.State("boolean"==typeof N?N:null);let J;if("function"==typeof Z)J=new e.Computed((()=>Boolean(Z(this))));else{const t=Boolean(Z);J=new e.Computed((()=>t))}const ee=()=>{if(W.get()?!G:Q)return!0;const e=X.get();return null===e?J.get():e},te=V?V.#g:null;this.#b=X,this.#g=te?new e.Computed((()=>te.get()||ee())):new e.Computed(ee),[this.#y,this.#v]=t(this,O,o.hidden,V?V.#v:null),[this.#w,this.#x]=t(this,S,o.clearable,V?V.#x:null),[this.#E,this.#A]=t(this,j,o.required,V?V.#A:null),[this.#L,this.#$]=t(this,M,o.disabled,V?V.#$:null),[this.#C,this.#O]=l(this,n,T,o.label),[this.#S,this.#j]=l(this,n,B,o.description),[this.#M,this.#N]=l(this,n,U,o.placeholder),[this.#k,this.#T]=l(this,r,P,o.min),[this.#B,this.#U]=l(this,r,q,o.max),[this.#P,this.#q]=l(this,r,_,o.step),[this.#_,this.#I]=l(this,r,I,o.minLength),[this.#F,this.#R]=l(this,r,F,o.maxLength),[this.#D,this.#V]=l(this,s,R,o.pattern),[this.#H,this.#K]=l(this,a,D,o.values),[this.#z,this.#Y]=t(this,k,o.removable??!0);const ne=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(m).filter(Boolean)})):new e.Computed((()=>[]))}(this,o.validator,x),[re,se,oe]=g(this,o.validators?.change,E?.change),[ie,ae,le]=g(this,o.validators?.blur,E?.blur);if(this.listen("change",(()=>{re()})),this.listen("blur",(()=>{ie()})),this.#W=function(...t){const n=t.filter(Boolean);return new e.Computed((()=>n.flatMap((e=>e.get()))))}(ne,se,ae),this.#Q=ne,this.#G=re,this.#Z=ie,this.#X=oe,this.#J=le,L instanceof e.State||L instanceof e.Computed?this.#ee=L:this.#ee=new e.State(L||0),i)return this.#t=!0,void(this.#n=u(this));this.#n=f||null,this.#te=v||null,this.#ne=w||null,this.#re="function"==typeof h?h:null,this.#se="function"==typeof p?p:null,this.#oe="function"==typeof y?y:null,this.#ie.set(A??"");for(const[e,t]of Object.entries(o.events||{}))"function"==typeof t&&this.listen(e,t)}#a;createDefault(){return this.#a()}#re=null;#se=null;#oe=null;#te=null;#ne=null;#s=null;#o=this;#c;#u;#f;#l=null;#i;get loading(){return this.#i.get()}set loading(e){const t=this.#l;t&&t.set(Boolean(e))}get store(){return this}get parent(){return this.#s}get root(){return this.#o}get type(){return this.#c}get meta(){return this.#u}get component(){return this.#f}#ee;get size(){return this.#ee.get()}#ie=new e.State("");get index(){return this.#ie.get()}set index(e){this.#ie.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#m=!0;get creatable(){return this.#m}#p=!1;get immutable(){return this.#p}#h;#d;get selfNew(){return this.#d.get()}set selfNew(e){this.#d.set(Boolean(e))}get new(){return this.#h.get()}set new(e){this.#d.set(Boolean(e))}#y;#v;get selfHidden(){return this.#y.get()}set selfHidden(e){this.#y.set("boolean"==typeof e?e:null)}get hidden(){return this.#v.get()}set hidden(e){this.#y.set("boolean"==typeof e?e:null)}#w;#x;get selfClearable(){return this.#w.get()}set selfClearable(e){this.#w.set("boolean"==typeof e?e:null)}get clearable(){return this.#x.get()}set clearable(e){this.#w.set("boolean"==typeof e?e:null)}#E;#A;get selfRequired(){return this.#E.get()}set selfRequired(e){this.#E.set("boolean"==typeof e?e:null)}get required(){return this.#A.get()}set required(e){this.#E.set("boolean"==typeof e?e:null)}#L;#$;get selfDisabled(){return this.#L.get()}set selfDisabled(e){this.#L.set("boolean"==typeof e?e:null)}get disabled(){return this.#$.get()}set disabled(e){this.#L.set("boolean"==typeof e?e:null)}#b;#g;get selfReadonly(){return this.#b.get()}set selfReadonly(e){this.#b.set("boolean"==typeof e?e:null)}get readonly(){return this.#g.get()}set readonly(e){this.#b.set("boolean"==typeof e?e:null)}#z;#Y;get selfRemovable(){return this.#z.get()}set selfRemovable(e){this.#z.set("boolean"==typeof e?e:null)}get removable(){return this.#Y.get()}set removable(e){this.#z.set("boolean"==typeof e?e:null)}#C;#O;get selfLabel(){return this.#C.get()}set selfLabel(e){this.#C.set(n(e))}get label(){return this.#O.get()}set label(e){this.#C.set(n(e))}#S;#j;get selfDescription(){return this.#S.get()}set selfDescription(e){this.#S.set(n(e))}get description(){return this.#j.get()}set description(e){this.#S.set(n(e))}#M;#N;get selfPlaceholder(){return this.#M.get()}set selfPlaceholder(e){this.#M.set(n(e))}get placeholder(){return this.#N.get()}set placeholder(e){this.#M.set(n(e))}#k;#T;get selfMin(){return this.#k.get()}set selfMin(e){this.#k.set(r(e))}get min(){return this.#T.get()}set min(e){this.#k.set(r(e))}#B;#U;get selfMax(){return this.#B.get()}set selfMax(e){this.#B.set(r(e))}get max(){return this.#U.get()}set max(e){this.#B.set(r(e))}#P;#q;get selfStep(){return this.#P.get()}set selfStep(e){this.#P.set(r(e))}get step(){return this.#q.get()}set step(e){this.#P.set(r(e))}#_;#I;get selfMinLength(){return this.#_.get()}set selfMinLength(e){this.#_.set(r(e))}get minLength(){return this.#I.get()}set minLength(e){this.#_.set(r(e))}#F;#R;get selfMaxLength(){return this.#F.get()}set selfMaxLength(e){this.#F.set(r(e))}get maxLength(){return this.#R.get()}set maxLength(e){this.#F.set(r(e))}#D;#V;get selfPattern(){return this.#D.get()}set selfPattern(e){this.#D.set(s(e))}get pattern(){return this.#V.get()}set pattern(e){this.#D.set(s(e))}#H;#K;get selfValues(){return this.#H.get()}set selfValues(e){this.#H.set(a(e))}get values(){return this.#K.get()}set values(e){this.#H.set(a(e))}#W;#Q;#G;#Z;#X;#J;get errors(){return this.#W.get()}get error(){return this.#W.get()[0]}*[Symbol.iterator](){}child(e){return null}#ae=!1;#le=new e.State(null);#ce=new e.State(this.#le.get());#r=new e.State(null);get changed(){return this.#ce.get()===this.#le.get()}get value(){return this.#ce.get()}set value(e){const t=this.#re?.(e),n=void 0===t?e:t;this.#ce.set(n),this.#ae||this.#le.set(n),this.#te?.(n,this.#ie.get(),this),this.#ue()}get state(){return this.#r.get()}set state(e){const t=this.#se?.(e),n=void 0===t?e:t;this.#r.set(n),this.#ne?.(n,this.#ie.get(),this),this.#ue()}#ue(){this.#fe||(this.#fe=!0,queueMicrotask((()=>{const e=this.#ce.get(),t=this.#r.get();this.#de(e,t)})))}reset(e=this.#le.get()){this.#he(e)}#he(e){const t=this.#re?.(e),n=void 0===t?e:t;if(this.#X(),this.#J(),this.#ae=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#he(null);return this.#ce.set(n),this.#le.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#he(r[e]);return this.#ce.set(r),this.#le.set(r),this.#te?.(r,this.#ie.get(),this),r}#fe=!1;#pe(e,t){const[n,r]=this.#oe?.(e,t)||[e,t];return this.#ce.get()===n&&this.#r.get()===r?[n,r]:(this.#ce.set(n),this.#r.set(r),this.#de(n,r))}#de(e,t){this.#fe=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},o=!1;for(const[n,i]of this){const a=e[n],l=t?.[n],[c,u]=i.#pe(a,l);a!==c&&(r[n]=c,o=!0),l!==u&&(s[n]=u,o=!0)}o&&(t=s,n=e=r,this.#ce.set(e),this.#r.set(s))}return this.#ae||(this.#ae=!0,this.#le.set(n)),[e,t]}validate(e){if(!0===e)return Promise.all([this.#Q.get(),this.#G(),this.#Z()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=Array.isArray(e)?e:[],n=[this.validate().then((e=>e?.length?[{path:[...t],store:this,errors:e}]:[]))];for(const[e,r]of this)n.push(r.validate([...t,e]));return Promise.all(n).then((e=>e.flat()))}}class y extends b{get kind(){return"object"}#me;*[Symbol.iterator](){yield*Object.entries(this.#me)}child(e){return this.#me[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o}={}){const i=Object.entries(e.type),a=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o,size:i.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}],default:e.default??(()=>Object.fromEntries(Object.entries(a).map((([e,t])=>[e,t.createDefault()]))))});const l={parent:this,onUpdate:(e,t,n)=>{n===this.#me[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#me[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of i)a[e]=p(t,{...l,index:e});this.#me=a}}f=y;class v extends b{#ge=()=>{throw new Error};#me;get children(){return[...this.#me.get()]}*[Symbol.iterator](){return yield*[...this.#me.get().entries()]}child(e){const t=this.#me.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(n,{parent:r,onUpdate:s,onUpdateState:o,index:i,new:a,addable:l}={}){const c=new e.State([]),u=e=>{const t=Array.isArray(e)&&e.length||0,n=[...c.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#ge(e));n.length=t,r!==t&&c.set(n)};super(n,{index:i,new:a,parent:r,size:new e.Computed((()=>c.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return u(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{u(e),s?.(e,t,n)},onUpdateState:o,default:n.default??[]}),[this.#be,this.#ye]=t(this,l,n.addable??!0),this.#me=c;const f={parent:this,onUpdate:(e,t,n)=>{if(c.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(c.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#ge=(e,t)=>{const r=p(n,{...f,index:e,new:t});return r.index=e,r}}#be;#ye;get selfAddable(){return this.#be.get()}set selfAddable(e){this.#be.set("boolean"==typeof e?e:null)}get addable(){return this.#ye.get()}set addable(e){this.#be.set("boolean"==typeof e?e:null)}insert(e,t=null,n){if(!this.addable)return!1;const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#me.get()],o=Math.max(0,Math.min(Math.floor(e),s.length)),i=this.#ge(o,n);i.new=!0,s.splice(o,0,i);for(let t=e+1;t<s.length;t++)s[t].index=t;const a=[...r];a.splice(o,0,t??i.createDefault());const l=this.state;if(Array.isArray(l)){const e=[...l];e.splice(o,0,{}),this.state=e}return this.#me.set(s),this.value=a,!0}add(e=null){return this.insert(this.#me.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#me.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const o=[...t],[i]=o.splice(r,1),a=this.state;if(Array.isArray(a)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#me.set(n),this.value=o,i}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let o=Math.min(e,t),i=Math.max(e,t);for(let e=o;e<=i;e++)r[e].index=e;const a=[...n],[l]=a.splice(e,1);a.splice(t,0,l);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#me.set(r),this.value=a,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],s=r[e],o=r[t];if(!s||!o)return!1;r[t]=s,r[e]=o,s.index=t,o.index=e;const i=[...n],a=i[e],l=i[t];i[t]=a,i[e]=l;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#me.set(r),this.value=i,!0}}function w(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),s=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;s=!0;const n=x(t);r[e]={params:t.params,children:n?[n]:[]}}function o(e){e.length&&t.push({type:"divergent",children:e.map((([e,t])=>{const n=x(t);return n?"string"!=typeof n&&"fragment"===n.type?[n,e]:[{children:[n]},e]:[{children:[]},e]}))})}for(const r of e){if("string"==typeof r){o(n),n=[],t.push(r);continue}if(r.template){o(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(o(n),n=[]);continue}o(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const s=x(r);s&&t.push(s)}return o(n),s?[{type:"fragment",templates:r,children:t}]:t}function x(e){let t=function(e){const t=e.fragment;if(t&&"string"==typeof t)return{type:"template",template:t,attrs:e.attrs,children:[]};const n=function({text:e,html:t}){return null!=e?{type:"content",value:e}:null!=t?{type:"content",value:t,html:!0}:void 0}(e),r=n?[n]:w(e.children);return!e.name||t?n||{type:"fragment",children:r}:{name:e.name,is:e.is,attrs:e.attrs,events:e.events,classes:e.classes,styles:e.styles,enhancements:e.enhancements,bind:e.bind,comment:e.comment,children:r}}(e),n=e.vars;n.length&&t&&"string"!=typeof t&&(t.vars?t.vars=[...n,...t.vars]:t?t.vars=n:t={type:"fragment",vars:n,children:[]},n=null);const r=e.enum,s=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),s&&(t={type:"value",name:s,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){d=e}(v);const E=/^([+-]?(\d(_?\d)*(\.(\d(_?\d)*)?)?|\.\d(_?\d)*)(?:e[+-]?\d(_?\d)*)|0(b[01](?:_?[01])*|o[0-7](?:_?[0-7])*|x[\dA-F](?:_?[\dA-F])*))$/is;const A={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class L extends Error{constructor(e,...t){const n=A[e];super("function"==typeof n?n(...t):n),this.code=e}}const $=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,C=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,O=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function S(e,t){const n=e[t];if(n)return n;const r={attrs:Object.create(null),events:Object.create(null)};return e[t]=r,r}function j(e,t){const n=e.replace(/$\s+|\s+$/gs,"");if("null"===n)return{value:null};if("true"===n)return{value:!0};if("false"===n)return{value:!1};const r=function(e){return E.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?O.test(n)?{name:n}:{calc:t(e)}:{value:r}}function M(e,t,n,r,s){const{attrs:o,events:i,classes:a,styles:l,vars:c,params:u,enhancements:f}=e;return function(d,h){const p=d.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=($.exec(p)||C.exec(p))?.groups;if(!m)throw new L("ATTR",d);const{name:g,enhancement:b}=m,y=m.decorator?.toLowerCase();if(b){if(":"===y)S(f,b).attrs[g]=h?j(h,t):{name:g};else if("@"===y)S(f,b).events[g]=h?O.test(h)?{name:h}:{event:r(h)}:{name:g};else if("!"===y){if("bind"===g)S(f,b).bind=h||!0}else S(f,b).value=j(h,t);return}if(!y)return void(o[g]={value:h});if(":"===y)return void(o[g]=h?j(h,t):{name:g});if("."===y)return void(a[g]=h?j(h,t):{name:g});if("style:"===y)return void(l[g]=j(h,t));if("@"===y)return void(i[g]=h?O.test(h)?{name:h}:{event:r(h)}:{name:g});if("+"===y)return void c.push({...h?j(h,n):{value:void 0},variable:g,init:!0});if("*"===y)return void c.push({...j(h,t),variable:g,init:!1});if("?"===y)return void(u[g]=j(h,t));if("!"!==y)return;switch(g.toString()){case"fragment":e.fragment=h||!0;break;case"else":e.else=!0;break;case"enum":e.enum=h?j(h,t):{value:!0};break;case"sort":e.sort=h?j(h,t):{value:!0};break;case"if":e.if=j(h,t);break;case"text":e.text=j(h,t);break;case"html":s&&(e.html=j(h,t));break;case"template":e.template=h;break;case"bind":e.bind=h||!0;break;case"value":e.value=h;break;case"comment":e.comment=h}}}function N(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:[],params:Object.create(null),enhancements:Object.create(null)}}var k={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const T=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function B(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function U(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function P(...e){console.error(new L(...e))}function q(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in k?k[t]:(P("ENTITY",e),e)}var _=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new L("CALC")},createInit:n=t,createEvent:r=()=>{throw new L("EVENT")},simpleTag:s=new Set,enableHTML:o=!1}={}){const i=[],a={children:i},l=[];let c=null,u=a;function f(){c=l.pop()||null,u=c||a}function d(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&u.children.push(e)}let h={},p=0;function m(t){if(t<=p)return;d(e.substring(p,t).replace(/&#?\w+;/g,q)),p=t}for(;;){const g=e.indexOf("<",p);if(g<0){const j=e.substring(p);j.match(/^\s*$/)||d(j);break}g>p&&m(g);const b=e.charAt(g+1);if("!"===b){let k=g+2,_=">";if("--"===e.slice(g+2,g+4)&&(k+=4,_="--\x3e"),p=e.indexOf(_,k),p<0)break;p++;continue}if("/"===b){p=e.indexOf(">",g+3);let I=e.substring(g+2,p);if(p<0?(I=e.substring(g+2).replace(/[\s<].*/,""),P("UNCOMPLETED",I,c?.name),p=g+1+I.length):I.match(/\s</)&&(I=I.replace(/[\s<].*/,""),P("UNCOMPLETED",I),p=g+1+I.length),c){const F=c.name;if(F===I)f();else{if(F.toLowerCase()!=I.toLowerCase())throw new L("CLOSE",I,c.name);f()}}p++;continue}function y(t){let n=p+1;if(p=e.indexOf(t,n),p<0)throw new L("QUOTE",t);const r=e.slice(n,p).replace(/&#?\w+;/g,q);return p++,r}function v(){let t=e.charAt(p);for(;t<=" "||"€"===t;t=e.charAt(++p));return t}function x(){let t=p,n=e.charAt(p);for(;B(n);)p++,n=e.charAt(p);return e.slice(t,p)}p=g+1;let E=e.charAt(p);switch(E){case"=":throw new L("EQUAL");case'"':case"'":throw new L("ATTR_VALUE");case">":case"/":throw new L("SYMBOL",E);case"":throw new L("EOF")}const A=x(),$=T.exec(A)?.groups;if(!$)throw new L("TAG",A);l.push(c),c=N($.name,$.is),u.children.push(c),u=c;const C=M(c,t,n,r,o);let O=!0,S=!1;e:for(;O;){let R=v();switch(R){case"":P("EOF"),p++;break e;case">":p++;break e;case"/":S=!0;break e;case'"':case"'":throw new L("ATTR_VALUE");case"=":throw new L("SYMBOL",R)}const D=x();if(!D){P("EOF"),p++;break e}switch(R=v(),R){case"":P("EOF"),p++;break e;case">":C(D,""),p++;break e;case"/":C(D,""),S=!0;break e;case"=":p++;break;case"'":case'"':C(D,y(R));continue;default:C(D,"");continue}switch(R=v(),R){case"":C(D,""),P("EOF"),p++;break e;case">":C(D,""),p++;break e;case"/":C(D,""),S=!0;break e;case"'":case'"':C(D,y(R));continue}C(D,x())}if(S){for(;;){p++;const V=e.charAt(p);if("/"!==V&&!(V<=" "||"€"===V))break}switch(e.charAt(p)){case"=":throw new L("EQUAL");case'"':case"'":throw new L("ATTR_VALUE");case"":P("EOF");break;case">":p++;break;default:throw new L("CLOSE_SYMBOL")}f()}else(s.has(A)||U(e,p,A,h))&&f()}return w(i)}});function I(t){let n=!0;const r=new e.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),s=new e.Computed(t);return r.watch(s),s.get(),()=>{r.unwatch(s)}}function F(e,t,n){let r,s=!1;return I((()=>{const o=e();if(!s)return s=!0,r=o,void(n&&t(o));Object.is(o,r)||(r=o,t(o))}))}const R=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,loading:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,size:!0,error:!0,errors:!0}));function*D(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of R)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof v?(yield[`${t}${n}addable`,{get:()=>e.addable}],yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}]):yield[`${t}${n}addable`,{get:()=>!1}]}function V(e,t,n){for(const[n,r]of t){for(const[t,s]of D(r,n))e[t]=s;for(const[t,s]of D(r,n,"$$"))e[t]=s}}const H={value$:{calc:e=>e?.[c].value},state$:{calc:e=>e?.[c].state}};var K=Object.getOwnPropertyDescriptors(H);function z(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function Y(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class W{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ve[e];if("function"!=typeof t?.get)return;return t.get()}return"function"==typeof t?t(this.getters):n}get({name:t,calc:n,value:r}){if("string"==typeof t){const e=this.#ve[t];if("function"!=typeof e?.get)return;const{get:n,set:r}=e;return{get:n,set:r}}if("function"==typeof n){const t=new e.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return F((()=>this.exec(e)),t,!0)}enum(e){const{name:t,calc:n}=e;if("function"==typeof n)return()=>n(this.getters);if("string"==typeof t){const e=this.#ve[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof b?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ve[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ve[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?R.has(t)?F((()=>s[t]),n,!0):void 0:"value"===t?F((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>F(e,t,!0)}}return Object.fromEntries([...R].map((e=>[`$${e}`,t=>F((()=>n[e]),t,!0)])))}getBindAll(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return{};const{store:n}=t;if(!n){const{get:e,set:n}=t;return{$value:{get:e,set:n}}}return Object.fromEntries([...R].map((e=>[`$${e}`,"value"===e||"state"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])))}bindSet(e,t){const n=this.#ve[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#ve[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent({name:e,event:t}){if("function"==typeof t)return t;const n=this.#ve[e];if(!n)return null;const{exec:r,calc:s}=n;return"function"==typeof r?r:"function"==typeof s?s:null}constructor(e,t){if(this.store=e,t instanceof W){this.#we=t.#we;const e=this.#xe;for(const[n,r]of Object.entries(t.#xe))e[n]=r;const n=this.#Ee;for(const[e,r]of Object.entries(t.#Ee))n[e]=r}else V(this.#xe,e),this.#we=function(e){const t=Object.create(null,K);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!z(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof b){for(const[e,s]of D(r,n))t[e]=s;continue}const{get:e,set:s,exec:o,calc:i}=r;"function"!=typeof e?"function"==typeof i||i&&"object"==typeof i?t[n]={calc:i}:("function"==typeof o||i&&"object"==typeof i)&&(t[n]={exec:o}):t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#we;#xe=Object.create(null);#Ee=Object.create(null);store;#Ae=null;#s=null;#Le=null;get#ve(){const e=this.#Le;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#xe,...this.#we,...this.#Ee})),n=this.store,r=this.#s,s=this.#Ae;for(const[e,r]of D(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof v))return yield[`${n}${r}removable`,{get:()=>!1}],yield[`${n}${r}upMovable`,{get:()=>!1}],yield[`${n}${r}downMovable`,{get:()=>!1}],yield[`${n}${r}remove`,{exec:()=>{}}],yield[`${n}${r}upMove`,{exec:()=>{}}],void(yield[`${n}${r}downMove`,{exec:()=>{}}]);yield[`${n}${r}removable`,{get:()=>!e.readonly&&!e.disabled&&!!t.removable}],yield[`${n}${r}upMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n>=e.size-1)}}],yield[`${n}${r}remove`,{exec:()=>{e.readonly||e.disabled||t.removable&&e.remove(Number(t.index))}}],yield[`${n}${r}upMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n>=e.size-1||e.move(n,n+1))}}]}(r,n))t[e]=s;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};return this.#Le=t,t}setStore(e,t,n){const r=new W(e,this);return t&&(r.#s=t),V(r.#xe,e),n&&(r.#Ae=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new W(t,this);return V(n.#xe,t),n}params(t,n,r,s){let o=this.store;if(!0===s)o=r.store;else if(s){const e=r.#ve[s],t=e?.get&&e.store;t&&(o=t)}if(0===Object.keys(t).length)return this;const i=new W(o,this);i.#s=this.#s,i.#Ae=this.#Ae;const a=i.#Ee,l=i.#ve;for(const[s,o]of Object.entries(t)){const t=s in n?n[s]:null;if(t){const{name:n,calc:o,value:i}=t;if(n){const e=r.#ve[n];if(!e?.get)continue;if(!e.store){a[s]=l[s]=e;continue}for(const[t,n]of D(e.store,s))a[t]=l[t]=n;continue}if("function"==typeof o){const t=new e.Computed((()=>o(r.getters)));a[s]=l[s]={get:()=>t.get()};continue}a[s]=l[s]={get:()=>i}}else{const{name:t,calc:n,value:r}=o;if("function"==typeof n){const t=i.getters;i.#$e=null;const r=new e.Computed((()=>n(t)));a[s]=l[s]={get:()=>r.get()};continue}if(t){const e=l[t];if(!e?.get)continue;if(!e.store){a[s]=l[s]=e;continue}for(const[t,n]of D(e.store,s))a[t]=l[t]=n;continue}a[s]=l[s]={get:()=>r}}}return i}setObject(e){const t=new W(this.store,this);return t.#Ae=e,t}set(t){if(!t?.length)return this;const n=new W(this.store,this);n.#s=this.#s,n.#Ae=this.#Ae;const r=n.#Ee,s=n.#ve;for(const{variable:o,name:i,calc:a,value:l,init:c}of t)if(c){const t=new e.State(l);if("function"==typeof a){const e=n.settable;n.#Ce=null,t.set(a(e))}else if(i){const e=s[i];if(!e?.get)continue;t.set(e.get())}r[o]=s[o]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof a)if(i){const e=s[i];if(!e)continue;if(!e.get||!e.store){r[o]=s[o]=e;continue}for(const[t,n]of D(e.store,o))r[t]=s[t]=n}else r[o]=s[o]={get:()=>l};else{const t=n.getters;n.#$e=null;const i=new e.Computed((()=>a(t)));r[o]=s[o]={get:()=>i.get()}}return n}#Oe=null;get all(){const e=this.#Oe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return Y(this.store,t),this.#Oe=t,t}#Ce=null;get settable(){const e=this.#Ce;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return Y(this.store,t),this.#Ce=t,t}#$e=null;get getters(){const e=this.#$e;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ve))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return Y(this.store,t),this.#$e=t,t}}const Q={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function G(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Q?`${s}${Q[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Z{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}}const X={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function J(e,t,n){const r=[];if(t)for(let s=e.shift();s;s=e.shift()){const e=s.indexOf(":"),o=e>=0?s.slice(0,e):s,i=e>=0?s.slice(e+1).split(":"):[],a=o.replace(/^-+/,""),l=(o.length-a.length)%2==1;let c=t[a]||a;if(n)switch(c){case"once":case"passive":case"capture":n[c]=!l;continue}"string"==typeof c&&(c=X[c]),"function"==typeof c&&r.push([c,i,l])}return r}function ee(e,t,n){return r=>{const s=e.all;for(const[e,t,o]of n)if(e(r,t,s)===o)return;t(r,s)}}function te(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function ne(e){return null===(e??null)?"":String(e)}function re(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return ne;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const se={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=ne(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=ne(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=ne(e)}},events:{$value:["change",(e,t)=>t.value]}}};function oe(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:s,props:o}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const i=se[t.toLowerCase()],a=i?.attrs||{},l=i?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=l[e];if(n){const[e,o]=n;r.addEventListener(e,(e=>t(o(e,r))),s)}}if(o)for(const[t,n]of Object.entries(e.attrs))if(s(t,(e=>{if(o.has(t))r[t]=e;else{const n=te(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),o.has(t))r[t]=n;else{const e=te(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.attrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=te(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=a[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=re(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let o=te(n);null!==o&&r.setAttribute(t,o),s(t,(e=>{const n=te(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function ie(e){return null===(e??null)?"":String(e)}function ae(e,t,n,r,s){if(!s){const s=e.insertBefore(document.createTextNode(""),t),o=n.watch(r,(e=>s.textContent=ie(e)));return()=>{s.remove(),o()}}const o=e.insertBefore(document.createComment(""),t),i=e.insertBefore(document.createComment(""),t),a=document.createElement("div");function l(){for(let e=o.nextSibling;e&&e!==i;e=o.nextSibling)e.remove()}const c=n.watch(r,(t=>{l(),function(t){a.innerHTML=t;for(let t=a.firstChild;t;t=o.firstChild)e.insertBefore(t,i)}(ie(t))}));return()=>{c(),l(),o.remove(),i.remove()}}function le(e,t){if("bigint"==typeof e&&"bigint"==typeof t)return Number(e-t);if(!("number"!=typeof e&&"bigint"!=typeof e||"number"!=typeof t&&"bigint"!=typeof t))return Number(e)-Number(t);const n=String(e),r=String(t);return n>r?1:n<r?-1:0}const ce=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ue(e,t,n,r,s){const o=e.children;if(!o.length)return()=>{};const i=t.insertBefore(document.createComment(""),n);let a=null,l=()=>{};const c=F((()=>o.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===a)return;a=e,l(),l=()=>{};const t=e?.[0];t&&(l=s(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),l(),l=()=>{},i.remove())}}function fe(t,n,r,s,o,i,a,l,c){const u=t.bind,f=[...i,t.name],d=c?.(f);if(c&&!d)return()=>{};const{context:h,handler:p}=function(t,n,r,s){const o="string"==typeof t?t:t.tag,{attrs:i,events:a}="string"!=typeof t&&t||{attrs:null,events:null};let l=!1;const c=new e.State(!1);let u=!1;const f=new e.State(!1),d=Object.create(null),h=Object.create(null),p=new Set,m=[],g=new Z;return{context:{events:m,props:i?new Set(Object.entries(i).filter((([,e])=>e.isProp)).map((([e])=>e))):null,attrs:h,watch(e,t){if(l)return()=>{};const n=d[e];if(!n)return()=>{};let r=n.get();const s=F((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return p.add(s),()=>{p.delete(s),s()}},relate(e){if(!r||!s||l)return()=>{};try{const t=s(r,e);return"function"!=typeof t?()=>{}:(p.add(t),()=>{p.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return f.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:o,set(t,n){if(i&&!(t in i))return;let r=d[t];if(r)return void r.set(n);const s=new e.State(n);d[t]=s,Object.defineProperty(h,t,{configurable:!0,enumerable:!0,get:s.get.bind(s)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...s]=e.split(".").filter(Boolean),o=a?a[r].filters:{};if(!o)return;const i={},l=J(s,o,i);m.push([r,ee(n,t,l),i])},destroy(){if(!l){l=!0,c.set(!0);for(const e of p)e();g.emit("destroy")}},mount(){u||(u=!0,f.set(!0),g.emit("init",{events:m}))}}}}(d||t.name,s,s.getStore(u),l),m=d?.attrs,g=m?function(e,t,n,r,s){let o=new Set;for(const[i,a]of Object.entries(r)){if("class"===i||"style"===i)continue;if(i in n){const r=n[i],{name:s,calc:l,value:c}=n[i];if(!s&&!l){e.set(i,c);continue}a.immutable&&e.set(i,t.exec(r)),o.add(t.watch(r,(t=>e.set(i,t))));continue}const r=a.bind;if(!s||!r){e.set(i,a.default);continue}if("string"==typeof r){const n=t.bind(s,r,(t=>e.set(i,t)));n?o.add(n):e.set(i,a.default);continue}if(!Array.isArray(r)){e.set(i,a.default);continue}const[l,c,u]=r;if(!l||"function"!=typeof c)continue;if(!u){const n=!0===s?"":s;o.add(t.watch({name:n},(t=>e.set(i,t)))),e.addEvent(l,((...e)=>{t.all[n]=c(...e)}));continue}const f=t.bind(s,"state",(t=>e.set(i,t)));if(!f)continue;o.add(f);const d=t.bindSet(s,"state");d&&e.addEvent(l,((...e)=>{d(c(...e))}))}return()=>{const e=o;o=new Set;for(const t of e)t()}}(p,s,t.attrs,m,u):function(e,t,n){const r=e.tag;let s=new Set;for(const[o,i]of Object.entries(n)){if("class"===o||"style"===o)continue;const{name:n,calc:a,value:l}=i;if(n||a)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==o.toLocaleLowerCase())s.add(t.watch(i,(t=>e.set(o,t))));else{const n=t.exec(i);e.set(o,n)}else e.set(o,l)}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,s,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=s.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,o]of Object.entries(t.bindAll(n)||{}))"function"==typeof o&&r.add(o((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,s,u),y=d?"function"==typeof d.tag?d.tag(h):oe(h,d.tag,d.is):oe(h,t.name,t.is),v=Array.isArray(y)?y[0]:y,w=Array.isArray(y)?y[1]:v;n.insertBefore(v,r);const x=w?pe(t.children||[],w,null,s,o,i,a,l,c):()=>{},E=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let s=new Set;for(const[r,o]of Object.entries(n))o.value?e.classList.add(r):s.add(F((()=>Boolean(t.exec(o))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!s)return;const e=s;s=null;for(const t of e)t()}}(v,s,t.classes,t.attrs.class),A=function(e,t,n,r){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};if(r){const n=[e.getAttribute("style")||"",t.exec(r)||""].filter(Boolean).join(";");n&&e.setAttribute("style",n)}let s=new Set;for(const[r,o]of Object.entries(n))s.add(F((()=>G(r,t.exec(o))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!s)return;const e=s;s=null;for(const t of e)t()}}(v,s,t.styles,t.attrs.style);p.mount();const L=function(t,n,r,s,o,i){let a=new Set;for(const[l,{attrs:c,value:u,events:f,bind:d}]of Object.entries(n)){if(!ce(s,l))continue;const h=s[l];if("function"!=typeof h)continue;let p=!1;const m=new e.State(!1),g=h?.events,b=[],y=Object.create(null),v=new Set,w=new Z;function x(e,t){if("function"!=typeof t)return;const[n,...s]=e.split(".").filter(Boolean),o=g?g[n].filters:{};if(!o)return;const i={},a=J(s,o,i);b.push([n,ee(r,t,a),i])}function E(){if(!p){p=!0,m.set(!0);for(const e of v)e();w.emit("destroy")}}a.add(E);for(const[L,$]of Object.entries(c)){const C=r.get($);C&&Object.defineProperty(y,L,{...C,configurable:!0,enumerable:!0})}for(const[O,S]of Object.entries(f)){const j=r.getEvent(S);j&&x(O,j)}if(d){for(const[M,N]of Object.entries(r.getBindAll(d)||{}))Object.defineProperty(y,M,{...N,configurable:!0,enumerable:!0});for(const[k,T]of Object.entries(r.bindEvents(d)||{}))x(k,(e=>T(e)))}const A={get value(){return null},events:b,attrs:y,watch(e,t){if(p)return()=>{};let n=y[e];const r=F((()=>y[e]),(r=>{const s=n;n=r,t(r,s,e)}),!0);return v.add(r),()=>{v.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:o,slot:i,tag:t};if(u){const B=r.get(u);B&&Object.defineProperty(A,"value",{...B,configurable:!0,enumerable:!0})}h(A)}return()=>{const e=a;a=new Set;for(const t of e)t()}}(p.tag,t.enhancements,s,a,v,w);return()=>{L(),p.destroy(),v.remove(),g(),x(),b(),E(),A()}}function de(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const s=Object.create(t);for(const[t,n]of r)s[t]=[n,e];return s}function he(t,n,r,s,o,i,a,l,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=s.set(t.vars),f=de(u,o,t.templates);if("divergent"===t.type)return ue(t,n,r,u,((e,t,s)=>{const f=u.set(t),d=de(f,o,s);return pe(e,n,r,f,d,i,a,l,c)}));if("value"===t.type){const e=u.child(t.name);return e?pe(t.children,n,r,e,f,i,a,l,c):()=>{}}if("enum"===t.type){const s=u.enum(t.value),o=(e,r)=>pe(t.children,n,e,r,f,i,a,l,c);return s instanceof v?function(t,n,r,s,o){const i=t.insertBefore(document.createComment(""),n);let a=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const c=new e.State(0),u=F((()=>r.children),(function(e){if(!i.parentNode)return;let n=i.nextSibling;const u=a;a=new Map,c.set(e.length);for(let i of e){const e=u.get(i);if(!e){const e=t.insertBefore(document.createComment(""),n),l=t.insertBefore(document.createComment(""),n),u=o(l,s.setStore(i,r,{get count(){return c.get()},get key(){return i.index},get index(){return i.index},get item(){return i.value}}));a.set(i,[e,l,u]);continue}if(u.delete(i),a.set(i,e),n===e[0]){n=e[1].nextSibling;continue}let l=e[0];for(;l&&l!==e[1];){const e=l;l=l.nextSibling,t.insertBefore(e,n)}t.insertBefore(e[1],n)}l(u)}),!0);return()=>{i.remove(),l(a),u()}}(n,r,s,u,o,t.sort):s instanceof y?function(e,t,n,r,s,o){const i=[],a=[...n],l=a.length,c=o?a.map((([e,t])=>[e,t,r.setStore(t,n).exec(o)])).sort((([,,e],[,,t])=>le(e,t))).map((([e,t],n)=>[e,t,n])):a.map((([e,t],n)=>[e,t,n]));for(const[e,o,a]of c)i.push(s(t,r.setStore(o,n,{get count(){return l},get key(){return e},get index(){return a},get item(){return o.value}})));return()=>{for(const e of i)e()}}(0,r,s,u,o,t.sort):"function"==typeof s?function(t,n,r,s,o,i){const a=new e.Computed((()=>{const e=r();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t])):Object.entries(e).map((([e,t])=>[t,e])):[]})),l=i?new e.Computed((()=>{const e=a.get();return e.map((([t,n],r)=>[n,t,s.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(i)])).sort((([,,e],[,,t])=>le(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Computed((()=>a.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function f(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const d=new e.State(0),h=F((()=>l.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const i=u;u=[],d.set(n.length);for(const[a,l,c]of n){const n=i.findIndex((e=>e[3]===c)),[f]=n>=0?i.splice(n,1):[];if(!f){const n=t.insertBefore(document.createComment(""),r),i=t.insertBefore(document.createComment(""),r),f=new e.State(a),h=new e.State(l),p=o(i,s.setObject({get count(){return d.get()},get key(){return c},get item(){return f.get()},get index(){return h.get()}}));u.push([n,i,p,c,f,h]);continue}if(u.push(f),f[4].set(a),f[5].set(l),r===f[0]){r=f[1].nextSibling;continue}let h=f[0];for(;h&&h!==f[1];){const e=h;h=h.nextSibling,t.insertBefore(e,r)}t.insertBefore(f[1],r)}f(i)}),!0);return()=>{c.remove(),f(u),h()}}(n,r,s,u,o,t.sort):()=>{}}if("content"===t.type)return ae(n,r,u,t.value,t.html);if("template"===t.type){const e=f[t.template];if(!e)return()=>{};const[s,d]=e,h=d.params(s.params,t.attrs,u,t.bind),p=de(h,o,s.templates);return pe(s.children,n,r,h,p,i,a,l,c)}return"fragment"===t.type?pe(t.children,n,r,u,f,i,a,l,c):fe(t,n,r,u,f,i,a,l,c)}function pe(e,t,n,r,s,o,i,a,l){const c=e.map((e=>he(e,t,n,r,s,o,i,a,l)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function me(e,t,n,{component:r,global:s,relate:o,enhancements:i}={}){return pe(t,n,null,new W(e,s),Object.create(null),[],i||{},"function"==typeof o?o:null,r)}function ge(e,t,n,{columns:r,remove:s,dragenter:o,dragstart:i,dragend:a,deletable:l},c){const u=document.createElement("tbody");u.addEventListener("dragenter",(()=>{o()})),u.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&i()})),u.addEventListener("dragend",a);const f=u.appendChild(document.createElement("tr")),d=[];let h=()=>{};const p=[];if(r.find((e=>Array.isArray(e)&&e.includes("trigger")))){const s=u.appendChild(document.createElement("tr")),o=s.appendChild(document.createElement("td"));o.colSpan=r.length;const[i,a]=Me(e,t,n,c);o.appendChild(i),d.push(a),s.hidden=!0,h=function(){if(s.hidden){s.hidden=!1;for(const e of p)e.classList.remove("NeeloongForm-table-line-open"),e.classList.add("NeeloongForm-table-line-close")}else{s.hidden=!0;for(const e of p)e.classList.remove("NeeloongForm-table-line-close"),e.classList.add("NeeloongForm-table-line-open")}}}function m({pointerId:e}){function t(n){n.pointerId===e&&u&&(u.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}u.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}for(const n of r){if(!Array.isArray(n)){const r=f.appendChild(document.createElement("td")),s=e.child(n);if(!s)continue;const[o,i]=Se(s,t,null,c,!0);d.push(i),r.appendChild(o);continue}const r=f.appendChild(document.createElement("th"));r.classList.add("NeeloongForm-table-line-handle");for(const t of n)switch(t){case"trigger":{const e=r.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-table-line-open"),p.push(e),e.addEventListener("click",h);continue}case"move":{if(!c?.editable)continue;const t=r.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-move"),t.addEventListener("pointerdown",m),d.push(F((()=>e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"remove":{if(!c?.editable)continue;const t=r.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-remove"),t.addEventListener("click",s),d.push(F((()=>!l.get()||e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"serial":r.appendChild(document.createElement("span")).classList.add("NeeloongForm-table-serial");continue}}return[u,()=>{for(const e of d)e()}]}function be(e,t,n,r,s){const o=e.appendChild(document.createElement("tr")),i=[];for(const e of t){if(!Array.isArray(e)){const{width:t,label:n}=e,r=o.appendChild(document.createElement("th"));t&&r.setAttribute("width",t),r.innerText=n;continue}const t=o.appendChild(document.createElement("th"));if(s)for(const s of e)if("add"!==s);else{const e=t.appendChild(document.createElement("button"));e.addEventListener("click",n),e.classList.add("NeeloongForm-table-add"),i.push(F((()=>!r.get()),(t=>{e.disabled=t}),!0))}}return()=>{for(const e of i)e()}}function ye(e){return function(t){return(!t.type||"field"===t.type)&&t.field===e}}function ve(e,t,n,r,s,o,i){const a=[];if(n instanceof Element){const l=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===l){const d=n.getAttribute("name")||"",h=n.getAttribute("mode")||"",p=d?e.child(d):e,m=d&&s?.fields?.find(ye(d))||null;if(!p)return()=>{};if("grid"===h){const[y,w]=Me(e,t,m,r);return n.replaceWith(y),w}const g=p.component;if(g){const x=t(p,g,r);if(x){const[E,A]=x;return n.replaceWith(E),A}}const b=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(b)),()=>{}}if("nl-form-button"===l){const L=document.createElement("button");L.className="NeeloongForm-item-button";const $=n.getAttribute("click")||"",C=r?.call;$&&"function"==typeof C&&L.addEventListener("click",(t=>C($,t,e,r)));for(const O of[...n.childNodes])L.appendChild(O);return n.replaceWith(L),()=>{}}const c=n.getAttribute("nl-form-field");if(c){const S=c.endsWith("[]"),j=S?c.slice(0,c.length-2):c,M=j?e.child(j):e;if(!M)return()=>{};n.removeAttribute("nl-form-field");const N=j?s?.fields?.find(ye(j)):s;if(!S)return ve(M,t,n,r,N,o);if(!(M instanceof v))return n.remove(),()=>{};const k=n.parentElement;if(!k)return n.remove(),()=>{};const T=k.insertBefore(document.createComment(""),n)||null;n.remove();let B=new Map;function U(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let P=-1;const q=e=>{if(P<0)return;const t=e?Number(e.index):M.children.length;t<0||P<0||P===t||M.move(P,t)&&(P=t)},_=F((()=>M.children),(e=>{let s=T.nextSibling;const o=B;B=new Map;for(const i of e){const e=o.get(i);if(e)o.delete(i),B.set(i,e),s!==e[0]?k.insertBefore(e[0],s):s=s.nextSibling;else{const e=k.insertBefore(n.cloneNode(!0),s),o=ve(i,t,e,r,N,e);e.addEventListener("dragenter",(()=>{q(i)})),e.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&(P=Number(i.index))})),e.addEventListener("dragend",(()=>{P=-1})),B.set(i,[e,o])}}U(o)}),!0);return()=>{T.remove(),U(B),_()}}if(null!==n.getAttribute("nl-form-remove")){const R=e.parent;R instanceof v&&n.addEventListener("click",(()=>{R.remove(Number(e.index))}))}null!==n.getAttribute("nl-form-move")&&o instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{o.draggable=!0;const t=n=>{n.pointerId===e&&(o.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))};window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}));const u=n.getAttribute("nl-form-add");if(u){const D=e.child(u);D instanceof v&&n.addEventListener("click",(()=>{D.add({})}))}const f=r?.call;for(const V of[...n.getAttributeNames()]){const H=V.indexOf(":");if(H<0)continue;const K=V.slice(0,H).toLowerCase(),z=V.slice(H+1);if("nl-form-field"===K){const Y=n.getAttribute(V),W=Y?e.child(Y):e;if(!W)continue;a.push(I((()=>{try{n.setAttribute(z,W.value)}catch{}})))}else if("nl-form-event"===K&&"function"==typeof f){const Q=n.getAttribute(V);if(!Q)continue;try{n.addEventListener(z,(t=>f(Q,t,e,r)))}catch{}}}}if(n instanceof Element||n instanceof DocumentFragment)for(const G of[...n.children])a.push(ve(e,t,G,r,s,o));return()=>{for(const e of a)e()}}function we(e){if(!e)return document.createElement("template").content;if("string"!=typeof e)return e.cloneNode(!0);const t=document.createElement("template");return t.innerHTML=e,t.content}function xe(e,t){return I((()=>{t?.error?e.classList.add("NeeloongForm-item-errored"):e.classList.remove("NeeloongForm-item-errored")}))}function Ee(e,t){return I((()=>{t?.required?e.classList.add("NeeloongForm-item-required"):e.classList.remove("NeeloongForm-item-required")}))}function Ae(e){const t=[],n=document.createElement("details");n.className="NeeloongForm-item",t.push(Ee(n,e)),n.open=!0;const r=n.appendChild(document.createElement("summary"));return t.push(I((()=>r.innerText=e?.label||""))),t.push(xe(n,e)),[n,()=>{for(const e of t)e()},n,t]}function Le(e,t){const{colStart:n,colSpan:r,colEnd:s,rowStart:o,rowSpan:i,rowEnd:a}=t||{};e.classList.add("NeeloongForm-item-grid"),n&&s?e.style.gridColumn=`${n} / ${s}`:n&&r?e.style.gridColumn=`${n} / span ${r}`:r&&(e.style.gridColumn=`span ${r}`),o&&a?e.style.gridRow=`${o} / ${a}`:o&&i?e.style.gridRow=`${o} / span ${i}`:i&&(e.style.gridRow=`span ${i}`)}function $e(e){const t=[],n=document.createElement("div");return n.className="NeeloongForm-item",t.push(Ee(n,e)),t.push(xe(n,e)),[n,()=>{for(const e of t)e()},n,t]}function Ce(e){const t=[],n=document.createElement("div");n.className="NeeloongForm-item",t.push(Ee(n,e));const r=n.appendChild(document.createElement("div"));r.className="NeeloongForm-item-label",t.push(I((()=>r.innerText=e?.label||"")));const s=n.appendChild(document.createElement("div"));s.className="NeeloongForm-item-content";const o=n.appendChild(document.createElement("div"));o.className="NeeloongForm-item-description",t.push(I((()=>o.innerText=e?.description||"")));const i=n.appendChild(document.createElement("div"));return i.className="NeeloongForm-item-error",t.push(I((()=>i.innerText=e?.error||""))),t.push(xe(n,e)),[n,()=>{for(const e of t)e()},s,t]}function Oe(e,t,n){switch(e.cell||n){default:case"block":return Ce(t);case"collapse":return Ae(t);case"inline":{const n=Ce(t);return Le(n[0],e),n}case"base":{const n=$e(t);return Le(n[0],e),n}}}function Se(t,n,r,s,o=!1){const{type:i,component:a}=t;if(o){const e=r?.inlineHtml;if(e){const o=we(e);return[o,ve(t,n,o,s,r)]}return a&&n(t,a,s)||[document.createElement("div"),()=>{}]}const l=i&&"object"==typeof i,c=r?.html;if(c){const[e,o,i,a]=Oe(r,t,l?"collapse":"base"),u=we(c);return a.push(ve(t,n,u,s,r)),i.appendChild(u),[e,o]}if(l){const[o,i,l,c]=Ae(t);if(c.push(I((()=>o.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,s);if(e){const[t,n]=e;l.appendChild(t),c.push(n)}}else if(t instanceof v){const[o,i]=function(t,n,r,s){const o=r?.columns,i=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let a=[];if(Array.isArray(o)){const e=new Map(i.map((e=>[e.field,e])));a=o.map((t=>{if("string"==typeof t)return e.get(t)||[];if(!Array.isArray(t))return[];const n=new Set(["add","move","trigger","remove","serial"]);return t.filter((e=>n.delete(e)))})).filter((e=>!Array.isArray(e)||e.length))}a.length||(a=[["add","trigger","move","remove","serial"]]),a.find((e=>!Array.isArray(e)))||a.push(...i.slice(0,3));const l=document.createElement("table");l.className="NeeloongForm-table";const c=l.appendChild(document.createElement("thead")),u=new e.Computed((()=>t.addable)),f={get:()=>Boolean(s?.editable)};function d(){t.add({})}function h(e){t.remove(Number(e.index))}let p=-1;function m(e){if(p<0)return;const n=e?Number(e.index):t.children.length;n<0||p<0||p===n||t.move(p,n)&&(p=n)}function g(e){p=Number(e.index)}function b(){p=-1}const y=[];switch(y.push(be(c,a,d,u,Boolean(s?.editable))),r?.tableFoot){default:case"header":{const e=l.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()})),y.push(be(e,a,d,u,Boolean(s?.editable)));break}case"add":{const e=l.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()}));const t=e.appendChild(document.createElement("tr")).appendChild(document.createElement("th"));t.colSpan=a.length;const n=t.appendChild(document.createElement("button"));n.addEventListener("click",d),n.classList.add("NeeloongForm-table-foot-add"),y.push(F((()=>!u.get()),(e=>{n.disabled=e}),!0));break}case"none":}const v=c;let w=new Map;function x(e){for(const[t,n]of e.values())n(),t.remove()}const E=a.map((e=>Array.isArray(e)?e:e.field)),A=F((()=>t.children),(function(e){let t=c.nextSibling;const o=w;w=new Map;for(let i of e){const e=o.get(i);if(e)o.delete(i),w.set(i,e),t!==e[0]?l.insertBefore(e[0],t):t=t.nextSibling;else{const[e,o]=ge(i,n,r,{columns:E,remove:h.bind(null,i),dragenter:m.bind(null,i),dragstart:g.bind(null,i),dragend:b,deletable:f},s);l.insertBefore(e,t),w.set(i,[e,o])}}x(o)}),!0);return[l,()=>{v.remove(),c.remove(),x(w),A();for(const e of y)e()}]}(t,n,r,s);l.appendChild(o),c.push(i)}else{const[e,o]=Me(t,n,r,s);l.appendChild(e),c.push(o)}return[o,i]}const[u,f,d,h]="base"===r?.cell?$e(t):Ce(t);if(Le(u,r),h.push(I((()=>u.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,s);if(e){const[t,n]=e;d.appendChild(t),h.push(n)}}return[u,f]}function je(e,t,n,r){if("button"===n.type)return function(e,t,n){const[r,s,o,i]=Oe(t,e),a=document.createElement("button");i.push((()=>{const r=t.text,s="function"==typeof r?r(e,n):r;a.innerText=s??""})),i.push((()=>{const r=t.disabled,s="function"==typeof r?r(e,n):r;a.disabled=Boolean(s)})),a.className="NeeloongForm-item-button",o.appendChild(a);const l=t.click;if("function"==typeof l)a.addEventListener("click",(t=>l(t,e,n)));else if(l&&"string"==typeof l){const t=n?.call;"function"==typeof t&&a.addEventListener("click",(r=>t(l,r,e,n)))}return[r,s]}(e,n,r);if("html"===n.type)return function(e,t,n,r){const[s,o,i,a]=Oe(n,e),l=n.html;if(!l)return[s,o];const c=we(l);return a.push(ve(e,t,c,r,n)),i.appendChild(c),[s,o]}(e,t,n,r);const s=e.child(n.field);return s?Se(s,t,n,r):null}function Me(e,t,n,r,s){const o=s instanceof HTMLElement?s:document.createElement("div");o.className="NeeloongForm";const i=[],a=n?.fields;if(a)for(const n of a){const s=je(e,t,n,r);if(!s)continue;const[a,l]=s;o.appendChild(a),i.push(l)}else{const n=[...e].map((([,e])=>e));for(const e of n){const[n,s]=Se(e,t,null,r);o.appendChild(n),i.push(s)}}return[o,()=>{for(const e of i)e()}]}function Ne(e,t,n,r,s){const o=r?.html;if(o){const i=we(o),a=ve(e,t,i,s||null,r);return n.appendChild(i),a}return Me(e,t,r||null,s||null,n)[1]}export{v as ArrayStore,_ as Layout,y as ObjectStore,b as Store,I as effect,me as render,Ne as renderStore,F as watch};