marko 6.3.31 → 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 (57) 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 -2250
  18. package/dist/debug/dom.mjs +6 -2094
  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-CI-06TZb.js +1721 -0
  42. package/dist/dom-Cj4HQ7T_.mjs +1137 -0
  43. package/dist/dom.d.ts +2 -2
  44. package/dist/dom.js +36 -1224
  45. package/dist/dom.mjs +4 -1191
  46. package/dist/translator/index.js +628 -534
  47. package/dist/translator/util/constants/structure-kind.d.ts +7 -0
  48. package/dist/translator/util/get-tag-name.d.ts +2 -1
  49. package/dist/translator/util/import-reference.d.ts +3 -0
  50. package/dist/translator/util/runtime.d.ts +2 -0
  51. package/dist/translator/util/sections.d.ts +28 -1
  52. package/dist/translator/util/{walks.d.ts → structure.d.ts} +20 -9
  53. package/dist/translator/util/writer.d.ts +0 -8
  54. package/dist/translator/visitors/placeholder.d.ts +4 -3
  55. package/dist/translator/visitors/tag/native-tag.d.ts +9 -6
  56. package/dist/translator/visitors/text.d.ts +3 -7
  57. package/package.json +3 -3
package/dist/debug/dom.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const require_control_flow = require("./dom-CiFITSPN.js");
3
4
  //#region src/common/attr-tag.ts
4
5
  const empty = [];
5
6
  const rest = Symbol("Attribute Tag");
@@ -21,2096 +22,9 @@ function* attrTagIterator() {
21
22
  yield* this[rest];
22
23
  }
23
24
  //#endregion
24
- //#region src/common/constants/accessor-prefix.debug.ts
25
- const BranchScopes$1 = "BranchScopes:";
26
- const ClosureScopes = "ClosureScopes:";
27
- const ClosureSignalIndex = "ClosureSignalIndex:";
28
- const ConditionalRenderer = "ConditionalRenderer:";
29
- const ControlledObserver = "ControlledObserver:";
30
- const ControlledHandler = "ControlledHandler:";
31
- const ControlledType = "ControlledType:";
32
- const ControlledValue = "ControlledValue:";
33
- const DynamicHTMLLastChild = "DynamicHTMLLastChild:";
34
- const EventAttributes = "EventAttributes:";
35
- const KeyedScopes = "KeyedScopes:";
36
- const Lifecycle = "Lifecycle:";
37
- const Promise$1 = "Promise:";
38
- const TagVariableChange$1 = "TagVariableChange:";
39
- //#endregion
40
- //#region src/common/constants/accessor-prop.debug.ts
41
- const Global = "$global";
42
- const AbortControllers = "#AbortControllers";
43
- const AbortScopes = "#AbortScopes";
44
- const AwaitCounter = "#AwaitCounter";
45
- const BranchAccessor = "#BranchAccessor";
46
- const BranchScopes = "#BranchScopes";
47
- const CatchContent = "#CatchContent";
48
- const ClosestBranch = "#ClosestBranch";
49
- const ClosestBranchId = "#ClosestBranchId";
50
- const Gen$1 = "#Gen";
51
- const DetachedAwait = "#DetachedAwait";
52
- const EndNode = "#EndNode";
53
- const Load = "#Load";
54
- const LoopKey = "#LoopKey";
55
- const ParentBranch = "#ParentBranch";
56
- const PendingEffects = "#PendingEffects";
57
- const PendingRenders = "#PendingRenders";
58
- const PendingScopes = "#PendingScopes";
59
- const PlaceholderBranch = "#PlaceholderBranch";
60
- const PlaceholderContent = "#PlaceholderContent";
61
- const Renderer = "#Renderer";
62
- const StartNode = "#StartNode";
63
- const Subscriptions = "#Subscriptions";
64
- const TagVariable = "#TagVariable";
65
- const TagVariableChange = "#TagVariableChange";
66
- //#endregion
67
- //#region src/common/constants/closure-signal-prop.debug.ts
68
- const ScopeInstancesAccessor = "scopeInstancesAccessor";
69
- const SignalIndexAccessor = "signalIndexAccessor";
70
- const Index = "index";
71
- //#endregion
72
- //#region src/common/constants/keyed-scopes-prop.debug.ts
73
- const PreviousKey = "PreviousKey:";
74
- //#endregion
75
25
  //#region src/common/constants/load-signal-value.debug.ts
76
- const Value$1 = "value";
77
- const Signal$1 = "signal";
78
- const Scope = "scope";
79
- const Signal = "signal";
80
26
  const Value = "value";
81
- const Pending = "pending";
82
- const Clone = "clone";
83
- const Setup = "setup";
84
- const Params = "params";
85
- const Owner = "owner";
86
- const Accessor = "accessor";
87
- const LocalClosures = "localClosures";
88
- const LocalClosureValues = "localClosureValues";
89
- //#endregion
90
- //#region src/common/helpers.ts
91
- const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
92
- const knownWrongAttrs = {
93
- className: "class",
94
- classList: "class",
95
- htmlFor: "for",
96
- acceptCharset: "accept-charset",
97
- httpEquiv: "http-equiv",
98
- defaultValue: "value",
99
- defaultChecked: "checked",
100
- dangerouslySetInnerHTML: "$!{html}",
101
- key: "<for by>",
102
- ref: "<tag/ref>",
103
- "v-if": "<if>",
104
- "v-else": "<else>",
105
- "v-else-if": "<else if>",
106
- "v-for": "<for>",
107
- "v-show": "<if>",
108
- "v-model": "value:=state",
109
- "v-bind": "...attrs",
110
- "v-html": "$!{html}",
111
- "v-text": "${text}"
112
- };
113
- function getWrongAttrSuggestion(name) {
114
- if (Object.hasOwn(knownWrongAttrs, name)) return knownWrongAttrs[name];
115
- const colon = name.indexOf(":");
116
- if (colon > 0) {
117
- const rest = name.slice(colon + 1);
118
- switch (name.slice(0, colon)) {
119
- case "class": return `class={ ${rest}: condition }`;
120
- case "style": return `style={ ${rest}: value }`;
121
- case "on":
122
- case "v-on": return `on${rest.charAt(0).toUpperCase()}${rest.slice(1)}`;
123
- case "bind":
124
- case "v-model": return `${rest}:=state`;
125
- case "v-bind": return rest;
126
- }
127
- }
128
- }
129
- function _call(fn, v) {
130
- fn(v);
131
- return v;
132
- }
133
- function stringifyClassObject(name, value) {
134
- return value ? name : "";
135
- }
136
- const warnedStyleKeys = /* @__PURE__ */ new Set();
137
- function stringifyStyleObject(name, value) {
138
- if (/[A-Z]/.test(name) && !name.includes("-") && !warnedStyleKeys.has(name)) {
139
- warnedStyleKeys.add(name);
140
- console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
141
- }
142
- return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
143
- }
144
- const unsafeStyleAttrReg = /[\\;]/g;
145
- const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
146
- function escapeStyleAttr(str) {
147
- return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
148
- }
149
- function escapeStyleValue(str) {
150
- let closers = "";
151
- const result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
152
- for (const c of result) if (c === "(") closers = ")" + closers;
153
- else if (c === "[") closers = "]" + closers;
154
- else if (c === closers[0]) closers = closers.slice(1);
155
- return result + closers;
156
- }
157
- const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
158
- let str = "";
159
- let sep = "";
160
- let part;
161
- if (val) if (typeof val !== "object") str += val;
162
- else if (Array.isArray(val)) for (const v of val) {
163
- part = toDelimitedString(v, delimiter, stringify);
164
- if (part) {
165
- str += sep + part;
166
- sep = delimiter;
167
- }
168
- }
169
- else for (const name in val) {
170
- part = stringify(name, val[name]);
171
- if (part) {
172
- str += sep + part;
173
- sep = delimiter;
174
- }
175
- }
176
- return str;
177
- };
178
- function isEventHandler(name) {
179
- return /^on[A-Z-]/.test(name);
180
- }
181
- function getEventHandlerName(name) {
182
- return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
183
- }
184
- function isNotVoid(value) {
185
- return value != null && value !== false;
186
- }
187
- function isPromise(value) {
188
- return value != null && typeof value.then === "function";
189
- }
190
- function normalizeDynamicRenderer(value) {
191
- if (value) {
192
- if (typeof value === "string") return value;
193
- const normalized = value.content || value.default || value;
194
- if (!((typeof normalized === "object" || typeof normalized === "function") && "id" in normalized)) {
195
- if (value.content) throw new Error(`A dynamic tag must be a string tag name (like \`"div"\`) or a Marko template/component, but received an object whose \`content\` is not a template/component.`);
196
- if (typeof value !== "object" && typeof value !== "function") throw new Error(`A dynamic tag must be a string tag name (like \`"div"\`) or a Marko template/component, but received a ${typeof value}.`);
197
- }
198
- if ("id" in normalized) return normalized;
199
- }
200
- }
201
- //#endregion
202
- //#region src/common/errors.ts
203
- const lowercaseEventHandlerReg = /^on[a-z]/;
204
- function assertValidAttrValue(name, value) {
205
- if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
206
- if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
207
- const unrenderable = describeUnrenderable(value);
208
- if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
209
- }
210
- function assertValidTextValue(value) {
211
- const unrenderable = describeUnrenderable(value);
212
- if (unrenderable) throw new Error(`Text content cannot be ${unrenderable}.`);
213
- }
214
- function describeUnrenderable(value) {
215
- if (typeof value === "symbol") return "a symbol";
216
- if (typeof value === "object" && value !== null) {
217
- let stringified;
218
- try {
219
- stringified = `${value}`;
220
- } catch {
221
- stringified = "[object Object]";
222
- }
223
- if (/^\[object \w+\]$/.test(stringified)) return stringified === "[object Promise]" ? "a promise (use the `<await>` tag to render its resolved value)" : stringified === "[object Object]" ? "a plain object (it would render as `[object Object]`)" : `a value that renders as \`${stringified}\``;
224
- }
225
- }
226
- function assertValidLoopKey(key, seenKeys) {
227
- if (typeof key !== "string" && typeof key !== "number") throw new Error(`A \`<for>\` tag's \`by\` attribute must return a string or number for each item, but received ${key === null ? "null" : `type "${typeof key}"`}.`);
228
- if (seenKeys) {
229
- if (seenKeys.has(key)) throw new Error(`A \`<for>\` tag's \`by\` attribute must return a unique value for each item, but \`${key}\` was used more than once.`);
230
- seenKeys.add(key);
231
- }
232
- }
233
- function assertValidList(value) {
234
- if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
235
- }
236
- function assertValidRangeBound(name, value) {
237
- if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
238
- }
239
- function describeForValue(value) {
240
- return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
241
- }
242
- function assertValidAttrName(name) {
243
- if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
244
- const suggestion = getWrongAttrSuggestion(name);
245
- if (suggestion) throw new Error(`\`${name}\` is not a valid attribute, did you mean \`${suggestion}\`?`);
246
- }
247
- function _el_read_error() {
248
- throw new Error("Element references can only be read in scripts and event handlers.");
249
- }
250
- function _hoist_read_error() {
251
- throw new Error("Hoisted values can only be read in scripts and event handlers.");
252
- }
253
- function _assert_hoist(value) {
254
- if (typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
255
- }
256
- function assertExclusiveAttrs(attrs, onError = throwErr) {
257
- if (attrs) {
258
- let exclusiveAttrs;
259
- if (attrs.checkedChange) (exclusiveAttrs ||= []).push("checkedChange");
260
- if ("checkedValue" in attrs) {
261
- (exclusiveAttrs ||= []).push("checkedValue");
262
- if ("checked" in attrs) exclusiveAttrs.push("checked");
263
- } else if (attrs.checkedValueChange) {
264
- (exclusiveAttrs ||= []).push("checkedValueChange");
265
- if ("checked" in attrs) exclusiveAttrs.push("checked");
266
- }
267
- if (attrs.valueChange) (exclusiveAttrs ||= []).push("valueChange");
268
- if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
269
- }
270
- }
271
- function assertHandlerIsFunction(name, value) {
272
- if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
273
- }
274
- function assertValidTagName(tagName) {
275
- if (!/^[a-z][a-z0-9._-]*$/i.test(tagName)) throw new Error(`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`);
276
- }
277
- function throwErr(msg) {
278
- throw new Error(msg);
279
- }
280
- function joinWithAnd(a) {
281
- switch (a.length) {
282
- case 0: return "";
283
- case 1: return a[0];
284
- case 2: return `${a[0]} and ${a[1]}`;
285
- default: return `${a.slice(0, -1).join(", ")}, and ${a[a.length - 1]}`;
286
- }
287
- }
288
- //#endregion
289
- //#region src/common/for.ts
290
- function forIn(obj, cb) {
291
- for (const key in obj) cb(key, obj[key]);
292
- }
293
- function forOf(list, cb) {
294
- assertValidList(list);
295
- if (list) {
296
- let i = 0;
297
- for (const item of list) cb(item, i++);
298
- }
299
- }
300
- function forTo(to, from, step, cb) {
301
- assertValidRangeBound("to", to);
302
- const start = from || 0;
303
- const delta = step || 1;
304
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
305
- }
306
- function forUntil(until, from, step, cb) {
307
- assertValidRangeBound("until", until);
308
- const start = from || 0;
309
- const delta = step || 1;
310
- for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
311
- }
312
- //#endregion
313
- //#region src/common/meta.ts
314
- const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
315
- //#endregion
316
- //#region src/common/opt.ts
317
- function toArray(opt) {
318
- return opt ? Array.isArray(opt) ? opt : [opt] : [];
319
- }
320
- function forEach(opt, cb) {
321
- if (opt) if (Array.isArray(opt)) for (const item of opt) cb(item);
322
- else cb(opt);
323
- }
324
- function push(opt, item) {
325
- return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
326
- }
327
- //#endregion
328
- //#region src/dom/event.ts
329
- function _on(element, type, handler) {
330
- assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
331
- if (element["$" + type] === void 0) delegate(type, handleDelegated);
332
- element["$" + type] = handler || null;
333
- }
334
- const delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, true), 1);
335
- function handleDelegated(ev) {
336
- let target = !rendering && ev.target;
337
- Object.defineProperty(ev, "currentTarget", {
338
- configurable: true,
339
- get() {
340
- console.error("Event.currentTarget is not supported in Marko's delegated events. Instead use an element reference or the second parameter of the event handler.");
341
- return null;
342
- }
343
- });
344
- while (target) {
345
- target["$" + ev.type]?.(ev, target);
346
- target = ev.bubbles && !ev.cancelBubble && target.parentNode;
347
- }
348
- delete ev.currentTarget;
349
- }
350
- //#endregion
351
- //#region src/dom/parse-html.ts
352
- const parsers = {};
353
- function parseHTML(html, ns) {
354
- const parser = parsers[ns] ||= document.createElementNS(ns, "template");
355
- parser.innerHTML = html;
356
- return parser.content || parser;
357
- }
358
- //#endregion
359
- //#region src/dom/scope.ts
360
- let nextScopeId = 1e6;
361
- let collectingScopes;
362
- function createScope($global, closestBranch) {
363
- const scope = {
364
- ["#Id"]: nextScopeId++,
365
- [Gen$1]: runId,
366
- [ClosestBranch]: closestBranch,
367
- [Global]: $global
368
- };
369
- collectingScopes?.push(scope);
370
- return scope;
371
- }
372
- function syncGen(scope) {
373
- scope[Gen$1] = runId;
374
- }
375
- function _assert_init(scope, accessor) {
376
- if (scope["#Gen"] === runId || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
377
- return scope[accessor];
378
- }
379
- function collectScopes(fn) {
380
- const prev = collectingScopes;
381
- collectingScopes = [];
382
- try {
383
- fn();
384
- return collectingScopes;
385
- } finally {
386
- collectingScopes = prev;
387
- }
388
- }
389
- function skipScope() {
390
- return nextScopeId++;
391
- }
392
- function findBranchWithKey(scope, key) {
393
- let branch = scope[ClosestBranch];
394
- while (branch && branch[key] == null) branch = branch[ParentBranch];
395
- return branch;
396
- }
397
- function destroyBranch(branch) {
398
- branch[ParentBranch]?.[BranchScopes]?.delete(branch);
399
- destroyNestedScopes(branch);
400
- }
401
- function destroyScope(scope) {
402
- if (scope["#Gen"]) {
403
- destroyNestedScopes(scope);
404
- cleanupScope(scope);
405
- }
406
- }
407
- const destroyNestedScopes = function destroyNestedScopes(scope) {
408
- scope[Gen$1] = 0;
409
- scope[BranchScopes]?.forEach(destroyNestedScopes);
410
- scope[AbortScopes]?.forEach(cleanupScope);
411
- };
412
- function cleanupScope(scope) {
413
- scope[Subscriptions]?.forEach(unsubscribe, scope);
414
- for (const id in scope[AbortControllers]) $signalReset(scope, id);
415
- }
416
- function unsubscribe(subscribers) {
417
- subscribers.delete(this);
418
- }
419
- function removeAndDestroyBranch(branch) {
420
- destroyBranch(branch);
421
- removeChildNodes(branch[StartNode], branch[EndNode]);
422
- }
423
- function insertBranchBefore(branch, parentNode, nextSibling) {
424
- insertChildNodes(parentNode, nextSibling, branch[StartNode], branch[EndNode]);
425
- }
426
- function tempDetachBranch(branch) {
427
- const fragment = new DocumentFragment();
428
- fragment.namespaceURI = branch[StartNode].parentNode.namespaceURI;
429
- insertChildNodes(fragment, null, branch[StartNode], branch[EndNode]);
430
- }
431
- //#endregion
432
- //#region src/dom/schedule.ts
433
- let runTask;
434
- let isScheduled;
435
- let channel;
436
- function schedule() {
437
- if (!isScheduled) {
438
- if (console.createTask) {
439
- const task = console.createTask("queue");
440
- runTask = () => task.run(run);
441
- } else runTask = run;
442
- isScheduled = 1;
443
- queueMicrotask(flushAndWaitFrame);
444
- }
445
- }
446
- function flushAndWaitFrame() {
447
- requestAnimationFrame(triggerMacroTask);
448
- runTask();
449
- }
450
- function triggerMacroTask() {
451
- if (!channel) {
452
- channel = new MessageChannel();
453
- channel.port1.onmessage = () => {
454
- isScheduled = 0;
455
- {
456
- const run = runTask;
457
- runTask = void 0;
458
- run();
459
- }
460
- };
461
- }
462
- channel.port2.postMessage(0);
463
- }
464
- //#endregion
465
- //#region src/dom/signals.ts
466
- function _let(id, fn) {
467
- const valueAccessor = id.slice(0, id.lastIndexOf("/"));
468
- id = +id.slice(id.lastIndexOf("/") + 1);
469
- return (scope, value) => {
470
- if (rendering) {
471
- if (scope["#Gen"] === runId) {
472
- scope[valueAccessor] = value;
473
- fn?.(scope);
474
- }
475
- } else if ((scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn)) {
476
- schedule();
477
- queueRender(scope, fn, id);
478
- }
479
- return value;
480
- };
481
- }
482
- function _let_change(id, fn) {
483
- const valueAccessor = id.slice(0, id.lastIndexOf("/"));
484
- const valueChangeAccessor = TagVariableChange$1 + valueAccessor;
485
- const base = _let(id, fn);
486
- return (scope, value, valueChange) => {
487
- if (rendering) if ((scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope))) {
488
- scope[valueAccessor] = value;
489
- fn?.(scope);
490
- } else base(scope, value);
491
- else if (scope[valueChangeAccessor]) scope[valueChangeAccessor](value);
492
- else base(scope, value);
493
- return value;
494
- };
495
- }
496
- function _const(valueAccessor, fn) {
497
- return ((scope, value) => {
498
- if (scope[valueAccessor] !== value || !(valueAccessor in scope)) {
499
- scope[valueAccessor] = value;
500
- fn?.(scope);
501
- }
502
- });
503
- }
504
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
505
- return (scope) => {
506
- if (scope["#Gen"] === runId) if (~id in scope) {
507
- if (!--scope[~id]) fn(scope);
508
- } else scope[~id] = defaultPending;
509
- else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
510
- };
511
- }
512
- function _for_closure(ownerLoopNodeAccessor, fn) {
513
- const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
514
- const ownerSignal = (ownerScope) => {
515
- const scopes = toArray(ownerScope[scopeAccessor]);
516
- if (scopes.length) queueRender(ownerScope, () => {
517
- for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
518
- }, -1, 0, scopes[0]["#Id"]);
519
- };
520
- ownerSignal._ = fn;
521
- return ownerSignal;
522
- }
523
- function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccessor, fn) {
524
- const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
525
- const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
526
- const prevKeyProp = `${PreviousKey}${ownerValueAccessor}`;
527
- const ownerSignal = (ownerScope) => {
528
- const scopes = toArray(ownerScope[scopeAccessor]);
529
- if (ownerScope["#Gen"] < runId && scopes.length) {
530
- const nextKey = ownerScope[ownerValueAccessor];
531
- queueRender(ownerScope, () => {
532
- const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor);
533
- if (map && prevKeyProp in map) {
534
- const prevScope = map.get(map[prevKeyProp]);
535
- const nextScope = map.get(nextKey);
536
- if (prevScope !== nextScope) {
537
- runLiveBranch(prevScope, fn);
538
- runLiveBranch(nextScope, fn);
539
- }
540
- } else for (const scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
541
- if (map) map[prevKeyProp] = nextKey;
542
- }, -1, 0, scopes[0]["#Id"]);
543
- }
544
- };
545
- ownerSignal._ = fn;
546
- return ownerSignal;
547
- }
548
- function keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor) {
549
- const map = ownerScope[mapAccessor] ||= /* @__PURE__ */ new Map();
550
- if (!map.size) for (const scope of toArray(ownerScope[scopeAccessor])) {
551
- const key = scope["#LoopKey"] ?? scope[keyValueAccessor];
552
- if (key === void 0) return ownerScope[mapAccessor] = null;
553
- scope[LoopKey] = key;
554
- map.set(key, scope);
555
- }
556
- return map;
557
- }
558
- function runLiveBranch(scope, fn) {
559
- if (scope && scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
560
- }
561
- function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
562
- const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
563
- const branchAccessor = ConditionalRenderer + ownerConditionalNodeAccessor;
564
- const ownerSignal = (scope) => {
565
- const ifScope = scope[scopeAccessor];
566
- if (ifScope && ifScope["#Gen"] > 0 && ifScope["#Gen"] < runId && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
567
- };
568
- ownerSignal._ = fn;
569
- return ownerSignal;
570
- }
571
- function subscribeToScopeSet(ownerScope, accessor, scope) {
572
- const subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
573
- const { size } = subscribers;
574
- if (subscribers.add(scope).size !== size) trackCleanup(scope, subscribers);
575
- }
576
- function _closure(...closureSignals) {
577
- const [firstSignal] = closureSignals;
578
- const scopeInstances = firstSignal[ScopeInstancesAccessor];
579
- const signalIndex = firstSignal[SignalIndexAccessor];
580
- for (let i = closureSignals.length; i--;) closureSignals[i][Index] = i;
581
- return (scope) => {
582
- if (scope[scopeInstances]) {
583
- for (const childScope of scope[scopeInstances]) if (childScope["#Gen"] > 0 && childScope["#Gen"] < runId) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
584
- }
585
- };
586
- }
587
- function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
588
- const closureSignal = ((scope) => {
589
- scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
590
- fn(scope);
591
- subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal[ScopeInstancesAccessor], scope);
592
- });
593
- closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
594
- closureSignal[SignalIndexAccessor] = ClosureSignalIndex + valueAccessor;
595
- resumeId && _resume(resumeId, closureSignal);
596
- return closureSignal;
597
- }
598
- function _child_setup(setup) {
599
- setup._ = (scope, owner) => {
600
- scope["_"] = owner;
601
- queueRender(scope, setup, -1);
602
- };
603
- return setup;
604
- }
605
- function _var(scope, childAccessor, signal) {
606
- scope[childAccessor][TagVariable] = (value) => signal(scope, value);
607
- }
608
- const _return = (scope, value) => scope[TagVariable]?.(value);
609
- function _return_change(scope, changeHandler) {
610
- if (changeHandler) scope[TagVariableChange] = changeHandler;
611
- }
612
- const _var_change = (scope, value, name = "This") => {
613
- if (typeof scope["#TagVariableChange"] !== "function") throw new TypeError(`${name} is a readonly tag variable.`);
614
- scope[TagVariableChange](value);
615
- };
616
- const tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
617
- function _id({ [Global]: $global }) {
618
- const id = tagIdsByGlobal.get($global) || 0;
619
- tagIdsByGlobal.set($global, id + 1);
620
- return "c" + $global.runtimeId + $global.renderId + id.toString(36);
621
- }
622
- function _script(id, fn) {
623
- _resume(id, fn);
624
- return (scope) => {
625
- queueEffect(scope, fn);
626
- };
627
- }
628
- function _el_read(value) {
629
- if (rendering) _el_read_error();
630
- return value;
631
- }
632
- function* traverse(scope, path, i = path.length - 1) {
633
- if (rendering) _hoist_read_error();
634
- if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, i);
635
- else {
636
- const item = scope[path[i]];
637
- if (i) yield* traverse(item, path, i - 1);
638
- else yield typeof item === "function" ? item() : item;
639
- }
640
- }
641
- function _hoist(...path) {
642
- return (scope) => {
643
- const fn = () => traverse(scope, path).next().value;
644
- fn[Symbol.iterator] = () => traverse(scope, path);
645
- return fn;
646
- };
647
- }
648
- function _hoist_resume(id, ...path) {
649
- return _resume(id, _hoist(...path));
650
- }
651
- //#endregion
652
- //#region src/dom/walker.ts
653
- /** Cloned templates are small, where a TreeWalker's per-step cost dominates. */
654
- let currentNode;
655
- function walk(startNode, walkCodes, branch) {
656
- currentNode = startNode;
657
- walkInternal(0, walkCodes, branch);
658
- }
659
- const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
660
- let value;
661
- let currentMultiplier;
662
- let storedMultiplier = 0;
663
- let currentScopeIndex = 0;
664
- for (; currentWalkIndex < walkCodes.length;) {
665
- value = walkCodes.charCodeAt(currentWalkIndex++);
666
- currentMultiplier = storedMultiplier;
667
- storedMultiplier = 0;
668
- if (value === 32) scope[getDebugKey(currentScopeIndex++, currentNode)] = currentNode;
669
- else if (value === 37 || value === 49) {
670
- currentNode.replaceWith(currentNode = scope[getDebugKey(currentScopeIndex++, "#text")] = new Text());
671
- if (value === 49) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
672
- } else if (value === 38) return currentWalkIndex;
673
- else if (value === 47 || value === 48) {
674
- currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope[Global], scope[ClosestBranch]));
675
- if (value === 48) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
676
- } else if (value < 92) {
677
- value = 25 * currentMultiplier + value - 67;
678
- while (value--) walkNextNode();
679
- } else if (value < 107) {
680
- value = 10 * currentMultiplier + value - 97;
681
- while (value--) walkNextSibling();
682
- } else if (value < 117) {
683
- value = 10 * currentMultiplier + value - 107;
684
- while (value--) currentNode = currentNode.parentNode || currentNode;
685
- walkNextSibling();
686
- } else {
687
- if (value < 117 || value > 126) throw new Error(`Unknown walk code: ${value}`);
688
- storedMultiplier = currentMultiplier * 10 + value - 117;
689
- }
690
- }
691
- };
692
- function getDebugKey(index, node) {
693
- if (typeof node === "string") return `${node}/${index}`;
694
- else if (node.nodeType === 3) return `#text/${index}`;
695
- else if (node.nodeType === 8) return `#comment/${index}`;
696
- else if (node.nodeType === 1) return `#${node.tagName.toLowerCase()}/${index}`;
697
- return index;
698
- }
699
- const walkNextNode = () => {
700
- if (currentNode.firstChild) return currentNode = currentNode.firstChild;
701
- while (!currentNode.nextSibling && currentNode.parentNode) currentNode = currentNode.parentNode;
702
- walkNextSibling();
703
- };
704
- const walkNextSibling = () => currentNode = currentNode.nextSibling || currentNode;
705
- //#endregion
706
- //#region src/dom/resume.ts
707
- const registeredValues = {};
708
- let curRenders;
709
- let branchesEnabled;
710
- let embedRenders;
711
- let readyIds;
712
- function enableBranches() {
713
- if (!branchesEnabled) {
714
- branchesEnabled = 1;
715
- skipDestroyedRenders();
716
- }
717
- }
718
- function ready(readyId) {
719
- (readyIds ||= /* @__PURE__ */ new Set()).add(readyId);
720
- for (const renderId in curRenders) runResumeEffects(curRenders[renderId]);
721
- }
722
- function initEmbedded(readyId, runtimeId) {
723
- if (!embedRenders) {
724
- embedRenders = /* @__PURE__ */ new Map();
725
- new MutationObserver(() => {
726
- for (const [anchor, [renderId, scopes]] of embedRenders) if (!anchor.isConnected) {
727
- embedRenders.delete(anchor);
728
- delete curRenders[renderId];
729
- for (const id in scopes) destroyScope(scopes[id]);
730
- }
731
- }).observe(document, {
732
- childList: true,
733
- subtree: true
734
- });
735
- }
736
- ready(readyId);
737
- init(runtimeId);
738
- }
739
- function init(runtimeId = "M") {
740
- if (curRenders) {
741
- if (curRenders !== self[runtimeId]) throw new Error(`Marko initialized multiple times with different $global.runtimeId's.`);
742
- return;
743
- }
744
- const renders = self[runtimeId];
745
- const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
746
- const initRuntime = (renders) => {
747
- defineRuntime({ value: curRenders = ((renderId) => {
748
- const render = curRenders[renderId] = renders[renderId] || renders(renderId);
749
- const walk = render.w;
750
- const scopeLookup = {};
751
- const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
752
- const initGlobal = () => scopeLookup[0] ||= {
753
- runtimeId,
754
- renderId
755
- };
756
- const initScope = (scope) => {
757
- scope[Gen$1] = 1;
758
- scope[Global] = initGlobal();
759
- if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
760
- return scope;
761
- };
762
- const applyScopes = (partials) => {
763
- let scopeId = partials[0];
764
- for (let i = 1; i < partials.length; i++) {
765
- const partial = partials[i];
766
- if (typeof partial === "number") scopeId += partial;
767
- else {
768
- if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
769
- else Object.assign(initGlobal(), partial);
770
- scopeId++;
771
- }
772
- }
773
- };
774
- const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
775
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
776
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
777
- if (visitType !== "[") {
778
- visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
779
- accessor = BranchScopes$1 + lastToken;
780
- singleNode = visitType !== "]" && visitType !== ")";
781
- nextToken();
782
- }
783
- while (branchId = +lastToken) {
784
- (endedBranches ||= []).push(branch = getScope(branchId));
785
- setParentBranch(branch, branch[ClosestBranch]);
786
- if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
787
- if (singleNode) {
788
- while (startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling));
789
- branch["_"] ??= visitScope;
790
- branch[EndNode] = branch[StartNode] = startVisit;
791
- if (visitType === "'") branch[getDebugKey(0, startVisit)] = startVisit;
792
- } else {
793
- curBranchScopes = push(curBranchScopes, branch);
794
- if (accessor) {
795
- visitScope[accessor] = curBranchScopes;
796
- forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
797
- curBranchScopes = branchScopesStack.pop();
798
- }
799
- startVisit = branchStarts.pop();
800
- if (parent !== startVisit.parentNode) parent.prepend(startVisit);
801
- branch[StartNode] = startVisit;
802
- branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
803
- }
804
- while (i && orphanBranches[i - 1]["#Id"] > branchId) {
805
- i--;
806
- setParentBranch(orphanBranches.pop(), branch);
807
- }
808
- while (j && deferredOwners[j - 1]["#Id"] > branchId) {
809
- j--;
810
- const owner = deferredOwners.pop();
811
- if (owner["#ClosestBranch"] !== owner) owner[ClosestBranch] = branch;
812
- }
813
- nextToken();
814
- }
815
- if (endedBranches) {
816
- for (const ended of endedBranches) orphanBranches.push(ended);
817
- if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
818
- }
819
- if (visitType === "[") {
820
- if (!endedBranches) {
821
- branchScopesStack.push(curBranchScopes);
822
- curBranchScopes = void 0;
823
- }
824
- branchStarts.push(visit);
825
- } else deferredOwners.push(visitScope);
826
- };
827
- };
828
- const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
829
- const processResumes = (resumes = [], effects) => {
830
- let i = 0;
831
- for (; i < resumes.length; i++) {
832
- const serialized = resumes[i];
833
- if (typeof serialized === "string") {
834
- lastTokenIndex = 0;
835
- visitText = serialized;
836
- while (nextToken()) if (/\D/.test(lastToken)) lastEffect = registeredValues[lastToken];
837
- else effects.push(lastEffect, getScope(lastToken));
838
- } else if (Array.isArray(serialized)) {
839
- if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
840
- } else if (readyIds && typeof serialized === "number") break;
841
- else {
842
- const scopes = serialized(serializeContext);
843
- if (Array.isArray(scopes)) applyScopes(scopes);
844
- }
845
- }
846
- resumes.splice(0, i);
847
- return i;
848
- };
849
- let lastEffect;
850
- let visits;
851
- let visit;
852
- let visitText;
853
- let visitType;
854
- let visitScope;
855
- let lastToken;
856
- let lastTokenIndex;
857
- let visitBranches;
858
- let embedAnchor;
859
- serializeContext._ = registeredValues;
860
- if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
861
- render.m = (effects) => {
862
- processResumes(render.r, effects);
863
- if (readyIds && render.b) for (let progress = 1; progress;) {
864
- progress = 0;
865
- for (const readyId of readyIds) {
866
- const resumes = render.b[readyId];
867
- if (resumes && processResumes(resumes, effects)) progress = 1;
868
- }
869
- }
870
- let retained = 0;
871
- for (visit of visits = render.v) {
872
- lastTokenIndex = render.i.length;
873
- visitText = visit.data;
874
- visitType = visitText[lastTokenIndex++];
875
- visitScope = getScope(nextToken());
876
- if (visitType === "*") {
877
- const prev = visit.previousSibling;
878
- visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
879
- } else if (branchesEnabled) (visitBranches ||= createVisitBranches())();
880
- else if (render.b) visits[retained++] = visit;
881
- }
882
- if (embedRenders && !embedAnchor && visit) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]);
883
- visits.length = retained;
884
- return effects;
885
- };
886
- render.w = () => {
887
- walk();
888
- runResumeEffects(render);
889
- };
890
- return render;
891
- }) });
892
- };
893
- if (renders) {
894
- initRuntime(renders);
895
- for (const renderId in renders) runResumeEffects(curRenders(renderId));
896
- } else defineRuntime({
897
- configurable: true,
898
- set: initRuntime
899
- });
900
- }
901
- let isResuming;
902
- function runResumeEffects(render) {
903
- try {
904
- isResuming = 1;
905
- runEffects(render.m([]), 1);
906
- } finally {
907
- isResuming = 0;
908
- }
909
- }
910
- function getRegisteredWithScope(id, scope) {
911
- const val = registeredValues[id];
912
- return scope ? val(scope) : val;
913
- }
914
- function _resume(id, obj) {
915
- return registeredValues[id] = obj;
916
- }
917
- function _var_resume(id, signal) {
918
- _resume(id, (scope) => (value) => signal(scope, value));
919
- return signal;
920
- }
921
- function _el(id, accessor) {
922
- return _resume(id, (scope) => () => _el_read(scope[accessor]));
923
- }
924
- //#endregion
925
- //#region src/dom/renderer.ts
926
- function createBranch($global, renderer, parentScope, parentNode) {
927
- const branch = createScope($global);
928
- branch["_"] = renderer["owner"] || parentScope;
929
- setParentBranch(branch, parentScope?.[ClosestBranch]);
930
- branch[Renderer] = renderer;
931
- renderer[Clone]?.(branch, parentNode.namespaceURI);
932
- return branch;
933
- }
934
- function setParentBranch(branch, parentBranch) {
935
- if (parentBranch) {
936
- branch[ParentBranch] = parentBranch;
937
- (parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
938
- }
939
- branch[ClosestBranch] = branch;
940
- }
941
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
942
- return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
943
- }
944
- function setupBranch(renderer, branch) {
945
- if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
946
- return branch;
947
- }
948
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
949
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
950
- setup = setup ? setup._ || setup : void 0;
951
- params ||= void 0;
952
- const clone = template ? (branch, ns) => {
953
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
954
- } : (branch) => {
955
- walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
956
- };
957
- return (owner) => {
958
- return {
959
- ["id"]: id,
960
- [Clone]: clone,
961
- [Owner]: owner,
962
- [Setup]: setup,
963
- [Params]: params,
964
- [Accessor]: dynamicScopesAccessor
965
- };
966
- };
967
- }
968
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
969
- return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
970
- }
971
- function _content_closures(renderer, closureFns) {
972
- const closureSignals = {};
973
- for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
974
- return (owner, closureValues) => {
975
- const instance = renderer(owner);
976
- instance[LocalClosures] = closureSignals;
977
- instance[LocalClosureValues] = closureValues;
978
- return instance;
979
- };
980
- }
981
- const cloneCache = {};
982
- function createCloneableHTML(html, ns) {
983
- const { firstChild, lastChild } = parseHTML(html, ns);
984
- const parent = document.createElementNS(ns, "t");
985
- insertChildNodes(parent, null, firstChild, lastChild);
986
- return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
987
- walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
988
- } : (branch, walks) => {
989
- const clone = parent.cloneNode(true);
990
- walk(clone.firstChild, walks, branch);
991
- branch[StartNode] = clone.firstChild;
992
- branch[EndNode] = clone.lastChild;
993
- };
994
- }
995
- //#endregion
996
- //#region src/dom/dom.ts
997
- function _to_text(value) {
998
- assertValidTextValue(value);
999
- return value || value === 0 ? value + "" : "";
1000
- }
1001
- function _attr(element, name, value) {
1002
- assertValidAttrValue(name, value);
1003
- setAttribute(element, name, normalizeAttrValue(value));
1004
- }
1005
- function setAttribute(element, name, value) {
1006
- if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
1007
- else element.setAttribute(name, value);
1008
- }
1009
- function _attr_class(element, value) {
1010
- setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
1011
- }
1012
- function _attr_class_items(element, items) {
1013
- for (const key in items) _attr_class_item(element, key, items[key]);
1014
- }
1015
- function _attr_class_item(element, name, value) {
1016
- element.classList.toggle(name, !!value);
1017
- }
1018
- function _attr_style(element, value) {
1019
- setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
1020
- }
1021
- function _attr_style_items(element, items) {
1022
- for (const key in items) _attr_style_item(element, key, items[key]);
1023
- }
1024
- function _attr_style_item(element, name, value) {
1025
- element.style.setProperty(name, _to_text(value));
1026
- }
1027
- function _style_shell(scope, nodeAccessor) {
1028
- const element = scope[nodeAccessor];
1029
- const id = _id(scope);
1030
- _attr_nonce(scope, nodeAccessor);
1031
- element.className = id;
1032
- _text_content(element, "." + id + "~*{}");
1033
- }
1034
- function _style_rule_item(element, name, value) {
1035
- const text = element.textContent;
1036
- const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
1037
- let start = text.indexOf("{" + name + ":");
1038
- if (!~start) start = text.indexOf(";" + name + ":");
1039
- _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
1040
- }
1041
- function _attr_nonce(scope, nodeAccessor) {
1042
- _attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
1043
- }
1044
- function _text(node, value) {
1045
- const normalizedValue = _to_text(value);
1046
- if (node.data !== normalizedValue) node.data = normalizedValue;
1047
- }
1048
- function _text_content(node, value) {
1049
- const normalizedValue = _to_text(value);
1050
- if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
1051
- }
1052
- function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
1053
- const el = scope[nodeAccessor];
1054
- for (let i = el.attributes.length; i--;) {
1055
- const { name } = el.attributes.item(i);
1056
- if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
1057
- }
1058
- assertExclusiveAttrs(nextAttrs);
1059
- attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
1060
- }
1061
- function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
1062
- _attrs(scope, nodeAccessor, nextAttrs, controllable);
1063
- _attr_content(scope, nodeAccessor, nextAttrs?.content);
1064
- }
1065
- function hasAttrAlias(element, attr, nextAttrs) {
1066
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
1067
- }
1068
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
1069
- const el = scope[nodeAccessor];
1070
- const partial = {};
1071
- for (let i = el.attributes.length; i--;) {
1072
- const { name } = el.attributes.item(i);
1073
- if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
1074
- }
1075
- for (const name in nextAttrs) {
1076
- const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
1077
- if (!skip[key]) partial[key] = nextAttrs[name];
1078
- }
1079
- assertExclusiveAttrs({
1080
- ...nextAttrs,
1081
- ...skip
1082
- });
1083
- attrsInternal(scope, nodeAccessor, partial, controllable);
1084
- }
1085
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
1086
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable);
1087
- _attr_content(scope, nodeAccessor, nextAttrs?.content);
1088
- }
1089
- function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1090
- const el = scope[nodeAccessor];
1091
- let events = scope[EventAttributes + nodeAccessor];
1092
- let skip = void 0;
1093
- for (const name in events) events[name] = 0;
1094
- if (controllable) {
1095
- scope[ControlledType + nodeAccessor] = 5;
1096
- scope[ControlledHandler + nodeAccessor] = 0;
1097
- if (nextAttrs) skip = controllable(scope, nodeAccessor, nextAttrs);
1098
- }
1099
- for (const name in nextAttrs) {
1100
- const value = nextAttrs[name];
1101
- switch (name) {
1102
- case "class":
1103
- _attr_class(el, value);
1104
- break;
1105
- case "style":
1106
- _attr_style(el, value);
1107
- break;
1108
- default:
1109
- assertValidAttrName(name);
1110
- if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
1111
- else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
1112
- break;
1113
- }
1114
- }
1115
- }
1116
- function _attr_content(scope, nodeAccessor, value) {
1117
- const content = normalizeClientRender(value);
1118
- if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
1119
- setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
1120
- if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
1121
- }
1122
- for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
1123
- }
1124
- function _attrs_script(scope, nodeAccessor) {
1125
- const el = scope[nodeAccessor];
1126
- const events = scope[EventAttributes + nodeAccessor];
1127
- controllableScripts[scope[ControlledType + nodeAccessor]]?.(scope, nodeAccessor);
1128
- for (const name in events) _on(el, name, events[name]);
1129
- }
1130
- function _html(scope, value, accessor) {
1131
- const firstChild = scope[accessor];
1132
- const parentNode = firstChild.parentNode;
1133
- const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
1134
- const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
1135
- insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
1136
- removeChildNodes(firstChild, lastChild);
1137
- }
1138
- function normalizeClientRender(value) {
1139
- const renderer = normalizeDynamicRenderer(value);
1140
- if (renderer) if (renderer["id"]) return renderer;
1141
- else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1142
- }
1143
- function normalizeAttrValue(value) {
1144
- if (isNotVoid(value)) return value === true ? "" : value + "";
1145
- }
1146
- function _lifecycle(scope, thisObj, index = 0) {
1147
- const accessor = Lifecycle + index;
1148
- const instance = scope[accessor];
1149
- if (instance) {
1150
- Object.assign(instance, thisObj);
1151
- instance.onUpdate?.();
1152
- } else {
1153
- scope[accessor] = thisObj;
1154
- {
1155
- const snapshot = { ...thisObj };
1156
- Object.assign(thisObj, thisObj.onMount?.());
1157
- for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
1158
- }
1159
- $signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
1160
- }
1161
- }
1162
- function removeChildNodes(startNode, endNode) {
1163
- const stop = endNode.nextSibling;
1164
- while (startNode !== stop) {
1165
- const next = startNode.nextSibling;
1166
- startNode.remove();
1167
- startNode = next;
1168
- }
1169
- }
1170
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
1171
- if (parentNode.isConnected) parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
1172
- else {
1173
- const stop = endNode.nextSibling;
1174
- while (startNode !== stop) {
1175
- const next = startNode.nextSibling;
1176
- parentNode.insertBefore(startNode, referenceNode);
1177
- startNode = next;
1178
- }
1179
- }
1180
- return parentNode;
1181
- }
1182
- function toInsertNode(startNode, endNode) {
1183
- return startNode === endNode ? startNode : insertChildNodes(new DocumentFragment(), null, startNode, endNode);
1184
- }
1185
- //#endregion
1186
- //#region src/dom/resolve-cursor-position.ts
1187
- const R = /[^\p{L}\p{N}]/gu;
1188
- function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
1189
- if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
1190
- const before = initialValue.slice(0, initialPosition);
1191
- const after = initialValue.slice(initialPosition);
1192
- if (updatedValue.startsWith(before)) return initialPosition;
1193
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
1194
- let count = before.replace(R, "").length;
1195
- let pos = 0;
1196
- while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
1197
- return pos;
1198
- }
1199
- return -1;
1200
- }
1201
- //#endregion
1202
- //#region src/dom/controllable.ts
1203
- let inputType = "";
1204
- function _attr_input_checked_default(scope, nodeAccessor, checked) {
1205
- const el = scope[nodeAccessor];
1206
- const normalizedChecked = isNotVoid(checked);
1207
- if (el.defaultChecked !== normalizedChecked) {
1208
- const restoreValue = scope["#Gen"] < runId ? el.checked : normalizedChecked;
1209
- el.defaultChecked = normalizedChecked;
1210
- if (restoreValue !== normalizedChecked) el.checked = restoreValue;
1211
- }
1212
- }
1213
- /** Filled by the latches a compiled page emits, so a page carries only the
1214
- * control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
1215
- const controllableScripts = {};
1216
- /** The render pass equivalent, for a tag whose name is only known at run time;
1217
- * a statically named tag passes its claim to `_attrs` instead. */
1218
- const controllableRenders = {};
1219
- function _enable_controllable_input() {
1220
- controllableScripts[0] = _attr_input_checked_script;
1221
- controllableScripts[1] = _attr_input_checkedValue_script;
1222
- controllableScripts[2] = _attr_input_value_script;
1223
- }
1224
- function _enable_controllable_textarea() {
1225
- controllableScripts[2] = _attr_input_value_script;
1226
- }
1227
- function _enable_controllable_select() {
1228
- controllableScripts[3] = _attr_select_value_script;
1229
- }
1230
- function _enable_controllable_open() {
1231
- controllableScripts[4] = _attr_details_or_dialog_open_script;
1232
- }
1233
- /** A run-time tag name can be any controllable, so its page enables them all. */
1234
- function _enable_controllable() {
1235
- _enable_controllable_input();
1236
- _enable_controllable_select();
1237
- _enable_controllable_open();
1238
- controllableRenders.INPUT = _controllable_input;
1239
- controllableRenders.TEXTAREA = _controllable_textarea;
1240
- controllableRenders.SELECT = _controllable_select;
1241
- controllableRenders.DETAILS = controllableRenders.DIALOG = _controllable_open;
1242
- }
1243
- function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
1244
- const el = scope[nodeAccessor];
1245
- const normalizedChecked = isNotVoid(checked);
1246
- assertHandlerIsFunction("checkedChange", checkedChange);
1247
- scope[ControlledHandler + nodeAccessor] = checkedChange;
1248
- scope[ControlledType + nodeAccessor] = checkedChange ? 0 : 5;
1249
- if (checkedChange && scope["#Gen"] < runId) el.checked = normalizedChecked;
1250
- else _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
1251
- }
1252
- function _attr_input_checked_script(scope, nodeAccessor) {
1253
- const el = scope[nodeAccessor];
1254
- syncControllableFormInput(el, hasCheckboxChanged, () => {
1255
- const checkedChange = scope[ControlledHandler + nodeAccessor];
1256
- if (checkedChange) {
1257
- const newValue = el.checked;
1258
- el.checked = !newValue;
1259
- checkedChange(newValue);
1260
- run();
1261
- }
1262
- });
1263
- }
1264
- function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
1265
- const multiple = Array.isArray(checkedValue);
1266
- const normalizedValue = normalizeStrProp(value);
1267
- const normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
1268
- _attr(scope[nodeAccessor], "value", value);
1269
- _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
1270
- }
1271
- function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
1272
- const el = scope[nodeAccessor];
1273
- const multiple = Array.isArray(checkedValue);
1274
- const normalizedCheckedValue = scope[ControlledValue + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
1275
- assertHandlerIsFunction("checkedValueChange", checkedValueChange);
1276
- scope[ControlledHandler + nodeAccessor] = checkedValueChange;
1277
- scope[ControlledType + nodeAccessor] = checkedValueChange ? 1 : 5;
1278
- if (checkedValueChange && scope["#Gen"] < runId) {
1279
- el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue;
1280
- _attr(el, "value", value);
1281
- } else _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
1282
- }
1283
- function _attr_input_checkedValue_script(scope, nodeAccessor) {
1284
- const el = scope[nodeAccessor];
1285
- if (isResuming && el.defaultChecked) if (scope["ControlledValue:" + nodeAccessor]) scope[ControlledValue + nodeAccessor].push(el.value);
1286
- else scope[ControlledValue + nodeAccessor] = el.value;
1287
- syncControllableFormInput(el, hasCheckboxChanged, () => {
1288
- const checkedValueChange = scope[ControlledHandler + nodeAccessor];
1289
- if (checkedValueChange) {
1290
- const controlledValueKey = ControlledValue + nodeAccessor;
1291
- const oldValue = scope[controlledValueKey];
1292
- let newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
1293
- if (el.name && el.type[0] === "r") {
1294
- for (const radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) {
1295
- if (newValue === void 0 && radio.defaultChecked) newValue = radio.value;
1296
- radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : controlledValueKey in scope ? oldValue === radio.value : radio.defaultChecked;
1297
- }
1298
- } else el.checked = !el.checked;
1299
- checkedValueChange(newValue);
1300
- run();
1301
- }
1302
- });
1303
- }
1304
- function _attr_input_value_default(scope, nodeAccessor, value) {
1305
- const el = scope[nodeAccessor];
1306
- const normalizedValue = normalizeAttrValue(value) || "";
1307
- if (el.defaultValue !== normalizedValue) {
1308
- const restoreValue = scope["#Gen"] < runId ? el.value : normalizedValue;
1309
- el.defaultValue = normalizedValue;
1310
- setInputValue(el, restoreValue);
1311
- }
1312
- }
1313
- function _attr_input_value_dynamic_default(scope, nodeAccessor, value) {
1314
- const el = scope[nodeAccessor];
1315
- if (/i[ot]|e[cns]|^[bi]/.test(el.type)) _attr(el, "value", value);
1316
- else _attr_input_value_default(scope, nodeAccessor, value);
1317
- }
1318
- function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault = _attr_input_value_default) {
1319
- const el = scope[nodeAccessor];
1320
- const normalizedValue = normalizeAttrValue(value) || "";
1321
- assertHandlerIsFunction("valueChange", valueChange);
1322
- scope[ControlledHandler + nodeAccessor] = valueChange;
1323
- scope[ControlledValue + nodeAccessor] = normalizedValue;
1324
- scope[ControlledType + nodeAccessor] = valueChange ? 2 : 5;
1325
- if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
1326
- else setDefault(scope, nodeAccessor, normalizedValue);
1327
- }
1328
- function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
1329
- _attr(scope[nodeAccessor], "value", value);
1330
- }
1331
- function _attr_input_value_script(scope, nodeAccessor) {
1332
- const el = scope[nodeAccessor];
1333
- if (isResuming) scope[ControlledValue + nodeAccessor] = el.defaultValue;
1334
- syncControllableFormInput(el, hasValueChanged, (ev) => {
1335
- const valueChange = scope[ControlledHandler + nodeAccessor];
1336
- if (valueChange) {
1337
- inputType = ev?.inputType;
1338
- valueChange(el.value);
1339
- run();
1340
- setInputValue(el, scope[ControlledValue + nodeAccessor]);
1341
- inputType = "";
1342
- }
1343
- });
1344
- }
1345
- function setInputValue(el, value) {
1346
- if (el.value !== value) {
1347
- const updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
1348
- if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
1349
- }
1350
- }
1351
- function _attr_select_value_default(scope, nodeAccessor, value) {
1352
- let restoreValue;
1353
- const el = scope[nodeAccessor];
1354
- const live = scope[Gen$1] < runId;
1355
- const multiple = Array.isArray(value);
1356
- const normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
1357
- pendingEffects.unshift(() => {
1358
- for (const opt of el.options) {
1359
- const selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
1360
- if (opt.defaultSelected !== selected) {
1361
- if (live) restoreValue ??= getSelectValue(el, multiple);
1362
- opt.defaultSelected = selected;
1363
- }
1364
- }
1365
- if (restoreValue !== void 0) setSelectValue(el, restoreValue, multiple);
1366
- }, scope);
1367
- }
1368
- function _attr_select_value(scope, nodeAccessor, value, valueChange) {
1369
- const el = scope[nodeAccessor];
1370
- const existing = scope[Gen$1] < runId;
1371
- const multiple = Array.isArray(value);
1372
- const normalizedValue = scope[ControlledValue + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
1373
- assertHandlerIsFunction("valueChange", valueChange);
1374
- scope[ControlledHandler + nodeAccessor] = valueChange;
1375
- scope[ControlledType + nodeAccessor] = valueChange ? 3 : 5;
1376
- if (valueChange) pendingEffects.unshift(() => assertSelectValueMatchesOption(el, normalizedValue, value), scope);
1377
- if (valueChange && existing) pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope);
1378
- else _attr_select_value_default(scope, nodeAccessor, normalizedValue);
1379
- }
1380
- function _attr_select_value_script(scope, nodeAccessor) {
1381
- const el = scope[nodeAccessor];
1382
- const onChange = () => {
1383
- const valueChange = scope[ControlledHandler + nodeAccessor];
1384
- if (valueChange) {
1385
- const oldValue = scope[ControlledValue + nodeAccessor];
1386
- const multiple = Array.isArray(oldValue);
1387
- const newValue = getSelectValue(el, multiple);
1388
- setSelectValue(el, oldValue, multiple);
1389
- valueChange(newValue);
1390
- run();
1391
- }
1392
- };
1393
- if (isResuming) if (el.multiple) {
1394
- scope[ControlledValue + nodeAccessor] = [];
1395
- for (const opt of el.options) if (opt.defaultSelected) scope[ControlledValue + nodeAccessor].push(opt.value);
1396
- } else {
1397
- scope[ControlledValue + nodeAccessor] = "";
1398
- for (const opt of el.options) if (opt.defaultSelected) {
1399
- scope[ControlledValue + nodeAccessor] = opt.value;
1400
- break;
1401
- }
1402
- }
1403
- syncControllableFormInput(el, hasSelectChanged, onChange);
1404
- observeOnce(scope, nodeAccessor, {
1405
- childList: true,
1406
- subtree: true
1407
- }, () => {
1408
- const value = scope[ControlledValue + nodeAccessor];
1409
- if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
1410
- });
1411
- }
1412
- function setSelectValue(el, value, multiple) {
1413
- if (multiple) for (const opt of el.options) opt.selected = value.includes(opt.value);
1414
- else el.value = value;
1415
- }
1416
- function getSelectValue(el, multiple) {
1417
- return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
1418
- }
1419
- function assertSelectValueMatchesOption(el, normalizedValue, value) {
1420
- const multiple = Array.isArray(normalizedValue);
1421
- if (multiple ? normalizedValue.some(Boolean) : normalizedValue) {
1422
- for (const opt of el.options) if (multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue) return;
1423
- console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
1424
- }
1425
- }
1426
- function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
1427
- if (scope["#Gen"] === runId) scope[nodeAccessor].open = isNotVoid(open);
1428
- }
1429
- function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
1430
- const normalizedOpen = scope[ControlledValue + nodeAccessor] = isNotVoid(open);
1431
- assertHandlerIsFunction("openChange", openChange);
1432
- scope[ControlledHandler + nodeAccessor] = openChange;
1433
- scope[ControlledType + nodeAccessor] = openChange ? 4 : 5;
1434
- if (openChange && scope["#Gen"] < runId) scope[nodeAccessor].open = normalizedOpen;
1435
- else _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
1436
- }
1437
- function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
1438
- const el = scope[nodeAccessor];
1439
- observeOnce(scope, nodeAccessor, {
1440
- attributes: true,
1441
- attributeFilter: ["open"]
1442
- }, () => {
1443
- const openChange = scope[ControlledHandler + nodeAccessor];
1444
- if (openChange && el.open === !scope["ControlledValue:" + nodeAccessor]) {
1445
- const newValue = el.open;
1446
- el.open = !newValue;
1447
- openChange(newValue);
1448
- run();
1449
- }
1450
- });
1451
- }
1452
- function observeOnce(scope, nodeAccessor, init, callback) {
1453
- (scope[ControlledObserver + nodeAccessor] ||= new MutationObserver(callback)).observe(scope[nodeAccessor], init);
1454
- }
1455
- function syncControllableFormInput(el, hasChanged, onChange) {
1456
- el._ = onChange;
1457
- delegate("input", handleChange);
1458
- if (el.form) delegate("reset", handleFormReset);
1459
- if (isResuming && hasChanged(el)) queueMicrotask(onChange);
1460
- }
1461
- function handleChange(ev) {
1462
- ev.target._?.(ev);
1463
- }
1464
- function handleFormReset(ev) {
1465
- const handlers = [];
1466
- for (const el of ev.target.elements) if (el._ && hasFormElementChanged(el)) handlers.push(el._);
1467
- requestAnimationFrame(() => {
1468
- if (!ev.defaultPrevented) for (const change of handlers) change();
1469
- });
1470
- }
1471
- function hasValueChanged(el) {
1472
- return el.value !== el.defaultValue;
1473
- }
1474
- function hasCheckboxChanged(el) {
1475
- return el.checked !== el.defaultChecked;
1476
- }
1477
- function hasSelectChanged(el) {
1478
- for (const opt of el.options) if (opt.selected !== opt.defaultSelected) return true;
1479
- }
1480
- function hasFormElementChanged(el) {
1481
- return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
1482
- }
1483
- function normalizeStrProp(value) {
1484
- return normalizeAttrValue(value) || "";
1485
- }
1486
- function updateList(arr, val, push) {
1487
- const index = arr.indexOf(val);
1488
- return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
1489
- }
1490
- function _controllable_input(scope, nodeAccessor, nextAttrs) {
1491
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
1492
- _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1493
- return /^checked(?:Value)?(?:Change)?$/;
1494
- }
1495
- if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
1496
- _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1497
- return /^(?:value|checked(?:Value)?)(?:Change)?$/;
1498
- }
1499
- return _controllable_textarea(scope, nodeAccessor, nextAttrs, _attr_input_value_dynamic_default);
1500
- }
1501
- function _controllable_textarea(scope, nodeAccessor, nextAttrs, dynamicDefault) {
1502
- if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1503
- _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, dynamicDefault);
1504
- return /^value(?:Change)?$/;
1505
- }
1506
- }
1507
- function _controllable_select(scope, nodeAccessor, nextAttrs) {
1508
- if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1509
- _attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1510
- return /^value(?:Change)?$/;
1511
- }
1512
- }
1513
- function _controllable_open(scope, nodeAccessor, nextAttrs) {
1514
- if ("open" in nextAttrs || "openChange" in nextAttrs) {
1515
- _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
1516
- return /^open(?:Change)?$/;
1517
- }
1518
- }
1519
- //#endregion
1520
- //#region src/dom/control-flow.ts
1521
- function _await_promise(nodeAccessor, params) {
1522
- const promiseAccessor = Promise$1 + nodeAccessor;
1523
- const branchAccessor = BranchScopes$1 + nodeAccessor;
1524
- _enable_catch();
1525
- const resolveAwait = (scope, referenceNode, value) => {
1526
- const awaitBranch = scope[branchAccessor];
1527
- if (awaitBranch["#DetachedAwait"]) {
1528
- awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1529
- setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1530
- awaitBranch[DetachedAwait] = 0;
1531
- insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1532
- referenceNode.remove();
1533
- }
1534
- params?.(awaitBranch, [value]);
1535
- return awaitBranch;
1536
- };
1537
- const awaitPromise = (scope, promise) => {
1538
- if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1539
- let awaitBranch = scope[branchAccessor];
1540
- const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1541
- const tryBranch = tryPlaceholder || awaitBranch;
1542
- if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1543
- scope[promiseAccessor] = () => awaitPromise(scope, promise);
1544
- return;
1545
- }
1546
- if (!isPromise(promise)) {
1547
- resolveAwait(scope, scope[nodeAccessor], promise);
1548
- return;
1549
- }
1550
- let awaitCounter = tryBranch[AwaitCounter];
1551
- placeholderShown.add(pendingEffects);
1552
- if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
1553
- if (tryBranch === scope[branchAccessor]) {
1554
- const anchor = scope[nodeAccessor];
1555
- if (anchor.parentNode) {
1556
- const detachedParent = scope[branchAccessor][StartNode].parentNode;
1557
- if (detachedParent === anchor.parentNode) anchor.remove();
1558
- else anchor.replaceWith(detachedParent);
1559
- }
1560
- } else dismissPlaceholder(tryBranch);
1561
- });
1562
- if (!scope[promiseAccessor]) {
1563
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1564
- if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1565
- else if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1566
- if (!awaitBranch["#DetachedAwait"]) {
1567
- awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1568
- tempDetachBranch(tryBranch);
1569
- }
1570
- }, -1))));
1571
- }
1572
- const thisPromise = scope[promiseAccessor] = promise.then((data) => {
1573
- if (thisPromise === scope[promiseAccessor]) {
1574
- const referenceNode = scope[nodeAccessor];
1575
- scope[promiseAccessor] = 0;
1576
- if (scope["#ClosestBranch"]?.["#Gen"] === 0) {
1577
- awaitCounter.c();
1578
- run();
1579
- return;
1580
- }
1581
- queueAsyncRender(scope, () => {
1582
- awaitBranch = resolveAwait(scope, referenceNode, data);
1583
- const pendingRenders = awaitBranch[PendingRenders];
1584
- awaitBranch[PendingRenders] = 0;
1585
- pendingRenders?.forEach(queuePendingRender);
1586
- placeholderShown.add(pendingEffects);
1587
- awaitCounter.c();
1588
- if (awaitCounter.m) {
1589
- const fnScopes = /* @__PURE__ */ new Map();
1590
- const effects = awaitCounter.m([]);
1591
- for (let i = 0; i < pendingEffects.length;) {
1592
- const fn = pendingEffects[i++];
1593
- let scopes = fnScopes.get(fn);
1594
- if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
1595
- scopes.add(pendingEffects[i++]);
1596
- }
1597
- for (let i = 0; i < effects.length;) {
1598
- const fn = effects[i++];
1599
- const scope = effects[i++];
1600
- if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
1601
- }
1602
- }
1603
- });
1604
- }
1605
- }, (error) => {
1606
- if (thisPromise === scope[promiseAccessor]) {
1607
- scope[promiseAccessor] = 0;
1608
- if (tryPlaceholder && !awaitCounter.m) awaitCounter.c();
1609
- else awaitCounter.i = 0;
1610
- queueAsyncRender(scope, renderCatch, error);
1611
- }
1612
- });
1613
- };
1614
- return awaitPromise;
1615
- }
1616
- function _await_content(nodeAccessor, template, walks, setup) {
1617
- const branchAccessor = BranchScopes$1 + nodeAccessor;
1618
- const promiseAccessor = Promise$1 + nodeAccessor;
1619
- const renderer = _content("", template, walks, setup)();
1620
- return (scope) => {
1621
- const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope[Global], renderer, scope, scope[nodeAccessor].parentNode))[DetachedAwait] = renderer);
1622
- scope[branchAccessor][PendingScopes] = pendingScopes;
1623
- const resolveSync = scope[promiseAccessor];
1624
- if (typeof resolveSync === "function") {
1625
- scope[promiseAccessor] = 0;
1626
- resolveSync();
1627
- }
1628
- };
1629
- }
1630
- function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
1631
- if (!tryBranch) return;
1632
- let awaitCounter = tryBranch[AwaitCounter];
1633
- if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
1634
- placeholderShown.add(pendingEffects);
1635
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1636
- insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1637
- tempDetachBranch(tryBranch);
1638
- }, -1))));
1639
- return awaitCounter;
1640
- }
1641
- function createAwaitCounter(tryBranch, done) {
1642
- const awaitCounter = tryBranch[AwaitCounter] = {
1643
- i: 0,
1644
- c() {
1645
- if (--awaitCounter.i) return 1;
1646
- done();
1647
- queueEffect(tryBranch, runPendingEffects);
1648
- }
1649
- };
1650
- return awaitCounter;
1651
- }
1652
- function runPendingEffects(scope) {
1653
- const effects = scope[PendingEffects];
1654
- if (effects) {
1655
- scope[PendingEffects] = [];
1656
- runEffects(effects, 1);
1657
- }
1658
- }
1659
- function dismissPlaceholder(tryBranch) {
1660
- const placeholderBranch = tryBranch[PlaceholderBranch];
1661
- if (placeholderBranch) {
1662
- tryBranch[PlaceholderBranch] = 0;
1663
- placeholderBranch[StartNode].parentNode.insertBefore(tryBranch[StartNode].parentNode, placeholderBranch[StartNode]);
1664
- removeAndDestroyBranch(placeholderBranch);
1665
- }
1666
- }
1667
- function _try(nodeAccessor, template, walks, setup) {
1668
- const branchAccessor = BranchScopes$1 + nodeAccessor;
1669
- const renderer = _content("", template, walks, setup)();
1670
- return (scope, input) => {
1671
- if (!scope[branchAccessor]) setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1672
- const branch = scope[branchAccessor];
1673
- if (branch) {
1674
- branch[BranchAccessor] = nodeAccessor;
1675
- branch[CatchContent] = input.catch && (normalizeDynamicRenderer(input.catch) || 0);
1676
- branch[PlaceholderContent] = normalizeDynamicRenderer(input.placeholder);
1677
- }
1678
- };
1679
- }
1680
- function renderCatch(scope, error) {
1681
- const tryWithCatch = findBranchWithKey(scope, CatchContent);
1682
- if (!tryWithCatch) throw error;
1683
- else {
1684
- const owner = tryWithCatch["_"];
1685
- const placeholderBranch = tryWithCatch[PlaceholderBranch];
1686
- if (placeholderBranch) {
1687
- if (tryWithCatch["#AwaitCounter"]) tryWithCatch[AwaitCounter].i = 0;
1688
- owner[BranchScopes$1 + tryWithCatch[BranchAccessor]] = placeholderBranch;
1689
- destroyBranch(tryWithCatch);
1690
- }
1691
- caughtError.add(pendingEffects);
1692
- setConditionalRenderer(owner, tryWithCatch[BranchAccessor], tryWithCatch[CatchContent], createAndSetupBranch);
1693
- tryWithCatch[CatchContent]?.[Params]?.(owner[BranchScopes$1 + tryWithCatch[BranchAccessor]], [error]);
1694
- }
1695
- }
1696
- function _if(nodeAccessor, ...branchesArgs) {
1697
- const branchAccessor = ConditionalRenderer + nodeAccessor;
1698
- const branches = [];
1699
- let i = 0;
1700
- while (i < branchesArgs.length) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
1701
- enableBranches();
1702
- return (scope, newBranch) => {
1703
- if (newBranch !== (scope[branchAccessor] ?? (scope["BranchScopes:" + nodeAccessor] && 0))) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
1704
- };
1705
- }
1706
- function _show(nodeAccessor, startNodeAccessor, endNodeAccessor) {
1707
- const rangeAccessor = BranchScopes$1 + nodeAccessor;
1708
- enableBranches();
1709
- return (scope, display) => {
1710
- const referenceNode = scope[nodeAccessor];
1711
- const onlyChild = referenceNode.nodeType === 1;
1712
- const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
1713
- let range = scope[rangeAccessor];
1714
- if (!range) {
1715
- range = scope[rangeAccessor] = {};
1716
- range[StartNode] = onlyChild ? parentNode.firstChild : scope[startNodeAccessor];
1717
- range[EndNode] = onlyChild ? parentNode.lastChild : endNodeAccessor === void 0 ? referenceNode.previousSibling : scope[endNodeAccessor];
1718
- }
1719
- let startNode = range[StartNode];
1720
- if (range["#Id"] && startNode === range["#EndNode"] && startNode.tagName === "T") {
1721
- const wrapper = startNode;
1722
- if (!wrapper.firstChild) wrapper.appendChild(new Text());
1723
- range = scope[rangeAccessor] = {};
1724
- range[StartNode] = startNode = wrapper.firstChild;
1725
- range[EndNode] = wrapper.lastChild;
1726
- wrapper.replaceWith(...wrapper.childNodes);
1727
- }
1728
- const inDom = onlyChild ? !!parentNode.firstChild : startNode.parentNode === parentNode;
1729
- if (display) {
1730
- if (!inDom) insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode);
1731
- } else if (inDom) {
1732
- if (onlyChild) {
1733
- range[StartNode] = parentNode.firstChild;
1734
- range[EndNode] = parentNode.lastChild;
1735
- }
1736
- tempDetachBranch(range);
1737
- }
1738
- };
1739
- }
1740
- function patchDynamicTag(fn) {
1741
- _dynamic_tag = fn(_dynamic_tag);
1742
- }
1743
- let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1744
- const childScopeAccessor = BranchScopes$1 + nodeAccessor;
1745
- const rendererAccessor = ConditionalRenderer + nodeAccessor;
1746
- enableBranches();
1747
- return (scope, newRenderer, getInput) => {
1748
- const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1749
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.["id"] || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1750
- setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
1751
- if (getTagVar) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1752
- if (typeof normalizedRenderer === "string") {
1753
- if (getContent) {
1754
- const content = getContent(scope);
1755
- setConditionalRenderer(scope[childScopeAccessor], `#${normalizedRenderer}/0`, content, createAndSetupBranch);
1756
- if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${normalizedRenderer}/0`]);
1757
- }
1758
- } else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer[Owner], normalizedRenderer[Accessor], scope[childScopeAccessor]);
1759
- }
1760
- if (normalizedRenderer) {
1761
- const childScope = scope[childScopeAccessor];
1762
- const args = getInput?.();
1763
- if (typeof normalizedRenderer === "string") {
1764
- const nodeAccessor = `#${normalizedRenderer}/0`;
1765
- (getContent ? _attrs : _attrs_content)(childScope, nodeAccessor, (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope[nodeAccessor].tagName]);
1766
- if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
1767
- } else {
1768
- for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
1769
- if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
1770
- else {
1771
- const inputWithContent = getContent ? {
1772
- ...args,
1773
- content: getContent(scope)
1774
- } : args || {};
1775
- normalizedRenderer[Params](childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
1776
- }
1777
- }
1778
- }
1779
- };
1780
- };
1781
- function _dynamic_tag_content(nodeAccessor) {
1782
- const childScopeAccessor = BranchScopes$1 + nodeAccessor;
1783
- const rendererAccessor = ConditionalRenderer + nodeAccessor;
1784
- enableBranches();
1785
- return (scope, renderer) => {
1786
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.["id"] || renderer)) {
1787
- setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1788
- if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1789
- }
1790
- if (renderer) for (const accessor in renderer[LocalClosures]) renderer[LocalClosures][accessor](scope[childScopeAccessor], renderer[LocalClosureValues][accessor]);
1791
- };
1792
- }
1793
- function _resume_dynamic_tag() {
1794
- _resume(DYNAMIC_TAG_SCRIPT_REGISTER_ID, dynamicTagScript);
1795
- }
1796
- function dynamicTagScript(branch) {
1797
- _attrs_script(branch, `#${branch[Renderer]}/0`);
1798
- }
1799
- function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
1800
- const referenceNode = scope[nodeAccessor];
1801
- const prevBranch = scope[BranchScopes$1 + nodeAccessor];
1802
- const parentNode = referenceNode.nodeType > 1 ? (prevBranch?.["#StartNode"] || referenceNode).parentNode : referenceNode;
1803
- const newBranch = scope[BranchScopes$1 + nodeAccessor] = newRenderer && createBranch(scope["$global"], newRenderer, scope, parentNode);
1804
- if (referenceNode === parentNode) {
1805
- if (prevBranch) {
1806
- destroyBranch(prevBranch);
1807
- referenceNode.textContent = "";
1808
- }
1809
- if (newBranch) insertBranchBefore(newBranch, parentNode, null);
1810
- } else if (prevBranch) {
1811
- if (newBranch) insertBranchBefore(newBranch, parentNode, prevBranch[StartNode]);
1812
- else parentNode.insertBefore(referenceNode, prevBranch[StartNode]);
1813
- removeAndDestroyBranch(prevBranch);
1814
- } else if (newBranch) {
1815
- insertBranchBefore(newBranch, parentNode, referenceNode);
1816
- referenceNode.remove();
1817
- }
1818
- }
1819
- const _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
1820
- if (typeof by === "string") forOf(all, (item, i) => cb(item[by], [item, i]));
1821
- else forOf(all, (item, i) => cb(by(item, i), [item, i]));
1822
- });
1823
- const _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value])));
1824
- const _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v])));
1825
- const _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v])));
1826
- /* @__NO_SIDE_EFFECTS__ */
1827
- function loop(forEach) {
1828
- return (nodeAccessor, template, walks, setup, params) => {
1829
- const scopesAccessor = BranchScopes$1 + nodeAccessor;
1830
- const keyedScopesAccessor = KeyedScopes + nodeAccessor;
1831
- const renderer = _content("", template, walks, setup)();
1832
- enableBranches();
1833
- return (scope, value) => {
1834
- const referenceNode = scope[nodeAccessor];
1835
- const oldScopes = toArray(scope[scopesAccessor]);
1836
- const newScopes = scope[scopesAccessor] = [];
1837
- scope[keyedScopesAccessor] = null;
1838
- const oldLen = oldScopes.length;
1839
- const parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.["#StartNode"].parentNode : referenceNode;
1840
- let oldScopesByKey;
1841
- let hasPotentialMoves;
1842
- let start = 0;
1843
- var seenKeys = /* @__PURE__ */ new Set();
1844
- forEach(value, (key, args) => {
1845
- assertValidLoopKey(key, seenKeys);
1846
- const i = newScopes.length;
1847
- const oldScope = oldScopes[i];
1848
- let branch = oldLen && (oldScopesByKey || key !== (oldScope?.["#LoopKey"] ?? i) ? (oldScopesByKey ||= oldScopes.reduce((map, scope, j) => j < i ? map : (scope["#LoopIndex"] = j, map.set(scope["#LoopKey"] ?? j, scope)), /* @__PURE__ */ new Map())).get(key) : oldScope && (start++, oldScope));
1849
- if (branch) {
1850
- hasPotentialMoves = true;
1851
- oldScopesByKey?.delete(key);
1852
- } else branch = createAndSetupBranch(scope[Global], renderer, scope, parentNode);
1853
- branch[LoopKey] = key;
1854
- newScopes.push(branch);
1855
- params?.(branch, args);
1856
- });
1857
- const newLen = newScopes.length;
1858
- const hasSiblings = referenceNode !== parentNode;
1859
- let afterReference = null;
1860
- let oldEnd = oldLen - 1;
1861
- let newEnd = newLen - 1;
1862
- if (hasSiblings) {
1863
- if (oldLen) {
1864
- afterReference = oldScopes[oldEnd][EndNode].nextSibling;
1865
- if (!newLen) parentNode.insertBefore(referenceNode, afterReference);
1866
- } else if (newLen) {
1867
- afterReference = referenceNode.nextSibling;
1868
- referenceNode.remove();
1869
- }
1870
- }
1871
- if (!hasPotentialMoves) {
1872
- if (oldLen) {
1873
- oldScopes.forEach(hasSiblings ? removeAndDestroyBranch : destroyBranch);
1874
- if (!hasSiblings) parentNode.textContent = "";
1875
- }
1876
- for (const newScope of newScopes) insertBranchBefore(newScope, parentNode, afterReference);
1877
- return;
1878
- }
1879
- if (oldScopesByKey) oldScopesByKey.forEach(removeAndDestroyBranch);
1880
- else for (let i = newLen; i < oldLen; i++) removeAndDestroyBranch(oldScopes[i]);
1881
- while (oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]) {
1882
- oldEnd--;
1883
- newEnd--;
1884
- }
1885
- if (oldEnd + 1 < oldLen) afterReference = oldScopes[oldEnd + 1][StartNode];
1886
- if (start > oldEnd || start > newEnd) {
1887
- for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
1888
- return;
1889
- }
1890
- const diffLen = newEnd - start + 1;
1891
- const sources = new Array(diffLen);
1892
- const pred = new Array(diffLen);
1893
- const tails = [];
1894
- let tail = -1;
1895
- let lo;
1896
- let hi;
1897
- let mid;
1898
- for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
1899
- for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
1900
- if (~tail) pred[i] = tails[tail];
1901
- tails[++tail] = i;
1902
- } else {
1903
- lo = 0;
1904
- hi = tail;
1905
- while (lo < hi) {
1906
- mid = (lo + hi) / 2 | 0;
1907
- if (sources[tails[mid]] < sources[i]) lo = mid + 1;
1908
- else hi = mid;
1909
- }
1910
- if (sources[i] < sources[tails[lo]]) {
1911
- if (lo > 0) pred[i] = tails[lo - 1];
1912
- tails[lo] = i;
1913
- }
1914
- }
1915
- hi = tails[tail];
1916
- lo = tail + 1;
1917
- while (lo-- > 0) {
1918
- tails[lo] = hi;
1919
- hi = pred[hi];
1920
- }
1921
- for (let i = diffLen; i--;) {
1922
- if (~tail && i === tails[tail]) tail--;
1923
- else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
1924
- afterReference = newScopes[start + i][StartNode];
1925
- }
1926
- };
1927
- };
1928
- }
1929
- function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1930
- if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
1931
- const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
1932
- if (typeof tagNameOrRenderer === "string") branch[`#${tagNameOrRenderer}/0`] = branch[StartNode] = branch[EndNode] = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer);
1933
- else setupBranch(tagNameOrRenderer, branch);
1934
- return branch;
1935
- }
1936
- function bySecondArg(_item, index) {
1937
- return index;
1938
- }
1939
- function byFirstArg(name) {
1940
- return name;
1941
- }
1942
- //#endregion
1943
- //#region src/dom/queue.ts
1944
- let rendering;
1945
- let runId = 2;
1946
- const caughtError = /* @__PURE__ */ new WeakSet();
1947
- const placeholderShown = /* @__PURE__ */ new WeakSet();
1948
- let pendingEffects = [];
1949
- let pendingRenders = [];
1950
- const scopeKeyOffset = 1e6;
1951
- function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
1952
- let render;
1953
- if (signalKey >= 0 && (render = scope[signalKey])) {
1954
- render[Value] = value;
1955
- if (render["gen"] === runId || catchEnabled && render["pending"]) return;
1956
- render["gen"] = runId;
1957
- } else {
1958
- render = {
1959
- ["key"]: scopeKey * scopeKeyOffset + signalKey,
1960
- [Scope]: scope,
1961
- [Signal]: signal,
1962
- [Value]: value,
1963
- ["gen"]: runId
1964
- };
1965
- if (signalKey >= 0) scope[signalKey] = render;
1966
- }
1967
- queuePendingRender(render);
1968
- }
1969
- function queuePendingRender(render) {
1970
- let i = pendingRenders.push(render) - 1;
1971
- while (i) {
1972
- const parentIndex = i - 1 >> 1;
1973
- const parent = pendingRenders[parentIndex];
1974
- if (render["key"] - parent["key"] >= 0) break;
1975
- pendingRenders[i] = parent;
1976
- i = parentIndex;
1977
- }
1978
- pendingRenders[i] = render;
1979
- }
1980
- function queueEffect(scope, fn) {
1981
- pendingEffects.push(fn, scope);
1982
- }
1983
- function run() {
1984
- const effects = pendingEffects;
1985
- try {
1986
- rendering = 1;
1987
- runRenders();
1988
- } finally {
1989
- runId++;
1990
- rendering = 0;
1991
- pendingRenders = [];
1992
- pendingEffects = [];
1993
- }
1994
- runEffects(effects);
1995
- }
1996
- function queueAsyncRender(scope, signal, value) {
1997
- queueRender(scope, signal, -1, value);
1998
- queueMicrotask(run);
1999
- }
2000
- function prepareEffects(fn) {
2001
- const prevRenders = pendingRenders;
2002
- const prevEffects = pendingEffects;
2003
- const preparedEffects = pendingEffects = [];
2004
- pendingRenders = [];
2005
- try {
2006
- rendering = 1;
2007
- fn();
2008
- runRenders();
2009
- } finally {
2010
- runId++;
2011
- rendering = 0;
2012
- pendingRenders = prevRenders;
2013
- pendingEffects = prevEffects;
2014
- }
2015
- return preparedEffects;
2016
- }
2017
- let runEffects = ((effects) => {
2018
- for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
2019
- });
2020
- function runRenders() {
2021
- while (pendingRenders.length) {
2022
- const render = pendingRenders[0];
2023
- const item = pendingRenders.pop();
2024
- if (render !== item) {
2025
- let i = 0;
2026
- const mid = pendingRenders.length >> 1;
2027
- const key = (pendingRenders[0] = item)["key"];
2028
- while (i < mid) {
2029
- let bestChild = (i << 1) + 1;
2030
- const right = bestChild + 1;
2031
- if (right < pendingRenders.length && pendingRenders[right]["key"] - pendingRenders[bestChild]["key"] < 0) bestChild = right;
2032
- if (pendingRenders[bestChild]["key"] - key >= 0) break;
2033
- else {
2034
- pendingRenders[i] = pendingRenders[bestChild];
2035
- i = bestChild;
2036
- }
2037
- }
2038
- pendingRenders[i] = item;
2039
- }
2040
- runRender(render);
2041
- }
2042
- }
2043
- let runRender = (render) => render[Signal](render[Scope], render[Value]);
2044
- function skipDestroyedRenders() {
2045
- runRender = ((runRender) => (render) => {
2046
- if (render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) runRender(render);
2047
- })(runRender);
2048
- }
2049
- let catchEnabled;
2050
- function _enable_catch() {
2051
- if (!catchEnabled) {
2052
- catchEnabled = 1;
2053
- enableBranches();
2054
- const handlePendingTry = (fn, scope, branch) => {
2055
- while (branch) {
2056
- if (branch["#AwaitCounter"]?.i) return (branch[PendingEffects] ||= []).push(fn, scope);
2057
- branch = branch[ParentBranch];
2058
- }
2059
- };
2060
- runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
2061
- if (checkPending || caughtError.has(effects)) {
2062
- let i = 0;
2063
- let fn;
2064
- let scope;
2065
- let branch;
2066
- for (; i < effects.length;) {
2067
- fn = effects[i++];
2068
- scope = effects[i++];
2069
- if ((branch = scope["#ClosestBranch"])?.["#Gen"] !== 0 && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
2070
- }
2071
- } else runEffects(effects);
2072
- })(runEffects);
2073
- runRender = ((runRender) => (render) => {
2074
- try {
2075
- let branch = render[Scope][ClosestBranch];
2076
- while (branch) {
2077
- if (branch["#PendingRenders"]) {
2078
- render[Pending] = 1;
2079
- return branch[PendingRenders].push(render);
2080
- }
2081
- branch = branch[ParentBranch];
2082
- }
2083
- render[Pending] = 0;
2084
- runRender(render);
2085
- } catch (error) {
2086
- renderCatch(render[Scope], error);
2087
- }
2088
- })(runRender);
2089
- }
2090
- }
2091
- //#endregion
2092
- //#region src/dom/abort-signal.ts
2093
- function $signalReset(scope, id) {
2094
- const ctrl = scope[AbortControllers]?.[id];
2095
- if (ctrl) {
2096
- scope[AbortControllers][id] = void 0;
2097
- if (rendering) queueEffect(ctrl, abort);
2098
- else abort(ctrl);
2099
- }
2100
- }
2101
- function $signal(scope, id) {
2102
- trackCleanup(scope);
2103
- return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
2104
- }
2105
- /** Enrols `scope` with its branch so destroying the branch cleans it up. */
2106
- function trackCleanup(scope, subscribers) {
2107
- const branch = scope[ClosestBranch];
2108
- if (branch) (branch[AbortScopes] ||= /* @__PURE__ */ new Set()).add(scope);
2109
- if (subscribers) (scope[Subscriptions] ||= []).push(subscribers);
2110
- }
2111
- function abort(ctrl) {
2112
- ctrl.abort();
2113
- }
27
+ const Signal = "signal";
2114
28
  //#endregion
2115
29
  //#region src/common/compat-meta.ts
2116
30
  const SET_SCOPE_REGISTER_ID = "$compat_setScope";
@@ -2127,18 +41,18 @@ const getRenderScopes = ($global) => {
2127
41
  return scopes;
2128
42
  };
2129
43
  const compat = {
2130
- patchDynamicTag,
2131
- queueEffect,
44
+ patchDynamicTag: require_control_flow.patchDynamicTag,
45
+ queueEffect: require_control_flow.queueEffect,
2132
46
  init(warp10Noop) {
2133
- _resume(SET_SCOPE_REGISTER_ID, (scope) => {
2134
- getRenderScopes(scope[Global])[scope["#Id"]] = scope;
47
+ require_control_flow._resume(SET_SCOPE_REGISTER_ID, (scope) => {
48
+ getRenderScopes(scope[require_control_flow.Global])[scope["#Id"]] = scope;
2135
49
  if (scope.m5c) classIdToBranch.set(scope.m5c, scope);
2136
50
  if (classEventResolver) for (const key in scope) {
2137
51
  const resolved = classEventResolver(scope[key], scope);
2138
52
  if (resolved !== scope[key]) scope[key] = resolved;
2139
53
  }
2140
54
  });
2141
- _resume(RENDER_BODY_ID, warp10Noop);
55
+ require_control_flow._resume(RENDER_BODY_ID, warp10Noop);
2142
56
  },
2143
57
  setClassEventResolver(fn) {
2144
58
  classEventResolver = fn;
@@ -2150,34 +64,34 @@ const compat = {
2150
64
  renderer["id"] = id;
2151
65
  },
2152
66
  isRenderer(renderer) {
2153
- return renderer[Clone];
67
+ return renderer[require_control_flow.Clone];
2154
68
  },
2155
69
  getStartNode(branch) {
2156
- return branch[StartNode];
70
+ return branch[require_control_flow.StartNode];
2157
71
  },
2158
72
  getEndNode(branch) {
2159
- return branch[EndNode];
73
+ return branch[require_control_flow.EndNode];
2160
74
  },
2161
75
  setScopeNodes(branch, startNode, endNode) {
2162
- branch[StartNode] = startNode;
2163
- branch[EndNode] = endNode;
76
+ branch[require_control_flow.StartNode] = startNode;
77
+ branch[require_control_flow.EndNode] = endNode;
2164
78
  },
2165
79
  runComponentEffects() {
2166
- if (this.effects) runEffects(this.effects);
80
+ if (this.effects) require_control_flow.runEffects(this.effects);
2167
81
  },
2168
82
  runComponentDestroy() {
2169
- if (this.scope) destroyBranch(this.scope);
83
+ if (this.scope) require_control_flow.destroyBranch(this.scope);
2170
84
  },
2171
85
  resolveRegistered(value, $global) {
2172
- if (Array.isArray(value) && typeof value[0] === "string") return getRegisteredWithScope(value[0], getRenderScopes($global)?.[value[1]]);
86
+ if (Array.isArray(value) && typeof value[0] === "string") return require_control_flow.getRegisteredWithScope(value[0], getRenderScopes($global)?.[value[1]]);
2173
87
  return value;
2174
88
  },
2175
89
  createRenderer(params, clone) {
2176
- const renderer = _content("", 0, 0, 0, params)();
2177
- renderer[Clone] = (branch) => {
90
+ const renderer = require_control_flow._content("", 0, 0, 0, params)();
91
+ renderer[require_control_flow.Clone] = (branch) => {
2178
92
  const cloned = clone();
2179
- branch[StartNode] = cloned.startNode;
2180
- branch[EndNode] = cloned.endNode;
93
+ branch[require_control_flow.StartNode] = cloned.startNode;
94
+ branch[require_control_flow.EndNode] = cloned.endNode;
2181
95
  };
2182
96
  return renderer;
2183
97
  },
@@ -2193,26 +107,26 @@ const compat = {
2193
107
  const normalizedInput = args[0] = {};
2194
108
  for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
2195
109
  }
2196
- component.effects = prepareEffects(() => {
110
+ component.effects = require_control_flow.prepareEffects(() => {
2197
111
  if (!branch) {
2198
112
  created = 1;
2199
- branch = component.scope = createAndSetupBranch(out.global, renderer, renderer[Owner], document.body);
113
+ branch = component.scope = require_control_flow.createAndSetupBranch(out.global, renderer, renderer[require_control_flow.Owner], document.body);
2200
114
  }
2201
- renderer[Params]?.(branch, renderer._ ? args[0] : args);
115
+ renderer[require_control_flow.Params]?.(branch, renderer._ ? args[0] : args);
2202
116
  });
2203
- if (created) return toInsertNode(branch[StartNode], branch[EndNode]);
117
+ if (created) return require_control_flow.toInsertNode(branch[require_control_flow.StartNode], branch[require_control_flow.EndNode]);
2204
118
  }
2205
119
  };
2206
120
  //#endregion
2207
121
  //#region src/dom/template.ts
2208
122
  const _template = (id, template, walks, setup, inputSignal) => {
2209
- const renderer = _content(id, template, walks, setup, inputSignal)();
123
+ const renderer = require_control_flow._content(id, template, walks, setup, inputSignal)();
2210
124
  renderer.mount = mount;
2211
125
  renderer._ = renderer;
2212
126
  renderer.render = () => {
2213
127
  throw new Error(`render() is not implemented for the DOM compilation of a Marko template`);
2214
128
  };
2215
- return _resume(id, renderer);
129
+ return require_control_flow._resume(id, renderer);
2216
130
  };
2217
131
  function mount(input = {}, reference, position) {
2218
132
  let branch;
@@ -2246,92 +160,90 @@ function mount(input = {}, reference, position) {
2246
160
  break;
2247
161
  }
2248
162
  let curValue;
2249
- const args = this[Params];
2250
- const effects = prepareEffects(() => {
2251
- branch = createBranch($global, this, void 0, parentNode);
2252
- branch[TagVariable] = (newValue) => {
163
+ const args = this[require_control_flow.Params];
164
+ const effects = require_control_flow.prepareEffects(() => {
165
+ branch = require_control_flow.createBranch($global, this, void 0, parentNode);
166
+ branch[require_control_flow.TagVariable] = (newValue) => {
2253
167
  curValue = newValue;
2254
168
  };
2255
- this[Setup]?.(branch);
169
+ this[require_control_flow.Setup]?.(branch);
2256
170
  args?.(branch, input);
2257
171
  });
2258
- insertChildNodes(parentNode, nextSibling, branch[StartNode], branch[EndNode]);
2259
- runEffects(effects);
172
+ require_control_flow.insertChildNodes(parentNode, nextSibling, branch[require_control_flow.StartNode], branch[require_control_flow.EndNode]);
173
+ require_control_flow.runEffects(effects);
2260
174
  return {
2261
175
  get value() {
2262
176
  return curValue;
2263
177
  },
2264
178
  set value(newValue) {
2265
- _var_change(branch, newValue);
179
+ require_control_flow._var_change(branch, newValue);
2266
180
  },
2267
181
  update(newInput = {}) {
2268
182
  if (args) {
2269
183
  if (newInput.$global) ({$global, ...newInput} = newInput);
2270
- runEffects(prepareEffects(() => {
184
+ require_control_flow.runEffects(require_control_flow.prepareEffects(() => {
2271
185
  args(branch, newInput);
2272
186
  }));
2273
187
  }
2274
188
  },
2275
189
  destroy() {
2276
- removeAndDestroyBranch(branch);
190
+ require_control_flow.removeAndDestroyBranch(branch);
2277
191
  }
2278
192
  };
2279
193
  }
2280
194
  //#endregion
2281
195
  //#region src/dom/load.ts
2282
196
  function _load_template(id, load) {
2283
- _enable_catch();
2284
197
  let pending;
2285
198
  const lazyTemplate = _template(id, 0, 0, (branch) => {
2286
- const awaitCounter = addAwaitCounter(branch);
2287
- branch[Load] ||= /* @__PURE__ */ new Map();
199
+ const awaitCounter = require_control_flow.addAwaitCounter(branch);
200
+ branch[require_control_flow.Load] ||= /* @__PURE__ */ new Map();
2288
201
  (pending ||= load()).then((renderer) => {
2289
202
  Object.assign(lazyTemplate, renderer);
2290
- queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[StartNode], awaitCounter));
203
+ require_control_flow.queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[require_control_flow.StartNode], awaitCounter));
2291
204
  }, loadFailed(branch, awaitCounter));
2292
- }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r[Params] }))));
205
+ }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r[require_control_flow.Params] }))));
2293
206
  return lazyTemplate;
2294
207
  }
2295
208
  function _load_setup(nodeAccessor, childScopeAccessor, load) {
2296
209
  let pending;
2297
210
  let renderer;
2298
- _enable_catch();
2299
211
  return (owner) => {
2300
212
  const child = owner[childScopeAccessor];
2301
213
  if (renderer) insertLoaded(renderer, child, owner[nodeAccessor]);
2302
214
  else {
2303
- const awaitCounter = addAwaitCounter(owner);
2304
- child[Load] ||= /* @__PURE__ */ new Map();
215
+ const awaitCounter = require_control_flow.addAwaitCounter(owner);
216
+ child[require_control_flow.Load] ||= /* @__PURE__ */ new Map();
2305
217
  (pending ||= load()).then((mod) => {
2306
- renderer = _content("", ...mod._)();
2307
- queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
218
+ renderer = require_control_flow._content("", ...mod._)();
219
+ require_control_flow.queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
2308
220
  }, loadFailed(child, awaitCounter));
2309
221
  }
2310
222
  };
2311
223
  }
2312
224
  function insertLoaded(renderer, branch, marker, awaitCounter) {
2313
- const parent = marker.parentNode, values = branch[Load], insert = () => {
2314
- insertBranchBefore(branch, parent, marker);
225
+ const parent = marker.parentNode, values = branch[require_control_flow.Load], insert = () => {
226
+ require_control_flow.insertBranchBefore(branch, parent, marker);
2315
227
  marker.remove();
2316
228
  awaitCounter?.c();
2317
229
  };
2318
230
  let remaining;
2319
- syncGen(branch);
2320
- renderer[Clone](branch, parent.namespaceURI);
2321
- branch[Load] = 0;
231
+ require_control_flow.syncGen(branch);
232
+ renderer[require_control_flow.Clone](branch, parent.namespaceURI);
233
+ branch[require_control_flow.Load] = 0;
2322
234
  if (remaining = values?.size) {
2323
235
  const fail = loadFailed(branch, awaitCounter);
2324
236
  for (const [promise, entry] of values) promise.then((signal) => {
2325
- entry[Signal$1] = signal;
2326
- if (!--remaining) queueAsyncRender(branch, (branch) => {
2327
- syncGen(branch);
2328
- renderer[Setup]?.(branch);
2329
- values.forEach((e) => e[Signal$1]._(branch, e[Value$1]));
237
+ entry[Signal] = signal;
238
+ if (!--remaining) require_control_flow.queueAsyncRender(branch, (branch) => {
239
+ require_control_flow.syncGen(branch);
240
+ renderer[require_control_flow.Setup]?.(branch);
241
+ values.forEach((e) => e[Signal]._(branch, e[Value]));
2330
242
  insert();
2331
243
  });
2332
244
  }, (error) => remaining > 0 && (remaining = 0, fail(error)));
2333
245
  } else {
2334
- setupBranch(renderer, branch);
246
+ require_control_flow.setupBranch(renderer, branch);
2335
247
  insert();
2336
248
  }
2337
249
  }
@@ -2339,7 +251,7 @@ function loadFailed(scope, awaitCounter) {
2339
251
  return (error) => {
2340
252
  if (awaitCounter) if (awaitCounter.m) awaitCounter.i = 0;
2341
253
  else awaitCounter.c();
2342
- queueAsyncRender(scope, renderCatch, error);
254
+ require_control_flow.queueAsyncRender(scope, require_control_flow.renderCatch, error);
2343
255
  };
2344
256
  }
2345
257
  function _load_signal(load) {
@@ -2347,9 +259,9 @@ function _load_signal(load) {
2347
259
  let signal;
2348
260
  return (scope, value) => {
2349
261
  pending ||= load();
2350
- if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope[Load] ||= /* @__PURE__ */ new Map()).set(pending, { [Value$1]: value });
262
+ if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === require_control_flow.runId) (scope[require_control_flow.Load] ||= /* @__PURE__ */ new Map()).set(pending, { [Value]: value });
2351
263
  else if (signal) signal(scope, value);
2352
- else pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
264
+ else pending.then((mod) => require_control_flow.queueAsyncRender(scope, signal = mod._, value), () => 0);
2353
265
  };
2354
266
  }
2355
267
  function _load_visible_trigger(selector, options) {
@@ -2379,91 +291,85 @@ function getSelectorOrResolve(selector, resolve) {
2379
291
  return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
2380
292
  }
2381
293
  //#endregion
2382
- exports.$signal = $signal;
2383
- exports.$signalReset = $signalReset;
2384
- exports._assert_hoist = _assert_hoist;
2385
- exports._assert_init = _assert_init;
2386
- exports._attr = _attr;
2387
- exports._attr_class = _attr_class;
2388
- exports._attr_class_item = _attr_class_item;
2389
- exports._attr_class_items = _attr_class_items;
2390
- exports._attr_content = _attr_content;
2391
- exports._attr_details_open = _attr_details_or_dialog_open;
2392
- exports._attr_details_open_default = _attr_details_or_dialog_open_default;
2393
- exports._attr_details_open_script = _attr_details_or_dialog_open_script;
2394
- exports._attr_dialog_open = _attr_details_or_dialog_open;
2395
- exports._attr_dialog_open_default = _attr_details_or_dialog_open_default;
2396
- exports._attr_dialog_open_script = _attr_details_or_dialog_open_script;
2397
- exports._attr_input_checked = _attr_input_checked;
2398
- exports._attr_input_checkedValue = _attr_input_checkedValue;
2399
- exports._attr_input_checkedValue_default = _attr_input_checkedValue_default;
2400
- exports._attr_input_checkedValue_script = _attr_input_checkedValue_script;
2401
- exports._attr_input_checked_default = _attr_input_checked_default;
2402
- exports._attr_input_checked_script = _attr_input_checked_script;
2403
- exports._attr_input_value = _attr_input_value;
2404
- exports._attr_input_value_attribute_default = _attr_input_value_attribute_default;
2405
- exports._attr_input_value_default = _attr_input_value_default;
2406
- exports._attr_input_value_dynamic_default = _attr_input_value_dynamic_default;
2407
- exports._attr_input_value_script = _attr_input_value_script;
2408
- exports._attr_nonce = _attr_nonce;
2409
- exports._attr_select_value = _attr_select_value;
2410
- exports._attr_select_value_default = _attr_select_value_default;
2411
- exports._attr_select_value_script = _attr_select_value_script;
2412
- exports._attr_style = _attr_style;
2413
- exports._attr_style_item = _attr_style_item;
2414
- exports._attr_style_items = _attr_style_items;
2415
- exports._attr_textarea_value = _attr_input_value;
2416
- exports._attr_textarea_value_default = _attr_input_value_default;
2417
- exports._attr_textarea_value_script = _attr_input_value_script;
2418
- exports._attrs = _attrs;
2419
- exports._attrs_content = _attrs_content;
2420
- exports._attrs_partial = _attrs_partial;
2421
- exports._attrs_partial_content = _attrs_partial_content;
2422
- exports._attrs_script = _attrs_script;
2423
- exports._await_content = _await_content;
2424
- exports._await_promise = _await_promise;
2425
- exports._call = _call;
2426
- exports._child_setup = _child_setup;
2427
- exports._closure = _closure;
2428
- exports._closure_get = _closure_get;
2429
- exports._const = _const;
2430
- exports._content = _content;
2431
- exports._content_closures = _content_closures;
2432
- exports._content_resume = _content_resume;
2433
- exports._controllable_input = _controllable_input;
2434
- exports._controllable_open = _controllable_open;
2435
- exports._controllable_select = _controllable_select;
2436
- exports._controllable_textarea = _controllable_textarea;
294
+ exports.$signal = require_control_flow.$signal;
295
+ exports.$signalReset = require_control_flow.$signalReset;
296
+ exports._assert_hoist = require_control_flow._assert_hoist;
297
+ exports._assert_init = require_control_flow._assert_init;
298
+ exports._attr = require_control_flow._attr;
299
+ exports._attr_class = require_control_flow._attr_class;
300
+ exports._attr_class_item = require_control_flow._attr_class_item;
301
+ exports._attr_class_items = require_control_flow._attr_class_items;
302
+ exports._attr_content = require_control_flow._attr_content;
303
+ exports._attr_details_open = require_control_flow._attr_details_or_dialog_open;
304
+ exports._attr_details_open_default = require_control_flow._attr_details_or_dialog_open_default;
305
+ exports._attr_details_open_script = require_control_flow._attr_details_or_dialog_open_script;
306
+ exports._attr_dialog_open = require_control_flow._attr_details_or_dialog_open;
307
+ exports._attr_dialog_open_default = require_control_flow._attr_details_or_dialog_open_default;
308
+ exports._attr_dialog_open_script = require_control_flow._attr_details_or_dialog_open_script;
309
+ exports._attr_input_checked = require_control_flow._attr_input_checked;
310
+ exports._attr_input_checkedValue = require_control_flow._attr_input_checkedValue;
311
+ exports._attr_input_checkedValue_default = require_control_flow._attr_input_checkedValue_default;
312
+ exports._attr_input_checkedValue_script = require_control_flow._attr_input_checkedValue_script;
313
+ exports._attr_input_checked_default = require_control_flow._attr_input_checked_default;
314
+ exports._attr_input_checked_script = require_control_flow._attr_input_checked_script;
315
+ exports._attr_input_value = require_control_flow._attr_input_value;
316
+ exports._attr_input_value_attribute_default = require_control_flow._attr_input_value_attribute_default;
317
+ exports._attr_input_value_default = require_control_flow._attr_input_value_default;
318
+ exports._attr_input_value_dynamic_default = require_control_flow._attr_input_value_dynamic_default;
319
+ exports._attr_input_value_script = require_control_flow._attr_input_value_script;
320
+ exports._attr_nonce = require_control_flow._attr_nonce;
321
+ exports._attr_select_value = require_control_flow._attr_select_value;
322
+ exports._attr_select_value_default = require_control_flow._attr_select_value_default;
323
+ exports._attr_select_value_script = require_control_flow._attr_select_value_script;
324
+ exports._attr_style = require_control_flow._attr_style;
325
+ exports._attr_style_item = require_control_flow._attr_style_item;
326
+ exports._attr_style_items = require_control_flow._attr_style_items;
327
+ exports._attr_textarea_value = require_control_flow._attr_input_value;
328
+ exports._attr_textarea_value_default = require_control_flow._attr_input_value_default;
329
+ exports._attr_textarea_value_script = require_control_flow._attr_input_value_script;
330
+ exports._attrs = require_control_flow._attrs;
331
+ exports._attrs_content = require_control_flow._attrs_content;
332
+ exports._attrs_partial = require_control_flow._attrs_partial;
333
+ exports._attrs_partial_content = require_control_flow._attrs_partial_content;
334
+ exports._attrs_script = require_control_flow._attrs_script;
335
+ exports._await_content = require_control_flow._await_content;
336
+ exports._await_promise = require_control_flow._await_promise;
337
+ exports._call = require_control_flow._call;
338
+ exports._child_setup = require_control_flow._child_setup;
339
+ exports._closure = require_control_flow._closure;
340
+ exports._closure_get = require_control_flow._closure_get;
341
+ exports._const = require_control_flow._const;
342
+ exports._content = require_control_flow._content;
343
+ exports._content_closures = require_control_flow._content_closures;
344
+ exports._content_resume = require_control_flow._content_resume;
345
+ exports._controllable_input = require_control_flow._controllable_input;
346
+ exports._controllable_open = require_control_flow._controllable_open;
347
+ exports._controllable_select = require_control_flow._controllable_select;
348
+ exports._controllable_textarea = require_control_flow._controllable_textarea;
2437
349
  Object.defineProperty(exports, "_dynamic_tag", {
2438
350
  enumerable: true,
2439
351
  get: function() {
2440
- return _dynamic_tag;
352
+ return require_control_flow._dynamic_tag;
2441
353
  }
2442
354
  });
2443
- exports._dynamic_tag_content = _dynamic_tag_content;
2444
- exports._el = _el;
2445
- exports._el_read = _el_read;
2446
- exports._enable_catch = _enable_catch;
2447
- exports._enable_controllable = _enable_controllable;
2448
- exports._enable_controllable_input = _enable_controllable_input;
2449
- exports._enable_controllable_open = _enable_controllable_open;
2450
- exports._enable_controllable_select = _enable_controllable_select;
2451
- exports._enable_controllable_textarea = _enable_controllable_textarea;
2452
- exports._for_closure = _for_closure;
2453
- exports._for_in = _for_in;
2454
- exports._for_of = _for_of;
2455
- exports._for_selector = _for_selector;
2456
- exports._for_to = _for_to;
2457
- exports._for_until = _for_until;
2458
- exports._hoist = _hoist;
2459
- exports._hoist_resume = _hoist_resume;
2460
- exports._html = _html;
2461
- exports._id = _id;
2462
- exports._if = _if;
2463
- exports._if_closure = _if_closure;
2464
- exports._let = _let;
2465
- exports._let_change = _let_change;
2466
- exports._lifecycle = _lifecycle;
355
+ exports._dynamic_tag_content = require_control_flow._dynamic_tag_content;
356
+ exports._el = require_control_flow._el;
357
+ exports._el_read = require_control_flow._el_read;
358
+ exports._for_closure = require_control_flow._for_closure;
359
+ exports._for_in = require_control_flow._for_in;
360
+ exports._for_of = require_control_flow._for_of;
361
+ exports._for_selector = require_control_flow._for_selector;
362
+ exports._for_to = require_control_flow._for_to;
363
+ exports._for_until = require_control_flow._for_until;
364
+ exports._hoist = require_control_flow._hoist;
365
+ exports._hoist_resume = require_control_flow._hoist_resume;
366
+ exports._html = require_control_flow._html;
367
+ exports._id = require_control_flow._id;
368
+ exports._if = require_control_flow._if;
369
+ exports._if_closure = require_control_flow._if_closure;
370
+ exports._let = require_control_flow._let;
371
+ exports._let_change = require_control_flow._let_change;
372
+ exports._lifecycle = require_control_flow._lifecycle;
2467
373
  exports._load_event_trigger = _load_event_trigger;
2468
374
  exports._load_idle_trigger = _load_idle_trigger;
2469
375
  exports._load_media_trigger = _load_media_trigger;
@@ -2472,32 +378,32 @@ exports._load_setup = _load_setup;
2472
378
  exports._load_signal = _load_signal;
2473
379
  exports._load_template = _load_template;
2474
380
  exports._load_visible_trigger = _load_visible_trigger;
2475
- exports._on = _on;
2476
- exports._or = _or;
2477
- exports._resume = _resume;
2478
- exports._resume_dynamic_tag = _resume_dynamic_tag;
2479
- exports._return = _return;
2480
- exports._return_change = _return_change;
2481
- exports._script = _script;
2482
- exports._show = _show;
2483
- exports._style_rule_item = _style_rule_item;
2484
- exports._style_shell = _style_shell;
381
+ exports._on = require_control_flow._on;
382
+ exports._or = require_control_flow._or;
383
+ exports._resume = require_control_flow._resume;
384
+ exports._resume_dynamic_tag = require_control_flow._resume_dynamic_tag;
385
+ exports._return = require_control_flow._return;
386
+ exports._return_change = require_control_flow._return_change;
387
+ exports._script = require_control_flow._script;
388
+ exports._show = require_control_flow._show;
389
+ exports._style_rule_item = require_control_flow._style_rule_item;
390
+ exports._style_shell = require_control_flow._style_shell;
2485
391
  exports._template = _template;
2486
- exports._text = _text;
2487
- exports._text_content = _text_content;
2488
- exports._to_text = _to_text;
2489
- exports._try = _try;
2490
- exports._var = _var;
2491
- exports._var_change = _var_change;
2492
- exports._var_resume = _var_resume;
392
+ exports._text = require_control_flow._text;
393
+ exports._text_content = require_control_flow._text_content;
394
+ exports._to_text = require_control_flow._to_text;
395
+ exports._try = require_control_flow._try;
396
+ exports._var = require_control_flow._var;
397
+ exports._var_change = require_control_flow._var_change;
398
+ exports._var_resume = require_control_flow._var_resume;
2493
399
  exports.attrTag = attrTag;
2494
400
  exports.attrTags = attrTags;
2495
401
  exports.compat = compat;
2496
- exports.forIn = forIn;
2497
- exports.forOf = forOf;
2498
- exports.forTo = forTo;
2499
- exports.forUntil = forUntil;
2500
- exports.init = init;
2501
- exports.initEmbedded = initEmbedded;
2502
- exports.ready = ready;
2503
- exports.run = run;
402
+ exports.forIn = require_control_flow.forIn;
403
+ exports.forOf = require_control_flow.forOf;
404
+ exports.forTo = require_control_flow.forTo;
405
+ exports.forUntil = require_control_flow.forUntil;
406
+ exports.init = require_control_flow.init;
407
+ exports.initEmbedded = require_control_flow.initEmbedded;
408
+ exports.ready = require_control_flow.ready;
409
+ exports.run = require_control_flow.run;