import{__exports as e}from"../../../_virtual/es.promise.constructor.mjs";import{__require as r}from"../internals/export.mjs";import{__require as t}from"../internals/is-pure.mjs";import{__require as n}from"../internals/environment-is-node.mjs";import{__require as i}from"../internals/global-this.mjs";import{__require as o}from"../internals/path.mjs";import{__require as s}from"../internals/function-call.mjs";import{__require as a}from"../internals/define-built-in.mjs";import{__require as m}from"../internals/object-set-prototype-of.mjs";import{__require as c}from"../internals/set-to-string-tag.mjs";import{__require as u}from"../internals/set-species.mjs";import{__require as f}from"../internals/a-callable.mjs";import{__require as p}from"../internals/is-callable.mjs";import{__require as l}from"../internals/is-object.mjs";import{__require as _}from"../internals/an-instance.mjs";import{__require as j}from"../internals/species-constructor.mjs";import{__require as d}from"../internals/task.mjs";import{__require as v}from"../internals/microtask.mjs";import{__require as h}from"../internals/host-report-errors.mjs";import{__require as q}from"../internals/perform.mjs";import{__require as y}from"../internals/queue.mjs";import{__require as E}from"../internals/internal-state.mjs";import{__require as b}from"../internals/promise-native-constructor.mjs";import{__require as w}from"../internals/promise-constructor-detection.mjs";import{__require as g}from"../internals/new-promise-capability.mjs";var x;function P(){if(x)return e;x=1;var P,T,k,C,N=r(),O=t(),R=n(),S=i(),U=o(),I=s(),A=a(),B=m(),F=c(),G=u(),H=f(),J=p(),L=l(),V=_(),z=j(),D=d().set,K=v(),M=h(),Q=q(),W=y(),X=E(),Y=b(),Z=w(),$=g(),ee="Promise",re=Z.CONSTRUCTOR,te=Z.REJECTION_EVENT,ne=Z.SUBCLASSING,ie=X.getterFor(ee),oe=X.set,se=Y&&Y.prototype,ae=Y,me=se,ce=S.TypeError,ue=S.document,fe=S.process,pe=$.f,le=pe,_e=!!(ue&&ue.createEvent&&S.dispatchEvent),je="unhandledrejection",de=function(e){var r;return!(!L(e)||!J(r=e.then))&&r},ve=function(e,r){var t,n,i,o=r.value,s=1===r.state,a=s?e.ok:e.fail,m=e.resolve,c=e.reject,u=e.domain;try{a?(s||(2===r.rejection&&be(r),r.rejection=1),!0===a?t=o:(u&&u.enter(),t=a(o),u&&(u.exit(),i=!0)),t===e.promise?c(new ce("Promise-chain cycle")):(n=de(t))?I(n,t,m,c):m(t)):c(o)}catch(e){u&&!i&&u.exit(),c(e)}},he=function(e,r){e.notified||(e.notified=!0,K(function(){for(var t,n=e.reactions;t=n.get();)ve(t,e);e.notified=!1,r&&!e.rejection&&ye(e)}))},qe=function(e,r,t){var n,i;_e?((n=ue.createEvent("Event")).promise=r,n.reason=t,n.initEvent(e,!1,!0),S.dispatchEvent(n)):n={promise:r,reason:t},!te&&(i=S["on"+e])?i(n):e===je&&M("Unhandled promise rejection",t)},ye=function(e){I(D,S,function(){var r,t=e.facade,n=e.value;if(Ee(e)&&(r=Q(function(){R?fe.emit("unhandledRejection",n,t):qe(je,t,n)}),e.rejection=R||Ee(e)?2:1,r.error))throw r.value})},Ee=function(e){return 1!==e.rejection&&!e.parent},be=function(e){I(D,S,function(){var r=e.facade;R?fe.emit("rejectionHandled",r):qe("rejectionhandled",r,e.value)})},we=function(e,r,t){return function(n){e(r,n,t)}},ge=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=2,he(e,!0))},xe=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw new ce("Promise can't be resolved itself");var n=de(r);n?K(function(){var t={done:!1};try{I(n,r,we(xe,t,e),we(ge,t,e))}catch(r){ge(t,r,e)}}):(e.value=r,e.state=1,he(e,!1))}catch(r){ge({done:!1},r,e)}}};if(re&&(me=(ae=function(e){V(this,me),H(e),I(P,this);var r=ie(this);try{e(we(xe,r),we(ge,r))}catch(e){ge(r,e)}}).prototype,(P=function(e){oe(this,{type:ee,done:!1,notified:!1,parent:!1,reactions:new W,rejection:!1,state:0,value:null})}).prototype=A(me,"then",function(e,r){var t=ie(this),n=pe(z(this,ae));return t.parent=!0,n.ok=!J(e)||e,n.fail=J(r)&&r,n.domain=R?fe.domain:void 0,0===t.state?t.reactions.add(n):K(function(){ve(n,t)}),n.promise}),T=function(){var e=new P,r=ie(e);this.promise=e,this.resolve=we(xe,r),this.reject=we(ge,r)},$.f=pe=function(e){return e===ae||e===k?new T(e):le(e)},!O&&J(Y)&&se!==Object.prototype)){C=se.then,ne||A(se,"then",function(e,r){var t=this;return new ae(function(e,r){I(C,t,e,r)}).then(e,r)},{unsafe:!0});try{delete se.constructor}catch(e){}B&&B(se,me)}return N({global:!0,constructor:!0,wrap:!0,forced:re},{Promise:ae}),k=U.Promise,F(ae,ee,!1,!0),G(ee),e}export{P as __require};