ilha 0.8.4 → 0.9.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/dist/{index-BUonLJXu.d.ts → index-C0SWn9oq.d.ts} +49 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/{jsx-runtime-DZl50XF-.d.ts → jsx-runtime-DBCAZ9YL.d.ts} +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/package.json +1 -1
|
@@ -61,7 +61,7 @@ type ContextSignal<T> = {
|
|
|
61
61
|
(): T;
|
|
62
62
|
(value: T): void;
|
|
63
63
|
};
|
|
64
|
-
declare function
|
|
64
|
+
declare function ilhaContextFn<T>(key: string, initial: T): ContextSignal<T>;
|
|
65
65
|
/**
|
|
66
66
|
* Create a free-standing reactive signal that lives outside any island.
|
|
67
67
|
* Useful for sharing state across islands without prop drilling, or for
|
|
@@ -74,6 +74,33 @@ declare function ilhaContext<T>(key: string, initial: T): ContextSignal<T>;
|
|
|
74
74
|
* so when the signal changes, dependents re-run as if it were local state.
|
|
75
75
|
*/
|
|
76
76
|
declare function ilhaSignal<T>(initial: T): SignalAccessor<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Create a free-standing read-only reactive value derived from other signals.
|
|
79
|
+
* The computation is lazy and cached: `fn` re-runs only when a signal it read
|
|
80
|
+
* changed and the computed is read again. Reading it inside a `.derived()`,
|
|
81
|
+
* `.effect()`, `.render()`, or top-level `effect()` subscribes that scope —
|
|
82
|
+
* dependents re-run when the computed's value changes.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* const items = ilha.signal([1, 2, 3]);
|
|
86
|
+
* const total = ilha.computed(() => items().reduce((a, b) => a + b, 0));
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function ilhaComputed<T>(fn: () => T): SignalAccessor<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Run a free-standing reactive effect outside any island. `fn` runs once
|
|
92
|
+
* immediately and again whenever a signal it read changes. It may return a
|
|
93
|
+
* cleanup function, invoked before each re-run and on stop. Signal writes
|
|
94
|
+
* inside the effect are batched. Returns a stop function that disposes the
|
|
95
|
+
* effect and runs the final cleanup.
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* const stop = effect(() => {
|
|
99
|
+
* document.title = `${cart.count()} items`;
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function ilhaEffect(fn: () => void | (() => void)): () => void;
|
|
77
104
|
/**
|
|
78
105
|
* Run `fn` with reactive tracking suspended. Reading signals inside `fn`
|
|
79
106
|
* returns their current value without subscribing the surrounding scope.
|
|
@@ -134,6 +161,17 @@ interface Island<TInput = Record<string, unknown>, _TStateMap extends Record<str
|
|
|
134
161
|
mount(host: Element, props?: Partial<TInput>): () => void;
|
|
135
162
|
hydratable(props: Partial<TInput>, options: HydratableOptions): Promise<string>;
|
|
136
163
|
key(key: string): KeyedIsland<TInput>;
|
|
164
|
+
/**
|
|
165
|
+
* Register this island as a custom element, usable from plain HTML or any
|
|
166
|
+
* framework: `Counter.define("x-counter", { observe: ["label"] })` then
|
|
167
|
+
* `<x-counter label="hi"></x-counter>`. Observed attributes become string
|
|
168
|
+
* input props and re-resolve input on change; richer props can be assigned
|
|
169
|
+
* via the element's `props` property. Mounts on connect, unmounts on
|
|
170
|
+
* disconnect. No-op (with a dev warning) where customElements is missing.
|
|
171
|
+
*/
|
|
172
|
+
define(tagName: string, options?: {
|
|
173
|
+
observe?: string[];
|
|
174
|
+
}): void;
|
|
137
175
|
[ISLAND]: true;
|
|
138
176
|
}
|
|
139
177
|
interface KeyedIsland<TInput> {
|
|
@@ -290,8 +328,12 @@ declare const ilha: IlhaBuilder<Record<string, unknown>, Record<never, never>, R
|
|
|
290
328
|
raw: typeof ilhaRaw;
|
|
291
329
|
mount: typeof mountAll;
|
|
292
330
|
from: typeof ilhaFrom;
|
|
293
|
-
context: typeof
|
|
331
|
+
context: typeof ilhaContextFn & {
|
|
332
|
+
/** Remove a context signal from the registry. Returns true if it existed. */delete(key: string): boolean; /** Remove all context signals from the registry (e.g. between tests). */
|
|
333
|
+
clear(): void;
|
|
334
|
+
};
|
|
294
335
|
signal: typeof ilhaSignal;
|
|
336
|
+
computed: typeof ilhaComputed;
|
|
295
337
|
batch: typeof batch;
|
|
296
338
|
untrack: typeof untrack;
|
|
297
339
|
onUncaughtError: typeof onUncaughtError;
|
|
@@ -303,6 +345,9 @@ declare const raw: typeof ilhaRaw;
|
|
|
303
345
|
declare const css: typeof ilhaCss;
|
|
304
346
|
declare const mount: typeof mountAll;
|
|
305
347
|
declare const from: typeof ilhaFrom;
|
|
306
|
-
declare const context: typeof
|
|
348
|
+
declare const context: typeof ilhaContextFn & {
|
|
349
|
+
/** Remove a context signal from the registry. Returns true if it existed. */delete(key: string): boolean; /** Remove all context signals from the registry (e.g. between tests). */
|
|
350
|
+
clear(): void;
|
|
351
|
+
};
|
|
307
352
|
//#endregion
|
|
308
|
-
export {
|
|
353
|
+
export { mount as A, css as C, ilhaComputed as D, ilha as E, raw as M, untrack as N, ilhaEffect as O, context as S, html as T, OnMountContext as _, ErrorSource as a, __ilhaJsxSlot as b, HandlerContextFor as c, Island as d, IslandDerived as f, MountResult as g, MountOptions as h, ErrorContext as i, onUncaughtError as j, ilhaSignal as k, HydratableOptions as l, KeyedIsland as m, DerivedValue as n, ExternalSignal as o, IslandState as p, EffectContext as r, HandlerContext as s, DerivedAccessor as t, ISLAND_MOUNT_INTERNAL as u, RawHtml as v, from as w, batch as x, SignalAccessor as y };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { DerivedAccessor, DerivedValue, EffectContext, ErrorContext, ErrorSource, ExternalSignal, HandlerContext, HandlerContextFor, HydratableOptions, ISLAND_MOUNT_INTERNAL, Island, IslandDerived, IslandState, KeyedIsland, MountOptions, MountResult, OnMountContext, RawHtml, SignalAccessor, __ilhaJsxSlot, batch, context, css, ilha as default, from, html, ilhaSignal, ilhaSignal as signal, mount, onUncaughtError, raw, untrack };
|
|
1
|
+
import { A as mount, C as css, D as ilhaComputed, E as ilha, M as raw, N as untrack, O as ilhaEffect, S as context, T as html, _ as OnMountContext, a as ErrorSource, b as __ilhaJsxSlot, c as HandlerContextFor, d as Island, f as IslandDerived, g as MountResult, h as MountOptions, i as ErrorContext, j as onUncaughtError, k as ilhaSignal, l as HydratableOptions, m as KeyedIsland, n as DerivedValue, o as ExternalSignal, p as IslandState, r as EffectContext, s as HandlerContext, t as DerivedAccessor, u as ISLAND_MOUNT_INTERNAL, v as RawHtml, w as from, x as batch, y as SignalAccessor } from "./index-C0SWn9oq.js";
|
|
2
|
+
export { DerivedAccessor, DerivedValue, EffectContext, ErrorContext, ErrorSource, ExternalSignal, HandlerContext, HandlerContextFor, HydratableOptions, ISLAND_MOUNT_INTERNAL, Island, IslandDerived, IslandState, KeyedIsland, MountOptions, MountResult, OnMountContext, RawHtml, SignalAccessor, __ilhaJsxSlot, batch, ilhaComputed as computed, context, css, ilha as default, ilhaEffect as effect, from, html, ilhaSignal, ilhaSignal as signal, mount, onUncaughtError, raw, untrack };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}`);return n.value}const
|
|
1
|
+
import{computed as e,effect as t,endBatch as n,setActiveSub as r,signal as i,startBatch as a}from"alien-signals";function o(e,t){if(t>32)return!0;if(typeof e!=`object`||!e)return!1;if(Array.isArray(e)){for(let n of e)if(o(n,t+1))return!0;return!1}for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&o(e[n],t+1))return!0;return!1}const s=new Set([`__proto__`,`constructor`,`prototype`]);function c(e){if(!(typeof e!=`object`||!e)){if(Array.isArray(e)){for(let t of e)c(t);return}for(let t of Object.getOwnPropertyNames(e))s.has(t)?delete e[t]:c(e[t])}}function l(e,t){if(e.length>262144){`${t}`;return}let n;try{n=JSON.parse(e)}catch{`${t}`;return}if(o(n,1)){`${t}`;return}if(typeof n!=`object`||!n||Array.isArray(n)){`${t}`;return}return c(n),n}function u(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}function d(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function f(e){let t=[];for(let n of e.querySelectorAll(`[data-ilha-slot]`)){if(!(n instanceof Element))continue;let r=n.parentElement??n.parentNode,i=!1;for(;r&&r!==e;){if(r instanceof Element&&r.hasAttribute(`data-ilha-slot`)){i=!0;break}r=r instanceof Element?r.parentElement??r.parentNode:r.parentNode}i||t.push(n.getAttribute(`data-ilha-slot`))}return t}function p(e,t){for(let n of e.querySelectorAll(`[${A}]`))if(n.getAttribute(A)===t)return n.getAttribute(j)??``;return null}const m=/^[a-z][a-z0-9-]*$/i;function h(e){let t=e.trim();if(t.length===0)throw Error(`island.as() requires a non-empty HTML tag name.`);if(!m.test(t))throw Error(`island.as() tag must be a valid HTML element name (got "${e}"). Use names like "span", "div", or "li".`);return t.toLowerCase()}function g(e){let t=e[k];return typeof t==`string`&&t.length>0?t:`div`}function _(e,t,n,r){return`<${e} ${A}="${w(t)}"${n}>${r}</${e}>`}function ee(e,t,n){if(typeof document>`u`)return!1;let r=d(e),i=d(t),a=f(r),o=f(i);if(a.length!==o.length||a.some((e,t)=>e!==o[t]))return!1;for(let e of n){let t=p(r,e),n=p(i,e);if(t===null||n===null||t!==n)return!1}return!0}function te(e){return e===void 0?``:JSON.stringify(e)}const v=new Set([`data-checked`,`data-unchecked`,`data-indeterminate`,`aria-checked`,`data-open`,`data-closed`,`data-state`,`aria-expanded`,`aria-hidden`,`data-selected`,`data-panel-open`]);function y(e,t){return e.matches(`[data-slot]`)&&v.has(t)}function b(e,t){for(let{name:n,value:r}of t.attributes)y(e,n)||e.getAttribute(n)!==r&&e.setAttribute(n,r);for(let{name:n}of Array.from(e.attributes))y(e,n)||t.hasAttribute(n)||e.removeAttribute(n)}function x(e,t){let n=Array.from(t.childNodes),r=null;for(let t of e.children){let e=t.getAttribute(`data-key`);e!==null&&!(r??=new Map).has(e)&&r.set(e,t)}let i=null;if(r!==null){i=new Set;for(let e of t.children){let t=e.getAttribute(`data-key`);t!==null&&i.add(t)}}for(let t=0;t<n.length;t++){let a=n[t],o=e.childNodes[t];if(r!==null&&a.nodeType===1){let t=a.getAttribute(`data-key`);if(t!==null){let n=r.get(t);if(n)n!==o&&(e.insertBefore(n,o??null),o=n);else if(o instanceof Element){let t=o.getAttribute(`data-key`);if(t!==null&&i.has(t)){e.insertBefore(a.cloneNode(!0),o);continue}}}}if(!o){e.appendChild(a.cloneNode(!0));continue}if(o.nodeType!==a.nodeType){e.replaceChild(a.cloneNode(!0),o);continue}if(o.nodeType===3||o.nodeType===8){o.nodeValue!==a.nodeValue&&(o.nodeValue=a.nodeValue);continue}if(o.nodeType===1){let t=o,n=a;if(t.localName!==n.localName||t.namespaceURI!==n.namespaceURI){e.replaceChild(n.cloneNode(!0),t);continue}if(t.localName===`input`&&t.type!==n.type){e.replaceChild(n.cloneNode(!0),t);continue}if(b(t,n),t.localName===`textarea`){let e=n.textContent??``;t.textContent!==e&&(t.textContent=e,t.value=e)}else x(t,n)}}for(;e.childNodes.length>n.length;)e.lastChild.remove()}function ne(e,t){if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)throw Error(`[ilha] morph: elements must match`);x(e,t)}function S(e){if(typeof e!=`object`||!e)return!1;let t=e[`~standard`];return t!=null&&typeof t.validate==`function`&&t.version===1}function re(e,t){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw Error(`[ilha] Async schemas are not supported.`);if(n.issues)throw Error(`[ilha] Validation failed:\n${n.issues.map(e=>` - ${e.message}`).join(`
|
|
2
|
+
`)}`);return n.value}const C={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};function w(e){return String(e).replace(/[&<>"']/g,e=>C[e])}function T(e){if(e.length===0||e[0]!==`
|
|
3
3
|
`)return e;let t=e.split(`
|
|
4
4
|
`);for(;t.length&&t[0].trim()===``;)t.shift();for(;t.length&&t[t.length-1].trim()===``;)t.pop();if(!t.length)return``;let n=Math.min(...t.filter(e=>e.trim()!==``).map(e=>e.match(/^(\s*)/)[1].length));return t.map(e=>e.slice(n)).join(`
|
|
5
|
-
`)}const S=Symbol.for(`ilha.raw`),C=Symbol.for(`ilha.signalAccessor`),w=Symbol.for(`ilha.island`),T=Symbol.for(`ilha.islandCall`),E=Symbol.for(`ilha.islandMountInternal`),D=Symbol.for(`ilha.islandSlotTag`),O=`data-ilha-slot`,k=`data-ilha-props`,A=`data-ilha-state`;function j(e){return`<style data-ilha-css>@scope (:scope) to ([data-ilha]){${e.replace(/<\/style/gi,`<\\/style`)}}</style>`}const M=[];function N(e,t){let n={slots:new Map,positional:0,liveHost:e,pending:t?new Map:void 0,binds:[],slotTags:new Map};return M.push(n),n}function P(){M.pop()}function F(){return M[M.length-1]}function ae(e){return typeof e==`function`?w in e?!0:Object.getOwnPropertySymbols(e).some(e=>e.description===`ilha.island`):!1}function I(e){if(e==null||typeof e!=`object`&&typeof e!=`function`)return!1;if(T in e||Object.getOwnPropertySymbols(e).some(e=>e.description===`ilha.islandCall`))return!0;if(typeof e==`object`&&`island`in e){let t=e.island;return typeof t==`function`&&(w in t||Object.getOwnPropertySymbols(t).some(e=>e.description===`ilha.island`))}return!1}function L(e,t,n){let r=F(),i;i=n===void 0?r?`p:${r.positional++}`:`p:0`:`k:${n}`,r&&r.slots.set(i,{island:e,props:t});let a=p(e);r&&r.slotTags.set(i,a);let o=t?` ${k}='${b(JSON.stringify(t))}'`:``;if(r?.liveHost)return m(a,i,o,``);if(r?.pending){P();try{let n=e(t);return n instanceof Promise?(r.pending.set(i,n.then(String)),m(a,i,o,``)):m(a,i,o,String(n))}finally{M.push(r)}}let s=e.toString(t);return m(a,i,o,s)}async function R(e,t){for(let[n,r]of t.pending){let i=await r,a=t.slotTags.get(n)??`div`,o=b(n);if(o.length>500)throw Error(`Slot id exceeds safe length for regex replacement (${o.length} > 500).`);let s=o.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),c=a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),l=RegExp(`<${c}\\s[^>]*${O}="${s}"[^>]*></${c}>`,`g`);e=e.replace(l,e=>{let t=`></${a}>`;return e.slice(0,-t.length)+`>${i}</${a}>`})}return e}function z(e){e[C]=!0;let t=e;return t.select=e=>G(t,e),t}function B(e){return typeof e==`function`?C in e?!0:Object.getOwnPropertySymbols(e).some(e=>e.description===`ilha.signalAccessor`):!1}function V(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function H(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=r;if(t<0||t>=e.length)return e;let a=e[t],o=i.length===0?n:H(a,i,n);if(Object.is(a,o))return e;let s=e.slice();return s[t]=o,s}if(typeof e==`object`&&e){let t=e,a=String(r),o=t[a],s=i.length===0?n:H(o,i,n);if(i.length===0){if(Object.is(o,n))return e}else if(Object.is(o,s))return e;return{...t,[a]:s}}return i.length===0?n:H(void 0,i,n)}function U(e){return typeof e==`symbol`||e===`length`?null:/^\d+$/.test(e)?Number(e):e}function W(e,t){let n=[],r=e=>e===null||typeof e!=`object`&&typeof e!=`function`?e:new Proxy(e,{get(e,t,i){let a=U(t);a!=null&&n.push(a);let o=Reflect.get(e,t,i);return a!=null&&typeof o==`object`&&o?r(o):o}});return t(r(e)),n}function G(e,t){let n=W(e(),t),r=t(e()),i=n.length===0?e():V(e(),n);if(!Object.is(r,i))throw Error(`select(): selector must only traverse nested properties or array indexes — derived or transformed values are not supported.`);return z((...r)=>{if(r.length===0)return n.length===0?t(e()):V(e(),n);let i=n.length===0?r[0]:H(e(),n,r[0]);Object.is(e(),i)||e(i)})}function K(e){return{[S]:!0,value:e}}function q(e,...t){if(typeof e==`string`)return e;let n=``;for(let r=0;r<e.length;r++)n+=e[r],r<t.length&&(n+=String(t[r]));return n}function J(e){if(e==null||e===!0||e===!1)return``;if(Array.isArray(e))return e.map(J).join(``);if(Q(e))return e.value;if(I(e)){let t=typeof e==`function`?e():e;return L(t.island,t.props,t.key)}return ae(e)?L(e,void 0,void 0):B(e)||typeof e==`function`?b(e()):b(e)}const Y=new Set([`value`,`checked`,`valueAsNumber`,`valueAsDate`,`files`,`open`,`group`,`this`]),X=/\bbind:([a-zA-Z]+)\s*=\s*("|')?$/;function Z(e){if(e instanceof Date){if(isNaN(e.getTime()))return``;let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}return``}function oe(e){let t=e.lastIndexOf(`<`);if(t===-1)return null;let n=e.slice(t);if(n.includes(`>`))return null;let r=n.match(/\bvalue\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))/);return r?r[2]??r[3]??r[4]??null:null}function se(e,t,n,r){let i=`${e}:${t}`,a;try{a=n()}catch{a=void 0}switch(e){case`value`:return[` value="${b(a??``)}"`,i];case`valueAsNumber`:return[` value="${b(a==null?``:String(a))}"`,i];case`valueAsDate`:return[` value="${b(Z(a))}"`,i];case`checked`:return[a?` checked`:``,i];case`open`:return[a?` open`:``,i];case`files`:return[``,i];case`this`:return[``,i];case`group`:{let e=oe(r);return e==null?[``,i]:[(Array.isArray(a)?a.map(String).includes(e):a!=null&&String(a)===e)?` checked`:``,i]}}}function ce(e,...t){let n=``,r=null,i=``,a=F();for(let o=0;o<e.length;o++){let s=e[o];if(r!==null&&(s.startsWith(r)&&(s=s.slice(1)),r=null),i!==``){let e=s.indexOf(`>`);e!==-1&&(s=s.slice(0,e)+` data-ilha-bind="${i}">`+s.slice(e+1),i=``)}if(o>=t.length){n+=s;continue}let c=t[o],l=s.match(X);if(l&&B(c)){let e=l[1],t=l[2]??null;if(!Y.has(e)){n+=s+J(c);continue}if(!a){let i=s.slice(0,s.length-l[0].length),a=t??`"`;n+=i+e+`=`+a+J(c)+a,t&&(r=t);continue}let o=s.length-l[0].length,u=s.slice(0,o).replace(/\s+$/,``),d=a.binds.length;a.binds.push({kind:e,accessor:c});let[f,p]=se(e,d,c,u);n+=u+f,i+=(i?`,`:``)+p,t&&(r=t);continue}n+=s+J(c)}return i!==``&&(n+=` data-ilha-bind="${i}"`),{[S]:!0,value:x(n)}}function Q(e){return typeof e!=`object`||!e||!(`value`in e)||typeof e.value!=`string`?!1:S in e?!0:Object.getOwnPropertySymbols(e).some(e=>e.description===`ilha.raw`)}function le(e){return Q(e)?e.value:e}const ue=new Map;function de(e,t){if(ue.has(e))return ue.get(e);let n=r(t),i=(...e)=>{if(e.length===0)return n();n(e[0])};return ue.set(e,i),i}function fe(e){let t=r(e);return z((...e)=>{if(e.length===0)return t();t(e[0])})}function pe(e){let t=n(void 0);try{return e()}finally{n(t)}}function me(e){i();try{return e()}finally{t()}}function he(e,t){let n=z((...n)=>{if(n.length>0){t&&t(n[0]);return}return e().value});return new Proxy(n,{get(t,n,r){return n===`loading`||n===`value`||n===`error`?e()[n]:Reflect.get(t,n,r)}})}function ge(){return he(()=>({loading:!1,value:void 0,error:void 0}))}function _e(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,he(()=>r,e=>{r.loading=!1,r.value=e,r.error=void 0}));return new Proxy({},{get(e,n){return t.get(n)??ge()}})}function ve(t,i,a,o){let s=new Map;for(let e of t){let t;if(o!=null&&e.key in o)t={...o[e.key]};else if(e.fn.constructor.name===`AsyncFunction`||e.fn.constructor.name===`AsyncGeneratorFunction`)t={loading:!0,value:void 0,error:void 0};else{let n=new AbortController;try{let r=e.fn({state:i,input:a,signal:n.signal});r instanceof Promise?(t={loading:!0,value:void 0,error:void 0},r.catch(()=>{})):t={loading:!1,value:r,error:void 0}}catch(e){t={loading:!1,value:void 0,error:e instanceof Error?e:Error(String(e))}}finally{n.abort()}}let n=r(t);s.set(e.key,n)}let c=new Map;for(let e of t){let t=s.get(e.key);c.set(e.key,he(()=>t(),e=>{let r=n(void 0);t({loading:!1,value:e,error:void 0}),n(r)}))}return{proxy:new Proxy({},{get(e,t){return c.get(t)??ge()}}),setup:()=>{let r=[];for(let c of t){let t=s.get(c.key),l=new AbortController,u=o!=null&&c.key in o,d=e(()=>{l.abort(),l=new AbortController;let e=l,r;try{r=c.fn({state:i,input:a,signal:e.signal})}catch(e){if(u){u=!1;return}let r=n(void 0);t({loading:!1,value:void 0,error:e instanceof Error?e:Error(String(e))}),n(r);return}if(u){u=!1,r instanceof Promise&&r.catch(()=>{});return}if(!(r instanceof Promise)){let e=n(void 0);t({loading:!1,value:r,error:void 0}),n(e);return}let o=n(void 0);t({loading:!0,value:t().value,error:void 0}),n(o),r.then(n=>{e.signal.aborted||t({loading:!1,value:n,error:void 0})}).catch(n=>{e.signal.aborted||t({loading:!1,value:void 0,error:n instanceof Error?n:Error(String(n))})})});r.push(()=>{d(),l.abort()})}return()=>r.forEach(e=>e())}}}const ye=`data-ilha-bind`;function be(e){let t=[];for(let n of e.split(`,`)){let[e,r]=n.split(`:`);if(!e||!r)continue;let i=Number(r);!Number.isInteger(i)||i<0||t.push({kind:e,index:i})}return t}function xe(e,t){let n=e;switch(t){case`value`:return{event:e.tagName===`SELECT`?`change`:`input`,read:e=>e.value,write:(e,t)=>e.value=t==null?``:String(t)};case`valueAsNumber`:return{event:`input`,read:e=>{let t=e.valueAsNumber;return Number.isNaN(t)?null:t},write:(e,t)=>e.value=t==null||Number.isNaN(t)?``:String(t)};case`valueAsDate`:return{event:`input`,read:e=>e.valueAsDate,write:(e,t)=>{e.value=Z(t)}};case`checked`:return{event:`change`,read:e=>e.checked,write:(e,t)=>e.checked=!!t};case`files`:return{event:`change`,read:e=>e.files,write:()=>{}};case`open`:return{event:`toggle`,read:e=>e.open,write:(e,t)=>e.open=!!t};case`this`:return{event:null,read:()=>void 0,write:()=>{}};case`group`:{let e=n.type===`checkbox`;return{event:`change`,read:t=>{let n=t;return e?{__ilhaGroup:!0,value:n.value,checked:n.checked}:n.checked?n.value:void 0},write:(t,n)=>{let r=t;e?r.checked=(Array.isArray(n)?n.map(String):[]).includes(r.value):r.checked=n!=null&&String(n)===r.value}}}}}function Se(e,t){if(t.length===0)return()=>{};let n=[],r=[];e.hasAttribute(ye)&&r.push(e);for(let t of e.querySelectorAll(`[${ye}]`))r.push(t);for(let e of r){let r=be(e.getAttribute(ye));for(let i of r){let r=t[i.index];if(!r||r.kind!==i.kind)continue;let{event:a,read:o,write:s}=xe(e,i.kind),c=r.accessor;if(i.kind===`this`){c(e),n.push(()=>c(null));continue}try{s(e,c())}catch{}if(a===null)continue;let l=()=>{let t=o(e);if(i.kind===`group`){let e=t;if(e===void 0)return;if(typeof e==`object`&&e.__ilhaGroup){let t=c(),n=Array.isArray(t)?[...t]:[],r=n.findIndex(t=>String(t)===e.value);if(e.checked&&r===-1){let r=e.value,i=Array.isArray(t)&&t.length>0?t[0]:void 0;if(i!==void 0)if(typeof i==`number`){let e=Number(r);r=Number.isNaN(e)?r:e}else typeof i==`boolean`&&(r=!!r);n.push(r)}else !e.checked&&r!==-1&&n.splice(r,1);c(n);return}let n=c(),r=e;if(typeof n==`number`&&typeof e==`string`){let t=Number(e);r=Number.isNaN(t)?0:t}else typeof n==`boolean`&&(r=!!e);c(r);return}let n=c(),r=t;if(typeof n==`number`&&typeof t==`string`){let e=Number(t);r=Number.isNaN(e)?0:e}else typeof n==`boolean`&&(r=!!t);c(r)};e.addEventListener(a,l),n.push(()=>e.removeEventListener(a,l))}}return()=>n.forEach(e=>e())}function Ce(e){let t=e.lastIndexOf(`@`),n=t===-1?``:e.slice(0,t),r=(t===-1?e:e.slice(t+1)).split(`:`),i=r[0],a=new Set(r.slice(1));return{selector:n,eventType:i,options:{once:a.has(`once`),capture:a.has(`capture`),passive:a.has(`passive`)},abortable:a.has(`abortable`)}}function we(e){if(typeof AbortSignal.any==`function`)return AbortSignal.any(e);let t=new AbortController,n=[];for(let r of e){if(r.aborted)return t.abort(r.reason),n.forEach(e=>e()),t.signal;let e=()=>t.abort(r.reason);r.addEventListener(`abort`,e,{once:!0}),n.push(()=>r.removeEventListener(`abort`,e))}return t.signal.aborted||t.signal.addEventListener(`abort`,()=>{n.forEach(e=>e())}),t.signal}const $=new Set;function Te(e,t){if($.size===0)return!1;for(let n of $)try{n(e,t)}catch(e){console.error(e)}return!0}function Ee(e){return $.add(e),()=>{$.delete(e)}}var De=class a{_cfg;constructor(e){this._cfg=e}input(e){let t=null,n=null;return e!==void 0&&(v(e)?t=e:n=e),new a({schema:t,defaultInput:n,states:[],deriveds:[],ons:[],effects:[],onMounts:[],onErrors:[],transition:null,css:null,as:null})}as(e){return new a({...this._cfg,as:f(e)})}state(e,t){let n=this._cfg;return new a({...n,states:[...n.states,{key:e,init:t}]})}derived(e,t){let n=this._cfg;return new a({...n,deriveds:[...n.deriveds,{key:e,fn:t}]})}on(e,t){let n=Ce(e);return new a({...this._cfg,ons:[...this._cfg.ons,{selector:n.selector,event:n.eventType,options:n.options,abortable:n.abortable,handler:t}]})}effect(e){return new a({...this._cfg,effects:[...this._cfg.effects,{fn:e}]})}onMount(e){return new a({...this._cfg,onMounts:[...this._cfg.onMounts,{fn:e}]})}onError(e){return new a({...this._cfg,onErrors:[...this._cfg.onErrors,{fn:e}]})}transition(e){return new a({...this._cfg,transition:e})}css(e,...t){let n;if(typeof e==`string`)n=e;else{let r=``;for(let n=0;n<e.length;n++)r+=e[n],n<t.length&&(r+=String(t[n]));n=r}return new a({...this._cfg,css:n})}render(a){let{schema:o,defaultInput:l,states:u,deriveds:d,ons:p,effects:m,onMounts:ne,onErrors:h,transition:g,css:_,as:v}=this._cfg,y=_==null?``:j(_),x=v??`div`;function S(e){let t={...l??{},...e??{}};return o?ie(o,t):t}function C(e,t,n){let r=N(t,n);try{let t=le(e()),n=r.slots,i=r.binds;if(r.pending&&r.pending.size>0){let e=r.pending,a=r.slotTags;return(async()=>({html:await R(t,{pending:e,slotTags:a}),slots:n,binds:i}))()}return{html:t,slots:n,binds:i}}finally{P()}}function M(e){let t={};for(let n of u){let r=typeof n.init==`function`?n.init(e):n.init,i=z((...e)=>{if(e.length===0)return r});t[n.key]=i}return t}function ae(e,t){let n={};for(let i of u){let a=r(t&&i.key in t?t[i.key]:typeof i.init==`function`?i.init(e):i.init),o=z((...e)=>{if(e.length===0)return a();a(e[0])});n[i.key]=o}return n}function I(e,t=!1){let r=S(e),i=M(r),o=d.map(e=>{let t=n(void 0);try{return{key:e.key,result:e.fn({state:i,input:r,signal:new AbortController().signal})}}catch(t){return{key:e.key,result:Promise.reject(t)}}finally{n(t)}});if(!o.some(e=>e.result instanceof Promise)||t){let e={};for(let t of o)t.result instanceof Promise?e[t.key]={loading:!0,value:void 0,error:void 0}:e[t.key]={loading:!1,value:t.result,error:void 0};let t=_e(e),s=n(void 0);try{let{html:e}=C(()=>a({state:i,derived:t,input:r}));return y+e}finally{n(s)}}return Promise.all(o.map(async e=>{try{return{key:e.key,envelope:{loading:!1,value:await Promise.resolve(e.result),error:void 0}}}catch(t){return{key:e.key,envelope:{loading:!1,value:void 0,error:t instanceof Error?t:Error(String(t))}}}})).then(async e=>{let t={};for(let n of e)t[n.key]=n.envelope;let o=_e(t),s=n(void 0);try{let{html:e}=await C(()=>a({state:i,derived:o,input:r}),void 0,!0);return y+e}finally{n(s)}})}function L(e,t){return B(e,t).unmount}function B(o,l){if(l===void 0){let e=o.getAttribute(k);if(e){let t=s(e,k);t!==void 0&&(l=t)}}let u=r(S(l)),f=new Proxy({},{get(e,t){return u()[t]},has(e,t){return t in u()},ownKeys(){let e=n(void 0);try{return Reflect.ownKeys(u())}finally{n(e)}},getOwnPropertyDescriptor(e,t){let r=n(void 0);try{return Reflect.getOwnPropertyDescriptor(u(),t)}finally{n(r)}}}),_,v=o.getAttribute(A);if(v){let e=s(v,A);e!==void 0&&(_=e)}let ie=_?Object.fromEntries(Object.entries(_).filter(([e])=>e!==`_derived`&&e!==`_skipOnMount`)):void 0,b=_?._derived,x;if(b){x={};for(let[e,t]of Object.entries(b))t.error&&!(t.error instanceof Error)?x[e]={...t,error:Error(String(t.error))}:x[e]=t}let w=_!=null,T=w&&_?._skipOnMount===!0,D=ae(f,ie),j=[],M=new AbortController;j.push(()=>M.abort());let{proxy:N,setup:P}=ve(d,D,f,x),F=()=>{};function I(e,t){let n=e instanceof Error?e:Error(String(e));if(h.length===0){Te(n,t)||console.error(n);return}for(let e of h)try{e.fn({error:n,source:t,state:D,derived:N,input:f,host:o})}catch(e){console.error(e)}}if(g?.enter)try{let e=g.enter(o);e instanceof Promise&&e.catch(e=>I(e,`transition`))}catch(e){I(e,`transition`)}let L=new Map,R=new Map;function z(e,t){L.delete(e);let n=Symbol(),r=t.unmount(),i=t=>{let r=R.get(e);!r||r.token!==n||(r.el.remove(),t?.remove(),R.delete(e))};if(r instanceof Promise)return R.set(e,{el:t.el,token:n}),r.finally(()=>i());t.el.remove()}function B(e){let t=e;for(;t&&t!==o;){if(t.hasAttribute(`data-ilha`))return!1;t=t.parentElement}return t===o}function V(){let e=new Set([...R.values()].map(e=>e.el)),t=new Map;for(let n of o.querySelectorAll(`[${O}]`)){if(e.has(n))continue;let r=n.getAttribute(O);r===null||t.has(r)||B(n)&&t.set(r,n)}return t}function H(e){for(let[t,n]of L)e.has(t)||z(t,n);for(let[t,n]of L){let r=e.get(t);r&&r.island!==n.island&&z(t,n)}let t=null;for(let[r,{island:i,props:a}]of e){let e=L.get(r);if(e){e.updateProps(a);continue}t===null&&(t=V());let o=t.get(r)??null;if(!o)continue;let c=a;if(c===void 0){let e=o.getAttribute(k)??o.getAttribute(`data-props`);if(e){let t=s(e,`props on [${O}="${r}"]`);t!==void 0&&(c=t)}}let l=n(void 0),u;try{let e=i[E];u=e?e(o,c):{unmount:i.mount(o,c),updateProps:()=>{}}}finally{n(l)}L.set(r,{el:o,island:i,...u})}}let U=[],W=new Set,G=new WeakMap;function K(){for(let e of p)e.options.once&&W.has(e)||(e.selector===``?[o]:Array.from(o.querySelectorAll(e.selector))).forEach(n=>{let r=r=>{if(e.options.once){W.add(e);for(let t of U.filter(t=>t.entry===e))t.target.removeEventListener(t.type,t.fn,t.options);U.splice(0,U.length,...U.filter(t=>t.entry!==e))}let a=r.target instanceof Element?r.target:n,s=e.selector===``?a:n,c;if(e.abortable){let t=G.get(e);t||(t=new WeakMap,G.set(e,t));let r=t.get(n);r&&r.abort();let i=new AbortController;t.set(n,i),c=we([M.signal,i.signal])}else c=M.signal;let l;i();try{l=e.handler({state:D,derived:N,input:f,host:o,target:s,event:r,signal:c})}catch(e){I(e,`on`),t();return}t(),l instanceof Promise&&l.catch(e=>{e&&e.name===`AbortError`||I(e,`on`)})},a={...e.options,once:!1};n.addEventListener(e.event,r,a),U.push({target:n,type:e.event,fn:r,options:a,entry:e})})}function q(){for(let e of U)e.target.removeEventListener(e.type,e.fn,e.options);U.length=0}let J=w&&o.childNodes.length>0,Y=C(()=>a({state:D,derived:N,input:f}),J?o:void 0);J||(o.innerHTML=y+Y.html);let X=Se(o,Y.binds);if(j.push(()=>X()),H(Y.slots),j.push(()=>L.forEach(e=>e.unmount())),K(),!T)for(let e of ne){let t=n(void 0),r;try{r=e.fn({state:D,derived:N,input:f,host:o,hydrated:w})}catch(e){I(e,`mount`)}finally{n(t)}if(r){let e=r;j.push(()=>{try{e()}catch(e){I(e,`mount`)}})}}for(let n of m){let r,a=null,s=e(()=>{if(r){try{r()}catch(e){I(e,`effect`)}r=void 0}a&&a.abort(),a=new AbortController;let e=we([M.signal,a.signal]);i();try{r=n.fn({state:D,derived:N,input:f,host:o,signal:e})}catch(e){I(e,`effect`)}finally{t()}});j.push(()=>{if(s(),r)try{r()}catch(e){I(e,`effect`)}a&&a.abort()})}F=P(),j.push(F);let Z=!1,oe=Y.html,se=0,ce=e(()=>{let e=++se,{html:t,slots:n,binds:r}=C(()=>a({state:D,derived:N,input:f}),o),i=y+t;if(!Z&&(Z=!0,t===oe||L.size>0&&L.size===n.size&&[...n.keys()].every(e=>L.has(e))&&ee(oe,t,n.keys())))return;q(),X();let s=L.size,c=[];for(let[e,t]of L)if(!n.has(e)){let n=z(e,t);n instanceof Promise&&c.push(n)}for(let[e,t]of L){let r=n.get(e);if(r&&r.island!==t.island){let n=z(e,t);n instanceof Promise&&c.push(n)}}let l=()=>{if(e!==se)return;let t=new Map,a=n.size<s;for(let[e,r]of L){if(!n.has(e)||!r.el.isConnected)continue;if(a&&e.startsWith(`p:`)){z(e,r);continue}let i=r.el.tagName.toLowerCase(),o=document.createElement(i);o.setAttribute(O,e);let s=te(n.get(e)?.props);s!==``&&o.setAttribute(k,s),r.el.replaceWith(o),t.set(e,r.el)}let c=document.createElement(`template`),l=o.tagName.toLowerCase();if(c.innerHTML=`<${l}>${i}</${l}>`,re(o,c.content.firstElementChild),t.size>0){let e=V();for(let[n,r]of t){let t=e.get(n);t&&t.replaceWith(r)}}K(),X=Se(o,r),H(n)};c.length>0?Promise.allSettled(c).then(e=>{for(let t of e)t.status===`rejected`&&console.error(t.reason);l()}):l()}),Q=!1;return{unmount:()=>{if(Q)return;Q=!0,ce(),q();let e=[];for(let[,t]of L){let n=t.unmount();n instanceof Promise&&e.push(n)}if(g?.leave)try{let t=g.leave(o);t instanceof Promise&&e.push(t)}catch(e){I(e,`transition`)}let t=()=>{for(let e of j)e()};if(e.length>0)return Promise.all(e).then(t).catch(e=>{I(e,`transition`),t()});t()},updateProps:e=>{if(Q)return;let t=S(e);c(u(),t)||u(t)}}}let V=function(e){return F()?{[T]:!0,island:V,props:e,key:void 0}:I(e)};return V.toString=e=>I(e,!0),V.mount=(e,t)=>L(e,t),V[E]=(e,t)=>B(e,t),V[D]=x,V.key=e=>{if(typeof e!=`string`||e.trim().length===0)throw Error(`island.key() requires a non-empty string.`);if(e.includes(`:`))throw Error(`island.key() key cannot contain the slot separator ":" (got "${e}").`);let t=(t=>({[T]:!0,island:V,props:t,key:e}));return t[T]=!0,t},V[w]=!0,V.hydratable=async(e,t)=>{let{name:r,as:i=`div`,snapshot:a=!1,skipOnMount:o}=t,s=f(i),c=e??{},l=await I(c),p=b(JSON.stringify(c)),m=``;if(a!==!1){let e=a===!0||a.state!==!1,t=a===!0||a.derived!==!1,r=o??(e||t),i={},s=S(c),l=M(s);if(e)for(let e of u)i[e.key]=l[e.key]();if(t){let e={};for(let t of d){let r=n(void 0),i,a,o=!1;try{i=t.fn({state:l,input:s,signal:new AbortController().signal})}catch(e){o=!0,a=e}finally{n(r)}if(o){e[t.key]={loading:!1,value:void 0,error:a instanceof Error?a.message:String(a)};continue}try{let n=await Promise.resolve(i);e[t.key]={loading:!1,value:n,error:void 0}}catch(n){e[t.key]={loading:!1,value:void 0,error:n instanceof Error?n.message:String(n)}}}i._derived=e}r&&(i._skipOnMount=!0),m=` ${A}='${b(JSON.stringify(i))}'`}return`<${s} data-ilha="${b(r)}" ${k}='${p}'${m}>${l}</${s}>`},V}};function Oe(e,t,n){let r=typeof e==`string`?document.querySelector(e):e;return r?t.mount(r,n):(console.warn(`[ilha] from(): element not found: ${e}`),null)}function ke(e,t={}){let n=t.root??document.body,r=t.lazy??!1,i=[];function a(t){let n=t.getAttribute(`data-ilha`);if(!n)return;let r=e[n];if(!r){`${n}${Object.keys(e).join(`, `)}`;return}let a={},o=t.getAttribute(k);if(o){let e=s(o,`${k} on [data-ilha="${n}"]`);e!==void 0&&(a=e)}i.push(r.mount(t,a))}let o=Array.from(n.querySelectorAll(`[data-ilha]`));if(r&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(n=>{if(!e)for(let e of n)e.isIntersecting&&(a(e.target),t.unobserve(e.target))});o.forEach(e=>t.observe(e)),i.push(()=>{e=!0,t.disconnect()})}else o.forEach(a);return{unmount:()=>{let e=[];for(let t of i){let n=t();n instanceof Promise&&e.push(n)}if(e.length>0)return Promise.all(e).then(()=>{})}}}const Ae=new De({schema:null,defaultInput:null,states:[],deriveds:[],ons:[],effects:[],onMounts:[],onErrors:[],transition:null,css:null,as:null}),je=Object.assign(Ae,{html:ce,raw:K,mount:ke,from:Oe,context:de,signal:fe,batch:me,untrack:pe,onUncaughtError:Ee});function Me(e,t,n){return K(L(e,t,n))}const Ne=ce,Pe=K,Fe=q,Ie=ke,Le=Oe,Re=de;export{E as ISLAND_MOUNT_INTERNAL,Me as __ilhaJsxSlot,me as batch,Re as context,Fe as css,je as default,Le as from,Ne as html,fe as ilhaSignal,fe as signal,Ie as mount,Ee as onUncaughtError,Pe as raw,pe as untrack};
|
|
5
|
+
`)}const E=Symbol.for(`ilha.raw`),D=Symbol.for(`ilha.signalAccessor`),ie=Symbol.for(`ilha.island`),O=Symbol.for(`ilha.islandCall`),ae=Symbol.for(`ilha.islandMountInternal`),k=Symbol.for(`ilha.islandSlotTag`),A=`data-ilha-slot`,j=`data-ilha-props`,oe=`data-ilha-state`;function M(e){return`<style data-ilha-css>@scope (:scope) to ([data-ilha]){${e.replace(/<\/style/gi,`<\\/style`)}}</style>`}const N=[];function se(e,t){let n={slots:new Map,positional:0,liveHost:e,pending:t?new Map:void 0,binds:[]};return N.push(n),n}function P(){N.pop()}function F(){return N[N.length-1]}function I(e){return typeof e==`function`&&ie in e}function L(e){return e==null||typeof e!=`object`&&typeof e!=`function`?!1:O in e?!0:typeof e==`object`&&`island`in e&&I(e.island)}function R(e,t,n){let r=F(),i;i=n===void 0?r?`p:${r.positional++}`:`p:0`:`k:${n}`,r&&r.slots.set(i,{island:e,props:t});let a=g(e),o=t?` ${j}='${w(JSON.stringify(t))}'`:``;if(r?.liveHost)return _(a,i,o,``);if(r?.pending){P();try{let n=e(t);return n instanceof Promise?(r.pending.set(i,n.then(String)),_(a,i,o,z(i))):_(a,i,o,String(n))}finally{N.push(r)}}let s=e.toString(t);return _(a,i,o,s)}function z(e){return`<!--ilha-async:${w(e)}-->`}async function ce(e,t){for(let[n,r]of t){let t=await r;e=e.split(z(n)).join(t)}return e}function B(e){e[D]=!0;let t=e;return t.select=e=>K(t,e),t}function V(e){return typeof e==`function`&&D in e}function H(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function U(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=r;if(t<0||t>=e.length)return e;let a=e[t],o=i.length===0?n:U(a,i,n);if(Object.is(a,o))return e;let s=e.slice();return s[t]=o,s}if(typeof e==`object`&&e){let t=e,a=String(r),o=t[a],s=i.length===0?n:U(o,i,n);if(i.length===0){if(Object.is(o,n))return e}else if(Object.is(o,s))return e;return{...t,[a]:s}}return i.length===0?n:U(void 0,i,n)}function W(e){return typeof e==`symbol`||e===`length`?null:/^\d+$/.test(e)?Number(e):e}function G(e,t){let n=[],r=e=>e===null||typeof e!=`object`&&typeof e!=`function`?e:new Proxy(e,{get(e,t,i){let a=W(t);a!=null&&n.push(a);let o=Reflect.get(e,t,i);return a!=null&&typeof o==`object`&&o?r(o):o}});return t(r(e)),n}function K(e,t){let n=G(e(),t),r=t(e()),i=n.length===0?e():H(e(),n);if(!Object.is(r,i))throw Error(`select(): selector must only traverse nested properties or array indexes — derived or transformed values are not supported.`);return B((...r)=>{if(r.length===0)return n.length===0?t(e()):H(e(),n);let i=n.length===0?r[0]:U(e(),n,r[0]);Object.is(e(),i)||e(i)})}function q(e){return{[E]:!0,value:e}}function J(e,...t){if(typeof e==`string`)return e;let n=``;for(let r=0;r<e.length;r++)n+=e[r],r<t.length&&(n+=String(t[r]));return n}function Y(e){if(e==null||e===!0||e===!1)return``;if(Array.isArray(e))return e.map(Y).join(``);if(me(e))return e.value;if(L(e)){let t=typeof e==`function`?e():e;return R(t.island,t.props,t.key)}return I(e)?R(e,void 0,void 0):V(e)||typeof e==`function`?w(e()):w(e)}const le=new Set([`value`,`checked`,`valueAsNumber`,`valueAsDate`,`files`,`open`,`group`,`this`]),X=/\bbind:([a-zA-Z]+)\s*=\s*("|')?$/;function ue(e,t){let n=t;for(let t=0;t<e.length;t++){let r=e[t];if(n!==null)r===n&&(n=null);else if(r===`"`||r===`'`)n=r;else if(r===`>`)return{index:t,quote:n}}return{index:-1,quote:n}}function de(e){if(e instanceof Date){if(isNaN(e.getTime()))return``;let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}return``}function Z(e){let t=e.lastIndexOf(`<`);if(t===-1)return null;let n=e.slice(t);if(n.includes(`>`))return null;let r=n.match(/\bvalue\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))/);return r?r[2]??r[3]??r[4]??null:null}function fe(e,t,n,r){let i=`${e}:${t}`,a;try{a=n()}catch{a=void 0}switch(e){case`value`:return[` value="${w(a??``)}"`,i];case`valueAsNumber`:return[` value="${w(a==null?``:String(a))}"`,i];case`valueAsDate`:return[` value="${w(de(a))}"`,i];case`checked`:return[a?` checked`:``,i];case`open`:return[a?` open`:``,i];case`files`:return[``,i];case`this`:return[``,i];case`group`:{let e=Z(r);return e==null?[``,i]:[(Array.isArray(a)?a.map(String).includes(e):a!=null&&String(a)===e)?` checked`:``,i]}}}function pe(e,...t){let n=``,r=null,i=``,a=null,o=F();for(let s=0;s<e.length;s++){let c=e[s];if(r!==null&&(c.startsWith(r)&&(c=c.slice(1)),r=null),i!==``){let{index:e,quote:t}=ue(c,a);e===-1?a=t:(c=c.slice(0,e).replace(/\s*\/\s*$/,``)+` data-ilha-bind="${i}">`+c.slice(e+1),i=``,a=null)}if(s>=t.length){n+=c;continue}let l=t[s],u=c.match(X);if(u&&V(l)){let e=u[1],t=u[2]??null;if(!le.has(e)){n+=c+Y(l);continue}if(!o){let i=c.slice(0,c.length-u[0].length),a=t??`"`;n+=i+e+`=`+a+Y(l)+a,t&&(r=t);continue}let a=c.length-u[0].length,s=c.slice(0,a).replace(/\s+$/,``),d=o.binds.length;o.binds.push({kind:e,accessor:l});let[f,p]=fe(e,d,l,s);n+=s+f,i+=(i?`,`:``)+p,t&&(r=t);continue}n+=c+Y(l)}return i!==``&&(n+=` data-ilha-bind="${i}"`),{[E]:!0,value:T(n)}}function me(e){return typeof e!=`object`||!e?!1:E in e&&typeof e.value==`string`}function he(e){return me(e)?e.value:e}const Q=new Map;function ge(e,t){if(Q.has(e))return Q.get(e);let n=i(t),r=(...e)=>{if(e.length===0)return n();n(e[0])};return Q.set(e,r),r}const _e=Object.assign(ge,{delete(e){return Q.delete(e)},clear(){Q.clear()}});function ve(e){let t=i(e);return B((...e)=>{if(e.length===0)return t();t(e[0])})}function ye(t){let n=e(t);return B((...e)=>{if(!(e.length>0))return n()})}function be(e){let r,i=()=>{if(typeof r==`function`){try{r()}catch(e){console.error(e)}r=void 0}},o=t(()=>{i(),a();try{r=e()}catch(e){console.error(e)}finally{n()}});return()=>{o(),i()}}function xe(e){let t=r(void 0);try{return e()}finally{r(t)}}function Se(e){a();try{return e()}finally{n()}}function Ce(e,t){let n=B((...n)=>{if(n.length>0){t&&t(n[0]);return}return e().value});return new Proxy(n,{get(t,n,r){return n===`loading`||n===`value`||n===`error`?e()[n]:Reflect.get(t,n,r)}})}function we(){return Ce(()=>({loading:!1,value:void 0,error:void 0}))}function Te(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,Ce(()=>r,e=>{r.loading=!1,r.value=e,r.error=void 0}));return new Proxy({},{get(e,n){if(typeof n==`string`)return t.get(n)??we()}})}function Ee(e,n,a,o){let s=new Map;for(let t of e){let e;if(o!=null&&t.key in o)e={...o[t.key]};else if(t.fn.constructor.name===`AsyncFunction`||t.fn.constructor.name===`AsyncGeneratorFunction`)e={loading:!0,value:void 0,error:void 0};else{let r=new AbortController;try{let i=t.fn({state:n,input:a,signal:r.signal});i instanceof Promise?(e={loading:!0,value:void 0,error:void 0},i.catch(()=>{})):e={loading:!1,value:i,error:void 0}}catch(t){e={loading:!1,value:void 0,error:t instanceof Error?t:Error(String(t))}}finally{r.abort()}}let r=i(e);s.set(t.key,r)}let c=new Map;for(let t of e){let e=s.get(t.key);c.set(t.key,Ce(()=>e(),t=>{let n=r(void 0);e({loading:!1,value:t,error:void 0}),r(n)}))}return{proxy:new Proxy({},{get(e,t){if(typeof t==`string`)return c.get(t)??we()}}),setup:()=>{let i=[];for(let c of e){let e=s.get(c.key),l=new AbortController,u=o!=null&&c.key in o,d=t(()=>{l.abort(),l=new AbortController;let t=l,i;try{i=c.fn({state:n,input:a,signal:t.signal})}catch(t){if(u){u=!1;return}let n=r(void 0);e({loading:!1,value:void 0,error:t instanceof Error?t:Error(String(t))}),r(n);return}if(u){u=!1,i instanceof Promise&&i.catch(()=>{});return}if(!(i instanceof Promise)){let t=r(void 0);e({loading:!1,value:i,error:void 0}),r(t);return}let o=r(void 0);e({loading:!0,value:e().value,error:void 0}),r(o),i.then(n=>{t.signal.aborted||e({loading:!1,value:n,error:void 0})}).catch(n=>{t.signal.aborted||e({loading:!1,value:void 0,error:n instanceof Error?n:Error(String(n))})})});i.push(()=>{d(),l.abort()})}return()=>i.forEach(e=>e())}}}const De=`data-ilha-bind`;function Oe(e){let t=[];for(let n of e.split(`,`)){let[e,r]=n.split(`:`);if(!e||!r)continue;let i=Number(r);!Number.isInteger(i)||i<0||t.push({kind:e,index:i})}return t}function ke(e,t){let n=e;switch(t){case`value`:return{event:e.tagName===`SELECT`?`change`:`input`,read:e=>e.value,write:(e,t)=>e.value=t==null?``:String(t)};case`valueAsNumber`:return{event:`input`,read:e=>{let t=e.valueAsNumber;return Number.isNaN(t)?null:t},write:(e,t)=>e.value=t==null||Number.isNaN(t)?``:String(t)};case`valueAsDate`:return{event:`input`,read:e=>e.valueAsDate,write:(e,t)=>{e.value=de(t)}};case`checked`:return{event:`change`,read:e=>e.checked,write:(e,t)=>e.checked=!!t};case`files`:return{event:`change`,read:e=>e.files,write:()=>{}};case`open`:return{event:`toggle`,read:e=>e.open,write:(e,t)=>e.open=!!t};case`this`:return{event:null,read:()=>void 0,write:()=>{}};case`group`:{let e=n.type===`checkbox`;return{event:`change`,read:t=>{let n=t;return e?{__ilhaGroup:!0,value:n.value,checked:n.checked}:n.checked?n.value:void 0},write:(t,n)=>{let r=t;e?r.checked=(Array.isArray(n)?n.map(String):[]).includes(r.value):r.checked=n!=null&&String(n)===r.value}}}}}function Ae(e,t){if(t.length===0)return()=>{};let n=[],r=[];e.hasAttribute(De)&&r.push(e);for(let t of e.querySelectorAll(`[${De}]`))r.push(t);for(let e of r){let r=Oe(e.getAttribute(De));for(let i of r){let r=t[i.index];if(!r||r.kind!==i.kind)continue;let{event:a,read:o,write:s}=ke(e,i.kind),c=r.accessor;if(i.kind===`this`){c(e),n.push(()=>c(null));continue}try{s(e,c())}catch{}if(a===null)continue;let l=()=>{let t=o(e);if(i.kind===`group`){let e=t;if(e===void 0)return;if(typeof e==`object`&&e.__ilhaGroup){let t=c(),n=Array.isArray(t)?[...t]:[],r=n.findIndex(t=>String(t)===e.value);if(e.checked&&r===-1){let r=e.value,i=Array.isArray(t)&&t.length>0?t[0]:void 0;if(i!==void 0)if(typeof i==`number`){let e=Number(r);r=Number.isNaN(e)?r:e}else typeof i==`boolean`&&(r=!!r);n.push(r)}else!e.checked&&r!==-1&&n.splice(r,1);c(n);return}let n=c(),r=e;if(typeof n==`number`&&typeof e==`string`){let t=Number(e);r=Number.isNaN(t)?0:t}else typeof n==`boolean`&&(r=!!e);c(r);return}let n=c(),r=t;if(typeof n==`number`&&typeof t==`string`){let e=Number(t);r=Number.isNaN(e)?0:e}else typeof n==`boolean`&&(r=!!t);c(r)};e.addEventListener(a,l),n.push(()=>e.removeEventListener(a,l))}}return()=>n.forEach(e=>e())}function je(e){let t=e.lastIndexOf(`@`),n=t===-1?``:e.slice(0,t),r=(t===-1?e:e.slice(t+1)).split(`:`),i=r[0],a=new Set(r.slice(1));return{selector:n,eventType:i,options:{once:a.has(`once`),capture:a.has(`capture`),passive:a.has(`passive`)},abortable:a.has(`abortable`)}}function Me(e){if(typeof AbortSignal.any==`function`)return AbortSignal.any(e);let t=new AbortController,n=[];for(let r of e){if(r.aborted)return t.abort(r.reason),n.forEach(e=>e()),t.signal;let e=()=>t.abort(r.reason);r.addEventListener(`abort`,e,{once:!0}),n.push(()=>r.removeEventListener(`abort`,e))}return t.signal.aborted||t.signal.addEventListener(`abort`,()=>{n.forEach(e=>e())}),t.signal}const $=new Set;function Ne(e,t){if($.size===0)return!1;for(let n of $)try{n(e,t)}catch(e){console.error(e)}return!0}function Pe(e){return $.add(e),()=>{$.delete(e)}}var Fe=class e{_cfg;constructor(e){this._cfg=e}input(t){let n=null,r=null;return t!==void 0&&(S(t)?n=t:r=t),new e({schema:n,defaultInput:r,states:[],deriveds:[],ons:[],effects:[],onMounts:[],onErrors:[],transition:null,css:null,as:null})}as(t){return new e({...this._cfg,as:h(t)})}state(t,n){let r=this._cfg;return new e({...r,states:[...r.states,{key:t,init:n}]})}derived(t,n){let r=this._cfg;return new e({...r,deriveds:[...r.deriveds,{key:t,fn:n}]})}on(t,n){let r=je(t);return new e({...this._cfg,ons:[...this._cfg.ons,{selector:r.selector,event:r.eventType,options:r.options,abortable:r.abortable,handler:n}]})}effect(t){return new e({...this._cfg,effects:[...this._cfg.effects,{fn:t}]})}onMount(t){return new e({...this._cfg,onMounts:[...this._cfg.onMounts,{fn:t}]})}onError(t){return new e({...this._cfg,onErrors:[...this._cfg.onErrors,{fn:t}]})}transition(t){return new e({...this._cfg,transition:t})}css(t,...n){let r;if(typeof t==`string`)r=t;else{let e=``;for(let r=0;r<t.length;r++)e+=t[r],r<n.length&&(e+=String(n[r]));r=e}return new e({...this._cfg,css:r})}render(e){let{schema:o,defaultInput:s,states:c,deriveds:d,ons:f,effects:p,onMounts:m,onErrors:g,transition:_,css:v,as:y}=this._cfg,b=v==null?``:M(v),x=y??`div`;function S(e){let t={...s??{},...e??{}};return o?re(o,t):t}function C(e,t,n){let r=se(t,n);try{let t=he(e()),n=r.slots,i=r.binds;if(r.pending&&r.pending.size>0){let e=r.pending;return(async()=>({html:await ce(t,e),slots:n,binds:i}))()}return{html:t,slots:n,binds:i}}finally{P()}}function T(e){let t={};for(let n of c){let r=typeof n.init==`function`?n.init(e):n.init,i=B((...e)=>{if(e.length===0)return r});t[n.key]=i}return t}function E(e,t){let n={};for(let r of c){let a=i(t&&r.key in t?t[r.key]:typeof r.init==`function`?r.init(e):r.init),o=B((...e)=>{if(e.length===0)return a();a(e[0])});n[r.key]=o}return n}function D(){if(typeof document<`u`)return document.createElement(`div`);let e={matches:()=>!1,querySelector:()=>null,querySelectorAll:()=>[],setAttribute:()=>{},getAttribute:()=>null,removeAttribute:()=>{},appendChild:()=>e};return e}function N(e,t,n){if(m.length===0||F())return;let i=D(),a=[];for(let o of m){let s=r(void 0),c;try{c=o.fn({state:t,derived:n,input:e,host:i,hydrated:!1})}catch(r){let a=r instanceof Error?r:Error(String(r));if(g.length===0)Ne(a,`mount`)||console.error(a);else for(let r of g)try{r.fn({error:a,source:`mount`,state:t,derived:n,input:e,host:i})}catch(e){console.error(e)}}finally{r(s)}typeof c==`function`&&a.push(c)}for(let e of a.reverse())try{e()}catch(e){let t=e instanceof Error?e:Error(String(e));g.length===0&&(Ne(t,`mount`)||console.error(t))}}function I(t,n=!1){let i=S(t),a=E(i),o=d.map(e=>{let t=r(void 0);try{return{key:e.key,result:e.fn({state:a,input:i,signal:new AbortController().signal})}}catch(t){return{key:e.key,result:Promise.reject(t)}}finally{r(t)}});if(!o.some(e=>e.result instanceof Promise)||n){let t={};for(let e of o)e.result instanceof Promise?t[e.key]={loading:!0,value:void 0,error:void 0}:t[e.key]={loading:!1,value:e.result,error:void 0};let n=Te(t);F()||N(i,a,n);let s=r(void 0);try{let{html:t}=C(()=>e({state:a,derived:n,input:i}));return b+t}finally{r(s)}}return Promise.all(o.map(async e=>{try{return{key:e.key,envelope:{loading:!1,value:await Promise.resolve(e.result),error:void 0}}}catch(t){return{key:e.key,envelope:{loading:!1,value:void 0,error:t instanceof Error?t:Error(String(t))}}}})).then(async t=>{let n={};for(let e of t)n[e.key]=e.envelope;let o=Te(n);F()||N(i,a,o);let s=r(void 0);try{let{html:t}=await C(()=>e({state:a,derived:o,input:i}),void 0,!0);return b+t}finally{r(s)}})}function L(e,t){return R(e,t).unmount}function R(o,s){if(s===void 0){let e=o.getAttribute(j);if(e){let t=l(e,j);t!==void 0&&(s=t)}}let c=i(S(s)),h=new Proxy({},{get(e,t){return c()[t]},has(e,t){return t in c()},ownKeys(){let e=r(void 0);try{return Reflect.ownKeys(c())}finally{r(e)}},getOwnPropertyDescriptor(e,t){let n=r(void 0);try{return Reflect.getOwnPropertyDescriptor(c(),t)}finally{r(n)}}}),v,y=o.getAttribute(oe);if(y){let e=l(y,oe);e!==void 0&&(v=e)}let x=v?Object.fromEntries(Object.entries(v).filter(([e])=>e!==`_derived`&&e!==`_skipOnMount`)):void 0,re=v?._derived,w;if(re){w={};for(let[e,t]of Object.entries(re))t.error&&!(t.error instanceof Error)?w[e]={...t,error:Error(String(t.error))}:w[e]=t}let T=v!=null,D=x!=null&&Object.keys(x).length>0,ie=T&&v?._skipOnMount===!0&&D,O=E(h,x),k=[],M=new AbortController;k.push(()=>M.abort());let{proxy:N,setup:se}=Ee(d,O,h,w),P=()=>{};function F(e,t){let n=e instanceof Error?e:Error(String(e));if(g.length===0){Ne(n,t)||console.error(n);return}for(let e of g)try{e.fn({error:n,source:t,state:O,derived:N,input:h,host:o})}catch(e){console.error(e)}}if(_?.enter)try{let e=_.enter(o);e instanceof Promise&&e.catch(e=>F(e,`transition`))}catch(e){F(e,`transition`)}let I=new Map,L=new Map;function R(e,t){I.delete(e);let n=Symbol(),r=t.unmount(),i=t=>{let r=L.get(e);!r||r.token!==n||(r.el.remove(),t?.remove(),L.delete(e))};if(r instanceof Promise)return L.set(e,{el:t.el,token:n}),r.finally(()=>i());t.el.remove()}function z(e){let t=e;for(;t&&t!==o;){if(t.hasAttribute(`data-ilha`))return!1;t=t.parentElement}return t===o}function ce(){let e=new Set([...L.values()].map(e=>e.el)),t=new Map;for(let n of o.querySelectorAll(`[${A}]`)){if(e.has(n))continue;let r=n.getAttribute(A);r===null||t.has(r)||z(n)&&t.set(r,n)}return t}function B(e){for(let[t,n]of I)e.has(t)||R(t,n);for(let[t,n]of I){let r=e.get(t);r&&r.island!==n.island&&R(t,n)}let t=null;for(let[n,{island:i,props:a}]of e){let e=I.get(n);if(e){e.updateProps(a);continue}t===null&&(t=ce());let o=t.get(n)??null;if(!o)continue;let s=a;if(s===void 0){let e=o.getAttribute(j)??o.getAttribute(`data-props`);if(e){let t=l(e,`props on [${A}="${n}"]`);t!==void 0&&(s=t)}}let c=r(void 0),u;try{let e=i[ae];u=e?e(o,s):{unmount:i.mount(o,s),updateProps:()=>{}}}finally{r(c)}I.set(n,{el:o,island:i,...u})}}let V=[],H=new Set,U=new WeakMap;function W(){for(let e of f)e.options.once&&H.has(e)||(e.selector===``?[o]:Array.from(o.querySelectorAll(e.selector))).forEach(t=>{let r=r=>{if(e.options.once){H.add(e);for(let t of V.filter(t=>t.entry===e))t.target.removeEventListener(t.type,t.fn,t.options);V.splice(0,V.length,...V.filter(t=>t.entry!==e))}let i=r.target instanceof Element?r.target:t,s=e.selector===``?i:t,c;if(e.abortable){let n=U.get(e);n||(n=new WeakMap,U.set(e,n));let r=n.get(t);r&&r.abort();let i=new AbortController;n.set(t,i),c=Me([M.signal,i.signal])}else c=M.signal;let l;a();try{l=e.handler({state:O,derived:N,input:h,host:o,target:s,event:r,signal:c})}catch(e){F(e,`on`),n();return}n(),l instanceof Promise&&l.catch(e=>{e&&e.name===`AbortError`||F(e,`on`)})},i={...e.options,once:!1};t.addEventListener(e.event,r,i),V.push({target:t,type:e.event,fn:r,options:i,entry:e})})}function G(){for(let e of V)e.target.removeEventListener(e.type,e.fn,e.options);V.length=0}function K(){for(let e of m){let t=r(void 0),n;try{n=e.fn({state:O,derived:N,input:h,host:o,hydrated:T})}catch(e){F(e,`mount`)}finally{r(t)}if(n){let e=n;k.push(()=>{try{e()}catch(e){F(e,`mount`)}})}}}let q=T&&o.childNodes.length>0;T&&m.length>0&&!ie&&K();let J=C(()=>e({state:O,derived:N,input:h}),q?o:void 0);q||(o.innerHTML=b+J.html);let Y=Ae(o,J.binds);k.push(()=>Y()),B(J.slots),k.push(()=>I.forEach(e=>e.unmount())),W(),!T&&m.length>0&&K();for(let e of p){let r,i=null,s=t(()=>{if(r){try{r()}catch(e){F(e,`effect`)}r=void 0}i&&i.abort(),i=new AbortController;let t=Me([M.signal,i.signal]);a();try{r=e.fn({state:O,derived:N,input:h,host:o,signal:t})}catch(e){F(e,`effect`)}finally{n()}});k.push(()=>{if(s(),r)try{r()}catch(e){F(e,`effect`)}i&&i.abort()})}P=se(),k.push(P);let le=!1,X=J.html,ue=0,de=t(()=>{let t=++ue,{html:n,slots:r,binds:i}=C(()=>e({state:O,derived:N,input:h}),o),a=b+n;if(!le){if(le=!0,q){for(let[e,t]of I){let n=r.get(e);n&&t.updateProps(n.props)}if(n===X)return}if(n===X||I.size>0&&I.size===r.size&&[...r.keys()].every(e=>I.has(e))&&ee(X,n,r.keys()))return}G(),Y();let s=I.size,c=[];for(let[e,t]of I)if(!r.has(e)){let n=R(e,t);n instanceof Promise&&c.push(n)}for(let[e,t]of I){let n=r.get(e);if(n&&n.island!==t.island){let n=R(e,t);n instanceof Promise&&c.push(n)}}let l=()=>{if(t!==ue)return;let e=new Map,n=r.size<s;for(let[t,i]of I){if(!r.has(t)||!i.el.isConnected)continue;if(n&&t.startsWith(`p:`)){R(t,i);continue}let a=i.el.tagName.toLowerCase(),o=document.createElement(a);o.setAttribute(A,t);let s=te(r.get(t)?.props);s!==``&&o.setAttribute(j,s),i.el.replaceWith(o),e.set(t,i.el)}let c=document.createElement(`template`),l=o.tagName.toLowerCase();if(c.innerHTML=`<${l}>${a}</${l}>`,ne(o,c.content.firstElementChild),e.size>0){let t=ce();for(let[n,r]of e){let e=t.get(n);e&&e.replaceWith(r)}}W(),Y=Ae(o,i),B(r)};c.length>0?Promise.allSettled(c).then(e=>{for(let t of e)t.status===`rejected`&&console.error(t.reason);l()}):l()}),Z=!1;return{unmount:()=>{if(Z)return;Z=!0,de(),G();let e=[];for(let[,t]of I){let n=t.unmount();n instanceof Promise&&e.push(n)}if(_?.leave)try{let t=_.leave(o);t instanceof Promise&&e.push(t)}catch(e){F(e,`transition`)}let t=()=>{for(let e of k)e()};if(e.length>0)return Promise.all(e).then(t).catch(e=>{F(e,`transition`),t()});t()},updateProps:e=>{if(Z)return;let t=S(e);u(c(),t)||c(t)}}}let z=function(e){return F()?{[O]:!0,island:z,props:e,key:void 0}:I(e)};return z.toString=e=>I(e,!0),z.mount=(e,t)=>L(e,t),z[ae]=(e,t)=>R(e,t),z[k]=x,z.key=e=>{if(typeof e!=`string`||e.trim().length===0)throw Error(`island.key() requires a non-empty string.`);if(e.includes(`:`))throw Error(`island.key() key cannot contain the slot separator ":" (got "${e}").`);let t=(t=>({[O]:!0,island:z,props:t,key:e}));return t[O]=!0,t},z[ie]=!0,z.define=(e,t)=>{if(typeof customElements>`u`||typeof HTMLElement>`u`){`${e}`;return}let n=new Set([`annotation-xml`,`color-profile`,`font-face`,`font-face-src`,`font-face-uri`,`font-face-format`,`font-face-name`,`missing-glyph`]);if(typeof e!=`string`||!/^[a-z][a-z0-9._-]*-[a-z0-9._-]*$/.test(e)||n.has(e)){`${e}`;return}if(customElements.get(e)){`${e}`;return}let r=t?.observe??[];class i extends HTMLElement{static observedAttributes=r;_handle=null;_props;_unmounting=!1;_reconnect=!1;get props(){return this._props}set props(e){this._props=e,this._handle&&!this._unmounting&&this._handle.updateProps(this._mergedProps())}_mergedProps(){let e={},t=!1;for(let n of r){let r=this.getAttribute(n);r!==null&&(e[n]=r,t=!0)}if(!(!t&&this._props===void 0))return{...e,...this._props??{}}}connectedCallback(){if(this._unmounting){this._reconnect=!0;return}this._handle||=R(this,this._mergedProps())}disconnectedCallback(){!this._handle||this._unmounting||(this._unmounting=!0,this._reconnect=!1,Promise.resolve(this._handle.unmount()).finally(()=>{this._handle=null,this._unmounting=!1,this._reconnect&&(this._reconnect=!1,this.isConnected&&(this._handle=R(this,this._mergedProps())))}))}attributeChangedCallback(){this._handle&&!this._unmounting&&this._handle.updateProps(this._mergedProps())}}customElements.define(e,i)},z.hydratable=async(e,t)=>{let{name:n,as:i=`div`,snapshot:a=!1,skipOnMount:o}=t,s=h(i),l=e??{},u=await I(l),f=w(JSON.stringify(l)),p=``;if(a!==!1){let e=a===!0||a.state!==!1,t=a===!0||a.derived!==!1,n=o??(e||t),i={},s=S(l),u=T(s);if(e)for(let e of c)i[e.key]=u[e.key]();if(t){let e={};for(let t of d){let n=r(void 0),i,a,o=!1;try{i=t.fn({state:u,input:s,signal:new AbortController().signal})}catch(e){o=!0,a=e}finally{r(n)}if(o){e[t.key]={loading:!1,value:void 0,error:a instanceof Error?a.message:String(a)};continue}try{let n=await Promise.resolve(i);e[t.key]={loading:!1,value:n,error:void 0}}catch(n){e[t.key]={loading:!1,value:void 0,error:n instanceof Error?n.message:String(n)}}}i._derived=e}n&&(i._skipOnMount=!0),p=` ${oe}='${w(JSON.stringify(i))}'`}return`<${s} data-ilha="${w(n)}" ${j}='${f}'${p}>${u}</${s}>`},z}};function Ie(e,t,n){let r=typeof e==`string`?document.querySelector(e):e;return r?t.mount(r,n):(console.warn(`[ilha] from(): element not found: ${e}`),null)}function Le(e,t={}){let n=t.root??document.body,r=t.lazy??!1,i=[];function a(t){let n=t.getAttribute(`data-ilha`);if(!n)return;let r=e[n];if(!r){`${n}${Object.keys(e).join(`, `)}`;return}let a={},o=t.getAttribute(j);if(o){let e=l(o,`${j} on [data-ilha="${n}"]`);e!==void 0&&(a=e)}i.push(r.mount(t,a))}let o=Array.from(n.querySelectorAll(`[data-ilha]`));if(r&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(n=>{if(!e)for(let e of n)e.isIntersecting&&(a(e.target),t.unobserve(e.target))});o.forEach(e=>t.observe(e)),i.push(()=>{e=!0,t.disconnect()})}else o.forEach(a);return{unmount:()=>{let e=[];for(let t of i){let n=t();n instanceof Promise&&e.push(n)}if(e.length>0)return Promise.all(e).then(()=>{})}}}const Re=new Fe({schema:null,defaultInput:null,states:[],deriveds:[],ons:[],effects:[],onMounts:[],onErrors:[],transition:null,css:null,as:null}),ze=Object.assign(Re,{html:pe,raw:q,mount:Le,from:Ie,context:_e,signal:ve,computed:ye,batch:Se,untrack:xe,onUncaughtError:Pe});function Be(e,t,n){return q(R(e,t,n))}const Ve=pe,He=q,Ue=J,We=Le,Ge=Ie,Ke=_e;export{ae as ISLAND_MOUNT_INTERNAL,Be as __ilhaJsxSlot,Se as batch,ye as computed,Ke as context,Ue as css,ze as default,be as effect,Ge as from,Ve as html,ve as ilhaSignal,ve as signal,We as mount,Pe as onUncaughtError,He as raw,xe as untrack};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSX, r as jsxDEV, t as Fragment } from "./jsx-runtime-
|
|
1
|
+
import { a as JSX, r as jsxDEV, t as Fragment } from "./jsx-runtime-DBCAZ9YL.js";
|
|
2
2
|
export { Fragment, type JSX, jsxDEV };
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSX, i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./jsx-runtime-
|
|
2
|
-
export { Fragment, JSX, jsx, jsxDEV, jsxs };
|
|
1
|
+
import { a as JSX, i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./jsx-runtime-DBCAZ9YL.js";
|
|
2
|
+
export { Fragment, type JSX, jsx, jsxDEV, jsxs };
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__ilhaJsxSlot as e,html as t,raw as n}from"./index.js";const r=Symbol.for(`ilha.raw`),i=Symbol.for(`ilha.signalAccessor`),a=Symbol.for(`ilha.island`),o=Symbol.for(`ilha.islandCall`),s=Symbol.for(`ilha.renderPart`),c=/^[A-Za-z_:][A-Za-z0-9:._-]*$/,l=/^[A-Za-z][A-Za-z0-9]*$/,u=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),d=/^(-{2}[a-zA-Z][a-zA-Z0-9-]*|-?[a-zA-Z][a-zA-Z0-9-]*)$/,f=new Set([`href`,`src`,`action`,`formaction`,`cite`,`data`,`poster`]),p=/^(?!javascript:|data:text\/html|data:text\/xml|data:application\/xhtml\+xml|data:image\/svg|vbscript:)/i;function m(e){return!!(e&&typeof e==`object`&&r in e)}function
|
|
1
|
+
import{__ilhaJsxSlot as e,html as t,raw as n}from"./index.js";const r=Symbol.for(`ilha.raw`),i=Symbol.for(`ilha.signalAccessor`),a=Symbol.for(`ilha.island`),o=Symbol.for(`ilha.islandCall`),s=Symbol.for(`ilha.renderPart`),c=/^[A-Za-z_:][A-Za-z0-9:._-]*$/,l=/^[A-Za-z][A-Za-z0-9]*$/,u=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),d=/^(-{2}[a-zA-Z][a-zA-Z0-9-]*|-?[a-zA-Z][a-zA-Z0-9-]*)$/,f=new Set([`href`,`src`,`action`,`formaction`,`cite`,`data`,`poster`]),p=/^(?!javascript:|data:text\/html|data:text\/xml|data:application\/xhtml\+xml|data:image\/svg|vbscript:)/i;function m(e){return p.test(e.replace(/[\u0000-\u0020]/g,``))}function h(e){return!!(e&&typeof e==`object`&&r in e)}function g(e){return typeof e==`function`&&i in e}function _(e){return typeof e==`function`&&a in e}function v(e){return e==null||typeof e!=`object`&&typeof e!=`function`?!1:o in e?!0:typeof e==`object`&&`island`in e&&_(e.island)}function y(e){return Array.isArray(e)?e.filter(Boolean).join(` `):e&&typeof e==`object`?Object.entries(e).filter(([,e])=>!!e).map(([e])=>e).join(` `):String(e)}function b(e,t){let n=e&&`children`in e?e.children:void 0;return(t.length>0?t:n===void 0?[]:[n]).flat(1)}function x(e){let t=String(e);if(t.trim().length===0)throw Error(`jsx key requires a non-empty string.`);if(t.includes(`:`))throw Error(`jsx key cannot contain the slot separator ":" (got "${t}").`);return t}function S(e,t){let n=e?.key,r=t??(typeof n==`string`||typeof n==`number`?n:void 0);if(r!=null)return x(r)}function C(e){return Object.entries(e).map(([e,t])=>{if(!d.test(e))return``;let n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),r=String(t);return/[<>{};]/.test(r)||/expression\(/i.test(r)||/javascript:/i.test(r)?``:`${n}:${r}`}).filter(Boolean).join(`;`)}function w(e,t,n,r){if(r==null||r===!1||n===`children`||n===`key`||n===`__proto__`||n===`constructor`||n===`prototype`)return;if(n.startsWith(`bind:`)){let[i,a,...o]=n.split(`:`);if(i!==`bind`||o.length>0||!a||!l.test(a)||!g(r))return;e[e.length-1]+=` ${i}:${a}=`,t.push(r),e.push(``);return}if(!c.test(n))return;let i=n;if(i===`className`&&(i=`class`),i===`htmlFor`&&(i=`for`),!i.startsWith(`on`)&&i!==`srcdoc`&&(i===`class`&&(r=y(r)),i===`style`&&r&&typeof r==`object`&&(r=C(r)),!((f.has(i)||/:(href|src|action|formaction|cite|data|poster)$/.test(i))&&!m(typeof r==`string`?r:String(r))))){if(r===!0){e[e.length-1]+=` ${i}`;return}e[e.length-1]+=` ${i}="`,t.push(r),e.push(`"`)}}function T(e,n,r){let i=[`<${e}`],a=[];if(n)for(let[e,t]of Object.entries(n))w(i,a,e,t);if(i[i.length-1]+=`>`,!u.has(e)){for(let e of r)a.push(e),i.push(``);i[i.length-1]+=`</${e}>`}return t(i,...a)}function E(r,i,a,...o){let c=typeof a==`string`||typeof a==`number`,l=c?a:void 0,u=b(i,c||a===void 0?o:[a,...o]);if(typeof r==`function`){let a=S(i,typeof l==`string`||typeof l==`number`?l:void 0),o={...i,...u.length>0?{children:u}:{}};delete o.key;let c=r(Object.keys(o).length?o:{});return v(c)?(a!==void 0&&(c.key=a),t`${c}`):h(c)?c:typeof c==`string`&&_(r)?e(r,o,a):typeof c==`string`?t`${c}`:typeof c==`object`&&c&&Object.getPrototypeOf(c)===Object.prototype&&c[s]===!0&&typeof c.toString==`function`?n(String(c)):t`${c}`}return T(r,i,u)}const D=E;function O(e,...n){let r=b(e,n);return t([``,...r.map(()=>``)],...r)}function k(e,t,n,r,i){return E(e,t,n)}export{O as Fragment,E as jsx,k as jsxDEV,D as jsxs};
|