UNPKG

json-variables

Version:

Resolves custom-marked, cross-referenced paths in parsed JSON

61 lines (60 loc) 51.6 kB
/** * @name json-variables * @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON * @version 12.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/json-variables/} */ "use strict";var jsonVariables=(()=>{var ke=Object.create,ce=Object.freeze,R=Object.defineProperty,Fe=Object.defineProperties,Le=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertyNames,ge=Object.getOwnPropertySymbols,Ke=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var X=(e,r,n)=>r in e?R(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,A=(e,r)=>{for(var n in r||(r={}))he.call(r,n)&&X(e,n,r[n]);if(ge)for(var n of ge(r))ze.call(r,n)&&X(e,n,r[n]);return e},B=(e,r)=>Fe(e,qe(r));var pe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ge=(e,r)=>{for(var n in r)R(e,n,{get:r[n],enumerable:!0})},de=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of Ue(r))!he.call(e,f)&&f!==n&&R(e,f,{get:()=>r[f],enumerable:!(s=Le(r,f))||s.enumerable});return e};var F=(e,r,n)=>(n=e!=null?ke(Ke(e)):{},de(r||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),Qe=e=>de(R({},"__esModule",{value:!0}),e);var ee=(e,r,n)=>X(e,typeof r!="symbol"?r+"":r,n);var L=(e,r)=>ce(R(e,"raw",{value:ce(r||e.slice())}));var q=pe((mr,me)=>{"use strict";me.exports=Ze;function x(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 Ye(e);let r=new Map;if(r.set(Date,o=>new Date(o)),r.set(Map,(o,l)=>new Map(s(Array.from(o),l))),r.set(Set,(o,l)=>new Set(s(Array.from(o),l))),e.constructorHandlers)for(let o of e.constructorHandlers)r.set(o[0],o[1]);let n=null;return e.proto?t:f;function s(o,l){let i=Object.keys(o),u=new Array(i.length);for(let a=0;a<i.length;a++){let c=i[a],$=o[c];typeof $!="object"||$===null?u[c]=$:$.constructor!==Object&&(n=r.get($.constructor))?u[c]=n($,l):ArrayBuffer.isView($)?u[c]=x($):u[c]=l($)}return u}function f(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,f);if(o.constructor!==Object&&(n=r.get(o.constructor)))return n(o,f);let l={};for(let i in o){if(Object.hasOwnProperty.call(o,i)===!1)continue;let u=o[i];typeof u!="object"||u===null?l[i]=u:u.constructor!==Object&&(n=r.get(u.constructor))?l[i]=n(u,f):ArrayBuffer.isView(u)?l[i]=x(u):l[i]=f(u)}return l}function t(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,t);if(o.constructor!==Object&&(n=r.get(o.constructor)))return n(o,t);let l={};for(let i in o){let u=o[i];typeof u!="object"||u===null?l[i]=u:u.constructor!==Object&&(n=r.get(u.constructor))?l[i]=n(u,t):ArrayBuffer.isView(u)?l[i]=x(u):l[i]=t(u)}return l}}function Ye(e){let r=[],n=[],s=new Map;if(s.set(Date,i=>new Date(i)),s.set(Map,(i,u)=>new Map(t(Array.from(i),u))),s.set(Set,(i,u)=>new Set(t(Array.from(i),u))),e.constructorHandlers)for(let i of e.constructorHandlers)s.set(i[0],i[1]);let f=null;return e.proto?l:o;function t(i,u){let a=Object.keys(i),c=new Array(a.length);for(let $=0;$<a.length;$++){let y=a[$],g=i[y];if(typeof g!="object"||g===null)c[y]=g;else if(g.constructor!==Object&&(f=s.get(g.constructor)))c[y]=f(g,u);else if(ArrayBuffer.isView(g))c[y]=x(g);else{let d=r.indexOf(g);d!==-1?c[y]=n[d]:c[y]=u(g)}}return c}function o(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return t(i,o);if(i.constructor!==Object&&(f=s.get(i.constructor)))return f(i,o);let u={};r.push(i),n.push(u);for(let a in i){if(Object.hasOwnProperty.call(i,a)===!1)continue;let c=i[a];if(typeof c!="object"||c===null)u[a]=c;else if(c.constructor!==Object&&(f=s.get(c.constructor)))u[a]=f(c,o);else if(ArrayBuffer.isView(c))u[a]=x(c);else{let $=r.indexOf(c);$!==-1?u[a]=n[$]:u[a]=o(c)}}return r.pop(),n.pop(),u}function l(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return t(i,l);if(i.constructor!==Object&&(f=s.get(i.constructor)))return f(i,l);let u={};r.push(i),n.push(u);for(let a in i){let c=i[a];if(typeof c!="object"||c===null)u[a]=c;else if(c.constructor!==Object&&(f=s.get(c.constructor)))u[a]=f(c,l);else if(ArrayBuffer.isView(c))u[a]=x(c);else{let $=r.indexOf(c);$!==-1?u[a]=n[$]:u[a]=l(c)}}return r.pop(),n.pop(),u}}});var Re=pe((_e,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()})(_e,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 s(a){return e.call(a)}function f(a){return typeof a=="object"&&s(a)==="[object Object]"}var t=Array.isArray||function(a){return e.call(a)==="[object Array]"};function o(a){return typeof a=="boolean"||s(a)==="[object Boolean]"}function l(a){var c=parseInt(a);return c.toString()===a?c:a}function i(a){a=a||{};var c=function(m){return Object.keys(c).reduce(function(h,p){return p==="create"||typeof c[p]=="function"&&(h[p]=c[p].bind(c,m)),h},{})},$;a.includeInheritedProps?$=function(){return!0}:$=function(m,h){return typeof h=="number"&&Array.isArray(m)||r(m,h)};function y(m,h){if($(m,h))return m[h]}var g;a.includeInheritedProps?g=function(m,h){typeof h!="string"&&typeof h!="number"&&(h=String(h));var p=y(m,h);if(h==="__proto__"||h==="prototype"||h==="constructor"&&typeof p=="function")throw new Error("For security reasons, object's magic properties cannot be set");return p}:g=function(m,h){return y(m,h)};function d(m,h,p,w){if(typeof h=="number"&&(h=[h]),!h||h.length===0)return m;if(typeof h=="string")return d(m,h.split(".").map(l),p,w);var b=h[0],v=g(m,b);return h.length===1?((v===void 0||!w)&&(m[b]=p),v):(v===void 0&&(typeof h[1]=="number"?m[b]=[]:m[b]={}),d(m[b],h.slice(1),p,w))}return c.has=function(m,h){if(typeof h=="number"?h=[h]:typeof h=="string"&&(h=h.split(".")),!h||h.length===0)return!!m;for(var p=0;p<h.length;p++){var w=l(h[p]);if(typeof w=="number"&&t(m)&&w<m.length||(a.includeInheritedProps?w in Object(m):r(m,w)))m=m[w];else return!1}return!0},c.ensureExists=function(m,h,p){return d(m,h,p,!0)},c.set=function(m,h,p,w){return d(m,h,p,w)},c.insert=function(m,h,p,w){var b=c.get(m,h);w=~~w,t(b)||(b=[],c.set(m,h,b)),b.splice(w,0,p)},c.empty=function(m,h){if(!n(h)&&m!=null){var p,w;if(p=c.get(m,h)){if(typeof p=="string")return c.set(m,h,"");if(o(p))return c.set(m,h,!1);if(typeof p=="number")return c.set(m,h,0);if(t(p))p.length=0;else if(f(p))for(w in p)$(p,w)&&delete p[w];else return c.set(m,h,null)}}},c.push=function(m,h){var p=c.get(m,h);t(p)||(p=[],c.set(m,h,p)),p.push.apply(p,Array.prototype.slice.call(arguments,2))},c.coalesce=function(m,h,p){for(var w,b=0,v=h.length;b<v;b++)if((w=c.get(m,h[b]))!==void 0)return w;return p},c.get=function(m,h,p){if(typeof h=="number"&&(h=[h]),!h||h.length===0)return m;if(m==null)return p;if(typeof h=="string")return c.get(m,h.split("."),p);var w=l(h[0]),b=g(m,w);return b===void 0?p:h.length===1?b:c.get(m[w],h.slice(1),p)},c.del=function(h,p){if(typeof p=="number"&&(p=[p]),h==null||n(p))return h;if(typeof p=="string")return c.del(h,p.split("."));var w=l(p[0]);if(g(h,w),!$(h,w))return h;if(p.length===1)t(h)?h.splice(w,1):delete h[w];else return c.del(h[w],p.slice(1));return h},c}var u=i();return u.create=i,u.withInheritedProps=i({includeInheritedProps:!0}),u})});var pr={};Ge(pr,{defaults:()=>Je,jVar:()=>hr,version:()=>fr});var ye=F(q(),1);var yr=(0,ye.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 H(e){return Number.isFinite(e)}function _(e){return Number.isSafeInteger(e)&&e>=0}function U(e){return typeof e=="boolean"}function J(e){return e===null}function I(e){return e!=null}function we(e,r){return E(e)&&T(r)&&r in e}function S(e){return typeof e!="string"?e:e.length?[e]:[]}var be={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},Xe=e=>e+1;function er(e,r,n,s,f=!1,t=Xe){var w;let o=typeof n=="function"?n():n;if(+r<0&&f&&o==="EOL")return o;let l=A(A({},be),s);if(r>=e.length&&!f)return!1;let i=f?1:n.length,u=0,a=!1,c=!1,$=!1,y=l.maxMismatches,g=r,d=!1,m=!1,h=!1;function p(){return u===1&&y<l.maxMismatches-1}for(;e[g];){let b=t(g);if(l.trimBeforeMatching&&e[g].trim()===""){if(!e[b]&&f&&n==="EOL")return!0;g=t(g);continue}if(l&&!l.i&&((w=l==null?void 0:l.trimCharsBeforeMatching)!=null&&w.includes(e[g]))||l!=null&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map(W=>W.toLowerCase()).includes(e[g].toLowerCase())){if(f&&n==="EOL"&&!e[b])return!0;g=t(g);continue}let v=b>g?n[n.length-i]:n[i-1];if(!l.i&&e[g]===v||l.i&&e[g].toLowerCase()===v.toLowerCase()){if(d||(d=!0),$||($=!0),i===n.length){if(m=!0,y!==l.maxMismatches)return!1}else i===1&&(h=!0);if(i-=1,u++,p())return!1;if(!i)return u!==n.length||y===l.maxMismatches||!a?g:!1}else if(!a&&!u&&(a=!0),l.maxMismatches&&y&&g){y-=1;for(let W=0;W<=y;W++){let V=b>g?n[n.length-i+1+W]:n[i-2-W],Y=e[t(g)];if(V&&(!l.i&&e[g]===V||l.i&&e[g].toLowerCase()===V.toLowerCase())&&(!l.firstMustMatch||i!==n.length)){if(u++,p())return!1;i-=2,d=!0;break}else if(Y&&V&&(!l.i&&Y===V||l.i&&Y.toLowerCase()===V.toLowerCase())&&(!l.firstMustMatch||i!==n.length)){if(!u&&!l.hungry)return!1;i-=1,d=!0;break}else if(V===void 0&&y>=0&&d&&(!l.firstMustMatch||m)&&(!l.lastMustMatch||h))return g}d||(c=g)}else return g===0&&i===1&&!l.lastMustMatch&&$?0:!1;if(c!==!1&&c!==g&&(c=!1),i<1)return g;g=t(g)}if(i>0)return f&&o==="EOL"?!0:l&&l.maxMismatches>=i&&$?c||0:!1}function $e(e,r,n,s,f){var a,c,$;if(E(f)&&we(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=A(A({},be),f);if(typeof t.trimCharsBeforeMatching=="string"&&(t.trimCharsBeforeMatching=S(t.trimCharsBeforeMatching)),t.trimCharsBeforeMatching=t.trimCharsBeforeMatching.map(y=>T(y)?y:String(y)),!T(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 o,l;if(T(s))o=[s];else if(Array.isArray(s))o=s;else if(!s)o=s;else if(typeof s=="function")o=[],o.push(s);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 s,", equal to:\n").concat(JSON.stringify(s,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 i=0,u="";if((a=t==null?void 0:t.trimCharsBeforeMatching)!=null&&a.some((y,g)=>y.length>1?(i=g,u=y,!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(i," is longer than 1 character, ").concat(u.length," (equals to ").concat(u,"). Please split it into separate characters and put into array as separate elements."));if(!o||!Array.isArray(o)||Array.isArray(o)&&!o.length||Array.isArray(o)&&o.length===1&&T(o[0])&&!o[0].trim()){if(typeof t.cb=="function"){let g,d=n;if((e==="matchLeftIncl"||e==="matchRight")&&(d+=1),e[5]==="L")for(let w=d;w--;){let b=r[w];if((!t.trimBeforeMatching||t.trimBeforeMatching&&(b!=null&&b.trim()))&&(!((c=t.trimCharsBeforeMatching)!=null&&c.length)||b!==void 0&&!t.trimCharsBeforeMatching.includes(b))){g=w;break}}else if(e.startsWith("matchRight"))for(let w=d;w<r.length;w++){let b=r[w];if((!t.trimBeforeMatching||t.trimBeforeMatching&&b.trim())&&(!(($=t.trimCharsBeforeMatching)!=null&&$.length)||!t.trimCharsBeforeMatching.includes(b))){g=w;break}}if(g===void 0)return!1;let m=r[g],h=g+1,p="";return h&&h>0&&(p=r.slice(0,h)),e[5]==="L"||g&&g>0&&(p=r.slice(g)),t.cb(m,p,g)}let y="";throw f||(y=" 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(y))}for(let y=0,g=o.length;y<g;y++){l=typeof o[y]=="function";let d=o[y],m,h,p="",w=n;e==="matchRight"?w+=1:e==="matchLeft"&&(w-=1);let b=er(r,w,d,t,l,v=>e[5]==="L"?v-1:v+1);if(b&&l&&typeof d=="function"&&d()==="EOL")return d()&&(!t.cb||t.cb(m,p,h))?d():!1;if(Number.isInteger(b)&&(h=e.startsWith("matchLeft")?b-1:b+1,e[5]==="L"?p=r.slice(0,b):p=r.slice(h)),h<0&&(h=void 0),r[h]&&(m=r[h]),Number.isInteger(b)&&(!t.cb||t.cb(m,p,h)))return d}return!1}function C(e,r,n,s){return $e("matchLeftIncl",e,r,n,s)}function D(e,r,n,s){return $e("matchRightIncl",e,r,n,s)}var Te={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function re(e,r,n,s){if(I(s)&&!E(s))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(s," (type: ").concat(typeof s,")"));let f=A(A({},Te),s);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("".concat(f.source," [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ").concat(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: ".concat(typeof e,", equal to: ").concat(e))}let t,o;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: ".concat(typeof r,", equal to:\n").concat(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=S(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((g,d)=>(t=g,o=d,T(g)))){if(!r.every((g,d)=>(o=d,T(g)&&g.length&&g.trim()!=="")))if(f.relaxedAPI){if(r=r.filter(g=>T(g)&&g.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(o," of heads array:\n").concat(JSON.stringify(r,null,4),"."))}else if(f.relaxedAPI){if(r=r.filter(g=>T(g)&&g.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(o,"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(!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: ".concat(typeof n,", equal to:\n").concat(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=S(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((g,d)=>(t=g,o=d,T(g)))){if(!n.every((g,d)=>(o=d,T(g)&&g.length&&g.trim()!=="")))if(f.relaxedAPI){if(n=n.filter(g=>T(g)&&g.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(o,". Whole tails array is equal to:\n").concat(JSON.stringify(n,null,4)))}else if(f.relaxedAPI){if(n=n.filter(g=>T(g)&&g.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(o,"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 l=f.source===Te.source;if(f.throwWhenSomethingWrongIsDetected&&!f.allowWholeValueToBeOnlyHeadsOrTails){if(S(r).includes(e))throw new Error("".concat(f.source).concat(l?": [THROW_ID_16]":""," the whole input string can't be equal to ").concat(T(r)?"":"one of ","heads (").concat(e,")!"));if(S(n).includes(e))throw new Error("".concat(f.source).concat(l?": [THROW_ID_17]":""," the whole input string can't be equal to ").concat(T(n)?"":"one of ","tails (").concat(e,")!"))}let i=r.concat(n).map(g=>g.charAt(0)).reduce((g,d)=>d.charCodeAt(0)>g[1]?[g[0],d.charCodeAt(0)]:d.charCodeAt(0)<g[0]?[d.charCodeAt(0),g[1]]:g,[r[0].charCodeAt(0),r[0].charCodeAt(0)]),u=[],a=!1,c={},$="",y;for(let g=f.fromIndex,d=e.length;g<d;g++){let m=e[g].charCodeAt(0);if(m<=i[1]&&m>=i[0]){let h=D(e,g,r);if(h&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder){for(let w=r.length;w--;)if(r[w]===h){y=w;break}}if(T(h))if(a){if(f.throwWhenSomethingWrongIsDetected)throw new TypeError("".concat(f.source).concat(l?": [THROW_ID_19]":"",' When processing "').concat(e,'", we found heads (').concat(e.slice(g,g+h.length),') starting at character with index number "').concat(g,'" 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(g-200,0),g),"\n \x1B[33m------->\x1B[39m ").concat("\x1B[31m".concat(e.slice(g,g+h.length),"\x1B[39m")," \x1B[33m<-------\x1B[39m\n").concat(e.slice(g+h.length,Math.min(d,g+200)),"\n--------------------------------------ends\n\n\nTo turn off this error being thrown, set resolvedOpts.throwWhenSomethingWrongIsDetected to Boolean false."))}else{c={},c.headsStartAt=g,c.headsEndAt=g+h.length,a=!0,g+=h.length-1,$&&($="");continue}let p=D(e,g,n);if(a&&p&&f.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&y!==void 0&&n[y]!==void 0&&n[y]!==p){let w;for(let b=n.length;b--;)if(n[b]===p){w=b;break}throw new TypeError("".concat(f.source).concat(l?": [THROW_ID_20]":"",' When processing "').concat(e,'", we had "resolvedOpts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (').concat(r[y],") but the tails the followed it were not of the same index, ").concat(y," (").concat(n[y],") but ").concat(w," (").concat(p,")."))}if(T(p))if(a){c.tailsStartAt=g,c.tailsEndAt=g+p.length,u.push(c),c={},a=!1,g+=p.length-1;continue}else f.throwWhenSomethingWrongIsDetected&&($="".concat(f.source).concat(l?": [THROW_ID_21]":"",' When processing "').concat(e,'", we found tails (').concat(e.slice(g,g+p.length),') starting at character with index number "').concat(g,"\" but there were no heads preceding it. That's very naughty!"))}if(f.throwWhenSomethingWrongIsDetected&&g===d-1){if(Object.keys(c).length!==0)throw new TypeError("".concat(f.source).concat(l?": [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 u}var Ae=F(q(),1);function te(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 ne=(0,Ae.default)();function K(e,r){let n={now:!1};function s(f,t,o,l){let i=ne(f),u,a=A({depth:-1,path:""},o);if(a.depth+=1,Array.isArray(i))for(let c=0,$=i.length;c<$&&!l.now;c++){let y=a.path?"".concat(a.path,".").concat(c):"".concat(c);i[c]!==void 0?(a.parent=ne(i),a.parentType="array",a.parentKey=te(y),u=s(t(i[c],void 0,B(A({},a),{path:y}),l),t,B(A({},a),{path:y}),l),Number.isNaN(u)&&c<i.length?(i.splice(c,1),c-=1):i[c]=u):i.splice(c,1)}else if(E(i))for(let c in i){if(l.now&&c!=null)break;let $=a.path?"".concat(a.path,".").concat(c):c;a.depth===0&&c!=null&&(a.topmostKey=c),a.parent=ne(i),a.parentType="object",a.parentKey=te($),u=s(t(c,i[c],B(A({},a),{path:$}),l),t,B(A({},a),{path:$}),l),Number.isNaN(u)?delete i[c]:i[c]=u}return i}return s(e,r,{},n)}function se(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ie=new Map,Oe=(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})},ve,Ee,Se,rr=(e,r)=>{r=A({caseSensitive:!1},r);let n="s"+(r.caseSensitive?"":"i"),s=e+"|"+n;if(ie.has(s))return ie.get(s);let f=e[0]==="!";f&&(e=e.slice(1)),e=e.replaceAll(String.raw(ve||(ve=L(["*"],["\\*"]))),"__ESCAPED_STAR__").replaceAll("\\\\","__ESCAPED_BACKSLASH__").replaceAll(/\\(.)/g,"$1"),e=se(e).replaceAll(String.raw(Ee||(Ee=L(["*"],["\\*"]))),".*"),e=e.replaceAll("__ESCAPED_STAR__",String.raw(Se||(Se=L(["*"],["\\*"])))).replaceAll("__ESCAPED_BACKSLASH__","\\\\");let t=new RegExp("^".concat(e,"$"),n);return t.negated=f,ie.set(s,t),t},tr=(e,r,n,s)=>{if(e=Oe(e,"inputs"),r=Oe(r,"patterns"),r.length===0)return[];r=r.map(i=>rr(i,n));let f=r.filter(i=>i.negated),t=r.filter(i=>!i.negated),{allPatterns:o}=n||{},l=[];if(o&&s&&f.length>1&&t.length===0){for(let i of e)for(let u of f)if(u.test(i))return[];return e.slice(0,1)}for(let i of e){let u=!1;for(let a of f)if(a.test(i)){u=!0;break}if(!u){if(t.length===0)l.push(i);else if(o){let a=Array.from({length:t.length},()=>!1);for(let[c,$]of t.entries())$.test(i)&&(a[c]=!0);a.every(Boolean)&&l.push(i)}else{let a=!1;for(let c of t)if(c.test(i)){a=!0;break}a&&l.push(i)}if(s&&l.length>0)break}}return l};function z(e,r,n){return tr(e,r,n,!0).length>0}var We=F(q(),1);var Ie=(0,We.default)();function ae(e,r,n){let s;n!==void 0&&(s=Array.isArray(n)?Ie(n):[Ie(n)]);let f=[],t=K(e,(o,l,i)=>{let u=l!==void 0?l:o;if(l!==void 0&&z(o,r,{caseSensitive:!0})){if(s===void 0)f.push({val:l,path:i.path});else if(s.length)return s.shift()}return u});return s===void 0?f:t}var nr={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function j(e,r){if(!Array.isArray(e)||!e.length)return e;let n=A(A({},nr),r),s,f;if(n.strictlyTwoElementsInRangeArrays&&!e.every((l,i)=>!Array.isArray(l)||l.length!==2?(s=i,f=l.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(s,"th range (").concat(JSON.stringify(e[s],null,4),") has not two but ").concat(f," elements!"));if(!e.every((l,i)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(s=i,!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(s,"th range (").concat(JSON.stringify(e[s],null,4),") does not consist of only natural numbers!"));let t=e.length**2,o=0;return Array.from(e).sort((l,i)=>(n.progressFn&&(o+=1,n.progressFn(Math.floor(o*100/t))),l[0]===i[0]?l[1]<i[1]?-1:l[1]>i[1]?1:0:l[0]<i[0]?-1:1))}var De={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ne(e,r){function n(u){return!!u&&typeof u=="object"&&!Array.isArray(u)}if(!Array.isArray(e)||!e.length)return null;let s;if(r)if(n(r)){if(s=A(A({},De),r),s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new Error('ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat(JSON.stringify(s.progressFn,null,4)));if(![1,2,"1","2"].includes(s.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 s.mergeType,'", equal to ').concat(JSON.stringify(s.mergeType,null,4)));if(typeof s.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 s.joinRangesThatTouchEdges,'", equal to ').concat(JSON.stringify(s.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 s=A({},De);let f=e.filter(u=>Array.isArray(u)).map(u=>[...u]).filter(u=>u[2]!==void 0||u[0]!==u[1]),t,o,l;s.progressFn?t=j(f,{progressFn:u=>{l=Math.floor(u/5),l!==o&&(o=l,s.progressFn(l))}}):t=j(f);let i=t.length-1;for(let u=i;u>0;u--)s.progressFn&&(l=Math.floor((1-u/i)*78)+21,l!==o&&l>o&&(o=l,s.progressFn(l))),(t[u][0]<=t[u-1][0]||!s.joinRangesThatTouchEdges&&t[u][0]<t[u-1][1]||s.joinRangesThatTouchEdges&&t[u][0]<=t[u-1][1])&&(t[u-1][0]=Math.min(t[u][0],t[u-1][0]),t[u-1][1]=Math.max(t[u][1],t[u-1][1]),t[u][2]!==void 0&&(t[u-1][0]>=t[u][0]||t[u-1][1]<=t[u][1])&&t[u-1][2]!==null&&(t[u][2]===null&&t[u-1][2]!==null?t[u-1][2]=null:t[u-1][2]!=null?+s.mergeType==2&&t[u-1][0]===t[u][0]?t[u-1][2]=t[u][2]:t[u-1][2]+=t[u][2]:t[u-1][2]=t[u][2]),t.splice(u,1),u=t.length);return t.length?t:null}var sr=!0,oe="Invariant failed";function Ve(e,r){if(!e){if(sr)throw new Error(oe);var n=typeof r=="function"?r():r,s=n?"".concat(oe,": ").concat(n):oe;throw new Error(s)}}function P(e,r,n){let s=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(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 o=t.length,l=0;t.filter(a=>a).forEach((a,c)=>{if(n&&(s=Math.floor(l/o*10),s!==f&&(f=s,n(s))),!Array.isArray(a))throw new TypeError("ranges-apply: [THROW_ID_05] ranges array, second input arg., has ".concat(c,"th element not an array: ").concat(JSON.stringify(a,null,4),", which is ").concat(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 ".concat(c,"th element, array ").concat(JSON.stringify(a,null,0),". Its first element is not an integer, string index, but ").concat(typeof a[0],", equal to: ").concat(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 ".concat(c,"th element, array ").concat(JSON.stringify(a,null,0),". Its second element is not an integer, string index, but ").concat(typeof a[1],", equal to: ").concat(JSON.stringify(a[1],null,4),"."));t[c][1]=+t[c][1]}l+=1});let i=Ne(t,{progressFn:a=>{n&&(s=10+Math.floor(a/10),s!==f&&(f=s,n(s)))}});Ve(i);let u=i.length;if(u>0){let a=e.slice(i[u-1][1]);e=i.reduce((c,$,y,g)=>{n&&(s=20+Math.floor(y/u*80),s!==f&&(f=s,n(s)));let d=y===0?0:g[y-1][1],m=g[y][0];return"".concat(c).concat(e.slice(d,m)).concat(g[y][2]||"")},""),e+=a}return e}var N=F(Re(),1);function Q(e,r=1){let n="\xA0";function s(t){return Array.from(t).reverse().join("")}function f(t,o,l){let i=l?"\n":"\r",u=l?"\r":"\n";if(!t)return t;let a=0,c=0,$="";for(let y=0,g=t.length;y<g;y++)(t[y]===i||t[y]===u&&t[y-1]!==i)&&c++,"\r\n".includes(t[y])||t[y]===n?(a=0,t[y]===n?$+=t[y]:t[y]===i?c<=o&&($+=t[y],t[y+1]===u&&($+=t[y+1],y++)):t[y]===u&&(t==null?void 0:t[y-1])!==i&&c<=o&&($+=t[y])):(a++,!t[y+1]&&!c&&($+=" "));return $}if(typeof e=="string"&&e.length){let t=1;typeof+r=="number"&&Number.isInteger(+r)&&+r>=0&&(t=+r);let o="",l="";if(!e.trim())o=e;else if(!e[0].trim()){for(let i=0,u=e.length;i<u;i++)if(e[i].trim()){o=e.slice(0,i);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let i=e.length;i--;)if(e[i].trim()){l=e.slice(i+1);break}}return"".concat(f(o,t,!1)).concat(e.trim()).concat(s(f(s(l),t,!0)))}return e}var xe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ir(e,r){var u;function n(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let s;if(r)if(n(r)){if(s=A(A({},xe),r),s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new Error('ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat(JSON.stringify(s.progressFn,null,4)));if(![1,2,"1","2"].includes(s.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 s.mergeType,'", equal to ').concat(JSON.stringify(s.mergeType,null,4)));if(typeof s.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 s.joinRangesThatTouchEdges,'", equal to ').concat(JSON.stringify(s.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 s=A({},xe);let f=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),t,o,l;s.progressFn?t=j(f,{progressFn:a=>{l=Math.floor(a/5),l!==o&&(o=l,s.progressFn!=null&&s.progressFn(l))}}):t=j(f);let i=t.length-1;for(let a=i;a>0;a--)s.progressFn&&(l=Math.floor((1-a/i)*78)+21,l!==o&&l>o&&(o=l,s.progressFn(l))),(t[a][0]<=t[a-1][0]||!s.joinRangesThatTouchEdges&&t[a][0]<t[a-1][1]||s.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?+((u=s||{})==null?void 0:u.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 ar={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},M=class{constructor(e){ee(this,"ranges");ee(this,"opts");let r=A(A({},ar),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: "'.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(I(e)&&!I(r)){if(Array.isArray(e)){if(e.length){if(e.some(o=>Array.isArray(o))){e.forEach(o=>{Array.isArray(o)&&this.add(...o)});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 ('.concat(JSON.stringify(e,null,0),') but second-one, "to" is not (').concat(JSON.stringify(r,null,0),")"))}else if(!I(e)&&I(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 s=+e,f=+r;if(_(s)&&_(f)){if(I(n)&&!T(n)&&!H(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(I(this.ranges)&&Array.isArray(this.last())&&s===this.last()[1]){if(this.last()[1]=f,this.last()[2],this.last()[2]!==null&&I(n)){let o=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&&(o=Q(o,this.opts.limitLinebreaksCount)),T(o)&&!o.length||(this.last()[2]=o)}}else{this.ranges||(this.ranges=[]);let o=n!==void 0&&!(T(n)&&!n.length)?[s,f,n&&this.opts.limitToBeAddedWhitespace?Q(n,this.opts.limitLinebreaksCount):n]:[s,f];this.ranges.push(o)}}else throw _(s)&&s>=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 s,'" equal to: ').concat(JSON.stringify(s,null,4)))}push(e,r,n){this.add(e,r,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=ir(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(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, ".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}};function He(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 le(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 ue(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 Ce(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 Z(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))}var or={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function k(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=A(A({},or),r);function s(o){return n.classicTrim&&!o.trim()||!n.classicTrim&&(n.space&&o===" "||n.cr&&o==="\r"||n.lf&&o==="\n"||n.tab&&o===" "||n.nbsp&&o==="\xA0")}let f,t;if(e.length){if(s(e[0]))for(let o=0,l=e.length;o<l;o++){if(!s(e[o])){f=o;break}if(o===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(s(e[e.length-1])){for(let o=e.length;o--;)if(!s(e[o])){t=o+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 lr={heads:["{{"],tails:["}}"]};function je(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 s=A({},r);if(s&&n.call(s,"heads"))if(S(s.heads).every(d=>typeof d=="string"||Array.isArray(d)))typeof s.heads=="string"&&(s.heads=S(s.heads));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_04] The resolvedOpts.heads contains elements which are not string-type!");if(s&&n.call(s,"tails"))if(S(s.tails).every(d=>typeof d=="string"||Array.isArray(d)))typeof s.tails=="string"&&(s.tails=S(s.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=k(e).res;if(f.length===0)return e;e=f;let t=A(A({},lr),s);t.heads=t.heads.map(d=>d.trim()),t.tails=t.tails.map(d=>d.trim());let o=!1,l=!1,i=new M({limitToBeAddedWhitespace:!0}),u=new M({limitToBeAddedWhitespace:!0}),a=!0,c=!0,$="";function y(d,m){let h;return D(d,0,m.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=b,!0)})&&D(d,h,m.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=b,!0)})?d.slice(h):d}for(;e!==y(e,t);)e=k(y(e,t)).res;function g(d,m){let h;return!C(d,d.length-1,m.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=b,!0)})||!h?d:C(d,h,m.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=b,!0)})?d.slice(0,h+1):d}for(;e!==g(e,t);)e=k(g(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 k(e).res;for(let d=0,m=e.length;d<m;d++)if(e[d].trim()!==""){let h;if(D(e,d,t.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=b,!0)})&&h){c=!0,a&&(a=!0);let p;D(e,h,t.tails,{trimBeforeMatching:!0,cb:(w,b,v)=>(p=v,!0)})&&i.push(d,p),u.current()&&o&&$!=="tails"&&i.push(u.current()),o||u.current()&&(i.push(u.current()),u.wipe()),u.push(d,h),$="heads",d=h-1;continue}if(D(e,d,t.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(h=Number.isInteger(b)?b:e.length,!0)})&&h){c=!0,a?($==="heads"&&u.wipe(),a=!1):u.push(d,h),$="tails",d=h-1;continue}a&&(a=!0),c&&!o?(o=!0,c=!1):c&&!l?(l=!0,a=!0,c=!1,$==="heads"&&u.wipe()):c&&l&&u.wipe()}return u.current()&&i.push(u.current()),i.current()?P(e,i.current()).trim():e.trim()}function Pe(e,r,n){let s,f;return T(e)&&e.length&&D(e,0,r,{trimBeforeMatching:!0,cb:(t,o,l)=>(s=l,!0)})&&C(e,e.length-1,n,{trimBeforeMatching:!0,cb:(t,o,l)=>(f=(l||0)+1,!0)})?e.slice(s,f):e}function fe(e,r,n=!1,s,f,t){if(r.wrapHeadsWith||(r.wrapHeadsWith=""),r.wrapTailsWith||(r.wrapTailsWith=""),T(e)&&!n&&r.wrapGlobalFlipSwitch&&!r.dontWrapVars.some(o=>z(t,o))&&(!r.preventDoubleWrapping||r.preventDoubleWrapping&&T(e)&&!e.includes(r.wrapHeadsWith)&&!e.includes(r.wrapTailsWith)))return"".concat(r.wrapHeadsWith).concat(e).concat(r.wrapTailsWith);if(n){if(!T(e))return e;let o=je(e,{heads:r.wrapHeadsWith,tails:r.wrapTailsWith});return T(o)?Pe(o,r.wrapHeadsWith,r.wrapTailsWith):o}return e}var Be="12.1.3";var fr=Be,cr=Object.prototype.hasOwnProperty,Je={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 T(e)?e.trim():e}function gr(e,r,n,s){let f;if(n.indexOf(".")!==-1){let t=n,o=!0;if(s.lookForDataContainers&&T(s.dataContainerIdentifierTails)&&s.dataContainerIdentifierTails.length&&!t.endsWith(s.dataContainerIdentifierTails)){let l=N.default.get(e,t+s.dataContainerIdentifierTails);E(l)&&N.default.get(l,r)&&(f=N.default.get(l,r),o=!1)}for(;o&&t.indexOf(".")!==-1;){if(t=le(t),ue(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(ue(t),'" is called the same as the variable "').concat(r,"\" we're looking for."));if(s.lookForDataContainers&&T(s.dataContainerIdentifierTails)&&s.dataContainerIdentifierTails.length&&!t.endsWith(s.dataContainerIdentifierTails)){let l=N.default.get(e,t+s.dataContainerIdentifierTails);E(l)&&N.default.get(l,r)&&(f=N.default.get(l,r),o=!1)}if(f===void 0){let l=N.default.get(e,t);E(l)&&N.default.get(l,r)&&(f=N.default.get(l,r),o=!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=ae(e,r);if(t.length){for(let o=0,l=t.length;o<l;o++)if(T(t[o].val)||U(t[o].val)||J(t[o].val)){f=t[o].val;break}else if(H(t[o].val)){f=t[o].val;break}else if(Array.isArray(t[o].val)){f=t[o].val.join("");break}}}else{let t=ae(e,He(r));if(t.length)for(let o=0,l=t.length;o<l;o++){let i=N.default.get(t[o].val,Ce(r));i&&T(i)&&(f=i)}}return f}function Me(e,r,n,s,f=[]){if(f.includes(n)){let g="";if(f.length>1){let d=" \u2192\n";g=f.reduce((m,h,p)=>m+(p===0?"":d)+(h===n?"\u{1F4A5} ":" ")+h," Here's the path we travelled up until we hit the recursion:\n\n"),g+="".concat(d,"\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(g))}let t={},o=Array.from(f);o.push(n);let l=new M,i;function u(g,d,m){for(let h=0,p=g.length;h<p;h++){let w=g[h],b=r.slice(w.headsEndAt,w.tailsStartAt);if(b.length===0)l.push(w.headsStartAt,w.tailsEndAt);else if(cr.call(t,b)&&T(t[b]))l.push(w.headsStartAt,w.tailsEndAt,t[b]);else{if(i=gr(e,b.trim(),n,s),i===void 0)if(s.allowUnresolved===!0)i="";else if(T(s.allowUnresolved))i=s.allowUnresolved;else throw new Error("json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ".concat(r.slice(w.headsEndAt,w.tailsStartAt),". We're at path: \"").concat(n,'".'));if(!m&&s.throwWhenNonStringInsertedInString&&!T(i))throw new Error("json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ".concat(r.slice(w.headsEndAt,w.tailsStartAt)," at path ").concat(n,", it resolved into a non-string value, ").concat(JSON.stringify(i,null,4),'. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").'));if(U(i)){if(s.resolveToBoolIfAnyValuesContainBool)return l.wipe(),s.resolveToFalseIfAnyValuesContainBool?!1:i;i=""}else{if(J(i)&&m)return l.wipe(),i;Array.isArray(i)?i=String(i.join("")):J(i)?i="":(!H(i)||!m)&&(i=String(i))}let v=n.includes(".")?"".concat(le(n),".").concat(b):b;if(Z(i,s)){let W=fe(Me(e,i,v,s,o),s,d,o,v,b.trim());W!==!1&&l.push(w.headsStartAt,w.tailsEndAt,W)}else{t[b]=i;let W=fe(i,s,d,o,v,b.trim());W!==!1&&l.push(w.headsStartAt,w.tailsEndAt,W)}}}}let a;try{a=re(r,s.heads,s.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(g){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(g))}let c=!1;a.length===1&&P(r,[[a[0].headsStartAt,a[0].tailsEndAt]]).trim()===""&&(c=!0);let $=u(a,!1,c);if(typeof $=="boolean"||$===null)return $;try{a=re(r,s.headsNoWrap,s.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(g){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(g))}a.length===1&&P(r,[[a[0].headsStartAt,a[0].tailsEndAt]]).trim()===""&&(c=!0);let y=u(a,!0,c);if(U(y)||J(y))return y;if(l!=null&&l.current()){let g=l.current();if(c){if(typeof i=="number")return i;if((g==null?void 0:g.length)===1&&g[0].length===3&&H(g[0][2]))return g[0][2]}return P(r,g)}return 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=A(A({},Je),r);n.dontWrapVars?Array.isArray(n.dontWrapVars)||(n.dontWrapVars=S(n.dontWrapVars)):n.dontWrapVars=[];let s,f;if(n.dontWrapVars.length&&!n.dontWrapVars.every((o,l)=>T(o)?!0:(s=o,f=l,!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(s,'" at index ').concat(f,", which is not string but ").concat(Array.isArray(s)?"array":typeof s,"!"));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,(o,l,i)=>{if(I(l)&&Z(o,n))throw new Error("json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!\nPlease check the following key: ".concat(o));if(l!==void 0?t=l:t=o,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(T(n.headsNoWrap)&&O(t)===O(n.headsNoWrap)?"headsNoWrap":"").concat(T(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 T(t)&&Z(t,n)?Me(e,t,i.path,n):t})}return Qe(pr);})(); /** * @name codsen-utils * @fileoverview Various utility functions * @version 1.7.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/codsen-utils/} */ /** * @name arrayiffy-if-string * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else. * @version 5.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/arrayiffy-if-string/} */ /** * @name string-match-left-right * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace * @version 9.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/string-match-left-right/} */ /** * @name string-find-heads-tails * @fileoverview Finds where are arbitrary templating marker heads and tails located * @version 6.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/string-find-heads-tails/} */ /** * @name ast-monkey-util * @fileoverview Utility library of AST helper functions * @version 3.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/ast-monkey-util/} */ /** * @name ast-monkey-traverse * @fileoverview Utility library to traverse AST * @version 4.1.3 * @author Roy Revelt * @license MIT * {@link https://codsen.com/os/ast-monkey-traverse/} */ /** * @name ast-get-values-by-key * @fileoverview Extract values and paths from AST by keys OR set them by ke