UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

2 lines (1 loc) • 35.2 kB
import{a as At}from"./chunk-75VPUOC5.js";import{a as vt}from"./chunk-HZA6IAA4.js";import{a as D,c as F,g as y}from"./chunk-VPRTJUIN.js";var st=F(N=>{"use strict";y();Object.defineProperty(N,"__esModule",{value:!0});N.LRUCache=void 0;var T=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,tt=new Set,k=typeof process=="object"&&process?process:{},et=(e,t,i,s)=>{typeof k.emitWarning=="function"?k.emitWarning(e,t,i,s):console.error(`[${i}] ${t}: ${e}`)},j=globalThis.AbortController,Q=globalThis.AbortSignal;if(typeof j>"u"){Q=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,n){this._onabort.push(n)}},j=class{constructor(){t()}signal=new Q;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let n of this.signal._onabort)n(s);this.signal.onabort?.(s)}}};let e=k.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,et("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var Et=e=>!tt.has(e),_=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),it=e=>_(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?z:null:null,z=class extends Array{constructor(t){super(t),this.fill(0)}},M=class e{heap;length;static#n=!1;static create(t){let i=it(t);if(!i)return[];e.#n=!0;let s=new e(t,i);return e.#n=!1,s}constructor(t,i){if(!e.#n)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},q=class e{#n;#l;#e;#g;#x;#T;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#w;#r;#s;#t;#f;#p;#c;#h;#b;#a;#S;#$;#d;#y;#_;#u;static unsafeExposeInternals(t){return{starts:t.#$,ttls:t.#d,sizes:t.#S,keyMap:t.#r,keyList:t.#s,valList:t.#t,next:t.#f,prev:t.#p,get head(){return t.#c},get tail(){return t.#h},free:t.#b,isBackgroundFetch:i=>t.#i(i),backgroundFetch:(i,s,n,r)=>t.#W(i,s,n,r),moveToTail:i=>t.#F(i),indexes:i=>t.#v(i),rindexes:i=>t.#A(i),isStale:i=>t.#m(i)}}get max(){return this.#n}get maxSize(){return this.#l}get calculatedSize(){return this.#w}get size(){return this.#o}get fetchMethod(){return this.#x}get memoMethod(){return this.#T}get dispose(){return this.#e}get disposeAfter(){return this.#g}constructor(t){let{max:i=0,ttl:s,ttlResolution:n=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:h,dispose:f,disposeAfter:w,noDisposeOnSet:p,noUpdateTTL:m,maxSize:d=0,maxEntrySize:A=0,sizeCalculation:l,fetchMethod:S,memoMethod:c,noDeleteOnFetchRejection:$,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:v,ignoreFetchAbort:W}=t;if(i!==0&&!_(i))throw new TypeError("max option must be a nonnegative integer");let O=i?it(i):Array;if(!O)throw new Error("invalid max value: "+i);if(this.#n=i,this.#l=d,this.maxEntrySize=A||this.#l,this.sizeCalculation=l,this.sizeCalculation){if(!this.#l&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(c!==void 0&&typeof c!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#T=c,S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#x=S,this.#_=!!S,this.#r=new Map,this.#s=new Array(i).fill(void 0),this.#t=new Array(i).fill(void 0),this.#f=new O(i),this.#p=new O(i),this.#c=0,this.#h=0,this.#b=M.create(i),this.#o=0,this.#w=0,typeof f=="function"&&(this.#e=f),typeof w=="function"?(this.#g=w,this.#a=[]):(this.#g=void 0,this.#a=void 0),this.#y=!!this.#e,this.#u=!!this.#g,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!$,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!W,this.maxEntrySize!==0){if(this.#l!==0&&!_(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!_(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=_(n)||n===0?n:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!_(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(this.#n===0&&this.ttl===0&&this.#l===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#n&&!this.#l){let P="LRU_CACHE_UNBOUNDED";Et(P)&&(tt.add(P),et("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",P,e))}}getRemainingTTL(t){return this.#r.has(t)?1/0:0}#D(){let t=new z(this.#n),i=new z(this.#n);this.#d=t,this.#$=i,this.#L=(r,o,a=T.now())=>{if(i[r]=o!==0?a:0,t[r]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{this.#m(r)&&this.#E(this.#s[r],"expire")},o+1);h.unref&&h.unref()}},this.#R=r=>{i[r]=t[r]!==0?T.now():0},this.#O=(r,o)=>{if(t[o]){let a=t[o],h=i[o];if(!a||!h)return;r.ttl=a,r.start=h,r.now=s||n();let f=r.now-h;r.remainingTTL=a-f}};let s=0,n=()=>{let r=T.now();if(this.ttlResolution>0){s=r;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return r};this.getRemainingTTL=r=>{let o=this.#r.get(r);if(o===void 0)return 0;let a=t[o],h=i[o];if(!a||!h)return 1/0;let f=(s||n())-h;return a-f},this.#m=r=>{let o=i[r],a=t[r];return!!a&&!!o&&(s||n())-o>a}}#R=()=>{};#O=()=>{};#L=()=>{};#m=()=>!1;#H(){let t=new z(this.#n);this.#w=0,this.#S=t,this.#C=i=>{this.#w-=t[i],t[i]=0},this.#I=(i,s,n,r)=>{if(this.#i(s))return 0;if(!_(n))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(n=r(s,i),!_(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#z=(i,s,n)=>{if(t[i]=s,this.#l){let r=this.#l-t[i];for(;this.#w>r;)this.#U(!0)}this.#w+=t[i],n&&(n.entrySize=s,n.totalCalculatedSize=this.#w)}}#C=t=>{};#z=(t,i,s)=>{};#I=(t,i,s,n)=>{if(s||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#v({allowStale:t=this.allowStale}={}){if(this.#o)for(let i=this.#h;!(!this.#P(i)||((t||!this.#m(i))&&(yield i),i===this.#c));)i=this.#p[i]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let i=this.#c;!(!this.#P(i)||((t||!this.#m(i))&&(yield i),i===this.#h));)i=this.#f[i]}#P(t){return t!==void 0&&this.#r.get(this.#s[t])===t}*entries(){for(let t of this.#v())this.#t[t]!==void 0&&this.#s[t]!==void 0&&!this.#i(this.#t[t])&&(yield[this.#s[t],this.#t[t]])}*rentries(){for(let t of this.#A())this.#t[t]!==void 0&&this.#s[t]!==void 0&&!this.#i(this.#t[t])&&(yield[this.#s[t],this.#t[t]])}*keys(){for(let t of this.#v()){let i=this.#s[t];i!==void 0&&!this.#i(this.#t[t])&&(yield i)}}*rkeys(){for(let t of this.#A()){let i=this.#s[t];i!==void 0&&!this.#i(this.#t[t])&&(yield i)}}*values(){for(let t of this.#v())this.#t[t]!==void 0&&!this.#i(this.#t[t])&&(yield this.#t[t])}*rvalues(){for(let t of this.#A())this.#t[t]!==void 0&&!this.#i(this.#t[t])&&(yield this.#t[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,i={}){for(let s of this.#v()){let n=this.#t[s],r=this.#i(n)?n.__staleWhileFetching:n;if(r!==void 0&&t(r,this.#s[s],this))return this.get(this.#s[s],i)}}forEach(t,i=this){for(let s of this.#v()){let n=this.#t[s],r=this.#i(n)?n.__staleWhileFetching:n;r!==void 0&&t.call(i,r,this.#s[s],this)}}rforEach(t,i=this){for(let s of this.#A()){let n=this.#t[s],r=this.#i(n)?n.__staleWhileFetching:n;r!==void 0&&t.call(i,r,this.#s[s],this)}}purgeStale(){let t=!1;for(let i of this.#A({allowStale:!0}))this.#m(i)&&(this.#E(this.#s[i],"expire"),t=!0);return t}info(t){let i=this.#r.get(t);if(i===void 0)return;let s=this.#t[i],n=this.#i(s)?s.__staleWhileFetching:s;if(n===void 0)return;let r={value:n};if(this.#d&&this.#$){let o=this.#d[i],a=this.#$[i];if(o&&a){let h=o-(T.now()-a);r.ttl=h,r.start=Date.now()}}return this.#S&&(r.size=this.#S[i]),r}dump(){let t=[];for(let i of this.#v({allowStale:!0})){let s=this.#s[i],n=this.#t[i],r=this.#i(n)?n.__staleWhileFetching:n;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#d&&this.#$){o.ttl=this.#d[i];let a=T.now()-this.#$[i];o.start=Math.floor(Date.now()-a)}this.#S&&(o.size=this.#S[i]),t.unshift([s,o])}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let n=Date.now()-s.start;s.start=T.now()-n}this.set(i,s.value,s)}}set(t,i,s={}){if(i===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:f=this.noUpdateTTL}=s,w=this.#I(t,i,s.size||0,a);if(this.maxEntrySize&&w>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.#E(t,"set"),this;let p=this.#o===0?void 0:this.#r.get(t);if(p===void 0)p=this.#o===0?this.#h:this.#b.length!==0?this.#b.pop():this.#o===this.#n?this.#U(!1):this.#o,this.#s[p]=t,this.#t[p]=i,this.#r.set(t,p),this.#f[this.#h]=p,this.#p[p]=this.#h,this.#h=p,this.#o++,this.#z(p,w,h),h&&(h.set="add"),f=!1;else{this.#F(p);let m=this.#t[p];if(i!==m){if(this.#_&&this.#i(m)){m.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=m;d!==void 0&&!o&&(this.#y&&this.#e?.(d,t,"set"),this.#u&&this.#a?.push([d,t,"set"]))}else o||(this.#y&&this.#e?.(m,t,"set"),this.#u&&this.#a?.push([m,t,"set"]));if(this.#C(p),this.#z(p,w,h),this.#t[p]=i,h){h.set="replace";let d=m&&this.#i(m)?m.__staleWhileFetching:m;d!==void 0&&(h.oldValue=d)}}else h&&(h.set="update")}if(n!==0&&!this.#d&&this.#D(),this.#d&&(f||this.#L(p,n,r),h&&this.#O(h,p)),!o&&this.#u&&this.#a){let m=this.#a,d;for(;d=m?.shift();)this.#g?.(...d)}return this}pop(){try{for(;this.#o;){let t=this.#t[this.#c];if(this.#U(!0),this.#i(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#u&&this.#a){let t=this.#a,i;for(;i=t?.shift();)this.#g?.(...i)}}}#U(t){let i=this.#c,s=this.#s[i],n=this.#t[i];return this.#_&&this.#i(n)?n.__abortController.abort(new Error("evicted")):(this.#y||this.#u)&&(this.#y&&this.#e?.(n,s,"evict"),this.#u&&this.#a?.push([n,s,"evict"])),this.#C(i),t&&(this.#s[i]=void 0,this.#t[i]=void 0,this.#b.push(i)),this.#o===1?(this.#c=this.#h=0,this.#b.length=0):this.#c=this.#f[i],this.#r.delete(s),this.#o--,i}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:n}=i,r=this.#r.get(t);if(r!==void 0){let o=this.#t[r];if(this.#i(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#m(r))n&&(n.has="stale",this.#O(n,r));else return s&&this.#R(r),n&&(n.has="hit",this.#O(n,r)),!0}else n&&(n.has="miss");return!1}peek(t,i={}){let{allowStale:s=this.allowStale}=i,n=this.#r.get(t);if(n===void 0||!s&&this.#m(n))return;let r=this.#t[n];return this.#i(r)?r.__staleWhileFetching:r}#W(t,i,s,n){let r=i===void 0?void 0:this.#t[i];if(this.#i(r))return r;let o=new j,{signal:a}=s;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let h={signal:o.signal,options:s,context:n},f=(l,S=!1)=>{let{aborted:c}=o.signal,$=s.ignoreFetchAbort&&l!==void 0;if(s.status&&(c&&!S?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,$&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),c&&!$&&!S)return p(o.signal.reason);let E=d;return this.#t[i]===d&&(l===void 0?E.__staleWhileFetching?this.#t[i]=E.__staleWhileFetching:this.#E(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,l,h.options))),l},w=l=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=l),p(l)),p=l=>{let{aborted:S}=o.signal,c=S&&s.allowStaleOnFetchAbort,$=c||s.allowStaleOnFetchRejection,E=$||s.noDeleteOnFetchRejection,b=d;if(this.#t[i]===d&&(!E||b.__staleWhileFetching===void 0?this.#E(t,"fetch"):c||(this.#t[i]=b.__staleWhileFetching)),$)return s.status&&b.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw l},m=(l,S)=>{let c=this.#x?.(t,r,h);c&&c instanceof Promise&&c.then($=>l($===void 0?void 0:$),S),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(l(void 0),s.allowStaleOnFetchAbort&&(l=$=>f($,!0)))})};s.status&&(s.status.fetchDispatched=!0);let d=new Promise(m).then(f,w),A=Object.assign(d,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return i===void 0?(this.set(t,A,{...h.options,status:void 0}),i=this.#r.get(t)):this.#t[i]=A,A}#i(t){if(!this.#_)return!1;let i=t;return!!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof j}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:A=this.allowStaleOnFetchAbort,context:l,forceRefresh:S=!1,status:c,signal:$}=i;if(!this.#_)return c&&(c.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:c});let E={allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:a,size:h,sizeCalculation:f,noUpdateTTL:w,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:A,ignoreFetchAbort:d,status:c,signal:$},b=this.#r.get(t);if(b===void 0){c&&(c.fetch="miss");let v=this.#W(t,b,E,l);return v.__returned=v}else{let v=this.#t[b];if(this.#i(v)){let Z=s&&v.__staleWhileFetching!==void 0;return c&&(c.fetch="inflight",Z&&(c.returnedStale=!0)),Z?v.__staleWhileFetching:v.__returned=v}let W=this.#m(b);if(!S&&!W)return c&&(c.fetch="hit"),this.#F(b),n&&this.#R(b),c&&this.#O(c,b),v;let O=this.#W(t,b,E,l),G=O.__staleWhileFetching!==void 0&&s;return c&&(c.fetch=W?"stale":"refresh",G&&W&&(c.returnedStale=!0)),G?O.__staleWhileFetching:O.__returned=O}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=this.#T;if(!s)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:r,...o}=i,a=this.get(t,o);if(!r&&a!==void 0)return a;let h=s(t,a,{options:o,context:n});return this.set(t,h,o),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=i,a=this.#r.get(t);if(a!==void 0){let h=this.#t[a],f=this.#i(h);return o&&this.#O(o,a),this.#m(a)?(o&&(o.get="stale"),f?(o&&s&&h.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?h.__staleWhileFetching:void 0):(r||this.#E(t,"expire"),o&&s&&(o.returnedStale=!0),s?h:void 0)):(o&&(o.get="hit"),f?h.__staleWhileFetching:(this.#F(a),n&&this.#R(a),h))}else o&&(o.get="miss")}#j(t,i){this.#p[i]=t,this.#f[t]=i}#F(t){t!==this.#h&&(t===this.#c?this.#c=this.#f[t]:this.#j(this.#p[t],this.#f[t]),this.#j(this.#h,t),this.#h=t)}delete(t){return this.#E(t,"delete")}#E(t,i){let s=!1;if(this.#o!==0){let n=this.#r.get(t);if(n!==void 0)if(s=!0,this.#o===1)this.#N(i);else{this.#C(n);let r=this.#t[n];if(this.#i(r)?r.__abortController.abort(new Error("deleted")):(this.#y||this.#u)&&(this.#y&&this.#e?.(r,t,i),this.#u&&this.#a?.push([r,t,i])),this.#r.delete(t),this.#s[n]=void 0,this.#t[n]=void 0,n===this.#h)this.#h=this.#p[n];else if(n===this.#c)this.#c=this.#f[n];else{let o=this.#p[n];this.#f[o]=this.#f[n];let a=this.#f[n];this.#p[a]=this.#p[n]}this.#o--,this.#b.push(n)}}if(this.#u&&this.#a?.length){let n=this.#a,r;for(;r=n?.shift();)this.#g?.(...r)}return s}clear(){return this.#N("delete")}#N(t){for(let i of this.#A({allowStale:!0})){let s=this.#t[i];if(this.#i(s))s.__abortController.abort(new Error("deleted"));else{let n=this.#s[i];this.#y&&this.#e?.(s,n,t),this.#u&&this.#a?.push([s,n,t])}}if(this.#r.clear(),this.#t.fill(void 0),this.#s.fill(void 0),this.#d&&this.#$&&(this.#d.fill(0),this.#$.fill(0)),this.#S&&this.#S.fill(0),this.#c=0,this.#h=0,this.#b.length=0,this.#w=0,this.#o=0,this.#u&&this.#a){let i=this.#a,s;for(;s=i?.shift();)this.#g?.(...s)}}};N.LRUCache=q});var ot=F((ee,rt)=>{"use strict";y();var u=(...e)=>e.every(t=>t)?e.join(""):"",g=e=>e?encodeURIComponent(e):"",nt=e=>e.toLowerCase().replace(/^\W+|\/|\W+$/g,"").replace(/\W+/g,"-"),Ot={sshtemplate:({domain:e,user:t,project:i,committish:s})=>`git@${e}:${t}/${i}.git${u("#",s)}`,sshurltemplate:({domain:e,user:t,project:i,committish:s})=>`git+ssh://git@${e}/${t}/${i}.git${u("#",s)}`,edittemplate:({domain:e,user:t,project:i,committish:s,editpath:n,path:r})=>`https://${e}/${t}/${i}${u("/",n,"/",g(s||"HEAD"),"/",r)}`,browsetemplate:({domain:e,user:t,project:i,committish:s,treepath:n})=>`https://${e}/${t}/${i}${u("/",n,"/",g(s))}`,browsetreetemplate:({domain:e,user:t,project:i,committish:s,treepath:n,path:r,fragment:o,hashformat:a})=>`https://${e}/${t}/${i}/${n}/${g(s||"HEAD")}/${r}${u("#",a(o||""))}`,browseblobtemplate:({domain:e,user:t,project:i,committish:s,blobpath:n,path:r,fragment:o,hashformat:a})=>`https://${e}/${t}/${i}/${n}/${g(s||"HEAD")}/${r}${u("#",a(o||""))}`,docstemplate:({domain:e,user:t,project:i,treepath:s,committish:n})=>`https://${e}/${t}/${i}${u("/",s,"/",g(n))}#readme`,httpstemplate:({auth:e,domain:t,user:i,project:s,committish:n})=>`git+https://${u(e,"@")}${t}/${i}/${s}.git${u("#",n)}`,filetemplate:({domain:e,user:t,project:i,committish:s,path:n})=>`https://${e}/${t}/${i}/raw/${g(s||"HEAD")}/${n}`,shortcuttemplate:({type:e,user:t,project:i,committish:s})=>`${e}:${t}/${i}${u("#",s)}`,pathtemplate:({user:e,project:t,committish:i})=>`${e}/${t}${u("#",i)}`,bugstemplate:({domain:e,user:t,project:i})=>`https://${e}/${t}/${i}/issues`,hashformat:nt},R={};R.github={protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",blobpath:"blob",editpath:"edit",filetemplate:({auth:e,user:t,project:i,committish:s,path:n})=>`https://${u(e,"@")}raw.githubusercontent.com/${t}/${i}/${g(s||"HEAD")}/${n}`,gittemplate:({auth:e,domain:t,user:i,project:s,committish:n})=>`git://${u(e,"@")}${t}/${i}/${s}.git${u("#",n)}`,tarballtemplate:({domain:e,user:t,project:i,committish:s})=>`https://codeload.${e}/${t}/${i}/tar.gz/${g(s||"HEAD")}`,extract:e=>{let[,t,i,s,n]=e.pathname.split("/",5);if(!(s&&s!=="tree")&&(s||(n=e.hash.slice(1)),i&&i.endsWith(".git")&&(i=i.slice(0,-4)),!(!t||!i)))return{user:t,project:i,committish:n}}};R.bitbucket={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",blobpath:"src",editpath:"?mode=edit",edittemplate:({domain:e,user:t,project:i,committish:s,treepath:n,path:r,editpath:o})=>`https://${e}/${t}/${i}${u("/",n,"/",g(s||"HEAD"),"/",r,o)}`,tarballtemplate:({domain:e,user:t,project:i,committish:s})=>`https://${e}/${t}/${i}/get/${g(s||"HEAD")}.tar.gz`,extract:e=>{let[,t,i,s]=e.pathname.split("/",4);if(!["get"].includes(s)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),!(!t||!i)))return{user:t,project:i,committish:e.hash.slice(1)}}};R.gitlab={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",blobpath:"tree",editpath:"-/edit",httpstemplate:({auth:e,domain:t,user:i,project:s,committish:n})=>`git+https://${u(e,"@")}${t}/${i}/${s}.git${u("#",n)}`,tarballtemplate:({domain:e,user:t,project:i,committish:s})=>`https://${e}/${t}/${i}/repository/archive.tar.gz?ref=${g(s||"HEAD")}`,extract:e=>{let t=e.pathname.slice(1);if(t.includes("/-/")||t.includes("/archive.tar.gz"))return;let i=t.split("/"),s=i.pop();s.endsWith(".git")&&(s=s.slice(0,-4));let n=i.join("/");if(!(!n||!s))return{user:n,project:s,committish:e.hash.slice(1)}}};R.gist={protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",editpath:"edit",sshtemplate:({domain:e,project:t,committish:i})=>`git@${e}:${t}.git${u("#",i)}`,sshurltemplate:({domain:e,project:t,committish:i})=>`git+ssh://git@${e}/${t}.git${u("#",i)}`,edittemplate:({domain:e,user:t,project:i,committish:s,editpath:n})=>`https://${e}/${t}/${i}${u("/",g(s))}/${n}`,browsetemplate:({domain:e,project:t,committish:i})=>`https://${e}/${t}${u("/",g(i))}`,browsetreetemplate:({domain:e,project:t,committish:i,path:s,hashformat:n})=>`https://${e}/${t}${u("/",g(i))}${u("#",n(s))}`,browseblobtemplate:({domain:e,project:t,committish:i,path:s,hashformat:n})=>`https://${e}/${t}${u("/",g(i))}${u("#",n(s))}`,docstemplate:({domain:e,project:t,committish:i})=>`https://${e}/${t}${u("/",g(i))}`,httpstemplate:({domain:e,project:t,committish:i})=>`git+https://${e}/${t}.git${u("#",i)}`,filetemplate:({user:e,project:t,committish:i,path:s})=>`https://gist.githubusercontent.com/${e}/${t}/raw${u("/",g(i))}/${s}`,shortcuttemplate:({type:e,project:t,committish:i})=>`${e}:${t}${u("#",i)}`,pathtemplate:({project:e,committish:t})=>`${e}${u("#",t)}`,bugstemplate:({domain:e,project:t})=>`https://${e}/${t}`,gittemplate:({domain:e,project:t,committish:i})=>`git://${e}/${t}.git${u("#",i)}`,tarballtemplate:({project:e,committish:t})=>`https://codeload.github.com/gist/${e}/tar.gz/${g(t||"HEAD")}`,extract:e=>{let[,t,i,s]=e.pathname.split("/",4);if(s!=="raw"){if(!i){if(!t)return;i=t,t=null}return i.endsWith(".git")&&(i=i.slice(0,-4)),{user:t,project:i,committish:e.hash.slice(1)}}},hashformat:function(e){return e&&"file-"+nt(e)}};R.sourcehut={protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",blobpath:"tree",filetemplate:({domain:e,user:t,project:i,committish:s,path:n})=>`https://${e}/${t}/${i}/blob/${g(s)||"HEAD"}/${n}`,httpstemplate:({domain:e,user:t,project:i,committish:s})=>`https://${e}/${t}/${i}.git${u("#",s)}`,tarballtemplate:({domain:e,user:t,project:i,committish:s})=>`https://${e}/${t}/${i}/archive/${g(s)||"HEAD"}.tar.gz`,bugstemplate:()=>null,extract:e=>{let[,t,i,s]=e.pathname.split("/",4);if(!["archive"].includes(s)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),!(!t||!i)))return{user:t,project:i,committish:e.hash.slice(1)}}};for(let[e,t]of Object.entries(R))R[e]=Object.assign({},Ot,t);rt.exports=R});var K=F((se,at)=>{y();var _t=D("url"),V=(e,t,i)=>{let s=e.indexOf(i);return e.lastIndexOf(t,s>-1?s:1/0)},ht=e=>{try{return new _t.URL(e)}catch{}},Rt=(e,t)=>{let i=e.indexOf(":"),s=e.slice(0,i+1);if(Object.prototype.hasOwnProperty.call(t,s))return e;let n=e.indexOf("@");return n>-1?n>i?`git+ssh://${e}`:e:e.indexOf("//")===i+1?e:`${e.slice(0,i+1)}//${e.slice(i+1)}`},Ct=e=>{let t=V(e,"@","#"),i=V(e,":","#");return i>t&&(e=e.slice(0,i)+"/"+e.slice(i+1)),V(e,":","#")===-1&&e.indexOf("//")===-1&&(e=`git+ssh://${e}`),e};at.exports=(e,t)=>{let i=t?Rt(e,t):e;return ht(i)||ht(Ct(i))}});var ct=F((re,lt)=>{"use strict";y();var Ft=K(),xt=e=>{let t=e.indexOf("#"),i=e.indexOf("/"),s=e.indexOf("/",i+1),n=e.indexOf(":"),r=/\s/.exec(e),o=e.indexOf("@"),a=!r||t>-1&&r.index>t,h=o===-1||t>-1&&o>t,f=n===-1||t>-1&&n>t,w=s===-1||t>-1&&s>t,p=i>0,m=t>-1?e[t-1]!=="/":!e.endsWith("/"),d=!e.startsWith(".");return a&&p&&m&&d&&h&&f&&w};lt.exports=(e,t,{gitHosts:i,protocols:s})=>{if(!e)return;let n=xt(e)?`github:${e}`:e,r=Ft(n,s);if(!r)return;let o=i.byShortcut[r.protocol],a=i.byDomain[r.hostname.startsWith("www.")?r.hostname.slice(4):r.hostname],h=o||a;if(!h)return;let f=i[o||a],w=null;s[r.protocol]?.auth&&(r.username||r.password)&&(w=`${r.username}${r.password?":"+r.password:""}`);let p=null,m=null,d=null,A=null;try{if(o){let l=r.pathname.startsWith("/")?r.pathname.slice(1):r.pathname,S=l.indexOf("@");S>-1&&(l=l.slice(S+1));let c=l.lastIndexOf("/");c>-1?(m=decodeURIComponent(l.slice(0,c)),m||(m=null),d=decodeURIComponent(l.slice(c+1))):d=decodeURIComponent(l),d.endsWith(".git")&&(d=d.slice(0,-4)),r.hash&&(p=decodeURIComponent(r.hash.slice(1))),A="shortcut"}else{if(!f.protocols.includes(r.protocol))return;let l=f.extract(r);if(!l)return;m=l.user&&decodeURIComponent(l.user),d=decodeURIComponent(l.project),p=decodeURIComponent(l.committish),A=s[r.protocol]?.name||r.protocol.slice(0,-1)}}catch(l){if(l instanceof URIError)return;throw l}return[h,m,w,d,p,A,t]}});var ut=F((he,ft)=>{"use strict";y();var{LRUCache:Tt}=st(),zt=ot(),Ut=ct(),Wt=K(),Y=new Tt({max:1e3}),H=class e{constructor(t,i,s,n,r,o,a={}){Object.assign(this,e.#n[t],{type:t,user:i,auth:s,project:n,committish:r,default:o,opts:a})}static#n={byShortcut:{},byDomain:{}};static#l={"git+ssh:":{name:"sshurl"},"ssh:":{name:"sshurl"},"git+https:":{name:"https",auth:!0},"git:":{auth:!0},"http:":{auth:!0},"https:":{auth:!0},"git+http:":{auth:!0}};static addHost(t,i){e.#n[t]=i,e.#n.byDomain[i.domain]=t,e.#n.byShortcut[`${t}:`]=t,e.#l[`${t}:`]={name:t}}static fromUrl(t,i){if(typeof t!="string")return;let s=t+JSON.stringify(i||{});if(!Y.has(s)){let n=Ut(t,i,{gitHosts:e.#n,protocols:e.#l});Y.set(s,n?new e(...n):void 0)}return Y.get(s)}static parseUrl(t){return Wt(t)}#e(t,i){if(typeof t!="function")return null;let s={...this,...this.opts,...i};s.path||(s.path=""),s.path.startsWith("/")&&(s.path=s.path.slice(1)),s.noCommittish&&(s.committish=null);let n=t(s);return s.noGitPlus&&n.startsWith("git+")?n.slice(4):n}hash(){return this.committish?`#${this.committish}`:""}ssh(t){return this.#e(this.sshtemplate,t)}sshurl(t){return this.#e(this.sshurltemplate,t)}browse(t,...i){return typeof t!="string"?this.#e(this.browsetemplate,t):typeof i[0]!="string"?this.#e(this.browsetreetemplate,{...i[0],path:t}):this.#e(this.browsetreetemplate,{...i[1],fragment:i[0],path:t})}browseFile(t,...i){return typeof i[0]!="string"?this.#e(this.browseblobtemplate,{...i[0],path:t}):this.#e(this.browseblobtemplate,{...i[1],fragment:i[0],path:t})}docs(t){return this.#e(this.docstemplate,t)}bugs(t){return this.#e(this.bugstemplate,t)}https(t){return this.#e(this.httpstemplate,t)}git(t){return this.#e(this.gittemplate,t)}shortcut(t){return this.#e(this.shortcuttemplate,t)}path(t){return this.#e(this.pathtemplate,t)}tarball(t){return this.#e(this.tarballtemplate,{...t,noCommittish:!1})}file(t,i){return this.#e(this.filetemplate,{...i,path:t})}edit(t,i){return this.#e(this.edittemplate,{...i,path:t})}getDefaultRepresentation(){return this.default}toString(t){return this.default&&typeof this[this.default]=="function"?this[this.default](t):this.sshurl(t)}};for(let[e,t]of Object.entries(zt))H.addHost(e,t);ft.exports=H});var dt=F((le,pt)=>{y();var Dt=Symbol("proc-log.meta");pt.exports={META:Dt,output:{LEVELS:["standard","error","buffer","flush"],KEYS:{standard:"standard",error:"error",buffer:"buffer",flush:"flush"},standard:function(...e){return process.emit("output","standard",...e)},error:function(...e){return process.emit("output","error",...e)},buffer:function(...e){return process.emit("output","buffer",...e)},flush:function(...e){return process.emit("output","flush",...e)}},log:{LEVELS:["notice","error","warn","info","verbose","http","silly","timing","pause","resume"],KEYS:{notice:"notice",error:"error",warn:"warn",info:"info",verbose:"verbose",http:"http",silly:"silly",timing:"timing",pause:"pause",resume:"resume"},error:function(...e){return process.emit("log","error",...e)},notice:function(...e){return process.emit("log","notice",...e)},warn:function(...e){return process.emit("log","warn",...e)},info:function(...e){return process.emit("log","info",...e)},verbose:function(...e){return process.emit("log","verbose",...e)},http:function(...e){return process.emit("log","http",...e)},silly:function(...e){return process.emit("log","silly",...e)},timing:function(...e){return process.emit("log","timing",...e)},pause:function(){return process.emit("log","pause")},resume:function(){return process.emit("log","resume")}},time:{LEVELS:["start","end"],KEYS:{start:"start",end:"end"},start:function(e,t){process.emit("time","start",e);function i(){return process.emit("time","end",e)}if(typeof t=="function"){let s=t();return s&&s.finally?s.finally(i):(i(),s)}return i},end:function(e){return process.emit("time","end",e)}},input:{LEVELS:["start","end","read"],KEYS:{start:"start",end:"end",read:"read"},start:function(e){process.emit("input","start");function t(){return process.emit("input","end")}if(typeof e=="function"){let i=e();return i&&i.finally?i.finally(t):(t(),i)}return t},end:function(){return process.emit("input","end")},read:function(...e){let t,i,s=new Promise((n,r)=>{t=n,i=r});return process.emit("input","read",t,i,...e),s}}}});var Jt=F((fe,I)=>{y();I.exports=L;I.exports.resolve=yt;I.exports.toPurl=Ht;I.exports.Result=U;var{URL:x}=D("url"),Lt=ut(),mt=vt(),C=global.FAKE_WINDOWS?D("path").win32:D("path"),bt=At(),{homedir:It}=D("os"),{log:Pt}=dt(),J=process.platform==="win32"||global.FAKE_WINDOWS,St=J?/\\|[/]/:/[/]/,$t=/^(?:git[+])?[a-z]+:/i,jt=/^[^@]+@[^:.]+\.[^:]+:.+$/i,X=/[.](?:tgz|tar.gz|tar)$/i;function L(e,t){let i,s;if(typeof e=="object")return e instanceof U&&(!t||t===e.where)?e:e.name&&e.rawSpec?L.resolve(e.name,e.rawSpec,t||e.where):L(e.raw,t||e.where);let n=e[0]==="@"?e.slice(1).indexOf("@")+1:e.indexOf("@"),r=n>0?e.slice(0,n):e;return $t.test(e)?s=e:jt.test(e)?s=`git+ssh://${e}`:r[0]!=="@"&&(St.test(r)||X.test(r))?s=e:n>0?(i=r,s=e.slice(n+1)||"*"):bt(e).validForOldPackages?(i=e,s="*"):s=e,yt(i,s,t,e)}var Nt=J?/^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/:/^(?:[.]|~[/]|[/]|[a-zA-Z]:)/;function yt(e,t,i,s){let n=new U({raw:s,name:e,rawSpec:t,fromArgument:s!=null});if(e&&n.setName(e),t&&(Nt.test(t)||/^file:/i.test(t)))return wt(n,i);if(t&&/^npm:/i.test(t))return Yt(n,i);let r=Lt.fromUrl(t,{noGitPlus:!0,noCommittish:!0});return r?qt(n,r):t&&$t.test(t)?Kt(n):t&&(St.test(t)||X.test(t))?wt(n,i):Bt(n)}var gt="https://registry.npmjs.org";function Ht(e,t=gt){let i=L(e);if(i.type!=="version")throw Mt(i.type,i.raw);let s="pkg:npm/"+i.name.replace(/^@/,"%40")+"@"+i.rawSpec;return t!==gt&&(s+="?repository_url="+t),s}function Gt(e,t,i){let s=new Error(`Invalid package name "${e}" of package "${i}": ${t.errors.join("; ")}.`);return s.code="EINVALIDPACKAGENAME",s}function kt(e,t){let i=new Error(`Invalid tag name "${e}" of package "${t}": Tags may not have any characters that encodeURIComponent encodes.`);return i.code="EINVALIDTAGNAME",i}function Mt(e,t){let i=new Error(`Invalid type "${e}" of package "${t}": Purl can only be generated for "version" types.`);return i.code="EINVALIDPURLTYPE",i}function U(e){this.type=e.type,this.registry=e.registry,this.where=e.where,e.raw==null?this.raw=e.name?e.name+"@"+e.rawSpec:e.rawSpec:this.raw=e.raw,this.name=void 0,this.escapedName=void 0,this.scope=void 0,this.rawSpec=e.rawSpec||"",this.saveSpec=e.saveSpec,this.fetchSpec=e.fetchSpec,e.name&&this.setName(e.name),this.gitRange=e.gitRange,this.gitCommittish=e.gitCommittish,this.gitSubdir=e.gitSubdir,this.hosted=e.hosted}U.prototype.setName=function(e){let t=bt(e);if(!t.validForOldPackages)throw Gt(e,t,this.raw);return this.name=e,this.scope=e[0]==="@"?e.slice(0,e.indexOf("/")):void 0,this.escapedName=e.replace("/","%2f"),this};U.prototype.toString=function(){let e=[];this.name!=null&&this.name!==""&&e.push(this.name);let t=this.saveSpec||this.fetchSpec||this.rawSpec;return t!=null&&t!==""&&e.push(t),e.length?e.join("@"):this.raw};U.prototype.toJSON=function(){let e=Object.assign({},this);return delete e.hosted,e};function B(e,t){if(!t){e.gitCommittish=null;return}for(let i of t.split("::")){if(!i.includes(":")){if(e.gitRange)throw new Error("cannot override existing semver range with a committish");if(e.gitCommittish)throw new Error("cannot override existing committish with a second committish");e.gitCommittish=i;continue}let[s,n]=i.split(":");if(s==="semver"){if(e.gitCommittish)throw new Error("cannot override existing committish with a semver range");if(e.gitRange)throw new Error("cannot override existing semver range with a second semver range");e.gitRange=decodeURIComponent(n);continue}if(s==="path"){if(e.gitSubdir)throw new Error("cannot override existing path with a second path");e.gitSubdir=`/${n}`;continue}Pt.warn("npm-package-arg",`ignoring unknown key "${s}"`)}}function wt(e,t){t||(t=process.cwd()),e.type=X.test(e.rawSpec)?"file":"directory",e.where=t;let i,s,r=(/^file:/.test(e.rawSpec)?"":"file:")+e.rawSpec,o=r.replace(/^file:/,"");try{s=new x(r,`file://${C.resolve(t)}/`),i=new x(r)}catch(f){let w=new Error("Invalid file: URL, must comply with RFC 8089");throw Object.assign(w,{raw:e.rawSpec,spec:e,where:t,originalError:f})}if(s.host&&s.host!=="localhost"){let f=e.rawSpec.replace(/^file:\/\//,"file:///");s=new x(f,`file://${C.resolve(t)}/`),i=new x(f),o=f.replace(/^file:/,"")}if(/^\/{1,3}\.\.?(\/|$)/.test(o)){let f=e.rawSpec.replace(/^file:\/{1,3}/,"file:");s=new x(f,`file://${C.resolve(t)}/`),i=new x(f),o=f.replace(/^file:/,"")}let a=decodeURIComponent(i.pathname),h=decodeURIComponent(s.pathname);return J&&(a=a.replace(/^\/+([a-z]:\/)/i,"$1"),h=h.replace(/^\/+([a-z]:\/)/i,"$1")),/^\/~(\/|$)/.test(a)?(e.saveSpec=`file:${a.substr(1)}`,h=C.resolve(It(),a.substr(3))):C.isAbsolute(o)?e.saveSpec=`file:${C.resolve(h)}`:e.saveSpec=`file:${C.relative(t,h)}`,e.fetchSpec=C.resolve(t,h),e}function qt(e,t){return e.type="git",e.hosted=t,e.saveSpec=t.toString({noGitPlus:!1,noCommittish:!1}),e.fetchSpec=t.getDefaultRepresentation()==="shortcut"?null:t.toString(),B(e,t.committish),e}function Vt(e,t){let i=new Error(`Unsupported URL Type "${e}": ${t}`);return i.code="EUNSUPPORTEDPROTOCOL",i}function Kt(e){let t=e.rawSpec;if(e.saveSpec=t,t.startsWith("git+ssh:")){let s=t.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i);if(s&&!s[1].match(/:[0-9]+\/?.*$/i))return e.type="git",B(e,s[2]),e.fetchSpec=s[1],e}else t.startsWith("git+file://")&&(t=t.replace(/\\/g,"/"));let i=new x(t);switch(i.protocol){case"git:":case"git+http:":case"git+https:":case"git+rsync:":case"git+ftp:":case"git+file:":case"git+ssh:":e.type="git",B(e,i.hash.slice(1)),i.protocol==="git+file:"&&/^git\+file:\/\/[a-z]:/i.test(t)?e.fetchSpec=`git+file://${i.host.toLowerCase()}:${i.pathname}`:(i.hash="",e.fetchSpec=i.toString()),e.fetchSpec.startsWith("git+")&&(e.fetchSpec=e.fetchSpec.slice(4));break;case"http:":case"https:":e.type="remote",e.fetchSpec=e.saveSpec;break;default:throw Vt(i.protocol,t)}return e}function Yt(e,t){let i=L(e.rawSpec.substr(4),t);if(i.type==="alias")throw new Error("nested aliases not supported");if(!i.registry)throw new Error("aliases only work for registry deps");if(!i.name)throw new Error("aliases must have a name");return e.subSpec=i,e.registry=!0,e.type="alias",e.saveSpec=null,e.fetchSpec=null,e}function Bt(e){e.registry=!0;let t=e.rawSpec.trim();e.saveSpec=null,e.fetchSpec=t;let i=mt.valid(t,!0),s=mt.validRange(t,!0);if(i)e.type="version";else if(s)e.type="range";else{if(encodeURIComponent(t)!==t)throw kt(t,e.raw);e.type="tag"}return e}});export default Jt();