UNPKG

ast-monkey

Version:
103 lines (93 loc) 36.9 kB
/** * @name ast-monkey * @fileoverview Traverse and edit AST * @version 9.0.29 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/ast-monkey/} */ "use strict";var astMonkey=(()=>{var wt=Object.create;var _=Object.defineProperty,Ot=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols,At=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))we.call(t,r)&&ve(e,r,t[r]);if(be)for(var r of be(t))$t.call(t,r)&&ve(e,r,t[r]);return e},E=(e,t)=>Ot(e,jt(t));var q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kt=(e,t)=>{for(var r in t)_(e,r,{get:t[r],enumerable:!0})},Oe=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of St(t))!we.call(e,p)&&p!==r&&_(e,p,{get:()=>t[p],enumerable:!(u=Tt(t,p))||u.enumerable});return e};var H=(e,t,r)=>(r=e!=null?wt(At(e)):{},Oe(t||!e||!e.__esModule?_(r,"default",{value:e,enumerable:!0}):r,e)),Et=e=>Oe(_({},"__esModule",{value:!0}),e);var lt=q((ue,le)=>{(function(e,t){typeof ue=="object"&&typeof le<"u"?le.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.typeDetect=t())})(ue,function(){"use strict";var e=typeof Promise=="function",t=function(g){if(typeof globalThis=="object")return globalThis;Object.defineProperty(g,"typeDetectGlobalObject",{get:function(){return this},configurable:!0});var D=typeDetectGlobalObject;return delete g.typeDetectGlobalObject,D}(Object.prototype),r=typeof Symbol<"u",u=typeof Map<"u",p=typeof Set<"u",y=typeof WeakMap<"u",m=typeof WeakSet<"u",o=typeof DataView<"u",n=r&&typeof Symbol.iterator<"u",a=r&&typeof Symbol.toStringTag<"u",f=p&&typeof Set.prototype.entries=="function",s=u&&typeof Map.prototype.entries=="function",l=f&&Object.getPrototypeOf(new Set().entries()),T=s&&Object.getPrototypeOf(new Map().entries()),b=n&&typeof Array.prototype[Symbol.iterator]=="function",A=b&&Object.getPrototypeOf([][Symbol.iterator]()),c=n&&typeof String.prototype[Symbol.iterator]=="function",i=c&&Object.getPrototypeOf(""[Symbol.iterator]()),d=8,x=-1;function j(g){var D=typeof g;if(D!=="object")return D;if(g===null)return"null";if(g===t)return"global";if(Array.isArray(g)&&(a===!1||!(Symbol.toStringTag in g)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&g===window.location)return"Location";if(typeof window.document=="object"&&g===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&g===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&g===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&g instanceof window.HTMLElement){if(g.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(g.tagName==="TD")return"HTMLTableDataCellElement";if(g.tagName==="TH")return"HTMLTableHeaderCellElement"}}var W=a&&g[Symbol.toStringTag];if(typeof W=="string")return W;var v=Object.getPrototypeOf(g);return v===RegExp.prototype?"RegExp":v===Date.prototype?"Date":e&&v===Promise.prototype?"Promise":p&&v===Set.prototype?"Set":u&&v===Map.prototype?"Map":m&&v===WeakSet.prototype?"WeakSet":y&&v===WeakMap.prototype?"WeakMap":o&&v===DataView.prototype?"DataView":u&&v===T?"Map Iterator":p&&v===l?"Set Iterator":b&&v===A?"Array Iterator":c&&v===i?"String Iterator":v===null?"Object":Object.prototype.toString.call(g).slice(d,x)}return j})});var pe=q((_n,pt)=>{"use strict";pt.exports=Ao;function F(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Ao(e){if(e=e||{},e.circles)return $o(e);let t=new Map;if(t.set(Date,m=>new Date(m)),t.set(Map,(m,o)=>new Map(u(Array.from(m),o))),t.set(Set,(m,o)=>new Set(u(Array.from(m),o))),e.constructorHandlers)for(let m of e.constructorHandlers)t.set(m[0],m[1]);let r=null;return e.proto?y:p;function u(m,o){let n=Object.keys(m),a=new Array(n.length);for(let f=0;f<n.length;f++){let s=n[f],l=m[s];typeof l!="object"||l===null?a[s]=l:l.constructor!==Object&&(r=t.get(l.constructor))?a[s]=r(l,o):ArrayBuffer.isView(l)?a[s]=F(l):a[s]=o(l)}return a}function p(m){if(typeof m!="object"||m===null)return m;if(Array.isArray(m))return u(m,p);if(m.constructor!==Object&&(r=t.get(m.constructor)))return r(m,p);let o={};for(let n in m){if(Object.hasOwnProperty.call(m,n)===!1)continue;let a=m[n];typeof a!="object"||a===null?o[n]=a:a.constructor!==Object&&(r=t.get(a.constructor))?o[n]=r(a,p):ArrayBuffer.isView(a)?o[n]=F(a):o[n]=p(a)}return o}function y(m){if(typeof m!="object"||m===null)return m;if(Array.isArray(m))return u(m,y);if(m.constructor!==Object&&(r=t.get(m.constructor)))return r(m,y);let o={};for(let n in m){let a=m[n];typeof a!="object"||a===null?o[n]=a:a.constructor!==Object&&(r=t.get(a.constructor))?o[n]=r(a,y):ArrayBuffer.isView(a)?o[n]=F(a):o[n]=y(a)}return o}}function $o(e){let t=[],r=[],u=new Map;if(u.set(Date,n=>new Date(n)),u.set(Map,(n,a)=>new Map(y(Array.from(n),a))),u.set(Set,(n,a)=>new Set(y(Array.from(n),a))),e.constructorHandlers)for(let n of e.constructorHandlers)u.set(n[0],n[1]);let p=null;return e.proto?o:m;function y(n,a){let f=Object.keys(n),s=new Array(f.length);for(let l=0;l<f.length;l++){let T=f[l],b=n[T];if(typeof b!="object"||b===null)s[T]=b;else if(b.constructor!==Object&&(p=u.get(b.constructor)))s[T]=p(b,a);else if(ArrayBuffer.isView(b))s[T]=F(b);else{let A=t.indexOf(b);A!==-1?s[T]=r[A]:s[T]=a(b)}}return s}function m(n){if(typeof n!="object"||n===null)return n;if(Array.isArray(n))return y(n,m);if(n.constructor!==Object&&(p=u.get(n.constructor)))return p(n,m);let a={};t.push(n),r.push(a);for(let f in n){if(Object.hasOwnProperty.call(n,f)===!1)continue;let s=n[f];if(typeof s!="object"||s===null)a[f]=s;else if(s.constructor!==Object&&(p=u.get(s.constructor)))a[f]=p(s,m);else if(ArrayBuffer.isView(s))a[f]=F(s);else{let l=t.indexOf(s);l!==-1?a[f]=r[l]:a[f]=m(s)}}return t.pop(),r.pop(),a}function o(n){if(typeof n!="object"||n===null)return n;if(Array.isArray(n))return y(n,o);if(n.constructor!==Object&&(p=u.get(n.constructor)))return p(n,o);let a={};t.push(n),r.push(a);for(let f in n){let s=n[f];if(typeof s!="object"||s===null)a[f]=s;else if(s.constructor!==Object&&(p=u.get(s.constructor)))a[f]=p(s,o);else if(ArrayBuffer.isView(s))a[f]=F(s);else{let l=t.indexOf(s);l!==-1?a[f]=r[l]:a[f]=o(s)}}return t.pop(),r.pop(),a}}});var xt=q((gt,ee)=>{(function(e,t){"use strict";typeof ee=="object"&&typeof ee.exports=="object"?ee.exports=t():typeof define=="function"&&define.amd?define([],t):e.objectPath=t()})(gt,function(){"use strict";var e=Object.prototype.toString;function t(f,s){return f==null?!1:Object.prototype.hasOwnProperty.call(f,s)}function r(f){if(!f||y(f)&&f.length===0)return!0;if(typeof f!="string"){for(var s in f)if(t(f,s))return!1;return!0}return!1}function u(f){return e.call(f)}function p(f){return typeof f=="object"&&u(f)==="[object Object]"}var y=Array.isArray||function(f){return e.call(f)==="[object Array]"};function m(f){return typeof f=="boolean"||u(f)==="[object Boolean]"}function o(f){var s=parseInt(f);return s.toString()===f?s:f}function n(f){f=f||{};var s=function(c){return Object.keys(s).reduce(function(i,d){return d==="create"||typeof s[d]=="function"&&(i[d]=s[d].bind(s,c)),i},{})},l;f.includeInheritedProps?l=function(){return!0}:l=function(c,i){return typeof i=="number"&&Array.isArray(c)||t(c,i)};function T(c,i){if(l(c,i))return c[i]}var b;f.includeInheritedProps?b=function(c,i){typeof i!="string"&&typeof i!="number"&&(i=String(i));var d=T(c,i);if(i==="__proto__"||i==="prototype"||i==="constructor"&&typeof d=="function")throw new Error("For security reasons, object's magic properties cannot be set");return d}:b=function(c,i){return T(c,i)};function A(c,i,d,x){if(typeof i=="number"&&(i=[i]),!i||i.length===0)return c;if(typeof i=="string")return A(c,i.split(".").map(o),d,x);var j=i[0],g=b(c,j);return i.length===1?((g===void 0||!x)&&(c[j]=d),g):(g===void 0&&(typeof i[1]=="number"?c[j]=[]:c[j]={}),A(c[j],i.slice(1),d,x))}return s.has=function(c,i){if(typeof i=="number"?i=[i]:typeof i=="string"&&(i=i.split(".")),!i||i.length===0)return!!c;for(var d=0;d<i.length;d++){var x=o(i[d]);if(typeof x=="number"&&y(c)&&x<c.length||(f.includeInheritedProps?x in Object(c):t(c,x)))c=c[x];else return!1}return!0},s.ensureExists=function(c,i,d){return A(c,i,d,!0)},s.set=function(c,i,d,x){return A(c,i,d,x)},s.insert=function(c,i,d,x){var j=s.get(c,i);x=~~x,y(j)||(j=[],s.set(c,i,j)),j.splice(x,0,d)},s.empty=function(c,i){if(!r(i)&&c!=null){var d,x;if(d=s.get(c,i)){if(typeof d=="string")return s.set(c,i,"");if(m(d))return s.set(c,i,!1);if(typeof d=="number")return s.set(c,i,0);if(y(d))d.length=0;else if(p(d))for(x in d)l(d,x)&&delete d[x];else return s.set(c,i,null)}}},s.push=function(c,i){var d=s.get(c,i);y(d)||(d=[],s.set(c,i,d)),d.push.apply(d,Array.prototype.slice.call(arguments,2))},s.coalesce=function(c,i,d){for(var x,j=0,g=i.length;j<g;j++)if((x=s.get(c,i[j]))!==void 0)return x;return d},s.get=function(c,i,d){if(typeof i=="number"&&(i=[i]),!i||i.length===0)return c;if(c==null)return d;if(typeof i=="string")return s.get(c,i.split("."),d);var x=o(i[0]),j=b(c,x);return j===void 0?d:i.length===1?j:s.get(c[x],i.slice(1),d)},s.del=function(i,d){if(typeof d=="number"&&(d=[d]),i==null||r(d))return i;if(typeof d=="string")return s.del(i,d.split("."));var x=o(d[0]);if(b(i,x),!l(i,x))return i;if(d.length===1)y(i)?i.splice(x,1):delete i[x];else return s.del(i[x],d.slice(1));return i},s}var a=n();return a.create=n,a.withInheritedProps=n({includeInheritedProps:!0}),a})});var bt=q((xe,he)=>{(function(e,t){typeof xe=="object"&&typeof he<"u"?he.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.typeDetect=t())})(xe,function(){"use strict";var e=typeof Promise=="function",t=function(g){if(typeof globalThis=="object")return globalThis;Object.defineProperty(g,"typeDetectGlobalObject",{get:function(){return this},configurable:!0});var D=typeDetectGlobalObject;return delete g.typeDetectGlobalObject,D}(Object.prototype),r=typeof Symbol<"u",u=typeof Map<"u",p=typeof Set<"u",y=typeof WeakMap<"u",m=typeof WeakSet<"u",o=typeof DataView<"u",n=r&&typeof Symbol.iterator<"u",a=r&&typeof Symbol.toStringTag<"u",f=p&&typeof Set.prototype.entries=="function",s=u&&typeof Map.prototype.entries=="function",l=f&&Object.getPrototypeOf(new Set().entries()),T=s&&Object.getPrototypeOf(new Map().entries()),b=n&&typeof Array.prototype[Symbol.iterator]=="function",A=b&&Object.getPrototypeOf([][Symbol.iterator]()),c=n&&typeof String.prototype[Symbol.iterator]=="function",i=c&&Object.getPrototypeOf(""[Symbol.iterator]()),d=8,x=-1;function j(g){var D=typeof g;if(D!=="object")return D;if(g===null)return"null";if(g===t)return"global";if(Array.isArray(g)&&(a===!1||!(Symbol.toStringTag in g)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&g===window.location)return"Location";if(typeof window.document=="object"&&g===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&g===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&g===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&g instanceof window.HTMLElement){if(g.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(g.tagName==="TD")return"HTMLTableDataCellElement";if(g.tagName==="TH")return"HTMLTableHeaderCellElement"}}var W=a&&g[Symbol.toStringTag];if(typeof W=="string")return W;var v=Object.getPrototypeOf(g);return v===RegExp.prototype?"RegExp":v===Date.prototype?"Date":e&&v===Promise.prototype?"Promise":p&&v===Set.prototype?"Set":u&&v===Map.prototype?"Map":m&&v===WeakSet.prototype?"WeakSet":y&&v===WeakMap.prototype?"WeakMap":o&&v===DataView.prototype?"DataView":u&&v===T?"Map Iterator":p&&v===l?"Set Iterator":b&&v===A?"Array Iterator":c&&v===i?"String Iterator":v===null?"Object":Object.prototype.toString.call(g).slice(d,x)}return j})});var _o={};kt(_o,{arrayFirstOnly:()=>Co,del:()=>Fo,drop:()=>Vo,find:()=>Lo,get:()=>Bo,set:()=>Ro,traverse:()=>N,version:()=>Mo});var It=typeof global=="object"&&global&&global.Object===Object&&global,z=It;var Pt=typeof self=="object"&&self&&self.Object===Object&&self,Dt=z||Pt||Function("return this")(),Q=Dt;var Nt=Q.Symbol,V=Nt;var Te=Object.prototype,Wt=Te.hasOwnProperty,Mt=Te.toString,J=V?V.toStringTag:void 0;function Lt(e){var t=Wt.call(e,J),r=e[J];try{e[J]=void 0;var u=!0}catch(y){}var p=Mt.call(e);return u&&(t?e[J]=r:delete e[J]),p}var je=Lt;var Bt=Object.prototype,Rt=Bt.toString;function Vt(e){return Rt.call(e)}var Se=Vt;var Ft="[object Null]",Ct="[object Undefined]",Ae=V?V.toStringTag:void 0;function _t(e){return e==null?e===void 0?Ct:Ft:Ae&&Ae in Object(e)?je(e):Se(e)}var I=_t;function Ht(e){return e!=null&&typeof e=="object"}var P=Ht;var Jt="[object Symbol]";function Kt(e){return typeof e=="symbol"||P(e)&&I(e)==Jt}var $e=Kt;function Gt(e,t){for(var r=-1,u=e==null?0:e.length,p=Array(u);++r<u;)p[r]=t(e[r],r,e);return p}var ke=Gt;var Ut=Array.isArray,X=Ut;var qt=/\s/;function zt(e){for(var t=e.length;t--&&qt.test(e.charAt(t)););return t}var Ee=zt;var Qt=/^\s+/;function Xt(e){return e&&e.slice(0,Ee(e)+1).replace(Qt,"")}var Ie=Xt;function Zt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var K=Zt;var Pe=NaN,Yt=/^[-+]0x[0-9a-f]+$/i,er=/^0b[01]+$/i,tr=/^0o[0-7]+$/i,rr=parseInt;function or(e){if(typeof e=="number")return e;if($e(e))return Pe;if(K(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=K(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ie(e);var r=er.test(e);return r||tr.test(e)?rr(e.slice(2),r?2:8):Yt.test(e)?Pe:+e}var De=or;var Ne=1/0,ar=17976931348623157e292;function nr(e){if(!e)return e===0?e:0;if(e=De(e),e===Ne||e===-Ne){var t=e<0?-1:1;return t*ar}return e===e?e:0}var We=nr;function sr(e){var t=We(e),r=t%1;return t===t?r?t-r:t:0}var Me=sr;var ir="[object AsyncFunction]",fr="[object Function]",ur="[object GeneratorFunction]",lr="[object Proxy]";function pr(e){if(!K(e))return!1;var t=I(e);return t==fr||t==ur||t==ir||t==lr}var Le=pr;function mr(e,t,r,u){for(var p=e.length,y=r+(u?1:-1);u?y--:++y<p;)if(t(e[y],y,e))return y;return-1}var Be=mr;function dr(e){return e!==e}var Re=dr;function cr(e,t,r){for(var u=r-1,p=e.length;++u<p;)if(e[u]===t)return u;return-1}var Ve=cr;function yr(e,t,r){return t===t?Ve(e,t,r):Be(e,Re,r)}var Fe=yr;var gr=9007199254740991,xr=/^(?:0|[1-9]\d*)$/;function hr(e,t){var r=typeof e;return t=t==null?gr:t,!!t&&(r=="number"||r!="symbol"&&xr.test(e))&&e>-1&&e%1==0&&e<t}var Ce=hr;var br=9007199254740991;function vr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=br}var Z=vr;function wr(e){return e!=null&&Z(e.length)&&!Le(e)}var Y=wr;var Or=Object.prototype;function Tr(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Or;return e===r}var _e=Tr;function jr(e,t){for(var r=-1,u=Array(e);++r<e;)u[r]=t(r);return u}var He=jr;var Sr="[object Arguments]";function Ar(e){return P(e)&&I(e)==Sr}var ne=Ar;var Je=Object.prototype,$r=Je.hasOwnProperty,kr=Je.propertyIsEnumerable,Er=ne(function(){return arguments}())?ne:function(e){return P(e)&&$r.call(e,"callee")&&!kr.call(e,"callee")},Ke=Er;function Ir(){return!1}var Ge=Ir;var ze=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ue=ze&&typeof module=="object"&&module&&!module.nodeType&&module,Pr=Ue&&Ue.exports===ze,qe=Pr?Q.Buffer:void 0,Dr=qe?qe.isBuffer:void 0,Nr=Dr||Ge,Qe=Nr;var Wr="[object Arguments]",Mr="[object Array]",Lr="[object Boolean]",Br="[object Date]",Rr="[object Error]",Vr="[object Function]",Fr="[object Map]",Cr="[object Number]",_r="[object Object]",Hr="[object RegExp]",Jr="[object Set]",Kr="[object String]",Gr="[object WeakMap]",Ur="[object ArrayBuffer]",qr="[object DataView]",zr="[object Float32Array]",Qr="[object Float64Array]",Xr="[object Int8Array]",Zr="[object Int16Array]",Yr="[object Int32Array]",eo="[object Uint8Array]",to="[object Uint8ClampedArray]",ro="[object Uint16Array]",oo="[object Uint32Array]",O={};O[zr]=O[Qr]=O[Xr]=O[Zr]=O[Yr]=O[eo]=O[to]=O[ro]=O[oo]=!0;O[Wr]=O[Mr]=O[Ur]=O[Lr]=O[qr]=O[Br]=O[Rr]=O[Vr]=O[Fr]=O[Cr]=O[_r]=O[Hr]=O[Jr]=O[Kr]=O[Gr]=!1;function ao(e){return P(e)&&Z(e.length)&&!!O[I(e)]}var Xe=ao;function no(e){return function(t){return e(t)}}var Ze=no;var Ye=typeof exports=="object"&&exports&&!exports.nodeType&&exports,G=Ye&&typeof module=="object"&&module&&!module.nodeType&&module,so=G&&G.exports===Ye,se=so&&z.process,io=function(){try{var e=G&&G.require&&G.require("util").types;return e||se&&se.binding&&se.binding("util")}catch(t){}}(),ie=io;var et=ie&&ie.isTypedArray,fo=et?Ze(et):Xe,tt=fo;var uo=Object.prototype,lo=uo.hasOwnProperty;function po(e,t){var r=X(e),u=!r&&Ke(e),p=!r&&!u&&Qe(e),y=!r&&!u&&!p&&tt(e),m=r||u||p||y,o=m?He(e.length,String):[],n=o.length;for(var a in e)(t||lo.call(e,a))&&!(m&&(a=="length"||p&&(a=="offset"||a=="parent")||y&&(a=="buffer"||a=="byteLength"||a=="byteOffset")||Ce(a,n)))&&o.push(a);return o}var rt=po;function mo(e,t){return function(r){return e(t(r))}}var ot=mo;var co=ot(Object.keys,Object),at=co;var yo=Object.prototype,go=yo.hasOwnProperty;function xo(e){if(!_e(e))return at(e);var t=[];for(var r in Object(e))go.call(e,r)&&r!="constructor"&&t.push(r);return t}var nt=xo;function ho(e){return Y(e)?rt(e):nt(e)}var st=ho;var bo="[object String]";function vo(e){return typeof e=="string"||!X(e)&&P(e)&&I(e)==bo}var it=vo;function wo(e,t){return ke(t,function(r){return e[r]})}var ft=wo;function Oo(e){return e==null?[]:ft(e,st(e))}var ut=Oo;var To=Math.max;function jo(e,t,r,u){e=Y(e)?e:ut(e),r=r&&!u?Me(r):0;var p=e.length;return r<0&&(r=To(p+r,0)),it(e)?r<=p&&e.indexOf(t,r)>-1:!!p&&Fe(e,t,r)>-1}var U=jo;var So={msg:"",optsVarName:"given variable"};function fe(e,t){var m;let r=["object","objects","obj","ob","o"],u=["array","arrays","arr","aray","arr","a"],p=["any","all","everything","both","either","each","whatever","whatevs","e"],y=h(h({},So),t);if((m=y==null?void 0:y.msg)!=null&&m.length&&(y.msg=`${y.msg.trim()} `),y.optsVarName!=="given variable"&&(y.optsVarName=`variable "${y.optsVarName}"`),U(r,e.toLowerCase().trim()))return"object";if(U(u,e.toLowerCase().trim()))return"array";if(U(p,e.toLowerCase().trim()))return"any";throw new TypeError(`${y.msg}The ${y.optsVarName} was customised to an unrecognised value: ${e}. Please check it against the API documentation.`)}var S=H(lt(),1);var yt=H(pe(),1);var mt=H(pe(),1);var Hn=(0,mt.default)();function w(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 M(e){return typeof e=="string"}function L(e=[],t=[]){return!e||!Array.isArray(e)||!e.length?[]:!t||!Array.isArray(t)||!t.length?e:e.filter(r=>!t.includes(r))}function dt(e,t){return w(e)&&M(t)&&t in e}function ct(e=[],t=[]){return!e||!t?[]:Array.from(new Set(Array.from(e).filter(r=>new Set(t).has(r))))}function me(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 de=(0,yt.default)();function N(e,t){let r={now:!1};function u(p,y,m,o){let n=de(p),a,f=h({depth:-1,path:""},m);if(f.depth+=1,Array.isArray(n))for(let s=0,l=n.length;s<l&&!o.now;s++){let T=f.path?`${f.path}.${s}`:`${s}`;n[s]!==void 0?(f.parent=de(n),f.parentType="array",f.parentKey=me(T),a=u(y(n[s],void 0,E(h({},f),{path:T}),o),y,E(h({},f),{path:T}),o),Number.isNaN(a)&&s<n.length?(n.splice(s,1),s-=1):n[s]=a):n.splice(s,1)}else if(w(n))for(let s in n){if(o.now&&s!=null)break;let l=f.path?`${f.path}.${s}`:s;f.depth===0&&s!=null&&(f.topmostKey=s),f.parent=de(n),f.parentType="object",f.parentKey=me(l),a=u(y(s,n[s],E(h({},f),{path:l}),o),y,E(h({},f),{path:l}),o),Number.isNaN(a)?delete n[s]:n[s]=a}return n}return u(e,t,{},r)}function ce(e){return typeof e!="string"?e:e.length?[e]:[]}var te=H(xt(),1);function ye(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ge=new Map,ht=(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})},ko=(e,t)=>{t=h({caseSensitive:!1},t);let r=e+JSON.stringify(t);if(ge.has(r))return ge.get(r);let u=e[0]==="!";u&&(e=e.slice(1)),e=ye(e).replace(/\\\*/g,"[\\s\\S]*");let p=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return p.negated=u,ge.set(r,p),p},Eo=(e,t,r,u)=>{if(e=ht(e,"inputs"),t=ht(t,"patterns"),t.length===0)return[];t=t.map(m=>ko(m,r));let{allPatterns:p}=r||{},y=[];for(let m of e){let o,n=[...t].fill(!1);for(let[a,f]of t.entries())if(f.test(m)&&(n[a]=!0,o=!f.negated,!o))break;if(!(o===!1||o===void 0&&t.some(a=>!a.negated)||p&&n.some((a,f)=>!a&&!t[f].negated))&&(y.push(m),u))break}return y};function B(e,t,r){return Eo(e,t,r,!0).length>0}var Io={ignoreKeys:[],ignorePaths:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"};function Po(e,t,r){function u(a){return a!=null}function p(a,f){return typeof f=="string"&&(f=ce(f)),Array.from(a).filter(s=>!f.some(l=>B(s,l,{caseSensitive:!0})))}let y=Object.prototype.hasOwnProperty,m=["any","anything","every","everything","all","whatever","whatevs"];if(!u(e))throw new Error("check-types-mini: [THROW_ID_01] First argument is missing!");let o=h(h({},Io),r);if(typeof o.ignoreKeys=="string"&&(o.ignoreKeys=[o.ignoreKeys]),typeof o.ignorePaths=="string"&&(o.ignorePaths=[o.ignorePaths]),typeof o.acceptArraysIgnore=="string"&&(o.acceptArraysIgnore=[o.acceptArraysIgnore]),o.msg=`${o.msg}`.trim(),o.msg[o.msg.length-1]===":"&&(o.msg=o.msg.slice(0,o.msg.length-1).trim()),w(o.schema))Object.keys(o.schema).forEach(a=>{if(w(o.schema[a])){let f={};N(o.schema[a],(s,l,T)=>{let b=l!==void 0?l:s;return!Array.isArray(b)&&!w(b)&&(f[`${a}.${T.path}`]=b),b}),delete o.schema[a],o.schema=h(h({},o.schema),f)}}),Object.keys(o.schema).forEach(a=>{Array.isArray(o.schema[a])||(o.schema[a]=[o.schema[a]]),o.schema[a]=o.schema[a].map(f=>`${f}`.toLowerCase().trim())});else if(o.schema!=null)throw new Error(`check-types-mini: opts.schema was customised to ${JSON.stringify(o.schema,null,0)} which is not object but ${typeof o.schema}`);if(u(t)||(t={}),o.enforceStrictKeyset)if(u(o.schema)&&Object.keys(o.schema).length){if(t&&p(L(Object.keys(e),Object.keys(t).concat(Object.keys(o.schema))),o.ignoreKeys).length){let a=L(Object.keys(e),Object.keys(t).concat(Object.keys(o.schema)));throw new TypeError(`${o.msg}: ${o.optsVarName}.enforceStrictKeyset is on and the following key${a.length>1?"s":""} ${a.length>1?"are":"is"} not covered by schema and/or reference objects: ${a.join(", ")}`)}}else if(w(t)&&Object.keys(t).length){if(p(L(Object.keys(e),Object.keys(t)),o.ignoreKeys).length!==0){let a=L(Object.keys(e),Object.keys(t));throw new TypeError(`${o.msg}: The input object has key${a.length>1?"s":""} which ${a.length>1?"are":"is"} not covered by the reference object: ${a.join(", ")}`)}else if(p(L(Object.keys(t),Object.keys(e)),o.ignoreKeys).length!==0){let a=L(Object.keys(t),Object.keys(e));throw new TypeError(`${o.msg}: The reference object has key${a.length>1?"s":""} which ${a.length>1?"are":"is"} not present in the input object: ${a.join(", ")}`)}}else throw new TypeError(`${o.msg}: Both ${o.optsVarName}.schema and reference objects are missing! We don't have anything to match the keys as you requested via resolvedOpts.enforceStrictKeyset!`);let n=[];N(e,(a,f,s)=>{let l=f,T=a;if(s.parentType==="array"&&(T=void 0,l=a),Array.isArray(n)&&n.length&&n.some(i=>s.path.startsWith(i))||T&&o.ignoreKeys.some(i=>T&&B(T,i))||o.ignorePaths.some(i=>B(s.path,i)))return l;let b=!(!w(l)&&!Array.isArray(l)&&Array.isArray(s.parent)),A=!1;w(o.schema)&&y.call(o.schema,s.path)&&(A=!0);let c=!1;if(w(t)&&te.default.has(t,s.path)&&(c=!0),o.enforceStrictKeyset&&b&&!A&&!c)throw new TypeError(`${o.msg}: ${o.optsVarName}.${s.path} is neither covered by reference object (second input argument), nor ${o.optsVarName}.schema! To stop this error, turn off ${o.optsVarName}.enforceStrictKeyset or provide some type reference (2nd argument or ${o.optsVarName}.schema). Debug info: obj = ${JSON.stringify(e,null,4)} ref = ${JSON.stringify(t,null,4)} innerObj = ${JSON.stringify(s,null,4)} resolvedOpts = ${JSON.stringify(o,null,4)} current = ${JSON.stringify(l,null,4)} `);if(A){let i=ce(o.schema[s.path]).map(d=>`${d}`.toLowerCase());if(te.default.set(o.schema,s.path,i),ct(i,m).length)n.push(s.path);else if(l!==!0&&l!==!1&&!i.includes((0,S.default)(l).toLowerCase())||(l===!0||l===!1)&&!i.includes(String(l))&&!i.includes("boolean"))if(Array.isArray(l)&&o.acceptArrays){for(let d=0,x=l.length;d<x;d++)if(!i.includes((0,S.default)(l[d]).toLowerCase()))throw new TypeError(`${o.msg}: ${o.optsVarName}.${s.path}.${d}, the ${d}th element (equal to ${JSON.stringify(l[d],null,0)}) is of a type ${(0,S.default)(l[d]).toLowerCase()}, but only the following are allowed by the ${o.optsVarName}.schema: ${i.join(", ")}`)}else throw new TypeError(`${o.msg}: ${o.optsVarName}.${s.path} was customised to ${(0,S.default)(l)!=="string"?'"':""}${JSON.stringify(l,null,0)}${(0,S.default)(l)!=="string"?'"':""} (type: ${(0,S.default)(l).toLowerCase()}) which is not among the allowed types in schema (which is equal to ${JSON.stringify(i,null,0)})`)}else if(t&&w(t)&&c){let i=te.default.get(t,s.path);if(o.acceptArrays&&Array.isArray(l)&&!o.acceptArraysIgnore.includes(a)){if(!l.every(d=>(0,S.default)(d).toLowerCase()===(0,S.default)(t[a]).toLowerCase()))throw new TypeError(`${o.msg}: ${o.optsVarName}.${s.path} was customised to be array, but not all of its elements are ${(0,S.default)(t[a]).toLowerCase()}-type`)}else if((0,S.default)(l)!==(0,S.default)(i))throw new TypeError(`${o.msg}: ${o.optsVarName}.${s.path} was customised to ${(0,S.default)(l).toLowerCase()==="string"?"":'"'}${JSON.stringify(l,null,0)}${(0,S.default)(l).toLowerCase()==="string"?"":'"'} which is not ${(0,S.default)(i).toLowerCase()} but ${(0,S.default)(l).toLowerCase()}`)}return l})}function re(e,t,r){Po(e,t,r)}var R=H(bt(),1);function k(e){if(typeof e=="string")return!e.trim();if(!["object","string"].includes(typeof e)||!e)return!1;let t=!0;return e=N(e,(r,u,p,y)=>{let m=u!==void 0?u:r;return typeof m=="string"&&m.trim()&&(t=!1,y.now=!0),m}),t}function Do(e){return w(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}var No={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function oe(e,t,r){let u,p,y,m=0,o=h(h({},No),r);if(o.hungryForWhitespace&&o.matchStrictly&&w(e)&&k(e)&&w(t)&&!Object.keys(t).length)return!0;if((!o.hungryForWhitespace||o.hungryForWhitespace&&!k(e)&&k(t))&&w(e)&&Object.keys(e).length!==0&&w(t)&&Object.keys(t).length===0||(0,R.default)(e)!==(0,R.default)(t)&&(!o.hungryForWhitespace||o.hungryForWhitespace&&!k(e)))return!1;if(typeof e=="string"&&typeof t=="string")return o.hungryForWhitespace&&k(e)&&k(t)?!0:o.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:o.useWildcards?B(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(o.hungryForWhitespace&&k(t)&&(!o.matchStrictly||o.matchStrictly&&e.length===t.length))return!0;if(!o.hungryForWhitespace&&t.length>e.length||o.matchStrictly&&t.length!==e.length)return o.verboseWhenMismatches?`The length of a given array, ${JSON.stringify(t,null,4)} is ${t.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`:!1;if(t.length===0)return e.length===0?!0:o.verboseWhenMismatches?`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`:!1;for(let n=0,a=t.length;n<a;n++){y=!1;for(let f=m,s=e.length;f<s;f++)if(m+=1,oe(e[f],t[n],o)===!0){y=!0;break}if(!y)return o.verboseWhenMismatches?`The given array ${JSON.stringify(t,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`:!1}}else if(w(e)&&w(t)){if(u=new Set(Object.keys(t)),p=new Set(Object.keys(e)),o.matchStrictly&&u.size!==p.size){if(!o.verboseWhenMismatches)return!1;let n=new Set([...u].filter(l=>!p.has(l))),a=n.size?` First object has unique keys: ${JSON.stringify(n,null,4)}.`:"",f=new Set([...p].filter(l=>!u.has(l))),s=f.size?` Second object has unique keys: ${JSON.stringify(f,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${a}${s}`}for(let n of u){if(!dt(e,n))return!o.useWildcards||o.useWildcards&&!n.includes("*")?o.verboseWhenMismatches?`The given object has key "${n}" which the other-one does not have.`:!1:Object.keys(e).some(a=>B(a,n,{caseSensitive:!0}))?!0:o.verboseWhenMismatches?`The given object has key "${n}" which the other-one does not have.`:!1;if(e[n]!=null&&(0,R.default)(e[n])!==(0,R.default)(t[n])){if(!(k(e[n])&&k(t[n])&&o.hungryForWhitespace))return o.verboseWhenMismatches?`The given key ${n} is of a different type on both objects. On the first-one, it's ${(0,R.default)(t[n])}, on the second-one, it's ${(0,R.default)(e[n])}`:!1}else if(oe(e[n],t[n],o)!==!0)return o.verboseWhenMismatches?`The given piece ${JSON.stringify(t[n],null,4)} and ${JSON.stringify(e[n],null,4)} don't match.`:!1}}else return o.hungryForWhitespace&&k(e)&&k(t)&&(!o.matchStrictly||o.matchStrictly&&Do(t))?!0:e===t;return!0}var vt="9.0.29";var Mo=vt;function $(e){return e!=null}function ae(e,t){return typeof e!=typeof t?!1:!!oe(e,t,{matchStrictly:!0,useWildcards:!0})}function C(e,t){let r=h({},t),u={count:0,gatherPath:[],finding:null},p=[],y=!1,m=!1;$(r.key)&&r.val===void 0&&(y=!0),!$(r.key)&&r.val!==void 0&&(m=!0);let o=e;return r.mode==="arrayFirstOnly"&&Array.isArray(o)&&o.length&&(o=[o[0]]),o=N(o,(n,a,f)=>{let s;if(u.count+=1,u.gatherPath.length=f.depth,u.gatherPath.push(u.count),r.mode==="get")u.count===r.index&&(f.parentType==="object"?(u.finding={},u.finding[n]=a):u.finding=n);else if(r.mode==="find"||r.mode==="del")if((r.only==="any"||r.only==="array"&&f.parentType==="array"||r.only==="object"&&f.parentType!=="array")&&(y&&ae(n,r.key)||m&&ae(a,r.val)||!y&&!m&&ae(n,r.key)&&ae(a,r.val)))if(r.mode==="find")s={index:u.count,key:n,val:a,path:[...u.gatherPath]},p.push(s);else return NaN;else return f.parentType==="object"?a:n;return r.mode==="set"&&u.count===r.index?r.val:r.mode==="drop"&&u.count===r.index?NaN:r.mode==="arrayFirstOnly"?f.parentType==="object"&&Array.isArray(a)?[a[0]]:$(n)&&Array.isArray(n)?[n[0]]:f.parentType==="object"?a:n:f.parentType==="object"?a:n}),r.mode==="get"?u.finding:r.mode==="find"?p:o}function Lo(e,t){if(!$(e))throw new Error("ast-monkey/main.js/find(): [THROW_ID_02] Please provide the input");if(!w(t)||t.key===void 0&&t.val===void 0)throw new Error("ast-monkey/main.js/find(): [THROW_ID_03] Please provide resolvedOpts.key or resolvedOpts.val");let r=h({},t);return re(r,null,{schema:{key:["null","string"],val:"any",only:["undefined","null","string"]},msg:"ast-monkey/get(): [THROW_ID_04*]"}),M(r.only)&&r.only.length?r.only=fe(r.only,{optsVarName:"resolvedOpts.only",msg:"ast-monkey/find(): [THROW_ID_05*]"}):r.only="any",C(e,E(h({},r),{mode:"find"}))}function Bo(e,t){if(!$(e))throw new Error("ast-monkey/main.js/get(): [THROW_ID_06] Please provide the input");if(!w(t))throw new Error("ast-monkey/main.js/get(): [THROW_ID_07] Please provide the resolvedOpts");if(!$(t.index))throw new Error("ast-monkey/main.js/get(): [THROW_ID_08] Please provide resolvedOpts.index");let r=h({},t);if(M(r.index)&&/^\d+$/.test(r.index))r.index=+r.index;else if(!Number.isInteger(r.index))throw new Error(`ast-monkey/main.js/get(): [THROW_ID_11] resolvedOpts.index must be a natural number. It was given as: ${r.index} (type ${typeof r.index})`);return C(e,E(h({},r),{mode:"get"}))}function Ro(e,t){if(!$(e))throw new Error("ast-monkey/main.js/set(): [THROW_ID_12] Please provide the input");if(!w(t))throw new Error("ast-monkey/main.js/set(): [THROW_ID_13] Please provide the input");if(!$(t.key)&&t.val===void 0)throw new Error("ast-monkey/main.js/set(): [THROW_ID_14] Please provide resolvedOpts.val");if(!$(t.index))throw new Error("ast-monkey/main.js/set(): [THROW_ID_15] Please provide resolvedOpts.index");let r=h({},t);if(M(r.index)&&/^\d+$/.test(r.index))r.index=+r.index;else if(!Number.isInteger(r.index))throw new Error(`ast-monkey/main.js/set(): [THROW_ID_17] resolvedOpts.index must be a natural number. It was given as: ${r.index}`);return $(r.key)&&r.val===void 0&&(r.val=r.key),re(r,null,{schema:{key:[null,"string"],val:"any",index:"number"},msg:"ast-monkey/set(): [THROW_ID_18*]"}),C(e,E(h({},r),{mode:"set"}))}function Vo(e,t){if(!$(e))throw new Error("ast-monkey/main.js/drop(): [THROW_ID_19] Please provide the input");if(!w(t))throw new Error("ast-monkey/main.js/drop(): [THROW_ID_20] Please provide the input");if(!$(t.index))throw new Error("ast-monkey/main.js/drop(): [THROW_ID_21] Please provide resolvedOpts.index");let r=h({},t);if(M(r.index)&&/^\d+$/.test(r.index))r.index=+r.index;else if(!Number.isInteger(r.index))throw new Error(`ast-monkey/main.js/drop(): [THROW_ID_23] resolvedOpts.index must be a natural number. It was given as: ${r.index}`);return C(e,E(h({},r),{mode:"drop"}))}function Fo(e,t){if(!$(e))throw new Error("ast-monkey/main.js/del(): [THROW_ID_26] Please provide the input");if(!w(t))throw new Error("ast-monkey/main.js/del(): [THROW_ID_27] Please provide the resolvedOpts object");if(!$(t.key)&&t.val===void 0)throw new Error("ast-monkey/main.js/del(): [THROW_ID_28] Please provide resolvedOpts.key or resolvedOpts.val");let r=h({},t);return re(r,null,{schema:{key:[null,"string"],val:"any",only:["undefined","null","string"]},msg:"ast-monkey/drop(): [THROW_ID_29*]"}),M(r.only)&&r.only.length?r.only=fe(r.only,{msg:"ast-monkey/del(): [THROW_ID_30*]",optsVarName:"resolvedOpts.only"}):r.only="any",C(e,E(h({},r),{mode:"del"}))}function Co(e){if(!$(e))throw new Error("ast-monkey/main.js/arrayFirstOnly(): [THROW_ID_31] Please provide the input");return C(e,{mode:"arrayFirstOnly"})}return Et(_o);})(); /** * @name util-array-object-or-both * @fileoverview Validate and normalise user choice: array, object or both? * @version 5.0.14 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/util-array-object-or-both/} */ /** * @name codsen-utils * @fileoverview Various utility functions * @version 1.6.7 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/codsen-utils/} */ /** * @name ast-monkey-util * @fileoverview Utility library of AST helper functions * @version 3.0.10 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/ast-monkey-util/} */ /** * @name ast-monkey-traverse * @fileoverview Utility library to traverse AST * @version 4.0.19 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/ast-monkey-traverse/} */ /** * @name arrayiffy-if-string * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else. * @version 5.0.10 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/arrayiffy-if-string/} */ /** * @name check-types-mini * @fileoverview Validate options object * @version 8.0.22 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/check-types-mini/} */ /** * @name ast-contains-only-empty-space * @fileoverview Does AST contain only empty space? * @version 4.0.19 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/ast-contains-only-empty-space/} */ /** * @name ast-compare * @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof * @version 4.0.30 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/ast-compare/} */ /*! Bundled license information: lodash-es/lodash.js: (** * @license * Lodash (Custom Build) <https://lodash.com/> * Build: `lodash modularize exports="es" -o ./` * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) */