@velcro/strategy-fs
Version:
Velcro resolver strategy backed by an fs-compatible object
3 lines (2 loc) • 47.5 kB
JavaScript
this.Velcro=this.Velcro||{},this.Velcro.StrategyFs=function(e){"use strict";class t extends Error{constructor(){super(...arguments),this.name=this.constructor.name}}class n extends t{}class r extends t{constructor(e){super(`Entry was excluded by current configuration '${e.toString()}'`)}}class i extends t{constructor(e){super(`Unable to resolve '${e.toString()}'`)}}class s extends i{constructor(e,t){super(`The dependency '${e}' of '${t.toString()}' was not found`)}}class o extends t{}function a(e,t){let n=!1;const r=e.map((e=>h(e)?(n=!0,c(e,t)):e));return n?Promise.all(r):e}async function c(e,t){try{const r=await e;return t.isCancellationRequested?Promise.reject(new n):r}catch(e){if(t.isCancellationRequested)return Promise.reject(new n);throw e}}function h(e){return e&&("function"==typeof e.then||"boolean"==typeof e.done&&"number"==typeof e.next&&"number"==typeof e.pre)}var l;!function(e){e.decode="object"==typeof global&&"function"==typeof global.Buffer?e=>global.Buffer.from(e,"base64").toString("utf-8"):"function"==typeof atob?e=>decodeURIComponent(escape(atob(e))):e=>{throw new Error("The environment has neither the Buffer nor btoa functions. Please consider polyfilling one of these apis.")},e.encode="object"==typeof global&&"function"==typeof global.Buffer?e=>global.Buffer.from(e).toString("base64"):"function"==typeof btoa?e=>btoa(unescape(encodeURIComponent(e))):e=>{throw new Error("The environment has neither the Buffer nor btoa functions. Please consider polyfilling one of these apis.")}}(l||(l={}));const u=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout((()=>{if(e.stack)throw new Error(e.message+"\n\n"+e.stack);throw e}),0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach((t=>{t(e)}))}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function f(e){var t;(t=e)instanceof Error&&t.name===d&&t.message===d||u.onUnexpectedError(e)}const d="Canceled";var p,g;function m(e){}function y(...e){return e.forEach(m),{dispose:()=>function(e){if(p.is(e)){for(let t of e)t&&t.dispose();return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}(e)}}!function(e){e.is=function(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]};const t=Object.freeze([]);e.empty=function(){return t},e.single=function*(e){yield e},e.from=function(e){return e||t},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){for(const n of e)if(t(n))return!0;return!1},e.filter=function*(e,t){for(const n of e)t(n)&&(yield n)},e.map=function*(e,t){for(const n of e)yield t(n)},e.concat=function*(...e){for(const t of e)for(const e of t)yield e},e.consume=function(t,n=Number.POSITIVE_INFINITY){const r=[];if(0===n)return[r,t];const i=t[Symbol.iterator]();for(let t=0;t<n;t++){const t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>i}]}}(p||(p={}));class C{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}clear(){this._toDispose.forEach((e=>e.dispose())),this._toDispose.clear()}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?C.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}}C.DISABLE_DISPOSED_WARNING=!1;class v{constructor(){this._store=new C}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}}v.None=Object.freeze({dispose(){}});class b{constructor(e){this.element=e,this.next=b.Undefined,this.prev=b.Undefined}}b.Undefined=new b(void 0);class w{constructor(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===b.Undefined}clear(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){const n=new b(e);if(this._first===b.Undefined)this._first=n,this._last=n;else if(t){const e=this._last;this._last=n,n.prev=e,e.next=n}else{const e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==b.Undefined){const e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==b.Undefined){const e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==b.Undefined&&e.next!==b.Undefined){const t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===b.Undefined&&e.next===b.Undefined?(this._first=b.Undefined,this._last=b.Undefined):e.next===b.Undefined?(this._last=this._last.prev,this._last.next=b.Undefined):e.prev===b.Undefined&&(this._first=this._first.next,this._first.prev=b.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==b.Undefined;)yield e.element,e=e.next}toArray(){const e=[];for(let t=this._first;t!==b.Undefined;t=t.next)e.push(t.element);return e}}!function(e){function t(e){return(t,n=null,r)=>{let i,s=!1;return i=e((e=>{if(!s)return i?i.dispose():s=!0,t.call(n,e)}),null,r),s&&i.dispose(),i}}function n(e,t){return o(((n,r=null,i)=>e((e=>n.call(r,t(e))),null,i)))}function r(e,t){return o(((n,r=null,i)=>e((e=>{t(e),n.call(r,e)}),null,i)))}function i(e,t){return o(((n,r=null,i)=>e((e=>t(e)&&n.call(r,e)),null,i)))}function s(e,t,r){let i=r;return n(e,(e=>(i=t(i,e),i)))}function o(e){let t;const n=new _({onFirstListenerAdd(){t=e(n.fire,n)},onLastListenerRemove(){t.dispose()}});return n.event}function a(e,t,n=100,r=!1,i){let s,o=void 0,a=void 0,c=0;const h=new _({leakWarningThreshold:i,onFirstListenerAdd(){s=e((e=>{c++,o=t(o,e),r&&!a&&(h.fire(o),o=void 0),clearTimeout(a),a=setTimeout((()=>{const e=o;o=void 0,a=void 0,(!r||c>1)&&h.fire(e),c=0}),n)}))},onLastListenerRemove(){s.dispose()}});return h.event}function c(e){let t,n=!0;return i(e,(e=>{const r=n||e!==t;return n=!1,t=e,r}))}e.None=()=>v.None,e.once=t,e.map=n,e.forEach=r,e.filter=i,e.signal=function(e){return e},e.any=function(...e){return(t,n=null,r)=>y(...e.map((e=>e((e=>t.call(n,e)),null,r))))},e.reduce=s,e.snapshot=o,e.debounce=a,e.stopwatch=function(e){const r=(new Date).getTime();return n(t(e),(e=>(new Date).getTime()-r))},e.latch=c,e.buffer=function(e,t=!1,n=[]){let r=n.slice(),i=e((e=>{r?r.push(e):o.fire(e)}));const s=()=>{r&&r.forEach((e=>o.fire(e))),r=null},o=new _({onFirstListenerAdd(){i||(i=e((e=>o.fire(e))))},onFirstListenerDidAdd(){r&&(t?setTimeout(s):s())},onLastListenerRemove(){i&&i.dispose(),i=null}});return o.event};class h{constructor(e){this.event=e}map(e){return new h(n(this.event,e))}forEach(e){return new h(r(this.event,e))}filter(e){return new h(i(this.event,e))}reduce(e,t){return new h(s(this.event,e,t))}latch(){return new h(c(this.event))}debounce(e,t=100,n=!1,r){return new h(a(this.event,e,t,n,r))}on(e,t,n){return this.event(e,t,n)}once(e,n,r){return t(this.event)(e,n,r)}}e.chain=function(e){return new h(e)},e.fromNodeEventEmitter=function(e,t,n=(e=>e)){const r=(...e)=>i.fire(n(...e)),i=new _({onFirstListenerAdd:()=>e.on(t,r),onLastListenerRemove:()=>e.removeListener(t,r)});return i.event},e.fromDOMEventEmitter=function(e,t,n=(e=>e)){const r=(...e)=>i.fire(n(...e)),i=new _({onFirstListenerAdd:()=>e.addEventListener(t,r),onLastListenerRemove:()=>e.removeEventListener(t,r)});return i.event},e.fromPromise=function(e){const t=new _;let n=!1;return e.then(void 0,(()=>null)).then((()=>{n?t.fire(void 0):setTimeout((()=>t.fire(void 0)),0)})),n=!0,t.event},e.toPromise=function(e){return new Promise((n=>t(e)(n)))}}(g||(g={}));class _{constructor(e){this._disposed=!1,this._options=e,this._leakageMon=void 0}get event(){return this._event||(this._event=(e,t,n)=>{this._listeners||(this._listeners=new w);const r=this._listeners.isEmpty();r&&this._options&&this._options.onFirstListenerAdd&&this._options.onFirstListenerAdd(this);const i=this._listeners.push(t?[e,t]:e);let s,o;return r&&this._options&&this._options.onFirstListenerDidAdd&&this._options.onFirstListenerDidAdd(this),this._options&&this._options.onListenerDidAdd&&this._options.onListenerDidAdd(this,e,t),this._leakageMon&&(s=this._leakageMon.check(this._listeners.size)),o={dispose:()=>{if(s&&s(),o.dispose=_._noop,!this._disposed&&(i(),this._options&&this._options.onLastListenerRemove)){this._listeners&&!this._listeners.isEmpty()||this._options.onLastListenerRemove(this)}}},n instanceof C?n.add(o):Array.isArray(n)&&n.push(o),o}),this._event}fire(e){if(this._listeners){this._deliveryQueue||(this._deliveryQueue=new w);for(let t of this._listeners)this._deliveryQueue.push([t,e]);for(;this._deliveryQueue.size>0;){const[e,t]=this._deliveryQueue.shift();try{"function"==typeof e?e.call(void 0,t):e[0].call(e[1],t)}catch(e){f(e)}}}}dispose(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0}}_._noop=function(){};const A=Object.freeze((function(e,t){const n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}));var k;!function(e){e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||(t instanceof x||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested))},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:g.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:A})}(k||(k={}));class x{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?A:(this._emitter||(this._emitter=new _),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}}class ${constructor(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}get token(){return this._token||(this._token=new x),this._token}cancel(){this._token?this._token instanceof x&&this._token.cancel():this._token=k.Cancelled}dispose(e=!1){e&&this.cancel(),this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof x&&this._token.dispose():this._token=k.None}}!function(){if("function"!=typeof requestIdleCallback||"function"!=typeof cancelIdleCallback){Object.freeze({didTimeout:!0,timeRemaining:()=>15})}}();const S="object"==typeof self?self:"object"==typeof global?global:{},E=function(){if(S.setImmediate)return S.setImmediate.bind(S);if("function"==typeof S.postMessage&&!S.importScripts){let e=[];S.addEventListener("message",(t=>{if(t.data&&t.data.vscodeSetImmediateId)for(let n=0,r=e.length;n<r;n++){const r=e[n];if(r.id===t.data.vscodeSetImmediateId)return e.splice(n,1),void r.callback()}}));let t=0;return n=>{const r=++t;e.push({id:r,callback:n}),S.postMessage({vscodeSetImmediateId:r},"*")}}if("undefined"!=typeof process&&"function"==typeof process.nextTick)return process.nextTick.bind(process);const e=Promise.resolve();return t=>e.then(t)}(),I="undefined"==typeof process?{cwd:()=>"/",env:Object.create(null),get platform(){return"linux"},nextTick:e=>E(e)}:process,U=I.cwd,P=I.env,j=(I.platform,I.nextTick,46),R=47,F=92,O=58;class D extends Error{constructor(e,t,n){let r;"string"==typeof t&&0===t.indexOf("not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be";const i=-1!==e.indexOf(".")?"property":"argument";let s=`The "${e}" ${i} ${r} of type ${t}`;s+=". Received type "+typeof n,super(s),this.code="ERR_INVALID_ARG_TYPE"}}function T(e,t){if("string"!=typeof e)throw new D(t,"string",e)}function L(e){return e===R||e===F}function q(e){return e===R}function V(e){return e>=65&&e<=90||e>=97&&e<=122}function z(e,t,n,r){let i="",s=0,o=-1,a=0,c=0;for(let h=0;h<=e.length;++h){if(h<e.length)c=e.charCodeAt(h);else{if(r(c))break;c=R}if(r(c)){if(o===h-1||1===a);else if(2===a){if(i.length<2||2!==s||i.charCodeAt(i.length-1)!==j||i.charCodeAt(i.length-2)!==j){if(i.length>2){const e=i.lastIndexOf(n);-1===e?(i="",s=0):(i=i.slice(0,e),s=i.length-1-i.lastIndexOf(n)),o=h,a=0;continue}if(0!==i.length){i="",s=0,o=h,a=0;continue}}t&&(i+=i.length>0?n+"..":"..",s=2)}else i.length>0?i+=`${n}${e.slice(o+1,h)}`:i=e.slice(o+1,h),s=h-o-1;o=h,a=0}else c===j&&-1!==a?++a:a=-1}return i}function J(e,t){if(null===t||"object"!=typeof t)throw new D("pathObject","Object",t);const n=t.dir||t.root,r=t.base||`${t.name||""}${t.ext||""}`;return n?n===t.root?`${n}${r}`:`${n}${e}${r}`:r}const N={resolve(...e){let t="",n="",r=!1;for(let i=e.length-1;i>=-1;i--){let s;if(i>=0){if(s=e[i],T(s,"path"),0===s.length)continue}else 0===t.length?s=U():(s=P["="+t]||U(),(void 0===s||s.slice(0,2).toLowerCase()!==t.toLowerCase()&&s.charCodeAt(2)===F)&&(s=t+"\\"));const o=s.length;let a=0,c="",h=!1;const l=s.charCodeAt(0);if(1===o)L(l)&&(a=1,h=!0);else if(L(l))if(h=!0,L(s.charCodeAt(1))){let e=2,t=e;for(;e<o&&!L(s.charCodeAt(e));)e++;if(e<o&&e!==t){const n=s.slice(t,e);for(t=e;e<o&&L(s.charCodeAt(e));)e++;if(e<o&&e!==t){for(t=e;e<o&&!L(s.charCodeAt(e));)e++;e!==o&&e===t||(c=`\\\\${n}\\${s.slice(t,e)}`,a=e)}}}else a=1;else V(l)&&s.charCodeAt(1)===O&&(c=s.slice(0,2),a=2,o>2&&L(s.charCodeAt(2))&&(h=!0,a=3));if(c.length>0)if(t.length>0){if(c.toLowerCase()!==t.toLowerCase())continue}else t=c;if(r){if(t.length>0)break}else if(n=`${s.slice(a)}\\${n}`,r=h,h&&t.length>0)break}return n=z(n,!r,"\\",L),r?`${t}\\${n}`:`${t}${n}`||"."},normalize(e){T(e,"path");const t=e.length;if(0===t)return".";let n,r=0,i=!1;const s=e.charCodeAt(0);if(1===t)return q(s)?"\\":e;if(L(s))if(i=!0,L(e.charCodeAt(1))){let i=2,s=i;for(;i<t&&!L(e.charCodeAt(i));)i++;if(i<t&&i!==s){const o=e.slice(s,i);for(s=i;i<t&&L(e.charCodeAt(i));)i++;if(i<t&&i!==s){for(s=i;i<t&&!L(e.charCodeAt(i));)i++;if(i===t)return`\\\\${o}\\${e.slice(s)}\\`;i!==s&&(n=`\\\\${o}\\${e.slice(s,i)}`,r=i)}}}else r=1;else V(s)&&e.charCodeAt(1)===O&&(n=e.slice(0,2),r=2,t>2&&L(e.charCodeAt(2))&&(i=!0,r=3));let o=r<t?z(e.slice(r),!i,"\\",L):"";return 0!==o.length||i||(o="."),o.length>0&&L(e.charCodeAt(t-1))&&(o+="\\"),void 0===n?i?"\\"+o:o:i?`${n}\\${o}`:`${n}${o}`},isAbsolute(e){T(e,"path");const t=e.length;if(0===t)return!1;const n=e.charCodeAt(0);return L(n)||t>2&&V(n)&&e.charCodeAt(1)===O&&L(e.charCodeAt(2))},join(...e){if(0===e.length)return".";let t,n;for(let r=0;r<e.length;++r){const i=e[r];T(i,"path"),i.length>0&&(void 0===t?t=n=i:t+="\\"+i)}if(void 0===t)return".";let r=!0,i=0;if("string"==typeof n&&L(n.charCodeAt(0))){++i;const e=n.length;e>1&&L(n.charCodeAt(1))&&(++i,e>2&&(L(n.charCodeAt(2))?++i:r=!1))}if(r){for(;i<t.length&&L(t.charCodeAt(i));)i++;i>=2&&(t="\\"+t.slice(i))}return N.normalize(t)},relative(e,t){if(T(e,"from"),T(t,"to"),e===t)return"";const n=N.resolve(e),r=N.resolve(t);if(n===r)return"";if((e=n.toLowerCase())===(t=r.toLowerCase()))return"";let i=0;for(;i<e.length&&e.charCodeAt(i)===F;)i++;let s=e.length;for(;s-1>i&&e.charCodeAt(s-1)===F;)s--;const o=s-i;let a=0;for(;a<t.length&&t.charCodeAt(a)===F;)a++;let c=t.length;for(;c-1>a&&t.charCodeAt(c-1)===F;)c--;const h=c-a,l=o<h?o:h;let u=-1,f=0;for(;f<l;f++){const n=e.charCodeAt(i+f);if(n!==t.charCodeAt(a+f))break;n===F&&(u=f)}if(f!==l){if(-1===u)return r}else{if(h>l){if(t.charCodeAt(a+f)===F)return r.slice(a+f+1);if(2===f)return r.slice(a+f)}o>l&&(e.charCodeAt(i+f)===F?u=f:2===f&&(u=3)),-1===u&&(u=0)}let d="";for(f=i+u+1;f<=s;++f)f!==s&&e.charCodeAt(f)!==F||(d+=0===d.length?"..":"\\..");return a+=u,d.length>0?`${d}${r.slice(a,c)}`:(r.charCodeAt(a)===F&&++a,r.slice(a,c))},toNamespacedPath(e){if("string"!=typeof e)return e;if(0===e.length)return"";const t=N.resolve(e);if(t.length<=2)return e;if(t.charCodeAt(0)===F){if(t.charCodeAt(1)===F){const e=t.charCodeAt(2);if(63!==e&&e!==j)return"\\\\?\\UNC\\"+t.slice(2)}}else if(V(t.charCodeAt(0))&&t.charCodeAt(1)===O&&t.charCodeAt(2)===F)return"\\\\?\\"+t;return e},dirname(e){T(e,"path");const t=e.length;if(0===t)return".";let n=-1,r=0;const i=e.charCodeAt(0);if(1===t)return L(i)?e:".";if(L(i)){if(n=r=1,L(e.charCodeAt(1))){let i=2,s=i;for(;i<t&&!L(e.charCodeAt(i));)i++;if(i<t&&i!==s){for(s=i;i<t&&L(e.charCodeAt(i));)i++;if(i<t&&i!==s){for(s=i;i<t&&!L(e.charCodeAt(i));)i++;if(i===t)return e;i!==s&&(n=r=i+1)}}}}else V(i)&&e.charCodeAt(1)===O&&(n=t>2&&L(e.charCodeAt(2))?3:2,r=n);let s=-1,o=!0;for(let n=t-1;n>=r;--n)if(L(e.charCodeAt(n))){if(!o){s=n;break}}else o=!1;if(-1===s){if(-1===n)return".";s=n}return e.slice(0,s)},basename(e,t){void 0!==t&&T(t,"ext"),T(e,"path");let n,r=0,i=-1,s=!0;if(e.length>=2&&V(e.charCodeAt(0))&&e.charCodeAt(1)===O&&(r=2),void 0!==t&&t.length>0&&t.length<=e.length){if(t===e)return"";let o=t.length-1,a=-1;for(n=e.length-1;n>=r;--n){const c=e.charCodeAt(n);if(L(c)){if(!s){r=n+1;break}}else-1===a&&(s=!1,a=n+1),o>=0&&(c===t.charCodeAt(o)?-1==--o&&(i=n):(o=-1,i=a))}return r===i?i=a:-1===i&&(i=e.length),e.slice(r,i)}for(n=e.length-1;n>=r;--n)if(L(e.charCodeAt(n))){if(!s){r=n+1;break}}else-1===i&&(s=!1,i=n+1);return-1===i?"":e.slice(r,i)},extname(e){T(e,"path");let t=0,n=-1,r=0,i=-1,s=!0,o=0;e.length>=2&&e.charCodeAt(1)===O&&V(e.charCodeAt(0))&&(t=r=2);for(let a=e.length-1;a>=t;--a){const t=e.charCodeAt(a);if(L(t)){if(!s){r=a+1;break}}else-1===i&&(s=!1,i=a+1),t===j?-1===n?n=a:1!==o&&(o=1):-1!==n&&(o=-1)}return-1===n||-1===i||0===o||1===o&&n===i-1&&n===r+1?"":e.slice(n,i)},format:J.bind(null,"\\"),parse(e){T(e,"path");const t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;const n=e.length;let r=0,i=e.charCodeAt(0);if(1===n)return L(i)?(t.root=t.dir=e,t):(t.base=t.name=e,t);if(L(i)){if(r=1,L(e.charCodeAt(1))){let t=2,i=t;for(;t<n&&!L(e.charCodeAt(t));)t++;if(t<n&&t!==i){for(i=t;t<n&&L(e.charCodeAt(t));)t++;if(t<n&&t!==i){for(i=t;t<n&&!L(e.charCodeAt(t));)t++;t===n?r=t:t!==i&&(r=t+1)}}}}else if(V(i)&&e.charCodeAt(1)===O){if(n<=2)return t.root=t.dir=e,t;if(r=2,L(e.charCodeAt(2))){if(3===n)return t.root=t.dir=e,t;r=3}}r>0&&(t.root=e.slice(0,r));let s=-1,o=r,a=-1,c=!0,h=e.length-1,l=0;for(;h>=r;--h)if(i=e.charCodeAt(h),L(i)){if(!c){o=h+1;break}}else-1===a&&(c=!1,a=h+1),i===j?-1===s?s=h:1!==l&&(l=1):-1!==s&&(l=-1);return-1!==a&&(-1===s||0===l||1===l&&s===a-1&&s===o+1?t.base=t.name=e.slice(o,a):(t.name=e.slice(o,s),t.base=e.slice(o,a),t.ext=e.slice(s,a))),t.dir=o>0&&o!==r?e.slice(0,o-1):t.root,t},sep:"\\",delimiter:";",win32:null,posix:null},K={resolve(...e){let t="",n=!1;for(let r=e.length-1;r>=-1&&!n;r--){const i=r>=0?e[r]:U();T(i,"path"),0!==i.length&&(t=`${i}/${t}`,n=i.charCodeAt(0)===R)}return t=z(t,!n,"/",q),n?"/"+t:t.length>0?t:"."},normalize(e){if(T(e,"path"),0===e.length)return".";const t=e.charCodeAt(0)===R,n=e.charCodeAt(e.length-1)===R;return 0===(e=z(e,!t,"/",q)).length?t?"/":n?"./":".":(n&&(e+="/"),t?"/"+e:e)},isAbsolute:e=>(T(e,"path"),e.length>0&&e.charCodeAt(0)===R),join(...e){if(0===e.length)return".";let t;for(let n=0;n<e.length;++n){const r=e[n];T(r,"path"),r.length>0&&(void 0===t?t=r:t+="/"+r)}return void 0===t?".":K.normalize(t)},relative(e,t){if(T(e,"from"),T(t,"to"),e===t)return"";if((e=K.resolve(e))===(t=K.resolve(t)))return"";const n=e.length,r=n-1,i=t.length-1,s=r<i?r:i;let o=-1,a=0;for(;a<s;a++){const n=e.charCodeAt(1+a);if(n!==t.charCodeAt(1+a))break;n===R&&(o=a)}if(a===s)if(i>s){if(t.charCodeAt(1+a)===R)return t.slice(1+a+1);if(0===a)return t.slice(1+a)}else r>s&&(e.charCodeAt(1+a)===R?o=a:0===a&&(o=0));let c="";for(a=1+o+1;a<=n;++a)a!==n&&e.charCodeAt(a)!==R||(c+=0===c.length?"..":"/..");return`${c}${t.slice(1+o)}`},toNamespacedPath:e=>e,dirname(e){if(T(e,"path"),0===e.length)return".";const t=e.charCodeAt(0)===R;let n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===R){if(!r){n=t;break}}else r=!1;return-1===n?t?"/":".":t&&1===n?"//":e.slice(0,n)},basename(e,t){void 0!==t&&T(t,"ext"),T(e,"path");let n,r=0,i=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t===e)return"";let o=t.length-1,a=-1;for(n=e.length-1;n>=0;--n){const c=e.charCodeAt(n);if(c===R){if(!s){r=n+1;break}}else-1===a&&(s=!1,a=n+1),o>=0&&(c===t.charCodeAt(o)?-1==--o&&(i=n):(o=-1,i=a))}return r===i?i=a:-1===i&&(i=e.length),e.slice(r,i)}for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===R){if(!s){r=n+1;break}}else-1===i&&(s=!1,i=n+1);return-1===i?"":e.slice(r,i)},extname(e){T(e,"path");let t=-1,n=0,r=-1,i=!0,s=0;for(let o=e.length-1;o>=0;--o){const a=e.charCodeAt(o);if(a!==R)-1===r&&(i=!1,r=o+1),a===j?-1===t?t=o:1!==s&&(s=1):-1!==t&&(s=-1);else if(!i){n=o+1;break}}return-1===t||-1===r||0===s||1===s&&t===r-1&&t===n+1?"":e.slice(t,r)},format:J.bind(null,"/"),parse(e){T(e,"path");const t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;const n=e.charCodeAt(0)===R;let r;n?(t.root="/",r=1):r=0;let i=-1,s=0,o=-1,a=!0,c=e.length-1,h=0;for(;c>=r;--c){const t=e.charCodeAt(c);if(t!==R)-1===o&&(a=!1,o=c+1),t===j?-1===i?i=c:1!==h&&(h=1):-1!==i&&(h=-1);else if(!a){s=c+1;break}}if(-1!==o){const r=0===s&&n?1:s;-1===i||0===h||1===h&&i===o-1&&i===s+1?t.base=t.name=e.slice(r,o):(t.name=e.slice(r,i),t.base=e.slice(r,o),t.ext=e.slice(i,o))}return s>0?t.dir=e.slice(0,s-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};K.win32=N.win32=N,K.posix=N.posix=K;class M{constructor(){if("undefined"!=typeof TextDecoder)this.decoder=new TextDecoder;else if("function"!=typeof Buffer||"function"!=typeof Buffer.from)throw new Error("The environment supports neither the TextDecoder nor Buffer API. Please consider polyfilling one of these.")}decode(e){const t=this.decoder?this.decoder.decode(e):Buffer.from(e).toString("utf-8");return 65279===t.charCodeAt(0)?t.slice(1):t}}class B{constructor(){this._data=new Map}get size(){return this._data.size}add(e,t){let n=this._data.get(e);return n||(n=new Set,this._data.set(e,n)),n.add(t),this}clear(){this._data.clear()}delete(e,t){const n=this._data.get(e);if(n){const r=n.delete(t);return n.size||this._data.delete(e),r}return!1}deleteAll(e){return this._data.delete(e)}get(e){return this._data.get(e)}has(e){return this._data.has(e)}hasValue(e,t){const n=this._data.get(e);return!!n&&n.has(t)}*entries(){for(const[e,t]of this._data.entries())for(const n of t)yield[e,n]}*values(){for(const e of this._data.values())yield*e.values()}}function W(e,t){return void 0!==e[t]&&"string"!=typeof e[t]}function H(e,t){return void 0!==e[t]&&"object"==typeof e[t]&&null!==e[t]&&!Object.keys(e[t]).every((n=>"string"==typeof n&&"string"==typeof e[t][n]))}function Q(e,t,n){try{return function(e,t){let n;try{n=JSON.parse(e)}catch(e){throw new Error(`Error parsing manifest as json for package ${t}: ${e.message}`)}if(!function(e){return!("object"!=typeof e||null===e||W(e,"name")||W(e,"version")||function(e){let t="";const n=e.browser;if(n&&"object"==typeof n)for(const e in n){if("string"!=typeof e){t=`The key ${e} of .browser must be a string`;break}if("string"!=typeof n[e]&&!1!==n[e]){t=`The value ${e} of .browser must be a string or false`;break}}return t}(e)||W(e,"main")||W(e,"module")||W(e,"jsnext:main")||W(e,"unpkg")||H(e,"dependencies")||H(e,"devDependencies")||H(e,"peerDependencies"))}(n))throw new Error("Invalid manifest for the package "+t);return n}(e.decode(t),n)}catch(e){throw new Error(`Error decoding manifest buffer for package ${n}: ${e.message}`)}}const G=47;class Y extends Error{constructor(e,t,n){let r;"string"==typeof t&&0===t.indexOf("not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be";const i=-1!==e.indexOf(".")?"property":"argument";let s=`The "${e}" ${i} ${r} of type ${t}`;s+=". Received type "+typeof n,super(s),this.code="ERR_INVALID_ARG_TYPE"}}function Z(e,t){if("string"!=typeof e)throw new Y(t,"string",e)}function X(e){return e===G}function ee(e,t,n,r){let i="",s=0,o=-1,a=0,c=0;for(let h=0;h<=e.length;++h){if(h<e.length)c=e.charCodeAt(h);else{if(r(c))break;c=G}if(r(c)){if(o===h-1||1===a);else if(2===a){if(i.length<2||2!==s||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2)){if(i.length>2){const e=i.lastIndexOf(n);-1===e?(i="",s=0):(i=i.slice(0,e),s=i.length-1-i.lastIndexOf(n)),o=h,a=0;continue}if(0!==i.length){i="",s=0,o=h,a=0;continue}}t&&(i+=i.length>0?n+"..":"..",s=2)}else i.length>0?i+=`${n}${e.slice(o+1,h)}`:i=e.slice(o+1,h),s=h-o-1;o=h,a=0}else 46===c&&-1!==a?++a:a=-1}return i}const te={resolve(...e){let t="",n=!1;for(let r=e.length-1;r>=-1&&!n;r--){const i=r>=0?e[r]:process.cwd();Z(i,"path"),0!==i.length&&(t=`${i}/${t}`,n=i.charCodeAt(0)===G)}return t=ee(t,!n,"/",X),n?"/"+t:t.length>0?t:"."},normalize(e){if(Z(e,"path"),0===e.length)return".";const t=e.charCodeAt(0)===G,n=e.charCodeAt(e.length-1)===G;return 0===(e=ee(e,!t,"/",X)).length?t?"/":n?"./":".":(n&&(e+="/"),t?"/"+e:e)},isAbsolute:e=>(Z(e,"path"),e.length>0&&e.charCodeAt(0)===G),join(...e){if(0===e.length)return".";let t;for(let n=0;n<e.length;++n){const r=e[n];Z(r,"path"),r.length>0&&(void 0===t?t=r:t+="/"+r)}return void 0===t?".":te.normalize(t)},relative(e,t){if(Z(e,"from"),Z(t,"to"),e===t)return"";if((e=te.resolve(e))===(t=te.resolve(t)))return"";const n=e.length,r=n-1,i=t.length-1,s=r<i?r:i;let o=-1,a=0;for(;a<s;a++){const n=e.charCodeAt(1+a);if(n!==t.charCodeAt(1+a))break;n===G&&(o=a)}if(a===s)if(i>s){if(t.charCodeAt(1+a)===G)return t.slice(1+a+1);if(0===a)return t.slice(1+a)}else r>s&&(e.charCodeAt(1+a)===G?o=a:0===a&&(o=0));let c="";for(a=1+o+1;a<=n;++a)a!==n&&e.charCodeAt(a)!==G||(c+=0===c.length?"..":"/..");return`${c}${t.slice(1+o)}`},toNamespacedPath:e=>e,dirname(e){if(Z(e,"path"),0===e.length)return".";const t=e.charCodeAt(0)===G;let n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===G){if(!r){n=t;break}}else r=!1;return-1===n?t?"/":".":t&&1===n?"//":e.slice(0,n)},basename(e,t){void 0!==t&&Z(t,"ext"),Z(e,"path");let n,r=0,i=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t===e)return"";let o=t.length-1,a=-1;for(n=e.length-1;n>=0;--n){const c=e.charCodeAt(n);if(c===G){if(!s){r=n+1;break}}else-1===a&&(s=!1,a=n+1),o>=0&&(c===t.charCodeAt(o)?-1==--o&&(i=n):(o=-1,i=a))}return r===i?i=a:-1===i&&(i=e.length),e.slice(r,i)}for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===G){if(!s){r=n+1;break}}else-1===i&&(s=!1,i=n+1);return-1===i?"":e.slice(r,i)},extname(e){Z(e,"path");let t=-1,n=0,r=-1,i=!0,s=0;for(let o=e.length-1;o>=0;--o){const a=e.charCodeAt(o);if(a!==G)-1===r&&(i=!1,r=o+1),46===a?-1===t?t=o:1!==s&&(s=1):-1!==t&&(s=-1);else if(!i){n=o+1;break}}return-1===t||-1===r||0===s||1===s&&t===r-1&&t===n+1?"":e.slice(t,r)},format:function(e,t){if(null===t||"object"!=typeof t)throw new Y("pathObject","Object",t);const n=t.dir||t.root,r=t.base||`${t.name||""}${t.ext||""}`;return n?n===t.root?`${n}${r}`:`${n}${e}${r}`:r}.bind(null,"/"),parse(e){Z(e,"path");const t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;const n=e.charCodeAt(0)===G;let r;n?(t.root="/",r=1):r=0;let i=-1,s=0,o=-1,a=!0,c=e.length-1,h=0;for(;c>=r;--c){const t=e.charCodeAt(c);if(t!==G)-1===o&&(a=!1,o=c+1),46===t?-1===i?i=c:1!==h&&(h=1):-1!==i&&(h=-1);else if(!a){s=c+1;break}}if(-1!==o){const r=0===s&&n?1:s;-1===i||0===h||1===h&&i===o-1&&i===s+1?t.base=t.name=e.slice(r,o):(t.name=e.slice(r,i),t.base=e.slice(r,o),t.ext=e.slice(i,o))}return s>0?t.dir=e.slice(0,s-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null},ne=te.join,re=te.dirname,ie=te.basename,se=/^\w[\w\d+.-]*$/,oe=/^\//,ae=/^\/\//;const ce="",he="/",le=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class ue{constructor(e,t,n,r,i,s=!1){"object"==typeof e?(this.scheme=e.scheme||ce,this.authority=e.authority||ce,this.path=e.path||ce,this.query=e.query||ce,this.fragment=e.fragment||ce):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t||ce,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==he&&(t=he+t):t=he}return t}(this.scheme,n||ce),this.query=r||ce,this.fragment=i||ce,function(e,t){if(!e.scheme&&t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!se.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!oe.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(ae.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}static ensureTrailingSlash(e,t="/"){return e.with({path:e.path.replace(_e,t)})}static equals(e,t){return e.authority===t.authority&&e.fragment===t.fragment&&e.path===t.path&&e.query===t.query&&e.scheme===t.scheme}static getFirstPathSegmentAfterPrefix(e,t){const n=e.path,r=t.path,i="/"===r.charAt(r.length-1)?-1:0;for(let s=0;s<=n.length;s++)if(s<r.length){if(n.charAt(s)!==r.charAt(s))throw new Error(`The child entry ${e.toString()} does not have the pathname of ${t.toString()} as a prefix`)}else if(s===r.length+i){if("/"!==n.charAt(s))throw new Error(`The child entry ${e.toString()} does not have the pathname of ${t.toString()} as a prefix`)}else if("/"===n.charAt(s))return n.slice(r.length+1+i,s);return n.slice(r.length+1+i)}static isPrefixOf(e,t,n){return e.authority===t.authority&&e.fragment===t.fragment&&e.query===t.query&&e.scheme===t.scheme&&t.path.startsWith(e.path)&&(!n||t.path.length>e.path.length)}static isUri(e){return e instanceof ue||!!e&&("string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString)}get fsPath(){return ye(this,!1)}with(e){if(!e)return this;let{scheme:t,authority:n,path:r,query:i,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=ce),void 0===n?n=this.authority:null===n&&(n=ce),void 0===r?r=this.path:null===r&&(r=ce),void 0===i?i=this.query:null===i&&(i=ce),void 0===s?s=this.fragment:null===s&&(s=ce),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&s===this.fragment?this:new de(t,n,r,i,s)}static parse(e,t=!1){const n=le.exec(e);return n?new de(n[2]||ce,we(n[4]||ce),we(n[5]||ce),we(n[7]||ce),we(n[9]||ce),t):new de(ce,ce,ce,ce,ce)}static file(e){let t=ce;if(e[0]===he&&e[1]===he){const n=e.indexOf(he,2);-1===n?(t=e.substring(2),e=he):(t=e.substring(2,n),e=e.substring(n)||he)}return new de("file",t,e,ce,ce)}static from(e){return new de(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");const n=ne(e.path,...t);return e.with({path:n})}toString(e=!0){return Ce(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof ue)return e;{const t=new de(e);return t._formatted=e.external,t._fsPath=e._sep===fe?e.fsPath:null,t}}return e}}const fe=void 0;class de extends ue{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return this._fsPath||(this._fsPath=ye(this,!1)),this._fsPath}toString(e=!0){return e?(this._formatted||(this._formatted=Ce(this,!0)),this._formatted):Ce(this,!1)}toJSON(){const e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath,e._sep=fe),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e}}const pe={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function ge(e,t){let n=void 0,r=-1;for(let i=0;i<e.length;i++){const s=e.charCodeAt(i);if(s>=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));const t=pe[s];void 0!==t?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=t):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function me(e){let t=void 0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);35===r||63===r?(void 0===t&&(t=e.substr(0,n)),t+=pe[r]):void 0!==t&&(t+=e[n])}return void 0!==t?t:e}function ye(e,t){let n;return n=e.authority&&e.path.length>1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,n}function Ce(e,t){const n=t?me:ge;let r="",{scheme:i,authority:s,path:o,query:a,fragment:c}=e;if(i&&(r+=i,r+=":"),(s||"file"===i)&&(r+=he,r+=he),s){let e=s.indexOf("@");if(-1!==e){const t=s.substr(0,e);s=s.substr(e+1),e=t.indexOf(":"),-1===e?r+=n(t,!1):(r+=n(t.substr(0,e),!1),r+=":",r+=n(t.substr(e+1),!1)),r+="@"}s=s.toLowerCase(),e=s.indexOf(":"),-1===e?r+=n(s,!1):(r+=n(s.substr(0,e),!1),r+=s.substr(e))}if(o){if(o.length>=3&&47===o.charCodeAt(0)&&58===o.charCodeAt(2)){const e=o.charCodeAt(1);e>=65&&e<=90&&(o=`/${String.fromCharCode(e+32)}:${o.substr(3)}`)}else if(o.length>=2&&58===o.charCodeAt(1)){const e=o.charCodeAt(0);e>=65&&e<=90&&(o=`${String.fromCharCode(e+32)}:${o.substr(2)}`)}r+=n(o,!0)}return a&&(r+="?",r+=n(a,!1)),c&&(r+="#",r+=t?c:ge(c,!1)),r}function ve(e){try{return decodeURIComponent(e)}catch(t){return e.length>3?e.substr(0,3)+ve(e.substr(3)):e}}const be=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function we(e){return e.match(be)?e.replace(be,(e=>ve(e))):e}const _e=/\/?$/,Ae=/^((@[^/]+\/[^/@]+|[^./@][^/@]*)(?:@([^/]+))?)(.*)?$/;function ke(e){const t=e.match(Ae);if(t){const[,e,n,r,i=""]=t;return{nameSpec:e,name:n,spec:r,path:i}}return null}const xe=Object.assign(Object.create(null),{string_decoder:ke("string_decoder@1.2.0"),punycode:ke("punycode@2.1.1")});for(const e of["assert","buffer","constants","crypto","events","fs","http","https","net","os","path","process","querystring","stream","tls","url","util","vm","zlib"])xe[e]=ke(`@velcro/node-libs@0.56.2/lib/${e}.js`);var $e;!function(e){let t;!function(e){e.File="file",e.Directory="directory"}(t=e.EntryKind||(e.EntryKind={}))}($e||($e={}));const Se=Symbol("Context.cache");class Ee{constructor(e,t){this.uri=e,this.visits=[],this.parent=t}child(e){return new Ee(e,this)}push(e){this.visits.find((t=>t.type==e.type&&ue.equals(t.uri,e.uri)))||(this.visits.push(e),this.parent&&this.parent.push(e))}toArray(){return this.parent?this.parent.toArray():this.visits.slice()}}class Ie{constructor(e){this.mapResultWithVisits=e=>Object.assign(e,{visited:this.visits.toArray()}),this.cache=e.cache,this.cacheInvalidations=e.cacheInvalidations,this.debugMode=e.debug,this.decoder=e.decoder,this.path=e.path,this.resolver=e.resolver,this.settings=e.settings,this.strategy=e.strategy,this.tokenSource=new $(e.token),this.visits=e.visits}static create(e,t,n,r,i={}){return new Ie({cache:new Map,cacheInvalidations:new B,debug:!!i.debug,decoder:new M,path:[],resolver:e,settings:n,strategy:t,token:r,visits:new Ee(ue.parse("velcro:/root"))})}get token(){return this.tokenSource.token}get visited(){return this.visits.toArray()}dispose(){this.tokenSource.dispose(!0)}forOperation(e,t,n={}){const r=function(e,t){return`${e}:${t.toString()}`}(e,t);if(this.path.includes(r)){const n=this.path.map((e=>{const{operationName:t,uri:n}=Ue(e);return`${t}(${n.toString()})`})).join(" -> ");throw this._wrapError(new Error(`Detected a recursive call to the operation '${e}' for '${t.toString()}' at path '${n}'`))}return new Ie({cache:this.cache,cacheInvalidations:this.cacheInvalidations,debug:this.debugMode,decoder:this.decoder,path:n.resetPath?[]:this.path.concat(r),resolver:this.resolver,settings:this.settings,strategy:this.strategy,token:this.tokenSource.token,visits:n.resetVisits?new Ee(t):this.visits.child(t)})}getCanonicalUrl(e){const t=this.strategy.getCanonicalUrl,n=this.strategy,r="Strategy.getCanonicalUrl",i=e.toString();return this.runInChildContext(r,e,(s=>s.runWithCache(r,i,t,n,s,e)))}getResolveRoot(e){const t=this.strategy.getResolveRoot,n=this.strategy,r="Strategy.getResolveRoot",i=e.toString();return this.runInChildContext(r,e,(s=>s.runWithCache(r,i,t,n,s,e)))}getSettings(e){const t=this.strategy.getSettings,n=this.strategy,r="Strategy.getSettings",i=e.toString();return this.runInChildContext(r,e,(s=>s.runWithCache(r,i,t,n,s,e)))}getUrlForBareModule(e,t,n){const r=this.strategy.getUrlForBareModule;if(!r)return Promise.reject(new Error(`Unable to resolve bare module spec '${e}@${t}${n}' because no strategy was found that supports resolving bare modules`));const i=this.strategy,s="Strategy.getUrlForBareModule",o=`${e}@${t}${n}`;return this.runInChildContext(s,o,(a=>a.runWithCache(s,o,r,i,a,e,t,n)))}invalidate(e){const t=e.toString(),n=this.cacheInvalidations.get(t);let r=!1;if(n)for(const{cacheKey:e,operationCache:t}of n)r=t.delete(e)||r;return this.cacheInvalidations.deleteAll(t),r}listEntries(e){const t=this.strategy.listEntries,n=this.strategy,r="Strategy.listEntries",i=e.toString();return this.runInChildContext(r,e,(s=>s.runWithCache(r,i,t,n,s,e)))}readFileContent(e){const t=this.strategy.readFileContent,n=this.strategy,r="Strategy.readFileContent",i=e.toString();return this.recordVisit(e,Ie.VisitKind.File),this.runInChildContext(r,e,(s=>s.runWithCache(r,i,t,n,s,e)))}readParentPackageJson(e){return console.debug("readParentPackageJson(%s)",e.toString()),this.runWithCache("readParentPackageJson",e.toString(),Oe,null,this,e)}recordVisit(e,t=Ie.VisitKind.File){this.visits.push({type:t,uri:e})}resolve(e,t){const n=je,r="resolve",i=`${t}|${e}`;return this.runInChildContext(r,i,(s=>s.runWithCache(r,i,n,null,s,t,e)))}resolveUri(e){const t=Pe,n="resolveUri",r=e.toString();return this.runInChildContext(n,e,(i=>i.runWithCache(n,r,t,null,i,e)))}runInChildContext(e,t,n){return this.runInContext(e,t,{resetPath:!1,resetVisits:!1},n)}runInIsolatedContext(e,t,n){return this.runInContext(e,t,{resetPath:!0,resetVisits:!0},n)}runInContext(e,t,n,r){const i=this.forOperation(e,t,n);return i.debug("%s(%s)",e,t.toString()),r(i)}createStoreResultFn(e,t){return n=>{const r=this.mapResultWithVisits(n),i=r.visited;if(r[Se]){const t=r[Se];delete r[Se];for(const[n,r]of t){e.set(n,r);for(const t of i)this.cacheInvalidations.add(t.uri.toString(),{cacheKey:n,operationCache:e})}}e.set(t,r);for(const n of i)this.cacheInvalidations.add(n.uri.toString(),{cacheKey:t,operationCache:e});return r}}runWithCache(e,t,n,r,...i){let s=this.cache.get(e);s||(s=new Map,this.cache.set(e,s));const o=s.get(t);if(o)return this.debug("%s(%s) [HIT]",e,t),o;const a=this.createStoreResultFn(s,t);this.debug("%s(%s) [MISS]",e,t);const c=n.apply(r,i);if(h(c)){const e=c.then(a,(e=>(s.delete(t),Promise.reject(e))));return s.set(t,e),e}return a(c)}_wrapError(e){return Object.assign(e,{path:this.path.map(Ue)})}debug(...e){this.debugMode&&("string"==typeof e[0]&&(e[0]=" ".repeat(this.path.length)+e[0]),console.warn(...e))}}function Ue(e){const t=e.split(":",2);if(2!==t.length)throw console.log("WTF",{node:e,parts:t}),new Error(`Invariant violation: Unexpected path node: '${e}'`);return{operationName:t[0],uri:t[1].includes(":")?ue.parse(t[1]):t[1]}}async function Pe(e,t){const n=a([e.getCanonicalUrl(t),e.getResolveRoot(t),e.getSettings(t)],e.token),[r,i,s]=h(n)?await c(n,e.token):n,o=i.uri,l=ue.ensureTrailingSlash(o,"");if(!ue.isPrefixOf(l,r.uri))throw new Error(`Unable to resolve a module whose path ${r.uri.toString(!0)} is above the host's root ${o.toString()}`);const u=a([ue.equals(l,r.uri)||ue.equals(o,r.uri)?e.runInChildContext("resolveAsDirectory",r.uri,(e=>Re(e,ue.ensureTrailingSlash(r.uri),i.uri,s.settings))):e.runInChildContext("resolveAsFile",r.uri,(e=>Fe(e,r.uri,i.uri,s.settings,null))),De(e,r.uri,o,{uriIsCanonicalized:!0})],e.token),[f,d]=h(u)?await u:u;let p=void 0;if(d.found&&"string"==typeof d.packageJson.name&&"string"==typeof d.packageJson.version)p={packageJson:d.packageJson,uri:d.uri};else if(d.found){let t=ue.joinPath(d.uri,"..");for(;ue.isPrefixOf(o,t,!0);){const n=De(e,t,o,{uriIsCanonicalized:!1}),r=h(n)?await c(n,e.token):n;if(!r.found)break;if(r.packageJson.name&&r.packageJson.version){p={packageJson:r.packageJson,uri:r.uri};break}t=ue.joinPath(r.uri,"..")}}return{...f,parentPackageJson:p}}async function je(e,t,n){const i=ke(n);if(i)return e.runInChildContext("resolveBareModule",t,(e=>async function(e,t,n){let i=n.name,o=n.spec,a=n.path;if(!o){const r=e.getResolveRoot(t),i=h(r)?await c(r,e.token):r;let a=t;const l=10,u=[];for(;ue.isPrefixOf(i.uri,a,!0);){if(u.length>=l)throw new Error(`Consulted a maximum of ${l} locations while trying to resolve '${Te(n)}' from '${t.toString()}', via ${e.path.join(" -> ")}: ${u.map((e=>e.toString())).join(", ")}`);const r=a;u.push(r);const f=De(e,r,i.uri,{uriIsCanonicalized:!1}),d=h(f)?await c(f,e.token):f;if(!d.found)throw new s(n.nameSpec,t);if(e.recordVisit(d.uri,Ie.VisitKind.File),d.packageJson.name===n.name){const t=ue.ensureTrailingSlash(ue.joinPath(d.uri,"../"));return e.runInChildContext("resolveAsDirectory",t,(e=>Re(e,t,i.uri,e.settings)))}if(o={...d.packageJson.devDependencies||{},...d.packageJson.peerDependencies||{},...d.packageJson.dependencies||{}}[n.name],o)break;if(a=ue.joinPath(d.uri,".."),ue.equals(a,r)||ue.equals(a,i.uri))break}}if(!o){const e=xe[n.name];e&&(i=e.name,o=e.spec,a=e.path)}if(!o)throw new s(n.nameSpec,t);const l=e.getUrlForBareModule(i,o,a),u=h(l)?await c(l,e.token):l;if(!u.found)throw new s(n.nameSpec,t);if(!u.uri)throw new r(n.nameSpec);const f=e.resolveUri(u.uri);return h(f)?await c(f,e.token):f}(e,t,i)));const o=ue.joinPath(ue.from({...t,path:re(t.path)}),n);return e.runInChildContext("resolveUri",o,(e=>Pe(e,o)))}async function Re(e,t,n,r){e.recordVisit(t,Ie.VisitKind.Directory);const i=e.listEntries(t),s=h(i)?await c(i,e.token):i;let o="index";const a=ue.joinPath(t,"./package.json");e.recordVisit(a,Ie.VisitKind.File);const l=s.entries.find((e=>e.type===$e.EntryKind.File&&ue.equals(a,e.uri)));let u=null;if(l){const n=e.readFileContent(a),i=h(n)?await c(n,e.token):n;u=Q(e.decoder,i.content,t.toString());for(const e of r.packageMain){const t=u[e];if("string"==typeof t){o=t;break}}}const f=ue.joinPath(t,o);return e.runInChildContext("resolveAsFile",t,(e=>Fe(e,f,n,r,u)))}async function Fe(e,t,n,r,s,o=!1){if(""===t.path||"/"===t.path)throw new TypeError("Unable to resolve the root as a file: "+t.toString());e.recordVisit(t,Ie.VisitKind.File);const a=new Map;if(null===s){const i=r.packageMain.includes("browser")&&!o?await c(e.runInChildContext("readParentPackageJsonInternal",t,(e=>De(e,t,n,{uriIsCanonicalized:!0}))),e.token):void 0;if(i&&i.found&&(e.recordVisit(i.uri,Ie.VisitKind.File),s=i.packageJson,i.packageJson.browser&&"object"==typeof i.packageJson.browser)){const o=i.packageJson.browser,c=ue.joinPath(i.uri,"..");for(const i in o){const h=ue.joinPath(c,i),l=o[i],u=!1!==l&&ue.joinPath(c,l);if(ue.equals(h,t))return!1===u?{found:!1,uri:null}:e.runInChildContext("resolveAsFile",u,(e=>Fe(e,u,n,r,s,!0)));a.set(h.toString(),u)}}}const l=ue.ensureTrailingSlash(ue.joinPath(t,"..")),u=ie(t.path),f=e.listEntries(l),d=h(f)?await c(f,e.token):f,p=new Map,g=new Map;for(const e of d.entries){if(ue.equals(e.uri,t)&&e.type==$e.EntryKind.File)return{found:!0,rootUri:n,uri:t};if(e.type===$e.EntryKind.Directory){const t=ue.getFirstPathSegmentAfterPrefix(e.uri,l);p.set(t,e)}else if(e.type===$e.EntryKind.File){const t=ie(e.uri.path);g.set(t,e)}}for(const i of r.extensions){const o=t.with({path:`${t.path}${i}`}),c=o.toString(),h=a.get(c);if(e.recordVisit(o,Ie.VisitKind.File),!1===h)return{found:!0,rootUri:n,uri:null};if(h)return e.runInChildContext("resolveAsFile",h,(e=>Fe(e,h,n,r,s,!0)));const l=g.get(`${u}${i}`);if(l){if(l.type!==$e.EntryKind.File)continue;return{found:!0,rootUri:n,uri:l.uri}}}const m=p.get(u);if(m){if(m.type!==$e.EntryKind.Directory)throw new Error(`Invariant violation ${m.type} is unexpected`);return e.runInChildContext("resolveAsDirectory",m.uri,(e=>Re(e,ue.ensureTrailingSlash(m.uri),n,r)))}throw new i(t)}async function Oe(e,t){const n=a([e.getCanonicalUrl(t),e.getResolveRoot(t)],e.token),[r,i]=h(n)?await c(n,e.token):n,s=e.runInChildContext("readParentPackageJsonInternal",r.uri,(e=>De(e,r.uri,i.uri,{uriIsCanonicalized:!0}))),o=h(s)?await s:s;if(o.found&&o.visitedDirs){const e=o.visitedDirs;delete o.visitedDirs,o[Se]=e.map((e=>[e.toString(),{...o,uri:e}]))}return o}async function De(e,t,r,i){if(!i.uriIsCanonicalized){const n=e.getCanonicalUrl(t);t=(h(n)?await c(n,e.token):n).uri}const s=ue.ensureTrailingSlash(r),o=ue.ensureTrailingSlash(ue.joinPath(t,"..")),a=[],l=async(e,t)=>{if(!ue.isPrefixOf(s,t))return{found:!1,packageJson:null,uri:null};e.recordVisit(t,Ie.VisitKind.Directory);const r=e.listEntries(t),i=h(r)?await c(r,e.token):r,o=ue.joinPath(t,"package.json"),u=i.entries.find((e=>e.type===$e.EntryKind.File&&ue.equals(e.uri,o)));if(e.recordVisit(o,Ie.VisitKind.File),u)try{const t=e.readFileContent(o),n=h(t)?await c(t,e.token):t;return{found:!0,packageJson:Q(e.decoder,n.content,o.toString()),uri:o,visitedDirs:a}}catch(e){if(e instanceof n||e&&"CanceledError"===e.name)throw e}const f=ue.ensureTrailingSlash(ue.joinPath(t,".."));return ue.equals(t,f)||ue.isPrefixOf(t,f)?{found:!1,packageJson:null,uri:null}:(a.push(t),e.runInChildContext("readPackageJsonOrRecurse",f,(e=>l(e,f))))};return ue.equals(t,o)||ue.isPrefixOf(t,o)?{found:!1,packageJson:null,uri:null}:e.runInChildContext("readPackageJsonOrRecurse",o,(e=>l(e,o)))}function Te(e){return`${e.nameSpec}${e.path}`}!function(e){let t;!function(e){e.Directory="Directory",e.File="File"}(t=e.VisitKind||(e.VisitKind={}))}(Ie||(Ie={}));return e.FsStrategy=class extends class extends class{getCanonicalUrl(e,t){return{uri:t}}getSettings(e,t){return{settings:e.settings}}withOverrides(e){const t={...e,parent:this};return Object.setPrototypeOf(Object.assign(Object.create(null),t),this)}}{constructor(e){super(),this.rootUri=e}}{constructor(e){super(e.rootUri||ue.file("/")),this.fs=e.fs}ensureUriUnderRoot(e){if(!ue.isPrefixOf(this.rootUri,e))return new o(`The URI '${e}' is not under the root for this resolver strategy '${this.rootUri}'`)}async getCanonicalUrl(e,t){const n=this.ensureUriUnderRoot(t);if(n)throw n;try{const e=await this.fs.promises.realpath(t.fsPath);return{uri:ue.file(e)}}catch(n){if(n&&"ENOENT"===n.code)return{uri:t};throw n}}getRootUrl(){return{uri:this.rootUri}}getResolveRoot(e,t){const n=this.ensureUriUnderRoot(t);return n?Promise.reject(n):{uri:this.rootUri}}async listEntries(e,t){const n=this.ensureUriUnderRoot(t);if(n)throw n;const r=await this.fs.promises.readdir(t.fsPath,{encoding:"utf-8",withFileTypes:!0}),i={entries:[]};for(const e of r)e.isDirectory()?i.entries.push({type:$e.EntryKind.Directory,uri:ue.joinPath(t,e.name)}):e.isFile()&&i.entries.push({type:$e.EntryKind.File,uri:ue.joinPath(t,e.name)});return i}async readFileContent(e,t){const n=this.ensureUriUnderRoot(t);if(n)throw n;return{content:await this.fs.promises.readFile(t.fsPath)}}},e.version="0.56.2",e}({});
//# sourceMappingURL=index.min.js.map