solve-engine 2.38.12 → 2.38.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/{PackageCompatibility-BQqAi18x.d.cts → PackageCompatibility-ByCnkoxf.d.cts} +1 -1
  2. package/dist/{PackageCompatibility-7daIo3Hc.d.ts → PackageCompatibility-WzScL1Av.d.ts} +1 -1
  3. package/dist/{PackageRegistry-DcyhcuUP.d.ts → PackageRegistry-11ThI3Qg.d.ts} +36 -1
  4. package/dist/{PackageRegistry-CgmkZ9-l.d.cts → PackageRegistry-BN4zOado.d.cts} +36 -1
  5. package/dist/{VMBuiltins-CgXOvwMx.d.cts → VMBuiltins-5ATHQ045.d.cts} +224 -3
  6. package/dist/{VMBuiltins-nHNiqOnT.d.ts → VMBuiltins-BbNZtVJc.d.ts} +224 -3
  7. package/dist/{chunk-BKPNQTEU.js → chunk-4LMPCB2V.js} +3 -3
  8. package/dist/{chunk-BKPNQTEU.js.map → chunk-4LMPCB2V.js.map} +1 -1
  9. package/dist/{chunk-25ZZB2W6.cjs → chunk-54MEZ574.cjs} +2 -2
  10. package/dist/{chunk-25ZZB2W6.cjs.map → chunk-54MEZ574.cjs.map} +1 -1
  11. package/dist/{chunk-4RJUVBHL.js → chunk-5M4F7PCU.js} +2 -2
  12. package/dist/{chunk-4RJUVBHL.js.map → chunk-5M4F7PCU.js.map} +1 -1
  13. package/dist/{chunk-JVIUA2PL.cjs → chunk-6ADFAXTZ.cjs} +2 -2
  14. package/dist/chunk-6ADFAXTZ.cjs.map +1 -0
  15. package/dist/{chunk-JHHTGKHV.js → chunk-AFNK2LUO.js} +2 -2
  16. package/dist/chunk-AFNK2LUO.js.map +1 -0
  17. package/dist/chunk-CH6NLOVG.js +2 -0
  18. package/dist/chunk-CH6NLOVG.js.map +1 -0
  19. package/dist/{chunk-EIFT45H3.cjs → chunk-DTOSRC6E.cjs} +2 -2
  20. package/dist/{chunk-EIFT45H3.cjs.map → chunk-DTOSRC6E.cjs.map} +1 -1
  21. package/dist/{chunk-WTIMAWOG.js → chunk-IUCUBHFW.js} +2 -2
  22. package/dist/{chunk-WTIMAWOG.js.map → chunk-IUCUBHFW.js.map} +1 -1
  23. package/dist/{chunk-QZ437BWD.cjs → chunk-KVONXXPJ.cjs} +3 -3
  24. package/dist/{chunk-QZ437BWD.cjs.map → chunk-KVONXXPJ.cjs.map} +1 -1
  25. package/dist/{chunk-FTI34FPL.js → chunk-NGHH4QKV.js} +4 -4
  26. package/dist/chunk-NGHH4QKV.js.map +1 -0
  27. package/dist/chunk-OXZWX5WY.cjs +2 -0
  28. package/dist/chunk-OXZWX5WY.cjs.map +1 -0
  29. package/dist/{chunk-ZBXB3HDZ.cjs → chunk-U54BIYXO.cjs} +2 -2
  30. package/dist/{chunk-ZBXB3HDZ.cjs.map → chunk-U54BIYXO.cjs.map} +1 -1
  31. package/dist/chunk-UM5A6VXI.js +3 -0
  32. package/dist/chunk-UM5A6VXI.js.map +1 -0
  33. package/dist/{chunk-TJR3EQB4.cjs → chunk-V52TAWYV.cjs} +4 -4
  34. package/dist/chunk-V52TAWYV.cjs.map +1 -0
  35. package/dist/chunk-VR35R5MV.cjs +3 -0
  36. package/dist/chunk-VR35R5MV.cjs.map +1 -0
  37. package/dist/{chunk-QQOYU665.js → chunk-ZXNM355C.js} +2 -2
  38. package/dist/{chunk-QQOYU665.js.map → chunk-ZXNM355C.js.map} +1 -1
  39. package/dist/constants.cjs +1 -1
  40. package/dist/constants.js +1 -1
  41. package/dist/engine.cjs +1 -1
  42. package/dist/engine.d.cts +4 -4
  43. package/dist/engine.d.ts +4 -4
  44. package/dist/engine.js +1 -1
  45. package/dist/engine.worker.cjs +1 -1
  46. package/dist/engine.worker.js +1 -1
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +4 -4
  50. package/dist/index.d.ts +4 -4
  51. package/dist/index.js +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/language.d.cts +3 -3
  54. package/dist/language.d.ts +3 -3
  55. package/dist/packages.cjs +1 -1
  56. package/dist/packages.d.cts +2 -2
  57. package/dist/packages.d.ts +2 -2
  58. package/dist/packages.js +1 -1
  59. package/dist/testing.cjs +2 -2
  60. package/dist/testing.d.cts +3 -3
  61. package/dist/testing.d.ts +3 -3
  62. package/dist/testing.js +1 -1
  63. package/dist/vm.cjs +1 -1
  64. package/dist/vm.cjs.map +1 -1
  65. package/dist/vm.d.cts +1 -2
  66. package/dist/vm.d.ts +1 -2
  67. package/dist/vm.js +1 -1
  68. package/dist/vm.js.map +1 -1
  69. package/dist/worker.cjs +2 -2
  70. package/dist/worker.d.cts +2 -2
  71. package/dist/worker.d.ts +2 -2
  72. package/dist/worker.js +1 -1
  73. package/package.json +1 -1
  74. package/dist/VMCheckpoints-Cj1lxo1z.d.ts +0 -176
  75. package/dist/VMCheckpoints-ZCTfca_Z.d.cts +0 -176
  76. package/dist/chunk-FTI34FPL.js.map +0 -1
  77. package/dist/chunk-FU7TW5GB.cjs +0 -3
  78. package/dist/chunk-FU7TW5GB.cjs.map +0 -1
  79. package/dist/chunk-JHHTGKHV.js.map +0 -1
  80. package/dist/chunk-JVIUA2PL.cjs.map +0 -1
  81. package/dist/chunk-TJR3EQB4.cjs.map +0 -1
  82. package/dist/chunk-ZGP35A6D.js +0 -3
  83. package/dist/chunk-ZGP35A6D.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ 'use strict';var p=class{constructor(n){this.checkpoints=[];this.vm=n;}snapshot(n,e,i){if(i.length===0)return null;let t=this.checkpoints.length;for(;t>0&&this.checkpoints[t-1].lineNumber>=n;)t--;t!==this.checkpoints.length&&(this.checkpoints.length=t);let r=t>0?this.checkpoints[t-1]:null,s=Object.create(null),o=Object.create(null);for(let c of i){if(this.vm.hasUserFunction(c)){let l=this.vm.getUserFunction(c);l&&(o[c]=l);continue}let u=this.vm.getVar(c);u!==void 0&&(s[c]=u);}let h={lineNumber:n,lineId:e,variables:s,functions:o,parent:r};return this.checkpoints.push(h),h}restoreTo(n){let e=this.getNearestCheckpoint(n);if(!e){this.vm.reset();return}let i=[],t=e;for(;t;)i.unshift(t),t=t.parent;this.vm.reset();for(let r of i){for(let s of Object.keys(r.variables))this.vm.setVar(s,r.variables[s]);for(let s of Object.keys(r.functions)){let o=r.functions[s];this.vm.defineUserFunction(o.name,o.params,o.program);}}}updateCheckpointAt(n,e){let i=this.getCheckpointAt(n);if(!i)return false;for(let t of e){if(this.vm.hasUserFunction(t)){let s=this.vm.getUserFunction(t);s&&(i.functions[t]=s);continue}let r=this.vm.getVar(t);r!==void 0&&(i.variables[t]=r);}return true}applyCheckpointAt(n){let e=this.getCheckpointAt(n);if(!e)return false;for(let i of Object.keys(e.variables))this.vm.setVar(i,e.variables[i]);for(let i of Object.keys(e.functions)){let t=e.functions[i];this.vm.defineUserFunction(t.name,t.params,t.program);}return true}getNearestCheckpoint(n){let e=null;for(let i of this.checkpoints)if(i.lineNumber<=n)e=i;else break;return e}getCheckpointAt(n){return this.checkpoints.find(e=>e.lineNumber===n)}getAllCheckpoints(){return this.checkpoints}lookupVariable(n){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1];for(;e;){if(Object.prototype.hasOwnProperty.call(e.variables,n))return e.variables[n];e=e.parent;}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};exports.a=p;//# sourceMappingURL=chunk-OXZWX5WY.cjs.map
2
+ //# sourceMappingURL=chunk-OXZWX5WY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vm/VMCheckpoints.ts"],"names":["VMCheckpointer","vm","lineNumber","lineId","variableNames","keep","parent","variables","functions","name","fn","val","checkpoint","target","chain","current","cp","key","value","result"],"mappings":"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","file":"chunk-OXZWX5WY.cjs","sourcesContent":["import { Value } from \"@solve-js/vm/Value\";\nimport type { VM } from \"@solve-js/vm/OpRegistry\";\nimport type { UserFunctionDef } from \"@solve-js/parser/BytecodeBuilder\";\n\n// ── VMCheckpoint ────────────────────────────────────────────────────────\n\n/**\n * A point-in-time snapshot of VM variable state.\n *\n * Each checkpoint holds only the variables that CHANGED at its line, and\n * reaches the rest through its `parent` link. A lookup walks that chain until\n * it finds the name; a restore walks it from the root applying each link's own\n * bindings in turn, so a later line's value naturally overwrites an earlier\n * one's.\n *\n * ```text\n * Checkpoint 0 (root): {} // empty scope\n * Checkpoint 1 (:x=5): { x: 5 } parent → 0\n * Checkpoint 2 (:y=8): { y: 8 } parent → 1\n * Checkpoint 3 (:x=3): { x: 3 } parent → 2 // shadows x=5\n * ```\n *\n * To look up `x` at checkpoint 3: find own `x=3` → done.\n * To look up `y` at checkpoint 3: not own → walk parent to checkpoint 2 → `y=8`.\n * To look up `z` at checkpoint 3: not found anywhere → undefined.\n *\n * **Memory:** O(number of variable definitions) heap, independent of\n * document length. Typical Obsidian documents have < 100 variable defs,\n * so total checkpoint heap is < 10 KB.\n */\nexport interface VMCheckpoint {\n\t/** 1-based line number where this checkpoint was created. */\n\tlineNumber: number;\n\t/** Persistent line ID from DocumentModel. */\n\tlineId: number;\n\t/**\n\t * Variable name → Value at this checkpoint.\n\t * Only the variables set or updated at this line; the rest are reached\n\t * through {@link VMCheckpoint.parent}.\n\t */\n\tvariables: Record<string, Value>;\n\t/**\n\t * User-defined-function name → definition at this checkpoint. SEPARATE\n\t * from `variables` above (not prototypally chained the same way\n\t * `restoreTo()` replays every checkpoint in the chain in order, so a\n\t * later redefinition of the same function name naturally overwrites an\n\t * earlier one during replay, without needing its own prototype walk).\n\t *\n\t * Without this field, a function definition's checkpoint entry would be\n\t * SILENTLY LOST: `snapshot()` used to call `vm.getVar(name)` for every\n\t * written name, which returns `undefined` for a function name (function\n\t * defs live in `vm.userFunctions`, not the flat variable store), and a\n\t * `val !== undefined` guard silently skipped it. A scroll-triggered\n\t * `restoreTo()` would then reset the VM and replay only `variables`,\n\t * making a function defined above the new viewport vanish (calling it\n\t * would throw `UNDEFINED_FUNCTION`) even though the document still\n\t * shows its definition line as clean/cached.\n\t */\n\tfunctions: Record<string, UserFunctionDef>;\n\t/** Parent checkpoint (closer to document start), or null for root. */\n\tparent: VMCheckpoint | null;\n}\n\n// ── VMCheckpointer ──────────────────────────────────────────────────────\n\n/**\n * Manages VM state checkpoints for the three-tier evaluation strategy.\n *\n * **Checkpoint creation:** After a variable-definition line executes\n * (Tier 1 or Tier 3), `snapshot()` records the current values of the\n * written variables. The checkpoint is linked via prototypal inheritance\n * to the previous checkpoint, so only changed variables consume memory.\n *\n * **Checkpoint restoration:** Before evaluating a viewport whose start line\n * is not line 1, `restoreTo(lineNumber)` resets the VM and replays all\n * variable definitions up to and including that line. This avoids\n * re-evaluating the entire document from line 1 on every scroll.\n *\n * **Thread safety:** Checkpoints are created synchronously on the main\n * thread during evaluation. They are immutable after creation (Value is\n * an immutable type), so no synchronization is needed.\n *\n * **Integration with Phase 5.2e:** `setViewport()` will use `getNearestCheckpoint()`\n * to find the checkpoint just before the new viewport start, then call\n * `restoreTo()` to set up the VM before evaluating only the visible lines.\n * This is the key to O(visible lines) scrolling instead of O(document).\n */\nexport class VMCheckpointer {\n\t/** Ordered array of checkpoints (ascending lineNumber). */\n\tprivate checkpoints: VMCheckpoint[] = [];\n\t/** The VM instance whose variables are snapshotted/restored. */\n\tprivate vm: VM;\n\n\tconstructor(vm: VM) {\n\t\tthis.vm = vm;\n\t}\n\n\t// ── Snapshot ─────────────────────────────────────────────────────\n\n\t/**\n\t * Create a checkpoint at the current line, recording the VM values of\n\t * the specified variables.\n\t *\n\t * Records only what this line wrote; the rest is reached through the\n\t * parent link rather than copied.\n\t *\n\t * A line that is snapshotted again drops every checkpoint at or after it\n\t * first, so the list stays in document order and the new checkpoint\n\t * inherits from the line before it rather than from one after it. See the\n\t * body for what went wrong without that.\n\t *\n\t * @param lineNumber 1-based line position.\n\t * @param lineId Persistent line ID from DocumentModel.\n\t * @param variableNames Names of variables that were written at this line.\n\t * @returns The new checkpoint, or null if no variable names provided.\n\t */\n\tsnapshot(\n\t\tlineNumber: number,\n\t\tlineId: number,\n\t\tvariableNames: string[]\n\t): VMCheckpoint | null {\n\t\tif (variableNames.length === 0) return null;\n\n\t\t// Everything at or after this line goes before the new checkpoint is\n\t\t// taken.\n\t\t//\n\t\t// The list is a sequence of document positions and `restoreTo` reads it\n\t\t// as one, so appending on a re-run broke both halves of that. Editing\n\t\t// line 2 of a document whose lines 1, 2 and 3 each define something\n\t\t// left the list as [1, 2, 3, 2]: `getNearestCheckpoint(2)` stops at the\n\t\t// first entry past its target, so it found the stale line 2 and\n\t\t// restored the old value, and the new line 2 inherited from line 3, a\n\t\t// chain running backwards through the document that would have defined\n\t\t// a variable from a line that had not run yet.\n\t\t//\n\t\t// Nothing is lost by dropping them. A pass runs in document order and\n\t\t// every line that writes takes a checkpoint, so the ones removed here\n\t\t// are re-taken by this same pass as it continues past this line.\n\t\tlet keep = this.checkpoints.length;\n\t\twhile (keep > 0 && this.checkpoints[keep - 1].lineNumber >= lineNumber) keep--;\n\t\tif (keep !== this.checkpoints.length) this.checkpoints.length = keep;\n\n\t\tconst parent = keep > 0 ? this.checkpoints[keep - 1] : null;\n\n\t\t// Each checkpoint holds only what its line wrote, and reaches the rest\n\t\t// through `parent`. It used to reach it through the prototype chain\n\t\t// instead, which held the same entries and cost the same memory, and\n\t\t// made the chain as deep as the document has definitions: a null\n\t\t// prototype is a flat object, and one per definition is a chain two\n\t\t// thousand deep on a document of two thousand definitions. Creating and\n\t\t// reading those took a pass over such a document from 6.0 ms to 23.1 ms.\n\t\t//\n\t\t// Nothing needed the inheritance. `restoreTo` walks `parent` and applies\n\t\t// each checkpoint's OWN keys, which is the same set either way, and the\n\t\t// one reader that did walk the prototype now walks `parent` too.\n\t\t//\n\t\t// Null-prototyped rather than `{}`, so a variable named `constructor` or\n\t\t// `toString` is a key like any other.\n\t\tconst variables: Record<string, Value> = Object.create(null) as Record<string, Value>;\n\t\tconst functions: Record<string, UserFunctionDef> = Object.create(null) as Record<string, UserFunctionDef>;\n\n\t\t// Record current VM values for the written names, routing each into\n\t\t// the right bag (a name is either a variable or a user-defined\n\t\t// function, never both; see VMCheckpoint.functions's doc comment for\n\t\t// why this dispatch is required, not optional).\n\t\tfor (const name of variableNames) {\n\t\t\tif (this.vm.hasUserFunction(name)) {\n\t\t\t\tconst fn = this.vm.getUserFunction(name);\n\t\t\t\tif (fn) functions[name] = fn;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst val = this.vm.getVar(name);\n\t\t\tif (val !== undefined) {\n\t\t\t\tvariables[name] = val;\n\t\t\t}\n\t\t}\n\n\t\tconst checkpoint: VMCheckpoint = {\n\t\t\tlineNumber,\n\t\t\tlineId,\n\t\t\tvariables,\n\t\t\tfunctions,\n\t\t\tparent,\n\t\t};\n\t\tthis.checkpoints.push(checkpoint);\n\t\treturn checkpoint;\n\t}\n\n\t// ── Restore ──────────────────────────────────────────────────────\n\n\t/**\n\t * Restore the VM to the state at or just after the given line number.\n\t *\n\t * Finds the nearest checkpoint whose `lineNumber <= targetLineNumber`,\n\t * then replays all variable definitions from root → that checkpoint\n\t * into the VM via `setVar()`. The VM's stack is also reset.\n\t *\n\t * If no checkpoint exists at or before the target line, the VM is\n\t * fully reset (empty scope, empty stack).\n\t *\n\t * **Performance:** O(total variable definitions before the line), since\n\t * each checkpoint in the chain contributes only the names its own line\n\t * wrote.\n\t *\n\t * @param lineNumber Target 1-based line number. The VM will have the\n\t * state that existed AFTER evaluating lines up to `lineNumber`.\n\t */\n\trestoreTo(lineNumber: number): void {\n\t\tconst target = this.getNearestCheckpoint(lineNumber);\n\t\tif (!target) {\n\t\t\tthis.vm.reset();\n\t\t\treturn;\n\t\t}\n\n\t\t// Collect the checkpoint chain from root to target.\n\t\t// Walk parent links and reverse so root is first.\n\t\tconst chain: VMCheckpoint[] = [];\n\t\tlet current: VMCheckpoint | null = target;\n\t\twhile (current) {\n\t\t\tchain.unshift(current);\n\t\t\tcurrent = current.parent;\n\t\t}\n\n\t\tthis.vm.reset();\n\t\tfor (const cp of chain) {\n\t\t\t// Only the names this checkpoint's own line wrote; the ones before\n\t\t\t// it are applied by their own links earlier in this same walk.\n\t\t\tfor (const key of Object.keys(cp.variables)) {\n\t\t\t\tthis.vm.setVar(key, cp.variables[key]);\n\t\t\t}\n\t\t\t// Replay function definitions the same way, a later checkpoint's\n\t\t\t// redefinition of the same name naturally overwrites an earlier\n\t\t\t// one since the chain replays in root-to-target order.\n\t\t\tfor (const key of Object.keys(cp.functions)) {\n\t\t\t\tconst fn = cp.functions[key];\n\t\t\t\tthis.vm.defineUserFunction(fn.name, fn.params, fn.program);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Record what `lineNumber` has just written, without disturbing the chain\n\t * after it.\n\t *\n\t * {@link snapshot} drops every checkpoint at or after the line, which is\n\t * right for a pass running forward in document order: it re-takes them as it\n\t * goes. A caller re-running a few lines out of a document does not, and\n\t * dropping the entries for lines it will never visit would lose the very\n\t * bindings it is sweeping through them to collect. So this overwrites in\n\t * place instead.\n\t *\n\t * Safe against the prototype chain, because it replaces only the\n\t * checkpoint's OWN bindings: a later checkpoint that also writes the name\n\t * holds its own copy and goes on shadowing this one.\n\t *\n\t * @param lineNumber 1-based line whose recorded bindings are refreshed.\n\t * @param variableNames The names it wrote.\n\t * @returns Whether a checkpoint existed at that line to update.\n\t */\n\tupdateCheckpointAt(lineNumber: number, variableNames: string[]): boolean {\n\t\tconst checkpoint = this.getCheckpointAt(lineNumber);\n\t\tif (!checkpoint) return false;\n\t\tfor (const name of variableNames) {\n\t\t\tif (this.vm.hasUserFunction(name)) {\n\t\t\t\tconst fn = this.vm.getUserFunction(name);\n\t\t\t\tif (fn) checkpoint.functions[name] = fn;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst value = this.vm.getVar(name);\n\t\t\tif (value !== undefined) checkpoint.variables[name] = value;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply the bindings recorded AT `lineNumber`, leaving the rest of the VM\n\t * alone.\n\t *\n\t * {@link restoreTo} rebuilds the whole prefix, which costs the chain every\n\t * time it is called. A caller moving forward through the document already\n\t * holds the prefix up to the line before, and needs only what this line\n\t * added: restoring once and then applying each line in turn as it is passed\n\t * costs the chain once rather than once per line.\n\t *\n\t * @param lineNumber 1-based line whose own bindings are applied.\n\t * @returns Whether a checkpoint existed at that line.\n\t */\n\tapplyCheckpointAt(lineNumber: number): boolean {\n\t\tconst checkpoint = this.getCheckpointAt(lineNumber);\n\t\tif (!checkpoint) return false;\n\t\tfor (const key of Object.keys(checkpoint.variables)) {\n\t\t\tthis.vm.setVar(key, checkpoint.variables[key]);\n\t\t}\n\t\tfor (const key of Object.keys(checkpoint.functions)) {\n\t\t\tconst fn = checkpoint.functions[key];\n\t\t\tthis.vm.defineUserFunction(fn.name, fn.params, fn.program);\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ── Queries ──────────────────────────────────────────────────────\n\n\t/**\n\t * Find the nearest checkpoint at or before the given line number.\n\t *\n\t * Uses linear scan (checkpoints are sorted by lineNumber and the list\n\t * is short, typically < 20 for Obsidian documents). Can be upgraded\n\t * to binary search if needed for documents with 1000+ variable defs.\n\t *\n\t * @returns The nearest checkpoint, or null if none exists before the line.\n\t */\n\tgetNearestCheckpoint(lineNumber: number): VMCheckpoint | null {\n\t\tlet result: VMCheckpoint | null = null;\n\t\tfor (const cp of this.checkpoints) {\n\t\t\tif (cp.lineNumber <= lineNumber) {\n\t\t\t\tresult = cp;\n\t\t\t} else {\n\t\t\t\tbreak; // checkpoints are sorted ascending\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get a specific checkpoint by its line number.\n\t * @returns The checkpoint, or undefined if not found.\n\t */\n\tgetCheckpointAt(lineNumber: number): VMCheckpoint | undefined {\n\t\treturn this.checkpoints.find((cp) => cp.lineNumber === lineNumber);\n\t}\n\n\t/**\n\t * Get the entire checkpoint chain from root to the last checkpoint.\n\t * Useful for debugging and serialization.\n\t */\n\tgetAllCheckpoints(): readonly VMCheckpoint[] {\n\t\treturn this.checkpoints;\n\t}\n\n\t/**\n\t * Look up a variable's value through the checkpoint chain.\n\t *\n\t * Walks the prototype chain starting from the most recent checkpoint,\n\t * looking for the variable name as an own property. This is O(depth)\n\t * where depth is the number of checkpoints since the variable was\n\t * last set.\n\t *\n\t * **Note:** This queries the checkpointer's snapshot, not the VM.\n\t * The VM may have been modified since the last snapshot (e.g., by\n\t * Tier 2 execution of non-variable-def lines that don't create checkpoints).\n\t *\n\t * @returns The Value, or undefined if the variable was never set.\n\t */\n\tlookupVariable(name: string): Value | undefined {\n\t\tif (this.checkpoints.length === 0) return undefined;\n\n\t\tlet checkpoint: VMCheckpoint | null = this.checkpoints[this.checkpoints.length - 1];\n\t\twhile (checkpoint) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(checkpoint.variables, name)) {\n\t\t\t\treturn checkpoint.variables[name];\n\t\t\t}\n\t\t\tcheckpoint = checkpoint.parent;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// ── Lifecycle ────────────────────────────────────────────────────\n\n\t/**\n\t * Clear all checkpoints. The underlying VM is NOT reset, call\n\t * `vm.reset()` separately if needed.\n\t */\n\tclear(): void {\n\t\tthis.checkpoints = [];\n\t}\n\n\t/** Number of checkpoints stored. */\n\tget count(): number {\n\t\treturn this.checkpoints.length;\n\t}\n\n\t/** Returns true if no checkpoints have been created. */\n\tget isEmpty(): boolean {\n\t\treturn this.checkpoints.length === 0;\n\t}\n\n\t/** The associated VM instance. */\n\tget vmInstance(): VM {\n\t\treturn this.vm;\n\t}\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkK3PZ66XR_cjs=require('./chunk-K3PZ66XR.cjs'),chunkJVIUA2PL_cjs=require('./chunk-JVIUA2PL.cjs'),chunkEQNKDTMX_cjs=require('./chunk-EQNKDTMX.cjs'),chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),chunk72J5V7SN_cjs=require('./chunk-72J5V7SN.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var M=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(67),t.emitIndex(1);}};var S=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(68),t.emitIndex(1);}};function B(r,e){let o=r.peek();if(!o||o.type!=="IDENT"&&o.type!=="UNIT")throw chunk6SYU4MH7_cjs.c.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${e} needs the name of an unknown here, as in ${e}(x^2, x).`,{found:o?.type??"end of input"});return r.consume(),o.value}function A(r,e){r.emitOpcode(13),r.emitString(e);}function T(r,e,o){let t=new chunkK3PZ66XR_cjs.d(e.pluginIndexMap);r.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),r.setBuilder(e);let n=t.build();if(n.hasAsync)throw chunk6SYU4MH7_cjs.c.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${o}'s expression must be synchronous (no weather/stocks/currency calls).`);return n}function _(r,e,o){let t=r.emitAnonymousBody([o],e);r.emitOpcode(159),r.emitIndex(t);}var k=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"solve"),i=e.match("EQUALS")?T(e,t,"solve"):null;e.consume("COMMA");let a=e.peek();if(!a||a.type!=="IDENT"&&a.type!=="UNIT")throw chunk6SYU4MH7_cjs.c.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:a?.type??"end of input"});e.consume(),_(t,n,a.value),i?_(t,i,a.value):(t.emitOpcode(10),t.emitNumber(0)),A(t,a.value),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(69),t.emitIndex(3);}};var b=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"der");e.consume("COMMA");let i=B(e,"der");_(t,n,i),A(t,i),e.match("COMMA")?e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t):(t.emitOpcode(10),t.emitNumber(1)),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(70),t.emitIndex(3);}};var F=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"integral");e.consume("COMMA");let i=B(e,"integral");_(t,n,i),A(t,i),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(71),t.emitIndex(2);}};var w=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"taylor");e.consume("COMMA");let i=B(e,"taylor");_(t,n,i),A(t,i),e.consume("EQUALS"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("COMMA"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(72),t.emitIndex(4);}};var Y=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=0;do e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),n++;while(e.match("COMMA"));e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(73),t.emitIndex(n);}};var v=class{constructor(){this.category="Symbolic";}parse(e,o,t){t.emitOpcode(10),t.emitNumber(Number(o.value)),t.emitOpcode(51),t.emitIndex(74),t.emitIndex(1);}};var U=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(75),t.emitIndex(1);}};var $=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(76),t.emitIndex(1);}};var z=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(77),t.emitIndex(1);}};var j=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(78),t.emitIndex(1);}};var G=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(79),t.emitIndex(1);}};function ae(r=75){return {name:"symbolic:imaginary-literal",priority:r,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["i"]}],match(e,o){let t=e[o];if(!t||t.type!=="NUMBER")return null;let n=e[o+1];return !n||n.type!=="IDENT"||n.value!=="i"||n.offset!==t.offset+t.value.length||e[o+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new chunk72J5V7SN_cjs.a("IMAGINARY",chunkYBQOQTVL_cjs.c("IMAGINARY"),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"symbolic:imaginary-literal"}}}}var se={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function me(r=80){return {name:"symbolic:call",priority:r,shape:[{types:["IDENT"],values:Object.keys(se)},{types:["LPAREN"]}],match(e,o){let t=e[o];if(!t||t.type!=="IDENT")return null;let n=se[t.value.toLowerCase()];return !n||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunk72J5V7SN_cjs.a(n,chunkYBQOQTVL_cjs.c(n),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"symbolic:call"}}}}var le=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"expanding.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"factoring.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"solving-equations.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"cancelling-fractions.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"splitting-fractions.md"}],Ye={name:"solve-symbolic",normalizerRules:[me(),ae()],prefixParselets:{EXPAND_FN:new M,FACTOR_FN:new S,SOLVE_FN:new k,DER_FN:new b,INTEGRAL_FN:new F,TAYLOR_FN:new w,JACOBIAN_FN:new Y,IMAGINARY:new v,CONJ_FN:new U,RE_FN:new $,IM_FN:new z,CANCEL_FN:new j,APART_FN:new G},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},ve=new Set(le.map(r=>r.tokenType));function Ue(r){return r.some(e=>ve.has(e.type))}var de=r=>chunkJVIUA2PL_cjs.a("tag",r.toLowerCase());function $e(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ce=/(?:total|sum|average|count)\s+of\s+$/i,ue=64,Z=/(?:^|[^0-9A-Za-z_])#([0-9A-Za-z_-]+)(?![0-9A-Za-z_-])/g;function yr(r,e,o){let t=pe(r);return t.members.length===0&&t.queries.length===0?{reads:e,writes:o}:{reads:t.queries.length===0?e:[...e,...t.queries.map(de)],writes:t.members.length===0?o:[...o,...t.members.map(de)]}}function Nr(r){let e=pe(r).members;for(let o=0;o<e.length;o++)e[o]=e[o].toLowerCase();return e}function pe(r){let e=[],o=[],t=r.search(/\S/);Z.lastIndex=0;for(let n=Z.exec(r);n!==null;n=Z.exec(r)){let i=n.index+n[0].indexOf("#");if(t===i)continue;let a=n[1];if(ce.test(r.slice(Math.max(0,i-ue),i))){o.push(a);continue}e.push(a);}return {members:e,queries:o}}function Ir(r,e){if(e==="")return false;let o=new RegExp(`(?:^|[^0-9A-Za-z_])#${$e(e)}(?![0-9A-Za-z_-])`,"gi"),t=r.search(/\S/);for(let n=o.exec(r);n!==null;n=o.exec(r)){let i=n.index+n[0].indexOf("#");if(t!==i&&!ce.test(r.slice(Math.max(0,i-ue),i)))return true}return false}var ze=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function fe(r,e){let o=r.trim();if(o.length>=2&&o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),!ze.test(o))return null;let t=e.parseIso8601(o);return Number.isNaN(t)?null:t}var je=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function Tr(r){let e=je.exec(r.trim());if(e===null||e[1]===void 0)return {grain:"date"};let o=e[2];if(o===void 0)return {grain:"datetime"};if(o==="Z")return {grain:"instant",zone:chunkE4HAKNBQ_cjs.f(0)};let t=o[0]==="-"?-1:1,n=o.slice(1).replace(":",""),i=Number(n.slice(0,2))*60+Number(n.slice(2));return {grain:"instant",zone:chunkE4HAKNBQ_cjs.f(t*i)}}function _r(r,e){let o=e.fields(r),t=N=>String(N).padStart(2,"0"),n=o.year,i=t(o.month0+1),a=t(o.day),m=t(o.hour),d=t(o.minute),f=t(o.second),l=e.utcOffsetMinutes(r),p=l>=0?"+":"-",y=Math.abs(l),u=t(Math.floor(y/60)),s=t(y%60);return `${n}-${i}-${a}T${m}:${d}:${f}${p}${u}:${s}`}var Ge=1e12;function Er(r){return Math.abs(r)>=Ge?r:r*1e3}var Ve=Date.UTC(2026,3,3),ye,R,K=new Map;function He(){return typeof Intl=="object"&&Intl!==null?Intl.DateTimeFormat:void 0}function Ne(){let r=He();r!==ye&&(ye=r,R=void 0,K.clear());}function Je(){if(Ne(),R!==void 0)return R;try{let r=new Intl.DateTimeFormat("ja-JP").resolvedOptions().locale;R=typeof r=="string"&&r.startsWith("ja");}catch{R=false;}return R}function Ie(){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function")return null;try{let r=new Intl.DateTimeFormat().resolvedOptions().locale;return typeof r=="string"&&r.length>0?r:null}catch{return null}}function xe(r){Ne();let e=K.get(r);if(e!==void 0)return e;let o=We(r);return K.set(r,o),o}function We(r){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function"||!Je())return null;try{if(typeof Intl.DateTimeFormat.supportedLocalesOf=="function"&&Intl.DateTimeFormat.supportedLocalesOf([r]).length===0)return null;let e=new Intl.DateTimeFormat(r,{calendar:"gregory",numberingSystem:"latn",timeZone:"UTC",year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ve);if(!Array.isArray(e))return null;let o=e.filter(t=>t.type==="year"||t.type==="month"||t.type==="day").map(t=>t.type[0].toUpperCase()).join("");return o==="DMY"||o==="MDY"||o==="YMD"?o:null}catch{return null}}var C={DATE_INPUT_LOCALE_INVALID:"DATE_INPUT_LOCALE_INVALID",DATE_ORDER_MISMATCH:"DATE_ORDER_MISMATCH",DATE_NOT_A_CALENDAR_DAY:"DATE_NOT_A_CALENDAR_DAY"};function Ze(r){if(typeof Intl!="object"||Intl===null||typeof Intl.getCanonicalLocales!="function")return true;try{return Intl.getCanonicalLocales(r),!0}catch{return false}}function Rr(r){let e=r.inputLocale;if(e!==void 0&&!Ze(e))throw chunk6SYU4MH7_cjs.c.config(C.DATE_INPUT_LOCALE_INVALID,`date.inputLocale "${e}" is not a BCP-47 locale tag. Use a tag Intl accepts, for example "en-US".`,{inputLocale:e});let o=r.onAmbiguous,t=r.inputOrder;if(t==="DMY"||t==="MDY"||t==="YMD")return Object.freeze({order:t,orderSource:"config",onAmbiguous:o});if(t==="locale"){let n=e??Ie();if(n!=null){let i=xe(n);if(i!==null)return Object.freeze({order:i,orderSource:e!==void 0?"locale":"host-locale",locale:n,onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"fallback",onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"separator",onAmbiguous:o})}var Te=["January","February","March","April","May","June","July","August","September","October","November","December"],q=/^\d{1,2}$/,X=/^\d{4}$/;function Ke(r,e,o,t){let n=q.test(r),i=q.test(e),a=q.test(o);return t==="hyphen"&&X.test(r)&&i&&a?"iso":n&&i&&X.test(o)?"year-last-4":t==="slash"&&X.test(r)&&i&&a?"year-first-4":n&&i&&a?"short":"none"}function qe(r){if(r.length===4)return Number(r);if(r.length===2){let e=Number(r);return e<=68?2e3+e:1900+e}return null}function O(r,e,o){return e<1||e>12||r<1?false:r<=chunkE4HAKNBQ_cjs.b(o,e-1)}function _e(r,e,o){return e<1||e>12?`there is no month ${e}`:r<1?`there is no day ${r}`:`${Te[e-1]} ${o} has ${chunkE4HAKNBQ_cjs.b(o,e-1)} days`}function P(r,e,o){return `${r} ${Te[e-1]} ${o}`}function Q(r,e,o){let t=n=>String(n).padStart(2,"0");return `${String(o).padStart(4,"0")}-${t(e)}-${t(r)}`}function V(r,e,o){return r==="DMY"?{day:Number(e),month:Number(o)}:{day:Number(o),month:Number(e)}}function D(r){return r==="DMY"?"day first":r==="MDY"?"month first":"year first"}function Xe(r){return r==="hyphen"?"MDY":"DMY"}function te(r,e,o,t){let[n,i,a]=r.groups,m=Ke(n,i,a,r.separator),d=r.separator!=="dot",f=o==="refuse"||!d;if(m==="none")return {kind:"arithmetic"};if(m==="iso"){let g=Number(n),x=Number(i),I=Number(a);return O(I,x,g)?{kind:"date",day:I,month:x,year:g,order:"ISO",shortYear:false}:f?ee(r.text,I,x,g):{kind:"arithmetic"}}if(m==="year-first-4"){if(e!=="YMD")return {kind:"arithmetic"};let g=Number(n),x=Number(i),I=Number(a);return O(I,x,g)?{kind:"date",day:I,month:x,year:g,order:"YMD",shortYear:false}:{kind:"arithmetic"}}let l=qe(a);if(l===null)return {kind:"arithmetic"};let p=a.length===2;if(e==="YMD")return !f||m==="short"&&d?{kind:"arithmetic"}:Qe(r.text,n,i,l);let y=e==="auto"?Xe(r.separator):e,u=y==="DMY"?"MDY":"DMY",s=V(y,n,i),N=V(u,n,i);if(O(s.day,s.month,l)){let x=(N.day!==s.day||N.month!==s.month)&&O(N.day,N.month,l)?Q(N.day,N.month,l):void 0;return {kind:"date",day:s.day,month:s.month,year:l,order:y,shortYear:p,alternative:x}}return !f||m==="short"&&d?{kind:"arithmetic"}:O(N.day,N.month,l)?{kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`"${r.text}" is not a date read ${D(y)}: ${_e(s.day,s.month,l)}. Read ${D(u)} it is ${P(N.day,N.month,l)}. Set date.inputOrder to "${u}" to read numeric dates ${D(u)}.`}:ee(r.text,s.day,s.month,l)}function ee(r,e,o,t){return {kind:"refuse",code:C.DATE_NOT_A_CALENDAR_DAY,message:`"${r}" is not a real date: ${_e(e,o,t)}.`}}function Qe(r,e,o,t,n){let i=V("DMY",e,o),a=V("MDY",e,o),m=O(i.day,i.month,t),d=O(a.day,a.month,t);if(!m&&!d)return ee(r,i.day,i.month,t);let f=`"${r}" is not a date read year first.`,l=i.day===a.day&&i.month===a.month;if(m&&d&&!l)return {kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`${f} Read day first it is ${P(i.day,i.month,t)} and month first ${P(a.day,a.month,t)}. Write it as ${Q(i.day,i.month,t)}, or set date.inputOrder to "DMY" or "MDY".`};let p=m?i:a,y=m?"DMY":"MDY";return {kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`${f} Read ${D(y)} it is ${P(p.day,p.month,t)}. Write it as ${Q(p.day,p.month,t)}, or set date.inputOrder to "${y}".`}}function et(r,e){if(r.orderSource==="iso")return "ISO";if(r.orderSource==="spelled")return "with the month spelled out";let o=r.order===null||r.order==="ISO"||r.order==="spelled"?"as written":D(r.order);switch(r.orderSource){case "config":return `${o}, from date.inputOrder`;case "locale":return `${o}, from the locale ${r.locale}`;case "host-locale":return `${o}, from the host locale ${r.locale}`;case "fallback":return `${o}, the default for a ${e} date, because the host locale could not be read`;default:return `${o}, the default for a ${e} date`}}function ge(r){let[e,o,t]=r.split("-").map(Number);return P(t,o,e)}function tt(r,e,o){if(r.iso===null)return o??`"${r.text}" is not a date this engine can read.`;let t=`${r.text} read as ${ge(r.iso)}, ${et(r,e)}.`;if(r.alternative!==void 0&&r.order!==null&&r.order!=="ISO"&&r.order!=="spelled"){let n=r.order==="DMY"?"Month first":"Day first";t+=` ${n} would be ${ge(r.alternative)}.`;}return r.shortYear&&(t+=` The two-digit year ${r.text.slice(-2)} was read as ${r.iso.slice(0,4)}.`),t}function Pr(r,e,o){return {...r,note:tt(r,e,o),needsNote:r.contested||r.shortYear||r.iso===null}}function Dr(r){let e=/^(\d+)([/-])(\d+)\2(\d+)$/.exec(r);if(e!==null)return {text:r,groups:[e[1],e[3],e[4]],separator:e[2]==="-"?"hyphen":"slash"};let o=/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$/.exec(r);return o!==null?{text:r,groups:[o[1],o[2],o[3]],separator:"dot"}:null}var re="DATETIME_LITERAL",Le=chunkYBQOQTVL_cjs.c(re),he="DATETIME_LITERAL_UNREADABLE",rt=chunkYBQOQTVL_cjs.c(he),H=/^\d+$/,ot=/^\d{1,2}\.\d{1,2}$/,nt=/^\.(\d{2}|\d{4})$/;function it(r){for(let e=0;e<r.length-1;e++){let o=r[e];if((o.sourceEnd??o.offset+o.text.length)!==r[e+1].offset)return false}return true}function Ee(r,e,o,t,n,i){if(e<1||e>12||r<1||r>31)return null;let a=i.localMidnight(o,e-1,r),m=i.fields(a);if(m.year!==o||m.month0!==e-1||m.day!==r)return null;let d=t[0],f=t.map(p=>p.value).join(""),l=new chunk72J5V7SN_cjs.a(re,Le,String(a),f,d.offset,0,d.line,d.col);return {consumed:t.length,replacement:[l],ruleName:n}}function at(r){let e="",o=-1;for(let t of r){let n=t.text??t.value;o>=0&&t.offset>o&&(e+=" "),e+=n,o=t.sourceEnd??t.offset+n.length;}return e}function Ae(r,e,o,t){let n=o[0],i=at(o),a=new chunk72J5V7SN_cjs.a(he,rt,i,i,n.offset,0,n.line,n.col);return a.fault={code:r,message:e},{consumed:o.length,replacement:[a],ruleName:t}}var st=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?/,mt=new Set(["NUMBER","MINUS","PLUS","COLON","IDENT"]),lt=16;function dt(r,e,o,t){let n=r[e];if(n.sourceEnd!==void 0)return null;let i=n.text,a=n.offset+n.text.length,m=[n];for(let u=e+1;u<r.length&&m.length<lt;u++){let s=r[u];if(s.sourceEnd!==void 0||s.offset!==a||!mt.has(s.type))break;i+=s.text,a=s.offset+s.text.length,m.push(s);}let d=st.exec(i);if(d===null)return null;let f=0,l=0;for(let u of m)if(l+=u.text.length,f++,l>=d[0].length)break;if(l!==d[0].length)return null;let p=fe(d[0],t);if(p===null)return null;let y=new chunk72J5V7SN_cjs.a(re,Le,String(p),d[0],n.offset,0,n.line,n.col,n.offset+d[0].length);return {consumed:f,replacement:[y],ruleName:o}}function wr(r=()=>"auto",e=()=>chunkEQNKDTMX_cjs.b,o=()=>"refuse"){return {name:"datetime:date-literal",priority:70,shape:[{types:["NUMBER"]}],match(t,n){let i=t[n];if(i.type!=="NUMBER")return null;let a=e();if(ot.test(i.value)){let s=t[n+1];if(s&&s.type==="NUMBER"&&nt.test(s.value)){let[N,g]=i.value.split("."),x={text:`${i.value}${s.value}`,groups:[N,g,s.value.slice(1)],separator:"dot"},I=te(x,r(),o());if(I.kind==="date")return Ee(I.day,I.month,I.year,[i,s],"datetime:date-literal:dot",a);if(I.kind==="refuse")return Ae(I.code,I.message,[i,s],"datetime:date-literal:dot:unreadable")}return null}if(i.value.length===4&&H.test(i.value)){let s=dt(t,n,"datetime:date-literal:iso-timestamp",a);if(s)return s}if(!H.test(i.value))return null;let m=t[n+1];if(!m||m.type!=="SLASH"&&m.type!=="MINUS")return null;let d=t[n+2],f=t[n+3],l=t[n+4];if(!d||d.type!=="NUMBER"||!H.test(d.value)||!f||f.type!==m.type||!l||l.type!=="NUMBER"||!H.test(l.value))return null;let p=[i,m,d,f,l];if(!it(p))return null;let y={text:p.map(s=>s.value).join(""),groups:[i.value,d.value,l.value],separator:m.type==="MINUS"?"hyphen":"slash"},u=te(y,r(),o());return u.kind==="arithmetic"?null:u.kind==="refuse"?Ae(u.code,u.message,p,"datetime:date-literal:unreadable"):Ee(u.day,u.month,u.year,p,`datetime:date-literal:${u.order.toLowerCase()}`,a)}}}exports.a=yr;exports.b=Nr;exports.c=Ir;exports.d=Ye;exports.e=Ue;exports.f=fe;exports.g=Tr;exports.h=_r;exports.i=Er;exports.j=C;exports.k=Rr;exports.l=Ke;exports.m=_e;exports.n=Q;exports.o=te;exports.p=Pr;exports.q=Dr;exports.r=re;exports.s=he;exports.t=Ee;exports.u=at;exports.v=Ae;exports.w=wr;//# sourceMappingURL=chunk-ZBXB3HDZ.cjs.map
2
- //# sourceMappingURL=chunk-ZBXB3HDZ.cjs.map
1
+ 'use strict';var chunkK3PZ66XR_cjs=require('./chunk-K3PZ66XR.cjs'),chunk6ADFAXTZ_cjs=require('./chunk-6ADFAXTZ.cjs'),chunkEQNKDTMX_cjs=require('./chunk-EQNKDTMX.cjs'),chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),chunk72J5V7SN_cjs=require('./chunk-72J5V7SN.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var M=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(67),t.emitIndex(1);}};var S=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(68),t.emitIndex(1);}};function B(r,e){let o=r.peek();if(!o||o.type!=="IDENT"&&o.type!=="UNIT")throw chunk6SYU4MH7_cjs.c.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${e} needs the name of an unknown here, as in ${e}(x^2, x).`,{found:o?.type??"end of input"});return r.consume(),o.value}function A(r,e){r.emitOpcode(13),r.emitString(e);}function T(r,e,o){let t=new chunkK3PZ66XR_cjs.d(e.pluginIndexMap);r.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),r.setBuilder(e);let n=t.build();if(n.hasAsync)throw chunk6SYU4MH7_cjs.c.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${o}'s expression must be synchronous (no weather/stocks/currency calls).`);return n}function _(r,e,o){let t=r.emitAnonymousBody([o],e);r.emitOpcode(159),r.emitIndex(t);}var k=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"solve"),i=e.match("EQUALS")?T(e,t,"solve"):null;e.consume("COMMA");let a=e.peek();if(!a||a.type!=="IDENT"&&a.type!=="UNIT")throw chunk6SYU4MH7_cjs.c.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:a?.type??"end of input"});e.consume(),_(t,n,a.value),i?_(t,i,a.value):(t.emitOpcode(10),t.emitNumber(0)),A(t,a.value),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(69),t.emitIndex(3);}};var b=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"der");e.consume("COMMA");let i=B(e,"der");_(t,n,i),A(t,i),e.match("COMMA")?e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t):(t.emitOpcode(10),t.emitNumber(1)),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(70),t.emitIndex(3);}};var F=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"integral");e.consume("COMMA");let i=B(e,"integral");_(t,n,i),A(t,i),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(71),t.emitIndex(2);}};var w=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=T(e,t,"taylor");e.consume("COMMA");let i=B(e,"taylor");_(t,n,i),A(t,i),e.consume("EQUALS"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("COMMA"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(72),t.emitIndex(4);}};var Y=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN");let n=0;do e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),n++;while(e.match("COMMA"));e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(73),t.emitIndex(n);}};var v=class{constructor(){this.category="Symbolic";}parse(e,o,t){t.emitOpcode(10),t.emitNumber(Number(o.value)),t.emitOpcode(51),t.emitIndex(74),t.emitIndex(1);}};var U=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(75),t.emitIndex(1);}};var $=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(76),t.emitIndex(1);}};var z=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(77),t.emitIndex(1);}};var j=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(78),t.emitIndex(1);}};var G=class{constructor(){this.category="Symbolic";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(79),t.emitIndex(1);}};function ae(r=75){return {name:"symbolic:imaginary-literal",priority:r,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["i"]}],match(e,o){let t=e[o];if(!t||t.type!=="NUMBER")return null;let n=e[o+1];return !n||n.type!=="IDENT"||n.value!=="i"||n.offset!==t.offset+t.value.length||e[o+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new chunk72J5V7SN_cjs.a("IMAGINARY",chunkYBQOQTVL_cjs.c("IMAGINARY"),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"symbolic:imaginary-literal"}}}}var se={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function me(r=80){return {name:"symbolic:call",priority:r,shape:[{types:["IDENT"],values:Object.keys(se)},{types:["LPAREN"]}],match(e,o){let t=e[o];if(!t||t.type!=="IDENT")return null;let n=se[t.value.toLowerCase()];return !n||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunk72J5V7SN_cjs.a(n,chunkYBQOQTVL_cjs.c(n),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"symbolic:call"}}}}var le=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"expanding.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"factoring.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"solving-equations.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"cancelling-fractions.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"splitting-fractions.md"}],Ye={name:"solve-symbolic",normalizerRules:[me(),ae()],prefixParselets:{EXPAND_FN:new M,FACTOR_FN:new S,SOLVE_FN:new k,DER_FN:new b,INTEGRAL_FN:new F,TAYLOR_FN:new w,JACOBIAN_FN:new Y,IMAGINARY:new v,CONJ_FN:new U,RE_FN:new $,IM_FN:new z,CANCEL_FN:new j,APART_FN:new G},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},ve=new Set(le.map(r=>r.tokenType));function Ue(r){return r.some(e=>ve.has(e.type))}var de=r=>chunk6ADFAXTZ_cjs.a("tag",r.toLowerCase());function $e(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ce=/(?:total|sum|average|count)\s+of\s+$/i,ue=64,Z=/(?:^|[^0-9A-Za-z_])#([0-9A-Za-z_-]+)(?![0-9A-Za-z_-])/g;function yr(r,e,o){let t=pe(r);return t.members.length===0&&t.queries.length===0?{reads:e,writes:o}:{reads:t.queries.length===0?e:[...e,...t.queries.map(de)],writes:t.members.length===0?o:[...o,...t.members.map(de)]}}function Nr(r){let e=pe(r).members;for(let o=0;o<e.length;o++)e[o]=e[o].toLowerCase();return e}function pe(r){let e=[],o=[],t=r.search(/\S/);Z.lastIndex=0;for(let n=Z.exec(r);n!==null;n=Z.exec(r)){let i=n.index+n[0].indexOf("#");if(t===i)continue;let a=n[1];if(ce.test(r.slice(Math.max(0,i-ue),i))){o.push(a);continue}e.push(a);}return {members:e,queries:o}}function Ir(r,e){if(e==="")return false;let o=new RegExp(`(?:^|[^0-9A-Za-z_])#${$e(e)}(?![0-9A-Za-z_-])`,"gi"),t=r.search(/\S/);for(let n=o.exec(r);n!==null;n=o.exec(r)){let i=n.index+n[0].indexOf("#");if(t!==i&&!ce.test(r.slice(Math.max(0,i-ue),i)))return true}return false}var ze=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function fe(r,e){let o=r.trim();if(o.length>=2&&o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),!ze.test(o))return null;let t=e.parseIso8601(o);return Number.isNaN(t)?null:t}var je=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function Tr(r){let e=je.exec(r.trim());if(e===null||e[1]===void 0)return {grain:"date"};let o=e[2];if(o===void 0)return {grain:"datetime"};if(o==="Z")return {grain:"instant",zone:chunkE4HAKNBQ_cjs.f(0)};let t=o[0]==="-"?-1:1,n=o.slice(1).replace(":",""),i=Number(n.slice(0,2))*60+Number(n.slice(2));return {grain:"instant",zone:chunkE4HAKNBQ_cjs.f(t*i)}}function _r(r,e){let o=e.fields(r),t=N=>String(N).padStart(2,"0"),n=o.year,i=t(o.month0+1),a=t(o.day),m=t(o.hour),d=t(o.minute),f=t(o.second),l=e.utcOffsetMinutes(r),p=l>=0?"+":"-",y=Math.abs(l),u=t(Math.floor(y/60)),s=t(y%60);return `${n}-${i}-${a}T${m}:${d}:${f}${p}${u}:${s}`}var Ge=1e12;function Er(r){return Math.abs(r)>=Ge?r:r*1e3}var Ve=Date.UTC(2026,3,3),ye,R,K=new Map;function He(){return typeof Intl=="object"&&Intl!==null?Intl.DateTimeFormat:void 0}function Ne(){let r=He();r!==ye&&(ye=r,R=void 0,K.clear());}function Je(){if(Ne(),R!==void 0)return R;try{let r=new Intl.DateTimeFormat("ja-JP").resolvedOptions().locale;R=typeof r=="string"&&r.startsWith("ja");}catch{R=false;}return R}function Ie(){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function")return null;try{let r=new Intl.DateTimeFormat().resolvedOptions().locale;return typeof r=="string"&&r.length>0?r:null}catch{return null}}function xe(r){Ne();let e=K.get(r);if(e!==void 0)return e;let o=We(r);return K.set(r,o),o}function We(r){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function"||!Je())return null;try{if(typeof Intl.DateTimeFormat.supportedLocalesOf=="function"&&Intl.DateTimeFormat.supportedLocalesOf([r]).length===0)return null;let e=new Intl.DateTimeFormat(r,{calendar:"gregory",numberingSystem:"latn",timeZone:"UTC",year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ve);if(!Array.isArray(e))return null;let o=e.filter(t=>t.type==="year"||t.type==="month"||t.type==="day").map(t=>t.type[0].toUpperCase()).join("");return o==="DMY"||o==="MDY"||o==="YMD"?o:null}catch{return null}}var C={DATE_INPUT_LOCALE_INVALID:"DATE_INPUT_LOCALE_INVALID",DATE_ORDER_MISMATCH:"DATE_ORDER_MISMATCH",DATE_NOT_A_CALENDAR_DAY:"DATE_NOT_A_CALENDAR_DAY"};function Ze(r){if(typeof Intl!="object"||Intl===null||typeof Intl.getCanonicalLocales!="function")return true;try{return Intl.getCanonicalLocales(r),!0}catch{return false}}function Rr(r){let e=r.inputLocale;if(e!==void 0&&!Ze(e))throw chunk6SYU4MH7_cjs.c.config(C.DATE_INPUT_LOCALE_INVALID,`date.inputLocale "${e}" is not a BCP-47 locale tag. Use a tag Intl accepts, for example "en-US".`,{inputLocale:e});let o=r.onAmbiguous,t=r.inputOrder;if(t==="DMY"||t==="MDY"||t==="YMD")return Object.freeze({order:t,orderSource:"config",onAmbiguous:o});if(t==="locale"){let n=e??Ie();if(n!=null){let i=xe(n);if(i!==null)return Object.freeze({order:i,orderSource:e!==void 0?"locale":"host-locale",locale:n,onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"fallback",onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"separator",onAmbiguous:o})}var Te=["January","February","March","April","May","June","July","August","September","October","November","December"],q=/^\d{1,2}$/,X=/^\d{4}$/;function Ke(r,e,o,t){let n=q.test(r),i=q.test(e),a=q.test(o);return t==="hyphen"&&X.test(r)&&i&&a?"iso":n&&i&&X.test(o)?"year-last-4":t==="slash"&&X.test(r)&&i&&a?"year-first-4":n&&i&&a?"short":"none"}function qe(r){if(r.length===4)return Number(r);if(r.length===2){let e=Number(r);return e<=68?2e3+e:1900+e}return null}function O(r,e,o){return e<1||e>12||r<1?false:r<=chunkE4HAKNBQ_cjs.b(o,e-1)}function _e(r,e,o){return e<1||e>12?`there is no month ${e}`:r<1?`there is no day ${r}`:`${Te[e-1]} ${o} has ${chunkE4HAKNBQ_cjs.b(o,e-1)} days`}function P(r,e,o){return `${r} ${Te[e-1]} ${o}`}function Q(r,e,o){let t=n=>String(n).padStart(2,"0");return `${String(o).padStart(4,"0")}-${t(e)}-${t(r)}`}function V(r,e,o){return r==="DMY"?{day:Number(e),month:Number(o)}:{day:Number(o),month:Number(e)}}function D(r){return r==="DMY"?"day first":r==="MDY"?"month first":"year first"}function Xe(r){return r==="hyphen"?"MDY":"DMY"}function te(r,e,o,t){let[n,i,a]=r.groups,m=Ke(n,i,a,r.separator),d=r.separator!=="dot",f=o==="refuse"||!d;if(m==="none")return {kind:"arithmetic"};if(m==="iso"){let g=Number(n),x=Number(i),I=Number(a);return O(I,x,g)?{kind:"date",day:I,month:x,year:g,order:"ISO",shortYear:false}:f?ee(r.text,I,x,g):{kind:"arithmetic"}}if(m==="year-first-4"){if(e!=="YMD")return {kind:"arithmetic"};let g=Number(n),x=Number(i),I=Number(a);return O(I,x,g)?{kind:"date",day:I,month:x,year:g,order:"YMD",shortYear:false}:{kind:"arithmetic"}}let l=qe(a);if(l===null)return {kind:"arithmetic"};let p=a.length===2;if(e==="YMD")return !f||m==="short"&&d?{kind:"arithmetic"}:Qe(r.text,n,i,l);let y=e==="auto"?Xe(r.separator):e,u=y==="DMY"?"MDY":"DMY",s=V(y,n,i),N=V(u,n,i);if(O(s.day,s.month,l)){let x=(N.day!==s.day||N.month!==s.month)&&O(N.day,N.month,l)?Q(N.day,N.month,l):void 0;return {kind:"date",day:s.day,month:s.month,year:l,order:y,shortYear:p,alternative:x}}return !f||m==="short"&&d?{kind:"arithmetic"}:O(N.day,N.month,l)?{kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`"${r.text}" is not a date read ${D(y)}: ${_e(s.day,s.month,l)}. Read ${D(u)} it is ${P(N.day,N.month,l)}. Set date.inputOrder to "${u}" to read numeric dates ${D(u)}.`}:ee(r.text,s.day,s.month,l)}function ee(r,e,o,t){return {kind:"refuse",code:C.DATE_NOT_A_CALENDAR_DAY,message:`"${r}" is not a real date: ${_e(e,o,t)}.`}}function Qe(r,e,o,t,n){let i=V("DMY",e,o),a=V("MDY",e,o),m=O(i.day,i.month,t),d=O(a.day,a.month,t);if(!m&&!d)return ee(r,i.day,i.month,t);let f=`"${r}" is not a date read year first.`,l=i.day===a.day&&i.month===a.month;if(m&&d&&!l)return {kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`${f} Read day first it is ${P(i.day,i.month,t)} and month first ${P(a.day,a.month,t)}. Write it as ${Q(i.day,i.month,t)}, or set date.inputOrder to "DMY" or "MDY".`};let p=m?i:a,y=m?"DMY":"MDY";return {kind:"refuse",code:C.DATE_ORDER_MISMATCH,message:`${f} Read ${D(y)} it is ${P(p.day,p.month,t)}. Write it as ${Q(p.day,p.month,t)}, or set date.inputOrder to "${y}".`}}function et(r,e){if(r.orderSource==="iso")return "ISO";if(r.orderSource==="spelled")return "with the month spelled out";let o=r.order===null||r.order==="ISO"||r.order==="spelled"?"as written":D(r.order);switch(r.orderSource){case "config":return `${o}, from date.inputOrder`;case "locale":return `${o}, from the locale ${r.locale}`;case "host-locale":return `${o}, from the host locale ${r.locale}`;case "fallback":return `${o}, the default for a ${e} date, because the host locale could not be read`;default:return `${o}, the default for a ${e} date`}}function ge(r){let[e,o,t]=r.split("-").map(Number);return P(t,o,e)}function tt(r,e,o){if(r.iso===null)return o??`"${r.text}" is not a date this engine can read.`;let t=`${r.text} read as ${ge(r.iso)}, ${et(r,e)}.`;if(r.alternative!==void 0&&r.order!==null&&r.order!=="ISO"&&r.order!=="spelled"){let n=r.order==="DMY"?"Month first":"Day first";t+=` ${n} would be ${ge(r.alternative)}.`;}return r.shortYear&&(t+=` The two-digit year ${r.text.slice(-2)} was read as ${r.iso.slice(0,4)}.`),t}function Pr(r,e,o){return {...r,note:tt(r,e,o),needsNote:r.contested||r.shortYear||r.iso===null}}function Dr(r){let e=/^(\d+)([/-])(\d+)\2(\d+)$/.exec(r);if(e!==null)return {text:r,groups:[e[1],e[3],e[4]],separator:e[2]==="-"?"hyphen":"slash"};let o=/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$/.exec(r);return o!==null?{text:r,groups:[o[1],o[2],o[3]],separator:"dot"}:null}var re="DATETIME_LITERAL",Le=chunkYBQOQTVL_cjs.c(re),he="DATETIME_LITERAL_UNREADABLE",rt=chunkYBQOQTVL_cjs.c(he),H=/^\d+$/,ot=/^\d{1,2}\.\d{1,2}$/,nt=/^\.(\d{2}|\d{4})$/;function it(r){for(let e=0;e<r.length-1;e++){let o=r[e];if((o.sourceEnd??o.offset+o.text.length)!==r[e+1].offset)return false}return true}function Ee(r,e,o,t,n,i){if(e<1||e>12||r<1||r>31)return null;let a=i.localMidnight(o,e-1,r),m=i.fields(a);if(m.year!==o||m.month0!==e-1||m.day!==r)return null;let d=t[0],f=t.map(p=>p.value).join(""),l=new chunk72J5V7SN_cjs.a(re,Le,String(a),f,d.offset,0,d.line,d.col);return {consumed:t.length,replacement:[l],ruleName:n}}function at(r){let e="",o=-1;for(let t of r){let n=t.text??t.value;o>=0&&t.offset>o&&(e+=" "),e+=n,o=t.sourceEnd??t.offset+n.length;}return e}function Ae(r,e,o,t){let n=o[0],i=at(o),a=new chunk72J5V7SN_cjs.a(he,rt,i,i,n.offset,0,n.line,n.col);return a.fault={code:r,message:e},{consumed:o.length,replacement:[a],ruleName:t}}var st=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?/,mt=new Set(["NUMBER","MINUS","PLUS","COLON","IDENT"]),lt=16;function dt(r,e,o,t){let n=r[e];if(n.sourceEnd!==void 0)return null;let i=n.text,a=n.offset+n.text.length,m=[n];for(let u=e+1;u<r.length&&m.length<lt;u++){let s=r[u];if(s.sourceEnd!==void 0||s.offset!==a||!mt.has(s.type))break;i+=s.text,a=s.offset+s.text.length,m.push(s);}let d=st.exec(i);if(d===null)return null;let f=0,l=0;for(let u of m)if(l+=u.text.length,f++,l>=d[0].length)break;if(l!==d[0].length)return null;let p=fe(d[0],t);if(p===null)return null;let y=new chunk72J5V7SN_cjs.a(re,Le,String(p),d[0],n.offset,0,n.line,n.col,n.offset+d[0].length);return {consumed:f,replacement:[y],ruleName:o}}function wr(r=()=>"auto",e=()=>chunkEQNKDTMX_cjs.b,o=()=>"refuse"){return {name:"datetime:date-literal",priority:70,shape:[{types:["NUMBER"]}],match(t,n){let i=t[n];if(i.type!=="NUMBER")return null;let a=e();if(ot.test(i.value)){let s=t[n+1];if(s&&s.type==="NUMBER"&&nt.test(s.value)){let[N,g]=i.value.split("."),x={text:`${i.value}${s.value}`,groups:[N,g,s.value.slice(1)],separator:"dot"},I=te(x,r(),o());if(I.kind==="date")return Ee(I.day,I.month,I.year,[i,s],"datetime:date-literal:dot",a);if(I.kind==="refuse")return Ae(I.code,I.message,[i,s],"datetime:date-literal:dot:unreadable")}return null}if(i.value.length===4&&H.test(i.value)){let s=dt(t,n,"datetime:date-literal:iso-timestamp",a);if(s)return s}if(!H.test(i.value))return null;let m=t[n+1];if(!m||m.type!=="SLASH"&&m.type!=="MINUS")return null;let d=t[n+2],f=t[n+3],l=t[n+4];if(!d||d.type!=="NUMBER"||!H.test(d.value)||!f||f.type!==m.type||!l||l.type!=="NUMBER"||!H.test(l.value))return null;let p=[i,m,d,f,l];if(!it(p))return null;let y={text:p.map(s=>s.value).join(""),groups:[i.value,d.value,l.value],separator:m.type==="MINUS"?"hyphen":"slash"},u=te(y,r(),o());return u.kind==="arithmetic"?null:u.kind==="refuse"?Ae(u.code,u.message,p,"datetime:date-literal:unreadable"):Ee(u.day,u.month,u.year,p,`datetime:date-literal:${u.order.toLowerCase()}`,a)}}}exports.a=yr;exports.b=Nr;exports.c=Ir;exports.d=Ye;exports.e=Ue;exports.f=fe;exports.g=Tr;exports.h=_r;exports.i=Er;exports.j=C;exports.k=Rr;exports.l=Ke;exports.m=_e;exports.n=Q;exports.o=te;exports.p=Pr;exports.q=Dr;exports.r=re;exports.s=he;exports.t=Ee;exports.u=at;exports.v=Ae;exports.w=wr;//# sourceMappingURL=chunk-U54BIYXO.cjs.map
2
+ //# sourceMappingURL=chunk-U54BIYXO.cjs.map