marko 6.3.30 → 6.3.32

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.
Files changed (58) hide show
  1. package/cheatsheet.md +36 -18
  2. package/dist/common/helpers.d.ts +2 -0
  3. package/dist/debug/dom/catch.feat.js +38 -0
  4. package/dist/debug/dom/catch.feat.mjs +37 -0
  5. package/dist/debug/dom/controllable-input.feat.js +7 -0
  6. package/dist/debug/dom/controllable-input.feat.mjs +6 -0
  7. package/dist/debug/dom/controllable-open.feat.js +5 -0
  8. package/dist/debug/dom/controllable-open.feat.mjs +4 -0
  9. package/dist/debug/dom/controllable-select.feat.js +5 -0
  10. package/dist/debug/dom/controllable-select.feat.mjs +4 -0
  11. package/dist/debug/dom/controllable-textarea.feat.js +5 -0
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +4 -0
  13. package/dist/debug/dom/controllable.feat.js +11 -0
  14. package/dist/debug/dom/controllable.feat.mjs +10 -0
  15. package/dist/debug/dom-BJ93mcSe.mjs +2016 -0
  16. package/dist/debug/dom-CiFITSPN.js +2814 -0
  17. package/dist/debug/dom.js +156 -2245
  18. package/dist/debug/dom.mjs +6 -2089
  19. package/dist/dom/catch.feat.d.ts +1 -0
  20. package/dist/dom/catch.feat.js +25 -0
  21. package/dist/dom/catch.feat.mjs +26 -0
  22. package/dist/dom/control-flow.d.ts +3 -3
  23. package/dist/dom/controllable-input.feat.d.ts +1 -0
  24. package/dist/dom/controllable-input.feat.js +3 -0
  25. package/dist/dom/controllable-input.feat.mjs +3 -0
  26. package/dist/dom/controllable-open.feat.d.ts +1 -0
  27. package/dist/dom/controllable-open.feat.js +4 -0
  28. package/dist/dom/controllable-open.feat.mjs +4 -0
  29. package/dist/dom/controllable-select.feat.d.ts +1 -0
  30. package/dist/dom/controllable-select.feat.js +4 -0
  31. package/dist/dom/controllable-select.feat.mjs +4 -0
  32. package/dist/dom/controllable-textarea.feat.d.ts +1 -0
  33. package/dist/dom/controllable-textarea.feat.js +4 -0
  34. package/dist/dom/controllable-textarea.feat.mjs +4 -0
  35. package/dist/dom/controllable.d.ts +3 -8
  36. package/dist/dom/controllable.feat.d.ts +3 -0
  37. package/dist/dom/controllable.feat.js +3 -0
  38. package/dist/dom/controllable.feat.mjs +6 -0
  39. package/dist/dom/queue.d.ts +2 -2
  40. package/dist/dom/resume.d.ts +0 -1
  41. package/dist/dom/walker.d.ts +0 -1
  42. package/dist/dom-CI-06TZb.js +1721 -0
  43. package/dist/dom-Cj4HQ7T_.mjs +1137 -0
  44. package/dist/dom.d.ts +2 -2
  45. package/dist/dom.js +36 -1221
  46. package/dist/dom.mjs +4 -1188
  47. package/dist/translator/index.js +628 -534
  48. package/dist/translator/util/constants/structure-kind.d.ts +7 -0
  49. package/dist/translator/util/get-tag-name.d.ts +2 -1
  50. package/dist/translator/util/import-reference.d.ts +3 -0
  51. package/dist/translator/util/runtime.d.ts +2 -0
  52. package/dist/translator/util/sections.d.ts +28 -1
  53. package/dist/translator/util/{walks.d.ts → structure.d.ts} +20 -9
  54. package/dist/translator/util/writer.d.ts +0 -8
  55. package/dist/translator/visitors/placeholder.d.ts +4 -3
  56. package/dist/translator/visitors/tag/native-tag.d.ts +9 -6
  57. package/dist/translator/visitors/text.d.ts +3 -7
  58. package/package.json +3 -3
package/dist/dom.mjs CHANGED
@@ -1,57 +1,4 @@
1
- let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
- let str = "", sep = "", part;
3
- if (val) if (typeof val != "object") str += val;
4
- else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
- else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
6
- return str;
7
- }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
8
- scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(cleanupScope);
9
- }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
10
- let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
11
- for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) {
12
- let node = walker.currentNode;
13
- scope[decodeAccessor(currentScopeIndex++)] = node;
14
- } else if (value === 37 || value === 49) walker.currentNode.replaceWith(walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()), value === 49 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
15
- else if (value === 38) return currentWalkIndex;
16
- else if (value === 47 || value === 48) currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[decodeAccessor(currentScopeIndex++)] = createScope(scope.$, scope.F)), value === 48 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
17
- else if (value < 92) for (value = 25 * currentMultiplier + value - 67; value--;) walker.nextNode();
18
- else if (value < 107) for (value = 10 * currentMultiplier + value - 97; value--;) walker.nextSibling();
19
- else if (value < 117) {
20
- for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
21
- walker.nextSibling();
22
- } else storedMultiplier = currentMultiplier * 10 + value - 117;
23
- }, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[^\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
24
- nodeAccessor = decodeAccessor(nodeAccessor);
25
- let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
26
- return enableBranches(), (scope, newRenderer, getInput) => {
27
- let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
28
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.a || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) if (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value)), typeof normalizedRenderer == "string") {
29
- if (getContent) {
30
- let content = getContent(scope);
31
- setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
32
- }
33
- } else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
34
- if (normalizedRenderer) {
35
- let childScope = scope[childScopeAccessor], args = getInput?.();
36
- if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope.a.tagName]), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
37
- else {
38
- for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
39
- if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
40
- else {
41
- let inputWithContent = getContent ? {
42
- ...args,
43
- content: getContent(scope)
44
- } : args || {};
45
- normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
46
- }
47
- }
48
- }
49
- };
50
- }, _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
51
- typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
52
- }), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), rendering, runId = 2, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingRenders = [], runEffects = ((effects) => {
53
- for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
54
- }), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
1
+ let empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
55
2
  let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
56
3
  return render && !scopes && scopesByRender.set(render, scopes = {}), scopes;
57
4
  }, compat = {
@@ -116,6 +63,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
116
63
  let renderer = _content(id, template, walks, setup, inputSignal)();
117
64
  return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
118
65
  };
66
+ import { $ as _html, $t as queueEffect, A as _attr_select_value, At as _id, B as _attr_class, Bt as _assert_init, C as _attr_input_checked_default, Ct as _closure_get, D as _attr_input_value_default, Dt as _for_selector, E as _attr_input_value_attribute_default, Et as _for_closure, F as _controllable_select, Ft as _return, G as _attr_style, Gt as _on, H as _attr_class_items, Ht as insertBranchBefore, I as _controllable_textarea, It as _return_change, J as _attrs, K as _attr_style_item, Kt as $signal, Lt as _script, M as _attr_select_value_script, Mt as _let, N as _controllable_input, Nt as _let_change, O as _attr_input_value_dynamic_default, Ot as _hoist, P as _controllable_open, Pt as _or, Q as _attrs_script, Qt as queueAsyncRender, Rt as _var, S as _attr_input_checkedValue_script, St as _closure, T as _attr_input_value, Tt as _el_read, U as _attr_content, Ut as removeAndDestroyBranch, V as _attr_class_item, Vt as destroyBranch, W as _attr_nonce, Wt as syncGen, X as _attrs_partial, Y as _attrs_content, Z as _attrs_partial_content, Zt as prepareEffects, _ as _attr_details_or_dialog_open_default, _t as getRegisteredWithScope, a as _for_in, an as forTo, at as _to_text, b as _attr_input_checkedValue, bt as ready, c as _for_until, cn as _call, ct as _content, d as _show, dt as createAndSetupBranch, en as run, et as _lifecycle, f as _try, ft as createBranch, g as _attr_details_or_dialog_open, gt as _var_resume, h as renderCatch, ht as _resume, i as _dynamic_tag_content, in as forOf, it as _text_content, j as _attr_select_value_default, jt as _if_closure, k as _attr_input_value_script, kt as _hoist_resume, l as _if, ln as decodeAccessor, lt as _content_closures, m as patchDynamicTag, mt as _el, n as _await_promise, nn as runId, nt as _style_shell, o as _for_of, on as forUntil, ot as insertChildNodes, p as addAwaitCounter, pt as setupBranch, q as _attr_style_items, qt as $signalReset, r as _dynamic_tag, rn as forIn, rt as _text, s as _for_to, sn as _assert_hoist, st as toInsertNode, t as _await_content, tn as runEffects, tt as _style_rule_item, u as _resume_dynamic_tag, ut as _content_resume, v as _attr_details_or_dialog_open_script, vt as init, w as _attr_input_checked_script, wt as _const, x as _attr_input_checkedValue_default, xt as _child_setup, y as _attr_input_checked, yt as initEmbedded, z as _attr, zt as _var_change } from "./dom-Cj4HQ7T_.mjs";
119
67
  //#region src/common/attr-tag.ts
120
68
  function attrTag(attrs) {
121
69
  return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
@@ -127,1137 +75,6 @@ function* attrTagIterator() {
127
75
  yield this, yield* this[rest];
128
76
  }
129
77
  //#endregion
130
- //#region src/common/helpers.ts
131
- function _call(fn, v) {
132
- return fn(v), v;
133
- }
134
- function stringifyClassObject(name, value) {
135
- return value ? name : "";
136
- }
137
- function stringifyStyleObject(name, value) {
138
- return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
139
- }
140
- function escapeStyleAttr(str) {
141
- return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
142
- }
143
- function escapeStyleValue(str) {
144
- let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
145
- for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
146
- return result + closers;
147
- }
148
- function isEventHandler(name) {
149
- return /^on[A-Z-]/.test(name);
150
- }
151
- function getEventHandlerName(name) {
152
- return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
153
- }
154
- function isNotVoid(value) {
155
- return value != null && value !== !1;
156
- }
157
- function isPromise(value) {
158
- return value != null && typeof value.then == "function";
159
- }
160
- function normalizeDynamicRenderer(value) {
161
- if (value) {
162
- if (typeof value == "string") return value;
163
- let normalized = value.content || value.default || value;
164
- if ("a" in normalized) return normalized;
165
- }
166
- }
167
- function _assert_hoist(value) {}
168
- //#endregion
169
- //#region src/common/for.ts
170
- function forIn(obj, cb) {
171
- for (let key in obj) cb(key, obj[key]);
172
- }
173
- function forOf(list, cb) {
174
- if (list) {
175
- let i = 0;
176
- for (let item of list) cb(item, i++);
177
- }
178
- }
179
- function forTo(to, from, step, cb) {
180
- let start = from || 0, delta = step || 1;
181
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
182
- }
183
- function forUntil(until, from, step, cb) {
184
- let start = from || 0, delta = step || 1;
185
- for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
186
- }
187
- //#endregion
188
- //#region src/common/opt.ts
189
- function toArray(opt) {
190
- return opt ? Array.isArray(opt) ? opt : [opt] : [];
191
- }
192
- function forEach(opt, cb) {
193
- if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
194
- else cb(opt);
195
- }
196
- function push(opt, item) {
197
- return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
198
- }
199
- //#endregion
200
- //#region src/dom/event.ts
201
- function _on(element, type, handler) {
202
- element["$" + type] === void 0 && delegate(type, handleDelegated), element["$" + type] = handler || null;
203
- }
204
- function handleDelegated(ev) {
205
- let target = !rendering && ev.target;
206
- for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
207
- }
208
- //#endregion
209
- //#region src/dom/parse-html.ts
210
- function parseHTML(html, ns) {
211
- let parser = parsers[ns] ||= document.createElementNS(ns, "template");
212
- return parser.innerHTML = html, parser.content || parser;
213
- }
214
- //#endregion
215
- //#region src/dom/scope.ts
216
- function createScope($global, closestBranch) {
217
- let scope = {
218
- L: nextScopeId++,
219
- H: runId,
220
- F: closestBranch,
221
- $: $global
222
- };
223
- return collectingScopes?.push(scope), scope;
224
- }
225
- function syncGen(scope) {
226
- scope.H = runId;
227
- }
228
- function _assert_init(scope, accessor) {
229
- return scope[accessor];
230
- }
231
- function collectScopes(fn) {
232
- let prev = collectingScopes;
233
- collectingScopes = [];
234
- try {
235
- return fn(), collectingScopes;
236
- } finally {
237
- collectingScopes = prev;
238
- }
239
- }
240
- function skipScope() {
241
- return nextScopeId++;
242
- }
243
- function findBranchWithKey(scope, key) {
244
- let branch = scope.F;
245
- for (; branch && branch[key] == null;) branch = branch.N;
246
- return branch;
247
- }
248
- function destroyBranch(branch) {
249
- branch.N?.D?.delete(branch), destroyNestedScopes(branch);
250
- }
251
- function destroyScope(scope) {
252
- scope.H && (destroyNestedScopes(scope), cleanupScope(scope));
253
- }
254
- function cleanupScope(scope) {
255
- scope.Z?.forEach(unsubscribe, scope);
256
- for (let id in scope.A) $signalReset(scope, id);
257
- }
258
- function unsubscribe(subscribers) {
259
- subscribers.delete(this);
260
- }
261
- function removeAndDestroyBranch(branch) {
262
- destroyBranch(branch), removeChildNodes(branch.S, branch.K);
263
- }
264
- function insertBranchBefore(branch, parentNode, nextSibling) {
265
- insertChildNodes(parentNode, nextSibling, branch.S, branch.K);
266
- }
267
- function tempDetachBranch(branch) {
268
- let fragment = new DocumentFragment();
269
- fragment.namespaceURI = branch.S.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.S, branch.K);
270
- }
271
- //#endregion
272
- //#region src/dom/schedule.ts
273
- function schedule() {
274
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
275
- }
276
- function flushAndWaitFrame() {
277
- requestAnimationFrame(triggerMacroTask), run();
278
- }
279
- function triggerMacroTask() {
280
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
281
- isScheduled = 0, run();
282
- }), channel.port2.postMessage(0);
283
- }
284
- //#endregion
285
- //#region src/dom/signals.ts
286
- function _let(id, fn) {
287
- let valueAccessor = decodeAccessor(id);
288
- return (scope, value) => (rendering ? scope.H === runId && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
289
- }
290
- function _let_change(id, fn) {
291
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = decodeAccessor(id + 1), base = _let(id, fn);
292
- return (scope, value, valueChange) => (rendering ? (scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope)) ? (scope[valueAccessor] = value, fn?.(scope)) : base(scope, value) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : base(scope, value), value);
293
- }
294
- function _const(valueAccessor, fn) {
295
- return valueAccessor = decodeAccessor(valueAccessor), ((scope, value) => {
296
- (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn?.(scope));
297
- });
298
- }
299
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
300
- return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
301
- scope.H === runId ? ~id in scope ? --scope[~id] || fn(scope) : scope[~id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
302
- };
303
- }
304
- function _for_closure(ownerLoopNodeAccessor, fn) {
305
- ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
306
- let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
307
- let scopes = toArray(ownerScope[scopeAccessor]);
308
- scopes.length && queueRender(ownerScope, () => {
309
- for (let scope of scopes) scope.H > 0 && scope.H < runId && fn(scope);
310
- }, -1, 0, scopes[0].L);
311
- };
312
- return ownerSignal._ = fn, ownerSignal;
313
- }
314
- function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccessor, fn) {
315
- ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor), ownerValueAccessor = decodeAccessor(ownerValueAccessor), keyValueAccessor !== "M" && (keyValueAccessor = decodeAccessor(keyValueAccessor));
316
- let scopeAccessor = "A" + ownerLoopNodeAccessor, mapAccessor = "O" + ownerLoopNodeAccessor, prevKeyProp = `_${ownerValueAccessor}`, ownerSignal = (ownerScope) => {
317
- let scopes = toArray(ownerScope[scopeAccessor]);
318
- if (ownerScope.H < runId && scopes.length) {
319
- let nextKey = ownerScope[ownerValueAccessor];
320
- queueRender(ownerScope, () => {
321
- let map = keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor);
322
- if (map && prevKeyProp in map) {
323
- let prevScope = map.get(map[prevKeyProp]), nextScope = map.get(nextKey);
324
- prevScope !== nextScope && (runLiveBranch(prevScope, fn), runLiveBranch(nextScope, fn));
325
- } else for (let scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
326
- map && (map[prevKeyProp] = nextKey);
327
- }, -1, 0, scopes[0].L);
328
- }
329
- };
330
- return ownerSignal._ = fn, ownerSignal;
331
- }
332
- function keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor) {
333
- let map = ownerScope[mapAccessor] ||= /* @__PURE__ */ new Map();
334
- if (!map.size) for (let scope of toArray(ownerScope[scopeAccessor])) {
335
- let key = scope.M ?? scope[keyValueAccessor];
336
- if (key === void 0) return ownerScope[mapAccessor] = null;
337
- scope.M = key, map.set(key, scope);
338
- }
339
- return map;
340
- }
341
- function runLiveBranch(scope, fn) {
342
- scope && scope.H > 0 && scope.H < runId && fn(scope);
343
- }
344
- function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
345
- ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
346
- let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
347
- let ifScope = scope[scopeAccessor];
348
- ifScope && ifScope.H > 0 && ifScope.H < runId && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
349
- };
350
- return ownerSignal._ = fn, ownerSignal;
351
- }
352
- function subscribeToScopeSet(ownerScope, accessor, scope) {
353
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set(), { size } = subscribers;
354
- subscribers.add(scope).size !== size && trackCleanup(scope, subscribers);
355
- }
356
- function _closure(...closureSignals) {
357
- let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
358
- for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
359
- return (scope) => {
360
- if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
361
- };
362
- }
363
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
364
- valueAccessor = decodeAccessor(valueAccessor);
365
- let closureSignal = ((scope) => {
366
- scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
367
- });
368
- return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
369
- }
370
- function _child_setup(setup) {
371
- return setup._ = (scope, owner) => {
372
- scope._ = owner, queueRender(scope, setup, -1);
373
- }, setup;
374
- }
375
- function _var(scope, childAccessor, signal) {
376
- scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
377
- }
378
- function _return_change(scope, changeHandler) {
379
- changeHandler && (scope.U = changeHandler);
380
- }
381
- function _id({ $: $global }) {
382
- let id = tagIdsByGlobal.get($global) || 0;
383
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
384
- }
385
- function _script(id, fn) {
386
- return _resume(id, fn), (scope) => {
387
- queueEffect(scope, fn);
388
- };
389
- }
390
- function _el_read(value) {
391
- return value;
392
- }
393
- function* traverse(scope, path, i = path.length - 1) {
394
- if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, i);
395
- else {
396
- let item = scope[path[i]];
397
- i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
398
- }
399
- }
400
- function _hoist(...path) {
401
- return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
402
- let fn = () => traverse(scope, path).next().value;
403
- return fn[Symbol.iterator] = () => traverse(scope, path), fn;
404
- };
405
- }
406
- function _hoist_resume(id, ...path) {
407
- return _resume(id, _hoist(...path));
408
- }
409
- //#endregion
410
- //#region src/dom/walker.ts
411
- function walk(startNode, walkCodes, branch) {
412
- walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
413
- }
414
- //#endregion
415
- //#region src/dom/resume.ts
416
- function enableBranches() {
417
- branchesEnabled || (branchesEnabled = 1, skipDestroyedRenders());
418
- }
419
- function ready(readyId) {
420
- (readyIds ||= /* @__PURE__ */ new Set()).add(readyId);
421
- for (let renderId in curRenders) runResumeEffects(curRenders[renderId]);
422
- }
423
- function initEmbedded(readyId, runtimeId) {
424
- embedRenders || (embedRenders = /* @__PURE__ */ new Map(), new MutationObserver(() => {
425
- for (let [anchor, [renderId, scopes]] of embedRenders) if (!anchor.isConnected) {
426
- embedRenders.delete(anchor), delete curRenders[renderId];
427
- for (let id in scopes) destroyScope(scopes[id]);
428
- }
429
- }).observe(document, {
430
- childList: !0,
431
- subtree: !0
432
- })), ready(readyId), init(runtimeId);
433
- }
434
- function init(runtimeId = "M") {
435
- if (curRenders) return;
436
- let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders) => {
437
- defineRuntime({ value: curRenders = ((renderId) => {
438
- let render = curRenders[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = {}, getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { L: +id }) : initGlobal()), initGlobal = () => scopeLookup[0] ||= {
439
- runtimeId,
440
- renderId
441
- }, initScope = (scope) => (scope.H = 1, scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
442
- let scopeId = partials[0];
443
- for (let i = 1; i < partials.length; i++) {
444
- let partial = partials[i];
445
- typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
446
- }
447
- }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
448
- for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
449
- if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
450
- for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
451
- branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
452
- } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
453
- for (; i && orphanBranches[i - 1].L > branchId;) i--, setParentBranch(orphanBranches.pop(), branch);
454
- for (; j && deferredOwners[j - 1].L > branchId;) {
455
- j--;
456
- let owner = deferredOwners.pop();
457
- owner.F !== owner && (owner.F = branch);
458
- }
459
- nextToken();
460
- }
461
- if (endedBranches) {
462
- for (let ended of endedBranches) orphanBranches.push(ended);
463
- singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
464
- }
465
- visitType === "[" ? (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit)) : deferredOwners.push(visitScope);
466
- }, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
467
- let i = 0;
468
- for (; i < resumes.length; i++) {
469
- let serialized = resumes[i];
470
- if (typeof serialized == "string") for (lastTokenIndex = 0, visitText = serialized; nextToken();) /\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
471
- else if (Array.isArray(serialized)) {
472
- if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
473
- } else if (readyIds && typeof serialized == "number") break;
474
- else {
475
- let scopes = serialized(serializeContext);
476
- Array.isArray(scopes) && applyScopes(scopes);
477
- }
478
- }
479
- return resumes.splice(0, i), i;
480
- }, lastEffect, visits, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, visitBranches, embedAnchor;
481
- return serializeContext._ = registeredValues, render.m = (effects) => {
482
- if (processResumes(render.r, effects), readyIds && render.b) for (let progress = 1; progress;) {
483
- progress = 0;
484
- for (let readyId of readyIds) {
485
- let resumes = render.b[readyId];
486
- resumes && processResumes(resumes, effects) && (progress = 1);
487
- }
488
- }
489
- let retained = 0;
490
- for (visit of visits = render.v) if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken()), visitType === "*") {
491
- let prev = visit.previousSibling;
492
- visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
493
- } else branchesEnabled ? (visitBranches ||= createVisitBranches())() : render.b && (visits[retained++] = visit);
494
- return embedRenders && !embedAnchor && visit && embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]), visits.length = retained, effects;
495
- }, render.w = () => {
496
- walk(), runResumeEffects(render);
497
- }, render;
498
- }) });
499
- };
500
- if (renders) {
501
- initRuntime(renders);
502
- for (let renderId in renders) runResumeEffects(curRenders(renderId));
503
- } else defineRuntime({
504
- configurable: !0,
505
- set: initRuntime
506
- });
507
- }
508
- function runResumeEffects(render) {
509
- try {
510
- isResuming = 1, runEffects(render.m([]), 1);
511
- } finally {
512
- isResuming = 0;
513
- }
514
- }
515
- function getRegisteredWithScope(id, scope) {
516
- let val = registeredValues[id];
517
- return scope ? val(scope) : val;
518
- }
519
- function _resume(id, obj) {
520
- return registeredValues[id] = obj;
521
- }
522
- function _var_resume(id, signal) {
523
- return _resume(id, (scope) => (value) => signal(scope, value)), signal;
524
- }
525
- function _el(id, accessor) {
526
- return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
527
- }
528
- //#endregion
529
- //#region src/dom/renderer.ts
530
- function createBranch($global, renderer, parentScope, parentNode) {
531
- let branch = createScope($global);
532
- return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
533
- }
534
- function setParentBranch(branch, parentBranch) {
535
- parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
536
- }
537
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
538
- return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
539
- }
540
- function setupBranch(renderer, branch) {
541
- return renderer.c && queueRender(branch, renderer.c, -1), branch;
542
- }
543
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
544
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
545
- let clone = template ? (branch, ns) => {
546
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
547
- } : (branch) => {
548
- walk(branch.S = branch.K = new Text(), walks, branch);
549
- };
550
- return (owner) => ({
551
- a: id,
552
- b: clone,
553
- e: owner,
554
- c: setup,
555
- d: params,
556
- f: dynamicScopesAccessor
557
- });
558
- }
559
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
560
- return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
561
- }
562
- function _content_closures(renderer, closureFns) {
563
- let closureSignals = {};
564
- for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
565
- return (owner, closureValues) => {
566
- let instance = renderer(owner);
567
- return instance.g = closureSignals, instance.h = closureValues, instance;
568
- };
569
- }
570
- function createCloneableHTML(html, ns) {
571
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
572
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
573
- walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
574
- } : (branch, walks) => {
575
- let clone = parent.cloneNode(!0);
576
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
577
- };
578
- }
579
- //#endregion
580
- //#region src/dom/dom.ts
581
- function _to_text(value) {
582
- return value || value === 0 ? value + "" : "";
583
- }
584
- function _attr(element, name, value) {
585
- setAttribute(element, name, normalizeAttrValue(value));
586
- }
587
- function setAttribute(element, name, value) {
588
- element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
589
- }
590
- function _attr_class(element, value) {
591
- setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
592
- }
593
- function _attr_class_items(element, items) {
594
- for (let key in items) _attr_class_item(element, key, items[key]);
595
- }
596
- function _attr_class_item(element, name, value) {
597
- element.classList.toggle(name, !!value);
598
- }
599
- function _attr_style(element, value) {
600
- setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
601
- }
602
- function _attr_style_items(element, items) {
603
- for (let key in items) _attr_style_item(element, key, items[key]);
604
- }
605
- function _attr_style_item(element, name, value) {
606
- element.style.setProperty(name, _to_text(value));
607
- }
608
- function _style_shell(scope, nodeAccessor) {
609
- let element = scope[nodeAccessor], id = _id(scope);
610
- _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
611
- }
612
- function _style_rule_item(element, name, value) {
613
- let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
614
- ~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
615
- }
616
- function _attr_nonce(scope, nodeAccessor) {
617
- _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
618
- }
619
- function _text(node, value) {
620
- let normalizedValue = _to_text(value);
621
- node.data !== normalizedValue && (node.data = normalizedValue);
622
- }
623
- function _text_content(node, value) {
624
- let normalizedValue = _to_text(value);
625
- node.textContent !== normalizedValue && (node.textContent = normalizedValue);
626
- }
627
- function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
628
- let el = scope[nodeAccessor];
629
- for (let i = el.attributes.length; i--;) {
630
- let { name } = el.attributes.item(i);
631
- nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
632
- }
633
- attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
634
- }
635
- function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
636
- _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
637
- }
638
- function hasAttrAlias(element, attr, nextAttrs) {
639
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
640
- }
641
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
642
- let el = scope[nodeAccessor], partial = {};
643
- for (let i = el.attributes.length; i--;) {
644
- let { name } = el.attributes.item(i);
645
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
646
- }
647
- for (let name in nextAttrs) {
648
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
649
- skip[key] || (partial[key] = nextAttrs[name]);
650
- }
651
- attrsInternal(scope, nodeAccessor, partial, controllable);
652
- }
653
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
654
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
655
- }
656
- function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
657
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
658
- for (let name in events) events[name] = 0;
659
- controllable && (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, nextAttrs && (skip = controllable(scope, nodeAccessor, nextAttrs)));
660
- for (let name in nextAttrs) {
661
- let value = nextAttrs[name];
662
- switch (name) {
663
- case "class":
664
- _attr_class(el, value);
665
- break;
666
- case "style":
667
- _attr_style(el, value);
668
- break;
669
- default:
670
- isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
671
- break;
672
- }
673
- }
674
- }
675
- function _attr_content(scope, nodeAccessor, value) {
676
- let content = normalizeClientRender(value);
677
- scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
678
- for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
679
- }
680
- function _attrs_script(scope, nodeAccessor) {
681
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
682
- controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
683
- for (let name in events) _on(el, name, events[name]);
684
- }
685
- function _html(scope, value, accessor) {
686
- let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
687
- insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
688
- }
689
- function normalizeClientRender(value) {
690
- let renderer = normalizeDynamicRenderer(value);
691
- if (renderer && renderer.a) return renderer;
692
- }
693
- function normalizeAttrValue(value) {
694
- if (isNotVoid(value)) return value === !0 ? "" : value + "";
695
- }
696
- function _lifecycle(scope, thisObj, index = 0) {
697
- let accessor = "K" + index, instance = scope[accessor];
698
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
699
- }
700
- function removeChildNodes(startNode, endNode) {
701
- let stop = endNode.nextSibling;
702
- for (; startNode !== stop;) {
703
- let next = startNode.nextSibling;
704
- startNode.remove(), startNode = next;
705
- }
706
- }
707
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
708
- if (parentNode.isConnected) parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
709
- else {
710
- let stop = endNode.nextSibling;
711
- for (; startNode !== stop;) {
712
- let next = startNode.nextSibling;
713
- parentNode.insertBefore(startNode, referenceNode), startNode = next;
714
- }
715
- }
716
- return parentNode;
717
- }
718
- function toInsertNode(startNode, endNode) {
719
- return startNode === endNode ? startNode : insertChildNodes(new DocumentFragment(), null, startNode, endNode);
720
- }
721
- //#endregion
722
- //#region src/dom/resolve-cursor-position.ts
723
- function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
724
- if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
725
- let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
726
- if (updatedValue.startsWith(before)) return initialPosition;
727
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
728
- let count = before.replace(R, "").length, pos = 0;
729
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
730
- return pos;
731
- }
732
- return -1;
733
- }
734
- //#endregion
735
- //#region src/dom/controllable.ts
736
- function _attr_input_checked_default(scope, nodeAccessor, checked) {
737
- let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
738
- if (el.defaultChecked !== normalizedChecked) {
739
- let restoreValue = scope.H < runId ? el.checked : normalizedChecked;
740
- el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
741
- }
742
- }
743
- /** Filled by the latches a compiled page emits, so a page carries only the
744
- * control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
745
- /** The render pass equivalent, for a tag whose name is only known at run time;
746
- * a statically named tag passes its claim to `_attrs` instead. */
747
- function _enable_controllable_input() {
748
- controllableScripts[0] = _attr_input_checked_script, controllableScripts[1] = _attr_input_checkedValue_script, controllableScripts[2] = _attr_input_value_script;
749
- }
750
- function _enable_controllable_textarea() {
751
- controllableScripts[2] = _attr_input_value_script;
752
- }
753
- function _enable_controllable_select() {
754
- controllableScripts[3] = _attr_select_value_script;
755
- }
756
- function _enable_controllable_open() {
757
- controllableScripts[4] = _attr_details_or_dialog_open_script;
758
- }
759
- /** A run-time tag name can be any controllable, so its page enables them all. */
760
- function _enable_controllable() {
761
- _enable_controllable_input(), _enable_controllable_select(), _enable_controllable_open(), controllableRenders.INPUT = _controllable_input, controllableRenders.TEXTAREA = _controllable_textarea, controllableRenders.SELECT = _controllable_select, controllableRenders.DETAILS = controllableRenders.DIALOG = _controllable_open;
762
- }
763
- function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
764
- let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
765
- scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && scope.H < runId ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
766
- }
767
- function _attr_input_checked_script(scope, nodeAccessor) {
768
- let el = scope[nodeAccessor];
769
- syncControllableFormInput(el, hasCheckboxChanged, () => {
770
- let checkedChange = scope["E" + nodeAccessor];
771
- if (checkedChange) {
772
- let newValue = el.checked;
773
- el.checked = !newValue, checkedChange(newValue), run();
774
- }
775
- });
776
- }
777
- function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
778
- let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
779
- _attr(scope[nodeAccessor], "value", value), _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
780
- }
781
- function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
782
- let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
783
- scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange && scope.H < runId ? (el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue, _attr(el, "value", value)) : _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
784
- }
785
- function _attr_input_checkedValue_script(scope, nodeAccessor) {
786
- let el = scope[nodeAccessor];
787
- isResuming && el.defaultChecked && (scope["G" + nodeAccessor] ? scope["G" + nodeAccessor].push(el.value) : scope["G" + nodeAccessor] = el.value), syncControllableFormInput(el, hasCheckboxChanged, () => {
788
- let checkedValueChange = scope["E" + nodeAccessor];
789
- if (checkedValueChange) {
790
- let controlledValueKey = "G" + nodeAccessor, oldValue = scope[controlledValueKey], newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
791
- if (el.name && el.type[0] === "r") for (let radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) radio.form === el.form && (newValue === void 0 && radio.defaultChecked && (newValue = radio.value), radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : controlledValueKey in scope ? oldValue === radio.value : radio.defaultChecked);
792
- else el.checked = !el.checked;
793
- checkedValueChange(newValue), run();
794
- }
795
- });
796
- }
797
- function _attr_input_value_default(scope, nodeAccessor, value) {
798
- let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
799
- if (el.defaultValue !== normalizedValue) {
800
- let restoreValue = scope.H < runId ? el.value : normalizedValue;
801
- el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
802
- }
803
- }
804
- function _attr_input_value_dynamic_default(scope, nodeAccessor, value) {
805
- let el = scope[nodeAccessor];
806
- /i[ot]|e[cns]|^[bi]/.test(el.type) ? _attr(el, "value", value) : _attr_input_value_default(scope, nodeAccessor, value);
807
- }
808
- function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault = _attr_input_value_default) {
809
- let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
810
- scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && scope.H < runId ? setInputValue(el, normalizedValue) : setDefault(scope, nodeAccessor, normalizedValue);
811
- }
812
- function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
813
- _attr(scope[nodeAccessor], "value", value);
814
- }
815
- function _attr_input_value_script(scope, nodeAccessor) {
816
- let el = scope[nodeAccessor];
817
- isResuming && (scope["G" + nodeAccessor] = el.defaultValue), syncControllableFormInput(el, hasValueChanged, (ev) => {
818
- let valueChange = scope["E" + nodeAccessor];
819
- valueChange && (inputType = ev?.inputType, valueChange(el.value), run(), setInputValue(el, scope["G" + nodeAccessor]), inputType = "");
820
- });
821
- }
822
- function setInputValue(el, value) {
823
- if (el.value !== value) {
824
- let updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
825
- ~updatedPosition && el.setSelectionRange(updatedPosition, updatedPosition);
826
- }
827
- }
828
- function _attr_select_value_default(scope, nodeAccessor, value) {
829
- let restoreValue, el = scope[nodeAccessor], live = scope.H < runId, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
830
- pendingEffects.unshift(() => {
831
- for (let opt of el.options) {
832
- let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
833
- opt.defaultSelected !== selected && (live && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
834
- }
835
- restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
836
- }, scope);
837
- }
838
- function _attr_select_value(scope, nodeAccessor, value, valueChange) {
839
- let el = scope[nodeAccessor], existing = scope.H < runId, multiple = Array.isArray(value), normalizedValue = scope["G" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
840
- scope["E" + nodeAccessor] = valueChange, scope["F" + nodeAccessor] = valueChange ? 3 : 5, valueChange && existing ? pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
841
- }
842
- function _attr_select_value_script(scope, nodeAccessor) {
843
- let el = scope[nodeAccessor], onChange = () => {
844
- let valueChange = scope["E" + nodeAccessor];
845
- if (valueChange) {
846
- let oldValue = scope["G" + nodeAccessor], multiple = Array.isArray(oldValue), newValue = getSelectValue(el, multiple);
847
- setSelectValue(el, oldValue, multiple), valueChange(newValue), run();
848
- }
849
- };
850
- if (isResuming) if (el.multiple) {
851
- scope["G" + nodeAccessor] = [];
852
- for (let opt of el.options) opt.defaultSelected && scope["G" + nodeAccessor].push(opt.value);
853
- } else {
854
- scope["G" + nodeAccessor] = "";
855
- for (let opt of el.options) if (opt.defaultSelected) {
856
- scope["G" + nodeAccessor] = opt.value;
857
- break;
858
- }
859
- }
860
- syncControllableFormInput(el, hasSelectChanged, onChange), observeOnce(scope, nodeAccessor, {
861
- childList: !0,
862
- subtree: !0
863
- }, () => {
864
- let value = scope["G" + nodeAccessor];
865
- (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) && onChange();
866
- });
867
- }
868
- function setSelectValue(el, value, multiple) {
869
- if (multiple) for (let opt of el.options) opt.selected = value.includes(opt.value);
870
- else el.value = value;
871
- }
872
- function getSelectValue(el, multiple) {
873
- return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
874
- }
875
- function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
876
- scope.H === runId && (scope[nodeAccessor].open = isNotVoid(open));
877
- }
878
- function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
879
- let normalizedOpen = scope["G" + nodeAccessor] = isNotVoid(open);
880
- scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange && scope.H < runId ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
881
- }
882
- function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
883
- let el = scope[nodeAccessor];
884
- observeOnce(scope, nodeAccessor, {
885
- attributes: !0,
886
- attributeFilter: ["open"]
887
- }, () => {
888
- let openChange = scope["E" + nodeAccessor];
889
- if (openChange && el.open === !scope["G" + nodeAccessor]) {
890
- let newValue = el.open;
891
- el.open = !newValue, openChange(newValue), run();
892
- }
893
- });
894
- }
895
- function observeOnce(scope, nodeAccessor, init, callback) {
896
- (scope["N" + nodeAccessor] ||= new MutationObserver(callback)).observe(scope[nodeAccessor], init);
897
- }
898
- function syncControllableFormInput(el, hasChanged, onChange) {
899
- el._ = onChange, delegate("input", handleChange), el.form && delegate("reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange);
900
- }
901
- function handleChange(ev) {
902
- ev.target._?.(ev);
903
- }
904
- function handleFormReset(ev) {
905
- let handlers = [];
906
- for (let el of ev.target.elements) el._ && hasFormElementChanged(el) && handlers.push(el._);
907
- requestAnimationFrame(() => {
908
- if (!ev.defaultPrevented) for (let change of handlers) change();
909
- });
910
- }
911
- function hasValueChanged(el) {
912
- return el.value !== el.defaultValue;
913
- }
914
- function hasCheckboxChanged(el) {
915
- return el.checked !== el.defaultChecked;
916
- }
917
- function hasSelectChanged(el) {
918
- for (let opt of el.options) if (opt.selected !== opt.defaultSelected) return !0;
919
- }
920
- function hasFormElementChanged(el) {
921
- return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
922
- }
923
- function normalizeStrProp(value) {
924
- return normalizeAttrValue(value) || "";
925
- }
926
- function updateList(arr, val, push) {
927
- let index = arr.indexOf(val);
928
- return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
929
- }
930
- function _controllable_input(scope, nodeAccessor, nextAttrs) {
931
- return "checked" in nextAttrs || "checkedChange" in nextAttrs ? (_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange), /^checked(?:Value)?(?:Change)?$/) : "checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs ? (_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value), /^(?:value|checked(?:Value)?)(?:Change)?$/) : _controllable_textarea(scope, nodeAccessor, nextAttrs, _attr_input_value_dynamic_default);
932
- }
933
- function _controllable_textarea(scope, nodeAccessor, nextAttrs, dynamicDefault) {
934
- if ("value" in nextAttrs || "valueChange" in nextAttrs) return _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, dynamicDefault), /^value(?:Change)?$/;
935
- }
936
- function _controllable_select(scope, nodeAccessor, nextAttrs) {
937
- if ("value" in nextAttrs || "valueChange" in nextAttrs) return _attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), /^value(?:Change)?$/;
938
- }
939
- function _controllable_open(scope, nodeAccessor, nextAttrs) {
940
- if ("open" in nextAttrs || "openChange" in nextAttrs) return _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), /^open(?:Change)?$/;
941
- }
942
- //#endregion
943
- //#region src/dom/control-flow.ts
944
- function _await_promise(nodeAccessor, params) {
945
- nodeAccessor = decodeAccessor(nodeAccessor);
946
- let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
947
- _enable_catch();
948
- let resolveAwait = (scope, referenceNode, value) => {
949
- let awaitBranch = scope[branchAccessor];
950
- return awaitBranch.V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [value]), awaitBranch;
951
- }, awaitPromise = (scope, promise) => {
952
- !isPromise(promise) && scope[promiseAccessor] && (promise = Promise.resolve(promise));
953
- let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch;
954
- if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
955
- scope[promiseAccessor] = () => awaitPromise(scope, promise);
956
- return;
957
- }
958
- if (!isPromise(promise)) {
959
- resolveAwait(scope, scope[nodeAccessor], promise);
960
- return;
961
- }
962
- let awaitCounter = tryBranch.O;
963
- placeholderShown.add(pendingEffects), !tryPlaceholder && !awaitCounter?.i && (awaitCounter = createAwaitCounter(tryBranch, () => {
964
- if (tryBranch === scope[branchAccessor]) {
965
- let anchor = scope[nodeAccessor];
966
- if (anchor.parentNode) {
967
- let detachedParent = scope[branchAccessor].S.parentNode;
968
- detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
969
- }
970
- } else dismissPlaceholder(tryBranch);
971
- })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
972
- awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
973
- }, -1)))));
974
- let thisPromise = scope[promiseAccessor] = promise.then((data) => {
975
- if (thisPromise === scope[promiseAccessor]) {
976
- let referenceNode = scope[nodeAccessor];
977
- if (scope[promiseAccessor] = 0, scope.F?.H === 0) {
978
- awaitCounter.c(), run();
979
- return;
980
- }
981
- queueAsyncRender(scope, () => {
982
- awaitBranch = resolveAwait(scope, referenceNode, data);
983
- let pendingRenders = awaitBranch.W;
984
- if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
985
- let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
986
- for (let i = 0; i < pendingEffects.length;) {
987
- let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
988
- scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
989
- }
990
- for (let i = 0; i < effects.length;) {
991
- let fn = effects[i++], scope = effects[i++];
992
- fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
993
- }
994
- }
995
- });
996
- }
997
- }, (error) => {
998
- thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, tryPlaceholder && !awaitCounter.m ? awaitCounter.c() : awaitCounter.i = 0, queueAsyncRender(scope, renderCatch, error));
999
- });
1000
- };
1001
- return awaitPromise;
1002
- }
1003
- function _await_content(nodeAccessor, template, walks, setup) {
1004
- nodeAccessor = decodeAccessor(nodeAccessor);
1005
- let branchAccessor = "A" + nodeAccessor, promiseAccessor = "L" + nodeAccessor, renderer = _content("", template, walks, setup)();
1006
- return (scope) => {
1007
- let pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer);
1008
- scope[branchAccessor].Y = pendingScopes;
1009
- let resolveSync = scope[promiseAccessor];
1010
- typeof resolveSync == "function" && (scope[promiseAccessor] = 0, resolveSync());
1011
- };
1012
- }
1013
- function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1014
- if (!tryBranch) return;
1015
- let awaitCounter = tryBranch.O;
1016
- return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1017
- insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1018
- }, -1)))), awaitCounter;
1019
- }
1020
- function createAwaitCounter(tryBranch, done) {
1021
- let awaitCounter = tryBranch.O = {
1022
- i: 0,
1023
- c() {
1024
- if (--awaitCounter.i) return 1;
1025
- done(), queueEffect(tryBranch, runPendingEffects);
1026
- }
1027
- };
1028
- return awaitCounter;
1029
- }
1030
- function runPendingEffects(scope) {
1031
- let effects = scope.J;
1032
- effects && (scope.J = [], runEffects(effects, 1));
1033
- }
1034
- function dismissPlaceholder(tryBranch) {
1035
- let placeholderBranch = tryBranch.P;
1036
- placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
1037
- }
1038
- function _try(nodeAccessor, template, walks, setup) {
1039
- nodeAccessor = decodeAccessor(nodeAccessor);
1040
- let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
1041
- return (scope, input) => {
1042
- scope[branchAccessor] || setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1043
- let branch = scope[branchAccessor];
1044
- branch && (branch.C = nodeAccessor, branch.E = input.catch && (normalizeDynamicRenderer(input.catch) || 0), branch.Q = normalizeDynamicRenderer(input.placeholder));
1045
- };
1046
- }
1047
- function renderCatch(scope, error) {
1048
- let tryWithCatch = findBranchWithKey(scope, "E");
1049
- if (tryWithCatch) {
1050
- let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
1051
- placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(owner, tryWithCatch.C, tryWithCatch.E, createAndSetupBranch), tryWithCatch.E?.d?.(owner["A" + tryWithCatch.C], [error]);
1052
- } else throw error;
1053
- }
1054
- function _if(nodeAccessor, ...branchesArgs) {
1055
- nodeAccessor = decodeAccessor(nodeAccessor);
1056
- let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
1057
- for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
1058
- return enableBranches(), (scope, newBranch) => {
1059
- newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
1060
- };
1061
- }
1062
- function _show(nodeAccessor, startNodeAccessor, endNodeAccessor) {
1063
- nodeAccessor = decodeAccessor(nodeAccessor), startNodeAccessor !== void 0 && (startNodeAccessor = decodeAccessor(startNodeAccessor)), endNodeAccessor !== void 0 && (endNodeAccessor = decodeAccessor(endNodeAccessor));
1064
- let rangeAccessor = "A" + nodeAccessor;
1065
- return enableBranches(), (scope, display) => {
1066
- let referenceNode = scope[nodeAccessor], onlyChild = referenceNode.nodeType === 1, parentNode = onlyChild ? referenceNode : referenceNode.parentNode, range = scope[rangeAccessor];
1067
- range || (range = scope[rangeAccessor] = {}, range.S = onlyChild ? parentNode.firstChild : scope[startNodeAccessor], range.K = onlyChild ? parentNode.lastChild : endNodeAccessor === void 0 ? referenceNode.previousSibling : scope[endNodeAccessor]);
1068
- let startNode = range.S;
1069
- if (range.L && startNode === range.K && startNode.tagName === "T") {
1070
- let wrapper = startNode;
1071
- wrapper.firstChild || wrapper.appendChild(new Text()), range = scope[rangeAccessor] = {}, range.S = startNode = wrapper.firstChild, range.K = wrapper.lastChild, wrapper.replaceWith(...wrapper.childNodes);
1072
- }
1073
- let inDom = onlyChild ? !!parentNode.firstChild : startNode.parentNode === parentNode;
1074
- display ? inDom || insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode) : inDom && (onlyChild && (range.S = parentNode.firstChild, range.K = parentNode.lastChild), tempDetachBranch(range));
1075
- };
1076
- }
1077
- function patchDynamicTag(fn) {
1078
- _dynamic_tag = fn(_dynamic_tag);
1079
- }
1080
- function _dynamic_tag_content(nodeAccessor) {
1081
- nodeAccessor = decodeAccessor(nodeAccessor);
1082
- let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
1083
- return enableBranches(), (scope, renderer) => {
1084
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.a || renderer) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer) for (let accessor in renderer.g) renderer.g[accessor](scope[childScopeAccessor], renderer.h[accessor]);
1085
- };
1086
- }
1087
- function _resume_dynamic_tag() {
1088
- _resume("d", dynamicTagScript);
1089
- }
1090
- function dynamicTagScript(branch) {
1091
- _attrs_script(branch, "a");
1092
- }
1093
- function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
1094
- let referenceNode = scope[nodeAccessor], prevBranch = scope["A" + nodeAccessor], parentNode = referenceNode.nodeType > 1 ? (prevBranch?.S || referenceNode).parentNode : referenceNode, newBranch = scope["A" + nodeAccessor] = newRenderer && createBranch(scope.$, newRenderer, scope, parentNode);
1095
- referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.S) : parentNode.insertBefore(referenceNode, prevBranch.S), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
1096
- }
1097
- /* @__NO_SIDE_EFFECTS__ */
1098
- function loop(forEach) {
1099
- return (nodeAccessor, template, walks, setup, params) => {
1100
- nodeAccessor = decodeAccessor(nodeAccessor);
1101
- let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
1102
- return enableBranches(), (scope, value) => {
1103
- let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [];
1104
- scope[keyedScopesAccessor] = null;
1105
- let oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves, start = 0;
1106
- forEach(value, (key, args) => {
1107
- let i = newScopes.length, oldScope = oldScopes[i], branch = oldLen && (oldScopesByKey || key !== (oldScope?.M ?? i) ? (oldScopesByKey ||= oldScopes.reduce((map, scope, j) => j < i ? map : (scope.I = j, map.set(scope.M ?? j, scope)), /* @__PURE__ */ new Map())).get(key) : oldScope && (start++, oldScope));
1108
- branch ? (hasPotentialMoves = !0, oldScopesByKey?.delete(key)) : branch = createAndSetupBranch(scope.$, renderer, scope, parentNode), branch.M = key, newScopes.push(branch), params?.(branch, args);
1109
- });
1110
- let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1;
1111
- if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
1112
- oldLen && (oldScopes.forEach(hasSiblings ? removeAndDestroyBranch : destroyBranch), hasSiblings || (parentNode.textContent = ""));
1113
- for (let newScope of newScopes) insertBranchBefore(newScope, parentNode, afterReference);
1114
- return;
1115
- }
1116
- if (oldScopesByKey) oldScopesByKey.forEach(removeAndDestroyBranch);
1117
- else for (let i = newLen; i < oldLen; i++) removeAndDestroyBranch(oldScopes[i]);
1118
- for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd];) oldEnd--, newEnd--;
1119
- if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd || start > newEnd) {
1120
- for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
1121
- return;
1122
- }
1123
- let diffLen = newEnd - start + 1, sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
1124
- for (let i = diffLen; i--;) sources[i] = newScopes[start + i].I ?? -1;
1125
- for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
1126
- else {
1127
- for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
1128
- sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
1129
- }
1130
- for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
1131
- for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
1132
- };
1133
- };
1134
- }
1135
- function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1136
- let branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
1137
- return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer) : setupBranch(tagNameOrRenderer, branch), branch;
1138
- }
1139
- function bySecondArg(_item, index) {
1140
- return index;
1141
- }
1142
- function byFirstArg(name) {
1143
- return name;
1144
- }
1145
- //#endregion
1146
- //#region src/dom/queue.ts
1147
- function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
1148
- let render;
1149
- if (signalKey >= 0 && (render = scope[signalKey])) {
1150
- if (render.d = value, render.e === runId || catchEnabled && render.f) return;
1151
- render.e = runId;
1152
- } else render = {
1153
- a: scopeKey * 1e6 + signalKey,
1154
- b: scope,
1155
- c: signal,
1156
- d: value,
1157
- e: runId
1158
- }, signalKey >= 0 && (scope[signalKey] = render);
1159
- queuePendingRender(render);
1160
- }
1161
- function queuePendingRender(render) {
1162
- let i = pendingRenders.push(render) - 1;
1163
- for (; i;) {
1164
- let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1165
- if (render.a - parent.a >= 0) break;
1166
- pendingRenders[i] = parent, i = parentIndex;
1167
- }
1168
- pendingRenders[i] = render;
1169
- }
1170
- function queueEffect(scope, fn) {
1171
- pendingEffects.push(fn, scope);
1172
- }
1173
- function run() {
1174
- let effects = pendingEffects;
1175
- try {
1176
- rendering = 1, runRenders();
1177
- } finally {
1178
- runId++, rendering = 0, pendingRenders = [], pendingEffects = [];
1179
- }
1180
- runEffects(effects);
1181
- }
1182
- function queueAsyncRender(scope, signal, value) {
1183
- queueRender(scope, signal, -1, value), queueMicrotask(run);
1184
- }
1185
- function prepareEffects(fn) {
1186
- let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1187
- pendingRenders = [];
1188
- try {
1189
- rendering = 1, fn(), runRenders();
1190
- } finally {
1191
- runId++, rendering = 0, pendingRenders = prevRenders, pendingEffects = prevEffects;
1192
- }
1193
- return preparedEffects;
1194
- }
1195
- function runRenders() {
1196
- for (; pendingRenders.length;) {
1197
- let render = pendingRenders[0], item = pendingRenders.pop();
1198
- if (render !== item) {
1199
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
1200
- for (; i < mid;) {
1201
- let bestChild = (i << 1) + 1, right = bestChild + 1;
1202
- if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0) break;
1203
- pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1204
- }
1205
- pendingRenders[i] = item;
1206
- }
1207
- runRender(render);
1208
- }
1209
- }
1210
- function skipDestroyedRenders() {
1211
- runRender = ((runRender) => (render) => {
1212
- render.b.F?.H !== 0 && runRender(render);
1213
- })(runRender);
1214
- }
1215
- function _enable_catch() {
1216
- if (!catchEnabled) {
1217
- catchEnabled = 1, enableBranches();
1218
- let handlePendingTry = (fn, scope, branch) => {
1219
- for (; branch;) {
1220
- if (branch.O?.i) return (branch.J ||= []).push(fn, scope);
1221
- branch = branch.N;
1222
- }
1223
- };
1224
- runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
1225
- if (checkPending || caughtError.has(effects)) {
1226
- let i = 0, fn, scope, branch;
1227
- for (; i < effects.length;) fn = effects[i++], scope = effects[i++], (branch = scope.F)?.H !== 0 && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
1228
- } else runEffects(effects);
1229
- })(runEffects), runRender = ((runRender) => (render) => {
1230
- try {
1231
- let branch = render.b.F;
1232
- for (; branch;) {
1233
- if (branch.W) return render.f = 1, branch.W.push(render);
1234
- branch = branch.N;
1235
- }
1236
- render.f = 0, runRender(render);
1237
- } catch (error) {
1238
- renderCatch(render.b, error);
1239
- }
1240
- })(runRender);
1241
- }
1242
- }
1243
- //#endregion
1244
- //#region src/dom/abort-signal.ts
1245
- function $signalReset(scope, id) {
1246
- let ctrl = scope.A?.[id];
1247
- ctrl && (scope.A[id] = void 0, rendering ? queueEffect(ctrl, abort) : abort(ctrl));
1248
- }
1249
- function $signal(scope, id) {
1250
- return trackCleanup(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
1251
- }
1252
- /** Enrols `scope` with its branch so destroying the branch cleans it up. */
1253
- function trackCleanup(scope, subscribers) {
1254
- let branch = scope.F;
1255
- branch && (branch.B ||= /* @__PURE__ */ new Set()).add(scope), subscribers && (scope.Z ||= []).push(subscribers);
1256
- }
1257
- function abort(ctrl) {
1258
- ctrl.abort();
1259
- }
1260
- //#endregion
1261
78
  //#region src/common/compat-meta.ts
1262
79
  //#endregion
1263
80
  //#region src/dom/compat.ts
@@ -1308,7 +125,6 @@ function mount(input = {}, reference, position) {
1308
125
  //#endregion
1309
126
  //#region src/dom/load.ts
1310
127
  function _load_template(id, load) {
1311
- _enable_catch();
1312
128
  let pending, lazyTemplate = _template(id, 0, 0, (branch) => {
1313
129
  let awaitCounter = addAwaitCounter(branch);
1314
130
  branch.X ||= /* @__PURE__ */ new Map(), (pending ||= load()).then((renderer) => {
@@ -1320,7 +136,7 @@ function _load_template(id, load) {
1320
136
  function _load_setup(nodeAccessor, childScopeAccessor, load) {
1321
137
  nodeAccessor = decodeAccessor(nodeAccessor), childScopeAccessor = decodeAccessor(childScopeAccessor);
1322
138
  let pending, renderer;
1323
- return _enable_catch(), (owner) => {
139
+ return (owner) => {
1324
140
  let child = owner[childScopeAccessor];
1325
141
  if (renderer) insertLoaded(renderer, child, owner[nodeAccessor]);
1326
142
  else {
@@ -1379,4 +195,4 @@ function getSelectorOrResolve(selector, resolve) {
1379
195
  return document.querySelector(selector) || resolve();
1380
196
  }
1381
197
  //#endregion
1382
- export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _enable_controllable, _enable_controllable_input, _enable_controllable_open, _enable_controllable_select, _enable_controllable_textarea, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
198
+ export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };