@decimalturn/toml-patch 0.7.0 → 1.0.0
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/CHANGELOG.md +145 -0
- package/README.md +6 -12
- package/dist/toml-patch.d.ts +1 -1
- package/dist/toml-patch.js +2 -0
- package/package.json +18 -21
- package/dist/toml-patch.cjs.min.js +0 -3
- package/dist/toml-patch.cjs.min.js.map +0 -1
- package/dist/toml-patch.es.js +0 -5232
- package/dist/toml-patch.umd.min.js +0 -3
- package/dist/toml-patch.umd.min.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-02-12
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **BREAKING**: Migrate to ESM-only distribution, removing CommonJS and UMD builds ([#100](https://github.com/DecimalTurn/toml-patch/pull/100))
|
|
14
|
+
- Package.json now declares `"type": "module"` and uses a modern `exports` field
|
|
15
|
+
- Single ESM build: `dist/toml-patch.js`
|
|
16
|
+
- Removed: `dist/toml-patch.cjs.min.js`, `dist/toml-patch.umd.min.js`, and all source maps
|
|
17
|
+
- Package size reduced by 90%
|
|
18
|
+
- Node.js 22.12.0+/23.3.0+ can directly `require()` this ESM package
|
|
19
|
+
- Users on older Node.js versions should use dynamic `import()` or stay on v0.x
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.7.0] - 2026-02-08
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Per official [toml-test](https://github.com/toml-lang/toml-test), return error for invalid TOML inputs (keys, strings, inline tables, tables, date/time, control characters, and newline handling) except for encoding issues ([#94](https://github.com/DecimalTurn/toml-patch/pull/95)).
|
|
26
|
+
|
|
27
|
+
## [0.6.0] - 2026-02-01
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- TOML v1.1 support
|
|
31
|
+
|
|
32
|
+
## [0.5.2] - 2026-01-19
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- Remove circular reference warning ([#90](https://github.com/DecimalTurn/toml-patch/pull/90))
|
|
36
|
+
|
|
37
|
+
## [0.5.1] - 2026-01-18
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- Add CHANGELOG.md
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Fix multiline string handling when patching ([#87](https://github.com/DecimalTurn/toml-patch/pull/87))
|
|
44
|
+
- Fix LocalTime timezone parsing issue (2dea07ffd8377ad2aa30678e7025dcbe6753a8e9)
|
|
45
|
+
|
|
46
|
+
## [0.5.0] - 2025-12-26
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
- Add `truncateZeroTimeInDates` formatting option for date serialization ([#86](https://github.com/DecimalTurn/toml-patch/pull/86))
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- Update dependency dedent to v1.7.1
|
|
53
|
+
|
|
54
|
+
## [0.4.1] - 2025-12-25
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
- Introduce `TomlDocument` class ([#66](https://github.com/DecimalTurn/toml-patch/pull/66))
|
|
58
|
+
- Add `TomlFormat` class ([#77](https://github.com/DecimalTurn/toml-patch/pull/77))
|
|
59
|
+
- Better Inline vs Multiline Tables formatting ([#79](https://github.com/DecimalTurn/toml-patch/pull/79))
|
|
60
|
+
- Handle TOML date formats when patching ([#82](https://github.com/DecimalTurn/toml-patch/pull/82))
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
- Dates will now preserve their formatting when patched
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
- Updated submodules/toml-test digest to b54f9ff
|
|
67
|
+
- Update actions/checkout action to v6
|
|
68
|
+
- Update actions/upload-artifact action to v6
|
|
69
|
+
- Updated Node.js to v24
|
|
70
|
+
- Updated glob to v13
|
|
71
|
+
- Updated rimraf to v6.1.2
|
|
72
|
+
- Updated js-yaml to v4.1.1
|
|
73
|
+
- Updated ts-jest to v29.4.6
|
|
74
|
+
- Updated rollup-plugin-dts to v6.3.0
|
|
75
|
+
- Skipped rollup v4.53.0 due to upstream issues
|
|
76
|
+
|
|
77
|
+
## [0.3.8] - 2025-10-25
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
- Add roundtrip tests and fix related issues ([#64](https://github.com/DecimalTurn/toml-patch/pull/64))
|
|
81
|
+
- Ensure trailing end-of-line (EOL) preservation at the end-of-file (ie. if the original TOML doesn't have any EOL at EOF, don't add one and if there's more than one include them)
|
|
82
|
+
- Fix issues with float values (`Infinity`, `-Infinity`, `NaN`, `-0`)
|
|
83
|
+
- Fix the regular expression for bare TOML keys ensuring correct quoted keys interpretation (`"tater.man"` != `tater.man`)
|
|
84
|
+
- Fix nested inline tables issues
|
|
85
|
+
- Fix ghost offset when TOML has no top-level key/value pairs
|
|
86
|
+
- Fix regex for newline matching
|
|
87
|
+
|
|
88
|
+
### Security
|
|
89
|
+
- Add Socket Free Firewall ([#53](https://github.com/DecimalTurn/toml-patch/pull/53))
|
|
90
|
+
|
|
91
|
+
### Changed
|
|
92
|
+
- Updated submodules/toml-test digest to 1d35870
|
|
93
|
+
- Update actions/upload-artifact action to v5
|
|
94
|
+
- Updated rollup to versions up to v4.52.5
|
|
95
|
+
- Updated TypeScript to v5.9.3
|
|
96
|
+
- Updated ts-jest to v29.4.5
|
|
97
|
+
- Updated jest monorepo to v30
|
|
98
|
+
- Updated dedent to v1.7.0
|
|
99
|
+
- Updated js-yaml to v4
|
|
100
|
+
- Updated @rollup/plugin-typescript to v12.3.0
|
|
101
|
+
- Updated actions/setup-node to v6
|
|
102
|
+
- Updated socketdev/action to v1.2.0
|
|
103
|
+
|
|
104
|
+
### Other
|
|
105
|
+
- Expand benchmarks ([#61](https://github.com/DecimalTurn/toml-patch/pull/61))
|
|
106
|
+
|
|
107
|
+
## [0.3.7] - 2025-08-20
|
|
108
|
+
|
|
109
|
+
### Added
|
|
110
|
+
- Package is now available on jsr.io: https://jsr.io/@decimalturn/toml-patch
|
|
111
|
+
|
|
112
|
+
### Changed
|
|
113
|
+
- Documentation and package description update
|
|
114
|
+
|
|
115
|
+
## [0.3.3] - 2025-05-10
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
- Handle key-value vs inline-item mixup ([#4](https://github.com/DecimalTurn/toml-patch/pull/4))
|
|
119
|
+
|
|
120
|
+
## [0.3.2] - 2025-04-13
|
|
121
|
+
|
|
122
|
+
### Fixed
|
|
123
|
+
- Fix replacement from Inline-Table to String Value ([#3](https://github.com/DecimalTurn/toml-patch/pull/3))
|
|
124
|
+
|
|
125
|
+
## [0.3.1] - 2025-04-12
|
|
126
|
+
|
|
127
|
+
### Fixed
|
|
128
|
+
- Fix inline-table element deletion ([#1](https://github.com/DecimalTurn/toml-patch/pull/1))
|
|
129
|
+
- Fix inline-table edition ([#2](https://github.com/DecimalTurn/toml-patch/pull/2))
|
|
130
|
+
|
|
131
|
+
## [0.3.0] - 2025-04-12
|
|
132
|
+
|
|
133
|
+
This first forked version from [timhall/toml-patch](https://github.com/timhall/toml-patch):
|
|
134
|
+
|
|
135
|
+
### Added
|
|
136
|
+
- Now available from npm: https://www.npmjs.com/package/@decimalturn/toml-patch
|
|
137
|
+
|
|
138
|
+
### Fixed
|
|
139
|
+
- Fix [timhall/toml-patch#27](https://github.com/timhall/toml-patch/issues/27)
|
|
140
|
+
- Fix [timhall/toml-patch#25](https://github.com/timhall/toml-patch/issues/25)
|
|
141
|
+
- Fix [timhall/toml-patch#10](https://github.com/timhall/toml-patch/issues/10)
|
|
142
|
+
|
|
143
|
+
### Changed
|
|
144
|
+
- Updates dependencies
|
|
145
|
+
- Ensures all latest spec tests from https://github.com/iarna/toml-spec-tests are passing (1880b1a)
|
package/README.md
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
Patch, parse, and stringify [TOML](https://toml.io/en/) (v1.1.0) while preserving comments and formatting.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
This project started as a fork of the [original toml-patch](https://github.com/timhall/toml-patch) but has since evolved into a standalone project with significant improvements in reliability and features. We've added TOML v1.1 support, introduced new APIs like `TomlDocument` and `TomlFormat` classes, fixed numerous bugs through comprehensive testing with toml-test, and continue to actively maintain and improve the package.
|
|
10
|
+
|
|
11
|
+
We hope that these improvements can be incorporated upstream one day if the original author returns, but until then, this project is the actively maintained version.
|
|
11
12
|
|
|
12
13
|
## Table of Contents
|
|
13
14
|
|
|
@@ -37,7 +38,7 @@ Hopefully, the work done here can go upstream one day if timhall returns, but un
|
|
|
37
38
|
- [Complete Example](#complete-example)
|
|
38
39
|
- [Legacy Format Objects](#legacy-format-objects)
|
|
39
40
|
- [Changelog](#changelog)
|
|
40
|
-
- [
|
|
41
|
+
- [Contributing](#contributing)
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
## Installation
|
|
@@ -622,13 +623,6 @@ const result = stringify(data, format);
|
|
|
622
623
|
|
|
623
624
|
For a detailed history of changes, see the [CHANGELOG](CHANGELOG.md).
|
|
624
625
|
|
|
625
|
-
##
|
|
626
|
-
|
|
627
|
-
1. Update submodules: `git submodule update --remote`
|
|
628
|
-
2. Typecheck: `npm run typecheck`
|
|
629
|
-
3. Build: `npm run build`
|
|
630
|
-
4. Test: `npm test`
|
|
631
|
-
5. Specs compliance: `npm run specs`
|
|
632
|
-
6. Benchmark: `npm run benchmark`
|
|
626
|
+
## Contributing
|
|
633
627
|
|
|
634
|
-
|
|
628
|
+
We welcome contributions! Please see the [CONTRIBUTING](CONTRIBUTING.md) guide for details on how to get started, development workflow, and pull request requirements.
|
package/dist/toml-patch.d.ts
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v1.0.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
var e,t;function n(t){return t.type===e.Document}function r(t){return t.type===e.Table}function o(t){return t.type===e.TableArray}function i(t){return t.type===e.KeyValue}function l(t){return t.type===e.String}function a(t){return t.type===e.DateTime}function s(t){return t.type===e.InlineArray}function c(t){return t.type===e.InlineItem}function u(t){return t.type===e.InlineTable}function f(t){return t.type===e.Comment}function d(e){return n(e)||r(e)||o(e)||u(e)||s(e)}function m(t){return function(t){return t.type===e.TableKey}(t)||function(t){return t.type===e.TableArrayKey}(t)||c(t)}!function(e){e.Document="Document",e.Table="Table",e.TableKey="TableKey",e.TableArray="TableArray",e.TableArrayKey="TableArrayKey",e.KeyValue="KeyValue",e.Key="Key",e.String="String",e.Integer="Integer",e.Float="Float",e.Boolean="Boolean",e.DateTime="DateTime",e.InlineArray="InlineArray",e.InlineItem="InlineItem",e.InlineTable="InlineTable",e.Comment="Comment"}(e||(e={}));class h{constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){var e;if(this.done)return p();const t=this.peeked||this.iterator.next();return this.index+=1,this.value=t.value,this.done=null!==(e=t.done)&&void 0!==e&&e,this.peeked=null,t}peek(){return this.done?p():(this.peeked||(this.peeked=this.iterator.next()),this.peeked)}[Symbol.iterator](){return this}}function p(){return{value:void 0,done:!0}}function w(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function g(e,t){const n=Array.isArray(e)?e:y(e),r=n.findIndex((e=>e>=t))+1;return{line:r,column:t-(n[r-2]+1||0)}}function y(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];"\n"===r?t.push(n):"\r"===r&&("\n"===e[n+1]?(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 b(e){return{start:v(e.start),end:v(e.end)}}class $ extends Error{constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){const n=function(e,t){const n=y(e),r=void 0!==n[t.line-2]?n[t.line-2]+1:0,o=n[t.line-1]||e.length;return e.substring(r,o)}(e,t),o=`${function(e,t=" "){return t.repeat(e)}(t.column)}^`;n&&(r+=`${n}\n${o}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}}!function(e){e.Bracket="Bracket",e.Curly="Curly",e.Equal="Equal",e.Comma="Comma",e.Dot="Dot",e.Comment="Comment",e.Literal="Literal"}(t||(t={}));const S=/\s/,T='"',I="'",k=/[\w,\d,\",\',\+,\-,\_]/;function*x(e){const n=new h("string"==typeof(r=e)?function*(e){for(let t=0;t<e.length;t++)yield e[t]}(r):r[Symbol.iterator]());var r;n.next();const o=function(e){const t=y(e);return(e,n)=>({start:g(t,e),end:g(t,n)})}(e);for(;!n.done;){const r=n.value.charCodeAt(0);if((r<=31||127===r)&&9!==r&&13!==r&&10!==r)throw new $(e,g(e,n.index),`Control character 0x${r.toString(16).toUpperCase().padStart(2,"0")} is not allowed in TOML`);if("\r"===n.value){const t=n.peek();if(t.done||"\n"!==t.value)throw new $(e,g(e,n.index),"Invalid standalone CR (\\r); CR must be part of a CRLF sequence")}if(S.test(n.value));else if("["===n.value||"]"===n.value)yield E(n,o,t.Bracket);else if("{"===n.value||"}"===n.value)yield E(n,o,t.Curly);else if("="===n.value)yield E(n,o,t.Equal);else if(","===n.value)yield E(n,o,t.Comma);else if("."===n.value)yield E(n,o,t.Dot);else if("#"===n.value)yield A(n,o,e);else{const t=O(e,n.index,I)||O(e,n.index,T);t?yield C(n,o,t,e):yield _(n,o,e)}n.next()}}function E(e,t,n){return{type:n,raw:e.value,loc:t(e.index,e.index+1)}}function A(e,n,r){const o=e.index;let i=e.value;for(;!e.peek().done&&"\n"!==e.peek().value&&"\r"!==e.peek().value;){e.next();const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t)throw new $(r,g(r,e.index),`Control character 0x${t.toString(16).toUpperCase().padStart(2,"0")} is not allowed in TOML`);i+=e.value}return{type:t.Comment,raw:i,loc:n(o,e.index+1)}}function C(e,n,r,o){const i=e.index,l=r+r+r;let a=l;for(e.next(),e.next(),e.next();!e.done;){if(O(o,e.index,r)){let t=3;for(;o[e.index+t]===r;)t++;if(t>=6)throw new $(o,g(o,e.index),`Invalid multiline string: ${t} consecutive ${r} characters`);if(3===t)break;a+=r.repeat(t-3);for(let n=0;n<t-3;n++)e.next();break}if("\r"===e.value){const t=e.peek();if(t.done||"\n"!==t.value)throw new $(o,g(o,e.index),"Invalid standalone CR (\\r) in multiline string (must be part of CRLF sequence)")}const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t&&10!==t&&13!==t){const n=r===T?"multiline basic strings":"multiline literal strings",i=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let l="";0===t?l="Null":127===t&&(l="DEL");const a=l?`${l} (control character ${i}) is not allowed in ${n}`:`Control character ${i} is not allowed in ${n}`;throw new $(o,g(o,e.index),a)}a+=e.value,e.next()}if(e.done){if(r===T){const t=o.slice(0,e.index);if(/\\"+$/.test(t))throw new $(o,g(o,e.index),`Expected close of multiline string with ${l}, reached end of file. Check for escape sequences (\\) that may be preventing proper string closure`)}throw new $(o,g(o,e.index),`Expected close of multiline string with ${l}, reached end of file`)}return a+=l,e.next(),e.next(),{type:t.Literal,raw:a,loc:n(i,e.index+1)}}function _(e,n,r){if(!k.test(e.value))throw new $(r,g(r,e.index),`Unsupported character "${e.value}". Expected ALPHANUMERIC, ", ', +, -, or _`);const o=e.index;let i=e.value,l=e.value===T,a=e.value===I;const s=e=>{if(e.peek().done)return!0;const t=e.peek().value;return!(l||a)&&(S.test(t)||","===t||"."===t||"]"===t||"}"===t||"="===t||"#"===t)};for(;!e.done&&!s(e);){if(e.next(),l||a){const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t){const n=l?"basic strings":"literal strings",o=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let i="";10===t?i="Newline":13===t?i="Carriage return":0===t?i="Null":127===t&&(i="DEL");const a=i?`${i} (control character ${o}) is not allowed in ${n}`:`Control character ${o} is not allowed in ${n}`;throw new $(r,g(r,e.index),a)}}if(e.value===T&&(l=!l),e.value!==I||l||(a=!a),i+=e.value,e.peek().done)break;let t=e.peek().value;l&&"\\"===e.value&&(t===T?(i+=T,e.next()):"\\"===t&&(i+="\\",e.next()))}if(l||a)throw new $(r,g(r,o),`Expected close of string with ${l?T:I}`);return{type:t.Literal,raw:i,loc:n(o,e.index+1)}}function O(e,t,n){if(!n)return!1;if(!(e[t]===n&&e[t+1]===n&&e[t+2]===n))return!1;if(n===I)return n;const r=e.slice(0,t).match(/\\+$/);if(!r)return n;return!(r[0].length%2!=0)&&n}function U(e){return e[e.length-1]}function D(){return Object.create(null)}function F(e){return"number"==typeof e&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function L(e){return"[object Date]"===Object.prototype.toString.call(e)}function M(e){return e&&"object"==typeof e&&!L(e)&&!Array.isArray(e)}function K(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function N(e,...t){return t.reduce(((e,t)=>t(e)),e)}function j(e){if(M(e)){return`{${Object.keys(e).sort().map((t=>`${JSON.stringify(t)}:${j(e[t])}`)).join(",")}}`}return Array.isArray(e)?`[${e.map(j).join(",")}]`:JSON.stringify(e)}function Z(e,t){const n=e.length,r=t.length;e.length=n+r;for(let o=0;o<r;o++)e[n+o]=t[o]}function W(e){return e.startsWith('"""')||e.startsWith("'''")}const z=/\r\n/g,B=/\n/g,q=/^(\r\n|\n)/,V=/(?<!\\)(?:\\\\)*(\\\s*[\n\r\n]\s*)/g;function P(e){return e.startsWith("'''")?N(Y(e,3),X):e.startsWith(I)?Y(e,1):e.startsWith('"""')?N(Y(e,3),X,Q,G,R,J):e.startsWith(T)?N(Y(e,1),J):e}function R(e){let t="",n=0;for(let r=0;r<e.length;r++){const o=e[r];t+='"'===o&&n%2==0?'\\"':o,"\\"===o?n++:n=0}return t}function H(e,t){let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r--)n++;return n%2!=0}function J(e){const t=/\\(.)/g;let n;for(;null!==(n=t.exec(e));){if(H(e,n.index))continue;const t=n[1];if(!["b","t","n","f","r",'"',"\\","e","u","U","x"].includes(t))throw new Error(`Invalid escape sequence: \\${t}`)}const r=/\\u([a-fA-F0-9]{4})/g,o=e;for(;null!==(n=r.exec(o));){if(H(o,n.index))continue;const e=n[1],t=parseInt(e,16);if(t>=55296&&t<=57343)throw new Error(`Invalid Unicode escape: \\u${e} (surrogate codepoints are not allowed)`)}const i=e;let l=i.replace(/\\x([a-fA-F0-9]{2})/g,((e,t,n)=>{if(H(i,n))return e;const r=parseInt(t,16),o=String.fromCharCode(r);return r<32||34===r||92===r?Y(JSON.stringify(o),1):o}));const a=l;l=a.replace(/\\e/g,((e,t)=>H(a,t)?e:"\\u001b"));const s=l.replace(/\\U[a-fA-F0-9]{8}/g,(e=>{const t=parseInt(e.replace("\\U",""),16),n=String.fromCodePoint(t);return Y(JSON.stringify(n),1)})),c=s.replace(/\t/g,"\\t");return JSON.parse(`"${c}"`)}function Y(e,t){return e.slice(t,e.length-t)}function X(e){return e.replace(q,"")}function G(e){return e.replace(z,"\\r\\n").replace(B,"\\n")}function Q(e){return e.replace(V,((e,t)=>e.replace(t,"")))}class ee{static createDateWithOriginalFormat(e,t){if(ee.IS_DATE_ONLY.test(t)){if(0!==e.getUTCHours()||0!==e.getUTCMinutes()||0!==e.getUTCSeconds()||0!==e.getUTCMilliseconds()){if(e instanceof oe)return e;let t=e.toISOString().replace("Z","");return t=t.replace(/\.000$/,""),new re(t,!1)}const t=e.toISOString().split("T")[0];return new te(t)}if(ee.IS_TIME_ONLY.test(t)){if(e instanceof ne)return e;{const n=t.match(/\.(\d+)\s*$/),r=e.toISOString();if(r&&r.includes("T")){let o=r.split("T")[1].split("Z")[0];if(n){const t=n[1].length,[r,i,l]=o.split(":"),[a]=l.split(".");o=`${r}:${i}:${a}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new ne(o,t)}{const r=String(e.getUTCHours()).padStart(2,"0"),o=String(e.getUTCMinutes()).padStart(2,"0"),i=String(e.getUTCSeconds()).padStart(2,"0"),l=e.getUTCMilliseconds();let a;if(n){const e=n[1].length;a=`${r}:${o}:${i}.${String(l).padStart(3,"0").slice(0,e)}`}else if(l>0){a=`${r}:${o}:${i}.${String(l).padStart(3,"0").replace(/0+$/,"")}`}else a=`${r}:${o}:${i}`;return new ne(a,t)}}}if(ee.IS_LOCAL_DATETIME_T.test(t)){const n=t.match(/\.(\d+)\s*$/);let r=e.toISOString().replace("Z","");if(n){const t=n[1].length,[o,i]=r.split("T"),[l,a,s]=i.split(":"),[c]=s.split(".");r=`${o}T${l}:${a}:${c}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new re(r,!1,t)}if(ee.IS_LOCAL_DATETIME_SPACE.test(t)){const n=t.match(/\.(\d+)\s*$/);let r=e.toISOString().replace("Z","").replace("T"," ");if(n){const t=n[1].length,[o,i]=r.split(" "),[l,a,s]=i.split(":"),[c]=s.split(".");r=`${o} ${l}:${a}:${c}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new re(r,!0,t)}if(ee.IS_OFFSET_DATETIME_T.test(t)||ee.IS_OFFSET_DATETIME_SPACE.test(t)){const n=t.match(/([+-]\d{2}:\d{2}|[Zz])$/),r=n?"z"===n[1]?"Z":n[1]:"Z",o=ee.IS_OFFSET_DATETIME_SPACE.test(t),i=t.match(/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),l=e.getTime();let a=0;if("Z"!==r){const e="+"===r[0]?1:-1,[t,n]=r.slice(1).split(":");a=e*(60*parseInt(t)+parseInt(n))}const s=new Date(l+6e4*a),c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=String(s.getUTCHours()).padStart(2,"0"),m=String(s.getUTCMinutes()).padStart(2,"0"),h=String(s.getUTCSeconds()).padStart(2,"0"),p=s.getUTCMilliseconds(),w=o?" ":"T";let g=`${d}:${m}:${h}`;if(i){const e=i[1].length;g+=`.${String(p).padStart(3,"0").slice(0,e)}`}else if(p>0){g+=`.${String(p).padStart(3,"0").replace(/0+$/,"")}`}return new oe(`${c}-${u}-${f}${w}${g}${r}`,o)}return e}}ee.IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/,ee.IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,ee.IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,ee.IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/,ee.IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;class te extends Date{constructor(e){super(e)}toISOString(){return`${this.getUTCFullYear()}-${String(this.getUTCMonth()+1).padStart(2,"0")}-${String(this.getUTCDate()).padStart(2,"0")}`}}class ne extends Date{constructor(e,t){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+":00"),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){const e=String(this.getUTCHours()).padStart(2,"0"),t=String(this.getUTCMinutes()).padStart(2,"0"),n=String(this.getUTCSeconds()).padStart(2,"0"),r=this.getUTCMilliseconds();if(this.originalFormat&&this.originalFormat.includes(".")){const o=this.originalFormat.match(/\.(\d+)\s*$/),i=o?o[1].length:3;return`${e}:${t}:${n}.${String(r).padStart(3,"0").slice(0,i)}`}if(r>0){return`${e}:${t}:${n}.${String(r).padStart(3,"0").replace(/0+$/,"")}`}return`${e}:${t}:${n}`}}class re extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){const e=this.getUTCFullYear(),t=String(this.getUTCMonth()+1).padStart(2,"0"),n=String(this.getUTCDate()).padStart(2,"0"),r=String(this.getUTCHours()).padStart(2,"0"),o=String(this.getUTCMinutes()).padStart(2,"0"),i=String(this.getUTCSeconds()).padStart(2,"0"),l=this.getUTCMilliseconds(),a=`${e}-${t}-${n}`,s=this.useSpaceSeparator?" ":"T";if(this.originalFormat&&this.originalFormat.includes(".")){const e=this.originalFormat.match(/\.(\d+)\s*$/),t=e?e[1].length:3;return`${a}${s}${r}:${o}:${i}.${String(l).padStart(3,"0").slice(0,t)}`}if(l>0){return`${a}${s}${r}:${o}:${i}.${String(l).padStart(3,"0").replace(/0+$/,"")}`}return`${a}${s}${r}:${o}:${i}`}}class oe extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=e;const r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset="z"===r[1]?"Z":r[1])}toISOString(){if(this.originalOffset){const e=this.getTime();let t=0;if("Z"!==this.originalOffset){const e="+"===this.originalOffset[0]?1:-1,[n,r]=this.originalOffset.slice(1).split(":");t=e*(60*parseInt(n)+parseInt(r))}const n=new Date(e+6e4*t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),i=String(n.getUTCDate()).padStart(2,"0"),l=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),s=String(n.getUTCSeconds()).padStart(2,"0"),c=n.getUTCMilliseconds(),u=`${r}-${o}-${i}`,f=this.useSpaceSeparator?" ":"T";if(this.originalFormat&&this.originalFormat.includes(".")){const e=this.originalFormat.match(/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),t=e?e[1].length:3;return`${u}${f}${l}:${a}:${s}.${String(c).padStart(3,"0").slice(0,t)}${this.originalOffset}`}if(c>0){return`${u}${f}${l}:${a}:${s}.${String(c).padStart(3,"0").replace(/0+$/,"")}${this.originalOffset}`}return`${u}${f}${l}:${a}:${s}${this.originalOffset}`}const e=super.toISOString();return this.useSpaceSeparator?e.replace("T"," "):e}}const ie=ee,le="true",ae=/e/i,se=/\_/g,ce=/^[+\-]?inf$/,ue=/^[+\-]?nan$/,fe=/^[+\-]?0x/i,de=/^[+\-]?0o/i,me=/^[+\-]?0b/i;function*he(e){const t=new h(x(e));for(;!t.next().done;){const n=Se(t,e);for(const e of n)yield e}}function pe(t){return{type:e.Comment,loc:t.value.loc,raw:t.value.raw}}function we(n,r){const o=n.peek().done||n.peek().value.type!==t.Bracket?e.Table:e.TableArray,i=o===e.Table;if(i&&"["!==n.value.raw)throw new $(r,n.value.loc.start,`Expected table opening "[", found ${n.value.raw}`);if(!i){const e=n.peek();if(e.done)throw new $(r,n.value.loc.start,'Expected second "[" for array of tables opening, found end of input');if("["!==n.value.raw||"["!==e.value.raw)throw new $(r,n.value.loc.start,`Expected array of tables opening "[[", found ${n.value.raw+e.value.raw}`);const t=n.value,o=e.value;if(t.loc.end.line!==o.loc.start.line||t.loc.end.column!==o.loc.start.column)throw new $(r,t.loc.start,"Array of tables opening brackets must be immediately adjacent with no whitespace: [[table]]")}const l=i?{type:e.TableKey,loc:n.value.loc}:{type:e.TableArrayKey,loc:n.value.loc};if(n.next(),o===e.TableArray&&n.next(),n.done)throw new $(r,l.loc.start,"Expected table key, reached end of file");if(n.value.type===t.Bracket&&"]"===n.value.raw)throw new $(r,n.value.loc.start,o===e.TableArray?"Array of tables header [[]] requires a table name":"Table header [] requires a table name");const a=n.value.raw;if(a.startsWith('"""')||a.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!(a.startsWith('"')||a.startsWith("'")))for(let e=0;e<a.length;e++){const t=a[e];if(!/[A-Za-z0-9_-]/.test(t))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${t}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}let s;try{s=[P(n.value.raw)]}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}for(l.item={type:e.Key,loc:b(n.value.loc),raw:n.value.raw,value:s};!n.peek().done&&n.peek().value.type===t.Dot;){n.next();const e=n.value;n.next();const t=n.value.raw;if(!(t.startsWith('"')||t.startsWith("'")))for(let e=0;e<t.length;e++){const o=t[e];if(!/[A-Za-z0-9_-]/.test(o))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${o}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}const o=" ".repeat(e.loc.start.column-l.item.loc.end.column),i=" ".repeat(n.value.loc.start.column-e.loc.end.column);l.item.loc.end=n.value.loc.end,l.item.raw+=`${o}.${i}${n.value.raw}`;try{l.item.value.push(P(n.value.raw))}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}}if(n.next(),!n.done){const e=l.loc.start.line;if(n.value.loc.start.line!==e)throw new $(r,n.value.loc.start,i?`Table header must not contain newlines. Expected closing ']' on line ${e}, found on line ${n.value.loc.start.line}`:`Unclosed array of tables header: expected closing ']]' on line ${e}, found newline`)}if(i&&(n.done||"]"!==n.value.raw))throw new $(r,n.done?l.item.loc.end:n.value.loc.start,`Expected table closing "]", found ${n.done?"end of file":n.value.raw}`);if(!i&&(n.done||n.peek().done||"]"!==n.value.raw||"]"!==n.peek().value.raw))throw new $(r,n.done||n.peek().done?l.item.loc.end:n.value.loc.start,`Expected array of tables closing "]]", found ${n.done||n.peek().done?"end of file":n.value.raw+n.peek().value.raw}`);if(!i){const e=n.value,t=n.peek().value;if(e.loc.end.line!==t.loc.start.line||e.loc.end.column!==t.loc.start.column)throw new $(r,e.loc.start,"Array of tables closing brackets must be immediately adjacent with no whitespace: ]]")}if(i||n.next(),l.loc.end=n.value.loc.end,!n.peek().done){const e=n.peek().value;if(e.loc.start.line===l.loc.end.line&&e.type!==t.Comment)throw new $(r,e.loc.start,`Unexpected content after ${i?"table":"array of tables"} header`)}let c=[];for(;!n.peek().done&&n.peek().value.type!==t.Bracket;)n.next(),Z(c,Se(n,r));return{type:i?e.Table:e.TableArray,loc:{start:v(l.loc.start),end:v(c.length?c[c.length-1].loc.end:l.loc.end)},key:l,items:c}}function ge(t,n){let r;try{r=P(t.value.raw)}catch(e){const r=e;throw new $(n,t.value.loc.start,r.message)}return{type:e.String,loc:t.value.loc,raw:t.value.raw,value:r}}function ye(t){return{type:e.Boolean,loc:t.value.loc,value:t.value.raw===le}}function ve(n,r){let o,i=n.value.loc,l=n.value.raw;if(!n.peek().done&&n.peek().value.type===t.Literal&&ie.IS_FULL_DATE.test(l)&&ie.IS_FULL_TIME.test(n.peek().value.raw)){const e=i.start;n.next(),i={start:e,end:n.value.loc.end},l+=` ${n.value.raw}`}if(!n.peek().done&&n.peek().value.type===t.Dot){const e=i.start;if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new $(r,n.value.loc.end,"Expected fractional value for DateTime");n.next(),i={start:e,end:n.value.loc.end},l+=`.${n.value.raw}`}if(function(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new $(t,n,`Invalid datetime "${e}": fractional seconds must have at least one digit after decimal point`);if(/[+-]$/.test(e))throw new $(t,n,`Invalid datetime "${e}": timezone offset requires hour and minute components`);const r=/\d{2}:\d{2}/.test(e),o=r?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(o){const e=o[0],r=o[2],i=o[3],l=o[4];if(":"!==i)throw new $(t,n,`Invalid timezone offset "${e}": must use colon separator (e.g., +09:09)`);if(2!==r.length)throw new $(t,n,`Invalid timezone offset "${e}": hour must be exactly 2 digits`);if(!l||0===l.length)throw new $(t,n,`Invalid timezone offset "${e}": minute component is required`);if(2!==l.length)throw new $(t,n,`Invalid timezone offset "${e}": minute must be exactly 2 digits`);const a=parseInt(r,10);if(a<0||a>23)throw new $(t,n,`Invalid timezone offset "${e}": hour must be between 00 and 23, found ${r}`);const s=parseInt(l,10);if(s<0||s>59)throw new $(t,n,`Invalid timezone offset "${e}": minute must be between 00 and 59, found ${l}`)}const i=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!i.test(e)){if(/^\d{4}-\d{2}-\d{2}T$/.test(e))throw new $(t,n,`Invalid date "${e}": date cannot end with 'T' without a time component`);if(/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e))throw new $(t,n,`Invalid date "${e}": unexpected character after date`);if(/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e))throw new $(t,n,`Invalid datetime "${e}": missing separator 'T' or space between date and time`);throw new $(t,n,`Invalid datetime "${e}"`)}const l=e.match(/^(\d+)-/);if(l&&4!==l[1].length)throw new $(t,n,`Invalid date "${e}": year must be exactly 4 digits, found ${l[1].length}`);const a=/^(\d+)-(\d+)-(\d+)/,s=e.match(a);if(s){const[,,r,o]=s;if(2!==r.length)throw new $(t,n,`Invalid date "${e}": month must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid date "${e}": day must be exactly 2 digits, found ${o.length}`)}const c=/[T ](\d+):(\d+)(?::(\d+))?/,u=e.match(c);if(u){const[,r,o,i]=u;if(2!==r.length)throw new $(t,n,`Invalid time "${e}": hour must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid time "${e}": minute must be exactly 2 digits, found ${o.length}`);if(i&&2!==i.length)throw new $(t,n,`Invalid time "${e}": second must be exactly 2 digits, found ${i.length}`)}const f=/^(\d+):(\d+)(?::(\d+))?/,d=e.match(f);if(d&&!s){const[,r,o,i]=d;if(2!==r.length)throw new $(t,n,`Invalid time "${e}": hour must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid time "${e}": minute must be exactly 2 digits, found ${o.length}`);if(i&&2!==i.length)throw new $(t,n,`Invalid time "${e}": second must be exactly 2 digits, found ${i.length}`)}const m=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),h=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(m){const[,r,o,i,l,a,s]=m,c=parseInt(o,10);if(c<1||c>12)throw new $(t,n,`Invalid date "${e}": month must be between 01 and 12`);const u=parseInt(i,10);if(u<1||u>31)throw new $(t,n,`Invalid date "${e}": day must be between 01 and 31`);const f=function(e,t){const n=[31,28,31,30,31,30,31,31,30,31,30,31];if(2===t){return e%4==0&&e%100!=0||e%400==0?29:28}return n[t-1]}(parseInt(r,10),c);if(u>f)throw new $(t,n,`Invalid date "${e}": day ${i} is invalid for month ${o} in year ${r}`);if(void 0!==l){const r=parseInt(l,10);if(r<0||r>23)throw new $(t,n,`Invalid time "${e}": hour must be between 00 and 23`)}if(void 0!==a){const r=parseInt(a,10);if(r<0||r>59)throw new $(t,n,`Invalid time "${e}": minute must be between 00 and 59`)}if(void 0!==s){const r=parseInt(s,10);if(r<0||r>60)throw new $(t,n,`Invalid time "${e}": second must be between 00 and 60`)}}else if(h){const[,r,o,i]=h,l=parseInt(r,10);if(l<0||l>23)throw new $(t,n,`Invalid time "${e}": hour must be between 00 and 23`);const a=parseInt(o,10);if(a<0||a>59)throw new $(t,n,`Invalid time "${e}": minute must be between 00 and 59`);if(void 0!==i){const r=parseInt(i,10);if(r<0||r>60)throw new $(t,n,`Invalid time "${e}": second must be between 00 and 60`)}}}(l,r,i.start),ie.IS_FULL_DATE.test(l))o=ie.IS_DATE_ONLY.test(l)?new te(l):ie.IS_LOCAL_DATETIME_T.test(l)?new re(l,!1):ie.IS_LOCAL_DATETIME_SPACE.test(l)?new re(l,!0):ie.IS_OFFSET_DATETIME_T.test(l)?new oe(l,!1):ie.IS_OFFSET_DATETIME_SPACE.test(l)?new oe(l,!0):new Date(l.replace(" ","T"));else if(ie.IS_TIME_ONLY.test(l))o=new ne(l,l);else{const[e]=(new Date).toISOString().split("T");o=new Date(`${e}T${l}`)}return{type:e.DateTime,loc:i,raw:l,value:o}}function be(n,r){let o,i=n.value.loc,l=n.value.raw;if(ce.test(l))o=l.startsWith("-")?-1/0:1/0;else if(ue.test(l))o=NaN;else if(n.peek().done||n.peek().value.type!==t.Dot){if(/_$/.test(l))throw new $(r,i.start,"Underscore before decimal point is not allowed");if(/^[+\-]?_/.test(l))throw new $(r,i.start,"Leading underscore is not allowed");if(/__/.test(l))throw new $(r,i.start,"Consecutive underscores are not allowed");if(/[eE][+\-]?$/.test(l))throw new $(r,i.start,`Invalid float "${l}": incomplete exponent`);if(/[eE][+\-]?.*\./.test(l))throw new $(r,i.start,`Invalid float "${l}": decimal point not allowed in exponent`);if(/_[eE]/.test(l))throw new $(r,i.start,"Underscore before exponent is not allowed");if(/[eE][+\-]?_/.test(l))throw new $(r,i.start,"Underscore at start of exponent is not allowed");if(!n.peek().done&&n.peek().value.type===t.Dot)throw new $(r,n.peek().value.loc.start,`Invalid float "${l}.": cannot have decimal point after exponent`);const e=l.replace(se,"");if(/^[+\-]?0\d/.test(e)&&!fe.test(l)&&!de.test(l)&&!me.test(l))throw new $(r,i.start,"Leading zeros are not allowed in the integer part of a float");o=Number(l.replace(se,""))}else{const e=i.start;{if(ae.test(l)&&!fe.test(l))throw new $(r,i.start,`Invalid float "${l}": cannot have decimal point after exponent`);const e=l,t=e.replace(se,"");if(/^[+\-]?0\d/.test(t)&&!fe.test(e)&&!de.test(e)&&!me.test(e))throw new $(r,i.start,"Leading zeros are not allowed in the integer part of a float");const n=e.replace(/^[+\-]/,"");if(""===n||"_"===n)throw new $(r,i.start,"Invalid float: decimal point must be preceded by at least one digit");if(/_$/.test(e))throw new $(r,i.start,"Underscore before decimal point is not allowed");if(/^[+\-]?_/.test(e))throw new $(r,i.start,"Leading underscore is not allowed");if(/__/.test(e))throw new $(r,i.start,"Consecutive underscores are not allowed")}if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new $(r,n.value.loc.end,"Expected fraction value for Float");n.next(),l+=`.${n.value.raw}`,i={start:e,end:n.value.loc.end};{const e=n.value.raw;if(!/^\d/.test(e))throw new $(r,n.value.loc.start,`Invalid float: fractional part must start with a digit, found "${e}"`);if(/^_/.test(e))throw new $(r,n.value.loc.start,"Underscore after decimal point is not allowed");if(/_$/.test(e))throw new $(r,n.value.loc.start,"Trailing underscore in fractional part is not allowed");if(/_[eE]/.test(e))throw new $(r,n.value.loc.start,"Underscore before exponent is not allowed");if(/[eE][+\-]?_/.test(e))throw new $(r,n.value.loc.start,"Underscore at start of exponent is not allowed");if(/[eE][+\-]?$/.test(e))throw new $(r,n.value.loc.start,`Invalid float "${l}": incomplete exponent`);if(/[eE][+\-]?.*\./.test(e))throw new $(r,n.value.loc.start,`Invalid float "${l}": decimal point not allowed in exponent`)}o=Number(l.replace(se,""))}if(Number.isNaN(o)&&!ue.test(l))throw new $(r,i.start,`Invalid float "${l}"`);return{type:e.Float,loc:i,raw:l,value:o}}function $e(t,n){const r=t.value.raw,o=t.value.loc;if(/^\d{1,}-\d{1,}/.test(r)||/^\d{1,}:\d{1,}/.test(r)||/^\d{6}-\d{2}$/.test(r))throw new $(n,o.start,`Invalid integer "${r}"`);{if("-0"===r||"+0"===r)return{type:e.Integer,loc:o,raw:r,value:0};if(/^[+\-]{2,}/.test(r))throw new $(n,o.start,"Double sign is not allowed in integers");const t=r.replace(/_/g,"");if(/^[+\-]?0\d/.test(t)&&!fe.test(r)&&!de.test(r)&&!me.test(r))throw new $(n,o.start,"Leading zeros are not allowed in decimal integers");if(/_$/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(/^[+\-]?_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(/__/.test(r))throw new $(n,o.start,"Consecutive underscores in numbers are not allowed")}let i,l=10;if(fe.test(r)){if(l=16,/^[+\-]?0X/.test(r))throw new $(n,o.start,'Hexadecimal prefix must be lowercase "0x"');if(/^[+\-]?0x_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0x/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete hexadecimal number");const e=i.replace(/_/g,"");if(!/^[0-9a-fA-F]+$/.test(e))throw new $(n,o.start,"Invalid hexadecimal digits");if(/^[+\-]/.test(r))throw new $(n,o.start,"Hexadecimal numbers cannot have a sign prefix")}else if(de.test(r)){if(l=8,/^[+\-]?0O/.test(r))throw new $(n,o.start,'Octal prefix must be lowercase "0o"');if(/^[+\-]?0o_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0o/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete octal number");const e=i.replace(/_/g,"");if(!/^[0-7]+$/.test(e))throw new $(n,o.start,"Invalid octal digits (must be 0-7)");if(/^[+\-]/.test(r))throw new $(n,o.start,"Octal numbers cannot have a sign prefix")}else if(me.test(r)){if(l=2,/^[+\-]?0B/.test(r))throw new $(n,o.start,'Binary prefix must be lowercase "0b"');if(/^[+\-]?0b_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0b/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete binary number");const e=i.replace(/_/g,"");if(!/^[01]+$/.test(e))throw new $(n,o.start,"Invalid binary digits (must be 0 or 1)");if(/^[+\-]/.test(r))throw new $(n,o.start,"Binary numbers cannot have a sign prefix")}const a=parseInt(r.replace(se,"").replace(de,"").replace(me,""),l);if(Number.isNaN(a))throw new $(n,o.start,`Invalid integer "${r}"`);return{type:e.Integer,loc:o,raw:r,value:a}}function Se(n,r){if(n.value.type===t.Comment)return[pe(n)];if(n.value.type===t.Bracket)return[we(n,r)];if(n.value.type===t.Literal)return function(n,r){const o=n.value.raw;if(o.endsWith(":"))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+[...o].length-1},"Use '=' to separate keys and values, not ':'");if(o.startsWith('"""')||o.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!o.startsWith('"')&&!o.startsWith("'"))for(let e=0;e<o.length;e++){const t=o[e];if(!/[A-Za-z0-9_-]/.test(t))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${t}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}let i;try{i=[P(n.value.raw)]}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}const l={type:e.Key,loc:b(n.value.loc),raw:n.value.raw,value:i};for(;!n.peek().done&&n.peek().value.type===t.Dot;){n.next(),n.next();const e=n.value.raw;if(e.startsWith('"""')||e.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!(e.startsWith('"')||e.startsWith("'")))for(let t=0;t<e.length;t++){const o=e[t];if(!/[A-Za-z0-9_-]/.test(o))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+t},`Invalid character '${o}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}l.loc.end=n.value.loc.end,l.raw+=`.${n.value.raw}`;try{l.value.push(P(n.value.raw))}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}}if(n.next(),!n.done&&n.value.loc.start.line!==l.loc.end.line)throw new $(r,n.value.loc.start,'Expected "=" for key-value on the same line as the key');if(n.done||n.value.type!==t.Equal){if(!n.done&&":"===n.value.raw)throw new $(r,n.value.loc.start,"Use '=' to separate keys and values, not ':'");throw new $(r,n.done?l.loc.end:n.value.loc.start,'Expected "=" for key-value')}const a=n.value.loc.start.column,s=n.value.loc.start.line;if(n.next(),n.done)throw new $(r,l.loc.start,"Expected value for key-value, reached end of file");if(n.value.loc.start.line!==s)throw new $(r,n.value.loc.start,"Expected value on the same line as the '=' sign");if(n.done)throw new $(r,l.loc.start,"Expected value for key-value");const c=Te(n,r),u=c[0],f=c.slice(1);if(!n.peek().done){const o=n.peek().value;if(o.type===t.Dot&&o.loc.start.line===u.loc.end.line&&(u.type===e.Float||u.type===e.Integer))throw new $(r,o.loc.start,"Invalid number: multiple decimal points not allowed");if((o.type===t.Literal||o.type===t.Bracket)&&o.loc.start.line===u.loc.end.line)throw new $(r,o.loc.start,"Key/value pairs must be separated by a newline")}return[{type:e.KeyValue,key:l,value:u,loc:{start:v(l.loc.start),end:v(u.loc.end)},equals:a},...f]}(n,r);throw n.value.type===t.Equal?new $(r,n.value.loc.start,"Missing key before '='"):new $(r,n.value.loc.start,`Unexpected token "${n.value.type}". Expected Comment, Bracket, or String`)}function Te(n,r){if(n.value.type===t.Literal){const e=n.value.raw;return e[0]===T||e[0]===I?[ge(n,r)]:e===le||"false"===e?[ye(n)]:/^\d/.test(e)&&(/^\d{1,}-\d{1,}/.test(e)||/^\d{1,}:\d{1,}/.test(e))?[ve(n,r)]:!n.peek().done&&n.peek().value.type===t.Dot||ce.test(e)||ue.test(e)||ae.test(e)&&!fe.test(e)?[be(n,r)]:[$e(n,r)]}if(n.value.type===t.Curly){const[o,i]=function(n,r){if("{"!==n.value.raw)throw new $(r,n.value.loc.start,'Expected "{" for inline table');const o={type:e.InlineTable,loc:b(n.value.loc),items:[]},i=[];n.next();for(;!n.done&&(n.value.type!==t.Curly||"}"!==n.value.raw);){if(n.value.type===t.Comment){i.push(pe(n)),n.next();continue}if(n.value.type===t.Comma){const e=o.items[o.items.length-1];if(!e)throw new $(r,n.value.loc.start,'Found "," without previous value in inline table');if(e.comma)throw new $(r,n.value.loc.start,"Found consecutive commas in inline table (double comma is not allowed)");e.comma=!0,e.loc.end=n.value.loc.start,n.next();continue}const l=o.items[o.items.length-1];if(l&&!l.comma)throw new $(r,n.value.loc.start,"Missing comma between inline table items");const a=Se(n,r),s=a[0],c=a.slice(1);s.type===e.KeyValue&&(o.items.push({type:e.InlineItem,loc:b(s.loc),item:s,comma:!1}),Z(i,c)),n.next()}if(n.done||n.value.type!==t.Curly||"}"!==n.value.raw)throw new $(r,n.done?o.loc.start:n.value.loc.start,'Expected "}"');return o.loc.end=n.value.loc.end,[o,i]}(n,r);return[o,...i]}if(n.value.type===t.Bracket){const[o,i]=function(n,r){if("["!==n.value.raw)throw new $(r,n.value.loc.start,'Expected "[" for inline array');const o={type:e.InlineArray,loc:b(n.value.loc),items:[]},i=[];n.next();for(;!n.done&&(n.value.type!==t.Bracket||"]"!==n.value.raw);){if(n.value.type===t.Comma){const e=o.items[o.items.length-1];if(!e)throw new $(r,n.value.loc.start,'Found "," without previous value for inline array');if(e.comma)throw new $(r,n.value.loc.start,"Found consecutive commas in array (double comma is not allowed)");e.comma=!0,e.loc.end=n.value.loc.start}else if(n.value.type===t.Comment)i.push(pe(n));else{const t=o.items[o.items.length-1];if(t&&!t.comma)throw new $(r,n.value.loc.start,"Missing comma between array elements");const l=Te(n,r),a=l[0],s=l.slice(1);o.items.push({type:e.InlineItem,loc:b(a.loc),item:a,comma:!1}),Z(i,s)}n.next()}if(n.done||n.value.type!==t.Bracket||"]"!==n.value.raw)throw new $(r,n.done?o.loc.start:n.value.loc.start,'Expected "]"');return o.loc.end=n.value.loc.end,[o,i]}(n,r);return[o,...i]}throw n.value.type===t.Dot?new $(r,n.value.loc.start,"Invalid number: cannot start with a dot. Numbers must start with a digit"):new $(r,n.value.loc.start,"Unrecognized token type")}function Ie(t,n){var r;function o(e,t){for(const n of e)i(n,t)}function i(t,r){const l=n[t.type];switch(l&&"function"==typeof l&&l(t,r),l&&l.enter&&l.enter(t,r),t.type){case e.Document:o(t.items,t);break;case e.Table:i(t.key,t),o(t.items,t);break;case e.TableKey:i(t.item,t);break;case e.TableArray:i(t.key,t),o(t.items,t);break;case e.TableArrayKey:i(t.item,t);break;case e.KeyValue:i(t.key,t),i(t.value,t);break;case e.InlineArray:o(t.items,t);break;case e.InlineItem:i(t.item,t);break;case e.InlineTable:o(t.items,t);break;case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:break;default:throw new Error(`Unrecognized node type "${t.type}"`)}l&&l.exit&&l.exit(t,r)}null!=(r=t)&&"function"==typeof r[Symbol.iterator]?o(t,null):i(t,null)}const ke=new WeakMap,xe=e=>(ke.has(e)||ke.set(e,new WeakMap),ke.get(e)),Ee=new WeakMap,Ae=e=>(Ee.has(e)||Ee.set(e,new WeakMap),Ee.get(e));function Ce(e,t,n,r){if(d(t)){const e=t.items.indexOf(n);if(e<0)throw new Error("Could not find existing item in parent node for replace");t.items.splice(e,1,r)}else if(i(t)&&u(t.value)&&!u(n)){const e=t.value.items.indexOf(n);if(e<0)throw new Error("Could not find existing item in parent node for replace");t.value.items.splice(e,1,r)}else if(m(t))t.item=r;else{if(!i(t))throw new Error(`Unsupported parent type "${t.type}" for replace`);t.key===n?t.key=r:t.value=r}Me(r,{lines:n.loc.start.line-r.loc.start.line,columns:n.loc.start.column-r.loc.start.column});const o=w(n.loc),l=w(r.loc);Ke({lines:l.lines-o.lines,columns:l.columns-o.columns},Ae(e),r,n)}function _e(e,t,l,a,m){if(!d(t))throw new Error(`Unsupported parent type "${t.type}" for insert`);let h,p;a=null!=a&&"number"==typeof a?a:t.items.length,s(t)||u(t)?({shift:h,offset:p}=function(e,t,n){if(!c(t))throw new Error(`Incompatible child type "${t.type}"`);const r=null!=n?e.items[n-1]:U(e.items),o=null==n||n===e.items.length;e.items.splice(n,0,t);const i=!!r,l=!o;i&&(r.comma=!0);l&&(t.comma=!0);const a=s(e)&&function(e){if(!e.items.length)return!1;return w(e.loc).lines>e.items.length}(e),u=o&&!0===t.comma;return Oe(e,t,n,{useNewLine:a,hasCommaHandling:!0,isLastElement:o,hasSeparatingCommaBefore:i,hasSeparatingCommaAfter:l,hasTrailingComma:u})}(t,l,a)):m&&n(t)?({shift:h,offset:p}=function(e,t,n){const r=Oe(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),r}(t,l,a)):({shift:h,offset:p}=function(e,t,l){if(a=t,!(i(a)||r(a)||o(a)||f(a)))throw new Error(`Incompatible child type "${t.type}"`);var a;const s=e.items[l-1],c=n(e)&&!e.items.length;e.items.splice(l,0,t);const u=s?{line:s.loc.end.line,column:f(s)?e.loc.start.column:s.loc.start.column}:v(e.loc.start),d=r(t)||o(t);let m=0;c||(m=d?2:1);u.line+=m;const h={lines:u.line-t.loc.start.line,columns:u.column-t.loc.start.column},p=w(t.loc),g={lines:p.lines+(m-1),columns:p.columns};return{shift:h,offset:g}}(t,l,a)),Me(l,h);const g=t.items[a-1],y=g&&Ae(e).get(g);y&&(p.lines+=y.lines,p.columns+=y.columns,Ae(e).delete(g));Ae(e).set(l,p)}function Oe(e,t,n,r={}){const{useNewLine:o=!1,skipCommaSpace:i=2,skipBracketSpace:l=1,hasCommaHandling:a=!1,isLastElement:s=!1,hasSeparatingCommaBefore:c=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:d=!1}=r,m=n>0?e.items[n-1]:void 0,h=m?{line:m.loc.end.line,column:o?f(m)?e.loc.start.column:m.loc.start.column:m.loc.end.column}:v(e.loc.start);let p=0;if(o)p=1;else{const e=c||!a&&!!m;e&&a?h.column+=i:(e||a&&!m)&&(h.column+=l)}h.line+=p;const g={lines:h.line-t.loc.start.line,columns:h.column-t.loc.start.column},y=w(t.loc);if(!a){return{shift:g,offset:{lines:y.lines+(p-1),columns:y.columns}}}let b=0;c&&d&&!u&&s&&(b=-1);return{shift:g,offset:{lines:y.lines+(p-1),columns:y.columns+(c||u?i:0)+(d?1+b:0)}}}function Ue(e,t,n){if(!d(t))throw new Error(`Unsupported parent type "${t.type}" for remove`);let r=t.items.indexOf(n);if(r<0){if(r=t.items.findIndex((e=>m(e)&&e.item===n)),r<0)throw new Error("Could not find node in parent for removal");n=t.items[r]}const o=t.items[r-1];let i=t.items[r+1];t.items.splice(r,1);let l=w(n.loc);i&&f(i)&&i.loc.start.line===n.loc.end.line&&(l=w({start:n.loc.start,end:i.loc.end}),i=t.items[r+1],t.items.splice(r,1));const a=o&&c(o)||i&&c(i),s=o&&o.loc.end.line===n.loc.start.line,u=i&&i.loc.start.line===n.loc.end.line,h=a&&(s||u),p={lines:-(l.lines-(h?1:0)),columns:-l.columns};if(void 0===o&&void 0===i&&(p.lines=0,p.columns=0),a&&s&&(p.columns-=2),a&&!o&&i&&(p.columns-=2),a&&o&&!i){const e=n.comma;o.comma=!!e}const g=o||t,y=o?Ae(e):xe(e),v=Ae(e),b=y.get(g);b&&(p.lines+=b.lines,p.columns+=b.columns);const $=v.get(n);$&&(p.lines+=$.lines,p.columns+=$.columns),y.set(g,p)}function De(e,t,n=!0){if(!n)return;if(!t.items.length)return;Ke({lines:0,columns:1},xe(e),t);const r=U(t.items);Ke({lines:0,columns:1},Ae(e),r)}function Fe(e,t,n=!1){if(!n)return;if(!t.items.length)return;const r=U(t.items);r.comma=!0,Ke({lines:0,columns:1},Ae(e),r)}function Le(t){const n=xe(t),r=Ae(t),o={lines:0,columns:{}};function i(e){const t=o.lines;e.loc.start.line+=t;const r=o.columns[e.loc.start.line]||0;e.loc.start.column+=r;const i=n.get(e);i&&(o.lines+=i.lines,o.columns[e.loc.start.line]=(o.columns[e.loc.start.line]||0)+i.columns)}function l(e){const t=o.lines;e.loc.end.line+=t;const n=o.columns[e.loc.end.line]||0;e.loc.end.column+=n;const i=r.get(e);i&&(o.lines+=i.lines,o.columns[e.loc.end.line]=(o.columns[e.loc.end.line]||0)+i.columns)}const a={enter:i,exit:l};Ie(t,{[e.Document]:a,[e.Table]:a,[e.TableArray]:a,[e.InlineTable]:a,[e.InlineArray]:a,[e.InlineItem]:a,[e.TableKey]:a,[e.TableArrayKey]:a,[e.KeyValue]:{enter(e){const t=e.loc.start.line+o.lines,n=r.get(e.key);e.equals+=(o.columns[t]||0)+(n?n.columns:0),i(e)},exit:l},[e.Key]:a,[e.String]:a,[e.Integer]:a,[e.Float]:a,[e.Boolean]:a,[e.DateTime]:a,[e.Comment]:a}),ke.delete(t),Ee.delete(t)}function Me(t,n,r={}){const{first_line_only:o=!1}=r,i=t.loc.start.line,{lines:l,columns:a}=n,s=e=>{o&&e.loc.start.line!==i||(e.loc.start.column+=a,e.loc.end.column+=a),e.loc.start.line+=l,e.loc.end.line+=l};return Ie(t,{[e.Table]:s,[e.TableKey]:s,[e.TableArray]:s,[e.TableArrayKey]:s,[e.KeyValue](e){s(e),e.equals+=a},[e.Key]:s,[e.String]:s,[e.Integer]:s,[e.Float]:s,[e.Boolean]:s,[e.DateTime]:s,[e.InlineArray]:s,[e.InlineItem]:s,[e.InlineTable]:s,[e.Comment]:s}),t}function Ke(e,t,n,r){const o=t.get(r||n);o&&(e.lines+=o.lines,e.columns+=o.columns),t.set(n,e)}function Ne(){return{type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:[]}}function je(t){const n=function(t){const n=Be(t);return{type:e.TableKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+2}},item:{type:e.Key,loc:{start:{line:1,column:1},end:{line:1,column:n.length+1}},value:t,raw:n}}}(t);return{type:e.Table,loc:b(n.loc),key:n,items:[]}}function Ze(t){const n=function(t){const n=Be(t);return{type:e.TableArrayKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+4}},item:{type:e.Key,loc:{start:{line:1,column:2},end:{line:1,column:n.length+2}},value:t,raw:n}}}(t);return{type:e.TableArray,loc:b(n.loc),key:n,items:[]}}function We(t,n){const r=function(t){const n=Be(t);return{type:e.Key,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t),{column:o}=r.loc.end,i=o+1;return Me(n,{lines:0,columns:o+3-n.loc.start.column},{first_line_only:!0}),{type:e.KeyValue,loc:{start:v(r.loc.start),end:v(n.loc.end)},key:r,equals:i,value:n}}const ze=/^[\w-]+$/;function Be(e){return e.map((e=>ze.test(e)?e:JSON.stringify(e))).join(".")}function qe(t,n){let r,o;if(n&&W(n)){let e=n.startsWith("'''");e&&t.includes("'''")&&(e=!1);const o=e?"'''":'"""',i=n.includes("\r\n")?"\r\n":"\n",l=n.startsWith(`${o}${i}`)||(n.startsWith("'''\n")||n.startsWith("'''\r\n"))&&!e;let a;a=e?t:t.replace(/\\/g,"\\\\").replace(/\x08/g,"\\b").replace(/\f/g,"\\f").replace(/\t/g,"\\t").replace(/[\x00-\x07\x0B\x0E-\x1F\x7F]/g,(e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase())).replace(/"""/g,'""\\"'),r=l?`${o}${i}${a}${o}`:`${o}${a}${o}`}else r=JSON.stringify(t);if(r.includes("\r\n")||r.includes("\n")&&!r.includes("\r\n")){const e=r.includes("\r\n")?"\r\n":"\n",t=(r.match(new RegExp("\r\n"===e?"\\r\\n":"\\n","g"))||[]).length;o=t>0?{line:1+t,column:3}:{line:1,column:r.length}}else o={line:1,column:r.length};return{type:e.String,loc:{start:{line:1,column:0},end:o},raw:r,value:t}}function Ve(t){return{type:e.InlineItem,loc:b(t.loc),item:t,comma:!1}}const Pe=!1,Re=!0,He=!1,Je=!1;function Ye(e,t){if(!e||"object"!=typeof e)return null;if(("InlineArray"===e.type||"InlineTable"===e.type)&&e.loc){const n=function(e,t){var n;if(!e||!e.start||!e.end)return null;const r=t.split(/\r?\n/),o=e.start.line-1,i=e.end.line-1,l=e.start.column,a=e.end.column;let s="";if(o===i)s=(null===(n=r[o])||void 0===n?void 0:n.substring(l,a+1))||"";else{r[o]&&(s+=r[o].substring(l));for(let e=o+1;e<i;e++)s+="\n"+(r[e]||"");r[i]&&(s+="\n"+r[i].substring(0,a+1))}const c=s.match(/^\[(\s*)/),u=s.match(/^\{(\s*)/);if(c)return c[1].length>0;if(u)return u[1].length>0;return null}(e.loc,t);if(null!==n)return n}if(e.items&&Array.isArray(e.items))for(const n of e.items){const e=Ye(n,t);if(null!==e)return e;if(n.item){const e=Ye(n.item,t);if(null!==e)return e}}for(const n of["value","key","item"])if(e[n]){const r=Ye(e[n],t);if(null!==r)return r}return null}function Xe(e){if(!e||"object"!=typeof e)return null;if("InlineArray"===e.type&&e.items&&Array.isArray(e.items))return Ge(e.items);if("InlineTable"===e.type&&e.items&&Array.isArray(e.items))return Ge(e.items);if("KeyValue"===e.type&&e.value)return Xe(e.value);if(e.items&&Array.isArray(e.items))for(const t of e.items){const e=Xe(t);if(null!==e)return e}return null}function Ge(e){if(0===e.length)return null;const t=e[e.length-1];return!(!t||"object"!=typeof t||!("comma"in t))&&!0===t.comma}function Qe(e){if(!s(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function et(e){if(!u(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function tt(e){const t=e.indexOf("\n");return t>0&&"\r"===e.substring(t-1,t)?"\r\n":"\n"}function nt(e,t){var n,r,o,i,l,a;if(e){if(e instanceof rt)return e;{const s=function(e){if(!e||"object"!=typeof e)return{};const t=new Set(["newLine","trailingNewline","trailingComma","bracketSpacing","inlineTableStart","truncateZeroTimeInDates","useTabsForIndentation"]),n={},r=[],o=[];for(const i in e){const l=Object.prototype.hasOwnProperty.call(e,i);if(t.has(i)){const t=e[i];switch(i){case"newLine":"string"==typeof t?n.newLine=t:o.push(`${i} (expected string, got ${typeof t})`);break;case"trailingNewline":"boolean"==typeof t||"number"==typeof t?n.trailingNewline=t:o.push(`${i} (expected boolean or number, got ${typeof t})`);break;case"trailingComma":case"bracketSpacing":case"truncateZeroTimeInDates":case"useTabsForIndentation":"boolean"==typeof t?n[i]=t:o.push(`${i} (expected boolean, got ${typeof t})`);break;case"inlineTableStart":"number"==typeof t&&Number.isInteger(t)&&t>=0||null==t?n.inlineTableStart=t:o.push(`${i} (expected non-negative integer or undefined, got ${typeof t})`)}}else l&&r.push(i)}if(r.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${r.join(", ")}. Supported properties are: ${Array.from(t).join(", ")}`),o.length>0)throw new TypeError(`Invalid types for format properties: ${o.join(", ")}`);return n}(e);return new rt(null!==(n=s.newLine)&&void 0!==n?n:t.newLine,null!==(r=s.trailingNewline)&&void 0!==r?r:t.trailingNewline,null!==(o=s.trailingComma)&&void 0!==o?o:t.trailingComma,null!==(i=s.bracketSpacing)&&void 0!==i?i:t.bracketSpacing,void 0!==s.inlineTableStart?s.inlineTableStart:t.inlineTableStart,null!==(l=s.truncateZeroTimeInDates)&&void 0!==l?l:t.truncateZeroTimeInDates,null!==(a=s.useTabsForIndentation)&&void 0!==a?a:t.useTabsForIndentation)}}return t}class rt{constructor(e,t,n,r,o,i,l){this.newLine=null!=e?e:"\n",this.trailingNewline=null!=t?t:1,this.trailingComma=null!=n?n:Pe,this.bracketSpacing=null!=r?r:Re,this.inlineTableStart=null!=o?o:1,this.truncateZeroTimeInDates=null!=i?i:He,this.useTabsForIndentation=null!=l?l:Je}static default(){return new rt("\n",1,Pe,Re,1,He,Je)}static autoDetectFormat(e){const t=rt.default();t.newLine=tt(e),t.trailingNewline=function(e,t){let n=0,r=e.length;for(;r>=t.length&&e.substring(r-t.length,r)===t;)n++,r-=t.length;return n}(e,t.newLine);try{const n=he(e),r=Array.from(n);t.trailingComma=function(e){const t=Array.from(e);for(const e of t){const t=Xe(e);if(null!==t)return t}return Pe}(r),t.bracketSpacing=function(e,t){const n=Array.from(t);for(const t of n){const n=Ye(t,e);if(null!==n)return n}return Re}(e,r)}catch(e){t.trailingComma=Pe,t.bracketSpacing=Re}return t.useTabsForIndentation=function(e){const t=e.split(/\r?\n/);let n=0,r=0;for(const e of t)if(0!==e.length&&("\t"===e[0]?n++:" "===e[0]&&r++,n+r>=5))break;return n>r}(e),t.inlineTableStart=1,t.truncateZeroTimeInDates=He,t}}function ot(e,t){if(0===t.inlineTableStart)return e;return e.items.filter((e=>{if(!i(e))return!1;const n=u(e.value),r=s(e.value)&&e.value.items.length&&u(e.value.items[0].item);if(n||r){const n=at(e.key.value);return void 0===t.inlineTableStart||n<t.inlineTableStart}return!1})).forEach((t=>{Ue(e,e,t),u(t.value)?_e(e,e,it(t)):function(e){const t=Ne();for(const n of e.value.items){const r=Ze(e.key.value);_e(t,t,r);for(const e of n.item.items)_e(t,r,e.item)}return Le(t),t.items}(t).forEach((t=>{_e(e,e,t)}))})),Le(e),e}function it(e){const t=je(e.key.value);for(const n of e.value.items)_e(t,t,n.item);return Le(t),t}function lt(e){if(e.items.length>0){const t=e.items[e.items.length-1];e.loc.end.line=t.loc.end.line,e.loc.end.column=t.loc.end.column}else e.loc.end.line=e.key.loc.end.line,e.loc.end.column=e.key.loc.end.column}function at(e){return Math.max(0,e.length-1)}function st(e,t,n){var r;for(let o=e.items.length-1;o>=0;o--){const l=e.items[o];if(i(l)&&u(l.value)){const o=[...e.key.item.value,...l.key.value];if(at(o)<(null!==(r=n.inlineTableStart)&&void 0!==r?r:1)){const r=je(o);for(const e of l.value.items)_e(r,r,e.item);Ue(e,e,l),lt(e),t.push(r),st(r,t,n)}}}}function ct(e,t=rt.default()){e=function(e){const t=[],n=[];for(const r in e)M(e[r])||Array.isArray(e[r])?n.push(r):t.push(r);const r={};for(let n=0;n<t.length;n++){const o=t[n];r[o]=e[o]}for(let t=0;t<n.length;t++){const o=n[t];r[o]=e[o]}return r}(e=dt(e));const n=Ne();for(const r of ut(e,t))_e(n,n,r);Le(n);const r=N(n,(e=>ot(e,t)),(e=>function(e,t){if(void 0===t.inlineTableStart||0===t.inlineTableStart)return e;const n=[];for(const r of e.items)if(i(r)&&u(r.value)){if(at(r.key.value)<t.inlineTableStart){const o=it(r);Ue(e,e,r),_e(e,e,o),st(o,n,t)}}else"Table"===r.type&&st(r,n,t);for(const t of n)_e(e,e,t);return Le(e),e}(e,t)),(e=>function(e){return e}(e)));return function(e){let t=0,n=0;for(const r of e.items)0===n&&r.loc.start.line>1?t=1-r.loc.start.line:r.loc.start.line+t>n+2&&(t+=n+2-(r.loc.start.line+t)),Me(r,{lines:t,columns:0}),n=r.loc.end.line;return e}(r)}function*ut(e,t){for(const n of Object.keys(e))yield We([n],ft(e[n],t))}function ft(t,n){if(null==t)throw new Error('"null" and "undefined" values are not supported');return function(e){return"string"==typeof e}(t)?qe(t):F(t)?function(t){const n=t.toString();return{type:e.Integer,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t):function(e){return"number"==typeof e&&(!F(e)||!isFinite(e)||Object.is(e,-0))}(t)?function(t){let n;return n=t===1/0?"inf":t===-1/0?"-inf":Number.isNaN(t)?"nan":Object.is(t,-0)?"-0.0":t.toString(),{type:e.Float,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t):function(e){return"boolean"==typeof e}(t)?function(t){return{type:e.Boolean,loc:{start:{line:1,column:0},end:{line:1,column:t?4:5}},value:t}}(t):L(t)?function(t,n){n.truncateZeroTimeInDates&&0===t.getUTCHours()&&0===t.getUTCMinutes()&&0===t.getUTCSeconds()&&0===t.getUTCMilliseconds()&&(t=new te(t.toISOString().split("T")[0]));const r=t.toISOString();return{type:e.DateTime,loc:{start:{line:1,column:0},end:{line:1,column:r.length}},raw:r,value:t}}(t,n):Array.isArray(t)?function(t,n){const r={type:e.InlineArray,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of t){_e(r,r,Ve(ft(e,n)))}return De(r,r,n.bracketSpacing),Fe(r,r,n.trailingComma),Le(r),r}(t,n):function(t,n){if(t=dt(t),!M(t))return ft(t,n);const r={type:e.InlineTable,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]},o=[...ut(t,n)];for(const e of o){_e(r,r,Ve(e))}return De(r,r,n.bracketSpacing),Fe(r,r,n.trailingComma),Le(r),r}(t,n)}function dt(e){return e?L(e)?e:"function"==typeof e.toJSON?e.toJSON():e:e}const mt=/(\r\n|\n)/g;function ht(t,n){const r=[],o=n.useTabsForIndentation?"\t":" ";if(Ie(t,{[e.TableKey](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"[",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"]",o)},[e.TableArrayKey](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+2}},"[[",o),pt(r,{start:{line:n.line,column:n.column-2},end:n},"]]",o)},[e.KeyValue](e){const{start:{line:t}}=e.loc;pt(r,{start:{line:t,column:e.equals},end:{line:t,column:e.equals+1}},"=",o)},[e.Key](e){pt(r,e.loc,e.raw,o)},[e.String](e){pt(r,e.loc,e.raw,o)},[e.Integer](e){pt(r,e.loc,e.raw,o)},[e.Float](e){pt(r,e.loc,e.raw,o)},[e.Boolean](e){pt(r,e.loc,e.value.toString(),o)},[e.DateTime](e){pt(r,e.loc,e.raw,o)},[e.InlineArray](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"[",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"]",o)},[e.InlineTable](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"{",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"}",o)},[e.InlineItem](e){if(!e.comma)return;const t=e.loc.end;pt(r,{start:t,end:{line:t.line,column:t.column+1}},",",o)},[e.Comment](e){pt(r,e.loc,e.raw,o)}}),n.useTabsForIndentation)for(let e=0;e<r.length;e++){const t=r[e],n=t.match(/^( +)/);if(n){const o=n[1],i="\t".repeat(o.length);r[e]=i+t.substring(o.length)}}return r.join(n.newLine)+n.newLine.repeat(n.trailingNewline)}function pt(e,t,n,r=" "){const o=n.split(mt).filter((e=>"\n"!==e&&"\r\n"!==e)),i=t.end.line-t.start.line+1;if(o.length!==i)throw new Error(`Mismatch between location and raw string, expected ${i} lines for "${n}"`);for(let r=t.start.line;r<=t.end.line;r++){const i=wt(e,r);if(void 0===i)throw new Error(`Line ${r} is uninitialized when writing "${n}" at ${t.start.line}:${t.start.column} to ${t.end.line}:${t.end.column}`);const l=r===t.start.line,a=r===t.end.line;let s="";if(l){const e=i.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column," "):e}const c=a?i.substring(t.end.column):"";e[r-1]=s+o[r-t.start.line]+c}}function wt(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]="");return e[t-1]}function gt(t,n,r){for(const o of t.items){const t=o.item,i=n.concat(t.key.value);t.value.type===e.InlineTable&&(r.add(It(i)),gt(t.value,i,r))}}function yt(t,n=""){const r=D(),o=new Set,i=new Set,l=new Set,a=new Set,s=new Set;let c=r,u=0,f=[];return Ie(t,{[e.Table](e){const t=e.key.item.value;try{bt(r,[],t,e.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(t){const r=t;throw new $(n,e.key.loc.start,r.message)}const u=It(t);o.add(u),l.add(u),c=$t(r,t),f=t},[e.TableArray](e){const t=e.key.item.value;try{bt(r,[],t,e.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(t){const r=t;throw new $(n,e.key.loc.start,r.message)}const u=It(t);i.add(u),l.add(u),c=function(e,t){const n=St(e,t.slice(0,-1)),r=U(t);n[r]||(n[r]=[]);const o=D();return n[U(t)].push(o),o}(r,t),f=t},[e.KeyValue]:{enter(t){if(u>0)return;const r=t.key.value;try{bt(c,f,r,t.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(e){const r=e;throw new $(n,t.key.loc.start,r.message)}if(r.length>1)for(let e=1;e<r.length;e++){const t=It(f.concat(r.slice(0,e)));a.add(t),l.add(t)}let d;try{d=vt(t.value)}catch(e){const r=e;throw new $(n,t.value.loc.start,r.message)}if(t.value.type===e.InlineTable){const e=f.concat(r);s.add(It(e)),gt(t.value,e,s)}(r.length>1?$t(c,r.slice(0,-1)):c)[U(r)]=d,l.add(It(f.concat(r)))}},[e.InlineTable]:{enter(){u++},exit(){u--}}}),r}function vt(t){switch(t.type){case e.InlineTable:const n=D(),r=new Set,o=new Map;return t.items.forEach((({item:e})=>{const t=e.key.value,i=vt(e.value),l=It(t);if(r.has(l))throw new Error(`Duplicate key "${l}" in inline table`);for(let e=1;e<t.length;e++){const n=It(t.slice(0,e));if(r.has(n))throw new Error(`Key "${l}" conflicts with already defined key "${n}" in inline table`)}if(o.has(l)){const e=o.get(l);throw new Error(`Key "${l}" conflicts with already defined key "${e}" in inline table`)}r.add(l);for(let e=1;e<t.length;e++){const n=It(t.slice(0,e));o.has(n)||o.set(n,l)}(t.length>1?$t(n,t.slice(0,-1)):n)[U(t)]=i})),n;case e.InlineArray:return t.items.map((e=>vt(e.item)));case e.DateTime:case e.String:case e.Integer:case e.Float:case e.Boolean:return t.value;default:throw new Error(`Unrecognized value type "${t.type}"`)}}function bt(t,n,r,o,i){const l=It(n.concat(r));if(o===e.KeyValue&&r.length>1)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.inline_tables.has(t))throw new Error(`Invalid key, cannot extend an inline table at ${t}`)}if((o===e.Table||o===e.TableArray)&&i.inline_tables.has(l))throw new Error(`Invalid key, cannot extend an inline table at ${l}`);if(o===e.Table||o===e.TableArray)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.inline_tables.has(t))throw new Error(`Invalid key, cannot extend an inline table at ${t}`)}if(o===e.KeyValue&&r.length>1)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.table_arrays.has(t))throw new Error(`Invalid key, cannot traverse into an array of tables at ${t}`)}if((o===e.Table||o===e.TableArray)&&i.implicit_tables.has(l))throw new Error(`Invalid key, a table has already been defined implicitly named ${l}`);if(o===e.KeyValue&&i.implicit_tables.has(l))throw new Error(`Invalid key, a table has already been defined named ${l}`);if(o===e.KeyValue&&r.length>1)for(let e=1;e<=r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.tables.has(t))throw new Error(`Invalid key, cannot add to an explicitly defined table ${t} using dotted keys`)}let a=[],s=0;for(const e of r){if(a.push(e),!K(t,e))return;if(Tt(t[e])){const e=It(n.concat(a));throw new Error(`Invalid key, a value has already been defined for ${e}`)}const o=It(n.concat(a));if(Array.isArray(t[e])&&!i.table_arrays.has(o))throw new Error(`Invalid key, cannot add to a static array at ${o}`);const l=s++<r.length-1;t=Array.isArray(t[e])&&l?U(t[e]):t[e]}const c=l;if(t&&o===e.Table&&i.defined.has(c))throw new Error(`Invalid key, a table has already been defined named ${c}`);if(t&&o===e.KeyValue&&1===r.length&&i.defined.has(c)&&!Tt(t))throw new Error(`Invalid key, a table has already been defined named ${c}`);if(t&&o===e.TableArray&&!i.table_arrays.has(c))throw new Error(`Invalid key, cannot add an array of tables to a table at ${c}`)}function $t(e,t){const n=St(e,t.slice(0,-1)),r=U(t);return n[r]||(n[r]=D()),n[r]}function St(e,t){return t.reduce(((e,t)=>(e[t]||(e[t]=D()),Array.isArray(e[t])?U(e[t]):e[t])),e)}function Tt(e){return"object"!=typeof e&&!L(e)}function It(e){return e.join(".")}var kt,xt,Et,At;function Ct(e){return e.type===kt.Remove}function _t(e,t,n=[]){return e===t||(o=t,L(r=e)&&L(o)&&r.toISOString()===o.toISOString())?[]:Array.isArray(e)&&Array.isArray(t)?function(e,t,n=[]){let r=[];const o=e.map(j),i=t.map(j);i.forEach(((l,a)=>{const s=a>=o.length;if(!s&&o[a]===l)return;const c=o.indexOf(l,a+1);if(!s&&c>-1){r.push({type:kt.Move,path:n,from:c,to:a});const e=o.splice(c,1);return void o.splice(a,0,...e)}const u=!i.includes(o[a]);if(!s&&u)return Z(r,_t(e[a],t[a],n.concat(a))),void(o[a]=l);r.push({type:kt.Add,path:n.concat(a)}),o.splice(a,0,l)}));for(let e=i.length;e<o.length;e++)r.push({type:kt.Remove,path:n.concat(e)});return r}(e,t,n):M(e)&&M(t)?function(e,t,n=[]){let r=[];const o=Object.keys(e),i=o.map((t=>j(e[t]))),l=Object.keys(t),a=l.map((e=>j(t[e]))),s=(e,t)=>{if(t.indexOf(e)<0)return!1;const n=o[i.indexOf(e)];return!l.includes(n)};return o.forEach(((o,c)=>{const u=n.concat(o);if(l.includes(o))Z(r,_t(e[o],t[o],u));else if(s(i[c],a)){const e=l[a.indexOf(i[c])];r.push({type:kt.Rename,path:n,from:o,to:e})}else r.push({type:kt.Remove,path:u})})),l.forEach(((e,t)=>{o.includes(e)||s(a[t],i)||r.push({type:kt.Add,path:n.concat(e)})})),r}(e,t,n):[{type:kt.Edit,path:n}];var r,o}function Ot(e,t){if(!t.length)return c(e)&&i(e.item)?e.item:e;if(i(e))return Ot(e.value,t);const n={};let l;if(d(e)&&e.items.some(((e,a)=>{try{let s=[];if(i(e))s=e.key.value;else if(r(e))s=e.key.item.value;else if(o(e)){s=e.key.item.value;const t=j(s);n[t]||(n[t]=0);const r=n[t]++;s=s.concat(r)}else c(e)&&i(e.item)?s=e.item.key.value:c(e)&&(s=[a]);return!(!s.length||!function(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}(s,t.slice(0,s.length)))&&(l=c(e)&&i(e.item)?t.length===s.length?e:Ot(e.item.value,t.slice(s.length)):Ot(e,t.slice(s.length)),!0)}catch(e){return!1}})),!l)throw new Error(`Could not find node at path ${t.join(".")}`);return l}function Ut(e,t){try{return Ot(e,t)}catch(e){}}function Dt(e,t){let n,r=t;for(;r.length&&!n;)r=r.slice(0,-1),n=Ut(e,r);if(!n)throw new Error(`Count not find parent node for path ${t.join(".")}`);return n}function Ft(e,t,n){return Lt(he(e),t,nt(n,rt.autoDetectFormat(e))).tomlString}function Lt(t,l,a){const f=[...t],d=yt(f),h={type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:f},p=ct(l,nt(Object.assign(Object.assign({},a),{inlineTableStart:void 0}),a)),w=function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Ct(n)){let r=t+1;for(;r<e.length;){const o=e[r];if(Ct(o)&&o.path[0]===n.path[0]&&o.path[1]>n.path[1]){e.splice(r,1),e.splice(t,0,o),t=0;break}r++}}}return e}(_t(d,l));if(0===w.length)return{tomlString:ht(f,a),document:h};const g=function(e,t,l,a){return l.forEach((l=>{if(function(e){return e.type===kt.Add}(l)){const f=Ot(t,l.path),d=l.path.slice(0,-1);let m,h=U(l.path),p=o(f);if(F(h)&&!d.some(F)){const t=Ut(e,d.concat(0));t&&o(t)&&(p=!0)}if(r(f))m=e;else if(p){m=e;const t=e,n=Ut(t,d.concat(h-1)),r=Ut(t,d.concat(h));h=r?t.items.indexOf(r):n?t.items.indexOf(n)+1:t.items.length}else m=Dt(e,l.path),i(m)&&(m=m.value);if(o(m)||s(m)||n(m)){if(s(m)){const e=Qe(m);c(f)&&(f.comma=e)}if(void 0!==a.inlineTableStart&&a.inlineTableStart>0&&n(m)&&r(f)){const t=Kt(f,e,a);_e(e,m,f,h);for(const n of t)_e(e,e,n,void 0)}else _e(e,m,f,h)}else if(u(m)){const t=et(m);if(i(f)){const n=Ve(f);n.comma=t,_e(e,m,n)}else _e(e,m,f)}else if(void 0!==a.inlineTableStart&&a.inlineTableStart>0&&i(f)&&u(f.value)&&r(m)){at([...m.key.item.value,...f.key.value])<a.inlineTableStart?function(e,t,n,r){const o=t.key.item.value,l=[...o,...e.key.value],a=je(l);if(u(e.value))for(const t of e.value.items)c(t)&&i(t.item)&&_e(n,a,t.item,void 0);_e(n,n,a,void 0),lt(t);const s=Kt(a,n,r);for(const e of s)_e(n,n,e,void 0)}(f,m,e,a):_e(e,m,f)}else if(0===a.inlineTableStart&&i(f)&&u(f.value)&&n(m))_e(e,m,f,void 0,!0);else{let t=f;c(f)&&(r(m)||n(m))&&(t=f.item),_e(e,m,t)}}else if(function(e){return e.type===kt.Edit}(l)){let n,r=Ot(e,l.path),o=Ot(t,l.path);if(i(r)&&i(o))Mt(r.value,o.value),n=r,r=r.value,o=o.value;else if(i(r)&&c(o)&&i(o.item))n=r,r=r.value,o=o.item.value;else if(c(r)&&i(o))n=r,r=r.item;else if(c(r)&&c(o)&&i(r.item)&&i(o.item))Mt(r.item.value,o.item.value),n=r.item,r=r.item.value,o=o.item.value;else if(n=Dt(e,l.path),i(n)){const t=l.path.slice(0,-1),r=Ot(e,t);i(r)&&s(r.value)&&(n=r.value)}Ce(e,n,r,o)}else if(Ct(l)){let t=Dt(e,l.path);i(t)&&(t=t.value);const n=Ot(e,l.path);Ue(e,t,n)}else if(function(e){return e.type===kt.Move}(l)){let t=Ot(e,l.path);m(t)&&(t=t.item),i(t)&&(t=t.value);const n=t.items[l.from];Ue(e,t,n),_e(e,t,n,l.to)}else if(function(e){return e.type===kt.Rename}(l)){let n=Ot(e,l.path.concat(l.from)),r=Ot(t,l.path.concat(l.to));m(n)&&(n=n.item),m(r)&&(r=r.item),Ce(e,n,n.key,r.key)}})),Le(e),e}(h,p,w,a);return{tomlString:ht(g.items,a),document:g}}function Mt(e,t){if(l(e)&&l(t)&&W(e.raw)){const n=qe(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(a(e)&&a(t)){const n=e.raw,r=t.value,o=ee.createDateWithOriginalFormat(r,n);t.value=o,t.raw=o.toISOString();0!==t.raw.length-n.length&&(t.loc.end.column=t.loc.start.column+t.raw.length)}if(s(e)&&s(t)){const n=Qe(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}if(u(e)&&u(t)){const n=et(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}}function Kt(e,t,n){const r=[],o=(e,r)=>{var l;for(let a=e.items.length-1;a>=0;a--){const s=e.items[a];if(i(s)&&u(s.value)){const u=[...e.key.item.value,...s.key.value];if(at(u)<(null!==(l=n.inlineTableStart)&&void 0!==l?l:1)&&0!==n.inlineTableStart){const n=je(u);for(const e of s.value.items)c(e)&&i(e.item)&&_e(t,n,e.item,void 0);e.items.splice(a,1),lt(e),r.push(n),o(n,r)}}}};return o(e,r),r}function Nt(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function jt(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function Zt(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}!function(e){e.Add="Add",e.Edit="Edit",e.Remove="Remove",e.Move="Move",e.Rename="Rename"}(kt||(kt={})),"function"==typeof SuppressedError&&SuppressedError;class Wt{constructor(e){xt.set(this,void 0),Et.set(this,void 0),At.set(this,void 0),jt(this,Et,e,"f"),jt(this,xt,Array.from(he(e)),"f"),jt(this,At,rt.autoDetectFormat(e),"f")}get toTomlString(){return Nt(this,Et,"f")}get toJsObject(){return zt(yt(Nt(this,xt,"f")))}get ast(){return Nt(this,xt,"f")}patch(e,t){const n=nt(t,Nt(this,At,"f")),{tomlString:r,document:o}=Lt(Nt(this,xt,"f"),e,n);jt(this,xt,o.items,"f"),jt(this,Et,r,"f")}update(e){if(e===this.toTomlString)return;const t=this.toTomlString.split(Nt(this,At,"f").newLine),n=tt(e),r=e.split(n);let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];)o++;let i=0;if(o<t.length&&o<r.length){const e=t[o],n=r[o];for(let t=0;t<Math.max(e.length,n.length);t++)if(e[t]!==n[t]){i=t;break}}let l=o+1;const{truncatedAst:a,lastEndPosition:s}=function(e,t,n){const r={line:t,column:n},o=[];let i=null;for(const t of e){const e=Zt(t.loc.end,r)<0,n=Zt(t.loc.start,r)<0;if(!e){if(n&&!e)break;break}o.push(t),i=t.loc.end}return{truncatedAst:o,lastEndPosition:i}}(Nt(this,xt,"f"),l,i),c=s?s.line:1,u=s?s.column+1:0,f=r.slice(c-1);f.length>0&&u>0&&(f[0]=f[0].substring(u));const d=f.join(Nt(this,At,"f").newLine);jt(this,xt,Array.from(function*(e,t){for(const t of e)yield t;const n=new h(x(t));for(;!n.next().done;){const e=Se(n,t);for(const t of e)yield t}}(a,d)),"f"),jt(this,Et,e,"f"),jt(this,At,rt.autoDetectFormat(e),"f")}overwrite(e){e!==this.toTomlString&&(jt(this,xt,Array.from(he(e)),"f"),jt(this,Et,e,"f"),jt(this,At,rt.autoDetectFormat(e),"f"))}}function zt(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(zt);if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))t[n]=zt(r);return t}return e}function Bt(e){return yt(he(e),e)}function qt(e,t){const n=nt(t,rt.default());return ht(ct(e,n).items,n)}xt=new WeakMap,Et=new WeakMap,At=new WeakMap;export{Wt as TomlDocument,rt as TomlFormat,Bt as parse,Ft as patch,qt as stringify};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decimalturn/toml-patch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"contributors": [
|
|
5
5
|
"Tim Hall <tim.hall.engr@gmail.com>",
|
|
6
6
|
"Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
|
|
@@ -24,26 +24,31 @@
|
|
|
24
24
|
"encoder",
|
|
25
25
|
"decoder"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
27
|
+
"type": "module",
|
|
28
|
+
"types": "./dist/toml-patch.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/toml-patch.d.ts",
|
|
32
|
+
"import": "./dist/toml-patch.js",
|
|
33
|
+
"default": "./dist/toml-patch.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
31
36
|
"scripts": {
|
|
32
37
|
"dev": "npm run typecheck && npm run build && npm-run-all2 --parallel test:all specs",
|
|
33
|
-
"test": "jest",
|
|
34
|
-
"test:js": "
|
|
38
|
+
"test": "jest --config jest.config.json",
|
|
39
|
+
"test:js": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.mjs",
|
|
35
40
|
"test:all": "npm run test && npm run test:js",
|
|
36
41
|
"typecheck": "tsc",
|
|
37
|
-
"specs": "jest --config specs.config.
|
|
42
|
+
"specs": "jest --config specs.config.cjs",
|
|
38
43
|
"benchmark": "npm-run-all2 bench:*",
|
|
39
44
|
"benchmark:example": "npm-run-all2 \"bench:* -- --example\"",
|
|
40
|
-
"bench:parse": "node benchmark/parse-benchmark.
|
|
41
|
-
"bench:stringify": "node benchmark/stringify-benchmark.
|
|
45
|
+
"bench:parse": "node benchmark/parse-benchmark.cjs",
|
|
46
|
+
"bench:stringify": "node benchmark/stringify-benchmark.cjs",
|
|
42
47
|
"build": "rimraf dist && rollup -c",
|
|
43
48
|
"prepublishOnly": "npm run build"
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
46
|
-
"@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@0.
|
|
51
|
+
"@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@0.7.0",
|
|
47
52
|
"@rollup/plugin-terser": "^0.4.4",
|
|
48
53
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
49
54
|
"@types/dedent": "^0.7.2",
|
|
@@ -64,20 +69,12 @@
|
|
|
64
69
|
"tslib": "^2.0.0",
|
|
65
70
|
"typescript": "5.9"
|
|
66
71
|
},
|
|
67
|
-
"jest": {
|
|
68
|
-
"testEnvironment": "node",
|
|
69
|
-
"preset": "ts-jest",
|
|
70
|
-
"testRegex": "/__tests__/(?!__js__).*\\.[jt]sx?$",
|
|
71
|
-
"snapshotFormat": {
|
|
72
|
-
"escapeString": true,
|
|
73
|
-
"printBasicPrototype": true
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
72
|
"prettier": {
|
|
77
73
|
"singleQuote": true,
|
|
78
74
|
"printWidth": 100
|
|
79
75
|
},
|
|
80
76
|
"files": [
|
|
81
|
-
"dist/"
|
|
77
|
+
"dist/",
|
|
78
|
+
"CHANGELOG.md"
|
|
82
79
|
]
|
|
83
80
|
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v0.7.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
-
"use strict";var e,t;function n(t){return t.type===e.Document}function r(t){return t.type===e.Table}function o(t){return t.type===e.TableArray}function i(t){return t.type===e.KeyValue}function l(t){return t.type===e.String}function a(t){return t.type===e.DateTime}function s(t){return t.type===e.InlineArray}function c(t){return t.type===e.InlineItem}function u(t){return t.type===e.InlineTable}function f(t){return t.type===e.Comment}function d(e){return n(e)||r(e)||o(e)||u(e)||s(e)}function m(t){return function(t){return t.type===e.TableKey}(t)||function(t){return t.type===e.TableArrayKey}(t)||c(t)}!function(e){e.Document="Document",e.Table="Table",e.TableKey="TableKey",e.TableArray="TableArray",e.TableArrayKey="TableArrayKey",e.KeyValue="KeyValue",e.Key="Key",e.String="String",e.Integer="Integer",e.Float="Float",e.Boolean="Boolean",e.DateTime="DateTime",e.InlineArray="InlineArray",e.InlineItem="InlineItem",e.InlineTable="InlineTable",e.Comment="Comment"}(e||(e={}));class h{constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){var e;if(this.done)return p();const t=this.peeked||this.iterator.next();return this.index+=1,this.value=t.value,this.done=null!==(e=t.done)&&void 0!==e&&e,this.peeked=null,t}peek(){return this.done?p():(this.peeked||(this.peeked=this.iterator.next()),this.peeked)}[Symbol.iterator](){return this}}function p(){return{value:void 0,done:!0}}function w(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function g(e,t){const n=Array.isArray(e)?e:y(e),r=n.findIndex((e=>e>=t))+1;return{line:r,column:t-(n[r-2]+1||0)}}function y(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];"\n"===r?t.push(n):"\r"===r&&("\n"===e[n+1]?(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 b(e){return{start:v(e.start),end:v(e.end)}}class $ extends Error{constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){const n=function(e,t){const n=y(e),r=void 0!==n[t.line-2]?n[t.line-2]+1:0,o=n[t.line-1]||e.length;return e.substring(r,o)}(e,t),o=`${function(e,t=" "){return t.repeat(e)}(t.column)}^`;n&&(r+=`${n}\n${o}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}}!function(e){e.Bracket="Bracket",e.Curly="Curly",e.Equal="Equal",e.Comma="Comma",e.Dot="Dot",e.Comment="Comment",e.Literal="Literal"}(t||(t={}));const S=/\s/,T='"',I="'",k=/[\w,\d,\",\',\+,\-,\_]/;function*x(e){const n=new h("string"==typeof(r=e)?function*(e){for(let t=0;t<e.length;t++)yield e[t]}(r):r[Symbol.iterator]());var r;n.next();const o=function(e){const t=y(e);return(e,n)=>({start:g(t,e),end:g(t,n)})}(e);for(;!n.done;){const r=n.value.charCodeAt(0);if((r<=31||127===r)&&9!==r&&13!==r&&10!==r)throw new $(e,g(e,n.index),`Control character 0x${r.toString(16).toUpperCase().padStart(2,"0")} is not allowed in TOML`);if("\r"===n.value){const t=n.peek();if(t.done||"\n"!==t.value)throw new $(e,g(e,n.index),"Invalid standalone CR (\\r); CR must be part of a CRLF sequence")}if(S.test(n.value));else if("["===n.value||"]"===n.value)yield E(n,o,t.Bracket);else if("{"===n.value||"}"===n.value)yield E(n,o,t.Curly);else if("="===n.value)yield E(n,o,t.Equal);else if(","===n.value)yield E(n,o,t.Comma);else if("."===n.value)yield E(n,o,t.Dot);else if("#"===n.value)yield A(n,o,e);else{const t=O(e,n.index,I)||O(e,n.index,T);t?yield C(n,o,t,e):yield _(n,o,e)}n.next()}}function E(e,t,n){return{type:n,raw:e.value,loc:t(e.index,e.index+1)}}function A(e,n,r){const o=e.index;let i=e.value;for(;!e.peek().done&&"\n"!==e.peek().value&&"\r"!==e.peek().value;){e.next();const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t)throw new $(r,g(r,e.index),`Control character 0x${t.toString(16).toUpperCase().padStart(2,"0")} is not allowed in TOML`);i+=e.value}return{type:t.Comment,raw:i,loc:n(o,e.index+1)}}function C(e,n,r,o){const i=e.index,l=r+r+r;let a=l;for(e.next(),e.next(),e.next();!e.done;){if(O(o,e.index,r)){let t=3;for(;o[e.index+t]===r;)t++;if(t>=6)throw new $(o,g(o,e.index),`Invalid multiline string: ${t} consecutive ${r} characters`);if(3===t)break;a+=r.repeat(t-3);for(let n=0;n<t-3;n++)e.next();break}if("\r"===e.value){const t=e.peek();if(t.done||"\n"!==t.value)throw new $(o,g(o,e.index),"Invalid standalone CR (\\r) in multiline string (must be part of CRLF sequence)")}const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t&&10!==t&&13!==t){const n=r===T?"multiline basic strings":"multiline literal strings",i=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let l="";0===t?l="Null":127===t&&(l="DEL");const a=l?`${l} (control character ${i}) is not allowed in ${n}`:`Control character ${i} is not allowed in ${n}`;throw new $(o,g(o,e.index),a)}a+=e.value,e.next()}if(e.done){if(r===T){const t=o.slice(0,e.index);if(/\\"+$/.test(t))throw new $(o,g(o,e.index),`Expected close of multiline string with ${l}, reached end of file. Check for escape sequences (\\) that may be preventing proper string closure`)}throw new $(o,g(o,e.index),`Expected close of multiline string with ${l}, reached end of file`)}return a+=l,e.next(),e.next(),{type:t.Literal,raw:a,loc:n(i,e.index+1)}}function _(e,n,r){if(!k.test(e.value))throw new $(r,g(r,e.index),`Unsupported character "${e.value}". Expected ALPHANUMERIC, ", ', +, -, or _`);const o=e.index;let i=e.value,l=e.value===T,a=e.value===I;const s=e=>{if(e.peek().done)return!0;const t=e.peek().value;return!(l||a)&&(S.test(t)||","===t||"."===t||"]"===t||"}"===t||"="===t||"#"===t)};for(;!e.done&&!s(e);){if(e.next(),l||a){const t=e.value.charCodeAt(0);if((t<=31||127===t)&&9!==t){const n=l?"basic strings":"literal strings",o=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let i="";10===t?i="Newline":13===t?i="Carriage return":0===t?i="Null":127===t&&(i="DEL");const a=i?`${i} (control character ${o}) is not allowed in ${n}`:`Control character ${o} is not allowed in ${n}`;throw new $(r,g(r,e.index),a)}}if(e.value===T&&(l=!l),e.value!==I||l||(a=!a),i+=e.value,e.peek().done)break;let t=e.peek().value;l&&"\\"===e.value&&(t===T?(i+=T,e.next()):"\\"===t&&(i+="\\",e.next()))}if(l||a)throw new $(r,g(r,o),`Expected close of string with ${l?T:I}`);return{type:t.Literal,raw:i,loc:n(o,e.index+1)}}function O(e,t,n){if(!n)return!1;if(!(e[t]===n&&e[t+1]===n&&e[t+2]===n))return!1;if(n===I)return n;const r=e.slice(0,t).match(/\\+$/);if(!r)return n;return!(r[0].length%2!=0)&&n}function D(e){return e[e.length-1]}function U(){return Object.create(null)}function F(e){return"number"==typeof e&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function L(e){return"[object Date]"===Object.prototype.toString.call(e)}function M(e){return e&&"object"==typeof e&&!L(e)&&!Array.isArray(e)}function K(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function N(e,...t){return t.reduce(((e,t)=>t(e)),e)}function j(e){if(M(e)){return`{${Object.keys(e).sort().map((t=>`${JSON.stringify(t)}:${j(e[t])}`)).join(",")}}`}return Array.isArray(e)?`[${e.map(j).join(",")}]`:JSON.stringify(e)}function Z(e,t){const n=e.length,r=t.length;e.length=n+r;for(let o=0;o<r;o++)e[n+o]=t[o]}function W(e){return e.startsWith('"""')||e.startsWith("'''")}const z=/\r\n/g,B=/\n/g,q=/^(\r\n|\n)/,V=/(?<!\\)(?:\\\\)*(\\\s*[\n\r\n]\s*)/g;function P(e){return e.startsWith("'''")?N(Y(e,3),X):e.startsWith(I)?Y(e,1):e.startsWith('"""')?N(Y(e,3),X,Q,G,R,J):e.startsWith(T)?N(Y(e,1),J):e}function R(e){let t="",n=0;for(let r=0;r<e.length;r++){const o=e[r];t+='"'===o&&n%2==0?'\\"':o,"\\"===o?n++:n=0}return t}function H(e,t){let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r--)n++;return n%2!=0}function J(e){const t=/\\(.)/g;let n;for(;null!==(n=t.exec(e));){if(H(e,n.index))continue;const t=n[1];if(!["b","t","n","f","r",'"',"\\","e","u","U","x"].includes(t))throw new Error(`Invalid escape sequence: \\${t}`)}const r=/\\u([a-fA-F0-9]{4})/g,o=e;for(;null!==(n=r.exec(o));){if(H(o,n.index))continue;const e=n[1],t=parseInt(e,16);if(t>=55296&&t<=57343)throw new Error(`Invalid Unicode escape: \\u${e} (surrogate codepoints are not allowed)`)}const i=e;let l=i.replace(/\\x([a-fA-F0-9]{2})/g,((e,t,n)=>{if(H(i,n))return e;const r=parseInt(t,16),o=String.fromCharCode(r);return r<32||34===r||92===r?Y(JSON.stringify(o),1):o}));const a=l;l=a.replace(/\\e/g,((e,t)=>H(a,t)?e:"\\u001b"));const s=l.replace(/\\U[a-fA-F0-9]{8}/g,(e=>{const t=parseInt(e.replace("\\U",""),16),n=String.fromCodePoint(t);return Y(JSON.stringify(n),1)})),c=s.replace(/\t/g,"\\t");return JSON.parse(`"${c}"`)}function Y(e,t){return e.slice(t,e.length-t)}function X(e){return e.replace(q,"")}function G(e){return e.replace(z,"\\r\\n").replace(B,"\\n")}function Q(e){return e.replace(V,((e,t)=>e.replace(t,"")))}class ee{static createDateWithOriginalFormat(e,t){if(ee.IS_DATE_ONLY.test(t)){if(0!==e.getUTCHours()||0!==e.getUTCMinutes()||0!==e.getUTCSeconds()||0!==e.getUTCMilliseconds()){if(e instanceof oe)return e;let t=e.toISOString().replace("Z","");return t=t.replace(/\.000$/,""),new re(t,!1)}const t=e.toISOString().split("T")[0];return new te(t)}if(ee.IS_TIME_ONLY.test(t)){if(e instanceof ne)return e;{const n=t.match(/\.(\d+)\s*$/),r=e.toISOString();if(r&&r.includes("T")){let o=r.split("T")[1].split("Z")[0];if(n){const t=n[1].length,[r,i,l]=o.split(":"),[a]=l.split(".");o=`${r}:${i}:${a}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new ne(o,t)}{const r=String(e.getUTCHours()).padStart(2,"0"),o=String(e.getUTCMinutes()).padStart(2,"0"),i=String(e.getUTCSeconds()).padStart(2,"0"),l=e.getUTCMilliseconds();let a;if(n){const e=n[1].length;a=`${r}:${o}:${i}.${String(l).padStart(3,"0").slice(0,e)}`}else if(l>0){a=`${r}:${o}:${i}.${String(l).padStart(3,"0").replace(/0+$/,"")}`}else a=`${r}:${o}:${i}`;return new ne(a,t)}}}if(ee.IS_LOCAL_DATETIME_T.test(t)){const n=t.match(/\.(\d+)\s*$/);let r=e.toISOString().replace("Z","");if(n){const t=n[1].length,[o,i]=r.split("T"),[l,a,s]=i.split(":"),[c]=s.split(".");r=`${o}T${l}:${a}:${c}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new re(r,!1,t)}if(ee.IS_LOCAL_DATETIME_SPACE.test(t)){const n=t.match(/\.(\d+)\s*$/);let r=e.toISOString().replace("Z","").replace("T"," ");if(n){const t=n[1].length,[o,i]=r.split(" "),[l,a,s]=i.split(":"),[c]=s.split(".");r=`${o} ${l}:${a}:${c}.${String(e.getUTCMilliseconds()).padStart(3,"0").slice(0,t)}`}return new re(r,!0,t)}if(ee.IS_OFFSET_DATETIME_T.test(t)||ee.IS_OFFSET_DATETIME_SPACE.test(t)){const n=t.match(/([+-]\d{2}:\d{2}|[Zz])$/),r=n?"z"===n[1]?"Z":n[1]:"Z",o=ee.IS_OFFSET_DATETIME_SPACE.test(t),i=t.match(/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),l=e.getTime();let a=0;if("Z"!==r){const e="+"===r[0]?1:-1,[t,n]=r.slice(1).split(":");a=e*(60*parseInt(t)+parseInt(n))}const s=new Date(l+6e4*a),c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=String(s.getUTCHours()).padStart(2,"0"),m=String(s.getUTCMinutes()).padStart(2,"0"),h=String(s.getUTCSeconds()).padStart(2,"0"),p=s.getUTCMilliseconds(),w=o?" ":"T";let g=`${d}:${m}:${h}`;if(i){const e=i[1].length;g+=`.${String(p).padStart(3,"0").slice(0,e)}`}else if(p>0){g+=`.${String(p).padStart(3,"0").replace(/0+$/,"")}`}return new oe(`${c}-${u}-${f}${w}${g}${r}`,o)}return e}}ee.IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/,ee.IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,ee.IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,ee.IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,ee.IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/,ee.IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;class te extends Date{constructor(e){super(e)}toISOString(){return`${this.getUTCFullYear()}-${String(this.getUTCMonth()+1).padStart(2,"0")}-${String(this.getUTCDate()).padStart(2,"0")}`}}class ne extends Date{constructor(e,t){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+":00"),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){const e=String(this.getUTCHours()).padStart(2,"0"),t=String(this.getUTCMinutes()).padStart(2,"0"),n=String(this.getUTCSeconds()).padStart(2,"0"),r=this.getUTCMilliseconds();if(this.originalFormat&&this.originalFormat.includes(".")){const o=this.originalFormat.match(/\.(\d+)\s*$/),i=o?o[1].length:3;return`${e}:${t}:${n}.${String(r).padStart(3,"0").slice(0,i)}`}if(r>0){return`${e}:${t}:${n}.${String(r).padStart(3,"0").replace(/0+$/,"")}`}return`${e}:${t}:${n}`}}class re extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){const e=this.getUTCFullYear(),t=String(this.getUTCMonth()+1).padStart(2,"0"),n=String(this.getUTCDate()).padStart(2,"0"),r=String(this.getUTCHours()).padStart(2,"0"),o=String(this.getUTCMinutes()).padStart(2,"0"),i=String(this.getUTCSeconds()).padStart(2,"0"),l=this.getUTCMilliseconds(),a=`${e}-${t}-${n}`,s=this.useSpaceSeparator?" ":"T";if(this.originalFormat&&this.originalFormat.includes(".")){const e=this.originalFormat.match(/\.(\d+)\s*$/),t=e?e[1].length:3;return`${a}${s}${r}:${o}:${i}.${String(l).padStart(3,"0").slice(0,t)}`}if(l>0){return`${a}${s}${r}:${o}:${i}.${String(l).padStart(3,"0").replace(/0+$/,"")}`}return`${a}${s}${r}:${o}:${i}`}}class oe extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=e;const r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset="z"===r[1]?"Z":r[1])}toISOString(){if(this.originalOffset){const e=this.getTime();let t=0;if("Z"!==this.originalOffset){const e="+"===this.originalOffset[0]?1:-1,[n,r]=this.originalOffset.slice(1).split(":");t=e*(60*parseInt(n)+parseInt(r))}const n=new Date(e+6e4*t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),i=String(n.getUTCDate()).padStart(2,"0"),l=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),s=String(n.getUTCSeconds()).padStart(2,"0"),c=n.getUTCMilliseconds(),u=`${r}-${o}-${i}`,f=this.useSpaceSeparator?" ":"T";if(this.originalFormat&&this.originalFormat.includes(".")){const e=this.originalFormat.match(/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),t=e?e[1].length:3;return`${u}${f}${l}:${a}:${s}.${String(c).padStart(3,"0").slice(0,t)}${this.originalOffset}`}if(c>0){return`${u}${f}${l}:${a}:${s}.${String(c).padStart(3,"0").replace(/0+$/,"")}${this.originalOffset}`}return`${u}${f}${l}:${a}:${s}${this.originalOffset}`}const e=super.toISOString();return this.useSpaceSeparator?e.replace("T"," "):e}}const ie=ee,le="true",ae=/e/i,se=/\_/g,ce=/^[+\-]?inf$/,ue=/^[+\-]?nan$/,fe=/^[+\-]?0x/i,de=/^[+\-]?0o/i,me=/^[+\-]?0b/i;function*he(e){const t=new h(x(e));for(;!t.next().done;){const n=Se(t,e);for(const e of n)yield e}}function pe(t){return{type:e.Comment,loc:t.value.loc,raw:t.value.raw}}function we(n,r){const o=n.peek().done||n.peek().value.type!==t.Bracket?e.Table:e.TableArray,i=o===e.Table;if(i&&"["!==n.value.raw)throw new $(r,n.value.loc.start,`Expected table opening "[", found ${n.value.raw}`);if(!i){const e=n.peek();if(e.done)throw new $(r,n.value.loc.start,'Expected second "[" for array of tables opening, found end of input');if("["!==n.value.raw||"["!==e.value.raw)throw new $(r,n.value.loc.start,`Expected array of tables opening "[[", found ${n.value.raw+e.value.raw}`);const t=n.value,o=e.value;if(t.loc.end.line!==o.loc.start.line||t.loc.end.column!==o.loc.start.column)throw new $(r,t.loc.start,"Array of tables opening brackets must be immediately adjacent with no whitespace: [[table]]")}const l=i?{type:e.TableKey,loc:n.value.loc}:{type:e.TableArrayKey,loc:n.value.loc};if(n.next(),o===e.TableArray&&n.next(),n.done)throw new $(r,l.loc.start,"Expected table key, reached end of file");if(n.value.type===t.Bracket&&"]"===n.value.raw)throw new $(r,n.value.loc.start,o===e.TableArray?"Array of tables header [[]] requires a table name":"Table header [] requires a table name");const a=n.value.raw;if(a.startsWith('"""')||a.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!(a.startsWith('"')||a.startsWith("'")))for(let e=0;e<a.length;e++){const t=a[e];if(!/[A-Za-z0-9_-]/.test(t))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${t}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}let s;try{s=[P(n.value.raw)]}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}for(l.item={type:e.Key,loc:b(n.value.loc),raw:n.value.raw,value:s};!n.peek().done&&n.peek().value.type===t.Dot;){n.next();const e=n.value;n.next();const t=n.value.raw;if(!(t.startsWith('"')||t.startsWith("'")))for(let e=0;e<t.length;e++){const o=t[e];if(!/[A-Za-z0-9_-]/.test(o))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${o}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}const o=" ".repeat(e.loc.start.column-l.item.loc.end.column),i=" ".repeat(n.value.loc.start.column-e.loc.end.column);l.item.loc.end=n.value.loc.end,l.item.raw+=`${o}.${i}${n.value.raw}`;try{l.item.value.push(P(n.value.raw))}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}}if(n.next(),!n.done){const e=l.loc.start.line;if(n.value.loc.start.line!==e)throw new $(r,n.value.loc.start,i?`Table header must not contain newlines. Expected closing ']' on line ${e}, found on line ${n.value.loc.start.line}`:`Unclosed array of tables header: expected closing ']]' on line ${e}, found newline`)}if(i&&(n.done||"]"!==n.value.raw))throw new $(r,n.done?l.item.loc.end:n.value.loc.start,`Expected table closing "]", found ${n.done?"end of file":n.value.raw}`);if(!i&&(n.done||n.peek().done||"]"!==n.value.raw||"]"!==n.peek().value.raw))throw new $(r,n.done||n.peek().done?l.item.loc.end:n.value.loc.start,`Expected array of tables closing "]]", found ${n.done||n.peek().done?"end of file":n.value.raw+n.peek().value.raw}`);if(!i){const e=n.value,t=n.peek().value;if(e.loc.end.line!==t.loc.start.line||e.loc.end.column!==t.loc.start.column)throw new $(r,e.loc.start,"Array of tables closing brackets must be immediately adjacent with no whitespace: ]]")}if(i||n.next(),l.loc.end=n.value.loc.end,!n.peek().done){const e=n.peek().value;if(e.loc.start.line===l.loc.end.line&&e.type!==t.Comment)throw new $(r,e.loc.start,`Unexpected content after ${i?"table":"array of tables"} header`)}let c=[];for(;!n.peek().done&&n.peek().value.type!==t.Bracket;)n.next(),Z(c,Se(n,r));return{type:i?e.Table:e.TableArray,loc:{start:v(l.loc.start),end:v(c.length?c[c.length-1].loc.end:l.loc.end)},key:l,items:c}}function ge(t,n){let r;try{r=P(t.value.raw)}catch(e){const r=e;throw new $(n,t.value.loc.start,r.message)}return{type:e.String,loc:t.value.loc,raw:t.value.raw,value:r}}function ye(t){return{type:e.Boolean,loc:t.value.loc,value:t.value.raw===le}}function ve(n,r){let o,i=n.value.loc,l=n.value.raw;if(!n.peek().done&&n.peek().value.type===t.Literal&&ie.IS_FULL_DATE.test(l)&&ie.IS_FULL_TIME.test(n.peek().value.raw)){const e=i.start;n.next(),i={start:e,end:n.value.loc.end},l+=` ${n.value.raw}`}if(!n.peek().done&&n.peek().value.type===t.Dot){const e=i.start;if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new $(r,n.value.loc.end,"Expected fractional value for DateTime");n.next(),i={start:e,end:n.value.loc.end},l+=`.${n.value.raw}`}if(function(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new $(t,n,`Invalid datetime "${e}": fractional seconds must have at least one digit after decimal point`);if(/[+-]$/.test(e))throw new $(t,n,`Invalid datetime "${e}": timezone offset requires hour and minute components`);const r=/\d{2}:\d{2}/.test(e),o=r?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(o){const e=o[0],r=o[2],i=o[3],l=o[4];if(":"!==i)throw new $(t,n,`Invalid timezone offset "${e}": must use colon separator (e.g., +09:09)`);if(2!==r.length)throw new $(t,n,`Invalid timezone offset "${e}": hour must be exactly 2 digits`);if(!l||0===l.length)throw new $(t,n,`Invalid timezone offset "${e}": minute component is required`);if(2!==l.length)throw new $(t,n,`Invalid timezone offset "${e}": minute must be exactly 2 digits`);const a=parseInt(r,10);if(a<0||a>23)throw new $(t,n,`Invalid timezone offset "${e}": hour must be between 00 and 23, found ${r}`);const s=parseInt(l,10);if(s<0||s>59)throw new $(t,n,`Invalid timezone offset "${e}": minute must be between 00 and 59, found ${l}`)}const i=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!i.test(e)){if(/^\d{4}-\d{2}-\d{2}T$/.test(e))throw new $(t,n,`Invalid date "${e}": date cannot end with 'T' without a time component`);if(/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e))throw new $(t,n,`Invalid date "${e}": unexpected character after date`);if(/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e))throw new $(t,n,`Invalid datetime "${e}": missing separator 'T' or space between date and time`);throw new $(t,n,`Invalid datetime "${e}"`)}const l=e.match(/^(\d+)-/);if(l&&4!==l[1].length)throw new $(t,n,`Invalid date "${e}": year must be exactly 4 digits, found ${l[1].length}`);const a=/^(\d+)-(\d+)-(\d+)/,s=e.match(a);if(s){const[,,r,o]=s;if(2!==r.length)throw new $(t,n,`Invalid date "${e}": month must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid date "${e}": day must be exactly 2 digits, found ${o.length}`)}const c=/[T ](\d+):(\d+)(?::(\d+))?/,u=e.match(c);if(u){const[,r,o,i]=u;if(2!==r.length)throw new $(t,n,`Invalid time "${e}": hour must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid time "${e}": minute must be exactly 2 digits, found ${o.length}`);if(i&&2!==i.length)throw new $(t,n,`Invalid time "${e}": second must be exactly 2 digits, found ${i.length}`)}const f=/^(\d+):(\d+)(?::(\d+))?/,d=e.match(f);if(d&&!s){const[,r,o,i]=d;if(2!==r.length)throw new $(t,n,`Invalid time "${e}": hour must be exactly 2 digits, found ${r.length}`);if(2!==o.length)throw new $(t,n,`Invalid time "${e}": minute must be exactly 2 digits, found ${o.length}`);if(i&&2!==i.length)throw new $(t,n,`Invalid time "${e}": second must be exactly 2 digits, found ${i.length}`)}const m=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),h=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(m){const[,r,o,i,l,a,s]=m,c=parseInt(o,10);if(c<1||c>12)throw new $(t,n,`Invalid date "${e}": month must be between 01 and 12`);const u=parseInt(i,10);if(u<1||u>31)throw new $(t,n,`Invalid date "${e}": day must be between 01 and 31`);const f=function(e,t){const n=[31,28,31,30,31,30,31,31,30,31,30,31];if(2===t){return e%4==0&&e%100!=0||e%400==0?29:28}return n[t-1]}(parseInt(r,10),c);if(u>f)throw new $(t,n,`Invalid date "${e}": day ${i} is invalid for month ${o} in year ${r}`);if(void 0!==l){const r=parseInt(l,10);if(r<0||r>23)throw new $(t,n,`Invalid time "${e}": hour must be between 00 and 23`)}if(void 0!==a){const r=parseInt(a,10);if(r<0||r>59)throw new $(t,n,`Invalid time "${e}": minute must be between 00 and 59`)}if(void 0!==s){const r=parseInt(s,10);if(r<0||r>60)throw new $(t,n,`Invalid time "${e}": second must be between 00 and 60`)}}else if(h){const[,r,o,i]=h,l=parseInt(r,10);if(l<0||l>23)throw new $(t,n,`Invalid time "${e}": hour must be between 00 and 23`);const a=parseInt(o,10);if(a<0||a>59)throw new $(t,n,`Invalid time "${e}": minute must be between 00 and 59`);if(void 0!==i){const r=parseInt(i,10);if(r<0||r>60)throw new $(t,n,`Invalid time "${e}": second must be between 00 and 60`)}}}(l,r,i.start),ie.IS_FULL_DATE.test(l))o=ie.IS_DATE_ONLY.test(l)?new te(l):ie.IS_LOCAL_DATETIME_T.test(l)?new re(l,!1):ie.IS_LOCAL_DATETIME_SPACE.test(l)?new re(l,!0):ie.IS_OFFSET_DATETIME_T.test(l)?new oe(l,!1):ie.IS_OFFSET_DATETIME_SPACE.test(l)?new oe(l,!0):new Date(l.replace(" ","T"));else if(ie.IS_TIME_ONLY.test(l))o=new ne(l,l);else{const[e]=(new Date).toISOString().split("T");o=new Date(`${e}T${l}`)}return{type:e.DateTime,loc:i,raw:l,value:o}}function be(n,r){let o,i=n.value.loc,l=n.value.raw;if(ce.test(l))o=l.startsWith("-")?-1/0:1/0;else if(ue.test(l))o=NaN;else if(n.peek().done||n.peek().value.type!==t.Dot){if(/_$/.test(l))throw new $(r,i.start,"Underscore before decimal point is not allowed");if(/^[+\-]?_/.test(l))throw new $(r,i.start,"Leading underscore is not allowed");if(/__/.test(l))throw new $(r,i.start,"Consecutive underscores are not allowed");if(/[eE][+\-]?$/.test(l))throw new $(r,i.start,`Invalid float "${l}": incomplete exponent`);if(/[eE][+\-]?.*\./.test(l))throw new $(r,i.start,`Invalid float "${l}": decimal point not allowed in exponent`);if(/_[eE]/.test(l))throw new $(r,i.start,"Underscore before exponent is not allowed");if(/[eE][+\-]?_/.test(l))throw new $(r,i.start,"Underscore at start of exponent is not allowed");if(!n.peek().done&&n.peek().value.type===t.Dot)throw new $(r,n.peek().value.loc.start,`Invalid float "${l}.": cannot have decimal point after exponent`);const e=l.replace(se,"");if(/^[+\-]?0\d/.test(e)&&!fe.test(l)&&!de.test(l)&&!me.test(l))throw new $(r,i.start,"Leading zeros are not allowed in the integer part of a float");o=Number(l.replace(se,""))}else{const e=i.start;{if(ae.test(l)&&!fe.test(l))throw new $(r,i.start,`Invalid float "${l}": cannot have decimal point after exponent`);const e=l,t=e.replace(se,"");if(/^[+\-]?0\d/.test(t)&&!fe.test(e)&&!de.test(e)&&!me.test(e))throw new $(r,i.start,"Leading zeros are not allowed in the integer part of a float");const n=e.replace(/^[+\-]/,"");if(""===n||"_"===n)throw new $(r,i.start,"Invalid float: decimal point must be preceded by at least one digit");if(/_$/.test(e))throw new $(r,i.start,"Underscore before decimal point is not allowed");if(/^[+\-]?_/.test(e))throw new $(r,i.start,"Leading underscore is not allowed");if(/__/.test(e))throw new $(r,i.start,"Consecutive underscores are not allowed")}if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new $(r,n.value.loc.end,"Expected fraction value for Float");n.next(),l+=`.${n.value.raw}`,i={start:e,end:n.value.loc.end};{const e=n.value.raw;if(!/^\d/.test(e))throw new $(r,n.value.loc.start,`Invalid float: fractional part must start with a digit, found "${e}"`);if(/^_/.test(e))throw new $(r,n.value.loc.start,"Underscore after decimal point is not allowed");if(/_$/.test(e))throw new $(r,n.value.loc.start,"Trailing underscore in fractional part is not allowed");if(/_[eE]/.test(e))throw new $(r,n.value.loc.start,"Underscore before exponent is not allowed");if(/[eE][+\-]?_/.test(e))throw new $(r,n.value.loc.start,"Underscore at start of exponent is not allowed");if(/[eE][+\-]?$/.test(e))throw new $(r,n.value.loc.start,`Invalid float "${l}": incomplete exponent`);if(/[eE][+\-]?.*\./.test(e))throw new $(r,n.value.loc.start,`Invalid float "${l}": decimal point not allowed in exponent`)}o=Number(l.replace(se,""))}if(Number.isNaN(o)&&!ue.test(l))throw new $(r,i.start,`Invalid float "${l}"`);return{type:e.Float,loc:i,raw:l,value:o}}function $e(t,n){const r=t.value.raw,o=t.value.loc;if(/^\d{1,}-\d{1,}/.test(r)||/^\d{1,}:\d{1,}/.test(r)||/^\d{6}-\d{2}$/.test(r))throw new $(n,o.start,`Invalid integer "${r}"`);{if("-0"===r||"+0"===r)return{type:e.Integer,loc:o,raw:r,value:0};if(/^[+\-]{2,}/.test(r))throw new $(n,o.start,"Double sign is not allowed in integers");const t=r.replace(/_/g,"");if(/^[+\-]?0\d/.test(t)&&!fe.test(r)&&!de.test(r)&&!me.test(r))throw new $(n,o.start,"Leading zeros are not allowed in decimal integers");if(/_$/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(/^[+\-]?_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(/__/.test(r))throw new $(n,o.start,"Consecutive underscores in numbers are not allowed")}let i,l=10;if(fe.test(r)){if(l=16,/^[+\-]?0X/.test(r))throw new $(n,o.start,'Hexadecimal prefix must be lowercase "0x"');if(/^[+\-]?0x_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0x/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete hexadecimal number");const e=i.replace(/_/g,"");if(!/^[0-9a-fA-F]+$/.test(e))throw new $(n,o.start,"Invalid hexadecimal digits");if(/^[+\-]/.test(r))throw new $(n,o.start,"Hexadecimal numbers cannot have a sign prefix")}else if(de.test(r)){if(l=8,/^[+\-]?0O/.test(r))throw new $(n,o.start,'Octal prefix must be lowercase "0o"');if(/^[+\-]?0o_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0o/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete octal number");const e=i.replace(/_/g,"");if(!/^[0-7]+$/.test(e))throw new $(n,o.start,"Invalid octal digits (must be 0-7)");if(/^[+\-]/.test(r))throw new $(n,o.start,"Octal numbers cannot have a sign prefix")}else if(me.test(r)){if(l=2,/^[+\-]?0B/.test(r))throw new $(n,o.start,'Binary prefix must be lowercase "0b"');if(/^[+\-]?0b_/.test(r))throw new $(n,o.start,"Underscores in numbers must be surrounded by digits");if(i=r.replace(/^[+\-]?0b/i,""),!i||"_"===i||/^_/.test(i))throw new $(n,o.start,"Incomplete binary number");const e=i.replace(/_/g,"");if(!/^[01]+$/.test(e))throw new $(n,o.start,"Invalid binary digits (must be 0 or 1)");if(/^[+\-]/.test(r))throw new $(n,o.start,"Binary numbers cannot have a sign prefix")}const a=parseInt(r.replace(se,"").replace(de,"").replace(me,""),l);if(Number.isNaN(a))throw new $(n,o.start,`Invalid integer "${r}"`);return{type:e.Integer,loc:o,raw:r,value:a}}function Se(n,r){if(n.value.type===t.Comment)return[pe(n)];if(n.value.type===t.Bracket)return[we(n,r)];if(n.value.type===t.Literal)return function(n,r){const o=n.value.raw;if(o.endsWith(":"))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+[...o].length-1},"Use '=' to separate keys and values, not ':'");if(o.startsWith('"""')||o.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!o.startsWith('"')&&!o.startsWith("'"))for(let e=0;e<o.length;e++){const t=o[e];if(!/[A-Za-z0-9_-]/.test(t))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+e},`Invalid character '${t}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}let i;try{i=[P(n.value.raw)]}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}const l={type:e.Key,loc:b(n.value.loc),raw:n.value.raw,value:i};for(;!n.peek().done&&n.peek().value.type===t.Dot;){n.next(),n.next();const e=n.value.raw;if(e.startsWith('"""')||e.startsWith("'''"))throw new $(r,n.value.loc.start,"Multiline strings (\"\"\" or ''') cannot be used as keys");if(!(e.startsWith('"')||e.startsWith("'")))for(let t=0;t<e.length;t++){const o=e[t];if(!/[A-Za-z0-9_-]/.test(o))throw new $(r,{line:n.value.loc.start.line,column:n.value.loc.start.column+t},`Invalid character '${o}' in bare key. Bare keys can only contain A-Z, a-z, 0-9, _, and -`)}l.loc.end=n.value.loc.end,l.raw+=`.${n.value.raw}`;try{l.value.push(P(n.value.raw))}catch(e){const t=e;throw new $(r,n.value.loc.start,t.message)}}if(n.next(),!n.done&&n.value.loc.start.line!==l.loc.end.line)throw new $(r,n.value.loc.start,'Expected "=" for key-value on the same line as the key');if(n.done||n.value.type!==t.Equal){if(!n.done&&":"===n.value.raw)throw new $(r,n.value.loc.start,"Use '=' to separate keys and values, not ':'");throw new $(r,n.done?l.loc.end:n.value.loc.start,'Expected "=" for key-value')}const a=n.value.loc.start.column,s=n.value.loc.start.line;if(n.next(),n.done)throw new $(r,l.loc.start,"Expected value for key-value, reached end of file");if(n.value.loc.start.line!==s)throw new $(r,n.value.loc.start,"Expected value on the same line as the '=' sign");if(n.done)throw new $(r,l.loc.start,"Expected value for key-value");const c=Te(n,r),u=c[0],f=c.slice(1);if(!n.peek().done){const o=n.peek().value;if(o.type===t.Dot&&o.loc.start.line===u.loc.end.line&&(u.type===e.Float||u.type===e.Integer))throw new $(r,o.loc.start,"Invalid number: multiple decimal points not allowed");if((o.type===t.Literal||o.type===t.Bracket)&&o.loc.start.line===u.loc.end.line)throw new $(r,o.loc.start,"Key/value pairs must be separated by a newline")}return[{type:e.KeyValue,key:l,value:u,loc:{start:v(l.loc.start),end:v(u.loc.end)},equals:a},...f]}(n,r);throw n.value.type===t.Equal?new $(r,n.value.loc.start,"Missing key before '='"):new $(r,n.value.loc.start,`Unexpected token "${n.value.type}". Expected Comment, Bracket, or String`)}function Te(n,r){if(n.value.type===t.Literal){const e=n.value.raw;return e[0]===T||e[0]===I?[ge(n,r)]:e===le||"false"===e?[ye(n)]:/^\d/.test(e)&&(/^\d{1,}-\d{1,}/.test(e)||/^\d{1,}:\d{1,}/.test(e))?[ve(n,r)]:!n.peek().done&&n.peek().value.type===t.Dot||ce.test(e)||ue.test(e)||ae.test(e)&&!fe.test(e)?[be(n,r)]:[$e(n,r)]}if(n.value.type===t.Curly){const[o,i]=function(n,r){if("{"!==n.value.raw)throw new $(r,n.value.loc.start,'Expected "{" for inline table');const o={type:e.InlineTable,loc:b(n.value.loc),items:[]},i=[];n.next();for(;!n.done&&(n.value.type!==t.Curly||"}"!==n.value.raw);){if(n.value.type===t.Comment){i.push(pe(n)),n.next();continue}if(n.value.type===t.Comma){const e=o.items[o.items.length-1];if(!e)throw new $(r,n.value.loc.start,'Found "," without previous value in inline table');if(e.comma)throw new $(r,n.value.loc.start,"Found consecutive commas in inline table (double comma is not allowed)");e.comma=!0,e.loc.end=n.value.loc.start,n.next();continue}const l=o.items[o.items.length-1];if(l&&!l.comma)throw new $(r,n.value.loc.start,"Missing comma between inline table items");const a=Se(n,r),s=a[0],c=a.slice(1);s.type===e.KeyValue&&(o.items.push({type:e.InlineItem,loc:b(s.loc),item:s,comma:!1}),Z(i,c)),n.next()}if(n.done||n.value.type!==t.Curly||"}"!==n.value.raw)throw new $(r,n.done?o.loc.start:n.value.loc.start,'Expected "}"');return o.loc.end=n.value.loc.end,[o,i]}(n,r);return[o,...i]}if(n.value.type===t.Bracket){const[o,i]=function(n,r){if("["!==n.value.raw)throw new $(r,n.value.loc.start,'Expected "[" for inline array');const o={type:e.InlineArray,loc:b(n.value.loc),items:[]},i=[];n.next();for(;!n.done&&(n.value.type!==t.Bracket||"]"!==n.value.raw);){if(n.value.type===t.Comma){const e=o.items[o.items.length-1];if(!e)throw new $(r,n.value.loc.start,'Found "," without previous value for inline array');if(e.comma)throw new $(r,n.value.loc.start,"Found consecutive commas in array (double comma is not allowed)");e.comma=!0,e.loc.end=n.value.loc.start}else if(n.value.type===t.Comment)i.push(pe(n));else{const t=o.items[o.items.length-1];if(t&&!t.comma)throw new $(r,n.value.loc.start,"Missing comma between array elements");const l=Te(n,r),a=l[0],s=l.slice(1);o.items.push({type:e.InlineItem,loc:b(a.loc),item:a,comma:!1}),Z(i,s)}n.next()}if(n.done||n.value.type!==t.Bracket||"]"!==n.value.raw)throw new $(r,n.done?o.loc.start:n.value.loc.start,'Expected "]"');return o.loc.end=n.value.loc.end,[o,i]}(n,r);return[o,...i]}throw n.value.type===t.Dot?new $(r,n.value.loc.start,"Invalid number: cannot start with a dot. Numbers must start with a digit"):new $(r,n.value.loc.start,"Unrecognized token type")}function Ie(t,n){var r;function o(e,t){for(const n of e)i(n,t)}function i(t,r){const l=n[t.type];switch(l&&"function"==typeof l&&l(t,r),l&&l.enter&&l.enter(t,r),t.type){case e.Document:o(t.items,t);break;case e.Table:i(t.key,t),o(t.items,t);break;case e.TableKey:i(t.item,t);break;case e.TableArray:i(t.key,t),o(t.items,t);break;case e.TableArrayKey:i(t.item,t);break;case e.KeyValue:i(t.key,t),i(t.value,t);break;case e.InlineArray:o(t.items,t);break;case e.InlineItem:i(t.item,t);break;case e.InlineTable:o(t.items,t);break;case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:break;default:throw new Error(`Unrecognized node type "${t.type}"`)}l&&l.exit&&l.exit(t,r)}null!=(r=t)&&"function"==typeof r[Symbol.iterator]?o(t,null):i(t,null)}const ke=new WeakMap,xe=e=>(ke.has(e)||ke.set(e,new WeakMap),ke.get(e)),Ee=new WeakMap,Ae=e=>(Ee.has(e)||Ee.set(e,new WeakMap),Ee.get(e));function Ce(e,t,n,r){if(d(t)){const e=t.items.indexOf(n);if(e<0)throw new Error("Could not find existing item in parent node for replace");t.items.splice(e,1,r)}else if(i(t)&&u(t.value)&&!u(n)){const e=t.value.items.indexOf(n);if(e<0)throw new Error("Could not find existing item in parent node for replace");t.value.items.splice(e,1,r)}else if(m(t))t.item=r;else{if(!i(t))throw new Error(`Unsupported parent type "${t.type}" for replace`);t.key===n?t.key=r:t.value=r}Me(r,{lines:n.loc.start.line-r.loc.start.line,columns:n.loc.start.column-r.loc.start.column});const o=w(n.loc),l=w(r.loc);Ke({lines:l.lines-o.lines,columns:l.columns-o.columns},Ae(e),r,n)}function _e(e,t,l,a,m){if(!d(t))throw new Error(`Unsupported parent type "${t.type}" for insert`);let h,p;a=null!=a&&"number"==typeof a?a:t.items.length,s(t)||u(t)?({shift:h,offset:p}=function(e,t,n){if(!c(t))throw new Error(`Incompatible child type "${t.type}"`);const r=null!=n?e.items[n-1]:D(e.items),o=null==n||n===e.items.length;e.items.splice(n,0,t);const i=!!r,l=!o;i&&(r.comma=!0);l&&(t.comma=!0);const a=s(e)&&function(e){if(!e.items.length)return!1;return w(e.loc).lines>e.items.length}(e),u=o&&!0===t.comma;return Oe(e,t,n,{useNewLine:a,hasCommaHandling:!0,isLastElement:o,hasSeparatingCommaBefore:i,hasSeparatingCommaAfter:l,hasTrailingComma:u})}(t,l,a)):m&&n(t)?({shift:h,offset:p}=function(e,t,n){const r=Oe(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),r}(t,l,a)):({shift:h,offset:p}=function(e,t,l){if(a=t,!(i(a)||r(a)||o(a)||f(a)))throw new Error(`Incompatible child type "${t.type}"`);var a;const s=e.items[l-1],c=n(e)&&!e.items.length;e.items.splice(l,0,t);const u=s?{line:s.loc.end.line,column:f(s)?e.loc.start.column:s.loc.start.column}:v(e.loc.start),d=r(t)||o(t);let m=0;c||(m=d?2:1);u.line+=m;const h={lines:u.line-t.loc.start.line,columns:u.column-t.loc.start.column},p=w(t.loc),g={lines:p.lines+(m-1),columns:p.columns};return{shift:h,offset:g}}(t,l,a)),Me(l,h);const g=t.items[a-1],y=g&&Ae(e).get(g);y&&(p.lines+=y.lines,p.columns+=y.columns,Ae(e).delete(g));Ae(e).set(l,p)}function Oe(e,t,n,r={}){const{useNewLine:o=!1,skipCommaSpace:i=2,skipBracketSpace:l=1,hasCommaHandling:a=!1,isLastElement:s=!1,hasSeparatingCommaBefore:c=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:d=!1}=r,m=n>0?e.items[n-1]:void 0,h=m?{line:m.loc.end.line,column:o?f(m)?e.loc.start.column:m.loc.start.column:m.loc.end.column}:v(e.loc.start);let p=0;if(o)p=1;else{const e=c||!a&&!!m;e&&a?h.column+=i:(e||a&&!m)&&(h.column+=l)}h.line+=p;const g={lines:h.line-t.loc.start.line,columns:h.column-t.loc.start.column},y=w(t.loc);if(!a){return{shift:g,offset:{lines:y.lines+(p-1),columns:y.columns}}}let b=0;c&&d&&!u&&s&&(b=-1);return{shift:g,offset:{lines:y.lines+(p-1),columns:y.columns+(c||u?i:0)+(d?1+b:0)}}}function De(e,t,n){if(!d(t))throw new Error(`Unsupported parent type "${t.type}" for remove`);let r=t.items.indexOf(n);if(r<0){if(r=t.items.findIndex((e=>m(e)&&e.item===n)),r<0)throw new Error("Could not find node in parent for removal");n=t.items[r]}const o=t.items[r-1];let i=t.items[r+1];t.items.splice(r,1);let l=w(n.loc);i&&f(i)&&i.loc.start.line===n.loc.end.line&&(l=w({start:n.loc.start,end:i.loc.end}),i=t.items[r+1],t.items.splice(r,1));const a=o&&c(o)||i&&c(i),s=o&&o.loc.end.line===n.loc.start.line,u=i&&i.loc.start.line===n.loc.end.line,h=a&&(s||u),p={lines:-(l.lines-(h?1:0)),columns:-l.columns};if(void 0===o&&void 0===i&&(p.lines=0,p.columns=0),a&&s&&(p.columns-=2),a&&!o&&i&&(p.columns-=2),a&&o&&!i){const e=n.comma;o.comma=!!e}const g=o||t,y=o?Ae(e):xe(e),v=Ae(e),b=y.get(g);b&&(p.lines+=b.lines,p.columns+=b.columns);const $=v.get(n);$&&(p.lines+=$.lines,p.columns+=$.columns),y.set(g,p)}function Ue(e,t,n=!0){if(!n)return;if(!t.items.length)return;Ke({lines:0,columns:1},xe(e),t);const r=D(t.items);Ke({lines:0,columns:1},Ae(e),r)}function Fe(e,t,n=!1){if(!n)return;if(!t.items.length)return;const r=D(t.items);r.comma=!0,Ke({lines:0,columns:1},Ae(e),r)}function Le(t){const n=xe(t),r=Ae(t),o={lines:0,columns:{}};function i(e){const t=o.lines;e.loc.start.line+=t;const r=o.columns[e.loc.start.line]||0;e.loc.start.column+=r;const i=n.get(e);i&&(o.lines+=i.lines,o.columns[e.loc.start.line]=(o.columns[e.loc.start.line]||0)+i.columns)}function l(e){const t=o.lines;e.loc.end.line+=t;const n=o.columns[e.loc.end.line]||0;e.loc.end.column+=n;const i=r.get(e);i&&(o.lines+=i.lines,o.columns[e.loc.end.line]=(o.columns[e.loc.end.line]||0)+i.columns)}const a={enter:i,exit:l};Ie(t,{[e.Document]:a,[e.Table]:a,[e.TableArray]:a,[e.InlineTable]:a,[e.InlineArray]:a,[e.InlineItem]:a,[e.TableKey]:a,[e.TableArrayKey]:a,[e.KeyValue]:{enter(e){const t=e.loc.start.line+o.lines,n=r.get(e.key);e.equals+=(o.columns[t]||0)+(n?n.columns:0),i(e)},exit:l},[e.Key]:a,[e.String]:a,[e.Integer]:a,[e.Float]:a,[e.Boolean]:a,[e.DateTime]:a,[e.Comment]:a}),ke.delete(t),Ee.delete(t)}function Me(t,n,r={}){const{first_line_only:o=!1}=r,i=t.loc.start.line,{lines:l,columns:a}=n,s=e=>{o&&e.loc.start.line!==i||(e.loc.start.column+=a,e.loc.end.column+=a),e.loc.start.line+=l,e.loc.end.line+=l};return Ie(t,{[e.Table]:s,[e.TableKey]:s,[e.TableArray]:s,[e.TableArrayKey]:s,[e.KeyValue](e){s(e),e.equals+=a},[e.Key]:s,[e.String]:s,[e.Integer]:s,[e.Float]:s,[e.Boolean]:s,[e.DateTime]:s,[e.InlineArray]:s,[e.InlineItem]:s,[e.InlineTable]:s,[e.Comment]:s}),t}function Ke(e,t,n,r){const o=t.get(r||n);o&&(e.lines+=o.lines,e.columns+=o.columns),t.set(n,e)}function Ne(){return{type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:[]}}function je(t){const n=function(t){const n=Be(t);return{type:e.TableKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+2}},item:{type:e.Key,loc:{start:{line:1,column:1},end:{line:1,column:n.length+1}},value:t,raw:n}}}(t);return{type:e.Table,loc:b(n.loc),key:n,items:[]}}function Ze(t){const n=function(t){const n=Be(t);return{type:e.TableArrayKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+4}},item:{type:e.Key,loc:{start:{line:1,column:2},end:{line:1,column:n.length+2}},value:t,raw:n}}}(t);return{type:e.TableArray,loc:b(n.loc),key:n,items:[]}}function We(t,n){const r=function(t){const n=Be(t);return{type:e.Key,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t),{column:o}=r.loc.end,i=o+1;return Me(n,{lines:0,columns:o+3-n.loc.start.column},{first_line_only:!0}),{type:e.KeyValue,loc:{start:v(r.loc.start),end:v(n.loc.end)},key:r,equals:i,value:n}}const ze=/^[\w-]+$/;function Be(e){return e.map((e=>ze.test(e)?e:JSON.stringify(e))).join(".")}function qe(t,n){let r,o;if(n&&W(n)){let e=n.startsWith("'''");e&&t.includes("'''")&&(e=!1);const o=e?"'''":'"""',i=n.includes("\r\n")?"\r\n":"\n",l=n.startsWith(`${o}${i}`)||(n.startsWith("'''\n")||n.startsWith("'''\r\n"))&&!e;let a;a=e?t:t.replace(/\\/g,"\\\\").replace(/\x08/g,"\\b").replace(/\f/g,"\\f").replace(/\t/g,"\\t").replace(/[\x00-\x07\x0B\x0E-\x1F\x7F]/g,(e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase())).replace(/"""/g,'""\\"'),r=l?`${o}${i}${a}${o}`:`${o}${a}${o}`}else r=JSON.stringify(t);if(r.includes("\r\n")||r.includes("\n")&&!r.includes("\r\n")){const e=r.includes("\r\n")?"\r\n":"\n",t=(r.match(new RegExp("\r\n"===e?"\\r\\n":"\\n","g"))||[]).length;o=t>0?{line:1+t,column:3}:{line:1,column:r.length}}else o={line:1,column:r.length};return{type:e.String,loc:{start:{line:1,column:0},end:o},raw:r,value:t}}function Ve(t){return{type:e.InlineItem,loc:b(t.loc),item:t,comma:!1}}const Pe=!1,Re=!0,He=!1,Je=!1;function Ye(e,t){if(!e||"object"!=typeof e)return null;if(("InlineArray"===e.type||"InlineTable"===e.type)&&e.loc){const n=function(e,t){var n;if(!e||!e.start||!e.end)return null;const r=t.split(/\r?\n/),o=e.start.line-1,i=e.end.line-1,l=e.start.column,a=e.end.column;let s="";if(o===i)s=(null===(n=r[o])||void 0===n?void 0:n.substring(l,a+1))||"";else{r[o]&&(s+=r[o].substring(l));for(let e=o+1;e<i;e++)s+="\n"+(r[e]||"");r[i]&&(s+="\n"+r[i].substring(0,a+1))}const c=s.match(/^\[(\s*)/),u=s.match(/^\{(\s*)/);if(c)return c[1].length>0;if(u)return u[1].length>0;return null}(e.loc,t);if(null!==n)return n}if(e.items&&Array.isArray(e.items))for(const n of e.items){const e=Ye(n,t);if(null!==e)return e;if(n.item){const e=Ye(n.item,t);if(null!==e)return e}}for(const n of["value","key","item"])if(e[n]){const r=Ye(e[n],t);if(null!==r)return r}return null}function Xe(e){if(!e||"object"!=typeof e)return null;if("InlineArray"===e.type&&e.items&&Array.isArray(e.items))return Ge(e.items);if("InlineTable"===e.type&&e.items&&Array.isArray(e.items))return Ge(e.items);if("KeyValue"===e.type&&e.value)return Xe(e.value);if(e.items&&Array.isArray(e.items))for(const t of e.items){const e=Xe(t);if(null!==e)return e}return null}function Ge(e){if(0===e.length)return null;const t=e[e.length-1];return!(!t||"object"!=typeof t||!("comma"in t))&&!0===t.comma}function Qe(e){if(!s(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function et(e){if(!u(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function tt(e){const t=e.indexOf("\n");return t>0&&"\r"===e.substring(t-1,t)?"\r\n":"\n"}function nt(e,t){var n,r,o,i,l,a;if(e){if(e instanceof rt)return e;{const s=function(e){if(!e||"object"!=typeof e)return{};const t=new Set(["newLine","trailingNewline","trailingComma","bracketSpacing","inlineTableStart","truncateZeroTimeInDates","useTabsForIndentation"]),n={},r=[],o=[];for(const i in e){const l=Object.prototype.hasOwnProperty.call(e,i);if(t.has(i)){const t=e[i];switch(i){case"newLine":"string"==typeof t?n.newLine=t:o.push(`${i} (expected string, got ${typeof t})`);break;case"trailingNewline":"boolean"==typeof t||"number"==typeof t?n.trailingNewline=t:o.push(`${i} (expected boolean or number, got ${typeof t})`);break;case"trailingComma":case"bracketSpacing":case"truncateZeroTimeInDates":case"useTabsForIndentation":"boolean"==typeof t?n[i]=t:o.push(`${i} (expected boolean, got ${typeof t})`);break;case"inlineTableStart":"number"==typeof t&&Number.isInteger(t)&&t>=0||null==t?n.inlineTableStart=t:o.push(`${i} (expected non-negative integer or undefined, got ${typeof t})`)}}else l&&r.push(i)}if(r.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${r.join(", ")}. Supported properties are: ${Array.from(t).join(", ")}`),o.length>0)throw new TypeError(`Invalid types for format properties: ${o.join(", ")}`);return n}(e);return new rt(null!==(n=s.newLine)&&void 0!==n?n:t.newLine,null!==(r=s.trailingNewline)&&void 0!==r?r:t.trailingNewline,null!==(o=s.trailingComma)&&void 0!==o?o:t.trailingComma,null!==(i=s.bracketSpacing)&&void 0!==i?i:t.bracketSpacing,void 0!==s.inlineTableStart?s.inlineTableStart:t.inlineTableStart,null!==(l=s.truncateZeroTimeInDates)&&void 0!==l?l:t.truncateZeroTimeInDates,null!==(a=s.useTabsForIndentation)&&void 0!==a?a:t.useTabsForIndentation)}}return t}class rt{constructor(e,t,n,r,o,i,l){this.newLine=null!=e?e:"\n",this.trailingNewline=null!=t?t:1,this.trailingComma=null!=n?n:Pe,this.bracketSpacing=null!=r?r:Re,this.inlineTableStart=null!=o?o:1,this.truncateZeroTimeInDates=null!=i?i:He,this.useTabsForIndentation=null!=l?l:Je}static default(){return new rt("\n",1,Pe,Re,1,He,Je)}static autoDetectFormat(e){const t=rt.default();t.newLine=tt(e),t.trailingNewline=function(e,t){let n=0,r=e.length;for(;r>=t.length&&e.substring(r-t.length,r)===t;)n++,r-=t.length;return n}(e,t.newLine);try{const n=he(e),r=Array.from(n);t.trailingComma=function(e){const t=Array.from(e);for(const e of t){const t=Xe(e);if(null!==t)return t}return Pe}(r),t.bracketSpacing=function(e,t){const n=Array.from(t);for(const t of n){const n=Ye(t,e);if(null!==n)return n}return Re}(e,r)}catch(e){t.trailingComma=Pe,t.bracketSpacing=Re}return t.useTabsForIndentation=function(e){const t=e.split(/\r?\n/);let n=0,r=0;for(const e of t)if(0!==e.length&&("\t"===e[0]?n++:" "===e[0]&&r++,n+r>=5))break;return n>r}(e),t.inlineTableStart=1,t.truncateZeroTimeInDates=He,t}}function ot(e,t){if(0===t.inlineTableStart)return e;return e.items.filter((e=>{if(!i(e))return!1;const n=u(e.value),r=s(e.value)&&e.value.items.length&&u(e.value.items[0].item);if(n||r){const n=at(e.key.value);return void 0===t.inlineTableStart||n<t.inlineTableStart}return!1})).forEach((t=>{De(e,e,t),u(t.value)?_e(e,e,it(t)):function(e){const t=Ne();for(const n of e.value.items){const r=Ze(e.key.value);_e(t,t,r);for(const e of n.item.items)_e(t,r,e.item)}return Le(t),t.items}(t).forEach((t=>{_e(e,e,t)}))})),Le(e),e}function it(e){const t=je(e.key.value);for(const n of e.value.items)_e(t,t,n.item);return Le(t),t}function lt(e){if(e.items.length>0){const t=e.items[e.items.length-1];e.loc.end.line=t.loc.end.line,e.loc.end.column=t.loc.end.column}else e.loc.end.line=e.key.loc.end.line,e.loc.end.column=e.key.loc.end.column}function at(e){return Math.max(0,e.length-1)}function st(e,t,n){var r;for(let o=e.items.length-1;o>=0;o--){const l=e.items[o];if(i(l)&&u(l.value)){const o=[...e.key.item.value,...l.key.value];if(at(o)<(null!==(r=n.inlineTableStart)&&void 0!==r?r:1)){const r=je(o);for(const e of l.value.items)_e(r,r,e.item);De(e,e,l),lt(e),t.push(r),st(r,t,n)}}}}function ct(e,t=rt.default()){e=function(e){const t=[],n=[];for(const r in e)M(e[r])||Array.isArray(e[r])?n.push(r):t.push(r);const r={};for(let n=0;n<t.length;n++){const o=t[n];r[o]=e[o]}for(let t=0;t<n.length;t++){const o=n[t];r[o]=e[o]}return r}(e=dt(e));const n=Ne();for(const r of ut(e,t))_e(n,n,r);Le(n);const r=N(n,(e=>ot(e,t)),(e=>function(e,t){if(void 0===t.inlineTableStart||0===t.inlineTableStart)return e;const n=[];for(const r of e.items)if(i(r)&&u(r.value)){if(at(r.key.value)<t.inlineTableStart){const o=it(r);De(e,e,r),_e(e,e,o),st(o,n,t)}}else"Table"===r.type&&st(r,n,t);for(const t of n)_e(e,e,t);return Le(e),e}(e,t)),(e=>function(e){return e}(e)));return function(e){let t=0,n=0;for(const r of e.items)0===n&&r.loc.start.line>1?t=1-r.loc.start.line:r.loc.start.line+t>n+2&&(t+=n+2-(r.loc.start.line+t)),Me(r,{lines:t,columns:0}),n=r.loc.end.line;return e}(r)}function*ut(e,t){for(const n of Object.keys(e))yield We([n],ft(e[n],t))}function ft(t,n){if(null==t)throw new Error('"null" and "undefined" values are not supported');return function(e){return"string"==typeof e}(t)?qe(t):F(t)?function(t){const n=t.toString();return{type:e.Integer,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t):function(e){return"number"==typeof e&&(!F(e)||!isFinite(e)||Object.is(e,-0))}(t)?function(t){let n;return n=t===1/0?"inf":t===-1/0?"-inf":Number.isNaN(t)?"nan":Object.is(t,-0)?"-0.0":t.toString(),{type:e.Float,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t):function(e){return"boolean"==typeof e}(t)?function(t){return{type:e.Boolean,loc:{start:{line:1,column:0},end:{line:1,column:t?4:5}},value:t}}(t):L(t)?function(t,n){n.truncateZeroTimeInDates&&0===t.getUTCHours()&&0===t.getUTCMinutes()&&0===t.getUTCSeconds()&&0===t.getUTCMilliseconds()&&(t=new te(t.toISOString().split("T")[0]));const r=t.toISOString();return{type:e.DateTime,loc:{start:{line:1,column:0},end:{line:1,column:r.length}},raw:r,value:t}}(t,n):Array.isArray(t)?function(t,n){const r={type:e.InlineArray,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of t){_e(r,r,Ve(ft(e,n)))}return Ue(r,r,n.bracketSpacing),Fe(r,r,n.trailingComma),Le(r),r}(t,n):function(t,n){if(t=dt(t),!M(t))return ft(t,n);const r={type:e.InlineTable,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]},o=[...ut(t,n)];for(const e of o){_e(r,r,Ve(e))}return Ue(r,r,n.bracketSpacing),Fe(r,r,n.trailingComma),Le(r),r}(t,n)}function dt(e){return e?L(e)?e:"function"==typeof e.toJSON?e.toJSON():e:e}const mt=/(\r\n|\n)/g;function ht(t,n){const r=[],o=n.useTabsForIndentation?"\t":" ";if(Ie(t,{[e.TableKey](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"[",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"]",o)},[e.TableArrayKey](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+2}},"[[",o),pt(r,{start:{line:n.line,column:n.column-2},end:n},"]]",o)},[e.KeyValue](e){const{start:{line:t}}=e.loc;pt(r,{start:{line:t,column:e.equals},end:{line:t,column:e.equals+1}},"=",o)},[e.Key](e){pt(r,e.loc,e.raw,o)},[e.String](e){pt(r,e.loc,e.raw,o)},[e.Integer](e){pt(r,e.loc,e.raw,o)},[e.Float](e){pt(r,e.loc,e.raw,o)},[e.Boolean](e){pt(r,e.loc,e.value.toString(),o)},[e.DateTime](e){pt(r,e.loc,e.raw,o)},[e.InlineArray](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"[",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"]",o)},[e.InlineTable](e){const{start:t,end:n}=e.loc;pt(r,{start:t,end:{line:t.line,column:t.column+1}},"{",o),pt(r,{start:{line:n.line,column:n.column-1},end:n},"}",o)},[e.InlineItem](e){if(!e.comma)return;const t=e.loc.end;pt(r,{start:t,end:{line:t.line,column:t.column+1}},",",o)},[e.Comment](e){pt(r,e.loc,e.raw,o)}}),n.useTabsForIndentation)for(let e=0;e<r.length;e++){const t=r[e],n=t.match(/^( +)/);if(n){const o=n[1],i="\t".repeat(o.length);r[e]=i+t.substring(o.length)}}return r.join(n.newLine)+n.newLine.repeat(n.trailingNewline)}function pt(e,t,n,r=" "){const o=n.split(mt).filter((e=>"\n"!==e&&"\r\n"!==e)),i=t.end.line-t.start.line+1;if(o.length!==i)throw new Error(`Mismatch between location and raw string, expected ${i} lines for "${n}"`);for(let r=t.start.line;r<=t.end.line;r++){const i=wt(e,r);if(void 0===i)throw new Error(`Line ${r} is uninitialized when writing "${n}" at ${t.start.line}:${t.start.column} to ${t.end.line}:${t.end.column}`);const l=r===t.start.line,a=r===t.end.line;let s="";if(l){const e=i.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column," "):e}const c=a?i.substring(t.end.column):"";e[r-1]=s+o[r-t.start.line]+c}}function wt(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]="");return e[t-1]}function gt(t,n,r){for(const o of t.items){const t=o.item,i=n.concat(t.key.value);t.value.type===e.InlineTable&&(r.add(It(i)),gt(t.value,i,r))}}function yt(t,n=""){const r=U(),o=new Set,i=new Set,l=new Set,a=new Set,s=new Set;let c=r,u=0,f=[];return Ie(t,{[e.Table](e){const t=e.key.item.value;try{bt(r,[],t,e.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(t){const r=t;throw new $(n,e.key.loc.start,r.message)}const u=It(t);o.add(u),l.add(u),c=$t(r,t),f=t},[e.TableArray](e){const t=e.key.item.value;try{bt(r,[],t,e.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(t){const r=t;throw new $(n,e.key.loc.start,r.message)}const u=It(t);i.add(u),l.add(u),c=function(e,t){const n=St(e,t.slice(0,-1)),r=D(t);n[r]||(n[r]=[]);const o=U();return n[D(t)].push(o),o}(r,t),f=t},[e.KeyValue]:{enter(t){if(u>0)return;const r=t.key.value;try{bt(c,f,r,t.type,{tables:o,table_arrays:i,defined:l,implicit_tables:a,inline_tables:s})}catch(e){const r=e;throw new $(n,t.key.loc.start,r.message)}if(r.length>1)for(let e=1;e<r.length;e++){const t=It(f.concat(r.slice(0,e)));a.add(t),l.add(t)}let d;try{d=vt(t.value)}catch(e){const r=e;throw new $(n,t.value.loc.start,r.message)}if(t.value.type===e.InlineTable){const e=f.concat(r);s.add(It(e)),gt(t.value,e,s)}(r.length>1?$t(c,r.slice(0,-1)):c)[D(r)]=d,l.add(It(f.concat(r)))}},[e.InlineTable]:{enter(){u++},exit(){u--}}}),r}function vt(t){switch(t.type){case e.InlineTable:const n=U(),r=new Set,o=new Map;return t.items.forEach((({item:e})=>{const t=e.key.value,i=vt(e.value),l=It(t);if(r.has(l))throw new Error(`Duplicate key "${l}" in inline table`);for(let e=1;e<t.length;e++){const n=It(t.slice(0,e));if(r.has(n))throw new Error(`Key "${l}" conflicts with already defined key "${n}" in inline table`)}if(o.has(l)){const e=o.get(l);throw new Error(`Key "${l}" conflicts with already defined key "${e}" in inline table`)}r.add(l);for(let e=1;e<t.length;e++){const n=It(t.slice(0,e));o.has(n)||o.set(n,l)}(t.length>1?$t(n,t.slice(0,-1)):n)[D(t)]=i})),n;case e.InlineArray:return t.items.map((e=>vt(e.item)));case e.DateTime:case e.String:case e.Integer:case e.Float:case e.Boolean:return t.value;default:throw new Error(`Unrecognized value type "${t.type}"`)}}function bt(t,n,r,o,i){const l=It(n.concat(r));if(o===e.KeyValue&&r.length>1)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.inline_tables.has(t))throw new Error(`Invalid key, cannot extend an inline table at ${t}`)}if((o===e.Table||o===e.TableArray)&&i.inline_tables.has(l))throw new Error(`Invalid key, cannot extend an inline table at ${l}`);if(o===e.Table||o===e.TableArray)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.inline_tables.has(t))throw new Error(`Invalid key, cannot extend an inline table at ${t}`)}if(o===e.KeyValue&&r.length>1)for(let e=1;e<r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.table_arrays.has(t))throw new Error(`Invalid key, cannot traverse into an array of tables at ${t}`)}if((o===e.Table||o===e.TableArray)&&i.implicit_tables.has(l))throw new Error(`Invalid key, a table has already been defined implicitly named ${l}`);if(o===e.KeyValue&&i.implicit_tables.has(l))throw new Error(`Invalid key, a table has already been defined named ${l}`);if(o===e.KeyValue&&r.length>1)for(let e=1;e<=r.length;e++){const t=It(n.concat(r.slice(0,e)));if(i.tables.has(t))throw new Error(`Invalid key, cannot add to an explicitly defined table ${t} using dotted keys`)}let a=[],s=0;for(const e of r){if(a.push(e),!K(t,e))return;if(Tt(t[e])){const e=It(n.concat(a));throw new Error(`Invalid key, a value has already been defined for ${e}`)}const o=It(n.concat(a));if(Array.isArray(t[e])&&!i.table_arrays.has(o))throw new Error(`Invalid key, cannot add to a static array at ${o}`);const l=s++<r.length-1;t=Array.isArray(t[e])&&l?D(t[e]):t[e]}const c=l;if(t&&o===e.Table&&i.defined.has(c))throw new Error(`Invalid key, a table has already been defined named ${c}`);if(t&&o===e.KeyValue&&1===r.length&&i.defined.has(c)&&!Tt(t))throw new Error(`Invalid key, a table has already been defined named ${c}`);if(t&&o===e.TableArray&&!i.table_arrays.has(c))throw new Error(`Invalid key, cannot add an array of tables to a table at ${c}`)}function $t(e,t){const n=St(e,t.slice(0,-1)),r=D(t);return n[r]||(n[r]=U()),n[r]}function St(e,t){return t.reduce(((e,t)=>(e[t]||(e[t]=U()),Array.isArray(e[t])?D(e[t]):e[t])),e)}function Tt(e){return"object"!=typeof e&&!L(e)}function It(e){return e.join(".")}var kt,xt,Et,At;function Ct(e){return e.type===kt.Remove}function _t(e,t,n=[]){return e===t||(o=t,L(r=e)&&L(o)&&r.toISOString()===o.toISOString())?[]:Array.isArray(e)&&Array.isArray(t)?function(e,t,n=[]){let r=[];const o=e.map(j),i=t.map(j);i.forEach(((l,a)=>{const s=a>=o.length;if(!s&&o[a]===l)return;const c=o.indexOf(l,a+1);if(!s&&c>-1){r.push({type:kt.Move,path:n,from:c,to:a});const e=o.splice(c,1);return void o.splice(a,0,...e)}const u=!i.includes(o[a]);if(!s&&u)return Z(r,_t(e[a],t[a],n.concat(a))),void(o[a]=l);r.push({type:kt.Add,path:n.concat(a)}),o.splice(a,0,l)}));for(let e=i.length;e<o.length;e++)r.push({type:kt.Remove,path:n.concat(e)});return r}(e,t,n):M(e)&&M(t)?function(e,t,n=[]){let r=[];const o=Object.keys(e),i=o.map((t=>j(e[t]))),l=Object.keys(t),a=l.map((e=>j(t[e]))),s=(e,t)=>{if(t.indexOf(e)<0)return!1;const n=o[i.indexOf(e)];return!l.includes(n)};return o.forEach(((o,c)=>{const u=n.concat(o);if(l.includes(o))Z(r,_t(e[o],t[o],u));else if(s(i[c],a)){const e=l[a.indexOf(i[c])];r.push({type:kt.Rename,path:n,from:o,to:e})}else r.push({type:kt.Remove,path:u})})),l.forEach(((e,t)=>{o.includes(e)||s(a[t],i)||r.push({type:kt.Add,path:n.concat(e)})})),r}(e,t,n):[{type:kt.Edit,path:n}];var r,o}function Ot(e,t){if(!t.length)return c(e)&&i(e.item)?e.item:e;if(i(e))return Ot(e.value,t);const n={};let l;if(d(e)&&e.items.some(((e,a)=>{try{let s=[];if(i(e))s=e.key.value;else if(r(e))s=e.key.item.value;else if(o(e)){s=e.key.item.value;const t=j(s);n[t]||(n[t]=0);const r=n[t]++;s=s.concat(r)}else c(e)&&i(e.item)?s=e.item.key.value:c(e)&&(s=[a]);return!(!s.length||!function(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}(s,t.slice(0,s.length)))&&(l=c(e)&&i(e.item)?t.length===s.length?e:Ot(e.item.value,t.slice(s.length)):Ot(e,t.slice(s.length)),!0)}catch(e){return!1}})),!l)throw new Error(`Could not find node at path ${t.join(".")}`);return l}function Dt(e,t){try{return Ot(e,t)}catch(e){}}function Ut(e,t){let n,r=t;for(;r.length&&!n;)r=r.slice(0,-1),n=Dt(e,r);if(!n)throw new Error(`Count not find parent node for path ${t.join(".")}`);return n}function Ft(t,l,a){const f=[...t],d=yt(f),h={type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:f},p=ct(l,nt(Object.assign(Object.assign({},a),{inlineTableStart:void 0}),a)),w=function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Ct(n)){let r=t+1;for(;r<e.length;){const o=e[r];if(Ct(o)&&o.path[0]===n.path[0]&&o.path[1]>n.path[1]){e.splice(r,1),e.splice(t,0,o),t=0;break}r++}}}return e}(_t(d,l));if(0===w.length)return{tomlString:ht(f,a),document:h};const g=function(e,t,l,a){return l.forEach((l=>{if(function(e){return e.type===kt.Add}(l)){const f=Ot(t,l.path),d=l.path.slice(0,-1);let m,h=D(l.path),p=o(f);if(F(h)&&!d.some(F)){const t=Dt(e,d.concat(0));t&&o(t)&&(p=!0)}if(r(f))m=e;else if(p){m=e;const t=e,n=Dt(t,d.concat(h-1)),r=Dt(t,d.concat(h));h=r?t.items.indexOf(r):n?t.items.indexOf(n)+1:t.items.length}else m=Ut(e,l.path),i(m)&&(m=m.value);if(o(m)||s(m)||n(m)){if(s(m)){const e=Qe(m);c(f)&&(f.comma=e)}if(void 0!==a.inlineTableStart&&a.inlineTableStart>0&&n(m)&&r(f)){const t=Mt(f,e,a);_e(e,m,f,h);for(const n of t)_e(e,e,n,void 0)}else _e(e,m,f,h)}else if(u(m)){const t=et(m);if(i(f)){const n=Ve(f);n.comma=t,_e(e,m,n)}else _e(e,m,f)}else if(void 0!==a.inlineTableStart&&a.inlineTableStart>0&&i(f)&&u(f.value)&&r(m)){at([...m.key.item.value,...f.key.value])<a.inlineTableStart?function(e,t,n,r){const o=t.key.item.value,l=[...o,...e.key.value],a=je(l);if(u(e.value))for(const t of e.value.items)c(t)&&i(t.item)&&_e(n,a,t.item,void 0);_e(n,n,a,void 0),lt(t);const s=Mt(a,n,r);for(const e of s)_e(n,n,e,void 0)}(f,m,e,a):_e(e,m,f)}else if(0===a.inlineTableStart&&i(f)&&u(f.value)&&n(m))_e(e,m,f,void 0,!0);else{let t=f;c(f)&&(r(m)||n(m))&&(t=f.item),_e(e,m,t)}}else if(function(e){return e.type===kt.Edit}(l)){let n,r=Ot(e,l.path),o=Ot(t,l.path);if(i(r)&&i(o))Lt(r.value,o.value),n=r,r=r.value,o=o.value;else if(i(r)&&c(o)&&i(o.item))n=r,r=r.value,o=o.item.value;else if(c(r)&&i(o))n=r,r=r.item;else if(c(r)&&c(o)&&i(r.item)&&i(o.item))Lt(r.item.value,o.item.value),n=r.item,r=r.item.value,o=o.item.value;else if(n=Ut(e,l.path),i(n)){const t=l.path.slice(0,-1),r=Ot(e,t);i(r)&&s(r.value)&&(n=r.value)}Ce(e,n,r,o)}else if(Ct(l)){let t=Ut(e,l.path);i(t)&&(t=t.value);const n=Ot(e,l.path);De(e,t,n)}else if(function(e){return e.type===kt.Move}(l)){let t=Ot(e,l.path);m(t)&&(t=t.item),i(t)&&(t=t.value);const n=t.items[l.from];De(e,t,n),_e(e,t,n,l.to)}else if(function(e){return e.type===kt.Rename}(l)){let n=Ot(e,l.path.concat(l.from)),r=Ot(t,l.path.concat(l.to));m(n)&&(n=n.item),m(r)&&(r=r.item),Ce(e,n,n.key,r.key)}})),Le(e),e}(h,p,w,a);return{tomlString:ht(g.items,a),document:g}}function Lt(e,t){if(l(e)&&l(t)&&W(e.raw)){const n=qe(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(a(e)&&a(t)){const n=e.raw,r=t.value,o=ee.createDateWithOriginalFormat(r,n);t.value=o,t.raw=o.toISOString();0!==t.raw.length-n.length&&(t.loc.end.column=t.loc.start.column+t.raw.length)}if(s(e)&&s(t)){const n=Qe(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}if(u(e)&&u(t)){const n=et(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}}function Mt(e,t,n){const r=[],o=(e,r)=>{var l;for(let a=e.items.length-1;a>=0;a--){const s=e.items[a];if(i(s)&&u(s.value)){const u=[...e.key.item.value,...s.key.value];if(at(u)<(null!==(l=n.inlineTableStart)&&void 0!==l?l:1)&&0!==n.inlineTableStart){const n=je(u);for(const e of s.value.items)c(e)&&i(e.item)&&_e(t,n,e.item,void 0);e.items.splice(a,1),lt(e),r.push(n),o(n,r)}}}};return o(e,r),r}function Kt(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function Nt(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function jt(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}!function(e){e.Add="Add",e.Edit="Edit",e.Remove="Remove",e.Move="Move",e.Rename="Rename"}(kt||(kt={})),"function"==typeof SuppressedError&&SuppressedError;function Zt(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(Zt);if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))t[n]=Zt(r);return t}return e}xt=new WeakMap,Et=new WeakMap,At=new WeakMap,exports.TomlDocument=class{constructor(e){xt.set(this,void 0),Et.set(this,void 0),At.set(this,void 0),Nt(this,Et,e,"f"),Nt(this,xt,Array.from(he(e)),"f"),Nt(this,At,rt.autoDetectFormat(e),"f")}get toTomlString(){return Kt(this,Et,"f")}get toJsObject(){return Zt(yt(Kt(this,xt,"f")))}get ast(){return Kt(this,xt,"f")}patch(e,t){const n=nt(t,Kt(this,At,"f")),{tomlString:r,document:o}=Ft(Kt(this,xt,"f"),e,n);Nt(this,xt,o.items,"f"),Nt(this,Et,r,"f")}update(e){if(e===this.toTomlString)return;const t=this.toTomlString.split(Kt(this,At,"f").newLine),n=tt(e),r=e.split(n);let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];)o++;let i=0;if(o<t.length&&o<r.length){const e=t[o],n=r[o];for(let t=0;t<Math.max(e.length,n.length);t++)if(e[t]!==n[t]){i=t;break}}let l=o+1;const{truncatedAst:a,lastEndPosition:s}=function(e,t,n){const r={line:t,column:n},o=[];let i=null;for(const t of e){const e=jt(t.loc.end,r)<0,n=jt(t.loc.start,r)<0;if(!e){if(n&&!e)break;break}o.push(t),i=t.loc.end}return{truncatedAst:o,lastEndPosition:i}}(Kt(this,xt,"f"),l,i),c=s?s.line:1,u=s?s.column+1:0,f=r.slice(c-1);f.length>0&&u>0&&(f[0]=f[0].substring(u));const d=f.join(Kt(this,At,"f").newLine);Nt(this,xt,Array.from(function*(e,t){for(const t of e)yield t;const n=new h(x(t));for(;!n.next().done;){const e=Se(n,t);for(const t of e)yield t}}(a,d)),"f"),Nt(this,Et,e,"f"),Nt(this,At,rt.autoDetectFormat(e),"f")}overwrite(e){e!==this.toTomlString&&(Nt(this,xt,Array.from(he(e)),"f"),Nt(this,Et,e,"f"),Nt(this,At,rt.autoDetectFormat(e),"f"))}},exports.TomlFormat=rt,exports.parse=function(e){return yt(he(e),e)},exports.patch=function(e,t,n){return Ft(he(e),t,nt(n,rt.autoDetectFormat(e))).tomlString},exports.stringify=function(e,t){const n=nt(t,rt.default());return ht(ct(e,n).items,n)};
|
|
3
|
-
//# sourceMappingURL=toml-patch.cjs.min.js.map
|