Bingo board for a D&D session I play in bingo.lesbian.skin/
gleam bingo dnd

Untrack generated JS file

Signed-off-by: Naomi Roberts <mia@naomieow.xyz>

lesbian.skin 06377675 43e53ada

verified
-7847
-7847
priv/static/voyagers_bingo.mjs
··· 1 - // build/dev/javascript/gleam_stdlib/gleam/bool.mjs 2 - function guard(requirement, consequence, alternative) { 3 - if (requirement) { 4 - return consequence; 5 - } else { 6 - return alternative(); 7 - } 8 - } 9 - function lazy_guard(requirement, consequence, alternative) { 10 - if (requirement) { 11 - return consequence(); 12 - } else { 13 - return alternative(); 14 - } 15 - } 16 - 17 - // build/dev/javascript/prelude.mjs 18 - var CustomType = class { 19 - withFields(fields) { 20 - let properties = Object.keys(this).map( 21 - (label) => label in fields ? fields[label] : this[label] 22 - ); 23 - return new this.constructor(...properties); 24 - } 25 - }; 26 - var List = class { 27 - static fromArray(array4, tail) { 28 - let t = tail || new Empty(); 29 - for (let i = array4.length - 1; i >= 0; --i) { 30 - t = new NonEmpty(array4[i], t); 31 - } 32 - return t; 33 - } 34 - [Symbol.iterator]() { 35 - return new ListIterator(this); 36 - } 37 - toArray() { 38 - return [...this]; 39 - } 40 - // @internal 41 - atLeastLength(desired) { 42 - let current = this; 43 - while (desired-- > 0 && current) current = current.tail; 44 - return current !== void 0; 45 - } 46 - // @internal 47 - hasLength(desired) { 48 - let current = this; 49 - while (desired-- > 0 && current) current = current.tail; 50 - return desired === -1 && current instanceof Empty; 51 - } 52 - // @internal 53 - countLength() { 54 - let current = this; 55 - let length4 = 0; 56 - while (current) { 57 - current = current.tail; 58 - length4++; 59 - } 60 - return length4 - 1; 61 - } 62 - }; 63 - function prepend(element4, tail) { 64 - return new NonEmpty(element4, tail); 65 - } 66 - function toList(elements, tail) { 67 - return List.fromArray(elements, tail); 68 - } 69 - var ListIterator = class { 70 - #current; 71 - constructor(current) { 72 - this.#current = current; 73 - } 74 - next() { 75 - if (this.#current instanceof Empty) { 76 - return { done: true }; 77 - } else { 78 - let { head, tail } = this.#current; 79 - this.#current = tail; 80 - return { value: head, done: false }; 81 - } 82 - } 83 - }; 84 - var Empty = class extends List { 85 - }; 86 - var NonEmpty = class extends List { 87 - constructor(head, tail) { 88 - super(); 89 - this.head = head; 90 - this.tail = tail; 91 - } 92 - }; 93 - var BitArray = class { 94 - /** 95 - * The size in bits of this bit array's data. 96 - * 97 - * @type {number} 98 - */ 99 - bitSize; 100 - /** 101 - * The size in bytes of this bit array's data. If this bit array doesn't store 102 - * a whole number of bytes then this value is rounded up. 103 - * 104 - * @type {number} 105 - */ 106 - byteSize; 107 - /** 108 - * The number of unused high bits in the first byte of this bit array's 109 - * buffer prior to the start of its data. The value of any unused high bits is 110 - * undefined. 111 - * 112 - * The bit offset will be in the range 0-7. 113 - * 114 - * @type {number} 115 - */ 116 - bitOffset; 117 - /** 118 - * The raw bytes that hold this bit array's data. 119 - * 120 - * If `bitOffset` is not zero then there are unused high bits in the first 121 - * byte of this buffer. 122 - * 123 - * If `bitOffset + bitSize` is not a multiple of 8 then there are unused low 124 - * bits in the last byte of this buffer. 125 - * 126 - * @type {Uint8Array} 127 - */ 128 - rawBuffer; 129 - /** 130 - * Constructs a new bit array from a `Uint8Array`, an optional size in 131 - * bits, and an optional bit offset. 132 - * 133 - * If no bit size is specified it is taken as `buffer.length * 8`, i.e. all 134 - * bytes in the buffer make up the new bit array's data. 135 - * 136 - * If no bit offset is specified it defaults to zero, i.e. there are no unused 137 - * high bits in the first byte of the buffer. 138 - * 139 - * @param {Uint8Array} buffer 140 - * @param {number} [bitSize] 141 - * @param {number} [bitOffset] 142 - */ 143 - constructor(buffer, bitSize, bitOffset) { 144 - if (!(buffer instanceof Uint8Array)) { 145 - throw globalThis.Error( 146 - "BitArray can only be constructed from a Uint8Array" 147 - ); 148 - } 149 - this.bitSize = bitSize ?? buffer.length * 8; 150 - this.byteSize = Math.trunc((this.bitSize + 7) / 8); 151 - this.bitOffset = bitOffset ?? 0; 152 - if (this.bitSize < 0) { 153 - throw globalThis.Error(`BitArray bit size is invalid: ${this.bitSize}`); 154 - } 155 - if (this.bitOffset < 0 || this.bitOffset > 7) { 156 - throw globalThis.Error( 157 - `BitArray bit offset is invalid: ${this.bitOffset}` 158 - ); 159 - } 160 - if (buffer.length !== Math.trunc((this.bitOffset + this.bitSize + 7) / 8)) { 161 - throw globalThis.Error("BitArray buffer length is invalid"); 162 - } 163 - this.rawBuffer = buffer; 164 - } 165 - /** 166 - * Returns a specific byte in this bit array. If the byte index is out of 167 - * range then `undefined` is returned. 168 - * 169 - * When returning the final byte of a bit array with a bit size that's not a 170 - * multiple of 8, the content of the unused low bits are undefined. 171 - * 172 - * @param {number} index 173 - * @returns {number | undefined} 174 - */ 175 - byteAt(index4) { 176 - if (index4 < 0 || index4 >= this.byteSize) { 177 - return void 0; 178 - } 179 - return bitArrayByteAt(this.rawBuffer, this.bitOffset, index4); 180 - } 181 - /** @internal */ 182 - equals(other) { 183 - if (this.bitSize !== other.bitSize) { 184 - return false; 185 - } 186 - const wholeByteCount = Math.trunc(this.bitSize / 8); 187 - if (this.bitOffset === 0 && other.bitOffset === 0) { 188 - for (let i = 0; i < wholeByteCount; i++) { 189 - if (this.rawBuffer[i] !== other.rawBuffer[i]) { 190 - return false; 191 - } 192 - } 193 - const trailingBitsCount = this.bitSize % 8; 194 - if (trailingBitsCount) { 195 - const unusedLowBitCount = 8 - trailingBitsCount; 196 - if (this.rawBuffer[wholeByteCount] >> unusedLowBitCount !== other.rawBuffer[wholeByteCount] >> unusedLowBitCount) { 197 - return false; 198 - } 199 - } 200 - } else { 201 - for (let i = 0; i < wholeByteCount; i++) { 202 - const a = bitArrayByteAt(this.rawBuffer, this.bitOffset, i); 203 - const b = bitArrayByteAt(other.rawBuffer, other.bitOffset, i); 204 - if (a !== b) { 205 - return false; 206 - } 207 - } 208 - const trailingBitsCount = this.bitSize % 8; 209 - if (trailingBitsCount) { 210 - const a = bitArrayByteAt( 211 - this.rawBuffer, 212 - this.bitOffset, 213 - wholeByteCount 214 - ); 215 - const b = bitArrayByteAt( 216 - other.rawBuffer, 217 - other.bitOffset, 218 - wholeByteCount 219 - ); 220 - const unusedLowBitCount = 8 - trailingBitsCount; 221 - if (a >> unusedLowBitCount !== b >> unusedLowBitCount) { 222 - return false; 223 - } 224 - } 225 - } 226 - return true; 227 - } 228 - /** 229 - * Returns this bit array's internal buffer. 230 - * 231 - * @deprecated Use `BitArray.byteAt()` or `BitArray.rawBuffer` instead. 232 - * 233 - * @returns {Uint8Array} 234 - */ 235 - get buffer() { 236 - bitArrayPrintDeprecationWarning( 237 - "buffer", 238 - "Use BitArray.byteAt() or BitArray.rawBuffer instead" 239 - ); 240 - if (this.bitOffset !== 0 || this.bitSize % 8 !== 0) { 241 - throw new globalThis.Error( 242 - "BitArray.buffer does not support unaligned bit arrays" 243 - ); 244 - } 245 - return this.rawBuffer; 246 - } 247 - /** 248 - * Returns the length in bytes of this bit array's internal buffer. 249 - * 250 - * @deprecated Use `BitArray.bitSize` or `BitArray.byteSize` instead. 251 - * 252 - * @returns {number} 253 - */ 254 - get length() { 255 - bitArrayPrintDeprecationWarning( 256 - "length", 257 - "Use BitArray.bitSize or BitArray.byteSize instead" 258 - ); 259 - if (this.bitOffset !== 0 || this.bitSize % 8 !== 0) { 260 - throw new globalThis.Error( 261 - "BitArray.length does not support unaligned bit arrays" 262 - ); 263 - } 264 - return this.rawBuffer.length; 265 - } 266 - }; 267 - function bitArrayByteAt(buffer, bitOffset, index4) { 268 - if (bitOffset === 0) { 269 - return buffer[index4] ?? 0; 270 - } else { 271 - const a = buffer[index4] << bitOffset & 255; 272 - const b = buffer[index4 + 1] >> 8 - bitOffset; 273 - return a | b; 274 - } 275 - } 276 - var UtfCodepoint = class { 277 - constructor(value) { 278 - this.value = value; 279 - } 280 - }; 281 - var isBitArrayDeprecationMessagePrinted = {}; 282 - function bitArrayPrintDeprecationWarning(name, message) { 283 - if (isBitArrayDeprecationMessagePrinted[name]) { 284 - return; 285 - } 286 - console.warn( 287 - `Deprecated BitArray.${name} property used in JavaScript FFI code. ${message}.` 288 - ); 289 - isBitArrayDeprecationMessagePrinted[name] = true; 290 - } 291 - function toBitArray(segments) { 292 - if (segments.length === 0) { 293 - return new BitArray(new Uint8Array()); 294 - } 295 - if (segments.length === 1) { 296 - const segment = segments[0]; 297 - if (segment instanceof BitArray) { 298 - return segment; 299 - } 300 - if (segment instanceof Uint8Array) { 301 - return new BitArray(segment); 302 - } 303 - return new BitArray(new Uint8Array( 304 - /** @type {number[]} */ 305 - segments 306 - )); 307 - } 308 - let bitSize = 0; 309 - let areAllSegmentsNumbers = true; 310 - for (const segment of segments) { 311 - if (segment instanceof BitArray) { 312 - bitSize += segment.bitSize; 313 - areAllSegmentsNumbers = false; 314 - } else if (segment instanceof Uint8Array) { 315 - bitSize += segment.byteLength * 8; 316 - areAllSegmentsNumbers = false; 317 - } else { 318 - bitSize += 8; 319 - } 320 - } 321 - if (areAllSegmentsNumbers) { 322 - return new BitArray(new Uint8Array( 323 - /** @type {number[]} */ 324 - segments 325 - )); 326 - } 327 - const buffer = new Uint8Array(Math.trunc((bitSize + 7) / 8)); 328 - let cursor = 0; 329 - for (let segment of segments) { 330 - const isCursorByteAligned = cursor % 8 === 0; 331 - if (segment instanceof BitArray) { 332 - if (isCursorByteAligned && segment.bitOffset === 0) { 333 - buffer.set(segment.rawBuffer, cursor / 8); 334 - cursor += segment.bitSize; 335 - const trailingBitsCount = segment.bitSize % 8; 336 - if (trailingBitsCount !== 0) { 337 - const lastByteIndex = Math.trunc(cursor / 8); 338 - buffer[lastByteIndex] >>= 8 - trailingBitsCount; 339 - buffer[lastByteIndex] <<= 8 - trailingBitsCount; 340 - } 341 - } else { 342 - appendUnalignedBits( 343 - segment.rawBuffer, 344 - segment.bitSize, 345 - segment.bitOffset 346 - ); 347 - } 348 - } else if (segment instanceof Uint8Array) { 349 - if (isCursorByteAligned) { 350 - buffer.set(segment, cursor / 8); 351 - cursor += segment.byteLength * 8; 352 - } else { 353 - appendUnalignedBits(segment, segment.byteLength * 8, 0); 354 - } 355 - } else { 356 - if (isCursorByteAligned) { 357 - buffer[cursor / 8] = segment; 358 - cursor += 8; 359 - } else { 360 - appendUnalignedBits(new Uint8Array([segment]), 8, 0); 361 - } 362 - } 363 - } 364 - function appendUnalignedBits(unalignedBits, size3, offset) { 365 - if (size3 === 0) { 366 - return; 367 - } 368 - const byteSize = Math.trunc(size3 + 7 / 8); 369 - const highBitsCount = cursor % 8; 370 - const lowBitsCount = 8 - highBitsCount; 371 - let byteIndex = Math.trunc(cursor / 8); 372 - for (let i = 0; i < byteSize; i++) { 373 - let byte = bitArrayByteAt(unalignedBits, offset, i); 374 - if (size3 < 8) { 375 - byte >>= 8 - size3; 376 - byte <<= 8 - size3; 377 - } 378 - buffer[byteIndex] |= byte >> highBitsCount; 379 - let appendedBitsCount = size3 - Math.max(0, size3 - lowBitsCount); 380 - size3 -= appendedBitsCount; 381 - cursor += appendedBitsCount; 382 - if (size3 === 0) { 383 - break; 384 - } 385 - buffer[++byteIndex] = byte << lowBitsCount; 386 - appendedBitsCount = size3 - Math.max(0, size3 - highBitsCount); 387 - size3 -= appendedBitsCount; 388 - cursor += appendedBitsCount; 389 - } 390 - } 391 - return new BitArray(buffer, bitSize); 392 - } 393 - function sizedInt(value, size3, isBigEndian) { 394 - if (size3 <= 0) { 395 - return new Uint8Array(); 396 - } 397 - if (size3 === 8) { 398 - return new Uint8Array([value]); 399 - } 400 - if (size3 < 8) { 401 - value <<= 8 - size3; 402 - return new BitArray(new Uint8Array([value]), size3); 403 - } 404 - const buffer = new Uint8Array(Math.trunc((size3 + 7) / 8)); 405 - const trailingBitsCount = size3 % 8; 406 - const unusedBitsCount = 8 - trailingBitsCount; 407 - if (size3 <= 32) { 408 - if (isBigEndian) { 409 - let i = buffer.length - 1; 410 - if (trailingBitsCount) { 411 - buffer[i--] = value << unusedBitsCount & 255; 412 - value >>= trailingBitsCount; 413 - } 414 - for (; i >= 0; i--) { 415 - buffer[i] = value; 416 - value >>= 8; 417 - } 418 - } else { 419 - let i = 0; 420 - const wholeByteCount = Math.trunc(size3 / 8); 421 - for (; i < wholeByteCount; i++) { 422 - buffer[i] = value; 423 - value >>= 8; 424 - } 425 - if (trailingBitsCount) { 426 - buffer[i] = value << unusedBitsCount; 427 - } 428 - } 429 - } else { 430 - const bigTrailingBitsCount = BigInt(trailingBitsCount); 431 - const bigUnusedBitsCount = BigInt(unusedBitsCount); 432 - let bigValue = BigInt(value); 433 - if (isBigEndian) { 434 - let i = buffer.length - 1; 435 - if (trailingBitsCount) { 436 - buffer[i--] = Number(bigValue << bigUnusedBitsCount); 437 - bigValue >>= bigTrailingBitsCount; 438 - } 439 - for (; i >= 0; i--) { 440 - buffer[i] = Number(bigValue); 441 - bigValue >>= 8n; 442 - } 443 - } else { 444 - let i = 0; 445 - const wholeByteCount = Math.trunc(size3 / 8); 446 - for (; i < wholeByteCount; i++) { 447 - buffer[i] = Number(bigValue); 448 - bigValue >>= 8n; 449 - } 450 - if (trailingBitsCount) { 451 - buffer[i] = Number(bigValue << bigUnusedBitsCount); 452 - } 453 - } 454 - } 455 - if (trailingBitsCount) { 456 - return new BitArray(buffer, size3); 457 - } 458 - return buffer; 459 - } 460 - var Result = class _Result extends CustomType { 461 - // @internal 462 - static isResult(data) { 463 - return data instanceof _Result; 464 - } 465 - }; 466 - var Ok = class extends Result { 467 - constructor(value) { 468 - super(); 469 - this[0] = value; 470 - } 471 - // @internal 472 - isOk() { 473 - return true; 474 - } 475 - }; 476 - var Error = class extends Result { 477 - constructor(detail) { 478 - super(); 479 - this[0] = detail; 480 - } 481 - // @internal 482 - isOk() { 483 - return false; 484 - } 485 - }; 486 - function isEqual(x, y) { 487 - let values3 = [x, y]; 488 - while (values3.length) { 489 - let a = values3.pop(); 490 - let b = values3.pop(); 491 - if (a === b) continue; 492 - if (!isObject(a) || !isObject(b)) return false; 493 - let unequal = !structurallyCompatibleObjects(a, b) || unequalDates(a, b) || unequalBuffers(a, b) || unequalArrays(a, b) || unequalMaps(a, b) || unequalSets(a, b) || unequalRegExps(a, b); 494 - if (unequal) return false; 495 - const proto = Object.getPrototypeOf(a); 496 - if (proto !== null && typeof proto.equals === "function") { 497 - try { 498 - if (a.equals(b)) continue; 499 - else return false; 500 - } catch { 501 - } 502 - } 503 - let [keys2, get4] = getters(a); 504 - for (let k of keys2(a)) { 505 - values3.push(get4(a, k), get4(b, k)); 506 - } 507 - } 508 - return true; 509 - } 510 - function getters(object4) { 511 - if (object4 instanceof Map) { 512 - return [(x) => x.keys(), (x, y) => x.get(y)]; 513 - } else { 514 - let extra = object4 instanceof globalThis.Error ? ["message"] : []; 515 - return [(x) => [...extra, ...Object.keys(x)], (x, y) => x[y]]; 516 - } 517 - } 518 - function unequalDates(a, b) { 519 - return a instanceof Date && (a > b || a < b); 520 - } 521 - function unequalBuffers(a, b) { 522 - return !(a instanceof BitArray) && a.buffer instanceof ArrayBuffer && a.BYTES_PER_ELEMENT && !(a.byteLength === b.byteLength && a.every((n, i) => n === b[i])); 523 - } 524 - function unequalArrays(a, b) { 525 - return Array.isArray(a) && a.length !== b.length; 526 - } 527 - function unequalMaps(a, b) { 528 - return a instanceof Map && a.size !== b.size; 529 - } 530 - function unequalSets(a, b) { 531 - return a instanceof Set && (a.size != b.size || [...a].some((e) => !b.has(e))); 532 - } 533 - function unequalRegExps(a, b) { 534 - return a instanceof RegExp && (a.source !== b.source || a.flags !== b.flags); 535 - } 536 - function isObject(a) { 537 - return typeof a === "object" && a !== null; 538 - } 539 - function structurallyCompatibleObjects(a, b) { 540 - if (typeof a !== "object" && typeof b !== "object" && (!a || !b)) 541 - return false; 542 - let nonstructural = [Promise, WeakSet, WeakMap, Function]; 543 - if (nonstructural.some((c) => a instanceof c)) return false; 544 - return a.constructor === b.constructor; 545 - } 546 - function makeError(variant, file, module, line, fn, message, extra) { 547 - let error = new globalThis.Error(message); 548 - error.gleam_error = variant; 549 - error.file = file; 550 - error.module = module; 551 - error.line = line; 552 - error.function = fn; 553 - error.fn = fn; 554 - for (let k in extra) error[k] = extra[k]; 555 - return error; 556 - } 557 - 558 - // build/dev/javascript/gleam_stdlib/gleam/order.mjs 559 - var Lt = class extends CustomType { 560 - }; 561 - var Eq = class extends CustomType { 562 - }; 563 - var Gt = class extends CustomType { 564 - }; 565 - 566 - // build/dev/javascript/gleam_stdlib/gleam/option.mjs 567 - var Some = class extends CustomType { 568 - constructor($0) { 569 - super(); 570 - this[0] = $0; 571 - } 572 - }; 573 - var None = class extends CustomType { 574 - }; 575 - function unwrap(option, default$) { 576 - if (option instanceof Some) { 577 - let x = option[0]; 578 - return x; 579 - } else { 580 - return default$; 581 - } 582 - } 583 - function lazy_unwrap(option, default$) { 584 - if (option instanceof Some) { 585 - let x = option[0]; 586 - return x; 587 - } else { 588 - return default$(); 589 - } 590 - } 591 - 592 - // build/dev/javascript/gleam_stdlib/dict.mjs 593 - var referenceMap = /* @__PURE__ */ new WeakMap(); 594 - var tempDataView = /* @__PURE__ */ new DataView( 595 - /* @__PURE__ */ new ArrayBuffer(8) 596 - ); 597 - var referenceUID = 0; 598 - function hashByReference(o) { 599 - const known = referenceMap.get(o); 600 - if (known !== void 0) { 601 - return known; 602 - } 603 - const hash = referenceUID++; 604 - if (referenceUID === 2147483647) { 605 - referenceUID = 0; 606 - } 607 - referenceMap.set(o, hash); 608 - return hash; 609 - } 610 - function hashMerge(a, b) { 611 - return a ^ b + 2654435769 + (a << 6) + (a >> 2) | 0; 612 - } 613 - function hashString(s) { 614 - let hash = 0; 615 - const len = s.length; 616 - for (let i = 0; i < len; i++) { 617 - hash = Math.imul(31, hash) + s.charCodeAt(i) | 0; 618 - } 619 - return hash; 620 - } 621 - function hashNumber(n) { 622 - tempDataView.setFloat64(0, n); 623 - const i = tempDataView.getInt32(0); 624 - const j = tempDataView.getInt32(4); 625 - return Math.imul(73244475, i >> 16 ^ i) ^ j; 626 - } 627 - function hashBigInt(n) { 628 - return hashString(n.toString()); 629 - } 630 - function hashObject(o) { 631 - const proto = Object.getPrototypeOf(o); 632 - if (proto !== null && typeof proto.hashCode === "function") { 633 - try { 634 - const code = o.hashCode(o); 635 - if (typeof code === "number") { 636 - return code; 637 - } 638 - } catch { 639 - } 640 - } 641 - if (o instanceof Promise || o instanceof WeakSet || o instanceof WeakMap) { 642 - return hashByReference(o); 643 - } 644 - if (o instanceof Date) { 645 - return hashNumber(o.getTime()); 646 - } 647 - let h = 0; 648 - if (o instanceof ArrayBuffer) { 649 - o = new Uint8Array(o); 650 - } 651 - if (Array.isArray(o) || o instanceof Uint8Array) { 652 - for (let i = 0; i < o.length; i++) { 653 - h = Math.imul(31, h) + getHash(o[i]) | 0; 654 - } 655 - } else if (o instanceof Set) { 656 - o.forEach((v) => { 657 - h = h + getHash(v) | 0; 658 - }); 659 - } else if (o instanceof Map) { 660 - o.forEach((v, k) => { 661 - h = h + hashMerge(getHash(v), getHash(k)) | 0; 662 - }); 663 - } else { 664 - const keys2 = Object.keys(o); 665 - for (let i = 0; i < keys2.length; i++) { 666 - const k = keys2[i]; 667 - const v = o[k]; 668 - h = h + hashMerge(getHash(v), hashString(k)) | 0; 669 - } 670 - } 671 - return h; 672 - } 673 - function getHash(u) { 674 - if (u === null) return 1108378658; 675 - if (u === void 0) return 1108378659; 676 - if (u === true) return 1108378657; 677 - if (u === false) return 1108378656; 678 - switch (typeof u) { 679 - case "number": 680 - return hashNumber(u); 681 - case "string": 682 - return hashString(u); 683 - case "bigint": 684 - return hashBigInt(u); 685 - case "object": 686 - return hashObject(u); 687 - case "symbol": 688 - return hashByReference(u); 689 - case "function": 690 - return hashByReference(u); 691 - default: 692 - return 0; 693 - } 694 - } 695 - var SHIFT = 5; 696 - var BUCKET_SIZE = Math.pow(2, SHIFT); 697 - var MASK = BUCKET_SIZE - 1; 698 - var MAX_INDEX_NODE = BUCKET_SIZE / 2; 699 - var MIN_ARRAY_NODE = BUCKET_SIZE / 4; 700 - var ENTRY = 0; 701 - var ARRAY_NODE = 1; 702 - var INDEX_NODE = 2; 703 - var COLLISION_NODE = 3; 704 - var EMPTY = { 705 - type: INDEX_NODE, 706 - bitmap: 0, 707 - array: [] 708 - }; 709 - function mask(hash, shift) { 710 - return hash >>> shift & MASK; 711 - } 712 - function bitpos(hash, shift) { 713 - return 1 << mask(hash, shift); 714 - } 715 - function bitcount(x) { 716 - x -= x >> 1 & 1431655765; 717 - x = (x & 858993459) + (x >> 2 & 858993459); 718 - x = x + (x >> 4) & 252645135; 719 - x += x >> 8; 720 - x += x >> 16; 721 - return x & 127; 722 - } 723 - function index(bitmap, bit) { 724 - return bitcount(bitmap & bit - 1); 725 - } 726 - function cloneAndSet(arr, at, val) { 727 - const len = arr.length; 728 - const out = new Array(len); 729 - for (let i = 0; i < len; ++i) { 730 - out[i] = arr[i]; 731 - } 732 - out[at] = val; 733 - return out; 734 - } 735 - function spliceIn(arr, at, val) { 736 - const len = arr.length; 737 - const out = new Array(len + 1); 738 - let i = 0; 739 - let g = 0; 740 - while (i < at) { 741 - out[g++] = arr[i++]; 742 - } 743 - out[g++] = val; 744 - while (i < len) { 745 - out[g++] = arr[i++]; 746 - } 747 - return out; 748 - } 749 - function spliceOut(arr, at) { 750 - const len = arr.length; 751 - const out = new Array(len - 1); 752 - let i = 0; 753 - let g = 0; 754 - while (i < at) { 755 - out[g++] = arr[i++]; 756 - } 757 - ++i; 758 - while (i < len) { 759 - out[g++] = arr[i++]; 760 - } 761 - return out; 762 - } 763 - function createNode(shift, key1, val1, key2hash, key2, val2) { 764 - const key1hash = getHash(key1); 765 - if (key1hash === key2hash) { 766 - return { 767 - type: COLLISION_NODE, 768 - hash: key1hash, 769 - array: [ 770 - { type: ENTRY, k: key1, v: val1 }, 771 - { type: ENTRY, k: key2, v: val2 } 772 - ] 773 - }; 774 - } 775 - const addedLeaf = { val: false }; 776 - return assoc( 777 - assocIndex(EMPTY, shift, key1hash, key1, val1, addedLeaf), 778 - shift, 779 - key2hash, 780 - key2, 781 - val2, 782 - addedLeaf 783 - ); 784 - } 785 - function assoc(root3, shift, hash, key, val, addedLeaf) { 786 - switch (root3.type) { 787 - case ARRAY_NODE: 788 - return assocArray(root3, shift, hash, key, val, addedLeaf); 789 - case INDEX_NODE: 790 - return assocIndex(root3, shift, hash, key, val, addedLeaf); 791 - case COLLISION_NODE: 792 - return assocCollision(root3, shift, hash, key, val, addedLeaf); 793 - } 794 - } 795 - function assocArray(root3, shift, hash, key, val, addedLeaf) { 796 - const idx = mask(hash, shift); 797 - const node2 = root3.array[idx]; 798 - if (node2 === void 0) { 799 - addedLeaf.val = true; 800 - return { 801 - type: ARRAY_NODE, 802 - size: root3.size + 1, 803 - array: cloneAndSet(root3.array, idx, { type: ENTRY, k: key, v: val }) 804 - }; 805 - } 806 - if (node2.type === ENTRY) { 807 - if (isEqual(key, node2.k)) { 808 - if (val === node2.v) { 809 - return root3; 810 - } 811 - return { 812 - type: ARRAY_NODE, 813 - size: root3.size, 814 - array: cloneAndSet(root3.array, idx, { 815 - type: ENTRY, 816 - k: key, 817 - v: val 818 - }) 819 - }; 820 - } 821 - addedLeaf.val = true; 822 - return { 823 - type: ARRAY_NODE, 824 - size: root3.size, 825 - array: cloneAndSet( 826 - root3.array, 827 - idx, 828 - createNode(shift + SHIFT, node2.k, node2.v, hash, key, val) 829 - ) 830 - }; 831 - } 832 - const n = assoc(node2, shift + SHIFT, hash, key, val, addedLeaf); 833 - if (n === node2) { 834 - return root3; 835 - } 836 - return { 837 - type: ARRAY_NODE, 838 - size: root3.size, 839 - array: cloneAndSet(root3.array, idx, n) 840 - }; 841 - } 842 - function assocIndex(root3, shift, hash, key, val, addedLeaf) { 843 - const bit = bitpos(hash, shift); 844 - const idx = index(root3.bitmap, bit); 845 - if ((root3.bitmap & bit) !== 0) { 846 - const node2 = root3.array[idx]; 847 - if (node2.type !== ENTRY) { 848 - const n = assoc(node2, shift + SHIFT, hash, key, val, addedLeaf); 849 - if (n === node2) { 850 - return root3; 851 - } 852 - return { 853 - type: INDEX_NODE, 854 - bitmap: root3.bitmap, 855 - array: cloneAndSet(root3.array, idx, n) 856 - }; 857 - } 858 - const nodeKey = node2.k; 859 - if (isEqual(key, nodeKey)) { 860 - if (val === node2.v) { 861 - return root3; 862 - } 863 - return { 864 - type: INDEX_NODE, 865 - bitmap: root3.bitmap, 866 - array: cloneAndSet(root3.array, idx, { 867 - type: ENTRY, 868 - k: key, 869 - v: val 870 - }) 871 - }; 872 - } 873 - addedLeaf.val = true; 874 - return { 875 - type: INDEX_NODE, 876 - bitmap: root3.bitmap, 877 - array: cloneAndSet( 878 - root3.array, 879 - idx, 880 - createNode(shift + SHIFT, nodeKey, node2.v, hash, key, val) 881 - ) 882 - }; 883 - } else { 884 - const n = root3.array.length; 885 - if (n >= MAX_INDEX_NODE) { 886 - const nodes = new Array(32); 887 - const jdx = mask(hash, shift); 888 - nodes[jdx] = assocIndex(EMPTY, shift + SHIFT, hash, key, val, addedLeaf); 889 - let j = 0; 890 - let bitmap = root3.bitmap; 891 - for (let i = 0; i < 32; i++) { 892 - if ((bitmap & 1) !== 0) { 893 - const node2 = root3.array[j++]; 894 - nodes[i] = node2; 895 - } 896 - bitmap = bitmap >>> 1; 897 - } 898 - return { 899 - type: ARRAY_NODE, 900 - size: n + 1, 901 - array: nodes 902 - }; 903 - } else { 904 - const newArray = spliceIn(root3.array, idx, { 905 - type: ENTRY, 906 - k: key, 907 - v: val 908 - }); 909 - addedLeaf.val = true; 910 - return { 911 - type: INDEX_NODE, 912 - bitmap: root3.bitmap | bit, 913 - array: newArray 914 - }; 915 - } 916 - } 917 - } 918 - function assocCollision(root3, shift, hash, key, val, addedLeaf) { 919 - if (hash === root3.hash) { 920 - const idx = collisionIndexOf(root3, key); 921 - if (idx !== -1) { 922 - const entry = root3.array[idx]; 923 - if (entry.v === val) { 924 - return root3; 925 - } 926 - return { 927 - type: COLLISION_NODE, 928 - hash, 929 - array: cloneAndSet(root3.array, idx, { type: ENTRY, k: key, v: val }) 930 - }; 931 - } 932 - const size3 = root3.array.length; 933 - addedLeaf.val = true; 934 - return { 935 - type: COLLISION_NODE, 936 - hash, 937 - array: cloneAndSet(root3.array, size3, { type: ENTRY, k: key, v: val }) 938 - }; 939 - } 940 - return assoc( 941 - { 942 - type: INDEX_NODE, 943 - bitmap: bitpos(root3.hash, shift), 944 - array: [root3] 945 - }, 946 - shift, 947 - hash, 948 - key, 949 - val, 950 - addedLeaf 951 - ); 952 - } 953 - function collisionIndexOf(root3, key) { 954 - const size3 = root3.array.length; 955 - for (let i = 0; i < size3; i++) { 956 - if (isEqual(key, root3.array[i].k)) { 957 - return i; 958 - } 959 - } 960 - return -1; 961 - } 962 - function find(root3, shift, hash, key) { 963 - switch (root3.type) { 964 - case ARRAY_NODE: 965 - return findArray(root3, shift, hash, key); 966 - case INDEX_NODE: 967 - return findIndex(root3, shift, hash, key); 968 - case COLLISION_NODE: 969 - return findCollision(root3, key); 970 - } 971 - } 972 - function findArray(root3, shift, hash, key) { 973 - const idx = mask(hash, shift); 974 - const node2 = root3.array[idx]; 975 - if (node2 === void 0) { 976 - return void 0; 977 - } 978 - if (node2.type !== ENTRY) { 979 - return find(node2, shift + SHIFT, hash, key); 980 - } 981 - if (isEqual(key, node2.k)) { 982 - return node2; 983 - } 984 - return void 0; 985 - } 986 - function findIndex(root3, shift, hash, key) { 987 - const bit = bitpos(hash, shift); 988 - if ((root3.bitmap & bit) === 0) { 989 - return void 0; 990 - } 991 - const idx = index(root3.bitmap, bit); 992 - const node2 = root3.array[idx]; 993 - if (node2.type !== ENTRY) { 994 - return find(node2, shift + SHIFT, hash, key); 995 - } 996 - if (isEqual(key, node2.k)) { 997 - return node2; 998 - } 999 - return void 0; 1000 - } 1001 - function findCollision(root3, key) { 1002 - const idx = collisionIndexOf(root3, key); 1003 - if (idx < 0) { 1004 - return void 0; 1005 - } 1006 - return root3.array[idx]; 1007 - } 1008 - function without(root3, shift, hash, key) { 1009 - switch (root3.type) { 1010 - case ARRAY_NODE: 1011 - return withoutArray(root3, shift, hash, key); 1012 - case INDEX_NODE: 1013 - return withoutIndex(root3, shift, hash, key); 1014 - case COLLISION_NODE: 1015 - return withoutCollision(root3, key); 1016 - } 1017 - } 1018 - function withoutArray(root3, shift, hash, key) { 1019 - const idx = mask(hash, shift); 1020 - const node2 = root3.array[idx]; 1021 - if (node2 === void 0) { 1022 - return root3; 1023 - } 1024 - let n = void 0; 1025 - if (node2.type === ENTRY) { 1026 - if (!isEqual(node2.k, key)) { 1027 - return root3; 1028 - } 1029 - } else { 1030 - n = without(node2, shift + SHIFT, hash, key); 1031 - if (n === node2) { 1032 - return root3; 1033 - } 1034 - } 1035 - if (n === void 0) { 1036 - if (root3.size <= MIN_ARRAY_NODE) { 1037 - const arr = root3.array; 1038 - const out = new Array(root3.size - 1); 1039 - let i = 0; 1040 - let j = 0; 1041 - let bitmap = 0; 1042 - while (i < idx) { 1043 - const nv = arr[i]; 1044 - if (nv !== void 0) { 1045 - out[j] = nv; 1046 - bitmap |= 1 << i; 1047 - ++j; 1048 - } 1049 - ++i; 1050 - } 1051 - ++i; 1052 - while (i < arr.length) { 1053 - const nv = arr[i]; 1054 - if (nv !== void 0) { 1055 - out[j] = nv; 1056 - bitmap |= 1 << i; 1057 - ++j; 1058 - } 1059 - ++i; 1060 - } 1061 - return { 1062 - type: INDEX_NODE, 1063 - bitmap, 1064 - array: out 1065 - }; 1066 - } 1067 - return { 1068 - type: ARRAY_NODE, 1069 - size: root3.size - 1, 1070 - array: cloneAndSet(root3.array, idx, n) 1071 - }; 1072 - } 1073 - return { 1074 - type: ARRAY_NODE, 1075 - size: root3.size, 1076 - array: cloneAndSet(root3.array, idx, n) 1077 - }; 1078 - } 1079 - function withoutIndex(root3, shift, hash, key) { 1080 - const bit = bitpos(hash, shift); 1081 - if ((root3.bitmap & bit) === 0) { 1082 - return root3; 1083 - } 1084 - const idx = index(root3.bitmap, bit); 1085 - const node2 = root3.array[idx]; 1086 - if (node2.type !== ENTRY) { 1087 - const n = without(node2, shift + SHIFT, hash, key); 1088 - if (n === node2) { 1089 - return root3; 1090 - } 1091 - if (n !== void 0) { 1092 - return { 1093 - type: INDEX_NODE, 1094 - bitmap: root3.bitmap, 1095 - array: cloneAndSet(root3.array, idx, n) 1096 - }; 1097 - } 1098 - if (root3.bitmap === bit) { 1099 - return void 0; 1100 - } 1101 - return { 1102 - type: INDEX_NODE, 1103 - bitmap: root3.bitmap ^ bit, 1104 - array: spliceOut(root3.array, idx) 1105 - }; 1106 - } 1107 - if (isEqual(key, node2.k)) { 1108 - if (root3.bitmap === bit) { 1109 - return void 0; 1110 - } 1111 - return { 1112 - type: INDEX_NODE, 1113 - bitmap: root3.bitmap ^ bit, 1114 - array: spliceOut(root3.array, idx) 1115 - }; 1116 - } 1117 - return root3; 1118 - } 1119 - function withoutCollision(root3, key) { 1120 - const idx = collisionIndexOf(root3, key); 1121 - if (idx < 0) { 1122 - return root3; 1123 - } 1124 - if (root3.array.length === 1) { 1125 - return void 0; 1126 - } 1127 - return { 1128 - type: COLLISION_NODE, 1129 - hash: root3.hash, 1130 - array: spliceOut(root3.array, idx) 1131 - }; 1132 - } 1133 - function forEach(root3, fn) { 1134 - if (root3 === void 0) { 1135 - return; 1136 - } 1137 - const items = root3.array; 1138 - const size3 = items.length; 1139 - for (let i = 0; i < size3; i++) { 1140 - const item = items[i]; 1141 - if (item === void 0) { 1142 - continue; 1143 - } 1144 - if (item.type === ENTRY) { 1145 - fn(item.v, item.k); 1146 - continue; 1147 - } 1148 - forEach(item, fn); 1149 - } 1150 - } 1151 - var Dict = class _Dict { 1152 - /** 1153 - * @template V 1154 - * @param {Record<string,V>} o 1155 - * @returns {Dict<string,V>} 1156 - */ 1157 - static fromObject(o) { 1158 - const keys2 = Object.keys(o); 1159 - let m = _Dict.new(); 1160 - for (let i = 0; i < keys2.length; i++) { 1161 - const k = keys2[i]; 1162 - m = m.set(k, o[k]); 1163 - } 1164 - return m; 1165 - } 1166 - /** 1167 - * @template K,V 1168 - * @param {Map<K,V>} o 1169 - * @returns {Dict<K,V>} 1170 - */ 1171 - static fromMap(o) { 1172 - let m = _Dict.new(); 1173 - o.forEach((v, k) => { 1174 - m = m.set(k, v); 1175 - }); 1176 - return m; 1177 - } 1178 - static new() { 1179 - return new _Dict(void 0, 0); 1180 - } 1181 - /** 1182 - * @param {undefined | Node<K,V>} root 1183 - * @param {number} size 1184 - */ 1185 - constructor(root3, size3) { 1186 - this.root = root3; 1187 - this.size = size3; 1188 - } 1189 - /** 1190 - * @template NotFound 1191 - * @param {K} key 1192 - * @param {NotFound} notFound 1193 - * @returns {NotFound | V} 1194 - */ 1195 - get(key, notFound) { 1196 - if (this.root === void 0) { 1197 - return notFound; 1198 - } 1199 - const found = find(this.root, 0, getHash(key), key); 1200 - if (found === void 0) { 1201 - return notFound; 1202 - } 1203 - return found.v; 1204 - } 1205 - /** 1206 - * @param {K} key 1207 - * @param {V} val 1208 - * @returns {Dict<K,V>} 1209 - */ 1210 - set(key, val) { 1211 - const addedLeaf = { val: false }; 1212 - const root3 = this.root === void 0 ? EMPTY : this.root; 1213 - const newRoot = assoc(root3, 0, getHash(key), key, val, addedLeaf); 1214 - if (newRoot === this.root) { 1215 - return this; 1216 - } 1217 - return new _Dict(newRoot, addedLeaf.val ? this.size + 1 : this.size); 1218 - } 1219 - /** 1220 - * @param {K} key 1221 - * @returns {Dict<K,V>} 1222 - */ 1223 - delete(key) { 1224 - if (this.root === void 0) { 1225 - return this; 1226 - } 1227 - const newRoot = without(this.root, 0, getHash(key), key); 1228 - if (newRoot === this.root) { 1229 - return this; 1230 - } 1231 - if (newRoot === void 0) { 1232 - return _Dict.new(); 1233 - } 1234 - return new _Dict(newRoot, this.size - 1); 1235 - } 1236 - /** 1237 - * @param {K} key 1238 - * @returns {boolean} 1239 - */ 1240 - has(key) { 1241 - if (this.root === void 0) { 1242 - return false; 1243 - } 1244 - return find(this.root, 0, getHash(key), key) !== void 0; 1245 - } 1246 - /** 1247 - * @returns {[K,V][]} 1248 - */ 1249 - entries() { 1250 - if (this.root === void 0) { 1251 - return []; 1252 - } 1253 - const result = []; 1254 - this.forEach((v, k) => result.push([k, v])); 1255 - return result; 1256 - } 1257 - /** 1258 - * 1259 - * @param {(val:V,key:K)=>void} fn 1260 - */ 1261 - forEach(fn) { 1262 - forEach(this.root, fn); 1263 - } 1264 - hashCode() { 1265 - let h = 0; 1266 - this.forEach((v, k) => { 1267 - h = h + hashMerge(getHash(v), getHash(k)) | 0; 1268 - }); 1269 - return h; 1270 - } 1271 - /** 1272 - * @param {unknown} o 1273 - * @returns {boolean} 1274 - */ 1275 - equals(o) { 1276 - if (!(o instanceof _Dict) || this.size !== o.size) { 1277 - return false; 1278 - } 1279 - try { 1280 - this.forEach((v, k) => { 1281 - if (!isEqual(o.get(k, !v), v)) { 1282 - throw unequalDictSymbol; 1283 - } 1284 - }); 1285 - return true; 1286 - } catch (e) { 1287 - if (e === unequalDictSymbol) { 1288 - return false; 1289 - } 1290 - throw e; 1291 - } 1292 - } 1293 - }; 1294 - var unequalDictSymbol = /* @__PURE__ */ Symbol(); 1295 - 1296 - // build/dev/javascript/gleam_stdlib/gleam/dict.mjs 1297 - function insert(dict2, key, value) { 1298 - return map_insert(key, value, dict2); 1299 - } 1300 - function reverse_and_concat(loop$remaining, loop$accumulator) { 1301 - while (true) { 1302 - let remaining = loop$remaining; 1303 - let accumulator = loop$accumulator; 1304 - if (remaining instanceof Empty) { 1305 - return accumulator; 1306 - } else { 1307 - let first2 = remaining.head; 1308 - let rest = remaining.tail; 1309 - loop$remaining = rest; 1310 - loop$accumulator = prepend(first2, accumulator); 1311 - } 1312 - } 1313 - } 1314 - function do_values_loop(loop$list, loop$acc) { 1315 - while (true) { 1316 - let list4 = loop$list; 1317 - let acc = loop$acc; 1318 - if (list4 instanceof Empty) { 1319 - return reverse_and_concat(acc, toList([])); 1320 - } else { 1321 - let rest = list4.tail; 1322 - let value = list4.head[1]; 1323 - loop$list = rest; 1324 - loop$acc = prepend(value, acc); 1325 - } 1326 - } 1327 - } 1328 - function values(dict2) { 1329 - let list_of_pairs = map_to_list(dict2); 1330 - return do_values_loop(list_of_pairs, toList([])); 1331 - } 1332 - 1333 - // build/dev/javascript/gleam_stdlib/gleam/int.mjs 1334 - function square_root2(x) { 1335 - let _pipe = identity(x); 1336 - return square_root(_pipe); 1337 - } 1338 - function min(a, b) { 1339 - let $ = a < b; 1340 - if ($) { 1341 - return a; 1342 - } else { 1343 - return b; 1344 - } 1345 - } 1346 - function add(a, b) { 1347 - return a + b; 1348 - } 1349 - 1350 - // build/dev/javascript/gleam_stdlib/gleam/list.mjs 1351 - var Ascending = class extends CustomType { 1352 - }; 1353 - var Descending = class extends CustomType { 1354 - }; 1355 - function length_loop(loop$list, loop$count) { 1356 - while (true) { 1357 - let list4 = loop$list; 1358 - let count = loop$count; 1359 - if (list4 instanceof Empty) { 1360 - return count; 1361 - } else { 1362 - let list$1 = list4.tail; 1363 - loop$list = list$1; 1364 - loop$count = count + 1; 1365 - } 1366 - } 1367 - } 1368 - function length(list4) { 1369 - return length_loop(list4, 0); 1370 - } 1371 - function reverse_and_prepend(loop$prefix, loop$suffix) { 1372 - while (true) { 1373 - let prefix = loop$prefix; 1374 - let suffix = loop$suffix; 1375 - if (prefix instanceof Empty) { 1376 - return suffix; 1377 - } else { 1378 - let first$1 = prefix.head; 1379 - let rest$1 = prefix.tail; 1380 - loop$prefix = rest$1; 1381 - loop$suffix = prepend(first$1, suffix); 1382 - } 1383 - } 1384 - } 1385 - function reverse(list4) { 1386 - return reverse_and_prepend(list4, toList([])); 1387 - } 1388 - function is_empty2(list4) { 1389 - return isEqual(list4, toList([])); 1390 - } 1391 - function first(list4) { 1392 - if (list4 instanceof Empty) { 1393 - return new Error(void 0); 1394 - } else { 1395 - let first$1 = list4.head; 1396 - return new Ok(first$1); 1397 - } 1398 - } 1399 - function map_loop(loop$list, loop$fun, loop$acc) { 1400 - while (true) { 1401 - let list4 = loop$list; 1402 - let fun = loop$fun; 1403 - let acc = loop$acc; 1404 - if (list4 instanceof Empty) { 1405 - return reverse(acc); 1406 - } else { 1407 - let first$1 = list4.head; 1408 - let rest$1 = list4.tail; 1409 - loop$list = rest$1; 1410 - loop$fun = fun; 1411 - loop$acc = prepend(fun(first$1), acc); 1412 - } 1413 - } 1414 - } 1415 - function map(list4, fun) { 1416 - return map_loop(list4, fun, toList([])); 1417 - } 1418 - function append_loop(loop$first, loop$second) { 1419 - while (true) { 1420 - let first2 = loop$first; 1421 - let second = loop$second; 1422 - if (first2 instanceof Empty) { 1423 - return second; 1424 - } else { 1425 - let first$1 = first2.head; 1426 - let rest$1 = first2.tail; 1427 - loop$first = rest$1; 1428 - loop$second = prepend(first$1, second); 1429 - } 1430 - } 1431 - } 1432 - function append(first2, second) { 1433 - return append_loop(reverse(first2), second); 1434 - } 1435 - function prepend2(list4, item) { 1436 - return prepend(item, list4); 1437 - } 1438 - function flatten_loop(loop$lists, loop$acc) { 1439 - while (true) { 1440 - let lists = loop$lists; 1441 - let acc = loop$acc; 1442 - if (lists instanceof Empty) { 1443 - return reverse(acc); 1444 - } else { 1445 - let list4 = lists.head; 1446 - let further_lists = lists.tail; 1447 - loop$lists = further_lists; 1448 - loop$acc = reverse_and_prepend(list4, acc); 1449 - } 1450 - } 1451 - } 1452 - function flatten(lists) { 1453 - return flatten_loop(lists, toList([])); 1454 - } 1455 - function flat_map(list4, fun) { 1456 - return flatten(map(list4, fun)); 1457 - } 1458 - function fold(loop$list, loop$initial, loop$fun) { 1459 - while (true) { 1460 - let list4 = loop$list; 1461 - let initial = loop$initial; 1462 - let fun = loop$fun; 1463 - if (list4 instanceof Empty) { 1464 - return initial; 1465 - } else { 1466 - let first$1 = list4.head; 1467 - let rest$1 = list4.tail; 1468 - loop$list = rest$1; 1469 - loop$initial = fun(initial, first$1); 1470 - loop$fun = fun; 1471 - } 1472 - } 1473 - } 1474 - function sequences(loop$list, loop$compare, loop$growing, loop$direction, loop$prev, loop$acc) { 1475 - while (true) { 1476 - let list4 = loop$list; 1477 - let compare4 = loop$compare; 1478 - let growing = loop$growing; 1479 - let direction = loop$direction; 1480 - let prev = loop$prev; 1481 - let acc = loop$acc; 1482 - let growing$1 = prepend(prev, growing); 1483 - if (list4 instanceof Empty) { 1484 - if (direction instanceof Ascending) { 1485 - return prepend(reverse(growing$1), acc); 1486 - } else { 1487 - return prepend(growing$1, acc); 1488 - } 1489 - } else { 1490 - let new$1 = list4.head; 1491 - let rest$1 = list4.tail; 1492 - let $ = compare4(prev, new$1); 1493 - if (direction instanceof Ascending) { 1494 - if ($ instanceof Lt) { 1495 - loop$list = rest$1; 1496 - loop$compare = compare4; 1497 - loop$growing = growing$1; 1498 - loop$direction = direction; 1499 - loop$prev = new$1; 1500 - loop$acc = acc; 1501 - } else if ($ instanceof Eq) { 1502 - loop$list = rest$1; 1503 - loop$compare = compare4; 1504 - loop$growing = growing$1; 1505 - loop$direction = direction; 1506 - loop$prev = new$1; 1507 - loop$acc = acc; 1508 - } else { 1509 - let _block; 1510 - if (direction instanceof Ascending) { 1511 - _block = prepend(reverse(growing$1), acc); 1512 - } else { 1513 - _block = prepend(growing$1, acc); 1514 - } 1515 - let acc$1 = _block; 1516 - if (rest$1 instanceof Empty) { 1517 - return prepend(toList([new$1]), acc$1); 1518 - } else { 1519 - let next = rest$1.head; 1520 - let rest$2 = rest$1.tail; 1521 - let _block$1; 1522 - let $1 = compare4(new$1, next); 1523 - if ($1 instanceof Lt) { 1524 - _block$1 = new Ascending(); 1525 - } else if ($1 instanceof Eq) { 1526 - _block$1 = new Ascending(); 1527 - } else { 1528 - _block$1 = new Descending(); 1529 - } 1530 - let direction$1 = _block$1; 1531 - loop$list = rest$2; 1532 - loop$compare = compare4; 1533 - loop$growing = toList([new$1]); 1534 - loop$direction = direction$1; 1535 - loop$prev = next; 1536 - loop$acc = acc$1; 1537 - } 1538 - } 1539 - } else if ($ instanceof Lt) { 1540 - let _block; 1541 - if (direction instanceof Ascending) { 1542 - _block = prepend(reverse(growing$1), acc); 1543 - } else { 1544 - _block = prepend(growing$1, acc); 1545 - } 1546 - let acc$1 = _block; 1547 - if (rest$1 instanceof Empty) { 1548 - return prepend(toList([new$1]), acc$1); 1549 - } else { 1550 - let next = rest$1.head; 1551 - let rest$2 = rest$1.tail; 1552 - let _block$1; 1553 - let $1 = compare4(new$1, next); 1554 - if ($1 instanceof Lt) { 1555 - _block$1 = new Ascending(); 1556 - } else if ($1 instanceof Eq) { 1557 - _block$1 = new Ascending(); 1558 - } else { 1559 - _block$1 = new Descending(); 1560 - } 1561 - let direction$1 = _block$1; 1562 - loop$list = rest$2; 1563 - loop$compare = compare4; 1564 - loop$growing = toList([new$1]); 1565 - loop$direction = direction$1; 1566 - loop$prev = next; 1567 - loop$acc = acc$1; 1568 - } 1569 - } else if ($ instanceof Eq) { 1570 - let _block; 1571 - if (direction instanceof Ascending) { 1572 - _block = prepend(reverse(growing$1), acc); 1573 - } else { 1574 - _block = prepend(growing$1, acc); 1575 - } 1576 - let acc$1 = _block; 1577 - if (rest$1 instanceof Empty) { 1578 - return prepend(toList([new$1]), acc$1); 1579 - } else { 1580 - let next = rest$1.head; 1581 - let rest$2 = rest$1.tail; 1582 - let _block$1; 1583 - let $1 = compare4(new$1, next); 1584 - if ($1 instanceof Lt) { 1585 - _block$1 = new Ascending(); 1586 - } else if ($1 instanceof Eq) { 1587 - _block$1 = new Ascending(); 1588 - } else { 1589 - _block$1 = new Descending(); 1590 - } 1591 - let direction$1 = _block$1; 1592 - loop$list = rest$2; 1593 - loop$compare = compare4; 1594 - loop$growing = toList([new$1]); 1595 - loop$direction = direction$1; 1596 - loop$prev = next; 1597 - loop$acc = acc$1; 1598 - } 1599 - } else { 1600 - loop$list = rest$1; 1601 - loop$compare = compare4; 1602 - loop$growing = growing$1; 1603 - loop$direction = direction; 1604 - loop$prev = new$1; 1605 - loop$acc = acc; 1606 - } 1607 - } 1608 - } 1609 - } 1610 - function merge_ascendings(loop$list1, loop$list2, loop$compare, loop$acc) { 1611 - while (true) { 1612 - let list1 = loop$list1; 1613 - let list22 = loop$list2; 1614 - let compare4 = loop$compare; 1615 - let acc = loop$acc; 1616 - if (list1 instanceof Empty) { 1617 - let list4 = list22; 1618 - return reverse_and_prepend(list4, acc); 1619 - } else if (list22 instanceof Empty) { 1620 - let list4 = list1; 1621 - return reverse_and_prepend(list4, acc); 1622 - } else { 1623 - let first1 = list1.head; 1624 - let rest1 = list1.tail; 1625 - let first2 = list22.head; 1626 - let rest2 = list22.tail; 1627 - let $ = compare4(first1, first2); 1628 - if ($ instanceof Lt) { 1629 - loop$list1 = rest1; 1630 - loop$list2 = list22; 1631 - loop$compare = compare4; 1632 - loop$acc = prepend(first1, acc); 1633 - } else if ($ instanceof Eq) { 1634 - loop$list1 = list1; 1635 - loop$list2 = rest2; 1636 - loop$compare = compare4; 1637 - loop$acc = prepend(first2, acc); 1638 - } else { 1639 - loop$list1 = list1; 1640 - loop$list2 = rest2; 1641 - loop$compare = compare4; 1642 - loop$acc = prepend(first2, acc); 1643 - } 1644 - } 1645 - } 1646 - } 1647 - function merge_ascending_pairs(loop$sequences, loop$compare, loop$acc) { 1648 - while (true) { 1649 - let sequences2 = loop$sequences; 1650 - let compare4 = loop$compare; 1651 - let acc = loop$acc; 1652 - if (sequences2 instanceof Empty) { 1653 - return reverse(acc); 1654 - } else { 1655 - let $ = sequences2.tail; 1656 - if ($ instanceof Empty) { 1657 - let sequence = sequences2.head; 1658 - return reverse(prepend(reverse(sequence), acc)); 1659 - } else { 1660 - let ascending1 = sequences2.head; 1661 - let ascending2 = $.head; 1662 - let rest$1 = $.tail; 1663 - let descending = merge_ascendings( 1664 - ascending1, 1665 - ascending2, 1666 - compare4, 1667 - toList([]) 1668 - ); 1669 - loop$sequences = rest$1; 1670 - loop$compare = compare4; 1671 - loop$acc = prepend(descending, acc); 1672 - } 1673 - } 1674 - } 1675 - } 1676 - function merge_descendings(loop$list1, loop$list2, loop$compare, loop$acc) { 1677 - while (true) { 1678 - let list1 = loop$list1; 1679 - let list22 = loop$list2; 1680 - let compare4 = loop$compare; 1681 - let acc = loop$acc; 1682 - if (list1 instanceof Empty) { 1683 - let list4 = list22; 1684 - return reverse_and_prepend(list4, acc); 1685 - } else if (list22 instanceof Empty) { 1686 - let list4 = list1; 1687 - return reverse_and_prepend(list4, acc); 1688 - } else { 1689 - let first1 = list1.head; 1690 - let rest1 = list1.tail; 1691 - let first2 = list22.head; 1692 - let rest2 = list22.tail; 1693 - let $ = compare4(first1, first2); 1694 - if ($ instanceof Lt) { 1695 - loop$list1 = list1; 1696 - loop$list2 = rest2; 1697 - loop$compare = compare4; 1698 - loop$acc = prepend(first2, acc); 1699 - } else if ($ instanceof Eq) { 1700 - loop$list1 = rest1; 1701 - loop$list2 = list22; 1702 - loop$compare = compare4; 1703 - loop$acc = prepend(first1, acc); 1704 - } else { 1705 - loop$list1 = rest1; 1706 - loop$list2 = list22; 1707 - loop$compare = compare4; 1708 - loop$acc = prepend(first1, acc); 1709 - } 1710 - } 1711 - } 1712 - } 1713 - function merge_descending_pairs(loop$sequences, loop$compare, loop$acc) { 1714 - while (true) { 1715 - let sequences2 = loop$sequences; 1716 - let compare4 = loop$compare; 1717 - let acc = loop$acc; 1718 - if (sequences2 instanceof Empty) { 1719 - return reverse(acc); 1720 - } else { 1721 - let $ = sequences2.tail; 1722 - if ($ instanceof Empty) { 1723 - let sequence = sequences2.head; 1724 - return reverse(prepend(reverse(sequence), acc)); 1725 - } else { 1726 - let descending1 = sequences2.head; 1727 - let descending2 = $.head; 1728 - let rest$1 = $.tail; 1729 - let ascending = merge_descendings( 1730 - descending1, 1731 - descending2, 1732 - compare4, 1733 - toList([]) 1734 - ); 1735 - loop$sequences = rest$1; 1736 - loop$compare = compare4; 1737 - loop$acc = prepend(ascending, acc); 1738 - } 1739 - } 1740 - } 1741 - } 1742 - function merge_all(loop$sequences, loop$direction, loop$compare) { 1743 - while (true) { 1744 - let sequences2 = loop$sequences; 1745 - let direction = loop$direction; 1746 - let compare4 = loop$compare; 1747 - if (sequences2 instanceof Empty) { 1748 - return toList([]); 1749 - } else if (direction instanceof Ascending) { 1750 - let $ = sequences2.tail; 1751 - if ($ instanceof Empty) { 1752 - let sequence = sequences2.head; 1753 - return sequence; 1754 - } else { 1755 - let sequences$1 = merge_ascending_pairs(sequences2, compare4, toList([])); 1756 - loop$sequences = sequences$1; 1757 - loop$direction = new Descending(); 1758 - loop$compare = compare4; 1759 - } 1760 - } else { 1761 - let $ = sequences2.tail; 1762 - if ($ instanceof Empty) { 1763 - let sequence = sequences2.head; 1764 - return reverse(sequence); 1765 - } else { 1766 - let sequences$1 = merge_descending_pairs(sequences2, compare4, toList([])); 1767 - loop$sequences = sequences$1; 1768 - loop$direction = new Ascending(); 1769 - loop$compare = compare4; 1770 - } 1771 - } 1772 - } 1773 - } 1774 - function sort(list4, compare4) { 1775 - if (list4 instanceof Empty) { 1776 - return toList([]); 1777 - } else { 1778 - let $ = list4.tail; 1779 - if ($ instanceof Empty) { 1780 - let x = list4.head; 1781 - return toList([x]); 1782 - } else { 1783 - let x = list4.head; 1784 - let y = $.head; 1785 - let rest$1 = $.tail; 1786 - let _block; 1787 - let $1 = compare4(x, y); 1788 - if ($1 instanceof Lt) { 1789 - _block = new Ascending(); 1790 - } else if ($1 instanceof Eq) { 1791 - _block = new Ascending(); 1792 - } else { 1793 - _block = new Descending(); 1794 - } 1795 - let direction = _block; 1796 - let sequences$1 = sequences( 1797 - rest$1, 1798 - compare4, 1799 - toList([x]), 1800 - direction, 1801 - y, 1802 - toList([]) 1803 - ); 1804 - return merge_all(sequences$1, new Ascending(), compare4); 1805 - } 1806 - } 1807 - } 1808 - function sized_chunk_loop(loop$list, loop$count, loop$left, loop$current_chunk, loop$acc) { 1809 - while (true) { 1810 - let list4 = loop$list; 1811 - let count = loop$count; 1812 - let left = loop$left; 1813 - let current_chunk = loop$current_chunk; 1814 - let acc = loop$acc; 1815 - if (list4 instanceof Empty) { 1816 - if (current_chunk instanceof Empty) { 1817 - return reverse(acc); 1818 - } else { 1819 - let remaining = current_chunk; 1820 - return reverse(prepend(reverse(remaining), acc)); 1821 - } 1822 - } else { 1823 - let first$1 = list4.head; 1824 - let rest$1 = list4.tail; 1825 - let chunk$1 = prepend(first$1, current_chunk); 1826 - let $ = left > 1; 1827 - if ($) { 1828 - loop$list = rest$1; 1829 - loop$count = count; 1830 - loop$left = left - 1; 1831 - loop$current_chunk = chunk$1; 1832 - loop$acc = acc; 1833 - } else { 1834 - loop$list = rest$1; 1835 - loop$count = count; 1836 - loop$left = count; 1837 - loop$current_chunk = toList([]); 1838 - loop$acc = prepend(reverse(chunk$1), acc); 1839 - } 1840 - } 1841 - } 1842 - } 1843 - function sized_chunk(list4, count) { 1844 - return sized_chunk_loop(list4, count, count, toList([]), toList([])); 1845 - } 1846 - function shuffle_pair_unwrap_loop(loop$list, loop$acc) { 1847 - while (true) { 1848 - let list4 = loop$list; 1849 - let acc = loop$acc; 1850 - if (list4 instanceof Empty) { 1851 - return acc; 1852 - } else { 1853 - let elem_pair = list4.head; 1854 - let enumerable = list4.tail; 1855 - loop$list = enumerable; 1856 - loop$acc = prepend(elem_pair[1], acc); 1857 - } 1858 - } 1859 - } 1860 - function do_shuffle_by_pair_indexes(list_of_pairs) { 1861 - return sort( 1862 - list_of_pairs, 1863 - (a_pair, b_pair) => { 1864 - return compare(a_pair[0], b_pair[0]); 1865 - } 1866 - ); 1867 - } 1868 - function shuffle(list4) { 1869 - let _pipe = list4; 1870 - let _pipe$1 = fold( 1871 - _pipe, 1872 - toList([]), 1873 - (acc, a) => { 1874 - return prepend([random_uniform(), a], acc); 1875 - } 1876 - ); 1877 - let _pipe$2 = do_shuffle_by_pair_indexes(_pipe$1); 1878 - return shuffle_pair_unwrap_loop(_pipe$2, toList([])); 1879 - } 1880 - 1881 - // build/dev/javascript/gleam_stdlib/gleam/string.mjs 1882 - function append2(first2, second) { 1883 - return first2 + second; 1884 - } 1885 - function concat_loop(loop$strings, loop$accumulator) { 1886 - while (true) { 1887 - let strings = loop$strings; 1888 - let accumulator = loop$accumulator; 1889 - if (strings instanceof Empty) { 1890 - return accumulator; 1891 - } else { 1892 - let string5 = strings.head; 1893 - let strings$1 = strings.tail; 1894 - loop$strings = strings$1; 1895 - loop$accumulator = accumulator + string5; 1896 - } 1897 - } 1898 - } 1899 - function concat2(strings) { 1900 - return concat_loop(strings, ""); 1901 - } 1902 - function repeat_loop(loop$string, loop$times, loop$acc) { 1903 - while (true) { 1904 - let string5 = loop$string; 1905 - let times = loop$times; 1906 - let acc = loop$acc; 1907 - let $ = times <= 0; 1908 - if ($) { 1909 - return acc; 1910 - } else { 1911 - loop$string = string5; 1912 - loop$times = times - 1; 1913 - loop$acc = acc + string5; 1914 - } 1915 - } 1916 - } 1917 - function repeat(string5, times) { 1918 - return repeat_loop(string5, times, ""); 1919 - } 1920 - function join_loop(loop$strings, loop$separator, loop$accumulator) { 1921 - while (true) { 1922 - let strings = loop$strings; 1923 - let separator = loop$separator; 1924 - let accumulator = loop$accumulator; 1925 - if (strings instanceof Empty) { 1926 - return accumulator; 1927 - } else { 1928 - let string5 = strings.head; 1929 - let strings$1 = strings.tail; 1930 - loop$strings = strings$1; 1931 - loop$separator = separator; 1932 - loop$accumulator = accumulator + separator + string5; 1933 - } 1934 - } 1935 - } 1936 - function join(strings, separator) { 1937 - if (strings instanceof Empty) { 1938 - return ""; 1939 - } else { 1940 - let first$1 = strings.head; 1941 - let rest = strings.tail; 1942 - return join_loop(rest, separator, first$1); 1943 - } 1944 - } 1945 - function do_to_utf_codepoints(string5) { 1946 - let _pipe = string5; 1947 - let _pipe$1 = string_to_codepoint_integer_list(_pipe); 1948 - return map(_pipe$1, codepoint); 1949 - } 1950 - function to_utf_codepoints(string5) { 1951 - return do_to_utf_codepoints(string5); 1952 - } 1953 - function inspect2(term) { 1954 - let _pipe = inspect(term); 1955 - return identity(_pipe); 1956 - } 1957 - 1958 - // build/dev/javascript/gleam_stdlib/gleam/dynamic/decode.mjs 1959 - var DecodeError = class extends CustomType { 1960 - constructor(expected, found, path) { 1961 - super(); 1962 - this.expected = expected; 1963 - this.found = found; 1964 - this.path = path; 1965 - } 1966 - }; 1967 - var Decoder = class extends CustomType { 1968 - constructor(function$) { 1969 - super(); 1970 - this.function = function$; 1971 - } 1972 - }; 1973 - function run(data, decoder) { 1974 - let $ = decoder.function(data); 1975 - let maybe_invalid_data = $[0]; 1976 - let errors = $[1]; 1977 - if (errors instanceof Empty) { 1978 - return new Ok(maybe_invalid_data); 1979 - } else { 1980 - return new Error(errors); 1981 - } 1982 - } 1983 - function success(data) { 1984 - return new Decoder((_) => { 1985 - return [data, toList([])]; 1986 - }); 1987 - } 1988 - function map2(decoder, transformer) { 1989 - return new Decoder( 1990 - (d) => { 1991 - let $ = decoder.function(d); 1992 - let data = $[0]; 1993 - let errors = $[1]; 1994 - return [transformer(data), errors]; 1995 - } 1996 - ); 1997 - } 1998 - function run_decoders(loop$data, loop$failure, loop$decoders) { 1999 - while (true) { 2000 - let data = loop$data; 2001 - let failure2 = loop$failure; 2002 - let decoders = loop$decoders; 2003 - if (decoders instanceof Empty) { 2004 - return failure2; 2005 - } else { 2006 - let decoder = decoders.head; 2007 - let decoders$1 = decoders.tail; 2008 - let $ = decoder.function(data); 2009 - let layer = $; 2010 - let errors = $[1]; 2011 - if (errors instanceof Empty) { 2012 - return layer; 2013 - } else { 2014 - loop$data = data; 2015 - loop$failure = failure2; 2016 - loop$decoders = decoders$1; 2017 - } 2018 - } 2019 - } 2020 - } 2021 - function one_of(first2, alternatives) { 2022 - return new Decoder( 2023 - (dynamic_data) => { 2024 - let $ = first2.function(dynamic_data); 2025 - let layer = $; 2026 - let errors = $[1]; 2027 - if (errors instanceof Empty) { 2028 - return layer; 2029 - } else { 2030 - return run_decoders(dynamic_data, layer, alternatives); 2031 - } 2032 - } 2033 - ); 2034 - } 2035 - function run_dynamic_function(data, name, f) { 2036 - let $ = f(data); 2037 - if ($ instanceof Ok) { 2038 - let data$1 = $[0]; 2039 - return [data$1, toList([])]; 2040 - } else { 2041 - let zero = $[0]; 2042 - return [ 2043 - zero, 2044 - toList([new DecodeError(name, classify_dynamic(data), toList([]))]) 2045 - ]; 2046 - } 2047 - } 2048 - function decode_int(data) { 2049 - return run_dynamic_function(data, "Int", int); 2050 - } 2051 - var int2 = /* @__PURE__ */ new Decoder(decode_int); 2052 - function decode_string(data) { 2053 - return run_dynamic_function(data, "String", string); 2054 - } 2055 - var string2 = /* @__PURE__ */ new Decoder(decode_string); 2056 - function push_path(layer, path) { 2057 - let decoder = one_of( 2058 - string2, 2059 - toList([ 2060 - (() => { 2061 - let _pipe = int2; 2062 - return map2(_pipe, to_string); 2063 - })() 2064 - ]) 2065 - ); 2066 - let path$1 = map( 2067 - path, 2068 - (key) => { 2069 - let key$1 = identity(key); 2070 - let $ = run(key$1, decoder); 2071 - if ($ instanceof Ok) { 2072 - let key$2 = $[0]; 2073 - return key$2; 2074 - } else { 2075 - return "<" + classify_dynamic(key$1) + ">"; 2076 - } 2077 - } 2078 - ); 2079 - let errors = map( 2080 - layer[1], 2081 - (error) => { 2082 - let _record = error; 2083 - return new DecodeError( 2084 - _record.expected, 2085 - _record.found, 2086 - append(path$1, error.path) 2087 - ); 2088 - } 2089 - ); 2090 - return [layer[0], errors]; 2091 - } 2092 - function index3(loop$path, loop$position, loop$inner, loop$data, loop$handle_miss) { 2093 - while (true) { 2094 - let path = loop$path; 2095 - let position = loop$position; 2096 - let inner = loop$inner; 2097 - let data = loop$data; 2098 - let handle_miss = loop$handle_miss; 2099 - if (path instanceof Empty) { 2100 - let _pipe = inner(data); 2101 - return push_path(_pipe, reverse(position)); 2102 - } else { 2103 - let key = path.head; 2104 - let path$1 = path.tail; 2105 - let $ = index2(data, key); 2106 - if ($ instanceof Ok) { 2107 - let $1 = $[0]; 2108 - if ($1 instanceof Some) { 2109 - let data$1 = $1[0]; 2110 - loop$path = path$1; 2111 - loop$position = prepend(key, position); 2112 - loop$inner = inner; 2113 - loop$data = data$1; 2114 - loop$handle_miss = handle_miss; 2115 - } else { 2116 - return handle_miss(data, prepend(key, position)); 2117 - } 2118 - } else { 2119 - let kind = $[0]; 2120 - let $1 = inner(data); 2121 - let default$ = $1[0]; 2122 - let _pipe = [ 2123 - default$, 2124 - toList([new DecodeError(kind, classify_dynamic(data), toList([]))]) 2125 - ]; 2126 - return push_path(_pipe, reverse(position)); 2127 - } 2128 - } 2129 - } 2130 - } 2131 - function subfield(field_path, field_decoder, next) { 2132 - return new Decoder( 2133 - (data) => { 2134 - let $ = index3( 2135 - field_path, 2136 - toList([]), 2137 - field_decoder.function, 2138 - data, 2139 - (data2, position) => { 2140 - let $12 = field_decoder.function(data2); 2141 - let default$ = $12[0]; 2142 - let _pipe = [ 2143 - default$, 2144 - toList([new DecodeError("Field", "Nothing", toList([]))]) 2145 - ]; 2146 - return push_path(_pipe, reverse(position)); 2147 - } 2148 - ); 2149 - let out = $[0]; 2150 - let errors1 = $[1]; 2151 - let $1 = next(out).function(data); 2152 - let out$1 = $1[0]; 2153 - let errors2 = $1[1]; 2154 - return [out$1, append(errors1, errors2)]; 2155 - } 2156 - ); 2157 - } 2158 - 2159 - // build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs 2160 - var Nil = void 0; 2161 - var NOT_FOUND = {}; 2162 - function identity(x) { 2163 - return x; 2164 - } 2165 - function parse_int(value) { 2166 - if (/^[-+]?(\d+)$/.test(value)) { 2167 - return new Ok(parseInt(value)); 2168 - } else { 2169 - return new Error(Nil); 2170 - } 2171 - } 2172 - function to_string(term) { 2173 - return term.toString(); 2174 - } 2175 - function starts_with(haystack, needle) { 2176 - return haystack.startsWith(needle); 2177 - } 2178 - var unicode_whitespaces = [ 2179 - " ", 2180 - // Space 2181 - " ", 2182 - // Horizontal tab 2183 - "\n", 2184 - // Line feed 2185 - "\v", 2186 - // Vertical tab 2187 - "\f", 2188 - // Form feed 2189 - "\r", 2190 - // Carriage return 2191 - "\x85", 2192 - // Next line 2193 - "\u2028", 2194 - // Line separator 2195 - "\u2029" 2196 - // Paragraph separator 2197 - ].join(""); 2198 - var trim_start_regex = /* @__PURE__ */ new RegExp( 2199 - `^[${unicode_whitespaces}]*` 2200 - ); 2201 - var trim_end_regex = /* @__PURE__ */ new RegExp(`[${unicode_whitespaces}]*$`); 2202 - function ceiling(float2) { 2203 - return Math.ceil(float2); 2204 - } 2205 - function floor(float2) { 2206 - return Math.floor(float2); 2207 - } 2208 - function round2(float2) { 2209 - return Math.round(float2); 2210 - } 2211 - function power2(base, exponent) { 2212 - return Math.pow(base, exponent); 2213 - } 2214 - function random_uniform() { 2215 - const random_uniform_result = Math.random(); 2216 - if (random_uniform_result === 1) { 2217 - return random_uniform(); 2218 - } 2219 - return random_uniform_result; 2220 - } 2221 - function codepoint(int5) { 2222 - return new UtfCodepoint(int5); 2223 - } 2224 - function string_to_codepoint_integer_list(string5) { 2225 - return List.fromArray(Array.from(string5).map((item) => item.codePointAt(0))); 2226 - } 2227 - function utf_codepoint_to_int(utf_codepoint) { 2228 - return utf_codepoint.value; 2229 - } 2230 - function new_map() { 2231 - return Dict.new(); 2232 - } 2233 - function map_to_list(map7) { 2234 - return List.fromArray(map7.entries()); 2235 - } 2236 - function map_get(map7, key) { 2237 - const value = map7.get(key, NOT_FOUND); 2238 - if (value === NOT_FOUND) { 2239 - return new Error(Nil); 2240 - } 2241 - return new Ok(value); 2242 - } 2243 - function map_insert(key, value, map7) { 2244 - return map7.set(key, value); 2245 - } 2246 - function classify_dynamic(data) { 2247 - if (typeof data === "string") { 2248 - return "String"; 2249 - } else if (typeof data === "boolean") { 2250 - return "Bool"; 2251 - } else if (data instanceof Result) { 2252 - return "Result"; 2253 - } else if (data instanceof List) { 2254 - return "List"; 2255 - } else if (data instanceof BitArray) { 2256 - return "BitArray"; 2257 - } else if (data instanceof Dict) { 2258 - return "Dict"; 2259 - } else if (Number.isInteger(data)) { 2260 - return "Int"; 2261 - } else if (Array.isArray(data)) { 2262 - return `Array`; 2263 - } else if (typeof data === "number") { 2264 - return "Float"; 2265 - } else if (data === null) { 2266 - return "Nil"; 2267 - } else if (data === void 0) { 2268 - return "Nil"; 2269 - } else { 2270 - const type = typeof data; 2271 - return type.charAt(0).toUpperCase() + type.slice(1); 2272 - } 2273 - } 2274 - function bitwise_and(x, y) { 2275 - return Number(BigInt(x) & BigInt(y)); 2276 - } 2277 - function bitwise_or(x, y) { 2278 - return Number(BigInt(x) | BigInt(y)); 2279 - } 2280 - function bitwise_exclusive_or(x, y) { 2281 - return Number(BigInt(x) ^ BigInt(y)); 2282 - } 2283 - function bitwise_shift_left(x, y) { 2284 - return Number(BigInt(x) << BigInt(y)); 2285 - } 2286 - function bitwise_shift_right(x, y) { 2287 - return Number(BigInt(x) >> BigInt(y)); 2288 - } 2289 - function inspect(v) { 2290 - return new Inspector().inspect(v); 2291 - } 2292 - function float_to_string(float2) { 2293 - const string5 = float2.toString().replace("+", ""); 2294 - if (string5.indexOf(".") >= 0) { 2295 - return string5; 2296 - } else { 2297 - const index4 = string5.indexOf("e"); 2298 - if (index4 >= 0) { 2299 - return string5.slice(0, index4) + ".0" + string5.slice(index4); 2300 - } else { 2301 - return string5 + ".0"; 2302 - } 2303 - } 2304 - } 2305 - var Inspector = class { 2306 - #references = /* @__PURE__ */ new Set(); 2307 - inspect(v) { 2308 - const t = typeof v; 2309 - if (v === true) return "True"; 2310 - if (v === false) return "False"; 2311 - if (v === null) return "//js(null)"; 2312 - if (v === void 0) return "Nil"; 2313 - if (t === "string") return this.#string(v); 2314 - if (t === "bigint" || Number.isInteger(v)) return v.toString(); 2315 - if (t === "number") return float_to_string(v); 2316 - if (v instanceof UtfCodepoint) return this.#utfCodepoint(v); 2317 - if (v instanceof BitArray) return this.#bit_array(v); 2318 - if (v instanceof RegExp) return `//js(${v})`; 2319 - if (v instanceof Date) return `//js(Date("${v.toISOString()}"))`; 2320 - if (v instanceof globalThis.Error) return `//js(${v.toString()})`; 2321 - if (v instanceof Function) { 2322 - const args = []; 2323 - for (const i of Array(v.length).keys()) 2324 - args.push(String.fromCharCode(i + 97)); 2325 - return `//fn(${args.join(", ")}) { ... }`; 2326 - } 2327 - if (this.#references.size === this.#references.add(v).size) { 2328 - return "//js(circular reference)"; 2329 - } 2330 - let printed; 2331 - if (Array.isArray(v)) { 2332 - printed = `#(${v.map((v2) => this.inspect(v2)).join(", ")})`; 2333 - } else if (v instanceof List) { 2334 - printed = this.#list(v); 2335 - } else if (v instanceof CustomType) { 2336 - printed = this.#customType(v); 2337 - } else if (v instanceof Dict) { 2338 - printed = this.#dict(v); 2339 - } else if (v instanceof Set) { 2340 - return `//js(Set(${[...v].map((v2) => this.inspect(v2)).join(", ")}))`; 2341 - } else { 2342 - printed = this.#object(v); 2343 - } 2344 - this.#references.delete(v); 2345 - return printed; 2346 - } 2347 - #object(v) { 2348 - const name = Object.getPrototypeOf(v)?.constructor?.name || "Object"; 2349 - const props = []; 2350 - for (const k of Object.keys(v)) { 2351 - props.push(`${this.inspect(k)}: ${this.inspect(v[k])}`); 2352 - } 2353 - const body = props.length ? " " + props.join(", ") + " " : ""; 2354 - const head = name === "Object" ? "" : name + " "; 2355 - return `//js(${head}{${body}})`; 2356 - } 2357 - #dict(map7) { 2358 - let body = "dict.from_list(["; 2359 - let first2 = true; 2360 - map7.forEach((value, key) => { 2361 - if (!first2) body = body + ", "; 2362 - body = body + "#(" + this.inspect(key) + ", " + this.inspect(value) + ")"; 2363 - first2 = false; 2364 - }); 2365 - return body + "])"; 2366 - } 2367 - #customType(record) { 2368 - const props = Object.keys(record).map((label) => { 2369 - const value = this.inspect(record[label]); 2370 - return isNaN(parseInt(label)) ? `${label}: ${value}` : value; 2371 - }).join(", "); 2372 - return props ? `${record.constructor.name}(${props})` : record.constructor.name; 2373 - } 2374 - #list(list4) { 2375 - if (list4 instanceof Empty) { 2376 - return "[]"; 2377 - } 2378 - let char_out = 'charlist.from_string("'; 2379 - let list_out = "["; 2380 - let current = list4; 2381 - while (current instanceof NonEmpty) { 2382 - let element4 = current.head; 2383 - current = current.tail; 2384 - if (list_out !== "[") { 2385 - list_out += ", "; 2386 - } 2387 - list_out += this.inspect(element4); 2388 - if (char_out) { 2389 - if (Number.isInteger(element4) && element4 >= 32 && element4 <= 126) { 2390 - char_out += String.fromCharCode(element4); 2391 - } else { 2392 - char_out = null; 2393 - } 2394 - } 2395 - } 2396 - if (char_out) { 2397 - return char_out + '")'; 2398 - } else { 2399 - return list_out + "]"; 2400 - } 2401 - } 2402 - #string(str) { 2403 - let new_str = '"'; 2404 - for (let i = 0; i < str.length; i++) { 2405 - const char = str[i]; 2406 - switch (char) { 2407 - case "\n": 2408 - new_str += "\\n"; 2409 - break; 2410 - case "\r": 2411 - new_str += "\\r"; 2412 - break; 2413 - case " ": 2414 - new_str += "\\t"; 2415 - break; 2416 - case "\f": 2417 - new_str += "\\f"; 2418 - break; 2419 - case "\\": 2420 - new_str += "\\\\"; 2421 - break; 2422 - case '"': 2423 - new_str += '\\"'; 2424 - break; 2425 - default: 2426 - if (char < " " || char > "~" && char < "\xA0") { 2427 - new_str += "\\u{" + char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0") + "}"; 2428 - } else { 2429 - new_str += char; 2430 - } 2431 - } 2432 - } 2433 - new_str += '"'; 2434 - return new_str; 2435 - } 2436 - #utfCodepoint(codepoint2) { 2437 - return `//utfcodepoint(${String.fromCodePoint(codepoint2.value)})`; 2438 - } 2439 - #bit_array(bits) { 2440 - if (bits.bitSize === 0) { 2441 - return "<<>>"; 2442 - } 2443 - let acc = "<<"; 2444 - for (let i = 0; i < bits.byteSize - 1; i++) { 2445 - acc += bits.byteAt(i).toString(); 2446 - acc += ", "; 2447 - } 2448 - if (bits.byteSize * 8 === bits.bitSize) { 2449 - acc += bits.byteAt(bits.byteSize - 1).toString(); 2450 - } else { 2451 - const trailingBitsCount = bits.bitSize % 8; 2452 - acc += bits.byteAt(bits.byteSize - 1) >> 8 - trailingBitsCount; 2453 - acc += `:size(${trailingBitsCount})`; 2454 - } 2455 - acc += ">>"; 2456 - return acc; 2457 - } 2458 - }; 2459 - function base16_encode(bit_array2) { 2460 - const trailingBitsCount = bit_array2.bitSize % 8; 2461 - let result = ""; 2462 - for (let i = 0; i < bit_array2.byteSize; i++) { 2463 - let byte = bit_array2.byteAt(i); 2464 - if (i === bit_array2.byteSize - 1 && trailingBitsCount !== 0) { 2465 - const unusedBitsCount = 8 - trailingBitsCount; 2466 - byte = byte >> unusedBitsCount << unusedBitsCount; 2467 - } 2468 - result += byte.toString(16).padStart(2, "0").toUpperCase(); 2469 - } 2470 - return result; 2471 - } 2472 - function index2(data, key) { 2473 - if (data instanceof Dict || data instanceof WeakMap || data instanceof Map) { 2474 - const token2 = {}; 2475 - const entry = data.get(key, token2); 2476 - if (entry === token2) return new Ok(new None()); 2477 - return new Ok(new Some(entry)); 2478 - } 2479 - const key_is_int = Number.isInteger(key); 2480 - if (key_is_int && key >= 0 && key < 8 && data instanceof List) { 2481 - let i = 0; 2482 - for (const value of data) { 2483 - if (i === key) return new Ok(new Some(value)); 2484 - i++; 2485 - } 2486 - return new Error("Indexable"); 2487 - } 2488 - if (key_is_int && Array.isArray(data) || data && typeof data === "object" || data && Object.getPrototypeOf(data) === Object.prototype) { 2489 - if (key in data) return new Ok(new Some(data[key])); 2490 - return new Ok(new None()); 2491 - } 2492 - return new Error(key_is_int ? "Indexable" : "Dict"); 2493 - } 2494 - function int(data) { 2495 - if (Number.isInteger(data)) return new Ok(data); 2496 - return new Error(0); 2497 - } 2498 - function string(data) { 2499 - if (typeof data === "string") return new Ok(data); 2500 - return new Error(""); 2501 - } 2502 - 2503 - // build/dev/javascript/gleam_stdlib/gleam/float.mjs 2504 - function compare(a, b) { 2505 - let $ = a === b; 2506 - if ($) { 2507 - return new Eq(); 2508 - } else { 2509 - let $1 = a < b; 2510 - if ($1) { 2511 - return new Lt(); 2512 - } else { 2513 - return new Gt(); 2514 - } 2515 - } 2516 - } 2517 - function power(base, exponent) { 2518 - let fractional = ceiling(exponent) - exponent > 0; 2519 - let $ = base < 0 && fractional || base === 0 && exponent < 0; 2520 - if ($) { 2521 - return new Error(void 0); 2522 - } else { 2523 - return new Ok(power2(base, exponent)); 2524 - } 2525 - } 2526 - function square_root(x) { 2527 - return power(x, 0.5); 2528 - } 2529 - function negate(x) { 2530 - return -1 * x; 2531 - } 2532 - function round(x) { 2533 - let $ = x >= 0; 2534 - if ($) { 2535 - return round2(x); 2536 - } else { 2537 - return 0 - round2(negate(x)); 2538 - } 2539 - } 2540 - 2541 - // build/dev/javascript/gleam_stdlib/gleam/result.mjs 2542 - function is_ok(result) { 2543 - if (result instanceof Ok) { 2544 - return true; 2545 - } else { 2546 - return false; 2547 - } 2548 - } 2549 - function unwrap2(result, default$) { 2550 - if (result instanceof Ok) { 2551 - let v = result[0]; 2552 - return v; 2553 - } else { 2554 - return default$; 2555 - } 2556 - } 2557 - 2558 - // build/dev/javascript/iv/iv_ffi.mjs 2559 - var empty = () => []; 2560 - var singleton = (x) => [x]; 2561 - var append3 = (xs, x) => [...xs, x]; 2562 - var get1 = (idx, xs) => xs[idx - 1]; 2563 - var set1 = (idx, xs, x) => xs.with(idx - 1, x); 2564 - var length3 = (xs) => xs.length; 2565 - var bsl = (a, b) => a << b; 2566 - var bsr = (a, b) => a >> b; 2567 - 2568 - // build/dev/javascript/iv/iv/internal/vector.mjs 2569 - function fold_loop(loop$xs, loop$state, loop$idx, loop$len, loop$fun) { 2570 - while (true) { 2571 - let xs = loop$xs; 2572 - let state = loop$state; 2573 - let idx = loop$idx; 2574 - let len = loop$len; 2575 - let fun = loop$fun; 2576 - let $ = idx <= len; 2577 - if ($) { 2578 - loop$xs = xs; 2579 - loop$state = fun(state, get1(idx, xs)); 2580 - loop$idx = idx + 1; 2581 - loop$len = len; 2582 - loop$fun = fun; 2583 - } else { 2584 - return state; 2585 - } 2586 - } 2587 - } 2588 - function fold_skip_first(xs, state, fun) { 2589 - let len = length3(xs); 2590 - return fold_loop(xs, state, 2, len, fun); 2591 - } 2592 - function fold_right_loop(loop$xs, loop$state, loop$idx, loop$fun) { 2593 - while (true) { 2594 - let xs = loop$xs; 2595 - let state = loop$state; 2596 - let idx = loop$idx; 2597 - let fun = loop$fun; 2598 - let $ = idx > 0; 2599 - if ($) { 2600 - loop$xs = xs; 2601 - loop$state = fun(state, get1(idx, xs)); 2602 - loop$idx = idx - 1; 2603 - loop$fun = fun; 2604 - } else { 2605 - return state; 2606 - } 2607 - } 2608 - } 2609 - function fold_right(xs, state, fun) { 2610 - let len = length3(xs); 2611 - return fold_right_loop(xs, state, len, fun); 2612 - } 2613 - function index_fold_loop(loop$xs, loop$state, loop$idx, loop$len, loop$fun) { 2614 - while (true) { 2615 - let xs = loop$xs; 2616 - let state = loop$state; 2617 - let idx = loop$idx; 2618 - let len = loop$len; 2619 - let fun = loop$fun; 2620 - let $ = idx <= len; 2621 - if ($) { 2622 - loop$xs = xs; 2623 - loop$state = fun(state, get1(idx, xs), idx); 2624 - loop$idx = idx + 1; 2625 - loop$len = len; 2626 - loop$fun = fun; 2627 - } else { 2628 - return state; 2629 - } 2630 - } 2631 - } 2632 - function index_fold(xs, state, fun) { 2633 - let len = length3(xs); 2634 - return index_fold_loop(xs, state, 1, len, fun); 2635 - } 2636 - function index_map(xs, fun) { 2637 - return index_fold( 2638 - xs, 2639 - empty(), 2640 - (result, item, index4) => { 2641 - return append3(result, fun(item, index4)); 2642 - } 2643 - ); 2644 - } 2645 - 2646 - // build/dev/javascript/iv/iv/internal/node.mjs 2647 - var Balanced = class extends CustomType { 2648 - constructor(size3, children) { 2649 - super(); 2650 - this.size = size3; 2651 - this.children = children; 2652 - } 2653 - }; 2654 - var Unbalanced = class extends CustomType { 2655 - constructor(sizes, children) { 2656 - super(); 2657 - this.sizes = sizes; 2658 - this.children = children; 2659 - } 2660 - }; 2661 - var Leaf = class extends CustomType { 2662 - constructor(children) { 2663 - super(); 2664 - this.children = children; 2665 - } 2666 - }; 2667 - function leaf(items) { 2668 - return new Leaf(items); 2669 - } 2670 - function size(node2) { 2671 - if (node2 instanceof Balanced) { 2672 - let size$1 = node2.size; 2673 - return size$1; 2674 - } else if (node2 instanceof Unbalanced) { 2675 - let sizes = node2.sizes; 2676 - return get1(length3(sizes), sizes); 2677 - } else { 2678 - let children = node2.children; 2679 - return length3(children); 2680 - } 2681 - } 2682 - function compute_sizes(nodes) { 2683 - let first_size = size(get1(1, nodes)); 2684 - return fold_skip_first( 2685 - nodes, 2686 - singleton(first_size), 2687 - (sizes, node2) => { 2688 - let size$1 = get1(length3(sizes), sizes) + size(node2); 2689 - return append3(sizes, size$1); 2690 - } 2691 - ); 2692 - } 2693 - function find_size(loop$sizes, loop$size_idx_plus_one, loop$index) { 2694 - while (true) { 2695 - let sizes = loop$sizes; 2696 - let size_idx_plus_one = loop$size_idx_plus_one; 2697 - let index4 = loop$index; 2698 - let $ = get1(size_idx_plus_one, sizes) > index4; 2699 - if ($) { 2700 - return size_idx_plus_one - 1; 2701 - } else { 2702 - loop$sizes = sizes; 2703 - loop$size_idx_plus_one = size_idx_plus_one + 1; 2704 - loop$index = index4; 2705 - } 2706 - } 2707 - } 2708 - function fold_right2(node2, state, fun) { 2709 - if (node2 instanceof Balanced) { 2710 - let children = node2.children; 2711 - return fold_right( 2712 - children, 2713 - state, 2714 - (state2, node3) => { 2715 - return fold_right2(node3, state2, fun); 2716 - } 2717 - ); 2718 - } else if (node2 instanceof Unbalanced) { 2719 - let children = node2.children; 2720 - return fold_right( 2721 - children, 2722 - state, 2723 - (state2, node3) => { 2724 - return fold_right2(node3, state2, fun); 2725 - } 2726 - ); 2727 - } else { 2728 - let children = node2.children; 2729 - return fold_right(children, state, fun); 2730 - } 2731 - } 2732 - function balanced(shift, nodes) { 2733 - let len = length3(nodes); 2734 - let last_child = get1(len, nodes); 2735 - let max_size = bsl(1, shift); 2736 - let size$1 = max_size * (len - 1) + size(last_child); 2737 - return new Balanced(size$1, nodes); 2738 - } 2739 - function branch(shift, nodes) { 2740 - let len = length3(nodes); 2741 - let max_size = bsl(1, shift); 2742 - let sizes = compute_sizes(nodes); 2743 - let _block; 2744 - if (len === 1) { 2745 - _block = 0; 2746 - } else { 2747 - _block = get1(len - 1, sizes); 2748 - } 2749 - let prefix_size = _block; 2750 - let is_balanced = prefix_size === max_size * (len - 1); 2751 - if (is_balanced) { 2752 - let size$1 = get1(len, sizes); 2753 - return new Balanced(size$1, nodes); 2754 - } else { 2755 - return new Unbalanced(sizes, nodes); 2756 - } 2757 - } 2758 - var branch_bits = 5; 2759 - function get(loop$node, loop$shift, loop$index) { 2760 - while (true) { 2761 - let node2 = loop$node; 2762 - let shift = loop$shift; 2763 - let index4 = loop$index; 2764 - if (node2 instanceof Balanced) { 2765 - let children = node2.children; 2766 - let node_index = bsr(index4, shift); 2767 - let index$1 = index4 - bsl(node_index, shift); 2768 - let child = get1(node_index + 1, children); 2769 - loop$node = child; 2770 - loop$shift = shift - branch_bits; 2771 - loop$index = index$1; 2772 - } else if (node2 instanceof Unbalanced) { 2773 - let sizes = node2.sizes; 2774 - let children = node2.children; 2775 - let start_search_index = bsr(index4, shift); 2776 - let node_index = find_size(sizes, start_search_index + 1, index4); 2777 - let _block; 2778 - if (node_index === 0) { 2779 - _block = index4; 2780 - } else { 2781 - _block = index4 - get1(node_index, sizes); 2782 - } 2783 - let index$1 = _block; 2784 - let child = get1(node_index + 1, children); 2785 - loop$node = child; 2786 - loop$shift = shift - branch_bits; 2787 - loop$index = index$1; 2788 - } else { 2789 - let children = node2.children; 2790 - return get1(index4 + 1, children); 2791 - } 2792 - } 2793 - } 2794 - function update(shift, node2, index4, fun) { 2795 - if (node2 instanceof Balanced) { 2796 - let size$1 = node2.size; 2797 - let children = node2.children; 2798 - let node_index = bsr(index4, shift); 2799 - let index$1 = index4 - bsl(node_index, shift); 2800 - let _block; 2801 - let _pipe = get1(node_index + 1, children); 2802 - let _pipe$1 = ((_capture) => { 2803 - return update(shift - branch_bits, _capture, index$1, fun); 2804 - })(_pipe); 2805 - _block = ((_capture) => { 2806 - return set1(node_index + 1, children, _capture); 2807 - })(_pipe$1); 2808 - let new_children = _block; 2809 - return new Balanced(size$1, new_children); 2810 - } else if (node2 instanceof Unbalanced) { 2811 - let sizes = node2.sizes; 2812 - let children = node2.children; 2813 - let start_search_index = bsr(index4, shift); 2814 - let node_index = find_size(sizes, start_search_index + 1, index4); 2815 - let _block; 2816 - if (node_index === 0) { 2817 - _block = index4; 2818 - } else { 2819 - _block = index4 - get1(node_index, sizes); 2820 - } 2821 - let index$1 = _block; 2822 - let _block$1; 2823 - let _pipe = get1(node_index + 1, children); 2824 - let _pipe$1 = ((_capture) => { 2825 - return update(shift - branch_bits, _capture, index$1, fun); 2826 - })(_pipe); 2827 - _block$1 = ((_capture) => { 2828 - return set1(node_index + 1, children, _capture); 2829 - })(_pipe$1); 2830 - let new_children = _block$1; 2831 - return new Unbalanced(sizes, new_children); 2832 - } else { 2833 - let children = node2.children; 2834 - let new_children = set1( 2835 - index4 + 1, 2836 - children, 2837 - fun(get1(index4 + 1, children)) 2838 - ); 2839 - return new Leaf(new_children); 2840 - } 2841 - } 2842 - var branch_factor = 32; 2843 - function index_map2(offset, node2, fun) { 2844 - if (node2 instanceof Balanced) { 2845 - let size$1 = node2.size; 2846 - let children = node2.children; 2847 - let children$1 = index_map( 2848 - children, 2849 - (child, index4) => { 2850 - return index_map2(offset + (index4 - 1) * branch_factor, child, fun); 2851 - } 2852 - ); 2853 - return new Balanced(size$1, children$1); 2854 - } else if (node2 instanceof Unbalanced) { 2855 - let sizes = node2.sizes; 2856 - let children = node2.children; 2857 - let children$1 = index_map( 2858 - children, 2859 - (child, index4) => { 2860 - let _block; 2861 - if (index4 === 1) { 2862 - _block = 0; 2863 - } else { 2864 - _block = get1(index4 - 1, sizes); 2865 - } 2866 - let child_offset = _block; 2867 - return index_map2(offset + child_offset, child, fun); 2868 - } 2869 - ); 2870 - return new Unbalanced(sizes, children$1); 2871 - } else { 2872 - let children = node2.children; 2873 - let children$1 = index_map( 2874 - children, 2875 - (item, index4) => { 2876 - return fun(item, index4 + offset - 1); 2877 - } 2878 - ); 2879 - return new Leaf(children$1); 2880 - } 2881 - } 2882 - 2883 - // build/dev/javascript/iv/iv/internal/builder.mjs 2884 - var Builder = class extends CustomType { 2885 - constructor(nodes, items, push_node, push_item) { 2886 - super(); 2887 - this.nodes = nodes; 2888 - this.items = items; 2889 - this.push_node = push_node; 2890 - this.push_item = push_item; 2891 - } 2892 - }; 2893 - function append_node(nodes, node2, shift) { 2894 - if (nodes instanceof Empty) { 2895 - return toList([singleton(node2)]); 2896 - } else { 2897 - let nodes$1 = nodes.head; 2898 - let rest = nodes.tail; 2899 - let $ = length3(nodes$1) < branch_factor; 2900 - if ($) { 2901 - return prepend(append3(nodes$1, node2), rest); 2902 - } else { 2903 - let shift$1 = shift + branch_bits; 2904 - let new_node = balanced(shift$1, nodes$1); 2905 - return prepend( 2906 - singleton(node2), 2907 - append_node(rest, new_node, shift$1) 2908 - ); 2909 - } 2910 - } 2911 - } 2912 - function new$() { 2913 - return new Builder(toList([]), empty(), append_node, append3); 2914 - } 2915 - function push(builder, item) { 2916 - let nodes = builder.nodes; 2917 - let items = builder.items; 2918 - let push_node = builder.push_node; 2919 - let push_item = builder.push_item; 2920 - let $ = length3(items) === branch_factor; 2921 - if ($) { 2922 - let leaf2 = leaf(items); 2923 - return new Builder( 2924 - push_node(nodes, leaf2, 0), 2925 - singleton(item), 2926 - push_node, 2927 - push_item 2928 - ); 2929 - } else { 2930 - return new Builder(nodes, push_item(items, item), push_node, push_item); 2931 - } 2932 - } 2933 - function compress_nodes(loop$nodes, loop$push_node, loop$shift) { 2934 - while (true) { 2935 - let nodes = loop$nodes; 2936 - let push_node = loop$push_node; 2937 - let shift = loop$shift; 2938 - if (nodes instanceof Empty) { 2939 - return new Error(void 0); 2940 - } else { 2941 - let $ = nodes.tail; 2942 - if ($ instanceof Empty) { 2943 - let root3 = nodes.head; 2944 - return new Ok([shift, root3]); 2945 - } else { 2946 - let nodes$1 = nodes.head; 2947 - let rest = $; 2948 - let shift$1 = shift + branch_bits; 2949 - let compressed = push_node( 2950 - rest, 2951 - branch(shift$1, nodes$1), 2952 - shift$1 2953 - ); 2954 - loop$nodes = compressed; 2955 - loop$push_node = push_node; 2956 - loop$shift = shift$1; 2957 - } 2958 - } 2959 - } 2960 - } 2961 - function build(builder) { 2962 - let nodes = builder.nodes; 2963 - let items = builder.items; 2964 - let push_node = builder.push_node; 2965 - let items_len = length3(items); 2966 - let _block; 2967 - let $ = items_len > 0; 2968 - if ($) { 2969 - _block = push_node(nodes, leaf(items), 0); 2970 - } else { 2971 - _block = nodes; 2972 - } 2973 - let nodes$1 = _block; 2974 - return compress_nodes(nodes$1, push_node, 0); 2975 - } 2976 - 2977 - // build/dev/javascript/iv/iv.mjs 2978 - var Empty2 = class extends CustomType { 2979 - }; 2980 - var Array2 = class extends CustomType { 2981 - constructor(shift, root3) { 2982 - super(); 2983 - this.shift = shift; 2984 - this.root = root3; 2985 - } 2986 - }; 2987 - function array(shift, nodes) { 2988 - let $ = length3(nodes); 2989 - if ($ === 0) { 2990 - return new Empty2(); 2991 - } else if ($ === 1) { 2992 - return new Array2(shift, get1(1, nodes)); 2993 - } else { 2994 - let shift$1 = shift + branch_bits; 2995 - return new Array2(shift$1, branch(shift$1, nodes)); 2996 - } 2997 - } 2998 - function from_list2(list4) { 2999 - let $ = (() => { 3000 - let _pipe = list4; 3001 - let _pipe$1 = fold(_pipe, new$(), push); 3002 - return build(_pipe$1); 3003 - })(); 3004 - if ($ instanceof Ok) { 3005 - let shift = $[0][0]; 3006 - let nodes = $[0][1]; 3007 - return array(shift, nodes); 3008 - } else { 3009 - return new Empty2(); 3010 - } 3011 - } 3012 - function get2(array4, index4) { 3013 - if (array4 instanceof Empty2) { 3014 - return new Error(void 0); 3015 - } else { 3016 - let shift = array4.shift; 3017 - let root3 = array4.root; 3018 - let $ = 0 <= index4 && index4 < size(root3); 3019 - if ($) { 3020 - return new Ok(get(root3, shift, index4)); 3021 - } else { 3022 - return new Error(void 0); 3023 - } 3024 - } 3025 - } 3026 - function update2(array4, index4, fun) { 3027 - if (array4 instanceof Empty2) { 3028 - return new Error(void 0); 3029 - } else { 3030 - let shift = array4.shift; 3031 - let root3 = array4.root; 3032 - let $ = 0 <= index4 && index4 < size(root3); 3033 - if ($) { 3034 - return new Ok(new Array2(shift, update(shift, root3, index4, fun))); 3035 - } else { 3036 - return new Error(void 0); 3037 - } 3038 - } 3039 - } 3040 - function set(array4, index4, item) { 3041 - return update2(array4, index4, (_) => { 3042 - return item; 3043 - }); 3044 - } 3045 - function index_map3(array4, fun) { 3046 - if (array4 instanceof Empty2) { 3047 - return new Empty2(); 3048 - } else { 3049 - let shift = array4.shift; 3050 - let root3 = array4.root; 3051 - return new Array2(shift, index_map2(0, root3, fun)); 3052 - } 3053 - } 3054 - function fold_right3(array4, state, fun) { 3055 - if (array4 instanceof Empty2) { 3056 - return state; 3057 - } else { 3058 - let root3 = array4.root; 3059 - return fold_right2(root3, state, fun); 3060 - } 3061 - } 3062 - function to_list(array4) { 3063 - return fold_right3(array4, toList([]), prepend2); 3064 - } 3065 - 3066 - // build/dev/javascript/gleam_stdlib/gleam/function.mjs 3067 - function identity2(x) { 3068 - return x; 3069 - } 3070 - function tap(arg, effect) { 3071 - effect(arg); 3072 - return arg; 3073 - } 3074 - 3075 - // build/dev/javascript/gleam_stdlib/gleam/set.mjs 3076 - var Set2 = class extends CustomType { 3077 - constructor(dict2) { 3078 - super(); 3079 - this.dict = dict2; 3080 - } 3081 - }; 3082 - function new$3() { 3083 - return new Set2(new_map()); 3084 - } 3085 - function contains(set2, member) { 3086 - let _pipe = set2.dict; 3087 - let _pipe$1 = map_get(_pipe, member); 3088 - return is_ok(_pipe$1); 3089 - } 3090 - var token = void 0; 3091 - function insert2(set2, member) { 3092 - return new Set2(insert(set2.dict, member, token)); 3093 - } 3094 - 3095 - // build/dev/javascript/lustre/lustre/internals/constants.ffi.mjs 3096 - var EMPTY_DICT = /* @__PURE__ */ Dict.new(); 3097 - var EMPTY_SET = /* @__PURE__ */ new$3(); 3098 - var empty_dict = () => EMPTY_DICT; 3099 - var empty_set = () => EMPTY_SET; 3100 - var document2 = () => globalThis?.document; 3101 - var NAMESPACE_HTML = "http://www.w3.org/1999/xhtml"; 3102 - var ELEMENT_NODE = 1; 3103 - var TEXT_NODE = 3; 3104 - var DOCUMENT_FRAGMENT_NODE = 11; 3105 - var SUPPORTS_MOVE_BEFORE = !!globalThis.HTMLElement?.prototype?.moveBefore; 3106 - 3107 - // build/dev/javascript/lustre/lustre/internals/constants.mjs 3108 - var empty_list = /* @__PURE__ */ toList([]); 3109 - var option_none = /* @__PURE__ */ new None(); 3110 - 3111 - // build/dev/javascript/lustre/lustre/vdom/vattr.ffi.mjs 3112 - var GT = /* @__PURE__ */ new Gt(); 3113 - var LT = /* @__PURE__ */ new Lt(); 3114 - var EQ = /* @__PURE__ */ new Eq(); 3115 - function compare3(a, b) { 3116 - if (a.name === b.name) { 3117 - return EQ; 3118 - } else if (a.name < b.name) { 3119 - return LT; 3120 - } else { 3121 - return GT; 3122 - } 3123 - } 3124 - 3125 - // build/dev/javascript/lustre/lustre/vdom/vattr.mjs 3126 - var Attribute = class extends CustomType { 3127 - constructor(kind, name, value) { 3128 - super(); 3129 - this.kind = kind; 3130 - this.name = name; 3131 - this.value = value; 3132 - } 3133 - }; 3134 - var Property = class extends CustomType { 3135 - constructor(kind, name, value) { 3136 - super(); 3137 - this.kind = kind; 3138 - this.name = name; 3139 - this.value = value; 3140 - } 3141 - }; 3142 - var Event2 = class extends CustomType { 3143 - constructor(kind, name, handler, include, prevent_default, stop_propagation, immediate2, debounce, throttle) { 3144 - super(); 3145 - this.kind = kind; 3146 - this.name = name; 3147 - this.handler = handler; 3148 - this.include = include; 3149 - this.prevent_default = prevent_default; 3150 - this.stop_propagation = stop_propagation; 3151 - this.immediate = immediate2; 3152 - this.debounce = debounce; 3153 - this.throttle = throttle; 3154 - } 3155 - }; 3156 - var Handler = class extends CustomType { 3157 - constructor(prevent_default, stop_propagation, message) { 3158 - super(); 3159 - this.prevent_default = prevent_default; 3160 - this.stop_propagation = stop_propagation; 3161 - this.message = message; 3162 - } 3163 - }; 3164 - var Never = class extends CustomType { 3165 - constructor(kind) { 3166 - super(); 3167 - this.kind = kind; 3168 - } 3169 - }; 3170 - function merge(loop$attributes, loop$merged) { 3171 - while (true) { 3172 - let attributes = loop$attributes; 3173 - let merged = loop$merged; 3174 - if (attributes instanceof Empty) { 3175 - return merged; 3176 - } else { 3177 - let $ = attributes.head; 3178 - if ($ instanceof Attribute) { 3179 - let $1 = $.name; 3180 - if ($1 === "") { 3181 - let rest = attributes.tail; 3182 - loop$attributes = rest; 3183 - loop$merged = merged; 3184 - } else if ($1 === "class") { 3185 - let $2 = $.value; 3186 - if ($2 === "") { 3187 - let rest = attributes.tail; 3188 - loop$attributes = rest; 3189 - loop$merged = merged; 3190 - } else { 3191 - let $3 = attributes.tail; 3192 - if ($3 instanceof Empty) { 3193 - let attribute$1 = $; 3194 - let rest = $3; 3195 - loop$attributes = rest; 3196 - loop$merged = prepend(attribute$1, merged); 3197 - } else { 3198 - let $4 = $3.head; 3199 - if ($4 instanceof Attribute) { 3200 - let $5 = $4.name; 3201 - if ($5 === "class") { 3202 - let kind = $.kind; 3203 - let class1 = $2; 3204 - let rest = $3.tail; 3205 - let class2 = $4.value; 3206 - let value = class1 + " " + class2; 3207 - let attribute$1 = new Attribute(kind, "class", value); 3208 - loop$attributes = prepend(attribute$1, rest); 3209 - loop$merged = merged; 3210 - } else { 3211 - let attribute$1 = $; 3212 - let rest = $3; 3213 - loop$attributes = rest; 3214 - loop$merged = prepend(attribute$1, merged); 3215 - } 3216 - } else { 3217 - let attribute$1 = $; 3218 - let rest = $3; 3219 - loop$attributes = rest; 3220 - loop$merged = prepend(attribute$1, merged); 3221 - } 3222 - } 3223 - } 3224 - } else if ($1 === "style") { 3225 - let $2 = $.value; 3226 - if ($2 === "") { 3227 - let rest = attributes.tail; 3228 - loop$attributes = rest; 3229 - loop$merged = merged; 3230 - } else { 3231 - let $3 = attributes.tail; 3232 - if ($3 instanceof Empty) { 3233 - let attribute$1 = $; 3234 - let rest = $3; 3235 - loop$attributes = rest; 3236 - loop$merged = prepend(attribute$1, merged); 3237 - } else { 3238 - let $4 = $3.head; 3239 - if ($4 instanceof Attribute) { 3240 - let $5 = $4.name; 3241 - if ($5 === "style") { 3242 - let kind = $.kind; 3243 - let style1 = $2; 3244 - let rest = $3.tail; 3245 - let style2 = $4.value; 3246 - let value = style1 + ";" + style2; 3247 - let attribute$1 = new Attribute(kind, "style", value); 3248 - loop$attributes = prepend(attribute$1, rest); 3249 - loop$merged = merged; 3250 - } else { 3251 - let attribute$1 = $; 3252 - let rest = $3; 3253 - loop$attributes = rest; 3254 - loop$merged = prepend(attribute$1, merged); 3255 - } 3256 - } else { 3257 - let attribute$1 = $; 3258 - let rest = $3; 3259 - loop$attributes = rest; 3260 - loop$merged = prepend(attribute$1, merged); 3261 - } 3262 - } 3263 - } 3264 - } else { 3265 - let attribute$1 = $; 3266 - let rest = attributes.tail; 3267 - loop$attributes = rest; 3268 - loop$merged = prepend(attribute$1, merged); 3269 - } 3270 - } else { 3271 - let attribute$1 = $; 3272 - let rest = attributes.tail; 3273 - loop$attributes = rest; 3274 - loop$merged = prepend(attribute$1, merged); 3275 - } 3276 - } 3277 - } 3278 - } 3279 - function prepare(attributes) { 3280 - if (attributes instanceof Empty) { 3281 - return attributes; 3282 - } else { 3283 - let $ = attributes.tail; 3284 - if ($ instanceof Empty) { 3285 - return attributes; 3286 - } else { 3287 - let _pipe = attributes; 3288 - let _pipe$1 = sort(_pipe, (a, b) => { 3289 - return compare3(b, a); 3290 - }); 3291 - return merge(_pipe$1, empty_list); 3292 - } 3293 - } 3294 - } 3295 - var attribute_kind = 0; 3296 - function attribute(name, value) { 3297 - return new Attribute(attribute_kind, name, value); 3298 - } 3299 - var property_kind = 1; 3300 - var event_kind = 2; 3301 - function event(name, handler, include, prevent_default, stop_propagation, immediate2, debounce, throttle) { 3302 - return new Event2( 3303 - event_kind, 3304 - name, 3305 - handler, 3306 - include, 3307 - prevent_default, 3308 - stop_propagation, 3309 - immediate2, 3310 - debounce, 3311 - throttle 3312 - ); 3313 - } 3314 - var never_kind = 0; 3315 - var never = /* @__PURE__ */ new Never(never_kind); 3316 - var always_kind = 2; 3317 - 3318 - // build/dev/javascript/lustre/lustre/attribute.mjs 3319 - function attribute2(name, value) { 3320 - return attribute(name, value); 3321 - } 3322 - function class$(name) { 3323 - return attribute2("class", name); 3324 - } 3325 - function placeholder(text5) { 3326 - return attribute2("placeholder", text5); 3327 - } 3328 - function type_(control_type) { 3329 - return attribute2("type", control_type); 3330 - } 3331 - 3332 - // build/dev/javascript/lustre/lustre/effect.mjs 3333 - var Effect = class extends CustomType { 3334 - constructor(synchronous, before_paint2, after_paint) { 3335 - super(); 3336 - this.synchronous = synchronous; 3337 - this.before_paint = before_paint2; 3338 - this.after_paint = after_paint; 3339 - } 3340 - }; 3341 - var empty3 = /* @__PURE__ */ new Effect( 3342 - /* @__PURE__ */ toList([]), 3343 - /* @__PURE__ */ toList([]), 3344 - /* @__PURE__ */ toList([]) 3345 - ); 3346 - function none() { 3347 - return empty3; 3348 - } 3349 - function from(effect) { 3350 - let task = (actions) => { 3351 - let dispatch = actions.dispatch; 3352 - return effect(dispatch); 3353 - }; 3354 - let _record = empty3; 3355 - return new Effect(toList([task]), _record.before_paint, _record.after_paint); 3356 - } 3357 - 3358 - // build/dev/javascript/lustre/lustre/internals/mutable_map.ffi.mjs 3359 - function empty4() { 3360 - return null; 3361 - } 3362 - function get3(map7, key) { 3363 - const value = map7?.get(key); 3364 - if (value != null) { 3365 - return new Ok(value); 3366 - } else { 3367 - return new Error(void 0); 3368 - } 3369 - } 3370 - function insert3(map7, key, value) { 3371 - map7 ??= /* @__PURE__ */ new Map(); 3372 - map7.set(key, value); 3373 - return map7; 3374 - } 3375 - function remove(map7, key) { 3376 - map7?.delete(key); 3377 - return map7; 3378 - } 3379 - 3380 - // build/dev/javascript/lustre/lustre/vdom/path.mjs 3381 - var Root = class extends CustomType { 3382 - }; 3383 - var Key = class extends CustomType { 3384 - constructor(key, parent) { 3385 - super(); 3386 - this.key = key; 3387 - this.parent = parent; 3388 - } 3389 - }; 3390 - var Index = class extends CustomType { 3391 - constructor(index4, parent) { 3392 - super(); 3393 - this.index = index4; 3394 - this.parent = parent; 3395 - } 3396 - }; 3397 - function do_matches(loop$path, loop$candidates) { 3398 - while (true) { 3399 - let path = loop$path; 3400 - let candidates = loop$candidates; 3401 - if (candidates instanceof Empty) { 3402 - return false; 3403 - } else { 3404 - let candidate = candidates.head; 3405 - let rest = candidates.tail; 3406 - let $ = starts_with(path, candidate); 3407 - if ($) { 3408 - return true; 3409 - } else { 3410 - loop$path = path; 3411 - loop$candidates = rest; 3412 - } 3413 - } 3414 - } 3415 - } 3416 - function add3(parent, index4, key) { 3417 - if (key === "") { 3418 - return new Index(index4, parent); 3419 - } else { 3420 - return new Key(key, parent); 3421 - } 3422 - } 3423 - var root2 = /* @__PURE__ */ new Root(); 3424 - var separator_element = " "; 3425 - function do_to_string(loop$path, loop$acc) { 3426 - while (true) { 3427 - let path = loop$path; 3428 - let acc = loop$acc; 3429 - if (path instanceof Root) { 3430 - if (acc instanceof Empty) { 3431 - return ""; 3432 - } else { 3433 - let segments = acc.tail; 3434 - return concat2(segments); 3435 - } 3436 - } else if (path instanceof Key) { 3437 - let key = path.key; 3438 - let parent = path.parent; 3439 - loop$path = parent; 3440 - loop$acc = prepend(separator_element, prepend(key, acc)); 3441 - } else { 3442 - let index4 = path.index; 3443 - let parent = path.parent; 3444 - loop$path = parent; 3445 - loop$acc = prepend( 3446 - separator_element, 3447 - prepend(to_string(index4), acc) 3448 - ); 3449 - } 3450 - } 3451 - } 3452 - function to_string2(path) { 3453 - return do_to_string(path, toList([])); 3454 - } 3455 - function matches(path, candidates) { 3456 - if (candidates instanceof Empty) { 3457 - return false; 3458 - } else { 3459 - return do_matches(to_string2(path), candidates); 3460 - } 3461 - } 3462 - var separator_event = "\n"; 3463 - function event2(path, event4) { 3464 - return do_to_string(path, toList([separator_event, event4])); 3465 - } 3466 - 3467 - // build/dev/javascript/lustre/lustre/vdom/vnode.mjs 3468 - var Fragment = class extends CustomType { 3469 - constructor(kind, key, mapper, children, keyed_children, children_count) { 3470 - super(); 3471 - this.kind = kind; 3472 - this.key = key; 3473 - this.mapper = mapper; 3474 - this.children = children; 3475 - this.keyed_children = keyed_children; 3476 - this.children_count = children_count; 3477 - } 3478 - }; 3479 - var Element = class extends CustomType { 3480 - constructor(kind, key, mapper, namespace, tag, attributes, children, keyed_children, self_closing, void$) { 3481 - super(); 3482 - this.kind = kind; 3483 - this.key = key; 3484 - this.mapper = mapper; 3485 - this.namespace = namespace; 3486 - this.tag = tag; 3487 - this.attributes = attributes; 3488 - this.children = children; 3489 - this.keyed_children = keyed_children; 3490 - this.self_closing = self_closing; 3491 - this.void = void$; 3492 - } 3493 - }; 3494 - var Text = class extends CustomType { 3495 - constructor(kind, key, mapper, content) { 3496 - super(); 3497 - this.kind = kind; 3498 - this.key = key; 3499 - this.mapper = mapper; 3500 - this.content = content; 3501 - } 3502 - }; 3503 - var UnsafeInnerHtml = class extends CustomType { 3504 - constructor(kind, key, mapper, namespace, tag, attributes, inner_html) { 3505 - super(); 3506 - this.kind = kind; 3507 - this.key = key; 3508 - this.mapper = mapper; 3509 - this.namespace = namespace; 3510 - this.tag = tag; 3511 - this.attributes = attributes; 3512 - this.inner_html = inner_html; 3513 - } 3514 - }; 3515 - function is_void_element(tag, namespace) { 3516 - if (namespace === "") { 3517 - if (tag === "area") { 3518 - return true; 3519 - } else if (tag === "base") { 3520 - return true; 3521 - } else if (tag === "br") { 3522 - return true; 3523 - } else if (tag === "col") { 3524 - return true; 3525 - } else if (tag === "embed") { 3526 - return true; 3527 - } else if (tag === "hr") { 3528 - return true; 3529 - } else if (tag === "img") { 3530 - return true; 3531 - } else if (tag === "input") { 3532 - return true; 3533 - } else if (tag === "link") { 3534 - return true; 3535 - } else if (tag === "meta") { 3536 - return true; 3537 - } else if (tag === "param") { 3538 - return true; 3539 - } else if (tag === "source") { 3540 - return true; 3541 - } else if (tag === "track") { 3542 - return true; 3543 - } else if (tag === "wbr") { 3544 - return true; 3545 - } else { 3546 - return false; 3547 - } 3548 - } else { 3549 - return false; 3550 - } 3551 - } 3552 - function advance(node2) { 3553 - if (node2 instanceof Fragment) { 3554 - let children_count = node2.children_count; 3555 - return 1 + children_count; 3556 - } else { 3557 - return 1; 3558 - } 3559 - } 3560 - var fragment_kind = 0; 3561 - function fragment(key, mapper, children, keyed_children, children_count) { 3562 - return new Fragment( 3563 - fragment_kind, 3564 - key, 3565 - mapper, 3566 - children, 3567 - keyed_children, 3568 - children_count 3569 - ); 3570 - } 3571 - var element_kind = 1; 3572 - function element(key, mapper, namespace, tag, attributes, children, keyed_children, self_closing, void$) { 3573 - return new Element( 3574 - element_kind, 3575 - key, 3576 - mapper, 3577 - namespace, 3578 - tag, 3579 - prepare(attributes), 3580 - children, 3581 - keyed_children, 3582 - self_closing, 3583 - void$ || is_void_element(tag, namespace) 3584 - ); 3585 - } 3586 - var text_kind = 2; 3587 - function text(key, mapper, content) { 3588 - return new Text(text_kind, key, mapper, content); 3589 - } 3590 - var unsafe_inner_html_kind = 3; 3591 - function unsafe_inner_html(key, mapper, namespace, tag, attributes, inner_html) { 3592 - return new UnsafeInnerHtml( 3593 - unsafe_inner_html_kind, 3594 - key, 3595 - mapper, 3596 - namespace, 3597 - tag, 3598 - prepare(attributes), 3599 - inner_html 3600 - ); 3601 - } 3602 - function set_fragment_key(loop$key, loop$children, loop$index, loop$new_children, loop$keyed_children) { 3603 - while (true) { 3604 - let key = loop$key; 3605 - let children = loop$children; 3606 - let index4 = loop$index; 3607 - let new_children = loop$new_children; 3608 - let keyed_children = loop$keyed_children; 3609 - if (children instanceof Empty) { 3610 - return [reverse(new_children), keyed_children]; 3611 - } else { 3612 - let $ = children.head; 3613 - if ($ instanceof Fragment) { 3614 - let node2 = $; 3615 - if (node2.key === "") { 3616 - let children$1 = children.tail; 3617 - let child_key = key + "::" + to_string(index4); 3618 - let $1 = set_fragment_key( 3619 - child_key, 3620 - node2.children, 3621 - 0, 3622 - empty_list, 3623 - empty4() 3624 - ); 3625 - let node_children = $1[0]; 3626 - let node_keyed_children = $1[1]; 3627 - let _block; 3628 - let _record = node2; 3629 - _block = new Fragment( 3630 - _record.kind, 3631 - _record.key, 3632 - _record.mapper, 3633 - node_children, 3634 - node_keyed_children, 3635 - _record.children_count 3636 - ); 3637 - let new_node = _block; 3638 - let new_children$1 = prepend(new_node, new_children); 3639 - let index$1 = index4 + 1; 3640 - loop$key = key; 3641 - loop$children = children$1; 3642 - loop$index = index$1; 3643 - loop$new_children = new_children$1; 3644 - loop$keyed_children = keyed_children; 3645 - } else { 3646 - let node$1 = $; 3647 - if (node$1.key !== "") { 3648 - let children$1 = children.tail; 3649 - let child_key = key + "::" + node$1.key; 3650 - let keyed_node = to_keyed(child_key, node$1); 3651 - let new_children$1 = prepend(keyed_node, new_children); 3652 - let keyed_children$1 = insert3( 3653 - keyed_children, 3654 - child_key, 3655 - keyed_node 3656 - ); 3657 - let index$1 = index4 + 1; 3658 - loop$key = key; 3659 - loop$children = children$1; 3660 - loop$index = index$1; 3661 - loop$new_children = new_children$1; 3662 - loop$keyed_children = keyed_children$1; 3663 - } else { 3664 - let node$2 = $; 3665 - let children$1 = children.tail; 3666 - let new_children$1 = prepend(node$2, new_children); 3667 - let index$1 = index4 + 1; 3668 - loop$key = key; 3669 - loop$children = children$1; 3670 - loop$index = index$1; 3671 - loop$new_children = new_children$1; 3672 - loop$keyed_children = keyed_children; 3673 - } 3674 - } 3675 - } else { 3676 - let node2 = $; 3677 - if (node2.key !== "") { 3678 - let children$1 = children.tail; 3679 - let child_key = key + "::" + node2.key; 3680 - let keyed_node = to_keyed(child_key, node2); 3681 - let new_children$1 = prepend(keyed_node, new_children); 3682 - let keyed_children$1 = insert3( 3683 - keyed_children, 3684 - child_key, 3685 - keyed_node 3686 - ); 3687 - let index$1 = index4 + 1; 3688 - loop$key = key; 3689 - loop$children = children$1; 3690 - loop$index = index$1; 3691 - loop$new_children = new_children$1; 3692 - loop$keyed_children = keyed_children$1; 3693 - } else { 3694 - let node$1 = $; 3695 - let children$1 = children.tail; 3696 - let new_children$1 = prepend(node$1, new_children); 3697 - let index$1 = index4 + 1; 3698 - loop$key = key; 3699 - loop$children = children$1; 3700 - loop$index = index$1; 3701 - loop$new_children = new_children$1; 3702 - loop$keyed_children = keyed_children; 3703 - } 3704 - } 3705 - } 3706 - } 3707 - } 3708 - function to_keyed(key, node2) { 3709 - if (node2 instanceof Fragment) { 3710 - let children = node2.children; 3711 - let $ = set_fragment_key( 3712 - key, 3713 - children, 3714 - 0, 3715 - empty_list, 3716 - empty4() 3717 - ); 3718 - let children$1 = $[0]; 3719 - let keyed_children = $[1]; 3720 - let _record = node2; 3721 - return new Fragment( 3722 - _record.kind, 3723 - key, 3724 - _record.mapper, 3725 - children$1, 3726 - keyed_children, 3727 - _record.children_count 3728 - ); 3729 - } else if (node2 instanceof Element) { 3730 - let _record = node2; 3731 - return new Element( 3732 - _record.kind, 3733 - key, 3734 - _record.mapper, 3735 - _record.namespace, 3736 - _record.tag, 3737 - _record.attributes, 3738 - _record.children, 3739 - _record.keyed_children, 3740 - _record.self_closing, 3741 - _record.void 3742 - ); 3743 - } else if (node2 instanceof Text) { 3744 - let _record = node2; 3745 - return new Text(_record.kind, key, _record.mapper, _record.content); 3746 - } else { 3747 - let _record = node2; 3748 - return new UnsafeInnerHtml( 3749 - _record.kind, 3750 - key, 3751 - _record.mapper, 3752 - _record.namespace, 3753 - _record.tag, 3754 - _record.attributes, 3755 - _record.inner_html 3756 - ); 3757 - } 3758 - } 3759 - 3760 - // build/dev/javascript/lustre/lustre/internals/equals.ffi.mjs 3761 - var isReferenceEqual = (a, b) => a === b; 3762 - var isEqual2 = (a, b) => { 3763 - if (a === b) { 3764 - return true; 3765 - } 3766 - if (a == null || b == null) { 3767 - return false; 3768 - } 3769 - const type = typeof a; 3770 - if (type !== typeof b) { 3771 - return false; 3772 - } 3773 - if (type !== "object") { 3774 - return false; 3775 - } 3776 - const ctor = a.constructor; 3777 - if (ctor !== b.constructor) { 3778 - return false; 3779 - } 3780 - if (Array.isArray(a)) { 3781 - return areArraysEqual(a, b); 3782 - } 3783 - return areObjectsEqual(a, b); 3784 - }; 3785 - var areArraysEqual = (a, b) => { 3786 - let index4 = a.length; 3787 - if (index4 !== b.length) { 3788 - return false; 3789 - } 3790 - while (index4--) { 3791 - if (!isEqual2(a[index4], b[index4])) { 3792 - return false; 3793 - } 3794 - } 3795 - return true; 3796 - }; 3797 - var areObjectsEqual = (a, b) => { 3798 - const properties = Object.keys(a); 3799 - let index4 = properties.length; 3800 - if (Object.keys(b).length !== index4) { 3801 - return false; 3802 - } 3803 - while (index4--) { 3804 - const property4 = properties[index4]; 3805 - if (!Object.hasOwn(b, property4)) { 3806 - return false; 3807 - } 3808 - if (!isEqual2(a[property4], b[property4])) { 3809 - return false; 3810 - } 3811 - } 3812 - return true; 3813 - }; 3814 - 3815 - // build/dev/javascript/lustre/lustre/vdom/events.mjs 3816 - var Events = class extends CustomType { 3817 - constructor(handlers, dispatched_paths, next_dispatched_paths) { 3818 - super(); 3819 - this.handlers = handlers; 3820 - this.dispatched_paths = dispatched_paths; 3821 - this.next_dispatched_paths = next_dispatched_paths; 3822 - } 3823 - }; 3824 - function new$5() { 3825 - return new Events( 3826 - empty4(), 3827 - empty_list, 3828 - empty_list 3829 - ); 3830 - } 3831 - function tick(events) { 3832 - return new Events( 3833 - events.handlers, 3834 - events.next_dispatched_paths, 3835 - empty_list 3836 - ); 3837 - } 3838 - function do_remove_event(handlers, path, name) { 3839 - return remove(handlers, event2(path, name)); 3840 - } 3841 - function remove_event(events, path, name) { 3842 - let handlers = do_remove_event(events.handlers, path, name); 3843 - let _record = events; 3844 - return new Events( 3845 - handlers, 3846 - _record.dispatched_paths, 3847 - _record.next_dispatched_paths 3848 - ); 3849 - } 3850 - function remove_attributes(handlers, path, attributes) { 3851 - return fold( 3852 - attributes, 3853 - handlers, 3854 - (events, attribute3) => { 3855 - if (attribute3 instanceof Event2) { 3856 - let name = attribute3.name; 3857 - return do_remove_event(events, path, name); 3858 - } else { 3859 - return events; 3860 - } 3861 - } 3862 - ); 3863 - } 3864 - function handle(events, path, name, event4) { 3865 - let next_dispatched_paths = prepend(path, events.next_dispatched_paths); 3866 - let _block; 3867 - let _record = events; 3868 - _block = new Events( 3869 - _record.handlers, 3870 - _record.dispatched_paths, 3871 - next_dispatched_paths 3872 - ); 3873 - let events$1 = _block; 3874 - let $ = get3( 3875 - events$1.handlers, 3876 - path + separator_event + name 3877 - ); 3878 - if ($ instanceof Ok) { 3879 - let handler = $[0]; 3880 - return [events$1, run(event4, handler)]; 3881 - } else { 3882 - return [events$1, new Error(toList([]))]; 3883 - } 3884 - } 3885 - function has_dispatched_events(events, path) { 3886 - return matches(path, events.dispatched_paths); 3887 - } 3888 - function do_add_event(handlers, mapper, path, name, handler) { 3889 - return insert3( 3890 - handlers, 3891 - event2(path, name), 3892 - map2( 3893 - handler, 3894 - (handler2) => { 3895 - let _record = handler2; 3896 - return new Handler( 3897 - _record.prevent_default, 3898 - _record.stop_propagation, 3899 - identity2(mapper)(handler2.message) 3900 - ); 3901 - } 3902 - ) 3903 - ); 3904 - } 3905 - function add_event(events, mapper, path, name, handler) { 3906 - let handlers = do_add_event(events.handlers, mapper, path, name, handler); 3907 - let _record = events; 3908 - return new Events( 3909 - handlers, 3910 - _record.dispatched_paths, 3911 - _record.next_dispatched_paths 3912 - ); 3913 - } 3914 - function add_attributes(handlers, mapper, path, attributes) { 3915 - return fold( 3916 - attributes, 3917 - handlers, 3918 - (events, attribute3) => { 3919 - if (attribute3 instanceof Event2) { 3920 - let name = attribute3.name; 3921 - let handler = attribute3.handler; 3922 - return do_add_event(events, mapper, path, name, handler); 3923 - } else { 3924 - return events; 3925 - } 3926 - } 3927 - ); 3928 - } 3929 - function compose_mapper(mapper, child_mapper) { 3930 - let $ = isReferenceEqual(mapper, identity2); 3931 - let $1 = isReferenceEqual(child_mapper, identity2); 3932 - if ($1) { 3933 - return mapper; 3934 - } else if ($) { 3935 - return child_mapper; 3936 - } else { 3937 - return (msg) => { 3938 - return mapper(child_mapper(msg)); 3939 - }; 3940 - } 3941 - } 3942 - function do_remove_children(loop$handlers, loop$path, loop$child_index, loop$children) { 3943 - while (true) { 3944 - let handlers = loop$handlers; 3945 - let path = loop$path; 3946 - let child_index = loop$child_index; 3947 - let children = loop$children; 3948 - if (children instanceof Empty) { 3949 - return handlers; 3950 - } else { 3951 - let child = children.head; 3952 - let rest = children.tail; 3953 - let _pipe = handlers; 3954 - let _pipe$1 = do_remove_child(_pipe, path, child_index, child); 3955 - loop$handlers = _pipe$1; 3956 - loop$path = path; 3957 - loop$child_index = child_index + advance(child); 3958 - loop$children = rest; 3959 - } 3960 - } 3961 - } 3962 - function do_remove_child(handlers, parent, child_index, child) { 3963 - if (child instanceof Fragment) { 3964 - let children = child.children; 3965 - return do_remove_children(handlers, parent, child_index + 1, children); 3966 - } else if (child instanceof Element) { 3967 - let attributes = child.attributes; 3968 - let children = child.children; 3969 - let path = add3(parent, child_index, child.key); 3970 - let _pipe = handlers; 3971 - let _pipe$1 = remove_attributes(_pipe, path, attributes); 3972 - return do_remove_children(_pipe$1, path, 0, children); 3973 - } else if (child instanceof Text) { 3974 - return handlers; 3975 - } else { 3976 - let attributes = child.attributes; 3977 - let path = add3(parent, child_index, child.key); 3978 - return remove_attributes(handlers, path, attributes); 3979 - } 3980 - } 3981 - function remove_child(events, parent, child_index, child) { 3982 - let handlers = do_remove_child(events.handlers, parent, child_index, child); 3983 - let _record = events; 3984 - return new Events( 3985 - handlers, 3986 - _record.dispatched_paths, 3987 - _record.next_dispatched_paths 3988 - ); 3989 - } 3990 - function do_add_children(loop$handlers, loop$mapper, loop$path, loop$child_index, loop$children) { 3991 - while (true) { 3992 - let handlers = loop$handlers; 3993 - let mapper = loop$mapper; 3994 - let path = loop$path; 3995 - let child_index = loop$child_index; 3996 - let children = loop$children; 3997 - if (children instanceof Empty) { 3998 - return handlers; 3999 - } else { 4000 - let child = children.head; 4001 - let rest = children.tail; 4002 - let _pipe = handlers; 4003 - let _pipe$1 = do_add_child(_pipe, mapper, path, child_index, child); 4004 - loop$handlers = _pipe$1; 4005 - loop$mapper = mapper; 4006 - loop$path = path; 4007 - loop$child_index = child_index + advance(child); 4008 - loop$children = rest; 4009 - } 4010 - } 4011 - } 4012 - function do_add_child(handlers, mapper, parent, child_index, child) { 4013 - if (child instanceof Fragment) { 4014 - let children = child.children; 4015 - let composed_mapper = compose_mapper(mapper, child.mapper); 4016 - let child_index$1 = child_index + 1; 4017 - return do_add_children( 4018 - handlers, 4019 - composed_mapper, 4020 - parent, 4021 - child_index$1, 4022 - children 4023 - ); 4024 - } else if (child instanceof Element) { 4025 - let attributes = child.attributes; 4026 - let children = child.children; 4027 - let path = add3(parent, child_index, child.key); 4028 - let composed_mapper = compose_mapper(mapper, child.mapper); 4029 - let _pipe = handlers; 4030 - let _pipe$1 = add_attributes(_pipe, composed_mapper, path, attributes); 4031 - return do_add_children(_pipe$1, composed_mapper, path, 0, children); 4032 - } else if (child instanceof Text) { 4033 - return handlers; 4034 - } else { 4035 - let attributes = child.attributes; 4036 - let path = add3(parent, child_index, child.key); 4037 - let composed_mapper = compose_mapper(mapper, child.mapper); 4038 - return add_attributes(handlers, composed_mapper, path, attributes); 4039 - } 4040 - } 4041 - function add_child(events, mapper, parent, index4, child) { 4042 - let handlers = do_add_child(events.handlers, mapper, parent, index4, child); 4043 - let _record = events; 4044 - return new Events( 4045 - handlers, 4046 - _record.dispatched_paths, 4047 - _record.next_dispatched_paths 4048 - ); 4049 - } 4050 - function add_children(events, mapper, path, child_index, children) { 4051 - let handlers = do_add_children( 4052 - events.handlers, 4053 - mapper, 4054 - path, 4055 - child_index, 4056 - children 4057 - ); 4058 - let _record = events; 4059 - return new Events( 4060 - handlers, 4061 - _record.dispatched_paths, 4062 - _record.next_dispatched_paths 4063 - ); 4064 - } 4065 - 4066 - // build/dev/javascript/lustre/lustre/element.mjs 4067 - function element2(tag, attributes, children) { 4068 - return element( 4069 - "", 4070 - identity2, 4071 - "", 4072 - tag, 4073 - attributes, 4074 - children, 4075 - empty4(), 4076 - false, 4077 - false 4078 - ); 4079 - } 4080 - function namespaced(namespace, tag, attributes, children) { 4081 - return element( 4082 - "", 4083 - identity2, 4084 - namespace, 4085 - tag, 4086 - attributes, 4087 - children, 4088 - empty4(), 4089 - false, 4090 - false 4091 - ); 4092 - } 4093 - function text2(content) { 4094 - return text("", identity2, content); 4095 - } 4096 - function none2() { 4097 - return text("", identity2, ""); 4098 - } 4099 - function count_fragment_children(loop$children, loop$count) { 4100 - while (true) { 4101 - let children = loop$children; 4102 - let count = loop$count; 4103 - if (children instanceof Empty) { 4104 - return count; 4105 - } else { 4106 - let child = children.head; 4107 - let rest = children.tail; 4108 - loop$children = rest; 4109 - loop$count = count + advance(child); 4110 - } 4111 - } 4112 - } 4113 - function fragment2(children) { 4114 - return fragment( 4115 - "", 4116 - identity2, 4117 - children, 4118 - empty4(), 4119 - count_fragment_children(children, 0) 4120 - ); 4121 - } 4122 - function unsafe_raw_html(namespace, tag, attributes, inner_html) { 4123 - return unsafe_inner_html( 4124 - "", 4125 - identity2, 4126 - namespace, 4127 - tag, 4128 - attributes, 4129 - inner_html 4130 - ); 4131 - } 4132 - 4133 - // build/dev/javascript/lustre/lustre/element/html.mjs 4134 - function style(attrs, css) { 4135 - return unsafe_raw_html("", "style", attrs, css); 4136 - } 4137 - 4138 - // build/dev/javascript/lustre/lustre/vdom/patch.mjs 4139 - var Patch = class extends CustomType { 4140 - constructor(index4, removed, changes, children) { 4141 - super(); 4142 - this.index = index4; 4143 - this.removed = removed; 4144 - this.changes = changes; 4145 - this.children = children; 4146 - } 4147 - }; 4148 - var ReplaceText = class extends CustomType { 4149 - constructor(kind, content) { 4150 - super(); 4151 - this.kind = kind; 4152 - this.content = content; 4153 - } 4154 - }; 4155 - var ReplaceInnerHtml = class extends CustomType { 4156 - constructor(kind, inner_html) { 4157 - super(); 4158 - this.kind = kind; 4159 - this.inner_html = inner_html; 4160 - } 4161 - }; 4162 - var Update = class extends CustomType { 4163 - constructor(kind, added, removed) { 4164 - super(); 4165 - this.kind = kind; 4166 - this.added = added; 4167 - this.removed = removed; 4168 - } 4169 - }; 4170 - var Move = class extends CustomType { 4171 - constructor(kind, key, before, count) { 4172 - super(); 4173 - this.kind = kind; 4174 - this.key = key; 4175 - this.before = before; 4176 - this.count = count; 4177 - } 4178 - }; 4179 - var RemoveKey = class extends CustomType { 4180 - constructor(kind, key, count) { 4181 - super(); 4182 - this.kind = kind; 4183 - this.key = key; 4184 - this.count = count; 4185 - } 4186 - }; 4187 - var Replace = class extends CustomType { 4188 - constructor(kind, from2, count, with$) { 4189 - super(); 4190 - this.kind = kind; 4191 - this.from = from2; 4192 - this.count = count; 4193 - this.with = with$; 4194 - } 4195 - }; 4196 - var Insert = class extends CustomType { 4197 - constructor(kind, children, before) { 4198 - super(); 4199 - this.kind = kind; 4200 - this.children = children; 4201 - this.before = before; 4202 - } 4203 - }; 4204 - var Remove = class extends CustomType { 4205 - constructor(kind, from2, count) { 4206 - super(); 4207 - this.kind = kind; 4208 - this.from = from2; 4209 - this.count = count; 4210 - } 4211 - }; 4212 - function new$7(index4, removed, changes, children) { 4213 - return new Patch(index4, removed, changes, children); 4214 - } 4215 - var replace_text_kind = 0; 4216 - function replace_text(content) { 4217 - return new ReplaceText(replace_text_kind, content); 4218 - } 4219 - var replace_inner_html_kind = 1; 4220 - function replace_inner_html(inner_html) { 4221 - return new ReplaceInnerHtml(replace_inner_html_kind, inner_html); 4222 - } 4223 - var update_kind = 2; 4224 - function update3(added, removed) { 4225 - return new Update(update_kind, added, removed); 4226 - } 4227 - var move_kind = 3; 4228 - function move(key, before, count) { 4229 - return new Move(move_kind, key, before, count); 4230 - } 4231 - var remove_key_kind = 4; 4232 - function remove_key(key, count) { 4233 - return new RemoveKey(remove_key_kind, key, count); 4234 - } 4235 - var replace_kind = 5; 4236 - function replace2(from2, count, with$) { 4237 - return new Replace(replace_kind, from2, count, with$); 4238 - } 4239 - var insert_kind = 6; 4240 - function insert4(children, before) { 4241 - return new Insert(insert_kind, children, before); 4242 - } 4243 - var remove_kind = 7; 4244 - function remove2(from2, count) { 4245 - return new Remove(remove_kind, from2, count); 4246 - } 4247 - 4248 - // build/dev/javascript/lustre/lustre/vdom/diff.mjs 4249 - var Diff = class extends CustomType { 4250 - constructor(patch, events) { 4251 - super(); 4252 - this.patch = patch; 4253 - this.events = events; 4254 - } 4255 - }; 4256 - var AttributeChange = class extends CustomType { 4257 - constructor(added, removed, events) { 4258 - super(); 4259 - this.added = added; 4260 - this.removed = removed; 4261 - this.events = events; 4262 - } 4263 - }; 4264 - function is_controlled(events, namespace, tag, path) { 4265 - if (tag === "input") { 4266 - if (namespace === "") { 4267 - return has_dispatched_events(events, path); 4268 - } else { 4269 - return false; 4270 - } 4271 - } else if (tag === "select") { 4272 - if (namespace === "") { 4273 - return has_dispatched_events(events, path); 4274 - } else { 4275 - return false; 4276 - } 4277 - } else if (tag === "textarea") { 4278 - if (namespace === "") { 4279 - return has_dispatched_events(events, path); 4280 - } else { 4281 - return false; 4282 - } 4283 - } else { 4284 - return false; 4285 - } 4286 - } 4287 - function diff_attributes(loop$controlled, loop$path, loop$mapper, loop$events, loop$old, loop$new, loop$added, loop$removed) { 4288 - while (true) { 4289 - let controlled = loop$controlled; 4290 - let path = loop$path; 4291 - let mapper = loop$mapper; 4292 - let events = loop$events; 4293 - let old = loop$old; 4294 - let new$11 = loop$new; 4295 - let added = loop$added; 4296 - let removed = loop$removed; 4297 - if (new$11 instanceof Empty) { 4298 - if (old instanceof Empty) { 4299 - return new AttributeChange(added, removed, events); 4300 - } else { 4301 - let $ = old.head; 4302 - if ($ instanceof Event2) { 4303 - let prev = $; 4304 - let old$1 = old.tail; 4305 - let name = $.name; 4306 - let removed$1 = prepend(prev, removed); 4307 - let events$1 = remove_event(events, path, name); 4308 - loop$controlled = controlled; 4309 - loop$path = path; 4310 - loop$mapper = mapper; 4311 - loop$events = events$1; 4312 - loop$old = old$1; 4313 - loop$new = new$11; 4314 - loop$added = added; 4315 - loop$removed = removed$1; 4316 - } else { 4317 - let prev = $; 4318 - let old$1 = old.tail; 4319 - let removed$1 = prepend(prev, removed); 4320 - loop$controlled = controlled; 4321 - loop$path = path; 4322 - loop$mapper = mapper; 4323 - loop$events = events; 4324 - loop$old = old$1; 4325 - loop$new = new$11; 4326 - loop$added = added; 4327 - loop$removed = removed$1; 4328 - } 4329 - } 4330 - } else if (old instanceof Empty) { 4331 - let $ = new$11.head; 4332 - if ($ instanceof Event2) { 4333 - let next = $; 4334 - let new$1 = new$11.tail; 4335 - let name = $.name; 4336 - let handler = $.handler; 4337 - let added$1 = prepend(next, added); 4338 - let events$1 = add_event(events, mapper, path, name, handler); 4339 - loop$controlled = controlled; 4340 - loop$path = path; 4341 - loop$mapper = mapper; 4342 - loop$events = events$1; 4343 - loop$old = old; 4344 - loop$new = new$1; 4345 - loop$added = added$1; 4346 - loop$removed = removed; 4347 - } else { 4348 - let next = $; 4349 - let new$1 = new$11.tail; 4350 - let added$1 = prepend(next, added); 4351 - loop$controlled = controlled; 4352 - loop$path = path; 4353 - loop$mapper = mapper; 4354 - loop$events = events; 4355 - loop$old = old; 4356 - loop$new = new$1; 4357 - loop$added = added$1; 4358 - loop$removed = removed; 4359 - } 4360 - } else { 4361 - let next = new$11.head; 4362 - let remaining_new = new$11.tail; 4363 - let prev = old.head; 4364 - let remaining_old = old.tail; 4365 - let $ = compare3(prev, next); 4366 - if ($ instanceof Lt) { 4367 - if (prev instanceof Event2) { 4368 - let name = prev.name; 4369 - let removed$1 = prepend(prev, removed); 4370 - let events$1 = remove_event(events, path, name); 4371 - loop$controlled = controlled; 4372 - loop$path = path; 4373 - loop$mapper = mapper; 4374 - loop$events = events$1; 4375 - loop$old = remaining_old; 4376 - loop$new = new$11; 4377 - loop$added = added; 4378 - loop$removed = removed$1; 4379 - } else { 4380 - let removed$1 = prepend(prev, removed); 4381 - loop$controlled = controlled; 4382 - loop$path = path; 4383 - loop$mapper = mapper; 4384 - loop$events = events; 4385 - loop$old = remaining_old; 4386 - loop$new = new$11; 4387 - loop$added = added; 4388 - loop$removed = removed$1; 4389 - } 4390 - } else if ($ instanceof Eq) { 4391 - if (next instanceof Attribute) { 4392 - if (prev instanceof Attribute) { 4393 - let _block; 4394 - let $1 = next.name; 4395 - if ($1 === "value") { 4396 - _block = controlled || prev.value !== next.value; 4397 - } else if ($1 === "checked") { 4398 - _block = controlled || prev.value !== next.value; 4399 - } else if ($1 === "selected") { 4400 - _block = controlled || prev.value !== next.value; 4401 - } else { 4402 - _block = prev.value !== next.value; 4403 - } 4404 - let has_changes = _block; 4405 - let _block$1; 4406 - if (has_changes) { 4407 - _block$1 = prepend(next, added); 4408 - } else { 4409 - _block$1 = added; 4410 - } 4411 - let added$1 = _block$1; 4412 - loop$controlled = controlled; 4413 - loop$path = path; 4414 - loop$mapper = mapper; 4415 - loop$events = events; 4416 - loop$old = remaining_old; 4417 - loop$new = remaining_new; 4418 - loop$added = added$1; 4419 - loop$removed = removed; 4420 - } else if (prev instanceof Event2) { 4421 - let name = prev.name; 4422 - let added$1 = prepend(next, added); 4423 - let removed$1 = prepend(prev, removed); 4424 - let events$1 = remove_event(events, path, name); 4425 - loop$controlled = controlled; 4426 - loop$path = path; 4427 - loop$mapper = mapper; 4428 - loop$events = events$1; 4429 - loop$old = remaining_old; 4430 - loop$new = remaining_new; 4431 - loop$added = added$1; 4432 - loop$removed = removed$1; 4433 - } else { 4434 - let added$1 = prepend(next, added); 4435 - let removed$1 = prepend(prev, removed); 4436 - loop$controlled = controlled; 4437 - loop$path = path; 4438 - loop$mapper = mapper; 4439 - loop$events = events; 4440 - loop$old = remaining_old; 4441 - loop$new = remaining_new; 4442 - loop$added = added$1; 4443 - loop$removed = removed$1; 4444 - } 4445 - } else if (next instanceof Property) { 4446 - if (prev instanceof Property) { 4447 - let _block; 4448 - let $1 = next.name; 4449 - if ($1 === "scrollLeft") { 4450 - _block = true; 4451 - } else if ($1 === "scrollRight") { 4452 - _block = true; 4453 - } else if ($1 === "value") { 4454 - _block = controlled || !isEqual2( 4455 - prev.value, 4456 - next.value 4457 - ); 4458 - } else if ($1 === "checked") { 4459 - _block = controlled || !isEqual2( 4460 - prev.value, 4461 - next.value 4462 - ); 4463 - } else if ($1 === "selected") { 4464 - _block = controlled || !isEqual2( 4465 - prev.value, 4466 - next.value 4467 - ); 4468 - } else { 4469 - _block = !isEqual2(prev.value, next.value); 4470 - } 4471 - let has_changes = _block; 4472 - let _block$1; 4473 - if (has_changes) { 4474 - _block$1 = prepend(next, added); 4475 - } else { 4476 - _block$1 = added; 4477 - } 4478 - let added$1 = _block$1; 4479 - loop$controlled = controlled; 4480 - loop$path = path; 4481 - loop$mapper = mapper; 4482 - loop$events = events; 4483 - loop$old = remaining_old; 4484 - loop$new = remaining_new; 4485 - loop$added = added$1; 4486 - loop$removed = removed; 4487 - } else if (prev instanceof Event2) { 4488 - let name = prev.name; 4489 - let added$1 = prepend(next, added); 4490 - let removed$1 = prepend(prev, removed); 4491 - let events$1 = remove_event(events, path, name); 4492 - loop$controlled = controlled; 4493 - loop$path = path; 4494 - loop$mapper = mapper; 4495 - loop$events = events$1; 4496 - loop$old = remaining_old; 4497 - loop$new = remaining_new; 4498 - loop$added = added$1; 4499 - loop$removed = removed$1; 4500 - } else { 4501 - let added$1 = prepend(next, added); 4502 - let removed$1 = prepend(prev, removed); 4503 - loop$controlled = controlled; 4504 - loop$path = path; 4505 - loop$mapper = mapper; 4506 - loop$events = events; 4507 - loop$old = remaining_old; 4508 - loop$new = remaining_new; 4509 - loop$added = added$1; 4510 - loop$removed = removed$1; 4511 - } 4512 - } else if (prev instanceof Event2) { 4513 - let name = next.name; 4514 - let handler = next.handler; 4515 - let has_changes = !isEqual( 4516 - prev.prevent_default, 4517 - next.prevent_default 4518 - ) || !isEqual(prev.stop_propagation, next.stop_propagation) || prev.immediate !== next.immediate || prev.debounce !== next.debounce || prev.throttle !== next.throttle; 4519 - let _block; 4520 - if (has_changes) { 4521 - _block = prepend(next, added); 4522 - } else { 4523 - _block = added; 4524 - } 4525 - let added$1 = _block; 4526 - let events$1 = add_event(events, mapper, path, name, handler); 4527 - loop$controlled = controlled; 4528 - loop$path = path; 4529 - loop$mapper = mapper; 4530 - loop$events = events$1; 4531 - loop$old = remaining_old; 4532 - loop$new = remaining_new; 4533 - loop$added = added$1; 4534 - loop$removed = removed; 4535 - } else { 4536 - let name = next.name; 4537 - let handler = next.handler; 4538 - let added$1 = prepend(next, added); 4539 - let removed$1 = prepend(prev, removed); 4540 - let events$1 = add_event(events, mapper, path, name, handler); 4541 - loop$controlled = controlled; 4542 - loop$path = path; 4543 - loop$mapper = mapper; 4544 - loop$events = events$1; 4545 - loop$old = remaining_old; 4546 - loop$new = remaining_new; 4547 - loop$added = added$1; 4548 - loop$removed = removed$1; 4549 - } 4550 - } else if (next instanceof Event2) { 4551 - let name = next.name; 4552 - let handler = next.handler; 4553 - let added$1 = prepend(next, added); 4554 - let events$1 = add_event(events, mapper, path, name, handler); 4555 - loop$controlled = controlled; 4556 - loop$path = path; 4557 - loop$mapper = mapper; 4558 - loop$events = events$1; 4559 - loop$old = old; 4560 - loop$new = remaining_new; 4561 - loop$added = added$1; 4562 - loop$removed = removed; 4563 - } else { 4564 - let added$1 = prepend(next, added); 4565 - loop$controlled = controlled; 4566 - loop$path = path; 4567 - loop$mapper = mapper; 4568 - loop$events = events; 4569 - loop$old = old; 4570 - loop$new = remaining_new; 4571 - loop$added = added$1; 4572 - loop$removed = removed; 4573 - } 4574 - } 4575 - } 4576 - } 4577 - function do_diff(loop$old, loop$old_keyed, loop$new, loop$new_keyed, loop$moved, loop$moved_offset, loop$removed, loop$node_index, loop$patch_index, loop$path, loop$changes, loop$children, loop$mapper, loop$events) { 4578 - while (true) { 4579 - let old = loop$old; 4580 - let old_keyed = loop$old_keyed; 4581 - let new$11 = loop$new; 4582 - let new_keyed = loop$new_keyed; 4583 - let moved = loop$moved; 4584 - let moved_offset = loop$moved_offset; 4585 - let removed = loop$removed; 4586 - let node_index = loop$node_index; 4587 - let patch_index = loop$patch_index; 4588 - let path = loop$path; 4589 - let changes = loop$changes; 4590 - let children = loop$children; 4591 - let mapper = loop$mapper; 4592 - let events = loop$events; 4593 - if (new$11 instanceof Empty) { 4594 - if (old instanceof Empty) { 4595 - return new Diff( 4596 - new Patch(patch_index, removed, changes, children), 4597 - events 4598 - ); 4599 - } else { 4600 - let prev = old.head; 4601 - let old$1 = old.tail; 4602 - let _block; 4603 - let $ = prev.key === "" || !contains(moved, prev.key); 4604 - if ($) { 4605 - _block = removed + advance(prev); 4606 - } else { 4607 - _block = removed; 4608 - } 4609 - let removed$1 = _block; 4610 - let events$1 = remove_child(events, path, node_index, prev); 4611 - loop$old = old$1; 4612 - loop$old_keyed = old_keyed; 4613 - loop$new = new$11; 4614 - loop$new_keyed = new_keyed; 4615 - loop$moved = moved; 4616 - loop$moved_offset = moved_offset; 4617 - loop$removed = removed$1; 4618 - loop$node_index = node_index; 4619 - loop$patch_index = patch_index; 4620 - loop$path = path; 4621 - loop$changes = changes; 4622 - loop$children = children; 4623 - loop$mapper = mapper; 4624 - loop$events = events$1; 4625 - } 4626 - } else if (old instanceof Empty) { 4627 - let events$1 = add_children( 4628 - events, 4629 - mapper, 4630 - path, 4631 - node_index, 4632 - new$11 4633 - ); 4634 - let insert5 = insert4(new$11, node_index - moved_offset); 4635 - let changes$1 = prepend(insert5, changes); 4636 - return new Diff( 4637 - new Patch(patch_index, removed, changes$1, children), 4638 - events$1 4639 - ); 4640 - } else { 4641 - let next = new$11.head; 4642 - let prev = old.head; 4643 - if (prev.key !== next.key) { 4644 - let new_remaining = new$11.tail; 4645 - let old_remaining = old.tail; 4646 - let next_did_exist = get3(old_keyed, next.key); 4647 - let prev_does_exist = get3(new_keyed, prev.key); 4648 - let prev_has_moved = contains(moved, prev.key); 4649 - if (next_did_exist instanceof Ok) { 4650 - if (prev_does_exist instanceof Ok) { 4651 - if (prev_has_moved) { 4652 - loop$old = old_remaining; 4653 - loop$old_keyed = old_keyed; 4654 - loop$new = new$11; 4655 - loop$new_keyed = new_keyed; 4656 - loop$moved = moved; 4657 - loop$moved_offset = moved_offset - advance(prev); 4658 - loop$removed = removed; 4659 - loop$node_index = node_index; 4660 - loop$patch_index = patch_index; 4661 - loop$path = path; 4662 - loop$changes = changes; 4663 - loop$children = children; 4664 - loop$mapper = mapper; 4665 - loop$events = events; 4666 - } else { 4667 - let match = next_did_exist[0]; 4668 - let count = advance(next); 4669 - let before = node_index - moved_offset; 4670 - let move2 = move(next.key, before, count); 4671 - let changes$1 = prepend(move2, changes); 4672 - let moved$1 = insert2(moved, next.key); 4673 - let moved_offset$1 = moved_offset + count; 4674 - loop$old = prepend(match, old); 4675 - loop$old_keyed = old_keyed; 4676 - loop$new = new$11; 4677 - loop$new_keyed = new_keyed; 4678 - loop$moved = moved$1; 4679 - loop$moved_offset = moved_offset$1; 4680 - loop$removed = removed; 4681 - loop$node_index = node_index; 4682 - loop$patch_index = patch_index; 4683 - loop$path = path; 4684 - loop$changes = changes$1; 4685 - loop$children = children; 4686 - loop$mapper = mapper; 4687 - loop$events = events; 4688 - } 4689 - } else { 4690 - let count = advance(prev); 4691 - let moved_offset$1 = moved_offset - count; 4692 - let events$1 = remove_child(events, path, node_index, prev); 4693 - let remove3 = remove_key(prev.key, count); 4694 - let changes$1 = prepend(remove3, changes); 4695 - loop$old = old_remaining; 4696 - loop$old_keyed = old_keyed; 4697 - loop$new = new$11; 4698 - loop$new_keyed = new_keyed; 4699 - loop$moved = moved; 4700 - loop$moved_offset = moved_offset$1; 4701 - loop$removed = removed; 4702 - loop$node_index = node_index; 4703 - loop$patch_index = patch_index; 4704 - loop$path = path; 4705 - loop$changes = changes$1; 4706 - loop$children = children; 4707 - loop$mapper = mapper; 4708 - loop$events = events$1; 4709 - } 4710 - } else if (prev_does_exist instanceof Ok) { 4711 - let before = node_index - moved_offset; 4712 - let count = advance(next); 4713 - let events$1 = add_child( 4714 - events, 4715 - mapper, 4716 - path, 4717 - node_index, 4718 - next 4719 - ); 4720 - let insert5 = insert4(toList([next]), before); 4721 - let changes$1 = prepend(insert5, changes); 4722 - loop$old = old; 4723 - loop$old_keyed = old_keyed; 4724 - loop$new = new_remaining; 4725 - loop$new_keyed = new_keyed; 4726 - loop$moved = moved; 4727 - loop$moved_offset = moved_offset + count; 4728 - loop$removed = removed; 4729 - loop$node_index = node_index + count; 4730 - loop$patch_index = patch_index; 4731 - loop$path = path; 4732 - loop$changes = changes$1; 4733 - loop$children = children; 4734 - loop$mapper = mapper; 4735 - loop$events = events$1; 4736 - } else { 4737 - let prev_count = advance(prev); 4738 - let next_count = advance(next); 4739 - let change = replace2( 4740 - node_index - moved_offset, 4741 - prev_count, 4742 - next 4743 - ); 4744 - let _block; 4745 - let _pipe = events; 4746 - let _pipe$1 = remove_child(_pipe, path, node_index, prev); 4747 - _block = add_child(_pipe$1, mapper, path, node_index, next); 4748 - let events$1 = _block; 4749 - loop$old = old_remaining; 4750 - loop$old_keyed = old_keyed; 4751 - loop$new = new_remaining; 4752 - loop$new_keyed = new_keyed; 4753 - loop$moved = moved; 4754 - loop$moved_offset = moved_offset - prev_count + next_count; 4755 - loop$removed = removed; 4756 - loop$node_index = node_index + next_count; 4757 - loop$patch_index = patch_index; 4758 - loop$path = path; 4759 - loop$changes = prepend(change, changes); 4760 - loop$children = children; 4761 - loop$mapper = mapper; 4762 - loop$events = events$1; 4763 - } 4764 - } else { 4765 - let $ = old.head; 4766 - if ($ instanceof Fragment) { 4767 - let $1 = new$11.head; 4768 - if ($1 instanceof Fragment) { 4769 - let next$1 = $1; 4770 - let new$1 = new$11.tail; 4771 - let prev$1 = $; 4772 - let old$1 = old.tail; 4773 - let node_index$1 = node_index + 1; 4774 - let prev_count = prev$1.children_count; 4775 - let next_count = next$1.children_count; 4776 - let composed_mapper = compose_mapper(mapper, next$1.mapper); 4777 - let child = do_diff( 4778 - prev$1.children, 4779 - prev$1.keyed_children, 4780 - next$1.children, 4781 - next$1.keyed_children, 4782 - empty_set(), 4783 - moved_offset, 4784 - 0, 4785 - node_index$1, 4786 - -1, 4787 - path, 4788 - empty_list, 4789 - children, 4790 - composed_mapper, 4791 - events 4792 - ); 4793 - let _block; 4794 - let $2 = child.patch.removed > 0; 4795 - if ($2) { 4796 - let remove_from = node_index$1 + next_count - moved_offset; 4797 - let patch = remove2(remove_from, child.patch.removed); 4798 - _block = append( 4799 - child.patch.changes, 4800 - prepend(patch, changes) 4801 - ); 4802 - } else { 4803 - _block = append(child.patch.changes, changes); 4804 - } 4805 - let changes$1 = _block; 4806 - loop$old = old$1; 4807 - loop$old_keyed = old_keyed; 4808 - loop$new = new$1; 4809 - loop$new_keyed = new_keyed; 4810 - loop$moved = moved; 4811 - loop$moved_offset = moved_offset + next_count - prev_count; 4812 - loop$removed = removed; 4813 - loop$node_index = node_index$1 + next_count; 4814 - loop$patch_index = patch_index; 4815 - loop$path = path; 4816 - loop$changes = changes$1; 4817 - loop$children = child.patch.children; 4818 - loop$mapper = mapper; 4819 - loop$events = child.events; 4820 - } else { 4821 - let next$1 = $1; 4822 - let new_remaining = new$11.tail; 4823 - let prev$1 = $; 4824 - let old_remaining = old.tail; 4825 - let prev_count = advance(prev$1); 4826 - let next_count = advance(next$1); 4827 - let change = replace2( 4828 - node_index - moved_offset, 4829 - prev_count, 4830 - next$1 4831 - ); 4832 - let _block; 4833 - let _pipe = events; 4834 - let _pipe$1 = remove_child(_pipe, path, node_index, prev$1); 4835 - _block = add_child( 4836 - _pipe$1, 4837 - mapper, 4838 - path, 4839 - node_index, 4840 - next$1 4841 - ); 4842 - let events$1 = _block; 4843 - loop$old = old_remaining; 4844 - loop$old_keyed = old_keyed; 4845 - loop$new = new_remaining; 4846 - loop$new_keyed = new_keyed; 4847 - loop$moved = moved; 4848 - loop$moved_offset = moved_offset - prev_count + next_count; 4849 - loop$removed = removed; 4850 - loop$node_index = node_index + next_count; 4851 - loop$patch_index = patch_index; 4852 - loop$path = path; 4853 - loop$changes = prepend(change, changes); 4854 - loop$children = children; 4855 - loop$mapper = mapper; 4856 - loop$events = events$1; 4857 - } 4858 - } else if ($ instanceof Element) { 4859 - let $1 = new$11.head; 4860 - if ($1 instanceof Element) { 4861 - let next$1 = $1; 4862 - let prev$1 = $; 4863 - if (prev$1.namespace === next$1.namespace && prev$1.tag === next$1.tag) { 4864 - let new$1 = new$11.tail; 4865 - let old$1 = old.tail; 4866 - let composed_mapper = compose_mapper( 4867 - mapper, 4868 - next$1.mapper 4869 - ); 4870 - let child_path = add3(path, node_index, next$1.key); 4871 - let controlled = is_controlled( 4872 - events, 4873 - next$1.namespace, 4874 - next$1.tag, 4875 - child_path 4876 - ); 4877 - let $2 = diff_attributes( 4878 - controlled, 4879 - child_path, 4880 - composed_mapper, 4881 - events, 4882 - prev$1.attributes, 4883 - next$1.attributes, 4884 - empty_list, 4885 - empty_list 4886 - ); 4887 - let added_attrs = $2.added; 4888 - let removed_attrs = $2.removed; 4889 - let events$1 = $2.events; 4890 - let _block; 4891 - if (removed_attrs instanceof Empty) { 4892 - if (added_attrs instanceof Empty) { 4893 - _block = empty_list; 4894 - } else { 4895 - _block = toList([update3(added_attrs, removed_attrs)]); 4896 - } 4897 - } else { 4898 - _block = toList([update3(added_attrs, removed_attrs)]); 4899 - } 4900 - let initial_child_changes = _block; 4901 - let child = do_diff( 4902 - prev$1.children, 4903 - prev$1.keyed_children, 4904 - next$1.children, 4905 - next$1.keyed_children, 4906 - empty_set(), 4907 - 0, 4908 - 0, 4909 - 0, 4910 - node_index, 4911 - child_path, 4912 - initial_child_changes, 4913 - empty_list, 4914 - composed_mapper, 4915 - events$1 4916 - ); 4917 - let _block$1; 4918 - let $3 = child.patch; 4919 - let $4 = $3.children; 4920 - if ($4 instanceof Empty) { 4921 - let $5 = $3.changes; 4922 - if ($5 instanceof Empty) { 4923 - let $6 = $3.removed; 4924 - if ($6 === 0) { 4925 - _block$1 = children; 4926 - } else { 4927 - _block$1 = prepend(child.patch, children); 4928 - } 4929 - } else { 4930 - _block$1 = prepend(child.patch, children); 4931 - } 4932 - } else { 4933 - _block$1 = prepend(child.patch, children); 4934 - } 4935 - let children$1 = _block$1; 4936 - loop$old = old$1; 4937 - loop$old_keyed = old_keyed; 4938 - loop$new = new$1; 4939 - loop$new_keyed = new_keyed; 4940 - loop$moved = moved; 4941 - loop$moved_offset = moved_offset; 4942 - loop$removed = removed; 4943 - loop$node_index = node_index + 1; 4944 - loop$patch_index = patch_index; 4945 - loop$path = path; 4946 - loop$changes = changes; 4947 - loop$children = children$1; 4948 - loop$mapper = mapper; 4949 - loop$events = child.events; 4950 - } else { 4951 - let next$2 = $1; 4952 - let new_remaining = new$11.tail; 4953 - let prev$2 = $; 4954 - let old_remaining = old.tail; 4955 - let prev_count = advance(prev$2); 4956 - let next_count = advance(next$2); 4957 - let change = replace2( 4958 - node_index - moved_offset, 4959 - prev_count, 4960 - next$2 4961 - ); 4962 - let _block; 4963 - let _pipe = events; 4964 - let _pipe$1 = remove_child( 4965 - _pipe, 4966 - path, 4967 - node_index, 4968 - prev$2 4969 - ); 4970 - _block = add_child( 4971 - _pipe$1, 4972 - mapper, 4973 - path, 4974 - node_index, 4975 - next$2 4976 - ); 4977 - let events$1 = _block; 4978 - loop$old = old_remaining; 4979 - loop$old_keyed = old_keyed; 4980 - loop$new = new_remaining; 4981 - loop$new_keyed = new_keyed; 4982 - loop$moved = moved; 4983 - loop$moved_offset = moved_offset - prev_count + next_count; 4984 - loop$removed = removed; 4985 - loop$node_index = node_index + next_count; 4986 - loop$patch_index = patch_index; 4987 - loop$path = path; 4988 - loop$changes = prepend(change, changes); 4989 - loop$children = children; 4990 - loop$mapper = mapper; 4991 - loop$events = events$1; 4992 - } 4993 - } else { 4994 - let next$1 = $1; 4995 - let new_remaining = new$11.tail; 4996 - let prev$1 = $; 4997 - let old_remaining = old.tail; 4998 - let prev_count = advance(prev$1); 4999 - let next_count = advance(next$1); 5000 - let change = replace2( 5001 - node_index - moved_offset, 5002 - prev_count, 5003 - next$1 5004 - ); 5005 - let _block; 5006 - let _pipe = events; 5007 - let _pipe$1 = remove_child(_pipe, path, node_index, prev$1); 5008 - _block = add_child( 5009 - _pipe$1, 5010 - mapper, 5011 - path, 5012 - node_index, 5013 - next$1 5014 - ); 5015 - let events$1 = _block; 5016 - loop$old = old_remaining; 5017 - loop$old_keyed = old_keyed; 5018 - loop$new = new_remaining; 5019 - loop$new_keyed = new_keyed; 5020 - loop$moved = moved; 5021 - loop$moved_offset = moved_offset - prev_count + next_count; 5022 - loop$removed = removed; 5023 - loop$node_index = node_index + next_count; 5024 - loop$patch_index = patch_index; 5025 - loop$path = path; 5026 - loop$changes = prepend(change, changes); 5027 - loop$children = children; 5028 - loop$mapper = mapper; 5029 - loop$events = events$1; 5030 - } 5031 - } else if ($ instanceof Text) { 5032 - let $1 = new$11.head; 5033 - if ($1 instanceof Text) { 5034 - let next$1 = $1; 5035 - let prev$1 = $; 5036 - if (prev$1.content === next$1.content) { 5037 - let new$1 = new$11.tail; 5038 - let old$1 = old.tail; 5039 - loop$old = old$1; 5040 - loop$old_keyed = old_keyed; 5041 - loop$new = new$1; 5042 - loop$new_keyed = new_keyed; 5043 - loop$moved = moved; 5044 - loop$moved_offset = moved_offset; 5045 - loop$removed = removed; 5046 - loop$node_index = node_index + 1; 5047 - loop$patch_index = patch_index; 5048 - loop$path = path; 5049 - loop$changes = changes; 5050 - loop$children = children; 5051 - loop$mapper = mapper; 5052 - loop$events = events; 5053 - } else { 5054 - let next$2 = $1; 5055 - let new$1 = new$11.tail; 5056 - let old$1 = old.tail; 5057 - let child = new$7( 5058 - node_index, 5059 - 0, 5060 - toList([replace_text(next$2.content)]), 5061 - empty_list 5062 - ); 5063 - loop$old = old$1; 5064 - loop$old_keyed = old_keyed; 5065 - loop$new = new$1; 5066 - loop$new_keyed = new_keyed; 5067 - loop$moved = moved; 5068 - loop$moved_offset = moved_offset; 5069 - loop$removed = removed; 5070 - loop$node_index = node_index + 1; 5071 - loop$patch_index = patch_index; 5072 - loop$path = path; 5073 - loop$changes = changes; 5074 - loop$children = prepend(child, children); 5075 - loop$mapper = mapper; 5076 - loop$events = events; 5077 - } 5078 - } else { 5079 - let next$1 = $1; 5080 - let new_remaining = new$11.tail; 5081 - let prev$1 = $; 5082 - let old_remaining = old.tail; 5083 - let prev_count = advance(prev$1); 5084 - let next_count = advance(next$1); 5085 - let change = replace2( 5086 - node_index - moved_offset, 5087 - prev_count, 5088 - next$1 5089 - ); 5090 - let _block; 5091 - let _pipe = events; 5092 - let _pipe$1 = remove_child(_pipe, path, node_index, prev$1); 5093 - _block = add_child( 5094 - _pipe$1, 5095 - mapper, 5096 - path, 5097 - node_index, 5098 - next$1 5099 - ); 5100 - let events$1 = _block; 5101 - loop$old = old_remaining; 5102 - loop$old_keyed = old_keyed; 5103 - loop$new = new_remaining; 5104 - loop$new_keyed = new_keyed; 5105 - loop$moved = moved; 5106 - loop$moved_offset = moved_offset - prev_count + next_count; 5107 - loop$removed = removed; 5108 - loop$node_index = node_index + next_count; 5109 - loop$patch_index = patch_index; 5110 - loop$path = path; 5111 - loop$changes = prepend(change, changes); 5112 - loop$children = children; 5113 - loop$mapper = mapper; 5114 - loop$events = events$1; 5115 - } 5116 - } else { 5117 - let $1 = new$11.head; 5118 - if ($1 instanceof UnsafeInnerHtml) { 5119 - let next$1 = $1; 5120 - let new$1 = new$11.tail; 5121 - let prev$1 = $; 5122 - let old$1 = old.tail; 5123 - let composed_mapper = compose_mapper(mapper, next$1.mapper); 5124 - let child_path = add3(path, node_index, next$1.key); 5125 - let $2 = diff_attributes( 5126 - false, 5127 - child_path, 5128 - composed_mapper, 5129 - events, 5130 - prev$1.attributes, 5131 - next$1.attributes, 5132 - empty_list, 5133 - empty_list 5134 - ); 5135 - let added_attrs = $2.added; 5136 - let removed_attrs = $2.removed; 5137 - let events$1 = $2.events; 5138 - let _block; 5139 - if (removed_attrs instanceof Empty) { 5140 - if (added_attrs instanceof Empty) { 5141 - _block = empty_list; 5142 - } else { 5143 - _block = toList([update3(added_attrs, removed_attrs)]); 5144 - } 5145 - } else { 5146 - _block = toList([update3(added_attrs, removed_attrs)]); 5147 - } 5148 - let child_changes = _block; 5149 - let _block$1; 5150 - let $3 = prev$1.inner_html === next$1.inner_html; 5151 - if ($3) { 5152 - _block$1 = child_changes; 5153 - } else { 5154 - _block$1 = prepend( 5155 - replace_inner_html(next$1.inner_html), 5156 - child_changes 5157 - ); 5158 - } 5159 - let child_changes$1 = _block$1; 5160 - let _block$2; 5161 - if (child_changes$1 instanceof Empty) { 5162 - _block$2 = children; 5163 - } else { 5164 - _block$2 = prepend( 5165 - new$7(node_index, 0, child_changes$1, toList([])), 5166 - children 5167 - ); 5168 - } 5169 - let children$1 = _block$2; 5170 - loop$old = old$1; 5171 - loop$old_keyed = old_keyed; 5172 - loop$new = new$1; 5173 - loop$new_keyed = new_keyed; 5174 - loop$moved = moved; 5175 - loop$moved_offset = moved_offset; 5176 - loop$removed = removed; 5177 - loop$node_index = node_index + 1; 5178 - loop$patch_index = patch_index; 5179 - loop$path = path; 5180 - loop$changes = changes; 5181 - loop$children = children$1; 5182 - loop$mapper = mapper; 5183 - loop$events = events$1; 5184 - } else { 5185 - let next$1 = $1; 5186 - let new_remaining = new$11.tail; 5187 - let prev$1 = $; 5188 - let old_remaining = old.tail; 5189 - let prev_count = advance(prev$1); 5190 - let next_count = advance(next$1); 5191 - let change = replace2( 5192 - node_index - moved_offset, 5193 - prev_count, 5194 - next$1 5195 - ); 5196 - let _block; 5197 - let _pipe = events; 5198 - let _pipe$1 = remove_child(_pipe, path, node_index, prev$1); 5199 - _block = add_child( 5200 - _pipe$1, 5201 - mapper, 5202 - path, 5203 - node_index, 5204 - next$1 5205 - ); 5206 - let events$1 = _block; 5207 - loop$old = old_remaining; 5208 - loop$old_keyed = old_keyed; 5209 - loop$new = new_remaining; 5210 - loop$new_keyed = new_keyed; 5211 - loop$moved = moved; 5212 - loop$moved_offset = moved_offset - prev_count + next_count; 5213 - loop$removed = removed; 5214 - loop$node_index = node_index + next_count; 5215 - loop$patch_index = patch_index; 5216 - loop$path = path; 5217 - loop$changes = prepend(change, changes); 5218 - loop$children = children; 5219 - loop$mapper = mapper; 5220 - loop$events = events$1; 5221 - } 5222 - } 5223 - } 5224 - } 5225 - } 5226 - } 5227 - function diff(events, old, new$11) { 5228 - return do_diff( 5229 - toList([old]), 5230 - empty4(), 5231 - toList([new$11]), 5232 - empty4(), 5233 - empty_set(), 5234 - 0, 5235 - 0, 5236 - 0, 5237 - 0, 5238 - root2, 5239 - empty_list, 5240 - empty_list, 5241 - identity2, 5242 - tick(events) 5243 - ); 5244 - } 5245 - 5246 - // build/dev/javascript/lustre/lustre/vdom/reconciler.ffi.mjs 5247 - var Reconciler = class { 5248 - offset = 0; 5249 - #root = null; 5250 - #dispatch = () => { 5251 - }; 5252 - #useServerEvents = false; 5253 - #exposeKeys = false; 5254 - constructor(root3, dispatch, { useServerEvents = false, exposeKeys = false } = {}) { 5255 - this.#root = root3; 5256 - this.#dispatch = dispatch; 5257 - this.#useServerEvents = useServerEvents; 5258 - this.#exposeKeys = exposeKeys; 5259 - } 5260 - mount(vdom) { 5261 - appendChild(this.#root, this.#createChild(this.#root, 0, vdom)); 5262 - } 5263 - #stack = []; 5264 - push(patch) { 5265 - const offset = this.offset; 5266 - if (offset) { 5267 - iterate(patch.changes, (change) => { 5268 - switch (change.kind) { 5269 - case insert_kind: 5270 - case move_kind: 5271 - change.before = (change.before | 0) + offset; 5272 - break; 5273 - case remove_kind: 5274 - case replace_kind: 5275 - change.from = (change.from | 0) + offset; 5276 - break; 5277 - } 5278 - }); 5279 - iterate(patch.children, (child) => { 5280 - child.index = (child.index | 0) + offset; 5281 - }); 5282 - } 5283 - this.#stack.push({ node: this.#root, patch }); 5284 - this.#reconcile(); 5285 - } 5286 - // PATCHING ------------------------------------------------------------------ 5287 - #reconcile() { 5288 - const self = this; 5289 - while (self.#stack.length) { 5290 - const { node: node2, patch } = self.#stack.pop(); 5291 - iterate(patch.changes, (change) => { 5292 - switch (change.kind) { 5293 - case insert_kind: 5294 - self.#insert(node2, change.children, change.before); 5295 - break; 5296 - case move_kind: 5297 - self.#move(node2, change.key, change.before, change.count); 5298 - break; 5299 - case remove_key_kind: 5300 - self.#removeKey(node2, change.key, change.count); 5301 - break; 5302 - case remove_kind: 5303 - self.#remove(node2, change.from, change.count); 5304 - break; 5305 - case replace_kind: 5306 - self.#replace(node2, change.from, change.count, change.with); 5307 - break; 5308 - case replace_text_kind: 5309 - self.#replaceText(node2, change.content); 5310 - break; 5311 - case replace_inner_html_kind: 5312 - self.#replaceInnerHtml(node2, change.inner_html); 5313 - break; 5314 - case update_kind: 5315 - self.#update(node2, change.added, change.removed); 5316 - break; 5317 - } 5318 - }); 5319 - if (patch.removed) { 5320 - self.#remove( 5321 - node2, 5322 - node2.childNodes.length - patch.removed, 5323 - patch.removed 5324 - ); 5325 - } 5326 - let lastIndex = -1; 5327 - let lastChild = null; 5328 - iterate(patch.children, (child) => { 5329 - const index4 = child.index | 0; 5330 - const next = lastChild && lastIndex - index4 === 1 ? lastChild.previousSibling : childAt(node2, index4); 5331 - self.#stack.push({ node: next, patch: child }); 5332 - lastChild = next; 5333 - lastIndex = index4; 5334 - }); 5335 - } 5336 - } 5337 - // CHANGES ------------------------------------------------------------------- 5338 - #insert(node2, children, before) { 5339 - const fragment3 = createDocumentFragment(); 5340 - let childIndex = before | 0; 5341 - iterate(children, (child) => { 5342 - const el = this.#createChild(node2, childIndex, child); 5343 - appendChild(fragment3, el); 5344 - childIndex += advance(child); 5345 - }); 5346 - insertBefore(node2, fragment3, childAt(node2, before)); 5347 - } 5348 - #move(node2, key, before, count) { 5349 - let el = getKeyedChild(node2, key); 5350 - const beforeEl = childAt(node2, before); 5351 - for (let i = 0; i < count && el !== null; ++i) { 5352 - const next = el.nextSibling; 5353 - if (SUPPORTS_MOVE_BEFORE) { 5354 - node2.moveBefore(el, beforeEl); 5355 - } else { 5356 - insertBefore(node2, el, beforeEl); 5357 - } 5358 - el = next; 5359 - } 5360 - } 5361 - #removeKey(node2, key, count) { 5362 - this.#removeFromChild(node2, getKeyedChild(node2, key), count); 5363 - } 5364 - #remove(node2, from2, count) { 5365 - this.#removeFromChild(node2, childAt(node2, from2), count); 5366 - } 5367 - #removeFromChild(parent, child, count) { 5368 - while (count-- > 0 && child !== null) { 5369 - const next = child.nextSibling; 5370 - const key = child[meta].key; 5371 - if (key) { 5372 - parent[meta].keyedChildren.delete(key); 5373 - } 5374 - for (const [_, { timeout }] of child[meta].debouncers ?? []) { 5375 - clearTimeout(timeout); 5376 - } 5377 - parent.removeChild(child); 5378 - child = next; 5379 - } 5380 - } 5381 - #replace(parent, from2, count, child) { 5382 - this.#remove(parent, from2, count); 5383 - const el = this.#createChild(parent, from2, child); 5384 - insertBefore(parent, el, childAt(parent, from2)); 5385 - } 5386 - #replaceText(node2, content) { 5387 - node2.data = content ?? ""; 5388 - } 5389 - #replaceInnerHtml(node2, inner_html) { 5390 - node2.innerHTML = inner_html ?? ""; 5391 - } 5392 - #update(node2, added, removed) { 5393 - iterate(removed, (attribute3) => { 5394 - const name = attribute3.name; 5395 - if (node2[meta].handlers.has(name)) { 5396 - node2.removeEventListener(name, handleEvent); 5397 - node2[meta].handlers.delete(name); 5398 - if (node2[meta].throttles.has(name)) { 5399 - node2[meta].throttles.delete(name); 5400 - } 5401 - if (node2[meta].debouncers.has(name)) { 5402 - clearTimeout(node2[meta].debouncers.get(name).timeout); 5403 - node2[meta].debouncers.delete(name); 5404 - } 5405 - } else { 5406 - node2.removeAttribute(name); 5407 - SYNCED_ATTRIBUTES[name]?.removed?.(node2, name); 5408 - } 5409 - }); 5410 - iterate(added, (attribute3) => { 5411 - this.#createAttribute(node2, attribute3); 5412 - }); 5413 - } 5414 - // CONSTRUCTORS -------------------------------------------------------------- 5415 - #createChild(parent, index4, vnode) { 5416 - switch (vnode.kind) { 5417 - case element_kind: { 5418 - const node2 = createChildElement(parent, index4, vnode); 5419 - this.#createAttributes(node2, vnode); 5420 - this.#insert(node2, vnode.children); 5421 - return node2; 5422 - } 5423 - case text_kind: { 5424 - return createChildText(parent, index4, vnode); 5425 - } 5426 - case fragment_kind: { 5427 - const node2 = createDocumentFragment(); 5428 - const head = createChildText(parent, index4, vnode); 5429 - appendChild(node2, head); 5430 - let childIndex = index4 + 1; 5431 - iterate(vnode.children, (child) => { 5432 - appendChild(node2, this.#createChild(parent, childIndex, child)); 5433 - childIndex += advance(child); 5434 - }); 5435 - return node2; 5436 - } 5437 - case unsafe_inner_html_kind: { 5438 - const node2 = createChildElement(parent, index4, vnode); 5439 - this.#createAttributes(node2, vnode); 5440 - this.#replaceInnerHtml(node2, vnode.inner_html); 5441 - return node2; 5442 - } 5443 - } 5444 - } 5445 - #createAttributes(node2, { key, attributes }) { 5446 - if (this.#exposeKeys && key) { 5447 - node2.setAttribute("data-lustre-key", key); 5448 - } 5449 - iterate(attributes, (attribute3) => this.#createAttribute(node2, attribute3)); 5450 - } 5451 - #createAttribute(node2, attribute3) { 5452 - const { debouncers, handlers, throttles } = node2[meta]; 5453 - const { 5454 - kind, 5455 - name, 5456 - value, 5457 - prevent_default: prevent, 5458 - stop_propagation: stop, 5459 - immediate: immediate2, 5460 - include, 5461 - debounce: debounceDelay, 5462 - throttle: throttleDelay 5463 - } = attribute3; 5464 - switch (kind) { 5465 - case attribute_kind: { 5466 - const valueOrDefault = value ?? ""; 5467 - if (name === "virtual:defaultValue") { 5468 - node2.defaultValue = valueOrDefault; 5469 - return; 5470 - } 5471 - if (valueOrDefault !== node2.getAttribute(name)) { 5472 - node2.setAttribute(name, valueOrDefault); 5473 - } 5474 - SYNCED_ATTRIBUTES[name]?.added?.(node2, value); 5475 - break; 5476 - } 5477 - case property_kind: 5478 - node2[name] = value; 5479 - break; 5480 - case event_kind: { 5481 - if (handlers.has(name)) { 5482 - node2.removeEventListener(name, handleEvent); 5483 - } 5484 - node2.addEventListener(name, handleEvent, { 5485 - passive: prevent.kind === never_kind 5486 - }); 5487 - if (throttleDelay > 0) { 5488 - const throttle = throttles.get(name) ?? {}; 5489 - throttle.delay = throttleDelay; 5490 - throttles.set(name, throttle); 5491 - } else { 5492 - throttles.delete(name); 5493 - } 5494 - if (debounceDelay > 0) { 5495 - const debounce = debouncers.get(name) ?? {}; 5496 - debounce.delay = debounceDelay; 5497 - debouncers.set(name, debounce); 5498 - } else { 5499 - clearTimeout(debouncers.get(name)?.timeout); 5500 - debouncers.delete(name); 5501 - } 5502 - handlers.set(name, (event4) => { 5503 - if (prevent.kind === always_kind) event4.preventDefault(); 5504 - if (stop.kind === always_kind) event4.stopPropagation(); 5505 - const type = event4.type; 5506 - const path = event4.currentTarget[meta].path; 5507 - const data = this.#useServerEvents ? createServerEvent(event4, include ?? []) : event4; 5508 - const throttle = throttles.get(type); 5509 - if (throttle) { 5510 - const now = Date.now(); 5511 - const last = throttle.last || 0; 5512 - if (now > last + throttle.delay) { 5513 - throttle.last = now; 5514 - throttle.lastEvent = event4; 5515 - this.#dispatch(data, path, type, immediate2); 5516 - } 5517 - } 5518 - const debounce = debouncers.get(type); 5519 - if (debounce) { 5520 - clearTimeout(debounce.timeout); 5521 - debounce.timeout = setTimeout(() => { 5522 - if (event4 === throttles.get(type)?.lastEvent) return; 5523 - this.#dispatch(data, path, type, immediate2); 5524 - }, debounce.delay); 5525 - } 5526 - if (!throttle && !debounce) { 5527 - this.#dispatch(data, path, type, immediate2); 5528 - } 5529 - }); 5530 - break; 5531 - } 5532 - } 5533 - } 5534 - }; 5535 - var iterate = (list4, callback) => { 5536 - if (Array.isArray(list4)) { 5537 - for (let i = 0; i < list4.length; i++) { 5538 - callback(list4[i]); 5539 - } 5540 - } else if (list4) { 5541 - for (list4; list4.tail; list4 = list4.tail) { 5542 - callback(list4.head); 5543 - } 5544 - } 5545 - }; 5546 - var appendChild = (node2, child) => node2.appendChild(child); 5547 - var insertBefore = (parent, node2, referenceNode) => parent.insertBefore(node2, referenceNode ?? null); 5548 - var createChildElement = (parent, index4, { key, tag, namespace }) => { 5549 - const node2 = document2().createElementNS(namespace || NAMESPACE_HTML, tag); 5550 - initialiseMetadata(parent, node2, index4, key); 5551 - return node2; 5552 - }; 5553 - var createChildText = (parent, index4, { key, content }) => { 5554 - const node2 = document2().createTextNode(content ?? ""); 5555 - initialiseMetadata(parent, node2, index4, key); 5556 - return node2; 5557 - }; 5558 - var createDocumentFragment = () => document2().createDocumentFragment(); 5559 - var childAt = (node2, at) => node2.childNodes[at | 0]; 5560 - var meta = Symbol("lustre"); 5561 - var initialiseMetadata = (parent, node2, index4 = 0, key = "") => { 5562 - const segment = `${key || index4}`; 5563 - switch (node2.nodeType) { 5564 - case ELEMENT_NODE: 5565 - case DOCUMENT_FRAGMENT_NODE: 5566 - node2[meta] = { 5567 - key, 5568 - path: segment, 5569 - keyedChildren: /* @__PURE__ */ new Map(), 5570 - handlers: /* @__PURE__ */ new Map(), 5571 - throttles: /* @__PURE__ */ new Map(), 5572 - debouncers: /* @__PURE__ */ new Map() 5573 - }; 5574 - break; 5575 - case TEXT_NODE: 5576 - node2[meta] = { key }; 5577 - break; 5578 - } 5579 - if (parent && parent[meta] && key) { 5580 - parent[meta].keyedChildren.set(key, new WeakRef(node2)); 5581 - } 5582 - if (parent && parent[meta] && parent[meta].path) { 5583 - node2[meta].path = `${parent[meta].path}${separator_element}${segment}`; 5584 - } 5585 - }; 5586 - var getKeyedChild = (node2, key) => node2[meta].keyedChildren.get(key).deref(); 5587 - var handleEvent = (event4) => { 5588 - const target = event4.currentTarget; 5589 - const handler = target[meta].handlers.get(event4.type); 5590 - if (event4.type === "submit") { 5591 - event4.detail ??= {}; 5592 - event4.detail.formData = [...new FormData(event4.target).entries()]; 5593 - } 5594 - handler(event4); 5595 - }; 5596 - var createServerEvent = (event4, include = []) => { 5597 - const data = {}; 5598 - if (event4.type === "input" || event4.type === "change") { 5599 - include.push("target.value"); 5600 - } 5601 - if (event4.type === "submit") { 5602 - include.push("detail.formData"); 5603 - } 5604 - for (const property4 of include) { 5605 - const path = property4.split("."); 5606 - for (let i = 0, input = event4, output = data; i < path.length; i++) { 5607 - if (i === path.length - 1) { 5608 - output[path[i]] = input[path[i]]; 5609 - break; 5610 - } 5611 - output = output[path[i]] ??= {}; 5612 - input = input[path[i]]; 5613 - } 5614 - } 5615 - return data; 5616 - }; 5617 - var syncedBooleanAttribute = (name) => { 5618 - return { 5619 - added(node2) { 5620 - node2[name] = true; 5621 - }, 5622 - removed(node2) { 5623 - node2[name] = false; 5624 - } 5625 - }; 5626 - }; 5627 - var syncedAttribute = (name) => { 5628 - return { 5629 - added(node2, value) { 5630 - node2[name] = value; 5631 - } 5632 - }; 5633 - }; 5634 - var SYNCED_ATTRIBUTES = { 5635 - checked: syncedBooleanAttribute("checked"), 5636 - selected: syncedBooleanAttribute("selected"), 5637 - value: syncedAttribute("value"), 5638 - autofocus: { 5639 - added(node2) { 5640 - queueMicrotask(() => node2.focus?.()); 5641 - } 5642 - }, 5643 - autoplay: { 5644 - added(node2) { 5645 - try { 5646 - node2.play?.(); 5647 - } catch (e) { 5648 - console.error(e); 5649 - } 5650 - } 5651 - } 5652 - }; 5653 - 5654 - // build/dev/javascript/lustre/lustre/vdom/virtualise.ffi.mjs 5655 - var virtualise = (root3) => { 5656 - const vdom = virtualiseNode(null, root3, ""); 5657 - if (vdom === null || vdom.children instanceof Empty) { 5658 - const empty5 = emptyTextNode(root3); 5659 - root3.appendChild(empty5); 5660 - return none2(); 5661 - } else if (vdom.children instanceof NonEmpty && vdom.children.tail instanceof Empty) { 5662 - return vdom.children.head; 5663 - } else { 5664 - const head = emptyTextNode(root3); 5665 - root3.insertBefore(head, root3.firstChild); 5666 - return fragment2(vdom.children); 5667 - } 5668 - }; 5669 - var emptyTextNode = (parent) => { 5670 - const node2 = document2().createTextNode(""); 5671 - initialiseMetadata(parent, node2); 5672 - return node2; 5673 - }; 5674 - var virtualiseNode = (parent, node2, index4) => { 5675 - switch (node2.nodeType) { 5676 - case ELEMENT_NODE: { 5677 - const key = node2.getAttribute("data-lustre-key"); 5678 - initialiseMetadata(parent, node2, index4, key); 5679 - if (key) { 5680 - node2.removeAttribute("data-lustre-key"); 5681 - } 5682 - const tag = node2.localName; 5683 - const namespace = node2.namespaceURI; 5684 - const isHtmlElement = !namespace || namespace === NAMESPACE_HTML; 5685 - if (isHtmlElement && INPUT_ELEMENTS.includes(tag)) { 5686 - virtualiseInputEvents(tag, node2); 5687 - } 5688 - const attributes = virtualiseAttributes(node2); 5689 - const children = virtualiseChildNodes(node2); 5690 - const vnode = isHtmlElement ? element2(tag, attributes, children) : namespaced(namespace, tag, attributes, children); 5691 - return key ? to_keyed(key, vnode) : vnode; 5692 - } 5693 - case TEXT_NODE: 5694 - initialiseMetadata(parent, node2, index4); 5695 - return node2.data ? text2(node2.data) : null; 5696 - case DOCUMENT_FRAGMENT_NODE: 5697 - initialiseMetadata(parent, node2, index4); 5698 - return node2.childNodes.length > 0 ? fragment2(virtualiseChildNodes(node2)) : null; 5699 - default: 5700 - return null; 5701 - } 5702 - }; 5703 - var INPUT_ELEMENTS = ["input", "select", "textarea"]; 5704 - var virtualiseInputEvents = (tag, node2) => { 5705 - const value = node2.value; 5706 - const checked = node2.checked; 5707 - if (tag === "input" && node2.type === "checkbox" && !checked) return; 5708 - if (tag === "input" && node2.type === "radio" && !checked) return; 5709 - if (node2.type !== "checkbox" && node2.type !== "radio" && !value) return; 5710 - queueMicrotask(() => { 5711 - node2.value = value; 5712 - node2.checked = checked; 5713 - node2.dispatchEvent(new Event("input", { bubbles: true })); 5714 - node2.dispatchEvent(new Event("change", { bubbles: true })); 5715 - if (document2().activeElement !== node2) { 5716 - node2.dispatchEvent(new Event("blur", { bubbles: true })); 5717 - } 5718 - }); 5719 - }; 5720 - var virtualiseChildNodes = (node2) => { 5721 - let children = null; 5722 - let index4 = 0; 5723 - let child = node2.firstChild; 5724 - let ptr = null; 5725 - while (child) { 5726 - const vnode = virtualiseNode(node2, child, index4); 5727 - const next = child.nextSibling; 5728 - if (vnode) { 5729 - const list_node = new NonEmpty(vnode, null); 5730 - if (ptr) { 5731 - ptr = ptr.tail = list_node; 5732 - } else { 5733 - ptr = children = list_node; 5734 - } 5735 - index4 += 1; 5736 - } else { 5737 - node2.removeChild(child); 5738 - } 5739 - child = next; 5740 - } 5741 - if (!ptr) return empty_list; 5742 - ptr.tail = empty_list; 5743 - return children; 5744 - }; 5745 - var virtualiseAttributes = (node2) => { 5746 - let index4 = node2.attributes.length; 5747 - let attributes = empty_list; 5748 - while (index4-- > 0) { 5749 - attributes = new NonEmpty( 5750 - virtualiseAttribute(node2.attributes[index4]), 5751 - attributes 5752 - ); 5753 - } 5754 - return attributes; 5755 - }; 5756 - var virtualiseAttribute = (attr) => { 5757 - const name = attr.localName; 5758 - const value = attr.value; 5759 - return attribute2(name, value); 5760 - }; 5761 - 5762 - // build/dev/javascript/lustre/lustre/runtime/client/runtime.ffi.mjs 5763 - var is_browser = () => !!document2(); 5764 - var Runtime = class { 5765 - constructor(root3, [model, effects], view2, update5) { 5766 - this.root = root3; 5767 - this.#model = model; 5768 - this.#view = view2; 5769 - this.#update = update5; 5770 - this.#reconciler = new Reconciler(this.root, (event4, path, name) => { 5771 - const [events, result] = handle(this.#events, path, name, event4); 5772 - this.#events = events; 5773 - if (result.isOk()) { 5774 - const handler = result[0]; 5775 - if (handler.stop_propagation) event4.stopPropagation(); 5776 - if (handler.prevent_default) event4.preventDefault(); 5777 - this.dispatch(handler.message, false); 5778 - } 5779 - }); 5780 - this.#vdom = virtualise(this.root); 5781 - this.#events = new$5(); 5782 - this.#shouldFlush = true; 5783 - this.#tick(effects); 5784 - } 5785 - // PUBLIC API ---------------------------------------------------------------- 5786 - root = null; 5787 - set offset(offset) { 5788 - this.#reconciler.offset = offset; 5789 - } 5790 - dispatch(msg, immediate2 = false) { 5791 - this.#shouldFlush ||= immediate2; 5792 - if (this.#shouldQueue) { 5793 - this.#queue.push(msg); 5794 - } else { 5795 - const [model, effects] = this.#update(this.#model, msg); 5796 - this.#model = model; 5797 - this.#tick(effects); 5798 - } 5799 - } 5800 - emit(event4, data) { 5801 - const target = this.root.host ?? this.root; 5802 - target.dispatchEvent( 5803 - new CustomEvent(event4, { 5804 - detail: data, 5805 - bubbles: true, 5806 - composed: true 5807 - }) 5808 - ); 5809 - } 5810 - // PRIVATE API --------------------------------------------------------------- 5811 - #model; 5812 - #view; 5813 - #update; 5814 - #vdom; 5815 - #events; 5816 - #reconciler; 5817 - #shouldQueue = false; 5818 - #queue = []; 5819 - #beforePaint = empty_list; 5820 - #afterPaint = empty_list; 5821 - #renderTimer = null; 5822 - #shouldFlush = false; 5823 - #actions = { 5824 - dispatch: (msg, immediate2) => this.dispatch(msg, immediate2), 5825 - emit: (event4, data) => this.emit(event4, data), 5826 - select: () => { 5827 - }, 5828 - root: () => this.root 5829 - }; 5830 - // A `#tick` is where we process effects and trigger any synchronous updates. 5831 - // Once a tick has been processed a render will be scheduled if none is already. 5832 - // p0 5833 - #tick(effects) { 5834 - this.#shouldQueue = true; 5835 - while (true) { 5836 - for (let list4 = effects.synchronous; list4.tail; list4 = list4.tail) { 5837 - list4.head(this.#actions); 5838 - } 5839 - this.#beforePaint = listAppend(this.#beforePaint, effects.before_paint); 5840 - this.#afterPaint = listAppend(this.#afterPaint, effects.after_paint); 5841 - if (!this.#queue.length) break; 5842 - [this.#model, effects] = this.#update(this.#model, this.#queue.shift()); 5843 - } 5844 - this.#shouldQueue = false; 5845 - if (this.#shouldFlush) { 5846 - cancelAnimationFrame(this.#renderTimer); 5847 - this.#render(); 5848 - } else if (!this.#renderTimer) { 5849 - this.#renderTimer = requestAnimationFrame(() => { 5850 - this.#render(); 5851 - }); 5852 - } 5853 - } 5854 - #render() { 5855 - this.#shouldFlush = false; 5856 - this.#renderTimer = null; 5857 - const next = this.#view(this.#model); 5858 - const { patch, events } = diff(this.#events, this.#vdom, next); 5859 - this.#events = events; 5860 - this.#vdom = next; 5861 - this.#reconciler.push(patch); 5862 - if (this.#beforePaint instanceof NonEmpty) { 5863 - const effects = makeEffect(this.#beforePaint); 5864 - this.#beforePaint = empty_list; 5865 - queueMicrotask(() => { 5866 - this.#shouldFlush = true; 5867 - this.#tick(effects); 5868 - }); 5869 - } 5870 - if (this.#afterPaint instanceof NonEmpty) { 5871 - const effects = makeEffect(this.#afterPaint); 5872 - this.#afterPaint = empty_list; 5873 - requestAnimationFrame(() => { 5874 - this.#shouldFlush = true; 5875 - this.#tick(effects); 5876 - }); 5877 - } 5878 - } 5879 - }; 5880 - function makeEffect(synchronous) { 5881 - return { 5882 - synchronous, 5883 - after_paint: empty_list, 5884 - before_paint: empty_list 5885 - }; 5886 - } 5887 - function listAppend(a, b) { 5888 - if (a instanceof Empty) { 5889 - return b; 5890 - } else if (b instanceof Empty) { 5891 - return a; 5892 - } else { 5893 - return append(a, b); 5894 - } 5895 - } 5896 - 5897 - // build/dev/javascript/lustre/lustre/runtime/server/runtime.mjs 5898 - var EffectDispatchedMessage = class extends CustomType { 5899 - constructor(message) { 5900 - super(); 5901 - this.message = message; 5902 - } 5903 - }; 5904 - var EffectEmitEvent = class extends CustomType { 5905 - constructor(name, data) { 5906 - super(); 5907 - this.name = name; 5908 - this.data = data; 5909 - } 5910 - }; 5911 - var SystemRequestedShutdown = class extends CustomType { 5912 - }; 5913 - 5914 - // build/dev/javascript/lustre/lustre/component.mjs 5915 - var Config2 = class extends CustomType { 5916 - constructor(open_shadow_root, adopt_styles, attributes, properties, is_form_associated, on_form_autofill, on_form_reset, on_form_restore) { 5917 - super(); 5918 - this.open_shadow_root = open_shadow_root; 5919 - this.adopt_styles = adopt_styles; 5920 - this.attributes = attributes; 5921 - this.properties = properties; 5922 - this.is_form_associated = is_form_associated; 5923 - this.on_form_autofill = on_form_autofill; 5924 - this.on_form_reset = on_form_reset; 5925 - this.on_form_restore = on_form_restore; 5926 - } 5927 - }; 5928 - function new$8(options) { 5929 - let init2 = new Config2( 5930 - false, 5931 - true, 5932 - empty_dict(), 5933 - empty_dict(), 5934 - false, 5935 - option_none, 5936 - option_none, 5937 - option_none 5938 - ); 5939 - return fold( 5940 - options, 5941 - init2, 5942 - (config, option) => { 5943 - return option.apply(config); 5944 - } 5945 - ); 5946 - } 5947 - 5948 - // build/dev/javascript/lustre/lustre/runtime/client/spa.ffi.mjs 5949 - var Spa = class _Spa { 5950 - static start({ init: init2, update: update5, view: view2 }, selector, flags) { 5951 - if (!is_browser()) return new Error(new NotABrowser()); 5952 - const root3 = selector instanceof HTMLElement ? selector : document2().querySelector(selector); 5953 - if (!root3) return new Error(new ElementNotFound(selector)); 5954 - return new Ok(new _Spa(root3, init2(flags), update5, view2)); 5955 - } 5956 - #runtime; 5957 - constructor(root3, [init2, effects], update5, view2) { 5958 - this.#runtime = new Runtime(root3, [init2, effects], view2, update5); 5959 - } 5960 - send(message) { 5961 - switch (message.constructor) { 5962 - case EffectDispatchedMessage: { 5963 - this.dispatch(message.message, false); 5964 - break; 5965 - } 5966 - case EffectEmitEvent: { 5967 - this.emit(message.name, message.data); 5968 - break; 5969 - } 5970 - case SystemRequestedShutdown: 5971 - break; 5972 - } 5973 - } 5974 - dispatch(msg, immediate2) { 5975 - this.#runtime.dispatch(msg, immediate2); 5976 - } 5977 - emit(event4, data) { 5978 - this.#runtime.emit(event4, data); 5979 - } 5980 - }; 5981 - var start = Spa.start; 5982 - 5983 - // build/dev/javascript/lustre/lustre.mjs 5984 - var App = class extends CustomType { 5985 - constructor(init2, update5, view2, config) { 5986 - super(); 5987 - this.init = init2; 5988 - this.update = update5; 5989 - this.view = view2; 5990 - this.config = config; 5991 - } 5992 - }; 5993 - var ElementNotFound = class extends CustomType { 5994 - constructor(selector) { 5995 - super(); 5996 - this.selector = selector; 5997 - } 5998 - }; 5999 - var NotABrowser = class extends CustomType { 6000 - }; 6001 - function application(init2, update5, view2) { 6002 - return new App(init2, update5, view2, new$8(empty_list)); 6003 - } 6004 - function start3(app, selector, start_args) { 6005 - return guard( 6006 - !is_browser(), 6007 - new Error(new NotABrowser()), 6008 - () => { 6009 - return start(app, selector, start_args); 6010 - } 6011 - ); 6012 - } 6013 - 6014 - // build/dev/javascript/gleam_stdlib/gleam/pair.mjs 6015 - function map_second(pair2, fun) { 6016 - let a = pair2[0]; 6017 - let b = pair2[1]; 6018 - return [a, fun(b)]; 6019 - } 6020 - 6021 - // build/dev/javascript/lustre/lustre/event.mjs 6022 - function is_immediate_event(name) { 6023 - if (name === "input") { 6024 - return true; 6025 - } else if (name === "change") { 6026 - return true; 6027 - } else if (name === "focus") { 6028 - return true; 6029 - } else if (name === "focusin") { 6030 - return true; 6031 - } else if (name === "focusout") { 6032 - return true; 6033 - } else if (name === "blur") { 6034 - return true; 6035 - } else if (name === "select") { 6036 - return true; 6037 - } else { 6038 - return false; 6039 - } 6040 - } 6041 - function on(name, handler) { 6042 - return event( 6043 - name, 6044 - map2(handler, (msg) => { 6045 - return new Handler(false, false, msg); 6046 - }), 6047 - empty_list, 6048 - never, 6049 - never, 6050 - is_immediate_event(name), 6051 - 0, 6052 - 0 6053 - ); 6054 - } 6055 - function on_click(msg) { 6056 - return on("click", success(msg)); 6057 - } 6058 - function on_input(msg) { 6059 - return on( 6060 - "input", 6061 - subfield( 6062 - toList(["target", "value"]), 6063 - string2, 6064 - (value) => { 6065 - return success(msg(value)); 6066 - } 6067 - ) 6068 - ); 6069 - } 6070 - 6071 - // build/dev/javascript/sketch/sketch.ffi.mjs 6072 - var id = 0; 6073 - function uniqueId() { 6074 - return id++; 6075 - } 6076 - 6077 - // build/dev/javascript/murmur3a/murmur3a_ffi.mjs 6078 - var signed_multiply = Math.imul; 6079 - 6080 - // build/dev/javascript/murmur3a/murmur3a.mjs 6081 - var Hash = class extends CustomType { 6082 - constructor(seed, shift, state) { 6083 - super(); 6084 - this.seed = seed; 6085 - this.shift = shift; 6086 - this.state = state; 6087 - } 6088 - }; 6089 - function int_digest(hash) { 6090 - return hash.state; 6091 - } 6092 - function bit_array_digest(hash) { 6093 - return toBitArray([sizedInt(int_digest(hash), 32, true)]); 6094 - } 6095 - function hex_digest(hash) { 6096 - let _pipe = hash; 6097 - let _pipe$1 = bit_array_digest(_pipe); 6098 - return base16_encode(_pipe$1); 6099 - } 6100 - var c1 = 3432918353; 6101 - var c2 = 461845907; 6102 - var m1 = 4294967295; 6103 - function rotate_left(n, shift) { 6104 - let n$1 = bitwise_and(n, m1); 6105 - let _pipe = bitwise_shift_left(n$1, shift); 6106 - let _pipe$1 = bitwise_and(_pipe, m1); 6107 - return bitwise_or(_pipe$1, bitwise_shift_right(n$1, 32 - shift)); 6108 - } 6109 - function mix(state, seed) { 6110 - let _pipe = state; 6111 - let _pipe$1 = signed_multiply(_pipe, c1); 6112 - let _pipe$2 = rotate_left(_pipe$1, 15); 6113 - let _pipe$3 = signed_multiply(_pipe$2, c2); 6114 - let _pipe$4 = bitwise_exclusive_or(_pipe$3, seed); 6115 - let _pipe$5 = rotate_left(_pipe$4, 13); 6116 - let _pipe$6 = signed_multiply(_pipe$5, 5); 6117 - return add(_pipe$6, 3864292196); 6118 - } 6119 - function hash_chunk(hash, chunk) { 6120 - let _block; 6121 - let _pipe = chunk; 6122 - let _pipe$1 = bitwise_and(_pipe, 255); 6123 - let _pipe$2 = bitwise_shift_left(_pipe$1, hash.shift); 6124 - _block = bitwise_or(_pipe$2, hash.state); 6125 - let state = _block; 6126 - let $ = hash.shift; 6127 - if ($ === 24) { 6128 - return new Hash(mix(state, hash.seed), 0, 0); 6129 - } else { 6130 - let _record = hash; 6131 - return new Hash(_record.seed, hash.shift + 8, state); 6132 - } 6133 - } 6134 - function finalize(hash, length4) { 6135 - let _block; 6136 - let _block$1; 6137 - let $ = hash.state; 6138 - if ($ === 0) { 6139 - _block$1 = hash.seed; 6140 - } else { 6141 - let _pipe2 = hash.state; 6142 - let _pipe$12 = signed_multiply(_pipe2, c1); 6143 - let _pipe$22 = rotate_left(_pipe$12, 15); 6144 - let _pipe$32 = signed_multiply(_pipe$22, c2); 6145 - let _pipe$42 = bitwise_exclusive_or(_pipe$32, hash.seed); 6146 - _block$1 = bitwise_and(_pipe$42, m1); 6147 - } 6148 - let _pipe = _block$1; 6149 - _block = bitwise_exclusive_or(_pipe, length4); 6150 - let state = _block; 6151 - let _block$2; 6152 - let _pipe$1 = bitwise_shift_right(state, 16); 6153 - let _pipe$2 = bitwise_exclusive_or(_pipe$1, state); 6154 - let _pipe$3 = signed_multiply(_pipe$2, 2246822507); 6155 - _block$2 = bitwise_and(_pipe$3, m1); 6156 - let state$1 = _block$2; 6157 - let _block$3; 6158 - let _pipe$4 = bitwise_shift_right(state$1, 13); 6159 - let _pipe$5 = bitwise_exclusive_or(_pipe$4, state$1); 6160 - _block$3 = signed_multiply(_pipe$5, 3266489909); 6161 - let state$2 = _block$3; 6162 - let _record = hash; 6163 - return new Hash( 6164 - _record.seed, 6165 - _record.shift, 6166 - (() => { 6167 - let _pipe$6 = bitwise_shift_right(state$2, 16); 6168 - let _pipe$7 = bitwise_and(_pipe$6, 65535); 6169 - return bitwise_exclusive_or(_pipe$7, state$2); 6170 - })() 6171 - ); 6172 - } 6173 - function hash_ints(key, seed) { 6174 - let _pipe = key; 6175 - let _pipe$1 = fold(_pipe, new Hash(seed, 0, 0), hash_chunk); 6176 - return finalize(_pipe$1, length(key)); 6177 - } 6178 - function hash_string(key, seed) { 6179 - let _pipe = key; 6180 - let _pipe$1 = to_utf_codepoints(_pipe); 6181 - let _pipe$2 = map(_pipe$1, utf_codepoint_to_int); 6182 - return hash_ints(_pipe$2, seed); 6183 - } 6184 - 6185 - // build/dev/javascript/sketch/sketch/internals/string.mjs 6186 - function indent(indent2) { 6187 - return repeat(" ", indent2); 6188 - } 6189 - function wrap_class(id2, properties, indentation, pseudo) { 6190 - let base_indent = indent(indentation); 6191 - let pseudo_ = unwrap(pseudo, ""); 6192 - let _pipe = prepend(base_indent + id2 + pseudo_ + " {", properties); 6193 - let _pipe$1 = join(_pipe, "\n"); 6194 - return append2(_pipe$1, "\n" + base_indent + "}"); 6195 - } 6196 - 6197 - // build/dev/javascript/sketch/sketch/internals/cache/cache.mjs 6198 - var FILEPATH = "src/sketch/internals/cache/cache.gleam"; 6199 - var Class = class extends CustomType { 6200 - constructor(as_string, content, name) { 6201 - super(); 6202 - this.as_string = as_string; 6203 - this.content = content; 6204 - this.name = name; 6205 - } 6206 - }; 6207 - var Definitions = class extends CustomType { 6208 - constructor(medias, selectors, class$5) { 6209 - super(); 6210 - this.medias = medias; 6211 - this.selectors = selectors; 6212 - this.class = class$5; 6213 - } 6214 - }; 6215 - var ComputedClass = class extends CustomType { 6216 - constructor(id2, name, class_name4, definitions) { 6217 - super(); 6218 - this.id = id2; 6219 - this.name = name; 6220 - this.class_name = class_name4; 6221 - this.definitions = definitions; 6222 - } 6223 - }; 6224 - var Cache = class extends CustomType { 6225 - constructor(cache, at_rules) { 6226 - super(); 6227 - this.cache = cache; 6228 - this.at_rules = at_rules; 6229 - } 6230 - }; 6231 - var Global = class extends CustomType { 6232 - constructor(class$5) { 6233 - super(); 6234 - this.class = class$5; 6235 - } 6236 - }; 6237 - var ClassName = class extends CustomType { 6238 - constructor(class$5) { 6239 - super(); 6240 - this.class = class$5; 6241 - } 6242 - }; 6243 - var Media = class extends CustomType { 6244 - constructor(query, styles) { 6245 - super(); 6246 - this.query = query; 6247 - this.styles = styles; 6248 - } 6249 - }; 6250 - var Selector = class extends CustomType { 6251 - constructor(selector, styles) { 6252 - super(); 6253 - this.selector = selector; 6254 - this.styles = styles; 6255 - } 6256 - }; 6257 - var Combinator = class extends CustomType { 6258 - constructor(selector, class$5, styles) { 6259 - super(); 6260 - this.selector = selector; 6261 - this.class = class$5; 6262 - this.styles = styles; 6263 - } 6264 - }; 6265 - var Property2 = class extends CustomType { 6266 - constructor(key, value, important) { 6267 - super(); 6268 - this.key = key; 6269 - this.value = value; 6270 - this.important = important; 6271 - } 6272 - }; 6273 - var Properties = class extends CustomType { 6274 - constructor(properties, medias, selectors, indentation) { 6275 - super(); 6276 - this.properties = properties; 6277 - this.medias = medias; 6278 - this.selectors = selectors; 6279 - this.indentation = indentation; 6280 - } 6281 - }; 6282 - var MediaProperty = class extends CustomType { 6283 - constructor(query, properties, selectors) { 6284 - super(); 6285 - this.query = query; 6286 - this.properties = properties; 6287 - this.selectors = selectors; 6288 - } 6289 - }; 6290 - var SelectorProperty = class extends CustomType { 6291 - constructor(selector, properties) { 6292 - super(); 6293 - this.selector = selector; 6294 - this.properties = properties; 6295 - } 6296 - }; 6297 - function new$10() { 6298 - return new Cache(new_map(), new_map()); 6299 - } 6300 - function class$2(content) { 6301 - let as_string = inspect2(content); 6302 - return new Class(as_string, content, new None()); 6303 - } 6304 - function named(name, content) { 6305 - let as_string = inspect2(content); 6306 - return new Class(as_string, content, new Some(name)); 6307 - } 6308 - function empty_computed() { 6309 - let definitions = new Definitions(toList([]), toList([]), ""); 6310 - return new ComputedClass("", "", "", definitions); 6311 - } 6312 - function compute_hash(to_hash) { 6313 - let _pipe = hash_string(to_hash, 1); 6314 - return hex_digest(_pipe); 6315 - } 6316 - function wrap_selectors(id2, indentation, selectors) { 6317 - return map( 6318 - selectors, 6319 - (selector) => { 6320 - let selector$1 = selector.selector; 6321 - let properties = selector.properties; 6322 - return wrap_class( 6323 - id2, 6324 - properties, 6325 - indentation, 6326 - new Some(selector$1) 6327 - ); 6328 - } 6329 - ); 6330 - } 6331 - function compute_classes(id2, name, properties) { 6332 - let class_name$1 = lazy_unwrap(name, () => { 6333 - return "css-" + id2; 6334 - }); 6335 - let name$1 = lazy_unwrap(name, () => { 6336 - return ".css-" + id2; 6337 - }); 6338 - let properties$1 = properties.properties; 6339 - let medias = properties.medias; 6340 - let selectors = properties.selectors; 6341 - let class$1 = wrap_class(name$1, properties$1, 0, new None()); 6342 - let selectors$1 = wrap_selectors(name$1, 0, selectors); 6343 - return new ComputedClass( 6344 - id2, 6345 - name$1, 6346 - class_name$1, 6347 - new Definitions( 6348 - map( 6349 - medias, 6350 - (_use0) => { 6351 - let query = _use0.query; 6352 - let properties$2 = _use0.properties; 6353 - let selectors$2 = _use0.selectors; 6354 - let selectors$3 = wrap_selectors(name$1, 2, selectors$2); 6355 - let _pipe = toList([ 6356 - query + " {", 6357 - wrap_class(name$1, properties$2, 2, new None()) 6358 - ]); 6359 - let _pipe$1 = ((_capture) => { 6360 - return prepend2(toList([selectors$3, toList(["}"])]), _capture); 6361 - })(_pipe); 6362 - let _pipe$2 = flatten(_pipe$1); 6363 - return join(_pipe$2, "\n"); 6364 - } 6365 - ), 6366 - selectors$1, 6367 - class$1 6368 - ) 6369 - ); 6370 - } 6371 - function compute_property(indent2, key, value, important) { 6372 - let base_indent = indent(indent2); 6373 - let _block; 6374 - if (important) { 6375 - _block = " !important"; 6376 - } else { 6377 - _block = ""; 6378 - } 6379 - let important$1 = _block; 6380 - return base_indent + key + ": " + value + important$1 + ";"; 6381 - } 6382 - function handle_property(props, property4) { 6383 - if (!(property4 instanceof Property2)) { 6384 - throw makeError( 6385 - "let_assert", 6386 - FILEPATH, 6387 - "sketch/internals/cache/cache", 6388 - 243, 6389 - "handle_property", 6390 - "Pattern match failed, no pattern matched the value.", 6391 - { 6392 - value: property4, 6393 - start: 7133, 6394 - end: 7189, 6395 - pattern_start: 7144, 6396 - pattern_end: 7178 6397 - } 6398 - ); 6399 - } 6400 - let key = property4.key; 6401 - let value = property4.value; 6402 - let important = property4.important; 6403 - let css_property = compute_property(props.indentation, key, value, important); 6404 - let properties = prepend(css_property, props.properties); 6405 - let _record = props; 6406 - return new Properties( 6407 - properties, 6408 - _record.medias, 6409 - _record.selectors, 6410 - _record.indentation 6411 - ); 6412 - } 6413 - function merge_computed_properties(target, argument) { 6414 - return new Properties( 6415 - append(argument.properties, target.properties), 6416 - append(argument.medias, target.medias), 6417 - append(argument.selectors, target.selectors), 6418 - target.indentation 6419 - ); 6420 - } 6421 - function get_definitions(class$5) { 6422 - let $ = class$5.definitions; 6423 - let medias = $.medias; 6424 - let selectors = $.selectors; 6425 - let class$1 = $.class; 6426 - let _pipe = toList([toList([class$1]), selectors, medias]); 6427 - return flatten(_pipe); 6428 - } 6429 - function render_sheet(cache) { 6430 - let _pipe = values(cache.at_rules); 6431 - let _pipe$1 = append( 6432 - _pipe, 6433 - flat_map( 6434 - values(cache.cache), 6435 - (c) => { 6436 - return get_definitions(c[0]); 6437 - } 6438 - ) 6439 - ); 6440 - return join(_pipe$1, "\n\n"); 6441 - } 6442 - function handle_combinator(cache, props, combinator, existing_selector) { 6443 - if (!(combinator instanceof Combinator)) { 6444 - throw makeError( 6445 - "let_assert", 6446 - FILEPATH, 6447 - "sketch/internals/cache/cache", 6448 - 285, 6449 - "handle_combinator", 6450 - "Pattern match failed, no pattern matched the value.", 6451 - { 6452 - value: combinator, 6453 - start: 8551, 6454 - end: 8613, 6455 - pattern_start: 8562, 6456 - pattern_end: 8600 6457 - } 6458 - ); 6459 - } 6460 - let selector = combinator.selector; 6461 - let class$1 = combinator.class; 6462 - let styles = combinator.styles; 6463 - let indentation = props.indentation + 2; 6464 - let $ = computed_class(class$1, cache); 6465 - let cache$1 = $[0]; 6466 - let class$22 = $[1]; 6467 - let selector$1 = existing_selector + selector + class$22.name; 6468 - let $1 = compute_properties(cache$1, styles, indentation, selector$1); 6469 - let cache$2 = $1[0]; 6470 - let properties = $1[1]; 6471 - let selector$2 = new SelectorProperty(selector$1, properties.properties); 6472 - let selectors = prepend(selector$2, properties.selectors); 6473 - let selectors$1 = append(selectors, props.selectors); 6474 - return [ 6475 - cache$2, 6476 - (() => { 6477 - let _record = props; 6478 - return new Properties( 6479 - _record.properties, 6480 - _record.medias, 6481 - selectors$1, 6482 - _record.indentation 6483 - ); 6484 - })() 6485 - ]; 6486 - } 6487 - function compute_properties(cache, properties, indentation, existing_selector) { 6488 - let init2 = new Properties(toList([]), toList([]), toList([]), indentation); 6489 - return fold( 6490 - reverse(properties), 6491 - [cache, init2], 6492 - (_use0, p) => { 6493 - let cache$1 = _use0[0]; 6494 - let acc = _use0[1]; 6495 - if (p instanceof ClassName) { 6496 - let class$1 = p.class; 6497 - let $ = map_get(cache$1.cache, class$1.as_string); 6498 - if ($ instanceof Ok) { 6499 - let props = $[0][1]; 6500 - return [cache$1, merge_computed_properties(acc, props)]; 6501 - } else { 6502 - let _pipe = compute_properties( 6503 - cache$1, 6504 - class$1.content, 6505 - indentation, 6506 - "" 6507 - ); 6508 - return map_second( 6509 - _pipe, 6510 - (_capture) => { 6511 - return merge_computed_properties(acc, _capture); 6512 - } 6513 - ); 6514 - } 6515 - } else if (p instanceof Media) { 6516 - return handle_media(cache$1, acc, p); 6517 - } else if (p instanceof Selector) { 6518 - return handle_selector(cache$1, acc, p, existing_selector); 6519 - } else if (p instanceof Combinator) { 6520 - return handle_combinator(cache$1, acc, p, existing_selector); 6521 - } else if (p instanceof Property2) { 6522 - return [cache$1, handle_property(acc, p)]; 6523 - } else { 6524 - return [cache$1, acc]; 6525 - } 6526 - } 6527 - ); 6528 - } 6529 - function insert_class_in_cache(cache, class$5) { 6530 - let $ = compute_properties(cache, class$5.content, 2, ""); 6531 - let cache$1 = $[0]; 6532 - let properties = $[1]; 6533 - let hash = compute_hash(class$5.as_string); 6534 - let class_ = compute_classes(hash, class$5.name, properties); 6535 - let key = unwrap(class$5.name, class$5.as_string); 6536 - let cache_ = insert(cache$1.cache, key, [class_, properties]); 6537 - return [ 6538 - (() => { 6539 - let _record = cache$1; 6540 - return new Cache(cache_, _record.at_rules); 6541 - })(), 6542 - class_ 6543 - ]; 6544 - } 6545 - function computed_class(class$5, cache) { 6546 - return lazy_guard( 6547 - is_empty2(class$5.content), 6548 - () => { 6549 - return [cache, empty_computed()]; 6550 - }, 6551 - () => { 6552 - let existing_class = map_get(cache.cache, class$5.as_string); 6553 - if (existing_class instanceof Ok) { 6554 - let class$1 = existing_class[0][0]; 6555 - return [cache, class$1]; 6556 - } else { 6557 - return insert_class_in_cache(cache, class$5); 6558 - } 6559 - } 6560 - ); 6561 - } 6562 - function class_name(class$5, cache) { 6563 - return map_second( 6564 - computed_class(class$5, cache), 6565 - (class$6) => { 6566 - return class$6.class_name; 6567 - } 6568 - ); 6569 - } 6570 - function handle_media(cache, props, media) { 6571 - if (!(media instanceof Media)) { 6572 - throw makeError( 6573 - "let_assert", 6574 - FILEPATH, 6575 - "sketch/internals/cache/cache", 6576 - 254, 6577 - "handle_media", 6578 - "Pattern match failed, no pattern matched the value.", 6579 - { 6580 - value: media, 6581 - start: 7462, 6582 - end: 7503, 6583 - pattern_start: 7473, 6584 - pattern_end: 7495 6585 - } 6586 - ); 6587 - } 6588 - let query = media.query; 6589 - let styles = media.styles; 6590 - let indentation = props.indentation + 2; 6591 - let $ = compute_properties(cache, styles, indentation, ""); 6592 - let cache$1 = $[0]; 6593 - let properties = $[1]; 6594 - let properties$1 = properties.properties; 6595 - let selectors = properties.selectors; 6596 - let medias = prepend( 6597 - new MediaProperty(query, properties$1, selectors), 6598 - props.medias 6599 - ); 6600 - return [ 6601 - cache$1, 6602 - (() => { 6603 - let _record = props; 6604 - return new Properties( 6605 - _record.properties, 6606 - medias, 6607 - _record.selectors, 6608 - _record.indentation 6609 - ); 6610 - })() 6611 - ]; 6612 - } 6613 - function handle_selector(cache, props, selector, existing_selector) { 6614 - if (!(selector instanceof Selector)) { 6615 - throw makeError( 6616 - "let_assert", 6617 - FILEPATH, 6618 - "sketch/internals/cache/cache", 6619 - 268, 6620 - "handle_selector", 6621 - "Pattern match failed, no pattern matched the value.", 6622 - { 6623 - value: selector, 6624 - start: 7944, 6625 - end: 7994, 6626 - pattern_start: 7955, 6627 - pattern_end: 7983 6628 - } 6629 - ); 6630 - } 6631 - let selector$1 = selector.selector; 6632 - let styles = selector.styles; 6633 - let indentation = props.indentation + 2; 6634 - let selector$2 = existing_selector + selector$1; 6635 - let $ = compute_properties(cache, styles, indentation, selector$2); 6636 - let cache$1 = $[0]; 6637 - let properties = $[1]; 6638 - let selector$3 = new SelectorProperty(selector$2, properties.properties); 6639 - let selectors = prepend(selector$3, properties.selectors); 6640 - let selectors$1 = append(selectors, props.selectors); 6641 - return [ 6642 - cache$1, 6643 - (() => { 6644 - let _record = props; 6645 - return new Properties( 6646 - _record.properties, 6647 - _record.medias, 6648 - selectors$1, 6649 - _record.indentation 6650 - ); 6651 - })() 6652 - ]; 6653 - } 6654 - 6655 - // build/dev/javascript/sketch/sketch/css/length.mjs 6656 - var Px = class extends CustomType { 6657 - constructor($0) { 6658 - super(); 6659 - this[0] = $0; 6660 - } 6661 - }; 6662 - var Cm = class extends CustomType { 6663 - constructor($0) { 6664 - super(); 6665 - this[0] = $0; 6666 - } 6667 - }; 6668 - var Mm = class extends CustomType { 6669 - constructor($0) { 6670 - super(); 6671 - this[0] = $0; 6672 - } 6673 - }; 6674 - var Q = class extends CustomType { 6675 - constructor($0) { 6676 - super(); 6677 - this[0] = $0; 6678 - } 6679 - }; 6680 - var In = class extends CustomType { 6681 - constructor($0) { 6682 - super(); 6683 - this[0] = $0; 6684 - } 6685 - }; 6686 - var Pc = class extends CustomType { 6687 - constructor($0) { 6688 - super(); 6689 - this[0] = $0; 6690 - } 6691 - }; 6692 - var Pt = class extends CustomType { 6693 - constructor($0) { 6694 - super(); 6695 - this[0] = $0; 6696 - } 6697 - }; 6698 - var Vh = class extends CustomType { 6699 - constructor($0) { 6700 - super(); 6701 - this[0] = $0; 6702 - } 6703 - }; 6704 - var Vw = class extends CustomType { 6705 - constructor($0) { 6706 - super(); 6707 - this[0] = $0; 6708 - } 6709 - }; 6710 - var Em = class extends CustomType { 6711 - constructor($0) { 6712 - super(); 6713 - this[0] = $0; 6714 - } 6715 - }; 6716 - var Rem = class extends CustomType { 6717 - constructor($0) { 6718 - super(); 6719 - this[0] = $0; 6720 - } 6721 - }; 6722 - var Lh = class extends CustomType { 6723 - constructor($0) { 6724 - super(); 6725 - this[0] = $0; 6726 - } 6727 - }; 6728 - var Rlh = class extends CustomType { 6729 - constructor($0) { 6730 - super(); 6731 - this[0] = $0; 6732 - } 6733 - }; 6734 - var Ch = class extends CustomType { 6735 - constructor($0) { 6736 - super(); 6737 - this[0] = $0; 6738 - } 6739 - }; 6740 - var Pct = class extends CustomType { 6741 - constructor($0) { 6742 - super(); 6743 - this[0] = $0; 6744 - } 6745 - }; 6746 - var Cap = class extends CustomType { 6747 - constructor($0) { 6748 - super(); 6749 - this[0] = $0; 6750 - } 6751 - }; 6752 - var Ex = class extends CustomType { 6753 - constructor($0) { 6754 - super(); 6755 - this[0] = $0; 6756 - } 6757 - }; 6758 - var Ic = class extends CustomType { 6759 - constructor($0) { 6760 - super(); 6761 - this[0] = $0; 6762 - } 6763 - }; 6764 - var Rcap = class extends CustomType { 6765 - constructor($0) { 6766 - super(); 6767 - this[0] = $0; 6768 - } 6769 - }; 6770 - var Rch = class extends CustomType { 6771 - constructor($0) { 6772 - super(); 6773 - this[0] = $0; 6774 - } 6775 - }; 6776 - var Rex = class extends CustomType { 6777 - constructor($0) { 6778 - super(); 6779 - this[0] = $0; 6780 - } 6781 - }; 6782 - var Ric = class extends CustomType { 6783 - constructor($0) { 6784 - super(); 6785 - this[0] = $0; 6786 - } 6787 - }; 6788 - var Vmax = class extends CustomType { 6789 - constructor($0) { 6790 - super(); 6791 - this[0] = $0; 6792 - } 6793 - }; 6794 - var Vmin = class extends CustomType { 6795 - constructor($0) { 6796 - super(); 6797 - this[0] = $0; 6798 - } 6799 - }; 6800 - var Vb = class extends CustomType { 6801 - constructor($0) { 6802 - super(); 6803 - this[0] = $0; 6804 - } 6805 - }; 6806 - var Vi = class extends CustomType { 6807 - constructor($0) { 6808 - super(); 6809 - this[0] = $0; 6810 - } 6811 - }; 6812 - var Cqw = class extends CustomType { 6813 - constructor($0) { 6814 - super(); 6815 - this[0] = $0; 6816 - } 6817 - }; 6818 - var Cqh = class extends CustomType { 6819 - constructor($0) { 6820 - super(); 6821 - this[0] = $0; 6822 - } 6823 - }; 6824 - var Cqi = class extends CustomType { 6825 - constructor($0) { 6826 - super(); 6827 - this[0] = $0; 6828 - } 6829 - }; 6830 - var Cqb = class extends CustomType { 6831 - constructor($0) { 6832 - super(); 6833 - this[0] = $0; 6834 - } 6835 - }; 6836 - var Cqmin = class extends CustomType { 6837 - constructor($0) { 6838 - super(); 6839 - this[0] = $0; 6840 - } 6841 - }; 6842 - function px(value) { 6843 - return new Px(identity(value)); 6844 - } 6845 - function percent(value) { 6846 - return new Pct(identity(value)); 6847 - } 6848 - function vw(value) { 6849 - return new Vw(identity(value)); 6850 - } 6851 - function em(value) { 6852 - return new Em(value); 6853 - } 6854 - function to_string4(size3) { 6855 - if (size3 instanceof Px) { 6856 - let value = size3[0]; 6857 - return append2(float_to_string(value), "px"); 6858 - } else if (size3 instanceof Cm) { 6859 - let value = size3[0]; 6860 - return append2(float_to_string(value), "cm"); 6861 - } else if (size3 instanceof Mm) { 6862 - let value = size3[0]; 6863 - return append2(float_to_string(value), "mm"); 6864 - } else if (size3 instanceof Q) { 6865 - let value = size3[0]; 6866 - return append2(float_to_string(value), "q"); 6867 - } else if (size3 instanceof In) { 6868 - let value = size3[0]; 6869 - return append2(float_to_string(value), "in"); 6870 - } else if (size3 instanceof Pc) { 6871 - let value = size3[0]; 6872 - return append2(float_to_string(value), "pc"); 6873 - } else if (size3 instanceof Pt) { 6874 - let value = size3[0]; 6875 - return append2(float_to_string(value), "pt"); 6876 - } else if (size3 instanceof Vh) { 6877 - let value = size3[0]; 6878 - return append2(float_to_string(value), "vh"); 6879 - } else if (size3 instanceof Vw) { 6880 - let value = size3[0]; 6881 - return append2(float_to_string(value), "vw"); 6882 - } else if (size3 instanceof Em) { 6883 - let value = size3[0]; 6884 - return append2(float_to_string(value), "em"); 6885 - } else if (size3 instanceof Rem) { 6886 - let value = size3[0]; 6887 - return append2(float_to_string(value), "rem"); 6888 - } else if (size3 instanceof Lh) { 6889 - let value = size3[0]; 6890 - return append2(float_to_string(value), "lh"); 6891 - } else if (size3 instanceof Rlh) { 6892 - let value = size3[0]; 6893 - return append2(float_to_string(value), "rlh"); 6894 - } else if (size3 instanceof Ch) { 6895 - let value = size3[0]; 6896 - return append2(float_to_string(value), "ch"); 6897 - } else if (size3 instanceof Pct) { 6898 - let value = size3[0]; 6899 - return append2(float_to_string(value), "%"); 6900 - } else if (size3 instanceof Cap) { 6901 - let value = size3[0]; 6902 - return append2(float_to_string(value), "cap"); 6903 - } else if (size3 instanceof Ex) { 6904 - let value = size3[0]; 6905 - return append2(float_to_string(value), "ex"); 6906 - } else if (size3 instanceof Ic) { 6907 - let value = size3[0]; 6908 - return append2(float_to_string(value), "ic"); 6909 - } else if (size3 instanceof Rcap) { 6910 - let value = size3[0]; 6911 - return append2(float_to_string(value), "rcap"); 6912 - } else if (size3 instanceof Rch) { 6913 - let value = size3[0]; 6914 - return append2(float_to_string(value), "rch"); 6915 - } else if (size3 instanceof Rex) { 6916 - let value = size3[0]; 6917 - return append2(float_to_string(value), "rex"); 6918 - } else if (size3 instanceof Ric) { 6919 - let value = size3[0]; 6920 - return append2(float_to_string(value), "ric"); 6921 - } else if (size3 instanceof Vmax) { 6922 - let value = size3[0]; 6923 - return append2(float_to_string(value), "vmax"); 6924 - } else if (size3 instanceof Vmin) { 6925 - let value = size3[0]; 6926 - return append2(float_to_string(value), "vmin"); 6927 - } else if (size3 instanceof Vb) { 6928 - let value = size3[0]; 6929 - return append2(float_to_string(value), "vb"); 6930 - } else if (size3 instanceof Vi) { 6931 - let value = size3[0]; 6932 - return append2(float_to_string(value), "vi"); 6933 - } else if (size3 instanceof Cqw) { 6934 - let value = size3[0]; 6935 - return append2(float_to_string(value), "cqw"); 6936 - } else if (size3 instanceof Cqh) { 6937 - let value = size3[0]; 6938 - return append2(float_to_string(value), "cqh"); 6939 - } else if (size3 instanceof Cqi) { 6940 - let value = size3[0]; 6941 - return append2(float_to_string(value), "cqi"); 6942 - } else if (size3 instanceof Cqb) { 6943 - let value = size3[0]; 6944 - return append2(float_to_string(value), "cqb"); 6945 - } else if (size3 instanceof Cqmin) { 6946 - let value = size3[0]; 6947 - return append2(float_to_string(value), "cqmin"); 6948 - } else { 6949 - let value = size3[0]; 6950 - return append2(float_to_string(value), "cqmax"); 6951 - } 6952 - } 6953 - 6954 - // build/dev/javascript/sketch/sketch/css.mjs 6955 - function class$4(styles) { 6956 - return class$2(styles); 6957 - } 6958 - function global(name, styles) { 6959 - return new Global(named(name, styles)); 6960 - } 6961 - function property3(field2, content) { 6962 - return new Property2(field2, content, false); 6963 - } 6964 - function align_items(align) { 6965 - return property3("align-items", align); 6966 - } 6967 - function aspect_ratio(aspect_ratio2) { 6968 - return property3("aspect-ratio", aspect_ratio2); 6969 - } 6970 - function background(background2) { 6971 - return property3("background", background2); 6972 - } 6973 - function background_color(value) { 6974 - return property3("background-color", value); 6975 - } 6976 - function border(border2) { 6977 - return property3("border", border2); 6978 - } 6979 - function border_radius(border_radius2) { 6980 - return property3("border-radius", to_string4(border_radius2)); 6981 - } 6982 - function color(color2) { 6983 - return property3("color", color2); 6984 - } 6985 - function display(display2) { 6986 - return property3("display", display2); 6987 - } 6988 - function flex_direction(flex_direction2) { 6989 - return property3("flex-direction", flex_direction2); 6990 - } 6991 - function gap(gap2) { 6992 - return property3("gap", to_string4(gap2)); 6993 - } 6994 - function margin(margin2) { 6995 - return property3("margin", to_string4(margin2)); 6996 - } 6997 - function margin_left(margin2) { 6998 - return property3("margin-left", to_string4(margin2)); 6999 - } 7000 - function max_width(width2) { 7001 - return property3("max-width", to_string4(width2)); 7002 - } 7003 - function padding(padding2) { 7004 - return property3("padding", to_string4(padding2)); 7005 - } 7006 - function width(width2) { 7007 - return property3("width", to_string4(width2)); 7008 - } 7009 - function width_(width2) { 7010 - return property3("width", width2); 7011 - } 7012 - 7013 - // build/dev/javascript/sketch/sketch.mjs 7014 - var StyleSheet = class extends CustomType { 7015 - constructor(cache, id2, is_persistent) { 7016 - super(); 7017 - this.cache = cache; 7018 - this.id = id2; 7019 - this.is_persistent = is_persistent; 7020 - } 7021 - }; 7022 - var Ephemeral = class extends CustomType { 7023 - }; 7024 - var Persistent = class extends CustomType { 7025 - }; 7026 - function render(cache) { 7027 - return render_sheet(cache.cache); 7028 - } 7029 - function class_name2(class$5, stylesheet2) { 7030 - let $ = class_name(class$5, stylesheet2.cache); 7031 - let cache = $[0]; 7032 - let class_name$1 = $[1]; 7033 - return [ 7034 - (() => { 7035 - let _record = stylesheet2; 7036 - return new StyleSheet(cache, _record.id, _record.is_persistent); 7037 - })(), 7038 - class_name$1 7039 - ]; 7040 - } 7041 - function global2(stylesheet2, global3) { 7042 - let $ = class_name(global3.class, stylesheet2.cache); 7043 - let cache = $[0]; 7044 - let _record = stylesheet2; 7045 - return new StyleSheet(cache, _record.id, _record.is_persistent); 7046 - } 7047 - function stylesheet(strategy) { 7048 - let id2 = uniqueId(); 7049 - return new Ok( 7050 - (() => { 7051 - if (strategy instanceof Ephemeral) { 7052 - return new StyleSheet(new$10(), id2, false); 7053 - } else { 7054 - return new StyleSheet(new$10(), id2, true); 7055 - } 7056 - })() 7057 - ); 7058 - } 7059 - 7060 - // build/dev/javascript/sketch_lustre/sketch/lustre/internals/css-stylesheet.ffi.mjs 7061 - function replaceSync(content, stylesheet2) { 7062 - stylesheet2.replaceSync(content); 7063 - } 7064 - 7065 - // build/dev/javascript/sketch_lustre/sketch/lustre/internals/global.ffi.mjs 7066 - var currentStylesheet = null; 7067 - var stylesheets = {}; 7068 - function setStyleSheet(stylesheet2) { 7069 - stylesheets[stylesheet2.id] = stylesheet2; 7070 - return new Ok(stylesheet2); 7071 - } 7072 - function setCurrentStylesheet(stylesheet2) { 7073 - currentStylesheet = stylesheet2.id; 7074 - return new Ok(stylesheet2); 7075 - } 7076 - function getStyleSheet() { 7077 - const stylesheet2 = stylesheets[currentStylesheet]; 7078 - if (!stylesheet2) return new Error(); 7079 - return new Ok(stylesheet2); 7080 - } 7081 - function dismissCurrentStylesheet() { 7082 - currentStylesheet = null; 7083 - return new Ok(void 0); 7084 - } 7085 - 7086 - // build/dev/javascript/sketch_lustre/sketch/lustre.mjs 7087 - var FILEPATH2 = "src/sketch/lustre.gleam"; 7088 - var Document2 = class extends CustomType { 7089 - constructor(css_stylesheet) { 7090 - super(); 7091 - this.css_stylesheet = css_stylesheet; 7092 - } 7093 - }; 7094 - var Shadow = class extends CustomType { 7095 - constructor(css_stylesheet) { 7096 - super(); 7097 - this.css_stylesheet = css_stylesheet; 7098 - } 7099 - }; 7100 - var Node = class extends CustomType { 7101 - }; 7102 - function setup() { 7103 - let $ = stylesheet(new Persistent()); 7104 - if ($ instanceof Ok) { 7105 - let stylesheet2 = $[0]; 7106 - return setStyleSheet(stylesheet2); 7107 - } else { 7108 - return new Error(void 0); 7109 - } 7110 - } 7111 - function render2(stylesheet2, outputs, view2) { 7112 - let $ = setCurrentStylesheet(stylesheet2); 7113 - if (!($ instanceof Ok)) { 7114 - throw makeError( 7115 - "let_assert", 7116 - FILEPATH2, 7117 - "sketch/lustre", 7118 - 117, 7119 - "render", 7120 - "Pattern match failed, no pattern matched the value.", 7121 - { 7122 - value: $, 7123 - start: 3944, 7124 - end: 4004, 7125 - pattern_start: 3955, 7126 - pattern_end: 3960 7127 - } 7128 - ); 7129 - } 7130 - let new_view = view2(); 7131 - let $1 = getStyleSheet(); 7132 - if ($1 instanceof Ok) { 7133 - let stylesheet$1 = $1[0]; 7134 - let content = render(stylesheet$1); 7135 - return fold( 7136 - outputs, 7137 - new_view, 7138 - (view3, stylesheet3) => { 7139 - if (stylesheet3 instanceof Document2) { 7140 - let css_stylesheet = stylesheet3.css_stylesheet; 7141 - return tap( 7142 - view3, 7143 - (_) => { 7144 - let $2 = dismissCurrentStylesheet(); 7145 - return replaceSync(content, css_stylesheet); 7146 - } 7147 - ); 7148 - } else if (stylesheet3 instanceof Shadow) { 7149 - let css_stylesheet = stylesheet3.css_stylesheet; 7150 - return tap( 7151 - view3, 7152 - (_) => { 7153 - let $2 = dismissCurrentStylesheet(); 7154 - return replaceSync(content, css_stylesheet); 7155 - } 7156 - ); 7157 - } else { 7158 - return fragment2(toList([style(toList([]), content), view3])); 7159 - } 7160 - } 7161 - ); 7162 - } else { 7163 - return new_view; 7164 - } 7165 - } 7166 - function node() { 7167 - return new Node(); 7168 - } 7169 - 7170 - // build/dev/javascript/sketch_lustre/sketch/lustre/element.mjs 7171 - var FILEPATH3 = "src/sketch/lustre/element.gleam"; 7172 - function element_(tag, attributes, children) { 7173 - return element2(tag, attributes, children); 7174 - } 7175 - var none3 = none2; 7176 - var text3 = text2; 7177 - var error_msg = "Stylesheet is not initialized in your application. Please, initialize a stylesheet before rendering some nodes."; 7178 - function class_name3(class$5) { 7179 - let $ = getStyleSheet(); 7180 - if ($ instanceof Ok) { 7181 - let stylesheet2 = $[0]; 7182 - let $1 = class_name2(class$5, stylesheet2); 7183 - let stylesheet$1 = $1[0]; 7184 - let class_name$1 = $1[1]; 7185 - let $2 = setStyleSheet(stylesheet$1); 7186 - return class_name$1; 7187 - } else { 7188 - throw makeError( 7189 - "panic", 7190 - FILEPATH3, 7191 - "sketch/lustre/element", 7192 - 77, 7193 - "class_name", 7194 - error_msg, 7195 - {} 7196 - ); 7197 - } 7198 - } 7199 - function element3(tag, class$5, attributes, children) { 7200 - let class_name$1 = class_name3(class$5); 7201 - let attributes$1 = prepend(class$(class_name$1), attributes); 7202 - return element2(tag, attributes$1, children); 7203 - } 7204 - 7205 - // build/dev/javascript/sketch_lustre/sketch/lustre/element/html.mjs 7206 - function text4(content) { 7207 - return text3(content); 7208 - } 7209 - function button(class$5, attributes, children) { 7210 - return element3("button", class$5, attributes, children); 7211 - } 7212 - function div(class$5, attributes, children) { 7213 - return element3("div", class$5, attributes, children); 7214 - } 7215 - function h1_(attributes, children) { 7216 - return element_("h1", attributes, children); 7217 - } 7218 - function h4(class$5, attributes, children) { 7219 - return element3("h4", class$5, attributes, children); 7220 - } 7221 - function input_(attributes) { 7222 - return element_("input", attributes, toList([])); 7223 - } 7224 - function span(class$5, attributes, children) { 7225 - return element3("span", class$5, attributes, children); 7226 - } 7227 - 7228 - // build/dev/javascript/voyagers_bingo/voyagers_bingo/styles.mjs 7229 - function container() { 7230 - return class$4( 7231 - toList([ 7232 - margin_left(vw(3)), 7233 - gap(em(0.5)), 7234 - display("flex"), 7235 - flex_direction("column"), 7236 - width_("fit-content"), 7237 - align_items("center") 7238 - ]) 7239 - ); 7240 - } 7241 - function grid() { 7242 - return class$4( 7243 - toList([ 7244 - display("flex"), 7245 - flex_direction("column"), 7246 - background_color("black"), 7247 - width_("auto"), 7248 - gap(em(0.5)), 7249 - padding(em(0.5)), 7250 - border_radius(px(4)), 7251 - align_items("center"), 7252 - width_("fit-content") 7253 - ]) 7254 - ); 7255 - } 7256 - function row() { 7257 - return class$4( 7258 - toList([ 7259 - display("flex"), 7260 - flex_direction("row"), 7261 - gap(em(0.5)), 7262 - width(percent(100)) 7263 - ]) 7264 - ); 7265 - } 7266 - function square(checked) { 7267 - return class$4( 7268 - toList([ 7269 - width(em(10)), 7270 - aspect_ratio("1 / 1"), 7271 - max_width(em(5)), 7272 - (() => { 7273 - if (checked) { 7274 - return background("yellow"); 7275 - } else { 7276 - return background("white"); 7277 - } 7278 - })(), 7279 - border("none"), 7280 - border_radius(px(4)) 7281 - ]) 7282 - ); 7283 - } 7284 - 7285 - // build/dev/javascript/voyagers_bingo/voyagers_bingo.mjs 7286 - var FILEPATH4 = "src/voyagers_bingo.gleam"; 7287 - var UserRequestedNewSheet = class extends CustomType { 7288 - constructor(rows, columns) { 7289 - super(); 7290 - this.rows = rows; 7291 - this.columns = columns; 7292 - } 7293 - }; 7294 - var UserSelectedSquare = class extends CustomType { 7295 - constructor(x, y) { 7296 - super(); 7297 - this.x = x; 7298 - this.y = y; 7299 - } 7300 - }; 7301 - var UserDeselectedSquare = class extends CustomType { 7302 - constructor(x, y) { 7303 - super(); 7304 - this.x = x; 7305 - this.y = y; 7306 - } 7307 - }; 7308 - var CreatedNewSheet = class extends CustomType { 7309 - constructor(sheet) { 7310 - super(); 7311 - this.sheet = sheet; 7312 - } 7313 - }; 7314 - var FailedToCreateSheet = class extends CustomType { 7315 - }; 7316 - var UserSetX = class extends CustomType { 7317 - constructor(x) { 7318 - super(); 7319 - this.x = x; 7320 - } 7321 - }; 7322 - var UserSetY = class extends CustomType { 7323 - constructor(y) { 7324 - super(); 7325 - this.y = y; 7326 - } 7327 - }; 7328 - var Square = class extends CustomType { 7329 - constructor(text5, crossed) { 7330 - super(); 7331 - this.text = text5; 7332 - this.crossed = crossed; 7333 - } 7334 - }; 7335 - var Model = class extends CustomType { 7336 - constructor(sheet, failed, x, y) { 7337 - super(); 7338 - this.sheet = sheet; 7339 - this.failed = failed; 7340 - this.x = x; 7341 - this.y = y; 7342 - } 7343 - }; 7344 - var available_squares = /* @__PURE__ */ toList([ 7345 - "PC Flirting", 7346 - "Ben Blushing", 7347 - "Off Topic", 7348 - "Pidgeon" 7349 - ]); 7350 - function sheet_with_size(rows, columns) { 7351 - let _block; 7352 - let _pipe = shuffle(available_squares); 7353 - let _pipe$1 = sized_chunk(_pipe, rows * columns); 7354 - _block = first(_pipe$1); 7355 - let $ = _block; 7356 - if (!($ instanceof Ok)) { 7357 - throw makeError( 7358 - "let_assert", 7359 - FILEPATH4, 7360 - "voyagers_bingo", 7361 - 45, 7362 - "sheet_with_size", 7363 - "Pattern match failed, no pattern matched the value.", 7364 - { value: $, start: 980, end: 1107, pattern_start: 991, pattern_end: 1009 } 7365 - ); 7366 - } 7367 - let random_squares = $[0]; 7368 - let _block$1; 7369 - let _pipe$2 = random_squares; 7370 - _block$1 = sized_chunk(_pipe$2, columns); 7371 - let square_rows = _block$1; 7372 - let _pipe$3 = square_rows; 7373 - let _pipe$4 = map( 7374 - _pipe$3, 7375 - (row2) => { 7376 - let _pipe$42 = row2; 7377 - let _pipe$5 = map( 7378 - _pipe$42, 7379 - (text5) => { 7380 - return new Square(text5, false); 7381 - } 7382 - ); 7383 - return from_list2(_pipe$5); 7384 - } 7385 - ); 7386 - return from_list2(_pipe$4); 7387 - } 7388 - function init(_) { 7389 - let _block; 7390 - let _pipe = square_root2(length(available_squares)); 7391 - let _pipe$1 = unwrap2(_pipe, 2); 7392 - let _pipe$2 = floor(_pipe$1); 7393 - let _pipe$3 = round(_pipe$2); 7394 - _block = min(_pipe$3, 5); 7395 - let sqrt = _block; 7396 - return [ 7397 - new Model(sheet_with_size(sqrt, sqrt), false, sqrt, sqrt), 7398 - none() 7399 - ]; 7400 - } 7401 - function update4(model, msg) { 7402 - if (msg instanceof UserRequestedNewSheet) { 7403 - let rows = msg.rows; 7404 - let columns = msg.columns; 7405 - let too_big = rows * columns > length(available_squares); 7406 - return guard( 7407 - too_big, 7408 - [ 7409 - model, 7410 - from( 7411 - (dispatch) => { 7412 - return dispatch(new FailedToCreateSheet()); 7413 - } 7414 - ) 7415 - ], 7416 - () => { 7417 - return [ 7418 - model, 7419 - from( 7420 - (dispatch) => { 7421 - let sheet = sheet_with_size(rows, columns); 7422 - return dispatch(new CreatedNewSheet(sheet)); 7423 - } 7424 - ) 7425 - ]; 7426 - } 7427 - ); 7428 - } else if (msg instanceof UserSelectedSquare) { 7429 - let x = msg.x; 7430 - let y = msg.y; 7431 - let $ = get2(model.sheet, x); 7432 - if (!($ instanceof Ok)) { 7433 - throw makeError( 7434 - "let_assert", 7435 - FILEPATH4, 7436 - "voyagers_bingo", 7437 - 95, 7438 - "update", 7439 - "Pattern match failed, no pattern matched the value.", 7440 - { 7441 - value: $, 7442 - start: 2211, 7443 - end: 2254, 7444 - pattern_start: 2222, 7445 - pattern_end: 2229 7446 - } 7447 - ); 7448 - } 7449 - let row2 = $[0]; 7450 - let $1 = get2(row2, y); 7451 - if (!($1 instanceof Ok)) { 7452 - throw makeError( 7453 - "let_assert", 7454 - FILEPATH4, 7455 - "voyagers_bingo", 7456 - 96, 7457 - "update", 7458 - "Pattern match failed, no pattern matched the value.", 7459 - { 7460 - value: $1, 7461 - start: 2261, 7462 - end: 2298, 7463 - pattern_start: 2272, 7464 - pattern_end: 2281 7465 - } 7466 - ); 7467 - } 7468 - let value = $1[0]; 7469 - let $2 = set( 7470 - row2, 7471 - y, 7472 - (() => { 7473 - let _record = value; 7474 - return new Square(_record.text, true); 7475 - })() 7476 - ); 7477 - if (!($2 instanceof Ok)) { 7478 - throw makeError( 7479 - "let_assert", 7480 - FILEPATH4, 7481 - "voyagers_bingo", 7482 - 97, 7483 - "update", 7484 - "Pattern match failed, no pattern matched the value.", 7485 - { 7486 - value: $2, 7487 - start: 2305, 7488 - end: 2388, 7489 - pattern_start: 2316, 7490 - pattern_end: 2331 7491 - } 7492 - ); 7493 - } 7494 - let updated_row = $2[0]; 7495 - let $3 = set(model.sheet, x, updated_row); 7496 - if (!($3 instanceof Ok)) { 7497 - throw makeError( 7498 - "let_assert", 7499 - FILEPATH4, 7500 - "voyagers_bingo", 7501 - 99, 7502 - "update", 7503 - "Pattern match failed, no pattern matched the value.", 7504 - { 7505 - value: $3, 7506 - start: 2395, 7507 - end: 2455, 7508 - pattern_start: 2406, 7509 - pattern_end: 2417 7510 - } 7511 - ); 7512 - } 7513 - let updated = $3[0]; 7514 - return [ 7515 - (() => { 7516 - let _record = model; 7517 - return new Model(updated, _record.failed, _record.x, _record.y); 7518 - })(), 7519 - none() 7520 - ]; 7521 - } else if (msg instanceof UserDeselectedSquare) { 7522 - let x = msg.x; 7523 - let y = msg.y; 7524 - let $ = get2(model.sheet, x); 7525 - if (!($ instanceof Ok)) { 7526 - throw makeError( 7527 - "let_assert", 7528 - FILEPATH4, 7529 - "voyagers_bingo", 7530 - 103, 7531 - "update", 7532 - "Pattern match failed, no pattern matched the value.", 7533 - { 7534 - value: $, 7535 - start: 2561, 7536 - end: 2604, 7537 - pattern_start: 2572, 7538 - pattern_end: 2579 7539 - } 7540 - ); 7541 - } 7542 - let row2 = $[0]; 7543 - let $1 = get2(row2, y); 7544 - if (!($1 instanceof Ok)) { 7545 - throw makeError( 7546 - "let_assert", 7547 - FILEPATH4, 7548 - "voyagers_bingo", 7549 - 104, 7550 - "update", 7551 - "Pattern match failed, no pattern matched the value.", 7552 - { 7553 - value: $1, 7554 - start: 2611, 7555 - end: 2648, 7556 - pattern_start: 2622, 7557 - pattern_end: 2631 7558 - } 7559 - ); 7560 - } 7561 - let value = $1[0]; 7562 - let $2 = set( 7563 - row2, 7564 - y, 7565 - (() => { 7566 - let _record = value; 7567 - return new Square(_record.text, false); 7568 - })() 7569 - ); 7570 - if (!($2 instanceof Ok)) { 7571 - throw makeError( 7572 - "let_assert", 7573 - FILEPATH4, 7574 - "voyagers_bingo", 7575 - 105, 7576 - "update", 7577 - "Pattern match failed, no pattern matched the value.", 7578 - { 7579 - value: $2, 7580 - start: 2655, 7581 - end: 2739, 7582 - pattern_start: 2666, 7583 - pattern_end: 2681 7584 - } 7585 - ); 7586 - } 7587 - let updated_row = $2[0]; 7588 - let $3 = set(model.sheet, x, updated_row); 7589 - if (!($3 instanceof Ok)) { 7590 - throw makeError( 7591 - "let_assert", 7592 - FILEPATH4, 7593 - "voyagers_bingo", 7594 - 107, 7595 - "update", 7596 - "Pattern match failed, no pattern matched the value.", 7597 - { 7598 - value: $3, 7599 - start: 2746, 7600 - end: 2806, 7601 - pattern_start: 2757, 7602 - pattern_end: 2768 7603 - } 7604 - ); 7605 - } 7606 - let updated = $3[0]; 7607 - return [ 7608 - (() => { 7609 - let _record = model; 7610 - return new Model(updated, _record.failed, _record.x, _record.y); 7611 - })(), 7612 - none() 7613 - ]; 7614 - } else if (msg instanceof CreatedNewSheet) { 7615 - let sheet = msg.sheet; 7616 - return [ 7617 - (() => { 7618 - let _record = model; 7619 - return new Model(sheet, false, _record.x, _record.y); 7620 - })(), 7621 - none() 7622 - ]; 7623 - } else if (msg instanceof FailedToCreateSheet) { 7624 - return [ 7625 - (() => { 7626 - let _record = model; 7627 - return new Model(_record.sheet, true, _record.x, _record.y); 7628 - })(), 7629 - none() 7630 - ]; 7631 - } else if (msg instanceof UserSetX) { 7632 - let x = msg.x; 7633 - return [ 7634 - (() => { 7635 - let _record = model; 7636 - return new Model(_record.sheet, false, x, _record.y); 7637 - })(), 7638 - none() 7639 - ]; 7640 - } else { 7641 - let y = msg.y; 7642 - return [ 7643 - (() => { 7644 - let _record = model; 7645 - return new Model(_record.sheet, false, _record.x, y); 7646 - })(), 7647 - none() 7648 - ]; 7649 - } 7650 - } 7651 - function view(model) { 7652 - return div( 7653 - container(), 7654 - toList([]), 7655 - toList([ 7656 - h1_(toList([]), toList([text4("Voyagers Bingo")])), 7657 - div( 7658 - grid(), 7659 - toList([]), 7660 - (() => { 7661 - let _pipe = model.sheet; 7662 - let _pipe$1 = index_map3( 7663 - _pipe, 7664 - (row2, x) => { 7665 - return span( 7666 - row(), 7667 - toList([]), 7668 - (() => { 7669 - let _pipe$12 = index_map3( 7670 - row2, 7671 - (square2, y) => { 7672 - return button( 7673 - square(square2.crossed), 7674 - toList([ 7675 - on_click( 7676 - (() => { 7677 - let $ = square2.crossed; 7678 - if ($) { 7679 - return new UserDeselectedSquare(x, y); 7680 - } else { 7681 - return new UserSelectedSquare(x, y); 7682 - } 7683 - })() 7684 - ) 7685 - ]), 7686 - toList([text4(square2.text)]) 7687 - ); 7688 - } 7689 - ); 7690 - return to_list(_pipe$12); 7691 - })() 7692 - ); 7693 - } 7694 - ); 7695 - return to_list(_pipe$1); 7696 - })() 7697 - ), 7698 - input_( 7699 - toList([ 7700 - type_("number"), 7701 - placeholder("Rows: 2"), 7702 - on_input( 7703 - (content) => { 7704 - let $ = parse_int(content); 7705 - if (!($ instanceof Ok)) { 7706 - throw makeError( 7707 - "let_assert", 7708 - FILEPATH4, 7709 - "voyagers_bingo", 7710 - 152, 7711 - "view", 7712 - "Pattern match failed, no pattern matched the value.", 7713 - { 7714 - value: $, 7715 - start: 4144, 7716 - end: 4183, 7717 - pattern_start: 4155, 7718 - pattern_end: 4162 7719 - } 7720 - ); 7721 - } 7722 - let num = $[0]; 7723 - return new UserSetX(num); 7724 - } 7725 - ) 7726 - ]) 7727 - ), 7728 - input_( 7729 - toList([ 7730 - type_("number"), 7731 - placeholder("Columns: 2"), 7732 - on_input( 7733 - (content) => { 7734 - let $ = parse_int(content); 7735 - if (!($ instanceof Ok)) { 7736 - throw makeError( 7737 - "let_assert", 7738 - FILEPATH4, 7739 - "voyagers_bingo", 7740 - 160, 7741 - "view", 7742 - "Pattern match failed, no pattern matched the value.", 7743 - { 7744 - value: $, 7745 - start: 4361, 7746 - end: 4400, 7747 - pattern_start: 4372, 7748 - pattern_end: 4379 7749 - } 7750 - ); 7751 - } 7752 - let num = $[0]; 7753 - return new UserSetY(num); 7754 - } 7755 - ) 7756 - ]) 7757 - ), 7758 - button( 7759 - class$4(toList([width_("fit-content")])), 7760 - toList([on_click(new UserRequestedNewSheet(model.x, model.y))]), 7761 - toList([text4("New Sheet")]) 7762 - ), 7763 - (() => { 7764 - let $ = model.failed; 7765 - if ($) { 7766 - return h4( 7767 - class$4(toList([color("red")])), 7768 - toList([]), 7769 - toList([ 7770 - text4( 7771 - "Failed to create sheet of size " + to_string( 7772 - model.x 7773 - ) + "x" + to_string(model.y) + " (" + to_string( 7774 - model.x * model.y 7775 - ) + ") - maximum possible size is " + to_string( 7776 - length(available_squares) 7777 - ) 7778 - ) 7779 - ]) 7780 - ); 7781 - } else { 7782 - return none3(); 7783 - } 7784 - })() 7785 - ]) 7786 - ); 7787 - } 7788 - function css_view(model, stylesheet2) { 7789 - return render2( 7790 - stylesheet2, 7791 - toList([node()]), 7792 - () => { 7793 - return view(model); 7794 - } 7795 - ); 7796 - } 7797 - function main() { 7798 - let $ = setup(); 7799 - if (!($ instanceof Ok)) { 7800 - throw makeError( 7801 - "let_assert", 7802 - FILEPATH4, 7803 - "voyagers_bingo", 7804 - 194, 7805 - "main", 7806 - "Pattern match failed, no pattern matched the value.", 7807 - { 7808 - value: $, 7809 - start: 5286, 7810 - end: 5330, 7811 - pattern_start: 5297, 7812 - pattern_end: 5311 7813 - } 7814 - ); 7815 - } 7816 - let stylesheet2 = $[0]; 7817 - global2(stylesheet2, global("body", toList([margin(vw(10))]))); 7818 - let app = application( 7819 - init, 7820 - update4, 7821 - (_capture) => { 7822 - return css_view(_capture, stylesheet2); 7823 - } 7824 - ); 7825 - let $1 = start3(app, "#app", void 0); 7826 - if (!($1 instanceof Ok)) { 7827 - throw makeError( 7828 - "let_assert", 7829 - FILEPATH4, 7830 - "voyagers_bingo", 7831 - 197, 7832 - "main", 7833 - "Pattern match failed, no pattern matched the value.", 7834 - { 7835 - value: $1, 7836 - start: 5473, 7837 - end: 5522, 7838 - pattern_start: 5484, 7839 - pattern_end: 5489 7840 - } 7841 - ); 7842 - } 7843 - return void 0; 7844 - } 7845 - 7846 - // build/.lustre/entry.mjs 7847 - main();