"use strict";function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function r(r){for(var t=1;te.length)&&(r=e.length);for(var t=0,n=new Array(r);t2&&void 0!==arguments[2]?arguments[2]:function(){return new Map};return e.has(r)||e.set(r,t()),e.get(r)},d=function(e,r){return r},y=function(e,r,t,n){var i=r.defer,o=r.registry,a=r.resolvers,u=r.initializer,c=void 0===u?d:u,s=f(t);if(o.has(s))return Promise.reject(new RangeError(l.Fulfill.guaranteeAlreadyRegistered(t)));o.add(s);var y=e.get(t,!0);return i.then((function(){return c(t,n)})).then((function(e){return a.get(s).resolve(e)}),(function(e){return a.get(s).reject(e)})),y},p=new WeakMap,v=function(){function e(t){var n,i=this,o=t.defer,a=void 0===o?Promise.resolve():o,u=t.retriever,c=t.initializer,f=t.retrieveEarly,s=void 0!==f&&f,d=t.thenableApi,v=void 0===d?Promise:d,h=t.publicFulfill,b=void 0!==h&&h;if(function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),!0!==b&&(!u||"function"!=typeof u))throw new TypeError(l.Guarantor.constructor.invalidRetriever(u));if(a&&"function"!=typeof a.then)throw new TypeError(l.Guarantor.constructor.invalidDeferrer(a));if(c&&"function"!=typeof c)throw new TypeError(l.Guarantor.constructor.invalidInitializer(c));if(v!==Promise&&"function"!=typeof(null==v||null===(n=v.prototype)||void 0===n?void 0:n.then))throw new TypeError(l.Guarantor.constructor.invalidThenableApi(v));p.set(this,r(r({defer:a,retriever:u,retrieveEarly:s,thenableApi:v,publicFulfill:b},c?{initializer:c}:{}),{},{registry:new Set,resolvers:new Map,promises:new Map})),!0===b&&Object.defineProperty(this,"fulfill",{configurable:!0,writable:!1,value:function(e,r){return y(i,p.get(i),e,r)}})}var t,i,a;return t=e,i=[{key:"get",value:function(e){var r=this,t=o(Array.from(arguments),2)[1],n=void 0!==t&&t,i=p.get(this),a=i.defer,u=i.resolvers,c=i.promises,d=i.retriever,v=i.retrieveEarly,h=i.publicFulfill,b=i.thenableApi;if("string"!=typeof e||0===e.length)return Promise.reject(new TypeError(l.Guarantor.get.requiredIdentifier(e)));var g=f(e);return s(c,g,(function(){return new b((function(t,i){u.set(g,{resolve:t,reject:i}),!0!==n&&d&&(v?Promise.resolve():a).then((function(){return d(e)})).then((function(t){if(void 0===t){if(!0===h)return;console.warn(l.Guarantor.get.undefinedGuarantee(e,t))}return y(r,p.get(r),e,t)})).catch(i)})).catch((function(r){throw console.error(l.Guarantor.get.retrieverError(e)),console.error(r),r}))}))}}],i&&n(t.prototype,i),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();module.exports=v;