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