json-variables 11.0.6 → 11.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -26,18 +26,17 @@
26
26
 
27
27
  ## Install
28
28
 
29
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `10.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i json-variables
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 10.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
40
38
  import { strict as assert } from "assert";
39
+
41
40
  import { jVar } from "json-variables";
42
41
 
43
42
  assert.deepEqual(
@@ -58,7 +57,7 @@ assert.deepEqual(
58
57
 
59
58
  ## Documentation
60
59
 
61
- Please [visit codsen.com](https://codsen.com/os/json-variables/) for a full description of the API, examples and even a test <a href="https://codsen.com/os/json-variables/play">playground</a>.
60
+ Please [visit codsen.com](https://codsen.com/os/json-variables/) for a full description of the API and even a test <a href="https://codsen.com/os/json-variables/play">playground</a>.
62
61
 
63
62
  ## Contributing
64
63
 
@@ -68,6 +67,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
68
67
 
69
68
  MIT License
70
69
 
71
- Copyright (c) 2010-2021 Roy Revelt and other contributors
70
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
72
71
 
73
72
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,511 +1,16 @@
1
1
  /**
2
2
  * @name json-variables
3
3
  * @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
4
- * @version 11.0.6
4
+ * @version 11.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/json-variables/}
8
8
  */
9
9
 
10
- import { traverse } from 'ast-monkey-traverse';
11
- import { isMatch } from 'matcher';
12
- import objectPath from 'object-path';
13
- import { arrayiffy } from 'arrayiffy-if-string';
14
- import { strFindHeadsTails } from 'string-find-heads-tails';
15
- import { getByKey } from 'ast-get-values-by-key';
16
- import { Ranges } from 'ranges-push';
17
- import { rApply } from 'ranges-apply';
18
- import { remDup } from 'string-remove-duplicate-heads-tails';
19
- import { matchRightIncl, matchLeftIncl } from 'string-match-left-right';
10
+ import{traverse as k}from"ast-monkey-traverse";import{isMatch as x}from"matcher";import d from"object-path";import{arrayiffy as F}from"arrayiffy-if-string";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{Ranges as B}from"ranges-push";import{rApply as S}from"ranges-apply";import{remDup as L}from"string-remove-duplicate-heads-tails";import{matchLeftIncl as U,matchRightIncl as M}from"string-match-left-right";var j="11.0.12";var de=j,q=Object.prototype.hasOwnProperty,K={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function u(e){return typeof e=="string"}function G(e){return typeof e=="number"}function A(e){return typeof e=="boolean"}function D(e){return e===null}function w(e){return e&&typeof e=="object"&&!Array.isArray(e)}function z(e){return e!=null}function g(e){return u(e)?e.trim():e}function Y(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=0,t=e.length;r<t;r++)if(e[r]===".")return e.slice(0,r)}return e}function Q(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=0,t=e.length;r<t;r++)if(e[r]===".")return e.slice(r+1)}return e}function P(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function H(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(r+1)}return e}function T(e,r){return typeof e!="string"||!e.trim()?!1:!!(e.includes(r.heads)||e.includes(r.tails)||u(r.headsNoWrap)&&r.headsNoWrap.length>0&&e.includes(r.headsNoWrap)||u(r.tailsNoWrap)&&r.tailsNoWrap.length>0&&e.includes(r.tailsNoWrap))}function X(e,r,t){let l,i;return typeof e=="string"&&e.length>0&&M(e,0,r,{trimBeforeMatching:!0,cb:(n,a,o)=>(l=o,!0)})&&U(e,e.length-1,t,{trimBeforeMatching:!0,cb:(n,a,o)=>(i=+o+1,!0)})?e.slice(l,i):e}function J(e,r,t=!1,l,i,n){if(r.wrapHeadsWith||(r.wrapHeadsWith=""),r.wrapTailsWith||(r.wrapTailsWith=""),u(e)&&!t&&r.wrapGlobalFlipSwitch&&!r.dontWrapVars.some(a=>x(n,a))&&(!r.preventDoubleWrapping||r.preventDoubleWrapping&&u(e)&&!e.includes(r.wrapHeadsWith)&&!e.includes(r.wrapTailsWith)))return`${r.wrapHeadsWith}${e}${r.wrapTailsWith}`;if(t){if(!u(e))return e;let a=L(e,{heads:r.wrapHeadsWith,tails:r.wrapTailsWith});return u(a)?X(a,r.wrapHeadsWith,r.wrapTailsWith):a}return e}function Z(e,r,t,l){let i;if(t.indexOf(".")!==-1){let n=t,a=!0;if(l.lookForDataContainers&&typeof l.dataContainerIdentifierTails=="string"&&l.dataContainerIdentifierTails.length>0&&!n.endsWith(l.dataContainerIdentifierTails)){let o=d.get(e,n+l.dataContainerIdentifierTails);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}for(;a&&n.indexOf(".")!==-1;){if(n=P(n),H(n)===r)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${r}" at path "${t}", we encountered a closed loop. The parent key "${H(n)}" is called the same as the variable "${r}" we're looking for.`);if(l.lookForDataContainers&&typeof l.dataContainerIdentifierTails=="string"&&l.dataContainerIdentifierTails.length>0&&!n.endsWith(l.dataContainerIdentifierTails)){let o=d.get(e,n+l.dataContainerIdentifierTails);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}if(i===void 0){let o=d.get(e,n);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}}}if(i===void 0){let n=d.get(e,r);n!==void 0&&(i=n)}if(i===void 0)if(r.indexOf(".")===-1){let n=_(e,r);if(n.length>0){for(let a=0,o=n.length;a<o;a++)if(u(n[a].val)||A(n[a].val)||D(n[a].val)){i=n[a].val;break}else if(G(n[a].val)){i=String(n[a].val);break}else if(Array.isArray(n[a].val)){i=n[a].val.join("");break}}}else{let n=_(e,Y(r));if(n.length>0)for(let a=0,o=n.length;a<o;a++){let y=d.get(n[a].val,Q(r));y&&u(y)&&(i=y)}}return i}function R(e,r,t,l,i=[]){if(i.includes(t)){let c="";if(i.length>1){let m=` \u2192
11
+ `;c=i.reduce((E,b,O)=>E+(O===0?"":m)+(b===t?"\u{1F4A5} ":" ")+b,` Here's the path we travelled up until we hit the recursion:
20
12
 
21
- var version$1 = "11.0.6";
22
-
23
- const version = version$1;
24
- const has = Object.prototype.hasOwnProperty;
25
- const defaults = {
26
- heads: "%%_",
27
- tails: "_%%",
28
- headsNoWrap: "%%-",
29
- tailsNoWrap: "-%%",
30
- lookForDataContainers: true,
31
- dataContainerIdentifierTails: "_data",
32
- wrapHeadsWith: "",
33
- wrapTailsWith: "",
34
- dontWrapVars: [],
35
- preventDoubleWrapping: true,
36
- wrapGlobalFlipSwitch: true,
37
- noSingleMarkers: false,
38
- resolveToBoolIfAnyValuesContainBool: true,
39
- resolveToFalseIfAnyValuesContainBool: true,
40
- throwWhenNonStringInsertedInString: false,
41
- allowUnresolved: false,
42
- };
43
- function isStr(something) {
44
- return typeof something === "string";
45
- }
46
- function isNum(something) {
47
- return typeof something === "number";
48
- }
49
- function isBool(something) {
50
- return typeof something === "boolean";
51
- }
52
- function isNull(something) {
53
- return something === null;
54
- }
55
- function isObj(something) {
56
- return (something && typeof something === "object" && !Array.isArray(something));
57
- }
58
- function existy(x) {
59
- return x != null;
60
- }
61
- function trimIfString(something) {
62
- return isStr(something) ? something.trim() : something;
63
- }
64
- function getTopmostKey(str) {
65
- if (typeof str === "string" && str.length > 0 && str.indexOf(".") !== -1) {
66
- for (let i = 0, len = str.length; i < len; i++) {
67
- if (str[i] === ".") {
68
- return str.slice(0, i);
69
- }
70
- }
71
- }
72
- return str;
73
- }
74
- function withoutTopmostKey(str) {
75
- if (typeof str === "string" && str.length > 0 && str.indexOf(".") !== -1) {
76
- for (let i = 0, len = str.length; i < len; i++) {
77
- if (str[i] === ".") {
78
- return str.slice(i + 1);
79
- }
80
- }
81
- }
82
- return str;
83
- }
84
- function goLevelUp(str) {
85
- if (typeof str === "string" && str.length > 0 && str.indexOf(".") !== -1) {
86
- for (let i = str.length; i--;) {
87
- if (str[i] === ".") {
88
- return str.slice(0, i);
89
- }
90
- }
91
- }
92
- return str;
93
- }
94
- function getLastKey(str) {
95
- if (typeof str === "string" && str.length > 0 && str.indexOf(".") !== -1) {
96
- for (let i = str.length; i--;) {
97
- if (str[i] === ".") {
98
- return str.slice(i + 1);
99
- }
100
- }
101
- }
102
- return str;
103
- }
104
- function containsHeadsOrTails(str, opts) {
105
- if (typeof str !== "string" || !str.trim()) {
106
- return false;
107
- }
108
- if (str.includes(opts.heads) ||
109
- str.includes(opts.tails) ||
110
- (isStr(opts.headsNoWrap) &&
111
- opts.headsNoWrap.length > 0 &&
112
- str.includes(opts.headsNoWrap)) ||
113
- (isStr(opts.tailsNoWrap) &&
114
- opts.tailsNoWrap.length > 0 &&
115
- str.includes(opts.tailsNoWrap))) {
116
- return true;
117
- }
118
- return false;
119
- }
120
- function removeWrappingHeadsAndTails(str, heads, tails) {
121
- let tempFrom;
122
- let tempTo;
123
- if (typeof str === "string" &&
124
- str.length > 0 &&
125
- matchRightIncl(str, 0, heads, {
126
- trimBeforeMatching: true,
127
- cb: (_c, _t, index) => {
128
- tempFrom = index;
129
- return true;
130
- },
131
- }) &&
132
- matchLeftIncl(str, str.length - 1, tails, {
133
- trimBeforeMatching: true,
134
- cb: (_c, _t, index) => {
135
- tempTo = index + 1;
136
- return true;
137
- },
138
- })) {
139
- return str.slice(tempFrom, tempTo);
140
- }
141
- return str;
142
- }
143
- function wrap(placementValue, opts, dontWrapTheseVars = false, breadCrumbPath, newPath, oldVarName) {
144
- if (!opts.wrapHeadsWith) {
145
- opts.wrapHeadsWith = "";
146
- }
147
- if (!opts.wrapTailsWith) {
148
- opts.wrapTailsWith = "";
149
- }
150
- if (isStr(placementValue) &&
151
- !dontWrapTheseVars &&
152
- opts.wrapGlobalFlipSwitch &&
153
- !opts.dontWrapVars.some((val) => isMatch(oldVarName, val)) &&
154
- (!opts.preventDoubleWrapping ||
155
- (opts.preventDoubleWrapping &&
156
- isStr(placementValue) &&
157
- !placementValue.includes(opts.wrapHeadsWith) &&
158
- !placementValue.includes(opts.wrapTailsWith)))) {
159
- return opts.wrapHeadsWith + placementValue + opts.wrapTailsWith;
160
- }
161
- if (dontWrapTheseVars) {
162
- if (!isStr(placementValue)) {
163
- return placementValue;
164
- }
165
- const tempValue = remDup(placementValue, {
166
- heads: opts.wrapHeadsWith,
167
- tails: opts.wrapTailsWith,
168
- });
169
- if (!isStr(tempValue)) {
170
- return tempValue;
171
- }
172
- return removeWrappingHeadsAndTails(tempValue, opts.wrapHeadsWith, opts.wrapTailsWith);
173
- }
174
- return placementValue;
175
- }
176
- function findValues(input, varName, path, opts) {
177
- let resolveValue;
178
- if (path.indexOf(".") !== -1) {
179
- let currentPath = path;
180
- let handBrakeOff = true;
181
- if (opts.lookForDataContainers &&
182
- typeof opts.dataContainerIdentifierTails === "string" &&
183
- opts.dataContainerIdentifierTails.length > 0 &&
184
- !currentPath.endsWith(opts.dataContainerIdentifierTails)) {
185
- const gotPath = objectPath.get(input, currentPath + opts.dataContainerIdentifierTails);
186
- if (isObj(gotPath) && objectPath.get(gotPath, varName)) {
187
- resolveValue = objectPath.get(gotPath, varName);
188
- handBrakeOff = false;
189
- }
190
- }
191
- while (handBrakeOff && currentPath.indexOf(".") !== -1) {
192
- currentPath = goLevelUp(currentPath);
193
- if (getLastKey(currentPath) === varName) {
194
- throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${varName}" at path "${path}", we encountered a closed loop. The parent key "${getLastKey(currentPath)}" is called the same as the variable "${varName}" we're looking for.`);
195
- }
196
- if (opts.lookForDataContainers &&
197
- typeof opts.dataContainerIdentifierTails === "string" &&
198
- opts.dataContainerIdentifierTails.length > 0 &&
199
- !currentPath.endsWith(opts.dataContainerIdentifierTails)) {
200
- const gotPath = objectPath.get(input, currentPath + opts.dataContainerIdentifierTails);
201
- if (isObj(gotPath) && objectPath.get(gotPath, varName)) {
202
- resolveValue = objectPath.get(gotPath, varName);
203
- handBrakeOff = false;
204
- }
205
- }
206
- if (resolveValue === undefined) {
207
- const gotPath = objectPath.get(input, currentPath);
208
- if (isObj(gotPath) && objectPath.get(gotPath, varName)) {
209
- resolveValue = objectPath.get(gotPath, varName);
210
- handBrakeOff = false;
211
- }
212
- }
213
- }
214
- }
215
- if (resolveValue === undefined) {
216
- const gotPath = objectPath.get(input, varName);
217
- if (gotPath !== undefined) {
218
- resolveValue = gotPath;
219
- }
220
- }
221
- if (resolveValue === undefined) {
222
- if (varName.indexOf(".") === -1) {
223
- const gotPathArr = getByKey(input, varName);
224
- if (gotPathArr.length > 0) {
225
- for (let y = 0, len2 = gotPathArr.length; y < len2; y++) {
226
- if (isStr(gotPathArr[y].val) ||
227
- isBool(gotPathArr[y].val) ||
228
- isNull(gotPathArr[y].val)) {
229
- resolveValue = gotPathArr[y].val;
230
- break;
231
- }
232
- else if (isNum(gotPathArr[y].val)) {
233
- resolveValue = String(gotPathArr[y].val);
234
- break;
235
- }
236
- else if (Array.isArray(gotPathArr[y].val)) {
237
- resolveValue = gotPathArr[y].val.join("");
238
- break;
239
- }
240
- else {
241
- throw new Error(`json-variables/findValues(): [THROW_ID_21] While trying to resolve: "${varName}" at path "${path}", we actually found the key named ${varName}, but it was not equal to a string but to:\n${JSON.stringify(gotPathArr[y], null, 4)}\nWe can't resolve a string with that! It should be a string.`);
242
- }
243
- }
244
- }
245
- }
246
- else {
247
- const gotPath = getByKey(input, getTopmostKey(varName));
248
- if (gotPath.length > 0) {
249
- for (let y = 0, len2 = gotPath.length; y < len2; y++) {
250
- const temp = objectPath.get(gotPath[y].val, withoutTopmostKey(varName));
251
- if (temp && isStr(temp)) {
252
- resolveValue = temp;
253
- }
254
- }
255
- }
256
- }
257
- }
258
- return resolveValue;
259
- }
260
- function resolveString(input, string, path, opts, incomingBreadCrumbPath = []) {
261
- if (incomingBreadCrumbPath.includes(path)) {
262
- let extra = "";
263
- if (incomingBreadCrumbPath.length > 1) {
264
- const separator = " →\n";
265
- extra = incomingBreadCrumbPath.reduce((accum, curr, idx) => accum +
266
- (idx === 0 ? "" : separator) +
267
- (curr === path ? "💥 " : " ") +
268
- curr, " Here's the path we travelled up until we hit the recursion:\n\n");
269
- extra += `${separator}💥 ${path}`;
270
- }
271
- throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${string}" at path "${path}", we encountered a closed loop, the key is referencing itself."${extra}`);
272
- }
273
- const secretResolvedVarsStash = {};
274
- const breadCrumbPath = Array.from(incomingBreadCrumbPath);
275
- breadCrumbPath.push(path);
276
- const finalRangesArr = new Ranges();
277
- function processHeadsAndTails(arr, dontWrapTheseVars, wholeValueIsVariable) {
278
- for (let i = 0, len = arr.length; i < len; i++) {
279
- const obj = arr[i];
280
- const varName = string.slice(obj.headsEndAt, obj.tailsStartAt);
281
- if (varName.length === 0) {
282
- finalRangesArr.push(obj.headsStartAt,
283
- obj.tailsEndAt
284
- );
285
- }
286
- else if (has.call(secretResolvedVarsStash, varName) &&
287
- isStr(secretResolvedVarsStash[varName])) {
288
- finalRangesArr.push(obj.headsStartAt,
289
- obj.tailsEndAt,
290
- secretResolvedVarsStash[varName]
291
- );
292
- }
293
- else {
294
- let resolvedValue = findValues(input,
295
- varName.trim(),
296
- path,
297
- opts
298
- );
299
- if (resolvedValue === undefined) {
300
- if (opts.allowUnresolved === true) {
301
- resolvedValue = "";
302
- }
303
- else if (typeof opts.allowUnresolved === "string") {
304
- resolvedValue = opts.allowUnresolved;
305
- }
306
- else {
307
- throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${string.slice(obj.headsEndAt, obj.tailsStartAt)}. We're at path: "${path}".`);
308
- }
309
- }
310
- if (!wholeValueIsVariable &&
311
- opts.throwWhenNonStringInsertedInString &&
312
- !isStr(resolvedValue)) {
313
- throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${string.slice(obj.headsEndAt, obj.tailsStartAt)} at path ${path}, it resolved into a non-string value, ${JSON.stringify(resolvedValue, null, 4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);
314
- }
315
- if (isBool(resolvedValue)) {
316
- if (opts.resolveToBoolIfAnyValuesContainBool) {
317
- finalRangesArr.wipe();
318
- if (!opts.resolveToFalseIfAnyValuesContainBool) {
319
- return resolvedValue;
320
- }
321
- return false;
322
- }
323
- resolvedValue = "";
324
- }
325
- else if (isNull(resolvedValue) && wholeValueIsVariable) {
326
- finalRangesArr.wipe();
327
- return resolvedValue;
328
- }
329
- else if (Array.isArray(resolvedValue)) {
330
- resolvedValue = String(resolvedValue.join(""));
331
- }
332
- else if (isNull(resolvedValue)) {
333
- resolvedValue = "";
334
- }
335
- else {
336
- resolvedValue = String(resolvedValue);
337
- }
338
- const newPath = path.includes(".")
339
- ? `${goLevelUp(path)}.${varName}`
340
- : varName;
341
- if (containsHeadsOrTails(resolvedValue, opts)) {
342
- const replacementVal = wrap(resolveString(
343
- input, resolvedValue, newPath, opts, breadCrumbPath), opts, dontWrapTheseVars, breadCrumbPath, newPath, varName.trim());
344
- if (isStr(replacementVal)) {
345
- finalRangesArr.push(obj.headsStartAt,
346
- obj.tailsEndAt,
347
- replacementVal);
348
- }
349
- }
350
- else {
351
- secretResolvedVarsStash[varName] = resolvedValue;
352
- const replacementVal = wrap(resolvedValue, opts, dontWrapTheseVars, breadCrumbPath, newPath, varName.trim());
353
- if (isStr(replacementVal)) {
354
- finalRangesArr.push(obj.headsStartAt,
355
- obj.tailsEndAt,
356
- replacementVal);
357
- }
358
- }
359
- }
360
- }
361
- return undefined;
362
- }
363
- let foundHeadsAndTails;
364
- try {
365
- foundHeadsAndTails = strFindHeadsTails(string, opts.heads, opts.tails, {
366
- source: "",
367
- throwWhenSomethingWrongIsDetected: false,
368
- });
369
- }
370
- catch (error) {
371
- throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${string}" at path ${path}, something wrong with heads and tails was detected! Here's the internal error message:\n${error}`);
372
- }
373
- let wholeValueIsVariable = false;
374
- if (foundHeadsAndTails.length === 1 &&
375
- rApply(string, [
376
- [foundHeadsAndTails[0].headsStartAt, foundHeadsAndTails[0].tailsEndAt],
377
- ]).trim() === "") {
378
- wholeValueIsVariable = true;
379
- }
380
- const temp1 = processHeadsAndTails(foundHeadsAndTails, false, wholeValueIsVariable);
381
- if (isBool(temp1)) {
382
- return temp1;
383
- }
384
- if (isNull(temp1)) {
385
- return temp1;
386
- }
387
- try {
388
- foundHeadsAndTails = strFindHeadsTails(string, opts.headsNoWrap, opts.tailsNoWrap, {
389
- source: "",
390
- throwWhenSomethingWrongIsDetected: false,
391
- });
392
- }
393
- catch (error) {
394
- throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${string}" at path ${path}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:\n${error}`);
395
- }
396
- if (foundHeadsAndTails.length === 1 &&
397
- rApply(string, [
398
- [foundHeadsAndTails[0].headsStartAt, foundHeadsAndTails[0].tailsEndAt],
399
- ]).trim() === "") {
400
- wholeValueIsVariable = true;
401
- }
402
- const temp2 = processHeadsAndTails(foundHeadsAndTails, true, wholeValueIsVariable);
403
- if (isBool(temp2)) {
404
- return temp2;
405
- }
406
- if (isNull(temp2)) {
407
- return temp2;
408
- }
409
- if (finalRangesArr && finalRangesArr.current()) {
410
- return rApply(string, finalRangesArr.current());
411
- }
412
- return string;
413
- }
414
- function jVar(input, originalOpts) {
415
- if (!arguments.length) {
416
- throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");
417
- }
418
- if (!isObj(input)) {
419
- throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(input) ? "array" : typeof input}`);
420
- }
421
- if (originalOpts && !isObj(originalOpts)) {
422
- throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(originalOpts) ? "array" : typeof originalOpts}`);
423
- }
424
- const opts = { ...defaults, ...originalOpts };
425
- if (!opts.dontWrapVars) {
426
- opts.dontWrapVars = [];
427
- }
428
- else if (!Array.isArray(opts.dontWrapVars)) {
429
- opts.dontWrapVars = arrayiffy(opts.dontWrapVars);
430
- }
431
- let culpritVal;
432
- let culpritIndex;
433
- if (opts.dontWrapVars.length > 0 &&
434
- !opts.dontWrapVars.every((el, idx) => {
435
- if (!isStr(el)) {
436
- culpritVal = el;
437
- culpritIndex = idx;
438
- return false;
439
- }
440
- return true;
441
- })) {
442
- throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in opts.dontWrapVars should be of a string type. Computer detected a value "${culpritVal}" at index ${culpritIndex}, which is not string but ${Array.isArray(culpritVal) ? "array" : typeof culpritVal}!`);
443
- }
444
- if (opts.heads === "") {
445
- throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! opts.heads are empty!");
446
- }
447
- if (opts.tails === "") {
448
- throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! opts.tails are empty!");
449
- }
450
- if (opts.lookForDataContainers && opts.dataContainerIdentifierTails === "") {
451
- throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! opts.dataContainerIdentifierTails is empty!");
452
- }
453
- if (opts.heads === opts.tails) {
454
- throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! opts.heads and opts.tails can't be equal!");
455
- }
456
- if (opts.heads === opts.headsNoWrap) {
457
- throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! opts.heads and opts.headsNoWrap can't be equal!");
458
- }
459
- if (opts.tails === opts.tailsNoWrap) {
460
- throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! opts.tails and opts.tailsNoWrap can't be equal!");
461
- }
462
- if (opts.headsNoWrap === "") {
463
- throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! opts.headsNoWrap is an empty string!");
464
- }
465
- if (opts.tailsNoWrap === "") {
466
- throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! opts.tailsNoWrap is an empty string!");
467
- }
468
- if (opts.headsNoWrap === opts.tailsNoWrap) {
469
- throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! opts.headsNoWrap and opts.tailsNoWrap can't be equal!");
470
- }
471
- let current;
472
- return traverse(input, (key, val, innerObj) => {
473
- if (existy(val) && containsHeadsOrTails(key, opts)) {
474
- throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!\nPlease check the following key: ${key}`);
475
- }
476
- if (val !== undefined) {
477
- current = val;
478
- }
479
- else {
480
- current = key;
481
- }
482
- if (current === "") {
483
- return current;
484
- }
485
- if ((opts.heads.length !== 0 &&
486
- trimIfString(current) === trimIfString(opts.heads)) ||
487
- (opts.tails.length !== 0 &&
488
- trimIfString(current) === trimIfString(opts.tails)) ||
489
- (opts.headsNoWrap.length !== 0 &&
490
- trimIfString(current) === trimIfString(opts.headsNoWrap)) ||
491
- (opts.tailsNoWrap.length !== 0 &&
492
- trimIfString(current) === trimIfString(opts.tailsNoWrap))) {
493
- if (!opts.noSingleMarkers) {
494
- return current;
495
- }
496
- throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${trimIfString(current)} which is equal to ${trimIfString(current) === trimIfString(opts.heads) ? "heads" : ""}${trimIfString(current) === trimIfString(opts.tails) ? "tails" : ""}${isStr(opts.headsNoWrap) &&
497
- trimIfString(current) === trimIfString(opts.headsNoWrap)
498
- ? "headsNoWrap"
499
- : ""}${isStr(opts.tailsNoWrap) &&
500
- trimIfString(current) === trimIfString(opts.tailsNoWrap)
501
- ? "tailsNoWrap"
502
- : ""}. If you wouldn't have set opts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${trimIfString(current)}) alone`);
503
- }
504
- if (isStr(current) && containsHeadsOrTails(current, opts)) {
505
- return resolveString(input, current, innerObj.path, opts);
506
- }
507
- return current;
508
- });
509
- }
510
-
511
- export { defaults, jVar, version };
13
+ `),c+=`${m}\u{1F4A5} ${t}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${r}" at path "${t}", we encountered a closed loop, the key is referencing itself."${c}`)}let n={},a=Array.from(i);a.push(t);let o=new B;function y(c,m,E){for(let b=0,O=c.length;b<O;b++){let f=c[b],p=r.slice(f.headsEndAt,f.tailsStartAt);if(p.length===0)o.push(f.headsStartAt,f.tailsEndAt);else if(q.call(n,p)&&u(n[p]))o.push(f.headsStartAt,f.tailsEndAt,n[p]);else{let s=Z(e,p.trim(),t,l);if(s===void 0)if(l.allowUnresolved===!0)s="";else if(typeof l.allowUnresolved=="string")s=l.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${r.slice(f.headsEndAt,f.tailsStartAt)}. We're at path: "${t}".`);if(!E&&l.throwWhenNonStringInsertedInString&&!u(s))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${r.slice(f.headsEndAt,f.tailsStartAt)} at path ${t}, it resolved into a non-string value, ${JSON.stringify(s,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(A(s)){if(l.resolveToBoolIfAnyValuesContainBool)return o.wipe(),l.resolveToFalseIfAnyValuesContainBool?!1:s;s=""}else{if(D(s)&&E)return o.wipe(),s;Array.isArray(s)?s=String(s.join("")):D(s)?s="":s=String(s)}let N=t.includes(".")?`${P(t)}.${p}`:p;if(T(s,l)){let V=J(R(e,s,N,l,a),l,m,a,N,p.trim());typeof V=="string"&&o.push(f.headsStartAt,f.tailsEndAt,V)}else{n[p]=s;let V=J(s,l,m,a,N,p.trim());typeof V=="string"&&o.push(f.headsStartAt,f.tailsEndAt,V)}}}}let h;try{h=I(r,l.heads,l.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${r}" at path ${t}, something wrong with heads and tails was detected! Here's the internal error message:
14
+ ${c}`)}let W=!1;h.length===1&&S(r,[[h[0].headsStartAt,h[0].tailsEndAt]]).trim()===""&&(W=!0);let $=y(h,!1,W);if(typeof $=="boolean"||$===null)return $;try{h=I(r,l.headsNoWrap,l.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${r}" at path ${t}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
15
+ ${c}`)}h.length===1&&S(r,[[h[0].headsStartAt,h[0].tailsEndAt]]).trim()===""&&(W=!0);let v=y(h,!0,W);return A(v)||D(v)?v:o?.current()?S(r,o.current()):r}function he(e,r){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!w(e))throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(e)?"array":typeof e}`);if(r&&!w(r))throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(r)?"array":typeof r}`);let t={...K,...r};t.dontWrapVars?Array.isArray(t.dontWrapVars)||(t.dontWrapVars=F(t.dontWrapVars)):t.dontWrapVars=[];let l,i;if(t.dontWrapVars.length>0&&!t.dontWrapVars.every((a,o)=>u(a)?!0:(l=a,i=o,!1)))throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in opts.dontWrapVars should be of a string type. Computer detected a value "${l}" at index ${i}, which is not string but ${Array.isArray(l)?"array":typeof l}!`);if(t.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! opts.heads are empty!");if(t.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! opts.tails are empty!");if(t.lookForDataContainers&&t.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! opts.dataContainerIdentifierTails is empty!");if(t.heads===t.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! opts.heads and opts.tails can't be equal!");if(t.heads===t.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! opts.heads and opts.headsNoWrap can't be equal!");if(t.tails===t.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! opts.tails and opts.tailsNoWrap can't be equal!");if(t.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! opts.headsNoWrap is an empty string!");if(t.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! opts.tailsNoWrap is an empty string!");if(t.headsNoWrap===t.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! opts.headsNoWrap and opts.tailsNoWrap can't be equal!");let n;return k(e,(a,o,y)=>{if(z(o)&&T(a,t))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
16
+ Please check the following key: ${a}`);if(o!==void 0?n=o:n=a,n==="")return n;if(t.heads.length!==0&&g(n)===g(t.heads)||t.tails.length!==0&&g(n)===g(t.tails)||t.headsNoWrap.length!==0&&g(n)===g(t.headsNoWrap)||t.tailsNoWrap.length!==0&&g(n)===g(t.tailsNoWrap)){if(!t.noSingleMarkers)return n;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${g(n)} which is equal to ${g(n)===g(t.heads)?"heads":""}${g(n)===g(t.tails)?"tails":""}${u(t.headsNoWrap)&&g(n)===g(t.headsNoWrap)?"headsNoWrap":""}${u(t.tailsNoWrap)&&g(n)===g(t.tailsNoWrap)?"tailsNoWrap":""}. If you wouldn't have set opts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${g(n)}) alone`)}return u(n)&&T(n,t)?R(e,n,y.path,t):n})}export{K as defaults,he as jVar,de as version};
@@ -1,114 +1,150 @@
1
1
  /**
2
2
  * @name json-variables
3
3
  * @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
4
- * @version 11.0.6
4
+ * @version 11.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/json-variables/}
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jsonVariables={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e,r){var n="__lodash_hash_undefined__",i=9007199254740991,s="[object Arguments]",o="[object Boolean]",a="[object Date]",l="[object Function]",u="[object GeneratorFunction]",f="[object Map]",h="[object Number]",c="[object Object]",g="[object Promise]",p="[object RegExp]",y="[object Set]",d="[object String]",m="[object Symbol]",w="[object WeakMap]",b="[object ArrayBuffer]",_="[object DataView]",T="[object Float32Array]",v="[object Float64Array]",O="[object Int8Array]",A="[object Int16Array]",$="[object Int32Array]",W="[object Uint8Array]",I="[object Uint8ClampedArray]",j="[object Uint16Array]",E="[object Uint32Array]",R=/\w*$/,S=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,H={};H[s]=H["[object Array]"]=H[b]=H[_]=H[o]=H[a]=H[T]=H[v]=H[O]=H[A]=H[$]=H[f]=H[h]=H[c]=H[p]=H[y]=H[d]=H[m]=H[W]=H[I]=H[j]=H[E]=!0,H["[object Error]"]=H[l]=H[w]=!1;var D="object"==typeof self&&self&&self.Object===Object&&self,x="object"==typeof t&&t&&t.Object===Object&&t||D||Function("return this")(),M=r&&!r.nodeType&&r,C=M&&e&&!e.nodeType&&e,B=C&&C.exports===M;function F(e,t){return e.set(t[0],t[1]),e}function k(e,t){return e.add(t),e}function J(e,t,r,n){var i=-1,s=e?e.length:0;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function P(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function V(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function q(e,t){return function(r){return e(t(r))}}function L(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var U,z=Array.prototype,G=Function.prototype,K=Object.prototype,Q=x["__core-js_shared__"],X=(U=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+U:"",Y=G.toString,Z=K.hasOwnProperty,ee=K.toString,te=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=B?x.Buffer:void 0,ne=x.Symbol,ie=x.Uint8Array,se=q(Object.getPrototypeOf,Object),oe=Object.create,ae=K.propertyIsEnumerable,le=z.splice,ue=Object.getOwnPropertySymbols,fe=re?re.isBuffer:void 0,he=q(Object.keys,Object),ce=Ce(x,"DataView"),ge=Ce(x,"Map"),pe=Ce(x,"Promise"),ye=Ce(x,"Set"),de=Ce(x,"WeakMap"),me=Ce(Object,"create"),we=Pe(ce),be=Pe(ge),_e=Pe(pe),Te=Pe(ye),ve=Pe(de),Oe=ne?ne.prototype:void 0,Ae=Oe?Oe.valueOf:void 0;function $e(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function We(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ie(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function je(e){this.__data__=new We(e)}function Ee(e,t){var r=qe(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Le(e)}(e)&&Z.call(e,"callee")&&(!ae.call(e,"callee")||ee.call(e)==s)}(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,i=!!n;for(var o in e)!t&&!Z.call(e,o)||i&&("length"==o||ke(o,n))||r.push(o);return r}function Re(e,t,r){var n=e[t];Z.call(e,t)&&Ve(n,r)&&(void 0!==r||t in e)||(e[t]=r)}function Se(e,t){for(var r=e.length;r--;)if(Ve(e[r][0],t))return r;return-1}function Ne(e,t,r,n,i,g,w){var S;if(n&&(S=g?n(e,i,g,w):n(e)),void 0!==S)return S;if(!Ge(e))return e;var N=qe(e);if(N){if(S=function(e){var t=e.length,r=e.constructor(t);t&&"string"==typeof e[0]&&Z.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!t)return function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(e,S)}else{var D=Fe(e),x=D==l||D==u;if(Ue(e))return function(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}(e,t);if(D==c||D==s||x&&!g){if(P(e))return g?e:{};if(S=function(e){return"function"!=typeof e.constructor||Je(e)?{}:(t=se(e),Ge(t)?oe(t):{});var t}(x?{}:e),!t)return function(e,t){return xe(e,Be(e),t)}(e,function(e,t){return e&&xe(t,Ke(t),e)}(S,e))}else{if(!H[D])return g?e:{};S=function(e,t,r,n){var i=e.constructor;switch(t){case b:return De(e);case o:case a:return new i(+e);case _:return function(e,t){var r=t?De(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,n);case T:case v:case O:case A:case $:case W:case I:case j:case E:return function(e,t){var r=t?De(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,n);case f:return function(e,t,r){return J(t?r(V(e),!0):V(e),F,new e.constructor)}(e,n,r);case h:case d:return new i(e);case p:return function(e){var t=new e.constructor(e.source,R.exec(e));return t.lastIndex=e.lastIndex,t}(e);case y:return function(e,t,r){return J(t?r(L(e),!0):L(e),k,new e.constructor)}(e,n,r);case m:return s=e,Ae?Object(Ae.call(s)):{}}var s}(e,D,Ne,t)}}w||(w=new je);var M=w.get(e);if(M)return M;if(w.set(e,S),!N)var C=r?function(e){return function(e,t,r){var n=t(e);return qe(e)?n:function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}(n,r(e))}(e,Ke,Be)}(e):Ke(e);return function(e,t){for(var r=-1,n=e?e.length:0;++r<n&&!1!==t(e[r],r,e););}(C||e,(function(i,s){C&&(i=e[s=i]),Re(S,s,Ne(i,t,r,n,s,e,w))})),S}function He(e){return!(!Ge(e)||(t=e,X&&X in t))&&(ze(e)||P(e)?te:S).test(Pe(e));var t}function De(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function xe(e,t,r,n){r||(r={});for(var i=-1,s=t.length;++i<s;){var o=t[i],a=n?n(r[o],e[o],o,r,e):void 0;Re(r,o,void 0===a?e[o]:a)}return r}function Me(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function Ce(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return He(r)?r:void 0}$e.prototype.clear=function(){this.__data__=me?me(null):{}},$e.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},$e.prototype.get=function(e){var t=this.__data__;if(me){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},$e.prototype.has=function(e){var t=this.__data__;return me?void 0!==t[e]:Z.call(t,e)},$e.prototype.set=function(e,t){return this.__data__[e]=me&&void 0===t?n:t,this},We.prototype.clear=function(){this.__data__=[]},We.prototype.delete=function(e){var t=this.__data__,r=Se(t,e);return!(r<0)&&(r==t.length-1?t.pop():le.call(t,r,1),!0)},We.prototype.get=function(e){var t=this.__data__,r=Se(t,e);return r<0?void 0:t[r][1]},We.prototype.has=function(e){return Se(this.__data__,e)>-1},We.prototype.set=function(e,t){var r=this.__data__,n=Se(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ie.prototype.clear=function(){this.__data__={hash:new $e,map:new(ge||We),string:new $e}},Ie.prototype.delete=function(e){return Me(this,e).delete(e)},Ie.prototype.get=function(e){return Me(this,e).get(e)},Ie.prototype.has=function(e){return Me(this,e).has(e)},Ie.prototype.set=function(e,t){return Me(this,e).set(e,t),this},je.prototype.clear=function(){this.__data__=new We},je.prototype.delete=function(e){return this.__data__.delete(e)},je.prototype.get=function(e){return this.__data__.get(e)},je.prototype.has=function(e){return this.__data__.has(e)},je.prototype.set=function(e,t){var r=this.__data__;if(r instanceof We){var n=r.__data__;if(!ge||n.length<199)return n.push([e,t]),this;r=this.__data__=new Ie(n)}return r.set(e,t),this};var Be=ue?q(ue,Object):function(){return[]},Fe=function(e){return ee.call(e)};function ke(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||N.test(e))&&e>-1&&e%1==0&&e<t}function Je(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||K)}function Pe(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(ce&&Fe(new ce(new ArrayBuffer(1)))!=_||ge&&Fe(new ge)!=f||pe&&Fe(pe.resolve())!=g||ye&&Fe(new ye)!=y||de&&Fe(new de)!=w)&&(Fe=function(e){var t=ee.call(e),r=t==c?e.constructor:void 0,n=r?Pe(r):void 0;if(n)switch(n){case we:return _;case be:return f;case _e:return g;case Te:return y;case ve:return w}return t});var qe=Array.isArray;function Le(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}(e.length)&&!ze(e)}var Ue=fe||function(){return!1};function ze(e){var t=Ge(e)?ee.call(e):"";return t==l||t==u}function Ge(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ke(e){return Le(e)?Ee(e):function(e){if(!Je(e))return he(e);var t=[];for(var r in Object(e))Z.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}e.exports=function(e){return Ne(e,!0,!0)}}(r,r.exports);var n=r.exports;var i,s,o=Object.prototype,a=Function.prototype.toString,l=o.hasOwnProperty,u=a.call(Object),f=o.toString,h=(i=Object.getPrototypeOf,s=Object,function(e){return i(s(e))});var c=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=f.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=h(e);if(null===t)return!0;var r=l.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&a.call(r)==u};
11
- /**
12
- * @name ast-monkey-util
13
- * @fileoverview Utility library of AST helper functions
14
- * @version 2.0.6
15
- * @author Roy Revelt, Codsen Ltd
16
- * @license MIT
17
- * {@link https://codsen.com/os/ast-monkey-util/}
18
- */function g(e){if(e.includes(".")){const t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let r=t-1;r--;)if("."===e[r])return e.slice(r+1,t)}return null}
19
- /**
20
- * @name ast-monkey-traverse
21
- * @fileoverview Utility library to traverse AST
22
- * @version 3.0.6
23
- * @author Roy Revelt, Codsen Ltd
24
- * @license MIT
25
- * {@link https://codsen.com/os/ast-monkey-traverse/}
26
- */function p(e,t){return function e(t,r,i,s){const o=n(t);let a;const l={depth:-1,path:"",...i};if(l.depth+=1,Array.isArray(o))for(let t=0,i=o.length;t<i&&!s.now;t++){const i=l.path?`${l.path}.${t}`:`${t}`;void 0!==o[t]?(l.parent=n(o),l.parentType="array",l.parentKey=g(i),a=e(r(o[t],void 0,{...l,path:i},s),r,{...l,path:i},s),Number.isNaN(a)&&t<o.length?(o.splice(t,1),t-=1):o[t]=a):o.splice(t,1)}else if(c(o))for(const t in o){if(s.now&&null!=t)break;const i=l.path?`${l.path}.${t}`:t;0===l.depth&&null!=t&&(l.topmostKey=t),l.parent=n(o),l.parentType="object",l.parentKey=g(i),a=e(r(t,o[t],{...l,path:i},s),r,{...l,path:i},s),Number.isNaN(a)?delete o[t]:o[t]=a}return o}(e,t,{},{now:!1})}const y=new Map,d=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter((e=>{if("string"!=typeof e){if(void 0===e)return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof e}' in the array`)}return!0}))},m=(e,t)=>{t={caseSensitive:!1,...t};const r=e+JSON.stringify(t);if(y.has(r))return y.get(r);const n="!"===e[0];n&&(e=e.slice(1)),e=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e).replace(/\\\*/g,"[\\s\\S]*");const i=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return i.negated=n,y.set(r,i),i};function w(e,t,r){return((e,t,r,n)=>{if(e=d(e,"inputs"),0===(t=d(t,"patterns")).length)return[];t=t.map((e=>m(e,r)));const{allPatterns:i}=r||{},s=[];for(const r of e){let e;const o=[...t].fill(!1);for(const[n,i]of t.entries())if(i.test(r)&&(o[n]=!0,e=!i.negated,!e))break;if(!(!1===e||void 0===e&&t.some((e=>!e.negated))||i&&o.some(((e,r)=>!e&&!t[r].negated)))&&(s.push(r),n))break}return s})(e,t,r,!0).length>0}var b={exports:{}};!function(e){e.exports=function(){var e=Object.prototype.toString;function t(e,t){return null!=e&&Object.prototype.hasOwnProperty.call(e,t)}function r(e){if(!e)return!0;if(s(e)&&0===e.length)return!0;if("string"!=typeof e){for(var r in e)if(t(e,r))return!1;return!0}return!1}function n(t){return e.call(t)}function i(e){return"object"==typeof e&&"[object Object]"===n(e)}var s=Array.isArray||function(t){return"[object Array]"===e.call(t)};function o(e){return"boolean"==typeof e||"[object Boolean]"===n(e)}function a(e){var t=parseInt(e);return t.toString()===e?t:e}function l(e){var n,l,u=function(e){return Object.keys(u).reduce((function(t,r){return"create"===r||"function"==typeof u[r]&&(t[r]=u[r].bind(u,e)),t}),{})};function f(e,t){if(n(e,t))return e[t]}function h(e,t,r,n){if("number"==typeof t&&(t=[t]),!t||0===t.length)return e;if("string"==typeof t)return h(e,t.split(".").map(a),r,n);var i=t[0],s=l(e,i);return 1===t.length?(void 0!==s&&n||(e[i]=r),s):(void 0===s&&(e[i]="number"==typeof t[1]?[]:{}),h(e[i],t.slice(1),r,n))}return n=(e=e||{}).includeInheritedProps?function(){return!0}:function(e,r){return"number"==typeof r&&Array.isArray(e)||t(e,r)},l=e.includeInheritedProps?function(e,t){"string"!=typeof t&&"number"!=typeof t&&(t=String(t));var r=f(e,t);if("__proto__"===t||"prototype"===t||"constructor"===t&&"function"==typeof r)throw new Error("For security reasons, object's magic properties cannot be set");return r}:function(e,t){return f(e,t)},u.has=function(r,n){if("number"==typeof n?n=[n]:"string"==typeof n&&(n=n.split(".")),!n||0===n.length)return!!r;for(var i=0;i<n.length;i++){var o=a(n[i]);if(!("number"==typeof o&&s(r)&&o<r.length||(e.includeInheritedProps?o in Object(r):t(r,o))))return!1;r=r[o]}return!0},u.ensureExists=function(e,t,r){return h(e,t,r,!0)},u.set=function(e,t,r,n){return h(e,t,r,n)},u.insert=function(e,t,r,n){var i=u.get(e,t);n=~~n,s(i)||u.set(e,t,i=[]),i.splice(n,0,r)},u.empty=function(e,t){var a,l;if(!r(t)&&null!=e&&(a=u.get(e,t))){if("string"==typeof a)return u.set(e,t,"");if(o(a))return u.set(e,t,!1);if("number"==typeof a)return u.set(e,t,0);if(s(a))a.length=0;else{if(!i(a))return u.set(e,t,null);for(l in a)n(a,l)&&delete a[l]}}},u.push=function(e,t){var r=u.get(e,t);s(r)||u.set(e,t,r=[]),r.push.apply(r,Array.prototype.slice.call(arguments,2))},u.coalesce=function(e,t,r){for(var n,i=0,s=t.length;i<s;i++)if(void 0!==(n=u.get(e,t[i])))return n;return r},u.get=function(e,t,r){if("number"==typeof t&&(t=[t]),!t||0===t.length)return e;if(null==e)return r;if("string"==typeof t)return u.get(e,t.split("."),r);var n=a(t[0]),i=l(e,n);return void 0===i?r:1===t.length?i:u.get(e[n],t.slice(1),r)},u.del=function(e,t){if("number"==typeof t&&(t=[t]),null==e)return e;if(r(t))return e;if("string"==typeof t)return u.del(e,t.split("."));var i=a(t[0]);return l(e,i),n(e,i)?1!==t.length?u.del(e[i],t.slice(1)):(s(e)?e.splice(i,1):delete e[i],e):e},u}var u=l();return u.create=l,u.withInheritedProps=l({includeInheritedProps:!0}),u}()}(b);var _=b.exports;
10
+ var jsonVariables=(()=>{var or=Object.create;var q=Object.defineProperty,lr=Object.defineProperties,fr=Object.getOwnPropertyDescriptor,ur=Object.getOwnPropertyDescriptors,gr=Object.getOwnPropertyNames,Ke=Object.getOwnPropertySymbols,cr=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$=(e,t)=>{for(var r in t||(t={}))Ue.call(t,r)&&me(e,r,t[r]);if(Ke)for(var r of Ke(t))hr.call(t,r)&&me(e,r,t[r]);return e},K=(e,t)=>lr(e,ur(t)),Ge=e=>q(e,"__esModule",{value:!0});var we=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pr=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},ze=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gr(t))!Ue.call(e,o)&&(r||o!=="default")&&q(e,o,{get:()=>t[o],enumerable:!(i=fr(t,o))||i.enumerable});return e},U=(e,t)=>ze(Ge(q(e!=null?or(cr(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),dr=(e=>(t,r)=>e&&e.get(t)||(r=ze(Ge({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var be=(e,t,r)=>(me(e,typeof t!="symbol"?t+"":t,r),r);var Ce=we((Y,F)=>{var yr=200,Ye="__lodash_hash_undefined__",Xe=9007199254740991,Te="[object Arguments]",mr="[object Array]",Ze="[object Boolean]",Qe="[object Date]",wr="[object Error]",$e="[object Function]",et="[object GeneratorFunction]",te="[object Map]",tt="[object Number]",ve="[object Object]",rt="[object Promise]",nt="[object RegExp]",re="[object Set]",it="[object String]",st="[object Symbol]",Oe="[object WeakMap]",at="[object ArrayBuffer]",ne="[object DataView]",ot="[object Float32Array]",lt="[object Float64Array]",ft="[object Int8Array]",ut="[object Int16Array]",gt="[object Int32Array]",ct="[object Uint8Array]",ht="[object Uint8ClampedArray]",pt="[object Uint16Array]",dt="[object Uint32Array]",br=/[\\^$.*+?()[\]{}|]/g,Tr=/\w*$/,$r=/^\[object .+?Constructor\]$/,vr=/^(?:0|[1-9]\d*)$/,v={};v[Te]=v[mr]=v[at]=v[ne]=v[Ze]=v[Qe]=v[ot]=v[lt]=v[ft]=v[ut]=v[gt]=v[te]=v[tt]=v[ve]=v[nt]=v[re]=v[it]=v[st]=v[ct]=v[ht]=v[pt]=v[dt]=!0;v[wr]=v[$e]=v[Oe]=!1;var Or=typeof global=="object"&&global&&global.Object===Object&&global,_r=typeof self=="object"&&self&&self.Object===Object&&self,N=Or||_r||Function("return this")(),yt=typeof Y=="object"&&Y&&!Y.nodeType&&Y,mt=yt&&typeof F=="object"&&F&&!F.nodeType&&F,Ar=mt&&mt.exports===yt;function Ir(e,t){return e.set(t[0],t[1]),e}function Er(e,t){return e.add(t),e}function Sr(e,t){for(var r=-1,i=e?e.length:0;++r<i&&t(e[r],r,e)!==!1;);return e}function Wr(e,t){for(var r=-1,i=t.length,o=e.length;++r<i;)e[o+r]=t[r];return e}function wt(e,t,r,i){var o=-1,n=e?e.length:0;for(i&&n&&(r=e[++o]);++o<n;)r=t(r,e[o],o,e);return r}function Dr(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}function Nr(e,t){return e==null?void 0:e[t]}function bt(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Tt(e){var t=-1,r=Array(e.size);return e.forEach(function(i,o){r[++t]=[o,i]}),r}function _e(e,t){return function(r){return e(t(r))}}function $t(e){var t=-1,r=Array(e.size);return e.forEach(function(i){r[++t]=i}),r}var xr=Array.prototype,Rr=Function.prototype,ie=Object.prototype,Ae=N["__core-js_shared__"],vt=function(){var e=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ot=Rr.toString,R=ie.hasOwnProperty,se=ie.toString,Cr=RegExp("^"+Ot.call(R).replace(br,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_t=Ar?N.Buffer:void 0,At=N.Symbol,It=N.Uint8Array,Vr=_e(Object.getPrototypeOf,Object),jr=Object.create,Hr=ie.propertyIsEnumerable,Mr=xr.splice,Et=Object.getOwnPropertySymbols,Pr=_t?_t.isBuffer:void 0,Jr=_e(Object.keys,Object),Ie=B(N,"DataView"),G=B(N,"Map"),Ee=B(N,"Promise"),Se=B(N,"Set"),We=B(N,"WeakMap"),z=B(Object,"create"),Br=M(Ie),Fr=M(G),kr=M(Ee),Lr=M(Se),qr=M(We),St=At?At.prototype:void 0,Wt=St?St.valueOf:void 0;function j(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function Kr(){this.__data__=z?z(null):{}}function Ur(e){return this.has(e)&&delete this.__data__[e]}function Gr(e){var t=this.__data__;if(z){var r=t[e];return r===Ye?void 0:r}return R.call(t,e)?t[e]:void 0}function zr(e){var t=this.__data__;return z?t[e]!==void 0:R.call(t,e)}function Yr(e,t){var r=this.__data__;return r[e]=z&&t===void 0?Ye:t,this}j.prototype.clear=Kr;j.prototype.delete=Ur;j.prototype.get=Gr;j.prototype.has=zr;j.prototype.set=Yr;function x(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function Xr(){this.__data__=[]}function Zr(e){var t=this.__data__,r=ae(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Mr.call(t,r,1),!0}function Qr(e){var t=this.__data__,r=ae(t,e);return r<0?void 0:t[r][1]}function en(e){return ae(this.__data__,e)>-1}function tn(e,t){var r=this.__data__,i=ae(r,e);return i<0?r.push([e,t]):r[i][1]=t,this}x.prototype.clear=Xr;x.prototype.delete=Zr;x.prototype.get=Qr;x.prototype.has=en;x.prototype.set=tn;function P(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function rn(){this.__data__={hash:new j,map:new(G||x),string:new j}}function nn(e){return oe(this,e).delete(e)}function sn(e){return oe(this,e).get(e)}function an(e){return oe(this,e).has(e)}function on(e,t){return oe(this,e).set(e,t),this}P.prototype.clear=rn;P.prototype.delete=nn;P.prototype.get=sn;P.prototype.has=an;P.prototype.set=on;function J(e){this.__data__=new x(e)}function ln(){this.__data__=new x}function fn(e){return this.__data__.delete(e)}function un(e){return this.__data__.get(e)}function gn(e){return this.__data__.has(e)}function cn(e,t){var r=this.__data__;if(r instanceof x){var i=r.__data__;if(!G||i.length<yr-1)return i.push([e,t]),this;r=this.__data__=new P(i)}return r.set(e,t),this}J.prototype.clear=ln;J.prototype.delete=fn;J.prototype.get=un;J.prototype.has=gn;J.prototype.set=cn;function hn(e,t){var r=xe(e)||Hn(e)?Dr(e.length,String):[],i=r.length,o=!!i;for(var n in e)(t||R.call(e,n))&&!(o&&(n=="length"||Rn(n,i)))&&r.push(n);return r}function Dt(e,t,r){var i=e[t];(!(R.call(e,t)&&Ct(i,r))||r===void 0&&!(t in e))&&(e[t]=r)}function ae(e,t){for(var r=e.length;r--;)if(Ct(e[r][0],t))return r;return-1}function pn(e,t){return e&&Nt(t,Re(t),e)}function De(e,t,r,i,o,n,l){var s;if(i&&(s=n?i(e,o,n,l):i(e)),s!==void 0)return s;if(!le(e))return e;var h=xe(e);if(h){if(s=Dn(e),!t)return En(e,s)}else{var a=H(e),g=a==$e||a==et;if(Pn(e))return Tn(e,t);if(a==ve||a==Te||g&&!n){if(bt(e))return n?e:{};if(s=Nn(g?{}:e),!t)return Sn(e,pn(s,e))}else{if(!v[a])return n?e:{};s=xn(e,a,De,t)}}l||(l=new J);var c=l.get(e);if(c)return c;if(l.set(e,s),!h)var T=r?Wn(e):Re(e);return Sr(T||e,function(m,u){T&&(u=m,m=e[u]),Dt(s,u,De(m,t,r,i,u,e,l))}),s}function dn(e){return le(e)?jr(e):{}}function yn(e,t,r){var i=t(e);return xe(e)?i:Wr(i,r(e))}function mn(e){return se.call(e)}function wn(e){if(!le(e)||Vn(e))return!1;var t=jt(e)||bt(e)?Cr:$r;return t.test(M(e))}function bn(e){if(!Rt(e))return Jr(e);var t=[];for(var r in Object(e))R.call(e,r)&&r!="constructor"&&t.push(r);return t}function Tn(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function Ne(e){var t=new e.constructor(e.byteLength);return new It(t).set(new It(e)),t}function $n(e,t){var r=t?Ne(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function vn(e,t,r){var i=t?r(Tt(e),!0):Tt(e);return wt(i,Ir,new e.constructor)}function On(e){var t=new e.constructor(e.source,Tr.exec(e));return t.lastIndex=e.lastIndex,t}function _n(e,t,r){var i=t?r($t(e),!0):$t(e);return wt(i,Er,new e.constructor)}function An(e){return Wt?Object(Wt.call(e)):{}}function In(e,t){var r=t?Ne(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function En(e,t){var r=-1,i=e.length;for(t||(t=Array(i));++r<i;)t[r]=e[r];return t}function Nt(e,t,r,i){r||(r={});for(var o=-1,n=t.length;++o<n;){var l=t[o],s=i?i(r[l],e[l],l,r,e):void 0;Dt(r,l,s===void 0?e[l]:s)}return r}function Sn(e,t){return Nt(e,xt(e),t)}function Wn(e){return yn(e,Re,xt)}function oe(e,t){var r=e.__data__;return Cn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function B(e,t){var r=Nr(e,t);return wn(r)?r:void 0}var xt=Et?_e(Et,Object):Fn,H=mn;(Ie&&H(new Ie(new ArrayBuffer(1)))!=ne||G&&H(new G)!=te||Ee&&H(Ee.resolve())!=rt||Se&&H(new Se)!=re||We&&H(new We)!=Oe)&&(H=function(e){var t=se.call(e),r=t==ve?e.constructor:void 0,i=r?M(r):void 0;if(i)switch(i){case Br:return ne;case Fr:return te;case kr:return rt;case Lr:return re;case qr:return Oe}return t});function Dn(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&R.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function Nn(e){return typeof e.constructor=="function"&&!Rt(e)?dn(Vr(e)):{}}function xn(e,t,r,i){var o=e.constructor;switch(t){case at:return Ne(e);case Ze:case Qe:return new o(+e);case ne:return $n(e,i);case ot:case lt:case ft:case ut:case gt:case ct:case ht:case pt:case dt:return In(e,i);case te:return vn(e,i,r);case tt:case it:return new o(e);case nt:return On(e);case re:return _n(e,i,r);case st:return An(e)}}function Rn(e,t){return t=t==null?Xe:t,!!t&&(typeof e=="number"||vr.test(e))&&e>-1&&e%1==0&&e<t}function Cn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Vn(e){return!!vt&&vt in e}function Rt(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||ie;return e===r}function M(e){if(e!=null){try{return Ot.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function jn(e){return De(e,!0,!0)}function Ct(e,t){return e===t||e!==e&&t!==t}function Hn(e){return Mn(e)&&R.call(e,"callee")&&(!Hr.call(e,"callee")||se.call(e)==Te)}var xe=Array.isArray;function Vt(e){return e!=null&&Jn(e.length)&&!jt(e)}function Mn(e){return Bn(e)&&Vt(e)}var Pn=Pr||kn;function jt(e){var t=le(e)?se.call(e):"";return t==$e||t==et}function Jn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Xe}function le(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Bn(e){return!!e&&typeof e=="object"}function Re(e){return Vt(e)?hn(e):bn(e)}function Fn(){return[]}function kn(){return!1}F.exports=jn});var Ve=we((Ai,Pt)=>{var Ln="[object Object]";function qn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Kn(e,t){return function(r){return e(t(r))}}var Un=Function.prototype,Ht=Object.prototype,Mt=Un.toString,Gn=Ht.hasOwnProperty,zn=Mt.call(Object),Yn=Ht.toString,Xn=Kn(Object.getPrototypeOf,Object);function Zn(e){return!!e&&typeof e=="object"}function Qn(e){if(!Zn(e)||Yn.call(e)!=Ln||qn(e))return!1;var t=Xn(e);if(t===null)return!0;var r=Gn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Mt.call(r)==zn}Pt.exports=Qn});var kt=we((Ft,ce)=>{(function(e,t){"use strict";typeof ce=="object"&&typeof ce.exports=="object"?ce.exports=t():typeof define=="function"&&define.amd?define([],t):e.objectPath=t()})(Ft,function(){"use strict";var e=Object.prototype.toString;function t(g,c){return g==null?!1:Object.prototype.hasOwnProperty.call(g,c)}function r(g){if(!g||n(g)&&g.length===0)return!0;if(typeof g!="string"){for(var c in g)if(t(g,c))return!1;return!0}return!1}function i(g){return e.call(g)}function o(g){return typeof g=="object"&&i(g)==="[object Object]"}var n=Array.isArray||function(g){return e.call(g)==="[object Array]"};function l(g){return typeof g=="boolean"||i(g)==="[object Boolean]"}function s(g){var c=parseInt(g);return c.toString()===g?c:g}function h(g){g=g||{};var c=function(d){return Object.keys(c).reduce(function(f,p){return p==="create"||typeof c[p]=="function"&&(f[p]=c[p].bind(c,d)),f},{})},T;g.includeInheritedProps?T=function(){return!0}:T=function(d,f){return typeof f=="number"&&Array.isArray(d)||t(d,f)};function m(d,f){if(T(d,f))return d[f]}var u;g.includeInheritedProps?u=function(d,f){typeof f!="string"&&typeof f!="number"&&(f=String(f));var p=m(d,f);if(f==="__proto__"||f==="prototype"||f==="constructor"&&typeof p=="function")throw new Error("For security reasons, object's magic properties cannot be set");return p}:u=function(d,f){return m(d,f)};function y(d,f,p,w){if(typeof f=="number"&&(f=[f]),!f||f.length===0)return d;if(typeof f=="string")return y(d,f.split(".").map(s),p,w);var b=f[0],O=u(d,b);return f.length===1?((O===void 0||!w)&&(d[b]=p),O):(O===void 0&&(typeof f[1]=="number"?d[b]=[]:d[b]={}),y(d[b],f.slice(1),p,w))}return c.has=function(d,f){if(typeof f=="number"?f=[f]:typeof f=="string"&&(f=f.split(".")),!f||f.length===0)return!!d;for(var p=0;p<f.length;p++){var w=s(f[p]);if(typeof w=="number"&&n(d)&&w<d.length||(g.includeInheritedProps?w in Object(d):t(d,w)))d=d[w];else return!1}return!0},c.ensureExists=function(d,f,p){return y(d,f,p,!0)},c.set=function(d,f,p,w){return y(d,f,p,w)},c.insert=function(d,f,p,w){var b=c.get(d,f);w=~~w,n(b)||(b=[],c.set(d,f,b)),b.splice(w,0,p)},c.empty=function(d,f){if(!r(f)&&d!=null){var p,w;if(!!(p=c.get(d,f))){if(typeof p=="string")return c.set(d,f,"");if(l(p))return c.set(d,f,!1);if(typeof p=="number")return c.set(d,f,0);if(n(p))p.length=0;else if(o(p))for(w in p)T(p,w)&&delete p[w];else return c.set(d,f,null)}}},c.push=function(d,f){var p=c.get(d,f);n(p)||(p=[],c.set(d,f,p)),p.push.apply(p,Array.prototype.slice.call(arguments,2))},c.coalesce=function(d,f,p){for(var w,b=0,O=f.length;b<O;b++)if((w=c.get(d,f[b]))!==void 0)return w;return p},c.get=function(d,f,p){if(typeof f=="number"&&(f=[f]),!f||f.length===0)return d;if(d==null)return p;if(typeof f=="string")return c.get(d,f.split("."),p);var w=s(f[0]),b=u(d,w);return b===void 0?p:f.length===1?b:c.get(d[w],f.slice(1),p)},c.del=function(f,p){if(typeof p=="number"&&(p=[p]),f==null||r(p))return f;if(typeof p=="string")return c.del(f,p.split("."));var w=s(p[0]);if(u(f,w),!T(f,w))return f;if(p.length===1)n(f)?f.splice(w,1):delete f[w];else return c.del(f[w],p.slice(1));return f},c}var a=h();return a.create=h,a.withInheritedProps=h({includeInheritedProps:!0}),a})});var Oi={};pr(Oi,{defaults:()=>rr,jVar:()=>vi,version:()=>pi});var fe=U(Ce(),1),Jt=U(Ve(),1);function ei(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let r=t-1;r--;)if(e[r]===".")return e.slice(r+1,t)}return null}var je=ei;function ue(e,t){let r={now:!1};function i(o,n,l,s){let h=(0,fe.default)(o),a,g=$({depth:-1,path:""},l);if(g.depth+=1,Array.isArray(h))for(let c=0,T=h.length;c<T&&!s.now;c++){let m=g.path?`${g.path}.${c}`:`${c}`;h[c]!==void 0?(g.parent=(0,fe.default)(h),g.parentType="array",g.parentKey=je(m),a=i(n(h[c],void 0,K($({},g),{path:m}),s),n,K($({},g),{path:m}),s),Number.isNaN(a)&&c<h.length?(h.splice(c,1),c-=1):h[c]=a):h.splice(c,1)}else if((0,Jt.default)(h))for(let c in h){if(s.now&&c!=null)break;let T=g.path?`${g.path}.${c}`:c;g.depth===0&&c!=null&&(g.topmostKey=c),g.parent=(0,fe.default)(h),g.parentType="object",g.parentKey=je(T),a=i(n(c,h[c],K($({},g),{path:T}),s),n,K($({},g),{path:T}),s),Number.isNaN(a)?delete h[c]:h[c]=a}return h}return i(e,t,{},r)}function He(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Me=new Map,Bt=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(r=>{if(typeof r!="string"){if(typeof r=="undefined")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},ti=(e,t)=>{t=$({caseSensitive:!1},t);let r=e+JSON.stringify(t);if(Me.has(r))return Me.get(r);let i=e[0]==="!";i&&(e=e.slice(1)),e=He(e).replace(/\\\*/g,"[\\s\\S]*");let o=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return o.negated=i,Me.set(r,o),o},ri=(e,t,r,i)=>{if(e=Bt(e,"inputs"),t=Bt(t,"patterns"),t.length===0)return[];t=t.map(l=>ti(l,r));let{allPatterns:o}=r||{},n=[];for(let l of e){let s,h=[...t].fill(!1);for(let[a,g]of t.entries())if(g.test(l)&&(h[a]=!0,s=!g.negated,!s))break;if(!(s===!1||s===void 0&&t.some(a=>!a.negated)||o&&h.some((a,g)=>!a&&!t[g].negated))&&(n.push(l),i))break}return n};function ge(e,t,r){return ri(e,t,r,!0).length>0}var D=U(kt(),1);function I(e){return typeof e=="string"?e.length?[e]:[]:e}function Lt(e){return e&&typeof e=="object"&&!Array.isArray(e)}function he(e){return typeof e=="string"}var qt={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},ni=e=>e+1;function ii(e,t,r,i,o=!1,n=ni){let l=typeof r=="function"?r():r;if(+t<0&&o&&l==="EOL")return l;let s=$($({},qt),i);if(t>=e.length&&!o)return!1;let h=o?1:r.length,a=0,g=!1,c=!1,T=!1,m=s.maxMismatches,u=t,y=!1,d=!1,f=!1;function p(){return a===1&&m<s.maxMismatches-1}for(;e[u];){let w=n(u);if(s.trimBeforeMatching&&e[u].trim()===""){if(!e[w]&&o&&r==="EOL")return!0;u=n(u);continue}if(s&&!s.i&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.includes(e[u])||(s==null?void 0:s.i)&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.map(O=>O.toLowerCase()).includes(e[u].toLowerCase())){if(o&&r==="EOL"&&!e[w])return!0;u=n(u);continue}let b=w>u?r[r.length-h]:r[h-1];if(!s.i&&e[u]===b||s.i&&e[u].toLowerCase()===b.toLowerCase()){if(y||(y=!0),T||(T=!0),h===r.length){if(d=!0,m!==s.maxMismatches)return!1}else h===1&&(f=!0);if(h-=1,a++,p())return!1;if(!h)return a!==r.length||m===s.maxMismatches||!g?u:!1}else if(!g&&!a&&(g=!0),s.maxMismatches&&m&&u){m-=1;for(let O=0;O<=m;O++){let E=w>u?r[r.length-h+1+O]:r[h-2-O],ye=e[n(u)];if(E&&(!s.i&&e[u]===E||s.i&&e[u].toLowerCase()===E.toLowerCase())&&(!s.firstMustMatch||h!==r.length)){if(a++,p())return!1;h-=2,y=!0;break}else if(ye&&E&&(!s.i&&ye===E||s.i&&ye.toLowerCase()===E.toLowerCase())&&(!s.firstMustMatch||h!==r.length)){if(!a&&!s.hungry)return!1;h-=1,y=!0;break}else if(E===void 0&&m>=0&&y&&(!s.firstMustMatch||d)&&(!s.lastMustMatch||f))return u}y||(c=u)}else return u===0&&h===1&&!s.lastMustMatch&&T?0:!1;if(c!==!1&&c!==u&&(c=!1),h<1)return u;u=n(u)}if(h>0)return o&&l==="EOL"?!0:s&&s.maxMismatches>=h&&T?c||0:!1}function Kt(e,t,r,i,o){if(Lt(o)&&Object.prototype.hasOwnProperty.call(o,"trimBeforeMatching")&&typeof o.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(o.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let n=$($({},qt),o);if(typeof n.trimCharsBeforeMatching=="string"&&(n.trimCharsBeforeMatching=I(n.trimCharsBeforeMatching)),n.trimCharsBeforeMatching=n.trimCharsBeforeMatching.map(g=>he(g)?g:String(g)),!he(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
11
+ ${JSON.stringify(r,null,4)}`);let l,s;if(he(i))l=[i];else if(Array.isArray(i))l=i;else if(!i)l=i;else if(typeof i=="function")l=[],l.push(i);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof i}, equal to:
12
+ ${JSON.stringify(i,null,4)}`);if(o&&!Lt(o))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof o}", and equal to:
13
+ ${JSON.stringify(o,null,4)}`);let h=0,a="";if((n==null?void 0:n.trimCharsBeforeMatching)&&n.trimCharsBeforeMatching.some((g,c)=>g.length>1?(h=c,a=g,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${h} is longer than 1 character, ${a.length} (equals to ${a}). Please split it into separate characters and put into array as separate elements.`);if(!l||!Array.isArray(l)||Array.isArray(l)&&!l.length||Array.isArray(l)&&l.length===1&&he(l[0])&&!l[0].trim()){if(typeof n.cb=="function"){let c,T=r;if((e==="matchLeftIncl"||e==="matchRight")&&(T+=1),e[5]==="L")for(let d=T;d--;){let f=t[d];if((!n.trimBeforeMatching||n.trimBeforeMatching&&f!==void 0&&f.trim())&&(!n.trimCharsBeforeMatching||!n.trimCharsBeforeMatching.length||f!==void 0&&!n.trimCharsBeforeMatching.includes(f))){c=d;break}}else if(e.startsWith("matchRight"))for(let d=T;d<t.length;d++){let f=t[d];if((!n.trimBeforeMatching||n.trimBeforeMatching&&f.trim())&&(!n.trimCharsBeforeMatching||!n.trimCharsBeforeMatching.length||!n.trimCharsBeforeMatching.includes(f))){c=d;break}}if(c===void 0)return!1;let m=t[c],u=c+1,y="";return u&&u>0&&(y=t.slice(0,u)),e[5]==="L"||c&&c>0&&(y=t.slice(c)),n.cb(m,y,c)}let g="";throw o||(g=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${g}`)}for(let g=0,c=l.length;g<c;g++){s=typeof l[g]=="function";let T=l[g],m,u,y="",d=r;e==="matchRight"?d+=1:e==="matchLeft"&&(d-=1);let f=ii(t,d,T,n,s,p=>e[5]==="L"?p-1:p+1);if(f&&s&&typeof T=="function"&&T()==="EOL")return T()&&(n.cb?n.cb(m,y,u):!0)?T():!1;if(Number.isInteger(f)&&(u=e.startsWith("matchLeft")?f-1:f+1,e[5]==="L"?y=t.slice(0,f):y=t.slice(u)),u<0&&(u=void 0),t[u]&&(m=t[u]),Number.isInteger(f)&&(n.cb?n.cb(m,y,u):!0))return T}return!1}function k(e,t,r,i){return Kt("matchLeftIncl",e,t,r,i)}function W(e,t,r,i){return Kt("matchRightIncl",e,t,r,i)}function si(e){return e&&typeof e=="object"&&!Array.isArray(e)}function S(e){return typeof e=="string"}var Ut={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function Pe(e,t,r,i){if(i&&!si(i))throw new TypeError(`string-find-heads-tails: [THROW_ID_01] the fourth input argument, an Optional Options Object, must be a plain object! Currently it's equal to: ${i} (type: ${typeof i})`);let o=$($({},Ut),i);if(typeof o.fromIndex=="string"&&/^\d*$/.test(o.fromIndex))o.fromIndex=Number(o.fromIndex);else if(!Number.isInteger(o.fromIndex)||o.fromIndex<0)throw new TypeError(`${o.source} [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ${o.fromIndex}`);if(!S(e)||e.length===0){if(o.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_02] the first input argument, input string, must be a non-zero-length string! Currently it's: ${typeof e}, equal to: ${e}`)}let n,l;if(typeof t!="string"&&!Array.isArray(t)){if(o.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_03] the second input argument, heads, must be either a string or an array of strings! Currently it's: ${typeof t}, equal to:
14
+ ${JSON.stringify(t,null,4)}`)}else if(typeof t=="string")if(t.length===0){if(o.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_04] the second input argument, heads, must be a non-empty string! Currently it's empty.")}else t=I(t);else if(Array.isArray(t))if(t.length===0){if(o.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_05] the second input argument, heads, must be a non-empty array and contain at least one string! Currently it's empty.")}else if(t.every((u,y)=>(n=u,l=y,S(u)))){if(!t.every((u,y)=>(l=y,S(u)&&u.length>0&&u.trim()!=="")))if(o.relaxedAPI){if(t=t.filter(u=>S(u)&&u.length>0),t.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_07] the second input argument, heads, should not contain empty strings! For example, there's one detected at index ${l} of heads array:
15
+ ${JSON.stringify(t,null,4)}.`)}else if(o.relaxedAPI){if(t=t.filter(u=>S(u)&&u.length>0),t.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_06] the second input argument, heads, contains non-string elements! For example, element at ${l}th index is ${typeof n}, equal to:
16
+ ${JSON.stringify(n,null,4)}. Whole heads array looks like:
17
+ ${JSON.stringify(t,null,4)}`);if(!S(r)&&!Array.isArray(r)){if(o.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_08] the third input argument, tails, must be either a string or an array of strings! Currently it's: ${typeof r}, equal to:
18
+ ${JSON.stringify(r,null,4)}`)}else if(S(r))if(r.length===0){if(o.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_09] the third input argument, tails, must be a non-empty string! Currently it's empty.")}else r=I(r);else if(Array.isArray(r))if(r.length===0){if(o.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_10] the third input argument, tails, must be a non-empty array and contain at least one string! Currently it's empty.")}else if(r.every((u,y)=>(n=u,l=y,S(u)))){if(!r.every((u,y)=>(l=y,S(u)&&u.length>0&&u.trim()!=="")))if(o.relaxedAPI){if(r=r.filter(u=>S(u)&&u.length>0),r.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_12] the third input argument, tails, should not contain empty strings! For example, there's one detected at index ${l}. Whole tails array is equal to:
19
+ ${JSON.stringify(r,null,4)}`)}else if(o.relaxedAPI){if(r=r.filter(u=>S(u)&&u.length>0),r.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_11] the third input argument, tails, contains non-string elements! For example, element at ${l}th index is ${typeof n}, equal to:
20
+ ${JSON.stringify(n,null,4)}. Whole tails array is equal to:
21
+ ${JSON.stringify(r,null,4)}`);let s=o.source===Ut.source;if(o.throwWhenSomethingWrongIsDetected&&!o.allowWholeValueToBeOnlyHeadsOrTails){if(I(t).includes(e))throw new Error(`${o.source}${s?": [THROW_ID_16]":""} the whole input string can't be equal to ${S(t)?"":"one of "}heads (${e})!`);if(I(r).includes(e))throw new Error(`${o.source}${s?": [THROW_ID_17]":""} the whole input string can't be equal to ${S(r)?"":"one of "}tails (${e})!`)}let h=t.concat(r).map(u=>u.charAt(0)).reduce((u,y)=>y.charCodeAt(0)>u[1]?[u[0],y.charCodeAt(0)]:y.charCodeAt(0)<u[0]?[y.charCodeAt(0),u[1]]:u,[t[0].charCodeAt(0),t[0].charCodeAt(0)]),a=[],g=!1,c={},T="",m;for(let u=o.fromIndex,y=e.length;u<y;u++){let d=e[u].charCodeAt(0);if(d<=h[1]&&d>=h[0]){let f=W(e,u,t);if(f&&o.matchHeadsAndTailsStrictlyInPairsByTheirOrder){for(let w=t.length;w--;)if(t[w]===f){m=w;break}}if(typeof f=="string")if(g){if(o.throwWhenSomethingWrongIsDetected)throw new TypeError(`${o.source}${s?": [THROW_ID_19]":""} When processing "${e}", we found heads (${e.slice(u,u+f.length)}) starting at character with index number "${u}" and there was another set of heads before it! Generally speaking, there should be "heads-tails-heads-tails", not "heads-heads-tails"!
22
+ We're talking about the area of the code:
23
+
24
+
25
+ --------------------------------------starts
26
+ ${e.slice(Math.max(u-200,0),u)}
27
+ ${`\x1B[${33}m------->\x1B[${39}m`} ${`\x1B[${31}m${e.slice(u,u+f.length)}\x1B[${39}m`} \x1B[${33}m<-------\x1B[${39}m
28
+ ${e.slice(u+f.length,Math.min(y,u+200))}
29
+ --------------------------------------ends
30
+
31
+
32
+ To turn off this error being thrown, set opts.throwWhenSomethingWrongIsDetected to Boolean false.`)}else{c={},c.headsStartAt=u,c.headsEndAt=u+f.length,g=!0,u+=f.length-1,T&&(T="");continue}let p=W(e,u,r);if(g&&p&&o.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&m!==void 0&&r[m]!==void 0&&r[m]!==p){let w;for(let b=r.length;b--;)if(r[b]===p){w=b;break}throw new TypeError(`${o.source}${s?": [THROW_ID_20]":""} When processing "${e}", we had "opts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (${t[m]}) but the tails the followed it were not of the same index, ${m} (${r[m]}) but ${w} (${p}).`)}if(typeof p=="string")if(g){c.tailsStartAt=u,c.tailsEndAt=u+p.length,a.push(c),c={},g=!1,u+=p.length-1;continue}else o.throwWhenSomethingWrongIsDetected&&(T=`${o.source}${s?": [THROW_ID_21]":""} When processing "${e}", we found tails (${e.slice(u,u+p.length)}) starting at character with index number "${u}" but there were no heads preceding it. That's very naughty!`)}if(o.throwWhenSomethingWrongIsDetected&&u===y-1){if(Object.keys(c).length!==0)throw new TypeError(`${o.source}${s?": [THROW_ID_22]":""} When processing "${e}", we reached the end of the string and yet didn't find any tails (${JSON.stringify(r,null,4)}) to match the last detected heads (${e.slice(c.headsStartAt,c.headsEndAt)})!`);if(T)throw new Error(T)}}return a}var Je=U(Ce(),1);function Be(e,t,r){let i;r!==void 0&&(i=Array.isArray(r)?(0,Je.default)(r):[(0,Je.default)(r)]);let o=[],n=ue(e,(l,s,h)=>{let a=s!==void 0?s:l;if(s!==void 0&&ge(l,t,{caseSensitive:!0})){if(i===void 0)o.push({val:s,path:h.path});else if(i.length)return i.shift()}return a});return i===void 0?o:n}function pe(e,t=1){let r="\xA0";function i(n){return Array.from(n).reverse().join("")}function o(n,l,s){let h=s?`
33
+ `:"\r",a=s?"\r":`
34
+ `;if(!n)return n;let g=0,c=0,T="";for(let m=0,u=n.length;m<u;m++)(n[m]===h||n[m]===a&&n[m-1]!==h)&&c++,`\r
35
+ `.includes(n[m])||n[m]===r?(g=0,n[m]===r?T+=n[m]:n[m]===h?c<=l&&(T+=n[m],n[m+1]===a&&(T+=n[m+1],m++)):n[m]===a&&(!n[m-1]||n[m-1]!==h)&&c<=l&&(T+=n[m])):(g++,!n[m+1]&&!c&&(T+=" "));return T}if(typeof e=="string"&&e.length){let n=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(n=+t);let l="",s="";if(!e.trim())l=e;else if(!e[0].trim()){for(let h=0,a=e.length;h<a;h++)if(e[h].trim()){l=e.slice(0,h);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===r)){for(let h=e.length;h--;)if(e[h].trim()){s=e.slice(h+1);break}}return`${o(l,n,!1)}${e.trim()}${i(o(i(s),n,!0))}`}return e}var ai={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Gt(e,t){if(!Array.isArray(e)||!e.length)return e;let r=$($({},ai),t),i,o;if(r.strictlyTwoElementsInRangeArrays&&!e.every((s,h)=>!Array.isArray(s)||s.length!==2?(i=h,o=s.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) has not two but ${o} elements!`);if(!e.every((s,h)=>!Array.isArray(s)||!Number.isInteger(s[0])||s[0]<0||!Number.isInteger(s[1])||s[1]<0?(i=h,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,l=0;return Array.from(e).sort((s,h)=>(r.progressFn&&(l+=1,r.progressFn(Math.floor(l*100/n))),s[0]===h[0]?s[1]<h[1]?-1:s[1]>h[1]?1:0:s[0]<h[0]?-1:1))}var zt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function oi(e,t){function r(a){return a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let i;if(t)if(r(t)){if(i=$($({},zt),t),i.progressFn&&r(i.progressFn)&&!Object.keys(i.progressFn).length)i.progressFn=null;else if(i.progressFn&&typeof i.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof i.progressFn}", equal to ${JSON.stringify(i.progressFn,null,4)}`);if(![1,2,"1","2"].includes(i.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof i.mergeType}", equal to ${JSON.stringify(i.mergeType,null,4)}`);if(typeof i.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof i.joinRangesThatTouchEdges}", equal to ${JSON.stringify(i.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
36
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},zt);let o=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),n,l,s;i.progressFn?n=Gt(o,{progressFn:a=>{s=Math.floor(a/5),s!==l&&(l=s,i.progressFn(s))}}):n=Gt(o);let h=n.length-1;for(let a=h;a>0;a--)i.progressFn&&(s=Math.floor((1-a/h)*78)+21,s!==l&&s>l&&(l=s,i.progressFn(s))),(n[a][0]<=n[a-1][0]||!i.joinRangesThatTouchEdges&&n[a][0]<n[a-1][1]||i.joinRangesThatTouchEdges&&n[a][0]<=n[a-1][1])&&(n[a-1][0]=Math.min(n[a][0],n[a-1][0]),n[a-1][1]=Math.max(n[a][1],n[a-1][1]),n[a][2]!==void 0&&(n[a-1][0]>=n[a][0]||n[a-1][1]<=n[a][1])&&n[a-1][2]!==null&&(n[a][2]===null&&n[a-1][2]!==null?n[a-1][2]=null:n[a-1][2]!=null?+i.mergeType==2&&n[a-1][0]===n[a][0]?n[a-1][2]=n[a][2]:n[a-1][2]+=n[a][2]:n[a-1][2]=n[a][2]),n.splice(a,1),a=n.length);return n.length?n:null}function C(e){return e!=null}function V(e){return Number.isInteger(e)&&e>=0}function X(e){return typeof e=="string"}var li={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Z=class{constructor(e){be(this,"ranges");be(this,"opts");let t=$($({},li),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(X(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(X(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,r){if(e==null&&t==null)return;if(C(e)&&!C(t)){if(Array.isArray(e)){if(e.length){if(e.some(n=>Array.isArray(n))){e.forEach(n=>{Array.isArray(n)&&this.add(...n)});return}e.length&&V(+e[0])&&V(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!C(e)&&C(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let i=+e,o=+t;if(V(r)&&(r=String(r)),V(i)&&V(o)){if(C(r)&&!X(r)&&!V(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:
37
+ ${JSON.stringify(r,null,4)}`);if(C(this.ranges)&&Array.isArray(this.last())&&i===this.last()[1]){if(this.last()[1]=o,this.last()[2],this.last()[2]!==null&&C(r)){let n=this.last()[2]&&this.last()[2].length>0&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(n=pe(n,this.opts.limitLinebreaksCount)),X(n)&&!n.length||(this.last()[2]=n)}}else{this.ranges||(this.ranges=[]);let n=r!==void 0&&!(X(r)&&!r.length)?[i,o,r&&this.opts.limitToBeAddedWhitespace?pe(r,this.opts.limitLinebreaksCount):r]:[i,o];this.ranges.push(n)}}else throw V(i)&&i>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof o}" equal to: ${JSON.stringify(o,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof i}" equal to: ${JSON.stringify(i,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=oi(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>C(e[2])?[e[0],e[1],pe(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&V(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var fi={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Fe(e,t){if(!Array.isArray(e)||!e.length)return e;let r=$($({},fi),t),i,o;if(r.strictlyTwoElementsInRangeArrays&&!e.every((s,h)=>!Array.isArray(s)||s.length!==2?(i=h,o=s.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) has not two but ${o} elements!`);if(!e.every((s,h)=>!Array.isArray(s)||!Number.isInteger(s[0])||s[0]<0||!Number.isInteger(s[1])||s[1]<0?(i=h,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,l=0;return Array.from(e).sort((s,h)=>(r.progressFn&&(l+=1,r.progressFn(Math.floor(l*100/n))),s[0]===h[0]?s[1]<h[1]?-1:s[1]>h[1]?1:0:s[0]<h[0]?-1:1))}var Yt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Xt(e,t){function r(a){return a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let i;if(t)if(r(t)){if(i=$($({},Yt),t),i.progressFn&&r(i.progressFn)&&!Object.keys(i.progressFn).length)i.progressFn=null;else if(i.progressFn&&typeof i.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof i.progressFn}", equal to ${JSON.stringify(i.progressFn,null,4)}`);if(![1,2,"1","2"].includes(i.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof i.mergeType}", equal to ${JSON.stringify(i.mergeType,null,4)}`);if(typeof i.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof i.joinRangesThatTouchEdges}", equal to ${JSON.stringify(i.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
38
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},Yt);let o=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),n,l,s;i.progressFn?n=Fe(o,{progressFn:a=>{s=Math.floor(a/5),s!==l&&(l=s,i.progressFn(s))}}):n=Fe(o);let h=n.length-1;for(let a=h;a>0;a--)i.progressFn&&(s=Math.floor((1-a/h)*78)+21,s!==l&&s>l&&(l=s,i.progressFn(s))),(n[a][0]<=n[a-1][0]||!i.joinRangesThatTouchEdges&&n[a][0]<n[a-1][1]||i.joinRangesThatTouchEdges&&n[a][0]<=n[a-1][1])&&(n[a-1][0]=Math.min(n[a][0],n[a-1][0]),n[a-1][1]=Math.max(n[a][1],n[a-1][1]),n[a][2]!==void 0&&(n[a-1][0]>=n[a][0]||n[a-1][1]<=n[a][1])&&n[a-1][2]!==null&&(n[a][2]===null&&n[a-1][2]!==null?n[a-1][2]=null:n[a-1][2]!=null?+i.mergeType==2&&n[a-1][0]===n[a][0]?n[a-1][2]=n[a][2]:n[a-1][2]+=n[a][2]:n[a-1][2]=n[a][2]),n.splice(a,1),a=n.length);return n.length?n:null}var ui=!0,ke="Invariant failed";function Zt(e,t){if(!e){if(ui)throw new Error(ke);var r=typeof t=="function"?t():t,i=r?ke+": "+r:ke;throw new Error(i)}}function L(e,t,r){let i=0,o=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter(g=>g).length)return e;let n;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?n=[Array.from(t)]:n=Array.from(t);let l=n.length,s=0;n.filter(g=>g).forEach((g,c)=>{if(r&&(i=Math.floor(s/l*10),i!==o&&(o=i,r(i))),!Array.isArray(g))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${c}th element not an array: ${JSON.stringify(g,null,4)}, which is ${typeof g}`);if(!Number.isInteger(g[0])){if(!Number.isInteger(+g[0])||+g[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(g,null,0)}. Its first element is not an integer, string index, but ${typeof g[0]}, equal to: ${JSON.stringify(g[0],null,4)}.`);n[c][0]=+n[c][0]}if(!Number.isInteger(g[1])){if(!Number.isInteger(+g[1])||+g[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(g,null,0)}. Its second element is not an integer, string index, but ${typeof g[1]}, equal to: ${JSON.stringify(g[1],null,4)}.`);n[c][1]=+n[c][1]}s+=1});let h=Xt(n,{progressFn:g=>{r&&(i=10+Math.floor(g/10),i!==o&&(o=i,r(i)))}});Zt(h);let a=h.length;if(a>0){let g=e.slice(h[a-1][1]);e=h.reduce((c,T,m,u)=>{r&&(i=20+Math.floor(m/a*80),i!==o&&(o=i,r(i)));let y=m===0?0:u[m-1][1],d=u[m][0];return`${c}${e.slice(y,d)}${u[m][2]||""}`},""),e+=g}return e}var Qt=U(Ve(),1);var gi={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function Q(e,t){if(typeof e!="string")throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:
39
+ ${JSON.stringify(e,null,4)}`);let r=$($({},gi),t);function i(l){return r.classicTrim&&!l.trim()||!r.classicTrim&&(r.space&&l===" "||r.cr&&l==="\r"||r.lf&&l===`
40
+ `||r.tab&&l===" "||r.nbsp&&l==="\xA0")}let o,n;if(e.length){if(i(e[0]))for(let l=0,s=e.length;l<s;l++){if(!i(e[l])){o=l;break}if(l===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let l=e.length;l--;)if(!i(e[l])){n=l+1;break}}return o?n?{res:e.slice(o,n),ranges:[[0,o],[n,e.length]]}:{res:e.slice(o),ranges:[[0,o]]}:n?{res:e.slice(0,n),ranges:[[n,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var ci={heads:["{{"],tails:["}}"]};function er(e,t){let r=Object.prototype.hasOwnProperty;if(e===void 0)throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(t&&!(0,Qt.default)(t))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof t}!`);let i=$({},t);if(i&&r.call(i,"heads"))if(I(i.heads).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.heads=="string"&&(i.heads=I(i.heads));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_04] The opts.heads contains elements which are not string-type!");if(i&&r.call(i,"tails"))if(I(i.tails).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.tails=="string"&&(i.tails=I(i.tails));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_05] The opts.tails contains elements which are not string-type!");let o=Q(e).res;if(o.length===0)return e;e=o;let n=$($({},ci),i);n.heads=n.heads.map(y=>y.trim()),n.tails=n.tails.map(y=>y.trim());let l=!1,s=!1,h=new Z({limitToBeAddedWhitespace:!0}),a=new Z({limitToBeAddedWhitespace:!0}),g=!0,c=!0,T="";function m(y,d){let f;return W(y,0,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&W(y,f,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(f):y}for(;e!==m(e,n);)e=Q(m(e,n)).res;function u(y,d){let f;return!k(y,y.length-1,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})||!f?y:k(y,f,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(0,f+1):y}for(;e!==u(e,n);)e=Q(u(e,n)).res;if(!n.heads.length||!W(e,0,n.heads,{trimBeforeMatching:!0})||!n.tails.length||!k(e,e.length-1,n.tails,{trimBeforeMatching:!0}))return Q(e).res;for(let y=0,d=e.length;y<d;y++)if(e[y].trim()!==""){let f;if(W(e,y,n.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&f){c=!0,g&&(g=!0);let p;W(e,f,n.tails,{trimBeforeMatching:!0,cb:(w,b,O)=>(p=O,!0)})&&h.push(y,p),a.current()&&l&&T!=="tails"&&h.push(a.current()),l||a.current()&&(h.push(a.current()),a.wipe()),a.push(y,f),T="heads",y=f-1;continue}if(W(e,y,n.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=Number.isInteger(b)?b:e.length,!0)})&&f){c=!0,g?(T==="heads"&&a.wipe(),g=!1):a.push(y,f),T="tails",y=f-1;continue}g&&(g=!0),c&&!l?(l=!0,c=!1):c&&!s?(s=!0,g=!0,c=!1,T==="heads"&&a.wipe()):c&&s&&a.wipe()}return a.current()&&h.push(a.current()),h.current()?L(e,h.current()).trim():e.trim()}var tr="11.0.12";var pi=tr,di=Object.prototype.hasOwnProperty,rr={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function A(e){return typeof e=="string"}function yi(e){return typeof e=="number"}function Le(e){return typeof e=="boolean"}function de(e){return e===null}function ee(e){return e&&typeof e=="object"&&!Array.isArray(e)}function mi(e){return e!=null}function _(e){return A(e)?e.trim():e}function wi(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(0,t)}return e}function bi(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(t+1)}return e}function nr(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(0,t)}return e}function ir(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(t+1)}return e}function qe(e,t){return typeof e!="string"||!e.trim()?!1:!!(e.includes(t.heads)||e.includes(t.tails)||A(t.headsNoWrap)&&t.headsNoWrap.length>0&&e.includes(t.headsNoWrap)||A(t.tailsNoWrap)&&t.tailsNoWrap.length>0&&e.includes(t.tailsNoWrap))}function Ti(e,t,r){let i,o;return typeof e=="string"&&e.length>0&&W(e,0,t,{trimBeforeMatching:!0,cb:(n,l,s)=>(i=s,!0)})&&k(e,e.length-1,r,{trimBeforeMatching:!0,cb:(n,l,s)=>(o=+s+1,!0)})?e.slice(i,o):e}function sr(e,t,r=!1,i,o,n){if(t.wrapHeadsWith||(t.wrapHeadsWith=""),t.wrapTailsWith||(t.wrapTailsWith=""),A(e)&&!r&&t.wrapGlobalFlipSwitch&&!t.dontWrapVars.some(l=>ge(n,l))&&(!t.preventDoubleWrapping||t.preventDoubleWrapping&&A(e)&&!e.includes(t.wrapHeadsWith)&&!e.includes(t.wrapTailsWith)))return`${t.wrapHeadsWith}${e}${t.wrapTailsWith}`;if(r){if(!A(e))return e;let l=er(e,{heads:t.wrapHeadsWith,tails:t.wrapTailsWith});return A(l)?Ti(l,t.wrapHeadsWith,t.wrapTailsWith):l}return e}function $i(e,t,r,i){let o;if(r.indexOf(".")!==-1){let n=r,l=!0;if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length>0&&!n.endsWith(i.dataContainerIdentifierTails)){let s=D.default.get(e,n+i.dataContainerIdentifierTails);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}for(;l&&n.indexOf(".")!==-1;){if(n=nr(n),ir(n)===t)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop. The parent key "${ir(n)}" is called the same as the variable "${t}" we're looking for.`);if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length>0&&!n.endsWith(i.dataContainerIdentifierTails)){let s=D.default.get(e,n+i.dataContainerIdentifierTails);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}if(o===void 0){let s=D.default.get(e,n);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}}}if(o===void 0){let n=D.default.get(e,t);n!==void 0&&(o=n)}if(o===void 0)if(t.indexOf(".")===-1){let n=Be(e,t);if(n.length>0){for(let l=0,s=n.length;l<s;l++)if(A(n[l].val)||Le(n[l].val)||de(n[l].val)){o=n[l].val;break}else if(yi(n[l].val)){o=String(n[l].val);break}else if(Array.isArray(n[l].val)){o=n[l].val.join("");break}}}else{let n=Be(e,wi(t));if(n.length>0)for(let l=0,s=n.length;l<s;l++){let h=D.default.get(n[l].val,bi(t));h&&A(h)&&(o=h)}}return o}function ar(e,t,r,i,o=[]){if(o.includes(r)){let m="";if(o.length>1){let u=` \u2192
41
+ `;m=o.reduce((y,d,f)=>y+(f===0?"":u)+(d===r?"\u{1F4A5} ":" ")+d,` Here's the path we travelled up until we hit the recursion:
42
+
43
+ `),m+=`${u}\u{1F4A5} ${r}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop, the key is referencing itself."${m}`)}let n={},l=Array.from(o);l.push(r);let s=new Z;function h(m,u,y){for(let d=0,f=m.length;d<f;d++){let p=m[d],w=t.slice(p.headsEndAt,p.tailsStartAt);if(w.length===0)s.push(p.headsStartAt,p.tailsEndAt);else if(di.call(n,w)&&A(n[w]))s.push(p.headsStartAt,p.tailsEndAt,n[w]);else{let b=$i(e,w.trim(),r,i);if(b===void 0)if(i.allowUnresolved===!0)b="";else if(typeof i.allowUnresolved=="string")b=i.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${t.slice(p.headsEndAt,p.tailsStartAt)}. We're at path: "${r}".`);if(!y&&i.throwWhenNonStringInsertedInString&&!A(b))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${t.slice(p.headsEndAt,p.tailsStartAt)} at path ${r}, it resolved into a non-string value, ${JSON.stringify(b,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(Le(b)){if(i.resolveToBoolIfAnyValuesContainBool)return s.wipe(),i.resolveToFalseIfAnyValuesContainBool?!1:b;b=""}else{if(de(b)&&y)return s.wipe(),b;Array.isArray(b)?b=String(b.join("")):de(b)?b="":b=String(b)}let O=r.includes(".")?`${nr(r)}.${w}`:w;if(qe(b,i)){let E=sr(ar(e,b,O,i,l),i,u,l,O,w.trim());typeof E=="string"&&s.push(p.headsStartAt,p.tailsEndAt,E)}else{n[w]=b;let E=sr(b,i,u,l,O,w.trim());typeof E=="string"&&s.push(p.headsStartAt,p.tailsEndAt,E)}}}}let a;try{a=Pe(t,i.heads,i.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(m){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${t}" at path ${r}, something wrong with heads and tails was detected! Here's the internal error message:
44
+ ${m}`)}let g=!1;a.length===1&&L(t,[[a[0].headsStartAt,a[0].tailsEndAt]]).trim()===""&&(g=!0);let c=h(a,!1,g);if(typeof c=="boolean"||c===null)return c;try{a=Pe(t,i.headsNoWrap,i.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(m){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${t}" at path ${r}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
45
+ ${m}`)}a.length===1&&L(t,[[a[0].headsStartAt,a[0].tailsEndAt]]).trim()===""&&(g=!0);let T=h(a,!0,g);return Le(T)||de(T)?T:(s==null?void 0:s.current())?L(t,s.current()):t}function vi(e,t){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!ee(e))throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(e)?"array":typeof e}`);if(t&&!ee(t))throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(t)?"array":typeof t}`);let r=$($({},rr),t);r.dontWrapVars?Array.isArray(r.dontWrapVars)||(r.dontWrapVars=I(r.dontWrapVars)):r.dontWrapVars=[];let i,o;if(r.dontWrapVars.length>0&&!r.dontWrapVars.every((l,s)=>A(l)?!0:(i=l,o=s,!1)))throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in opts.dontWrapVars should be of a string type. Computer detected a value "${i}" at index ${o}, which is not string but ${Array.isArray(i)?"array":typeof i}!`);if(r.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! opts.heads are empty!");if(r.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! opts.tails are empty!");if(r.lookForDataContainers&&r.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! opts.dataContainerIdentifierTails is empty!");if(r.heads===r.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! opts.heads and opts.tails can't be equal!");if(r.heads===r.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! opts.heads and opts.headsNoWrap can't be equal!");if(r.tails===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! opts.tails and opts.tailsNoWrap can't be equal!");if(r.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! opts.headsNoWrap is an empty string!");if(r.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! opts.tailsNoWrap is an empty string!");if(r.headsNoWrap===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! opts.headsNoWrap and opts.tailsNoWrap can't be equal!");let n;return ue(e,(l,s,h)=>{if(mi(s)&&qe(l,r))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
46
+ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(r.heads.length!==0&&_(n)===_(r.heads)||r.tails.length!==0&&_(n)===_(r.tails)||r.headsNoWrap.length!==0&&_(n)===_(r.headsNoWrap)||r.tailsNoWrap.length!==0&&_(n)===_(r.tailsNoWrap)){if(!r.noSingleMarkers)return n;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${_(n)} which is equal to ${_(n)===_(r.heads)?"heads":""}${_(n)===_(r.tails)?"tails":""}${A(r.headsNoWrap)&&_(n)===_(r.headsNoWrap)?"headsNoWrap":""}${A(r.tailsNoWrap)&&_(n)===_(r.tailsNoWrap)?"tailsNoWrap":""}. If you wouldn't have set opts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${_(n)}) alone`)}return A(n)&&qe(n,r)?ar(e,n,h.path,r):n})}return dr(Oi);})();
27
47
  /**
28
48
  * @name arrayiffy-if-string
29
49
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
30
- * @version 4.0.6
50
+ * @version 4.0.12
31
51
  * @author Roy Revelt, Codsen Ltd
32
52
  * @license MIT
33
53
  * {@link https://codsen.com/os/arrayiffy-if-string/}
34
- */function T(e){return"string"==typeof e?e.length?[e]:[]:e}
54
+ */
35
55
  /**
36
- * @name string-match-left-right
37
- * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
38
- * @version 8.0.6
56
+ * @name ast-get-values-by-key
57
+ * @fileoverview Extract values and paths from AST by keys OR set them by keys
58
+ * @version 4.0.12
39
59
  * @author Roy Revelt, Codsen Ltd
40
60
  * @license MIT
41
- * {@link https://codsen.com/os/string-match-left-right/}
42
- */function v(e){return e&&"object"==typeof e&&!Array.isArray(e)}function O(e){return"string"==typeof e}const A={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},$=e=>e+1;function W(e,t,r,n,i=!1,s=$){const o="function"==typeof r?r():r;if(+t<0&&i&&"EOL"===o)return o;const a={...A,...n};if(t>=e.length&&!i)return!1;let l=i?1:r.length,u=0,f=!1,h=!1,c=!1,g=a.maxMismatches,p=t,y=!1,d=!1,m=!1;function w(){return 1===u&&g<a.maxMismatches-1}for(;e[p];){const t=s(p);if(a.trimBeforeMatching&&""===e[p].trim()){if(!e[t]&&i&&"EOL"===r)return!0;p=s(p);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[p])||a&&a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map((e=>e.toLowerCase())).includes(e[p].toLowerCase())){if(i&&"EOL"===r&&!e[t])return!0;p=s(p);continue}const n=t>p?r[r.length-l]:r[l-1];if(!a.i&&e[p]===n||a.i&&e[p].toLowerCase()===n.toLowerCase()){if(y||(y=!0),c||(c=!0),l===r.length){if(d=!0,g!==a.maxMismatches)return!1}else 1===l&&(m=!0);if(l-=1,u++,w())return!1;if(!l)return(u!==r.length||g===a.maxMismatches||!f)&&p}else{if(f||u||(f=!0),!(a.maxMismatches&&g&&p))return!(0!==p||1!==l||a.lastMustMatch||!c)&&0;g-=1;for(let n=0;n<=g;n++){const i=t>p?r[r.length-l+1+n]:r[l-2-n],o=e[s(p)];if(i&&(!a.i&&e[p]===i||a.i&&e[p].toLowerCase()===i.toLowerCase())&&(!a.firstMustMatch||l!==r.length)){if(u++,w())return!1;l-=2,y=!0;break}if(o&&i&&(!a.i&&o===i||a.i&&o.toLowerCase()===i.toLowerCase())&&(!a.firstMustMatch||l!==r.length)){if(!u&&!a.hungry)return!1;l-=1,y=!0;break}if(void 0===i&&g>=0&&y&&(!a.firstMustMatch||d)&&(!a.lastMustMatch||m))return p}y||(h=p)}if(!1!==h&&h!==p&&(h=!1),l<1)return p;p=s(p)}return l>0?!(!i||"EOL"!==o)||!!(a&&a.maxMismatches>=l&&c)&&(h||0):void 0}function I(e,t,r,n,i){if(v(i)&&Object.prototype.hasOwnProperty.call(i,"trimBeforeMatching")&&"boolean"!=typeof i.trimBeforeMatching)throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(i.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);const s={...A,...i};if("string"==typeof s.trimCharsBeforeMatching&&(s.trimCharsBeforeMatching=T(s.trimCharsBeforeMatching)),s.trimCharsBeforeMatching=s.trimCharsBeforeMatching.map((e=>O(e)?e:String(e))),!O(t))return!1;if(!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);let o,a;if(O(n))o=[n];else if(Array.isArray(n))o=n;else if(n){if("function"!=typeof n)throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof n}, equal to:\n${JSON.stringify(n,null,4)}`);o=[],o.push(n)}else o=n;if(i&&!v(i))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof i}", and equal to:\n${JSON.stringify(i,null,4)}`);let l=0,u="";if(s&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.some(((e,t)=>e.length>1&&(l=t,u=e,!0))))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${l} is longer than 1 character, ${u.length} (equals to ${u}). Please split it into separate characters and put into array as separate elements.`);if(!o||!Array.isArray(o)||Array.isArray(o)&&!o.length||Array.isArray(o)&&1===o.length&&O(o[0])&&!o[0].trim()){if("function"==typeof s.cb){let n,i=r;if("matchLeftIncl"!==e&&"matchRight"!==e||(i+=1),"L"===e[5])for(let e=i;e--;){const r=t[e];if((!s.trimBeforeMatching||s.trimBeforeMatching&&void 0!==r&&r.trim())&&(!s.trimCharsBeforeMatching||!s.trimCharsBeforeMatching.length||void 0!==r&&!s.trimCharsBeforeMatching.includes(r))){n=e;break}}else if(e.startsWith("matchRight"))for(let e=i;e<t.length;e++){const r=t[e];if((!s.trimBeforeMatching||s.trimBeforeMatching&&r.trim())&&(!s.trimCharsBeforeMatching||!s.trimCharsBeforeMatching.length||!s.trimCharsBeforeMatching.includes(r))){n=e;break}}if(void 0===n)return!1;const o=t[n],a=n+1;let l="";return a&&a>0&&(l=t.slice(0,a)),"L"===e[5]?s.cb(o,l,n):(n&&n>0&&(l=t.slice(n)),s.cb(o,l,n))}let n="";throw i||(n=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${n}`)}for(let n=0,i=o.length;n<i;n++){a="function"==typeof o[n];const i=o[n];let l,u,f="",h=r;"matchRight"===e?h+=1:"matchLeft"===e&&(h-=1);const c=W(t,h,i,s,a,(t=>"L"===e[5]?t-1:t+1));if(c&&a&&"function"==typeof i&&"EOL"===i())return!(!i()||s.cb&&!s.cb(l,f,u))&&i();if(Number.isInteger(c)&&(u=e.startsWith("matchLeft")?c-1:c+1,f="L"===e[5]?t.slice(0,c):t.slice(u)),u<0&&(u=void 0),t[u]&&(l=t[u]),Number.isInteger(c)&&(!s.cb||s.cb(l,f,u)))return i}return!1}function j(e,t,r,n){return I("matchLeftIncl",e,t,r,n)}function E(e,t,r,n){return I("matchRightIncl",e,t,r,n)}
61
+ * {@link https://codsen.com/os/ast-get-values-by-key/}
62
+ */
43
63
  /**
44
- * @name string-find-heads-tails
45
- * @fileoverview Finds where are arbitrary templating marker heads and tails located
46
- * @version 5.0.6
64
+ * @name ast-monkey-traverse
65
+ * @fileoverview Utility library to traverse AST
66
+ * @version 3.0.12
47
67
  * @author Roy Revelt, Codsen Ltd
48
68
  * @license MIT
49
- * {@link https://codsen.com/os/string-find-heads-tails/}
50
- */function R(e){return"string"==typeof e}const S={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function N(e,t,r,n){if(n&&(!(i=n)||"object"!=typeof i||Array.isArray(i)))throw new TypeError(`string-find-heads-tails: [THROW_ID_01] the fourth input argument, an Optional Options Object, must be a plain object! Currently it's equal to: ${n} (type: ${typeof n})`);var i;const s={...S,...n};if("string"==typeof s.fromIndex&&/^\d*$/.test(s.fromIndex))s.fromIndex=Number(s.fromIndex);else if(!Number.isInteger(s.fromIndex)||s.fromIndex<0)throw new TypeError(`${s.source} [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ${s.fromIndex}`);if(!R(e)||0===e.length){if(s.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_02] the first input argument, input string, must be a non-zero-length string! Currently it's: ${typeof e}, equal to: ${e}`)}let o,a;if("string"!=typeof t&&!Array.isArray(t)){if(s.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_03] the second input argument, heads, must be either a string or an array of strings! Currently it's: ${typeof t}, equal to:\n${JSON.stringify(t,null,4)}`)}if("string"==typeof t){if(0===t.length){if(s.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_04] the second input argument, heads, must be a non-empty string! Currently it's empty.")}t=T(t)}else if(Array.isArray(t)){if(0===t.length){if(s.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_05] the second input argument, heads, must be a non-empty array and contain at least one string! Currently it's empty.")}if(t.every(((e,t)=>(o=e,a=t,R(e))))){if(!t.every(((e,t)=>(a=t,R(e)&&e.length>0&&""!==e.trim())))){if(!s.relaxedAPI)throw new TypeError(`string-find-heads-tails: [THROW_ID_07] the second input argument, heads, should not contain empty strings! For example, there's one detected at index ${a} of heads array:\n${JSON.stringify(t,null,4)}.`);if(0===(t=t.filter((e=>R(e)&&e.length>0))).length)return[]}}else{if(!s.relaxedAPI)throw new TypeError(`string-find-heads-tails: [THROW_ID_06] the second input argument, heads, contains non-string elements! For example, element at ${a}th index is ${typeof o}, equal to:\n${JSON.stringify(o,null,4)}. Whole heads array looks like:\n${JSON.stringify(t,null,4)}`);if(0===(t=t.filter((e=>R(e)&&e.length>0))).length)return[]}}if(!R(r)&&!Array.isArray(r)){if(s.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_08] the third input argument, tails, must be either a string or an array of strings! Currently it's: ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`)}if(R(r)){if(0===r.length){if(s.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_09] the third input argument, tails, must be a non-empty string! Currently it's empty.")}r=T(r)}else if(Array.isArray(r)){if(0===r.length){if(s.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_10] the third input argument, tails, must be a non-empty array and contain at least one string! Currently it's empty.")}if(r.every(((e,t)=>(o=e,a=t,R(e))))){if(!r.every(((e,t)=>(a=t,R(e)&&e.length>0&&""!==e.trim())))){if(!s.relaxedAPI)throw new TypeError(`string-find-heads-tails: [THROW_ID_12] the third input argument, tails, should not contain empty strings! For example, there's one detected at index ${a}. Whole tails array is equal to:\n${JSON.stringify(r,null,4)}`);if(0===(r=r.filter((e=>R(e)&&e.length>0))).length)return[]}}else{if(!s.relaxedAPI)throw new TypeError(`string-find-heads-tails: [THROW_ID_11] the third input argument, tails, contains non-string elements! For example, element at ${a}th index is ${typeof o}, equal to:\n${JSON.stringify(o,null,4)}. Whole tails array is equal to:\n${JSON.stringify(r,null,4)}`);if(0===(r=r.filter((e=>R(e)&&e.length>0))).length)return[]}}const l=s.source===S.source;if(s.throwWhenSomethingWrongIsDetected&&!s.allowWholeValueToBeOnlyHeadsOrTails){if(T(t).includes(e))throw new Error(`${s.source}${l?": [THROW_ID_16]":""} the whole input string can't be equal to ${R(t)?"":"one of "}heads (${e})!`);if(T(r).includes(e))throw new Error(`${s.source}${l?": [THROW_ID_17]":""} the whole input string can't be equal to ${R(r)?"":"one of "}tails (${e})!`)}const u=t.concat(r).map((e=>e.charAt(0))).reduce(((e,t)=>t.charCodeAt(0)>e[1]?[e[0],t.charCodeAt(0)]:t.charCodeAt(0)<e[0]?[t.charCodeAt(0),e[1]]:e),[t[0].charCodeAt(0),t[0].charCodeAt(0)]),f=[];let h,c=!1,g={},p="";for(let n=s.fromIndex,i=e.length;n<i;n++){const o=e[n].charCodeAt(0);if(o<=u[1]&&o>=u[0]){const o=E(e,n,t);if(o&&s.matchHeadsAndTailsStrictlyInPairsByTheirOrder)for(let e=t.length;e--;)if(t[e]===o){h=e;break}if("string"==typeof o){if(!c){g={},g.headsStartAt=n,g.headsEndAt=n+o.length,c=!0,n+=o.length-1,p&&(p="");continue}if(s.throwWhenSomethingWrongIsDetected)throw new TypeError(`${s.source}${l?": [THROW_ID_19]":""} When processing "${e}", we found heads (${e.slice(n,n+o.length)}) starting at character with index number "${n}" and there was another set of heads before it! Generally speaking, there should be "heads-tails-heads-tails", not "heads-heads-tails"!\nWe're talking about the area of the code:\n\n\n--------------------------------------starts\n${e.slice(Math.max(n-200,0),n)}\n -------\x3e ${e.slice(n,n+o.length)} <-------\n${e.slice(n+o.length,Math.min(i,n+200))}\n--------------------------------------ends\n\n\nTo turn off this error being thrown, set opts.throwWhenSomethingWrongIsDetected to Boolean false.`)}const a=E(e,n,r);if(c&&a&&s.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&void 0!==h&&void 0!==r[h]&&r[h]!==a){let n;for(let e=r.length;e--;)if(r[e]===a){n=e;break}throw new TypeError(`${s.source}${l?": [THROW_ID_20]":""} When processing "${e}", we had "opts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (${t[h]}) but the tails the followed it were not of the same index, ${h} (${r[h]}) but ${n} (${a}).`)}if("string"==typeof a){if(c){g.tailsStartAt=n,g.tailsEndAt=n+a.length,f.push(g),g={},c=!1,n+=a.length-1;continue}s.throwWhenSomethingWrongIsDetected&&(p=`${s.source}${l?": [THROW_ID_21]":""} When processing "${e}", we found tails (${e.slice(n,n+a.length)}) starting at character with index number "${n}" but there were no heads preceding it. That's very naughty!`)}}if(s.throwWhenSomethingWrongIsDetected&&n===i-1){if(0!==Object.keys(g).length)throw new TypeError(`${s.source}${l?": [THROW_ID_22]":""} When processing "${e}", we reached the end of the string and yet didn't find any tails (${JSON.stringify(r,null,4)}) to match the last detected heads (${e.slice(g.headsStartAt,g.headsEndAt)})!`);if(p)throw new Error(p)}}return f}
69
+ * {@link https://codsen.com/os/ast-monkey-traverse/}
70
+ */
51
71
  /**
52
- * @name ast-get-values-by-key
53
- * @fileoverview Extract values and paths from AST by keys OR set them by keys
54
- * @version 4.0.6
72
+ * @name ast-monkey-util
73
+ * @fileoverview Utility library of AST helper functions
74
+ * @version 2.0.12
55
75
  * @author Roy Revelt, Codsen Ltd
56
76
  * @license MIT
57
- * {@link https://codsen.com/os/ast-get-values-by-key/}
58
- */function H(e,t,r){let i;void 0!==r&&(i=Array.isArray(r)?n(r):[n(r)]);const s=[],o=p(e,((e,r,n)=>{const o=void 0!==r?r:e;if(void 0!==r&&w(e,t,{caseSensitive:!0}))if(void 0===i)s.push({val:r,path:n.path});else if(i.length)return i.shift();return o}));return void 0===i?s:o}
77
+ * {@link https://codsen.com/os/ast-monkey-util/}
78
+ */
59
79
  /**
60
- * @name string-collapse-leading-whitespace
61
- * @fileoverview Collapse the leading and trailing whitespace of a string
62
- * @version 6.0.6
80
+ * @name ranges-apply
81
+ * @fileoverview Take an array of string index ranges, delete/replace the string according to them
82
+ * @version 6.0.12
63
83
  * @author Roy Revelt, Codsen Ltd
64
84
  * @license MIT
65
- * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
66
- */function D(e,t=1){function r(e){return Array.from(e).reverse().join("")}function n(e,t,r){const n=r?"\n":"\r",i=r?"\r":"\n";if(!e)return e;let s=0,o="";for(let r=0,a=e.length;r<a;r++)(e[r]===n||e[r]===i&&e[r-1]!==n)&&s++,"\r\n".includes(e[r])||" "===e[r]?" "===e[r]?o+=e[r]:e[r]===n?s<=t&&(o+=e[r],e[r+1]===i&&(o+=e[r+1],r++)):e[r]===i&&(!e[r-1]||e[r-1]!==n)&&s<=t&&(o+=e[r]):e[r+1]||s||(o+=" ");return o}if("string"==typeof e&&e.length){let i=1;"number"==typeof+t&&Number.isInteger(+t)&&+t>=0&&(i=+t);let s="",o="";if(e.trim()){if(!e[0].trim())for(let t=0,r=e.length;t<r;t++)if(e[t].trim()){s=e.slice(0,t);break}}else s=e;if(e.trim()&&(""===e.slice(-1).trim()||" "===e.slice(-1)))for(let t=e.length;t--;)if(e[t].trim()){o=e.slice(t+1);break}return`${n(s,i,!1)}${e.trim()}${r(n(r(o),i,!0))}`}return e}
85
+ * {@link https://codsen.com/os/ranges-apply/}
86
+ */
87
+ /**
88
+ * @name ranges-merge
89
+ * @fileoverview Merge and sort string index ranges
90
+ * @version 8.0.12
91
+ * @author Roy Revelt, Codsen Ltd
92
+ * @license MIT
93
+ * {@link https://codsen.com/os/ranges-merge/}
94
+ */
67
95
  /**
68
96
  * @name ranges-push
69
97
  * @fileoverview Gather string index ranges
70
- * @version 6.0.6
98
+ * @version 6.0.12
71
99
  * @author Roy Revelt, Codsen Ltd
72
100
  * @license MIT
73
101
  * {@link https://codsen.com/os/ranges-push/}
74
- */const x={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function M(e,t){if(!Array.isArray(e)||!e.length)return e;const r={...x,...t};let n,i;if(r.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,t)=>2===e.length||(n=t,i=e.length,!1))))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${i} elements!`);if(!e.filter((e=>e)).every(((e,t)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(n=t,!1))))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);const s=e.filter((e=>e)).length**2;let o=0;return Array.from(e).filter((e=>e)).sort(((e,t)=>(r.progressFn&&(o+=1,r.progressFn(Math.floor(100*o/s))),e[0]===t[0]?e[1]<t[1]?-1:e[1]>t[1]?1:0:e[0]<t[0]?-1:1)))}const C={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function B(e){return null!=e}function F(e){return Number.isInteger(e)&&e>=0}function k(e){return"string"==typeof e}const J={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};class P{constructor(e){const t={...J,...e};if(t.mergeType&&1!==t.mergeType&&2!==t.mergeType)if(k(t.mergeType)&&"1"===t.mergeType.trim())t.mergeType=1;else{if(!k(t.mergeType)||"2"!==t.mergeType.trim())throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);t.mergeType=2}this.opts=t,this.ranges=[]}ranges;opts;add(e,t,r){if(null==e&&null==t)return;if(B(e)&&!B(t)){if(Array.isArray(e)){if(e.length){if(e.some((e=>Array.isArray(e))))return void e.forEach((e=>{Array.isArray(e)&&this.add(...e)}));e.length&&F(+e[0])&&F(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}if(!B(e)&&B(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);const n=+e,i=+t;if(F(r)&&(r=String(r)),!F(n)||!F(i))throw F(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof i}" equal to: ${JSON.stringify(i,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`);if(B(r)&&!k(r)&&!F(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);if(B(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=i,this.last(),null!==this.last()[2]&&B(r)){let e=!(this.last()[2]&&this.last()[2].length>0)||this.opts&&this.opts.mergeType&&1!==this.opts.mergeType?r:this.last()[2]+r;this.opts.limitToBeAddedWhitespace&&(e=D(e,this.opts.limitLinebreaksCount)),k(e)&&!e.length||(this.last()[2]=e)}}else{this.ranges||(this.ranges=[]);const e=void 0===r||k(r)&&!r.length?[n,i]:[n,i,r&&this.opts.limitToBeAddedWhitespace?D(r,this.opts.limitLinebreaksCount):r];this.ranges.push(e)}}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=function(e,t){function r(e){return e&&"object"==typeof e&&!Array.isArray(e)}if(!Array.isArray(e)||!e.length)return null;let n;if(t){if(!r(t))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(t,null,4)} (type ${typeof t})`);if(n={...C,...t},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...C};const i=e.filter((e=>e)).map((e=>[...e])).filter((e=>void 0!==e[2]||e[0]!==e[1]));let s,o,a;if(s=n.progressFn?M(i,{progressFn:e=>{a=Math.floor(e/5),a!==o&&(o=a,n.progressFn(a))}}):M(i),!s)return null;const l=s.length-1;for(let e=l;e>0;e--)n.progressFn&&(a=Math.floor(78*(1-e/l))+21,a!==o&&a>o&&(o=a,n.progressFn(a))),(s[e][0]<=s[e-1][0]||!n.joinRangesThatTouchEdges&&s[e][0]<s[e-1][1]||n.joinRangesThatTouchEdges&&s[e][0]<=s[e-1][1])&&(s[e-1][0]=Math.min(s[e][0],s[e-1][0]),s[e-1][1]=Math.max(s[e][1],s[e-1][1]),void 0!==s[e][2]&&(s[e-1][0]>=s[e][0]||s[e-1][1]<=s[e][1])&&null!==s[e-1][2]&&(null===s[e][2]&&null!==s[e-1][2]?s[e-1][2]=null:null!=s[e-1][2]?2==+n.mergeType&&s[e-1][0]===s[e][0]?s[e-1][2]=s[e][2]:s[e-1][2]+=s[e][2]:s[e-1][2]=s[e][2]),s.splice(e,1),e=s.length);return s.length?s:null}(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((e=>B(e[2])?[e[0],e[1],D(e[2],this.opts.limitLinebreaksCount)]:e)):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length){if(!Array.isArray(e[0])||!F(e[0][0]))throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);this.ranges=Array.from(e)}else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}}
102
+ */
75
103
  /**
76
104
  * @name ranges-sort
77
105
  * @fileoverview Sort string index ranges
78
- * @version 5.0.6
106
+ * @version 5.0.12
79
107
  * @author Roy Revelt, Codsen Ltd
80
108
  * @license MIT
81
109
  * {@link https://codsen.com/os/ranges-sort/}
82
- */const V={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function q(e,t){if(!Array.isArray(e)||!e.length)return e;const r={...V,...t};let n,i;if(r.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,t)=>2===e.length||(n=t,i=e.length,!1))))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${i} elements!`);if(!e.filter((e=>e)).every(((e,t)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(n=t,!1))))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);const s=e.filter((e=>e)).length**2;let o=0;return Array.from(e).filter((e=>e)).sort(((e,t)=>(r.progressFn&&(o+=1,r.progressFn(Math.floor(100*o/s))),e[0]===t[0]?e[1]<t[1]?-1:e[1]>t[1]?1:0:e[0]<t[0]?-1:1)))}
110
+ */
83
111
  /**
84
- * @name ranges-merge
85
- * @fileoverview Merge and sort string index ranges
86
- * @version 8.0.6
112
+ * @name string-collapse-leading-whitespace
113
+ * @fileoverview Collapse the leading and trailing whitespace of a string
114
+ * @version 6.0.12
87
115
  * @author Roy Revelt, Codsen Ltd
88
116
  * @license MIT
89
- * {@link https://codsen.com/os/ranges-merge/}
90
- */const L={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function U(e,t){function r(e){return e&&"object"==typeof e&&!Array.isArray(e)}if(!Array.isArray(e)||!e.length)return null;let n;if(t){if(!r(t))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(t,null,4)} (type ${typeof t})`);if(n={...L,...t},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...L};const i=e.filter((e=>e)).map((e=>[...e])).filter((e=>void 0!==e[2]||e[0]!==e[1]));let s,o,a;if(s=n.progressFn?q(i,{progressFn:e=>{a=Math.floor(e/5),a!==o&&(o=a,n.progressFn(a))}}):q(i),!s)return null;const l=s.length-1;for(let e=l;e>0;e--)n.progressFn&&(a=Math.floor(78*(1-e/l))+21,a!==o&&a>o&&(o=a,n.progressFn(a))),(s[e][0]<=s[e-1][0]||!n.joinRangesThatTouchEdges&&s[e][0]<s[e-1][1]||n.joinRangesThatTouchEdges&&s[e][0]<=s[e-1][1])&&(s[e-1][0]=Math.min(s[e][0],s[e-1][0]),s[e-1][1]=Math.max(s[e][1],s[e-1][1]),void 0!==s[e][2]&&(s[e-1][0]>=s[e][0]||s[e-1][1]<=s[e][1])&&null!==s[e-1][2]&&(null===s[e][2]&&null!==s[e-1][2]?s[e-1][2]=null:null!=s[e-1][2]?2==+n.mergeType&&s[e-1][0]===s[e][0]?s[e-1][2]=s[e][2]:s[e-1][2]+=s[e][2]:s[e-1][2]=s[e][2]),s.splice(e,1),e=s.length);return s.length?s:null}
117
+ * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
118
+ */
91
119
  /**
92
- * @name ranges-apply
93
- * @fileoverview Take an array of string index ranges, delete/replace the string according to them
94
- * @version 6.0.6
120
+ * @name string-find-heads-tails
121
+ * @fileoverview Finds where are arbitrary templating marker heads and tails located
122
+ * @version 5.0.12
95
123
  * @author Roy Revelt, Codsen Ltd
96
124
  * @license MIT
97
- * {@link https://codsen.com/os/ranges-apply/}
98
- */function z(e,t,r){let n,i=0,s=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof e)throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter((e=>e)).length)return e;n=Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?[Array.from(t)]:Array.from(t);const o=n.length;let a=0;n.filter((e=>e)).forEach(((e,t)=>{if(r&&(i=Math.floor(a/o*10),i!==s&&(s=i,r(i))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${t}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);n[t][0]=+n[t][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${t}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);n[t][1]=+n[t][1]}a+=1}));const l=U(n,{progressFn:e=>{r&&(i=10+Math.floor(e/10),i!==s&&(s=i,r(i)))}}),u=Array.isArray(l)?l.length:0;if(u>0){const t=e.slice(l[u-1][1]);e=l.reduce(((t,n,o,a)=>{r&&(i=20+Math.floor(o/u*80),i!==s&&(s=i,r(i)));return t+e.slice(0===o?0:a[o-1][1],a[o][0])+(a[o][2]||"")}),""),e+=t}return e}
125
+ * {@link https://codsen.com/os/string-find-heads-tails/}
126
+ */
99
127
  /**
100
- * @name string-trim-spaces-only
101
- * @fileoverview Like String.trim() but you can choose granularly what to trim
102
- * @version 4.0.6
128
+ * @name string-match-left-right
129
+ * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
130
+ * @version 8.0.12
103
131
  * @author Roy Revelt, Codsen Ltd
104
132
  * @license MIT
105
- * {@link https://codsen.com/os/string-trim-spaces-only/}
106
- */const G={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function K(e,t){if("string"!=typeof e)throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}`);const r={...G,...t};function n(e){return r.classicTrim&&!e.trim()||!r.classicTrim&&(r.space&&" "===e||r.cr&&"\r"===e||r.lf&&"\n"===e||r.tab&&"\t"===e||r.nbsp&&" "===e)}let i,s;if(e.length){if(n(e[0]))for(let t=0,r=e.length;t<r;t++){if(!n(e[t])){i=t;break}if(t===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(n(e[e.length-1]))for(let t=e.length;t--;)if(!n(e[t])){s=t+1;break}return i?s?{res:e.slice(i,s),ranges:[[0,i],[s,e.length]]}:{res:e.slice(i),ranges:[[0,i]]}:s?{res:e.slice(0,s),ranges:[[s,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}
133
+ * {@link https://codsen.com/os/string-match-left-right/}
134
+ */
107
135
  /**
108
136
  * @name string-remove-duplicate-heads-tails
109
137
  * @fileoverview Detect and (recursively) remove head and tail wrappings around the input string
110
- * @version 6.0.6
138
+ * @version 6.0.12
111
139
  * @author Roy Revelt, Codsen Ltd
112
140
  * @license MIT
113
141
  * {@link https://codsen.com/os/string-remove-duplicate-heads-tails/}
114
- */const Q=Object.prototype.hasOwnProperty,X={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function Y(e){return"string"==typeof e}function Z(e){return"boolean"==typeof e}function ee(e){return null===e}function te(e){return e&&"object"==typeof e&&!Array.isArray(e)}function re(e){return null!=e}function ne(e){return Y(e)?e.trim():e}function ie(e){if("string"==typeof e&&e.length>0&&-1!==e.indexOf("."))for(let t=0,r=e.length;t<r;t++)if("."===e[t])return e.slice(t+1);return e}function se(e){if("string"==typeof e&&e.length>0&&-1!==e.indexOf("."))for(let t=e.length;t--;)if("."===e[t])return e.slice(0,t);return e}function oe(e){if("string"==typeof e&&e.length>0&&-1!==e.indexOf("."))for(let t=e.length;t--;)if("."===e[t])return e.slice(t+1);return e}function ae(e,t){return!("string"!=typeof e||!e.trim())&&!!(e.includes(t.heads)||e.includes(t.tails)||Y(t.headsNoWrap)&&t.headsNoWrap.length>0&&e.includes(t.headsNoWrap)||Y(t.tailsNoWrap)&&t.tailsNoWrap.length>0&&e.includes(t.tailsNoWrap))}function le(e,t,r=!1,n,i,s){if(t.wrapHeadsWith||(t.wrapHeadsWith=""),t.wrapTailsWith||(t.wrapTailsWith=""),Y(e)&&!r&&t.wrapGlobalFlipSwitch&&!t.dontWrapVars.some((e=>w(s,e)))&&(!t.preventDoubleWrapping||t.preventDoubleWrapping&&Y(e)&&!e.includes(t.wrapHeadsWith)&&!e.includes(t.wrapTailsWith)))return t.wrapHeadsWith+e+t.wrapTailsWith;if(r){if(!Y(e))return e;const r=function(e,t){const r=Object.prototype.hasOwnProperty;if(void 0===e)throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_01] The input is missing!");if("string"!=typeof e)return e;if(t&&!c(t))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof t}!`);const n={...t};if(n&&r.call(n,"heads")){if(!T(n.heads).every((e=>"string"==typeof e||Array.isArray(e))))throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_04] The opts.heads contains elements which are not string-type!");"string"==typeof n.heads&&(n.heads=T(n.heads))}if(n&&r.call(n,"tails")){if(!T(n.tails).every((e=>"string"==typeof e||Array.isArray(e))))throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_05] The opts.tails contains elements which are not string-type!");"string"==typeof n.tails&&(n.tails=T(n.tails))}const i=K(e).res;if(0===i.length)return e;e=i;const s={heads:["{{"],tails:["}}"],...n};s.heads=s.heads.map((e=>e.trim())),s.tails=s.tails.map((e=>e.trim()));let o=!1,a=!1;const l=new P({limitToBeAddedWhitespace:!0}),u=new P({limitToBeAddedWhitespace:!0});let f=!0,h=!0,g="";function p(e,t){let r;return E(e,0,t.heads,{trimBeforeMatching:!0,cb:(e,t,n)=>(r=n,!0)})&&E(e,r,t.tails,{trimBeforeMatching:!0,cb:(e,t,n)=>(r=n,!0)})?e.slice(r):e}for(;e!==p(e,s);)e=K(p(e,s)).res;function y(e,t){let r;return j(e,e.length-1,t.tails,{trimBeforeMatching:!0,cb:(e,t,n)=>(r=n,!0)})&&r&&j(e,r,t.heads,{trimBeforeMatching:!0,cb:(e,t,n)=>(r=n,!0)})?e.slice(0,r+1):e}for(;e!==y(e,s);)e=K(y(e,s)).res;if(!(s.heads.length&&E(e,0,s.heads,{trimBeforeMatching:!0})&&s.tails.length&&j(e,e.length-1,s.tails,{trimBeforeMatching:!0})))return K(e).res;for(let t=0,r=e.length;t<r;t++)if(""===e[t].trim());else{let r;if(E(e,t,s.heads,{trimBeforeMatching:!0,cb:(e,t,n)=>(r=n,!0)})&&r){let n;h=!0,f&&(f=!0),E(e,r,s.tails,{trimBeforeMatching:!0,cb:(e,t,r)=>(n=r,!0)})&&l.push(t,n),u.current()&&o&&"tails"!==g&&l.push(u.current()),o||u.current()&&(l.push(u.current()),u.wipe()),u.push(t,r),g="heads",t=r-1;continue}if(E(e,t,s.tails,{trimBeforeMatching:!0,cb:(t,n,i)=>(r=Number.isInteger(i)?i:e.length,!0)})&&r){h=!0,f?("heads"===g&&u.wipe(),f=!1):u.push(t,r),g="tails",t=r-1;continue}f&&(f=!0),h&&!o?(o=!0,h=!1):h&&!a?(a=!0,f=!0,h=!1,"heads"===g&&u.wipe()):h&&a&&u.wipe()}return u.current()&&l.push(u.current()),l.current()?z(e,l.current()).trim():e.trim()}(e,{heads:t.wrapHeadsWith,tails:t.wrapTailsWith});return Y(r)?function(e,t,r){let n,i;return"string"==typeof e&&e.length>0&&E(e,0,t,{trimBeforeMatching:!0,cb:(e,t,r)=>(n=r,!0)})&&j(e,e.length-1,r,{trimBeforeMatching:!0,cb:(e,t,r)=>(i=r+1,!0)})?e.slice(n,i):e}(r,t.wrapHeadsWith,t.wrapTailsWith):r}return e}function ue(e,t,r,n){let i;if(-1!==r.indexOf(".")){let s=r,o=!0;if(n.lookForDataContainers&&"string"==typeof n.dataContainerIdentifierTails&&n.dataContainerIdentifierTails.length>0&&!s.endsWith(n.dataContainerIdentifierTails)){const r=_.get(e,s+n.dataContainerIdentifierTails);te(r)&&_.get(r,t)&&(i=_.get(r,t),o=!1)}for(;o&&-1!==s.indexOf(".");){if(s=se(s),oe(s)===t)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop. The parent key "${oe(s)}" is called the same as the variable "${t}" we're looking for.`);if(n.lookForDataContainers&&"string"==typeof n.dataContainerIdentifierTails&&n.dataContainerIdentifierTails.length>0&&!s.endsWith(n.dataContainerIdentifierTails)){const r=_.get(e,s+n.dataContainerIdentifierTails);te(r)&&_.get(r,t)&&(i=_.get(r,t),o=!1)}if(void 0===i){const r=_.get(e,s);te(r)&&_.get(r,t)&&(i=_.get(r,t),o=!1)}}}if(void 0===i){const r=_.get(e,t);void 0!==r&&(i=r)}if(void 0===i)if(-1===t.indexOf(".")){const n=H(e,t);if(n.length>0)for(let e=0,s=n.length;e<s;e++){if(Y(n[e].val)||Z(n[e].val)||ee(n[e].val)){i=n[e].val;break}if("number"==typeof n[e].val){i=String(n[e].val);break}if(Array.isArray(n[e].val)){i=n[e].val.join("");break}throw new Error(`json-variables/findValues(): [THROW_ID_21] While trying to resolve: "${t}" at path "${r}", we actually found the key named ${t}, but it was not equal to a string but to:\n${JSON.stringify(n[e],null,4)}\nWe can't resolve a string with that! It should be a string.`)}}else{const r=H(e,function(e){if("string"==typeof e&&e.length>0&&-1!==e.indexOf("."))for(let t=0,r=e.length;t<r;t++)if("."===e[t])return e.slice(0,t);return e}(t));if(r.length>0)for(let e=0,n=r.length;e<n;e++){const n=_.get(r[e].val,ie(t));n&&Y(n)&&(i=n)}}return i}function fe(e,t,r,n,i=[]){if(i.includes(r)){let e="";if(i.length>1){const t=" →\n";e=i.reduce(((e,n,i)=>e+(0===i?"":t)+(n===r?"💥 ":" ")+n)," Here's the path we travelled up until we hit the recursion:\n\n"),e+=`${t}💥 ${r}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop, the key is referencing itself."${e}`)}const s={},o=Array.from(i);o.push(r);const a=new P;function l(i,l,u){for(let f=0,h=i.length;f<h;f++){const h=i[f],c=t.slice(h.headsEndAt,h.tailsStartAt);if(0===c.length)a.push(h.headsStartAt,h.tailsEndAt);else if(Q.call(s,c)&&Y(s[c]))a.push(h.headsStartAt,h.tailsEndAt,s[c]);else{let i=ue(e,c.trim(),r,n);if(void 0===i)if(!0===n.allowUnresolved)i="";else{if("string"!=typeof n.allowUnresolved)throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${t.slice(h.headsEndAt,h.tailsStartAt)}. We're at path: "${r}".`);i=n.allowUnresolved}if(!u&&n.throwWhenNonStringInsertedInString&&!Y(i))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${t.slice(h.headsEndAt,h.tailsStartAt)} at path ${r}, it resolved into a non-string value, ${JSON.stringify(i,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(Z(i)){if(n.resolveToBoolIfAnyValuesContainBool)return a.wipe(),!n.resolveToFalseIfAnyValuesContainBool&&i;i=""}else{if(ee(i)&&u)return a.wipe(),i;i=Array.isArray(i)?String(i.join("")):ee(i)?"":String(i)}const f=r.includes(".")?`${se(r)}.${c}`:c;if(ae(i,n)){const t=le(fe(e,i,f,n,o),n,l,0,0,c.trim());Y(t)&&a.push(h.headsStartAt,h.tailsEndAt,t)}else{s[c]=i;const e=le(i,n,l,0,0,c.trim());Y(e)&&a.push(h.headsStartAt,h.tailsEndAt,e)}}}}let u;try{u=N(t,n.heads,n.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(e){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${t}" at path ${r}, something wrong with heads and tails was detected! Here's the internal error message:\n${e}`)}let f=!1;1===u.length&&""===z(t,[[u[0].headsStartAt,u[0].tailsEndAt]]).trim()&&(f=!0);const h=l(u,!1,f);if(Z(h))return h;if(ee(h))return h;try{u=N(t,n.headsNoWrap,n.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(e){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${t}" at path ${r}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:\n${e}`)}1===u.length&&""===z(t,[[u[0].headsStartAt,u[0].tailsEndAt]]).trim()&&(f=!0);const c=l(u,!0,f);return Z(c)||ee(c)?c:a&&a.current()?z(t,a.current()):t}e.defaults=X,e.jVar=function(e,t){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!te(e))throw new TypeError("json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: "+(Array.isArray(e)?"array":typeof e));if(t&&!te(t))throw new TypeError("json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: "+(Array.isArray(t)?"array":typeof t));const r={...X,...t};let n,i,s;if(r.dontWrapVars?Array.isArray(r.dontWrapVars)||(r.dontWrapVars=T(r.dontWrapVars)):r.dontWrapVars=[],r.dontWrapVars.length>0&&!r.dontWrapVars.every(((e,t)=>!!Y(e)||(n=e,i=t,!1))))throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in opts.dontWrapVars should be of a string type. Computer detected a value "${n}" at index ${i}, which is not string but ${Array.isArray(n)?"array":typeof n}!`);if(""===r.heads)throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! opts.heads are empty!");if(""===r.tails)throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! opts.tails are empty!");if(r.lookForDataContainers&&""===r.dataContainerIdentifierTails)throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! opts.dataContainerIdentifierTails is empty!");if(r.heads===r.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! opts.heads and opts.tails can't be equal!");if(r.heads===r.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! opts.heads and opts.headsNoWrap can't be equal!");if(r.tails===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! opts.tails and opts.tailsNoWrap can't be equal!");if(""===r.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! opts.headsNoWrap is an empty string!");if(""===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! opts.tailsNoWrap is an empty string!");if(r.headsNoWrap===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! opts.headsNoWrap and opts.tailsNoWrap can't be equal!");return p(e,((t,n,i)=>{if(re(n)&&ae(t,r))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!\nPlease check the following key: ${t}`);if(s=void 0!==n?n:t,""===s)return s;if(0!==r.heads.length&&ne(s)===ne(r.heads)||0!==r.tails.length&&ne(s)===ne(r.tails)||0!==r.headsNoWrap.length&&ne(s)===ne(r.headsNoWrap)||0!==r.tailsNoWrap.length&&ne(s)===ne(r.tailsNoWrap)){if(!r.noSingleMarkers)return s;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${ne(s)} which is equal to ${ne(s)===ne(r.heads)?"heads":""}${ne(s)===ne(r.tails)?"tails":""}${Y(r.headsNoWrap)&&ne(s)===ne(r.headsNoWrap)?"headsNoWrap":""}${Y(r.tailsNoWrap)&&ne(s)===ne(r.tailsNoWrap)?"tailsNoWrap":""}. If you wouldn't have set opts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${ne(s)}) alone`)}return Y(s)&&ae(s,r)?fe(e,s,i.path,r):s}))},e.version="11.0.6",Object.defineProperty(e,"__esModule",{value:!0})}));
142
+ */
143
+ /**
144
+ * @name string-trim-spaces-only
145
+ * @fileoverview Like String.trim() but you can choose granularly what to trim
146
+ * @version 4.0.12
147
+ * @author Roy Revelt, Codsen Ltd
148
+ * @license MIT
149
+ * {@link https://codsen.com/os/string-trim-spaces-only/}
150
+ */
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { jVar } from "../dist/json-variables.esm.js";
5
6
 
6
7
  assert.deepEqual(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-variables",
3
- "version": "11.0.6",
3
+ "version": "11.0.12",
4
4
  "description": "Resolves custom-marked, cross-referenced paths in parsed JSON",
5
5
  "keywords": [
6
6
  "comb",
@@ -40,35 +40,31 @@
40
40
  },
41
41
  "types": "types/index.d.ts",
42
42
  "scripts": {
43
- "build": "rollup -c",
44
- "build:esbuild": "node '../../scripts/esbuild.js'",
45
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
46
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
47
- "clean_types": "../../scripts/cleanTypes.js",
48
- "dev": "rollup -c --dev",
49
- "devunittest": "npm run dev && tap --only -R 'base'",
50
- "format": "npm run lect && npm run prettier && npm run lint",
51
- "lect": "lect",
52
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
53
- "perf": "node perf/check",
54
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
55
- "republish": "npm publish || :",
56
- "tap": "tap",
57
- "pretest": "npm run build",
58
- "test": "npm run test:ci && npm run perf",
59
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
60
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
61
- "tsc": "tsc",
62
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
43
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
44
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
45
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
46
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
47
+ "examples": "node '../../ops/scripts/run-examples.js'",
48
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
49
+ "letspublish": "yarn publish || :",
50
+ "lint": "eslint . --fix",
51
+ "perf": "node perf/check.js",
52
+ "prepare": "echo 'ready'",
53
+ "prettier": "prettier",
54
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
55
+ "pretest": "yarn run lect && yarn run build",
56
+ "test": "yarn run devtest",
57
+ "unit": "uvu test"
63
58
  },
64
- "tap": {
65
- "check-coverage": false,
66
- "node-arg": [
67
- "--no-warnings",
68
- "--experimental-loader",
69
- "@istanbuljs/esm-loader-hook"
59
+ "engines": {
60
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
61
+ },
62
+ "c8": {
63
+ "check-coverage": true,
64
+ "exclude": [
65
+ "**/test/**/*.*"
70
66
  ],
71
- "timeout": 0
67
+ "lines": 100
72
68
  },
73
69
  "lect": {
74
70
  "licence": {
@@ -76,63 +72,18 @@
76
72
  ""
77
73
  ]
78
74
  },
79
- "req": "{ jVar }",
80
- "various": {
81
- "devDependencies": []
82
- }
75
+ "various": {}
83
76
  },
84
77
  "dependencies": {
85
- "@babel/runtime": "^7.16.3",
86
- "arrayiffy-if-string": "^4.0.6",
87
- "ast-get-values-by-key": "^4.0.6",
88
- "ast-monkey-traverse": "^3.0.6",
78
+ "arrayiffy-if-string": "^4.0.12",
79
+ "ast-get-values-by-key": "^4.0.12",
80
+ "ast-monkey-traverse": "^3.0.12",
89
81
  "matcher": "^5.0.0",
90
82
  "object-path": "^0.11.8",
91
- "ranges-apply": "^6.0.6",
92
- "ranges-push": "^6.0.6",
93
- "string-find-heads-tails": "^5.0.6",
94
- "string-match-left-right": "^8.0.6",
95
- "string-remove-duplicate-heads-tails": "^6.0.6"
96
- },
97
- "devDependencies": {
98
- "@babel/cli": "^7.16.0",
99
- "@babel/core": "^7.16.0",
100
- "@babel/node": "^7.16.0",
101
- "@babel/plugin-external-helpers": "^7.16.0",
102
- "@babel/plugin-proposal-class-properties": "^7.16.0",
103
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
104
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
105
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
106
- "@babel/plugin-transform-runtime": "^7.16.4",
107
- "@babel/preset-env": "^7.16.4",
108
- "@babel/preset-typescript": "^7.16.0",
109
- "@babel/register": "^7.16.0",
110
- "@istanbuljs/esm-loader-hook": "^0.1.2",
111
- "@rollup/plugin-babel": "^5.3.0",
112
- "@rollup/plugin-commonjs": "^21.0.1",
113
- "@rollup/plugin-json": "^4.1.0",
114
- "@rollup/plugin-node-resolve": "^13.0.6",
115
- "@rollup/plugin-strip": "^2.1.0",
116
- "@rollup/plugin-typescript": "^8.3.0",
117
- "@types/node": "^16.11.9",
118
- "@types/tap": "^15.0.5",
119
- "@typescript-eslint/eslint-plugin": "^5.4.0",
120
- "@typescript-eslint/parser": "^5.4.0",
121
- "core-js": "^3.19.1",
122
- "cross-env": "^7.0.3",
123
- "eslint": "^8.3.0",
124
- "lect": "^0.18.6",
125
- "rollup": "^2.60.0",
126
- "rollup-plugin-ascii": "^0.0.3",
127
- "rollup-plugin-banner": "^0.2.1",
128
- "rollup-plugin-cleanup": "^3.2.1",
129
- "rollup-plugin-dts": "^4.0.1",
130
- "rollup-plugin-terser": "^7.0.2",
131
- "tap": "^15.1.2",
132
- "tslib": "^2.3.1",
133
- "typescript": "^4.5.2"
134
- },
135
- "engines": {
136
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
83
+ "ranges-apply": "^6.0.12",
84
+ "ranges-push": "^6.0.12",
85
+ "string-find-heads-tails": "^5.0.12",
86
+ "string-match-left-right": "^8.0.12",
87
+ "string-remove-duplicate-heads-tails": "^6.0.12"
137
88
  }
138
89
  }
package/types/index.d.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  declare const version: string;
2
2
  interface Obj {
3
- [key: string]: any;
3
+ [key: string]: any;
4
4
  }
5
5
  interface Opts {
6
- heads: string;
7
- tails: string;
8
- headsNoWrap: string;
9
- tailsNoWrap: string;
10
- lookForDataContainers: boolean;
11
- dataContainerIdentifierTails: string;
12
- wrapHeadsWith: string | string[];
13
- wrapTailsWith: string | string[];
14
- dontWrapVars: string[];
15
- preventDoubleWrapping: boolean;
16
- wrapGlobalFlipSwitch: boolean;
17
- noSingleMarkers: boolean;
18
- resolveToBoolIfAnyValuesContainBool: boolean;
19
- resolveToFalseIfAnyValuesContainBool: boolean;
20
- throwWhenNonStringInsertedInString: boolean;
21
- allowUnresolved: boolean;
6
+ heads: string;
7
+ tails: string;
8
+ headsNoWrap: string;
9
+ tailsNoWrap: string;
10
+ lookForDataContainers: boolean;
11
+ dataContainerIdentifierTails: string;
12
+ wrapHeadsWith: string | string[];
13
+ wrapTailsWith: string | string[];
14
+ dontWrapVars: string[];
15
+ preventDoubleWrapping: boolean;
16
+ wrapGlobalFlipSwitch: boolean;
17
+ noSingleMarkers: boolean;
18
+ resolveToBoolIfAnyValuesContainBool: boolean;
19
+ resolveToFalseIfAnyValuesContainBool: boolean;
20
+ throwWhenNonStringInsertedInString: boolean;
21
+ allowUnresolved: boolean | string;
22
22
  }
23
23
  declare const defaults: Opts;
24
24
  /**
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; jVar &#x7D; from \"json-variables\";\n\nassert.deepEqual(\n jVar(&#x7B;\n a: \"some text %%_var1.key1.0_%% more text %%_var2.key2.key3.1_%%\",\n b: \"something\",\n var1: &#x7B; key1: [\"value1\"] &#x7D;,\n var2: &#x7B; key2: &#x7B; key3: [\"\", \"value2\"] &#x7D; &#x7D;,\n &#x7D;),\n &#x7B;\n a: \"some text value1 more text value2\",\n b: \"something\",\n var1: &#x7B; key1: [\"value1\"] &#x7D;,\n var2: &#x7B; key2: &#x7B; key3: [\"\", \"value2\"] &#x7D; &#x7D;,\n &#x7D;\n);"}}