@tempots/dom 25.1.3 → 26.0.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.
@@ -131,13 +131,13 @@ export declare class BrowserContext implements DOMContext {
131
131
  */
132
132
  readonly withReference: (reference: Text | undefined) => DOMContext;
133
133
  /**
134
- * Returns a new HTMLDOMContext instance with the specified providers merged into
135
- * the existing providers.
134
+ * Sets a provider for the given provider mark.
136
135
  *
137
- * @param providers - An object containing the providers to be merged into the existing providers.
138
- * @returns A new HTMLDOMContext instance with the merged providers.
136
+ * @param mark - The provider mark to set the provider for.
137
+ * @param value - The provider to set for the given mark.
138
+ * @returns A new `DOMContext` instance with the specified provider.
139
139
  */
140
- readonly withProviders: (providers: { [K in ProviderMark<unknown>]: unknown; }) => DOMContext;
140
+ readonly setProvider: <T>(mark: ProviderMark<T>, value: T) => DOMContext;
141
141
  /**
142
142
  * Retrieves a provider for the given provider mark.
143
143
  *
@@ -173,13 +173,24 @@ export declare class BrowserContext implements DOMContext {
173
173
  /**
174
174
  * Returns `true` if the context is a browser DOM context.
175
175
  * @returns `true` if the context is a browser DOM context.
176
+ * @deprecated Use `isBrowser()` instead.
176
177
  */
177
178
  readonly isBrowserDOM: () => this is BrowserContext;
179
+ /**
180
+ * Returns `true` if the context is a browser context.
181
+ * @returns `true` if the context is a browser context.
182
+ */
183
+ readonly isBrowser: () => this is BrowserContext;
178
184
  /**
179
185
  * Returns `true` if the context is a headless DOM context.
180
186
  * @returns `true` if the context is a headless DOM context.
181
187
  */
182
188
  readonly isHeadlessDOM: () => this is HeadlessContext;
189
+ /**
190
+ * Returns `true` if the context is a headless context.
191
+ * @returns `true` if the context is a headless context.
192
+ */
193
+ readonly isHeadless: () => this is HeadlessContext;
183
194
  /**
184
195
  * Sets the style of the element.
185
196
  * @param name - The name of the style to set.
@@ -12,6 +12,15 @@ export type HandlerOptions = {
12
12
  passive?: boolean;
13
13
  capture?: boolean;
14
14
  };
15
+ /**
16
+ * Creates a unique symbol that can be used as a provider mark for a specific type `T`.
17
+ * The provider mark is used to identify the provider of a value of type `T` in a dependency injection system.
18
+ *
19
+ * @param identifier - A string that uniquely identifies the provider.
20
+ * @returns A unique symbol that can be used as a provider mark.
21
+ * @public
22
+ */
23
+ export declare const makeProviderMark: <T>(identifier: string) => ProviderMark<T>;
15
24
  /**
16
25
  * `DOMContext` is an immutable class that represents the context of a DOM element.
17
26
  * It provides methods and properties to manipulate and interact with the DOM element.
@@ -58,16 +67,6 @@ export interface DOMContext {
58
67
  * @returns A new `DOMContext` instance with a reference to the selected DOM element.
59
68
  */
60
69
  makePortal(selector: string): DOMContext;
61
- /**
62
- * Returns a new DOMContext instance with the specified providers merged into
63
- * the existing providers.
64
- *
65
- * @param providers - An object containing the providers to be merged into the existing providers.
66
- * @returns A new DOMContext instance with the merged providers.
67
- */
68
- withProviders(providers: {
69
- [K in ProviderMark<unknown>]: unknown;
70
- }): DOMContext;
71
70
  /**
72
71
  * Retrieves a provider for the given provider mark.
73
72
  *
@@ -76,6 +75,13 @@ export interface DOMContext {
76
75
  * @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
77
76
  */
78
77
  getProvider<T>(mark: ProviderMark<T>): T;
78
+ /**
79
+ * Sets a provider for the given provider mark.
80
+ *
81
+ * @param mark - The provider mark to set the provider for.
82
+ * @param value - The provider to set for the given mark.
83
+ */
84
+ setProvider<T>(mark: ProviderMark<T>, value: T): DOMContext;
79
85
  clear(removeTree: boolean): void;
80
86
  /**
81
87
  * Adds an event listener to the element.
@@ -103,13 +109,24 @@ export interface DOMContext {
103
109
  /**
104
110
  * Returns `true` if the context is a browser DOM context.
105
111
  * @returns `true` if the context is a browser DOM context.
112
+ * @deprecated Use `isBrowser()` instead.
106
113
  */
107
114
  isBrowserDOM(): this is BrowserContext;
115
+ /**
116
+ * Returns `true` if the context is a browser DOM context.
117
+ * @returns `true` if the context is a browser DOM context.
118
+ */
119
+ isBrowser(): this is BrowserContext;
108
120
  /**
109
121
  * Returns `true` if the context is a headless DOM context.
110
122
  * @returns `true` if the context is a headless DOM context.
111
123
  */
112
124
  isHeadlessDOM(): this is HeadlessContext;
125
+ /**
126
+ * Returns `true` if the context is a headless context.
127
+ * @returns `true` if the context is a headless context.
128
+ */
129
+ isHeadless(): this is HeadlessContext;
113
130
  /**
114
131
  * Sets the style of the element.
115
132
  * @param name - The name of the style to set.
@@ -84,7 +84,14 @@ export declare class HeadlessContext implements DOMContext {
84
84
  readonly getText: () => string;
85
85
  readonly makeRef: () => DOMContext;
86
86
  readonly makePortal: (selector: string) => DOMContext;
87
- readonly withProviders: (providers: { [K in ProviderMark<unknown>]: unknown; }) => DOMContext;
87
+ /**
88
+ * Sets a provider for the given provider mark.
89
+ *
90
+ * @param mark - The provider mark to set the provider for.
91
+ * @param value - The provider to set for the given mark.
92
+ * @returns A new `DOMContext` instance with the specified provider.
93
+ */
94
+ readonly setProvider: <T>(mark: ProviderMark<T>, value: T) => DOMContext;
88
95
  readonly getProvider: <T>(mark: ProviderMark<T>) => T;
89
96
  readonly clear: (removeTree: boolean) => void;
90
97
  readonly on: <E>(event: string, listener: (event: E) => void) => Clear;
@@ -92,7 +99,9 @@ export declare class HeadlessContext implements DOMContext {
92
99
  readonly removeClasses: (tokens: string[]) => void;
93
100
  readonly getClasses: () => string[];
94
101
  readonly isBrowserDOM: () => this is BrowserContext;
102
+ readonly isBrowser: () => this is BrowserContext;
95
103
  readonly isHeadlessDOM: () => this is HeadlessContext;
104
+ readonly isHeadless: () => this is HeadlessContext;
96
105
  readonly setStyle: (name: string, value: string) => void;
97
106
  readonly getStyle: (name: string) => string;
98
107
  readonly makeAccessors: (name: string) => {
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var at=Object.defineProperty;var ye=s=>{throw TypeError(s)};var ct=(s,e,t)=>e in s?at(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>ct(s,typeof e!="symbol"?e+"":e,t),Te=(s,e,t)=>e.has(s)||ye("Cannot "+t);var Z=(s,e,t)=>(Te(s,e,"read from private field"),t?t.call(s):e.get(s)),Ee=(s,e,t)=>e.has(s)?ye("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Se=(s,e,t,r)=>(Te(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pe=(s,e,t)=>s+(e-s)*t,be=97,_e=(s,e,t)=>{const r=Math.max(s.length,e.length);let n="";for(let i=0;i<r;i++){let l=s.charCodeAt(i);isNaN(l)&&(l=be);let a=e.charCodeAt(i);isNaN(a)&&(a=be),n+=String.fromCharCode(l+(a-l)*t)}return n},ve=(s,e,t)=>new Date(s.getTime()+(e.getTime()-s.getTime())*t),Ce=(s,e)=>e,we=s=>typeof s=="number"?Pe:typeof s=="string"?_e:s instanceof Date?ve:Ce;var M;class F{constructor(e,t){o(this,"counter");o(this,"isFirst");o(this,"isEven");o(this,"isOdd");Ee(this,M);o(this,"dispose",()=>{this.total.dispose()});this.index=e,this.total=t,this.counter=e+1,this.isFirst=e===0,this.isEven=e%2===1,this.isOdd=e%2===0}get isLast(){return Z(this,M)==null&&Se(this,M,this.total.map(e=>this.counter===e)),Z(this,M)}}M=new WeakMap;const k=class k{constructor(e,t){o(this,"$__signal__",!0);o(this,"_value");o(this,"_derivatives",[]);o(this,"_onValueListeners",[]);o(this,"_onDisposeListeners",[]);o(this,"get",()=>this._value);o(this,"hasListeners",()=>this._onValueListeners.length>0);o(this,"on",(e,t={})=>{t.skipInitial||e(this.get(),void 0);const r=t.once?(i,l)=>{n(),e(i,l)}:e;this._onValueListeners.push(r);const n=()=>{this._onValueListeners.splice(this._onValueListeners.indexOf(r),1),t.abortSignal!=null&&t.abortSignal.removeEventListener("abort",n)};return t.abortSignal!=null&&t.abortSignal.addEventListener("abort",n),n});o(this,"_setAndNotify",(e,t)=>{const r=this._value,n=this.equals(r,e);n||(this._value=e),(t||!n)&&this._onValueListeners.forEach(i=>i(e,r))});o(this,"_disposed",!1);o(this,"isDisposed",()=>this._disposed);o(this,"onDispose",e=>{this._onDisposeListeners.push(e)});o(this,"dispose",()=>{this._disposed||(this._disposed=!0,this._onDisposeListeners.forEach(e=>e()),this._onDisposeListeners.length=0,this._derivatives.length=0)});o(this,"map",(e,t=(r,n)=>r===n)=>{const r=new C(()=>{try{return e(this.get())}catch(n){throw console.error("Error in Signal.map:",n),n}},t);return this.setDerivative(r),r});o(this,"flatMap",(e,t=(r,n)=>r===n)=>{const r=new C(()=>{try{return e(this.get()).get()}catch(n){throw console.error("Error in Signal.flatMap:",n),n}},t);return this.setDerivative(r),r});o(this,"tap",e=>this.map(t=>(e(t),t)));o(this,"at",e=>this.map(t=>t[e]));o(this,"_$");o(this,"filter",(e,t)=>{let r=t??this.get();const n=new C(()=>{try{const i=this.get();return r=e(i)?i:r}catch(i){throw console.error("Error in Signal.filter:",i),i}},this.equals);return this.setDerivative(n),n});o(this,"filterMap",(e,t,r=(n,i)=>n===i)=>{let n=t;const i=new C(()=>{try{const l=this.get(),a=e(l);return n=a??n}catch(l){throw console.error("Error in Signal.filterMap:",l),l}},r);return this.setDerivative(i),i});o(this,"mapAsync",(e,t,r,n=(i,l)=>i===l)=>{const i=P(t,n);let l=0,a=new AbortController;return i.onDispose(this.on(async c=>{const h=++l;a.abort(),a=new AbortController;try{const u=await e(c,{abortSignal:a.signal});h===l&&i.set(u)}catch(u){if(h===l)if(r!=null)i.set(r(u));else throw u}})),i});o(this,"mapMaybe",(e,t)=>this.map(r=>e(r)??t));o(this,"feedProp",(e,t=!1)=>{const r=this.on(e.set);return e.onDispose(r),t?this.onDispose(e.dispose):this.onDispose(r),e});o(this,"deriveProp",({autoDisposeProp:e=!0,equals:t}={})=>this.feedProp(P(this.get(),t),e));o(this,"derive",()=>this.map(e=>e));o(this,"count",()=>{let e=0;return this.map(()=>++e)});o(this,"setDerivative",e=>{this._derivatives.push(e),e.onDispose(()=>{this._derivatives.splice(this._derivatives.indexOf(e),1)}),e.onDispose(this.on(e.setDirty)),this.onDispose(e.dispose)});this.equals=t,this._value=e}get value(){return this._value}get $(){return this._$!==void 0?this._$:this._$=new Proxy(this,{get:(e,t)=>this.at(t)})}};o(k,"ofPromise",(e,t,r,n=(i,l)=>i===l)=>{const i=new k(t,n);return e.then(l=>i._setAndNotify(l,!1)).catch(l=>{r!=null?i._setAndNotify(r(l),!1):console.error("Unhandled promise rejection in Signal.ofPromise:",l)}),i}),o(k,"is",e=>e!=null&&e.$__signal__===!0);let f=k;const ut=typeof queueMicrotask=="function"?queueMicrotask:s=>Promise.resolve().then(s);class C extends f{constructor(t,r){super(void 0,r);o(this,"$__computed__",!0);o(this,"_isDirty",!1);o(this,"setDirty",()=>{this._isDirty||this._disposed||(this._isDirty=!0,this._derivatives.forEach(t=>t.setDirty()),this._scheduleNotify())});o(this,"_scheduleCount",0);o(this,"_scheduleNotify",()=>{const t=++this._scheduleCount;ut(()=>{this._scheduleCount!==t||this._disposed!==!1||this._isDirty&&(this._isDirty=!1,this._setAndNotify(this._fn(),!1))})});o(this,"get",()=>(this._isDirty&&(this._isDirty=!1,this._setAndNotify(this._fn(),!0)),this._value));this._fn=t,this.setDirty()}static is(t){return t!=null&&t.$__computed__===!0}get value(){return this.get()}}const X=class X extends f{constructor(){super(...arguments);o(this,"$__prop__",!0);o(this,"set",t=>{this._setAndNotify(t,!1)});o(this,"update",t=>{this._setAndNotify(t(this.get()),!1)});o(this,"reducer",(t,...r)=>{const n=this;return function i(l){const a=n.value;n.update(c=>t(c,l)),!n.equals(a,n.value)&&r.forEach(c=>c({previousState:a,state:n.value,action:l,dispatch:i}))}});o(this,"iso",(t,r,n=(i,l)=>i===l)=>{const i=new X(t(this.get()),n);return i.onDispose(this.on(l=>i.set(t(l)))),i.on(l=>this._setAndNotify(r(l),!1)),i});o(this,"atProp",t=>this.iso(r=>r[t],r=>({...this.value,[t]:r})))}get value(){return this.get()}set value(t){this._setAndNotify(t,!1)}};o(X,"is",t=>t!=null&&t.$__prop__===!0);let H=X;const Y=(s,e,t=(r,n)=>r===n)=>{const r=new C(s,t);return e.forEach(n=>n.setDerivative(r)),r},Oe=(s,e,t={})=>{let r=t.once?()=>{i(),s()}:s;if(t.skipInitial){let l=!1;const a=r;r=()=>{l?a():l=!0}}const n=Y(r,e),i=()=>{n.dispose(),t.abortSignal!=null&&t.abortSignal.removeEventListener("abort",i)};return t.abortSignal!=null&&t.abortSignal.addEventListener("abort",i),i},P=(s,e=(t,r)=>t===r)=>new H(s,e),$=(s,e=(t,r)=>t===r)=>new f(s,e),K=()=>typeof window<"u"?window:void 0,y={map:(s,e)=>f.is(s)?s.map(e):e(s),toSignal:(s,e)=>f.is(s)?s:$(s,e),maybeToSignal:(s,e)=>{if(s!=null)return y.toSignal(s,e)},get:s=>f.is(s)?s.get():s,on:(s,e)=>f.is(s)?s.on(e):(e(s),()=>{}),dispose:s=>{f.is(s)&&s.dispose()},deriveProp:(s,{autoDisposeProp:e=!0,equals:t}={})=>f.is(s)?s.deriveProp({autoDisposeProp:e,equals:t}):P(s,t)},ht=(...s)=>(e,t)=>{const r=s.filter(n=>f.is(n));return Y(()=>e(...s.map(n=>y.get(n))),r,t)},dt=(...s)=>(e,t={})=>{const r=s.filter(n=>f.is(n));return Oe(()=>e(...s.map(y.get)),r,t)};class ee{constructor(){o(this,"_store",new Map);o(this,"getItem",e=>this._store.get(e)??null);o(this,"setItem",(e,t)=>{this._store.set(e,t)})}}const te=({key:s,defaultValue:e,store:t,serialize:r=JSON.stringify,deserialize:n=JSON.parse,equals:i=(a,c)=>a===c,onLoad:l=a=>a})=>{const a=t.getItem(s),c=new H(a!=null?l(n(a)):typeof e=="function"?e():e,i);return c.on(h=>{t.setItem(s,r(h))}),c},ft=s=>{var e;return te({...s,store:((e=K())==null?void 0:e.localStorage)??new ee})},pt=s=>{var e;return te({...s,store:((e=K())==null?void 0:e.sessionStorage)??new ee})};function Ae(s){return typeof requestAnimationFrame=="function"?requestAnimationFrame(s):setTimeout(s,0)}const xe=(s,e,t,r)=>{const n=(r==null?void 0:r.duration)??300,i=(r==null?void 0:r.easing)??(A=>A),l=(r==null?void 0:r.equals)??((A,B)=>A===B);let a=r==null?void 0:r.interpolate,c=s,h=e(),u=performance.now(),g=null,T=!0;const p=new C(e,l),m=P(s,l);m.onDispose(()=>{g!==null&&cancelAnimationFrame(g)}),m.onDispose(p.dispose),t.forEach(A=>{A.setDerivative(p),A.onDispose(m.dispose)});const v=A=>{h=A,u=performance.now(),c=m.value,T&&(T=!1,g=Ae(me))},me=()=>{const B=(performance.now()-u)/y.get(n),lt=i(B);a==null&&(a=we(c));let ge=a(c,h,lt);B>=1?(T=!0,ge=h):g=Ae(me),m.set(ge)};return p.on(v),m},mt=(s,e)=>{const{initialValue:t,...r}=e??{};return xe(t??s.get(),s.get,[s],r)},gt=(s,e)=>{const{signals:t,literals:r}=Object.entries(s).reduce(({signals:i,literals:l},[a,c])=>(f.is(c)?i.push([a,c]):l[a]=c,{signals:i,literals:l}),{signals:[],literals:{}}),n=t.map(([,i])=>i);return Y(()=>(t.forEach(([i,l])=>r[i]=l.value),e(r)),n)},Le=new Set(["checked","disabled","hidden"]),De=new Set(["selected"]),Me=new Set(["rowSpan","colSpan","tabIndex","valueAsNumber"]),ke=new Set(["valueAsDate"]),He=new Set(["value","textContent","innerText","innerHTML","outerHTML","className","classList"]),Ie=(s,e)=>De.has(s)?t=>{t==null||t!==!0?e.removeAttribute(s):e.setAttribute(s,"")}:Le.has(s)?t=>{t==null?e[s]=null:e[s]=!!t}:Me.has(s)?t=>{t==null?e[s]=null:e[s]=Number(t)}:ke.has(s)?t=>{t==null?e[s]=null:e[s]=t}:He.has(s)?t=>{t==null?e[s]=null:e[s]=String(t)}:t=>{t==null?e.removeAttribute(s):e.setAttribute(s,t)},Ne=(s,e)=>De.has(s)?()=>e.hasAttribute(s):Le.has(s)?()=>!!e[s]:Me.has(s)?()=>Number(e[s]):ke.has(s)?()=>e[s]:He.has(s)?()=>String(e[s]):()=>e.getAttribute(s),I=s=>{const e=s;e&&e.onblur&&(e.onblur=null),!(!s||s.ownerDocument===void 0)&&s.parentElement&&s.parentElement.removeChild(s)},$e=s=>se(s)?s:s.parentElement,se=s=>s.nodeType===1;class re extends Error{constructor(e){super(`Provider not found: ${e.description}`)}}class w{constructor(e,t,r,n){o(this,"createElement",(e,t)=>t!==void 0?this.document.createElementNS(t,e):this.document.createElement(e));o(this,"makeChildElement",(e,t)=>{const r=this.createElement(e,t);return this.appendOrInsert(r),this.withElement(r)});o(this,"createText",e=>this.document.createTextNode(e));o(this,"makeChildText",e=>{const t=this.createText(e);return this.appendOrInsert(t),this.withReference(t)});o(this,"setText",e=>{this.reference.nodeValue=e});o(this,"getText",()=>{var e;return((e=this.reference)==null?void 0:e.nodeValue)??this.element.textContent??""});o(this,"makeRef",()=>{const e=this.createText("");return this.appendOrInsert(e),this.withReference(e)});o(this,"appendOrInsert",e=>{this.reference===void 0?this.element.appendChild(e):this.element.insertBefore(e,this.reference)});o(this,"withElement",e=>new w(this.document,e,void 0,this.providers));o(this,"makePortal",e=>{const t=this.document.querySelector(e);if(t==null)throw new Error(`Cannot find element by selector for portal: ${e}`);return this.withElement(t)});o(this,"withReference",e=>new w(this.document,this.element,e,this.providers));o(this,"withProviders",e=>new w(this.document,this.element,this.reference,{...this.providers,...e}));o(this,"getProvider",e=>{if(this.providers[e]===void 0)throw new re(e);return this.providers[e]});o(this,"clear",e=>{e&&(this.reference!==void 0?I(this.reference):I(this.element))});o(this,"addClasses",e=>{this.element.classList.add(...e)});o(this,"removeClasses",e=>{this.element.classList.remove(...e)});o(this,"getClasses",()=>Array.from(this.element.classList));o(this,"on",(e,t,r)=>(this.element.addEventListener(e,t,r),n=>{n&&this.element.removeEventListener(e,t,r)}));o(this,"isBrowserDOM",()=>!0);o(this,"isHeadlessDOM",()=>!1);o(this,"setStyle",(e,t)=>{this.element.style[e]=t});o(this,"getStyle",e=>this.element.style[e]);o(this,"makeAccessors",e=>({get:Ne(e,this.element),set:Ie(e,this.element)}));this.document=e,this.element=t,this.reference=r,this.providers=n}static of(e,t){return new w(e.ownerDocument,e,t,{})}}const z=(s,e)=>{const t=s(e);return(r=!0)=>t(r)},yt=(s,e,{doc:t,clear:r,disposeWithParent:n=!0}={})=>{const i=typeof e=="string"?(t??document).querySelector(e):e;if(i===null)throw new Re(`Cannot find element by selector for render: ${e}`);r!==!1&&(t??i.ownerDocument)!=null&&i.nodeType===1&&(i.innerHTML="");const l=$e(i),a=se(i)?void 0:i,c=w.of(l,a),h=z(s,c);let u;return n&&(u=new MutationObserver(g=>{var T;(T=g[0])==null||T.removedNodes.forEach(p=>{p===i&&(h(i.nodeType!==Node.ELEMENT_NODE),u==null||u.disconnect())})}),u.observe(i.parentElement,{childList:!0,subtree:!1,attributes:!1})),()=>{u==null||u.disconnect(),h(!0)}},Tt=(s,{startUrl:e="https://example.com",selector:t=":root"}={})=>{const r=y.toSignal(e).deriveProp(),n=new ie(t,void 0),i=new O(n,void 0,{currentURL:r},{});return{clear:z(s(),i),root:n,currentURL:r}};class Re extends Error{constructor(e){super(e)}}const ne="data-tts-node",N="data-tts-class",U="data-tts-style",W="data-tts-html",G="data-tts-text",J="data-tts-attrs";class Et{constructor({select:e,getAttribute:t,setAttribute:r,getClass:n,setClass:i,getStyles:l,setStyles:a,appendHTML:c,getInnerHTML:h,setInnerHTML:u,getInnerText:g,setInnerText:T}){o(this,"select");o(this,"getAttribute");o(this,"setAttribute");o(this,"getClass");o(this,"setClass");o(this,"getStyles");o(this,"setStyles");o(this,"appendHTML");o(this,"getInnerHTML");o(this,"setInnerHTML");o(this,"getInnerText");o(this,"setInnerText");o(this,"setFromRoot",(e,t)=>{e.getPortals().forEach(n=>{for(const i of this.select(n.selector)){if(i==null)throw new Error(`Cannot find element by selector for render: ${n.selector}`);if(n.hasChildren()&&this.appendHTML(i,n.contentToHTML(t)),n.hasInnerHTML()){if(t){const l=this.getInnerHTML(i);l!=null&&this.setAttribute(i,W,l)}this.setInnerHTML(i,n.getInnerHTML())}if(n.hasInnerText()){if(t){const l=this.getInnerText(i);l!=null&&this.setAttribute(i,G,l)}this.setInnerText(i,n.getInnerText())}if(n.hasClasses()){if(t){const l=this.getClass(i);l!=null&&this.setAttribute(i,N,l)}this.setClass(i,n.getClasses().join(" "))}if(n.hasStyles()){if(t){const l=this.getStyles(i);Object.keys(l).length>0&&this.setAttribute(i,U,JSON.stringify(l))}this.setStyles(i,n.getStyles())}if(n.hasAttributes()){const l=n.getAttributes();if(t){const a=[];l.forEach(([c])=>{const h=this.getAttribute(i,c);h!=null&&a.push([c,h])}),a.length>0&&this.setAttribute(i,J,JSON.stringify(Object.fromEntries(a)))}l.forEach(([a,c])=>{this.setAttribute(i,a,c)})}}})});this.select=e,this.getAttribute=t,this.setAttribute=r,this.getClass=n,this.setClass=i,this.getStyles=l,this.setStyles=a,this.appendHTML=c,this.getInnerHTML=h,this.setInnerHTML=u,this.getInnerText=g,this.setInnerText=T}}const St=()=>{document.querySelectorAll(`[${ne}]`).forEach(I)},bt=s=>{const e=s.getAttribute(N);s.removeAttribute(N),e!=null&&s.setAttribute("class",e)},At=()=>{document.querySelectorAll(`[${N}]`).forEach(e=>bt(e))},Pt=s=>{const e=s.getAttribute(W);s.removeAttribute(W),e!=null&&(s.innerHTML=e)},_t=()=>{document.querySelectorAll(`[${W}]`).forEach(e=>Pt(e))},vt=s=>{const e=s.getAttribute(G);s.removeAttribute(G),e!=null&&(s.innerText=e)},Ct=()=>{document.querySelectorAll(`[${G}]`).forEach(e=>vt(e))},Ve=s=>JSON.parse(s.replace(/&quot;/g,'"')),wt=s=>{const e=s.getAttribute(U);if(s.removeAttribute(U),e!=null){const t=Ve(e);Object.entries(t).forEach(([r,n])=>{s.style.setProperty(r,n)})}},Ot=()=>{document.querySelectorAll(`[${U}]`).forEach(e=>wt(e))},xt=s=>{const e=s.getAttribute(J);if(s.removeAttribute(J),e!=null){const t=Ve(e);Object.entries(t).forEach(([r,n])=>{n==null?s.removeAttribute(r):s.setAttribute(r,n)})}},Lt=()=>{document.querySelectorAll(`[${J}]`).forEach(e=>xt(e))},Dt=()=>{St(),At(),Ct(),_t(),Ot(),Lt()},S=Symbol("class"),_=Symbol("style"),L=Symbol("handler"),je=()=>Math.random().toString(36).substring(2,15),Mt=s=>s.replace(/<[^>]*>?/g,"");class qe{constructor(e){o(this,"id",je());o(this,"properties",{});o(this,"children",[]);o(this,"isElement",()=>!0);o(this,"isText",()=>!1);o(this,"getText",()=>this.properties.innerText!=null?this.properties.innerText:this.properties.innerHTML!=null?Mt(this.properties.innerHTML):this.children.map(e=>e.getText()).join(""));o(this,"removeChild",e=>{const t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)});o(this,"remove",()=>{if(this.parent!=null)this.parent.removeChild(this);else throw new Error("Parent is undefined")});o(this,"getPortals",()=>{const e=this.elements().flatMap(t=>t.isPortal()?[t,...t.getPortals()]:t.getPortals());return this.isPortal()&&e.unshift(this),e});o(this,"elements",()=>this.children.filter(e=>e.isElement()));o(this,"hasInnerHTML",()=>this.properties.innerHTML!=null);o(this,"getInnerHTML",()=>this.properties.innerHTML??"");o(this,"getInnerText",()=>this.properties.innerText??"");o(this,"hasInnerText",()=>this.properties.innerText!=null);o(this,"hasChildren",()=>this.children.length>0);o(this,"hasClasses",()=>this.properties[S]!=null);o(this,"hasStyles",()=>this.properties[_]!=null);o(this,"hasAttributes",()=>Object.keys(this.properties).length>0);o(this,"hasHandlers",()=>this.properties[L]!=null);o(this,"hasRenderableProperties",()=>this.hasClasses()||this.hasAttributes()||this.hasStyles());o(this,"getById",e=>{if(this.properties.id===e)return this;for(const t of this.elements()){const r=t.getById(e);if(r!=null)return r}});o(this,"trigger",(e,t)=>{((this.properties[L]??{})[e]??[]).forEach(n=>n(t))});o(this,"click",()=>{this.trigger("click",{})});o(this,"on",(e,t,r)=>{var a;const n=(a=this.properties)[L]??(a[L]={}),i=r!=null&&r.once?c=>{l(),t(c)}:c=>t(c);n[e]=[...n[e]??[],i];const l=()=>{const c=n[e]??[],h=c.indexOf(i);h!==-1&&(c.splice(h,1),c.length===0?(delete n[e],Object.keys(n).length===0&&delete this.properties[L]):n[e]=c,(r==null?void 0:r.signal)!=null&&r.signal.removeEventListener("abort",l))};return(r==null?void 0:r.signal)!=null&&r.signal.addEventListener("abort",l),l});o(this,"addClasses",e=>{var r;if(e.length===0)return;const t=(r=this.properties)[S]??(r[S]=[]);e.forEach(n=>{t.includes(n)||t.push(n)})});o(this,"removeClasses",e=>{var r;if(e.length===0)return;const t=(r=this.properties)[S]??(r[S]=[]);e.forEach(n=>{const i=t.indexOf(n);i!==-1&&t.splice(i,1)}),t.length===0&&delete this.properties[S]});o(this,"getClasses",()=>this.properties[S]??[]);o(this,"getAttributes",()=>Object.entries(this.properties).filter(([e])=>!["innerText","innerHTML"].includes(e)));o(this,"getVisibleAttributes",()=>Reflect.ownKeys(this.properties).flatMap(e=>e===S?[["class",this.getClasses()]]:e===_?[["style",this.getStyles()]]:typeof e=="string"?[[e,String(this.properties[e])]]:[]));o(this,"setStyle",(e,t)=>{var n;const r=(n=this.properties)[_]??(n[_]={});r[e]=t,t===""&&(delete r[e],Object.keys(r).length===0&&delete this.properties[_])});o(this,"getStyle",e=>{var t;return((t=this.properties[_])==null?void 0:t[e])??""});o(this,"getStyles",()=>this.properties[_]??{});o(this,"makeAccessors",e=>{const t=this.properties;return{get:()=>t[e],set:r=>t[e]=r}});this.parent=e}}const kt=s=>s.replace(/"/g,"&quot;"),Ht=s=>s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");class Be extends qe{constructor(t,r,n){super(n);o(this,"isPortal",()=>!1);o(this,"toHTML",(t=!1)=>{const r=this.children.map(c=>c.toHTML()).join(""),n=this.namespace?` xmlns="${this.namespace}"`:"";let i=null;const l=this.getVisibleAttributes().map(([c,h])=>c==="class"?` class="${h.join(" ")}"`:c==="style"?typeof h=="string"?` style="${h}"`:` style="${Object.entries(h).map(([u,g])=>`${u}: ${g};`).join(" ")}"`:It.has(c)?` ${c}`:c==="innerHTML"?(i=h,""):c==="innerText"?(i=Ht(h),""):` ${c}="${kt(h)}"`).join(""),a=t?` ${ne}`:"";return Nt.has(this.tagName)&&r===""?`<${this.tagName}${n}${l}${a} />`:`<${this.tagName}${n}${l}${a}>${i??r}</${this.tagName}>`});this.tagName=t,this.namespace=r}}class ie extends qe{constructor(t,r){super(r);o(this,"isPortal",()=>!0);o(this,"toHTML",()=>"");o(this,"contentToHTML",(t=!1)=>this.children.map(r=>r.toHTML(t)).join(""));this.selector=t}}class Fe{constructor(e){o(this,"id",je());o(this,"isElement",()=>!1);o(this,"isText",()=>!0);o(this,"getText",()=>this.text);o(this,"toHTML",()=>this.text);this.text=e}}class O{constructor(e,t,r,n){o(this,"appendOrInsert",e=>{if(this.reference!=null){const t=this.element.children.indexOf(this.reference);this.element.children.splice(t,0,e)}else this.element.children.push(e)});o(this,"makeChildElement",(e,t)=>{const r=new Be(e,t,this.element);return this.appendOrInsert(r),new O(r,void 0,this.container,this.providers)});o(this,"makeChildText",e=>{const t=new Fe(e);return this.appendOrInsert(t),new O(this.element,t,this.container,this.providers)});o(this,"setText",e=>{this.reference&&this.reference.isText()&&(this.reference.text=e)});o(this,"getText",()=>{var e;return((e=this.reference)==null?void 0:e.getText())??this.element.getText()});o(this,"makeRef",()=>this.makeChildText(""));o(this,"makePortal",e=>{const t=new ie(e,this.element);return this.appendOrInsert(t),new O(t,void 0,this.container,this.providers)});o(this,"withProviders",e=>new O(this.element,this.reference,this.container,{...this.providers,...e}));o(this,"getProvider",e=>{if(this.providers[e]===void 0)throw new re(e);return this.providers[e]});o(this,"clear",e=>{e&&(this.reference!==void 0?this.element.removeChild(this.reference):this.element.remove())});o(this,"on",(e,t)=>this.element.on(e,t));o(this,"addClasses",e=>this.element.addClasses(e));o(this,"removeClasses",e=>this.element.removeClasses(e));o(this,"getClasses",()=>this.element.getClasses());o(this,"isBrowserDOM",()=>!1);o(this,"isHeadlessDOM",()=>!0);o(this,"setStyle",(e,t)=>this.element.setStyle(e,t));o(this,"getStyle",e=>this.element.getStyle(e));o(this,"makeAccessors",e=>this.element.makeAccessors(e));this.element=e,this.reference=t,this.container=r,this.providers=n}}const It=new Set(["checked","disabled","multiple","readonly","required","selected"]),Nt=new Set(["img","br","hr","input","link","meta"]),oe=s=>e=>{const t=e.makeChildText(s);return r=>t.clear(r)},le=s=>e=>{const t=e.makeChildText(s.value),r=s.on(n=>t.setText(n));return n=>{r(),t.clear(n)}},$t=s=>f.is(s)?le(s):oe(s),E=(...s)=>e=>{const t=s.map(r=>d(r)(e));return r=>{t.forEach(n=>n(r))}},b=()=>()=>{},Rt=s=>e=>(e.addClasses(s),t=>{t&&e.removeClasses(s)}),Vt=s=>e=>{let t=[];const r=s.on(n=>{e.removeClasses(t),t=(n??"").split(" ").filter(i=>i.length>0),e.addClasses(t)});return n=>{r(),n&&e.removeClasses(t),t.length=0}},R=(s,e)=>t=>{const{get:r,set:n}=t.makeAccessors(s),i=r();return n(e),l=>{l&&n(i)}},V=(s,e)=>t=>{const{get:r,set:n}=t.makeAccessors(s),i=r(),l=e.on(n);return a=>{l(),a&&n(i)}},x=new Proxy({},{get:(s,e)=>e==="class"?t=>f.is(t)?Vt(t):Rt((t??"").split(" ").filter(r=>r.length>0)):t=>f.is(t)?V(e,t):R(e,t)}),jt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(`data-${e}`,t):R(`data-${e}`,t)}),qt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(`aria-${e}`,t):R(`aria-${e}`,t)}),Bt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(e,t):R(e,t)}),Ft=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(e,t):R(e,t)}),d=s=>{if(s==null)return b;if(Array.isArray(s))return E(...s.map(d));if(typeof s=="string")return oe(s);if(f.is(s))return le(s);if(typeof s=="function")return s;throw new Error(`Unknown type: '${typeof s}' for child: ${s}`)},ae=(s,...e)=>t=>{const r=t.makeChildElement(s,void 0),n=e.map(i=>d(i)(r));return i=>{n.forEach(l=>l(!1)),r.clear(i)}},ce=(s,e,...t)=>r=>{const n=r.makeChildElement(s,e),i=t.map(l=>d(l)(n));return l=>{i.forEach(a=>a(!1)),n.clear(l)}},Ut=new Proxy({},{get:(s,e)=>(...t)=>ae(e,t.flatMap(d))}),Wt=new Proxy({},{get:(s,e)=>(...t)=>ae("input",x.type(e),...t)}),Gt="http://www.w3.org/2000/svg",Jt=new Proxy({},{get:(s,e)=>(...t)=>ce(e,Gt,t.flatMap(d))}),Xt="http://www.w3.org/1998/Math/MathML",Yt=new Proxy({},{get:(s,e)=>(...t)=>ce(e,Xt,t.flatMap(d))}),ue=(s,e)=>{if(typeof e=="function")return ue(s,{then:e});const t=e.pending!=null?d(e.pending()):b,r=e.then,n=e.error!=null?i=>d(e.error(i)):()=>b;return i=>{let l=!0;const a=s(),c=i.makeRef();let h=d(t)(c);return a.then(u=>{l&&(h(!0),h=d(r(u))(c))},u=>{l&&(h(!0),h=d(n(u))(c))}),u=>{l=!1,h(u),c.clear(u)}}},zt=(s,e)=>ue(()=>s,e),Ue=(s,e,t)=>r=>r.on(s,e,t),We=s=>Ue("click",e=>{e.preventDefault();const t=e.target;setTimeout(()=>{const r=t.ownerDocument!=null?t==null?void 0:t.checked:void 0;r!=null&&s(!r)},0)}),j=new Proxy({},{get:(s,e)=>t=>Ue(e,t)}),Ge=s=>e=>{const t=e.target;s(t.value)},Je=s=>e=>{const t=e.target;s(t.valueAsNumber)},Xe=s=>e=>{const t=e.target;if(t.value==="")return;const r=t.value.split("-"),n=new Date(Number(r[0]),Number(r[1])-1,Number(r[2].substring(0,2)));s(n)},Ye=s=>e=>{const t=e.target;if(t.value==="")return;const r=t.value.split("T"),n=r[0].split("-"),i=new Date(Number(n[0]),Number(n[1])-1,Number(n[2])),l=r[1].split(":");i.setHours(Number(l[0])),i.setMinutes(Number(l[1])),i.setSeconds(Number(l[2])),s(i)},Qt=s=>e=>{const t=e.target;s(t.checked)},Zt=s=>e=>{e.preventDefault(),s()},Kt=s=>e=>{e.stopPropagation(),s()},es=s=>e=>{e.stopImmediatePropagation(),s()},ts=(s,e="input")=>E(x.valueAsDate(s),j[e](Xe(s.set))),ss=(s,e="input")=>E(x.valueAsDate(s),j[e](Ye(s.set))),rs=(s,e="input")=>E(x.valueAsNumber(s),j[e](Je(s.set))),ns=(s,e="input")=>E(x.value(s),j[e](Ge(s.set))),is=s=>E(x.checked(s),We(s.set)),q=(s,e)=>{if(f.is(s))return r=>{const n=r.makeRef();let i,l;const a=s.map(u=>Object.keys(u)[0]);let c;const h=a.on(u=>{if(u!==c){l==null||l.dispose(),i==null||i(!0),l=s.map(T=>T[u]);const g=e[u](l);i=d(g)(n),c=u}});return u=>{l==null||l.dispose(),h(),n.clear(u),i==null||i(u)}};const t=Object.keys(s)[0];return d(e[t]($(s[t])))},he=(s,e,t)=>q(y.map(s,r=>({[r[e]]:r})),t),os=(s,e)=>he(s,"kind",e),ls=(s,e)=>{const t=y.map(s,([r,n])=>({[r]:n}));return q(t,e)},as=(s,e)=>he(s,"type",e),ze=(s,e)=>q(y.map(s,t=>({[t]:!0})),e),cs=(s,e={})=>t=>{const r=(e==null?void 0:e.firstSeparator)??s,n=(e==null?void 0:e.lastSeparator)??s;return ze(t.map(i=>i.isFirst?"first":i.isLast?"last":"other"),{first:r,last:n,other:s})},Qe=(s,e)=>t=>{const r=Object.values(s).reduce((n,i)=>{const l=t.getProvider(i);return Reflect.set(n,i,l),n},{});return d(e(r))(t)},us=(s,e)=>t=>{const r=[],n=Object.entries(s).reduce((i,[l,a])=>(r.push(a(c=>(Reflect.set(i,l,c),null))(t)),i),{});return r.push(d(e(n))(t)),i=>{r.forEach(l=>l(i))}},Ze=(s,e)=>Qe([s],t=>d(e(t[s]))),hs=(s,e)=>Qe(s,t=>d(e(t))),ds=s=>e=>{const t=s(e);return t==null?()=>{}:d(t)(e)},fs=s=>e=>(e.appendOrInsert(s),t=>{t&&I(s)}),Ke=(s,e,t)=>{if(f.is(s)){const r=s;return n=>{const i=n.makeRef();let l=()=>{},a=!1,c=null;const h=r.on(u=>{u==null?(l(!0),l=d((t==null?void 0:t())??b)(i),a=!1,c==null||c.dispose(),c=null):(c==null?c=P(u):c.value=u,a||(l(!0),l=d(e(c))(i),a=!0))});return u=>{c==null||c.dispose(),h(),l==null||l(u),i.clear(u)}}}else{const r=s;if(r==null){const n=t==null?void 0:t();return n!=null?d(n):b}return d(e($(r)))}},ps=(...s)=>(e,t)=>r=>{const n=r.makeRef();if(s.some(p=>!f.is(p)&&p==null))return(t!=null?d(t==null?void 0:t()):b)(n);const l=s.map(()=>null),a=s.map(p=>f.is(p)?p.value!=null:p!=null);let c=null;const h=P(a.every(p=>p)),u=(p,m)=>{if(p.value!=null){if(l[m]==null){const v=P(p.value);l[m]=v}else l[m].value=p.value;a[m]=!0}else a[m]=!1};let g=s.length-1;const T=s.map((p,m)=>{if(!f.is(p)){const v=P(p);return l[m]=v,()=>{}}return p.on(()=>{u(p,m),g===0?h.value=a.every(v=>v):g--})});return h.on(p=>{c==null||c(!0),c=null,p?c=d(e(...l))(n):c=d((t==null?void 0:t())??b)(n)}),p=>{l.forEach(m=>m==null?void 0:m.dispose()),h.dispose(),T.forEach(m=>m()),c==null||c(p),n.clear(p)}},Q=(...s)=>e=>t=>s.forEach(r=>r(t,e)),de=(s,e,t)=>Ke(y.map(s,r=>r?!0:null),e,t??void 0),ms=(s,e,t)=>de(y.map(s,r=>!r),e,t),fe=(s,e,t)=>t!=null?fe(s,r=>{const n=new F(r.index,r.total.map(i=>i-1));return E(Q(n.dispose),d(e(r)),de(r.isLast,()=>b,()=>t(n)))}):f.is(s)?r=>{const n=r.makeRef(),i=[],l=s.on(a=>{const c=i.splice(a);for(const h of c)h(!0);for(let h=i.length;h<a;h++){const u=new F(h,s);i.push(d(e(u))(n))}});return a=>{l();for(const c of i)c(a);i.length=0,n.clear(a)}}:E(...Array.from({length:s},(r,n)=>n).map(r=>d(e(new F(r,$(s)))))),gs=(s,e,t)=>{const r=y.map(s,i=>i.length),n=y.toSignal(s);return fe(r,i=>{const l=n.map(a=>a[i.index]);return E(Q(l.dispose),d(e(l,i)))},t)},et=s=>e=>{if(e.isBrowserDOM()){const t=s(e);if(t!=null)return d(t)(e)}return()=>{}},ys=s=>e=>{if(e.isHeadlessDOM()){const t=s(e);if(t)return d(t)(e)}return()=>{}},Ts=s=>et(e=>s(e.element)),Es=(s,e)=>{if(f.is(s)){const t=s;return r=>{r=r.makeRef();const n=t.map(a=>d(e(a)));let i=()=>{};const l=n.on(a=>{i(!0),i=a(r)});return a=>{l(),i(a)}}}return d(e(s))},Ss=(s,e,t=()=>b)=>q(y.map(s,r=>r.length>0?{notEmpty:r}:{whenEmpty:null}),{notEmpty:r=>e(r),whenEmpty:()=>t()}),bs=(s,e)=>t=>{const r=t.makePortal(s);return z(d(e),r)},tt=s=>Symbol(s),st=(s,e)=>t=>d(e)(t.withProviders(s)),As=(...s)=>s.length>0?s.reduceRight((e,t)=>r=>e(t(r))):d,rt=(s,e,t)=>st({[s]:e},d(t)),Ps=(s,e)=>st(s,d(e)),pe=tt("Probe"),D=new Map,nt=({identifier:s,callback:e=()=>{},child:t,timeout:r=10})=>{if(D.has(s))throw new Error(`Probe already exists: ${s.description}`);const n=setTimeout(()=>e("timeout"),r);D.set(s,{counter:0,timeoutId:n});const i=l=>{clearTimeout(n);const a=D.get(l);if(a==null)throw new Error(`Probe not found: ${l.description}`);--a.counter===0?(e("resolved"),D.delete(l)):D.set(l,a)};return E(Q(()=>clearTimeout(n)),rt(pe,i,t))},it=(s,e)=>Ze(pe,t=>{const r=D.get(s);return r==null?e(()=>{}):(clearTimeout(r.timeoutId),r.counter++,e(()=>t(s)))}),ot=Symbol("globalProbe"),_s=({callback:s,timeout:e},t)=>nt({identifier:ot,callback:s,child:t,timeout:e}),vs=s=>it(ot,s),Cs=(s,e)=>t=>{const r=t.getStyle(s);return t.setStyle(s,e),n=>{n&&t.setStyle(s,r)}},ws=(s,e)=>t=>{const r=t.getStyle(s);return e.on(n=>t.setStyle(s,n)),n=>{n&&t.setStyle(s,r)}},Os=new Proxy({},{get:(s,e)=>t=>f.is(t)?ws(e,t):Cs(e,t)});exports.Async=zt;exports.BindChecked=is;exports.BindDate=ts;exports.BindDateTime=ss;exports.BindNumber=rs;exports.BindText=ns;exports.BrowserContext=w;exports.CLASS_PLACEHOLDER_ATTR=N;exports.Computed=C;exports.Conjunction=cs;exports.DOMNode=fs;exports.El=ae;exports.ElNS=ce;exports.ElementPosition=F;exports.Empty=b;exports.Ensure=Ke;exports.EnsureAll=ps;exports.ForEach=gs;exports.Fragment=E;exports.HeadlessAdapter=Et;exports.HeadlessContext=O;exports.HeadlessElement=Be;exports.HeadlessPortal=ie;exports.HeadlessText=Fe;exports.MapSignal=Es;exports.MemoryStore=ee;exports.NotEmpty=Ss;exports.OnBrowserCtx=et;exports.OnChecked=We;exports.OnCtx=ds;exports.OnDispose=Q;exports.OnElement=Ts;exports.OnHeadlessCtx=ys;exports.OneOf=q;exports.OneOfField=he;exports.OneOfKind=os;exports.OneOfTuple=ls;exports.OneOfType=as;exports.OneOfValue=ze;exports.Portal=bs;exports.Prop=H;exports.Provide=As;exports.ProvideGlobalProbe=_s;exports.ProvideProbe=nt;exports.ProviderNotFoundError=re;exports.RenderingError=Re;exports.Repeat=fe;exports.Signal=f;exports.Task=ue;exports.TextNode=$t;exports.Unless=ms;exports.Use=us;exports.UseGlobalProbe=vs;exports.UseProbe=it;exports.UseProvider=Ze;exports.UseProviders=hs;exports.Value=y;exports.When=de;exports.WithProvider=rt;exports.WithProviders=Ps;exports._NODE_PLACEHOLDER_ATTR=ne;exports._getSelfOrParentElement=$e;exports._isElement=se;exports._makeGetter=Ne;exports._makeSetter=Ie;exports._removeDOMNode=I;exports._signalText=le;exports._staticText=oe;exports.animateSignal=mt;exports.animateSignals=xe;exports.aria=qt;exports.attr=x;exports.dataAttr=jt;exports.emitChecked=Qt;exports.emitPreventDefault=Zt;exports.emitStopImmediatePropagation=es;exports.emitStopPropagation=Kt;exports.emitValue=Ge;exports.emitValueAsDate=Xe;exports.emitValueAsDateTime=Ye;exports.emitValueAsNumber=Je;exports.endInterpolate=Ce;exports.getWindow=K;exports.guessInterpolate=we;exports.html=Ut;exports.input=Wt;exports.interpolateDate=ve;exports.interpolateNumber=Pe;exports.interpolateString=_e;exports.localStorageProp=ft;exports.makeComputed=Y;exports.makeComputedOf=ht;exports.makeComputedRecord=gt;exports.makeEffect=Oe;exports.makeEffectOf=dt;exports.makeProp=P;exports.makeProviderMark=tt;exports.makeSignal=$;exports.math=Yt;exports.mathAttr=Ft;exports.on=j;exports.probeMarker=pe;exports.render=yt;exports.renderWithContext=z;exports.renderableOfTNode=d;exports.restoreTempoPlaceholders=Dt;exports.runHeadless=Tt;exports.sessionStorageProp=pt;exports.storedProp=te;exports.style=Os;exports.svg=Jt;exports.svgAttr=Bt;
1
+ "use strict";var at=Object.defineProperty;var Te=s=>{throw TypeError(s)};var ct=(s,e,t)=>e in s?at(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>ct(s,typeof e!="symbol"?e+"":e,t),be=(s,e,t)=>e.has(s)||Te("Cannot "+t);var K=(s,e,t)=>(be(s,e,"read from private field"),t?t.call(s):e.get(s)),Se=(s,e,t)=>e.has(s)?Te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Ae=(s,e,t,r)=>(be(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pe=(s,e,t)=>s+(e-s)*t,Ee=97,we=(s,e,t)=>{const r=Math.max(s.length,e.length);let n="";for(let i=0;i<r;i++){let l=s.charCodeAt(i);isNaN(l)&&(l=Ee);let a=e.charCodeAt(i);isNaN(a)&&(a=Ee),n+=String.fromCharCode(l+(a-l)*t)}return n},Ce=(s,e,t)=>new Date(s.getTime()+(e.getTime()-s.getTime())*t),ve=(s,e)=>e,Oe=s=>typeof s=="number"?Pe:typeof s=="string"?we:s instanceof Date?Ce:ve;var M;class F{constructor(e,t){o(this,"counter");o(this,"isFirst");o(this,"isEven");o(this,"isOdd");Se(this,M);o(this,"dispose",()=>{this.total.dispose()});this.index=e,this.total=t,this.counter=e+1,this.isFirst=e===0,this.isEven=e%2===1,this.isOdd=e%2===0}get isLast(){return K(this,M)==null&&Ae(this,M,this.total.map(e=>this.counter===e)),K(this,M)}}M=new WeakMap;const H=class H{constructor(e,t){o(this,"$__signal__",!0);o(this,"_value");o(this,"_derivatives",[]);o(this,"_onValueListeners",[]);o(this,"_onDisposeListeners",[]);o(this,"get",()=>this._value);o(this,"hasListeners",()=>this._onValueListeners.length>0);o(this,"on",(e,t={})=>{t.skipInitial||e(this.get(),void 0);const r=t.once?(i,l)=>{n(),e(i,l)}:e;this._onValueListeners.push(r);const n=()=>{this._onValueListeners.splice(this._onValueListeners.indexOf(r),1),t.abortSignal!=null&&t.abortSignal.removeEventListener("abort",n)};return t.abortSignal!=null&&t.abortSignal.addEventListener("abort",n),n});o(this,"_setAndNotify",(e,t)=>{if(this._disposed)return;const r=this._value,n=this.equals(r,e);n||(this._value=e),(t||!n)&&this._onValueListeners.forEach(i=>i(e,r))});o(this,"_disposed",!1);o(this,"isDisposed",()=>this._disposed);o(this,"onDispose",e=>{this._onDisposeListeners.push(e)});o(this,"dispose",()=>{this._disposed||(this._disposed=!0,this._onDisposeListeners.forEach(e=>e()),this._onDisposeListeners.length=0,this._derivatives.length=0)});o(this,"map",(e,t=(r,n)=>r===n)=>{const r=new C(()=>{try{return e(this.get())}catch(n){throw console.error("Error in Signal.map:",n),n}},t);return this.setDerivative(r),r});o(this,"flatMap",(e,t=(r,n)=>r===n)=>{const r=new C(()=>{try{return e(this.get()).get()}catch(n){throw console.error("Error in Signal.flatMap:",n),n}},t);return this.setDerivative(r),r});o(this,"tap",e=>this.map(t=>(e(t),t)));o(this,"at",e=>this.map(t=>t[e]));o(this,"_$");o(this,"filter",(e,t)=>{let r=t??this.get();const n=new C(()=>{try{const i=this.get();return r=e(i)?i:r}catch(i){throw console.error("Error in Signal.filter:",i),i}},this.equals);return this.setDerivative(n),n});o(this,"filterMap",(e,t,r=(n,i)=>n===i)=>{let n=t;const i=new C(()=>{try{const l=this.get(),a=e(l);return n=a??n}catch(l){throw console.error("Error in Signal.filterMap:",l),l}},r);return this.setDerivative(i),i});o(this,"mapAsync",(e,t,r,n=(i,l)=>i===l)=>{const i=_(t,n);let l=0,a=new AbortController;return i.onDispose(this.on(async c=>{const h=++l;a.abort(),a=new AbortController;try{const u=await e(c,{abortSignal:a.signal});h===l&&i.set(u)}catch(u){if(h===l)if(r!=null)i.set(r(u));else throw u}})),i});o(this,"mapMaybe",(e,t)=>this.map(r=>e(r)??t));o(this,"feedProp",(e,t=!1)=>{const r=this.on(e.set);return e.onDispose(r),t?this.onDispose(e.dispose):this.onDispose(r),e});o(this,"deriveProp",({autoDisposeProp:e=!0,equals:t}={})=>this.feedProp(_(this.get(),t),e));o(this,"derive",()=>this.map(e=>e));o(this,"count",()=>{let e=0;return this.map(()=>++e)});o(this,"setDerivative",e=>{this._derivatives.push(e),e.onDispose(()=>{this._derivatives.splice(this._derivatives.indexOf(e),1)}),e.onDispose(this.on(e.setDirty)),this.onDispose(e.dispose)});this.equals=t,this._value=e}get value(){return this._value}get $(){return this._$!==void 0?this._$:this._$=new Proxy(this,{get:(e,t)=>this.at(t)})}};o(H,"ofPromise",(e,t,r,n=(i,l)=>i===l)=>{const i=new H(t,n);return e.then(l=>i._setAndNotify(l,!1)).catch(l=>{r!=null?i._setAndNotify(r(l),!1):console.error("Unhandled promise rejection in Signal.ofPromise:",l)}),i}),o(H,"is",e=>e!=null&&e.$__signal__===!0);let f=H;const ut=typeof queueMicrotask=="function"?queueMicrotask:s=>Promise.resolve().then(s);class C extends f{constructor(t,r){super(void 0,r);o(this,"$__computed__",!0);o(this,"_isDirty",!1);o(this,"setDirty",()=>{this._isDirty||this._disposed||(this._isDirty=!0,this._derivatives.forEach(t=>t.setDirty()),this._scheduleNotify())});o(this,"_scheduleCount",0);o(this,"_scheduleNotify",()=>{const t=++this._scheduleCount;ut(()=>{this._scheduleCount!==t||this._disposed||this._isDirty&&(this._isDirty=!1,this._setAndNotify(this._fn(),!1))})});o(this,"get",()=>(this._isDirty&&(this._isDirty=!1,this._setAndNotify(this._fn(),!0)),this._value));this._fn=t,this.setDirty()}static is(t){return t!=null&&t.$__computed__===!0}get value(){return this.get()}}const X=class X extends f{constructor(){super(...arguments);o(this,"$__prop__",!0);o(this,"set",t=>{this._setAndNotify(t,!1)});o(this,"update",t=>{this._setAndNotify(t(this.get()),!1)});o(this,"reducer",(t,...r)=>{const n=this;return function i(l){const a=n.value;n.update(c=>t(c,l)),!n.equals(a,n.value)&&r.forEach(c=>c({previousState:a,state:n.value,action:l,dispatch:i}))}});o(this,"iso",(t,r,n=(i,l)=>i===l)=>{const i=new X(t(this.get()),n);return i.onDispose(this.on(l=>i.set(t(l)))),i.on(l=>this._setAndNotify(r(l),!1)),i});o(this,"atProp",t=>this.iso(r=>r[t],r=>({...this.value,[t]:r})))}get value(){return this.get()}set value(t){this._setAndNotify(t,!1)}};o(X,"is",t=>t!=null&&t.$__prop__===!0);let N=X;const Y=(s,e,t=(r,n)=>r===n)=>{const r=new C(s,t);return e.forEach(n=>n.setDerivative(r)),r},xe=(s,e,t={})=>{let r=t.once?()=>{i(),s()}:s;if(t.skipInitial){let l=!1;const a=r;r=()=>{l?a():l=!0}}const n=Y(r,e),i=()=>{n.dispose(),t.abortSignal!=null&&t.abortSignal.removeEventListener("abort",i)};return t.abortSignal!=null&&t.abortSignal.addEventListener("abort",i),i},_=(s,e=(t,r)=>t===r)=>new N(s,e),$=(s,e=(t,r)=>t===r)=>new f(s,e),ee=()=>typeof window<"u"?window:void 0,y={map:(s,e)=>f.is(s)?s.map(e):e(s),toSignal:(s,e)=>f.is(s)?s:$(s,e),maybeToSignal:(s,e)=>{if(s!=null)return y.toSignal(s,e)},get:s=>f.is(s)?s.get():s,on:(s,e)=>f.is(s)?s.on(e):(e(s),()=>{}),dispose:s=>{f.is(s)&&s.dispose()},deriveProp:(s,{autoDisposeProp:e=!0,equals:t}={})=>f.is(s)?s.deriveProp({autoDisposeProp:e,equals:t}):_(s,t)},De=(...s)=>(e,t)=>{const r=s.filter(n=>f.is(n));return Y(()=>e(...s.map(n=>y.get(n))),r,t)},ht=s=>{const e=Object.keys(s);return De(...Object.values(s))((...t)=>Object.fromEntries(e.map((r,n)=>[r,t[n]])))},dt=(...s)=>(e,t={})=>{const r=s.filter(n=>f.is(n));return xe(()=>e(...s.map(y.get)),r,t)};class te{constructor(){o(this,"_store",new Map);o(this,"getItem",e=>this._store.get(e)??null);o(this,"setItem",(e,t)=>{this._store.set(e,t)})}}const se=({key:s,defaultValue:e,store:t,serialize:r=JSON.stringify,deserialize:n=JSON.parse,equals:i=(a,c)=>a===c,onLoad:l=a=>a})=>{const a=t.getItem(s),c=new N(a!=null?l(n(a)):typeof e=="function"?e():e,i);return c.on(h=>{t.setItem(s,r(h))}),c},ft=s=>{var e;return se({...s,store:((e=ee())==null?void 0:e.localStorage)??new te})},pt=s=>{var e;return se({...s,store:((e=ee())==null?void 0:e.sessionStorage)??new te})};function _e(s){return typeof requestAnimationFrame=="function"?requestAnimationFrame(s):setTimeout(s,0)}const Le=(s,e,t,r)=>{const n=(r==null?void 0:r.duration)??300,i=(r==null?void 0:r.easing)??(E=>E),l=(r==null?void 0:r.equals)??((E,B)=>E===B);let a=r==null?void 0:r.interpolate,c=s,h=e(),u=performance.now(),g=null,T=!0;const p=new C(e,l),m=_(s,l);m.onDispose(()=>{g!==null&&cancelAnimationFrame(g)}),m.onDispose(p.dispose),t.forEach(E=>{E.setDerivative(p),E.onDispose(m.dispose)});const w=E=>{h=E,u=performance.now(),c=m.value,T&&(T=!1,g=_e(ge))},ge=()=>{const B=(performance.now()-u)/y.get(n),lt=i(B);a==null&&(a=Oe(c));let ye=a(c,h,lt);B>=1?(T=!0,ye=h):g=_e(ge),m.set(ye)};return p.on(w),m},mt=(s,e)=>{const{initialValue:t,...r}=e??{};return Le(t??s.get(),s.get,[s],r)},gt=(s,e)=>{const{signals:t,literals:r}=Object.entries(s).reduce(({signals:i,literals:l},[a,c])=>(f.is(c)?i.push([a,c]):l[a]=c,{signals:i,literals:l}),{signals:[],literals:{}}),n=t.map(([,i])=>i);return Y(()=>(t.forEach(([i,l])=>r[i]=l.value),e(r)),n)},Me=new Set(["checked","disabled","hidden"]),He=new Set(["selected"]),Ne=new Set(["rowSpan","colSpan","tabIndex","valueAsNumber"]),ke=new Set(["valueAsDate"]),Ie=new Set(["value","textContent","innerText","innerHTML","outerHTML","className","classList"]),$e=(s,e)=>He.has(s)?t=>{t==null||t!==!0?e.removeAttribute(s):e.setAttribute(s,"")}:Me.has(s)?t=>{t==null?e[s]=null:e[s]=!!t}:Ne.has(s)?t=>{t==null?e[s]=null:e[s]=Number(t)}:ke.has(s)?t=>{t==null?e[s]=null:e[s]=t}:Ie.has(s)?t=>{t==null?e[s]=null:e[s]=String(t)}:t=>{t==null?e.removeAttribute(s):e.setAttribute(s,t)},Re=(s,e)=>He.has(s)?()=>e.hasAttribute(s):Me.has(s)?()=>!!e[s]:Ne.has(s)?()=>Number(e[s]):ke.has(s)?()=>e[s]:Ie.has(s)?()=>String(e[s]):()=>e.getAttribute(s),k=s=>{const e=s;e&&e.onblur&&(e.onblur=null),!(!s||s.ownerDocument===void 0)&&s.parentElement&&s.parentElement.removeChild(s)},Ve=s=>re(s)?s:s.parentElement,re=s=>s.nodeType===1;class ne extends Error{constructor(e){super(`Provider not found: ${e.description}`)}}class v{constructor(e,t,r,n){o(this,"createElement",(e,t)=>t!==void 0?this.document.createElementNS(t,e):this.document.createElement(e));o(this,"makeChildElement",(e,t)=>{const r=this.createElement(e,t);return this.appendOrInsert(r),this.withElement(r)});o(this,"createText",e=>this.document.createTextNode(e));o(this,"makeChildText",e=>{const t=this.createText(e);return this.appendOrInsert(t),this.withReference(t)});o(this,"setText",e=>{this.reference.nodeValue=e});o(this,"getText",()=>{var e;return((e=this.reference)==null?void 0:e.nodeValue)??this.element.textContent??""});o(this,"makeRef",()=>{const e=this.createText("");return this.appendOrInsert(e),this.withReference(e)});o(this,"appendOrInsert",e=>{this.reference===void 0?this.element.appendChild(e):this.element.insertBefore(e,this.reference)});o(this,"withElement",e=>new v(this.document,e,void 0,this.providers));o(this,"makePortal",e=>{const t=this.document.querySelector(e);if(t==null)throw new Error(`Cannot find element by selector for portal: ${e}`);return this.withElement(t)});o(this,"withReference",e=>new v(this.document,this.element,e,this.providers));o(this,"setProvider",(e,t)=>new v(this.document,this.element,this.reference,{...this.providers,[e]:t}));o(this,"getProvider",e=>{if(this.providers[e]===void 0)throw new ne(e);return this.providers[e]});o(this,"clear",e=>{e&&(this.reference!==void 0?k(this.reference):k(this.element))});o(this,"addClasses",e=>{this.element.classList.add(...e)});o(this,"removeClasses",e=>{this.element.classList.remove(...e)});o(this,"getClasses",()=>Array.from(this.element.classList));o(this,"on",(e,t,r)=>(this.element.addEventListener(e,t,r),n=>{n&&this.element.removeEventListener(e,t,r)}));o(this,"isBrowserDOM",()=>!0);o(this,"isBrowser",()=>!0);o(this,"isHeadlessDOM",()=>!1);o(this,"isHeadless",()=>!1);o(this,"setStyle",(e,t)=>{this.element.style[e]=t});o(this,"getStyle",e=>this.element.style[e]);o(this,"makeAccessors",e=>({get:Re(e,this.element),set:$e(e,this.element)}));this.document=e,this.element=t,this.reference=r,this.providers=n}static of(e,t){return new v(e.ownerDocument,e,t,{})}}const je=s=>Symbol(s),z=(s,e)=>{const t=s(e);return(r=!0)=>t(r)},yt=(s,e,{doc:t,clear:r,disposeWithParent:n=!0}={})=>{const i=typeof e=="string"?(t??document).querySelector(e):e;if(i===null)throw new qe(`Cannot find element by selector for render: ${e}`);r!==!1&&(t??i.ownerDocument)!=null&&i.nodeType===1&&(i.innerHTML="");const l=Ve(i),a=re(i)?void 0:i,c=v.of(l,a),h=z(s,c);let u;return n&&(u=new MutationObserver(g=>{var T;(T=g[0])==null||T.removedNodes.forEach(p=>{p===i&&(h(i.nodeType!==Node.ELEMENT_NODE),u==null||u.disconnect())})}),u.observe(i.parentElement,{childList:!0,subtree:!1,attributes:!1})),()=>{u==null||u.disconnect(),h(!0)}},Tt=(s,{startUrl:e="https://example.com",selector:t=":root"}={})=>{const r=y.toSignal(e).deriveProp(),n=new oe(t,void 0),i=new O(n,void 0,{currentURL:r},{});return{clear:z(s(),i),root:n,currentURL:r}};class qe extends Error{constructor(e){super(e)}}const ie="data-tts-node",I="data-tts-class",W="data-tts-style",U="data-tts-html",G="data-tts-text",J="data-tts-attrs";class bt{constructor({select:e,getAttribute:t,setAttribute:r,getClass:n,setClass:i,getStyles:l,setStyles:a,appendHTML:c,getInnerHTML:h,setInnerHTML:u,getInnerText:g,setInnerText:T}){o(this,"select");o(this,"getAttribute");o(this,"setAttribute");o(this,"getClass");o(this,"setClass");o(this,"getStyles");o(this,"setStyles");o(this,"appendHTML");o(this,"getInnerHTML");o(this,"setInnerHTML");o(this,"getInnerText");o(this,"setInnerText");o(this,"setFromRoot",(e,t)=>{e.getPortals().forEach(n=>{for(const i of this.select(n.selector)){if(i==null)throw new Error(`Cannot find element by selector for render: ${n.selector}`);if(n.hasChildren()&&this.appendHTML(i,n.contentToHTML(t)),n.hasInnerHTML()){if(t){const l=this.getInnerHTML(i);l!=null&&this.setAttribute(i,U,l)}this.setInnerHTML(i,n.getInnerHTML())}if(n.hasInnerText()){if(t){const l=this.getInnerText(i);l!=null&&this.setAttribute(i,G,l)}this.setInnerText(i,n.getInnerText())}if(n.hasClasses()){if(t){const l=this.getClass(i);l!=null&&this.setAttribute(i,I,l)}this.setClass(i,n.getClasses().join(" "))}if(n.hasStyles()){if(t){const l=this.getStyles(i);Object.keys(l).length>0&&this.setAttribute(i,W,JSON.stringify(l))}this.setStyles(i,n.getStyles())}if(n.hasAttributes()){const l=n.getAttributes();if(t){const a=[];l.forEach(([c])=>{const h=this.getAttribute(i,c);h!=null&&a.push([c,h])}),a.length>0&&this.setAttribute(i,J,JSON.stringify(Object.fromEntries(a)))}l.forEach(([a,c])=>{this.setAttribute(i,a,c)})}}})});this.select=e,this.getAttribute=t,this.setAttribute=r,this.getClass=n,this.setClass=i,this.getStyles=l,this.setStyles=a,this.appendHTML=c,this.getInnerHTML=h,this.setInnerHTML=u,this.getInnerText=g,this.setInnerText=T}}const St=()=>{document.querySelectorAll(`[${ie}]`).forEach(k)},At=s=>{const e=s.getAttribute(I);s.removeAttribute(I),e!=null&&s.setAttribute("class",e)},Et=()=>{document.querySelectorAll(`[${I}]`).forEach(e=>At(e))},_t=s=>{const e=s.getAttribute(U);s.removeAttribute(U),e!=null&&(s.innerHTML=e)},Pt=()=>{document.querySelectorAll(`[${U}]`).forEach(e=>_t(e))},wt=s=>{const e=s.getAttribute(G);s.removeAttribute(G),e!=null&&(s.innerText=e)},Ct=()=>{document.querySelectorAll(`[${G}]`).forEach(e=>wt(e))},Be=s=>JSON.parse(s.replace(/&quot;/g,'"')),vt=s=>{const e=s.getAttribute(W);if(s.removeAttribute(W),e!=null){const t=Be(e);Object.entries(t).forEach(([r,n])=>{s.style.setProperty(r,n)})}},Ot=()=>{document.querySelectorAll(`[${W}]`).forEach(e=>vt(e))},xt=s=>{const e=s.getAttribute(J);if(s.removeAttribute(J),e!=null){const t=Be(e);Object.entries(t).forEach(([r,n])=>{n==null?s.removeAttribute(r):s.setAttribute(r,n)})}},Dt=()=>{document.querySelectorAll(`[${J}]`).forEach(e=>xt(e))},Lt=()=>{St(),Et(),Ct(),Pt(),Ot(),Dt()},S=Symbol("class"),P=Symbol("style"),D=Symbol("handler"),Fe=()=>Math.random().toString(36).substring(2,15),Mt=s=>s.replace(/<[^>]*>?/g,"");class We{constructor(e){o(this,"id",Fe());o(this,"properties",{});o(this,"children",[]);o(this,"isElement",()=>!0);o(this,"isText",()=>!1);o(this,"getText",()=>this.properties.innerText!=null?this.properties.innerText:this.properties.innerHTML!=null?Mt(this.properties.innerHTML):this.children.map(e=>e.getText()).join(""));o(this,"removeChild",e=>{const t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)});o(this,"remove",()=>{if(this.parent!=null)this.parent.removeChild(this);else throw new Error("Parent is undefined")});o(this,"getPortals",()=>{const e=this.elements().flatMap(t=>t.isPortal()?[t,...t.getPortals()]:t.getPortals());return this.isPortal()&&e.unshift(this),e});o(this,"elements",()=>this.children.filter(e=>e.isElement()));o(this,"hasInnerHTML",()=>this.properties.innerHTML!=null);o(this,"getInnerHTML",()=>this.properties.innerHTML??"");o(this,"getInnerText",()=>this.properties.innerText??"");o(this,"hasInnerText",()=>this.properties.innerText!=null);o(this,"hasChildren",()=>this.children.length>0);o(this,"hasClasses",()=>this.properties[S]!=null);o(this,"hasStyles",()=>this.properties[P]!=null);o(this,"hasAttributes",()=>Object.keys(this.properties).length>0);o(this,"hasHandlers",()=>this.properties[D]!=null);o(this,"hasRenderableProperties",()=>this.hasClasses()||this.hasAttributes()||this.hasStyles());o(this,"getById",e=>{if(this.properties.id===e)return this;for(const t of this.elements()){const r=t.getById(e);if(r!=null)return r}});o(this,"trigger",(e,t)=>{((this.properties[D]??{})[e]??[]).forEach(n=>n(t))});o(this,"click",()=>{this.trigger("click",{})});o(this,"on",(e,t,r)=>{var a;const n=(a=this.properties)[D]??(a[D]={}),i=r!=null&&r.once?c=>{l(),t(c)}:c=>t(c);n[e]=[...n[e]??[],i];const l=()=>{const c=n[e]??[],h=c.indexOf(i);h!==-1&&(c.splice(h,1),c.length===0?(delete n[e],Object.keys(n).length===0&&delete this.properties[D]):n[e]=c,(r==null?void 0:r.signal)!=null&&r.signal.removeEventListener("abort",l))};return(r==null?void 0:r.signal)!=null&&r.signal.addEventListener("abort",l),l});o(this,"addClasses",e=>{var r;if(e.length===0)return;const t=(r=this.properties)[S]??(r[S]=[]);e.forEach(n=>{t.includes(n)||t.push(n)})});o(this,"removeClasses",e=>{var r;if(e.length===0)return;const t=(r=this.properties)[S]??(r[S]=[]);e.forEach(n=>{const i=t.indexOf(n);i!==-1&&t.splice(i,1)}),t.length===0&&delete this.properties[S]});o(this,"getClasses",()=>this.properties[S]??[]);o(this,"getAttributes",()=>Object.entries(this.properties).filter(([e])=>!["innerText","innerHTML"].includes(e)));o(this,"getVisibleAttributes",()=>Reflect.ownKeys(this.properties).flatMap(e=>e===S?[["class",this.getClasses()]]:e===P?[["style",this.getStyles()]]:typeof e=="string"?[[e,String(this.properties[e])]]:[]));o(this,"setStyle",(e,t)=>{var n;const r=(n=this.properties)[P]??(n[P]={});r[e]=t,t===""&&(delete r[e],Object.keys(r).length===0&&delete this.properties[P])});o(this,"getStyle",e=>{var t;return((t=this.properties[P])==null?void 0:t[e])??""});o(this,"getStyles",()=>this.properties[P]??{});o(this,"makeAccessors",e=>{const t=this.properties;return{get:()=>t[e],set:r=>t[e]=r}});this.parent=e}}const Ht=s=>s.replace(/"/g,"&quot;"),Nt=s=>s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");class Ue extends We{constructor(t,r,n){super(n);o(this,"isPortal",()=>!1);o(this,"toHTML",(t=!1)=>{const r=this.children.map(c=>c.toHTML()).join(""),n=this.namespace?` xmlns="${this.namespace}"`:"";let i=null;const l=this.getVisibleAttributes().map(([c,h])=>c==="class"?` class="${h.join(" ")}"`:c==="style"?typeof h=="string"?` style="${h}"`:` style="${Object.entries(h).map(([u,g])=>`${u}: ${g};`).join(" ")}"`:kt.has(c)?` ${c}`:c==="innerHTML"?(i=h,""):c==="innerText"?(i=Nt(h),""):` ${c}="${Ht(h)}"`).join(""),a=t?` ${ie}`:"";return It.has(this.tagName)&&r===""?`<${this.tagName}${n}${l}${a} />`:`<${this.tagName}${n}${l}${a}>${i??r}</${this.tagName}>`});this.tagName=t,this.namespace=r}}class oe extends We{constructor(t,r){super(r);o(this,"isPortal",()=>!0);o(this,"toHTML",()=>"");o(this,"contentToHTML",(t=!1)=>this.children.map(r=>r.toHTML(t)).join(""));this.selector=t}}class Ge{constructor(e){o(this,"id",Fe());o(this,"isElement",()=>!1);o(this,"isText",()=>!0);o(this,"getText",()=>this.text);o(this,"toHTML",()=>this.text);this.text=e}}class O{constructor(e,t,r,n){o(this,"appendOrInsert",e=>{if(this.reference!=null){const t=this.element.children.indexOf(this.reference);this.element.children.splice(t,0,e)}else this.element.children.push(e)});o(this,"makeChildElement",(e,t)=>{const r=new Ue(e,t,this.element);return this.appendOrInsert(r),new O(r,void 0,this.container,this.providers)});o(this,"makeChildText",e=>{const t=new Ge(e);return this.appendOrInsert(t),new O(this.element,t,this.container,this.providers)});o(this,"setText",e=>{this.reference&&this.reference.isText()&&(this.reference.text=e)});o(this,"getText",()=>{var e;return((e=this.reference)==null?void 0:e.getText())??this.element.getText()});o(this,"makeRef",()=>this.makeChildText(""));o(this,"makePortal",e=>{const t=new oe(e,this.element);return this.appendOrInsert(t),new O(t,void 0,this.container,this.providers)});o(this,"setProvider",(e,t)=>new O(this.element,this.reference,this.container,{...this.providers,[e]:t}));o(this,"getProvider",e=>{if(this.providers[e]===void 0)throw new ne(e);return this.providers[e]});o(this,"clear",e=>{e&&(this.reference!==void 0?this.element.removeChild(this.reference):this.element.remove())});o(this,"on",(e,t)=>this.element.on(e,t));o(this,"addClasses",e=>this.element.addClasses(e));o(this,"removeClasses",e=>this.element.removeClasses(e));o(this,"getClasses",()=>this.element.getClasses());o(this,"isBrowserDOM",()=>!1);o(this,"isBrowser",()=>!1);o(this,"isHeadlessDOM",()=>!0);o(this,"isHeadless",()=>!0);o(this,"setStyle",(e,t)=>this.element.setStyle(e,t));o(this,"getStyle",e=>this.element.getStyle(e));o(this,"makeAccessors",e=>this.element.makeAccessors(e));this.element=e,this.reference=t,this.container=r,this.providers=n}}const kt=new Set(["checked","disabled","multiple","readonly","required","selected"]),It=new Set(["img","br","hr","input","link","meta"]),le=s=>e=>e.makeChildText(s).clear,ae=s=>e=>{const t=e.makeChildText(s.value),r=s.on(t.setText);return n=>{r(),t.clear(n)}},$t=s=>f.is(s)?ae(s):le(s),b=(...s)=>e=>{const t=s.map(r=>d(r)(e));return r=>{t.forEach(n=>n(r))}},A=()=>()=>{},Rt=s=>e=>(e.addClasses(s),t=>{t&&e.removeClasses(s)}),Vt=s=>e=>{let t=[];const r=s.on(n=>{e.removeClasses(t),t=(n??"").split(" ").filter(i=>i.length>0),e.addClasses(t)});return n=>{r(),n&&e.removeClasses(t),t.length=0}},R=(s,e)=>t=>{const{get:r,set:n}=t.makeAccessors(s),i=r();return n(e),l=>{l&&n(i)}},V=(s,e)=>t=>{const{get:r,set:n}=t.makeAccessors(s),i=r(),l=e.on(n);return a=>{l(),a&&n(i)}},x=new Proxy({},{get:(s,e)=>e==="class"?t=>f.is(t)?Vt(t):Rt((t??"").split(" ").filter(r=>r.length>0)):t=>f.is(t)?V(e,t):R(e,t)}),jt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(`data-${e}`,t):R(`data-${e}`,t)}),qt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(`aria-${e}`,t):R(`aria-${e}`,t)}),Bt=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(e,t):R(e,t)}),Ft=new Proxy({},{get:(s,e)=>t=>f.is(t)?V(e,t):R(e,t)}),d=s=>{if(s==null)return A;if(Array.isArray(s))return b(...s.map(d));if(typeof s=="string")return le(s);if(f.is(s))return ae(s);if(typeof s=="function")return s;throw new Error(`Unknown type: '${typeof s}' for child: ${s}`)},ce=(s,...e)=>t=>{const r=t.makeChildElement(s,void 0),n=e.map(i=>d(i)(r));return i=>{n.forEach(l=>l(!1)),r.clear(i)}},ue=(s,e,...t)=>r=>{const n=r.makeChildElement(s,e),i=t.map(l=>d(l)(n));return l=>{i.forEach(a=>a(!1)),n.clear(l)}},Wt=new Proxy({},{get:(s,e)=>(...t)=>ce(e,t.flatMap(d))}),Ut=new Proxy({},{get:(s,e)=>(...t)=>ce("input",x.type(e),...t)}),Gt="http://www.w3.org/2000/svg",Jt=new Proxy({},{get:(s,e)=>(...t)=>ue(e,Gt,t.flatMap(d))}),Xt="http://www.w3.org/1998/Math/MathML",Yt=new Proxy({},{get:(s,e)=>(...t)=>ue(e,Xt,t.flatMap(d))}),he=(s,e)=>{if(typeof e=="function")return he(s,{then:e});const t=e.pending!=null?d(e.pending()):A,r=e.then,n=e.error!=null?i=>d(e.error(i)):()=>A;return i=>{let l=!0;const a=s(),c=i.makeRef();let h=d(t)(c);return a.then(u=>{l&&(h(!0),h=d(r(u))(c))},u=>{l&&(h(!0),h=d(n(u))(c))}),u=>{l=!1,h(u),c.clear(u)}}},zt=(s,e)=>he(()=>s,e),Je=(s,e,t)=>r=>r.on(s,e,t),Xe=s=>Je("click",e=>{e.preventDefault();const t=e.target;setTimeout(()=>{const r=t.ownerDocument!=null?t==null?void 0:t.checked:void 0;r!=null&&s(!r)},0)}),j=new Proxy({},{get:(s,e)=>t=>Je(e,t)}),Ye=s=>e=>{const t=e.target;s(t.value)},ze=s=>e=>{const t=e.target;s(t.valueAsNumber)},Qe=s=>e=>{const t=e.target;if(t.value==="")return;const r=t.value.split("-"),n=new Date(Number(r[0]),Number(r[1])-1,Number(r[2].substring(0,2)));s(n)},Qt=s=>e=>{const t=e.target;if(t.value===""){s(null);return}const r=t.value.split("-"),n=new Date(Number(r[0]),Number(r[1])-1,Number(r[2].substring(0,2)));s(n)},Ze=s=>e=>{const t=e.target;if(t.value==="")return;const r=t.value.split("T"),n=r[0].split("-"),i=new Date(Number(n[0]),Number(n[1])-1,Number(n[2])),l=r[1].split(":");i.setHours(Number(l[0])),i.setMinutes(Number(l[1])),i.setSeconds(Number(l[2])),s(i)},Zt=s=>e=>{const t=e.target;if(t.value===""){s(null);return}const r=t.value.split("T");if(r.length!==2){s(null);return}const n=r[0].split("-"),i=new Date(Number(n[0]),Number(n[1])-1,Number(n[2])),l=r[1].split(":");i.setHours(Number(l[0]??0)),i.setMinutes(Number(l[1]??0)),i.setSeconds(Number(l[2]??0)),s(i)},Kt=s=>e=>{const t=e.target;s(t.checked)},es=s=>e=>{e.preventDefault(),s()},ts=s=>e=>{e.stopPropagation(),s()},ss=s=>e=>{e.stopImmediatePropagation(),s()},rs=(s,e="input")=>b(x.valueAsDate(s),j[e](Qe(s.set))),ns=(s,e="input")=>b(x.valueAsDate(s),j[e](Ze(s.set))),is=(s,e="input")=>b(x.valueAsNumber(s),j[e](ze(s.set))),os=(s,e="input")=>b(x.value(s),j[e](Ye(s.set))),ls=s=>b(x.checked(s),Xe(s.set)),q=(s,e)=>{if(f.is(s))return r=>{const n=r.makeRef();let i,l;const a=s.map(u=>Object.keys(u)[0]);let c;const h=a.on(u=>{if(u!==c){c=u,l==null||l.dispose(),i==null||i(!0),l=s.map(T=>T[u]);const g=e[u](l);i=d(g)(n)}});return u=>{l==null||l.dispose(),h(),n.clear(u),i==null||i(u)}};const t=Object.keys(s)[0];return d(e[t]($(s[t])))},de=(s,e,t)=>q(y.map(s,r=>({[r[e]]:r})),t),as=(s,e)=>de(s,"kind",e),cs=(s,e)=>{const t=y.map(s,([r,n])=>({[r]:n}));return q(t,e)},us=(s,e)=>de(s,"type",e),Ke=(s,e)=>q(y.map(s,t=>({[t]:!0})),e),hs=(s,e={})=>t=>{const r=(e==null?void 0:e.firstSeparator)??s,n=(e==null?void 0:e.lastSeparator)??s;return Ke(t.map(i=>i.isFirst?"first":i.isLast?"last":"other"),{first:r,last:n,other:s})},ds=s=>e=>(e.appendOrInsert(s),t=>{t&&k(s)}),et=(s,e,t)=>{if(f.is(s)){const r=s;return n=>{const i=n.makeRef();let l=()=>{},a=!1,c=null;const h=r.on(u=>{u==null?(l(!0),l=d((t==null?void 0:t())??A)(i),a=!1,c==null||c.dispose(),c=null):(c==null?c=_(u):c.value=u,a||(l(!0),l=d(e(c))(i),a=!0))});return u=>{c==null||c.dispose(),h(),l==null||l(u),i.clear(u)}}}else{const r=s;if(r==null){const n=t==null?void 0:t();return n!=null?d(n):A}return d(e($(r)))}},fs=(...s)=>(e,t)=>r=>{const n=r.makeRef();if(s.some(p=>!f.is(p)&&p==null))return(t!=null?d(t==null?void 0:t()):A)(n);const l=s.map(()=>null),a=s.map(p=>f.is(p)?p.value!=null:p!=null);let c=null;const h=_(a.every(p=>p)),u=(p,m)=>{if(p.value!=null){if(l[m]==null){const w=_(p.value);l[m]=w}else l[m].value=p.value;a[m]=!0}else a[m]=!1};let g=s.length-1;const T=s.map((p,m)=>{if(!f.is(p)){const w=_(p);return l[m]=w,()=>{}}return p.on(()=>{u(p,m),g===0?h.value=a.every(w=>w):g--})});return h.on(p=>{c==null||c(!0),c=null,p?c=d(e(...l))(n):c=d((t==null?void 0:t())??A)(n)}),p=>{l.forEach(m=>m==null?void 0:m.dispose()),h.dispose(),T.forEach(m=>m()),c==null||c(p),n.clear(p)}},Q=(...s)=>e=>t=>s.forEach(r=>r(t,e)),fe=(s,e,t)=>et(y.map(s,r=>r?!0:null),e,t??void 0),ps=(s,e,t)=>fe(y.map(s,r=>!r),e,t),pe=(s,e,t)=>t!=null?pe(s,r=>{const n=new F(r.index,r.total.map(i=>i-1));return b(Q(n.dispose),d(e(r)),fe(r.isLast,()=>A,()=>t(n)))}):f.is(s)?r=>{const n=r.makeRef(),i=[],l=s.on(a=>{const c=i.splice(a);for(const h of c)h(!0);for(let h=i.length;h<a;h++){const u=new F(h,s);i.push(d(e(u))(n))}});return a=>{l();for(const c of i)c(a);i.length=0,n.clear(a)}}:b(...Array.from({length:s},(r,n)=>n).map(r=>d(e(new F(r,$(s)))))),ms=(s,e,t)=>{const r=y.map(s,i=>i.length),n=y.toSignal(s);return pe(r,i=>{const l=n.map(a=>a[i.index]);return b(Q(l.dispose),d(e(l,i)))},t)},gs=(s,e)=>{if(f.is(s)){const t=s;return r=>{r=r.makeRef();const n=t.map(a=>d(e(a)));let i=()=>{};const l=n.on(a=>{i(!0),i=a(r)});return a=>{l(),i(a)}}}return d(e(s))},ys=(s,e,t=()=>A)=>q(y.map(s,r=>r.length>0?{notEmpty:r}:{whenEmpty:null}),{notEmpty:r=>e(r),whenEmpty:()=>t()}),Ts=(s,e)=>t=>{const r=t.makePortal(s);return z(d(e),r)},Z=s=>e=>{let t=e;const r=s({use:e.getProvider,set:(n,i)=>t=t.setProvider(n,i)});return r==null?()=>{}:d(r)(t)},tt=(s,e,t)=>Z(({set:r})=>(r(s,e),t(e))),st=(s,e)=>Z(({use:t})=>e(t(s))),bs=(...s)=>e=>Z(({use:t})=>{const r=s.map(n=>t(n));return e(...r)}),me=je("Probe"),L=new Map,rt=({identifier:s,callback:e=()=>{},child:t,timeout:r=10})=>{if(L.has(s))throw new Error(`Probe already exists: ${s.description}`);const n=setTimeout(()=>e("timeout"),r);L.set(s,{counter:0,timeoutId:n});const i=l=>{clearTimeout(n);const a=L.get(l);if(a==null)throw new Error(`Probe not found: ${l.description}`);--a.counter===0?(e("resolved"),L.delete(l)):L.set(l,a)};return b(Q(()=>clearTimeout(n)),tt(me,i,()=>t))},nt=(s,e)=>st(me,t=>{const r=L.get(s);return r==null?e(()=>{}):(clearTimeout(r.timeoutId),r.counter++,e(()=>t(s)))}),it=Symbol("globalProbe"),Ss=({callback:s,timeout:e},t)=>rt({identifier:it,callback:s,child:t,timeout:e}),As=s=>nt(it,s),Es=(s,e)=>t=>{const r=t.getStyle(s);return t.setStyle(s,e),n=>{n&&t.setStyle(s,r)}},_s=(s,e)=>t=>{const r=t.getStyle(s);return e.on(n=>t.setStyle(s,n)),n=>{n&&t.setStyle(s,r)}},Ps=new Proxy({},{get:(s,e)=>t=>f.is(t)?_s(e,t):Es(e,t)}),ot=s=>e=>{if(e.isBrowser()){const t=s(e);if(t!=null)return d(t)(e)}return()=>{}},ws=s=>e=>{const t=s(e);return t==null?()=>{}:d(t)(e)},Cs=s=>ot(e=>s(e.element)),vs=s=>e=>{if(e.isHeadlessDOM()){const t=s(e);if(t)return d(t)(e)}return()=>{}};exports.Async=zt;exports.BindChecked=ls;exports.BindDate=rs;exports.BindDateTime=ns;exports.BindNumber=is;exports.BindText=os;exports.BrowserContext=v;exports.CLASS_PLACEHOLDER_ATTR=I;exports.Computed=C;exports.Conjunction=hs;exports.DOMNode=ds;exports.El=ce;exports.ElNS=ue;exports.ElementPosition=F;exports.Empty=A;exports.Ensure=et;exports.EnsureAll=fs;exports.ForEach=ms;exports.Fragment=b;exports.HeadlessAdapter=bt;exports.HeadlessContext=O;exports.HeadlessElement=Ue;exports.HeadlessPortal=oe;exports.HeadlessText=Ge;exports.MapSignal=gs;exports.MemoryStore=te;exports.NotEmpty=ys;exports.OnChecked=Xe;exports.OnDispose=Q;exports.OneOf=q;exports.OneOfField=de;exports.OneOfKind=as;exports.OneOfTuple=cs;exports.OneOfType=us;exports.OneOfValue=Ke;exports.Portal=Ts;exports.Prop=N;exports.ProvideGlobalProbe=Ss;exports.ProvideProbe=rt;exports.ProviderNotFoundError=ne;exports.RenderingError=qe;exports.Repeat=pe;exports.SetProvider=tt;exports.Signal=f;exports.Task=he;exports.TextNode=$t;exports.Unless=ps;exports.UseGlobalProbe=As;exports.UseProbe=nt;exports.UseProvider=st;exports.UseProviders=bs;exports.Value=y;exports.When=fe;exports.WithBrowserCtx=ot;exports.WithCtx=ws;exports.WithElement=Cs;exports.WithHeadlessCtx=vs;exports.WithProvider=Z;exports._NODE_PLACEHOLDER_ATTR=ie;exports._getSelfOrParentElement=Ve;exports._isElement=re;exports._makeGetter=Re;exports._makeSetter=$e;exports._removeDOMNode=k;exports._signalText=ae;exports._staticText=le;exports.animateSignal=mt;exports.animateSignals=Le;exports.aria=qt;exports.attr=x;exports.computed=Y;exports.computedOf=De;exports.computedRecord=gt;exports.dataAttr=jt;exports.effect=xe;exports.effectOf=dt;exports.emitChecked=Kt;exports.emitPreventDefault=es;exports.emitStopImmediatePropagation=ss;exports.emitStopPropagation=ts;exports.emitValue=Ye;exports.emitValueAsDate=Qe;exports.emitValueAsDateTime=Ze;exports.emitValueAsNullableDate=Qt;exports.emitValueAsNullableDateTime=Zt;exports.emitValueAsNumber=ze;exports.endInterpolate=ve;exports.getWindow=ee;exports.guessInterpolate=Oe;exports.html=Wt;exports.input=Ut;exports.interpolateDate=Ce;exports.interpolateNumber=Pe;exports.interpolateString=we;exports.joinSignals=ht;exports.localStorageProp=ft;exports.makeProviderMark=je;exports.math=Yt;exports.mathAttr=Ft;exports.on=j;exports.probeMarker=me;exports.prop=_;exports.render=yt;exports.renderWithContext=z;exports.renderableOfTNode=d;exports.restoreTempoPlaceholders=Lt;exports.runHeadless=Tt;exports.sessionStorageProp=pt;exports.signal=$;exports.storedProp=se;exports.style=Ps;exports.svg=Jt;exports.svgAttr=Bt;
package/index.d.ts CHANGED
@@ -24,8 +24,6 @@ export * from './renderable/async';
24
24
  export * from './renderable/attribute';
25
25
  export * from './renderable/bind';
26
26
  export * from './renderable/conjunction';
27
- export * from './renderable/consumers';
28
- export * from './renderable/on-ctx';
29
27
  export * from './renderable/domnode';
30
28
  export * from './renderable/element';
31
29
  export * from './renderable/empty';
@@ -33,20 +31,20 @@ export * from './renderable/ensure';
33
31
  export * from './renderable/foreach';
34
32
  export * from './renderable/fragment';
35
33
  export * from './renderable/on';
36
- export * from './renderable/on-browser-ctx';
37
- export * from './renderable/on-headless-ctx';
38
- export * from './renderable/on-ctx';
39
34
  export * from './renderable/on-dispose';
40
- export * from './renderable/on-element';
41
35
  export * from './renderable/oneof';
42
36
  export * from './renderable/map-signal';
43
37
  export * from './renderable/not-empty';
44
38
  export * from './renderable/portal';
45
39
  export * from './renderable/probe';
46
- export * from './renderable/providers';
47
40
  export * from './renderable/render';
48
41
  export * from './renderable/repeat';
49
42
  export * from './renderable/style';
50
43
  export * from './renderable/task';
51
44
  export * from './renderable/text';
52
45
  export * from './renderable/when';
46
+ export * from './renderable/with-browser-ctx';
47
+ export * from './renderable/with-ctx';
48
+ export * from './renderable/with-element';
49
+ export * from './renderable/with-headless-ctx';
50
+ export * from './renderable/with-provider';