@decimalturn/toml-patch 3.3.1-lite → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +203 -0
- package/dist/toml-patch.d.ts +564 -0
- package/dist/toml-patch.js +84 -0
- package/package.json +106 -14
- package/dist/patch.d.ts +0 -18
- package/dist/patch.js +0 -20
package/package.json
CHANGED
|
@@ -1,30 +1,122 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decimalturn/toml-patch",
|
|
3
|
-
"version": "3.3.1
|
|
4
|
-
"
|
|
3
|
+
"version": "3.3.1",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Tim Hall <tim.hall.engr@gmail.com>",
|
|
6
|
+
"Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting.",
|
|
5
10
|
"homepage": "https://github.com/DecimalTurn/toml-patch",
|
|
6
11
|
"repository": {
|
|
7
12
|
"type": "git",
|
|
8
13
|
"url": "git+https://github.com/DecimalTurn/toml-patch.git"
|
|
9
14
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"toml",
|
|
20
|
+
"patch",
|
|
21
|
+
"edit",
|
|
22
|
+
"parse",
|
|
23
|
+
"stringify",
|
|
24
|
+
"parser",
|
|
25
|
+
"encoder",
|
|
26
|
+
"decoder",
|
|
27
|
+
"preserve-whitespace",
|
|
28
|
+
"preserve-comments",
|
|
29
|
+
"preserve-formatting",
|
|
30
|
+
"edit-in-place"
|
|
31
|
+
],
|
|
12
32
|
"engines": {
|
|
13
33
|
"node": ">=16"
|
|
14
34
|
},
|
|
35
|
+
"type": "module",
|
|
15
36
|
"sideEffects": false,
|
|
16
|
-
"types": "./dist/patch.d.ts",
|
|
17
|
-
"files": [
|
|
18
|
-
"dist/"
|
|
19
|
-
],
|
|
37
|
+
"types": "./dist/toml-patch.d.ts",
|
|
20
38
|
"exports": {
|
|
21
39
|
".": {
|
|
22
|
-
"types": "./dist/patch.d.ts",
|
|
23
|
-
"import": "./dist/patch.js",
|
|
24
|
-
"default": "./dist/patch.js"
|
|
40
|
+
"types": "./dist/toml-patch.d.ts",
|
|
41
|
+
"import": "./dist/toml-patch.js",
|
|
42
|
+
"default": "./dist/toml-patch.js"
|
|
25
43
|
}
|
|
26
44
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@3.3.0",
|
|
47
|
+
"@js-temporal/polyfill": "^0.5.1",
|
|
48
|
+
"@playwright/test": "^1.59.1",
|
|
49
|
+
"@types/dedent": "^1.0.0",
|
|
50
|
+
"@types/js-yaml": "^4.0.0",
|
|
51
|
+
"@types/node": "^24.12.3",
|
|
52
|
+
"benchmark": "^2",
|
|
53
|
+
"dedent": "^1.5.3",
|
|
54
|
+
"glob": "^13.0.0",
|
|
55
|
+
"js-yaml": "4.3.2",
|
|
56
|
+
"jsr": "^0.14.0",
|
|
57
|
+
"mri": "^1",
|
|
58
|
+
"npm-run-all2": "^9.0.0",
|
|
59
|
+
"oxlint": "^1.55.0",
|
|
60
|
+
"rimraf": "^6.0.0",
|
|
61
|
+
"smol-toml": "^1.9.0",
|
|
62
|
+
"tsdown": "^0.23.0",
|
|
63
|
+
"tslib": "^2.0.0",
|
|
64
|
+
"typescript": "7.0.2",
|
|
65
|
+
"vitest": "^5.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": {
|
|
68
|
+
"singleQuote": true,
|
|
69
|
+
"printWidth": 100
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist/toml-patch.js",
|
|
73
|
+
"dist/toml-patch.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"json-comments": {
|
|
76
|
+
"tips": "Please install the JsonComments plugin to enable commenting functionality for JSON files, see: https://github.com/zhangfisher/json_comments_extension",
|
|
77
|
+
"package.json": {
|
|
78
|
+
"devDependencies.js-yaml": "Used by specs/specs.test.ts to parse YAML expected-value fixtures from submodules/spec-tests (https://github.com/iarna/toml-spec-tests).",
|
|
79
|
+
"scripts.bench": "Parse and stringify benchmark over the curated fixtures. Fails the CI job when toml-patch exceeds the maxSlowdown budgets in benchmark/thresholds.toml. Set BENCH_BASELINE to a build path to add the branch comparison.",
|
|
80
|
+
"scripts.bench:all": "Runs the same benchmark over every fixture in both corpora, including the single-type and scaling documents the curated set leaves out."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"dev": "pnpm run typecheck && pnpm run build && npm-run-all2 --parallel test:all specs",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:output": "node scripts/test-debug.mjs",
|
|
87
|
+
"test:js": "vitest run --config vitest.js.config.ts",
|
|
88
|
+
"test:watch": "vitest",
|
|
89
|
+
"test:go": "./run-toml-test.bash",
|
|
90
|
+
"test:playwright": "playwright test",
|
|
91
|
+
"playwright:install": "playwright install --with-deps chromium",
|
|
92
|
+
"test:all": "pnpm run test && pnpm run test:js && pnpm run test:playwright",
|
|
93
|
+
"typecheck": "tsc",
|
|
94
|
+
"specs": "vitest run --config vitest.specs.config.ts",
|
|
95
|
+
"bench": "node benchmark/fixture-benchmark.mjs",
|
|
96
|
+
"bench:all": "node benchmark/fixture-benchmark.mjs --all",
|
|
97
|
+
"benchmark": "npm-run-all2 bench:*",
|
|
98
|
+
"benchmark:ci": "npm-run-all2 \"bench:* -- --sample --versions latest\"",
|
|
99
|
+
"seed-toml": "npx -y tsx scripts/generate-seed-toml.ts",
|
|
100
|
+
"fuzz": "npx -y tsx scripts/fuzz-run.ts --seed 0 --to 9999 --mutations 3 --progress 100",
|
|
101
|
+
"fuzz2": "npx -y tsx scripts/fuzz-run2.ts --seed 0 --to 9999 --mutations 3",
|
|
102
|
+
"fuzz3": "npx -y tsx scripts/fuzz-run3.ts --seed 0 --to 9999 --mutations 3",
|
|
103
|
+
"fuzz4": "npx -y tsx scripts/fuzz-run4.ts --seed 0 --to 9999 --mutations 3",
|
|
104
|
+
"bench:bundle-size": "node benchmark/bundle-size.mjs",
|
|
105
|
+
"bench:parse": "node benchmark/parse-benchmark.mjs",
|
|
106
|
+
"bench:stringify": "node benchmark/stringify-benchmark.mjs",
|
|
107
|
+
"bench:patch": "node benchmark/patch-benchmark.mjs",
|
|
108
|
+
"bench:patch-lite": "node benchmark/patch-lite-bundle-size.mjs",
|
|
109
|
+
"profile": "node benchmark/profile.mjs",
|
|
110
|
+
"build": "rimraf dist && tsdown",
|
|
111
|
+
"build:demo": "node scripts/build-demo.mjs",
|
|
112
|
+
"build:dev": "node scripts/prepare-dev-package.mjs",
|
|
113
|
+
"build:lite": "node scripts/prepare-lite-package.mjs",
|
|
114
|
+
"test:dev": "pnpm run build:dev && node scripts/test-dev-package.mjs",
|
|
115
|
+
"test:lite": "pnpm run build:lite && node scripts/test-lite-package.mjs",
|
|
116
|
+
"lint": "oxlint",
|
|
117
|
+
"lint:fix": "oxlint --fix",
|
|
118
|
+
"check-overrides": "node scripts/check-overrides.mjs",
|
|
119
|
+
"compare-branch-size": "node scripts/compare-branch-size.mjs",
|
|
120
|
+
"publish:jsr": "jsr publish --allow-dirty"
|
|
29
121
|
}
|
|
30
|
-
}
|
|
122
|
+
}
|
package/dist/patch.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/patch-lite.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Applies in-place value edits to an existing TOML document.
|
|
5
|
-
*
|
|
6
|
-
* This is an edit-only distribution: every change must be an edit to an
|
|
7
|
-
* existing scalar value. Added or removed keys, array length changes, array
|
|
8
|
-
* reordering, key renames and scalar/container type changes all throw before
|
|
9
|
-
* the source is mutated. All text outside the edited value spans is preserved
|
|
10
|
-
* byte for byte.
|
|
11
|
-
*
|
|
12
|
-
* @param existing - The original TOML document as a string
|
|
13
|
-
* @param updated - The updated JavaScript object with desired value changes
|
|
14
|
-
* @returns A new TOML string with only the edited values replaced
|
|
15
|
-
*/
|
|
16
|
-
declare function patchLite(existing: string, updated: any): string;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { patchLite as patch };
|
package/dist/patch.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.3.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
-
function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableArray`}function r(e){return e.type===`KeyValue`}function i(e){return e.type===`String`}function a(e){return e.type===`Integer`}function o(e){return e.type===`Float`}function s(e){return e.type===`Boolean`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(r){return e(r)||t(r)||n(r)||d(r)||l(r)}function p(e){return i(e)||a(e)||o(e)||s(e)||c(e)||l(e)||d(e)}let m,h;function g(e){if(m===e&&h!==void 0)return h;let t=ne(e);return m=e,h=t,t}function ee(){m=void 0,h=void 0}function _(e,t){let n=Array.isArray(e)?e:ne(e);if(n.length===0)return{line:1,column:t};let r=0,i=n.length-1;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}n[r]<t&&r++;let a=r+1;return{line:a,column:t-(n[a-2]+1||0)}}function te(e,t){let n=g(e),r=n[t.line-2]===void 0?0:n[t.line-2]+1,i=n[t.line-1]||e.length;return e.substring(r,i)}function ne(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===10?t.push(n):r===13&&(e.charCodeAt(n+1)===10?(t.push(n+1),n++):t.push(n))}return t.push(e.length),t}function v(e){return{line:e.line,column:e.column}}function re(e){return{start:v(e.start),end:v(e.end)}}var y=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=te(e,t),i=`${ie(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function ie(e,t=` `){return t.repeat(e)}const ae=/[\w,\d,",',+,\-,_]/;function oe(){return{reference:null,mixed:!1}}function*se(e,t){let n=e.length,r=0,i=t??oe(),a=[],o=(e,t)=>({start:_(a,e),end:_(a,t)});for(;r<n;){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9&&t!==13&&t!==10)throw new y(e,_(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed`);if(t===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new y(e,_(a,r),`Standalone CR; must be CRLF or LF`);if(t!==32&&t!==9&&t!==13){if(t===10)s(r);else if(t===91||t===93)yield{type:`Bracket`,raw:e[r],loc:o(r,r+1)};else if(t===123||t===125)yield{type:`Curly`,raw:e[r],loc:o(r,r+1)};else if(t===61)yield{type:`Equal`,raw:`=`,loc:o(r,r+1)};else if(t===44)yield{type:`Comma`,raw:`,`,loc:o(r,r+1)};else if(t===46)yield{type:`Dot`,raw:`.`,loc:o(r,r+1)};else if(t===35)yield c();else{let t=ce(e,r,`'`)||ce(e,r,`"`);t?yield l(t):yield u()}}r++}function s(t){a.push(t);let n=t>0&&e.charCodeAt(t-1)===13?`\r
|
|
3
|
-
`:`
|
|
4
|
-
`;i.reference===null?i.reference=n:i.reference!==n&&(i.mixed=!0)}function c(){let t=r;for(;r+1<n;){let t=e.charCodeAt(r+1);if(t===10||t===13)break;r++;let n=e.charCodeAt(r);if((n<=31||n===127)&&n!==9)throw new y(e,_(a,r),`Control char 0x${n.toString(16).toUpperCase().padStart(2,`0`)} not allowed`)}return{type:`Comment`,raw:e.slice(t,r+1),loc:o(t,r+1)}}function l(t){let i=r,c=t+t+t;for(r+=3;r<n;){if(ce(e,r,t)){let n=3;for(;e[r+n]===t;)n++;if(n>=6)throw new y(e,_(a,r),`Invalid multiline string: ${n} consecutive ${t} characters`);if(n===3){r+=2;break}r+=n-3,r+=2;break}let i=e.charCodeAt(r);if(i===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new y(e,_(a,r),`Standalone CR in multiline string; must be CRLF or LF`);if((i<=31||i===127)&&i!==9&&i!==10&&i!==13){let n=t===`"`?`multiline basic strings`:`multiline literal strings`,o=`0x${i.toString(16).toUpperCase().padStart(2,`0`)}`,s=``;i===0?s=`Null`:i===127&&(s=`DEL`);let c=s?`${s} (${o}) not allowed in ${n}`:`Control char ${o} not allowed in ${n}`;throw new y(e,_(a,r),c)}i===10&&s(r),r++}if(r>=n){if(t===`"`){let t=0,i=n-1;for(;i>=0&&e[i]===`\\`;)t++,i--;if(t>0&&t%2!=0)throw new y(e,_(a,r),`Unterminated multiline ${c} (possible escape issue)`)}throw new y(e,_(a,r),`Unterminated multiline ${c}`)}return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}function u(){let t=e[r];if(!ae.test(t))throw new y(e,_(a,r),`Unexpected char "${t}"`);let i=r,s=t===`"`,c=t===`'`;for(;r<n&&!(r+1>=n);){let t=e.charCodeAt(r+1);if(!(s||c)&&(t===32||t===9||t===10||t===13||t===44||t===46||t===93||t===125||t===61||t===35))break;if(r++,!(s||c)){let t=e.charCodeAt(r);if(t<=31||t===127)throw new y(e,_(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed in unquoted value`)}if(s||c){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9){let n=s?`basic strings`:`literal strings`,i=`0x${t.toString(16).toUpperCase().padStart(2,`0`)}`,o=``;t===10?o=`Newline`:t===13?o=`Carriage return`:t===0?o=`Null`:t===127&&(o=`DEL`);let c=o?`${o} (${i}) not allowed in ${n}`:`Control char ${i} not allowed in ${n}`;throw new y(e,_(a,r),c)}}let i=e[r];if(i===`"`&&!c&&(s=!s),i===`'`&&!s&&(c=!c),r+1>=n)break;if(s&&i===`\\`){let t=e[r+1];(t===`"`||t===`\\`)&&r++}}if(s||c)throw new y(e,_(a,i),`Expected close of string with ${s?`"`:`'`}`);return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}}function ce(e,t,n){if(!n||e[t]!==n||e[t+1]!==n||e[t+2]!==n)return!1;if(n===`'`)return n;let r=0,i=t-1;for(;i>=0&&e[i]===`\\`;)r++,i--;return(r===0||r%2==0)&&n}const b=/* @__PURE__ */ new Int8Array(128);b.fill(-1);for(let e=0;e<10;e++)b[48+e]=e;for(let e=0;e<6;e++)b[65+e]=10+e,b[97+e]=10+e;function x(e){let t=e.charCodeAt(0);return t<128&&b[t]!==-1}function le(e,t){return b[e.charCodeAt(t)]<<12|b[e.charCodeAt(t+1)]<<8|b[e.charCodeAt(t+2)]<<4|b[e.charCodeAt(t+3)]}function ue(e){return e.startsWith(`'''`)?fe(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?de(fe(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?de(e.slice(1,e.length-1),!1):e}function de(e,t){let n=e.length;if(!t&&e.indexOf(`\\`)===-1)return e;let r=[],i=0;for(let a=0;a<n;a++){if(e[a]!==`\\`)continue;if(a>i&&r.push(e.slice(i,a)),a++,a>=n)throw Error(`Trailing backslash`);let o=e[a];switch(o){case`b`:r.push(`\b`);break;case`t`:r.push(` `);break;case`n`:r.push(`
|
|
5
|
-
`);break;case`f`:r.push(`\f`);break;case`r`:r.push(`\r`);break;case`"`:r.push(`"`);break;case`\\`:r.push(`\\`);break;case`e`:r.push(`\x1B`);break;case`u`:{if(a+4>n||!x(e[a+1])||!x(e[a+2])||!x(e[a+3])||!x(e[a+4]))throw Error(`Invalid Unicode escape: \\u${e.slice(a+1,a+5)}`);let t=le(e,a+1);if(t>=55296&&t<=57343)throw Error(`Invalid \\u${e.slice(a+1,a+5)}: surrogates not allowed`);r.push(String.fromCharCode(t)),a+=4;break}case`U`:{if(a+8>n)throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);for(let t=1;t<=8;t++)if(!x(e[a+t]))throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);let t=parseInt(e.slice(a+1,a+9),16);if(t>=55296&&t<=57343)throw Error(`Invalid \\U${e.slice(a+1,a+9)}: surrogates not allowed`);r.push(String.fromCodePoint(t)),a+=8;break}case`x`:{if(a+2>n||!x(e[a+1])||!x(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=b[e.charCodeAt(a+1)]<<4|b[e.charCodeAt(a+2)];r.push(String.fromCharCode(t)),a+=2;break}default:if(t&&(o===`
|
|
6
|
-
`||o===`\r`||o===` `||o===` `)){let t=o===`
|
|
7
|
-
`||o===`\r`,r=a;for(;r<n&&(e[r]===` `||e[r]===` `||e[r]===`
|
|
8
|
-
`||e[r]===`\r`);)(e[r]===`
|
|
9
|
-
`||e[r]===`\r`)&&(t=!0),r++;if(!t)throw Error(`Invalid escape sequence: \\${o}`);a=r-1;break}throw Error(`Invalid escape sequence: \\${o}`)}i=a+1}return i===0?e:(i<n&&r.push(e.slice(i)),r.join(``))}function fe(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var pe=class{iterator;index;value;done;peeked;constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){if(this.done)return he();let e=this.peeked||this.iterator.next();return this.index+=1,this.value=e.value,this.done=e.done??!1,this.peeked=null,e}peek(){return this.done?he():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const me=Object.freeze({value:void 0,done:!0});function he(){return me}const ge=/* @__PURE__ */ new WeakMap;function _e(e,t){ge.set(e,t)}function S(e){return{year:String(e.getUTCFullYear()).padStart(4,`0`),month:String(e.getUTCMonth()+1).padStart(2,`0`),day:String(e.getUTCDate()).padStart(2,`0`),hours:String(e.getUTCHours()).padStart(2,`0`),minutes:String(e.getUTCMinutes()).padStart(2,`0`),seconds:String(e.getUTCSeconds()).padStart(2,`0`),ms:e.getUTCMilliseconds()}}function ve(e){return e===0?``:String(e).padStart(3,`0`).replace(/0+$/,``)}const ye=/\.(\d+)\s*$/,be=/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/;function xe(e,t){var n;return((n=e.match(t))==null?void 0:n[1])??``}function Se(e,t,n){let r=xe(t,n),i=r.length>r.replace(/0+$/,``).length?Math.max(r.length,e.length):e.length;return i===0?``:`.`+e.padEnd(i,`0`)}function Ce(e){let t=e.toISOString().match(/\.(\d+)/);return t?t[1]:``}function C(e,t,n,r=ye){let i=Ce(e).replace(/0+$/,``);return i.length>ve(t).length?Se(i,n,r):w(t,n,r)}function w(e,t,n=ye){let r=ve(e);if(t&&t.includes(`.`)){let i=t.match(n);return i&&i[1].startsWith(String(e).padStart(3,`0`))?`.`+i[1]:Se(r,t,n)}return r?`.`+r:``}function we(e){if(e===`Z`)return 0;let t=e[0]===`+`?1:-1,[n,r]=e.slice(1).split(`:`);return t*(parseInt(n)*60+parseInt(r))}var Te=class e{static IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/;static IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/;static IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;static createDateWithOriginalFormat(t,n){if(e.IS_DATE_ONLY.test(n)){if(t.getUTCHours()!==0||t.getUTCMinutes()!==0||t.getUTCSeconds()!==0||t.getUTCMilliseconds()!==0){if(t instanceof O)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new D(e,!1)}let e=t.toISOString().split(`T`)[0];return new T(e)}if(e.IS_TIME_ONLY.test(n)){let e=S(t),r=C(t,e.ms,n);return new E(`${e.hours}:${e.minutes}:${e.seconds}${r}`)}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=S(t),r=C(t,e.ms,n),i=`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`;return new D(i,!1,i)}if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=S(t),r=C(t,e.ms,n),i=`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`;return new D(i,!0,i)}if(e.IS_OFFSET_DATETIME_T.test(n)||e.IS_OFFSET_DATETIME_SPACE.test(n)){let r=n.match(/([+-]\d{2}:\d{2}|[Zz])$/),i=r?r[1]===`z`?`Z`:r[1]:`Z`,a=e.IS_OFFSET_DATETIME_SPACE.test(n),o=S(new Date(t.getTime()+we(i)*6e4)),s=a?` `:`T`,c=C(t,o.ms,n,be);return new O(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}return t}},T=class extends Date{constructor(e){super(e)}toISOString(){let e=S(this);return`${e.year}-${e.month}-${e.day}`}},E=class extends Date{originalFormat;constructor(e,t=e){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+`:00`),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){let e=S(this);return`${e.hours}:${e.minutes}:${e.seconds}${w(e.ms,this.originalFormat)}`}},D=class extends Date{useSpaceSeparator=!1;originalFormat;constructor(e,t=!1,n){let r=e;/\d{2}:\d{2}:\d{2}/.test(e)||(r=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(r.replace(` `,`T`)+`Z`),this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){let e=S(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${w(e.ms,this.originalFormat)}`}},O=class extends Date{useSpaceSeparator=!1;originalOffset;originalFormat;constructor(e,t=!1){let n=e;/\d{2}:\d{2}:\d{2}/.test(e)||(n=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(n.replace(` `,`T`)),this.useSpaceSeparator=t,this.originalFormat=e;let r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset=r[1]===`z`?`Z`:r[1])}toISOString(){if(this.originalOffset){let e=S(new Date(this.getTime()+we(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=w(e.ms,this.originalFormat,be);return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${n}${this.originalOffset}`}let e=super.toISOString();return this.useSpaceSeparator?e.replace(`T`,` `):e}};const k=Te,Ee=`true`,De=/e/i,A=/_/g,Oe=/^[+-]?inf$/,ke=/^[+-]?nan$/,j=/^[+-]?0x/i;function Ae(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const M=/^[+-]?0o/i,N=/^[+-]?0b/i;function P(e,t,n){for(let r=0;r<e.length;r++)if(!Ae(e.charCodeAt(r)))throw new y(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function F(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new y(t,n,`Multiline strings cannot be keys`)}function I(e,t,n){try{return ue(e)}catch(e){throw new y(t,n,e.message)}}function L(e,t,n,r=!0){if(e.endsWith(`_`)||(r?/^[+-]?_/.test(e):e.startsWith(`_`)))throw new y(t,n,`Underscore must be between digits`);if(/__/.test(e))throw new y(t,n,`Consecutive underscores not allowed`)}function R(e,t,n,r){let i=e.replace(A,``);if(/^[+-]?0\d/.test(i)&&!j.test(e)&&!M.test(e)&&!N.test(e))throw new y(t,n,`Leading zeros are not allowed in ${r}`)}function je(e,t,n,r){if(/_[eE]/.test(e))throw new y(n,r,`Underscore before exponent is not allowed`);if(/[eE][+-]?_/.test(e))throw new y(n,r,`Underscore at start of exponent is not allowed`);if(/[eE][+-]?$/.test(e))throw new y(n,r,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new y(n,r,`Invalid float "${t}": decimal point not allowed in exponent`)}function Me(e,t,n,r,i,a){if(e.length!==2)throw new y(i,a,`"${r}": hour must be 2 digits`);if(t.length!==2)throw new y(i,a,`"${r}": minute must be 2 digits`);if(n&&n.length!==2)throw new y(i,a,`"${r}": second must be 2 digits`)}function Ne(e,t,n,r,i,a){if(e!==void 0){let t=parseInt(e,10);if(t<0||t>23)throw new y(i,a,`"${r}": hour must be 00-23`)}if(t!==void 0){let e=parseInt(t,10);if(e<0||e>59)throw new y(i,a,`"${r}": minute must be 00-59`)}if(n!==void 0){let e=parseInt(n,10);if(e<0||e>60)throw new y(i,a,`"${r}": second must be 00-60`)}}function Pe(e,t,n){if(j.test(e)||M.test(e)||N.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new y(t,n,`Invalid integer "${e}"`)}function z(e,t,n,r,i,a,o){let s=r[0]+r[1].toUpperCase();if(RegExp(`^[+\\-]?`+s.replace(/([[\]])/g,`\\$1`)).test(e))throw new y(t,n,`${a} prefix must be lowercase "${r}"`);if(RegExp(`^[+\\-]?`+r+`_`,`i`).test(e))throw new y(t,n,`Underscore must be between digits`);let c=RegExp(`^[+\\-]?`+r,`i`),l=e.replace(c,``);if(!l||l===`_`||l.startsWith(`_`))throw new y(t,n,`Incomplete ${a.toLowerCase()} number`);let u=l.replace(/_/g,``);if(!i.test(u))throw new y(t,n,o??`Invalid ${a.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new y(t,n,`${a} numbers cannot have a sign prefix`)}function*Fe(e,t){let n=new pe(se(e,t));try{for(;!n.next().done;){let t=We(n,e);for(let e of t)yield e}}finally{ee()}}function B(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function Ie(e,t){let n=!e.peek().done&&e.peek().value.type===`Bracket`?`TableArray`:`Table`,r=n===`Table`;if(r&&e.value.raw!==`[`)throw new y(t,e.value.loc.start,`Expected table opening "[", found ${e.value.raw}`);if(!r){let n=e.peek();if(n.done)throw new y(t,e.value.loc.start,`Expected "[[" for Array of Tables, found end of input`);if(e.value.raw!==`[`||n.value.raw!==`[`)throw new y(t,e.value.loc.start,`Expected "[[", found ${e.value.raw+n.value.raw}`);let r=e.value,i=n.value;if(r.loc.end.line!==i.loc.start.line||r.loc.end.column!==i.loc.start.column)throw new y(t,r.loc.start,`"[[" brackets must be adjacent (no whitespace)`)}let i=r?{type:`TableKey`,loc:e.value.loc}:{type:`TableArrayKey`,loc:e.value.loc};if(e.next(),n===`TableArray`&&e.next(),e.done)throw new y(t,i.loc.start,`Expected table key, reached end of file`);if(e.value.type===`Bracket`&&e.value.raw===`]`)throw new y(t,e.value.loc.start,n===`TableArray`?`Array of Tables header [[]] requires a table name`:`Table header [] requires a table name`);let a=e.value.raw;F(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||P(a,t,e.value.loc.start);let o;for(o=[I(e.value.raw,t,e.value.loc.start)],i.item={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:o};!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;r.startsWith(`"`)||r.startsWith(`'`)||P(r,t,e.value.loc.start);let a=` `.repeat(n.loc.start.column-i.item.loc.end.column),o=` `.repeat(e.value.loc.start.column-n.loc.end.column);i.item.loc.end=e.value.loc.end,i.item.raw+=`${a}.${o}${e.value.raw}`;try{i.item.value.push(ue(e.value.raw))}catch(n){let r=n;throw new y(t,e.value.loc.start,r.message)}}if(e.next(),!e.done){let n=i.loc.start.line;if(e.value.loc.start.line!==n)throw new y(t,e.value.loc.start,r?`Table header must be single-line`:`Array of Tables header must be single-line`)}if(r&&(e.done||e.value.raw!==`]`))throw new y(t,e.done?i.item.loc.end:e.value.loc.start,`Expected table closing "]", found ${e.done?`end of file`:e.value.raw}`);if(!r&&(e.done||e.peek().done||e.value.raw!==`]`||e.peek().value.raw!==`]`))throw new y(t,e.done||e.peek().done?i.item.loc.end:e.value.loc.start,`Expected "]]" closing, found ${e.done||e.peek().done?`end of file`:e.value.raw+e.peek().value.raw}`);if(!r){let n=e.value,r=e.peek().value;if(n.loc.end.line!==r.loc.start.line||n.loc.end.column!==r.loc.start.column)throw new y(t,n.loc.start,`"]]" brackets must be adjacent (no whitespace)`)}if(r||e.next(),i.loc.end=e.value.loc.end,!e.peek().done){let n=e.peek().value;if(n.loc.start.line===i.loc.end.line&&n.type!==`Comment`)throw new y(t,n.loc.start,`Extra content after ${r?`table`:`Array of Tables`} header`)}let s=[];for(;!e.peek().done&&e.peek().value.type!==`Bracket`;){e.next();let n=We(e,t);for(let e=0;e<n.length;e++)s.push(n[e])}return{type:r?`Table`:`TableArray`,loc:{start:v(i.loc.start),end:s.length?v(s[s.length-1].loc.end):v(i.loc.end)},key:i,items:s}}function Le(e,t){let n=I(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function Re(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===Ee}}function ze(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&k.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&k.IS_FULL_TIME.test(e.peek().value.raw)){let t=n.start;e.next(),n={start:t,end:e.value.loc.end},r+=` ${e.value.raw}`}if(!e.peek().done&&e.peek().value.type===`Dot`){let i=n.start;if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new y(t,e.value.loc.end,`Expected fractional value for DateTime`);e.next(),n={start:i,end:e.value.loc.end},r+=`.${e.value.raw}`}if(Ve(r,t,n.start),k.IS_FULL_DATE.test(r))i=k.IS_DATE_ONLY.test(r)?new T(r):k.IS_LOCAL_DATETIME_T.test(r)?new D(r,!1):k.IS_LOCAL_DATETIME_SPACE.test(r)?new D(r,!0):k.IS_OFFSET_DATETIME_T.test(r)?new O(r,!1):k.IS_OFFSET_DATETIME_SPACE.test(r)?new O(r,!0):new Date(r.replace(` `,`T`));else if(k.IS_TIME_ONLY.test(r))i=new E(r,r);else{let[e]=(/* @__PURE__ */ new Date()).toISOString().split(`T`);i=/* @__PURE__ */ new Date(`${e}T${r}`)}return{type:`DateTime`,loc:n,raw:r,value:i}}function Be(e,t){return t===2?e%4==0&&e%100!=0||e%400==0?29:28:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}function Ve(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new y(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new y(t,n,`"${e}": offset needs HH:MM`);let r=/\d{2}:\d{2}/.test(e)?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(r){let e=r[0],i=r[2],a=r[3],o=r[4];if(a!==`:`)throw new y(t,n,`Offset "${e}": missing colon separator`);if(i.length!==2)throw new y(t,n,`Offset "${e}": hour must be 2 digits`);if(!o||o.length===0)throw new y(t,n,`Offset "${e}": minute required`);if(o.length!==2)throw new y(t,n,`Offset "${e}": minute must be 2 digits`);let s=parseInt(i,10);if(s<0||s>23)throw new y(t,n,`Offset "${e}": hour must be 00-23`);let c=parseInt(o,10);if(c<0||c>59)throw new y(t,n,`Offset "${e}": minute must be 00-59`)}if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/.test(e))throw/^\d{4}-\d{2}-\d{2}T$/.test(e)?new y(t,n,`"${e}": 'T' requires time component`):/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e)?new y(t,n,`Invalid date "${e}": unexpected character after date`):/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e)?new y(t,n,`"${e}": missing 'T' or space separator`):new y(t,n,`Invalid datetime "${e}"`);let i=e.match(/^(\d+)-/);if(i&&i[1].length!==4)throw new y(t,n,`"${e}": year must be 4 digits`);let a=e.match(/^(\d+)-(\d+)-(\d+)/);if(a){let[,,r,i]=a;if(r.length!==2)throw new y(t,n,`"${e}": month must be 2 digits`);if(i.length!==2)throw new y(t,n,`"${e}": day must be 2 digits`)}let o=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(o){let[,r,i,a]=o;Me(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;Me(r,i,a,e,t,n)}let c=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),l=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(c){let[,r,i,a,o,s,l]=c,u=parseInt(i,10);if(u<1||u>12)throw new y(t,n,`"${e}": month must be 01-12`);let d=parseInt(a,10);if(d<1||d>31)throw new y(t,n,`"${e}": day must be 01-31`);if(d>Be(parseInt(r,10),u))throw new y(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Ne(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Ne(r,i,a,e,t,n)}}function He(e,t){let n=e.value.loc,r=e.value.raw,i;if(Oe.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(ke.test(r)){let e=/* @__PURE__ */ new Float64Array(1),t=new DataView(e.buffer);r.startsWith(`-`)?(t.setUint32(0,0,!0),t.setUint32(4,4294443008,!0)):(t.setUint32(0,0,!0),t.setUint32(4,2146959360,!0)),i=e[0];let a=r.startsWith(`+`)?`+`:r.startsWith(`-`)?`-`:void 0;return{type:`Float`,loc:n,raw:r,value:i,nanSign:a}}else if(!e.peek().done&&e.peek().value.type===`Dot`){let a=n.start;{if(De.test(r)&&!j.test(r))throw new y(t,n.start,`Float "${r}": dot after exponent`);let e=r;R(e,t,n.start,`the integer part of a float`);let i=e.replace(/^[+-]/,``);if(i===``||i===`_`)throw new y(t,n.start,`Float: digit required before dot`);L(e,t,n.start)}if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new y(t,e.value.loc.end,`Expected fraction value for Float`);e.next(),r+=`.${e.value.raw}`,n={start:a,end:e.value.loc.end};{let n=e.value.raw;if(!/^\d/.test(n))throw new y(t,e.value.loc.start,`Float: fraction must start with digit, found "${n}"`);L(n,t,e.value.loc.start,!1),je(n,r,t,e.value.loc.start)}i=Number(r.replace(A,``))}else{if(L(r,t,n.start),je(r,r,t,n.start),!e.peek().done&&e.peek().value.type===`Dot`)throw new y(t,e.peek().value.loc.start,`Float "${r}.": dot after exponent`);R(r,t,n.start,`the integer part of a float`),i=Number(r.replace(A,``))}if(Number.isNaN(i)&&!ke.test(r))throw new y(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function Ue(e,t){let n=e.value.raw,r=e.value.loc;if(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n)||/^\d{6}-\d{2}$/.test(n))throw new y(t,r.start,`Invalid integer "${n}"`);if(n===`-0`||n===`+0`)return{type:`Integer`,loc:r,raw:n,value:0};if(/^[+-]{2,}/.test(n))throw new y(t,r.start,`Double sign is not allowed in integers`);R(n,t,r.start,`decimal integers`),L(n,t,r.start),Pe(n,t,r.start);let i=10;j.test(n)?(i=16,z(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):M.test(n)?(i=8,z(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):N.test(n)&&(i=2,z(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(A,``).replace(M,``).replace(N,``),i);if(Number.isNaN(a))throw new y(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function We(e,t){if(e.value.type===`Comment`)return[B(e)];if(e.value.type===`Bracket`)return[Ie(e,t)];if(e.value.type===`Literal`)return Ge(e,t);throw e.value.type===`Equal`?new y(t,e.value.loc.start,`Missing key before '='`):new y(t,e.value.loc.start,`Unexpected token "${e.value.type}"`)}function Ge(e,t){let n=e.value.raw;if(n.endsWith(`:`))throw new y(t,{line:e.value.loc.start.line,column:e.value.loc.start.column+[...n].length-1},`Use '=' to separate keys and values, not ':'`);F(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||P(n,t,e.value.loc.start);let r;r=[I(e.value.raw,t,e.value.loc.start)];let i={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:r};for(;!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;F(r,t,e.value.loc.start),r.startsWith(`"`)||r.startsWith(`'`)||P(r,t,e.value.loc.start);let a=te(t,i.loc.end),o=te(t,n.loc.end),s=a.slice(i.loc.end.column,n.loc.start.column),c=o.slice(n.loc.end.column,e.value.loc.start.column);i.loc.end=e.value.loc.end,i.raw+=`${s}.${c}${e.value.raw}`,i.value.push(I(e.value.raw,t,e.value.loc.start))}if(e.next(),!e.done&&e.value.loc.start.line!==i.loc.end.line)throw new y(t,e.value.loc.start,`"=" must be on same line as key`);if(e.done||e.value.type!==`Equal`)throw!e.done&&e.value.raw===`:`?new y(t,e.value.loc.start,`Use '=' to separate keys and values, not ':'`):new y(t,e.done?i.loc.end:e.value.loc.start,`Expected "=" for key-value`);let a=e.value.loc.start.column,o=e.value.loc.start.line;if(e.next(),e.done)throw new y(t,i.loc.start,`Expected value, reached EOF`);if(e.value.loc.start.line!==o)throw new y(t,e.value.loc.start,`Value must be on same line as '='`);if(e.done)throw new y(t,i.loc.start,`Expected value for key-value`);let s=Ke(e,t),c=s[0];if(!e.peek().done){let n=e.peek().value;if(n.type===`Dot`&&n.loc.start.line===c.loc.end.line&&(c.type===`Float`||c.type===`Integer`))throw new y(t,n.loc.start,`Invalid number: multiple decimal points not allowed`);if((n.type===`Literal`||n.type===`Bracket`)&&n.loc.start.line===c.loc.end.line)throw new y(t,n.loc.start,`Key/value pairs must be separated by a newline`)}return s[0]={type:`KeyValue`,key:i,value:c,loc:{start:v(i.loc.start),end:v(c.loc.end)},equals:a},s}function Ke(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[Le(e,t)]:n===Ee||n===`false`?[Re(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[ze(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||Oe.test(n)||ke.test(n)||De.test(n)&&!j.test(n)?[He(e,t)]:[Ue(e,t)]}if(e.value.type===`Curly`){let[n,r]=Je(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=Ye(e,t);return[n,...r]}throw e.value.type===`Dot`?new y(t,e.value.loc.start,`Number cannot start with a dot`):new y(t,e.value.loc.start,`Unrecognized token type`)}function qe(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.loc.end.line===r.loc.start.line){let e=r.loc.start.column-n.loc.end.column;if(e>=1)return e}}}function Je(e,t){if(e.value.raw!==`{`)throw new y(t,e.value.loc.start,`Expected "{" for inline table`);let n={type:`InlineTable`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Curly`||e.value.raw!==`}`);){if(e.value.type===`Comment`){r.push(B(e)),e.next();continue}if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new y(t,e.value.loc.start,`Leading comma in inline table`);if(r.comma)throw new y(t,e.value.loc.start,`Consecutive commas in inline table`);r.comma=!0,r.loc.end=e.value.loc.start,e.next();continue}let i=n.items[n.items.length-1];if(i&&!i.comma)throw new y(t,e.value.loc.start,`Missing comma between inline table items`);let a=We(e,t),o=a[0];if(o.type===`KeyValue`){n.items.push({type:`InlineItem`,loc:re(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Curly`||e.value.raw!==`}`)throw new y(t,e.done?n.loc.start:e.value.loc.start,`Expected "}"`);n.loc.end=e.value.loc.end;{let e=qe(n.items);e!==void 0&&_e(n,e)}return[n,r]}function Ye(e,t){if(e.value.raw!==`[`)throw new y(t,e.value.loc.start,`Expected "[" for inline array`);let n={type:`InlineArray`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Bracket`||e.value.raw!==`]`);){if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new y(t,e.value.loc.start,`Leading comma in array`);if(r.comma)throw new y(t,e.value.loc.start,`Consecutive commas in array`);r.comma=!0,r.loc.end=e.value.loc.start}else if(e.value.type===`Comment`)r.push(B(e));else{let i=n.items[n.items.length-1];if(i&&!i.comma)throw new y(t,e.value.loc.start,`Missing comma between array elements`);let a=Ke(e,t),o=a[0];n.items.push({type:`InlineItem`,loc:re(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Bracket`||e.value.raw!==`]`)throw new y(t,e.done?n.loc.start:e.value.loc.start,`Expected "]"`);n.loc.end=e.value.loc.end;{let e=qe(n.items);e!==void 0&&_e(n,e)}return[n,r]}function V(e){return e[e.length-1]}function H(){return Object.create(null)}function Xe(e,t){return e===t&&(typeof e!=`number`||Object.is(e,t))}const Ze=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));function U(e){return Number.isNaN(e)?(Ze.setFloat64(0,e,!0),!!(Ze.getUint32(4,!0)&2147483648)):!1}function W(e){return Object.prototype.toString.call(e)===`[object Date]`}const Qe=/* @__PURE__ */ new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function G(e){var t;return typeof e==`object`&&!!e&&Qe.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function $e(e){var t;let n=((t=e.constructor)==null?void 0:t.name)??``;if(n===`Temporal.ZonedDateTime`||n===`ZonedDateTime`){let t=e.toString(),n=t.match(/\[(.+)\]$/);if(n&&!/^[+-]\d{2}:\d{2}$/.test(n[1]))throw Error(`ZonedDateTime with IANA timezone "${t}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);return t.replace(/\[.*\]$/,``).replace(/(\+00:00)$/,`Z`)}let r=e.toString();if(/\[.*\]/.test(r))throw Error(`Temporal value contains unsupported annotation: "${r}". TOML only supports ISO 8601 calendar.`);return r}function et(e,t=/* @__PURE__ */ new WeakSet){return typeof e!=`object`||!e?!1:G(e)?!0:!t.has(e)&&(t.add(e),Object.values(e).some(e=>et(e,t)))}function tt(e){return e&&typeof e==`object`&&!W(e)&&!G(e)&&!Array.isArray(e)}function nt(e,t){return t in e}function K(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function rt(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?`date`:/^\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(e)?`time`:/(?:[Zz]|[+-]\d{2}:\d{2})$/.test(e)?`offset`:`datetime`}function it(e){let t=e.match(/\.(\d+)/);return t?t[1].replace(/0+$/,``):``}function at(e){return e===0?0:String(e).padStart(3,`0`).replace(/0+$/,``).length}function ot(e,t){let n=it(t);return n.length>at(e.getUTCMilliseconds())?n:void 0}function st(e,t){if(G(e)&&G(t))return e.toString()===t.toString();if(W(e)&&W(t)){if(e.getTime()!==t.getTime())return!1;let n=e.toISOString(),r=t.toISOString();if(rt(n)!==rt(r))return!1;let i=ot(e,n),a=ot(t,r);return i===void 0||a===void 0||i===a}return!1}function q(e){let t=[],n=/* @__PURE__ */ new WeakSet,r=[{value:e}];for(;r.length>0;){let e=r.pop();if(`text`in e){t.push(e.text),`leave`in e&&n.delete(e.leave);continue}let i=e.value;if(tt(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i);let e=Object.keys(i).sort();t.push(`{`),r.push({leave:i,text:`}`});for(let t=e.length-1;t>=0;t--){let n=e[t];t<e.length-1&&r.push({text:`,`}),r.push({value:i[n]}),r.push({text:`:`}),r.push({text:JSON.stringify(n)})}}else if(Array.isArray(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i),t.push(`[`),r.push({leave:i,text:`]`});for(let e=i.length-1;e>=0;e--)e<i.length-1&&r.push({text:`,`}),r.push({value:i[e]})}else if(G(i))t.push(JSON.stringify(i.toString()));else if(W(i))t.push(JSON.stringify(i.toISOString()));else if(typeof i==`bigint`)t.push(i.toString()+`n`);else if(typeof i==`number`&&!Number.isFinite(i)){let e=Number.isNaN(i)?U(i)?`-`:`+`:i<0?`-`:`+`;t.push(`${e}${String(i)}`)}else typeof i==`number`&&Object.is(i,-0)?t.push(`-0`):t.push(JSON.stringify(i))}return t.join(``)}typeof String.prototype.isWellFormed==`function`&&String.prototype.isWellFormed;function ct(e,t=`asNeeded`){let n=e.replace(/_/g,``),r=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){let e=n[0]===`+`||n[0]===`-`?n[0]:``;r=e+n.slice(+!!e).toLowerCase()}let i;try{i=BigInt(r)}catch{return Number(n)}return t===!0?i:t===!1||i>=BigInt(-(2**53-1))&&i<=BigInt(2**53-1)?Number(i):i}function lt(e,t,n){for(let r of e.items){let e=r.item;if(e.value.type===`InlineTable`){let r=t.concat(e.key.value);n.add(J(r)),lt(e.value,r,n)}}}function ut(e){var t,n,r,i,a,o;if((t=e.constructor)!=null&&(t=t.name)!=null&&(n=t.startsWith)!=null&&n.call(t,`Temporal.`)||((r=e.constructor)==null?void 0:r.name)===`PlainDate`||((i=e.constructor)==null?void 0:i.name)===`PlainTime`||((a=e.constructor)==null?void 0:a.name)===`PlainDateTime`||((o=e.constructor)==null?void 0:o.name)===`ZonedDateTime`)return e;let s=globalThis.Temporal;if(e instanceof T)return s.PlainDate.from(e.toISOString());if(e instanceof E)return s.PlainTime.from(e.toISOString());if(e instanceof D)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof O){let t=e.toISOString().replace(` `,`T`),n=t.match(/([+-]\d{2}:\d{2}|Z)$/),r=n?n[1]:`Z`,i=t.replace(/([+-]\d{2}:\d{2}|Z)$/,``),a=r===`Z`?`+00:00`:r;return s.ZonedDateTime.from(`${i}${r}[${a}]`)}return s.PlainDateTime.from(e.toISOString().replace(`Z`,``))}function dt(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=H(),o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Set,d=a,f=[],p={tables:o,table_arrays:s,defined:c,implicit_tables:l,inline_tables:u};for(let t of e)switch(t.type){case`Table`:m(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`TableArray`:h(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`KeyValue`:g(t)}return a;function m(e){let n=e.key.item.value;try{pt(a,[],n,e.type,p)}catch(n){let r=n;throw new y(t,e.key.loc.start,r.message)}let r=J(n);o.add(r),c.add(r),d=mt(a,n),f=n}function h(e){let n=e.key.item.value;try{pt(a,[],n,e.type,p)}catch(n){let r=n;throw new y(t,e.key.loc.start,r.message)}let r=J(n);s.add(r),c.add(r),d=ht(a,n),f=n}function g(e){let n=e.key.value;try{pt(d,f,n,e.type,p)}catch(n){let r=n;throw new y(t,e.key.loc.start,r.message)}if(n.length>1)for(let e=1;e<n.length;e++){let t=J(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=ft(e.value,{integersAsBigInt:r,temporal:i})}catch(n){let r=n;throw new y(t,e.value.loc.start,r.message)}if(e.value.type===`InlineTable`){let t=f.concat(n);u.add(J(t)),lt(e.value,t,u)}let o=n.length>1?mt(d,n.slice(0,-1)):d;o[V(n)]=a,c.add(J(f.concat(n)))}}function ft(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=H(),i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=ft(e.value,{integersAsBigInt:n,temporal:r}),c=vt(o),l=J(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=vt(o.slice(0,e));if(i.has(J(o.slice(0,e))))throw Error(`Key "${c}" conflicts with key: "${t}"`)}if(a.has(l)){let e=a.get(l);throw Error(`Key "${c}" conflicts with key: "${e}"`)}i.add(l);for(let e=1;e<o.length;e++){let t=J(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?mt(t,o.slice(0,-1)):t;u[V(o)]=s}),t;case`InlineArray`:return e.items.map(e=>ft(e.item,{integersAsBigInt:n,temporal:r}));case`DateTime`:if(r){if(globalThis.Temporal===void 0)throw Error(`Temporal API is not available in this runtime. Set temporal: false or use a runtime with Temporal support.`);return ut(e.value)}return e.value;case`String`:return e.value;case`Integer`:return ct(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function pt(e,t,n,r,i){let a=t.length>0?[...t]:[],o=Array(n.length),s=Array(n.length);for(let e=0;e<n.length;e++)a.push(n[e]),o[e]=vt(a),s[e]=J(a);let c=o[n.length-1],l=s[n.length-1];if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(s[e-1]))throw Error(`Cannot extend inline table at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.inline_tables.has(l))throw Error(`Cannot extend inline table at ${c}`);if(r===`Table`||r===`TableArray`)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(s[e-1]))throw Error(`Cannot extend inline table at ${t}`)}if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.table_arrays.has(s[e-1]))throw Error(`Cannot traverse Array of Tables at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.implicit_tables.has(l))throw Error(`Implicit table already defined: ${c}`);if(r===`KeyValue`&&i.implicit_tables.has(l))throw Error(`Table already defined: ${c}`);if(r===`KeyValue`&&n.length>1)for(let e=1;e<=n.length;e++){let t=o[e-1];if(i.tables.has(s[e-1]))throw Error(`Cannot extend explicit table ${t} with dotted keys`)}let u=0;for(let t of n){if(!nt(e,t))return;if(_t(e[t]))throw Error(`Value already defined for ${o[u]}`);let r=o[u];if(Array.isArray(e[t])&&!i.table_arrays.has(s[u]))throw Error(`Cannot add to static array at ${r}`);let a=u++<n.length-1;e=Array.isArray(e[t])&&a?V(e[t]):e[t]}let d=c;if(e&&r===`Table`&&i.defined.has(l)||e&&r===`KeyValue`&&n.length===1&&i.defined.has(l)&&!_t(e))throw Error(`Table already defined: ${d}`);if(e&&r===`TableArray`&&!i.table_arrays.has(l))throw Error(`Cannot add Array of Tables to table at ${d}`)}function mt(e,t){let n=gt(e,t.slice(0,-1)),r=V(t);return n[r]||(n[r]=H()),n[r]}function ht(e,t){let n=gt(e,t.slice(0,-1)),r=V(t);n[r]||(n[r]=[]);let i=H();return n[V(t)].push(i),i}function gt(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=H()),Array.isArray(e[t])?V(e[t]):e[t]),e)}function _t(e){return typeof e!=`object`&&!W(e)}function vt(e){return e.join(`.`)}function J(e){return JSON.stringify(e)}var Y=class extends Error{code;path;constructor(e,t,n){super(n),this.name=`PatchLiteError`,this.code=e,this.path=t}};function X(e){let t=``;for(let n of e)t+=typeof n==`number`?`[${n}]`:t?`.${n}`:n;return t||`(root)`}function yt(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`||t===`bigint`}function Z(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;if(W(e)||G(e))return`date`;let t=typeof e;return t===`object`?`table`:t}function bt(e,t){return U(e)===U(t)}function Q(e){return W(e)||G(e)}function xt(e,t,n=[]){if(st(e,t)||Xe(e,t)||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t)&&bt(e,t))return[];let r=Array.isArray(e),i=Array.isArray(t);if(r&&i)return Ct(e,t,n);if(r||i)throw new Y(`TypeChange`,n,`Cannot change a ${r?`array`:Z(e)} to a ${i?`array`:Z(t)} at ${X(n)}`);let a=tt(e),o=tt(t);if(a&&o)return St(e,t,n);if(a||o)throw new Y(`TypeChange`,n,`Cannot change a ${a?`table`:Z(e)} to a ${o?`table`:Z(t)} at ${X(n)}`);if(Q(e)&&Q(t))return[{type:`Edit`,path:n}];if(Q(e)||Q(t))throw new Y(`TypeChange`,n,`Cannot change a ${Z(e)} to a ${Z(t)} at ${X(n)}`);if(!yt(e)||!yt(t))throw new Y(`UnsupportedValue`,n,`Unsupported value type ${Z(t)} at ${X(n)}`);return[{type:`Edit`,path:n}]}function St(e,t,n){let r=Object.keys(e),i=Object.keys(t),a=new Set(i);for(let e of r)if(!a.has(e))throw new Y(`RemovedKey`,n.concat(e),`Cannot remove key ${X(n.concat(e))}`);let o=new Set(r);for(let e of i)if(!o.has(e))throw new Y(`AddedKey`,n.concat(e),`Cannot add key ${X(n.concat(e))}`);let s=[];for(let i of r){let r=xt(e[i],t[i],n.concat(i));for(let e of r)s.push(e)}return s}function Ct(e,t,n){if(e.length!==t.length)throw new Y(`ArrayLengthChange`,n,`Cannot change the length of array at ${X(n)} (${e.length} to ${t.length})`);let r=e.map(q),i=t.map(q);if(!r.every((e,t)=>e===i[t])){let e=r.slice().sort(),t=i.slice().sort();if(e.length===t.length&&e.every((e,n)=>e===t[n]))throw new Y(`ArrayReorder`,n,`Cannot reorder array elements at ${X(n)}`)}let a=[];for(let r=0;r<e.length;r++){let i=xt(e[r],t[r],n.concat(r));for(let e of i)a.push(e)}return a}function wt(e){if(e.includes(`'`))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32&&n!==9||n===127)return!1}return!0}function Tt(e){if(e.includes(`'''`))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n===13){if(e.charCodeAt(t+1)!==10)return!1}else if(n<32&&n!==9&&n!==10||n===127)return!1}return!0}function Et(e,t,n){let r=typeof e;if(r===`string`)return It(e,t==null?void 0:t.raw);if(r===`boolean`)return e?`true`:`false`;if(r===`bigint`)return e.toString();if(r===`number`)return Number.isFinite(e)?Number.isSafeInteger(e)&&!Object.is(e,-0)&&!o(t)?jt(e,t==null?void 0:t.raw):Mt(e,o(t)?t.raw:void 0):Pt(e);if(G(e))return Dt(e,t);if(e instanceof Date)return Ot(e,t);throw new Y(`UnsupportedValue`,n,`Unsupported value type ${Object.prototype.toString.call(e)} at ${X(n)}`)}function Dt(e,t){let n=$e(e),r=t==null?void 0:t.raw;return typeof r==`string`&&(r.includes(` `)&&n.includes(`T`)&&(n=n.replace(`T`,` `)),/(?:\+00:00|-00:00)/.test(r)&&n.endsWith(`Z`)&&(n=n.replace(/Z$/,r.match(/([+-]00:00)/)[1]))),n}function Ot(e,t){let n=t==null?void 0:t.raw,r=kt(e);return typeof n==`string`?Te.createDateWithOriginalFormat(r,n).toISOString():r.toISOString()}function kt(e){let t=e;if(typeof t.isDate!=`function`||typeof t.isTime!=`function`)return e;let n=e.toISOString().replace(/\.000(?=([Zz]|[+-]\d{2}:\d{2})$|$)/,``);return t.isDate()?new T(n):t.isTime()?new E(n,n):t.isLocal()?new D(n,!1):new O(n,!1)}function At(e){if(e.startsWith(`0x`))return{radix:16,prefix:`0x`};if(e.startsWith(`0o`))return{radix:8,prefix:`0o`};if(e.startsWith(`0b`))return{radix:2,prefix:`0b`}}function jt(e,t){if(t){let n=At(t);if(n&&e>=0){let r=n.radix===16&&/[A-F]/.test(t),i=e.toString(n.radix);return r&&(i=i.toUpperCase()),n.prefix+i}}return String(e)}function Mt(e,t){if(Object.is(e,-0))return`-0.0`;if(t&&/[eE]/.test(t))return Nt(e,t);let n=String(e);return/[.eE]/.test(n)?n:`${n}.0`}function Nt(e,t){let n=t.slice(0,t.search(/[eE]/)),r=n.indexOf(`.`),i=r===-1?``:n.slice(r+1),a=!/[1-9]/.test(i),o=Number.isInteger(e)&&!Object.is(e,-0)&&a?i.length:0,[s,c]=e.toExponential().split(/[eE]/),l=s.includes(`.`)?s.length-s.indexOf(`.`)-1:0,u=Math.max(o,l);return`${u>0?Number(s).toFixed(u):String(Number(s))}${t.includes(`E`)?`E`:`e`}${c.replace(/^\+/,``)}`}function Pt(e){return Number.isNaN(e)?U(e)?`-nan`:`nan`:e>0?`inf`:`-inf`}function Ft(e,t,n){return e.startsWith(t+`\r
|
|
10
|
-
`)?`\r
|
|
11
|
-
`:e.startsWith(t+`
|
|
12
|
-
`)?`
|
|
13
|
-
`:n.startsWith(`\r
|
|
14
|
-
`)?`\r
|
|
15
|
-
`:n.startsWith(`
|
|
16
|
-
`)?`
|
|
17
|
-
`:``}function It(e,t){if(t){if(t.startsWith(`'''`))return Tt(e)?`'''`+Ft(t,`'''`,e)+e+`'''`:zt(e);if(t.startsWith(`"""`))return Lt(e,t);if(t.startsWith(`'`)){if(wt(e))return`'`+e+`'`;if(Tt(e))return`'''`+Ft(t,`'''`,e)+e+`'''`}}return zt(e)}function Lt(e,t){let n=Rt(e);return`"""`+Ft(t,`"""`,n)+n+`"""`}function Rt(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e.charCodeAt(n);t+=r===`\\`?`\\\\`:r===`\b`?`\\b`:r===` `?`\\t`:r===`
|
|
18
|
-
`?`
|
|
19
|
-
`:r===`\f`?`\\f`:r===`\r`?e.charCodeAt(n+1)===10?`\r`:`\\r`:i>=0&&i<=7||i===11||i>=14&&i<=31||i===127?`\\u`+i.toString(16).padStart(4,`0`).toUpperCase():r}return t.replace(/"""/g,`""\\"`)}function zt(e){let t=`"`;for(let n of e){let e=n.codePointAt(0);t+=n===`"`?`\\"`:n===`\\`?`\\\\`:n===`\b`?`\\b`:n===` `?`\\t`:n===`
|
|
20
|
-
`?`\\n`:n===`\f`?`\\f`:n===`\r`?`\\r`:e<32||e===127?`\\u`+e.toString(16).padStart(4,`0`).toUpperCase():n}return t+=`"`,t}function $(i,a){if(!a.length)return u(i)&&r(i.item)?i.item:i;if(r(i))return $(i.value,a);let o={},s,c;if(f(i)&&i.items.some((l,d)=>{try{let f=[];if(r(l))f=l.key.value;else if(t(l))f=l.key.item.value;else if(n(l)){f=l.key.item.value;let e=q(f);o[e]||(o[e]=0);let t=o[e]++;f=f.concat(t)}else u(l)&&r(l.item)?f=l.item.key.value:u(l)&&(f=[d]);if(f.length&&K(f,a.slice(0,f.length))){let t=a.slice(f.length);if(e(i)&&n(l)&&t.length>0){let e=l.key.item.value,r=i,a=r.items.findIndex((t,r)=>r>d&&n(t)&&K(t.key.item.value,e)),o=a===-1?r.items.length:a;s=Bt(l,t,e,r.items.slice(d+1,o))}else s=u(l)&&r(l.item)?a.length===f.length?l:$(l.item.value,t):u(l)&&a.length>f.length?$(l.item,t):$(l,t);return!0}return(r(l)||u(l)&&r(l.item))&&f.length>a.length&&K(f.slice(0,a.length),a)&&(c||=l),!1}catch{return!1}}),!s&&c&&(s=c),!s)throw Error(`Node not found at ${a.join(`.`)}`);return s}function Bt(e,r,i,a){try{return $(e,r)}catch{}let o={};for(let e of a){let a=[];if(t(e)){let t=e.key.item.value;t.length>i.length&&K(t.slice(0,i.length),i)&&(a=t.slice(i.length))}else if(n(e)){let t=e.key.item.value;if(t.length>i.length&&K(t.slice(0,i.length),i)){let e=t.slice(i.length),n=q(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&K(a,r.slice(0,a.length)))try{return $(e,r.slice(a.length))}catch{}}throw Error(`Node not found at (aot scope) ${r.join(`.`)}`)}function Vt(e){return e.charCodeAt(0)===65279}const Ht=/* @__PURE__ */ new WeakMap,Ut=/* @__PURE__ */ new WeakMap;function Wt(e,t){return(e[t.line-1]??e[e.length-1])+t.column}function Gt(e,t){let n=Kt(t);for(let t of e)n(t)}function Kt(e){let i=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&i.push(t+1);return a=>{let o=[a];for(;o.length>0;){let a=o.pop(),s=[Wt(i,a.loc.start),Wt(i,a.loc.end)];if(Object.defineProperty(a,"range",{configurable:!0,enumerable:!1,value:s}),Ht.set(a,e),Ut.set(a,qt(a).slice()),r(a))o.push(a.value),o.push(a.key);else if(u(a))o.push(a.item);else if(t(a)||n(a)){o.push(a.key);let e=a.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}else if(f(a)){let e=a.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}}}}function qt(e){return r(e)?[e.key,e.value]:u(e)?[e.item]:t(e)||n(e)?[e.key,...e.items]:f(e)?e.items:[]}function Jt(e){let t=1,n=0;for(let r of e){let e=r.loc.end;(e.line>t||e.line===t&&e.column>n)&&(t=e.line,n=e.column)}return{type:`Document`,loc:{start:{line:1,column:0},end:{line:t,column:n}},items:e}}function Yt(e){return r(e)?e.value:u(e)?r(e.item)?e.item.value:e.item:e}function Xt(e,t){let n=e;for(let e of t)n=n==null?void 0:n[e];return n}function Zt(e,t){if(arguments.length>2&&arguments[2]!==void 0&&arguments[2]!==null)throw new Y(`UnsupportedOption`,[],`patch-lite does not support formatting options; use patch() from the main package`);let n=Vt(e),r=n?e.slice(1):e,i=Array.from(Fe(r));Gt(i,r);let a=xt(dt(i,r,{integersAsBigInt:`asNeeded`,temporal:et(t)}),t);if(a.length===0)return e;let o=Jt(i),s=[];for(let e of a){let n=Yt($(o,e.path));if(!p(n))throw Error(`Cannot locate a value at ${X(e.path)}`);let r=n.range;if(!r)throw Error(`Missing source location for value at ${X(e.path)}`);s.push({start:r[0],end:r[1],text:Et(Xt(t,e.path),n,e.path)})}s.sort((e,t)=>t.start-e.start);let c=r;for(let e of s)c=c.slice(0,e.start)+e.text+c.slice(e.end);return n?``+c:c}export{Zt as patch};
|