@firsthandjs/dom 0.9.1 → 0.10.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../src/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAiCvF"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Where a render function keeps what it made (ADR-0026).
3
+ *
4
+ * A render function runs as a whole and has to write into the DOM it already
5
+ * made, so something has to survive between runs. That is a store: one per
6
+ * instance, declared in the setup — which runs once — with a numbered slot per
7
+ * site the compiler found. The index is fixed at compile time, so a site inside
8
+ * an `if` keeps its place whether or not the branch was taken.
9
+ *
10
+ * Everything here is the compiler/runtime protocol. The names and the
11
+ * signatures are what `@firsthandjs/compiler` emits against, and changing one
12
+ * is a protocol change (ARCHITECTURE section 1.1).
13
+ */
14
+ import { type Owner, type Signal } from '@firsthandjs/core';
15
+ import type { ChildSlot } from './nodes.js';
16
+ /**
17
+ * One place a run writes to, and what it last put there.
18
+ *
19
+ * A render function runs as a whole, so the DOM it describes has to be the DOM
20
+ * it already made: created on the first run, written on every one after. These
21
+ * records are what survives between runs — the node, and the last value, so a
22
+ * run that produces what is already on screen writes nothing.
23
+ */
24
+ export type Slot = {
25
+ /** What this site made, or what a write currently owns. */
26
+ node?: ChildSlot;
27
+ /** The last primitive written here, when the last thing written was one. */
28
+ text?: string | undefined;
29
+ /** The last value written to an attribute or a property. */
30
+ last?: unknown;
31
+ /** What the site made besides its node: parts, listeners, components. */
32
+ owner?: Owner;
33
+ /** The run that last reached this site. */
34
+ seen?: number;
35
+ /** A prop a run feeds a child, held so the child keeps its instance. */
36
+ cell?: Signal<unknown>;
37
+ };
38
+ /**
39
+ * Where a run keeps its sites.
40
+ *
41
+ * One per instance, made in the setup — which runs once, so there is nothing
42
+ * to look up and nothing ambient. What a site makes belongs to `owner`, the
43
+ * component's own, rather than to the run that happened to make it: a run's
44
+ * scope is cleared before it runs again, and anything left there would be
45
+ * disposed by the second run.
46
+ */
47
+ export type Store = {
48
+ slots: (Slot | undefined)[];
49
+ owner: Owner | null;
50
+ /** Which run is in progress, so that what it did not reach can be found. */
51
+ generation: number;
52
+ /** The component this belongs to, for what development has to say about it. */
53
+ name: string;
54
+ /** Whether this run has changed anything. Development only. */
55
+ busy?: boolean;
56
+ /** How many runs in a row have changed nothing. Development only. */
57
+ quiet?: number;
58
+ };
59
+ /** Declared once per instance by the compiler, in the setup. */
60
+ export declare function store(name?: string): Store;
61
+ /** Notes that this run has actually changed something. */
62
+ export declare function wrote(store: Store): void;
63
+ /** The record for one site, made the first time a run reaches it. */
64
+ export declare function site(store: Store, index: number): Slot;
65
+ /**
66
+ * Opens a site: what it makes now belongs to the instance, not to this run.
67
+ *
68
+ * Returns the owner to restore, which the compiler hands back to `close`.
69
+ */
70
+ export declare function open(store: Store, slot: Slot): Owner | null;
71
+ export declare function close(previous: Owner | null): void;
72
+ /**
73
+ * Ends a run, and disposes what it did not reach.
74
+ *
75
+ * A branch the run has left is gone, not hidden: its components run their
76
+ * cleanups and its parts stop, exactly as if the markup had never been there.
77
+ * Coming back builds it again. That is what the control flow says, so it is
78
+ * what happens.
79
+ */
80
+ export declare function ran<T>(store: Store, value: T): T;
81
+ /**
82
+ * A prop whose value belongs to the run, as something the child can hold.
83
+ *
84
+ * The child keeps its instance across runs, so its props cannot be getters
85
+ * over the run that made them — that value belongs to one call. It gets a cell
86
+ * instead, made the first time and written afterwards, so a prop that did not
87
+ * change wakes nothing.
88
+ */
89
+ export declare function cell(store: Store, index: number, value: unknown): Signal<unknown>;
90
+ /**
91
+ * Writes a child position a run owns.
92
+ *
93
+ * The same text twice is not a write: `data` would accept it, and measuring
94
+ * says that comparing a remembered string costs half what setting one does.
95
+ * Anything else goes through `applyChild`, where a node that has not moved is
96
+ * recognised and left where it is.
97
+ *
98
+ * Five parameters, against the limit in docs/architecture/code-rules.md §2.
99
+ * The compiler emits this call for every dynamic child of every run, and its
100
+ * arity is the compiler/runtime protocol (ARCHITECTURE section 1.1): an options
101
+ * object here would be one allocation per child per run, on the path a run
102
+ * exists to keep cheap.
103
+ */
104
+ export declare function writeChild(store: Store, index: number, parent: Node, marker: Node | null, value: unknown): void;
105
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAOL,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,4DAA4D;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CACxB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,EAAE,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC5B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,IAAI,SAAK,GAAG,KAAK,CAEtC;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAExC;AAED,qEAAqE;AACrE,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAStD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAI3D;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAgBhD;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAcjF;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,KAAK,EAAE,OAAO,GACb,IAAI,CAyBN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/dom",
3
- "version": "0.9.1",
3
+ "version": "0.10.1",
4
4
  "description": "DOM parts, templates, components, portals and keyed lists for Firsthand.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "dependencies": {
33
- "@firsthandjs/core": "0.9.1"
33
+ "@firsthandjs/core": "0.10.1"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">=20.11.0"
@@ -1 +0,0 @@
1
- import{b as S,e as T,f as A,g as N,h as g,i as j,s as L,t as H}from"./chunk-P4PXTIUD.js";var C=null,E=new WeakMap;function $n(n){C=n,E=new WeakMap}var R=class extends Error{constructor(e){super(`${e} is not a Firsthand component. If it is a React component, import '@firsthandjs/react/auto' once at startup to render React components directly, or wrap it with fromReact(). Otherwise, declare it with component().`),this.name="FirsthandComponentError"}};function M(n){let e=E.get(n);if(e!==void 0)return e;if(C===null){let o=typeof n=="function"&&n.name!==""?n.name:"The value";throw new R(o)}let t=C(n);return E.set(n,t),t}import{signal as un,createOwner as D,devEnterSetup as V,devExitSetup as y,disposeOwner as ln,getOwner as F,handleError as W,setOwner as w,untrack as I}from"@firsthandjs/core";var z=Symbol.for("firsthand.component"),K=Symbol.for("firsthand.view"),an=0,Z="firsthand";function Mn(n){Z=n}function Dn(n,e,t,o){let s=Object.assign(i=>fn(s,i),{[z]:!0,setup:n,options:e,id:t??`c${String(++an)}`,tag:void 0});return Object.defineProperty(s,"name",{configurable:!0,value:o??(n.name===""?"Component":n.name)}),t===void 0&&(`${s.name}`,void 0),(e?.tag!==void 0||e?.shadow===!0)&&mn(s,typeof e.tag=="string"?e.tag:void 0),s}function Vn(n){return typeof n=="function"&&z in n}function Fn(n){return n[K]=!0,n}function fn(n,e){if(Object.freeze(e),n.setup===void 0)return K in n?g(()=>n(e)):M(n)(e);if(n.tag!==void 0)return yn(n,e);let t=D(F());n.name;let o=w(t);try{V(n.id);let r=I(()=>n.setup(e));return y(),w(o),r}catch(r){return y(),w(o),W(r,t),null}}function pn(n){let e=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase();return`${Z}-${e}`}function mn(n,e){let t=n;if(t.tag!==void 0)return t.tag;let o=e??pn(t);return customElements.get(o)!==void 0&&(o=`${o}-${t.id.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}`),t.tag=o,customElements.define(o,wn(t)),o}function wn(n){let e=n.options?.shadow===!0,t=n.options?.attributes,o=t!==void 0?Object.keys(t):[];return class extends HTMLElement{static observedAttributes=o;constructor(){super(),this.$owner=null,this.$props=null,this.$attrs=null,this.$standalone=!1}connectedCallback(){this.$owner===null&&(this.$standalone=!0,this.$attrs={},this.$props=gn(this,t,this.$attrs),q(this,n,e))}disconnectedCallback(){!this.$standalone||this.$owner===null||(ln(this.$owner),this.$owner=null)}attributeChangedCallback(s,i,u){let l=this.$attrs?.[s];l!==void 0&&(l.value=t[s]?.(u))}}}function gn(n,e,t){let o={};if(e!==void 0)for(let r in e){let s=un(e[r](n.getAttribute(r)));t[r]=s,Object.defineProperty(o,r,{enumerable:!0,get:()=>s.value})}return Object.freeze(o)}function q(n,e,t){let o=D(F());e.name,n.$owner=o;let r=w(o);try{V(e.id);let s=t?n.attachShadow({mode:"open"}):n,i=I(()=>e.setup(n.$props));y(),L(s,null,null,i)}catch(s){y(),W(s,o)}finally{w(r)}}function yn(n,e){let t=document.createElement(n.tag);return t.$props=e,q(t,n,n.options?.shadow===!0),t}import{batch as hn,createOwner as J,disposeOwner as bn,getOwner as kn,setOwner as B,signal as G,untrack as Q}from"@firsthandjs/core";function Gn(n,e,t){let o=J(kn()),r=new Map,s,i=!1;return()=>{let u=n();if(i&&s!==void 0){s.length=0;for(let d of r.values())for(let f of d.pieces===void 0?d.nodes:Y(d))s.push(f)}let l=new Map,a=[];a[A]=!0;let m;if(Q(()=>{hn(()=>{cn()})}),r=l,s=a,m!==void 0){let d=m;a[N]=f=>{for(let p of d)_(p,f)}}return a;function cn(){for(let d=0;d<u.length;d++){let f=u[d],p=e(f,d);if(l.has(p)){`${String(p)}`;continue}let c=r.get(p);c===void 0?(c=Cn(o,f,d,t),c.pieces!==void 0&&(i=!0,_(c,null)||(m=m===void 0?[c]:[...m,c]))):(r.delete(p),c.item.value=f,c.index.value=d),l.set(p,c);let $=c.pieces===void 0?c.nodes:Y(c);for(let k=0;k<$.length;k++)a.push($[k])}T(()=>{for(let d of r.values())bn(d.owner)})}}}function U(n){return typeof n.nodeType=="number"}function _(n,e){let t=n.pieces;for(let o of t){if(U(o))continue;let r=e??S.current?.place(o.child.anchor)??null;if(r===null)return!1;H(o.child,r,s=>{o.nodes=s})}return!0}function Y(n){let e=[];for(let t of n.pieces)if(U(t))e.push(t);else for(let o of t.nodes)e.push(o);return e}function Cn(n,e,t,o){let r=J(n),s=G(e),i=G(t),u=B(r),l=[],a;try{a=X(Q(()=>o(s,i)),l)}finally{B(u)}return a?{owner:r,item:s,index:i,nodes:[],pieces:l}:{owner:r,item:s,index:i,nodes:l}}function X(n,e){if(n==null||typeof n=="boolean")return!1;if(Array.isArray(n)){let t=!1;for(let o=0;o<n.length;o++)t=X(n[o],e)||t;return t}if(typeof n=="function"){let t=g(n);return e.push({child:t,nodes:[t.anchor]}),!0}if(typeof n=="object"){if(j(n))return e.push({child:n,nodes:[n.anchor]}),!0;if(typeof n.nodeType=="number")return e.push(n),!1}return e.push(document.createTextNode(String(n))),!1}var En=new Set(["click","dblclick","contextmenu","input","beforeinput","change","keydown","keyup","keypress","pointerdown","pointerup","pointermove","mousedown","mouseup","mouseover","mouseout","submit","focusin","focusout","touchstart","touchend"]),nn=new Set;function h(n){return`$firsthand$${n}`}function Rn(n){let e=h(n.type),t=n.composedPath(),o=null;Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>o});for(let r=0;r<t.length;r++){let s=t[r],i=s[e];if(i!==void 0&&(o=s,i.call(s,n),n.cancelBubble)||s===document)break}o=null}function b(n,e,t,o){if(o!==void 0||!En.has(e)){let r=n,s=o===!0?void 0:o,i=`${h(e)}$${s===void 0?"":Object.keys(s).sort().join(",")}`,u=r[i];u!==void 0&&n.removeEventListener(e,u.handler,u.options),r[i]={handler:t,options:s},n.addEventListener(e,t,s);return}n[h(e)]=t,nn.has(e)||(nn.add(e),document.addEventListener(e,Rn))}function Yn(n,e){n[h(e)]=void 0}var Pn={class:"className",for:"htmlFor"};function x(n,e,t){t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,t===!0?"":String(t))}function Xn(n,e,t,o){o==null||o===!1?n.removeAttributeNS(e,t):n.setAttributeNS(e,t,o===!0?"":String(o))}function v(n,e,t){n[Pn[e]??e]=t}function ne(n,e,t){n[e]=!!t}function O(n,e){e==null?n.removeAttribute("class"):n.className=String(e)}function tn(n,e,t){let o=n.classList;if(t!==void 0)for(let r in t)r in e||o.remove(r);for(let r in e){let s=!!e[r];(t===void 0||!!t[r]!==s)&&o.toggle(r,s)}}function on(n,e){e==null?n.style.cssText="":n.style.cssText=String(e)}function rn(n,e,t){let o=n.style;if(t!==void 0)for(let r in t)r in e||o.removeProperty(P(r));for(let r in e){let s=e[r];(t===void 0||t[r]!==s)&&(s==null?o.removeProperty(P(r)):o.setProperty(P(r),String(s)))}}var xn=/[A-Z]/g,en=new Map;function P(n){let e=en.get(n);return e===void 0&&(e=n.startsWith("--")?n:n.replace(xn,t=>`-${t.toLowerCase()}`),en.set(n,e)),e}function vn(n,e,t){if(e==="class"||e==="className"){Array.isArray(t)?O(n,t.filter(Boolean).join(" ")):t!==null&&typeof t=="object"?tn(n,t,dn(n,"class",t)):O(n,t);return}if(e==="style"){t!==null&&typeof t=="object"?rn(n,t,dn(n,"style",t)):on(n,t);return}if(e==="ref"){t(n);return}if(e.startsWith("prop:")){v(n,e.slice(5),t);return}if(e.startsWith("attr:")){x(n,e.slice(5),t);return}if(e.startsWith("on")&&e.length>2&&/[A-Z:]/.test(e[2])){On(n,e,t);return}if(e in n&&typeof t!="string"){v(n,e,t);return}x(n,e,t)}function On(n,e,t){let o=e.slice(2).split(":"),r=o[0]==="",s=r?o[1]:o[0].toLowerCase(),i=o[r?2:1];i===void 0?b(n,s,t):i==="native"?b(n,s,t,!0):b(n,s,t,{[i]:!0})}function re(n,e){for(let t in e)t!=="children"&&vn(n,t,e[t])}function se(...n){let e={};for(let t=0;t<n.length;t++){let o=n[t];for(let r of Object.keys(o))Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>o[r]})}return e}function ie(n,e){let t={};for(let o of Object.keys(n))e.includes(o)||Object.defineProperty(t,o,{enumerable:!0,get:()=>n[o]});return Object.freeze(t)}var sn=new WeakMap;function dn(n,e,t){let o=sn.get(n);o===void 0&&(o={},sn.set(n,o));let r=o[e];return o[e]=t,r}export{$n as a,R as b,z as c,K as d,Mn as e,Dn as f,Vn as g,Fn as h,fn as i,mn as j,Gn as k,b as l,Yn as m,x as n,Xn as o,v as p,ne as q,O as r,tn as s,on as t,rn as u,vn as v,re as w,se as x,ie as y};
@@ -1 +0,0 @@
1
- function Q(n,i,e){return n}var a={current:null};function V(n){let i=n.firstChild,e=a.current;return e===null?i:e.step(i)}function Y(n){let i=n.nextSibling,e=a.current;return e===null?i:e.step(i)}import{bind as v,createOwner as B,signal as H,disposeOwner as G,getOwner as A,onCleanup as k,runWithOwner as E,setOwner as I}from"@firsthandjs/core";var S=0;function dn(n){S++;try{n()}finally{S--}}var M=3;function P(n){return typeof n.nodeType=="number"}var W=Symbol("firsthand.part"),L=Symbol("firsthand.flat"),X=Symbol("firsthand.pending"),w=new WeakSet;function sn(n){return{[W]:!0,anchor:document.createTextNode(""),thunk:n,owner:A()}}function T(n){return W in n}function un(n=""){return{slots:[],owner:A(),generation:0,name:n}}function C(n){n.busy=!0}function q(n,i){let e=n.slots[i];if(e!==void 0)return e.seen=n.generation,e;let o={seen:n.generation};return n.slots[i]=o,o}function fn(n,i){let e=B(n.owner);return i.owner=e,I(e)}function cn(n){I(n)}function an(n,i){let e=n.generation,o=n.slots;for(let t=0;t<o.length;t++){let l=o[t];l===void 0||l.seen===e||(l.owner!==void 0&&G(l.owner),o[t]=void 0)}return n.generation=e+1,i}function yn(n,i,e){let o=q(n,i),t=o.cell;if(t===void 0){let l=H(e);return o.cell=l,l}return t.peek()!==e&&(C(n),t.value=e),t}function hn(n,i,e,o,t){let l=q(n,i);if(l.node===void 0&&a.current!==null){let r=a.current.claim(e,o);if(r!==null){if(typeof t=="object"&&t!==null&&T(t)){l.last=t,a.current.keep(l,e,t.anchor,r),E(t.owner,()=>{m(e,t.thunk,t.anchor)});return}l.node=r.nodes,l.text=r.text}}let d=typeof t;if(d==="string"||d==="number"){let r=String(t);if(r===l.text)return;C(n),l.text=r,l.node=h(e,o,l.node??null,r);return}l.text=void 0,t!==l.last&&(C(n),l.last=t,l.node=h(e,o,l.node??null,t))}function m(n,i,e=null,o,t){if(typeof i!="function"){h(n,e,null,i);return}let l=null,d,r=o!==void 0?o:a.current===null?null:a.current.claim(n,e),u=r!==null;r!==null&&(l=r.nodes,d=r.text);let f=()=>{c(),t?.(z(l,e))},c=()=>{let y=i(),g=typeof y;if(g==="string"||g==="number"){let p=String(y);p!==d&&(d=p,l=h(n,e,l,p));return}if(d=void 0,g==="function"){if(u){l=null,m(n,y,e,r);return}l=x(l),m(n,y,e,null);return}l=h(n,e,l,y)};r===null?v(f):a.current.within(r.region,()=>{v(f)}),u=!1,k(()=>{l=S>0?null:x(l)})}function z(n,i){let e=n===null?[]:Array.isArray(n)?[...n]:[n];return e.push(i),e}function h(n,i,e,o){let t=typeof o;if(o==null||t==="boolean")return b(n,i,e);if(t==="string"||t==="number"){let l=String(o);return e!==null&&!Array.isArray(e)&&e.nodeType===M?(e.data=l,e):D(n,i,e,document.createTextNode(l))}if(t==="function")return h(n,i,e,o());if(Array.isArray(o)){if(L in o){let r=o;return r.length===0?b(n,i,e):(R(n,i,e===null?[]:Array.isArray(e)?e:[e],r),o[X]?.(n),r)}let l=[],d=[];if(F(o,l,d),l.length===0)return b(n,i,e);R(n,i,e===null?[]:Array.isArray(e)?e:[e],l);for(let r=0;r<d.length;r++)J(d[r],n);return l}return T(o)?h(n,i,e,[o]):P(o)?D(n,i,e,o):h(n,i,e,String(o))}function J(n,i,e){w.has(n)||(w.add(n),E(n.owner??A(),()=>{m(i,n.thunk,n.anchor,void 0,e),k(()=>{w.delete(n)})}))}function F(n,i,e){for(let o=0;o<n.length;o++){let t=n[o];if(typeof t=="object"&&t!==null&&T(t)){i.push(t.anchor),e.push(t);continue}for(;typeof t=="function";)t=t();t==null||typeof t=="boolean"||(Array.isArray(t)?F(t,i,e):typeof t=="object"&&P(t)?i.push(t):i.push(document.createTextNode(String(t))))}}function j(n){let i=n.parentNode;i!==null&&i.removeChild(n)}function b(n,i,e){return i===null&&Array.isArray(e)&&e.length>1&&n.childNodes.length===e.length?(n.textContent="",null):x(e)}function x(n){if(n!==null)if(Array.isArray(n))for(let i=0;i<n.length;i++)j(n[i]);else j(n);return null}function D(n,i,e,o){return e===o?o:e!==null&&!Array.isArray(e)?(n.replaceChild(o,e),o):(x(e),n.insertBefore(o,i),o)}function R(n,i,e,o){let t=0,l=0,d=e.length-1,r=o.length-1;for(;t<=d&&l<=r&&e[t]===o[l];)t++,l++;for(;t<=d&&l<=r&&e[d]===o[r];)d--,r--;let u=r+1<o.length?o[r+1]:i;if(t>d){for(let s=l;s<=r;s++)n.insertBefore(o[s],u);return}if(l>r){for(let s=t;s<=d;s++)n.removeChild(e[s]);return}let f=new Map;for(let s=t;s<=d;s++)f.set(e[s],s);let c=r-l+1,y=new Int32Array(c).fill(-1);for(let s=0;s<c;s++){let N=o[l+s],_=f.get(N);_!==void 0&&(y[s]=_,f.delete(N))}for(let s of f.keys())n.removeChild(s);let g=K(y),p=g.length-1,O=u;for(let s=c-1;s>=0;s--){let N=o[l+s];p>=0&&g[p]===s?p--:n.insertBefore(N,O),O=N}}function K(n){let i=n.length,e=new Int32Array(i).fill(-1),o=[];for(let d=0;d<i;d++){let r=n[d];if(r===-1)continue;let u=0,f=o.length;for(;u<f;){let c=u+f>>1;n[o[c]]<r?u=c+1:f=c}u>0&&(e[d]=o[u-1]),o[u]=d}let t=[],l=o.length>0?o[o.length-1]:-1;for(;l!==-1;)t.push(l),l=e[l];return t.reverse()}export{Q as a,a as b,V as c,Y as d,dn as e,L as f,X as g,sn as h,T as i,un as j,C as k,q as l,fn as m,cn as n,an as o,yn as p,hn as q,m as r,h as s,J as t,R as u};