@neeloong/form 0.18.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.d.mts +3 -2
- package/index.full.js +59 -11
- package/index.full.min.js +3 -3
- package/index.full.min.mjs +5 -5
- package/index.min.mjs +2 -2
- package/index.mjs +59 -11
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.19.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -812,7 +812,8 @@ declare namespace StoreLayout {
|
|
|
812
812
|
required?: boolean | undefined;
|
|
813
813
|
label?: string | undefined;
|
|
814
814
|
description?: string | undefined;
|
|
815
|
-
|
|
815
|
+
disabled?: ((store: Store<any, any>, options?: StoreLayout.Options | null) => boolean) | undefined;
|
|
816
|
+
text?: string | ((store: Store<any, any>, options?: StoreLayout.Options | null) => string) | undefined;
|
|
816
817
|
click?: string | ((event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
817
818
|
};
|
|
818
819
|
type Html = {
|
package/index.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.19.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -5901,6 +5901,24 @@
|
|
|
5901
5901
|
return template.content;
|
|
5902
5902
|
}
|
|
5903
5903
|
|
|
5904
|
+
/** @import { CellValues } from './createCell.mjs' */
|
|
5905
|
+
|
|
5906
|
+
/**
|
|
5907
|
+
*
|
|
5908
|
+
* @param {HTMLElement} root
|
|
5909
|
+
* @param {CellValues} [values]
|
|
5910
|
+
* @returns {() => void}
|
|
5911
|
+
*/
|
|
5912
|
+
function bindErrored(root, values) {
|
|
5913
|
+
return effect(() => {
|
|
5914
|
+
if (values?.error) {
|
|
5915
|
+
root.classList.add('NeeloongForm-item-errored');
|
|
5916
|
+
} else {
|
|
5917
|
+
root.classList.remove('NeeloongForm-item-errored');
|
|
5918
|
+
}
|
|
5919
|
+
});
|
|
5920
|
+
}
|
|
5921
|
+
|
|
5904
5922
|
/**
|
|
5905
5923
|
*
|
|
5906
5924
|
* @param {HTMLElement} root
|
|
@@ -5917,9 +5935,11 @@
|
|
|
5917
5935
|
});
|
|
5918
5936
|
}
|
|
5919
5937
|
|
|
5938
|
+
/** @import { CellValues } from './createCell.mjs' */
|
|
5939
|
+
|
|
5920
5940
|
/**
|
|
5921
5941
|
*
|
|
5922
|
-
* @param {
|
|
5942
|
+
* @param {CellValues} [values]
|
|
5923
5943
|
* @returns {[HTMLElement, () => void, HTMLElement, (() => void)[]]}
|
|
5924
5944
|
*/
|
|
5925
5945
|
function createCollapseCell(values) {
|
|
@@ -5932,6 +5952,7 @@
|
|
|
5932
5952
|
root.open = true;
|
|
5933
5953
|
const summary = root.appendChild(document.createElement('summary'));
|
|
5934
5954
|
destroyList.push(effect(() => summary.innerText = values?.label || ''));
|
|
5955
|
+
destroyList.push(bindErrored(root, values));
|
|
5935
5956
|
|
|
5936
5957
|
return [root, () => {
|
|
5937
5958
|
for (const destroy of destroyList) {
|
|
@@ -5972,9 +5993,11 @@
|
|
|
5972
5993
|
|
|
5973
5994
|
}
|
|
5974
5995
|
|
|
5996
|
+
/** @import { CellValues } from './createCell.mjs' */
|
|
5997
|
+
|
|
5975
5998
|
/**
|
|
5976
5999
|
*
|
|
5977
|
-
* @param {
|
|
6000
|
+
* @param {CellValues} [values]
|
|
5978
6001
|
* @returns {[HTMLDivElement, () => void, HTMLDivElement, (() => void)[]]}
|
|
5979
6002
|
*/
|
|
5980
6003
|
function createNullCell(values) {
|
|
@@ -5983,6 +6006,7 @@
|
|
|
5983
6006
|
const root = document.createElement('div');
|
|
5984
6007
|
root.className = 'NeeloongForm-item';
|
|
5985
6008
|
destroyList.push(bindRequired(root, values));
|
|
6009
|
+
destroyList.push(bindErrored(root, values));
|
|
5986
6010
|
|
|
5987
6011
|
|
|
5988
6012
|
return [root, () => {
|
|
@@ -5994,12 +6018,14 @@
|
|
|
5994
6018
|
|
|
5995
6019
|
}
|
|
5996
6020
|
|
|
6021
|
+
/** @import { CellValues } from './createCell.mjs' */
|
|
6022
|
+
|
|
5997
6023
|
/**
|
|
5998
6024
|
*
|
|
5999
|
-
* @param {
|
|
6025
|
+
* @param {CellValues} [values]
|
|
6000
6026
|
* @returns {[HTMLDivElement, () => void, HTMLDivElement, (() => void)[]]}
|
|
6001
6027
|
*/
|
|
6002
|
-
function
|
|
6028
|
+
function createStdCell(values) {
|
|
6003
6029
|
/** @type {(() => void)[]} */
|
|
6004
6030
|
const destroyList = [];
|
|
6005
6031
|
const root = document.createElement('div');
|
|
@@ -6016,6 +6042,10 @@
|
|
|
6016
6042
|
const description = root.appendChild(document.createElement('div'));
|
|
6017
6043
|
description.className = 'NeeloongForm-item-description';
|
|
6018
6044
|
destroyList.push(effect(() => description.innerText = values?.description || ''));
|
|
6045
|
+
const error = root.appendChild(document.createElement('div'));
|
|
6046
|
+
error.className = 'NeeloongForm-item-error';
|
|
6047
|
+
destroyList.push(effect(() => error.innerText = values?.error || ''));
|
|
6048
|
+
destroyList.push(bindErrored(root, values));
|
|
6019
6049
|
|
|
6020
6050
|
return [root, () => {
|
|
6021
6051
|
for (const destroy of destroyList) {
|
|
@@ -6028,20 +6058,27 @@
|
|
|
6028
6058
|
|
|
6029
6059
|
/** @import { StoreLayout } from '../types.mjs' */
|
|
6030
6060
|
|
|
6061
|
+
/**
|
|
6062
|
+
* @typedef {object} CellValues
|
|
6063
|
+
* @property {string?} [label]
|
|
6064
|
+
* @property {string?} [description]
|
|
6065
|
+
* @property {string?} [error]
|
|
6066
|
+
* @property {boolean?} [required]
|
|
6067
|
+
*/
|
|
6031
6068
|
/**
|
|
6032
6069
|
*
|
|
6033
6070
|
* @param {StoreLayout.Item} layout
|
|
6034
|
-
* @param {
|
|
6071
|
+
* @param {CellValues} [values]
|
|
6035
6072
|
* @param {string?} [defCell]
|
|
6036
6073
|
* @returns {[HTMLElement, () => void, HTMLElement, (() => void)[]]}
|
|
6037
6074
|
*/
|
|
6038
6075
|
function createCell(layout, values, defCell) {
|
|
6039
6076
|
switch (layout.cell || defCell) {
|
|
6040
6077
|
default:
|
|
6041
|
-
case 'block': return
|
|
6078
|
+
case 'block': return createStdCell(values);
|
|
6042
6079
|
case 'collapse': return createCollapseCell(values);
|
|
6043
6080
|
case 'inline': {
|
|
6044
|
-
const result =
|
|
6081
|
+
const result = createStdCell(values);
|
|
6045
6082
|
bindGrid(result[0], layout);
|
|
6046
6083
|
return result;
|
|
6047
6084
|
}
|
|
@@ -6108,7 +6145,9 @@
|
|
|
6108
6145
|
}
|
|
6109
6146
|
|
|
6110
6147
|
|
|
6111
|
-
const [root, destroy, content, destroyList] =
|
|
6148
|
+
const [root, destroy, content, destroyList] = layout?.cell === 'base'
|
|
6149
|
+
? createNullCell(store)
|
|
6150
|
+
: createStdCell(store);
|
|
6112
6151
|
bindGrid(root, layout);
|
|
6113
6152
|
destroyList.push(effect(() => root.hidden = store.hidden));
|
|
6114
6153
|
if (typeof component === 'function') {
|
|
@@ -6133,9 +6172,18 @@
|
|
|
6133
6172
|
* @returns {[ParentNode, () => void]}
|
|
6134
6173
|
*/
|
|
6135
6174
|
function FormButton(store, layout, options) {
|
|
6136
|
-
const [root, destroy, content] = createCell(layout, store);
|
|
6175
|
+
const [root, destroy, content, destroyList] = createCell(layout, store);
|
|
6137
6176
|
const button = document.createElement('button');
|
|
6138
|
-
|
|
6177
|
+
destroyList.push(() => {
|
|
6178
|
+
const t = layout.text;
|
|
6179
|
+
const text = typeof t === 'function' ? t(store, options) : t;
|
|
6180
|
+
button.innerText = text ?? '';
|
|
6181
|
+
});
|
|
6182
|
+
destroyList.push(() => {
|
|
6183
|
+
const d = layout.disabled;
|
|
6184
|
+
const disabled = typeof d === 'function' ? d(store, options) : d;
|
|
6185
|
+
button.disabled = Boolean(disabled);
|
|
6186
|
+
});
|
|
6139
6187
|
button.className = 'NeeloongForm-item-button';
|
|
6140
6188
|
content.appendChild(button);
|
|
6141
6189
|
const click = layout.click;
|
package/index.full.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.19.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -33,7 +33,7 @@ function i(e,t){return Object.is(e,t)}
|
|
|
33
33
|
* Use of this source code is governed by an MIT-style license that can be
|
|
34
34
|
* found in the LICENSE file at https://angular.io/license
|
|
35
35
|
*/
|
|
36
|
-
function(){throw new Error};function
|
|
36
|
+
function(){throw new Error};function N(){return h(this),this.value}function $(e,t){!1===(null==a?void 0:a.consumerAllowSignalWrites)&&L(),e.equal.call(e.wrapper,e.value,t)||(e.value=t,function(e){e.version++,c++,m(e)}
|
|
37
37
|
/**
|
|
38
38
|
* @license
|
|
39
39
|
* Copyright 2024 Bloomberg Finance L.P.
|
|
@@ -57,4 +57,4 @@ function(){throw new Error};function $(){return h(this),this.value}function N(e,
|
|
|
57
57
|
* Use of this source code is governed by an MIT-style license that can be
|
|
58
58
|
* found in the LICENSE file at https://angular.io/license
|
|
59
59
|
*/
|
|
60
|
-
function(e){const t=Object.create(j);t.value=e;const n=()=>(h(t),t.value);return n[u]=t,n}(r),l=a[u];if(this[T]=l,l.wrapper=this,s){const t=s.equals;t&&(l.equal=t),l.watched=s[e.subtle.watched],l.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return $.call(this[T])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(l)throw new Error("Writes to signals not permitted during Watcher callback");N(this[T],t)}};c=T,p=new WeakSet,e.isComputed=e=>r(p,e),e.Computed=class{constructor(t,r){o(this,p),n(this,c);const s=function(e){const t=Object.create(A);t.computation=e;const n=()=>S(t);return n[u]=t,n}(t),i=s[u];if(i.consumerAllowSignalWrites=!0,this[T]=i,i.wrapper=this,r){const t=r.equals;t&&(i.equal=t),i.watched=r[e.subtle.watched],i.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return S(this[T])}},(t=>{var i,l,c,u;t.untrack=function(e){let t,n=null;try{n=d(null),t=e()}finally{d(n)}return t},t.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[T].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[T].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[T].liveConsumerNode;return!!n&&n.length>0},t.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[T].producerNode;return!!n&&n.length>0};i=T,l=new WeakSet,c=new WeakSet,u=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>r(l,e),t.Watcher=class{constructor(e){o(this,l),o(this,c),n(this,i);let t=Object.create(f);t.wrapper=this,t.consumerMarkedDirty=e,t.consumerIsAlwaysLive=!0,t.consumerAllowSignalWrites=!1,t.producerNode=[],this[T]=t}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,u).call(this,t);const n=this[T];n.dirty=!1;const r=d(n);for(const e of t)h(e[T]);d(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,u).call(this,t);const n=this[T];w(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){v(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];x(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[T].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},t.currentComputed=function(){var e;return null==(e=a)?void 0:e.wrapper},t.watched=Symbol("watched"),t.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(e.Signal||(e.Signal={}));const k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function B(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,o=Array.isArray(t)?t.map(B).filter(U):[];return o.length?{children:o,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const R=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(B).filter(U);return t.length?t:null};function q(t,n,r,o){const s=new e.Signal.State(n(r));let i;if("function"==typeof o){const r=o;i=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(o);i=new e.Signal.Computed((()=>t))}const a=new e.Signal.Computed((()=>{const e=s.get();return null===e?i.get():e}));return[s,a]}const _=Symbol();function D(e){const t={[_]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,_,{get:()=>e,configurable:!1,enumerable:!0}),t}let V=null,F=null,W=Object.create(null);function H(e,t){const n=e.type;let r=Y;if(!e.array||F&&t?.parent instanceof F)if("string"==typeof n){const e=W[n];e&&(r=e)}else n&&"object"==typeof n&&V&&(r=V);else F&&(r=F);return new r(e,t)}function K(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Signal.Computed((()=>[])),()=>{}];const o=new e.Signal.State([]);let s=null;return[function(){s?.abort(),s=new AbortController;const e=s.signal;return o.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 s=r.flat().map(K).filter(Boolean);return!n.aborted&&s.length&&o.set([...o.get(),...s]),s}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>o.get())),()=>{s?.abort(),o.set([])}]}class Y{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let o=!1;for(const e of[...r.get(n)||[]])o=!1===e(t,this)||o;return!o}listen(e,t){const n=t.bind(this),r=this.#e,o="number"==typeof e?String(e):e;let s=r.get(o);return s||(s=new Set,r.set(o,s)),s.add(n),()=>{s?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){W[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(t,{null:n,state:r,ref:o,default:s,setValue:i,setState:a,convert:l,onUpdate:c,onUpdateState:u,validator:d,validators:f,index:h,size:p,new:m,parent:g,hidden:b,clearable:v,required:y,disabled:w,readonly:x,removable:S,label:E,description:C,placeholder:O,min:A,max:L,step:$,minLength:N,maxLength:j,pattern:T,values:U}={}){this.schema=t,this.#r.set("object"==typeof r&&r||{});const B=g instanceof Y?g:null;var _,V;B&&(this.#o=B,this.#s=B.#s,this.#i=B.#i),this.#a=(_=this,"function"!=typeof(V=s??t.default)?()=>structuredClone(V):()=>structuredClone(V(_)));const F=new e.Signal.State(!1);this.#l=F,this.#i=F,this.#c=t.type,this.#u=t.meta,this.#d=t.component;const W=new e.Signal.State(Boolean(m));this.#f=W;const H=B?new e.Signal.Computed((()=>B.#h.get()||W.get())):new e.Signal.Computed((()=>W.get()));this.#h=H;const G=Boolean(t.immutable),Q=!1!==t.creatable;this.#p=G,this.#m=Q;const Z=t.readonly,X=new e.Signal.State("boolean"==typeof x?x:null);let J;if("function"==typeof Z)J=new e.Signal.Computed((()=>Boolean(Z(this))));else{const t=Boolean(Z);J=new e.Signal.Computed((()=>t))}const ee=()=>{if(H.get()?!Q:G)return!0;const e=X.get();return null===e?J.get():e},te=B?B.#g:null;this.#b=X,this.#g=te?new e.Signal.Computed((()=>te.get()||ee())):new e.Signal.Computed(ee),[this.#v,this.#y]=M(this,b,t.hidden,B?B.#y:null),[this.#w,this.#x]=M(this,v,t.clearable,B?B.#x:null),[this.#S,this.#E]=M(this,y,t.required,B?B.#E:null),[this.#C,this.#O]=M(this,w,t.disabled,B?B.#O:null),[this.#A,this.#L]=q(this,k,E,t.label),[this.#$,this.#N]=q(this,k,C,t.description),[this.#j,this.#T]=q(this,k,O,t.placeholder),[this.#M,this.#k]=q(this,I,A,t.min),[this.#I,this.#P]=q(this,I,L,t.max),[this.#U,this.#B]=q(this,I,$,t.step),[this.#R,this.#q]=q(this,I,N,t.minLength),[this.#_,this.#D]=q(this,I,j,t.maxLength),[this.#V,this.#F]=q(this,P,T,t.pattern),[this.#W,this.#H]=q(this,R,U,t.values),[this.#K,this.#z]=M(this,S,t.removable??!0);const ne=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Signal.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(K).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,d),[re,oe,se]=z(this,t.validators?.change,f?.change),[ie,ae,le]=z(this,t.validators?.blur,f?.blur);if(this.listen("change",(()=>{re()})),this.listen("blur",(()=>{ie()})),this.#Y=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(ne,oe,ae),this.#G=ne,this.#Q=re,this.#Z=ie,this.#X=se,this.#J=le,p instanceof e.Signal.State||p instanceof e.Signal.Computed?this.#ee=p:this.#ee=new e.Signal.State(p||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=o||null,this.#te=c||null,this.#ne=u||null,this.#re="function"==typeof i?i:null,this.#oe="function"==typeof a?a:null,this.#se="function"==typeof l?l:null,this.#ie.set(h??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#a;createDefault(){return this.#a()}#re=null;#oe=null;#se=null;#te=null;#ne=null;#o=null;#s=this;#c;#u;#d;#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.#o}get root(){return this.#s}get type(){return this.#c}get meta(){return this.#u}get component(){return this.#d}#ee;get size(){return this.#ee.get()}#ie=new e.Signal.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;#f;get selfNew(){return this.#f.get()}set selfNew(e){this.#f.set(Boolean(e))}get new(){return this.#h.get()}set new(e){this.#f.set(Boolean(e))}#v;#y;get selfHidden(){return this.#v.get()}set selfHidden(e){this.#v.set("boolean"==typeof e?e:null)}get hidden(){return this.#y.get()}set hidden(e){this.#v.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)}#S;#E;get selfRequired(){return this.#S.get()}set selfRequired(e){this.#S.set("boolean"==typeof e?e:null)}get required(){return this.#E.get()}set required(e){this.#S.set("boolean"==typeof e?e:null)}#C;#O;get selfDisabled(){return this.#C.get()}set selfDisabled(e){this.#C.set("boolean"==typeof e?e:null)}get disabled(){return this.#O.get()}set disabled(e){this.#C.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)}#K;#z;get selfRemovable(){return this.#K.get()}set selfRemovable(e){this.#K.set("boolean"==typeof e?e:null)}get removable(){return this.#z.get()}set removable(e){this.#K.set("boolean"==typeof e?e:null)}#A;#L;get selfLabel(){return this.#A.get()}set selfLabel(e){this.#A.set(k(e))}get label(){return this.#L.get()}set label(e){this.#A.set(k(e))}#$;#N;get selfDescription(){return this.#$.get()}set selfDescription(e){this.#$.set(k(e))}get description(){return this.#N.get()}set description(e){this.#$.set(k(e))}#j;#T;get selfPlaceholder(){return this.#j.get()}set selfPlaceholder(e){this.#j.set(k(e))}get placeholder(){return this.#T.get()}set placeholder(e){this.#j.set(k(e))}#M;#k;get selfMin(){return this.#M.get()}set selfMin(e){this.#M.set(I(e))}get min(){return this.#k.get()}set min(e){this.#M.set(I(e))}#I;#P;get selfMax(){return this.#I.get()}set selfMax(e){this.#I.set(I(e))}get max(){return this.#P.get()}set max(e){this.#I.set(I(e))}#U;#B;get selfStep(){return this.#U.get()}set selfStep(e){this.#U.set(I(e))}get step(){return this.#B.get()}set step(e){this.#U.set(I(e))}#R;#q;get selfMinLength(){return this.#R.get()}set selfMinLength(e){this.#R.set(I(e))}get minLength(){return this.#q.get()}set minLength(e){this.#R.set(I(e))}#_;#D;get selfMaxLength(){return this.#_.get()}set selfMaxLength(e){this.#_.set(I(e))}get maxLength(){return this.#D.get()}set maxLength(e){this.#_.set(I(e))}#V;#F;get selfPattern(){return this.#V.get()}set selfPattern(e){this.#V.set(P(e))}get pattern(){return this.#F.get()}set pattern(e){this.#V.set(P(e))}#W;#H;get selfValues(){return this.#W.get()}set selfValues(e){this.#W.set(R(e))}get values(){return this.#H.get()}set values(e){this.#W.set(R(e))}#Y;#G;#Q;#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.Signal.State(null);#ce=new e.Signal.State(this.#le.get());#r=new e.Signal.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.#oe?.(e),n=void 0===t?e:t;this.#r.set(n),this.#ne?.(n,this.#ie.get(),this),this.#ue()}#ue(){this.#de||(this.#de=!0,queueMicrotask((()=>{const e=this.#ce.get(),t=this.#r.get();this.#fe(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}#de=!1;#pe(e,t){const[n,r]=this.#se?.(e,t)||[e,t];return this.#ce.get()===n&&this.#r.get()===r?[n,r]:(this.#ce.set(n),this.#r.set(r),this.#fe(n,r))}#fe(e,t){this.#de=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},o=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},s=!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,s=!0),l!==u&&(o[n]=u,s=!0)}s&&(t=o,n=e=r,this.#ce.set(e),this.#r.set(o))}return this.#ae||(this.#ae=!0,this.#le.set(n)),[e,t]}validate(e){if(!0===e)return Promise.all([this.#G.get(),this.#Q(),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 G extends Y{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:o,onUpdateState:s}={}){const i=Object.entries(e.type),a=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:o,onUpdateState:s,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]=H(t,{...l,index:e});this.#me=a}}V=G;class Q extends Y{#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(t,{parent:n,onUpdate:r,onUpdateState:o,index:s,new:i,addable:a}={}){const l=new e.Signal.State([]),c=e=>{const t=Array.isArray(e)&&e.length||0,n=[...l.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#ge(e));n.length=t,r!==t&&l.set(n)};super(t,{index:s,new:i,parent:n,size:new e.Signal.Computed((()=>l.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 c(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{c(e),r?.(e,t,n)},onUpdateState:o,default:t.default??[]}),[this.#be,this.#ve]=M(this,a,t.addable??!0),this.#me=l;const u={parent:this,onUpdate:(e,t,n)=>{if(l.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(l.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#ge=(e,n)=>{const r=H(t,{...u,index:e,new:n});return r.index=e,r}}#be;#ve;get selfAddable(){return this.#be.get()}set selfAddable(e){this.#be.set("boolean"==typeof e?e:null)}get addable(){return this.#ve.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 o=[...this.#me.get()],s=Math.max(0,Math.min(Math.floor(e),o.length)),i=this.#ge(s,n);i.new=!0,o.splice(s,0,i);for(let t=e+1;t<o.length;t++)o[t].index=t;const a=[...r];a.splice(s,0,t??i.createDefault());const l=this.state;if(Array.isArray(l)){const e=[...l];e.splice(s,0,{}),this.state=e}return this.#me.set(o),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)),[o]=n.splice(r,1);if(!o)return;for(let t=e;t<n.length;t++)n[t].index=t;const s=[...t],[i]=s.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=s,i}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],[o]=r.splice(e,1);if(!o)return!1;r.splice(t,0,o);let s=Math.min(e,t),i=Math.max(e,t);for(let e=s;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()],o=r[e],s=r[t];if(!o||!s)return!1;r[t]=o,r[e]=s,o.index=t,s.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],o=n[t];n[t]=r,n[e]=o,this.state=n}return this.#me.set(r),this.value=i,!0}}function Z(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),o=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;o=!0;const n=X(t);r[e]={params:t.params,children:n?[n]:[]}}function s(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){s(n),n=[],t.push(r);continue}if(r.template){s(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(s(n),n=[]);continue}s(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const o=X(r);o&&t.push(o)}return s(n),o?[{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]:Z(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,o=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),o&&(t={type:"value",name:o,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){F=e}(Q);const J=/^([+-]?(\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 ee={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 te extends Error{constructor(e,...t){const n=ee[e];super("function"==typeof n?n(...t):n),this.code=e}}const ne=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,re=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,oe=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function se(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 ie(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 J.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?oe.test(n)?{name:n}:{calc:t(e)}:{value:r}}function ae(e,t,n,r,o){const{attrs:s,events:i,classes:a,styles:l,vars:c,params:u,enhancements:d}=e;return function(f,h){const p=f.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=(ne.exec(p)||re.exec(p))?.groups;if(!m)throw new te("ATTR",f);const{name:g,enhancement:b}=m,v=m.decorator?.toLowerCase();if(b){if(":"===v)se(d,b).attrs[g]=h?ie(h,t):{name:g};else if("@"===v)se(d,b).events[g]=h?oe.test(h)?{name:h}:{event:r(h)}:{name:g};else if("!"===v){if("bind"===g)se(d,b).bind=h||!0}else se(d,b).value=ie(h,t);return}if(!v)return void(s[g]={value:h});if(":"===v)return void(s[g]=h?ie(h,t):{name:g});if("."===v)return void(a[g]=h?ie(h,t):{name:g});if("style:"===v)return void(l[g]=ie(h,t));if("@"===v)return void(i[g]=h?oe.test(h)?{name:h}:{event:r(h)}:{name:g});if("+"===v)return void c.push({...h?ie(h,n):{value:void 0},variable:g,init:!0});if("*"===v)return void c.push({...ie(h,t),variable:g,init:!1});if("?"===v)return void(u[g]=ie(h,t));if("!"!==v)return;switch(g.toString()){case"fragment":e.fragment=h||!0;break;case"else":e.else=!0;break;case"enum":e.enum=h?ie(h,t):{value:!0};break;case"sort":e.sort=h?ie(h,t):{value:!0};break;case"if":e.if=ie(h,t);break;case"text":e.text=ie(h,t);break;case"html":o&&(e.html=ie(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 le(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 ce={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 ue=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function de(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function fe(e,t,n,r){let o=r[n];return null==o&&(o=e.lastIndexOf("</"+n+">"),o<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function he(...e){console.error(new te(...e))}function pe(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in ce?ce[t]:(he("ENTITY",e),e)}var me=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new te("CALC")},createInit:n=t,createEvent:r=()=>{throw new te("EVENT")},simpleTag:o=new Set,enableHTML:s=!1}={}){const i=[],a={children:i},l=[];let c=null,u=a;function d(){c=l.pop()||null,u=c||a}function f(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;f(e.substring(p,t).replace(/&#?\w+;/g,pe)),p=t}for(;;){const g=e.indexOf("<",p);if(g<0){const L=e.substring(p);L.match(/^\s*$/)||f(L);break}g>p&&m(g);const b=e.charAt(g+1);if("!"===b){let $=g+2,N=">";if("--"===e.slice(g+2,g+4)&&($+=4,N="--\x3e"),p=e.indexOf(N,$),p<0)break;p++;continue}if("/"===b){p=e.indexOf(">",g+3);let j=e.substring(g+2,p);if(p<0?(j=e.substring(g+2).replace(/[\s<].*/,""),he("UNCOMPLETED",j,c?.name),p=g+1+j.length):j.match(/\s</)&&(j=j.replace(/[\s<].*/,""),he("UNCOMPLETED",j),p=g+1+j.length),c){const T=c.name;if(T===j)d();else{if(T.toLowerCase()!=j.toLowerCase())throw new te("CLOSE",j,c.name);d()}}p++;continue}function v(t){let n=p+1;if(p=e.indexOf(t,n),p<0)throw new te("QUOTE",t);const r=e.slice(n,p).replace(/&#?\w+;/g,pe);return p++,r}function y(){let t=e.charAt(p);for(;t<=" "||""===t;t=e.charAt(++p));return t}function w(){let t=p,n=e.charAt(p);for(;de(n);)p++,n=e.charAt(p);return e.slice(t,p)}p=g+1;let x=e.charAt(p);switch(x){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case">":case"/":throw new te("SYMBOL",x);case"":throw new te("EOF")}const S=w(),E=ue.exec(S)?.groups;if(!E)throw new te("TAG",S);l.push(c),c=le(E.name,E.is),u.children.push(c),u=c;const C=ae(c,t,n,r,s);let O=!0,A=!1;e:for(;O;){let M=y();switch(M){case"":he("EOF"),p++;break e;case">":p++;break e;case"/":A=!0;break e;case'"':case"'":throw new te("ATTR_VALUE");case"=":throw new te("SYMBOL",M)}const k=w();if(!k){he("EOF"),p++;break e}switch(M=y(),M){case"":he("EOF"),p++;break e;case">":C(k,""),p++;break e;case"/":C(k,""),A=!0;break e;case"=":p++;break;case"'":case'"':C(k,v(M));continue;default:C(k,"");continue}switch(M=y(),M){case"":C(k,""),he("EOF"),p++;break e;case">":C(k,""),p++;break e;case"/":C(k,""),A=!0;break e;case"'":case'"':C(k,v(M));continue}C(k,w())}if(A){for(;;){p++;const I=e.charAt(p);if("/"!==I&&!(I<=" "||""===I))break}switch(e.charAt(p)){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case"":he("EOF");break;case">":p++;break;default:throw new te("CLOSE_SYMBOL")}d()}else(o.has(S)||fe(e,p,S,h))&&d()}return Z(i)}});function ge(t){let n=!0;const r=new e.Signal.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),o=new e.Signal.Computed(t);return r.watch(o),o.get(),()=>{r.unwatch(o)}}function be(e,t,n){let r,o=!1;return ge((()=>{const s=e();if(!o)return o=!0,r=s,void(n&&t(s));Object.is(s,r)||(r=s,t(s))}))}const ve=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*ye(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ve)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 Q?(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 we(e,t,n){for(const[n,r]of t){for(const[t,o]of ye(r,n))e[t]=o;for(const[t,o]of ye(r,n,"$$"))e[t]=o}}const xe={value$:{calc:e=>e?.[_].value},state$:{calc:e=>e?.[_].state}};var Se=Object.getOwnPropertyDescriptors(xe);function Ee(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function Ce(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 Oe{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ye[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.#ye[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.Signal.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return be((()=>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.#ye[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof Y?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ye[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ye[!0===e?"":e];if(!r?.get)return;const{store:o}=r;return o?ve.has(t)?be((()=>o[t]),n,!0):void 0:"value"===t?be((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ye[!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=>be(e,t,!0)}}return Object.fromEntries([...ve].map((e=>[`$${e}`,t=>be((()=>n[e]),t,!0)])))}getBindAll(e){const t=this.#ye[!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([...ve].map((e=>[`$${e}`,"value"===e||"state"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])))}bindSet(e,t){const n=this.#ye[!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.#ye[!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.#ye[e];if(!n)return null;const{exec:r,calc:o}=n;return"function"==typeof r?r:"function"==typeof o?o:null}constructor(e,t){if(this.store=e,t instanceof Oe){this.#we=t.#we;const e=this.#xe;for(const[n,r]of Object.entries(t.#xe))e[n]=r;const n=this.#Se;for(const[e,r]of Object.entries(t.#Se))n[e]=r}else we(this.#xe,e),this.#we=function(e){const t=Object.create(null,Se);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!Ee(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof Y){for(const[e,o]of ye(r,n))t[e]=o;continue}const{get:e,set:o,exec:s,calc:i}=r;"function"!=typeof e?"function"==typeof i||i&&"object"==typeof i?t[n]={calc:i}:("function"==typeof s||i&&"object"==typeof i)&&(t[n]={exec:s}):t[n]="function"==typeof o?{get:e,set:o}:{get:e}}return t}(t)}#we;#xe=Object.create(null);#Se=Object.create(null);store;#Ee=null;#o=null;#Ce=null;get#ye(){const e=this.#Ce;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#xe,...this.#we,...this.#Se})),n=this.store,r=this.#o,o=this.#Ee;for(const[e,r]of ye(n))t[e]=r;for(const[e,o]of function*(e,t,n="",r="$"){if(!(e instanceof Q))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]=o;if(o)for(const e of Object.keys(o))t[`$${e}`]={get:()=>o[e]};return this.#Ce=t,t}setStore(e,t,n){const r=new Oe(e,this);return t&&(r.#o=t),we(r.#xe,e),n&&(r.#Ee=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Oe(t,this);return we(n.#xe,t),n}params(t,n,r,o){let s=this.store;if(!0===o)s=r.store;else if(o){const e=r.#ye[o],t=e?.get&&e.store;t&&(s=t)}if(0===Object.keys(t).length)return this;const i=new Oe(s,this);i.#o=this.#o,i.#Ee=this.#Ee;const a=i.#Se,l=i.#ye;for(const[o,s]of Object.entries(t)){const t=o in n?n[o]:null;if(t){const{name:n,calc:s,value:i}=t;if(n){const e=r.#ye[n];if(!e?.get)continue;if(!e.store){a[o]=l[o]=e;continue}for(const[t,n]of ye(e.store,o))a[t]=l[t]=n;continue}if("function"==typeof s){const t=new e.Signal.Computed((()=>s(r.getters)));a[o]=l[o]={get:()=>t.get()};continue}a[o]=l[o]={get:()=>i}}else{const{name:t,calc:n,value:r}=s;if("function"==typeof n){const t=i.getters;i.#Oe=null;const r=new e.Signal.Computed((()=>n(t)));a[o]=l[o]={get:()=>r.get()};continue}if(t){const e=l[t];if(!e?.get)continue;if(!e.store){a[o]=l[o]=e;continue}for(const[t,n]of ye(e.store,o))a[t]=l[t]=n;continue}a[o]=l[o]={get:()=>r}}}return i}setObject(e){const t=new Oe(this.store,this);return t.#Ee=e,t}set(t){if(!t?.length)return this;const n=new Oe(this.store,this);n.#o=this.#o,n.#Ee=this.#Ee;const r=n.#Se,o=n.#ye;for(const{variable:s,name:i,calc:a,value:l,init:c}of t)if(c){const t=new e.Signal.State(l);if("function"==typeof a){const e=n.settable;n.#Ae=null,t.set(a(e))}else if(i){const e=o[i];if(!e?.get)continue;t.set(e.get())}r[s]=o[s]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof a)if(i){const e=o[i];if(!e)continue;if(!e.get||!e.store){r[s]=o[s]=e;continue}for(const[t,n]of ye(e.store,s))r[t]=o[t]=n}else r[s]=o[s]={get:()=>l};else{const t=n.getters;n.#Oe=null;const i=new e.Signal.Computed((()=>a(t)));r[s]=o[s]={get:()=>i.get()}}return n}#Le=null;get all(){const e=this.#Le;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Le=t,t}#Ae=null;get settable(){const e=this.#Ae;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Ae=t,t}#Oe=null;get getters(){const e=this.#Oe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Oe=t,t}}const Ae={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 Le(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 o=Array.isArray(t)?t[0]:t;return"number"==typeof o||"bigint"==typeof o?r=o&&e in Ae?`${o}${Ae[e]}`:`${o}`:"string"==typeof o&&(r=o),r?[r,n?"important":void 0]:null}class $e{#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,o="number"==typeof e?String(e):e;let s=r.get(o);return s||(s=new Set,r.set(o,s)),s.add(n),()=>{s?.delete(n)}}}const Ne={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 je(e,t,n){const r=[];if(t)for(let o=e.shift();o;o=e.shift()){const e=o.indexOf(":"),s=e>=0?o.slice(0,e):o,i=e>=0?o.slice(e+1).split(":"):[],a=s.replace(/^-+/,""),l=(s.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=Ne[c]),"function"==typeof c&&r.push([c,i,l])}return r}function Te(e,t,n){return r=>{const o=e.all;for(const[e,t,s]of n)if(e(r,t,o)===s)return;t(r,o)}}function Me(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 ke(e){return null===(e??null)?"":String(e)}function Ie(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 ke;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 Pe={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=ke(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=ke(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=ke(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Ue(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:o,props:s}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const i=Pe[t.toLowerCase()],a=i?.attrs||{},l=i?.events||{};for(const[e,t,o]of n)if("$"!==e[0])r.addEventListener(e,t,o);else{const n=l[e];if(n){const[e,s]=n;r.addEventListener(e,(e=>t(s(e,r))),o)}}if(s)for(const[t,n]of Object.entries(e.attrs))if(o(t,(e=>{if(s.has(t))r[t]=e;else{const n=Me(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),s.has(t))r[t]=n;else{const e=Me(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=Me(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),o(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=a[t];e&&(e(n,r),o(t,(t=>e(t,r))));continue}const e=Ie(r,t);if("function"==typeof e){r[t]=e(n),o(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,o(t,(e=>{r[t]=e}));continue}let s=Me(n);null!==s&&r.setAttribute(t,s),o(t,(e=>{const n=Me(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Be(e){return null===(e??null)?"":String(e)}function Re(e,t,n,r,o){if(!o){const o=e.insertBefore(document.createTextNode(""),t),s=n.watch(r,(e=>o.textContent=Be(e)));return()=>{o.remove(),s()}}const s=e.insertBefore(document.createComment(""),t),i=e.insertBefore(document.createComment(""),t),a=document.createElement("div");function l(){for(let e=s.nextSibling;e&&e!==i;e=s.nextSibling)e.remove()}const c=n.watch(r,(t=>{l(),function(t){a.innerHTML=t;for(let t=a.firstChild;t;t=s.firstChild)e.insertBefore(t,i)}(Be(t))}));return()=>{c(),l(),s.remove(),i.remove()}}function qe(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 _e=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function De(e,t,n,r,o){const s=e.children;if(!s.length)return()=>{};const i=t.insertBefore(document.createComment(""),n);let a=null,l=()=>{};const c=be((()=>s.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===a)return;a=e,l(),l=()=>{};const t=e?.[0];t&&(l=o(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),l(),l=()=>{},i.remove())}}function Ve(t,n,r,o,s,i,a,l,c){const u=t.bind,d=[...i,t.name],f=c?.(d);if(c&&!f)return()=>{};const{context:h,handler:p}=function(t,n,r,o){const s="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.Signal.State(!1);let u=!1;const d=new e.Signal.State(!1),f=Object.create(null),h=Object.create(null),p=new Set,m=[],g=new $e;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=f[e];if(!n)return()=>{};let r=n.get();const o=be((()=>n.get()),(n=>{const o=r;r=n,t(n,o,e)}),!0);return p.add(o),()=>{p.delete(o),o()}},relate(e){if(!r||!o||l)return()=>{};try{const t=o(r,e);return"function"!=typeof t?()=>{}:(p.add(t),()=>{p.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return d.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:s,set(t,n){if(i&&!(t in i))return;let r=f[t];if(r)return void r.set(n);const o=new e.Signal.State(n);f[t]=o,Object.defineProperty(h,t,{configurable:!0,enumerable:!0,get:o.get.bind(o)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...o]=e.split(".").filter(Boolean),s=a?a[r].filters:{};if(!s)return;const i={},l=je(o,s,i);m.push([r,Te(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,d.set(!0),g.emit("init",{events:m}))}}}}(f||t.name,o,o.getStore(u),l),m=f?.attrs,g=m?function(e,t,n,r,o){let s=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:o,calc:l,value:c}=n[i];if(!o&&!l){e.set(i,c);continue}a.immutable&&e.set(i,t.exec(r)),s.add(t.watch(r,(t=>e.set(i,t))));continue}const r=a.bind;if(!o||!r){e.set(i,a.default);continue}if("string"==typeof r){const n=t.bind(o,r,(t=>e.set(i,t)));n?s.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===o?"":o;s.add(t.watch({name:n},(t=>e.set(i,t)))),e.addEvent(l,((...e)=>{t.all[n]=c(...e)}));continue}const d=t.bind(o,"state",(t=>e.set(i,t)));if(!d)continue;s.add(d);const f=t.bindSet(o,"state");f&&e.addEvent(l,((...e)=>{f(c(...e))}))}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,o,t.attrs,m,u):function(e,t,n){const r=e.tag;let o=new Set;for(const[s,i]of Object.entries(n)){if("class"===s||"style"===s)continue;const{name:n,calc:a,value:l}=i;if(n||a)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==s.toLocaleLowerCase())o.add(t.watch(i,(t=>e.set(s,t))));else{const n=t.exec(i);e.set(s,n)}else e.set(s,l)}return()=>{const e=o;o=new Set;for(const t of e)t()}}(p,o,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=o.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[o,s]of Object.entries(t.bindAll(n)||{}))"function"==typeof s&&r.add(s((t=>e.set(o,t))));for(const[r,o]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>o(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,o,u),v=f?"function"==typeof f.tag?f.tag(h):Ue(h,f.tag,f.is):Ue(h,t.name,t.is),y=Array.isArray(v)?v[0]:v,w=Array.isArray(v)?v[1]:y;n.insertBefore(y,r);const x=w?He(t.children||[],w,null,o,s,i,a,l,c):()=>{},S=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let o=new Set;for(const[r,s]of Object.entries(n))s.value?e.classList.add(r):o.add(be((()=>Boolean(t.exec(s))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.classes,t.attrs.class),E=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 o=new Set;for(const[r,s]of Object.entries(n))o.add(be((()=>Le(r,t.exec(s))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.styles,t.attrs.style);p.mount();const C=function(t,n,r,o,s,i){let a=new Set;for(const[l,{attrs:c,value:u,events:d,bind:f}]of Object.entries(n)){if(!_e(o,l))continue;const h=o[l];if("function"!=typeof h)continue;let p=!1;const m=new e.Signal.State(!1),g=h?.events,b=[],v=Object.create(null),y=new Set,w=new $e;function x(e,t){if("function"!=typeof t)return;const[n,...o]=e.split(".").filter(Boolean),s=g?g[n].filters:{};if(!s)return;const i={},a=je(o,s,i);b.push([n,Te(r,t,a),i])}function S(){if(!p){p=!0,m.set(!0);for(const e of y)e();w.emit("destroy")}}a.add(S);for(const[C,O]of Object.entries(c)){const A=r.get(O);A&&Object.defineProperty(v,C,{...A,configurable:!0,enumerable:!0})}for(const[L,$]of Object.entries(d)){const N=r.getEvent($);N&&x(L,N)}if(f){for(const[j,T]of Object.entries(r.getBindAll(f)||{}))Object.defineProperty(v,j,{...T,configurable:!0,enumerable:!0});for(const[M,k]of Object.entries(r.bindEvents(f)||{}))x(M,(e=>k(e)))}const E={get value(){return null},events:b,attrs:v,watch(e,t){if(p)return()=>{};let n=v[e];const r=be((()=>v[e]),(r=>{const o=n;n=r,t(r,o,e)}),!0);return y.add(r),()=>{y.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:s,slot:i,tag:t};if(u){const I=r.get(u);I&&Object.defineProperty(E,"value",{...I,configurable:!0,enumerable:!0})}h(E)}return()=>{const e=a;a=new Set;for(const t of e)t()}}(p.tag,t.enhancements,o,a,y,w);return()=>{C(),p.destroy(),y.remove(),g(),x(),b(),S(),E()}}function Fe(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const o=Object.create(t);for(const[t,n]of r)o[t]=[n,e];return o}function We(t,n,r,o,s,i,a,l,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=o.set(t.vars),d=Fe(u,s,t.templates);if("divergent"===t.type)return De(t,n,r,u,((e,t,o)=>{const d=u.set(t),f=Fe(d,s,o);return He(e,n,r,d,f,i,a,l,c)}));if("value"===t.type){const e=u.child(t.name);return e?He(t.children,n,r,e,d,i,a,l,c):()=>{}}if("enum"===t.type){const o=u.enum(t.value),s=(e,r)=>He(t.children,n,e,r,d,i,a,l,c);return o instanceof Q?function(t,n,r,o,s){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.Signal.State(0),u=be((()=>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=s(l,o.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,o,u,s,t.sort):o instanceof G?function(e,t,n,r,o,s){const i=[],a=[...n],l=a.length,c=s?a.map((([e,t])=>[e,t,r.setStore(t,n).exec(s)])).sort((([,,e],[,,t])=>qe(e,t))).map((([e,t],n)=>[e,t,n])):a.map((([e,t],n)=>[e,t,n]));for(const[e,s,a]of c)i.push(o(t,r.setStore(s,n,{get count(){return l},get key(){return e},get index(){return a},get item(){return s.value}})));return()=>{for(const e of i)e()}}(0,r,o,u,s,t.sort):"function"==typeof o?function(t,n,r,o,s,i){const a=new e.Signal.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.Signal.Computed((()=>{const e=a.get();return e.map((([t,n],r)=>[n,t,o.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(i)])).sort((([,,e],[,,t])=>qe(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Signal.Computed((()=>a.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function d(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const f=new e.Signal.State(0),h=be((()=>l.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const i=u;u=[],f.set(n.length);for(const[a,l,c]of n){const n=i.findIndex((e=>e[3]===c)),[d]=n>=0?i.splice(n,1):[];if(!d){const n=t.insertBefore(document.createComment(""),r),i=t.insertBefore(document.createComment(""),r),d=new e.Signal.State(a),h=new e.Signal.State(l),p=s(i,o.setObject({get count(){return f.get()},get key(){return c},get item(){return d.get()},get index(){return h.get()}}));u.push([n,i,p,c,d,h]);continue}if(u.push(d),d[4].set(a),d[5].set(l),r===d[0]){r=d[1].nextSibling;continue}let h=d[0];for(;h&&h!==d[1];){const e=h;h=h.nextSibling,t.insertBefore(e,r)}t.insertBefore(d[1],r)}d(i)}),!0);return()=>{c.remove(),d(u),h()}}(n,r,o,u,s,t.sort):()=>{}}if("content"===t.type)return Re(n,r,u,t.value,t.html);if("template"===t.type){const e=d[t.template];if(!e)return()=>{};const[o,f]=e,h=f.params(o.params,t.attrs,u,t.bind),p=Fe(h,s,o.templates);return He(o.children,n,r,h,p,i,a,l,c)}return"fragment"===t.type?He(t.children,n,r,u,d,i,a,l,c):Ve(t,n,r,u,d,i,a,l,c)}function He(e,t,n,r,o,s,i,a,l){const c=e.map((e=>We(e,t,n,r,o,s,i,a,l)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function Ke(e,t,n,{columns:r,remove:o,dragenter:s,dragstart:i,dragend:a,deletable:l},c){const u=document.createElement("tbody");u.addEventListener("dragenter",(()=>{s()})),u.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&i()})),u.addEventListener("dragend",a);const d=u.appendChild(document.createElement("tr")),f=[];let h=()=>{};const p=[];if(r.find((e=>Array.isArray(e)&&e.includes("trigger")))){const o=u.appendChild(document.createElement("tr")),s=o.appendChild(document.createElement("td"));s.colSpan=r.length;const[i,a]=st(e,t,n,c);s.appendChild(i),f.push(a),o.hidden=!0,h=function(){if(o.hidden){o.hidden=!1;for(const e of p)e.classList.remove("NeeloongForm-table-line-open"),e.classList.add("NeeloongForm-table-line-close")}else{o.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=d.appendChild(document.createElement("td")),o=e.child(n);if(!o)continue;const[s,i]=rt(o,t,null,c,!0);f.push(i),r.appendChild(s);continue}const r=d.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),f.push(be((()=>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",o),f.push(be((()=>!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 f)e()}]}function ze(e,t,n,r,o){const s=e.appendChild(document.createElement("tr")),i=[];for(const e of t){if(!Array.isArray(e)){const{width:t,label:n}=e,r=s.appendChild(document.createElement("th"));t&&r.setAttribute("width",t),r.innerText=n;continue}const t=s.appendChild(document.createElement("th"));if(o)for(const o of e)if("add"!==o);else{const e=t.appendChild(document.createElement("button"));e.addEventListener("click",n),e.classList.add("NeeloongForm-table-add"),i.push(be((()=>!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 Ge(e,t,n,r,o,s,i){const a=[];if(n instanceof Element){const l=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===l){const f=n.getAttribute("name")||"",h=n.getAttribute("mode")||"",p=f?e.child(f):e,m=f&&o?.fields?.find(Ye(f))||null;if(!p)return()=>{};if("grid"===h){const[v,y]=st(e,t,m,r);return n.replaceWith(v),y}const g=p.component;if(g){const w=t(p,g,r);if(w){const[x,S]=w;return n.replaceWith(x),S}}const b=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(b)),()=>{}}if("nl-form-button"===l){const E=document.createElement("button");E.className="NeeloongForm-item-button";const C=n.getAttribute("click")||"",O=r?.call;C&&"function"==typeof O&&E.addEventListener("click",(t=>O(C,t,e,r)));for(const A of[...n.childNodes])E.appendChild(A);return n.replaceWith(E),()=>{}}const c=n.getAttribute("nl-form-field");if(c){const L=c.endsWith("[]"),$=L?c.slice(0,c.length-2):c,N=$?e.child($):e;if(!N)return()=>{};n.removeAttribute("nl-form-field");const j=$?o?.fields?.find(Ye($)):o;if(!L)return Ge(N,t,n,r,j,s);if(!(N instanceof Q))return n.remove(),()=>{};const T=n.parentElement;if(!T)return n.remove(),()=>{};const M=T.insertBefore(document.createComment(""),n)||null;n.remove();let k=new Map;function I(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let P=-1;const U=e=>{if(P<0)return;const t=e?Number(e.index):N.children.length;t<0||P<0||P===t||N.move(P,t)&&(P=t)},B=be((()=>N.children),(e=>{let o=M.nextSibling;const s=k;k=new Map;for(const i of e){const e=s.get(i);if(e)s.delete(i),k.set(i,e),o!==e[0]?T.insertBefore(e[0],o):o=o.nextSibling;else{const e=T.insertBefore(n.cloneNode(!0),o),s=Ge(i,t,e,r,j,e);e.addEventListener("dragenter",(()=>{U(i)})),e.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&(P=Number(i.index))})),e.addEventListener("dragend",(()=>{P=-1})),k.set(i,[e,s])}}I(s)}),!0);return()=>{M.remove(),I(k),B()}}if(null!==n.getAttribute("nl-form-remove")){const R=e.parent;R instanceof Q&&n.addEventListener("click",(()=>{R.remove(Number(e.index))}))}null!==n.getAttribute("nl-form-move")&&s instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{s.draggable=!0;const t=n=>{n.pointerId===e&&(s.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 q=e.child(u);q instanceof Q&&n.addEventListener("click",(()=>{q.add({})}))}const d=r?.call;for(const _ of[...n.getAttributeNames()]){const D=_.indexOf(":");if(D<0)continue;const V=_.slice(0,D).toLowerCase(),F=_.slice(D+1);if("nl-form-field"===V){const W=n.getAttribute(_),H=W?e.child(W):e;if(!H)continue;a.push(ge((()=>{try{n.setAttribute(F,H.value)}catch{}})))}else if("nl-form-event"===V&&"function"==typeof d){const K=n.getAttribute(_);if(!K)continue;try{n.addEventListener(F,(t=>d(K,t,e,r)))}catch{}}}}if(n instanceof Element||n instanceof DocumentFragment)for(const z of[...n.children])a.push(Ge(e,t,z,r,o,s));return()=>{for(const e of a)e()}}function Qe(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 Ze(e,t){return ge((()=>{t?.required?e.classList.add("NeeloongForm-item-required"):e.classList.remove("NeeloongForm-item-required")}))}function Xe(e){const t=[],n=document.createElement("details");n.className="NeeloongForm-item",t.push(Ze(n,e)),n.open=!0;const r=n.appendChild(document.createElement("summary"));return t.push(ge((()=>r.innerText=e?.label||""))),[n,()=>{for(const e of t)e()},n,t]}function Je(e,t){const{colStart:n,colSpan:r,colEnd:o,rowStart:s,rowSpan:i,rowEnd:a}=t||{};e.classList.add("NeeloongForm-item-grid"),n&&o?e.style.gridColumn=`${n} / ${o}`:n&&r?e.style.gridColumn=`${n} / span ${r}`:r&&(e.style.gridColumn=`span ${r}`),s&&a?e.style.gridRow=`${s} / ${a}`:s&&i?e.style.gridRow=`${s} / span ${i}`:i&&(e.style.gridRow=`span ${i}`)}function et(e){const t=[],n=document.createElement("div");return n.className="NeeloongForm-item",t.push(Ze(n,e)),[n,()=>{for(const e of t)e()},n,t]}function tt(e){const t=[],n=document.createElement("div");n.className="NeeloongForm-item",t.push(Ze(n,e));const r=n.appendChild(document.createElement("div"));r.className="NeeloongForm-item-label",t.push(ge((()=>r.innerText=e?.label||"")));const o=n.appendChild(document.createElement("div"));o.className="NeeloongForm-item-content";const s=n.appendChild(document.createElement("div"));return s.className="NeeloongForm-item-description",t.push(ge((()=>s.innerText=e?.description||""))),[n,()=>{for(const e of t)e()},o,t]}function nt(e,t,n){switch(e.cell||n){default:case"block":return tt(t);case"collapse":return Xe(t);case"inline":{const n=tt(t);return Je(n[0],e),n}case"base":{const n=et(t);return Je(n[0],e),n}}}function rt(t,n,r,o,s=!1){const{type:i,component:a}=t;if(s){const e=r?.inlineHtml;if(e){const s=Qe(e);return[s,Ge(t,n,s,o,r)]}return a&&n(t,a,o)||[document.createElement("div"),()=>{}]}const l=i&&"object"==typeof i,c=r?.html;if(c){const[e,s,i,a]=nt(r,t,l?"collapse":"base"),u=Qe(c);return a.push(Ge(t,n,u,o,r)),i.appendChild(u),[e,s]}if(l){const[s,i,l,c]=Xe(t);if(c.push(ge((()=>s.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,o);if(e){const[t,n]=e;l.appendChild(t),c.push(n)}}else if(t instanceof Q){const[s,i]=function(t,n,r,o){const s=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(s)){const e=new Map(i.map((e=>[e.field,e])));a=s.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.Signal.Computed((()=>t.addable)),d={get:()=>Boolean(o?.editable)};function f(){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 v=[];switch(v.push(ze(c,a,f,u,Boolean(o?.editable))),r?.tableFoot){default:case"header":{const e=l.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()})),v.push(ze(e,a,f,u,Boolean(o?.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",f),n.classList.add("NeeloongForm-table-foot-add"),v.push(be((()=>!u.get()),(e=>{n.disabled=e}),!0));break}case"none":}const y=c;let w=new Map;function x(e){for(const[t,n]of e.values())n(),t.remove()}const S=a.map((e=>Array.isArray(e)?e:e.field)),E=be((()=>t.children),(function(e){let t=c.nextSibling;const s=w;w=new Map;for(let i of e){const e=s.get(i);if(e)s.delete(i),w.set(i,e),t!==e[0]?l.insertBefore(e[0],t):t=t.nextSibling;else{const[e,s]=Ke(i,n,r,{columns:S,remove:h.bind(null,i),dragenter:m.bind(null,i),dragstart:g.bind(null,i),dragend:b,deletable:d},o);l.insertBefore(e,t),w.set(i,[e,s])}}x(s)}),!0);return[l,()=>{y.remove(),c.remove(),x(w),E();for(const e of v)e()}]}(t,n,r,o);l.appendChild(s),c.push(i)}else{const[e,s]=st(t,n,r,o);l.appendChild(e),c.push(s)}return[s,i]}const[u,d,f,h]=et(t);if(Je(u,r),h.push(ge((()=>u.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,o);if(e){const[t,n]=e;f.appendChild(t),h.push(n)}}return[u,d]}function ot(e,t,n,r){if("button"===n.type)return function(e,t,n){const[r,o,s]=nt(t,e),i=document.createElement("button");i.innerText=t.text||"",i.className="NeeloongForm-item-button",s.appendChild(i);const a=t.click;if("function"==typeof a)i.addEventListener("click",(t=>a(t,e,n)));else if(a&&"string"==typeof a){const t=n?.call;"function"==typeof t&&i.addEventListener("click",(r=>t(a,r,e,n)))}return[r,o]}(e,n,r);if("html"===n.type)return function(e,t,n,r){const[o,s,i,a]=nt(n,e),l=n.html;if(!l)return[o,s];const c=Qe(l);return a.push(Ge(e,t,c,r,n)),i.appendChild(c),[o,s]}(e,t,n,r);const o=e.child(n.field);return o?rt(o,t,n,r):null}function st(e,t,n,r,o){const s=o instanceof HTMLElement?o:document.createElement("div");s.className="NeeloongForm";const i=[],a=n?.fields;if(a)for(const n of a){const o=ot(e,t,n,r);if(!o)continue;const[a,l]=o;s.appendChild(a),i.push(l)}else{const n=[...e].map((([,e])=>e));for(const e of n){const[n,o]=rt(e,t,null,r);s.appendChild(n),i.push(o)}}return[s,()=>{for(const e of i)e()}]}e.ArrayStore=Q,e.Layout=me,e.ObjectStore=G,e.Store=Y,e.effect=ge,e.render=function(e,t,n,{component:r,global:o,relate:s,enhancements:i}={}){return He(t,n,null,new Oe(e,o),Object.create(null),[],i||{},"function"==typeof s?s:null,r)},e.renderStore=function(e,t,n,r,o){const s=r?.html;if(s){const i=Qe(s),a=Ge(e,t,i,o||null,r);return n.appendChild(i),a}return st(e,t,r||null,o||null,n)[1]},e.watch=be}));
|
|
60
|
+
function(e){const t=Object.create(j);t.value=e;const n=()=>(h(t),t.value);return n[u]=t,n}(r),l=a[u];if(this[T]=l,l.wrapper=this,s){const t=s.equals;t&&(l.equal=t),l.watched=s[e.subtle.watched],l.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return N.call(this[T])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(l)throw new Error("Writes to signals not permitted during Watcher callback");$(this[T],t)}};c=T,p=new WeakSet,e.isComputed=e=>r(p,e),e.Computed=class{constructor(t,r){o(this,p),n(this,c);const s=function(e){const t=Object.create(A);t.computation=e;const n=()=>S(t);return n[u]=t,n}(t),i=s[u];if(i.consumerAllowSignalWrites=!0,this[T]=i,i.wrapper=this,r){const t=r.equals;t&&(i.equal=t),i.watched=r[e.subtle.watched],i.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return S(this[T])}},(t=>{var i,l,c,u;t.untrack=function(e){let t,n=null;try{n=d(null),t=e()}finally{d(n)}return t},t.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[T].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[T].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[T].liveConsumerNode;return!!n&&n.length>0},t.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[T].producerNode;return!!n&&n.length>0};i=T,l=new WeakSet,c=new WeakSet,u=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>r(l,e),t.Watcher=class{constructor(e){o(this,l),o(this,c),n(this,i);let t=Object.create(f);t.wrapper=this,t.consumerMarkedDirty=e,t.consumerIsAlwaysLive=!0,t.consumerAllowSignalWrites=!1,t.producerNode=[],this[T]=t}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,u).call(this,t);const n=this[T];n.dirty=!1;const r=d(n);for(const e of t)h(e[T]);d(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,u).call(this,t);const n=this[T];w(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){v(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];x(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[T].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},t.currentComputed=function(){var e;return null==(e=a)?void 0:e.wrapper},t.watched=Symbol("watched"),t.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(e.Signal||(e.Signal={}));const k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function B(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,o=Array.isArray(t)?t.map(B).filter(U):[];return o.length?{children:o,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const R=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(B).filter(U);return t.length?t:null};function q(t,n,r,o){const s=new e.Signal.State(n(r));let i;if("function"==typeof o){const r=o;i=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(o);i=new e.Signal.Computed((()=>t))}const a=new e.Signal.Computed((()=>{const e=s.get();return null===e?i.get():e}));return[s,a]}const _=Symbol();function D(e){const t={[_]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,_,{get:()=>e,configurable:!1,enumerable:!0}),t}let F=null,V=null,W=Object.create(null);function H(e,t){const n=e.type;let r=Y;if(!e.array||V&&t?.parent instanceof V)if("string"==typeof n){const e=W[n];e&&(r=e)}else n&&"object"==typeof n&&F&&(r=F);else V&&(r=V);return new r(e,t)}function K(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Signal.Computed((()=>[])),()=>{}];const o=new e.Signal.State([]);let s=null;return[function(){s?.abort(),s=new AbortController;const e=s.signal;return o.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 s=r.flat().map(K).filter(Boolean);return!n.aborted&&s.length&&o.set([...o.get(),...s]),s}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>o.get())),()=>{s?.abort(),o.set([])}]}class Y{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let o=!1;for(const e of[...r.get(n)||[]])o=!1===e(t,this)||o;return!o}listen(e,t){const n=t.bind(this),r=this.#e,o="number"==typeof e?String(e):e;let s=r.get(o);return s||(s=new Set,r.set(o,s)),s.add(n),()=>{s?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){W[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(t,{null:n,state:r,ref:o,default:s,setValue:i,setState:a,convert:l,onUpdate:c,onUpdateState:u,validator:d,validators:f,index:h,size:p,new:m,parent:g,hidden:b,clearable:v,required:y,disabled:w,readonly:x,removable:S,label:E,description:C,placeholder:O,min:A,max:L,step:N,minLength:$,maxLength:j,pattern:T,values:U}={}){this.schema=t,this.#r.set("object"==typeof r&&r||{});const B=g instanceof Y?g:null;var _,F;B&&(this.#o=B,this.#s=B.#s,this.#i=B.#i),this.#a=(_=this,"function"!=typeof(F=s??t.default)?()=>structuredClone(F):()=>structuredClone(F(_)));const V=new e.Signal.State(!1);this.#l=V,this.#i=V,this.#c=t.type,this.#u=t.meta,this.#d=t.component;const W=new e.Signal.State(Boolean(m));this.#f=W;const H=B?new e.Signal.Computed((()=>B.#h.get()||W.get())):new e.Signal.Computed((()=>W.get()));this.#h=H;const G=Boolean(t.immutable),Q=!1!==t.creatable;this.#p=G,this.#m=Q;const Z=t.readonly,X=new e.Signal.State("boolean"==typeof x?x:null);let J;if("function"==typeof Z)J=new e.Signal.Computed((()=>Boolean(Z(this))));else{const t=Boolean(Z);J=new e.Signal.Computed((()=>t))}const ee=()=>{if(H.get()?!Q:G)return!0;const e=X.get();return null===e?J.get():e},te=B?B.#g:null;this.#b=X,this.#g=te?new e.Signal.Computed((()=>te.get()||ee())):new e.Signal.Computed(ee),[this.#v,this.#y]=M(this,b,t.hidden,B?B.#y:null),[this.#w,this.#x]=M(this,v,t.clearable,B?B.#x:null),[this.#S,this.#E]=M(this,y,t.required,B?B.#E:null),[this.#C,this.#O]=M(this,w,t.disabled,B?B.#O:null),[this.#A,this.#L]=q(this,k,E,t.label),[this.#N,this.#$]=q(this,k,C,t.description),[this.#j,this.#T]=q(this,k,O,t.placeholder),[this.#M,this.#k]=q(this,I,A,t.min),[this.#I,this.#P]=q(this,I,L,t.max),[this.#U,this.#B]=q(this,I,N,t.step),[this.#R,this.#q]=q(this,I,$,t.minLength),[this.#_,this.#D]=q(this,I,j,t.maxLength),[this.#F,this.#V]=q(this,P,T,t.pattern),[this.#W,this.#H]=q(this,R,U,t.values),[this.#K,this.#z]=M(this,S,t.removable??!0);const ne=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Signal.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(K).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,d),[re,oe,se]=z(this,t.validators?.change,f?.change),[ie,ae,le]=z(this,t.validators?.blur,f?.blur);if(this.listen("change",(()=>{re()})),this.listen("blur",(()=>{ie()})),this.#Y=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(ne,oe,ae),this.#G=ne,this.#Q=re,this.#Z=ie,this.#X=se,this.#J=le,p instanceof e.Signal.State||p instanceof e.Signal.Computed?this.#ee=p:this.#ee=new e.Signal.State(p||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=o||null,this.#te=c||null,this.#ne=u||null,this.#re="function"==typeof i?i:null,this.#oe="function"==typeof a?a:null,this.#se="function"==typeof l?l:null,this.#ie.set(h??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#a;createDefault(){return this.#a()}#re=null;#oe=null;#se=null;#te=null;#ne=null;#o=null;#s=this;#c;#u;#d;#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.#o}get root(){return this.#s}get type(){return this.#c}get meta(){return this.#u}get component(){return this.#d}#ee;get size(){return this.#ee.get()}#ie=new e.Signal.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;#f;get selfNew(){return this.#f.get()}set selfNew(e){this.#f.set(Boolean(e))}get new(){return this.#h.get()}set new(e){this.#f.set(Boolean(e))}#v;#y;get selfHidden(){return this.#v.get()}set selfHidden(e){this.#v.set("boolean"==typeof e?e:null)}get hidden(){return this.#y.get()}set hidden(e){this.#v.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)}#S;#E;get selfRequired(){return this.#S.get()}set selfRequired(e){this.#S.set("boolean"==typeof e?e:null)}get required(){return this.#E.get()}set required(e){this.#S.set("boolean"==typeof e?e:null)}#C;#O;get selfDisabled(){return this.#C.get()}set selfDisabled(e){this.#C.set("boolean"==typeof e?e:null)}get disabled(){return this.#O.get()}set disabled(e){this.#C.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)}#K;#z;get selfRemovable(){return this.#K.get()}set selfRemovable(e){this.#K.set("boolean"==typeof e?e:null)}get removable(){return this.#z.get()}set removable(e){this.#K.set("boolean"==typeof e?e:null)}#A;#L;get selfLabel(){return this.#A.get()}set selfLabel(e){this.#A.set(k(e))}get label(){return this.#L.get()}set label(e){this.#A.set(k(e))}#N;#$;get selfDescription(){return this.#N.get()}set selfDescription(e){this.#N.set(k(e))}get description(){return this.#$.get()}set description(e){this.#N.set(k(e))}#j;#T;get selfPlaceholder(){return this.#j.get()}set selfPlaceholder(e){this.#j.set(k(e))}get placeholder(){return this.#T.get()}set placeholder(e){this.#j.set(k(e))}#M;#k;get selfMin(){return this.#M.get()}set selfMin(e){this.#M.set(I(e))}get min(){return this.#k.get()}set min(e){this.#M.set(I(e))}#I;#P;get selfMax(){return this.#I.get()}set selfMax(e){this.#I.set(I(e))}get max(){return this.#P.get()}set max(e){this.#I.set(I(e))}#U;#B;get selfStep(){return this.#U.get()}set selfStep(e){this.#U.set(I(e))}get step(){return this.#B.get()}set step(e){this.#U.set(I(e))}#R;#q;get selfMinLength(){return this.#R.get()}set selfMinLength(e){this.#R.set(I(e))}get minLength(){return this.#q.get()}set minLength(e){this.#R.set(I(e))}#_;#D;get selfMaxLength(){return this.#_.get()}set selfMaxLength(e){this.#_.set(I(e))}get maxLength(){return this.#D.get()}set maxLength(e){this.#_.set(I(e))}#F;#V;get selfPattern(){return this.#F.get()}set selfPattern(e){this.#F.set(P(e))}get pattern(){return this.#V.get()}set pattern(e){this.#F.set(P(e))}#W;#H;get selfValues(){return this.#W.get()}set selfValues(e){this.#W.set(R(e))}get values(){return this.#H.get()}set values(e){this.#W.set(R(e))}#Y;#G;#Q;#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.Signal.State(null);#ce=new e.Signal.State(this.#le.get());#r=new e.Signal.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.#oe?.(e),n=void 0===t?e:t;this.#r.set(n),this.#ne?.(n,this.#ie.get(),this),this.#ue()}#ue(){this.#de||(this.#de=!0,queueMicrotask((()=>{const e=this.#ce.get(),t=this.#r.get();this.#fe(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}#de=!1;#pe(e,t){const[n,r]=this.#se?.(e,t)||[e,t];return this.#ce.get()===n&&this.#r.get()===r?[n,r]:(this.#ce.set(n),this.#r.set(r),this.#fe(n,r))}#fe(e,t){this.#de=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},o=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},s=!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,s=!0),l!==u&&(o[n]=u,s=!0)}s&&(t=o,n=e=r,this.#ce.set(e),this.#r.set(o))}return this.#ae||(this.#ae=!0,this.#le.set(n)),[e,t]}validate(e){if(!0===e)return Promise.all([this.#G.get(),this.#Q(),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 G extends Y{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:o,onUpdateState:s}={}){const i=Object.entries(e.type),a=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:o,onUpdateState:s,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]=H(t,{...l,index:e});this.#me=a}}F=G;class Q extends Y{#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(t,{parent:n,onUpdate:r,onUpdateState:o,index:s,new:i,addable:a}={}){const l=new e.Signal.State([]),c=e=>{const t=Array.isArray(e)&&e.length||0,n=[...l.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#ge(e));n.length=t,r!==t&&l.set(n)};super(t,{index:s,new:i,parent:n,size:new e.Signal.Computed((()=>l.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 c(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{c(e),r?.(e,t,n)},onUpdateState:o,default:t.default??[]}),[this.#be,this.#ve]=M(this,a,t.addable??!0),this.#me=l;const u={parent:this,onUpdate:(e,t,n)=>{if(l.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(l.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#ge=(e,n)=>{const r=H(t,{...u,index:e,new:n});return r.index=e,r}}#be;#ve;get selfAddable(){return this.#be.get()}set selfAddable(e){this.#be.set("boolean"==typeof e?e:null)}get addable(){return this.#ve.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 o=[...this.#me.get()],s=Math.max(0,Math.min(Math.floor(e),o.length)),i=this.#ge(s,n);i.new=!0,o.splice(s,0,i);for(let t=e+1;t<o.length;t++)o[t].index=t;const a=[...r];a.splice(s,0,t??i.createDefault());const l=this.state;if(Array.isArray(l)){const e=[...l];e.splice(s,0,{}),this.state=e}return this.#me.set(o),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)),[o]=n.splice(r,1);if(!o)return;for(let t=e;t<n.length;t++)n[t].index=t;const s=[...t],[i]=s.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=s,i}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#me.get()],[o]=r.splice(e,1);if(!o)return!1;r.splice(t,0,o);let s=Math.min(e,t),i=Math.max(e,t);for(let e=s;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()],o=r[e],s=r[t];if(!o||!s)return!1;r[t]=o,r[e]=s,o.index=t,s.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],o=n[t];n[t]=r,n[e]=o,this.state=n}return this.#me.set(r),this.value=i,!0}}function Z(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),o=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;o=!0;const n=X(t);r[e]={params:t.params,children:n?[n]:[]}}function s(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){s(n),n=[],t.push(r);continue}if(r.template){s(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(s(n),n=[]);continue}s(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const o=X(r);o&&t.push(o)}return s(n),o?[{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]:Z(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,o=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),o&&(t={type:"value",name:o,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){V=e}(Q);const J=/^([+-]?(\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 ee={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 te extends Error{constructor(e,...t){const n=ee[e];super("function"==typeof n?n(...t):n),this.code=e}}const ne=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,re=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,oe=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function se(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 ie(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 J.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?oe.test(n)?{name:n}:{calc:t(e)}:{value:r}}function ae(e,t,n,r,o){const{attrs:s,events:i,classes:a,styles:l,vars:c,params:u,enhancements:d}=e;return function(f,h){const p=f.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=(ne.exec(p)||re.exec(p))?.groups;if(!m)throw new te("ATTR",f);const{name:g,enhancement:b}=m,v=m.decorator?.toLowerCase();if(b){if(":"===v)se(d,b).attrs[g]=h?ie(h,t):{name:g};else if("@"===v)se(d,b).events[g]=h?oe.test(h)?{name:h}:{event:r(h)}:{name:g};else if("!"===v){if("bind"===g)se(d,b).bind=h||!0}else se(d,b).value=ie(h,t);return}if(!v)return void(s[g]={value:h});if(":"===v)return void(s[g]=h?ie(h,t):{name:g});if("."===v)return void(a[g]=h?ie(h,t):{name:g});if("style:"===v)return void(l[g]=ie(h,t));if("@"===v)return void(i[g]=h?oe.test(h)?{name:h}:{event:r(h)}:{name:g});if("+"===v)return void c.push({...h?ie(h,n):{value:void 0},variable:g,init:!0});if("*"===v)return void c.push({...ie(h,t),variable:g,init:!1});if("?"===v)return void(u[g]=ie(h,t));if("!"!==v)return;switch(g.toString()){case"fragment":e.fragment=h||!0;break;case"else":e.else=!0;break;case"enum":e.enum=h?ie(h,t):{value:!0};break;case"sort":e.sort=h?ie(h,t):{value:!0};break;case"if":e.if=ie(h,t);break;case"text":e.text=ie(h,t);break;case"html":o&&(e.html=ie(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 le(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 ce={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 ue=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function de(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function fe(e,t,n,r){let o=r[n];return null==o&&(o=e.lastIndexOf("</"+n+">"),o<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function he(...e){console.error(new te(...e))}function pe(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in ce?ce[t]:(he("ENTITY",e),e)}var me=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new te("CALC")},createInit:n=t,createEvent:r=()=>{throw new te("EVENT")},simpleTag:o=new Set,enableHTML:s=!1}={}){const i=[],a={children:i},l=[];let c=null,u=a;function d(){c=l.pop()||null,u=c||a}function f(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;f(e.substring(p,t).replace(/&#?\w+;/g,pe)),p=t}for(;;){const g=e.indexOf("<",p);if(g<0){const L=e.substring(p);L.match(/^\s*$/)||f(L);break}g>p&&m(g);const b=e.charAt(g+1);if("!"===b){let N=g+2,$=">";if("--"===e.slice(g+2,g+4)&&(N+=4,$="--\x3e"),p=e.indexOf($,N),p<0)break;p++;continue}if("/"===b){p=e.indexOf(">",g+3);let j=e.substring(g+2,p);if(p<0?(j=e.substring(g+2).replace(/[\s<].*/,""),he("UNCOMPLETED",j,c?.name),p=g+1+j.length):j.match(/\s</)&&(j=j.replace(/[\s<].*/,""),he("UNCOMPLETED",j),p=g+1+j.length),c){const T=c.name;if(T===j)d();else{if(T.toLowerCase()!=j.toLowerCase())throw new te("CLOSE",j,c.name);d()}}p++;continue}function v(t){let n=p+1;if(p=e.indexOf(t,n),p<0)throw new te("QUOTE",t);const r=e.slice(n,p).replace(/&#?\w+;/g,pe);return p++,r}function y(){let t=e.charAt(p);for(;t<=" "||""===t;t=e.charAt(++p));return t}function w(){let t=p,n=e.charAt(p);for(;de(n);)p++,n=e.charAt(p);return e.slice(t,p)}p=g+1;let x=e.charAt(p);switch(x){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case">":case"/":throw new te("SYMBOL",x);case"":throw new te("EOF")}const S=w(),E=ue.exec(S)?.groups;if(!E)throw new te("TAG",S);l.push(c),c=le(E.name,E.is),u.children.push(c),u=c;const C=ae(c,t,n,r,s);let O=!0,A=!1;e:for(;O;){let M=y();switch(M){case"":he("EOF"),p++;break e;case">":p++;break e;case"/":A=!0;break e;case'"':case"'":throw new te("ATTR_VALUE");case"=":throw new te("SYMBOL",M)}const k=w();if(!k){he("EOF"),p++;break e}switch(M=y(),M){case"":he("EOF"),p++;break e;case">":C(k,""),p++;break e;case"/":C(k,""),A=!0;break e;case"=":p++;break;case"'":case'"':C(k,v(M));continue;default:C(k,"");continue}switch(M=y(),M){case"":C(k,""),he("EOF"),p++;break e;case">":C(k,""),p++;break e;case"/":C(k,""),A=!0;break e;case"'":case'"':C(k,v(M));continue}C(k,w())}if(A){for(;;){p++;const I=e.charAt(p);if("/"!==I&&!(I<=" "||""===I))break}switch(e.charAt(p)){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case"":he("EOF");break;case">":p++;break;default:throw new te("CLOSE_SYMBOL")}d()}else(o.has(S)||fe(e,p,S,h))&&d()}return Z(i)}});function ge(t){let n=!0;const r=new e.Signal.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),o=new e.Signal.Computed(t);return r.watch(o),o.get(),()=>{r.unwatch(o)}}function be(e,t,n){let r,o=!1;return ge((()=>{const s=e();if(!o)return o=!0,r=s,void(n&&t(s));Object.is(s,r)||(r=s,t(s))}))}const ve=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*ye(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ve)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 Q?(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 we(e,t,n){for(const[n,r]of t){for(const[t,o]of ye(r,n))e[t]=o;for(const[t,o]of ye(r,n,"$$"))e[t]=o}}const xe={value$:{calc:e=>e?.[_].value},state$:{calc:e=>e?.[_].state}};var Se=Object.getOwnPropertyDescriptors(xe);function Ee(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function Ce(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 Oe{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ye[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.#ye[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.Signal.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return be((()=>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.#ye[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof Y?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ye[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ye[!0===e?"":e];if(!r?.get)return;const{store:o}=r;return o?ve.has(t)?be((()=>o[t]),n,!0):void 0:"value"===t?be((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ye[!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=>be(e,t,!0)}}return Object.fromEntries([...ve].map((e=>[`$${e}`,t=>be((()=>n[e]),t,!0)])))}getBindAll(e){const t=this.#ye[!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([...ve].map((e=>[`$${e}`,"value"===e||"state"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])))}bindSet(e,t){const n=this.#ye[!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.#ye[!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.#ye[e];if(!n)return null;const{exec:r,calc:o}=n;return"function"==typeof r?r:"function"==typeof o?o:null}constructor(e,t){if(this.store=e,t instanceof Oe){this.#we=t.#we;const e=this.#xe;for(const[n,r]of Object.entries(t.#xe))e[n]=r;const n=this.#Se;for(const[e,r]of Object.entries(t.#Se))n[e]=r}else we(this.#xe,e),this.#we=function(e){const t=Object.create(null,Se);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!Ee(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof Y){for(const[e,o]of ye(r,n))t[e]=o;continue}const{get:e,set:o,exec:s,calc:i}=r;"function"!=typeof e?"function"==typeof i||i&&"object"==typeof i?t[n]={calc:i}:("function"==typeof s||i&&"object"==typeof i)&&(t[n]={exec:s}):t[n]="function"==typeof o?{get:e,set:o}:{get:e}}return t}(t)}#we;#xe=Object.create(null);#Se=Object.create(null);store;#Ee=null;#o=null;#Ce=null;get#ye(){const e=this.#Ce;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#xe,...this.#we,...this.#Se})),n=this.store,r=this.#o,o=this.#Ee;for(const[e,r]of ye(n))t[e]=r;for(const[e,o]of function*(e,t,n="",r="$"){if(!(e instanceof Q))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]=o;if(o)for(const e of Object.keys(o))t[`$${e}`]={get:()=>o[e]};return this.#Ce=t,t}setStore(e,t,n){const r=new Oe(e,this);return t&&(r.#o=t),we(r.#xe,e),n&&(r.#Ee=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Oe(t,this);return we(n.#xe,t),n}params(t,n,r,o){let s=this.store;if(!0===o)s=r.store;else if(o){const e=r.#ye[o],t=e?.get&&e.store;t&&(s=t)}if(0===Object.keys(t).length)return this;const i=new Oe(s,this);i.#o=this.#o,i.#Ee=this.#Ee;const a=i.#Se,l=i.#ye;for(const[o,s]of Object.entries(t)){const t=o in n?n[o]:null;if(t){const{name:n,calc:s,value:i}=t;if(n){const e=r.#ye[n];if(!e?.get)continue;if(!e.store){a[o]=l[o]=e;continue}for(const[t,n]of ye(e.store,o))a[t]=l[t]=n;continue}if("function"==typeof s){const t=new e.Signal.Computed((()=>s(r.getters)));a[o]=l[o]={get:()=>t.get()};continue}a[o]=l[o]={get:()=>i}}else{const{name:t,calc:n,value:r}=s;if("function"==typeof n){const t=i.getters;i.#Oe=null;const r=new e.Signal.Computed((()=>n(t)));a[o]=l[o]={get:()=>r.get()};continue}if(t){const e=l[t];if(!e?.get)continue;if(!e.store){a[o]=l[o]=e;continue}for(const[t,n]of ye(e.store,o))a[t]=l[t]=n;continue}a[o]=l[o]={get:()=>r}}}return i}setObject(e){const t=new Oe(this.store,this);return t.#Ee=e,t}set(t){if(!t?.length)return this;const n=new Oe(this.store,this);n.#o=this.#o,n.#Ee=this.#Ee;const r=n.#Se,o=n.#ye;for(const{variable:s,name:i,calc:a,value:l,init:c}of t)if(c){const t=new e.Signal.State(l);if("function"==typeof a){const e=n.settable;n.#Ae=null,t.set(a(e))}else if(i){const e=o[i];if(!e?.get)continue;t.set(e.get())}r[s]=o[s]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof a)if(i){const e=o[i];if(!e)continue;if(!e.get||!e.store){r[s]=o[s]=e;continue}for(const[t,n]of ye(e.store,s))r[t]=o[t]=n}else r[s]=o[s]={get:()=>l};else{const t=n.getters;n.#Oe=null;const i=new e.Signal.Computed((()=>a(t)));r[s]=o[s]={get:()=>i.get()}}return n}#Le=null;get all(){const e=this.#Le;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Le=t,t}#Ae=null;get settable(){const e=this.#Ae;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Ae=t,t}#Oe=null;get getters(){const e=this.#Oe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ye))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 Ce(this.store,t),this.#Oe=t,t}}const Ae={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 Le(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 o=Array.isArray(t)?t[0]:t;return"number"==typeof o||"bigint"==typeof o?r=o&&e in Ae?`${o}${Ae[e]}`:`${o}`:"string"==typeof o&&(r=o),r?[r,n?"important":void 0]:null}class Ne{#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,o="number"==typeof e?String(e):e;let s=r.get(o);return s||(s=new Set,r.set(o,s)),s.add(n),()=>{s?.delete(n)}}}const $e={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 je(e,t,n){const r=[];if(t)for(let o=e.shift();o;o=e.shift()){const e=o.indexOf(":"),s=e>=0?o.slice(0,e):o,i=e>=0?o.slice(e+1).split(":"):[],a=s.replace(/^-+/,""),l=(s.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=$e[c]),"function"==typeof c&&r.push([c,i,l])}return r}function Te(e,t,n){return r=>{const o=e.all;for(const[e,t,s]of n)if(e(r,t,o)===s)return;t(r,o)}}function Me(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 ke(e){return null===(e??null)?"":String(e)}function Ie(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 ke;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 Pe={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=ke(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=ke(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=ke(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Ue(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:o,props:s}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const i=Pe[t.toLowerCase()],a=i?.attrs||{},l=i?.events||{};for(const[e,t,o]of n)if("$"!==e[0])r.addEventListener(e,t,o);else{const n=l[e];if(n){const[e,s]=n;r.addEventListener(e,(e=>t(s(e,r))),o)}}if(s)for(const[t,n]of Object.entries(e.attrs))if(o(t,(e=>{if(s.has(t))r[t]=e;else{const n=Me(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),s.has(t))r[t]=n;else{const e=Me(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=Me(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),o(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=a[t];e&&(e(n,r),o(t,(t=>e(t,r))));continue}const e=Ie(r,t);if("function"==typeof e){r[t]=e(n),o(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,o(t,(e=>{r[t]=e}));continue}let s=Me(n);null!==s&&r.setAttribute(t,s),o(t,(e=>{const n=Me(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Be(e){return null===(e??null)?"":String(e)}function Re(e,t,n,r,o){if(!o){const o=e.insertBefore(document.createTextNode(""),t),s=n.watch(r,(e=>o.textContent=Be(e)));return()=>{o.remove(),s()}}const s=e.insertBefore(document.createComment(""),t),i=e.insertBefore(document.createComment(""),t),a=document.createElement("div");function l(){for(let e=s.nextSibling;e&&e!==i;e=s.nextSibling)e.remove()}const c=n.watch(r,(t=>{l(),function(t){a.innerHTML=t;for(let t=a.firstChild;t;t=s.firstChild)e.insertBefore(t,i)}(Be(t))}));return()=>{c(),l(),s.remove(),i.remove()}}function qe(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 _e=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function De(e,t,n,r,o){const s=e.children;if(!s.length)return()=>{};const i=t.insertBefore(document.createComment(""),n);let a=null,l=()=>{};const c=be((()=>s.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===a)return;a=e,l(),l=()=>{};const t=e?.[0];t&&(l=o(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),l(),l=()=>{},i.remove())}}function Fe(t,n,r,o,s,i,a,l,c){const u=t.bind,d=[...i,t.name],f=c?.(d);if(c&&!f)return()=>{};const{context:h,handler:p}=function(t,n,r,o){const s="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.Signal.State(!1);let u=!1;const d=new e.Signal.State(!1),f=Object.create(null),h=Object.create(null),p=new Set,m=[],g=new Ne;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=f[e];if(!n)return()=>{};let r=n.get();const o=be((()=>n.get()),(n=>{const o=r;r=n,t(n,o,e)}),!0);return p.add(o),()=>{p.delete(o),o()}},relate(e){if(!r||!o||l)return()=>{};try{const t=o(r,e);return"function"!=typeof t?()=>{}:(p.add(t),()=>{p.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return d.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:s,set(t,n){if(i&&!(t in i))return;let r=f[t];if(r)return void r.set(n);const o=new e.Signal.State(n);f[t]=o,Object.defineProperty(h,t,{configurable:!0,enumerable:!0,get:o.get.bind(o)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...o]=e.split(".").filter(Boolean),s=a?a[r].filters:{};if(!s)return;const i={},l=je(o,s,i);m.push([r,Te(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,d.set(!0),g.emit("init",{events:m}))}}}}(f||t.name,o,o.getStore(u),l),m=f?.attrs,g=m?function(e,t,n,r,o){let s=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:o,calc:l,value:c}=n[i];if(!o&&!l){e.set(i,c);continue}a.immutable&&e.set(i,t.exec(r)),s.add(t.watch(r,(t=>e.set(i,t))));continue}const r=a.bind;if(!o||!r){e.set(i,a.default);continue}if("string"==typeof r){const n=t.bind(o,r,(t=>e.set(i,t)));n?s.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===o?"":o;s.add(t.watch({name:n},(t=>e.set(i,t)))),e.addEvent(l,((...e)=>{t.all[n]=c(...e)}));continue}const d=t.bind(o,"state",(t=>e.set(i,t)));if(!d)continue;s.add(d);const f=t.bindSet(o,"state");f&&e.addEvent(l,((...e)=>{f(c(...e))}))}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,o,t.attrs,m,u):function(e,t,n){const r=e.tag;let o=new Set;for(const[s,i]of Object.entries(n)){if("class"===s||"style"===s)continue;const{name:n,calc:a,value:l}=i;if(n||a)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==s.toLocaleLowerCase())o.add(t.watch(i,(t=>e.set(s,t))));else{const n=t.exec(i);e.set(s,n)}else e.set(s,l)}return()=>{const e=o;o=new Set;for(const t of e)t()}}(p,o,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=o.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[o,s]of Object.entries(t.bindAll(n)||{}))"function"==typeof s&&r.add(s((t=>e.set(o,t))));for(const[r,o]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>o(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,o,u),v=f?"function"==typeof f.tag?f.tag(h):Ue(h,f.tag,f.is):Ue(h,t.name,t.is),y=Array.isArray(v)?v[0]:v,w=Array.isArray(v)?v[1]:y;n.insertBefore(y,r);const x=w?He(t.children||[],w,null,o,s,i,a,l,c):()=>{},S=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let o=new Set;for(const[r,s]of Object.entries(n))s.value?e.classList.add(r):o.add(be((()=>Boolean(t.exec(s))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.classes,t.attrs.class),E=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 o=new Set;for(const[r,s]of Object.entries(n))o.add(be((()=>Le(r,t.exec(s))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.styles,t.attrs.style);p.mount();const C=function(t,n,r,o,s,i){let a=new Set;for(const[l,{attrs:c,value:u,events:d,bind:f}]of Object.entries(n)){if(!_e(o,l))continue;const h=o[l];if("function"!=typeof h)continue;let p=!1;const m=new e.Signal.State(!1),g=h?.events,b=[],v=Object.create(null),y=new Set,w=new Ne;function x(e,t){if("function"!=typeof t)return;const[n,...o]=e.split(".").filter(Boolean),s=g?g[n].filters:{};if(!s)return;const i={},a=je(o,s,i);b.push([n,Te(r,t,a),i])}function S(){if(!p){p=!0,m.set(!0);for(const e of y)e();w.emit("destroy")}}a.add(S);for(const[C,O]of Object.entries(c)){const A=r.get(O);A&&Object.defineProperty(v,C,{...A,configurable:!0,enumerable:!0})}for(const[L,N]of Object.entries(d)){const $=r.getEvent(N);$&&x(L,$)}if(f){for(const[j,T]of Object.entries(r.getBindAll(f)||{}))Object.defineProperty(v,j,{...T,configurable:!0,enumerable:!0});for(const[M,k]of Object.entries(r.bindEvents(f)||{}))x(M,(e=>k(e)))}const E={get value(){return null},events:b,attrs:v,watch(e,t){if(p)return()=>{};let n=v[e];const r=be((()=>v[e]),(r=>{const o=n;n=r,t(r,o,e)}),!0);return y.add(r),()=>{y.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:s,slot:i,tag:t};if(u){const I=r.get(u);I&&Object.defineProperty(E,"value",{...I,configurable:!0,enumerable:!0})}h(E)}return()=>{const e=a;a=new Set;for(const t of e)t()}}(p.tag,t.enhancements,o,a,y,w);return()=>{C(),p.destroy(),y.remove(),g(),x(),b(),S(),E()}}function Ve(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const o=Object.create(t);for(const[t,n]of r)o[t]=[n,e];return o}function We(t,n,r,o,s,i,a,l,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=o.set(t.vars),d=Ve(u,s,t.templates);if("divergent"===t.type)return De(t,n,r,u,((e,t,o)=>{const d=u.set(t),f=Ve(d,s,o);return He(e,n,r,d,f,i,a,l,c)}));if("value"===t.type){const e=u.child(t.name);return e?He(t.children,n,r,e,d,i,a,l,c):()=>{}}if("enum"===t.type){const o=u.enum(t.value),s=(e,r)=>He(t.children,n,e,r,d,i,a,l,c);return o instanceof Q?function(t,n,r,o,s){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.Signal.State(0),u=be((()=>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=s(l,o.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,o,u,s,t.sort):o instanceof G?function(e,t,n,r,o,s){const i=[],a=[...n],l=a.length,c=s?a.map((([e,t])=>[e,t,r.setStore(t,n).exec(s)])).sort((([,,e],[,,t])=>qe(e,t))).map((([e,t],n)=>[e,t,n])):a.map((([e,t],n)=>[e,t,n]));for(const[e,s,a]of c)i.push(o(t,r.setStore(s,n,{get count(){return l},get key(){return e},get index(){return a},get item(){return s.value}})));return()=>{for(const e of i)e()}}(0,r,o,u,s,t.sort):"function"==typeof o?function(t,n,r,o,s,i){const a=new e.Signal.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.Signal.Computed((()=>{const e=a.get();return e.map((([t,n],r)=>[n,t,o.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(i)])).sort((([,,e],[,,t])=>qe(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Signal.Computed((()=>a.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function d(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const f=new e.Signal.State(0),h=be((()=>l.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const i=u;u=[],f.set(n.length);for(const[a,l,c]of n){const n=i.findIndex((e=>e[3]===c)),[d]=n>=0?i.splice(n,1):[];if(!d){const n=t.insertBefore(document.createComment(""),r),i=t.insertBefore(document.createComment(""),r),d=new e.Signal.State(a),h=new e.Signal.State(l),p=s(i,o.setObject({get count(){return f.get()},get key(){return c},get item(){return d.get()},get index(){return h.get()}}));u.push([n,i,p,c,d,h]);continue}if(u.push(d),d[4].set(a),d[5].set(l),r===d[0]){r=d[1].nextSibling;continue}let h=d[0];for(;h&&h!==d[1];){const e=h;h=h.nextSibling,t.insertBefore(e,r)}t.insertBefore(d[1],r)}d(i)}),!0);return()=>{c.remove(),d(u),h()}}(n,r,o,u,s,t.sort):()=>{}}if("content"===t.type)return Re(n,r,u,t.value,t.html);if("template"===t.type){const e=d[t.template];if(!e)return()=>{};const[o,f]=e,h=f.params(o.params,t.attrs,u,t.bind),p=Ve(h,s,o.templates);return He(o.children,n,r,h,p,i,a,l,c)}return"fragment"===t.type?He(t.children,n,r,u,d,i,a,l,c):Fe(t,n,r,u,d,i,a,l,c)}function He(e,t,n,r,o,s,i,a,l){const c=e.map((e=>We(e,t,n,r,o,s,i,a,l)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function Ke(e,t,n,{columns:r,remove:o,dragenter:s,dragstart:i,dragend:a,deletable:l},c){const u=document.createElement("tbody");u.addEventListener("dragenter",(()=>{s()})),u.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&i()})),u.addEventListener("dragend",a);const d=u.appendChild(document.createElement("tr")),f=[];let h=()=>{};const p=[];if(r.find((e=>Array.isArray(e)&&e.includes("trigger")))){const o=u.appendChild(document.createElement("tr")),s=o.appendChild(document.createElement("td"));s.colSpan=r.length;const[i,a]=it(e,t,n,c);s.appendChild(i),f.push(a),o.hidden=!0,h=function(){if(o.hidden){o.hidden=!1;for(const e of p)e.classList.remove("NeeloongForm-table-line-open"),e.classList.add("NeeloongForm-table-line-close")}else{o.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=d.appendChild(document.createElement("td")),o=e.child(n);if(!o)continue;const[s,i]=ot(o,t,null,c,!0);f.push(i),r.appendChild(s);continue}const r=d.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),f.push(be((()=>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",o),f.push(be((()=>!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 f)e()}]}function ze(e,t,n,r,o){const s=e.appendChild(document.createElement("tr")),i=[];for(const e of t){if(!Array.isArray(e)){const{width:t,label:n}=e,r=s.appendChild(document.createElement("th"));t&&r.setAttribute("width",t),r.innerText=n;continue}const t=s.appendChild(document.createElement("th"));if(o)for(const o of e)if("add"!==o);else{const e=t.appendChild(document.createElement("button"));e.addEventListener("click",n),e.classList.add("NeeloongForm-table-add"),i.push(be((()=>!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 Ge(e,t,n,r,o,s,i){const a=[];if(n instanceof Element){const l=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===l){const f=n.getAttribute("name")||"",h=n.getAttribute("mode")||"",p=f?e.child(f):e,m=f&&o?.fields?.find(Ye(f))||null;if(!p)return()=>{};if("grid"===h){const[v,y]=it(e,t,m,r);return n.replaceWith(v),y}const g=p.component;if(g){const w=t(p,g,r);if(w){const[x,S]=w;return n.replaceWith(x),S}}const b=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(b)),()=>{}}if("nl-form-button"===l){const E=document.createElement("button");E.className="NeeloongForm-item-button";const C=n.getAttribute("click")||"",O=r?.call;C&&"function"==typeof O&&E.addEventListener("click",(t=>O(C,t,e,r)));for(const A of[...n.childNodes])E.appendChild(A);return n.replaceWith(E),()=>{}}const c=n.getAttribute("nl-form-field");if(c){const L=c.endsWith("[]"),N=L?c.slice(0,c.length-2):c,$=N?e.child(N):e;if(!$)return()=>{};n.removeAttribute("nl-form-field");const j=N?o?.fields?.find(Ye(N)):o;if(!L)return Ge($,t,n,r,j,s);if(!($ instanceof Q))return n.remove(),()=>{};const T=n.parentElement;if(!T)return n.remove(),()=>{};const M=T.insertBefore(document.createComment(""),n)||null;n.remove();let k=new Map;function I(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let P=-1;const U=e=>{if(P<0)return;const t=e?Number(e.index):$.children.length;t<0||P<0||P===t||$.move(P,t)&&(P=t)},B=be((()=>$.children),(e=>{let o=M.nextSibling;const s=k;k=new Map;for(const i of e){const e=s.get(i);if(e)s.delete(i),k.set(i,e),o!==e[0]?T.insertBefore(e[0],o):o=o.nextSibling;else{const e=T.insertBefore(n.cloneNode(!0),o),s=Ge(i,t,e,r,j,e);e.addEventListener("dragenter",(()=>{U(i)})),e.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&(P=Number(i.index))})),e.addEventListener("dragend",(()=>{P=-1})),k.set(i,[e,s])}}I(s)}),!0);return()=>{M.remove(),I(k),B()}}if(null!==n.getAttribute("nl-form-remove")){const R=e.parent;R instanceof Q&&n.addEventListener("click",(()=>{R.remove(Number(e.index))}))}null!==n.getAttribute("nl-form-move")&&s instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{s.draggable=!0;const t=n=>{n.pointerId===e&&(s.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 q=e.child(u);q instanceof Q&&n.addEventListener("click",(()=>{q.add({})}))}const d=r?.call;for(const _ of[...n.getAttributeNames()]){const D=_.indexOf(":");if(D<0)continue;const F=_.slice(0,D).toLowerCase(),V=_.slice(D+1);if("nl-form-field"===F){const W=n.getAttribute(_),H=W?e.child(W):e;if(!H)continue;a.push(ge((()=>{try{n.setAttribute(V,H.value)}catch{}})))}else if("nl-form-event"===F&&"function"==typeof d){const K=n.getAttribute(_);if(!K)continue;try{n.addEventListener(V,(t=>d(K,t,e,r)))}catch{}}}}if(n instanceof Element||n instanceof DocumentFragment)for(const z of[...n.children])a.push(Ge(e,t,z,r,o,s));return()=>{for(const e of a)e()}}function Qe(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 Ze(e,t){return ge((()=>{t?.error?e.classList.add("NeeloongForm-item-errored"):e.classList.remove("NeeloongForm-item-errored")}))}function Xe(e,t){return ge((()=>{t?.required?e.classList.add("NeeloongForm-item-required"):e.classList.remove("NeeloongForm-item-required")}))}function Je(e){const t=[],n=document.createElement("details");n.className="NeeloongForm-item",t.push(Xe(n,e)),n.open=!0;const r=n.appendChild(document.createElement("summary"));return t.push(ge((()=>r.innerText=e?.label||""))),t.push(Ze(n,e)),[n,()=>{for(const e of t)e()},n,t]}function et(e,t){const{colStart:n,colSpan:r,colEnd:o,rowStart:s,rowSpan:i,rowEnd:a}=t||{};e.classList.add("NeeloongForm-item-grid"),n&&o?e.style.gridColumn=`${n} / ${o}`:n&&r?e.style.gridColumn=`${n} / span ${r}`:r&&(e.style.gridColumn=`span ${r}`),s&&a?e.style.gridRow=`${s} / ${a}`:s&&i?e.style.gridRow=`${s} / span ${i}`:i&&(e.style.gridRow=`span ${i}`)}function tt(e){const t=[],n=document.createElement("div");return n.className="NeeloongForm-item",t.push(Xe(n,e)),t.push(Ze(n,e)),[n,()=>{for(const e of t)e()},n,t]}function nt(e){const t=[],n=document.createElement("div");n.className="NeeloongForm-item",t.push(Xe(n,e));const r=n.appendChild(document.createElement("div"));r.className="NeeloongForm-item-label",t.push(ge((()=>r.innerText=e?.label||"")));const o=n.appendChild(document.createElement("div"));o.className="NeeloongForm-item-content";const s=n.appendChild(document.createElement("div"));s.className="NeeloongForm-item-description",t.push(ge((()=>s.innerText=e?.description||"")));const i=n.appendChild(document.createElement("div"));return i.className="NeeloongForm-item-error",t.push(ge((()=>i.innerText=e?.error||""))),t.push(Ze(n,e)),[n,()=>{for(const e of t)e()},o,t]}function rt(e,t,n){switch(e.cell||n){default:case"block":return nt(t);case"collapse":return Je(t);case"inline":{const n=nt(t);return et(n[0],e),n}case"base":{const n=tt(t);return et(n[0],e),n}}}function ot(t,n,r,o,s=!1){const{type:i,component:a}=t;if(s){const e=r?.inlineHtml;if(e){const s=Qe(e);return[s,Ge(t,n,s,o,r)]}return a&&n(t,a,o)||[document.createElement("div"),()=>{}]}const l=i&&"object"==typeof i,c=r?.html;if(c){const[e,s,i,a]=rt(r,t,l?"collapse":"base"),u=Qe(c);return a.push(Ge(t,n,u,o,r)),i.appendChild(u),[e,s]}if(l){const[s,i,l,c]=Je(t);if(c.push(ge((()=>s.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,o);if(e){const[t,n]=e;l.appendChild(t),c.push(n)}}else if(t instanceof Q){const[s,i]=function(t,n,r,o){const s=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(s)){const e=new Map(i.map((e=>[e.field,e])));a=s.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.Signal.Computed((()=>t.addable)),d={get:()=>Boolean(o?.editable)};function f(){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 v=[];switch(v.push(ze(c,a,f,u,Boolean(o?.editable))),r?.tableFoot){default:case"header":{const e=l.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()})),v.push(ze(e,a,f,u,Boolean(o?.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",f),n.classList.add("NeeloongForm-table-foot-add"),v.push(be((()=>!u.get()),(e=>{n.disabled=e}),!0));break}case"none":}const y=c;let w=new Map;function x(e){for(const[t,n]of e.values())n(),t.remove()}const S=a.map((e=>Array.isArray(e)?e:e.field)),E=be((()=>t.children),(function(e){let t=c.nextSibling;const s=w;w=new Map;for(let i of e){const e=s.get(i);if(e)s.delete(i),w.set(i,e),t!==e[0]?l.insertBefore(e[0],t):t=t.nextSibling;else{const[e,s]=Ke(i,n,r,{columns:S,remove:h.bind(null,i),dragenter:m.bind(null,i),dragstart:g.bind(null,i),dragend:b,deletable:d},o);l.insertBefore(e,t),w.set(i,[e,s])}}x(s)}),!0);return[l,()=>{y.remove(),c.remove(),x(w),E();for(const e of v)e()}]}(t,n,r,o);l.appendChild(s),c.push(i)}else{const[e,s]=it(t,n,r,o);l.appendChild(e),c.push(s)}return[s,i]}const[u,d,f,h]="base"===r?.cell?tt(t):nt(t);if(et(u,r),h.push(ge((()=>u.hidden=t.hidden))),"function"==typeof a){const e=n(t,a,o);if(e){const[t,n]=e;f.appendChild(t),h.push(n)}}return[u,d]}function st(e,t,n,r){if("button"===n.type)return function(e,t,n){const[r,o,s,i]=rt(t,e),a=document.createElement("button");i.push((()=>{const r=t.text,o="function"==typeof r?r(e,n):r;a.innerText=o??""})),i.push((()=>{const r=t.disabled,o="function"==typeof r?r(e,n):r;a.disabled=Boolean(o)})),a.className="NeeloongForm-item-button",s.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,o]}(e,n,r);if("html"===n.type)return function(e,t,n,r){const[o,s,i,a]=rt(n,e),l=n.html;if(!l)return[o,s];const c=Qe(l);return a.push(Ge(e,t,c,r,n)),i.appendChild(c),[o,s]}(e,t,n,r);const o=e.child(n.field);return o?ot(o,t,n,r):null}function it(e,t,n,r,o){const s=o instanceof HTMLElement?o:document.createElement("div");s.className="NeeloongForm";const i=[],a=n?.fields;if(a)for(const n of a){const o=st(e,t,n,r);if(!o)continue;const[a,l]=o;s.appendChild(a),i.push(l)}else{const n=[...e].map((([,e])=>e));for(const e of n){const[n,o]=ot(e,t,null,r);s.appendChild(n),i.push(o)}}return[s,()=>{for(const e of i)e()}]}e.ArrayStore=Q,e.Layout=me,e.ObjectStore=G,e.Store=Y,e.effect=ge,e.render=function(e,t,n,{component:r,global:o,relate:s,enhancements:i}={}){return He(t,n,null,new Oe(e,o),Object.create(null),[],i||{},"function"==typeof s?s:null,r)},e.renderStore=function(e,t,n,r,o){const s=r?.html;if(s){const i=Qe(s),a=Ge(e,t,i,o||null,r);return n.appendChild(i),a}return it(e,t,r||null,o||null,n)[1]},e.watch=be}));
|