marko 6.0.165 → 6.0.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/html.mjs CHANGED
@@ -1,2353 +1,1773 @@
1
- // src/common/attr-tag.ts
2
- var empty = [], rest = /* @__PURE__ */ Symbol();
1
+ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
+ let str = "", sep = "", part;
3
+ if (val) if (typeof val != "object") str += val;
4
+ else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
+ else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
6
+ return str;
7
+ }, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<\/script/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str, unsafeStyleReg = /<\/style/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, "&gt;") : str, kTouchedIterator = Symbol(), { hasOwnProperty } = {}, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, MutationType = /* @__PURE__ */ function(MutationType) {
8
+ return MutationType[MutationType.call = 0] = "call", MutationType[MutationType.assign = 1] = "assign", MutationType;
9
+ }(MutationType || {}), REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
10
+ let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
11
+ for (let name of Object.getOwnPropertyNames(Symbol)) {
12
+ let symbol = Symbol[name];
13
+ typeof symbol == "symbol" && KNOWN_SYMBOLS.set(symbol, "Symbol." + name);
14
+ }
15
+ return KNOWN_SYMBOLS;
16
+ })(), KNOWN_FUNCTIONS = new Map([
17
+ [AggregateError, "AggregateError"],
18
+ [Array, "Array"],
19
+ [Array.from, "Array.from"],
20
+ [Array.isArray, "Array.isArray"],
21
+ [Array.of, "Array.of"],
22
+ [ArrayBuffer, "ArrayBuffer"],
23
+ [ArrayBuffer.isView, "ArrayBuffer.isView"],
24
+ [Atomics.add, "Atomics.add"],
25
+ [Atomics.and, "Atomics.and"],
26
+ [Atomics.compareExchange, "Atomics.compareExchange"],
27
+ [Atomics.exchange, "Atomics.exchange"],
28
+ [Atomics.isLockFree, "Atomics.isLockFree"],
29
+ [Atomics.load, "Atomics.load"],
30
+ [Atomics.notify, "Atomics.notify"],
31
+ [Atomics.or, "Atomics.or"],
32
+ [Atomics.store, "Atomics.store"],
33
+ [Atomics.sub, "Atomics.sub"],
34
+ [Atomics.wait, "Atomics.wait"],
35
+ [BigInt, "BigInt"],
36
+ [BigInt.asIntN, "BigInt.asIntN"],
37
+ [BigInt.asUintN, "BigInt.asUintN"],
38
+ [BigInt64Array, "BigInt64Array"],
39
+ [BigInt64Array.from, "BigInt64Array.from"],
40
+ [BigInt64Array.of, "BigInt64Array.of"],
41
+ [BigUint64Array, "BigUint64Array"],
42
+ [BigUint64Array.from, "BigUint64Array.from"],
43
+ [BigUint64Array.of, "BigUint64Array.of"],
44
+ [Boolean, "Boolean"],
45
+ [console.assert, "console.assert"],
46
+ [console.clear, "console.clear"],
47
+ [console.count, "console.count"],
48
+ [console.countReset, "console.countReset"],
49
+ [console.debug, "console.debug"],
50
+ [console.dir, "console.dir"],
51
+ [console.dirxml, "console.dirxml"],
52
+ [console.error, "console.error"],
53
+ [console.group, "console.group"],
54
+ [console.groupCollapsed, "console.groupCollapsed"],
55
+ [console.groupEnd, "console.groupEnd"],
56
+ [console.info, "console.info"],
57
+ [console.log, "console.log"],
58
+ [console.table, "console.table"],
59
+ [console.time, "console.time"],
60
+ [console.timeEnd, "console.timeEnd"],
61
+ [console.timeLog, "console.timeLog"],
62
+ [console.timeStamp, "console.timeStamp"],
63
+ [console.trace, "console.trace"],
64
+ [console.warn, "console.warn"],
65
+ [DataView, "DataView"],
66
+ [Date, "Date"],
67
+ [Date.now, "Date.now"],
68
+ [Date.parse, "Date.parse"],
69
+ [Date.UTC, "Date.UTC"],
70
+ [decodeURI, "decodeURI"],
71
+ [decodeURIComponent, "decodeURIComponent"],
72
+ [encodeURI, "encodeURI"],
73
+ [encodeURIComponent, "encodeURIComponent"],
74
+ [Error, "Error"],
75
+ [EvalError, "EvalError"],
76
+ [Float32Array, "Float32Array"],
77
+ [Float32Array.from, "Float32Array.from"],
78
+ [Float32Array.of, "Float32Array.of"],
79
+ [Float64Array, "Float64Array"],
80
+ [Float64Array.from, "Float64Array.from"],
81
+ [Float64Array.of, "Float64Array.of"],
82
+ [Function, "Function"],
83
+ [globalThis.atob, "atob"],
84
+ [globalThis.btoa, "btoa"],
85
+ [globalThis.clearImmediate, "clearImmediate"],
86
+ [globalThis.clearInterval, "clearInterval"],
87
+ [globalThis.clearTimeout, "clearTimeout"],
88
+ [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
89
+ [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
90
+ [globalThis.fetch, "fetch"],
91
+ [globalThis.performance?.now, "performance.now"],
92
+ [globalThis.queueMicrotask, "queueMicrotask"],
93
+ [globalThis.setImmediate, "setImmediate"],
94
+ [globalThis.setInterval, "setInterval"],
95
+ [globalThis.setTimeout, "setTimeout"],
96
+ [globalThis.structuredClone, "structuredClone"],
97
+ [globalThis.URL, "URL"],
98
+ [globalThis.URLSearchParams, "URLSearchParams"],
99
+ [globalThis.WritableStream, "WritableStream"],
100
+ [Int16Array, "Int16Array"],
101
+ [Int16Array.from, "Int16Array.from"],
102
+ [Int16Array.of, "Int16Array.of"],
103
+ [Int32Array, "Int32Array"],
104
+ [Int32Array.from, "Int32Array.from"],
105
+ [Int32Array.of, "Int32Array.of"],
106
+ [Int8Array, "Int8Array"],
107
+ [Int8Array.from, "Int8Array.from"],
108
+ [Int8Array.of, "Int8Array.of"],
109
+ [Intl.Collator, "Intl.Collator"],
110
+ [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
111
+ [Intl.DisplayNames, "Intl.DisplayNames"],
112
+ [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
113
+ [Intl.ListFormat, "Intl.ListFormat"],
114
+ [Intl.Locale, "Intl.Locale"],
115
+ [Intl.NumberFormat, "Intl.NumberFormat"],
116
+ [Intl.PluralRules, "Intl.PluralRules"],
117
+ [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
118
+ [Intl.Segmenter, "Intl.Segmenter"],
119
+ [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
120
+ [isFinite, "isFinite"],
121
+ [isNaN, "isNaN"],
122
+ [JSON.parse, "JSON.parse"],
123
+ [JSON.stringify, "JSON.stringify"],
124
+ [Map, "Map"],
125
+ [Map.groupBy, "Map.groupBy"],
126
+ [Math.abs, "Math.abs"],
127
+ [Math.acos, "Math.acos"],
128
+ [Math.acosh, "Math.acosh"],
129
+ [Math.asin, "Math.asin"],
130
+ [Math.asinh, "Math.asinh"],
131
+ [Math.atan, "Math.atan"],
132
+ [Math.atan2, "Math.atan2"],
133
+ [Math.atanh, "Math.atanh"],
134
+ [Math.cbrt, "Math.cbrt"],
135
+ [Math.ceil, "Math.ceil"],
136
+ [Math.clz32, "Math.clz32"],
137
+ [Math.cos, "Math.cos"],
138
+ [Math.cosh, "Math.cosh"],
139
+ [Math.exp, "Math.exp"],
140
+ [Math.expm1, "Math.expm1"],
141
+ [Math.floor, "Math.floor"],
142
+ [Math.fround, "Math.fround"],
143
+ [Math.hypot, "Math.hypot"],
144
+ [Math.imul, "Math.imul"],
145
+ [Math.log, "Math.log"],
146
+ [Math.log10, "Math.log10"],
147
+ [Math.log1p, "Math.log1p"],
148
+ [Math.log2, "Math.log2"],
149
+ [Math.max, "Math.max"],
150
+ [Math.min, "Math.min"],
151
+ [Math.pow, "Math.pow"],
152
+ [Math.random, "Math.random"],
153
+ [Math.round, "Math.round"],
154
+ [Math.sign, "Math.sign"],
155
+ [Math.sin, "Math.sin"],
156
+ [Math.sinh, "Math.sinh"],
157
+ [Math.sqrt, "Math.sqrt"],
158
+ [Math.tan, "Math.tan"],
159
+ [Math.tanh, "Math.tanh"],
160
+ [Math.trunc, "Math.trunc"],
161
+ [Number, "Number"],
162
+ [Number.isFinite, "Number.isFinite"],
163
+ [Number.isInteger, "Number.isInteger"],
164
+ [Number.isNaN, "Number.isNaN"],
165
+ [Number.isSafeInteger, "Number.isSafeInteger"],
166
+ [Number.parseFloat, "Number.parseFloat"],
167
+ [Number.parseInt, "Number.parseInt"],
168
+ [Object, "Object"],
169
+ [Object.assign, "Object.assign"],
170
+ [Object.create, "Object.create"],
171
+ [Object.defineProperties, "Object.defineProperties"],
172
+ [Object.defineProperty, "Object.defineProperty"],
173
+ [Object.entries, "Object.entries"],
174
+ [Object.freeze, "Object.freeze"],
175
+ [Object.fromEntries, "Object.fromEntries"],
176
+ [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
177
+ [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
178
+ [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
179
+ [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
180
+ [Object.getPrototypeOf, "Object.getPrototypeOf"],
181
+ [Object.is, "Object.is"],
182
+ [Object.isExtensible, "Object.isExtensible"],
183
+ [Object.isFrozen, "Object.isFrozen"],
184
+ [Object.isSealed, "Object.isSealed"],
185
+ [Object.keys, "Object.keys"],
186
+ [Object.preventExtensions, "Object.preventExtensions"],
187
+ [Object.seal, "Object.seal"],
188
+ [Object.setPrototypeOf, "Object.setPrototypeOf"],
189
+ [Object.values, "Object.values"],
190
+ [parseFloat, "parseFloat"],
191
+ [parseInt, "parseInt"],
192
+ [Promise, "Promise"],
193
+ [Proxy, "Proxy"],
194
+ [RangeError, "RangeError"],
195
+ [ReferenceError, "ReferenceError"],
196
+ [Reflect.apply, "Reflect.apply"],
197
+ [Reflect.construct, "Reflect.construct"],
198
+ [Reflect.defineProperty, "Reflect.defineProperty"],
199
+ [Reflect.deleteProperty, "Reflect.deleteProperty"],
200
+ [Reflect.get, "Reflect.get"],
201
+ [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
202
+ [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
203
+ [Reflect.has, "Reflect.has"],
204
+ [Reflect.isExtensible, "Reflect.isExtensible"],
205
+ [Reflect.ownKeys, "Reflect.ownKeys"],
206
+ [Reflect.preventExtensions, "Reflect.preventExtensions"],
207
+ [Reflect.set, "Reflect.set"],
208
+ [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
209
+ [RegExp, "RegExp"],
210
+ [Set, "Set"],
211
+ [String, "String"],
212
+ [String.fromCharCode, "String.fromCharCode"],
213
+ [String.fromCodePoint, "String.fromCodePoint"],
214
+ [String.raw, "String.raw"],
215
+ [Symbol, "Symbol"],
216
+ [Symbol.for, "Symbol.for"],
217
+ [SyntaxError, "SyntaxError"],
218
+ [TypeError, "TypeError"],
219
+ [Uint16Array, "Uint16Array"],
220
+ [Uint16Array.from, "Uint16Array.from"],
221
+ [Uint16Array.of, "Uint16Array.of"],
222
+ [Uint32Array, "Uint32Array"],
223
+ [Uint32Array.from, "Uint32Array.from"],
224
+ [Uint32Array.of, "Uint32Array.of"],
225
+ [Uint8Array, "Uint8Array"],
226
+ [Uint8Array.from, "Uint8Array.from"],
227
+ [Uint8Array.of, "Uint8Array.of"],
228
+ [Uint8ClampedArray, "Uint8ClampedArray"],
229
+ [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
230
+ [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
231
+ [URIError, "URIError"],
232
+ [WeakMap, "WeakMap"],
233
+ [WeakSet, "WeakSet"]
234
+ ]), KNOWN_OBJECTS = new Map([
235
+ [Atomics, "Atomics"],
236
+ [console, "console"],
237
+ [globalThis, "globalThis"],
238
+ [globalThis.crypto, "crypto"],
239
+ [Intl, "Intl"],
240
+ [JSON, "JSON"],
241
+ [Math, "Math"],
242
+ [Reflect, "Reflect"]
243
+ ]), State$1 = class {
244
+ ids = 0;
245
+ flush = 0;
246
+ registerInstanceId = 0;
247
+ flushed = !1;
248
+ wroteUndefined = !1;
249
+ buf = [];
250
+ strs = /* @__PURE__ */ new Map();
251
+ refs = /* @__PURE__ */ new WeakMap();
252
+ assigned = /* @__PURE__ */ new Set();
253
+ registered = [];
254
+ boundary = void 0;
255
+ mutated = [];
256
+ }, Reference = class {
257
+ registered = null;
258
+ assigns = null;
259
+ constructor(parent, accessor, flush, pos = null, id = null) {
260
+ this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id, this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
261
+ }
262
+ }, Serializer = class {
263
+ #state = new State$1();
264
+ get flushed() {
265
+ return this.#state.flushed;
266
+ }
267
+ stringify(val, boundary) {
268
+ try {
269
+ return this.#state.flushed = !1, this.#state.boundary = boundary, writeRoot(this.#state, val);
270
+ } finally {
271
+ this.#state.flush++, this.#state.buf = [];
272
+ }
273
+ }
274
+ nextId() {
275
+ return nextId(this.#state);
276
+ }
277
+ symbol(id) {
278
+ let symbol = Symbol();
279
+ return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
280
+ }
281
+ writeCall(value, object, property, spread) {
282
+ let state = this.#state;
283
+ state.mutated.push({
284
+ type: 0,
285
+ value,
286
+ object,
287
+ property,
288
+ spread
289
+ }), state.flushed = !0;
290
+ }
291
+ writeAssign(value, object, property) {
292
+ let state = this.#state;
293
+ state.mutated.push({
294
+ type: 1,
295
+ value,
296
+ object,
297
+ property
298
+ }), state.flushed = !0;
299
+ }
300
+ register(id, val, scope) {
301
+ return register(id, val, scope, scope ? ++this.#state.registerInstanceId : 0);
302
+ }
303
+ }, $chunk, NOOP$2 = () => {}, K_SCOPE_ID = Symbol("Scope ID"), K_SCOPE_REFERENCED = Symbol("Scope Referenced"), Mark = /* @__PURE__ */ function(Mark) {
304
+ return Mark.Placeholder = "!^", Mark.PlaceholderEnd = "!", Mark.ReorderMarker = "#", Mark;
305
+ }(Mark || {}), RuntimeKey = /* @__PURE__ */ function(RuntimeKey) {
306
+ return RuntimeKey.Walk = ".w", RuntimeKey.Resume = ".r", RuntimeKey.Blocking = ".b", RuntimeKey.Scripts = ".j", RuntimeKey;
307
+ }(RuntimeKey || {}), kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => writeScopeToState($chunk.boundary.state, scopeId, partialScope), State = class {
308
+ tagId = 1;
309
+ scopeId = 1;
310
+ reorderId = 1;
311
+ lastSerializedScopeId = this.scopeId;
312
+ hasGlobals = !1;
313
+ needsMainRuntime = !1;
314
+ hasMainRuntime = !1;
315
+ hasReorderRuntime = !1;
316
+ hasWrittenResume = !1;
317
+ walkOnNextFlush = !1;
318
+ trailerHTML = "";
319
+ resumes = "";
320
+ nonceAttr = "";
321
+ serializer = new Serializer();
322
+ writeReorders = null;
323
+ scopes = /* @__PURE__ */ new Map();
324
+ writeScopes = null;
325
+ ensureReady = null;
326
+ serializeReason;
327
+ constructor($global) {
328
+ this.$global = $global, this.$global = $global, $global.cspNonce && (this.nonceAttr = " nonce" + attrAssignment($global.cspNonce));
329
+ }
330
+ get runtimePrefix() {
331
+ let { $global } = this;
332
+ return $global.runtimeId + "." + $global.renderId;
333
+ }
334
+ get commentPrefix() {
335
+ let { $global } = this;
336
+ return $global.runtimeId + $global.renderId;
337
+ }
338
+ reorder(chunk) {
339
+ this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
340
+ }
341
+ nextReorderId() {
342
+ let c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = this.reorderId++, r = c[n % 54];
343
+ for (n = n / 54 | 0; n; n >>>= 6) r += c[n & 63];
344
+ return r;
345
+ }
346
+ mark(code, str) {
347
+ return "<!--" + this.commentPrefix + code + str + "-->";
348
+ }
349
+ }, Boundary = class extends AbortController {
350
+ onNext = NOOP$2;
351
+ count = 0;
352
+ constructor(state, parent) {
353
+ super(), this.state = state, this.state = state, this.signal.addEventListener("abort", () => {
354
+ this.count = 0, this.state = new State(this.state.$global), this.onNext();
355
+ }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
356
+ this.abort(parent.reason);
357
+ }));
358
+ }
359
+ flush() {
360
+ return this.signal.aborted || flushSerializer(this), this.count ? 1 : this.signal.aborted ? 2 : 0;
361
+ }
362
+ startAsync() {
363
+ this.signal.aborted || this.count++;
364
+ }
365
+ endAsync(chunk) {
366
+ !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
367
+ }
368
+ }, Chunk = class {
369
+ html = "";
370
+ scripts = "";
371
+ effects = "";
372
+ lastEffect = "";
373
+ async = !1;
374
+ consumed = !1;
375
+ needsWalk = !1;
376
+ reorderId = null;
377
+ placeholderBody = null;
378
+ placeholderRender = null;
379
+ placeholderBranchId = null;
380
+ constructor(boundary, next, context) {
381
+ this.boundary = boundary, this.next = next, this.context = context, this.boundary = boundary, this.next = next, this.context = context;
382
+ }
383
+ writeHTML(html) {
384
+ this.html += html;
385
+ }
386
+ writeEffect(scopeId, registryId) {
387
+ this.lastEffect === registryId ? this.effects += " " + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
388
+ }
389
+ writeScript(script) {
390
+ this.scripts = concatScripts(this.scripts, script);
391
+ }
392
+ append(chunk) {
393
+ this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect;
394
+ }
395
+ flushPlaceholder() {
396
+ if (this.placeholderBody) {
397
+ let body = this.placeholderBody.consume();
398
+ if (body.async) {
399
+ let { state } = this.boundary, reorderId = body.reorderId = this.placeholderBranchId ? this.placeholderBranchId + "" : state.nextReorderId();
400
+ this.placeholderBranchId = null, this.writeHTML(state.mark("!^", reorderId));
401
+ let after = this.render(this.placeholderRender);
402
+ after !== this && this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), after.writeHTML(state.mark("!", reorderId)), state.reorder(body);
403
+ } else body.next = this.next, this.next = body;
404
+ this.placeholderRender = this.placeholderBody = null;
405
+ }
406
+ }
407
+ consume() {
408
+ let cur = this, needsWalk = cur.needsWalk;
409
+ if (cur.next && !cur.async) {
410
+ let html = "", effects = "", scripts = "", lastEffect = "";
411
+ do
412
+ cur.flushPlaceholder(), needsWalk ||= cur.needsWalk, html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), lastEffect = cur.lastEffect || lastEffect, cur.consumed = !0, cur = cur.next;
413
+ while (cur.next && !cur.async);
414
+ cur.needsWalk = needsWalk, cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts), cur.lastEffect = lastEffect;
415
+ }
416
+ return cur;
417
+ }
418
+ render(content, val) {
419
+ let prev = $chunk;
420
+ $chunk = this;
421
+ try {
422
+ return content(val), $chunk;
423
+ } catch (err) {
424
+ return this.boundary.abort(err), this;
425
+ } finally {
426
+ $chunk = prev;
427
+ }
428
+ }
429
+ flushScript() {
430
+ let { boundary, effects } = this, { state } = boundary, { $global, runtimePrefix, nonceAttr } = state, { html, scripts } = this, needsWalk = state.walkOnNextFlush;
431
+ if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}}),self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), state.ensureReady && state.hasMainRuntime) {
432
+ let first = !0;
433
+ for (let id in state.ensureReady) state.ensureReady[id] && (state.ensureReady[id] = 0, scripts = first ? concatScripts(scripts, "(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1") : concatScripts(scripts, runtimePrefix + ".b" + toAccess(toObjectKey(id)) + "=1")), first = !1;
434
+ }
435
+ if (effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
436
+ needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector(\"style[\"+e.i+\"]\")||\"\"),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
437
+ for (let reorderedChunk of state.writeReorders) {
438
+ let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
439
+ for (reorderedChunk.reorderId = null;;) {
440
+ cur.flushPlaceholder();
441
+ let { next } = cur;
442
+ if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next) cur = next;
443
+ else break;
444
+ }
445
+ reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")")), scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
446
+ }
447
+ state.writeReorders = null;
448
+ }
449
+ return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
450
+ }
451
+ flushHTML() {
452
+ let { boundary } = this, { state } = boundary;
453
+ this.needsWalk && (this.needsWalk = !1, state.walkOnNextFlush = !0), this.flushScript();
454
+ let { scripts } = this, { $global, nonceAttr } = state, { __flush__ } = $global, { html } = this;
455
+ return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "<\/script>"), __flush__ && ($global.__flush__ = void 0, html = __flush__($global, html)), boundary.count || (html += state.trailerHTML), html;
456
+ }
457
+ }, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g, doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g, needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g, SET_SCOPE_REGISTER_ID = "$C_s", voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
458
+ let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
459
+ if (typeof renderer == "string") {
460
+ let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
461
+ if (rendered = !0, _scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
462
+ let renderContent = content || normalizeDynamicRenderer(input.content);
463
+ if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange));
464
+ else if (renderContent) {
465
+ if (typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
466
+ renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent) : _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
467
+ }
468
+ _html(`</${renderer}>`);
469
+ }
470
+ let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
471
+ needsScript && (childScope.R = renderer, _script(branchId, "d")), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
472
+ } else {
473
+ shouldResume && _html(state.mark("[", ""));
474
+ let render = () => {
475
+ if (renderer) try {
476
+ return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
477
+ ...inputOrArgs,
478
+ content
479
+ } : inputOrArgs);
480
+ } finally {
481
+ _set_serialize_reason(void 0);
482
+ }
483
+ else if (content) return content();
484
+ };
485
+ result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId, shouldResume && _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
486
+ }
487
+ return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer?.a || renderer }) : _scope_id(), result;
488
+ }, patchDynamicTag = ((originalDynamicTag) => (patch) => {
489
+ _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
490
+ let patched = patch(tag, scopeId, accessor);
491
+ return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
492
+ };
493
+ })(_dynamic_tag), K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
494
+ $global,
495
+ fork: _await,
496
+ write: _html,
497
+ writeScript,
498
+ nextScopeId: _scope_id,
499
+ peekNextScopeId: _peek_scope_id,
500
+ isInResumedBranch,
501
+ ensureState($global) {
502
+ let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
503
+ return state || ($global.runtimeId ||= "M", $global.renderId ||= $global.componentIdPrefix || $global.widgetIdPrefix || "_", $global[K_TAGS_API_STATE] = state = new State($global)), state;
504
+ },
505
+ isTagsAPI(fn) {
506
+ return !!fn.a;
507
+ },
508
+ onFlush(fn) {
509
+ let { flushHTML } = Chunk.prototype;
510
+ Chunk.prototype.flushHTML = function() {
511
+ return fn(this), flushHTML.call(this);
512
+ };
513
+ },
514
+ patchDynamicTag,
515
+ writeSetScopeForComponent(branchId, m5c, m5i) {
516
+ writeScope(branchId, {
517
+ m5c,
518
+ m5i
519
+ }), _script(branchId, SET_SCOPE_REGISTER_ID);
520
+ },
521
+ toJSON(state) {
522
+ return function() {
523
+ let compatRegistered = COMPAT_REGISTRY.get(this);
524
+ if (!compatRegistered) {
525
+ let registered = getRegistered(this);
526
+ if (registered) {
527
+ let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
528
+ scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(this, compatRegistered = [registered.id, scopeId]);
529
+ }
530
+ }
531
+ return compatRegistered;
532
+ };
533
+ },
534
+ flushScript($global) {
535
+ let boundary = new Boundary(this.ensureState($global));
536
+ if (boundary.flush() === 1) throw Error("Cannot serialize promise across tags/class compat layer.");
537
+ return new Chunk(boundary, null, null).flushScript().scripts;
538
+ },
539
+ render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
540
+ let boundary = new Boundary(this.ensureState(classAPIOut.global)), head = new Chunk(boundary, null, null), normalizedInput = input;
541
+ if ("renderBody" in input) {
542
+ normalizedInput = {};
543
+ for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
544
+ }
545
+ head.render(() => {
546
+ if (willRerender) {
547
+ let scopeId = _peek_scope_id();
548
+ writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
549
+ }
550
+ _set_serialize_reason(+!!willRerender);
551
+ try {
552
+ renderer(normalizedInput);
553
+ } finally {
554
+ _set_serialize_reason(void 0);
555
+ }
556
+ let asyncOut = classAPIOut.beginAsync({
557
+ last: !0,
558
+ timeout: -1
559
+ });
560
+ classAPIOut.onLast((next) => {
561
+ (boundary.onNext = () => {
562
+ boundary.signal.aborted ? (asyncOut.error(boundary.signal.reason), boundary.onNext = NOOP$1) : boundary.count || (boundary.onNext = NOOP$1, head = head.consume(), asyncOut.write(head.html), asyncOut.script(head.scripts), asyncOut.end(), head.html = head.scripts = "", completeChunks.push(head), next());
563
+ })();
564
+ });
565
+ });
566
+ },
567
+ registerRenderer(renderer, id) {
568
+ return register("$C_r", renderer, register(id, () => {}));
569
+ },
570
+ registerRenderBody(fn) {
571
+ register("$C_b", fn);
572
+ }
573
+ }, _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), ServerRendered = class {
574
+ #head;
575
+ #cachedPromise = null;
576
+ constructor(head) {
577
+ this.#head = head;
578
+ }
579
+ [Symbol.asyncIterator]() {
580
+ let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read((html) => {
581
+ value += html, resolve && (resolve({
582
+ value,
583
+ done
584
+ }), value = "");
585
+ }, (err) => {
586
+ aborted = !0, reason = err, reject && reject(err);
587
+ }, () => {
588
+ done = !0, resolve && (resolve({
589
+ value,
590
+ done: !value
591
+ }), value = "");
592
+ });
593
+ return {
594
+ next() {
595
+ if (aborted) return Promise.reject(reason);
596
+ if (value) {
597
+ let result = {
598
+ value,
599
+ done: !1
600
+ };
601
+ return value = "", Promise.resolve(result);
602
+ } else if (done) return Promise.resolve({
603
+ value: "",
604
+ done
605
+ });
606
+ else return new Promise(exec);
607
+ },
608
+ throw(error) {
609
+ return done || aborted || boundary?.abort(error), Promise.resolve({
610
+ value: "",
611
+ done: !0
612
+ });
613
+ },
614
+ return(value) {
615
+ return done || aborted || boundary?.abort(/* @__PURE__ */ Error("Iterator returned before consumed.")), Promise.resolve({
616
+ value,
617
+ done: !0
618
+ });
619
+ }
620
+ };
621
+ function exec(_resolve, _reject) {
622
+ resolve = _resolve, reject = _reject;
623
+ }
624
+ }
625
+ pipe(stream) {
626
+ this.#read((html) => {
627
+ stream.write(html);
628
+ }, (err) => {
629
+ let socket = "socket" in stream && stream.socket;
630
+ if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err)) throw err;
631
+ }, () => {
632
+ stream.end();
633
+ });
634
+ }
635
+ toReadable() {
636
+ let cancelled = !1, boundary, encoder = new TextEncoder();
637
+ return new ReadableStream({
638
+ start: (ctrl) => {
639
+ boundary = this.#read((html) => {
640
+ ctrl.enqueue(encoder.encode(html));
641
+ }, (err) => {
642
+ boundary = void 0, cancelled || ctrl.error(err);
643
+ }, () => {
644
+ boundary = void 0, ctrl.close();
645
+ });
646
+ },
647
+ cancel: (reason) => {
648
+ cancelled = !0, boundary?.abort(reason);
649
+ }
650
+ });
651
+ }
652
+ then(onfulfilled, onrejected) {
653
+ return this.#promise().then(onfulfilled, onrejected);
654
+ }
655
+ catch(onrejected) {
656
+ return this.#promise().catch(onrejected);
657
+ }
658
+ finally(onfinally) {
659
+ return this.#promise().finally(onfinally);
660
+ }
661
+ #promise() {
662
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
663
+ let head = this.#head;
664
+ if (this.#head = null, !head) return reject(/* @__PURE__ */ Error("Cannot read from a consumed render result"));
665
+ let { boundary } = head;
666
+ (boundary.onNext = () => {
667
+ switch (!boundary.count && boundary.flush()) {
668
+ case 2:
669
+ boundary.onNext = NOOP, reject(boundary.signal.reason);
670
+ break;
671
+ case 0:
672
+ resolve(head.consume().flushHTML());
673
+ break;
674
+ }
675
+ })();
676
+ });
677
+ }
678
+ #read(onWrite, onAbort, onClose) {
679
+ let tick = !0, head = this.#head;
680
+ if (this.#head = null, !head) {
681
+ onAbort(/* @__PURE__ */ Error("Cannot read from a consumed render result"));
682
+ return;
683
+ }
684
+ let { boundary } = head, onNext = boundary.onNext = (write) => {
685
+ let status = boundary.flush();
686
+ if (status === 2) tick || offTick(onNext), boundary.onNext = NOOP, onAbort(boundary.signal.reason);
687
+ else if (write || status === 0) {
688
+ let html = (head = head.consume()).flushHTML();
689
+ html && onWrite(html), status === 0 ? (tick || offTick(onNext), onClose()) : tick = !0;
690
+ } else tick && (tick = !1, queueTick(onNext));
691
+ };
692
+ return onNext(), boundary;
693
+ }
694
+ toString() {
695
+ let head = this.#head;
696
+ if (this.#head = null, !head) throw Error("Cannot read from a consumed render result");
697
+ let { boundary } = head;
698
+ switch (boundary.flush()) {
699
+ case 2: throw boundary.signal.reason;
700
+ case 1: throw Error("Cannot consume asynchronous render with 'toString'");
701
+ }
702
+ return head.consume().flushHTML();
703
+ }
704
+ };
705
+ //#region src/common/attr-tag.ts
3
706
  function attrTag(attrs) {
4
- return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
707
+ return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
5
708
  }
6
709
  function attrTags(first, attrs) {
7
- return first ? (first[rest] === empty ? first[rest] = [attrs] : first[rest].push(attrs), first) : attrTag(attrs);
710
+ return first ? (first[rest] === empty ? first[rest] = [attrs] : first[rest].push(attrs), first) : attrTag(attrs);
8
711
  }
9
712
  function* attrTagIterator() {
10
- yield this, yield* this[rest];
11
- }
12
-
13
- // src/common/errors.ts
14
- function _el_read_error() {
15
- }
16
- function _hoist_read_error() {
17
- }
18
- function _assert_hoist(value) {
19
- }
20
-
21
- // src/common/helpers.ts
22
- function classValue(classValue2) {
23
- return toDelimitedString(classValue2, " ", stringifyClassObject);
24
- }
713
+ yield this, yield* this[rest];
714
+ }
715
+ //#endregion
716
+ //#region src/common/errors.ts
717
+ function _el_read_error() {}
718
+ function _hoist_read_error() {}
719
+ function _assert_hoist(value) {}
720
+ //#endregion
721
+ //#region src/common/helpers.ts
25
722
  function stringifyClassObject(name, value) {
26
- return value ? name : "";
27
- }
28
- function styleValue(styleValue2) {
29
- return toDelimitedString(styleValue2, ";", stringifyStyleObject);
723
+ return value ? name : "";
30
724
  }
31
725
  function stringifyStyleObject(name, value) {
32
- return value || value === 0 ? name + ":" + value : "";
33
- }
34
- function toDelimitedString(val, delimiter, stringify) {
35
- let str = "", sep = "", part;
36
- if (val)
37
- if (typeof val != "object")
38
- str += val;
39
- else if (Array.isArray(val))
40
- for (let v of val)
41
- part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
42
- else
43
- for (let name in val)
44
- part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
45
- return str;
726
+ return value || value === 0 ? name + ":" + value : "";
46
727
  }
47
728
  function isEventHandler(name) {
48
- return /^on[A-Z-]/.test(name);
729
+ return /^on[A-Z-]/.test(name);
49
730
  }
50
731
  function getEventHandlerName(name) {
51
- return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
732
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
52
733
  }
53
734
  function isVoid(value) {
54
- return value == null || value === !1;
735
+ return value == null || value === !1;
55
736
  }
56
737
  function normalizeDynamicRenderer(value) {
57
- if (value) {
58
- if (typeof value == "string") return value;
59
- let normalized = value.content || value.default || value;
60
- if (/* @__KEY__ */ "a" in normalized)
61
- return normalized;
62
- }
63
- }
64
-
65
- // src/html/content.ts
738
+ if (value) {
739
+ if (typeof value == "string") return value;
740
+ let normalized = value.content || value.default || value;
741
+ if ("a" in normalized) return normalized;
742
+ }
743
+ }
744
+ //#endregion
745
+ //#region src/html/content.ts
66
746
  function _unescaped(val) {
67
- return val ? val + "" : val === 0 ? "0" : "";
747
+ return val ? val + "" : val === 0 ? "0" : "";
68
748
  }
69
- var unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
70
749
  function _escape(val) {
71
- return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
750
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
72
751
  }
73
- var unsafeScriptReg = /<\/script/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
74
752
  function _escape_script(val) {
75
- return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
753
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
76
754
  }
77
- var unsafeStyleReg = /<\/style/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
78
755
  function _escape_style(val) {
79
- return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
756
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
80
757
  }
81
- var unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, "&gt;") : str;
82
758
  function _escape_comment(val) {
83
- return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
759
+ return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
84
760
  }
85
-
86
- // src/common/for.ts
761
+ //#endregion
762
+ //#region src/common/for.ts
87
763
  function forIn(obj, cb) {
88
- for (let key in obj)
89
- cb(key, obj[key]);
764
+ for (let key in obj) cb(key, obj[key]);
90
765
  }
91
766
  function forOf(list, cb) {
92
- if (list) {
93
- let i = 0;
94
- for (let item of list)
95
- cb(item, i++);
96
- }
767
+ if (list) {
768
+ let i = 0;
769
+ for (let item of list) cb(item, i++);
770
+ }
97
771
  }
98
772
  function forTo(to, from, step, cb) {
99
- let start = from || 0, delta = step || 1;
100
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
101
- cb(start + i * delta);
773
+ let start = from || 0, delta = step || 1;
774
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
102
775
  }
103
776
  function forUntil(until, from, step, cb) {
104
- let start = from || 0, delta = step || 1;
105
- for (let steps = (until - start) / delta, i = 0; i < steps; i++)
106
- cb(start + i * delta);
777
+ let start = from || 0, delta = step || 1;
778
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
107
779
  }
108
-
109
- // src/common/opt.ts
780
+ //#endregion
781
+ //#region src/common/opt.ts
110
782
  function push(opt, item) {
111
- return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
783
+ return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
112
784
  }
113
-
114
- // src/html/for.ts
785
+ //#endregion
786
+ //#region src/html/for.ts
115
787
  function forOfBy(by, item, index) {
116
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
788
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
117
789
  }
118
790
  function forInBy(by, name, value) {
119
- return by ? by(name, value) : name;
791
+ return by ? by(name, value) : name;
120
792
  }
121
793
  function forStepBy(by, index) {
122
- return by ? by(index) : index;
123
- }
124
-
125
- // src/html/inlined-runtimes.ts
126
- var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})';
127
-
128
- // src/html/serializer.ts
129
- var kTouchedIterator = /* @__PURE__ */ Symbol(), { hasOwnProperty } = {}, Generator = (function* () {
130
- })().constructor, AsyncGenerator = (async function* () {
131
- })().constructor;
132
- patchIteratorNext(Generator.prototype);
133
- patchIteratorNext(AsyncGenerator.prototype);
134
- var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
135
- let KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
136
- for (let name of Object.getOwnPropertyNames(Symbol)) {
137
- let symbol = Symbol[name];
138
- typeof symbol == "symbol" && KNOWN_SYMBOLS2.set(symbol, "Symbol." + name);
139
- }
140
- return KNOWN_SYMBOLS2;
141
- })(), KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
142
- // This is by no means an exhaustive list,
143
- // but it should cover most of the built-in functions.
144
- [AggregateError, "AggregateError"],
145
- [Array, "Array"],
146
- [Array.from, "Array.from"],
147
- [Array.isArray, "Array.isArray"],
148
- [Array.of, "Array.of"],
149
- [ArrayBuffer, "ArrayBuffer"],
150
- [ArrayBuffer.isView, "ArrayBuffer.isView"],
151
- [Atomics.add, "Atomics.add"],
152
- [Atomics.and, "Atomics.and"],
153
- [Atomics.compareExchange, "Atomics.compareExchange"],
154
- [Atomics.exchange, "Atomics.exchange"],
155
- [Atomics.isLockFree, "Atomics.isLockFree"],
156
- [Atomics.load, "Atomics.load"],
157
- [Atomics.notify, "Atomics.notify"],
158
- [Atomics.or, "Atomics.or"],
159
- [Atomics.store, "Atomics.store"],
160
- [Atomics.sub, "Atomics.sub"],
161
- [Atomics.wait, "Atomics.wait"],
162
- [BigInt, "BigInt"],
163
- [BigInt.asIntN, "BigInt.asIntN"],
164
- [BigInt.asUintN, "BigInt.asUintN"],
165
- [BigInt64Array, "BigInt64Array"],
166
- [BigInt64Array.from, "BigInt64Array.from"],
167
- [BigInt64Array.of, "BigInt64Array.of"],
168
- [BigUint64Array, "BigUint64Array"],
169
- [BigUint64Array.from, "BigUint64Array.from"],
170
- [BigUint64Array.of, "BigUint64Array.of"],
171
- [Boolean, "Boolean"],
172
- [console.assert, "console.assert"],
173
- [console.clear, "console.clear"],
174
- [console.count, "console.count"],
175
- [console.countReset, "console.countReset"],
176
- [console.debug, "console.debug"],
177
- [console.dir, "console.dir"],
178
- [console.dirxml, "console.dirxml"],
179
- [console.error, "console.error"],
180
- [console.group, "console.group"],
181
- [console.groupCollapsed, "console.groupCollapsed"],
182
- [console.groupEnd, "console.groupEnd"],
183
- [console.info, "console.info"],
184
- [console.log, "console.log"],
185
- [console.table, "console.table"],
186
- [console.time, "console.time"],
187
- [console.timeEnd, "console.timeEnd"],
188
- [console.timeLog, "console.timeLog"],
189
- [console.timeStamp, "console.timeStamp"],
190
- [console.trace, "console.trace"],
191
- [console.warn, "console.warn"],
192
- [DataView, "DataView"],
193
- [Date, "Date"],
194
- [Date.now, "Date.now"],
195
- [Date.parse, "Date.parse"],
196
- [Date.UTC, "Date.UTC"],
197
- [decodeURI, "decodeURI"],
198
- [decodeURIComponent, "decodeURIComponent"],
199
- [encodeURI, "encodeURI"],
200
- [encodeURIComponent, "encodeURIComponent"],
201
- [Error, "Error"],
202
- [EvalError, "EvalError"],
203
- [Float32Array, "Float32Array"],
204
- [Float32Array.from, "Float32Array.from"],
205
- [Float32Array.of, "Float32Array.of"],
206
- [Float64Array, "Float64Array"],
207
- [Float64Array.from, "Float64Array.from"],
208
- [Float64Array.of, "Float64Array.of"],
209
- [Function, "Function"],
210
- [globalThis.atob, "atob"],
211
- [globalThis.btoa, "btoa"],
212
- [globalThis.clearImmediate, "clearImmediate"],
213
- [globalThis.clearInterval, "clearInterval"],
214
- [globalThis.clearTimeout, "clearTimeout"],
215
- [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
216
- [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
217
- [globalThis.fetch, "fetch"],
218
- [globalThis.performance?.now, "performance.now"],
219
- [globalThis.queueMicrotask, "queueMicrotask"],
220
- [globalThis.setImmediate, "setImmediate"],
221
- [globalThis.setInterval, "setInterval"],
222
- [globalThis.setTimeout, "setTimeout"],
223
- [globalThis.structuredClone, "structuredClone"],
224
- [globalThis.URL, "URL"],
225
- [globalThis.URLSearchParams, "URLSearchParams"],
226
- [globalThis.WritableStream, "WritableStream"],
227
- [Int16Array, "Int16Array"],
228
- [Int16Array.from, "Int16Array.from"],
229
- [Int16Array.of, "Int16Array.of"],
230
- [Int32Array, "Int32Array"],
231
- [Int32Array.from, "Int32Array.from"],
232
- [Int32Array.of, "Int32Array.of"],
233
- [Int8Array, "Int8Array"],
234
- [Int8Array.from, "Int8Array.from"],
235
- [Int8Array.of, "Int8Array.of"],
236
- [Intl.Collator, "Intl.Collator"],
237
- [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
238
- [Intl.DisplayNames, "Intl.DisplayNames"],
239
- [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
240
- [Intl.ListFormat, "Intl.ListFormat"],
241
- [Intl.Locale, "Intl.Locale"],
242
- [Intl.NumberFormat, "Intl.NumberFormat"],
243
- [Intl.PluralRules, "Intl.PluralRules"],
244
- [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
245
- [Intl.Segmenter, "Intl.Segmenter"],
246
- [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
247
- [isFinite, "isFinite"],
248
- [isNaN, "isNaN"],
249
- [JSON.parse, "JSON.parse"],
250
- [JSON.stringify, "JSON.stringify"],
251
- [Map, "Map"],
252
- [Map.groupBy, "Map.groupBy"],
253
- [Math.abs, "Math.abs"],
254
- [Math.acos, "Math.acos"],
255
- [Math.acosh, "Math.acosh"],
256
- [Math.asin, "Math.asin"],
257
- [Math.asinh, "Math.asinh"],
258
- [Math.atan, "Math.atan"],
259
- [Math.atan2, "Math.atan2"],
260
- [Math.atanh, "Math.atanh"],
261
- [Math.cbrt, "Math.cbrt"],
262
- [Math.ceil, "Math.ceil"],
263
- [Math.clz32, "Math.clz32"],
264
- [Math.cos, "Math.cos"],
265
- [Math.cosh, "Math.cosh"],
266
- [Math.exp, "Math.exp"],
267
- [Math.expm1, "Math.expm1"],
268
- [Math.floor, "Math.floor"],
269
- [Math.fround, "Math.fround"],
270
- [Math.hypot, "Math.hypot"],
271
- [Math.imul, "Math.imul"],
272
- [Math.log, "Math.log"],
273
- [Math.log10, "Math.log10"],
274
- [Math.log1p, "Math.log1p"],
275
- [Math.log2, "Math.log2"],
276
- [Math.max, "Math.max"],
277
- [Math.min, "Math.min"],
278
- [Math.pow, "Math.pow"],
279
- [Math.random, "Math.random"],
280
- [Math.round, "Math.round"],
281
- [Math.sign, "Math.sign"],
282
- [Math.sin, "Math.sin"],
283
- [Math.sinh, "Math.sinh"],
284
- [Math.sqrt, "Math.sqrt"],
285
- [Math.tan, "Math.tan"],
286
- [Math.tanh, "Math.tanh"],
287
- [Math.trunc, "Math.trunc"],
288
- [Number, "Number"],
289
- [Number.isFinite, "Number.isFinite"],
290
- [Number.isInteger, "Number.isInteger"],
291
- [Number.isNaN, "Number.isNaN"],
292
- [Number.isSafeInteger, "Number.isSafeInteger"],
293
- [Number.parseFloat, "Number.parseFloat"],
294
- [Number.parseInt, "Number.parseInt"],
295
- [Object, "Object"],
296
- [Object.assign, "Object.assign"],
297
- [Object.create, "Object.create"],
298
- [Object.defineProperties, "Object.defineProperties"],
299
- [Object.defineProperty, "Object.defineProperty"],
300
- [Object.entries, "Object.entries"],
301
- [Object.freeze, "Object.freeze"],
302
- [Object.fromEntries, "Object.fromEntries"],
303
- [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
304
- [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
305
- [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
306
- [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
307
- [Object.getPrototypeOf, "Object.getPrototypeOf"],
308
- [Object.is, "Object.is"],
309
- [Object.isExtensible, "Object.isExtensible"],
310
- [Object.isFrozen, "Object.isFrozen"],
311
- [Object.isSealed, "Object.isSealed"],
312
- [Object.keys, "Object.keys"],
313
- [Object.preventExtensions, "Object.preventExtensions"],
314
- [Object.seal, "Object.seal"],
315
- [Object.setPrototypeOf, "Object.setPrototypeOf"],
316
- [Object.values, "Object.values"],
317
- [parseFloat, "parseFloat"],
318
- [parseInt, "parseInt"],
319
- [Promise, "Promise"],
320
- [Proxy, "Proxy"],
321
- [RangeError, "RangeError"],
322
- [ReferenceError, "ReferenceError"],
323
- [Reflect.apply, "Reflect.apply"],
324
- [Reflect.construct, "Reflect.construct"],
325
- [Reflect.defineProperty, "Reflect.defineProperty"],
326
- [Reflect.deleteProperty, "Reflect.deleteProperty"],
327
- [Reflect.get, "Reflect.get"],
328
- [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
329
- [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
330
- [Reflect.has, "Reflect.has"],
331
- [Reflect.isExtensible, "Reflect.isExtensible"],
332
- [Reflect.ownKeys, "Reflect.ownKeys"],
333
- [Reflect.preventExtensions, "Reflect.preventExtensions"],
334
- [Reflect.set, "Reflect.set"],
335
- [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
336
- [RegExp, "RegExp"],
337
- [Set, "Set"],
338
- [String, "String"],
339
- [String.fromCharCode, "String.fromCharCode"],
340
- [String.fromCodePoint, "String.fromCodePoint"],
341
- [String.raw, "String.raw"],
342
- [Symbol, "Symbol"],
343
- [Symbol.for, "Symbol.for"],
344
- [SyntaxError, "SyntaxError"],
345
- [TypeError, "TypeError"],
346
- [Uint16Array, "Uint16Array"],
347
- [Uint16Array.from, "Uint16Array.from"],
348
- [Uint16Array.of, "Uint16Array.of"],
349
- [Uint32Array, "Uint32Array"],
350
- [Uint32Array.from, "Uint32Array.from"],
351
- [Uint32Array.of, "Uint32Array.of"],
352
- [Uint8Array, "Uint8Array"],
353
- [Uint8Array.from, "Uint8Array.from"],
354
- [Uint8Array.of, "Uint8Array.of"],
355
- [Uint8ClampedArray, "Uint8ClampedArray"],
356
- [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
357
- [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
358
- [URIError, "URIError"],
359
- [WeakMap, "WeakMap"],
360
- [WeakSet, "WeakSet"]
361
- ]), KNOWN_OBJECTS = /* @__PURE__ */ new Map([
362
- [Atomics, "Atomics"],
363
- [console, "console"],
364
- [globalThis, "globalThis"],
365
- [globalThis.crypto, "crypto"],
366
- [Intl, "Intl"],
367
- [JSON, "JSON"],
368
- [Math, "Math"],
369
- [Reflect, "Reflect"]
370
- ]), State = class {
371
- ids = 0;
372
- flush = 0;
373
- registerInstanceId = 0;
374
- flushed = !1;
375
- wroteUndefined = !1;
376
- buf = [];
377
- strs = /* @__PURE__ */ new Map();
378
- refs = /* @__PURE__ */ new WeakMap();
379
- assigned = /* @__PURE__ */ new Set();
380
- registered = [];
381
- boundary = void 0;
382
- mutated = [];
383
- }, Reference = class {
384
- constructor(parent, accessor, flush, pos = null, id = null) {
385
- this.parent = parent;
386
- this.accessor = accessor;
387
- this.flush = flush;
388
- this.pos = pos;
389
- this.id = id;
390
- this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
391
- }
392
- registered = null;
393
- assigns = null;
394
- };
395
- var Serializer = class {
396
- #state = new State();
397
- get flushed() {
398
- return this.#state.flushed;
399
- }
400
- stringify(val, boundary) {
401
- try {
402
- return this.#state.flushed = !1, this.#state.boundary = boundary, writeRoot(this.#state, val);
403
- } finally {
404
- this.#state.flush++, this.#state.buf = [];
405
- }
406
- }
407
- nextId() {
408
- return nextId(this.#state);
409
- }
410
- symbol(id) {
411
- let symbol = /* @__PURE__ */ Symbol();
412
- return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
413
- }
414
- writeCall(value, object, property, spread) {
415
- let state = this.#state;
416
- state.mutated.push({
417
- type: 0 /* call */,
418
- value,
419
- object,
420
- property,
421
- spread
422
- }), state.flushed = !0;
423
- }
424
- writeAssign(value, object, property) {
425
- let state = this.#state;
426
- state.mutated.push({
427
- type: 1 /* assign */,
428
- value,
429
- object,
430
- property
431
- }), state.flushed = !0;
432
- }
433
- register(id, val, scope) {
434
- return register(
435
- id,
436
- val,
437
- scope,
438
- scope ? ++this.#state.registerInstanceId : 0
439
- );
440
- }
441
- };
794
+ return by ? by(index) : index;
795
+ }
796
+ patchIteratorNext(Generator.prototype), patchIteratorNext(AsyncGenerator.prototype);
442
797
  function register(id, val, scope, instanceId) {
443
- return REGISTRY.set(val, {
444
- id,
445
- scope,
446
- instanceId: instanceId ?? 0,
447
- access: "_._" + toAccess(toObjectKey(id))
448
- }), val;
798
+ return REGISTRY.set(val, {
799
+ id,
800
+ scope,
801
+ instanceId: instanceId ?? 0,
802
+ access: "_._" + toAccess(toObjectKey(id))
803
+ }), val;
449
804
  }
450
805
  function getRegistered(val) {
451
- let registered = REGISTRY.get(val);
452
- if (registered)
453
- return { id: registered.id, scope: registered.scope };
806
+ let registered = REGISTRY.get(val);
807
+ if (registered) return {
808
+ id: registered.id,
809
+ scope: registered.scope
810
+ };
454
811
  }
455
812
  function writeRoot(state, root) {
456
- let { buf } = state, hadBuf = buf.length !== 0, result;
457
- if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
458
- let rootRef = state.refs.get(root);
459
- if (rootRef) {
460
- let rootId = ensureId(state, rootRef);
461
- (state.assigned.size || state.registered.length || state.mutated.length) && (state.assigned.delete(rootRef), writeAssigned(state), buf.push(
462
- "," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
463
- ));
464
- }
465
- result = "(", buf.push(")");
466
- } else
467
- hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
468
- for (let chunk of buf)
469
- result += chunk;
470
- return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
813
+ let { buf } = state, hadBuf = buf.length !== 0, result;
814
+ if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
815
+ let rootRef = state.refs.get(root);
816
+ if (rootRef) {
817
+ let rootId = ensureId(state, rootRef);
818
+ (state.assigned.size || state.registered.length || state.mutated.length) && (state.assigned.delete(rootRef), writeAssigned(state), buf.push("," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)));
819
+ }
820
+ result = "(", buf.push(")");
821
+ } else hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
822
+ for (let chunk of buf) result += chunk;
823
+ return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
471
824
  }
472
825
  function writeAssigned(state) {
473
- if (state.assigned.size) {
474
- let buf = "";
475
- for (let ref of state.assigned)
476
- buf += "," + assignsToString(ref.assigns, ref.id), ref.assigns = null;
477
- state.buf.push(buf), state.assigned = /* @__PURE__ */ new Set();
478
- }
479
- if (state.registered.length) {
480
- let buf = "";
481
- for (let ref of state.registered.sort(compareRegisteredReferences)) {
482
- let scopeRef = state.refs.get(ref.registered.scope);
483
- buf += "," + assignsToString(
484
- ref.assigns,
485
- ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"
486
- ), ref.assigns = null, ref.registered = null;
487
- }
488
- state.buf.push(buf), state.registered = [];
489
- }
490
- if (state.mutated.length) {
491
- for (let mutation of state.mutated) {
492
- let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(
493
- state.buf.length === 0 ? "" : ","
494
- );
495
- if (writeProp(state, mutation.object, null, "")) {
496
- let objectRef = state.refs.get(mutation.object);
497
- objectRef && (objectRef.id ? hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")) : (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")));
498
- } else
499
- state.buf.push("void 0");
500
- let isCall = mutation.type === 0 /* call */, valueStartIndex = state.buf.push(
501
- isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
502
- );
503
- if (writeProp(state, mutation.value, null, "")) {
504
- let valueRef = state.refs.get(mutation.value);
505
- valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
506
- } else
507
- state.buf.push("void 0");
508
- isCall && state.buf.push(")");
509
- }
510
- state.mutated = [], (state.assigned.size || state.registered.length) && writeAssigned(state);
511
- }
826
+ if (state.assigned.size) {
827
+ let buf = "";
828
+ for (let ref of state.assigned) buf += "," + assignsToString(ref.assigns, ref.id), ref.assigns = null;
829
+ state.buf.push(buf), state.assigned = /* @__PURE__ */ new Set();
830
+ }
831
+ if (state.registered.length) {
832
+ let buf = "";
833
+ for (let ref of state.registered.sort(compareRegisteredReferences)) {
834
+ let scopeRef = state.refs.get(ref.registered.scope);
835
+ buf += "," + assignsToString(ref.assigns, ref.registered.access + "(" + (scopeRef ? ensureId(state, scopeRef) : ref.assigns[0]) + ")"), ref.assigns = null, ref.registered = null;
836
+ }
837
+ state.buf.push(buf), state.registered = [];
838
+ }
839
+ if (state.mutated.length) {
840
+ for (let mutation of state.mutated) {
841
+ let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(state.buf.length === 0 ? "" : ",");
842
+ if (writeProp(state, mutation.object, null, "")) {
843
+ let objectRef = state.refs.get(mutation.object);
844
+ objectRef && (objectRef.id ? hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")) : (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")));
845
+ } else state.buf.push("void 0");
846
+ let isCall = mutation.type === 0, valueStartIndex = state.buf.push(isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "=");
847
+ if (writeProp(state, mutation.value, null, "")) {
848
+ let valueRef = state.refs.get(mutation.value);
849
+ valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
850
+ } else state.buf.push("void 0");
851
+ isCall && state.buf.push(")");
852
+ }
853
+ state.mutated = [], (state.assigned.size || state.registered.length) && writeAssigned(state);
854
+ }
512
855
  }
513
856
  function writeProp(state, val, parent, accessor) {
514
- switch (typeof val) {
515
- case "string":
516
- return writeString(state, val, parent, accessor);
517
- case "number":
518
- return writeNumber(state, val);
519
- case "boolean":
520
- return writeBoolean(state, val);
521
- case "bigint":
522
- return writeBigInt(state, val);
523
- case "symbol":
524
- return writeSymbol(state, val, parent, accessor);
525
- case "function":
526
- return writeFunction(state, val, parent, accessor);
527
- case "object":
528
- return writeObject(state, val, parent, accessor);
529
- default:
530
- return !1;
531
- }
857
+ switch (typeof val) {
858
+ case "string": return writeString(state, val, parent, accessor);
859
+ case "number": return writeNumber(state, val);
860
+ case "boolean": return writeBoolean(state, val);
861
+ case "bigint": return writeBigInt(state, val);
862
+ case "symbol": return writeSymbol(state, val, parent, accessor);
863
+ case "function": return writeFunction(state, val, parent, accessor);
864
+ case "object": return writeObject(state, val, parent, accessor);
865
+ default: return !1;
866
+ }
532
867
  }
533
868
  function writeReferenceOr(state, write, val, parent, accessor) {
534
- let ref = state.refs.get(val);
535
- if (ref) {
536
- if (parent) {
537
- if (ref.assigns)
538
- return addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
539
- if (isCircular(parent, ref))
540
- return ensureId(state, ref), state.assigned.add(ref), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
541
- }
542
- return state.buf.push(ensureId(state, ref)), !0;
543
- }
544
- let registered = REGISTRY.get(val);
545
- return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
546
- val,
547
- ref = new Reference(parent, accessor, state.flush, state.buf.length)
548
- ), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
869
+ let ref = state.refs.get(val);
870
+ if (ref) {
871
+ if (parent) {
872
+ if (ref.assigns) return addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
873
+ if (isCircular(parent, ref)) return ensureId(state, ref), state.assigned.add(ref), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1;
874
+ }
875
+ return state.buf.push(ensureId(state, ref)), !0;
876
+ }
877
+ let registered = REGISTRY.get(val);
878
+ return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.flush, state.buf.length)), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
549
879
  }
550
880
  function writeRegistered(state, val, parent, accessor, registered) {
551
- if (parent && registered.scope) {
552
- let fnRef = new Reference(
553
- parent,
554
- accessor,
555
- state.flush,
556
- state.buf.length
557
- );
558
- return fnRef.registered = registered, state.refs.set(val, fnRef), state.registered.push(fnRef), addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
559
- } else
560
- state.buf.push(registered.access);
561
- return !0;
881
+ if (parent && registered.scope) {
882
+ let fnRef = new Reference(parent, accessor, state.flush, state.buf.length);
883
+ return fnRef.registered = registered, state.refs.set(val, fnRef), state.registered.push(fnRef), addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !state.refs.has(registered.scope) && writeProp(state, registered.scope, null, "");
884
+ } else state.buf.push(registered.access);
885
+ return !0;
562
886
  }
563
887
  function writeString(state, val, parent, accessor) {
564
- if (val.length > 30) {
565
- let ref = state.strs.get(val);
566
- ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(
567
- val,
568
- new Reference(parent, accessor, state.flush, state.buf.length)
569
- ), state.buf.push(quote(val, 0)));
570
- } else
571
- state.buf.push(quote(val, 0));
572
- return !0;
888
+ if (val.length > 30) {
889
+ let ref = state.strs.get(val);
890
+ ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(val, new Reference(parent, accessor, state.flush, state.buf.length)), state.buf.push(quote(val, 0)));
891
+ } else state.buf.push(quote(val, 0));
892
+ return !0;
573
893
  }
574
894
  function writeNumber(state, val) {
575
- return state.buf.push(val + ""), !0;
895
+ return state.buf.push(val + ""), !0;
576
896
  }
577
897
  function writeBoolean(state, val) {
578
- return state.buf.push(val ? "!0" : "!1"), !0;
898
+ return state.buf.push(val ? "!0" : "!1"), !0;
579
899
  }
580
900
  function writeBigInt(state, val) {
581
- return state.buf.push(val + "n"), !0;
901
+ return state.buf.push(val + "n"), !0;
582
902
  }
583
903
  function writeFunction(state, val, parent, accessor) {
584
- let wellKnownFunction = KNOWN_FUNCTIONS.get(val);
585
- return wellKnownFunction ? (state.buf.push(wellKnownFunction), !0) : writeReferenceOr(state, writeNever, val, parent, accessor);
904
+ let wellKnownFunction = KNOWN_FUNCTIONS.get(val);
905
+ return wellKnownFunction ? (state.buf.push(wellKnownFunction), !0) : writeReferenceOr(state, writeNever, val, parent, accessor);
586
906
  }
587
907
  function writeSymbol(state, val, parent, accessor) {
588
- let wellKnownSymbol = KNOWN_SYMBOLS.get(val);
589
- if (wellKnownSymbol)
590
- return state.buf.push(wellKnownSymbol), !0;
591
- let key = Symbol.keyFor(val);
592
- return key !== void 0 ? (state.buf.push("Symbol.for(" + quote(key, 0) + ")"), !0) : writeReferenceOr(state, writeUnknownSymbol, val, parent, accessor);
908
+ let wellKnownSymbol = KNOWN_SYMBOLS.get(val);
909
+ if (wellKnownSymbol) return state.buf.push(wellKnownSymbol), !0;
910
+ let key = Symbol.keyFor(val);
911
+ return key === void 0 ? writeReferenceOr(state, writeUnknownSymbol, val, parent, accessor) : (state.buf.push("Symbol.for(" + quote(key, 0) + ")"), !0);
593
912
  }
594
913
  function writeUnknownSymbol(state) {
595
- return state.buf.push("Symbol()"), !0;
914
+ return state.buf.push("Symbol()"), !0;
596
915
  }
597
916
  function writeNever(state, val, ref) {
598
- return !1;
917
+ return !1;
599
918
  }
600
919
  function writeNull(state) {
601
- return state.buf.push("null"), !0;
920
+ return state.buf.push("null"), !0;
602
921
  }
603
922
  function writeObject(state, val, parent, accessor) {
604
- if (val === null) return writeNull(state);
605
- let wellKnownObject = KNOWN_OBJECTS.get(val);
606
- return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
923
+ if (val === null) return writeNull(state);
924
+ let wellKnownObject = KNOWN_OBJECTS.get(val);
925
+ return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
607
926
  }
608
927
  function writeUnknownObject(state, val, ref) {
609
- switch (val.constructor) {
610
- case void 0:
611
- return writeNullObject(state, val, ref);
612
- case Object:
613
- return writePlainObject(state, val, ref);
614
- case Array:
615
- return writeArray(state, val, ref);
616
- case Date:
617
- return writeDate(state, val);
618
- case RegExp:
619
- return writeRegExp(state, val);
620
- case Promise:
621
- return writePromise(state, val, ref);
622
- case Map:
623
- return writeMap(state, val, ref);
624
- case Set:
625
- return writeSet(state, val, ref);
626
- case Generator:
627
- return writeGenerator(state, val, ref);
628
- case AsyncGenerator:
629
- return writeAsyncGenerator(state, val, ref);
630
- case Error:
631
- case EvalError:
632
- case RangeError:
633
- case ReferenceError:
634
- case SyntaxError:
635
- case TypeError:
636
- case URIError:
637
- return writeError(state, val, ref);
638
- case AggregateError:
639
- return writeAggregateError(state, val, ref);
640
- case ArrayBuffer:
641
- return writeArrayBuffer(state, val);
642
- case Int8Array:
643
- case Uint8Array:
644
- case Uint8ClampedArray:
645
- case Int16Array:
646
- case Uint16Array:
647
- case Int32Array:
648
- case Uint32Array:
649
- case Float32Array:
650
- case Float64Array:
651
- return writeTypedArray(state, val, ref);
652
- case WeakSet:
653
- return writeWeakSet(state);
654
- case WeakMap:
655
- return writeWeakMap(state);
656
- // The following references use `globalThis`
657
- // since they are not implemented by all runtimes.
658
- case globalThis.URL:
659
- return writeURL(state, val);
660
- case globalThis.URLSearchParams:
661
- return writeURLSearchParams(state, val);
662
- case globalThis.Headers:
663
- return writeHeaders(state, val);
664
- case globalThis.FormData:
665
- return writeFormData(state, val);
666
- case globalThis.ReadableStream:
667
- return writeReadableStream(state, val, ref);
668
- case globalThis.Request:
669
- return writeRequest(state, val, ref);
670
- case globalThis.Response:
671
- return writeResponse(state, val, ref);
672
- }
673
- return !1;
928
+ switch (val.constructor) {
929
+ case void 0: return writeNullObject(state, val, ref);
930
+ case Object: return writePlainObject(state, val, ref);
931
+ case Array: return writeArray(state, val, ref);
932
+ case Date: return writeDate(state, val);
933
+ case RegExp: return writeRegExp(state, val);
934
+ case Promise: return writePromise(state, val, ref);
935
+ case Map: return writeMap(state, val, ref);
936
+ case Set: return writeSet(state, val, ref);
937
+ case Generator: return writeGenerator(state, val, ref);
938
+ case AsyncGenerator: return writeAsyncGenerator(state, val, ref);
939
+ case Error:
940
+ case EvalError:
941
+ case RangeError:
942
+ case ReferenceError:
943
+ case SyntaxError:
944
+ case TypeError:
945
+ case URIError: return writeError(state, val, ref);
946
+ case AggregateError: return writeAggregateError(state, val, ref);
947
+ case ArrayBuffer: return writeArrayBuffer(state, val);
948
+ case Int8Array:
949
+ case Uint8Array:
950
+ case Uint8ClampedArray:
951
+ case Int16Array:
952
+ case Uint16Array:
953
+ case Int32Array:
954
+ case Uint32Array:
955
+ case Float32Array:
956
+ case Float64Array: return writeTypedArray(state, val, ref);
957
+ case WeakSet: return writeWeakSet(state);
958
+ case WeakMap: return writeWeakMap(state);
959
+ case globalThis.URL: return writeURL(state, val);
960
+ case globalThis.URLSearchParams: return writeURLSearchParams(state, val);
961
+ case globalThis.Headers: return writeHeaders(state, val);
962
+ case globalThis.FormData: return writeFormData(state, val);
963
+ case globalThis.ReadableStream: return writeReadableStream(state, val, ref);
964
+ case globalThis.Request: return writeRequest(state, val, ref);
965
+ case globalThis.Response: return writeResponse(state, val, ref);
966
+ }
967
+ return !1;
674
968
  }
675
969
  function writePlainObject(state, val, ref) {
676
- return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
970
+ return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
677
971
  }
678
972
  function writeArray(state, val, ref) {
679
- let sep = "[";
680
- for (let i = 0; i < val.length; i++) {
681
- let item = val[i];
682
- state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
683
- }
684
- return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
973
+ let sep = "[";
974
+ for (let i = 0; i < val.length; i++) {
975
+ let item = val[i];
976
+ state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
977
+ }
978
+ return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
685
979
  }
686
980
  function writeDate(state, val) {
687
- return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
981
+ return state.buf.push("new Date(\"" + val.toISOString() + "\")"), !0;
688
982
  }
689
983
  function writeRegExp(state, val) {
690
- return state.buf.push(val + ""), !0;
984
+ return state.buf.push(val + ""), !0;
691
985
  }
692
986
  function writePromise(state, val, ref) {
693
- let { boundary } = state;
694
- if (!boundary) return !1;
695
- let pId = nextRefAccess(state), pRef = new Reference(ref, null, state.flush, null, pId);
696
- return state.buf.push(
697
- "(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"
698
- ), val.then(
699
- (v) => writeAsyncCall(state, boundary, pRef, "f", v, pId),
700
- (v) => writeAsyncCall(state, boundary, pRef, "r", v, pId)
701
- ), boundary.startAsync(), !0;
987
+ let { boundary } = state;
988
+ if (!boundary) return !1;
989
+ let pId = nextRefAccess(state), pRef = new Reference(ref, null, state.flush, null, pId);
990
+ return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) => writeAsyncCall(state, boundary, pRef, "f", v, pId), (v) => writeAsyncCall(state, boundary, pRef, "r", v, pId)), boundary.startAsync(), !0;
702
991
  }
703
992
  function writeMap(state, val, ref) {
704
- if (!val.size)
705
- return state.buf.push("new Map"), !0;
706
- let arrayRef = new Reference(
707
- ref,
708
- null,
709
- state.flush,
710
- null,
711
- nextRefAccess(state)
712
- ), items = [], assigns, i = 0;
713
- if (val.size < 25) {
714
- for (let [itemKey, itemValue] of val)
715
- itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(
716
- itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]
717
- );
718
- assigns ? state.buf.push(
719
- "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "="
720
- ) : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
721
- } else {
722
- for (let [itemKey, itemValue] of val)
723
- itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
724
- assigns ? state.buf.push(
725
- "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "="
726
- ) : state.buf.push(
727
- "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="
728
- ), writeArray(state, items, arrayRef), state.buf.push(")");
729
- }
730
- return !0;
993
+ if (!val.size) return state.buf.push("new Map"), !0;
994
+ let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state)), items = [], assigns, i = 0;
995
+ if (val.size < 25) {
996
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
997
+ assigns ? state.buf.push("((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "=") : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
998
+ } else {
999
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
1000
+ assigns ? state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "=") : state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
1001
+ }
1002
+ return !0;
731
1003
  }
732
1004
  function writeSet(state, val, ref) {
733
- if (!val.size)
734
- return state.buf.push("new Set"), !0;
735
- let items = [], assigns, i = 0;
736
- for (let item of val)
737
- item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
738
- let arrayRef = new Reference(
739
- ref,
740
- null,
741
- state.flush,
742
- null,
743
- nextRefAccess(state)
744
- );
745
- return state.buf.push(
746
- (assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
747
- ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
1005
+ if (!val.size) return state.buf.push("new Set"), !0;
1006
+ let items = [], assigns, i = 0;
1007
+ for (let item of val) item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
1008
+ let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1009
+ return state.buf.push((assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
748
1010
  }
749
1011
  function writeArrayBuffer(state, val) {
750
- let result;
751
- if (val.byteLength) {
752
- let view = new Int8Array(val);
753
- result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
754
- } else
755
- result = "new ArrayBuffer";
756
- return state.buf.push(result), !0;
1012
+ let result;
1013
+ if (val.byteLength) {
1014
+ let view = new Int8Array(val);
1015
+ result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
1016
+ } else result = "new ArrayBuffer";
1017
+ return state.buf.push(result), !0;
757
1018
  }
758
1019
  function writeTypedArray(state, val, ref) {
759
- return val.byteOffset || state.refs.has(val.buffer) ? (state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push(val.byteOffset ? "," + val.byteOffset + ")" : ")")) : (state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push(
760
- "new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")")
761
- )), !0;
1020
+ return val.byteOffset || state.refs.has(val.buffer) ? (state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push(val.byteOffset ? "," + val.byteOffset + ")" : ")")) : (state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"))), !0;
762
1021
  }
763
1022
  function writeWeakSet(state) {
764
- return state.buf.push("new WeakSet"), !0;
1023
+ return state.buf.push("new WeakSet"), !0;
765
1024
  }
766
1025
  function writeWeakMap(state) {
767
- return state.buf.push("new WeakMap"), !0;
1026
+ return state.buf.push("new WeakMap"), !0;
768
1027
  }
769
1028
  function writeError(state, val, ref) {
770
- let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
771
- return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
1029
+ let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
1030
+ return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
772
1031
  }
773
1032
  function writeAggregateError(state, val, ref) {
774
- return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
1033
+ return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
775
1034
  }
776
1035
  function writeURL(state, val) {
777
- return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
1036
+ return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
778
1037
  }
779
1038
  function writeURLSearchParams(state, val) {
780
- let str = val.toString();
781
- return str ? state.buf.push("new URLSearchParams(" + quote(str, 0) + ")") : state.buf.push("new URLSearchParams"), !0;
1039
+ let str = val.toString();
1040
+ return str ? state.buf.push("new URLSearchParams(" + quote(str, 0) + ")") : state.buf.push("new URLSearchParams"), !0;
782
1041
  }
783
1042
  function writeHeaders(state, val) {
784
- let headers = stringEntriesToProps(val);
785
- return state.buf.push("new Headers" + (headers ? "({" + headers + "})" : "")), !0;
1043
+ let headers = stringEntriesToProps(val);
1044
+ return state.buf.push("new Headers" + (headers ? "({" + headers + "})" : "")), !0;
786
1045
  }
787
1046
  function writeFormData(state, val) {
788
- let sep = "[", valStr = "";
789
- for (let [key, value] of val)
790
- typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
791
- return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
792
- valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"
793
- ), !0;
1047
+ let sep = "[", valStr = "";
1048
+ for (let [key, value] of val) typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
1049
+ return sep === "[" ? state.buf.push("new FormData") : state.buf.push(valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"), !0;
794
1050
  }
795
1051
  function writeRequest(state, val, ref) {
796
- let sep = "", hasBody = val.body && !val.bodyUsed && val.duplex === "half";
797
- state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(',duplex:"half"'), sep = ",") : state.buf.pop());
798
- let options = "";
799
- val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
800
- let headers = stringEntriesToProps(val.headers);
801
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(
802
- hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
803
- ), !0;
1052
+ let sep = "", hasBody = val.body && !val.bodyUsed && val.duplex === "half";
1053
+ state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(",duplex:\"half\""), sep = ",") : state.buf.pop());
1054
+ let options = "";
1055
+ val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
1056
+ let headers = stringEntriesToProps(val.headers);
1057
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(hasBody ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
804
1058
  }
805
1059
  function writeResponse(state, val, ref) {
806
- let sep = "", options = "";
807
- val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
808
- let headers = stringEntriesToProps(val.headers);
809
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}"), !val.body || val.bodyUsed ? state.buf.push(
810
- "new Response" + (options ? "(null,{" + options + "})" : "")
811
- ) : (state.buf.push("new Response("), state.buf.push(
812
- (writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
813
- )), !0;
1060
+ let sep = "", options = "";
1061
+ val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
1062
+ let headers = stringEntriesToProps(val.headers);
1063
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}"), !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
814
1064
  }
815
1065
  function writeReadableStream(state, val, ref) {
816
- let { boundary } = state;
817
- if (!boundary || val.locked) return !1;
818
- let reader = val.getReader(), iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
819
- done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
820
- }, onRejected = (reason) => {
821
- writeAsyncCall(state, boundary, iterRef, "j", reason);
822
- };
823
- return state.buf.push(
824
- "new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"
825
- ), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
1066
+ let { boundary } = state;
1067
+ if (!boundary || val.locked) return !1;
1068
+ let reader = val.getReader(), iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
1069
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
1070
+ }, onRejected = (reason) => {
1071
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
1072
+ };
1073
+ return state.buf.push("new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
826
1074
  }
827
1075
  function writeGenerator(state, iter, ref) {
828
- if (iter[kTouchedIterator])
829
- return state.buf.push("(async function*(){}())"), !0;
830
- let sep = "";
831
- for (state.buf.push("(function*(){"); ; ) {
832
- let { value, done } = iter.next();
833
- if (done) {
834
- value !== void 0 && (state.buf.push(sep + "return "), writeProp(state, value, ref, ""));
835
- break;
836
- }
837
- value === void 0 ? state.buf.push(sep + "yield") : (state.buf.push(sep + "yield "), writeProp(state, value, ref, "")), sep = ";";
838
- }
839
- return state.buf.push("})()"), !0;
1076
+ if (iter[kTouchedIterator]) return state.buf.push("(async function*(){}())"), !0;
1077
+ let sep = "";
1078
+ for (state.buf.push("(function*(){");;) {
1079
+ let { value, done } = iter.next();
1080
+ if (done) {
1081
+ value !== void 0 && (state.buf.push(sep + "return "), writeProp(state, value, ref, ""));
1082
+ break;
1083
+ }
1084
+ value === void 0 ? state.buf.push(sep + "yield") : (state.buf.push(sep + "yield "), writeProp(state, value, ref, "")), sep = ";";
1085
+ }
1086
+ return state.buf.push("})()"), !0;
840
1087
  }
841
1088
  function writeAsyncGenerator(state, iter, ref) {
842
- if (iter[kTouchedIterator])
843
- return state.buf.push("(async function*(){}())"), !0;
844
- let { boundary } = state;
845
- if (!boundary) return !1;
846
- let iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
847
- done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
848
- }, onRejected = (reason) => {
849
- writeAsyncCall(state, boundary, iterRef, "j", reason);
850
- };
851
- return state.buf.push(
852
- "(async function*(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()])){for(i of a)v=await i,i!=l&&(yield v);return v})(" + iterId + "={})"
853
- ), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
1089
+ if (iter[kTouchedIterator]) return state.buf.push("(async function*(){}())"), !0;
1090
+ let { boundary } = state;
1091
+ if (!boundary) return !1;
1092
+ let iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
1093
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
1094
+ }, onRejected = (reason) => {
1095
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
1096
+ };
1097
+ return state.buf.push("(async function*(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()])){for(i of a)v=await i,i!=l&&(yield v);return v})(" + iterId + "={})"), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
854
1098
  }
855
1099
  function writeNullObject(state, val, ref) {
856
- return state.buf.push("{"), state.buf.push(writeObjectProps(state, val, ref) + "__proto__:null}"), !0;
1100
+ return state.buf.push("{"), state.buf.push(writeObjectProps(state, val, ref) + "__proto__:null}"), !0;
857
1101
  }
858
1102
  function writeObjectProps(state, val, ref) {
859
- let sep = "";
860
- for (let key in val)
861
- if (hasOwnProperty.call(val, key)) {
862
- let escapedKey = toObjectKey(key);
863
- state.buf.push(sep + escapedKey + ":"), writeProp(
864
- state,
865
- val[key],
866
- ref,
867
- escapedKey
868
- ) ? sep = "," : state.buf.pop();
869
- }
870
- if (hasSymbolIterator(val)) {
871
- let iterArr = [...val];
872
- switch (iterArr.length) {
873
- case 0:
874
- state.buf.push(sep + "*[Symbol.iterator](){}");
875
- break;
876
- case 1:
877
- state.buf.push(
878
- sep + "*[Symbol.iterator](){yield " + (iterArr[0] === val ? "this" : ensureId(state, ref)) + "}"
879
- );
880
- break;
881
- default: {
882
- let iterRef = new Reference(
883
- ref,
884
- null,
885
- state.flush,
886
- null,
887
- nextRefAccess(state)
888
- );
889
- state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){yield*" + iterRef.id + "}");
890
- break;
891
- }
892
- }
893
- sep = ",";
894
- }
895
- return sep;
1103
+ let sep = "";
1104
+ for (let key in val) if (hasOwnProperty.call(val, key)) {
1105
+ let escapedKey = toObjectKey(key);
1106
+ state.buf.push(sep + escapedKey + ":"), writeProp(state, val[key], ref, escapedKey) ? sep = "," : state.buf.pop();
1107
+ }
1108
+ if (hasSymbolIterator(val)) {
1109
+ let iterArr = [...val];
1110
+ switch (iterArr.length) {
1111
+ case 0:
1112
+ state.buf.push(sep + "*[Symbol.iterator](){}");
1113
+ break;
1114
+ case 1:
1115
+ state.buf.push(sep + "*[Symbol.iterator](){yield " + (iterArr[0] === val ? "this" : ensureId(state, ref)) + "}");
1116
+ break;
1117
+ default: {
1118
+ let iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1119
+ state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){yield*" + iterRef.id + "}");
1120
+ break;
1121
+ }
1122
+ }
1123
+ sep = ",";
1124
+ }
1125
+ return sep;
896
1126
  }
897
1127
  function writeAsyncCall(state, boundary, ref, method, value, preferredValueId = null) {
898
- if (boundary.signal.aborted) return;
899
- state.flushed = !0;
900
- let valueStartIndex = state.buf.push(
901
- (state.buf.length === 0 ? "" : ",") + ref.id + "." + method + "("
902
- );
903
- if (writeProp(state, value, ref, "")) {
904
- let valueRef = state.refs.get(value);
905
- valueRef && !valueRef.id && (valueRef.id = preferredValueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
906
- }
907
- state.buf.push(")"), boundary.endAsync();
1128
+ if (boundary.signal.aborted) return;
1129
+ state.flushed = !0;
1130
+ let valueStartIndex = state.buf.push((state.buf.length === 0 ? "" : ",") + ref.id + "." + method + "(");
1131
+ if (writeProp(state, value, ref, "")) {
1132
+ let valueRef = state.refs.get(value);
1133
+ valueRef && !valueRef.id && (valueRef.id = preferredValueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
1134
+ }
1135
+ state.buf.push(")"), boundary.endAsync();
908
1136
  }
909
1137
  function isCircular(parent, ref) {
910
- let cur = parent;
911
- for (; cur; ) {
912
- if (cur === ref) return !0;
913
- cur = cur.parent;
914
- }
915
- return !1;
1138
+ let cur = parent;
1139
+ for (; cur;) {
1140
+ if (cur === ref) return !0;
1141
+ cur = cur.parent;
1142
+ }
1143
+ return !1;
916
1144
  }
917
1145
  function toObjectKey(name) {
918
- if (name === "")
919
- return '""';
920
- let startChar = name[0];
921
- if (isDigit(startChar)) {
922
- if (startChar === "0") {
923
- if (name !== "0")
924
- return quote(name, 1);
925
- } else
926
- for (let i = 1; i < name.length; i++)
927
- if (!isDigit(name[i]))
928
- return quote(name, i);
929
- } else if (isWord(startChar)) {
930
- for (let i = 1; i < name.length; i++)
931
- if (!isWordOrDigit(name[i]))
932
- return quote(name, i);
933
- } else
934
- return quote(name, 0);
935
- return name;
1146
+ if (name === "") return "\"\"";
1147
+ let startChar = name[0];
1148
+ if (isDigit(startChar)) {
1149
+ if (startChar === "0") {
1150
+ if (name !== "0") return quote(name, 1);
1151
+ } else for (let i = 1; i < name.length; i++) if (!isDigit(name[i])) return quote(name, i);
1152
+ } else if (isWord(startChar)) {
1153
+ for (let i = 1; i < name.length; i++) if (!isWordOrDigit(name[i])) return quote(name, i);
1154
+ } else return quote(name, 0);
1155
+ return name;
936
1156
  }
937
1157
  function toAccess(accessor) {
938
- let start = accessor[0];
939
- return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1158
+ let start = accessor[0];
1159
+ return start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
940
1160
  }
941
1161
  function quote(str, startPos) {
942
- let result = "", lastPos = 0;
943
- for (let i = startPos; i < str.length; i++) {
944
- let replacement;
945
- switch (str[i]) {
946
- case '"':
947
- replacement = '\\"';
948
- break;
949
- case "\\":
950
- replacement = "\\\\";
951
- break;
952
- case "<":
953
- replacement = "\\x3C";
954
- break;
955
- case `
956
- `:
957
- replacement = "\\n";
958
- break;
959
- case "\r":
960
- replacement = "\\r";
961
- break;
962
- case "\u2028":
963
- replacement = "\\u2028";
964
- break;
965
- case "\u2029":
966
- replacement = "\\u2029";
967
- break;
968
- default:
969
- continue;
970
- }
971
- result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
972
- }
973
- return '"' + (lastPos === startPos ? str : result + str.slice(lastPos)) + '"';
1162
+ let result = "", lastPos = 0;
1163
+ for (let i = startPos; i < str.length; i++) {
1164
+ let replacement;
1165
+ switch (str[i]) {
1166
+ case "\"":
1167
+ replacement = "\\\"";
1168
+ break;
1169
+ case "\\":
1170
+ replacement = "\\\\";
1171
+ break;
1172
+ case "<":
1173
+ replacement = "\\x3C";
1174
+ break;
1175
+ case "\n":
1176
+ replacement = "\\n";
1177
+ break;
1178
+ case "\r":
1179
+ replacement = "\\r";
1180
+ break;
1181
+ case "\u2028":
1182
+ replacement = "\\u2028";
1183
+ break;
1184
+ case "\u2029":
1185
+ replacement = "\\u2029";
1186
+ break;
1187
+ default: continue;
1188
+ }
1189
+ result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
1190
+ }
1191
+ return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
974
1192
  }
975
1193
  function ensureId(state, ref) {
976
- return ref.id || assignId(state, ref);
1194
+ return ref.id || assignId(state, ref);
977
1195
  }
978
1196
  function assignId(state, ref) {
979
- let { pos } = ref;
980
- if (ref.id = nextRefAccess(state), pos !== null && ref.flush === state.flush)
981
- return pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id;
982
- let cur = ref, accessPrevValue = "";
983
- do {
984
- accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
985
- let parent = cur.parent;
986
- if (parent.id) {
987
- accessPrevValue = parent.id + accessPrevValue;
988
- break;
989
- }
990
- if (parent.flush === state.flush) {
991
- accessPrevValue = ensureId(state, parent) + accessPrevValue;
992
- break;
993
- }
994
- cur = parent;
995
- } while (cur);
996
- return ref.id + "=" + accessPrevValue;
1197
+ let { pos } = ref;
1198
+ if (ref.id = nextRefAccess(state), pos !== null && ref.flush === state.flush) return pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id;
1199
+ let cur = ref, accessPrevValue = "";
1200
+ do {
1201
+ accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
1202
+ let parent = cur.parent;
1203
+ if (parent.id) {
1204
+ accessPrevValue = parent.id + accessPrevValue;
1205
+ break;
1206
+ }
1207
+ if (parent.flush === state.flush) {
1208
+ accessPrevValue = ensureId(state, parent) + accessPrevValue;
1209
+ break;
1210
+ }
1211
+ cur = parent;
1212
+ } while (cur);
1213
+ return ref.id + "=" + accessPrevValue;
997
1214
  }
998
1215
  function assignsToString(assigns, value) {
999
- return assigns.length > 100 ? "($=>(" + assigns.join("=$,") + "=$))(" + value + ")" : assigns.join("=") + "=" + value;
1216
+ return assigns.length > 100 ? "($=>(" + assigns.join("=$,") + "=$))(" + value + ")" : assigns.join("=") + "=" + value;
1000
1217
  }
1001
1218
  function addAssignment(ref, assign) {
1002
- ref.assigns ? ref.assigns.push(assign) : ref.assigns = [assign];
1219
+ ref.assigns ? ref.assigns.push(assign) : ref.assigns = [assign];
1003
1220
  }
1004
1221
  function nextRefAccess(state) {
1005
- return "_." + nextId(state);
1222
+ return "_." + nextId(state);
1006
1223
  }
1007
1224
  function nextId(state) {
1008
- let c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = state.ids++, r = c[n % 53];
1009
- for (n = n / 53 | 0; n; n >>>= 6)
1010
- r += c[n & 63];
1011
- return r;
1225
+ let c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = state.ids++, r = c[n % 53];
1226
+ for (n = n / 53 | 0; n; n >>>= 6) r += c[n & 63];
1227
+ return r;
1012
1228
  }
1013
1229
  function hasSymbolIterator(value) {
1014
- return Symbol.iterator in value;
1230
+ return Symbol.iterator in value;
1015
1231
  }
1016
1232
  function stringEntriesToProps(entries) {
1017
- let result = "", sep = "";
1018
- for (let [key, value] of entries)
1019
- result += sep + toObjectKey(key) + ":" + quote(value, 0), sep = ",";
1020
- return result;
1233
+ let result = "", sep = "";
1234
+ for (let [key, value] of entries) result += sep + toObjectKey(key) + ":" + quote(value, 0), sep = ",";
1235
+ return result;
1021
1236
  }
1022
1237
  function typedArrayToInitString(view) {
1023
- let result = "[", sep = "";
1024
- for (let i = 0; i < view.length; i++)
1025
- result += sep + view[i], sep = ",";
1026
- return result += "]", result;
1238
+ let result = "[", sep = "";
1239
+ for (let i = 0; i < view.length; i++) result += sep + view[i], sep = ",";
1240
+ return result += "]", result;
1027
1241
  }
1028
1242
  function hasOnlyZeros(typedArray) {
1029
- for (let i = 0; i < typedArray.length; i++)
1030
- if (typedArray[i] !== 0) return !1;
1031
- return !0;
1243
+ for (let i = 0; i < typedArray.length; i++) if (typedArray[i] !== 0) return !1;
1244
+ return !0;
1032
1245
  }
1033
1246
  function isWordOrDigit(char) {
1034
- return isWord(char) || isDigit(char);
1247
+ return isWord(char) || isDigit(char);
1035
1248
  }
1036
1249
  function isDigit(char) {
1037
- return char >= "0" && char <= "9";
1250
+ return char >= "0" && char <= "9";
1038
1251
  }
1039
1252
  function isWord(char) {
1040
- return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
1253
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
1041
1254
  }
1042
1255
  function patchIteratorNext(proto) {
1043
- let { next } = proto;
1044
- proto.next = function(value) {
1045
- return this[kTouchedIterator] = 1, next.call(this, value);
1046
- };
1256
+ let { next } = proto;
1257
+ proto.next = function(value) {
1258
+ return this[kTouchedIterator] = 1, next.call(this, value);
1259
+ };
1047
1260
  }
1048
1261
  function compareRegisteredReferences(a, b) {
1049
- return a.registered.instanceId - b.registered.instanceId;
1262
+ return a.registered.instanceId - b.registered.instanceId;
1050
1263
  }
1051
-
1052
- // src/html/writer.ts
1053
- var $chunk, NOOP = () => {
1054
- }, K_SCOPE_ID = /* @__PURE__ */ Symbol("Scope ID"), K_SCOPE_REFERENCED = /* @__PURE__ */ Symbol("Scope Referenced");
1264
+ //#endregion
1265
+ //#region src/html/writer.ts
1055
1266
  function getChunk() {
1056
- return $chunk;
1267
+ return $chunk;
1057
1268
  }
1058
1269
  function getContext(key) {
1059
- return $chunk.context?.[key];
1270
+ return $chunk.context?.[key];
1060
1271
  }
1061
1272
  function getState() {
1062
- return $chunk.boundary.state;
1273
+ return $chunk.boundary.state;
1063
1274
  }
1064
1275
  function getScopeId(scope) {
1065
- return scope[K_SCOPE_ID];
1276
+ return scope[K_SCOPE_ID];
1066
1277
  }
1067
1278
  function _html(html) {
1068
- $chunk.writeHTML(html);
1279
+ $chunk.writeHTML(html);
1069
1280
  }
1070
1281
  function writeScript(script) {
1071
- $chunk.writeScript(script);
1282
+ $chunk.writeScript(script);
1072
1283
  }
1073
1284
  function _script(scopeId, registryId) {
1074
- $chunk.context?.[kIsAsync] && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
1285
+ $chunk.context?.[kIsAsync] && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
1075
1286
  }
1076
1287
  function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1077
- let shouldResume = serializeReason !== 0, render2 = normalizeServerRender(content), branchId = _peek_scope_id();
1078
- render2 && (shouldResume ? withBranchId(branchId, render2) : render2()), _peek_scope_id() !== branchId ? shouldResume && writeScope(scopeId, {
1079
- ["A" /* BranchScopes */ + nodeAccessor]: referenceScope(
1080
- writeScope(branchId, {})
1081
- ),
1082
- ["D" /* ConditionalRenderer */ + nodeAccessor]: render2?.a
1083
- }) : _scope_id();
1288
+ let shouldResume = serializeReason !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
1289
+ render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
1290
+ ["A" + nodeAccessor]: referenceScope(writeScope(branchId, {})),
1291
+ ["D" + nodeAccessor]: render?.a
1292
+ });
1084
1293
  }
1085
1294
  function normalizeServerRender(value) {
1086
- let renderer = normalizeDynamicRenderer(value);
1087
- if (renderer && typeof renderer == "function")
1088
- return renderer;
1295
+ let renderer = normalizeDynamicRenderer(value);
1296
+ if (renderer && typeof renderer == "function") return renderer;
1089
1297
  }
1090
- var kPendingContexts = /* @__PURE__ */ Symbol("Pending Contexts");
1091
1298
  function withContext(key, value, cb, cbValue) {
1092
- let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
1093
- ctx[kPendingContexts]++, ctx[key] = value;
1094
- try {
1095
- return cb(cbValue);
1096
- } finally {
1097
- ctx[kPendingContexts]--, ctx[key] = prev;
1098
- }
1299
+ let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
1300
+ ctx[kPendingContexts]++, ctx[key] = value;
1301
+ try {
1302
+ return cb(cbValue);
1303
+ } finally {
1304
+ ctx[kPendingContexts]--, ctx[key] = prev;
1305
+ }
1099
1306
  }
1100
1307
  function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
1101
- _scope_with_id(parentScopeId)[scopeOffsetAccessor] = _scope_id(), _scope_with_id(childScopeId).T = _resume(
1102
- {},
1103
- registryId,
1104
- parentScopeId
1105
- );
1308
+ _scope_with_id(parentScopeId)[scopeOffsetAccessor] = _scope_id(), _scope_with_id(childScopeId).T = _resume({}, registryId, parentScopeId);
1106
1309
  }
1107
1310
  function _resume(val, id, scopeId) {
1108
- return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(
1109
- id,
1110
- val,
1111
- _scope_with_id(scopeId)
1112
- );
1311
+ return scopeId === void 0 ? register(id, val) : $chunk.boundary.state.serializer.register(id, val, _scope_with_id(scopeId));
1113
1312
  }
1114
1313
  function _id() {
1115
- let state = $chunk.boundary.state, { $global: $global2 } = state;
1116
- return "s" + $global2.runtimeId + $global2.renderId + (state.tagId++).toString(36);
1314
+ let state = $chunk.boundary.state, { $global } = state;
1315
+ return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
1117
1316
  }
1118
1317
  function _scope_id() {
1119
- return $chunk.boundary.state.scopeId++;
1318
+ return $chunk.boundary.state.scopeId++;
1120
1319
  }
1121
1320
  function _peek_scope_id() {
1122
- return $chunk.boundary.state.scopeId;
1321
+ return $chunk.boundary.state.scopeId;
1123
1322
  }
1124
1323
  function getScopeById(scopeId) {
1125
- if (scopeId !== void 0)
1126
- return $chunk.boundary.state.scopes.get(scopeId);
1324
+ if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
1127
1325
  }
1128
1326
  function _set_serialize_reason(reason) {
1129
- $chunk.boundary.state.serializeReason = reason;
1327
+ $chunk.boundary.state.serializeReason = reason;
1130
1328
  }
1131
1329
  function _scope_reason() {
1132
- let reason = $chunk.boundary.state.serializeReason;
1133
- return $chunk.boundary.state.serializeReason = void 0, reason;
1330
+ let reason = $chunk.boundary.state.serializeReason;
1331
+ return $chunk.boundary.state.serializeReason = void 0, reason;
1134
1332
  }
1135
1333
  function _serialize_if(condition, key) {
1136
- return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1334
+ return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1137
1335
  }
1138
1336
  function _serialize_guard(condition, key) {
1139
- return condition && (condition === 1 || condition[key]) ? 1 : 0;
1337
+ return condition && (condition === 1 || condition[key]) ? 1 : 0;
1140
1338
  }
1141
1339
  function _el_resume(scopeId, accessor, shouldResume) {
1142
- if (shouldResume === 0) return "";
1143
- let { state } = $chunk.boundary;
1144
- return state.needsMainRuntime = !0, state.mark("*" /* Node */, scopeId + " " + accessor);
1340
+ if (shouldResume === 0) return "";
1341
+ let { state } = $chunk.boundary;
1342
+ return state.needsMainRuntime = !0, state.mark("*", scopeId + " " + accessor);
1145
1343
  }
1146
1344
  function _sep(shouldResume) {
1147
- return shouldResume === 0 ? "" : "<!>";
1345
+ return shouldResume === 0 ? "" : "<!>";
1148
1346
  }
1149
1347
  function _el(scopeId, id) {
1150
- return _resume(() => void 0, id, scopeId);
1348
+ return _resume(() => void 0, id, scopeId);
1151
1349
  }
1152
1350
  function _hoist(scopeId, id) {
1153
- let getter = () => void 0;
1154
- return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
1351
+ let getter = () => void 0;
1352
+ return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
1155
1353
  }
1156
1354
  function _resume_branch(scopeId) {
1157
- let branchId = $chunk.context?.[kBranchId];
1158
- branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { G: branchId });
1355
+ let branchId = $chunk.context?.[kBranchId];
1356
+ branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { G: branchId });
1159
1357
  }
1160
- var kBranchId = /* @__PURE__ */ Symbol("Branch Id"), kIsAsync = /* @__PURE__ */ Symbol("Is Async");
1161
1358
  function isInResumedBranch() {
1162
- return $chunk?.context?.[kBranchId] !== void 0;
1359
+ return $chunk?.context?.[kBranchId] !== void 0;
1163
1360
  }
1164
1361
  function withBranchId(branchId, cb) {
1165
- return withContext(kBranchId, branchId, cb);
1362
+ return withContext(kBranchId, branchId, cb);
1166
1363
  }
1167
1364
  function withIsAsync(cb, value) {
1168
- return withContext(kIsAsync, !0, cb, value);
1365
+ return withContext(kIsAsync, !0, cb, value);
1169
1366
  }
1170
1367
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1171
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1172
- if (serializeBranch !== 0) {
1173
- let loopScopes;
1174
- if (0)
1175
- var seenKeys;
1176
- forOf(list, (item, index) => {
1177
- let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1178
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1179
- state.mark("[" /* BranchStart */, flushBranchIds)
1180
- ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1181
- cb(item, index);
1182
- let branchScope = writeScope(branchId, {});
1183
- resumeKeys && itemKey !== index && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1184
- });
1185
- }), loopScopes && writeScope(scopeId, {
1186
- ["A" /* BranchScopes */ + accessor]: loopScopes
1187
- });
1188
- } else
1189
- forOf(list, cb);
1190
- writeBranchEnd(
1191
- scopeId,
1192
- accessor,
1193
- serializeStateful,
1194
- serializeMarker,
1195
- parentEndTag,
1196
- singleNode,
1197
- singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1198
- );
1368
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1369
+ if (serializeBranch !== 0) {
1370
+ let loopScopes;
1371
+ forOf(list, (item, index) => {
1372
+ let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1373
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1374
+ cb(item, index);
1375
+ let branchScope = writeScope(branchId, {});
1376
+ resumeKeys && itemKey !== index && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1377
+ });
1378
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1379
+ } else forOf(list, cb);
1380
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1199
1381
  }
1200
1382
  function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1201
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1202
- if (serializeBranch !== 0) {
1203
- let loopScopes;
1204
- if (0)
1205
- var seenKeys;
1206
- forIn(obj, (key, value) => {
1207
- let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1208
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1209
- state.mark("[" /* BranchStart */, flushBranchIds)
1210
- ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1211
- cb(key, value);
1212
- let branchScope = writeScope(branchId, {});
1213
- resumeKeys && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1214
- });
1215
- }), loopScopes && writeScope(scopeId, {
1216
- ["A" /* BranchScopes */ + accessor]: loopScopes
1217
- });
1218
- } else
1219
- forIn(obj, cb);
1220
- writeBranchEnd(
1221
- scopeId,
1222
- accessor,
1223
- serializeStateful,
1224
- serializeMarker,
1225
- parentEndTag,
1226
- singleNode,
1227
- singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1228
- );
1383
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1384
+ if (serializeBranch !== 0) {
1385
+ let loopScopes;
1386
+ forIn(obj, (key, value) => {
1387
+ let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1388
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1389
+ cb(key, value);
1390
+ let branchScope = writeScope(branchId, {});
1391
+ resumeKeys && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1392
+ });
1393
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1394
+ } else forIn(obj, cb);
1395
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1229
1396
  }
1230
1397
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1231
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1232
- if (serializeBranch !== 0) {
1233
- let loopScopes;
1234
- if (0)
1235
- var seenKeys;
1236
- forTo(to, from, step, (i) => {
1237
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1238
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1239
- state.mark("[" /* BranchStart */, flushBranchIds)
1240
- ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1241
- cb(i);
1242
- let branchScope = writeScope(branchId, {});
1243
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1244
- });
1245
- }), loopScopes && writeScope(scopeId, {
1246
- ["A" /* BranchScopes */ + accessor]: loopScopes
1247
- });
1248
- } else
1249
- forTo(to, from, step, cb);
1250
- writeBranchEnd(
1251
- scopeId,
1252
- accessor,
1253
- serializeStateful,
1254
- serializeMarker,
1255
- parentEndTag,
1256
- singleNode,
1257
- singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1258
- );
1398
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1399
+ if (serializeBranch !== 0) {
1400
+ let loopScopes;
1401
+ forTo(to, from, step, (i) => {
1402
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1403
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1404
+ cb(i);
1405
+ let branchScope = writeScope(branchId, {});
1406
+ resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1407
+ });
1408
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1409
+ } else forTo(to, from, step, cb);
1410
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1259
1411
  }
1260
1412
  function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1261
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1262
- if (serializeBranch !== 0) {
1263
- let loopScopes;
1264
- if (0)
1265
- var seenKeys;
1266
- forUntil(to, from, step, (i) => {
1267
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1268
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1269
- state.mark("[" /* BranchStart */, flushBranchIds)
1270
- ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1271
- cb(i);
1272
- let branchScope = writeScope(branchId, {});
1273
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1274
- });
1275
- }), loopScopes && writeScope(scopeId, {
1276
- ["A" /* BranchScopes */ + accessor]: loopScopes
1277
- });
1278
- } else
1279
- forUntil(to, from, step, cb);
1280
- writeBranchEnd(
1281
- scopeId,
1282
- accessor,
1283
- serializeStateful,
1284
- serializeMarker,
1285
- parentEndTag,
1286
- singleNode,
1287
- singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1288
- );
1413
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1414
+ if (serializeBranch !== 0) {
1415
+ let loopScopes;
1416
+ forUntil(to, from, step, (i) => {
1417
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1418
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1419
+ cb(i);
1420
+ let branchScope = writeScope(branchId, {});
1421
+ resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1422
+ });
1423
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1424
+ } else forUntil(to, from, step, cb);
1425
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1289
1426
  }
1290
1427
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1291
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id();
1292
- resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1293
- let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1294
- shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
1295
- // TODO: technically conditional renderer should only be written when either the
1296
- // condition is stateful, or if there are direct closures.
1297
- // It may make sense to pass in another arg for this.
1298
- ["D" /* ConditionalRenderer */ + accessor]: branchIndex || void 0,
1299
- // we convert 0 to undefined since the runtime defaults branch to 0.
1300
- ["A" /* BranchScopes */ + accessor]: resumeMarker ? void 0 : referenceScope(writeScope(branchId, {}))
1301
- }), writeBranchEnd(
1302
- scopeId,
1303
- accessor,
1304
- serializeStateful,
1305
- serializeMarker,
1306
- parentEndTag,
1307
- singleNode,
1308
- shouldWriteBranch ? " " + branchId : ""
1309
- );
1428
+ let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id();
1429
+ resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[", ""));
1430
+ let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1431
+ shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
1432
+ ["D" + accessor]: branchIndex || void 0,
1433
+ ["A" + accessor]: resumeMarker ? void 0 : referenceScope(writeScope(branchId, {}))
1434
+ }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
1310
1435
  }
1311
1436
  function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
1312
- let endTag = parentEndTag || "";
1313
- if (serializeMarker !== 0)
1314
- if (!parentEndTag || serializeStateful !== 0) {
1315
- let { state } = $chunk.boundary, mark = singleNode ? state.mark(
1316
- parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
1317
- scopeId + " " + accessor + (branchIds || "")
1318
- ) : state.mark(
1319
- parentEndTag ? ")" /* BranchEndOnlyChildInParent */ : "]" /* BranchEnd */,
1320
- scopeId + " " + accessor + (branchIds || "")
1321
- );
1322
- $chunk.writeHTML(mark + endTag);
1323
- } else
1324
- $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1325
- else
1326
- $chunk.writeHTML(endTag);
1437
+ let endTag = parentEndTag || "";
1438
+ if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
1439
+ let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
1440
+ $chunk.writeHTML(mark + endTag);
1441
+ } else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1442
+ else $chunk.writeHTML(endTag);
1327
1443
  }
1328
1444
  function scopeHasReference(scope) {
1329
- return !!scope[K_SCOPE_REFERENCED];
1445
+ return !!scope[K_SCOPE_REFERENCED];
1330
1446
  }
1331
1447
  function referenceScope(scope) {
1332
- return scope[K_SCOPE_REFERENCED] = 1, scope;
1448
+ return scope[K_SCOPE_REFERENCED] = 1, scope;
1333
1449
  }
1334
- var writeScope = (scopeId, partialScope) => writeScopeToState($chunk.boundary.state, scopeId, partialScope);
1335
1450
  function writeScopeToState(state, scopeId, partialScope) {
1336
- let { scopes } = state, scope = scopes.get(scopeId);
1337
- return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
1451
+ let { scopes } = state, scope = scopes.get(scopeId);
1452
+ return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
1338
1453
  }
1339
1454
  function _existing_scope(scopeId) {
1340
- return writeScope(scopeId, _scope_with_id(scopeId));
1455
+ return writeScope(scopeId, _scope_with_id(scopeId));
1341
1456
  }
1342
1457
  function _scope_with_id(scopeId) {
1343
- let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
1344
- return scope || (scope = { [K_SCOPE_ID]: scopeId }, state.scopes.set(scopeId, scope)), referenceScope(scope);
1458
+ let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
1459
+ return scope || (scope = { [K_SCOPE_ID]: scopeId }, state.scopes.set(scopeId, scope)), referenceScope(scope);
1345
1460
  }
1346
1461
  function $global() {
1347
- return $chunk.boundary.state.$global;
1462
+ return $chunk.boundary.state.$global;
1348
1463
  }
1349
1464
  function _await(scopeId, accessor, promise, content, serializeMarker) {
1350
- let resumeMarker = serializeMarker !== 0;
1351
- if (!isPromise(promise)) {
1352
- if (resumeMarker) {
1353
- let branchId = _peek_scope_id();
1354
- $chunk.writeHTML(
1355
- $chunk.boundary.state.mark("[" /* BranchStart */, "")
1356
- ), content(promise), $chunk.writeHTML(
1357
- $chunk.boundary.state.mark(
1358
- "]" /* BranchEnd */,
1359
- scopeId + " " + accessor + " " + branchId
1360
- )
1361
- );
1362
- } else
1363
- content(promise);
1364
- return;
1365
- }
1366
- let chunk = $chunk, { boundary } = chunk;
1367
- chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
1368
- (value) => {
1369
- chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
1370
- if (resumeMarker) {
1371
- let branchId = _peek_scope_id();
1372
- $chunk.writeHTML(
1373
- $chunk.boundary.state.mark("[" /* BranchStart */, "")
1374
- ), withIsAsync(content, value), $chunk.writeHTML(
1375
- $chunk.boundary.state.mark(
1376
- "]" /* BranchEnd */,
1377
- scopeId + " " + accessor + " " + branchId
1378
- )
1379
- );
1380
- } else
1381
- withIsAsync(content, value);
1382
- }), boundary.endAsync(chunk)));
1383
- },
1384
- (err) => {
1385
- chunk.async = !1, boundary.abort(err);
1386
- }
1387
- );
1465
+ let resumeMarker = serializeMarker !== 0;
1466
+ if (!isPromise(promise)) {
1467
+ if (resumeMarker) {
1468
+ let branchId = _peek_scope_id();
1469
+ $chunk.writeHTML($chunk.boundary.state.mark("[", "")), content(promise), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1470
+ } else content(promise);
1471
+ return;
1472
+ }
1473
+ let chunk = $chunk, { boundary } = chunk;
1474
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = {
1475
+ ...chunk.context,
1476
+ [kPendingContexts]: 0
1477
+ }), boundary.startAsync(), promise.then((value) => {
1478
+ chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
1479
+ if (resumeMarker) {
1480
+ let branchId = _peek_scope_id();
1481
+ $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withIsAsync(content, value), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1482
+ } else withIsAsync(content, value);
1483
+ }), boundary.endAsync(chunk)));
1484
+ }, (err) => {
1485
+ chunk.async = !1, boundary.abort(err);
1486
+ });
1388
1487
  }
1389
1488
  function _try(scopeId, accessor, content, input) {
1390
- let branchId = _peek_scope_id();
1391
- $chunk.writeHTML($chunk.boundary.state.mark("[" /* BranchStart */, ""));
1392
- let catchContent = input.catch ? normalizeDynamicRenderer(input.catch) || 0 : void 0, placeholderContent = normalizeDynamicRenderer(input.placeholder);
1393
- catchContent !== void 0 ? tryCatch(
1394
- placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId) : content,
1395
- catchContent || (() => {
1396
- })
1397
- ) : placeholderContent ? tryPlaceholder(content, placeholderContent, branchId) : content(), writeScope(branchId, {
1398
- C: accessor,
1399
- E: catchContent,
1400
- Q: placeholderContent
1401
- }), $chunk.writeHTML(
1402
- $chunk.boundary.state.mark(
1403
- "]" /* BranchEnd */,
1404
- scopeId + " " + accessor + " " + branchId
1405
- )
1406
- );
1489
+ let branchId = _peek_scope_id();
1490
+ $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
1491
+ let catchContent = input.catch ? normalizeDynamicRenderer(input.catch) || 0 : void 0, placeholderContent = normalizeDynamicRenderer(input.placeholder);
1492
+ catchContent === void 0 ? placeholderContent ? tryPlaceholder(content, placeholderContent, branchId) : content() : tryCatch(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId) : content, catchContent || (() => {})), writeScope(branchId, {
1493
+ C: accessor,
1494
+ E: catchContent,
1495
+ Q: placeholderContent
1496
+ }), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1407
1497
  }
1408
1498
  function tryPlaceholder(content, placeholder, branchId) {
1409
- let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
1410
- if (body === body.render(content)) {
1411
- chunk.append(body);
1412
- return;
1413
- }
1414
- chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.placeholderBody = body, chunk.placeholderRender = placeholder, chunk.placeholderBranchId = branchId;
1499
+ let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
1500
+ if (body === body.render(content)) {
1501
+ chunk.append(body);
1502
+ return;
1503
+ }
1504
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.placeholderBody = body, chunk.placeholderRender = placeholder, chunk.placeholderBranchId = branchId;
1415
1505
  }
1416
1506
  function tryCatch(content, catchContent) {
1417
- let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(content);
1418
- if (catchBoundary.signal.aborted) {
1419
- catchContent(catchBoundary.signal.reason);
1420
- return;
1421
- }
1422
- if (body === bodyEnd) {
1423
- chunk.append(body);
1424
- return;
1425
- }
1426
- let reorderId = state.nextReorderId(), endMarker = state.mark("!" /* PlaceholderEnd */, reorderId), bodyNext = bodyEnd.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1427
- chunk.next = body, chunk.writeHTML(state.mark("!^" /* Placeholder */, reorderId)), bodyEnd.writeHTML(endMarker), boundary.startAsync(), catchBoundary.onNext = () => {
1428
- if (!boundary.signal.aborted)
1429
- if (catchBoundary.signal.aborted) {
1430
- if (!bodyEnd.consumed) {
1431
- let cur = body, writeMarker = !0;
1432
- do {
1433
- let next = cur.next;
1434
- cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.needsWalk = !0, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1435
- } while (cur !== bodyNext);
1436
- }
1437
- let catchChunk = new Chunk(boundary, null, chunk.context);
1438
- catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1439
- } else catchBoundary.count ? boundary.onNext() : boundary.endAsync();
1440
- };
1441
- }
1442
- var State2 = class {
1443
- constructor($global2) {
1444
- this.$global = $global2;
1445
- this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " nonce" + attrAssignment($global2.cspNonce));
1446
- }
1447
- tagId = 1;
1448
- scopeId = 1;
1449
- reorderId = 1;
1450
- lastSerializedScopeId = this.scopeId;
1451
- hasGlobals = !1;
1452
- needsMainRuntime = !1;
1453
- hasMainRuntime = !1;
1454
- hasReorderRuntime = !1;
1455
- hasWrittenResume = !1;
1456
- walkOnNextFlush = !1;
1457
- trailerHTML = "";
1458
- resumes = "";
1459
- nonceAttr = "";
1460
- serializer = new Serializer();
1461
- writeReorders = null;
1462
- scopes = /* @__PURE__ */ new Map();
1463
- writeScopes = null;
1464
- ensureReady = null;
1465
- serializeReason;
1466
- get runtimePrefix() {
1467
- let { $global: $global2 } = this;
1468
- return $global2.runtimeId + "." + $global2.renderId;
1469
- }
1470
- get commentPrefix() {
1471
- let { $global: $global2 } = this;
1472
- return $global2.runtimeId + $global2.renderId;
1473
- }
1474
- reorder(chunk) {
1475
- this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
1476
- }
1477
- nextReorderId() {
1478
- let c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = this.reorderId++, r = c[n % 54];
1479
- for (n = n / 54 | 0; n; n >>>= 6)
1480
- r += c[n & 63];
1481
- return r;
1482
- }
1483
- mark(code, str) {
1484
- return "<!--" + this.commentPrefix + code + str + "-->";
1485
- }
1486
- };
1487
- var Boundary = class extends AbortController {
1488
- constructor(state, parent) {
1489
- super();
1490
- this.state = state;
1491
- this.state = state, this.signal.addEventListener("abort", () => {
1492
- this.count = 0, this.state = new State2(this.state.$global), this.onNext();
1493
- }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1494
- this.abort(parent.reason);
1495
- }));
1496
- }
1497
- onNext = NOOP;
1498
- count = 0;
1499
- flush() {
1500
- return this.signal.aborted || flushSerializer(this), this.count ? 1 /* continue */ : this.signal.aborted ? 2 /* aborted */ : 0 /* complete */;
1501
- }
1502
- startAsync() {
1503
- this.signal.aborted || this.count++;
1504
- }
1505
- endAsync(chunk) {
1506
- !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
1507
- }
1508
- }, Chunk = class {
1509
- constructor(boundary, next, context) {
1510
- this.boundary = boundary;
1511
- this.next = next;
1512
- this.context = context;
1513
- this.boundary = boundary, this.next = next, this.context = context;
1514
- }
1515
- html = "";
1516
- scripts = "";
1517
- effects = "";
1518
- lastEffect = "";
1519
- async = !1;
1520
- consumed = !1;
1521
- needsWalk = !1;
1522
- reorderId = null;
1523
- placeholderBody = null;
1524
- placeholderRender = null;
1525
- placeholderBranchId = null;
1526
- writeHTML(html) {
1527
- this.html += html;
1528
- }
1529
- writeEffect(scopeId, registryId) {
1530
- this.lastEffect === registryId ? this.effects += " " + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
1531
- }
1532
- writeScript(script) {
1533
- this.scripts = concatScripts(this.scripts, script);
1534
- }
1535
- append(chunk) {
1536
- this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect;
1537
- }
1538
- flushPlaceholder() {
1539
- if (this.placeholderBody) {
1540
- let body = this.placeholderBody.consume();
1541
- if (body.async) {
1542
- let { state } = this.boundary, reorderId = body.reorderId = this.placeholderBranchId ? this.placeholderBranchId + "" : state.nextReorderId();
1543
- this.placeholderBranchId = null, this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
1544
- let after = this.render(this.placeholderRender);
1545
- after !== this && this.boundary.abort(
1546
- new Error("An @placeholder cannot contain async content.")
1547
- ), after.writeHTML(state.mark("!" /* PlaceholderEnd */, reorderId)), state.reorder(body);
1548
- } else
1549
- body.next = this.next, this.next = body;
1550
- this.placeholderRender = this.placeholderBody = null;
1551
- }
1552
- }
1553
- consume() {
1554
- let cur = this, needsWalk = cur.needsWalk;
1555
- if (cur.next && !cur.async) {
1556
- let html = "", effects = "", scripts = "", lastEffect = "";
1557
- do
1558
- cur.flushPlaceholder(), needsWalk ||= cur.needsWalk, html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), lastEffect = cur.lastEffect || lastEffect, cur.consumed = !0, cur = cur.next;
1559
- while (cur.next && !cur.async);
1560
- cur.needsWalk = needsWalk, cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts), cur.lastEffect = lastEffect;
1561
- }
1562
- return cur;
1563
- }
1564
- render(content, val) {
1565
- let prev = $chunk;
1566
- $chunk = this;
1567
- try {
1568
- return content(val), $chunk;
1569
- } catch (err) {
1570
- return this.boundary.abort(err), this;
1571
- } finally {
1572
- $chunk = prev;
1573
- }
1574
- }
1575
- flushScript() {
1576
- let { boundary, effects } = this, { state } = boundary, { $global: $global2, runtimePrefix, nonceAttr } = state, { html, scripts } = this, needsWalk = state.walkOnNextFlush;
1577
- if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1578
- scripts,
1579
- WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1580
- )), state.ensureReady && state.hasMainRuntime) {
1581
- let first = !0;
1582
- for (let id in state.ensureReady)
1583
- state.ensureReady[id] && (state.ensureReady[id] = 0, first ? scripts = concatScripts(
1584
- scripts,
1585
- "(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1"
1586
- ) : scripts = concatScripts(
1587
- scripts,
1588
- runtimePrefix + ".b" /* Blocking */ + toAccess(toObjectKey(id)) + "=1"
1589
- )), first = !1;
1590
- }
1591
- if (effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ',"' + effects + '"' : '"' + effects + '"'), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(
1592
- scripts,
1593
- runtimePrefix + ".r.push(" + state.resumes + ")"
1594
- ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1595
- scripts,
1596
- runtimePrefix + ".r=[" + state.resumes + "]"
1597
- ))), state.writeReorders) {
1598
- needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1599
- scripts,
1600
- REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1601
- ));
1602
- for (let reorderedChunk of state.writeReorders) {
1603
- let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1604
- for (reorderedChunk.reorderId = null; ; ) {
1605
- cur.flushPlaceholder();
1606
- let { next } = cur;
1607
- if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1608
- "#" /* ReorderMarker */,
1609
- cur.reorderId = state.nextReorderId()
1610
- ), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next)
1611
- cur = next;
1612
- else
1613
- break;
1614
- }
1615
- reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1616
- scripts,
1617
- runtimePrefix + ".r=[]"
1618
- )), reorderScripts = concatScripts(
1619
- reorderScripts,
1620
- '_.push("' + reorderEffects + '")'
1621
- )), scripts = concatScripts(
1622
- scripts,
1623
- reorderScripts && runtimePrefix + ".j" /* Scripts */ + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"
1624
- ), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1625
- }
1626
- state.writeReorders = null;
1627
- }
1628
- return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
1629
- }
1630
- flushHTML() {
1631
- let { boundary } = this, { state } = boundary;
1632
- this.needsWalk && (this.needsWalk = !1, state.walkOnNextFlush = !0), this.flushScript();
1633
- let { scripts } = this, { $global: $global2, nonceAttr } = state, { __flush__ } = $global2, { html } = this;
1634
- return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, html = __flush__($global2, html)), boundary.count || (html += state.trailerHTML), html;
1635
- }
1636
- };
1507
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(content);
1508
+ if (catchBoundary.signal.aborted) {
1509
+ catchContent(catchBoundary.signal.reason);
1510
+ return;
1511
+ }
1512
+ if (body === bodyEnd) {
1513
+ chunk.append(body);
1514
+ return;
1515
+ }
1516
+ let reorderId = state.nextReorderId(), endMarker = state.mark("!", reorderId), bodyNext = bodyEnd.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1517
+ chunk.next = body, chunk.writeHTML(state.mark("!^", reorderId)), bodyEnd.writeHTML(endMarker), boundary.startAsync(), catchBoundary.onNext = () => {
1518
+ if (!boundary.signal.aborted) if (catchBoundary.signal.aborted) {
1519
+ if (!bodyEnd.consumed) {
1520
+ let cur = body, writeMarker = !0;
1521
+ do {
1522
+ let next = cur.next;
1523
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.needsWalk = !0, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1524
+ } while (cur !== bodyNext);
1525
+ }
1526
+ let catchChunk = new Chunk(boundary, null, chunk.context);
1527
+ catchChunk.reorderId = reorderId, catchChunk.render(catchContent, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1528
+ } else catchBoundary.count ? boundary.onNext() : boundary.endAsync();
1529
+ };
1530
+ }
1637
1531
  function flushSerializer(boundary) {
1638
- let { state } = boundary, { writeScopes, serializer } = state, { flushed } = serializer;
1639
- if (writeScopes || flushed) {
1640
- let shouldSerialize = !1, serializeData = [], { lastSerializedScopeId } = state;
1641
- state.hasGlobals || (state.hasGlobals = !0, serializeData.push(getFilteredGlobals(state.$global)), shouldSerialize = !0);
1642
- for (let key in writeScopes) {
1643
- let scope = writeScopes[key];
1644
- if (scopeHasReference(scope) || Object.getOwnPropertyNames(scope).length) {
1645
- let scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1646
- lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope), shouldSerialize = !0;
1647
- }
1648
- }
1649
- shouldSerialize && (state.resumes = concatSequence(
1650
- state.resumes,
1651
- serializer.stringify(serializeData, boundary)
1652
- )), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null, flushed && (state.walkOnNextFlush = !0);
1653
- }
1532
+ let { state } = boundary, { writeScopes, serializer } = state, { flushed } = serializer;
1533
+ if (writeScopes || flushed) {
1534
+ let shouldSerialize = !1, serializeData = [], { lastSerializedScopeId } = state;
1535
+ state.hasGlobals || (state.hasGlobals = !0, serializeData.push(getFilteredGlobals(state.$global)), shouldSerialize = !0);
1536
+ for (let key in writeScopes) {
1537
+ let scope = writeScopes[key];
1538
+ if (scopeHasReference(scope) || Object.getOwnPropertyNames(scope).length) {
1539
+ let scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
1540
+ lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope), shouldSerialize = !0;
1541
+ }
1542
+ }
1543
+ shouldSerialize && (state.resumes = concatSequence(state.resumes, serializer.stringify(serializeData, boundary))), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null, flushed && (state.walkOnNextFlush = !0);
1544
+ }
1654
1545
  }
1655
1546
  function _trailers(html) {
1656
- $chunk.boundary.state.trailerHTML += html;
1547
+ $chunk.boundary.state.trailerHTML += html;
1657
1548
  }
1658
1549
  function concatEffects(a, b) {
1659
- return a ? b ? a + " " + b : a : b;
1550
+ return a ? b ? a + " " + b : a : b;
1660
1551
  }
1661
1552
  function concatSequence(a, b) {
1662
- return a ? b ? a + "," + b : a : b;
1553
+ return a ? b ? a + "," + b : a : b;
1663
1554
  }
1664
1555
  function concatScripts(a, b) {
1665
- return a ? b ? a + ";" + b : a : b;
1556
+ return a ? b ? a + ";" + b : a : b;
1666
1557
  }
1667
- var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue;
1668
1558
  function queueTick(cb) {
1669
- tickQueue ? tickQueue.add(cb) : (tickQueue = /* @__PURE__ */ new Set([cb]), tick(flushTickQueue));
1559
+ tickQueue ? tickQueue.add(cb) : (tickQueue = new Set([cb]), tick(flushTickQueue));
1670
1560
  }
1671
1561
  function offTick(cb) {
1672
- tickQueue?.delete(cb);
1562
+ tickQueue?.delete(cb);
1673
1563
  }
1674
1564
  function flushTickQueue() {
1675
- let queue = tickQueue;
1676
- tickQueue = void 0;
1677
- for (let cb of queue)
1678
- cb(!0);
1565
+ let queue = tickQueue;
1566
+ tickQueue = void 0;
1567
+ for (let cb of queue) cb(!0);
1679
1568
  }
1680
1569
  function isPromise(value) {
1681
- return value != null && typeof value.then == "function";
1682
- }
1683
- function getFilteredGlobals($global2) {
1684
- if (!$global2) return 0;
1685
- let serializedGlobals = $global2.serializedGlobals;
1686
- if (!serializedGlobals) return 0;
1687
- let filtered = 0;
1688
- if (Array.isArray(serializedGlobals))
1689
- for (let key of serializedGlobals) {
1690
- let value = $global2[key];
1691
- value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1692
- }
1693
- else
1694
- for (let key in serializedGlobals)
1695
- if (serializedGlobals[key]) {
1696
- let value = $global2[key];
1697
- value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1698
- }
1699
- return filtered;
1570
+ return value != null && typeof value.then == "function";
1571
+ }
1572
+ function getFilteredGlobals($global) {
1573
+ if (!$global) return 0;
1574
+ let serializedGlobals = $global.serializedGlobals;
1575
+ if (!serializedGlobals) return 0;
1576
+ let filtered = 0;
1577
+ if (Array.isArray(serializedGlobals)) for (let key of serializedGlobals) {
1578
+ let value = $global[key];
1579
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1580
+ }
1581
+ else for (let key in serializedGlobals) if (serializedGlobals[key]) {
1582
+ let value = $global[key];
1583
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1584
+ }
1585
+ return filtered;
1700
1586
  }
1701
1587
  function _subscribe(subscribers, scope) {
1702
- return $chunk.boundary.state.serializer.writeCall(scope, subscribers, "add"), referenceScope(scope);
1588
+ return $chunk.boundary.state.serializer.writeCall(scope, subscribers, "add"), referenceScope(scope);
1703
1589
  }
1704
-
1705
- // src/html/attrs.ts
1590
+ //#endregion
1591
+ //#region src/html/attrs.ts
1706
1592
  function _attr_class(value) {
1707
- return stringAttr("class", classValue(value));
1593
+ return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
1708
1594
  }
1709
1595
  function _attr_style(value) {
1710
- return stringAttr("style", styleValue(value));
1596
+ return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1711
1597
  }
1712
1598
  function _attr_option_value(value) {
1713
- let valueAttr = _attr("value", value);
1714
- return normalizedValueMatches(getContext(kSelectedValue), value) ? valueAttr + " selected" : valueAttr;
1599
+ let valueAttr = _attr("value", value);
1600
+ return normalizedValueMatches(getContext(kSelectedValue), value) ? valueAttr + " selected" : valueAttr;
1715
1601
  }
1716
- var kSelectedValue = /* @__PURE__ */ Symbol("selectedValue");
1717
1602
  function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
1718
- valueChange && writeControlledScope(
1719
- 3 /* SelectValue */,
1720
- scopeId,
1721
- nodeAccessor,
1722
- void 0,
1723
- valueChange
1724
- ), content && withContext(kSelectedValue, value, content);
1603
+ valueChange && writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange), content && withContext(kSelectedValue, value, content);
1725
1604
  }
1726
1605
  function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1727
- return valueChange && writeControlledScope(
1728
- 2 /* InputValue */,
1729
- scopeId,
1730
- nodeAccessor,
1731
- void 0,
1732
- valueChange
1733
- ), _escape(value);
1606
+ return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange), _escape(value);
1734
1607
  }
1735
1608
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
1736
- return valueChange && writeControlledScope(
1737
- 2 /* InputValue */,
1738
- scopeId,
1739
- nodeAccessor,
1740
- void 0,
1741
- valueChange
1742
- ), _attr("value", value);
1609
+ return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange), _attr("value", value);
1743
1610
  }
1744
1611
  function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
1745
- return checkedChange && writeControlledScope(
1746
- 0 /* InputChecked */,
1747
- scopeId,
1748
- nodeAccessor,
1749
- void 0,
1750
- checkedChange
1751
- ), normalizeBoolAttrValue(checked) ? " checked" : "";
1612
+ return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange), normalizeBoolAttrValue(checked) ? " checked" : "";
1752
1613
  }
1753
1614
  function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
1754
- let valueAttr = _attr("value", value);
1755
- return checkedValueChange && writeControlledScope(
1756
- 1 /* InputCheckedValue */,
1757
- scopeId,
1758
- nodeAccessor,
1759
- getCheckedValueRef(checkedValue),
1760
- checkedValueChange
1761
- ), normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
1762
- }
1763
- var checkedValuesRefs = /* @__PURE__ */ new WeakMap();
1615
+ let valueAttr = _attr("value", value);
1616
+ return checkedValueChange && writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange), normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
1617
+ }
1764
1618
  function getCheckedValueRef(checkedValue) {
1765
- if (Array.isArray(checkedValue)) {
1766
- let ref = checkedValuesRefs.get(checkedValue);
1767
- return ref || (ref = [], checkedValuesRefs.set(checkedValue, ref)), ref;
1768
- }
1619
+ if (Array.isArray(checkedValue)) {
1620
+ let ref = checkedValuesRefs.get(checkedValue);
1621
+ return ref || (ref = [], checkedValuesRefs.set(checkedValue, ref)), ref;
1622
+ }
1769
1623
  }
1770
1624
  function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
1771
- let normalizedOpen = normalizeBoolAttrValue(open);
1772
- return openChange && writeControlledScope(
1773
- 4 /* DetailsOrDialogOpen */,
1774
- scopeId,
1775
- nodeAccessor,
1776
- normalizedOpen,
1777
- openChange
1778
- ), normalizedOpen ? " open" : "";
1625
+ let normalizedOpen = normalizeBoolAttrValue(open);
1626
+ return openChange && writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen, openChange), normalizedOpen ? " open" : "";
1779
1627
  }
1780
1628
  function _attr_nonce() {
1781
- return getChunk().boundary.state.nonceAttr;
1629
+ return getChunk().boundary.state.nonceAttr;
1782
1630
  }
1783
1631
  function _attr(name, value) {
1784
- return isVoid(value) ? "" : nonVoidAttr(name, value);
1632
+ return isVoid(value) ? "" : nonVoidAttr(name, value);
1785
1633
  }
1786
1634
  function _attrs(data, nodeAccessor, scopeId, tagName) {
1787
- let result = "", skip = /[\s/>"'=]/, events;
1788
- switch (tagName) {
1789
- case "input":
1790
- if (data.checkedChange)
1791
- result += _attr_input_checked(
1792
- scopeId,
1793
- nodeAccessor,
1794
- data.checked,
1795
- data.checkedChange
1796
- );
1797
- else if (data.checkedValue || data.checkedValueChange)
1798
- result += _attr_input_checkedValue(
1799
- scopeId,
1800
- nodeAccessor,
1801
- data.checkedValue,
1802
- data.checkedValueChange,
1803
- data.value
1804
- );
1805
- else if (data.valueChange)
1806
- result += _attr_input_value(
1807
- scopeId,
1808
- nodeAccessor,
1809
- data.value,
1810
- data.valueChange
1811
- );
1812
- else
1813
- break;
1814
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1815
- break;
1816
- case "select":
1817
- case "textarea":
1818
- (data.value || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1819
- break;
1820
- case "option":
1821
- data.value && (result += _attr_option_value(data.value), skip = /^value$|[\s/>"'=]/);
1822
- break;
1823
- case "details":
1824
- case "dialog":
1825
- data.openChange && (result += _attr_details_or_dialog_open(
1826
- scopeId,
1827
- nodeAccessor,
1828
- data.open,
1829
- data.openChange
1830
- ), skip = /^open(?:Change)?$|[\s/>"'=]/);
1831
- break;
1832
- }
1833
- for (let name in data) {
1834
- let value = data[name];
1835
- switch (name) {
1836
- case "class":
1837
- result += _attr_class(value);
1838
- break;
1839
- case "style":
1840
- result += _attr_style(value);
1841
- break;
1842
- default:
1843
- name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, {
1844
- ["I" /* EventAttributes */ + nodeAccessor]: events
1845
- })), events[getEventHandlerName(name)] = value) : result += nonVoidAttr(name, value));
1846
- break;
1847
- }
1848
- }
1849
- return result;
1635
+ let result = "", skip = /[\s/>"'=]/, events;
1636
+ switch (tagName) {
1637
+ case "input":
1638
+ if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange);
1639
+ else if (data.checkedValue || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value);
1640
+ else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange);
1641
+ else break;
1642
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1643
+ break;
1644
+ case "select":
1645
+ case "textarea":
1646
+ (data.value || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1647
+ break;
1648
+ case "option":
1649
+ data.value && (result += _attr_option_value(data.value), skip = /^value$|[\s/>"'=]/);
1650
+ break;
1651
+ case "details":
1652
+ case "dialog":
1653
+ data.openChange && (result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange), skip = /^open(?:Change)?$|[\s/>"'=]/);
1654
+ break;
1655
+ }
1656
+ for (let name in data) {
1657
+ let value = data[name];
1658
+ switch (name) {
1659
+ case "class":
1660
+ result += _attr_class(value);
1661
+ break;
1662
+ case "style":
1663
+ result += _attr_style(value);
1664
+ break;
1665
+ default:
1666
+ name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventHandlerName(name)] = value) : result += nonVoidAttr(name, value));
1667
+ break;
1668
+ }
1669
+ }
1670
+ return result;
1850
1671
  }
1851
1672
  function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
1852
- _html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1673
+ _html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1853
1674
  }
1854
1675
  function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
1855
- let partial = {};
1856
- for (let name in data) {
1857
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
1858
- skip[key] || (partial[key] = data[name]);
1859
- }
1860
- return _attrs(partial, nodeAccessor, scopeId, tagName);
1676
+ let partial = {};
1677
+ for (let name in data) {
1678
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
1679
+ skip[key] || (partial[key] = data[name]);
1680
+ }
1681
+ return _attrs(partial, nodeAccessor, scopeId, tagName);
1861
1682
  }
1862
1683
  function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
1863
- _html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1684
+ _html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`), _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
1864
1685
  }
1865
1686
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
1866
- writeScope(scopeId, {
1867
- ["F" /* ControlledType */ + nodeAccessor]: type,
1868
- ["G" /* ControlledValue */ + nodeAccessor]: value,
1869
- ["E" /* ControlledHandler */ + nodeAccessor]: valueChange
1870
- });
1687
+ writeScope(scopeId, {
1688
+ ["F" + nodeAccessor]: type,
1689
+ ["G" + nodeAccessor]: value,
1690
+ ["E" + nodeAccessor]: valueChange
1691
+ });
1871
1692
  }
1872
1693
  function stringAttr(name, value) {
1873
- return value && " " + name + attrAssignment(value);
1694
+ return value && " " + name + attrAssignment(value);
1874
1695
  }
1875
1696
  function nonVoidAttr(name, value) {
1876
- switch (typeof value) {
1877
- case "string":
1878
- return " " + name + attrAssignment(value);
1879
- case "boolean":
1880
- return " " + name;
1881
- case "number":
1882
- return " " + name + "=" + value;
1883
- case "object":
1884
- if (value instanceof RegExp)
1885
- return " " + name + attrAssignment(value.source);
1886
- break;
1887
- }
1888
- return " " + name + attrAssignment(value + "");
1889
- }
1890
- var singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g, doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g, needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
1697
+ switch (typeof value) {
1698
+ case "string": return " " + name + attrAssignment(value);
1699
+ case "boolean": return " " + name;
1700
+ case "number": return " " + name + "=" + value;
1701
+ case "object":
1702
+ if (value instanceof RegExp) return " " + name + attrAssignment(value.source);
1703
+ break;
1704
+ }
1705
+ return " " + name + attrAssignment(value + "");
1706
+ }
1891
1707
  function attrAssignment(value) {
1892
- return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, '"') ? "='" + escapeSingleQuotedAttrValue(value) + "'" : '="' + escapeDoubleQuotedAttrValue(value) + '"' : "=" + value : "";
1708
+ return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
1893
1709
  }
1894
1710
  function escapeSingleQuotedAttrValue(value) {
1895
- return singleQuoteAttrReplacements.test(value) ? value.replace(
1896
- singleQuoteAttrReplacements,
1897
- replaceUnsafeSingleQuoteAttrChar
1898
- ) : value;
1711
+ return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
1899
1712
  }
1900
1713
  function replaceUnsafeSingleQuoteAttrChar(match) {
1901
- return match === "'" ? "&#39;" : "&amp;";
1714
+ return match === "'" ? "&#39;" : "&amp;";
1902
1715
  }
1903
1716
  function escapeDoubleQuotedAttrValue(value) {
1904
- return doubleQuoteAttrReplacements.test(value) ? value.replace(
1905
- doubleQuoteAttrReplacements,
1906
- replaceUnsafeDoubleQuoteAttrChar
1907
- ) : value;
1717
+ return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
1908
1718
  }
1909
1719
  function replaceUnsafeDoubleQuoteAttrChar(match) {
1910
- return match === '"' ? "&#34;" : "&amp;";
1720
+ return match === "\"" ? "&#34;" : "&amp;";
1911
1721
  }
1912
1722
  function normalizedValueMatches(a, b) {
1913
- let value = normalizeStrAttrValue(b);
1914
- if (Array.isArray(a)) {
1915
- for (let item of a)
1916
- if (normalizeStrAttrValue(item) === value)
1917
- return !0;
1918
- } else if (normalizeStrAttrValue(a) === value)
1919
- return !0;
1920
- return !1;
1723
+ let value = normalizeStrAttrValue(b);
1724
+ if (Array.isArray(a)) {
1725
+ for (let item of a) if (normalizeStrAttrValue(item) === value) return !0;
1726
+ } else if (normalizeStrAttrValue(a) === value) return !0;
1727
+ return !1;
1921
1728
  }
1922
1729
  function normalizeStrAttrValue(value) {
1923
- return value && value !== !0 || value === 0 ? value + "" : "";
1730
+ return value && value !== !0 || value === 0 ? value + "" : "";
1924
1731
  }
1925
1732
  function normalizeBoolAttrValue(value) {
1926
- if (value != null && value !== !1)
1927
- return !0;
1928
- }
1929
-
1930
- // src/common/compat-meta.ts
1931
- var RENDERER_REGISTER_ID = "$C_r", SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b";
1932
-
1933
- // src/html/dynamic-tag.ts
1934
- var voidElementsReg = (
1935
- /* cspell:disable-next-line */
1936
- /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/
1937
- ), _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
1938
- let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
1939
- if (typeof renderer == "string") {
1940
- let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
1941
- if (rendered = !0, _scope_id(), _html(
1942
- `<${renderer}${_attrs(input, "a", branchId, renderer)}>`
1943
- ), !voidElementsReg.test(renderer)) {
1944
- let renderContent = content || normalizeDynamicRenderer(input.content);
1945
- if (renderer === "textarea")
1946
- _html(
1947
- _attr_textarea_value(
1948
- branchId,
1949
- "a",
1950
- input.value,
1951
- input.valueChange
1952
- )
1953
- );
1954
- else if (renderContent) {
1955
- if (typeof renderContent != "function")
1956
- throw new Error(
1957
- `Body content is not supported for the \`<${renderer}>\` tag.`
1958
- );
1959
- renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(
1960
- branchId,
1961
- "a",
1962
- input.value,
1963
- input.valueChange,
1964
- renderContent
1965
- ) : _dynamic_tag(
1966
- branchId,
1967
- "a",
1968
- renderContent,
1969
- void 0,
1970
- 0,
1971
- void 0,
1972
- serializeReason
1973
- );
1974
- }
1975
- _html(`</${renderer}>`);
1976
- }
1977
- let childScope = getScopeById(branchId), needsScript = childScope && (childScope["Ia"] || childScope["Ea"]);
1978
- needsScript && (childScope.R = renderer, _script(branchId, "d")), (shouldResume || needsScript) && _html(
1979
- state.mark(
1980
- "'" /* BranchEndNativeTag */,
1981
- scopeId + " " + accessor + " " + branchId
1982
- )
1983
- );
1984
- } else {
1985
- shouldResume && _html(state.mark("[" /* BranchStart */, ""));
1986
- let render2 = () => {
1987
- if (renderer)
1988
- try {
1989
- return _set_serialize_reason(
1990
- shouldResume && inputOrArgs !== void 0 ? 1 : 0
1991
- ), inputIsArgs ? renderer(...inputOrArgs) : renderer(
1992
- content ? { ...inputOrArgs, content } : inputOrArgs
1993
- );
1994
- } finally {
1995
- _set_serialize_reason(void 0);
1996
- }
1997
- else if (content)
1998
- return content();
1999
- };
2000
- result = shouldResume ? withBranchId(branchId, render2) : render2(), rendered = _peek_scope_id() !== branchId, shouldResume && _html(
2001
- state.mark(
2002
- "]" /* BranchEnd */,
2003
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
2004
- )
2005
- );
2006
- }
2007
- return rendered ? shouldResume && writeScope(scopeId, {
2008
- ["D" /* ConditionalRenderer */ + accessor]: renderer?.a || renderer
2009
- }) : _scope_id(), result;
2010
- };
1733
+ if (value != null && value !== !1) return !0;
1734
+ }
1735
+ //#endregion
1736
+ //#region src/common/compat-meta.ts
1737
+ //#endregion
1738
+ //#region src/html/dynamic-tag.ts
2011
1739
  function _content(id, fn) {
2012
- return fn.a = id, fn;
1740
+ return fn.a = id, fn;
2013
1741
  }
2014
1742
  function _content_resume(id, fn, scopeId) {
2015
- return _resume(_content(id, fn), id, scopeId);
2016
- }
2017
- var patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
2018
- _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2019
- let patched = patch(tag, scopeId, accessor);
2020
- return patched !== tag && (patched.a = tag), originalDynamicTag(
2021
- scopeId,
2022
- accessor,
2023
- patched,
2024
- input,
2025
- content,
2026
- inputIsArgs,
2027
- resume
2028
- );
2029
- };
2030
- })(_dynamic_tag);
2031
-
2032
- // src/html/compat.ts
2033
- var K_TAGS_API_STATE = /* @__PURE__ */ Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
2034
- $global,
2035
- fork: _await,
2036
- write: _html,
2037
- writeScript,
2038
- nextScopeId: _scope_id,
2039
- peekNextScopeId: _peek_scope_id,
2040
- isInResumedBranch,
2041
- ensureState($global2) {
2042
- let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
2043
- return state || ($global2.runtimeId ||= "M", $global2.renderId ||= $global2.componentIdPrefix || $global2.widgetIdPrefix || "_", $global2[K_TAGS_API_STATE] = state = new State2($global2)), state;
2044
- },
2045
- isTagsAPI(fn) {
2046
- return !!fn.a;
2047
- },
2048
- onFlush(fn) {
2049
- let { flushHTML } = Chunk.prototype;
2050
- Chunk.prototype.flushHTML = function() {
2051
- return fn(this), flushHTML.call(this);
2052
- };
2053
- },
2054
- patchDynamicTag,
2055
- writeSetScopeForComponent(branchId, m5c, m5i) {
2056
- writeScope(branchId, { m5c, m5i }), _script(branchId, SET_SCOPE_REGISTER_ID);
2057
- },
2058
- toJSON(state) {
2059
- return function() {
2060
- let compatRegistered = COMPAT_REGISTRY.get(this);
2061
- if (!compatRegistered) {
2062
- let registered = getRegistered(this);
2063
- if (registered) {
2064
- let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
2065
- scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(
2066
- this,
2067
- compatRegistered = [registered.id, scopeId]
2068
- );
2069
- }
2070
- }
2071
- return compatRegistered;
2072
- };
2073
- },
2074
- flushScript($global2) {
2075
- let boundary = new Boundary(this.ensureState($global2));
2076
- if (boundary.flush() === 1 /* continue */)
2077
- throw new Error(
2078
- "Cannot serialize promise across tags/class compat layer."
2079
- );
2080
- return new Chunk(boundary, null, null).flushScript().scripts;
2081
- },
2082
- render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
2083
- let boundary = new Boundary(this.ensureState(classAPIOut.global)), head = new Chunk(
2084
- boundary,
2085
- null,
2086
- null
2087
- ), normalizedInput = input;
2088
- if ("renderBody" in input) {
2089
- normalizedInput = {};
2090
- for (let key in input)
2091
- normalizedInput[key === "renderBody" ? "content" : key] = input[key];
2092
- }
2093
- head.render(() => {
2094
- if (willRerender) {
2095
- let scopeId = _peek_scope_id();
2096
- writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
2097
- }
2098
- _set_serialize_reason(willRerender ? 1 : 0);
2099
- try {
2100
- renderer(normalizedInput);
2101
- } finally {
2102
- _set_serialize_reason(void 0);
2103
- }
2104
- let asyncOut = classAPIOut.beginAsync({ last: !0, timeout: -1 });
2105
- classAPIOut.onLast((next) => {
2106
- (boundary.onNext = () => {
2107
- boundary.signal.aborted ? (asyncOut.error(boundary.signal.reason), boundary.onNext = NOOP2) : boundary.count || (boundary.onNext = NOOP2, head = head.consume(), asyncOut.write(head.html), asyncOut.script(head.scripts), asyncOut.end(), head.html = head.scripts = "", completeChunks.push(head), next());
2108
- })();
2109
- });
2110
- });
2111
- },
2112
- registerRenderer(renderer, id) {
2113
- return register(
2114
- RENDERER_REGISTER_ID,
2115
- renderer,
2116
- register(id, () => {
2117
- })
2118
- );
2119
- },
2120
- registerRenderBody(fn) {
2121
- register(RENDER_BODY_ID, fn);
2122
- }
2123
- };
2124
- function NOOP2() {
1743
+ return _resume(_content(id, fn), id, scopeId);
2125
1744
  }
2126
-
2127
- // src/html/template.ts
2128
- var _template = (templateId, renderer, page) => (renderer.render = render, renderer.b = !page, renderer._ = renderer, _content_resume(templateId, renderer));
1745
+ //#endregion
1746
+ //#region src/html/compat.ts
1747
+ function NOOP$1() {}
1748
+ //#endregion
1749
+ //#region src/html/template.ts
2129
1750
  function render(input = {}) {
2130
- let { $global: $global2 } = input;
2131
- $global2 ? ({ $global: $global2, ...input } = input, $global2 = {
2132
- runtimeId: "M",
2133
- renderId: getDefaultRenderId(this),
2134
- ...$global2
2135
- }) : $global2 = {
2136
- runtimeId: "M",
2137
- renderId: getDefaultRenderId(this)
2138
- };
2139
- let state = new State2($global2), head = new Chunk(new Boundary(state, $global2.signal), null, null);
2140
- return this.b && ((state.ensureReady ||= {})[this.a] = 1), head.render(this, input), new ServerRendered(head);
1751
+ let { $global } = input;
1752
+ $global ? ({$global, ...input} = input, $global = {
1753
+ runtimeId: "M",
1754
+ renderId: getDefaultRenderId(this),
1755
+ ...$global
1756
+ }) : $global = {
1757
+ runtimeId: "M",
1758
+ renderId: getDefaultRenderId(this)
1759
+ };
1760
+ let state = new State($global), head = new Chunk(new Boundary(state, $global.signal), null, null);
1761
+ return this.i && ((state.ensureReady ||= {})[this.a] = 1), head.render(this, input), new ServerRendered(head);
2141
1762
  }
2142
1763
  function getDefaultRenderId(template) {
2143
- if (template.b) {
2144
- let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 53];
2145
- for (n = n / 53 | 0; n; n >>>= 6)
2146
- r += ENCODE_CHARS[n & 63];
2147
- return r;
2148
- }
2149
- return "_";
2150
- }
2151
- var ServerRendered = class {
2152
- #head;
2153
- #cachedPromise = null;
2154
- constructor(head) {
2155
- this.#head = head;
2156
- }
2157
- [Symbol.asyncIterator]() {
2158
- let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read(
2159
- (html) => {
2160
- value += html, resolve && (resolve({ value, done }), value = "");
2161
- },
2162
- (err) => {
2163
- aborted = !0, reason = err, reject && reject(err);
2164
- },
2165
- () => {
2166
- done = !0, resolve && (resolve({ value, done: !value }), value = "");
2167
- }
2168
- );
2169
- return {
2170
- next() {
2171
- if (aborted)
2172
- return Promise.reject(reason);
2173
- if (value) {
2174
- let result = { value, done: !1 };
2175
- return value = "", Promise.resolve(result);
2176
- } else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
2177
- },
2178
- throw(error) {
2179
- return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
2180
- },
2181
- return(value2) {
2182
- return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
2183
- }
2184
- };
2185
- function exec(_resolve, _reject) {
2186
- resolve = _resolve, reject = _reject;
2187
- }
2188
- }
2189
- pipe(stream) {
2190
- this.#read(
2191
- (html) => {
2192
- stream.write(html);
2193
- },
2194
- (err) => {
2195
- let socket = "socket" in stream && stream.socket;
2196
- if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err))
2197
- throw err;
2198
- },
2199
- () => {
2200
- stream.end();
2201
- }
2202
- );
2203
- }
2204
- toReadable() {
2205
- let cancelled = !1, boundary, encoder = new TextEncoder();
2206
- return new ReadableStream({
2207
- start: (ctrl) => {
2208
- boundary = this.#read(
2209
- (html) => {
2210
- ctrl.enqueue(encoder.encode(html));
2211
- },
2212
- (err) => {
2213
- boundary = void 0, cancelled || ctrl.error(err);
2214
- },
2215
- () => {
2216
- boundary = void 0, ctrl.close();
2217
- }
2218
- );
2219
- },
2220
- cancel: (reason) => {
2221
- cancelled = !0, boundary?.abort(reason);
2222
- }
2223
- });
2224
- }
2225
- then(onfulfilled, onrejected) {
2226
- return this.#promise().then(onfulfilled, onrejected);
2227
- }
2228
- catch(onrejected) {
2229
- return this.#promise().catch(onrejected);
2230
- }
2231
- finally(onfinally) {
2232
- return this.#promise().finally(onfinally);
2233
- }
2234
- #promise() {
2235
- return this.#cachedPromise ||= new Promise((resolve, reject) => {
2236
- let head = this.#head;
2237
- if (this.#head = null, !head)
2238
- return reject(new Error("Cannot read from a consumed render result"));
2239
- let { boundary } = head;
2240
- (boundary.onNext = () => {
2241
- switch (!boundary.count && boundary.flush()) {
2242
- case 2 /* aborted */:
2243
- boundary.onNext = NOOP3, reject(boundary.signal.reason);
2244
- break;
2245
- case 0 /* complete */:
2246
- resolve(head.consume().flushHTML());
2247
- break;
2248
- }
2249
- })();
2250
- });
2251
- }
2252
- #read(onWrite, onAbort, onClose) {
2253
- let tick2 = !0, head = this.#head;
2254
- if (this.#head = null, !head) {
2255
- onAbort(new Error("Cannot read from a consumed render result"));
2256
- return;
2257
- }
2258
- let { boundary } = head, onNext = boundary.onNext = (write) => {
2259
- let status = boundary.flush();
2260
- if (status === 2 /* aborted */)
2261
- tick2 || offTick(onNext), boundary.onNext = NOOP3, onAbort(boundary.signal.reason);
2262
- else if (write || status === 0 /* complete */) {
2263
- let html = (head = head.consume()).flushHTML();
2264
- html && onWrite(html), status === 0 /* complete */ ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2265
- } else tick2 && (tick2 = !1, queueTick(onNext));
2266
- };
2267
- return onNext(), boundary;
2268
- }
2269
- toString() {
2270
- let head = this.#head;
2271
- if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
2272
- let { boundary } = head;
2273
- switch (boundary.flush()) {
2274
- case 2 /* aborted */:
2275
- throw boundary.signal.reason;
2276
- case 1 /* continue */:
2277
- throw new Error("Cannot consume asynchronous render with 'toString'");
2278
- }
2279
- return head.consume().flushHTML();
2280
- }
2281
- };
2282
- function NOOP3() {
2283
- }
2284
- export {
2285
- $global,
2286
- _assert_hoist,
2287
- _attr,
2288
- _attr_class,
2289
- _attr_content,
2290
- _attr_details_or_dialog_open as _attr_details_open,
2291
- _attr_details_or_dialog_open as _attr_dialog_open,
2292
- _attr_input_checked,
2293
- _attr_input_checkedValue,
2294
- _attr_input_value,
2295
- _attr_nonce,
2296
- _attr_option_value,
2297
- _attr_select_value,
2298
- _attr_style,
2299
- _attr_textarea_value,
2300
- _attrs,
2301
- _attrs_content,
2302
- _attrs_partial,
2303
- _attrs_partial_content,
2304
- _await,
2305
- _content,
2306
- _content_resume,
2307
- _dynamic_tag,
2308
- _el,
2309
- _el_read_error,
2310
- _el_resume,
2311
- _escape,
2312
- _escape_comment,
2313
- _escape_script,
2314
- _escape_style,
2315
- _existing_scope,
2316
- _for_in,
2317
- _for_of,
2318
- _for_to,
2319
- _for_until,
2320
- _hoist,
2321
- _hoist_read_error,
2322
- _html,
2323
- _id,
2324
- _if,
2325
- _peek_scope_id,
2326
- _resume,
2327
- _resume_branch,
2328
- writeScope as _scope,
2329
- _scope_id,
2330
- _scope_reason,
2331
- _scope_with_id,
2332
- _script,
2333
- _sep,
2334
- _serialize_guard,
2335
- _serialize_if,
2336
- _set_serialize_reason,
2337
- _subscribe,
2338
- _template,
2339
- _trailers,
2340
- _try,
2341
- _unescaped,
2342
- _var,
2343
- attrTag,
2344
- attrTags,
2345
- compat,
2346
- forIn,
2347
- forInBy,
2348
- forOf,
2349
- forOfBy,
2350
- forStepBy,
2351
- forTo,
2352
- forUntil
2353
- };
1764
+ if (template.i) {
1765
+ let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 53];
1766
+ for (n = n / 53 | 0; n; n >>>= 6) r += ENCODE_CHARS[n & 63];
1767
+ return r;
1768
+ }
1769
+ return "_";
1770
+ }
1771
+ function NOOP() {}
1772
+ //#endregion
1773
+ export { $global, _assert_hoist, _attr, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil };