json-variables 12.0.23 → 12.0.33
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/dist/json-variables.esm.js +2 -2
- package/dist/json-variables.umd.js +16 -52
- package/package.json +15 -12
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name json-variables
|
|
3
3
|
* @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
|
|
4
|
-
* @version 12.0.
|
|
4
|
+
* @version 12.0.33
|
|
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{matchLeftIncl as k,matchRightIncl as x}from"string-match-left-right";import{remDup as F}from"string-remove-duplicate-heads-tails";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{arrayiffy as B}from"arrayiffy-if-string";import{traverse as L}from"ast-monkey-traverse";import{rApply as O}from"ranges-apply";import h from"object-path";import{Ranges as U}from"ranges-push";import{isMatch as M}from"matcher";import{isPlainObject as w,existy as q,isBool as A,isNull as N,isStr as o,isNum as K}from"codsen-utils";var j="12.0.
|
|
10
|
+
import{matchLeftIncl as k,matchRightIncl as x}from"string-match-left-right";import{remDup as F}from"string-remove-duplicate-heads-tails";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{arrayiffy as B}from"arrayiffy-if-string";import{traverse as L}from"ast-monkey-traverse";import{rApply as O}from"ranges-apply";import h from"object-path";import{Ranges as U}from"ranges-push";import{isMatch as M}from"matcher";import{isPlainObject as w,existy as q,isBool as A,isNull as N,isStr as o,isNum as K}from"codsen-utils";var j="12.0.33";var ce=j,G=Object.prototype.hasOwnProperty,z={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 g(r){return o(r)?r.trim():r}function Y(r){if(o(r)&&r.length&&r.indexOf(".")!==-1){for(let e=0,t=r.length;e<t;e++)if(r[e]===".")return r.slice(0,e)}return r}function Q(r){if(o(r)&&r.length&&r.indexOf(".")!==-1){for(let e=0,t=r.length;e<t;e++)if(r[e]===".")return r.slice(e+1)}return r}function J(r){if(o(r)&&r.length&&r.indexOf(".")!==-1){for(let e=r.length;e--;)if(r[e]===".")return r.slice(0,e)}return r}function P(r){if(o(r)&&r.length&&r.indexOf(".")!==-1){for(let e=r.length;e--;)if(r[e]===".")return r.slice(e+1)}return r}function T(r,e){return!o(r)||!r.trim()?!1:!!(r.includes(e.heads)||r.includes(e.tails)||o(e.headsNoWrap)&&e.headsNoWrap.length&&r.includes(e.headsNoWrap)||o(e.tailsNoWrap)&&e.tailsNoWrap.length&&r.includes(e.tailsNoWrap))}function X(r,e,t){let l,s;return o(r)&&r.length&&x(r,0,e,{trimBeforeMatching:!0,cb:(n,a,i)=>(l=i,!0)})&&k(r,r.length-1,t,{trimBeforeMatching:!0,cb:(n,a,i)=>(s=(i||0)+1,!0)})?r.slice(l,s):r}function H(r,e,t=!1,l,s,n){if(e.wrapHeadsWith||(e.wrapHeadsWith=""),e.wrapTailsWith||(e.wrapTailsWith=""),o(r)&&!t&&e.wrapGlobalFlipSwitch&&!e.dontWrapVars.some(a=>M(n,a))&&(!e.preventDoubleWrapping||e.preventDoubleWrapping&&o(r)&&!r.includes(e.wrapHeadsWith)&&!r.includes(e.wrapTailsWith)))return`${e.wrapHeadsWith}${r}${e.wrapTailsWith}`;if(t){if(!o(r))return r;let a=F(r,{heads:e.wrapHeadsWith,tails:e.wrapTailsWith});return o(a)?X(a,e.wrapHeadsWith,e.wrapTailsWith):a}return r}function Z(r,e,t,l){let s;if(t.indexOf(".")!==-1){let n=t,a=!0;if(l.lookForDataContainers&&o(l.dataContainerIdentifierTails)&&l.dataContainerIdentifierTails.length&&!n.endsWith(l.dataContainerIdentifierTails)){let i=h.get(r,n+l.dataContainerIdentifierTails);w(i)&&h.get(i,e)&&(s=h.get(i,e),a=!1)}for(;a&&n.indexOf(".")!==-1;){if(n=J(n),P(n)===e)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${e}" at path "${t}", we encountered a closed loop. The parent key "${P(n)}" is called the same as the variable "${e}" we're looking for.`);if(l.lookForDataContainers&&o(l.dataContainerIdentifierTails)&&l.dataContainerIdentifierTails.length&&!n.endsWith(l.dataContainerIdentifierTails)){let i=h.get(r,n+l.dataContainerIdentifierTails);w(i)&&h.get(i,e)&&(s=h.get(i,e),a=!1)}if(s===void 0){let i=h.get(r,n);w(i)&&h.get(i,e)&&(s=h.get(i,e),a=!1)}}}if(s===void 0){let n=h.get(r,e);n!==void 0&&(s=n)}if(s===void 0)if(e.indexOf(".")===-1){let n=_(r,e);if(n.length){for(let a=0,i=n.length;a<i;a++)if(o(n[a].val)||A(n[a].val)||N(n[a].val)){s=n[a].val;break}else if(K(n[a].val)){s=String(n[a].val);break}else if(Array.isArray(n[a].val)){s=n[a].val.join("");break}}}else{let n=_(r,Y(e));if(n.length)for(let a=0,i=n.length;a<i;a++){let m=h.get(n[a].val,Q(e));m&&o(m)&&(s=m)}}return s}function R(r,e,t,l,s=[]){if(s.includes(t)){let c="";if(s.length>1){let y=` \u2192
|
|
11
11
|
`;c=s.reduce((D,b,S)=>D+(S===0?"":y)+(b===t?"\u{1F4A5} ":" ")+b,` Here's the path we travelled up until we hit the recursion:
|
|
12
12
|
|
|
13
13
|
`),c+=`${y}\u{1F4A5} ${t}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${e}" at path "${t}", we encountered a closed loop, the key is referencing itself."${c}`)}let n={},a=Array.from(s);a.push(t);let i=new U;function m(c,y,D){for(let b=0,S=c.length;b<S;b++){let f=c[b],p=e.slice(f.headsEndAt,f.tailsStartAt);if(p.length===0)i.push(f.headsStartAt,f.tailsEndAt);else if(G.call(n,p)&&o(n[p]))i.push(f.headsStartAt,f.tailsEndAt,n[p]);else{let u=Z(r,p.trim(),t,l);if(u===void 0)if(l.allowUnresolved===!0)u="";else if(o(l.allowUnresolved))u=l.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${e.slice(f.headsEndAt,f.tailsStartAt)}. We're at path: "${t}".`);if(!D&&l.throwWhenNonStringInsertedInString&&!o(u))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${e.slice(f.headsEndAt,f.tailsStartAt)} at path ${t}, it resolved into a non-string value, ${JSON.stringify(u,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(A(u)){if(l.resolveToBoolIfAnyValuesContainBool)return i.wipe(),l.resolveToFalseIfAnyValuesContainBool?!1:u;u=""}else{if(N(u)&&D)return i.wipe(),u;Array.isArray(u)?u=String(u.join("")):N(u)?u="":u=String(u)}let v=t.includes(".")?`${J(t)}.${p}`:p;if(T(u,l)){let V=H(R(r,u,v,l,a),l,y,a,v,p.trim());o(V)&&i.push(f.headsStartAt,f.tailsEndAt,V)}else{n[p]=u;let V=H(u,l,y,a,v,p.trim());o(V)&&i.push(f.headsStartAt,f.tailsEndAt,V)}}}}let d;try{d=I(e,l.heads,l.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${e}" at path ${t}, something wrong with heads and tails was detected! Here's the internal error message:
|
|
@@ -1,53 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name json-variables
|
|
3
3
|
* @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
|
|
4
|
-
* @version 12.0.
|
|
4
|
+
* @version 12.0.33
|
|
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
|
-
"use strict";var jsonVariables=(()=>{var Ve=Object.create;var j=Object.defineProperty,He=Object.defineProperties,Ce=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertyNames,ae=Object.getOwnPropertySymbols,Be=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var Q=(e,r,n)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,O=(e,r)=>{for(var n in r||(r={}))oe.call(r,n)&&Q(e,n,r[n]);if(ae)for(var n of ae(r))Pe.call(r,n)&&Q(e,n,r[n]);return e},M=(e,r)=>He(e,je(r));var le=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Je=(e,r)=>{for(var n in r)j(e,n,{get:r[n],enumerable:!0})},ue=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of Me(r))!oe.call(e,f)&&f!==n&&j(e,f,{get:()=>r[f],enumerable:!(i=Ce(r,f))||i.enumerable});return e};var k=(e,r,n)=>(n=e!=null?Ve(Be(e)):{},ue(r||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),ke=e=>ue(j({},"__esModule",{value:!0}),e);var Z=(e,r,n)=>Q(e,typeof r!="symbol"?r+"":r,n);var F=le((gr,fe)=>{"use strict";fe.exports=Fe;function R(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Fe(e){if(e=e||{},e.circles)return Le(e);let r=new Map;if(r.set(Date,s=>new Date(s)),r.set(Map,(s,o)=>new Map(i(Array.from(s),o))),r.set(Set,(s,o)=>new Set(i(Array.from(s),o))),e.constructorHandlers)for(let s of e.constructorHandlers)r.set(s[0],s[1]);let n=null;return e.proto?t:f;function i(s,o){let u=Object.keys(s),l=new Array(u.length);for(let a=0;a<u.length;a++){let c=u[a],$=s[c];typeof $!="object"||$===null?l[c]=$:$.constructor!==Object&&(n=r.get($.constructor))?l[c]=n($,o):ArrayBuffer.isView($)?l[c]=R($):l[c]=o($)}return l}function f(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return i(s,f);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,f);let o={};for(let u in s){if(Object.hasOwnProperty.call(s,u)===!1)continue;let l=s[u];typeof l!="object"||l===null?o[u]=l:l.constructor!==Object&&(n=r.get(l.constructor))?o[u]=n(l,f):ArrayBuffer.isView(l)?o[u]=R(l):o[u]=f(l)}return o}function t(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return i(s,t);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,t);let o={};for(let u in s){let l=s[u];typeof l!="object"||l===null?o[u]=l:l.constructor!==Object&&(n=r.get(l.constructor))?o[u]=n(l,t):ArrayBuffer.isView(l)?o[u]=R(l):o[u]=t(l)}return o}}function Le(e){let r=[],n=[],i=new Map;if(i.set(Date,u=>new Date(u)),i.set(Map,(u,l)=>new Map(t(Array.from(u),l))),i.set(Set,(u,l)=>new Set(t(Array.from(u),l))),e.constructorHandlers)for(let u of e.constructorHandlers)i.set(u[0],u[1]);let f=null;return e.proto?o:s;function t(u,l){let a=Object.keys(u),c=new Array(a.length);for(let $=0;$<a.length;$++){let d=a[$],h=u[d];if(typeof h!="object"||h===null)c[d]=h;else if(h.constructor!==Object&&(f=i.get(h.constructor)))c[d]=f(h,l);else if(ArrayBuffer.isView(h))c[d]=R(h);else{let y=r.indexOf(h);y!==-1?c[d]=n[y]:c[d]=l(h)}}return c}function s(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return t(u,s);if(u.constructor!==Object&&(f=i.get(u.constructor)))return f(u,s);let l={};r.push(u),n.push(l);for(let a in u){if(Object.hasOwnProperty.call(u,a)===!1)continue;let c=u[a];if(typeof c!="object"||c===null)l[a]=c;else if(c.constructor!==Object&&(f=i.get(c.constructor)))l[a]=f(c,s);else if(ArrayBuffer.isView(c))l[a]=R(c);else{let $=r.indexOf(c);$!==-1?l[a]=n[$]:l[a]=s(c)}}return r.pop(),n.pop(),l}function o(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return t(u,o);if(u.constructor!==Object&&(f=i.get(u.constructor)))return f(u,o);let l={};r.push(u),n.push(l);for(let a in u){let c=u[a];if(typeof c!="object"||c===null)l[a]=c;else if(c.constructor!==Object&&(f=i.get(c.constructor)))l[a]=f(c,o);else if(ArrayBuffer.isView(c))l[a]=R(c);else{let $=r.indexOf(c);$!==-1?l[a]=n[$]:l[a]=o(c)}}return r.pop(),n.pop(),l}}});var We=le((Ie,z)=>{(function(e,r){"use strict";typeof z=="object"&&typeof z.exports=="object"?z.exports=r():typeof define=="function"&&define.amd?define([],r):e.objectPath=r()})(Ie,function(){"use strict";var e=Object.prototype.toString;function r(a,c){return a==null?!1:Object.prototype.hasOwnProperty.call(a,c)}function n(a){if(!a||t(a)&&a.length===0)return!0;if(typeof a!="string"){for(var c in a)if(r(a,c))return!1;return!0}return!1}function i(a){return e.call(a)}function f(a){return typeof a=="object"&&i(a)==="[object Object]"}var t=Array.isArray||function(a){return e.call(a)==="[object Array]"};function s(a){return typeof a=="boolean"||i(a)==="[object Boolean]"}function o(a){var c=parseInt(a);return c.toString()===a?c:a}function u(a){a=a||{};var c=function(m){return Object.keys(c).reduce(function(g,p){return p==="create"||typeof c[p]=="function"&&(g[p]=c[p].bind(c,m)),g},{})},$;a.includeInheritedProps?$=function(){return!0}:$=function(m,g){return typeof g=="number"&&Array.isArray(m)||r(m,g)};function d(m,g){if($(m,g))return m[g]}var h;a.includeInheritedProps?h=function(m,g){typeof g!="string"&&typeof g!="number"&&(g=String(g));var p=d(m,g);if(g==="__proto__"||g==="prototype"||g==="constructor"&&typeof p=="function")throw new Error("For security reasons, object's magic properties cannot be set");return p}:h=function(m,g){return d(m,g)};function y(m,g,p,b){if(typeof g=="number"&&(g=[g]),!g||g.length===0)return m;if(typeof g=="string")return y(m,g.split(".").map(o),p,b);var w=g[0],v=h(m,w);return g.length===1?((v===void 0||!b)&&(m[w]=p),v):(v===void 0&&(typeof g[1]=="number"?m[w]=[]:m[w]={}),y(m[w],g.slice(1),p,b))}return c.has=function(m,g){if(typeof g=="number"?g=[g]:typeof g=="string"&&(g=g.split(".")),!g||g.length===0)return!!m;for(var p=0;p<g.length;p++){var b=o(g[p]);if(typeof b=="number"&&t(m)&&b<m.length||(a.includeInheritedProps?b in Object(m):r(m,b)))m=m[b];else return!1}return!0},c.ensureExists=function(m,g,p){return y(m,g,p,!0)},c.set=function(m,g,p,b){return y(m,g,p,b)},c.insert=function(m,g,p,b){var w=c.get(m,g);b=~~b,t(w)||(w=[],c.set(m,g,w)),w.splice(b,0,p)},c.empty=function(m,g){if(!n(g)&&m!=null){var p,b;if(p=c.get(m,g)){if(typeof p=="string")return c.set(m,g,"");if(s(p))return c.set(m,g,!1);if(typeof p=="number")return c.set(m,g,0);if(t(p))p.length=0;else if(f(p))for(b in p)$(p,b)&&delete p[b];else return c.set(m,g,null)}}},c.push=function(m,g){var p=c.get(m,g);t(p)||(p=[],c.set(m,g,p)),p.push.apply(p,Array.prototype.slice.call(arguments,2))},c.coalesce=function(m,g,p){for(var b,w=0,v=g.length;w<v;w++)if((b=c.get(m,g[w]))!==void 0)return b;return p},c.get=function(m,g,p){if(typeof g=="number"&&(g=[g]),!g||g.length===0)return m;if(m==null)return p;if(typeof g=="string")return c.get(m,g.split("."),p);var b=o(g[0]),w=h(m,b);return w===void 0?p:g.length===1?w:c.get(m[b],g.slice(1),p)},c.del=function(g,p){if(typeof p=="number"&&(p=[p]),g==null||n(p))return g;if(typeof p=="string")return c.del(g,p.split("."));var b=o(p[0]);if(h(g,b),!$(g,b))return g;if(p.length===1)t(g)?g.splice(b,1):delete g[b];else return c.del(g[b],p.slice(1));return g},c}var l=u();return l.create=u,l.withInheritedProps=u({includeInheritedProps:!0}),l})});var ur={};Je(ur,{defaults:()=>_e,jVar:()=>lr,version:()=>tr});function I(e){return typeof e!="string"?e:e.length?[e]:[]}var ce=k(F(),1);var hr=(0,ce.default)();function E(e){if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r!==null&&r!==Object.prototype&&Object.getPrototypeOf(r)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function T(e){return typeof e=="string"}function ge(e){return Number.isFinite(e)}function _(e){return Number.isSafeInteger(e)&&e>=0}function L(e){return typeof e=="boolean"}function B(e){return e===null}function W(e){return e!=null}function he(e,r){return E(e)&&T(r)&&r in e}var pe={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},qe=e=>e+1;function Ue(e,r,n,i,f=!1,t=qe){var b;let s=typeof n=="function"?n():n;if(+r<0&&f&&s==="EOL")return s;let o=O(O({},pe),i);if(r>=e.length&&!f)return!1;let u=f?1:n.length,l=0,a=!1,c=!1,$=!1,d=o.maxMismatches,h=r,y=!1,m=!1,g=!1;function p(){return l===1&&d<o.maxMismatches-1}for(;e[h];){let w=t(h);if(o.trimBeforeMatching&&e[h].trim()===""){if(!e[w]&&f&&n==="EOL")return!0;h=t(h);continue}if(o&&!o.i&&((b=o==null?void 0:o.trimCharsBeforeMatching)!=null&&b.includes(e[h]))||o!=null&&o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.map(S=>S.toLowerCase()).includes(e[h].toLowerCase())){if(f&&n==="EOL"&&!e[w])return!0;h=t(h);continue}let v=w>h?n[n.length-u]:n[u-1];if(!o.i&&e[h]===v||o.i&&e[h].toLowerCase()===v.toLowerCase()){if(y||(y=!0),$||($=!0),u===n.length){if(m=!0,d!==o.maxMismatches)return!1}else u===1&&(g=!0);if(u-=1,l++,p())return!1;if(!u)return l!==n.length||d===o.maxMismatches||!a?h:!1}else if(!a&&!l&&(a=!0),o.maxMismatches&&d&&h){d-=1;for(let S=0;S<=d;S++){let x=w>h?n[n.length-u+1+S]:n[u-2-S],G=e[t(h)];if(x&&(!o.i&&e[h]===x||o.i&&e[h].toLowerCase()===x.toLowerCase())&&(!o.firstMustMatch||u!==n.length)){if(l++,p())return!1;u-=2,y=!0;break}else if(G&&x&&(!o.i&&G===x||o.i&&G.toLowerCase()===x.toLowerCase())&&(!o.firstMustMatch||u!==n.length)){if(!l&&!o.hungry)return!1;u-=1,y=!0;break}else if(x===void 0&&d>=0&&y&&(!o.firstMustMatch||m)&&(!o.lastMustMatch||g))return h}y||(c=h)}else return h===0&&u===1&&!o.lastMustMatch&&$?0:!1;if(c!==!1&&c!==h&&(c=!1),u<1)return h;h=t(h)}if(u>0)return f&&s==="EOL"?!0:o&&o.maxMismatches>=u&&$?c||0:!1}function de(e,r,n,i,f){var a,c,$;if(E(f)&&he(f,"trimBeforeMatching")&&f&&typeof f.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(f.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let t=O(O({},pe),f);if(typeof t.trimCharsBeforeMatching=="string"&&(t.trimCharsBeforeMatching=I(t.trimCharsBeforeMatching)),t.trimCharsBeforeMatching=t.trimCharsBeforeMatching.map(d=>T(d)?d:String(d)),!T(r)||!r.length)return!1;if(!Number.isInteger(n)||n<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 n}, equal to:
|
|
11
|
-
${JSON.stringify(n,null,4)}`);let s,o;if(T(i))s=[i];else if(Array.isArray(i))s=i;else if(!i)s=i;else if(typeof i=="function")s=[],s.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(f&&!E(f))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 f}", and equal to:
|
|
13
|
-
${JSON.stringify(f,null,4)}`);let u=0,l="";if((a=t==null?void 0:t.trimCharsBeforeMatching)!=null&&a.some((d,h)=>d.length>1?(u=h,l=d,!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 ${u} is longer than 1 character, ${l.length} (equals to ${l}). Please split it into separate characters and put into array as separate elements.`);if(!s||!Array.isArray(s)||Array.isArray(s)&&!s.length||Array.isArray(s)&&s.length===1&&T(s[0])&&!s[0].trim()){if(typeof t.cb=="function"){let h,y=n;if((e==="matchLeftIncl"||e==="matchRight")&&(y+=1),e[5]==="L")for(let b=y;b--;){let w=r[b];if((!t.trimBeforeMatching||t.trimBeforeMatching&&(w!=null&&w.trim()))&&(!((c=t.trimCharsBeforeMatching)!=null&&c.length)||w!==void 0&&!t.trimCharsBeforeMatching.includes(w))){h=b;break}}else if(e.startsWith("matchRight"))for(let b=y;b<r.length;b++){let w=r[b];if((!t.trimBeforeMatching||t.trimBeforeMatching&&w.trim())&&(!(($=t.trimCharsBeforeMatching)!=null&&$.length)||!t.trimCharsBeforeMatching.includes(w))){h=b;break}}if(h===void 0)return!1;let m=r[h],g=h+1,p="";return g&&g>0&&(p=r.slice(0,g)),e[5]==="L"||h&&h>0&&(p=r.slice(h)),t.cb(m,p,h)}let d="";throw f||(d=" 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!${d}`)}for(let d=0,h=s.length;d<h;d++){o=typeof s[d]=="function";let y=s[d],m,g,p="",b=n;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let w=Ue(r,b,y,t,o,v=>e[5]==="L"?v-1:v+1);if(w&&o&&typeof y=="function"&&y()==="EOL")return y()&&(!t.cb||t.cb(m,p,g))?y():!1;if(Number.isInteger(w)&&(g=e.startsWith("matchLeft")?w-1:w+1,e[5]==="L"?p=r.slice(0,w):p=r.slice(g)),g<0&&(g=void 0),r[g]&&(m=r[g]),Number.isInteger(w)&&(!t.cb||t.cb(m,p,g)))return y}return!1}function V(e,r,n,i){return de("matchLeftIncl",e,r,n,i)}function D(e,r,n,i){return de("matchRightIncl",e,r,n,i)}function q(e,r=1){let n="\xA0";function i(t){return Array.from(t).reverse().join("")}function f(t,s,o){let u=o?`
|
|
14
|
-
`:"\r",l=o?"\r":`
|
|
15
|
-
`;if(!t)return t;let a=0,c=0,$="";for(let d=0,h=t.length;d<h;d++)(t[d]===u||t[d]===l&&t[d-1]!==u)&&c++,`\r
|
|
16
|
-
`.includes(t[d])||t[d]===n?(a=0,t[d]===n?$+=t[d]:t[d]===u?c<=s&&($+=t[d],t[d+1]===l&&($+=t[d+1],d++)):t[d]===l&&(t==null?void 0:t[d-1])!==u&&c<=s&&($+=t[d])):(a++,!t[d+1]&&!c&&($+=" "));return $}if(typeof e=="string"&&e.length){let t=1;typeof+r=="number"&&Number.isInteger(+r)&&+r>=0&&(t=+r);let s="",o="";if(!e.trim())s=e;else if(!e[0].trim()){for(let u=0,l=e.length;u<l;u++)if(e[u].trim()){s=e.slice(0,u);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let u=e.length;u--;)if(e[u].trim()){o=e.slice(u+1);break}}return`${f(s,t,!1)}${e.trim()}${i(f(i(o),t,!0))}`}return e}var Ke={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function H(e,r){if(!Array.isArray(e)||!e.length)return e;let n=O(O({},Ke),r),i,f;if(n.strictlyTwoElementsInRangeArrays&&!e.every((o,u)=>!Array.isArray(o)||o.length!==2?(i=u,f=o.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 ${f} elements!`);if(!e.every((o,u)=>!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<0||!Number.isInteger(o[1])||o[1]<0?(i=u,!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 t=e.length**2,s=0;return Array.from(e).sort((o,u)=>(n.progressFn&&(s+=1,n.progressFn(Math.floor(s*100/t))),o[0]===u[0]?o[1]<u[1]?-1:o[1]>u[1]?1:0:o[0]<u[0]?-1:1))}var ye={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ze(e,r){var l;function n(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let i;if(r)if(n(r)){if(i=O(O({},ye),r),i.progressFn&&n(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] resolvedOpts.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] resolvedOpts.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] resolvedOpts.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(`ranges-merge: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
17
|
-
${JSON.stringify(r,null,4)} (type ${typeof r})`);else i=O({},ye);let f=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),t,s,o;i.progressFn?t=H(f,{progressFn:a=>{o=Math.floor(a/5),o!==s&&(s=o,i.progressFn!=null&&i.progressFn(o))}}):t=H(f);let u=t.length-1;for(let a=u;a>0;a--)i.progressFn&&(o=Math.floor((1-a/u)*78)+21,o!==s&&o>s&&(s=o,i.progressFn(o))),(t[a][0]<=t[a-1][0]||!i.joinRangesThatTouchEdges&&t[a][0]<t[a-1][1]||i.joinRangesThatTouchEdges&&t[a][0]<=t[a-1][1])&&(t[a-1][0]=Math.min(t[a][0],t[a-1][0]),t[a-1][1]=Math.max(t[a][1],t[a-1][1]),t[a][2]!==void 0&&(t[a-1][0]>=t[a][0]||t[a-1][1]<=t[a][1])&&t[a-1][2]!==null&&(t[a][2]===null&&t[a-1][2]!==null?t[a-1][2]=null:t[a-1][2]!=null?+((l=i||{})==null?void 0:l.mergeType)==2&&t[a-1][0]===t[a][0]?t[a-1][2]=t[a][2]:t[a-1][2]+=t[a][2]:t[a-1][2]=t[a][2]),t.splice(a,1),a=t.length);return t.length?t:null}var Ge={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},P=class{constructor(e){Z(this,"ranges");Z(this,"opts");let r=O(O({},Ge),e);if(r.mergeType&&r.mergeType!==1&&r.mergeType!==2)if(T(r.mergeType)&&r.mergeType.trim()==="1")r.mergeType=1;else if(T(r.mergeType)&&r.mergeType.trim()==="2")r.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 r.mergeType}", equal to ${JSON.stringify(r.mergeType,null,4)}`);this.opts=r,this.ranges=[]}add(e,r,n){var t;if(e==null&&r==null)return;if(W(e)&&!W(r)){if(Array.isArray(e)){if(e.length){if(e.some(s=>Array.isArray(s))){e.forEach(s=>{Array.isArray(s)&&this.add(...s)});return}e.length&&_(+e[0])&&_(+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(r,null,0)})`)}else if(!W(e)&&W(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(r,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let i=+e,f=+r;if(_(n)&&(n=String(n)),_(i)&&_(f)){if(W(n)&&!T(n)&&!_(n))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof n}, equal to:
|
|
18
|
-
${JSON.stringify(n,null,4)}`);if(W(this.ranges)&&Array.isArray(this.last())&&i===this.last()[1]){if(this.last()[1]=f,this.last()[2],this.last()[2]!==null&&W(n)){let s=this.last()[2]&&this.last()[2].length&&(!((t=this.opts)!=null&&t.mergeType)||this.opts.mergeType===1)?`${this.last()[2]}${n}`:n;this.opts.limitToBeAddedWhitespace&&(s=q(s,this.opts.limitLinebreaksCount)),T(s)&&!s.length||(this.last()[2]=s)}}else{this.ranges||(this.ranges=[]);let s=n!==void 0&&!(T(n)&&!n.length)?[i,f,n&&this.opts.limitToBeAddedWhitespace?q(n,this.opts.limitLinebreaksCount):n]:[i,f];this.ranges.push(s)}}else throw _(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 f}" equal to: ${JSON.stringify(f,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,r,n){this.add(e,r,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=ze(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>W(e[2])?[e[0],e[1],q(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])&&_(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 me={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function we(e,r){function n(l){return!!l&&typeof l=="object"&&!Array.isArray(l)}if(!Array.isArray(e)||!e.length)return null;let i;if(r)if(n(r)){if(i=O(O({},me),r),i.progressFn&&n(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:
|
|
19
|
-
${JSON.stringify(r,null,4)} (type ${typeof r})`);else i=O({},me);let f=e.filter(l=>Array.isArray(l)).map(l=>[...l]).filter(l=>l[2]!==void 0||l[0]!==l[1]),t,s,o;i.progressFn?t=H(f,{progressFn:l=>{o=Math.floor(l/5),o!==s&&(s=o,i.progressFn(o))}}):t=H(f);let u=t.length-1;for(let l=u;l>0;l--)i.progressFn&&(o=Math.floor((1-l/u)*78)+21,o!==s&&o>s&&(s=o,i.progressFn(o))),(t[l][0]<=t[l-1][0]||!i.joinRangesThatTouchEdges&&t[l][0]<t[l-1][1]||i.joinRangesThatTouchEdges&&t[l][0]<=t[l-1][1])&&(t[l-1][0]=Math.min(t[l][0],t[l-1][0]),t[l-1][1]=Math.max(t[l][1],t[l-1][1]),t[l][2]!==void 0&&(t[l-1][0]>=t[l][0]||t[l-1][1]<=t[l][1])&&t[l-1][2]!==null&&(t[l][2]===null&&t[l-1][2]!==null?t[l-1][2]=null:t[l-1][2]!=null?+i.mergeType==2&&t[l-1][0]===t[l][0]?t[l-1][2]=t[l][2]:t[l-1][2]+=t[l][2]:t[l-1][2]=t[l][2]),t.splice(l,1),l=t.length);return t.length?t:null}var Qe=!0,Y="Invariant failed";function be(e,r){if(!e){if(Qe)throw new Error(Y);var n=typeof r=="function"?r():r,i=n?"".concat(Y,": ").concat(n):Y;throw new Error(i)}}function C(e,r,n){let i=0,f=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(r&&!Array.isArray(r))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(n&&typeof n!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof n}, equal to: ${JSON.stringify(n,null,4)}`);if(!(r!=null&&r.filter(a=>a).length))return e;let t;Array.isArray(r)&&Number.isInteger(r[0])&&Number.isInteger(r[1])?t=[Array.from(r)]:t=Array.from(r);let s=t.length,o=0;t.filter(a=>a).forEach((a,c)=>{if(n&&(i=Math.floor(o/s*10),i!==f&&(f=i,n(i))),!Array.isArray(a))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${c}th element not an array: ${JSON.stringify(a,null,4)}, which is ${typeof a}`);if(!Number.isInteger(a[0])){if(!Number.isInteger(+a[0])||+a[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(a,null,0)}. Its first element is not an integer, string index, but ${typeof a[0]}, equal to: ${JSON.stringify(a[0],null,4)}.`);t[c][0]=+t[c][0]}if(!Number.isInteger(a[1])){if(!Number.isInteger(+a[1])||+a[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(a,null,0)}. Its second element is not an integer, string index, but ${typeof a[1]}, equal to: ${JSON.stringify(a[1],null,4)}.`);t[c][1]=+t[c][1]}o+=1});let u=we(t,{progressFn:a=>{n&&(i=10+Math.floor(a/10),i!==f&&(f=i,n(i)))}});be(u);let l=u.length;if(l>0){let a=e.slice(u[l-1][1]);e=u.reduce((c,$,d,h)=>{n&&(i=20+Math.floor(d/l*80),i!==f&&(f=i,n(i)));let y=d===0?0:h[d-1][1],m=h[d][0];return`${c}${e.slice(y,m)}${h[d][2]||""}`},""),e+=a}return e}var Ze={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function J(e,r){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:
|
|
20
|
-
${JSON.stringify(e,null,4)}`);let n=O(O({},Ze),r);function i(s){return n.classicTrim&&!s.trim()||!n.classicTrim&&(n.space&&s===" "||n.cr&&s==="\r"||n.lf&&s===`
|
|
21
|
-
`||n.tab&&s===" "||n.nbsp&&s==="\xA0")}let f,t;if(e.length){if(i(e[0]))for(let s=0,o=e.length;s<o;s++){if(!i(e[s])){f=s;break}if(s===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let s=e.length;s--;)if(!i(e[s])){t=s+1;break}}return f?t?{res:e.slice(f,t),ranges:[[0,f],[t,e.length]]}:{res:e.slice(f),ranges:[[0,f]]}:t?{res:e.slice(0,t),ranges:[[t,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var Ye={heads:["{{"],tails:["}}"]};function $e(e,r){let n=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(r&&!E(r))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof r}!`);let i=O({},r);if(i&&n.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 resolvedOpts.heads contains elements which are not string-type!");if(i&&n.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 resolvedOpts.tails contains elements which are not string-type!");let f=J(e).res;if(f.length===0)return e;e=f;let t=O(O({},Ye),i);t.heads=t.heads.map(y=>y.trim()),t.tails=t.tails.map(y=>y.trim());let s=!1,o=!1,u=new P({limitToBeAddedWhitespace:!0}),l=new P({limitToBeAddedWhitespace:!0}),a=!0,c=!0,$="";function d(y,m){let g;return D(y,0,m.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})&&D(y,g,m.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})?y.slice(g):y}for(;e!==d(e,t);)e=J(d(e,t)).res;function h(y,m){let g;return!V(y,y.length-1,m.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})||!g?y:V(y,g,m.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})?y.slice(0,g+1):y}for(;e!==h(e,t);)e=J(h(e,t)).res;if(!t.heads.length||!D(e,0,t.heads,{trimBeforeMatching:!0})||!t.tails.length||!V(e,e.length-1,t.tails,{trimBeforeMatching:!0}))return J(e).res;for(let y=0,m=e.length;y<m;y++)if(e[y].trim()!==""){let g;if(D(e,y,t.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})&&g){c=!0,a&&(a=!0);let p;D(e,g,t.tails,{trimBeforeMatching:!0,cb:(b,w,v)=>(p=v,!0)})&&u.push(y,p),l.current()&&s&&$!=="tails"&&u.push(l.current()),s||l.current()&&(u.push(l.current()),l.wipe()),l.push(y,g),$="heads",y=g-1;continue}if(D(e,y,t.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=Number.isInteger(w)?w:e.length,!0)})&&g){c=!0,a?($==="heads"&&l.wipe(),a=!1):l.push(y,g),$="tails",y=g-1;continue}a&&(a=!0),c&&!s?(s=!0,c=!1):c&&!o?(o=!0,a=!0,c=!1,$==="heads"&&l.wipe()):c&&o&&l.wipe()}return l.current()&&u.push(l.current()),u.current()?C(e,u.current()).trim():e.trim()}var Te={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function X(e,r,n,i){if(W(i)&&!E(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 f=O(O({},Te),i);if(T(f.fromIndex)&&/^\d*$/.test(f.fromIndex))f.fromIndex=Number(f.fromIndex);else if(!Number.isInteger(f.fromIndex)||f.fromIndex<0)throw new TypeError(`${f.source} [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ${f.fromIndex}`);if(!T(e)||e.length===0){if(f.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 t,s;if(!T(r)&&!Array.isArray(r)){if(f.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 r}, equal to:
|
|
22
|
-
${JSON.stringify(r,null,4)}`)}else if(T(r))if(r.length===0){if(f.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 r=I(r);else if(Array.isArray(r))if(r.length===0){if(f.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(r.every((h,y)=>(t=h,s=y,T(h)))){if(!r.every((h,y)=>(s=y,T(h)&&h.length&&h.trim()!=="")))if(f.relaxedAPI){if(r=r.filter(h=>T(h)&&h.length),r.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 ${s} of heads array:
|
|
23
|
-
${JSON.stringify(r,null,4)}.`)}else if(f.relaxedAPI){if(r=r.filter(h=>T(h)&&h.length),r.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 ${s}th index is ${typeof t}, equal to:
|
|
24
|
-
${JSON.stringify(t,null,4)}. Whole heads array looks like:
|
|
25
|
-
${JSON.stringify(r,null,4)}`);if(!T(n)&&!Array.isArray(n)){if(f.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 n}, equal to:
|
|
26
|
-
${JSON.stringify(n,null,4)}`)}else if(T(n))if(n.length===0){if(f.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 n=I(n);else if(Array.isArray(n))if(n.length===0){if(f.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(n.every((h,y)=>(t=h,s=y,T(h)))){if(!n.every((h,y)=>(s=y,T(h)&&h.length&&h.trim()!=="")))if(f.relaxedAPI){if(n=n.filter(h=>T(h)&&h.length),n.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 ${s}. Whole tails array is equal to:
|
|
27
|
-
${JSON.stringify(n,null,4)}`)}else if(f.relaxedAPI){if(n=n.filter(h=>T(h)&&h.length),n.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 ${s}th index is ${typeof t}, equal to:
|
|
28
|
-
${JSON.stringify(t,null,4)}. Whole tails array is equal to:
|
|
29
|
-
${JSON.stringify(n,null,4)}`);let o=f.source===Te.source;if(f.throwWhenSomethingWrongIsDetected&&!f.allowWholeValueToBeOnlyHeadsOrTails){if(I(r).includes(e))throw new Error(`${f.source}${o?": [THROW_ID_16]":""} the whole input string can't be equal to ${T(r)?"":"one of "}heads (${e})!`);if(I(n).includes(e))throw new Error(`${f.source}${o?": [THROW_ID_17]":""} the whole input string can't be equal to ${T(n)?"":"one of "}tails (${e})!`)}let u=r.concat(n).map(h=>h.charAt(0)).reduce((h,y)=>y.charCodeAt(0)>h[1]?[h[0],y.charCodeAt(0)]:y.charCodeAt(0)<h[0]?[y.charCodeAt(0),h[1]]:h,[r[0].charCodeAt(0),r[0].charCodeAt(0)]),l=[],a=!1,c={},$="",d;for(let h=f.fromIndex,y=e.length;h<y;h++){let m=e[h].charCodeAt(0);if(m<=u[1]&&m>=u[0]){let g=D(e,h,r);if(g&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder){for(let b=r.length;b--;)if(r[b]===g){d=b;break}}if(T(g))if(a){if(f.throwWhenSomethingWrongIsDetected)throw new TypeError(`${f.source}${o?": [THROW_ID_19]":""} When processing "${e}", we found heads (${e.slice(h,h+g.length)}) starting at character with index number "${h}" and there was another set of heads before it! Generally speaking, there should be "heads-tails-heads-tails", not "heads-heads-tails"!
|
|
30
|
-
We're talking about the area of the code:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
--------------------------------------starts
|
|
34
|
-
${e.slice(Math.max(h-200,0),h)}
|
|
35
|
-
\x1B[33m------->\x1B[39m ${`\x1B[31m${e.slice(h,h+g.length)}\x1B[39m`} \x1B[33m<-------\x1B[39m
|
|
36
|
-
${e.slice(h+g.length,Math.min(y,h+200))}
|
|
37
|
-
--------------------------------------ends
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
To turn off this error being thrown, set resolvedOpts.throwWhenSomethingWrongIsDetected to Boolean false.`)}else{c={},c.headsStartAt=h,c.headsEndAt=h+g.length,a=!0,h+=g.length-1,$&&($="");continue}let p=D(e,h,n);if(a&&p&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&d!==void 0&&n[d]!==void 0&&n[d]!==p){let b;for(let w=n.length;w--;)if(n[w]===p){b=w;break}throw new TypeError(`${f.source}${o?": [THROW_ID_20]":""} When processing "${e}", we had "resolvedOpts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (${r[d]}) but the tails the followed it were not of the same index, ${d} (${n[d]}) but ${b} (${p}).`)}if(T(p))if(a){c.tailsStartAt=h,c.tailsEndAt=h+p.length,l.push(c),c={},a=!1,h+=p.length-1;continue}else f.throwWhenSomethingWrongIsDetected&&($=`${f.source}${o?": [THROW_ID_21]":""} When processing "${e}", we found tails (${e.slice(h,h+p.length)}) starting at character with index number "${h}" but there were no heads preceding it. That's very naughty!`)}if(f.throwWhenSomethingWrongIsDetected&&h===y-1){if(Object.keys(c).length!==0)throw new TypeError(`${f.source}${o?": [THROW_ID_22]":""} When processing "${e}", we reached the end of the string and yet didn't find any tails (${JSON.stringify(n,null,4)}) to match the last detected heads (${e.slice(c.headsStartAt,c.headsEndAt)})!`);if($)throw new Error($)}}return l}var Oe=k(F(),1);function ee(e){if(e.includes(".")){let r=e.lastIndexOf(".");if(!e.slice(0,r).includes("."))return e.slice(0,r);for(let n=r-1;n--;)if(e[n]===".")return e.slice(n+1,r)}return null}var re=(0,Oe.default)();function U(e,r){let n={now:!1};function i(f,t,s,o){let u=re(f),l,a=O({depth:-1,path:""},s);if(a.depth+=1,Array.isArray(u))for(let c=0,$=u.length;c<$&&!o.now;c++){let d=a.path?`${a.path}.${c}`:`${c}`;u[c]!==void 0?(a.parent=re(u),a.parentType="array",a.parentKey=ee(d),l=i(t(u[c],void 0,M(O({},a),{path:d}),o),t,M(O({},a),{path:d}),o),Number.isNaN(l)&&c<u.length?(u.splice(c,1),c-=1):u[c]=l):u.splice(c,1)}else if(E(u))for(let c in u){if(o.now&&c!=null)break;let $=a.path?`${a.path}.${c}`:c;a.depth===0&&c!=null&&(a.topmostKey=c),a.parent=re(u),a.parentType="object",a.parentKey=ee($),l=i(t(c,u[c],M(O({},a),{path:$}),o),t,M(O({},a),{path:$}),o),Number.isNaN(l)?delete u[c]:u[c]=l}return u}return i(e,r,{},n)}function te(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ne=new Map,Ae=(e,r)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${r}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(n=>{if(typeof n!="string"){if(typeof n>"u")return!1;throw new TypeError(`Expected '${r}' to be an array of strings, but found a type of '${typeof n}' in the array`)}return!0})},Xe=(e,r)=>{r=O({caseSensitive:!1},r);let n=e+JSON.stringify(r);if(ne.has(n))return ne.get(n);let i=e[0]==="!";i&&(e=e.slice(1)),e=te(e).replace(/\\\*/g,"[\\s\\S]*");let f=new RegExp(`^${e}$`,r.caseSensitive?"":"i");return f.negated=i,ne.set(n,f),f},er=(e,r,n,i)=>{if(e=Ae(e,"inputs"),r=Ae(r,"patterns"),r.length===0)return[];r=r.map(s=>Xe(s,n));let{allPatterns:f}=n||{},t=[];for(let s of e){let o,u=[...r].fill(!1);for(let[l,a]of r.entries())if(a.test(s)&&(u[l]=!0,o=!a.negated,!o))break;if(!(o===!1||o===void 0&&r.some(l=>!l.negated)||f&&u.some((l,a)=>!l&&!r[a].negated))&&(t.push(s),i))break}return t};function K(e,r,n){return er(e,r,n,!0).length>0}var Ee=k(F(),1);var ve=(0,Ee.default)();function ie(e,r,n){let i;n!==void 0&&(i=Array.isArray(n)?ve(n):[ve(n)]);let f=[],t=U(e,(s,o,u)=>{let l=o!==void 0?o:s;if(o!==void 0&&K(s,r,{caseSensitive:!0})){if(i===void 0)f.push({val:o,path:u.path});else if(i.length)return i.shift()}return l});return i===void 0?f:t}var N=k(We(),1);var Se="12.0.23";var tr=Se,nr=Object.prototype.hasOwnProperty,_e={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 T(e)?e.trim():e}function ir(e){if(T(e)&&e.length&&e.indexOf(".")!==-1){for(let r=0,n=e.length;r<n;r++)if(e[r]===".")return e.slice(0,r)}return e}function sr(e){if(T(e)&&e.length&&e.indexOf(".")!==-1){for(let r=0,n=e.length;r<n;r++)if(e[r]===".")return e.slice(r+1)}return e}function xe(e){if(T(e)&&e.length&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function De(e){if(T(e)&&e.length&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(r+1)}return e}function se(e,r){return!T(e)||!e.trim()?!1:!!(e.includes(r.heads)||e.includes(r.tails)||T(r.headsNoWrap)&&r.headsNoWrap.length&&e.includes(r.headsNoWrap)||T(r.tailsNoWrap)&&r.tailsNoWrap.length&&e.includes(r.tailsNoWrap))}function ar(e,r,n){let i,f;return T(e)&&e.length&&D(e,0,r,{trimBeforeMatching:!0,cb:(t,s,o)=>(i=o,!0)})&&V(e,e.length-1,n,{trimBeforeMatching:!0,cb:(t,s,o)=>(f=(o||0)+1,!0)})?e.slice(i,f):e}function Ne(e,r,n=!1,i,f,t){if(r.wrapHeadsWith||(r.wrapHeadsWith=""),r.wrapTailsWith||(r.wrapTailsWith=""),T(e)&&!n&&r.wrapGlobalFlipSwitch&&!r.dontWrapVars.some(s=>K(t,s))&&(!r.preventDoubleWrapping||r.preventDoubleWrapping&&T(e)&&!e.includes(r.wrapHeadsWith)&&!e.includes(r.wrapTailsWith)))return`${r.wrapHeadsWith}${e}${r.wrapTailsWith}`;if(n){if(!T(e))return e;let s=$e(e,{heads:r.wrapHeadsWith,tails:r.wrapTailsWith});return T(s)?ar(s,r.wrapHeadsWith,r.wrapTailsWith):s}return e}function or(e,r,n,i){let f;if(n.indexOf(".")!==-1){let t=n,s=!0;if(i.lookForDataContainers&&T(i.dataContainerIdentifierTails)&&i.dataContainerIdentifierTails.length&&!t.endsWith(i.dataContainerIdentifierTails)){let o=N.default.get(e,t+i.dataContainerIdentifierTails);E(o)&&N.default.get(o,r)&&(f=N.default.get(o,r),s=!1)}for(;s&&t.indexOf(".")!==-1;){if(t=xe(t),De(t)===r)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${r}" at path "${n}", we encountered a closed loop. The parent key "${De(t)}" is called the same as the variable "${r}" we're looking for.`);if(i.lookForDataContainers&&T(i.dataContainerIdentifierTails)&&i.dataContainerIdentifierTails.length&&!t.endsWith(i.dataContainerIdentifierTails)){let o=N.default.get(e,t+i.dataContainerIdentifierTails);E(o)&&N.default.get(o,r)&&(f=N.default.get(o,r),s=!1)}if(f===void 0){let o=N.default.get(e,t);E(o)&&N.default.get(o,r)&&(f=N.default.get(o,r),s=!1)}}}if(f===void 0){let t=N.default.get(e,r);t!==void 0&&(f=t)}if(f===void 0)if(r.indexOf(".")===-1){let t=ie(e,r);if(t.length){for(let s=0,o=t.length;s<o;s++)if(T(t[s].val)||L(t[s].val)||B(t[s].val)){f=t[s].val;break}else if(ge(t[s].val)){f=String(t[s].val);break}else if(Array.isArray(t[s].val)){f=t[s].val.join("");break}}}else{let t=ie(e,ir(r));if(t.length)for(let s=0,o=t.length;s<o;s++){let u=N.default.get(t[s].val,sr(r));u&&T(u)&&(f=u)}}return f}function Re(e,r,n,i,f=[]){if(f.includes(n)){let d="";if(f.length>1){let h=` \u2192
|
|
41
|
-
`;d=f.reduce((y,m,g)=>y+(g===0?"":h)+(m===n?"\u{1F4A5} ":" ")+m,` Here's the path we travelled up until we hit the recursion:
|
|
42
|
-
|
|
43
|
-
`),d+=`${h}\u{1F4A5} ${n}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${r}" at path "${n}", we encountered a closed loop, the key is referencing itself."${d}`)}let t={},s=Array.from(f);s.push(n);let o=new P;function u(d,h,y){for(let m=0,g=d.length;m<g;m++){let p=d[m],b=r.slice(p.headsEndAt,p.tailsStartAt);if(b.length===0)o.push(p.headsStartAt,p.tailsEndAt);else if(nr.call(t,b)&&T(t[b]))o.push(p.headsStartAt,p.tailsEndAt,t[b]);else{let w=or(e,b.trim(),n,i);if(w===void 0)if(i.allowUnresolved===!0)w="";else if(T(i.allowUnresolved))w=i.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${r.slice(p.headsEndAt,p.tailsStartAt)}. We're at path: "${n}".`);if(!y&&i.throwWhenNonStringInsertedInString&&!T(w))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${r.slice(p.headsEndAt,p.tailsStartAt)} at path ${n}, it resolved into a non-string value, ${JSON.stringify(w,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(L(w)){if(i.resolveToBoolIfAnyValuesContainBool)return o.wipe(),i.resolveToFalseIfAnyValuesContainBool?!1:w;w=""}else{if(B(w)&&y)return o.wipe(),w;Array.isArray(w)?w=String(w.join("")):B(w)?w="":w=String(w)}let v=n.includes(".")?`${xe(n)}.${b}`:b;if(se(w,i)){let S=Ne(Re(e,w,v,i,s),i,h,s,v,b.trim());T(S)&&o.push(p.headsStartAt,p.tailsEndAt,S)}else{t[b]=w;let S=Ne(w,i,h,s,v,b.trim());T(S)&&o.push(p.headsStartAt,p.tailsEndAt,S)}}}}let l;try{l=X(r,i.heads,i.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(d){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${r}" at path ${n}, something wrong with heads and tails was detected! Here's the internal error message:
|
|
44
|
-
${d}`)}let a=!1;l.length===1&&C(r,[[l[0].headsStartAt,l[0].tailsEndAt]]).trim()===""&&(a=!0);let c=u(l,!1,a);if(typeof c=="boolean"||c===null)return c;try{l=X(r,i.headsNoWrap,i.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(d){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${r}" at path ${n}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
|
|
45
|
-
${d}`)}l.length===1&&C(r,[[l[0].headsStartAt,l[0].tailsEndAt]]).trim()===""&&(a=!0);let $=u(l,!0,a);return L($)||B($)?$:o!=null&&o.current()?C(r,o.current()):r}function lr(e,r){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!E(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&&!E(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 n=O(O({},_e),r);n.dontWrapVars?Array.isArray(n.dontWrapVars)||(n.dontWrapVars=I(n.dontWrapVars)):n.dontWrapVars=[];let i,f;if(n.dontWrapVars.length&&!n.dontWrapVars.every((s,o)=>T(s)?!0:(i=s,f=o,!1)))throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in resolvedOpts.dontWrapVars should be of a string type. Computer detected a value "${i}" at index ${f}, which is not string but ${Array.isArray(i)?"array":typeof i}!`);if(n.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! resolvedOpts.heads are empty!");if(n.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! resolvedOpts.tails are empty!");if(n.lookForDataContainers&&n.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! resolvedOpts.dataContainerIdentifierTails is empty!");if(n.heads===n.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! resolvedOpts.heads and resolvedOpts.tails can't be equal!");if(n.heads===n.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! resolvedOpts.heads and resolvedOpts.headsNoWrap can't be equal!");if(n.tails===n.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! resolvedOpts.tails and resolvedOpts.tailsNoWrap can't be equal!");if(n.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! resolvedOpts.headsNoWrap is an empty string!");if(n.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! resolvedOpts.tailsNoWrap is an empty string!");if(n.headsNoWrap===n.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! resolvedOpts.headsNoWrap and resolvedOpts.tailsNoWrap can't be equal!");let t;return U(e,(s,o,u)=>{if(W(o)&&se(s,n))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
|
|
46
|
-
Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(n.heads.length&&A(t)===A(n.heads)||n.tails.length&&A(t)===A(n.tails)||n.headsNoWrap.length&&A(t)===A(n.headsNoWrap)||n.tailsNoWrap.length&&A(t)===A(n.tailsNoWrap)){if(!n.noSingleMarkers)return t;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${A(t)} which is equal to ${A(t)===A(n.heads)?"heads":""}${A(t)===A(n.tails)?"tails":""}${T(n.headsNoWrap)&&A(t)===A(n.headsNoWrap)?"headsNoWrap":""}${T(n.tailsNoWrap)&&A(t)===A(n.tailsNoWrap)?"tailsNoWrap":""}. If you wouldn't have set resolvedOpts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${A(t)}) alone`)}return T(t)&&se(t,n)?Re(e,t,u.path,n):t})}return ke(ur);})();
|
|
10
|
+
"use strict";var jsonVariables=(()=>{var Be=Object.create,oe=Object.freeze,R=Object.defineProperty,Me=Object.defineProperties,Je=Object.getOwnPropertyDescriptor,ke=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertyNames,le=Object.getOwnPropertySymbols,Le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable;var Z=(e,r,n)=>r in e?R(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,T=(e,r)=>{for(var n in r||(r={}))ue.call(r,n)&&Z(e,n,r[n]);if(le)for(var n of le(r))qe.call(r,n)&&Z(e,n,r[n]);return e},P=(e,r)=>Me(e,ke(r));var fe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ue=(e,r)=>{for(var n in r)R(e,n,{get:r[n],enumerable:!0})},ce=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of Fe(r))!ue.call(e,f)&&f!==n&&R(e,f,{get:()=>r[f],enumerable:!(i=Je(r,f))||i.enumerable});return e};var k=(e,r,n)=>(n=e!=null?Be(Le(e)):{},ce(r||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),Ke=e=>ce(R({},"__esModule",{value:!0}),e);var Y=(e,r,n)=>Z(e,typeof r!="symbol"?r+"":r,n);var F=(e,r)=>oe(R(e,"raw",{value:oe(r||e.slice())}));var L=fe((mr,ge)=>{"use strict";ge.exports=ze;function V(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function ze(e){if(e=e||{},e.circles)return Ge(e);let r=new Map;if(r.set(Date,a=>new Date(a)),r.set(Map,(a,o)=>new Map(i(Array.from(a),o))),r.set(Set,(a,o)=>new Set(i(Array.from(a),o))),e.constructorHandlers)for(let a of e.constructorHandlers)r.set(a[0],a[1]);let n=null;return e.proto?t:f;function i(a,o){let u=Object.keys(a),l=new Array(u.length);for(let s=0;s<u.length;s++){let c=u[s],$=a[c];typeof $!="object"||$===null?l[c]=$:$.constructor!==Object&&(n=r.get($.constructor))?l[c]=n($,o):ArrayBuffer.isView($)?l[c]=V($):l[c]=o($)}return l}function f(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return i(a,f);if(a.constructor!==Object&&(n=r.get(a.constructor)))return n(a,f);let o={};for(let u in a){if(Object.hasOwnProperty.call(a,u)===!1)continue;let l=a[u];typeof l!="object"||l===null?o[u]=l:l.constructor!==Object&&(n=r.get(l.constructor))?o[u]=n(l,f):ArrayBuffer.isView(l)?o[u]=V(l):o[u]=f(l)}return o}function t(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return i(a,t);if(a.constructor!==Object&&(n=r.get(a.constructor)))return n(a,t);let o={};for(let u in a){let l=a[u];typeof l!="object"||l===null?o[u]=l:l.constructor!==Object&&(n=r.get(l.constructor))?o[u]=n(l,t):ArrayBuffer.isView(l)?o[u]=V(l):o[u]=t(l)}return o}}function Ge(e){let r=[],n=[],i=new Map;if(i.set(Date,u=>new Date(u)),i.set(Map,(u,l)=>new Map(t(Array.from(u),l))),i.set(Set,(u,l)=>new Set(t(Array.from(u),l))),e.constructorHandlers)for(let u of e.constructorHandlers)i.set(u[0],u[1]);let f=null;return e.proto?o:a;function t(u,l){let s=Object.keys(u),c=new Array(s.length);for(let $=0;$<s.length;$++){let d=s[$],h=u[d];if(typeof h!="object"||h===null)c[d]=h;else if(h.constructor!==Object&&(f=i.get(h.constructor)))c[d]=f(h,l);else if(ArrayBuffer.isView(h))c[d]=V(h);else{let y=r.indexOf(h);y!==-1?c[d]=n[y]:c[d]=l(h)}}return c}function a(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return t(u,a);if(u.constructor!==Object&&(f=i.get(u.constructor)))return f(u,a);let l={};r.push(u),n.push(l);for(let s in u){if(Object.hasOwnProperty.call(u,s)===!1)continue;let c=u[s];if(typeof c!="object"||c===null)l[s]=c;else if(c.constructor!==Object&&(f=i.get(c.constructor)))l[s]=f(c,a);else if(ArrayBuffer.isView(c))l[s]=V(c);else{let $=r.indexOf(c);$!==-1?l[s]=n[$]:l[s]=a(c)}}return r.pop(),n.pop(),l}function o(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return t(u,o);if(u.constructor!==Object&&(f=i.get(u.constructor)))return f(u,o);let l={};r.push(u),n.push(l);for(let s in u){let c=u[s];if(typeof c!="object"||c===null)l[s]=c;else if(c.constructor!==Object&&(f=i.get(c.constructor)))l[s]=f(c,o);else if(ArrayBuffer.isView(c))l[s]=V(c);else{let $=r.indexOf(c);$!==-1?l[s]=n[$]:l[s]=o(c)}}return r.pop(),n.pop(),l}}});var xe=fe((Ne,G)=>{(function(e,r){"use strict";typeof G=="object"&&typeof G.exports=="object"?G.exports=r():typeof define=="function"&&define.amd?define([],r):e.objectPath=r()})(Ne,function(){"use strict";var e=Object.prototype.toString;function r(s,c){return s==null?!1:Object.prototype.hasOwnProperty.call(s,c)}function n(s){if(!s||t(s)&&s.length===0)return!0;if(typeof s!="string"){for(var c in s)if(r(s,c))return!1;return!0}return!1}function i(s){return e.call(s)}function f(s){return typeof s=="object"&&i(s)==="[object Object]"}var t=Array.isArray||function(s){return e.call(s)==="[object Array]"};function a(s){return typeof s=="boolean"||i(s)==="[object Boolean]"}function o(s){var c=parseInt(s);return c.toString()===s?c:s}function u(s){s=s||{};var c=function(m){return Object.keys(c).reduce(function(g,p){return p==="create"||typeof c[p]=="function"&&(g[p]=c[p].bind(c,m)),g},{})},$;s.includeInheritedProps?$=function(){return!0}:$=function(m,g){return typeof g=="number"&&Array.isArray(m)||r(m,g)};function d(m,g){if($(m,g))return m[g]}var h;s.includeInheritedProps?h=function(m,g){typeof g!="string"&&typeof g!="number"&&(g=String(g));var p=d(m,g);if(g==="__proto__"||g==="prototype"||g==="constructor"&&typeof p=="function")throw new Error("For security reasons, object's magic properties cannot be set");return p}:h=function(m,g){return d(m,g)};function y(m,g,p,b){if(typeof g=="number"&&(g=[g]),!g||g.length===0)return m;if(typeof g=="string")return y(m,g.split(".").map(o),p,b);var w=g[0],v=h(m,w);return g.length===1?((v===void 0||!b)&&(m[w]=p),v):(v===void 0&&(typeof g[1]=="number"?m[w]=[]:m[w]={}),y(m[w],g.slice(1),p,b))}return c.has=function(m,g){if(typeof g=="number"?g=[g]:typeof g=="string"&&(g=g.split(".")),!g||g.length===0)return!!m;for(var p=0;p<g.length;p++){var b=o(g[p]);if(typeof b=="number"&&t(m)&&b<m.length||(s.includeInheritedProps?b in Object(m):r(m,b)))m=m[b];else return!1}return!0},c.ensureExists=function(m,g,p){return y(m,g,p,!0)},c.set=function(m,g,p,b){return y(m,g,p,b)},c.insert=function(m,g,p,b){var w=c.get(m,g);b=~~b,t(w)||(w=[],c.set(m,g,w)),w.splice(b,0,p)},c.empty=function(m,g){if(!n(g)&&m!=null){var p,b;if(p=c.get(m,g)){if(typeof p=="string")return c.set(m,g,"");if(a(p))return c.set(m,g,!1);if(typeof p=="number")return c.set(m,g,0);if(t(p))p.length=0;else if(f(p))for(b in p)$(p,b)&&delete p[b];else return c.set(m,g,null)}}},c.push=function(m,g){var p=c.get(m,g);t(p)||(p=[],c.set(m,g,p)),p.push.apply(p,Array.prototype.slice.call(arguments,2))},c.coalesce=function(m,g,p){for(var b,w=0,v=g.length;w<v;w++)if((b=c.get(m,g[w]))!==void 0)return b;return p},c.get=function(m,g,p){if(typeof g=="number"&&(g=[g]),!g||g.length===0)return m;if(m==null)return p;if(typeof g=="string")return c.get(m,g.split("."),p);var b=o(g[0]),w=h(m,b);return w===void 0?p:g.length===1?w:c.get(m[b],g.slice(1),p)},c.del=function(g,p){if(typeof p=="number"&&(p=[p]),g==null||n(p))return g;if(typeof p=="string")return c.del(g,p.split("."));var b=o(p[0]);if(h(g,b),!$(g,b))return g;if(p.length===1)t(g)?g.splice(b,1):delete g[b];else return c.del(g[b],p.slice(1));return g},c}var l=u();return l.create=u,l.withInheritedProps=u({includeInheritedProps:!0}),l})});var pr={};Ue(pr,{defaults:()=>He,jVar:()=>hr,version:()=>or});function I(e){return typeof e!="string"?e:e.length?[e]:[]}var he=k(L(),1);var wr=(0,he.default)();function E(e){if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r!==null&&r!==Object.prototype&&Object.getPrototypeOf(r)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function A(e){return typeof e=="string"}function pe(e){return Number.isFinite(e)}function N(e){return Number.isSafeInteger(e)&&e>=0}function q(e){return typeof e=="boolean"}function B(e){return e===null}function S(e){return e!=null}function de(e,r){return E(e)&&A(r)&&r in e}var ye={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},Qe=e=>e+1;function Ze(e,r,n,i,f=!1,t=Qe){var b;let a=typeof n=="function"?n():n;if(+r<0&&f&&a==="EOL")return a;let o=T(T({},ye),i);if(r>=e.length&&!f)return!1;let u=f?1:n.length,l=0,s=!1,c=!1,$=!1,d=o.maxMismatches,h=r,y=!1,m=!1,g=!1;function p(){return l===1&&d<o.maxMismatches-1}for(;e[h];){let w=t(h);if(o.trimBeforeMatching&&e[h].trim()===""){if(!e[w]&&f&&n==="EOL")return!0;h=t(h);continue}if(o&&!o.i&&((b=o==null?void 0:o.trimCharsBeforeMatching)!=null&&b.includes(e[h]))||o!=null&&o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.map(W=>W.toLowerCase()).includes(e[h].toLowerCase())){if(f&&n==="EOL"&&!e[w])return!0;h=t(h);continue}let v=w>h?n[n.length-u]:n[u-1];if(!o.i&&e[h]===v||o.i&&e[h].toLowerCase()===v.toLowerCase()){if(y||(y=!0),$||($=!0),u===n.length){if(m=!0,d!==o.maxMismatches)return!1}else u===1&&(g=!0);if(u-=1,l++,p())return!1;if(!u)return l!==n.length||d===o.maxMismatches||!s?h:!1}else if(!s&&!l&&(s=!0),o.maxMismatches&&d&&h){d-=1;for(let W=0;W<=d;W++){let x=w>h?n[n.length-u+1+W]:n[u-2-W],Q=e[t(h)];if(x&&(!o.i&&e[h]===x||o.i&&e[h].toLowerCase()===x.toLowerCase())&&(!o.firstMustMatch||u!==n.length)){if(l++,p())return!1;u-=2,y=!0;break}else if(Q&&x&&(!o.i&&Q===x||o.i&&Q.toLowerCase()===x.toLowerCase())&&(!o.firstMustMatch||u!==n.length)){if(!l&&!o.hungry)return!1;u-=1,y=!0;break}else if(x===void 0&&d>=0&&y&&(!o.firstMustMatch||m)&&(!o.lastMustMatch||g))return h}y||(c=h)}else return h===0&&u===1&&!o.lastMustMatch&&$?0:!1;if(c!==!1&&c!==h&&(c=!1),u<1)return h;h=t(h)}if(u>0)return f&&a==="EOL"?!0:o&&o.maxMismatches>=u&&$?c||0:!1}function me(e,r,n,i,f){var s,c,$;if(E(f)&&de(f,"trimBeforeMatching")&&f&&typeof f.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(f.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let t=T(T({},ye),f);if(typeof t.trimCharsBeforeMatching=="string"&&(t.trimCharsBeforeMatching=I(t.trimCharsBeforeMatching)),t.trimCharsBeforeMatching=t.trimCharsBeforeMatching.map(d=>A(d)?d:String(d)),!A(r)||!r.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ").concat(typeof n,", equal to:\n").concat(JSON.stringify(n,null,4)));let a,o;if(A(i))a=[i];else if(Array.isArray(i))a=i;else if(!i)a=i;else if(typeof i=="function")a=[],a.push(i);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof i,", equal to:\n").concat(JSON.stringify(i,null,4)));if(f&&!E(f))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof f,'", and equal to:\n').concat(JSON.stringify(f,null,4)));let u=0,l="";if((s=t==null?void 0:t.trimCharsBeforeMatching)!=null&&s.some((d,h)=>d.length>1?(u=h,l=d,!0):!1))throw new Error("string-match-left-right/".concat(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 ").concat(u," is longer than 1 character, ").concat(l.length," (equals to ").concat(l,"). Please split it into separate characters and put into array as separate elements."));if(!a||!Array.isArray(a)||Array.isArray(a)&&!a.length||Array.isArray(a)&&a.length===1&&A(a[0])&&!a[0].trim()){if(typeof t.cb=="function"){let h,y=n;if((e==="matchLeftIncl"||e==="matchRight")&&(y+=1),e[5]==="L")for(let b=y;b--;){let w=r[b];if((!t.trimBeforeMatching||t.trimBeforeMatching&&(w!=null&&w.trim()))&&(!((c=t.trimCharsBeforeMatching)!=null&&c.length)||w!==void 0&&!t.trimCharsBeforeMatching.includes(w))){h=b;break}}else if(e.startsWith("matchRight"))for(let b=y;b<r.length;b++){let w=r[b];if((!t.trimBeforeMatching||t.trimBeforeMatching&&w.trim())&&(!(($=t.trimCharsBeforeMatching)!=null&&$.length)||!t.trimCharsBeforeMatching.includes(w))){h=b;break}}if(h===void 0)return!1;let m=r[h],g=h+1,p="";return g&&g>0&&(p=r.slice(0,g)),e[5]==="L"||h&&h>0&&(p=r.slice(h)),t.cb(m,p,h)}let d="";throw f||(d=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(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!').concat(d))}for(let d=0,h=a.length;d<h;d++){o=typeof a[d]=="function";let y=a[d],m,g,p="",b=n;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let w=Ze(r,b,y,t,o,v=>e[5]==="L"?v-1:v+1);if(w&&o&&typeof y=="function"&&y()==="EOL")return y()&&(!t.cb||t.cb(m,p,g))?y():!1;if(Number.isInteger(w)&&(g=e.startsWith("matchLeft")?w-1:w+1,e[5]==="L"?p=r.slice(0,w):p=r.slice(g)),g<0&&(g=void 0),r[g]&&(m=r[g]),Number.isInteger(w)&&(!t.cb||t.cb(m,p,g)))return y}return!1}function C(e,r,n,i){return me("matchLeftIncl",e,r,n,i)}function D(e,r,n,i){return me("matchRightIncl",e,r,n,i)}function U(e,r=1){let n="\xA0";function i(t){return Array.from(t).reverse().join("")}function f(t,a,o){let u=o?"\n":"\r",l=o?"\r":"\n";if(!t)return t;let s=0,c=0,$="";for(let d=0,h=t.length;d<h;d++)(t[d]===u||t[d]===l&&t[d-1]!==u)&&c++,"\r\n".includes(t[d])||t[d]===n?(s=0,t[d]===n?$+=t[d]:t[d]===u?c<=a&&($+=t[d],t[d+1]===l&&($+=t[d+1],d++)):t[d]===l&&(t==null?void 0:t[d-1])!==u&&c<=a&&($+=t[d])):(s++,!t[d+1]&&!c&&($+=" "));return $}if(typeof e=="string"&&e.length){let t=1;typeof+r=="number"&&Number.isInteger(+r)&&+r>=0&&(t=+r);let a="",o="";if(!e.trim())a=e;else if(!e[0].trim()){for(let u=0,l=e.length;u<l;u++)if(e[u].trim()){a=e.slice(0,u);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let u=e.length;u--;)if(e[u].trim()){o=e.slice(u+1);break}}return"".concat(f(a,t,!1)).concat(e.trim()).concat(i(f(i(o),t,!0)))}return e}var Ye={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function H(e,r){if(!Array.isArray(e)||!e.length)return e;let n=T(T({},Ye),r),i,f;if(n.strictlyTwoElementsInRangeArrays&&!e.every((o,u)=>!Array.isArray(o)||o.length!==2?(i=u,f=o.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, ".concat(i,"th range (").concat(JSON.stringify(e[i],null,4),") has not two but ").concat(f," elements!"));if(!e.every((o,u)=>!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<0||!Number.isInteger(o[1])||o[1]<0?(i=u,!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, ".concat(i,"th range (").concat(JSON.stringify(e[i],null,4),") does not consist of only natural numbers!"));let t=e.length**2,a=0;return Array.from(e).sort((o,u)=>(n.progressFn&&(a+=1,n.progressFn(Math.floor(a*100/t))),o[0]===u[0]?o[1]<u[1]?-1:o[1]>u[1]?1:0:o[0]<u[0]?-1:1))}var we={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Xe(e,r){var l;function n(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}if(!Array.isArray(e)||!e.length)return null;let i;if(r)if(n(r)){if(i=T(T({},we),r),i.progressFn&&n(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] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof i.progressFn,'", equal to ').concat(JSON.stringify(i.progressFn,null,4)));if(![1,2,"1","2"].includes(i.mergeType))throw new Error('ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof i.mergeType,'", equal to ').concat(JSON.stringify(i.mergeType,null,4)));if(typeof i.joinRangesThatTouchEdges!="boolean")throw new Error('ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof i.joinRangesThatTouchEdges,'", equal to ').concat(JSON.stringify(i.joinRangesThatTouchEdges,null,4)))}else throw new Error("ranges-merge: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n".concat(JSON.stringify(r,null,4)," (type ").concat(typeof r,")"));else i=T({},we);let f=e.filter(s=>Array.isArray(s)).map(s=>[...s]).filter(s=>s[2]!==void 0||s[0]!==s[1]),t,a,o;i.progressFn?t=H(f,{progressFn:s=>{o=Math.floor(s/5),o!==a&&(a=o,i.progressFn!=null&&i.progressFn(o))}}):t=H(f);let u=t.length-1;for(let s=u;s>0;s--)i.progressFn&&(o=Math.floor((1-s/u)*78)+21,o!==a&&o>a&&(a=o,i.progressFn(o))),(t[s][0]<=t[s-1][0]||!i.joinRangesThatTouchEdges&&t[s][0]<t[s-1][1]||i.joinRangesThatTouchEdges&&t[s][0]<=t[s-1][1])&&(t[s-1][0]=Math.min(t[s][0],t[s-1][0]),t[s-1][1]=Math.max(t[s][1],t[s-1][1]),t[s][2]!==void 0&&(t[s-1][0]>=t[s][0]||t[s-1][1]<=t[s][1])&&t[s-1][2]!==null&&(t[s][2]===null&&t[s-1][2]!==null?t[s-1][2]=null:t[s-1][2]!=null?+((l=i||{})==null?void 0:l.mergeType)==2&&t[s-1][0]===t[s][0]?t[s-1][2]=t[s][2]:t[s-1][2]+=t[s][2]:t[s-1][2]=t[s][2]),t.splice(s,1),s=t.length);return t.length?t:null}var er={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},M=class{constructor(e){Y(this,"ranges");Y(this,"opts");let r=T(T({},er),e);if(r.mergeType&&r.mergeType!==1&&r.mergeType!==2)if(A(r.mergeType)&&r.mergeType.trim()==="1")r.mergeType=1;else if(A(r.mergeType)&&r.mergeType.trim()==="2")r.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: "'.concat(typeof r.mergeType,'", equal to ').concat(JSON.stringify(r.mergeType,null,4)));this.opts=r,this.ranges=[]}add(e,r,n){var t;if(e==null&&r==null)return;if(S(e)&&!S(r)){if(Array.isArray(e)){if(e.length){if(e.some(a=>Array.isArray(a))){e.forEach(a=>{Array.isArray(a)&&this.add(...a)});return}e.length&&N(+e[0])&&N(+e[1])&&this.add(...e)}return}throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set ('.concat(JSON.stringify(e,null,0),') but second-one, "to" is not (').concat(JSON.stringify(r,null,0),")"))}else if(!S(e)&&S(r))throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set ('.concat(JSON.stringify(r,null,0),') but first-one, "from" is not (').concat(JSON.stringify(e,null,0),")"));let i=+e,f=+r;if(N(n)&&(n=String(n)),N(i)&&N(f)){if(S(n)&&!A(n)&&!N(n))throw new TypeError("ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ".concat(typeof n,", equal to:\n").concat(JSON.stringify(n,null,4)));if(S(this.ranges)&&Array.isArray(this.last())&&i===this.last()[1]){if(this.last()[1]=f,this.last()[2],this.last()[2]!==null&&S(n)){let a=this.last()[2]&&this.last()[2].length&&(!((t=this.opts)!=null&&t.mergeType)||this.opts.mergeType===1)?"".concat(this.last()[2]).concat(n):n;this.opts.limitToBeAddedWhitespace&&(a=U(a,this.opts.limitLinebreaksCount)),A(a)&&!a.length||(this.last()[2]=a)}}else{this.ranges||(this.ranges=[]);let a=n!==void 0&&!(A(n)&&!n.length)?[i,f,n&&this.opts.limitToBeAddedWhitespace?U(n,this.opts.limitLinebreaksCount):n]:[i,f];this.ranges.push(a)}}else throw N(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 "'.concat(typeof f,'" equal to: ').concat(JSON.stringify(f,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 "'.concat(typeof i,'" equal to: ').concat(JSON.stringify(i,null,4)))}push(e,r,n){this.add(e,r,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=Xe(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>S(e[2])?[e[0],e[1],U(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])&&N(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, ".concat(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 be={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function $e(e,r){function n(l){return!!l&&typeof l=="object"&&!Array.isArray(l)}if(!Array.isArray(e)||!e.length)return null;let i;if(r)if(n(r)){if(i=T(T({},be),r),i.progressFn&&n(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: "'.concat(typeof i.progressFn,'", equal to ').concat(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: "'.concat(typeof i.mergeType,'", equal to ').concat(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: "'.concat(typeof i.joinRangesThatTouchEdges,'", equal to ').concat(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:\n".concat(JSON.stringify(r,null,4)," (type ").concat(typeof r,")"));else i=T({},be);let f=e.filter(l=>Array.isArray(l)).map(l=>[...l]).filter(l=>l[2]!==void 0||l[0]!==l[1]),t,a,o;i.progressFn?t=H(f,{progressFn:l=>{o=Math.floor(l/5),o!==a&&(a=o,i.progressFn(o))}}):t=H(f);let u=t.length-1;for(let l=u;l>0;l--)i.progressFn&&(o=Math.floor((1-l/u)*78)+21,o!==a&&o>a&&(a=o,i.progressFn(o))),(t[l][0]<=t[l-1][0]||!i.joinRangesThatTouchEdges&&t[l][0]<t[l-1][1]||i.joinRangesThatTouchEdges&&t[l][0]<=t[l-1][1])&&(t[l-1][0]=Math.min(t[l][0],t[l-1][0]),t[l-1][1]=Math.max(t[l][1],t[l-1][1]),t[l][2]!==void 0&&(t[l-1][0]>=t[l][0]||t[l-1][1]<=t[l][1])&&t[l-1][2]!==null&&(t[l][2]===null&&t[l-1][2]!==null?t[l-1][2]=null:t[l-1][2]!=null?+i.mergeType==2&&t[l-1][0]===t[l][0]?t[l-1][2]=t[l][2]:t[l-1][2]+=t[l][2]:t[l-1][2]=t[l][2]),t.splice(l,1),l=t.length);return t.length?t:null}var rr=!0,X="Invariant failed";function Ae(e,r){if(!e){if(rr)throw new Error(X);var n=typeof r=="function"?r():r,i=n?"".concat(X,": ").concat(n):X;throw new Error(i)}}function j(e,r,n){let i=0,f=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: ".concat(typeof e,", equal to: ").concat(JSON.stringify(e,null,4)));if(r&&!Array.isArray(r))throw new TypeError("ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ".concat(typeof r,", equal to: ").concat(JSON.stringify(r,null,4)));if(n&&typeof n!="function")throw new TypeError("ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ".concat(typeof n,", equal to: ").concat(JSON.stringify(n,null,4)));if(!(r!=null&&r.filter(s=>s).length))return e;let t;Array.isArray(r)&&Number.isInteger(r[0])&&Number.isInteger(r[1])?t=[Array.from(r)]:t=Array.from(r);let a=t.length,o=0;t.filter(s=>s).forEach((s,c)=>{if(n&&(i=Math.floor(o/a*10),i!==f&&(f=i,n(i))),!Array.isArray(s))throw new TypeError("ranges-apply: [THROW_ID_05] ranges array, second input arg., has ".concat(c,"th element not an array: ").concat(JSON.stringify(s,null,4),", which is ").concat(typeof s));if(!Number.isInteger(s[0])){if(!Number.isInteger(+s[0])||+s[0]<0)throw new TypeError("ranges-apply: [THROW_ID_06] ranges array, second input arg. has ".concat(c,"th element, array ").concat(JSON.stringify(s,null,0),". Its first element is not an integer, string index, but ").concat(typeof s[0],", equal to: ").concat(JSON.stringify(s[0],null,4),"."));t[c][0]=+t[c][0]}if(!Number.isInteger(s[1])){if(!Number.isInteger(+s[1])||+s[1]<0)throw new TypeError("ranges-apply: [THROW_ID_07] ranges array, second input arg. has ".concat(c,"th element, array ").concat(JSON.stringify(s,null,0),". Its second element is not an integer, string index, but ").concat(typeof s[1],", equal to: ").concat(JSON.stringify(s[1],null,4),"."));t[c][1]=+t[c][1]}o+=1});let u=$e(t,{progressFn:s=>{n&&(i=10+Math.floor(s/10),i!==f&&(f=i,n(i)))}});Ae(u);let l=u.length;if(l>0){let s=e.slice(u[l-1][1]);e=u.reduce((c,$,d,h)=>{n&&(i=20+Math.floor(d/l*80),i!==f&&(f=i,n(i)));let y=d===0?0:h[d-1][1],m=h[d][0];return"".concat(c).concat(e.slice(y,m)).concat(h[d][2]||"")},""),e+=s}return e}var tr={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function J(e,r){if(typeof e!="string")throw new Error("string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ".concat(typeof e,", equal to:\n").concat(JSON.stringify(e,null,4)));let n=T(T({},tr),r);function i(a){return n.classicTrim&&!a.trim()||!n.classicTrim&&(n.space&&a===" "||n.cr&&a==="\r"||n.lf&&a==="\n"||n.tab&&a===" "||n.nbsp&&a==="\xA0")}let f,t;if(e.length){if(i(e[0]))for(let a=0,o=e.length;a<o;a++){if(!i(e[a])){f=a;break}if(a===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let a=e.length;a--;)if(!i(e[a])){t=a+1;break}}return f?t?{res:e.slice(f,t),ranges:[[0,f],[t,e.length]]}:{res:e.slice(f),ranges:[[0,f]]}:t?{res:e.slice(0,t),ranges:[[t,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var nr={heads:["{{"],tails:["}}"]};function Te(e,r){let n=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(r&&!E(r))throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ".concat(typeof r,"!"));let i=T({},r);if(i&&n.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 resolvedOpts.heads contains elements which are not string-type!");if(i&&n.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 resolvedOpts.tails contains elements which are not string-type!");let f=J(e).res;if(f.length===0)return e;e=f;let t=T(T({},nr),i);t.heads=t.heads.map(y=>y.trim()),t.tails=t.tails.map(y=>y.trim());let a=!1,o=!1,u=new M({limitToBeAddedWhitespace:!0}),l=new M({limitToBeAddedWhitespace:!0}),s=!0,c=!0,$="";function d(y,m){let g;return D(y,0,m.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})&&D(y,g,m.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})?y.slice(g):y}for(;e!==d(e,t);)e=J(d(e,t)).res;function h(y,m){let g;return!C(y,y.length-1,m.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})||!g?y:C(y,g,m.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})?y.slice(0,g+1):y}for(;e!==h(e,t);)e=J(h(e,t)).res;if(!t.heads.length||!D(e,0,t.heads,{trimBeforeMatching:!0})||!t.tails.length||!C(e,e.length-1,t.tails,{trimBeforeMatching:!0}))return J(e).res;for(let y=0,m=e.length;y<m;y++)if(e[y].trim()!==""){let g;if(D(e,y,t.heads,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=w,!0)})&&g){c=!0,s&&(s=!0);let p;D(e,g,t.tails,{trimBeforeMatching:!0,cb:(b,w,v)=>(p=v,!0)})&&u.push(y,p),l.current()&&a&&$!=="tails"&&u.push(l.current()),a||l.current()&&(u.push(l.current()),l.wipe()),l.push(y,g),$="heads",y=g-1;continue}if(D(e,y,t.tails,{trimBeforeMatching:!0,cb:(p,b,w)=>(g=Number.isInteger(w)?w:e.length,!0)})&&g){c=!0,s?($==="heads"&&l.wipe(),s=!1):l.push(y,g),$="tails",y=g-1;continue}s&&(s=!0),c&&!a?(a=!0,c=!1):c&&!o?(o=!0,s=!0,c=!1,$==="heads"&&l.wipe()):c&&o&&l.wipe()}return l.current()&&u.push(l.current()),u.current()?j(e,u.current()).trim():e.trim()}var Oe={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function ee(e,r,n,i){if(S(i)&&!E(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: ".concat(i," (type: ").concat(typeof i,")"));let f=T(T({},Oe),i);if(A(f.fromIndex)&&/^\d*$/.test(f.fromIndex))f.fromIndex=Number(f.fromIndex);else if(!Number.isInteger(f.fromIndex)||f.fromIndex<0)throw new TypeError("".concat(f.source," [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ").concat(f.fromIndex));if(!A(e)||e.length===0){if(f.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: ".concat(typeof e,", equal to: ").concat(e))}let t,a;if(!A(r)&&!Array.isArray(r)){if(f.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: ".concat(typeof r,", equal to:\n").concat(JSON.stringify(r,null,4)))}else if(A(r))if(r.length===0){if(f.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 r=I(r);else if(Array.isArray(r))if(r.length===0){if(f.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(r.every((h,y)=>(t=h,a=y,A(h)))){if(!r.every((h,y)=>(a=y,A(h)&&h.length&&h.trim()!=="")))if(f.relaxedAPI){if(r=r.filter(h=>A(h)&&h.length),r.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 ".concat(a," of heads array:\n").concat(JSON.stringify(r,null,4),"."))}else if(f.relaxedAPI){if(r=r.filter(h=>A(h)&&h.length),r.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 ".concat(a,"th index is ").concat(typeof t,", equal to:\n").concat(JSON.stringify(t,null,4),". Whole heads array looks like:\n").concat(JSON.stringify(r,null,4)));if(!A(n)&&!Array.isArray(n)){if(f.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: ".concat(typeof n,", equal to:\n").concat(JSON.stringify(n,null,4)))}else if(A(n))if(n.length===0){if(f.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 n=I(n);else if(Array.isArray(n))if(n.length===0){if(f.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(n.every((h,y)=>(t=h,a=y,A(h)))){if(!n.every((h,y)=>(a=y,A(h)&&h.length&&h.trim()!=="")))if(f.relaxedAPI){if(n=n.filter(h=>A(h)&&h.length),n.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 ".concat(a,". Whole tails array is equal to:\n").concat(JSON.stringify(n,null,4)))}else if(f.relaxedAPI){if(n=n.filter(h=>A(h)&&h.length),n.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 ".concat(a,"th index is ").concat(typeof t,", equal to:\n").concat(JSON.stringify(t,null,4),". Whole tails array is equal to:\n").concat(JSON.stringify(n,null,4)));let o=f.source===Oe.source;if(f.throwWhenSomethingWrongIsDetected&&!f.allowWholeValueToBeOnlyHeadsOrTails){if(I(r).includes(e))throw new Error("".concat(f.source).concat(o?": [THROW_ID_16]":""," the whole input string can't be equal to ").concat(A(r)?"":"one of ","heads (").concat(e,")!"));if(I(n).includes(e))throw new Error("".concat(f.source).concat(o?": [THROW_ID_17]":""," the whole input string can't be equal to ").concat(A(n)?"":"one of ","tails (").concat(e,")!"))}let u=r.concat(n).map(h=>h.charAt(0)).reduce((h,y)=>y.charCodeAt(0)>h[1]?[h[0],y.charCodeAt(0)]:y.charCodeAt(0)<h[0]?[y.charCodeAt(0),h[1]]:h,[r[0].charCodeAt(0),r[0].charCodeAt(0)]),l=[],s=!1,c={},$="",d;for(let h=f.fromIndex,y=e.length;h<y;h++){let m=e[h].charCodeAt(0);if(m<=u[1]&&m>=u[0]){let g=D(e,h,r);if(g&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder){for(let b=r.length;b--;)if(r[b]===g){d=b;break}}if(A(g))if(s){if(f.throwWhenSomethingWrongIsDetected)throw new TypeError("".concat(f.source).concat(o?": [THROW_ID_19]":"",' When processing "').concat(e,'", we found heads (').concat(e.slice(h,h+g.length),') starting at character with index number "').concat(h,'" 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').concat(e.slice(Math.max(h-200,0),h),"\n \x1B[33m------->\x1B[39m ").concat("\x1B[31m".concat(e.slice(h,h+g.length),"\x1B[39m")," \x1B[33m<-------\x1B[39m\n").concat(e.slice(h+g.length,Math.min(y,h+200)),"\n--------------------------------------ends\n\n\nTo turn off this error being thrown, set resolvedOpts.throwWhenSomethingWrongIsDetected to Boolean false."))}else{c={},c.headsStartAt=h,c.headsEndAt=h+g.length,s=!0,h+=g.length-1,$&&($="");continue}let p=D(e,h,n);if(s&&p&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&d!==void 0&&n[d]!==void 0&&n[d]!==p){let b;for(let w=n.length;w--;)if(n[w]===p){b=w;break}throw new TypeError("".concat(f.source).concat(o?": [THROW_ID_20]":"",' When processing "').concat(e,'", we had "resolvedOpts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (').concat(r[d],") but the tails the followed it were not of the same index, ").concat(d," (").concat(n[d],") but ").concat(b," (").concat(p,")."))}if(A(p))if(s){c.tailsStartAt=h,c.tailsEndAt=h+p.length,l.push(c),c={},s=!1,h+=p.length-1;continue}else f.throwWhenSomethingWrongIsDetected&&($="".concat(f.source).concat(o?": [THROW_ID_21]":"",' When processing "').concat(e,'", we found tails (').concat(e.slice(h,h+p.length),') starting at character with index number "').concat(h,"\" but there were no heads preceding it. That's very naughty!"))}if(f.throwWhenSomethingWrongIsDetected&&h===y-1){if(Object.keys(c).length!==0)throw new TypeError("".concat(f.source).concat(o?": [THROW_ID_22]":"",' When processing "').concat(e,"\", we reached the end of the string and yet didn't find any tails (").concat(JSON.stringify(n,null,4),") to match the last detected heads (").concat(e.slice(c.headsStartAt,c.headsEndAt),")!"));if($)throw new Error($)}}return l}var ve=k(L(),1);function re(e){if(e.includes(".")){let r=e.lastIndexOf(".");if(!e.slice(0,r).includes("."))return e.slice(0,r);for(let n=r-1;n--;)if(e[n]===".")return e.slice(n+1,r)}return null}var te=(0,ve.default)();function K(e,r){let n={now:!1};function i(f,t,a,o){let u=te(f),l,s=T({depth:-1,path:""},a);if(s.depth+=1,Array.isArray(u))for(let c=0,$=u.length;c<$&&!o.now;c++){let d=s.path?"".concat(s.path,".").concat(c):"".concat(c);u[c]!==void 0?(s.parent=te(u),s.parentType="array",s.parentKey=re(d),l=i(t(u[c],void 0,P(T({},s),{path:d}),o),t,P(T({},s),{path:d}),o),Number.isNaN(l)&&c<u.length?(u.splice(c,1),c-=1):u[c]=l):u.splice(c,1)}else if(E(u))for(let c in u){if(o.now&&c!=null)break;let $=s.path?"".concat(s.path,".").concat(c):c;s.depth===0&&c!=null&&(s.topmostKey=c),s.parent=te(u),s.parentType="object",s.parentKey=re($),l=i(t(c,u[c],P(T({},s),{path:$}),o),t,P(T({},s),{path:$}),o),Number.isNaN(l)?delete u[c]:u[c]=l}return u}return i(e,r,{},n)}function ne(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ie=new Map,Ee=(e,r)=>{if(!Array.isArray(e))switch(typeof e){case"string":{e=[e];break}case"undefined":{e=[];break}default:throw new TypeError("Expected '".concat(r,"' to be a string or an array, but got a type of '").concat(typeof e,"'"))}return e.filter(n=>{if(typeof n!="string"){if(n===void 0)return!1;throw new TypeError("Expected '".concat(r,"' to be an array of strings, but found a type of '").concat(typeof n,"' in the array"))}return!0})},Ie,Se,We,ir=(e,r)=>{r=T({caseSensitive:!1},r);let n="s"+(r.caseSensitive?"":"i"),i=e+"|"+n;if(ie.has(i))return ie.get(i);let f=e[0]==="!";f&&(e=e.slice(1)),e=e.replaceAll(String.raw(Ie||(Ie=F(["*"],["\\*"]))),"__ESCAPED_STAR__").replaceAll("\\\\","__ESCAPED_BACKSLASH__").replaceAll(/\\(.)/g,"$1"),e=ne(e).replaceAll(String.raw(Se||(Se=F(["*"],["\\*"]))),".*"),e=e.replaceAll("__ESCAPED_STAR__",String.raw(We||(We=F(["*"],["\\*"])))).replaceAll("__ESCAPED_BACKSLASH__","\\\\");let t=new RegExp("^".concat(e,"$"),n);return t.negated=f,ie.set(i,t),t},sr=(e,r,n,i)=>{if(e=Ee(e,"inputs"),r=Ee(r,"patterns"),r.length===0)return[];r=r.map(u=>ir(u,n));let f=r.filter(u=>u.negated),t=r.filter(u=>!u.negated),{allPatterns:a}=n||{},o=[];if(a&&i&&f.length>1&&t.length===0){for(let u of e)for(let l of f)if(l.test(u))return[];return e.slice(0,1)}for(let u of e){let l=!1;for(let s of f)if(s.test(u)){l=!0;break}if(!l){if(t.length===0)o.push(u);else if(a){let s=Array.from({length:t.length},()=>!1);for(let[c,$]of t.entries())$.test(u)&&(s[c]=!0);s.every(Boolean)&&o.push(u)}else{let s=!1;for(let c of t)if(c.test(u)){s=!0;break}s&&o.push(u)}if(i&&o.length>0)break}}return o};function z(e,r,n){return sr(e,r,n,!0).length>0}var _e=k(L(),1);var De=(0,_e.default)();function se(e,r,n){let i;n!==void 0&&(i=Array.isArray(n)?De(n):[De(n)]);let f=[],t=K(e,(a,o,u)=>{let l=o!==void 0?o:a;if(o!==void 0&&z(a,r,{caseSensitive:!0})){if(i===void 0)f.push({val:o,path:u.path});else if(i.length)return i.shift()}return l});return i===void 0?f:t}var _=k(xe(),1);var Re="12.0.33";var or=Re,lr=Object.prototype.hasOwnProperty,He={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 O(e){return A(e)?e.trim():e}function ur(e){if(A(e)&&e.length&&e.indexOf(".")!==-1){for(let r=0,n=e.length;r<n;r++)if(e[r]===".")return e.slice(0,r)}return e}function fr(e){if(A(e)&&e.length&&e.indexOf(".")!==-1){for(let r=0,n=e.length;r<n;r++)if(e[r]===".")return e.slice(r+1)}return e}function je(e){if(A(e)&&e.length&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function Ve(e){if(A(e)&&e.length&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(r+1)}return e}function ae(e,r){return!A(e)||!e.trim()?!1:!!(e.includes(r.heads)||e.includes(r.tails)||A(r.headsNoWrap)&&r.headsNoWrap.length&&e.includes(r.headsNoWrap)||A(r.tailsNoWrap)&&r.tailsNoWrap.length&&e.includes(r.tailsNoWrap))}function cr(e,r,n){let i,f;return A(e)&&e.length&&D(e,0,r,{trimBeforeMatching:!0,cb:(t,a,o)=>(i=o,!0)})&&C(e,e.length-1,n,{trimBeforeMatching:!0,cb:(t,a,o)=>(f=(o||0)+1,!0)})?e.slice(i,f):e}function Ce(e,r,n=!1,i,f,t){if(r.wrapHeadsWith||(r.wrapHeadsWith=""),r.wrapTailsWith||(r.wrapTailsWith=""),A(e)&&!n&&r.wrapGlobalFlipSwitch&&!r.dontWrapVars.some(a=>z(t,a))&&(!r.preventDoubleWrapping||r.preventDoubleWrapping&&A(e)&&!e.includes(r.wrapHeadsWith)&&!e.includes(r.wrapTailsWith)))return"".concat(r.wrapHeadsWith).concat(e).concat(r.wrapTailsWith);if(n){if(!A(e))return e;let a=Te(e,{heads:r.wrapHeadsWith,tails:r.wrapTailsWith});return A(a)?cr(a,r.wrapHeadsWith,r.wrapTailsWith):a}return e}function gr(e,r,n,i){let f;if(n.indexOf(".")!==-1){let t=n,a=!0;if(i.lookForDataContainers&&A(i.dataContainerIdentifierTails)&&i.dataContainerIdentifierTails.length&&!t.endsWith(i.dataContainerIdentifierTails)){let o=_.default.get(e,t+i.dataContainerIdentifierTails);E(o)&&_.default.get(o,r)&&(f=_.default.get(o,r),a=!1)}for(;a&&t.indexOf(".")!==-1;){if(t=je(t),Ve(t)===r)throw new Error('json-variables/findValues(): [THROW_ID_20] While trying to resolve: "'.concat(r,'" at path "').concat(n,'", we encountered a closed loop. The parent key "').concat(Ve(t),'" is called the same as the variable "').concat(r,"\" we're looking for."));if(i.lookForDataContainers&&A(i.dataContainerIdentifierTails)&&i.dataContainerIdentifierTails.length&&!t.endsWith(i.dataContainerIdentifierTails)){let o=_.default.get(e,t+i.dataContainerIdentifierTails);E(o)&&_.default.get(o,r)&&(f=_.default.get(o,r),a=!1)}if(f===void 0){let o=_.default.get(e,t);E(o)&&_.default.get(o,r)&&(f=_.default.get(o,r),a=!1)}}}if(f===void 0){let t=_.default.get(e,r);t!==void 0&&(f=t)}if(f===void 0)if(r.indexOf(".")===-1){let t=se(e,r);if(t.length){for(let a=0,o=t.length;a<o;a++)if(A(t[a].val)||q(t[a].val)||B(t[a].val)){f=t[a].val;break}else if(pe(t[a].val)){f=String(t[a].val);break}else if(Array.isArray(t[a].val)){f=t[a].val.join("");break}}}else{let t=se(e,ur(r));if(t.length)for(let a=0,o=t.length;a<o;a++){let u=_.default.get(t[a].val,fr(r));u&&A(u)&&(f=u)}}return f}function Pe(e,r,n,i,f=[]){if(f.includes(n)){let d="";if(f.length>1){let h=" \u2192\n";d=f.reduce((y,m,g)=>y+(g===0?"":h)+(m===n?"\u{1F4A5} ":" ")+m," Here's the path we travelled up until we hit the recursion:\n\n"),d+="".concat(h,"\u{1F4A5} ").concat(n)}throw new Error('json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "'.concat(r,'" at path "').concat(n,'", we encountered a closed loop, the key is referencing itself."').concat(d))}let t={},a=Array.from(f);a.push(n);let o=new M;function u(d,h,y){for(let m=0,g=d.length;m<g;m++){let p=d[m],b=r.slice(p.headsEndAt,p.tailsStartAt);if(b.length===0)o.push(p.headsStartAt,p.tailsEndAt);else if(lr.call(t,b)&&A(t[b]))o.push(p.headsStartAt,p.tailsEndAt,t[b]);else{let w=gr(e,b.trim(),n,i);if(w===void 0)if(i.allowUnresolved===!0)w="";else if(A(i.allowUnresolved))w=i.allowUnresolved;else throw new Error("json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ".concat(r.slice(p.headsEndAt,p.tailsStartAt),". We're at path: \"").concat(n,'".'));if(!y&&i.throwWhenNonStringInsertedInString&&!A(w))throw new Error("json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ".concat(r.slice(p.headsEndAt,p.tailsStartAt)," at path ").concat(n,", it resolved into a non-string value, ").concat(JSON.stringify(w,null,4),'. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").'));if(q(w)){if(i.resolveToBoolIfAnyValuesContainBool)return o.wipe(),i.resolveToFalseIfAnyValuesContainBool?!1:w;w=""}else{if(B(w)&&y)return o.wipe(),w;Array.isArray(w)?w=String(w.join("")):B(w)?w="":w=String(w)}let v=n.includes(".")?"".concat(je(n),".").concat(b):b;if(ae(w,i)){let W=Ce(Pe(e,w,v,i,a),i,h,a,v,b.trim());A(W)&&o.push(p.headsStartAt,p.tailsEndAt,W)}else{t[b]=w;let W=Ce(w,i,h,a,v,b.trim());A(W)&&o.push(p.headsStartAt,p.tailsEndAt,W)}}}}let l;try{l=ee(r,i.heads,i.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(d){throw new Error('json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "'.concat(r,'" at path ').concat(n,", something wrong with heads and tails was detected! Here's the internal error message:\n").concat(d))}let s=!1;l.length===1&&j(r,[[l[0].headsStartAt,l[0].tailsEndAt]]).trim()===""&&(s=!0);let c=u(l,!1,s);if(typeof c=="boolean"||c===null)return c;try{l=ee(r,i.headsNoWrap,i.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(d){throw new Error('json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "'.concat(r,'" at path ').concat(n,", something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:\n").concat(d))}l.length===1&&j(r,[[l[0].headsStartAt,l[0].tailsEndAt]]).trim()===""&&(s=!0);let $=u(l,!0,s);return q($)||B($)?$:o!=null&&o.current()?j(r,o.current()):r}function hr(e,r){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!E(e))throw new TypeError("json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ".concat(Array.isArray(e)?"array":typeof e));if(r&&!E(r))throw new TypeError("json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ".concat(Array.isArray(r)?"array":typeof r));let n=T(T({},He),r);n.dontWrapVars?Array.isArray(n.dontWrapVars)||(n.dontWrapVars=I(n.dontWrapVars)):n.dontWrapVars=[];let i,f;if(n.dontWrapVars.length&&!n.dontWrapVars.every((a,o)=>A(a)?!0:(i=a,f=o,!1)))throw new Error('json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in resolvedOpts.dontWrapVars should be of a string type. Computer detected a value "'.concat(i,'" at index ').concat(f,", which is not string but ").concat(Array.isArray(i)?"array":typeof i,"!"));if(n.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! resolvedOpts.heads are empty!");if(n.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! resolvedOpts.tails are empty!");if(n.lookForDataContainers&&n.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! resolvedOpts.dataContainerIdentifierTails is empty!");if(n.heads===n.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! resolvedOpts.heads and resolvedOpts.tails can't be equal!");if(n.heads===n.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! resolvedOpts.heads and resolvedOpts.headsNoWrap can't be equal!");if(n.tails===n.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! resolvedOpts.tails and resolvedOpts.tailsNoWrap can't be equal!");if(n.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! resolvedOpts.headsNoWrap is an empty string!");if(n.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! resolvedOpts.tailsNoWrap is an empty string!");if(n.headsNoWrap===n.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! resolvedOpts.headsNoWrap and resolvedOpts.tailsNoWrap can't be equal!");let t;return K(e,(a,o,u)=>{if(S(o)&&ae(a,n))throw new Error("json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!\nPlease check the following key: ".concat(a));if(o!==void 0?t=o:t=a,t==="")return t;if(n.heads.length&&O(t)===O(n.heads)||n.tails.length&&O(t)===O(n.tails)||n.headsNoWrap.length&&O(t)===O(n.headsNoWrap)||n.tailsNoWrap.length&&O(t)===O(n.tailsNoWrap)){if(!n.noSingleMarkers)return t;throw new Error("json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ".concat(O(t)," which is equal to ").concat(O(t)===O(n.heads)?"heads":"").concat(O(t)===O(n.tails)?"tails":"").concat(A(n.headsNoWrap)&&O(t)===O(n.headsNoWrap)?"headsNoWrap":"").concat(A(n.tailsNoWrap)&&O(t)===O(n.tailsNoWrap)?"tailsNoWrap":"",'. If you wouldn\'t have set resolvedOpts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (').concat(O(t),") alone"))}return A(t)&&ae(t,n)?Pe(e,t,u.path,n):t})}return Ke(pr);})();
|
|
47
11
|
/**
|
|
48
12
|
* @name arrayiffy-if-string
|
|
49
13
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
50
|
-
* @version 5.0.
|
|
14
|
+
* @version 5.0.20
|
|
51
15
|
* @author Roy Revelt, Codsen Ltd
|
|
52
16
|
* @license MIT
|
|
53
17
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -55,7 +19,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
55
19
|
/**
|
|
56
20
|
* @name codsen-utils
|
|
57
21
|
* @fileoverview Various utility functions
|
|
58
|
-
* @version 1.6.
|
|
22
|
+
* @version 1.6.18
|
|
59
23
|
* @author Roy Revelt, Codsen Ltd
|
|
60
24
|
* @license MIT
|
|
61
25
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
@@ -63,7 +27,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
63
27
|
/**
|
|
64
28
|
* @name string-match-left-right
|
|
65
29
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
66
|
-
* @version 9.0.
|
|
30
|
+
* @version 9.0.33
|
|
67
31
|
* @author Roy Revelt, Codsen Ltd
|
|
68
32
|
* @license MIT
|
|
69
33
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -71,7 +35,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
71
35
|
/**
|
|
72
36
|
* @name string-collapse-leading-whitespace
|
|
73
37
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
74
|
-
* @version 7.0.
|
|
38
|
+
* @version 7.0.19
|
|
75
39
|
* @author Roy Revelt, Codsen Ltd
|
|
76
40
|
* @license MIT
|
|
77
41
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
@@ -79,7 +43,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
79
43
|
/**
|
|
80
44
|
* @name ranges-sort
|
|
81
45
|
* @fileoverview Sort string index ranges
|
|
82
|
-
* @version 6.0.
|
|
46
|
+
* @version 6.0.24
|
|
83
47
|
* @author Roy Revelt, Codsen Ltd
|
|
84
48
|
* @license MIT
|
|
85
49
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -87,7 +51,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
87
51
|
/**
|
|
88
52
|
* @name ranges-push
|
|
89
53
|
* @fileoverview Gather string index ranges
|
|
90
|
-
* @version 7.0.
|
|
54
|
+
* @version 7.0.29
|
|
91
55
|
* @author Roy Revelt, Codsen Ltd
|
|
92
56
|
* @license MIT
|
|
93
57
|
* {@link https://codsen.com/os/ranges-push/}
|
|
@@ -95,7 +59,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
95
59
|
/**
|
|
96
60
|
* @name ranges-merge
|
|
97
61
|
* @fileoverview Merge and sort string index ranges
|
|
98
|
-
* @version 9.0.
|
|
62
|
+
* @version 9.0.29
|
|
99
63
|
* @author Roy Revelt, Codsen Ltd
|
|
100
64
|
* @license MIT
|
|
101
65
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -103,7 +67,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
103
67
|
/**
|
|
104
68
|
* @name ranges-apply
|
|
105
69
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
106
|
-
* @version 7.0.
|
|
70
|
+
* @version 7.0.30
|
|
107
71
|
* @author Roy Revelt, Codsen Ltd
|
|
108
72
|
* @license MIT
|
|
109
73
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -111,7 +75,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
111
75
|
/**
|
|
112
76
|
* @name string-trim-spaces-only
|
|
113
77
|
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
114
|
-
* @version 5.0.
|
|
78
|
+
* @version 5.0.23
|
|
115
79
|
* @author Roy Revelt, Codsen Ltd
|
|
116
80
|
* @license MIT
|
|
117
81
|
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
|
@@ -119,7 +83,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
119
83
|
/**
|
|
120
84
|
* @name string-remove-duplicate-heads-tails
|
|
121
85
|
* @fileoverview Detect and (recursively) remove head and tail wrappings around the input string
|
|
122
|
-
* @version 7.0.
|
|
86
|
+
* @version 7.0.33
|
|
123
87
|
* @author Roy Revelt, Codsen Ltd
|
|
124
88
|
* @license MIT
|
|
125
89
|
* {@link https://codsen.com/os/string-remove-duplicate-heads-tails/}
|
|
@@ -127,7 +91,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
127
91
|
/**
|
|
128
92
|
* @name string-find-heads-tails
|
|
129
93
|
* @fileoverview Finds where are arbitrary templating marker heads and tails located
|
|
130
|
-
* @version 6.0.
|
|
94
|
+
* @version 6.0.33
|
|
131
95
|
* @author Roy Revelt, Codsen Ltd
|
|
132
96
|
* @license MIT
|
|
133
97
|
* {@link https://codsen.com/os/string-find-heads-tails/}
|
|
@@ -135,7 +99,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
135
99
|
/**
|
|
136
100
|
* @name ast-monkey-util
|
|
137
101
|
* @fileoverview Utility library of AST helper functions
|
|
138
|
-
* @version 3.0.
|
|
102
|
+
* @version 3.0.20
|
|
139
103
|
* @author Roy Revelt, Codsen Ltd
|
|
140
104
|
* @license MIT
|
|
141
105
|
* {@link https://codsen.com/os/ast-monkey-util/}
|
|
@@ -143,7 +107,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
143
107
|
/**
|
|
144
108
|
* @name ast-monkey-traverse
|
|
145
109
|
* @fileoverview Utility library to traverse AST
|
|
146
|
-
* @version 4.0.
|
|
110
|
+
* @version 4.0.30
|
|
147
111
|
* @author Roy Revelt, Codsen Ltd
|
|
148
112
|
* @license MIT
|
|
149
113
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
@@ -151,7 +115,7 @@ Please check the following key: ${s}`);if(o!==void 0?t=o:t=s,t==="")return t;if(
|
|
|
151
115
|
/**
|
|
152
116
|
* @name ast-get-values-by-key
|
|
153
117
|
* @fileoverview Extract values and paths from AST by keys OR set them by keys
|
|
154
|
-
* @version 5.0.
|
|
118
|
+
* @version 5.0.32
|
|
155
119
|
* @author Roy Revelt, Codsen Ltd
|
|
156
120
|
* @license MIT
|
|
157
121
|
* {@link https://codsen.com/os/ast-get-values-by-key/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-variables",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.33",
|
|
4
4
|
"description": "Resolves custom-marked, cross-referenced paths in parsed JSON",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comb",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
|
|
50
50
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
51
51
|
"lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
52
|
-
"letspublish": "npm publish || :",
|
|
52
|
+
"letspublish": "npm publish --provenance || :",
|
|
53
53
|
"lint": "eslint . --fix",
|
|
54
54
|
"perf": "node perf/check.js",
|
|
55
55
|
"prep": "echo 'ready'",
|
|
@@ -78,16 +78,19 @@
|
|
|
78
78
|
"various": {}
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"arrayiffy-if-string": "^5.0.
|
|
82
|
-
"ast-get-values-by-key": "^5.0.
|
|
83
|
-
"ast-monkey-traverse": "^4.0.
|
|
84
|
-
"codsen-utils": "^1.6.
|
|
85
|
-
"matcher": "^
|
|
81
|
+
"arrayiffy-if-string": "^5.0.20",
|
|
82
|
+
"ast-get-values-by-key": "^5.0.32",
|
|
83
|
+
"ast-monkey-traverse": "^4.0.30",
|
|
84
|
+
"codsen-utils": "^1.6.18",
|
|
85
|
+
"matcher": "^6.0.0",
|
|
86
86
|
"object-path": "^0.11.8",
|
|
87
|
-
"ranges-apply": "^7.0.
|
|
88
|
-
"ranges-push": "^7.0.
|
|
89
|
-
"string-find-heads-tails": "^6.0.
|
|
90
|
-
"string-match-left-right": "^9.0.
|
|
91
|
-
"string-remove-duplicate-heads-tails": "^7.0.
|
|
87
|
+
"ranges-apply": "^7.0.30",
|
|
88
|
+
"ranges-push": "^7.0.29",
|
|
89
|
+
"string-find-heads-tails": "^6.0.33",
|
|
90
|
+
"string-match-left-right": "^9.0.33",
|
|
91
|
+
"string-remove-duplicate-heads-tails": "^7.0.33"
|
|
92
|
+
},
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"registry": "https://registry.npmjs.org/"
|
|
92
95
|
}
|
|
93
96
|
}
|