json-variables 12.0.1 → 12.0.3

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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @name json-variables
3
+ * @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
4
+ * @version 12.0.3
5
+ * @author Roy Revelt, Codsen Ltd
6
+ * @license MIT
7
+ * {@link https://codsen.com/os/json-variables/}
8
+ */
9
+
10
+ import{traverse as C}from"ast-monkey-traverse";import{isMatch as x}from"matcher";import h from"object-path";import{arrayiffy as F}from"arrayiffy-if-string";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{Ranges as B}from"ranges-push";import{rApply as A}from"ranges-apply";import{remDup as L}from"string-remove-duplicate-heads-tails";import{matchLeftIncl as U,matchRightIncl as M}from"string-match-left-right";var j="12.0.3";var he=j,q=Object.prototype.hasOwnProperty,K={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function u(e){return typeof e=="string"}function G(e){return typeof e=="number"}function O(e){return typeof e=="boolean"}function N(e){return e===null}function V(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function z(e){return e!=null}function g(e){return u(e)?e.trim():e}function Y(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=0,n=e.length;t<n;t++)if(e[t]===".")return e.slice(0,t)}return e}function Q(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=0,n=e.length;t<n;t++)if(e[t]===".")return e.slice(t+1)}return e}function J(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(0,t)}return e}function P(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(t+1)}return e}function T(e,t){return typeof e!="string"||!e.trim()?!1:!!(e.includes(t.heads)||e.includes(t.tails)||u(t.headsNoWrap)&&t.headsNoWrap.length&&e.includes(t.headsNoWrap)||u(t.tailsNoWrap)&&t.tailsNoWrap.length&&e.includes(t.tailsNoWrap))}function X(e,t,n){let o,i;return typeof e=="string"&&e.length&&M(e,0,t,{trimBeforeMatching:!0,cb:(r,a,l)=>(o=l,!0)})&&U(e,e.length-1,n,{trimBeforeMatching:!0,cb:(r,a,l)=>(i=(l||0)+1,!0)})?e.slice(o,i):e}function H(e,t,n=!1,o,i,r){if(t.wrapHeadsWith||(t.wrapHeadsWith=""),t.wrapTailsWith||(t.wrapTailsWith=""),u(e)&&!n&&t.wrapGlobalFlipSwitch&&!t.dontWrapVars.some(a=>x(r,a))&&(!t.preventDoubleWrapping||t.preventDoubleWrapping&&u(e)&&!e.includes(t.wrapHeadsWith)&&!e.includes(t.wrapTailsWith)))return`${t.wrapHeadsWith}${e}${t.wrapTailsWith}`;if(n){if(!u(e))return e;let a=L(e,{heads:t.wrapHeadsWith,tails:t.wrapTailsWith});return u(a)?X(a,t.wrapHeadsWith,t.wrapTailsWith):a}return e}function Z(e,t,n,o){let i;if(n.indexOf(".")!==-1){let r=n,a=!0;if(o.lookForDataContainers&&typeof o.dataContainerIdentifierTails=="string"&&o.dataContainerIdentifierTails.length&&!r.endsWith(o.dataContainerIdentifierTails)){let l=h.get(e,r+o.dataContainerIdentifierTails);V(l)&&h.get(l,t)&&(i=h.get(l,t),a=!1)}for(;a&&r.indexOf(".")!==-1;){if(r=J(r),P(r)===t)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${t}" at path "${n}", we encountered a closed loop. The parent key "${P(r)}" is called the same as the variable "${t}" we're looking for.`);if(o.lookForDataContainers&&typeof o.dataContainerIdentifierTails=="string"&&o.dataContainerIdentifierTails.length&&!r.endsWith(o.dataContainerIdentifierTails)){let l=h.get(e,r+o.dataContainerIdentifierTails);V(l)&&h.get(l,t)&&(i=h.get(l,t),a=!1)}if(i===void 0){let l=h.get(e,r);V(l)&&h.get(l,t)&&(i=h.get(l,t),a=!1)}}}if(i===void 0){let r=h.get(e,t);r!==void 0&&(i=r)}if(i===void 0)if(t.indexOf(".")===-1){let r=_(e,t);if(r.length){for(let a=0,l=r.length;a<l;a++)if(u(r[a].val)||O(r[a].val)||N(r[a].val)){i=r[a].val;break}else if(G(r[a].val)){i=String(r[a].val);break}else if(Array.isArray(r[a].val)){i=r[a].val.join("");break}}}else{let r=_(e,Y(t));if(r.length)for(let a=0,l=r.length;a<l;a++){let y=h.get(r[a].val,Q(t));y&&u(y)&&(i=y)}}return i}function R(e,t,n,o,i=[]){if(i.includes(n)){let c="";if(i.length>1){let b=` \u2192
11
+ `;c=i.reduce((D,m,S)=>D+(S===0?"":b)+(m===n?"\u{1F4A5} ":" ")+m,` Here's the path we travelled up until we hit the recursion:
12
+
13
+ `),c+=`${b}\u{1F4A5} ${n}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${t}" at path "${n}", we encountered a closed loop, the key is referencing itself."${c}`)}let r={},a=Array.from(i);a.push(n);let l=new B;function y(c,b,D){for(let m=0,S=c.length;m<S;m++){let f=c[m],p=t.slice(f.headsEndAt,f.tailsStartAt);if(p.length===0)l.push(f.headsStartAt,f.tailsEndAt);else if(q.call(r,p)&&u(r[p]))l.push(f.headsStartAt,f.tailsEndAt,r[p]);else{let s=Z(e,p.trim(),n,o);if(s===void 0)if(o.allowUnresolved===!0)s="";else if(typeof o.allowUnresolved=="string")s=o.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${t.slice(f.headsEndAt,f.tailsStartAt)}. We're at path: "${n}".`);if(!D&&o.throwWhenNonStringInsertedInString&&!u(s))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${t.slice(f.headsEndAt,f.tailsStartAt)} at path ${n}, it resolved into a non-string value, ${JSON.stringify(s,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(O(s)){if(o.resolveToBoolIfAnyValuesContainBool)return l.wipe(),o.resolveToFalseIfAnyValuesContainBool?!1:s;s=""}else{if(N(s)&&D)return l.wipe(),s;Array.isArray(s)?s=String(s.join("")):N(s)?s="":s=String(s)}let v=n.includes(".")?`${J(n)}.${p}`:p;if(T(s,o)){let w=H(R(e,s,v,o,a),o,b,a,v,p.trim());typeof w=="string"&&l.push(f.headsStartAt,f.tailsEndAt,w)}else{r[p]=s;let w=H(s,o,b,a,v,p.trim());typeof w=="string"&&l.push(f.headsStartAt,f.tailsEndAt,w)}}}}let d;try{d=I(t,o.heads,o.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${t}" at path ${n}, something wrong with heads and tails was detected! Here's the internal error message:
14
+ ${c}`)}let W=!1;d.length===1&&A(t,[[d[0].headsStartAt,d[0].tailsEndAt]]).trim()===""&&(W=!0);let $=y(d,!1,W);if(typeof $=="boolean"||$===null)return $;try{d=I(t,o.headsNoWrap,o.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${t}" at path ${n}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
15
+ ${c}`)}d.length===1&&A(t,[[d[0].headsStartAt,d[0].tailsEndAt]]).trim()===""&&(W=!0);let E=y(d,!0,W);return O(E)||N(E)?E:l?.current()?A(t,l.current()):t}function de(e,t){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!V(e))throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(e)?"array":typeof e}`);if(t&&!V(t))throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(t)?"array":typeof t}`);let n={...K,...t};n.dontWrapVars?Array.isArray(n.dontWrapVars)||(n.dontWrapVars=F(n.dontWrapVars)):n.dontWrapVars=[];let o,i;if(n.dontWrapVars.length&&!n.dontWrapVars.every((a,l)=>u(a)?!0:(o=a,i=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 "${o}" at index ${i}, which is not string but ${Array.isArray(o)?"array":typeof o}!`);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 r;return C(e,(a,l,y)=>{if(z(l)&&T(a,n))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
16
+ Please check the following key: ${a}`);if(l!==void 0?r=l:r=a,r==="")return r;if(n.heads.length&&g(r)===g(n.heads)||n.tails.length&&g(r)===g(n.tails)||n.headsNoWrap.length&&g(r)===g(n.headsNoWrap)||n.tailsNoWrap.length&&g(r)===g(n.tailsNoWrap)){if(!n.noSingleMarkers)return r;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${g(r)} which is equal to ${g(r)===g(n.heads)?"heads":""}${g(r)===g(n.tails)?"tails":""}${u(n.headsNoWrap)&&g(r)===g(n.headsNoWrap)?"headsNoWrap":""}${u(n.tailsNoWrap)&&g(r)===g(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 (${g(r)}) alone`)}return u(r)&&T(r,n)?R(e,r,y.path,n):r})}export{K as defaults,de as jVar,he as version};
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @name json-variables
3
+ * @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
4
+ * @version 12.0.3
5
+ * @author Roy Revelt, Codsen Ltd
6
+ * @license MIT
7
+ * {@link https://codsen.com/os/json-variables/}
8
+ */
9
+
10
+ "use strict";var jsonVariables=(()=>{var tr=Object.create;var q=Object.defineProperty,rr=Object.defineProperties,nr=Object.getOwnPropertyDescriptor,ir=Object.getOwnPropertyDescriptors,ar=Object.getOwnPropertyNames,qe=Object.getOwnPropertySymbols,sr=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$=(e,t)=>{for(var r in t||(t={}))Ue.call(t,r)&&me(e,r,t[r]);if(qe)for(var r of qe(t))or.call(t,r)&&me(e,r,t[r]);return e},U=(e,t)=>rr(e,ir(t));var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lr=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},Ge=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ar(t))!Ue.call(e,l)&&l!==r&&q(e,l,{get:()=>t[l],enumerable:!(i=nr(t,l))||i.enumerable});return e};var we=(e,t,r)=>(r=e!=null?tr(sr(e)):{},Ge(t||!e||!e.__esModule?q(r,"default",{value:e,enumerable:!0}):r,e)),fr=e=>Ge(q({},"__esModule",{value:!0}),e);var be=(e,t,r)=>(me(e,typeof t!="symbol"?t+"":t,r),r);var Ce=Ke((K,P)=>{var ur=200,st="__lodash_hash_undefined__",ot=9007199254740991,Ee="[object Arguments]",gr="[object Array]",lt="[object Boolean]",ft="[object Date]",hr="[object Error]",Se="[object Function]",ut="[object GeneratorFunction]",ee="[object Map]",gt="[object Number]",We="[object Object]",Qe="[object Promise]",ht="[object RegExp]",te="[object Set]",ct="[object String]",pt="[object Symbol]",$e="[object WeakMap]",dt="[object ArrayBuffer]",re="[object DataView]",yt="[object Float32Array]",mt="[object Float64Array]",wt="[object Int8Array]",bt="[object Int16Array]",Tt="[object Int32Array]",$t="[object Uint8Array]",vt="[object Uint8ClampedArray]",Ot="[object Uint16Array]",At="[object Uint32Array]",cr=/[\\^$.*+?()[\]{}|]/g,pr=/\w*$/,dr=/^\[object .+?Constructor\]$/,yr=/^(?:0|[1-9]\d*)$/,v={};v[Ee]=v[gr]=v[dt]=v[re]=v[lt]=v[ft]=v[yt]=v[mt]=v[wt]=v[bt]=v[Tt]=v[ee]=v[gt]=v[We]=v[ht]=v[te]=v[ct]=v[pt]=v[$t]=v[vt]=v[Ot]=v[At]=!0;v[hr]=v[Se]=v[$e]=!1;var mr=typeof global=="object"&&global&&global.Object===Object&&global,wr=typeof self=="object"&&self&&self.Object===Object&&self,x=mr||wr||Function("return this")(),_t=typeof K=="object"&&K&&!K.nodeType&&K,ze=_t&&typeof P=="object"&&P&&!P.nodeType&&P,br=ze&&ze.exports===_t;function Tr(e,t){return e.set(t[0],t[1]),e}function $r(e,t){return e.add(t),e}function vr(e,t){for(var r=-1,i=e?e.length:0;++r<i&&t(e[r],r,e)!==!1;);return e}function Or(e,t){for(var r=-1,i=t.length,l=e.length;++r<i;)e[l+r]=t[r];return e}function It(e,t,r,i){var l=-1,n=e?e.length:0;for(i&&n&&(r=e[++l]);++l<n;)r=t(r,e[l],l,e);return r}function Ar(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}function _r(e,t){return e==null?void 0:e[t]}function Et(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Ye(e){var t=-1,r=Array(e.size);return e.forEach(function(i,l){r[++t]=[l,i]}),r}function De(e,t){return function(r){return e(t(r))}}function Xe(e){var t=-1,r=Array(e.size);return e.forEach(function(i){r[++t]=i}),r}var Ir=Array.prototype,Er=Function.prototype,ne=Object.prototype,Te=x["__core-js_shared__"],Ze=function(){var e=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),St=Er.toString,R=ne.hasOwnProperty,ie=ne.toString,Sr=RegExp("^"+St.call(R).replace(cr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=br?x.Buffer:void 0,tt=x.Symbol,rt=x.Uint8Array,Wr=De(Object.getPrototypeOf,Object),Dr=Object.create,xr=ne.propertyIsEnumerable,Nr=Ir.splice,nt=Object.getOwnPropertySymbols,Rr=et?et.isBuffer:void 0,Cr=De(Object.keys,Object),ve=F(x,"DataView"),G=F(x,"Map"),Oe=F(x,"Promise"),Ae=F(x,"Set"),_e=F(x,"WeakMap"),Q=F(Object,"create"),Vr=M(ve),jr=M(G),Hr=M(Oe),Mr=M(Ae),Pr=M(_e),it=tt?tt.prototype:void 0,at=it?it.valueOf:void 0;function H(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function Jr(){this.__data__=Q?Q(null):{}}function Br(e){return this.has(e)&&delete this.__data__[e]}function Fr(e){var t=this.__data__;if(Q){var r=t[e];return r===st?void 0:r}return R.call(t,e)?t[e]:void 0}function kr(e){var t=this.__data__;return Q?t[e]!==void 0:R.call(t,e)}function Lr(e,t){var r=this.__data__;return r[e]=Q&&t===void 0?st:t,this}H.prototype.clear=Jr;H.prototype.delete=Br;H.prototype.get=Fr;H.prototype.has=kr;H.prototype.set=Lr;function N(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function qr(){this.__data__=[]}function Ur(e){var t=this.__data__,r=ae(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Nr.call(t,r,1),!0}function Kr(e){var t=this.__data__,r=ae(t,e);return r<0?void 0:t[r][1]}function Gr(e){return ae(this.__data__,e)>-1}function Qr(e,t){var r=this.__data__,i=ae(r,e);return i<0?r.push([e,t]):r[i][1]=t,this}N.prototype.clear=qr;N.prototype.delete=Ur;N.prototype.get=Kr;N.prototype.has=Gr;N.prototype.set=Qr;function J(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function zr(){this.__data__={hash:new H,map:new(G||N),string:new H}}function Yr(e){return se(this,e).delete(e)}function Xr(e){return se(this,e).get(e)}function Zr(e){return se(this,e).has(e)}function en(e,t){return se(this,e).set(e,t),this}J.prototype.clear=zr;J.prototype.delete=Yr;J.prototype.get=Xr;J.prototype.has=Zr;J.prototype.set=en;function B(e){this.__data__=new N(e)}function tn(){this.__data__=new N}function rn(e){return this.__data__.delete(e)}function nn(e){return this.__data__.get(e)}function an(e){return this.__data__.has(e)}function sn(e,t){var r=this.__data__;if(r instanceof N){var i=r.__data__;if(!G||i.length<ur-1)return i.push([e,t]),this;r=this.__data__=new J(i)}return r.set(e,t),this}B.prototype.clear=tn;B.prototype.delete=rn;B.prototype.get=nn;B.prototype.has=an;B.prototype.set=sn;function on(e,t){var r=Ne(e)||xn(e)?Ar(e.length,String):[],i=r.length,l=!!i;for(var n in e)(t||R.call(e,n))&&!(l&&(n=="length"||En(n,i)))&&r.push(n);return r}function Wt(e,t,r){var i=e[t];(!(R.call(e,t)&&Rt(i,r))||r===void 0&&!(t in e))&&(e[t]=r)}function ae(e,t){for(var r=e.length;r--;)if(Rt(e[r][0],t))return r;return-1}function ln(e,t){return e&&Dt(t,Re(t),e)}function Ie(e,t,r,i,l,n,o){var a;if(i&&(a=n?i(e,l,n,o):i(e)),a!==void 0)return a;if(!oe(e))return e;var g=Ne(e);if(g){if(a=An(e),!t)return $n(e,a)}else{var s=j(e),h=s==Se||s==ut;if(Rn(e))return pn(e,t);if(s==We||s==Ee||h&&!n){if(Et(e))return n?e:{};if(a=_n(h?{}:e),!t)return vn(e,ln(a,e))}else{if(!v[s])return n?e:{};a=In(e,s,Ie,t)}}o||(o=new B);var c=o.get(e);if(c)return c;if(o.set(e,a),!g)var T=r?On(e):Re(e);return vr(T||e,function(y,u){T&&(u=y,y=e[u]),Wt(a,u,Ie(y,t,r,i,u,e,o))}),a}function fn(e){return oe(e)?Dr(e):{}}function un(e,t,r){var i=t(e);return Ne(e)?i:Or(i,r(e))}function gn(e){return ie.call(e)}function hn(e){if(!oe(e)||Wn(e))return!1;var t=Vt(e)||Et(e)?Sr:dr;return t.test(M(e))}function cn(e){if(!Nt(e))return Cr(e);var t=[];for(var r in Object(e))R.call(e,r)&&r!="constructor"&&t.push(r);return t}function pn(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function xe(e){var t=new e.constructor(e.byteLength);return new rt(t).set(new rt(e)),t}function dn(e,t){var r=t?xe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function yn(e,t,r){var i=t?r(Ye(e),!0):Ye(e);return It(i,Tr,new e.constructor)}function mn(e){var t=new e.constructor(e.source,pr.exec(e));return t.lastIndex=e.lastIndex,t}function wn(e,t,r){var i=t?r(Xe(e),!0):Xe(e);return It(i,$r,new e.constructor)}function bn(e){return at?Object(at.call(e)):{}}function Tn(e,t){var r=t?xe(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function $n(e,t){var r=-1,i=e.length;for(t||(t=Array(i));++r<i;)t[r]=e[r];return t}function Dt(e,t,r,i){r||(r={});for(var l=-1,n=t.length;++l<n;){var o=t[l],a=i?i(r[o],e[o],o,r,e):void 0;Wt(r,o,a===void 0?e[o]:a)}return r}function vn(e,t){return Dt(e,xt(e),t)}function On(e){return un(e,Re,xt)}function se(e,t){var r=e.__data__;return Sn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function F(e,t){var r=_r(e,t);return hn(r)?r:void 0}var xt=nt?De(nt,Object):jn,j=gn;(ve&&j(new ve(new ArrayBuffer(1)))!=re||G&&j(new G)!=ee||Oe&&j(Oe.resolve())!=Qe||Ae&&j(new Ae)!=te||_e&&j(new _e)!=$e)&&(j=function(e){var t=ie.call(e),r=t==We?e.constructor:void 0,i=r?M(r):void 0;if(i)switch(i){case Vr:return re;case jr:return ee;case Hr:return Qe;case Mr:return te;case Pr:return $e}return t});function An(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&R.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function _n(e){return typeof e.constructor=="function"&&!Nt(e)?fn(Wr(e)):{}}function In(e,t,r,i){var l=e.constructor;switch(t){case dt:return xe(e);case lt:case ft:return new l(+e);case re:return dn(e,i);case yt:case mt:case wt:case bt:case Tt:case $t:case vt:case Ot:case At:return Tn(e,i);case ee:return yn(e,i,r);case gt:case ct:return new l(e);case ht:return mn(e);case te:return wn(e,i,r);case pt:return bn(e)}}function En(e,t){return t=t==null?ot:t,!!t&&(typeof e=="number"||yr.test(e))&&e>-1&&e%1==0&&e<t}function Sn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Wn(e){return!!Ze&&Ze in e}function Nt(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||ne;return e===r}function M(e){if(e!=null){try{return St.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Dn(e){return Ie(e,!0,!0)}function Rt(e,t){return e===t||e!==e&&t!==t}function xn(e){return Nn(e)&&R.call(e,"callee")&&(!xr.call(e,"callee")||ie.call(e)==Ee)}var Ne=Array.isArray;function Ct(e){return e!=null&&Cn(e.length)&&!Vt(e)}function Nn(e){return Vn(e)&&Ct(e)}var Rn=Rr||Hn;function Vt(e){var t=oe(e)?ie.call(e):"";return t==Se||t==ut}function Cn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ot}function oe(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Vn(e){return!!e&&typeof e=="object"}function Re(e){return Ct(e)?on(e):cn(e)}function jn(){return[]}function Hn(){return!1}P.exports=Dn});var Mt=Ke((Ht,he)=>{(function(e,t){"use strict";typeof he=="object"&&typeof he.exports=="object"?he.exports=t():typeof define=="function"&&define.amd?define([],t):e.objectPath=t()})(Ht,function(){"use strict";var e=Object.prototype.toString;function t(h,c){return h==null?!1:Object.prototype.hasOwnProperty.call(h,c)}function r(h){if(!h||n(h)&&h.length===0)return!0;if(typeof h!="string"){for(var c in h)if(t(h,c))return!1;return!0}return!1}function i(h){return e.call(h)}function l(h){return typeof h=="object"&&i(h)==="[object Object]"}var n=Array.isArray||function(h){return e.call(h)==="[object Array]"};function o(h){return typeof h=="boolean"||i(h)==="[object Boolean]"}function a(h){var c=parseInt(h);return c.toString()===h?c:h}function g(h){h=h||{};var c=function(d){return Object.keys(c).reduce(function(f,p){return p==="create"||typeof c[p]=="function"&&(f[p]=c[p].bind(c,d)),f},{})},T;h.includeInheritedProps?T=function(){return!0}:T=function(d,f){return typeof f=="number"&&Array.isArray(d)||t(d,f)};function y(d,f){if(T(d,f))return d[f]}var u;h.includeInheritedProps?u=function(d,f){typeof f!="string"&&typeof f!="number"&&(f=String(f));var p=y(d,f);if(f==="__proto__"||f==="prototype"||f==="constructor"&&typeof p=="function")throw new Error("For security reasons, object's magic properties cannot be set");return p}:u=function(d,f){return y(d,f)};function w(d,f,p,m){if(typeof f=="number"&&(f=[f]),!f||f.length===0)return d;if(typeof f=="string")return w(d,f.split(".").map(a),p,m);var b=f[0],O=u(d,b);return f.length===1?((O===void 0||!m)&&(d[b]=p),O):(O===void 0&&(typeof f[1]=="number"?d[b]=[]:d[b]={}),w(d[b],f.slice(1),p,m))}return c.has=function(d,f){if(typeof f=="number"?f=[f]:typeof f=="string"&&(f=f.split(".")),!f||f.length===0)return!!d;for(var p=0;p<f.length;p++){var m=a(f[p]);if(typeof m=="number"&&n(d)&&m<d.length||(h.includeInheritedProps?m in Object(d):t(d,m)))d=d[m];else return!1}return!0},c.ensureExists=function(d,f,p){return w(d,f,p,!0)},c.set=function(d,f,p,m){return w(d,f,p,m)},c.insert=function(d,f,p,m){var b=c.get(d,f);m=~~m,n(b)||(b=[],c.set(d,f,b)),b.splice(m,0,p)},c.empty=function(d,f){if(!r(f)&&d!=null){var p,m;if(p=c.get(d,f)){if(typeof p=="string")return c.set(d,f,"");if(o(p))return c.set(d,f,!1);if(typeof p=="number")return c.set(d,f,0);if(n(p))p.length=0;else if(l(p))for(m in p)T(p,m)&&delete p[m];else return c.set(d,f,null)}}},c.push=function(d,f){var p=c.get(d,f);n(p)||(p=[],c.set(d,f,p)),p.push.apply(p,Array.prototype.slice.call(arguments,2))},c.coalesce=function(d,f,p){for(var m,b=0,O=f.length;b<O;b++)if((m=c.get(d,f[b]))!==void 0)return m;return p},c.get=function(d,f,p){if(typeof f=="number"&&(f=[f]),!f||f.length===0)return d;if(d==null)return p;if(typeof f=="string")return c.get(d,f.split("."),p);var m=a(f[0]),b=u(d,m);return b===void 0?p:f.length===1?b:c.get(d[m],f.slice(1),p)},c.del=function(f,p){if(typeof p=="number"&&(p=[p]),f==null||r(p))return f;if(typeof p=="string")return c.del(f,p.split("."));var m=a(p[0]);if(u(f,m),!T(f,m))return f;if(p.length===1)n(f)?f.splice(m,1):delete f[m];else return c.del(f[m],p.slice(1));return f},c}var s=g();return s.create=g,s.withInheritedProps=g({includeInheritedProps:!0}),s})});var oi={};lr(oi,{defaults:()=>Xt,jVar:()=>si,version:()=>Xn});var fe=we(Ce(),1);function le(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function Mn(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let r=t-1;r--;)if(e[r]===".")return e.slice(r+1,t)}return null}var Ve=Mn;function ue(e,t){let r={now:!1};function i(l,n,o,a){let g=(0,fe.default)(l),s,h=$({depth:-1,path:""},o);if(h.depth+=1,Array.isArray(g))for(let c=0,T=g.length;c<T&&!a.now;c++){let y=h.path?`${h.path}.${c}`:`${c}`;g[c]!==void 0?(h.parent=(0,fe.default)(g),h.parentType="array",h.parentKey=Ve(y),s=i(n(g[c],void 0,U($({},h),{path:y}),a),n,U($({},h),{path:y}),a),Number.isNaN(s)&&c<g.length?(g.splice(c,1),c-=1):g[c]=s):g.splice(c,1)}else if(le(g))for(let c in g){if(a.now&&c!=null)break;let T=h.path?`${h.path}.${c}`:c;h.depth===0&&c!=null&&(h.topmostKey=c),h.parent=(0,fe.default)(g),h.parentType="object",h.parentKey=Ve(T),s=i(n(c,g[c],U($({},h),{path:T}),a),n,U($({},h),{path:T}),a),Number.isNaN(s)?delete g[c]:g[c]=s}return g}return i(e,t,{},r)}function je(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var He=new Map,jt=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(r=>{if(typeof r!="string"){if(typeof r>"u")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},Pn=(e,t)=>{t=$({caseSensitive:!1},t);let r=e+JSON.stringify(t);if(He.has(r))return He.get(r);let i=e[0]==="!";i&&(e=e.slice(1)),e=je(e).replace(/\\\*/g,"[\\s\\S]*");let l=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return l.negated=i,He.set(r,l),l},Jn=(e,t,r,i)=>{if(e=jt(e,"inputs"),t=jt(t,"patterns"),t.length===0)return[];t=t.map(o=>Pn(o,r));let{allPatterns:l}=r||{},n=[];for(let o of e){let a,g=[...t].fill(!1);for(let[s,h]of t.entries())if(h.test(o)&&(g[s]=!0,a=!h.negated,!a))break;if(!(a===!1||a===void 0&&t.some(s=>!s.negated)||l&&g.some((s,h)=>!s&&!t[h].negated))&&(n.push(o),i))break}return n};function ge(e,t,r){return Jn(e,t,r,!0).length>0}var W=we(Mt(),1);function I(e){return typeof e!="string"?e:e.length?[e]:[]}function Pt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ce(e){return typeof e=="string"}var Jt={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},Bn=e=>e+1;function Fn(e,t,r,i,l=!1,n=Bn){let o=typeof r=="function"?r():r;if(+t<0&&l&&o==="EOL")return o;let a=$($({},Jt),i);if(t>=e.length&&!l)return!1;let g=l?1:r.length,s=0,h=!1,c=!1,T=!1,y=a.maxMismatches,u=t,w=!1,d=!1,f=!1;function p(){return s===1&&y<a.maxMismatches-1}for(;e[u];){let m=n(u);if(a.trimBeforeMatching&&e[u].trim()===""){if(!e[m]&&l&&r==="EOL")return!0;u=n(u);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[u])||a!=null&&a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map(O=>O.toLowerCase()).includes(e[u].toLowerCase())){if(l&&r==="EOL"&&!e[m])return!0;u=n(u);continue}let b=m>u?r[r.length-g]:r[g-1];if(!a.i&&e[u]===b||a.i&&e[u].toLowerCase()===b.toLowerCase()){if(w||(w=!0),T||(T=!0),g===r.length){if(d=!0,y!==a.maxMismatches)return!1}else g===1&&(f=!0);if(g-=1,s++,p())return!1;if(!g)return s!==r.length||y===a.maxMismatches||!h?u:!1}else if(!h&&!s&&(h=!0),a.maxMismatches&&y&&u){y-=1;for(let O=0;O<=y;O++){let E=m>u?r[r.length-g+1+O]:r[g-2-O],ye=e[n(u)];if(E&&(!a.i&&e[u]===E||a.i&&e[u].toLowerCase()===E.toLowerCase())&&(!a.firstMustMatch||g!==r.length)){if(s++,p())return!1;g-=2,w=!0;break}else if(ye&&E&&(!a.i&&ye===E||a.i&&ye.toLowerCase()===E.toLowerCase())&&(!a.firstMustMatch||g!==r.length)){if(!s&&!a.hungry)return!1;g-=1,w=!0;break}else if(E===void 0&&y>=0&&w&&(!a.firstMustMatch||d)&&(!a.lastMustMatch||f))return u}w||(c=u)}else return u===0&&g===1&&!a.lastMustMatch&&T?0:!1;if(c!==!1&&c!==u&&(c=!1),g<1)return u;u=n(u)}if(g>0)return l&&o==="EOL"?!0:a&&a.maxMismatches>=g&&T?c||0:!1}function Bt(e,t,r,i,l){var h,c;if(Pt(l)&&Object.prototype.hasOwnProperty.call(l,"trimBeforeMatching")&&l&&typeof l.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(l.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let n=$($({},Jt),l);if(typeof n.trimCharsBeforeMatching=="string"&&(n.trimCharsBeforeMatching=I(n.trimCharsBeforeMatching)),n.trimCharsBeforeMatching=n.trimCharsBeforeMatching.map(T=>ce(T)?T:String(T)),!ce(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
11
+ ${JSON.stringify(r,null,4)}`);let o,a;if(ce(i))o=[i];else if(Array.isArray(i))o=i;else if(!i)o=i;else if(typeof i=="function")o=[],o.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(l&&!Pt(l))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 l}", and equal to:
13
+ ${JSON.stringify(l,null,4)}`);let g=0,s="";if(n!=null&&n.trimCharsBeforeMatching&&n.trimCharsBeforeMatching.some((T,y)=>T.length>1?(g=y,s=T,!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 ${g} is longer than 1 character, ${s.length} (equals to ${s}). 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&&ce(o[0])&&!o[0].trim()){if(typeof n.cb=="function"){let y,u=r;if((e==="matchLeftIncl"||e==="matchRight")&&(u+=1),e[5]==="L")for(let p=u;p--;){let m=t[p];if((!n.trimBeforeMatching||n.trimBeforeMatching&&m!==void 0&&m.trim())&&(!((h=n.trimCharsBeforeMatching)!=null&&h.length)||m!==void 0&&!n.trimCharsBeforeMatching.includes(m))){y=p;break}}else if(e.startsWith("matchRight"))for(let p=u;p<t.length;p++){let m=t[p];if((!n.trimBeforeMatching||n.trimBeforeMatching&&m.trim())&&(!((c=n.trimCharsBeforeMatching)!=null&&c.length)||!n.trimCharsBeforeMatching.includes(m))){y=p;break}}if(y===void 0)return!1;let w=t[y],d=y+1,f="";return d&&d>0&&(f=t.slice(0,d)),e[5]==="L"||y&&y>0&&(f=t.slice(y)),n.cb(w,f,y)}let T="";throw l||(T=" 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!${T}`)}for(let T=0,y=o.length;T<y;T++){a=typeof o[T]=="function";let u=o[T],w,d,f="",p=r;e==="matchRight"?p+=1:e==="matchLeft"&&(p-=1);let m=Fn(t,p,u,n,a,b=>e[5]==="L"?b-1:b+1);if(m&&a&&typeof u=="function"&&u()==="EOL")return u()&&(!n.cb||n.cb(w,f,d))?u():!1;if(Number.isInteger(m)&&(d=e.startsWith("matchLeft")?m-1:m+1,e[5]==="L"?f=t.slice(0,m):f=t.slice(d)),d<0&&(d=void 0),t[d]&&(w=t[d]),Number.isInteger(m)&&(!n.cb||n.cb(w,f,d)))return u}return!1}function k(e,t,r,i){return Bt("matchLeftIncl",e,t,r,i)}function S(e,t,r,i){return Bt("matchRightIncl",e,t,r,i)}function kn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function D(e){return typeof e=="string"}var Ft={fromIndex:0,throwWhenSomethingWrongIsDetected:!0,allowWholeValueToBeOnlyHeadsOrTails:!0,source:"string-find-heads-tails",matchHeadsAndTailsStrictlyInPairsByTheirOrder:!1,relaxedAPI:!1};function Me(e,t,r,i){if(i&&!kn(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 l=$($({},Ft),i);if(typeof l.fromIndex=="string"&&/^\d*$/.test(l.fromIndex))l.fromIndex=Number(l.fromIndex);else if(!Number.isInteger(l.fromIndex)||l.fromIndex<0)throw new TypeError(`${l.source} [THROW_ID_18] the fourth input argument must be a natural number or zero! Currently it's: ${l.fromIndex}`);if(!D(e)||e.length===0){if(l.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_02] the first input argument, input string, must be a non-zero-length string! Currently it's: ${typeof e}, equal to: ${e}`)}let n,o;if(typeof t!="string"&&!Array.isArray(t)){if(l.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_03] the second input argument, heads, must be either a string or an array of strings! Currently it's: ${typeof t}, equal to:
14
+ ${JSON.stringify(t,null,4)}`)}else if(typeof t=="string")if(t.length===0){if(l.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_04] the second input argument, heads, must be a non-empty string! Currently it's empty.")}else t=I(t);else if(Array.isArray(t))if(t.length===0){if(l.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_05] the second input argument, heads, must be a non-empty array and contain at least one string! Currently it's empty.")}else if(t.every((u,w)=>(n=u,o=w,D(u)))){if(!t.every((u,w)=>(o=w,D(u)&&u.length&&u.trim()!=="")))if(l.relaxedAPI){if(t=t.filter(u=>D(u)&&u.length),t.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_07] the second input argument, heads, should not contain empty strings! For example, there's one detected at index ${o} of heads array:
15
+ ${JSON.stringify(t,null,4)}.`)}else if(l.relaxedAPI){if(t=t.filter(u=>D(u)&&u.length),t.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_06] the second input argument, heads, contains non-string elements! For example, element at ${o}th index is ${typeof n}, equal to:
16
+ ${JSON.stringify(n,null,4)}. Whole heads array looks like:
17
+ ${JSON.stringify(t,null,4)}`);if(typeof r!="string"&&!Array.isArray(r)){if(l.relaxedAPI)return[];throw new TypeError(`string-find-heads-tails: [THROW_ID_08] the third input argument, tails, must be either a string or an array of strings! Currently it's: ${typeof r}, equal to:
18
+ ${JSON.stringify(r,null,4)}`)}else if(typeof r=="string")if(r.length===0){if(l.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_09] the third input argument, tails, must be a non-empty string! Currently it's empty.")}else r=I(r);else if(Array.isArray(r))if(r.length===0){if(l.relaxedAPI)return[];throw new TypeError("string-find-heads-tails: [THROW_ID_10] the third input argument, tails, must be a non-empty array and contain at least one string! Currently it's empty.")}else if(r.every((u,w)=>(n=u,o=w,D(u)))){if(!r.every((u,w)=>(o=w,D(u)&&u.length&&u.trim()!=="")))if(l.relaxedAPI){if(r=r.filter(u=>D(u)&&u.length),r.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_12] the third input argument, tails, should not contain empty strings! For example, there's one detected at index ${o}. Whole tails array is equal to:
19
+ ${JSON.stringify(r,null,4)}`)}else if(l.relaxedAPI){if(r=r.filter(u=>D(u)&&u.length),r.length===0)return[]}else throw new TypeError(`string-find-heads-tails: [THROW_ID_11] the third input argument, tails, contains non-string elements! For example, element at ${o}th index is ${typeof n}, equal to:
20
+ ${JSON.stringify(n,null,4)}. Whole tails array is equal to:
21
+ ${JSON.stringify(r,null,4)}`);let a=l.source===Ft.source;if(l.throwWhenSomethingWrongIsDetected&&!l.allowWholeValueToBeOnlyHeadsOrTails){if(I(t).includes(e))throw new Error(`${l.source}${a?": [THROW_ID_16]":""} the whole input string can't be equal to ${D(t)?"":"one of "}heads (${e})!`);if(I(r).includes(e))throw new Error(`${l.source}${a?": [THROW_ID_17]":""} the whole input string can't be equal to ${D(r)?"":"one of "}tails (${e})!`)}let g=t.concat(r).map(u=>u.charAt(0)).reduce((u,w)=>w.charCodeAt(0)>u[1]?[u[0],w.charCodeAt(0)]:w.charCodeAt(0)<u[0]?[w.charCodeAt(0),u[1]]:u,[t[0].charCodeAt(0),t[0].charCodeAt(0)]),s=[],h=!1,c={},T="",y;for(let u=l.fromIndex,w=e.length;u<w;u++){let d=e[u].charCodeAt(0);if(d<=g[1]&&d>=g[0]){let f=S(e,u,t);if(f&&l.matchHeadsAndTailsStrictlyInPairsByTheirOrder){for(let m=t.length;m--;)if(t[m]===f){y=m;break}}if(typeof f=="string")if(h){if(l.throwWhenSomethingWrongIsDetected)throw new TypeError(`${l.source}${a?": [THROW_ID_19]":""} When processing "${e}", we found heads (${e.slice(u,u+f.length)}) starting at character with index number "${u}" and there was another set of heads before it! Generally speaking, there should be "heads-tails-heads-tails", not "heads-heads-tails"!
22
+ We're talking about the area of the code:
23
+
24
+
25
+ --------------------------------------starts
26
+ ${e.slice(Math.max(u-200,0),u)}
27
+ ${`\x1B[${33}m------->\x1B[${39}m`} ${`\x1B[${31}m${e.slice(u,u+f.length)}\x1B[${39}m`} \x1B[${33}m<-------\x1B[${39}m
28
+ ${e.slice(u+f.length,Math.min(w,u+200))}
29
+ --------------------------------------ends
30
+
31
+
32
+ To turn off this error being thrown, set resolvedOpts.throwWhenSomethingWrongIsDetected to Boolean false.`)}else{c={},c.headsStartAt=u,c.headsEndAt=u+f.length,h=!0,u+=f.length-1,T&&(T="");continue}let p=S(e,u,r);if(h&&p&&l.matchHeadsAndTailsStrictlyInPairsByTheirOrder&&y!==void 0&&r[y]!==void 0&&r[y]!==p){let m;for(let b=r.length;b--;)if(r[b]===p){m=b;break}throw new TypeError(`${l.source}${a?": [THROW_ID_20]":""} When processing "${e}", we had "resolvedOpts.matchHeadsAndTailsStrictlyInPairsByTheirOrder" on. We found heads (${t[y]}) but the tails the followed it were not of the same index, ${y} (${r[y]}) but ${m} (${p}).`)}if(typeof p=="string")if(h){c.tailsStartAt=u,c.tailsEndAt=u+p.length,s.push(c),c={},h=!1,u+=p.length-1;continue}else l.throwWhenSomethingWrongIsDetected&&(T=`${l.source}${a?": [THROW_ID_21]":""} When processing "${e}", we found tails (${e.slice(u,u+p.length)}) starting at character with index number "${u}" but there were no heads preceding it. That's very naughty!`)}if(l.throwWhenSomethingWrongIsDetected&&u===w-1){if(Object.keys(c).length!==0)throw new TypeError(`${l.source}${a?": [THROW_ID_22]":""} When processing "${e}", we reached the end of the string and yet didn't find any tails (${JSON.stringify(r,null,4)}) to match the last detected heads (${e.slice(c.headsStartAt,c.headsEndAt)})!`);if(T)throw new Error(T)}}return s}var Pe=we(Ce(),1);function Je(e,t,r){let i;r!==void 0&&(i=Array.isArray(r)?(0,Pe.default)(r):[(0,Pe.default)(r)]);let l=[],n=ue(e,(o,a,g)=>{let s=a!==void 0?a:o;if(a!==void 0&&ge(o,t,{caseSensitive:!0})){if(i===void 0)l.push({val:a,path:g.path});else if(i.length)return i.shift()}return s});return i===void 0?l:n}function pe(e,t=1){let r="\xA0";function i(n){return Array.from(n).reverse().join("")}function l(n,o,a){let g=a?`
33
+ `:"\r",s=a?"\r":`
34
+ `;if(!n)return n;let h=0,c=0,T="";for(let y=0,u=n.length;y<u;y++)(n[y]===g||n[y]===s&&n[y-1]!==g)&&c++,`\r
35
+ `.includes(n[y])||n[y]===r?(h=0,n[y]===r?T+=n[y]:n[y]===g?c<=o&&(T+=n[y],n[y+1]===s&&(T+=n[y+1],y++)):n[y]===s&&(n==null?void 0:n[y-1])!==g&&c<=o&&(T+=n[y])):(h++,!n[y+1]&&!c&&(T+=" "));return T}if(typeof e=="string"&&e.length){let n=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(n=+t);let o="",a="";if(!e.trim())o=e;else if(!e[0].trim()){for(let g=0,s=e.length;g<s;g++)if(e[g].trim()){o=e.slice(0,g);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===r)){for(let g=e.length;g--;)if(e[g].trim()){a=e.slice(g+1);break}}return`${l(o,n,!1)}${e.trim()}${i(l(i(a),n,!0))}`}return e}var Ln={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function kt(e,t){if(!Array.isArray(e)||!e.length)return e;let r=$($({},Ln),t),i,l;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,g)=>!Array.isArray(a)||a.length!==2?(i=g,l=a.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 ${l} elements!`);if(!e.every((a,g)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(i=g,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,o=0;return Array.from(e).sort((a,g)=>(r.progressFn&&(o+=1,r.progressFn(Math.floor(o*100/n))),a[0]===g[0]?a[1]<g[1]?-1:a[1]>g[1]?1:0:a[0]<g[0]?-1:1))}var Lt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function qn(e,t){function r(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}if(!Array.isArray(e)||!e.length)return null;let i;if(t)if(r(t)){if(i=$($({},Lt),t),i.progressFn&&r(i.progressFn)&&!Object.keys(i.progressFn).length)i.progressFn=null;else if(i.progressFn&&typeof i.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] 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(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
36
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},Lt);let l=e.filter(s=>Array.isArray(s)).map(s=>[...s]).filter(s=>s[2]!==void 0||s[0]!==s[1]),n,o,a;i.progressFn?n=kt(l,{progressFn:s=>{a=Math.floor(s/5),a!==o&&(o=a,i.progressFn(a))}}):n=kt(l);let g=n.length-1;for(let s=g;s>0;s--)i.progressFn&&(a=Math.floor((1-s/g)*78)+21,a!==o&&a>o&&(o=a,i.progressFn(a))),(n[s][0]<=n[s-1][0]||!i.joinRangesThatTouchEdges&&n[s][0]<n[s-1][1]||i.joinRangesThatTouchEdges&&n[s][0]<=n[s-1][1])&&(n[s-1][0]=Math.min(n[s][0],n[s-1][0]),n[s-1][1]=Math.max(n[s][1],n[s-1][1]),n[s][2]!==void 0&&(n[s-1][0]>=n[s][0]||n[s-1][1]<=n[s][1])&&n[s-1][2]!==null&&(n[s][2]===null&&n[s-1][2]!==null?n[s-1][2]=null:n[s-1][2]!=null?+i.mergeType==2&&n[s-1][0]===n[s][0]?n[s-1][2]=n[s][2]:n[s-1][2]+=n[s][2]:n[s-1][2]=n[s][2]),n.splice(s,1),s=n.length);return n.length?n:null}function C(e){return e!=null}function V(e){return Number.isInteger(e)&&e>=0}function z(e){return typeof e=="string"}var Un={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Y=class{constructor(e){be(this,"ranges");be(this,"opts");let t=$($({},Un),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(z(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(z(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,r){var n;if(e==null&&t==null)return;if(C(e)&&!C(t)){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&&V(+e[0])&&V(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!C(e)&&C(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let i=+e,l=+t;if(V(r)&&(r=String(r)),V(i)&&V(l)){if(C(r)&&!z(r)&&!V(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:
37
+ ${JSON.stringify(r,null,4)}`);if(C(this.ranges)&&Array.isArray(this.last())&&i===this.last()[1]){if(this.last()[1]=l,this.last()[2],this.last()[2]!==null&&C(r)){let o=this.last()[2]&&this.last()[2].length&&(!((n=this.opts)!=null&&n.mergeType)||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(o=pe(o,this.opts.limitLinebreaksCount)),z(o)&&!o.length||(this.last()[2]=o)}}else{this.ranges||(this.ranges=[]);let o=r!==void 0&&!(z(r)&&!r.length)?[i,l,r&&this.opts.limitToBeAddedWhitespace?pe(r,this.opts.limitLinebreaksCount):r]:[i,l];this.ranges.push(o)}}else throw V(i)&&i>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof l}" equal to: ${JSON.stringify(l,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof i}" equal to: ${JSON.stringify(i,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=qn(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>C(e[2])?[e[0],e[1],pe(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&V(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var Kn={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Be(e,t){if(!Array.isArray(e)||!e.length)return e;let r=$($({},Kn),t),i,l;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,g)=>!Array.isArray(a)||a.length!==2?(i=g,l=a.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 ${l} elements!`);if(!e.every((a,g)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(i=g,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,o=0;return Array.from(e).sort((a,g)=>(r.progressFn&&(o+=1,r.progressFn(Math.floor(o*100/n))),a[0]===g[0]?a[1]<g[1]?-1:a[1]>g[1]?1:0:a[0]<g[0]?-1:1))}var qt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ut(e,t){function r(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}if(!Array.isArray(e)||!e.length)return null;let i;if(t)if(r(t)){if(i=$($({},qt),t),i.progressFn&&r(i.progressFn)&&!Object.keys(i.progressFn).length)i.progressFn=null;else if(i.progressFn&&typeof i.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof i.progressFn}", equal to ${JSON.stringify(i.progressFn,null,4)}`);if(![1,2,"1","2"].includes(i.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof i.mergeType}", equal to ${JSON.stringify(i.mergeType,null,4)}`);if(typeof i.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof i.joinRangesThatTouchEdges}", equal to ${JSON.stringify(i.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
38
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},qt);let l=e.filter(s=>Array.isArray(s)).map(s=>[...s]).filter(s=>s[2]!==void 0||s[0]!==s[1]),n,o,a;i.progressFn?n=Be(l,{progressFn:s=>{a=Math.floor(s/5),a!==o&&(o=a,i.progressFn(a))}}):n=Be(l);let g=n.length-1;for(let s=g;s>0;s--)i.progressFn&&(a=Math.floor((1-s/g)*78)+21,a!==o&&a>o&&(o=a,i.progressFn(a))),(n[s][0]<=n[s-1][0]||!i.joinRangesThatTouchEdges&&n[s][0]<n[s-1][1]||i.joinRangesThatTouchEdges&&n[s][0]<=n[s-1][1])&&(n[s-1][0]=Math.min(n[s][0],n[s-1][0]),n[s-1][1]=Math.max(n[s][1],n[s-1][1]),n[s][2]!==void 0&&(n[s-1][0]>=n[s][0]||n[s-1][1]<=n[s][1])&&n[s-1][2]!==null&&(n[s][2]===null&&n[s-1][2]!==null?n[s-1][2]=null:n[s-1][2]!=null?+i.mergeType==2&&n[s-1][0]===n[s][0]?n[s-1][2]=n[s][2]:n[s-1][2]+=n[s][2]:n[s-1][2]=n[s][2]),n.splice(s,1),s=n.length);return n.length?n:null}var Gn=!0,Fe="Invariant failed";function Kt(e,t){if(!e){if(Gn)throw new Error(Fe);var r=typeof t=="function"?t():t,i=r?"".concat(Fe,": ").concat(r):Fe;throw new Error(i)}}function L(e,t,r){let i=0,l=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter(h=>h).length)return e;let n;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?n=[Array.from(t)]:n=Array.from(t);let o=n.length,a=0;n.filter(h=>h).forEach((h,c)=>{if(r&&(i=Math.floor(a/o*10),i!==l&&(l=i,r(i))),!Array.isArray(h))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${c}th element not an array: ${JSON.stringify(h,null,4)}, which is ${typeof h}`);if(!Number.isInteger(h[0])){if(!Number.isInteger(+h[0])||+h[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(h,null,0)}. Its first element is not an integer, string index, but ${typeof h[0]}, equal to: ${JSON.stringify(h[0],null,4)}.`);n[c][0]=+n[c][0]}if(!Number.isInteger(h[1])){if(!Number.isInteger(+h[1])||+h[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(h,null,0)}. Its second element is not an integer, string index, but ${typeof h[1]}, equal to: ${JSON.stringify(h[1],null,4)}.`);n[c][1]=+n[c][1]}a+=1});let g=Ut(n,{progressFn:h=>{r&&(i=10+Math.floor(h/10),i!==l&&(l=i,r(i)))}});Kt(g);let s=g.length;if(s>0){let h=e.slice(g[s-1][1]);e=g.reduce((c,T,y,u)=>{r&&(i=20+Math.floor(y/s*80),i!==l&&(l=i,r(i)));let w=y===0?0:u[y-1][1],d=u[y][0];return`${c}${e.slice(w,d)}${u[y][2]||""}`},""),e+=h}return e}var Qn={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function X(e,t){if(typeof e!="string")throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:
39
+ ${JSON.stringify(e,null,4)}`);let r=$($({},Qn),t);function i(o){return r.classicTrim&&!o.trim()||!r.classicTrim&&(r.space&&o===" "||r.cr&&o==="\r"||r.lf&&o===`
40
+ `||r.tab&&o===" "||r.nbsp&&o==="\xA0")}let l,n;if(e.length){if(i(e[0]))for(let o=0,a=e.length;o<a;o++){if(!i(e[o])){l=o;break}if(o===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let o=e.length;o--;)if(!i(e[o])){n=o+1;break}}return l?n?{res:e.slice(l,n),ranges:[[0,l],[n,e.length]]}:{res:e.slice(l),ranges:[[0,l]]}:n?{res:e.slice(0,n),ranges:[[n,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var zn={heads:["{{"],tails:["}}"]};function Gt(e,t){let r=Object.prototype.hasOwnProperty;if(e===void 0)throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(t&&!le(t))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof t}!`);let i=$({},t);if(i&&r.call(i,"heads"))if(I(i.heads).every(w=>typeof w=="string"||Array.isArray(w)))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&&r.call(i,"tails"))if(I(i.tails).every(w=>typeof w=="string"||Array.isArray(w)))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 l=X(e).res;if(l.length===0)return e;e=l;let n=$($({},zn),i);n.heads=n.heads.map(w=>w.trim()),n.tails=n.tails.map(w=>w.trim());let o=!1,a=!1,g=new Y({limitToBeAddedWhitespace:!0}),s=new Y({limitToBeAddedWhitespace:!0}),h=!0,c=!0,T="";function y(w,d){let f;return S(w,0,d.heads,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=b,!0)})&&S(w,f,d.tails,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=b,!0)})?w.slice(f):w}for(;e!==y(e,n);)e=X(y(e,n)).res;function u(w,d){let f;return!k(w,w.length-1,d.tails,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=b,!0)})||!f?w:k(w,f,d.heads,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=b,!0)})?w.slice(0,f+1):w}for(;e!==u(e,n);)e=X(u(e,n)).res;if(!n.heads.length||!S(e,0,n.heads,{trimBeforeMatching:!0})||!n.tails.length||!k(e,e.length-1,n.tails,{trimBeforeMatching:!0}))return X(e).res;for(let w=0,d=e.length;w<d;w++)if(e[w].trim()!==""){let f;if(S(e,w,n.heads,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=b,!0)})&&f){c=!0,h&&(h=!0);let p;S(e,f,n.tails,{trimBeforeMatching:!0,cb:(m,b,O)=>(p=O,!0)})&&g.push(w,p),s.current()&&o&&T!=="tails"&&g.push(s.current()),o||s.current()&&(g.push(s.current()),s.wipe()),s.push(w,f),T="heads",w=f-1;continue}if(S(e,w,n.tails,{trimBeforeMatching:!0,cb:(p,m,b)=>(f=Number.isInteger(b)?b:e.length,!0)})&&f){c=!0,h?(T==="heads"&&s.wipe(),h=!1):s.push(w,f),T="tails",w=f-1;continue}h&&(h=!0),c&&!o?(o=!0,c=!1):c&&!a?(a=!0,h=!0,c=!1,T==="heads"&&s.wipe()):c&&a&&s.wipe()}return s.current()&&g.push(s.current()),g.current()?L(e,g.current()).trim():e.trim()}var Qt="12.0.3";var Xn=Qt,Zn=Object.prototype.hasOwnProperty,Xt={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 _(e){return typeof e=="string"}function ei(e){return typeof e=="number"}function ke(e){return typeof e=="boolean"}function de(e){return e===null}function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ti(e){return e!=null}function A(e){return _(e)?e.trim():e}function ri(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(0,t)}return e}function ni(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(t+1)}return e}function Zt(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(0,t)}return e}function zt(e){if(typeof e=="string"&&e.length&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(t+1)}return e}function Le(e,t){return typeof e!="string"||!e.trim()?!1:!!(e.includes(t.heads)||e.includes(t.tails)||_(t.headsNoWrap)&&t.headsNoWrap.length&&e.includes(t.headsNoWrap)||_(t.tailsNoWrap)&&t.tailsNoWrap.length&&e.includes(t.tailsNoWrap))}function ii(e,t,r){let i,l;return typeof e=="string"&&e.length&&S(e,0,t,{trimBeforeMatching:!0,cb:(n,o,a)=>(i=a,!0)})&&k(e,e.length-1,r,{trimBeforeMatching:!0,cb:(n,o,a)=>(l=(a||0)+1,!0)})?e.slice(i,l):e}function Yt(e,t,r=!1,i,l,n){if(t.wrapHeadsWith||(t.wrapHeadsWith=""),t.wrapTailsWith||(t.wrapTailsWith=""),_(e)&&!r&&t.wrapGlobalFlipSwitch&&!t.dontWrapVars.some(o=>ge(n,o))&&(!t.preventDoubleWrapping||t.preventDoubleWrapping&&_(e)&&!e.includes(t.wrapHeadsWith)&&!e.includes(t.wrapTailsWith)))return`${t.wrapHeadsWith}${e}${t.wrapTailsWith}`;if(r){if(!_(e))return e;let o=Gt(e,{heads:t.wrapHeadsWith,tails:t.wrapTailsWith});return _(o)?ii(o,t.wrapHeadsWith,t.wrapTailsWith):o}return e}function ai(e,t,r,i){let l;if(r.indexOf(".")!==-1){let n=r,o=!0;if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length&&!n.endsWith(i.dataContainerIdentifierTails)){let a=W.default.get(e,n+i.dataContainerIdentifierTails);Z(a)&&W.default.get(a,t)&&(l=W.default.get(a,t),o=!1)}for(;o&&n.indexOf(".")!==-1;){if(n=Zt(n),zt(n)===t)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop. The parent key "${zt(n)}" is called the same as the variable "${t}" we're looking for.`);if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length&&!n.endsWith(i.dataContainerIdentifierTails)){let a=W.default.get(e,n+i.dataContainerIdentifierTails);Z(a)&&W.default.get(a,t)&&(l=W.default.get(a,t),o=!1)}if(l===void 0){let a=W.default.get(e,n);Z(a)&&W.default.get(a,t)&&(l=W.default.get(a,t),o=!1)}}}if(l===void 0){let n=W.default.get(e,t);n!==void 0&&(l=n)}if(l===void 0)if(t.indexOf(".")===-1){let n=Je(e,t);if(n.length){for(let o=0,a=n.length;o<a;o++)if(_(n[o].val)||ke(n[o].val)||de(n[o].val)){l=n[o].val;break}else if(ei(n[o].val)){l=String(n[o].val);break}else if(Array.isArray(n[o].val)){l=n[o].val.join("");break}}}else{let n=Je(e,ri(t));if(n.length)for(let o=0,a=n.length;o<a;o++){let g=W.default.get(n[o].val,ni(t));g&&_(g)&&(l=g)}}return l}function er(e,t,r,i,l=[]){if(l.includes(r)){let y="";if(l.length>1){let u=` \u2192
41
+ `;y=l.reduce((w,d,f)=>w+(f===0?"":u)+(d===r?"\u{1F4A5} ":" ")+d,` Here's the path we travelled up until we hit the recursion:
42
+
43
+ `),y+=`${u}\u{1F4A5} ${r}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop, the key is referencing itself."${y}`)}let n={},o=Array.from(l);o.push(r);let a=new Y;function g(y,u,w){for(let d=0,f=y.length;d<f;d++){let p=y[d],m=t.slice(p.headsEndAt,p.tailsStartAt);if(m.length===0)a.push(p.headsStartAt,p.tailsEndAt);else if(Zn.call(n,m)&&_(n[m]))a.push(p.headsStartAt,p.tailsEndAt,n[m]);else{let b=ai(e,m.trim(),r,i);if(b===void 0)if(i.allowUnresolved===!0)b="";else if(typeof i.allowUnresolved=="string")b=i.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${t.slice(p.headsEndAt,p.tailsStartAt)}. We're at path: "${r}".`);if(!w&&i.throwWhenNonStringInsertedInString&&!_(b))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${t.slice(p.headsEndAt,p.tailsStartAt)} at path ${r}, it resolved into a non-string value, ${JSON.stringify(b,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(ke(b)){if(i.resolveToBoolIfAnyValuesContainBool)return a.wipe(),i.resolveToFalseIfAnyValuesContainBool?!1:b;b=""}else{if(de(b)&&w)return a.wipe(),b;Array.isArray(b)?b=String(b.join("")):de(b)?b="":b=String(b)}let O=r.includes(".")?`${Zt(r)}.${m}`:m;if(Le(b,i)){let E=Yt(er(e,b,O,i,o),i,u,o,O,m.trim());typeof E=="string"&&a.push(p.headsStartAt,p.tailsEndAt,E)}else{n[m]=b;let E=Yt(b,i,u,o,O,m.trim());typeof E=="string"&&a.push(p.headsStartAt,p.tailsEndAt,E)}}}}let s;try{s=Me(t,i.heads,i.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(y){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${t}" at path ${r}, something wrong with heads and tails was detected! Here's the internal error message:
44
+ ${y}`)}let h=!1;s.length===1&&L(t,[[s[0].headsStartAt,s[0].tailsEndAt]]).trim()===""&&(h=!0);let c=g(s,!1,h);if(typeof c=="boolean"||c===null)return c;try{s=Me(t,i.headsNoWrap,i.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(y){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${t}" at path ${r}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
45
+ ${y}`)}s.length===1&&L(t,[[s[0].headsStartAt,s[0].tailsEndAt]]).trim()===""&&(h=!0);let T=g(s,!0,h);return ke(T)||de(T)?T:a!=null&&a.current()?L(t,a.current()):t}function si(e,t){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!Z(e))throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(e)?"array":typeof e}`);if(t&&!Z(t))throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(t)?"array":typeof t}`);let r=$($({},Xt),t);r.dontWrapVars?Array.isArray(r.dontWrapVars)||(r.dontWrapVars=I(r.dontWrapVars)):r.dontWrapVars=[];let i,l;if(r.dontWrapVars.length&&!r.dontWrapVars.every((o,a)=>_(o)?!0:(i=o,l=a,!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 ${l}, which is not string but ${Array.isArray(i)?"array":typeof i}!`);if(r.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! resolvedOpts.heads are empty!");if(r.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! resolvedOpts.tails are empty!");if(r.lookForDataContainers&&r.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! resolvedOpts.dataContainerIdentifierTails is empty!");if(r.heads===r.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! resolvedOpts.heads and resolvedOpts.tails can't be equal!");if(r.heads===r.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! resolvedOpts.heads and resolvedOpts.headsNoWrap can't be equal!");if(r.tails===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! resolvedOpts.tails and resolvedOpts.tailsNoWrap can't be equal!");if(r.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! resolvedOpts.headsNoWrap is an empty string!");if(r.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! resolvedOpts.tailsNoWrap is an empty string!");if(r.headsNoWrap===r.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! resolvedOpts.headsNoWrap and resolvedOpts.tailsNoWrap can't be equal!");let n;return ue(e,(o,a,g)=>{if(ti(a)&&Le(o,r))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
46
+ Please check the following key: ${o}`);if(a!==void 0?n=a:n=o,n==="")return n;if(r.heads.length&&A(n)===A(r.heads)||r.tails.length&&A(n)===A(r.tails)||r.headsNoWrap.length&&A(n)===A(r.headsNoWrap)||r.tailsNoWrap.length&&A(n)===A(r.tailsNoWrap)){if(!r.noSingleMarkers)return n;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${A(n)} which is equal to ${A(n)===A(r.heads)?"heads":""}${A(n)===A(r.tails)?"tails":""}${_(r.headsNoWrap)&&A(n)===A(r.headsNoWrap)?"headsNoWrap":""}${_(r.tailsNoWrap)&&A(n)===A(r.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(n)}) alone`)}return _(n)&&Le(n,r)?er(e,n,g.path,r):n})}return fr(oi);})();
47
+ /**
48
+ * @name codsen-utils
49
+ * @fileoverview Various utility functions
50
+ * @version 1.0.1
51
+ * @author Roy Revelt, Codsen Ltd
52
+ * @license MIT
53
+ * {@link https://codsen.com/os/codsen-utils/}
54
+ */
55
+ /**
56
+ * @name ast-monkey-util
57
+ * @fileoverview Utility library of AST helper functions
58
+ * @version 3.0.3
59
+ * @author Roy Revelt, Codsen Ltd
60
+ * @license MIT
61
+ * {@link https://codsen.com/os/ast-monkey-util/}
62
+ */
63
+ /**
64
+ * @name ast-monkey-traverse
65
+ * @fileoverview Utility library to traverse AST
66
+ * @version 4.0.3
67
+ * @author Roy Revelt, Codsen Ltd
68
+ * @license MIT
69
+ * {@link https://codsen.com/os/ast-monkey-traverse/}
70
+ */
71
+ /**
72
+ * @name arrayiffy-if-string
73
+ * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
74
+ * @version 5.0.3
75
+ * @author Roy Revelt, Codsen Ltd
76
+ * @license MIT
77
+ * {@link https://codsen.com/os/arrayiffy-if-string/}
78
+ */
79
+ /**
80
+ * @name string-match-left-right
81
+ * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
82
+ * @version 9.0.3
83
+ * @author Roy Revelt, Codsen Ltd
84
+ * @license MIT
85
+ * {@link https://codsen.com/os/string-match-left-right/}
86
+ */
87
+ /**
88
+ * @name string-find-heads-tails
89
+ * @fileoverview Finds where are arbitrary templating marker heads and tails located
90
+ * @version 6.0.3
91
+ * @author Roy Revelt, Codsen Ltd
92
+ * @license MIT
93
+ * {@link https://codsen.com/os/string-find-heads-tails/}
94
+ */
95
+ /**
96
+ * @name ast-get-values-by-key
97
+ * @fileoverview Extract values and paths from AST by keys OR set them by keys
98
+ * @version 5.0.3
99
+ * @author Roy Revelt, Codsen Ltd
100
+ * @license MIT
101
+ * {@link https://codsen.com/os/ast-get-values-by-key/}
102
+ */
103
+ /**
104
+ * @name string-collapse-leading-whitespace
105
+ * @fileoverview Collapse the leading and trailing whitespace of a string
106
+ * @version 7.0.3
107
+ * @author Roy Revelt, Codsen Ltd
108
+ * @license MIT
109
+ * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
110
+ */
111
+ /**
112
+ * @name ranges-push
113
+ * @fileoverview Gather string index ranges
114
+ * @version 7.0.3
115
+ * @author Roy Revelt, Codsen Ltd
116
+ * @license MIT
117
+ * {@link https://codsen.com/os/ranges-push/}
118
+ */
119
+ /**
120
+ * @name ranges-sort
121
+ * @fileoverview Sort string index ranges
122
+ * @version 6.0.3
123
+ * @author Roy Revelt, Codsen Ltd
124
+ * @license MIT
125
+ * {@link https://codsen.com/os/ranges-sort/}
126
+ */
127
+ /**
128
+ * @name ranges-merge
129
+ * @fileoverview Merge and sort string index ranges
130
+ * @version 9.0.3
131
+ * @author Roy Revelt, Codsen Ltd
132
+ * @license MIT
133
+ * {@link https://codsen.com/os/ranges-merge/}
134
+ */
135
+ /**
136
+ * @name ranges-apply
137
+ * @fileoverview Take an array of string index ranges, delete/replace the string according to them
138
+ * @version 7.0.3
139
+ * @author Roy Revelt, Codsen Ltd
140
+ * @license MIT
141
+ * {@link https://codsen.com/os/ranges-apply/}
142
+ */
143
+ /**
144
+ * @name string-trim-spaces-only
145
+ * @fileoverview Like String.trim() but you can choose granularly what to trim
146
+ * @version 5.0.3
147
+ * @author Roy Revelt, Codsen Ltd
148
+ * @license MIT
149
+ * {@link https://codsen.com/os/string-trim-spaces-only/}
150
+ */
151
+ /**
152
+ * @name string-remove-duplicate-heads-tails
153
+ * @fileoverview Detect and (recursively) remove head and tail wrappings around the input string
154
+ * @version 7.0.3
155
+ * @author Roy Revelt, Codsen Ltd
156
+ * @license MIT
157
+ * {@link https://codsen.com/os/string-remove-duplicate-heads-tails/}
158
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-variables",
3
- "version": "12.0.1",
3
+ "version": "12.0.3",
4
4
  "description": "Resolves custom-marked, cross-referenced paths in parsed JSON",
5
5
  "keywords": [
6
6
  "comb",
@@ -78,15 +78,15 @@
78
78
  "various": {}
79
79
  },
80
80
  "dependencies": {
81
- "arrayiffy-if-string": "^5.0.1",
82
- "ast-get-values-by-key": "^5.0.1",
83
- "ast-monkey-traverse": "^4.0.1",
81
+ "arrayiffy-if-string": "^5.0.3",
82
+ "ast-get-values-by-key": "^5.0.3",
83
+ "ast-monkey-traverse": "^4.0.3",
84
84
  "matcher": "^5.0.0",
85
85
  "object-path": "^0.11.8",
86
- "ranges-apply": "^7.0.1",
87
- "ranges-push": "^7.0.1",
88
- "string-find-heads-tails": "^6.0.1",
89
- "string-match-left-right": "^9.0.1",
90
- "string-remove-duplicate-heads-tails": "^7.0.1"
86
+ "ranges-apply": "^7.0.3",
87
+ "ranges-push": "^7.0.3",
88
+ "string-find-heads-tails": "^6.0.3",
89
+ "string-match-left-right": "^9.0.3",
90
+ "string-remove-duplicate-heads-tails": "^7.0.3"
91
91
  }
92
92
  }
package/types/index.d.ts CHANGED
File without changes