@netlify/agent-runner-cli 1.145.0-ex-2517.6 → 1.145.0-ex-2517.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +4 -4
- package/dist/bin.js +4 -4
- package/dist/index.js +41 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,9 +19,9 @@ ${e}`;return Object.assign(new Error(r),t,{stack:i})}var mP=class extends mye.Ev
|
|
|
19
19
|
`;this.trace(`Received server trailers:
|
|
20
20
|
`+r);let n;try{n=ns.Metadata.fromHttp2Headers(e)}catch{n=new ns.Metadata}let i=n.getMap(),o;if(typeof i["grpc-status"]=="string"){let s=Number(i["grpc-status"]);this.trace("received status code "+s+" from server"),n.remove("grpc-status");let a="";if(typeof i["grpc-message"]=="string"){try{a=decodeURI(i["grpc-message"])}catch{a=i["grpc-message"]}n.remove("grpc-message"),this.trace('received status details string "'+a+'" from server')}o={code:s,details:a,metadata:n}}else this.httpStatusCode?(o=_N(this.httpStatusCode),o.metadata=n):o={code:et.Status.UNKNOWN,details:"No status information received",metadata:n};this.endCall(o)}destroyHttp2Stream(){var e;if(!this.http2Stream.destroyed)if(this.serverEndedCall)this.http2Stream.end();else{let r;((e=this.finalStatus)===null||e===void 0?void 0:e.code)===et.Status.OK?r=rs.constants.NGHTTP2_NO_ERROR:r=rs.constants.NGHTTP2_CANCEL,this.trace("close http2 stream with code "+r),this.http2Stream.close(r)}}cancelWithStatus(e,r){this.trace("cancelWithStatus code: "+e+' details: "'+r+'"'),this.endCall({code:e,details:r,metadata:new ns.Metadata})}getStatus(){return this.finalStatus}getPeer(){return this.transport.getPeerName()}getCallNumber(){return this.callId}getAuthContext(){return this.transport.getAuthContext()}startRead(){if(this.finalStatus!==null&&this.finalStatus.code!==et.Status.OK){this.readsClosed=!0,this.maybeOutputStatus();return}if(this.canPush=!0,this.unpushedReadMessages.length>0){let e=this.unpushedReadMessages.shift();this.push(e);return}this.http2Stream.resume()}sendMessageWithContext(e,r){this.trace("write() called with message of length "+r.length);let n=i=>{process.nextTick(()=>{var o;let s=et.Status.UNAVAILABLE;i?.code==="ERR_STREAM_WRITE_AFTER_END"&&(s=et.Status.INTERNAL),i&&this.cancelWithStatus(s,`Write error: ${i.message}`),(o=e.callback)===null||o===void 0||o.call(e)})};this.trace("sending data chunk of length "+r.length),this.callEventTracker.addMessageSent();try{this.http2Stream.write(r,n)}catch(i){this.endCall({code:et.Status.UNAVAILABLE,details:`Write failed with error ${i.message}`,metadata:new ns.Metadata})}}halfClose(){this.trace("end() called"),this.trace("calling end() on HTTP/2 stream"),this.http2Stream.end()}};Eb.Http2SubchannelCall=yN});var A8=b(Tb=>{"use strict";Object.defineProperty(Tb,"__esModule",{value:!0});Tb.Http2SubchannelConnector=void 0;var cl=Z("http2"),Ube=Z("tls"),vb=_a(),dg=je(),Fbe=hN(),Sd=st(),Bbe=ni(),bb=zr(),SN=Rr(),jbe=Z("net"),zbe=w8(),Gbe=ab(),EN="transport",qbe="transport_flowctrl",Vbe=j0().version,{HTTP2_HEADER_AUTHORITY:Hbe,HTTP2_HEADER_CONTENT_TYPE:Wbe,HTTP2_HEADER_METHOD:Ybe,HTTP2_HEADER_PATH:Kbe,HTTP2_HEADER_TE:Zbe,HTTP2_HEADER_USER_AGENT:Jbe}=cl.constants,Xbe=2e4,Qbe=Buffer.from("too_many_pings","ascii"),vN=class{constructor(e,r,n,i){this.session=e,this.options=n,this.remoteName=i,this.keepaliveTimer=null,this.pendingSendKeepalivePing=!1,this.activeCalls=new Set,this.disconnectListeners=[],this.disconnectHandled=!1,this.channelzEnabled=!0,this.keepalivesSent=0,this.messagesSent=0,this.messagesReceived=0,this.lastMessageSentTimestamp=null,this.lastMessageReceivedTimestamp=null,this.subchannelAddressString=(0,bb.subchannelAddressToString)(r),n["grpc.enable_channelz"]===0?(this.channelzEnabled=!1,this.streamTracker=new vb.ChannelzCallTrackerStub):this.streamTracker=new vb.ChannelzCallTracker,this.channelzRef=(0,vb.registerChannelzSocket)(this.subchannelAddressString,()=>this.getChannelzInfo(),this.channelzEnabled),this.userAgent=[n["grpc.primary_user_agent"],`grpc-node-js/${Vbe}`,n["grpc.secondary_user_agent"]].filter(o=>o).join(" "),"grpc.keepalive_time_ms"in n?this.keepaliveTimeMs=n["grpc.keepalive_time_ms"]:this.keepaliveTimeMs=-1,"grpc.keepalive_timeout_ms"in n?this.keepaliveTimeoutMs=n["grpc.keepalive_timeout_ms"]:this.keepaliveTimeoutMs=Xbe,"grpc.keepalive_permit_without_calls"in n?this.keepaliveWithoutCalls=n["grpc.keepalive_permit_without_calls"]===1:this.keepaliveWithoutCalls=!1,e.once("close",()=>{this.trace("session closed"),this.handleDisconnect()}),e.once("goaway",(o,s,a)=>{let c=!1;o===cl.constants.NGHTTP2_ENHANCE_YOUR_CALM&&a&&a.equals(Qbe)&&(c=!0),this.trace("connection closed by GOAWAY with code "+o+" and data "+a?.toString()),this.reportDisconnectToOwner(c)}),e.once("error",o=>{this.trace("connection closed with error "+o.message),this.handleDisconnect()}),e.socket.once("close",o=>{this.trace("connection closed. hadError="+o),this.handleDisconnect()}),Sd.isTracerEnabled(EN)&&(e.on("remoteSettings",o=>{this.trace("new settings received"+(this.session!==e?" on the old connection":"")+": "+JSON.stringify(o))}),e.on("localSettings",o=>{this.trace("local settings acknowledged by remote"+(this.session!==e?" on the old connection":"")+": "+JSON.stringify(o))})),this.keepaliveWithoutCalls&&this.maybeStartKeepalivePingTimer(),e.socket instanceof Ube.TLSSocket?this.authContext={transportSecurityType:"ssl",sslPeerCertificate:e.socket.getPeerCertificate()}:this.authContext={}}getChannelzInfo(){var e,r,n;let i=this.session.socket,o=i.remoteAddress?(0,bb.stringToSubchannelAddress)(i.remoteAddress,i.remotePort):null,s=i.localAddress?(0,bb.stringToSubchannelAddress)(i.localAddress,i.localPort):null,a;if(this.session.encrypted){let l=i,u=l.getCipher(),d=l.getCertificate(),f=l.getPeerCertificate();a={cipherSuiteStandardName:(e=u.standardName)!==null&&e!==void 0?e:null,cipherSuiteOtherName:u.standardName?null:u.name,localCertificate:d&&"raw"in d?d.raw:null,remoteCertificate:f&&"raw"in f?f.raw:null}}else a=null;return{remoteAddress:o,localAddress:s,security:a,remoteName:this.remoteName,streamsStarted:this.streamTracker.callsStarted,streamsSucceeded:this.streamTracker.callsSucceeded,streamsFailed:this.streamTracker.callsFailed,messagesSent:this.messagesSent,messagesReceived:this.messagesReceived,keepAlivesSent:this.keepalivesSent,lastLocalStreamCreatedTimestamp:this.streamTracker.lastCallStartedTimestamp,lastRemoteStreamCreatedTimestamp:null,lastMessageSentTimestamp:this.lastMessageSentTimestamp,lastMessageReceivedTimestamp:this.lastMessageReceivedTimestamp,localFlowControlWindow:(r=this.session.state.localWindowSize)!==null&&r!==void 0?r:null,remoteFlowControlWindow:(n=this.session.state.remoteWindowSize)!==null&&n!==void 0?n:null}}trace(e){Sd.trace(dg.LogVerbosity.DEBUG,EN,"("+this.channelzRef.id+") "+this.subchannelAddressString+" "+e)}keepaliveTrace(e){Sd.trace(dg.LogVerbosity.DEBUG,"keepalive","("+this.channelzRef.id+") "+this.subchannelAddressString+" "+e)}flowControlTrace(e){Sd.trace(dg.LogVerbosity.DEBUG,qbe,"("+this.channelzRef.id+") "+this.subchannelAddressString+" "+e)}internalsTrace(e){Sd.trace(dg.LogVerbosity.DEBUG,"transport_internals","("+this.channelzRef.id+") "+this.subchannelAddressString+" "+e)}reportDisconnectToOwner(e){this.disconnectHandled||(this.disconnectHandled=!0,this.disconnectListeners.forEach(r=>r(e)))}handleDisconnect(){this.clearKeepaliveTimeout(),this.reportDisconnectToOwner(!1);for(let e of this.activeCalls)e.onDisconnect();setImmediate(()=>{this.session.destroy()})}addDisconnectListener(e){this.disconnectListeners.push(e)}canSendPing(){return!this.session.destroyed&&this.keepaliveTimeMs>0&&(this.keepaliveWithoutCalls||this.activeCalls.size>0)}maybeSendPing(){var e,r;if(!this.canSendPing()){this.pendingSendKeepalivePing=!0;return}if(this.keepaliveTimer){console.error("keepaliveTimeout is not null");return}this.channelzEnabled&&(this.keepalivesSent+=1),this.keepaliveTrace("Sending ping with timeout "+this.keepaliveTimeoutMs+"ms"),this.keepaliveTimer=setTimeout(()=>{this.keepaliveTimer=null,this.keepaliveTrace("Ping timeout passed without response"),this.handleDisconnect()},this.keepaliveTimeoutMs),(r=(e=this.keepaliveTimer).unref)===null||r===void 0||r.call(e);let n="";try{this.session.ping((o,s,a)=>{this.clearKeepaliveTimeout(),o?(this.keepaliveTrace("Ping failed with error "+o.message),this.handleDisconnect()):(this.keepaliveTrace("Received ping response"),this.maybeStartKeepalivePingTimer())})||(n="Ping returned false")}catch(i){n=(i instanceof Error?i.message:"")||"Unknown error"}n&&(this.keepaliveTrace("Ping send failed: "+n),this.handleDisconnect())}maybeStartKeepalivePingTimer(){var e,r;this.canSendPing()&&(this.pendingSendKeepalivePing?(this.pendingSendKeepalivePing=!1,this.maybeSendPing()):this.keepaliveTimer||(this.keepaliveTrace("Starting keepalive timer for "+this.keepaliveTimeMs+"ms"),this.keepaliveTimer=setTimeout(()=>{this.keepaliveTimer=null,this.maybeSendPing()},this.keepaliveTimeMs),(r=(e=this.keepaliveTimer).unref)===null||r===void 0||r.call(e)))}clearKeepaliveTimeout(){this.keepaliveTimer&&(clearTimeout(this.keepaliveTimer),this.keepaliveTimer=null)}removeActiveCall(e){this.activeCalls.delete(e),this.activeCalls.size===0&&this.session.unref()}addActiveCall(e){this.activeCalls.add(e),this.activeCalls.size===1&&(this.session.ref(),this.keepaliveWithoutCalls||this.maybeStartKeepalivePingTimer())}createCall(e,r,n,i,o){let s=e.toHttp2Headers();s[Hbe]=r,s[Jbe]=this.userAgent,s[Wbe]="application/grpc",s[Ybe]="POST",s[Kbe]=n,s[Zbe]="trailers";let a;try{a=this.session.request(s)}catch(u){throw this.handleDisconnect(),u}this.flowControlTrace("local window size: "+this.session.state.localWindowSize+" remote window size: "+this.session.state.remoteWindowSize),this.internalsTrace("session.closed="+this.session.closed+" session.destroyed="+this.session.destroyed+" session.socket.destroyed="+this.session.socket.destroyed);let c,l;return this.channelzEnabled?(this.streamTracker.addCallStarted(),c={addMessageSent:()=>{var u;this.messagesSent+=1,this.lastMessageSentTimestamp=new Date,(u=o.addMessageSent)===null||u===void 0||u.call(o)},addMessageReceived:()=>{var u;this.messagesReceived+=1,this.lastMessageReceivedTimestamp=new Date,(u=o.addMessageReceived)===null||u===void 0||u.call(o)},onCallEnd:u=>{var d;(d=o.onCallEnd)===null||d===void 0||d.call(o,u),this.removeActiveCall(l)},onStreamEnd:u=>{var d;u?this.streamTracker.addCallSucceeded():this.streamTracker.addCallFailed(),(d=o.onStreamEnd)===null||d===void 0||d.call(o,u)}}):c={addMessageSent:()=>{var u;(u=o.addMessageSent)===null||u===void 0||u.call(o)},addMessageReceived:()=>{var u;(u=o.addMessageReceived)===null||u===void 0||u.call(o)},onCallEnd:u=>{var d;(d=o.onCallEnd)===null||d===void 0||d.call(o,u),this.removeActiveCall(l)},onStreamEnd:u=>{var d;(d=o.onStreamEnd)===null||d===void 0||d.call(o,u)}},l=new zbe.Http2SubchannelCall(a,c,i,this,(0,Gbe.getNextCallNumber)()),this.addActiveCall(l),l}getChannelzRef(){return this.channelzRef}getPeerName(){return this.subchannelAddressString}getOptions(){return this.options}getAuthContext(){return this.authContext}shutdown(){this.session.close(),(0,vb.unregisterChannelzRef)(this.channelzRef)}},bN=class{constructor(e){this.channelTarget=e,this.session=null,this.isShutdown=!1}trace(e){Sd.trace(dg.LogVerbosity.DEBUG,EN,(0,SN.uriToString)(this.channelTarget)+" "+e)}createSession(e,r,n){return this.isShutdown?Promise.reject():e.socket.closed?Promise.reject("Connection closed before starting HTTP/2 handshake"):new Promise((i,o)=>{var s,a,c,l,u,d,f,p;let h=null,m=this.channelTarget;if("grpc.http_connect_target"in n){let j=(0,SN.parseUri)(n["grpc.http_connect_target"]);j&&(m=j,h=(0,SN.uriToString)(j))}let y=e.secure?"https":"http",S=(0,Bbe.getDefaultAuthority)(m),T=()=>{var j;(j=this.session)===null||j===void 0||j.destroy(),this.session=null,setImmediate(()=>{D||(D=!0,o(`${C.trim()} (${new Date().toISOString()})`))})},x=j=>{var _;(_=this.session)===null||_===void 0||_.destroy(),C=j.message,this.trace("connection failed with error "+C),D||(D=!0,o(`${C} (${new Date().toISOString()})`))},v={createConnection:(j,_)=>e.socket,settings:{initialWindowSize:(l=(s=n["grpc-node.flow_control_window"])!==null&&s!==void 0?s:(c=(a=cl.getDefaultSettings)===null||a===void 0?void 0:a.call(cl))===null||c===void 0?void 0:c.initialWindowSize)!==null&&l!==void 0?l:65535},maxSendHeaderBlockLength:Number.MAX_SAFE_INTEGER,maxSessionMemory:(u=n["grpc-node.max_session_memory"])!==null&&u!==void 0?u:Number.MAX_SAFE_INTEGER},N=cl.connect(`${y}://${S}`,v),R=(p=(f=(d=cl.getDefaultSettings)===null||d===void 0?void 0:d.call(cl))===null||f===void 0?void 0:f.initialWindowSize)!==null&&p!==void 0?p:65535,U=n["grpc-node.flow_control_window"];this.session=N;let C="Failed to connect",D=!1;N.unref(),N.once("remoteSettings",()=>{var j;if(U&&U>R)try{N.setLocalWindowSize(U)}catch{let ae=U-((j=N.state.localWindowSize)!==null&&j!==void 0?j:R);ae>0&&N.incrementWindowSize(ae)}N.removeAllListeners(),e.socket.removeListener("close",T),e.socket.removeListener("error",x),i(new vN(N,r,n,h)),this.session=null}),N.once("close",T),N.once("error",x),e.socket.once("close",T),e.socket.once("error",x)})}tcpConnect(e,r){return(0,Fbe.getProxiedConnection)(e,r).then(n=>n||new Promise((i,o)=>{let s=()=>{o(new Error("Socket closed"))},a=l=>{o(l)},c=jbe.connect(e,()=>{c.removeListener("close",s),c.removeListener("error",a),i(c)});c.once("close",s),c.once("error",a)}))}async connect(e,r,n){if(this.isShutdown)return Promise.reject();let i=null,o=null,s=(0,bb.subchannelAddressToString)(e);try{return this.trace(s+" Waiting for secureConnector to be ready"),await r.waitForReady(),this.trace(s+" secureConnector is ready"),i=await this.tcpConnect(e,n),i.setNoDelay(),this.trace(s+" Established TCP connection"),o=await r.connect(i),this.trace(s+" Established secure connection"),this.createSession(o,e,n)}catch(a){throw i?.destroy(),o?.socket.destroy(),a}}shutdown(){var e;this.isShutdown=!0,(e=this.session)===null||e===void 0||e.close(),this.session=null}};Tb.Http2SubchannelConnector=bN});var R8=b(pg=>{"use strict";Object.defineProperty(pg,"__esModule",{value:!0});pg.SubchannelPool=void 0;pg.getSubchannelPool=aTe;var eTe=JH(),tTe=g8(),rTe=zr(),nTe=Rr(),iTe=A8(),oTe=1e4,fg=class{constructor(){this.pool=Object.create(null),this.cleanupTimer=null}unrefUnusedSubchannels(){let e=!0;for(let r in this.pool){let i=this.pool[r].filter(o=>!o.subchannel.unrefIfOneRef());i.length>0&&(e=!1),this.pool[r]=i}e&&this.cleanupTimer!==null&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null)}ensureCleanupTask(){var e,r;this.cleanupTimer===null&&(this.cleanupTimer=setInterval(()=>{this.unrefUnusedSubchannels()},oTe),(r=(e=this.cleanupTimer).unref)===null||r===void 0||r.call(e))}getOrCreateSubchannel(e,r,n,i){this.ensureCleanupTask();let o=(0,nTe.uriToString)(e);if(o in this.pool){let a=this.pool[o];for(let c of a)if((0,rTe.subchannelAddressEqual)(r,c.subchannelAddress)&&(0,eTe.channelOptionsEqual)(n,c.channelArguments)&&i._equals(c.channelCredentials))return c.subchannel}let s=new tTe.Subchannel(e,r,n,i,new iTe.Http2SubchannelConnector(e));return o in this.pool||(this.pool[o]=[]),this.pool[o].push({subchannelAddress:r,channelArguments:n,channelCredentials:i,subchannel:s}),s.ref(),s}};pg.SubchannelPool=fg;var sTe=new fg;function aTe(t){return t?sTe:new fg}});var P8=b(Ab=>{"use strict";Object.defineProperty(Ab,"__esModule",{value:!0});Ab.LoadBalancingCall=void 0;var I8=Ir(),xb=je(),C8=hd(),wb=Wt(),hg=Ho(),cTe=Rr(),lTe=st(),TN=og(),uTe=Z("http2"),dTe="load_balancing_call",xN=class{constructor(e,r,n,i,o,s,a){var c,l;this.channel=e,this.callConfig=r,this.methodName=n,this.host=i,this.credentials=o,this.deadline=s,this.callNumber=a,this.child=null,this.readPending=!1,this.pendingMessage=null,this.pendingHalfClose=!1,this.ended=!1,this.metadata=null,this.listener=null,this.onCallEnded=null,this.childStartTime=null;let u=this.methodName.split("/"),d="";u.length>=2&&(d=u[1]);let f=(l=(c=(0,cTe.splitHostPort)(this.host))===null||c===void 0?void 0:c.host)!==null&&l!==void 0?l:"localhost";this.serviceUrl=`https://${f}/${d}`,this.startTime=new Date}getDeadlineInfo(){var e,r;let n=[];return this.childStartTime?(this.childStartTime>this.startTime&&(!((e=this.metadata)===null||e===void 0)&&e.getOptions().waitForReady&&n.push("wait_for_ready"),n.push(`LB pick: ${(0,C8.formatDateDifference)(this.startTime,this.childStartTime)}`)),n.push(...this.child.getDeadlineInfo()),n):(!((r=this.metadata)===null||r===void 0)&&r.getOptions().waitForReady&&n.push("wait_for_ready"),n.push("Waiting for LB pick"),n)}trace(e){lTe.trace(xb.LogVerbosity.DEBUG,dTe,"["+this.callNumber+"] "+e)}outputStatus(e,r){var n,i;if(!this.ended){this.ended=!0,this.trace("ended with status: code="+e.code+' details="'+e.details+'" start time='+this.startTime.toISOString());let o=Object.assign(Object.assign({},e),{progress:r});(n=this.listener)===null||n===void 0||n.onReceiveStatus(o),(i=this.onCallEnded)===null||i===void 0||i.call(this,o.code,o.details,o.metadata)}}doPick(){var e,r;if(this.ended)return;if(!this.metadata)throw new Error("doPick called before start");this.trace("Pick called");let n=this.metadata.clone(),i=this.channel.doPick(n,this.callConfig.pickInformation),o=i.subchannel?"("+i.subchannel.getChannelzRef().id+") "+i.subchannel.getAddress():""+i.subchannel;switch(this.trace("Pick result: "+hg.PickResultType[i.pickResultType]+" subchannel: "+o+" status: "+((e=i.status)===null||e===void 0?void 0:e.code)+" "+((r=i.status)===null||r===void 0?void 0:r.details)),i.pickResultType){case hg.PickResultType.COMPLETE:this.credentials.compose(i.subchannel.getCallCredentials()).generateMetadata({method_name:this.methodName,service_url:this.serviceUrl}).then(l=>{var u;if(this.ended){this.trace("Credentials metadata generation finished after call ended");return}if(n.merge(l),n.get("authorization").length>1&&this.outputStatus({code:xb.Status.INTERNAL,details:'"authorization" metadata cannot have multiple values',metadata:new wb.Metadata},"PROCESSED"),i.subchannel.getConnectivityState()!==I8.ConnectivityState.READY){this.trace("Picked subchannel "+o+" has state "+I8.ConnectivityState[i.subchannel.getConnectivityState()]+" after getting credentials metadata. Retrying pick"),this.doPick();return}this.deadline!==1/0&&n.set("grpc-timeout",(0,C8.getDeadlineTimeoutString)(this.deadline));try{this.child=i.subchannel.getRealSubchannel().createCall(n,this.host,this.methodName,{onReceiveMetadata:d=>{this.trace("Received metadata"),this.listener.onReceiveMetadata(d)},onReceiveMessage:d=>{this.trace("Received message"),this.listener.onReceiveMessage(d)},onReceiveStatus:d=>{this.trace("Received status"),d.rstCode===uTe.constants.NGHTTP2_REFUSED_STREAM?this.outputStatus(d,"REFUSED"):this.outputStatus(d,"PROCESSED")}}),this.childStartTime=new Date}catch(d){this.trace("Failed to start call on picked subchannel "+o+" with error "+d.message),this.outputStatus({code:xb.Status.INTERNAL,details:"Failed to start HTTP/2 stream with error "+d.message,metadata:new wb.Metadata},"NOT_STARTED");return}(u=i.onCallStarted)===null||u===void 0||u.call(i),this.onCallEnded=i.onCallEnded,this.trace("Created child call ["+this.child.getCallNumber()+"]"),this.readPending&&this.child.startRead(),this.pendingMessage&&this.child.sendMessageWithContext(this.pendingMessage.context,this.pendingMessage.message),this.pendingHalfClose&&this.child.halfClose()},l=>{let{code:u,details:d}=(0,TN.restrictControlPlaneStatusCode)(typeof l.code=="number"?l.code:xb.Status.UNKNOWN,`Getting metadata from plugin failed with error: ${l.message}`);this.outputStatus({code:u,details:d,metadata:new wb.Metadata},"PROCESSED")});break;case hg.PickResultType.DROP:let{code:a,details:c}=(0,TN.restrictControlPlaneStatusCode)(i.status.code,i.status.details);setImmediate(()=>{this.outputStatus({code:a,details:c,metadata:i.status.metadata},"DROP")});break;case hg.PickResultType.TRANSIENT_FAILURE:if(this.metadata.getOptions().waitForReady)this.channel.queueCallForPick(this);else{let{code:l,details:u}=(0,TN.restrictControlPlaneStatusCode)(i.status.code,i.status.details);setImmediate(()=>{this.outputStatus({code:l,details:u,metadata:i.status.metadata},"PROCESSED")})}break;case hg.PickResultType.QUEUE:this.channel.queueCallForPick(this)}}cancelWithStatus(e,r){var n;this.trace("cancelWithStatus code: "+e+' details: "'+r+'"'),(n=this.child)===null||n===void 0||n.cancelWithStatus(e,r),this.outputStatus({code:e,details:r,metadata:new wb.Metadata},"PROCESSED")}getPeer(){var e,r;return(r=(e=this.child)===null||e===void 0?void 0:e.getPeer())!==null&&r!==void 0?r:this.channel.getTarget()}start(e,r){this.trace("start called"),this.listener=r,this.metadata=e,this.doPick()}sendMessageWithContext(e,r){this.trace("write() called with message of length "+r.length),this.child?this.child.sendMessageWithContext(e,r):this.pendingMessage={context:e,message:r}}startRead(){this.trace("startRead called"),this.child?this.child.startRead():this.readPending=!0}halfClose(){this.trace("halfClose called"),this.child?this.child.halfClose():this.pendingHalfClose=!0}setCredentials(e){throw new Error("Method not implemented.")}getCallNumber(){return this.callNumber}getAuthContext(){return this.child?this.child.getAuthContext():null}};Ab.LoadBalancingCall=xN});var N8=b(Rb=>{"use strict";Object.defineProperty(Rb,"__esModule",{value:!0});Rb.ResolvingCall=void 0;var fTe=ov(),ll=je(),ul=hd(),O8=Wt(),pTe=st(),hTe=og(),mTe="resolving_call",wN=class{constructor(e,r,n,i,o){this.channel=e,this.method=r,this.filterStackFactory=i,this.callNumber=o,this.child=null,this.readPending=!1,this.pendingMessage=null,this.pendingHalfClose=!1,this.ended=!1,this.readFilterPending=!1,this.writeFilterPending=!1,this.pendingChildStatus=null,this.metadata=null,this.listener=null,this.statusWatchers=[],this.deadlineTimer=setTimeout(()=>{},0),this.filterStack=null,this.deadlineStartTime=null,this.configReceivedTime=null,this.childStartTime=null,this.credentials=fTe.CallCredentials.createEmpty(),this.deadline=n.deadline,this.host=n.host,n.parentCall&&(n.flags&ll.Propagate.CANCELLATION&&n.parentCall.on("cancelled",()=>{this.cancelWithStatus(ll.Status.CANCELLED,"Cancelled by parent call")}),n.flags&ll.Propagate.DEADLINE&&(this.trace("Propagating deadline from parent: "+n.parentCall.getDeadline()),this.deadline=(0,ul.minDeadline)(this.deadline,n.parentCall.getDeadline()))),this.trace("Created"),this.runDeadlineTimer()}trace(e){pTe.trace(ll.LogVerbosity.DEBUG,mTe,"["+this.callNumber+"] "+e)}runDeadlineTimer(){clearTimeout(this.deadlineTimer),this.deadlineStartTime=new Date,this.trace("Deadline: "+(0,ul.deadlineToString)(this.deadline));let e=(0,ul.getRelativeTimeout)(this.deadline);if(e!==1/0){this.trace("Deadline will be reached in "+e+"ms");let r=()=>{if(!this.deadlineStartTime){this.cancelWithStatus(ll.Status.DEADLINE_EXCEEDED,"Deadline exceeded");return}let n=[],i=new Date;n.push(`Deadline exceeded after ${(0,ul.formatDateDifference)(this.deadlineStartTime,i)}`),this.configReceivedTime?(this.configReceivedTime>this.deadlineStartTime&&n.push(`name resolution: ${(0,ul.formatDateDifference)(this.deadlineStartTime,this.configReceivedTime)}`),this.childStartTime?this.childStartTime>this.configReceivedTime&&n.push(`metadata filters: ${(0,ul.formatDateDifference)(this.configReceivedTime,this.childStartTime)}`):n.push("waiting for metadata filters")):n.push("waiting for name resolution"),this.child&&n.push(...this.child.getDeadlineInfo()),this.cancelWithStatus(ll.Status.DEADLINE_EXCEEDED,n.join(","))};e<=0?process.nextTick(r):this.deadlineTimer=setTimeout(r,e)}}outputStatus(e){if(!this.ended){this.ended=!0,this.filterStack||(this.filterStack=this.filterStackFactory.createFilter()),clearTimeout(this.deadlineTimer);let r=this.filterStack.receiveTrailers(e);this.trace("ended with status: code="+r.code+' details="'+r.details+'"'),this.statusWatchers.forEach(n=>n(r)),process.nextTick(()=>{var n;(n=this.listener)===null||n===void 0||n.onReceiveStatus(r)})}}sendMessageOnChild(e,r){if(!this.child)throw new Error("sendMessageonChild called with child not populated");let n=this.child;this.writeFilterPending=!0,this.filterStack.sendMessage(Promise.resolve({message:r,flags:e.flags})).then(i=>{this.writeFilterPending=!1,n.sendMessageWithContext(e,i.message),this.pendingHalfClose&&n.halfClose()},i=>{this.cancelWithStatus(i.code,i.details)})}getConfig(){if(this.ended)return;if(!this.metadata||!this.listener)throw new Error("getConfig called before start");let e=this.channel.getConfig(this.method,this.metadata);if(e.type==="NONE"){this.channel.queueCallForConfig(this);return}else if(e.type==="ERROR"){this.metadata.getOptions().waitForReady?this.channel.queueCallForConfig(this):this.outputStatus(e.error);return}this.configReceivedTime=new Date;let r=e.config;if(r.status!==ll.Status.OK){let{code:n,details:i}=(0,hTe.restrictControlPlaneStatusCode)(r.status,"Failed to route call to method "+this.method);this.outputStatus({code:n,details:i,metadata:new O8.Metadata});return}if(r.methodConfig.timeout){let n=new Date;n.setSeconds(n.getSeconds()+r.methodConfig.timeout.seconds),n.setMilliseconds(n.getMilliseconds()+r.methodConfig.timeout.nanos/1e6),this.deadline=(0,ul.minDeadline)(this.deadline,n),this.runDeadlineTimer()}this.filterStackFactory.push(r.dynamicFilterFactories),this.filterStack=this.filterStackFactory.createFilter(),this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then(n=>{this.child=this.channel.createRetryingCall(r,this.method,this.host,this.credentials,this.deadline),this.trace("Created child ["+this.child.getCallNumber()+"]"),this.childStartTime=new Date,this.child.start(n,{onReceiveMetadata:i=>{this.trace("Received metadata"),this.listener.onReceiveMetadata(this.filterStack.receiveMetadata(i))},onReceiveMessage:i=>{this.trace("Received message"),this.readFilterPending=!0,this.filterStack.receiveMessage(i).then(o=>{this.trace("Finished filtering received message"),this.readFilterPending=!1,this.listener.onReceiveMessage(o),this.pendingChildStatus&&this.outputStatus(this.pendingChildStatus)},o=>{this.cancelWithStatus(o.code,o.details)})},onReceiveStatus:i=>{this.trace("Received status"),this.readFilterPending?this.pendingChildStatus=i:this.outputStatus(i)}}),this.readPending&&this.child.startRead(),this.pendingMessage?this.sendMessageOnChild(this.pendingMessage.context,this.pendingMessage.message):this.pendingHalfClose&&this.child.halfClose()},n=>{this.outputStatus(n)})}reportResolverError(e){var r;!((r=this.metadata)===null||r===void 0)&&r.getOptions().waitForReady?this.channel.queueCallForConfig(this):this.outputStatus(e)}cancelWithStatus(e,r){var n;this.trace("cancelWithStatus code: "+e+' details: "'+r+'"'),(n=this.child)===null||n===void 0||n.cancelWithStatus(e,r),this.outputStatus({code:e,details:r,metadata:new O8.Metadata})}getPeer(){var e,r;return(r=(e=this.child)===null||e===void 0?void 0:e.getPeer())!==null&&r!==void 0?r:this.channel.getTarget()}start(e,r){this.trace("start called"),this.metadata=e.clone(),this.listener=r,this.getConfig()}sendMessageWithContext(e,r){this.trace("write() called with message of length "+r.length),this.child?this.sendMessageOnChild(e,r):this.pendingMessage={context:e,message:r}}startRead(){this.trace("startRead called"),this.child?this.child.startRead():this.readPending=!0}halfClose(){this.trace("halfClose called"),this.child&&!this.writeFilterPending?this.child.halfClose():this.pendingHalfClose=!0}setCredentials(e){this.credentials=e}addStatusWatcher(e){this.statusWatchers.push(e)}getCallNumber(){return this.callNumber}getAuthContext(){return this.child?this.child.getAuthContext():null}};Rb.ResolvingCall=wN});var k8=b(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.RetryingCall=Ea.MessageBufferTracker=Ea.RetryThrottler=void 0;var Ib=je(),gTe=hd(),_Te=Wt(),yTe=st(),STe="retrying_call",RN=class{constructor(e,r,n){this.maxTokens=e,this.tokenRatio=r,n?this.tokens=n.tokens*(e/n.maxTokens):this.tokens=e}addCallSucceeded(){this.tokens=Math.min(this.tokens+this.tokenRatio,this.maxTokens)}addCallFailed(){this.tokens=Math.max(this.tokens-1,0)}canRetryCall(){return this.tokens>this.maxTokens/2}};Ea.RetryThrottler=RN;var IN=class{constructor(e,r){this.totalLimit=e,this.limitPerCall=r,this.totalAllocated=0,this.allocatedPerCall=new Map}allocate(e,r){var n;let i=(n=this.allocatedPerCall.get(r))!==null&&n!==void 0?n:0;return this.limitPerCall-i<e||this.totalLimit-this.totalAllocated<e?!1:(this.allocatedPerCall.set(r,i+e),this.totalAllocated+=e,!0)}free(e,r){var n;if(this.totalAllocated<e)throw new Error(`Invalid buffer allocation state: call ${r} freed ${e} > total allocated ${this.totalAllocated}`);this.totalAllocated-=e;let i=(n=this.allocatedPerCall.get(r))!==null&&n!==void 0?n:0;if(i<e)throw new Error(`Invalid buffer allocation state: call ${r} freed ${e} > allocated for call ${i}`);this.allocatedPerCall.set(r,i-e)}freeAll(e){var r;let n=(r=this.allocatedPerCall.get(e))!==null&&r!==void 0?r:0;if(this.totalAllocated<n)throw new Error(`Invalid buffer allocation state: call ${e} allocated ${n} > total allocated ${this.totalAllocated}`);this.totalAllocated-=n,this.allocatedPerCall.delete(e)}};Ea.MessageBufferTracker=IN;var AN="grpc-previous-rpc-attempts",ETe=5,CN=class{constructor(e,r,n,i,o,s,a,c,l){var u;this.channel=e,this.callConfig=r,this.methodName=n,this.host=i,this.credentials=o,this.deadline=s,this.callNumber=a,this.bufferTracker=c,this.retryThrottler=l,this.listener=null,this.initialMetadata=null,this.underlyingCalls=[],this.writeBuffer=[],this.writeBufferOffset=0,this.readStarted=!1,this.transparentRetryUsed=!1,this.attempts=0,this.hedgingTimer=null,this.committedCallIndex=null,this.initialRetryBackoffSec=0,this.nextRetryBackoffSec=0;let d=(u=e.getOptions()["grpc-node.retry_max_attempts_limit"])!==null&&u!==void 0?u:ETe;if(e.getOptions()["grpc.enable_retries"]===0)this.state="NO_RETRY",this.maxAttempts=1;else if(r.methodConfig.retryPolicy){this.state="RETRY";let f=r.methodConfig.retryPolicy;this.nextRetryBackoffSec=this.initialRetryBackoffSec=Number(f.initialBackoff.substring(0,f.initialBackoff.length-1)),this.maxAttempts=Math.min(f.maxAttempts,d)}else r.methodConfig.hedgingPolicy?(this.state="HEDGING",this.maxAttempts=Math.min(r.methodConfig.hedgingPolicy.maxAttempts,d)):(this.state="TRANSPARENT_ONLY",this.maxAttempts=1);this.startTime=new Date}getDeadlineInfo(){if(this.underlyingCalls.length===0)return[];let e=[],r=this.underlyingCalls[this.underlyingCalls.length-1];return this.underlyingCalls.length>1&&e.push(`previous attempts: ${this.underlyingCalls.length-1}`),r.startTime>this.startTime&&e.push(`time to current attempt start: ${(0,gTe.formatDateDifference)(this.startTime,r.startTime)}`),e.push(...r.call.getDeadlineInfo()),e}getCallNumber(){return this.callNumber}trace(e){yTe.trace(Ib.LogVerbosity.DEBUG,STe,"["+this.callNumber+"] "+e)}reportStatus(e){this.trace("ended with status: code="+e.code+' details="'+e.details+'" start time='+this.startTime.toISOString()),this.bufferTracker.freeAll(this.callNumber),this.writeBufferOffset=this.writeBufferOffset+this.writeBuffer.length,this.writeBuffer=[],process.nextTick(()=>{var r;(r=this.listener)===null||r===void 0||r.onReceiveStatus({code:e.code,details:e.details,metadata:e.metadata})})}cancelWithStatus(e,r){this.trace("cancelWithStatus code: "+e+' details: "'+r+'"'),this.reportStatus({code:e,details:r,metadata:new _Te.Metadata});for(let{call:n}of this.underlyingCalls)n.cancelWithStatus(e,r)}getPeer(){return this.committedCallIndex!==null?this.underlyingCalls[this.committedCallIndex].call.getPeer():"unknown"}getBufferEntry(e){var r;return(r=this.writeBuffer[e-this.writeBufferOffset])!==null&&r!==void 0?r:{entryType:"FREED",allocated:!1}}getNextBufferIndex(){return this.writeBufferOffset+this.writeBuffer.length}clearSentMessages(){if(this.state!=="COMMITTED")return;let e;this.underlyingCalls[this.committedCallIndex].state==="COMPLETED"?e=this.getNextBufferIndex():e=this.underlyingCalls[this.committedCallIndex].nextMessageToSend;for(let r=this.writeBufferOffset;r<e;r++){let n=this.getBufferEntry(r);n.allocated&&this.bufferTracker.free(n.message.message.length,this.callNumber)}this.writeBuffer=this.writeBuffer.slice(e-this.writeBufferOffset),this.writeBufferOffset=e}commitCall(e){var r,n;if(this.state!=="COMMITTED"){this.trace("Committing call ["+this.underlyingCalls[e].call.getCallNumber()+"] at index "+e),this.state="COMMITTED",(n=(r=this.callConfig).onCommitted)===null||n===void 0||n.call(r),this.committedCallIndex=e;for(let i=0;i<this.underlyingCalls.length;i++)i!==e&&this.underlyingCalls[i].state!=="COMPLETED"&&(this.underlyingCalls[i].state="COMPLETED",this.underlyingCalls[i].call.cancelWithStatus(Ib.Status.CANCELLED,"Discarded in favor of other hedged attempt"));this.clearSentMessages()}}commitCallWithMostMessages(){if(this.state==="COMMITTED")return;let e=-1,r=-1;for(let[n,i]of this.underlyingCalls.entries())i.state==="ACTIVE"&&i.nextMessageToSend>e&&(e=i.nextMessageToSend,r=n);r===-1?this.state="TRANSPARENT_ONLY":this.commitCall(r)}isStatusCodeInList(e,r){return e.some(n=>{var i;return n===r||n.toString().toLowerCase()===((i=Ib.Status[r])===null||i===void 0?void 0:i.toLowerCase())})}getNextRetryJitter(){return Math.random()*(1.2-.8)+.8}getNextRetryBackoffMs(){var e;let r=(e=this.callConfig)===null||e===void 0?void 0:e.methodConfig.retryPolicy;if(!r)return 0;let i=this.getNextRetryJitter()*this.nextRetryBackoffSec*1e3,o=Number(r.maxBackoff.substring(0,r.maxBackoff.length-1));return this.nextRetryBackoffSec=Math.min(this.nextRetryBackoffSec*r.backoffMultiplier,o),i}maybeRetryCall(e,r){if(this.state!=="RETRY"){r(!1);return}if(this.attempts>=this.maxAttempts){r(!1);return}let n;if(e===null)n=this.getNextRetryBackoffMs();else if(e<0){this.state="TRANSPARENT_ONLY",r(!1);return}else n=e,this.nextRetryBackoffSec=this.initialRetryBackoffSec;setTimeout(()=>{var i,o;if(this.state!=="RETRY"){r(!1);return}!((o=(i=this.retryThrottler)===null||i===void 0?void 0:i.canRetryCall())!==null&&o!==void 0)||o?(r(!0),this.attempts+=1,this.startNewAttempt()):(this.trace("Retry attempt denied by throttling policy"),r(!1))},n)}countActiveCalls(){let e=0;for(let r of this.underlyingCalls)r?.state==="ACTIVE"&&(e+=1);return e}handleProcessedStatus(e,r,n){var i,o,s;switch(this.state){case"COMMITTED":case"NO_RETRY":case"TRANSPARENT_ONLY":this.commitCall(r),this.reportStatus(e);break;case"HEDGING":if(this.isStatusCodeInList((i=this.callConfig.methodConfig.hedgingPolicy.nonFatalStatusCodes)!==null&&i!==void 0?i:[],e.code)){(o=this.retryThrottler)===null||o===void 0||o.addCallFailed();let a;if(n===null)a=0;else if(n<0){this.state="TRANSPARENT_ONLY",this.commitCall(r),this.reportStatus(e);return}else a=n;setTimeout(()=>{this.maybeStartHedgingAttempt(),this.countActiveCalls()===0&&(this.commitCall(r),this.reportStatus(e))},a)}else this.commitCall(r),this.reportStatus(e);break;case"RETRY":this.isStatusCodeInList(this.callConfig.methodConfig.retryPolicy.retryableStatusCodes,e.code)?((s=this.retryThrottler)===null||s===void 0||s.addCallFailed(),this.maybeRetryCall(n,a=>{a||(this.commitCall(r),this.reportStatus(e))})):(this.commitCall(r),this.reportStatus(e));break}}getPushback(e){let r=e.get("grpc-retry-pushback-ms");if(r.length===0)return null;try{return parseInt(r[0])}catch{return-1}}handleChildStatus(e,r){var n;if(this.underlyingCalls[r].state==="COMPLETED")return;if(this.trace("state="+this.state+" handling status with progress "+e.progress+" from child ["+this.underlyingCalls[r].call.getCallNumber()+"] in state "+this.underlyingCalls[r].state),this.underlyingCalls[r].state="COMPLETED",e.code===Ib.Status.OK){(n=this.retryThrottler)===null||n===void 0||n.addCallSucceeded(),this.commitCall(r),this.reportStatus(e);return}if(this.state==="NO_RETRY"){this.commitCall(r),this.reportStatus(e);return}if(this.state==="COMMITTED"){this.reportStatus(e);return}let i=this.getPushback(e.metadata);switch(e.progress){case"NOT_STARTED":this.startNewAttempt();break;case"REFUSED":this.transparentRetryUsed?this.handleProcessedStatus(e,r,i):(this.transparentRetryUsed=!0,this.startNewAttempt());break;case"DROP":this.commitCall(r),this.reportStatus(e);break;case"PROCESSED":this.handleProcessedStatus(e,r,i);break}}maybeStartHedgingAttempt(){this.state==="HEDGING"&&this.callConfig.methodConfig.hedgingPolicy&&(this.attempts>=this.maxAttempts||(this.attempts+=1,this.startNewAttempt(),this.maybeStartHedgingTimer()))}maybeStartHedgingTimer(){var e,r,n;if(this.hedgingTimer&&clearTimeout(this.hedgingTimer),this.state!=="HEDGING"||!this.callConfig.methodConfig.hedgingPolicy)return;let i=this.callConfig.methodConfig.hedgingPolicy;if(this.attempts>=this.maxAttempts)return;let o=(e=i.hedgingDelay)!==null&&e!==void 0?e:"0s",s=Number(o.substring(0,o.length-1));this.hedgingTimer=setTimeout(()=>{this.maybeStartHedgingAttempt()},s*1e3),(n=(r=this.hedgingTimer).unref)===null||n===void 0||n.call(r)}startNewAttempt(){let e=this.channel.createLoadBalancingCall(this.callConfig,this.methodName,this.host,this.credentials,this.deadline);this.trace("Created child call ["+e.getCallNumber()+"] for attempt "+this.attempts);let r=this.underlyingCalls.length;this.underlyingCalls.push({state:"ACTIVE",call:e,nextMessageToSend:0,startTime:new Date});let n=this.attempts-1,i=this.initialMetadata.clone();n>0&&i.set(AN,`${n}`);let o=!1;e.start(i,{onReceiveMetadata:s=>{this.trace("Received metadata from child ["+e.getCallNumber()+"]"),this.commitCall(r),o=!0,n>0&&s.set(AN,`${n}`),this.underlyingCalls[r].state==="ACTIVE"&&this.listener.onReceiveMetadata(s)},onReceiveMessage:s=>{this.trace("Received message from child ["+e.getCallNumber()+"]"),this.commitCall(r),this.underlyingCalls[r].state==="ACTIVE"&&this.listener.onReceiveMessage(s)},onReceiveStatus:s=>{this.trace("Received status from child ["+e.getCallNumber()+"]"),!o&&n>0&&s.metadata.set(AN,`${n}`),this.handleChildStatus(s,r)}}),this.sendNextChildMessage(r),this.readStarted&&e.startRead()}start(e,r){this.trace("start called"),this.listener=r,this.initialMetadata=e,this.attempts+=1,this.startNewAttempt(),this.maybeStartHedgingTimer()}handleChildWriteCompleted(e,r){var n,i;(i=(n=this.getBufferEntry(r)).callback)===null||i===void 0||i.call(n),this.clearSentMessages();let o=this.underlyingCalls[e];o.nextMessageToSend+=1,this.sendNextChildMessage(e)}sendNextChildMessage(e){let r=this.underlyingCalls[e];if(r.state==="COMPLETED")return;let n=r.nextMessageToSend;if(this.getBufferEntry(n)){let i=this.getBufferEntry(n);switch(i.entryType){case"MESSAGE":r.call.sendMessageWithContext({callback:s=>{this.handleChildWriteCompleted(e,n)}},i.message.message),this.getBufferEntry(n+1).entryType==="HALF_CLOSE"&&(this.trace("Sending halfClose immediately after message to child ["+r.call.getCallNumber()+"] - optimizing for unary/final message"),r.nextMessageToSend+=1,r.call.halfClose());break;case"HALF_CLOSE":r.nextMessageToSend+=1,r.call.halfClose();break;case"FREED":break}}}sendMessageWithContext(e,r){this.trace("write() called with message of length "+r.length);let n={message:r,flags:e.flags},i=this.getNextBufferIndex(),o={entryType:"MESSAGE",message:n,allocated:this.bufferTracker.allocate(r.length,this.callNumber)};if(this.writeBuffer.push(o),o.allocated){process.nextTick(()=>{var s;(s=e.callback)===null||s===void 0||s.call(e)});for(let[s,a]of this.underlyingCalls.entries())a.state==="ACTIVE"&&a.nextMessageToSend===i&&a.call.sendMessageWithContext({callback:c=>{this.handleChildWriteCompleted(s,i)}},r)}else{if(this.commitCallWithMostMessages(),this.committedCallIndex===null)return;let s=this.underlyingCalls[this.committedCallIndex];o.callback=e.callback,s.state==="ACTIVE"&&s.nextMessageToSend===i&&s.call.sendMessageWithContext({callback:a=>{this.handleChildWriteCompleted(this.committedCallIndex,i)}},r)}}startRead(){this.trace("startRead called"),this.readStarted=!0;for(let e of this.underlyingCalls)e?.state==="ACTIVE"&&e.call.startRead()}halfClose(){this.trace("halfClose called");let e=this.getNextBufferIndex();this.writeBuffer.push({entryType:"HALF_CLOSE",allocated:!1});for(let r of this.underlyingCalls)r?.state==="ACTIVE"&&(r.nextMessageToSend===e||r.nextMessageToSend===e-1)&&(this.trace("Sending halfClose immediately to child ["+r.call.getCallNumber()+"] - all messages already sent"),r.nextMessageToSend+=1,r.call.halfClose())}setCredentials(e){throw new Error("Method not implemented.")}getMethod(){return this.methodName}getHost(){return this.host}getAuthContext(){return this.committedCallIndex!==null?this.underlyingCalls[this.committedCallIndex].call.getAuthContext():null}};Ea.RetryingCall=CN});var mg=b(Cb=>{"use strict";Object.defineProperty(Cb,"__esModule",{value:!0});Cb.BaseSubchannelWrapper=void 0;var PN=class{constructor(e){this.child=e,this.healthy=!0,this.healthListeners=new Set,this.refcount=0,this.dataWatchers=new Set,e.addHealthStateWatcher(r=>{this.healthy&&this.updateHealthListeners()})}updateHealthListeners(){for(let e of this.healthListeners)e(this.isHealthy())}getConnectivityState(){return this.child.getConnectivityState()}addConnectivityStateListener(e){this.child.addConnectivityStateListener(e)}removeConnectivityStateListener(e){this.child.removeConnectivityStateListener(e)}startConnecting(){this.child.startConnecting()}getAddress(){return this.child.getAddress()}throttleKeepalive(e){this.child.throttleKeepalive(e)}ref(){this.child.ref(),this.refcount+=1}unref(){this.child.unref(),this.refcount-=1,this.refcount===0&&this.destroy()}destroy(){for(let e of this.dataWatchers)e.destroy()}getChannelzRef(){return this.child.getChannelzRef()}isHealthy(){return this.healthy&&this.child.isHealthy()}addHealthStateWatcher(e){this.healthListeners.add(e)}removeHealthStateWatcher(e){this.healthListeners.delete(e)}addDataWatcher(e){e.setSubchannel(this.getRealSubchannel()),this.dataWatchers.add(e)}setHealthy(e){e!==this.healthy&&(this.healthy=e,this.child.isHealthy()&&this.updateHealthListeners())}getRealSubchannel(){return this.child.getRealSubchannel()}realSubchannelEquals(e){return this.getRealSubchannel()===e.getRealSubchannel()}getCallCredentials(){return this.child.getCallCredentials()}getChannel(){return this.child.getChannel()}};Cb.BaseSubchannelWrapper=PN});var UN=b(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.InternalChannel=dl.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX=void 0;var vTe=Wu(),bTe=ZH(),TTe=R8(),kN=Ho(),xTe=Wt(),va=je(),wTe=pb(),ATe=tN(),M8=ni(),Pb=st(),RTe=hN(),Ob=Rr(),Bn=Ir(),gg=_a(),ITe=P8(),CTe=hd(),PTe=N8(),ON=ab(),OTe=og(),NN=k8(),NTe=mg(),kTe=2147483647,MTe=1e3,DTe=1800*1e3,Nb=new Map,LTe=1<<24,$Te=1<<20,MN=class extends NTe.BaseSubchannelWrapper{constructor(e,r){super(e),this.channel=r,this.refCount=0,this.subchannelStateListener=(n,i,o,s)=>{r.throttleKeepalive(s)}}ref(){this.refCount===0&&(this.child.addConnectivityStateListener(this.subchannelStateListener),this.channel.addWrappedSubchannel(this)),this.child.ref(),this.refCount+=1}unref(){this.child.unref(),this.refCount-=1,this.refCount<=0&&(this.child.removeConnectivityStateListener(this.subchannelStateListener),this.channel.removeWrappedSubchannel(this))}},DN=class{pick(e){return{pickResultType:kN.PickResultType.DROP,status:{code:va.Status.UNAVAILABLE,details:"Channel closed before call started",metadata:new xTe.Metadata},subchannel:null,onCallStarted:null,onCallEnded:null}}};dl.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX="grpc.internal.no_subchannel";var LN=class{constructor(e){this.target=e,this.trace=new gg.ChannelzTrace,this.callTracker=new gg.ChannelzCallTracker,this.childrenTracker=new gg.ChannelzChildrenTracker,this.state=Bn.ConnectivityState.IDLE}getChannelzInfoCallback(){return()=>({target:this.target,state:this.state,trace:this.trace,callTracker:this.callTracker,children:this.childrenTracker.getChildLists()})}},$N=class{constructor(e,r,n){var i,o,s,a,c,l;if(this.credentials=r,this.options=n,this.connectivityState=Bn.ConnectivityState.IDLE,this.currentPicker=new kN.UnavailablePicker,this.configSelectionQueue=[],this.pickQueue=[],this.connectivityStateWatchers=[],this.callRefTimer=null,this.configSelector=null,this.currentResolutionError=null,this.wrappedSubchannels=new Set,this.callCount=0,this.idleTimer=null,this.channelzEnabled=!0,this.randomChannelId=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),typeof e!="string")throw new TypeError("Channel target must be a string");if(!(r instanceof vTe.ChannelCredentials))throw new TypeError("Channel credentials must be a ChannelCredentials object");if(n&&typeof n!="object")throw new TypeError("Channel options must be an object");this.channelzInfoTracker=new LN(e);let u=(0,Ob.parseUri)(e);if(u===null)throw new Error(`Could not parse target name "${e}"`);let d=(0,M8.mapUriDefaultScheme)(u);if(d===null)throw new Error(`Could not find a default scheme for target name "${e}"`);this.options["grpc.enable_channelz"]===0&&(this.channelzEnabled=!1),this.channelzRef=(0,gg.registerChannelzChannel)(e,this.channelzInfoTracker.getChannelzInfoCallback(),this.channelzEnabled),this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_INFO","Channel created"),this.options["grpc.default_authority"]?this.defaultAuthority=this.options["grpc.default_authority"]:this.defaultAuthority=(0,M8.getDefaultAuthority)(d);let f=(0,RTe.mapProxyName)(d,n);this.target=f.target,this.options=Object.assign({},this.options,f.extraOptions),this.subchannelPool=(0,TTe.getSubchannelPool)(((i=this.options["grpc.use_local_subchannel_pool"])!==null&&i!==void 0?i:0)===0),this.retryBufferTracker=new NN.MessageBufferTracker((o=this.options["grpc.retry_buffer_size"])!==null&&o!==void 0?o:LTe,(s=this.options["grpc.per_rpc_retry_buffer_size"])!==null&&s!==void 0?s:$Te),this.keepaliveTime=(a=this.options["grpc.keepalive_time_ms"])!==null&&a!==void 0?a:-1,this.idleTimeoutMs=Math.max((c=this.options["grpc.client_idle_timeout_ms"])!==null&&c!==void 0?c:DTe,MTe);let p={createSubchannel:(m,y)=>{let S={};for(let[v,N]of Object.entries(y))v.startsWith(dl.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX)||(S[v]=N);let T=this.subchannelPool.getOrCreateSubchannel(this.target,m,S,this.credentials);return T.throttleKeepalive(this.keepaliveTime),this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_INFO","Created subchannel or used existing subchannel",T.getChannelzRef()),new MN(T,this)},updateState:(m,y)=>{this.currentPicker=y;let S=this.pickQueue.slice();this.pickQueue=[],S.length>0&&this.callRefTimerUnref();for(let T of S)T.doPick();this.updateState(m)},requestReresolution:()=>{throw new Error("Resolving load balancer should never call requestReresolution")},addChannelzChild:m=>{this.channelzEnabled&&this.channelzInfoTracker.childrenTracker.refChild(m)},removeChannelzChild:m=>{this.channelzEnabled&&this.channelzInfoTracker.childrenTracker.unrefChild(m)}};this.resolvingLoadBalancer=new bTe.ResolvingLoadBalancer(this.target,p,this.options,(m,y)=>{var S;m.retryThrottling?Nb.set(this.getTarget(),new NN.RetryThrottler(m.retryThrottling.maxTokens,m.retryThrottling.tokenRatio,Nb.get(this.getTarget()))):Nb.delete(this.getTarget()),this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_INFO","Address resolution succeeded"),(S=this.configSelector)===null||S===void 0||S.unref(),this.configSelector=y,this.currentResolutionError=null,process.nextTick(()=>{let T=this.configSelectionQueue;this.configSelectionQueue=[],T.length>0&&this.callRefTimerUnref();for(let x of T)x.getConfig()})},m=>{this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_WARNING","Address resolution failed with code "+m.code+' and details "'+m.details+'"'),this.configSelectionQueue.length>0&&this.trace("Name resolution failed with calls queued for config selection"),this.configSelector===null&&(this.currentResolutionError=Object.assign(Object.assign({},(0,OTe.restrictControlPlaneStatusCode)(m.code,m.details)),{metadata:m.metadata}));let y=this.configSelectionQueue;this.configSelectionQueue=[],y.length>0&&this.callRefTimerUnref();for(let S of y)S.reportResolverError(m)}),this.filterStackFactory=new wTe.FilterStackFactory([new ATe.CompressionFilterFactory(this,this.options)]),this.trace("Channel constructed with options "+JSON.stringify(n,void 0,2));let h=new Error;(0,Pb.isTracerEnabled)("channel_stacktrace")&&(0,Pb.trace)(va.LogVerbosity.DEBUG,"channel_stacktrace","("+this.channelzRef.id+`) Channel constructed
|
|
21
21
|
`+((l=h.stack)===null||l===void 0?void 0:l.substring(h.stack.indexOf(`
|
|
22
|
-
`)+1))),this.lastActivityTimestamp=new Date}trace(e,r){(0,Pb.trace)(r??va.LogVerbosity.DEBUG,"channel","("+this.channelzRef.id+") "+(0,Ob.uriToString)(this.target)+" "+e)}callRefTimerRef(){var e,r,n,i;this.callRefTimer||(this.callRefTimer=setInterval(()=>{},kTe)),!((r=(e=this.callRefTimer).hasRef)===null||r===void 0)&&r.call(e)||(this.trace("callRefTimer.ref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),(i=(n=this.callRefTimer).ref)===null||i===void 0||i.call(n))}callRefTimerUnref(){var e,r,n;(!(!((e=this.callRefTimer)===null||e===void 0)&&e.hasRef)||this.callRefTimer.hasRef())&&(this.trace("callRefTimer.unref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),(n=(r=this.callRefTimer)===null||r===void 0?void 0:r.unref)===null||n===void 0||n.call(r))}removeConnectivityStateWatcher(e){let r=this.connectivityStateWatchers.findIndex(n=>n===e);r>=0&&this.connectivityStateWatchers.splice(r,1)}updateState(e){(0,Pb.trace)(va.LogVerbosity.DEBUG,"connectivity_state","("+this.channelzRef.id+") "+(0,Ob.uriToString)(this.target)+" "+Bn.ConnectivityState[this.connectivityState]+" -> "+Bn.ConnectivityState[e]),this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_INFO","Connectivity state change to "+Bn.ConnectivityState[e]),this.connectivityState=e,this.channelzInfoTracker.state=e;let r=this.connectivityStateWatchers.slice();for(let n of r)e!==n.currentState&&(n.timer&&clearTimeout(n.timer),this.removeConnectivityStateWatcher(n),n.callback());e!==Bn.ConnectivityState.TRANSIENT_FAILURE&&(this.currentResolutionError=null)}throttleKeepalive(e){if(e>this.keepaliveTime){this.keepaliveTime=e;for(let r of this.wrappedSubchannels)r.throttleKeepalive(e)}}addWrappedSubchannel(e){this.wrappedSubchannels.add(e)}removeWrappedSubchannel(e){this.wrappedSubchannels.delete(e)}doPick(e,r){return this.currentPicker.pick({metadata:e,extraPickInfo:r})}queueCallForPick(e){this.pickQueue.push(e),this.callRefTimerRef()}getConfig(e,r){return this.connectivityState!==Bn.ConnectivityState.SHUTDOWN&&this.resolvingLoadBalancer.exitIdle(),this.configSelector?{type:"SUCCESS",config:this.configSelector.invoke(e,r,this.randomChannelId)}:this.currentResolutionError?{type:"ERROR",error:this.currentResolutionError}:{type:"NONE"}}queueCallForConfig(e){this.configSelectionQueue.push(e),this.callRefTimerRef()}enterIdle(){this.resolvingLoadBalancer.destroy(),this.updateState(Bn.ConnectivityState.IDLE),this.currentPicker=new kN.QueuePicker(this.resolvingLoadBalancer),this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null),this.callRefTimer&&(clearInterval(this.callRefTimer),this.callRefTimer=null)}startIdleTimeout(e){var r,n;this.idleTimer=setTimeout(()=>{if(this.callCount>0){this.startIdleTimeout(this.idleTimeoutMs);return}let o=new Date().valueOf()-this.lastActivityTimestamp.valueOf();o>=this.idleTimeoutMs?(this.trace("Idle timer triggered after "+this.idleTimeoutMs+"ms of inactivity"),this.enterIdle()):this.startIdleTimeout(this.idleTimeoutMs-o)},e),(n=(r=this.idleTimer).unref)===null||n===void 0||n.call(r)}maybeStartIdleTimer(){this.connectivityState!==Bn.ConnectivityState.SHUTDOWN&&!this.idleTimer&&this.startIdleTimeout(this.idleTimeoutMs)}onCallStart(){this.channelzEnabled&&this.channelzInfoTracker.callTracker.addCallStarted(),this.callCount+=1}onCallEnd(e){this.channelzEnabled&&(e.code===va.Status.OK?this.channelzInfoTracker.callTracker.addCallSucceeded():this.channelzInfoTracker.callTracker.addCallFailed()),this.callCount-=1,this.lastActivityTimestamp=new Date,this.maybeStartIdleTimer()}createLoadBalancingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();return this.trace("createLoadBalancingCall ["+s+'] method="'+r+'"'),new ITe.LoadBalancingCall(this,e,r,n,i,o,s)}createRetryingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();return this.trace("createRetryingCall ["+s+'] method="'+r+'"'),new NN.RetryingCall(this,e,r,n,i,o,s,this.retryBufferTracker,Nb.get(this.getTarget()))}createResolvingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();this.trace("createResolvingCall ["+s+'] method="'+e+'", deadline='+(0,CTe.deadlineToString)(r));let a={deadline:r,flags:o??va.Propagate.DEFAULTS,host:n??this.defaultAuthority,parentCall:i},c=new PTe.ResolvingCall(this,e,a,this.filterStackFactory.clone(),s);return this.onCallStart(),c.addStatusWatcher(l=>{this.onCallEnd(l)}),c}close(){var e;this.resolvingLoadBalancer.destroy(),this.updateState(Bn.ConnectivityState.SHUTDOWN),this.currentPicker=new DN;for(let r of this.configSelectionQueue)r.cancelWithStatus(va.Status.UNAVAILABLE,"Channel closed before call started");this.configSelectionQueue=[];for(let r of this.pickQueue)r.cancelWithStatus(va.Status.UNAVAILABLE,"Channel closed before call started");this.pickQueue=[],this.callRefTimer&&clearInterval(this.callRefTimer),this.idleTimer&&clearTimeout(this.idleTimer),this.channelzEnabled&&(0,gg.unregisterChannelzRef)(this.channelzRef),this.subchannelPool.unrefUnusedSubchannels(),(e=this.configSelector)===null||e===void 0||e.unref(),this.configSelector=null}getTarget(){return(0,Ob.uriToString)(this.target)}getConnectivityState(e){let r=this.connectivityState;return e&&(this.resolvingLoadBalancer.exitIdle(),this.lastActivityTimestamp=new Date,this.maybeStartIdleTimer()),r}watchConnectivityState(e,r,n){if(this.connectivityState===Bn.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");let i=null;if(r!==1/0){let s=r instanceof Date?r:new Date(r),a=new Date;if(r===-1/0||s<=a){process.nextTick(n,new Error("Deadline passed without connectivity state change"));return}i=setTimeout(()=>{this.removeConnectivityStateWatcher(o),n(new Error("Deadline passed without connectivity state change"))},s.getTime()-a.getTime())}let o={currentState:e,callback:n,timer:i};this.connectivityStateWatchers.push(o)}getChannelzRef(){return this.channelzRef}createCall(e,r,n,i,o){if(typeof e!="string")throw new TypeError("Channel#createCall: method must be a string");if(!(typeof r=="number"||r instanceof Date))throw new TypeError("Channel#createCall: deadline must be a number or Date");if(this.connectivityState===Bn.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");return this.createResolvingCall(e,r,n,i,o)}getOptions(){return this.options}};dl.InternalChannel=$N});var OP=b(kb=>{"use strict";Object.defineProperty(kb,"__esModule",{value:!0});kb.ChannelImplementation=void 0;var UTe=Wu(),FTe=UN(),FN=class{constructor(e,r,n){if(typeof e!="string")throw new TypeError("Channel target must be a string");if(!(r instanceof UTe.ChannelCredentials))throw new TypeError("Channel credentials must be a ChannelCredentials object");if(n&&typeof n!="object")throw new TypeError("Channel options must be an object");this.internalChannel=new FTe.InternalChannel(e,r,n)}close(){this.internalChannel.close()}getTarget(){return this.internalChannel.getTarget()}getConnectivityState(e){return this.internalChannel.getConnectivityState(e)}watchConnectivityState(e,r,n){this.internalChannel.watchConnectivityState(e,r,n)}getChannelzRef(){return this.internalChannel.getChannelzRef()}createCall(e,r,n,i,o){if(typeof e!="string")throw new TypeError("Channel#createCall: method must be a string");if(!(typeof r=="number"||r instanceof Date))throw new TypeError("Channel#createCall: deadline must be a number or Date");return this.internalChannel.createCall(e,r,n,i,o)}};kb.ChannelImplementation=FN});var L8=b(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.ServerDuplexStreamImpl=gi.ServerWritableStreamImpl=gi.ServerReadableStreamImpl=gi.ServerUnaryCallImpl=void 0;gi.serverErrorToStatus=HN;var BTe=Z("events"),qN=Z("stream"),VN=je(),D8=Wt();function HN(t,e){var r;let n={code:VN.Status.UNKNOWN,details:"message"in t?t.message:"Unknown Error",metadata:(r=e??t.metadata)!==null&&r!==void 0?r:null};return"code"in t&&typeof t.code=="number"&&Number.isInteger(t.code)&&(n.code=t.code,"details"in t&&typeof t.details=="string"&&(n.details=t.details)),n}var BN=class extends BTe.EventEmitter{constructor(e,r,n,i){super(),this.path=e,this.call=r,this.metadata=n,this.request=i,this.cancelled=!1}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}};gi.ServerUnaryCallImpl=BN;var jN=class extends qN.Readable{constructor(e,r,n){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.cancelled=!1}_read(e){this.call.startRead()}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}};gi.ServerReadableStreamImpl=jN;var zN=class extends qN.Writable{constructor(e,r,n,i){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.request=i,this.pendingStatus={code:VN.Status.OK,details:"OK"},this.cancelled=!1,this.trailingMetadata=new D8.Metadata,this.on("error",o=>{this.pendingStatus=HN(o),this.end()})}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}_write(e,r,n){this.call.sendMessage(e,n)}_final(e){var r;e(null),this.call.sendStatus(Object.assign(Object.assign({},this.pendingStatus),{metadata:(r=this.pendingStatus.metadata)!==null&&r!==void 0?r:this.trailingMetadata}))}end(e){return e&&(this.trailingMetadata=e),super.end()}};gi.ServerWritableStreamImpl=zN;var GN=class extends qN.Duplex{constructor(e,r,n){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.pendingStatus={code:VN.Status.OK,details:"OK"},this.cancelled=!1,this.trailingMetadata=new D8.Metadata,this.on("error",i=>{this.pendingStatus=HN(i),this.end()})}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}_read(e){this.call.startRead()}_write(e,r,n){this.call.sendMessage(e,n)}_final(e){var r;e(null),this.call.sendStatus(Object.assign(Object.assign({},this.pendingStatus),{metadata:(r=this.pendingStatus.metadata)!==null&&r!==void 0?r:this.trailingMetadata}))}end(e){return e&&(this.trailingMetadata=e),super.end()}};gi.ServerDuplexStreamImpl=GN});var Mb=b(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.ServerCredentials=void 0;Ed.createCertificateProviderServerCredentials=jTe;Ed.createServerCredentialsWithInterceptors=zTe;var WN=Q0(),fl=class{constructor(e,r){this.serverConstructorOptions=e,this.watchers=new Set,this.latestContextOptions=null,this.latestContextOptions=r??null}_addWatcher(e){this.watchers.add(e)}_removeWatcher(e){this.watchers.delete(e)}getWatcherCount(){return this.watchers.size}updateSecureContextOptions(e){this.latestContextOptions=e;for(let r of this.watchers)r(this.latestContextOptions)}_isSecure(){return this.serverConstructorOptions!==null}_getSecureContextOptions(){return this.latestContextOptions}_getConstructorOptions(){return this.serverConstructorOptions}_getInterceptors(){return[]}static createInsecure(){return new YN}static createSsl(e,r,n=!1){var i;if(e!==null&&!Buffer.isBuffer(e))throw new TypeError("rootCerts must be null or a Buffer");if(!Array.isArray(r))throw new TypeError("keyCertPairs must be an array");if(typeof n!="boolean")throw new TypeError("checkClientCertificate must be a boolean");let o=[],s=[];for(let a=0;a<r.length;a++){let c=r[a];if(c===null||typeof c!="object")throw new TypeError(`keyCertPair[${a}] must be an object`);if(!Buffer.isBuffer(c.private_key))throw new TypeError(`keyCertPair[${a}].private_key must be a Buffer`);if(!Buffer.isBuffer(c.cert_chain))throw new TypeError(`keyCertPair[${a}].cert_chain must be a Buffer`);o.push(c.cert_chain),s.push(c.private_key)}return new KN({requestCert:n,ciphers:WN.CIPHER_SUITES},{ca:(i=e??(0,WN.getDefaultRootsData)())!==null&&i!==void 0?i:void 0,cert:o,key:s})}};Ed.ServerCredentials=fl;var YN=class t extends fl{constructor(){super(null)}_getSettings(){return null}_equals(e){return e instanceof t}},KN=class t extends fl{constructor(e,r){super(e,r),this.options=Object.assign(Object.assign({},e),r)}_equals(e){if(this===e)return!0;if(!(e instanceof t))return!1;if(Buffer.isBuffer(this.options.ca)&&Buffer.isBuffer(e.options.ca)){if(!this.options.ca.equals(e.options.ca))return!1}else if(this.options.ca!==e.options.ca)return!1;if(Array.isArray(this.options.cert)&&Array.isArray(e.options.cert)){if(this.options.cert.length!==e.options.cert.length)return!1;for(let r=0;r<this.options.cert.length;r++){let n=this.options.cert[r],i=e.options.cert[r];if(Buffer.isBuffer(n)&&Buffer.isBuffer(i)){if(!n.equals(i))return!1}else if(n!==i)return!1}}else if(this.options.cert!==e.options.cert)return!1;if(Array.isArray(this.options.key)&&Array.isArray(e.options.key)){if(this.options.key.length!==e.options.key.length)return!1;for(let r=0;r<this.options.key.length;r++){let n=this.options.key[r],i=e.options.key[r];if(Buffer.isBuffer(n)&&Buffer.isBuffer(i)){if(!n.equals(i))return!1}else if(n!==i)return!1}}else if(this.options.key!==e.options.key)return!1;return this.options.requestCert===e.options.requestCert}},ZN=class t extends fl{constructor(e,r,n){super({requestCert:r!==null,rejectUnauthorized:n,ciphers:WN.CIPHER_SUITES}),this.identityCertificateProvider=e,this.caCertificateProvider=r,this.requireClientCertificate=n,this.latestCaUpdate=null,this.latestIdentityUpdate=null,this.caCertificateUpdateListener=this.handleCaCertificateUpdate.bind(this),this.identityCertificateUpdateListener=this.handleIdentityCertitificateUpdate.bind(this)}_addWatcher(e){var r;this.getWatcherCount()===0&&((r=this.caCertificateProvider)===null||r===void 0||r.addCaCertificateListener(this.caCertificateUpdateListener),this.identityCertificateProvider.addIdentityCertificateListener(this.identityCertificateUpdateListener)),super._addWatcher(e)}_removeWatcher(e){var r;super._removeWatcher(e),this.getWatcherCount()===0&&((r=this.caCertificateProvider)===null||r===void 0||r.removeCaCertificateListener(this.caCertificateUpdateListener),this.identityCertificateProvider.removeIdentityCertificateListener(this.identityCertificateUpdateListener))}_equals(e){return this===e?!0:e instanceof t?this.caCertificateProvider===e.caCertificateProvider&&this.identityCertificateProvider===e.identityCertificateProvider&&this.requireClientCertificate===e.requireClientCertificate:!1}calculateSecureContextOptions(){var e;return this.latestIdentityUpdate===null||this.caCertificateProvider!==null&&this.latestCaUpdate===null?null:{ca:(e=this.latestCaUpdate)===null||e===void 0?void 0:e.caCertificate,cert:[this.latestIdentityUpdate.certificate],key:[this.latestIdentityUpdate.privateKey]}}finalizeUpdate(){let e=this.calculateSecureContextOptions();this.updateSecureContextOptions(e)}handleCaCertificateUpdate(e){this.latestCaUpdate=e,this.finalizeUpdate()}handleIdentityCertitificateUpdate(e){this.latestIdentityUpdate=e,this.finalizeUpdate()}};function jTe(t,e,r){return new ZN(t,e,r)}var JN=class t extends fl{constructor(e,r){super({}),this.childCredentials=e,this.interceptors=r}_isSecure(){return this.childCredentials._isSecure()}_equals(e){if(!(e instanceof t)||!this.childCredentials._equals(e.childCredentials)||this.interceptors.length!==e.interceptors.length)return!1;for(let r=0;r<this.interceptors.length;r++)if(this.interceptors[r]!==e.interceptors[r])return!1;return!0}_getInterceptors(){return this.interceptors}_addWatcher(e){this.childCredentials._addWatcher(e)}_removeWatcher(e){this.childCredentials._removeWatcher(e)}_getConstructorOptions(){return this.childCredentials._getConstructorOptions()}_getSecureContextOptions(){return this.childCredentials._getSecureContextOptions()}};function zTe(t,e){return new JN(t,e)}});var _g=b(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.durationMessageToDuration=GTe;is.msToDuration=qTe;is.durationToMs=VTe;is.isDuration=HTe;is.isDurationMessage=WTe;is.parseDuration=KTe;is.durationToString=ZTe;function GTe(t){return{seconds:Number.parseInt(t.seconds),nanos:t.nanos}}function qTe(t){return{seconds:t/1e3|0,nanos:t%1e3*1e6|0}}function VTe(t){return t.seconds*1e3+t.nanos/1e6|0}function HTe(t){return typeof t.seconds=="number"&&typeof t.nanos=="number"}function WTe(t){return typeof t.seconds=="string"&&typeof t.nanos=="number"}var YTe=/^(\d+)(?:\.(\d+))?s$/;function KTe(t){let e=t.match(YTe);return e?{seconds:Number.parseInt(e[1],10),nanos:e[2]?Number.parseInt(e[2].padEnd(9,"0"),10):0}:null}function ZTe(t){if(t.nanos===0)return`${t.seconds}s`;let e;return t.nanos%1e6===0?e=1e6:t.nanos%1e3===0?e=1e3:e=1,`${t.seconds}.${t.nanos/e}s`}});var Lb=b(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.OrcaOobMetricsSubchannelWrapper=hn.GRPC_METRICS_HEADER=hn.ServerMetricRecorder=hn.PerRequestMetricRecorder=void 0;hn.createOrcaClient=B8;hn.createMetricsReader=nxe;var JTe=wv(),XN=_g(),XTe=Wu(),QTe=mg(),$8=je(),exe=Yu(),txe=Ir(),U8=null;function Db(){if(U8)return U8;let t=FO().loadSync,e=t("xds/service/orca/v3/orca.proto",{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0,includeDirs:[`${__dirname}/../../proto/xds`,`${__dirname}/../../proto/protoc-gen-validate`]});return(0,JTe.loadPackageDefinition)(e)}var QN=class{constructor(){this.message={}}recordRequestCostMetric(e,r){this.message.request_cost||(this.message.request_cost={}),this.message.request_cost[e]=r}recordUtilizationMetric(e,r){this.message.utilization||(this.message.utilization={}),this.message.utilization[e]=r}recordNamedMetric(e,r){this.message.named_metrics||(this.message.named_metrics={}),this.message.named_metrics[e]=r}recordCPUUtilizationMetric(e){this.message.cpu_utilization=e}recordMemoryUtilizationMetric(e){this.message.mem_utilization=e}recordApplicationUtilizationMetric(e){this.message.application_utilization=e}recordQpsMetric(e){this.message.rps_fractional=e}recordEpsMetric(e){this.message.eps=e}serialize(){return Db().xds.data.orca.v3.OrcaLoadReport.serialize(this.message)}};hn.PerRequestMetricRecorder=QN;var rxe=3e4,ek=class{constructor(){this.message={},this.serviceImplementation={StreamCoreMetrics:e=>{let r=e.request.report_interval?(0,XN.durationToMs)((0,XN.durationMessageToDuration)(e.request.report_interval)):rxe,n=setInterval(()=>{e.write(this.message)},r);e.on("cancelled",()=>{clearInterval(n)})}}}putUtilizationMetric(e,r){this.message.utilization||(this.message.utilization={}),this.message.utilization[e]=r}setAllUtilizationMetrics(e){this.message.utilization=Object.assign({},e)}deleteUtilizationMetric(e){var r;(r=this.message.utilization)===null||r===void 0||delete r[e]}setCpuUtilizationMetric(e){this.message.cpu_utilization=e}deleteCpuUtilizationMetric(){delete this.message.cpu_utilization}setApplicationUtilizationMetric(e){this.message.application_utilization=e}deleteApplicationUtilizationMetric(){delete this.message.application_utilization}setQpsMetric(e){this.message.rps_fractional=e}deleteQpsMetric(){delete this.message.rps_fractional}setEpsMetric(e){this.message.eps=e}deleteEpsMetric(){delete this.message.eps}addToServer(e){let r=Db().xds.service.orca.v3.OpenRcaService.service;e.addService(r,this.serviceImplementation)}};hn.ServerMetricRecorder=ek;function B8(t){let e=Db().xds.service.orca.v3.OpenRcaService;return new e("unused",XTe.ChannelCredentials.createInsecure(),{channelOverride:t})}hn.GRPC_METRICS_HEADER="endpoint-load-metrics-bin";var F8="grpc_orca_load_report";function nxe(t,e){return(r,n,i)=>{let o=i.getOpaque(F8);if(o)t(o);else{let s=i.get(hn.GRPC_METRICS_HEADER);s.length>0&&(o=Db().xds.data.orca.v3.OrcaLoadReport.deserialize(s[0]),t(o),i.setOpaque(F8,o))}e&&e(r,n,i)}}var j8="orca_oob_metrics",tk=class{constructor(e,r){this.metricsListener=e,this.intervalMs=r,this.dataProducer=null}setSubchannel(e){let r=e.getOrCreateDataProducer(j8,ixe);this.dataProducer=r,r.addDataWatcher(this)}destroy(){var e;(e=this.dataProducer)===null||e===void 0||e.removeDataWatcher(this)}getInterval(){return this.intervalMs}onMetricsUpdate(e){this.metricsListener(e)}},rk=class{constructor(e){this.subchannel=e,this.dataWatchers=new Set,this.orcaSupported=!0,this.metricsCall=null,this.currentInterval=1/0,this.backoffTimer=new exe.BackoffTimeout(()=>this.updateMetricsSubscription()),this.subchannelStateListener=()=>this.updateMetricsSubscription();let r=e.getChannel();this.client=B8(r),e.addConnectivityStateListener(this.subchannelStateListener)}addDataWatcher(e){this.dataWatchers.add(e),this.updateMetricsSubscription()}removeDataWatcher(e){var r;this.dataWatchers.delete(e),this.dataWatchers.size===0?(this.subchannel.removeDataProducer(j8),(r=this.metricsCall)===null||r===void 0||r.cancel(),this.metricsCall=null,this.client.close(),this.subchannel.removeConnectivityStateListener(this.subchannelStateListener)):this.updateMetricsSubscription()}updateMetricsSubscription(){var e;if(this.dataWatchers.size===0||!this.orcaSupported||this.subchannel.getConnectivityState()!==txe.ConnectivityState.READY)return;let r=Math.min(...Array.from(this.dataWatchers).map(n=>n.getInterval()));if(!this.metricsCall||r!==this.currentInterval){(e=this.metricsCall)===null||e===void 0||e.cancel(),this.currentInterval=r;let n=this.client.streamCoreMetrics({report_interval:(0,XN.msToDuration)(r)});this.metricsCall=n,n.on("data",i=>{this.dataWatchers.forEach(o=>{o.onMetricsUpdate(i)})}),n.on("error",i=>{if(this.metricsCall=null,i.code===$8.Status.UNIMPLEMENTED){this.orcaSupported=!1;return}i.code!==$8.Status.CANCELLED&&this.backoffTimer.runOnce()})}}},nk=class extends QTe.BaseSubchannelWrapper{constructor(e,r,n){super(e),this.addDataWatcher(new tk(r,n))}getWrappedSubchannel(){return this.child}};hn.OrcaOobMetricsSubchannelWrapper=nk;function ixe(t){return new rk(t)}});var uk=b(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.BaseServerInterceptingCall=jn.ServerInterceptingCall=jn.ResponderBuilder=jn.ServerListenerBuilder=void 0;jn.isInterceptingServerListener=axe;jn.getServerInterceptingCall=fxe;var Fb=Wt(),Pr=je(),vd=Z("http2"),z8=tv(),G8=Z("zlib"),oxe=gN(),Y8=st(),sxe=Z("tls"),q8=Lb(),K8="server_call";function pl(t){Y8.trace(Pr.LogVerbosity.DEBUG,K8,t)}var ok=class{constructor(){this.metadata=void 0,this.message=void 0,this.halfClose=void 0,this.cancel=void 0}withOnReceiveMetadata(e){return this.metadata=e,this}withOnReceiveMessage(e){return this.message=e,this}withOnReceiveHalfClose(e){return this.halfClose=e,this}withOnCancel(e){return this.cancel=e,this}build(){return{onReceiveMetadata:this.metadata,onReceiveMessage:this.message,onReceiveHalfClose:this.halfClose,onCancel:this.cancel}}};jn.ServerListenerBuilder=ok;function axe(t){return t.onReceiveMetadata!==void 0&&t.onReceiveMetadata.length===1}var sk=class{constructor(e,r){this.listener=e,this.nextListener=r,this.cancelled=!1,this.processingMetadata=!1,this.hasPendingMessage=!1,this.pendingMessage=null,this.processingMessage=!1,this.hasPendingHalfClose=!1}processPendingMessage(){this.hasPendingMessage&&(this.nextListener.onReceiveMessage(this.pendingMessage),this.pendingMessage=null,this.hasPendingMessage=!1)}processPendingHalfClose(){this.hasPendingHalfClose&&(this.nextListener.onReceiveHalfClose(),this.hasPendingHalfClose=!1)}onReceiveMetadata(e){this.cancelled||(this.processingMetadata=!0,this.listener.onReceiveMetadata(e,r=>{this.processingMetadata=!1,!this.cancelled&&(this.nextListener.onReceiveMetadata(r),this.processPendingMessage(),this.processPendingHalfClose())}))}onReceiveMessage(e){this.cancelled||(this.processingMessage=!0,this.listener.onReceiveMessage(e,r=>{this.processingMessage=!1,!this.cancelled&&(this.processingMetadata?(this.pendingMessage=r,this.hasPendingMessage=!0):(this.nextListener.onReceiveMessage(r),this.processPendingHalfClose()))}))}onReceiveHalfClose(){this.cancelled||this.listener.onReceiveHalfClose(()=>{this.cancelled||(this.processingMetadata||this.processingMessage?this.hasPendingHalfClose=!0:this.nextListener.onReceiveHalfClose())})}onCancel(){this.cancelled=!0,this.listener.onCancel(),this.nextListener.onCancel()}},ak=class{constructor(){this.start=void 0,this.metadata=void 0,this.message=void 0,this.status=void 0}withStart(e){return this.start=e,this}withSendMetadata(e){return this.metadata=e,this}withSendMessage(e){return this.message=e,this}withSendStatus(e){return this.status=e,this}build(){return{start:this.start,sendMetadata:this.metadata,sendMessage:this.message,sendStatus:this.status}}};jn.ResponderBuilder=ak;var $b={onReceiveMetadata:(t,e)=>{e(t)},onReceiveMessage:(t,e)=>{e(t)},onReceiveHalfClose:t=>{t()},onCancel:()=>{}},Ub={start:t=>{t()},sendMetadata:(t,e)=>{e(t)},sendMessage:(t,e)=>{e(t)},sendStatus:(t,e)=>{e(t)}},ck=class{constructor(e,r){var n,i,o,s;this.nextCall=e,this.processingMetadata=!1,this.sentMetadata=!1,this.processingMessage=!1,this.pendingMessage=null,this.pendingMessageCallback=null,this.pendingStatus=null,this.responder={start:(n=r?.start)!==null&&n!==void 0?n:Ub.start,sendMetadata:(i=r?.sendMetadata)!==null&&i!==void 0?i:Ub.sendMetadata,sendMessage:(o=r?.sendMessage)!==null&&o!==void 0?o:Ub.sendMessage,sendStatus:(s=r?.sendStatus)!==null&&s!==void 0?s:Ub.sendStatus}}processPendingMessage(){this.pendingMessageCallback&&(this.nextCall.sendMessage(this.pendingMessage,this.pendingMessageCallback),this.pendingMessage=null,this.pendingMessageCallback=null)}processPendingStatus(){this.pendingStatus&&(this.nextCall.sendStatus(this.pendingStatus),this.pendingStatus=null)}start(e){this.responder.start(r=>{var n,i,o,s;let a={onReceiveMetadata:(n=r?.onReceiveMetadata)!==null&&n!==void 0?n:$b.onReceiveMetadata,onReceiveMessage:(i=r?.onReceiveMessage)!==null&&i!==void 0?i:$b.onReceiveMessage,onReceiveHalfClose:(o=r?.onReceiveHalfClose)!==null&&o!==void 0?o:$b.onReceiveHalfClose,onCancel:(s=r?.onCancel)!==null&&s!==void 0?s:$b.onCancel},c=new sk(a,e);this.nextCall.start(c)})}sendMetadata(e){this.processingMetadata=!0,this.sentMetadata=!0,this.responder.sendMetadata(e,r=>{this.processingMetadata=!1,this.nextCall.sendMetadata(r),this.processPendingMessage(),this.processPendingStatus()})}sendMessage(e,r){this.processingMessage=!0,this.sentMetadata||this.sendMetadata(new Fb.Metadata),this.responder.sendMessage(e,n=>{this.processingMessage=!1,this.processingMetadata?(this.pendingMessage=n,this.pendingMessageCallback=r):this.nextCall.sendMessage(n,r)})}sendStatus(e){this.responder.sendStatus(e,r=>{this.processingMetadata||this.processingMessage?this.pendingStatus=r:this.nextCall.sendStatus(r)})}startRead(){this.nextCall.startRead()}getPeer(){return this.nextCall.getPeer()}getDeadline(){return this.nextCall.getDeadline()}getHost(){return this.nextCall.getHost()}getAuthContext(){return this.nextCall.getAuthContext()}getConnectionInfo(){return this.nextCall.getConnectionInfo()}getMetricsRecorder(){return this.nextCall.getMetricsRecorder()}};jn.ServerInterceptingCall=ck;var Z8="grpc-accept-encoding",lk="grpc-encoding",V8="grpc-message",H8="grpc-status",ik="grpc-timeout",cxe=/(\d{1,8})\s*([HMSmun])/,lxe={H:36e5,M:6e4,S:1e3,m:1,u:.001,n:1e-6},uxe={[Z8]:"identity,deflate,gzip",[lk]:"identity"},W8={[vd.constants.HTTP2_HEADER_STATUS]:vd.constants.HTTP_STATUS_OK,[vd.constants.HTTP2_HEADER_CONTENT_TYPE]:"application/grpc+proto"},dxe={waitForTrailers:!0},Bb=class{constructor(e,r,n,i,o){var s,a;this.stream=e,this.callEventTracker=n,this.handler=i,this.listener=null,this.deadlineTimer=null,this.deadline=1/0,this.maxSendMessageSize=Pr.DEFAULT_MAX_SEND_MESSAGE_LENGTH,this.maxReceiveMessageSize=Pr.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH,this.cancelled=!1,this.metadataSent=!1,this.wantTrailers=!1,this.cancelNotified=!1,this.incomingEncoding="identity",this.readQueue=[],this.isReadPending=!1,this.receivedHalfClose=!1,this.streamEnded=!1,this.metricsRecorder=new q8.PerRequestMetricRecorder,this.stream.once("close",()=>{var f;pl("Request to method "+((f=this.handler)===null||f===void 0?void 0:f.path)+" stream closed with rstCode "+this.stream.rstCode),this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!1),this.callEventTracker.onCallEnd({code:Pr.Status.CANCELLED,details:"Stream closed before sending status",metadata:null})),this.notifyOnCancel()}),this.stream.on("data",f=>{this.handleDataFrame(f)}),this.stream.pause(),this.stream.on("end",()=>{this.handleEndEvent()}),"grpc.max_send_message_length"in o&&(this.maxSendMessageSize=o["grpc.max_send_message_length"]),"grpc.max_receive_message_length"in o&&(this.maxReceiveMessageSize=o["grpc.max_receive_message_length"]),this.host=(s=r[":authority"])!==null&&s!==void 0?s:r.host,this.decoder=new oxe.StreamDecoder(this.maxReceiveMessageSize);let c=Fb.Metadata.fromHttp2Headers(r);Y8.isTracerEnabled(K8)&&pl("Request to "+this.handler.path+" received headers "+JSON.stringify(c.toJSON()));let l=c.get(ik);l.length>0&&this.handleTimeoutHeader(l[0]);let u=c.get(lk);u.length>0&&(this.incomingEncoding=u[0]),c.remove(ik),c.remove(lk),c.remove(Z8),c.remove(vd.constants.HTTP2_HEADER_ACCEPT_ENCODING),c.remove(vd.constants.HTTP2_HEADER_TE),c.remove(vd.constants.HTTP2_HEADER_CONTENT_TYPE),this.metadata=c;let d=(a=e.session)===null||a===void 0?void 0:a.socket;this.connectionInfo={localAddress:d?.localAddress,localPort:d?.localPort,remoteAddress:d?.remoteAddress,remotePort:d?.remotePort},this.shouldSendMetrics=!!o["grpc.server_call_metric_recording"]}handleTimeoutHeader(e){let r=e.toString().match(cxe);if(r===null){let o={code:Pr.Status.INTERNAL,details:`Invalid ${ik} value "${e}"`,metadata:null};process.nextTick(()=>{this.sendStatus(o)});return}let n=+r[1]*lxe[r[2]]|0,i=new Date;this.deadline=i.setMilliseconds(i.getMilliseconds()+n),this.deadlineTimer=setTimeout(()=>{let o={code:Pr.Status.DEADLINE_EXCEEDED,details:"Deadline exceeded",metadata:null};this.sendStatus(o)},n)}checkCancelled(){return!this.cancelled&&(this.stream.destroyed||this.stream.closed)&&(this.notifyOnCancel(),this.cancelled=!0),this.cancelled}notifyOnCancel(){this.cancelNotified||(this.cancelNotified=!0,this.cancelled=!0,process.nextTick(()=>{var e;(e=this.listener)===null||e===void 0||e.onCancel()}),this.deadlineTimer&&clearTimeout(this.deadlineTimer),this.stream.resume())}maybeSendMetadata(){this.metadataSent||this.sendMetadata(new Fb.Metadata)}serializeMessage(e){let r=this.handler.serialize(e),n=r.byteLength,i=Buffer.allocUnsafe(n+5);return i.writeUInt8(0,0),i.writeUInt32BE(n,1),r.copy(i,5),i}decompressMessage(e,r){let n=e.subarray(5);if(r==="identity")return n;if(r==="deflate"||r==="gzip"){let i;return r==="deflate"?i=G8.createInflate():i=G8.createGunzip(),new Promise((o,s)=>{let a=0,c=[];i.on("error",l=>{s({code:Pr.Status.INTERNAL,details:"Failed to decompress message"})}),i.on("data",l=>{c.push(l),a+=l.byteLength,this.maxReceiveMessageSize!==-1&&a>this.maxReceiveMessageSize&&(i.destroy(),s({code:Pr.Status.RESOURCE_EXHAUSTED,details:`Received message that decompresses to a size larger than ${this.maxReceiveMessageSize}`}))}),i.on("end",()=>{o(Buffer.concat(c))}),i.write(n),i.end()})}else return Promise.reject({code:Pr.Status.UNIMPLEMENTED,details:`Received message compressed with unsupported encoding "${r}"`})}async decompressAndMaybePush(e){if(e.type!=="COMPRESSED")throw new Error(`Invalid queue entry type: ${e.type}`);let n=e.compressedMessage.readUInt8(0)===1?this.incomingEncoding:"identity",i;try{i=await this.decompressMessage(e.compressedMessage,n)}catch(o){this.sendStatus(o);return}try{e.parsedMessage=this.handler.deserialize(i)}catch(o){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error deserializing request: ${o.message}`});return}e.type="READABLE",this.maybePushNextMessage()}maybePushNextMessage(){if(this.listener&&this.isReadPending&&this.readQueue.length>0&&this.readQueue[0].type!=="COMPRESSED"){this.isReadPending=!1;let e=this.readQueue.shift();e.type==="READABLE"?this.listener.onReceiveMessage(e.parsedMessage):this.listener.onReceiveHalfClose()}}handleDataFrame(e){var r;if(this.checkCancelled())return;pl("Request to "+this.handler.path+" received data frame of size "+e.length);let n;try{n=this.decoder.write(e)}catch(i){this.sendStatus({code:Pr.Status.RESOURCE_EXHAUSTED,details:i.message});return}for(let i of n){this.stream.pause();let o={type:"COMPRESSED",compressedMessage:i,parsedMessage:null};this.readQueue.push(o),this.decompressAndMaybePush(o),(r=this.callEventTracker)===null||r===void 0||r.addMessageReceived()}}handleEndEvent(){this.readQueue.push({type:"HALF_CLOSE",compressedMessage:null,parsedMessage:null}),this.receivedHalfClose=!0,this.maybePushNextMessage()}start(e){pl("Request to "+this.handler.path+" start called"),!this.checkCancelled()&&(this.listener=e,e.onReceiveMetadata(this.metadata))}sendMetadata(e){if(this.checkCancelled()||this.metadataSent)return;this.metadataSent=!0;let r=e?e.toHttp2Headers():null,n=Object.assign(Object.assign(Object.assign({},W8),uxe),r);this.stream.respond(n,dxe)}sendMessage(e,r){if(this.checkCancelled())return;let n;try{n=this.serializeMessage(e)}catch(i){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error serializing response: ${(0,z8.getErrorMessage)(i)}`,metadata:null});return}if(this.maxSendMessageSize!==-1&&n.length-5>this.maxSendMessageSize){this.sendStatus({code:Pr.Status.RESOURCE_EXHAUSTED,details:`Sent message larger than max (${n.length} vs. ${this.maxSendMessageSize})`,metadata:null});return}this.maybeSendMetadata(),pl("Request to "+this.handler.path+" sent data frame of size "+n.length),this.stream.write(n,i=>{var o;if(i){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error writing message: ${(0,z8.getErrorMessage)(i)}`,metadata:null});return}(o=this.callEventTracker)===null||o===void 0||o.addMessageSent(),r()})}sendStatus(e){var r,n,i;if(this.checkCancelled())return;pl("Request to method "+((r=this.handler)===null||r===void 0?void 0:r.path)+" ended with status code: "+Pr.Status[e.code]+" details: "+e.details);let o=(i=(n=e.metadata)===null||n===void 0?void 0:n.clone())!==null&&i!==void 0?i:new Fb.Metadata;if(this.shouldSendMetrics&&o.set(q8.GRPC_METRICS_HEADER,this.metricsRecorder.serialize()),this.metadataSent)this.wantTrailers?this.notifyOnCancel():(this.wantTrailers=!0,this.stream.once("wantTrailers",()=>{this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!0),this.callEventTracker.onCallEnd(e));let s=Object.assign({[H8]:e.code,[V8]:encodeURI(e.details)},o.toHttp2Headers());this.stream.sendTrailers(s),this.notifyOnCancel()}),this.stream.end());else{this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!0),this.callEventTracker.onCallEnd(e));let s=Object.assign(Object.assign({[H8]:e.code,[V8]:encodeURI(e.details)},W8),o.toHttp2Headers());this.stream.respond(s,{endStream:!0}),this.notifyOnCancel()}}startRead(){pl("Request to "+this.handler.path+" startRead called"),!this.checkCancelled()&&(this.isReadPending=!0,this.readQueue.length===0?this.receivedHalfClose||this.stream.resume():this.maybePushNextMessage())}getPeer(){var e;let r=(e=this.stream.session)===null||e===void 0?void 0:e.socket;return r?.remoteAddress?r.remotePort?`${r.remoteAddress}:${r.remotePort}`:r.remoteAddress:"unknown"}getDeadline(){return this.deadline}getHost(){return this.host}getAuthContext(){var e;if(((e=this.stream.session)===null||e===void 0?void 0:e.socket)instanceof sxe.TLSSocket){let r=this.stream.session.socket.getPeerCertificate();return{transportSecurityType:"ssl",sslPeerCertificate:r.raw?r:void 0}}else return{}}getConnectionInfo(){return this.connectionInfo}getMetricsRecorder(){return this.metricsRecorder}};jn.BaseServerInterceptingCall=Bb;function fxe(t,e,r,n,i,o){let s={path:i.path,requestStream:i.type==="clientStream"||i.type==="bidi",responseStream:i.type==="serverStream"||i.type==="bidi",requestDeserialize:i.deserialize,responseSerialize:i.serialize},a=new Bb(e,r,n,i,o);return t.reduce((c,l)=>l(s,c),a)}});var nK=b(Ta=>{"use strict";var pxe=Ta&&Ta.__runInitializers||function(t,e,r){for(var n=arguments.length>2,i=0;i<e.length;i++)r=n?e[i].call(t,r):e[i].call(t);return n?r:void 0},hxe=Ta&&Ta.__esDecorate||function(t,e,r,n,i,o){function s(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&t?n.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),d,f=!1,p=r.length-1;p>=0;p--){var h={};for(var m in n)h[m]=m==="access"?{}:n[m];for(var m in n.access)h.access[m]=n.access[m];h.addInitializer=function(S){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(S||null))};var y=(0,r[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],h);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=s(y.get))&&(u.get=d),(d=s(y.set))&&(u.set=d),(d=s(y.init))&&i.unshift(d)}else(d=s(y))&&(a==="field"?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,n.name,u),f=!0};Object.defineProperty(Ta,"__esModule",{value:!0});Ta.Server=void 0;var qr=Z("http2"),mxe=Z("util"),Rt=je(),xd=L8(),dk=Mb(),J8=ni(),Td=st(),ba=zr(),_i=Rr(),Ft=_a(),X8=uk(),bd=~(1<<31),fk=~(1<<31),gxe=2e4,Q8=~(1<<31),{HTTP2_HEADER_PATH:eK}=qr.constants,_xe="server",tK=Buffer.from("max_age");function rK(t){Td.trace(Rt.LogVerbosity.DEBUG,"server_call",t)}function yxe(){}function Sxe(t){return function(e,r){return mxe.deprecate(e,t)}}function pk(t){return{code:Rt.Status.UNIMPLEMENTED,details:`The server does not implement the method ${t}`}}function Exe(t,e){let r=pk(e);switch(t){case"unary":return(n,i)=>{i(r,null)};case"clientStream":return(n,i)=>{i(r,null)};case"serverStream":return n=>{n.emit("error",r)};case"bidi":return n=>{n.emit("error",r)};default:throw new Error(`Invalid handlerType ${t}`)}}var vxe=(()=>{var t;let e=[],r;return t=class{constructor(i){var o,s,a,c,l,u;this.boundPorts=(pxe(this,e),new Map),this.http2Servers=new Map,this.sessionIdleTimeouts=new Map,this.handlers=new Map,this.sessions=new Map,this.started=!1,this.shutdown=!1,this.serverAddressString="null",this.channelzEnabled=!0,this.options=i??{},this.options["grpc.enable_channelz"]===0?(this.channelzEnabled=!1,this.channelzTrace=new Ft.ChannelzTraceStub,this.callTracker=new Ft.ChannelzCallTrackerStub,this.listenerChildrenTracker=new Ft.ChannelzChildrenTrackerStub,this.sessionChildrenTracker=new Ft.ChannelzChildrenTrackerStub):(this.channelzTrace=new Ft.ChannelzTrace,this.callTracker=new Ft.ChannelzCallTracker,this.listenerChildrenTracker=new Ft.ChannelzChildrenTracker,this.sessionChildrenTracker=new Ft.ChannelzChildrenTracker),this.channelzRef=(0,Ft.registerChannelzServer)("server",()=>this.getChannelzInfo(),this.channelzEnabled),this.channelzTrace.addTrace("CT_INFO","Server created"),this.maxConnectionAgeMs=(o=this.options["grpc.max_connection_age_ms"])!==null&&o!==void 0?o:bd,this.maxConnectionAgeGraceMs=(s=this.options["grpc.max_connection_age_grace_ms"])!==null&&s!==void 0?s:bd,this.keepaliveTimeMs=(a=this.options["grpc.keepalive_time_ms"])!==null&&a!==void 0?a:fk,this.keepaliveTimeoutMs=(c=this.options["grpc.keepalive_timeout_ms"])!==null&&c!==void 0?c:gxe,this.sessionIdleTimeout=(l=this.options["grpc.max_connection_idle_ms"])!==null&&l!==void 0?l:Q8,this.commonServerOptions={maxSendHeaderBlockLength:Number.MAX_SAFE_INTEGER},"grpc-node.max_session_memory"in this.options?this.commonServerOptions.maxSessionMemory=this.options["grpc-node.max_session_memory"]:this.commonServerOptions.maxSessionMemory=Number.MAX_SAFE_INTEGER,"grpc.max_concurrent_streams"in this.options&&(this.commonServerOptions.settings={maxConcurrentStreams:this.options["grpc.max_concurrent_streams"]}),this.interceptors=(u=this.options.interceptors)!==null&&u!==void 0?u:[],this.trace("Server constructed")}getChannelzInfo(){return{trace:this.channelzTrace,callTracker:this.callTracker,listenerChildren:this.listenerChildrenTracker.getChildLists(),sessionChildren:this.sessionChildrenTracker.getChildLists()}}getChannelzSessionInfo(i){var o,s,a;let c=this.sessions.get(i),l=i.socket,u=l.remoteAddress?(0,ba.stringToSubchannelAddress)(l.remoteAddress,l.remotePort):null,d=l.localAddress?(0,ba.stringToSubchannelAddress)(l.localAddress,l.localPort):null,f;if(i.encrypted){let h=l,m=h.getCipher(),y=h.getCertificate(),S=h.getPeerCertificate();f={cipherSuiteStandardName:(o=m.standardName)!==null&&o!==void 0?o:null,cipherSuiteOtherName:m.standardName?null:m.name,localCertificate:y&&"raw"in y?y.raw:null,remoteCertificate:S&&"raw"in S?S.raw:null}}else f=null;return{remoteAddress:u,localAddress:d,security:f,remoteName:null,streamsStarted:c.streamTracker.callsStarted,streamsSucceeded:c.streamTracker.callsSucceeded,streamsFailed:c.streamTracker.callsFailed,messagesSent:c.messagesSent,messagesReceived:c.messagesReceived,keepAlivesSent:c.keepAlivesSent,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:c.streamTracker.lastCallStartedTimestamp,lastMessageSentTimestamp:c.lastMessageSentTimestamp,lastMessageReceivedTimestamp:c.lastMessageReceivedTimestamp,localFlowControlWindow:(s=i.state.localWindowSize)!==null&&s!==void 0?s:null,remoteFlowControlWindow:(a=i.state.remoteWindowSize)!==null&&a!==void 0?a:null}}trace(i){Td.trace(Rt.LogVerbosity.DEBUG,_xe,"("+this.channelzRef.id+") "+i)}keepaliveTrace(i){Td.trace(Rt.LogVerbosity.DEBUG,"keepalive","("+this.channelzRef.id+") "+i)}addProtoService(){throw new Error("Not implemented. Use addService() instead")}addService(i,o){if(i===null||typeof i!="object"||o===null||typeof o!="object")throw new Error("addService() requires two objects as arguments");let s=Object.keys(i);if(s.length===0)throw new Error("Cannot add an empty service to a server");s.forEach(a=>{let c=i[a],l;c.requestStream?c.responseStream?l="bidi":l="clientStream":c.responseStream?l="serverStream":l="unary";let u=o[a],d;if(u===void 0&&typeof c.originalName=="string"&&(u=o[c.originalName]),u!==void 0?d=u.bind(o):d=Exe(l,a),this.register(c.path,d,c.responseSerialize,c.requestDeserialize,l)===!1)throw new Error(`Method handler for ${c.path} already provided.`)})}removeService(i){if(i===null||typeof i!="object")throw new Error("removeService() requires object as argument");Object.keys(i).forEach(s=>{let a=i[s];this.unregister(a.path)})}bind(i,o){throw new Error("Not implemented. Use bindAsync() instead")}experimentalRegisterListenerToChannelz(i){return(0,Ft.registerChannelzSocket)((0,ba.subchannelAddressToString)(i),()=>({localAddress:i,remoteAddress:null,security:null,remoteName:null,streamsStarted:0,streamsSucceeded:0,streamsFailed:0,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:null,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null,localFlowControlWindow:null,remoteFlowControlWindow:null}),this.channelzEnabled)}experimentalUnregisterListenerFromChannelz(i){(0,Ft.unregisterChannelzRef)(i)}createHttp2Server(i){let o;if(i._isSecure()){let s=i._getConstructorOptions(),a=i._getSecureContextOptions(),c=Object.assign(Object.assign(Object.assign(Object.assign({},this.commonServerOptions),s),a),{enableTrace:this.options["grpc-node.tls_enable_trace"]===1}),l=a!==null;this.trace("Initial credentials valid: "+l),o=qr.createSecureServer(c),o.prependListener("connection",d=>{l||(this.trace("Dropped connection from "+JSON.stringify(d.address())+" due to unloaded credentials"),d.destroy())}),o.on("secureConnection",d=>{d.on("error",f=>{this.trace("An incoming TLS connection closed with error: "+f.message)})});let u=d=>{if(d){let f=o;try{f.setSecureContext(d)}catch(p){Td.log(Rt.LogVerbosity.ERROR,"Failed to set secure context with error "+p.message),d=null}}l=d!==null,this.trace("Post-update credentials valid: "+l)};i._addWatcher(u),o.on("close",()=>{i._removeWatcher(u)})}else o=qr.createServer(this.commonServerOptions);return o.setTimeout(0,yxe),this._setupHandlers(o,i._getInterceptors()),o}bindOneAddress(i,o){this.trace("Attempting to bind "+(0,ba.subchannelAddressToString)(i));let s=this.createHttp2Server(o.credentials);return new Promise((a,c)=>{let l=u=>{this.trace("Failed to bind "+(0,ba.subchannelAddressToString)(i)+" with error "+u.message),a({port:"port"in i?i.port:1,error:u.message})};s.once("error",l),s.listen(i,()=>{let u=s.address(),d;typeof u=="string"?d={path:u}:d={host:u.address,port:u.port};let f=this.experimentalRegisterListenerToChannelz(d);this.listenerChildrenTracker.refChild(f),this.http2Servers.set(s,{channelzRef:f,sessions:new Set,ownsChannelzRef:!0}),o.listeningServers.add(s),this.trace("Successfully bound "+(0,ba.subchannelAddressToString)(d)),a({port:"port"in d?d.port:1}),s.removeListener("error",l)})})}async bindManyPorts(i,o){if(i.length===0)return{count:0,port:0,errors:[]};if((0,ba.isTcpSubchannelAddress)(i[0])&&i[0].port===0){let s=await this.bindOneAddress(i[0],o);if(s.error){let a=await this.bindManyPorts(i.slice(1),o);return Object.assign(Object.assign({},a),{errors:[s.error,...a.errors]})}else{let a=i.slice(1).map(u=>(0,ba.isTcpSubchannelAddress)(u)?{host:u.host,port:s.port}:u),c=await Promise.all(a.map(u=>this.bindOneAddress(u,o))),l=[s,...c];return{count:l.filter(u=>u.error===void 0).length,port:s.port,errors:l.filter(u=>u.error).map(u=>u.error)}}}else{let s=await Promise.all(i.map(a=>this.bindOneAddress(a,o)));return{count:s.filter(a=>a.error===void 0).length,port:s[0].port,errors:s.filter(a=>a.error).map(a=>a.error)}}}async bindAddressList(i,o){let s=await this.bindManyPorts(i,o);if(s.count>0)return s.count<i.length&&Td.log(Rt.LogVerbosity.INFO,`WARNING Only ${s.count} addresses added out of total ${i.length} resolved`),s.port;{let a=`No address added out of total ${i.length} resolved`;throw Td.log(Rt.LogVerbosity.ERROR,a),new Error(`${a} errors: [${s.errors.join(",")}]`)}}resolvePort(i){return new Promise((o,s)=>{let a=!1,c=(u,d,f,p)=>{if(a)return!0;if(a=!0,!u.ok)return s(new Error(u.error.details)),!0;let h=[].concat(...u.value.map(m=>m.addresses));return h.length===0?(s(new Error(`No addresses resolved for port ${i}`)),!0):(o(h),!0)};(0,J8.createResolver)(i,c,this.options).updateResolution()})}async bindPort(i,o){let s=await this.resolvePort(i);if(o.cancelled)throw this.completeUnbind(o),new Error("bindAsync operation cancelled by unbind call");let a=await this.bindAddressList(s,o);if(o.cancelled)throw this.completeUnbind(o),new Error("bindAsync operation cancelled by unbind call");return a}normalizePort(i){let o=(0,_i.parseUri)(i);if(o===null)throw new Error(`Could not parse port "${i}"`);let s=(0,J8.mapUriDefaultScheme)(o);if(s===null)throw new Error(`Could not get a default scheme for port "${i}"`);return s}bindAsync(i,o,s){if(this.shutdown)throw new Error("bindAsync called after shutdown");if(typeof i!="string")throw new TypeError("port must be a string");if(o===null||!(o instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");if(typeof s!="function")throw new TypeError("callback must be a function");this.trace("bindAsync port="+i);let a=this.normalizePort(i),c=(f,p)=>{process.nextTick(()=>s(f,p))},l=this.boundPorts.get((0,_i.uriToString)(a));if(l){if(!o._equals(l.credentials)){c(new Error(`${i} already bound with incompatible credentials`),0);return}l.cancelled=!1,l.completionPromise?l.completionPromise.then(f=>s(null,f),f=>s(f,0)):c(null,l.portNumber);return}l={mapKey:(0,_i.uriToString)(a),originalUri:a,completionPromise:null,cancelled:!1,portNumber:0,credentials:o,listeningServers:new Set};let u=(0,_i.splitHostPort)(a.path),d=this.bindPort(a,l);l.completionPromise=d,u?.port===0?d.then(f=>{let p={scheme:a.scheme,authority:a.authority,path:(0,_i.combineHostPort)({host:u.host,port:f})};l.mapKey=(0,_i.uriToString)(p),l.completionPromise=null,l.portNumber=f,this.boundPorts.set(l.mapKey,l),s(null,f)},f=>{s(f,0)}):(this.boundPorts.set(l.mapKey,l),d.then(f=>{l.completionPromise=null,l.portNumber=f,s(null,f)},f=>{s(f,0)}))}registerInjectorToChannelz(){return(0,Ft.registerChannelzSocket)("injector",()=>({localAddress:null,remoteAddress:null,security:null,remoteName:null,streamsStarted:0,streamsSucceeded:0,streamsFailed:0,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:null,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null,localFlowControlWindow:null,remoteFlowControlWindow:null}),this.channelzEnabled)}experimentalCreateConnectionInjectorWithChannelzRef(i,o,s=!1){if(i===null||!(i instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");this.channelzEnabled&&this.listenerChildrenTracker.refChild(o);let a=this.createHttp2Server(i),c=new Set;return this.http2Servers.set(a,{channelzRef:o,sessions:c,ownsChannelzRef:s}),{injectConnection:l=>{a.emit("connection",l)},drain:l=>{var u,d;for(let f of c)this.closeSession(f);(d=(u=setTimeout(()=>{for(let f of c)f.destroy(qr.constants.NGHTTP2_CANCEL)},l)).unref)===null||d===void 0||d.call(u)},destroy:()=>{this.closeServer(a);for(let l of c)this.closeSession(l)}}}createConnectionInjector(i){if(i===null||!(i instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");let o=this.registerInjectorToChannelz();return this.experimentalCreateConnectionInjectorWithChannelzRef(i,o,!0)}closeServer(i,o){this.trace("Closing server with address "+JSON.stringify(i.address()));let s=this.http2Servers.get(i);i.close(()=>{s&&s.ownsChannelzRef&&(this.listenerChildrenTracker.unrefChild(s.channelzRef),(0,Ft.unregisterChannelzRef)(s.channelzRef)),this.http2Servers.delete(i),o?.()})}closeSession(i,o){var s;this.trace("Closing session initiated by "+((s=i.socket)===null||s===void 0?void 0:s.remoteAddress));let a=this.sessions.get(i),c=()=>{a&&(this.sessionChildrenTracker.unrefChild(a.ref),(0,Ft.unregisterChannelzRef)(a.ref)),o?.()};i.closed?queueMicrotask(c):i.close(c)}completeUnbind(i){for(let o of i.listeningServers){let s=this.http2Servers.get(o);if(this.closeServer(o,()=>{i.listeningServers.delete(o)}),s)for(let a of s.sessions)this.closeSession(a)}this.boundPorts.delete(i.mapKey)}unbind(i){this.trace("unbind port="+i);let o=this.normalizePort(i),s=(0,_i.splitHostPort)(o.path);if(s?.port===0)throw new Error("Cannot unbind port 0");let a=this.boundPorts.get((0,_i.uriToString)(o));a&&(this.trace("unbinding "+a.mapKey+" originally bound as "+(0,_i.uriToString)(a.originalUri)),a.completionPromise?a.cancelled=!0:this.completeUnbind(a))}drain(i,o){var s,a;this.trace("drain port="+i+" graceTimeMs="+o);let c=this.normalizePort(i),l=(0,_i.splitHostPort)(c.path);if(l?.port===0)throw new Error("Cannot drain port 0");let u=this.boundPorts.get((0,_i.uriToString)(c));if(!u)return;let d=new Set;for(let f of u.listeningServers){let p=this.http2Servers.get(f);if(p)for(let h of p.sessions)d.add(h),this.closeSession(h,()=>{d.delete(h)})}(a=(s=setTimeout(()=>{for(let f of d)f.destroy(qr.constants.NGHTTP2_CANCEL)},o)).unref)===null||a===void 0||a.call(s)}forceShutdown(){for(let i of this.boundPorts.values())i.cancelled=!0;this.boundPorts.clear();for(let i of this.http2Servers.keys())this.closeServer(i);this.sessions.forEach((i,o)=>{this.closeSession(o),o.destroy(qr.constants.NGHTTP2_CANCEL)}),this.sessions.clear(),(0,Ft.unregisterChannelzRef)(this.channelzRef),this.shutdown=!0}register(i,o,s,a,c){return this.handlers.has(i)?!1:(this.handlers.set(i,{func:o,serialize:s,deserialize:a,type:c,path:i}),!0)}unregister(i){return this.handlers.delete(i)}start(){if(this.http2Servers.size===0||[...this.http2Servers.keys()].every(i=>!i.listening))throw new Error("server must be bound in order to start");if(this.started===!0)throw new Error("server is already started");this.started=!0}tryShutdown(i){var o;let s=l=>{(0,Ft.unregisterChannelzRef)(this.channelzRef),i(l)},a=0;function c(){a--,a===0&&s()}this.shutdown=!0;for(let[l,u]of this.http2Servers.entries()){a++;let d=u.channelzRef.name;this.trace("Waiting for server "+d+" to close"),this.closeServer(l,()=>{this.trace("Server "+d+" finished closing"),c()});for(let f of u.sessions.keys()){a++;let p=(o=f.socket)===null||o===void 0?void 0:o.remoteAddress;this.trace("Waiting for session "+p+" to close"),this.closeSession(f,()=>{this.trace("Session "+p+" finished closing"),c()})}}a===0&&s()}addHttp2Port(){throw new Error("Not yet implemented")}getChannelzRef(){return this.channelzRef}_verifyContentType(i,o){let s=o[qr.constants.HTTP2_HEADER_CONTENT_TYPE];return typeof s!="string"||!s.startsWith("application/grpc")?(i.respond({[qr.constants.HTTP2_HEADER_STATUS]:qr.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE},{endStream:!0}),!1):!0}_retrieveHandler(i){rK("Received call to method "+i+" at address "+this.serverAddressString);let o=this.handlers.get(i);return o===void 0?(rK("No handler registered for method "+i+". Sending UNIMPLEMENTED status."),null):o}_respondWithError(i,o,s=null){var a,c;let l=Object.assign({"grpc-status":(a=i.code)!==null&&a!==void 0?a:Rt.Status.INTERNAL,"grpc-message":i.details,[qr.constants.HTTP2_HEADER_STATUS]:qr.constants.HTTP_STATUS_OK,[qr.constants.HTTP2_HEADER_CONTENT_TYPE]:"application/grpc+proto"},(c=i.metadata)===null||c===void 0?void 0:c.toHttp2Headers());o.respond(l,{endStream:!0}),this.callTracker.addCallFailed(),s?.streamTracker.addCallFailed()}_channelzHandler(i,o,s){o.once("error",f=>{}),this.onStreamOpened(o);let a=this.sessions.get(o.session);if(this.callTracker.addCallStarted(),a?.streamTracker.addCallStarted(),!this._verifyContentType(o,s)){this.callTracker.addCallFailed(),a?.streamTracker.addCallFailed();return}let c=s[eK],l=this._retrieveHandler(c);if(!l){this._respondWithError(pk(c),o,a);return}let u={addMessageSent:()=>{a&&(a.messagesSent+=1,a.lastMessageSentTimestamp=new Date)},addMessageReceived:()=>{a&&(a.messagesReceived+=1,a.lastMessageReceivedTimestamp=new Date)},onCallEnd:f=>{f.code===Rt.Status.OK?this.callTracker.addCallSucceeded():this.callTracker.addCallFailed()},onStreamEnd:f=>{a&&(f?a.streamTracker.addCallSucceeded():a.streamTracker.addCallFailed())}},d=(0,X8.getServerInterceptingCall)([...i,...this.interceptors],o,s,u,l,this.options);this._runHandlerForCall(d,l)||(this.callTracker.addCallFailed(),a?.streamTracker.addCallFailed(),d.sendStatus({code:Rt.Status.INTERNAL,details:`Unknown handler type: ${l.type}`}))}_streamHandler(i,o,s){if(o.once("error",u=>{}),this.onStreamOpened(o),this._verifyContentType(o,s)!==!0)return;let a=s[eK],c=this._retrieveHandler(a);if(!c){this._respondWithError(pk(a),o,null);return}let l=(0,X8.getServerInterceptingCall)([...i,...this.interceptors],o,s,null,c,this.options);this._runHandlerForCall(l,c)||l.sendStatus({code:Rt.Status.INTERNAL,details:`Unknown handler type: ${c.type}`})}_runHandlerForCall(i,o){let{type:s}=o;if(s==="unary")bxe(i,o);else if(s==="clientStream")Txe(i,o);else if(s==="serverStream")xxe(i,o);else if(s==="bidi")wxe(i,o);else return!1;return!0}_setupHandlers(i,o){if(i===null)return;let s=i.address(),a="null";s&&(typeof s=="string"?a=s:a=s.address+":"+s.port),this.serverAddressString=a;let c=this.channelzEnabled?this._channelzHandler:this._streamHandler,l=this.channelzEnabled?this._channelzSessionHandler(i):this._sessionHandler(i);i.on("stream",c.bind(this,o)),i.on("session",l)}_sessionHandler(i){return o=>{var s,a;(s=this.http2Servers.get(i))===null||s===void 0||s.sessions.add(o);let c=null,l=null,u=null,d=!1,f=this.enableIdleTimeout(o);if(this.maxConnectionAgeMs!==bd){let S=this.maxConnectionAgeMs/10,T=Math.random()*S*2-S;c=setTimeout(()=>{var x,v;d=!0,this.trace("Connection dropped by max connection age: "+((x=o.socket)===null||x===void 0?void 0:x.remoteAddress));try{o.goaway(qr.constants.NGHTTP2_NO_ERROR,~(1<<31),tK)}catch{o.destroy();return}o.close(),this.maxConnectionAgeGraceMs!==bd&&(l=setTimeout(()=>{o.destroy()},this.maxConnectionAgeGraceMs),(v=l.unref)===null||v===void 0||v.call(l))},this.maxConnectionAgeMs+T),(a=c.unref)===null||a===void 0||a.call(c)}let p=()=>{u&&(clearTimeout(u),u=null)},h=()=>!o.destroyed&&this.keepaliveTimeMs<fk&&this.keepaliveTimeMs>0,m,y=()=>{var S;h()&&(this.keepaliveTrace("Starting keepalive timer for "+this.keepaliveTimeMs+"ms"),u=setTimeout(()=>{p(),m()},this.keepaliveTimeMs),(S=u.unref)===null||S===void 0||S.call(u))};m=()=>{var S;if(!h())return;this.keepaliveTrace("Sending ping with timeout "+this.keepaliveTimeoutMs+"ms");let T="";try{o.ping((v,N,R)=>{p(),v?(this.keepaliveTrace("Ping failed with error: "+v.message),d=!0,o.destroy()):(this.keepaliveTrace("Received ping response"),y())})||(T="Ping returned false")}catch(x){T=(x instanceof Error?x.message:"")||"Unknown error"}if(T){this.keepaliveTrace("Ping send failed: "+T),this.trace("Connection dropped due to ping send error: "+T),d=!0,o.destroy();return}u=setTimeout(()=>{p(),this.keepaliveTrace("Ping timeout passed without response"),this.trace("Connection dropped by keepalive timeout"),d=!0,o.destroy()},this.keepaliveTimeoutMs),(S=u.unref)===null||S===void 0||S.call(u)},y(),o.on("close",()=>{var S,T;d||this.trace(`Connection dropped by client ${(S=o.socket)===null||S===void 0?void 0:S.remoteAddress}`),c&&clearTimeout(c),l&&clearTimeout(l),p(),f!==null&&(clearTimeout(f.timeout),this.sessionIdleTimeouts.delete(o)),(T=this.http2Servers.get(i))===null||T===void 0||T.sessions.delete(o)})}}_channelzSessionHandler(i){return o=>{var s,a,c,l;let u=(0,Ft.registerChannelzSocket)((a=(s=o.socket)===null||s===void 0?void 0:s.remoteAddress)!==null&&a!==void 0?a:"unknown",this.getChannelzSessionInfo.bind(this,o),this.channelzEnabled),d={ref:u,streamTracker:new Ft.ChannelzCallTracker,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null};(c=this.http2Servers.get(i))===null||c===void 0||c.sessions.add(o),this.sessions.set(o,d);let f=`${o.socket.remoteAddress}:${o.socket.remotePort}`;this.channelzTrace.addTrace("CT_INFO","Connection established by client "+f),this.trace("Connection established by client "+f),this.sessionChildrenTracker.refChild(u);let p=null,h=null,m=null,y=!1,S=this.enableIdleTimeout(o);if(this.maxConnectionAgeMs!==bd){let R=this.maxConnectionAgeMs/10,U=Math.random()*R*2-R;p=setTimeout(()=>{var C;y=!0,this.channelzTrace.addTrace("CT_INFO","Connection dropped by max connection age from "+f);try{o.goaway(qr.constants.NGHTTP2_NO_ERROR,~(1<<31),tK)}catch{o.destroy();return}o.close(),this.maxConnectionAgeGraceMs!==bd&&(h=setTimeout(()=>{o.destroy()},this.maxConnectionAgeGraceMs),(C=h.unref)===null||C===void 0||C.call(h))},this.maxConnectionAgeMs+U),(l=p.unref)===null||l===void 0||l.call(p)}let T=()=>{m&&(clearTimeout(m),m=null)},x=()=>!o.destroyed&&this.keepaliveTimeMs<fk&&this.keepaliveTimeMs>0,v,N=()=>{var R;x()&&(this.keepaliveTrace("Starting keepalive timer for "+this.keepaliveTimeMs+"ms"),m=setTimeout(()=>{T(),v()},this.keepaliveTimeMs),(R=m.unref)===null||R===void 0||R.call(m))};v=()=>{var R;if(!x())return;this.keepaliveTrace("Sending ping with timeout "+this.keepaliveTimeoutMs+"ms");let U="";try{o.ping((D,j,_)=>{T(),D?(this.keepaliveTrace("Ping failed with error: "+D.message),this.channelzTrace.addTrace("CT_INFO","Connection dropped due to error of a ping frame "+D.message+" return in "+j),y=!0,o.destroy()):(this.keepaliveTrace("Received ping response"),N())})||(U="Ping returned false")}catch(C){U=(C instanceof Error?C.message:"")||"Unknown error"}if(U){this.keepaliveTrace("Ping send failed: "+U),this.channelzTrace.addTrace("CT_INFO","Connection dropped due to ping send error: "+U),y=!0,o.destroy();return}d.keepAlivesSent+=1,m=setTimeout(()=>{T(),this.keepaliveTrace("Ping timeout passed without response"),this.channelzTrace.addTrace("CT_INFO","Connection dropped by keepalive timeout from "+f),y=!0,o.destroy()},this.keepaliveTimeoutMs),(R=m.unref)===null||R===void 0||R.call(m)},N(),o.on("close",()=>{var R;y||this.channelzTrace.addTrace("CT_INFO","Connection dropped by client "+f),this.sessionChildrenTracker.unrefChild(u),(0,Ft.unregisterChannelzRef)(u),p&&clearTimeout(p),h&&clearTimeout(h),T(),S!==null&&(clearTimeout(S.timeout),this.sessionIdleTimeouts.delete(o)),(R=this.http2Servers.get(i))===null||R===void 0||R.sessions.delete(o),this.sessions.delete(o)})}}enableIdleTimeout(i){var o,s;if(this.sessionIdleTimeout>=Q8)return null;let a={activeStreams:0,lastIdle:Date.now(),onClose:this.onStreamClose.bind(this,i),timeout:setTimeout(this.onIdleTimeout,this.sessionIdleTimeout,this,i)};(s=(o=a.timeout).unref)===null||s===void 0||s.call(o),this.sessionIdleTimeouts.set(i,a);let{socket:c}=i;return this.trace("Enable idle timeout for "+c.remoteAddress+":"+c.remotePort),a}onIdleTimeout(i,o){let{socket:s}=o,a=i.sessionIdleTimeouts.get(o);a!==void 0&&a.activeStreams===0&&(Date.now()-a.lastIdle>=i.sessionIdleTimeout?(i.trace("Session idle timeout triggered for "+s?.remoteAddress+":"+s?.remotePort+" last idle at "+a.lastIdle),i.closeSession(o)):a.timeout.refresh())}onStreamOpened(i){let o=i.session,s=this.sessionIdleTimeouts.get(o);s&&(s.activeStreams+=1,i.once("close",s.onClose))}onStreamClose(i){var o,s;let a=this.sessionIdleTimeouts.get(i);a&&(a.activeStreams-=1,a.activeStreams===0&&(a.lastIdle=Date.now(),a.timeout.refresh(),this.trace("Session onStreamClose"+((o=i.socket)===null||o===void 0?void 0:o.remoteAddress)+":"+((s=i.socket)===null||s===void 0?void 0:s.remotePort)+" at "+a.lastIdle)))}},(()=>{let n=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;r=[Sxe("Calling start() is no longer necessary. It can be safely omitted.")],hxe(t,null,r,{kind:"method",name:"start",static:!1,private:!1,access:{has:i=>"start"in i,get:i=>i.start},metadata:n},null,e),n&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n})})(),t})();Ta.Server=vxe;async function bxe(t,e){let r;function n(s,a,c,l){if(s){t.sendStatus((0,xd.serverErrorToStatus)(s,c));return}t.sendMessage(a,()=>{t.sendStatus({code:Rt.Status.OK,details:"OK",metadata:c??null})})}let i,o=null;t.start({onReceiveMetadata(s){i=s,t.startRead()},onReceiveMessage(s){if(o){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received a second request message for server streaming method ${e.path}`,metadata:null});return}o=s,t.startRead()},onReceiveHalfClose(){if(!o){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received no request message for server streaming method ${e.path}`,metadata:null});return}r=new xd.ServerWritableStreamImpl(e.path,t,i,o);try{e.func(r,n)}catch(s){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${s.message}`,metadata:null})}},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"))}})}function Txe(t,e){let r;function n(i,o,s,a){if(i){t.sendStatus((0,xd.serverErrorToStatus)(i,s));return}t.sendMessage(o,()=>{t.sendStatus({code:Rt.Status.OK,details:"OK",metadata:s??null})})}t.start({onReceiveMetadata(i){r=new xd.ServerDuplexStreamImpl(e.path,t,i);try{e.func(r,n)}catch(o){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${o.message}`,metadata:null})}},onReceiveMessage(i){r.push(i)},onReceiveHalfClose(){r.push(null)},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}function xxe(t,e){let r,n,i=null;t.start({onReceiveMetadata(o){n=o,t.startRead()},onReceiveMessage(o){if(i){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received a second request message for server streaming method ${e.path}`,metadata:null});return}i=o,t.startRead()},onReceiveHalfClose(){if(!i){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received no request message for server streaming method ${e.path}`,metadata:null});return}r=new xd.ServerWritableStreamImpl(e.path,t,n,i);try{e.func(r)}catch(o){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${o.message}`,metadata:null})}},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}function wxe(t,e){let r;t.start({onReceiveMetadata(n){r=new xd.ServerDuplexStreamImpl(e.path,t,n);try{e.func(r)}catch(i){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${i.message}`,metadata:null})}},onReceiveMessage(n){r.push(n)},onReceiveHalfClose(){r.push(null)},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}});var iK=b(jb=>{"use strict";Object.defineProperty(jb,"__esModule",{value:!0});jb.StatusBuilder=void 0;var hk=class{constructor(){this.code=null,this.details=null,this.metadata=null}withCode(e){return this.code=e,this}withDetails(e){return this.details=e,this}withMetadata(e){return this.metadata=e,this}build(){let e={};return this.code!==null&&(e.code=this.code),this.details!==null&&(e.details=this.details),this.metadata!==null&&(e.metadata=this.metadata),e}};jb.StatusBuilder=hk});var vg=b(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.LeafLoadBalancer=oo.PickFirstLoadBalancer=oo.PickFirstLoadBalancingConfig=void 0;oo.shuffled=cK;oo.setup=kxe;var mk=aa(),It=Ir(),xa=Ho(),oK=zr(),Axe=st(),Rxe=je(),sK=zr(),aK=Z("net"),Ixe=Kc(),Cxe="pick_first";function yg(t){Axe.trace(Rxe.LogVerbosity.DEBUG,Cxe,t)}var Sg="pick_first",Pxe=250,wd=class t{constructor(e){this.shuffleAddressList=e}getLoadBalancerName(){return Sg}toJsonObject(){return{[Sg]:{shuffleAddressList:this.shuffleAddressList}}}getShuffleAddressList(){return this.shuffleAddressList}static createFromJson(e){if("shuffleAddressList"in e&&typeof e.shuffleAddressList!="boolean")throw new Error("pick_first config field shuffleAddressList must be a boolean if provided");return new t(e.shuffleAddressList===!0)}};oo.PickFirstLoadBalancingConfig=wd;var gk=class{constructor(e){this.subchannel=e}pick(e){return{pickResultType:xa.PickResultType.COMPLETE,subchannel:this.subchannel,status:null,onCallStarted:null,onCallEnded:null}}};function cK(t){let e=t.slice();for(let r=e.length-1;r>1;r--){let n=Math.floor(Math.random()*(r+1)),i=e[r];e[r]=e[n],e[n]=i}return e}function Oxe(t){if(t.length===0)return[];let e=[],r=[],n=[],i=(0,sK.isTcpSubchannelAddress)(t[0])&&(0,aK.isIPv6)(t[0].host);for(let a of t)(0,sK.isTcpSubchannelAddress)(a)&&(0,aK.isIPv6)(a.host)?r.push(a):n.push(a);let o=i?r:n,s=i?n:r;for(let a=0;a<Math.max(o.length,s.length);a++)a<o.length&&e.push(o[a]),a<s.length&&e.push(s[a]);return e}var lK="grpc-node.internal.pick-first.report_health_status",Eg=class{constructor(e){this.channelControlHelper=e,this.children=[],this.currentState=It.ConnectivityState.IDLE,this.currentSubchannelIndex=0,this.currentPick=null,this.subchannelStateListener=(r,n,i,o,s)=>{this.onSubchannelStateUpdate(r,n,i,s)},this.pickedSubchannelHealthListener=()=>this.calculateAndReportNewState(),this.stickyTransientFailureMode=!1,this.reportHealthStatus=!1,this.lastError=null,this.latestAddressList=null,this.latestOptions={},this.latestResolutionNote="",this.connectionDelayTimeout=setTimeout(()=>{},0),clearTimeout(this.connectionDelayTimeout)}allChildrenHaveReportedTF(){return this.children.every(e=>e.hasReportedTransientFailure)}resetChildrenReportedTF(){this.children.every(e=>e.hasReportedTransientFailure=!1)}calculateAndReportNewState(){var e;if(this.currentPick)if(this.reportHealthStatus&&!this.currentPick.isHealthy()){let r=`Picked subchannel ${this.currentPick.getAddress()} is unhealthy`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else this.updateState(It.ConnectivityState.READY,new gk(this.currentPick),null);else if(((e=this.latestAddressList)===null||e===void 0?void 0:e.length)===0){let r=`No connection established. Last error: ${this.lastError}. Resolution note: ${this.latestResolutionNote}`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else if(this.children.length===0)this.updateState(It.ConnectivityState.IDLE,new xa.QueuePicker(this),null);else if(this.stickyTransientFailureMode){let r=`No connection established. Last error: ${this.lastError}. Resolution note: ${this.latestResolutionNote}`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else this.updateState(It.ConnectivityState.CONNECTING,new xa.QueuePicker(this),null)}requestReresolution(){this.channelControlHelper.requestReresolution()}maybeEnterStickyTransientFailureMode(){if(this.allChildrenHaveReportedTF()){if(this.requestReresolution(),this.resetChildrenReportedTF(),this.stickyTransientFailureMode){this.calculateAndReportNewState();return}this.stickyTransientFailureMode=!0;for(let{subchannel:e}of this.children)e.startConnecting();this.calculateAndReportNewState()}}removeCurrentPick(){this.currentPick!==null&&(this.currentPick.removeConnectivityStateListener(this.subchannelStateListener),this.channelControlHelper.removeChannelzChild(this.currentPick.getChannelzRef()),this.currentPick.removeHealthStateWatcher(this.pickedSubchannelHealthListener),this.currentPick.unref(),this.currentPick=null)}onSubchannelStateUpdate(e,r,n,i){var o;if(!((o=this.currentPick)===null||o===void 0)&&o.realSubchannelEquals(e)){n!==It.ConnectivityState.READY&&(this.removeCurrentPick(),this.calculateAndReportNewState());return}for(let[s,a]of this.children.entries())if(e.realSubchannelEquals(a.subchannel)){n===It.ConnectivityState.READY&&this.pickSubchannel(a.subchannel),n===It.ConnectivityState.TRANSIENT_FAILURE&&(a.hasReportedTransientFailure=!0,i&&(this.lastError=i),this.maybeEnterStickyTransientFailureMode(),s===this.currentSubchannelIndex&&this.startNextSubchannelConnecting(s+1)),a.subchannel.startConnecting();return}}startNextSubchannelConnecting(e){clearTimeout(this.connectionDelayTimeout);for(let[r,n]of this.children.entries())if(r>=e){let i=n.subchannel.getConnectivityState();if(i===It.ConnectivityState.IDLE||i===It.ConnectivityState.CONNECTING){this.startConnecting(r);return}}this.maybeEnterStickyTransientFailureMode()}startConnecting(e){var r,n;clearTimeout(this.connectionDelayTimeout),this.currentSubchannelIndex=e,this.children[e].subchannel.getConnectivityState()===It.ConnectivityState.IDLE&&(yg("Start connecting to subchannel with address "+this.children[e].subchannel.getAddress()),process.nextTick(()=>{var i;(i=this.children[e])===null||i===void 0||i.subchannel.startConnecting()})),this.connectionDelayTimeout=setTimeout(()=>{this.startNextSubchannelConnecting(e+1)},Pxe),(n=(r=this.connectionDelayTimeout).unref)===null||n===void 0||n.call(r)}pickSubchannel(e){yg("Pick subchannel with address "+e.getAddress()),this.stickyTransientFailureMode=!1,e.ref(),this.channelControlHelper.addChannelzChild(e.getChannelzRef()),this.removeCurrentPick(),this.resetSubchannelList(),e.addConnectivityStateListener(this.subchannelStateListener),e.addHealthStateWatcher(this.pickedSubchannelHealthListener),this.currentPick=e,clearTimeout(this.connectionDelayTimeout),this.calculateAndReportNewState()}updateState(e,r,n){yg(It.ConnectivityState[this.currentState]+" -> "+It.ConnectivityState[e]),this.currentState=e,this.channelControlHelper.updateState(e,r,n)}resetSubchannelList(){for(let e of this.children)e.subchannel.removeConnectivityStateListener(this.subchannelStateListener),e.subchannel.unref(),this.channelControlHelper.removeChannelzChild(e.subchannel.getChannelzRef());this.currentSubchannelIndex=0,this.children=[]}connectToAddressList(e,r){yg("connectToAddressList(["+e.map(i=>(0,oK.subchannelAddressToString)(i))+"])");let n=e.map(i=>({subchannel:this.channelControlHelper.createSubchannel(i,r),hasReportedTransientFailure:!1}));for(let{subchannel:i}of n)if(i.getConnectivityState()===It.ConnectivityState.READY){this.pickSubchannel(i);return}for(let{subchannel:i}of n)i.ref(),this.channelControlHelper.addChannelzChild(i.getChannelzRef());this.resetSubchannelList(),this.children=n;for(let{subchannel:i}of this.children)i.addConnectivityStateListener(this.subchannelStateListener);for(let i of this.children)i.subchannel.getConnectivityState()===It.ConnectivityState.TRANSIENT_FAILURE&&(i.hasReportedTransientFailure=!0);this.startNextSubchannelConnecting(0),this.calculateAndReportNewState()}updateAddressList(e,r,n,i){if(!(r instanceof wd))return!1;if(!e.ok)return this.children.length===0&&this.currentPick===null&&this.channelControlHelper.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker(e.error),e.error.details),!0;let o=e.value;this.reportHealthStatus=n[lK],r.getShuffleAddressList()&&(o=cK(o));let s=[].concat(...o.map(c=>c.addresses));yg("updateAddressList(["+s.map(c=>(0,oK.subchannelAddressToString)(c))+"])");let a=Oxe(s);return this.latestAddressList=a,this.latestOptions=n,this.connectToAddressList(a,n),this.latestResolutionNote=i,s.length>0?!0:(this.lastError="No addresses resolved",!1)}exitIdle(){this.currentState===It.ConnectivityState.IDLE&&this.latestAddressList&&this.connectToAddressList(this.latestAddressList,this.latestOptions)}resetBackoff(){}destroy(){this.resetSubchannelList(),this.removeCurrentPick()}getTypeName(){return Sg}};oo.PickFirstLoadBalancer=Eg;var Nxe=new wd(!1),_k=class{constructor(e,r,n,i){this.endpoint=e,this.options=n,this.resolutionNote=i,this.latestState=It.ConnectivityState.IDLE;let o=(0,mk.createChildChannelControlHelper)(r,{updateState:(s,a,c)=>{this.latestState=s,this.latestPicker=a,r.updateState(s,a,c)}});this.pickFirstBalancer=new Eg(o),this.latestPicker=new xa.QueuePicker(this.pickFirstBalancer)}startConnecting(){this.pickFirstBalancer.updateAddressList((0,Ixe.statusOrFromValue)([this.endpoint]),Nxe,Object.assign(Object.assign({},this.options),{[lK]:!0}),this.resolutionNote)}updateEndpoint(e,r){this.options=r,this.endpoint=e,this.latestState!==It.ConnectivityState.IDLE&&this.startConnecting()}getConnectivityState(){return this.latestState}getPicker(){return this.latestPicker}getEndpoint(){return this.endpoint}exitIdle(){this.pickFirstBalancer.exitIdle()}destroy(){this.pickFirstBalancer.destroy()}};oo.LeafLoadBalancer=_k;function kxe(){(0,mk.registerLoadBalancerType)(Sg,Eg,wd),(0,mk.registerDefaultLoadBalancerType)(Sg)}});var uK=b(Gb=>{"use strict";Object.defineProperty(Gb,"__esModule",{value:!0});Gb.FileWatcherCertificateProvider=void 0;var Mxe=Z("fs"),Dxe=st(),Lxe=je(),$xe=Z("util"),Uxe="certificate_provider";function zb(t){Dxe.trace(Lxe.LogVerbosity.DEBUG,Uxe,t)}var yk=(0,$xe.promisify)(Mxe.readFile),Sk=class{constructor(e){if(this.config=e,this.refreshTimer=null,this.fileResultPromise=null,this.latestCaUpdate=void 0,this.caListeners=new Set,this.latestIdentityUpdate=void 0,this.identityListeners=new Set,this.lastUpdateTime=null,e.certificateFile===void 0!=(e.privateKeyFile===void 0))throw new Error("certificateFile and privateKeyFile must be set or unset together");if(e.certificateFile===void 0&&e.caCertificateFile===void 0)throw new Error("At least one of certificateFile and caCertificateFile must be set");zb("File watcher constructed with config "+JSON.stringify(e))}updateCertificates(){this.fileResultPromise||(this.fileResultPromise=Promise.allSettled([this.config.certificateFile?yk(this.config.certificateFile):Promise.reject(),this.config.privateKeyFile?yk(this.config.privateKeyFile):Promise.reject(),this.config.caCertificateFile?yk(this.config.caCertificateFile):Promise.reject()]),this.fileResultPromise.then(([e,r,n])=>{if(this.refreshTimer){zb("File watcher read certificates certificate "+e.status+", privateKey "+r.status+", CA certificate "+n.status),this.lastUpdateTime=new Date,this.fileResultPromise=null,e.status==="fulfilled"&&r.status==="fulfilled"?this.latestIdentityUpdate={certificate:e.value,privateKey:r.value}:this.latestIdentityUpdate=null,n.status==="fulfilled"?this.latestCaUpdate={caCertificate:n.value}:this.latestCaUpdate=null;for(let i of this.identityListeners)i(this.latestIdentityUpdate);for(let i of this.caListeners)i(this.latestCaUpdate)}}),zb("File watcher initiated certificate update"))}maybeStartWatchingFiles(){if(!this.refreshTimer){let e=this.lastUpdateTime?new Date().getTime()-this.lastUpdateTime.getTime():1/0;e>this.config.refreshIntervalMs&&this.updateCertificates(),e>this.config.refreshIntervalMs*2&&(this.latestCaUpdate=void 0,this.latestIdentityUpdate=void 0),this.refreshTimer=setInterval(()=>this.updateCertificates(),this.config.refreshIntervalMs),zb("File watcher started watching")}}maybeStopWatchingFiles(){this.caListeners.size===0&&this.identityListeners.size===0&&(this.fileResultPromise=null,this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null))}addCaCertificateListener(e){this.caListeners.add(e),this.maybeStartWatchingFiles(),this.latestCaUpdate!==void 0&&process.nextTick(e,this.latestCaUpdate)}removeCaCertificateListener(e){this.caListeners.delete(e),this.maybeStopWatchingFiles()}addIdentityCertificateListener(e){this.identityListeners.add(e),this.maybeStartWatchingFiles(),this.latestIdentityUpdate!==void 0&&process.nextTick(e,this.latestIdentityUpdate)}removeIdentityCertificateListener(e){this.identityListeners.delete(e),this.maybeStopWatchingFiles()}};Gb.FileWatcherCertificateProvider=Sk});var bk=b(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX=_e.createCertificateProviderChannelCredentials=_e.FileWatcherCertificateProvider=_e.createCertificateProviderServerCredentials=_e.createServerCredentialsWithInterceptors=_e.BaseSubchannelWrapper=_e.registerAdminService=_e.FilterStackFactory=_e.BaseFilter=_e.statusOrFromError=_e.statusOrFromValue=_e.PickResultType=_e.QueuePicker=_e.UnavailablePicker=_e.ChildLoadBalancerHandler=_e.EndpointMap=_e.endpointHasAddress=_e.endpointToString=_e.subchannelAddressToString=_e.LeafLoadBalancer=_e.isLoadBalancerNameRegistered=_e.parseLoadBalancingConfig=_e.selectLbConfigFromList=_e.registerLoadBalancerType=_e.createChildChannelControlHelper=_e.BackoffTimeout=_e.parseDuration=_e.durationToMs=_e.splitHostPort=_e.uriToString=_e.CHANNEL_ARGS_CONFIG_SELECTOR_KEY=_e.createResolver=_e.registerResolver=_e.log=_e.trace=void 0;var dK=st();Object.defineProperty(_e,"trace",{enumerable:!0,get:function(){return dK.trace}});Object.defineProperty(_e,"log",{enumerable:!0,get:function(){return dK.log}});var Ek=ni();Object.defineProperty(_e,"registerResolver",{enumerable:!0,get:function(){return Ek.registerResolver}});Object.defineProperty(_e,"createResolver",{enumerable:!0,get:function(){return Ek.createResolver}});Object.defineProperty(_e,"CHANNEL_ARGS_CONFIG_SELECTOR_KEY",{enumerable:!0,get:function(){return Ek.CHANNEL_ARGS_CONFIG_SELECTOR_KEY}});var fK=Rr();Object.defineProperty(_e,"uriToString",{enumerable:!0,get:function(){return fK.uriToString}});Object.defineProperty(_e,"splitHostPort",{enumerable:!0,get:function(){return fK.splitHostPort}});var pK=_g();Object.defineProperty(_e,"durationToMs",{enumerable:!0,get:function(){return pK.durationToMs}});Object.defineProperty(_e,"parseDuration",{enumerable:!0,get:function(){return pK.parseDuration}});var Fxe=Yu();Object.defineProperty(_e,"BackoffTimeout",{enumerable:!0,get:function(){return Fxe.BackoffTimeout}});var bg=aa();Object.defineProperty(_e,"createChildChannelControlHelper",{enumerable:!0,get:function(){return bg.createChildChannelControlHelper}});Object.defineProperty(_e,"registerLoadBalancerType",{enumerable:!0,get:function(){return bg.registerLoadBalancerType}});Object.defineProperty(_e,"selectLbConfigFromList",{enumerable:!0,get:function(){return bg.selectLbConfigFromList}});Object.defineProperty(_e,"parseLoadBalancingConfig",{enumerable:!0,get:function(){return bg.parseLoadBalancingConfig}});Object.defineProperty(_e,"isLoadBalancerNameRegistered",{enumerable:!0,get:function(){return bg.isLoadBalancerNameRegistered}});var Bxe=vg();Object.defineProperty(_e,"LeafLoadBalancer",{enumerable:!0,get:function(){return Bxe.LeafLoadBalancer}});var qb=zr();Object.defineProperty(_e,"subchannelAddressToString",{enumerable:!0,get:function(){return qb.subchannelAddressToString}});Object.defineProperty(_e,"endpointToString",{enumerable:!0,get:function(){return qb.endpointToString}});Object.defineProperty(_e,"endpointHasAddress",{enumerable:!0,get:function(){return qb.endpointHasAddress}});Object.defineProperty(_e,"EndpointMap",{enumerable:!0,get:function(){return qb.EndpointMap}});var jxe=gv();Object.defineProperty(_e,"ChildLoadBalancerHandler",{enumerable:!0,get:function(){return jxe.ChildLoadBalancerHandler}});var vk=Ho();Object.defineProperty(_e,"UnavailablePicker",{enumerable:!0,get:function(){return vk.UnavailablePicker}});Object.defineProperty(_e,"QueuePicker",{enumerable:!0,get:function(){return vk.QueuePicker}});Object.defineProperty(_e,"PickResultType",{enumerable:!0,get:function(){return vk.PickResultType}});var hK=Kc();Object.defineProperty(_e,"statusOrFromValue",{enumerable:!0,get:function(){return hK.statusOrFromValue}});Object.defineProperty(_e,"statusOrFromError",{enumerable:!0,get:function(){return hK.statusOrFromError}});var zxe=ZO();Object.defineProperty(_e,"BaseFilter",{enumerable:!0,get:function(){return zxe.BaseFilter}});var Gxe=pb();Object.defineProperty(_e,"FilterStackFactory",{enumerable:!0,get:function(){return Gxe.FilterStackFactory}});var qxe=Ev();Object.defineProperty(_e,"registerAdminService",{enumerable:!0,get:function(){return qxe.registerAdminService}});var Vxe=mg();Object.defineProperty(_e,"BaseSubchannelWrapper",{enumerable:!0,get:function(){return Vxe.BaseSubchannelWrapper}});var mK=Mb();Object.defineProperty(_e,"createServerCredentialsWithInterceptors",{enumerable:!0,get:function(){return mK.createServerCredentialsWithInterceptors}});Object.defineProperty(_e,"createCertificateProviderServerCredentials",{enumerable:!0,get:function(){return mK.createCertificateProviderServerCredentials}});var Hxe=uK();Object.defineProperty(_e,"FileWatcherCertificateProvider",{enumerable:!0,get:function(){return Hxe.FileWatcherCertificateProvider}});var Wxe=Wu();Object.defineProperty(_e,"createCertificateProviderChannelCredentials",{enumerable:!0,get:function(){return Wxe.createCertificateProviderChannelCredentials}});var Yxe=UN();Object.defineProperty(_e,"SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX",{enumerable:!0,get:function(){return Yxe.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX}})});var gK=b(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});xk.setup=Jxe;var Kxe=ni(),Zxe=Kc(),Tk=class{constructor(e,r,n){this.listener=r,this.hasReturnedResult=!1,this.endpoints=[];let i;e.authority===""?i="/"+e.path:i=e.path,this.endpoints=[{addresses:[{path:i}]}]}updateResolution(){this.hasReturnedResult||(this.hasReturnedResult=!0,process.nextTick(this.listener,(0,Zxe.statusOrFromValue)(this.endpoints),{},null,""))}destroy(){this.hasReturnedResult=!1}static getDefaultAuthority(e){return"localhost"}};function Jxe(){(0,Kxe.registerResolver)("unix",Tk)}});var bK=b(Ik=>{"use strict";Object.defineProperty(Ik,"__esModule",{value:!0});Ik.setup=rwe;var _K=Z("net"),yK=Kc(),Vb=je(),wk=Wt(),SK=ni(),Xxe=zr(),EK=Rr(),Qxe=st(),ewe="ip_resolver";function vK(t){Qxe.trace(Vb.LogVerbosity.DEBUG,ewe,t)}var Ak="ipv4",Rk="ipv6",twe=443,Hb=class{constructor(e,r,n){var i;this.listener=r,this.endpoints=[],this.error=null,this.hasReturnedResult=!1,vK("Resolver constructed for target "+(0,EK.uriToString)(e));let o=[];if(!(e.scheme===Ak||e.scheme===Rk)){this.error={code:Vb.Status.UNAVAILABLE,details:`Unrecognized scheme ${e.scheme} in IP resolver`,metadata:new wk.Metadata};return}let s=e.path.split(",");for(let a of s){let c=(0,EK.splitHostPort)(a);if(c===null){this.error={code:Vb.Status.UNAVAILABLE,details:`Failed to parse ${e.scheme} address ${a}`,metadata:new wk.Metadata};return}if(e.scheme===Ak&&!(0,_K.isIPv4)(c.host)||e.scheme===Rk&&!(0,_K.isIPv6)(c.host)){this.error={code:Vb.Status.UNAVAILABLE,details:`Failed to parse ${e.scheme} address ${a}`,metadata:new wk.Metadata};return}o.push({host:c.host,port:(i=c.port)!==null&&i!==void 0?i:twe})}this.endpoints=o.map(a=>({addresses:[a]})),vK("Parsed "+e.scheme+" address list "+o.map(Xxe.subchannelAddressToString))}updateResolution(){this.hasReturnedResult||(this.hasReturnedResult=!0,process.nextTick(()=>{this.error?this.listener((0,yK.statusOrFromError)(this.error),{},null,""):this.listener((0,yK.statusOrFromValue)(this.endpoints),{},null,"")}))}destroy(){this.hasReturnedResult=!1}static getDefaultAuthority(e){return e.path.split(",")[0]}};function rwe(){(0,SK.registerResolver)(Ak,Hb),(0,SK.registerResolver)(Rk,Hb)}});var AK=b(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0});xg.RoundRobinLoadBalancer=void 0;xg.setup=cwe;var wK=aa(),sr=Ir(),Tg=Ho(),nwe=st(),iwe=je(),TK=zr(),owe=vg(),swe="round_robin";function xK(t){nwe.trace(iwe.LogVerbosity.DEBUG,swe,t)}var Wb="round_robin",Yb=class t{getLoadBalancerName(){return Wb}constructor(){}toJsonObject(){return{[Wb]:{}}}static createFromJson(e){return new t}},Ck=class{constructor(e,r=0){this.children=e,this.nextIndex=r}pick(e){let r=this.children[this.nextIndex].picker;return this.nextIndex=(this.nextIndex+1)%this.children.length,r.pick(e)}peekNextEndpoint(){return this.children[this.nextIndex].endpoint}};function awe(t,e){return[...t.slice(e),...t.slice(0,e)]}var Kb=class{constructor(e){this.channelControlHelper=e,this.children=[],this.currentState=sr.ConnectivityState.IDLE,this.currentReadyPicker=null,this.updatesPaused=!1,this.lastError=null,this.childChannelControlHelper=(0,wK.createChildChannelControlHelper)(e,{updateState:(r,n,i)=>{this.currentState===sr.ConnectivityState.READY&&r!==sr.ConnectivityState.READY&&this.channelControlHelper.requestReresolution(),i&&(this.lastError=i),this.calculateAndUpdateState()}})}countChildrenWithState(e){return this.children.filter(r=>r.getConnectivityState()===e).length}calculateAndUpdateState(){if(!this.updatesPaused){if(this.countChildrenWithState(sr.ConnectivityState.READY)>0){let e=this.children.filter(n=>n.getConnectivityState()===sr.ConnectivityState.READY),r=0;if(this.currentReadyPicker!==null){let n=this.currentReadyPicker.peekNextEndpoint();r=e.findIndex(i=>(0,TK.endpointEqual)(i.getEndpoint(),n)),r<0&&(r=0)}this.updateState(sr.ConnectivityState.READY,new Ck(e.map(n=>({endpoint:n.getEndpoint(),picker:n.getPicker()})),r),null)}else if(this.countChildrenWithState(sr.ConnectivityState.CONNECTING)>0)this.updateState(sr.ConnectivityState.CONNECTING,new Tg.QueuePicker(this),null);else if(this.countChildrenWithState(sr.ConnectivityState.TRANSIENT_FAILURE)>0){let e=`round_robin: No connection established. Last error: ${this.lastError}`;this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker({details:e}),e)}else this.updateState(sr.ConnectivityState.IDLE,new Tg.QueuePicker(this),null);for(let e of this.children)e.getConnectivityState()===sr.ConnectivityState.IDLE&&e.exitIdle()}}updateState(e,r,n){xK(sr.ConnectivityState[this.currentState]+" -> "+sr.ConnectivityState[e]),e===sr.ConnectivityState.READY?this.currentReadyPicker=r:this.currentReadyPicker=null,this.currentState=e,this.channelControlHelper.updateState(e,r,n)}resetSubchannelList(){for(let e of this.children)e.destroy();this.children=[]}updateAddressList(e,r,n,i){if(!(r instanceof Yb))return!1;if(!e.ok)return this.children.length===0&&this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker(e.error),e.error.details),!0;let o=Math.random()*e.value.length|0,s=awe(e.value,o);if(this.resetSubchannelList(),s.length===0){let a=`No addresses resolved. Resolution note: ${i}`;this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker({details:a}),a)}xK("Connect to endpoint list "+s.map(TK.endpointToString)),this.updatesPaused=!0,this.children=s.map(a=>new owe.LeafLoadBalancer(a,this.childChannelControlHelper,n,i));for(let a of this.children)a.startConnecting();return this.updatesPaused=!1,this.calculateAndUpdateState(),!0}exitIdle(){}resetBackoff(){}destroy(){this.resetSubchannelList()}getTypeName(){return Wb}};xg.RoundRobinLoadBalancer=Kb;function cwe(){(0,wK.registerLoadBalancerType)(Wb,Kb,Yb)}});var CK=b(ml=>{"use strict";var Pk;Object.defineProperty(ml,"__esModule",{value:!0});ml.OutlierDetectionLoadBalancer=ml.OutlierDetectionLoadBalancingConfig=void 0;ml.setup=Swe;var lwe=Ir(),RK=je(),hl=_g(),IK=bk(),uwe=aa(),dwe=gv(),fwe=Ho(),Ok=zr(),pwe=mg(),hwe=st(),mwe="outlier_detection";function Jt(t){hwe.trace(RK.LogVerbosity.DEBUG,mwe,t)}var $k="outlier_detection",gwe=((Pk=process.env.GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION)!==null&&Pk!==void 0?Pk:"true")==="true",_we={stdev_factor:1900,enforcement_percentage:100,minimum_hosts:5,request_volume:100},ywe={threshold:85,enforcement_percentage:100,minimum_hosts:5,request_volume:50};function Ad(t,e,r,n){if(e in t&&t[e]!==void 0&&typeof t[e]!==r){let i=n?`${n}.${e}`:e;throw new Error(`outlier detection config ${i} parse error: expected ${r}, got ${typeof t[e]}`)}}function Nk(t,e,r){let n=r?`${r}.${e}`:e;if(e in t&&t[e]!==void 0){if(!(0,hl.isDuration)(t[e]))throw new Error(`outlier detection config ${n} parse error: expected Duration, got ${typeof t[e]}`);if(!(t[e].seconds>=0&&t[e].seconds<=315576e6&&t[e].nanos>=0&&t[e].nanos<=999999999))throw new Error(`outlier detection config ${n} parse error: values out of range for non-negative Duaration`)}}function Zb(t,e,r){let n=r?`${r}.${e}`:e;if(Ad(t,e,"number",r),e in t&&t[e]!==void 0&&!(t[e]>=0&&t[e]<=100))throw new Error(`outlier detection config ${n} parse error: value out of range for percentage (0-100)`)}var wg=class t{constructor(e,r,n,i,o,s,a){if(this.childPolicy=a,a.getLoadBalancerName()==="pick_first")throw new Error("outlier_detection LB policy cannot have a pick_first child policy");this.intervalMs=e??1e4,this.baseEjectionTimeMs=r??3e4,this.maxEjectionTimeMs=n??3e5,this.maxEjectionPercent=i??10,this.successRateEjection=o?Object.assign(Object.assign({},_we),o):null,this.failurePercentageEjection=s?Object.assign(Object.assign({},ywe),s):null}getLoadBalancerName(){return $k}toJsonObject(){var e,r;return{outlier_detection:{interval:(0,hl.msToDuration)(this.intervalMs),base_ejection_time:(0,hl.msToDuration)(this.baseEjectionTimeMs),max_ejection_time:(0,hl.msToDuration)(this.maxEjectionTimeMs),max_ejection_percent:this.maxEjectionPercent,success_rate_ejection:(e=this.successRateEjection)!==null&&e!==void 0?e:void 0,failure_percentage_ejection:(r=this.failurePercentageEjection)!==null&&r!==void 0?r:void 0,child_policy:[this.childPolicy.toJsonObject()]}}}getIntervalMs(){return this.intervalMs}getBaseEjectionTimeMs(){return this.baseEjectionTimeMs}getMaxEjectionTimeMs(){return this.maxEjectionTimeMs}getMaxEjectionPercent(){return this.maxEjectionPercent}getSuccessRateEjectionConfig(){return this.successRateEjection}getFailurePercentageEjectionConfig(){return this.failurePercentageEjection}getChildPolicy(){return this.childPolicy}static createFromJson(e){var r;if(Nk(e,"interval"),Nk(e,"base_ejection_time"),Nk(e,"max_ejection_time"),Zb(e,"max_ejection_percent"),"success_rate_ejection"in e&&e.success_rate_ejection!==void 0){if(typeof e.success_rate_ejection!="object")throw new Error("outlier detection config success_rate_ejection must be an object");Ad(e.success_rate_ejection,"stdev_factor","number","success_rate_ejection"),Zb(e.success_rate_ejection,"enforcement_percentage","success_rate_ejection"),Ad(e.success_rate_ejection,"minimum_hosts","number","success_rate_ejection"),Ad(e.success_rate_ejection,"request_volume","number","success_rate_ejection")}if("failure_percentage_ejection"in e&&e.failure_percentage_ejection!==void 0){if(typeof e.failure_percentage_ejection!="object")throw new Error("outlier detection config failure_percentage_ejection must be an object");Zb(e.failure_percentage_ejection,"threshold","failure_percentage_ejection"),Zb(e.failure_percentage_ejection,"enforcement_percentage","failure_percentage_ejection"),Ad(e.failure_percentage_ejection,"minimum_hosts","number","failure_percentage_ejection"),Ad(e.failure_percentage_ejection,"request_volume","number","failure_percentage_ejection")}if(!("child_policy"in e)||!Array.isArray(e.child_policy))throw new Error("outlier detection config child_policy must be an array");let n=(0,uwe.selectLbConfigFromList)(e.child_policy);if(!n)throw new Error("outlier detection config child_policy: no valid recognized policy found");return new t(e.interval?(0,hl.durationToMs)(e.interval):null,e.base_ejection_time?(0,hl.durationToMs)(e.base_ejection_time):null,e.max_ejection_time?(0,hl.durationToMs)(e.max_ejection_time):null,(r=e.max_ejection_percent)!==null&&r!==void 0?r:null,e.success_rate_ejection,e.failure_percentage_ejection,n)}};ml.OutlierDetectionLoadBalancingConfig=wg;var Mk=class extends pwe.BaseSubchannelWrapper{constructor(e,r){super(e),this.mapEntry=r,this.refCount=0}ref(){this.child.ref(),this.refCount+=1}unref(){if(this.child.unref(),this.refCount-=1,this.refCount<=0&&this.mapEntry){let e=this.mapEntry.subchannelWrappers.indexOf(this);e>=0&&this.mapEntry.subchannelWrappers.splice(e,1)}}eject(){this.setHealthy(!1)}uneject(){this.setHealthy(!0)}getMapEntry(){return this.mapEntry}getWrappedSubchannel(){return this.child}};function kk(){return{success:0,failure:0}}var Dk=class{constructor(){this.activeBucket=kk(),this.inactiveBucket=kk()}addSuccess(){this.activeBucket.success+=1}addFailure(){this.activeBucket.failure+=1}switchBuckets(){this.inactiveBucket=this.activeBucket,this.activeBucket=kk()}getLastSuccesses(){return this.inactiveBucket.success}getLastFailures(){return this.inactiveBucket.failure}},Lk=class{constructor(e,r){this.wrappedPicker=e,this.countCalls=r}pick(e){let r=this.wrappedPicker.pick(e);if(r.pickResultType===fwe.PickResultType.COMPLETE){let n=r.subchannel,i=n.getMapEntry();if(i){let o=r.onCallEnded;return this.countCalls&&(o=(s,a,c)=>{var l;s===RK.Status.OK?i.counter.addSuccess():i.counter.addFailure(),(l=r.onCallEnded)===null||l===void 0||l.call(r,s,a,c)}),Object.assign(Object.assign({},r),{subchannel:n.getWrappedSubchannel(),onCallEnded:o})}else return Object.assign(Object.assign({},r),{subchannel:n.getWrappedSubchannel()})}else return r}},Jb=class{constructor(e){this.entryMap=new Ok.EndpointMap,this.latestConfig=null,this.timerStartTime=null,this.childBalancer=new dwe.ChildLoadBalancerHandler((0,IK.createChildChannelControlHelper)(e,{createSubchannel:(r,n)=>{let i=e.createSubchannel(r,n),o=this.entryMap.getForSubchannelAddress(r),s=new Mk(i,o);return o?.currentEjectionTimestamp!==null&&s.eject(),o?.subchannelWrappers.push(s),s},updateState:(r,n,i)=>{r===lwe.ConnectivityState.READY?e.updateState(r,new Lk(n,this.isCountingEnabled()),i):e.updateState(r,n,i)}})),this.ejectionTimer=setInterval(()=>{},0),clearInterval(this.ejectionTimer)}isCountingEnabled(){return this.latestConfig!==null&&(this.latestConfig.getSuccessRateEjectionConfig()!==null||this.latestConfig.getFailurePercentageEjectionConfig()!==null)}getCurrentEjectionPercent(){let e=0;for(let r of this.entryMap.values())r.currentEjectionTimestamp!==null&&(e+=1);return e*100/this.entryMap.size}runSuccessRateCheck(e){if(!this.latestConfig)return;let r=this.latestConfig.getSuccessRateEjectionConfig();if(!r)return;Jt("Running success rate check");let n=r.request_volume,i=0,o=[];for(let[d,f]of this.entryMap.entries()){let p=f.counter.getLastSuccesses(),h=f.counter.getLastFailures();Jt("Stats for "+(0,Ok.endpointToString)(d)+": successes="+p+" failures="+h+" targetRequestVolume="+n),p+h>=n&&(i+=1,o.push(p/(p+h)))}if(Jt("Found "+i+" success rate candidates; currentEjectionPercent="+this.getCurrentEjectionPercent()+" successRates=["+o+"]"),i<r.minimum_hosts)return;let s=o.reduce((d,f)=>d+f)/o.length,a=0;for(let d of o){let f=d-s;a+=f*f}let c=a/o.length,l=Math.sqrt(c),u=s-l*(r.stdev_factor/1e3);Jt("stdev="+l+" ejectionThreshold="+u);for(let[d,f]of this.entryMap.entries()){if(this.getCurrentEjectionPercent()>=this.latestConfig.getMaxEjectionPercent())break;let p=f.counter.getLastSuccesses(),h=f.counter.getLastFailures();if(p+h<n)continue;let m=p/(p+h);if(Jt("Checking candidate "+d+" successRate="+m),m<u){let y=Math.random()*100;Jt("Candidate "+d+" randomNumber="+y+" enforcement_percentage="+r.enforcement_percentage),y<r.enforcement_percentage&&(Jt("Ejecting candidate "+d),this.eject(f,e))}}}runFailurePercentageCheck(e){if(!this.latestConfig)return;let r=this.latestConfig.getFailurePercentageEjectionConfig();if(!r)return;Jt("Running failure percentage check. threshold="+r.threshold+" request volume threshold="+r.request_volume);let n=0;for(let i of this.entryMap.values()){let o=i.counter.getLastSuccesses(),s=i.counter.getLastFailures();o+s>=r.request_volume&&(n+=1)}if(!(n<r.minimum_hosts))for(let[i,o]of this.entryMap.entries()){if(this.getCurrentEjectionPercent()>=this.latestConfig.getMaxEjectionPercent())break;let s=o.counter.getLastSuccesses(),a=o.counter.getLastFailures();if(Jt("Candidate successes="+s+" failures="+a),s+a<r.request_volume)continue;if(a*100/(a+s)>r.threshold){let l=Math.random()*100;Jt("Candidate "+i+" randomNumber="+l+" enforcement_percentage="+r.enforcement_percentage),l<r.enforcement_percentage&&(Jt("Ejecting candidate "+i),this.eject(o,e))}}}eject(e,r){e.currentEjectionTimestamp=new Date,e.ejectionTimeMultiplier+=1;for(let n of e.subchannelWrappers)n.eject()}uneject(e){e.currentEjectionTimestamp=null;for(let r of e.subchannelWrappers)r.uneject()}switchAllBuckets(){for(let e of this.entryMap.values())e.counter.switchBuckets()}startTimer(e){var r,n;this.ejectionTimer=setTimeout(()=>this.runChecks(),e),(n=(r=this.ejectionTimer).unref)===null||n===void 0||n.call(r)}runChecks(){let e=new Date;if(Jt("Ejection timer running"),this.switchAllBuckets(),!!this.latestConfig){this.timerStartTime=e,this.startTimer(this.latestConfig.getIntervalMs()),this.runSuccessRateCheck(e),this.runFailurePercentageCheck(e);for(let[r,n]of this.entryMap.entries())if(n.currentEjectionTimestamp===null)n.ejectionTimeMultiplier>0&&(n.ejectionTimeMultiplier-=1);else{let i=this.latestConfig.getBaseEjectionTimeMs(),o=this.latestConfig.getMaxEjectionTimeMs(),s=new Date(n.currentEjectionTimestamp.getTime());s.setMilliseconds(s.getMilliseconds()+Math.min(i*n.ejectionTimeMultiplier,Math.max(i,o))),s<new Date&&(Jt("Unejecting "+r),this.uneject(n))}}}updateAddressList(e,r,n,i){if(!(r instanceof wg))return!1;if(Jt("Received update with config: "+JSON.stringify(r.toJsonObject(),void 0,2)),e.ok){for(let s of e.value)this.entryMap.has(s)||(Jt("Adding map entry for "+(0,Ok.endpointToString)(s)),this.entryMap.set(s,{counter:new Dk,currentEjectionTimestamp:null,ejectionTimeMultiplier:0,subchannelWrappers:[]}));this.entryMap.deleteMissing(e.value)}let o=r.getChildPolicy();if(this.childBalancer.updateAddressList(e,o,n,i),r.getSuccessRateEjectionConfig()||r.getFailurePercentageEjectionConfig())if(this.timerStartTime){Jt("Previous timer existed. Replacing timer"),clearTimeout(this.ejectionTimer);let s=r.getIntervalMs()-(new Date().getTime()-this.timerStartTime.getTime());this.startTimer(s)}else Jt("Starting new timer"),this.timerStartTime=new Date,this.startTimer(r.getIntervalMs()),this.switchAllBuckets();else{Jt("Counting disabled. Cancelling timer."),this.timerStartTime=null,clearTimeout(this.ejectionTimer);for(let s of this.entryMap.values())this.uneject(s),s.ejectionTimeMultiplier=0}return this.latestConfig=r,!0}exitIdle(){this.childBalancer.exitIdle()}resetBackoff(){this.childBalancer.resetBackoff()}destroy(){clearTimeout(this.ejectionTimer),this.childBalancer.destroy()}getTypeName(){return $k}};ml.OutlierDetectionLoadBalancer=Jb;function Swe(){gwe&&(0,IK.registerLoadBalancerType)($k,Jb,wg)}});var PK=b(Qb=>{"use strict";Object.defineProperty(Qb,"__esModule",{value:!0});Qb.PriorityQueue=void 0;var Rd=0,Uk=t=>Math.floor(t/2),Xb=t=>t*2+1,Ag=t=>t*2+2,Fk=class{constructor(e=(r,n)=>r>n){this.comparator=e,this.heap=[]}size(){return this.heap.length}isEmpty(){return this.size()==0}peek(){return this.heap[Rd]}push(...e){return e.forEach(r=>{this.heap.push(r),this.siftUp()}),this.size()}pop(){let e=this.peek(),r=this.size()-1;return r>Rd&&this.swap(Rd,r),this.heap.pop(),this.siftDown(),e}replace(e){let r=this.peek();return this.heap[Rd]=e,this.siftDown(),r}greater(e,r){return this.comparator(this.heap[e],this.heap[r])}swap(e,r){[this.heap[e],this.heap[r]]=[this.heap[r],this.heap[e]]}siftUp(){let e=this.size()-1;for(;e>Rd&&this.greater(e,Uk(e));)this.swap(e,Uk(e)),e=Uk(e)}siftDown(){let e=Rd;for(;Xb(e)<this.size()&&this.greater(Xb(e),e)||Ag(e)<this.size()&&this.greater(Ag(e),e);){let r=Ag(e)<this.size()&&this.greater(Ag(e),Xb(e))?Ag(e):Xb(e);this.swap(e,r),e=r}}};Qb.PriorityQueue=Fk});var DK=b(Ig=>{"use strict";Object.defineProperty(Ig,"__esModule",{value:!0});Ig.WeightedRoundRobinLoadBalancingConfig=void 0;Ig.setup=Pwe;var Xt=Ir(),Ewe=je(),mn=_g(),kK=aa(),vwe=vg(),bwe=st(),MK=Lb(),Id=Ho(),Twe=PK(),OK=zr(),xwe="weighted_round_robin";function Bk(t){bwe.trace(Ewe.LogVerbosity.DEBUG,xwe,t)}var Gk="weighted_round_robin",wwe=1e4,Awe=1e4,Rwe=3*6e4,Iwe=1e3,Cwe=1;function NK(t,e,r){if(e in t&&t[e]!==void 0&&typeof t[e]!==r)throw new Error(`weighted round robin config ${e} parse error: expected ${r}, got ${typeof t[e]}`)}function eT(t,e){if(e in t&&t[e]!==void 0&&t[e]!==null){let r;if((0,mn.isDuration)(t[e]))r=t[e];else if((0,mn.isDurationMessage)(t[e]))r=(0,mn.durationMessageToDuration)(t[e]);else if(typeof t[e]=="string"){let n=(0,mn.parseDuration)(t[e]);if(!n)throw new Error(`weighted round robin config ${e}: failed to parse duration string ${t[e]}`);r=n}else throw new Error(`weighted round robin config ${e}: expected duration, got ${typeof t[e]}`);return(0,mn.durationToMs)(r)}return null}var Rg=class t{constructor(e,r,n,i,o,s){this.enableOobLoadReport=e??!1,this.oobLoadReportingPeriodMs=r??wwe,this.blackoutPeriodMs=n??Awe,this.weightExpirationPeriodMs=i??Rwe,this.weightUpdatePeriodMs=Math.max(o??Iwe,100),this.errorUtilizationPenalty=s??Cwe}getLoadBalancerName(){return Gk}toJsonObject(){return{enable_oob_load_report:this.enableOobLoadReport,oob_load_reporting_period:(0,mn.durationToString)((0,mn.msToDuration)(this.oobLoadReportingPeriodMs)),blackout_period:(0,mn.durationToString)((0,mn.msToDuration)(this.blackoutPeriodMs)),weight_expiration_period:(0,mn.durationToString)((0,mn.msToDuration)(this.weightExpirationPeriodMs)),weight_update_period:(0,mn.durationToString)((0,mn.msToDuration)(this.weightUpdatePeriodMs)),error_utilization_penalty:this.errorUtilizationPenalty}}static createFromJson(e){if(NK(e,"enable_oob_load_report","boolean"),NK(e,"error_utilization_penalty","number"),e.error_utilization_penalty<0)throw new Error("weighted round robin config error_utilization_penalty < 0");return new t(e.enable_oob_load_report,eT(e,"oob_load_reporting_period"),eT(e,"blackout_period"),eT(e,"weight_expiration_period"),eT(e,"weight_update_period"),e.error_utilization_penalty)}getEnableOobLoadReport(){return this.enableOobLoadReport}getOobLoadReportingPeriodMs(){return this.oobLoadReportingPeriodMs}getBlackoutPeriodMs(){return this.blackoutPeriodMs}getWeightExpirationPeriodMs(){return this.weightExpirationPeriodMs}getWeightUpdatePeriodMs(){return this.weightUpdatePeriodMs}getErrorUtilizationPenalty(){return this.errorUtilizationPenalty}};Ig.WeightedRoundRobinLoadBalancingConfig=Rg;var jk=class{constructor(e,r){this.metricsHandler=r,this.queue=new Twe.PriorityQueue((o,s)=>o.deadline<s.deadline);let n=e.filter(o=>o.weight>0),i;if(n.length<2)i=1;else{let o=0;for(let{weight:s}of n)o+=s;i=o/n.length}for(let o of e){let s=o.weight>0?1/o.weight:i;this.queue.push({endpointName:o.endpointName,picker:o.picker,period:s,deadline:Math.random()*s})}}pick(e){let r=this.queue.pop();this.queue.push(Object.assign(Object.assign({},r),{deadline:r.deadline+r.period}));let n=r.picker.pick(e);if(n.pickResultType===Id.PickResultType.COMPLETE){if(this.metricsHandler)return Object.assign(Object.assign({},n),{onCallEnded:(0,MK.createMetricsReader)(i=>this.metricsHandler(i,r.endpointName),n.onCallEnded)});{let i=n.subchannel;return Object.assign(Object.assign({},n),{subchannel:i.getWrappedSubchannel()})}}else return n}},zk=class{constructor(e){this.channelControlHelper=e,this.latestConfig=null,this.children=new Map,this.currentState=Xt.ConnectivityState.IDLE,this.updatesPaused=!1,this.lastError=null,this.weightUpdateTimer=null}countChildrenWithState(e){let r=0;for(let n of this.children.values())n.child.getConnectivityState()===e&&(r+=1);return r}updateWeight(e,r){var n,i;let o=r.rps_fractional,s=r.application_utilization;s>0&&o>0&&(s+=r.eps/o*((i=(n=this.latestConfig)===null||n===void 0?void 0:n.getErrorUtilizationPenalty())!==null&&i!==void 0?i:0));let a=s===0?0:o/s;if(a===0)return;let c=new Date;e.nonEmptySince===null&&(e.nonEmptySince=c),e.lastUpdated=c,e.weight=a}getWeight(e){if(!this.latestConfig)return 0;let r=new Date().getTime();if(r-e.lastUpdated.getTime()>=this.latestConfig.getWeightExpirationPeriodMs())return e.nonEmptySince=null,0;let n=this.latestConfig.getBlackoutPeriodMs();return n>0&&(e.nonEmptySince===null||r-e.nonEmptySince.getTime()<n)?0:e.weight}calculateAndUpdateState(){if(!(this.updatesPaused||!this.latestConfig)){if(this.countChildrenWithState(Xt.ConnectivityState.READY)>0){let e=[];for(let[n,i]of this.children)i.child.getConnectivityState()===Xt.ConnectivityState.READY&&e.push({endpointName:n,picker:i.child.getPicker(),weight:this.getWeight(i)});Bk("Created picker with weights: "+e.map(n=>n.endpointName+":"+n.weight).join(","));let r;this.latestConfig.getEnableOobLoadReport()?r=null:r=(n,i)=>{let o=this.children.get(i);o&&this.updateWeight(o,n)},this.updateState(Xt.ConnectivityState.READY,new jk(e,r),null)}else if(this.countChildrenWithState(Xt.ConnectivityState.CONNECTING)>0)this.updateState(Xt.ConnectivityState.CONNECTING,new Id.QueuePicker(this),null);else if(this.countChildrenWithState(Xt.ConnectivityState.TRANSIENT_FAILURE)>0){let e=`weighted_round_robin: No connection established. Last error: ${this.lastError}`;this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker({details:e}),e)}else this.updateState(Xt.ConnectivityState.IDLE,new Id.QueuePicker(this),null);for(let{child:e}of this.children.values())e.getConnectivityState()===Xt.ConnectivityState.IDLE&&e.exitIdle()}}updateState(e,r,n){Bk(Xt.ConnectivityState[this.currentState]+" -> "+Xt.ConnectivityState[e]),this.currentState=e,this.channelControlHelper.updateState(e,r,n)}updateAddressList(e,r,n,i){var o,s;if(!(r instanceof Rg))return!1;if(!e.ok)return this.children.size===0&&this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker(e.error),e.error.details),!0;if(e.value.length===0){let l=`No addresses resolved. Resolution note: ${i}`;return this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker({details:l}),l),!1}Bk("Connect to endpoint list "+e.value.map(OK.endpointToString));let a=new Date,c=new Set;this.updatesPaused=!0,this.latestConfig=r;for(let l of e.value){let u=(0,OK.endpointToString)(l);c.add(u);let d=this.children.get(u);d||(d={child:new vwe.LeafLoadBalancer(l,(0,kK.createChildChannelControlHelper)(this.channelControlHelper,{updateState:(f,p,h)=>{this.currentState===Xt.ConnectivityState.READY&&f!==Xt.ConnectivityState.READY&&this.channelControlHelper.requestReresolution(),f===Xt.ConnectivityState.READY&&(d.nonEmptySince=null),h&&(this.lastError=h),this.calculateAndUpdateState()},createSubchannel:(f,p)=>{let h=this.channelControlHelper.createSubchannel(f,p);return d?.oobMetricsListener?new MK.OrcaOobMetricsSubchannelWrapper(h,d.oobMetricsListener,this.latestConfig.getOobLoadReportingPeriodMs()):h}}),n,i),lastUpdated:a,nonEmptySince:null,weight:0,oobMetricsListener:null},this.children.set(u,d)),r.getEnableOobLoadReport()?d.oobMetricsListener=f=>{this.updateWeight(d,f)}:d.oobMetricsListener=null}for(let[l,u]of this.children)c.has(l)?u.child.startConnecting():(u.child.destroy(),this.children.delete(l));return this.updatesPaused=!1,this.calculateAndUpdateState(),this.weightUpdateTimer&&clearInterval(this.weightUpdateTimer),this.weightUpdateTimer=(s=(o=setInterval(()=>{this.currentState===Xt.ConnectivityState.READY&&this.calculateAndUpdateState()},r.getWeightUpdatePeriodMs())).unref)===null||s===void 0?void 0:s.call(o),!0}exitIdle(){}resetBackoff(){}destroy(){for(let e of this.children.values())e.child.destroy();this.children.clear(),this.weightUpdateTimer&&clearInterval(this.weightUpdateTimer)}getTypeName(){return Gk}};function Pwe(){(0,kK.registerLoadBalancerType)(Gk,zk,Rg)}});var Cg=b(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.experimental=he.ServerMetricRecorder=he.ServerInterceptingCall=he.ResponderBuilder=he.ServerListenerBuilder=he.addAdminServicesToServer=he.getChannelzHandlers=he.getChannelzServiceDefinition=he.InterceptorConfigurationError=he.InterceptingCall=he.RequesterBuilder=he.ListenerBuilder=he.StatusBuilder=he.getClientChannel=he.ServerCredentials=he.Server=he.setLogVerbosity=he.setLogger=he.load=he.loadObject=he.CallCredentials=he.ChannelCredentials=he.waitForClientReady=he.closeClient=he.Channel=he.makeGenericClientConstructor=he.makeClientConstructor=he.loadPackageDefinition=he.Client=he.compressionAlgorithms=he.propagate=he.connectivityState=he.status=he.logVerbosity=he.Metadata=he.credentials=void 0;var tT=ov();Object.defineProperty(he,"CallCredentials",{enumerable:!0,get:function(){return tT.CallCredentials}});var Owe=OP();Object.defineProperty(he,"Channel",{enumerable:!0,get:function(){return Owe.ChannelImplementation}});var Nwe=YO();Object.defineProperty(he,"compressionAlgorithms",{enumerable:!0,get:function(){return Nwe.CompressionAlgorithms}});var kwe=Ir();Object.defineProperty(he,"connectivityState",{enumerable:!0,get:function(){return kwe.ConnectivityState}});var rT=Wu();Object.defineProperty(he,"ChannelCredentials",{enumerable:!0,get:function(){return rT.ChannelCredentials}});var LK=PP();Object.defineProperty(he,"Client",{enumerable:!0,get:function(){return LK.Client}});var qk=je();Object.defineProperty(he,"logVerbosity",{enumerable:!0,get:function(){return qk.LogVerbosity}});Object.defineProperty(he,"status",{enumerable:!0,get:function(){return qk.Status}});Object.defineProperty(he,"propagate",{enumerable:!0,get:function(){return qk.Propagate}});var $K=st(),Vk=wv();Object.defineProperty(he,"loadPackageDefinition",{enumerable:!0,get:function(){return Vk.loadPackageDefinition}});Object.defineProperty(he,"makeClientConstructor",{enumerable:!0,get:function(){return Vk.makeClientConstructor}});Object.defineProperty(he,"makeGenericClientConstructor",{enumerable:!0,get:function(){return Vk.makeClientConstructor}});var Mwe=Wt();Object.defineProperty(he,"Metadata",{enumerable:!0,get:function(){return Mwe.Metadata}});var Dwe=nK();Object.defineProperty(he,"Server",{enumerable:!0,get:function(){return Dwe.Server}});var Lwe=Mb();Object.defineProperty(he,"ServerCredentials",{enumerable:!0,get:function(){return Lwe.ServerCredentials}});var $we=iK();Object.defineProperty(he,"StatusBuilder",{enumerable:!0,get:function(){return $we.StatusBuilder}});he.credentials={combineChannelCredentials:(t,...e)=>e.reduce((r,n)=>r.compose(n),t),combineCallCredentials:(t,...e)=>e.reduce((r,n)=>r.compose(n),t),createInsecure:rT.ChannelCredentials.createInsecure,createSsl:rT.ChannelCredentials.createSsl,createFromSecureContext:rT.ChannelCredentials.createFromSecureContext,createFromMetadataGenerator:tT.CallCredentials.createFromMetadataGenerator,createFromGoogleCredential:tT.CallCredentials.createFromGoogleCredential,createEmpty:tT.CallCredentials.createEmpty};var Uwe=t=>t.close();he.closeClient=Uwe;var Fwe=(t,e,r)=>t.waitForReady(e,r);he.waitForClientReady=Fwe;var Bwe=(t,e)=>{throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead")};he.loadObject=Bwe;var jwe=(t,e,r)=>{throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead")};he.load=jwe;var zwe=t=>{$K.setLogger(t)};he.setLogger=zwe;var Gwe=t=>{$K.setLoggerVerbosity(t)};he.setLogVerbosity=Gwe;var qwe=t=>LK.Client.prototype.getChannel.call(t);he.getClientChannel=qwe;var nT=RP();Object.defineProperty(he,"ListenerBuilder",{enumerable:!0,get:function(){return nT.ListenerBuilder}});Object.defineProperty(he,"RequesterBuilder",{enumerable:!0,get:function(){return nT.RequesterBuilder}});Object.defineProperty(he,"InterceptingCall",{enumerable:!0,get:function(){return nT.InterceptingCall}});Object.defineProperty(he,"InterceptorConfigurationError",{enumerable:!0,get:function(){return nT.InterceptorConfigurationError}});var UK=_a();Object.defineProperty(he,"getChannelzServiceDefinition",{enumerable:!0,get:function(){return UK.getChannelzServiceDefinition}});Object.defineProperty(he,"getChannelzHandlers",{enumerable:!0,get:function(){return UK.getChannelzHandlers}});var Vwe=Ev();Object.defineProperty(he,"addAdminServicesToServer",{enumerable:!0,get:function(){return Vwe.addAdminServicesToServer}});var Hk=uk();Object.defineProperty(he,"ServerListenerBuilder",{enumerable:!0,get:function(){return Hk.ServerListenerBuilder}});Object.defineProperty(he,"ResponderBuilder",{enumerable:!0,get:function(){return Hk.ResponderBuilder}});Object.defineProperty(he,"ServerInterceptingCall",{enumerable:!0,get:function(){return Hk.ServerInterceptingCall}});var Hwe=Lb();Object.defineProperty(he,"ServerMetricRecorder",{enumerable:!0,get:function(){return Hwe.ServerMetricRecorder}});var Wwe=bk();he.experimental=Wwe;var Ywe=pN(),Kwe=gK(),Zwe=bK(),Jwe=vg(),Xwe=AK(),Qwe=CK(),eAe=DK(),tAe=_a();Ywe.setup(),Kwe.setup(),Zwe.setup(),Jwe.setup(),Xwe.setup(),Qwe.setup(),eAe.setup(),tAe.setup()});var FK=b(iT=>{"use strict";Object.defineProperty(iT,"__esModule",{value:!0});iT.createServiceClientConstructor=void 0;var rAe=Cg();function nAe(t,e){let r={export:{path:t,requestStream:!1,responseStream:!1,requestSerialize:n=>n,requestDeserialize:n=>n,responseSerialize:n=>n,responseDeserialize:n=>n}};return rAe.makeGenericClientConstructor(r,e)}iT.createServiceClientConstructor=nAe});var Pg=b(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.createOtlpGrpcExporterTransport=zn.GrpcExporterTransport=zn.createEmptyMetadata=zn.createSslCredentials=zn.createInsecureCredentials=void 0;var iAe=NH(),BK=`OTel-OTLP-Exporter-JavaScript/${iAe.VERSION}`;function oAe(t){return t?`${t} ${BK}`:BK}var sAe=0,aAe=2;function cAe(t){return t==="gzip"?aAe:sAe}function lAe(){let{credentials:t}=Cg();return t.createInsecure()}zn.createInsecureCredentials=lAe;function uAe(t,e,r){let{credentials:n}=Cg();return n.createSsl(t,e,r)}zn.createSslCredentials=uAe;function dAe(){let{Metadata:t}=Cg();return new t}zn.createEmptyMetadata=dAe;var oT=class{_client;_metadata;_parameters;constructor(e){this._parameters=e}shutdown(){this._client?.close()}send(e,r){let n=Buffer.from(e);if(this._client==null){let{createServiceClientConstructor:i}=FK();try{this._metadata=this._parameters.metadata()}catch(s){return Promise.resolve({status:"failure",error:s})}let o=i(this._parameters.grpcPath,this._parameters.grpcName);try{this._client=new o(this._parameters.address,this._parameters.credentials(),{"grpc.default_compression_algorithm":cAe(this._parameters.compression),"grpc.primary_user_agent":oAe(this._parameters.userAgent)})}catch(s){return Promise.resolve({status:"failure",error:s})}}return new Promise(i=>{let o=Date.now()+r;if(this._metadata==null)return i({error:new Error("metadata was null"),status:"failure"});this._client.export(n,this._metadata,{deadline:o},(s,a)=>{i(s?{status:"failure",error:s}:{data:a,status:"success"})})})}};zn.GrpcExporterTransport=oT;function fAe(t){return new oT(t)}zn.createOtlpGrpcExporterTransport=fAe});var VK=b(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.getOtlpGrpcDefaultConfiguration=wa.mergeOtlpGrpcConfigurationWithDefaults=wa.validateAndNormalizeUrl=void 0;var GK=(XE(),wr(JE)),Og=Pg(),pAe=Z("url"),jK=(Fe(),wr(Fc));function qK(t){t=t.trim(),t.match(/^([\w]{1,8}):\/\//)||(t=`https://${t}`);let r=new pAe.URL(t);return r.protocol==="unix:"?t:(r.pathname&&r.pathname!=="/"&&jK.diag.warn("URL path should not be set when using grpc, the path part of the URL will be ignored."),r.protocol!==""&&!r.protocol?.match(/^(http)s?:$/)&&jK.diag.warn("URL protocol should be http(s)://. Using http://."),r.host)}wa.validateAndNormalizeUrl=qK;function zK(t,e){for(let[r,n]of Object.entries(e.getMap()))t.get(r).length<1&&t.set(r,n)}function hAe(t,e,r){let n=t.url??e.url??r.url;return{...(0,GK.mergeOtlpSharedConfigurationWithDefaults)(t,e,r),metadata:()=>{let i=r.metadata();return zK(i,t.metadata?.().clone()??(0,Og.createEmptyMetadata)()),zK(i,e.metadata?.()??(0,Og.createEmptyMetadata)()),i},url:qK(n),credentials:t.credentials??e.credentials?.(n)??r.credentials(n),userAgent:t.userAgent}}wa.mergeOtlpGrpcConfigurationWithDefaults=hAe;function mAe(){return{...(0,GK.getSharedConfigurationDefaults)(),metadata:()=>(0,Og.createEmptyMetadata)(),url:"http://localhost:4317",credentials:t=>t.startsWith("http://")?()=>(0,Og.createInsecureCredentials)():()=>(0,Og.createSslCredentials)()}}wa.getOtlpGrpcDefaultConfiguration=mAe});function HK(t){let e={};return Object.entries(t??{}).forEach(([r,n])=>{typeof n<"u"?e[r]=String(n):de.warn(`Header "${r}" has invalid value (${n}) and will be ignored`)}),e}var WK=O(()=>{"use strict";Fe()});function gAe(t,e,r){return async()=>{let n={...await r()},i={};return e!=null&&Object.assign(i,await e()),t!=null&&Object.assign(i,HK(await t())),Object.assign(i,n)}}function _Ae(t){if(t!=null)try{let e=globalThis.location?.href;return new URL(t,e).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${t}'`)}}function YK(t,e,r){return{...HE(t,e,r),headers:gAe(t.headers,e.headers,r.headers),url:_Ae(t.url)??e.url??r.url}}function KK(t,e){return{...WE(),headers:async()=>t,url:"http://localhost:4318/"+e}}var ZK=O(()=>{"use strict";Cm();WK()});function gl(t){return async e=>{let r=e==="http:",n=r?import("http"):import("https"),{Agent:i}=await n;if(r){let{ca:o,cert:s,key:a,...c}=t;return new i(c)}return new i(t)}}function JK(t,e,r){return{...YK(t,e,r),agentFactory:t.agentFactory??e.agentFactory??r.agentFactory,userAgent:t.userAgent}}function XK(t,e){return{...KK(t,e),agentFactory:gl({keepAlive:!0})}}var sT=O(()=>{"use strict";ZK()});function Wk(t){return t===429||t===502||t===503||t===504}function Yk(t){if(t==null)return;let e=Number.parseInt(t,10);if(Number.isInteger(e))return e>0?e*1e3:-1;let r=new Date(t).getTime()-Date.now();return r>=0?r:0}var QK=O(()=>{"use strict"});var eZ,tZ=O(()=>{"use strict";eZ="0.218.0"});import*as iZ from"zlib";import{Readable as yAe}from"stream";function oZ(t,e,r,n,i,o,s,a){return new Promise(c=>{let l=new URL(e);i?r["User-Agent"]=`${i} ${rZ}`:r["User-Agent"]=rZ;let d=t(l,{method:"POST",headers:r,agent:o},f=>{let p=[],h=0;f.on("data",m=>{if(h+=m.length,h>nZ){let y=new Error(`OTLP export response body exceeded size limit of ${nZ} bytes`);c({status:"failure",error:y}),f.destroy();return}p.push(m)}),f.on("end",()=>{if(f.statusCode&&f.statusCode<=299)c({status:"success",data:Buffer.concat(p)});else if(f.statusCode&&Wk(f.statusCode))c({status:"retryable",retryInMillis:Yk(f.headers["retry-after"])});else{let m=new qo(f.statusMessage,f.statusCode,Buffer.concat(p).toString());c({status:"failure",error:m})}}),f.on("error",m=>{f.statusCode&&f.statusCode<=299?c({status:"success"}):f.statusCode&&Wk(f.statusCode)?c({status:"retryable",error:m,retryInMillis:Yk(f.headers["retry-after"])}):c({status:"failure",error:m})})});d.setTimeout(a,()=>{d.destroy(),c({status:"retryable",error:new Error("Request timed out")})}),d.on("error",f=>{vAe(f)?c({status:"retryable",error:f}):c({status:"failure",error:f})}),SAe(d,n,s,f=>{c({status:"failure",error:f})})})}function SAe(t,e,r,n){let i=EAe(r);e==="gzip"&&(t.setHeader("Content-Encoding","gzip"),i=i.on("error",n).pipe(iZ.createGzip()).on("error",n)),i.pipe(t).on("error",n)}function EAe(t){let e=new yAe;return e.push(t),e.push(null),e}function vAe(t){let e=new Set(["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","EAI_AGAIN","ENOTFOUND","ENETUNREACH","EHOSTUNREACH"]);return"code"in t&&typeof t.code=="string"?e.has(t.code):!1}var rZ,nZ,sZ=O(()=>{"use strict";QK();qE();tZ();rZ=`OTel-OTLP-Exporter-JavaScript/${eZ}`,nZ=4*1024*1024});async function bAe(t){let e=t==="http:"?import("http"):import("https"),{request:r}=await e;return r}function aZ(t){return new Kk(t)}var Kk,cZ=O(()=>{"use strict";sZ();Kk=class{_utils=null;_parameters;constructor(e){this._parameters=e}async send(e,r){let{agent:n,request:i}=await this._loadUtils(),o=await this._parameters.headers();return oZ(i,this._parameters.url,o,this._parameters.compression,this._parameters.userAgent,n,e,r)}shutdown(){}async _loadUtils(){let e=this._utils;if(e===null){let r=new URL(this._parameters.url).protocol,[n,i]=await Promise.all([this._parameters.agentFactory(r),bAe(r)]);e=this._utils={agent:n,request:i}}return e}}});function AAe(){return Math.random()*(2*lZ)-lZ}function uZ(t){return new Jk(t.transport)}var Zk,TAe,xAe,wAe,lZ,Jk,dZ=O(()=>{"use strict";Fe();Zk=5,TAe=1e3,xAe=5e3,wAe=1.5,lZ=.2;Jk=class{_transport;constructor(e){this._transport=e}retry(e,r,n){return new Promise((i,o)=>{setTimeout(()=>{this._transport.send(e,r).then(i,o)},n)})}async send(e,r){let n=Zk,i=TAe,o=Date.now()+r,s=await this._transport.send(e,r);for(;s.status==="retryable"&&n>0;){n--;let a=Math.max(Math.min(i*(1+AAe()),xAe),0);i=i*wAe;let c=s.retryInMillis??a,l=o-Date.now();if(c>l)return de.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),s;de.verbose(`Scheduling export retry in ${Math.round(c)}ms`),s=await this.retry(e,l,c)}return s.status==="success"?de.verbose(`Export succeeded after ${Zk-n} retry attempts.`):s.status==="retryable"?de.info(`Export failed after maximum retry attempts (${Zk}).`):de.info(`Export failed with non-retryable error: ${s.error}`),s}shutdown(){return this._transport.shutdown()}}});function fZ(t,e){return ZE({transport:uZ({transport:aZ(t)}),serializer:e,promiseHandler:KE(t)},{timeout:t.timeoutMillis})}var pZ=O(()=>{"use strict";B0();cZ();U0();dZ()});function hZ(t){let e=ut(t);if(e!=null){if(Number.isFinite(e)&&e>0)return e;de.warn(`Configuration: ${t} is invalid, expected number greater than 0 (actual: ${e})`)}}function RAe(t){let e=hZ(`OTEL_EXPORTER_OTLP_${t}_TIMEOUT`),r=hZ("OTEL_EXPORTER_OTLP_TIMEOUT");return e??r}function mZ(t){let e=hr(t)?.trim();if(e==null||e==="none"||e==="gzip")return e;de.warn(`Configuration: ${t} is invalid, expected 'none' or 'gzip' (actual: '${e}')`)}function IAe(t){let e=mZ(`OTEL_EXPORTER_OTLP_${t}_COMPRESSION`),r=mZ("OTEL_EXPORTER_OTLP_COMPRESSION");return e??r}function aT(t){return{timeoutMillis:RAe(t),compression:IAe(t)}}var Xk=O(()=>{"use strict";bt();Fe()});import*as gZ from"fs";import*as _Z from"path";function CAe(t){let e=hr(`OTEL_EXPORTER_OTLP_${t}_HEADERS`),r=hr("OTEL_EXPORTER_OTLP_HEADERS"),n=Bc(e),i=Bc(r);if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return Object.assign({},Bc(r),Bc(e))}function PAe(t){try{return new URL(t).toString()}catch{de.warn(`Configuration: Could not parse environment-provided export URL: '${t}', falling back to undefined`);return}}function OAe(t,e){try{new URL(t)}catch{de.warn(`Configuration: Could not parse environment-provided export URL: '${t}', falling back to undefined`);return}t.endsWith("/")||(t=t+"/"),t+=e;try{new URL(t)}catch{de.warn(`Configuration: Provided URL appended with '${e}' is not a valid URL, using 'undefined' instead of '${t}'`);return}return t}function NAe(t){let e=hr("OTEL_EXPORTER_OTLP_ENDPOINT");if(e!==void 0)return OAe(e,t)}function kAe(t){let e=hr(`OTEL_EXPORTER_OTLP_${t}_ENDPOINT`);if(e!==void 0)return PAe(e)}function Qk(t,e,r){let n=hr(t),i=hr(e),o=n??i;if(o!=null)try{return gZ.readFileSync(_Z.resolve(process.cwd(),o))}catch{de.warn(r);return}else return}function MAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CLIENT_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE","Failed to read client certificate chain file")}function DAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CLIENT_KEY`,"OTEL_EXPORTER_OTLP_CLIENT_KEY","Failed to read client certificate private key file")}function LAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CERTIFICATE","Failed to read root certificate file")}function yZ(t,e){return{...aT(t),url:kAe(t)??NAe(e),headers:VE(CAe(t)),agentFactory:gl({keepAlive:!0,ca:LAe(t),cert:MAe(t),key:DAe(t)})}}var SZ=O(()=>{"use strict";bt();Fe();Xk();Cm();sT()});function EZ(t){return typeof t.headers=="function"?t.headers:VE(t.headers)}var vZ=O(()=>{"use strict";Cm()});function $Ae(t){if(typeof t.httpAgentOptions=="function")return t.httpAgentOptions;let e=t.httpAgentOptions;if(t.keepAlive!=null&&(e={keepAlive:t.keepAlive,...e}),e!=null)return gl(e)}function bZ(t,e,r,n){return t.metadata&&de.warn("Metadata cannot be set when using http"),JK({url:t.url,headers:EZ(t),concurrencyLimit:t.concurrencyLimit,timeoutMillis:t.timeoutMillis,compression:t.compression,agentFactory:$Ae(t),userAgent:t.userAgent},yZ(e,r),XK(n,r))}var TZ=O(()=>{"use strict";Fe();sT();eM();SZ();vZ()});var xZ={};pr(xZ,{convertLegacyHttpOptions:()=>bZ,createOtlpHttpExportDelegate:()=>fZ,getSharedConfigurationFromEnvironment:()=>aT,httpAgentFactoryFromOptions:()=>gl});var eM=O(()=>{"use strict";sT();pZ();Xk();TZ()});var CZ=b(cT=>{"use strict";Object.defineProperty(cT,"__esModule",{value:!0});cT.getOtlpGrpcConfigurationFromEnv=void 0;var wZ=(bt(),wr(u0)),Ng=Pg(),UAe=(eM(),wr(xZ)),FAe=Z("fs"),BAe=Z("path"),RZ=(Fe(),wr(Fc));function tM(t,e){if(t!=null&&t!=="")return t;if(e!=null&&e!=="")return e}function jAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_HEADERS`]?.trim(),r=process.env.OTEL_EXPORTER_OTLP_HEADERS?.trim(),n=(0,wZ.parseKeyPairsIntoRecord)(e),i=(0,wZ.parseKeyPairsIntoRecord)(r);if(Object.keys(n).length===0&&Object.keys(i).length===0)return;let o=Object.assign({},i,n),s=(0,Ng.createEmptyMetadata)();for(let[a,c]of Object.entries(o))s.set(a,c);return s}function zAe(t){let e=jAe(t);if(e!=null)return()=>e}function GAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_ENDPOINT`]?.trim(),r=process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();return tM(e,r)}function qAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_INSECURE`]?.toLowerCase().trim(),r=process.env.OTEL_EXPORTER_OTLP_INSECURE?.toLowerCase().trim();return tM(e,r)==="true"}function rM(t,e,r){let n=process.env[t]?.trim(),i=process.env[e]?.trim(),o=tM(n,i);if(o!=null)try{return FAe.readFileSync(BAe.resolve(process.cwd(),o))}catch{RZ.diag.warn(r);return}else return}function VAe(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CLIENT_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE","Failed to read client certificate chain file")}function HAe(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CLIENT_KEY`,"OTEL_EXPORTER_OTLP_CLIENT_KEY","Failed to read client certificate private key file")}function AZ(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CERTIFICATE","Failed to read root certificate file")}function IZ(t){let e=HAe(t),r=VAe(t),n=AZ(t),i=e!=null&&r!=null;return n!=null&&!i?(RZ.diag.warn("Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate"),(0,Ng.createSslCredentials)(AZ(t))):(0,Ng.createSslCredentials)(n,e,r)}function WAe(t){return qAe(t)?(0,Ng.createInsecureCredentials)():IZ(t)}function YAe(t){return{...(0,UAe.getSharedConfigurationFromEnvironment)(t),metadata:zAe(t),url:GAe(t),credentials:e=>e.startsWith("http://")?()=>(0,Ng.createInsecureCredentials)():e.startsWith("https://")?()=>IZ(t):()=>WAe(t)}}cT.getOtlpGrpcConfigurationFromEnv=YAe});var OZ=b(lT=>{"use strict";Object.defineProperty(lT,"__esModule",{value:!0});lT.convertLegacyOtlpGrpcOptions=void 0;var PZ=VK(),KAe=Pg(),ZAe=CZ();function JAe(t,e){let r=t.credentials;return(0,PZ.mergeOtlpGrpcConfigurationWithDefaults)({url:t.url,metadata:()=>t.metadata??(0,KAe.createEmptyMetadata)(),compression:t.compression,timeoutMillis:t.timeoutMillis,concurrencyLimit:t.concurrencyLimit,credentials:r!=null?()=>r:void 0,userAgent:t.userAgent},(0,ZAe.getOtlpGrpcConfigurationFromEnv)(e),(0,PZ.getOtlpGrpcDefaultConfiguration)())}lT.convertLegacyOtlpGrpcOptions=JAe});var NZ=b(uT=>{"use strict";Object.defineProperty(uT,"__esModule",{value:!0});uT.createOtlpGrpcExportDelegate=void 0;var XAe=(XE(),wr(JE)),QAe=Pg();function eRe(t,e,r,n){return(0,XAe.createOtlpNetworkExportDelegate)(t,e,(0,QAe.createOtlpGrpcExporterTransport)({address:t.url,compression:t.compression,credentials:t.credentials,metadata:t.metadata,userAgent:t.userAgent,grpcName:r,grpcPath:n}))}uT.createOtlpGrpcExportDelegate=eRe});var kZ=b(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.createOtlpGrpcExportDelegate=Cd.convertLegacyOtlpGrpcOptions=void 0;var tRe=OZ();Object.defineProperty(Cd,"convertLegacyOtlpGrpcOptions",{enumerable:!0,get:function(){return tRe.convertLegacyOtlpGrpcOptions}});var rRe=NZ();Object.defineProperty(Cd,"createOtlpGrpcExportDelegate",{enumerable:!0,get:function(){return rRe.createOtlpGrpcExportDelegate}})});function os(t){return t<0?10:t<128?1:t<16384?2:t<2097152?3:t<268435456?4:t<34359738368?5:t<4398046511104?6:t<562949953421312?7:t<72057594037927940?8:9}var nM=O(()=>{"use strict"});var nRe,kg,Aa,dT=O(()=>{"use strict";Fe();nM();nRe="ProtobufWriter: estimated size was too small, growing buffer.",kg=1,Aa=class{_buffer;_textEncoder;_dataView;pos=0;constructor(e=65536){this._buffer=new Uint8Array(e),this._textEncoder=new TextEncoder,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}_ensureCapacity(e){let r=this.pos+e;if(r<=this._buffer.length)return;de.debug(nRe);let n=this._buffer.length*2;for(;n<r;)n*=2;let i=new Uint8Array(n);i.set(this._buffer),this._buffer=i,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}finish(){return this._buffer.subarray(0,this.pos)}startLengthDelimited(){let e=this.pos;return this._ensureCapacity(kg),this.pos+=kg,e}finishLengthDelimited(e,r){let n=r>>>0,i=os(n);if(i>kg){let s=i-kg;this._ensureCapacity(s),this._buffer.copyWithin(e+i,e+kg,this.pos),this.pos+=s}let o=e;n<128?this._buffer[o]=n:n<16384?(this._buffer[o++]=n&127|128,this._buffer[o]=n>>>7):n<2097152?(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o]=n>>>14):n<268435456?(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o++]=n>>>14&127|128,this._buffer[o]=n>>>21):(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o++]=n>>>14&127|128,this._buffer[o++]=n>>>21&127|128,this._buffer[o]=n>>>28)}writeSint32(e){this.writeVarint((e<<1^e>>31)>>>0)}writeSfixed64(e){let r,n;if(e>=0)r=e>>>0,n=e/4294967296>>>0;else{let i=Math.abs(e);r=i>>>0,n=i/4294967296>>>0,r=~r>>>0,n=~n>>>0,r=r+1>>>0,r===0&&(n=n+1>>>0)}this.writeFixed64(r,n)}writeVarint(e){if(this._ensureCapacity(os(e)),e>=0&&e<=4294967295){let r=e>>>0;for(;r>127;)this._buffer[this.pos++]=r&127|128,r>>>=7;this._buffer[this.pos++]=r}else{let r,n;if(e>=0)r=e>>>0,n=e/4294967296>>>0;else{let i=Math.abs(e);r=i>>>0,n=i/4294967296>>>0,r=~r>>>0,n=~n>>>0,r=r+1>>>0,r===0&&(n=n+1>>>0)}for(;n>0||r>127;)this._buffer[this.pos++]=r&127|128,r=(r>>>7|n<<25)>>>0,n>>>=7;this._buffer[this.pos++]=r&127}}writeFixed32(e){this._ensureCapacity(4);let r=e>>>0;this._buffer[this.pos++]=r&255,this._buffer[this.pos++]=r>>>8&255,this._buffer[this.pos++]=r>>>16&255,this._buffer[this.pos++]=r>>>24&255}writeFixed64(e,r){this._ensureCapacity(8);let n=e>>>0,i=r>>>0;this._buffer[this.pos++]=n&255,this._buffer[this.pos++]=n>>>8&255,this._buffer[this.pos++]=n>>>16&255,this._buffer[this.pos++]=n>>>24&255,this._buffer[this.pos++]=i&255,this._buffer[this.pos++]=i>>>8&255,this._buffer[this.pos++]=i>>>16&255,this._buffer[this.pos++]=i>>>24&255}writeBytes(e){this.writeVarint(e.length),this._ensureCapacity(e.length),this._buffer.set(e,this.pos),this.pos+=e.length}writeTag(e,r){this.writeVarint(e<<3|r)}writeDouble(e){this._ensureCapacity(8),this._dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeString(e){let r=!0,n=e.length;for(let i=0;i<n;i++)if(e.charCodeAt(i)>127){r=!1;break}if(r){this.writeVarint(n),this._ensureCapacity(n);for(let i=0;i<n;i++)this._buffer[this.pos++]=e.charCodeAt(i)}else{let i=this._textEncoder.encode(e);this.writeBytes(i)}}}});function MZ(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function ss(t){let e=new Uint8Array(t.length/2),r=0;for(let n=0;n<t.length;n+=2){let i=MZ(t.charCodeAt(n)),o=MZ(t.charCodeAt(n+1));e[r++]=i<<4|o}return e}var iM=O(()=>{"use strict"});var Mg,DZ=O(()=>{"use strict";(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TRACE=1]="TRACE",t[t.TRACE2=2]="TRACE2",t[t.TRACE3=3]="TRACE3",t[t.TRACE4=4]="TRACE4",t[t.DEBUG=5]="DEBUG",t[t.DEBUG2=6]="DEBUG2",t[t.DEBUG3=7]="DEBUG3",t[t.DEBUG4=8]="DEBUG4",t[t.INFO=9]="INFO",t[t.INFO2=10]="INFO2",t[t.INFO3=11]="INFO3",t[t.INFO4=12]="INFO4",t[t.WARN=13]="WARN",t[t.WARN2=14]="WARN2",t[t.WARN3=15]="WARN3",t[t.WARN4=16]="WARN4",t[t.ERROR=17]="ERROR",t[t.ERROR2=18]="ERROR2",t[t.ERROR3=19]="ERROR3",t[t.ERROR4=20]="ERROR4",t[t.FATAL=21]="FATAL",t[t.FATAL2=22]="FATAL2",t[t.FATAL3=23]="FATAL3",t[t.FATAL4=24]="FATAL4"})(Mg||(Mg={}))});var Dg,LZ,oM=O(()=>{"use strict";Dg=class{emit(e){}enabled(){return!1}},LZ=new Dg});function $Z(t,e,r){return n=>n===t?e:r}var Lg,Pd,sM,UZ=O(()=>{"use strict";Lg=Symbol.for("io.opentelemetry.js.api.logs"),Pd=globalThis;sM=1});var aM,fT,cM=O(()=>{"use strict";oM();aM=class{getLogger(e,r,n){return new Dg}},fT=new aM});var pT,FZ=O(()=>{"use strict";oM();pT=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):LZ}}});var $g,BZ=O(()=>{"use strict";cM();FZ();$g=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new pT(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:fT}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}}});var hT,jZ=O(()=>{"use strict";UZ();cM();BZ();hT=class t{constructor(){this._proxyLoggerProvider=new $g}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Pd[Lg]?this.getLoggerProvider():(Pd[Lg]=$Z(sM,e,fT),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Pd[Lg])===null||e===void 0?void 0:e.call(Pd,sM))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Pd[Lg],this._proxyLoggerProvider=new $g}}});var lnt,zZ=O(()=>{"use strict";DZ();jZ();lnt=hT.getInstance()});function Vr(t,e){let r=e[0],n=e[1],i=1e9,o=r&65535,s=r/65536>>>0,a=o*i,c=s*i,l=a>>>0,u=Math.floor(a/4294967296),d=(c&65535)*65536>>>0,f=c/65536>>>0,p=l+d+n,h=p>>>0,m=Math.floor(p/4294967296),y=u+f+m>>>0;t.writeFixed64(h,y)}function yi(t,e,r){for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let i=e[n];t.writeTag(r,2);let o=t.startLengthDelimited(),s=t.pos;iRe(t,n,i),t.finishLengthDelimited(o,t.pos-s)}}function iRe(t,e,r){t.writeTag(1,2),t.writeString(e),t.writeTag(2,2);let n=t.startLengthDelimited(),i=t.pos;Ug(t,r),t.finishLengthDelimited(n,t.pos-i)}function Ug(t,e){let r=typeof e;if(r==="string")t.writeTag(1,2),t.writeString(e);else if(r==="boolean")t.writeTag(2,0),t.writeVarint(e?1:0);else if(r==="number"){let n=e;Number.isInteger(n)&&n>=oRe&&n<sRe?(t.writeTag(3,0),t.writeVarint(n)):(t.writeTag(4,1),t.writeDouble(n))}else if(e instanceof Uint8Array)t.writeTag(7,2),t.writeBytes(e);else if(Array.isArray(e)){t.writeTag(5,2);let n=t.startLengthDelimited(),i=t.pos;for(let o of e){t.writeTag(1,2);let s=t.startLengthDelimited(),a=t.pos;Ug(t,o),t.finishLengthDelimited(s,t.pos-a)}t.finishLengthDelimited(n,t.pos-i)}else if(r==="object"&&e!=null){t.writeTag(6,2);let n=t.startLengthDelimited(),i=t.pos,o=e;for(let s in o){if(!Object.prototype.hasOwnProperty.call(o,s))continue;let a=o[s];t.writeTag(1,2);let c=t.startLengthDelimited(),l=t.pos;t.writeTag(1,2),t.writeString(s),t.writeTag(2,2);let u=t.startLengthDelimited(),d=t.pos;Ug(t,a),t.finishLengthDelimited(u,t.pos-d),t.finishLengthDelimited(c,t.pos-l)}t.finishLengthDelimited(n,t.pos-i)}}function Od(t,e,r){t.writeTag(r,2);let n=t.startLengthDelimited(),i=t.pos;t.writeTag(1,2),t.writeString(e.name),e.version&&(t.writeTag(2,2),t.writeString(e.version)),t.finishLengthDelimited(n,t.pos-i)}function Nd(t,e,r){t.writeTag(r,2);let n=t.startLengthDelimited(),i=t.pos;e.attributes&&yi(t,e.attributes,1),t.writeTag(2,0),t.writeVarint(0),t.finishLengthDelimited(n,t.pos-i)}var oRe,sRe,mT=O(()=>{"use strict";oRe=-(2**63),sRe=2**63});function aRe(t){let e=t.length,r=0;for(let n=0;n<e;n++){let i=t.charCodeAt(n);i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(n++,r+=4)}return r}var Ra,gT=O(()=>{"use strict";nM();Ra=class{pos=0;startLengthDelimited(){return this.pos}finishLengthDelimited(e,r){this.pos+=os(r)}writeVarint(e){this.pos+=os(e)}writeSint32(e){this.pos+=os((e<<1^e>>31)>>>0)}writeSfixed64(e){this.pos+=8}writeFixed32(e){this.pos+=4}writeFixed64(e,r){this.pos+=8}writeBytes(e){this.pos+=os(e.length),this.pos+=e.length}writeTag(e,r){this.writeVarint(e<<3|r)}writeDouble(e){this.pos+=8}writeString(e){let r=aRe(e);this.pos+=os(r),this.pos+=r}}});function cRe(t,e){let r=t.startLengthDelimited(),n=t.pos;if(t.writeTag(1,1),Vr(t,e.hrTime),e.severityNumber!==void 0&&e.severityNumber!==Mg.UNSPECIFIED&&(t.writeTag(2,0),t.writeVarint(e.severityNumber)),e.severityText&&(t.writeTag(3,2),t.writeString(e.severityText)),e.body!==void 0){t.writeTag(5,2);let i=t.startLengthDelimited(),o=t.pos;Ug(t,e.body),t.finishLengthDelimited(i,t.pos-o)}e.attributes&&yi(t,e.attributes,6),t.writeTag(7,0),t.writeVarint(e.droppedAttributesCount),e.spanContext?.traceFlags&&(t.writeTag(8,5),t.writeFixed32(e.spanContext.traceFlags)),e.spanContext?.traceId&&(t.writeTag(9,2),t.writeBytes(ss(e.spanContext.traceId))),e.spanContext?.spanId&&(t.writeTag(10,2),t.writeBytes(ss(e.spanContext.spanId))),t.writeTag(11,1),Vr(t,e.hrTimeObserved),e.eventName&&(t.writeTag(12,2),t.writeString(e.eventName)),t.finishLengthDelimited(r,t.pos-n)}function lRe(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Od(t,e,1);for(let o of r)t.writeTag(2,2),cRe(t,o);e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function GZ(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Nd(t,e,1);for(let o of r.values()){t.writeTag(2,2);let s=o[0].instrumentationScope;lRe(t,s,o)}e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function uRe(t){let e=new Map;for(let r of t){let n=r.resource,i=r.instrumentationScope,o=e.get(n);o||(o=new Map,e.set(n,o));let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}return e}function qZ(t){let e=uRe(t),r=new Ra;for(let[i,o]of e)r.writeTag(1,2),GZ(r,i,o);let n=new Aa(r.pos);for(let[i,o]of e)n.writeTag(1,2),GZ(n,i,o);return n.finish()}var VZ=O(()=>{"use strict";dT();iM();zZ();mT();gT()});var Si,_T=O(()=>{"use strict";Si=class{pos=0;_buf;_textDecoder;constructor(e){this._buf=e,this._textDecoder=new TextDecoder}isAtEnd(){return this.pos>=this._buf.length}readTag(){let e=this.readVarint();return{fieldNumber:e>>>3,wireType:e&7}}readVarint(){let e=0,r=0,n=!1;for(;this.pos<this._buf.length;){let i=this._buf[this.pos++];if(e+=(i&127)*Math.pow(2,r),r+=7,(i&128)===0){n=!0;break}}if(!n)throw new Error("Truncated buffer: unexpected end of data while reading varint");return e}readBytes(){let e=this.readVarint();if(this.pos+e>this._buf.length)throw new Error(`Truncated buffer: expected ${e} bytes at position ${this.pos}, but only ${this._buf.length-this.pos} available`);let r=this._buf.subarray(this.pos,this.pos+e);return this.pos+=e,r}readString(){return this._textDecoder.decode(this.readBytes())}skip(e){switch(e){case 0:this.readVarint();break;case 1:this.pos+=8;break;case 2:this.readBytes();break;case 3:for(;!this.isAtEnd();){let{wireType:r}=this.readTag();if(r===4)break;this.skip(r)}break;case 4:break;case 5:this.pos+=4;break;default:throw new Error(`Unknown wire type ${e}, cannot safely skip`)}}}});function dRe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedLogRecords=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function HZ(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=dRe(e.readBytes()):e.skip(i)}return r}var WZ=O(()=>{"use strict";_T()});var lM,YZ=O(()=>{"use strict";VZ();WZ();lM={serializeRequest:t=>qZ(t),deserializeResponse:t=>HZ(t)}});var KZ=O(()=>{"use strict";YZ()});var as,ZZ=O(()=>{"use strict";(function(t){t[t.DELTA=0]="DELTA",t[t.CUMULATIVE=1]="CUMULATIVE"})(as||(as={}))});var uM,gn,JZ=O(()=>{"use strict";(function(t){t.COUNTER="COUNTER",t.GAUGE="GAUGE",t.HISTOGRAM="HISTOGRAM",t.UP_DOWN_COUNTER="UP_DOWN_COUNTER",t.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",t.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",t.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(uM||(uM={}));(function(t){t[t.HISTOGRAM=0]="HISTOGRAM",t[t.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",t[t.GAUGE=2]="GAUGE",t[t.SUM=3]="SUM"})(gn||(gn={}))});var dM=O(()=>{"use strict";ZZ();JZ()});function e5(t,e,r){let n=t.startLengthDelimited(),i=t.pos;t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),r===Fo.INT?(t.writeTag(6,1),t.writeSfixed64(e.value)):(t.writeTag(4,1),t.writeDouble(e.value)),e.attributes&&yi(t,e.attributes,7),t.finishLengthDelimited(n,t.pos-i)}function fRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.value;if(t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),t.writeTag(4,1),t.writeFixed64(i.count>>>0,i.count/4294967296>>>0),i.sum!==void 0&&(t.writeTag(5,1),t.writeDouble(i.sum)),i.buckets.counts.length>0){t.writeTag(6,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of i.buckets.counts)t.writeFixed64(a>>>0,a/4294967296>>>0);t.finishLengthDelimited(o,t.pos-s)}if(i.buckets.boundaries.length>0){t.writeTag(7,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of i.buckets.boundaries)t.writeDouble(a);t.finishLengthDelimited(o,t.pos-s)}e.attributes&&yi(t,e.attributes,9),i.min!==void 0&&(t.writeTag(11,1),t.writeDouble(i.min)),i.max!==void 0&&(t.writeTag(12,1),t.writeDouble(i.max)),t.finishLengthDelimited(r,t.pos-n)}function XZ(t,e,r){let n=t.startLengthDelimited(),i=t.pos;if(e!==0&&(t.writeTag(1,0),t.writeSint32(e)),r.length>0){t.writeTag(2,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of r)t.writeVarint(a);t.finishLengthDelimited(o,t.pos-s)}t.finishLengthDelimited(n,t.pos-i)}function pRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.value;e.attributes&&yi(t,e.attributes,1),t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),t.writeTag(4,1),t.writeFixed64(i.count>>>0,i.count/4294967296>>>0),i.sum!==void 0&&(t.writeTag(5,1),t.writeDouble(i.sum)),i.scale!==0&&(t.writeTag(6,0),t.writeSint32(i.scale)),t.writeTag(7,1),t.writeFixed64(i.zeroCount>>>0,i.zeroCount/4294967296>>>0),t.writeTag(8,2),XZ(t,i.positive.offset,i.positive.bucketCounts),t.writeTag(9,2),XZ(t,i.negative.offset,i.negative.bucketCounts),i.min!==void 0&&(t.writeTag(12,1),t.writeDouble(i.min)),i.max!==void 0&&(t.writeTag(13,1),t.writeDouble(i.max)),t.finishLengthDelimited(r,t.pos-n)}function hRe(t,e){let r=t.startLengthDelimited(),n=t.pos;switch(t.writeTag(1,2),t.writeString(e.descriptor.name),e.descriptor.description&&(t.writeTag(2,2),t.writeString(e.descriptor.description)),e.descriptor.unit&&(t.writeTag(3,2),t.writeString(e.descriptor.unit)),e.dataPointType){case gn.GAUGE:t.writeTag(5,2),mRe(t,e);break;case gn.SUM:t.writeTag(7,2),gRe(t,e);break;case gn.HISTOGRAM:t.writeTag(9,2),_Re(t,e);break;case gn.EXPONENTIAL_HISTOGRAM:t.writeTag(10,2),yRe(t,e);break;default:{let i=e}}t.finishLengthDelimited(r,t.pos-n)}function mRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let i of e.dataPoints)t.writeTag(1,2),e5(t,i,e.descriptor.valueType);t.finishLengthDelimited(r,t.pos-n)}function gRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),e5(t,o,e.descriptor.valueType);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),e.isMonotonic&&(t.writeTag(3,0),t.writeVarint(1)),t.finishLengthDelimited(r,t.pos-n)}function _Re(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),fRe(t,o);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),t.finishLengthDelimited(r,t.pos-n)}function yRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),pRe(t,o);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),t.finishLengthDelimited(r,t.pos-n)}function SRe(t,e){let r=t.startLengthDelimited(),n=t.pos;Od(t,e.scope,1);for(let i of e.metrics)t.writeTag(2,2),hRe(t,i);e.scope.schemaUrl&&(t.writeTag(3,2),t.writeString(e.scope.schemaUrl)),t.finishLengthDelimited(r,t.pos-n)}function QZ(t,e){let r=t.startLengthDelimited(),n=t.pos;Nd(t,e.resource,1);for(let i of e.scopeMetrics)t.writeTag(2,2),SRe(t,i);e.resource.schemaUrl&&(t.writeTag(3,2),t.writeString(e.resource.schemaUrl)),t.finishLengthDelimited(r,t.pos-n)}function fM(t){switch(t){case as.DELTA:return 1;case as.CUMULATIVE:return 2;default:return 0}}function t5(t){let e=new Ra;e.writeTag(1,2),QZ(e,t);let r=new Aa(e.pos);return r.writeTag(1,2),QZ(r,t),r.finish()}var r5=O(()=>{"use strict";Fe();dM();mT();gT();dT()});function ERe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedDataPoints=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function n5(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=ERe(e.readBytes()):e.skip(i)}return r}var i5=O(()=>{"use strict";_T()});var pM,o5=O(()=>{"use strict";r5();i5();pM={serializeRequest:t=>t5(t),deserializeResponse:t=>n5(t)}});var s5=O(()=>{"use strict";o5()});function c5(t,e){let r=t&255|vRe;return e&&(r|=bRe),r}function TRe(t,e){let r=t.startLengthDelimited(),n=t.pos;e.message&&(t.writeTag(2,2),t.writeString(e.message)),t.writeTag(3,0),t.writeVarint(e.code),t.finishLengthDelimited(r,t.pos-n)}function xRe(t,e){let r=t.startLengthDelimited(),n=t.pos;t.writeTag(1,1),Vr(t,e.time),t.writeTag(2,2),t.writeString(e.name),e.attributes&&yi(t,e.attributes,3),t.writeTag(4,0),t.writeVarint(e.droppedAttributesCount||0),t.finishLengthDelimited(r,t.pos-n)}function wRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.context;t.writeTag(1,2),t.writeBytes(ss(i.traceId)),t.writeTag(2,2),t.writeBytes(ss(i.spanId));let o=i.traceState?.serialize();o&&(t.writeTag(3,2),t.writeString(o)),e.attributes&&yi(t,e.attributes,4),t.writeTag(5,0),t.writeVarint(e.droppedAttributesCount||0);let s=c5(i.traceFlags,i.isRemote);s&&(t.writeTag(6,5),t.writeFixed32(s)),t.finishLengthDelimited(r,t.pos-n)}function ARe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.spanContext();t.writeTag(1,2),t.writeBytes(ss(i.traceId)),t.writeTag(2,2),t.writeBytes(ss(i.spanId));let o=i.traceState?.serialize();o&&(t.writeTag(3,2),t.writeString(o)),e.parentSpanContext?.spanId&&(t.writeTag(4,2),t.writeBytes(ss(e.parentSpanContext.spanId))),t.writeTag(5,2),t.writeString(e.name);let s=e.kind==null?0:e.kind+1;s!==0&&(t.writeTag(6,0),t.writeVarint(s)),t.writeTag(7,1),Vr(t,e.startTime),t.writeTag(8,1),Vr(t,e.endTime),e.attributes&&yi(t,e.attributes,9),t.writeTag(10,0),t.writeVarint(e.droppedAttributesCount);for(let c of e.events)t.writeTag(11,2),xRe(t,c);t.writeTag(12,0),t.writeVarint(e.droppedEventsCount);for(let c of e.links)t.writeTag(13,2),wRe(t,c);t.writeTag(14,0),t.writeVarint(e.droppedLinksCount),t.writeTag(15,2),TRe(t,e.status);let a=c5(i.traceFlags,e.parentSpanContext?.isRemote);a&&(t.writeTag(16,5),t.writeFixed32(a)),t.finishLengthDelimited(r,t.pos-n)}function RRe(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Od(t,e,1);for(let o of r)t.writeTag(2,2),ARe(t,o);e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function a5(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Nd(t,e,1);for(let o of r.values()){t.writeTag(2,2);let s=o[0].instrumentationScope;RRe(t,s,o)}e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function IRe(t){let e=new Map;for(let r of t){let n=r.resource,i=r.instrumentationScope,o=e.get(n);o||(o=new Map,e.set(n,o));let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}return e}function l5(t){let e=IRe(t),r=new Ra;for(let[i,o]of e)r.writeTag(1,2),a5(r,i,o);let n=new Aa(r.pos);for(let[i,o]of e)n.writeTag(1,2),a5(n,i,o);return n.finish()}var vRe,bRe,u5=O(()=>{"use strict";dT();iM();mT();gT();vRe=256,bRe=512});function CRe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedSpans=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function d5(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=CRe(e.readBytes()):e.skip(i)}return r}var f5=O(()=>{"use strict";_T()});var hM,p5=O(()=>{"use strict";u5();f5();hM={serializeRequest:t=>l5(t),deserializeResponse:t=>d5(t)}});var h5=O(()=>{"use strict";p5()});function kd(t,e){let r={attributes:cs(t.attributes,e),droppedAttributesCount:0},n=t.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function Md(t){return{name:t.name,version:t.version}}function cs(t,e){return Object.keys(t).map(r=>mM(r,t[r],e))}function mM(t,e,r){return{key:t,value:Fg(e,r)}}function Fg(t,e){let r=typeof t;if(r==="string")return{stringValue:t};if(r==="number")return Number.isInteger(t)?{intValue:t}:{doubleValue:t};if(r==="boolean")return{boolValue:t};if(t instanceof Uint8Array)return{bytesValue:e.encodeUint8Array(t)};if(Array.isArray(t)){let n=new Array(t.length);for(let i=0;i<t.length;i++)n[i]=Fg(t[i],e);return{arrayValue:{values:n}}}if(r==="object"&&t!=null){let n=Object.keys(t),i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]={key:n[o],value:Fg(t[n[o]],e)};return{kvlistValue:{values:i}}}return{}}var yT=O(()=>{"use strict"});function m5(t,e){return{resourceLogs:ORe(t,e)}}function PRe(t){let e=new Map;for(let r of t){let{resource:n,instrumentationScope:{name:i,version:o="",schemaUrl:s=""}}=r,a=e.get(n);a||(a=new Map,e.set(n,a));let c=`${i}@${o}:${s}`,l=a.get(c);l||(l=[],a.set(c,l)),l.push(r)}return e}function ORe(t,e){let r=PRe(t);return Array.from(r,([n,i])=>{let o=kd(n,e);return{resource:o,scopeLogs:Array.from(i,([,s])=>({scope:Md(s[0].instrumentationScope),logRecords:s.map(a=>NRe(a,e)),schemaUrl:s[0].instrumentationScope.schemaUrl})),schemaUrl:o.schemaUrl}})}function NRe(t,e){return{timeUnixNano:e.encodeHrTime(t.hrTime),observedTimeUnixNano:e.encodeHrTime(t.hrTimeObserved),severityNumber:t.severityNumber,severityText:t.severityText,body:Fg(t.body,e),eventName:t.eventName,attributes:kRe(t.attributes,e),droppedAttributesCount:t.droppedAttributesCount,flags:t.spanContext?.traceFlags,traceId:e.encodeOptionalSpanContext(t.spanContext?.traceId),spanId:e.encodeOptionalSpanContext(t.spanContext?.spanId)}}function kRe(t,e){return Object.keys(t).map(r=>mM(r,t[r],e))}var g5=O(()=>{"use strict";yT()});function MRe(t){let e=BigInt(1e9);return BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))}function DRe(t){return MRe(t).toString()}function _5(t){return t}var LRe,Dd,ST=O(()=>{"use strict";bt();LRe=typeof BigInt<"u"?DRe:cE;Dd={encodeHrTime:LRe,encodeSpanContext:_5,encodeOptionalSpanContext:_5,encodeUint8Array:t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");let e=new Array(t.length);for(let r=0;r<t.length;r++)e[r]=String.fromCharCode(t[r]);return btoa(e.join(""))}}});var gM,y5=O(()=>{"use strict";g5();ST();Fe();gM={serializeRequest:t=>{let e=m5(t,Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse logs export response: ${r.message}. Returning empty response`),{}}}}});var S5=O(()=>{"use strict";y5()});var Bg,E5=O(()=>{"use strict";(function(t){t[t.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]="AGGREGATION_TEMPORALITY_UNSPECIFIED",t[t.AGGREGATION_TEMPORALITY_DELTA=1]="AGGREGATION_TEMPORALITY_DELTA",t[t.AGGREGATION_TEMPORALITY_CUMULATIVE=2]="AGGREGATION_TEMPORALITY_CUMULATIVE"})(Bg||(Bg={}))});function $Re(t,e){let r=kd(t.resource,e);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:URe(t.scopeMetrics,e)}}function URe(t,e){return Array.from(t.map(r=>({scope:Md(r.scope),metrics:r.metrics.map(n=>FRe(n,e)),schemaUrl:r.scope.schemaUrl})))}function FRe(t,e){let r={name:t.descriptor.name,description:t.descriptor.description,unit:t.descriptor.unit},n=GRe(t.aggregationTemporality);switch(t.dataPointType){case gn.SUM:r.sum={aggregationTemporality:n,isMonotonic:t.isMonotonic,dataPoints:v5(t,e)};break;case gn.GAUGE:r.gauge={dataPoints:v5(t,e)};break;case gn.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:jRe(t,e)};break;case gn.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:zRe(t,e)};break}return r}function BRe(t,e,r){let n={attributes:cs(t.attributes,r),startTimeUnixNano:r.encodeHrTime(t.startTime),timeUnixNano:r.encodeHrTime(t.endTime)};switch(e){case Fo.INT:n.asInt=t.value;break;case Fo.DOUBLE:n.asDouble=t.value;break}return n}function v5(t,e){return t.dataPoints.map(r=>BRe(r,t.descriptor.valueType,e))}function jRe(t,e){return t.dataPoints.map(r=>{let n=r.value;return{attributes:cs(r.attributes,e),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function zRe(t,e){return t.dataPoints.map(r=>{let n=r.value;return{attributes:cs(r.attributes,e),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function GRe(t){switch(t){case as.DELTA:return Bg.AGGREGATION_TEMPORALITY_DELTA;case as.CUMULATIVE:return Bg.AGGREGATION_TEMPORALITY_CUMULATIVE}}function b5(t,e){return{resourceMetrics:t.map(r=>$Re(r,e))}}var T5=O(()=>{"use strict";Fe();dM();E5();yT()});var _M,x5=O(()=>{"use strict";T5();ST();Fe();_M={serializeRequest:t=>{let e=b5([t],Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse metrics export response: ${r.message}. Returning empty response`),{}}}}});var w5=O(()=>{"use strict";x5()});function A5(t,e){let r=t&255|qRe;return e&&(r|=VRe),r}function HRe(t,e){let r=t.spanContext(),n=t.status,i=t.parentSpanContext?.spanId?e.encodeSpanContext(t.parentSpanContext?.spanId):void 0;return{traceId:e.encodeSpanContext(r.traceId),spanId:e.encodeSpanContext(r.spanId),parentSpanId:i,traceState:r.traceState?.serialize(),name:t.name,kind:t.kind==null?0:t.kind+1,startTimeUnixNano:e.encodeHrTime(t.startTime),endTimeUnixNano:e.encodeHrTime(t.endTime),attributes:cs(t.attributes,e),droppedAttributesCount:t.droppedAttributesCount,events:t.events.map(o=>YRe(o,e)),droppedEventsCount:t.droppedEventsCount,status:{code:n.code,message:n.message},links:t.links.map(o=>WRe(o,e)),droppedLinksCount:t.droppedLinksCount,flags:A5(r.traceFlags,t.parentSpanContext?.isRemote)}}function WRe(t,e){return{attributes:t.attributes?cs(t.attributes,e):[],spanId:e.encodeSpanContext(t.context.spanId),traceId:e.encodeSpanContext(t.context.traceId),traceState:t.context.traceState?.serialize(),droppedAttributesCount:t.droppedAttributesCount||0,flags:A5(t.context.traceFlags,t.context.isRemote)}}function YRe(t,e){return{attributes:t.attributes?cs(t.attributes,e):[],name:t.name,timeUnixNano:e.encodeHrTime(t.time),droppedAttributesCount:t.droppedAttributesCount||0}}function R5(t,e){return{resourceSpans:ZRe(t,e)}}function KRe(t){let e=new Map;for(let r of t){let n=e.get(r.resource);n||(n=new Map,e.set(r.resource,n));let i=`${r.instrumentationScope.name}@${r.instrumentationScope.version||""}:${r.instrumentationScope.schemaUrl||""}`,o=n.get(i);o||(o=[],n.set(i,o)),o.push(r)}return e}function ZRe(t,e){let r=KRe(t),n=[],i=r.entries(),o=i.next();for(;!o.done;){let[s,a]=o.value,c=[],l=a.values(),u=l.next();for(;!u.done;){let p=u.value;if(p.length>0){let h=p.map(m=>HRe(m,e));c.push({scope:Md(p[0].instrumentationScope),spans:h,schemaUrl:p[0].instrumentationScope.schemaUrl})}u=l.next()}let d=kd(s,e),f={resource:d,scopeSpans:c,schemaUrl:d.schemaUrl};n.push(f),o=i.next()}return n}var qRe,VRe,I5=O(()=>{"use strict";yT();qRe=256,VRe=512});var yM,C5=O(()=>{"use strict";I5();ST();Fe();yM={serializeRequest:t=>{let e=R5(t,Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse trace export response: ${r.message}. Returning empty response`),{}}}}});var P5=O(()=>{"use strict";C5()});var O5={};pr(O5,{JsonLogsSerializer:()=>gM,JsonMetricsSerializer:()=>_M,JsonTraceSerializer:()=>yM,ProtobufLogsSerializer:()=>lM,ProtobufMetricsSerializer:()=>pM,ProtobufTraceSerializer:()=>hM});var N5=O(()=>{"use strict";KZ();s5();h5();S5();w5();P5()});var M5=b(ET=>{"use strict";Object.defineProperty(ET,"__esModule",{value:!0});ET.OTLPTraceExporter=void 0;var k5=kZ(),JRe=(N5(),wr(O5)),XRe=(XE(),wr(JE)),SM=class extends XRe.OTLPExporterBase{constructor(e={}){super((0,k5.createOtlpGrpcExportDelegate)((0,k5.convertLegacyOtlpGrpcOptions)(e,"TRACES"),JRe.ProtobufTraceSerializer,"TraceExportService","/opentelemetry.proto.collector.trace.v1.TraceService/Export"))}};ET.OTLPTraceExporter=SM});var D5=b(vT=>{"use strict";Object.defineProperty(vT,"__esModule",{value:!0});vT.OTLPTraceExporter=void 0;var QRe=M5();Object.defineProperty(vT,"OTLPTraceExporter",{enumerable:!0,get:function(){return QRe.OTLPTraceExporter}})});var K9=b((mat,Y9)=>{"use strict";Y9.exports=W9;W9.sync=jCe;var V9=Z("fs");function BCe(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&t.substr(-i.length).toLowerCase()===i)return!0}return!1}function H9(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:BCe(e,r)}function W9(t,e,r){V9.stat(t,function(n,i){r(n,n?!1:H9(i,t,e))})}function jCe(t,e){return H9(V9.statSync(t),t,e)}});var eJ=b((gat,Q9)=>{"use strict";Q9.exports=J9;J9.sync=zCe;var Z9=Z("fs");function J9(t,e,r){Z9.stat(t,function(n,i){r(n,n?!1:X9(i,e))})}function zCe(t,e){return X9(Z9.statSync(t),e)}function X9(t,e){return t.isFile()&&GCe(t,e)}function GCe(t,e){var r=t.mode,n=t.uid,i=t.gid,o=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),s=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),l=parseInt("001",8),u=a|c,d=r&l||r&c&&i===s||r&a&&n===o||r&u&&o===0;return d}});var rJ=b((yat,tJ)=>{"use strict";var _at=Z("fs"),qT;process.platform==="win32"||global.TESTING_WINDOWS?qT=K9():qT=eJ();tJ.exports=zM;zM.sync=qCe;function zM(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){zM(t,e||{},function(o,s){o?i(o):n(s)})})}qT(t,e||{},function(n,i){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function qCe(t,e){try{return qT.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var lJ=b((Sat,cJ)=>{"use strict";var jd=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",nJ=Z("path"),VCe=jd?";":":",iJ=rJ(),oJ=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),sJ=(t,e)=>{let r=e.colon||VCe,n=t.match(/\//)||jd&&t.match(/\\/)?[""]:[...jd?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],i=jd?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=jd?i.split(r):[""];return jd&&t.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:i}},aJ=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:i,pathExtExe:o}=sJ(t,e),s=[],a=l=>new Promise((u,d)=>{if(l===n.length)return e.all&&s.length?u(s):d(oJ(t));let f=n[l],p=/^".*"$/.test(f)?f.slice(1,-1):f,h=nJ.join(p,t),m=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+h:h;u(c(m,l,0))}),c=(l,u,d)=>new Promise((f,p)=>{if(d===i.length)return f(a(u+1));let h=i[d];iJ(l+h,{pathExt:o},(m,y)=>{if(!m&&y)if(e.all)s.push(l+h);else return f(l+h);return f(c(l,u,d+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},HCe=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:i}=sJ(t,e),o=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=nJ.join(c,t),u=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let d=0;d<n.length;d++){let f=u+n[d];try{if(iJ.sync(f,{pathExt:i}))if(e.all)o.push(f);else return f}catch{}}}if(e.all&&o.length)return o;if(e.nothrow)return null;throw oJ(t)};cJ.exports=aJ;aJ.sync=HCe});var dJ=b((Eat,GM)=>{"use strict";var uJ=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};GM.exports=uJ;GM.exports.default=uJ});var mJ=b((vat,hJ)=>{"use strict";var fJ=Z("path"),WCe=lJ(),YCe=dJ();function pJ(t,e){let r=t.options.env||process.env,n=process.cwd(),i=t.options.cwd!=null,o=i&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(t.options.cwd)}catch{}let s;try{s=WCe.sync(t.command,{path:r[YCe({env:r})],pathExt:e?fJ.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return s&&(s=fJ.resolve(i?t.options.cwd:"",s)),s}function KCe(t){return pJ(t)||pJ(t,!0)}hJ.exports=KCe});var gJ=b((bat,VM)=>{"use strict";var qM=/([()\][%!^"`<>&|;, *?])/g;function ZCe(t){return t=t.replace(qM,"^$1"),t}function JCe(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(qM,"^$1"),e&&(t=t.replace(qM,"^$1")),t}VM.exports.command=ZCe;VM.exports.argument=JCe});var yJ=b((Tat,_J)=>{"use strict";_J.exports=/^#!(.*)/});var EJ=b((xat,SJ)=>{"use strict";var XCe=yJ();SJ.exports=(t="")=>{let e=t.match(XCe);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?n:n?`${i} ${n}`:i}});var bJ=b((wat,vJ)=>{"use strict";var HM=Z("fs"),QCe=EJ();function e0e(t){let r=Buffer.alloc(150),n;try{n=HM.openSync(t,"r"),HM.readSync(n,r,0,150,0),HM.closeSync(n)}catch{}return QCe(r.toString())}vJ.exports=e0e});var AJ=b((Aat,wJ)=>{"use strict";var t0e=Z("path"),TJ=mJ(),xJ=gJ(),r0e=bJ(),n0e=process.platform==="win32",i0e=/\.(?:com|exe)$/i,o0e=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function s0e(t){t.file=TJ(t);let e=t.file&&r0e(t.file);return e?(t.args.unshift(t.file),t.command=e,TJ(t)):t.file}function a0e(t){if(!n0e)return t;let e=s0e(t),r=!i0e.test(e);if(t.options.forceShell||r){let n=o0e.test(e);t.command=t0e.normalize(t.command),t.command=xJ.command(t.command),t.args=t.args.map(o=>xJ.argument(o,n));let i=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${i}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function c0e(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:a0e(n)}wJ.exports=c0e});var CJ=b((Rat,IJ)=>{"use strict";var WM=process.platform==="win32";function YM(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function l0e(t,e){if(!WM)return;let r=t.emit;t.emit=function(n,i){if(n==="exit"){let o=RJ(i,e);if(o)return r.call(t,"error",o)}return r.apply(t,arguments)}}function RJ(t,e){return WM&&t===1&&!e.file?YM(e.original,"spawn"):null}function u0e(t,e){return WM&&t===1&&!e.file?YM(e.original,"spawnSync"):null}IJ.exports={hookChildProcess:l0e,verifyENOENT:RJ,verifyENOENTSync:u0e,notFoundError:YM}});var NJ=b((Iat,zd)=>{"use strict";var PJ=Z("child_process"),KM=AJ(),ZM=CJ();function OJ(t,e,r){let n=KM(t,e,r),i=PJ.spawn(n.command,n.args,n.options);return ZM.hookChildProcess(i,n),i}function d0e(t,e,r){let n=KM(t,e,r),i=PJ.spawnSync(n.command,n.args,n.options);return i.error=i.error||ZM.verifyENOENTSync(i.status,n),i}zd.exports=OJ;zd.exports.spawn=OJ;zd.exports.sync=d0e;zd.exports._parse=KM;zd.exports._enoent=ZM});var Bse=b((hDt,Fse)=>{"use strict";var Ec=Z("constants"),v2e=process.cwd,qR=null,b2e=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return qR||(qR=v2e.call(process)),qR};try{process.cwd()}catch{}typeof process.chdir=="function"&&(uj=process.chdir,process.chdir=function(t){qR=null,uj.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,uj));var uj;Fse.exports=T2e;function T2e(t){Ec.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=o(t.chown),t.fchown=o(t.fchown),t.lchown=o(t.lchown),t.chmod=n(t.chmod),t.fchmod=n(t.fchmod),t.lchmod=n(t.lchmod),t.chownSync=s(t.chownSync),t.fchownSync=s(t.fchownSync),t.lchownSync=s(t.lchownSync),t.chmodSync=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=c(t.statSync),t.fstatSync=c(t.fstatSync),t.lstatSync=c(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,d,f){f&&process.nextTick(f)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,d,f,p){p&&process.nextTick(p)},t.lchownSync=function(){}),b2e==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(u){function d(f,p,h){var m=Date.now(),y=0;u(f,p,function S(T){if(T&&(T.code==="EACCES"||T.code==="EPERM"||T.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){t.stat(p,function(x,v){x&&x.code==="ENOENT"?u(f,p,S):h(T)})},y),y<100&&(y+=10);return}h&&h(T)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(u){function d(f,p,h,m,y,S){var T;if(S&&typeof S=="function"){var x=0;T=function(v,N,R){if(v&&v.code==="EAGAIN"&&x<10)return x++,u.call(t,f,p,h,m,y,T);S.apply(this,arguments)}}return u.call(t,f,p,h,m,y,T)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(u){return function(d,f,p,h,m){for(var y=0;;)try{return u.call(t,d,f,p,h,m)}catch(S){if(S.code==="EAGAIN"&&y<10){y++;continue}throw S}}})(t.readSync);function e(u){u.lchmod=function(d,f,p){u.open(d,Ec.O_WRONLY|Ec.O_SYMLINK,f,function(h,m){if(h){p&&p(h);return}u.fchmod(m,f,function(y){u.close(m,function(S){p&&p(y||S)})})})},u.lchmodSync=function(d,f){var p=u.openSync(d,Ec.O_WRONLY|Ec.O_SYMLINK,f),h=!0,m;try{m=u.fchmodSync(p,f),h=!1}finally{if(h)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}}function r(u){Ec.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(d,f,p,h){u.open(d,Ec.O_SYMLINK,function(m,y){if(m){h&&h(m);return}u.futimes(y,f,p,function(S){u.close(y,function(T){h&&h(S||T)})})})},u.lutimesSync=function(d,f,p){var h=u.openSync(d,Ec.O_SYMLINK),m,y=!0;try{m=u.futimesSync(h,f,p),y=!1}finally{if(y)try{u.closeSync(h)}catch{}else u.closeSync(h)}return m}):u.futimes&&(u.lutimes=function(d,f,p,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function n(u){return u&&function(d,f,p){return u.call(t,d,f,function(h){l(h)&&(h=null),p&&p.apply(this,arguments)})}}function i(u){return u&&function(d,f){try{return u.call(t,d,f)}catch(p){if(!l(p))throw p}}}function o(u){return u&&function(d,f,p,h){return u.call(t,d,f,p,function(m){l(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(u){return u&&function(d,f,p){try{return u.call(t,d,f,p)}catch(h){if(!l(h))throw h}}}function a(u){return u&&function(d,f,p){typeof f=="function"&&(p=f,f=null);function h(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),p&&p.apply(this,arguments)}return f?u.call(t,d,f,h):u.call(t,d,h)}}function c(u){return u&&function(d,f){var p=f?u.call(t,d,f):u.call(t,d);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function l(u){if(!u||u.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Gse=b((mDt,zse)=>{"use strict";var jse=Z("stream").Stream;zse.exports=x2e;function x2e(t){return{ReadStream:e,WriteStream:r};function e(n,i){if(!(this instanceof e))return new e(n,i);jse.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var l=s[a];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}t.open(this.path,this.flags,this.mode,function(u,d){if(u){o.emit("error",u),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);jse.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,a=o.length;s<a;s++){var c=o[s];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Vse=b((gDt,qse)=>{"use strict";qse.exports=A2e;var w2e=Object.getPrototypeOf||function(t){return t.__proto__};function A2e(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:w2e(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var Kse=b((_Dt,pj)=>{"use strict";var St=Z("fs"),R2e=Bse(),I2e=Gse(),C2e=Vse(),VR=Z("util"),fr,WR;typeof Symbol=="function"&&typeof Symbol.for=="function"?(fr=Symbol.for("graceful-fs.queue"),WR=Symbol.for("graceful-fs.previous")):(fr="___graceful-fs.queue",WR="___graceful-fs.previous");function P2e(){}function Yse(t,e){Object.defineProperty(t,fr,{get:function(){return e}})}var Eu=P2e;VR.debuglog?Eu=VR.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Eu=function(){var t=VR.format.apply(VR,arguments);t="GFS4: "+t.split(/\n/).join(`
|
|
23
|
-
GFS4: `),console.error(t)});St[fr]||(Hse=global[fr]||[],Yse(St,Hse),St.close=(function(t){function e(r,n){return t.call(St,r,function(i){i||Wse(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,WR,{value:t}),e})(St.close),St.closeSync=(function(t){function e(r){t.apply(St,arguments),Wse()}return Object.defineProperty(e,WR,{value:t}),e})(St.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Eu(St[fr]),Z("assert").equal(St[fr].length,0)}));var Hse;global[fr]||Yse(global,St[fr]);pj.exports=dj(C2e(St));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!St.__patched&&(pj.exports=dj(St),St.__patched=!0);function dj(t){R2e(t),t.gracefulify=dj,t.createReadStream=N,t.createWriteStream=R;var e=t.readFile;t.readFile=r;function r(D,j,_){return typeof j=="function"&&(_=j,j=null),ae(D,j,_);function ae(I,g,E,w){return e(I,g,function(W){W&&(W.code==="EMFILE"||W.code==="ENFILE")?ph([ae,[I,g,E],W,w||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=i;function i(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return n(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var o=t.appendFile;o&&(t.appendFile=s);function s(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return o(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=c);function c(D,j,_,ae){return typeof _=="function"&&(ae=_,_=0),I(D,j,_,ae);function I(g,E,w,W,G){return a(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var l=t.readdir;t.readdir=d;var u=/^v[0-5]\./;function d(D,j,_){typeof j=="function"&&(_=j,j=null);var ae=u.test(process.version)?function(E,w,W,G){return l(E,I(E,w,W,G))}:function(E,w,W,G){return l(E,w,I(E,w,W,G))};return ae(D,j,_);function I(g,E,w,W){return function(G,ce){G&&(G.code==="EMFILE"||G.code==="ENFILE")?ph([ae,[g,E,w],G,W||Date.now(),Date.now()]):(ce&&ce.sort&&ce.sort(),typeof w=="function"&&w.call(this,G,ce))}}}if(process.version.substr(0,4)==="v0.8"){var f=I2e(t);S=f.ReadStream,x=f.WriteStream}var p=t.ReadStream;p&&(S.prototype=Object.create(p.prototype),S.prototype.open=T);var h=t.WriteStream;h&&(x.prototype=Object.create(h.prototype),x.prototype.open=v),Object.defineProperty(t,"ReadStream",{get:function(){return S},set:function(D){S=D},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return x},set:function(D){x=D},enumerable:!0,configurable:!0});var m=S;Object.defineProperty(t,"FileReadStream",{get:function(){return m},set:function(D){m=D},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(D){y=D},enumerable:!0,configurable:!0});function S(D,j){return this instanceof S?(p.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function T(){var D=this;C(D.path,D.flags,D.mode,function(j,_){j?(D.autoClose&&D.destroy(),D.emit("error",j)):(D.fd=_,D.emit("open",_),D.read())})}function x(D,j){return this instanceof x?(h.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function v(){var D=this;C(D.path,D.flags,D.mode,function(j,_){j?(D.destroy(),D.emit("error",j)):(D.fd=_,D.emit("open",_))})}function N(D,j){return new t.ReadStream(D,j)}function R(D,j){return new t.WriteStream(D,j)}var U=t.open;t.open=C;function C(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return U(g,E,w,function(ce,Te){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}return t}function ph(t){Eu("ENQUEUE",t[0].name,t[1]),St[fr].push(t),fj()}var HR;function Wse(){for(var t=Date.now(),e=0;e<St[fr].length;++e)St[fr][e].length>2&&(St[fr][e][3]=t,St[fr][e][4]=t);fj()}function fj(){if(clearTimeout(HR),HR=void 0,St[fr].length!==0){var t=St[fr].shift(),e=t[0],r=t[1],n=t[2],i=t[3],o=t[4];if(i===void 0)Eu("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-i>=6e4){Eu("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,c=Math.max(o-i,1),l=Math.min(c*1.2,100);a>=l?(Eu("RETRY",e.name,r),e.apply(null,r.concat([i]))):St[fr].push(t)}HR===void 0&&(HR=setTimeout(fj,0))}}});var lae=b(hh=>{"use strict";Object.defineProperty(hh,"__esModule",{value:!0});hh.splitWhen=hh.flatten=void 0;function Z2e(t){return t.reduce((e,r)=>[].concat(e,r),[])}hh.flatten=Z2e;function J2e(t,e){let r=[[]],n=0;for(let i of t)e(i)?(n++,r[n]=[]):r[n].push(i);return r}hh.splitWhen=J2e});var uae=b(KR=>{"use strict";Object.defineProperty(KR,"__esModule",{value:!0});KR.isEnoentCodeError=void 0;function X2e(t){return t.code==="ENOENT"}KR.isEnoentCodeError=X2e});var dae=b(ZR=>{"use strict";Object.defineProperty(ZR,"__esModule",{value:!0});ZR.createDirentFromStats=void 0;var bj=class{constructor(e,r){this.name=e,this.isBlockDevice=r.isBlockDevice.bind(r),this.isCharacterDevice=r.isCharacterDevice.bind(r),this.isDirectory=r.isDirectory.bind(r),this.isFIFO=r.isFIFO.bind(r),this.isFile=r.isFile.bind(r),this.isSocket=r.isSocket.bind(r),this.isSymbolicLink=r.isSymbolicLink.bind(r)}};function Q2e(t,e){return new bj(t,e)}ZR.createDirentFromStats=Q2e});var mae=b(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.convertPosixPathToPattern=Dt.convertWindowsPathToPattern=Dt.convertPathToPattern=Dt.escapePosixPath=Dt.escapeWindowsPath=Dt.escape=Dt.removeLeadingDotSegment=Dt.makeAbsolute=Dt.unixify=void 0;var eje=Z("os"),tje=Z("path"),fae=eje.platform()==="win32",rje=2,nje=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,ije=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,oje=/^\\\\([.?])/,sje=/\\(?![!()+@[\]{}])/g;function aje(t){return t.replace(/\\/g,"/")}Dt.unixify=aje;function cje(t,e){return tje.resolve(t,e)}Dt.makeAbsolute=cje;function lje(t){if(t.charAt(0)==="."){let e=t.charAt(1);if(e==="/"||e==="\\")return t.slice(rje)}return t}Dt.removeLeadingDotSegment=lje;Dt.escape=fae?Tj:xj;function Tj(t){return t.replace(ije,"\\$2")}Dt.escapeWindowsPath=Tj;function xj(t){return t.replace(nje,"\\$2")}Dt.escapePosixPath=xj;Dt.convertPathToPattern=fae?pae:hae;function pae(t){return Tj(t).replace(oje,"//$1").replace(sje,"/")}Dt.convertWindowsPathToPattern=pae;function hae(t){return xj(t)}Dt.convertPosixPathToPattern=hae});var _ae=b((qDt,gae)=>{"use strict";gae.exports=function(e){if(typeof e!="string"||e==="")return!1;for(var r;r=/(\\).|([@?!+*]\(.*\))/g.exec(e);){if(r[2])return!0;e=e.slice(r.index+r[0].length)}return!1}});var Eae=b((VDt,Sae)=>{"use strict";var uje=_ae(),yae={"{":"}","(":")","[":"]"},dje=function(t){if(t[0]==="!")return!0;for(var e=0,r=-2,n=-2,i=-2,o=-2,s=-2;e<t.length;){if(t[e]==="*"||t[e+1]==="?"&&/[\].+)]/.test(t[e])||n!==-1&&t[e]==="["&&t[e+1]!=="]"&&(n<e&&(n=t.indexOf("]",e)),n>e&&(s===-1||s>n||(s=t.indexOf("\\",e),s===-1||s>n)))||i!==-1&&t[e]==="{"&&t[e+1]!=="}"&&(i=t.indexOf("}",e),i>e&&(s=t.indexOf("\\",e),s===-1||s>i))||o!==-1&&t[e]==="("&&t[e+1]==="?"&&/[:!=]/.test(t[e+2])&&t[e+3]!==")"&&(o=t.indexOf(")",e),o>e&&(s=t.indexOf("\\",e),s===-1||s>o))||r!==-1&&t[e]==="("&&t[e+1]!=="|"&&(r<e&&(r=t.indexOf("|",e)),r!==-1&&t[r+1]!==")"&&(o=t.indexOf(")",r),o>r&&(s=t.indexOf("\\",r),s===-1||s>o))))return!0;if(t[e]==="\\"){var a=t[e+1];e+=2;var c=yae[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},fje=function(t){if(t[0]==="!")return!0;for(var e=0;e<t.length;){if(/[*?{}()[\]]/.test(t[e]))return!0;if(t[e]==="\\"){var r=t[e+1];e+=2;var n=yae[r];if(n){var i=t.indexOf(n,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};Sae.exports=function(e,r){if(typeof e!="string"||e==="")return!1;if(uje(e))return!0;var n=dje;return r&&r.strict===!1&&(n=fje),n(e)}});var bae=b((HDt,vae)=>{"use strict";var pje=Eae(),hje=Z("path").posix.dirname,mje=Z("os").platform()==="win32",wj="/",gje=/\\/g,_je=/[\{\[].*[\}\]]$/,yje=/(^|[^\\])([\{\[]|\([^\)]+$)/,Sje=/\\([\!\*\?\|\[\]\(\)\{\}])/g;vae.exports=function(e,r){var n=Object.assign({flipBackslashes:!0},r);n.flipBackslashes&&mje&&e.indexOf(wj)<0&&(e=e.replace(gje,wj)),_je.test(e)&&(e+=wj),e+="a";do e=hje(e);while(pje(e)||yje.test(e));return e.replace(Sje,"$1")}});var JR=b(Zn=>{"use strict";Zn.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;Zn.find=(t,e)=>t.nodes.find(r=>r.type===e);Zn.exceedsLimit=(t,e,r=1,n)=>n===!1||!Zn.isInteger(t)||!Zn.isInteger(e)?!1:(Number(e)-Number(t))/Number(r)>=n;Zn.escapeNode=(t,e=0,r)=>{let n=t.nodes[e];n&&(r&&n.type===r||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};Zn.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;Zn.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1;Zn.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;Zn.reduce=t=>t.reduce((e,r)=>(r.type==="text"&&e.push(r.value),r.type==="range"&&(r.type="text"),e),[]);Zn.flatten=(...t)=>{let e=[],r=n=>{for(let i=0;i<n.length;i++){let o=n[i];if(Array.isArray(o)){r(o);continue}o!==void 0&&e.push(o)}return e};return r(t),e}});var XR=b((YDt,xae)=>{"use strict";var Tae=JR();xae.exports=(t,e={})=>{let r=(n,i={})=>{let o=e.escapeInvalid&&Tae.isInvalidBrace(i),s=n.invalid===!0&&e.escapeInvalid===!0,a="";if(n.value)return(o||s)&&Tae.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let c of n.nodes)a+=r(c);return a};return r(t)}});var Aae=b((KDt,wae)=>{"use strict";wae.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var Dae=b((ZDt,Mae)=>{"use strict";var Rae=Aae(),bu=(t,e,r)=>{if(Rae(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Rae(e)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...r};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let i=String(n.relaxZeros),o=String(n.shorthand),s=String(n.capture),a=String(n.wrap),c=t+":"+e+"="+i+o+s+a;if(bu.cache.hasOwnProperty(c))return bu.cache[c].result;let l=Math.min(t,e),u=Math.max(t,e);if(Math.abs(l-u)===1){let m=t+"|"+e;return n.capture?`(${m})`:n.wrap===!1?m:`(?:${m})`}let d=kae(t)||kae(e),f={min:t,max:e,a:l,b:u},p=[],h=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let m=u<0?Math.abs(u):1;h=Iae(m,Math.abs(l),f,n),l=f.a=0}return u>=0&&(p=Iae(l,u,f,n)),f.negatives=h,f.positives=p,f.result=Eje(h,p,n),n.capture===!0?f.result=`(${f.result})`:n.wrap!==!1&&p.length+h.length>1&&(f.result=`(?:${f.result})`),bu.cache[c]=f,f.result};function Eje(t,e,r){let n=Aj(t,e,"-",!1,r)||[],i=Aj(e,t,"",!1,r)||[],o=Aj(t,e,"-?",!0,r)||[];return n.concat(o).concat(i).join("|")}function vje(t,e){let r=1,n=1,i=Pae(t,r),o=new Set([e]);for(;t<=i&&i<=e;)o.add(i),r+=1,i=Pae(t,r);for(i=Oae(e+1,n)-1;t<i&&i<=e;)o.add(i),n+=1,i=Oae(e+1,n)-1;return o=[...o],o.sort(xje),o}function bje(t,e,r){if(t===e)return{pattern:t,count:[],digits:0};let n=Tje(t,e),i=n.length,o="",s=0;for(let a=0;a<i;a++){let[c,l]=n[a];c===l?o+=c:c!=="0"||l!=="9"?o+=wje(c,l,r):s++}return s&&(o+=r.shorthand===!0?"\\d":"[0-9]"),{pattern:o,count:[s],digits:i}}function Iae(t,e,r,n){let i=vje(t,e),o=[],s=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=bje(String(s),String(l),n),d="";if(!r.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Nae(a.count),s=l+1;continue}r.isPadded&&(d=Aje(l,r,n)),u.string=d+u.pattern+Nae(u.count),o.push(u),s=l+1,a=u}return o}function Aj(t,e,r,n,i){let o=[];for(let s of t){let{string:a}=s;!n&&!Cae(e,"string",a)&&o.push(r+a),n&&Cae(e,"string",a)&&o.push(r+a)}return o}function Tje(t,e){let r=[];for(let n=0;n<t.length;n++)r.push([t[n],e[n]]);return r}function xje(t,e){return t>e?1:e>t?-1:0}function Cae(t,e,r){return t.some(n=>n[e]===r)}function Pae(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Oae(t,e){return t-t%Math.pow(10,e)}function Nae(t){let[e=0,r=""]=t;return r||e>1?`{${e+(r?","+r:"")}}`:""}function wje(t,e,r){return`[${t}${e-t===1?"":"-"}${e}]`}function kae(t){return/^-?(0+)\d/.test(t)}function Aje(t,e,r){if(!e.isPadded)return t;let n=Math.abs(e.maxLen-String(t).length),i=r.relaxZeros!==!1;switch(n){case 0:return"";case 1:return i?"0?":"0";case 2:return i?"0{0,2}":"00";default:return i?`0{0,${n}}`:`0{${n}}`}}bu.cache={};bu.clearCache=()=>bu.cache={};Mae.exports=bu});var Cj=b((JDt,zae)=>{"use strict";var Rje=Z("util"),$ae=Dae(),Lae=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),Ije=t=>e=>t===!0?Number(e):String(e),Rj=t=>typeof t=="number"||typeof t=="string"&&t!=="",Yy=t=>Number.isInteger(+t),Ij=t=>{let e=`${t}`,r=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++r]==="0";);return r>0},Cje=(t,e,r)=>typeof t=="string"||typeof e=="string"?!0:r.stringify===!0,Pje=(t,e,r)=>{if(e>0){let n=t[0]==="-"?"-":"";n&&(t=t.slice(1)),t=n+t.padStart(n?e-1:e,"0")}return r===!1?String(t):t},eI=(t,e)=>{let r=t[0]==="-"?"-":"";for(r&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return r?"-"+t:t},Oje=(t,e,r)=>{t.negatives.sort((a,c)=>a<c?-1:a>c?1:0),t.positives.sort((a,c)=>a<c?-1:a>c?1:0);let n=e.capture?"":"?:",i="",o="",s;return t.positives.length&&(i=t.positives.map(a=>eI(String(a),r)).join("|")),t.negatives.length&&(o=`-(${n}${t.negatives.map(a=>eI(String(a),r)).join("|")})`),i&&o?s=`${i}|${o}`:s=i||o,e.wrap?`(${n}${s})`:s},Uae=(t,e,r,n)=>{if(r)return $ae(t,e,{wrap:!1,...n});let i=String.fromCharCode(t);if(t===e)return i;let o=String.fromCharCode(e);return`[${i}-${o}]`},Fae=(t,e,r)=>{if(Array.isArray(t)){let n=r.wrap===!0,i=r.capture?"":"?:";return n?`(${i}${t.join("|")})`:t.join("|")}return $ae(t,e,r)},Bae=(...t)=>new RangeError("Invalid range arguments: "+Rje.inspect(...t)),jae=(t,e,r)=>{if(r.strictRanges===!0)throw Bae([t,e]);return[]},Nje=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},kje=(t,e,r=1,n={})=>{let i=Number(t),o=Number(e);if(!Number.isInteger(i)||!Number.isInteger(o)){if(n.strictRanges===!0)throw Bae([t,e]);return[]}i===0&&(i=0),o===0&&(o=0);let s=i>o,a=String(t),c=String(e),l=String(r);r=Math.max(Math.abs(r),1);let u=Ij(a)||Ij(c)||Ij(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&Cje(t,e,n)===!1,p=n.transform||Ije(f);if(n.toRegex&&r===1)return Uae(eI(t,d),eI(e,d),!0,n);let h={negatives:[],positives:[]},m=T=>h[T<0?"negatives":"positives"].push(Math.abs(T)),y=[],S=0;for(;s?i>=o:i<=o;)n.toRegex===!0&&r>1?m(i):y.push(Pje(p(i,S),d,f)),i=s?i-r:i+r,S++;return n.toRegex===!0?r>1?Oje(h,n,d):Fae(y,null,{wrap:!1,...n}):y},Mje=(t,e,r=1,n={})=>{if(!Yy(t)&&t.length>1||!Yy(e)&&e.length>1)return jae(t,e,n);let i=n.transform||(f=>String.fromCharCode(f)),o=`${t}`.charCodeAt(0),s=`${e}`.charCodeAt(0),a=o>s,c=Math.min(o,s),l=Math.max(o,s);if(n.toRegex&&r===1)return Uae(c,l,!1,n);let u=[],d=0;for(;a?o>=s:o<=s;)u.push(i(o,d)),o=a?o-r:o+r,d++;return n.toRegex===!0?Fae(u,null,{wrap:!1,options:n}):u},QR=(t,e,r,n={})=>{if(e==null&&Rj(t))return[t];if(!Rj(t)||!Rj(e))return jae(t,e,n);if(typeof r=="function")return QR(t,e,1,{transform:r});if(Lae(r))return QR(t,e,0,r);let i={...n};return i.capture===!0&&(i.wrap=!0),r=r||i.step||1,Yy(r)?Yy(t)&&Yy(e)?kje(t,e,r,i):Mje(t,e,Math.max(Math.abs(r),1),i):r!=null&&!Lae(r)?Nje(r,i):QR(t,e,1,r)};zae.exports=QR});var Vae=b((XDt,qae)=>{"use strict";var Dje=Cj(),Gae=JR(),Lje=(t,e={})=>{let r=(n,i={})=>{let o=Gae.isInvalidBrace(i),s=n.invalid===!0&&e.escapeInvalid===!0,a=o===!0||s===!0,c=e.escapeInvalid===!0?"\\":"",l="";if(n.isOpen===!0)return c+n.value;if(n.isClose===!0)return console.log("node.isClose",c,n.value),c+n.value;if(n.type==="open")return a?c+n.value:"(";if(n.type==="close")return a?c+n.value:")";if(n.type==="comma")return n.prev.type==="comma"?"":a?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let u=Gae.reduce(n.nodes),d=Dje(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(n.nodes)for(let u of n.nodes)l+=r(u,n);return l};return r(t)};qae.exports=Lje});var Yae=b((QDt,Wae)=>{"use strict";var $je=Cj(),Hae=XR(),mh=JR(),Tu=(t="",e="",r=!1)=>{let n=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return r?mh.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let o of i)n.push(Tu(o,e,r));else for(let o of e)r===!0&&typeof o=="string"&&(o=`{${o}}`),n.push(Array.isArray(o)?Tu(i,o,r):i+o);return mh.flatten(n)},Uje=(t,e={})=>{let r=e.rangeLimit===void 0?1e3:e.rangeLimit,n=(i,o={})=>{i.queue=[];let s=o,a=o.queue;for(;s.type!=="brace"&&s.type!=="root"&&s.parent;)s=s.parent,a=s.queue;if(i.invalid||i.dollar){a.push(Tu(a.pop(),Hae(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(Tu(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let d=mh.reduce(i.nodes);if(mh.exceedsLimit(...d,e.step,r))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=$je(...d,e);f.length===0&&(f=Hae(i,e)),a.push(Tu(a.pop(),f)),i.nodes=[];return}let c=mh.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<i.nodes.length;d++){let f=i.nodes[d];if(f.type==="comma"&&i.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(Tu(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(Tu(l.pop(),f.value));continue}f.nodes&&n(f,i)}return l};return mh.flatten(n(t))};Wae.exports=Uje});var Zae=b((eLt,Kae)=>{"use strict";Kae.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
24
|
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var tce=b((tLt,ece)=>{"use strict";var Fje=XR(),{MAX_LENGTH:Jae,CHAR_BACKSLASH:Pj,CHAR_BACKTICK:Bje,CHAR_COMMA:jje,CHAR_DOT:zje,CHAR_LEFT_PARENTHESES:Gje,CHAR_RIGHT_PARENTHESES:qje,CHAR_LEFT_CURLY_BRACE:Vje,CHAR_RIGHT_CURLY_BRACE:Hje,CHAR_LEFT_SQUARE_BRACKET:Xae,CHAR_RIGHT_SQUARE_BRACKET:Qae,CHAR_DOUBLE_QUOTE:Wje,CHAR_SINGLE_QUOTE:Yje,CHAR_NO_BREAK_SPACE:Kje,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Zje}=Zae(),Jje=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let r=e||{},n=typeof r.maxLength=="number"?Math.min(Jae,r.maxLength):Jae;if(t.length>n)throw new SyntaxError(`Input length (${t.length}), exceeds max characters (${n})`);let i={type:"root",input:t,nodes:[]},o=[i],s=i,a=i,c=0,l=t.length,u=0,d=0,f,p=()=>t[u++],h=m=>{if(m.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&m.type==="text"){a.value+=m.value;return}return s.nodes.push(m),m.parent=s,m.prev=a,a=m,m};for(h({type:"bos"});u<l;)if(s=o[o.length-1],f=p(),!(f===Zje||f===Kje)){if(f===Pj){h({type:"text",value:(e.keepEscaping?f:"")+p()});continue}if(f===Qae){h({type:"text",value:"\\"+f});continue}if(f===Xae){c++;let m;for(;u<l&&(m=p());){if(f+=m,m===Xae){c++;continue}if(m===Pj){f+=p();continue}if(m===Qae&&(c--,c===0))break}h({type:"text",value:f});continue}if(f===Gje){s=h({type:"paren",nodes:[]}),o.push(s),h({type:"text",value:f});continue}if(f===qje){if(s.type!=="paren"){h({type:"text",value:f});continue}s=o.pop(),h({type:"text",value:f}),s=o[o.length-1];continue}if(f===Wje||f===Yje||f===Bje){let m=f,y;for(e.keepQuotes!==!0&&(f="");u<l&&(y=p());){if(y===Pj){f+=y+p();continue}if(y===m){e.keepQuotes===!0&&(f+=y);break}f+=y}h({type:"text",value:f});continue}if(f===Vje){d++;let y={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||s.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};s=h(y),o.push(s),h({type:"open",value:f});continue}if(f===Hje){if(s.type!=="brace"){h({type:"text",value:f});continue}let m="close";s=o.pop(),s.close=!0,h({type:m,value:f}),d--,s=o[o.length-1];continue}if(f===jje&&d>0){if(s.ranges>0){s.ranges=0;let m=s.nodes.shift();s.nodes=[m,{type:"text",value:Fje(s)}]}h({type:"comma",value:f}),s.commas++;continue}if(f===zje&&d>0&&s.commas===0){let m=s.nodes;if(d===0||m.length===0){h({type:"text",value:f});continue}if(a.type==="dot"){if(s.range=[],a.value+=f,a.type="range",s.nodes.length!==3&&s.nodes.length!==5){s.invalid=!0,s.ranges=0,a.type="text";continue}s.ranges++,s.args=[];continue}if(a.type==="range"){m.pop();let y=m[m.length-1];y.value+=a.value+f,a=y,s.ranges--;continue}h({type:"dot",value:f});continue}h({type:"text",value:f})}do if(s=o.pop(),s.type!=="root"){s.nodes.forEach(S=>{S.nodes||(S.type==="open"&&(S.isOpen=!0),S.type==="close"&&(S.isClose=!0),S.nodes||(S.type="text"),S.invalid=!0)});let m=o[o.length-1],y=m.nodes.indexOf(s);m.nodes.splice(y,1,...s.nodes)}while(o.length>0);return h({type:"eos"}),i};ece.exports=Jje});var ice=b((rLt,nce)=>{"use strict";var rce=XR(),Xje=Vae(),Qje=Yae(),eze=tce(),In=(t,e={})=>{let r=[];if(Array.isArray(t))for(let n of t){let i=In.create(n,e);Array.isArray(i)?r.push(...i):r.push(i)}else r=[].concat(In.create(t,e));return e&&e.expand===!0&&e.nodupes===!0&&(r=[...new Set(r)]),r};In.parse=(t,e={})=>eze(t,e);In.stringify=(t,e={})=>rce(typeof t=="string"?In.parse(t,e):t,e);In.compile=(t,e={})=>(typeof t=="string"&&(t=In.parse(t,e)),Xje(t,e));In.expand=(t,e={})=>{typeof t=="string"&&(t=In.parse(t,e));let r=Qje(t,e);return e.noempty===!0&&(r=r.filter(Boolean)),e.nodupes===!0&&(r=[...new Set(r)]),r};In.create=(t,e={})=>t===""||t.length<3?[t]:e.expand!==!0?In.compile(t,e):In.expand(t,e);nce.exports=In});var Ky=b((nLt,lce)=>{"use strict";var tze=Z("path"),Oo="\\\\/",oce=`[^${Oo}]`,rze=0,Gs="\\.",nze="\\+",ize="\\?",tI="\\/",oze="(?=.)",sce="[^/]",Oj=`(?:${tI}|$)`,ace=`(?:^|${tI})`,Nj=`${Gs}{1,2}${Oj}`,sze=`(?!${Gs})`,aze=`(?!${ace}${Nj})`,cze=`(?!${Gs}{0,1}${Oj})`,lze=`(?!${Nj})`,uze=`[^.${tI}]`,dze=`${sce}*?`,cce={DOT_LITERAL:Gs,PLUS_LITERAL:nze,QMARK_LITERAL:ize,SLASH_LITERAL:tI,ONE_CHAR:oze,QMARK:sce,END_ANCHOR:Oj,DOTS_SLASH:Nj,NO_DOT:sze,NO_DOTS:aze,NO_DOT_SLASH:cze,NO_DOTS_SLASH:lze,QMARK_NO_DOT:uze,STAR:dze,START_ANCHOR:ace},fze={...cce,SLASH_LITERAL:`[${Oo}]`,QMARK:oce,STAR:`${oce}*?`,DOTS_SLASH:`${Gs}{1,2}(?:[${Oo}]|$)`,NO_DOT:`(?!${Gs})`,NO_DOTS:`(?!(?:^|[${Oo}])${Gs}{1,2}(?:[${Oo}]|$))`,NO_DOT_SLASH:`(?!${Gs}{0,1}(?:[${Oo}]|$))`,NO_DOTS_SLASH:`(?!${Gs}{1,2}(?:[${Oo}]|$))`,QMARK_NO_DOT:`[^.${Oo}]`,START_ANCHOR:`(?:^|[${Oo}])`,END_ANCHOR:`(?:[${Oo}]|$)`},pze={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};lce.exports={DEFAULT_MAX_EXTGLOB_RECURSION:rze,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:pze,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:tze.sep,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?fze:cce}}});var Zy=b(en=>{"use strict";var hze=Z("path"),mze=process.platform==="win32",{REGEX_BACKSLASH:gze,REGEX_REMOVE_BACKSLASH:_ze,REGEX_SPECIAL_CHARS:yze,REGEX_SPECIAL_CHARS_GLOBAL:Sze}=Ky();en.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);en.hasRegexChars=t=>yze.test(t);en.isRegexChar=t=>t.length===1&&en.hasRegexChars(t);en.escapeRegex=t=>t.replace(Sze,"\\$1");en.toPosixSlashes=t=>t.replace(gze,"/");en.removeBackslashes=t=>t.replace(_ze,e=>e==="\\"?"":e);en.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};en.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:mze===!0||hze.sep==="\\";en.escapeLast=(t,e,r)=>{let n=t.lastIndexOf(e,r);return n===-1?t:t[n-1]==="\\"?en.escapeLast(t,e,n-1):`${t.slice(0,n)}\\${t.slice(n)}`};en.removePrefix=(t,e={})=>{let r=t;return r.startsWith("./")&&(r=r.slice(2),e.prefix="./"),r};en.wrapOutput=(t,e={},r={})=>{let n=r.contains?"":"^",i=r.contains?"":"$",o=`${n}(?:${t})${i}`;return e.negated===!0&&(o=`(?:^(?!${o}).*$)`),o}});var _ce=b((oLt,gce)=>{"use strict";var uce=Zy(),{CHAR_ASTERISK:kj,CHAR_AT:Eze,CHAR_BACKWARD_SLASH:Jy,CHAR_COMMA:vze,CHAR_DOT:Mj,CHAR_EXCLAMATION_MARK:Dj,CHAR_FORWARD_SLASH:mce,CHAR_LEFT_CURLY_BRACE:Lj,CHAR_LEFT_PARENTHESES:$j,CHAR_LEFT_SQUARE_BRACKET:bze,CHAR_PLUS:Tze,CHAR_QUESTION_MARK:dce,CHAR_RIGHT_CURLY_BRACE:xze,CHAR_RIGHT_PARENTHESES:fce,CHAR_RIGHT_SQUARE_BRACKET:wze}=Ky(),pce=t=>t===mce||t===Jy,hce=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Aze=(t,e)=>{let r=e||{},n=t.length-1,i=r.parts===!0||r.scanToEnd===!0,o=[],s=[],a=[],c=t,l=-1,u=0,d=0,f=!1,p=!1,h=!1,m=!1,y=!1,S=!1,T=!1,x=!1,v=!1,N=!1,R=0,U,C,D={value:"",depth:0,isGlob:!1},j=()=>l>=n,_=()=>c.charCodeAt(l+1),ae=()=>(U=C,c.charCodeAt(++l));for(;l<n;){C=ae();let W;if(C===Jy){T=D.backslashes=!0,C=ae(),C===Lj&&(S=!0);continue}if(S===!0||C===Lj){for(R++;j()!==!0&&(C=ae());){if(C===Jy){T=D.backslashes=!0,ae();continue}if(C===Lj){R++;continue}if(S!==!0&&C===Mj&&(C=ae())===Mj){if(f=D.isBrace=!0,h=D.isGlob=!0,N=!0,i===!0)continue;break}if(S!==!0&&C===vze){if(f=D.isBrace=!0,h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===xze&&(R--,R===0)){S=!1,f=D.isBrace=!0,N=!0;break}}if(i===!0)continue;break}if(C===mce){if(o.push(l),s.push(D),D={value:"",depth:0,isGlob:!1},N===!0)continue;if(U===Mj&&l===u+1){u+=2;continue}d=l+1;continue}if(r.noext!==!0&&(C===Tze||C===Eze||C===kj||C===dce||C===Dj)===!0&&_()===$j){if(h=D.isGlob=!0,m=D.isExtglob=!0,N=!0,C===Dj&&l===u&&(v=!0),i===!0){for(;j()!==!0&&(C=ae());){if(C===Jy){T=D.backslashes=!0,C=ae();continue}if(C===fce){h=D.isGlob=!0,N=!0;break}}continue}break}if(C===kj){if(U===kj&&(y=D.isGlobstar=!0),h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===dce){if(h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===bze){for(;j()!==!0&&(W=ae());){if(W===Jy){T=D.backslashes=!0,ae();continue}if(W===wze){p=D.isBracket=!0,h=D.isGlob=!0,N=!0;break}}if(i===!0)continue;break}if(r.nonegate!==!0&&C===Dj&&l===u){x=D.negated=!0,u++;continue}if(r.noparen!==!0&&C===$j){if(h=D.isGlob=!0,i===!0){for(;j()!==!0&&(C=ae());){if(C===$j){T=D.backslashes=!0,C=ae();continue}if(C===fce){N=!0;break}}continue}break}if(h===!0){if(N=!0,i===!0)continue;break}}r.noext===!0&&(m=!1,h=!1);let I=c,g="",E="";u>0&&(g=c.slice(0,u),c=c.slice(u),d-=u),I&&h===!0&&d>0?(I=c.slice(0,d),E=c.slice(d)):h===!0?(I="",E=c):I=c,I&&I!==""&&I!=="/"&&I!==c&&pce(I.charCodeAt(I.length-1))&&(I=I.slice(0,-1)),r.unescape===!0&&(E&&(E=uce.removeBackslashes(E)),I&&T===!0&&(I=uce.removeBackslashes(I)));let w={prefix:g,input:t,start:u,base:I,glob:E,isBrace:f,isBracket:p,isGlob:h,isExtglob:m,isGlobstar:y,negated:x,negatedExtglob:v};if(r.tokens===!0&&(w.maxDepth=0,pce(C)||s.push(D),w.tokens=s),r.parts===!0||r.tokens===!0){let W;for(let G=0;G<o.length;G++){let ce=W?W+1:u,Te=o[G],we=t.slice(ce,Te);r.tokens&&(G===0&&u!==0?(s[G].isPrefix=!0,s[G].value=g):s[G].value=we,hce(s[G]),w.maxDepth+=s[G].depth),(G!==0||we!=="")&&a.push(we),W=Te}if(W&&W+1<t.length){let G=t.slice(W+1);a.push(G),r.tokens&&(s[s.length-1].value=G,hce(s[s.length-1]),w.maxDepth+=s[s.length-1].depth)}w.slashes=o,w.parts=a}return w};gce.exports=Aze});var bce=b((sLt,vce)=>{"use strict";var Xy=Ky(),vr=Zy(),{MAX_LENGTH:rI,POSIX_REGEX_SOURCE:Rze,REGEX_NON_SPECIAL_CHARS:Ize,REGEX_SPECIAL_CHARS_BACKREF:Cze,REPLACEMENTS:yce}=Xy,Pze=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let r=`[${t.join("-")}]`;try{new RegExp(r)}catch{return t.map(i=>vr.escapeRegex(i)).join("..")}return r},gh=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,Sce=t=>{let e=[],r=0,n=0,i=0,o="",s=!1;for(let a of t){if(s===!0){o+=a,s=!1;continue}if(a==="\\"){o+=a,s=!0;continue}if(a==='"'){i=i===1?0:1,o+=a;continue}if(i===0){if(a==="[")r++;else if(a==="]"&&r>0)r--;else if(r===0){if(a==="(")n++;else if(a===")"&&n>0)n--;else if(a==="|"&&n===0){e.push(o),o="";continue}}}o+=a}return e.push(o),e},Oze=t=>{let e=!1;for(let r of t){if(e===!0){e=!1;continue}if(r==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(r))return!1}return!0},Ece=t=>{let e=t.trim(),r=!0;for(;r===!0;)r=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),r=!0);if(Oze(e))return e.replace(/\\(.)/g,"$1")},Nze=t=>{let e=t.map(Ece).filter(Boolean);for(let r=0;r<e.length;r++)for(let n=r+1;n<e.length;n++){let i=e[r],o=e[n],s=i[0];if(!(!s||i!==s.repeat(i.length)||o!==s.repeat(o.length))&&(i===o||i.startsWith(o)||o.startsWith(i)))return!0}return!1},Uj=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let r=0,n=0,i=0,o=!1;for(let s=1;s<t.length;s++){let a=t[s];if(o===!0){o=!1;continue}if(a==="\\"){o=!0;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){r++;continue}if(a==="]"&&r>0){r--;continue}if(!(r>0)){if(a==="("){n++;continue}if(a===")"&&(n--,n===0))return e===!0&&s!==t.length-1?void 0:{type:t[0],body:t.slice(2,s),end:s}}}}},kze=t=>{let e=0,r=[];for(;e<t.length;){let i=Uj(t.slice(e),!1);if(!i||i.type!=="*")return;let o=Sce(i.body).map(a=>a.trim());if(o.length!==1)return;let s=Ece(o[0]);if(!s||s.length!==1)return;r.push(s),e+=i.end+1}return r.length<1?void 0:`${r.length===1?vr.escapeRegex(r[0]):`[${r.map(i=>vr.escapeRegex(i)).join("")}]`}*`},Mze=t=>{let e=0,r=t.trim(),n=Uj(r);for(;n;)e++,r=n.body.trim(),n=Uj(r);return e},Dze=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let r=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:Xy.DEFAULT_MAX_EXTGLOB_RECURSION,n=Sce(t).map(i=>i.trim());if(n.length>1&&(n.some(i=>i==="")||n.some(i=>/^[*?]+$/.test(i))||Nze(n)))return{risky:!0};for(let i of n){let o=kze(i);if(o)return{risky:!0,safeOutput:o};if(Mze(i)>r)return{risky:!0}}return{risky:!1}},Fj=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=yce[t]||t;let r={...e},n=typeof r.maxLength=="number"?Math.min(rI,r.maxLength):rI,i=t.length;if(i>n)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${n}`);let o={type:"bos",value:"",output:r.prepend||""},s=[o],a=r.capture?"":"?:",c=vr.isWindows(e),l=Xy.globChars(c),u=Xy.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:h,DOTS_SLASH:m,NO_DOT:y,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:x,QMARK_NO_DOT:v,STAR:N,START_ANCHOR:R}=l,U=te=>`(${a}(?:(?!${R}${te.dot?m:d}).)*?)`,C=r.dot?"":y,D=r.dot?x:v,j=r.bash===!0?U(r):N;r.capture&&(j=`(${j})`),typeof r.noext=="boolean"&&(r.noextglob=r.noext);let _={input:t,index:-1,start:0,dot:r.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:s};t=vr.removePrefix(t,_),i=t.length;let ae=[],I=[],g=[],E=o,w,W=()=>_.index===i-1,G=_.peek=(te=1)=>t[_.index+te],ce=_.advance=()=>t[++_.index]||"",Te=()=>t.slice(_.index+1),we=(te="",Ae=0)=>{_.consumed+=te,_.index+=Ae},Ce=te=>{_.output+=te.output!=null?te.output:te.value,we(te.value)},V=()=>{let te=1;for(;G()==="!"&&(G(2)!=="("||G(3)==="?");)ce(),_.start++,te++;return te%2===0?!1:(_.negated=!0,_.start++,!0)},De=te=>{_[te]++,g.push(te)},be=te=>{_[te]--,g.pop()},ee=te=>{if(E.type==="globstar"){let Ae=_.braces>0&&(te.type==="comma"||te.type==="brace"),K=te.extglob===!0||ae.length&&(te.type==="pipe"||te.type==="paren");te.type!=="slash"&&te.type!=="paren"&&!Ae&&!K&&(_.output=_.output.slice(0,-E.output.length),E.type="star",E.value="*",E.output=j,_.output+=E.output)}if(ae.length&&te.type!=="paren"&&(ae[ae.length-1].inner+=te.value),(te.value||te.output)&&Ce(te),E&&E.type==="text"&&te.type==="text"){E.value+=te.value,E.output=(E.output||"")+te.value;return}te.prev=E,s.push(te),E=te},ie=(te,Ae)=>{let K={...u[Ae],conditions:1,inner:""};K.prev=E,K.parens=_.parens,K.output=_.output,K.startIndex=_.index,K.tokensIndex=s.length;let M=(r.capture?"(":"")+K.open;De("parens"),ee({type:te,value:Ae,output:_.output?"":h}),ee({type:"paren",extglob:!0,value:ce(),output:M}),ae.push(K)},Re=te=>{let Ae=t.slice(te.startIndex,_.index+1),K=t.slice(te.startIndex+2,_.index),M=Dze(K,r);if((te.type==="plus"||te.type==="star")&&M.risky){let A=M.safeOutput?(te.output?"":h)+(r.capture?`(${M.safeOutput})`:M.safeOutput):void 0,J=s[te.tokensIndex];J.type="text",J.value=Ae,J.output=A||vr.escapeRegex(Ae);for(let ne=te.tokensIndex+1;ne<s.length;ne++)s[ne].value="",s[ne].output="",delete s[ne].suffix;_.output=te.output+J.output,_.backtrack=!0,ee({type:"paren",extglob:!0,value:w,output:""}),be("parens");return}let k=te.close+(r.capture?")":""),F;if(te.type==="negate"){let A=j;if(te.inner&&te.inner.length>1&&te.inner.includes("/")&&(A=U(r)),(A!==j||W()||/^\)+$/.test(Te()))&&(k=te.close=`)$))${A}`),te.inner.includes("*")&&(F=Te())&&/^\.[^\\/.]+$/.test(F)){let J=Fj(F,{...e,fastpaths:!1}).output;k=te.close=`)${J})${A})`}te.prev.type==="bos"&&(_.negatedExtglob=!0)}ee({type:"paren",extglob:!0,value:w,output:k}),be("parens")};if(r.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let te=!1,Ae=t.replace(Cze,(K,M,k,F,A,J)=>F==="\\"?(te=!0,K):F==="?"?M?M+F+(A?x.repeat(A.length):""):J===0?D+(A?x.repeat(A.length):""):x.repeat(k.length):F==="."?d.repeat(k.length):F==="*"?M?M+F+(A?j:""):j:M?K:`\\${K}`);return te===!0&&(r.unescape===!0?Ae=Ae.replace(/\\/g,""):Ae=Ae.replace(/\\+/g,K=>K.length%2===0?"\\\\":K?"\\":"")),Ae===t&&r.contains===!0?(_.output=t,_):(_.output=vr.wrapOutput(Ae,_,e),_)}for(;!W();){if(w=ce(),w==="\0")continue;if(w==="\\"){let K=G();if(K==="/"&&r.bash!==!0||K==="."||K===";")continue;if(!K){w+="\\",ee({type:"text",value:w});continue}let M=/^\\+/.exec(Te()),k=0;if(M&&M[0].length>2&&(k=M[0].length,_.index+=k,k%2!==0&&(w+="\\")),r.unescape===!0?w=ce():w+=ce(),_.brackets===0){ee({type:"text",value:w});continue}}if(_.brackets>0&&(w!=="]"||E.value==="["||E.value==="[^")){if(r.posix!==!1&&w===":"){let K=E.value.slice(1);if(K.includes("[")&&(E.posix=!0,K.includes(":"))){let M=E.value.lastIndexOf("["),k=E.value.slice(0,M),F=E.value.slice(M+2),A=Rze[F];if(A){E.value=k+A,_.backtrack=!0,ce(),!o.output&&s.indexOf(E)===1&&(o.output=h);continue}}}(w==="["&&G()!==":"||w==="-"&&G()==="]")&&(w=`\\${w}`),w==="]"&&(E.value==="["||E.value==="[^")&&(w=`\\${w}`),r.posix===!0&&w==="!"&&E.value==="["&&(w="^"),E.value+=w,Ce({value:w});continue}if(_.quotes===1&&w!=='"'){w=vr.escapeRegex(w),E.value+=w,Ce({value:w});continue}if(w==='"'){_.quotes=_.quotes===1?0:1,r.keepQuotes===!0&&ee({type:"text",value:w});continue}if(w==="("){De("parens"),ee({type:"paren",value:w});continue}if(w===")"){if(_.parens===0&&r.strictBrackets===!0)throw new SyntaxError(gh("opening","("));let K=ae[ae.length-1];if(K&&_.parens===K.parens+1){Re(ae.pop());continue}ee({type:"paren",value:w,output:_.parens?")":"\\)"}),be("parens");continue}if(w==="["){if(r.nobracket===!0||!Te().includes("]")){if(r.nobracket!==!0&&r.strictBrackets===!0)throw new SyntaxError(gh("closing","]"));w=`\\${w}`}else De("brackets");ee({type:"bracket",value:w});continue}if(w==="]"){if(r.nobracket===!0||E&&E.type==="bracket"&&E.value.length===1){ee({type:"text",value:w,output:`\\${w}`});continue}if(_.brackets===0){if(r.strictBrackets===!0)throw new SyntaxError(gh("opening","["));ee({type:"text",value:w,output:`\\${w}`});continue}be("brackets");let K=E.value.slice(1);if(E.posix!==!0&&K[0]==="^"&&!K.includes("/")&&(w=`/${w}`),E.value+=w,Ce({value:w}),r.literalBrackets===!1||vr.hasRegexChars(K))continue;let M=vr.escapeRegex(E.value);if(_.output=_.output.slice(0,-E.value.length),r.literalBrackets===!0){_.output+=M,E.value=M;continue}E.value=`(${a}${M}|${E.value})`,_.output+=E.value;continue}if(w==="{"&&r.nobrace!==!0){De("braces");let K={type:"brace",value:w,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};I.push(K),ee(K);continue}if(w==="}"){let K=I[I.length-1];if(r.nobrace===!0||!K){ee({type:"text",value:w,output:w});continue}let M=")";if(K.dots===!0){let k=s.slice(),F=[];for(let A=k.length-1;A>=0&&(s.pop(),k[A].type!=="brace");A--)k[A].type!=="dots"&&F.unshift(k[A].value);M=Pze(F,r),_.backtrack=!0}if(K.comma!==!0&&K.dots!==!0){let k=_.output.slice(0,K.outputIndex),F=_.tokens.slice(K.tokensIndex);K.value=K.output="\\{",w=M="\\}",_.output=k;for(let A of F)_.output+=A.output||A.value}ee({type:"brace",value:w,output:M}),be("braces"),I.pop();continue}if(w==="|"){ae.length>0&&ae[ae.length-1].conditions++,ee({type:"text",value:w});continue}if(w===","){let K=w,M=I[I.length-1];M&&g[g.length-1]==="braces"&&(M.comma=!0,K="|"),ee({type:"comma",value:w,output:K});continue}if(w==="/"){if(E.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",s.pop(),E=o;continue}ee({type:"slash",value:w,output:p});continue}if(w==="."){if(_.braces>0&&E.type==="dot"){E.value==="."&&(E.output=d);let K=I[I.length-1];E.type="dots",E.output+=w,E.value+=w,K.dots=!0;continue}if(_.braces+_.parens===0&&E.type!=="bos"&&E.type!=="slash"){ee({type:"text",value:w,output:d});continue}ee({type:"dot",value:w,output:d});continue}if(w==="?"){if(!(E&&E.value==="(")&&r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ie("qmark",w);continue}if(E&&E.type==="paren"){let M=G(),k=w;if(M==="<"&&!vr.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(E.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(Te()))&&(k=`\\${w}`),ee({type:"text",value:w,output:k});continue}if(r.dot!==!0&&(E.type==="slash"||E.type==="bos")){ee({type:"qmark",value:w,output:v});continue}ee({type:"qmark",value:w,output:x});continue}if(w==="!"){if(r.noextglob!==!0&&G()==="("&&(G(2)!=="?"||!/[!=<:]/.test(G(3)))){ie("negate",w);continue}if(r.nonegate!==!0&&_.index===0){V();continue}}if(w==="+"){if(r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ie("plus",w);continue}if(E&&E.value==="("||r.regex===!1){ee({type:"plus",value:w,output:f});continue}if(E&&(E.type==="bracket"||E.type==="paren"||E.type==="brace")||_.parens>0){ee({type:"plus",value:w});continue}ee({type:"plus",value:f});continue}if(w==="@"){if(r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ee({type:"at",extglob:!0,value:w,output:""});continue}ee({type:"text",value:w});continue}if(w!=="*"){(w==="$"||w==="^")&&(w=`\\${w}`);let K=Ize.exec(Te());K&&(w+=K[0],_.index+=K[0].length),ee({type:"text",value:w});continue}if(E&&(E.type==="globstar"||E.star===!0)){E.type="star",E.star=!0,E.value+=w,E.output=j,_.backtrack=!0,_.globstar=!0,we(w);continue}let te=Te();if(r.noextglob!==!0&&/^\([^?]/.test(te)){ie("star",w);continue}if(E.type==="star"){if(r.noglobstar===!0){we(w);continue}let K=E.prev,M=K.prev,k=K.type==="slash"||K.type==="bos",F=M&&(M.type==="star"||M.type==="globstar");if(r.bash===!0&&(!k||te[0]&&te[0]!=="/")){ee({type:"star",value:w,output:""});continue}let A=_.braces>0&&(K.type==="comma"||K.type==="brace"),J=ae.length&&(K.type==="pipe"||K.type==="paren");if(!k&&K.type!=="paren"&&!A&&!J){ee({type:"star",value:w,output:""});continue}for(;te.slice(0,3)==="/**";){let ne=t[_.index+4];if(ne&&ne!=="/")break;te=te.slice(3),we("/**",3)}if(K.type==="bos"&&W()){E.type="globstar",E.value+=w,E.output=U(r),_.output=E.output,_.globstar=!0,we(w);continue}if(K.type==="slash"&&K.prev.type!=="bos"&&!F&&W()){_.output=_.output.slice(0,-(K.output+E.output).length),K.output=`(?:${K.output}`,E.type="globstar",E.output=U(r)+(r.strictSlashes?")":"|$)"),E.value+=w,_.globstar=!0,_.output+=K.output+E.output,we(w);continue}if(K.type==="slash"&&K.prev.type!=="bos"&&te[0]==="/"){let ne=te[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(K.output+E.output).length),K.output=`(?:${K.output}`,E.type="globstar",E.output=`${U(r)}${p}|${p}${ne})`,E.value+=w,_.output+=K.output+E.output,_.globstar=!0,we(w+ce()),ee({type:"slash",value:"/",output:""});continue}if(K.type==="bos"&&te[0]==="/"){E.type="globstar",E.value+=w,E.output=`(?:^|${p}|${U(r)}${p})`,_.output=E.output,_.globstar=!0,we(w+ce()),ee({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-E.output.length),E.type="globstar",E.output=U(r),E.value+=w,_.output+=E.output,_.globstar=!0,we(w);continue}let Ae={type:"star",value:w,output:j};if(r.bash===!0){Ae.output=".*?",(E.type==="bos"||E.type==="slash")&&(Ae.output=C+Ae.output),ee(Ae);continue}if(E&&(E.type==="bracket"||E.type==="paren")&&r.regex===!0){Ae.output=w,ee(Ae);continue}(_.index===_.start||E.type==="slash"||E.type==="dot")&&(E.type==="dot"?(_.output+=S,E.output+=S):r.dot===!0?(_.output+=T,E.output+=T):(_.output+=C,E.output+=C),G()!=="*"&&(_.output+=h,E.output+=h)),ee(Ae)}for(;_.brackets>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing","]"));_.output=vr.escapeLast(_.output,"["),be("brackets")}for(;_.parens>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing",")"));_.output=vr.escapeLast(_.output,"("),be("parens")}for(;_.braces>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing","}"));_.output=vr.escapeLast(_.output,"{"),be("braces")}if(r.strictSlashes!==!0&&(E.type==="star"||E.type==="bracket")&&ee({type:"maybe_slash",value:"",output:`${p}?`}),_.backtrack===!0){_.output="";for(let te of _.tokens)_.output+=te.output!=null?te.output:te.value,te.suffix&&(_.output+=te.suffix)}return _};Fj.fastpaths=(t,e)=>{let r={...e},n=typeof r.maxLength=="number"?Math.min(rI,r.maxLength):rI,i=t.length;if(i>n)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${n}`);t=yce[t]||t;let o=vr.isWindows(e),{DOT_LITERAL:s,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:h}=Xy.globChars(o),m=r.dot?d:u,y=r.dot?f:u,S=r.capture?"":"?:",T={negated:!1,prefix:""},x=r.bash===!0?".*?":p;r.capture&&(x=`(${x})`);let v=C=>C.noglobstar===!0?x:`(${S}(?:(?!${h}${C.dot?l:s}).)*?)`,N=C=>{switch(C){case"*":return`${m}${c}${x}`;case".*":return`${s}${c}${x}`;case"*.*":return`${m}${x}${s}${c}${x}`;case"*/*":return`${m}${x}${a}${c}${y}${x}`;case"**":return m+v(r);case"**/*":return`(?:${m}${v(r)}${a})?${y}${c}${x}`;case"**/*.*":return`(?:${m}${v(r)}${a})?${y}${x}${s}${c}${x}`;case"**/.*":return`(?:${m}${v(r)}${a})?${s}${c}${x}`;default:{let D=/^(.*?)\.(\w+)$/.exec(C);if(!D)return;let j=N(D[1]);return j?j+s+D[2]:void 0}}},R=vr.removePrefix(t,T),U=N(R);return U&&r.strictSlashes!==!0&&(U+=`${a}?`),U};vce.exports=Fj});var xce=b((aLt,Tce)=>{"use strict";var Lze=Z("path"),$ze=_ce(),Bj=bce(),jj=Zy(),Uze=Ky(),Fze=t=>t&&typeof t=="object"&&!Array.isArray(t),Ot=(t,e,r=!1)=>{if(Array.isArray(t)){let u=t.map(f=>Ot(f,e,r));return f=>{for(let p of u){let h=p(f);if(h)return h}return!1}}let n=Fze(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!n)throw new TypeError("Expected pattern to be a non-empty string");let i=e||{},o=jj.isWindows(e),s=n?Ot.compileRe(t,e):Ot.makeRe(t,e,!1,!0),a=s.state;delete s.state;let c=()=>!1;if(i.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};c=Ot(i.ignore,u,r)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:h}=Ot.test(u,s,e,{glob:t,posix:o}),m={glob:t,state:a,regex:s,posix:o,input:u,output:h,match:p,isMatch:f};return typeof i.onResult=="function"&&i.onResult(m),f===!1?(m.isMatch=!1,d?m:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(m),m.isMatch=!1,d?m:!1):(typeof i.onMatch=="function"&&i.onMatch(m),d?m:!0)};return r&&(l.state=a),l};Ot.test=(t,e,r,{glob:n,posix:i}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let o=r||{},s=o.format||(i?jj.toPosixSlashes:null),a=t===n,c=a&&s?s(t):t;return a===!1&&(c=s?s(t):t,a=c===n),(a===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?a=Ot.matchBase(t,e,r,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};Ot.matchBase=(t,e,r,n=jj.isWindows(r))=>(e instanceof RegExp?e:Ot.makeRe(e,r)).test(Lze.basename(t));Ot.isMatch=(t,e,r)=>Ot(e,r)(t);Ot.parse=(t,e)=>Array.isArray(t)?t.map(r=>Ot.parse(r,e)):Bj(t,{...e,fastpaths:!1});Ot.scan=(t,e)=>$ze(t,e);Ot.compileRe=(t,e,r=!1,n=!1)=>{if(r===!0)return t.output;let i=e||{},o=i.contains?"":"^",s=i.contains?"":"$",a=`${o}(?:${t.output})${s}`;t&&t.negated===!0&&(a=`^(?!${a}).*$`);let c=Ot.toRegex(a,e);return n===!0&&(c.state=t),c};Ot.makeRe=(t,e={},r=!1,n=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(i.output=Bj.fastpaths(t,e)),i.output||(i=Bj(t,e)),Ot.compileRe(i,e,r,n)};Ot.toRegex=(t,e)=>{try{let r=e||{};return new RegExp(t,r.flags||(r.nocase?"i":""))}catch(r){if(e&&e.debug===!0)throw r;return/$^/}};Ot.constants=Uze;Tce.exports=Ot});var Ace=b((cLt,wce)=>{"use strict";wce.exports=xce()});var Gj=b((lLt,Oce)=>{"use strict";var Ice=Z("util"),Cce=ice(),No=Ace(),zj=Zy(),Rce=t=>t===""||t==="./",Pce=t=>{let e=t.indexOf("{");return e>-1&&t.indexOf("}",e)>-1},ht=(t,e,r)=>{e=[].concat(e),t=[].concat(t);let n=new Set,i=new Set,o=new Set,s=0,a=u=>{o.add(u.output),r&&r.onResult&&r.onResult(u)};for(let u=0;u<e.length;u++){let d=No(String(e[u]),{...r,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&s++;for(let p of t){let h=d(p,!0);(f?!h.isMatch:h.isMatch)&&(f?n.add(h.output):(n.delete(h.output),i.add(h.output)))}}let l=(s===e.length?[...o]:[...i]).filter(u=>!n.has(u));if(r&&l.length===0){if(r.failglob===!0)throw new Error(`No matches found for "${e.join(", ")}"`);if(r.nonull===!0||r.nullglob===!0)return r.unescape?e.map(u=>u.replace(/\\/g,"")):e}return l};ht.match=ht;ht.matcher=(t,e)=>No(t,e);ht.isMatch=(t,e,r)=>No(e,r)(t);ht.any=ht.isMatch;ht.not=(t,e,r={})=>{e=[].concat(e).map(String);let n=new Set,i=[],o=a=>{r.onResult&&r.onResult(a),i.push(a.output)},s=new Set(ht(t,e,{...r,onResult:o}));for(let a of i)s.has(a)||n.add(a);return[...n]};ht.contains=(t,e,r)=>{if(typeof t!="string")throw new TypeError(`Expected a string: "${Ice.inspect(t)}"`);if(Array.isArray(e))return e.some(n=>ht.contains(t,n,r));if(typeof e=="string"){if(Rce(t)||Rce(e))return!1;if(t.includes(e)||t.startsWith("./")&&t.slice(2).includes(e))return!0}return ht.isMatch(t,e,{...r,contains:!0})};ht.matchKeys=(t,e,r)=>{if(!zj.isObject(t))throw new TypeError("Expected the first argument to be an object");let n=ht(Object.keys(t),e,r),i={};for(let o of n)i[o]=t[o];return i};ht.some=(t,e,r)=>{let n=[].concat(t);for(let i of[].concat(e)){let o=No(String(i),r);if(n.some(s=>o(s)))return!0}return!1};ht.every=(t,e,r)=>{let n=[].concat(t);for(let i of[].concat(e)){let o=No(String(i),r);if(!n.every(s=>o(s)))return!1}return!0};ht.all=(t,e,r)=>{if(typeof t!="string")throw new TypeError(`Expected a string: "${Ice.inspect(t)}"`);return[].concat(e).every(n=>No(n,r)(t))};ht.capture=(t,e,r)=>{let n=zj.isWindows(r),o=No.makeRe(String(t),{...r,capture:!0}).exec(n?zj.toPosixSlashes(e):e);if(o)return o.slice(1).map(s=>s===void 0?"":s)};ht.makeRe=(...t)=>No.makeRe(...t);ht.scan=(...t)=>No.scan(...t);ht.parse=(t,e)=>{let r=[];for(let n of[].concat(t||[]))for(let i of Cce(String(n),e))r.push(No.parse(i,e));return r};ht.braces=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");return e&&e.nobrace===!0||!Pce(t)?[t]:Cce(t,e)};ht.braceExpand=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");return ht.braces(t,{...e,expand:!0})};ht.hasBraces=Pce;Oce.exports=ht});var jce=b(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.isAbsolute=Ie.partitionAbsoluteAndRelative=Ie.removeDuplicateSlashes=Ie.matchAny=Ie.convertPatternsToRe=Ie.makeRe=Ie.getPatternParts=Ie.expandBraceExpansion=Ie.expandPatternsWithBraceExpansion=Ie.isAffectDepthOfReadingPattern=Ie.endsWithSlashGlobStar=Ie.hasGlobStar=Ie.getBaseDirectory=Ie.isPatternRelatedToParentDirectory=Ie.getPatternsOutsideCurrentDirectory=Ie.getPatternsInsideCurrentDirectory=Ie.getPositivePatterns=Ie.getNegativePatterns=Ie.isPositivePattern=Ie.isNegativePattern=Ie.convertToNegativePattern=Ie.convertToPositivePattern=Ie.isDynamicPattern=Ie.isStaticPattern=void 0;var Nce=Z("path"),Bze=bae(),qj=Gj(),kce="**",jze="\\",zze=/[*?]|^!/,Gze=/\[[^[]*]/,qze=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/,Vze=/[!*+?@]\([^(]*\)/,Hze=/,|\.\./,Wze=/(?!^)\/{2,}/g;function Mce(t,e={}){return!Dce(t,e)}Ie.isStaticPattern=Mce;function Dce(t,e={}){return t===""?!1:!!(e.caseSensitiveMatch===!1||t.includes(jze)||zze.test(t)||Gze.test(t)||qze.test(t)||e.extglob!==!1&&Vze.test(t)||e.braceExpansion!==!1&&Yze(t))}Ie.isDynamicPattern=Dce;function Yze(t){let e=t.indexOf("{");if(e===-1)return!1;let r=t.indexOf("}",e+1);if(r===-1)return!1;let n=t.slice(e,r);return Hze.test(n)}function Kze(t){return nI(t)?t.slice(1):t}Ie.convertToPositivePattern=Kze;function Zze(t){return"!"+t}Ie.convertToNegativePattern=Zze;function nI(t){return t.startsWith("!")&&t[1]!=="("}Ie.isNegativePattern=nI;function Lce(t){return!nI(t)}Ie.isPositivePattern=Lce;function Jze(t){return t.filter(nI)}Ie.getNegativePatterns=Jze;function Xze(t){return t.filter(Lce)}Ie.getPositivePatterns=Xze;function Qze(t){return t.filter(e=>!Vj(e))}Ie.getPatternsInsideCurrentDirectory=Qze;function eGe(t){return t.filter(Vj)}Ie.getPatternsOutsideCurrentDirectory=eGe;function Vj(t){return t.startsWith("..")||t.startsWith("./..")}Ie.isPatternRelatedToParentDirectory=Vj;function tGe(t){return Bze(t,{flipBackslashes:!1})}Ie.getBaseDirectory=tGe;function rGe(t){return t.includes(kce)}Ie.hasGlobStar=rGe;function $ce(t){return t.endsWith("/"+kce)}Ie.endsWithSlashGlobStar=$ce;function nGe(t){let e=Nce.basename(t);return $ce(t)||Mce(e)}Ie.isAffectDepthOfReadingPattern=nGe;function iGe(t){return t.reduce((e,r)=>e.concat(Uce(r)),[])}Ie.expandPatternsWithBraceExpansion=iGe;function Uce(t){let e=qj.braces(t,{expand:!0,nodupes:!0,keepEscaping:!0});return e.sort((r,n)=>r.length-n.length),e.filter(r=>r!=="")}Ie.expandBraceExpansion=Uce;function oGe(t,e){let{parts:r}=qj.scan(t,Object.assign(Object.assign({},e),{parts:!0}));return r.length===0&&(r=[t]),r[0].startsWith("/")&&(r[0]=r[0].slice(1),r.unshift("")),r}Ie.getPatternParts=oGe;function Fce(t,e){return qj.makeRe(t,e)}Ie.makeRe=Fce;function sGe(t,e){return t.map(r=>Fce(r,e))}Ie.convertPatternsToRe=sGe;function aGe(t,e){return e.some(r=>r.test(t))}Ie.matchAny=aGe;function cGe(t){return t.replace(Wze,"/")}Ie.removeDuplicateSlashes=cGe;function lGe(t){let e=[],r=[];for(let n of t)Bce(n)?e.push(n):r.push(n);return[e,r]}Ie.partitionAbsoluteAndRelative=lGe;function Bce(t){return Nce.isAbsolute(t)}Ie.isAbsolute=Bce});var Vce=b((dLt,qce)=>{"use strict";var uGe=Z("stream"),zce=uGe.PassThrough,dGe=Array.prototype.slice;qce.exports=fGe;function fGe(){let t=[],e=dGe.call(arguments),r=!1,n=e[e.length-1];n&&!Array.isArray(n)&&n.pipe==null?e.pop():n={};let i=n.end!==!1,o=n.pipeError===!0;n.objectMode==null&&(n.objectMode=!0),n.highWaterMark==null&&(n.highWaterMark=64*1024);let s=zce(n);function a(){for(let u=0,d=arguments.length;u<d;u++)t.push(Gce(arguments[u],n));return c(),this}function c(){if(r)return;r=!0;let u=t.shift();if(!u){process.nextTick(l);return}Array.isArray(u)||(u=[u]);let d=u.length+1;function f(){--d>0||(r=!1,c())}function p(h){function m(){h.removeListener("merge2UnpipeEnd",m),h.removeListener("end",m),o&&h.removeListener("error",y),f()}function y(S){s.emit("error",S)}if(h._readableState.endEmitted)return f();h.on("merge2UnpipeEnd",m),h.on("end",m),o&&h.on("error",y),h.pipe(s,{end:!1}),h.resume()}for(let h=0;h<u.length;h++)p(u[h]);f()}function l(){r=!1,s.emit("queueDrain"),i&&s.end()}return s.setMaxListeners(0),s.add=a,s.on("unpipe",function(u){u.emit("merge2UnpipeEnd")}),e.length&&a.apply(null,e),s}function Gce(t,e){if(Array.isArray(t))for(let r=0,n=t.length;r<n;r++)t[r]=Gce(t[r],e);else{if(!t._readableState&&t.pipe&&(t=t.pipe(zce(e))),!t._readableState||!t.pause||!t.pipe)throw new Error("Only readable stream can be merged.");t.pause()}return t}});var Wce=b(iI=>{"use strict";Object.defineProperty(iI,"__esModule",{value:!0});iI.merge=void 0;var pGe=Vce();function hGe(t){let e=pGe(t);return t.forEach(r=>{r.once("error",n=>e.emit("error",n))}),e.once("close",()=>Hce(t)),e.once("end",()=>Hce(t)),e}iI.merge=hGe;function Hce(t){t.forEach(e=>e.emit("close"))}});var Yce=b(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});_h.isEmpty=_h.isString=void 0;function mGe(t){return typeof t=="string"}_h.isString=mGe;function gGe(t){return t===""}_h.isEmpty=gGe});var qs=b(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.string=br.stream=br.pattern=br.path=br.fs=br.errno=br.array=void 0;var _Ge=lae();br.array=_Ge;var yGe=uae();br.errno=yGe;var SGe=dae();br.fs=SGe;var EGe=mae();br.path=EGe;var vGe=jce();br.pattern=vGe;var bGe=Wce();br.stream=bGe;var TGe=Yce();br.string=TGe});var Xce=b(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.convertPatternGroupToTask=Tr.convertPatternGroupsToTasks=Tr.groupPatternsByBaseDirectory=Tr.getNegativePatternsAsPositive=Tr.getPositivePatterns=Tr.convertPatternsToTasks=Tr.generate=void 0;var ki=qs();function xGe(t,e){let r=Kce(t,e),n=Kce(e.ignore,e),i=Zce(r),o=Jce(r,n),s=i.filter(u=>ki.pattern.isStaticPattern(u,e)),a=i.filter(u=>ki.pattern.isDynamicPattern(u,e)),c=Hj(s,o,!1),l=Hj(a,o,!0);return c.concat(l)}Tr.generate=xGe;function Kce(t,e){let r=t;return e.braceExpansion&&(r=ki.pattern.expandPatternsWithBraceExpansion(r)),e.baseNameMatch&&(r=r.map(n=>n.includes("/")?n:`**/${n}`)),r.map(n=>ki.pattern.removeDuplicateSlashes(n))}function Hj(t,e,r){let n=[],i=ki.pattern.getPatternsOutsideCurrentDirectory(t),o=ki.pattern.getPatternsInsideCurrentDirectory(t),s=Wj(i),a=Wj(o);return n.push(...Yj(s,e,r)),"."in a?n.push(Kj(".",o,e,r)):n.push(...Yj(a,e,r)),n}Tr.convertPatternsToTasks=Hj;function Zce(t){return ki.pattern.getPositivePatterns(t)}Tr.getPositivePatterns=Zce;function Jce(t,e){return ki.pattern.getNegativePatterns(t).concat(e).map(ki.pattern.convertToPositivePattern)}Tr.getNegativePatternsAsPositive=Jce;function Wj(t){let e={};return t.reduce((r,n)=>{let i=ki.pattern.getBaseDirectory(n);return i in r?r[i].push(n):r[i]=[n],r},e)}Tr.groupPatternsByBaseDirectory=Wj;function Yj(t,e,r){return Object.keys(t).map(n=>Kj(n,t[n],e,r))}Tr.convertPatternGroupsToTasks=Yj;function Kj(t,e,r,n){return{dynamic:n,positive:e,negative:r,base:t,patterns:[].concat(e,r.map(ki.pattern.convertToNegativePattern))}}Tr.convertPatternGroupToTask=Kj});var ele=b(oI=>{"use strict";Object.defineProperty(oI,"__esModule",{value:!0});oI.read=void 0;function wGe(t,e,r){e.fs.lstat(t,(n,i)=>{if(n!==null){Qce(r,n);return}if(!i.isSymbolicLink()||!e.followSymbolicLink){Zj(r,i);return}e.fs.stat(t,(o,s)=>{if(o!==null){if(e.throwErrorOnBrokenSymbolicLink){Qce(r,o);return}Zj(r,i);return}e.markSymbolicLink&&(s.isSymbolicLink=()=>!0),Zj(r,s)})})}oI.read=wGe;function Qce(t,e){t(e)}function Zj(t,e){t(null,e)}});var tle=b(sI=>{"use strict";Object.defineProperty(sI,"__esModule",{value:!0});sI.read=void 0;function AGe(t,e){let r=e.fs.lstatSync(t);if(!r.isSymbolicLink()||!e.followSymbolicLink)return r;try{let n=e.fs.statSync(t);return e.markSymbolicLink&&(n.isSymbolicLink=()=>!0),n}catch(n){if(!e.throwErrorOnBrokenSymbolicLink)return r;throw n}}sI.read=AGe});var rle=b(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.createFileSystemAdapter=vc.FILE_SYSTEM_ADAPTER=void 0;var aI=Z("fs");vc.FILE_SYSTEM_ADAPTER={lstat:aI.lstat,stat:aI.stat,lstatSync:aI.lstatSync,statSync:aI.statSync};function RGe(t){return t===void 0?vc.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},vc.FILE_SYSTEM_ADAPTER),t)}vc.createFileSystemAdapter=RGe});var nle=b(Xj=>{"use strict";Object.defineProperty(Xj,"__esModule",{value:!0});var IGe=rle(),Jj=class{constructor(e={}){this._options=e,this.followSymbolicLink=this._getValue(this._options.followSymbolicLink,!0),this.fs=IGe.createFileSystemAdapter(this._options.fs),this.markSymbolicLink=this._getValue(this._options.markSymbolicLink,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0)}_getValue(e,r){return e??r}};Xj.default=Jj});var xu=b(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.statSync=bc.stat=bc.Settings=void 0;var ile=ele(),CGe=tle(),Qj=nle();bc.Settings=Qj.default;function PGe(t,e,r){if(typeof e=="function"){ile.read(t,ez(),e);return}ile.read(t,ez(e),r)}bc.stat=PGe;function OGe(t,e){let r=ez(e);return CGe.read(t,r)}bc.statSync=OGe;function ez(t={}){return t instanceof Qj.default?t:new Qj.default(t)}});var ale=b((vLt,sle)=>{"use strict";var ole;sle.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:global):t=>(ole||(ole=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var lle=b((bLt,cle)=>{"use strict";cle.exports=kGe;var NGe=ale();function kGe(t,e){let r,n,i,o=!0;Array.isArray(t)?(r=[],n=t.length):(i=Object.keys(t),r={},n=i.length);function s(c){function l(){e&&e(c,r),e=null}o?NGe(l):l()}function a(c,l,u){r[c]=u,(--n===0||l)&&s(l)}n?i?i.forEach(function(c){t[c](function(l,u){a(c,l,u)})}):t.forEach(function(c,l){c(function(u,d){a(l,u,d)})}):s(null),o=!1}});var tz=b(lI=>{"use strict";Object.defineProperty(lI,"__esModule",{value:!0});lI.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;var cI=process.versions.node.split(".");if(cI[0]===void 0||cI[1]===void 0)throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);var ule=Number.parseInt(cI[0],10),MGe=Number.parseInt(cI[1],10),dle=10,DGe=10,LGe=ule>dle,$Ge=ule===dle&&MGe>=DGe;lI.IS_SUPPORT_READDIR_WITH_FILE_TYPES=LGe||$Ge});var fle=b(uI=>{"use strict";Object.defineProperty(uI,"__esModule",{value:!0});uI.createDirentFromStats=void 0;var rz=class{constructor(e,r){this.name=e,this.isBlockDevice=r.isBlockDevice.bind(r),this.isCharacterDevice=r.isCharacterDevice.bind(r),this.isDirectory=r.isDirectory.bind(r),this.isFIFO=r.isFIFO.bind(r),this.isFile=r.isFile.bind(r),this.isSocket=r.isSocket.bind(r),this.isSymbolicLink=r.isSymbolicLink.bind(r)}};function UGe(t,e){return new rz(t,e)}uI.createDirentFromStats=UGe});var nz=b(dI=>{"use strict";Object.defineProperty(dI,"__esModule",{value:!0});dI.fs=void 0;var FGe=fle();dI.fs=FGe});var iz=b(fI=>{"use strict";Object.defineProperty(fI,"__esModule",{value:!0});fI.joinPathSegments=void 0;function BGe(t,e,r){return t.endsWith(r)?t+e:t+r+e}fI.joinPathSegments=BGe});var yle=b(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.readdir=Tc.readdirWithFileTypes=Tc.read=void 0;var jGe=xu(),ple=lle(),zGe=tz(),hle=nz(),mle=iz();function GGe(t,e,r){if(!e.stats&&zGe.IS_SUPPORT_READDIR_WITH_FILE_TYPES){gle(t,e,r);return}_le(t,e,r)}Tc.read=GGe;function gle(t,e,r){e.fs.readdir(t,{withFileTypes:!0},(n,i)=>{if(n!==null){pI(r,n);return}let o=i.map(a=>({dirent:a,name:a.name,path:mle.joinPathSegments(t,a.name,e.pathSegmentSeparator)}));if(!e.followSymbolicLinks){oz(r,o);return}let s=o.map(a=>qGe(a,e));ple(s,(a,c)=>{if(a!==null){pI(r,a);return}oz(r,c)})})}Tc.readdirWithFileTypes=gle;function qGe(t,e){return r=>{if(!t.dirent.isSymbolicLink()){r(null,t);return}e.fs.stat(t.path,(n,i)=>{if(n!==null){if(e.throwErrorOnBrokenSymbolicLink){r(n);return}r(null,t);return}t.dirent=hle.fs.createDirentFromStats(t.name,i),r(null,t)})}}function _le(t,e,r){e.fs.readdir(t,(n,i)=>{if(n!==null){pI(r,n);return}let o=i.map(s=>{let a=mle.joinPathSegments(t,s,e.pathSegmentSeparator);return c=>{jGe.stat(a,e.fsStatSettings,(l,u)=>{if(l!==null){c(l);return}let d={name:s,path:a,dirent:hle.fs.createDirentFromStats(s,u)};e.stats&&(d.stats=u),c(null,d)})}});ple(o,(s,a)=>{if(s!==null){pI(r,s);return}oz(r,a)})})}Tc.readdir=_le;function pI(t,e){t(e)}function oz(t,e){t(null,e)}});var Tle=b(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.readdir=xc.readdirWithFileTypes=xc.read=void 0;var VGe=xu(),HGe=tz(),Sle=nz(),Ele=iz();function WGe(t,e){return!e.stats&&HGe.IS_SUPPORT_READDIR_WITH_FILE_TYPES?vle(t,e):ble(t,e)}xc.read=WGe;function vle(t,e){return e.fs.readdirSync(t,{withFileTypes:!0}).map(n=>{let i={dirent:n,name:n.name,path:Ele.joinPathSegments(t,n.name,e.pathSegmentSeparator)};if(i.dirent.isSymbolicLink()&&e.followSymbolicLinks)try{let o=e.fs.statSync(i.path);i.dirent=Sle.fs.createDirentFromStats(i.name,o)}catch(o){if(e.throwErrorOnBrokenSymbolicLink)throw o}return i})}xc.readdirWithFileTypes=vle;function ble(t,e){return e.fs.readdirSync(t).map(n=>{let i=Ele.joinPathSegments(t,n,e.pathSegmentSeparator),o=VGe.statSync(i,e.fsStatSettings),s={name:n,path:i,dirent:Sle.fs.createDirentFromStats(n,o)};return e.stats&&(s.stats=o),s})}xc.readdir=ble});var xle=b(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.createFileSystemAdapter=wc.FILE_SYSTEM_ADAPTER=void 0;var yh=Z("fs");wc.FILE_SYSTEM_ADAPTER={lstat:yh.lstat,stat:yh.stat,lstatSync:yh.lstatSync,statSync:yh.statSync,readdir:yh.readdir,readdirSync:yh.readdirSync};function YGe(t){return t===void 0?wc.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},wc.FILE_SYSTEM_ADAPTER),t)}wc.createFileSystemAdapter=YGe});var wle=b(az=>{"use strict";Object.defineProperty(az,"__esModule",{value:!0});var KGe=Z("path"),ZGe=xu(),JGe=xle(),sz=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=JGe.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,KGe.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new ZGe.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,r){return e??r}};az.default=sz});var hI=b(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.Settings=Ac.scandirSync=Ac.scandir=void 0;var Ale=yle(),XGe=Tle(),cz=wle();Ac.Settings=cz.default;function QGe(t,e,r){if(typeof e=="function"){Ale.read(t,lz(),e);return}Ale.read(t,lz(e),r)}Ac.scandir=QGe;function e4e(t,e){let r=lz(e);return XGe.read(t,r)}Ac.scandirSync=e4e;function lz(t={}){return t instanceof cz.default?t:new cz.default(t)}});var Ile=b((NLt,Rle)=>{"use strict";function t4e(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}Rle.exports=t4e});var Ple=b((kLt,uz)=>{"use strict";var r4e=Ile();function Cle(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),!(r>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var n=r4e(n4e),i=null,o=null,s=0,a=null,c={push:m,drain:tn,saturated:tn,pause:u,paused:!1,get concurrency(){return r},set concurrency(R){if(!(R>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(r=R,!c.paused)for(;i&&s<r;)s++,S()},running:l,resume:p,idle:h,length:d,getQueue:f,unshift:y,empty:tn,kill:T,killAndDrain:x,error:N,abort:v};return c;function l(){return s}function u(){c.paused=!0}function d(){for(var R=i,U=0;R;)R=R.next,U++;return U}function f(){for(var R=i,U=[];R;)U.push(R.value),R=R.next;return U}function p(){if(c.paused){if(c.paused=!1,i===null){s++,S();return}for(;i&&s<r;)s++,S()}}function h(){return s===0&&c.length()===0}function m(R,U){var C=n.get();C.context=t,C.release=S,C.value=R,C.callback=U||tn,C.errorHandler=a,s>=r||c.paused?o?(o.next=C,o=C):(i=C,o=C,c.saturated()):(s++,e.call(t,C.value,C.worked))}function y(R,U){var C=n.get();C.context=t,C.release=S,C.value=R,C.callback=U||tn,C.errorHandler=a,s>=r||c.paused?i?(C.next=i,i=C):(i=C,o=C,c.saturated()):(s++,e.call(t,C.value,C.worked))}function S(R){R&&n.release(R);var U=i;U&&s<=r?c.paused?s--:(o===i&&(o=null),i=U.next,U.next=null,e.call(t,U.value,U.worked),o===null&&c.empty()):--s===0&&c.drain()}function T(){i=null,o=null,c.drain=tn}function x(){i=null,o=null,c.drain(),c.drain=tn}function v(){var R=i;for(i=null,o=null;R;){var U=R.next,C=R.callback,D=R.errorHandler,j=R.value,_=R.context;R.value=null,R.callback=tn,R.errorHandler=null,D&&D(new Error("abort"),j),C.call(_,new Error("abort")),R.release(R),R=U}c.drain=tn}function N(R){a=R}}function tn(){}function n4e(){this.value=null,this.callback=tn,this.next=null,this.release=tn,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,n){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=tn,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function i4e(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(u,d){e.call(this,u).then(function(f){d(null,f)},d)}var i=Cle(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=c,i.drained=l,i;function a(u){var d=new Promise(function(f,p){o(u,function(h,m){if(h){p(h);return}f(m)})});return d.catch(tn),d}function c(u){var d=new Promise(function(f,p){s(u,function(h,m){if(h){p(h);return}f(m)})});return d.catch(tn),d}function l(){var u=new Promise(function(d){process.nextTick(function(){if(i.idle())d();else{var f=i.drain;i.drain=function(){typeof f=="function"&&f(),d(),i.drain=f}}})});return u}}uz.exports=Cle;uz.exports.promise=i4e});var mI=b(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.joinPathSegments=ko.replacePathSegmentSeparator=ko.isAppliedFilter=ko.isFatalError=void 0;function o4e(t,e){return t.errorFilter===null?!0:!t.errorFilter(e)}ko.isFatalError=o4e;function s4e(t,e){return t===null||t(e)}ko.isAppliedFilter=s4e;function a4e(t,e){return t.split(/[/\\]/).join(e)}ko.replacePathSegmentSeparator=a4e;function c4e(t,e,r){return t===""?e:t.endsWith(r)?t+e:t+r+e}ko.joinPathSegments=c4e});var pz=b(fz=>{"use strict";Object.defineProperty(fz,"__esModule",{value:!0});var l4e=mI(),dz=class{constructor(e,r){this._root=e,this._settings=r,this._root=l4e.replacePathSegmentSeparator(e,r.pathSegmentSeparator)}};fz.default=dz});var gz=b(mz=>{"use strict";Object.defineProperty(mz,"__esModule",{value:!0});var u4e=Z("events"),d4e=hI(),f4e=Ple(),gI=mI(),p4e=pz(),hz=class extends p4e.default{constructor(e,r){super(e,r),this._settings=r,this._scandir=d4e.scandir,this._emitter=new u4e.EventEmitter,this._queue=f4e(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit("end")}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw new Error("The reader is already destroyed");this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on("entry",e)}onError(e){this._emitter.once("error",e)}onEnd(e){this._emitter.once("end",e)}_pushToQueue(e,r){let n={directory:e,base:r};this._queue.push(n,i=>{i!==null&&this._handleError(i)})}_worker(e,r){this._scandir(e.directory,this._settings.fsScandirSettings,(n,i)=>{if(n!==null){r(n,void 0);return}for(let o of i)this._handleEntry(o,e.base);r(null,void 0)})}_handleError(e){this._isDestroyed||!gI.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit("error",e))}_handleEntry(e,r){if(this._isDestroyed||this._isFatalError)return;let n=e.path;r!==void 0&&(e.path=gI.joinPathSegments(r,e.name,this._settings.pathSegmentSeparator)),gI.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&gI.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,r===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit("entry",e)}};mz.default=hz});var Ole=b(yz=>{"use strict";Object.defineProperty(yz,"__esModule",{value:!0});var h4e=gz(),_z=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new h4e.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(r=>{m4e(e,r)}),this._reader.onEntry(r=>{this._storage.push(r)}),this._reader.onEnd(()=>{g4e(e,this._storage)}),this._reader.read()}};yz.default=_z;function m4e(t,e){t(e)}function g4e(t,e){t(null,e)}});var Nle=b(Ez=>{"use strict";Object.defineProperty(Ez,"__esModule",{value:!0});var _4e=Z("stream"),y4e=gz(),Sz=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new y4e.default(this._root,this._settings),this._stream=new _4e.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit("error",e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}};Ez.default=Sz});var kle=b(bz=>{"use strict";Object.defineProperty(bz,"__esModule",{value:!0});var S4e=hI(),_I=mI(),E4e=pz(),vz=class extends E4e.default{constructor(){super(...arguments),this._scandir=S4e.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,r){this._queue.add({directory:e,base:r})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,r){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let i of n)this._handleEntry(i,r)}catch(n){this._handleError(n)}}_handleError(e){if(_I.isFatalError(this._settings,e))throw e}_handleEntry(e,r){let n=e.path;r!==void 0&&(e.path=_I.joinPathSegments(r,e.name,this._settings.pathSegmentSeparator)),_I.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&_I.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,r===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}};bz.default=vz});var Mle=b(xz=>{"use strict";Object.defineProperty(xz,"__esModule",{value:!0});var v4e=kle(),Tz=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new v4e.default(this._root,this._settings)}read(){return this._reader.read()}};xz.default=Tz});var Dle=b(Az=>{"use strict";Object.defineProperty(Az,"__esModule",{value:!0});var b4e=Z("path"),T4e=hI(),wz=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,Number.POSITIVE_INFINITY),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,b4e.sep),this.fsScandirSettings=new T4e.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,r){return e??r}};Az.default=wz});var SI=b(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.Settings=Mo.walkStream=Mo.walkSync=Mo.walk=void 0;var Lle=Ole(),x4e=Nle(),w4e=Mle(),Rz=Dle();Mo.Settings=Rz.default;function A4e(t,e,r){if(typeof e=="function"){new Lle.default(t,yI()).read(e);return}new Lle.default(t,yI(e)).read(r)}Mo.walk=A4e;function R4e(t,e){let r=yI(e);return new w4e.default(t,r).read()}Mo.walkSync=R4e;function I4e(t,e){let r=yI(e);return new x4e.default(t,r).read()}Mo.walkStream=I4e;function yI(t={}){return t instanceof Rz.default?t:new Rz.default(t)}});var EI=b(Cz=>{"use strict";Object.defineProperty(Cz,"__esModule",{value:!0});var C4e=Z("path"),P4e=xu(),$le=qs(),Iz=class{constructor(e){this._settings=e,this._fsStatSettings=new P4e.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return C4e.resolve(this._settings.cwd,e)}_makeEntry(e,r){let n={name:r,path:r,dirent:$le.fs.createDirentFromStats(r,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!$le.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}};Cz.default=Iz});var Nz=b(Oz=>{"use strict";Object.defineProperty(Oz,"__esModule",{value:!0});var O4e=Z("stream"),N4e=xu(),k4e=SI(),M4e=EI(),Pz=class extends M4e.default{constructor(){super(...arguments),this._walkStream=k4e.walkStream,this._stat=N4e.stat}dynamic(e,r){return this._walkStream(e,r)}static(e,r){let n=e.map(this._getFullEntryPath,this),i=new O4e.PassThrough({objectMode:!0});i._write=(o,s,a)=>this._getEntry(n[o],e[o],r).then(c=>{c!==null&&r.entryFilter(c)&&i.push(c),o===n.length-1&&i.end(),a()}).catch(a);for(let o=0;o<n.length;o++)i.write(o);return i}_getEntry(e,r,n){return this._getStat(e).then(i=>this._makeEntry(i,r)).catch(i=>{if(n.errorFilter(i))return null;throw i})}_getStat(e){return new Promise((r,n)=>{this._stat(e,this._fsStatSettings,(i,o)=>i===null?r(o):n(i))})}};Oz.default=Pz});var Ule=b(Mz=>{"use strict";Object.defineProperty(Mz,"__esModule",{value:!0});var D4e=SI(),L4e=EI(),$4e=Nz(),kz=class extends L4e.default{constructor(){super(...arguments),this._walkAsync=D4e.walk,this._readerStream=new $4e.default(this._settings)}dynamic(e,r){return new Promise((n,i)=>{this._walkAsync(e,r,(o,s)=>{o===null?n(s):i(o)})})}async static(e,r){let n=[],i=this._readerStream.static(e,r);return new Promise((o,s)=>{i.once("error",s),i.on("data",a=>n.push(a)),i.once("end",()=>o(n))})}};Mz.default=kz});var Fle=b(Lz=>{"use strict";Object.defineProperty(Lz,"__esModule",{value:!0});var Qy=qs(),Dz=class{constructor(e,r,n){this._patterns=e,this._settings=r,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let r=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(r);this._storage.push({complete:n.length<=1,pattern:e,segments:r,sections:n})}}_getPatternSegments(e){return Qy.pattern.getPatternParts(e,this._micromatchOptions).map(n=>Qy.pattern.isDynamicPattern(n,this._settings)?{dynamic:!0,pattern:n,patternRe:Qy.pattern.makeRe(n,this._micromatchOptions)}:{dynamic:!1,pattern:n})}_splitSegmentsIntoSections(e){return Qy.array.splitWhen(e,r=>r.dynamic&&Qy.pattern.hasGlobStar(r.pattern))}};Lz.default=Dz});var Ble=b(Uz=>{"use strict";Object.defineProperty(Uz,"__esModule",{value:!0});var U4e=Fle(),$z=class extends U4e.default{match(e){let r=e.split("/"),n=r.length,i=this._storage.filter(o=>!o.complete||o.segments.length>n);for(let o of i){let s=o.sections[0];if(!o.complete&&n>s.length||r.every((c,l)=>{let u=o.segments[l];return!!(u.dynamic&&u.patternRe.test(c)||!u.dynamic&&u.pattern===c)}))return!0}return!1}};Uz.default=$z});var jle=b(Bz=>{"use strict";Object.defineProperty(Bz,"__esModule",{value:!0});var vI=qs(),F4e=Ble(),Fz=class{constructor(e,r){this._settings=e,this._micromatchOptions=r}getFilter(e,r,n){let i=this._getMatcher(r),o=this._getNegativePatternsRe(n);return s=>this._filter(e,s,i,o)}_getMatcher(e){return new F4e.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let r=e.filter(vI.pattern.isAffectDepthOfReadingPattern);return vI.pattern.convertPatternsToRe(r,this._micromatchOptions)}_filter(e,r,n,i){if(this._isSkippedByDeep(e,r.path)||this._isSkippedSymbolicLink(r))return!1;let o=vI.path.removeLeadingDotSegment(r.path);return this._isSkippedByPositivePatterns(o,n)?!1:this._isSkippedByNegativePatterns(o,i)}_isSkippedByDeep(e,r){return this._settings.deep===1/0?!1:this._getEntryLevel(e,r)>=this._settings.deep}_getEntryLevel(e,r){let n=r.split("/").length;if(e==="")return n;let i=e.split("/").length;return n-i}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,r){return!this._settings.baseNameMatch&&!r.match(e)}_isSkippedByNegativePatterns(e,r){return!vI.pattern.matchAny(e,r)}};Bz.default=Fz});var zle=b(zz=>{"use strict";Object.defineProperty(zz,"__esModule",{value:!0});var Rc=qs(),jz=class{constructor(e,r){this._settings=e,this._micromatchOptions=r,this.index=new Map}getFilter(e,r){let[n,i]=Rc.pattern.partitionAbsoluteAndRelative(r),o={positive:{all:Rc.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:Rc.pattern.convertPatternsToRe(n,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:Rc.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return s=>this._filter(s,o)}_filter(e,r){let n=Rc.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(n)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(n,r,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(n),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,r,n){return!(!this._isMatchToPatterns(e,r.positive.all,n)||this._isMatchToPatterns(e,r.negative.relative,n)||this._isMatchToAbsoluteNegative(e,r.negative.absolute,n))}_isMatchToAbsoluteNegative(e,r,n){if(r.length===0)return!1;let i=Rc.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,r,n)}_isMatchToPatterns(e,r,n){if(r.length===0)return!1;let i=Rc.pattern.matchAny(e,r);return!i&&n?Rc.pattern.matchAny(e+"/",r):i}};zz.default=jz});var Gle=b(qz=>{"use strict";Object.defineProperty(qz,"__esModule",{value:!0});var B4e=qs(),Gz=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return B4e.errno.isEnoentCodeError(e)||this._settings.suppressErrors}};qz.default=Gz});var Vle=b(Hz=>{"use strict";Object.defineProperty(Hz,"__esModule",{value:!0});var qle=qs(),Vz=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let r=e.path;return this._settings.absolute&&(r=qle.path.makeAbsolute(this._settings.cwd,r),r=qle.path.unixify(r)),this._settings.markDirectories&&e.dirent.isDirectory()&&(r+="/"),this._settings.objectMode?Object.assign(Object.assign({},e),{path:r}):r}};Hz.default=Vz});var bI=b(Yz=>{"use strict";Object.defineProperty(Yz,"__esModule",{value:!0});var j4e=Z("path"),z4e=jle(),G4e=zle(),q4e=Gle(),V4e=Vle(),Wz=class{constructor(e){this._settings=e,this.errorFilter=new q4e.default(this._settings),this.entryFilter=new G4e.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new z4e.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new V4e.default(this._settings)}_getRootDirectory(e){return j4e.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let r=e.base==="."?"":e.base;return{basePath:r,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(r,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}};Yz.default=Wz});var Hle=b(Zz=>{"use strict";Object.defineProperty(Zz,"__esModule",{value:!0});var H4e=Ule(),W4e=bI(),Kz=class extends W4e.default{constructor(){super(...arguments),this._reader=new H4e.default(this._settings)}async read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(r,e,n)).map(o=>n.transform(o))}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};Zz.default=Kz});var Wle=b(Xz=>{"use strict";Object.defineProperty(Xz,"__esModule",{value:!0});var Y4e=Z("stream"),K4e=Nz(),Z4e=bI(),Jz=class extends Z4e.default{constructor(){super(...arguments),this._reader=new K4e.default(this._settings)}read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e),i=this.api(r,e,n),o=new Y4e.Readable({objectMode:!0,read:()=>{}});return i.once("error",s=>o.emit("error",s)).on("data",s=>o.emit("data",n.transform(s))).once("end",()=>o.emit("end")),o.once("close",()=>i.destroy()),o}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};Xz.default=Jz});var Yle=b(eG=>{"use strict";Object.defineProperty(eG,"__esModule",{value:!0});var J4e=xu(),X4e=SI(),Q4e=EI(),Qz=class extends Q4e.default{constructor(){super(...arguments),this._walkSync=X4e.walkSync,this._statSync=J4e.statSync}dynamic(e,r){return this._walkSync(e,r)}static(e,r){let n=[];for(let i of e){let o=this._getFullEntryPath(i),s=this._getEntry(o,i,r);s===null||!r.entryFilter(s)||n.push(s)}return n}_getEntry(e,r,n){try{let i=this._getStat(e);return this._makeEntry(i,r)}catch(i){if(n.errorFilter(i))return null;throw i}}_getStat(e){return this._statSync(e,this._fsStatSettings)}};eG.default=Qz});var Kle=b(rG=>{"use strict";Object.defineProperty(rG,"__esModule",{value:!0});var eqe=Yle(),tqe=bI(),tG=class extends tqe.default{constructor(){super(...arguments),this._reader=new eqe.default(this._settings)}read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(r,e,n).map(n.transform)}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};rG.default=tG});var Zle=b(Eh=>{"use strict";Object.defineProperty(Eh,"__esModule",{value:!0});Eh.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;var Sh=Z("fs"),rqe=Z("os"),nqe=Math.max(rqe.cpus().length,1);Eh.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:Sh.lstat,lstatSync:Sh.lstatSync,stat:Sh.stat,statSync:Sh.statSync,readdir:Sh.readdir,readdirSync:Sh.readdirSync};var nG=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,nqe),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,r){return e===void 0?r:e}_getFileSystemMethods(e={}){return Object.assign(Object.assign({},Eh.DEFAULT_FILE_SYSTEM_ADAPTER),e)}};Eh.default=nG});var eS=b((i$t,Xle)=>{"use strict";var Jle=Xce(),iqe=Hle(),oqe=Wle(),sqe=Kle(),iG=Zle(),Jn=qs();async function oG(t,e){Mi(t);let r=sG(t,iqe.default,e),n=await Promise.all(r);return Jn.array.flatten(n)}(function(t){t.glob=t,t.globSync=e,t.globStream=r,t.async=t;function e(l,u){Mi(l);let d=sG(l,sqe.default,u);return Jn.array.flatten(d)}t.sync=e;function r(l,u){Mi(l);let d=sG(l,oqe.default,u);return Jn.stream.merge(d)}t.stream=r;function n(l,u){Mi(l);let d=[].concat(l),f=new iG.default(u);return Jle.generate(d,f)}t.generateTasks=n;function i(l,u){Mi(l);let d=new iG.default(u);return Jn.pattern.isDynamicPattern(l,d)}t.isDynamicPattern=i;function o(l){return Mi(l),Jn.path.escape(l)}t.escapePath=o;function s(l){return Mi(l),Jn.path.convertPathToPattern(l)}t.convertPathToPattern=s;let a;(function(l){function u(f){return Mi(f),Jn.path.escapePosixPath(f)}l.escapePath=u;function d(f){return Mi(f),Jn.path.convertPosixPathToPattern(f)}l.convertPathToPattern=d})(a=t.posix||(t.posix={}));let c;(function(l){function u(f){return Mi(f),Jn.path.escapeWindowsPath(f)}l.escapePath=u;function d(f){return Mi(f),Jn.path.convertWindowsPathToPattern(f)}l.convertPathToPattern=d})(c=t.win32||(t.win32={}))})(oG||(oG={}));function sG(t,e,r){let n=[].concat(t),i=new iG.default(r),o=Jle.generate(n,i),s=new e(i);return o.map(s.read,s)}function Mi(t){if(![].concat(t).every(n=>Jn.string.isString(n)&&!Jn.string.isEmpty(n)))throw new TypeError("Patterns must be a string (non empty) or an array of strings")}Xle.exports=oG});var mG=b((f$t,wI)=>{"use strict";function nue(t){return Array.isArray(t)?t:[t]}var lqe=void 0,uG="",tue=" ",lG="\\",uqe=/^\s+$/,dqe=/(?:[^\\]|^)\\$/,fqe=/^\\!/,pqe=/^\\#/,hqe=/\r?\n/g,mqe=/^\.{0,2}\/|^\.{1,2}$/,gqe=/\/$/,vh="/",iue="node-ignore";typeof Symbol<"u"&&(iue=Symbol.for("node-ignore"));var oue=iue,bh=(t,e,r)=>(Object.defineProperty(t,e,{value:r}),r),_qe=/([0-z])-([0-z])/g,sue=()=>!1,yqe=t=>t.replace(_qe,(e,r,n)=>r.charCodeAt(0)<=n.charCodeAt(0)?e:uG),Sqe=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Eqe=[[/^\uFEFF/,()=>uG],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,r)=>e+(r.indexOf("\\")===0?tue:uG)],[/(\\+?)\s/g,(t,e)=>{let{length:r}=e;return e.slice(0,r-r%2)+tue}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,r)=>e+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,r)=>{let n=r.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>lG],[/\\\\/g,()=>lG],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,r,n,i)=>e===lG?`\\[${r}${Sqe(n)}${i}`:i==="]"&&n.length%2===0?`[${yqe(r)}${n}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`]],vqe=/(^|\\\/)?\\\*$/,tS="regex",TI="checkRegex",rue="_",bqe={[tS](t,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[TI](t,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Tqe=t=>Eqe.reduce((e,[r,n])=>e.replace(r,n.bind(t)),t),xI=t=>typeof t=="string",xqe=t=>t&&xI(t)&&!uqe.test(t)&&!dqe.test(t)&&t.indexOf("#")!==0,wqe=t=>t.split(hqe).filter(Boolean),dG=class{constructor(e,r,n,i,o,s){this.pattern=e,this.mark=r,this.negative=o,bh(this,"body",n),bh(this,"ignoreCase",i),bh(this,"regexPrefix",s)}get regex(){let e=rue+tS;return this[e]?this[e]:this._make(tS,e)}get checkRegex(){let e=rue+TI;return this[e]?this[e]:this._make(TI,e)}_make(e,r){let n=this.regexPrefix.replace(vqe,bqe[e]),i=this.ignoreCase?new RegExp(n,"i"):new RegExp(n);return bh(this,r,i)}},Aqe=({pattern:t,mark:e},r)=>{let n=!1,i=t;i.indexOf("!")===0&&(n=!0,i=i.substr(1)),i=i.replace(fqe,"!").replace(pqe,"#");let o=Tqe(i);return new dG(t,e,i,r,n,o)},fG=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[oue]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(xI(e)&&(e={pattern:e}),xqe(e.pattern)){let r=Aqe(e,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(e){return this._added=!1,nue(xI(e)?wqe(e):e).forEach(this._add,this),this._added}test(e,r,n){let i=!1,o=!1,s;this._rules.forEach(c=>{let{negative:l}=c;o===l&&i!==o||l&&!i&&!o&&!r||!c[n].test(e)||(i=!l,o=l,s=l?lqe:c)});let a={ignored:i,unignored:o};return s&&(a.rule=s),a}},Rqe=(t,e)=>{throw new e(t)},Vs=(t,e,r)=>xI(t)?t?Vs.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${e}\``,TypeError),aue=t=>mqe.test(t);Vs.isNotRelative=aue;Vs.convert=t=>t;var pG=class{constructor({ignorecase:e=!0,ignoreCase:r=e,allowRelativePaths:n=!1}={}){bh(this,oue,!0),this._rules=new fG(r),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,r,n,i){let o=e&&Vs.convert(e);return Vs(o,e,this._strictPathCheck?Rqe:sue),this._t(o,r,n,i)}checkIgnore(e){if(!gqe.test(e))return this.test(e);let r=e.split(vh).filter(Boolean);if(r.pop(),r.length){let n=this._t(r.join(vh)+vh,this._testCache,!0,r);if(n.ignored)return n}return this._rules.test(e,!1,TI)}_t(e,r,n,i){if(e in r)return r[e];if(i||(i=e.split(vh).filter(Boolean)),i.pop(),!i.length)return r[e]=this._rules.test(e,n,tS);let o=this._t(i.join(vh)+vh,r,n,i);return r[e]=o.ignored?o:this._rules.test(e,n,tS)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return nue(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},hG=t=>new pG(t),Iqe=t=>Vs(t&&Vs.convert(t),t,sue),cue=()=>{let t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");Vs.convert=t;let e=/^[a-z]:\//i;Vs.isNotRelative=r=>e.test(r)||aue(r)};typeof process<"u"&&process.platform==="win32"&&cue();wI.exports=hG;hG.default=hG;wI.exports.isPathValid=Iqe;bh(wI.exports,Symbol.for("setupWindows"),cue)});var WG=b(cfe=>{"use strict";cfe.parse=function(t,e){return new HG(t,e).parse()};var HG=class t{constructor(e,r){this.source=e,this.transform=r||rHe,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e==="\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var r;(this.recorded.length>0||e)&&(r=this.recorded.join(""),r==="NULL"&&!e&&(r=null),r!==null&&(r=this.transform(r)),this.entries.push(r),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var r,n,i;for(this.consumeDimensions();!this.isEof();)if(r=this.nextCharacter(),r.value==="{"&&!i)this.dimension++,this.dimension>1&&(n=new t(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse(!0)),this.position+=n.position-2);else if(r.value==="}"&&!i){if(this.dimension--,!this.dimension&&(this.newEntry(),e))return this.entries}else r.value==='"'&&!r.escaped?(i&&this.newEntry(!0),i=!i):r.value===","&&!i?this.newEntry():this.record(r.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};function rHe(t){return t}});var YG=b((mBt,lfe)=>{"use strict";var nHe=WG();lfe.exports={create:function(t,e){return{parse:function(){return nHe.parse(t,e)}}}}});var ffe=b((gBt,dfe)=>{"use strict";var iHe=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,oHe=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,sHe=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,aHe=/^-?infinity$/;dfe.exports=function(e){if(aHe.test(e))return Number(e.replace("i","I"));var r=iHe.exec(e);if(!r)return cHe(e)||null;var n=!!r[8],i=parseInt(r[1],10);n&&(i=ufe(i));var o=parseInt(r[2],10)-1,s=r[3],a=parseInt(r[4],10),c=parseInt(r[5],10),l=parseInt(r[6],10),u=r[7];u=u?1e3*parseFloat(u):0;var d,f=lHe(e);return f!=null?(d=new Date(Date.UTC(i,o,s,a,c,l,u)),KG(i)&&d.setUTCFullYear(i),f!==0&&d.setTime(d.getTime()-f)):(d=new Date(i,o,s,a,c,l,u),KG(i)&&d.setFullYear(i)),d};function cHe(t){var e=oHe.exec(t);if(e){var r=parseInt(e[1],10),n=!!e[4];n&&(r=ufe(r));var i=parseInt(e[2],10)-1,o=e[3],s=new Date(r,i,o);return KG(r)&&s.setFullYear(r),s}}function lHe(t){if(t.endsWith("+00"))return 0;var e=sHe.exec(t.split(" ")[1]);if(e){var r=e[1];if(r==="Z")return 0;var n=r==="-"?-1:1,i=parseInt(e[2],10)*3600+parseInt(e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}function ufe(t){return-(t-1)}function KG(t){return t>=0&&t<100}});var hfe=b((_Bt,pfe)=>{"use strict";pfe.exports=dHe;var uHe=Object.prototype.hasOwnProperty;function dHe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)uHe.call(r,n)&&(t[n]=r[n])}return t}});var _fe=b((yBt,gfe)=>{"use strict";var fHe=hfe();gfe.exports=Dh;function Dh(t){if(!(this instanceof Dh))return new Dh(t);fHe(this,xHe(t))}var pHe=["seconds","minutes","hours","days","months","years"];Dh.prototype.toPostgres=function(){var t=pHe.filter(this.hasOwnProperty,this);return this.milliseconds&&t.indexOf("seconds")<0&&t.push("seconds"),t.length===0?"0":t.map(function(e){var r=this[e]||0;return e==="seconds"&&this.milliseconds&&(r=(r+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),r+" "+e},this).join(" ")};var hHe={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},mHe=["years","months","days"],gHe=["hours","minutes","seconds"];Dh.prototype.toISOString=Dh.prototype.toISO=function(){var t=mHe.map(r,this).join(""),e=gHe.map(r,this).join("");return"P"+t+"T"+e;function r(n){var i=this[n]||0;return n==="seconds"&&this.milliseconds&&(i=(i+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),i+hHe[n]}};var ZG="([+-]?\\d+)",_He=ZG+"\\s+years?",yHe=ZG+"\\s+mons?",SHe=ZG+"\\s+days?",EHe="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",vHe=new RegExp([_He,yHe,SHe,EHe].map(function(t){return"("+t+")?"}).join("\\s*")),mfe={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},bHe=["hours","minutes","seconds","milliseconds"];function THe(t){var e=t+"000000".slice(t.length);return parseInt(e,10)/1e3}function xHe(t){if(!t)return{};var e=vHe.exec(t),r=e[8]==="-";return Object.keys(mfe).reduce(function(n,i){var o=mfe[i],s=e[o];return!s||(s=i==="milliseconds"?THe(s):parseInt(s,10),!s)||(r&&~bHe.indexOf(i)&&(s*=-1),n[i]=s),n},{})}});var Efe=b((SBt,Sfe)=>{"use strict";var yfe=Buffer.from||Buffer;Sfe.exports=function(e){if(/^\\x/.test(e))return yfe(e.substr(2),"hex");for(var r="",n=0;n<e.length;)if(e[n]!=="\\")r+=e[n],++n;else if(/[0-7]{3}/.test(e.substr(n+1,3)))r+=String.fromCharCode(parseInt(e.substr(n+1,3),8)),n+=4;else{for(var i=1;n+i<e.length&&e[n+i]==="\\";)i++;for(var o=0;o<Math.floor(i/2);++o)r+="\\";n+=Math.floor(i/2)*2}return yfe(r,"binary")}});var Rfe=b((EBt,Afe)=>{"use strict";var lS=WG(),uS=YG(),FI=ffe(),bfe=_fe(),Tfe=Efe();function BI(t){return function(r){return r===null?r:t(r)}}function xfe(t){return t===null?t:t==="TRUE"||t==="t"||t==="true"||t==="y"||t==="yes"||t==="on"||t==="1"}function wHe(t){return t?lS.parse(t,xfe):null}function AHe(t){return parseInt(t,10)}function JG(t){return t?lS.parse(t,BI(AHe)):null}function RHe(t){return t?lS.parse(t,BI(function(e){return wfe(e).trim()})):null}var IHe=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=t4(r)),r});return e.parse()},XG=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=parseFloat(r)),r});return e.parse()},Xn=function(t){if(!t)return null;var e=uS.create(t);return e.parse()},QG=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=FI(r)),r});return e.parse()},CHe=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=bfe(r)),r});return e.parse()},PHe=function(t){return t?lS.parse(t,BI(Tfe)):null},e4=function(t){return parseInt(t,10)},wfe=function(t){var e=String(t);return/^\d+$/.test(e)?e:t},vfe=function(t){return t?lS.parse(t,BI(JSON.parse)):null},t4=function(t){return t[0]!=="("?null:(t=t.substring(1,t.length-1).split(","),{x:parseFloat(t[0]),y:parseFloat(t[1])})},OHe=function(t){if(t[0]!=="<"&&t[1]!=="(")return null;for(var e="(",r="",n=!1,i=2;i<t.length-1;i++){if(n||(e+=t[i]),t[i]===")"){n=!0;continue}else if(!n)continue;t[i]!==","&&(r+=t[i])}var o=t4(e);return o.radius=parseFloat(r),o},NHe=function(t){t(20,wfe),t(21,e4),t(23,e4),t(26,e4),t(700,parseFloat),t(701,parseFloat),t(16,xfe),t(1082,FI),t(1114,FI),t(1184,FI),t(600,t4),t(651,Xn),t(718,OHe),t(1e3,wHe),t(1001,PHe),t(1005,JG),t(1007,JG),t(1028,JG),t(1016,RHe),t(1017,IHe),t(1021,XG),t(1022,XG),t(1231,XG),t(1014,Xn),t(1015,Xn),t(1008,Xn),t(1009,Xn),t(1040,Xn),t(1041,Xn),t(1115,QG),t(1182,QG),t(1185,QG),t(1186,bfe),t(1187,CHe),t(17,Tfe),t(114,JSON.parse.bind(JSON)),t(3802,JSON.parse.bind(JSON)),t(199,vfe),t(3807,vfe),t(3907,Xn),t(2951,Xn),t(791,Xn),t(1183,Xn),t(1270,Xn)};Afe.exports={init:NHe}});var Cfe=b((vBt,Ife)=>{"use strict";var nn=1e6;function kHe(t){var e=t.readInt32BE(0),r=t.readUInt32BE(4),n="";e<0&&(e=~e+(r===0),r=~r+1>>>0,n="-");var i="",o,s,a,c,l,u;{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}return o=e%nn,s=4294967296*o+r,a=""+s%nn,n+a+i}Ife.exports=kHe});var Mfe=b((bBt,kfe)=>{"use strict";var MHe=Cfe(),Et=function(t,e,r,n,i){r=r||0,n=n||!1,i=i||function(p,h,m){return p*Math.pow(2,m)+h};var o=r>>3,s=function(p){return n?~p&255:p},a=255,c=8-r%8;e<c&&(a=255<<8-e&255,c=e),r&&(a=a>>r%8);var l=0;r%8+e>=8&&(l=i(0,s(t[o])&a,c));for(var u=e+r>>3,d=o+1;d<u;d++)l=i(l,s(t[d]),8);var f=(e+r)%8;return f>0&&(l=i(l,s(t[u])>>8-f,f)),l},Nfe=function(t,e,r){var n=Math.pow(2,r-1)-1,i=Et(t,1),o=Et(t,r,1);if(o===0)return 0;var s=1,a=function(l,u,d){l===0&&(l=1);for(var f=1;f<=d;f++)s/=2,(u&1<<d-f)>0&&(l+=s);return l},c=Et(t,e,r+1,!1,a);return o==Math.pow(2,r+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,o-n)*c},DHe=function(t){return Et(t,1)==1?-1*(Et(t,15,1,!0)+1):Et(t,15,1)},Pfe=function(t){return Et(t,1)==1?-1*(Et(t,31,1,!0)+1):Et(t,31,1)},LHe=function(t){return Nfe(t,23,8)},$He=function(t){return Nfe(t,52,11)},UHe=function(t){var e=Et(t,16,32);if(e==49152)return NaN;for(var r=Math.pow(1e4,Et(t,16,16)),n=0,i=[],o=Et(t,16),s=0;s<o;s++)n+=Et(t,16,64+16*s)*r,r/=1e4;var a=Math.pow(10,Et(t,16,48));return(e===0?1:-1)*Math.round(n*a)/a},Ofe=function(t,e){var r=Et(e,1),n=Et(e,63,1),i=new Date((r===0?1:-1)*n/1e3+9466848e5);return t||i.setTime(i.getTime()+i.getTimezoneOffset()*6e4),i.usec=n%1e3,i.getMicroSeconds=function(){return this.usec},i.setMicroSeconds=function(o){this.usec=o},i.getUTCMicroSeconds=function(){return this.usec},i},dS=function(t){for(var e=Et(t,32),r=Et(t,32,32),n=Et(t,32,64),i=96,o=[],s=0;s<e;s++)o[s]=Et(t,32,i),i+=32,i+=32;var a=function(l){var u=Et(t,32,i);if(i+=32,u==4294967295)return null;var d;if(l==23||l==20)return d=Et(t,u*8,i),i+=u*8,d;if(l==25)return d=t.toString(this.encoding,i>>3,(i+=u<<3)>>3),d;console.log("ERROR: ElementType not implemented: "+l)},c=function(l,u){var d=[],f;if(l.length>1){var p=l.shift();for(f=0;f<p;f++)d[f]=c(l,u);l.unshift(p)}else for(f=0;f<l[0];f++)d[f]=a(u);return d};return c(o,n)},FHe=function(t){return t.toString("utf8")},BHe=function(t){return t===null?null:Et(t,8)>0},jHe=function(t){t(20,MHe),t(21,DHe),t(23,Pfe),t(26,Pfe),t(1700,UHe),t(700,LHe),t(701,$He),t(16,BHe),t(1114,Ofe.bind(null,!1)),t(1184,Ofe.bind(null,!0)),t(1e3,dS),t(1007,dS),t(1016,dS),t(1008,dS),t(1009,dS),t(25,FHe)};kfe.exports={init:jHe}});var Lfe=b((TBt,Dfe)=>{"use strict";Dfe.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var hS=b(pS=>{"use strict";var zHe=Rfe(),GHe=Mfe(),qHe=YG(),VHe=Lfe();pS.getTypeParser=HHe;pS.setTypeParser=WHe;pS.arrayParser=qHe;pS.builtins=VHe;var fS={text:{},binary:{}};function $fe(t){return String(t)}function HHe(t,e){return e=e||"text",fS[e]&&fS[e][t]||$fe}function WHe(t,e,r){typeof e=="function"&&(r=e,e="text"),fS[e][t]=r}zHe.init(function(t,e){fS.text[t]=e});GHe.init(function(t,e){fS.binary[t]=e})});var mS=b((wBt,r4)=>{"use strict";var Ufe;try{Ufe=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}r4.exports={host:"localhost",user:Ufe,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:"",ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var Lh=hS(),YHe=Lh.getTypeParser(20,"text"),KHe=Lh.getTypeParser(1016,"text");r4.exports.__defineSetter__("parseInt8",function(t){Lh.setTypeParser(20,"text",t?Lh.getTypeParser(23,"text"):YHe),Lh.setTypeParser(1016,"text",t?Lh.getTypeParser(1007,"text"):KHe)})});var $h=b((ABt,Bfe)=>{"use strict";var ZHe=mS(),{isDate:JHe}=Z("util/types");function XHe(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function Ffe(t){let e="{";for(let r=0;r<t.length;r++){r>0&&(e+=",");let n=t[r];n==null?e+="NULL":Array.isArray(n)?e+=Ffe(n):ArrayBuffer.isView(n)?(n instanceof Buffer||(n=Buffer.from(n.buffer,n.byteOffset,n.byteLength)),e+="\\\\x"+n.toString("hex")):e+=XHe(jI(n))}return e+="}",e}var jI=function(t,e){return t==null?null:typeof t=="object"?t instanceof Buffer?t:ArrayBuffer.isView(t)?Buffer.from(t.buffer,t.byteOffset,t.byteLength):JHe(t)?ZHe.parseInputDatesAsUTC?t3e(t):e3e(t):Array.isArray(t)?Ffe(t):QHe(t,e):t.toString()};function QHe(t,e){if(t&&typeof t.toPostgres=="function"){if(e=e||[],e.indexOf(t)!==-1)throw new Error('circular reference detected while preparing "'+t+'" for query');return e.push(t),jI(t.toPostgres(jI),e)}return JSON.stringify(t)}function e3e(t){let e=-t.getTimezoneOffset(),r=t.getFullYear(),n=r<1;n&&(r=Math.abs(r)+1);let i=String(r).padStart(4,"0")+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0")+"T"+String(t.getHours()).padStart(2,"0")+":"+String(t.getMinutes()).padStart(2,"0")+":"+String(t.getSeconds()).padStart(2,"0")+"."+String(t.getMilliseconds()).padStart(3,"0");return e<0?(i+="-",e*=-1):i+="+",i+=String(Math.floor(e/60)).padStart(2,"0")+":"+String(e%60).padStart(2,"0"),n&&(i+=" BC"),i}function t3e(t){let e=t.getUTCFullYear(),r=e<1;r&&(e=Math.abs(e)+1);let n=String(e).padStart(4,"0")+"-"+String(t.getUTCMonth()+1).padStart(2,"0")+"-"+String(t.getUTCDate()).padStart(2,"0")+"T"+String(t.getUTCHours()).padStart(2,"0")+":"+String(t.getUTCMinutes()).padStart(2,"0")+":"+String(t.getUTCSeconds()).padStart(2,"0")+"."+String(t.getUTCMilliseconds()).padStart(3,"0");return n+="+00:00",r&&(n+=" BC"),n}function r3e(t,e,r){return t=typeof t=="string"?{text:t}:t,e&&(typeof e=="function"?t.callback=e:t.values=e),r&&(t.callback=r),t}var n3e=function(t){return'"'+t.replace(/"/g,'""')+'"'},i3e=function(t){let e=!1,r="'";if(t==null||typeof t!="string")return"''";for(let n=0;n<t.length;n++){let i=t[n];i==="'"?r+=i+i:i==="\\"?(r+=i+i,e=!0):r+=i}return r+="'",e===!0&&(r=" E"+r),r};Bfe.exports={prepareValue:function(e){return jI(e)},normalizeQueryConfig:r3e,escapeIdentifier:n3e,escapeLiteral:i3e}});var o4=b((RBt,Gfe)=>{"use strict";var jfe=Z("crypto");Gfe.exports={postgresMd5PasswordHash:s3e,randomBytes:o3e,deriveKey:u3e,sha256:a3e,hashByName:c3e,hmacSha256:l3e,md5:n4};var zfe=jfe.webcrypto||globalThis.crypto,Ru=zfe.subtle,i4=new TextEncoder;function o3e(t){return zfe.getRandomValues(Buffer.alloc(t))}async function n4(t){try{return jfe.createHash("md5").update(t,"utf-8").digest("hex")}catch{let r=typeof t=="string"?i4.encode(t):t,n=await Ru.digest("MD5",r);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}}async function s3e(t,e,r){let n=await n4(e+t);return"md5"+await n4(Buffer.concat([Buffer.from(n),r]))}async function a3e(t){return await Ru.digest("SHA-256",t)}async function c3e(t,e){return await Ru.digest(t,e)}async function l3e(t,e){let r=await Ru.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await Ru.sign("HMAC",r,i4.encode(e))}async function u3e(t,e,r){let n=await Ru.importKey("raw",i4.encode(t),"PBKDF2",!1,["deriveBits"]),i={name:"PBKDF2",hash:"SHA-256",salt:e,iterations:r};return await Ru.deriveBits(i,n,256,["deriveBits"])}});var Hfe=b((IBt,Vfe)=>{"use strict";function Iu(t,e){return new Error("SASL channel binding: "+t+" when parsing public certificate "+e.toString("base64"))}function s4(t,e){let r=t[e++];if(r<128)return{length:r,index:e};let n=r&127;if(n>4)throw Iu("bad length",t);r=0;for(let i=0;i<n;i++)r=r<<8|t[e++];return{length:r,index:e}}function qfe(t,e){if(t[e++]!==6)throw Iu("non-OID data",t);let{length:r,index:n}=s4(t,e);e=n;let i=e+r,o=t[e++],s=(o/40>>0)+"."+o%40;for(;e<i;){let a=0;for(;e<i;){let c=t[e++];if(a=a<<7|c&127,c<128)break}s+="."+a}return{oid:s,index:e}}function gS(t,e){if(t[e++]!==48)throw Iu("non-sequence data",t);return s4(t,e)}function d3e(t,e){e===void 0&&(e=0),e=gS(t,e).index;let{length:r,index:n}=gS(t,e);e=n+r,e=gS(t,e).index;let{oid:i,index:o}=qfe(t,e);switch(i){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(e=o,e=gS(t,e).index,t[e++]!==160)throw Iu("non-tag data",t);e=s4(t,e).index,e=gS(t,e).index;let{oid:s}=qfe(t,e);switch(s){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw Iu("unknown hash OID "+s,t)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw Iu("Ed448 certificate channel binding is not currently supported by Postgres")}throw Iu("unknown OID "+i,t)}Vfe.exports={signatureAlgorithmHashFromCertificate:d3e}});var Zfe=b((CBt,Kfe)=>{"use strict";var Pc=o4(),{signatureAlgorithmHashFromCertificate:f3e}=Hfe();function p3e(t){let e=/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g,r=/[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;return t.replace(e," ").replace(r,"").normalize("NFKC")}var a4=1e5;function h3e(t,e,r=a4){let n=["SCRAM-SHA-256"];e&&n.unshift("SCRAM-SHA-256-PLUS");let i=n.find(a=>t.includes(a));if(!i)throw new Error("SASL: Only mechanism(s) "+n.join(" and ")+" are supported");if(i==="SCRAM-SHA-256-PLUS"&&typeof e.getPeerCertificate!="function")throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let o=Pc.randomBytes(18).toString("base64");return{mechanism:i,clientNonce:o,response:(i==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":e?"y":"n")+",,n=*,r="+o,message:"SASLInitialResponse",scramMaxIterations:r}}async function m3e(t,e,r,n){if(t.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(e==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof r!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let i=y3e(r);if(i.nonce.startsWith(t.clientNonce)){if(i.nonce.length===t.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");let o=typeof t.scramMaxIterations=="number"?t.scramMaxIterations:a4;if(o!==0&&i.iteration>o)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count "+i.iteration+" exceeds scramMaxIterations of "+o);let s="n=*,r="+t.clientNonce,a="r="+i.nonce+",s="+i.salt+",i="+i.iteration,c=n?"eSws":"biws";if(t.mechanism==="SCRAM-SHA-256-PLUS"){let x=n.getPeerCertificate().raw,v=f3e(x);(v==="MD5"||v==="SHA-1")&&(v="SHA-256");let N=await Pc.hashByName(v,x);c=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from(N)]).toString("base64")}let l="c="+c+",r="+i.nonce,u=s+","+a+","+l,d=Buffer.from(i.salt,"base64"),f=await Pc.deriveKey(p3e(e),d,i.iteration),p=await Pc.hmacSha256(f,"Client Key"),h=await Pc.sha256(p),m=await Pc.hmacSha256(h,u),y=E3e(Buffer.from(p),Buffer.from(m)).toString("base64"),S=await Pc.hmacSha256(f,"Server Key"),T=await Pc.hmacSha256(S,u);t.message="SASLResponse",t.serverSignature=Buffer.from(T).toString("base64"),t.response=l+",p="+y}function g3e(t,e){if(t.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:r}=S3e(e);if(r!==t.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function _3e(t){if(typeof t!="string")throw new TypeError("SASL: text must be a string");return t.split("").map((e,r)=>t.charCodeAt(r)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function Wfe(t){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(t)}function Yfe(t){if(typeof t!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(t.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("SASL: Invalid attribute pair entry");let r=e[0],n=e.substring(2);return[r,n]}))}function y3e(t){let e=Yfe(t),r=e.get("r");if(r){if(!_3e(r))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!Wfe(n))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let i=e.get("i");if(i){if(!/^[1-9][0-9]*$/.test(i))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let o=parseInt(i,10);return{nonce:r,salt:n,iteration:o}}function S3e(t){let e=Yfe(t),r=e.get("e"),n=e.get("v");if(r)throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${r}"`);if(n){if(!Wfe(n))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:n}}function E3e(t,e){if(!Buffer.isBuffer(t))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(e))throw new TypeError("second argument must be a Buffer");if(t.length!==e.length)throw new Error("Buffer lengths must match");if(t.length===0)throw new Error("Buffers cannot be empty");return Buffer.from(t.map((r,n)=>t[n]^e[n]))}Kfe.exports={startSession:h3e,continueSession:m3e,finalizeSession:g3e,DEFAULT_MAX_SCRAM_ITERATIONS:a4}});var GI=b((PBt,Jfe)=>{"use strict";var v3e=hS();function zI(t){this._types=t||v3e,this.text={},this.binary={}}zI.prototype.getOverrides=function(t){switch(t){case"text":return this.text;case"binary":return this.binary;default:return{}}};zI.prototype.setTypeParser=function(t,e,r){typeof e=="function"&&(r=e,e="text"),this.getOverrides(e)[t]=r};zI.prototype.getTypeParser=function(t,e){return e=e||"text",this.getOverrides(e)[t]||this._types.getTypeParser(t,e)};Jfe.exports=zI});var epe=b((OBt,Qfe)=>{"use strict";function Uh(t,e={}){if(t.charAt(0)==="/"){let c=t.split(" ");return{host:c[0],database:c[1]}}let r=Object.create(null),n,i=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(t)&&(t=encodeURI(t).replace(/%25(\d\d)/g,"%$1"));try{try{n=new URL(t,"postgres://base")}catch{n=new URL(t.replace("@/","@___DUMMY___/"),"postgres://base"),i=!0}}catch(c){throw c.input&&(c.input="*****REDACTED*****"),c}for(let c of n.searchParams.entries())r[c[0]]=c[1];if(r.user=r.user||decodeURIComponent(n.username),r.password=r.password||decodeURIComponent(n.password),n.protocol=="socket:")return r.host=decodeURI(n.pathname),r.database=n.searchParams.get("db"),r.client_encoding=n.searchParams.get("encoding"),r;let o=i?"":n.hostname;r.host?o&&/^%2f/i.test(o)&&(n.pathname=o+n.pathname):r.host=decodeURIComponent(o),r.port||(r.port=n.port);let s=n.pathname.slice(1)||null;r.database=s?decodeURI(s):null,(r.ssl==="true"||r.ssl==="1")&&(r.ssl=!0),r.ssl==="0"&&(r.ssl=!1),(r.sslcert||r.sslkey||r.sslrootcert||r.sslmode)&&(r.ssl={});let a=r.sslcert||r.sslkey||r.sslrootcert?Z("fs"):null;if(r.sslcert&&(r.ssl.cert=a.readFileSync(r.sslcert).toString()),r.sslkey&&(r.ssl.key=a.readFileSync(r.sslkey).toString()),r.sslrootcert&&(r.ssl.ca=a.readFileSync(r.sslrootcert).toString()),e.useLibpqCompat&&r.uselibpqcompat)throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(r.uselibpqcompat==="true"||e.useLibpqCompat)switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":{r.ssl.rejectUnauthorized=!1;break}case"require":{r.sslrootcert?r.ssl.checkServerIdentity=function(){}:r.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!r.ssl.ca)throw new Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");r.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{r.sslmode!=="verify-full"&&c4(r.sslmode);break}case"no-verify":{r.ssl.rejectUnauthorized=!1;break}}return r}function b3e(t){return Object.entries(t).reduce((r,[n,i])=>(i!=null&&(r[n]=i),r),Object.create(null))}function Xfe(t){return Object.entries(t).reduce((r,[n,i])=>{if(n==="ssl"){let o=i;typeof o=="boolean"&&(r[n]=o),typeof o=="object"&&(r[n]=b3e(o))}else if(i!=null)if(n==="port"){if(i!==""){let o=parseInt(i,10);if(isNaN(o))throw new Error(`Invalid ${n}: ${i}`);r[n]=o}}else r[n]=i;return r},Object.create(null))}function T3e(t){return Xfe(Uh(t))}function c4(t){!c4.warned&&typeof process<"u"&&process.emitWarning&&(c4.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
|
|
22
|
+
`)+1))),this.lastActivityTimestamp=new Date}trace(e,r){(0,Pb.trace)(r??va.LogVerbosity.DEBUG,"channel","("+this.channelzRef.id+") "+(0,Ob.uriToString)(this.target)+" "+e)}callRefTimerRef(){var e,r,n,i;this.callRefTimer||(this.callRefTimer=setInterval(()=>{},kTe)),!((r=(e=this.callRefTimer).hasRef)===null||r===void 0)&&r.call(e)||(this.trace("callRefTimer.ref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),(i=(n=this.callRefTimer).ref)===null||i===void 0||i.call(n))}callRefTimerUnref(){var e,r,n;(!(!((e=this.callRefTimer)===null||e===void 0)&&e.hasRef)||this.callRefTimer.hasRef())&&(this.trace("callRefTimer.unref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),(n=(r=this.callRefTimer)===null||r===void 0?void 0:r.unref)===null||n===void 0||n.call(r))}removeConnectivityStateWatcher(e){let r=this.connectivityStateWatchers.findIndex(n=>n===e);r>=0&&this.connectivityStateWatchers.splice(r,1)}updateState(e){(0,Pb.trace)(va.LogVerbosity.DEBUG,"connectivity_state","("+this.channelzRef.id+") "+(0,Ob.uriToString)(this.target)+" "+Bn.ConnectivityState[this.connectivityState]+" -> "+Bn.ConnectivityState[e]),this.channelzEnabled&&this.channelzInfoTracker.trace.addTrace("CT_INFO","Connectivity state change to "+Bn.ConnectivityState[e]),this.connectivityState=e,this.channelzInfoTracker.state=e;let r=this.connectivityStateWatchers.slice();for(let n of r)e!==n.currentState&&(n.timer&&clearTimeout(n.timer),this.removeConnectivityStateWatcher(n),n.callback());e!==Bn.ConnectivityState.TRANSIENT_FAILURE&&(this.currentResolutionError=null)}throttleKeepalive(e){if(e>this.keepaliveTime){this.keepaliveTime=e;for(let r of this.wrappedSubchannels)r.throttleKeepalive(e)}}addWrappedSubchannel(e){this.wrappedSubchannels.add(e)}removeWrappedSubchannel(e){this.wrappedSubchannels.delete(e)}doPick(e,r){return this.currentPicker.pick({metadata:e,extraPickInfo:r})}queueCallForPick(e){this.pickQueue.push(e),this.callRefTimerRef()}getConfig(e,r){return this.connectivityState!==Bn.ConnectivityState.SHUTDOWN&&this.resolvingLoadBalancer.exitIdle(),this.configSelector?{type:"SUCCESS",config:this.configSelector.invoke(e,r,this.randomChannelId)}:this.currentResolutionError?{type:"ERROR",error:this.currentResolutionError}:{type:"NONE"}}queueCallForConfig(e){this.configSelectionQueue.push(e),this.callRefTimerRef()}enterIdle(){this.resolvingLoadBalancer.destroy(),this.updateState(Bn.ConnectivityState.IDLE),this.currentPicker=new kN.QueuePicker(this.resolvingLoadBalancer),this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null),this.callRefTimer&&(clearInterval(this.callRefTimer),this.callRefTimer=null)}startIdleTimeout(e){var r,n;this.idleTimer=setTimeout(()=>{if(this.callCount>0){this.startIdleTimeout(this.idleTimeoutMs);return}let o=new Date().valueOf()-this.lastActivityTimestamp.valueOf();o>=this.idleTimeoutMs?(this.trace("Idle timer triggered after "+this.idleTimeoutMs+"ms of inactivity"),this.enterIdle()):this.startIdleTimeout(this.idleTimeoutMs-o)},e),(n=(r=this.idleTimer).unref)===null||n===void 0||n.call(r)}maybeStartIdleTimer(){this.connectivityState!==Bn.ConnectivityState.SHUTDOWN&&!this.idleTimer&&this.startIdleTimeout(this.idleTimeoutMs)}onCallStart(){this.channelzEnabled&&this.channelzInfoTracker.callTracker.addCallStarted(),this.callCount+=1}onCallEnd(e){this.channelzEnabled&&(e.code===va.Status.OK?this.channelzInfoTracker.callTracker.addCallSucceeded():this.channelzInfoTracker.callTracker.addCallFailed()),this.callCount-=1,this.lastActivityTimestamp=new Date,this.maybeStartIdleTimer()}createLoadBalancingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();return this.trace("createLoadBalancingCall ["+s+'] method="'+r+'"'),new ITe.LoadBalancingCall(this,e,r,n,i,o,s)}createRetryingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();return this.trace("createRetryingCall ["+s+'] method="'+r+'"'),new NN.RetryingCall(this,e,r,n,i,o,s,this.retryBufferTracker,Nb.get(this.getTarget()))}createResolvingCall(e,r,n,i,o){let s=(0,ON.getNextCallNumber)();this.trace("createResolvingCall ["+s+'] method="'+e+'", deadline='+(0,CTe.deadlineToString)(r));let a={deadline:r,flags:o??va.Propagate.DEFAULTS,host:n??this.defaultAuthority,parentCall:i},c=new PTe.ResolvingCall(this,e,a,this.filterStackFactory.clone(),s);return this.onCallStart(),c.addStatusWatcher(l=>{this.onCallEnd(l)}),c}close(){var e;this.resolvingLoadBalancer.destroy(),this.updateState(Bn.ConnectivityState.SHUTDOWN),this.currentPicker=new DN;for(let r of this.configSelectionQueue)r.cancelWithStatus(va.Status.UNAVAILABLE,"Channel closed before call started");this.configSelectionQueue=[];for(let r of this.pickQueue)r.cancelWithStatus(va.Status.UNAVAILABLE,"Channel closed before call started");this.pickQueue=[],this.callRefTimer&&clearInterval(this.callRefTimer),this.idleTimer&&clearTimeout(this.idleTimer),this.channelzEnabled&&(0,gg.unregisterChannelzRef)(this.channelzRef),this.subchannelPool.unrefUnusedSubchannels(),(e=this.configSelector)===null||e===void 0||e.unref(),this.configSelector=null}getTarget(){return(0,Ob.uriToString)(this.target)}getConnectivityState(e){let r=this.connectivityState;return e&&(this.resolvingLoadBalancer.exitIdle(),this.lastActivityTimestamp=new Date,this.maybeStartIdleTimer()),r}watchConnectivityState(e,r,n){if(this.connectivityState===Bn.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");let i=null;if(r!==1/0){let s=r instanceof Date?r:new Date(r),a=new Date;if(r===-1/0||s<=a){process.nextTick(n,new Error("Deadline passed without connectivity state change"));return}i=setTimeout(()=>{this.removeConnectivityStateWatcher(o),n(new Error("Deadline passed without connectivity state change"))},s.getTime()-a.getTime())}let o={currentState:e,callback:n,timer:i};this.connectivityStateWatchers.push(o)}getChannelzRef(){return this.channelzRef}createCall(e,r,n,i,o){if(typeof e!="string")throw new TypeError("Channel#createCall: method must be a string");if(!(typeof r=="number"||r instanceof Date))throw new TypeError("Channel#createCall: deadline must be a number or Date");if(this.connectivityState===Bn.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");return this.createResolvingCall(e,r,n,i,o)}getOptions(){return this.options}};dl.InternalChannel=$N});var OP=b(kb=>{"use strict";Object.defineProperty(kb,"__esModule",{value:!0});kb.ChannelImplementation=void 0;var UTe=Wu(),FTe=UN(),FN=class{constructor(e,r,n){if(typeof e!="string")throw new TypeError("Channel target must be a string");if(!(r instanceof UTe.ChannelCredentials))throw new TypeError("Channel credentials must be a ChannelCredentials object");if(n&&typeof n!="object")throw new TypeError("Channel options must be an object");this.internalChannel=new FTe.InternalChannel(e,r,n)}close(){this.internalChannel.close()}getTarget(){return this.internalChannel.getTarget()}getConnectivityState(e){return this.internalChannel.getConnectivityState(e)}watchConnectivityState(e,r,n){this.internalChannel.watchConnectivityState(e,r,n)}getChannelzRef(){return this.internalChannel.getChannelzRef()}createCall(e,r,n,i,o){if(typeof e!="string")throw new TypeError("Channel#createCall: method must be a string");if(!(typeof r=="number"||r instanceof Date))throw new TypeError("Channel#createCall: deadline must be a number or Date");return this.internalChannel.createCall(e,r,n,i,o)}};kb.ChannelImplementation=FN});var L8=b(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.ServerDuplexStreamImpl=gi.ServerWritableStreamImpl=gi.ServerReadableStreamImpl=gi.ServerUnaryCallImpl=void 0;gi.serverErrorToStatus=HN;var BTe=Z("events"),qN=Z("stream"),VN=je(),D8=Wt();function HN(t,e){var r;let n={code:VN.Status.UNKNOWN,details:"message"in t?t.message:"Unknown Error",metadata:(r=e??t.metadata)!==null&&r!==void 0?r:null};return"code"in t&&typeof t.code=="number"&&Number.isInteger(t.code)&&(n.code=t.code,"details"in t&&typeof t.details=="string"&&(n.details=t.details)),n}var BN=class extends BTe.EventEmitter{constructor(e,r,n,i){super(),this.path=e,this.call=r,this.metadata=n,this.request=i,this.cancelled=!1}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}};gi.ServerUnaryCallImpl=BN;var jN=class extends qN.Readable{constructor(e,r,n){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.cancelled=!1}_read(e){this.call.startRead()}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}};gi.ServerReadableStreamImpl=jN;var zN=class extends qN.Writable{constructor(e,r,n,i){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.request=i,this.pendingStatus={code:VN.Status.OK,details:"OK"},this.cancelled=!1,this.trailingMetadata=new D8.Metadata,this.on("error",o=>{this.pendingStatus=HN(o),this.end()})}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}_write(e,r,n){this.call.sendMessage(e,n)}_final(e){var r;e(null),this.call.sendStatus(Object.assign(Object.assign({},this.pendingStatus),{metadata:(r=this.pendingStatus.metadata)!==null&&r!==void 0?r:this.trailingMetadata}))}end(e){return e&&(this.trailingMetadata=e),super.end()}};gi.ServerWritableStreamImpl=zN;var GN=class extends qN.Duplex{constructor(e,r,n){super({objectMode:!0}),this.path=e,this.call=r,this.metadata=n,this.pendingStatus={code:VN.Status.OK,details:"OK"},this.cancelled=!1,this.trailingMetadata=new D8.Metadata,this.on("error",i=>{this.pendingStatus=HN(i),this.end()})}getPeer(){return this.call.getPeer()}sendMetadata(e){this.call.sendMetadata(e)}getDeadline(){return this.call.getDeadline()}getPath(){return this.path}getHost(){return this.call.getHost()}getAuthContext(){return this.call.getAuthContext()}getMetricsRecorder(){return this.call.getMetricsRecorder()}_read(e){this.call.startRead()}_write(e,r,n){this.call.sendMessage(e,n)}_final(e){var r;e(null),this.call.sendStatus(Object.assign(Object.assign({},this.pendingStatus),{metadata:(r=this.pendingStatus.metadata)!==null&&r!==void 0?r:this.trailingMetadata}))}end(e){return e&&(this.trailingMetadata=e),super.end()}};gi.ServerDuplexStreamImpl=GN});var Mb=b(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.ServerCredentials=void 0;Ed.createCertificateProviderServerCredentials=jTe;Ed.createServerCredentialsWithInterceptors=zTe;var WN=Q0(),fl=class{constructor(e,r){this.serverConstructorOptions=e,this.watchers=new Set,this.latestContextOptions=null,this.latestContextOptions=r??null}_addWatcher(e){this.watchers.add(e)}_removeWatcher(e){this.watchers.delete(e)}getWatcherCount(){return this.watchers.size}updateSecureContextOptions(e){this.latestContextOptions=e;for(let r of this.watchers)r(this.latestContextOptions)}_isSecure(){return this.serverConstructorOptions!==null}_getSecureContextOptions(){return this.latestContextOptions}_getConstructorOptions(){return this.serverConstructorOptions}_getInterceptors(){return[]}static createInsecure(){return new YN}static createSsl(e,r,n=!1){var i;if(e!==null&&!Buffer.isBuffer(e))throw new TypeError("rootCerts must be null or a Buffer");if(!Array.isArray(r))throw new TypeError("keyCertPairs must be an array");if(typeof n!="boolean")throw new TypeError("checkClientCertificate must be a boolean");let o=[],s=[];for(let a=0;a<r.length;a++){let c=r[a];if(c===null||typeof c!="object")throw new TypeError(`keyCertPair[${a}] must be an object`);if(!Buffer.isBuffer(c.private_key))throw new TypeError(`keyCertPair[${a}].private_key must be a Buffer`);if(!Buffer.isBuffer(c.cert_chain))throw new TypeError(`keyCertPair[${a}].cert_chain must be a Buffer`);o.push(c.cert_chain),s.push(c.private_key)}return new KN({requestCert:n,ciphers:WN.CIPHER_SUITES},{ca:(i=e??(0,WN.getDefaultRootsData)())!==null&&i!==void 0?i:void 0,cert:o,key:s})}};Ed.ServerCredentials=fl;var YN=class t extends fl{constructor(){super(null)}_getSettings(){return null}_equals(e){return e instanceof t}},KN=class t extends fl{constructor(e,r){super(e,r),this.options=Object.assign(Object.assign({},e),r)}_equals(e){if(this===e)return!0;if(!(e instanceof t))return!1;if(Buffer.isBuffer(this.options.ca)&&Buffer.isBuffer(e.options.ca)){if(!this.options.ca.equals(e.options.ca))return!1}else if(this.options.ca!==e.options.ca)return!1;if(Array.isArray(this.options.cert)&&Array.isArray(e.options.cert)){if(this.options.cert.length!==e.options.cert.length)return!1;for(let r=0;r<this.options.cert.length;r++){let n=this.options.cert[r],i=e.options.cert[r];if(Buffer.isBuffer(n)&&Buffer.isBuffer(i)){if(!n.equals(i))return!1}else if(n!==i)return!1}}else if(this.options.cert!==e.options.cert)return!1;if(Array.isArray(this.options.key)&&Array.isArray(e.options.key)){if(this.options.key.length!==e.options.key.length)return!1;for(let r=0;r<this.options.key.length;r++){let n=this.options.key[r],i=e.options.key[r];if(Buffer.isBuffer(n)&&Buffer.isBuffer(i)){if(!n.equals(i))return!1}else if(n!==i)return!1}}else if(this.options.key!==e.options.key)return!1;return this.options.requestCert===e.options.requestCert}},ZN=class t extends fl{constructor(e,r,n){super({requestCert:r!==null,rejectUnauthorized:n,ciphers:WN.CIPHER_SUITES}),this.identityCertificateProvider=e,this.caCertificateProvider=r,this.requireClientCertificate=n,this.latestCaUpdate=null,this.latestIdentityUpdate=null,this.caCertificateUpdateListener=this.handleCaCertificateUpdate.bind(this),this.identityCertificateUpdateListener=this.handleIdentityCertitificateUpdate.bind(this)}_addWatcher(e){var r;this.getWatcherCount()===0&&((r=this.caCertificateProvider)===null||r===void 0||r.addCaCertificateListener(this.caCertificateUpdateListener),this.identityCertificateProvider.addIdentityCertificateListener(this.identityCertificateUpdateListener)),super._addWatcher(e)}_removeWatcher(e){var r;super._removeWatcher(e),this.getWatcherCount()===0&&((r=this.caCertificateProvider)===null||r===void 0||r.removeCaCertificateListener(this.caCertificateUpdateListener),this.identityCertificateProvider.removeIdentityCertificateListener(this.identityCertificateUpdateListener))}_equals(e){return this===e?!0:e instanceof t?this.caCertificateProvider===e.caCertificateProvider&&this.identityCertificateProvider===e.identityCertificateProvider&&this.requireClientCertificate===e.requireClientCertificate:!1}calculateSecureContextOptions(){var e;return this.latestIdentityUpdate===null||this.caCertificateProvider!==null&&this.latestCaUpdate===null?null:{ca:(e=this.latestCaUpdate)===null||e===void 0?void 0:e.caCertificate,cert:[this.latestIdentityUpdate.certificate],key:[this.latestIdentityUpdate.privateKey]}}finalizeUpdate(){let e=this.calculateSecureContextOptions();this.updateSecureContextOptions(e)}handleCaCertificateUpdate(e){this.latestCaUpdate=e,this.finalizeUpdate()}handleIdentityCertitificateUpdate(e){this.latestIdentityUpdate=e,this.finalizeUpdate()}};function jTe(t,e,r){return new ZN(t,e,r)}var JN=class t extends fl{constructor(e,r){super({}),this.childCredentials=e,this.interceptors=r}_isSecure(){return this.childCredentials._isSecure()}_equals(e){if(!(e instanceof t)||!this.childCredentials._equals(e.childCredentials)||this.interceptors.length!==e.interceptors.length)return!1;for(let r=0;r<this.interceptors.length;r++)if(this.interceptors[r]!==e.interceptors[r])return!1;return!0}_getInterceptors(){return this.interceptors}_addWatcher(e){this.childCredentials._addWatcher(e)}_removeWatcher(e){this.childCredentials._removeWatcher(e)}_getConstructorOptions(){return this.childCredentials._getConstructorOptions()}_getSecureContextOptions(){return this.childCredentials._getSecureContextOptions()}};function zTe(t,e){return new JN(t,e)}});var _g=b(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.durationMessageToDuration=GTe;is.msToDuration=qTe;is.durationToMs=VTe;is.isDuration=HTe;is.isDurationMessage=WTe;is.parseDuration=KTe;is.durationToString=ZTe;function GTe(t){return{seconds:Number.parseInt(t.seconds),nanos:t.nanos}}function qTe(t){return{seconds:t/1e3|0,nanos:t%1e3*1e6|0}}function VTe(t){return t.seconds*1e3+t.nanos/1e6|0}function HTe(t){return typeof t.seconds=="number"&&typeof t.nanos=="number"}function WTe(t){return typeof t.seconds=="string"&&typeof t.nanos=="number"}var YTe=/^(\d+)(?:\.(\d+))?s$/;function KTe(t){let e=t.match(YTe);return e?{seconds:Number.parseInt(e[1],10),nanos:e[2]?Number.parseInt(e[2].padEnd(9,"0"),10):0}:null}function ZTe(t){if(t.nanos===0)return`${t.seconds}s`;let e;return t.nanos%1e6===0?e=1e6:t.nanos%1e3===0?e=1e3:e=1,`${t.seconds}.${t.nanos/e}s`}});var Lb=b(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.OrcaOobMetricsSubchannelWrapper=hn.GRPC_METRICS_HEADER=hn.ServerMetricRecorder=hn.PerRequestMetricRecorder=void 0;hn.createOrcaClient=B8;hn.createMetricsReader=nxe;var JTe=wv(),XN=_g(),XTe=Wu(),QTe=mg(),$8=je(),exe=Yu(),txe=Ir(),U8=null;function Db(){if(U8)return U8;let t=FO().loadSync,e=t("xds/service/orca/v3/orca.proto",{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0,includeDirs:[`${__dirname}/../../proto/xds`,`${__dirname}/../../proto/protoc-gen-validate`]});return(0,JTe.loadPackageDefinition)(e)}var QN=class{constructor(){this.message={}}recordRequestCostMetric(e,r){this.message.request_cost||(this.message.request_cost={}),this.message.request_cost[e]=r}recordUtilizationMetric(e,r){this.message.utilization||(this.message.utilization={}),this.message.utilization[e]=r}recordNamedMetric(e,r){this.message.named_metrics||(this.message.named_metrics={}),this.message.named_metrics[e]=r}recordCPUUtilizationMetric(e){this.message.cpu_utilization=e}recordMemoryUtilizationMetric(e){this.message.mem_utilization=e}recordApplicationUtilizationMetric(e){this.message.application_utilization=e}recordQpsMetric(e){this.message.rps_fractional=e}recordEpsMetric(e){this.message.eps=e}serialize(){return Db().xds.data.orca.v3.OrcaLoadReport.serialize(this.message)}};hn.PerRequestMetricRecorder=QN;var rxe=3e4,ek=class{constructor(){this.message={},this.serviceImplementation={StreamCoreMetrics:e=>{let r=e.request.report_interval?(0,XN.durationToMs)((0,XN.durationMessageToDuration)(e.request.report_interval)):rxe,n=setInterval(()=>{e.write(this.message)},r);e.on("cancelled",()=>{clearInterval(n)})}}}putUtilizationMetric(e,r){this.message.utilization||(this.message.utilization={}),this.message.utilization[e]=r}setAllUtilizationMetrics(e){this.message.utilization=Object.assign({},e)}deleteUtilizationMetric(e){var r;(r=this.message.utilization)===null||r===void 0||delete r[e]}setCpuUtilizationMetric(e){this.message.cpu_utilization=e}deleteCpuUtilizationMetric(){delete this.message.cpu_utilization}setApplicationUtilizationMetric(e){this.message.application_utilization=e}deleteApplicationUtilizationMetric(){delete this.message.application_utilization}setQpsMetric(e){this.message.rps_fractional=e}deleteQpsMetric(){delete this.message.rps_fractional}setEpsMetric(e){this.message.eps=e}deleteEpsMetric(){delete this.message.eps}addToServer(e){let r=Db().xds.service.orca.v3.OpenRcaService.service;e.addService(r,this.serviceImplementation)}};hn.ServerMetricRecorder=ek;function B8(t){let e=Db().xds.service.orca.v3.OpenRcaService;return new e("unused",XTe.ChannelCredentials.createInsecure(),{channelOverride:t})}hn.GRPC_METRICS_HEADER="endpoint-load-metrics-bin";var F8="grpc_orca_load_report";function nxe(t,e){return(r,n,i)=>{let o=i.getOpaque(F8);if(o)t(o);else{let s=i.get(hn.GRPC_METRICS_HEADER);s.length>0&&(o=Db().xds.data.orca.v3.OrcaLoadReport.deserialize(s[0]),t(o),i.setOpaque(F8,o))}e&&e(r,n,i)}}var j8="orca_oob_metrics",tk=class{constructor(e,r){this.metricsListener=e,this.intervalMs=r,this.dataProducer=null}setSubchannel(e){let r=e.getOrCreateDataProducer(j8,ixe);this.dataProducer=r,r.addDataWatcher(this)}destroy(){var e;(e=this.dataProducer)===null||e===void 0||e.removeDataWatcher(this)}getInterval(){return this.intervalMs}onMetricsUpdate(e){this.metricsListener(e)}},rk=class{constructor(e){this.subchannel=e,this.dataWatchers=new Set,this.orcaSupported=!0,this.metricsCall=null,this.currentInterval=1/0,this.backoffTimer=new exe.BackoffTimeout(()=>this.updateMetricsSubscription()),this.subchannelStateListener=()=>this.updateMetricsSubscription();let r=e.getChannel();this.client=B8(r),e.addConnectivityStateListener(this.subchannelStateListener)}addDataWatcher(e){this.dataWatchers.add(e),this.updateMetricsSubscription()}removeDataWatcher(e){var r;this.dataWatchers.delete(e),this.dataWatchers.size===0?(this.subchannel.removeDataProducer(j8),(r=this.metricsCall)===null||r===void 0||r.cancel(),this.metricsCall=null,this.client.close(),this.subchannel.removeConnectivityStateListener(this.subchannelStateListener)):this.updateMetricsSubscription()}updateMetricsSubscription(){var e;if(this.dataWatchers.size===0||!this.orcaSupported||this.subchannel.getConnectivityState()!==txe.ConnectivityState.READY)return;let r=Math.min(...Array.from(this.dataWatchers).map(n=>n.getInterval()));if(!this.metricsCall||r!==this.currentInterval){(e=this.metricsCall)===null||e===void 0||e.cancel(),this.currentInterval=r;let n=this.client.streamCoreMetrics({report_interval:(0,XN.msToDuration)(r)});this.metricsCall=n,n.on("data",i=>{this.dataWatchers.forEach(o=>{o.onMetricsUpdate(i)})}),n.on("error",i=>{if(this.metricsCall=null,i.code===$8.Status.UNIMPLEMENTED){this.orcaSupported=!1;return}i.code!==$8.Status.CANCELLED&&this.backoffTimer.runOnce()})}}},nk=class extends QTe.BaseSubchannelWrapper{constructor(e,r,n){super(e),this.addDataWatcher(new tk(r,n))}getWrappedSubchannel(){return this.child}};hn.OrcaOobMetricsSubchannelWrapper=nk;function ixe(t){return new rk(t)}});var uk=b(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.BaseServerInterceptingCall=jn.ServerInterceptingCall=jn.ResponderBuilder=jn.ServerListenerBuilder=void 0;jn.isInterceptingServerListener=axe;jn.getServerInterceptingCall=fxe;var Fb=Wt(),Pr=je(),vd=Z("http2"),z8=tv(),G8=Z("zlib"),oxe=gN(),Y8=st(),sxe=Z("tls"),q8=Lb(),K8="server_call";function pl(t){Y8.trace(Pr.LogVerbosity.DEBUG,K8,t)}var ok=class{constructor(){this.metadata=void 0,this.message=void 0,this.halfClose=void 0,this.cancel=void 0}withOnReceiveMetadata(e){return this.metadata=e,this}withOnReceiveMessage(e){return this.message=e,this}withOnReceiveHalfClose(e){return this.halfClose=e,this}withOnCancel(e){return this.cancel=e,this}build(){return{onReceiveMetadata:this.metadata,onReceiveMessage:this.message,onReceiveHalfClose:this.halfClose,onCancel:this.cancel}}};jn.ServerListenerBuilder=ok;function axe(t){return t.onReceiveMetadata!==void 0&&t.onReceiveMetadata.length===1}var sk=class{constructor(e,r){this.listener=e,this.nextListener=r,this.cancelled=!1,this.processingMetadata=!1,this.hasPendingMessage=!1,this.pendingMessage=null,this.processingMessage=!1,this.hasPendingHalfClose=!1}processPendingMessage(){this.hasPendingMessage&&(this.nextListener.onReceiveMessage(this.pendingMessage),this.pendingMessage=null,this.hasPendingMessage=!1)}processPendingHalfClose(){this.hasPendingHalfClose&&(this.nextListener.onReceiveHalfClose(),this.hasPendingHalfClose=!1)}onReceiveMetadata(e){this.cancelled||(this.processingMetadata=!0,this.listener.onReceiveMetadata(e,r=>{this.processingMetadata=!1,!this.cancelled&&(this.nextListener.onReceiveMetadata(r),this.processPendingMessage(),this.processPendingHalfClose())}))}onReceiveMessage(e){this.cancelled||(this.processingMessage=!0,this.listener.onReceiveMessage(e,r=>{this.processingMessage=!1,!this.cancelled&&(this.processingMetadata?(this.pendingMessage=r,this.hasPendingMessage=!0):(this.nextListener.onReceiveMessage(r),this.processPendingHalfClose()))}))}onReceiveHalfClose(){this.cancelled||this.listener.onReceiveHalfClose(()=>{this.cancelled||(this.processingMetadata||this.processingMessage?this.hasPendingHalfClose=!0:this.nextListener.onReceiveHalfClose())})}onCancel(){this.cancelled=!0,this.listener.onCancel(),this.nextListener.onCancel()}},ak=class{constructor(){this.start=void 0,this.metadata=void 0,this.message=void 0,this.status=void 0}withStart(e){return this.start=e,this}withSendMetadata(e){return this.metadata=e,this}withSendMessage(e){return this.message=e,this}withSendStatus(e){return this.status=e,this}build(){return{start:this.start,sendMetadata:this.metadata,sendMessage:this.message,sendStatus:this.status}}};jn.ResponderBuilder=ak;var $b={onReceiveMetadata:(t,e)=>{e(t)},onReceiveMessage:(t,e)=>{e(t)},onReceiveHalfClose:t=>{t()},onCancel:()=>{}},Ub={start:t=>{t()},sendMetadata:(t,e)=>{e(t)},sendMessage:(t,e)=>{e(t)},sendStatus:(t,e)=>{e(t)}},ck=class{constructor(e,r){var n,i,o,s;this.nextCall=e,this.processingMetadata=!1,this.sentMetadata=!1,this.processingMessage=!1,this.pendingMessage=null,this.pendingMessageCallback=null,this.pendingStatus=null,this.responder={start:(n=r?.start)!==null&&n!==void 0?n:Ub.start,sendMetadata:(i=r?.sendMetadata)!==null&&i!==void 0?i:Ub.sendMetadata,sendMessage:(o=r?.sendMessage)!==null&&o!==void 0?o:Ub.sendMessage,sendStatus:(s=r?.sendStatus)!==null&&s!==void 0?s:Ub.sendStatus}}processPendingMessage(){this.pendingMessageCallback&&(this.nextCall.sendMessage(this.pendingMessage,this.pendingMessageCallback),this.pendingMessage=null,this.pendingMessageCallback=null)}processPendingStatus(){this.pendingStatus&&(this.nextCall.sendStatus(this.pendingStatus),this.pendingStatus=null)}start(e){this.responder.start(r=>{var n,i,o,s;let a={onReceiveMetadata:(n=r?.onReceiveMetadata)!==null&&n!==void 0?n:$b.onReceiveMetadata,onReceiveMessage:(i=r?.onReceiveMessage)!==null&&i!==void 0?i:$b.onReceiveMessage,onReceiveHalfClose:(o=r?.onReceiveHalfClose)!==null&&o!==void 0?o:$b.onReceiveHalfClose,onCancel:(s=r?.onCancel)!==null&&s!==void 0?s:$b.onCancel},c=new sk(a,e);this.nextCall.start(c)})}sendMetadata(e){this.processingMetadata=!0,this.sentMetadata=!0,this.responder.sendMetadata(e,r=>{this.processingMetadata=!1,this.nextCall.sendMetadata(r),this.processPendingMessage(),this.processPendingStatus()})}sendMessage(e,r){this.processingMessage=!0,this.sentMetadata||this.sendMetadata(new Fb.Metadata),this.responder.sendMessage(e,n=>{this.processingMessage=!1,this.processingMetadata?(this.pendingMessage=n,this.pendingMessageCallback=r):this.nextCall.sendMessage(n,r)})}sendStatus(e){this.responder.sendStatus(e,r=>{this.processingMetadata||this.processingMessage?this.pendingStatus=r:this.nextCall.sendStatus(r)})}startRead(){this.nextCall.startRead()}getPeer(){return this.nextCall.getPeer()}getDeadline(){return this.nextCall.getDeadline()}getHost(){return this.nextCall.getHost()}getAuthContext(){return this.nextCall.getAuthContext()}getConnectionInfo(){return this.nextCall.getConnectionInfo()}getMetricsRecorder(){return this.nextCall.getMetricsRecorder()}};jn.ServerInterceptingCall=ck;var Z8="grpc-accept-encoding",lk="grpc-encoding",V8="grpc-message",H8="grpc-status",ik="grpc-timeout",cxe=/(\d{1,8})\s*([HMSmun])/,lxe={H:36e5,M:6e4,S:1e3,m:1,u:.001,n:1e-6},uxe={[Z8]:"identity,deflate,gzip",[lk]:"identity"},W8={[vd.constants.HTTP2_HEADER_STATUS]:vd.constants.HTTP_STATUS_OK,[vd.constants.HTTP2_HEADER_CONTENT_TYPE]:"application/grpc+proto"},dxe={waitForTrailers:!0},Bb=class{constructor(e,r,n,i,o){var s,a;this.stream=e,this.callEventTracker=n,this.handler=i,this.listener=null,this.deadlineTimer=null,this.deadline=1/0,this.maxSendMessageSize=Pr.DEFAULT_MAX_SEND_MESSAGE_LENGTH,this.maxReceiveMessageSize=Pr.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH,this.cancelled=!1,this.metadataSent=!1,this.wantTrailers=!1,this.cancelNotified=!1,this.incomingEncoding="identity",this.readQueue=[],this.isReadPending=!1,this.receivedHalfClose=!1,this.streamEnded=!1,this.metricsRecorder=new q8.PerRequestMetricRecorder,this.stream.once("close",()=>{var f;pl("Request to method "+((f=this.handler)===null||f===void 0?void 0:f.path)+" stream closed with rstCode "+this.stream.rstCode),this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!1),this.callEventTracker.onCallEnd({code:Pr.Status.CANCELLED,details:"Stream closed before sending status",metadata:null})),this.notifyOnCancel()}),this.stream.on("data",f=>{this.handleDataFrame(f)}),this.stream.pause(),this.stream.on("end",()=>{this.handleEndEvent()}),"grpc.max_send_message_length"in o&&(this.maxSendMessageSize=o["grpc.max_send_message_length"]),"grpc.max_receive_message_length"in o&&(this.maxReceiveMessageSize=o["grpc.max_receive_message_length"]),this.host=(s=r[":authority"])!==null&&s!==void 0?s:r.host,this.decoder=new oxe.StreamDecoder(this.maxReceiveMessageSize);let c=Fb.Metadata.fromHttp2Headers(r);Y8.isTracerEnabled(K8)&&pl("Request to "+this.handler.path+" received headers "+JSON.stringify(c.toJSON()));let l=c.get(ik);l.length>0&&this.handleTimeoutHeader(l[0]);let u=c.get(lk);u.length>0&&(this.incomingEncoding=u[0]),c.remove(ik),c.remove(lk),c.remove(Z8),c.remove(vd.constants.HTTP2_HEADER_ACCEPT_ENCODING),c.remove(vd.constants.HTTP2_HEADER_TE),c.remove(vd.constants.HTTP2_HEADER_CONTENT_TYPE),this.metadata=c;let d=(a=e.session)===null||a===void 0?void 0:a.socket;this.connectionInfo={localAddress:d?.localAddress,localPort:d?.localPort,remoteAddress:d?.remoteAddress,remotePort:d?.remotePort},this.shouldSendMetrics=!!o["grpc.server_call_metric_recording"]}handleTimeoutHeader(e){let r=e.toString().match(cxe);if(r===null){let o={code:Pr.Status.INTERNAL,details:`Invalid ${ik} value "${e}"`,metadata:null};process.nextTick(()=>{this.sendStatus(o)});return}let n=+r[1]*lxe[r[2]]|0,i=new Date;this.deadline=i.setMilliseconds(i.getMilliseconds()+n),this.deadlineTimer=setTimeout(()=>{let o={code:Pr.Status.DEADLINE_EXCEEDED,details:"Deadline exceeded",metadata:null};this.sendStatus(o)},n)}checkCancelled(){return!this.cancelled&&(this.stream.destroyed||this.stream.closed)&&(this.notifyOnCancel(),this.cancelled=!0),this.cancelled}notifyOnCancel(){this.cancelNotified||(this.cancelNotified=!0,this.cancelled=!0,process.nextTick(()=>{var e;(e=this.listener)===null||e===void 0||e.onCancel()}),this.deadlineTimer&&clearTimeout(this.deadlineTimer),this.stream.resume())}maybeSendMetadata(){this.metadataSent||this.sendMetadata(new Fb.Metadata)}serializeMessage(e){let r=this.handler.serialize(e),n=r.byteLength,i=Buffer.allocUnsafe(n+5);return i.writeUInt8(0,0),i.writeUInt32BE(n,1),r.copy(i,5),i}decompressMessage(e,r){let n=e.subarray(5);if(r==="identity")return n;if(r==="deflate"||r==="gzip"){let i;return r==="deflate"?i=G8.createInflate():i=G8.createGunzip(),new Promise((o,s)=>{let a=0,c=[];i.on("error",l=>{s({code:Pr.Status.INTERNAL,details:"Failed to decompress message"})}),i.on("data",l=>{c.push(l),a+=l.byteLength,this.maxReceiveMessageSize!==-1&&a>this.maxReceiveMessageSize&&(i.destroy(),s({code:Pr.Status.RESOURCE_EXHAUSTED,details:`Received message that decompresses to a size larger than ${this.maxReceiveMessageSize}`}))}),i.on("end",()=>{o(Buffer.concat(c))}),i.write(n),i.end()})}else return Promise.reject({code:Pr.Status.UNIMPLEMENTED,details:`Received message compressed with unsupported encoding "${r}"`})}async decompressAndMaybePush(e){if(e.type!=="COMPRESSED")throw new Error(`Invalid queue entry type: ${e.type}`);let n=e.compressedMessage.readUInt8(0)===1?this.incomingEncoding:"identity",i;try{i=await this.decompressMessage(e.compressedMessage,n)}catch(o){this.sendStatus(o);return}try{e.parsedMessage=this.handler.deserialize(i)}catch(o){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error deserializing request: ${o.message}`});return}e.type="READABLE",this.maybePushNextMessage()}maybePushNextMessage(){if(this.listener&&this.isReadPending&&this.readQueue.length>0&&this.readQueue[0].type!=="COMPRESSED"){this.isReadPending=!1;let e=this.readQueue.shift();e.type==="READABLE"?this.listener.onReceiveMessage(e.parsedMessage):this.listener.onReceiveHalfClose()}}handleDataFrame(e){var r;if(this.checkCancelled())return;pl("Request to "+this.handler.path+" received data frame of size "+e.length);let n;try{n=this.decoder.write(e)}catch(i){this.sendStatus({code:Pr.Status.RESOURCE_EXHAUSTED,details:i.message});return}for(let i of n){this.stream.pause();let o={type:"COMPRESSED",compressedMessage:i,parsedMessage:null};this.readQueue.push(o),this.decompressAndMaybePush(o),(r=this.callEventTracker)===null||r===void 0||r.addMessageReceived()}}handleEndEvent(){this.readQueue.push({type:"HALF_CLOSE",compressedMessage:null,parsedMessage:null}),this.receivedHalfClose=!0,this.maybePushNextMessage()}start(e){pl("Request to "+this.handler.path+" start called"),!this.checkCancelled()&&(this.listener=e,e.onReceiveMetadata(this.metadata))}sendMetadata(e){if(this.checkCancelled()||this.metadataSent)return;this.metadataSent=!0;let r=e?e.toHttp2Headers():null,n=Object.assign(Object.assign(Object.assign({},W8),uxe),r);this.stream.respond(n,dxe)}sendMessage(e,r){if(this.checkCancelled())return;let n;try{n=this.serializeMessage(e)}catch(i){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error serializing response: ${(0,z8.getErrorMessage)(i)}`,metadata:null});return}if(this.maxSendMessageSize!==-1&&n.length-5>this.maxSendMessageSize){this.sendStatus({code:Pr.Status.RESOURCE_EXHAUSTED,details:`Sent message larger than max (${n.length} vs. ${this.maxSendMessageSize})`,metadata:null});return}this.maybeSendMetadata(),pl("Request to "+this.handler.path+" sent data frame of size "+n.length),this.stream.write(n,i=>{var o;if(i){this.sendStatus({code:Pr.Status.INTERNAL,details:`Error writing message: ${(0,z8.getErrorMessage)(i)}`,metadata:null});return}(o=this.callEventTracker)===null||o===void 0||o.addMessageSent(),r()})}sendStatus(e){var r,n,i;if(this.checkCancelled())return;pl("Request to method "+((r=this.handler)===null||r===void 0?void 0:r.path)+" ended with status code: "+Pr.Status[e.code]+" details: "+e.details);let o=(i=(n=e.metadata)===null||n===void 0?void 0:n.clone())!==null&&i!==void 0?i:new Fb.Metadata;if(this.shouldSendMetrics&&o.set(q8.GRPC_METRICS_HEADER,this.metricsRecorder.serialize()),this.metadataSent)this.wantTrailers?this.notifyOnCancel():(this.wantTrailers=!0,this.stream.once("wantTrailers",()=>{this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!0),this.callEventTracker.onCallEnd(e));let s=Object.assign({[H8]:e.code,[V8]:encodeURI(e.details)},o.toHttp2Headers());this.stream.sendTrailers(s),this.notifyOnCancel()}),this.stream.end());else{this.callEventTracker&&!this.streamEnded&&(this.streamEnded=!0,this.callEventTracker.onStreamEnd(!0),this.callEventTracker.onCallEnd(e));let s=Object.assign(Object.assign({[H8]:e.code,[V8]:encodeURI(e.details)},W8),o.toHttp2Headers());this.stream.respond(s,{endStream:!0}),this.notifyOnCancel()}}startRead(){pl("Request to "+this.handler.path+" startRead called"),!this.checkCancelled()&&(this.isReadPending=!0,this.readQueue.length===0?this.receivedHalfClose||this.stream.resume():this.maybePushNextMessage())}getPeer(){var e;let r=(e=this.stream.session)===null||e===void 0?void 0:e.socket;return r?.remoteAddress?r.remotePort?`${r.remoteAddress}:${r.remotePort}`:r.remoteAddress:"unknown"}getDeadline(){return this.deadline}getHost(){return this.host}getAuthContext(){var e;if(((e=this.stream.session)===null||e===void 0?void 0:e.socket)instanceof sxe.TLSSocket){let r=this.stream.session.socket.getPeerCertificate();return{transportSecurityType:"ssl",sslPeerCertificate:r.raw?r:void 0}}else return{}}getConnectionInfo(){return this.connectionInfo}getMetricsRecorder(){return this.metricsRecorder}};jn.BaseServerInterceptingCall=Bb;function fxe(t,e,r,n,i,o){let s={path:i.path,requestStream:i.type==="clientStream"||i.type==="bidi",responseStream:i.type==="serverStream"||i.type==="bidi",requestDeserialize:i.deserialize,responseSerialize:i.serialize},a=new Bb(e,r,n,i,o);return t.reduce((c,l)=>l(s,c),a)}});var nK=b(Ta=>{"use strict";var pxe=Ta&&Ta.__runInitializers||function(t,e,r){for(var n=arguments.length>2,i=0;i<e.length;i++)r=n?e[i].call(t,r):e[i].call(t);return n?r:void 0},hxe=Ta&&Ta.__esDecorate||function(t,e,r,n,i,o){function s(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&t?n.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),d,f=!1,p=r.length-1;p>=0;p--){var h={};for(var m in n)h[m]=m==="access"?{}:n[m];for(var m in n.access)h.access[m]=n.access[m];h.addInitializer=function(S){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(S||null))};var y=(0,r[p])(a==="accessor"?{get:u.get,set:u.set}:u[c],h);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(d=s(y.get))&&(u.get=d),(d=s(y.set))&&(u.set=d),(d=s(y.init))&&i.unshift(d)}else(d=s(y))&&(a==="field"?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,n.name,u),f=!0};Object.defineProperty(Ta,"__esModule",{value:!0});Ta.Server=void 0;var qr=Z("http2"),mxe=Z("util"),Rt=je(),xd=L8(),dk=Mb(),J8=ni(),Td=st(),ba=zr(),_i=Rr(),Ft=_a(),X8=uk(),bd=~(1<<31),fk=~(1<<31),gxe=2e4,Q8=~(1<<31),{HTTP2_HEADER_PATH:eK}=qr.constants,_xe="server",tK=Buffer.from("max_age");function rK(t){Td.trace(Rt.LogVerbosity.DEBUG,"server_call",t)}function yxe(){}function Sxe(t){return function(e,r){return mxe.deprecate(e,t)}}function pk(t){return{code:Rt.Status.UNIMPLEMENTED,details:`The server does not implement the method ${t}`}}function Exe(t,e){let r=pk(e);switch(t){case"unary":return(n,i)=>{i(r,null)};case"clientStream":return(n,i)=>{i(r,null)};case"serverStream":return n=>{n.emit("error",r)};case"bidi":return n=>{n.emit("error",r)};default:throw new Error(`Invalid handlerType ${t}`)}}var vxe=(()=>{var t;let e=[],r;return t=class{constructor(i){var o,s,a,c,l,u;this.boundPorts=(pxe(this,e),new Map),this.http2Servers=new Map,this.sessionIdleTimeouts=new Map,this.handlers=new Map,this.sessions=new Map,this.started=!1,this.shutdown=!1,this.serverAddressString="null",this.channelzEnabled=!0,this.options=i??{},this.options["grpc.enable_channelz"]===0?(this.channelzEnabled=!1,this.channelzTrace=new Ft.ChannelzTraceStub,this.callTracker=new Ft.ChannelzCallTrackerStub,this.listenerChildrenTracker=new Ft.ChannelzChildrenTrackerStub,this.sessionChildrenTracker=new Ft.ChannelzChildrenTrackerStub):(this.channelzTrace=new Ft.ChannelzTrace,this.callTracker=new Ft.ChannelzCallTracker,this.listenerChildrenTracker=new Ft.ChannelzChildrenTracker,this.sessionChildrenTracker=new Ft.ChannelzChildrenTracker),this.channelzRef=(0,Ft.registerChannelzServer)("server",()=>this.getChannelzInfo(),this.channelzEnabled),this.channelzTrace.addTrace("CT_INFO","Server created"),this.maxConnectionAgeMs=(o=this.options["grpc.max_connection_age_ms"])!==null&&o!==void 0?o:bd,this.maxConnectionAgeGraceMs=(s=this.options["grpc.max_connection_age_grace_ms"])!==null&&s!==void 0?s:bd,this.keepaliveTimeMs=(a=this.options["grpc.keepalive_time_ms"])!==null&&a!==void 0?a:fk,this.keepaliveTimeoutMs=(c=this.options["grpc.keepalive_timeout_ms"])!==null&&c!==void 0?c:gxe,this.sessionIdleTimeout=(l=this.options["grpc.max_connection_idle_ms"])!==null&&l!==void 0?l:Q8,this.commonServerOptions={maxSendHeaderBlockLength:Number.MAX_SAFE_INTEGER},"grpc-node.max_session_memory"in this.options?this.commonServerOptions.maxSessionMemory=this.options["grpc-node.max_session_memory"]:this.commonServerOptions.maxSessionMemory=Number.MAX_SAFE_INTEGER,"grpc.max_concurrent_streams"in this.options&&(this.commonServerOptions.settings={maxConcurrentStreams:this.options["grpc.max_concurrent_streams"]}),this.interceptors=(u=this.options.interceptors)!==null&&u!==void 0?u:[],this.trace("Server constructed")}getChannelzInfo(){return{trace:this.channelzTrace,callTracker:this.callTracker,listenerChildren:this.listenerChildrenTracker.getChildLists(),sessionChildren:this.sessionChildrenTracker.getChildLists()}}getChannelzSessionInfo(i){var o,s,a;let c=this.sessions.get(i),l=i.socket,u=l.remoteAddress?(0,ba.stringToSubchannelAddress)(l.remoteAddress,l.remotePort):null,d=l.localAddress?(0,ba.stringToSubchannelAddress)(l.localAddress,l.localPort):null,f;if(i.encrypted){let h=l,m=h.getCipher(),y=h.getCertificate(),S=h.getPeerCertificate();f={cipherSuiteStandardName:(o=m.standardName)!==null&&o!==void 0?o:null,cipherSuiteOtherName:m.standardName?null:m.name,localCertificate:y&&"raw"in y?y.raw:null,remoteCertificate:S&&"raw"in S?S.raw:null}}else f=null;return{remoteAddress:u,localAddress:d,security:f,remoteName:null,streamsStarted:c.streamTracker.callsStarted,streamsSucceeded:c.streamTracker.callsSucceeded,streamsFailed:c.streamTracker.callsFailed,messagesSent:c.messagesSent,messagesReceived:c.messagesReceived,keepAlivesSent:c.keepAlivesSent,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:c.streamTracker.lastCallStartedTimestamp,lastMessageSentTimestamp:c.lastMessageSentTimestamp,lastMessageReceivedTimestamp:c.lastMessageReceivedTimestamp,localFlowControlWindow:(s=i.state.localWindowSize)!==null&&s!==void 0?s:null,remoteFlowControlWindow:(a=i.state.remoteWindowSize)!==null&&a!==void 0?a:null}}trace(i){Td.trace(Rt.LogVerbosity.DEBUG,_xe,"("+this.channelzRef.id+") "+i)}keepaliveTrace(i){Td.trace(Rt.LogVerbosity.DEBUG,"keepalive","("+this.channelzRef.id+") "+i)}addProtoService(){throw new Error("Not implemented. Use addService() instead")}addService(i,o){if(i===null||typeof i!="object"||o===null||typeof o!="object")throw new Error("addService() requires two objects as arguments");let s=Object.keys(i);if(s.length===0)throw new Error("Cannot add an empty service to a server");s.forEach(a=>{let c=i[a],l;c.requestStream?c.responseStream?l="bidi":l="clientStream":c.responseStream?l="serverStream":l="unary";let u=o[a],d;if(u===void 0&&typeof c.originalName=="string"&&(u=o[c.originalName]),u!==void 0?d=u.bind(o):d=Exe(l,a),this.register(c.path,d,c.responseSerialize,c.requestDeserialize,l)===!1)throw new Error(`Method handler for ${c.path} already provided.`)})}removeService(i){if(i===null||typeof i!="object")throw new Error("removeService() requires object as argument");Object.keys(i).forEach(s=>{let a=i[s];this.unregister(a.path)})}bind(i,o){throw new Error("Not implemented. Use bindAsync() instead")}experimentalRegisterListenerToChannelz(i){return(0,Ft.registerChannelzSocket)((0,ba.subchannelAddressToString)(i),()=>({localAddress:i,remoteAddress:null,security:null,remoteName:null,streamsStarted:0,streamsSucceeded:0,streamsFailed:0,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:null,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null,localFlowControlWindow:null,remoteFlowControlWindow:null}),this.channelzEnabled)}experimentalUnregisterListenerFromChannelz(i){(0,Ft.unregisterChannelzRef)(i)}createHttp2Server(i){let o;if(i._isSecure()){let s=i._getConstructorOptions(),a=i._getSecureContextOptions(),c=Object.assign(Object.assign(Object.assign(Object.assign({},this.commonServerOptions),s),a),{enableTrace:this.options["grpc-node.tls_enable_trace"]===1}),l=a!==null;this.trace("Initial credentials valid: "+l),o=qr.createSecureServer(c),o.prependListener("connection",d=>{l||(this.trace("Dropped connection from "+JSON.stringify(d.address())+" due to unloaded credentials"),d.destroy())}),o.on("secureConnection",d=>{d.on("error",f=>{this.trace("An incoming TLS connection closed with error: "+f.message)})});let u=d=>{if(d){let f=o;try{f.setSecureContext(d)}catch(p){Td.log(Rt.LogVerbosity.ERROR,"Failed to set secure context with error "+p.message),d=null}}l=d!==null,this.trace("Post-update credentials valid: "+l)};i._addWatcher(u),o.on("close",()=>{i._removeWatcher(u)})}else o=qr.createServer(this.commonServerOptions);return o.setTimeout(0,yxe),this._setupHandlers(o,i._getInterceptors()),o}bindOneAddress(i,o){this.trace("Attempting to bind "+(0,ba.subchannelAddressToString)(i));let s=this.createHttp2Server(o.credentials);return new Promise((a,c)=>{let l=u=>{this.trace("Failed to bind "+(0,ba.subchannelAddressToString)(i)+" with error "+u.message),a({port:"port"in i?i.port:1,error:u.message})};s.once("error",l),s.listen(i,()=>{let u=s.address(),d;typeof u=="string"?d={path:u}:d={host:u.address,port:u.port};let f=this.experimentalRegisterListenerToChannelz(d);this.listenerChildrenTracker.refChild(f),this.http2Servers.set(s,{channelzRef:f,sessions:new Set,ownsChannelzRef:!0}),o.listeningServers.add(s),this.trace("Successfully bound "+(0,ba.subchannelAddressToString)(d)),a({port:"port"in d?d.port:1}),s.removeListener("error",l)})})}async bindManyPorts(i,o){if(i.length===0)return{count:0,port:0,errors:[]};if((0,ba.isTcpSubchannelAddress)(i[0])&&i[0].port===0){let s=await this.bindOneAddress(i[0],o);if(s.error){let a=await this.bindManyPorts(i.slice(1),o);return Object.assign(Object.assign({},a),{errors:[s.error,...a.errors]})}else{let a=i.slice(1).map(u=>(0,ba.isTcpSubchannelAddress)(u)?{host:u.host,port:s.port}:u),c=await Promise.all(a.map(u=>this.bindOneAddress(u,o))),l=[s,...c];return{count:l.filter(u=>u.error===void 0).length,port:s.port,errors:l.filter(u=>u.error).map(u=>u.error)}}}else{let s=await Promise.all(i.map(a=>this.bindOneAddress(a,o)));return{count:s.filter(a=>a.error===void 0).length,port:s[0].port,errors:s.filter(a=>a.error).map(a=>a.error)}}}async bindAddressList(i,o){let s=await this.bindManyPorts(i,o);if(s.count>0)return s.count<i.length&&Td.log(Rt.LogVerbosity.INFO,`WARNING Only ${s.count} addresses added out of total ${i.length} resolved`),s.port;{let a=`No address added out of total ${i.length} resolved`;throw Td.log(Rt.LogVerbosity.ERROR,a),new Error(`${a} errors: [${s.errors.join(",")}]`)}}resolvePort(i){return new Promise((o,s)=>{let a=!1,c=(u,d,f,p)=>{if(a)return!0;if(a=!0,!u.ok)return s(new Error(u.error.details)),!0;let h=[].concat(...u.value.map(m=>m.addresses));return h.length===0?(s(new Error(`No addresses resolved for port ${i}`)),!0):(o(h),!0)};(0,J8.createResolver)(i,c,this.options).updateResolution()})}async bindPort(i,o){let s=await this.resolvePort(i);if(o.cancelled)throw this.completeUnbind(o),new Error("bindAsync operation cancelled by unbind call");let a=await this.bindAddressList(s,o);if(o.cancelled)throw this.completeUnbind(o),new Error("bindAsync operation cancelled by unbind call");return a}normalizePort(i){let o=(0,_i.parseUri)(i);if(o===null)throw new Error(`Could not parse port "${i}"`);let s=(0,J8.mapUriDefaultScheme)(o);if(s===null)throw new Error(`Could not get a default scheme for port "${i}"`);return s}bindAsync(i,o,s){if(this.shutdown)throw new Error("bindAsync called after shutdown");if(typeof i!="string")throw new TypeError("port must be a string");if(o===null||!(o instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");if(typeof s!="function")throw new TypeError("callback must be a function");this.trace("bindAsync port="+i);let a=this.normalizePort(i),c=(f,p)=>{process.nextTick(()=>s(f,p))},l=this.boundPorts.get((0,_i.uriToString)(a));if(l){if(!o._equals(l.credentials)){c(new Error(`${i} already bound with incompatible credentials`),0);return}l.cancelled=!1,l.completionPromise?l.completionPromise.then(f=>s(null,f),f=>s(f,0)):c(null,l.portNumber);return}l={mapKey:(0,_i.uriToString)(a),originalUri:a,completionPromise:null,cancelled:!1,portNumber:0,credentials:o,listeningServers:new Set};let u=(0,_i.splitHostPort)(a.path),d=this.bindPort(a,l);l.completionPromise=d,u?.port===0?d.then(f=>{let p={scheme:a.scheme,authority:a.authority,path:(0,_i.combineHostPort)({host:u.host,port:f})};l.mapKey=(0,_i.uriToString)(p),l.completionPromise=null,l.portNumber=f,this.boundPorts.set(l.mapKey,l),s(null,f)},f=>{s(f,0)}):(this.boundPorts.set(l.mapKey,l),d.then(f=>{l.completionPromise=null,l.portNumber=f,s(null,f)},f=>{s(f,0)}))}registerInjectorToChannelz(){return(0,Ft.registerChannelzSocket)("injector",()=>({localAddress:null,remoteAddress:null,security:null,remoteName:null,streamsStarted:0,streamsSucceeded:0,streamsFailed:0,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastLocalStreamCreatedTimestamp:null,lastRemoteStreamCreatedTimestamp:null,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null,localFlowControlWindow:null,remoteFlowControlWindow:null}),this.channelzEnabled)}experimentalCreateConnectionInjectorWithChannelzRef(i,o,s=!1){if(i===null||!(i instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");this.channelzEnabled&&this.listenerChildrenTracker.refChild(o);let a=this.createHttp2Server(i),c=new Set;return this.http2Servers.set(a,{channelzRef:o,sessions:c,ownsChannelzRef:s}),{injectConnection:l=>{a.emit("connection",l)},drain:l=>{var u,d;for(let f of c)this.closeSession(f);(d=(u=setTimeout(()=>{for(let f of c)f.destroy(qr.constants.NGHTTP2_CANCEL)},l)).unref)===null||d===void 0||d.call(u)},destroy:()=>{this.closeServer(a);for(let l of c)this.closeSession(l)}}}createConnectionInjector(i){if(i===null||!(i instanceof dk.ServerCredentials))throw new TypeError("creds must be a ServerCredentials object");let o=this.registerInjectorToChannelz();return this.experimentalCreateConnectionInjectorWithChannelzRef(i,o,!0)}closeServer(i,o){this.trace("Closing server with address "+JSON.stringify(i.address()));let s=this.http2Servers.get(i);i.close(()=>{s&&s.ownsChannelzRef&&(this.listenerChildrenTracker.unrefChild(s.channelzRef),(0,Ft.unregisterChannelzRef)(s.channelzRef)),this.http2Servers.delete(i),o?.()})}closeSession(i,o){var s;this.trace("Closing session initiated by "+((s=i.socket)===null||s===void 0?void 0:s.remoteAddress));let a=this.sessions.get(i),c=()=>{a&&(this.sessionChildrenTracker.unrefChild(a.ref),(0,Ft.unregisterChannelzRef)(a.ref)),o?.()};i.closed?queueMicrotask(c):i.close(c)}completeUnbind(i){for(let o of i.listeningServers){let s=this.http2Servers.get(o);if(this.closeServer(o,()=>{i.listeningServers.delete(o)}),s)for(let a of s.sessions)this.closeSession(a)}this.boundPorts.delete(i.mapKey)}unbind(i){this.trace("unbind port="+i);let o=this.normalizePort(i),s=(0,_i.splitHostPort)(o.path);if(s?.port===0)throw new Error("Cannot unbind port 0");let a=this.boundPorts.get((0,_i.uriToString)(o));a&&(this.trace("unbinding "+a.mapKey+" originally bound as "+(0,_i.uriToString)(a.originalUri)),a.completionPromise?a.cancelled=!0:this.completeUnbind(a))}drain(i,o){var s,a;this.trace("drain port="+i+" graceTimeMs="+o);let c=this.normalizePort(i),l=(0,_i.splitHostPort)(c.path);if(l?.port===0)throw new Error("Cannot drain port 0");let u=this.boundPorts.get((0,_i.uriToString)(c));if(!u)return;let d=new Set;for(let f of u.listeningServers){let p=this.http2Servers.get(f);if(p)for(let h of p.sessions)d.add(h),this.closeSession(h,()=>{d.delete(h)})}(a=(s=setTimeout(()=>{for(let f of d)f.destroy(qr.constants.NGHTTP2_CANCEL)},o)).unref)===null||a===void 0||a.call(s)}forceShutdown(){for(let i of this.boundPorts.values())i.cancelled=!0;this.boundPorts.clear();for(let i of this.http2Servers.keys())this.closeServer(i);this.sessions.forEach((i,o)=>{this.closeSession(o),o.destroy(qr.constants.NGHTTP2_CANCEL)}),this.sessions.clear(),(0,Ft.unregisterChannelzRef)(this.channelzRef),this.shutdown=!0}register(i,o,s,a,c){return this.handlers.has(i)?!1:(this.handlers.set(i,{func:o,serialize:s,deserialize:a,type:c,path:i}),!0)}unregister(i){return this.handlers.delete(i)}start(){if(this.http2Servers.size===0||[...this.http2Servers.keys()].every(i=>!i.listening))throw new Error("server must be bound in order to start");if(this.started===!0)throw new Error("server is already started");this.started=!0}tryShutdown(i){var o;let s=l=>{(0,Ft.unregisterChannelzRef)(this.channelzRef),i(l)},a=0;function c(){a--,a===0&&s()}this.shutdown=!0;for(let[l,u]of this.http2Servers.entries()){a++;let d=u.channelzRef.name;this.trace("Waiting for server "+d+" to close"),this.closeServer(l,()=>{this.trace("Server "+d+" finished closing"),c()});for(let f of u.sessions.keys()){a++;let p=(o=f.socket)===null||o===void 0?void 0:o.remoteAddress;this.trace("Waiting for session "+p+" to close"),this.closeSession(f,()=>{this.trace("Session "+p+" finished closing"),c()})}}a===0&&s()}addHttp2Port(){throw new Error("Not yet implemented")}getChannelzRef(){return this.channelzRef}_verifyContentType(i,o){let s=o[qr.constants.HTTP2_HEADER_CONTENT_TYPE];return typeof s!="string"||!s.startsWith("application/grpc")?(i.respond({[qr.constants.HTTP2_HEADER_STATUS]:qr.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE},{endStream:!0}),!1):!0}_retrieveHandler(i){rK("Received call to method "+i+" at address "+this.serverAddressString);let o=this.handlers.get(i);return o===void 0?(rK("No handler registered for method "+i+". Sending UNIMPLEMENTED status."),null):o}_respondWithError(i,o,s=null){var a,c;let l=Object.assign({"grpc-status":(a=i.code)!==null&&a!==void 0?a:Rt.Status.INTERNAL,"grpc-message":i.details,[qr.constants.HTTP2_HEADER_STATUS]:qr.constants.HTTP_STATUS_OK,[qr.constants.HTTP2_HEADER_CONTENT_TYPE]:"application/grpc+proto"},(c=i.metadata)===null||c===void 0?void 0:c.toHttp2Headers());o.respond(l,{endStream:!0}),this.callTracker.addCallFailed(),s?.streamTracker.addCallFailed()}_channelzHandler(i,o,s){o.once("error",f=>{}),this.onStreamOpened(o);let a=this.sessions.get(o.session);if(this.callTracker.addCallStarted(),a?.streamTracker.addCallStarted(),!this._verifyContentType(o,s)){this.callTracker.addCallFailed(),a?.streamTracker.addCallFailed();return}let c=s[eK],l=this._retrieveHandler(c);if(!l){this._respondWithError(pk(c),o,a);return}let u={addMessageSent:()=>{a&&(a.messagesSent+=1,a.lastMessageSentTimestamp=new Date)},addMessageReceived:()=>{a&&(a.messagesReceived+=1,a.lastMessageReceivedTimestamp=new Date)},onCallEnd:f=>{f.code===Rt.Status.OK?this.callTracker.addCallSucceeded():this.callTracker.addCallFailed()},onStreamEnd:f=>{a&&(f?a.streamTracker.addCallSucceeded():a.streamTracker.addCallFailed())}},d=(0,X8.getServerInterceptingCall)([...i,...this.interceptors],o,s,u,l,this.options);this._runHandlerForCall(d,l)||(this.callTracker.addCallFailed(),a?.streamTracker.addCallFailed(),d.sendStatus({code:Rt.Status.INTERNAL,details:`Unknown handler type: ${l.type}`}))}_streamHandler(i,o,s){if(o.once("error",u=>{}),this.onStreamOpened(o),this._verifyContentType(o,s)!==!0)return;let a=s[eK],c=this._retrieveHandler(a);if(!c){this._respondWithError(pk(a),o,null);return}let l=(0,X8.getServerInterceptingCall)([...i,...this.interceptors],o,s,null,c,this.options);this._runHandlerForCall(l,c)||l.sendStatus({code:Rt.Status.INTERNAL,details:`Unknown handler type: ${c.type}`})}_runHandlerForCall(i,o){let{type:s}=o;if(s==="unary")bxe(i,o);else if(s==="clientStream")Txe(i,o);else if(s==="serverStream")xxe(i,o);else if(s==="bidi")wxe(i,o);else return!1;return!0}_setupHandlers(i,o){if(i===null)return;let s=i.address(),a="null";s&&(typeof s=="string"?a=s:a=s.address+":"+s.port),this.serverAddressString=a;let c=this.channelzEnabled?this._channelzHandler:this._streamHandler,l=this.channelzEnabled?this._channelzSessionHandler(i):this._sessionHandler(i);i.on("stream",c.bind(this,o)),i.on("session",l)}_sessionHandler(i){return o=>{var s,a;(s=this.http2Servers.get(i))===null||s===void 0||s.sessions.add(o);let c=null,l=null,u=null,d=!1,f=this.enableIdleTimeout(o);if(this.maxConnectionAgeMs!==bd){let S=this.maxConnectionAgeMs/10,T=Math.random()*S*2-S;c=setTimeout(()=>{var x,v;d=!0,this.trace("Connection dropped by max connection age: "+((x=o.socket)===null||x===void 0?void 0:x.remoteAddress));try{o.goaway(qr.constants.NGHTTP2_NO_ERROR,~(1<<31),tK)}catch{o.destroy();return}o.close(),this.maxConnectionAgeGraceMs!==bd&&(l=setTimeout(()=>{o.destroy()},this.maxConnectionAgeGraceMs),(v=l.unref)===null||v===void 0||v.call(l))},this.maxConnectionAgeMs+T),(a=c.unref)===null||a===void 0||a.call(c)}let p=()=>{u&&(clearTimeout(u),u=null)},h=()=>!o.destroyed&&this.keepaliveTimeMs<fk&&this.keepaliveTimeMs>0,m,y=()=>{var S;h()&&(this.keepaliveTrace("Starting keepalive timer for "+this.keepaliveTimeMs+"ms"),u=setTimeout(()=>{p(),m()},this.keepaliveTimeMs),(S=u.unref)===null||S===void 0||S.call(u))};m=()=>{var S;if(!h())return;this.keepaliveTrace("Sending ping with timeout "+this.keepaliveTimeoutMs+"ms");let T="";try{o.ping((v,N,R)=>{p(),v?(this.keepaliveTrace("Ping failed with error: "+v.message),d=!0,o.destroy()):(this.keepaliveTrace("Received ping response"),y())})||(T="Ping returned false")}catch(x){T=(x instanceof Error?x.message:"")||"Unknown error"}if(T){this.keepaliveTrace("Ping send failed: "+T),this.trace("Connection dropped due to ping send error: "+T),d=!0,o.destroy();return}u=setTimeout(()=>{p(),this.keepaliveTrace("Ping timeout passed without response"),this.trace("Connection dropped by keepalive timeout"),d=!0,o.destroy()},this.keepaliveTimeoutMs),(S=u.unref)===null||S===void 0||S.call(u)},y(),o.on("close",()=>{var S,T;d||this.trace(`Connection dropped by client ${(S=o.socket)===null||S===void 0?void 0:S.remoteAddress}`),c&&clearTimeout(c),l&&clearTimeout(l),p(),f!==null&&(clearTimeout(f.timeout),this.sessionIdleTimeouts.delete(o)),(T=this.http2Servers.get(i))===null||T===void 0||T.sessions.delete(o)})}}_channelzSessionHandler(i){return o=>{var s,a,c,l;let u=(0,Ft.registerChannelzSocket)((a=(s=o.socket)===null||s===void 0?void 0:s.remoteAddress)!==null&&a!==void 0?a:"unknown",this.getChannelzSessionInfo.bind(this,o),this.channelzEnabled),d={ref:u,streamTracker:new Ft.ChannelzCallTracker,messagesSent:0,messagesReceived:0,keepAlivesSent:0,lastMessageSentTimestamp:null,lastMessageReceivedTimestamp:null};(c=this.http2Servers.get(i))===null||c===void 0||c.sessions.add(o),this.sessions.set(o,d);let f=`${o.socket.remoteAddress}:${o.socket.remotePort}`;this.channelzTrace.addTrace("CT_INFO","Connection established by client "+f),this.trace("Connection established by client "+f),this.sessionChildrenTracker.refChild(u);let p=null,h=null,m=null,y=!1,S=this.enableIdleTimeout(o);if(this.maxConnectionAgeMs!==bd){let R=this.maxConnectionAgeMs/10,U=Math.random()*R*2-R;p=setTimeout(()=>{var C;y=!0,this.channelzTrace.addTrace("CT_INFO","Connection dropped by max connection age from "+f);try{o.goaway(qr.constants.NGHTTP2_NO_ERROR,~(1<<31),tK)}catch{o.destroy();return}o.close(),this.maxConnectionAgeGraceMs!==bd&&(h=setTimeout(()=>{o.destroy()},this.maxConnectionAgeGraceMs),(C=h.unref)===null||C===void 0||C.call(h))},this.maxConnectionAgeMs+U),(l=p.unref)===null||l===void 0||l.call(p)}let T=()=>{m&&(clearTimeout(m),m=null)},x=()=>!o.destroyed&&this.keepaliveTimeMs<fk&&this.keepaliveTimeMs>0,v,N=()=>{var R;x()&&(this.keepaliveTrace("Starting keepalive timer for "+this.keepaliveTimeMs+"ms"),m=setTimeout(()=>{T(),v()},this.keepaliveTimeMs),(R=m.unref)===null||R===void 0||R.call(m))};v=()=>{var R;if(!x())return;this.keepaliveTrace("Sending ping with timeout "+this.keepaliveTimeoutMs+"ms");let U="";try{o.ping((D,j,_)=>{T(),D?(this.keepaliveTrace("Ping failed with error: "+D.message),this.channelzTrace.addTrace("CT_INFO","Connection dropped due to error of a ping frame "+D.message+" return in "+j),y=!0,o.destroy()):(this.keepaliveTrace("Received ping response"),N())})||(U="Ping returned false")}catch(C){U=(C instanceof Error?C.message:"")||"Unknown error"}if(U){this.keepaliveTrace("Ping send failed: "+U),this.channelzTrace.addTrace("CT_INFO","Connection dropped due to ping send error: "+U),y=!0,o.destroy();return}d.keepAlivesSent+=1,m=setTimeout(()=>{T(),this.keepaliveTrace("Ping timeout passed without response"),this.channelzTrace.addTrace("CT_INFO","Connection dropped by keepalive timeout from "+f),y=!0,o.destroy()},this.keepaliveTimeoutMs),(R=m.unref)===null||R===void 0||R.call(m)},N(),o.on("close",()=>{var R;y||this.channelzTrace.addTrace("CT_INFO","Connection dropped by client "+f),this.sessionChildrenTracker.unrefChild(u),(0,Ft.unregisterChannelzRef)(u),p&&clearTimeout(p),h&&clearTimeout(h),T(),S!==null&&(clearTimeout(S.timeout),this.sessionIdleTimeouts.delete(o)),(R=this.http2Servers.get(i))===null||R===void 0||R.sessions.delete(o),this.sessions.delete(o)})}}enableIdleTimeout(i){var o,s;if(this.sessionIdleTimeout>=Q8)return null;let a={activeStreams:0,lastIdle:Date.now(),onClose:this.onStreamClose.bind(this,i),timeout:setTimeout(this.onIdleTimeout,this.sessionIdleTimeout,this,i)};(s=(o=a.timeout).unref)===null||s===void 0||s.call(o),this.sessionIdleTimeouts.set(i,a);let{socket:c}=i;return this.trace("Enable idle timeout for "+c.remoteAddress+":"+c.remotePort),a}onIdleTimeout(i,o){let{socket:s}=o,a=i.sessionIdleTimeouts.get(o);a!==void 0&&a.activeStreams===0&&(Date.now()-a.lastIdle>=i.sessionIdleTimeout?(i.trace("Session idle timeout triggered for "+s?.remoteAddress+":"+s?.remotePort+" last idle at "+a.lastIdle),i.closeSession(o)):a.timeout.refresh())}onStreamOpened(i){let o=i.session,s=this.sessionIdleTimeouts.get(o);s&&(s.activeStreams+=1,i.once("close",s.onClose))}onStreamClose(i){var o,s;let a=this.sessionIdleTimeouts.get(i);a&&(a.activeStreams-=1,a.activeStreams===0&&(a.lastIdle=Date.now(),a.timeout.refresh(),this.trace("Session onStreamClose"+((o=i.socket)===null||o===void 0?void 0:o.remoteAddress)+":"+((s=i.socket)===null||s===void 0?void 0:s.remotePort)+" at "+a.lastIdle)))}},(()=>{let n=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;r=[Sxe("Calling start() is no longer necessary. It can be safely omitted.")],hxe(t,null,r,{kind:"method",name:"start",static:!1,private:!1,access:{has:i=>"start"in i,get:i=>i.start},metadata:n},null,e),n&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n})})(),t})();Ta.Server=vxe;async function bxe(t,e){let r;function n(s,a,c,l){if(s){t.sendStatus((0,xd.serverErrorToStatus)(s,c));return}t.sendMessage(a,()=>{t.sendStatus({code:Rt.Status.OK,details:"OK",metadata:c??null})})}let i,o=null;t.start({onReceiveMetadata(s){i=s,t.startRead()},onReceiveMessage(s){if(o){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received a second request message for server streaming method ${e.path}`,metadata:null});return}o=s,t.startRead()},onReceiveHalfClose(){if(!o){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received no request message for server streaming method ${e.path}`,metadata:null});return}r=new xd.ServerWritableStreamImpl(e.path,t,i,o);try{e.func(r,n)}catch(s){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${s.message}`,metadata:null})}},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"))}})}function Txe(t,e){let r;function n(i,o,s,a){if(i){t.sendStatus((0,xd.serverErrorToStatus)(i,s));return}t.sendMessage(o,()=>{t.sendStatus({code:Rt.Status.OK,details:"OK",metadata:s??null})})}t.start({onReceiveMetadata(i){r=new xd.ServerDuplexStreamImpl(e.path,t,i);try{e.func(r,n)}catch(o){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${o.message}`,metadata:null})}},onReceiveMessage(i){r.push(i)},onReceiveHalfClose(){r.push(null)},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}function xxe(t,e){let r,n,i=null;t.start({onReceiveMetadata(o){n=o,t.startRead()},onReceiveMessage(o){if(i){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received a second request message for server streaming method ${e.path}`,metadata:null});return}i=o,t.startRead()},onReceiveHalfClose(){if(!i){t.sendStatus({code:Rt.Status.UNIMPLEMENTED,details:`Received no request message for server streaming method ${e.path}`,metadata:null});return}r=new xd.ServerWritableStreamImpl(e.path,t,n,i);try{e.func(r)}catch(o){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${o.message}`,metadata:null})}},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}function wxe(t,e){let r;t.start({onReceiveMetadata(n){r=new xd.ServerDuplexStreamImpl(e.path,t,n);try{e.func(r)}catch(i){t.sendStatus({code:Rt.Status.UNKNOWN,details:`Server method handler threw error ${i.message}`,metadata:null})}},onReceiveMessage(n){r.push(n)},onReceiveHalfClose(){r.push(null)},onCancel(){r&&(r.cancelled=!0,r.emit("cancelled","cancelled"),r.destroy())}})}});var iK=b(jb=>{"use strict";Object.defineProperty(jb,"__esModule",{value:!0});jb.StatusBuilder=void 0;var hk=class{constructor(){this.code=null,this.details=null,this.metadata=null}withCode(e){return this.code=e,this}withDetails(e){return this.details=e,this}withMetadata(e){return this.metadata=e,this}build(){let e={};return this.code!==null&&(e.code=this.code),this.details!==null&&(e.details=this.details),this.metadata!==null&&(e.metadata=this.metadata),e}};jb.StatusBuilder=hk});var vg=b(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.LeafLoadBalancer=oo.PickFirstLoadBalancer=oo.PickFirstLoadBalancingConfig=void 0;oo.shuffled=cK;oo.setup=kxe;var mk=aa(),It=Ir(),xa=Ho(),oK=zr(),Axe=st(),Rxe=je(),sK=zr(),aK=Z("net"),Ixe=Kc(),Cxe="pick_first";function yg(t){Axe.trace(Rxe.LogVerbosity.DEBUG,Cxe,t)}var Sg="pick_first",Pxe=250,wd=class t{constructor(e){this.shuffleAddressList=e}getLoadBalancerName(){return Sg}toJsonObject(){return{[Sg]:{shuffleAddressList:this.shuffleAddressList}}}getShuffleAddressList(){return this.shuffleAddressList}static createFromJson(e){if("shuffleAddressList"in e&&typeof e.shuffleAddressList!="boolean")throw new Error("pick_first config field shuffleAddressList must be a boolean if provided");return new t(e.shuffleAddressList===!0)}};oo.PickFirstLoadBalancingConfig=wd;var gk=class{constructor(e){this.subchannel=e}pick(e){return{pickResultType:xa.PickResultType.COMPLETE,subchannel:this.subchannel,status:null,onCallStarted:null,onCallEnded:null}}};function cK(t){let e=t.slice();for(let r=e.length-1;r>1;r--){let n=Math.floor(Math.random()*(r+1)),i=e[r];e[r]=e[n],e[n]=i}return e}function Oxe(t){if(t.length===0)return[];let e=[],r=[],n=[],i=(0,sK.isTcpSubchannelAddress)(t[0])&&(0,aK.isIPv6)(t[0].host);for(let a of t)(0,sK.isTcpSubchannelAddress)(a)&&(0,aK.isIPv6)(a.host)?r.push(a):n.push(a);let o=i?r:n,s=i?n:r;for(let a=0;a<Math.max(o.length,s.length);a++)a<o.length&&e.push(o[a]),a<s.length&&e.push(s[a]);return e}var lK="grpc-node.internal.pick-first.report_health_status",Eg=class{constructor(e){this.channelControlHelper=e,this.children=[],this.currentState=It.ConnectivityState.IDLE,this.currentSubchannelIndex=0,this.currentPick=null,this.subchannelStateListener=(r,n,i,o,s)=>{this.onSubchannelStateUpdate(r,n,i,s)},this.pickedSubchannelHealthListener=()=>this.calculateAndReportNewState(),this.stickyTransientFailureMode=!1,this.reportHealthStatus=!1,this.lastError=null,this.latestAddressList=null,this.latestOptions={},this.latestResolutionNote="",this.connectionDelayTimeout=setTimeout(()=>{},0),clearTimeout(this.connectionDelayTimeout)}allChildrenHaveReportedTF(){return this.children.every(e=>e.hasReportedTransientFailure)}resetChildrenReportedTF(){this.children.every(e=>e.hasReportedTransientFailure=!1)}calculateAndReportNewState(){var e;if(this.currentPick)if(this.reportHealthStatus&&!this.currentPick.isHealthy()){let r=`Picked subchannel ${this.currentPick.getAddress()} is unhealthy`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else this.updateState(It.ConnectivityState.READY,new gk(this.currentPick),null);else if(((e=this.latestAddressList)===null||e===void 0?void 0:e.length)===0){let r=`No connection established. Last error: ${this.lastError}. Resolution note: ${this.latestResolutionNote}`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else if(this.children.length===0)this.updateState(It.ConnectivityState.IDLE,new xa.QueuePicker(this),null);else if(this.stickyTransientFailureMode){let r=`No connection established. Last error: ${this.lastError}. Resolution note: ${this.latestResolutionNote}`;this.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker({details:r}),r)}else this.updateState(It.ConnectivityState.CONNECTING,new xa.QueuePicker(this),null)}requestReresolution(){this.channelControlHelper.requestReresolution()}maybeEnterStickyTransientFailureMode(){if(this.allChildrenHaveReportedTF()){if(this.requestReresolution(),this.resetChildrenReportedTF(),this.stickyTransientFailureMode){this.calculateAndReportNewState();return}this.stickyTransientFailureMode=!0;for(let{subchannel:e}of this.children)e.startConnecting();this.calculateAndReportNewState()}}removeCurrentPick(){this.currentPick!==null&&(this.currentPick.removeConnectivityStateListener(this.subchannelStateListener),this.channelControlHelper.removeChannelzChild(this.currentPick.getChannelzRef()),this.currentPick.removeHealthStateWatcher(this.pickedSubchannelHealthListener),this.currentPick.unref(),this.currentPick=null)}onSubchannelStateUpdate(e,r,n,i){var o;if(!((o=this.currentPick)===null||o===void 0)&&o.realSubchannelEquals(e)){n!==It.ConnectivityState.READY&&(this.removeCurrentPick(),this.calculateAndReportNewState());return}for(let[s,a]of this.children.entries())if(e.realSubchannelEquals(a.subchannel)){n===It.ConnectivityState.READY&&this.pickSubchannel(a.subchannel),n===It.ConnectivityState.TRANSIENT_FAILURE&&(a.hasReportedTransientFailure=!0,i&&(this.lastError=i),this.maybeEnterStickyTransientFailureMode(),s===this.currentSubchannelIndex&&this.startNextSubchannelConnecting(s+1)),a.subchannel.startConnecting();return}}startNextSubchannelConnecting(e){clearTimeout(this.connectionDelayTimeout);for(let[r,n]of this.children.entries())if(r>=e){let i=n.subchannel.getConnectivityState();if(i===It.ConnectivityState.IDLE||i===It.ConnectivityState.CONNECTING){this.startConnecting(r);return}}this.maybeEnterStickyTransientFailureMode()}startConnecting(e){var r,n;clearTimeout(this.connectionDelayTimeout),this.currentSubchannelIndex=e,this.children[e].subchannel.getConnectivityState()===It.ConnectivityState.IDLE&&(yg("Start connecting to subchannel with address "+this.children[e].subchannel.getAddress()),process.nextTick(()=>{var i;(i=this.children[e])===null||i===void 0||i.subchannel.startConnecting()})),this.connectionDelayTimeout=setTimeout(()=>{this.startNextSubchannelConnecting(e+1)},Pxe),(n=(r=this.connectionDelayTimeout).unref)===null||n===void 0||n.call(r)}pickSubchannel(e){yg("Pick subchannel with address "+e.getAddress()),this.stickyTransientFailureMode=!1,e.ref(),this.channelControlHelper.addChannelzChild(e.getChannelzRef()),this.removeCurrentPick(),this.resetSubchannelList(),e.addConnectivityStateListener(this.subchannelStateListener),e.addHealthStateWatcher(this.pickedSubchannelHealthListener),this.currentPick=e,clearTimeout(this.connectionDelayTimeout),this.calculateAndReportNewState()}updateState(e,r,n){yg(It.ConnectivityState[this.currentState]+" -> "+It.ConnectivityState[e]),this.currentState=e,this.channelControlHelper.updateState(e,r,n)}resetSubchannelList(){for(let e of this.children)e.subchannel.removeConnectivityStateListener(this.subchannelStateListener),e.subchannel.unref(),this.channelControlHelper.removeChannelzChild(e.subchannel.getChannelzRef());this.currentSubchannelIndex=0,this.children=[]}connectToAddressList(e,r){yg("connectToAddressList(["+e.map(i=>(0,oK.subchannelAddressToString)(i))+"])");let n=e.map(i=>({subchannel:this.channelControlHelper.createSubchannel(i,r),hasReportedTransientFailure:!1}));for(let{subchannel:i}of n)if(i.getConnectivityState()===It.ConnectivityState.READY){this.pickSubchannel(i);return}for(let{subchannel:i}of n)i.ref(),this.channelControlHelper.addChannelzChild(i.getChannelzRef());this.resetSubchannelList(),this.children=n;for(let{subchannel:i}of this.children)i.addConnectivityStateListener(this.subchannelStateListener);for(let i of this.children)i.subchannel.getConnectivityState()===It.ConnectivityState.TRANSIENT_FAILURE&&(i.hasReportedTransientFailure=!0);this.startNextSubchannelConnecting(0),this.calculateAndReportNewState()}updateAddressList(e,r,n,i){if(!(r instanceof wd))return!1;if(!e.ok)return this.children.length===0&&this.currentPick===null&&this.channelControlHelper.updateState(It.ConnectivityState.TRANSIENT_FAILURE,new xa.UnavailablePicker(e.error),e.error.details),!0;let o=e.value;this.reportHealthStatus=n[lK],r.getShuffleAddressList()&&(o=cK(o));let s=[].concat(...o.map(c=>c.addresses));yg("updateAddressList(["+s.map(c=>(0,oK.subchannelAddressToString)(c))+"])");let a=Oxe(s);return this.latestAddressList=a,this.latestOptions=n,this.connectToAddressList(a,n),this.latestResolutionNote=i,s.length>0?!0:(this.lastError="No addresses resolved",!1)}exitIdle(){this.currentState===It.ConnectivityState.IDLE&&this.latestAddressList&&this.connectToAddressList(this.latestAddressList,this.latestOptions)}resetBackoff(){}destroy(){this.resetSubchannelList(),this.removeCurrentPick()}getTypeName(){return Sg}};oo.PickFirstLoadBalancer=Eg;var Nxe=new wd(!1),_k=class{constructor(e,r,n,i){this.endpoint=e,this.options=n,this.resolutionNote=i,this.latestState=It.ConnectivityState.IDLE;let o=(0,mk.createChildChannelControlHelper)(r,{updateState:(s,a,c)=>{this.latestState=s,this.latestPicker=a,r.updateState(s,a,c)}});this.pickFirstBalancer=new Eg(o),this.latestPicker=new xa.QueuePicker(this.pickFirstBalancer)}startConnecting(){this.pickFirstBalancer.updateAddressList((0,Ixe.statusOrFromValue)([this.endpoint]),Nxe,Object.assign(Object.assign({},this.options),{[lK]:!0}),this.resolutionNote)}updateEndpoint(e,r){this.options=r,this.endpoint=e,this.latestState!==It.ConnectivityState.IDLE&&this.startConnecting()}getConnectivityState(){return this.latestState}getPicker(){return this.latestPicker}getEndpoint(){return this.endpoint}exitIdle(){this.pickFirstBalancer.exitIdle()}destroy(){this.pickFirstBalancer.destroy()}};oo.LeafLoadBalancer=_k;function kxe(){(0,mk.registerLoadBalancerType)(Sg,Eg,wd),(0,mk.registerDefaultLoadBalancerType)(Sg)}});var uK=b(Gb=>{"use strict";Object.defineProperty(Gb,"__esModule",{value:!0});Gb.FileWatcherCertificateProvider=void 0;var Mxe=Z("fs"),Dxe=st(),Lxe=je(),$xe=Z("util"),Uxe="certificate_provider";function zb(t){Dxe.trace(Lxe.LogVerbosity.DEBUG,Uxe,t)}var yk=(0,$xe.promisify)(Mxe.readFile),Sk=class{constructor(e){if(this.config=e,this.refreshTimer=null,this.fileResultPromise=null,this.latestCaUpdate=void 0,this.caListeners=new Set,this.latestIdentityUpdate=void 0,this.identityListeners=new Set,this.lastUpdateTime=null,e.certificateFile===void 0!=(e.privateKeyFile===void 0))throw new Error("certificateFile and privateKeyFile must be set or unset together");if(e.certificateFile===void 0&&e.caCertificateFile===void 0)throw new Error("At least one of certificateFile and caCertificateFile must be set");zb("File watcher constructed with config "+JSON.stringify(e))}updateCertificates(){this.fileResultPromise||(this.fileResultPromise=Promise.allSettled([this.config.certificateFile?yk(this.config.certificateFile):Promise.reject(),this.config.privateKeyFile?yk(this.config.privateKeyFile):Promise.reject(),this.config.caCertificateFile?yk(this.config.caCertificateFile):Promise.reject()]),this.fileResultPromise.then(([e,r,n])=>{if(this.refreshTimer){zb("File watcher read certificates certificate "+e.status+", privateKey "+r.status+", CA certificate "+n.status),this.lastUpdateTime=new Date,this.fileResultPromise=null,e.status==="fulfilled"&&r.status==="fulfilled"?this.latestIdentityUpdate={certificate:e.value,privateKey:r.value}:this.latestIdentityUpdate=null,n.status==="fulfilled"?this.latestCaUpdate={caCertificate:n.value}:this.latestCaUpdate=null;for(let i of this.identityListeners)i(this.latestIdentityUpdate);for(let i of this.caListeners)i(this.latestCaUpdate)}}),zb("File watcher initiated certificate update"))}maybeStartWatchingFiles(){if(!this.refreshTimer){let e=this.lastUpdateTime?new Date().getTime()-this.lastUpdateTime.getTime():1/0;e>this.config.refreshIntervalMs&&this.updateCertificates(),e>this.config.refreshIntervalMs*2&&(this.latestCaUpdate=void 0,this.latestIdentityUpdate=void 0),this.refreshTimer=setInterval(()=>this.updateCertificates(),this.config.refreshIntervalMs),zb("File watcher started watching")}}maybeStopWatchingFiles(){this.caListeners.size===0&&this.identityListeners.size===0&&(this.fileResultPromise=null,this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null))}addCaCertificateListener(e){this.caListeners.add(e),this.maybeStartWatchingFiles(),this.latestCaUpdate!==void 0&&process.nextTick(e,this.latestCaUpdate)}removeCaCertificateListener(e){this.caListeners.delete(e),this.maybeStopWatchingFiles()}addIdentityCertificateListener(e){this.identityListeners.add(e),this.maybeStartWatchingFiles(),this.latestIdentityUpdate!==void 0&&process.nextTick(e,this.latestIdentityUpdate)}removeIdentityCertificateListener(e){this.identityListeners.delete(e),this.maybeStopWatchingFiles()}};Gb.FileWatcherCertificateProvider=Sk});var bk=b(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX=_e.createCertificateProviderChannelCredentials=_e.FileWatcherCertificateProvider=_e.createCertificateProviderServerCredentials=_e.createServerCredentialsWithInterceptors=_e.BaseSubchannelWrapper=_e.registerAdminService=_e.FilterStackFactory=_e.BaseFilter=_e.statusOrFromError=_e.statusOrFromValue=_e.PickResultType=_e.QueuePicker=_e.UnavailablePicker=_e.ChildLoadBalancerHandler=_e.EndpointMap=_e.endpointHasAddress=_e.endpointToString=_e.subchannelAddressToString=_e.LeafLoadBalancer=_e.isLoadBalancerNameRegistered=_e.parseLoadBalancingConfig=_e.selectLbConfigFromList=_e.registerLoadBalancerType=_e.createChildChannelControlHelper=_e.BackoffTimeout=_e.parseDuration=_e.durationToMs=_e.splitHostPort=_e.uriToString=_e.CHANNEL_ARGS_CONFIG_SELECTOR_KEY=_e.createResolver=_e.registerResolver=_e.log=_e.trace=void 0;var dK=st();Object.defineProperty(_e,"trace",{enumerable:!0,get:function(){return dK.trace}});Object.defineProperty(_e,"log",{enumerable:!0,get:function(){return dK.log}});var Ek=ni();Object.defineProperty(_e,"registerResolver",{enumerable:!0,get:function(){return Ek.registerResolver}});Object.defineProperty(_e,"createResolver",{enumerable:!0,get:function(){return Ek.createResolver}});Object.defineProperty(_e,"CHANNEL_ARGS_CONFIG_SELECTOR_KEY",{enumerable:!0,get:function(){return Ek.CHANNEL_ARGS_CONFIG_SELECTOR_KEY}});var fK=Rr();Object.defineProperty(_e,"uriToString",{enumerable:!0,get:function(){return fK.uriToString}});Object.defineProperty(_e,"splitHostPort",{enumerable:!0,get:function(){return fK.splitHostPort}});var pK=_g();Object.defineProperty(_e,"durationToMs",{enumerable:!0,get:function(){return pK.durationToMs}});Object.defineProperty(_e,"parseDuration",{enumerable:!0,get:function(){return pK.parseDuration}});var Fxe=Yu();Object.defineProperty(_e,"BackoffTimeout",{enumerable:!0,get:function(){return Fxe.BackoffTimeout}});var bg=aa();Object.defineProperty(_e,"createChildChannelControlHelper",{enumerable:!0,get:function(){return bg.createChildChannelControlHelper}});Object.defineProperty(_e,"registerLoadBalancerType",{enumerable:!0,get:function(){return bg.registerLoadBalancerType}});Object.defineProperty(_e,"selectLbConfigFromList",{enumerable:!0,get:function(){return bg.selectLbConfigFromList}});Object.defineProperty(_e,"parseLoadBalancingConfig",{enumerable:!0,get:function(){return bg.parseLoadBalancingConfig}});Object.defineProperty(_e,"isLoadBalancerNameRegistered",{enumerable:!0,get:function(){return bg.isLoadBalancerNameRegistered}});var Bxe=vg();Object.defineProperty(_e,"LeafLoadBalancer",{enumerable:!0,get:function(){return Bxe.LeafLoadBalancer}});var qb=zr();Object.defineProperty(_e,"subchannelAddressToString",{enumerable:!0,get:function(){return qb.subchannelAddressToString}});Object.defineProperty(_e,"endpointToString",{enumerable:!0,get:function(){return qb.endpointToString}});Object.defineProperty(_e,"endpointHasAddress",{enumerable:!0,get:function(){return qb.endpointHasAddress}});Object.defineProperty(_e,"EndpointMap",{enumerable:!0,get:function(){return qb.EndpointMap}});var jxe=gv();Object.defineProperty(_e,"ChildLoadBalancerHandler",{enumerable:!0,get:function(){return jxe.ChildLoadBalancerHandler}});var vk=Ho();Object.defineProperty(_e,"UnavailablePicker",{enumerable:!0,get:function(){return vk.UnavailablePicker}});Object.defineProperty(_e,"QueuePicker",{enumerable:!0,get:function(){return vk.QueuePicker}});Object.defineProperty(_e,"PickResultType",{enumerable:!0,get:function(){return vk.PickResultType}});var hK=Kc();Object.defineProperty(_e,"statusOrFromValue",{enumerable:!0,get:function(){return hK.statusOrFromValue}});Object.defineProperty(_e,"statusOrFromError",{enumerable:!0,get:function(){return hK.statusOrFromError}});var zxe=ZO();Object.defineProperty(_e,"BaseFilter",{enumerable:!0,get:function(){return zxe.BaseFilter}});var Gxe=pb();Object.defineProperty(_e,"FilterStackFactory",{enumerable:!0,get:function(){return Gxe.FilterStackFactory}});var qxe=Ev();Object.defineProperty(_e,"registerAdminService",{enumerable:!0,get:function(){return qxe.registerAdminService}});var Vxe=mg();Object.defineProperty(_e,"BaseSubchannelWrapper",{enumerable:!0,get:function(){return Vxe.BaseSubchannelWrapper}});var mK=Mb();Object.defineProperty(_e,"createServerCredentialsWithInterceptors",{enumerable:!0,get:function(){return mK.createServerCredentialsWithInterceptors}});Object.defineProperty(_e,"createCertificateProviderServerCredentials",{enumerable:!0,get:function(){return mK.createCertificateProviderServerCredentials}});var Hxe=uK();Object.defineProperty(_e,"FileWatcherCertificateProvider",{enumerable:!0,get:function(){return Hxe.FileWatcherCertificateProvider}});var Wxe=Wu();Object.defineProperty(_e,"createCertificateProviderChannelCredentials",{enumerable:!0,get:function(){return Wxe.createCertificateProviderChannelCredentials}});var Yxe=UN();Object.defineProperty(_e,"SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX",{enumerable:!0,get:function(){return Yxe.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX}})});var gK=b(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});xk.setup=Jxe;var Kxe=ni(),Zxe=Kc(),Tk=class{constructor(e,r,n){this.listener=r,this.hasReturnedResult=!1,this.endpoints=[];let i;e.authority===""?i="/"+e.path:i=e.path,this.endpoints=[{addresses:[{path:i}]}]}updateResolution(){this.hasReturnedResult||(this.hasReturnedResult=!0,process.nextTick(this.listener,(0,Zxe.statusOrFromValue)(this.endpoints),{},null,""))}destroy(){this.hasReturnedResult=!1}static getDefaultAuthority(e){return"localhost"}};function Jxe(){(0,Kxe.registerResolver)("unix",Tk)}});var bK=b(Ik=>{"use strict";Object.defineProperty(Ik,"__esModule",{value:!0});Ik.setup=rwe;var _K=Z("net"),yK=Kc(),Vb=je(),wk=Wt(),SK=ni(),Xxe=zr(),EK=Rr(),Qxe=st(),ewe="ip_resolver";function vK(t){Qxe.trace(Vb.LogVerbosity.DEBUG,ewe,t)}var Ak="ipv4",Rk="ipv6",twe=443,Hb=class{constructor(e,r,n){var i;this.listener=r,this.endpoints=[],this.error=null,this.hasReturnedResult=!1,vK("Resolver constructed for target "+(0,EK.uriToString)(e));let o=[];if(!(e.scheme===Ak||e.scheme===Rk)){this.error={code:Vb.Status.UNAVAILABLE,details:`Unrecognized scheme ${e.scheme} in IP resolver`,metadata:new wk.Metadata};return}let s=e.path.split(",");for(let a of s){let c=(0,EK.splitHostPort)(a);if(c===null){this.error={code:Vb.Status.UNAVAILABLE,details:`Failed to parse ${e.scheme} address ${a}`,metadata:new wk.Metadata};return}if(e.scheme===Ak&&!(0,_K.isIPv4)(c.host)||e.scheme===Rk&&!(0,_K.isIPv6)(c.host)){this.error={code:Vb.Status.UNAVAILABLE,details:`Failed to parse ${e.scheme} address ${a}`,metadata:new wk.Metadata};return}o.push({host:c.host,port:(i=c.port)!==null&&i!==void 0?i:twe})}this.endpoints=o.map(a=>({addresses:[a]})),vK("Parsed "+e.scheme+" address list "+o.map(Xxe.subchannelAddressToString))}updateResolution(){this.hasReturnedResult||(this.hasReturnedResult=!0,process.nextTick(()=>{this.error?this.listener((0,yK.statusOrFromError)(this.error),{},null,""):this.listener((0,yK.statusOrFromValue)(this.endpoints),{},null,"")}))}destroy(){this.hasReturnedResult=!1}static getDefaultAuthority(e){return e.path.split(",")[0]}};function rwe(){(0,SK.registerResolver)(Ak,Hb),(0,SK.registerResolver)(Rk,Hb)}});var AK=b(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0});xg.RoundRobinLoadBalancer=void 0;xg.setup=cwe;var wK=aa(),sr=Ir(),Tg=Ho(),nwe=st(),iwe=je(),TK=zr(),owe=vg(),swe="round_robin";function xK(t){nwe.trace(iwe.LogVerbosity.DEBUG,swe,t)}var Wb="round_robin",Yb=class t{getLoadBalancerName(){return Wb}constructor(){}toJsonObject(){return{[Wb]:{}}}static createFromJson(e){return new t}},Ck=class{constructor(e,r=0){this.children=e,this.nextIndex=r}pick(e){let r=this.children[this.nextIndex].picker;return this.nextIndex=(this.nextIndex+1)%this.children.length,r.pick(e)}peekNextEndpoint(){return this.children[this.nextIndex].endpoint}};function awe(t,e){return[...t.slice(e),...t.slice(0,e)]}var Kb=class{constructor(e){this.channelControlHelper=e,this.children=[],this.currentState=sr.ConnectivityState.IDLE,this.currentReadyPicker=null,this.updatesPaused=!1,this.lastError=null,this.childChannelControlHelper=(0,wK.createChildChannelControlHelper)(e,{updateState:(r,n,i)=>{this.currentState===sr.ConnectivityState.READY&&r!==sr.ConnectivityState.READY&&this.channelControlHelper.requestReresolution(),i&&(this.lastError=i),this.calculateAndUpdateState()}})}countChildrenWithState(e){return this.children.filter(r=>r.getConnectivityState()===e).length}calculateAndUpdateState(){if(!this.updatesPaused){if(this.countChildrenWithState(sr.ConnectivityState.READY)>0){let e=this.children.filter(n=>n.getConnectivityState()===sr.ConnectivityState.READY),r=0;if(this.currentReadyPicker!==null){let n=this.currentReadyPicker.peekNextEndpoint();r=e.findIndex(i=>(0,TK.endpointEqual)(i.getEndpoint(),n)),r<0&&(r=0)}this.updateState(sr.ConnectivityState.READY,new Ck(e.map(n=>({endpoint:n.getEndpoint(),picker:n.getPicker()})),r),null)}else if(this.countChildrenWithState(sr.ConnectivityState.CONNECTING)>0)this.updateState(sr.ConnectivityState.CONNECTING,new Tg.QueuePicker(this),null);else if(this.countChildrenWithState(sr.ConnectivityState.TRANSIENT_FAILURE)>0){let e=`round_robin: No connection established. Last error: ${this.lastError}`;this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker({details:e}),e)}else this.updateState(sr.ConnectivityState.IDLE,new Tg.QueuePicker(this),null);for(let e of this.children)e.getConnectivityState()===sr.ConnectivityState.IDLE&&e.exitIdle()}}updateState(e,r,n){xK(sr.ConnectivityState[this.currentState]+" -> "+sr.ConnectivityState[e]),e===sr.ConnectivityState.READY?this.currentReadyPicker=r:this.currentReadyPicker=null,this.currentState=e,this.channelControlHelper.updateState(e,r,n)}resetSubchannelList(){for(let e of this.children)e.destroy();this.children=[]}updateAddressList(e,r,n,i){if(!(r instanceof Yb))return!1;if(!e.ok)return this.children.length===0&&this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker(e.error),e.error.details),!0;let o=Math.random()*e.value.length|0,s=awe(e.value,o);if(this.resetSubchannelList(),s.length===0){let a=`No addresses resolved. Resolution note: ${i}`;this.updateState(sr.ConnectivityState.TRANSIENT_FAILURE,new Tg.UnavailablePicker({details:a}),a)}xK("Connect to endpoint list "+s.map(TK.endpointToString)),this.updatesPaused=!0,this.children=s.map(a=>new owe.LeafLoadBalancer(a,this.childChannelControlHelper,n,i));for(let a of this.children)a.startConnecting();return this.updatesPaused=!1,this.calculateAndUpdateState(),!0}exitIdle(){}resetBackoff(){}destroy(){this.resetSubchannelList()}getTypeName(){return Wb}};xg.RoundRobinLoadBalancer=Kb;function cwe(){(0,wK.registerLoadBalancerType)(Wb,Kb,Yb)}});var CK=b(ml=>{"use strict";var Pk;Object.defineProperty(ml,"__esModule",{value:!0});ml.OutlierDetectionLoadBalancer=ml.OutlierDetectionLoadBalancingConfig=void 0;ml.setup=Swe;var lwe=Ir(),RK=je(),hl=_g(),IK=bk(),uwe=aa(),dwe=gv(),fwe=Ho(),Ok=zr(),pwe=mg(),hwe=st(),mwe="outlier_detection";function Jt(t){hwe.trace(RK.LogVerbosity.DEBUG,mwe,t)}var $k="outlier_detection",gwe=((Pk=process.env.GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION)!==null&&Pk!==void 0?Pk:"true")==="true",_we={stdev_factor:1900,enforcement_percentage:100,minimum_hosts:5,request_volume:100},ywe={threshold:85,enforcement_percentage:100,minimum_hosts:5,request_volume:50};function Ad(t,e,r,n){if(e in t&&t[e]!==void 0&&typeof t[e]!==r){let i=n?`${n}.${e}`:e;throw new Error(`outlier detection config ${i} parse error: expected ${r}, got ${typeof t[e]}`)}}function Nk(t,e,r){let n=r?`${r}.${e}`:e;if(e in t&&t[e]!==void 0){if(!(0,hl.isDuration)(t[e]))throw new Error(`outlier detection config ${n} parse error: expected Duration, got ${typeof t[e]}`);if(!(t[e].seconds>=0&&t[e].seconds<=315576e6&&t[e].nanos>=0&&t[e].nanos<=999999999))throw new Error(`outlier detection config ${n} parse error: values out of range for non-negative Duaration`)}}function Zb(t,e,r){let n=r?`${r}.${e}`:e;if(Ad(t,e,"number",r),e in t&&t[e]!==void 0&&!(t[e]>=0&&t[e]<=100))throw new Error(`outlier detection config ${n} parse error: value out of range for percentage (0-100)`)}var wg=class t{constructor(e,r,n,i,o,s,a){if(this.childPolicy=a,a.getLoadBalancerName()==="pick_first")throw new Error("outlier_detection LB policy cannot have a pick_first child policy");this.intervalMs=e??1e4,this.baseEjectionTimeMs=r??3e4,this.maxEjectionTimeMs=n??3e5,this.maxEjectionPercent=i??10,this.successRateEjection=o?Object.assign(Object.assign({},_we),o):null,this.failurePercentageEjection=s?Object.assign(Object.assign({},ywe),s):null}getLoadBalancerName(){return $k}toJsonObject(){var e,r;return{outlier_detection:{interval:(0,hl.msToDuration)(this.intervalMs),base_ejection_time:(0,hl.msToDuration)(this.baseEjectionTimeMs),max_ejection_time:(0,hl.msToDuration)(this.maxEjectionTimeMs),max_ejection_percent:this.maxEjectionPercent,success_rate_ejection:(e=this.successRateEjection)!==null&&e!==void 0?e:void 0,failure_percentage_ejection:(r=this.failurePercentageEjection)!==null&&r!==void 0?r:void 0,child_policy:[this.childPolicy.toJsonObject()]}}}getIntervalMs(){return this.intervalMs}getBaseEjectionTimeMs(){return this.baseEjectionTimeMs}getMaxEjectionTimeMs(){return this.maxEjectionTimeMs}getMaxEjectionPercent(){return this.maxEjectionPercent}getSuccessRateEjectionConfig(){return this.successRateEjection}getFailurePercentageEjectionConfig(){return this.failurePercentageEjection}getChildPolicy(){return this.childPolicy}static createFromJson(e){var r;if(Nk(e,"interval"),Nk(e,"base_ejection_time"),Nk(e,"max_ejection_time"),Zb(e,"max_ejection_percent"),"success_rate_ejection"in e&&e.success_rate_ejection!==void 0){if(typeof e.success_rate_ejection!="object")throw new Error("outlier detection config success_rate_ejection must be an object");Ad(e.success_rate_ejection,"stdev_factor","number","success_rate_ejection"),Zb(e.success_rate_ejection,"enforcement_percentage","success_rate_ejection"),Ad(e.success_rate_ejection,"minimum_hosts","number","success_rate_ejection"),Ad(e.success_rate_ejection,"request_volume","number","success_rate_ejection")}if("failure_percentage_ejection"in e&&e.failure_percentage_ejection!==void 0){if(typeof e.failure_percentage_ejection!="object")throw new Error("outlier detection config failure_percentage_ejection must be an object");Zb(e.failure_percentage_ejection,"threshold","failure_percentage_ejection"),Zb(e.failure_percentage_ejection,"enforcement_percentage","failure_percentage_ejection"),Ad(e.failure_percentage_ejection,"minimum_hosts","number","failure_percentage_ejection"),Ad(e.failure_percentage_ejection,"request_volume","number","failure_percentage_ejection")}if(!("child_policy"in e)||!Array.isArray(e.child_policy))throw new Error("outlier detection config child_policy must be an array");let n=(0,uwe.selectLbConfigFromList)(e.child_policy);if(!n)throw new Error("outlier detection config child_policy: no valid recognized policy found");return new t(e.interval?(0,hl.durationToMs)(e.interval):null,e.base_ejection_time?(0,hl.durationToMs)(e.base_ejection_time):null,e.max_ejection_time?(0,hl.durationToMs)(e.max_ejection_time):null,(r=e.max_ejection_percent)!==null&&r!==void 0?r:null,e.success_rate_ejection,e.failure_percentage_ejection,n)}};ml.OutlierDetectionLoadBalancingConfig=wg;var Mk=class extends pwe.BaseSubchannelWrapper{constructor(e,r){super(e),this.mapEntry=r,this.refCount=0}ref(){this.child.ref(),this.refCount+=1}unref(){if(this.child.unref(),this.refCount-=1,this.refCount<=0&&this.mapEntry){let e=this.mapEntry.subchannelWrappers.indexOf(this);e>=0&&this.mapEntry.subchannelWrappers.splice(e,1)}}eject(){this.setHealthy(!1)}uneject(){this.setHealthy(!0)}getMapEntry(){return this.mapEntry}getWrappedSubchannel(){return this.child}};function kk(){return{success:0,failure:0}}var Dk=class{constructor(){this.activeBucket=kk(),this.inactiveBucket=kk()}addSuccess(){this.activeBucket.success+=1}addFailure(){this.activeBucket.failure+=1}switchBuckets(){this.inactiveBucket=this.activeBucket,this.activeBucket=kk()}getLastSuccesses(){return this.inactiveBucket.success}getLastFailures(){return this.inactiveBucket.failure}},Lk=class{constructor(e,r){this.wrappedPicker=e,this.countCalls=r}pick(e){let r=this.wrappedPicker.pick(e);if(r.pickResultType===fwe.PickResultType.COMPLETE){let n=r.subchannel,i=n.getMapEntry();if(i){let o=r.onCallEnded;return this.countCalls&&(o=(s,a,c)=>{var l;s===RK.Status.OK?i.counter.addSuccess():i.counter.addFailure(),(l=r.onCallEnded)===null||l===void 0||l.call(r,s,a,c)}),Object.assign(Object.assign({},r),{subchannel:n.getWrappedSubchannel(),onCallEnded:o})}else return Object.assign(Object.assign({},r),{subchannel:n.getWrappedSubchannel()})}else return r}},Jb=class{constructor(e){this.entryMap=new Ok.EndpointMap,this.latestConfig=null,this.timerStartTime=null,this.childBalancer=new dwe.ChildLoadBalancerHandler((0,IK.createChildChannelControlHelper)(e,{createSubchannel:(r,n)=>{let i=e.createSubchannel(r,n),o=this.entryMap.getForSubchannelAddress(r),s=new Mk(i,o);return o?.currentEjectionTimestamp!==null&&s.eject(),o?.subchannelWrappers.push(s),s},updateState:(r,n,i)=>{r===lwe.ConnectivityState.READY?e.updateState(r,new Lk(n,this.isCountingEnabled()),i):e.updateState(r,n,i)}})),this.ejectionTimer=setInterval(()=>{},0),clearInterval(this.ejectionTimer)}isCountingEnabled(){return this.latestConfig!==null&&(this.latestConfig.getSuccessRateEjectionConfig()!==null||this.latestConfig.getFailurePercentageEjectionConfig()!==null)}getCurrentEjectionPercent(){let e=0;for(let r of this.entryMap.values())r.currentEjectionTimestamp!==null&&(e+=1);return e*100/this.entryMap.size}runSuccessRateCheck(e){if(!this.latestConfig)return;let r=this.latestConfig.getSuccessRateEjectionConfig();if(!r)return;Jt("Running success rate check");let n=r.request_volume,i=0,o=[];for(let[d,f]of this.entryMap.entries()){let p=f.counter.getLastSuccesses(),h=f.counter.getLastFailures();Jt("Stats for "+(0,Ok.endpointToString)(d)+": successes="+p+" failures="+h+" targetRequestVolume="+n),p+h>=n&&(i+=1,o.push(p/(p+h)))}if(Jt("Found "+i+" success rate candidates; currentEjectionPercent="+this.getCurrentEjectionPercent()+" successRates=["+o+"]"),i<r.minimum_hosts)return;let s=o.reduce((d,f)=>d+f)/o.length,a=0;for(let d of o){let f=d-s;a+=f*f}let c=a/o.length,l=Math.sqrt(c),u=s-l*(r.stdev_factor/1e3);Jt("stdev="+l+" ejectionThreshold="+u);for(let[d,f]of this.entryMap.entries()){if(this.getCurrentEjectionPercent()>=this.latestConfig.getMaxEjectionPercent())break;let p=f.counter.getLastSuccesses(),h=f.counter.getLastFailures();if(p+h<n)continue;let m=p/(p+h);if(Jt("Checking candidate "+d+" successRate="+m),m<u){let y=Math.random()*100;Jt("Candidate "+d+" randomNumber="+y+" enforcement_percentage="+r.enforcement_percentage),y<r.enforcement_percentage&&(Jt("Ejecting candidate "+d),this.eject(f,e))}}}runFailurePercentageCheck(e){if(!this.latestConfig)return;let r=this.latestConfig.getFailurePercentageEjectionConfig();if(!r)return;Jt("Running failure percentage check. threshold="+r.threshold+" request volume threshold="+r.request_volume);let n=0;for(let i of this.entryMap.values()){let o=i.counter.getLastSuccesses(),s=i.counter.getLastFailures();o+s>=r.request_volume&&(n+=1)}if(!(n<r.minimum_hosts))for(let[i,o]of this.entryMap.entries()){if(this.getCurrentEjectionPercent()>=this.latestConfig.getMaxEjectionPercent())break;let s=o.counter.getLastSuccesses(),a=o.counter.getLastFailures();if(Jt("Candidate successes="+s+" failures="+a),s+a<r.request_volume)continue;if(a*100/(a+s)>r.threshold){let l=Math.random()*100;Jt("Candidate "+i+" randomNumber="+l+" enforcement_percentage="+r.enforcement_percentage),l<r.enforcement_percentage&&(Jt("Ejecting candidate "+i),this.eject(o,e))}}}eject(e,r){e.currentEjectionTimestamp=new Date,e.ejectionTimeMultiplier+=1;for(let n of e.subchannelWrappers)n.eject()}uneject(e){e.currentEjectionTimestamp=null;for(let r of e.subchannelWrappers)r.uneject()}switchAllBuckets(){for(let e of this.entryMap.values())e.counter.switchBuckets()}startTimer(e){var r,n;this.ejectionTimer=setTimeout(()=>this.runChecks(),e),(n=(r=this.ejectionTimer).unref)===null||n===void 0||n.call(r)}runChecks(){let e=new Date;if(Jt("Ejection timer running"),this.switchAllBuckets(),!!this.latestConfig){this.timerStartTime=e,this.startTimer(this.latestConfig.getIntervalMs()),this.runSuccessRateCheck(e),this.runFailurePercentageCheck(e);for(let[r,n]of this.entryMap.entries())if(n.currentEjectionTimestamp===null)n.ejectionTimeMultiplier>0&&(n.ejectionTimeMultiplier-=1);else{let i=this.latestConfig.getBaseEjectionTimeMs(),o=this.latestConfig.getMaxEjectionTimeMs(),s=new Date(n.currentEjectionTimestamp.getTime());s.setMilliseconds(s.getMilliseconds()+Math.min(i*n.ejectionTimeMultiplier,Math.max(i,o))),s<new Date&&(Jt("Unejecting "+r),this.uneject(n))}}}updateAddressList(e,r,n,i){if(!(r instanceof wg))return!1;if(Jt("Received update with config: "+JSON.stringify(r.toJsonObject(),void 0,2)),e.ok){for(let s of e.value)this.entryMap.has(s)||(Jt("Adding map entry for "+(0,Ok.endpointToString)(s)),this.entryMap.set(s,{counter:new Dk,currentEjectionTimestamp:null,ejectionTimeMultiplier:0,subchannelWrappers:[]}));this.entryMap.deleteMissing(e.value)}let o=r.getChildPolicy();if(this.childBalancer.updateAddressList(e,o,n,i),r.getSuccessRateEjectionConfig()||r.getFailurePercentageEjectionConfig())if(this.timerStartTime){Jt("Previous timer existed. Replacing timer"),clearTimeout(this.ejectionTimer);let s=r.getIntervalMs()-(new Date().getTime()-this.timerStartTime.getTime());this.startTimer(s)}else Jt("Starting new timer"),this.timerStartTime=new Date,this.startTimer(r.getIntervalMs()),this.switchAllBuckets();else{Jt("Counting disabled. Cancelling timer."),this.timerStartTime=null,clearTimeout(this.ejectionTimer);for(let s of this.entryMap.values())this.uneject(s),s.ejectionTimeMultiplier=0}return this.latestConfig=r,!0}exitIdle(){this.childBalancer.exitIdle()}resetBackoff(){this.childBalancer.resetBackoff()}destroy(){clearTimeout(this.ejectionTimer),this.childBalancer.destroy()}getTypeName(){return $k}};ml.OutlierDetectionLoadBalancer=Jb;function Swe(){gwe&&(0,IK.registerLoadBalancerType)($k,Jb,wg)}});var PK=b(Qb=>{"use strict";Object.defineProperty(Qb,"__esModule",{value:!0});Qb.PriorityQueue=void 0;var Rd=0,Uk=t=>Math.floor(t/2),Xb=t=>t*2+1,Ag=t=>t*2+2,Fk=class{constructor(e=(r,n)=>r>n){this.comparator=e,this.heap=[]}size(){return this.heap.length}isEmpty(){return this.size()==0}peek(){return this.heap[Rd]}push(...e){return e.forEach(r=>{this.heap.push(r),this.siftUp()}),this.size()}pop(){let e=this.peek(),r=this.size()-1;return r>Rd&&this.swap(Rd,r),this.heap.pop(),this.siftDown(),e}replace(e){let r=this.peek();return this.heap[Rd]=e,this.siftDown(),r}greater(e,r){return this.comparator(this.heap[e],this.heap[r])}swap(e,r){[this.heap[e],this.heap[r]]=[this.heap[r],this.heap[e]]}siftUp(){let e=this.size()-1;for(;e>Rd&&this.greater(e,Uk(e));)this.swap(e,Uk(e)),e=Uk(e)}siftDown(){let e=Rd;for(;Xb(e)<this.size()&&this.greater(Xb(e),e)||Ag(e)<this.size()&&this.greater(Ag(e),e);){let r=Ag(e)<this.size()&&this.greater(Ag(e),Xb(e))?Ag(e):Xb(e);this.swap(e,r),e=r}}};Qb.PriorityQueue=Fk});var DK=b(Ig=>{"use strict";Object.defineProperty(Ig,"__esModule",{value:!0});Ig.WeightedRoundRobinLoadBalancingConfig=void 0;Ig.setup=Pwe;var Xt=Ir(),Ewe=je(),mn=_g(),kK=aa(),vwe=vg(),bwe=st(),MK=Lb(),Id=Ho(),Twe=PK(),OK=zr(),xwe="weighted_round_robin";function Bk(t){bwe.trace(Ewe.LogVerbosity.DEBUG,xwe,t)}var Gk="weighted_round_robin",wwe=1e4,Awe=1e4,Rwe=3*6e4,Iwe=1e3,Cwe=1;function NK(t,e,r){if(e in t&&t[e]!==void 0&&typeof t[e]!==r)throw new Error(`weighted round robin config ${e} parse error: expected ${r}, got ${typeof t[e]}`)}function eT(t,e){if(e in t&&t[e]!==void 0&&t[e]!==null){let r;if((0,mn.isDuration)(t[e]))r=t[e];else if((0,mn.isDurationMessage)(t[e]))r=(0,mn.durationMessageToDuration)(t[e]);else if(typeof t[e]=="string"){let n=(0,mn.parseDuration)(t[e]);if(!n)throw new Error(`weighted round robin config ${e}: failed to parse duration string ${t[e]}`);r=n}else throw new Error(`weighted round robin config ${e}: expected duration, got ${typeof t[e]}`);return(0,mn.durationToMs)(r)}return null}var Rg=class t{constructor(e,r,n,i,o,s){this.enableOobLoadReport=e??!1,this.oobLoadReportingPeriodMs=r??wwe,this.blackoutPeriodMs=n??Awe,this.weightExpirationPeriodMs=i??Rwe,this.weightUpdatePeriodMs=Math.max(o??Iwe,100),this.errorUtilizationPenalty=s??Cwe}getLoadBalancerName(){return Gk}toJsonObject(){return{enable_oob_load_report:this.enableOobLoadReport,oob_load_reporting_period:(0,mn.durationToString)((0,mn.msToDuration)(this.oobLoadReportingPeriodMs)),blackout_period:(0,mn.durationToString)((0,mn.msToDuration)(this.blackoutPeriodMs)),weight_expiration_period:(0,mn.durationToString)((0,mn.msToDuration)(this.weightExpirationPeriodMs)),weight_update_period:(0,mn.durationToString)((0,mn.msToDuration)(this.weightUpdatePeriodMs)),error_utilization_penalty:this.errorUtilizationPenalty}}static createFromJson(e){if(NK(e,"enable_oob_load_report","boolean"),NK(e,"error_utilization_penalty","number"),e.error_utilization_penalty<0)throw new Error("weighted round robin config error_utilization_penalty < 0");return new t(e.enable_oob_load_report,eT(e,"oob_load_reporting_period"),eT(e,"blackout_period"),eT(e,"weight_expiration_period"),eT(e,"weight_update_period"),e.error_utilization_penalty)}getEnableOobLoadReport(){return this.enableOobLoadReport}getOobLoadReportingPeriodMs(){return this.oobLoadReportingPeriodMs}getBlackoutPeriodMs(){return this.blackoutPeriodMs}getWeightExpirationPeriodMs(){return this.weightExpirationPeriodMs}getWeightUpdatePeriodMs(){return this.weightUpdatePeriodMs}getErrorUtilizationPenalty(){return this.errorUtilizationPenalty}};Ig.WeightedRoundRobinLoadBalancingConfig=Rg;var jk=class{constructor(e,r){this.metricsHandler=r,this.queue=new Twe.PriorityQueue((o,s)=>o.deadline<s.deadline);let n=e.filter(o=>o.weight>0),i;if(n.length<2)i=1;else{let o=0;for(let{weight:s}of n)o+=s;i=o/n.length}for(let o of e){let s=o.weight>0?1/o.weight:i;this.queue.push({endpointName:o.endpointName,picker:o.picker,period:s,deadline:Math.random()*s})}}pick(e){let r=this.queue.pop();this.queue.push(Object.assign(Object.assign({},r),{deadline:r.deadline+r.period}));let n=r.picker.pick(e);if(n.pickResultType===Id.PickResultType.COMPLETE){if(this.metricsHandler)return Object.assign(Object.assign({},n),{onCallEnded:(0,MK.createMetricsReader)(i=>this.metricsHandler(i,r.endpointName),n.onCallEnded)});{let i=n.subchannel;return Object.assign(Object.assign({},n),{subchannel:i.getWrappedSubchannel()})}}else return n}},zk=class{constructor(e){this.channelControlHelper=e,this.latestConfig=null,this.children=new Map,this.currentState=Xt.ConnectivityState.IDLE,this.updatesPaused=!1,this.lastError=null,this.weightUpdateTimer=null}countChildrenWithState(e){let r=0;for(let n of this.children.values())n.child.getConnectivityState()===e&&(r+=1);return r}updateWeight(e,r){var n,i;let o=r.rps_fractional,s=r.application_utilization;s>0&&o>0&&(s+=r.eps/o*((i=(n=this.latestConfig)===null||n===void 0?void 0:n.getErrorUtilizationPenalty())!==null&&i!==void 0?i:0));let a=s===0?0:o/s;if(a===0)return;let c=new Date;e.nonEmptySince===null&&(e.nonEmptySince=c),e.lastUpdated=c,e.weight=a}getWeight(e){if(!this.latestConfig)return 0;let r=new Date().getTime();if(r-e.lastUpdated.getTime()>=this.latestConfig.getWeightExpirationPeriodMs())return e.nonEmptySince=null,0;let n=this.latestConfig.getBlackoutPeriodMs();return n>0&&(e.nonEmptySince===null||r-e.nonEmptySince.getTime()<n)?0:e.weight}calculateAndUpdateState(){if(!(this.updatesPaused||!this.latestConfig)){if(this.countChildrenWithState(Xt.ConnectivityState.READY)>0){let e=[];for(let[n,i]of this.children)i.child.getConnectivityState()===Xt.ConnectivityState.READY&&e.push({endpointName:n,picker:i.child.getPicker(),weight:this.getWeight(i)});Bk("Created picker with weights: "+e.map(n=>n.endpointName+":"+n.weight).join(","));let r;this.latestConfig.getEnableOobLoadReport()?r=null:r=(n,i)=>{let o=this.children.get(i);o&&this.updateWeight(o,n)},this.updateState(Xt.ConnectivityState.READY,new jk(e,r),null)}else if(this.countChildrenWithState(Xt.ConnectivityState.CONNECTING)>0)this.updateState(Xt.ConnectivityState.CONNECTING,new Id.QueuePicker(this),null);else if(this.countChildrenWithState(Xt.ConnectivityState.TRANSIENT_FAILURE)>0){let e=`weighted_round_robin: No connection established. Last error: ${this.lastError}`;this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker({details:e}),e)}else this.updateState(Xt.ConnectivityState.IDLE,new Id.QueuePicker(this),null);for(let{child:e}of this.children.values())e.getConnectivityState()===Xt.ConnectivityState.IDLE&&e.exitIdle()}}updateState(e,r,n){Bk(Xt.ConnectivityState[this.currentState]+" -> "+Xt.ConnectivityState[e]),this.currentState=e,this.channelControlHelper.updateState(e,r,n)}updateAddressList(e,r,n,i){var o,s;if(!(r instanceof Rg))return!1;if(!e.ok)return this.children.size===0&&this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker(e.error),e.error.details),!0;if(e.value.length===0){let l=`No addresses resolved. Resolution note: ${i}`;return this.updateState(Xt.ConnectivityState.TRANSIENT_FAILURE,new Id.UnavailablePicker({details:l}),l),!1}Bk("Connect to endpoint list "+e.value.map(OK.endpointToString));let a=new Date,c=new Set;this.updatesPaused=!0,this.latestConfig=r;for(let l of e.value){let u=(0,OK.endpointToString)(l);c.add(u);let d=this.children.get(u);d||(d={child:new vwe.LeafLoadBalancer(l,(0,kK.createChildChannelControlHelper)(this.channelControlHelper,{updateState:(f,p,h)=>{this.currentState===Xt.ConnectivityState.READY&&f!==Xt.ConnectivityState.READY&&this.channelControlHelper.requestReresolution(),f===Xt.ConnectivityState.READY&&(d.nonEmptySince=null),h&&(this.lastError=h),this.calculateAndUpdateState()},createSubchannel:(f,p)=>{let h=this.channelControlHelper.createSubchannel(f,p);return d?.oobMetricsListener?new MK.OrcaOobMetricsSubchannelWrapper(h,d.oobMetricsListener,this.latestConfig.getOobLoadReportingPeriodMs()):h}}),n,i),lastUpdated:a,nonEmptySince:null,weight:0,oobMetricsListener:null},this.children.set(u,d)),r.getEnableOobLoadReport()?d.oobMetricsListener=f=>{this.updateWeight(d,f)}:d.oobMetricsListener=null}for(let[l,u]of this.children)c.has(l)?u.child.startConnecting():(u.child.destroy(),this.children.delete(l));return this.updatesPaused=!1,this.calculateAndUpdateState(),this.weightUpdateTimer&&clearInterval(this.weightUpdateTimer),this.weightUpdateTimer=(s=(o=setInterval(()=>{this.currentState===Xt.ConnectivityState.READY&&this.calculateAndUpdateState()},r.getWeightUpdatePeriodMs())).unref)===null||s===void 0?void 0:s.call(o),!0}exitIdle(){}resetBackoff(){}destroy(){for(let e of this.children.values())e.child.destroy();this.children.clear(),this.weightUpdateTimer&&clearInterval(this.weightUpdateTimer)}getTypeName(){return Gk}};function Pwe(){(0,kK.registerLoadBalancerType)(Gk,zk,Rg)}});var Cg=b(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.experimental=he.ServerMetricRecorder=he.ServerInterceptingCall=he.ResponderBuilder=he.ServerListenerBuilder=he.addAdminServicesToServer=he.getChannelzHandlers=he.getChannelzServiceDefinition=he.InterceptorConfigurationError=he.InterceptingCall=he.RequesterBuilder=he.ListenerBuilder=he.StatusBuilder=he.getClientChannel=he.ServerCredentials=he.Server=he.setLogVerbosity=he.setLogger=he.load=he.loadObject=he.CallCredentials=he.ChannelCredentials=he.waitForClientReady=he.closeClient=he.Channel=he.makeGenericClientConstructor=he.makeClientConstructor=he.loadPackageDefinition=he.Client=he.compressionAlgorithms=he.propagate=he.connectivityState=he.status=he.logVerbosity=he.Metadata=he.credentials=void 0;var tT=ov();Object.defineProperty(he,"CallCredentials",{enumerable:!0,get:function(){return tT.CallCredentials}});var Owe=OP();Object.defineProperty(he,"Channel",{enumerable:!0,get:function(){return Owe.ChannelImplementation}});var Nwe=YO();Object.defineProperty(he,"compressionAlgorithms",{enumerable:!0,get:function(){return Nwe.CompressionAlgorithms}});var kwe=Ir();Object.defineProperty(he,"connectivityState",{enumerable:!0,get:function(){return kwe.ConnectivityState}});var rT=Wu();Object.defineProperty(he,"ChannelCredentials",{enumerable:!0,get:function(){return rT.ChannelCredentials}});var LK=PP();Object.defineProperty(he,"Client",{enumerable:!0,get:function(){return LK.Client}});var qk=je();Object.defineProperty(he,"logVerbosity",{enumerable:!0,get:function(){return qk.LogVerbosity}});Object.defineProperty(he,"status",{enumerable:!0,get:function(){return qk.Status}});Object.defineProperty(he,"propagate",{enumerable:!0,get:function(){return qk.Propagate}});var $K=st(),Vk=wv();Object.defineProperty(he,"loadPackageDefinition",{enumerable:!0,get:function(){return Vk.loadPackageDefinition}});Object.defineProperty(he,"makeClientConstructor",{enumerable:!0,get:function(){return Vk.makeClientConstructor}});Object.defineProperty(he,"makeGenericClientConstructor",{enumerable:!0,get:function(){return Vk.makeClientConstructor}});var Mwe=Wt();Object.defineProperty(he,"Metadata",{enumerable:!0,get:function(){return Mwe.Metadata}});var Dwe=nK();Object.defineProperty(he,"Server",{enumerable:!0,get:function(){return Dwe.Server}});var Lwe=Mb();Object.defineProperty(he,"ServerCredentials",{enumerable:!0,get:function(){return Lwe.ServerCredentials}});var $we=iK();Object.defineProperty(he,"StatusBuilder",{enumerable:!0,get:function(){return $we.StatusBuilder}});he.credentials={combineChannelCredentials:(t,...e)=>e.reduce((r,n)=>r.compose(n),t),combineCallCredentials:(t,...e)=>e.reduce((r,n)=>r.compose(n),t),createInsecure:rT.ChannelCredentials.createInsecure,createSsl:rT.ChannelCredentials.createSsl,createFromSecureContext:rT.ChannelCredentials.createFromSecureContext,createFromMetadataGenerator:tT.CallCredentials.createFromMetadataGenerator,createFromGoogleCredential:tT.CallCredentials.createFromGoogleCredential,createEmpty:tT.CallCredentials.createEmpty};var Uwe=t=>t.close();he.closeClient=Uwe;var Fwe=(t,e,r)=>t.waitForReady(e,r);he.waitForClientReady=Fwe;var Bwe=(t,e)=>{throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead")};he.loadObject=Bwe;var jwe=(t,e,r)=>{throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead")};he.load=jwe;var zwe=t=>{$K.setLogger(t)};he.setLogger=zwe;var Gwe=t=>{$K.setLoggerVerbosity(t)};he.setLogVerbosity=Gwe;var qwe=t=>LK.Client.prototype.getChannel.call(t);he.getClientChannel=qwe;var nT=RP();Object.defineProperty(he,"ListenerBuilder",{enumerable:!0,get:function(){return nT.ListenerBuilder}});Object.defineProperty(he,"RequesterBuilder",{enumerable:!0,get:function(){return nT.RequesterBuilder}});Object.defineProperty(he,"InterceptingCall",{enumerable:!0,get:function(){return nT.InterceptingCall}});Object.defineProperty(he,"InterceptorConfigurationError",{enumerable:!0,get:function(){return nT.InterceptorConfigurationError}});var UK=_a();Object.defineProperty(he,"getChannelzServiceDefinition",{enumerable:!0,get:function(){return UK.getChannelzServiceDefinition}});Object.defineProperty(he,"getChannelzHandlers",{enumerable:!0,get:function(){return UK.getChannelzHandlers}});var Vwe=Ev();Object.defineProperty(he,"addAdminServicesToServer",{enumerable:!0,get:function(){return Vwe.addAdminServicesToServer}});var Hk=uk();Object.defineProperty(he,"ServerListenerBuilder",{enumerable:!0,get:function(){return Hk.ServerListenerBuilder}});Object.defineProperty(he,"ResponderBuilder",{enumerable:!0,get:function(){return Hk.ResponderBuilder}});Object.defineProperty(he,"ServerInterceptingCall",{enumerable:!0,get:function(){return Hk.ServerInterceptingCall}});var Hwe=Lb();Object.defineProperty(he,"ServerMetricRecorder",{enumerable:!0,get:function(){return Hwe.ServerMetricRecorder}});var Wwe=bk();he.experimental=Wwe;var Ywe=pN(),Kwe=gK(),Zwe=bK(),Jwe=vg(),Xwe=AK(),Qwe=CK(),eAe=DK(),tAe=_a();Ywe.setup(),Kwe.setup(),Zwe.setup(),Jwe.setup(),Xwe.setup(),Qwe.setup(),eAe.setup(),tAe.setup()});var FK=b(iT=>{"use strict";Object.defineProperty(iT,"__esModule",{value:!0});iT.createServiceClientConstructor=void 0;var rAe=Cg();function nAe(t,e){let r={export:{path:t,requestStream:!1,responseStream:!1,requestSerialize:n=>n,requestDeserialize:n=>n,responseSerialize:n=>n,responseDeserialize:n=>n}};return rAe.makeGenericClientConstructor(r,e)}iT.createServiceClientConstructor=nAe});var Pg=b(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.createOtlpGrpcExporterTransport=zn.GrpcExporterTransport=zn.createEmptyMetadata=zn.createSslCredentials=zn.createInsecureCredentials=void 0;var iAe=NH(),BK=`OTel-OTLP-Exporter-JavaScript/${iAe.VERSION}`;function oAe(t){return t?`${t} ${BK}`:BK}var sAe=0,aAe=2;function cAe(t){return t==="gzip"?aAe:sAe}function lAe(){let{credentials:t}=Cg();return t.createInsecure()}zn.createInsecureCredentials=lAe;function uAe(t,e,r){let{credentials:n}=Cg();return n.createSsl(t,e,r)}zn.createSslCredentials=uAe;function dAe(){let{Metadata:t}=Cg();return new t}zn.createEmptyMetadata=dAe;var oT=class{_client;_metadata;_parameters;constructor(e){this._parameters=e}shutdown(){this._client?.close()}send(e,r){let n=Buffer.from(e);if(this._client==null){let{createServiceClientConstructor:i}=FK();try{this._metadata=this._parameters.metadata()}catch(s){return Promise.resolve({status:"failure",error:s})}let o=i(this._parameters.grpcPath,this._parameters.grpcName);try{this._client=new o(this._parameters.address,this._parameters.credentials(),{"grpc.default_compression_algorithm":cAe(this._parameters.compression),"grpc.primary_user_agent":oAe(this._parameters.userAgent)})}catch(s){return Promise.resolve({status:"failure",error:s})}}return new Promise(i=>{let o=Date.now()+r;if(this._metadata==null)return i({error:new Error("metadata was null"),status:"failure"});this._client.export(n,this._metadata,{deadline:o},(s,a)=>{i(s?{status:"failure",error:s}:{data:a,status:"success"})})})}};zn.GrpcExporterTransport=oT;function fAe(t){return new oT(t)}zn.createOtlpGrpcExporterTransport=fAe});var VK=b(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.getOtlpGrpcDefaultConfiguration=wa.mergeOtlpGrpcConfigurationWithDefaults=wa.validateAndNormalizeUrl=void 0;var GK=(XE(),wr(JE)),Og=Pg(),pAe=Z("url"),jK=(Fe(),wr(Fc));function qK(t){t=t.trim(),t.match(/^([\w]{1,8}):\/\//)||(t=`https://${t}`);let r=new pAe.URL(t);return r.protocol==="unix:"?t:(r.pathname&&r.pathname!=="/"&&jK.diag.warn("URL path should not be set when using grpc, the path part of the URL will be ignored."),r.protocol!==""&&!r.protocol?.match(/^(http)s?:$/)&&jK.diag.warn("URL protocol should be http(s)://. Using http://."),r.host)}wa.validateAndNormalizeUrl=qK;function zK(t,e){for(let[r,n]of Object.entries(e.getMap()))t.get(r).length<1&&t.set(r,n)}function hAe(t,e,r){let n=t.url??e.url??r.url;return{...(0,GK.mergeOtlpSharedConfigurationWithDefaults)(t,e,r),metadata:()=>{let i=r.metadata();return zK(i,t.metadata?.().clone()??(0,Og.createEmptyMetadata)()),zK(i,e.metadata?.()??(0,Og.createEmptyMetadata)()),i},url:qK(n),credentials:t.credentials??e.credentials?.(n)??r.credentials(n),userAgent:t.userAgent}}wa.mergeOtlpGrpcConfigurationWithDefaults=hAe;function mAe(){return{...(0,GK.getSharedConfigurationDefaults)(),metadata:()=>(0,Og.createEmptyMetadata)(),url:"http://localhost:4317",credentials:t=>t.startsWith("http://")?()=>(0,Og.createInsecureCredentials)():()=>(0,Og.createSslCredentials)()}}wa.getOtlpGrpcDefaultConfiguration=mAe});function HK(t){let e={};return Object.entries(t??{}).forEach(([r,n])=>{typeof n<"u"?e[r]=String(n):de.warn(`Header "${r}" has invalid value (${n}) and will be ignored`)}),e}var WK=O(()=>{"use strict";Fe()});function gAe(t,e,r){return async()=>{let n={...await r()},i={};return e!=null&&Object.assign(i,await e()),t!=null&&Object.assign(i,HK(await t())),Object.assign(i,n)}}function _Ae(t){if(t!=null)try{let e=globalThis.location?.href;return new URL(t,e).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${t}'`)}}function YK(t,e,r){return{...HE(t,e,r),headers:gAe(t.headers,e.headers,r.headers),url:_Ae(t.url)??e.url??r.url}}function KK(t,e){return{...WE(),headers:async()=>t,url:"http://localhost:4318/"+e}}var ZK=O(()=>{"use strict";Cm();WK()});function gl(t){return async e=>{let r=e==="http:",n=r?import("http"):import("https"),{Agent:i}=await n;if(r){let{ca:o,cert:s,key:a,...c}=t;return new i(c)}return new i(t)}}function JK(t,e,r){return{...YK(t,e,r),agentFactory:t.agentFactory??e.agentFactory??r.agentFactory,userAgent:t.userAgent}}function XK(t,e){return{...KK(t,e),agentFactory:gl({keepAlive:!0})}}var sT=O(()=>{"use strict";ZK()});function Wk(t){return t===429||t===502||t===503||t===504}function Yk(t){if(t==null)return;let e=Number.parseInt(t,10);if(Number.isInteger(e))return e>0?e*1e3:-1;let r=new Date(t).getTime()-Date.now();return r>=0?r:0}var QK=O(()=>{"use strict"});var eZ,tZ=O(()=>{"use strict";eZ="0.218.0"});import*as iZ from"zlib";import{Readable as yAe}from"stream";function oZ(t,e,r,n,i,o,s,a){return new Promise(c=>{let l=new URL(e);i?r["User-Agent"]=`${i} ${rZ}`:r["User-Agent"]=rZ;let d=t(l,{method:"POST",headers:r,agent:o},f=>{let p=[],h=0;f.on("data",m=>{if(h+=m.length,h>nZ){let y=new Error(`OTLP export response body exceeded size limit of ${nZ} bytes`);c({status:"failure",error:y}),f.destroy();return}p.push(m)}),f.on("end",()=>{if(f.statusCode&&f.statusCode<=299)c({status:"success",data:Buffer.concat(p)});else if(f.statusCode&&Wk(f.statusCode))c({status:"retryable",retryInMillis:Yk(f.headers["retry-after"])});else{let m=new qo(f.statusMessage,f.statusCode,Buffer.concat(p).toString());c({status:"failure",error:m})}}),f.on("error",m=>{f.statusCode&&f.statusCode<=299?c({status:"success"}):f.statusCode&&Wk(f.statusCode)?c({status:"retryable",error:m,retryInMillis:Yk(f.headers["retry-after"])}):c({status:"failure",error:m})})});d.setTimeout(a,()=>{d.destroy(),c({status:"retryable",error:new Error("Request timed out")})}),d.on("error",f=>{vAe(f)?c({status:"retryable",error:f}):c({status:"failure",error:f})}),SAe(d,n,s,f=>{c({status:"failure",error:f})})})}function SAe(t,e,r,n){let i=EAe(r);e==="gzip"&&(t.setHeader("Content-Encoding","gzip"),i=i.on("error",n).pipe(iZ.createGzip()).on("error",n)),i.pipe(t).on("error",n)}function EAe(t){let e=new yAe;return e.push(t),e.push(null),e}function vAe(t){let e=new Set(["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","EAI_AGAIN","ENOTFOUND","ENETUNREACH","EHOSTUNREACH"]);return"code"in t&&typeof t.code=="string"?e.has(t.code):!1}var rZ,nZ,sZ=O(()=>{"use strict";QK();qE();tZ();rZ=`OTel-OTLP-Exporter-JavaScript/${eZ}`,nZ=4*1024*1024});async function bAe(t){let e=t==="http:"?import("http"):import("https"),{request:r}=await e;return r}function aZ(t){return new Kk(t)}var Kk,cZ=O(()=>{"use strict";sZ();Kk=class{_utils=null;_parameters;constructor(e){this._parameters=e}async send(e,r){let{agent:n,request:i}=await this._loadUtils(),o=await this._parameters.headers();return oZ(i,this._parameters.url,o,this._parameters.compression,this._parameters.userAgent,n,e,r)}shutdown(){}async _loadUtils(){let e=this._utils;if(e===null){let r=new URL(this._parameters.url).protocol,[n,i]=await Promise.all([this._parameters.agentFactory(r),bAe(r)]);e=this._utils={agent:n,request:i}}return e}}});function AAe(){return Math.random()*(2*lZ)-lZ}function uZ(t){return new Jk(t.transport)}var Zk,TAe,xAe,wAe,lZ,Jk,dZ=O(()=>{"use strict";Fe();Zk=5,TAe=1e3,xAe=5e3,wAe=1.5,lZ=.2;Jk=class{_transport;constructor(e){this._transport=e}retry(e,r,n){return new Promise((i,o)=>{setTimeout(()=>{this._transport.send(e,r).then(i,o)},n)})}async send(e,r){let n=Zk,i=TAe,o=Date.now()+r,s=await this._transport.send(e,r);for(;s.status==="retryable"&&n>0;){n--;let a=Math.max(Math.min(i*(1+AAe()),xAe),0);i=i*wAe;let c=s.retryInMillis??a,l=o-Date.now();if(c>l)return de.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),s;de.verbose(`Scheduling export retry in ${Math.round(c)}ms`),s=await this.retry(e,l,c)}return s.status==="success"?de.verbose(`Export succeeded after ${Zk-n} retry attempts.`):s.status==="retryable"?de.info(`Export failed after maximum retry attempts (${Zk}).`):de.info(`Export failed with non-retryable error: ${s.error}`),s}shutdown(){return this._transport.shutdown()}}});function fZ(t,e){return ZE({transport:uZ({transport:aZ(t)}),serializer:e,promiseHandler:KE(t)},{timeout:t.timeoutMillis})}var pZ=O(()=>{"use strict";B0();cZ();U0();dZ()});function hZ(t){let e=ut(t);if(e!=null){if(Number.isFinite(e)&&e>0)return e;de.warn(`Configuration: ${t} is invalid, expected number greater than 0 (actual: ${e})`)}}function RAe(t){let e=hZ(`OTEL_EXPORTER_OTLP_${t}_TIMEOUT`),r=hZ("OTEL_EXPORTER_OTLP_TIMEOUT");return e??r}function mZ(t){let e=hr(t)?.trim();if(e==null||e==="none"||e==="gzip")return e;de.warn(`Configuration: ${t} is invalid, expected 'none' or 'gzip' (actual: '${e}')`)}function IAe(t){let e=mZ(`OTEL_EXPORTER_OTLP_${t}_COMPRESSION`),r=mZ("OTEL_EXPORTER_OTLP_COMPRESSION");return e??r}function aT(t){return{timeoutMillis:RAe(t),compression:IAe(t)}}var Xk=O(()=>{"use strict";bt();Fe()});import*as gZ from"fs";import*as _Z from"path";function CAe(t){let e=hr(`OTEL_EXPORTER_OTLP_${t}_HEADERS`),r=hr("OTEL_EXPORTER_OTLP_HEADERS"),n=Bc(e),i=Bc(r);if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return Object.assign({},Bc(r),Bc(e))}function PAe(t){try{return new URL(t).toString()}catch{de.warn(`Configuration: Could not parse environment-provided export URL: '${t}', falling back to undefined`);return}}function OAe(t,e){try{new URL(t)}catch{de.warn(`Configuration: Could not parse environment-provided export URL: '${t}', falling back to undefined`);return}t.endsWith("/")||(t=t+"/"),t+=e;try{new URL(t)}catch{de.warn(`Configuration: Provided URL appended with '${e}' is not a valid URL, using 'undefined' instead of '${t}'`);return}return t}function NAe(t){let e=hr("OTEL_EXPORTER_OTLP_ENDPOINT");if(e!==void 0)return OAe(e,t)}function kAe(t){let e=hr(`OTEL_EXPORTER_OTLP_${t}_ENDPOINT`);if(e!==void 0)return PAe(e)}function Qk(t,e,r){let n=hr(t),i=hr(e),o=n??i;if(o!=null)try{return gZ.readFileSync(_Z.resolve(process.cwd(),o))}catch{de.warn(r);return}else return}function MAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CLIENT_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE","Failed to read client certificate chain file")}function DAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CLIENT_KEY`,"OTEL_EXPORTER_OTLP_CLIENT_KEY","Failed to read client certificate private key file")}function LAe(t){return Qk(`OTEL_EXPORTER_OTLP_${t}_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CERTIFICATE","Failed to read root certificate file")}function yZ(t,e){return{...aT(t),url:kAe(t)??NAe(e),headers:VE(CAe(t)),agentFactory:gl({keepAlive:!0,ca:LAe(t),cert:MAe(t),key:DAe(t)})}}var SZ=O(()=>{"use strict";bt();Fe();Xk();Cm();sT()});function EZ(t){return typeof t.headers=="function"?t.headers:VE(t.headers)}var vZ=O(()=>{"use strict";Cm()});function $Ae(t){if(typeof t.httpAgentOptions=="function")return t.httpAgentOptions;let e=t.httpAgentOptions;if(t.keepAlive!=null&&(e={keepAlive:t.keepAlive,...e}),e!=null)return gl(e)}function bZ(t,e,r,n){return t.metadata&&de.warn("Metadata cannot be set when using http"),JK({url:t.url,headers:EZ(t),concurrencyLimit:t.concurrencyLimit,timeoutMillis:t.timeoutMillis,compression:t.compression,agentFactory:$Ae(t),userAgent:t.userAgent},yZ(e,r),XK(n,r))}var TZ=O(()=>{"use strict";Fe();sT();eM();SZ();vZ()});var xZ={};pr(xZ,{convertLegacyHttpOptions:()=>bZ,createOtlpHttpExportDelegate:()=>fZ,getSharedConfigurationFromEnvironment:()=>aT,httpAgentFactoryFromOptions:()=>gl});var eM=O(()=>{"use strict";sT();pZ();Xk();TZ()});var CZ=b(cT=>{"use strict";Object.defineProperty(cT,"__esModule",{value:!0});cT.getOtlpGrpcConfigurationFromEnv=void 0;var wZ=(bt(),wr(u0)),Ng=Pg(),UAe=(eM(),wr(xZ)),FAe=Z("fs"),BAe=Z("path"),RZ=(Fe(),wr(Fc));function tM(t,e){if(t!=null&&t!=="")return t;if(e!=null&&e!=="")return e}function jAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_HEADERS`]?.trim(),r=process.env.OTEL_EXPORTER_OTLP_HEADERS?.trim(),n=(0,wZ.parseKeyPairsIntoRecord)(e),i=(0,wZ.parseKeyPairsIntoRecord)(r);if(Object.keys(n).length===0&&Object.keys(i).length===0)return;let o=Object.assign({},i,n),s=(0,Ng.createEmptyMetadata)();for(let[a,c]of Object.entries(o))s.set(a,c);return s}function zAe(t){let e=jAe(t);if(e!=null)return()=>e}function GAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_ENDPOINT`]?.trim(),r=process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();return tM(e,r)}function qAe(t){let e=process.env[`OTEL_EXPORTER_OTLP_${t}_INSECURE`]?.toLowerCase().trim(),r=process.env.OTEL_EXPORTER_OTLP_INSECURE?.toLowerCase().trim();return tM(e,r)==="true"}function rM(t,e,r){let n=process.env[t]?.trim(),i=process.env[e]?.trim(),o=tM(n,i);if(o!=null)try{return FAe.readFileSync(BAe.resolve(process.cwd(),o))}catch{RZ.diag.warn(r);return}else return}function VAe(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CLIENT_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE","Failed to read client certificate chain file")}function HAe(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CLIENT_KEY`,"OTEL_EXPORTER_OTLP_CLIENT_KEY","Failed to read client certificate private key file")}function AZ(t){return rM(`OTEL_EXPORTER_OTLP_${t}_CERTIFICATE`,"OTEL_EXPORTER_OTLP_CERTIFICATE","Failed to read root certificate file")}function IZ(t){let e=HAe(t),r=VAe(t),n=AZ(t),i=e!=null&&r!=null;return n!=null&&!i?(RZ.diag.warn("Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate"),(0,Ng.createSslCredentials)(AZ(t))):(0,Ng.createSslCredentials)(n,e,r)}function WAe(t){return qAe(t)?(0,Ng.createInsecureCredentials)():IZ(t)}function YAe(t){return{...(0,UAe.getSharedConfigurationFromEnvironment)(t),metadata:zAe(t),url:GAe(t),credentials:e=>e.startsWith("http://")?()=>(0,Ng.createInsecureCredentials)():e.startsWith("https://")?()=>IZ(t):()=>WAe(t)}}cT.getOtlpGrpcConfigurationFromEnv=YAe});var OZ=b(lT=>{"use strict";Object.defineProperty(lT,"__esModule",{value:!0});lT.convertLegacyOtlpGrpcOptions=void 0;var PZ=VK(),KAe=Pg(),ZAe=CZ();function JAe(t,e){let r=t.credentials;return(0,PZ.mergeOtlpGrpcConfigurationWithDefaults)({url:t.url,metadata:()=>t.metadata??(0,KAe.createEmptyMetadata)(),compression:t.compression,timeoutMillis:t.timeoutMillis,concurrencyLimit:t.concurrencyLimit,credentials:r!=null?()=>r:void 0,userAgent:t.userAgent},(0,ZAe.getOtlpGrpcConfigurationFromEnv)(e),(0,PZ.getOtlpGrpcDefaultConfiguration)())}lT.convertLegacyOtlpGrpcOptions=JAe});var NZ=b(uT=>{"use strict";Object.defineProperty(uT,"__esModule",{value:!0});uT.createOtlpGrpcExportDelegate=void 0;var XAe=(XE(),wr(JE)),QAe=Pg();function eRe(t,e,r,n){return(0,XAe.createOtlpNetworkExportDelegate)(t,e,(0,QAe.createOtlpGrpcExporterTransport)({address:t.url,compression:t.compression,credentials:t.credentials,metadata:t.metadata,userAgent:t.userAgent,grpcName:r,grpcPath:n}))}uT.createOtlpGrpcExportDelegate=eRe});var kZ=b(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.createOtlpGrpcExportDelegate=Cd.convertLegacyOtlpGrpcOptions=void 0;var tRe=OZ();Object.defineProperty(Cd,"convertLegacyOtlpGrpcOptions",{enumerable:!0,get:function(){return tRe.convertLegacyOtlpGrpcOptions}});var rRe=NZ();Object.defineProperty(Cd,"createOtlpGrpcExportDelegate",{enumerable:!0,get:function(){return rRe.createOtlpGrpcExportDelegate}})});function os(t){return t<0?10:t<128?1:t<16384?2:t<2097152?3:t<268435456?4:t<34359738368?5:t<4398046511104?6:t<562949953421312?7:t<72057594037927940?8:9}var nM=O(()=>{"use strict"});var nRe,kg,Aa,dT=O(()=>{"use strict";Fe();nM();nRe="ProtobufWriter: estimated size was too small, growing buffer.",kg=1,Aa=class{_buffer;_textEncoder;_dataView;pos=0;constructor(e=65536){this._buffer=new Uint8Array(e),this._textEncoder=new TextEncoder,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}_ensureCapacity(e){let r=this.pos+e;if(r<=this._buffer.length)return;de.debug(nRe);let n=this._buffer.length*2;for(;n<r;)n*=2;let i=new Uint8Array(n);i.set(this._buffer),this._buffer=i,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}finish(){return this._buffer.subarray(0,this.pos)}startLengthDelimited(){let e=this.pos;return this._ensureCapacity(kg),this.pos+=kg,e}finishLengthDelimited(e,r){let n=r>>>0,i=os(n);if(i>kg){let s=i-kg;this._ensureCapacity(s),this._buffer.copyWithin(e+i,e+kg,this.pos),this.pos+=s}let o=e;n<128?this._buffer[o]=n:n<16384?(this._buffer[o++]=n&127|128,this._buffer[o]=n>>>7):n<2097152?(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o]=n>>>14):n<268435456?(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o++]=n>>>14&127|128,this._buffer[o]=n>>>21):(this._buffer[o++]=n&127|128,this._buffer[o++]=n>>>7&127|128,this._buffer[o++]=n>>>14&127|128,this._buffer[o++]=n>>>21&127|128,this._buffer[o]=n>>>28)}writeSint32(e){this.writeVarint((e<<1^e>>31)>>>0)}writeSfixed64(e){let r,n;if(e>=0)r=e>>>0,n=e/4294967296>>>0;else{let i=Math.abs(e);r=i>>>0,n=i/4294967296>>>0,r=~r>>>0,n=~n>>>0,r=r+1>>>0,r===0&&(n=n+1>>>0)}this.writeFixed64(r,n)}writeVarint(e){if(this._ensureCapacity(os(e)),e>=0&&e<=4294967295){let r=e>>>0;for(;r>127;)this._buffer[this.pos++]=r&127|128,r>>>=7;this._buffer[this.pos++]=r}else{let r,n;if(e>=0)r=e>>>0,n=e/4294967296>>>0;else{let i=Math.abs(e);r=i>>>0,n=i/4294967296>>>0,r=~r>>>0,n=~n>>>0,r=r+1>>>0,r===0&&(n=n+1>>>0)}for(;n>0||r>127;)this._buffer[this.pos++]=r&127|128,r=(r>>>7|n<<25)>>>0,n>>>=7;this._buffer[this.pos++]=r&127}}writeFixed32(e){this._ensureCapacity(4);let r=e>>>0;this._buffer[this.pos++]=r&255,this._buffer[this.pos++]=r>>>8&255,this._buffer[this.pos++]=r>>>16&255,this._buffer[this.pos++]=r>>>24&255}writeFixed64(e,r){this._ensureCapacity(8);let n=e>>>0,i=r>>>0;this._buffer[this.pos++]=n&255,this._buffer[this.pos++]=n>>>8&255,this._buffer[this.pos++]=n>>>16&255,this._buffer[this.pos++]=n>>>24&255,this._buffer[this.pos++]=i&255,this._buffer[this.pos++]=i>>>8&255,this._buffer[this.pos++]=i>>>16&255,this._buffer[this.pos++]=i>>>24&255}writeBytes(e){this.writeVarint(e.length),this._ensureCapacity(e.length),this._buffer.set(e,this.pos),this.pos+=e.length}writeTag(e,r){this.writeVarint(e<<3|r)}writeDouble(e){this._ensureCapacity(8),this._dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeString(e){let r=!0,n=e.length;for(let i=0;i<n;i++)if(e.charCodeAt(i)>127){r=!1;break}if(r){this.writeVarint(n),this._ensureCapacity(n);for(let i=0;i<n;i++)this._buffer[this.pos++]=e.charCodeAt(i)}else{let i=this._textEncoder.encode(e);this.writeBytes(i)}}}});function MZ(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function ss(t){let e=new Uint8Array(t.length/2),r=0;for(let n=0;n<t.length;n+=2){let i=MZ(t.charCodeAt(n)),o=MZ(t.charCodeAt(n+1));e[r++]=i<<4|o}return e}var iM=O(()=>{"use strict"});var Mg,DZ=O(()=>{"use strict";(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TRACE=1]="TRACE",t[t.TRACE2=2]="TRACE2",t[t.TRACE3=3]="TRACE3",t[t.TRACE4=4]="TRACE4",t[t.DEBUG=5]="DEBUG",t[t.DEBUG2=6]="DEBUG2",t[t.DEBUG3=7]="DEBUG3",t[t.DEBUG4=8]="DEBUG4",t[t.INFO=9]="INFO",t[t.INFO2=10]="INFO2",t[t.INFO3=11]="INFO3",t[t.INFO4=12]="INFO4",t[t.WARN=13]="WARN",t[t.WARN2=14]="WARN2",t[t.WARN3=15]="WARN3",t[t.WARN4=16]="WARN4",t[t.ERROR=17]="ERROR",t[t.ERROR2=18]="ERROR2",t[t.ERROR3=19]="ERROR3",t[t.ERROR4=20]="ERROR4",t[t.FATAL=21]="FATAL",t[t.FATAL2=22]="FATAL2",t[t.FATAL3=23]="FATAL3",t[t.FATAL4=24]="FATAL4"})(Mg||(Mg={}))});var Dg,LZ,oM=O(()=>{"use strict";Dg=class{emit(e){}enabled(){return!1}},LZ=new Dg});function $Z(t,e,r){return n=>n===t?e:r}var Lg,Pd,sM,UZ=O(()=>{"use strict";Lg=Symbol.for("io.opentelemetry.js.api.logs"),Pd=globalThis;sM=1});var aM,fT,cM=O(()=>{"use strict";oM();aM=class{getLogger(e,r,n){return new Dg}},fT=new aM});var pT,FZ=O(()=>{"use strict";oM();pT=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):LZ}}});var $g,BZ=O(()=>{"use strict";cM();FZ();$g=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new pT(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:fT}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}}});var hT,jZ=O(()=>{"use strict";UZ();cM();BZ();hT=class t{constructor(){this._proxyLoggerProvider=new $g}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Pd[Lg]?this.getLoggerProvider():(Pd[Lg]=$Z(sM,e,fT),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Pd[Lg])===null||e===void 0?void 0:e.call(Pd,sM))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Pd[Lg],this._proxyLoggerProvider=new $g}}});var lnt,zZ=O(()=>{"use strict";DZ();jZ();lnt=hT.getInstance()});function Vr(t,e){let r=e[0],n=e[1],i=1e9,o=r&65535,s=r/65536>>>0,a=o*i,c=s*i,l=a>>>0,u=Math.floor(a/4294967296),d=(c&65535)*65536>>>0,f=c/65536>>>0,p=l+d+n,h=p>>>0,m=Math.floor(p/4294967296),y=u+f+m>>>0;t.writeFixed64(h,y)}function yi(t,e,r){for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let i=e[n];t.writeTag(r,2);let o=t.startLengthDelimited(),s=t.pos;iRe(t,n,i),t.finishLengthDelimited(o,t.pos-s)}}function iRe(t,e,r){t.writeTag(1,2),t.writeString(e),t.writeTag(2,2);let n=t.startLengthDelimited(),i=t.pos;Ug(t,r),t.finishLengthDelimited(n,t.pos-i)}function Ug(t,e){let r=typeof e;if(r==="string")t.writeTag(1,2),t.writeString(e);else if(r==="boolean")t.writeTag(2,0),t.writeVarint(e?1:0);else if(r==="number"){let n=e;Number.isInteger(n)&&n>=oRe&&n<sRe?(t.writeTag(3,0),t.writeVarint(n)):(t.writeTag(4,1),t.writeDouble(n))}else if(e instanceof Uint8Array)t.writeTag(7,2),t.writeBytes(e);else if(Array.isArray(e)){t.writeTag(5,2);let n=t.startLengthDelimited(),i=t.pos;for(let o of e){t.writeTag(1,2);let s=t.startLengthDelimited(),a=t.pos;Ug(t,o),t.finishLengthDelimited(s,t.pos-a)}t.finishLengthDelimited(n,t.pos-i)}else if(r==="object"&&e!=null){t.writeTag(6,2);let n=t.startLengthDelimited(),i=t.pos,o=e;for(let s in o){if(!Object.prototype.hasOwnProperty.call(o,s))continue;let a=o[s];t.writeTag(1,2);let c=t.startLengthDelimited(),l=t.pos;t.writeTag(1,2),t.writeString(s),t.writeTag(2,2);let u=t.startLengthDelimited(),d=t.pos;Ug(t,a),t.finishLengthDelimited(u,t.pos-d),t.finishLengthDelimited(c,t.pos-l)}t.finishLengthDelimited(n,t.pos-i)}}function Od(t,e,r){t.writeTag(r,2);let n=t.startLengthDelimited(),i=t.pos;t.writeTag(1,2),t.writeString(e.name),e.version&&(t.writeTag(2,2),t.writeString(e.version)),t.finishLengthDelimited(n,t.pos-i)}function Nd(t,e,r){t.writeTag(r,2);let n=t.startLengthDelimited(),i=t.pos;e.attributes&&yi(t,e.attributes,1),t.writeTag(2,0),t.writeVarint(0),t.finishLengthDelimited(n,t.pos-i)}var oRe,sRe,mT=O(()=>{"use strict";oRe=-(2**63),sRe=2**63});function aRe(t){let e=t.length,r=0;for(let n=0;n<e;n++){let i=t.charCodeAt(n);i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(n++,r+=4)}return r}var Ra,gT=O(()=>{"use strict";nM();Ra=class{pos=0;startLengthDelimited(){return this.pos}finishLengthDelimited(e,r){this.pos+=os(r)}writeVarint(e){this.pos+=os(e)}writeSint32(e){this.pos+=os((e<<1^e>>31)>>>0)}writeSfixed64(e){this.pos+=8}writeFixed32(e){this.pos+=4}writeFixed64(e,r){this.pos+=8}writeBytes(e){this.pos+=os(e.length),this.pos+=e.length}writeTag(e,r){this.writeVarint(e<<3|r)}writeDouble(e){this.pos+=8}writeString(e){let r=aRe(e);this.pos+=os(r),this.pos+=r}}});function cRe(t,e){let r=t.startLengthDelimited(),n=t.pos;if(t.writeTag(1,1),Vr(t,e.hrTime),e.severityNumber!==void 0&&e.severityNumber!==Mg.UNSPECIFIED&&(t.writeTag(2,0),t.writeVarint(e.severityNumber)),e.severityText&&(t.writeTag(3,2),t.writeString(e.severityText)),e.body!==void 0){t.writeTag(5,2);let i=t.startLengthDelimited(),o=t.pos;Ug(t,e.body),t.finishLengthDelimited(i,t.pos-o)}e.attributes&&yi(t,e.attributes,6),t.writeTag(7,0),t.writeVarint(e.droppedAttributesCount),e.spanContext?.traceFlags&&(t.writeTag(8,5),t.writeFixed32(e.spanContext.traceFlags)),e.spanContext?.traceId&&(t.writeTag(9,2),t.writeBytes(ss(e.spanContext.traceId))),e.spanContext?.spanId&&(t.writeTag(10,2),t.writeBytes(ss(e.spanContext.spanId))),t.writeTag(11,1),Vr(t,e.hrTimeObserved),e.eventName&&(t.writeTag(12,2),t.writeString(e.eventName)),t.finishLengthDelimited(r,t.pos-n)}function lRe(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Od(t,e,1);for(let o of r)t.writeTag(2,2),cRe(t,o);e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function GZ(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Nd(t,e,1);for(let o of r.values()){t.writeTag(2,2);let s=o[0].instrumentationScope;lRe(t,s,o)}e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function uRe(t){let e=new Map;for(let r of t){let n=r.resource,i=r.instrumentationScope,o=e.get(n);o||(o=new Map,e.set(n,o));let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}return e}function qZ(t){let e=uRe(t),r=new Ra;for(let[i,o]of e)r.writeTag(1,2),GZ(r,i,o);let n=new Aa(r.pos);for(let[i,o]of e)n.writeTag(1,2),GZ(n,i,o);return n.finish()}var VZ=O(()=>{"use strict";dT();iM();zZ();mT();gT()});var Si,_T=O(()=>{"use strict";Si=class{pos=0;_buf;_textDecoder;constructor(e){this._buf=e,this._textDecoder=new TextDecoder}isAtEnd(){return this.pos>=this._buf.length}readTag(){let e=this.readVarint();return{fieldNumber:e>>>3,wireType:e&7}}readVarint(){let e=0,r=0,n=!1;for(;this.pos<this._buf.length;){let i=this._buf[this.pos++];if(e+=(i&127)*Math.pow(2,r),r+=7,(i&128)===0){n=!0;break}}if(!n)throw new Error("Truncated buffer: unexpected end of data while reading varint");return e}readBytes(){let e=this.readVarint();if(this.pos+e>this._buf.length)throw new Error(`Truncated buffer: expected ${e} bytes at position ${this.pos}, but only ${this._buf.length-this.pos} available`);let r=this._buf.subarray(this.pos,this.pos+e);return this.pos+=e,r}readString(){return this._textDecoder.decode(this.readBytes())}skip(e){switch(e){case 0:this.readVarint();break;case 1:this.pos+=8;break;case 2:this.readBytes();break;case 3:for(;!this.isAtEnd();){let{wireType:r}=this.readTag();if(r===4)break;this.skip(r)}break;case 4:break;case 5:this.pos+=4;break;default:throw new Error(`Unknown wire type ${e}, cannot safely skip`)}}}});function dRe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedLogRecords=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function HZ(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=dRe(e.readBytes()):e.skip(i)}return r}var WZ=O(()=>{"use strict";_T()});var lM,YZ=O(()=>{"use strict";VZ();WZ();lM={serializeRequest:t=>qZ(t),deserializeResponse:t=>HZ(t)}});var KZ=O(()=>{"use strict";YZ()});var as,ZZ=O(()=>{"use strict";(function(t){t[t.DELTA=0]="DELTA",t[t.CUMULATIVE=1]="CUMULATIVE"})(as||(as={}))});var uM,gn,JZ=O(()=>{"use strict";(function(t){t.COUNTER="COUNTER",t.GAUGE="GAUGE",t.HISTOGRAM="HISTOGRAM",t.UP_DOWN_COUNTER="UP_DOWN_COUNTER",t.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",t.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",t.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(uM||(uM={}));(function(t){t[t.HISTOGRAM=0]="HISTOGRAM",t[t.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",t[t.GAUGE=2]="GAUGE",t[t.SUM=3]="SUM"})(gn||(gn={}))});var dM=O(()=>{"use strict";ZZ();JZ()});function e5(t,e,r){let n=t.startLengthDelimited(),i=t.pos;t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),r===Fo.INT?(t.writeTag(6,1),t.writeSfixed64(e.value)):(t.writeTag(4,1),t.writeDouble(e.value)),e.attributes&&yi(t,e.attributes,7),t.finishLengthDelimited(n,t.pos-i)}function fRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.value;if(t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),t.writeTag(4,1),t.writeFixed64(i.count>>>0,i.count/4294967296>>>0),i.sum!==void 0&&(t.writeTag(5,1),t.writeDouble(i.sum)),i.buckets.counts.length>0){t.writeTag(6,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of i.buckets.counts)t.writeFixed64(a>>>0,a/4294967296>>>0);t.finishLengthDelimited(o,t.pos-s)}if(i.buckets.boundaries.length>0){t.writeTag(7,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of i.buckets.boundaries)t.writeDouble(a);t.finishLengthDelimited(o,t.pos-s)}e.attributes&&yi(t,e.attributes,9),i.min!==void 0&&(t.writeTag(11,1),t.writeDouble(i.min)),i.max!==void 0&&(t.writeTag(12,1),t.writeDouble(i.max)),t.finishLengthDelimited(r,t.pos-n)}function XZ(t,e,r){let n=t.startLengthDelimited(),i=t.pos;if(e!==0&&(t.writeTag(1,0),t.writeSint32(e)),r.length>0){t.writeTag(2,2);let o=t.startLengthDelimited(),s=t.pos;for(let a of r)t.writeVarint(a);t.finishLengthDelimited(o,t.pos-s)}t.finishLengthDelimited(n,t.pos-i)}function pRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.value;e.attributes&&yi(t,e.attributes,1),t.writeTag(2,1),Vr(t,e.startTime),t.writeTag(3,1),Vr(t,e.endTime),t.writeTag(4,1),t.writeFixed64(i.count>>>0,i.count/4294967296>>>0),i.sum!==void 0&&(t.writeTag(5,1),t.writeDouble(i.sum)),i.scale!==0&&(t.writeTag(6,0),t.writeSint32(i.scale)),t.writeTag(7,1),t.writeFixed64(i.zeroCount>>>0,i.zeroCount/4294967296>>>0),t.writeTag(8,2),XZ(t,i.positive.offset,i.positive.bucketCounts),t.writeTag(9,2),XZ(t,i.negative.offset,i.negative.bucketCounts),i.min!==void 0&&(t.writeTag(12,1),t.writeDouble(i.min)),i.max!==void 0&&(t.writeTag(13,1),t.writeDouble(i.max)),t.finishLengthDelimited(r,t.pos-n)}function hRe(t,e){let r=t.startLengthDelimited(),n=t.pos;switch(t.writeTag(1,2),t.writeString(e.descriptor.name),e.descriptor.description&&(t.writeTag(2,2),t.writeString(e.descriptor.description)),e.descriptor.unit&&(t.writeTag(3,2),t.writeString(e.descriptor.unit)),e.dataPointType){case gn.GAUGE:t.writeTag(5,2),mRe(t,e);break;case gn.SUM:t.writeTag(7,2),gRe(t,e);break;case gn.HISTOGRAM:t.writeTag(9,2),_Re(t,e);break;case gn.EXPONENTIAL_HISTOGRAM:t.writeTag(10,2),yRe(t,e);break;default:{let i=e}}t.finishLengthDelimited(r,t.pos-n)}function mRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let i of e.dataPoints)t.writeTag(1,2),e5(t,i,e.descriptor.valueType);t.finishLengthDelimited(r,t.pos-n)}function gRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),e5(t,o,e.descriptor.valueType);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),e.isMonotonic&&(t.writeTag(3,0),t.writeVarint(1)),t.finishLengthDelimited(r,t.pos-n)}function _Re(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),fRe(t,o);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),t.finishLengthDelimited(r,t.pos-n)}function yRe(t,e){let r=t.startLengthDelimited(),n=t.pos;for(let o of e.dataPoints)t.writeTag(1,2),pRe(t,o);let i=fM(e.aggregationTemporality);i!==0&&(t.writeTag(2,0),t.writeVarint(i)),t.finishLengthDelimited(r,t.pos-n)}function SRe(t,e){let r=t.startLengthDelimited(),n=t.pos;Od(t,e.scope,1);for(let i of e.metrics)t.writeTag(2,2),hRe(t,i);e.scope.schemaUrl&&(t.writeTag(3,2),t.writeString(e.scope.schemaUrl)),t.finishLengthDelimited(r,t.pos-n)}function QZ(t,e){let r=t.startLengthDelimited(),n=t.pos;Nd(t,e.resource,1);for(let i of e.scopeMetrics)t.writeTag(2,2),SRe(t,i);e.resource.schemaUrl&&(t.writeTag(3,2),t.writeString(e.resource.schemaUrl)),t.finishLengthDelimited(r,t.pos-n)}function fM(t){switch(t){case as.DELTA:return 1;case as.CUMULATIVE:return 2;default:return 0}}function t5(t){let e=new Ra;e.writeTag(1,2),QZ(e,t);let r=new Aa(e.pos);return r.writeTag(1,2),QZ(r,t),r.finish()}var r5=O(()=>{"use strict";Fe();dM();mT();gT();dT()});function ERe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedDataPoints=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function n5(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=ERe(e.readBytes()):e.skip(i)}return r}var i5=O(()=>{"use strict";_T()});var pM,o5=O(()=>{"use strict";r5();i5();pM={serializeRequest:t=>t5(t),deserializeResponse:t=>n5(t)}});var s5=O(()=>{"use strict";o5()});function c5(t,e){let r=t&255|vRe;return e&&(r|=bRe),r}function TRe(t,e){let r=t.startLengthDelimited(),n=t.pos;e.message&&(t.writeTag(2,2),t.writeString(e.message)),t.writeTag(3,0),t.writeVarint(e.code),t.finishLengthDelimited(r,t.pos-n)}function xRe(t,e){let r=t.startLengthDelimited(),n=t.pos;t.writeTag(1,1),Vr(t,e.time),t.writeTag(2,2),t.writeString(e.name),e.attributes&&yi(t,e.attributes,3),t.writeTag(4,0),t.writeVarint(e.droppedAttributesCount||0),t.finishLengthDelimited(r,t.pos-n)}function wRe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.context;t.writeTag(1,2),t.writeBytes(ss(i.traceId)),t.writeTag(2,2),t.writeBytes(ss(i.spanId));let o=i.traceState?.serialize();o&&(t.writeTag(3,2),t.writeString(o)),e.attributes&&yi(t,e.attributes,4),t.writeTag(5,0),t.writeVarint(e.droppedAttributesCount||0);let s=c5(i.traceFlags,i.isRemote);s&&(t.writeTag(6,5),t.writeFixed32(s)),t.finishLengthDelimited(r,t.pos-n)}function ARe(t,e){let r=t.startLengthDelimited(),n=t.pos,i=e.spanContext();t.writeTag(1,2),t.writeBytes(ss(i.traceId)),t.writeTag(2,2),t.writeBytes(ss(i.spanId));let o=i.traceState?.serialize();o&&(t.writeTag(3,2),t.writeString(o)),e.parentSpanContext?.spanId&&(t.writeTag(4,2),t.writeBytes(ss(e.parentSpanContext.spanId))),t.writeTag(5,2),t.writeString(e.name);let s=e.kind==null?0:e.kind+1;s!==0&&(t.writeTag(6,0),t.writeVarint(s)),t.writeTag(7,1),Vr(t,e.startTime),t.writeTag(8,1),Vr(t,e.endTime),e.attributes&&yi(t,e.attributes,9),t.writeTag(10,0),t.writeVarint(e.droppedAttributesCount);for(let c of e.events)t.writeTag(11,2),xRe(t,c);t.writeTag(12,0),t.writeVarint(e.droppedEventsCount);for(let c of e.links)t.writeTag(13,2),wRe(t,c);t.writeTag(14,0),t.writeVarint(e.droppedLinksCount),t.writeTag(15,2),TRe(t,e.status);let a=c5(i.traceFlags,e.parentSpanContext?.isRemote);a&&(t.writeTag(16,5),t.writeFixed32(a)),t.finishLengthDelimited(r,t.pos-n)}function RRe(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Od(t,e,1);for(let o of r)t.writeTag(2,2),ARe(t,o);e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function a5(t,e,r){let n=t.startLengthDelimited(),i=t.pos;Nd(t,e,1);for(let o of r.values()){t.writeTag(2,2);let s=o[0].instrumentationScope;RRe(t,s,o)}e.schemaUrl&&(t.writeTag(3,2),t.writeString(e.schemaUrl)),t.finishLengthDelimited(n,t.pos-i)}function IRe(t){let e=new Map;for(let r of t){let n=r.resource,i=r.instrumentationScope,o=e.get(n);o||(o=new Map,e.set(n,o));let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}return e}function l5(t){let e=IRe(t),r=new Ra;for(let[i,o]of e)r.writeTag(1,2),a5(r,i,o);let n=new Aa(r.pos);for(let[i,o]of e)n.writeTag(1,2),a5(n,i,o);return n.finish()}var vRe,bRe,u5=O(()=>{"use strict";dT();iM();mT();gT();vRe=256,bRe=512});function CRe(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();switch(n){case 1:i===0?r.rejectedSpans=e.readVarint():e.skip(i);break;case 2:i===2?r.errorMessage=e.readString():e.skip(i);break;default:e.skip(i);break}}return r}function d5(t){let e=new Si(t),r={};for(;!e.isAtEnd();){let{fieldNumber:n,wireType:i}=e.readTag();n===1&&i===2?r.partialSuccess=CRe(e.readBytes()):e.skip(i)}return r}var f5=O(()=>{"use strict";_T()});var hM,p5=O(()=>{"use strict";u5();f5();hM={serializeRequest:t=>l5(t),deserializeResponse:t=>d5(t)}});var h5=O(()=>{"use strict";p5()});function kd(t,e){let r={attributes:cs(t.attributes,e),droppedAttributesCount:0},n=t.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function Md(t){return{name:t.name,version:t.version}}function cs(t,e){return Object.keys(t).map(r=>mM(r,t[r],e))}function mM(t,e,r){return{key:t,value:Fg(e,r)}}function Fg(t,e){let r=typeof t;if(r==="string")return{stringValue:t};if(r==="number")return Number.isInteger(t)?{intValue:t}:{doubleValue:t};if(r==="boolean")return{boolValue:t};if(t instanceof Uint8Array)return{bytesValue:e.encodeUint8Array(t)};if(Array.isArray(t)){let n=new Array(t.length);for(let i=0;i<t.length;i++)n[i]=Fg(t[i],e);return{arrayValue:{values:n}}}if(r==="object"&&t!=null){let n=Object.keys(t),i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]={key:n[o],value:Fg(t[n[o]],e)};return{kvlistValue:{values:i}}}return{}}var yT=O(()=>{"use strict"});function m5(t,e){return{resourceLogs:ORe(t,e)}}function PRe(t){let e=new Map;for(let r of t){let{resource:n,instrumentationScope:{name:i,version:o="",schemaUrl:s=""}}=r,a=e.get(n);a||(a=new Map,e.set(n,a));let c=`${i}@${o}:${s}`,l=a.get(c);l||(l=[],a.set(c,l)),l.push(r)}return e}function ORe(t,e){let r=PRe(t);return Array.from(r,([n,i])=>{let o=kd(n,e);return{resource:o,scopeLogs:Array.from(i,([,s])=>({scope:Md(s[0].instrumentationScope),logRecords:s.map(a=>NRe(a,e)),schemaUrl:s[0].instrumentationScope.schemaUrl})),schemaUrl:o.schemaUrl}})}function NRe(t,e){return{timeUnixNano:e.encodeHrTime(t.hrTime),observedTimeUnixNano:e.encodeHrTime(t.hrTimeObserved),severityNumber:t.severityNumber,severityText:t.severityText,body:Fg(t.body,e),eventName:t.eventName,attributes:kRe(t.attributes,e),droppedAttributesCount:t.droppedAttributesCount,flags:t.spanContext?.traceFlags,traceId:e.encodeOptionalSpanContext(t.spanContext?.traceId),spanId:e.encodeOptionalSpanContext(t.spanContext?.spanId)}}function kRe(t,e){return Object.keys(t).map(r=>mM(r,t[r],e))}var g5=O(()=>{"use strict";yT()});function MRe(t){let e=BigInt(1e9);return BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))}function DRe(t){return MRe(t).toString()}function _5(t){return t}var LRe,Dd,ST=O(()=>{"use strict";bt();LRe=typeof BigInt<"u"?DRe:cE;Dd={encodeHrTime:LRe,encodeSpanContext:_5,encodeOptionalSpanContext:_5,encodeUint8Array:t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");let e=new Array(t.length);for(let r=0;r<t.length;r++)e[r]=String.fromCharCode(t[r]);return btoa(e.join(""))}}});var gM,y5=O(()=>{"use strict";g5();ST();Fe();gM={serializeRequest:t=>{let e=m5(t,Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse logs export response: ${r.message}. Returning empty response`),{}}}}});var S5=O(()=>{"use strict";y5()});var Bg,E5=O(()=>{"use strict";(function(t){t[t.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]="AGGREGATION_TEMPORALITY_UNSPECIFIED",t[t.AGGREGATION_TEMPORALITY_DELTA=1]="AGGREGATION_TEMPORALITY_DELTA",t[t.AGGREGATION_TEMPORALITY_CUMULATIVE=2]="AGGREGATION_TEMPORALITY_CUMULATIVE"})(Bg||(Bg={}))});function $Re(t,e){let r=kd(t.resource,e);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:URe(t.scopeMetrics,e)}}function URe(t,e){return Array.from(t.map(r=>({scope:Md(r.scope),metrics:r.metrics.map(n=>FRe(n,e)),schemaUrl:r.scope.schemaUrl})))}function FRe(t,e){let r={name:t.descriptor.name,description:t.descriptor.description,unit:t.descriptor.unit},n=GRe(t.aggregationTemporality);switch(t.dataPointType){case gn.SUM:r.sum={aggregationTemporality:n,isMonotonic:t.isMonotonic,dataPoints:v5(t,e)};break;case gn.GAUGE:r.gauge={dataPoints:v5(t,e)};break;case gn.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:jRe(t,e)};break;case gn.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:zRe(t,e)};break}return r}function BRe(t,e,r){let n={attributes:cs(t.attributes,r),startTimeUnixNano:r.encodeHrTime(t.startTime),timeUnixNano:r.encodeHrTime(t.endTime)};switch(e){case Fo.INT:n.asInt=t.value;break;case Fo.DOUBLE:n.asDouble=t.value;break}return n}function v5(t,e){return t.dataPoints.map(r=>BRe(r,t.descriptor.valueType,e))}function jRe(t,e){return t.dataPoints.map(r=>{let n=r.value;return{attributes:cs(r.attributes,e),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function zRe(t,e){return t.dataPoints.map(r=>{let n=r.value;return{attributes:cs(r.attributes,e),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function GRe(t){switch(t){case as.DELTA:return Bg.AGGREGATION_TEMPORALITY_DELTA;case as.CUMULATIVE:return Bg.AGGREGATION_TEMPORALITY_CUMULATIVE}}function b5(t,e){return{resourceMetrics:t.map(r=>$Re(r,e))}}var T5=O(()=>{"use strict";Fe();dM();E5();yT()});var _M,x5=O(()=>{"use strict";T5();ST();Fe();_M={serializeRequest:t=>{let e=b5([t],Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse metrics export response: ${r.message}. Returning empty response`),{}}}}});var w5=O(()=>{"use strict";x5()});function A5(t,e){let r=t&255|qRe;return e&&(r|=VRe),r}function HRe(t,e){let r=t.spanContext(),n=t.status,i=t.parentSpanContext?.spanId?e.encodeSpanContext(t.parentSpanContext?.spanId):void 0;return{traceId:e.encodeSpanContext(r.traceId),spanId:e.encodeSpanContext(r.spanId),parentSpanId:i,traceState:r.traceState?.serialize(),name:t.name,kind:t.kind==null?0:t.kind+1,startTimeUnixNano:e.encodeHrTime(t.startTime),endTimeUnixNano:e.encodeHrTime(t.endTime),attributes:cs(t.attributes,e),droppedAttributesCount:t.droppedAttributesCount,events:t.events.map(o=>YRe(o,e)),droppedEventsCount:t.droppedEventsCount,status:{code:n.code,message:n.message},links:t.links.map(o=>WRe(o,e)),droppedLinksCount:t.droppedLinksCount,flags:A5(r.traceFlags,t.parentSpanContext?.isRemote)}}function WRe(t,e){return{attributes:t.attributes?cs(t.attributes,e):[],spanId:e.encodeSpanContext(t.context.spanId),traceId:e.encodeSpanContext(t.context.traceId),traceState:t.context.traceState?.serialize(),droppedAttributesCount:t.droppedAttributesCount||0,flags:A5(t.context.traceFlags,t.context.isRemote)}}function YRe(t,e){return{attributes:t.attributes?cs(t.attributes,e):[],name:t.name,timeUnixNano:e.encodeHrTime(t.time),droppedAttributesCount:t.droppedAttributesCount||0}}function R5(t,e){return{resourceSpans:ZRe(t,e)}}function KRe(t){let e=new Map;for(let r of t){let n=e.get(r.resource);n||(n=new Map,e.set(r.resource,n));let i=`${r.instrumentationScope.name}@${r.instrumentationScope.version||""}:${r.instrumentationScope.schemaUrl||""}`,o=n.get(i);o||(o=[],n.set(i,o)),o.push(r)}return e}function ZRe(t,e){let r=KRe(t),n=[],i=r.entries(),o=i.next();for(;!o.done;){let[s,a]=o.value,c=[],l=a.values(),u=l.next();for(;!u.done;){let p=u.value;if(p.length>0){let h=p.map(m=>HRe(m,e));c.push({scope:Md(p[0].instrumentationScope),spans:h,schemaUrl:p[0].instrumentationScope.schemaUrl})}u=l.next()}let d=kd(s,e),f={resource:d,scopeSpans:c,schemaUrl:d.schemaUrl};n.push(f),o=i.next()}return n}var qRe,VRe,I5=O(()=>{"use strict";yT();qRe=256,VRe=512});var yM,C5=O(()=>{"use strict";I5();ST();Fe();yM={serializeRequest:t=>{let e=R5(t,Dd);return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;try{return JSON.parse(e.decode(t))}catch(r){return de.warn(`Failed to parse trace export response: ${r.message}. Returning empty response`),{}}}}});var P5=O(()=>{"use strict";C5()});var O5={};pr(O5,{JsonLogsSerializer:()=>gM,JsonMetricsSerializer:()=>_M,JsonTraceSerializer:()=>yM,ProtobufLogsSerializer:()=>lM,ProtobufMetricsSerializer:()=>pM,ProtobufTraceSerializer:()=>hM});var N5=O(()=>{"use strict";KZ();s5();h5();S5();w5();P5()});var M5=b(ET=>{"use strict";Object.defineProperty(ET,"__esModule",{value:!0});ET.OTLPTraceExporter=void 0;var k5=kZ(),JRe=(N5(),wr(O5)),XRe=(XE(),wr(JE)),SM=class extends XRe.OTLPExporterBase{constructor(e={}){super((0,k5.createOtlpGrpcExportDelegate)((0,k5.convertLegacyOtlpGrpcOptions)(e,"TRACES"),JRe.ProtobufTraceSerializer,"TraceExportService","/opentelemetry.proto.collector.trace.v1.TraceService/Export"))}};ET.OTLPTraceExporter=SM});var D5=b(vT=>{"use strict";Object.defineProperty(vT,"__esModule",{value:!0});vT.OTLPTraceExporter=void 0;var QRe=M5();Object.defineProperty(vT,"OTLPTraceExporter",{enumerable:!0,get:function(){return QRe.OTLPTraceExporter}})});var K9=b((mat,Y9)=>{"use strict";Y9.exports=W9;W9.sync=jCe;var V9=Z("fs");function BCe(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&t.substr(-i.length).toLowerCase()===i)return!0}return!1}function H9(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:BCe(e,r)}function W9(t,e,r){V9.stat(t,function(n,i){r(n,n?!1:H9(i,t,e))})}function jCe(t,e){return H9(V9.statSync(t),t,e)}});var eJ=b((gat,Q9)=>{"use strict";Q9.exports=J9;J9.sync=zCe;var Z9=Z("fs");function J9(t,e,r){Z9.stat(t,function(n,i){r(n,n?!1:X9(i,e))})}function zCe(t,e){return X9(Z9.statSync(t),e)}function X9(t,e){return t.isFile()&&GCe(t,e)}function GCe(t,e){var r=t.mode,n=t.uid,i=t.gid,o=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),s=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),l=parseInt("001",8),u=a|c,d=r&l||r&c&&i===s||r&a&&n===o||r&u&&o===0;return d}});var rJ=b((yat,tJ)=>{"use strict";var _at=Z("fs"),qT;process.platform==="win32"||global.TESTING_WINDOWS?qT=K9():qT=eJ();tJ.exports=zM;zM.sync=qCe;function zM(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){zM(t,e||{},function(o,s){o?i(o):n(s)})})}qT(t,e||{},function(n,i){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function qCe(t,e){try{return qT.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var lJ=b((Sat,cJ)=>{"use strict";var jd=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",nJ=Z("path"),VCe=jd?";":":",iJ=rJ(),oJ=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),sJ=(t,e)=>{let r=e.colon||VCe,n=t.match(/\//)||jd&&t.match(/\\/)?[""]:[...jd?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],i=jd?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=jd?i.split(r):[""];return jd&&t.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:i}},aJ=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:i,pathExtExe:o}=sJ(t,e),s=[],a=l=>new Promise((u,d)=>{if(l===n.length)return e.all&&s.length?u(s):d(oJ(t));let f=n[l],p=/^".*"$/.test(f)?f.slice(1,-1):f,h=nJ.join(p,t),m=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+h:h;u(c(m,l,0))}),c=(l,u,d)=>new Promise((f,p)=>{if(d===i.length)return f(a(u+1));let h=i[d];iJ(l+h,{pathExt:o},(m,y)=>{if(!m&&y)if(e.all)s.push(l+h);else return f(l+h);return f(c(l,u,d+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},HCe=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:i}=sJ(t,e),o=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=nJ.join(c,t),u=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let d=0;d<n.length;d++){let f=u+n[d];try{if(iJ.sync(f,{pathExt:i}))if(e.all)o.push(f);else return f}catch{}}}if(e.all&&o.length)return o;if(e.nothrow)return null;throw oJ(t)};cJ.exports=aJ;aJ.sync=HCe});var dJ=b((Eat,GM)=>{"use strict";var uJ=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};GM.exports=uJ;GM.exports.default=uJ});var mJ=b((vat,hJ)=>{"use strict";var fJ=Z("path"),WCe=lJ(),YCe=dJ();function pJ(t,e){let r=t.options.env||process.env,n=process.cwd(),i=t.options.cwd!=null,o=i&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(t.options.cwd)}catch{}let s;try{s=WCe.sync(t.command,{path:r[YCe({env:r})],pathExt:e?fJ.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return s&&(s=fJ.resolve(i?t.options.cwd:"",s)),s}function KCe(t){return pJ(t)||pJ(t,!0)}hJ.exports=KCe});var gJ=b((bat,VM)=>{"use strict";var qM=/([()\][%!^"`<>&|;, *?])/g;function ZCe(t){return t=t.replace(qM,"^$1"),t}function JCe(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(qM,"^$1"),e&&(t=t.replace(qM,"^$1")),t}VM.exports.command=ZCe;VM.exports.argument=JCe});var yJ=b((Tat,_J)=>{"use strict";_J.exports=/^#!(.*)/});var EJ=b((xat,SJ)=>{"use strict";var XCe=yJ();SJ.exports=(t="")=>{let e=t.match(XCe);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?n:n?`${i} ${n}`:i}});var bJ=b((wat,vJ)=>{"use strict";var HM=Z("fs"),QCe=EJ();function e0e(t){let r=Buffer.alloc(150),n;try{n=HM.openSync(t,"r"),HM.readSync(n,r,0,150,0),HM.closeSync(n)}catch{}return QCe(r.toString())}vJ.exports=e0e});var AJ=b((Aat,wJ)=>{"use strict";var t0e=Z("path"),TJ=mJ(),xJ=gJ(),r0e=bJ(),n0e=process.platform==="win32",i0e=/\.(?:com|exe)$/i,o0e=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function s0e(t){t.file=TJ(t);let e=t.file&&r0e(t.file);return e?(t.args.unshift(t.file),t.command=e,TJ(t)):t.file}function a0e(t){if(!n0e)return t;let e=s0e(t),r=!i0e.test(e);if(t.options.forceShell||r){let n=o0e.test(e);t.command=t0e.normalize(t.command),t.command=xJ.command(t.command),t.args=t.args.map(o=>xJ.argument(o,n));let i=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${i}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function c0e(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:a0e(n)}wJ.exports=c0e});var CJ=b((Rat,IJ)=>{"use strict";var WM=process.platform==="win32";function YM(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function l0e(t,e){if(!WM)return;let r=t.emit;t.emit=function(n,i){if(n==="exit"){let o=RJ(i,e);if(o)return r.call(t,"error",o)}return r.apply(t,arguments)}}function RJ(t,e){return WM&&t===1&&!e.file?YM(e.original,"spawn"):null}function u0e(t,e){return WM&&t===1&&!e.file?YM(e.original,"spawnSync"):null}IJ.exports={hookChildProcess:l0e,verifyENOENT:RJ,verifyENOENTSync:u0e,notFoundError:YM}});var NJ=b((Iat,zd)=>{"use strict";var PJ=Z("child_process"),KM=AJ(),ZM=CJ();function OJ(t,e,r){let n=KM(t,e,r),i=PJ.spawn(n.command,n.args,n.options);return ZM.hookChildProcess(i,n),i}function d0e(t,e,r){let n=KM(t,e,r),i=PJ.spawnSync(n.command,n.args,n.options);return i.error=i.error||ZM.verifyENOENTSync(i.status,n),i}zd.exports=OJ;zd.exports.spawn=OJ;zd.exports.sync=d0e;zd.exports._parse=KM;zd.exports._enoent=ZM});var Bse=b((hDt,Fse)=>{"use strict";var Ec=Z("constants"),vje=process.cwd,qR=null,bje=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return qR||(qR=vje.call(process)),qR};try{process.cwd()}catch{}typeof process.chdir=="function"&&(u2=process.chdir,process.chdir=function(t){qR=null,u2.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,u2));var u2;Fse.exports=Tje;function Tje(t){Ec.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=o(t.chown),t.fchown=o(t.fchown),t.lchown=o(t.lchown),t.chmod=n(t.chmod),t.fchmod=n(t.fchmod),t.lchmod=n(t.lchmod),t.chownSync=s(t.chownSync),t.fchownSync=s(t.fchownSync),t.lchownSync=s(t.lchownSync),t.chmodSync=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=c(t.statSync),t.fstatSync=c(t.fstatSync),t.lstatSync=c(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,d,f){f&&process.nextTick(f)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,d,f,p){p&&process.nextTick(p)},t.lchownSync=function(){}),bje==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(u){function d(f,p,h){var m=Date.now(),y=0;u(f,p,function S(T){if(T&&(T.code==="EACCES"||T.code==="EPERM"||T.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){t.stat(p,function(x,v){x&&x.code==="ENOENT"?u(f,p,S):h(T)})},y),y<100&&(y+=10);return}h&&h(T)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(u){function d(f,p,h,m,y,S){var T;if(S&&typeof S=="function"){var x=0;T=function(v,N,R){if(v&&v.code==="EAGAIN"&&x<10)return x++,u.call(t,f,p,h,m,y,T);S.apply(this,arguments)}}return u.call(t,f,p,h,m,y,T)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(u){return function(d,f,p,h,m){for(var y=0;;)try{return u.call(t,d,f,p,h,m)}catch(S){if(S.code==="EAGAIN"&&y<10){y++;continue}throw S}}})(t.readSync);function e(u){u.lchmod=function(d,f,p){u.open(d,Ec.O_WRONLY|Ec.O_SYMLINK,f,function(h,m){if(h){p&&p(h);return}u.fchmod(m,f,function(y){u.close(m,function(S){p&&p(y||S)})})})},u.lchmodSync=function(d,f){var p=u.openSync(d,Ec.O_WRONLY|Ec.O_SYMLINK,f),h=!0,m;try{m=u.fchmodSync(p,f),h=!1}finally{if(h)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}}function r(u){Ec.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(d,f,p,h){u.open(d,Ec.O_SYMLINK,function(m,y){if(m){h&&h(m);return}u.futimes(y,f,p,function(S){u.close(y,function(T){h&&h(S||T)})})})},u.lutimesSync=function(d,f,p){var h=u.openSync(d,Ec.O_SYMLINK),m,y=!0;try{m=u.futimesSync(h,f,p),y=!1}finally{if(y)try{u.closeSync(h)}catch{}else u.closeSync(h)}return m}):u.futimes&&(u.lutimes=function(d,f,p,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function n(u){return u&&function(d,f,p){return u.call(t,d,f,function(h){l(h)&&(h=null),p&&p.apply(this,arguments)})}}function i(u){return u&&function(d,f){try{return u.call(t,d,f)}catch(p){if(!l(p))throw p}}}function o(u){return u&&function(d,f,p,h){return u.call(t,d,f,p,function(m){l(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(u){return u&&function(d,f,p){try{return u.call(t,d,f,p)}catch(h){if(!l(h))throw h}}}function a(u){return u&&function(d,f,p){typeof f=="function"&&(p=f,f=null);function h(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),p&&p.apply(this,arguments)}return f?u.call(t,d,f,h):u.call(t,d,h)}}function c(u){return u&&function(d,f){var p=f?u.call(t,d,f):u.call(t,d);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function l(u){if(!u||u.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Gse=b((mDt,zse)=>{"use strict";var jse=Z("stream").Stream;zse.exports=xje;function xje(t){return{ReadStream:e,WriteStream:r};function e(n,i){if(!(this instanceof e))return new e(n,i);jse.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var l=s[a];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}t.open(this.path,this.flags,this.mode,function(u,d){if(u){o.emit("error",u),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);jse.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,a=o.length;s<a;s++){var c=o[s];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Vse=b((gDt,qse)=>{"use strict";qse.exports=Aje;var wje=Object.getPrototypeOf||function(t){return t.__proto__};function Aje(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:wje(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var Kse=b((_Dt,p2)=>{"use strict";var St=Z("fs"),Rje=Bse(),Ije=Gse(),Cje=Vse(),VR=Z("util"),fr,WR;typeof Symbol=="function"&&typeof Symbol.for=="function"?(fr=Symbol.for("graceful-fs.queue"),WR=Symbol.for("graceful-fs.previous")):(fr="___graceful-fs.queue",WR="___graceful-fs.previous");function Pje(){}function Yse(t,e){Object.defineProperty(t,fr,{get:function(){return e}})}var Eu=Pje;VR.debuglog?Eu=VR.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Eu=function(){var t=VR.format.apply(VR,arguments);t="GFS4: "+t.split(/\n/).join(`
|
|
23
|
+
GFS4: `),console.error(t)});St[fr]||(Hse=global[fr]||[],Yse(St,Hse),St.close=(function(t){function e(r,n){return t.call(St,r,function(i){i||Wse(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,WR,{value:t}),e})(St.close),St.closeSync=(function(t){function e(r){t.apply(St,arguments),Wse()}return Object.defineProperty(e,WR,{value:t}),e})(St.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Eu(St[fr]),Z("assert").equal(St[fr].length,0)}));var Hse;global[fr]||Yse(global,St[fr]);p2.exports=d2(Cje(St));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!St.__patched&&(p2.exports=d2(St),St.__patched=!0);function d2(t){Rje(t),t.gracefulify=d2,t.createReadStream=N,t.createWriteStream=R;var e=t.readFile;t.readFile=r;function r(D,j,_){return typeof j=="function"&&(_=j,j=null),ae(D,j,_);function ae(I,g,E,w){return e(I,g,function(W){W&&(W.code==="EMFILE"||W.code==="ENFILE")?ph([ae,[I,g,E],W,w||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=i;function i(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return n(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var o=t.appendFile;o&&(t.appendFile=s);function s(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return o(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=c);function c(D,j,_,ae){return typeof _=="function"&&(ae=_,_=0),I(D,j,_,ae);function I(g,E,w,W,G){return a(g,E,w,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var l=t.readdir;t.readdir=d;var u=/^v[0-5]\./;function d(D,j,_){typeof j=="function"&&(_=j,j=null);var ae=u.test(process.version)?function(E,w,W,G){return l(E,I(E,w,W,G))}:function(E,w,W,G){return l(E,w,I(E,w,W,G))};return ae(D,j,_);function I(g,E,w,W){return function(G,ce){G&&(G.code==="EMFILE"||G.code==="ENFILE")?ph([ae,[g,E,w],G,W||Date.now(),Date.now()]):(ce&&ce.sort&&ce.sort(),typeof w=="function"&&w.call(this,G,ce))}}}if(process.version.substr(0,4)==="v0.8"){var f=Ije(t);S=f.ReadStream,x=f.WriteStream}var p=t.ReadStream;p&&(S.prototype=Object.create(p.prototype),S.prototype.open=T);var h=t.WriteStream;h&&(x.prototype=Object.create(h.prototype),x.prototype.open=v),Object.defineProperty(t,"ReadStream",{get:function(){return S},set:function(D){S=D},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return x},set:function(D){x=D},enumerable:!0,configurable:!0});var m=S;Object.defineProperty(t,"FileReadStream",{get:function(){return m},set:function(D){m=D},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(D){y=D},enumerable:!0,configurable:!0});function S(D,j){return this instanceof S?(p.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function T(){var D=this;C(D.path,D.flags,D.mode,function(j,_){j?(D.autoClose&&D.destroy(),D.emit("error",j)):(D.fd=_,D.emit("open",_),D.read())})}function x(D,j){return this instanceof x?(h.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function v(){var D=this;C(D.path,D.flags,D.mode,function(j,_){j?(D.destroy(),D.emit("error",j)):(D.fd=_,D.emit("open",_))})}function N(D,j){return new t.ReadStream(D,j)}function R(D,j){return new t.WriteStream(D,j)}var U=t.open;t.open=C;function C(D,j,_,ae){return typeof _=="function"&&(ae=_,_=null),I(D,j,_,ae);function I(g,E,w,W,G){return U(g,E,w,function(ce,Te){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?ph([I,[g,E,w,W],ce,G||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}return t}function ph(t){Eu("ENQUEUE",t[0].name,t[1]),St[fr].push(t),f2()}var HR;function Wse(){for(var t=Date.now(),e=0;e<St[fr].length;++e)St[fr][e].length>2&&(St[fr][e][3]=t,St[fr][e][4]=t);f2()}function f2(){if(clearTimeout(HR),HR=void 0,St[fr].length!==0){var t=St[fr].shift(),e=t[0],r=t[1],n=t[2],i=t[3],o=t[4];if(i===void 0)Eu("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-i>=6e4){Eu("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,c=Math.max(o-i,1),l=Math.min(c*1.2,100);a>=l?(Eu("RETRY",e.name,r),e.apply(null,r.concat([i]))):St[fr].push(t)}HR===void 0&&(HR=setTimeout(f2,0))}}});var lae=b(hh=>{"use strict";Object.defineProperty(hh,"__esModule",{value:!0});hh.splitWhen=hh.flatten=void 0;function Zje(t){return t.reduce((e,r)=>[].concat(e,r),[])}hh.flatten=Zje;function Jje(t,e){let r=[[]],n=0;for(let i of t)e(i)?(n++,r[n]=[]):r[n].push(i);return r}hh.splitWhen=Jje});var uae=b(KR=>{"use strict";Object.defineProperty(KR,"__esModule",{value:!0});KR.isEnoentCodeError=void 0;function Xje(t){return t.code==="ENOENT"}KR.isEnoentCodeError=Xje});var dae=b(ZR=>{"use strict";Object.defineProperty(ZR,"__esModule",{value:!0});ZR.createDirentFromStats=void 0;var b2=class{constructor(e,r){this.name=e,this.isBlockDevice=r.isBlockDevice.bind(r),this.isCharacterDevice=r.isCharacterDevice.bind(r),this.isDirectory=r.isDirectory.bind(r),this.isFIFO=r.isFIFO.bind(r),this.isFile=r.isFile.bind(r),this.isSocket=r.isSocket.bind(r),this.isSymbolicLink=r.isSymbolicLink.bind(r)}};function Qje(t,e){return new b2(t,e)}ZR.createDirentFromStats=Qje});var mae=b(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.convertPosixPathToPattern=Dt.convertWindowsPathToPattern=Dt.convertPathToPattern=Dt.escapePosixPath=Dt.escapeWindowsPath=Dt.escape=Dt.removeLeadingDotSegment=Dt.makeAbsolute=Dt.unixify=void 0;var e2e=Z("os"),t2e=Z("path"),fae=e2e.platform()==="win32",r2e=2,n2e=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,i2e=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,o2e=/^\\\\([.?])/,s2e=/\\(?![!()+@[\]{}])/g;function a2e(t){return t.replace(/\\/g,"/")}Dt.unixify=a2e;function c2e(t,e){return t2e.resolve(t,e)}Dt.makeAbsolute=c2e;function l2e(t){if(t.charAt(0)==="."){let e=t.charAt(1);if(e==="/"||e==="\\")return t.slice(r2e)}return t}Dt.removeLeadingDotSegment=l2e;Dt.escape=fae?T2:x2;function T2(t){return t.replace(i2e,"\\$2")}Dt.escapeWindowsPath=T2;function x2(t){return t.replace(n2e,"\\$2")}Dt.escapePosixPath=x2;Dt.convertPathToPattern=fae?pae:hae;function pae(t){return T2(t).replace(o2e,"//$1").replace(s2e,"/")}Dt.convertWindowsPathToPattern=pae;function hae(t){return x2(t)}Dt.convertPosixPathToPattern=hae});var _ae=b((qDt,gae)=>{"use strict";gae.exports=function(e){if(typeof e!="string"||e==="")return!1;for(var r;r=/(\\).|([@?!+*]\(.*\))/g.exec(e);){if(r[2])return!0;e=e.slice(r.index+r[0].length)}return!1}});var Eae=b((VDt,Sae)=>{"use strict";var u2e=_ae(),yae={"{":"}","(":")","[":"]"},d2e=function(t){if(t[0]==="!")return!0;for(var e=0,r=-2,n=-2,i=-2,o=-2,s=-2;e<t.length;){if(t[e]==="*"||t[e+1]==="?"&&/[\].+)]/.test(t[e])||n!==-1&&t[e]==="["&&t[e+1]!=="]"&&(n<e&&(n=t.indexOf("]",e)),n>e&&(s===-1||s>n||(s=t.indexOf("\\",e),s===-1||s>n)))||i!==-1&&t[e]==="{"&&t[e+1]!=="}"&&(i=t.indexOf("}",e),i>e&&(s=t.indexOf("\\",e),s===-1||s>i))||o!==-1&&t[e]==="("&&t[e+1]==="?"&&/[:!=]/.test(t[e+2])&&t[e+3]!==")"&&(o=t.indexOf(")",e),o>e&&(s=t.indexOf("\\",e),s===-1||s>o))||r!==-1&&t[e]==="("&&t[e+1]!=="|"&&(r<e&&(r=t.indexOf("|",e)),r!==-1&&t[r+1]!==")"&&(o=t.indexOf(")",r),o>r&&(s=t.indexOf("\\",r),s===-1||s>o))))return!0;if(t[e]==="\\"){var a=t[e+1];e+=2;var c=yae[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},f2e=function(t){if(t[0]==="!")return!0;for(var e=0;e<t.length;){if(/[*?{}()[\]]/.test(t[e]))return!0;if(t[e]==="\\"){var r=t[e+1];e+=2;var n=yae[r];if(n){var i=t.indexOf(n,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};Sae.exports=function(e,r){if(typeof e!="string"||e==="")return!1;if(u2e(e))return!0;var n=d2e;return r&&r.strict===!1&&(n=f2e),n(e)}});var bae=b((HDt,vae)=>{"use strict";var p2e=Eae(),h2e=Z("path").posix.dirname,m2e=Z("os").platform()==="win32",w2="/",g2e=/\\/g,_2e=/[\{\[].*[\}\]]$/,y2e=/(^|[^\\])([\{\[]|\([^\)]+$)/,S2e=/\\([\!\*\?\|\[\]\(\)\{\}])/g;vae.exports=function(e,r){var n=Object.assign({flipBackslashes:!0},r);n.flipBackslashes&&m2e&&e.indexOf(w2)<0&&(e=e.replace(g2e,w2)),_2e.test(e)&&(e+=w2),e+="a";do e=h2e(e);while(p2e(e)||y2e.test(e));return e.replace(S2e,"$1")}});var JR=b(Zn=>{"use strict";Zn.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;Zn.find=(t,e)=>t.nodes.find(r=>r.type===e);Zn.exceedsLimit=(t,e,r=1,n)=>n===!1||!Zn.isInteger(t)||!Zn.isInteger(e)?!1:(Number(e)-Number(t))/Number(r)>=n;Zn.escapeNode=(t,e=0,r)=>{let n=t.nodes[e];n&&(r&&n.type===r||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};Zn.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;Zn.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1;Zn.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;Zn.reduce=t=>t.reduce((e,r)=>(r.type==="text"&&e.push(r.value),r.type==="range"&&(r.type="text"),e),[]);Zn.flatten=(...t)=>{let e=[],r=n=>{for(let i=0;i<n.length;i++){let o=n[i];if(Array.isArray(o)){r(o);continue}o!==void 0&&e.push(o)}return e};return r(t),e}});var XR=b((YDt,xae)=>{"use strict";var Tae=JR();xae.exports=(t,e={})=>{let r=(n,i={})=>{let o=e.escapeInvalid&&Tae.isInvalidBrace(i),s=n.invalid===!0&&e.escapeInvalid===!0,a="";if(n.value)return(o||s)&&Tae.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let c of n.nodes)a+=r(c);return a};return r(t)}});var Aae=b((KDt,wae)=>{"use strict";wae.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var Dae=b((ZDt,Mae)=>{"use strict";var Rae=Aae(),bu=(t,e,r)=>{if(Rae(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Rae(e)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...r};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let i=String(n.relaxZeros),o=String(n.shorthand),s=String(n.capture),a=String(n.wrap),c=t+":"+e+"="+i+o+s+a;if(bu.cache.hasOwnProperty(c))return bu.cache[c].result;let l=Math.min(t,e),u=Math.max(t,e);if(Math.abs(l-u)===1){let m=t+"|"+e;return n.capture?`(${m})`:n.wrap===!1?m:`(?:${m})`}let d=kae(t)||kae(e),f={min:t,max:e,a:l,b:u},p=[],h=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let m=u<0?Math.abs(u):1;h=Iae(m,Math.abs(l),f,n),l=f.a=0}return u>=0&&(p=Iae(l,u,f,n)),f.negatives=h,f.positives=p,f.result=E2e(h,p,n),n.capture===!0?f.result=`(${f.result})`:n.wrap!==!1&&p.length+h.length>1&&(f.result=`(?:${f.result})`),bu.cache[c]=f,f.result};function E2e(t,e,r){let n=A2(t,e,"-",!1,r)||[],i=A2(e,t,"",!1,r)||[],o=A2(t,e,"-?",!0,r)||[];return n.concat(o).concat(i).join("|")}function v2e(t,e){let r=1,n=1,i=Pae(t,r),o=new Set([e]);for(;t<=i&&i<=e;)o.add(i),r+=1,i=Pae(t,r);for(i=Oae(e+1,n)-1;t<i&&i<=e;)o.add(i),n+=1,i=Oae(e+1,n)-1;return o=[...o],o.sort(x2e),o}function b2e(t,e,r){if(t===e)return{pattern:t,count:[],digits:0};let n=T2e(t,e),i=n.length,o="",s=0;for(let a=0;a<i;a++){let[c,l]=n[a];c===l?o+=c:c!=="0"||l!=="9"?o+=w2e(c,l,r):s++}return s&&(o+=r.shorthand===!0?"\\d":"[0-9]"),{pattern:o,count:[s],digits:i}}function Iae(t,e,r,n){let i=v2e(t,e),o=[],s=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=b2e(String(s),String(l),n),d="";if(!r.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Nae(a.count),s=l+1;continue}r.isPadded&&(d=A2e(l,r,n)),u.string=d+u.pattern+Nae(u.count),o.push(u),s=l+1,a=u}return o}function A2(t,e,r,n,i){let o=[];for(let s of t){let{string:a}=s;!n&&!Cae(e,"string",a)&&o.push(r+a),n&&Cae(e,"string",a)&&o.push(r+a)}return o}function T2e(t,e){let r=[];for(let n=0;n<t.length;n++)r.push([t[n],e[n]]);return r}function x2e(t,e){return t>e?1:e>t?-1:0}function Cae(t,e,r){return t.some(n=>n[e]===r)}function Pae(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Oae(t,e){return t-t%Math.pow(10,e)}function Nae(t){let[e=0,r=""]=t;return r||e>1?`{${e+(r?","+r:"")}}`:""}function w2e(t,e,r){return`[${t}${e-t===1?"":"-"}${e}]`}function kae(t){return/^-?(0+)\d/.test(t)}function A2e(t,e,r){if(!e.isPadded)return t;let n=Math.abs(e.maxLen-String(t).length),i=r.relaxZeros!==!1;switch(n){case 0:return"";case 1:return i?"0?":"0";case 2:return i?"0{0,2}":"00";default:return i?`0{0,${n}}`:`0{${n}}`}}bu.cache={};bu.clearCache=()=>bu.cache={};Mae.exports=bu});var C2=b((JDt,zae)=>{"use strict";var R2e=Z("util"),$ae=Dae(),Lae=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),I2e=t=>e=>t===!0?Number(e):String(e),R2=t=>typeof t=="number"||typeof t=="string"&&t!=="",Yy=t=>Number.isInteger(+t),I2=t=>{let e=`${t}`,r=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++r]==="0";);return r>0},C2e=(t,e,r)=>typeof t=="string"||typeof e=="string"?!0:r.stringify===!0,P2e=(t,e,r)=>{if(e>0){let n=t[0]==="-"?"-":"";n&&(t=t.slice(1)),t=n+t.padStart(n?e-1:e,"0")}return r===!1?String(t):t},eI=(t,e)=>{let r=t[0]==="-"?"-":"";for(r&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return r?"-"+t:t},O2e=(t,e,r)=>{t.negatives.sort((a,c)=>a<c?-1:a>c?1:0),t.positives.sort((a,c)=>a<c?-1:a>c?1:0);let n=e.capture?"":"?:",i="",o="",s;return t.positives.length&&(i=t.positives.map(a=>eI(String(a),r)).join("|")),t.negatives.length&&(o=`-(${n}${t.negatives.map(a=>eI(String(a),r)).join("|")})`),i&&o?s=`${i}|${o}`:s=i||o,e.wrap?`(${n}${s})`:s},Uae=(t,e,r,n)=>{if(r)return $ae(t,e,{wrap:!1,...n});let i=String.fromCharCode(t);if(t===e)return i;let o=String.fromCharCode(e);return`[${i}-${o}]`},Fae=(t,e,r)=>{if(Array.isArray(t)){let n=r.wrap===!0,i=r.capture?"":"?:";return n?`(${i}${t.join("|")})`:t.join("|")}return $ae(t,e,r)},Bae=(...t)=>new RangeError("Invalid range arguments: "+R2e.inspect(...t)),jae=(t,e,r)=>{if(r.strictRanges===!0)throw Bae([t,e]);return[]},N2e=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},k2e=(t,e,r=1,n={})=>{let i=Number(t),o=Number(e);if(!Number.isInteger(i)||!Number.isInteger(o)){if(n.strictRanges===!0)throw Bae([t,e]);return[]}i===0&&(i=0),o===0&&(o=0);let s=i>o,a=String(t),c=String(e),l=String(r);r=Math.max(Math.abs(r),1);let u=I2(a)||I2(c)||I2(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&C2e(t,e,n)===!1,p=n.transform||I2e(f);if(n.toRegex&&r===1)return Uae(eI(t,d),eI(e,d),!0,n);let h={negatives:[],positives:[]},m=T=>h[T<0?"negatives":"positives"].push(Math.abs(T)),y=[],S=0;for(;s?i>=o:i<=o;)n.toRegex===!0&&r>1?m(i):y.push(P2e(p(i,S),d,f)),i=s?i-r:i+r,S++;return n.toRegex===!0?r>1?O2e(h,n,d):Fae(y,null,{wrap:!1,...n}):y},M2e=(t,e,r=1,n={})=>{if(!Yy(t)&&t.length>1||!Yy(e)&&e.length>1)return jae(t,e,n);let i=n.transform||(f=>String.fromCharCode(f)),o=`${t}`.charCodeAt(0),s=`${e}`.charCodeAt(0),a=o>s,c=Math.min(o,s),l=Math.max(o,s);if(n.toRegex&&r===1)return Uae(c,l,!1,n);let u=[],d=0;for(;a?o>=s:o<=s;)u.push(i(o,d)),o=a?o-r:o+r,d++;return n.toRegex===!0?Fae(u,null,{wrap:!1,options:n}):u},QR=(t,e,r,n={})=>{if(e==null&&R2(t))return[t];if(!R2(t)||!R2(e))return jae(t,e,n);if(typeof r=="function")return QR(t,e,1,{transform:r});if(Lae(r))return QR(t,e,0,r);let i={...n};return i.capture===!0&&(i.wrap=!0),r=r||i.step||1,Yy(r)?Yy(t)&&Yy(e)?k2e(t,e,r,i):M2e(t,e,Math.max(Math.abs(r),1),i):r!=null&&!Lae(r)?N2e(r,i):QR(t,e,1,r)};zae.exports=QR});var Vae=b((XDt,qae)=>{"use strict";var D2e=C2(),Gae=JR(),L2e=(t,e={})=>{let r=(n,i={})=>{let o=Gae.isInvalidBrace(i),s=n.invalid===!0&&e.escapeInvalid===!0,a=o===!0||s===!0,c=e.escapeInvalid===!0?"\\":"",l="";if(n.isOpen===!0)return c+n.value;if(n.isClose===!0)return console.log("node.isClose",c,n.value),c+n.value;if(n.type==="open")return a?c+n.value:"(";if(n.type==="close")return a?c+n.value:")";if(n.type==="comma")return n.prev.type==="comma"?"":a?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let u=Gae.reduce(n.nodes),d=D2e(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(n.nodes)for(let u of n.nodes)l+=r(u,n);return l};return r(t)};qae.exports=L2e});var Yae=b((QDt,Wae)=>{"use strict";var $2e=C2(),Hae=XR(),mh=JR(),Tu=(t="",e="",r=!1)=>{let n=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return r?mh.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let o of i)n.push(Tu(o,e,r));else for(let o of e)r===!0&&typeof o=="string"&&(o=`{${o}}`),n.push(Array.isArray(o)?Tu(i,o,r):i+o);return mh.flatten(n)},U2e=(t,e={})=>{let r=e.rangeLimit===void 0?1e3:e.rangeLimit,n=(i,o={})=>{i.queue=[];let s=o,a=o.queue;for(;s.type!=="brace"&&s.type!=="root"&&s.parent;)s=s.parent,a=s.queue;if(i.invalid||i.dollar){a.push(Tu(a.pop(),Hae(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(Tu(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let d=mh.reduce(i.nodes);if(mh.exceedsLimit(...d,e.step,r))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=$2e(...d,e);f.length===0&&(f=Hae(i,e)),a.push(Tu(a.pop(),f)),i.nodes=[];return}let c=mh.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<i.nodes.length;d++){let f=i.nodes[d];if(f.type==="comma"&&i.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(Tu(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(Tu(l.pop(),f.value));continue}f.nodes&&n(f,i)}return l};return mh.flatten(n(t))};Wae.exports=U2e});var Zae=b((eLt,Kae)=>{"use strict";Kae.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
24
|
+
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var tce=b((tLt,ece)=>{"use strict";var F2e=XR(),{MAX_LENGTH:Jae,CHAR_BACKSLASH:P2,CHAR_BACKTICK:B2e,CHAR_COMMA:j2e,CHAR_DOT:z2e,CHAR_LEFT_PARENTHESES:G2e,CHAR_RIGHT_PARENTHESES:q2e,CHAR_LEFT_CURLY_BRACE:V2e,CHAR_RIGHT_CURLY_BRACE:H2e,CHAR_LEFT_SQUARE_BRACKET:Xae,CHAR_RIGHT_SQUARE_BRACKET:Qae,CHAR_DOUBLE_QUOTE:W2e,CHAR_SINGLE_QUOTE:Y2e,CHAR_NO_BREAK_SPACE:K2e,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Z2e}=Zae(),J2e=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let r=e||{},n=typeof r.maxLength=="number"?Math.min(Jae,r.maxLength):Jae;if(t.length>n)throw new SyntaxError(`Input length (${t.length}), exceeds max characters (${n})`);let i={type:"root",input:t,nodes:[]},o=[i],s=i,a=i,c=0,l=t.length,u=0,d=0,f,p=()=>t[u++],h=m=>{if(m.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&m.type==="text"){a.value+=m.value;return}return s.nodes.push(m),m.parent=s,m.prev=a,a=m,m};for(h({type:"bos"});u<l;)if(s=o[o.length-1],f=p(),!(f===Z2e||f===K2e)){if(f===P2){h({type:"text",value:(e.keepEscaping?f:"")+p()});continue}if(f===Qae){h({type:"text",value:"\\"+f});continue}if(f===Xae){c++;let m;for(;u<l&&(m=p());){if(f+=m,m===Xae){c++;continue}if(m===P2){f+=p();continue}if(m===Qae&&(c--,c===0))break}h({type:"text",value:f});continue}if(f===G2e){s=h({type:"paren",nodes:[]}),o.push(s),h({type:"text",value:f});continue}if(f===q2e){if(s.type!=="paren"){h({type:"text",value:f});continue}s=o.pop(),h({type:"text",value:f}),s=o[o.length-1];continue}if(f===W2e||f===Y2e||f===B2e){let m=f,y;for(e.keepQuotes!==!0&&(f="");u<l&&(y=p());){if(y===P2){f+=y+p();continue}if(y===m){e.keepQuotes===!0&&(f+=y);break}f+=y}h({type:"text",value:f});continue}if(f===V2e){d++;let y={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||s.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};s=h(y),o.push(s),h({type:"open",value:f});continue}if(f===H2e){if(s.type!=="brace"){h({type:"text",value:f});continue}let m="close";s=o.pop(),s.close=!0,h({type:m,value:f}),d--,s=o[o.length-1];continue}if(f===j2e&&d>0){if(s.ranges>0){s.ranges=0;let m=s.nodes.shift();s.nodes=[m,{type:"text",value:F2e(s)}]}h({type:"comma",value:f}),s.commas++;continue}if(f===z2e&&d>0&&s.commas===0){let m=s.nodes;if(d===0||m.length===0){h({type:"text",value:f});continue}if(a.type==="dot"){if(s.range=[],a.value+=f,a.type="range",s.nodes.length!==3&&s.nodes.length!==5){s.invalid=!0,s.ranges=0,a.type="text";continue}s.ranges++,s.args=[];continue}if(a.type==="range"){m.pop();let y=m[m.length-1];y.value+=a.value+f,a=y,s.ranges--;continue}h({type:"dot",value:f});continue}h({type:"text",value:f})}do if(s=o.pop(),s.type!=="root"){s.nodes.forEach(S=>{S.nodes||(S.type==="open"&&(S.isOpen=!0),S.type==="close"&&(S.isClose=!0),S.nodes||(S.type="text"),S.invalid=!0)});let m=o[o.length-1],y=m.nodes.indexOf(s);m.nodes.splice(y,1,...s.nodes)}while(o.length>0);return h({type:"eos"}),i};ece.exports=J2e});var ice=b((rLt,nce)=>{"use strict";var rce=XR(),X2e=Vae(),Q2e=Yae(),eze=tce(),In=(t,e={})=>{let r=[];if(Array.isArray(t))for(let n of t){let i=In.create(n,e);Array.isArray(i)?r.push(...i):r.push(i)}else r=[].concat(In.create(t,e));return e&&e.expand===!0&&e.nodupes===!0&&(r=[...new Set(r)]),r};In.parse=(t,e={})=>eze(t,e);In.stringify=(t,e={})=>rce(typeof t=="string"?In.parse(t,e):t,e);In.compile=(t,e={})=>(typeof t=="string"&&(t=In.parse(t,e)),X2e(t,e));In.expand=(t,e={})=>{typeof t=="string"&&(t=In.parse(t,e));let r=Q2e(t,e);return e.noempty===!0&&(r=r.filter(Boolean)),e.nodupes===!0&&(r=[...new Set(r)]),r};In.create=(t,e={})=>t===""||t.length<3?[t]:e.expand!==!0?In.compile(t,e):In.expand(t,e);nce.exports=In});var Ky=b((nLt,lce)=>{"use strict";var tze=Z("path"),Oo="\\\\/",oce=`[^${Oo}]`,rze=0,Gs="\\.",nze="\\+",ize="\\?",tI="\\/",oze="(?=.)",sce="[^/]",O2=`(?:${tI}|$)`,ace=`(?:^|${tI})`,N2=`${Gs}{1,2}${O2}`,sze=`(?!${Gs})`,aze=`(?!${ace}${N2})`,cze=`(?!${Gs}{0,1}${O2})`,lze=`(?!${N2})`,uze=`[^.${tI}]`,dze=`${sce}*?`,cce={DOT_LITERAL:Gs,PLUS_LITERAL:nze,QMARK_LITERAL:ize,SLASH_LITERAL:tI,ONE_CHAR:oze,QMARK:sce,END_ANCHOR:O2,DOTS_SLASH:N2,NO_DOT:sze,NO_DOTS:aze,NO_DOT_SLASH:cze,NO_DOTS_SLASH:lze,QMARK_NO_DOT:uze,STAR:dze,START_ANCHOR:ace},fze={...cce,SLASH_LITERAL:`[${Oo}]`,QMARK:oce,STAR:`${oce}*?`,DOTS_SLASH:`${Gs}{1,2}(?:[${Oo}]|$)`,NO_DOT:`(?!${Gs})`,NO_DOTS:`(?!(?:^|[${Oo}])${Gs}{1,2}(?:[${Oo}]|$))`,NO_DOT_SLASH:`(?!${Gs}{0,1}(?:[${Oo}]|$))`,NO_DOTS_SLASH:`(?!${Gs}{1,2}(?:[${Oo}]|$))`,QMARK_NO_DOT:`[^.${Oo}]`,START_ANCHOR:`(?:^|[${Oo}])`,END_ANCHOR:`(?:[${Oo}]|$)`},pze={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};lce.exports={DEFAULT_MAX_EXTGLOB_RECURSION:rze,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:pze,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:tze.sep,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?fze:cce}}});var Zy=b(en=>{"use strict";var hze=Z("path"),mze=process.platform==="win32",{REGEX_BACKSLASH:gze,REGEX_REMOVE_BACKSLASH:_ze,REGEX_SPECIAL_CHARS:yze,REGEX_SPECIAL_CHARS_GLOBAL:Sze}=Ky();en.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);en.hasRegexChars=t=>yze.test(t);en.isRegexChar=t=>t.length===1&&en.hasRegexChars(t);en.escapeRegex=t=>t.replace(Sze,"\\$1");en.toPosixSlashes=t=>t.replace(gze,"/");en.removeBackslashes=t=>t.replace(_ze,e=>e==="\\"?"":e);en.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};en.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:mze===!0||hze.sep==="\\";en.escapeLast=(t,e,r)=>{let n=t.lastIndexOf(e,r);return n===-1?t:t[n-1]==="\\"?en.escapeLast(t,e,n-1):`${t.slice(0,n)}\\${t.slice(n)}`};en.removePrefix=(t,e={})=>{let r=t;return r.startsWith("./")&&(r=r.slice(2),e.prefix="./"),r};en.wrapOutput=(t,e={},r={})=>{let n=r.contains?"":"^",i=r.contains?"":"$",o=`${n}(?:${t})${i}`;return e.negated===!0&&(o=`(?:^(?!${o}).*$)`),o}});var _ce=b((oLt,gce)=>{"use strict";var uce=Zy(),{CHAR_ASTERISK:k2,CHAR_AT:Eze,CHAR_BACKWARD_SLASH:Jy,CHAR_COMMA:vze,CHAR_DOT:M2,CHAR_EXCLAMATION_MARK:D2,CHAR_FORWARD_SLASH:mce,CHAR_LEFT_CURLY_BRACE:L2,CHAR_LEFT_PARENTHESES:$2,CHAR_LEFT_SQUARE_BRACKET:bze,CHAR_PLUS:Tze,CHAR_QUESTION_MARK:dce,CHAR_RIGHT_CURLY_BRACE:xze,CHAR_RIGHT_PARENTHESES:fce,CHAR_RIGHT_SQUARE_BRACKET:wze}=Ky(),pce=t=>t===mce||t===Jy,hce=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Aze=(t,e)=>{let r=e||{},n=t.length-1,i=r.parts===!0||r.scanToEnd===!0,o=[],s=[],a=[],c=t,l=-1,u=0,d=0,f=!1,p=!1,h=!1,m=!1,y=!1,S=!1,T=!1,x=!1,v=!1,N=!1,R=0,U,C,D={value:"",depth:0,isGlob:!1},j=()=>l>=n,_=()=>c.charCodeAt(l+1),ae=()=>(U=C,c.charCodeAt(++l));for(;l<n;){C=ae();let W;if(C===Jy){T=D.backslashes=!0,C=ae(),C===L2&&(S=!0);continue}if(S===!0||C===L2){for(R++;j()!==!0&&(C=ae());){if(C===Jy){T=D.backslashes=!0,ae();continue}if(C===L2){R++;continue}if(S!==!0&&C===M2&&(C=ae())===M2){if(f=D.isBrace=!0,h=D.isGlob=!0,N=!0,i===!0)continue;break}if(S!==!0&&C===vze){if(f=D.isBrace=!0,h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===xze&&(R--,R===0)){S=!1,f=D.isBrace=!0,N=!0;break}}if(i===!0)continue;break}if(C===mce){if(o.push(l),s.push(D),D={value:"",depth:0,isGlob:!1},N===!0)continue;if(U===M2&&l===u+1){u+=2;continue}d=l+1;continue}if(r.noext!==!0&&(C===Tze||C===Eze||C===k2||C===dce||C===D2)===!0&&_()===$2){if(h=D.isGlob=!0,m=D.isExtglob=!0,N=!0,C===D2&&l===u&&(v=!0),i===!0){for(;j()!==!0&&(C=ae());){if(C===Jy){T=D.backslashes=!0,C=ae();continue}if(C===fce){h=D.isGlob=!0,N=!0;break}}continue}break}if(C===k2){if(U===k2&&(y=D.isGlobstar=!0),h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===dce){if(h=D.isGlob=!0,N=!0,i===!0)continue;break}if(C===bze){for(;j()!==!0&&(W=ae());){if(W===Jy){T=D.backslashes=!0,ae();continue}if(W===wze){p=D.isBracket=!0,h=D.isGlob=!0,N=!0;break}}if(i===!0)continue;break}if(r.nonegate!==!0&&C===D2&&l===u){x=D.negated=!0,u++;continue}if(r.noparen!==!0&&C===$2){if(h=D.isGlob=!0,i===!0){for(;j()!==!0&&(C=ae());){if(C===$2){T=D.backslashes=!0,C=ae();continue}if(C===fce){N=!0;break}}continue}break}if(h===!0){if(N=!0,i===!0)continue;break}}r.noext===!0&&(m=!1,h=!1);let I=c,g="",E="";u>0&&(g=c.slice(0,u),c=c.slice(u),d-=u),I&&h===!0&&d>0?(I=c.slice(0,d),E=c.slice(d)):h===!0?(I="",E=c):I=c,I&&I!==""&&I!=="/"&&I!==c&&pce(I.charCodeAt(I.length-1))&&(I=I.slice(0,-1)),r.unescape===!0&&(E&&(E=uce.removeBackslashes(E)),I&&T===!0&&(I=uce.removeBackslashes(I)));let w={prefix:g,input:t,start:u,base:I,glob:E,isBrace:f,isBracket:p,isGlob:h,isExtglob:m,isGlobstar:y,negated:x,negatedExtglob:v};if(r.tokens===!0&&(w.maxDepth=0,pce(C)||s.push(D),w.tokens=s),r.parts===!0||r.tokens===!0){let W;for(let G=0;G<o.length;G++){let ce=W?W+1:u,Te=o[G],we=t.slice(ce,Te);r.tokens&&(G===0&&u!==0?(s[G].isPrefix=!0,s[G].value=g):s[G].value=we,hce(s[G]),w.maxDepth+=s[G].depth),(G!==0||we!=="")&&a.push(we),W=Te}if(W&&W+1<t.length){let G=t.slice(W+1);a.push(G),r.tokens&&(s[s.length-1].value=G,hce(s[s.length-1]),w.maxDepth+=s[s.length-1].depth)}w.slashes=o,w.parts=a}return w};gce.exports=Aze});var bce=b((sLt,vce)=>{"use strict";var Xy=Ky(),vr=Zy(),{MAX_LENGTH:rI,POSIX_REGEX_SOURCE:Rze,REGEX_NON_SPECIAL_CHARS:Ize,REGEX_SPECIAL_CHARS_BACKREF:Cze,REPLACEMENTS:yce}=Xy,Pze=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let r=`[${t.join("-")}]`;try{new RegExp(r)}catch{return t.map(i=>vr.escapeRegex(i)).join("..")}return r},gh=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,Sce=t=>{let e=[],r=0,n=0,i=0,o="",s=!1;for(let a of t){if(s===!0){o+=a,s=!1;continue}if(a==="\\"){o+=a,s=!0;continue}if(a==='"'){i=i===1?0:1,o+=a;continue}if(i===0){if(a==="[")r++;else if(a==="]"&&r>0)r--;else if(r===0){if(a==="(")n++;else if(a===")"&&n>0)n--;else if(a==="|"&&n===0){e.push(o),o="";continue}}}o+=a}return e.push(o),e},Oze=t=>{let e=!1;for(let r of t){if(e===!0){e=!1;continue}if(r==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(r))return!1}return!0},Ece=t=>{let e=t.trim(),r=!0;for(;r===!0;)r=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),r=!0);if(Oze(e))return e.replace(/\\(.)/g,"$1")},Nze=t=>{let e=t.map(Ece).filter(Boolean);for(let r=0;r<e.length;r++)for(let n=r+1;n<e.length;n++){let i=e[r],o=e[n],s=i[0];if(!(!s||i!==s.repeat(i.length)||o!==s.repeat(o.length))&&(i===o||i.startsWith(o)||o.startsWith(i)))return!0}return!1},U2=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let r=0,n=0,i=0,o=!1;for(let s=1;s<t.length;s++){let a=t[s];if(o===!0){o=!1;continue}if(a==="\\"){o=!0;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){r++;continue}if(a==="]"&&r>0){r--;continue}if(!(r>0)){if(a==="("){n++;continue}if(a===")"&&(n--,n===0))return e===!0&&s!==t.length-1?void 0:{type:t[0],body:t.slice(2,s),end:s}}}}},kze=t=>{let e=0,r=[];for(;e<t.length;){let i=U2(t.slice(e),!1);if(!i||i.type!=="*")return;let o=Sce(i.body).map(a=>a.trim());if(o.length!==1)return;let s=Ece(o[0]);if(!s||s.length!==1)return;r.push(s),e+=i.end+1}return r.length<1?void 0:`${r.length===1?vr.escapeRegex(r[0]):`[${r.map(i=>vr.escapeRegex(i)).join("")}]`}*`},Mze=t=>{let e=0,r=t.trim(),n=U2(r);for(;n;)e++,r=n.body.trim(),n=U2(r);return e},Dze=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let r=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:Xy.DEFAULT_MAX_EXTGLOB_RECURSION,n=Sce(t).map(i=>i.trim());if(n.length>1&&(n.some(i=>i==="")||n.some(i=>/^[*?]+$/.test(i))||Nze(n)))return{risky:!0};for(let i of n){let o=kze(i);if(o)return{risky:!0,safeOutput:o};if(Mze(i)>r)return{risky:!0}}return{risky:!1}},F2=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=yce[t]||t;let r={...e},n=typeof r.maxLength=="number"?Math.min(rI,r.maxLength):rI,i=t.length;if(i>n)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${n}`);let o={type:"bos",value:"",output:r.prepend||""},s=[o],a=r.capture?"":"?:",c=vr.isWindows(e),l=Xy.globChars(c),u=Xy.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:h,DOTS_SLASH:m,NO_DOT:y,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:x,QMARK_NO_DOT:v,STAR:N,START_ANCHOR:R}=l,U=te=>`(${a}(?:(?!${R}${te.dot?m:d}).)*?)`,C=r.dot?"":y,D=r.dot?x:v,j=r.bash===!0?U(r):N;r.capture&&(j=`(${j})`),typeof r.noext=="boolean"&&(r.noextglob=r.noext);let _={input:t,index:-1,start:0,dot:r.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:s};t=vr.removePrefix(t,_),i=t.length;let ae=[],I=[],g=[],E=o,w,W=()=>_.index===i-1,G=_.peek=(te=1)=>t[_.index+te],ce=_.advance=()=>t[++_.index]||"",Te=()=>t.slice(_.index+1),we=(te="",Ae=0)=>{_.consumed+=te,_.index+=Ae},Ce=te=>{_.output+=te.output!=null?te.output:te.value,we(te.value)},V=()=>{let te=1;for(;G()==="!"&&(G(2)!=="("||G(3)==="?");)ce(),_.start++,te++;return te%2===0?!1:(_.negated=!0,_.start++,!0)},De=te=>{_[te]++,g.push(te)},be=te=>{_[te]--,g.pop()},ee=te=>{if(E.type==="globstar"){let Ae=_.braces>0&&(te.type==="comma"||te.type==="brace"),K=te.extglob===!0||ae.length&&(te.type==="pipe"||te.type==="paren");te.type!=="slash"&&te.type!=="paren"&&!Ae&&!K&&(_.output=_.output.slice(0,-E.output.length),E.type="star",E.value="*",E.output=j,_.output+=E.output)}if(ae.length&&te.type!=="paren"&&(ae[ae.length-1].inner+=te.value),(te.value||te.output)&&Ce(te),E&&E.type==="text"&&te.type==="text"){E.value+=te.value,E.output=(E.output||"")+te.value;return}te.prev=E,s.push(te),E=te},ie=(te,Ae)=>{let K={...u[Ae],conditions:1,inner:""};K.prev=E,K.parens=_.parens,K.output=_.output,K.startIndex=_.index,K.tokensIndex=s.length;let M=(r.capture?"(":"")+K.open;De("parens"),ee({type:te,value:Ae,output:_.output?"":h}),ee({type:"paren",extglob:!0,value:ce(),output:M}),ae.push(K)},Re=te=>{let Ae=t.slice(te.startIndex,_.index+1),K=t.slice(te.startIndex+2,_.index),M=Dze(K,r);if((te.type==="plus"||te.type==="star")&&M.risky){let A=M.safeOutput?(te.output?"":h)+(r.capture?`(${M.safeOutput})`:M.safeOutput):void 0,J=s[te.tokensIndex];J.type="text",J.value=Ae,J.output=A||vr.escapeRegex(Ae);for(let ne=te.tokensIndex+1;ne<s.length;ne++)s[ne].value="",s[ne].output="",delete s[ne].suffix;_.output=te.output+J.output,_.backtrack=!0,ee({type:"paren",extglob:!0,value:w,output:""}),be("parens");return}let k=te.close+(r.capture?")":""),F;if(te.type==="negate"){let A=j;if(te.inner&&te.inner.length>1&&te.inner.includes("/")&&(A=U(r)),(A!==j||W()||/^\)+$/.test(Te()))&&(k=te.close=`)$))${A}`),te.inner.includes("*")&&(F=Te())&&/^\.[^\\/.]+$/.test(F)){let J=F2(F,{...e,fastpaths:!1}).output;k=te.close=`)${J})${A})`}te.prev.type==="bos"&&(_.negatedExtglob=!0)}ee({type:"paren",extglob:!0,value:w,output:k}),be("parens")};if(r.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let te=!1,Ae=t.replace(Cze,(K,M,k,F,A,J)=>F==="\\"?(te=!0,K):F==="?"?M?M+F+(A?x.repeat(A.length):""):J===0?D+(A?x.repeat(A.length):""):x.repeat(k.length):F==="."?d.repeat(k.length):F==="*"?M?M+F+(A?j:""):j:M?K:`\\${K}`);return te===!0&&(r.unescape===!0?Ae=Ae.replace(/\\/g,""):Ae=Ae.replace(/\\+/g,K=>K.length%2===0?"\\\\":K?"\\":"")),Ae===t&&r.contains===!0?(_.output=t,_):(_.output=vr.wrapOutput(Ae,_,e),_)}for(;!W();){if(w=ce(),w==="\0")continue;if(w==="\\"){let K=G();if(K==="/"&&r.bash!==!0||K==="."||K===";")continue;if(!K){w+="\\",ee({type:"text",value:w});continue}let M=/^\\+/.exec(Te()),k=0;if(M&&M[0].length>2&&(k=M[0].length,_.index+=k,k%2!==0&&(w+="\\")),r.unescape===!0?w=ce():w+=ce(),_.brackets===0){ee({type:"text",value:w});continue}}if(_.brackets>0&&(w!=="]"||E.value==="["||E.value==="[^")){if(r.posix!==!1&&w===":"){let K=E.value.slice(1);if(K.includes("[")&&(E.posix=!0,K.includes(":"))){let M=E.value.lastIndexOf("["),k=E.value.slice(0,M),F=E.value.slice(M+2),A=Rze[F];if(A){E.value=k+A,_.backtrack=!0,ce(),!o.output&&s.indexOf(E)===1&&(o.output=h);continue}}}(w==="["&&G()!==":"||w==="-"&&G()==="]")&&(w=`\\${w}`),w==="]"&&(E.value==="["||E.value==="[^")&&(w=`\\${w}`),r.posix===!0&&w==="!"&&E.value==="["&&(w="^"),E.value+=w,Ce({value:w});continue}if(_.quotes===1&&w!=='"'){w=vr.escapeRegex(w),E.value+=w,Ce({value:w});continue}if(w==='"'){_.quotes=_.quotes===1?0:1,r.keepQuotes===!0&&ee({type:"text",value:w});continue}if(w==="("){De("parens"),ee({type:"paren",value:w});continue}if(w===")"){if(_.parens===0&&r.strictBrackets===!0)throw new SyntaxError(gh("opening","("));let K=ae[ae.length-1];if(K&&_.parens===K.parens+1){Re(ae.pop());continue}ee({type:"paren",value:w,output:_.parens?")":"\\)"}),be("parens");continue}if(w==="["){if(r.nobracket===!0||!Te().includes("]")){if(r.nobracket!==!0&&r.strictBrackets===!0)throw new SyntaxError(gh("closing","]"));w=`\\${w}`}else De("brackets");ee({type:"bracket",value:w});continue}if(w==="]"){if(r.nobracket===!0||E&&E.type==="bracket"&&E.value.length===1){ee({type:"text",value:w,output:`\\${w}`});continue}if(_.brackets===0){if(r.strictBrackets===!0)throw new SyntaxError(gh("opening","["));ee({type:"text",value:w,output:`\\${w}`});continue}be("brackets");let K=E.value.slice(1);if(E.posix!==!0&&K[0]==="^"&&!K.includes("/")&&(w=`/${w}`),E.value+=w,Ce({value:w}),r.literalBrackets===!1||vr.hasRegexChars(K))continue;let M=vr.escapeRegex(E.value);if(_.output=_.output.slice(0,-E.value.length),r.literalBrackets===!0){_.output+=M,E.value=M;continue}E.value=`(${a}${M}|${E.value})`,_.output+=E.value;continue}if(w==="{"&&r.nobrace!==!0){De("braces");let K={type:"brace",value:w,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};I.push(K),ee(K);continue}if(w==="}"){let K=I[I.length-1];if(r.nobrace===!0||!K){ee({type:"text",value:w,output:w});continue}let M=")";if(K.dots===!0){let k=s.slice(),F=[];for(let A=k.length-1;A>=0&&(s.pop(),k[A].type!=="brace");A--)k[A].type!=="dots"&&F.unshift(k[A].value);M=Pze(F,r),_.backtrack=!0}if(K.comma!==!0&&K.dots!==!0){let k=_.output.slice(0,K.outputIndex),F=_.tokens.slice(K.tokensIndex);K.value=K.output="\\{",w=M="\\}",_.output=k;for(let A of F)_.output+=A.output||A.value}ee({type:"brace",value:w,output:M}),be("braces"),I.pop();continue}if(w==="|"){ae.length>0&&ae[ae.length-1].conditions++,ee({type:"text",value:w});continue}if(w===","){let K=w,M=I[I.length-1];M&&g[g.length-1]==="braces"&&(M.comma=!0,K="|"),ee({type:"comma",value:w,output:K});continue}if(w==="/"){if(E.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",s.pop(),E=o;continue}ee({type:"slash",value:w,output:p});continue}if(w==="."){if(_.braces>0&&E.type==="dot"){E.value==="."&&(E.output=d);let K=I[I.length-1];E.type="dots",E.output+=w,E.value+=w,K.dots=!0;continue}if(_.braces+_.parens===0&&E.type!=="bos"&&E.type!=="slash"){ee({type:"text",value:w,output:d});continue}ee({type:"dot",value:w,output:d});continue}if(w==="?"){if(!(E&&E.value==="(")&&r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ie("qmark",w);continue}if(E&&E.type==="paren"){let M=G(),k=w;if(M==="<"&&!vr.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(E.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(Te()))&&(k=`\\${w}`),ee({type:"text",value:w,output:k});continue}if(r.dot!==!0&&(E.type==="slash"||E.type==="bos")){ee({type:"qmark",value:w,output:v});continue}ee({type:"qmark",value:w,output:x});continue}if(w==="!"){if(r.noextglob!==!0&&G()==="("&&(G(2)!=="?"||!/[!=<:]/.test(G(3)))){ie("negate",w);continue}if(r.nonegate!==!0&&_.index===0){V();continue}}if(w==="+"){if(r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ie("plus",w);continue}if(E&&E.value==="("||r.regex===!1){ee({type:"plus",value:w,output:f});continue}if(E&&(E.type==="bracket"||E.type==="paren"||E.type==="brace")||_.parens>0){ee({type:"plus",value:w});continue}ee({type:"plus",value:f});continue}if(w==="@"){if(r.noextglob!==!0&&G()==="("&&G(2)!=="?"){ee({type:"at",extglob:!0,value:w,output:""});continue}ee({type:"text",value:w});continue}if(w!=="*"){(w==="$"||w==="^")&&(w=`\\${w}`);let K=Ize.exec(Te());K&&(w+=K[0],_.index+=K[0].length),ee({type:"text",value:w});continue}if(E&&(E.type==="globstar"||E.star===!0)){E.type="star",E.star=!0,E.value+=w,E.output=j,_.backtrack=!0,_.globstar=!0,we(w);continue}let te=Te();if(r.noextglob!==!0&&/^\([^?]/.test(te)){ie("star",w);continue}if(E.type==="star"){if(r.noglobstar===!0){we(w);continue}let K=E.prev,M=K.prev,k=K.type==="slash"||K.type==="bos",F=M&&(M.type==="star"||M.type==="globstar");if(r.bash===!0&&(!k||te[0]&&te[0]!=="/")){ee({type:"star",value:w,output:""});continue}let A=_.braces>0&&(K.type==="comma"||K.type==="brace"),J=ae.length&&(K.type==="pipe"||K.type==="paren");if(!k&&K.type!=="paren"&&!A&&!J){ee({type:"star",value:w,output:""});continue}for(;te.slice(0,3)==="/**";){let ne=t[_.index+4];if(ne&&ne!=="/")break;te=te.slice(3),we("/**",3)}if(K.type==="bos"&&W()){E.type="globstar",E.value+=w,E.output=U(r),_.output=E.output,_.globstar=!0,we(w);continue}if(K.type==="slash"&&K.prev.type!=="bos"&&!F&&W()){_.output=_.output.slice(0,-(K.output+E.output).length),K.output=`(?:${K.output}`,E.type="globstar",E.output=U(r)+(r.strictSlashes?")":"|$)"),E.value+=w,_.globstar=!0,_.output+=K.output+E.output,we(w);continue}if(K.type==="slash"&&K.prev.type!=="bos"&&te[0]==="/"){let ne=te[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(K.output+E.output).length),K.output=`(?:${K.output}`,E.type="globstar",E.output=`${U(r)}${p}|${p}${ne})`,E.value+=w,_.output+=K.output+E.output,_.globstar=!0,we(w+ce()),ee({type:"slash",value:"/",output:""});continue}if(K.type==="bos"&&te[0]==="/"){E.type="globstar",E.value+=w,E.output=`(?:^|${p}|${U(r)}${p})`,_.output=E.output,_.globstar=!0,we(w+ce()),ee({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-E.output.length),E.type="globstar",E.output=U(r),E.value+=w,_.output+=E.output,_.globstar=!0,we(w);continue}let Ae={type:"star",value:w,output:j};if(r.bash===!0){Ae.output=".*?",(E.type==="bos"||E.type==="slash")&&(Ae.output=C+Ae.output),ee(Ae);continue}if(E&&(E.type==="bracket"||E.type==="paren")&&r.regex===!0){Ae.output=w,ee(Ae);continue}(_.index===_.start||E.type==="slash"||E.type==="dot")&&(E.type==="dot"?(_.output+=S,E.output+=S):r.dot===!0?(_.output+=T,E.output+=T):(_.output+=C,E.output+=C),G()!=="*"&&(_.output+=h,E.output+=h)),ee(Ae)}for(;_.brackets>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing","]"));_.output=vr.escapeLast(_.output,"["),be("brackets")}for(;_.parens>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing",")"));_.output=vr.escapeLast(_.output,"("),be("parens")}for(;_.braces>0;){if(r.strictBrackets===!0)throw new SyntaxError(gh("closing","}"));_.output=vr.escapeLast(_.output,"{"),be("braces")}if(r.strictSlashes!==!0&&(E.type==="star"||E.type==="bracket")&&ee({type:"maybe_slash",value:"",output:`${p}?`}),_.backtrack===!0){_.output="";for(let te of _.tokens)_.output+=te.output!=null?te.output:te.value,te.suffix&&(_.output+=te.suffix)}return _};F2.fastpaths=(t,e)=>{let r={...e},n=typeof r.maxLength=="number"?Math.min(rI,r.maxLength):rI,i=t.length;if(i>n)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${n}`);t=yce[t]||t;let o=vr.isWindows(e),{DOT_LITERAL:s,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:h}=Xy.globChars(o),m=r.dot?d:u,y=r.dot?f:u,S=r.capture?"":"?:",T={negated:!1,prefix:""},x=r.bash===!0?".*?":p;r.capture&&(x=`(${x})`);let v=C=>C.noglobstar===!0?x:`(${S}(?:(?!${h}${C.dot?l:s}).)*?)`,N=C=>{switch(C){case"*":return`${m}${c}${x}`;case".*":return`${s}${c}${x}`;case"*.*":return`${m}${x}${s}${c}${x}`;case"*/*":return`${m}${x}${a}${c}${y}${x}`;case"**":return m+v(r);case"**/*":return`(?:${m}${v(r)}${a})?${y}${c}${x}`;case"**/*.*":return`(?:${m}${v(r)}${a})?${y}${x}${s}${c}${x}`;case"**/.*":return`(?:${m}${v(r)}${a})?${s}${c}${x}`;default:{let D=/^(.*?)\.(\w+)$/.exec(C);if(!D)return;let j=N(D[1]);return j?j+s+D[2]:void 0}}},R=vr.removePrefix(t,T),U=N(R);return U&&r.strictSlashes!==!0&&(U+=`${a}?`),U};vce.exports=F2});var xce=b((aLt,Tce)=>{"use strict";var Lze=Z("path"),$ze=_ce(),B2=bce(),j2=Zy(),Uze=Ky(),Fze=t=>t&&typeof t=="object"&&!Array.isArray(t),Ot=(t,e,r=!1)=>{if(Array.isArray(t)){let u=t.map(f=>Ot(f,e,r));return f=>{for(let p of u){let h=p(f);if(h)return h}return!1}}let n=Fze(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!n)throw new TypeError("Expected pattern to be a non-empty string");let i=e||{},o=j2.isWindows(e),s=n?Ot.compileRe(t,e):Ot.makeRe(t,e,!1,!0),a=s.state;delete s.state;let c=()=>!1;if(i.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};c=Ot(i.ignore,u,r)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:h}=Ot.test(u,s,e,{glob:t,posix:o}),m={glob:t,state:a,regex:s,posix:o,input:u,output:h,match:p,isMatch:f};return typeof i.onResult=="function"&&i.onResult(m),f===!1?(m.isMatch=!1,d?m:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(m),m.isMatch=!1,d?m:!1):(typeof i.onMatch=="function"&&i.onMatch(m),d?m:!0)};return r&&(l.state=a),l};Ot.test=(t,e,r,{glob:n,posix:i}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let o=r||{},s=o.format||(i?j2.toPosixSlashes:null),a=t===n,c=a&&s?s(t):t;return a===!1&&(c=s?s(t):t,a=c===n),(a===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?a=Ot.matchBase(t,e,r,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};Ot.matchBase=(t,e,r,n=j2.isWindows(r))=>(e instanceof RegExp?e:Ot.makeRe(e,r)).test(Lze.basename(t));Ot.isMatch=(t,e,r)=>Ot(e,r)(t);Ot.parse=(t,e)=>Array.isArray(t)?t.map(r=>Ot.parse(r,e)):B2(t,{...e,fastpaths:!1});Ot.scan=(t,e)=>$ze(t,e);Ot.compileRe=(t,e,r=!1,n=!1)=>{if(r===!0)return t.output;let i=e||{},o=i.contains?"":"^",s=i.contains?"":"$",a=`${o}(?:${t.output})${s}`;t&&t.negated===!0&&(a=`^(?!${a}).*$`);let c=Ot.toRegex(a,e);return n===!0&&(c.state=t),c};Ot.makeRe=(t,e={},r=!1,n=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(i.output=B2.fastpaths(t,e)),i.output||(i=B2(t,e)),Ot.compileRe(i,e,r,n)};Ot.toRegex=(t,e)=>{try{let r=e||{};return new RegExp(t,r.flags||(r.nocase?"i":""))}catch(r){if(e&&e.debug===!0)throw r;return/$^/}};Ot.constants=Uze;Tce.exports=Ot});var Ace=b((cLt,wce)=>{"use strict";wce.exports=xce()});var G2=b((lLt,Oce)=>{"use strict";var Ice=Z("util"),Cce=ice(),No=Ace(),z2=Zy(),Rce=t=>t===""||t==="./",Pce=t=>{let e=t.indexOf("{");return e>-1&&t.indexOf("}",e)>-1},ht=(t,e,r)=>{e=[].concat(e),t=[].concat(t);let n=new Set,i=new Set,o=new Set,s=0,a=u=>{o.add(u.output),r&&r.onResult&&r.onResult(u)};for(let u=0;u<e.length;u++){let d=No(String(e[u]),{...r,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&s++;for(let p of t){let h=d(p,!0);(f?!h.isMatch:h.isMatch)&&(f?n.add(h.output):(n.delete(h.output),i.add(h.output)))}}let l=(s===e.length?[...o]:[...i]).filter(u=>!n.has(u));if(r&&l.length===0){if(r.failglob===!0)throw new Error(`No matches found for "${e.join(", ")}"`);if(r.nonull===!0||r.nullglob===!0)return r.unescape?e.map(u=>u.replace(/\\/g,"")):e}return l};ht.match=ht;ht.matcher=(t,e)=>No(t,e);ht.isMatch=(t,e,r)=>No(e,r)(t);ht.any=ht.isMatch;ht.not=(t,e,r={})=>{e=[].concat(e).map(String);let n=new Set,i=[],o=a=>{r.onResult&&r.onResult(a),i.push(a.output)},s=new Set(ht(t,e,{...r,onResult:o}));for(let a of i)s.has(a)||n.add(a);return[...n]};ht.contains=(t,e,r)=>{if(typeof t!="string")throw new TypeError(`Expected a string: "${Ice.inspect(t)}"`);if(Array.isArray(e))return e.some(n=>ht.contains(t,n,r));if(typeof e=="string"){if(Rce(t)||Rce(e))return!1;if(t.includes(e)||t.startsWith("./")&&t.slice(2).includes(e))return!0}return ht.isMatch(t,e,{...r,contains:!0})};ht.matchKeys=(t,e,r)=>{if(!z2.isObject(t))throw new TypeError("Expected the first argument to be an object");let n=ht(Object.keys(t),e,r),i={};for(let o of n)i[o]=t[o];return i};ht.some=(t,e,r)=>{let n=[].concat(t);for(let i of[].concat(e)){let o=No(String(i),r);if(n.some(s=>o(s)))return!0}return!1};ht.every=(t,e,r)=>{let n=[].concat(t);for(let i of[].concat(e)){let o=No(String(i),r);if(!n.every(s=>o(s)))return!1}return!0};ht.all=(t,e,r)=>{if(typeof t!="string")throw new TypeError(`Expected a string: "${Ice.inspect(t)}"`);return[].concat(e).every(n=>No(n,r)(t))};ht.capture=(t,e,r)=>{let n=z2.isWindows(r),o=No.makeRe(String(t),{...r,capture:!0}).exec(n?z2.toPosixSlashes(e):e);if(o)return o.slice(1).map(s=>s===void 0?"":s)};ht.makeRe=(...t)=>No.makeRe(...t);ht.scan=(...t)=>No.scan(...t);ht.parse=(t,e)=>{let r=[];for(let n of[].concat(t||[]))for(let i of Cce(String(n),e))r.push(No.parse(i,e));return r};ht.braces=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");return e&&e.nobrace===!0||!Pce(t)?[t]:Cce(t,e)};ht.braceExpand=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");return ht.braces(t,{...e,expand:!0})};ht.hasBraces=Pce;Oce.exports=ht});var jce=b(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.isAbsolute=Ie.partitionAbsoluteAndRelative=Ie.removeDuplicateSlashes=Ie.matchAny=Ie.convertPatternsToRe=Ie.makeRe=Ie.getPatternParts=Ie.expandBraceExpansion=Ie.expandPatternsWithBraceExpansion=Ie.isAffectDepthOfReadingPattern=Ie.endsWithSlashGlobStar=Ie.hasGlobStar=Ie.getBaseDirectory=Ie.isPatternRelatedToParentDirectory=Ie.getPatternsOutsideCurrentDirectory=Ie.getPatternsInsideCurrentDirectory=Ie.getPositivePatterns=Ie.getNegativePatterns=Ie.isPositivePattern=Ie.isNegativePattern=Ie.convertToNegativePattern=Ie.convertToPositivePattern=Ie.isDynamicPattern=Ie.isStaticPattern=void 0;var Nce=Z("path"),Bze=bae(),q2=G2(),kce="**",jze="\\",zze=/[*?]|^!/,Gze=/\[[^[]*]/,qze=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/,Vze=/[!*+?@]\([^(]*\)/,Hze=/,|\.\./,Wze=/(?!^)\/{2,}/g;function Mce(t,e={}){return!Dce(t,e)}Ie.isStaticPattern=Mce;function Dce(t,e={}){return t===""?!1:!!(e.caseSensitiveMatch===!1||t.includes(jze)||zze.test(t)||Gze.test(t)||qze.test(t)||e.extglob!==!1&&Vze.test(t)||e.braceExpansion!==!1&&Yze(t))}Ie.isDynamicPattern=Dce;function Yze(t){let e=t.indexOf("{");if(e===-1)return!1;let r=t.indexOf("}",e+1);if(r===-1)return!1;let n=t.slice(e,r);return Hze.test(n)}function Kze(t){return nI(t)?t.slice(1):t}Ie.convertToPositivePattern=Kze;function Zze(t){return"!"+t}Ie.convertToNegativePattern=Zze;function nI(t){return t.startsWith("!")&&t[1]!=="("}Ie.isNegativePattern=nI;function Lce(t){return!nI(t)}Ie.isPositivePattern=Lce;function Jze(t){return t.filter(nI)}Ie.getNegativePatterns=Jze;function Xze(t){return t.filter(Lce)}Ie.getPositivePatterns=Xze;function Qze(t){return t.filter(e=>!V2(e))}Ie.getPatternsInsideCurrentDirectory=Qze;function eGe(t){return t.filter(V2)}Ie.getPatternsOutsideCurrentDirectory=eGe;function V2(t){return t.startsWith("..")||t.startsWith("./..")}Ie.isPatternRelatedToParentDirectory=V2;function tGe(t){return Bze(t,{flipBackslashes:!1})}Ie.getBaseDirectory=tGe;function rGe(t){return t.includes(kce)}Ie.hasGlobStar=rGe;function $ce(t){return t.endsWith("/"+kce)}Ie.endsWithSlashGlobStar=$ce;function nGe(t){let e=Nce.basename(t);return $ce(t)||Mce(e)}Ie.isAffectDepthOfReadingPattern=nGe;function iGe(t){return t.reduce((e,r)=>e.concat(Uce(r)),[])}Ie.expandPatternsWithBraceExpansion=iGe;function Uce(t){let e=q2.braces(t,{expand:!0,nodupes:!0,keepEscaping:!0});return e.sort((r,n)=>r.length-n.length),e.filter(r=>r!=="")}Ie.expandBraceExpansion=Uce;function oGe(t,e){let{parts:r}=q2.scan(t,Object.assign(Object.assign({},e),{parts:!0}));return r.length===0&&(r=[t]),r[0].startsWith("/")&&(r[0]=r[0].slice(1),r.unshift("")),r}Ie.getPatternParts=oGe;function Fce(t,e){return q2.makeRe(t,e)}Ie.makeRe=Fce;function sGe(t,e){return t.map(r=>Fce(r,e))}Ie.convertPatternsToRe=sGe;function aGe(t,e){return e.some(r=>r.test(t))}Ie.matchAny=aGe;function cGe(t){return t.replace(Wze,"/")}Ie.removeDuplicateSlashes=cGe;function lGe(t){let e=[],r=[];for(let n of t)Bce(n)?e.push(n):r.push(n);return[e,r]}Ie.partitionAbsoluteAndRelative=lGe;function Bce(t){return Nce.isAbsolute(t)}Ie.isAbsolute=Bce});var Vce=b((dLt,qce)=>{"use strict";var uGe=Z("stream"),zce=uGe.PassThrough,dGe=Array.prototype.slice;qce.exports=fGe;function fGe(){let t=[],e=dGe.call(arguments),r=!1,n=e[e.length-1];n&&!Array.isArray(n)&&n.pipe==null?e.pop():n={};let i=n.end!==!1,o=n.pipeError===!0;n.objectMode==null&&(n.objectMode=!0),n.highWaterMark==null&&(n.highWaterMark=64*1024);let s=zce(n);function a(){for(let u=0,d=arguments.length;u<d;u++)t.push(Gce(arguments[u],n));return c(),this}function c(){if(r)return;r=!0;let u=t.shift();if(!u){process.nextTick(l);return}Array.isArray(u)||(u=[u]);let d=u.length+1;function f(){--d>0||(r=!1,c())}function p(h){function m(){h.removeListener("merge2UnpipeEnd",m),h.removeListener("end",m),o&&h.removeListener("error",y),f()}function y(S){s.emit("error",S)}if(h._readableState.endEmitted)return f();h.on("merge2UnpipeEnd",m),h.on("end",m),o&&h.on("error",y),h.pipe(s,{end:!1}),h.resume()}for(let h=0;h<u.length;h++)p(u[h]);f()}function l(){r=!1,s.emit("queueDrain"),i&&s.end()}return s.setMaxListeners(0),s.add=a,s.on("unpipe",function(u){u.emit("merge2UnpipeEnd")}),e.length&&a.apply(null,e),s}function Gce(t,e){if(Array.isArray(t))for(let r=0,n=t.length;r<n;r++)t[r]=Gce(t[r],e);else{if(!t._readableState&&t.pipe&&(t=t.pipe(zce(e))),!t._readableState||!t.pause||!t.pipe)throw new Error("Only readable stream can be merged.");t.pause()}return t}});var Wce=b(iI=>{"use strict";Object.defineProperty(iI,"__esModule",{value:!0});iI.merge=void 0;var pGe=Vce();function hGe(t){let e=pGe(t);return t.forEach(r=>{r.once("error",n=>e.emit("error",n))}),e.once("close",()=>Hce(t)),e.once("end",()=>Hce(t)),e}iI.merge=hGe;function Hce(t){t.forEach(e=>e.emit("close"))}});var Yce=b(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});_h.isEmpty=_h.isString=void 0;function mGe(t){return typeof t=="string"}_h.isString=mGe;function gGe(t){return t===""}_h.isEmpty=gGe});var qs=b(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.string=br.stream=br.pattern=br.path=br.fs=br.errno=br.array=void 0;var _Ge=lae();br.array=_Ge;var yGe=uae();br.errno=yGe;var SGe=dae();br.fs=SGe;var EGe=mae();br.path=EGe;var vGe=jce();br.pattern=vGe;var bGe=Wce();br.stream=bGe;var TGe=Yce();br.string=TGe});var Xce=b(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.convertPatternGroupToTask=Tr.convertPatternGroupsToTasks=Tr.groupPatternsByBaseDirectory=Tr.getNegativePatternsAsPositive=Tr.getPositivePatterns=Tr.convertPatternsToTasks=Tr.generate=void 0;var ki=qs();function xGe(t,e){let r=Kce(t,e),n=Kce(e.ignore,e),i=Zce(r),o=Jce(r,n),s=i.filter(u=>ki.pattern.isStaticPattern(u,e)),a=i.filter(u=>ki.pattern.isDynamicPattern(u,e)),c=H2(s,o,!1),l=H2(a,o,!0);return c.concat(l)}Tr.generate=xGe;function Kce(t,e){let r=t;return e.braceExpansion&&(r=ki.pattern.expandPatternsWithBraceExpansion(r)),e.baseNameMatch&&(r=r.map(n=>n.includes("/")?n:`**/${n}`)),r.map(n=>ki.pattern.removeDuplicateSlashes(n))}function H2(t,e,r){let n=[],i=ki.pattern.getPatternsOutsideCurrentDirectory(t),o=ki.pattern.getPatternsInsideCurrentDirectory(t),s=W2(i),a=W2(o);return n.push(...Y2(s,e,r)),"."in a?n.push(K2(".",o,e,r)):n.push(...Y2(a,e,r)),n}Tr.convertPatternsToTasks=H2;function Zce(t){return ki.pattern.getPositivePatterns(t)}Tr.getPositivePatterns=Zce;function Jce(t,e){return ki.pattern.getNegativePatterns(t).concat(e).map(ki.pattern.convertToPositivePattern)}Tr.getNegativePatternsAsPositive=Jce;function W2(t){let e={};return t.reduce((r,n)=>{let i=ki.pattern.getBaseDirectory(n);return i in r?r[i].push(n):r[i]=[n],r},e)}Tr.groupPatternsByBaseDirectory=W2;function Y2(t,e,r){return Object.keys(t).map(n=>K2(n,t[n],e,r))}Tr.convertPatternGroupsToTasks=Y2;function K2(t,e,r,n){return{dynamic:n,positive:e,negative:r,base:t,patterns:[].concat(e,r.map(ki.pattern.convertToNegativePattern))}}Tr.convertPatternGroupToTask=K2});var ele=b(oI=>{"use strict";Object.defineProperty(oI,"__esModule",{value:!0});oI.read=void 0;function wGe(t,e,r){e.fs.lstat(t,(n,i)=>{if(n!==null){Qce(r,n);return}if(!i.isSymbolicLink()||!e.followSymbolicLink){Z2(r,i);return}e.fs.stat(t,(o,s)=>{if(o!==null){if(e.throwErrorOnBrokenSymbolicLink){Qce(r,o);return}Z2(r,i);return}e.markSymbolicLink&&(s.isSymbolicLink=()=>!0),Z2(r,s)})})}oI.read=wGe;function Qce(t,e){t(e)}function Z2(t,e){t(null,e)}});var tle=b(sI=>{"use strict";Object.defineProperty(sI,"__esModule",{value:!0});sI.read=void 0;function AGe(t,e){let r=e.fs.lstatSync(t);if(!r.isSymbolicLink()||!e.followSymbolicLink)return r;try{let n=e.fs.statSync(t);return e.markSymbolicLink&&(n.isSymbolicLink=()=>!0),n}catch(n){if(!e.throwErrorOnBrokenSymbolicLink)return r;throw n}}sI.read=AGe});var rle=b(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.createFileSystemAdapter=vc.FILE_SYSTEM_ADAPTER=void 0;var aI=Z("fs");vc.FILE_SYSTEM_ADAPTER={lstat:aI.lstat,stat:aI.stat,lstatSync:aI.lstatSync,statSync:aI.statSync};function RGe(t){return t===void 0?vc.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},vc.FILE_SYSTEM_ADAPTER),t)}vc.createFileSystemAdapter=RGe});var nle=b(X2=>{"use strict";Object.defineProperty(X2,"__esModule",{value:!0});var IGe=rle(),J2=class{constructor(e={}){this._options=e,this.followSymbolicLink=this._getValue(this._options.followSymbolicLink,!0),this.fs=IGe.createFileSystemAdapter(this._options.fs),this.markSymbolicLink=this._getValue(this._options.markSymbolicLink,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0)}_getValue(e,r){return e??r}};X2.default=J2});var xu=b(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.statSync=bc.stat=bc.Settings=void 0;var ile=ele(),CGe=tle(),Q2=nle();bc.Settings=Q2.default;function PGe(t,e,r){if(typeof e=="function"){ile.read(t,ez(),e);return}ile.read(t,ez(e),r)}bc.stat=PGe;function OGe(t,e){let r=ez(e);return CGe.read(t,r)}bc.statSync=OGe;function ez(t={}){return t instanceof Q2.default?t:new Q2.default(t)}});var ale=b((vLt,sle)=>{"use strict";var ole;sle.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:global):t=>(ole||(ole=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var lle=b((bLt,cle)=>{"use strict";cle.exports=kGe;var NGe=ale();function kGe(t,e){let r,n,i,o=!0;Array.isArray(t)?(r=[],n=t.length):(i=Object.keys(t),r={},n=i.length);function s(c){function l(){e&&e(c,r),e=null}o?NGe(l):l()}function a(c,l,u){r[c]=u,(--n===0||l)&&s(l)}n?i?i.forEach(function(c){t[c](function(l,u){a(c,l,u)})}):t.forEach(function(c,l){c(function(u,d){a(l,u,d)})}):s(null),o=!1}});var tz=b(lI=>{"use strict";Object.defineProperty(lI,"__esModule",{value:!0});lI.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;var cI=process.versions.node.split(".");if(cI[0]===void 0||cI[1]===void 0)throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);var ule=Number.parseInt(cI[0],10),MGe=Number.parseInt(cI[1],10),dle=10,DGe=10,LGe=ule>dle,$Ge=ule===dle&&MGe>=DGe;lI.IS_SUPPORT_READDIR_WITH_FILE_TYPES=LGe||$Ge});var fle=b(uI=>{"use strict";Object.defineProperty(uI,"__esModule",{value:!0});uI.createDirentFromStats=void 0;var rz=class{constructor(e,r){this.name=e,this.isBlockDevice=r.isBlockDevice.bind(r),this.isCharacterDevice=r.isCharacterDevice.bind(r),this.isDirectory=r.isDirectory.bind(r),this.isFIFO=r.isFIFO.bind(r),this.isFile=r.isFile.bind(r),this.isSocket=r.isSocket.bind(r),this.isSymbolicLink=r.isSymbolicLink.bind(r)}};function UGe(t,e){return new rz(t,e)}uI.createDirentFromStats=UGe});var nz=b(dI=>{"use strict";Object.defineProperty(dI,"__esModule",{value:!0});dI.fs=void 0;var FGe=fle();dI.fs=FGe});var iz=b(fI=>{"use strict";Object.defineProperty(fI,"__esModule",{value:!0});fI.joinPathSegments=void 0;function BGe(t,e,r){return t.endsWith(r)?t+e:t+r+e}fI.joinPathSegments=BGe});var yle=b(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.readdir=Tc.readdirWithFileTypes=Tc.read=void 0;var jGe=xu(),ple=lle(),zGe=tz(),hle=nz(),mle=iz();function GGe(t,e,r){if(!e.stats&&zGe.IS_SUPPORT_READDIR_WITH_FILE_TYPES){gle(t,e,r);return}_le(t,e,r)}Tc.read=GGe;function gle(t,e,r){e.fs.readdir(t,{withFileTypes:!0},(n,i)=>{if(n!==null){pI(r,n);return}let o=i.map(a=>({dirent:a,name:a.name,path:mle.joinPathSegments(t,a.name,e.pathSegmentSeparator)}));if(!e.followSymbolicLinks){oz(r,o);return}let s=o.map(a=>qGe(a,e));ple(s,(a,c)=>{if(a!==null){pI(r,a);return}oz(r,c)})})}Tc.readdirWithFileTypes=gle;function qGe(t,e){return r=>{if(!t.dirent.isSymbolicLink()){r(null,t);return}e.fs.stat(t.path,(n,i)=>{if(n!==null){if(e.throwErrorOnBrokenSymbolicLink){r(n);return}r(null,t);return}t.dirent=hle.fs.createDirentFromStats(t.name,i),r(null,t)})}}function _le(t,e,r){e.fs.readdir(t,(n,i)=>{if(n!==null){pI(r,n);return}let o=i.map(s=>{let a=mle.joinPathSegments(t,s,e.pathSegmentSeparator);return c=>{jGe.stat(a,e.fsStatSettings,(l,u)=>{if(l!==null){c(l);return}let d={name:s,path:a,dirent:hle.fs.createDirentFromStats(s,u)};e.stats&&(d.stats=u),c(null,d)})}});ple(o,(s,a)=>{if(s!==null){pI(r,s);return}oz(r,a)})})}Tc.readdir=_le;function pI(t,e){t(e)}function oz(t,e){t(null,e)}});var Tle=b(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.readdir=xc.readdirWithFileTypes=xc.read=void 0;var VGe=xu(),HGe=tz(),Sle=nz(),Ele=iz();function WGe(t,e){return!e.stats&&HGe.IS_SUPPORT_READDIR_WITH_FILE_TYPES?vle(t,e):ble(t,e)}xc.read=WGe;function vle(t,e){return e.fs.readdirSync(t,{withFileTypes:!0}).map(n=>{let i={dirent:n,name:n.name,path:Ele.joinPathSegments(t,n.name,e.pathSegmentSeparator)};if(i.dirent.isSymbolicLink()&&e.followSymbolicLinks)try{let o=e.fs.statSync(i.path);i.dirent=Sle.fs.createDirentFromStats(i.name,o)}catch(o){if(e.throwErrorOnBrokenSymbolicLink)throw o}return i})}xc.readdirWithFileTypes=vle;function ble(t,e){return e.fs.readdirSync(t).map(n=>{let i=Ele.joinPathSegments(t,n,e.pathSegmentSeparator),o=VGe.statSync(i,e.fsStatSettings),s={name:n,path:i,dirent:Sle.fs.createDirentFromStats(n,o)};return e.stats&&(s.stats=o),s})}xc.readdir=ble});var xle=b(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.createFileSystemAdapter=wc.FILE_SYSTEM_ADAPTER=void 0;var yh=Z("fs");wc.FILE_SYSTEM_ADAPTER={lstat:yh.lstat,stat:yh.stat,lstatSync:yh.lstatSync,statSync:yh.statSync,readdir:yh.readdir,readdirSync:yh.readdirSync};function YGe(t){return t===void 0?wc.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},wc.FILE_SYSTEM_ADAPTER),t)}wc.createFileSystemAdapter=YGe});var wle=b(az=>{"use strict";Object.defineProperty(az,"__esModule",{value:!0});var KGe=Z("path"),ZGe=xu(),JGe=xle(),sz=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=JGe.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,KGe.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new ZGe.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,r){return e??r}};az.default=sz});var hI=b(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.Settings=Ac.scandirSync=Ac.scandir=void 0;var Ale=yle(),XGe=Tle(),cz=wle();Ac.Settings=cz.default;function QGe(t,e,r){if(typeof e=="function"){Ale.read(t,lz(),e);return}Ale.read(t,lz(e),r)}Ac.scandir=QGe;function e4e(t,e){let r=lz(e);return XGe.read(t,r)}Ac.scandirSync=e4e;function lz(t={}){return t instanceof cz.default?t:new cz.default(t)}});var Ile=b((NLt,Rle)=>{"use strict";function t4e(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}Rle.exports=t4e});var Ple=b((kLt,uz)=>{"use strict";var r4e=Ile();function Cle(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),!(r>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var n=r4e(n4e),i=null,o=null,s=0,a=null,c={push:m,drain:tn,saturated:tn,pause:u,paused:!1,get concurrency(){return r},set concurrency(R){if(!(R>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(r=R,!c.paused)for(;i&&s<r;)s++,S()},running:l,resume:p,idle:h,length:d,getQueue:f,unshift:y,empty:tn,kill:T,killAndDrain:x,error:N,abort:v};return c;function l(){return s}function u(){c.paused=!0}function d(){for(var R=i,U=0;R;)R=R.next,U++;return U}function f(){for(var R=i,U=[];R;)U.push(R.value),R=R.next;return U}function p(){if(c.paused){if(c.paused=!1,i===null){s++,S();return}for(;i&&s<r;)s++,S()}}function h(){return s===0&&c.length()===0}function m(R,U){var C=n.get();C.context=t,C.release=S,C.value=R,C.callback=U||tn,C.errorHandler=a,s>=r||c.paused?o?(o.next=C,o=C):(i=C,o=C,c.saturated()):(s++,e.call(t,C.value,C.worked))}function y(R,U){var C=n.get();C.context=t,C.release=S,C.value=R,C.callback=U||tn,C.errorHandler=a,s>=r||c.paused?i?(C.next=i,i=C):(i=C,o=C,c.saturated()):(s++,e.call(t,C.value,C.worked))}function S(R){R&&n.release(R);var U=i;U&&s<=r?c.paused?s--:(o===i&&(o=null),i=U.next,U.next=null,e.call(t,U.value,U.worked),o===null&&c.empty()):--s===0&&c.drain()}function T(){i=null,o=null,c.drain=tn}function x(){i=null,o=null,c.drain(),c.drain=tn}function v(){var R=i;for(i=null,o=null;R;){var U=R.next,C=R.callback,D=R.errorHandler,j=R.value,_=R.context;R.value=null,R.callback=tn,R.errorHandler=null,D&&D(new Error("abort"),j),C.call(_,new Error("abort")),R.release(R),R=U}c.drain=tn}function N(R){a=R}}function tn(){}function n4e(){this.value=null,this.callback=tn,this.next=null,this.release=tn,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,n){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=tn,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function i4e(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(u,d){e.call(this,u).then(function(f){d(null,f)},d)}var i=Cle(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=c,i.drained=l,i;function a(u){var d=new Promise(function(f,p){o(u,function(h,m){if(h){p(h);return}f(m)})});return d.catch(tn),d}function c(u){var d=new Promise(function(f,p){s(u,function(h,m){if(h){p(h);return}f(m)})});return d.catch(tn),d}function l(){var u=new Promise(function(d){process.nextTick(function(){if(i.idle())d();else{var f=i.drain;i.drain=function(){typeof f=="function"&&f(),d(),i.drain=f}}})});return u}}uz.exports=Cle;uz.exports.promise=i4e});var mI=b(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.joinPathSegments=ko.replacePathSegmentSeparator=ko.isAppliedFilter=ko.isFatalError=void 0;function o4e(t,e){return t.errorFilter===null?!0:!t.errorFilter(e)}ko.isFatalError=o4e;function s4e(t,e){return t===null||t(e)}ko.isAppliedFilter=s4e;function a4e(t,e){return t.split(/[/\\]/).join(e)}ko.replacePathSegmentSeparator=a4e;function c4e(t,e,r){return t===""?e:t.endsWith(r)?t+e:t+r+e}ko.joinPathSegments=c4e});var pz=b(fz=>{"use strict";Object.defineProperty(fz,"__esModule",{value:!0});var l4e=mI(),dz=class{constructor(e,r){this._root=e,this._settings=r,this._root=l4e.replacePathSegmentSeparator(e,r.pathSegmentSeparator)}};fz.default=dz});var gz=b(mz=>{"use strict";Object.defineProperty(mz,"__esModule",{value:!0});var u4e=Z("events"),d4e=hI(),f4e=Ple(),gI=mI(),p4e=pz(),hz=class extends p4e.default{constructor(e,r){super(e,r),this._settings=r,this._scandir=d4e.scandir,this._emitter=new u4e.EventEmitter,this._queue=f4e(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit("end")}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw new Error("The reader is already destroyed");this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on("entry",e)}onError(e){this._emitter.once("error",e)}onEnd(e){this._emitter.once("end",e)}_pushToQueue(e,r){let n={directory:e,base:r};this._queue.push(n,i=>{i!==null&&this._handleError(i)})}_worker(e,r){this._scandir(e.directory,this._settings.fsScandirSettings,(n,i)=>{if(n!==null){r(n,void 0);return}for(let o of i)this._handleEntry(o,e.base);r(null,void 0)})}_handleError(e){this._isDestroyed||!gI.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit("error",e))}_handleEntry(e,r){if(this._isDestroyed||this._isFatalError)return;let n=e.path;r!==void 0&&(e.path=gI.joinPathSegments(r,e.name,this._settings.pathSegmentSeparator)),gI.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&gI.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,r===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit("entry",e)}};mz.default=hz});var Ole=b(yz=>{"use strict";Object.defineProperty(yz,"__esModule",{value:!0});var h4e=gz(),_z=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new h4e.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(r=>{m4e(e,r)}),this._reader.onEntry(r=>{this._storage.push(r)}),this._reader.onEnd(()=>{g4e(e,this._storage)}),this._reader.read()}};yz.default=_z;function m4e(t,e){t(e)}function g4e(t,e){t(null,e)}});var Nle=b(Ez=>{"use strict";Object.defineProperty(Ez,"__esModule",{value:!0});var _4e=Z("stream"),y4e=gz(),Sz=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new y4e.default(this._root,this._settings),this._stream=new _4e.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit("error",e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}};Ez.default=Sz});var kle=b(bz=>{"use strict";Object.defineProperty(bz,"__esModule",{value:!0});var S4e=hI(),_I=mI(),E4e=pz(),vz=class extends E4e.default{constructor(){super(...arguments),this._scandir=S4e.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,r){this._queue.add({directory:e,base:r})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,r){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let i of n)this._handleEntry(i,r)}catch(n){this._handleError(n)}}_handleError(e){if(_I.isFatalError(this._settings,e))throw e}_handleEntry(e,r){let n=e.path;r!==void 0&&(e.path=_I.joinPathSegments(r,e.name,this._settings.pathSegmentSeparator)),_I.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&_I.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,r===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}};bz.default=vz});var Mle=b(xz=>{"use strict";Object.defineProperty(xz,"__esModule",{value:!0});var v4e=kle(),Tz=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new v4e.default(this._root,this._settings)}read(){return this._reader.read()}};xz.default=Tz});var Dle=b(Az=>{"use strict";Object.defineProperty(Az,"__esModule",{value:!0});var b4e=Z("path"),T4e=hI(),wz=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,Number.POSITIVE_INFINITY),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,b4e.sep),this.fsScandirSettings=new T4e.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,r){return e??r}};Az.default=wz});var SI=b(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.Settings=Mo.walkStream=Mo.walkSync=Mo.walk=void 0;var Lle=Ole(),x4e=Nle(),w4e=Mle(),Rz=Dle();Mo.Settings=Rz.default;function A4e(t,e,r){if(typeof e=="function"){new Lle.default(t,yI()).read(e);return}new Lle.default(t,yI(e)).read(r)}Mo.walk=A4e;function R4e(t,e){let r=yI(e);return new w4e.default(t,r).read()}Mo.walkSync=R4e;function I4e(t,e){let r=yI(e);return new x4e.default(t,r).read()}Mo.walkStream=I4e;function yI(t={}){return t instanceof Rz.default?t:new Rz.default(t)}});var EI=b(Cz=>{"use strict";Object.defineProperty(Cz,"__esModule",{value:!0});var C4e=Z("path"),P4e=xu(),$le=qs(),Iz=class{constructor(e){this._settings=e,this._fsStatSettings=new P4e.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return C4e.resolve(this._settings.cwd,e)}_makeEntry(e,r){let n={name:r,path:r,dirent:$le.fs.createDirentFromStats(r,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!$le.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}};Cz.default=Iz});var Nz=b(Oz=>{"use strict";Object.defineProperty(Oz,"__esModule",{value:!0});var O4e=Z("stream"),N4e=xu(),k4e=SI(),M4e=EI(),Pz=class extends M4e.default{constructor(){super(...arguments),this._walkStream=k4e.walkStream,this._stat=N4e.stat}dynamic(e,r){return this._walkStream(e,r)}static(e,r){let n=e.map(this._getFullEntryPath,this),i=new O4e.PassThrough({objectMode:!0});i._write=(o,s,a)=>this._getEntry(n[o],e[o],r).then(c=>{c!==null&&r.entryFilter(c)&&i.push(c),o===n.length-1&&i.end(),a()}).catch(a);for(let o=0;o<n.length;o++)i.write(o);return i}_getEntry(e,r,n){return this._getStat(e).then(i=>this._makeEntry(i,r)).catch(i=>{if(n.errorFilter(i))return null;throw i})}_getStat(e){return new Promise((r,n)=>{this._stat(e,this._fsStatSettings,(i,o)=>i===null?r(o):n(i))})}};Oz.default=Pz});var Ule=b(Mz=>{"use strict";Object.defineProperty(Mz,"__esModule",{value:!0});var D4e=SI(),L4e=EI(),$4e=Nz(),kz=class extends L4e.default{constructor(){super(...arguments),this._walkAsync=D4e.walk,this._readerStream=new $4e.default(this._settings)}dynamic(e,r){return new Promise((n,i)=>{this._walkAsync(e,r,(o,s)=>{o===null?n(s):i(o)})})}async static(e,r){let n=[],i=this._readerStream.static(e,r);return new Promise((o,s)=>{i.once("error",s),i.on("data",a=>n.push(a)),i.once("end",()=>o(n))})}};Mz.default=kz});var Fle=b(Lz=>{"use strict";Object.defineProperty(Lz,"__esModule",{value:!0});var Qy=qs(),Dz=class{constructor(e,r,n){this._patterns=e,this._settings=r,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let r=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(r);this._storage.push({complete:n.length<=1,pattern:e,segments:r,sections:n})}}_getPatternSegments(e){return Qy.pattern.getPatternParts(e,this._micromatchOptions).map(n=>Qy.pattern.isDynamicPattern(n,this._settings)?{dynamic:!0,pattern:n,patternRe:Qy.pattern.makeRe(n,this._micromatchOptions)}:{dynamic:!1,pattern:n})}_splitSegmentsIntoSections(e){return Qy.array.splitWhen(e,r=>r.dynamic&&Qy.pattern.hasGlobStar(r.pattern))}};Lz.default=Dz});var Ble=b(Uz=>{"use strict";Object.defineProperty(Uz,"__esModule",{value:!0});var U4e=Fle(),$z=class extends U4e.default{match(e){let r=e.split("/"),n=r.length,i=this._storage.filter(o=>!o.complete||o.segments.length>n);for(let o of i){let s=o.sections[0];if(!o.complete&&n>s.length||r.every((c,l)=>{let u=o.segments[l];return!!(u.dynamic&&u.patternRe.test(c)||!u.dynamic&&u.pattern===c)}))return!0}return!1}};Uz.default=$z});var jle=b(Bz=>{"use strict";Object.defineProperty(Bz,"__esModule",{value:!0});var vI=qs(),F4e=Ble(),Fz=class{constructor(e,r){this._settings=e,this._micromatchOptions=r}getFilter(e,r,n){let i=this._getMatcher(r),o=this._getNegativePatternsRe(n);return s=>this._filter(e,s,i,o)}_getMatcher(e){return new F4e.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let r=e.filter(vI.pattern.isAffectDepthOfReadingPattern);return vI.pattern.convertPatternsToRe(r,this._micromatchOptions)}_filter(e,r,n,i){if(this._isSkippedByDeep(e,r.path)||this._isSkippedSymbolicLink(r))return!1;let o=vI.path.removeLeadingDotSegment(r.path);return this._isSkippedByPositivePatterns(o,n)?!1:this._isSkippedByNegativePatterns(o,i)}_isSkippedByDeep(e,r){return this._settings.deep===1/0?!1:this._getEntryLevel(e,r)>=this._settings.deep}_getEntryLevel(e,r){let n=r.split("/").length;if(e==="")return n;let i=e.split("/").length;return n-i}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,r){return!this._settings.baseNameMatch&&!r.match(e)}_isSkippedByNegativePatterns(e,r){return!vI.pattern.matchAny(e,r)}};Bz.default=Fz});var zle=b(zz=>{"use strict";Object.defineProperty(zz,"__esModule",{value:!0});var Rc=qs(),jz=class{constructor(e,r){this._settings=e,this._micromatchOptions=r,this.index=new Map}getFilter(e,r){let[n,i]=Rc.pattern.partitionAbsoluteAndRelative(r),o={positive:{all:Rc.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:Rc.pattern.convertPatternsToRe(n,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:Rc.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return s=>this._filter(s,o)}_filter(e,r){let n=Rc.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(n)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(n,r,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(n),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,r,n){return!(!this._isMatchToPatterns(e,r.positive.all,n)||this._isMatchToPatterns(e,r.negative.relative,n)||this._isMatchToAbsoluteNegative(e,r.negative.absolute,n))}_isMatchToAbsoluteNegative(e,r,n){if(r.length===0)return!1;let i=Rc.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,r,n)}_isMatchToPatterns(e,r,n){if(r.length===0)return!1;let i=Rc.pattern.matchAny(e,r);return!i&&n?Rc.pattern.matchAny(e+"/",r):i}};zz.default=jz});var Gle=b(qz=>{"use strict";Object.defineProperty(qz,"__esModule",{value:!0});var B4e=qs(),Gz=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return B4e.errno.isEnoentCodeError(e)||this._settings.suppressErrors}};qz.default=Gz});var Vle=b(Hz=>{"use strict";Object.defineProperty(Hz,"__esModule",{value:!0});var qle=qs(),Vz=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let r=e.path;return this._settings.absolute&&(r=qle.path.makeAbsolute(this._settings.cwd,r),r=qle.path.unixify(r)),this._settings.markDirectories&&e.dirent.isDirectory()&&(r+="/"),this._settings.objectMode?Object.assign(Object.assign({},e),{path:r}):r}};Hz.default=Vz});var bI=b(Yz=>{"use strict";Object.defineProperty(Yz,"__esModule",{value:!0});var j4e=Z("path"),z4e=jle(),G4e=zle(),q4e=Gle(),V4e=Vle(),Wz=class{constructor(e){this._settings=e,this.errorFilter=new q4e.default(this._settings),this.entryFilter=new G4e.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new z4e.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new V4e.default(this._settings)}_getRootDirectory(e){return j4e.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let r=e.base==="."?"":e.base;return{basePath:r,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(r,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}};Yz.default=Wz});var Hle=b(Zz=>{"use strict";Object.defineProperty(Zz,"__esModule",{value:!0});var H4e=Ule(),W4e=bI(),Kz=class extends W4e.default{constructor(){super(...arguments),this._reader=new H4e.default(this._settings)}async read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(r,e,n)).map(o=>n.transform(o))}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};Zz.default=Kz});var Wle=b(Xz=>{"use strict";Object.defineProperty(Xz,"__esModule",{value:!0});var Y4e=Z("stream"),K4e=Nz(),Z4e=bI(),Jz=class extends Z4e.default{constructor(){super(...arguments),this._reader=new K4e.default(this._settings)}read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e),i=this.api(r,e,n),o=new Y4e.Readable({objectMode:!0,read:()=>{}});return i.once("error",s=>o.emit("error",s)).on("data",s=>o.emit("data",n.transform(s))).once("end",()=>o.emit("end")),o.once("close",()=>i.destroy()),o}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};Xz.default=Jz});var Yle=b(eG=>{"use strict";Object.defineProperty(eG,"__esModule",{value:!0});var J4e=xu(),X4e=SI(),Q4e=EI(),Qz=class extends Q4e.default{constructor(){super(...arguments),this._walkSync=X4e.walkSync,this._statSync=J4e.statSync}dynamic(e,r){return this._walkSync(e,r)}static(e,r){let n=[];for(let i of e){let o=this._getFullEntryPath(i),s=this._getEntry(o,i,r);s===null||!r.entryFilter(s)||n.push(s)}return n}_getEntry(e,r,n){try{let i=this._getStat(e);return this._makeEntry(i,r)}catch(i){if(n.errorFilter(i))return null;throw i}}_getStat(e){return this._statSync(e,this._fsStatSettings)}};eG.default=Qz});var Kle=b(rG=>{"use strict";Object.defineProperty(rG,"__esModule",{value:!0});var eqe=Yle(),tqe=bI(),tG=class extends tqe.default{constructor(){super(...arguments),this._reader=new eqe.default(this._settings)}read(e){let r=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(r,e,n).map(n.transform)}api(e,r,n){return r.dynamic?this._reader.dynamic(e,n):this._reader.static(r.patterns,n)}};rG.default=tG});var Zle=b(Eh=>{"use strict";Object.defineProperty(Eh,"__esModule",{value:!0});Eh.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;var Sh=Z("fs"),rqe=Z("os"),nqe=Math.max(rqe.cpus().length,1);Eh.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:Sh.lstat,lstatSync:Sh.lstatSync,stat:Sh.stat,statSync:Sh.statSync,readdir:Sh.readdir,readdirSync:Sh.readdirSync};var nG=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,nqe),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,r){return e===void 0?r:e}_getFileSystemMethods(e={}){return Object.assign(Object.assign({},Eh.DEFAULT_FILE_SYSTEM_ADAPTER),e)}};Eh.default=nG});var eS=b((i$t,Xle)=>{"use strict";var Jle=Xce(),iqe=Hle(),oqe=Wle(),sqe=Kle(),iG=Zle(),Jn=qs();async function oG(t,e){Mi(t);let r=sG(t,iqe.default,e),n=await Promise.all(r);return Jn.array.flatten(n)}(function(t){t.glob=t,t.globSync=e,t.globStream=r,t.async=t;function e(l,u){Mi(l);let d=sG(l,sqe.default,u);return Jn.array.flatten(d)}t.sync=e;function r(l,u){Mi(l);let d=sG(l,oqe.default,u);return Jn.stream.merge(d)}t.stream=r;function n(l,u){Mi(l);let d=[].concat(l),f=new iG.default(u);return Jle.generate(d,f)}t.generateTasks=n;function i(l,u){Mi(l);let d=new iG.default(u);return Jn.pattern.isDynamicPattern(l,d)}t.isDynamicPattern=i;function o(l){return Mi(l),Jn.path.escape(l)}t.escapePath=o;function s(l){return Mi(l),Jn.path.convertPathToPattern(l)}t.convertPathToPattern=s;let a;(function(l){function u(f){return Mi(f),Jn.path.escapePosixPath(f)}l.escapePath=u;function d(f){return Mi(f),Jn.path.convertPosixPathToPattern(f)}l.convertPathToPattern=d})(a=t.posix||(t.posix={}));let c;(function(l){function u(f){return Mi(f),Jn.path.escapeWindowsPath(f)}l.escapePath=u;function d(f){return Mi(f),Jn.path.convertWindowsPathToPattern(f)}l.convertPathToPattern=d})(c=t.win32||(t.win32={}))})(oG||(oG={}));function sG(t,e,r){let n=[].concat(t),i=new iG.default(r),o=Jle.generate(n,i),s=new e(i);return o.map(s.read,s)}function Mi(t){if(![].concat(t).every(n=>Jn.string.isString(n)&&!Jn.string.isEmpty(n)))throw new TypeError("Patterns must be a string (non empty) or an array of strings")}Xle.exports=oG});var mG=b((f$t,wI)=>{"use strict";function nue(t){return Array.isArray(t)?t:[t]}var lqe=void 0,uG="",tue=" ",lG="\\",uqe=/^\s+$/,dqe=/(?:[^\\]|^)\\$/,fqe=/^\\!/,pqe=/^\\#/,hqe=/\r?\n/g,mqe=/^\.{0,2}\/|^\.{1,2}$/,gqe=/\/$/,vh="/",iue="node-ignore";typeof Symbol<"u"&&(iue=Symbol.for("node-ignore"));var oue=iue,bh=(t,e,r)=>(Object.defineProperty(t,e,{value:r}),r),_qe=/([0-z])-([0-z])/g,sue=()=>!1,yqe=t=>t.replace(_qe,(e,r,n)=>r.charCodeAt(0)<=n.charCodeAt(0)?e:uG),Sqe=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Eqe=[[/^\uFEFF/,()=>uG],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,r)=>e+(r.indexOf("\\")===0?tue:uG)],[/(\\+?)\s/g,(t,e)=>{let{length:r}=e;return e.slice(0,r-r%2)+tue}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,r)=>e+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,r)=>{let n=r.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>lG],[/\\\\/g,()=>lG],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,r,n,i)=>e===lG?`\\[${r}${Sqe(n)}${i}`:i==="]"&&n.length%2===0?`[${yqe(r)}${n}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`]],vqe=/(^|\\\/)?\\\*$/,tS="regex",TI="checkRegex",rue="_",bqe={[tS](t,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[TI](t,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Tqe=t=>Eqe.reduce((e,[r,n])=>e.replace(r,n.bind(t)),t),xI=t=>typeof t=="string",xqe=t=>t&&xI(t)&&!uqe.test(t)&&!dqe.test(t)&&t.indexOf("#")!==0,wqe=t=>t.split(hqe).filter(Boolean),dG=class{constructor(e,r,n,i,o,s){this.pattern=e,this.mark=r,this.negative=o,bh(this,"body",n),bh(this,"ignoreCase",i),bh(this,"regexPrefix",s)}get regex(){let e=rue+tS;return this[e]?this[e]:this._make(tS,e)}get checkRegex(){let e=rue+TI;return this[e]?this[e]:this._make(TI,e)}_make(e,r){let n=this.regexPrefix.replace(vqe,bqe[e]),i=this.ignoreCase?new RegExp(n,"i"):new RegExp(n);return bh(this,r,i)}},Aqe=({pattern:t,mark:e},r)=>{let n=!1,i=t;i.indexOf("!")===0&&(n=!0,i=i.substr(1)),i=i.replace(fqe,"!").replace(pqe,"#");let o=Tqe(i);return new dG(t,e,i,r,n,o)},fG=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[oue]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(xI(e)&&(e={pattern:e}),xqe(e.pattern)){let r=Aqe(e,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(e){return this._added=!1,nue(xI(e)?wqe(e):e).forEach(this._add,this),this._added}test(e,r,n){let i=!1,o=!1,s;this._rules.forEach(c=>{let{negative:l}=c;o===l&&i!==o||l&&!i&&!o&&!r||!c[n].test(e)||(i=!l,o=l,s=l?lqe:c)});let a={ignored:i,unignored:o};return s&&(a.rule=s),a}},Rqe=(t,e)=>{throw new e(t)},Vs=(t,e,r)=>xI(t)?t?Vs.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${e}\``,TypeError),aue=t=>mqe.test(t);Vs.isNotRelative=aue;Vs.convert=t=>t;var pG=class{constructor({ignorecase:e=!0,ignoreCase:r=e,allowRelativePaths:n=!1}={}){bh(this,oue,!0),this._rules=new fG(r),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,r,n,i){let o=e&&Vs.convert(e);return Vs(o,e,this._strictPathCheck?Rqe:sue),this._t(o,r,n,i)}checkIgnore(e){if(!gqe.test(e))return this.test(e);let r=e.split(vh).filter(Boolean);if(r.pop(),r.length){let n=this._t(r.join(vh)+vh,this._testCache,!0,r);if(n.ignored)return n}return this._rules.test(e,!1,TI)}_t(e,r,n,i){if(e in r)return r[e];if(i||(i=e.split(vh).filter(Boolean)),i.pop(),!i.length)return r[e]=this._rules.test(e,n,tS);let o=this._t(i.join(vh)+vh,r,n,i);return r[e]=o.ignored?o:this._rules.test(e,n,tS)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return nue(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},hG=t=>new pG(t),Iqe=t=>Vs(t&&Vs.convert(t),t,sue),cue=()=>{let t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");Vs.convert=t;let e=/^[a-z]:\//i;Vs.isNotRelative=r=>e.test(r)||aue(r)};typeof process<"u"&&process.platform==="win32"&&cue();wI.exports=hG;hG.default=hG;wI.exports.isPathValid=Iqe;bh(wI.exports,Symbol.for("setupWindows"),cue)});var WG=b(cfe=>{"use strict";cfe.parse=function(t,e){return new HG(t,e).parse()};var HG=class t{constructor(e,r){this.source=e,this.transform=r||rHe,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e==="\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var r;(this.recorded.length>0||e)&&(r=this.recorded.join(""),r==="NULL"&&!e&&(r=null),r!==null&&(r=this.transform(r)),this.entries.push(r),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var r,n,i;for(this.consumeDimensions();!this.isEof();)if(r=this.nextCharacter(),r.value==="{"&&!i)this.dimension++,this.dimension>1&&(n=new t(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse(!0)),this.position+=n.position-2);else if(r.value==="}"&&!i){if(this.dimension--,!this.dimension&&(this.newEntry(),e))return this.entries}else r.value==='"'&&!r.escaped?(i&&this.newEntry(!0),i=!i):r.value===","&&!i?this.newEntry():this.record(r.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};function rHe(t){return t}});var YG=b((mBt,lfe)=>{"use strict";var nHe=WG();lfe.exports={create:function(t,e){return{parse:function(){return nHe.parse(t,e)}}}}});var ffe=b((gBt,dfe)=>{"use strict";var iHe=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,oHe=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,sHe=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,aHe=/^-?infinity$/;dfe.exports=function(e){if(aHe.test(e))return Number(e.replace("i","I"));var r=iHe.exec(e);if(!r)return cHe(e)||null;var n=!!r[8],i=parseInt(r[1],10);n&&(i=ufe(i));var o=parseInt(r[2],10)-1,s=r[3],a=parseInt(r[4],10),c=parseInt(r[5],10),l=parseInt(r[6],10),u=r[7];u=u?1e3*parseFloat(u):0;var d,f=lHe(e);return f!=null?(d=new Date(Date.UTC(i,o,s,a,c,l,u)),KG(i)&&d.setUTCFullYear(i),f!==0&&d.setTime(d.getTime()-f)):(d=new Date(i,o,s,a,c,l,u),KG(i)&&d.setFullYear(i)),d};function cHe(t){var e=oHe.exec(t);if(e){var r=parseInt(e[1],10),n=!!e[4];n&&(r=ufe(r));var i=parseInt(e[2],10)-1,o=e[3],s=new Date(r,i,o);return KG(r)&&s.setFullYear(r),s}}function lHe(t){if(t.endsWith("+00"))return 0;var e=sHe.exec(t.split(" ")[1]);if(e){var r=e[1];if(r==="Z")return 0;var n=r==="-"?-1:1,i=parseInt(e[2],10)*3600+parseInt(e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}function ufe(t){return-(t-1)}function KG(t){return t>=0&&t<100}});var hfe=b((_Bt,pfe)=>{"use strict";pfe.exports=dHe;var uHe=Object.prototype.hasOwnProperty;function dHe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)uHe.call(r,n)&&(t[n]=r[n])}return t}});var _fe=b((yBt,gfe)=>{"use strict";var fHe=hfe();gfe.exports=Dh;function Dh(t){if(!(this instanceof Dh))return new Dh(t);fHe(this,xHe(t))}var pHe=["seconds","minutes","hours","days","months","years"];Dh.prototype.toPostgres=function(){var t=pHe.filter(this.hasOwnProperty,this);return this.milliseconds&&t.indexOf("seconds")<0&&t.push("seconds"),t.length===0?"0":t.map(function(e){var r=this[e]||0;return e==="seconds"&&this.milliseconds&&(r=(r+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),r+" "+e},this).join(" ")};var hHe={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},mHe=["years","months","days"],gHe=["hours","minutes","seconds"];Dh.prototype.toISOString=Dh.prototype.toISO=function(){var t=mHe.map(r,this).join(""),e=gHe.map(r,this).join("");return"P"+t+"T"+e;function r(n){var i=this[n]||0;return n==="seconds"&&this.milliseconds&&(i=(i+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),i+hHe[n]}};var ZG="([+-]?\\d+)",_He=ZG+"\\s+years?",yHe=ZG+"\\s+mons?",SHe=ZG+"\\s+days?",EHe="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",vHe=new RegExp([_He,yHe,SHe,EHe].map(function(t){return"("+t+")?"}).join("\\s*")),mfe={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},bHe=["hours","minutes","seconds","milliseconds"];function THe(t){var e=t+"000000".slice(t.length);return parseInt(e,10)/1e3}function xHe(t){if(!t)return{};var e=vHe.exec(t),r=e[8]==="-";return Object.keys(mfe).reduce(function(n,i){var o=mfe[i],s=e[o];return!s||(s=i==="milliseconds"?THe(s):parseInt(s,10),!s)||(r&&~bHe.indexOf(i)&&(s*=-1),n[i]=s),n},{})}});var Efe=b((SBt,Sfe)=>{"use strict";var yfe=Buffer.from||Buffer;Sfe.exports=function(e){if(/^\\x/.test(e))return yfe(e.substr(2),"hex");for(var r="",n=0;n<e.length;)if(e[n]!=="\\")r+=e[n],++n;else if(/[0-7]{3}/.test(e.substr(n+1,3)))r+=String.fromCharCode(parseInt(e.substr(n+1,3),8)),n+=4;else{for(var i=1;n+i<e.length&&e[n+i]==="\\";)i++;for(var o=0;o<Math.floor(i/2);++o)r+="\\";n+=Math.floor(i/2)*2}return yfe(r,"binary")}});var Rfe=b((EBt,Afe)=>{"use strict";var lS=WG(),uS=YG(),FI=ffe(),bfe=_fe(),Tfe=Efe();function BI(t){return function(r){return r===null?r:t(r)}}function xfe(t){return t===null?t:t==="TRUE"||t==="t"||t==="true"||t==="y"||t==="yes"||t==="on"||t==="1"}function wHe(t){return t?lS.parse(t,xfe):null}function AHe(t){return parseInt(t,10)}function JG(t){return t?lS.parse(t,BI(AHe)):null}function RHe(t){return t?lS.parse(t,BI(function(e){return wfe(e).trim()})):null}var IHe=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=t4(r)),r});return e.parse()},XG=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=parseFloat(r)),r});return e.parse()},Xn=function(t){if(!t)return null;var e=uS.create(t);return e.parse()},QG=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=FI(r)),r});return e.parse()},CHe=function(t){if(!t)return null;var e=uS.create(t,function(r){return r!==null&&(r=bfe(r)),r});return e.parse()},PHe=function(t){return t?lS.parse(t,BI(Tfe)):null},e4=function(t){return parseInt(t,10)},wfe=function(t){var e=String(t);return/^\d+$/.test(e)?e:t},vfe=function(t){return t?lS.parse(t,BI(JSON.parse)):null},t4=function(t){return t[0]!=="("?null:(t=t.substring(1,t.length-1).split(","),{x:parseFloat(t[0]),y:parseFloat(t[1])})},OHe=function(t){if(t[0]!=="<"&&t[1]!=="(")return null;for(var e="(",r="",n=!1,i=2;i<t.length-1;i++){if(n||(e+=t[i]),t[i]===")"){n=!0;continue}else if(!n)continue;t[i]!==","&&(r+=t[i])}var o=t4(e);return o.radius=parseFloat(r),o},NHe=function(t){t(20,wfe),t(21,e4),t(23,e4),t(26,e4),t(700,parseFloat),t(701,parseFloat),t(16,xfe),t(1082,FI),t(1114,FI),t(1184,FI),t(600,t4),t(651,Xn),t(718,OHe),t(1e3,wHe),t(1001,PHe),t(1005,JG),t(1007,JG),t(1028,JG),t(1016,RHe),t(1017,IHe),t(1021,XG),t(1022,XG),t(1231,XG),t(1014,Xn),t(1015,Xn),t(1008,Xn),t(1009,Xn),t(1040,Xn),t(1041,Xn),t(1115,QG),t(1182,QG),t(1185,QG),t(1186,bfe),t(1187,CHe),t(17,Tfe),t(114,JSON.parse.bind(JSON)),t(3802,JSON.parse.bind(JSON)),t(199,vfe),t(3807,vfe),t(3907,Xn),t(2951,Xn),t(791,Xn),t(1183,Xn),t(1270,Xn)};Afe.exports={init:NHe}});var Cfe=b((vBt,Ife)=>{"use strict";var nn=1e6;function kHe(t){var e=t.readInt32BE(0),r=t.readUInt32BE(4),n="";e<0&&(e=~e+(r===0),r=~r+1>>>0,n="-");var i="",o,s,a,c,l,u;{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}{if(o=e%nn,e=e/nn>>>0,s=4294967296*o+r,r=s/nn>>>0,a=""+(s-nn*r),r===0&&e===0)return n+a+i;for(c="",l=6-a.length,u=0;u<l;u++)c+="0";i=c+a+i}return o=e%nn,s=4294967296*o+r,a=""+s%nn,n+a+i}Ife.exports=kHe});var Mfe=b((bBt,kfe)=>{"use strict";var MHe=Cfe(),Et=function(t,e,r,n,i){r=r||0,n=n||!1,i=i||function(p,h,m){return p*Math.pow(2,m)+h};var o=r>>3,s=function(p){return n?~p&255:p},a=255,c=8-r%8;e<c&&(a=255<<8-e&255,c=e),r&&(a=a>>r%8);var l=0;r%8+e>=8&&(l=i(0,s(t[o])&a,c));for(var u=e+r>>3,d=o+1;d<u;d++)l=i(l,s(t[d]),8);var f=(e+r)%8;return f>0&&(l=i(l,s(t[u])>>8-f,f)),l},Nfe=function(t,e,r){var n=Math.pow(2,r-1)-1,i=Et(t,1),o=Et(t,r,1);if(o===0)return 0;var s=1,a=function(l,u,d){l===0&&(l=1);for(var f=1;f<=d;f++)s/=2,(u&1<<d-f)>0&&(l+=s);return l},c=Et(t,e,r+1,!1,a);return o==Math.pow(2,r+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,o-n)*c},DHe=function(t){return Et(t,1)==1?-1*(Et(t,15,1,!0)+1):Et(t,15,1)},Pfe=function(t){return Et(t,1)==1?-1*(Et(t,31,1,!0)+1):Et(t,31,1)},LHe=function(t){return Nfe(t,23,8)},$He=function(t){return Nfe(t,52,11)},UHe=function(t){var e=Et(t,16,32);if(e==49152)return NaN;for(var r=Math.pow(1e4,Et(t,16,16)),n=0,i=[],o=Et(t,16),s=0;s<o;s++)n+=Et(t,16,64+16*s)*r,r/=1e4;var a=Math.pow(10,Et(t,16,48));return(e===0?1:-1)*Math.round(n*a)/a},Ofe=function(t,e){var r=Et(e,1),n=Et(e,63,1),i=new Date((r===0?1:-1)*n/1e3+9466848e5);return t||i.setTime(i.getTime()+i.getTimezoneOffset()*6e4),i.usec=n%1e3,i.getMicroSeconds=function(){return this.usec},i.setMicroSeconds=function(o){this.usec=o},i.getUTCMicroSeconds=function(){return this.usec},i},dS=function(t){for(var e=Et(t,32),r=Et(t,32,32),n=Et(t,32,64),i=96,o=[],s=0;s<e;s++)o[s]=Et(t,32,i),i+=32,i+=32;var a=function(l){var u=Et(t,32,i);if(i+=32,u==4294967295)return null;var d;if(l==23||l==20)return d=Et(t,u*8,i),i+=u*8,d;if(l==25)return d=t.toString(this.encoding,i>>3,(i+=u<<3)>>3),d;console.log("ERROR: ElementType not implemented: "+l)},c=function(l,u){var d=[],f;if(l.length>1){var p=l.shift();for(f=0;f<p;f++)d[f]=c(l,u);l.unshift(p)}else for(f=0;f<l[0];f++)d[f]=a(u);return d};return c(o,n)},FHe=function(t){return t.toString("utf8")},BHe=function(t){return t===null?null:Et(t,8)>0},jHe=function(t){t(20,MHe),t(21,DHe),t(23,Pfe),t(26,Pfe),t(1700,UHe),t(700,LHe),t(701,$He),t(16,BHe),t(1114,Ofe.bind(null,!1)),t(1184,Ofe.bind(null,!0)),t(1e3,dS),t(1007,dS),t(1016,dS),t(1008,dS),t(1009,dS),t(25,FHe)};kfe.exports={init:jHe}});var Lfe=b((TBt,Dfe)=>{"use strict";Dfe.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var hS=b(pS=>{"use strict";var zHe=Rfe(),GHe=Mfe(),qHe=YG(),VHe=Lfe();pS.getTypeParser=HHe;pS.setTypeParser=WHe;pS.arrayParser=qHe;pS.builtins=VHe;var fS={text:{},binary:{}};function $fe(t){return String(t)}function HHe(t,e){return e=e||"text",fS[e]&&fS[e][t]||$fe}function WHe(t,e,r){typeof e=="function"&&(r=e,e="text"),fS[e][t]=r}zHe.init(function(t,e){fS.text[t]=e});GHe.init(function(t,e){fS.binary[t]=e})});var mS=b((wBt,r4)=>{"use strict";var Ufe;try{Ufe=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}r4.exports={host:"localhost",user:Ufe,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:"",ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var Lh=hS(),YHe=Lh.getTypeParser(20,"text"),KHe=Lh.getTypeParser(1016,"text");r4.exports.__defineSetter__("parseInt8",function(t){Lh.setTypeParser(20,"text",t?Lh.getTypeParser(23,"text"):YHe),Lh.setTypeParser(1016,"text",t?Lh.getTypeParser(1007,"text"):KHe)})});var $h=b((ABt,Bfe)=>{"use strict";var ZHe=mS(),{isDate:JHe}=Z("util/types");function XHe(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function Ffe(t){let e="{";for(let r=0;r<t.length;r++){r>0&&(e+=",");let n=t[r];n==null?e+="NULL":Array.isArray(n)?e+=Ffe(n):ArrayBuffer.isView(n)?(n instanceof Buffer||(n=Buffer.from(n.buffer,n.byteOffset,n.byteLength)),e+="\\\\x"+n.toString("hex")):e+=XHe(jI(n))}return e+="}",e}var jI=function(t,e){return t==null?null:typeof t=="object"?t instanceof Buffer?t:ArrayBuffer.isView(t)?Buffer.from(t.buffer,t.byteOffset,t.byteLength):JHe(t)?ZHe.parseInputDatesAsUTC?t3e(t):e3e(t):Array.isArray(t)?Ffe(t):QHe(t,e):t.toString()};function QHe(t,e){if(t&&typeof t.toPostgres=="function"){if(e=e||[],e.indexOf(t)!==-1)throw new Error('circular reference detected while preparing "'+t+'" for query');return e.push(t),jI(t.toPostgres(jI),e)}return JSON.stringify(t)}function e3e(t){let e=-t.getTimezoneOffset(),r=t.getFullYear(),n=r<1;n&&(r=Math.abs(r)+1);let i=String(r).padStart(4,"0")+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0")+"T"+String(t.getHours()).padStart(2,"0")+":"+String(t.getMinutes()).padStart(2,"0")+":"+String(t.getSeconds()).padStart(2,"0")+"."+String(t.getMilliseconds()).padStart(3,"0");return e<0?(i+="-",e*=-1):i+="+",i+=String(Math.floor(e/60)).padStart(2,"0")+":"+String(e%60).padStart(2,"0"),n&&(i+=" BC"),i}function t3e(t){let e=t.getUTCFullYear(),r=e<1;r&&(e=Math.abs(e)+1);let n=String(e).padStart(4,"0")+"-"+String(t.getUTCMonth()+1).padStart(2,"0")+"-"+String(t.getUTCDate()).padStart(2,"0")+"T"+String(t.getUTCHours()).padStart(2,"0")+":"+String(t.getUTCMinutes()).padStart(2,"0")+":"+String(t.getUTCSeconds()).padStart(2,"0")+"."+String(t.getUTCMilliseconds()).padStart(3,"0");return n+="+00:00",r&&(n+=" BC"),n}function r3e(t,e,r){return t=typeof t=="string"?{text:t}:t,e&&(typeof e=="function"?t.callback=e:t.values=e),r&&(t.callback=r),t}var n3e=function(t){return'"'+t.replace(/"/g,'""')+'"'},i3e=function(t){let e=!1,r="'";if(t==null||typeof t!="string")return"''";for(let n=0;n<t.length;n++){let i=t[n];i==="'"?r+=i+i:i==="\\"?(r+=i+i,e=!0):r+=i}return r+="'",e===!0&&(r=" E"+r),r};Bfe.exports={prepareValue:function(e){return jI(e)},normalizeQueryConfig:r3e,escapeIdentifier:n3e,escapeLiteral:i3e}});var o4=b((RBt,Gfe)=>{"use strict";var jfe=Z("crypto");Gfe.exports={postgresMd5PasswordHash:s3e,randomBytes:o3e,deriveKey:u3e,sha256:a3e,hashByName:c3e,hmacSha256:l3e,md5:n4};var zfe=jfe.webcrypto||globalThis.crypto,Ru=zfe.subtle,i4=new TextEncoder;function o3e(t){return zfe.getRandomValues(Buffer.alloc(t))}async function n4(t){try{return jfe.createHash("md5").update(t,"utf-8").digest("hex")}catch{let r=typeof t=="string"?i4.encode(t):t,n=await Ru.digest("MD5",r);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}}async function s3e(t,e,r){let n=await n4(e+t);return"md5"+await n4(Buffer.concat([Buffer.from(n),r]))}async function a3e(t){return await Ru.digest("SHA-256",t)}async function c3e(t,e){return await Ru.digest(t,e)}async function l3e(t,e){let r=await Ru.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await Ru.sign("HMAC",r,i4.encode(e))}async function u3e(t,e,r){let n=await Ru.importKey("raw",i4.encode(t),"PBKDF2",!1,["deriveBits"]),i={name:"PBKDF2",hash:"SHA-256",salt:e,iterations:r};return await Ru.deriveBits(i,n,256,["deriveBits"])}});var Hfe=b((IBt,Vfe)=>{"use strict";function Iu(t,e){return new Error("SASL channel binding: "+t+" when parsing public certificate "+e.toString("base64"))}function s4(t,e){let r=t[e++];if(r<128)return{length:r,index:e};let n=r&127;if(n>4)throw Iu("bad length",t);r=0;for(let i=0;i<n;i++)r=r<<8|t[e++];return{length:r,index:e}}function qfe(t,e){if(t[e++]!==6)throw Iu("non-OID data",t);let{length:r,index:n}=s4(t,e);e=n;let i=e+r,o=t[e++],s=(o/40>>0)+"."+o%40;for(;e<i;){let a=0;for(;e<i;){let c=t[e++];if(a=a<<7|c&127,c<128)break}s+="."+a}return{oid:s,index:e}}function gS(t,e){if(t[e++]!==48)throw Iu("non-sequence data",t);return s4(t,e)}function d3e(t,e){e===void 0&&(e=0),e=gS(t,e).index;let{length:r,index:n}=gS(t,e);e=n+r,e=gS(t,e).index;let{oid:i,index:o}=qfe(t,e);switch(i){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(e=o,e=gS(t,e).index,t[e++]!==160)throw Iu("non-tag data",t);e=s4(t,e).index,e=gS(t,e).index;let{oid:s}=qfe(t,e);switch(s){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw Iu("unknown hash OID "+s,t)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw Iu("Ed448 certificate channel binding is not currently supported by Postgres")}throw Iu("unknown OID "+i,t)}Vfe.exports={signatureAlgorithmHashFromCertificate:d3e}});var Zfe=b((CBt,Kfe)=>{"use strict";var Pc=o4(),{signatureAlgorithmHashFromCertificate:f3e}=Hfe();function p3e(t){let e=/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g,r=/[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;return t.replace(e," ").replace(r,"").normalize("NFKC")}var a4=1e5;function h3e(t,e,r=a4){let n=["SCRAM-SHA-256"];e&&n.unshift("SCRAM-SHA-256-PLUS");let i=n.find(a=>t.includes(a));if(!i)throw new Error("SASL: Only mechanism(s) "+n.join(" and ")+" are supported");if(i==="SCRAM-SHA-256-PLUS"&&typeof e.getPeerCertificate!="function")throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let o=Pc.randomBytes(18).toString("base64");return{mechanism:i,clientNonce:o,response:(i==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":e?"y":"n")+",,n=*,r="+o,message:"SASLInitialResponse",scramMaxIterations:r}}async function m3e(t,e,r,n){if(t.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(e==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof r!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let i=y3e(r);if(i.nonce.startsWith(t.clientNonce)){if(i.nonce.length===t.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");let o=typeof t.scramMaxIterations=="number"?t.scramMaxIterations:a4;if(o!==0&&i.iteration>o)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count "+i.iteration+" exceeds scramMaxIterations of "+o);let s="n=*,r="+t.clientNonce,a="r="+i.nonce+",s="+i.salt+",i="+i.iteration,c=n?"eSws":"biws";if(t.mechanism==="SCRAM-SHA-256-PLUS"){let x=n.getPeerCertificate().raw,v=f3e(x);(v==="MD5"||v==="SHA-1")&&(v="SHA-256");let N=await Pc.hashByName(v,x);c=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from(N)]).toString("base64")}let l="c="+c+",r="+i.nonce,u=s+","+a+","+l,d=Buffer.from(i.salt,"base64"),f=await Pc.deriveKey(p3e(e),d,i.iteration),p=await Pc.hmacSha256(f,"Client Key"),h=await Pc.sha256(p),m=await Pc.hmacSha256(h,u),y=E3e(Buffer.from(p),Buffer.from(m)).toString("base64"),S=await Pc.hmacSha256(f,"Server Key"),T=await Pc.hmacSha256(S,u);t.message="SASLResponse",t.serverSignature=Buffer.from(T).toString("base64"),t.response=l+",p="+y}function g3e(t,e){if(t.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:r}=S3e(e);if(r!==t.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function _3e(t){if(typeof t!="string")throw new TypeError("SASL: text must be a string");return t.split("").map((e,r)=>t.charCodeAt(r)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function Wfe(t){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(t)}function Yfe(t){if(typeof t!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(t.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("SASL: Invalid attribute pair entry");let r=e[0],n=e.substring(2);return[r,n]}))}function y3e(t){let e=Yfe(t),r=e.get("r");if(r){if(!_3e(r))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!Wfe(n))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let i=e.get("i");if(i){if(!/^[1-9][0-9]*$/.test(i))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let o=parseInt(i,10);return{nonce:r,salt:n,iteration:o}}function S3e(t){let e=Yfe(t),r=e.get("e"),n=e.get("v");if(r)throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${r}"`);if(n){if(!Wfe(n))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:n}}function E3e(t,e){if(!Buffer.isBuffer(t))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(e))throw new TypeError("second argument must be a Buffer");if(t.length!==e.length)throw new Error("Buffer lengths must match");if(t.length===0)throw new Error("Buffers cannot be empty");return Buffer.from(t.map((r,n)=>t[n]^e[n]))}Kfe.exports={startSession:h3e,continueSession:m3e,finalizeSession:g3e,DEFAULT_MAX_SCRAM_ITERATIONS:a4}});var GI=b((PBt,Jfe)=>{"use strict";var v3e=hS();function zI(t){this._types=t||v3e,this.text={},this.binary={}}zI.prototype.getOverrides=function(t){switch(t){case"text":return this.text;case"binary":return this.binary;default:return{}}};zI.prototype.setTypeParser=function(t,e,r){typeof e=="function"&&(r=e,e="text"),this.getOverrides(e)[t]=r};zI.prototype.getTypeParser=function(t,e){return e=e||"text",this.getOverrides(e)[t]||this._types.getTypeParser(t,e)};Jfe.exports=zI});var epe=b((OBt,Qfe)=>{"use strict";function Uh(t,e={}){if(t.charAt(0)==="/"){let c=t.split(" ");return{host:c[0],database:c[1]}}let r=Object.create(null),n,i=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(t)&&(t=encodeURI(t).replace(/%25(\d\d)/g,"%$1"));try{try{n=new URL(t,"postgres://base")}catch{n=new URL(t.replace("@/","@___DUMMY___/"),"postgres://base"),i=!0}}catch(c){throw c.input&&(c.input="*****REDACTED*****"),c}for(let c of n.searchParams.entries())r[c[0]]=c[1];if(r.user=r.user||decodeURIComponent(n.username),r.password=r.password||decodeURIComponent(n.password),n.protocol=="socket:")return r.host=decodeURI(n.pathname),r.database=n.searchParams.get("db"),r.client_encoding=n.searchParams.get("encoding"),r;let o=i?"":n.hostname;r.host?o&&/^%2f/i.test(o)&&(n.pathname=o+n.pathname):r.host=decodeURIComponent(o),r.port||(r.port=n.port);let s=n.pathname.slice(1)||null;r.database=s?decodeURI(s):null,(r.ssl==="true"||r.ssl==="1")&&(r.ssl=!0),r.ssl==="0"&&(r.ssl=!1),(r.sslcert||r.sslkey||r.sslrootcert||r.sslmode)&&(r.ssl={});let a=r.sslcert||r.sslkey||r.sslrootcert?Z("fs"):null;if(r.sslcert&&(r.ssl.cert=a.readFileSync(r.sslcert).toString()),r.sslkey&&(r.ssl.key=a.readFileSync(r.sslkey).toString()),r.sslrootcert&&(r.ssl.ca=a.readFileSync(r.sslrootcert).toString()),e.useLibpqCompat&&r.uselibpqcompat)throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(r.uselibpqcompat==="true"||e.useLibpqCompat)switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":{r.ssl.rejectUnauthorized=!1;break}case"require":{r.sslrootcert?r.ssl.checkServerIdentity=function(){}:r.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!r.ssl.ca)throw new Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");r.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(r.sslmode){case"disable":{r.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{r.sslmode!=="verify-full"&&c4(r.sslmode);break}case"no-verify":{r.ssl.rejectUnauthorized=!1;break}}return r}function b3e(t){return Object.entries(t).reduce((r,[n,i])=>(i!=null&&(r[n]=i),r),Object.create(null))}function Xfe(t){return Object.entries(t).reduce((r,[n,i])=>{if(n==="ssl"){let o=i;typeof o=="boolean"&&(r[n]=o),typeof o=="object"&&(r[n]=b3e(o))}else if(i!=null)if(n==="port"){if(i!==""){let o=parseInt(i,10);if(isNaN(o))throw new Error(`Invalid ${n}: ${i}`);r[n]=o}}else r[n]=i;return r},Object.create(null))}function T3e(t){return Xfe(Uh(t))}function c4(t){!c4.warned&&typeof process<"u"&&process.emitWarning&&(c4.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
|
|
25
25
|
In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
|
|
26
26
|
|
|
27
27
|
To prepare for this change:
|
|
@@ -29,7 +29,7 @@ To prepare for this change:
|
|
|
29
29
|
- If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${t}'
|
|
30
30
|
|
|
31
31
|
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`))}Qfe.exports=Uh;Uh.parse=Uh;Uh.toClientConfig=Xfe;Uh.parseIntoClientConfig=T3e});var u4=b((NBt,npe)=>{"use strict";var x3e=Z("dns"),rpe=mS(),tpe=epe().parse,Br=function(t,e,r){return e[t]?e[t]:(r===void 0?r=process.env["PG"+t.toUpperCase()]:r===!1||(r=process.env[r]),r||rpe[t])},w3e=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return rpe.ssl},Fh=function(t){return"'"+(""+t).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},Qn=function(t,e,r){let n=e[r];n!=null&&t.push(r+"="+Fh(n))},l4=class{constructor(e){e=typeof e=="string"?tpe(e):e||{},e.connectionString&&(e=Object.assign({},e,tpe(e.connectionString))),this.user=Br("user",e),this.database=Br("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(Br("port",e),10),this.host=Br("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:Br("password",e)}),this.binary=Br("binary",e),this.options=Br("options",e),this.ssl=typeof e.ssl>"u"?w3e():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.client_encoding=Br("client_encoding",e),this.replication=Br("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=Br("application_name",e,"PGAPPNAME"),this.fallback_application_name=Br("fallback_application_name",e,!1),this.statement_timeout=Br("statement_timeout",e,!1),this.lock_timeout=Br("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=Br("idle_in_transaction_session_timeout",e,!1),this.query_timeout=Br("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let r=[];Qn(r,this,"user"),Qn(r,this,"password"),Qn(r,this,"port"),Qn(r,this,"application_name"),Qn(r,this,"fallback_application_name"),Qn(r,this,"connect_timeout"),Qn(r,this,"options");let n=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(Qn(r,n,"sslmode"),Qn(r,n,"sslca"),Qn(r,n,"sslkey"),Qn(r,n,"sslcert"),Qn(r,n,"sslrootcert"),this.database&&r.push("dbname="+Fh(this.database)),this.replication&&r.push("replication="+Fh(this.replication)),this.host&&r.push("host="+Fh(this.host)),this.isDomainSocket)return e(null,r.join(" "));this.client_encoding&&r.push("client_encoding="+Fh(this.client_encoding)),x3e.lookup(this.host,function(i,o){return i?e(i,null):(r.push("hostaddr="+Fh(o)),e(null,r.join(" ")))})}};npe.exports=l4});var f4=b((kBt,ope)=>{"use strict";var A3e=hS(),ipe=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,d4=class{constructor(e,r){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=r,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let r;e.text?r=ipe.exec(e.text):r=ipe.exec(e.command),r&&(this.command=r[1],r[3]?(this.oid=parseInt(r[2],10),this.rowCount=parseInt(r[3],10)):r[2]&&(this.rowCount=parseInt(r[2],10)))}_parseRowAsArray(e){let r=new Array(e.length);for(let n=0,i=e.length;n<i;n++){let o=e[n];o!==null?r[n]=this._parsers[n](o):r[n]=null}return r}parseRow(e){let r={...this._prebuiltEmptyResultObject};for(let n=0,i=e.length;n<i;n++){let o=e[n],s=this.fields[n].name;if(o!==null){let a=this.fields[n].format==="binary"?Buffer.from(o):o;r[s]=this._parsers[n](a)}else r[s]=null}return r}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=new Array(e.length));let r=Object.create(null);for(let n=0;n<e.length;n++){let i=e[n];r[i.name]=null,this._types?this._parsers[n]=this._types.getTypeParser(i.dataTypeID,i.format||"text"):this._parsers[n]=A3e.getTypeParser(i.dataTypeID,i.format||"text")}this._prebuiltEmptyResultObject={...r}}};ope.exports=d4});var lpe=b((MBt,cpe)=>{"use strict";var{EventEmitter:R3e}=Z("events"),spe=f4(),ape=$h(),p4=class extends R3e{constructor(e,r,n){super(),e=ape.normalizeQueryConfig(e,r,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new spe(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode==="extended"||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new spe(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(e){let r;if(!this._canceledDueToError){try{r=this._result.parseRow(e.fields)}catch(n){this._canceledDueToError=n;return}this.emit("row",r,this._result),this._accumulateRows&&this._result.addRow(r)}}handleCommandComplete(e,r){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&r.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,r){if(this._canceledDueToError&&(e=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(e);this.emit("error",e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(r){process.nextTick(()=>{throw r})}this.emit("end",this._results)}submit(e){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let r=e.parsedStatements[this.name];if(this.text&&r&&this.text!==r)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,r){e.execute({portal:this.portal,rows:r}),r?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:ape.prepareValue})}catch(r){this.handleError(r,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail("No source stream defined")}handleCopyData(e,r){}};cpe.exports=p4});var I4=b(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.NoticeMessage=Me.DataRowMessage=Me.CommandCompleteMessage=Me.ReadyForQueryMessage=Me.NotificationResponseMessage=Me.BackendKeyDataMessage=Me.AuthenticationMD5Password=Me.ParameterStatusMessage=Me.ParameterDescriptionMessage=Me.RowDescriptionMessage=Me.Field=Me.CopyResponse=Me.CopyDataMessage=Me.DatabaseError=Me.copyDone=Me.emptyQuery=Me.replicationStart=Me.portalSuspended=Me.noData=Me.closeComplete=Me.bindComplete=Me.parseComplete=void 0;Me.parseComplete={name:"parseComplete",length:5};Me.bindComplete={name:"bindComplete",length:5};Me.closeComplete={name:"closeComplete",length:5};Me.noData={name:"noData",length:5};Me.portalSuspended={name:"portalSuspended",length:5};Me.replicationStart={name:"replicationStart",length:4};Me.emptyQuery={name:"emptyQuery",length:4};Me.copyDone={name:"copyDone",length:4};var h4=class extends Error{constructor(e,r,n){super(e),this.length=r,this.name=n}};Me.DatabaseError=h4;var m4=class{constructor(e,r){this.length=e,this.chunk=r,this.name="copyData"}};Me.CopyDataMessage=m4;var g4=class{constructor(e,r,n,i){this.length=e,this.name=r,this.binary=n,this.columnTypes=new Array(i)}};Me.CopyResponse=g4;var _4=class{constructor(e,r,n,i,o,s,a){this.name=e,this.tableID=r,this.columnID=n,this.dataTypeID=i,this.dataTypeSize=o,this.dataTypeModifier=s,this.format=a}};Me.Field=_4;var y4=class{constructor(e,r){this.length=e,this.fieldCount=r,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};Me.RowDescriptionMessage=y4;var S4=class{constructor(e,r){this.length=e,this.parameterCount=r,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};Me.ParameterDescriptionMessage=S4;var E4=class{constructor(e,r,n){this.length=e,this.parameterName=r,this.parameterValue=n,this.name="parameterStatus"}};Me.ParameterStatusMessage=E4;var v4=class{constructor(e,r){this.length=e,this.salt=r,this.name="authenticationMD5Password"}};Me.AuthenticationMD5Password=v4;var b4=class{constructor(e,r,n){this.length=e,this.processID=r,this.secretKey=n,this.name="backendKeyData"}};Me.BackendKeyDataMessage=b4;var T4=class{constructor(e,r,n,i){this.length=e,this.processId=r,this.channel=n,this.payload=i,this.name="notification"}};Me.NotificationResponseMessage=T4;var x4=class{constructor(e,r){this.length=e,this.status=r,this.name="readyForQuery"}};Me.ReadyForQueryMessage=x4;var w4=class{constructor(e,r){this.length=e,this.text=r,this.name="commandComplete"}};Me.CommandCompleteMessage=w4;var A4=class{constructor(e,r){this.length=e,this.fields=r,this.name="dataRow",this.fieldCount=r.length}};Me.DataRowMessage=A4;var R4=class{constructor(e,r){this.length=e,this.message=r,this.name="notice"}};Me.NoticeMessage=R4});var upe=b(qI=>{"use strict";Object.defineProperty(qI,"__esModule",{value:!0});qI.Writer=void 0;var C4=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let n=this.buffer,i=n.length+(n.length>>1)+e;this.buffer=Buffer.allocUnsafe(i),n.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let r=Buffer.byteLength(e);this.ensure(r+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=r}return this.buffer[this.offset++]=0,this}addString(e=""){let r=Buffer.byteLength(e);return this.ensure(r),this.buffer.write(e,this.offset),this.offset+=r,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let r=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(r,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let r=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),r}};qI.Writer=C4});var fpe=b(HI=>{"use strict";Object.defineProperty(HI,"__esModule",{value:!0});HI.serialize=void 0;var P4=upe(),gt=new P4.Writer,I3e=t=>{gt.addInt16(3).addInt16(0);for(let n of Object.keys(t))gt.addCString(n).addCString(t[n]);gt.addCString("client_encoding").addCString("UTF8");let e=gt.addCString("").flush(),r=e.length+4;return new P4.Writer().addInt32(r).add(e).flush()},C3e=()=>{let t=Buffer.allocUnsafe(8);return t.writeInt32BE(8,0),t.writeInt32BE(80877103,4),t},P3e=t=>gt.addCString(t).flush(112),O3e=function(t,e){return gt.addCString(t).addInt32(Buffer.byteLength(e)).addString(e),gt.flush(112)},N3e=function(t){return gt.addString(t).flush(112)},k3e=t=>gt.addCString(t).flush(81),dpe=[],M3e=t=>{let e=t.name||"";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors executing queries"));let r=t.types||dpe,n=r.length,i=gt.addCString(e).addCString(t.text).addInt16(n);for(let o=0;o<n;o++)i.addInt32(r[o]);return gt.flush(80)},Bh=new P4.Writer,D3e=function(t,e){for(let r=0;r<t.length;r++){let n=e?e(t[r],r):t[r];n==null?(gt.addInt16(0),Bh.addInt32(-1)):n instanceof Buffer?(gt.addInt16(1),Bh.addInt32(n.length),Bh.add(n)):(gt.addInt16(0),Bh.addInt32(Buffer.byteLength(n)),Bh.addString(n))}},L3e=(t={})=>{let e=t.portal||"",r=t.statement||"",n=t.binary||!1,i=t.values||dpe,o=i.length;return gt.addCString(e).addCString(r),gt.addInt16(o),D3e(i,t.valueMapper),gt.addInt16(o),gt.add(Bh.flush()),gt.addInt16(1),gt.addInt16(n?1:0),gt.flush(66)},$3e=Buffer.from([69,0,0,0,9,0,0,0,0,0]),U3e=t=>{if(!t||!t.portal&&!t.rows)return $3e;let e=t.portal||"",r=t.rows||0,n=Buffer.byteLength(e),i=4+n+1+4,o=Buffer.allocUnsafe(1+i);return o[0]=69,o.writeInt32BE(i,1),o.write(e,5,"utf-8"),o[n+5]=0,o.writeUInt32BE(r,o.length-4),o},F3e=(t,e)=>{let r=Buffer.allocUnsafe(16);return r.writeInt32BE(16,0),r.writeInt16BE(1234,4),r.writeInt16BE(5678,6),r.writeInt32BE(t,8),r.writeInt32BE(e,12),r},O4=(t,e)=>{let n=4+Buffer.byteLength(e)+1,i=Buffer.allocUnsafe(1+n);return i[0]=t,i.writeInt32BE(n,1),i.write(e,5,"utf-8"),i[n]=0,i},B3e=gt.addCString("P").flush(68),j3e=gt.addCString("S").flush(68),z3e=t=>t.name?O4(68,`${t.type}${t.name||""}`):t.type==="P"?B3e:j3e,G3e=t=>{let e=`${t.type}${t.name||""}`;return O4(67,e)},q3e=t=>gt.add(t).flush(100),V3e=t=>O4(102,t),VI=t=>Buffer.from([t,0,0,0,4]),H3e=VI(72),W3e=VI(83),Y3e=VI(88),K3e=VI(99),Z3e={startup:I3e,password:P3e,requestSsl:C3e,sendSASLInitialResponseMessage:O3e,sendSCRAMClientFinalMessage:N3e,query:k3e,parse:M3e,bind:L3e,execute:U3e,describe:z3e,close:G3e,flush:()=>H3e,sync:()=>W3e,end:()=>Y3e,copyData:q3e,copyDone:()=>K3e,copyFail:V3e,cancel:F3e};HI.serialize=Z3e});var ppe=b(WI=>{"use strict";Object.defineProperty(WI,"__esModule",{value:!0});WI.BufferReader=void 0;var N4=class{constructor(e=0){this.offset=e,this.buffer=Buffer.allocUnsafe(0),this.encoding="utf-8"}setBuffer(e,r){this.offset=e,this.buffer=r}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let r=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,r}cstring(){let e=this.offset,r=e;for(;this.buffer[r++]!==0;);return this.offset=r,this.buffer.toString(this.encoding,e,r-1)}bytes(e){let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,r}};WI.BufferReader=N4});var _pe=b(YI=>{"use strict";Object.defineProperty(YI,"__esModule",{value:!0});YI.Parser=void 0;var vt=I4(),J3e=ppe(),M4=1,X3e=4,hpe=M4+X3e,On=-1,k4=Buffer.allocUnsafe(0),D4=class{constructor(e){if(this.buffer=k4,this.bufferLength=0,this.bufferOffset=0,this.reader=new J3e.BufferReader,e?.mode==="binary")throw new Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,r){this.mergeBuffer(e);let n=this.bufferOffset+this.bufferLength,i=this.bufferOffset;for(;i+hpe<=n;){let o=this.buffer[i],s=this.buffer.readUInt32BE(i+M4),a=M4+s;if(a+i<=n){let c=this.handlePacket(i+hpe,o,s,this.buffer);r(c),i+=a}else break}i===n?(this.buffer=k4,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){if(this.bufferLength>0){let r=this.bufferLength+e.byteLength;if(r+this.bufferOffset>this.buffer.byteLength){let i;if(r<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)i=this.buffer;else{let o=this.buffer.byteLength*2;for(;r>=o;)o*=2;i=Buffer.allocUnsafe(o)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=i,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=r}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,r,n,i){let{reader:o}=this;o.setBuffer(e,i);let s;switch(r){case 50:s=vt.bindComplete;break;case 49:s=vt.parseComplete;break;case 51:s=vt.closeComplete;break;case 110:s=vt.noData;break;case 115:s=vt.portalSuspended;break;case 99:s=vt.copyDone;break;case 87:s=vt.replicationStart;break;case 73:s=vt.emptyQuery;break;case 68:s=cWe(o);break;case 67:s=eWe(o);break;case 90:s=Q3e(o);break;case 65:s=iWe(o);break;case 82:s=dWe(o,n);break;case 83:s=lWe(o);break;case 75:s=uWe(o);break;case 69:s=mpe(o,"error");break;case 78:s=mpe(o,"notice");break;case 84:s=oWe(o);break;case 116:s=aWe(o);break;case 71:s=rWe(o);break;case 72:s=nWe(o);break;case 100:s=tWe(o,n);break;default:return new vt.DatabaseError("received invalid response: "+r.toString(16),n,"error")}return o.setBuffer(0,k4),s.length=n,s}};YI.Parser=D4;var Q3e=t=>{let e=t.string(1);return new vt.ReadyForQueryMessage(On,e)},eWe=t=>{let e=t.cstring();return new vt.CommandCompleteMessage(On,e)},tWe=(t,e)=>{let r=t.bytes(e-4);return new vt.CopyDataMessage(On,r)},rWe=t=>gpe(t,"copyInResponse"),nWe=t=>gpe(t,"copyOutResponse"),gpe=(t,e)=>{let r=t.byte()!==0,n=t.int16(),i=new vt.CopyResponse(On,e,r,n);for(let o=0;o<n;o++)i.columnTypes[o]=t.int16();return i},iWe=t=>{let e=t.int32(),r=t.cstring(),n=t.cstring();return new vt.NotificationResponseMessage(On,e,r,n)},oWe=t=>{let e=t.int16(),r=new vt.RowDescriptionMessage(On,e);for(let n=0;n<e;n++)r.fields[n]=sWe(t);return r},sWe=t=>{let e=t.cstring(),r=t.uint32(),n=t.int16(),i=t.uint32(),o=t.int16(),s=t.int32(),a=t.int16()===0?"text":"binary";return new vt.Field(e,r,n,i,o,s,a)},aWe=t=>{let e=t.int16(),r=new vt.ParameterDescriptionMessage(On,e);for(let n=0;n<e;n++)r.dataTypeIDs[n]=t.int32();return r},cWe=t=>{let e=t.int16(),r=new Array(e);for(let n=0;n<e;n++){let i=t.int32();r[n]=i===-1?null:t.string(i)}return new vt.DataRowMessage(On,r)},lWe=t=>{let e=t.cstring(),r=t.cstring();return new vt.ParameterStatusMessage(On,e,r)},uWe=t=>{let e=t.int32(),r=t.int32();return new vt.BackendKeyDataMessage(On,e,r)},dWe=(t,e)=>{let r=t.int32(),n={name:"authenticationOk",length:e};switch(r){case 0:break;case 3:n.length===8&&(n.name="authenticationCleartextPassword");break;case 5:if(n.length===12){n.name="authenticationMD5Password";let i=t.bytes(4);return new vt.AuthenticationMD5Password(On,i)}break;case 10:{n.name="authenticationSASL",n.mechanisms=[];let i;do i=t.cstring(),i&&n.mechanisms.push(i);while(i)}break;case 11:n.name="authenticationSASLContinue",n.data=t.string(e-8);break;case 12:n.name="authenticationSASLFinal",n.data=t.string(e-8);break;default:throw new Error("Unknown authenticationOk message type "+r)}return n},mpe=(t,e)=>{let r={},n=t.string(1);for(;n!=="\0";)r[n]=t.cstring(),n=t.string(1);let i=r.M,o=e==="notice"?new vt.NoticeMessage(On,i):new vt.DatabaseError(i,On,e);return o.severity=r.S,o.code=r.C,o.detail=r.D,o.hint=r.H,o.position=r.P,o.internalPosition=r.p,o.internalQuery=r.q,o.where=r.W,o.schema=r.s,o.table=r.t,o.column=r.c,o.dataType=r.d,o.constraint=r.n,o.file=r.F,o.line=r.L,o.routine=r.R,o}});var L4=b(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.DatabaseError=Oc.serialize=Oc.parse=void 0;var fWe=I4();Object.defineProperty(Oc,"DatabaseError",{enumerable:!0,get:function(){return fWe.DatabaseError}});var pWe=fpe();Object.defineProperty(Oc,"serialize",{enumerable:!0,get:function(){return pWe.serialize}});var hWe=_pe();function mWe(t,e){let r=new hWe.Parser;return t.on("data",n=>r.parse(n,e)),new Promise(n=>t.on("end",()=>n()))}Oc.parse=mWe});var ype=b($4=>{"use strict";Object.defineProperty($4,"__esModule",{value:!0});$4.default={}});var Epe=b((zBt,Spe)=>{"use strict";var{getStream:gWe,getSecureStream:_We}=vWe();Spe.exports={getStream:gWe,getSecureStream:_We};function yWe(){function t(r){let n=Z("net");return new n.Socket}function e(r){return Z("tls").connect(r)}return{getStream:t,getSecureStream:e}}function SWe(){function t(r){let{CloudflareSocket:n}=ype();return new n(r)}function e(r){return r.socket.startTls(r),r.socket}return{getStream:t,getSecureStream:e}}function EWe(){if(typeof navigator=="object"&&navigator!==null&&typeof navigator.userAgent=="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response=="function"){let t=new Response(null,{cf:{thing:!0}});if(typeof t.cf=="object"&&t.cf!==null&&t.cf.thing)return!0}return!1}function vWe(){return EWe()?SWe():yWe()}});var F4=b((GBt,vpe)=>{"use strict";var bWe=Z("events").EventEmitter,{parse:TWe,serialize:nr}=L4(),{getStream:xWe,getSecureStream:wWe}=Epe(),AWe=nr.flush(),RWe=nr.sync(),IWe=nr.end(),U4=class extends bWe{constructor(e){super(),e=e||{},this.stream=e.stream||xWe(e.ssl),typeof this.stream=="function"&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;let r=this;this.on("newListener",function(n){n==="message"&&(r._emitMessage=!0)})}connect(e,r){let n=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,r),this.stream.once("connect",function(){n._keepAlive&&n.stream.setKeepAlive(!0,n._keepAliveInitialDelayMillis),n.emit("connect")});let i=function(o){n._ending&&(o.code==="ECONNRESET"||o.code==="EPIPE")||n.emit("error",o)};if(this.stream.on("error",i),this.stream.on("close",function(){n.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(o){switch(o.toString("utf8")){case"S":break;case"N":return n.stream.end(),n.emit("error",new Error("The server does not support SSL connections"));default:return n.stream.end(),n.emit("error",new Error("There was an error establishing an SSL connection"))}let a={socket:n.stream};n.ssl!==!0&&(Object.assign(a,n.ssl),"key"in n.ssl&&(a.key=n.ssl.key));let c=Z("net");c.isIP&&c.isIP(r)===0&&(a.servername=r);try{n.stream=wWe(a)}catch(l){return n.emit("error",l)}n.attachListeners(n.stream),n.stream.on("error",i),n.emit("sslconnect")})}attachListeners(e){TWe(e,r=>{let n=r.name==="error"?"errorMessage":r.name;this._emitMessage&&this.emit("message",r),this.emit(n,r)})}requestSsl(){this.stream.write(nr.requestSsl())}startup(e){this.stream.write(nr.startup(e))}cancel(e,r){this._send(nr.cancel(e,r))}password(e){this._send(nr.password(e))}sendSASLInitialResponseMessage(e,r){this._send(nr.sendSASLInitialResponseMessage(e,r))}sendSCRAMClientFinalMessage(e){this._send(nr.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(nr.query(e))}parse(e){this._send(nr.parse(e))}bind(e){this._send(nr.bind(e))}execute(e){this._send(nr.execute(e))}flush(){this.stream.writable&&this.stream.write(AWe)}sync(){this._ending=!0,this._send(RWe)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(IWe,()=>{this.stream.end()})}close(e){this._send(nr.close(e))}describe(e){this._send(nr.describe(e))}sendCopyFromChunk(e){this._send(nr.copyData(e))}endCopyFrom(){this._send(nr.copyDone())}sendCopyFail(e){this._send(nr.copyFail(e))}};vpe.exports=U4});var wpe=b((qBt,xpe)=>{"use strict";var{Transform:CWe}=Z("stream"),{StringDecoder:PWe}=Z("string_decoder"),Nc=Symbol("last"),KI=Symbol("decoder");function OWe(t,e,r){let n;if(this.overflow){if(n=this[KI].write(t).split(this.matcher),n.length===1)return r();n.shift(),this.overflow=!1}else this[Nc]+=this[KI].write(t),n=this[Nc].split(this.matcher);this[Nc]=n.pop();for(let i=0;i<n.length;i++)try{Tpe(this,this.mapper(n[i]))}catch(o){return r(o)}if(this.overflow=this[Nc].length>this.maxLength,this.overflow&&!this.skipOverflow){r(new Error("maximum buffer reached"));return}r()}function NWe(t){if(this[Nc]+=this[KI].end(),this[Nc])try{Tpe(this,this.mapper(this[Nc]))}catch(e){return t(e)}t()}function Tpe(t,e){e!==void 0&&t.push(e)}function bpe(t){return t}function kWe(t,e,r){switch(t=t||/\r?\n/,e=e||bpe,r=r||{},arguments.length){case 1:typeof t=="function"?(e=t,t=/\r?\n/):typeof t=="object"&&!(t instanceof RegExp)&&!t[Symbol.split]&&(r=t,t=/\r?\n/);break;case 2:typeof t=="function"?(r=e,e=t,t=/\r?\n/):typeof e=="object"&&(r=e,e=bpe)}r=Object.assign({},r),r.autoDestroy=!0,r.transform=OWe,r.flush=NWe,r.readableObjectMode=!0;let n=new CWe(r);return n[Nc]="",n[KI]=new PWe("utf8"),n.matcher=t,n.mapper=e,n.maxLength=r.maxLength,n.skipOverflow=r.skipOverflow||!1,n.overflow=!1,n._destroy=function(i,o){this._writableState.errorEmitted=!1,o(i)},n}xpe.exports=kWe});var Ipe=b((VBt,Zs)=>{"use strict";var Ape=Z("path"),MWe=Z("stream").Stream,DWe=wpe(),Rpe=Z("util"),LWe=5432,ZI=process.platform==="win32",_S=process.stderr,$We=56,UWe=7,FWe=61440,BWe=32768;function jWe(t){return(t&FWe)==BWe}var jh=["host","port","database","user","password"],B4=jh.length,zWe=jh[B4-1];function j4(){var t=_S instanceof MWe&&_S.writable===!0;if(t){var e=Array.prototype.slice.call(arguments).concat(`
|
|
32
|
-
`);_S.write(Rpe.format.apply(Rpe,e))}}Object.defineProperty(Zs.exports,"isWin",{get:function(){return ZI},set:function(t){ZI=t}});Zs.exports.warnTo=function(t){var e=_S;return _S=t,e};Zs.exports.getFileName=function(t){var e=t||process.env,r=e.PGPASSFILE||(ZI?Ape.join(e.APPDATA||"./","postgresql","pgpass.conf"):Ape.join(e.HOME||"./",".pgpass"));return r};Zs.exports.usePgPass=function(t,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:ZI?!0:(e=e||"<unkn>",jWe(t.mode)?t.mode&($We|UWe)?(j4('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(j4('WARNING: password file "%s" is not a plain file',e),!1))};var GWe=Zs.exports.match=function(t,e){return jh.slice(0,-1).reduce(function(r,n,i){return i==1&&Number(t[n]||LWe)===Number(e[n])?r&&!0:r&&(e[n]==="*"||e[n]===t[n])},!0)};Zs.exports.getPassword=function(t,e,r){var n,i=e.pipe(DWe());function o(c){var l=qWe(c);l&&VWe(l)&&GWe(t,l)&&(n=l[zWe],i.end())}var s=function(){e.destroy(),r(n)},a=function(c){e.destroy(),j4("WARNING: error on reading file: %s",c),r(void 0)};e.on("error",a),i.on("data",o).on("end",s).on("error",a)};var qWe=Zs.exports.parseLine=function(t){if(t.length<11||t.match(/^\s+#/))return null;for(var e="",r="",n=0,i=0,o=0,s={},a=!1,c=function(u,d,f){var p=t.substring(d,f);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(p=p.replace(/\\([:\\])/g,"$1")),s[jh[u]]=p},l=0;l<t.length-1;l+=1){if(e=t.charAt(l+1),r=t.charAt(l),a=n==B4-1,a){c(n,i);break}l>=0&&e==":"&&r!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return s=Object.keys(s).length===B4?s:null,s},VWe=Zs.exports.isValidEntry=function(t){for(var e={0:function(s){return s.length>0},1:function(s){return s==="*"?!0:(s=Number(s),isFinite(s)&&s>0&&s<9007199254740992&&Math.floor(s)===s)},2:function(s){return s.length>0},3:function(s){return s.length>0},4:function(s){return s.length>0}},r=0;r<jh.length;r+=1){var n=e[r],i=t[jh[r]]||"",o=n(i);if(!o)return!1}return!0}});var Ppe=b((WBt,z4)=>{"use strict";var HBt=Z("path"),Cpe=Z("fs"),JI=Ipe();z4.exports=function(t,e){var r=JI.getFileName();Cpe.stat(r,function(n,i){if(n||!JI.usePgPass(i,r))return e(void 0);var o=Cpe.createReadStream(r);JI.getPassword(t,o,e)})};z4.exports.warnTo=JI.warnTo});var Dpe=b((YBt,Mpe)=>{"use strict";var HWe=Z("events").EventEmitter,Ope=$h(),yS=Z("util"),XI=Zfe(),WWe=GI(),YWe=u4(),kpe=lpe(),KWe=mS(),ZWe=F4(),JWe=o4(),Npe=yS.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in pg@9.0"),XWe=yS.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in pg@9.0."),QWe=yS.deprecate(()=>{},"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."),eYe=yS.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."),tYe=yS.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");function rYe(t,e){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isFinite(r)?r:e}return e}var QI=class extends HWe{constructor(e){super(),this.connectionParameters=new YWe(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let r=e||{};r.Promise&&eYe(),this._Promise=r.Promise||global.Promise,this._types=new WWe(r.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this._txStatus=null,this.enableChannelBinding=!!r.enableChannelBinding,this.scramMaxIterations=rYe(r.scramMaxIterations,XI.DEFAULT_MAX_SCRAM_ITERATIONS),this.connection=r.connection||new ZWe({stream:r.stream,ssl:this.connectionParameters.ssl,keepAlive:r.keepAlive||!1,keepAliveInitialDelayMillis:r.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=r.binary||KWe.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=r.connectionTimeoutMillis||0}get activeQuery(){return Npe(),this._activeQuery}set activeQuery(e){Npe(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let r=i=>{process.nextTick(()=>{i.handleError(e,this.connection)})},n=this._getActiveQuery();n&&(r(n),this._activeQuery=null),this._queryQueue.forEach(r),this._queryQueue.length=0}_connect(e){let r=this,n=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let i=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(i)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{n._ending=!0,n.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){r.ssl?n.requestSsl():n.startup(r.getStartupConf())}),n.on("sslconnect",function(){n.startup(r.getStartupConf())}),this._attachListeners(n),n.once("end",()=>{let i=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(i),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(i):this._handleErrorEvent(i):this._connectionError||this._handleErrorEvent(i)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((r,n)=>{this._connect(i=>{i?n(i):r(this)})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_getPassword(e){let r=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password(this.connectionParameters)).then(n=>{if(n!==void 0){if(typeof n!="string"){r.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=n}else this.connectionParameters.password=this.password=null;e()}).catch(n=>{r.emit("error",n)});else if(this.password!==null)e();else try{Ppe()(this.connectionParameters,i=>{i!==void 0&&(QWe(),this.connectionParameters.password=this.password=i),e()})}catch(n){this.emit("error",n)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let r=await JWe.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(r)}catch(r){this.emit("error",r)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=XI.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream,this.scramMaxIterations),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(r){this.connection.emit("error",r)}})}async _handleAuthSASLContinue(e){try{await XI.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(r){this.connection.emit("error",r)}}_handleAuthSASLFinal(e){try{XI.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(r){this.connection.emit("error",r)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let r=this._getActiveQuery();this._activeQuery=null,this._txStatus=e?.status??null,this.readyForQuery=!0,r&&r.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let r=this._getActiveQuery();if(!r){this._handleErrorEvent(e);return}this._activeQuery=null,r.handleError(e,this.connection)}_handleRowDescription(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(n);return}r.handleRowDescription(e)}_handleDataRow(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(n);return}r.handleDataRow(e)}_handlePortalSuspended(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(n);return}r.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(n);return}r.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(n);return}r.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let r=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(r);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(n);return}r.handleCopyInResponse(this.connection)}_handleCopyData(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyData message from backend.");this._handleErrorEvent(n);return}r.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,r={user:e.user,database:e.database},n=e.application_name||e.fallback_application_name;return n&&(r.application_name=n),e.replication&&(r.replication=""+e.replication),e.statement_timeout&&(r.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(r.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(r.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(r.options=e.options),r}cancel(e,r){if(e.activeQuery===r){let n=this.connection;this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){n.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(r)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(r),1)}setTypeParser(e,r,n){return this._types.setTypeParser(e,r,n)}getTypeParser(e,r){return this._types.getTypeParser(e,r)}escapeIdentifier(e){return Ope.escapeIdentifier(e)}escapeLiteral(e){return Ope.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let r=e.submit(this.connection);r&&process.nextTick(()=>{e.handleError(r,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit("drain"))}}query(e,r,n){let i,o;if(e==null)throw new TypeError("Client was passed a null or undefined query");if(typeof e.submit=="function")o=i=e,i.callback||(typeof r=="function"?i.callback=r:n&&(i.callback=n));else if(i=new kpe(e,r,n),!i.callback)o=new this._Promise((a,c)=>{i.callback=(l,u)=>l?c(l):a(u)}).catch(a=>{throw Error.captureStackTrace(a),a});else if(typeof i.callback!="function")throw new TypeError("callback is not a function");let s=e.query_timeout||this.connectionParameters.query_timeout;if(s){let a=i.callback||(()=>{}),c=setTimeout(()=>{let l=new Error("Query read timeout");process.nextTick(()=>{i.handleError(l,this.connection)}),a(l),i.callback=()=>{};let u=this._queryQueue.indexOf(i);u>-1&&this._queryQueue.splice(u,1),this._pulseQueryQueue()},s);i.callback=(l,u)=>{clearTimeout(c),a(l,u)}}return this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{i.handleError(new Error("Client was closed and is not queryable"),this.connection)}),o):(this._queryQueue.length>0&&tYe(),this._queryQueue.push(i),this._pulseQueryQueue(),o):(process.nextTick(()=>{i.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),o)}ref(){this.connection.ref()}unref(){this.connection.unref()}getTransactionStatus(){return this._txStatus}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e){e();return}else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(r=>{this.connection.once("end",r)})}get queryQueue(){return XWe(),this._queryQueue}};QI.Query=kpe;Mpe.exports=QI});var Upe=b((KBt,$pe)=>{"use strict";var nYe=Z("events").EventEmitter,G4=function(){},Lpe=(t,e)=>{let r=t.findIndex(e);return r===-1?void 0:t.splice(r,1)[0]},q4=class{constructor(e,r,n){this.client=e,this.idleListener=r,this.timeoutId=n}},zh=class{constructor(e){this.callback=e}};function iYe(){throw new Error("Release called on client which has already been released to the pool.")}function eC(t,e){if(e)return{callback:e,result:void 0};let r,n,i=function(s,a){s?r(s):n(a)},o=new t(function(s,a){n=s,r=a}).catch(s=>{throw Error.captureStackTrace(s),s});return{callback:i,result:o}}function oYe(t,e){return function r(n){n.client=e,e.removeListener("error",r),e.on("error",()=>{t.log("additional client error after disconnection due to error",n)}),t._remove(e),t.emit("error",n,e)}}var V4=class extends nYe{constructor(e,r){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||r||H4().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let r=this.Promise;return typeof r.try=="function"?r.try(e):new r(n=>n(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(r=>{this._remove(r.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let r=this._idle.pop();clearTimeout(r.timeoutId);let n=r.client;n.ref&&n.ref();let i=r.idleListener;return this._acquireClient(n,e,i,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,r){let n=Lpe(this._idle,o=>o.client===e);n!==void 0&&clearTimeout(n.timeoutId),this._clients=this._clients.filter(o=>o!==e);let i=this;e.end(()=>{i.emit("remove",e),typeof r=="function"&&r()})}connect(e){if(this.ending){let i=new Error("Cannot use a pool after calling end on the pool");return e?e(i):this.Promise.reject(i)}let r=eC(this.Promise,e),n=r.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new zh(r.callback)),n;let i=(a,c,l)=>{clearTimeout(s),r.callback(a,c,l)},o=new zh(i),s=setTimeout(()=>{Lpe(this._pendingQueue,a=>a.callback===i),o.timedOut=!0,r.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return s.unref&&s.unref(),this._pendingQueue.push(o),n}return this.newClient(new zh(r.callback)),n}newClient(e){let r=new this.Client(this.options);this._clients.push(r);let n=oYe(this,r);this.log("checking client timeout");let i,o=!1;this.options.connectionTimeoutMillis&&(i=setTimeout(()=>{r.connection?(this.log("ending client due to timeout"),o=!0,r.connection.stream.destroy()):r.isConnected()||(this.log("ending client due to timeout"),o=!0,r.end())},this.options.connectionTimeoutMillis)),this.log("connecting new client"),r.connect(s=>{if(i&&clearTimeout(i),r.on("error",n),s)this.log("client failed to connect",s),this._clients=this._clients.filter(a=>a!==r),o&&(s=new Error("Connection terminated due to connection timeout",{cause:s})),this._pulseQueue(),e.timedOut||e.callback(s,void 0,G4);else{if(this.log("new client connected"),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(r)).then(()=>{this._afterConnect(r,e,n)},a=>{this._clients=this._clients.filter(c=>c!==r),r.end(()=>{this._pulseQueue(),e.timedOut||e.callback(a,void 0,G4)})});return}return this._afterConnect(r,e,n)}})}_afterConnect(e,r,n){if(this.options.maxLifetimeSeconds!==0){let i=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(e),this._idle.findIndex(s=>s.client===e)!==-1&&this._acquireClient(e,new zh((s,a,c)=>c()),n,!1)},this.options.maxLifetimeSeconds*1e3);i.unref(),e.once("end",()=>clearTimeout(i))}return this._acquireClient(e,r,n,!0)}_acquireClient(e,r,n,i){i&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,n),e.removeListener("error",n),r.timedOut?i&&this.options.verify?this.options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,o=>{if(o)return e.release(o),r.callback(o,void 0,G4);r.callback(void 0,e,e.release)}):r.callback(void 0,e,e.release)}_releaseOnce(e,r){let n=!1;return i=>{n&&iYe(),n=!0,this._release(e,r,i)}}_release(e,r,n){if(e.on("error",r),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let o;this.options.idleTimeoutMillis&&this._isAboveMin()&&(o=setTimeout(()=>{this._isAboveMin()&&(this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&o.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new q4(e,r,o)),this._pulseQueue()}query(e,r,n){if(typeof e=="function"){let o=eC(this.Promise,e);return setImmediate(function(){return o.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),o.result}typeof r=="function"&&(n=r,r=void 0);let i=eC(this.Promise,n);return n=i.callback,this.connect((o,s)=>{if(o)return n(o);let a=!1,c=l=>{a||(a=!0,s.release(l),n(l))};s.once("error",c),this.log("dispatching query");try{s.query(e,r,(l,u)=>{if(this.log("query dispatched"),s.removeListener("error",c),!a)return a=!0,s.release(l),l?n(l):n(void 0,u)})}catch(l){return s.release(l),n(l)}}),i.result}end(e){if(this.log("ending"),this.ending){let n=new Error("Called end on pool more than once");return e?e(n):this.Promise.reject(n)}this.ending=!0;let r=eC(this.Promise,e);return this._endCallback=r.callback,this._pulseQueue(),r.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,r)=>e+(this._expired.has(r)?1:0),0)}get totalCount(){return this._clients.length}};$pe.exports=V4});var jpe=b((ZBt,Bpe)=>{"use strict";var Fpe=Z("events").EventEmitter,sYe=Z("util"),W4=$h(),Gh=Bpe.exports=function(t,e,r){Fpe.call(this),t=W4.normalizeQueryConfig(t,e,r),this.text=t.text,this.values=t.values,this.name=t.name,this.queryMode=t.queryMode,this.callback=t.callback,this.state="new",this._arrayMode=t.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};sYe.inherits(Gh,Fpe);var aYe={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};Gh.prototype.handleError=function(t){let e=this.native.pq.resultErrorFields();if(e)for(let r in e){let n=aYe[r]||r;t[n]=e[r]}this.callback?this.callback(t):this.emit("error",t),this.state="error"};Gh.prototype.then=function(t,e){return this._getPromise().then(t,e)};Gh.prototype.catch=function(t){return this._getPromise().catch(t)};Gh.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(t,e){this._once("end",t),this._once("error",e)}.bind(this)),this._promise)};Gh.prototype.submit=function(t){this.state="running";let e=this;this.native=t.native,t.native.arrayMode=this._arrayMode;let r=function(n,i,o){if(t.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),n)return e.handleError(n);e._emitRowEvents&&(o.length>1?i.forEach((s,a)=>{s.forEach(c=>{e.emit("row",c,o[a])})}):i.forEach(function(s){e.emit("row",s,o)})),e.state="end",e.emit("end",o),e.callback&&e.callback(null,o)};if(process.domain&&(r=process.domain.bind(r)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let n=(this.values||[]).map(W4.prepareValue);if(t.namedQueries[this.name]){if(this.text&&t.namedQueries[this.name]!==this.text){let i=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return r(i)}return t.native.execute(this.name,n,r)}return t.native.prepare(this.name,this.text,n.length,function(i){return i?r(i):(t.namedQueries[e.name]=e.text,e.native.execute(e.name,n,r))})}else if(this.values){if(!Array.isArray(this.values)){let i=new Error("Query values must be an array");return r(i)}let n=this.values.map(W4.prepareValue);t.native.query(this.text,n,r)}else this.queryMode==="extended"?t.native.query(this.text,[],r):t.native.query(this.text,r)}});var Hpe=b((JBt,Vpe)=>{"use strict";var cYe=Z("util"),zpe;try{zpe=Z("pg-native")}catch(t){throw t}var lYe=GI(),Gpe=Z("events").EventEmitter,uYe=Z("util"),dYe=u4(),qpe=jpe(),fYe=cYe.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."),xr=Vpe.exports=function(t){Gpe.call(this),t=t||{},this._Promise=t.Promise||global.Promise,this._types=new lYe(t.types),this.native=new zpe({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new dYe(t);t.nativeConnectionString&&(e.nativeConnectionString=t.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};xr.Query=qpe;uYe.inherits(xr,Gpe);xr.prototype._errorAllQueries=function(t){let e=r=>{process.nextTick(()=>{r.native=this.native,r.handleError(t)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};xr.prototype._connect=function(t){let e=this;if(this._connecting){process.nextTick(()=>t(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,n){if(e.connectionParameters.nativeConnectionString&&(n=e.connectionParameters.nativeConnectionString),r)return t(r);e.native.connect(n,function(i){if(i)return e.native.end(),t(i);e._connected=!0,e.native.on("error",function(o){e._queryable=!1,e._errorAllQueries(o),e.emit("error",o)}),e.native.on("notification",function(o){e.emit("notification",{channel:o.relname,payload:o.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),t(null,this)})})};xr.prototype.connect=function(t){if(t){this._connect(t);return}return new this._Promise((e,r)=>{this._connect(n=>{n?r(n):e(this)})})};xr.prototype.query=function(t,e,r){let n,i,o,s,a;if(t==null)throw new TypeError("Client was passed a null or undefined query");if(typeof t.submit=="function")o=t.query_timeout||this.connectionParameters.query_timeout,i=n=t,typeof e=="function"&&(t.callback=e);else if(o=t.query_timeout||this.connectionParameters.query_timeout,n=new qpe(t,e,r),!n.callback){let c,l;i=new this._Promise((u,d)=>{c=u,l=d}).catch(u=>{throw Error.captureStackTrace(u),u}),n.callback=(u,d)=>u?l(u):c(d)}return o&&(a=n.callback||(()=>{}),s=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),a(c),n.callback=()=>{};let l=this._queryQueue.indexOf(n);l>-1&&this._queryQueue.splice(l,1),this._pulseQueryQueue()},o),n.callback=(c,l)=>{clearTimeout(s),a(c,l)}),this._queryable?this._ending?(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"))}),i):(this._queryQueue.length>0&&fYe(),this._queryQueue.push(n),this._pulseQueryQueue(),i):(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"))}),i)};xr.prototype.end=function(t){let e=this;this._ending=!0,this._connecting&&!this._connected&&this.once("connect",()=>{this.end(()=>{})});let r;return t||(r=new this._Promise(function(n,i){t=o=>o?i(o):n()})),this.native.end(function(){e._connected=!1,e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),t&&t()})}),r};xr.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};xr.prototype._pulseQueryQueue=function(t){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){t||this.emit("drain");return}this._activeQuery=e,e.submit(this);let r=this;e.once("_done",function(){r._pulseQueryQueue()})};xr.prototype.cancel=function(t){this._activeQuery===t?this.native.cancel(function(){}):this._queryQueue.indexOf(t)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(t),1)};xr.prototype.ref=function(){};xr.prototype.unref=function(){};xr.prototype.setTypeParser=function(t,e,r){return this._types.setTypeParser(t,e,r)};xr.prototype.getTypeParser=function(t,e){return this._types.getTypeParser(t,e)};xr.prototype.isConnected=function(){return this._connected};xr.prototype.getTransactionStatus=function(){return this.native.getTransactionStatus()}});var Y4=b((XBt,Wpe)=>{"use strict";Wpe.exports=Hpe()});var H4=b((e2t,tC)=>{"use strict";var pYe=Dpe(),hYe=mS(),mYe=F4(),gYe=f4(),_Ye=$h(),yYe=Upe(),SYe=GI(),{DatabaseError:EYe}=L4(),{escapeIdentifier:vYe,escapeLiteral:bYe}=$h(),TYe=t=>class extends yYe{constructor(r){super(r,t)}},Ype=function(t){this.defaults=hYe,this.Client=t,this.Query=this.Client.Query,this.Pool=TYe(this.Client),this._pools=[],this.Connection=mYe,this.types=hS(),this.DatabaseError=EYe,this.TypeOverrides=SYe,this.escapeIdentifier=vYe,this.escapeLiteral=bYe,this.Result=gYe,this.utils=_Ye},Kpe=pYe,Zpe=!1;try{Zpe=!!process.env.NODE_PG_FORCE_NATIVE}catch{}Zpe&&(Kpe=Y4());tC.exports=new Ype(Kpe);Object.defineProperty(tC.exports,"native",{configurable:!0,enumerable:!1,get(){let t=null;try{t=new Ype(Y4())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(tC.exports,"native",{value:t}),t}})});import{readFileSync as jYe}from"fs";import zYe from"path";import{createRequire as GYe}from"module";import{setTimeout as lIe}from"timers/promises";import pge from"process";var X4=typeof globalThis=="object"?globalThis:global;var Lo="1.9.0";var Q4=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yhe(t){var e=new Set([t]),r=new Set,n=t.match(Q4);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function o(a){return r.add(a),!1}function s(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(Q4);if(!l)return o(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?o(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?s(c):o(c):i.minor<=u.minor?s(c):o(c)}}var eq=yhe(Lo);var She=Lo.split(".")[0],Hh=Symbol.for("opentelemetry.js.api."+She),Wh=X4;function Js(t,e,r,n){var i;n===void 0&&(n=!1);var o=Wh[Hh]=(i=Wh[Hh])!==null&&i!==void 0?i:{version:Lo};if(!n&&o[t]){var s=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(s.stack||s.message),!1}if(o.version!==Lo){var s=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+t+" does not match previously registered API v"+Lo);return r.error(s.stack||s.message),!1}return o[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Lo+"."),!0}function ei(t){var e,r,n=(e=Wh[Hh])===null||e===void 0?void 0:e.version;if(!(!n||!eq(n)))return(r=Wh[Hh])===null||r===void 0?void 0:r[t]}function Xs(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Lo+".");var r=Wh[Hh];r&&delete r[t]}var Ehe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},vhe=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},tq=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("verbose",this._namespace,e)},t})();function Yh(t,e,r){var n=ei("diag");if(n)return r.unshift(e),n[t].apply(n,vhe([],Ehe(r),!1))}var Ar;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Ar||(Ar={}));function rq(t,e){t<Ar.NONE?t=Ar.NONE:t>Ar.ALL&&(t=Ar.ALL),e=e||{};function r(n,i){var o=e[n];return typeof o=="function"&&t>=i?o.bind(e):function(){}}return{error:r("error",Ar.ERROR),warn:r("warn",Ar.WARN),info:r("info",Ar.INFO),debug:r("debug",Ar.DEBUG),verbose:r("verbose",Ar.VERBOSE)}}var bhe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},The=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},xhe="diag",sn=(function(){function t(){function e(i){return function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=ei("diag");if(a)return a[i].apply(a,The([],bhe(o),!1))}}var r=this,n=function(i,o){var s,a,c;if(o===void 0&&(o={logLevel:Ar.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((s=l.stack)!==null&&s!==void 0?s:l.message),!1}typeof o=="number"&&(o={logLevel:o});var u=ei("diag"),d=rq((a=o.logLevel)!==null&&a!==void 0?a:Ar.INFO,i);if(u&&!o.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Js("diag",d,r,!0)};r.setLogger=n,r.disable=function(){Xs(xhe,r)},r.createComponentLogger=function(i){return new tq(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var whe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ahe=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nq=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=whe(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t(this._entries);try{for(var s=Ahe(n),a=s.next();!a.done;a=s.next()){var c=a.value;o._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return o},t.prototype.clear=function(){return new t},t})();var h8e=sn.instance();function iq(t){return t===void 0&&(t={}),new nq(new Map(Object.entries(t)))}function vS(t){return Symbol.for(t)}var Rhe=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var o=new t(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),oq=new Rhe;var sq={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},aq={set:function(t,e,r){t!=null&&(t[e]=r)}};var Ihe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Che=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},cq=(function(){function t(){}return t.prototype.active=function(){return oq},t.prototype.with=function(e,r,n){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return r.call.apply(r,Che([n],Ihe(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Phe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ohe=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},sC="context",Nhe=new cq,Qs=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Js(sC,e,sn.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return(i=this._getContextManager()).with.apply(i,Ohe([e,r,n],Phe(o),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return ei(sC)||Nhe},t.prototype.disable=function(){this._getContextManager().disable(),Xs(sC,sn.instance())},t})();var bS;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(bS||(bS={}));var aC="0000000000000000",cC="00000000000000000000000000000000",lq={traceId:cC,spanId:aC,traceFlags:bS.NONE};var ea=(function(){function t(e){e===void 0&&(e=lq),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var lC=vS("OpenTelemetry Context Key SPAN");function TS(t){return t.getValue(lC)||void 0}function uq(){return TS(Qs.getInstance().active())}function Kh(t,e){return t.setValue(lC,e)}function dq(t){return t.deleteValue(lC)}function fq(t,e){return Kh(t,new ea(e))}function xS(t){var e;return(e=TS(t))===null||e===void 0?void 0:e.spanContext()}var khe=/^([0-9a-f]{32})$/i,Mhe=/^[0-9a-f]{16}$/i;function Dhe(t){return khe.test(t)&&t!==cC}function Lhe(t){return Mhe.test(t)&&t!==aC}function wS(t){return Dhe(t.traceId)&&Lhe(t.spanId)}function pq(t){return new ea(t)}var uC=Qs.getInstance(),AS=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=uC.active());var i=!!r?.root;if(i)return new ea;var o=n&&xS(n);return $he(o)&&wS(o)?new ea(o):new ea},t.prototype.startActiveSpan=function(e,r,n,i){var o,s,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(o=r,a=n):(o=r,s=n,a=i);var c=s??uC.active(),l=this.startSpan(e,o,c),u=Kh(c,l);return uC.with(u,a,void 0,l)}},t})();function $he(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Uhe=new AS,hq=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Uhe},t})();var mq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new AS},t})();var Fhe=new mq,dC=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new hq(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Fhe},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var ta;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(ta||(ta={}));var Di;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Di||(Di={}));var $o=Qs.getInstance();var fC=sn.instance();var gq=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var pC=vS("OpenTelemetry Baggage Key");function hC(t){return t.getValue(pC)||void 0}function _q(){return hC(Qs.getInstance().active())}function yq(t,e){return t.setValue(pC,e)}function Sq(t){return t.deleteValue(pC)}var mC="propagation",Bhe=new gq,Eq=(function(){function t(){this.createBaggage=iq,this.getBaggage=hC,this.getActiveBaggage=_q,this.setBaggage=yq,this.deleteBaggage=Sq}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Js(mC,e,sn.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=aq),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=sq),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){Xs(mC,sn.instance())},t.prototype._getGlobalPropagator=function(){return ei(mC)||Bhe},t})();var Zh=Eq.getInstance();var gC="trace",vq=(function(){function t(){this._proxyTracerProvider=new dC,this.wrapSpanContext=pq,this.isSpanContextValid=wS,this.deleteSpan=dq,this.getSpan=TS,this.getActiveSpan=uq,this.getSpanContext=xS,this.setSpan=Kh,this.setSpanContext=fq}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Js(gC,this._proxyTracerProvider,sn.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return ei(gC)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){Xs(gC,sn.instance()),this._proxyTracerProvider=new dC},t})();var Jh=vq.getInstance();var zhe=function(t,e){e.recordException(t),e.setStatus({code:Di.ERROR})};var kc=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var o=bq(r,n,i),s=o.opts,a=o.ctx,c=o.fn;return this._tracer.startActiveSpan(e,s,a,function(l){return Tq(l,s,c)})},t.prototype.withSpan=function(e,r,n,i){var o=bq(r,n,i),s=o.opts,a=o.ctx,c=o.fn,l=this._tracer.startSpan(e,s,a);return Tq(l,s,c)},t})();function bq(t,e,r){var n,i,o;return!e&&!r?o=t:r?(n=t,i=e,o=r):(n=t,o=e),n=n??{},i=i??$o.active(),{opts:n,ctx:i,fn:o}}function Tq(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:zhe,o=function(a){throw i(a,t),t.end(),a};try{var s=r(t);return typeof s?.then=="function"?s.then(function(a){return t.end(),a},o):(t.end(),s)}catch(a){throw o(a)}}p0();Fe();var bm=class{emit(e){}enabled(){return!1}},L6=new bm;var Tm=Symbol.for("io.opentelemetry.js.api.logs"),Fu=globalThis;function $6(t,e,r){return n=>n===t?e:r}var h0=1;var m0=class{getLogger(e,r,n){return new bm}},_E=new m0;var yE=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):L6}};var xm=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yE(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_E}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SE=class t{constructor(){this._proxyLoggerProvider=new xm}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Fu[Tm]?this.getLoggerProvider():(Fu[Tm]=$6(h0,e,_E),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Fu[Tm])===null||e===void 0?void 0:e.call(Fu,h0))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Fu[Tm],this._proxyLoggerProvider=new xm}};var U6=SE.getInstance();function F6(t,e,r,n){for(let i=0,o=t.length;i<o;i++){let s=t[i];e&&s.setTracerProvider(e),r&&s.setMeterProvider(r),n&&s.setLoggerProvider&&s.setLoggerProvider(n),s.getConfig().enabled||s.enable()}}function B6(t){t.forEach(e=>e.disable())}function g0(t){let e=t.tracerProvider||$t.getTracerProvider(),r=t.meterProvider||cm.getMeterProvider(),n=t.loggerProvider||U6.getLoggerProvider(),i=t.instrumentations?.flat()??[];return F6(i,e,r,n),()=>{B6(i)}}bt();var jE=on(N0(),1);bt();var SH=t=>{throw TypeError(t)},L0=(t,e,r)=>e.has(t)||SH("Cannot "+r),BE=(t,e,r)=>(L0(t,e,"read from private field"),r?r.call(t):e.get(t)),k0=(t,e,r)=>e.has(t)?SH("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),gH=(t,e,r,n)=>(L0(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),fge=(t,e,r)=>(L0(t,e,"access private method"),r),_H="__netlify__getTracer",hge="__netlify__shutdownTracers",mge="__nfOTLPTrace",Am,Rm,D0,EH,gge=class{constructor(){k0(this,D0),k0(this,Am),k0(this,Rm),gH(this,Am,new zi(fge(this,D0,EH),this)),gH(this,Rm,fC.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(BE(this,Rm).debug(`export ${t.length.toString()} spans`),BE(this,Am).isCalled){e({code:mt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(mge,JSON.stringify(_ge(t))),e({code:mt.SUCCESS})}shutdown(){return BE(this,Am).call()}};Am=new WeakMap;Rm=new WeakMap;D0=new WeakSet;EH=function(){return BE(this,Rm).debug("Shutting down"),Promise.resolve()};function _ge(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:FE(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||ta.SERVER,startTimeUnixNano:M0(e.startTime),endTimeUnixNano:M0(e.endTime),attributes:FE(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:M0(n.time),attributes:FE(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:FE(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function FE(t){return Object.keys(t).map(e=>vH(e,t[e]))}function vH(t,e){return{key:t,value:bH(e)}}function bH(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(bH)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>vH(r,n))}}:{}}function M0(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var yH={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},TH=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,_H))return;let e=pge.version.slice(1),r=gE({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[yge()],i=new jE.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zo});let o=t.instrumentations??[];g0({instrumentations:o,tracerProvider:i}),Object.defineProperty(globalThis,_H,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kc(Jh.getTracer(a,c)):new kc(Jh.getTracer(yH.name,yH.version))}}),Object.defineProperty(globalThis,hge,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},yge=()=>new jE.SimpleSpanProcessor(new gge);bt();var Im=on(N0(),1);import*as zE from"diagnostics_channel";var xH=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Di.ERROR:Di.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],o=n.some(a=>r.includes(a.toString())),s={};if(o)return s;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?s[d]="REDACTED":s[d]=l.toString()}return s}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof kc?t:new kc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){zE.subscribe(t,e);let r=()=>zE.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:ta.CLIENT},$o.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Di.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var Sge="__netlify__getTracer",Ege="__netlify__shutdownTracers",qe=(t,e)=>globalThis[Sge]?.(t,e),wH=async()=>globalThis[Ege]?.();function qc(t,e,r,n,i){let o=typeof n=="function"?n:typeof r=="function"?r:i;if(!o)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,o):o()}var F5=on(D5(),1);import eIe from"process";var tIe="NETLIFY_FF_",Ei=t=>t==="true"||t==="1",We=()=>{let t={};for(let[e,r]of Object.entries(eIe.env))e.startsWith(tIe)&&r!==void 0&&(t[e]=r);return{byokEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_BYOK_ENABLED),idleTimeoutEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_IDLE_TIMEOUT),fetchAssetsEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_FETCH_ASSETS),coldResumeFromS3Enabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_COLD_RESUME_FROM_S3),creditWrapUpEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_CREDIT_WRAPUP),warmNativeResumeEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_WARM_NATIVE_RESUME),aiFnV1GuardrailEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_AI_FN_V1_GUARDRAIL),questionsEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_QUESTIONS_ENABLED),captureLlmContentEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_CAPTURE_LLM_CONTENT),skillVariations:Object.entries(t).filter(([e,r])=>e.startsWith("NETLIFY_FF_AGENT_RUNNER_SKILL_")&&Ei(r)).map(([e])=>e.replace("NETLIFY_FF_AGENT_RUNNER_SKILL_","").toLowerCase()),modelVersionOverrides:{codex:t.NETLIFY_FF_AGENT_RUNNER_CODEX_VERSION,claude:t.NETLIFY_FF_AGENT_RUNNER_CLAUDE_VERSION,gemini:t.NETLIFY_FF_AGENT_RUNNER_GEMINI_VERSION,opencode:t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_VERSION},opencodeEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_ENABLED),opencodeDefaultModel:t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_DEFAULT_MODEL||void 0,raw:t}};import rIe from"process";var L5;var jg=()=>L5?`-[session:${L5}]`:"";function ye(t){let e=rIe.env.LOG!=="0";return{log:(...r)=>{e&&console.log(`[AR]-[${t}]${jg()}`,...r)},error:(...r)=>{e&&console.error(`[AR]-[ERROR]-[${t}]${jg()}`,...r)},warn:(...r)=>{e&&console.warn(`[AR]-[WARN]-[${t}]${jg()}`,...r)},info:(...r)=>{e&&console.info(`[AR]-[${t}]${jg()}`,...r)},debug:(...r)=>{e&&console.debug(`[AR]-[DEBUG]-[${t}]${jg()}`,...r)}}}import{Transform as nIe}from"stream";var iIe=["NETLIFY_AI_GATEWAY_KEY"];function oIe(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...iIe])]}function sIe(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function aIe(){let e=oIe().map(r=>process.env[r]).filter(r=>!(!r||sIe(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Gn(t){if(typeof t!="string")return t;let e=aIe();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(cIe(n),"g");r=r.replace(i,"******")}),r}function cIe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zg=class extends nIe{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),o=Gn(i);n(null,o)}},bT=Symbol("maskedWrite");function $5(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[bT]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,o){let s=typeof n=="string"?Gn(n):n;return typeof i=="function"?e(s,i):e(s,i,o)};r[bT]=!0,process.stdout.write=r}if(!process.stderr.write[bT]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,o){let s=typeof n=="string"?Gn(n):n;return typeof i=="function"?e(s,i):e(s,i,o)};r[bT]=!0,process.stderr.write=r}}}var TT=ye("tracing"),U5=8e3,uIe=5e3,B5=async(t=uIe)=>{try{await Promise.race([wH(),lIe(t)])}catch(e){TT.warn("Failed to flush tracers on shutdown",e)}},j5=async(t,e,r)=>{if(!qe()){let n=[new Im.SimpleSpanProcessor(new EM),new Im.SimpleSpanProcessor(new F5.OTLPTraceExporter({url:r.exporterUrl}))];await TH({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new xH({skipHeaders:!0})]})}return r.traceparent?(Zh.setGlobalPropagator(new zo),Zh.extract($o.active(),{traceparent:r.traceparent,isRemote:!0})):$o.active()};function ft(t,e,r){return TT.log(`\u23F3 TRACE: ${e} starting...`),qc(t,e,r)}var EM=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let o=e.status?.code===2?"\u274C":"\u2705",s=i.length>0?` [${i.join(", ")}]`:"";TT.log(`${o} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${s}`),e.status?.code===2&&e.status.message&&TT.log(` \u274C Error: ${e.status.message}`)}};function vM(){return We().captureLlmContentEnabled}function z5(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function xT(t,e,r){let n={role:t,parts:[{type:"text",content:Gn(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function G5(t,e,r,n){if(!t.length)return;let i=qe();if(!i)return;let o=vM(),s=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*s),u=Math.min(n,l+s),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>U5?`${a.message.slice(0,U5)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...o&&p?f?{"gen_ai.tool.call.result":Gn(p)}:{"gen_ai.output.messages":xT("assistant",p)}:{}}}).end(u)})}var dIe=["error","failed","exception","fatal","panic","abort","crash"];function q5(t){let e=t.split(`
|
|
32
|
+
`);_S.write(Rpe.format.apply(Rpe,e))}}Object.defineProperty(Zs.exports,"isWin",{get:function(){return ZI},set:function(t){ZI=t}});Zs.exports.warnTo=function(t){var e=_S;return _S=t,e};Zs.exports.getFileName=function(t){var e=t||process.env,r=e.PGPASSFILE||(ZI?Ape.join(e.APPDATA||"./","postgresql","pgpass.conf"):Ape.join(e.HOME||"./",".pgpass"));return r};Zs.exports.usePgPass=function(t,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:ZI?!0:(e=e||"<unkn>",jWe(t.mode)?t.mode&($We|UWe)?(j4('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(j4('WARNING: password file "%s" is not a plain file',e),!1))};var GWe=Zs.exports.match=function(t,e){return jh.slice(0,-1).reduce(function(r,n,i){return i==1&&Number(t[n]||LWe)===Number(e[n])?r&&!0:r&&(e[n]==="*"||e[n]===t[n])},!0)};Zs.exports.getPassword=function(t,e,r){var n,i=e.pipe(DWe());function o(c){var l=qWe(c);l&&VWe(l)&&GWe(t,l)&&(n=l[zWe],i.end())}var s=function(){e.destroy(),r(n)},a=function(c){e.destroy(),j4("WARNING: error on reading file: %s",c),r(void 0)};e.on("error",a),i.on("data",o).on("end",s).on("error",a)};var qWe=Zs.exports.parseLine=function(t){if(t.length<11||t.match(/^\s+#/))return null;for(var e="",r="",n=0,i=0,o=0,s={},a=!1,c=function(u,d,f){var p=t.substring(d,f);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(p=p.replace(/\\([:\\])/g,"$1")),s[jh[u]]=p},l=0;l<t.length-1;l+=1){if(e=t.charAt(l+1),r=t.charAt(l),a=n==B4-1,a){c(n,i);break}l>=0&&e==":"&&r!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return s=Object.keys(s).length===B4?s:null,s},VWe=Zs.exports.isValidEntry=function(t){for(var e={0:function(s){return s.length>0},1:function(s){return s==="*"?!0:(s=Number(s),isFinite(s)&&s>0&&s<9007199254740992&&Math.floor(s)===s)},2:function(s){return s.length>0},3:function(s){return s.length>0},4:function(s){return s.length>0}},r=0;r<jh.length;r+=1){var n=e[r],i=t[jh[r]]||"",o=n(i);if(!o)return!1}return!0}});var Ppe=b((WBt,z4)=>{"use strict";var HBt=Z("path"),Cpe=Z("fs"),JI=Ipe();z4.exports=function(t,e){var r=JI.getFileName();Cpe.stat(r,function(n,i){if(n||!JI.usePgPass(i,r))return e(void 0);var o=Cpe.createReadStream(r);JI.getPassword(t,o,e)})};z4.exports.warnTo=JI.warnTo});var Dpe=b((YBt,Mpe)=>{"use strict";var HWe=Z("events").EventEmitter,Ope=$h(),yS=Z("util"),XI=Zfe(),WWe=GI(),YWe=u4(),kpe=lpe(),KWe=mS(),ZWe=F4(),JWe=o4(),Npe=yS.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in pg@9.0"),XWe=yS.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in pg@9.0."),QWe=yS.deprecate(()=>{},"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."),eYe=yS.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."),tYe=yS.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");function rYe(t,e){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isFinite(r)?r:e}return e}var QI=class extends HWe{constructor(e){super(),this.connectionParameters=new YWe(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let r=e||{};r.Promise&&eYe(),this._Promise=r.Promise||global.Promise,this._types=new WWe(r.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this._txStatus=null,this.enableChannelBinding=!!r.enableChannelBinding,this.scramMaxIterations=rYe(r.scramMaxIterations,XI.DEFAULT_MAX_SCRAM_ITERATIONS),this.connection=r.connection||new ZWe({stream:r.stream,ssl:this.connectionParameters.ssl,keepAlive:r.keepAlive||!1,keepAliveInitialDelayMillis:r.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=r.binary||KWe.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=r.connectionTimeoutMillis||0}get activeQuery(){return Npe(),this._activeQuery}set activeQuery(e){Npe(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let r=i=>{process.nextTick(()=>{i.handleError(e,this.connection)})},n=this._getActiveQuery();n&&(r(n),this._activeQuery=null),this._queryQueue.forEach(r),this._queryQueue.length=0}_connect(e){let r=this,n=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let i=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(i)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{n._ending=!0,n.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){r.ssl?n.requestSsl():n.startup(r.getStartupConf())}),n.on("sslconnect",function(){n.startup(r.getStartupConf())}),this._attachListeners(n),n.once("end",()=>{let i=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(i),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(i):this._handleErrorEvent(i):this._connectionError||this._handleErrorEvent(i)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((r,n)=>{this._connect(i=>{i?n(i):r(this)})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_getPassword(e){let r=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password(this.connectionParameters)).then(n=>{if(n!==void 0){if(typeof n!="string"){r.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=n}else this.connectionParameters.password=this.password=null;e()}).catch(n=>{r.emit("error",n)});else if(this.password!==null)e();else try{Ppe()(this.connectionParameters,i=>{i!==void 0&&(QWe(),this.connectionParameters.password=this.password=i),e()})}catch(n){this.emit("error",n)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let r=await JWe.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(r)}catch(r){this.emit("error",r)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=XI.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream,this.scramMaxIterations),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(r){this.connection.emit("error",r)}})}async _handleAuthSASLContinue(e){try{await XI.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(r){this.connection.emit("error",r)}}_handleAuthSASLFinal(e){try{XI.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(r){this.connection.emit("error",r)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let r=this._getActiveQuery();this._activeQuery=null,this._txStatus=e?.status??null,this.readyForQuery=!0,r&&r.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let r=this._getActiveQuery();if(!r){this._handleErrorEvent(e);return}this._activeQuery=null,r.handleError(e,this.connection)}_handleRowDescription(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(n);return}r.handleRowDescription(e)}_handleDataRow(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(n);return}r.handleDataRow(e)}_handlePortalSuspended(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(n);return}r.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(n);return}r.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(n);return}r.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let r=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(r);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(n);return}r.handleCopyInResponse(this.connection)}_handleCopyData(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyData message from backend.");this._handleErrorEvent(n);return}r.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,r={user:e.user,database:e.database},n=e.application_name||e.fallback_application_name;return n&&(r.application_name=n),e.replication&&(r.replication=""+e.replication),e.statement_timeout&&(r.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(r.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(r.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(r.options=e.options),r}cancel(e,r){if(e.activeQuery===r){let n=this.connection;this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){n.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(r)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(r),1)}setTypeParser(e,r,n){return this._types.setTypeParser(e,r,n)}getTypeParser(e,r){return this._types.getTypeParser(e,r)}escapeIdentifier(e){return Ope.escapeIdentifier(e)}escapeLiteral(e){return Ope.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let r=e.submit(this.connection);r&&process.nextTick(()=>{e.handleError(r,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit("drain"))}}query(e,r,n){let i,o;if(e==null)throw new TypeError("Client was passed a null or undefined query");if(typeof e.submit=="function")o=i=e,i.callback||(typeof r=="function"?i.callback=r:n&&(i.callback=n));else if(i=new kpe(e,r,n),!i.callback)o=new this._Promise((a,c)=>{i.callback=(l,u)=>l?c(l):a(u)}).catch(a=>{throw Error.captureStackTrace(a),a});else if(typeof i.callback!="function")throw new TypeError("callback is not a function");let s=e.query_timeout||this.connectionParameters.query_timeout;if(s){let a=i.callback||(()=>{}),c=setTimeout(()=>{let l=new Error("Query read timeout");process.nextTick(()=>{i.handleError(l,this.connection)}),a(l),i.callback=()=>{};let u=this._queryQueue.indexOf(i);u>-1&&this._queryQueue.splice(u,1),this._pulseQueryQueue()},s);i.callback=(l,u)=>{clearTimeout(c),a(l,u)}}return this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{i.handleError(new Error("Client was closed and is not queryable"),this.connection)}),o):(this._queryQueue.length>0&&tYe(),this._queryQueue.push(i),this._pulseQueryQueue(),o):(process.nextTick(()=>{i.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),o)}ref(){this.connection.ref()}unref(){this.connection.unref()}getTransactionStatus(){return this._txStatus}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e){e();return}else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(r=>{this.connection.once("end",r)})}get queryQueue(){return XWe(),this._queryQueue}};QI.Query=kpe;Mpe.exports=QI});var Upe=b((KBt,$pe)=>{"use strict";var nYe=Z("events").EventEmitter,G4=function(){},Lpe=(t,e)=>{let r=t.findIndex(e);return r===-1?void 0:t.splice(r,1)[0]},q4=class{constructor(e,r,n){this.client=e,this.idleListener=r,this.timeoutId=n}},zh=class{constructor(e){this.callback=e}};function iYe(){throw new Error("Release called on client which has already been released to the pool.")}function eC(t,e){if(e)return{callback:e,result:void 0};let r,n,i=function(s,a){s?r(s):n(a)},o=new t(function(s,a){n=s,r=a}).catch(s=>{throw Error.captureStackTrace(s),s});return{callback:i,result:o}}function oYe(t,e){return function r(n){n.client=e,e.removeListener("error",r),e.on("error",()=>{t.log("additional client error after disconnection due to error",n)}),t._remove(e),t.emit("error",n,e)}}var V4=class extends nYe{constructor(e,r){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||r||H4().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let r=this.Promise;return typeof r.try=="function"?r.try(e):new r(n=>n(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(r=>{this._remove(r.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let r=this._idle.pop();clearTimeout(r.timeoutId);let n=r.client;n.ref&&n.ref();let i=r.idleListener;return this._acquireClient(n,e,i,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,r){let n=Lpe(this._idle,o=>o.client===e);n!==void 0&&clearTimeout(n.timeoutId),this._clients=this._clients.filter(o=>o!==e);let i=this;e.end(()=>{i.emit("remove",e),typeof r=="function"&&r()})}connect(e){if(this.ending){let i=new Error("Cannot use a pool after calling end on the pool");return e?e(i):this.Promise.reject(i)}let r=eC(this.Promise,e),n=r.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new zh(r.callback)),n;let i=(a,c,l)=>{clearTimeout(s),r.callback(a,c,l)},o=new zh(i),s=setTimeout(()=>{Lpe(this._pendingQueue,a=>a.callback===i),o.timedOut=!0,r.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return s.unref&&s.unref(),this._pendingQueue.push(o),n}return this.newClient(new zh(r.callback)),n}newClient(e){let r=new this.Client(this.options);this._clients.push(r);let n=oYe(this,r);this.log("checking client timeout");let i,o=!1;this.options.connectionTimeoutMillis&&(i=setTimeout(()=>{r.connection?(this.log("ending client due to timeout"),o=!0,r.connection.stream.destroy()):r.isConnected()||(this.log("ending client due to timeout"),o=!0,r.end())},this.options.connectionTimeoutMillis)),this.log("connecting new client"),r.connect(s=>{if(i&&clearTimeout(i),r.on("error",n),s)this.log("client failed to connect",s),this._clients=this._clients.filter(a=>a!==r),o&&(s=new Error("Connection terminated due to connection timeout",{cause:s})),this._pulseQueue(),e.timedOut||e.callback(s,void 0,G4);else{if(this.log("new client connected"),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(r)).then(()=>{this._afterConnect(r,e,n)},a=>{this._clients=this._clients.filter(c=>c!==r),r.end(()=>{this._pulseQueue(),e.timedOut||e.callback(a,void 0,G4)})});return}return this._afterConnect(r,e,n)}})}_afterConnect(e,r,n){if(this.options.maxLifetimeSeconds!==0){let i=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(e),this._idle.findIndex(s=>s.client===e)!==-1&&this._acquireClient(e,new zh((s,a,c)=>c()),n,!1)},this.options.maxLifetimeSeconds*1e3);i.unref(),e.once("end",()=>clearTimeout(i))}return this._acquireClient(e,r,n,!0)}_acquireClient(e,r,n,i){i&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,n),e.removeListener("error",n),r.timedOut?i&&this.options.verify?this.options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,o=>{if(o)return e.release(o),r.callback(o,void 0,G4);r.callback(void 0,e,e.release)}):r.callback(void 0,e,e.release)}_releaseOnce(e,r){let n=!1;return i=>{n&&iYe(),n=!0,this._release(e,r,i)}}_release(e,r,n){if(e.on("error",r),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let o;this.options.idleTimeoutMillis&&this._isAboveMin()&&(o=setTimeout(()=>{this._isAboveMin()&&(this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&o.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new q4(e,r,o)),this._pulseQueue()}query(e,r,n){if(typeof e=="function"){let o=eC(this.Promise,e);return setImmediate(function(){return o.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),o.result}typeof r=="function"&&(n=r,r=void 0);let i=eC(this.Promise,n);return n=i.callback,this.connect((o,s)=>{if(o)return n(o);let a=!1,c=l=>{a||(a=!0,s.release(l),n(l))};s.once("error",c),this.log("dispatching query");try{s.query(e,r,(l,u)=>{if(this.log("query dispatched"),s.removeListener("error",c),!a)return a=!0,s.release(l),l?n(l):n(void 0,u)})}catch(l){return s.release(l),n(l)}}),i.result}end(e){if(this.log("ending"),this.ending){let n=new Error("Called end on pool more than once");return e?e(n):this.Promise.reject(n)}this.ending=!0;let r=eC(this.Promise,e);return this._endCallback=r.callback,this._pulseQueue(),r.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,r)=>e+(this._expired.has(r)?1:0),0)}get totalCount(){return this._clients.length}};$pe.exports=V4});var jpe=b((ZBt,Bpe)=>{"use strict";var Fpe=Z("events").EventEmitter,sYe=Z("util"),W4=$h(),Gh=Bpe.exports=function(t,e,r){Fpe.call(this),t=W4.normalizeQueryConfig(t,e,r),this.text=t.text,this.values=t.values,this.name=t.name,this.queryMode=t.queryMode,this.callback=t.callback,this.state="new",this._arrayMode=t.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};sYe.inherits(Gh,Fpe);var aYe={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};Gh.prototype.handleError=function(t){let e=this.native.pq.resultErrorFields();if(e)for(let r in e){let n=aYe[r]||r;t[n]=e[r]}this.callback?this.callback(t):this.emit("error",t),this.state="error"};Gh.prototype.then=function(t,e){return this._getPromise().then(t,e)};Gh.prototype.catch=function(t){return this._getPromise().catch(t)};Gh.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(t,e){this._once("end",t),this._once("error",e)}.bind(this)),this._promise)};Gh.prototype.submit=function(t){this.state="running";let e=this;this.native=t.native,t.native.arrayMode=this._arrayMode;let r=function(n,i,o){if(t.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),n)return e.handleError(n);e._emitRowEvents&&(o.length>1?i.forEach((s,a)=>{s.forEach(c=>{e.emit("row",c,o[a])})}):i.forEach(function(s){e.emit("row",s,o)})),e.state="end",e.emit("end",o),e.callback&&e.callback(null,o)};if(process.domain&&(r=process.domain.bind(r)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let n=(this.values||[]).map(W4.prepareValue);if(t.namedQueries[this.name]){if(this.text&&t.namedQueries[this.name]!==this.text){let i=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return r(i)}return t.native.execute(this.name,n,r)}return t.native.prepare(this.name,this.text,n.length,function(i){return i?r(i):(t.namedQueries[e.name]=e.text,e.native.execute(e.name,n,r))})}else if(this.values){if(!Array.isArray(this.values)){let i=new Error("Query values must be an array");return r(i)}let n=this.values.map(W4.prepareValue);t.native.query(this.text,n,r)}else this.queryMode==="extended"?t.native.query(this.text,[],r):t.native.query(this.text,r)}});var Hpe=b((JBt,Vpe)=>{"use strict";var cYe=Z("util"),zpe;try{zpe=Z("pg-native")}catch(t){throw t}var lYe=GI(),Gpe=Z("events").EventEmitter,uYe=Z("util"),dYe=u4(),qpe=jpe(),fYe=cYe.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."),xr=Vpe.exports=function(t){Gpe.call(this),t=t||{},this._Promise=t.Promise||global.Promise,this._types=new lYe(t.types),this.native=new zpe({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new dYe(t);t.nativeConnectionString&&(e.nativeConnectionString=t.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};xr.Query=qpe;uYe.inherits(xr,Gpe);xr.prototype._errorAllQueries=function(t){let e=r=>{process.nextTick(()=>{r.native=this.native,r.handleError(t)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};xr.prototype._connect=function(t){let e=this;if(this._connecting){process.nextTick(()=>t(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,n){if(e.connectionParameters.nativeConnectionString&&(n=e.connectionParameters.nativeConnectionString),r)return t(r);e.native.connect(n,function(i){if(i)return e.native.end(),t(i);e._connected=!0,e.native.on("error",function(o){e._queryable=!1,e._errorAllQueries(o),e.emit("error",o)}),e.native.on("notification",function(o){e.emit("notification",{channel:o.relname,payload:o.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),t(null,this)})})};xr.prototype.connect=function(t){if(t){this._connect(t);return}return new this._Promise((e,r)=>{this._connect(n=>{n?r(n):e(this)})})};xr.prototype.query=function(t,e,r){let n,i,o,s,a;if(t==null)throw new TypeError("Client was passed a null or undefined query");if(typeof t.submit=="function")o=t.query_timeout||this.connectionParameters.query_timeout,i=n=t,typeof e=="function"&&(t.callback=e);else if(o=t.query_timeout||this.connectionParameters.query_timeout,n=new qpe(t,e,r),!n.callback){let c,l;i=new this._Promise((u,d)=>{c=u,l=d}).catch(u=>{throw Error.captureStackTrace(u),u}),n.callback=(u,d)=>u?l(u):c(d)}return o&&(a=n.callback||(()=>{}),s=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),a(c),n.callback=()=>{};let l=this._queryQueue.indexOf(n);l>-1&&this._queryQueue.splice(l,1),this._pulseQueryQueue()},o),n.callback=(c,l)=>{clearTimeout(s),a(c,l)}),this._queryable?this._ending?(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"))}),i):(this._queryQueue.length>0&&fYe(),this._queryQueue.push(n),this._pulseQueryQueue(),i):(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"))}),i)};xr.prototype.end=function(t){let e=this;this._ending=!0,this._connecting&&!this._connected&&this.once("connect",()=>{this.end(()=>{})});let r;return t||(r=new this._Promise(function(n,i){t=o=>o?i(o):n()})),this.native.end(function(){e._connected=!1,e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),t&&t()})}),r};xr.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};xr.prototype._pulseQueryQueue=function(t){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){t||this.emit("drain");return}this._activeQuery=e,e.submit(this);let r=this;e.once("_done",function(){r._pulseQueryQueue()})};xr.prototype.cancel=function(t){this._activeQuery===t?this.native.cancel(function(){}):this._queryQueue.indexOf(t)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(t),1)};xr.prototype.ref=function(){};xr.prototype.unref=function(){};xr.prototype.setTypeParser=function(t,e,r){return this._types.setTypeParser(t,e,r)};xr.prototype.getTypeParser=function(t,e){return this._types.getTypeParser(t,e)};xr.prototype.isConnected=function(){return this._connected};xr.prototype.getTransactionStatus=function(){return this.native.getTransactionStatus()}});var Y4=b((XBt,Wpe)=>{"use strict";Wpe.exports=Hpe()});var H4=b((ejt,tC)=>{"use strict";var pYe=Dpe(),hYe=mS(),mYe=F4(),gYe=f4(),_Ye=$h(),yYe=Upe(),SYe=GI(),{DatabaseError:EYe}=L4(),{escapeIdentifier:vYe,escapeLiteral:bYe}=$h(),TYe=t=>class extends yYe{constructor(r){super(r,t)}},Ype=function(t){this.defaults=hYe,this.Client=t,this.Query=this.Client.Query,this.Pool=TYe(this.Client),this._pools=[],this.Connection=mYe,this.types=hS(),this.DatabaseError=EYe,this.TypeOverrides=SYe,this.escapeIdentifier=vYe,this.escapeLiteral=bYe,this.Result=gYe,this.utils=_Ye},Kpe=pYe,Zpe=!1;try{Zpe=!!process.env.NODE_PG_FORCE_NATIVE}catch{}Zpe&&(Kpe=Y4());tC.exports=new Ype(Kpe);Object.defineProperty(tC.exports,"native",{configurable:!0,enumerable:!1,get(){let t=null;try{t=new Ype(Y4())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(tC.exports,"native",{value:t}),t}})});import{readFileSync as jYe}from"fs";import zYe from"path";import{createRequire as GYe}from"module";import{setTimeout as lIe}from"timers/promises";import pge from"process";var X4=typeof globalThis=="object"?globalThis:global;var Lo="1.9.0";var Q4=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yhe(t){var e=new Set([t]),r=new Set,n=t.match(Q4);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function o(a){return r.add(a),!1}function s(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(Q4);if(!l)return o(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?o(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?s(c):o(c):i.minor<=u.minor?s(c):o(c)}}var eq=yhe(Lo);var She=Lo.split(".")[0],Hh=Symbol.for("opentelemetry.js.api."+She),Wh=X4;function Js(t,e,r,n){var i;n===void 0&&(n=!1);var o=Wh[Hh]=(i=Wh[Hh])!==null&&i!==void 0?i:{version:Lo};if(!n&&o[t]){var s=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(s.stack||s.message),!1}if(o.version!==Lo){var s=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+t+" does not match previously registered API v"+Lo);return r.error(s.stack||s.message),!1}return o[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Lo+"."),!0}function ei(t){var e,r,n=(e=Wh[Hh])===null||e===void 0?void 0:e.version;if(!(!n||!eq(n)))return(r=Wh[Hh])===null||r===void 0?void 0:r[t]}function Xs(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Lo+".");var r=Wh[Hh];r&&delete r[t]}var Ehe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},vhe=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},tq=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Yh("verbose",this._namespace,e)},t})();function Yh(t,e,r){var n=ei("diag");if(n)return r.unshift(e),n[t].apply(n,vhe([],Ehe(r),!1))}var Ar;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Ar||(Ar={}));function rq(t,e){t<Ar.NONE?t=Ar.NONE:t>Ar.ALL&&(t=Ar.ALL),e=e||{};function r(n,i){var o=e[n];return typeof o=="function"&&t>=i?o.bind(e):function(){}}return{error:r("error",Ar.ERROR),warn:r("warn",Ar.WARN),info:r("info",Ar.INFO),debug:r("debug",Ar.DEBUG),verbose:r("verbose",Ar.VERBOSE)}}var bhe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},The=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},xhe="diag",sn=(function(){function t(){function e(i){return function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=ei("diag");if(a)return a[i].apply(a,The([],bhe(o),!1))}}var r=this,n=function(i,o){var s,a,c;if(o===void 0&&(o={logLevel:Ar.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((s=l.stack)!==null&&s!==void 0?s:l.message),!1}typeof o=="number"&&(o={logLevel:o});var u=ei("diag"),d=rq((a=o.logLevel)!==null&&a!==void 0?a:Ar.INFO,i);if(u&&!o.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Js("diag",d,r,!0)};r.setLogger=n,r.disable=function(){Xs(xhe,r)},r.createComponentLogger=function(i){return new tq(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var whe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ahe=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nq=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=whe(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t(this._entries);try{for(var s=Ahe(n),a=s.next();!a.done;a=s.next()){var c=a.value;o._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return o},t.prototype.clear=function(){return new t},t})();var h8e=sn.instance();function iq(t){return t===void 0&&(t={}),new nq(new Map(Object.entries(t)))}function vS(t){return Symbol.for(t)}var Rhe=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var o=new t(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),oq=new Rhe;var sq={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},aq={set:function(t,e,r){t!=null&&(t[e]=r)}};var Ihe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Che=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},cq=(function(){function t(){}return t.prototype.active=function(){return oq},t.prototype.with=function(e,r,n){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return r.call.apply(r,Che([n],Ihe(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Phe=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ohe=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},sC="context",Nhe=new cq,Qs=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Js(sC,e,sn.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return(i=this._getContextManager()).with.apply(i,Ohe([e,r,n],Phe(o),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return ei(sC)||Nhe},t.prototype.disable=function(){this._getContextManager().disable(),Xs(sC,sn.instance())},t})();var bS;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(bS||(bS={}));var aC="0000000000000000",cC="00000000000000000000000000000000",lq={traceId:cC,spanId:aC,traceFlags:bS.NONE};var ea=(function(){function t(e){e===void 0&&(e=lq),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var lC=vS("OpenTelemetry Context Key SPAN");function TS(t){return t.getValue(lC)||void 0}function uq(){return TS(Qs.getInstance().active())}function Kh(t,e){return t.setValue(lC,e)}function dq(t){return t.deleteValue(lC)}function fq(t,e){return Kh(t,new ea(e))}function xS(t){var e;return(e=TS(t))===null||e===void 0?void 0:e.spanContext()}var khe=/^([0-9a-f]{32})$/i,Mhe=/^[0-9a-f]{16}$/i;function Dhe(t){return khe.test(t)&&t!==cC}function Lhe(t){return Mhe.test(t)&&t!==aC}function wS(t){return Dhe(t.traceId)&&Lhe(t.spanId)}function pq(t){return new ea(t)}var uC=Qs.getInstance(),AS=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=uC.active());var i=!!r?.root;if(i)return new ea;var o=n&&xS(n);return $he(o)&&wS(o)?new ea(o):new ea},t.prototype.startActiveSpan=function(e,r,n,i){var o,s,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(o=r,a=n):(o=r,s=n,a=i);var c=s??uC.active(),l=this.startSpan(e,o,c),u=Kh(c,l);return uC.with(u,a,void 0,l)}},t})();function $he(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Uhe=new AS,hq=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Uhe},t})();var mq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new AS},t})();var Fhe=new mq,dC=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new hq(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Fhe},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var ta;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(ta||(ta={}));var Di;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Di||(Di={}));var $o=Qs.getInstance();var fC=sn.instance();var gq=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var pC=vS("OpenTelemetry Baggage Key");function hC(t){return t.getValue(pC)||void 0}function _q(){return hC(Qs.getInstance().active())}function yq(t,e){return t.setValue(pC,e)}function Sq(t){return t.deleteValue(pC)}var mC="propagation",Bhe=new gq,Eq=(function(){function t(){this.createBaggage=iq,this.getBaggage=hC,this.getActiveBaggage=_q,this.setBaggage=yq,this.deleteBaggage=Sq}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Js(mC,e,sn.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=aq),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=sq),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){Xs(mC,sn.instance())},t.prototype._getGlobalPropagator=function(){return ei(mC)||Bhe},t})();var Zh=Eq.getInstance();var gC="trace",vq=(function(){function t(){this._proxyTracerProvider=new dC,this.wrapSpanContext=pq,this.isSpanContextValid=wS,this.deleteSpan=dq,this.getSpan=TS,this.getActiveSpan=uq,this.getSpanContext=xS,this.setSpan=Kh,this.setSpanContext=fq}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Js(gC,this._proxyTracerProvider,sn.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return ei(gC)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){Xs(gC,sn.instance()),this._proxyTracerProvider=new dC},t})();var Jh=vq.getInstance();var zhe=function(t,e){e.recordException(t),e.setStatus({code:Di.ERROR})};var kc=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var o=bq(r,n,i),s=o.opts,a=o.ctx,c=o.fn;return this._tracer.startActiveSpan(e,s,a,function(l){return Tq(l,s,c)})},t.prototype.withSpan=function(e,r,n,i){var o=bq(r,n,i),s=o.opts,a=o.ctx,c=o.fn,l=this._tracer.startSpan(e,s,a);return Tq(l,s,c)},t})();function bq(t,e,r){var n,i,o;return!e&&!r?o=t:r?(n=t,i=e,o=r):(n=t,o=e),n=n??{},i=i??$o.active(),{opts:n,ctx:i,fn:o}}function Tq(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:zhe,o=function(a){throw i(a,t),t.end(),a};try{var s=r(t);return typeof s?.then=="function"?s.then(function(a){return t.end(),a},o):(t.end(),s)}catch(a){throw o(a)}}p0();Fe();var bm=class{emit(e){}enabled(){return!1}},L6=new bm;var Tm=Symbol.for("io.opentelemetry.js.api.logs"),Fu=globalThis;function $6(t,e,r){return n=>n===t?e:r}var h0=1;var m0=class{getLogger(e,r,n){return new bm}},_E=new m0;var yE=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):L6}};var xm=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yE(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_E}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SE=class t{constructor(){this._proxyLoggerProvider=new xm}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Fu[Tm]?this.getLoggerProvider():(Fu[Tm]=$6(h0,e,_E),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Fu[Tm])===null||e===void 0?void 0:e.call(Fu,h0))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Fu[Tm],this._proxyLoggerProvider=new xm}};var U6=SE.getInstance();function F6(t,e,r,n){for(let i=0,o=t.length;i<o;i++){let s=t[i];e&&s.setTracerProvider(e),r&&s.setMeterProvider(r),n&&s.setLoggerProvider&&s.setLoggerProvider(n),s.getConfig().enabled||s.enable()}}function B6(t){t.forEach(e=>e.disable())}function g0(t){let e=t.tracerProvider||$t.getTracerProvider(),r=t.meterProvider||cm.getMeterProvider(),n=t.loggerProvider||U6.getLoggerProvider(),i=t.instrumentations?.flat()??[];return F6(i,e,r,n),()=>{B6(i)}}bt();var jE=on(N0(),1);bt();var SH=t=>{throw TypeError(t)},L0=(t,e,r)=>e.has(t)||SH("Cannot "+r),BE=(t,e,r)=>(L0(t,e,"read from private field"),r?r.call(t):e.get(t)),k0=(t,e,r)=>e.has(t)?SH("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),gH=(t,e,r,n)=>(L0(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),fge=(t,e,r)=>(L0(t,e,"access private method"),r),_H="__netlify__getTracer",hge="__netlify__shutdownTracers",mge="__nfOTLPTrace",Am,Rm,D0,EH,gge=class{constructor(){k0(this,D0),k0(this,Am),k0(this,Rm),gH(this,Am,new zi(fge(this,D0,EH),this)),gH(this,Rm,fC.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(BE(this,Rm).debug(`export ${t.length.toString()} spans`),BE(this,Am).isCalled){e({code:mt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(mge,JSON.stringify(_ge(t))),e({code:mt.SUCCESS})}shutdown(){return BE(this,Am).call()}};Am=new WeakMap;Rm=new WeakMap;D0=new WeakSet;EH=function(){return BE(this,Rm).debug("Shutting down"),Promise.resolve()};function _ge(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:FE(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||ta.SERVER,startTimeUnixNano:M0(e.startTime),endTimeUnixNano:M0(e.endTime),attributes:FE(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:M0(n.time),attributes:FE(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:FE(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function FE(t){return Object.keys(t).map(e=>vH(e,t[e]))}function vH(t,e){return{key:t,value:bH(e)}}function bH(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(bH)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>vH(r,n))}}:{}}function M0(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var yH={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},TH=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,_H))return;let e=pge.version.slice(1),r=gE({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[yge()],i=new jE.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zo});let o=t.instrumentations??[];g0({instrumentations:o,tracerProvider:i}),Object.defineProperty(globalThis,_H,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kc(Jh.getTracer(a,c)):new kc(Jh.getTracer(yH.name,yH.version))}}),Object.defineProperty(globalThis,hge,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},yge=()=>new jE.SimpleSpanProcessor(new gge);bt();var Im=on(N0(),1);import*as zE from"diagnostics_channel";var xH=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Di.ERROR:Di.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],o=n.some(a=>r.includes(a.toString())),s={};if(o)return s;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?s[d]="REDACTED":s[d]=l.toString()}return s}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof kc?t:new kc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){zE.subscribe(t,e);let r=()=>zE.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:ta.CLIENT},$o.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Di.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var Sge="__netlify__getTracer",Ege="__netlify__shutdownTracers",qe=(t,e)=>globalThis[Sge]?.(t,e),wH=async()=>globalThis[Ege]?.();function qc(t,e,r,n,i){let o=typeof n=="function"?n:typeof r=="function"?r:i;if(!o)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,o):o()}var F5=on(D5(),1);import eIe from"process";var tIe="NETLIFY_FF_",Ei=t=>t==="true"||t==="1",We=()=>{let t={};for(let[e,r]of Object.entries(eIe.env))e.startsWith(tIe)&&r!==void 0&&(t[e]=r);return{byokEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_BYOK_ENABLED),idleTimeoutEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_IDLE_TIMEOUT),fetchAssetsEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_FETCH_ASSETS),coldResumeFromS3Enabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_COLD_RESUME_FROM_S3),creditWrapUpEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_CREDIT_WRAPUP),warmNativeResumeEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_WARM_NATIVE_RESUME),aiFnV1GuardrailEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_AI_FN_V1_GUARDRAIL),questionsEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_QUESTIONS_ENABLED),captureLlmContentEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_CAPTURE_LLM_CONTENT),skillVariations:Object.entries(t).filter(([e,r])=>e.startsWith("NETLIFY_FF_AGENT_RUNNER_SKILL_")&&Ei(r)).map(([e])=>e.replace("NETLIFY_FF_AGENT_RUNNER_SKILL_","").toLowerCase()),modelVersionOverrides:{codex:t.NETLIFY_FF_AGENT_RUNNER_CODEX_VERSION,claude:t.NETLIFY_FF_AGENT_RUNNER_CLAUDE_VERSION,gemini:t.NETLIFY_FF_AGENT_RUNNER_GEMINI_VERSION,opencode:t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_VERSION},opencodeEnabled:Ei(t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_ENABLED),opencodeDefaultModel:t.NETLIFY_FF_AGENT_RUNNER_OPENCODE_DEFAULT_MODEL||void 0,raw:t}};import rIe from"process";var L5;var jg=()=>L5?`-[session:${L5}]`:"";function ye(t){let e=rIe.env.LOG!=="0";return{log:(...r)=>{e&&console.log(`[AR]-[${t}]${jg()}`,...r)},error:(...r)=>{e&&console.error(`[AR]-[ERROR]-[${t}]${jg()}`,...r)},warn:(...r)=>{e&&console.warn(`[AR]-[WARN]-[${t}]${jg()}`,...r)},info:(...r)=>{e&&console.info(`[AR]-[${t}]${jg()}`,...r)},debug:(...r)=>{e&&console.debug(`[AR]-[DEBUG]-[${t}]${jg()}`,...r)}}}import{Transform as nIe}from"stream";var iIe=["NETLIFY_AI_GATEWAY_KEY"];function oIe(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...iIe])]}function sIe(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function aIe(){let e=oIe().map(r=>process.env[r]).filter(r=>!(!r||sIe(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Gn(t){if(typeof t!="string")return t;let e=aIe();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(cIe(n),"g");r=r.replace(i,"******")}),r}function cIe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zg=class extends nIe{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),o=Gn(i);n(null,o)}},bT=Symbol("maskedWrite");function $5(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[bT]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,o){let s=typeof n=="string"?Gn(n):n;return typeof i=="function"?e(s,i):e(s,i,o)};r[bT]=!0,process.stdout.write=r}if(!process.stderr.write[bT]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,o){let s=typeof n=="string"?Gn(n):n;return typeof i=="function"?e(s,i):e(s,i,o)};r[bT]=!0,process.stderr.write=r}}}var TT=ye("tracing"),U5=8e3,uIe=5e3,B5=async(t=uIe)=>{try{await Promise.race([wH(),lIe(t)])}catch(e){TT.warn("Failed to flush tracers on shutdown",e)}},j5=async(t,e,r)=>{if(!qe()){let n=[new Im.SimpleSpanProcessor(new EM),new Im.SimpleSpanProcessor(new F5.OTLPTraceExporter({url:r.exporterUrl}))];await TH({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new xH({skipHeaders:!0})]})}return r.traceparent?(Zh.setGlobalPropagator(new zo),Zh.extract($o.active(),{traceparent:r.traceparent,isRemote:!0})):$o.active()};function ft(t,e,r){return TT.log(`\u23F3 TRACE: ${e} starting...`),qc(t,e,r)}var EM=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let o=e.status?.code===2?"\u274C":"\u2705",s=i.length>0?` [${i.join(", ")}]`:"";TT.log(`${o} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${s}`),e.status?.code===2&&e.status.message&&TT.log(` \u274C Error: ${e.status.message}`)}};function vM(){return We().captureLlmContentEnabled}function z5(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function xT(t,e,r){let n={role:t,parts:[{type:"text",content:Gn(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function G5(t,e,r,n){if(!t.length)return;let i=qe();if(!i)return;let o=vM(),s=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*s),u=Math.min(n,l+s),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>U5?`${a.message.slice(0,U5)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...o&&p?f?{"gen_ai.tool.call.result":Gn(p)}:{"gen_ai.output.messages":xT("assistant",p)}:{}}}).end(u)})}var dIe=["error","failed","exception","fatal","panic","abort","crash"];function q5(t){let e=t.split(`
|
|
33
33
|
`),r=[],n=-1,i=0;for(;i<e.length;){let a=e[i].slice(0,500).toLowerCase();if(dIe.some(l=>a.includes(l))){let l=Math.max(0,i-10,n+1),u=Math.min(e.length-1,i+20),d=[];for(let f=l;f<=u;f++)d.push(e[f]);r.push(d.join(`
|
|
34
34
|
`)),n=u,i=u+1}else i++}if(r.length===0)return t;let o=r.map((s,a)=>`<extracted_error_chunk order="${a+1}">
|
|
35
35
|
${s}
|
|
@@ -98,7 +98,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
98
98
|
`,LF:`
|
|
99
99
|
`,concatBytes:xD},xNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},wNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:xNe};import{Buffer as ANe}from"buffer";var WQ=(t,e)=>t?void 0:RNe.bind(void 0,e),RNe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!ANe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},YQ=(t,e)=>t?INe.bind(void 0,e):CNe.bind(void 0,e),INe=function*(t,e){KQ(t,e),yield e},CNe=function*(t,e){if(KQ(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},KQ=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
100
100
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
101
|
-
if (condition) { yield value; }`)};import{Buffer as PNe}from"buffer";import{StringDecoder as ONe}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:NNe.bind(void 0,new TextEncoder)};let n=new ONe(e);return{transform:kNe.bind(void 0,n),final:MNe.bind(void 0,n)}},NNe=function*(t,e){PNe.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},kNe=function*(t,e){yield jt(e)?t.write(e):e},MNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZQ}from"util";var AD=ZQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LNe}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},JQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DNe(r,Number(e),t)},DNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},XQ=ZQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LNe=function*(t){yield t};var RD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...s_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},UNe=function*(t){yield t};var ID=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=t7(t,s,o),l=Tl(e),u=Tl(r),d=l?AD.bind(void 0,wx,a):RD.bind(void 0,xl),f=l||u?AD.bind(void 0,JQ,a):RD.bind(void 0,s_),p=l||u?XQ.bind(void 0,a):void 0;return{stream:new FNe({writableObjectMode:n,writableHighWaterMark:e7(n),readableObjectMode:i,readableHighWaterMark:e7(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Ax=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=t7(s,r,a);t=QQ(c,t)}return t},t7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:WQ(n,a)},xx(r,s,n),Tx(r,o,n,c),{transform:t,final:e},{transform:YQ(i,a)},HQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var r7=(t,e)=>{for(let r of BNe(t))jNe(t,r,e)},BNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jNe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Pa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>zNe(a,n));r.input=Zg(s)},zNe=(t,e)=>{let r=Ax(t,e,"utf8",!0);return GNe(r),Zg(r)},GNe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as WNe,appendFileSync as YNe}from"fs";var Rx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!_n.has(e)&&qNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&VNe.has(o))||t.every(({type:i})=>Vn.has(i))),qNe=t=>t===1||t===2,VNe=new Set(["pipe","overlapped"]),n7=async(t,e,r,n)=>{for await(let i of t)HNe(e)||o7(i,r,n)},i7=(t,e,r)=>{for(let n of t)o7(n,e,r)},HNe=t=>t._readableState.pipes.length>0,o7=(t,e,r)=>{let n=jT(t);co({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s7=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>KNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},KNe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=aQ(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=ZNe([p],h,c,n),{serializedResult:S,finalResult:T=S}=JNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});XNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&QNe(S,h,i),x}catch(v){return n.error=v,x}},ZNe=(t,e,r,n)=>{try{return Ax(t,e,r,!1)}catch(i){return n.error=i,t}},JNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Zg(t)};let s=v9(t,r);return n[o]?{serializedResult:s,finalResult:wD(s,!i[o],e)}:{serializedResult:s}},XNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Rx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=wD(t,!1,s);try{i7(a,e,n)}catch(c){r.error??=c}},QNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?YNe(n,t):(r.add(o),WNe(n,t))}};var a7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?MM([t,e]):`${t}${e}`};import{once as CD}from"events";var c7=async(t,e)=>{let[r,n]=await eke(t);return e.isForcefullyTerminated??=!1,[r,n]},eke=async t=>{let[e,r]=await Promise.allSettled([CD(t,"spawn"),CD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l7(t):r.value},l7=async t=>{try{return await CD(t,"exit")}catch{return l7(t)}},u7=async t=>{let[e,r]=await t;if(!tke(e,r)&&PD(e,r))throw new Ti;return[e,r]},tke=(t,e)=>t===void 0&&e===void 0,PD=(t,e)=>t!==0||e!==null;var d7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=rke(t,e,r),s=o?.code==="ETIMEDOUT",a=sQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},rke=(t,e,r)=>t!==void 0?t:PD(e,r)?new Ti:void 0;var f7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=ike(t,e,r),d=ake({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},ike=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),a=oke(r),{file:c,commandArguments:l,options:u}=lx(t,e,a);ske(u);let d=zQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ske=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ake=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=cke({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=d7(c,r),{output:h,error:m=l}=s7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((T,x)=>ms(T,r,x)),S=ms(a7(h,r),r,"all");return uke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},cke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{r7(o,r);let a=lke(r);return nke(...ux(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},lke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_x(e)}),uke=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?yx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):o_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as JMe}from"events";import{spawn as XMe}from"child_process";import _7 from"process";import{once as OD,on as dke}from"events";var p7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),fke({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),fke=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([pke(o,n,s),hke(o,r,s),mke(o,r,s)])}catch(a){throw qd(t),a}finally{s.abort(),ex(e,i)}},pke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await OD(t,"message",{signal:r});return n}for await(let[n]of dke(t,"message",{signal:r}))if(e(n))return n},hke=async(t,e,{signal:r})=>{await OD(t,"disconnect",{signal:r}),QJ(e)},mke=async(t,e,{signal:r})=>{let[n]=await OD(t,"strict:error",{signal:r});throw ZT(n,e)};import{once as m7,on as gke}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ND({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ND=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),QT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return _ke(t,s,a),yke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ske({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},_ke=async(t,e,r)=>{try{await m7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},yke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m7(t,"strict:error",{signal:r.signal});n.error=ZT(i,e),r.abort()}catch{}},Ske=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of gke(r,"message",{signal:o.signal}))h7(s),yield c}catch{h7(s)}finally{o.abort(),ex(e,a),n||qd(t),i&&await t}},h7=({error:t})=>{if(t)throw t};var y7=(t,{ipc:e})=>{Object.assign(t,E7(t,!1,e))},S7=()=>{let t=_7,e=!0,r=_7.channel!==void 0;return{...E7(t,e,r),getCancelSignal:AX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E7=(t,e,r)=>({sendMessage:ax.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Eke}from"child_process";import{PassThrough as vke,Readable as bke,Writable as Tke,Duplex as xke}from"stream";var v7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{bD(n);let a=new Eke;wke(a,n),Object.assign(a,{readable:Ake,writable:Rke,duplex:Ike});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Cke(c,s,i);return{subprocess:a,promise:l}},wke=(t,e)=>{let r=a_(),n=a_(),i=a_(),o=Array.from({length:e.length-3},a_),s=a_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},a_=()=>{let t=new vke;return t.end(),t},Ake=()=>new bke({read(){}}),Rke=()=>new Tke({write(){}}),Ike=()=>new xke({read(){},write(){}}),Cke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as b7,createWriteStream as T7}from"fs";import{Buffer as Pke}from"buffer";import{Readable as c_,Writable as Oke,Duplex as Nke}from"stream";var w7=(t,e)=>bx(kke,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},x7={fileNumber:l_,generator:ID,asyncGenerator:ID,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Nke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},kke={input:{...x7,fileUrl:({value:t})=>({stream:b7(t)}),filePath:({value:{file:t}})=>({stream:b7(t)}),webStream:({value:t})=>({stream:c_.fromWeb(t)}),iterable:({value:t})=>({stream:c_.from(t)}),asyncIterable:({value:t})=>({stream:c_.from(t)}),string:({value:t})=>({stream:c_.from(t)}),uint8Array:({value:t})=>({stream:c_.from(Pke.from(t))})},output:{...x7,fileUrl:({value:t})=>({stream:T7(t)}),filePath:({value:{file:t,append:e}})=>({stream:T7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Oke.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as Mke,once as A7}from"events";import{PassThrough as Dke,getDefaultHighWaterMark as Lke}from"stream";import{finished as C7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)MD(i);let e=t.some(({readableObjectMode:i})=>i),r=$ke(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $ke=(t,e)=>{if(t.length===0)return Lke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends Dke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(MD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Uke(this,this.#e,this.#o);let r=jke({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(MD(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Uke=async(t,e,r)=>{Cx(t,R7);let n=new AbortController;try{await Promise.race([Fke(t,n),Bke(t,e,r,n)])}finally{n.abort(),Cx(t,-R7)}},Fke=async(t,{signal:e})=>{try{await C7(t,{signal:e,cleanup:!0})}catch(r){throw P7(t,r),r}},Bke=async(t,e,r,{signal:n})=>{for await(let[i]of Mke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},MD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Cx(t,I7);let a=new AbortController;try{await Promise.race([zke(o,e,a),Gke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),qke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Cx(t,-I7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DD(t):Vke(t))},zke=async(t,e,{signal:r})=>{try{await t,r.aborted||DD(e)}catch(n){r.aborted||P7(e,n)}},Gke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await C7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;O7(s)?i.add(e):N7(t,s)}},qke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await A7(t,i,{signal:o}),!t.readable)return A7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Vke=t=>{t.writable&&t.end()},P7=(t,e)=>{O7(e)?DD(t):N7(t,e)},O7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DD=t=>{(t.readable||t.writable)&&t.destroy()},N7=(t,e)=>{t.destroyed||(t.once("error",Hke),t.destroy(e))},Hke=()=>{},Cx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},R7=2,I7=1;import{finished as k7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),Wke(t,e),Yke(t,e)},Wke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}LD(e)}},LD=t=>{t.writable&&t.end()},Yke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$D(t)}},$D=t=>{t.readable&&t.destroy()};var M7=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Vn.has(c)))Kke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vn.has(c)))Jke({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:wl(o);Xd(s,i)}},Kke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Zke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Zke=["stdin","stdout","stderr"],Jke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Xke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Xke=(t,{signal:e})=>{bi(t)&&vl(t,Qke,e)},Qke=2;import{addAbortListener as rMe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Px=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",UD=Symbol.for("signal-exit emitter"),FD=globalThis,eMe=Object.defineProperty.bind(Object),BD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(FD[UD])return FD[UD];eMe(FD,UD,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Ox=class{},tMe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),jD=class extends Ox{onExit(){return()=>{}}load(){}unload(){}},zD=class extends Ox{#e=GD.platform==="win32"?"SIGINT":"SIGHUP";#r=new BD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!Px(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Al)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Al.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return Px(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&Px(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},GD=globalThis.process,{onExit:D7,load:Lpt,unload:$pt}=tMe(Px(GD)?new zD(GD):new jD);var L7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D7(()=>{t.kill()});rMe(n,()=>{i()})};var U7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=zT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=nMe(r,n,i),{sourceStream:d,sourceError:f}=oMe(t,l),{options:p,fileDescriptors:h}=uo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},nMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=iMe(t,e,...r),a=XT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},iMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||NM(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=NT(r,...n);return{destination:e($7)(i,o,s),pipeOptions:s}}if(uo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},$7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),oMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var B7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=sMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},sMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $D(t),n;if(e!==void 0)return LD(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:F7,escapedCommand:F7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F7="source.pipe(destination)";var j7=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as aMe}from"stream/promises";var z7=(t,e,r)=>{let n=Nx.has(e)?lMe(t,e):cMe(t,e);return vl(t,dMe,r.signal),vl(e,fMe,r.signal),uMe(e),n},cMe=(t,e)=>{let r=wl([t]);return Xd(r,e),Nx.set(e,r),r},lMe=(t,e)=>{let r=Nx.get(e);return r.add(t),r},uMe=async t=>{try{await aMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Nx.delete(t)},Nx=new WeakMap,dMe=2,fMe=1;import{aborted as pMe}from"util";var G7=(t,e)=>t===void 0?[]:[hMe(t,e)],hMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await pMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw qD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kx=(t,...e)=>{if(Ct(e[0]))return kx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U7(t,...e),i=mMe({...n,destination:r});return i.pipe=kx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},mMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=gMe(t,i);B7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z7(e,o,d);return await Promise.race([j7(u),...G7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},gMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as TMe}from"timers/promises";import{on as _Me}from"events";import{getDefaultHighWaterMark as yMe}from"stream";var Mx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return SMe(e,s),V7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},SMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;EMe(e,s,t);let a=t.readableObjectMode&&!o;return V7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},EMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=_Me(t,"data",{signal:e.signal,highWaterMark:q7,highWatermark:q7});return vMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},HD=yMe(!0),q7=HD,vMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=bMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*s_(a)}},bMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Tx(t,i,!n,{})].filter(Boolean);var H7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=xMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([wMe(t),d]);return}let f=TD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([AMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},xMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Rx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n7(a,t,r,o)},wMe=async t=>{await TMe(),t.readableFlowing===null&&t.resume()},AMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return W7(nQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},WD=async t=>{try{return await t}catch(e){return W7(e)}},W7=({bufferedData:t})=>S9(t)?new Uint8Array(t):t;import{finished as RMe}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=IMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],RMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||OMe(a,e,r,n)}finally{s.abort()}},IMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&CMe(t,r,n),n},CMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{PMe(e,r),n.call(t,...i)}},PMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},OMe=(t,e,r,n)=>{if(!NMe(t,e,r,n))throw t},NMe=(t,e,r,n=!0)=>r.propagating?Y7(t)||Dx(t):(r.propagating=!0,YD(r,e)===n?Y7(t):Dx(t)),YD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Dx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y7=t=>t?.code==="EPIPE";var K7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>KD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),KD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=u_(t,e,l);if(YD(l,e)){await u;return}let[d]=await Promise.all([H7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,J7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>KD({...kMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:MMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),kMe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},MMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as DMe}from"events";var X7=t=>Bd(t,"ipc"),Q7=(t,e)=>{let r=jT(t);co({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=X7(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of ND({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iQ(t,i,c),i.push(l)),s&&Q7(l,o);return i},tee=async(t,e)=>(await Promise.allSettled([t]),e);var ree=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:y,controller:S})=>{let T=c7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=K7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=J7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],U=eee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=LMe(m,t,x),D=$Me(h,x);try{return await Promise.race([Promise.all([{},u7(T),Promise.all(v),N,U,LX(t,d),...C,...D]),y,UMe(t,S),...OX(t,o,f,S),...XJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...CX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},T,Promise.all(v.map(_=>WD(_))),WD(N),tee(U,R),Promise.allSettled(C),Promise.allSettled(D)])}},LMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),$Me=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wi(o,{checkOpen:!1})&&!bi(o)).map(({type:i,value:o,stream:s=o})=>u_(s,n,e,{isSameDirection:Vn.has(i),stopOnExit:i==="native"}))),UMe=async(t,{signal:e})=>{let[r]=await DMe(t,"error",{signal:e});throw r};var nee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),d_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=lo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Qd=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as FMe}from"stream";import{callbackify as BMe}from"util";import{finished as iee}from"stream/promises";var ZD=async t=>{if(t!==void 0)try{await JD(t)}catch{}},oee=async t=>{if(t!==void 0)try{await XD(t)}catch{}},JD=async t=>{await iee(t,{cleanup:!0,readable:!1,writable:!0})},XD=async t=>{await iee(t,{cleanup:!0,readable:!0,writable:!1})},Lx=async(t,e)=>{if(await t,e)throw e},$x=(t,e,r)=>{r&&!Dx(r)?t.destroy(r):e&&t.destroy()};var see=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eL(a,s),{read:f,onStdoutDataDone:p}=tL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new FMe({read:f,destroy:BMe(nL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QD=(t,e,r)=>{let n=Vd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:HD},tL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=lo(),s=Mx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){jMe(this,s,o)},onStdoutDataDone:o}},jMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await XD(t),await n,await ZD(i),await e,r.readable&&r.push(null)}catch(o){await ZD(i),aee(r,o)}},nL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(aee(t,n),await Lx(e,n))},aee=(t,e)=>{$x(t,t.readable,e)};import{Writable as zMe}from"stream";import{callbackify as cee}from"util";var lee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=iL(t,r,e),s=new zMe({...oL(n,t,i),destroy:cee(aL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sL(n,s),s},iL=(t,e,r)=>{let n=XT(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},oL=(t,e,r)=>({write:GMe.bind(void 0,t),final:cee(qMe.bind(void 0,t,e,r))}),GMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},qMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},sL=async(t,e,r)=>{try{await JD(t),e.writable&&e.end()}catch(n){await oee(r),uee(e,n)}},aL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(uee(t,i),await Lx(e,i))},uee=(t,e)=>{$x(t,t.writable,e)};import{Duplex as VMe}from"stream";import{callbackify as HMe}from"util";var dee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=QD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eL(c,a),{read:y,onStdoutDataDone:S}=tL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new VMe({read:y,...oL(u,t,d),destroy:HMe(WMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return rL({subprocessStdout:c,onStdoutDataDone:S,readable:T,subprocess:t,subprocessStdin:u}),sL(u,T,c),T},WMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),aL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var cL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=Vd(t,r),a=Mx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return YMe(a,s,t)},YMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fee=(t,{encoding:e})=>{let r=nee();t.readable=see.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cL.bind(void 0,t,e),t[Symbol.asyncIterator]=cL.bind(void 0,t,e,{})};var pee=(t,e)=>{for(let[r,n]of ZMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},KMe=(async()=>{})().constructor.prototype,ZMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(KMe,t)]);var hee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=QMe(t,e,r),{subprocess:f,promise:p}=tDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pee(f,p),uo.set(f,{options:u,fileDescriptors:d}),f},QMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),{file:a,commandArguments:c,options:l}=lx(t,e,r),u=eDe(l),d=w7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eDe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},tDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=XMe(...ux(t,e,r))}catch(h){return v7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;JMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];M7(c,a,l),L7(c,r,l);let d={},f=lo();c.kill=ZJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z7(c,r),fee(c,r),y7(c,r);let p=rDe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},rDe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,y]=await ree({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,N)=>ms(v,e,N)),T=ms(m,e,"all"),x=nDe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:T,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(x,n,e)},nDe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?o_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):yx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,iDe(n,t[n],i)]));return{...t,...r}},iDe=(t,e,r)=>oDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,oDe=new Set(["env",...UM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>sDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},sDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Ux(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=aDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?f7(a,c,l):hee(a,c,l,i)},aDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=w9(e)?A9(e,r):[e,...r],[s,a,c]=NT(...o),l=Ux(Ux(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var mee=({file:t,commandArguments:e})=>_ee(t,e),gee=({file:t,commandArguments:e})=>({..._ee(t,e),isSync:!0}),_ee=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=cDe(t);return{file:r,commandArguments:n}},cDe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(lDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},lDe=/ +/g;var yee=(t,e,r)=>{t.sync=e(uDe,r),t.s=t.sync},See=({options:t})=>Eee(t),uDe=({options:t})=>({...Eee(t),isSync:!0}),Eee=t=>({options:{...dDe(t),...t}}),dDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vee={preferLocal:!0};var bee=Oa(()=>({})),Agt=Oa(()=>({isSync:!0})),Tee=Oa(mee),Rgt=Oa(gee),Igt=Oa(kX),Cgt=Oa(See,{},vee,yee),{sendMessage:Pgt,getOneMessage:Ogt,getEachMessage:Ngt,getCancelSignal:kgt}=S7();var xee=!1,wee=()=>{xee=!0},ho=()=>xee;var f_=null,Aee=t=>(f_&&f_.destroy(),f_=new gs({totalAllowedTime:t}),f_),Ree=()=>f_;var gs=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ho())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await wT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Iee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.6",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var mDe=pDe(import.meta.url),gDe=_s.dirname(mDe),_De=hDe(import.meta.url),ef=ye("shell"),lL=new Set,Cee={preferLocal:!0},Nr=(t,e,r)=>{let[n,i]=yDe(e,r),o={...Cee,...i},s=bee(t,n,o);Oee(s,o),Mee(s);let a=r?.idleTimeout;return a&&a>0&&kee(s,a),s},Pee=(t,e)=>{let r={...Cee,...e},n=Tee(t,r);return Oee(n,r),Mee(n),e?.idleTimeout&&e.idleTimeout>0&&kee(n,e.idleTimeout),n},yDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Oee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(ys.stdout),t.stderr?.pipe(new zg).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},uL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),ef.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ef.error("Error killing process:",r),!1}},Nee=t=>uL(t,"SIGKILL"),kee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),Nee(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Mee=t=>{lL.add(t);let e=Ree();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),Nee(t))},5e3)});t.on("exit",()=>{lL.delete(t),r()}),t.on("error",()=>{lL.delete(t),r()})}};function mo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=_De.resolve(Iee.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Fx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Fx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Fx.existsSync(r))return r;let n=_s.join(gDe,"..","node_modules",".bin",e);if(Fx.existsSync(n))return n}var SDe=ye("utils"),EDe=t=>new Promise(e=>{setTimeout(e,t)});var Bx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await EDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Na=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Dee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):SDe.error("Could not parse JSON",n))}},vDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():vDe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var jx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Lee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var dL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},bDe=1e4,fL=(t,e=bDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as $ee}from"buffer";import TDe from"path";var Uee=ye("repo"),Yr=(t,e={})=>Nr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Uee.info("Getting runner diffs");let n=await wDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=RDe(o);await IDe(m,r)}Uee.info("Changes after processing"),await hL(r);let s=await gL(o,r);if(await pL(s,r),i=await ADe(r),!i)return{hasChanges:!1,ignored:s};await Yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Fee(r),{hasChanges:!1,ignored:s};let u=await Yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Yr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=$ee.from(S).toString("base64"))}await Fee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=$ee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Fee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Yr(["reset","--soft","HEAD~1"],{cwd:t})},pL=async(t=[],e=process.cwd())=>{await Yr(["add",".",...t],{cwd:e})},hL=async(t=process.cwd())=>{let e=await Yr(["status","-s"],{cwd:t});return String(e.stdout??"")},Bee=/.. (.+)?\.log$/,xDe=[Bee],wDe=async(t=process.cwd())=>{let e=await hL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as PNe}from"buffer";import{StringDecoder as ONe}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:NNe.bind(void 0,new TextEncoder)};let n=new ONe(e);return{transform:kNe.bind(void 0,n),final:MNe.bind(void 0,n)}},NNe=function*(t,e){PNe.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},kNe=function*(t,e){yield jt(e)?t.write(e):e},MNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZQ}from"util";var AD=ZQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LNe}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},JQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DNe(r,Number(e),t)},DNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},XQ=ZQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LNe=function*(t){yield t};var RD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...s_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},UNe=function*(t){yield t};var ID=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=t7(t,s,o),l=Tl(e),u=Tl(r),d=l?AD.bind(void 0,wx,a):RD.bind(void 0,xl),f=l||u?AD.bind(void 0,JQ,a):RD.bind(void 0,s_),p=l||u?XQ.bind(void 0,a):void 0;return{stream:new FNe({writableObjectMode:n,writableHighWaterMark:e7(n),readableObjectMode:i,readableHighWaterMark:e7(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Ax=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=t7(s,r,a);t=QQ(c,t)}return t},t7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:WQ(n,a)},xx(r,s,n),Tx(r,o,n,c),{transform:t,final:e},{transform:YQ(i,a)},HQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var r7=(t,e)=>{for(let r of BNe(t))jNe(t,r,e)},BNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jNe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Pa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>zNe(a,n));r.input=Zg(s)},zNe=(t,e)=>{let r=Ax(t,e,"utf8",!0);return GNe(r),Zg(r)},GNe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as WNe,appendFileSync as YNe}from"fs";var Rx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!_n.has(e)&&qNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&VNe.has(o))||t.every(({type:i})=>Vn.has(i))),qNe=t=>t===1||t===2,VNe=new Set(["pipe","overlapped"]),n7=async(t,e,r,n)=>{for await(let i of t)HNe(e)||o7(i,r,n)},i7=(t,e,r)=>{for(let n of t)o7(n,e,r)},HNe=t=>t._readableState.pipes.length>0,o7=(t,e,r)=>{let n=jT(t);co({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s7=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>KNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},KNe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=aQ(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=ZNe([p],h,c,n),{serializedResult:S,finalResult:T=S}=JNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});XNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&QNe(S,h,i),x}catch(v){return n.error=v,x}},ZNe=(t,e,r,n)=>{try{return Ax(t,e,r,!1)}catch(i){return n.error=i,t}},JNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Zg(t)};let s=v9(t,r);return n[o]?{serializedResult:s,finalResult:wD(s,!i[o],e)}:{serializedResult:s}},XNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Rx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=wD(t,!1,s);try{i7(a,e,n)}catch(c){r.error??=c}},QNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?YNe(n,t):(r.add(o),WNe(n,t))}};var a7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?MM([t,e]):`${t}${e}`};import{once as CD}from"events";var c7=async(t,e)=>{let[r,n]=await eke(t);return e.isForcefullyTerminated??=!1,[r,n]},eke=async t=>{let[e,r]=await Promise.allSettled([CD(t,"spawn"),CD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l7(t):r.value},l7=async t=>{try{return await CD(t,"exit")}catch{return l7(t)}},u7=async t=>{let[e,r]=await t;if(!tke(e,r)&&PD(e,r))throw new Ti;return[e,r]},tke=(t,e)=>t===void 0&&e===void 0,PD=(t,e)=>t!==0||e!==null;var d7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=rke(t,e,r),s=o?.code==="ETIMEDOUT",a=sQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},rke=(t,e,r)=>t!==void 0?t:PD(e,r)?new Ti:void 0;var f7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=ike(t,e,r),d=ake({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},ike=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),a=oke(r),{file:c,commandArguments:l,options:u}=lx(t,e,a);ske(u);let d=zQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ske=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ake=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=cke({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=d7(c,r),{output:h,error:m=l}=s7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((T,x)=>ms(T,r,x)),S=ms(a7(h,r),r,"all");return uke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},cke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{r7(o,r);let a=lke(r);return nke(...ux(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},lke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_x(e)}),uke=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?yx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):o_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as JMe}from"events";import{spawn as XMe}from"child_process";import _7 from"process";import{once as OD,on as dke}from"events";var p7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),fke({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),fke=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([pke(o,n,s),hke(o,r,s),mke(o,r,s)])}catch(a){throw qd(t),a}finally{s.abort(),ex(e,i)}},pke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await OD(t,"message",{signal:r});return n}for await(let[n]of dke(t,"message",{signal:r}))if(e(n))return n},hke=async(t,e,{signal:r})=>{await OD(t,"disconnect",{signal:r}),QJ(e)},mke=async(t,e,{signal:r})=>{let[n]=await OD(t,"strict:error",{signal:r});throw ZT(n,e)};import{once as m7,on as gke}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ND({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ND=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),QT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return _ke(t,s,a),yke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ske({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},_ke=async(t,e,r)=>{try{await m7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},yke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m7(t,"strict:error",{signal:r.signal});n.error=ZT(i,e),r.abort()}catch{}},Ske=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of gke(r,"message",{signal:o.signal}))h7(s),yield c}catch{h7(s)}finally{o.abort(),ex(e,a),n||qd(t),i&&await t}},h7=({error:t})=>{if(t)throw t};var y7=(t,{ipc:e})=>{Object.assign(t,E7(t,!1,e))},S7=()=>{let t=_7,e=!0,r=_7.channel!==void 0;return{...E7(t,e,r),getCancelSignal:AX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E7=(t,e,r)=>({sendMessage:ax.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Eke}from"child_process";import{PassThrough as vke,Readable as bke,Writable as Tke,Duplex as xke}from"stream";var v7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{bD(n);let a=new Eke;wke(a,n),Object.assign(a,{readable:Ake,writable:Rke,duplex:Ike});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Cke(c,s,i);return{subprocess:a,promise:l}},wke=(t,e)=>{let r=a_(),n=a_(),i=a_(),o=Array.from({length:e.length-3},a_),s=a_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},a_=()=>{let t=new vke;return t.end(),t},Ake=()=>new bke({read(){}}),Rke=()=>new Tke({write(){}}),Ike=()=>new xke({read(){},write(){}}),Cke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as b7,createWriteStream as T7}from"fs";import{Buffer as Pke}from"buffer";import{Readable as c_,Writable as Oke,Duplex as Nke}from"stream";var w7=(t,e)=>bx(kke,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},x7={fileNumber:l_,generator:ID,asyncGenerator:ID,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Nke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},kke={input:{...x7,fileUrl:({value:t})=>({stream:b7(t)}),filePath:({value:{file:t}})=>({stream:b7(t)}),webStream:({value:t})=>({stream:c_.fromWeb(t)}),iterable:({value:t})=>({stream:c_.from(t)}),asyncIterable:({value:t})=>({stream:c_.from(t)}),string:({value:t})=>({stream:c_.from(t)}),uint8Array:({value:t})=>({stream:c_.from(Pke.from(t))})},output:{...x7,fileUrl:({value:t})=>({stream:T7(t)}),filePath:({value:{file:t,append:e}})=>({stream:T7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Oke.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as Mke,once as A7}from"events";import{PassThrough as Dke,getDefaultHighWaterMark as Lke}from"stream";import{finished as C7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)MD(i);let e=t.some(({readableObjectMode:i})=>i),r=$ke(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $ke=(t,e)=>{if(t.length===0)return Lke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends Dke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(MD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Uke(this,this.#e,this.#o);let r=jke({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(MD(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Uke=async(t,e,r)=>{Cx(t,R7);let n=new AbortController;try{await Promise.race([Fke(t,n),Bke(t,e,r,n)])}finally{n.abort(),Cx(t,-R7)}},Fke=async(t,{signal:e})=>{try{await C7(t,{signal:e,cleanup:!0})}catch(r){throw P7(t,r),r}},Bke=async(t,e,r,{signal:n})=>{for await(let[i]of Mke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},MD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Cx(t,I7);let a=new AbortController;try{await Promise.race([zke(o,e,a),Gke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),qke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Cx(t,-I7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DD(t):Vke(t))},zke=async(t,e,{signal:r})=>{try{await t,r.aborted||DD(e)}catch(n){r.aborted||P7(e,n)}},Gke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await C7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;O7(s)?i.add(e):N7(t,s)}},qke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await A7(t,i,{signal:o}),!t.readable)return A7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Vke=t=>{t.writable&&t.end()},P7=(t,e)=>{O7(e)?DD(t):N7(t,e)},O7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DD=t=>{(t.readable||t.writable)&&t.destroy()},N7=(t,e)=>{t.destroyed||(t.once("error",Hke),t.destroy(e))},Hke=()=>{},Cx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},R7=2,I7=1;import{finished as k7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),Wke(t,e),Yke(t,e)},Wke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}LD(e)}},LD=t=>{t.writable&&t.end()},Yke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$D(t)}},$D=t=>{t.readable&&t.destroy()};var M7=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Vn.has(c)))Kke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vn.has(c)))Jke({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:wl(o);Xd(s,i)}},Kke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Zke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Zke=["stdin","stdout","stderr"],Jke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Xke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Xke=(t,{signal:e})=>{bi(t)&&vl(t,Qke,e)},Qke=2;import{addAbortListener as rMe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Px=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",UD=Symbol.for("signal-exit emitter"),FD=globalThis,eMe=Object.defineProperty.bind(Object),BD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(FD[UD])return FD[UD];eMe(FD,UD,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Ox=class{},tMe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),jD=class extends Ox{onExit(){return()=>{}}load(){}unload(){}},zD=class extends Ox{#e=GD.platform==="win32"?"SIGINT":"SIGHUP";#r=new BD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!Px(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Al)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Al.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return Px(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&Px(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},GD=globalThis.process,{onExit:D7,load:Lpt,unload:$pt}=tMe(Px(GD)?new zD(GD):new jD);var L7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D7(()=>{t.kill()});rMe(n,()=>{i()})};var U7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=zT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=nMe(r,n,i),{sourceStream:d,sourceError:f}=oMe(t,l),{options:p,fileDescriptors:h}=uo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},nMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=iMe(t,e,...r),a=XT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},iMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||NM(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=NT(r,...n);return{destination:e($7)(i,o,s),pipeOptions:s}}if(uo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},$7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),oMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var B7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=sMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},sMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $D(t),n;if(e!==void 0)return LD(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:F7,escapedCommand:F7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F7="source.pipe(destination)";var j7=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as aMe}from"stream/promises";var z7=(t,e,r)=>{let n=Nx.has(e)?lMe(t,e):cMe(t,e);return vl(t,dMe,r.signal),vl(e,fMe,r.signal),uMe(e),n},cMe=(t,e)=>{let r=wl([t]);return Xd(r,e),Nx.set(e,r),r},lMe=(t,e)=>{let r=Nx.get(e);return r.add(t),r},uMe=async t=>{try{await aMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Nx.delete(t)},Nx=new WeakMap,dMe=2,fMe=1;import{aborted as pMe}from"util";var G7=(t,e)=>t===void 0?[]:[hMe(t,e)],hMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await pMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw qD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kx=(t,...e)=>{if(Ct(e[0]))return kx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U7(t,...e),i=mMe({...n,destination:r});return i.pipe=kx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},mMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=gMe(t,i);B7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z7(e,o,d);return await Promise.race([j7(u),...G7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},gMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as TMe}from"timers/promises";import{on as _Me}from"events";import{getDefaultHighWaterMark as yMe}from"stream";var Mx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return SMe(e,s),V7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},SMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;EMe(e,s,t);let a=t.readableObjectMode&&!o;return V7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},EMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=_Me(t,"data",{signal:e.signal,highWaterMark:q7,highWatermark:q7});return vMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},HD=yMe(!0),q7=HD,vMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=bMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*s_(a)}},bMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Tx(t,i,!n,{})].filter(Boolean);var H7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=xMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([wMe(t),d]);return}let f=TD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([AMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},xMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Rx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n7(a,t,r,o)},wMe=async t=>{await TMe(),t.readableFlowing===null&&t.resume()},AMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return W7(nQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},WD=async t=>{try{return await t}catch(e){return W7(e)}},W7=({bufferedData:t})=>S9(t)?new Uint8Array(t):t;import{finished as RMe}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=IMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],RMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||OMe(a,e,r,n)}finally{s.abort()}},IMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&CMe(t,r,n),n},CMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{PMe(e,r),n.call(t,...i)}},PMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},OMe=(t,e,r,n)=>{if(!NMe(t,e,r,n))throw t},NMe=(t,e,r,n=!0)=>r.propagating?Y7(t)||Dx(t):(r.propagating=!0,YD(r,e)===n?Y7(t):Dx(t)),YD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Dx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y7=t=>t?.code==="EPIPE";var K7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>KD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),KD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=u_(t,e,l);if(YD(l,e)){await u;return}let[d]=await Promise.all([H7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,J7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>KD({...kMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:MMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),kMe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},MMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as DMe}from"events";var X7=t=>Bd(t,"ipc"),Q7=(t,e)=>{let r=jT(t);co({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=X7(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of ND({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iQ(t,i,c),i.push(l)),s&&Q7(l,o);return i},tee=async(t,e)=>(await Promise.allSettled([t]),e);var ree=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:y,controller:S})=>{let T=c7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=K7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=J7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],U=eee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=LMe(m,t,x),D=$Me(h,x);try{return await Promise.race([Promise.all([{},u7(T),Promise.all(v),N,U,LX(t,d),...C,...D]),y,UMe(t,S),...OX(t,o,f,S),...XJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...CX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},T,Promise.all(v.map(_=>WD(_))),WD(N),tee(U,R),Promise.allSettled(C),Promise.allSettled(D)])}},LMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),$Me=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wi(o,{checkOpen:!1})&&!bi(o)).map(({type:i,value:o,stream:s=o})=>u_(s,n,e,{isSameDirection:Vn.has(i),stopOnExit:i==="native"}))),UMe=async(t,{signal:e})=>{let[r]=await DMe(t,"error",{signal:e});throw r};var nee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),d_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=lo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Qd=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as FMe}from"stream";import{callbackify as BMe}from"util";import{finished as iee}from"stream/promises";var ZD=async t=>{if(t!==void 0)try{await JD(t)}catch{}},oee=async t=>{if(t!==void 0)try{await XD(t)}catch{}},JD=async t=>{await iee(t,{cleanup:!0,readable:!1,writable:!0})},XD=async t=>{await iee(t,{cleanup:!0,readable:!0,writable:!1})},Lx=async(t,e)=>{if(await t,e)throw e},$x=(t,e,r)=>{r&&!Dx(r)?t.destroy(r):e&&t.destroy()};var see=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eL(a,s),{read:f,onStdoutDataDone:p}=tL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new FMe({read:f,destroy:BMe(nL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QD=(t,e,r)=>{let n=Vd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:HD},tL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=lo(),s=Mx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){jMe(this,s,o)},onStdoutDataDone:o}},jMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await XD(t),await n,await ZD(i),await e,r.readable&&r.push(null)}catch(o){await ZD(i),aee(r,o)}},nL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(aee(t,n),await Lx(e,n))},aee=(t,e)=>{$x(t,t.readable,e)};import{Writable as zMe}from"stream";import{callbackify as cee}from"util";var lee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=iL(t,r,e),s=new zMe({...oL(n,t,i),destroy:cee(aL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sL(n,s),s},iL=(t,e,r)=>{let n=XT(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},oL=(t,e,r)=>({write:GMe.bind(void 0,t),final:cee(qMe.bind(void 0,t,e,r))}),GMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},qMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},sL=async(t,e,r)=>{try{await JD(t),e.writable&&e.end()}catch(n){await oee(r),uee(e,n)}},aL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(uee(t,i),await Lx(e,i))},uee=(t,e)=>{$x(t,t.writable,e)};import{Duplex as VMe}from"stream";import{callbackify as HMe}from"util";var dee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=QD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eL(c,a),{read:y,onStdoutDataDone:S}=tL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new VMe({read:y,...oL(u,t,d),destroy:HMe(WMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return rL({subprocessStdout:c,onStdoutDataDone:S,readable:T,subprocess:t,subprocessStdin:u}),sL(u,T,c),T},WMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),aL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var cL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=Vd(t,r),a=Mx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return YMe(a,s,t)},YMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fee=(t,{encoding:e})=>{let r=nee();t.readable=see.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cL.bind(void 0,t,e),t[Symbol.asyncIterator]=cL.bind(void 0,t,e,{})};var pee=(t,e)=>{for(let[r,n]of ZMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},KMe=(async()=>{})().constructor.prototype,ZMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(KMe,t)]);var hee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=QMe(t,e,r),{subprocess:f,promise:p}=tDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pee(f,p),uo.set(f,{options:u,fileDescriptors:d}),f},QMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),{file:a,commandArguments:c,options:l}=lx(t,e,r),u=eDe(l),d=w7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eDe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},tDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=XMe(...ux(t,e,r))}catch(h){return v7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;JMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];M7(c,a,l),L7(c,r,l);let d={},f=lo();c.kill=ZJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z7(c,r),fee(c,r),y7(c,r);let p=rDe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},rDe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,y]=await ree({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,N)=>ms(v,e,N)),T=ms(m,e,"all"),x=nDe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:T,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(x,n,e)},nDe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?o_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):yx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,iDe(n,t[n],i)]));return{...t,...r}},iDe=(t,e,r)=>oDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,oDe=new Set(["env",...UM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>sDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},sDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Ux(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=aDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?f7(a,c,l):hee(a,c,l,i)},aDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=w9(e)?A9(e,r):[e,...r],[s,a,c]=NT(...o),l=Ux(Ux(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var mee=({file:t,commandArguments:e})=>_ee(t,e),gee=({file:t,commandArguments:e})=>({..._ee(t,e),isSync:!0}),_ee=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=cDe(t);return{file:r,commandArguments:n}},cDe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(lDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},lDe=/ +/g;var yee=(t,e,r)=>{t.sync=e(uDe,r),t.s=t.sync},See=({options:t})=>Eee(t),uDe=({options:t})=>({...Eee(t),isSync:!0}),Eee=t=>({options:{...dDe(t),...t}}),dDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vee={preferLocal:!0};var bee=Oa(()=>({})),Agt=Oa(()=>({isSync:!0})),Tee=Oa(mee),Rgt=Oa(gee),Igt=Oa(kX),Cgt=Oa(See,{},vee,yee),{sendMessage:Pgt,getOneMessage:Ogt,getEachMessage:Ngt,getCancelSignal:kgt}=S7();var xee=!1,wee=()=>{xee=!0},ho=()=>xee;var f_=null,Aee=t=>(f_&&f_.destroy(),f_=new gs({totalAllowedTime:t}),f_),Ree=()=>f_;var gs=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ho())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await wT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Iee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.7",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var mDe=pDe(import.meta.url),gDe=_s.dirname(mDe),_De=hDe(import.meta.url),ef=ye("shell"),lL=new Set,Cee={preferLocal:!0},Nr=(t,e,r)=>{let[n,i]=yDe(e,r),o={...Cee,...i},s=bee(t,n,o);Oee(s,o),Mee(s);let a=r?.idleTimeout;return a&&a>0&&kee(s,a),s},Pee=(t,e)=>{let r={...Cee,...e},n=Tee(t,r);return Oee(n,r),Mee(n),e?.idleTimeout&&e.idleTimeout>0&&kee(n,e.idleTimeout),n},yDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Oee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(ys.stdout),t.stderr?.pipe(new zg).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},uL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),ef.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ef.error("Error killing process:",r),!1}},Nee=t=>uL(t,"SIGKILL"),kee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),Nee(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Mee=t=>{lL.add(t);let e=Ree();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),Nee(t))},5e3)});t.on("exit",()=>{lL.delete(t),r()}),t.on("error",()=>{lL.delete(t),r()})}};function mo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=_De.resolve(Iee.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Fx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Fx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Fx.existsSync(r))return r;let n=_s.join(gDe,"..","node_modules",".bin",e);if(Fx.existsSync(n))return n}var SDe=ye("utils"),EDe=t=>new Promise(e=>{setTimeout(e,t)});var Bx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await EDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Na=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Dee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):SDe.error("Could not parse JSON",n))}},vDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():vDe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var jx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Lee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var dL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},bDe=1e4,fL=(t,e=bDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as $ee}from"buffer";import TDe from"path";var Uee=ye("repo"),Yr=(t,e={})=>Nr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Uee.info("Getting runner diffs");let n=await wDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=RDe(o);await IDe(m,r)}Uee.info("Changes after processing"),await hL(r);let s=await gL(o,r);if(await pL(s,r),i=await ADe(r),!i)return{hasChanges:!1,ignored:s};await Yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Fee(r),{hasChanges:!1,ignored:s};let u=await Yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Yr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=$ee.from(S).toString("base64"))}await Fee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=$ee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Fee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Yr(["reset","--soft","HEAD~1"],{cwd:t})},pL=async(t=[],e=process.cwd())=>{await Yr(["add",".",...t],{cwd:e})},hL=async(t=process.cwd())=>{let e=await Yr(["status","-s"],{cwd:t});return String(e.stdout??"")},Bee=/.. (.+)?\.log$/,xDe=[Bee],wDe=async(t=process.cwd())=>{let e=await hL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>xDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},ADe=async(t=process.cwd())=>{try{return await Yr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},mL=async(t=process.cwd())=>{let{stdout:e}=await Yr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},jee=async(t=process.cwd())=>{let{stdout:e}=await Yr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},gL=async(t,e=process.cwd())=>{t||=await hL(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
103
103
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${TDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Bee)?.[1];o&&n.push(`:!${o}.log`)}),n},_L=async(t=process.cwd())=>{await Yr(["reset","--hard","HEAD"],{cwd:t})},zee=async(t=process.cwd())=>{let e=await Yr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
104
104
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},RDe=t=>{let e=t.split(`
|
|
@@ -206,7 +206,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
206
206
|
|
|
207
207
|
`)}p.write("payload.value = newResult;"),p.write("return payload;");let T=p.compile();return(x,v)=>T(f,x,v)},o,s=Fl,a=!Ul.jitless,l=a&&n$.value,u=e.catchall,d;t._zod.parse=(f,p)=>{d??(d=n.value);let h=f.value;return s(h)?a&&l&&p?.async===!1&&p.jitless!==!0?(o||(o=i(e.shape)),f=o(f,p),u?fre([],h,f,p,d,t):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),f)}});function Zte(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;let i=t.filter(o=>!Va(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>Mr(s,n,Tt())))}),e)}var Z_=P("$ZodUnion",(t,e)=>{ke.init(t,e),ze(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),ze(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ze(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),ze(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>F_(i.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,s=[];for(let a of e.options){let c=a._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>Zte(a,n,t,i)):Zte(s,n,t,i)}});function Jte(t,e,r,n){let i=t.filter(o=>o.issues.length===0);return i.length===1?(e.value=i[0].value,e):(i.length===0?e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>Mr(s,n,Tt())))}):e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:[],inclusive:!1}),e)}var W1=P("$ZodXor",(t,e)=>{Z_.init(t,e),e.inclusive=!1;let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,s=[];for(let a of e.options){let c=a._zod.run({value:n.value,issues:[]},i);c instanceof Promise?(s.push(c),o=!0):s.push(c)}return o?Promise.all(s).then(a=>Jte(a,n,t,i)):Jte(s,n,t,i)}}),Y1=P("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Z_.init(t,e);let r=t._zod.parse;ze(t._zod,"propValues",()=>{let i={};for(let o of e.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,c]of Object.entries(s)){i[a]||(i[a]=new Set);for(let l of c)i[a].add(l)}}return i});let n=Mf(()=>{let i=e.options,o=new Map;for(let s of i){let a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});t._zod.parse=(i,o)=>{let s=i.value;if(!Fl(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;let a=n.value.get(s?.[e.discriminator]);return a?a._zod.run(i,o):e.unionFallback||o.direction==="backward"?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:s,path:[e.discriminator],inst:t}),i)}}),K1=P("$ZodIntersection",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{let i=r.value,o=e.left._zod.run({value:i,issues:[]},n),s=e.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([c,l])=>Xte(r,c,l)):Xte(r,o,s)}});function c1(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(qa(t)&&qa(e)){let r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(let o of n){let s=c1(t[o],e[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let i=t[n],o=e[n],s=c1(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Xte(t,e,r){let n=new Map,i;for(let a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let o=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&i&&t.issues.push({...i,keys:o}),Va(t))return t;let s=c1(e.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return t.value=s.data,t}var jw=P("$ZodTuple",(t,e)=>{ke.init(t,e);let r=e.items;t._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:t,expected:"tuple",code:"invalid_type"}),n;n.value=[];let s=[],a=Qte(r,"optin"),c=Qte(r,"optout");if(!e.rest){if(o.length<a)return n.issues.push({code:"too_small",minimum:a,inclusive:!0,input:o,inst:t,origin:"array"}),n;o.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:o,inst:t,origin:"array"})}let l=new Array(r.length);for(let u=0;u<r.length;u++){let d=r[u]._zod.run({value:o[u],issues:[]},i);d instanceof Promise?s.push(d.then(f=>{l[u]=f})):l[u]=d}if(e.rest){let u=r.length-1,d=o.slice(r.length);for(let f of d){u++;let p=e.rest._zod.run({value:f,issues:[]},i);p instanceof Promise?s.push(p.then(h=>ere(h,n,u))):ere(p,n,u)}}return s.length?Promise.all(s).then(()=>tre(l,n,r,o,c)):tre(l,n,r,o,c)}});function Qte(t,e){for(let r=t.length-1;r>=0;r--)if(t[r]._zod[e]!=="optional")return r+1;return 0}function ere(t,e,r){t.issues.length&&e.issues.push(...Zr(r,t.issues)),e.value[r]=t.value}function tre(t,e,r,n,i){for(let o=0;o<r.length;o++){let s=t[o],a=o<n.length;if(s.issues.length){if(!a&&o>=i){e.value.length=o;break}e.issues.push(...Zr(o,s.issues))}e.value[o]=s.value}for(let o=e.value.length-1;o>=n.length&&(r[o]._zod.optout==="optional"&&e.value[o]===void 0);o--)e.value.length=o;return e}var Z1=P("$ZodRecord",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!qa(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),r;let o=[],s=e.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let u=e.keyType._zod.run({value:l,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>Mr(p,n,Tt())),input:l,path:[l],inst:t});continue}let d=u.value,f=e.valueType._zod.run({value:i[l],issues:[]},n);f instanceof Promise?o.push(f.then(p=>{p.issues.length&&r.issues.push(...Zr(l,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...Zr(l,f.issues)),r.value[d]=f.value)}let c;for(let l in i)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(i)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Nw.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=i[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Mr(d,n,Tt())),input:a,path:[a],inst:t});continue}let u=e.valueType._zod.run({value:i[a],issues:[]},n);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Zr(a,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...Zr(a,u.issues)),r.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}}),J1=P("$ZodMap",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:t}),r;let o=[];r.value=new Map;for(let[s,a]of i){let c=e.keyType._zod.run({value:s,issues:[]},n),l=e.valueType._zod.run({value:a,issues:[]},n);c instanceof Promise||l instanceof Promise?o.push(Promise.all([c,l]).then(([u,d])=>{rre(u,d,r,s,i,t,n)})):rre(c,l,r,s,i,t,n)}return o.length?Promise.all(o).then(()=>r):r}});function rre(t,e,r,n,i,o,s){t.issues.length&&(B_.has(typeof n)?r.issues.push(...Zr(n,t.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:t.issues.map(a=>Mr(a,s,Tt()))})),e.issues.length&&(B_.has(typeof n)?r.issues.push(...Zr(n,e.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:e.issues.map(a=>Mr(a,s,Tt()))})),r.value.set(t.value,e.value)}var X1=P("$ZodSet",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:t,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let s of i){let a=e.valueType._zod.run({value:s,issues:[]},n);a instanceof Promise?o.push(a.then(c=>nre(c,r))):nre(a,r)}return o.length?Promise.all(o).then(()=>r):r}});function nre(t,e){t.issues.length&&e.issues.push(...t.issues),e.value.add(t.value)}var Q1=P("$ZodEnum",(t,e)=>{ke.init(t,e);let r=U_(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(i=>B_.has(typeof i)).map(i=>typeof i=="string"?Kn(i):i.toString()).join("|")})$`),t._zod.parse=(i,o)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:t}),i}}),eU=P("$ZodLiteral",(t,e)=>{if(ke.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Kn(n):n?Kn(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),n}}),tU=P("$ZodFile",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:t}),r}}),rU=P("$ZodTransform",(t,e)=>{ke.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ja(t.constructor.name);let i=e.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r.fallback=!0,r));if(i instanceof Promise)throw new Ai;return r.value=i,r.fallback=!0,r}});function ire(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var zw=P("$ZodOptional",(t,e)=>{ke.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ze(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ze(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${F_(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let i=r.value,o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>ire(s,i)):ire(o,i)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),nU=P("$ZodExactOptional",(t,e)=>{zw.init(t,e),ze(t._zod,"values",()=>e.innerType._zod.values),ze(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),iU=P("$ZodNullable",(t,e)=>{ke.init(t,e),ze(t._zod,"optin",()=>e.innerType._zod.optin),ze(t._zod,"optout",()=>e.innerType._zod.optout),ze(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${F_(r.source)}|null)$`):void 0}),ze(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),oU=P("$ZodDefault",(t,e)=>{ke.init(t,e),t._zod.optin="optional",ze(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>ore(o,e)):ore(i,e)}});function ore(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var sU=P("$ZodPrefault",(t,e)=>{ke.init(t,e),t._zod.optin="optional",ze(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),aU=P("$ZodNonOptional",(t,e)=>{ke.init(t,e),ze(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>sre(o,t)):sre(i,t)}});function sre(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var cU=P("$ZodSuccess",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ja("ZodSuccess");let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),lU=P("$ZodCatch",(t,e)=>{ke.init(t,e),t._zod.optin="optional",ze(t._zod,"optout",()=>e.innerType._zod.optout),ze(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>Mr(s,n,Tt()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>Mr(o,n,Tt()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),uU=P("$ZodNaN",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:t,expected:"nan",code:"invalid_type"}),r)}),Gw=P("$ZodPipe",(t,e)=>{ke.init(t,e),ze(t._zod,"values",()=>e.in._zod.values),ze(t._zod,"optin",()=>e.in._zod.optin),ze(t._zod,"optout",()=>e.out._zod.optout),ze(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=e.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Dw(s,e.in,n)):Dw(o,e.in,n)}let i=e.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Dw(o,e.out,n)):Dw(i,e.out,n)}});function Dw(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var J_=P("$ZodCodec",(t,e)=>{ke.init(t,e),ze(t._zod,"values",()=>e.in._zod.values),ze(t._zod,"optin",()=>e.in._zod.optin),ze(t._zod,"optout",()=>e.out._zod.optout),ze(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Lw(s,e,n)):Lw(o,e,n)}else{let o=e.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Lw(s,e,n)):Lw(o,e,n)}}});function Lw(t,e,r){if(t.issues.length)return t.aborted=!0,t;if((r.direction||"forward")==="forward"){let i=e.transform(t.value,t);return i instanceof Promise?i.then(o=>$w(t,o,e.out,r)):$w(t,i,e.out,r)}else{let i=e.reverseTransform(t.value,t);return i instanceof Promise?i.then(o=>$w(t,o,e.in,r)):$w(t,i,e.in,r)}}function $w(t,e,r,n){return t.issues.length?(t.aborted=!0,t):r._zod.run({value:e,issues:t.issues},n)}var dU=P("$ZodPreprocess",(t,e)=>{Gw.init(t,e)}),fU=P("$ZodReadonly",(t,e)=>{ke.init(t,e),ze(t._zod,"propValues",()=>e.innerType._zod.propValues),ze(t._zod,"values",()=>e.innerType._zod.values),ze(t._zod,"optin",()=>e.innerType?._zod?.optin),ze(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(are):are(i)}});function are(t){return t.value=Object.freeze(t.value),t}var pU=P("$ZodTemplateLiteral",(t,e)=>{ke.init(t,e);let r=[];for(let n of e.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let o=i.startsWith("^")?1:0,s=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(o,s))}else if(n===null||o$.has(typeof n))r.push(Kn(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);t._zod.pattern=new RegExp(`^${r.join("")}$`),t._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:t,expected:"string",code:"invalid_type"}),n):(t._zod.pattern.lastIndex=0,t._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:t,code:"invalid_format",format:e.format??"template_literal",pattern:t._zod.pattern.source}),n)}),hU=P("$ZodFunction",(t,e)=>(ke.init(t,e),t._def=e,t._zod.def=e,t.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let i=t._def.input?vw(t._def.input,n):n,o=Reflect.apply(r,this,i);return t._def.output?vw(t._def.output,o):o}},t.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=t._def.input?await bw(t._def.input,n):n,o=await Reflect.apply(r,this,i);return t._def.output?await bw(t._def.output,o):o}},t._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:t}),r):(t._def.output&&t._def.output._zod.def.type==="promise"?r.value=t.implementAsync(r.value):r.value=t.implement(r.value),r),t.input=(...r)=>{let n=t.constructor;return Array.isArray(r[0])?new n({type:"function",input:new jw({type:"tuple",items:r[0],rest:r[1]}),output:t._def.output}):new n({type:"function",input:r[0],output:t._def.output})},t.output=r=>{let n=t.constructor;return new n({type:"function",input:t._def.input,output:r})},t)),mU=P("$ZodPromise",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>e.innerType._zod.run({value:i,issues:[]},n))}),gU=P("$ZodLazy",(t,e)=>{ke.init(t,e),ze(t._zod,"innerType",()=>{let r=e;return r._cachedInner||(r._cachedInner=e.getter()),r._cachedInner}),ze(t._zod,"pattern",()=>t._zod.innerType?._zod?.pattern),ze(t._zod,"propValues",()=>t._zod.innerType?._zod?.propValues),ze(t._zod,"optin",()=>t._zod.innerType?._zod?.optin??void 0),ze(t._zod,"optout",()=>t._zod.innerType?._zod?.optout??void 0),t._zod.parse=(r,n)=>t._zod.innerType._zod.run(r,n)}),_U=P("$ZodCustom",(t,e)=>{ct.init(t,e),ke.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,i=e.fn(n);if(i instanceof Promise)return i.then(o=>cre(o,r,n,t));cre(i,r,n,t)}});function cre(t,e,r,n){if(!t){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),e.issues.push(Df(i))}}var Q_={};pr(Q_,{ar:()=>hre,az:()=>mre,be:()=>_re,bg:()=>yre,ca:()=>Sre,cs:()=>Ere,da:()=>vre,de:()=>bre,el:()=>Tre,en:()=>qw,eo:()=>xre,es:()=>wre,fa:()=>Are,fi:()=>Rre,fr:()=>Ire,frCA:()=>Cre,he:()=>Pre,hr:()=>Ore,hu:()=>Nre,hy:()=>Mre,id:()=>Dre,is:()=>Lre,it:()=>$re,ja:()=>Ure,ka:()=>Fre,kh:()=>Bre,km:()=>Vw,ko:()=>jre,lt:()=>Gre,mk:()=>qre,ms:()=>Vre,nl:()=>Hre,no:()=>Wre,ota:()=>Yre,pl:()=>Zre,ps:()=>Kre,pt:()=>Jre,ro:()=>Xre,ru:()=>ene,sl:()=>tne,sv:()=>rne,ta:()=>nne,th:()=>ine,tr:()=>one,ua:()=>sne,uk:()=>Hw,ur:()=>ane,uz:()=>cne,vi:()=>lne,yo:()=>fne,zhCN:()=>une,zhTW:()=>dne});var U$e=()=>{let t={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function e(i){return t[i]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${i.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return i.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${X(i.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${i.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${r[o.format]??i.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${B(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function hre(){return{localeError:U$e()}}var F$e=()=>{let t={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function e(i){return t[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${X(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function mre(){return{localeError:F$e()}}function gre(t,e,r,n){let i=Math.abs(t),o=i%10,s=i%100;return s>=11&&s<=19?n:o===1?e:o>=2&&o<=4?r:n}var B$e=()=>{let t={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function e(i){return t[i]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${X(i.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);if(s){let a=Number(i.maximum),c=gre(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${i.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);if(s){let a=Number(i.minimum),c=gre(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${i.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${B(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function _re(){return{localeError:B$e()}}var j$e=()=>{let t={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function e(i){return t[i]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${X(i.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${B(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function yre(){return{localeError:j$e()}}var z$e=()=>{let t={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function e(i){return t[i]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${X(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${B(i.values," o ")}`;case"too_big":{let o=i.inclusive?"com a m\xE0xim":"menys de",s=e(i.origin);return s?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${o} ${i.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"com a m\xEDnim":"m\xE9s de",s=e(i.origin);return s?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${o} ${i.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}};function Sre(){return{localeError:z$e()}}var G$e=()=>{let t={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function e(i){return t[i]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${X(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${B(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}};function Ere(){return{localeError:G$e()}}var q$e=()=>{let t={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function e(i){return t[i]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${X(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin),a=n[i.origin]??i.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${i.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin),a=n[i.origin]??i.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${i.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${B(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}};function vre(){return{localeError:q$e()}}var V$e=()=>{let t={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function e(i){return t[i]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${X(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ist`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ist`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${B(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}};function bre(){return{localeError:V$e()}}var H$e=()=>{let t={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function e(i){return t[i]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return typeof i.expected=="string"&&/^[A-Z]/.test(i.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${i.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":return i.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${X(i.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.minimum.toString()} ${s.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${o.prefix}"`:o.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${o.suffix}"`:o.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${o.includes}"`:o.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[o.format]??i.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${B(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function Tre(){return{localeError:H$e()}}var W$e=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(i){return t[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${X(i.values[0])}`:`Invalid option: expected one of ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Too big: expected ${i.origin??"value"} to have ${o}${i.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Too small: expected ${i.origin} to have ${o}${i.minimum.toString()} ${s.unit}`:`Too small: expected ${i.origin} to be ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(s=>`'${s}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function qw(){return{localeError:W$e()}}var Y$e=()=>{let t={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function e(i){return t[i]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${X(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${o}${i.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}};function xre(){return{localeError:Y$e()}}var K$e=()=>{let t={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function e(i){return t[i]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${X(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin),a=n[i.origin]??i.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${i.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin),a=n[i.origin]??i.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${i.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function wre(){return{localeError:K$e()}}var Z$e=()=>{let t={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function e(i){return t[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${X(i.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${B(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??i.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${B(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function Are(){return{localeError:Z$e()}}var J$e=()=>{let t={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function e(i){return t[i]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${X(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${i.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${i.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${B(i.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function Rre(){return{localeError:J$e()}}var X$e=()=>{let t={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(i){return t[i]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${X(i.values[0])} attendu`:`Option invalide : une valeur parmi ${B(i.values,"|")} attendue`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Trop grand : ${n[i.origin]??"valeur"} doit ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Trop petit : ${n[i.origin]??"valeur"} doit ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Trop petit : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${B(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function Ire(){return{localeError:X$e()}}var Q$e=()=>{let t={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(i){return t[i]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${X(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u2264":"<",s=e(i.origin);return s?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${o}${i.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u2265":">",s=e(i.origin);return s?`Trop petit : attendu que ${i.origin} ait ${o}${i.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${i.origin} soit ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${B(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function Cre(){return{localeError:Q$e()}}var e1e=()=>{let t={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},e={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?t[l]:void 0,n=l=>{let u=r(l);return u?u.label:l??t.unknown.label},i=l=>`\u05D4${n(l)}`,o=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=l=>l?e[l]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,d=c[u??""]??n(u),f=Q(l.input),p=c[f]??t[f]?.label??f;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${X(l.values[0])}`;let u=l.values.map(p=>X(p));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=s(l.origin),d=i(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let h=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${h}`}if(l.origin==="array"||l.origin==="set"){let h=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",m=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${h} \u05DC\u05D4\u05DB\u05D9\u05DC ${m}`.trim()}let f=l.inclusive?"<=":"<",p=o(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()}`}case"too_small":{let u=s(l.origin),d=i(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let h=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${h}`}if(l.origin==="array"||l.origin==="set"){let h=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let y=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${h} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`}let m=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${h} \u05DC\u05D4\u05DB\u05D9\u05DC ${m}`.trim()}let f=l.inclusive?">=":">",p=o(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=a[u.format],f=d?.label??u.format,h=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${f} \u05DC\u05D0 ${h}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${B(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${i(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function Pre(){return{localeError:e1e()}}var t1e=()=>{let t={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function e(i){return t[i]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},n={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${a}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${a}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${X(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin),a=n[i.origin]??i.origin;return s?`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${o}${i.maximum.toString()} ${s.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin),a=n[i.origin]??i.origin;return s?`Premalo: o\u010Dekivano da ${a} ima ${o}${i.minimum.toString()} ${s.unit}`:`Premalo: o\u010Dekivano da ${a} bude ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${r[o.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${B(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${n[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${n[i.origin]??i.origin}`;default:return"Neispravan unos"}}};function Ore(){return{localeError:t1e()}}var r1e=()=>{let t={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function e(i){return t[i]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${X(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${i.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${o}${i.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function Nre(){return{localeError:r1e()}}function kre(t,e,r){return Math.abs(t)===1?e:r}function jf(t){if(!t)return"";let e=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=t[t.length-1];return t+(e.includes(r)?"\u0576":"\u0568")}var n1e=()=>{let t={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function e(i){return t[i]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${i.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return i.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${X(i.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);if(s){let a=Number(i.maximum),c=kre(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${jf(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${jf(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);if(s){let a=Number(i.minimum),c=kre(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${jf(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${jf(i.origin)} \u056C\u056B\u0576\u056B ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??i.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${B(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${jf(i.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${jf(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function Mre(){return{localeError:n1e()}}var i1e=()=>{let t={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function e(i){return t[i]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${X(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${o}${i.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Terlalu kecil: diharapkan ${i.origin} memiliki ${o}${i.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}};function Dre(){return{localeError:i1e()}}var o1e=()=>{let t={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function e(i){return t[i]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${X(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${o}${i.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${o}${i.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${B(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}};function Lre(){return{localeError:o1e()}}var s1e=()=>{let t={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function e(i){return t[i]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${X(i.values[0])}`:`Opzione non valida: atteso uno tra ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Troppo grande: ${i.origin??"valore"} deve avere ${o}${i.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Troppo piccolo: ${i.origin} deve avere ${o}${i.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${i.origin} deve essere ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${r[o.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${B(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}};function $re(){return{localeError:s1e()}}var a1e=()=>{let t={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function e(i){return t[i]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${X(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${B(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=e(i.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=e(i.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${i.keys.length>1?"\u7FA4":""}: ${B(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function Ure(){return{localeError:a1e()}}var c1e=()=>{let t={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function e(i){return t[i]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},n={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${i.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return i.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${X(i.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${B(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${i.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${B(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function Fre(){return{localeError:c1e()}}var l1e=()=>{let t={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function e(i){return t[i]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},n={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${i.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return i.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X(i.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${B(i.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Vw(){return{localeError:l1e()}}function Bre(){return Vw()}var u1e=()=>{let t={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function e(i){return t[i]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${X(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${B(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${o}${s}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${o}${s}`}case"too_small":{let o=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${o}${s}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${B(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function jre(){return{localeError:u1e()}}var X_=t=>t.charAt(0).toUpperCase()+t.slice(1);function zre(t){let e=Math.abs(t),r=e%10,n=e%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}var d1e=()=>{let t={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function e(i,o,s,a){let c=t[i]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},n={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${X(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${B(i.values,"|")} pasirinkim\u0173`;case"too_big":{let o=n[i.origin]??i.origin,s=e(i.origin,zre(Number(i.maximum)),i.inclusive??!1,"smaller");if(s?.verb)return`${X_(o??i.origin??"reik\u0161m\u0117")} ${s.verb} ${i.maximum.toString()} ${s.unit??"element\u0173"}`;let a=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${X_(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.maximum.toString()} ${s?.unit}`}case"too_small":{let o=n[i.origin]??i.origin,s=e(i.origin,zre(Number(i.minimum)),i.inclusive??!1,"bigger");if(s?.verb)return`${X_(o??i.origin??"reik\u0161m\u0117")} ${s.verb} ${i.minimum.toString()} ${s.unit??"element\u0173"}`;let a=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${X_(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${B(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=n[i.origin]??i.origin;return`${X_(o??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function Gre(){return{localeError:d1e()}}var f1e=()=>{let t={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function e(i){return t[i]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${X(i.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${B(i.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function qre(){return{localeError:f1e()}}var p1e=()=>{let t={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function e(i){return t[i]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${X(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Terlalu besar: dijangka ${i.origin??"nilai"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Terlalu kecil: dijangka ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${B(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}};function Vre(){return{localeError:p1e()}}var h1e=()=>{let t={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function e(i){return t[i]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${X(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin),a=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} is`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin),a=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} is`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}};function Hre(){return{localeError:h1e()}}var m1e=()=>{let t={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function e(i){return t[i]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${X(i.values[0])}`:`Ugyldig valg: forventet en av ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${B(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}};function Wre(){return{localeError:m1e()}}var g1e=()=>{let t={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function e(i){return t[i]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${X(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=i;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function Yre(){return{localeError:g1e()}}var _1e=()=>{let t={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function e(i){return t[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${X(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${B(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${B(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function Kre(){return{localeError:_1e()}}var y1e=()=>{let t={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function e(i){return t[i]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${X(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function Zre(){return{localeError:y1e()}}var S1e=()=>{let t={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function e(i){return t[i]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${X(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${o}${i.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Muito pequeno: esperado que ${i.origin} tivesse ${o}${i.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${B(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}};function Jre(){return{localeError:S1e()}}var E1e=()=>{let t={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function e(i){return t[i]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},n={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${a}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${X(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Prea mic: a\u0219teptat ca ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${r[o.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${B(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}};function Xre(){return{localeError:E1e()}}function Qre(t,e,r,n){let i=Math.abs(t),o=i%10,s=i%100;return s>=11&&s<=19?n:o===1?e:o>=2&&o<=4?r:n}var v1e=()=>{let t={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function e(i){return t[i]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${X(i.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);if(s){let a=Number(i.maximum),c=Qre(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);if(s){let a=Number(i.minimum),c=Qre(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${B(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function ene(){return{localeError:v1e()}}var b1e=()=>{let t={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function e(i){return t[i]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${X(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${o}${i.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${o}${i.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${B(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}};function tne(){return{localeError:b1e()}}var T1e=()=>{let t={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function e(i){return t[i]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${X(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${B(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function rne(){return{localeError:T1e()}}var x1e=()=>{let t={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function e(i){return t[i]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${i.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return i.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X(i.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${B(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${o}${i.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${o}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function nne(){return{localeError:x1e()}}var w1e=()=>{let t={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function e(i){return t[i]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},n={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${i.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${X(i.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=e(i.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=e(i.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${i.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${B(i.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function ine(){return{localeError:w1e()}}var A1e=()=>{let t={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function e(i){return t[i]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${X(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function one(){return{localeError:A1e()}}var R1e=()=>{let t={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function e(i){return t[i]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${i.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${X(i.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${B(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${i.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function Hw(){return{localeError:R1e()}}function sne(){return Hw()}var I1e=()=>{let t={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function e(i){return t[i]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${X(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${B(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${o}${i.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${o}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${i.keys.length>1?"\u0632":""}: ${B(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function ane(){return{localeError:I1e()}}var C1e=()=>{let t={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function e(i){return t[i]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${X(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function cne(){return{localeError:C1e()}}var P1e=()=>{let t={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function e(i){return t[i]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${X(i.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??i.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${B(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function lne(){return{localeError:P1e()}}var O1e=()=>{let t={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function e(i){return t[i]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${X(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${B(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function une(){return{localeError:O1e()}}var N1e=()=>{let t={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function e(i){return t[i]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${X(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${B(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function dne(){return{localeError:N1e()}}var k1e=()=>{let t={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function e(i){return t[i]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=Q(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${X(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${B(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=e(i.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${s.verb} ${o}${i.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.maximum}`}case"too_small":{let o=i.inclusive?">=":">",s=e(i.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${s.verb} ${o}${i.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.minimum}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??i.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${B(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function fne(){return{localeError:k1e()}}var pne,yU=Symbol("ZodOutput"),SU=Symbol("ZodInput"),Ww=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Yw(){return new Ww}(pne=globalThis).__zod_globalRegistry??(pne.__zod_globalRegistry=Yw());var ur=globalThis.__zod_globalRegistry;function EU(t,e){return new t({type:"string",...se(e)})}function vU(t,e){return new t({type:"string",coerce:!0,...se(e)})}function Kw(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...se(e)})}function ey(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...se(e)})}function Zw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...se(e)})}function Jw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...se(e)})}function Xw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...se(e)})}function Qw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...se(e)})}function ty(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...se(e)})}function eA(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...se(e)})}function tA(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...se(e)})}function rA(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...se(e)})}function nA(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...se(e)})}function iA(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...se(e)})}function oA(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...se(e)})}function sA(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...se(e)})}function aA(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...se(e)})}function cA(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...se(e)})}function bU(t,e){return new t({type:"string",format:"mac",check:"string_format",abort:!1,...se(e)})}function lA(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...se(e)})}function uA(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...se(e)})}function dA(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...se(e)})}function fA(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...se(e)})}function pA(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...se(e)})}function hA(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...se(e)})}var TU={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function xU(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...se(e)})}function wU(t,e){return new t({type:"string",format:"date",check:"string_format",...se(e)})}function AU(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...se(e)})}function RU(t,e){return new t({type:"string",format:"duration",check:"string_format",...se(e)})}function IU(t,e){return new t({type:"number",checks:[],...se(e)})}function CU(t,e){return new t({type:"number",coerce:!0,checks:[],...se(e)})}function PU(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...se(e)})}function OU(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"float32",...se(e)})}function NU(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"float64",...se(e)})}function kU(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"int32",...se(e)})}function MU(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"uint32",...se(e)})}function DU(t,e){return new t({type:"boolean",...se(e)})}function LU(t,e){return new t({type:"boolean",coerce:!0,...se(e)})}function $U(t,e){return new t({type:"bigint",...se(e)})}function UU(t,e){return new t({type:"bigint",coerce:!0,...se(e)})}function FU(t,e){return new t({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...se(e)})}function BU(t,e){return new t({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...se(e)})}function jU(t,e){return new t({type:"symbol",...se(e)})}function zU(t,e){return new t({type:"undefined",...se(e)})}function GU(t,e){return new t({type:"null",...se(e)})}function qU(t){return new t({type:"any"})}function VU(t){return new t({type:"unknown"})}function HU(t,e){return new t({type:"never",...se(e)})}function WU(t,e){return new t({type:"void",...se(e)})}function YU(t,e){return new t({type:"date",...se(e)})}function KU(t,e){return new t({type:"date",coerce:!0,...se(e)})}function ZU(t,e){return new t({type:"nan",...se(e)})}function So(t,e){return new kw({check:"less_than",...se(e),value:t,inclusive:!1})}function bn(t,e){return new kw({check:"less_than",...se(e),value:t,inclusive:!0})}function Eo(t,e){return new Mw({check:"greater_than",...se(e),value:t,inclusive:!1})}function Dr(t,e){return new Mw({check:"greater_than",...se(e),value:t,inclusive:!0})}function mA(t){return Eo(0,t)}function gA(t){return So(0,t)}function _A(t){return bn(0,t)}function yA(t){return Dr(0,t)}function Ha(t,e){return new G$({check:"multiple_of",...se(e),value:t})}function Wa(t,e){return new H$({check:"max_size",...se(e),maximum:t})}function vo(t,e){return new W$({check:"min_size",...se(e),minimum:t})}function zl(t,e){return new Y$({check:"size_equals",...se(e),size:t})}function Gl(t,e){return new K$({check:"max_length",...se(e),maximum:t})}function Is(t,e){return new Z$({check:"min_length",...se(e),minimum:t})}function ql(t,e){return new J$({check:"length_equals",...se(e),length:t})}function zf(t,e){return new X$({check:"string_format",format:"regex",...se(e),pattern:t})}function Gf(t){return new Q$({check:"string_format",format:"lowercase",...se(t)})}function qf(t){return new e1({check:"string_format",format:"uppercase",...se(t)})}function Vf(t,e){return new t1({check:"string_format",format:"includes",...se(e),includes:t})}function Hf(t,e){return new r1({check:"string_format",format:"starts_with",...se(e),prefix:t})}function Wf(t,e){return new n1({check:"string_format",format:"ends_with",...se(e),suffix:t})}function SA(t,e,r){return new i1({check:"property",property:t,schema:e,...se(r)})}function Yf(t,e){return new o1({check:"mime_type",mime:t,...se(e)})}function Ri(t){return new s1({check:"overwrite",tx:t})}function Kf(t){return Ri(e=>e.normalize(t))}function Zf(){return Ri(t=>t.trim())}function Jf(){return Ri(t=>t.toLowerCase())}function Xf(){return Ri(t=>t.toUpperCase())}function Qf(){return Ri(t=>r$(t))}function JU(t,e,r){return new t({type:"array",element:e,...se(r)})}function D1e(t,e,r){return new t({type:"union",options:e,...se(r)})}function L1e(t,e,r){return new t({type:"union",options:e,inclusive:!1,...se(r)})}function $1e(t,e,r,n){return new t({type:"union",options:r,discriminator:e,...se(n)})}function U1e(t,e,r){return new t({type:"intersection",left:e,right:r})}function F1e(t,e,r,n){let i=r instanceof ke,o=i?n:r,s=i?r:null;return new t({type:"tuple",items:e,rest:s,...se(o)})}function B1e(t,e,r,n){return new t({type:"record",keyType:e,valueType:r,...se(n)})}function j1e(t,e,r,n){return new t({type:"map",keyType:e,valueType:r,...se(n)})}function z1e(t,e,r){return new t({type:"set",valueType:e,...se(r)})}function G1e(t,e,r){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new t({type:"enum",entries:n,...se(r)})}function q1e(t,e,r){return new t({type:"enum",entries:e,...se(r)})}function V1e(t,e,r){return new t({type:"literal",values:Array.isArray(e)?e:[e],...se(r)})}function XU(t,e){return new t({type:"file",...se(e)})}function H1e(t,e){return new t({type:"transform",transform:e})}function W1e(t,e){return new t({type:"optional",innerType:e})}function Y1e(t,e){return new t({type:"nullable",innerType:e})}function K1e(t,e,r){return new t({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():i$(r)}})}function Z1e(t,e,r){return new t({type:"nonoptional",innerType:e,...se(r)})}function J1e(t,e){return new t({type:"success",innerType:e})}function X1e(t,e,r){return new t({type:"catch",innerType:e,catchValue:typeof r=="function"?r:()=>r})}function Q1e(t,e,r){return new t({type:"pipe",in:e,out:r})}function eUe(t,e){return new t({type:"readonly",innerType:e})}function tUe(t,e,r){return new t({type:"template_literal",parts:e,...se(r)})}function rUe(t,e){return new t({type:"lazy",getter:e})}function nUe(t,e){return new t({type:"promise",innerType:e})}function QU(t,e,r){let n=se(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function eF(t,e,r){return new t({type:"custom",check:"custom",fn:e,...se(r)})}function tF(t,e){let r=hne(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(Df(i,n.value,r._zod.def));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(Df(o))}},t(n.value,n)),e);return r}function hne(t,e){let r=new ct({check:"custom",...se(e)});return r._zod.check=t,r}function rF(t){let e=new ct({check:"describe"});return e._zod.onattach=[r=>{let n=ur.get(r)??{};ur.add(r,{...n,description:t})}],e._zod.check=()=>{},e}function nF(t){let e=new ct({check:"meta"});return e._zod.onattach=[r=>{let n=ur.get(r)??{};ur.add(r,{...n,...t})}],e._zod.check=()=>{},e}function iF(t,e){let r=se(e),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(p=>typeof p=="string"?p.toLowerCase():p),i=i.map(p=>typeof p=="string"?p.toLowerCase():p));let o=new Set(n),s=new Set(i),a=t.Codec??J_,c=t.Boolean??K_,l=t.String??jl,u=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new a({type:"pipe",in:u,out:d,transform:((p,h)=>{let m=p;return r.case!=="sensitive"&&(m=m.toLowerCase()),o.has(m)?!0:s.has(m)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:h.value,inst:f,continue:!1}),{})}),reverseTransform:((p,h)=>p===!0?n[0]||"true":i[0]||"false"),error:r.error});return f}function ep(t,e,r,n={}){let i=se(n),o={...se(n),check:"string_format",type:"string",format:e,fn:typeof r=="function"?r:a=>r.test(a),...i};return r instanceof RegExp&&(o.pattern=r),new t(o)}function Ya(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??ur,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function Ze(t,e,r={path:[],schemaPath:[]}){var n;let i=t._zod.def,o=e.seen.get(t);if(o)return o.count++,r.schemaPath.includes(t)&&(o.cycle=r.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,s);let a=t._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,s.schema,u);else{let f=s.schema,p=e.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(t,e,f,u)}let d=t._zod.parent;d&&(s.ref||(s.ref=d),Ze(d,e,u),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(s.schema,c),e.io==="input"&&Lr(t)&&(delete s.schema.examples,delete s.schema.default),e.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,e.seen.get(t).schema}function Ka(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let s of t.seen.entries()){let a=t.metadataRegistry.get(s[0])?.id;if(a){let c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}let i=s=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(s[0])?.id,f=t.external.uri??(h=>h);if(d)return{ref:f(d)};let p=s[1].defId??s[1].schema.id??`schema${t.counter++}`;return s[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};let l=`#/${a}/`,u=s[1].schema.id??`__schema${t.counter++}`;return{defId:u,ref:l+u}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=i(s);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(t.cycles==="throw")for(let s of t.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
208
208
|
|
|
209
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of t.seen.entries()){let a=s[1];if(e===s[0]){o(s);continue}if(t.external){let l=t.external.registry.get(s[0])?.id;if(e!==s[0]&&l){o(s);continue}}if(t.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&t.reused==="ref"){o(s);continue}}}function Za(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){n(d);let p=t.seen.get(d),h=p.schema;if(h.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(h)):Object.assign(l,h),Object.assign(l,u),a._zod.parent===d)for(let y in l)y==="$ref"||y==="allOf"||y in u||delete l[y];if(h.$ref&&p.def)for(let y in l)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(l[y])===JSON.stringify(p.def[y])&&delete l[y]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=t.seen.get(f);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let h in l)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(l[h])===JSON.stringify(p.def[h])&&delete l[h]}t.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(a)}Object.assign(i,r.def??r.schema);let o=t.metadataRegistry.get(e)?.id;o!==void 0&&i.id===o&&delete i.id;let s=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}t.external||Object.keys(s).length>0&&(t.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:tp(e,"input",t.processors),output:tp(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Lr(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Lr(n.element,r);if(n.type==="set")return Lr(n.valueType,r);if(n.type==="lazy")return Lr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Lr(n.innerType,r);if(n.type==="intersection")return Lr(n.left,r)||Lr(n.right,r);if(n.type==="record"||n.type==="map")return Lr(n.keyType,r)||Lr(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Lr(n.in,r)||Lr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(Lr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(Lr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(Lr(i,r))return!0;return!!(n.rest&&Lr(n.rest,r))}return!1}var oF=(t,e={})=>r=>{let n=Ya({...r,processors:e});return Ze(t,n),Ka(n,t),Za(n,t)},tp=(t,e,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},s=Ya({...i??{},target:o,io:e,processors:r});return Ze(t,s),Ka(s,t),Za(s,t)};var iUe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sF=(t,e,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:l}=t._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=iUe[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},aF=(t,e,r,n)=>{let i=r,{minimum:o,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";let d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),f=typeof l=="number"&&l<=(s??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof o=="number"&&(i.minimum=o),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof s=="number"&&(i.maximum=s),typeof c=="number"&&(i.multipleOf=c)},cF=(t,e,r,n)=>{r.type="boolean"},lF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},uF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},dF=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},fF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},pF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},hF=(t,e,r,n)=>{r.not={}},mF=(t,e,r,n)=>{},gF=(t,e,r,n)=>{},_F=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},yF=(t,e,r,n)=>{let i=t._zod.def,o=U_(i.entries);o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},SF=(t,e,r,n)=>{let i=t._zod.def,o=[];for(let s of i.values)if(s===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];r.type=s===null?"null":typeof s,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[s]:r.const=s}else o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),o.every(s=>typeof s=="boolean")&&(r.type="boolean"),o.every(s=>s===null)&&(r.type="null"),r.enum=o},EF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},vF=(t,e,r,n)=>{let i=r,o=t._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},bF=(t,e,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=t._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(i,o)},TF=(t,e,r,n)=>{r.type="boolean"},xF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},AF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},RF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},IF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},CF=(t,e,r,n)=>{let i=r,o=t._zod.def,{minimum:s,maximum:a}=t._zod.bag;typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ze(o.element,e,{...n,path:[...n.path,"items"]})},PF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="object",i.properties={};let s=o.shape;for(let l in s)i.properties[l]=Ze(s[l],e,{...n,path:[...n.path,"properties",l]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(l=>{let u=o.shape[l]._zod;return e.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Ze(o.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},vA=(t,e,r,n)=>{let i=t._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>Ze(a,e,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},OF=(t,e,r,n)=>{let i=t._zod.def,o=Ze(i.left,e,{...n,path:[...n.path,"allOf",0]}),s=Ze(i.right,e,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c},NF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="array";let s=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((f,p)=>Ze(f,e,{...n,path:[...n.path,s,p]})),l=o.rest?Ze(o.rest,e,{...n,path:[...n.path,a,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null;e.target==="draft-2020-12"?(i.prefixItems=c,l&&(i.items=l)):e.target==="openapi-3.0"?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=t._zod.bag;typeof u=="number"&&(i.minItems=u),typeof d=="number"&&(i.maxItems=d)},kF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="object";let s=o.keyType,c=s._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let u=Ze(o.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=Ze(o.keyType,e,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Ze(o.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let l=s._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(i.required=u)}},MF=(t,e,r,n)=>{let i=t._zod.def,o=Ze(i.innerType,e,n),s=e.seen.get(t);e.target==="openapi-3.0"?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},DF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},LF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},$F=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},UF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},FF=(t,e,r,n)=>{let i=t._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=e.io==="input"?o?i.out:i.in:i.out;Ze(s,e,n);let a=e.seen.get(t);a.ref=s},BF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,r.readOnly=!0},jF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},bA=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},zF=(t,e,r,n)=>{let i=t._zod.innerType;Ze(i,e,n);let o=e.seen.get(t);o.ref=i},EA={string:sF,number:aF,boolean:cF,bigint:lF,symbol:uF,null:dF,undefined:fF,void:pF,never:hF,any:mF,unknown:gF,date:_F,enum:yF,literal:SF,nan:EF,template_literal:vF,file:bF,success:TF,custom:xF,function:wF,transform:AF,map:RF,set:IF,array:CF,object:PF,union:vA,intersection:OF,tuple:NF,record:kF,nullable:MF,nonoptional:DF,default:LF,prefault:$F,catch:UF,pipe:FF,readonly:BF,promise:jF,optional:bA,lazy:zF};function TA(t,e){if("_idmap"in t){let n=t,i=Ya({...e,processors:EA}),o={};for(let c of n._idmap.entries()){let[l,u]=c;Ze(u,i)}let s={},a={registry:n,uri:e?.uri,defs:o};i.external=a;for(let c of n._idmap.entries()){let[l,u]=c;Ka(i,u),s[l]=Za(i,u)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=Ya({...e,processors:EA});return Ze(t,r),Ka(r,t),Za(r,t)}var xA=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Ya({processors:EA,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return Ze(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Ka(this.ctx,e);let n=Za(this.ctx,e),{"~standard":i,...o}=n;return o}};var mne={};var ry={};pr(ry,{ZodAny:()=>fB,ZodArray:()=>gB,ZodBase64:()=>VA,ZodBase64URL:()=>HA,ZodBigInt:()=>lp,ZodBigIntFormat:()=>KA,ZodBoolean:()=>cp,ZodCIDRv4:()=>GA,ZodCIDRv6:()=>qA,ZodCUID:()=>LA,ZodCUID2:()=>$A,ZodCatch:()=>UB,ZodCodec:()=>hy,ZodCustom:()=>my,ZodCustomStringFormat:()=>sp,ZodDate:()=>ly,ZodDefault:()=>NB,ZodDiscriminatedUnion:()=>yB,ZodE164:()=>WA,ZodEmail:()=>kA,ZodEmoji:()=>MA,ZodEnum:()=>ip,ZodExactOptional:()=>CB,ZodFile:()=>RB,ZodFunction:()=>YB,ZodGUID:()=>iy,ZodIPv4:()=>jA,ZodIPv6:()=>zA,ZodIntersection:()=>SB,ZodJWT:()=>YA,ZodKSUID:()=>BA,ZodLazy:()=>VB,ZodLiteral:()=>AB,ZodMAC:()=>oB,ZodMap:()=>xB,ZodNaN:()=>BB,ZodNanoID:()=>DA,ZodNever:()=>hB,ZodNonOptional:()=>tR,ZodNull:()=>uB,ZodNullable:()=>OB,ZodNumber:()=>ap,ZodNumberFormat:()=>Hl,ZodObject:()=>dy,ZodOptional:()=>eR,ZodPipe:()=>py,ZodPrefault:()=>MB,ZodPreprocess:()=>jB,ZodPromise:()=>WB,ZodReadonly:()=>zB,ZodRecord:()=>np,ZodSet:()=>wB,ZodString:()=>op,ZodStringFormat:()=>rt,ZodSuccess:()=>$B,ZodSymbol:()=>cB,ZodTemplateLiteral:()=>qB,ZodTransform:()=>IB,ZodTuple:()=>vB,ZodType:()=>$e,ZodULID:()=>UA,ZodURL:()=>cy,ZodUUID:()=>bo,ZodUndefined:()=>lB,ZodUnion:()=>fy,ZodUnknown:()=>pB,ZodVoid:()=>mB,ZodXID:()=>FA,ZodXor:()=>_B,_ZodString:()=>NA,_default:()=>kB,_function:()=>xie,any:()=>tie,array:()=>uy,base64:()=>Une,base64url:()=>Fne,bigint:()=>Zne,boolean:()=>aB,catch:()=>FB,check:()=>wie,cidrv4:()=>Lne,cidrv6:()=>$ne,codec:()=>Eie,cuid:()=>Ine,cuid2:()=>Cne,custom:()=>Aie,date:()=>nie,describe:()=>Rie,discriminatedUnion:()=>lie,e164:()=>Bne,email:()=>yne,emoji:()=>Ane,enum:()=>XA,exactOptional:()=>PB,file:()=>gie,float32:()=>Hne,float64:()=>Wne,function:()=>xie,guid:()=>Sne,hash:()=>Vne,hex:()=>qne,hostname:()=>Gne,httpUrl:()=>wne,instanceof:()=>Cie,int:()=>PA,int32:()=>Yne,int64:()=>Jne,intersection:()=>EB,invertCodec:()=>vie,ipv4:()=>kne,ipv6:()=>Dne,json:()=>Oie,jwt:()=>jne,keyof:()=>iie,ksuid:()=>Nne,lazy:()=>HB,literal:()=>mie,looseObject:()=>aie,looseRecord:()=>die,mac:()=>Mne,map:()=>fie,meta:()=>Iie,nan:()=>Sie,nanoid:()=>Rne,nativeEnum:()=>hie,never:()=>ZA,nonoptional:()=>LB,null:()=>dB,nullable:()=>sy,nullish:()=>_ie,number:()=>sB,object:()=>oie,optional:()=>oy,partialRecord:()=>uie,pipe:()=>OA,prefault:()=>DB,preprocess:()=>Nie,promise:()=>Tie,readonly:()=>GB,record:()=>TB,refine:()=>KB,set:()=>pie,strictObject:()=>sie,string:()=>ny,stringFormat:()=>zne,stringbool:()=>Pie,success:()=>yie,superRefine:()=>ZB,symbol:()=>Qne,templateLiteral:()=>bie,transform:()=>QA,tuple:()=>bB,uint32:()=>Kne,uint64:()=>Xne,ulid:()=>Pne,undefined:()=>eie,union:()=>JA,unknown:()=>Vl,url:()=>xne,uuid:()=>Ene,uuidv4:()=>vne,uuidv6:()=>bne,uuidv7:()=>Tne,void:()=>rie,xid:()=>One,xor:()=>cie});var wA={};pr(wA,{endsWith:()=>Wf,gt:()=>Eo,gte:()=>Dr,includes:()=>Vf,length:()=>ql,lowercase:()=>Gf,lt:()=>So,lte:()=>bn,maxLength:()=>Gl,maxSize:()=>Wa,mime:()=>Yf,minLength:()=>Is,minSize:()=>vo,multipleOf:()=>Ha,negative:()=>gA,nonnegative:()=>yA,nonpositive:()=>_A,normalize:()=>Kf,overwrite:()=>Ri,positive:()=>mA,property:()=>SA,regex:()=>zf,size:()=>zl,slugify:()=>Qf,startsWith:()=>Hf,toLowerCase:()=>Jf,toUpperCase:()=>Xf,trim:()=>Zf,uppercase:()=>qf});var rp={};pr(rp,{ZodISODate:()=>RA,ZodISODateTime:()=>AA,ZodISODuration:()=>CA,ZodISOTime:()=>IA,date:()=>qF,datetime:()=>GF,duration:()=>HF,time:()=>VF});var AA=P("ZodISODateTime",(t,e)=>{E1.init(t,e),rt.init(t,e)});function GF(t){return xU(AA,t)}var RA=P("ZodISODate",(t,e)=>{v1.init(t,e),rt.init(t,e)});function qF(t){return wU(RA,t)}var IA=P("ZodISOTime",(t,e)=>{b1.init(t,e),rt.init(t,e)});function VF(t){return AU(IA,t)}var CA=P("ZodISODuration",(t,e)=>{T1.init(t,e),rt.init(t,e)});function HF(t){return RU(CA,t)}var gne=(t,e)=>{G_.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>V_(t,r)},flatten:{value:r=>q_(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,kf,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,kf,2)}},isEmpty:{get(){return t.issues.length===0}}})},sUe=P("ZodError",gne),Xr=P("ZodError",gne,{Parent:Error});var WF=Lf(Xr),YF=$f(Xr),KF=Uf(Xr),ZF=Ff(Xr),JF=Tw(Xr),XF=xw(Xr),QF=ww(Xr),eB=Aw(Xr),tB=Rw(Xr),rB=Iw(Xr),nB=Cw(Xr),iB=Pw(Xr);var _ne=new WeakMap;function ay(t,e,r){let n=Object.getPrototypeOf(t),i=_ne.get(n);if(i||(i=new Set,_ne.set(n,i)),!i.has(e)){i.add(e);for(let o in r){let s=r[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var $e=P("ZodType",(t,e)=>(ke.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:tp(t,"input"),output:tp(t,"output")}}),t.toJSONSchema=oF(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>WF(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>KF(t,r,n),t.parseAsync=async(r,n)=>YF(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ZF(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>JF(t,r,n),t.decode=(r,n)=>XF(t,r,n),t.encodeAsync=async(r,n)=>QF(t,r,n),t.decodeAsync=async(r,n)=>eB(t,r,n),t.safeEncode=(r,n)=>tB(t,r,n),t.safeDecode=(r,n)=>rB(t,r,n),t.safeEncodeAsync=async(r,n)=>nB(t,r,n),t.safeDecodeAsync=async(r,n)=>iB(t,r,n),ay(t,"ZodType",{check(...r){let n=this.def;return this.clone(re.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return kr(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(KB(r,n))},superRefine(r,n){return this.check(ZB(r,n))},overwrite(r){return this.check(Ri(r))},optional(){return oy(this)},exactOptional(){return PB(this)},nullable(){return sy(this)},nullish(){return oy(sy(this))},nonoptional(r){return LB(this,r)},array(){return uy(this)},or(r){return JA([this,r])},and(r){return EB(this,r)},transform(r){return OA(this,QA(r))},default(r){return kB(this,r)},prefault(r){return DB(this,r)},catch(r){return FB(this,r)},pipe(r){return OA(this,r)},readonly(){return GB(this)},describe(r){let n=this.clone();return ur.add(n,{description:r}),n},meta(...r){if(r.length===0)return ur.get(this);let n=this.clone();return ur.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return ur.get(t)?.description},configurable:!0}),t)),NA=P("_ZodString",(t,e)=>{jl.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>sF(t,n,i,o);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,ay(t,"_ZodString",{regex(...n){return this.check(zf(...n))},includes(...n){return this.check(Vf(...n))},startsWith(...n){return this.check(Hf(...n))},endsWith(...n){return this.check(Wf(...n))},min(...n){return this.check(Is(...n))},max(...n){return this.check(Gl(...n))},length(...n){return this.check(ql(...n))},nonempty(...n){return this.check(Is(1,...n))},lowercase(n){return this.check(Gf(n))},uppercase(n){return this.check(qf(n))},trim(){return this.check(Zf())},normalize(...n){return this.check(Kf(...n))},toLowerCase(){return this.check(Jf())},toUpperCase(){return this.check(Xf())},slugify(){return this.check(Qf())}})}),op=P("ZodString",(t,e)=>{jl.init(t,e),NA.init(t,e),t.email=r=>t.check(Kw(kA,r)),t.url=r=>t.check(ty(cy,r)),t.jwt=r=>t.check(hA(YA,r)),t.emoji=r=>t.check(eA(MA,r)),t.guid=r=>t.check(ey(iy,r)),t.uuid=r=>t.check(Zw(bo,r)),t.uuidv4=r=>t.check(Jw(bo,r)),t.uuidv6=r=>t.check(Xw(bo,r)),t.uuidv7=r=>t.check(Qw(bo,r)),t.nanoid=r=>t.check(tA(DA,r)),t.guid=r=>t.check(ey(iy,r)),t.cuid=r=>t.check(rA(LA,r)),t.cuid2=r=>t.check(nA($A,r)),t.ulid=r=>t.check(iA(UA,r)),t.base64=r=>t.check(dA(VA,r)),t.base64url=r=>t.check(fA(HA,r)),t.xid=r=>t.check(oA(FA,r)),t.ksuid=r=>t.check(sA(BA,r)),t.ipv4=r=>t.check(aA(jA,r)),t.ipv6=r=>t.check(cA(zA,r)),t.cidrv4=r=>t.check(lA(GA,r)),t.cidrv6=r=>t.check(uA(qA,r)),t.e164=r=>t.check(pA(WA,r)),t.datetime=r=>t.check(GF(r)),t.date=r=>t.check(qF(r)),t.time=r=>t.check(VF(r)),t.duration=r=>t.check(HF(r))});function ny(t){return EU(op,t)}var rt=P("ZodStringFormat",(t,e)=>{tt.init(t,e),NA.init(t,e)}),kA=P("ZodEmail",(t,e)=>{d1.init(t,e),rt.init(t,e)});function yne(t){return Kw(kA,t)}var iy=P("ZodGUID",(t,e)=>{l1.init(t,e),rt.init(t,e)});function Sne(t){return ey(iy,t)}var bo=P("ZodUUID",(t,e)=>{u1.init(t,e),rt.init(t,e)});function Ene(t){return Zw(bo,t)}function vne(t){return Jw(bo,t)}function bne(t){return Xw(bo,t)}function Tne(t){return Qw(bo,t)}var cy=P("ZodURL",(t,e)=>{f1.init(t,e),rt.init(t,e)});function xne(t){return ty(cy,t)}function wne(t){return ty(cy,{protocol:vn.httpProtocol,hostname:vn.domain,...re.normalizeParams(t)})}var MA=P("ZodEmoji",(t,e)=>{p1.init(t,e),rt.init(t,e)});function Ane(t){return eA(MA,t)}var DA=P("ZodNanoID",(t,e)=>{h1.init(t,e),rt.init(t,e)});function Rne(t){return tA(DA,t)}var LA=P("ZodCUID",(t,e)=>{m1.init(t,e),rt.init(t,e)});function Ine(t){return rA(LA,t)}var $A=P("ZodCUID2",(t,e)=>{g1.init(t,e),rt.init(t,e)});function Cne(t){return nA($A,t)}var UA=P("ZodULID",(t,e)=>{_1.init(t,e),rt.init(t,e)});function Pne(t){return iA(UA,t)}var FA=P("ZodXID",(t,e)=>{y1.init(t,e),rt.init(t,e)});function One(t){return oA(FA,t)}var BA=P("ZodKSUID",(t,e)=>{S1.init(t,e),rt.init(t,e)});function Nne(t){return sA(BA,t)}var jA=P("ZodIPv4",(t,e)=>{x1.init(t,e),rt.init(t,e)});function kne(t){return aA(jA,t)}var oB=P("ZodMAC",(t,e)=>{A1.init(t,e),rt.init(t,e)});function Mne(t){return bU(oB,t)}var zA=P("ZodIPv6",(t,e)=>{w1.init(t,e),rt.init(t,e)});function Dne(t){return cA(zA,t)}var GA=P("ZodCIDRv4",(t,e)=>{R1.init(t,e),rt.init(t,e)});function Lne(t){return lA(GA,t)}var qA=P("ZodCIDRv6",(t,e)=>{I1.init(t,e),rt.init(t,e)});function $ne(t){return uA(qA,t)}var VA=P("ZodBase64",(t,e)=>{P1.init(t,e),rt.init(t,e)});function Une(t){return dA(VA,t)}var HA=P("ZodBase64URL",(t,e)=>{O1.init(t,e),rt.init(t,e)});function Fne(t){return fA(HA,t)}var WA=P("ZodE164",(t,e)=>{N1.init(t,e),rt.init(t,e)});function Bne(t){return pA(WA,t)}var YA=P("ZodJWT",(t,e)=>{k1.init(t,e),rt.init(t,e)});function jne(t){return hA(YA,t)}var sp=P("ZodCustomStringFormat",(t,e)=>{M1.init(t,e),rt.init(t,e)});function zne(t,e,r={}){return ep(sp,t,e,r)}function Gne(t){return ep(sp,"hostname",vn.hostname,t)}function qne(t){return ep(sp,"hex",vn.hex,t)}function Vne(t,e){let r=e?.enc??"hex",n=`${t}_${r}`,i=vn[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return ep(sp,n,i,e)}var ap=P("ZodNumber",(t,e)=>{Fw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>aF(t,n,i,o),ay(t,"ZodNumber",{gt(n,i){return this.check(Eo(n,i))},gte(n,i){return this.check(Dr(n,i))},min(n,i){return this.check(Dr(n,i))},lt(n,i){return this.check(So(n,i))},lte(n,i){return this.check(bn(n,i))},max(n,i){return this.check(bn(n,i))},int(n){return this.check(PA(n))},safe(n){return this.check(PA(n))},positive(n){return this.check(Eo(0,n))},nonnegative(n){return this.check(Dr(0,n))},negative(n){return this.check(So(0,n))},nonpositive(n){return this.check(bn(0,n))},multipleOf(n,i){return this.check(Ha(n,i))},step(n,i){return this.check(Ha(n,i))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function sB(t){return IU(ap,t)}var Hl=P("ZodNumberFormat",(t,e)=>{D1.init(t,e),ap.init(t,e)});function PA(t){return PU(Hl,t)}function Hne(t){return OU(Hl,t)}function Wne(t){return NU(Hl,t)}function Yne(t){return kU(Hl,t)}function Kne(t){return MU(Hl,t)}var cp=P("ZodBoolean",(t,e)=>{K_.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>cF(t,r,n,i)});function aB(t){return DU(cp,t)}var lp=P("ZodBigInt",(t,e)=>{Bw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>lF(t,n,i,o),t.gte=(n,i)=>t.check(Dr(n,i)),t.min=(n,i)=>t.check(Dr(n,i)),t.gt=(n,i)=>t.check(Eo(n,i)),t.gte=(n,i)=>t.check(Dr(n,i)),t.min=(n,i)=>t.check(Dr(n,i)),t.lt=(n,i)=>t.check(So(n,i)),t.lte=(n,i)=>t.check(bn(n,i)),t.max=(n,i)=>t.check(bn(n,i)),t.positive=n=>t.check(Eo(BigInt(0),n)),t.negative=n=>t.check(So(BigInt(0),n)),t.nonpositive=n=>t.check(bn(BigInt(0),n)),t.nonnegative=n=>t.check(Dr(BigInt(0),n)),t.multipleOf=(n,i)=>t.check(Ha(n,i));let r=t._zod.bag;t.minValue=r.minimum??null,t.maxValue=r.maximum??null,t.format=r.format??null});function Zne(t){return $U(lp,t)}var KA=P("ZodBigIntFormat",(t,e)=>{L1.init(t,e),lp.init(t,e)});function Jne(t){return FU(KA,t)}function Xne(t){return BU(KA,t)}var cB=P("ZodSymbol",(t,e)=>{$1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>uF(t,r,n,i)});function Qne(t){return jU(cB,t)}var lB=P("ZodUndefined",(t,e)=>{U1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>fF(t,r,n,i)});function eie(t){return zU(lB,t)}var uB=P("ZodNull",(t,e)=>{F1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>dF(t,r,n,i)});function dB(t){return GU(uB,t)}var fB=P("ZodAny",(t,e)=>{B1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>mF(t,r,n,i)});function tie(){return qU(fB)}var pB=P("ZodUnknown",(t,e)=>{j1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>gF(t,r,n,i)});function Vl(){return VU(pB)}var hB=P("ZodNever",(t,e)=>{z1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>hF(t,r,n,i)});function ZA(t){return HU(hB,t)}var mB=P("ZodVoid",(t,e)=>{G1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>pF(t,r,n,i)});function rie(t){return WU(mB,t)}var ly=P("ZodDate",(t,e)=>{q1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>_F(t,n,i,o),t.min=(n,i)=>t.check(Dr(n,i)),t.max=(n,i)=>t.check(bn(n,i));let r=t._zod.bag;t.minDate=r.minimum?new Date(r.minimum):null,t.maxDate=r.maximum?new Date(r.maximum):null});function nie(t){return YU(ly,t)}var gB=P("ZodArray",(t,e)=>{V1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>CF(t,r,n,i),t.element=e.element,ay(t,"ZodArray",{min(r,n){return this.check(Is(r,n))},nonempty(r){return this.check(Is(1,r))},max(r,n){return this.check(Gl(r,n))},length(r,n){return this.check(ql(r,n))},unwrap(){return this.element}})});function uy(t,e){return JU(gB,t,e)}function iie(t){let e=t._zod.def.shape;return XA(Object.keys(e))}var dy=P("ZodObject",(t,e)=>{H1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>PF(t,r,n,i),re.defineLazy(t,"shape",()=>e.shape),ay(t,"ZodObject",{keyof(){return XA(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Vl()})},loose(){return this.clone({...this._zod.def,catchall:Vl()})},strict(){return this.clone({...this._zod.def,catchall:ZA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return re.extend(this,r)},safeExtend(r){return re.safeExtend(this,r)},merge(r){return re.merge(this,r)},pick(r){return re.pick(this,r)},omit(r){return re.omit(this,r)},partial(...r){return re.partial(eR,this,r[0])},required(...r){return re.required(tR,this,r[0])}})});function oie(t,e){let r={type:"object",shape:t??{},...re.normalizeParams(e)};return new dy(r)}function sie(t,e){return new dy({type:"object",shape:t,catchall:ZA(),...re.normalizeParams(e)})}function aie(t,e){return new dy({type:"object",shape:t,catchall:Vl(),...re.normalizeParams(e)})}var fy=P("ZodUnion",(t,e)=>{Z_.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vA(t,r,n,i),t.options=e.options});function JA(t,e){return new fy({type:"union",options:t,...re.normalizeParams(e)})}var _B=P("ZodXor",(t,e)=>{fy.init(t,e),W1.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vA(t,r,n,i),t.options=e.options});function cie(t,e){return new _B({type:"union",options:t,inclusive:!1,...re.normalizeParams(e)})}var yB=P("ZodDiscriminatedUnion",(t,e)=>{fy.init(t,e),Y1.init(t,e)});function lie(t,e,r){return new yB({type:"union",options:e,discriminator:t,...re.normalizeParams(r)})}var SB=P("ZodIntersection",(t,e)=>{K1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>OF(t,r,n,i)});function EB(t,e){return new SB({type:"intersection",left:t,right:e})}var vB=P("ZodTuple",(t,e)=>{jw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>NF(t,r,n,i),t.rest=r=>t.clone({...t._zod.def,rest:r})});function bB(t,e,r){let n=e instanceof ke,i=n?r:e,o=n?e:null;return new vB({type:"tuple",items:t,rest:o,...re.normalizeParams(i)})}var np=P("ZodRecord",(t,e)=>{Z1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>kF(t,r,n,i),t.keyType=e.keyType,t.valueType=e.valueType});function TB(t,e,r){return!e||!e._zod?new np({type:"record",keyType:ny(),valueType:t,...re.normalizeParams(e)}):new np({type:"record",keyType:t,valueType:e,...re.normalizeParams(r)})}function uie(t,e,r){let n=kr(t);return n._zod.values=void 0,new np({type:"record",keyType:n,valueType:e,...re.normalizeParams(r)})}function die(t,e,r){return new np({type:"record",keyType:t,valueType:e,mode:"loose",...re.normalizeParams(r)})}var xB=P("ZodMap",(t,e)=>{J1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>RF(t,r,n,i),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(vo(...r)),t.nonempty=r=>t.check(vo(1,r)),t.max=(...r)=>t.check(Wa(...r)),t.size=(...r)=>t.check(zl(...r))});function fie(t,e,r){return new xB({type:"map",keyType:t,valueType:e,...re.normalizeParams(r)})}var wB=P("ZodSet",(t,e)=>{X1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>IF(t,r,n,i),t.min=(...r)=>t.check(vo(...r)),t.nonempty=r=>t.check(vo(1,r)),t.max=(...r)=>t.check(Wa(...r)),t.size=(...r)=>t.check(zl(...r))});function pie(t,e){return new wB({type:"set",valueType:t,...re.normalizeParams(e)})}var ip=P("ZodEnum",(t,e)=>{Q1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>yF(t,n,i,o),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ip({...e,checks:[],...re.normalizeParams(i),entries:o})},t.exclude=(n,i)=>{let o={...e.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new ip({...e,checks:[],...re.normalizeParams(i),entries:o})}});function XA(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ip({type:"enum",entries:r,...re.normalizeParams(e)})}function hie(t,e){return new ip({type:"enum",entries:t,...re.normalizeParams(e)})}var AB=P("ZodLiteral",(t,e)=>{eU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>SF(t,r,n,i),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function mie(t,e){return new AB({type:"literal",values:Array.isArray(t)?t:[t],...re.normalizeParams(e)})}var RB=P("ZodFile",(t,e)=>{tU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bF(t,r,n,i),t.min=(r,n)=>t.check(vo(r,n)),t.max=(r,n)=>t.check(Wa(r,n)),t.mime=(r,n)=>t.check(Yf(Array.isArray(r)?r:[r],n))});function gie(t){return XU(RB,t)}var IB=P("ZodTransform",(t,e)=>{rU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>AF(t,r,n,i),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ja(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(re.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),r.issues.push(re.issue(s))}};let i=e.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function QA(t){return new IB({type:"transform",transform:t})}var eR=P("ZodOptional",(t,e)=>{zw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bA(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function oy(t){return new eR({type:"optional",innerType:t})}var CB=P("ZodExactOptional",(t,e)=>{nU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bA(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function PB(t){return new CB({type:"optional",innerType:t})}var OB=P("ZodNullable",(t,e)=>{iU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>MF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function sy(t){return new OB({type:"nullable",innerType:t})}function _ie(t){return oy(sy(t))}var NB=P("ZodDefault",(t,e)=>{oU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>LF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function kB(t,e){return new NB({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():re.shallowClone(e)}})}var MB=P("ZodPrefault",(t,e)=>{sU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>$F(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function DB(t,e){return new MB({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():re.shallowClone(e)}})}var tR=P("ZodNonOptional",(t,e)=>{aU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>DF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function LB(t,e){return new tR({type:"nonoptional",innerType:t,...re.normalizeParams(e)})}var $B=P("ZodSuccess",(t,e)=>{cU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>TF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function yie(t){return new $B({type:"success",innerType:t})}var UB=P("ZodCatch",(t,e)=>{lU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>UF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function FB(t,e){return new UB({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var BB=P("ZodNaN",(t,e)=>{uU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>EF(t,r,n,i)});function Sie(t){return ZU(BB,t)}var py=P("ZodPipe",(t,e)=>{Gw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>FF(t,r,n,i),t.in=e.in,t.out=e.out});function OA(t,e){return new py({type:"pipe",in:t,out:e})}var hy=P("ZodCodec",(t,e)=>{py.init(t,e),J_.init(t,e)});function Eie(t,e,r){return new hy({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function vie(t){let e=t._zod.def;return new hy({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var jB=P("ZodPreprocess",(t,e)=>{py.init(t,e),dU.init(t,e)}),zB=P("ZodReadonly",(t,e)=>{fU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>BF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function GB(t){return new zB({type:"readonly",innerType:t})}var qB=P("ZodTemplateLiteral",(t,e)=>{pU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vF(t,r,n,i)});function bie(t,e){return new qB({type:"template_literal",parts:t,...re.normalizeParams(e)})}var VB=P("ZodLazy",(t,e)=>{gU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>zF(t,r,n,i),t.unwrap=()=>t._zod.def.getter()});function HB(t){return new VB({type:"lazy",getter:t})}var WB=P("ZodPromise",(t,e)=>{mU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>jF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function Tie(t){return new WB({type:"promise",innerType:t})}var YB=P("ZodFunction",(t,e)=>{hU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>wF(t,r,n,i)});function xie(t){return new YB({type:"function",input:Array.isArray(t?.input)?bB(t?.input):t?.input??uy(Vl()),output:t?.output??Vl()})}var my=P("ZodCustom",(t,e)=>{_U.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>xF(t,r,n,i)});function wie(t){let e=new ct({check:"custom"});return e._zod.check=t,e}function Aie(t,e){return QU(my,t??(()=>!0),e)}function KB(t,e={}){return eF(my,t,e)}function ZB(t,e){return tF(t,e)}var Rie=rF,Iie=nF;function Cie(t,e={}){let r=new my({type:"custom",check:"custom",fn:n=>n instanceof t,abort:!0,...re.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=n=>{n.value instanceof t||n.issues.push({code:"invalid_type",expected:t.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Pie=(...t)=>iF({Codec:hy,Boolean:cp,String:op},...t);function Oie(t){let e=HB(()=>JA([ny(t),sB(),aB(),dB(),uy(e),TB(ny(),e)]));return e}function Nie(t,e){return new jB({type:"pipe",in:QA(t),out:e})}var cUe={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function lUe(t){Tt({customError:t})}function uUe(){return Tt().customError}var JB;JB||(JB={});var pe={...ry,...wA,iso:rp},dUe=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function fUe(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function pUe(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let n=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!e.defs[i])throw new Error(`Reference not found: ${t}`);return e.defs[i]}throw new Error(`Reference not found: ${t}`)}function kie(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return pe.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let i=t.$ref;if(e.refs.has(i))return e.refs.get(i);if(e.processing.has(i))return pe.lazy(()=>{if(!e.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return e.refs.get(i)});e.processing.add(i);let o=pUe(i,e),s=gr(o,e);return e.refs.set(i,s),e.processing.delete(i),s}if(t.enum!==void 0){let i=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&i.length===1&&i[0]===null)return pe.null();if(i.length===0)return pe.never();if(i.length===1)return pe.literal(i[0]);if(i.every(s=>typeof s=="string"))return pe.enum(i);let o=i.map(s=>pe.literal(s));return o.length<2?o[0]:pe.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return pe.literal(t.const);let r=t.type;if(Array.isArray(r)){let i=r.map(o=>{let s={...t,type:o};return kie(s,e)});return i.length===0?pe.never():i.length===1?i[0]:pe.union(i)}if(!r)return pe.any();let n;switch(r){case"string":{let i=pe.string();if(t.format){let o=t.format;o==="email"?i=i.check(pe.email()):o==="uri"||o==="uri-reference"?i=i.check(pe.url()):o==="uuid"||o==="guid"?i=i.check(pe.uuid()):o==="date-time"?i=i.check(pe.iso.datetime()):o==="date"?i=i.check(pe.iso.date()):o==="time"?i=i.check(pe.iso.time()):o==="duration"?i=i.check(pe.iso.duration()):o==="ipv4"?i=i.check(pe.ipv4()):o==="ipv6"?i=i.check(pe.ipv6()):o==="mac"?i=i.check(pe.mac()):o==="cidr"?i=i.check(pe.cidrv4()):o==="cidr-v6"?i=i.check(pe.cidrv6()):o==="base64"?i=i.check(pe.base64()):o==="base64url"?i=i.check(pe.base64url()):o==="e164"?i=i.check(pe.e164()):o==="jwt"?i=i.check(pe.jwt()):o==="emoji"?i=i.check(pe.emoji()):o==="nanoid"?i=i.check(pe.nanoid()):o==="cuid"?i=i.check(pe.cuid()):o==="cuid2"?i=i.check(pe.cuid2()):o==="ulid"?i=i.check(pe.ulid()):o==="xid"?i=i.check(pe.xid()):o==="ksuid"&&(i=i.check(pe.ksuid()))}typeof t.minLength=="number"&&(i=i.min(t.minLength)),typeof t.maxLength=="number"&&(i=i.max(t.maxLength)),t.pattern&&(i=i.regex(new RegExp(t.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?pe.number().int():pe.number();typeof t.minimum=="number"&&(i=i.min(t.minimum)),typeof t.maximum=="number"&&(i=i.max(t.maximum)),typeof t.exclusiveMinimum=="number"?i=i.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(i=i.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?i=i.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(i=i.lt(t.maximum)),typeof t.multipleOf=="number"&&(i=i.multipleOf(t.multipleOf)),n=i;break}case"boolean":{n=pe.boolean();break}case"null":{n=pe.null();break}case"object":{let i={},o=t.properties||{},s=new Set(t.required||[]);for(let[c,l]of Object.entries(o)){let u=gr(l,e);i[c]=s.has(c)?u:u.optional()}if(t.propertyNames){let c=gr(t.propertyNames,e),l=t.additionalProperties&&typeof t.additionalProperties=="object"?gr(t.additionalProperties,e):pe.any();if(Object.keys(i).length===0){n=pe.record(c,l);break}let u=pe.object(i).passthrough(),d=pe.looseRecord(c,l);n=pe.intersection(u,d);break}if(t.patternProperties){let c=t.patternProperties,l=Object.keys(c),u=[];for(let f of l){let p=gr(c[f],e),h=pe.string().regex(new RegExp(f));u.push(pe.looseRecord(h,p))}let d=[];if(Object.keys(i).length>0&&d.push(pe.object(i).passthrough()),d.push(...u),d.length===0)n=pe.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=pe.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=pe.intersection(f,d[p]);n=f}break}let a=pe.object(i);t.additionalProperties===!1?n=a.strict():typeof t.additionalProperties=="object"?n=a.catchall(gr(t.additionalProperties,e)):n=a.passthrough();break}case"array":{let i=t.prefixItems,o=t.items;if(i&&Array.isArray(i)){let s=i.map(c=>gr(c,e)),a=o&&typeof o=="object"&&!Array.isArray(o)?gr(o,e):void 0;a?n=pe.tuple(s).rest(a):n=pe.tuple(s),typeof t.minItems=="number"&&(n=n.check(pe.minLength(t.minItems))),typeof t.maxItems=="number"&&(n=n.check(pe.maxLength(t.maxItems)))}else if(Array.isArray(o)){let s=o.map(c=>gr(c,e)),a=t.additionalItems&&typeof t.additionalItems=="object"?gr(t.additionalItems,e):void 0;a?n=pe.tuple(s).rest(a):n=pe.tuple(s),typeof t.minItems=="number"&&(n=n.check(pe.minLength(t.minItems))),typeof t.maxItems=="number"&&(n=n.check(pe.maxLength(t.maxItems)))}else if(o!==void 0){let s=gr(o,e),a=pe.array(s);typeof t.minItems=="number"&&(a=a.min(t.minItems)),typeof t.maxItems=="number"&&(a=a.max(t.maxItems)),n=a}else n=pe.array(pe.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function gr(t,e){if(typeof t=="boolean")return t?pe.any():pe.never();let r=kie(t,e),n=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let a=t.anyOf.map(l=>gr(l,e)),c=pe.union(a);r=n?pe.intersection(r,c):c}if(t.oneOf&&Array.isArray(t.oneOf)){let a=t.oneOf.map(l=>gr(l,e)),c=pe.xor(a);r=n?pe.intersection(r,c):c}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=n?r:pe.any();else{let a=n?r:gr(t.allOf[0],e),c=n?0:1;for(let l=c;l<t.allOf.length;l++)a=pe.intersection(a,gr(t.allOf[l],e));r=a}t.nullable===!0&&e.version==="openapi-3.0"&&(r=pe.nullable(r)),t.readOnly===!0&&(r=pe.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in t&&(i[a]=t[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in t&&(i[a]=t[a]);for(let a of Object.keys(t))dUe.has(a)||(i[a]=t[a]);return Object.keys(i).length>0&&e.registry.add(r,i),t.description&&(r=r.describe(t.description)),r}function Mie(t,e){if(typeof t=="boolean")return t?pe.any():pe.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=fUe(r,e?.defaultTarget),i=r.$defs||r.definitions||{},o={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??ur};return gr(r,o)}var XB={};pr(XB,{bigint:()=>_Ue,boolean:()=>gUe,date:()=>yUe,number:()=>mUe,string:()=>hUe});function hUe(t){return vU(op,t)}function mUe(t){return CU(ap,t)}function gUe(t){return LU(cp,t)}function _Ue(t){return UU(lp,t)}function yUe(t){return KU(ly,t)}Tt(qw());var SUe={questions:Tn.array(Tn.object({question:Tn.string(),header:Tn.string().optional().describe('Very short topic label rendered as a tag above the question, max ~12 characters (e.g. "Framework")'),multiSelect:Tn.boolean().optional(),options:Tn.array(Tn.object({label:Tn.string(),description:Tn.string().optional()})).optional()})).min(1).max(3)},up=Tn.object(SUe);import QB from"path";import EUe from"fs/promises";var e2=ye("agent-output-utils");async function Ja({initialResult:t,agentName:e,hasError:r}){let n="",i=QB.join(process.cwd(),ar,Sl);try{let o=await EUe.readFile(i,"utf-8");o&&(n=o,e2.log(`Pulled result from ${QB.relative(process.cwd(),i)}`))}catch{e2.log(`No results file found at ${QB.relative(process.cwd(),i)}`)}return n||(!t&&!r?`${e} has finished working on task.`:t||void 0)}var vUe=[/^API Error:\s*\d{3}/i,/^\d{3}\s*status code/i,/^API request failed:\s*\d{3}/i,/^API Error: The socket connection was closed/i,/^overloaded_error/i];function rR(t){let e=t.trim();return vUe.some(r=>r.test(e))?"Encountered a temporary issue \u2014 the agent will attempt to continue.":t}function Xa({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),i&&e2.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function Qa(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ec(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider"))}import nR from"process";import{fileURLToPath as AUe}from"url";import{createRequire as RUe}from"module";import iR from"path";import{readdir as bUe,rm as TUe}from"fs/promises";import{join as xUe}from"path";async function Die(t,e=[]){let n=(await bUe(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>TUe(xUe(t,i),{recursive:!0,force:!0})))}var wUe=700,Lie=t=>t.mode==="create"&&(t.accountType===Yg||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=wUe);var IUe=iR.dirname(AUe(import.meta.url)),$ie=RUe(import.meta.url),CUe=iR.resolve(IUe,"scripts/scaffold.js"),PUe="scripts/scaffold.js",OUe=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,t2=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},NUe=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),kUe=t=>{let e=t2(t);return e==="node"||e.endsWith("/node")},Ps=t=>{if(typeof t!="string")return!1;let e=t.match(OUe)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&NUe(t2(e[r]));)r+=1;if(r>=e.length||!kUe(e[r]))return!1;let n=e[r+1];return n?t2(n).includes(PUe):!1},dp=ye("create_stage"),Uie="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",MUe=`${Uie}
|
|
209
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of t.seen.entries()){let a=s[1];if(e===s[0]){o(s);continue}if(t.external){let l=t.external.registry.get(s[0])?.id;if(e!==s[0]&&l){o(s);continue}}if(t.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&t.reused==="ref"){o(s);continue}}}function Za(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){n(d);let p=t.seen.get(d),h=p.schema;if(h.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(h)):Object.assign(l,h),Object.assign(l,u),a._zod.parent===d)for(let y in l)y==="$ref"||y==="allOf"||y in u||delete l[y];if(h.$ref&&p.def)for(let y in l)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(l[y])===JSON.stringify(p.def[y])&&delete l[y]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=t.seen.get(f);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let h in l)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(l[h])===JSON.stringify(p.def[h])&&delete l[h]}t.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(a)}Object.assign(i,r.def??r.schema);let o=t.metadataRegistry.get(e)?.id;o!==void 0&&i.id===o&&delete i.id;let s=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}t.external||Object.keys(s).length>0&&(t.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:tp(e,"input",t.processors),output:tp(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Lr(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Lr(n.element,r);if(n.type==="set")return Lr(n.valueType,r);if(n.type==="lazy")return Lr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Lr(n.innerType,r);if(n.type==="intersection")return Lr(n.left,r)||Lr(n.right,r);if(n.type==="record"||n.type==="map")return Lr(n.keyType,r)||Lr(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Lr(n.in,r)||Lr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(Lr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(Lr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(Lr(i,r))return!0;return!!(n.rest&&Lr(n.rest,r))}return!1}var oF=(t,e={})=>r=>{let n=Ya({...r,processors:e});return Ze(t,n),Ka(n,t),Za(n,t)},tp=(t,e,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},s=Ya({...i??{},target:o,io:e,processors:r});return Ze(t,s),Ka(s,t),Za(s,t)};var iUe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sF=(t,e,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:l}=t._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=iUe[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},aF=(t,e,r,n)=>{let i=r,{minimum:o,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";let d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),f=typeof l=="number"&&l<=(s??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof o=="number"&&(i.minimum=o),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof s=="number"&&(i.maximum=s),typeof c=="number"&&(i.multipleOf=c)},cF=(t,e,r,n)=>{r.type="boolean"},lF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},uF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},dF=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},fF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},pF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},hF=(t,e,r,n)=>{r.not={}},mF=(t,e,r,n)=>{},gF=(t,e,r,n)=>{},_F=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},yF=(t,e,r,n)=>{let i=t._zod.def,o=U_(i.entries);o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},SF=(t,e,r,n)=>{let i=t._zod.def,o=[];for(let s of i.values)if(s===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];r.type=s===null?"null":typeof s,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[s]:r.const=s}else o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),o.every(s=>typeof s=="boolean")&&(r.type="boolean"),o.every(s=>s===null)&&(r.type="null"),r.enum=o},EF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},vF=(t,e,r,n)=>{let i=r,o=t._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},bF=(t,e,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=t._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(i,o)},TF=(t,e,r,n)=>{r.type="boolean"},xF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},AF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},RF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},IF=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},CF=(t,e,r,n)=>{let i=r,o=t._zod.def,{minimum:s,maximum:a}=t._zod.bag;typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ze(o.element,e,{...n,path:[...n.path,"items"]})},PF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="object",i.properties={};let s=o.shape;for(let l in s)i.properties[l]=Ze(s[l],e,{...n,path:[...n.path,"properties",l]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(l=>{let u=o.shape[l]._zod;return e.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Ze(o.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},vA=(t,e,r,n)=>{let i=t._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>Ze(a,e,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},OF=(t,e,r,n)=>{let i=t._zod.def,o=Ze(i.left,e,{...n,path:[...n.path,"allOf",0]}),s=Ze(i.right,e,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c},NF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="array";let s=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((f,p)=>Ze(f,e,{...n,path:[...n.path,s,p]})),l=o.rest?Ze(o.rest,e,{...n,path:[...n.path,a,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null;e.target==="draft-2020-12"?(i.prefixItems=c,l&&(i.items=l)):e.target==="openapi-3.0"?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=t._zod.bag;typeof u=="number"&&(i.minItems=u),typeof d=="number"&&(i.maxItems=d)},kF=(t,e,r,n)=>{let i=r,o=t._zod.def;i.type="object";let s=o.keyType,c=s._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let u=Ze(o.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=Ze(o.keyType,e,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Ze(o.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let l=s._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(i.required=u)}},MF=(t,e,r,n)=>{let i=t._zod.def,o=Ze(i.innerType,e,n),s=e.seen.get(t);e.target==="openapi-3.0"?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},DF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},LF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},$F=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},UF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},FF=(t,e,r,n)=>{let i=t._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=e.io==="input"?o?i.out:i.in:i.out;Ze(s,e,n);let a=e.seen.get(t);a.ref=s},BF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType,r.readOnly=!0},jF=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},bA=(t,e,r,n)=>{let i=t._zod.def;Ze(i.innerType,e,n);let o=e.seen.get(t);o.ref=i.innerType},zF=(t,e,r,n)=>{let i=t._zod.innerType;Ze(i,e,n);let o=e.seen.get(t);o.ref=i},EA={string:sF,number:aF,boolean:cF,bigint:lF,symbol:uF,null:dF,undefined:fF,void:pF,never:hF,any:mF,unknown:gF,date:_F,enum:yF,literal:SF,nan:EF,template_literal:vF,file:bF,success:TF,custom:xF,function:wF,transform:AF,map:RF,set:IF,array:CF,object:PF,union:vA,intersection:OF,tuple:NF,record:kF,nullable:MF,nonoptional:DF,default:LF,prefault:$F,catch:UF,pipe:FF,readonly:BF,promise:jF,optional:bA,lazy:zF};function TA(t,e){if("_idmap"in t){let n=t,i=Ya({...e,processors:EA}),o={};for(let c of n._idmap.entries()){let[l,u]=c;Ze(u,i)}let s={},a={registry:n,uri:e?.uri,defs:o};i.external=a;for(let c of n._idmap.entries()){let[l,u]=c;Ka(i,u),s[l]=Za(i,u)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=Ya({...e,processors:EA});return Ze(t,r),Ka(r,t),Za(r,t)}var xA=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Ya({processors:EA,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return Ze(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Ka(this.ctx,e);let n=Za(this.ctx,e),{"~standard":i,...o}=n;return o}};var mne={};var ry={};pr(ry,{ZodAny:()=>fB,ZodArray:()=>gB,ZodBase64:()=>VA,ZodBase64URL:()=>HA,ZodBigInt:()=>lp,ZodBigIntFormat:()=>KA,ZodBoolean:()=>cp,ZodCIDRv4:()=>GA,ZodCIDRv6:()=>qA,ZodCUID:()=>LA,ZodCUID2:()=>$A,ZodCatch:()=>UB,ZodCodec:()=>hy,ZodCustom:()=>my,ZodCustomStringFormat:()=>sp,ZodDate:()=>ly,ZodDefault:()=>NB,ZodDiscriminatedUnion:()=>yB,ZodE164:()=>WA,ZodEmail:()=>kA,ZodEmoji:()=>MA,ZodEnum:()=>ip,ZodExactOptional:()=>CB,ZodFile:()=>RB,ZodFunction:()=>YB,ZodGUID:()=>iy,ZodIPv4:()=>jA,ZodIPv6:()=>zA,ZodIntersection:()=>SB,ZodJWT:()=>YA,ZodKSUID:()=>BA,ZodLazy:()=>VB,ZodLiteral:()=>AB,ZodMAC:()=>oB,ZodMap:()=>xB,ZodNaN:()=>BB,ZodNanoID:()=>DA,ZodNever:()=>hB,ZodNonOptional:()=>tR,ZodNull:()=>uB,ZodNullable:()=>OB,ZodNumber:()=>ap,ZodNumberFormat:()=>Hl,ZodObject:()=>dy,ZodOptional:()=>eR,ZodPipe:()=>py,ZodPrefault:()=>MB,ZodPreprocess:()=>jB,ZodPromise:()=>WB,ZodReadonly:()=>zB,ZodRecord:()=>np,ZodSet:()=>wB,ZodString:()=>op,ZodStringFormat:()=>rt,ZodSuccess:()=>$B,ZodSymbol:()=>cB,ZodTemplateLiteral:()=>qB,ZodTransform:()=>IB,ZodTuple:()=>vB,ZodType:()=>$e,ZodULID:()=>UA,ZodURL:()=>cy,ZodUUID:()=>bo,ZodUndefined:()=>lB,ZodUnion:()=>fy,ZodUnknown:()=>pB,ZodVoid:()=>mB,ZodXID:()=>FA,ZodXor:()=>_B,_ZodString:()=>NA,_default:()=>kB,_function:()=>xie,any:()=>tie,array:()=>uy,base64:()=>Une,base64url:()=>Fne,bigint:()=>Zne,boolean:()=>aB,catch:()=>FB,check:()=>wie,cidrv4:()=>Lne,cidrv6:()=>$ne,codec:()=>Eie,cuid:()=>Ine,cuid2:()=>Cne,custom:()=>Aie,date:()=>nie,describe:()=>Rie,discriminatedUnion:()=>lie,e164:()=>Bne,email:()=>yne,emoji:()=>Ane,enum:()=>XA,exactOptional:()=>PB,file:()=>gie,float32:()=>Hne,float64:()=>Wne,function:()=>xie,guid:()=>Sne,hash:()=>Vne,hex:()=>qne,hostname:()=>Gne,httpUrl:()=>wne,instanceof:()=>Cie,int:()=>PA,int32:()=>Yne,int64:()=>Jne,intersection:()=>EB,invertCodec:()=>vie,ipv4:()=>kne,ipv6:()=>Dne,json:()=>Oie,jwt:()=>jne,keyof:()=>iie,ksuid:()=>Nne,lazy:()=>HB,literal:()=>mie,looseObject:()=>aie,looseRecord:()=>die,mac:()=>Mne,map:()=>fie,meta:()=>Iie,nan:()=>Sie,nanoid:()=>Rne,nativeEnum:()=>hie,never:()=>ZA,nonoptional:()=>LB,null:()=>dB,nullable:()=>sy,nullish:()=>_ie,number:()=>sB,object:()=>oie,optional:()=>oy,partialRecord:()=>uie,pipe:()=>OA,prefault:()=>DB,preprocess:()=>Nie,promise:()=>Tie,readonly:()=>GB,record:()=>TB,refine:()=>KB,set:()=>pie,strictObject:()=>sie,string:()=>ny,stringFormat:()=>zne,stringbool:()=>Pie,success:()=>yie,superRefine:()=>ZB,symbol:()=>Qne,templateLiteral:()=>bie,transform:()=>QA,tuple:()=>bB,uint32:()=>Kne,uint64:()=>Xne,ulid:()=>Pne,undefined:()=>eie,union:()=>JA,unknown:()=>Vl,url:()=>xne,uuid:()=>Ene,uuidv4:()=>vne,uuidv6:()=>bne,uuidv7:()=>Tne,void:()=>rie,xid:()=>One,xor:()=>cie});var wA={};pr(wA,{endsWith:()=>Wf,gt:()=>Eo,gte:()=>Dr,includes:()=>Vf,length:()=>ql,lowercase:()=>Gf,lt:()=>So,lte:()=>bn,maxLength:()=>Gl,maxSize:()=>Wa,mime:()=>Yf,minLength:()=>Is,minSize:()=>vo,multipleOf:()=>Ha,negative:()=>gA,nonnegative:()=>yA,nonpositive:()=>_A,normalize:()=>Kf,overwrite:()=>Ri,positive:()=>mA,property:()=>SA,regex:()=>zf,size:()=>zl,slugify:()=>Qf,startsWith:()=>Hf,toLowerCase:()=>Jf,toUpperCase:()=>Xf,trim:()=>Zf,uppercase:()=>qf});var rp={};pr(rp,{ZodISODate:()=>RA,ZodISODateTime:()=>AA,ZodISODuration:()=>CA,ZodISOTime:()=>IA,date:()=>qF,datetime:()=>GF,duration:()=>HF,time:()=>VF});var AA=P("ZodISODateTime",(t,e)=>{E1.init(t,e),rt.init(t,e)});function GF(t){return xU(AA,t)}var RA=P("ZodISODate",(t,e)=>{v1.init(t,e),rt.init(t,e)});function qF(t){return wU(RA,t)}var IA=P("ZodISOTime",(t,e)=>{b1.init(t,e),rt.init(t,e)});function VF(t){return AU(IA,t)}var CA=P("ZodISODuration",(t,e)=>{T1.init(t,e),rt.init(t,e)});function HF(t){return RU(CA,t)}var gne=(t,e)=>{G_.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>V_(t,r)},flatten:{value:r=>q_(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,kf,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,kf,2)}},isEmpty:{get(){return t.issues.length===0}}})},sUe=P("ZodError",gne),Xr=P("ZodError",gne,{Parent:Error});var WF=Lf(Xr),YF=$f(Xr),KF=Uf(Xr),ZF=Ff(Xr),JF=Tw(Xr),XF=xw(Xr),QF=ww(Xr),eB=Aw(Xr),tB=Rw(Xr),rB=Iw(Xr),nB=Cw(Xr),iB=Pw(Xr);var _ne=new WeakMap;function ay(t,e,r){let n=Object.getPrototypeOf(t),i=_ne.get(n);if(i||(i=new Set,_ne.set(n,i)),!i.has(e)){i.add(e);for(let o in r){let s=r[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var $e=P("ZodType",(t,e)=>(ke.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:tp(t,"input"),output:tp(t,"output")}}),t.toJSONSchema=oF(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>WF(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>KF(t,r,n),t.parseAsync=async(r,n)=>YF(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ZF(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>JF(t,r,n),t.decode=(r,n)=>XF(t,r,n),t.encodeAsync=async(r,n)=>QF(t,r,n),t.decodeAsync=async(r,n)=>eB(t,r,n),t.safeEncode=(r,n)=>tB(t,r,n),t.safeDecode=(r,n)=>rB(t,r,n),t.safeEncodeAsync=async(r,n)=>nB(t,r,n),t.safeDecodeAsync=async(r,n)=>iB(t,r,n),ay(t,"ZodType",{check(...r){let n=this.def;return this.clone(re.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return kr(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(KB(r,n))},superRefine(r,n){return this.check(ZB(r,n))},overwrite(r){return this.check(Ri(r))},optional(){return oy(this)},exactOptional(){return PB(this)},nullable(){return sy(this)},nullish(){return oy(sy(this))},nonoptional(r){return LB(this,r)},array(){return uy(this)},or(r){return JA([this,r])},and(r){return EB(this,r)},transform(r){return OA(this,QA(r))},default(r){return kB(this,r)},prefault(r){return DB(this,r)},catch(r){return FB(this,r)},pipe(r){return OA(this,r)},readonly(){return GB(this)},describe(r){let n=this.clone();return ur.add(n,{description:r}),n},meta(...r){if(r.length===0)return ur.get(this);let n=this.clone();return ur.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return ur.get(t)?.description},configurable:!0}),t)),NA=P("_ZodString",(t,e)=>{jl.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>sF(t,n,i,o);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,ay(t,"_ZodString",{regex(...n){return this.check(zf(...n))},includes(...n){return this.check(Vf(...n))},startsWith(...n){return this.check(Hf(...n))},endsWith(...n){return this.check(Wf(...n))},min(...n){return this.check(Is(...n))},max(...n){return this.check(Gl(...n))},length(...n){return this.check(ql(...n))},nonempty(...n){return this.check(Is(1,...n))},lowercase(n){return this.check(Gf(n))},uppercase(n){return this.check(qf(n))},trim(){return this.check(Zf())},normalize(...n){return this.check(Kf(...n))},toLowerCase(){return this.check(Jf())},toUpperCase(){return this.check(Xf())},slugify(){return this.check(Qf())}})}),op=P("ZodString",(t,e)=>{jl.init(t,e),NA.init(t,e),t.email=r=>t.check(Kw(kA,r)),t.url=r=>t.check(ty(cy,r)),t.jwt=r=>t.check(hA(YA,r)),t.emoji=r=>t.check(eA(MA,r)),t.guid=r=>t.check(ey(iy,r)),t.uuid=r=>t.check(Zw(bo,r)),t.uuidv4=r=>t.check(Jw(bo,r)),t.uuidv6=r=>t.check(Xw(bo,r)),t.uuidv7=r=>t.check(Qw(bo,r)),t.nanoid=r=>t.check(tA(DA,r)),t.guid=r=>t.check(ey(iy,r)),t.cuid=r=>t.check(rA(LA,r)),t.cuid2=r=>t.check(nA($A,r)),t.ulid=r=>t.check(iA(UA,r)),t.base64=r=>t.check(dA(VA,r)),t.base64url=r=>t.check(fA(HA,r)),t.xid=r=>t.check(oA(FA,r)),t.ksuid=r=>t.check(sA(BA,r)),t.ipv4=r=>t.check(aA(jA,r)),t.ipv6=r=>t.check(cA(zA,r)),t.cidrv4=r=>t.check(lA(GA,r)),t.cidrv6=r=>t.check(uA(qA,r)),t.e164=r=>t.check(pA(WA,r)),t.datetime=r=>t.check(GF(r)),t.date=r=>t.check(qF(r)),t.time=r=>t.check(VF(r)),t.duration=r=>t.check(HF(r))});function ny(t){return EU(op,t)}var rt=P("ZodStringFormat",(t,e)=>{tt.init(t,e),NA.init(t,e)}),kA=P("ZodEmail",(t,e)=>{d1.init(t,e),rt.init(t,e)});function yne(t){return Kw(kA,t)}var iy=P("ZodGUID",(t,e)=>{l1.init(t,e),rt.init(t,e)});function Sne(t){return ey(iy,t)}var bo=P("ZodUUID",(t,e)=>{u1.init(t,e),rt.init(t,e)});function Ene(t){return Zw(bo,t)}function vne(t){return Jw(bo,t)}function bne(t){return Xw(bo,t)}function Tne(t){return Qw(bo,t)}var cy=P("ZodURL",(t,e)=>{f1.init(t,e),rt.init(t,e)});function xne(t){return ty(cy,t)}function wne(t){return ty(cy,{protocol:vn.httpProtocol,hostname:vn.domain,...re.normalizeParams(t)})}var MA=P("ZodEmoji",(t,e)=>{p1.init(t,e),rt.init(t,e)});function Ane(t){return eA(MA,t)}var DA=P("ZodNanoID",(t,e)=>{h1.init(t,e),rt.init(t,e)});function Rne(t){return tA(DA,t)}var LA=P("ZodCUID",(t,e)=>{m1.init(t,e),rt.init(t,e)});function Ine(t){return rA(LA,t)}var $A=P("ZodCUID2",(t,e)=>{g1.init(t,e),rt.init(t,e)});function Cne(t){return nA($A,t)}var UA=P("ZodULID",(t,e)=>{_1.init(t,e),rt.init(t,e)});function Pne(t){return iA(UA,t)}var FA=P("ZodXID",(t,e)=>{y1.init(t,e),rt.init(t,e)});function One(t){return oA(FA,t)}var BA=P("ZodKSUID",(t,e)=>{S1.init(t,e),rt.init(t,e)});function Nne(t){return sA(BA,t)}var jA=P("ZodIPv4",(t,e)=>{x1.init(t,e),rt.init(t,e)});function kne(t){return aA(jA,t)}var oB=P("ZodMAC",(t,e)=>{A1.init(t,e),rt.init(t,e)});function Mne(t){return bU(oB,t)}var zA=P("ZodIPv6",(t,e)=>{w1.init(t,e),rt.init(t,e)});function Dne(t){return cA(zA,t)}var GA=P("ZodCIDRv4",(t,e)=>{R1.init(t,e),rt.init(t,e)});function Lne(t){return lA(GA,t)}var qA=P("ZodCIDRv6",(t,e)=>{I1.init(t,e),rt.init(t,e)});function $ne(t){return uA(qA,t)}var VA=P("ZodBase64",(t,e)=>{P1.init(t,e),rt.init(t,e)});function Une(t){return dA(VA,t)}var HA=P("ZodBase64URL",(t,e)=>{O1.init(t,e),rt.init(t,e)});function Fne(t){return fA(HA,t)}var WA=P("ZodE164",(t,e)=>{N1.init(t,e),rt.init(t,e)});function Bne(t){return pA(WA,t)}var YA=P("ZodJWT",(t,e)=>{k1.init(t,e),rt.init(t,e)});function jne(t){return hA(YA,t)}var sp=P("ZodCustomStringFormat",(t,e)=>{M1.init(t,e),rt.init(t,e)});function zne(t,e,r={}){return ep(sp,t,e,r)}function Gne(t){return ep(sp,"hostname",vn.hostname,t)}function qne(t){return ep(sp,"hex",vn.hex,t)}function Vne(t,e){let r=e?.enc??"hex",n=`${t}_${r}`,i=vn[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return ep(sp,n,i,e)}var ap=P("ZodNumber",(t,e)=>{Fw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>aF(t,n,i,o),ay(t,"ZodNumber",{gt(n,i){return this.check(Eo(n,i))},gte(n,i){return this.check(Dr(n,i))},min(n,i){return this.check(Dr(n,i))},lt(n,i){return this.check(So(n,i))},lte(n,i){return this.check(bn(n,i))},max(n,i){return this.check(bn(n,i))},int(n){return this.check(PA(n))},safe(n){return this.check(PA(n))},positive(n){return this.check(Eo(0,n))},nonnegative(n){return this.check(Dr(0,n))},negative(n){return this.check(So(0,n))},nonpositive(n){return this.check(bn(0,n))},multipleOf(n,i){return this.check(Ha(n,i))},step(n,i){return this.check(Ha(n,i))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function sB(t){return IU(ap,t)}var Hl=P("ZodNumberFormat",(t,e)=>{D1.init(t,e),ap.init(t,e)});function PA(t){return PU(Hl,t)}function Hne(t){return OU(Hl,t)}function Wne(t){return NU(Hl,t)}function Yne(t){return kU(Hl,t)}function Kne(t){return MU(Hl,t)}var cp=P("ZodBoolean",(t,e)=>{K_.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>cF(t,r,n,i)});function aB(t){return DU(cp,t)}var lp=P("ZodBigInt",(t,e)=>{Bw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>lF(t,n,i,o),t.gte=(n,i)=>t.check(Dr(n,i)),t.min=(n,i)=>t.check(Dr(n,i)),t.gt=(n,i)=>t.check(Eo(n,i)),t.gte=(n,i)=>t.check(Dr(n,i)),t.min=(n,i)=>t.check(Dr(n,i)),t.lt=(n,i)=>t.check(So(n,i)),t.lte=(n,i)=>t.check(bn(n,i)),t.max=(n,i)=>t.check(bn(n,i)),t.positive=n=>t.check(Eo(BigInt(0),n)),t.negative=n=>t.check(So(BigInt(0),n)),t.nonpositive=n=>t.check(bn(BigInt(0),n)),t.nonnegative=n=>t.check(Dr(BigInt(0),n)),t.multipleOf=(n,i)=>t.check(Ha(n,i));let r=t._zod.bag;t.minValue=r.minimum??null,t.maxValue=r.maximum??null,t.format=r.format??null});function Zne(t){return $U(lp,t)}var KA=P("ZodBigIntFormat",(t,e)=>{L1.init(t,e),lp.init(t,e)});function Jne(t){return FU(KA,t)}function Xne(t){return BU(KA,t)}var cB=P("ZodSymbol",(t,e)=>{$1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>uF(t,r,n,i)});function Qne(t){return jU(cB,t)}var lB=P("ZodUndefined",(t,e)=>{U1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>fF(t,r,n,i)});function eie(t){return zU(lB,t)}var uB=P("ZodNull",(t,e)=>{F1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>dF(t,r,n,i)});function dB(t){return GU(uB,t)}var fB=P("ZodAny",(t,e)=>{B1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>mF(t,r,n,i)});function tie(){return qU(fB)}var pB=P("ZodUnknown",(t,e)=>{j1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>gF(t,r,n,i)});function Vl(){return VU(pB)}var hB=P("ZodNever",(t,e)=>{z1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>hF(t,r,n,i)});function ZA(t){return HU(hB,t)}var mB=P("ZodVoid",(t,e)=>{G1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>pF(t,r,n,i)});function rie(t){return WU(mB,t)}var ly=P("ZodDate",(t,e)=>{q1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>_F(t,n,i,o),t.min=(n,i)=>t.check(Dr(n,i)),t.max=(n,i)=>t.check(bn(n,i));let r=t._zod.bag;t.minDate=r.minimum?new Date(r.minimum):null,t.maxDate=r.maximum?new Date(r.maximum):null});function nie(t){return YU(ly,t)}var gB=P("ZodArray",(t,e)=>{V1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>CF(t,r,n,i),t.element=e.element,ay(t,"ZodArray",{min(r,n){return this.check(Is(r,n))},nonempty(r){return this.check(Is(1,r))},max(r,n){return this.check(Gl(r,n))},length(r,n){return this.check(ql(r,n))},unwrap(){return this.element}})});function uy(t,e){return JU(gB,t,e)}function iie(t){let e=t._zod.def.shape;return XA(Object.keys(e))}var dy=P("ZodObject",(t,e)=>{H1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>PF(t,r,n,i),re.defineLazy(t,"shape",()=>e.shape),ay(t,"ZodObject",{keyof(){return XA(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Vl()})},loose(){return this.clone({...this._zod.def,catchall:Vl()})},strict(){return this.clone({...this._zod.def,catchall:ZA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return re.extend(this,r)},safeExtend(r){return re.safeExtend(this,r)},merge(r){return re.merge(this,r)},pick(r){return re.pick(this,r)},omit(r){return re.omit(this,r)},partial(...r){return re.partial(eR,this,r[0])},required(...r){return re.required(tR,this,r[0])}})});function oie(t,e){let r={type:"object",shape:t??{},...re.normalizeParams(e)};return new dy(r)}function sie(t,e){return new dy({type:"object",shape:t,catchall:ZA(),...re.normalizeParams(e)})}function aie(t,e){return new dy({type:"object",shape:t,catchall:Vl(),...re.normalizeParams(e)})}var fy=P("ZodUnion",(t,e)=>{Z_.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vA(t,r,n,i),t.options=e.options});function JA(t,e){return new fy({type:"union",options:t,...re.normalizeParams(e)})}var _B=P("ZodXor",(t,e)=>{fy.init(t,e),W1.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vA(t,r,n,i),t.options=e.options});function cie(t,e){return new _B({type:"union",options:t,inclusive:!1,...re.normalizeParams(e)})}var yB=P("ZodDiscriminatedUnion",(t,e)=>{fy.init(t,e),Y1.init(t,e)});function lie(t,e,r){return new yB({type:"union",options:e,discriminator:t,...re.normalizeParams(r)})}var SB=P("ZodIntersection",(t,e)=>{K1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>OF(t,r,n,i)});function EB(t,e){return new SB({type:"intersection",left:t,right:e})}var vB=P("ZodTuple",(t,e)=>{jw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>NF(t,r,n,i),t.rest=r=>t.clone({...t._zod.def,rest:r})});function bB(t,e,r){let n=e instanceof ke,i=n?r:e,o=n?e:null;return new vB({type:"tuple",items:t,rest:o,...re.normalizeParams(i)})}var np=P("ZodRecord",(t,e)=>{Z1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>kF(t,r,n,i),t.keyType=e.keyType,t.valueType=e.valueType});function TB(t,e,r){return!e||!e._zod?new np({type:"record",keyType:ny(),valueType:t,...re.normalizeParams(e)}):new np({type:"record",keyType:t,valueType:e,...re.normalizeParams(r)})}function uie(t,e,r){let n=kr(t);return n._zod.values=void 0,new np({type:"record",keyType:n,valueType:e,...re.normalizeParams(r)})}function die(t,e,r){return new np({type:"record",keyType:t,valueType:e,mode:"loose",...re.normalizeParams(r)})}var xB=P("ZodMap",(t,e)=>{J1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>RF(t,r,n,i),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(vo(...r)),t.nonempty=r=>t.check(vo(1,r)),t.max=(...r)=>t.check(Wa(...r)),t.size=(...r)=>t.check(zl(...r))});function fie(t,e,r){return new xB({type:"map",keyType:t,valueType:e,...re.normalizeParams(r)})}var wB=P("ZodSet",(t,e)=>{X1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>IF(t,r,n,i),t.min=(...r)=>t.check(vo(...r)),t.nonempty=r=>t.check(vo(1,r)),t.max=(...r)=>t.check(Wa(...r)),t.size=(...r)=>t.check(zl(...r))});function pie(t,e){return new wB({type:"set",valueType:t,...re.normalizeParams(e)})}var ip=P("ZodEnum",(t,e)=>{Q1.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(n,i,o)=>yF(t,n,i,o),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ip({...e,checks:[],...re.normalizeParams(i),entries:o})},t.exclude=(n,i)=>{let o={...e.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new ip({...e,checks:[],...re.normalizeParams(i),entries:o})}});function XA(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ip({type:"enum",entries:r,...re.normalizeParams(e)})}function hie(t,e){return new ip({type:"enum",entries:t,...re.normalizeParams(e)})}var AB=P("ZodLiteral",(t,e)=>{eU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>SF(t,r,n,i),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function mie(t,e){return new AB({type:"literal",values:Array.isArray(t)?t:[t],...re.normalizeParams(e)})}var RB=P("ZodFile",(t,e)=>{tU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bF(t,r,n,i),t.min=(r,n)=>t.check(vo(r,n)),t.max=(r,n)=>t.check(Wa(r,n)),t.mime=(r,n)=>t.check(Yf(Array.isArray(r)?r:[r],n))});function gie(t){return XU(RB,t)}var IB=P("ZodTransform",(t,e)=>{rU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>AF(t,r,n,i),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ja(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(re.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),r.issues.push(re.issue(s))}};let i=e.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function QA(t){return new IB({type:"transform",transform:t})}var eR=P("ZodOptional",(t,e)=>{zw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bA(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function oy(t){return new eR({type:"optional",innerType:t})}var CB=P("ZodExactOptional",(t,e)=>{nU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>bA(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function PB(t){return new CB({type:"optional",innerType:t})}var OB=P("ZodNullable",(t,e)=>{iU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>MF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function sy(t){return new OB({type:"nullable",innerType:t})}function _ie(t){return oy(sy(t))}var NB=P("ZodDefault",(t,e)=>{oU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>LF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function kB(t,e){return new NB({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():re.shallowClone(e)}})}var MB=P("ZodPrefault",(t,e)=>{sU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>$F(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function DB(t,e){return new MB({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():re.shallowClone(e)}})}var tR=P("ZodNonOptional",(t,e)=>{aU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>DF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function LB(t,e){return new tR({type:"nonoptional",innerType:t,...re.normalizeParams(e)})}var $B=P("ZodSuccess",(t,e)=>{cU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>TF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function yie(t){return new $B({type:"success",innerType:t})}var UB=P("ZodCatch",(t,e)=>{lU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>UF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function FB(t,e){return new UB({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var BB=P("ZodNaN",(t,e)=>{uU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>EF(t,r,n,i)});function Sie(t){return ZU(BB,t)}var py=P("ZodPipe",(t,e)=>{Gw.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>FF(t,r,n,i),t.in=e.in,t.out=e.out});function OA(t,e){return new py({type:"pipe",in:t,out:e})}var hy=P("ZodCodec",(t,e)=>{py.init(t,e),J_.init(t,e)});function Eie(t,e,r){return new hy({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function vie(t){let e=t._zod.def;return new hy({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var jB=P("ZodPreprocess",(t,e)=>{py.init(t,e),dU.init(t,e)}),zB=P("ZodReadonly",(t,e)=>{fU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>BF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function GB(t){return new zB({type:"readonly",innerType:t})}var qB=P("ZodTemplateLiteral",(t,e)=>{pU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>vF(t,r,n,i)});function bie(t,e){return new qB({type:"template_literal",parts:t,...re.normalizeParams(e)})}var VB=P("ZodLazy",(t,e)=>{gU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>zF(t,r,n,i),t.unwrap=()=>t._zod.def.getter()});function HB(t){return new VB({type:"lazy",getter:t})}var WB=P("ZodPromise",(t,e)=>{mU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>jF(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function Tie(t){return new WB({type:"promise",innerType:t})}var YB=P("ZodFunction",(t,e)=>{hU.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>wF(t,r,n,i)});function xie(t){return new YB({type:"function",input:Array.isArray(t?.input)?bB(t?.input):t?.input??uy(Vl()),output:t?.output??Vl()})}var my=P("ZodCustom",(t,e)=>{_U.init(t,e),$e.init(t,e),t._zod.processJSONSchema=(r,n,i)=>xF(t,r,n,i)});function wie(t){let e=new ct({check:"custom"});return e._zod.check=t,e}function Aie(t,e){return QU(my,t??(()=>!0),e)}function KB(t,e={}){return eF(my,t,e)}function ZB(t,e){return tF(t,e)}var Rie=rF,Iie=nF;function Cie(t,e={}){let r=new my({type:"custom",check:"custom",fn:n=>n instanceof t,abort:!0,...re.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=n=>{n.value instanceof t||n.issues.push({code:"invalid_type",expected:t.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Pie=(...t)=>iF({Codec:hy,Boolean:cp,String:op},...t);function Oie(t){let e=HB(()=>JA([ny(t),sB(),aB(),dB(),uy(e),TB(ny(),e)]));return e}function Nie(t,e){return new jB({type:"pipe",in:QA(t),out:e})}var cUe={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function lUe(t){Tt({customError:t})}function uUe(){return Tt().customError}var JB;JB||(JB={});var pe={...ry,...wA,iso:rp},dUe=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function fUe(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function pUe(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let n=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!e.defs[i])throw new Error(`Reference not found: ${t}`);return e.defs[i]}throw new Error(`Reference not found: ${t}`)}function kie(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return pe.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let i=t.$ref;if(e.refs.has(i))return e.refs.get(i);if(e.processing.has(i))return pe.lazy(()=>{if(!e.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return e.refs.get(i)});e.processing.add(i);let o=pUe(i,e),s=gr(o,e);return e.refs.set(i,s),e.processing.delete(i),s}if(t.enum!==void 0){let i=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&i.length===1&&i[0]===null)return pe.null();if(i.length===0)return pe.never();if(i.length===1)return pe.literal(i[0]);if(i.every(s=>typeof s=="string"))return pe.enum(i);let o=i.map(s=>pe.literal(s));return o.length<2?o[0]:pe.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return pe.literal(t.const);let r=t.type;if(Array.isArray(r)){let i=r.map(o=>{let s={...t,type:o};return kie(s,e)});return i.length===0?pe.never():i.length===1?i[0]:pe.union(i)}if(!r)return pe.any();let n;switch(r){case"string":{let i=pe.string();if(t.format){let o=t.format;o==="email"?i=i.check(pe.email()):o==="uri"||o==="uri-reference"?i=i.check(pe.url()):o==="uuid"||o==="guid"?i=i.check(pe.uuid()):o==="date-time"?i=i.check(pe.iso.datetime()):o==="date"?i=i.check(pe.iso.date()):o==="time"?i=i.check(pe.iso.time()):o==="duration"?i=i.check(pe.iso.duration()):o==="ipv4"?i=i.check(pe.ipv4()):o==="ipv6"?i=i.check(pe.ipv6()):o==="mac"?i=i.check(pe.mac()):o==="cidr"?i=i.check(pe.cidrv4()):o==="cidr-v6"?i=i.check(pe.cidrv6()):o==="base64"?i=i.check(pe.base64()):o==="base64url"?i=i.check(pe.base64url()):o==="e164"?i=i.check(pe.e164()):o==="jwt"?i=i.check(pe.jwt()):o==="emoji"?i=i.check(pe.emoji()):o==="nanoid"?i=i.check(pe.nanoid()):o==="cuid"?i=i.check(pe.cuid()):o==="cuid2"?i=i.check(pe.cuid2()):o==="ulid"?i=i.check(pe.ulid()):o==="xid"?i=i.check(pe.xid()):o==="ksuid"&&(i=i.check(pe.ksuid()))}typeof t.minLength=="number"&&(i=i.min(t.minLength)),typeof t.maxLength=="number"&&(i=i.max(t.maxLength)),t.pattern&&(i=i.regex(new RegExp(t.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?pe.number().int():pe.number();typeof t.minimum=="number"&&(i=i.min(t.minimum)),typeof t.maximum=="number"&&(i=i.max(t.maximum)),typeof t.exclusiveMinimum=="number"?i=i.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(i=i.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?i=i.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(i=i.lt(t.maximum)),typeof t.multipleOf=="number"&&(i=i.multipleOf(t.multipleOf)),n=i;break}case"boolean":{n=pe.boolean();break}case"null":{n=pe.null();break}case"object":{let i={},o=t.properties||{},s=new Set(t.required||[]);for(let[c,l]of Object.entries(o)){let u=gr(l,e);i[c]=s.has(c)?u:u.optional()}if(t.propertyNames){let c=gr(t.propertyNames,e),l=t.additionalProperties&&typeof t.additionalProperties=="object"?gr(t.additionalProperties,e):pe.any();if(Object.keys(i).length===0){n=pe.record(c,l);break}let u=pe.object(i).passthrough(),d=pe.looseRecord(c,l);n=pe.intersection(u,d);break}if(t.patternProperties){let c=t.patternProperties,l=Object.keys(c),u=[];for(let f of l){let p=gr(c[f],e),h=pe.string().regex(new RegExp(f));u.push(pe.looseRecord(h,p))}let d=[];if(Object.keys(i).length>0&&d.push(pe.object(i).passthrough()),d.push(...u),d.length===0)n=pe.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=pe.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=pe.intersection(f,d[p]);n=f}break}let a=pe.object(i);t.additionalProperties===!1?n=a.strict():typeof t.additionalProperties=="object"?n=a.catchall(gr(t.additionalProperties,e)):n=a.passthrough();break}case"array":{let i=t.prefixItems,o=t.items;if(i&&Array.isArray(i)){let s=i.map(c=>gr(c,e)),a=o&&typeof o=="object"&&!Array.isArray(o)?gr(o,e):void 0;a?n=pe.tuple(s).rest(a):n=pe.tuple(s),typeof t.minItems=="number"&&(n=n.check(pe.minLength(t.minItems))),typeof t.maxItems=="number"&&(n=n.check(pe.maxLength(t.maxItems)))}else if(Array.isArray(o)){let s=o.map(c=>gr(c,e)),a=t.additionalItems&&typeof t.additionalItems=="object"?gr(t.additionalItems,e):void 0;a?n=pe.tuple(s).rest(a):n=pe.tuple(s),typeof t.minItems=="number"&&(n=n.check(pe.minLength(t.minItems))),typeof t.maxItems=="number"&&(n=n.check(pe.maxLength(t.maxItems)))}else if(o!==void 0){let s=gr(o,e),a=pe.array(s);typeof t.minItems=="number"&&(a=a.min(t.minItems)),typeof t.maxItems=="number"&&(a=a.max(t.maxItems)),n=a}else n=pe.array(pe.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function gr(t,e){if(typeof t=="boolean")return t?pe.any():pe.never();let r=kie(t,e),n=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let a=t.anyOf.map(l=>gr(l,e)),c=pe.union(a);r=n?pe.intersection(r,c):c}if(t.oneOf&&Array.isArray(t.oneOf)){let a=t.oneOf.map(l=>gr(l,e)),c=pe.xor(a);r=n?pe.intersection(r,c):c}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=n?r:pe.any();else{let a=n?r:gr(t.allOf[0],e),c=n?0:1;for(let l=c;l<t.allOf.length;l++)a=pe.intersection(a,gr(t.allOf[l],e));r=a}t.nullable===!0&&e.version==="openapi-3.0"&&(r=pe.nullable(r)),t.readOnly===!0&&(r=pe.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in t&&(i[a]=t[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in t&&(i[a]=t[a]);for(let a of Object.keys(t))dUe.has(a)||(i[a]=t[a]);return Object.keys(i).length>0&&e.registry.add(r,i),t.description&&(r=r.describe(t.description)),r}function Mie(t,e){if(typeof t=="boolean")return t?pe.any():pe.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=fUe(r,e?.defaultTarget),i=r.$defs||r.definitions||{},o={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??ur};return gr(r,o)}var XB={};pr(XB,{bigint:()=>_Ue,boolean:()=>gUe,date:()=>yUe,number:()=>mUe,string:()=>hUe});function hUe(t){return vU(op,t)}function mUe(t){return CU(ap,t)}function gUe(t){return LU(cp,t)}function _Ue(t){return UU(lp,t)}function yUe(t){return KU(ly,t)}Tt(qw());var SUe={questions:Tn.array(Tn.object({question:Tn.string(),header:Tn.string().optional().describe('Very short topic label rendered as a tag above the question, max ~12 characters (e.g. "Framework")'),multiSelect:Tn.boolean().optional(),options:Tn.array(Tn.object({label:Tn.string(),description:Tn.string().optional()})).optional()})).min(1).max(3)},up=Tn.object(SUe);import QB from"path";import EUe from"fs/promises";var ej=ye("agent-output-utils");async function Ja({initialResult:t,agentName:e,hasError:r}){let n="",i=QB.join(process.cwd(),ar,Sl);try{let o=await EUe.readFile(i,"utf-8");o&&(n=o,ej.log(`Pulled result from ${QB.relative(process.cwd(),i)}`))}catch{ej.log(`No results file found at ${QB.relative(process.cwd(),i)}`)}return n||(!t&&!r?`${e} has finished working on task.`:t||void 0)}var vUe=[/^API Error:\s*\d{3}/i,/^\d{3}\s*status code/i,/^API request failed:\s*\d{3}/i,/^API Error: The socket connection was closed/i,/^overloaded_error/i];function rR(t){let e=t.trim();return vUe.some(r=>r.test(e))?"Encountered a temporary issue \u2014 the agent will attempt to continue.":t}function Xa({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),i&&ej.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function Qa(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ec(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider"))}import nR from"process";import{fileURLToPath as AUe}from"url";import{createRequire as RUe}from"module";import iR from"path";import{readdir as bUe,rm as TUe}from"fs/promises";import{join as xUe}from"path";async function Die(t,e=[]){let n=(await bUe(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>TUe(xUe(t,i),{recursive:!0,force:!0})))}var wUe=700,Lie=t=>t.mode==="create"&&(t.accountType===Yg||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=wUe);var IUe=iR.dirname(AUe(import.meta.url)),$ie=RUe(import.meta.url),CUe=iR.resolve(IUe,"scripts/scaffold.js"),PUe="scripts/scaffold.js",OUe=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,tj=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},NUe=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),kUe=t=>{let e=tj(t);return e==="node"||e.endsWith("/node")},Ps=t=>{if(typeof t!="string")return!1;let e=t.match(OUe)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&NUe(tj(e[r]));)r+=1;if(r>=e.length||!kUe(e[r]))return!1;let n=e[r+1];return n?tj(n).includes(PUe):!1},dp=ye("create_stage"),Uie="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",MUe=`${Uie}
|
|
210
210
|
|
|
211
211
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,DUe=`${Uie}
|
|
212
212
|
|
|
@@ -263,29 +263,29 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${UUe}}" ${e} ${r} <template-id> [--p
|
|
|
263
263
|
|
|
264
264
|
Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",s="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.";return(n?[s,$Ue,o]:[s,o,LUe]).filter(Boolean).join(`
|
|
265
265
|
|
|
266
|
-
`)},Fie=async({config:t,cwd:e=nR.cwd()})=>await ft(qe(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await Die(e,[".netlify",".git","node_modules"]),dp.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=FUe({cwd:e}),s=[];if(o){let u=[o,"--list-addons-json"];dp.log(`Running ${i} ${u.join(" ")}`);let{stdout:d}=await Nr(i,u);s=BUe(d),dp.info("Retrieved add-ons")}else dp.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),fe.inc("context.degraded",1,{component:"templates"});let a=We().creditWrapUpEnabled&&Lie(t);a&&dp.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,enforcedAICreditsRemaining:t.enforcedAICreditsRemaining}),fe.inc("create.budget_constrained",1,{constrained:a});let c=jUe({templates:s,nodeCmd:i,scaffoldScriptPath:CUe,budgetConstrained:a}),l=performance.now()-n;return r?.setAttributes({"create.duration.ms":l,"create.status":"success","create.budget_constrained":a}),{additionalContext:c}});var Os={Task:{name:"Task",category:Y.Task},Agent:{name:"Task",category:Y.Task},SendMessage:{name:"Message agent",category:Y.Task},TaskOutput:{name:"Get task output",category:Y.Task},TaskStop:{name:"Stop task",category:Y.Task},TaskCreate:{name:"Update task list",category:Y.Todo},TaskUpdate:{name:"Update task list",category:Y.Todo},TaskList:{name:"Read task list",category:Y.Todo},TaskGet:{name:"Read task list",category:Y.Todo},ToolSearch:{name:"Load tools",category:Y.Explore},Skill:{name:"Use skill",category:Y.Skill},EnterPlanMode:{name:"Start planning",category:Y.Plan},ListMcpResources:{name:"List resources",category:Y.Explore},ReadMcpResource:{name:"Read resource",category:Y.Explore},Bash:{name:"Run command",category:Y.RunCommand},Glob:{name:"Find files",category:Y.Explore},Grep:{name:"Search files",category:Y.Explore},LS:{name:"List directory",category:Y.Explore},ExitPlanMode:{name:"Exit planning",category:Y.Plan},Read:{name:"Read file",category:Y.FileRead},Edit:{name:"Edit file",category:Y.FileWrite},MultiEdit:{name:"Edit multiple files",category:Y.FileWrite},Write:{name:"Edit file",category:Y.FileWrite},NotebookEdit:{name:"Edit notebook",category:Y.Notebook},WebFetch:{name:"Fetch web",category:Y.Web},TodoWrite:{name:"Update task list",category:Y.Todo},WebSearch:{name:"Search web",category:Y.Web},BashOutput:{name:"Get command output",category:Y.RunCommand},KillBash:{name:"Stop command",category:Y.RunCommand}},gy=t=>{if(Os[t])return Os[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},
|
|
266
|
+
`)},Fie=async({config:t,cwd:e=nR.cwd()})=>await ft(qe(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await Die(e,[".netlify",".git","node_modules"]),dp.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=FUe({cwd:e}),s=[];if(o){let u=[o,"--list-addons-json"];dp.log(`Running ${i} ${u.join(" ")}`);let{stdout:d}=await Nr(i,u);s=BUe(d),dp.info("Retrieved add-ons")}else dp.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),fe.inc("context.degraded",1,{component:"templates"});let a=We().creditWrapUpEnabled&&Lie(t);a&&dp.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,enforcedAICreditsRemaining:t.enforcedAICreditsRemaining}),fe.inc("create.budget_constrained",1,{constrained:a});let c=jUe({templates:s,nodeCmd:i,scaffoldScriptPath:CUe,budgetConstrained:a}),l=performance.now()-n;return r?.setAttributes({"create.duration.ms":l,"create.status":"success","create.budget_constrained":a}),{additionalContext:c}});var Os={Task:{name:"Task",category:Y.Task},Agent:{name:"Task",category:Y.Task},SendMessage:{name:"Message agent",category:Y.Task},TaskOutput:{name:"Get task output",category:Y.Task},TaskStop:{name:"Stop task",category:Y.Task},TaskCreate:{name:"Update task list",category:Y.Todo},TaskUpdate:{name:"Update task list",category:Y.Todo},TaskList:{name:"Read task list",category:Y.Todo},TaskGet:{name:"Read task list",category:Y.Todo},ToolSearch:{name:"Load tools",category:Y.Explore},Skill:{name:"Use skill",category:Y.Skill},EnterPlanMode:{name:"Start planning",category:Y.Plan},ListMcpResources:{name:"List resources",category:Y.Explore},ReadMcpResource:{name:"Read resource",category:Y.Explore},Bash:{name:"Run command",category:Y.RunCommand},Glob:{name:"Find files",category:Y.Explore},Grep:{name:"Search files",category:Y.Explore},LS:{name:"List directory",category:Y.Explore},ExitPlanMode:{name:"Exit planning",category:Y.Plan},Read:{name:"Read file",category:Y.FileRead},Edit:{name:"Edit file",category:Y.FileWrite},MultiEdit:{name:"Edit multiple files",category:Y.FileWrite},Write:{name:"Edit file",category:Y.FileWrite},NotebookEdit:{name:"Edit notebook",category:Y.Notebook},WebFetch:{name:"Fetch web",category:Y.Web},TodoWrite:{name:"Update task list",category:Y.Todo},WebSearch:{name:"Search web",category:Y.Web},BashOutput:{name:"Get command output",category:Y.RunCommand},KillBash:{name:"Stop command",category:Y.RunCommand}},gy=t=>{if(Os[t])return Os[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},rj=t=>t==="Task"||t==="Agent",Bie=t=>{let[e=""]=t.split(`
|
|
267
267
|
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},jie=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var _r=ye("runner_claude"),oR="Claude Code",Gie="claude-opus-4-8",GUe={[Yg]:"claude-sonnet-5"},qUe=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(_r.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(_r.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(_r.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function qie({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("anthropic",r))throw new Error(`Model '${r}' is not available for anthropic provider`)}else{let i=GUe[e.accountType],o=i||Gie;!!o&&await t.isModelAvailableForProvider("anthropic",o)?(_r.log(`Using ${i?"account override":"default"} model: ${o}`),n=o):o&&_r.log(`Model ${o} is not available, proceeding without model specification`)}return n}function Vie({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...pp.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!pp.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...pp.env}}async function VUe(){let t=_y.join(pp.cwd(),"AGENTS.md");try{await fp.access(t)}catch{return}let e=_y.join(pp.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await fp.readFile(e,"utf-8")).includes(r))return;await fp.appendFile(e,`
|
|
268
268
|
${r}
|
|
269
269
|
`)}catch{await fp.writeFile(e,`${r}
|
|
270
|
-
`)}_r.log("Added @AGENTS.md import to CLAUDE.local.md")}async function
|
|
270
|
+
`)}_r.log("Added @AGENTS.md import to CLAUDE.local.md")}async function nj({config:t,netlify:e,persistSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=pp.cwd(),abortSignal:a,onSessionId:c,effortOverride:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await VUe();let h=Vie({aiGateway:n}),m=await qie({config:t,aiGateway:n,model:f}),y=[],S=[],T={},x=new Set,v=[],N=k=>k?.match(/task\s+#([\w-]+)\s+created/i)?.[1],R=k=>{if(typeof k=="string")return k;if(Array.isArray(k))return k.filter(A=>A?.type==="text"&&typeof A.text=="string").map(A=>A.text).join(`
|
|
271
271
|
`)||void 0},U=(k,F)=>{let A=k.input||{};if(k.name==="TaskCreate"){v.push({id:N(F),subject:typeof A.subject=="string"?A.subject:"",activeForm:typeof A.activeForm=="string"?A.activeForm:void 0,status:"pending"});return}let J=typeof A.taskId=="string"?A.taskId:void 0,ne=J===void 0?void 0:v.find(xe=>xe.id===J);if(!ne&&typeof A.subject=="string"){let xe=v.filter(it=>it.subject===A.subject);xe.length===1&&(ne=xe[0])}if(A.status==="deleted"){ne&&v.splice(v.indexOf(ne),1);return}if(!ne){if(J===void 0||typeof A.subject!="string"&&typeof A.activeForm!="string")return;ne={id:J,subject:"",status:"pending"},v.push(ne)}typeof A.status=="string"&&(ne.status=A.status),typeof A.subject=="string"&&(ne.subject=A.subject),typeof A.activeForm=="string"&&(ne.activeForm=A.activeForm)},C=()=>v.map(k=>({name:k.status==="in_progress"&&k.activeForm||k.subject,value:k.status})),D=0,j=0,_,ae,I,g,E="",w="mode"in t&&t.mode==="create"&&t.accountType===Yg,W="mode"in t&&t.mode==="ask",G=We().questionsEnabled,ce=w&&!We().creditWrapUpEnabled,Te=["ExitPlanMode","EnterPlanMode","AskUserQuestion"];ce&&Te.push("TodoWrite","TaskCreate","TaskUpdate","TaskList","TaskGet"),W&&Te.push("Edit","Write","NotebookEdit","EnterWorktree","Bash(git push:*)","Bash(netlify deploy:*)");let we=l??(ce?"low":"high"),Ce=mo(s,"claude");if(!Ce)throw new Error("Claude CLI binary not found");let V=G?await Lte():void 0,De=["--permission-mode","bypassPermissions","--dangerously-skip-permissions","--output-format","stream-json","--verbose","--disallowed-tools",Te.join(","),...V?.args??[],"--effort",we,...m?["--model",m]:[],...i?o?["--resume",o]:["--continue"]:[],"-p"];_r.log(`Running ${Ce} ${De.join(" ")}`);let be=e.utils.run(Ce,De,{all:!0,env:h,cwd:s,idleTimeout:ds,cancelSignal:a});be.stdin?.end(d);let ee=Na(()=>{r?.({steps:y,duration:j})},250),ie=(k,F)=>{let{wrapMessage:A,...J}=k,ne=jx({...J,id:D});ne.message&&(ne.message=ne.message.replace(/\n?<system-reminder>.+?<\/system-reminder>\n?/gs,"").trim(),A&&ne.message&&(ne.message=`\`\`\`
|
|
272
272
|
${ne.message}
|
|
273
|
-
\`\`\``)),D+=1,S.push(ne),y.push(ne),F||ee.flush(),ee(),F&&ee.flush()},Re=m||Gie,te=ce?`Using ${oR} in low credit usage mode due to low remaining credits. Setting model to ${Re} and extra effort to low`:`Using ${oR} with ${Re}`;ie({title:te,category:Y.Environment},!0);let Ae=zUe.createInterface({input:be.all});Ae.on("error",k=>{_r.error("Readline interface error",{error:k.message,stack:k.stack})}),Ae.on("line",k=>{let F=null;try{F=JSON.parse(k)}catch{_r.log("Could not parse line",k)}F?.session_id&&F.session_id!==p&&(p=F.session_id,c?.(p)),Array.isArray(F?.message?.content)?F.message.content.forEach(A=>{switch(A.type){case"text":{if(A.text){if(A.text.startsWith("Base directory for this skill:"))break;F.message?.role!=="user"&&(E=A.text),ie({message:A.text,category:F.message?.role==="user"?Y.UserMessage:Y.AgentMessage,parentGroupId:F.parent_tool_use_id||void 0})}break}case"image":{typeof A.source=="object"&&A.source&&A.source.type==="base64"&&A.source.media_type?ie({message:``,category:Y.AgentMessage,parentGroupId:F.parent_tool_use_id||void 0}):_r.log(`Unsupported image type ${A.source?.type}`,A.source);break}case"tool_use":{if(A.name&&!Os[A.name]&&!x.has(A.name)&&(x.add(A.name),_r.log(`Unmapped tool in stream: ${A.name}`)),
|
|
273
|
+
\`\`\``)),D+=1,S.push(ne),y.push(ne),F||ee.flush(),ee(),F&&ee.flush()},Re=m||Gie,te=ce?`Using ${oR} in low credit usage mode due to low remaining credits. Setting model to ${Re} and extra effort to low`:`Using ${oR} with ${Re}`;ie({title:te,category:Y.Environment},!0);let Ae=zUe.createInterface({input:be.all});Ae.on("error",k=>{_r.error("Readline interface error",{error:k.message,stack:k.stack})}),Ae.on("line",k=>{let F=null;try{F=JSON.parse(k)}catch{_r.log("Could not parse line",k)}F?.session_id&&F.session_id!==p&&(p=F.session_id,c?.(p)),Array.isArray(F?.message?.content)?F.message.content.forEach(A=>{switch(A.type){case"text":{if(A.text){if(A.text.startsWith("Base directory for this skill:"))break;F.message?.role!=="user"&&(E=A.text),ie({message:A.text,category:F.message?.role==="user"?Y.UserMessage:Y.AgentMessage,parentGroupId:F.parent_tool_use_id||void 0})}break}case"image":{typeof A.source=="object"&&A.source&&A.source.type==="base64"&&A.source.media_type?ie({message:``,category:Y.AgentMessage,parentGroupId:F.parent_tool_use_id||void 0}):_r.log(`Unsupported image type ${A.source?.type}`,A.source);break}case"tool_use":{if(A.name&&!Os[A.name]&&!x.has(A.name)&&(x.add(A.name),_r.log(`Unmapped tool in stream: ${A.name}`)),rj(A.name)){let J=A.input?.description&&`\`${A.input.description}\``;ie({title:[gy(A.name),J].filter(Boolean).join(" "),category:Os[A.name]?.category,groupId:A.id,parentGroupId:F.parent_tool_use_id||void 0})}else A.name==="Bash"&&Ps(A.input?.command)&&ie({title:"Generating the site",category:Y.SiteGeneration,groupId:A.id,parentGroupId:F.parent_tool_use_id||void 0});if(A.name===KL&&A.id&&!g){let J=up.safeParse(A.input);J.success?(g={questions:J.data.questions,toolUseId:A.id},be.kill()):(_r.warn("Ignoring malformed ask tool input",{toolUseId:A.id}),fe.inc("inference.malformed_ask",1))}A.id&&(T[A.id]=A),ee.flush();break}case"tool_result":{let J=A.tool_use_id?T[A.tool_use_id]:void 0;if(J?.name===KL)break;let ne=rj(J?.name),xe=J?.name==="Bash"&&Ps(J?.input?.command);if(J?.name==="Skill"&&J?.input?.skill){let Ge=go(J.input.skill?.toString());Ss(_r,Ge),ie({title:`Use ${Ge}`,category:Y.Skill,type:J.input.skill?.toString(),parentGroupId:F.parent_tool_use_id||void 0},!0);break}if(J?.name==="TodoWrite"){let{name:Ge,category:ot}=Os.TodoWrite;ie({title:Ge,category:ot,parentGroupId:F.parent_tool_use_id||void 0,tasks:F.tool_use_result?.newTodos?.map(Cu=>({name:Cu.status==="in_progress"?Cu.activeForm:Cu.content,value:Cu.status}))},!0);break}if(J?.name==="TaskCreate"||J?.name==="TaskUpdate"){A.is_error||U(J,R(A.content)),ie({title:gy(J.name),category:Y.Todo,parentGroupId:F.parent_tool_use_id||void 0,tasks:C()},!0);break}if(J?.name&&jie.has(J.name)){let Ge=Os[J.name]?.category||Y.Tool,ot=Ge===Y.Todo&&v.length>0;ie({title:gy(J.name),category:Ge===Y.Todo&&!ot?Y.Tool:Ge,parentGroupId:F.parent_tool_use_id||void 0,...ot?{tasks:C()}:{}},!0);break}let it=!!(J?.name&&Os[J.name]),Nt;if(!ne&&!xe&&J){let Ge=J.input?.file_path&&_y.relative(s,J.input.file_path);Ge||(Ge=J.input?.pattern||J.input?.command);let ot=Ge&&`\`${Ge}\``;Nt=[gy(J.name||""),ot].filter(Boolean).join(" ")}else!ne&&!xe&&!J&&(Nt="Tool result");let At=["Bash","Glob","Grep","LS","Read","Edit","Write","TaskOutput"].includes(J?.name||"")||!ne&&!xe&&!it,ge=F.parent_tool_use_id||void 0;!ge&&(ne||xe)&&(ge=A.tool_use_id);let Pe,Lt=ne&&F.tool_use_result?.content||A.content;if(typeof Lt=="string")Pe=Lt;else if(Array.isArray(Lt)){let Ge=[];Lt.forEach(ot=>{ot?.type==="text"&&typeof ot.text=="string"?Ge.push(ot.text):ot?.type==="image"&&typeof ot.source=="object"&&ot.source?ot.source.type==="base64"&&ot.source.media_type?Ge.push(``):_r.log(`Unsupported image type ${ot.source.type}`,ot.source):_r.log(`Unsupported block type ${ot?.type}`)}),Pe=Ge.join(`
|
|
274
274
|
|
|
275
|
-
`)}if(ne&&Pe&&Bie(Pe)){ie({title:"Running in background",category:Y.Task,parentGroupId:ge},!0);break}ie({title:Nt,message:Pe,wrapMessage:At,category:ne?Y.AgentMessage:xe?Y.SiteGeneration:Os[J?.name??""]?.category||Y.Tool,parentGroupId:ge},!0);break}case"thinking":{A.thinking&&ie({title:"Reasoning",message:A.thinking,category:Y.Reasoning,parentGroupId:F.parent_tool_use_id||void 0},!0);break}default:_r.log(`Message content type is not supported ${A.type}`,A)}}):F?.type==="result"&&(j=F.duration_ms||0,F.is_error?g||(ae=F.result):_=F.result,F.usage&&(so(F.usage),I=F.usage),[S,y].forEach(A=>{A[A.length-1]?.message===_&&A.pop()}))});let K=!1;if(await be.catch(k=>{K=Of(k,a),{error:ae,result:_}=qUe({catchError:k,runCmd:be,error:ae,result:_,runnerName:"Claude"})}),V&&await fp.rm(V.mcpConfigPath,{force:!0}).catch(()=>{}),Ae.close(),ee.flush(),g)return{steps:S,duration:j,agentSessionId:p,resolvedModel:m,effort:we,usage:I,pendingInteraction:g};let M=K;return M&&(!_&&E.trim()&&(_=E.trim()),ae=void 0),{steps:S,duration:j,result:await Ja({initialResult:_,agentName:oR,hasError:!!ae}),error:Xa({error:ae,agentName:oR}),isRetryableError:Qa(ae),isProviderUnavailableError:ec(ae),agentSessionId:p,resolvedModel:m,effort:we,usage:I,...M?{aborted:!0}:{}}}var Hie=async()=>{let t=_y.join(zie.homedir(),".claude");await fp.rm(t,{recursive:!0,force:!0})},Wie={baseDir:_y.join(zie.homedir(),".claude"),include:["projects"]},Yie=async({aiGateway:t,config:e,model:r,prompt:n,systemPrompt:i,outputFormat:o,maxTokens:s})=>{let a=Vie({aiGateway:t}),c=await qie({config:e,aiGateway:t,model:r});if(!c)throw new Error("Model is required");let u=await new yo({apiKey:a.ANTHROPIC_API_KEY,...a.ANTHROPIC_BASE_URL?{baseURL:a.ANTHROPIC_BASE_URL}:{}}).messages.create({max_tokens:s||4096,model:c,system:i,messages:[{role:"user",content:n}],...o&&{output_config:{format:o}}}),d=u.content.map(f=>"text"in f&&f.text).filter(Boolean).join("");return{response:u,text:d}};import By from"fs/promises";import DR from"os";import ah from"path";import yc from"process";import gBe from"readline";function ve(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function $(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}var i2=function(){let{crypto:t}=globalThis;if(t?.randomUUID)return i2=t.randomUUID.bind(t),t.randomUUID();let e=new Uint8Array(1),r=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function yy(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}var Sy=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){let e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};var me=class extends Error{},xt=class t extends me{constructor(e,r,n,i){super(`${t.makeMessage(e,r,n)}`),this.status=e,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=r;let o=r;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,r,n){let i=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,r,n,i){if(!e||!i)return new tc({message:n,cause:Sy(r)});let o=r?.error;return e===400?new hp(e,o,n,i):e===401?new mp(e,o,n,i):e===403?new gp(e,o,n,i):e===404?new _p(e,o,n,i):e===409?new yp(e,o,n,i):e===422?new Sp(e,o,n,i):e===429?new Ep(e,o,n,i):e>=500?new vp(e,o,n,i):new t(e,o,n,i)}},Mt=class extends xt{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},tc=class extends xt{constructor({message:e,cause:r}){super(void 0,void 0,e||"Connection error.",void 0),r&&(this.cause=r)}},rc=class extends tc{constructor({message:e}={}){super({message:e??"Request timed out."})}},hp=class extends xt{},mp=class extends xt{},gp=class extends xt{},_p=class extends xt{},yp=class extends xt{},Sp=class extends xt{},Ep=class extends xt{},vp=class extends xt{},bp=class extends me{constructor(){super("Could not parse response content as the length limit was reached")}},Tp=class extends me{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},To=class extends Error{constructor(e){super(e)}},Wl=class extends xt{constructor(e,r,n){let i="OAuth2 authentication error",o;if(r&&typeof r=="object"){let s=r;o=s.error;let a=s.error_description;a&&typeof a=="string"?i=a:o&&(i=o)}super(e,r,i,n),this.error_code=o}},Ey=class extends me{constructor(e,r,n){super(e),this.provider=r,this.cause=n}};var WUe=/^[a-z][a-z0-9+.-]*:/i,Kie=t=>WUe.test(t),yr=t=>(yr=Array.isArray,yr(t)),o2=yr;function s2(t){return typeof t!="object"?{}:t??{}}function a2(t){if(!t)return!0;for(let e in t)return!1;return!0}function Zie(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function vy(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}var Jie=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new me(`${t} must be an integer`);if(e<0)throw new me(`${t} must be a positive integer`);return e};var Xie=t=>{try{return JSON.parse(t)}catch{return}};var xo=t=>new Promise(e=>setTimeout(e,t));var nc="6.34.0";var roe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function YUe(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var KUe=()=>{let t=YUe();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":eoe(Deno.build.os),"X-Stainless-Arch":Qie(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":eoe(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Qie(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=ZUe();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ZUe(){if(typeof navigator>"u"||!navigator)return null;let t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:r}of t){let n=r.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,s=n[3]||0;return{browser:e,version:`${i}.${o}.${s}`}}}return null}var Qie=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",eoe=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),toe,noe=()=>toe??(toe=KUe());function sR(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function c2(...t){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function aR(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return c2({start(){},async pull(r){let{done:n,value:i}=await e.next();n?r.close():r.enqueue(i)},async cancel(){await e.return?.()}})}function l2(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let r=await e.read();return r?.done&&e.releaseLock(),r}catch(r){throw e.releaseLock(),r}},async return(){let r=e.cancel();return e.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function u2(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}let e=t.getReader(),r=e.cancel();e.releaseLock(),await r}var ooe=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var d2="RFC3986",f2=t=>String(t),p2={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:f2},soe="RFC1738";var cR=(t,e)=>(cR=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),cR(t,e)),wo=(()=>{let t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})();var h2=1024,aoe=(t,e,r,n,i)=>{if(t.length===0)return t;let o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let s="";for(let a=0;a<o.length;a+=h2){let c=o.length>=h2?o.slice(a,a+h2):o,l=[];for(let u=0;u<c.length;++u){let d=c.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===soe&&(d===40||d===41)){l[l.length]=c.charAt(u);continue}if(d<128){l[l.length]=wo[d];continue}if(d<2048){l[l.length]=wo[192|d>>6]+wo[128|d&63];continue}if(d<55296||d>=57344){l[l.length]=wo[224|d>>12]+wo[128|d>>6&63]+wo[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|c.charCodeAt(u)&1023),l[l.length]=wo[240|d>>18]+wo[128|d>>12&63]+wo[128|d>>6&63]+wo[128|d&63]}s+=l.join("")}return s};function coe(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function m2(t,e){if(yr(t)){let r=[];for(let n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)}var uoe={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},doe=function(t,e){Array.prototype.push.apply(t,yr(e)?e:[e])},loe,Gt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:aoe,encodeValuesOnly:!1,format:d2,formatter:f2,indices:!1,serializeDate(t){return(loe??(loe=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function XUe(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}var g2={};function foe(t,e,r,n,i,o,s,a,c,l,u,d,f,p,h,m,y,S){let T=t,x=S,v=0,N=!1;for(;(x=x.get(g2))!==void 0&&!N;){let j=x.get(t);if(v+=1,typeof j<"u"){if(j===v)throw new RangeError("Cyclic object value");N=!0}typeof x.get(g2)>"u"&&(v=0)}if(typeof l=="function"?T=l(e,T):T instanceof Date?T=f?.(T):r==="comma"&&yr(T)&&(T=m2(T,function(j){return j instanceof Date?f?.(j):j})),T===null){if(o)return c&&!m?c(e,Gt.encoder,y,"key",p):e;T=""}if(XUe(T)||coe(T)){if(c){let j=m?e:c(e,Gt.encoder,y,"key",p);return[h?.(j)+"="+h?.(c(T,Gt.encoder,y,"value",p))]}return[h?.(e)+"="+h?.(String(T))]}let R=[];if(typeof T>"u")return R;let U;if(r==="comma"&&yr(T))m&&c&&(T=m2(T,c)),U=[{value:T.length>0?T.join(",")||null:void 0}];else if(yr(l))U=l;else{let j=Object.keys(T);U=u?j.sort(u):j}let C=a?String(e).replace(/\./g,"%2E"):String(e),D=n&&yr(T)&&T.length===1?C+"[]":C;if(i&&yr(T)&&T.length===0)return D+"[]";for(let j=0;j<U.length;++j){let _=U[j],ae=typeof _=="object"&&typeof _.value<"u"?_.value:T[_];if(s&&ae===null)continue;let I=d&&a?_.replace(/\./g,"%2E"):_,g=yr(T)?typeof r=="function"?r(D,I):D:D+(d?"."+I:"["+I+"]");S.set(t,v);let E=new WeakMap;E.set(g2,S),doe(R,foe(ae,g,r,n,i,o,s,a,r==="comma"&&m&&yr(T)?null:c,l,u,d,f,p,h,m,y,E))}return R}function QUe(t=Gt){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=t.charset||Gt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=d2;if(typeof t.format<"u"){if(!cR(p2,t.format))throw new TypeError("Unknown format option provided.");r=t.format}let n=p2[r],i=Gt.filter;(typeof t.filter=="function"||yr(t.filter))&&(i=t.filter);let o;if(t.arrayFormat&&t.arrayFormat in uoe?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Gt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let s=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:Gt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Gt.addQueryPrefix,allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Gt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Gt.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Gt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Gt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Gt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Gt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Gt.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Gt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Gt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Gt.strictNullHandling}}function poe(t,e={}){let r=t,n=QUe(e),i,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):yr(n.filter)&&(o=n.filter,i=o);let s=[];if(typeof r!="object"||r===null)return"";let a=uoe[n.arrayFormat],c=a==="comma"&&n.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);let l=new WeakMap;for(let f=0;f<i.length;++f){let p=i[f];n.skipNulls&&r[p]===null||doe(s,foe(r[p],p,a,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,l))}let u=s.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),u.length>0?d+u:""}function hoe(t){return poe(t,{arrayFormat:"brackets"})}function _oe(t){let e=0;for(let i of t)e+=i.length;let r=new Uint8Array(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var moe;function xp(t){let e;return(moe??(e=new globalThis.TextEncoder,moe=e.encode.bind(e)))(t)}var goe;function _2(t){let e;return(goe??(e=new globalThis.TextDecoder,goe=e.decode.bind(e)))(t)}var xn,wn,Yl=class{constructor(){xn.set(this,void 0),wn.set(this,void 0),ve(this,xn,new Uint8Array,"f"),ve(this,wn,null,"f")}decode(e){if(e==null)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?xp(e):e;ve(this,xn,_oe([$(this,xn,"f"),r]),"f");let n=[],i;for(;(i=tFe($(this,xn,"f"),$(this,wn,"f")))!=null;){if(i.carriage&&$(this,wn,"f")==null){ve(this,wn,i.index,"f");continue}if($(this,wn,"f")!=null&&(i.index!==$(this,wn,"f")+1||i.carriage)){n.push(_2($(this,xn,"f").subarray(0,$(this,wn,"f")-1))),ve(this,xn,$(this,xn,"f").subarray($(this,wn,"f")),"f"),ve(this,wn,null,"f");continue}let o=$(this,wn,"f")!==null?i.preceding-1:i.preceding,s=_2($(this,xn,"f").subarray(0,o));n.push(s),ve(this,xn,$(this,xn,"f").subarray(i.index),"f"),ve(this,wn,null,"f")}return n}flush(){return $(this,xn,"f").length?this.decode(`
|
|
275
|
+
`)}if(ne&&Pe&&Bie(Pe)){ie({title:"Running in background",category:Y.Task,parentGroupId:ge},!0);break}ie({title:Nt,message:Pe,wrapMessage:At,category:ne?Y.AgentMessage:xe?Y.SiteGeneration:Os[J?.name??""]?.category||Y.Tool,parentGroupId:ge},!0);break}case"thinking":{A.thinking&&ie({title:"Reasoning",message:A.thinking,category:Y.Reasoning,parentGroupId:F.parent_tool_use_id||void 0},!0);break}default:_r.log(`Message content type is not supported ${A.type}`,A)}}):F?.type==="result"&&(j=F.duration_ms||0,F.is_error?g||(ae=F.result):_=F.result,F.usage&&(so(F.usage),I=F.usage),[S,y].forEach(A=>{A[A.length-1]?.message===_&&A.pop()}))});let K=!1;if(await be.catch(k=>{K=Of(k,a),{error:ae,result:_}=qUe({catchError:k,runCmd:be,error:ae,result:_,runnerName:"Claude"})}),V&&await fp.rm(V.mcpConfigPath,{force:!0}).catch(()=>{}),Ae.close(),ee.flush(),g)return{steps:S,duration:j,agentSessionId:p,resolvedModel:m,effort:we,usage:I,pendingInteraction:g};let M=K;return M&&(!_&&E.trim()&&(_=E.trim()),ae=void 0),{steps:S,duration:j,result:await Ja({initialResult:_,agentName:oR,hasError:!!ae}),error:Xa({error:ae,agentName:oR}),isRetryableError:Qa(ae),isProviderUnavailableError:ec(ae),agentSessionId:p,resolvedModel:m,effort:we,usage:I,...M?{aborted:!0}:{}}}var Hie=async()=>{let t=_y.join(zie.homedir(),".claude");await fp.rm(t,{recursive:!0,force:!0})},Wie={baseDir:_y.join(zie.homedir(),".claude"),include:["projects"]},Yie=async({aiGateway:t,config:e,model:r,prompt:n,systemPrompt:i,outputFormat:o,maxTokens:s})=>{let a=Vie({aiGateway:t}),c=await qie({config:e,aiGateway:t,model:r});if(!c)throw new Error("Model is required");let u=await new yo({apiKey:a.ANTHROPIC_API_KEY,...a.ANTHROPIC_BASE_URL?{baseURL:a.ANTHROPIC_BASE_URL}:{}}).messages.create({max_tokens:s||4096,model:c,system:i,messages:[{role:"user",content:n}],...o&&{output_config:{format:o}}}),d=u.content.map(f=>"text"in f&&f.text).filter(Boolean).join("");return{response:u,text:d}};import By from"fs/promises";import DR from"os";import ah from"path";import yc from"process";import gBe from"readline";function ve(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function $(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}var ij=function(){let{crypto:t}=globalThis;if(t?.randomUUID)return ij=t.randomUUID.bind(t),t.randomUUID();let e=new Uint8Array(1),r=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function yy(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}var Sy=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){let e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};var me=class extends Error{},xt=class t extends me{constructor(e,r,n,i){super(`${t.makeMessage(e,r,n)}`),this.status=e,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=r;let o=r;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,r,n){let i=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,r,n,i){if(!e||!i)return new tc({message:n,cause:Sy(r)});let o=r?.error;return e===400?new hp(e,o,n,i):e===401?new mp(e,o,n,i):e===403?new gp(e,o,n,i):e===404?new _p(e,o,n,i):e===409?new yp(e,o,n,i):e===422?new Sp(e,o,n,i):e===429?new Ep(e,o,n,i):e>=500?new vp(e,o,n,i):new t(e,o,n,i)}},Mt=class extends xt{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},tc=class extends xt{constructor({message:e,cause:r}){super(void 0,void 0,e||"Connection error.",void 0),r&&(this.cause=r)}},rc=class extends tc{constructor({message:e}={}){super({message:e??"Request timed out."})}},hp=class extends xt{},mp=class extends xt{},gp=class extends xt{},_p=class extends xt{},yp=class extends xt{},Sp=class extends xt{},Ep=class extends xt{},vp=class extends xt{},bp=class extends me{constructor(){super("Could not parse response content as the length limit was reached")}},Tp=class extends me{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},To=class extends Error{constructor(e){super(e)}},Wl=class extends xt{constructor(e,r,n){let i="OAuth2 authentication error",o;if(r&&typeof r=="object"){let s=r;o=s.error;let a=s.error_description;a&&typeof a=="string"?i=a:o&&(i=o)}super(e,r,i,n),this.error_code=o}},Ey=class extends me{constructor(e,r,n){super(e),this.provider=r,this.cause=n}};var WUe=/^[a-z][a-z0-9+.-]*:/i,Kie=t=>WUe.test(t),yr=t=>(yr=Array.isArray,yr(t)),oj=yr;function sj(t){return typeof t!="object"?{}:t??{}}function aj(t){if(!t)return!0;for(let e in t)return!1;return!0}function Zie(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function vy(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}var Jie=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new me(`${t} must be an integer`);if(e<0)throw new me(`${t} must be a positive integer`);return e};var Xie=t=>{try{return JSON.parse(t)}catch{return}};var xo=t=>new Promise(e=>setTimeout(e,t));var nc="6.34.0";var roe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function YUe(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var KUe=()=>{let t=YUe();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":eoe(Deno.build.os),"X-Stainless-Arch":Qie(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":eoe(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Qie(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=ZUe();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":nc,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ZUe(){if(typeof navigator>"u"||!navigator)return null;let t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:r}of t){let n=r.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,s=n[3]||0;return{browser:e,version:`${i}.${o}.${s}`}}}return null}var Qie=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",eoe=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),toe,noe=()=>toe??(toe=KUe());function sR(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function cj(...t){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function aR(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return cj({start(){},async pull(r){let{done:n,value:i}=await e.next();n?r.close():r.enqueue(i)},async cancel(){await e.return?.()}})}function lj(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let r=await e.read();return r?.done&&e.releaseLock(),r}catch(r){throw e.releaseLock(),r}},async return(){let r=e.cancel();return e.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function uj(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}let e=t.getReader(),r=e.cancel();e.releaseLock(),await r}var ooe=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var dj="RFC3986",fj=t=>String(t),pj={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:fj},soe="RFC1738";var cR=(t,e)=>(cR=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),cR(t,e)),wo=(()=>{let t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})();var hj=1024,aoe=(t,e,r,n,i)=>{if(t.length===0)return t;let o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let s="";for(let a=0;a<o.length;a+=hj){let c=o.length>=hj?o.slice(a,a+hj):o,l=[];for(let u=0;u<c.length;++u){let d=c.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===soe&&(d===40||d===41)){l[l.length]=c.charAt(u);continue}if(d<128){l[l.length]=wo[d];continue}if(d<2048){l[l.length]=wo[192|d>>6]+wo[128|d&63];continue}if(d<55296||d>=57344){l[l.length]=wo[224|d>>12]+wo[128|d>>6&63]+wo[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|c.charCodeAt(u)&1023),l[l.length]=wo[240|d>>18]+wo[128|d>>12&63]+wo[128|d>>6&63]+wo[128|d&63]}s+=l.join("")}return s};function coe(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function mj(t,e){if(yr(t)){let r=[];for(let n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)}var uoe={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},doe=function(t,e){Array.prototype.push.apply(t,yr(e)?e:[e])},loe,Gt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:aoe,encodeValuesOnly:!1,format:dj,formatter:fj,indices:!1,serializeDate(t){return(loe??(loe=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function XUe(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}var gj={};function foe(t,e,r,n,i,o,s,a,c,l,u,d,f,p,h,m,y,S){let T=t,x=S,v=0,N=!1;for(;(x=x.get(gj))!==void 0&&!N;){let j=x.get(t);if(v+=1,typeof j<"u"){if(j===v)throw new RangeError("Cyclic object value");N=!0}typeof x.get(gj)>"u"&&(v=0)}if(typeof l=="function"?T=l(e,T):T instanceof Date?T=f?.(T):r==="comma"&&yr(T)&&(T=mj(T,function(j){return j instanceof Date?f?.(j):j})),T===null){if(o)return c&&!m?c(e,Gt.encoder,y,"key",p):e;T=""}if(XUe(T)||coe(T)){if(c){let j=m?e:c(e,Gt.encoder,y,"key",p);return[h?.(j)+"="+h?.(c(T,Gt.encoder,y,"value",p))]}return[h?.(e)+"="+h?.(String(T))]}let R=[];if(typeof T>"u")return R;let U;if(r==="comma"&&yr(T))m&&c&&(T=mj(T,c)),U=[{value:T.length>0?T.join(",")||null:void 0}];else if(yr(l))U=l;else{let j=Object.keys(T);U=u?j.sort(u):j}let C=a?String(e).replace(/\./g,"%2E"):String(e),D=n&&yr(T)&&T.length===1?C+"[]":C;if(i&&yr(T)&&T.length===0)return D+"[]";for(let j=0;j<U.length;++j){let _=U[j],ae=typeof _=="object"&&typeof _.value<"u"?_.value:T[_];if(s&&ae===null)continue;let I=d&&a?_.replace(/\./g,"%2E"):_,g=yr(T)?typeof r=="function"?r(D,I):D:D+(d?"."+I:"["+I+"]");S.set(t,v);let E=new WeakMap;E.set(gj,S),doe(R,foe(ae,g,r,n,i,o,s,a,r==="comma"&&m&&yr(T)?null:c,l,u,d,f,p,h,m,y,E))}return R}function QUe(t=Gt){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=t.charset||Gt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=dj;if(typeof t.format<"u"){if(!cR(pj,t.format))throw new TypeError("Unknown format option provided.");r=t.format}let n=pj[r],i=Gt.filter;(typeof t.filter=="function"||yr(t.filter))&&(i=t.filter);let o;if(t.arrayFormat&&t.arrayFormat in uoe?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Gt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let s=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:Gt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Gt.addQueryPrefix,allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Gt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Gt.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Gt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Gt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Gt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Gt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Gt.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Gt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Gt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Gt.strictNullHandling}}function poe(t,e={}){let r=t,n=QUe(e),i,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):yr(n.filter)&&(o=n.filter,i=o);let s=[];if(typeof r!="object"||r===null)return"";let a=uoe[n.arrayFormat],c=a==="comma"&&n.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);let l=new WeakMap;for(let f=0;f<i.length;++f){let p=i[f];n.skipNulls&&r[p]===null||doe(s,foe(r[p],p,a,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,l))}let u=s.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),u.length>0?d+u:""}function hoe(t){return poe(t,{arrayFormat:"brackets"})}function _oe(t){let e=0;for(let i of t)e+=i.length;let r=new Uint8Array(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var moe;function xp(t){let e;return(moe??(e=new globalThis.TextEncoder,moe=e.encode.bind(e)))(t)}var goe;function _j(t){let e;return(goe??(e=new globalThis.TextDecoder,goe=e.decode.bind(e)))(t)}var xn,wn,Yl=class{constructor(){xn.set(this,void 0),wn.set(this,void 0),ve(this,xn,new Uint8Array,"f"),ve(this,wn,null,"f")}decode(e){if(e==null)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?xp(e):e;ve(this,xn,_oe([$(this,xn,"f"),r]),"f");let n=[],i;for(;(i=tFe($(this,xn,"f"),$(this,wn,"f")))!=null;){if(i.carriage&&$(this,wn,"f")==null){ve(this,wn,i.index,"f");continue}if($(this,wn,"f")!=null&&(i.index!==$(this,wn,"f")+1||i.carriage)){n.push(_j($(this,xn,"f").subarray(0,$(this,wn,"f")-1))),ve(this,xn,$(this,xn,"f").subarray($(this,wn,"f")),"f"),ve(this,wn,null,"f");continue}let o=$(this,wn,"f")!==null?i.preceding-1:i.preceding,s=_j($(this,xn,"f").subarray(0,o));n.push(s),ve(this,xn,$(this,xn,"f").subarray(i.index),"f"),ve(this,wn,null,"f")}return n}flush(){return $(this,xn,"f").length?this.decode(`
|
|
276
276
|
`):[]}};xn=new WeakMap,wn=new WeakMap;Yl.NEWLINE_CHARS=new Set([`
|
|
277
|
-
`,"\r"]);Yl.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function tFe(t,e){for(let i=e??0;i<t.length;i++){if(t[i]===10)return{preceding:i,index:i+1,carriage:!1};if(t[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function yoe(t){for(let n=0;n<t.length-1;n++){if(t[n]===10&&t[n+1]===10||t[n]===13&&t[n+1]===13)return n+2;if(t[n]===13&&t[n+1]===10&&n+3<t.length&&t[n+2]===13&&t[n+3]===10)return n+4}return-1}var uR={off:0,error:200,warn:300,info:400,debug:500},
|
|
278
|
-
`);n.enqueue(s)}catch(i){n.error(i)}},async cancel(){await r.return?.()}})}};async function*nFe(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new me("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new me("Attempted to iterate over a response with no body");let r=new
|
|
279
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,n,i]=oFe(e,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};function oFe(t,e){let r=t.indexOf(e);return r!==-1?[t.substring(0,r),e,t.substring(r+e.length)]:[t,"",""]}async function dR(t,e){let{response:r,requestLogID:n,retryOfRequestLogID:i,startTime:o}=e,s=await(async()=>{if(e.options.stream)return Pt(t).debug("response",r.status,r.url,r.headers,r.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(r,e.controller,t,e.options.__synthesizeEventData):Ao.fromSSEResponse(r,e.controller,t,e.options.__synthesizeEventData);if(r.status===204)return null;if(e.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(r.headers.get("content-length")==="0")return;let f=await r.json();return E2(f,r)}return await r.text()})();return Pt(t).debug(`[${n}] response parsed`,Ns({retryOfRequestLogID:i,url:r.url,status:r.status,body:s,durationMs:Date.now()-o})),s}function E2(t,e){return!t||typeof t!="object"||Array.isArray(t)?t:Object.defineProperty(t,"_request_id",{value:e.headers.get("x-request-id"),enumerable:!1})}var xy,Kl=class t extends Promise{constructor(e,r,n=dR){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=n,xy.set(this,void 0),ve(this,xy,e,"f")}_thenUnwrap(e){return new t($(this,xy,"f"),this.responsePromise,async(r,n)=>E2(e(await this.parseResponse(r,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:r,request_id:r.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse($(this,xy,"f"),e))),this.parsedPromise}then(e,r){return this.parse().then(e,r)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};xy=new WeakMap;var fR,wy=class{constructor(e,r,n,i){fR.set(this,void 0),ve(this,fR,e,"f"),this.options=i,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new me("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await $(this,fR,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(fR=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let r of e.getPaginatedItems())yield r}},Ay=class extends Kl{constructor(e,r,n){super(e,r,async(i,o)=>new n(i,o.response,await dR(i,o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let r of e)yield r}},Ro=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},Le=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),r=e[e.length-1]?.id;return r?{...this.options,query:{...s2(this.options.query),after:r}}:null}},Ii=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...s2(this.options.query),after:e}}:null}};var aFe={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},cFe="urn:ietf:params:oauth:grant-type:token-exchange",pR=class{constructor(e,r){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl="https://auth.openai.com/oauth/token",this.config=e,this.fetch=r??sR()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let e=await this.config.provider.getToken(),r=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:cFe,client_id:this.config.clientId,subject_token:e,subject_token_type:aFe[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId})});if(!r.ok){let s=await r.text(),a;try{a=JSON.parse(s)}catch{}throw r.status===400||r.status===401||r.status===403?new Wl(r.status,a,r.headers):xt.generate(r.status,a,`Token exchange failed with status ${r.status}`,r.headers)}let n=await r.json(),i=n.expires_in||3600,o=Date.now()+i*1e3;return this.cachedToken={token:n.access_token,expiresAt:o},n.access_token}isTokenExpired(e){return Date.now()>=e.expiresAt}needsRefresh(e){let n=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=e.expiresAt-n}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};var T2=()=>{if(typeof File>"u"){let{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function wp(t,e,r){return T2(),new File(t,e??"unknown_file",r)}function Ry(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}var hR=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",ic=async(t,e)=>v2(t.body)?{...t,body:await voe(t.body,e)}:t,Sr=async(t,e)=>({...t,body:await voe(t.body,e)}),Eoe=new WeakMap;function lFe(t){let e=typeof t=="function"?t:t.fetch,r=Eoe.get(e);if(r)return r;let n=(async()=>{try{let i="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new i(o).text()}catch{return!0}})();return Eoe.set(e,n),n}var voe=async(t,e)=>{if(!await lFe(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;return await Promise.all(Object.entries(t||{}).map(([n,i])=>b2(r,n,i))),r},boe=t=>t instanceof Blob&&"name"in t,uFe=t=>typeof t=="object"&&t!==null&&(t instanceof Response||hR(t)||boe(t)),v2=t=>{if(uFe(t))return!0;if(Array.isArray(t))return t.some(v2);if(t&&typeof t=="object"){for(let e in t)if(v2(t[e]))return!0}return!1},b2=async(t,e,r)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")t.append(e,String(r));else if(r instanceof Response)t.append(e,wp([await r.blob()],Ry(r)));else if(hR(r))t.append(e,wp([await new Response(aR(r)).blob()],Ry(r)));else if(boe(r))t.append(e,r,Ry(r));else if(Array.isArray(r))await Promise.all(r.map(n=>b2(t,e+"[]",n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([n,i])=>b2(t,`${e}[${n}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var Toe=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",dFe=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Toe(t),fFe=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function mR(t,e,r){if(T2(),t=await t,dFe(t))return t instanceof File?t:wp([await t.arrayBuffer()],t.name);if(fFe(t)){let i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),wp(await x2(i),e,r)}let n=await x2(t);if(e||(e=Ry(t)),!r?.type){let i=n.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof i=="string"&&(r={...r,type:i})}return wp(n,e,r)}async function x2(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(Toe(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(hR(t))for await(let r of t)e.push(...await x2(r));else{let r=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${r?`; constructor: ${r}`:""}${pFe(t)}`)}return e}function pFe(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(r=>`"${r}"`).join(", ")}]`}var q=class{constructor(e){this._client=e}};function woe(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var xoe=Object.freeze(Object.create(null)),mFe=(t=woe)=>function(r,...n){if(r.length===1)return r[0];let i=!1,o=[],s=r.reduce((u,d,f)=>{/[?#]/.test(d)&&(i=!0);let p=n[f],h=(i?encodeURIComponent:t)(""+p);return f!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??xoe)??xoe)?.toString)&&(h=p+"",o.push({start:u.length+d.length,length:h.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),u+d+(f===n.length?"":h)},""),a=s.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,l;for(;(l=c.exec(a))!==null;)o.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can't be safely passed as a path parameter`});if(o.sort((u,d)=>u.start-d.start),o.length>0){let u=0,d=o.reduce((f,p)=>{let h=" ".repeat(p.start-u),m="^".repeat(p.length);return u=p.start+p.length,f+h+m},"");throw new me(`Path parameters result in path with invalid segments:
|
|
277
|
+
`,"\r"]);Yl.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function tFe(t,e){for(let i=e??0;i<t.length;i++){if(t[i]===10)return{preceding:i,index:i+1,carriage:!1};if(t[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function yoe(t){for(let n=0;n<t.length-1;n++){if(t[n]===10&&t[n+1]===10||t[n]===13&&t[n+1]===13)return n+2;if(t[n]===13&&t[n+1]===10&&n+3<t.length&&t[n+2]===13&&t[n+3]===10)return n+4}return-1}var uR={off:0,error:200,warn:300,info:400,debug:500},yj=(t,e,r)=>{if(t){if(Zie(uR,t))return t;Pt(r).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(uR))}`)}};function by(){}function lR(t,e,r){return!e||uR[t]>uR[r]?by:e[t].bind(e)}var rFe={error:by,warn:by,info:by,debug:by},Soe=new WeakMap;function Pt(t){let e=t.logger,r=t.logLevel??"off";if(!e)return rFe;let n=Soe.get(e);if(n&&n[0]===r)return n[1];let i={error:lR("error",e,r),warn:lR("warn",e,r),info:lR("info",e,r),debug:lR("debug",e,r)};return Soe.set(e,[r,i]),i}var Ns=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,r])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":r]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);var Ty,Ao=class t{constructor(e,r,n){this.iterator=e,Ty.set(this,void 0),this.controller=r,ve(this,Ty,n,"f")}static fromSSEResponse(e,r,n,i){let o=!1,s=n?Pt(n):console;async function*a(){if(o)throw new me("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let c=!1;try{for await(let l of nFe(e,r))if(!c){if(l.data.startsWith("[DONE]")){c=!0;continue}if(l.event===null||!l.event.startsWith("thread.")){let u;try{u=JSON.parse(l.data)}catch(d){throw s.error("Could not parse message into JSON:",l.data),s.error("From chunk:",l.raw),d}if(u&&u.error)throw new xt(void 0,u.error,void 0,e.headers);yield i?{event:l.event,data:u}:u}else{let u;try{u=JSON.parse(l.data)}catch(d){throw console.error("Could not parse message into JSON:",l.data),console.error("From chunk:",l.raw),d}if(l.event=="error")throw new xt(void 0,u.error,u.message,void 0);yield{event:l.event,data:u}}}c=!0}catch(l){if(yy(l))return;throw l}finally{c||r.abort()}}return new t(a,r,n)}static fromReadableStream(e,r,n){let i=!1;async function*o(){let a=new Yl,c=lj(e);for await(let l of c)for(let u of a.decode(l))yield u;for(let l of a.flush())yield l}async function*s(){if(i)throw new me("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(let c of o())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(yy(c))return;throw c}finally{a||r.abort()}}return new t(s,r,n)}[(Ty=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],r=[],n=this.iterator(),i=o=>({next:()=>{if(o.length===0){let s=n.next();e.push(s),r.push(s)}return o.shift()}});return[new t(()=>i(e),this.controller,$(this,Ty,"f")),new t(()=>i(r),this.controller,$(this,Ty,"f"))]}toReadableStream(){let e=this,r;return cj({async start(){r=e[Symbol.asyncIterator]()},async pull(n){try{let{value:i,done:o}=await r.next();if(o)return n.close();let s=xp(JSON.stringify(i)+`
|
|
278
|
+
`);n.enqueue(s)}catch(i){n.error(i)}},async cancel(){await r.return?.()}})}};async function*nFe(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new me("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new me("Attempted to iterate over a response with no body");let r=new Sj,n=new Yl,i=lj(t.body);for await(let o of iFe(i))for(let s of n.decode(o)){let a=r.decode(s);a&&(yield a)}for(let o of n.flush()){let s=r.decode(o);s&&(yield s)}}async function*iFe(t){let e=new Uint8Array;for await(let r of t){if(r==null)continue;let n=r instanceof ArrayBuffer?new Uint8Array(r):typeof r=="string"?xp(r):r,i=new Uint8Array(e.length+n.length);i.set(e),i.set(n,e.length),e=i;let o;for(;(o=yoe(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var Sj=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
279
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,n,i]=oFe(e,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};function oFe(t,e){let r=t.indexOf(e);return r!==-1?[t.substring(0,r),e,t.substring(r+e.length)]:[t,"",""]}async function dR(t,e){let{response:r,requestLogID:n,retryOfRequestLogID:i,startTime:o}=e,s=await(async()=>{if(e.options.stream)return Pt(t).debug("response",r.status,r.url,r.headers,r.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(r,e.controller,t,e.options.__synthesizeEventData):Ao.fromSSEResponse(r,e.controller,t,e.options.__synthesizeEventData);if(r.status===204)return null;if(e.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(r.headers.get("content-length")==="0")return;let f=await r.json();return Ej(f,r)}return await r.text()})();return Pt(t).debug(`[${n}] response parsed`,Ns({retryOfRequestLogID:i,url:r.url,status:r.status,body:s,durationMs:Date.now()-o})),s}function Ej(t,e){return!t||typeof t!="object"||Array.isArray(t)?t:Object.defineProperty(t,"_request_id",{value:e.headers.get("x-request-id"),enumerable:!1})}var xy,Kl=class t extends Promise{constructor(e,r,n=dR){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=n,xy.set(this,void 0),ve(this,xy,e,"f")}_thenUnwrap(e){return new t($(this,xy,"f"),this.responsePromise,async(r,n)=>Ej(e(await this.parseResponse(r,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:r,request_id:r.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse($(this,xy,"f"),e))),this.parsedPromise}then(e,r){return this.parse().then(e,r)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};xy=new WeakMap;var fR,wy=class{constructor(e,r,n,i){fR.set(this,void 0),ve(this,fR,e,"f"),this.options=i,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new me("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await $(this,fR,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(fR=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let r of e.getPaginatedItems())yield r}},Ay=class extends Kl{constructor(e,r,n){super(e,r,async(i,o)=>new n(i,o.response,await dR(i,o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let r of e)yield r}},Ro=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},Le=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),r=e[e.length-1]?.id;return r?{...this.options,query:{...sj(this.options.query),after:r}}:null}},Ii=class extends wy{constructor(e,r,n,i){super(e,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...sj(this.options.query),after:e}}:null}};var aFe={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},cFe="urn:ietf:params:oauth:grant-type:token-exchange",pR=class{constructor(e,r){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl="https://auth.openai.com/oauth/token",this.config=e,this.fetch=r??sR()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let e=await this.config.provider.getToken(),r=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:cFe,client_id:this.config.clientId,subject_token:e,subject_token_type:aFe[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId})});if(!r.ok){let s=await r.text(),a;try{a=JSON.parse(s)}catch{}throw r.status===400||r.status===401||r.status===403?new Wl(r.status,a,r.headers):xt.generate(r.status,a,`Token exchange failed with status ${r.status}`,r.headers)}let n=await r.json(),i=n.expires_in||3600,o=Date.now()+i*1e3;return this.cachedToken={token:n.access_token,expiresAt:o},n.access_token}isTokenExpired(e){return Date.now()>=e.expiresAt}needsRefresh(e){let n=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=e.expiresAt-n}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};var Tj=()=>{if(typeof File>"u"){let{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function wp(t,e,r){return Tj(),new File(t,e??"unknown_file",r)}function Ry(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}var hR=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",ic=async(t,e)=>vj(t.body)?{...t,body:await voe(t.body,e)}:t,Sr=async(t,e)=>({...t,body:await voe(t.body,e)}),Eoe=new WeakMap;function lFe(t){let e=typeof t=="function"?t:t.fetch,r=Eoe.get(e);if(r)return r;let n=(async()=>{try{let i="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new i(o).text()}catch{return!0}})();return Eoe.set(e,n),n}var voe=async(t,e)=>{if(!await lFe(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;return await Promise.all(Object.entries(t||{}).map(([n,i])=>bj(r,n,i))),r},boe=t=>t instanceof Blob&&"name"in t,uFe=t=>typeof t=="object"&&t!==null&&(t instanceof Response||hR(t)||boe(t)),vj=t=>{if(uFe(t))return!0;if(Array.isArray(t))return t.some(vj);if(t&&typeof t=="object"){for(let e in t)if(vj(t[e]))return!0}return!1},bj=async(t,e,r)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")t.append(e,String(r));else if(r instanceof Response)t.append(e,wp([await r.blob()],Ry(r)));else if(hR(r))t.append(e,wp([await new Response(aR(r)).blob()],Ry(r)));else if(boe(r))t.append(e,r,Ry(r));else if(Array.isArray(r))await Promise.all(r.map(n=>bj(t,e+"[]",n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([n,i])=>bj(t,`${e}[${n}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var Toe=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",dFe=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Toe(t),fFe=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function mR(t,e,r){if(Tj(),t=await t,dFe(t))return t instanceof File?t:wp([await t.arrayBuffer()],t.name);if(fFe(t)){let i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),wp(await xj(i),e,r)}let n=await xj(t);if(e||(e=Ry(t)),!r?.type){let i=n.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof i=="string"&&(r={...r,type:i})}return wp(n,e,r)}async function xj(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(Toe(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(hR(t))for await(let r of t)e.push(...await xj(r));else{let r=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${r?`; constructor: ${r}`:""}${pFe(t)}`)}return e}function pFe(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(r=>`"${r}"`).join(", ")}]`}var q=class{constructor(e){this._client=e}};function woe(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var xoe=Object.freeze(Object.create(null)),mFe=(t=woe)=>function(r,...n){if(r.length===1)return r[0];let i=!1,o=[],s=r.reduce((u,d,f)=>{/[?#]/.test(d)&&(i=!0);let p=n[f],h=(i?encodeURIComponent:t)(""+p);return f!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??xoe)??xoe)?.toString)&&(h=p+"",o.push({start:u.length+d.length,length:h.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),u+d+(f===n.length?"":h)},""),a=s.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,l;for(;(l=c.exec(a))!==null;)o.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can't be safely passed as a path parameter`});if(o.sort((u,d)=>u.start-d.start),o.length>0){let u=0,d=o.reduce((f,p)=>{let h=" ".repeat(p.start-u),m="^".repeat(p.length);return u=p.start+p.length,f+h+m},"");throw new me(`Path parameters result in path with invalid segments:
|
|
280
280
|
${o.map(f=>f.error).join(`
|
|
281
281
|
`)}
|
|
282
282
|
${s}
|
|
283
|
-
${d}`)}return s},z=mFe(woe);var Zl=class extends q{list(e,r={},n){return this._client.getAPIList(z`/chat/completions/${e}/messages`,Le,{query:r,...n})}};function Iy(t){return t!==void 0&&"function"in t&&t.function!==void 0}function Cy(t){return t?.$brand==="auto-parseable-response-format"}function Jl(t){return t?.$brand==="auto-parseable-tool"}function Aoe(t,e){return!e||!w2(e)?{...t,choices:t.choices.map(r=>(Ioe(r.message.tool_calls),{...r,message:{...r.message,parsed:null,...r.message.tool_calls?{tool_calls:r.message.tool_calls}:void 0}}))}:Py(t,e)}function Py(t,e){let r=t.choices.map(n=>{if(n.finish_reason==="length")throw new bp;if(n.finish_reason==="content_filter")throw new Tp;return Ioe(n.message.tool_calls),{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:n.message.tool_calls?.map(i=>SFe(e,i))??void 0}:void 0,parsed:n.message.content&&!n.message.refusal?yFe(e,n.message.content):null}}});return{...t,choices:r}}function yFe(t,e){return t.response_format?.type!=="json_schema"?null:t.response_format?.type==="json_schema"?"$parseRaw"in t.response_format?t.response_format.$parseRaw(e):JSON.parse(e):null}function SFe(t,e){let r=t.tools?.find(n=>Iy(n)&&n.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:Jl(r)?r.$parseRaw(e.function.arguments):r?.function.strict?JSON.parse(e.function.arguments):null}}}function Roe(t,e){if(!t||!("tools"in t)||!t.tools)return!1;let r=t.tools?.find(n=>Iy(n)&&n.function?.name===e.function.name);return Iy(r)&&(Jl(r)||r?.function.strict||!1)}function w2(t){return Cy(t.response_format)?!0:t.tools?.some(e=>Jl(e)||e.type==="function"&&e.function.strict===!0)??!1}function Ioe(t){for(let e of t||[])if(e.type!=="function")throw new me(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function Coe(t){for(let e of t??[]){if(e.type!=="function")throw new me(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new me(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var Ap=t=>t?.role==="assistant",A2=t=>t?.role==="tool";var R2,gR,_R,Oy,Ny,yR,ky,ks,My,SR,ER,Rp,Poe,oc=class{constructor(){R2.add(this),this.controller=new AbortController,gR.set(this,void 0),_R.set(this,()=>{}),Oy.set(this,()=>{}),Ny.set(this,void 0),yR.set(this,()=>{}),ky.set(this,()=>{}),ks.set(this,{}),My.set(this,!1),SR.set(this,!1),ER.set(this,!1),Rp.set(this,!1),ve(this,gR,new Promise((e,r)=>{ve(this,_R,e,"f"),ve(this,Oy,r,"f")}),"f"),ve(this,Ny,new Promise((e,r)=>{ve(this,yR,e,"f"),ve(this,ky,r,"f")}),"f"),$(this,gR,"f").catch(()=>{}),$(this,Ny,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},$(this,R2,"m",Poe).bind(this))},0)}_connected(){this.ended||($(this,_R,"f").call(this),this._emit("connect"))}get ended(){return $(this,My,"f")}get errored(){return $(this,SR,"f")}get aborted(){return $(this,ER,"f")}abort(){this.controller.abort()}on(e,r){return($(this,ks,"f")[e]||($(this,ks,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=$(this,ks,"f")[e];if(!n)return this;let i=n.findIndex(o=>o.listener===r);return i>=0&&n.splice(i,1),this}once(e,r){return($(this,ks,"f")[e]||($(this,ks,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{ve(this,Rp,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){ve(this,Rp,!0,"f"),await $(this,Ny,"f")}_emit(e,...r){if($(this,My,"f"))return;e==="end"&&(ve(this,My,!0,"f"),$(this,yR,"f").call(this));let n=$(this,ks,"f")[e];if(n&&($(this,ks,"f")[e]=n.filter(i=>!i.once),n.forEach(({listener:i})=>i(...r))),e==="abort"){let i=r[0];!$(this,Rp,"f")&&!n?.length&&Promise.reject(i),$(this,Oy,"f").call(this,i),$(this,ky,"f").call(this,i),this._emit("end");return}if(e==="error"){let i=r[0];!$(this,Rp,"f")&&!n?.length&&Promise.reject(i),$(this,Oy,"f").call(this,i),$(this,ky,"f").call(this,i),this._emit("end")}}_emitFinal(){}};gR=new WeakMap,_R=new WeakMap,Oy=new WeakMap,Ny=new WeakMap,yR=new WeakMap,ky=new WeakMap,ks=new WeakMap,My=new WeakMap,SR=new WeakMap,ER=new WeakMap,Rp=new WeakMap,R2=new WeakSet,Poe=function(e){if(ve(this,SR,!0,"f"),e instanceof Error&&e.name==="AbortError"&&(e=new Mt),e instanceof Mt)return ve(this,ER,!0,"f"),this._emit("abort",e);if(e instanceof me)return this._emit("error",e);if(e instanceof Error){let r=new me(e.message);return r.cause=e,this._emit("error",r)}return this._emit("error",new me(String(e)))};function Ooe(t){return typeof t.parse=="function"}var $r,I2,vR,C2,P2,O2,Noe,koe,EFe=10,Ip=class extends oc{constructor(){super(...arguments),$r.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let r=e.choices[0]?.message;return r&&this._addMessage(r),e}_addMessage(e,r=!0){if("content"in e||(e.content=null),this.messages.push(e),r){if(this._emit("message",e),A2(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(Ap(e)&&e.tool_calls)for(let n of e.tool_calls)n.type==="function"&&this._emit("functionToolCall",n.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new me("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),$(this,$r,"m",I2).call(this)}async finalMessage(){return await this.done(),$(this,$r,"m",vR).call(this)}async finalFunctionToolCall(){return await this.done(),$(this,$r,"m",C2).call(this)}async finalFunctionToolCallResult(){return await this.done(),$(this,$r,"m",P2).call(this)}async totalUsage(){return await this.done(),$(this,$r,"m",O2).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let r=$(this,$r,"m",vR).call(this);r&&this._emit("finalMessage",r);let n=$(this,$r,"m",I2).call(this);n&&this._emit("finalContent",n);let i=$(this,$r,"m",C2).call(this);i&&this._emit("finalFunctionToolCall",i);let o=$(this,$r,"m",P2).call(this);o!=null&&this._emit("finalFunctionToolCallResult",o),this._chatCompletions.some(s=>s.usage)&&this._emit("totalUsage",$(this,$r,"m",O2).call(this))}async _createChatCompletion(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),$(this,$r,"m",Noe).call(this,r);let o=await e.chat.completions.create({...r,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Py(o,r))}async _runChatCompletion(e,r,n){for(let i of r.messages)this._addMessage(i,!1);return await this._createChatCompletion(e,r,n)}async _runTools(e,r,n){let i="tool",{tool_choice:o="auto",stream:s,...a}=r,c=typeof o!="string"&&o.type==="function"&&o?.function?.name,{maxChatCompletions:l=EFe}=n||{},u=r.tools.map(p=>{if(Jl(p)){if(!p.$callback)throw new me("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:p.$callback,name:p.function.name,description:p.function.description||"",parameters:p.function.parameters,parse:p.$parseRaw,strict:!0}}}return p}),d={};for(let p of u)p.type==="function"&&(d[p.function.name||p.function.function.name]=p.function);let f="tools"in r?u.map(p=>p.type==="function"?{type:"function",function:{name:p.function.name||p.function.function.name,parameters:p.function.parameters,description:p.function.description,strict:p.function.strict}}:p):void 0;for(let p of r.messages)this._addMessage(p,!1);for(let p=0;p<l;++p){let m=(await this._createChatCompletion(e,{...a,tool_choice:o,tools:f,messages:[...this.messages]},n)).choices[0]?.message;if(!m)throw new me("missing message in ChatCompletion response");if(!m.tool_calls?.length)return;for(let y of m.tool_calls){if(y.type!=="function")continue;let S=y.id,{name:T,arguments:x}=y.function,v=d[T];if(v){if(c&&c!==T){let C=`Invalid tool_call: ${JSON.stringify(T)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:S,content:C});continue}}else{let C=`Invalid tool_call: ${JSON.stringify(T)}. Available options are: ${Object.keys(d).map(D=>JSON.stringify(D)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:S,content:C});continue}let N;try{N=Ooe(v)?await v.parse(x):x}catch(C){let D=C instanceof Error?C.message:String(C);this._addMessage({role:i,tool_call_id:S,content:D});continue}let R=await v.function(N,this),U=$(this,$r,"m",koe).call(this,R);if(this._addMessage({role:i,tool_call_id:S,content:U}),c)return}}}};$r=new WeakSet,I2=function(){return $(this,$r,"m",vR).call(this).content??null},vR=function(){let e=this.messages.length;for(;e-- >0;){let r=this.messages[e];if(Ap(r))return{...r,content:r.content??null,refusal:r.refusal??null}}throw new me("stream ended without producing a ChatCompletionMessage with role=assistant")},C2=function(){for(let e=this.messages.length-1;e>=0;e--){let r=this.messages[e];if(Ap(r)&&r?.tool_calls?.length)return r.tool_calls.filter(n=>n.type==="function").at(-1)?.function}},P2=function(){for(let e=this.messages.length-1;e>=0;e--){let r=this.messages[e];if(A2(r)&&r.content!=null&&typeof r.content=="string"&&this.messages.some(n=>n.role==="assistant"&&n.tool_calls?.some(i=>i.type==="function"&&i.id===r.tool_call_id)))return r.content}},O2=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:r}of this._chatCompletions)r&&(e.completion_tokens+=r.completion_tokens,e.prompt_tokens+=r.prompt_tokens,e.total_tokens+=r.total_tokens);return e},Noe=function(e){if(e.n!=null&&e.n>1)throw new me("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},koe=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};var Dy=class t extends Ip{static runTools(e,r,n){let i=new t,o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,r,o)),i}_addMessage(e,r=!0){super._addMessage(e,r),Ap(e)&&e.content&&this._emit("content",e.content)}};var tr={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},N2=class extends Error{},k2=class extends Error{};function vFe(t,e=tr.ALL){if(typeof t!="string")throw new TypeError(`expecting str, got ${typeof t}`);if(!t.trim())throw new Error(`${t} is empty`);return bFe(t.trim(),e)}var bFe=(t,e)=>{let r=t.length,n=0,i=f=>{throw new N2(`${f} at position ${n}`)},o=f=>{throw new k2(`${f} at position ${n}`)},s=()=>(d(),n>=r&&i("Unexpected end of input"),t[n]==='"'?a():t[n]==="{"?c():t[n]==="["?l():t.substring(n,n+4)==="null"||tr.NULL&e&&r-n<4&&"null".startsWith(t.substring(n))?(n+=4,null):t.substring(n,n+4)==="true"||tr.BOOL&e&&r-n<4&&"true".startsWith(t.substring(n))?(n+=4,!0):t.substring(n,n+5)==="false"||tr.BOOL&e&&r-n<5&&"false".startsWith(t.substring(n))?(n+=5,!1):t.substring(n,n+8)==="Infinity"||tr.INFINITY&e&&r-n<8&&"Infinity".startsWith(t.substring(n))?(n+=8,1/0):t.substring(n,n+9)==="-Infinity"||tr.MINUS_INFINITY&e&&1<r-n&&r-n<9&&"-Infinity".startsWith(t.substring(n))?(n+=9,-1/0):t.substring(n,n+3)==="NaN"||tr.NAN&e&&r-n<3&&"NaN".startsWith(t.substring(n))?(n+=3,NaN):u()),a=()=>{let f=n,p=!1;for(n++;n<r&&(t[n]!=='"'||p&&t[n-1]==="\\");)p=t[n]==="\\"?!p:!1,n++;if(t.charAt(n)=='"')try{return JSON.parse(t.substring(f,++n-Number(p)))}catch(h){o(String(h))}else if(tr.STR&e)try{return JSON.parse(t.substring(f,n-Number(p))+'"')}catch{return JSON.parse(t.substring(f,t.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{n++,d();let f={};try{for(;t[n]!=="}";){if(d(),n>=r&&tr.OBJ&e)return f;let p=a();d(),n++;try{let h=s();Object.defineProperty(f,p,{value:h,writable:!0,enumerable:!0,configurable:!0})}catch(h){if(tr.OBJ&e)return f;throw h}d(),t[n]===","&&n++}}catch{if(tr.OBJ&e)return f;i("Expected '}' at end of object")}return n++,f},l=()=>{n++;let f=[];try{for(;t[n]!=="]";)f.push(s()),d(),t[n]===","&&n++}catch{if(tr.ARR&e)return f;i("Expected ']' at end of array")}return n++,f},u=()=>{if(n===0){t==="-"&&tr.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t)}catch(p){if(tr.NUM&e)try{return t[t.length-1]==="."?JSON.parse(t.substring(0,t.lastIndexOf("."))):JSON.parse(t.substring(0,t.lastIndexOf("e")))}catch{}o(String(p))}}let f=n;for(t[n]==="-"&&n++;t[n]&&!",]}".includes(t[n]);)n++;n==r&&!(tr.NUM&e)&&i("Unterminated number literal");try{return JSON.parse(t.substring(f,n))}catch{t.substring(f,n)==="-"&&tr.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t.substring(f,t.lastIndexOf("e")))}catch(h){o(String(h))}}},d=()=>{for(;n<r&&`
|
|
284
|
-
\r `.includes(t[n]);)n++};return s()},
|
|
283
|
+
${d}`)}return s},z=mFe(woe);var Zl=class extends q{list(e,r={},n){return this._client.getAPIList(z`/chat/completions/${e}/messages`,Le,{query:r,...n})}};function Iy(t){return t!==void 0&&"function"in t&&t.function!==void 0}function Cy(t){return t?.$brand==="auto-parseable-response-format"}function Jl(t){return t?.$brand==="auto-parseable-tool"}function Aoe(t,e){return!e||!wj(e)?{...t,choices:t.choices.map(r=>(Ioe(r.message.tool_calls),{...r,message:{...r.message,parsed:null,...r.message.tool_calls?{tool_calls:r.message.tool_calls}:void 0}}))}:Py(t,e)}function Py(t,e){let r=t.choices.map(n=>{if(n.finish_reason==="length")throw new bp;if(n.finish_reason==="content_filter")throw new Tp;return Ioe(n.message.tool_calls),{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:n.message.tool_calls?.map(i=>SFe(e,i))??void 0}:void 0,parsed:n.message.content&&!n.message.refusal?yFe(e,n.message.content):null}}});return{...t,choices:r}}function yFe(t,e){return t.response_format?.type!=="json_schema"?null:t.response_format?.type==="json_schema"?"$parseRaw"in t.response_format?t.response_format.$parseRaw(e):JSON.parse(e):null}function SFe(t,e){let r=t.tools?.find(n=>Iy(n)&&n.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:Jl(r)?r.$parseRaw(e.function.arguments):r?.function.strict?JSON.parse(e.function.arguments):null}}}function Roe(t,e){if(!t||!("tools"in t)||!t.tools)return!1;let r=t.tools?.find(n=>Iy(n)&&n.function?.name===e.function.name);return Iy(r)&&(Jl(r)||r?.function.strict||!1)}function wj(t){return Cy(t.response_format)?!0:t.tools?.some(e=>Jl(e)||e.type==="function"&&e.function.strict===!0)??!1}function Ioe(t){for(let e of t||[])if(e.type!=="function")throw new me(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function Coe(t){for(let e of t??[]){if(e.type!=="function")throw new me(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new me(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var Ap=t=>t?.role==="assistant",Aj=t=>t?.role==="tool";var Rj,gR,_R,Oy,Ny,yR,ky,ks,My,SR,ER,Rp,Poe,oc=class{constructor(){Rj.add(this),this.controller=new AbortController,gR.set(this,void 0),_R.set(this,()=>{}),Oy.set(this,()=>{}),Ny.set(this,void 0),yR.set(this,()=>{}),ky.set(this,()=>{}),ks.set(this,{}),My.set(this,!1),SR.set(this,!1),ER.set(this,!1),Rp.set(this,!1),ve(this,gR,new Promise((e,r)=>{ve(this,_R,e,"f"),ve(this,Oy,r,"f")}),"f"),ve(this,Ny,new Promise((e,r)=>{ve(this,yR,e,"f"),ve(this,ky,r,"f")}),"f"),$(this,gR,"f").catch(()=>{}),$(this,Ny,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},$(this,Rj,"m",Poe).bind(this))},0)}_connected(){this.ended||($(this,_R,"f").call(this),this._emit("connect"))}get ended(){return $(this,My,"f")}get errored(){return $(this,SR,"f")}get aborted(){return $(this,ER,"f")}abort(){this.controller.abort()}on(e,r){return($(this,ks,"f")[e]||($(this,ks,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=$(this,ks,"f")[e];if(!n)return this;let i=n.findIndex(o=>o.listener===r);return i>=0&&n.splice(i,1),this}once(e,r){return($(this,ks,"f")[e]||($(this,ks,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{ve(this,Rp,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){ve(this,Rp,!0,"f"),await $(this,Ny,"f")}_emit(e,...r){if($(this,My,"f"))return;e==="end"&&(ve(this,My,!0,"f"),$(this,yR,"f").call(this));let n=$(this,ks,"f")[e];if(n&&($(this,ks,"f")[e]=n.filter(i=>!i.once),n.forEach(({listener:i})=>i(...r))),e==="abort"){let i=r[0];!$(this,Rp,"f")&&!n?.length&&Promise.reject(i),$(this,Oy,"f").call(this,i),$(this,ky,"f").call(this,i),this._emit("end");return}if(e==="error"){let i=r[0];!$(this,Rp,"f")&&!n?.length&&Promise.reject(i),$(this,Oy,"f").call(this,i),$(this,ky,"f").call(this,i),this._emit("end")}}_emitFinal(){}};gR=new WeakMap,_R=new WeakMap,Oy=new WeakMap,Ny=new WeakMap,yR=new WeakMap,ky=new WeakMap,ks=new WeakMap,My=new WeakMap,SR=new WeakMap,ER=new WeakMap,Rp=new WeakMap,Rj=new WeakSet,Poe=function(e){if(ve(this,SR,!0,"f"),e instanceof Error&&e.name==="AbortError"&&(e=new Mt),e instanceof Mt)return ve(this,ER,!0,"f"),this._emit("abort",e);if(e instanceof me)return this._emit("error",e);if(e instanceof Error){let r=new me(e.message);return r.cause=e,this._emit("error",r)}return this._emit("error",new me(String(e)))};function Ooe(t){return typeof t.parse=="function"}var $r,Ij,vR,Cj,Pj,Oj,Noe,koe,EFe=10,Ip=class extends oc{constructor(){super(...arguments),$r.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let r=e.choices[0]?.message;return r&&this._addMessage(r),e}_addMessage(e,r=!0){if("content"in e||(e.content=null),this.messages.push(e),r){if(this._emit("message",e),Aj(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(Ap(e)&&e.tool_calls)for(let n of e.tool_calls)n.type==="function"&&this._emit("functionToolCall",n.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new me("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),$(this,$r,"m",Ij).call(this)}async finalMessage(){return await this.done(),$(this,$r,"m",vR).call(this)}async finalFunctionToolCall(){return await this.done(),$(this,$r,"m",Cj).call(this)}async finalFunctionToolCallResult(){return await this.done(),$(this,$r,"m",Pj).call(this)}async totalUsage(){return await this.done(),$(this,$r,"m",Oj).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let r=$(this,$r,"m",vR).call(this);r&&this._emit("finalMessage",r);let n=$(this,$r,"m",Ij).call(this);n&&this._emit("finalContent",n);let i=$(this,$r,"m",Cj).call(this);i&&this._emit("finalFunctionToolCall",i);let o=$(this,$r,"m",Pj).call(this);o!=null&&this._emit("finalFunctionToolCallResult",o),this._chatCompletions.some(s=>s.usage)&&this._emit("totalUsage",$(this,$r,"m",Oj).call(this))}async _createChatCompletion(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),$(this,$r,"m",Noe).call(this,r);let o=await e.chat.completions.create({...r,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Py(o,r))}async _runChatCompletion(e,r,n){for(let i of r.messages)this._addMessage(i,!1);return await this._createChatCompletion(e,r,n)}async _runTools(e,r,n){let i="tool",{tool_choice:o="auto",stream:s,...a}=r,c=typeof o!="string"&&o.type==="function"&&o?.function?.name,{maxChatCompletions:l=EFe}=n||{},u=r.tools.map(p=>{if(Jl(p)){if(!p.$callback)throw new me("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:p.$callback,name:p.function.name,description:p.function.description||"",parameters:p.function.parameters,parse:p.$parseRaw,strict:!0}}}return p}),d={};for(let p of u)p.type==="function"&&(d[p.function.name||p.function.function.name]=p.function);let f="tools"in r?u.map(p=>p.type==="function"?{type:"function",function:{name:p.function.name||p.function.function.name,parameters:p.function.parameters,description:p.function.description,strict:p.function.strict}}:p):void 0;for(let p of r.messages)this._addMessage(p,!1);for(let p=0;p<l;++p){let m=(await this._createChatCompletion(e,{...a,tool_choice:o,tools:f,messages:[...this.messages]},n)).choices[0]?.message;if(!m)throw new me("missing message in ChatCompletion response");if(!m.tool_calls?.length)return;for(let y of m.tool_calls){if(y.type!=="function")continue;let S=y.id,{name:T,arguments:x}=y.function,v=d[T];if(v){if(c&&c!==T){let C=`Invalid tool_call: ${JSON.stringify(T)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:S,content:C});continue}}else{let C=`Invalid tool_call: ${JSON.stringify(T)}. Available options are: ${Object.keys(d).map(D=>JSON.stringify(D)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:S,content:C});continue}let N;try{N=Ooe(v)?await v.parse(x):x}catch(C){let D=C instanceof Error?C.message:String(C);this._addMessage({role:i,tool_call_id:S,content:D});continue}let R=await v.function(N,this),U=$(this,$r,"m",koe).call(this,R);if(this._addMessage({role:i,tool_call_id:S,content:U}),c)return}}}};$r=new WeakSet,Ij=function(){return $(this,$r,"m",vR).call(this).content??null},vR=function(){let e=this.messages.length;for(;e-- >0;){let r=this.messages[e];if(Ap(r))return{...r,content:r.content??null,refusal:r.refusal??null}}throw new me("stream ended without producing a ChatCompletionMessage with role=assistant")},Cj=function(){for(let e=this.messages.length-1;e>=0;e--){let r=this.messages[e];if(Ap(r)&&r?.tool_calls?.length)return r.tool_calls.filter(n=>n.type==="function").at(-1)?.function}},Pj=function(){for(let e=this.messages.length-1;e>=0;e--){let r=this.messages[e];if(Aj(r)&&r.content!=null&&typeof r.content=="string"&&this.messages.some(n=>n.role==="assistant"&&n.tool_calls?.some(i=>i.type==="function"&&i.id===r.tool_call_id)))return r.content}},Oj=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:r}of this._chatCompletions)r&&(e.completion_tokens+=r.completion_tokens,e.prompt_tokens+=r.prompt_tokens,e.total_tokens+=r.total_tokens);return e},Noe=function(e){if(e.n!=null&&e.n>1)throw new me("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},koe=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};var Dy=class t extends Ip{static runTools(e,r,n){let i=new t,o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,r,o)),i}_addMessage(e,r=!0){super._addMessage(e,r),Ap(e)&&e.content&&this._emit("content",e.content)}};var tr={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},Nj=class extends Error{},kj=class extends Error{};function vFe(t,e=tr.ALL){if(typeof t!="string")throw new TypeError(`expecting str, got ${typeof t}`);if(!t.trim())throw new Error(`${t} is empty`);return bFe(t.trim(),e)}var bFe=(t,e)=>{let r=t.length,n=0,i=f=>{throw new Nj(`${f} at position ${n}`)},o=f=>{throw new kj(`${f} at position ${n}`)},s=()=>(d(),n>=r&&i("Unexpected end of input"),t[n]==='"'?a():t[n]==="{"?c():t[n]==="["?l():t.substring(n,n+4)==="null"||tr.NULL&e&&r-n<4&&"null".startsWith(t.substring(n))?(n+=4,null):t.substring(n,n+4)==="true"||tr.BOOL&e&&r-n<4&&"true".startsWith(t.substring(n))?(n+=4,!0):t.substring(n,n+5)==="false"||tr.BOOL&e&&r-n<5&&"false".startsWith(t.substring(n))?(n+=5,!1):t.substring(n,n+8)==="Infinity"||tr.INFINITY&e&&r-n<8&&"Infinity".startsWith(t.substring(n))?(n+=8,1/0):t.substring(n,n+9)==="-Infinity"||tr.MINUS_INFINITY&e&&1<r-n&&r-n<9&&"-Infinity".startsWith(t.substring(n))?(n+=9,-1/0):t.substring(n,n+3)==="NaN"||tr.NAN&e&&r-n<3&&"NaN".startsWith(t.substring(n))?(n+=3,NaN):u()),a=()=>{let f=n,p=!1;for(n++;n<r&&(t[n]!=='"'||p&&t[n-1]==="\\");)p=t[n]==="\\"?!p:!1,n++;if(t.charAt(n)=='"')try{return JSON.parse(t.substring(f,++n-Number(p)))}catch(h){o(String(h))}else if(tr.STR&e)try{return JSON.parse(t.substring(f,n-Number(p))+'"')}catch{return JSON.parse(t.substring(f,t.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{n++,d();let f={};try{for(;t[n]!=="}";){if(d(),n>=r&&tr.OBJ&e)return f;let p=a();d(),n++;try{let h=s();Object.defineProperty(f,p,{value:h,writable:!0,enumerable:!0,configurable:!0})}catch(h){if(tr.OBJ&e)return f;throw h}d(),t[n]===","&&n++}}catch{if(tr.OBJ&e)return f;i("Expected '}' at end of object")}return n++,f},l=()=>{n++;let f=[];try{for(;t[n]!=="]";)f.push(s()),d(),t[n]===","&&n++}catch{if(tr.ARR&e)return f;i("Expected ']' at end of array")}return n++,f},u=()=>{if(n===0){t==="-"&&tr.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t)}catch(p){if(tr.NUM&e)try{return t[t.length-1]==="."?JSON.parse(t.substring(0,t.lastIndexOf("."))):JSON.parse(t.substring(0,t.lastIndexOf("e")))}catch{}o(String(p))}}let f=n;for(t[n]==="-"&&n++;t[n]&&!",]}".includes(t[n]);)n++;n==r&&!(tr.NUM&e)&&i("Unterminated number literal");try{return JSON.parse(t.substring(f,n))}catch{t.substring(f,n)==="-"&&tr.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t.substring(f,t.lastIndexOf("e")))}catch(h){o(String(h))}}},d=()=>{for(;n<r&&`
|
|
284
|
+
\r `.includes(t[n]);)n++};return s()},Mj=t=>vFe(t,tr.ALL^tr.NUM);var qt,Ms,Cp,sc,Dj,bR,Lj,$j,Uj,TR,Fj,Moe,Xl=class t extends Ip{constructor(e){super(),qt.add(this),Ms.set(this,void 0),Cp.set(this,void 0),sc.set(this,void 0),ve(this,Ms,e,"f"),ve(this,Cp,[],"f")}get currentChatCompletionSnapshot(){return $(this,sc,"f")}static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createChatCompletion(e,r,n){let i=new t(r);return i._run(()=>i._runChatCompletion(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createChatCompletion(e,r,n){super._createChatCompletion;let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),$(this,qt,"m",Dj).call(this);let o=await e.chat.completions.create({...r,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let s of o)$(this,qt,"m",Lj).call(this,s);if(o.controller.signal?.aborted)throw new Mt;return this._addChatCompletion($(this,qt,"m",TR).call(this))}async _fromReadableStream(e,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),$(this,qt,"m",Dj).call(this),this._connected();let i=Ao.fromReadableStream(e,this.controller),o;for await(let s of i)o&&o!==s.id&&this._addChatCompletion($(this,qt,"m",TR).call(this)),$(this,qt,"m",Lj).call(this,s),o=s.id;if(i.controller.signal?.aborted)throw new Mt;return this._addChatCompletion($(this,qt,"m",TR).call(this))}[(Ms=new WeakMap,Cp=new WeakMap,sc=new WeakMap,qt=new WeakSet,Dj=function(){this.ended||ve(this,sc,void 0,"f")},bR=function(r){let n=$(this,Cp,"f")[r.index];return n||(n={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},$(this,Cp,"f")[r.index]=n,n)},Lj=function(r){if(this.ended)return;let n=$(this,qt,"m",Moe).call(this,r);this._emit("chunk",r,n);for(let i of r.choices){let o=n.choices[i.index];i.delta.content!=null&&o.message?.role==="assistant"&&o.message?.content&&(this._emit("content",i.delta.content,o.message.content),this._emit("content.delta",{delta:i.delta.content,snapshot:o.message.content,parsed:o.message.parsed})),i.delta.refusal!=null&&o.message?.role==="assistant"&&o.message?.refusal&&this._emit("refusal.delta",{delta:i.delta.refusal,snapshot:o.message.refusal}),i.logprobs?.content!=null&&o.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:i.logprobs?.content,snapshot:o.logprobs?.content??[]}),i.logprobs?.refusal!=null&&o.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:i.logprobs?.refusal,snapshot:o.logprobs?.refusal??[]});let s=$(this,qt,"m",bR).call(this,o);o.finish_reason&&($(this,qt,"m",Uj).call(this,o),s.current_tool_call_index!=null&&$(this,qt,"m",$j).call(this,o,s.current_tool_call_index));for(let a of i.delta.tool_calls??[])s.current_tool_call_index!==a.index&&($(this,qt,"m",Uj).call(this,o),s.current_tool_call_index!=null&&$(this,qt,"m",$j).call(this,o,s.current_tool_call_index)),s.current_tool_call_index=a.index;for(let a of i.delta.tool_calls??[]){let c=o.message.tool_calls?.[a.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:a.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):(c?.type,void 0))}}},$j=function(r,n){if($(this,qt,"m",bR).call(this,r).done_tool_calls.has(n))return;let o=r.message.tool_calls?.[n];if(!o)throw new Error("no tool call snapshot");if(!o.type)throw new Error("tool call snapshot missing `type`");if(o.type==="function"){let s=$(this,Ms,"f")?.tools?.find(a=>Iy(a)&&a.function.name===o.function.name);this._emit("tool_calls.function.arguments.done",{name:o.function.name,index:n,arguments:o.function.arguments,parsed_arguments:Jl(s)?s.$parseRaw(o.function.arguments):s?.function.strict?JSON.parse(o.function.arguments):null})}else o.type},Uj=function(r){let n=$(this,qt,"m",bR).call(this,r);if(r.message.content&&!n.content_done){n.content_done=!0;let i=$(this,qt,"m",Fj).call(this);this._emit("content.done",{content:r.message.content,parsed:i?i.$parseRaw(r.message.content):null})}r.message.refusal&&!n.refusal_done&&(n.refusal_done=!0,this._emit("refusal.done",{refusal:r.message.refusal})),r.logprobs?.content&&!n.logprobs_content_done&&(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:r.logprobs.content})),r.logprobs?.refusal&&!n.logprobs_refusal_done&&(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:r.logprobs.refusal}))},TR=function(){if(this.ended)throw new me("stream has ended, this shouldn't happen");let r=$(this,sc,"f");if(!r)throw new me("request ended without sending any chunks");return ve(this,sc,void 0,"f"),ve(this,Cp,[],"f"),TFe(r,$(this,Ms,"f"))},Fj=function(){let r=$(this,Ms,"f")?.response_format;return Cy(r)?r:null},Moe=function(r){var n,i,o,s;let a=$(this,sc,"f"),{choices:c,...l}=r;a?Object.assign(a,l):a=ve(this,sc,{...l,choices:[]},"f");for(let{delta:u,finish_reason:d,index:f,logprobs:p=null,...h}of r.choices){let m=a.choices[f];if(m||(m=a.choices[f]={finish_reason:d,index:f,message:{},logprobs:p,...h}),p)if(!m.logprobs)m.logprobs=Object.assign({},p);else{let{content:R,refusal:U,...C}=p;Object.assign(m.logprobs,C),R&&((n=m.logprobs).content??(n.content=[]),m.logprobs.content.push(...R)),U&&((i=m.logprobs).refusal??(i.refusal=[]),m.logprobs.refusal.push(...U))}if(d&&(m.finish_reason=d,$(this,Ms,"f")&&wj($(this,Ms,"f")))){if(d==="length")throw new bp;if(d==="content_filter")throw new Tp}if(Object.assign(m,h),!u)continue;let{content:y,refusal:S,function_call:T,role:x,tool_calls:v,...N}=u;if(Object.assign(m.message,N),S&&(m.message.refusal=(m.message.refusal||"")+S),x&&(m.message.role=x),T&&(m.message.function_call?(T.name&&(m.message.function_call.name=T.name),T.arguments&&((o=m.message.function_call).arguments??(o.arguments=""),m.message.function_call.arguments+=T.arguments)):m.message.function_call=T),y&&(m.message.content=(m.message.content||"")+y,!m.message.refusal&&$(this,qt,"m",Fj).call(this)&&(m.message.parsed=Mj(m.message.content))),v){m.message.tool_calls||(m.message.tool_calls=[]);for(let{index:R,id:U,type:C,function:D,...j}of v){let _=(s=m.message.tool_calls)[R]??(s[R]={});Object.assign(_,j),U&&(_.id=U),C&&(_.type=C),D&&(_.function??(_.function={name:D.name??"",arguments:""})),D?.name&&(_.function.name=D.name),D?.arguments&&(_.function.arguments+=D.arguments,Roe($(this,Ms,"f"),_)&&(_.function.parsed_arguments=Mj(_.function.arguments)))}}}return a},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("chunk",i=>{let o=r.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,s)=>r.push({resolve:o,reject:s})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ao(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function TFe(t,e){let{id:r,choices:n,created:i,model:o,system_fingerprint:s,...a}=t,c={...a,id:r,choices:n.map(({message:l,finish_reason:u,index:d,logprobs:f,...p})=>{if(!u)throw new me(`missing finish_reason for choice ${d}`);let{content:h=null,function_call:m,tool_calls:y,...S}=l,T=l.role;if(!T)throw new me(`missing role for choice ${d}`);if(m){let{arguments:x,name:v}=m;if(x==null)throw new me(`missing function_call.arguments for choice ${d}`);if(!v)throw new me(`missing function_call.name for choice ${d}`);return{...p,message:{content:h,function_call:{arguments:x,name:v},role:T,refusal:l.refusal??null},finish_reason:u,index:d,logprobs:f}}return y?{...p,index:d,finish_reason:u,logprobs:f,message:{...S,role:T,content:h,refusal:l.refusal??null,tool_calls:y.map((x,v)=>{let{function:N,type:R,id:U,...C}=x,{arguments:D,name:j,..._}=N||{};if(U==null)throw new me(`missing choices[${d}].tool_calls[${v}].id
|
|
285
285
|
${xR(t)}`);if(R==null)throw new me(`missing choices[${d}].tool_calls[${v}].type
|
|
286
286
|
${xR(t)}`);if(j==null)throw new me(`missing choices[${d}].tool_calls[${v}].function.name
|
|
287
287
|
${xR(t)}`);if(D==null)throw new me(`missing choices[${d}].tool_calls[${v}].function.arguments
|
|
288
|
-
${xR(t)}`);return{...C,id:U,type:R,function:{..._,name:j,arguments:D}}})}}:{...p,message:{...S,content:h,role:T,refusal:l.refusal??null},finish_reason:u,index:d,logprobs:f}}),created:i,model:o,object:"chat.completion",...s?{system_fingerprint:s}:{}};return Aoe(c,e)}function xR(t){return JSON.stringify(t)}var Ly=class t extends Xl{static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static runTools(e,r,n){let i=new t(r),o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,r,o)),i}};var Ds=class extends q{constructor(){super(...arguments),this.messages=new Zl(this._client)}create(e,r){return this._client.post("/chat/completions",{body:e,...r,stream:e.stream??!1})}retrieve(e,r){return this._client.get(z`/chat/completions/${e}`,r)}update(e,r,n){return this._client.post(z`/chat/completions/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/chat/completions",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/chat/completions/${e}`,r)}parse(e,r){return Coe(e.tools),this._client.chat.completions.create(e,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(n=>Py(n,e))}runTools(e,r){return e.stream?Ly.runTools(this._client,e,r):Dy.runTools(this._client,e,r)}stream(e,r){return Xl.createChatCompletion(this._client,e,r)}};Ds.Messages=Zl;var ac=class extends q{constructor(){super(...arguments),this.completions=new Ds(this._client)}};ac.Completions=Ds;var Doe=Symbol("brand.privateNullableHeaders");function*wFe(t){if(!t)return;if(Doe in t){let{values:n,nulls:i}=t;yield*n.entries();for(let o of i)yield[o,null];return}let e=!1,r;t instanceof Headers?r=t.entries():o2(t)?r=t:(e=!0,r=Object.entries(t??{}));for(let n of r){let i=n[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let o=o2(n[1])?n[1]:[n[1]],s=!1;for(let a of o)a!==void 0&&(e&&!s&&(s=!0,yield[i,null]),yield[i,a])}}var oe=t=>{let e=new Headers,r=new Set;for(let n of t){let i=new Set;for(let[o,s]of wFe(n)){let a=o.toLowerCase();i.has(a)||(e.delete(o),i.add(a)),s===null?(e.delete(o),r.add(a)):(e.append(o,s),r.delete(a))}}return{[Doe]:!0,values:e,nulls:r}};var Pp=class extends q{create(e,r){return this._client.post("/audio/speech",{body:e,...r,headers:oe([{Accept:"application/octet-stream"},r?.headers]),__binaryResponse:!0})}};var Op=class extends q{create(e,r){return this._client.post("/audio/transcriptions",Sr({body:e,...r,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}};var Np=class extends q{create(e,r){return this._client.post("/audio/translations",Sr({body:e,...r,__metadata:{model:e.model}},this._client))}};var Io=class extends q{constructor(){super(...arguments),this.transcriptions=new Op(this._client),this.translations=new Np(this._client),this.speech=new Pp(this._client)}};Io.Transcriptions=Op;Io.Translations=Np;Io.Speech=Pp;var Ql=class extends q{create(e,r){return this._client.post("/batches",{body:e,...r})}retrieve(e,r){return this._client.get(z`/batches/${e}`,r)}list(e={},r){return this._client.getAPIList("/batches",Le,{query:e,...r})}cancel(e,r){return this._client.post(z`/batches/${e}/cancel`,r)}};var kp=class extends q{create(e,r){return this._client.post("/assistants",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/assistants/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/assistants/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},r){return this._client.getAPIList("/assistants",Le,{query:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,r){return this._client.delete(z`/assistants/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Mp=class extends q{create(e,r){return this._client.post("/realtime/sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Dp=class extends q{create(e,r){return this._client.post("/realtime/transcription_sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var cc=class extends q{constructor(){super(...arguments),this.sessions=new Mp(this._client),this.transcriptionSessions=new Dp(this._client)}};cc.Sessions=Mp;cc.TranscriptionSessions=Dp;var Lp=class extends q{create(e,r){return this._client.post("/chatkit/sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}cancel(e,r){return this._client.post(z`/chatkit/sessions/${e}/cancel`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}};var $p=class extends q{retrieve(e,r){return this._client.get(z`/chatkit/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}list(e={},r){return this._client.getAPIList("/chatkit/threads",Ii,{query:e,...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}delete(e,r){return this._client.delete(z`/chatkit/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}listItems(e,r={},n){return this._client.getAPIList(z`/chatkit/threads/${e}/items`,Ii,{query:r,...n,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}};var lc=class extends q{constructor(){super(...arguments),this.sessions=new Lp(this._client),this.threads=new $p(this._client)}};lc.Sessions=Lp;lc.Threads=$p;var Up=class extends q{create(e,r,n){return this._client.post(z`/threads/${e}/messages`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{thread_id:i}=r;return this._client.get(z`/threads/${i}/messages/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/messages/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/threads/${e}/messages`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r,n){let{thread_id:i}=r;return this._client.delete(z`/threads/${i}/messages/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Fp=class extends q{retrieve(e,r,n){let{thread_id:i,run_id:o,...s}=r;return this._client.get(z`/threads/${i}/runs/${o}/steps/${e}`,{query:s,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r,n){let{thread_id:i,...o}=r;return this._client.getAPIList(z`/threads/${i}/runs/${e}/steps`,Le,{query:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Loe=t=>{if(typeof Buffer<"u"){let e=Buffer.from(t,"base64");return Array.from(new Float32Array(e.buffer,e.byteOffset,e.length/Float32Array.BYTES_PER_ELEMENT))}else{let e=atob(t),r=e.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);return Array.from(new Float32Array(n.buffer))}};var uc=t=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var dr,tu,B2,Co,wR,Ci,ru,Bp,eu,IR,An,AR,RR,Fy,$y,Uy,$oe,Uoe,Foe,Boe,joe,zoe,Goe,Ls=class extends oc{constructor(){super(...arguments),dr.add(this),B2.set(this,[]),Co.set(this,{}),wR.set(this,{}),Ci.set(this,void 0),ru.set(this,void 0),Bp.set(this,void 0),eu.set(this,void 0),IR.set(this,void 0),An.set(this,void 0),AR.set(this,void 0),RR.set(this,void 0),Fy.set(this,void 0)}[(B2=new WeakMap,Co=new WeakMap,wR=new WeakMap,Ci=new WeakMap,ru=new WeakMap,Bp=new WeakMap,eu=new WeakMap,IR=new WeakMap,An=new WeakMap,AR=new WeakMap,RR=new WeakMap,Fy=new WeakMap,dr=new WeakSet,Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,s)=>r.push({resolve:o,reject:s})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let r=new tu;return r._run(()=>r._fromReadableStream(e)),r}async _fromReadableStream(e,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();let i=Ao.fromReadableStream(e,this.controller);for await(let o of i)$(this,dr,"m",$y).call(this,o);if(i.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}toReadableStream(){return new Ao(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,r,n,i){let o=new tu;return o._run(()=>o._runToolAssistantStream(e,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createToolAssistantStream(e,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.submitToolOutputs(r,s,{...i,signal:this.controller.signal});this._connected();for await(let c of a)$(this,dr,"m",$y).call(this,c);if(a.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}static createThreadAssistantStream(e,r,n){let i=new tu;return i._run(()=>i._threadAssistantStream(e,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}static createAssistantStream(e,r,n,i){let o=new tu;return o._run(()=>o._runAssistantStream(e,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}currentEvent(){return $(this,AR,"f")}currentRun(){return $(this,RR,"f")}currentMessageSnapshot(){return $(this,Ci,"f")}currentRunStepSnapshot(){return $(this,Fy,"f")}async finalRunSteps(){return await this.done(),Object.values($(this,Co,"f"))}async finalMessages(){return await this.done(),Object.values($(this,wR,"f"))}async finalRun(){if(await this.done(),!$(this,ru,"f"))throw Error("Final run was not received.");return $(this,ru,"f")}async _createThreadAssistantStream(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let o={...r,stream:!0},s=await e.createAndRun(o,{...n,signal:this.controller.signal});this._connected();for await(let a of s)$(this,dr,"m",$y).call(this,a);if(s.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}async _createAssistantStream(e,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.create(r,s,{...i,signal:this.controller.signal});this._connected();for await(let c of a)$(this,dr,"m",$y).call(this,c);if(a.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}static accumulateDelta(e,r){for(let[n,i]of Object.entries(r)){if(!e.hasOwnProperty(n)){e[n]=i;continue}let o=e[n];if(o==null){e[n]=i;continue}if(n==="index"||n==="type"){e[n]=i;continue}if(typeof o=="string"&&typeof i=="string")o+=i;else if(typeof o=="number"&&typeof i=="number")o+=i;else if(vy(o)&&vy(i))o=this.accumulateDelta(o,i);else if(Array.isArray(o)&&Array.isArray(i)){if(o.every(s=>typeof s=="string"||typeof s=="number")){o.push(...i);continue}for(let s of i){if(!vy(s))throw new Error(`Expected array delta entry to be an object but got: ${s}`);let a=s.index;if(a==null)throw console.error(s),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);let c=o[a];c==null?o.push(s):o[a]=this.accumulateDelta(c,s)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${i}, accValue: ${o}`);e[n]=o}return e}_addRun(e){return e}async _threadAssistantStream(e,r,n){return await this._createThreadAssistantStream(r,e,n)}async _runAssistantStream(e,r,n,i){return await this._createAssistantStream(r,e,n,i)}async _runToolAssistantStream(e,r,n,i){return await this._createToolAssistantStream(r,e,n,i)}};tu=Ls,$y=function(e){if(!this.ended)switch(ve(this,AR,e,"f"),$(this,dr,"m",Foe).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":$(this,dr,"m",Goe).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":$(this,dr,"m",Uoe).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":$(this,dr,"m",$oe).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:}},Uy=function(){if(this.ended)throw new me("stream has ended, this shouldn't happen");if(!$(this,ru,"f"))throw Error("Final run has not been received");return $(this,ru,"f")},$oe=function(e){let[r,n]=$(this,dr,"m",joe).call(this,e,$(this,Ci,"f"));ve(this,Ci,r,"f"),$(this,wR,"f")[r.id]=r;for(let i of n){let o=r.content[i.index];o?.type=="text"&&this._emit("textCreated",o.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,r),e.data.delta.content)for(let i of e.data.delta.content){if(i.type=="text"&&i.text){let o=i.text,s=r.content[i.index];if(s&&s.type=="text")this._emit("textDelta",o,s.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(i.index!=$(this,Bp,"f")){if($(this,eu,"f"))switch($(this,eu,"f").type){case"text":this._emit("textDone",$(this,eu,"f").text,$(this,Ci,"f"));break;case"image_file":this._emit("imageFileDone",$(this,eu,"f").image_file,$(this,Ci,"f"));break}ve(this,Bp,i.index,"f")}ve(this,eu,r.content[i.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if($(this,Bp,"f")!==void 0){let i=e.data.content[$(this,Bp,"f")];if(i)switch(i.type){case"image_file":this._emit("imageFileDone",i.image_file,$(this,Ci,"f"));break;case"text":this._emit("textDone",i.text,$(this,Ci,"f"));break}}$(this,Ci,"f")&&this._emit("messageDone",e.data),ve(this,Ci,void 0,"f")}},Uoe=function(e){let r=$(this,dr,"m",Boe).call(this,e);switch(ve(this,Fy,r,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let n=e.data.delta;if(n.step_details&&n.step_details.type=="tool_calls"&&n.step_details.tool_calls&&r.step_details.type=="tool_calls")for(let o of n.step_details.tool_calls)o.index==$(this,IR,"f")?this._emit("toolCallDelta",o,r.step_details.tool_calls[o.index]):($(this,An,"f")&&this._emit("toolCallDone",$(this,An,"f")),ve(this,IR,o.index,"f"),ve(this,An,r.step_details.tool_calls[o.index],"f"),$(this,An,"f")&&this._emit("toolCallCreated",$(this,An,"f")));this._emit("runStepDelta",e.data.delta,r);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ve(this,Fy,void 0,"f"),e.data.step_details.type=="tool_calls"&&$(this,An,"f")&&(this._emit("toolCallDone",$(this,An,"f")),ve(this,An,void 0,"f")),this._emit("runStepDone",e.data,r);break;case"thread.run.step.in_progress":break}},Foe=function(e){$(this,B2,"f").push(e),this._emit("event",e)},Boe=function(e){switch(e.event){case"thread.run.step.created":return $(this,Co,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let r=$(this,Co,"f")[e.data.id];if(!r)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){let i=tu.accumulateDelta(r,n.delta);$(this,Co,"f")[e.data.id]=i}return $(this,Co,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":$(this,Co,"f")[e.data.id]=e.data;break}if($(this,Co,"f")[e.data.id])return $(this,Co,"f")[e.data.id];throw new Error("No snapshot available")},joe=function(e,r){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!r)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let i=e.data;if(i.delta.content)for(let o of i.delta.content)if(o.index in r.content){let s=r.content[o.index];r.content[o.index]=$(this,dr,"m",zoe).call(this,o,s)}else r.content[o.index]=o,n.push(o);return[r,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(r)return[r,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},zoe=function(e,r){return tu.accumulateDelta(r,e)},Goe=function(e){switch(ve(this,RR,e.data,"f"),e.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":ve(this,ru,e.data,"f"),$(this,An,"f")&&(this._emit("toolCallDone",$(this,An,"f")),ve(this,An,void 0,"f"));break;case"thread.run.cancelling":break}};var nu=class extends q{constructor(){super(...arguments),this.steps=new Fp(this._client)}create(e,r,n){let{include:i,...o}=r;return this._client.post(z`/threads/${e}/runs`,{query:{include:i},body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}retrieve(e,r,n){let{thread_id:i}=r;return this._client.get(z`/threads/${i}/runs/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/runs/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/threads/${e}/runs`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,r,n){let{thread_id:i}=r;return this._client.post(z`/threads/${i}/runs/${e}/cancel`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r,n);return await this.poll(i.id,{thread_id:e},n)}createAndStream(e,r,n){return Ls.createAssistantStream(e,this._client.beta.threads.runs,r,n)}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:s}=await this.retrieve(e,r,{...n,headers:{...n?.headers,...i}}).withResponse();switch(o.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=s.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return o}}}stream(e,r,n){return Ls.createAssistantStream(e,this._client.beta.threads.runs,r,n)}submitToolOutputs(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/runs/${e}/submit_tool_outputs`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,r,n){let i=await this.submitToolOutputs(e,r,n);return await this.poll(i.id,r,n)}submitToolOutputsStream(e,r,n){return Ls.createToolAssistantStream(e,this._client.beta.threads.runs,r,n)}};nu.Steps=Fp;var dc=class extends q{constructor(){super(...arguments),this.runs=new nu(this._client),this.messages=new Up(this._client)}create(e={},r){return this._client.post("/threads",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/threads/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r){return this._client.delete(z`/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}createAndRun(e,r){return this._client.post("/threads/runs",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,r){let n=await this.createAndRun(e,r);return await this.runs.poll(n.id,{thread_id:n.thread_id},r)}createAndRunStream(e,r){return Ls.createThreadAssistantStream(e,this._client.beta.threads,r)}};dc.Runs=nu;dc.Messages=Up;var Pi=class extends q{constructor(){super(...arguments),this.realtime=new cc(this._client),this.chatkit=new lc(this._client),this.assistants=new kp(this._client),this.threads=new dc(this._client)}};Pi.Realtime=cc;Pi.ChatKit=lc;Pi.Assistants=kp;Pi.Threads=dc;var iu=class extends q{create(e,r){return this._client.post("/completions",{body:e,...r,stream:e.stream??!1})}};var jp=class extends q{retrieve(e,r,n){let{container_id:i}=r;return this._client.get(z`/containers/${i}/files/${e}/content`,{...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var ou=class extends q{constructor(){super(...arguments),this.content=new jp(this._client)}create(e,r,n){return this._client.post(z`/containers/${e}/files`,ic({body:r,...n},this._client))}retrieve(e,r,n){let{container_id:i}=r;return this._client.get(z`/containers/${i}/files/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/containers/${e}/files`,Le,{query:r,...n})}delete(e,r,n){let{container_id:i}=r;return this._client.delete(z`/containers/${i}/files/${e}`,{...n,headers:oe([{Accept:"*/*"},n?.headers])})}};ou.Content=jp;var fc=class extends q{constructor(){super(...arguments),this.files=new ou(this._client)}create(e,r){return this._client.post("/containers",{body:e,...r})}retrieve(e,r){return this._client.get(z`/containers/${e}`,r)}list(e={},r){return this._client.getAPIList("/containers",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/containers/${e}`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}};fc.Files=ou;var zp=class extends q{create(e,r,n){let{include:i,...o}=r;return this._client.post(z`/conversations/${e}/items`,{query:{include:i},body:o,...n})}retrieve(e,r,n){let{conversation_id:i,...o}=r;return this._client.get(z`/conversations/${i}/items/${e}`,{query:o,...n})}list(e,r={},n){return this._client.getAPIList(z`/conversations/${e}/items`,Ii,{query:r,...n})}delete(e,r,n){let{conversation_id:i}=r;return this._client.delete(z`/conversations/${i}/items/${e}`,n)}};var pc=class extends q{constructor(){super(...arguments),this.items=new zp(this._client)}create(e={},r){return this._client.post("/conversations",{body:e,...r})}retrieve(e,r){return this._client.get(z`/conversations/${e}`,r)}update(e,r,n){return this._client.post(z`/conversations/${e}`,{body:r,...n})}delete(e,r){return this._client.delete(z`/conversations/${e}`,r)}};pc.Items=zp;var su=class extends q{create(e,r){let n=!!e.encoding_format,i=n?e.encoding_format:"base64";n&&Pt(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let o=this._client.post("/embeddings",{body:{...e,encoding_format:i},...r});return n?o:(Pt(this._client).debug("embeddings/decoding base64 embeddings from base64"),o._thenUnwrap(s=>(s&&s.data&&s.data.forEach(a=>{let c=a.embedding;a.embedding=Loe(c)}),s)))}};var Gp=class extends q{retrieve(e,r,n){let{eval_id:i,run_id:o}=r;return this._client.get(z`/evals/${i}/runs/${o}/output_items/${e}`,n)}list(e,r,n){let{eval_id:i,...o}=r;return this._client.getAPIList(z`/evals/${i}/runs/${e}/output_items`,Le,{query:o,...n})}};var au=class extends q{constructor(){super(...arguments),this.outputItems=new Gp(this._client)}create(e,r,n){return this._client.post(z`/evals/${e}/runs`,{body:r,...n})}retrieve(e,r,n){let{eval_id:i}=r;return this._client.get(z`/evals/${i}/runs/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/evals/${e}/runs`,Le,{query:r,...n})}delete(e,r,n){let{eval_id:i}=r;return this._client.delete(z`/evals/${i}/runs/${e}`,n)}cancel(e,r,n){let{eval_id:i}=r;return this._client.post(z`/evals/${i}/runs/${e}`,n)}};au.OutputItems=Gp;var hc=class extends q{constructor(){super(...arguments),this.runs=new au(this._client)}create(e,r){return this._client.post("/evals",{body:e,...r})}retrieve(e,r){return this._client.get(z`/evals/${e}`,r)}update(e,r,n){return this._client.post(z`/evals/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/evals",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/evals/${e}`,r)}};hc.Runs=au;var cu=class extends q{create(e,r){return this._client.post("/files",Sr({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/files/${e}`,r)}list(e={},r){return this._client.getAPIList("/files",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/files/${e}`,r)}content(e,r){return this._client.get(z`/files/${e}/content`,{...r,headers:oe([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:r=5e3,maxWait:n=1800*1e3}={}){let i=new Set(["processed","error","deleted"]),o=Date.now(),s=await this.retrieve(e);for(;!s.status||!i.has(s.status);)if(await xo(r),s=await this.retrieve(e),Date.now()-o>n)throw new rc({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return s}};var qp=class extends q{};var Vp=class extends q{run(e,r){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...r})}validate(e,r){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...r})}};var lu=class extends q{constructor(){super(...arguments),this.graders=new Vp(this._client)}};lu.Graders=Vp;var Hp=class extends q{create(e,r,n){return this._client.getAPIList(z`/fine_tuning/checkpoints/${e}/permissions`,Ro,{body:r,method:"post",...n})}retrieve(e,r={},n){return this._client.get(z`/fine_tuning/checkpoints/${e}/permissions`,{query:r,...n})}list(e,r={},n){return this._client.getAPIList(z`/fine_tuning/checkpoints/${e}/permissions`,Ii,{query:r,...n})}delete(e,r,n){let{fine_tuned_model_checkpoint:i}=r;return this._client.delete(z`/fine_tuning/checkpoints/${i}/permissions/${e}`,n)}};var uu=class extends q{constructor(){super(...arguments),this.permissions=new Hp(this._client)}};uu.Permissions=Hp;var Wp=class extends q{list(e,r={},n){return this._client.getAPIList(z`/fine_tuning/jobs/${e}/checkpoints`,Le,{query:r,...n})}};var du=class extends q{constructor(){super(...arguments),this.checkpoints=new Wp(this._client)}create(e,r){return this._client.post("/fine_tuning/jobs",{body:e,...r})}retrieve(e,r){return this._client.get(z`/fine_tuning/jobs/${e}`,r)}list(e={},r){return this._client.getAPIList("/fine_tuning/jobs",Le,{query:e,...r})}cancel(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/cancel`,r)}listEvents(e,r={},n){return this._client.getAPIList(z`/fine_tuning/jobs/${e}/events`,Le,{query:r,...n})}pause(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/pause`,r)}resume(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/resume`,r)}};du.Checkpoints=Wp;var Oi=class extends q{constructor(){super(...arguments),this.methods=new qp(this._client),this.jobs=new du(this._client),this.checkpoints=new uu(this._client),this.alpha=new lu(this._client)}};Oi.Methods=qp;Oi.Jobs=du;Oi.Checkpoints=uu;Oi.Alpha=lu;var Yp=class extends q{};var mc=class extends q{constructor(){super(...arguments),this.graderModels=new Yp(this._client)}};mc.GraderModels=Yp;var fu=class extends q{createVariation(e,r){return this._client.post("/images/variations",Sr({body:e,...r},this._client))}edit(e,r){return this._client.post("/images/edits",Sr({body:e,...r,stream:e.stream??!1},this._client))}generate(e,r){return this._client.post("/images/generations",{body:e,...r,stream:e.stream??!1})}};var pu=class extends q{retrieve(e,r){return this._client.get(z`/models/${e}`,r)}list(e){return this._client.getAPIList("/models",Ro,e)}delete(e,r){return this._client.delete(z`/models/${e}`,r)}};var hu=class extends q{create(e,r){return this._client.post("/moderations",{body:e,...r})}};var Kp=class extends q{accept(e,r,n){return this._client.post(z`/realtime/calls/${e}/accept`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}hangup(e,r){return this._client.post(z`/realtime/calls/${e}/hangup`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}refer(e,r,n){return this._client.post(z`/realtime/calls/${e}/refer`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}reject(e,r={},n){return this._client.post(z`/realtime/calls/${e}/reject`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}};var Zp=class extends q{create(e,r){return this._client.post("/realtime/client_secrets",{body:e,...r})}};var $s=class extends q{constructor(){super(...arguments),this.clientSecrets=new Zp(this._client),this.calls=new Kp(this._client)}};$s.ClientSecrets=Zp;$s.Calls=Kp;function qoe(t,e){return!e||!rBe(e)?{...t,output_parsed:null,output:t.output.map(r=>r.type==="function_call"?{...r,parsed_arguments:null}:r.type==="message"?{...r,content:r.content.map(n=>({...n,parsed:null}))}:r)}:j2(t,e)}function j2(t,e){let r=t.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:oBe(e,i)};if(i.type==="message"){let o=i.content.map(s=>s.type==="output_text"?{...s,parsed:tBe(e,s.text)}:s);return{...i,content:o}}return i}),n=Object.assign({},t,{output:r});return Object.getOwnPropertyDescriptor(t,"output_text")||CR(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(let i of n.output)if(i.type==="message"){for(let o of i.content)if(o.type==="output_text"&&o.parsed!==null)return o.parsed}return null}}),n}function tBe(t,e){return t.text?.format?.type!=="json_schema"?null:"$parseRaw"in t.text?.format?(t.text?.format).$parseRaw(e):JSON.parse(e)}function rBe(t){return!!Cy(t.text?.format)}function nBe(t){return t?.$brand==="auto-parseable-tool"}function iBe(t,e){return t.find(r=>r.type==="function"&&r.name===e)}function oBe(t,e){let r=iBe(t.tools??[],e.name);return{...e,...e,parsed_arguments:nBe(r)?r.$parseRaw(e.arguments):r?.strict?JSON.parse(e.arguments):null}}function CR(t){let e=[];for(let r of t.output)if(r.type==="message")for(let n of r.content)n.type==="output_text"&&e.push(n.text);t.output_text=e.join("")}var Jp,PR,gc,OR,Voe,Hoe,Woe,Yoe,NR=class t extends oc{constructor(e){super(),Jp.add(this),PR.set(this,void 0),gc.set(this,void 0),OR.set(this,void 0),ve(this,PR,e,"f")}static createResponse(e,r,n){let i=new t(r);return i._run(()=>i._createOrRetrieveResponse(e,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createOrRetrieveResponse(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),$(this,Jp,"m",Voe).call(this);let o,s=null;"response_id"in r?(o=await e.responses.retrieve(r.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),s=r.starting_after??null):o=await e.responses.create({...r,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let a of o)$(this,Jp,"m",Hoe).call(this,a,s);if(o.controller.signal?.aborted)throw new Mt;return $(this,Jp,"m",Woe).call(this)}[(PR=new WeakMap,gc=new WeakMap,OR=new WeakMap,Jp=new WeakSet,Voe=function(){this.ended||ve(this,gc,void 0,"f")},Hoe=function(r,n){if(this.ended)return;let i=(s,a)=>{(n==null||a.sequence_number>n)&&this._emit(s,a)},o=$(this,Jp,"m",Yoe).call(this,r);switch(i("event",r),r.type){case"response.output_text.delta":{let s=o.output[r.output_index];if(!s)throw new me(`missing output at index ${r.output_index}`);if(s.type==="message"){let a=s.content[r.content_index];if(!a)throw new me(`missing content at index ${r.content_index}`);if(a.type!=="output_text")throw new me(`expected content to be 'output_text', got ${a.type}`);i("response.output_text.delta",{...r,snapshot:a.text})}break}case"response.function_call_arguments.delta":{let s=o.output[r.output_index];if(!s)throw new me(`missing output at index ${r.output_index}`);s.type==="function_call"&&i("response.function_call_arguments.delta",{...r,snapshot:s.arguments});break}default:i(r.type,r);break}},Woe=function(){if(this.ended)throw new me("stream has ended, this shouldn't happen");let r=$(this,gc,"f");if(!r)throw new me("request ended without sending any events");ve(this,gc,void 0,"f");let n=sBe(r,$(this,PR,"f"));return ve(this,OR,n,"f"),n},Yoe=function(r){let n=$(this,gc,"f");if(!n){if(r.type!=="response.created")throw new me(`When snapshot hasn't been set yet, expected 'response.created' event, got ${r.type}`);return n=ve(this,gc,r.response,"f"),n}switch(r.type){case"response.output_item.added":{n.output.push(r.item);break}case"response.content_part.added":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);let o=i.type,s=r.part;o==="message"&&s.type!=="reasoning_text"?i.content.push(s):o==="reasoning"&&s.type==="reasoning_text"&&(i.content||(i.content=[]),i.content.push(s));break}case"response.output_text.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);if(i.type==="message"){let o=i.content[r.content_index];if(!o)throw new me(`missing content at index ${r.content_index}`);if(o.type!=="output_text")throw new me(`expected content to be 'output_text', got ${o.type}`);o.text+=r.delta}break}case"response.function_call_arguments.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);i.type==="function_call"&&(i.arguments+=r.delta);break}case"response.reasoning_text.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);if(i.type==="reasoning"){let o=i.content?.[r.content_index];if(!o)throw new me(`missing content at index ${r.content_index}`);if(o.type!=="reasoning_text")throw new me(`expected content to be 'reasoning_text', got ${o.type}`);o.text+=r.delta}break}case"response.completed":{ve(this,gc,r.response,"f");break}}return n},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,s)=>r.push({resolve:o,reject:s})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=$(this,OR,"f");if(!e)throw new me("stream ended without producing a ChatCompletion");return e}};function sBe(t,e){return qoe(t,e)}var Xp=class extends q{list(e,r={},n){return this._client.getAPIList(z`/responses/${e}/input_items`,Le,{query:r,...n})}};var Qp=class extends q{count(e={},r){return this._client.post("/responses/input_tokens",{body:e,...r})}};var Us=class extends q{constructor(){super(...arguments),this.inputItems=new Xp(this._client),this.inputTokens=new Qp(this._client)}create(e,r){return this._client.post("/responses",{body:e,...r,stream:e.stream??!1})._thenUnwrap(n=>("object"in n&&n.object==="response"&&CR(n),n))}retrieve(e,r={},n){return this._client.get(z`/responses/${e}`,{query:r,...n,stream:r?.stream??!1})._thenUnwrap(i=>("object"in i&&i.object==="response"&&CR(i),i))}delete(e,r){return this._client.delete(z`/responses/${e}`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}parse(e,r){return this._client.responses.create(e,r)._thenUnwrap(n=>j2(n,e))}stream(e,r){return NR.createResponse(this._client,e,r)}cancel(e,r){return this._client.post(z`/responses/${e}/cancel`,r)}compact(e,r){return this._client.post("/responses/compact",{body:e,...r})}};Us.InputItems=Xp;Us.InputTokens=Qp;var eh=class extends q{retrieve(e,r){return this._client.get(z`/skills/${e}/content`,{...r,headers:oe([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}};var th=class extends q{retrieve(e,r,n){let{skill_id:i}=r;return this._client.get(z`/skills/${i}/versions/${e}/content`,{...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var mu=class extends q{constructor(){super(...arguments),this.content=new th(this._client)}create(e,r={},n){return this._client.post(z`/skills/${e}/versions`,ic({body:r,...n},this._client))}retrieve(e,r,n){let{skill_id:i}=r;return this._client.get(z`/skills/${i}/versions/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/skills/${e}/versions`,Le,{query:r,...n})}delete(e,r,n){let{skill_id:i}=r;return this._client.delete(z`/skills/${i}/versions/${e}`,n)}};mu.Content=th;var Fs=class extends q{constructor(){super(...arguments),this.content=new eh(this._client),this.versions=new mu(this._client)}create(e={},r){return this._client.post("/skills",ic({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/skills/${e}`,r)}update(e,r,n){return this._client.post(z`/skills/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/skills",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/skills/${e}`,r)}};Fs.Content=eh;Fs.Versions=mu;var rh=class extends q{create(e,r,n){return this._client.post(z`/uploads/${e}/parts`,Sr({body:r,...n},this._client))}};var _c=class extends q{constructor(){super(...arguments),this.parts=new rh(this._client)}create(e,r){return this._client.post("/uploads",{body:e,...r})}cancel(e,r){return this._client.post(z`/uploads/${e}/cancel`,r)}complete(e,r,n){return this._client.post(z`/uploads/${e}/complete`,{body:r,...n})}};_c.Parts=rh;var Koe=async t=>{let e=await Promise.allSettled(t),r=e.filter(i=>i.status==="rejected");if(r.length){for(let i of r)console.error(i.reason);throw new Error(`${r.length} promise(s) failed - see the above errors`)}let n=[];for(let i of e)i.status==="fulfilled"&&n.push(i.value);return n};var nh=class extends q{create(e,r,n){return this._client.post(z`/vector_stores/${e}/file_batches`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{vector_store_id:i}=r;return this._client.get(z`/vector_stores/${i}/file_batches/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,r,n){let{vector_store_id:i}=r;return this._client.post(z`/vector_stores/${i}/file_batches/${e}/cancel`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r);return await this.poll(e,i.id,n)}listFiles(e,r,n){let{vector_store_id:i,...o}=r;return this._client.getAPIList(z`/vector_stores/${i}/file_batches/${e}/files`,Le,{query:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:s}=await this.retrieve(r,{vector_store_id:e},{...n,headers:i}).withResponse();switch(o.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=s.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"failed":case"cancelled":case"completed":return o}}}async uploadAndPoll(e,{files:r,fileIds:n=[]},i){if(r==null||r.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let o=i?.maxConcurrency??5,s=Math.min(o,r.length),a=this._client,c=r.values(),l=[...n];async function u(f){for(let p of f){let h=await a.files.create({file:p,purpose:"assistants"},i);l.push(h.id)}}let d=Array(s).fill(c).map(u);return await Koe(d),await this.createAndPoll(e,{file_ids:l})}};var ih=class extends q{create(e,r,n){return this._client.post(z`/vector_stores/${e}/files`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{vector_store_id:i}=r;return this._client.get(z`/vector_stores/${i}/files/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{vector_store_id:i,...o}=r;return this._client.post(z`/vector_stores/${i}/files/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/vector_stores/${e}/files`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r,n){let{vector_store_id:i}=r;return this._client.delete(z`/vector_stores/${i}/files/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r,n);return await this.poll(e,i.id,n)}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let o=await this.retrieve(r,{vector_store_id:e},{...n,headers:i}).withResponse(),s=o.data;switch(s.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=o.response.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"failed":case"completed":return s}}}async upload(e,r,n){let i=await this._client.files.create({file:r,purpose:"assistants"},n);return this.create(e,{file_id:i.id},n)}async uploadAndPoll(e,r,n){let i=await this.upload(e,r,n);return await this.poll(e,i.id,n)}content(e,r,n){let{vector_store_id:i}=r;return this._client.getAPIList(z`/vector_stores/${i}/files/${e}/content`,Ro,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Bs=class extends q{constructor(){super(...arguments),this.files=new ih(this._client),this.fileBatches=new nh(this._client)}create(e,r){return this._client.post("/vector_stores",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/vector_stores/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/vector_stores/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},r){return this._client.getAPIList("/vector_stores",Le,{query:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,r){return this._client.delete(z`/vector_stores/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}search(e,r,n){return this._client.getAPIList(z`/vector_stores/${e}/search`,Ro,{body:r,method:"post",...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};Bs.Files=ih;Bs.FileBatches=nh;var gu=class extends q{create(e,r){return this._client.post("/videos",Sr({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/videos/${e}`,r)}list(e={},r){return this._client.getAPIList("/videos",Ii,{query:e,...r})}delete(e,r){return this._client.delete(z`/videos/${e}`,r)}createCharacter(e,r){return this._client.post("/videos/characters",Sr({body:e,...r},this._client))}downloadContent(e,r={},n){return this._client.get(z`/videos/${e}/content`,{query:r,...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}edit(e,r){return this._client.post("/videos/edits",Sr({body:e,...r},this._client))}extend(e,r){return this._client.post("/videos/extensions",Sr({body:e,...r},this._client))}getCharacter(e,r){return this._client.get(z`/videos/characters/${e}`,r)}remix(e,r,n){return this._client.post(z`/videos/${e}/remix`,ic({body:r,...n},this._client))}};var oh,Zoe,kR,_u=class extends q{constructor(){super(...arguments),oh.add(this)}async unwrap(e,r,n=this._client.webhookSecret,i=300){return await this.verifySignature(e,r,n,i),JSON.parse(e)}async verifySignature(e,r,n=this._client.webhookSecret,i=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");$(this,oh,"m",Zoe).call(this,n);let o=oe([r]).values,s=$(this,oh,"m",kR).call(this,o,"webhook-signature"),a=$(this,oh,"m",kR).call(this,o,"webhook-timestamp"),c=$(this,oh,"m",kR).call(this,o,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new To("Invalid webhook timestamp format");let u=Math.floor(Date.now()/1e3);if(u-l>i)throw new To("Webhook timestamp is too old");if(l>u+i)throw new To("Webhook timestamp is too new");let d=s.split(" ").map(m=>m.startsWith("v1,")?m.substring(3):m),f=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),p=c?`${c}.${a}.${e}`:`${a}.${e}`,h=await crypto.subtle.importKey("raw",f,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let m of d)try{let y=Buffer.from(m,"base64");if(await crypto.subtle.verify("HMAC",h,y,new TextEncoder().encode(p)))return}catch{continue}throw new To("The given webhook signature does not match the expected signature")}};oh=new WeakSet,Zoe=function(e){if(typeof e!="string"||e.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},kR=function(e,r){if(!e)throw new Error("Headers are required");let n=e.get(r);if(n==null)throw new Error(`Missing required header: ${r}`);return n};var G2,q2,MR,Joe,z2="workload-identity-auth",Ne=class{constructor({baseURL:e=uc("OPENAI_BASE_URL"),apiKey:r=uc("OPENAI_API_KEY"),organization:n=uc("OPENAI_ORG_ID")??null,project:i=uc("OPENAI_PROJECT_ID")??null,webhookSecret:o=uc("OPENAI_WEBHOOK_SECRET")??null,workloadIdentity:s,...a}={}){if(G2.add(this),MR.set(this,void 0),this.completions=new iu(this),this.chat=new ac(this),this.embeddings=new su(this),this.files=new cu(this),this.images=new fu(this),this.audio=new Io(this),this.moderations=new hu(this),this.models=new pu(this),this.fineTuning=new Oi(this),this.graders=new mc(this),this.vectorStores=new Bs(this),this.webhooks=new _u(this),this.beta=new Pi(this),this.batches=new Ql(this),this.uploads=new _c(this),this.responses=new Us(this),this.realtime=new $s(this),this.conversations=new pc(this),this.evals=new hc(this),this.containers=new fc(this),this.skills=new Fs(this),this.videos=new gu(this),s){if(r&&r!==z2)throw new me("The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.");r=z2}else if(r===void 0)throw new me("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.");let c={apiKey:r,organization:n,project:i,webhookSecret:o,workloadIdentity:s,...a,baseURL:e||"https://api.openai.com/v1"};if(!c.dangerouslyAllowBrowser&&roe())throw new me(`It looks like you're running in a browser-like environment.
|
|
288
|
+
${xR(t)}`);return{...C,id:U,type:R,function:{..._,name:j,arguments:D}}})}}:{...p,message:{...S,content:h,role:T,refusal:l.refusal??null},finish_reason:u,index:d,logprobs:f}}),created:i,model:o,object:"chat.completion",...s?{system_fingerprint:s}:{}};return Aoe(c,e)}function xR(t){return JSON.stringify(t)}var Ly=class t extends Xl{static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static runTools(e,r,n){let i=new t(r),o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,r,o)),i}};var Ds=class extends q{constructor(){super(...arguments),this.messages=new Zl(this._client)}create(e,r){return this._client.post("/chat/completions",{body:e,...r,stream:e.stream??!1})}retrieve(e,r){return this._client.get(z`/chat/completions/${e}`,r)}update(e,r,n){return this._client.post(z`/chat/completions/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/chat/completions",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/chat/completions/${e}`,r)}parse(e,r){return Coe(e.tools),this._client.chat.completions.create(e,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(n=>Py(n,e))}runTools(e,r){return e.stream?Ly.runTools(this._client,e,r):Dy.runTools(this._client,e,r)}stream(e,r){return Xl.createChatCompletion(this._client,e,r)}};Ds.Messages=Zl;var ac=class extends q{constructor(){super(...arguments),this.completions=new Ds(this._client)}};ac.Completions=Ds;var Doe=Symbol("brand.privateNullableHeaders");function*wFe(t){if(!t)return;if(Doe in t){let{values:n,nulls:i}=t;yield*n.entries();for(let o of i)yield[o,null];return}let e=!1,r;t instanceof Headers?r=t.entries():oj(t)?r=t:(e=!0,r=Object.entries(t??{}));for(let n of r){let i=n[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let o=oj(n[1])?n[1]:[n[1]],s=!1;for(let a of o)a!==void 0&&(e&&!s&&(s=!0,yield[i,null]),yield[i,a])}}var oe=t=>{let e=new Headers,r=new Set;for(let n of t){let i=new Set;for(let[o,s]of wFe(n)){let a=o.toLowerCase();i.has(a)||(e.delete(o),i.add(a)),s===null?(e.delete(o),r.add(a)):(e.append(o,s),r.delete(a))}}return{[Doe]:!0,values:e,nulls:r}};var Pp=class extends q{create(e,r){return this._client.post("/audio/speech",{body:e,...r,headers:oe([{Accept:"application/octet-stream"},r?.headers]),__binaryResponse:!0})}};var Op=class extends q{create(e,r){return this._client.post("/audio/transcriptions",Sr({body:e,...r,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}};var Np=class extends q{create(e,r){return this._client.post("/audio/translations",Sr({body:e,...r,__metadata:{model:e.model}},this._client))}};var Io=class extends q{constructor(){super(...arguments),this.transcriptions=new Op(this._client),this.translations=new Np(this._client),this.speech=new Pp(this._client)}};Io.Transcriptions=Op;Io.Translations=Np;Io.Speech=Pp;var Ql=class extends q{create(e,r){return this._client.post("/batches",{body:e,...r})}retrieve(e,r){return this._client.get(z`/batches/${e}`,r)}list(e={},r){return this._client.getAPIList("/batches",Le,{query:e,...r})}cancel(e,r){return this._client.post(z`/batches/${e}/cancel`,r)}};var kp=class extends q{create(e,r){return this._client.post("/assistants",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/assistants/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/assistants/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},r){return this._client.getAPIList("/assistants",Le,{query:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,r){return this._client.delete(z`/assistants/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Mp=class extends q{create(e,r){return this._client.post("/realtime/sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Dp=class extends q{create(e,r){return this._client.post("/realtime/transcription_sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var cc=class extends q{constructor(){super(...arguments),this.sessions=new Mp(this._client),this.transcriptionSessions=new Dp(this._client)}};cc.Sessions=Mp;cc.TranscriptionSessions=Dp;var Lp=class extends q{create(e,r){return this._client.post("/chatkit/sessions",{body:e,...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}cancel(e,r){return this._client.post(z`/chatkit/sessions/${e}/cancel`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}};var $p=class extends q{retrieve(e,r){return this._client.get(z`/chatkit/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}list(e={},r){return this._client.getAPIList("/chatkit/threads",Ii,{query:e,...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}delete(e,r){return this._client.delete(z`/chatkit/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}listItems(e,r={},n){return this._client.getAPIList(z`/chatkit/threads/${e}/items`,Ii,{query:r,...n,headers:oe([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}};var lc=class extends q{constructor(){super(...arguments),this.sessions=new Lp(this._client),this.threads=new $p(this._client)}};lc.Sessions=Lp;lc.Threads=$p;var Up=class extends q{create(e,r,n){return this._client.post(z`/threads/${e}/messages`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{thread_id:i}=r;return this._client.get(z`/threads/${i}/messages/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/messages/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/threads/${e}/messages`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r,n){let{thread_id:i}=r;return this._client.delete(z`/threads/${i}/messages/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Fp=class extends q{retrieve(e,r,n){let{thread_id:i,run_id:o,...s}=r;return this._client.get(z`/threads/${i}/runs/${o}/steps/${e}`,{query:s,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r,n){let{thread_id:i,...o}=r;return this._client.getAPIList(z`/threads/${i}/runs/${e}/steps`,Le,{query:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Loe=t=>{if(typeof Buffer<"u"){let e=Buffer.from(t,"base64");return Array.from(new Float32Array(e.buffer,e.byteOffset,e.length/Float32Array.BYTES_PER_ELEMENT))}else{let e=atob(t),r=e.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);return Array.from(new Float32Array(n.buffer))}};var uc=t=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var dr,tu,Bj,Co,wR,Ci,ru,Bp,eu,IR,An,AR,RR,Fy,$y,Uy,$oe,Uoe,Foe,Boe,joe,zoe,Goe,Ls=class extends oc{constructor(){super(...arguments),dr.add(this),Bj.set(this,[]),Co.set(this,{}),wR.set(this,{}),Ci.set(this,void 0),ru.set(this,void 0),Bp.set(this,void 0),eu.set(this,void 0),IR.set(this,void 0),An.set(this,void 0),AR.set(this,void 0),RR.set(this,void 0),Fy.set(this,void 0)}[(Bj=new WeakMap,Co=new WeakMap,wR=new WeakMap,Ci=new WeakMap,ru=new WeakMap,Bp=new WeakMap,eu=new WeakMap,IR=new WeakMap,An=new WeakMap,AR=new WeakMap,RR=new WeakMap,Fy=new WeakMap,dr=new WeakSet,Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,s)=>r.push({resolve:o,reject:s})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let r=new tu;return r._run(()=>r._fromReadableStream(e)),r}async _fromReadableStream(e,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();let i=Ao.fromReadableStream(e,this.controller);for await(let o of i)$(this,dr,"m",$y).call(this,o);if(i.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}toReadableStream(){return new Ao(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,r,n,i){let o=new tu;return o._run(()=>o._runToolAssistantStream(e,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createToolAssistantStream(e,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.submitToolOutputs(r,s,{...i,signal:this.controller.signal});this._connected();for await(let c of a)$(this,dr,"m",$y).call(this,c);if(a.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}static createThreadAssistantStream(e,r,n){let i=new tu;return i._run(()=>i._threadAssistantStream(e,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}static createAssistantStream(e,r,n,i){let o=new tu;return o._run(()=>o._runAssistantStream(e,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}currentEvent(){return $(this,AR,"f")}currentRun(){return $(this,RR,"f")}currentMessageSnapshot(){return $(this,Ci,"f")}currentRunStepSnapshot(){return $(this,Fy,"f")}async finalRunSteps(){return await this.done(),Object.values($(this,Co,"f"))}async finalMessages(){return await this.done(),Object.values($(this,wR,"f"))}async finalRun(){if(await this.done(),!$(this,ru,"f"))throw Error("Final run was not received.");return $(this,ru,"f")}async _createThreadAssistantStream(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let o={...r,stream:!0},s=await e.createAndRun(o,{...n,signal:this.controller.signal});this._connected();for await(let a of s)$(this,dr,"m",$y).call(this,a);if(s.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}async _createAssistantStream(e,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.create(r,s,{...i,signal:this.controller.signal});this._connected();for await(let c of a)$(this,dr,"m",$y).call(this,c);if(a.controller.signal?.aborted)throw new Mt;return this._addRun($(this,dr,"m",Uy).call(this))}static accumulateDelta(e,r){for(let[n,i]of Object.entries(r)){if(!e.hasOwnProperty(n)){e[n]=i;continue}let o=e[n];if(o==null){e[n]=i;continue}if(n==="index"||n==="type"){e[n]=i;continue}if(typeof o=="string"&&typeof i=="string")o+=i;else if(typeof o=="number"&&typeof i=="number")o+=i;else if(vy(o)&&vy(i))o=this.accumulateDelta(o,i);else if(Array.isArray(o)&&Array.isArray(i)){if(o.every(s=>typeof s=="string"||typeof s=="number")){o.push(...i);continue}for(let s of i){if(!vy(s))throw new Error(`Expected array delta entry to be an object but got: ${s}`);let a=s.index;if(a==null)throw console.error(s),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);let c=o[a];c==null?o.push(s):o[a]=this.accumulateDelta(c,s)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${i}, accValue: ${o}`);e[n]=o}return e}_addRun(e){return e}async _threadAssistantStream(e,r,n){return await this._createThreadAssistantStream(r,e,n)}async _runAssistantStream(e,r,n,i){return await this._createAssistantStream(r,e,n,i)}async _runToolAssistantStream(e,r,n,i){return await this._createToolAssistantStream(r,e,n,i)}};tu=Ls,$y=function(e){if(!this.ended)switch(ve(this,AR,e,"f"),$(this,dr,"m",Foe).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":$(this,dr,"m",Goe).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":$(this,dr,"m",Uoe).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":$(this,dr,"m",$oe).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:}},Uy=function(){if(this.ended)throw new me("stream has ended, this shouldn't happen");if(!$(this,ru,"f"))throw Error("Final run has not been received");return $(this,ru,"f")},$oe=function(e){let[r,n]=$(this,dr,"m",joe).call(this,e,$(this,Ci,"f"));ve(this,Ci,r,"f"),$(this,wR,"f")[r.id]=r;for(let i of n){let o=r.content[i.index];o?.type=="text"&&this._emit("textCreated",o.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,r),e.data.delta.content)for(let i of e.data.delta.content){if(i.type=="text"&&i.text){let o=i.text,s=r.content[i.index];if(s&&s.type=="text")this._emit("textDelta",o,s.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(i.index!=$(this,Bp,"f")){if($(this,eu,"f"))switch($(this,eu,"f").type){case"text":this._emit("textDone",$(this,eu,"f").text,$(this,Ci,"f"));break;case"image_file":this._emit("imageFileDone",$(this,eu,"f").image_file,$(this,Ci,"f"));break}ve(this,Bp,i.index,"f")}ve(this,eu,r.content[i.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if($(this,Bp,"f")!==void 0){let i=e.data.content[$(this,Bp,"f")];if(i)switch(i.type){case"image_file":this._emit("imageFileDone",i.image_file,$(this,Ci,"f"));break;case"text":this._emit("textDone",i.text,$(this,Ci,"f"));break}}$(this,Ci,"f")&&this._emit("messageDone",e.data),ve(this,Ci,void 0,"f")}},Uoe=function(e){let r=$(this,dr,"m",Boe).call(this,e);switch(ve(this,Fy,r,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let n=e.data.delta;if(n.step_details&&n.step_details.type=="tool_calls"&&n.step_details.tool_calls&&r.step_details.type=="tool_calls")for(let o of n.step_details.tool_calls)o.index==$(this,IR,"f")?this._emit("toolCallDelta",o,r.step_details.tool_calls[o.index]):($(this,An,"f")&&this._emit("toolCallDone",$(this,An,"f")),ve(this,IR,o.index,"f"),ve(this,An,r.step_details.tool_calls[o.index],"f"),$(this,An,"f")&&this._emit("toolCallCreated",$(this,An,"f")));this._emit("runStepDelta",e.data.delta,r);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ve(this,Fy,void 0,"f"),e.data.step_details.type=="tool_calls"&&$(this,An,"f")&&(this._emit("toolCallDone",$(this,An,"f")),ve(this,An,void 0,"f")),this._emit("runStepDone",e.data,r);break;case"thread.run.step.in_progress":break}},Foe=function(e){$(this,Bj,"f").push(e),this._emit("event",e)},Boe=function(e){switch(e.event){case"thread.run.step.created":return $(this,Co,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let r=$(this,Co,"f")[e.data.id];if(!r)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){let i=tu.accumulateDelta(r,n.delta);$(this,Co,"f")[e.data.id]=i}return $(this,Co,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":$(this,Co,"f")[e.data.id]=e.data;break}if($(this,Co,"f")[e.data.id])return $(this,Co,"f")[e.data.id];throw new Error("No snapshot available")},joe=function(e,r){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!r)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let i=e.data;if(i.delta.content)for(let o of i.delta.content)if(o.index in r.content){let s=r.content[o.index];r.content[o.index]=$(this,dr,"m",zoe).call(this,o,s)}else r.content[o.index]=o,n.push(o);return[r,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(r)return[r,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},zoe=function(e,r){return tu.accumulateDelta(r,e)},Goe=function(e){switch(ve(this,RR,e.data,"f"),e.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":ve(this,ru,e.data,"f"),$(this,An,"f")&&(this._emit("toolCallDone",$(this,An,"f")),ve(this,An,void 0,"f"));break;case"thread.run.cancelling":break}};var nu=class extends q{constructor(){super(...arguments),this.steps=new Fp(this._client)}create(e,r,n){let{include:i,...o}=r;return this._client.post(z`/threads/${e}/runs`,{query:{include:i},body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}retrieve(e,r,n){let{thread_id:i}=r;return this._client.get(z`/threads/${i}/runs/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/runs/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/threads/${e}/runs`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,r,n){let{thread_id:i}=r;return this._client.post(z`/threads/${i}/runs/${e}/cancel`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r,n);return await this.poll(i.id,{thread_id:e},n)}createAndStream(e,r,n){return Ls.createAssistantStream(e,this._client.beta.threads.runs,r,n)}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:s}=await this.retrieve(e,r,{...n,headers:{...n?.headers,...i}}).withResponse();switch(o.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=s.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return o}}}stream(e,r,n){return Ls.createAssistantStream(e,this._client.beta.threads.runs,r,n)}submitToolOutputs(e,r,n){let{thread_id:i,...o}=r;return this._client.post(z`/threads/${i}/runs/${e}/submit_tool_outputs`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,r,n){let i=await this.submitToolOutputs(e,r,n);return await this.poll(i.id,r,n)}submitToolOutputsStream(e,r,n){return Ls.createToolAssistantStream(e,this._client.beta.threads.runs,r,n)}};nu.Steps=Fp;var dc=class extends q{constructor(){super(...arguments),this.runs=new nu(this._client),this.messages=new Up(this._client)}create(e={},r){return this._client.post("/threads",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/threads/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r){return this._client.delete(z`/threads/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}createAndRun(e,r){return this._client.post("/threads/runs",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,r){let n=await this.createAndRun(e,r);return await this.runs.poll(n.id,{thread_id:n.thread_id},r)}createAndRunStream(e,r){return Ls.createThreadAssistantStream(e,this._client.beta.threads,r)}};dc.Runs=nu;dc.Messages=Up;var Pi=class extends q{constructor(){super(...arguments),this.realtime=new cc(this._client),this.chatkit=new lc(this._client),this.assistants=new kp(this._client),this.threads=new dc(this._client)}};Pi.Realtime=cc;Pi.ChatKit=lc;Pi.Assistants=kp;Pi.Threads=dc;var iu=class extends q{create(e,r){return this._client.post("/completions",{body:e,...r,stream:e.stream??!1})}};var jp=class extends q{retrieve(e,r,n){let{container_id:i}=r;return this._client.get(z`/containers/${i}/files/${e}/content`,{...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var ou=class extends q{constructor(){super(...arguments),this.content=new jp(this._client)}create(e,r,n){return this._client.post(z`/containers/${e}/files`,ic({body:r,...n},this._client))}retrieve(e,r,n){let{container_id:i}=r;return this._client.get(z`/containers/${i}/files/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/containers/${e}/files`,Le,{query:r,...n})}delete(e,r,n){let{container_id:i}=r;return this._client.delete(z`/containers/${i}/files/${e}`,{...n,headers:oe([{Accept:"*/*"},n?.headers])})}};ou.Content=jp;var fc=class extends q{constructor(){super(...arguments),this.files=new ou(this._client)}create(e,r){return this._client.post("/containers",{body:e,...r})}retrieve(e,r){return this._client.get(z`/containers/${e}`,r)}list(e={},r){return this._client.getAPIList("/containers",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/containers/${e}`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}};fc.Files=ou;var zp=class extends q{create(e,r,n){let{include:i,...o}=r;return this._client.post(z`/conversations/${e}/items`,{query:{include:i},body:o,...n})}retrieve(e,r,n){let{conversation_id:i,...o}=r;return this._client.get(z`/conversations/${i}/items/${e}`,{query:o,...n})}list(e,r={},n){return this._client.getAPIList(z`/conversations/${e}/items`,Ii,{query:r,...n})}delete(e,r,n){let{conversation_id:i}=r;return this._client.delete(z`/conversations/${i}/items/${e}`,n)}};var pc=class extends q{constructor(){super(...arguments),this.items=new zp(this._client)}create(e={},r){return this._client.post("/conversations",{body:e,...r})}retrieve(e,r){return this._client.get(z`/conversations/${e}`,r)}update(e,r,n){return this._client.post(z`/conversations/${e}`,{body:r,...n})}delete(e,r){return this._client.delete(z`/conversations/${e}`,r)}};pc.Items=zp;var su=class extends q{create(e,r){let n=!!e.encoding_format,i=n?e.encoding_format:"base64";n&&Pt(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let o=this._client.post("/embeddings",{body:{...e,encoding_format:i},...r});return n?o:(Pt(this._client).debug("embeddings/decoding base64 embeddings from base64"),o._thenUnwrap(s=>(s&&s.data&&s.data.forEach(a=>{let c=a.embedding;a.embedding=Loe(c)}),s)))}};var Gp=class extends q{retrieve(e,r,n){let{eval_id:i,run_id:o}=r;return this._client.get(z`/evals/${i}/runs/${o}/output_items/${e}`,n)}list(e,r,n){let{eval_id:i,...o}=r;return this._client.getAPIList(z`/evals/${i}/runs/${e}/output_items`,Le,{query:o,...n})}};var au=class extends q{constructor(){super(...arguments),this.outputItems=new Gp(this._client)}create(e,r,n){return this._client.post(z`/evals/${e}/runs`,{body:r,...n})}retrieve(e,r,n){let{eval_id:i}=r;return this._client.get(z`/evals/${i}/runs/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/evals/${e}/runs`,Le,{query:r,...n})}delete(e,r,n){let{eval_id:i}=r;return this._client.delete(z`/evals/${i}/runs/${e}`,n)}cancel(e,r,n){let{eval_id:i}=r;return this._client.post(z`/evals/${i}/runs/${e}`,n)}};au.OutputItems=Gp;var hc=class extends q{constructor(){super(...arguments),this.runs=new au(this._client)}create(e,r){return this._client.post("/evals",{body:e,...r})}retrieve(e,r){return this._client.get(z`/evals/${e}`,r)}update(e,r,n){return this._client.post(z`/evals/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/evals",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/evals/${e}`,r)}};hc.Runs=au;var cu=class extends q{create(e,r){return this._client.post("/files",Sr({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/files/${e}`,r)}list(e={},r){return this._client.getAPIList("/files",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/files/${e}`,r)}content(e,r){return this._client.get(z`/files/${e}/content`,{...r,headers:oe([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:r=5e3,maxWait:n=1800*1e3}={}){let i=new Set(["processed","error","deleted"]),o=Date.now(),s=await this.retrieve(e);for(;!s.status||!i.has(s.status);)if(await xo(r),s=await this.retrieve(e),Date.now()-o>n)throw new rc({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return s}};var qp=class extends q{};var Vp=class extends q{run(e,r){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...r})}validate(e,r){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...r})}};var lu=class extends q{constructor(){super(...arguments),this.graders=new Vp(this._client)}};lu.Graders=Vp;var Hp=class extends q{create(e,r,n){return this._client.getAPIList(z`/fine_tuning/checkpoints/${e}/permissions`,Ro,{body:r,method:"post",...n})}retrieve(e,r={},n){return this._client.get(z`/fine_tuning/checkpoints/${e}/permissions`,{query:r,...n})}list(e,r={},n){return this._client.getAPIList(z`/fine_tuning/checkpoints/${e}/permissions`,Ii,{query:r,...n})}delete(e,r,n){let{fine_tuned_model_checkpoint:i}=r;return this._client.delete(z`/fine_tuning/checkpoints/${i}/permissions/${e}`,n)}};var uu=class extends q{constructor(){super(...arguments),this.permissions=new Hp(this._client)}};uu.Permissions=Hp;var Wp=class extends q{list(e,r={},n){return this._client.getAPIList(z`/fine_tuning/jobs/${e}/checkpoints`,Le,{query:r,...n})}};var du=class extends q{constructor(){super(...arguments),this.checkpoints=new Wp(this._client)}create(e,r){return this._client.post("/fine_tuning/jobs",{body:e,...r})}retrieve(e,r){return this._client.get(z`/fine_tuning/jobs/${e}`,r)}list(e={},r){return this._client.getAPIList("/fine_tuning/jobs",Le,{query:e,...r})}cancel(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/cancel`,r)}listEvents(e,r={},n){return this._client.getAPIList(z`/fine_tuning/jobs/${e}/events`,Le,{query:r,...n})}pause(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/pause`,r)}resume(e,r){return this._client.post(z`/fine_tuning/jobs/${e}/resume`,r)}};du.Checkpoints=Wp;var Oi=class extends q{constructor(){super(...arguments),this.methods=new qp(this._client),this.jobs=new du(this._client),this.checkpoints=new uu(this._client),this.alpha=new lu(this._client)}};Oi.Methods=qp;Oi.Jobs=du;Oi.Checkpoints=uu;Oi.Alpha=lu;var Yp=class extends q{};var mc=class extends q{constructor(){super(...arguments),this.graderModels=new Yp(this._client)}};mc.GraderModels=Yp;var fu=class extends q{createVariation(e,r){return this._client.post("/images/variations",Sr({body:e,...r},this._client))}edit(e,r){return this._client.post("/images/edits",Sr({body:e,...r,stream:e.stream??!1},this._client))}generate(e,r){return this._client.post("/images/generations",{body:e,...r,stream:e.stream??!1})}};var pu=class extends q{retrieve(e,r){return this._client.get(z`/models/${e}`,r)}list(e){return this._client.getAPIList("/models",Ro,e)}delete(e,r){return this._client.delete(z`/models/${e}`,r)}};var hu=class extends q{create(e,r){return this._client.post("/moderations",{body:e,...r})}};var Kp=class extends q{accept(e,r,n){return this._client.post(z`/realtime/calls/${e}/accept`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}hangup(e,r){return this._client.post(z`/realtime/calls/${e}/hangup`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}refer(e,r,n){return this._client.post(z`/realtime/calls/${e}/refer`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}reject(e,r={},n){return this._client.post(z`/realtime/calls/${e}/reject`,{body:r,...n,headers:oe([{Accept:"*/*"},n?.headers])})}};var Zp=class extends q{create(e,r){return this._client.post("/realtime/client_secrets",{body:e,...r})}};var $s=class extends q{constructor(){super(...arguments),this.clientSecrets=new Zp(this._client),this.calls=new Kp(this._client)}};$s.ClientSecrets=Zp;$s.Calls=Kp;function qoe(t,e){return!e||!rBe(e)?{...t,output_parsed:null,output:t.output.map(r=>r.type==="function_call"?{...r,parsed_arguments:null}:r.type==="message"?{...r,content:r.content.map(n=>({...n,parsed:null}))}:r)}:jj(t,e)}function jj(t,e){let r=t.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:oBe(e,i)};if(i.type==="message"){let o=i.content.map(s=>s.type==="output_text"?{...s,parsed:tBe(e,s.text)}:s);return{...i,content:o}}return i}),n=Object.assign({},t,{output:r});return Object.getOwnPropertyDescriptor(t,"output_text")||CR(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(let i of n.output)if(i.type==="message"){for(let o of i.content)if(o.type==="output_text"&&o.parsed!==null)return o.parsed}return null}}),n}function tBe(t,e){return t.text?.format?.type!=="json_schema"?null:"$parseRaw"in t.text?.format?(t.text?.format).$parseRaw(e):JSON.parse(e)}function rBe(t){return!!Cy(t.text?.format)}function nBe(t){return t?.$brand==="auto-parseable-tool"}function iBe(t,e){return t.find(r=>r.type==="function"&&r.name===e)}function oBe(t,e){let r=iBe(t.tools??[],e.name);return{...e,...e,parsed_arguments:nBe(r)?r.$parseRaw(e.arguments):r?.strict?JSON.parse(e.arguments):null}}function CR(t){let e=[];for(let r of t.output)if(r.type==="message")for(let n of r.content)n.type==="output_text"&&e.push(n.text);t.output_text=e.join("")}var Jp,PR,gc,OR,Voe,Hoe,Woe,Yoe,NR=class t extends oc{constructor(e){super(),Jp.add(this),PR.set(this,void 0),gc.set(this,void 0),OR.set(this,void 0),ve(this,PR,e,"f")}static createResponse(e,r,n){let i=new t(r);return i._run(()=>i._createOrRetrieveResponse(e,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createOrRetrieveResponse(e,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),$(this,Jp,"m",Voe).call(this);let o,s=null;"response_id"in r?(o=await e.responses.retrieve(r.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),s=r.starting_after??null):o=await e.responses.create({...r,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let a of o)$(this,Jp,"m",Hoe).call(this,a,s);if(o.controller.signal?.aborted)throw new Mt;return $(this,Jp,"m",Woe).call(this)}[(PR=new WeakMap,gc=new WeakMap,OR=new WeakMap,Jp=new WeakSet,Voe=function(){this.ended||ve(this,gc,void 0,"f")},Hoe=function(r,n){if(this.ended)return;let i=(s,a)=>{(n==null||a.sequence_number>n)&&this._emit(s,a)},o=$(this,Jp,"m",Yoe).call(this,r);switch(i("event",r),r.type){case"response.output_text.delta":{let s=o.output[r.output_index];if(!s)throw new me(`missing output at index ${r.output_index}`);if(s.type==="message"){let a=s.content[r.content_index];if(!a)throw new me(`missing content at index ${r.content_index}`);if(a.type!=="output_text")throw new me(`expected content to be 'output_text', got ${a.type}`);i("response.output_text.delta",{...r,snapshot:a.text})}break}case"response.function_call_arguments.delta":{let s=o.output[r.output_index];if(!s)throw new me(`missing output at index ${r.output_index}`);s.type==="function_call"&&i("response.function_call_arguments.delta",{...r,snapshot:s.arguments});break}default:i(r.type,r);break}},Woe=function(){if(this.ended)throw new me("stream has ended, this shouldn't happen");let r=$(this,gc,"f");if(!r)throw new me("request ended without sending any events");ve(this,gc,void 0,"f");let n=sBe(r,$(this,PR,"f"));return ve(this,OR,n,"f"),n},Yoe=function(r){let n=$(this,gc,"f");if(!n){if(r.type!=="response.created")throw new me(`When snapshot hasn't been set yet, expected 'response.created' event, got ${r.type}`);return n=ve(this,gc,r.response,"f"),n}switch(r.type){case"response.output_item.added":{n.output.push(r.item);break}case"response.content_part.added":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);let o=i.type,s=r.part;o==="message"&&s.type!=="reasoning_text"?i.content.push(s):o==="reasoning"&&s.type==="reasoning_text"&&(i.content||(i.content=[]),i.content.push(s));break}case"response.output_text.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);if(i.type==="message"){let o=i.content[r.content_index];if(!o)throw new me(`missing content at index ${r.content_index}`);if(o.type!=="output_text")throw new me(`expected content to be 'output_text', got ${o.type}`);o.text+=r.delta}break}case"response.function_call_arguments.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);i.type==="function_call"&&(i.arguments+=r.delta);break}case"response.reasoning_text.delta":{let i=n.output[r.output_index];if(!i)throw new me(`missing output at index ${r.output_index}`);if(i.type==="reasoning"){let o=i.content?.[r.content_index];if(!o)throw new me(`missing content at index ${r.content_index}`);if(o.type!=="reasoning_text")throw new me(`expected content to be 'reasoning_text', got ${o.type}`);o.text+=r.delta}break}case"response.completed":{ve(this,gc,r.response,"f");break}}return n},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,s)=>r.push({resolve:o,reject:s})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=$(this,OR,"f");if(!e)throw new me("stream ended without producing a ChatCompletion");return e}};function sBe(t,e){return qoe(t,e)}var Xp=class extends q{list(e,r={},n){return this._client.getAPIList(z`/responses/${e}/input_items`,Le,{query:r,...n})}};var Qp=class extends q{count(e={},r){return this._client.post("/responses/input_tokens",{body:e,...r})}};var Us=class extends q{constructor(){super(...arguments),this.inputItems=new Xp(this._client),this.inputTokens=new Qp(this._client)}create(e,r){return this._client.post("/responses",{body:e,...r,stream:e.stream??!1})._thenUnwrap(n=>("object"in n&&n.object==="response"&&CR(n),n))}retrieve(e,r={},n){return this._client.get(z`/responses/${e}`,{query:r,...n,stream:r?.stream??!1})._thenUnwrap(i=>("object"in i&&i.object==="response"&&CR(i),i))}delete(e,r){return this._client.delete(z`/responses/${e}`,{...r,headers:oe([{Accept:"*/*"},r?.headers])})}parse(e,r){return this._client.responses.create(e,r)._thenUnwrap(n=>jj(n,e))}stream(e,r){return NR.createResponse(this._client,e,r)}cancel(e,r){return this._client.post(z`/responses/${e}/cancel`,r)}compact(e,r){return this._client.post("/responses/compact",{body:e,...r})}};Us.InputItems=Xp;Us.InputTokens=Qp;var eh=class extends q{retrieve(e,r){return this._client.get(z`/skills/${e}/content`,{...r,headers:oe([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}};var th=class extends q{retrieve(e,r,n){let{skill_id:i}=r;return this._client.get(z`/skills/${i}/versions/${e}/content`,{...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var mu=class extends q{constructor(){super(...arguments),this.content=new th(this._client)}create(e,r={},n){return this._client.post(z`/skills/${e}/versions`,ic({body:r,...n},this._client))}retrieve(e,r,n){let{skill_id:i}=r;return this._client.get(z`/skills/${i}/versions/${e}`,n)}list(e,r={},n){return this._client.getAPIList(z`/skills/${e}/versions`,Le,{query:r,...n})}delete(e,r,n){let{skill_id:i}=r;return this._client.delete(z`/skills/${i}/versions/${e}`,n)}};mu.Content=th;var Fs=class extends q{constructor(){super(...arguments),this.content=new eh(this._client),this.versions=new mu(this._client)}create(e={},r){return this._client.post("/skills",ic({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/skills/${e}`,r)}update(e,r,n){return this._client.post(z`/skills/${e}`,{body:r,...n})}list(e={},r){return this._client.getAPIList("/skills",Le,{query:e,...r})}delete(e,r){return this._client.delete(z`/skills/${e}`,r)}};Fs.Content=eh;Fs.Versions=mu;var rh=class extends q{create(e,r,n){return this._client.post(z`/uploads/${e}/parts`,Sr({body:r,...n},this._client))}};var _c=class extends q{constructor(){super(...arguments),this.parts=new rh(this._client)}create(e,r){return this._client.post("/uploads",{body:e,...r})}cancel(e,r){return this._client.post(z`/uploads/${e}/cancel`,r)}complete(e,r,n){return this._client.post(z`/uploads/${e}/complete`,{body:r,...n})}};_c.Parts=rh;var Koe=async t=>{let e=await Promise.allSettled(t),r=e.filter(i=>i.status==="rejected");if(r.length){for(let i of r)console.error(i.reason);throw new Error(`${r.length} promise(s) failed - see the above errors`)}let n=[];for(let i of e)i.status==="fulfilled"&&n.push(i.value);return n};var nh=class extends q{create(e,r,n){return this._client.post(z`/vector_stores/${e}/file_batches`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{vector_store_id:i}=r;return this._client.get(z`/vector_stores/${i}/file_batches/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,r,n){let{vector_store_id:i}=r;return this._client.post(z`/vector_stores/${i}/file_batches/${e}/cancel`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r);return await this.poll(e,i.id,n)}listFiles(e,r,n){let{vector_store_id:i,...o}=r;return this._client.getAPIList(z`/vector_stores/${i}/file_batches/${e}/files`,Le,{query:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:s}=await this.retrieve(r,{vector_store_id:e},{...n,headers:i}).withResponse();switch(o.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=s.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"failed":case"cancelled":case"completed":return o}}}async uploadAndPoll(e,{files:r,fileIds:n=[]},i){if(r==null||r.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let o=i?.maxConcurrency??5,s=Math.min(o,r.length),a=this._client,c=r.values(),l=[...n];async function u(f){for(let p of f){let h=await a.files.create({file:p,purpose:"assistants"},i);l.push(h.id)}}let d=Array(s).fill(c).map(u);return await Koe(d),await this.createAndPoll(e,{file_ids:l})}};var ih=class extends q{create(e,r,n){return this._client.post(z`/vector_stores/${e}/files`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,r,n){let{vector_store_id:i}=r;return this._client.get(z`/vector_stores/${i}/files/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,r,n){let{vector_store_id:i,...o}=r;return this._client.post(z`/vector_stores/${i}/files/${e}`,{body:o,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,r={},n){return this._client.getAPIList(z`/vector_stores/${e}/files`,Le,{query:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,r,n){let{vector_store_id:i}=r;return this._client.delete(z`/vector_stores/${i}/files/${e}`,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,r,n){let i=await this.create(e,r,n);return await this.poll(e,i.id,n)}async poll(e,r,n){let i=oe([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let o=await this.retrieve(r,{vector_store_id:e},{...n,headers:i}).withResponse(),s=o.data;switch(s.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let c=o.response.headers.get("openai-poll-after-ms");if(c){let l=parseInt(c);isNaN(l)||(a=l)}}await xo(a);break;case"failed":case"completed":return s}}}async upload(e,r,n){let i=await this._client.files.create({file:r,purpose:"assistants"},n);return this.create(e,{file_id:i.id},n)}async uploadAndPoll(e,r,n){let i=await this.upload(e,r,n);return await this.poll(e,i.id,n)}content(e,r,n){let{vector_store_id:i}=r;return this._client.getAPIList(z`/vector_stores/${i}/files/${e}/content`,Ro,{...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Bs=class extends q{constructor(){super(...arguments),this.files=new ih(this._client),this.fileBatches=new nh(this._client)}create(e,r){return this._client.post("/vector_stores",{body:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,r){return this._client.get(z`/vector_stores/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,r,n){return this._client.post(z`/vector_stores/${e}`,{body:r,...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},r){return this._client.getAPIList("/vector_stores",Le,{query:e,...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,r){return this._client.delete(z`/vector_stores/${e}`,{...r,headers:oe([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}search(e,r,n){return this._client.getAPIList(z`/vector_stores/${e}/search`,Ro,{body:r,method:"post",...n,headers:oe([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};Bs.Files=ih;Bs.FileBatches=nh;var gu=class extends q{create(e,r){return this._client.post("/videos",Sr({body:e,...r},this._client))}retrieve(e,r){return this._client.get(z`/videos/${e}`,r)}list(e={},r){return this._client.getAPIList("/videos",Ii,{query:e,...r})}delete(e,r){return this._client.delete(z`/videos/${e}`,r)}createCharacter(e,r){return this._client.post("/videos/characters",Sr({body:e,...r},this._client))}downloadContent(e,r={},n){return this._client.get(z`/videos/${e}/content`,{query:r,...n,headers:oe([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}edit(e,r){return this._client.post("/videos/edits",Sr({body:e,...r},this._client))}extend(e,r){return this._client.post("/videos/extensions",Sr({body:e,...r},this._client))}getCharacter(e,r){return this._client.get(z`/videos/characters/${e}`,r)}remix(e,r,n){return this._client.post(z`/videos/${e}/remix`,ic({body:r,...n},this._client))}};var oh,Zoe,kR,_u=class extends q{constructor(){super(...arguments),oh.add(this)}async unwrap(e,r,n=this._client.webhookSecret,i=300){return await this.verifySignature(e,r,n,i),JSON.parse(e)}async verifySignature(e,r,n=this._client.webhookSecret,i=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");$(this,oh,"m",Zoe).call(this,n);let o=oe([r]).values,s=$(this,oh,"m",kR).call(this,o,"webhook-signature"),a=$(this,oh,"m",kR).call(this,o,"webhook-timestamp"),c=$(this,oh,"m",kR).call(this,o,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new To("Invalid webhook timestamp format");let u=Math.floor(Date.now()/1e3);if(u-l>i)throw new To("Webhook timestamp is too old");if(l>u+i)throw new To("Webhook timestamp is too new");let d=s.split(" ").map(m=>m.startsWith("v1,")?m.substring(3):m),f=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),p=c?`${c}.${a}.${e}`:`${a}.${e}`,h=await crypto.subtle.importKey("raw",f,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let m of d)try{let y=Buffer.from(m,"base64");if(await crypto.subtle.verify("HMAC",h,y,new TextEncoder().encode(p)))return}catch{continue}throw new To("The given webhook signature does not match the expected signature")}};oh=new WeakSet,Zoe=function(e){if(typeof e!="string"||e.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},kR=function(e,r){if(!e)throw new Error("Headers are required");let n=e.get(r);if(n==null)throw new Error(`Missing required header: ${r}`);return n};var Gj,qj,MR,Joe,zj="workload-identity-auth",Ne=class{constructor({baseURL:e=uc("OPENAI_BASE_URL"),apiKey:r=uc("OPENAI_API_KEY"),organization:n=uc("OPENAI_ORG_ID")??null,project:i=uc("OPENAI_PROJECT_ID")??null,webhookSecret:o=uc("OPENAI_WEBHOOK_SECRET")??null,workloadIdentity:s,...a}={}){if(Gj.add(this),MR.set(this,void 0),this.completions=new iu(this),this.chat=new ac(this),this.embeddings=new su(this),this.files=new cu(this),this.images=new fu(this),this.audio=new Io(this),this.moderations=new hu(this),this.models=new pu(this),this.fineTuning=new Oi(this),this.graders=new mc(this),this.vectorStores=new Bs(this),this.webhooks=new _u(this),this.beta=new Pi(this),this.batches=new Ql(this),this.uploads=new _c(this),this.responses=new Us(this),this.realtime=new $s(this),this.conversations=new pc(this),this.evals=new hc(this),this.containers=new fc(this),this.skills=new Fs(this),this.videos=new gu(this),s){if(r&&r!==zj)throw new me("The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.");r=zj}else if(r===void 0)throw new me("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.");let c={apiKey:r,organization:n,project:i,webhookSecret:o,workloadIdentity:s,...a,baseURL:e||"https://api.openai.com/v1"};if(!c.dangerouslyAllowBrowser&&roe())throw new me(`It looks like you're running in a browser-like environment.
|
|
289
289
|
|
|
290
290
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
291
291
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -294,11 +294,11 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
294
294
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
295
295
|
|
|
296
296
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
297
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??q2.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=y2(c.logLevel,"ClientOptions.logLevel",this)??y2(uc("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??sR(),ve(this,MR,ooe,"f"),this._options=c,s&&(this._workloadIdentityAuth=new pR(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return oe([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return hoe(e)}getUserAgent(){return`${this.constructor.name}/JS ${nc}`}defaultIdempotencyKey(){return`stainless-node-retry-${i2()}`}makeStatusError(e,r,n,i){return xt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof me?n:new me(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new me(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!$(this,G2,"m",Joe).call(this)&&n||this.baseURL,o=Kie(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!a2(s)||!a2(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Kl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Pt(this).debug(`[${l}] sending request`,Ns({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new Mt;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(Sy),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Mt;let T=yy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Pt(this).info(`[${l}] connection ${T?"timed out":"failed"} - ${S}`),Pt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (${S})`,Ns({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Pt(this).info(`[${l}] connection ${T?"timed out":"failed"} - error; no more retries left`),Pt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (error; no more retries left)`,Ns({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Wl||p instanceof Ey?p:T?new rc:new tc({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,T])=>", "+S+": "+JSON.stringify(T)).join(""),y=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await u2(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let U=`retrying, ${r} attempts remaining`;return await u2(p.body),Pt(this).info(`${y} - ${U}`),Pt(this).debug(`[${l}] response error (${U})`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let T=S?"error; no more retries left":"error; not retryable";Pt(this).info(`${y} - ${T}`);let x=await p.text().catch(U=>Sy(U).message),v=Xie(x),N=v?void 0:x;throw Pt(this).debug(`[${l}] response error (${T})`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:N,durationMs:Date.now()-d})),this.makeStatusError(p.status,v,N,p.headers)}return Pt(this).info(y),Pt(this).debug(`[${l}] response start`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Ay(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${z2}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await xo(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&Jie("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=oe([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...noe(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=oe([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:aR(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...$(this,MR,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};q2=Ne,MR=new WeakMap,G2=new WeakSet,Joe=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=q2;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=me;Ne.APIError=xt;Ne.APIConnectionError=tc;Ne.APIConnectionTimeoutError=rc;Ne.APIUserAbortError=Mt;Ne.NotFoundError=_p;Ne.ConflictError=yp;Ne.RateLimitError=Ep;Ne.BadRequestError=hp;Ne.AuthenticationError=mp;Ne.InternalServerError=vp;Ne.PermissionDeniedError=gp;Ne.UnprocessableEntityError=Sp;Ne.InvalidWebhookSignatureError=To;Ne.toFile=mR;Ne.Completions=iu;Ne.Chat=ac;Ne.Embeddings=su;Ne.Files=cu;Ne.Images=fu;Ne.Audio=Io;Ne.Moderations=hu;Ne.Models=pu;Ne.FineTuning=Oi;Ne.Graders=mc;Ne.VectorStores=Bs;Ne.Webhooks=_u;Ne.Beta=Pi;Ne.Batches=Ql;Ne.Uploads=_c;Ne.Responses=Us;Ne.Realtime=$s;Ne.Conversations=pc;Ne.Evals=hc;Ne.Containers=fc;Ne.Skills=Fs;Ne.Videos=gu;var Ur=ye("runner_codex"),V2="Codex CLI",sh="gpt-5.6-sol",_Be=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(Ur.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(Ur.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(Ur.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function Xoe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!sh&&await t.isModelAvailableForProvider("openai",sh)?(n=sh,Ur.log(`Using default model: ${sh}`)):sh&&Ur.log(`Default model ${sh} is not available, proceeding without model specification`);return n}function Qoe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");yc.env.OPENAI_API_KEY=e,yc.env.OPENAI_BASE_URL=r}else if(!yc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function H2({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:o,priorAgentSessionId:s,cwd:a=yc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Qoe({aiGateway:i});let p=await Xoe({config:t,aiGateway:i,model:f}),h=[],m=[],y=[],S={},T=new Set,x=0,v=0,N,R,U,C,D,j=`${yc.env.NVM_BIN}/node`,_=ah.join(DR.homedir(),".codex"),ae=ah.join(_,"config.toml"),I=ah.join(_,"auth.json");try{await By.mkdir(_,{recursive:!0});let ee={OPENAI_API_KEY:yc.env.OPENAI_API_KEY};await By.writeFile(I,JSON.stringify(ee,null,2),"utf-8"),Ur.log("Created Codex auth.json file");let ie=yc.env.OPENAI_BASE_URL,Re=['forced_login_method = "api"'],te=We().questionsEnabled;ie&&Re.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${ie}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),te&&Re.push(...Dte()),await By.writeFile(ae,`${Re.join(`
|
|
297
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??qj.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=yj(c.logLevel,"ClientOptions.logLevel",this)??yj(uc("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??sR(),ve(this,MR,ooe,"f"),this._options=c,s&&(this._workloadIdentityAuth=new pR(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return oe([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return hoe(e)}getUserAgent(){return`${this.constructor.name}/JS ${nc}`}defaultIdempotencyKey(){return`stainless-node-retry-${ij()}`}makeStatusError(e,r,n,i){return xt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof me?n:new me(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new me(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!$(this,Gj,"m",Joe).call(this)&&n||this.baseURL,o=Kie(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!aj(s)||!aj(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Kl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Pt(this).debug(`[${l}] sending request`,Ns({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new Mt;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(Sy),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Mt;let T=yy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Pt(this).info(`[${l}] connection ${T?"timed out":"failed"} - ${S}`),Pt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (${S})`,Ns({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Pt(this).info(`[${l}] connection ${T?"timed out":"failed"} - error; no more retries left`),Pt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (error; no more retries left)`,Ns({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Wl||p instanceof Ey?p:T?new rc:new tc({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,T])=>", "+S+": "+JSON.stringify(T)).join(""),y=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await uj(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let U=`retrying, ${r} attempts remaining`;return await uj(p.body),Pt(this).info(`${y} - ${U}`),Pt(this).debug(`[${l}] response error (${U})`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let T=S?"error; no more retries left":"error; not retryable";Pt(this).info(`${y} - ${T}`);let x=await p.text().catch(U=>Sy(U).message),v=Xie(x),N=v?void 0:x;throw Pt(this).debug(`[${l}] response error (${T})`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:N,durationMs:Date.now()-d})),this.makeStatusError(p.status,v,N,p.headers)}return Pt(this).info(y),Pt(this).debug(`[${l}] response start`,Ns({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Ay(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${zj}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await xo(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&Jie("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=oe([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...noe(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=oe([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:aR(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...$(this,MR,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};qj=Ne,MR=new WeakMap,Gj=new WeakSet,Joe=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=qj;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=me;Ne.APIError=xt;Ne.APIConnectionError=tc;Ne.APIConnectionTimeoutError=rc;Ne.APIUserAbortError=Mt;Ne.NotFoundError=_p;Ne.ConflictError=yp;Ne.RateLimitError=Ep;Ne.BadRequestError=hp;Ne.AuthenticationError=mp;Ne.InternalServerError=vp;Ne.PermissionDeniedError=gp;Ne.UnprocessableEntityError=Sp;Ne.InvalidWebhookSignatureError=To;Ne.toFile=mR;Ne.Completions=iu;Ne.Chat=ac;Ne.Embeddings=su;Ne.Files=cu;Ne.Images=fu;Ne.Audio=Io;Ne.Moderations=hu;Ne.Models=pu;Ne.FineTuning=Oi;Ne.Graders=mc;Ne.VectorStores=Bs;Ne.Webhooks=_u;Ne.Beta=Pi;Ne.Batches=Ql;Ne.Uploads=_c;Ne.Responses=Us;Ne.Realtime=$s;Ne.Conversations=pc;Ne.Evals=hc;Ne.Containers=fc;Ne.Skills=Fs;Ne.Videos=gu;var Ur=ye("runner_codex"),Vj="Codex CLI",sh="gpt-5.6-sol",_Be=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(Ur.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(Ur.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(Ur.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function Xoe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!sh&&await t.isModelAvailableForProvider("openai",sh)?(n=sh,Ur.log(`Using default model: ${sh}`)):sh&&Ur.log(`Default model ${sh} is not available, proceeding without model specification`);return n}function Qoe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");yc.env.OPENAI_API_KEY=e,yc.env.OPENAI_BASE_URL=r}else if(!yc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function Hj({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:o,priorAgentSessionId:s,cwd:a=yc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Qoe({aiGateway:i});let p=await Xoe({config:t,aiGateway:i,model:f}),h=[],m=[],y=[],S={},T=new Set,x=0,v=0,N,R,U,C,D,j=`${yc.env.NVM_BIN}/node`,_=ah.join(DR.homedir(),".codex"),ae=ah.join(_,"config.toml"),I=ah.join(_,"auth.json");try{await By.mkdir(_,{recursive:!0});let ee={OPENAI_API_KEY:yc.env.OPENAI_API_KEY};await By.writeFile(I,JSON.stringify(ee,null,2),"utf-8"),Ur.log("Created Codex auth.json file");let ie=yc.env.OPENAI_BASE_URL,Re=['forced_login_method = "api"'],te=We().questionsEnabled;ie&&Re.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${ie}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),te&&Re.push(...Dte()),await By.writeFile(ae,`${Re.join(`
|
|
298
298
|
`)}
|
|
299
|
-
`,"utf-8"),Ur.log("Wrote Codex config.toml")}catch(ee){let ie=ee instanceof Error?ee.message:String(ee);throw Ur.warn("Failed to setup Codex config and credentials",{error:ie}),new Error(`Codex setup failed: ${ie}`)}let g=p==="gpt-5.6-sol",E=u??(g?"low":"high"),w=!!(o&&s),W="mode"in t&&t.mode==="ask",G=[mo(a,"codex"),"exec",...W?["--sandbox","read-only"]:[],...w?["resume",s]:[],...W?[]:["--yolo"],"--json",...u?["-c",`model_reasoning_effort="${u}"`]:g?["-c",'model_reasoning_effort="low"']:[],...p?["--model",p]:[]].filter(Boolean);Ur.log(`Running ${j} ${G.join(" ")}`);let ce=e.utils.run(j,G,{all:!0,cwd:a,env:{...yc.env},stdin:"pipe",idleTimeout:ds,cancelSignal:c});ce.stdin?.end(d);let Te=Na(()=>{r?.({steps:h,duration:v}),n?.({steps:m,duration:v}),m=[]},250),we=(ee,ie)=>{let Re={...ee,id:x};x+=1,y.push(Re),h.push(Re),m.push(Re),ie||Te.flush(),Te(),ie&&Te.flush()};we({title:`Using ${
|
|
299
|
+
`,"utf-8"),Ur.log("Wrote Codex config.toml")}catch(ee){let ie=ee instanceof Error?ee.message:String(ee);throw Ur.warn("Failed to setup Codex config and credentials",{error:ie}),new Error(`Codex setup failed: ${ie}`)}let g=p==="gpt-5.6-sol",E=u??(g?"low":"high"),w=!!(o&&s),W="mode"in t&&t.mode==="ask",G=[mo(a,"codex"),"exec",...W?["--sandbox","read-only"]:[],...w?["resume",s]:[],...W?[]:["--yolo"],"--json",...u?["-c",`model_reasoning_effort="${u}"`]:g?["-c",'model_reasoning_effort="low"']:[],...p?["--model",p]:[]].filter(Boolean);Ur.log(`Running ${j} ${G.join(" ")}`);let ce=e.utils.run(j,G,{all:!0,cwd:a,env:{...yc.env},stdin:"pipe",idleTimeout:ds,cancelSignal:c});ce.stdin?.end(d);let Te=Na(()=>{r?.({steps:h,duration:v}),n?.({steps:m,duration:v}),m=[]},250),we=(ee,ie)=>{let Re={...ee,id:x};x+=1,y.push(Re),h.push(Re),m.push(Re),ie||Te.flush(),Te(),ie&&Te.flush()};we({title:`Using ${Vj} with ${p||"default"}`,category:Y.Environment},!0);let V=gBe.createInterface({input:ce.all});V.on("error",ee=>{Ur.error("Readline interface error",{error:ee.message,stack:ee.stack})}),V.on("line",ee=>{let ie;try{ie=JSON.parse(ee)}catch{Ur.log("Could not parse line",ee);return}if(ie?.duration_ms&&(v=ie.duration_ms),ie?.type==="thread.started"&&typeof ie?.thread_id=="string"&&(U=ie.thread_id,l?.(U)),ie?.type==="item.started"&&ie?.item?.type==="command_execution")S[ie.item.id]=ie.item;else if(ie?.type==="item.completed"&&ie?.item?.type==="command_execution"){let Re=ie.item,te=EBe(Re);te&&we(te,!0);let Ae=Re.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(Ae&&!T.has(Ae)){T.add(Ae);let K=go(Ae);Ss(Ur,K),we({title:`Use ${K}`,category:Y.Skill,type:Ae},!0)}}else if(ie?.type==="item.completed"&&ie?.item?.type==="reasoning"){let Re={title:"Reasoning",message:ie.item.text,category:Y.Reasoning};we(Re,!0)}else if(ie?.type==="item.completed"&&ie?.item?.type==="agent_message")N=ie.item.text;else if(ie?.type==="item.started"&&ie?.item?.type==="mcp_tool_call"){let Re=ie.item;if(Re.server===Nf&&Re.tool==="ask"&&!D){let te=up.safeParse(Re.arguments);te.success?(D={questions:te.data.questions,toolUseId:Re.id},ce.kill()):(Ur.warn("Ignoring malformed ask tool input",{toolUseId:Re.id}),fe.inc("inference.malformed_ask",1))}}else if(ie?.type==="turn.completed"&&ie.usage)C={input_tokens:ie.usage.input_tokens,output_tokens:ie.usage.output_tokens},so(C);else if(ie?.type==="turn.failed"&&ie?.error?.message)R=ie.error.message;else if(ie?.type==="local_shell_call"){let Re=ie;S[Re.call_id]=Re}else if(ie?.type==="local_shell_call_output"){let Re=ie,te=S[Re.call_id],Ae=vBe(te,Re);Ae&&we(Ae,!0);let M=(te?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(M&&!T.has(M)){T.add(M);let k=go(M);Ss(Ur,k),we({title:`Use ${k}`,category:Y.Skill,type:M},!0)}}else ie?.type==="message"&&ie.role==="assistant"?N=ie.content?.map(Re=>Re.text).join(`
|
|
300
300
|
`):ie?.type==="message"&&ie.role==="system"&&(R=ie.content?.map(Re=>Re.text).join(`
|
|
301
|
-
`))});let De=!1;if(await ce.catch(ee=>{De=Of(ee,c);let ie=_Be({catchError:ee,runCmd:ce,error:R,result:N,runnerName:"Codex"});R=ie.error,N=ie.result}),V.close(),Te.flush(),D)return{steps:y,duration:v,agentSessionId:U,resolvedModel:p,effort:E,usage:C,pendingInteraction:D};let be=De;return be&&(R=void 0),{steps:y,duration:v,result:await Ja({initialResult:N,agentName:
|
|
301
|
+
`))});let De=!1;if(await ce.catch(ee=>{De=Of(ee,c);let ie=_Be({catchError:ee,runCmd:ce,error:R,result:N,runnerName:"Codex"});R=ie.error,N=ie.result}),V.close(),Te.flush(),D)return{steps:y,duration:v,agentSessionId:U,resolvedModel:p,effort:E,usage:C,pendingInteraction:D};let be=De;return be&&(R=void 0),{steps:y,duration:v,result:await Ja({initialResult:N,agentName:Vj,hasError:!!R}),error:Xa({error:R,agentName:Vj}),isRetryableError:Qa(R),isProviderUnavailableError:ec(R),resolvedModel:p,effort:E,agentSessionId:U,usage:C,...be?{aborted:!0}:{}}}var ese=async()=>{let t=ah.join(DR.homedir(),".codex");await By.rm(t,{recursive:!0,force:!0});let e=ah.join(DR.homedir(),".agents","skills");await By.rm(e,{recursive:!0,force:!0})},tse={baseDir:ah.join(DR.homedir(),".codex"),include:["sessions"]},yBe=new Set(["bash","-lc"]),SBe=/^sed\s+-n\s+(?:'[^']*'|"[^"]*"|\S+)\s+(\S+)\s*$/,rse=t=>{if(Ps(t))return{title:"Generating the site",category:Y.SiteGeneration};let e=t.match(SBe);return e?{title:`Reading \`${e[1]}\``,category:Y.FileRead}:{title:`Running \`${t}\``,category:Y.RunCommand}},EBe=t=>{if(!t||t.type!=="command_execution")return null;let e=t.command;e=e.replace(/^(\/usr\/bin\/)?bash -lc ['"]/,"").replace(/['"]$/,"");let{command:r,heredocContent:n}=dL(e),{title:i,category:o}=rse(r),s=t.aggregated_output?.trim();return n?s=`\`\`\`
|
|
302
302
|
${n}
|
|
303
303
|
\`\`\`${s?`
|
|
304
304
|
|
|
@@ -318,23 +318,23 @@ ${s.trim()}
|
|
|
318
318
|
${s.trim()}
|
|
319
319
|
\`\`\``),{title:n,message:s,category:i}},nse=async({aiGateway:t,config:e,model:r,prompt:n,systemPrompt:i="",outputFormat:o,maxTokens:s=4096})=>{Qoe({aiGateway:t});let a=await Xoe({config:e,aiGateway:t,model:r});if(!a)throw new Error("Model is required");let l=await new Ne().responses.parse({model:a,max_output_tokens:s,input:[...i?[{role:"system",content:i}]:[],{role:"user",content:n}],...o&&{text:{format:{...o,name:"output"}}}});return{response:l,text:l.output_text}};import yu from"fs/promises";import Gy from"os";import Sc from"path";import lh from"process";import ABe from"readline";import jy from"fs/promises";import bBe from"os";import LR from"path";var ise=ye("gemini_session"),TBe=t=>t instanceof Error?t.message:String(t),xBe=t=>{let e=!1;if(Array.isArray(t?.toolCalls))for(let n of t.toolCalls)n&&typeof n=="object"&&"id"in n&&(delete n.id,e=!0);let r=typeof t?.content=="object"?t.content?.parts:void 0;if(Array.isArray(r))for(let n of r)n?.functionCall&&typeof n.functionCall=="object"&&"id"in n.functionCall&&(delete n.functionCall.id,e=!0);return e},wBe=async t=>{let r=(await jy.readFile(t,"utf8")).split(`
|
|
320
320
|
`),n=!1,i=r.map(o=>{if(!o.trim())return o;let s;try{s=JSON.parse(o)}catch{return o}return xBe(s)?(n=!0,JSON.stringify(s)):o});return n&&await jy.writeFile(t,i.join(`
|
|
321
|
-
`),"utf8"),n},
|
|
322
|
-
`,1)[0];if(JSON.parse(u).sessionId===t)return l}catch{continue}}}},zy=async t=>{try{let e=await
|
|
321
|
+
`),"utf8"),n},Wj=async(t,e=LR.join(bBe.homedir(),".gemini"))=>{let r=LR.join(e,"tmp"),n=t.slice(0,8),i;try{i=await jy.readdir(r)}catch{return}for(let o of i){let s=LR.join(r,o,"chats"),a;try{a=await jy.readdir(s)}catch{continue}for(let c of a){if(!c.endsWith(".jsonl")||!c.includes(n))continue;let l=LR.join(s,c);try{let u=(await jy.readFile(l,"utf8")).split(`
|
|
322
|
+
`,1)[0];if(JSON.parse(u).sessionId===t)return l}catch{continue}}}},zy=async t=>{try{let e=await Wj(t);return e?(await wBe(e),!0):(ise.log(`No gemini session file for ${t}; not resumable, using fresh session`),!1)}catch(e){return ise.warn(`Could not sanitize gemini session ${t} for resume; using fresh session`,{error:TBe(e)}),!1}};var Yj={list_directory:{name:"List directory",category:Y.Explore},read_file:{name:"Read file",category:Y.FileRead},write_file:{name:"Edit file",category:Y.FileWrite},glob:{name:"Find files",category:Y.Explore},search_file_content:{name:"Search files",category:Y.Explore},replace:{name:"Edit file",category:Y.FileWrite},run_shell_command:{name:"Run command",category:Y.RunCommand},web_fetch:{name:"Fetch web",category:Y.Web},web_search:{name:"Search web",category:Y.Web},google_web_search:{name:"Search web",category:Y.Web},update_topic:{name:"Update topic",category:Y.Plan},read_many_files:{name:"Read files",category:Y.FileRead},save_memory:{name:"Memorize",category:Y.Memorize},activate_skill:{name:"Use Skill",category:Y.Skill},grep_search:{name:"Search files",category:Y.Explore}};var Qr=ye("runner_gemini"),Kj="Gemini CLI",ch="gemini-3.5-flash",RBe=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(Qr.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(Qr.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(Qr.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0})),IBe=async()=>{let t=Sc.join(Gy.homedir(),".gemini"),e=Sc.join(t,"settings.json");try{await yu.mkdir(t,{recursive:!0});let r={};try{let n=await yu.readFile(e,"utf-8");r=JSON.parse(n)}catch{Qr.log("Creating new Gemini CLI settings file")}r.general||(r.general={}),r.general.previewFeatures||(r.general.previewFeatures=!0),r.model||(r.model={}),r.model.compressionThreshold!==.3&&(r.model.compressionThreshold=.3),r.skills||(r.skills={}),r.skills.enabled=!0,r.context||(r.context={}),r.context.fileName=["GEMINI.md","AGENTS.md"],We().questionsEnabled&&(r.mcpServers={...r.mcpServers,...ZL({trust:!0})}),await yu.writeFile(e,JSON.stringify(r,null,2),"utf-8"),Qr.log("Configured Gemini CLI settings (preview features and compression threshold)")}catch(r){Qr.error("Failed to ensure Gemini CLI settings",{error:r.message}),fe.inc("context.degraded",1,{component:"agent_config"})}},CBe=t=>{t?.category===Y.Skill&&t.type&&Ss(Qr,go(t.type))},PBe=({aiGateway:t})=>{if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");lh.env.GEMINI_API_KEY=e,lh.env.GOOGLE_GEMINI_BASE_URL=r}else if(!lh.env.GEMINI_API_KEY)throw new Error("GEMINI_API_KEY is not provided")},OBe=async({aiGateway:t,config:e,model:r})=>{let n=r;if(t){let i=e.modelVersionOverrides?.gemini?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("gemini",i))throw new Error(`Model override '${i}' is not available for gemini provider`);n=i}if(!n)!!ch&&await t.isModelAvailableForProvider("gemini",ch)?(n=ch,Qr.log(`Using default model: ${ch}`)):ch&&Qr.log(`Default model ${ch} is not available, proceeding without model specification`);else if(!i&&!await t.isModelAvailableForProvider("gemini",n))throw new Error(`Model '${n}' is not available for gemini provider`)}return n};async function Zj({config:t,netlify:e,persistSteps:r=void 0,sendSteps:n=void 0,aiGateway:i,continueSession:o=!1,priorAgentSessionId:s=void 0,cwd:a=lh.cwd(),abortSignal:c=void 0,onSessionId:l=void 0}){let{prompt:u}=t;await IBe(),PBe({aiGateway:i});let d=await OBe({aiGateway:i,config:t,model:t.model}),f=[],p=[],h=[],m={},y=0,S=0,T,x,v,N,R,U=!!(o&&s),C=!1;U&&(C=await zy(s)),U&&!C&&(Qr.log(`Gemini resume requested for session ${s} but it was not resumable; starting a fresh session`),fe.inc("inference.native_resume",1,{outcome:"sanitize_failed"}));let D=t.mode==="ask",j;D&&(j=Sc.join(Gy.homedir(),".gemini","ask-policy.toml"),await yu.mkdir(Sc.dirname(j),{recursive:!0}),await yu.writeFile(j,`[[rule]]
|
|
323
323
|
toolName = "web_fetch"
|
|
324
324
|
decision = "allow"
|
|
325
325
|
priority = 10
|
|
326
|
-
`,"utf-8"));let _=[mo(a,"gemini"),...d?["--model",d]:[],...D?["--approval-mode","default","--policy",j]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${lh.env.NVM_BIN}/node`;Qr.log(`Running ${ae} ${_.join(" ")}`);let I=e.utils.run(ae,_,{all:!0,env:{...lh.env,GEMINI_CLI_NO_RELAUNCH:"1"},cwd:a,idleTimeout:ds,cancelSignal:c});I.stdin?.end(u);let g=Na(()=>{r?.({steps:f,duration:S}),n?.({steps:p,duration:S}),p=[]},250),E=(Ce,V)=>{Ce.id=y,y+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};E({title:`Using ${
|
|
326
|
+
`,"utf-8"));let _=[mo(a,"gemini"),...d?["--model",d]:[],...D?["--approval-mode","default","--policy",j]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${lh.env.NVM_BIN}/node`;Qr.log(`Running ${ae} ${_.join(" ")}`);let I=e.utils.run(ae,_,{all:!0,env:{...lh.env,GEMINI_CLI_NO_RELAUNCH:"1"},cwd:a,idleTimeout:ds,cancelSignal:c});I.stdin?.end(u);let g=Na(()=>{r?.({steps:f,duration:S}),n?.({steps:p,duration:S}),p=[]},250),E=(Ce,V)=>{Ce.id=y,y+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};E({title:`Using ${Kj} with ${d||"default"}`,category:Y.Environment},!0);let W=ABe.createInterface({input:I.all});W.on("error",Ce=>{Qr.error("Readline interface error",{error:Ce.message,stack:Ce.stack})});let G="",ce=()=>{G&&E({message:G.trim(),category:Y.AgentMessage}),G=""};W.on("line",Ce=>{let V;try{if(Ce.startsWith("[API Error")){let De=Ce.match(/\[api error: (.+?)]$/i)?.[1];V={type:"error",value:Dee(De,!1)?.error?.message||De||"Gemini encountered error"}}else V=JSON.parse(Ce)}catch{return}if(V)switch(V.type==="init"&&typeof V.session_id=="string"&&(N=V.session_id,l?.(N)),["message","result"].includes(V.type)||ce(),V.type){case"message":{V.role!=="user"&&V.content&&(G+=V.content);break}case"tool_use":{if(V.tool_name===kte){if(V.tool_id&&!R){let M=up.safeParse(V.parameters);M.success?(R={questions:M.data.questions,toolUseId:V.tool_id},I.kill()):(Qr.warn("Ignoring malformed ask tool input",{toolUseId:V.tool_id}),fe.inc("inference.malformed_ask",1))}break}let De=Yj[V.tool_name]?.name??V.tool_name,be=V.parameters?.file_path,ee=be&&Sc.relative(a,be),ie=V.parameters?.command,Re=V.tool_name==="activate_skill"&&V.parameters?.name,te=V.tool_name==="run_shell_command"&&Ps(ie),Ae=[De,ee&&`\`${ee}\``,ie&&`\`${ie}\``].filter(Boolean).join(" ");if(Re)Ae=`Use ${go(Re)}`;else if(te)Ae="Generating the site";else if(V.tool_name==="grep_search"){let{dir_path:M,pattern:k}=V.parameters||{};M&&k?Ae=`Search in \`${M}\` for \`${k}\``:M?Ae=`Search in \`${M}\``:k&&(Ae=`Search for \`${k}\``)}else if(V.tool_name==="update_topic"){let M=V.parameters?.title;M&&(Ae=`${De} \`${M}\``)}let K={title:Ae,category:te?Y.SiteGeneration:Yj[V.tool_name]?.category,...Re&&{type:Re}};m[V.tool_id]=K,g.flush();break}case"tool_result":{let De=m[V.tool_id];De&&(V.output&&(De.message=`\`\`\`
|
|
327
327
|
${V.output.trim()}
|
|
328
|
-
\`\`\``),E(De,!0),CBe(De));break}case"result":{S=V.stats?.duration_ms,V.stats&&(so(V.stats),v=V.stats),V.status==="error"?x=V.error?.message:T=G.trim();break}case"error":{x=V.error;break}case"finished":break;case"init":break;default:{Qr.warn("Unhandled message type:",V.type);break}}});let Te=!1;if(await I.catch(Ce=>{Te=Of(Ce,c),{error:x,result:T}=RBe({catchError:Ce,runCmd:I,error:x,result:T,runnerName:"Gemini"})}),W.close(),R)return g.flush(),{steps:h,duration:S,agentSessionId:N,resolvedModel:d,usage:v,pendingInteraction:R};let we=Te;return we&&(!T&&G.trim()&&(T=G.trim()),x=void 0),g.flush(),{steps:h,duration:S,result:await Ja({initialResult:T,agentName:
|
|
328
|
+
\`\`\``),E(De,!0),CBe(De));break}case"result":{S=V.stats?.duration_ms,V.stats&&(so(V.stats),v=V.stats),V.status==="error"?x=V.error?.message:T=G.trim();break}case"error":{x=V.error;break}case"finished":break;case"init":break;default:{Qr.warn("Unhandled message type:",V.type);break}}});let Te=!1;if(await I.catch(Ce=>{Te=Of(Ce,c),{error:x,result:T}=RBe({catchError:Ce,runCmd:I,error:x,result:T,runnerName:"Gemini"})}),W.close(),R)return g.flush(),{steps:h,duration:S,agentSessionId:N,resolvedModel:d,usage:v,pendingInteraction:R};let we=Te;return we&&(!T&&G.trim()&&(T=G.trim()),x=void 0),g.flush(),{steps:h,duration:S,result:await Ja({initialResult:T,agentName:Kj,hasError:!!x}),error:Xa({error:x,agentName:Kj}),isRetryableError:Qa(x),isProviderUnavailableError:ec(x),resolvedModel:d,usage:v,agentSessionId:N,...we?{aborted:!0}:{}}}var ose=async()=>{let t=Sc.join(Gy.homedir(),".gemini");await yu.rm(t,{recursive:!0,force:!0});let e=Sc.join(Gy.homedir(),".agents","skills");await yu.rm(e,{recursive:!0,force:!0})},sse={baseDir:Sc.join(Gy.homedir(),".gemini"),include:["tmp"]};import MBe from"fs/promises";import dse from"os";import Xj from"path";import UR from"process";import DBe from"readline";import NBe from"os";import lse from"path";import Jj from"fs";var ase=ye("opencode_install"),cse="1.17.19",kBe=()=>lse.join(NBe.homedir(),".netlify-agent-runner","opencode"),use=async t=>{let e=mo(t,"opencode");if(e)return e;let r=kBe(),n=lse.join(r,"node_modules",".bin","opencode");if(Jj.existsSync(n))return n;Jj.mkdirSync(r,{recursive:!0}),ase.log(`Installing opencode-ai@${cse} on demand`);let i=Date.now();await Nr("npm",["install","--no-save","--no-audit","--no-fund","--prefix",r,`opencode-ai@${cse}`],{cwd:r});let o=Date.now()-i;if(fe.timing("opencode.install_duration",o),ase.log(`Installed opencode-ai in ${o}ms`),!Jj.existsSync(n))throw new Error("OpenCode CLI binary not found after installing opencode-ai");return n};var js=ye("runner_opencode"),$R="OpenCode",fse="gateway",LBe="z-ai/glm-5.2",pse={bash:{name:"Run command",category:Y.RunCommand},read:{name:"Read file",category:Y.FileRead},write:{name:"Edit file",category:Y.FileWrite},edit:{name:"Edit file",category:Y.FileWrite},glob:{name:"Find files",category:Y.Explore},grep:{name:"Search files",category:Y.Explore},list:{name:"List directory",category:Y.Explore},task:{name:"Task",category:Y.Task},todowrite:{name:"Update task list",category:Y.Todo},webfetch:{name:"Fetch web",category:Y.Web},websearch:{name:"Search web",category:Y.Web},skill:{name:"Use Skill",category:Y.Skill}},$Be=t=>pse[t]?.name||t,UBe=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(js.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(js.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(js.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function FBe({aiGateway:t,config:e,model:r}){let n=r;if(t){let i=t.isModelAvailable;if(!i)throw new Error("OpenCode runner requires a gateway with isModelAvailable support");let o=e.modelVersionOverrides?.opencode?.[e.accountType];o?n=o:r||(n=We().opencodeDefaultModel||LBe),n&&(await i(n)||js.log(`Model '${n}' not found in gateway catalog; proceeding anyway (gateway is authoritative, e.g. flag-gated OpenRouter models)`))}return n}function BBe({aiGateway:t,model:e}){if(!t)throw new Error("OpenCode runner requires the AI gateway");let{token:r,url:n}=t;if(!r||!n)throw new Error("No token or url provided from AI Gateway");let i=e?{[e]:{id:e,name:e,tool_call:!0,reasoning:!0,interleaved:{field:"reasoning_details"}}}:{},o={$schema:"https://opencode.ai/config.json",provider:{[fse]:{api:"openai",name:"Netlify AI Gateway",options:{apiKey:r,baseURL:n},...Object.keys(i).length>0?{models:i}:{}}}};UR.env.OPENCODE_CONFIG_CONTENT=JSON.stringify(o),UR.env.OPENCODE_DISABLE_AUTOUPDATE="1"}async function Qj({config:t,netlify:e,persistSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=UR.cwd()}){let{prompt:a}=t,{model:c}=t,l="",u,d,f,p=await FBe({config:t,aiGateway:n,model:c});BBe({aiGateway:n,model:p});let h=[],m=0,y=Date.now(),S=await use(s),T=["run","--format","json","--dangerously-skip-permissions","--agent","build",...p?["--model",`${fse}/${p}`]:[],...i?o?["--session",o]:["--continue"]:[]];js.log(`Running ${S} ${T.join(" ")}`);let x=e.utils.run(S,T,{all:!0,env:UR.env,cwd:s,idleTimeout:ds});x.stdin?.end(a);let v=Na(()=>{r?.({steps:h,duration:Date.now()-y})},250),N=(I,g)=>{let{wrapMessage:E,...w}=I,W=jx({...w,id:m});W.message&&E&&(W.message=`\`\`\`
|
|
329
329
|
${W.message}
|
|
330
|
-
\`\`\``),m+=1,h.push(W),g||v.flush(),v(),g&&v.flush()};N({title:`Using ${$R} with ${p||"default"}`,category:Y.Environment},!0);let U=DBe.createInterface({input:x.all});U.on("error",I=>{js.error("Readline interface error",{error:I.message,stack:I.stack})});let C="",D,j=new Set,_=()=>{C&&(N({message:C,category:Y.AgentMessage}),D=C,C="")};U.on("line",I=>{let g;try{g=JSON.parse(I)}catch{js.log("Could not parse line",I);return}switch(g.sessionID&&g.sessionID!==l&&(l=g.sessionID),g.type){case"step_start":{_();break}case"text":{let E=g.part?.text;E&&(C+=E);break}case"reasoning":{_();let E=g.part?.text;E&&N({title:"Reasoning",message:E,category:Y.Reasoning},!0);break}case"tool_use":{_();let E=g.part?.tool;if(!E)break;let w=g.part?.state?.input??{},W=g.part?.state?.status,G=g.part?.state?.output,ce=g.part?.state?.error;if(E==="skill"){let ie=typeof w.name=="string"?w.name:void 0;if(ie){let Re=go(ie);Ss(js,Re),N({title:`Use ${Re}`,category:Y.Skill,type:ie},!0);break}}let Te=typeof w.command=="string"?w.command:void 0,we=Te?Ps(Te):!1,Ce=typeof w.path=="string"&&w.path||typeof w.file_path=="string"&&w.file_path||typeof w.pattern=="string"&&w.pattern||void 0,V,De;if(we)V="Generating the site",De=Y.SiteGeneration;else if(Te&&E==="bash")V=`Running \`${Te}\``,De=Y.RunCommand;else{let ie=Ce&&`\`${
|
|
330
|
+
\`\`\``),m+=1,h.push(W),g||v.flush(),v(),g&&v.flush()};N({title:`Using ${$R} with ${p||"default"}`,category:Y.Environment},!0);let U=DBe.createInterface({input:x.all});U.on("error",I=>{js.error("Readline interface error",{error:I.message,stack:I.stack})});let C="",D,j=new Set,_=()=>{C&&(N({message:C,category:Y.AgentMessage}),D=C,C="")};U.on("line",I=>{let g;try{g=JSON.parse(I)}catch{js.log("Could not parse line",I);return}switch(g.sessionID&&g.sessionID!==l&&(l=g.sessionID),g.type){case"step_start":{_();break}case"text":{let E=g.part?.text;E&&(C+=E);break}case"reasoning":{_();let E=g.part?.text;E&&N({title:"Reasoning",message:E,category:Y.Reasoning},!0);break}case"tool_use":{_();let E=g.part?.tool;if(!E)break;let w=g.part?.state?.input??{},W=g.part?.state?.status,G=g.part?.state?.output,ce=g.part?.state?.error;if(E==="skill"){let ie=typeof w.name=="string"?w.name:void 0;if(ie){let Re=go(ie);Ss(js,Re),N({title:`Use ${Re}`,category:Y.Skill,type:ie},!0);break}}let Te=typeof w.command=="string"?w.command:void 0,we=Te?Ps(Te):!1,Ce=typeof w.path=="string"&&w.path||typeof w.file_path=="string"&&w.file_path||typeof w.pattern=="string"&&w.pattern||void 0,V,De;if(we)V="Generating the site",De=Y.SiteGeneration;else if(Te&&E==="bash")V=`Running \`${Te}\``,De=Y.RunCommand;else{let ie=Ce&&`\`${Xj.relative(s,Ce)}\``;V=[$Be(E),ie].filter(Boolean).join(" "),De=pse[E]?.category||Y.AgentMessage}let be,ee=["bash","read","glob","grep","list","webfetch","websearch"].includes(E);ce?be=`\`\`\`
|
|
331
331
|
${ce.trim()}
|
|
332
332
|
\`\`\``:G&&(be=ee?`\`\`\`
|
|
333
333
|
${G.trim()}
|
|
334
334
|
\`\`\``:G.trim()),W==="error"&&ce&&(be=be?`${be}
|
|
335
335
|
|
|
336
336
|
*Command failed*`:`*Command failed: ${ce.trim()}*`),N({title:V,message:be,category:De},!0);break}case"step_finish":{_();let E=g.part?.tokens;E&&(f={input_tokens:(f?.input_tokens??0)+(E.input??0),output_tokens:(f?.output_tokens??0)+(E.output??0),cache_creation_input_tokens:(f?.cache_creation_input_tokens??0)+(E.cache?.write??0),cache_read_input_tokens:(f?.cache_read_input_tokens??0)+(E.cache?.read??0)});break}case"error":{_();let E=g.part?.state?.error;E&&(d=d?`${d}
|
|
337
|
-
${E}`:E);break}default:g.type&&!j.has(g.type)&&(j.add(g.type),js.log(`Unhandled opencode event type: ${g.type}`))}}),await x.catch(I=>{let g=UBe({catchError:I,runCmd:x,error:d,result:u,runnerName:$R});d=g.error,u=g.result});let ae=Date.now()-y;return _(),U.close(),v.flush(),!d&&!u&&D&&(u=D),f&&so(f),{steps:h,duration:ae,result:await Ja({initialResult:u,agentName:$R,hasError:!!d}),error:Xa({error:d,agentName:$R}),isRetryableError:Qa(d),isProviderUnavailableError:ec(d),agentSessionId:l,resolvedModel:p,effort:"high",usage:f}}var hse=async()=>{let t=
|
|
337
|
+
${E}`:E);break}default:g.type&&!j.has(g.type)&&(j.add(g.type),js.log(`Unhandled opencode event type: ${g.type}`))}}),await x.catch(I=>{let g=UBe({catchError:I,runCmd:x,error:d,result:u,runnerName:$R});d=g.error,u=g.result});let ae=Date.now()-y;return _(),U.close(),v.flush(),!d&&!u&&D&&(u=D),f&&so(f),{steps:h,duration:ae,result:await Ja({initialResult:u,agentName:$R,hasError:!!d}),error:Xa({error:d,agentName:$R}),isRetryableError:Qa(d),isProviderUnavailableError:ec(d),agentSessionId:l,resolvedModel:p,effort:"high",usage:f}}var hse=async()=>{let t=Xj.join(dse.homedir(),".config","opencode");await MBe.rm(t,{recursive:!0,force:!0})},mse={baseDir:Xj.join(dse.homedir(),".config","opencode"),include:["opencode.db","opencode.db-shm","opencode.db-wal"]};var e2={codex:{runner:Hj,clean:ese,nativeSessionArchive:tse},claude:{runner:nj,clean:Hie,nativeSessionArchive:Wie},gemini:{runner:Zj,clean:ose,nativeSessionArchive:sse},opencode:{runner:Qj,clean:hse,nativeSessionArchive:mse}},nMt=Object.keys(e2),zs=t=>e2[t]?.nativeSessionArchive,uh=e2;import{execSync as jBe}from"child_process";import gse from"fs/promises";import zBe from"path";import dh from"process";var _se=ye("git-wrapper"),GBe=["status","diff","log","show","rev-parse","rev-list","ls-files","show-ref","cat-file","merge-base","blame","grep","describe"],qBe=t=>`#!/bin/bash
|
|
338
338
|
# Git wrapper that only allows read-only commands.
|
|
339
339
|
# The deployment system handles staging, moves, and commits automatically.
|
|
340
340
|
|
|
@@ -355,7 +355,7 @@ case "$1" in
|
|
|
355
355
|
exit 1
|
|
356
356
|
;;
|
|
357
357
|
esac
|
|
358
|
-
`,yse=async()=>{let t="/tmp/netlify-git-wrapper",e=zBe.join(t,"git"),r="/usr/bin/git";try{let n=(dh.env.PATH||"").split(":").filter(i=>i!==t).join(":");r=jBe("which git",{env:{...dh.env,PATH:n}}).toString().trim()||r}catch{}try{await gse.mkdir(t,{recursive:!0}),await gse.writeFile(e,qBe(r),{mode:493}),dh.env.PATH?.split(":").includes(t)||(dh.env.PATH=`${t}:${dh.env.PATH}`),dh.env.NETLIFY_INTERNAL_GIT="0",_se.info("Installed git wrapper to restrict the agent to read-only git commands")}catch(n){_se.warn("Failed to install git wrapper",{error:n?.message||n}),fe.inc("context.degraded",1,{component:"git_wrapper"})}};var qy=ye("init_stage"),WBe=async(t,e)=>{let r=HBe.join(e,ar,ao,t);try{return(await VBe.readdir(r,{withFileTypes:!0})).filter(i=>i.isFile()&&!i.name.endsWith(".part")).length}catch{return 0}},YBe=async(t,e)=>{if(!(!We().fetchAssetsEnabled||!t.assetMap))try{await _9({assetMap:t.assetMap,cwd:e})}catch(r){throw qy.error("Failed to fetch session assets",{error:r?.message||r}),fe.inc("assets.fetch_failed",1),new Error("Failed to download the attachments uploaded for this session. Please try again.")}},Sse=async({config:t,apiThrottle:e,apiToken:r,cwd:n,runnerVersion:i})=>await ft(qe(),"init-stage",async o=>{let s=performance.now();o?.setAttributes({"init.runner":t.runner,"init.id":t.id,"init.sessionId":t.sessionId,"init.hasRepo":t.hasRepo,"init.useGateway":t.useGateway,"init.runnerVersion":i||"unknown"});let a=uh[t.runner];if(!a)throw o?.setAttributes({"init.error":"unsupported_runner"}),new Error(`${t.runner} is not supported`);if(t.runner==="opencode"&&!We().opencodeEnabled)throw o?.setAttributes({"init.error":"opencode_disabled"}),new Error("opencode runner is not enabled on this environment");let c=KBe({apiToken:r,config:t});if(K5(c),t.siteId)try{t.site=await J5(t.siteId)}catch(S){qy.error("Failed to get the site information",{error:S})}let l=t.useGateway?await u9({config:t}):void 0;o?.setAttributes({"init.aiGateway.created":!!l}),await Hr(t.id,t.sessionId,{steps:[{title:"Environment ready",category:Y.Environment,type:"ready"}]});let u=5*1024,d=1e4,f=Bx(async({steps:S=[],duration:T})=>{let x=S.map(v=>{let N=v.title?fL(Gn(v.title),u):void 0,R=v.category===Y.AgentMessage||v.category===Y.UserMessage,U=v.message?Gn(v.message):void 0,C=U&&!R?fL(U,d):U,D=v.category===Y.UserMessage,j=C&&!D?rR(C):C;return j!==C&&qy.info("Sanitized internal error from step message",{original:C}),{...v,title:N,message:j}});S.length=0;try{return await Hr(t.id,t.sessionId,{steps:x,duration:T})}catch(v){qy.error("persistSteps failed",{error:v?.message||v})}},e);qy.info("Adding build files to stage");let p=await gL();await pL(p),Vy.env.NETLIFY_LOCAL_MODE||await yse();let h;t.hasRepo?t.sha?(h=t.sha,o?.setAttributes({"init.sha.source":"provided"})):(h=await mL(),t.mode!=="redeploy"&&await IT(t.id,{sha:h}),o?.setAttributes({"init.sha.source":"current_commit"})):(h=await jee(),o?.setAttributes({"init.sha.source":"first_commit","init.source":"zip"})),t.runSha=await mL(),await YBe(t,n);let m=await WBe(t.sessionId,n??Vy.cwd());fe.inc("assets.session",1,{has_assets:m>0}),m>0&&fe.distribution("assets.session.count",m);let y=performance.now()-s;return o?.setAttributes({"init.sha":h||"unknown","init.duration.ms":y,"init.status":"success","init.assetCount":m}),{aiGateway:l,context:c,persistSteps:f,runner:a,sha:h}}),KBe=({apiToken:t,config:e})=>({constants:{NETLIFY_API_HOST:Vy.env.NETLIFY_API_HOST||"api.netlify.com",NETLIFY_API_TOKEN:t||Vy.env.NETLIFY_API_TOKEN,SITE_ID:e.siteId,FUNCTIONS_DIST:Vy.env.FUNCTIONS_DIST||"netlify/functions"},utils:{run:Nr}});Fe();import ZBe from"crypto";import Er from"fs/promises";import FR from"os";import nt from"path";import Po from"process";import{fileURLToPath as JBe}from"url";var Rn=ye("context"),XBe=JBe(import.meta.url),QBe=nt.dirname(XBe),Ese={claude:nt.join(FR.homedir(),".claude","skills"),gemini:nt.join(FR.homedir(),".agents","skills"),codex:nt.join(FR.homedir(),".agents","skills"),opencode:nt.join(FR.homedir(),".agents","skills")},
|
|
358
|
+
`,yse=async()=>{let t="/tmp/netlify-git-wrapper",e=zBe.join(t,"git"),r="/usr/bin/git";try{let n=(dh.env.PATH||"").split(":").filter(i=>i!==t).join(":");r=jBe("which git",{env:{...dh.env,PATH:n}}).toString().trim()||r}catch{}try{await gse.mkdir(t,{recursive:!0}),await gse.writeFile(e,qBe(r),{mode:493}),dh.env.PATH?.split(":").includes(t)||(dh.env.PATH=`${t}:${dh.env.PATH}`),dh.env.NETLIFY_INTERNAL_GIT="0",_se.info("Installed git wrapper to restrict the agent to read-only git commands")}catch(n){_se.warn("Failed to install git wrapper",{error:n?.message||n}),fe.inc("context.degraded",1,{component:"git_wrapper"})}};var qy=ye("init_stage"),WBe=async(t,e)=>{let r=HBe.join(e,ar,ao,t);try{return(await VBe.readdir(r,{withFileTypes:!0})).filter(i=>i.isFile()&&!i.name.endsWith(".part")).length}catch{return 0}},YBe=async(t,e)=>{if(!(!We().fetchAssetsEnabled||!t.assetMap))try{await _9({assetMap:t.assetMap,cwd:e})}catch(r){throw qy.error("Failed to fetch session assets",{error:r?.message||r}),fe.inc("assets.fetch_failed",1),new Error("Failed to download the attachments uploaded for this session. Please try again.")}},Sse=async({config:t,apiThrottle:e,apiToken:r,cwd:n,runnerVersion:i})=>await ft(qe(),"init-stage",async o=>{let s=performance.now();o?.setAttributes({"init.runner":t.runner,"init.id":t.id,"init.sessionId":t.sessionId,"init.hasRepo":t.hasRepo,"init.useGateway":t.useGateway,"init.runnerVersion":i||"unknown"});let a=uh[t.runner];if(!a)throw o?.setAttributes({"init.error":"unsupported_runner"}),new Error(`${t.runner} is not supported`);if(t.runner==="opencode"&&!We().opencodeEnabled)throw o?.setAttributes({"init.error":"opencode_disabled"}),new Error("opencode runner is not enabled on this environment");let c=KBe({apiToken:r,config:t});if(K5(c),t.siteId)try{t.site=await J5(t.siteId)}catch(S){qy.error("Failed to get the site information",{error:S})}let l=t.useGateway?await u9({config:t}):void 0;o?.setAttributes({"init.aiGateway.created":!!l}),await Hr(t.id,t.sessionId,{steps:[{title:"Environment ready",category:Y.Environment,type:"ready"}]});let u=5*1024,d=1e4,f=Bx(async({steps:S=[],duration:T})=>{let x=S.map(v=>{let N=v.title?fL(Gn(v.title),u):void 0,R=v.category===Y.AgentMessage||v.category===Y.UserMessage,U=v.message?Gn(v.message):void 0,C=U&&!R?fL(U,d):U,D=v.category===Y.UserMessage,j=C&&!D?rR(C):C;return j!==C&&qy.info("Sanitized internal error from step message",{original:C}),{...v,title:N,message:j}});S.length=0;try{return await Hr(t.id,t.sessionId,{steps:x,duration:T})}catch(v){qy.error("persistSteps failed",{error:v?.message||v})}},e);qy.info("Adding build files to stage");let p=await gL();await pL(p),Vy.env.NETLIFY_LOCAL_MODE||await yse();let h;t.hasRepo?t.sha?(h=t.sha,o?.setAttributes({"init.sha.source":"provided"})):(h=await mL(),t.mode!=="redeploy"&&await IT(t.id,{sha:h}),o?.setAttributes({"init.sha.source":"current_commit"})):(h=await jee(),o?.setAttributes({"init.sha.source":"first_commit","init.source":"zip"})),t.runSha=await mL(),await YBe(t,n);let m=await WBe(t.sessionId,n??Vy.cwd());fe.inc("assets.session",1,{has_assets:m>0}),m>0&&fe.distribution("assets.session.count",m);let y=performance.now()-s;return o?.setAttributes({"init.sha":h||"unknown","init.duration.ms":y,"init.status":"success","init.assetCount":m}),{aiGateway:l,context:c,persistSteps:f,runner:a,sha:h}}),KBe=({apiToken:t,config:e})=>({constants:{NETLIFY_API_HOST:Vy.env.NETLIFY_API_HOST||"api.netlify.com",NETLIFY_API_TOKEN:t||Vy.env.NETLIFY_API_TOKEN,SITE_ID:e.siteId,FUNCTIONS_DIST:Vy.env.FUNCTIONS_DIST||"netlify/functions"},utils:{run:Nr}});Fe();import ZBe from"crypto";import Er from"fs/promises";import FR from"os";import nt from"path";import Po from"process";import{fileURLToPath as JBe}from"url";var Rn=ye("context"),XBe=JBe(import.meta.url),QBe=nt.dirname(XBe),Ese={claude:nt.join(FR.homedir(),".claude","skills"),gemini:nt.join(FR.homedir(),".agents","skills"),codex:nt.join(FR.homedir(),".agents","skills"),opencode:nt.join(FR.homedir(),".agents","skills")},eje=nt.join(QBe,"skills"),tje="asking-questions",r2=t=>t.replace(/<\/user_request/gi,"</user_request"),BR=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+$/.test(t)?t:null,rje=({userRequest:t,buildErrorContextText:e="",projectContext:r="",sessionHistoryContextText:n="",additionalContext:i="",netlifyInfo:o={},cliPath:s="netlify",skillsDir:a="",netlifyFolder:c=ar,resultsFilename:l=Sl,assetsFolder:u=ao,sessionId:d,currentSessionHasAssets:f=!1,nodeVersion:p=Po.version||"unknown",mode:h=void 0})=>{let m=BR(d),y=i?`<additional_rules>
|
|
359
359
|
${i}
|
|
360
360
|
</additional_rules>`:"",S=h==="ask"?`<responses>
|
|
361
361
|
- Write progress updates in concise, present-tense language describing what is happening now (e.g. "Reading the routing setup", "Checking the deploy configuration"). Avoid third-person self-reference (e.g. "the agent"), and avoid future-tense phrasing like "will".
|
|
@@ -391,7 +391,7 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
|
|
|
391
391
|
|
|
392
392
|
<request>
|
|
393
393
|
<user_request>
|
|
394
|
-
${
|
|
394
|
+
${r2(t)}
|
|
395
395
|
</user_request>
|
|
396
396
|
${e}
|
|
397
397
|
</request>
|
|
@@ -428,12 +428,12 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
|
|
|
428
428
|
</extra_context>
|
|
429
429
|
|
|
430
430
|
${n}
|
|
431
|
-
`},
|
|
431
|
+
`},t2=null;var zR="SKILL.md",nje=()=>{let t=We().skillVariations;return Rn.log(`Active skill variations: ${t.length?t.join(", "):"none"}`),t},vse=t=>{let e=t.match(/^(.+)@([^.]+)(.*)$/);return e?{baseName:`${e[1]}${e[3]}`,variation:e[2]}:{baseName:t,variation:null}},ije=async(t,e=[])=>{try{let r=await Er.readdir(t);for(let n of r){let{baseName:i,variation:o}=vse(n);if(o&&i===zR&&e.includes(o))return{filename:n,variation:o}}}catch{}return{filename:zR,variation:null}},oje=async(t,{targetDir:e,sourceDir:r}={})=>{let n=e||Ese[t],i=r||eje;if(!n)return Rn.warn(`Unknown runner: ${t}, skipping skills setup`),[];if(t2)return t2;let o=[],s=nje(),a=We().questionsEnabled;try{await Er.mkdir(n,{recursive:!0});let c=await Er.readdir(i);for(let l of c){let u=nt.join(i,l);if(!(await Er.stat(u)).isDirectory())continue;let{baseName:f,variation:p}=vse(l);if(p&&!s.includes(p)||f===tje&&!a)continue;let h=nt.join(n,f);try{await Er.cp(u,h,{recursive:!0});let m=await ije(u,s);m.variation&&(await Er.copyFile(nt.join(u,m.filename),nt.join(h,zR)),await Er.unlink(nt.join(h,m.filename)),Rn.log(`Using skill variation for ${f}: ${m.filename}`)),o.push(f),p&&Rn.log(`Installed skill variation: ${f} (variation: ${p})`)}catch(m){Rn.warn(`Failed to copy skill ${f}:`,m.message),fe.inc("context.degraded",1,{component:"skills"})}}}catch(c){Rn.warn("Failed to setup agent skills:",c.message),fe.inc("context.degraded",1,{component:"skills"})}if(o.includes("netlify-ai-gateway"))try{let c=await Wg(),l=nt.join(n,"netlify-ai-gateway",zR),u=await Er.readFile(l,"utf-8");if(u.includes("<!-- AVAILABLE_MODELS -->")){let d=Object.entries(c.providers).map(([f,p])=>`### ${f}
|
|
432
432
|
|
|
433
433
|
${p.models.map(h=>`- \`${h}\``).join(`
|
|
434
434
|
`)}`).join(`
|
|
435
435
|
|
|
436
|
-
`);u=u.replace("<!-- AVAILABLE_MODELS -->",d),await Er.writeFile(l,u,"utf-8"),Rn.log("Injected dynamic model list into AI Gateway skill",{modelList:d})}}catch(c){Rn.warn("Failed to inject dynamic model list into AI Gateway skill:",c.message),fe.inc("context.degraded",1,{component:"model_list"})}return o.length>0&&(Rn.log(`Installed ${o.length} skills for ${t}: ${o.join(", ")}`,{runner:t,skills:o,targetDir:n}),$t.getActiveSpan()?.setAttributes({"agent.skills_loaded":o,"agent.skills_loaded_count":o.length})),
|
|
436
|
+
`);u=u.replace("<!-- AVAILABLE_MODELS -->",d),await Er.writeFile(l,u,"utf-8"),Rn.log("Injected dynamic model list into AI Gateway skill",{modelList:d})}}catch(c){Rn.warn("Failed to inject dynamic model list into AI Gateway skill:",c.message),fe.inc("context.degraded",1,{component:"model_list"})}return o.length>0&&(Rn.log(`Installed ${o.length} skills for ${t}: ${o.join(", ")}`,{runner:t,skills:o,targetDir:n}),$t.getActiveSpan()?.setAttributes({"agent.skills_loaded":o,"agent.skills_loaded_count":o.length})),t2=o,o},sje=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:Po.env.NETLIFY_TEAM_ID,userId:Po.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:Po.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},aje=10,cje=async t=>{let{name:e,ext:r}=nt.parse(t),n=t,i=nt.join(Po.cwd(),ar,n),o=0;for(;await jR(i);){if(o>=aje)throw new Error("Failed to generate context file");n=`${e}-${ZBe.randomUUID().slice(0,5)}${r}`,i=nt.join(Po.cwd(),ar,n),o+=1}return n},jR=async t=>{try{return await Er.access(t),!0}catch{return!1}},bse=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:o})=>{let s=sje(e),a=await cje(p9),c=nt.join(Po.cwd(),ar);await Er.mkdir(c,{recursive:!0});let l=nt.join(ar,a),u=nt.join(Po.cwd(),l),d=nt.join(Po.cwd(),ar,Sl);try{await Er.unlink(d),Rn.log(`Deleted old results file: ${d}`)}catch{}let f=n?`You've already made changes to complete the above request. However, the build is currently failing after your changes.
|
|
437
437
|
Your task is to analyze and fix the build errors.
|
|
438
438
|
Don't apply techniques of reverting changes. Apply fixes related to errors.
|
|
439
439
|
Don't try to run build by yourself. Just fix the errors.
|
|
@@ -449,7 +449,7 @@ ${n}
|
|
|
449
449
|
</mode_reminder>`:"",C=`
|
|
450
450
|
<request>
|
|
451
451
|
<user_request>
|
|
452
|
-
${
|
|
452
|
+
${r2(r.prompt)}
|
|
453
453
|
</user_request>
|
|
454
454
|
${f}
|
|
455
455
|
</request>${R}${U}
|
|
@@ -482,29 +482,29 @@ ${g}`;return await Er.writeFile(j,E,"utf-8"),Rn.log(`Created history file: ${_}`
|
|
|
482
482
|
`)}
|
|
483
483
|
|
|
484
484
|
</session_history_context>
|
|
485
|
-
`}let m=r.skillsTargetDir||Ese[r.runner];r.runner&&await
|
|
485
|
+
`}let m=r.skillsTargetDir||Ese[r.runner];r.runner&&await oje(r.runner,{targetDir:r.skillsTargetDir});let y=BR(r.sessionId),S=y?nt.join(c,ao,y):null,T=!!S&&await jR(S),x=rje({userRequest:r.prompt,buildErrorContextText:f,projectContext:p,sessionHistoryContextText:h,additionalContext:i,netlifyInfo:s,cliPath:t,skillsDir:m,netlifyFolder:c,resultsFilename:Sl,assetsFolder:ao,sessionId:r.sessionId,currentSessionHasAssets:T,mode:r.mode});return await Er.writeFile(u,x,"utf-8"),Rn.log(`Generated agent context document at: ${u}`),x.length>5e5&&(x=`
|
|
486
486
|
You're an AI agent designed to assist with tasks related to a Netlify project. Please review, understand, and use the context provided to complete the user's request as needed.
|
|
487
487
|
|
|
488
488
|
<request>
|
|
489
489
|
<user_request>
|
|
490
|
-
${
|
|
490
|
+
${r2(r.prompt)}
|
|
491
491
|
</user_request>
|
|
492
492
|
${f}
|
|
493
493
|
</request>
|
|
494
494
|
|
|
495
495
|
Use the following file for the complete context of the ask, the environment, and what's available. ${u} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
|
|
496
|
-
`),x};var
|
|
497
|
-
A: ${
|
|
496
|
+
`),x};var lje=ye("prompt"),Tse=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o})=>{let s=await bse({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o});return process.env.AGENT_RUNNER_DEBUG&&lje.log("Contextful Prompt:",s),{prompt:s}};var xse=ye("session_manager"),n2=null;var uje,i2,dje=0,fje,pje;var o2=()=>uje,wse=()=>n2!==null,Ase=()=>dje,Rse=()=>pje,Ise=()=>fje,s2=async(t,e)=>{if(!We().idleTimeoutEnabled||!t||t===e)return;let r=uh[t];if(r)try{await r.clean(),xse.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){xse.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{i2=void 0}},fh=t=>{i2=t};var Cse=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===i2},Pse=async()=>{if(n2)try{await n2}catch{}};var Ose=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import{randomUUID as mje}from"crypto";var gje=ye("interactions"),Nse=async(t,e,r)=>{let n=mje();return await Hr(t.id,t.sessionId,{state:"await_input",interactions:{[n]:{type:"question",status:"pending",payload:e.questions,nativeToolId:e.toolUseId}},steps:[{id:n,refId:n,category:Y.Question}],...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},kse=async t=>{let e;try{e=await CT(t.id,t.sessionId)}catch(s){return gje.warn("Failed to fetch session for the full answer fold",{error:s?.message}),fe.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,o=(s,a)=>{!a||i.has(s)||(i.add(s),a.type==="question"&&(a.status==="answered"||a.status==="skipped")&&n.push({refId:s,questions:a.payload??[],responses:a.response??[]}))};for(let s of e?.steps??[])s?.refId&&o(s.refId,r[s.refId]);for(let[s,a]of Object.entries(r))o(s,a);return n},Mse=()=>({counted:!1}),Dse=(t,e)=>{let r=!1,n=e.map(o=>o.questions.map((s,a)=>{let c=o.responses[a];c==null&&(r=!0);let l=c==null?"(skipped)":Array.isArray(c)?c.join(", "):c;return`Q: ${s.question}
|
|
497
|
+
A: ${l}`}).join(`
|
|
498
498
|
|
|
499
499
|
`)).join(`
|
|
500
500
|
|
|
501
|
-
`);return[t,"You previously paused to ask the user for clarification. Here are their answers:",
|
|
501
|
+
`);return[t,"You previously paused to ask the user for clarification. Here are their answers:",n,`Continue with the task using these answers.${r?' A "(skipped)" answer means the user chose not to answer; proceed with your best judgment there.':""} Do not ask these questions again.`].filter(Boolean).join(`
|
|
502
502
|
|
|
503
|
-
`)};import Hs from"fs/promises";import Ude from"os";import Ws from"path";import{rm as BG}from"fs/promises";import{resolve as _2e}from"path";var y2e=".netlify/cache/",Su=function({cacheDir:t=y2e,cwd:e="."}={}){return _2e(e,t)};import{promises as RVe}from"fs";import{basename as fde,dirname as pde,join as IVe}from"path";import Gqe from"process";import qqe from"events";import Je from"path";import Vqe from"os";async function Hy(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((o,s)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),y=()=>{x(i.reason)},S=()=>{i?.removeEventListener("abort",y)},T=N=>{o(N),S()},x=N=>{u=!0,d=!0,s(N),S()};i&&(i.aborted&&x(i.reason),i.addEventListener("abort",y,{once:!0}));let v=async()=>{if(d)return;let N=await m.next(),R=h;if(h++,N.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){x(new AggregateError(c));return}if(d=!0,l.size===0){T(a);return}let U=[];for(let[C,D]of a.entries())l.get(C)!==Lse&&U.push(D);T(U)}return}p++,(async()=>{try{let U=await N.value;if(d)return;let C=await e(U,R);C===Lse&&l.set(R,C),a[R]=C,p--,await v()}catch(U){if(n)x(U);else{c.push(U),p--;try{await v()}catch(C){x(C)}}}})()};(async()=>{for(let N=0;N<r;N++){try{await v()}catch(R){x(R);break}if(f||u)break}})()})}var Lse=Symbol("skip");import vu from"path";import IDt,{constants as mj}from"fs";import gj from"fs/promises";var aj=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},cj=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},$se=t=>globalThis.DOMException===void 0?new cj(t):new DOMException(t),Use=t=>{let e=t.reason===void 0?$se("This operation was aborted."):t.reason;return e instanceof Error?e:$se(e)};function lj(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=e,s,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(Use(p)),a=()=>{d(Use(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new aj;s=o.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},l}var S2e=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function E2e(t,e,r){let n,i=new Promise((o,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=S2e(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),o(c)))},f=p=>{n(),s(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&o(c)});if(i.cancel=n,typeof r.timeout=="number"){let o=lj(i,{milliseconds:r.timeout});return o.cancel=n,o}return i}function GR(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=E2e(t,e,r),i=n.then(o=>o[0]);return i.cancel=n.cancel,i}var Fr=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Ni=on(Kse(),1);import{promisify as Wy}from"util";var vDt=Wy(Ni.default.stat),O2e=Wy(Ni.default.lstat),N2e=Wy(Ni.default.utimes),k2e=Wy(Ni.default.chmod),M2e=Wy(Ni.default.mkdir),bDt=Ni.default.closeSync.bind(Ni.default),Zse=Ni.default.createWriteStream.bind(Ni.default);async function Jse(t,e){let r=Ni.default.createReadStream(t,e);try{await GR(r,["readable","end"])}catch(n){throw new Fr(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var hj=t=>O2e(t).catch(e=>{throw new Fr(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),Xse=(t,e,r)=>N2e(t,e,r).catch(n=>{throw new Fr(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),Qse=(t,e)=>k2e(t,e).catch(r=>{throw new Fr(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var eae=(t,e)=>M2e(t,{...e,recursive:!0}).catch(r=>{throw new Fr(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var L2e=(t,e,r)=>({sourcePath:vu.resolve(t,e),destinationPath:vu.resolve(t,r)}),$2e=(t,e)=>{if(!t.isFile())throw Object.assign(new Fr(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function tae(t,e,r={}){if(!t||!e)throw new Fr("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=L2e(r.cwd,t,e)),r={overwrite:!0,...r};let n=await hj(t),{size:i}=n;$2e(n,t);let o=vu.dirname(e);if(vu.parse(o).root===o||await eae(vu.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await Jse(t),c=Zse(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:vu.resolve(t),destinationPath:vu.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new Fr(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=GR(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Fr(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await hj(t);return Promise.all([Xse(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),Qse(e,p.mode)])}}else{let a=r.overwrite?mj.COPYFILE_FICLONE:mj.COPYFILE_FICLONE|mj.COPYFILE_EXCL;try{await gj.copyFile(t,e,a),await Promise.all([gj.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),gj.chmod(e,n.mode)])}catch(c){throw new Fr(c.message,{cause:c})}}}async function _j(t,e,r){return(await Hy(t,(i,o)=>Promise.all([e(i,o),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import yue from"process";import Lqe from"fs";import wh from"path";import{on as U2e,once as F2e}from"events";import{PassThrough as B2e}from"stream";import{finished as iae}from"stream/promises";function vj(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Sj(i);let e=t.some(({readableObjectMode:i})=>i),r=j2e(t,e),n=new yj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&aae(n),n}var j2e=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yj=class extends B2e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){Sj(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=z2e(this,this.#e),V2e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return Sj(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},z2e=async(t,e)=>{YR(t,rae);let r=new AbortController;try{await Promise.race([G2e(t,r),q2e(t,e,r)])}finally{r.abort(),YR(t,-rae)}},G2e=async(t,{signal:e})=>{await iae(t,{signal:e,cleanup:!0})},q2e=async(t,e,{signal:r})=>{for await(let[n]of U2e(t,"unpipe",{signal:r}))e.has(n)&&n.emit(sae)},Sj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},V2e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{YR(t,nae);let s=new AbortController;try{await Promise.race([H2e(o,e),W2e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),Y2e({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),YR(t,-nae)}r.size===n.size+i.size&&(n.size===0&&i.size>0?Ej(t):aae(t))},oae=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",H2e=async(t,e)=>{try{await t,Ej(e)}catch(r){oae(r)?Ej(e):cae(e,r)}},W2e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await iae(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;oae(s)?i.add(e):cae(t,s)}},Y2e=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await F2e(t,sae,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},sae=Symbol("unpipe"),aae=t=>{t.writable&&t.end()},Ej=t=>{(t.readable||t.writable)&&t.destroy()},cae=(t,e)=>{t.destroyed||(t.once("error",K2e),t.destroy(e))},K2e=()=>{},YR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},rae=2,nae=1;var Ah=on(eS(),1);import aqe from"fs";import cqe from"fs/promises";async function aG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await cqe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function cG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return aqe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var a$t=aG.bind(void 0,"stat","isFile"),Qle=aG.bind(void 0,"stat","isDirectory"),c$t=aG.bind(void 0,"lstat","isSymbolicLink"),l$t=cG.bind(void 0,"statSync","isFile"),eue=cG.bind(void 0,"statSync","isDirectory"),u$t=cG.bind(void 0,"lstatSync","isSymbolicLink");var gG=on(eS(),1),lue=on(mG(),1);import Cqe from"process";import Pqe from"fs";import Oqe from"fs/promises";import xh from"path";function Th(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var rS=t=>t[0]==="!";var Nqe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],uue={absolute:!0,dot:!0},due="**/.gitignore",kqe=(t,e)=>rS(t)?"!"+xh.posix.join(e,t.slice(1)):xh.posix.join(e,t),Mqe=(t,e)=>{let r=Th(xh.relative(e,xh.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>kqe(n,r))},Dqe=(t,e)=>{if(e=Th(e),xh.isAbsolute(t)){if(Th(t).startsWith(e))return xh.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},fue=(t,e)=>{let r=t.flatMap(i=>Mqe(i,e)),n=(0,lue.default)().add(r);return i=>(i=Wr(i),i=Dqe(i,e),i?n.ignores(Th(i)):!1)},pue=(t={})=>({cwd:Wr(t.cwd)??Cqe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Nqe]}),hue=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=pue(e),s=await(0,gG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...uue}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Oqe.readFile(c,"utf8")})));return fue(a,r)},mue=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=pue(e),a=gG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...uue}).map(c=>({filePath:c,content:Pqe.readFileSync(c,"utf8")}));return fue(a,r)};var $qe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Sue=(t,e)=>{let r=rS(t)?t.slice(1):t;return wh.isAbsolute(r)?r:wh.join(e,r)},Eue=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>wh.posix.join(t,`**/${wh.extname(i)?i:`${i}${n}`}`)):[wh.posix.join(t,`**${n?`/*${n}`:""}`)]},gue=async(t,{cwd:e=yue.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Qle(Sue(o,e))?Eue({directoryPath:o,files:r,extensions:n}):o))).flat(),_ue=(t,{cwd:e=yue.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>eue(Sue(i,e))?Eue({directoryPath:i,files:r,extensions:n}):i),_G=t=>(t=[...new Set([t].flat())],$qe(t),t),Uqe=t=>{if(!t)return;let e;try{e=Lqe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},vue=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Wr(t.cwd)},Uqe(t.cwd),t),bue=t=>async(e,r)=>t(_G(e),vue(r)),AI=t=>(e,r)=>t(_G(e),vue(r)),Tue=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?_G(e):[];return r&&n.push(due),n},Fqe=async t=>{let e=Tue(t);return wue(e.length>0&&await hue(e,t))},xue=t=>{let e=Tue(t);return wue(e.length>0&&mue(e,t))},wue=t=>{let e=new Set;return r=>{let n=wh.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},Aue=(t,e)=>t.flat().filter(r=>e(r)),Rue=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>rS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},Iue=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),Cue=async(t,e)=>{let r=Rue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Iue(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([gue(a,o),gue(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},yG=(t,e)=>{let r=Rue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Iue(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=_ue(a,o),c.ignore=_ue(c.ignore,{cwd:n}),{patterns:a,options:c}})},O$t=bue(async(t,e)=>{let[r,n]=await Promise.all([Cue(t,e),Fqe(e)]),i=await Promise.all(r.map(o=>(0,Ah.default)(o.patterns,o.options)));return Aue(i,n)}),Pue=AI((t,e)=>{let r=yG(t,e),n=xue(e),i=r.map(o=>Ah.default.sync(o.patterns,o.options));return Aue(i,n)}),N$t=AI((t,e)=>{let r=yG(t,e),n=xue(e),i=r.map(s=>Ah.default.stream(s.patterns,s.options));return vj(i).filter(s=>n(s))}),wu=AI((t,e)=>t.some(r=>Ah.default.isDynamicPattern(r,e))),k$t=bue(Cue),M$t=AI(yG),{convertPathToPattern:D$t}=Ah.default;var Nue=on(Gj(),1);var Ic=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import II from"path";import Oue from"fs";var Bqe=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],jqe=new RegExp(Bqe.join("|"));function zqe(t){return jqe.test(t)}function RI(t){return!zqe(t)}var nS=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!wu(e)&&Oue.existsSync(e)&&Oue.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return II.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?wu(i):!1),n=e.slice(0,r).join("/");return n?II.isAbsolute(n)?n:II.join(this.options.cwd,n):this.destination}hasMagic(){return wu(this.options.flat?this.path:this.originalPath)}getMatches(){let e=Pue(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>RI(II.basename(r)))),e}};var Hqe={ignoreJunk:!0,flat:!1,cwd:Gqe.cwd()},SG=class{constructor(e,r,n){this.path=e.split("/").join(Je.sep),this.relativePath=r.split("/").join(Je.sep),this.pattern=n,Object.freeze(this)}get name(){return Je.basename(this.path)}get nameWithoutExtension(){return Je.basename(this.path,Je.extname(this.path))}get extension(){return Je.extname(this.path).slice(1)}},Wqe=t=>t.flatMap(e=>Nue.default.braces(e,{expand:!0,nodupes:!0})),Yqe=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?Je.isAbsolute(e)?Je.join(e,t.name):Je.join(r.cwd,e,t.name):Je.join(e,Je.relative(t.pattern.normalizedPath,t.path)):Je.isAbsolute(e)?Je.join(e,t.name):t.pattern.isDirectory&&Je.relative(r.cwd,t.path).startsWith("..")?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath)):Je.join(r.cwd,e,Je.relative(r.cwd,t.path)),Kqe=(t,e)=>{let r=Je.dirname(t);if(typeof e=="string")return Je.join(r,e);if(typeof e=="function"){let n=Je.basename(t);return Je.join(r,e(n))}return t};function EG(t,e,{concurrency:r=Vqe.availableParallelism(),...n}={}){let i=new Map,o=new qqe;n={...Hqe,...n};let s=(async()=>{let a=[],c=0,l=0,u=Wqe([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new Ic("`source` and `destination` required");u=u.map(h=>new nS(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(y){throw new Ic(`Cannot glob \`${h.originalPath}\`: ${y.message}`,{cause:y})}if(m.length===0&&!wu(h.originalPath)&&!wu(f))throw new Ic(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(y=>new SG(y,Je.relative(n.cwd,y),h))]}n.filter!==void 0&&(a=await _j(a,n.filter,{concurrency:1024})),a.length===0&&o.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),o.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return Hy(a,async h=>{let m=Kqe(Yqe({entry:h,destination:e,options:n}),n.rename);try{await tae(h.path,m,{...n,onProgress:p})}catch(y){throw new Ic(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${y.message}`,{cause:y})}return m},{concurrency:r})})();return s.on=(...a)=>(o.on(...a),s),s}import Jue from"process";import _Ve from"fs";import Ch from"path";import{on as Zqe,once as Jqe}from"events";import{PassThrough as Xqe}from"stream";import{finished as Due}from"stream/promises";function xG(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)bG(i);let e=t.some(({readableObjectMode:i})=>i),r=Qqe(t,e),n=new vG({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&Uue(n),n}var Qqe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},vG=class extends Xqe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){bG(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=eVe(this,this.#e),nVe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return bG(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},eVe=async(t,e)=>{CI(t,kue);let r=new AbortController;try{await Promise.race([tVe(t,r),rVe(t,e,r)])}finally{r.abort(),CI(t,-kue)}},tVe=async(t,{signal:e})=>{await Due(t,{signal:e,cleanup:!0})},rVe=async(t,e,{signal:r})=>{for await(let[n]of Zqe(t,"unpipe",{signal:r}))e.has(n)&&n.emit($ue)},bG=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{CI(t,Mue);let s=new AbortController;try{await Promise.race([iVe(o,e),oVe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),sVe({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),CI(t,-Mue)}r.size===n.size+i.size&&(n.size===0&&i.size>0?TG(t):Uue(t))},Lue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",iVe=async(t,e)=>{try{await t,TG(e)}catch(r){Lue(r)?TG(e):Fue(e,r)}},oVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Due(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Lue(s)?i.add(e):Fue(t,s)}},sVe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await Jqe(t,$ue,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},$ue=Symbol("unpipe"),Uue=t=>{t.writable&&t.end()},TG=t=>{(t.readable||t.writable)&&t.destroy()},Fue=(t,e)=>{t.destroyed||(t.once("error",aVe),t.destroy(e))},aVe=()=>{},CI=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},kue=2,Mue=1;var Ph=on(eS(),1);import cVe from"fs";import lVe from"fs/promises";async function wG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await lVe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function AG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return cVe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var a1t=wG.bind(void 0,"stat","isFile"),Bue=wG.bind(void 0,"stat","isDirectory"),c1t=wG.bind(void 0,"lstat","isSymbolicLink"),l1t=AG.bind(void 0,"statSync","isFile"),jue=AG.bind(void 0,"statSync","isDirectory"),u1t=AG.bind(void 0,"lstatSync","isSymbolicLink");var RG=on(eS(),1),zue=on(mG(),1);import uVe from"process";import dVe from"fs";import fVe from"fs/promises";import Ih from"path";function Rh(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var iS=t=>t[0]==="!";var pVe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],Gue={absolute:!0,dot:!0},que="**/.gitignore",hVe=(t,e)=>iS(t)?"!"+Ih.posix.join(e,t.slice(1)):Ih.posix.join(e,t),mVe=(t,e)=>{let r=Rh(Ih.relative(e,Ih.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>hVe(n,r))},gVe=(t,e)=>{if(e=Rh(e),Ih.isAbsolute(t)){if(Rh(t).startsWith(e))return Ih.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},Vue=(t,e)=>{let r=t.flatMap(i=>mVe(i,e)),n=(0,zue.default)().add(r);return i=>(i=Wr(i),i=gVe(i,e),i?n.ignores(Rh(i)):!1)},Hue=(t={})=>({cwd:Wr(t.cwd)??uVe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...pVe]}),Wue=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Hue(e),s=await(0,RG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Gue}),a=await Promise.all(s.map(async c=>({filePath:c,content:await fVe.readFile(c,"utf8")})));return Vue(a,r)},Yue=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Hue(e),a=RG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Gue}).map(c=>({filePath:c,content:dVe.readFileSync(c,"utf8")}));return Vue(a,r)};var yVe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Xue=(t,e)=>{let r=iS(t)?t.slice(1):t;return Ch.isAbsolute(r)?r:Ch.join(e,r)},Que=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>Ch.posix.join(t,`**/${Ch.extname(i)?i:`${i}${n}`}`)):[Ch.posix.join(t,`**${n?`/*${n}`:""}`)]},Kue=async(t,{cwd:e=Jue.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Bue(Xue(o,e))?Que({directoryPath:o,files:r,extensions:n}):o))).flat(),Zue=(t,{cwd:e=Jue.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>jue(Xue(i,e))?Que({directoryPath:i,files:r,extensions:n}):i),IG=t=>(t=[...new Set([t].flat())],yVe(t),t),SVe=t=>{if(!t)return;let e;try{e=_Ve.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},ede=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Wr(t.cwd)},SVe(t.cwd),t),tde=t=>async(e,r)=>t(IG(e),ede(r)),PI=t=>(e,r)=>t(IG(e),ede(r)),rde=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?IG(e):[];return r&&n.push(que),n},EVe=async t=>{let e=rde(t);return ide(e.length>0&&await Wue(e,t))},nde=t=>{let e=rde(t);return ide(e.length>0&&Yue(e,t))},ide=t=>{let e=new Set;return r=>{let n=Ch.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},ode=(t,e)=>t.flat().filter(r=>e(r)),sde=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>iS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},ade=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),cde=async(t,e)=>{let r=sde(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=ade(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Kue(a,o),Kue(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},CG=(t,e)=>{let r=sde(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=ade(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=Zue(a,o),c.ignore=Zue(c.ignore,{cwd:n}),{patterns:a,options:c}})},lde=tde(async(t,e)=>{let[r,n]=await Promise.all([cde(t,e),EVe(e)]),i=await Promise.all(r.map(o=>(0,Ph.default)(o.patterns,o.options)));return ode(i,n)}),P1t=PI((t,e)=>{let r=CG(t,e),n=nde(e),i=r.map(o=>Ph.default.sync(o.patterns,o.options));return ode(i,n)}),O1t=PI((t,e)=>{let r=CG(t,e),n=nde(e),i=r.map(s=>Ph.default.stream(s.patterns,s.options));return xG(i).filter(s=>n(s))}),N1t=PI((t,e)=>t.some(r=>Ph.default.isDynamicPattern(r,e))),k1t=tde(cde),M1t=PI(CG),{convertPathToPattern:D1t}=Ph.default;import bVe from"process";import oS from"path";import G1t,{promises as OI}from"fs";import U1t,{promises as vVe}from"fs";async function ude(t){try{return await vVe.access(t),!0}catch{return!1}}var TVe=(t,e,r)=>(e=oS.resolve(t,e),r=oS.resolve(t,r),{sourcePath:e,destinationPath:r}),xVe=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},wVe=(t,e)=>{if(oS.dirname(t)!==oS.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},AVe=async(t,e,{overwrite:r=!0,cwd:n=bVe.cwd(),directoryMode:i,validateDirectory:o=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=TVe(n,t,e)),o&&wVe(t,e),!r&&await ude(e))throw new Error(`The destination file exists: ${e}`);await OI.mkdir(oS.dirname(e),{recursive:!0,mode:i});try{await OI.rename(t,e)}catch(s){if(s.code==="EXDEV")await OI.copyFile(t,e),await OI.unlink(t);else throw s}};async function dde(t,e,r){return xVe(t,e),AVe(t,e,r)}var PG=async function(t,e,r=!1){if(r)return dde(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...o}=await hde(t,pde(e));if(n&&i)return EG(n,i,{...o,overwrite:!1})},sS=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await hde(t,"");return e!==void 0&&!await CVe(e,r,i)},CVe=async function(t,e,r){return e?(await lde(t,r)).filter(o=>RI(fde(o))).length===0:!1},hde=async function(t,e){let r=await PVe(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=fde(t),o=pde(t),s={srcGlob:i,dest:e,isDir:n,cwd:o,dot:!0};return n?{...s,srcGlob:`${i}/**`,dest:IVe(e,i)}:s},PVe=async t=>{try{return await RVe.stat(t)}catch{return}};import{join as w6e}from"path";import{stat as OVe,lstat as mde,readdir as NVe,realpath as kVe}from"fs/promises";import{Readable as MVe}from"stream";import{resolve as gde,relative as DVe,join as LVe,sep as $Ve}from"path";var Cn={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},OG={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Cn.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(OG);var Ede="READDIRP_RECURSIVE_ERROR",UVe=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ede]),_de=[Cn.DIR_TYPE,Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE,Cn.FILE_TYPE],FVe=new Set([Cn.DIR_TYPE,Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE]),BVe=new Set([Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE,Cn.FILE_TYPE]),jVe=t=>UVe.has(t.code),zVe=process.platform==="win32",yde=t=>!0,Sde=t=>{if(t===void 0)return yde;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return yde},NG=class extends MVe{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...OG,...e},{root:n,type:i}=r;this._fileFilter=Sde(r.fileFilter),this._directoryFilter=Sde(r.directoryFilter);let o=r.lstat?mde:OVe;zVe?this._stat=s=>o(s,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??OG.depth,this._wantsDir=i?FVe.has(i):!1,this._wantsFile=i?BVe.has(i):!1,this._wantsEverything=i===Cn.EVERYTHING_TYPE,this._root=gde(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:o}=r,s=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(s);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,o+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await NVe(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let o=gde(LVe(r,i));n={path:DVe(this._root,o),fullPath:o,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return n}_onError(e){jVe(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await kVe(n),o=await mde(i);if(o.isFile())return"file";if(o.isDirectory()){let s=i.length;if(n.startsWith(i)&&n.substr(s,1)===$Ve){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=Ede,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function GVe(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Cn.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!_de.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${_de.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new NG(e)}function vde(t,e={}){return new Promise((r,n)=>{let i=[];GVe(t,e).on("data",o=>i.push(o)).on("end",()=>r(i)).on("error",o=>n(o))})}import{mkdir as r6e,readFile as Ide,rm as n6e,writeFile as i6e}from"fs/promises";import{existsSync as Cde}from"fs";import{dirname as o6e}from"path";var bde=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},Tde=t=>t!==void 0&&Date.now()>t;import{createHash as XVe}from"crypto";import{createReadStream as QVe}from"fs";import HVe from"process";import WVe from"path";import fUt,{promises as xde}from"fs";import{fileURLToPath as YVe}from"url";var kG=class{value;next;constructor(e){this.value=e}},aS=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new kG(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function NI(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new aS,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},o=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},s=(a,...c)=>new Promise(l=>{o(a,l,c)});return Object.defineProperties(s,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),s}var kI=class extends Error{constructor(e){super(),this.value=e}},qVe=async(t,e)=>e(await t),VVe=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new kI(e[0]);return!1};async function MG(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=NI(r),o=[...t].map(a=>[a,i(qVe,a,e)]),s=NI(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(o.map(a=>s(VVe,a)))}catch(a){if(a instanceof kI)return a.value;throw a}}var wde={directory:"isDirectory",file:"isFile"};function KVe(t){if(!Object.hasOwnProperty.call(wde,t))throw new Error(`Invalid type specified: ${t}`)}var ZVe=(t,e)=>e[wde[t]](),JVe=t=>t instanceof URL?YVe(t):t;async function Ade(t,{cwd:e=HVe.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:o}={}){KVe(r),e=JVe(e);let s=n?xde.stat:xde.lstat;return MG(t,async a=>{try{let c=await s(WVe.resolve(e,a));return ZVe(r,c)}catch{return!1}},{concurrency:i,preserveOrder:o})}var e6e="sha1",Rde=async function(t,e){if(e||t.length===0)return;let r=await Ade(t);return r===void 0?void 0:await t6e(r)},t6e=async function(t){let e=QVe(t,"utf8"),r=XVe(e6e,{encoding:"hex"});return e.pipe(r),await Yd(r)};var Pde=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=MI(t),o=bde(r),s=await Rde(n,e),c=`${JSON.stringify({expires:o,hash:s},null,2)}
|
|
503
|
+
`)};import Hs from"fs/promises";import Ude from"os";import Ws from"path";import{rm as BG}from"fs/promises";import{resolve as _je}from"path";var yje=".netlify/cache/",Su=function({cacheDir:t=yje,cwd:e="."}={}){return _je(e,t)};import{promises as RVe}from"fs";import{basename as fde,dirname as pde,join as IVe}from"path";import Gqe from"process";import qqe from"events";import Je from"path";import Vqe from"os";async function Hy(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((o,s)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),y=()=>{x(i.reason)},S=()=>{i?.removeEventListener("abort",y)},T=N=>{o(N),S()},x=N=>{u=!0,d=!0,s(N),S()};i&&(i.aborted&&x(i.reason),i.addEventListener("abort",y,{once:!0}));let v=async()=>{if(d)return;let N=await m.next(),R=h;if(h++,N.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){x(new AggregateError(c));return}if(d=!0,l.size===0){T(a);return}let U=[];for(let[C,D]of a.entries())l.get(C)!==Lse&&U.push(D);T(U)}return}p++,(async()=>{try{let U=await N.value;if(d)return;let C=await e(U,R);C===Lse&&l.set(R,C),a[R]=C,p--,await v()}catch(U){if(n)x(U);else{c.push(U),p--;try{await v()}catch(C){x(C)}}}})()};(async()=>{for(let N=0;N<r;N++){try{await v()}catch(R){x(R);break}if(f||u)break}})()})}var Lse=Symbol("skip");import vu from"path";import IDt,{constants as m2}from"fs";import g2 from"fs/promises";var a2=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},c2=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},$se=t=>globalThis.DOMException===void 0?new c2(t):new DOMException(t),Use=t=>{let e=t.reason===void 0?$se("This operation was aborted."):t.reason;return e instanceof Error?e:$se(e)};function l2(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=e,s,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(Use(p)),a=()=>{d(Use(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new a2;s=o.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},l}var Sje=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function Eje(t,e,r){let n,i=new Promise((o,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=Sje(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),o(c)))},f=p=>{n(),s(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&o(c)});if(i.cancel=n,typeof r.timeout=="number"){let o=l2(i,{milliseconds:r.timeout});return o.cancel=n,o}return i}function GR(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Eje(t,e,r),i=n.then(o=>o[0]);return i.cancel=n.cancel,i}var Fr=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Ni=on(Kse(),1);import{promisify as Wy}from"util";var vDt=Wy(Ni.default.stat),Oje=Wy(Ni.default.lstat),Nje=Wy(Ni.default.utimes),kje=Wy(Ni.default.chmod),Mje=Wy(Ni.default.mkdir),bDt=Ni.default.closeSync.bind(Ni.default),Zse=Ni.default.createWriteStream.bind(Ni.default);async function Jse(t,e){let r=Ni.default.createReadStream(t,e);try{await GR(r,["readable","end"])}catch(n){throw new Fr(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var h2=t=>Oje(t).catch(e=>{throw new Fr(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),Xse=(t,e,r)=>Nje(t,e,r).catch(n=>{throw new Fr(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),Qse=(t,e)=>kje(t,e).catch(r=>{throw new Fr(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var eae=(t,e)=>Mje(t,{...e,recursive:!0}).catch(r=>{throw new Fr(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var Lje=(t,e,r)=>({sourcePath:vu.resolve(t,e),destinationPath:vu.resolve(t,r)}),$je=(t,e)=>{if(!t.isFile())throw Object.assign(new Fr(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function tae(t,e,r={}){if(!t||!e)throw new Fr("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=Lje(r.cwd,t,e)),r={overwrite:!0,...r};let n=await h2(t),{size:i}=n;$je(n,t);let o=vu.dirname(e);if(vu.parse(o).root===o||await eae(vu.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await Jse(t),c=Zse(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:vu.resolve(t),destinationPath:vu.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new Fr(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=GR(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Fr(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await h2(t);return Promise.all([Xse(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),Qse(e,p.mode)])}}else{let a=r.overwrite?m2.COPYFILE_FICLONE:m2.COPYFILE_FICLONE|m2.COPYFILE_EXCL;try{await g2.copyFile(t,e,a),await Promise.all([g2.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),g2.chmod(e,n.mode)])}catch(c){throw new Fr(c.message,{cause:c})}}}async function _2(t,e,r){return(await Hy(t,(i,o)=>Promise.all([e(i,o),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import yue from"process";import Lqe from"fs";import wh from"path";import{on as Uje,once as Fje}from"events";import{PassThrough as Bje}from"stream";import{finished as iae}from"stream/promises";function v2(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)S2(i);let e=t.some(({readableObjectMode:i})=>i),r=jje(t,e),n=new y2({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&aae(n),n}var jje=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},y2=class extends Bje{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){S2(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=zje(this,this.#e),Vje({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return S2(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},zje=async(t,e)=>{YR(t,rae);let r=new AbortController;try{await Promise.race([Gje(t,r),qje(t,e,r)])}finally{r.abort(),YR(t,-rae)}},Gje=async(t,{signal:e})=>{await iae(t,{signal:e,cleanup:!0})},qje=async(t,e,{signal:r})=>{for await(let[n]of Uje(t,"unpipe",{signal:r}))e.has(n)&&n.emit(sae)},S2=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Vje=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{YR(t,nae);let s=new AbortController;try{await Promise.race([Hje(o,e),Wje({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),Yje({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),YR(t,-nae)}r.size===n.size+i.size&&(n.size===0&&i.size>0?E2(t):aae(t))},oae=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Hje=async(t,e)=>{try{await t,E2(e)}catch(r){oae(r)?E2(e):cae(e,r)}},Wje=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await iae(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;oae(s)?i.add(e):cae(t,s)}},Yje=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await Fje(t,sae,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},sae=Symbol("unpipe"),aae=t=>{t.writable&&t.end()},E2=t=>{(t.readable||t.writable)&&t.destroy()},cae=(t,e)=>{t.destroyed||(t.once("error",Kje),t.destroy(e))},Kje=()=>{},YR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},rae=2,nae=1;var Ah=on(eS(),1);import aqe from"fs";import cqe from"fs/promises";async function aG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await cqe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function cG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return aqe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var a$t=aG.bind(void 0,"stat","isFile"),Qle=aG.bind(void 0,"stat","isDirectory"),c$t=aG.bind(void 0,"lstat","isSymbolicLink"),l$t=cG.bind(void 0,"statSync","isFile"),eue=cG.bind(void 0,"statSync","isDirectory"),u$t=cG.bind(void 0,"lstatSync","isSymbolicLink");var gG=on(eS(),1),lue=on(mG(),1);import Cqe from"process";import Pqe from"fs";import Oqe from"fs/promises";import xh from"path";function Th(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var rS=t=>t[0]==="!";var Nqe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],uue={absolute:!0,dot:!0},due="**/.gitignore",kqe=(t,e)=>rS(t)?"!"+xh.posix.join(e,t.slice(1)):xh.posix.join(e,t),Mqe=(t,e)=>{let r=Th(xh.relative(e,xh.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>kqe(n,r))},Dqe=(t,e)=>{if(e=Th(e),xh.isAbsolute(t)){if(Th(t).startsWith(e))return xh.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},fue=(t,e)=>{let r=t.flatMap(i=>Mqe(i,e)),n=(0,lue.default)().add(r);return i=>(i=Wr(i),i=Dqe(i,e),i?n.ignores(Th(i)):!1)},pue=(t={})=>({cwd:Wr(t.cwd)??Cqe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Nqe]}),hue=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=pue(e),s=await(0,gG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...uue}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Oqe.readFile(c,"utf8")})));return fue(a,r)},mue=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=pue(e),a=gG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...uue}).map(c=>({filePath:c,content:Pqe.readFileSync(c,"utf8")}));return fue(a,r)};var $qe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Sue=(t,e)=>{let r=rS(t)?t.slice(1):t;return wh.isAbsolute(r)?r:wh.join(e,r)},Eue=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>wh.posix.join(t,`**/${wh.extname(i)?i:`${i}${n}`}`)):[wh.posix.join(t,`**${n?`/*${n}`:""}`)]},gue=async(t,{cwd:e=yue.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Qle(Sue(o,e))?Eue({directoryPath:o,files:r,extensions:n}):o))).flat(),_ue=(t,{cwd:e=yue.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>eue(Sue(i,e))?Eue({directoryPath:i,files:r,extensions:n}):i),_G=t=>(t=[...new Set([t].flat())],$qe(t),t),Uqe=t=>{if(!t)return;let e;try{e=Lqe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},vue=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Wr(t.cwd)},Uqe(t.cwd),t),bue=t=>async(e,r)=>t(_G(e),vue(r)),AI=t=>(e,r)=>t(_G(e),vue(r)),Tue=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?_G(e):[];return r&&n.push(due),n},Fqe=async t=>{let e=Tue(t);return wue(e.length>0&&await hue(e,t))},xue=t=>{let e=Tue(t);return wue(e.length>0&&mue(e,t))},wue=t=>{let e=new Set;return r=>{let n=wh.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},Aue=(t,e)=>t.flat().filter(r=>e(r)),Rue=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>rS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},Iue=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),Cue=async(t,e)=>{let r=Rue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Iue(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([gue(a,o),gue(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},yG=(t,e)=>{let r=Rue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Iue(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=_ue(a,o),c.ignore=_ue(c.ignore,{cwd:n}),{patterns:a,options:c}})},O$t=bue(async(t,e)=>{let[r,n]=await Promise.all([Cue(t,e),Fqe(e)]),i=await Promise.all(r.map(o=>(0,Ah.default)(o.patterns,o.options)));return Aue(i,n)}),Pue=AI((t,e)=>{let r=yG(t,e),n=xue(e),i=r.map(o=>Ah.default.sync(o.patterns,o.options));return Aue(i,n)}),N$t=AI((t,e)=>{let r=yG(t,e),n=xue(e),i=r.map(s=>Ah.default.stream(s.patterns,s.options));return v2(i).filter(s=>n(s))}),wu=AI((t,e)=>t.some(r=>Ah.default.isDynamicPattern(r,e))),k$t=bue(Cue),M$t=AI(yG),{convertPathToPattern:D$t}=Ah.default;var Nue=on(G2(),1);var Ic=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import II from"path";import Oue from"fs";var Bqe=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],jqe=new RegExp(Bqe.join("|"));function zqe(t){return jqe.test(t)}function RI(t){return!zqe(t)}var nS=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!wu(e)&&Oue.existsSync(e)&&Oue.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return II.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?wu(i):!1),n=e.slice(0,r).join("/");return n?II.isAbsolute(n)?n:II.join(this.options.cwd,n):this.destination}hasMagic(){return wu(this.options.flat?this.path:this.originalPath)}getMatches(){let e=Pue(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>RI(II.basename(r)))),e}};var Hqe={ignoreJunk:!0,flat:!1,cwd:Gqe.cwd()},SG=class{constructor(e,r,n){this.path=e.split("/").join(Je.sep),this.relativePath=r.split("/").join(Je.sep),this.pattern=n,Object.freeze(this)}get name(){return Je.basename(this.path)}get nameWithoutExtension(){return Je.basename(this.path,Je.extname(this.path))}get extension(){return Je.extname(this.path).slice(1)}},Wqe=t=>t.flatMap(e=>Nue.default.braces(e,{expand:!0,nodupes:!0})),Yqe=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?Je.isAbsolute(e)?Je.join(e,t.name):Je.join(r.cwd,e,t.name):Je.join(e,Je.relative(t.pattern.normalizedPath,t.path)):Je.isAbsolute(e)?Je.join(e,t.name):t.pattern.isDirectory&&Je.relative(r.cwd,t.path).startsWith("..")?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath)):Je.join(r.cwd,e,Je.relative(r.cwd,t.path)),Kqe=(t,e)=>{let r=Je.dirname(t);if(typeof e=="string")return Je.join(r,e);if(typeof e=="function"){let n=Je.basename(t);return Je.join(r,e(n))}return t};function EG(t,e,{concurrency:r=Vqe.availableParallelism(),...n}={}){let i=new Map,o=new qqe;n={...Hqe,...n};let s=(async()=>{let a=[],c=0,l=0,u=Wqe([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new Ic("`source` and `destination` required");u=u.map(h=>new nS(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(y){throw new Ic(`Cannot glob \`${h.originalPath}\`: ${y.message}`,{cause:y})}if(m.length===0&&!wu(h.originalPath)&&!wu(f))throw new Ic(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(y=>new SG(y,Je.relative(n.cwd,y),h))]}n.filter!==void 0&&(a=await _2(a,n.filter,{concurrency:1024})),a.length===0&&o.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),o.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return Hy(a,async h=>{let m=Kqe(Yqe({entry:h,destination:e,options:n}),n.rename);try{await tae(h.path,m,{...n,onProgress:p})}catch(y){throw new Ic(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${y.message}`,{cause:y})}return m},{concurrency:r})})();return s.on=(...a)=>(o.on(...a),s),s}import Jue from"process";import _Ve from"fs";import Ch from"path";import{on as Zqe,once as Jqe}from"events";import{PassThrough as Xqe}from"stream";import{finished as Due}from"stream/promises";function xG(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)bG(i);let e=t.some(({readableObjectMode:i})=>i),r=Qqe(t,e),n=new vG({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&Uue(n),n}var Qqe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},vG=class extends Xqe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){bG(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=eVe(this,this.#e),nVe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return bG(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},eVe=async(t,e)=>{CI(t,kue);let r=new AbortController;try{await Promise.race([tVe(t,r),rVe(t,e,r)])}finally{r.abort(),CI(t,-kue)}},tVe=async(t,{signal:e})=>{await Due(t,{signal:e,cleanup:!0})},rVe=async(t,e,{signal:r})=>{for await(let[n]of Zqe(t,"unpipe",{signal:r}))e.has(n)&&n.emit($ue)},bG=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{CI(t,Mue);let s=new AbortController;try{await Promise.race([iVe(o,e),oVe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),sVe({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),CI(t,-Mue)}r.size===n.size+i.size&&(n.size===0&&i.size>0?TG(t):Uue(t))},Lue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",iVe=async(t,e)=>{try{await t,TG(e)}catch(r){Lue(r)?TG(e):Fue(e,r)}},oVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Due(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Lue(s)?i.add(e):Fue(t,s)}},sVe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await Jqe(t,$ue,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},$ue=Symbol("unpipe"),Uue=t=>{t.writable&&t.end()},TG=t=>{(t.readable||t.writable)&&t.destroy()},Fue=(t,e)=>{t.destroyed||(t.once("error",aVe),t.destroy(e))},aVe=()=>{},CI=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},kue=2,Mue=1;var Ph=on(eS(),1);import cVe from"fs";import lVe from"fs/promises";async function wG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await lVe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function AG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return cVe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var a1t=wG.bind(void 0,"stat","isFile"),Bue=wG.bind(void 0,"stat","isDirectory"),c1t=wG.bind(void 0,"lstat","isSymbolicLink"),l1t=AG.bind(void 0,"statSync","isFile"),jue=AG.bind(void 0,"statSync","isDirectory"),u1t=AG.bind(void 0,"lstatSync","isSymbolicLink");var RG=on(eS(),1),zue=on(mG(),1);import uVe from"process";import dVe from"fs";import fVe from"fs/promises";import Ih from"path";function Rh(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var iS=t=>t[0]==="!";var pVe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],Gue={absolute:!0,dot:!0},que="**/.gitignore",hVe=(t,e)=>iS(t)?"!"+Ih.posix.join(e,t.slice(1)):Ih.posix.join(e,t),mVe=(t,e)=>{let r=Rh(Ih.relative(e,Ih.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>hVe(n,r))},gVe=(t,e)=>{if(e=Rh(e),Ih.isAbsolute(t)){if(Rh(t).startsWith(e))return Ih.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},Vue=(t,e)=>{let r=t.flatMap(i=>mVe(i,e)),n=(0,zue.default)().add(r);return i=>(i=Wr(i),i=gVe(i,e),i?n.ignores(Rh(i)):!1)},Hue=(t={})=>({cwd:Wr(t.cwd)??uVe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...pVe]}),Wue=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Hue(e),s=await(0,RG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Gue}),a=await Promise.all(s.map(async c=>({filePath:c,content:await fVe.readFile(c,"utf8")})));return Vue(a,r)},Yue=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Hue(e),a=RG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Gue}).map(c=>({filePath:c,content:dVe.readFileSync(c,"utf8")}));return Vue(a,r)};var yVe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Xue=(t,e)=>{let r=iS(t)?t.slice(1):t;return Ch.isAbsolute(r)?r:Ch.join(e,r)},Que=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>Ch.posix.join(t,`**/${Ch.extname(i)?i:`${i}${n}`}`)):[Ch.posix.join(t,`**${n?`/*${n}`:""}`)]},Kue=async(t,{cwd:e=Jue.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Bue(Xue(o,e))?Que({directoryPath:o,files:r,extensions:n}):o))).flat(),Zue=(t,{cwd:e=Jue.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>jue(Xue(i,e))?Que({directoryPath:i,files:r,extensions:n}):i),IG=t=>(t=[...new Set([t].flat())],yVe(t),t),SVe=t=>{if(!t)return;let e;try{e=_Ve.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},ede=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Wr(t.cwd)},SVe(t.cwd),t),tde=t=>async(e,r)=>t(IG(e),ede(r)),PI=t=>(e,r)=>t(IG(e),ede(r)),rde=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?IG(e):[];return r&&n.push(que),n},EVe=async t=>{let e=rde(t);return ide(e.length>0&&await Wue(e,t))},nde=t=>{let e=rde(t);return ide(e.length>0&&Yue(e,t))},ide=t=>{let e=new Set;return r=>{let n=Ch.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},ode=(t,e)=>t.flat().filter(r=>e(r)),sde=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>iS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},ade=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),cde=async(t,e)=>{let r=sde(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=ade(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Kue(a,o),Kue(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},CG=(t,e)=>{let r=sde(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=ade(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=Zue(a,o),c.ignore=Zue(c.ignore,{cwd:n}),{patterns:a,options:c}})},lde=tde(async(t,e)=>{let[r,n]=await Promise.all([cde(t,e),EVe(e)]),i=await Promise.all(r.map(o=>(0,Ph.default)(o.patterns,o.options)));return ode(i,n)}),P1t=PI((t,e)=>{let r=CG(t,e),n=nde(e),i=r.map(o=>Ph.default.sync(o.patterns,o.options));return ode(i,n)}),O1t=PI((t,e)=>{let r=CG(t,e),n=nde(e),i=r.map(s=>Ph.default.stream(s.patterns,s.options));return xG(i).filter(s=>n(s))}),N1t=PI((t,e)=>t.some(r=>Ph.default.isDynamicPattern(r,e))),k1t=tde(cde),M1t=PI(CG),{convertPathToPattern:D1t}=Ph.default;import bVe from"process";import oS from"path";import G1t,{promises as OI}from"fs";import U1t,{promises as vVe}from"fs";async function ude(t){try{return await vVe.access(t),!0}catch{return!1}}var TVe=(t,e,r)=>(e=oS.resolve(t,e),r=oS.resolve(t,r),{sourcePath:e,destinationPath:r}),xVe=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},wVe=(t,e)=>{if(oS.dirname(t)!==oS.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},AVe=async(t,e,{overwrite:r=!0,cwd:n=bVe.cwd(),directoryMode:i,validateDirectory:o=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=TVe(n,t,e)),o&&wVe(t,e),!r&&await ude(e))throw new Error(`The destination file exists: ${e}`);await OI.mkdir(oS.dirname(e),{recursive:!0,mode:i});try{await OI.rename(t,e)}catch(s){if(s.code==="EXDEV")await OI.copyFile(t,e),await OI.unlink(t);else throw s}};async function dde(t,e,r){return xVe(t,e),AVe(t,e,r)}var PG=async function(t,e,r=!1){if(r)return dde(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...o}=await hde(t,pde(e));if(n&&i)return EG(n,i,{...o,overwrite:!1})},sS=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await hde(t,"");return e!==void 0&&!await CVe(e,r,i)},CVe=async function(t,e,r){return e?(await lde(t,r)).filter(o=>RI(fde(o))).length===0:!1},hde=async function(t,e){let r=await PVe(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=fde(t),o=pde(t),s={srcGlob:i,dest:e,isDir:n,cwd:o,dot:!0};return n?{...s,srcGlob:`${i}/**`,dest:IVe(e,i)}:s},PVe=async t=>{try{return await RVe.stat(t)}catch{return}};import{join as w6e}from"path";import{stat as OVe,lstat as mde,readdir as NVe,realpath as kVe}from"fs/promises";import{Readable as MVe}from"stream";import{resolve as gde,relative as DVe,join as LVe,sep as $Ve}from"path";var Cn={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},OG={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Cn.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(OG);var Ede="READDIRP_RECURSIVE_ERROR",UVe=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ede]),_de=[Cn.DIR_TYPE,Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE,Cn.FILE_TYPE],FVe=new Set([Cn.DIR_TYPE,Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE]),BVe=new Set([Cn.EVERYTHING_TYPE,Cn.FILE_DIR_TYPE,Cn.FILE_TYPE]),jVe=t=>UVe.has(t.code),zVe=process.platform==="win32",yde=t=>!0,Sde=t=>{if(t===void 0)return yde;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return yde},NG=class extends MVe{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...OG,...e},{root:n,type:i}=r;this._fileFilter=Sde(r.fileFilter),this._directoryFilter=Sde(r.directoryFilter);let o=r.lstat?mde:OVe;zVe?this._stat=s=>o(s,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??OG.depth,this._wantsDir=i?FVe.has(i):!1,this._wantsFile=i?BVe.has(i):!1,this._wantsEverything=i===Cn.EVERYTHING_TYPE,this._root=gde(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:o}=r,s=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(s);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,o+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await NVe(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let o=gde(LVe(r,i));n={path:DVe(this._root,o),fullPath:o,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return n}_onError(e){jVe(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await kVe(n),o=await mde(i);if(o.isFile())return"file";if(o.isDirectory()){let s=i.length;if(n.startsWith(i)&&n.substr(s,1)===$Ve){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=Ede,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function GVe(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Cn.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!_de.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${_de.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new NG(e)}function vde(t,e={}){return new Promise((r,n)=>{let i=[];GVe(t,e).on("data",o=>i.push(o)).on("end",()=>r(i)).on("error",o=>n(o))})}import{mkdir as r6e,readFile as Ide,rm as n6e,writeFile as i6e}from"fs/promises";import{existsSync as Cde}from"fs";import{dirname as o6e}from"path";var bde=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},Tde=t=>t!==void 0&&Date.now()>t;import{createHash as XVe}from"crypto";import{createReadStream as QVe}from"fs";import HVe from"process";import WVe from"path";import fUt,{promises as xde}from"fs";import{fileURLToPath as YVe}from"url";var kG=class{value;next;constructor(e){this.value=e}},aS=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new kG(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function NI(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new aS,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},o=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},s=(a,...c)=>new Promise(l=>{o(a,l,c)});return Object.defineProperties(s,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),s}var kI=class extends Error{constructor(e){super(),this.value=e}},qVe=async(t,e)=>e(await t),VVe=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new kI(e[0]);return!1};async function MG(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=NI(r),o=[...t].map(a=>[a,i(qVe,a,e)]),s=NI(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(o.map(a=>s(VVe,a)))}catch(a){if(a instanceof kI)return a.value;throw a}}var wde={directory:"isDirectory",file:"isFile"};function KVe(t){if(!Object.hasOwnProperty.call(wde,t))throw new Error(`Invalid type specified: ${t}`)}var ZVe=(t,e)=>e[wde[t]](),JVe=t=>t instanceof URL?YVe(t):t;async function Ade(t,{cwd:e=HVe.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:o}={}){KVe(r),e=JVe(e);let s=n?xde.stat:xde.lstat;return MG(t,async a=>{try{let c=await s(WVe.resolve(e,a));return ZVe(r,c)}catch{return!1}},{concurrency:i,preserveOrder:o})}var e6e="sha1",Rde=async function(t,e){if(e||t.length===0)return;let r=await Ade(t);return r===void 0?void 0:await t6e(r)},t6e=async function(t){let e=QVe(t,"utf8"),r=XVe(e6e,{encoding:"hex"});return e.pipe(r),await Yd(r)};var Pde=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=MI(t),o=bde(r),s=await Rde(n,e),c=`${JSON.stringify({expires:o,hash:s},null,2)}
|
|
504
504
|
`,l=await s6e({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},s6e=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!Cde(e)?!1:await Ide(e,"utf8")===r},Ode=async function({manifestPath:t,manifestString:e}){await r6e(o6e(t),{recursive:!0}),await i6e(t,e)},Nde=async function(t){let e=MI(t);await n6e(e,{force:!0,recursive:!0,maxRetries:3})},MI=function(t){return`${t}${Mde}`},kde=function(t){return t.endsWith(Mde)},Mde=".netlify.cache.json",DG=async function(t){let e=MI(t);if(!Cde(e))return!1;let{expires:r}=await a6e(t);return Tde(r)},a6e=async function(t){let e=MI(t),r=await Ide(e,"utf-8");return JSON.parse(r)};import{homedir as f6e}from"os";import{resolve as Dde,isAbsolute as p6e,join as h6e,sep as $G}from"path";import{normalize as c6e}from"path";import{existsSync as l6e}from"fs";import u6e from"process";var LG=function(t){try{let e=d6e(t);return l6e(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},d6e=function(t=u6e.cwd()){return c6e(t)};var cS=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await m6e(t,r),i=await S6e({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},m6e=async function(t,e){let r=await LG(e),n=g6e(t,r);return _6e(n,r),n},g6e=function(t,e){if(p6e(t))return Dde(t);if(e!=="")return Dde(e,t);throw new Error(`Current directory does not exist: ${e}`)},_6e=function(t,e){if(e!==""&&y6e(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},y6e=function(t,e){return`${e}${$G}`.startsWith(`${t}${$G}`)},S6e=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Su({cacheDir:e,cwd:r}),{name:i,relPath:o}=await E6e(t,r);return h6e(n,i,o)},E6e=async function(t,e){let r=await UG(e),n=v6e(t);return r.map(({name:i,base:o})=>T6e(i,o,n)).find(Boolean)},v6e=function(t){return t.replace(b6e,"\\")},b6e=/^[a-zA-Z]:\\/,T6e=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},UG=async function(t){return[...await x6e(t),{name:"home",base:f6e()},{name:"root",base:$G}]},x6e=async function(t){let e=await LG(t);return e===""?[]:[{name:"cwd",base:e}]};var A6e=1,FG=async function({cacheDir:t,cwd:e,depth:r=A6e}={}){let n=await UG(e),i=Su({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>R6e({name:a,base:c,cacheDir:i,depth:r})))).flat()},R6e=async function({name:t,base:e,cacheDir:r,depth:n}){return(await vde(`${r}/${t}`,{fileFilter:I6e,depth:n,type:"files_directories"})).map(({path:s})=>w6e(e,s))},I6e=function({basename:t}){return!kde(t)};var C6e=async function(t,{move:e=Lde,ttl:r=k6e,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await cS({path:t,cacheDir:i,cwdOpt:o});if(!await sS(s))return!1;let{manifestInfo:c,identical:l}=await Pde({cachePath:a,move:e,ttl:r,digests:n});return l||(await BG(a,{force:!0,recursive:!0,maxRetries:3}),await PG(s,a,e),await Ode(c)),!0},P6e=async function(t,{move:e=Lde,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await cS({path:t,cacheDir:r,cwdOpt:n});return!await sS(o)||await DG(o)?!1:(await BG(i,{force:!0,recursive:!0,maxRetries:3}),await PG(o,i,e),!0)},O6e=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await cS({path:t,cacheDir:e,cwdOpt:r});return await sS(n)?(await BG(n,{force:!0,recursive:!0,maxRetries:3}),await Nde(n),!0):!1},N6e=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await cS({path:t,cacheDir:e,cwdOpt:r});return await sS(n)&&!await DG(n)},Lde=!1,k6e=void 0,DI=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},M6e=DI.bind(null,C6e),D6e=DI.bind(null,P6e),L6e=DI.bind(null,O6e),$6e=DI.bind(null,N6e),$de=function(t){return{save:(e,r)=>M6e(e,{...t,...r}),restore:(e,r)=>D6e(e,{...t,...r}),remove:(e,r)=>L6e(e,{...t,...r}),has:(e,r)=>$6e(e,{...t,...r}),list:e=>FG({...t,...e}),getCacheDir:e=>Su({...t,...e})}};var rr=ye("native_session"),jG=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Hs.stat(Ws.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Au=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return rr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await Hs.stat(i)).isDirectory()}catch{}if(!s)return rr.log(`Native session base dir ${i} not found, skipping`),null;let a=await jG(i,o);if(a.length===0)return rr.log(`No native session history found under ${i}, skipping`),null;let c=Ws.join(Ude.tmpdir(),`native-session-${e}.zip`);try{await Nr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await Hs.readFile(c);rr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await t9(t,e);return await Hg(u,l,{contentType:"application/zip"}),rr.log("Successfully uploaded native session to S3"),d}catch(l){return rr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await Hs.rm(c,{force:!0}).catch(()=>{})}},Fde=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await jG(e,r);for(let i of n)if((await Hs.readdir(Ws.join(e,i)).catch(()=>[])).length>0)return!0;return!1},U6e=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Bde=async(t,e)=>{let r=await Hs.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Bde(Ws.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},jde=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${U6e(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:i}=t,o=await jG(n,i);for(let s of o)if(await Bde(Ws.join(n,s),r))return!0;return!1},zde=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return rr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=Ws.join(Ude.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await r9(t,e);if(!o?.download_url)return rr.log("No native session available to restore, skipping"),!1;let s=await l9(o.download_url);return await Hs.writeFile(i,s),rr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await Hs.mkdir(n,{recursive:!0}),await Nr("unzip",["-o","-q",i,"-d",n]),rr.log(`Restored native session into ${n}`),!0}catch(o){return rr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await Hs.rm(i,{force:!0}).catch(()=>{})}},F6e="native-sessions",Gde=(t,e)=>$de({cacheDir:Ws.join(e.dir,F6e),cwd:t}),qde=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await Gde(r,e).restore(n.map(o=>Ws.join(r,o)),{})?(rr.log(`Restored native session from buildbot cache into ${r}`),!0):(rr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return rr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Oh=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return rr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await Gde(n,e).save(i.map(s=>Ws.join(n,s)),{})?(rr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(rr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return rr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var Nh=ye("inference_stage"),Vde=5,Do=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:o,runner:s,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeSession:m,effortOverride:y,answerFold:S}=t;if(ho())throw new Error("Shutdown in progress, aborting inference stage");Nh.log(`Running inference stage, attempt ${l} of ${Vde}`);let T=!1,x=await ft(qe(),"inference-stage",async v=>{v?.setAttributes({"inference.attempt":l||1}),$5();let N=!!(l&&l>1),R=await B6e(n,N),U=!!m&&!!d;U&&n.runner==="gemini"&&!await zy(d)&&(U=!1);let C=R.viable||U;T=C,R.outcome!=="not_eligible"&&fe.inc("inference.native_resume",1,{outcome:R.outcome,...R.source?{source:R.source}:{}});let D=n;if("prompt"in n&&n.answeredInteraction&&We().questionsEnabled){let E=n.answeredInteraction,w=C||N&&!!d,W=[E];if(!w){S.allAnswered??=kse(n);let G=await S.allAnswered;G===null&&(S.allAnswered=void 0),G&&G.length>0&&(W=G.some(ce=>ce.refId===E.refId)?G:[...G,E])}D={...n,prompt:Dse(n.prompt,W)},!N&&!S.counted&&(S.counted=!0,Nh.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),fe.inc("inference.answer_resume",1,{fold:w?"latest":"all"}))}let{prompt:j}=await ft(qe(),"compose-prompt",async()=>await Tse({cliPath:r,config:D,buildErrorContext:j6e(o),netlify:i,additionalContext:e,resumePrompt:C})),_=`
|
|
505
505
|
${u||""}
|
|
506
506
|
${j}
|
|
507
|
-
`.trim(),ae={...n,prompt:_},I=d??(C?R.sessionId:void 0),g=await ft(qe(),`run-${n.runner}`,async E=>{let w=vM();E?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":z5(n.runner),"gen_ai.system":n.runner,...w?{"gen_ai.input.messages":xT("user",_)}:{}});let W=Date.now(),G=await s({aiGateway:c,config:ae,netlify:i,persistSteps:a,continueSession:N||C,priorAgentSessionId:I,cwd:f,abortSignal:p,onSessionId:h,...y?{effortOverride:y}:{}}),ce=Date.now(),Te=G.resolvedModel||n.model||"unknown",we=G.error?"error":"stop";return E?.setAttributes({...w?{"gen_ai.output.messages":xT("assistant",G.result??G.error??"",we)}:{},"gen_ai.response.finish_reasons":[we],"gen_ai.request.model":Te,"gen_ai.response.model":Te,...G.effort?{"gen_ai.request.effort":G.effort}:{},...G.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":G.usage.input_tokens}:{},...G.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":G.usage.output_tokens}:{},...G.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":G.usage.cache_creation_input_tokens}:{},...G.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":G.usage.cache_read_input_tokens}:{}}),G5(G.steps??[],n.mode,W,ce),G});return g.result&&(g.result=Gn(g.result)),g.error&&(g.error=Gn(g.error)),await a.flush(),g});if(x.aborted)return Nh.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:x.agentSessionId}),{runnerResult:x,nativeResume:T};if(x.error){if(ho()){let v=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(v,{agentSessionId:x.agentSessionId}),v}if(Nh.error("Runner failed",{stepsCount:x.steps.length,duration:x.duration,error:x.error,isRetryableError:x.isRetryableError,attempt:l||1,agentSessionId:x.agentSessionId}),fe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!x.isRetryableError,is_provider_unavailable:!!x.isProviderUnavailableError}),x.isRetryableError&&(!l||l<Vde))return Nh.log("Retrying inference stage"),await new Promise(N=>setTimeout(N,5e3)),{runnerResult:(await Do({...t,attempt:(l||1)+1,priorAgentSessionId:x.agentSessionId,contextPrefix:x.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:T};{if(Nh.log("Do not retry inference stage"),x.error.toLowerCase().includes("usage exceeded")){let N=new vi(x.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(N,{agentSessionId:x.agentSessionId}),N}let v=x.isRetryableError||x.isProviderUnavailableError?new $d(x.error):new Error(x.error);throw Object.assign(v,{agentSessionId:x.agentSessionId}),v}}return{runnerResult:x,nativeResume:T}},B6e=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:i}=Ose(t);if(!n)return{viable:n,outcome:i};let o=r?.nativeSessionId,s=zs(t.runner),a=async()=>o?t.runner==="gemini"?!!await
|
|
507
|
+
`.trim(),ae={...n,prompt:_},I=d??(C?R.sessionId:void 0),g=await ft(qe(),`run-${n.runner}`,async E=>{let w=vM();E?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":z5(n.runner),"gen_ai.system":n.runner,...w?{"gen_ai.input.messages":xT("user",_)}:{}});let W=Date.now(),G=await s({aiGateway:c,config:ae,netlify:i,persistSteps:a,continueSession:N||C,priorAgentSessionId:I,cwd:f,abortSignal:p,onSessionId:h,...y?{effortOverride:y}:{}}),ce=Date.now(),Te=G.resolvedModel||n.model||"unknown",we=G.error?"error":"stop";return E?.setAttributes({...w?{"gen_ai.output.messages":xT("assistant",G.result??G.error??"",we)}:{},"gen_ai.response.finish_reasons":[we],"gen_ai.request.model":Te,"gen_ai.response.model":Te,...G.effort?{"gen_ai.request.effort":G.effort}:{},...G.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":G.usage.input_tokens}:{},...G.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":G.usage.output_tokens}:{},...G.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":G.usage.cache_creation_input_tokens}:{},...G.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":G.usage.cache_read_input_tokens}:{}}),G5(G.steps??[],n.mode,W,ce),G});return g.result&&(g.result=Gn(g.result)),g.error&&(g.error=Gn(g.error)),await a.flush(),g});if(x.aborted)return Nh.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:x.agentSessionId}),{runnerResult:x,nativeResume:T};if(x.error){if(ho()){let v=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(v,{agentSessionId:x.agentSessionId}),v}if(Nh.error("Runner failed",{stepsCount:x.steps.length,duration:x.duration,error:x.error,isRetryableError:x.isRetryableError,attempt:l||1,agentSessionId:x.agentSessionId}),fe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!x.isRetryableError,is_provider_unavailable:!!x.isProviderUnavailableError}),x.isRetryableError&&(!l||l<Vde))return Nh.log("Retrying inference stage"),await new Promise(N=>setTimeout(N,5e3)),{runnerResult:(await Do({...t,attempt:(l||1)+1,priorAgentSessionId:x.agentSessionId,contextPrefix:x.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:T};{if(Nh.log("Do not retry inference stage"),x.error.toLowerCase().includes("usage exceeded")){let N=new vi(x.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(N,{agentSessionId:x.agentSessionId}),N}let v=x.isRetryableError||x.isProviderUnavailableError?new $d(x.error):new Error(x.error);throw Object.assign(v,{agentSessionId:x.agentSessionId}),v}}return{runnerResult:x,nativeResume:T}},B6e=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:i}=Ose(t);if(!n)return{viable:n,outcome:i};let o=r?.nativeSessionId,s=zs(t.runner),a=async()=>o?t.runner==="gemini"?!!await Wj(o):jde(s,o):!1,c;if(Cse(t)&&await Fde(s))c="local";else if(t.fastInit&&We().warmNativeResumeEnabled&&await qde({archive:s,cache:t.cache})&&await a())c="cache_restore";else{if(c="fetch",!We().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:c};if(!await zde({runnerId:t.id,sessionId:t.sessionId,archive:s}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&o&&!await zy(o)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:o,outcome:"resumed",source:c}},j6e=t=>!t||t.length===0?"":`
|
|
508
508
|
Deploy failed failed. Here are the errors to review on the latest build:
|
|
509
509
|
|
|
510
510
|
Below are all of the logs with potential issues that we extracted. Some of them may be false positives, discern them carefully and ensure fixes are relevant.
|
|
@@ -538,17 +538,17 @@ Output a single slug. No sentences, no markdown, no quotes, no newlines. Your en
|
|
|
538
538
|
`)}return t instanceof Error?t.message:String(t)};var VG=ye("migration_state"),UI=async({cliPath:t,cwd:e})=>{let r;try{let n=await Nr(t,["db","status","--json"],{cwd:e,stdio:["ignore","pipe","pipe"]});r=n.stdout?String(n.stdout):""}catch(n){let i=n;throw VG.warn("`netlify db status --json` failed",{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}),n}VG.log("`netlify db status --json` output",{stdout:r});try{return JSON.parse(r)}catch(n){throw VG.warn("Failed to parse `netlify db status --json` output",{stdout:r,error:String(n)}),n}},rfe=()=>["## Netlify Database","","A Netlify Database (managed Postgres) is available for this site.","It will be provisioned automatically on first connection.","No migrations have been applied yet \u2014 this is a fresh database.","","Use `@netlify/database` with Drizzle ORM for persistent data storage.","Define your schema in `db/schema.ts` and migrations will be generated automatically at deploy time.","Read the `netlify-database` skill for setup instructions."].join(`
|
|
539
539
|
`),nfe=t=>{if(t.applied.length===0&&t.pending.length===0)return null;let e=["## CRITICAL: Current Netlify Database state",""];if(t.applied.length>0){e.push("The following migrations are **already applied** to your preview database branch. They are immutable:","");for(let r of t.applied)e.push(`- ${r.name}`);e.push("","**Never delete, rename, or edit an applied migration file.** Doing so will break the deploy \u2014 the","platform requires every migration applied to the branch to exist on disk with its original content. If","you think an applied migration is wrong, roll forward with a NEW migration that corrects whatever it","did. That's always safe; deletion isn't.")}else e.push("No migrations are applied to your preview database branch yet.");if(t.pending.length>0){e.push(""),e.push("The following migration files exist on disk but have NOT yet been applied:","");for(let r of t.pending)e.push(`- ${r.name}`);e.push("","Pending files can be modified or deleted freely \u2014 use `netlify db migrations reset` to remove them","cleanly, then regenerate via `npx drizzle-kit generate` if you want a replacement.")}return e.join(`
|
|
540
540
|
`)},ife=t=>{let e=[];return t.missingOnDisk.length>0&&e.push("You deleted the following migration file(s) that are already applied to the preview database branch:",...t.missingOnDisk.map(r=>`- ${r.name}`),"","Applied migrations cannot be removed \u2014 the deploy will fail because the platform requires every applied","migration to exist on disk with its original content. Please revise your work:","","1. Restore the deleted file(s) by running `netlify db migrations pull --force`, which overwrites the"," local migrations directory with the authoritative state of the branch. Note this also wipes any"," unapplied migration files you generated this session \u2014 regenerate them via `npx drizzle-kit generate`"," afterwards if you still need them (your `db/schema.ts` edits aren't affected by the pull).","2. If the underlying problem is that an applied migration is wrong, add a NEW migration on top that"," corrects whatever it did (drop a column, rename a table, etc.). Do not touch the original."),t.outOfOrder.length>0&&(e.length>0&&e.push(""),e.push("The following pending migration file(s) have a version prefix that sorts BEFORE migrations already","applied to the branch, so the platform will reject them on deploy:",...t.outOfOrder.map(r=>`- ${r.name} (version ${r.version} \u2264 applied max ${r.maxApplied})`),"","Delete these out-of-order files (use `netlify db migrations reset` \u2014 it only removes unapplied files),","then run `npx drizzle-kit generate` to produce a replacement whose version sorts after the applied","migrations.")),e.length===0?null:e.join(`
|
|
541
|
-
`)},ofe=t=>t.missingOnDisk.length>0||t.outOfOrder.length>0;var sfe=ye("db_migrations_verify"),afe=async t=>await ft(qe(),"db-migrations-verify-stage",async e=>{let r;try{r=await UI({cliPath:t.cliPath,cwd:t.cwd})}catch(i){return sfe.warn("Skipping migration verification \u2014 failed to read status",{error:i}),e?.setAttributes({"verify.skipped":!0,"verify.skip_reason":"status_error"}),{}}if(!ofe(r))return e?.setAttributes({"verify.drift":!1}),{};let n=ife(r);return e?.setAttributes({"verify.drift":!0,"verify.missing_on_disk_count":r.missingOnDisk.length,"verify.out_of_order_count":r.outOfOrder.length}),sfe.log("Detected post-inference migration drift",{missingOnDisk:r.missingOnDisk.map(i=>i.name),outOfOrder:r.outOfOrder.map(i=>i.name)}),{error:n??void 0}});import K4 from"process";import xYe from"net";var Nn=on(H4(),1),
|
|
541
|
+
`)},ofe=t=>t.missingOnDisk.length>0||t.outOfOrder.length>0;var sfe=ye("db_migrations_verify"),afe=async t=>await ft(qe(),"db-migrations-verify-stage",async e=>{let r;try{r=await UI({cliPath:t.cliPath,cwd:t.cwd})}catch(i){return sfe.warn("Skipping migration verification \u2014 failed to read status",{error:i}),e?.setAttributes({"verify.skipped":!0,"verify.skip_reason":"status_error"}),{}}if(!ofe(r))return e?.setAttributes({"verify.drift":!1}),{};let n=ife(r);return e?.setAttributes({"verify.drift":!0,"verify.missing_on_disk_count":r.missingOnDisk.length,"verify.out_of_order_count":r.outOfOrder.length}),sfe.log("Detected post-inference migration drift",{missingOnDisk:r.missingOnDisk.map(i=>i.name),outOfOrder:r.outOfOrder.map(i=>i.name)}),{error:n??void 0}});import K4 from"process";import xYe from"net";var Nn=on(H4(),1),tjt=Nn.default.Client,rjt=Nn.default.Pool,njt=Nn.default.Connection,ijt=Nn.default.types,ojt=Nn.default.Query,sjt=Nn.default.DatabaseError,ajt=Nn.default.escapeIdentifier,cjt=Nn.default.escapeLiteral,ljt=Nn.default.Result,ujt=Nn.default.TypeOverrides,djt=Nn.default.defaults,Jpe=Nn.default;var wYe=80877103,AYe=196608,RYe=Buffer.from([78]);function IYe(){let t=Buffer.alloc(9);t.writeUInt8(82,0),t.writeInt32BE(8,1),t.writeInt32BE(0,5);let e=Buffer.alloc(6);return e.writeUInt8(90,0),e.writeInt32BE(5,1),e.writeUInt8(73,5),Buffer.concat([t,e])}function rC(t){let e=Buffer.from("SERROR\0","utf8"),r=Buffer.concat([Buffer.from("M","utf8"),Buffer.from(t+"\0","utf8")]),n=Buffer.from("CXX000\0","utf8"),i=Buffer.from([0]),o=e.length+r.length+n.length+i.length,s=Buffer.alloc(5);return s.writeUInt8(69,0),s.writeInt32BE(o+4,1),Buffer.concat([s,e,n,r,i])}async function CYe(t){let{clientSocket:e,provision:r,logger:n,cleanup:i}=t,o;try{o=await r()}catch(f){let p=f instanceof Error?f.message:"Provisioning failed";throw n("Provisioning error:",p),e.end(rC(p)),i(),f}let s=OYe(o),a=new Jpe.Client({host:s.host,port:s.port,user:s.user,password:s.password,database:s.database,ssl:s.ssl,options:s.options});a.on("error",()=>{});try{await a.connect()}catch(f){let p=f instanceof Error?f.message:"Remote connection failed";throw n("Remote connection error:",p),e.end(rC(p)),i(),f}let c=a.connection,l=c.stream;c.removeAllListeners(),l.removeAllListeners();let u=l,d=f=>p=>{p.code!=="ECONNRESET"&&n(`${f} socket error:`,p.message),i()};return u.on("error",d("Remote")),u.on("close",i),e.on("error",d("Client")),e.on("close",i),e.write(IYe()),e.on("data",f=>{u.destroyed||u.write(f)}),u.on("data",f=>{e.destroyed||e.write(f)}),e.resume(),u}function PYe(t,e){let{provision:r,logger:n,onCleanup:i}=e,o,s="ssl",a=!1;function c(){a||(a=!0,t.destroy(),o?.destroy(),i())}t.on("error",l=>{l.code!=="ECONNRESET"&&n("Client socket error:",l.message),c()}),t.on("data",l=>{if(s==="ssl"){if(l.length>=8&&l.readInt32BE(4)===wYe){t.write(RYe),s="startup";return}s="startup"}if(s==="startup"){if(l.length<8){t.end(rC("Invalid startup message")),c();return}if(l.readInt32BE(4)!==AYe){t.end(rC("Unsupported protocol version")),c();return}t.pause(),t.removeAllListeners("data"),CYe({clientSocket:t,provision:r,logger:n,cleanup:c}).then(d=>{o=d},d=>{n("Startup error:",d),c()})}})}function OYe(t){let e=new URL(t);return{host:e.hostname,port:Number(e.port)||5432,user:decodeURIComponent(e.username),password:decodeURIComponent(e.password),database:e.pathname.slice(1)||"postgres",ssl:e.searchParams.get("sslmode")==="require"?!0:void 0,options:e.searchParams.get("options")??void 0}}var Xpe=class{server;sockets=new Set;host;port;logger;provision;constructor(t){this.host=t.host??"127.0.0.1",this.port=t.port??0,this.logger=t.logger??(()=>{}),this.provision=t.provision}async start(){return new Promise((t,e)=>{let r=xYe.createServer(n=>{this.sockets.add(n),n.on("close",()=>{this.sockets.delete(n)}),PYe(n,{provision:this.provision,logger:this.logger,onCleanup:()=>{this.sockets.delete(n)}})});r.on("error",n=>{e(n)}),r.listen(this.port,this.host,()=>{this.server=r;let n=r.address(),i=`postgres://${this.host}:${String(n.port)}`;this.logger("Proxy listening on",i),t(i)})})}async stop(){for(let t of this.sockets)t.destroy();return this.sockets.clear(),new Promise(t=>{if(!this.server){t();return}this.server.close(()=>{this.server=void 0,t()})})}};var nC=ye("db_setup"),Qpe=async({siteId:t,isProd:e,alias:r,connectionString:n})=>await ft(qe(),"db-setup-stage",async i=>{i?.setAttributes({"db_setup.site_id":t,"db_setup.is_prod":e,...r&&{"db_setup.alias":r}});let o;if(e?o="production":r&&(o=r),K4.env.NETLIFY_DB_BRANCH=o,n)return i?.setAttributes({"db_setup.source":"config","db_setup.has_proxy":!1}),nC.log("Using database connection string provided by the API"),K4.env.NETLIFY_DB_URL=n,{connectionString:n,wasProvisioned:()=>!1};let s=!1,a=new Xpe({logger:(...l)=>nC.log("db-proxy:",...l),provision:async()=>(s=!0,nC.log("Provisioning database for site via API"),await a9(t),await NYe(t,e,r))}),c=await a.start();return i?.setAttributes({"db_setup.source":"proxy","db_setup.has_proxy":!0}),nC.log("Local DB proxy started",{connectionString:c}),K4.env.NETLIFY_DB_URL=c,{connectionString:c,proxy:a,wasProvisioned:()=>s}}),NYe=async(t,e,r)=>e||!r?(await i9(t)).connection_string:(await c9(t,r),(await s9(t,r)).connection_string);var kYe=({isHotFollowUp:t,enqueuedAt:e})=>t?e===void 0?[]:[["request",e]]:[["spawn",Number(process.env.NETLIFY_AGENT_RUNNER_SPAWN_AT_MS)],["enqueue",Number(process.env.NETLIFY_AGENT_RUNNER_ENQUEUED_AT_MS)]],ehe=(t,e,r,n)=>{for(let[i,o]of kYe(r))Number.isFinite(o)&&o>0&&o<=n&&t.timing(e,n-o,{from:i})},the=(t,e=Date.now(),r=fe)=>ehe(r,"startup.duration",t,e),rhe=(t,e=Date.now(),r=fe)=>ehe(r,"startup.time_to_first_output",t,e);function nhe(t){return["One or more AI functions use the legacy **v1** syntax (`exports.handler` / `module.exports.handler`):","",t.map(r=>`- ${r}`).join(`
|
|
542
542
|
`),"",'Netlify AI Gateway credentials (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY` and the matching `*_BASE_URL` variables) are injected ONLY into the modern v2/v3 function runtime. A v1 function builds and deploys successfully but throws "missing API key" at runtime \u2014 this will NOT appear as a build error.',"","Rewrite each listed function using **v2** syntax \u2014 `export default async (req: Request) => Response` \u2014 or **v3** object export (`satisfies NetlifyFunction`), preserving its existing behavior and route. Do not set your own API keys; rely on the injected gateway credentials. See the `netlify-ai-gateway` skill for examples."].join(`
|
|
543
|
-
`)}var qh=ye("usage_tracker"),MYe=4e3,DYe=(t,e,r)=>t===!0||r!=null&&e!=null&&e>=r,LYe=(t,e,r)=>e!=null&&e>0&&r!=null&&t!=null&&t>=r*e,iC=(t,e,r,{softLimitRatio:n,onSoftLimit:i}={})=>{let o=!1,s=!1,a=!1,c=!1,l,u,d,f=i!=null&&n!=null&&r!=null,p=async()=>{try{let T=await n9(t,e);qh.log("Usage update response",{usage:T?.usage});let x=T?.usage?.total_credits_cost;x!=null&&(l=x);let v=DYe(T?.credit_limit_exceeded,x,r);if(v&&(qh.log("Credit limit exceeded",{totalCreditsCost:x,enforcedCreditsRemaining:r}),a||(u=Date.now(),d=x??l??0),a=!0),f&&!c&&!v&&LYe(x,r,n)){c=!0,qh.log("Soft credit limit reached",{totalCreditsCost:x,enforcedCreditsRemaining:r,softLimitRatio:n});try{i()}catch(N){qh.warn("onSoftLimit callback threw",{error:N?.message||N})}}}catch(T){qh.warn("Failed to update usage",{error:T?.message||T})}},h=Bx(p,MYe);return{onAgentOutput:()=>{if(a)throw new vi("AI credit usage exceeded enforced limit.",503,"Credit limit reached. Check credit limits to continue using Agent Runners.",!0);s||(o=!0,h())},stop:async()=>{s||(s=!0,o&&(h.cancel(),qh.log("Sending final usage update"),await p(),u!==void 0&&(fe.timing("credit_limit.overage_duration",Date.now()-u),fe.distribution("credit_limit.overage_credits",Math.max(0,(l??d??0)-(d??0))))))},getCreditsCost:()=>l}};var oC=ye("credit_wrapup"),ihe=(t,e)=>e&&t.enforcedAICreditsRemaining!=null&&t.mode==="create",ohe=async({runnerResult:t,interruptedSessionId:e,originalBudget:r,costAtSoftLimit:n,cliPath:i,config:o,context:s,runner:a,aiGateway:c,cwd:l,persistSteps:u,withStageTimer:d,answerFold:f})=>{let p=Math.max(0,r-n),h=Math.max(1,Math.min(p,r*.15)),m=n+h,y=new AbortController,S=!1,T=iC(o.id,o.sessionId,m),x=Object.assign(async v=>{try{T.onAgentOutput()}catch(N){ls(N)&&!S&&(S=!0,oC.log("Wrap-up turn hit its hard budget limit \u2014 stopping wrap-up",{wrapUpBudget:h,wrapUpHardLimit:m}),fe.inc("session.credit_wrapup_aborted",1),y.abort())}return u(v)},{flush:u.flush.bind(u)});oC.log("Running credit wrap-up inference turn",{wrapUpBudget:h,wrapUpHardLimit:m,costAtSoftLimit:n,remainingAtSoftLimit:p});try{await u({steps:[{category:Y.Environment,message:"\u26A0\uFE0F You are running low on credits \u2014 wrapping up your project now."}],duration:0})}catch{}try{let{runnerResult:v}=await d("inference-credit-wrapup",()=>Do({cliPath:i,config:o,context:s,runner:a,persistSteps:x,aiGateway:c,cwd:l,contextPrefix:IM,priorAgentSessionId:e,resumeSession:!0,answerFold:f,effortOverride:"low",abortSignal:y.signal}));return S&&oC.log("Wrap-up turn was aborted due to budget limit"),{...v,steps:[...t.steps||[],...v.steps||[]],duration:(t.duration||0)+(v.duration||0)}}catch(v){return oC.warn("Credit wrap-up turn failed \u2014 proceeding with pre-wrap-up result",{error:v?.message||v}),fe.inc("session.credit_wrapup_failed",1),t}finally{await T.stop()}};import $Ye from"process";var Z4=ye("shutdown"),she=!1,UYe,FYe=async t=>{if(she)return;if(she=!0,Z4.info("Shutting down...",{signal:t}),wee(),fe.distribution("session.hot_followups",Ase()),!wse()){let r=Date.now(),n=Rse(),i=Ise();n!==void 0&&fe.timing("session.last_linger",r-n),i!==void 0&&fe.timing("session.total_linger",r-i)}let e=UYe?.close().catch(r=>{Z4.error("Error closing server during graceful shutdown",r)});await Pse(),await e,await B5(),Z4.info("Shutdown complete"),$Ye.exit(0)};var ahe=t=>{FYe(t)};var lhe=4e3,BYe=3e4,che=ye("credit_limit_preservation"),uhe=async(t,e)=>{let r=null,n={},i=[];if(e){fh(e);let o=zs(t.runner);i.push(Promise.all([Au({runnerId:t.id,sessionId:t.sessionId,archive:o,nativeSessionId:e}).then(s=>{r=s}),Oh({archive:o,cache:t.cache,nativeSessionId:e})]).catch(s=>{che.warn("Failed to preserve native session on credit-limit shutdown",{error:s?.message||s})}))}if(t.mode!=="ask"&&i.push(zx({config:t}).then(o=>o.hasChanges?qG({config:t,diff:o.diff,diffBinary:o.diffBinary,resultDiff:o.resultDiff,resultDiffBinary:o.resultDiffBinary}):{}).then(o=>{n=o}).catch(o=>{che.warn("Failed to preserve working-tree diff on credit-limit shutdown",{error:o?.message||o})})),i.length>0){let o=!1;await Promise.race([Promise.all(i).then(()=>{o=!0}),new Promise(s=>{setTimeout(s,BYe).unref()})]),o||fe.inc("credit_preservation.timed_out",1)}return{nativeSessionS3Key:r,diffFields:n}};var qYe=GYe(import.meta.url),SS=qYe("../package.json"),wt=ye("pipeline_index"),Vh=3,VYe=["codex","gemini"],
|
|
543
|
+
`)}var qh=ye("usage_tracker"),MYe=4e3,DYe=(t,e,r)=>t===!0||r!=null&&e!=null&&e>=r,LYe=(t,e,r)=>e!=null&&e>0&&r!=null&&t!=null&&t>=r*e,iC=(t,e,r,{softLimitRatio:n,onSoftLimit:i}={})=>{let o=!1,s=!1,a=!1,c=!1,l,u,d,f=i!=null&&n!=null&&r!=null,p=async()=>{try{let T=await n9(t,e);qh.log("Usage update response",{usage:T?.usage});let x=T?.usage?.total_credits_cost;x!=null&&(l=x);let v=DYe(T?.credit_limit_exceeded,x,r);if(v&&(qh.log("Credit limit exceeded",{totalCreditsCost:x,enforcedCreditsRemaining:r}),a||(u=Date.now(),d=x??l??0),a=!0),f&&!c&&!v&&LYe(x,r,n)){c=!0,qh.log("Soft credit limit reached",{totalCreditsCost:x,enforcedCreditsRemaining:r,softLimitRatio:n});try{i()}catch(N){qh.warn("onSoftLimit callback threw",{error:N?.message||N})}}}catch(T){qh.warn("Failed to update usage",{error:T?.message||T})}},h=Bx(p,MYe);return{onAgentOutput:()=>{if(a)throw new vi("AI credit usage exceeded enforced limit.",503,"Credit limit reached. Check credit limits to continue using Agent Runners.",!0);s||(o=!0,h())},stop:async()=>{s||(s=!0,o&&(h.cancel(),qh.log("Sending final usage update"),await p(),u!==void 0&&(fe.timing("credit_limit.overage_duration",Date.now()-u),fe.distribution("credit_limit.overage_credits",Math.max(0,(l??d??0)-(d??0))))))},getCreditsCost:()=>l}};var oC=ye("credit_wrapup"),ihe=(t,e)=>e&&t.enforcedAICreditsRemaining!=null&&t.mode==="create",ohe=async({runnerResult:t,interruptedSessionId:e,originalBudget:r,costAtSoftLimit:n,cliPath:i,config:o,context:s,runner:a,aiGateway:c,cwd:l,persistSteps:u,withStageTimer:d,answerFold:f})=>{let p=Math.max(0,r-n),h=Math.max(1,Math.min(p,r*.15)),m=n+h,y=new AbortController,S=!1,T=iC(o.id,o.sessionId,m),x=Object.assign(async v=>{try{T.onAgentOutput()}catch(N){ls(N)&&!S&&(S=!0,oC.log("Wrap-up turn hit its hard budget limit \u2014 stopping wrap-up",{wrapUpBudget:h,wrapUpHardLimit:m}),fe.inc("session.credit_wrapup_aborted",1),y.abort())}return u(v)},{flush:u.flush.bind(u)});oC.log("Running credit wrap-up inference turn",{wrapUpBudget:h,wrapUpHardLimit:m,costAtSoftLimit:n,remainingAtSoftLimit:p});try{await u({steps:[{category:Y.Environment,message:"\u26A0\uFE0F You are running low on credits \u2014 wrapping up your project now."}],duration:0})}catch{}try{let{runnerResult:v}=await d("inference-credit-wrapup",()=>Do({cliPath:i,config:o,context:s,runner:a,persistSteps:x,aiGateway:c,cwd:l,contextPrefix:IM,priorAgentSessionId:e,resumeSession:!0,answerFold:f,effortOverride:"low",abortSignal:y.signal}));return S&&oC.log("Wrap-up turn was aborted due to budget limit"),{...v,steps:[...t.steps||[],...v.steps||[]],duration:(t.duration||0)+(v.duration||0)}}catch(v){return oC.warn("Credit wrap-up turn failed \u2014 proceeding with pre-wrap-up result",{error:v?.message||v}),fe.inc("session.credit_wrapup_failed",1),t}finally{await T.stop()}};import $Ye from"process";var Z4=ye("shutdown"),she=!1,UYe,FYe=async t=>{if(she)return;if(she=!0,Z4.info("Shutting down...",{signal:t}),wee(),fe.distribution("session.hot_followups",Ase()),!wse()){let r=Date.now(),n=Rse(),i=Ise();n!==void 0&&fe.timing("session.last_linger",r-n),i!==void 0&&fe.timing("session.total_linger",r-i)}let e=UYe?.close().catch(r=>{Z4.error("Error closing server during graceful shutdown",r)});await Pse(),await e,await B5(),Z4.info("Shutdown complete"),$Ye.exit(0)};var ahe=t=>{FYe(t)};var lhe=4e3,BYe=3e4,che=ye("credit_limit_preservation"),uhe=async(t,e)=>{let r=null,n={},i=[];if(e){fh(e);let o=zs(t.runner);i.push(Promise.all([Au({runnerId:t.id,sessionId:t.sessionId,archive:o,nativeSessionId:e}).then(s=>{r=s}),Oh({archive:o,cache:t.cache,nativeSessionId:e})]).catch(s=>{che.warn("Failed to preserve native session on credit-limit shutdown",{error:s?.message||s})}))}if(t.mode!=="ask"&&i.push(zx({config:t}).then(o=>o.hasChanges?qG({config:t,diff:o.diff,diffBinary:o.diffBinary,resultDiff:o.resultDiff,resultDiffBinary:o.resultDiffBinary}):{}).then(o=>{n=o}).catch(o=>{che.warn("Failed to preserve working-tree diff on credit-limit shutdown",{error:o?.message||o})})),i.length>0){let o=!1;await Promise.race([Promise.all(i).then(()=>{o=!0}),new Promise(s=>{setTimeout(s,BYe).unref()})]),o||fe.inc("credit_preservation.timed_out",1)}return{nativeSessionS3Key:r,diffFields:n}};var qYe=GYe(import.meta.url),SS=qYe("../package.json"),wt=ye("pipeline_index"),Vh=3,VYe=["codex","gemini"],hje=async({config:t,apiToken:e,cliPath:r="netlify",cwd:n,filter:i,isHotFollowUp:o=!1,enqueuedAt:s,tracing:a={}})=>{let c,l,u,d=Date.now(),f="success",p=!1,{withStageTimer:h}=Aee(gs.timeUnits.hours(4)),m=await j5(SS.version,t.id,a);wt.log(`Agent runner orchestrator v${SS.version}`,{featureFlags:We().raw,metrics:Y5()}),xM({agent:t.runner,mode:t.mode,is_follow_up:t.sessionHistoryContext.length>0,version:SS.version,fast_init:t.fastInit}),the({isHotFollowUp:o,enqueuedAt:s});try{await qc(qe(),"run-pipeline",{},m,async y=>{await s2(o2(),t.runner),y?.setAttributes({"gen_ai.capability.name":t.mode,"session.id":t.sessionId,...process.env.NETLIFY_DEV_SERVER_ID?{"dev_server.id":process.env.NETLIFY_DEV_SERVER_ID}:{}});let{aiGateway:S,context:T,persistSteps:x,runner:v,sha:N}=await h("init",()=>Sse({config:t,apiToken:e,cliPath:r,cwd:n,filter:i,runnerVersion:SS.version}),gs.timeUnits.minutes(10)),R=v.runner;We().idleTimeoutEnabled||(c=v.clean);let U=ihe(t,We().creditWrapUpEnabled),C=new AbortController,D=!1,j=0,_;l=iC(t.id,t.sessionId,t.enforcedAICreditsRemaining,U?{softLimitRatio:.7,onSoftLimit:()=>{if(!D){if(!_){wt.warn("Soft credit limit reached but no session id yet \u2014 skipping wrap-up interrupt"),fe.inc("session.credit_wrapup_skipped_no_session",1);return}D=!0,j=l?.getCreditsCost()??0,wt.log("Soft credit limit reached \u2014 interrupting agent to wrap up",{costAtSoftLimit:j}),fe.inc("session.credit_wrapup_triggered",1),C.abort()}}}:void 0);let ae=yw(t.mode),I;t.deployAlias&&t.deployAlias.length>0?I=t.deployAlias:(t.deployAlias!==void 0&&!ae&&wt.warn("Received empty deploy alias for a non-prod deploy, falling back to local computation"),I=Lee(t.id,process.env.SITE_NAME,ae));let g,E=!1,w=Object.assign(async ge=>{try{l?.onAgentOutput()}catch(Pe){ls(Pe)?g??=Pe:wt.warn("Unexpected error in onAgentOutput",{error:Pe?.message||Pe});return}return!E&&ge.steps?.some(Pe=>Pe.category!==Y.Environment&&Pe.category!==Y.UserMessage)&&(E=!0,rhe({isHotFollowUp:o,enqueuedAt:s})),x(ge)},{flush:x.flush.bind(x)});if(t.sha=N,t.mode==="redeploy"){let ge=await h("deploy",()=>LI({cliPath:r,config:t,context:T,result:"Redeploy completed",filter:i,isRetry:!1,deploySubdomain:I}));ge.deployError&&(wt.warn(`Redeploy deploy failed: ${ge.deployError}`),fe.inc("deploy.failed",1,{attempt:1})),wM({previewDeployed:!!ge.previewInfo,hadFailedAttempts:!!ge.deployError});let{diff:Pe,resultDiff:Lt,previewInfo:Ge,diffBinary:ot,resultDiffBinary:Cu,hasNetlifyForm:dhe,hasNetlifyIdentity:fhe}=ge;await l?.stop(),await h("cleanup",()=>GG({config:t,diff:Pe,result:"Redeploy completed",duration:0,resultDiff:Lt,diffBinary:ot,resultDiffBinary:Cu,previewInfo:Ge,isProdDeploy:ae,hasNetlifyForm:dhe,hasNetlifyIdentity:fhe,nativeSessionArchive:zs(t.runner)}),gs.timeUnits.minutes(10),{interruptible:!1}),process.env.NETLIFY_LOCAL_MODE||(await c?.(),await u?.stop(),await _L());return}let W=Mse(),G;t.mode==="create"&&(G=(await h("create",()=>Fie({config:t,cwd:n}))).additionalContext),process.env.EXPERIMENTAL_NETLIFY_DB_ENABLED="1";let ce,Te;if(!process.env.NETLIFY_LOCAL_MODE&&t.siteId){let ge=await h("db-setup",()=>Qpe({siteId:t.siteId,isProd:ae,alias:I,connectionString:t.dbConnectionString}),gs.timeUnits.minutes(10));if(u=ge.proxy,n)if(ge.proxy)G=[rfe(),G].filter(Boolean).join(`
|
|
544
544
|
|
|
545
545
|
`);else try{let Pe=await UI({cliPath:r,cwd:n});ce=new Set(Pe.applied.map(Ge=>Ge.name)),Te=Pe.migrationsPath;let Lt=nfe(Pe);Lt&&(G=[Lt,G].filter(Boolean).join(`
|
|
546
546
|
|
|
547
|
-
`))}catch(Pe){wt.warn("Skipping migration context injection \u2014 failed to build state block",{error:Pe})}}let we=await tfe(n??process.cwd(),Te),Ce=await h("inference",async()=>{try{return await Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,additionalContext:G,cwd:n,answerFold:W,abortSignal:U?C.signal:void 0,onSessionId:U?ge=>{_=ge}:void 0})}catch(ge){if(!(ge instanceof $d)||t.mode!=="rebase"&&t.mode!=="conflict_resolution")throw ge;for(let Pe of VYe){if(g&&ls(g))throw g;if(Pe===t.runner)continue;let Lt=uh[Pe];if(Lt){wt.log(`Primary runner ${t.runner} failed in ${t.mode} mode, falling back to ${Pe}`),xM({agent:Pe,mode:t.mode,version:SS.version}),await
|
|
547
|
+
`))}catch(Pe){wt.warn("Skipping migration context injection \u2014 failed to build state block",{error:Pe})}}let we=await tfe(n??process.cwd(),Te),Ce=await h("inference",async()=>{try{return await Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,additionalContext:G,cwd:n,answerFold:W,abortSignal:U?C.signal:void 0,onSessionId:U?ge=>{_=ge}:void 0})}catch(ge){if(!(ge instanceof $d)||t.mode!=="rebase"&&t.mode!=="conflict_resolution")throw ge;for(let Pe of VYe){if(g&&ls(g))throw g;if(Pe===t.runner)continue;let Lt=uh[Pe];if(Lt){wt.log(`Primary runner ${t.runner} failed in ${t.mode} mode, falling back to ${Pe}`),xM({agent:Pe,mode:t.mode,version:SS.version}),await s2(o2(),Pe);try{let Ge=await Do({cliPath:r,config:{...t,runner:Pe},context:T,runner:Lt.runner,persistSteps:w,aiGateway:S,additionalContext:G,cwd:n,answerFold:W,abortSignal:U?C.signal:void 0});return t.runner=Pe,R=Lt.runner,We().idleTimeoutEnabled||(c=Lt.clean),Ge}catch(Ge){if(ls(Ge))throw Ge;wt.error(`Fallback runner ${Pe} also failed`,{error:String(Ge)})}}}throw ge}}),V=Ce.runnerResult;p=Ce.nativeResume??!1;let De=V.agentSessionId;if(U&&D&&V.aborted&&De&&!g&&(V=await ohe({runnerResult:V,interruptedSessionId:De,originalBudget:t.enforcedAICreditsRemaining,costAtSoftLimit:j,cliPath:r,config:t,context:T,runner:R,aiGateway:S,cwd:n,persistSteps:x,withStageTimer:h,answerFold:W})),t.mode==="create")try{let ge=JSON.parse(jYe(zYe.join(n??process.cwd(),".netlify","scaffold-result.json"),"utf8"));await qc(qe(),"create-scaffold-telemetry",Pe=>{Pe?.setAttributes({"create.template":ge.template,"create.packageManager":ge.packageManager})})}catch{await qc(qe(),"create-scaffold-telemetry",ge=>{ge?.setAttributes({"create.template":"none","create.packageManager":"none"})})}if(g)throw Object.assign(g,{agentSessionId:V.agentSessionId}),g;if(V.pendingInteraction){let ge=V.agentSessionId;ge&&fh(ge);let Pe=await Au({runnerId:t.id,sessionId:t.sessionId,archive:zs(t.runner)}),Lt;try{Lt=await Nse(t,V.pendingInteraction,{nativeSessionId:ge,nativeSessionS3Key:Pe??void 0})}catch(Ge){throw fe.inc("inference.pause_persist_failed",1),Ge}wt.log("Agent paused on a question; session set to await_input",{sessionId:t.sessionId,refId:Lt,questionCount:V.pendingInteraction.questions.length}),fe.inc("inference.pending_question",1),fe.distribution("inference.questions_per_ask",V.pendingInteraction.questions.length),await l?.stop(),process.env.NETLIFY_LOCAL_MODE||await u?.stop();return}let be=await $I({cwd:n,migrationsPath:Te,snapshot:we,applied:ce,config:t,aiGateway:S});if(be.error){wt.log("Migration generation failed, running inference to fix the issue");let{runnerResult:ge}=await h("inference-migration-fix",()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:[`Running \`drizzle-kit generate\` to generate database migrations failed with the following error:
|
|
548
548
|
|
|
549
549
|
${be.error}
|
|
550
550
|
|
|
551
|
-
Please fix the issue and do NOT run \`drizzle-kit generate\` yourself \u2014 it will be run automatically after you're done.`],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...ge,steps:[...V.steps||[],...ge.steps||[]],duration:(V.duration||0)+(ge.duration||0)},await $I({cwd:n,migrationsPath:Te,snapshot:we,applied:ce,config:t,aiGateway:S})}if(n&&!be.skipped){let ge=await h("db-migrations-verify",()=>afe({cliPath:r,cwd:n}));if(ge.error){wt.log("Migration drift detected, running inference to fix");let{runnerResult:Pe}=await h("inference-migration-drift-fix",()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:[ge.error],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...Pe,steps:[...V.steps||[],...Pe.steps||[]],duration:(V.duration||0)+(Pe.duration||0)}}}if(We().aiFnV1GuardrailEnabled&&n&&t.mode!=="ask")try{let ge=await bM(n);if(ge.v1>0){wt.log(`Detected ${ge.v1} v1 AI function(s), running inference to fix`);let{runnerResult:Pe}=await h("inference-ai-fn-v1-fix",()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:[nhe(ge.v1Files)],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...Pe,steps:[...V.steps||[],...Pe.steps||[]],duration:(V.duration||0)+(Pe.duration||0)}}}catch(ge){if(ls(ge))throw ge;wt.warn("ai_fn_v1_guardrail failed",{err:ge})}let ee=await h("deploy",()=>LI({cliPath:r,config:t,context:T,result:V.result,filter:i,isRetry:!1,deploySubdomain:I})),ie=ee.hasChanges?ee:void 0,Re=V;ee.deployError&&fe.inc("deploy.failed",1,{attempt:1});let te=[],Ae;if(ee.hasChanges&&ee.deployError){te.push(q5(ee.deployError));let ge=1,Pe=!1;for(;ge<=Vh&&!ee.previewInfo&&!Pe;)wt.log(`Deploy attempt had errors. Retrying. ${ge}/${Vh}`),await qc(qe(),"deploy-stage",async Lt=>{Lt?.setAttributes({"stage.attempt":ge});let Ge;try{Ge=(await h(`inference-retry-${ge}`,()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:te,priorAgentSessionId:V.agentSessionId,answerFold:W}))).runnerResult}catch(ot){if(ls(ot))throw ot;wt.warn(`Inference retry ${ge} failed, stopping deploy retries:`,ot),Pe=!0;return}if(g)throw Object.assign(g,{agentSessionId:Ge.agentSessionId??V.agentSessionId}),g;Re={...Ge,steps:[...Re.steps||[],...Ge.steps||[]],duration:(Re.duration||0)+(Ge.duration||0)},await $I({cwd:n,migrationsPath:Te,snapshot:we,applied:ce,config:t,aiGateway:S}),ee=await h(`deploy-retry-${ge}`,()=>LI({cliPath:r,config:t,context:T,result:Ge.result,filter:i,isRetry:!0,deploySubdomain:I})),ee.hasChanges&&(ie=ee),ee.deployError&&(fe.inc("deploy.failed",1,{attempt:ge+1}),te.push(ee.deployError)),ge++});ge>Vh&&!ee.previewInfo&&(fe.inc("deploy.retries_exhausted",1),t.mode==="create"?(console.warn(`Deploy still failing after ${Vh} retries, failing the create run`),Ae=new Error(`Deploy failed after ${Vh} retries`)):console.warn(`Deploy still failing after ${Vh} retries, completing run without a preview`))}let K=ee.previewInfo||ee.hasChanges?ee:ie??ee,{diff:M,resultDiff:k,previewInfo:F,diffBinary:A,resultDiffBinary:J,hasNetlifyForm:ne,hasNetlifyIdentity:xe}=K;K.hasChanges&&wM({previewDeployed:!!K.previewInfo,hadFailedAttempts:te.length>0}),await l?.stop();let it=Re.agentSessionId??V.agentSessionId;if(it&&fh(it),await h("cleanup",()=>GG({config:t,diff:M,result:Re.result,duration:Re.duration,resultDiff:k,diffBinary:A,resultDiffBinary:J,previewInfo:F,isProdDeploy:ae,hasNetlifyForm:ne,hasNetlifyIdentity:xe,nativeSessionArchive:zs(t.runner),nativeSessionId:it}),gs.timeUnits.minutes(10),{interruptible:!1}),Ae)throw Ae;try{let ge=await bM(n??process.cwd());ge.aiTotal>0&&y?.setAttributes({"agent.fn_ai_total":ge.aiTotal,"agent.fn_ai_v1":ge.v1,"agent.fn_ai_v2":ge.v2,"agent.fn_ai_v3":ge.v3,"agent.fn_ai_unknown":ge.unknown})}catch{}if(!process.env.NETLIFY_LOCAL_MODE&&(await c?.(),await u?.stop(),await _L(),t.mode==="ask")){let ge=await zee();ge.length>0&&(wt.warn(`Removed ${ge.length} leftover untracked change(s) after ask run`,{removed:ge}),fe.inc("ask_mode.leaked_untracked_files",ge.length))}let Nt=t.siteId?await o9(t.siteId):!1;typeof Nt=="boolean"&&y?.setAttributes({"actual.has_db":Nt}),wt.info("agent_storage_outcome",{sessionId:t.sessionId,runnerId:t.id,siteId:t.siteId,accountId:t.accountId,runner:t.runner,has_db:Nt??"unknown"});let At=y?.spanContext();At&&await Hr(t.id,t.sessionId,{metadata:{storage_outcome:{...typeof Nt=="boolean"?{has_db:Nt}:{},trace_id:At.traceId,span_id:At.spanId}}}).catch(ge=>wt.warn("Failed to persist storage_outcome",{error:ge?.message}))})}catch(y){if(ls(y)){f="gracefulError",wt.info("Agent run terminated gracefully",{statusCode:y.statusCode,reason:y.message}),await l?.stop();let R=y?.agentSessionId,U=y.isCreditLimitExceeded&&!!R,{nativeSessionS3Key:C,diffFields:D}=y.isCreditLimitExceeded?await uhe(t,R):{nativeSessionS3Key:null,diffFields:{}};await c?.(),await u?.stop();try{await Hr(t.id,t.sessionId,{result:y.userMessage,state:y.isCreditLimitExceeded?"cancelled":"error",...y.isCreditLimitExceeded&&{credit_limit_exceeded:!0},...U?{native_session_id:R}:{},...C?{native_session_s3_key:C}:{},...D})}catch{wt.info("Could not update session (site may have been deleted)")}y.isCreditLimitExceeded&&ahe("credit_limit_cancelled");return}f=ho()?"interrupted":"error",wt.error("Got error while running pipeline",y),await l?.stop();let S=y?.agentSessionId,T=ho()&&!!S,x=null;if(T){fh(S);let R=zs(t.runner);await Promise.race([Promise.all([Au({runnerId:t.id,sessionId:t.sessionId,archive:R,nativeSessionId:S}).then(U=>{x=U}),Oh({archive:R,cache:t.cache,nativeSessionId:S})]),new Promise(U=>{setTimeout(U,lhe).unref()})])}await c?.(),await u?.stop();let v=y instanceof Error&&y.message,N=v?rR(v):"Encountered error when running agent";throw await Hr(t.id,t.sessionId,{result:N,state:"error",...T?{native_session_id:S}:{},...x?{native_session_s3_key:x}:{}}),y}finally{fe.timing("session.duration",Date.now()-d,{hot_follow_up:o,outcome:f,native_resume:p});let y=l?.getCreditsCost();y!=null&&fe.distribution("session.credits_cost",y,{outcome:f,native_resume:p})}};export{
|
|
551
|
+
Please fix the issue and do NOT run \`drizzle-kit generate\` yourself \u2014 it will be run automatically after you're done.`],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...ge,steps:[...V.steps||[],...ge.steps||[]],duration:(V.duration||0)+(ge.duration||0)},await $I({cwd:n,migrationsPath:Te,snapshot:we,applied:ce,config:t,aiGateway:S})}if(n&&!be.skipped){let ge=await h("db-migrations-verify",()=>afe({cliPath:r,cwd:n}));if(ge.error){wt.log("Migration drift detected, running inference to fix");let{runnerResult:Pe}=await h("inference-migration-drift-fix",()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:[ge.error],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...Pe,steps:[...V.steps||[],...Pe.steps||[]],duration:(V.duration||0)+(Pe.duration||0)}}}if(We().aiFnV1GuardrailEnabled&&n&&t.mode!=="ask")try{let ge=await bM(n);if(ge.v1>0){wt.log(`Detected ${ge.v1} v1 AI function(s), running inference to fix`);let{runnerResult:Pe}=await h("inference-ai-fn-v1-fix",()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:[nhe(ge.v1Files)],priorAgentSessionId:V.agentSessionId,answerFold:W}));V={...Pe,steps:[...V.steps||[],...Pe.steps||[]],duration:(V.duration||0)+(Pe.duration||0)}}}catch(ge){if(ls(ge))throw ge;wt.warn("ai_fn_v1_guardrail failed",{err:ge})}let ee=await h("deploy",()=>LI({cliPath:r,config:t,context:T,result:V.result,filter:i,isRetry:!1,deploySubdomain:I})),ie=ee.hasChanges?ee:void 0,Re=V;ee.deployError&&fe.inc("deploy.failed",1,{attempt:1});let te=[],Ae;if(ee.hasChanges&&ee.deployError){te.push(q5(ee.deployError));let ge=1,Pe=!1;for(;ge<=Vh&&!ee.previewInfo&&!Pe;)wt.log(`Deploy attempt had errors. Retrying. ${ge}/${Vh}`),await qc(qe(),"deploy-stage",async Lt=>{Lt?.setAttributes({"stage.attempt":ge});let Ge;try{Ge=(await h(`inference-retry-${ge}`,()=>Do({cliPath:r,config:t,context:T,runner:R,persistSteps:w,aiGateway:S,buildErrors:te,priorAgentSessionId:V.agentSessionId,answerFold:W}))).runnerResult}catch(ot){if(ls(ot))throw ot;wt.warn(`Inference retry ${ge} failed, stopping deploy retries:`,ot),Pe=!0;return}if(g)throw Object.assign(g,{agentSessionId:Ge.agentSessionId??V.agentSessionId}),g;Re={...Ge,steps:[...Re.steps||[],...Ge.steps||[]],duration:(Re.duration||0)+(Ge.duration||0)},await $I({cwd:n,migrationsPath:Te,snapshot:we,applied:ce,config:t,aiGateway:S}),ee=await h(`deploy-retry-${ge}`,()=>LI({cliPath:r,config:t,context:T,result:Ge.result,filter:i,isRetry:!0,deploySubdomain:I})),ee.hasChanges&&(ie=ee),ee.deployError&&(fe.inc("deploy.failed",1,{attempt:ge+1}),te.push(ee.deployError)),ge++});ge>Vh&&!ee.previewInfo&&(fe.inc("deploy.retries_exhausted",1),t.mode==="create"?(console.warn(`Deploy still failing after ${Vh} retries, failing the create run`),Ae=new Error(`Deploy failed after ${Vh} retries`)):console.warn(`Deploy still failing after ${Vh} retries, completing run without a preview`))}let K=ee.previewInfo||ee.hasChanges?ee:ie??ee,{diff:M,resultDiff:k,previewInfo:F,diffBinary:A,resultDiffBinary:J,hasNetlifyForm:ne,hasNetlifyIdentity:xe}=K;K.hasChanges&&wM({previewDeployed:!!K.previewInfo,hadFailedAttempts:te.length>0}),await l?.stop();let it=Re.agentSessionId??V.agentSessionId;if(it&&fh(it),await h("cleanup",()=>GG({config:t,diff:M,result:Re.result,duration:Re.duration,resultDiff:k,diffBinary:A,resultDiffBinary:J,previewInfo:F,isProdDeploy:ae,hasNetlifyForm:ne,hasNetlifyIdentity:xe,nativeSessionArchive:zs(t.runner),nativeSessionId:it}),gs.timeUnits.minutes(10),{interruptible:!1}),Ae)throw Ae;try{let ge=await bM(n??process.cwd());ge.aiTotal>0&&y?.setAttributes({"agent.fn_ai_total":ge.aiTotal,"agent.fn_ai_v1":ge.v1,"agent.fn_ai_v2":ge.v2,"agent.fn_ai_v3":ge.v3,"agent.fn_ai_unknown":ge.unknown})}catch{}if(!process.env.NETLIFY_LOCAL_MODE&&(await c?.(),await u?.stop(),await _L(),t.mode==="ask")){let ge=await zee();ge.length>0&&(wt.warn(`Removed ${ge.length} leftover untracked change(s) after ask run`,{removed:ge}),fe.inc("ask_mode.leaked_untracked_files",ge.length))}let Nt=t.siteId?await o9(t.siteId):!1;typeof Nt=="boolean"&&y?.setAttributes({"actual.has_db":Nt}),wt.info("agent_storage_outcome",{sessionId:t.sessionId,runnerId:t.id,siteId:t.siteId,accountId:t.accountId,runner:t.runner,has_db:Nt??"unknown"});let At=y?.spanContext();At&&await Hr(t.id,t.sessionId,{metadata:{storage_outcome:{...typeof Nt=="boolean"?{has_db:Nt}:{},trace_id:At.traceId,span_id:At.spanId}}}).catch(ge=>wt.warn("Failed to persist storage_outcome",{error:ge?.message}))})}catch(y){if(ls(y)){f="gracefulError",wt.info("Agent run terminated gracefully",{statusCode:y.statusCode,reason:y.message}),await l?.stop();let R=y?.agentSessionId,U=y.isCreditLimitExceeded&&!!R,{nativeSessionS3Key:C,diffFields:D}=y.isCreditLimitExceeded?await uhe(t,R):{nativeSessionS3Key:null,diffFields:{}};await c?.(),await u?.stop();try{await Hr(t.id,t.sessionId,{result:y.userMessage,state:y.isCreditLimitExceeded?"cancelled":"error",...y.isCreditLimitExceeded&&{credit_limit_exceeded:!0},...U?{native_session_id:R}:{},...C?{native_session_s3_key:C}:{},...D})}catch{wt.info("Could not update session (site may have been deleted)")}y.isCreditLimitExceeded&&ahe("credit_limit_cancelled");return}f=ho()?"interrupted":"error",wt.error("Got error while running pipeline",y),await l?.stop();let S=y?.agentSessionId,T=ho()&&!!S,x=null;if(T){fh(S);let R=zs(t.runner);await Promise.race([Promise.all([Au({runnerId:t.id,sessionId:t.sessionId,archive:R,nativeSessionId:S}).then(U=>{x=U}),Oh({archive:R,cache:t.cache,nativeSessionId:S})]),new Promise(U=>{setTimeout(U,lhe).unref()})])}await c?.(),await u?.stop();let v=y instanceof Error&&y.message,N=v?rR(v):"Encountered error when running agent";throw await Hr(t.id,t.sessionId,{result:N,state:"error",...T?{native_session_id:S}:{},...x?{native_session_s3_key:x}:{}}),y}finally{fe.timing("session.duration",Date.now()-d,{hot_follow_up:o,outcome:f,native_resume:p});let y=l?.getCreditsCost();y!=null&&fe.distribution("session.credits_cost",y,{outcome:f,native_resume:p})}};export{hje as runPipeline};
|
|
552
552
|
/*! Bundled license information:
|
|
553
553
|
|
|
554
554
|
long/umd/index.js:
|