@sourcegraph/amp 0.0.1764165115-gcd064d → 0.0.1764172241-gaca8cf

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.
Files changed (2) hide show
  1. package/dist/main.js +11 -12
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -45,7 +45,7 @@ ${q}`.trim()}_serializeSingularDataPoint(J,Q,Y){let X="";J=EG1(J,Q);let{value:G,
45
45
  ${X}
46
46
  ${G}
47
47
  `}}SW0.PrometheusSerializer=jW0});var xW0=v((kW0)=>{Object.defineProperty(kW0,"__esModule",{value:!0});kW0.PrometheusExporter=void 0;var h_=b6(),e74=V8(),TG1=LD(),J24=k1("http"),Q24=PG1(),Y24=k1("url");class _W extends TG1.MetricReader{static DEFAULT_OPTIONS={host:void 0,port:9464,endpoint:"/metrics",prefix:"",appendTimestamp:!1,withResourceConstantLabels:void 0,withoutTargetInfo:!1};_host;_port;_baseUrl;_endpoint;_server;_prefix;_appendTimestamp;_serializer;_startServerPromise;constructor(J={},Q=()=>{}){super({aggregationSelector:(G)=>{return{type:TG1.AggregationType.DEFAULT}},aggregationTemporalitySelector:(G)=>TG1.AggregationTemporality.CUMULATIVE,metricProducers:J.metricProducers});this._host=J.host||process.env.OTEL_EXPORTER_PROMETHEUS_HOST||_W.DEFAULT_OPTIONS.host,this._port=J.port||Number(process.env.OTEL_EXPORTER_PROMETHEUS_PORT)||_W.DEFAULT_OPTIONS.port,this._prefix=J.prefix||_W.DEFAULT_OPTIONS.prefix,this._appendTimestamp=typeof J.appendTimestamp==="boolean"?J.appendTimestamp:_W.DEFAULT_OPTIONS.appendTimestamp;let Y=J.withResourceConstantLabels||_W.DEFAULT_OPTIONS.withResourceConstantLabels,X=J.withoutTargetInfo||_W.DEFAULT_OPTIONS.withoutTargetInfo;if(this._server=(0,J24.createServer)(this._requestHandler).unref(),this._serializer=new Q24.PrometheusSerializer(this._prefix,this._appendTimestamp,Y,X),this._baseUrl=`http://${this._host}:${this._port}/`,this._endpoint=(J.endpoint||_W.DEFAULT_OPTIONS.endpoint).replace(/^([^/])/,"/$1"),J.preventServerStart!==!0)this.startServer().then(Q,(G)=>{h_.diag.error(G),Q(G)});else if(Q)queueMicrotask(Q)}async onForceFlush(){}onShutdown(){return this.stopServer()}stopServer(){if(!this._server)return h_.diag.debug("Prometheus stopServer() was called but server was never started."),Promise.resolve();else return new Promise((J)=>{this._server.close((Q)=>{if(!Q)h_.diag.debug("Prometheus exporter was stopped");else if(Q.code!=="ERR_SERVER_NOT_RUNNING")(0,e74.globalErrorHandler)(Q);J()})})}startServer(){return this._startServerPromise??=new Promise((J,Q)=>{this._server.once("error",Q),this._server.listen({port:this._port,host:this._host},()=>{h_.diag.debug(`Prometheus exporter server started: ${this._host}:${this._port}/${this._endpoint}`),J()})}),this._startServerPromise}getMetricsRequestHandler(J,Q){this._exportMetrics(Q)}_requestHandler=(J,Q)=>{if(J.url!=null&&new Y24.URL(J.url,this._baseUrl).pathname===this._endpoint)this._exportMetrics(Q);else this._notFound(Q)};_exportMetrics=(J)=>{J.statusCode=200,J.setHeader("content-type","text/plain"),this.collect().then((Q)=>{let{resourceMetrics:Y,errors:X}=Q;if(X.length)h_.diag.error("PrometheusExporter: metrics collection errors",...X);J.end(this._serializer.serialize(Y))},(Q)=>{J.end(`# failed to export metrics: ${Q}`)})};_notFound=(J)=>{J.statusCode=404,J.end()}}kW0.PrometheusExporter=_W});var vW0=v((rc)=>{Object.defineProperty(rc,"__esModule",{value:!0});rc.PrometheusSerializer=rc.PrometheusExporter=void 0;var X24=xW0();Object.defineProperty(rc,"PrometheusExporter",{enumerable:!0,get:function(){return X24.PrometheusExporter}});var G24=PG1();Object.defineProperty(rc,"PrometheusSerializer",{enumerable:!0,get:function(){return G24.PrometheusSerializer}})});var mW0=v((bW0)=>{Object.defineProperty(bW0,"__esModule",{value:!0});bW0.OTLPTraceExporter=void 0;var $24=XV(),q24=W$(),fW0=OW();class hW0 extends $24.OTLPExporterBase{constructor(J={}){super((0,fW0.createOtlpHttpExportDelegate)((0,fW0.convertLegacyHttpOptions)(J,"TRACES","v1/traces",{"Content-Type":"application/x-protobuf"}),q24.ProtobufTraceSerializer))}}bW0.OTLPTraceExporter=hW0});var uW0=v((RG1)=>{Object.defineProperty(RG1,"__esModule",{value:!0});RG1.OTLPTraceExporter=void 0;var V24=mW0();Object.defineProperty(RG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return V24.OTLPTraceExporter}})});var pW0=v((CG1)=>{Object.defineProperty(CG1,"__esModule",{value:!0});CG1.OTLPTraceExporter=void 0;var W24=uW0();Object.defineProperty(CG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return W24.OTLPTraceExporter}})});var dW0=v((jG1)=>{Object.defineProperty(jG1,"__esModule",{value:!0});jG1.OTLPTraceExporter=void 0;var z24=pW0();Object.defineProperty(jG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return z24.OTLPTraceExporter}})});var aW0=v((iW0)=>{Object.defineProperty(iW0,"__esModule",{value:!0});iW0.OTLPTraceExporter=void 0;var U24=XV(),B24=W$(),cW0=OW();class lW0 extends U24.OTLPExporterBase{constructor(J={}){super((0,cW0.createOtlpHttpExportDelegate)((0,cW0.convertLegacyHttpOptions)(J,"TRACES","v1/traces",{"Content-Type":"application/json"}),B24.JsonTraceSerializer))}}iW0.OTLPTraceExporter=lW0});var oW0=v((SG1)=>{Object.defineProperty(SG1,"__esModule",{value:!0});SG1.OTLPTraceExporter=void 0;var N24=aW0();Object.defineProperty(SG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return N24.OTLPTraceExporter}})});var rW0=v((_G1)=>{Object.defineProperty(_G1,"__esModule",{value:!0});_G1.OTLPTraceExporter=void 0;var M24=oW0();Object.defineProperty(_G1,"OTLPTraceExporter",{enumerable:!0,get:function(){return M24.OTLPTraceExporter}})});var sW0=v((kG1)=>{Object.defineProperty(kG1,"__esModule",{value:!0});kG1.OTLPTraceExporter=void 0;var A24=rW0();Object.defineProperty(kG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return A24.OTLPTraceExporter}})});var YH0=v((JH0)=>{Object.defineProperty(JH0,"__esModule",{value:!0});JH0.OTLPTraceExporter=void 0;var tW0=cc(),w24=W$(),E24=XV();class eW0 extends E24.OTLPExporterBase{constructor(J={}){super((0,tW0.createOtlpGrpcExportDelegate)((0,tW0.convertLegacyOtlpGrpcOptions)(J,"TRACES"),w24.ProtobufTraceSerializer,"TraceExportService","/opentelemetry.proto.collector.trace.v1.TraceService/Export"))}}JH0.OTLPTraceExporter=eW0});var XH0=v((yG1)=>{Object.defineProperty(yG1,"__esModule",{value:!0});yG1.OTLPTraceExporter=void 0;var I24=YH0();Object.defineProperty(yG1,"OTLPTraceExporter",{enumerable:!0,get:function(){return I24.OTLPTraceExporter}})});var $H0=v((GH0)=>{Object.defineProperty(GH0,"__esModule",{value:!0});GH0.prepareSend=void 0;var xG1=b6(),sc=V8(),T24=k1("http"),R24=k1("https");function C24(J,Q){let Y=new URL(J),X=Object.assign({method:"POST",headers:{"Content-Type":"application/json",...Q}});return function(Z,q){if(Z.length===0)return xG1.diag.debug("Zipkin send with empty spans"),q({code:sc.ExportResultCode.SUCCESS});let{request:V}=Y.protocol==="http:"?T24:R24,K=V(Y,X,(H)=>{let z="";H.on("data",(U)=>{z+=U}),H.on("end",()=>{let U=H.statusCode||0;if(xG1.diag.debug(`Zipkin response status code: ${U}, body: ${z}`),U<400)return q({code:sc.ExportResultCode.SUCCESS});else return q({code:sc.ExportResultCode.FAILED,error:Error(`Got unexpected status code from zipkin: ${U}`)})})});K.on("error",(H)=>{return q({code:sc.ExportResultCode.FAILED,error:H})});let W=JSON.stringify(Z);xG1.diag.debug(`Zipkin request payload: ${W}`),K.write(W,"utf8"),K.end()}}GH0.prepareSend=C24});var qH0=v((vG1)=>{Object.defineProperty(vG1,"__esModule",{value:!0});vG1.prepareSend=void 0;var j24=$H0();Object.defineProperty(vG1,"prepareSend",{enumerable:!0,get:function(){return j24.prepareSend}})});var hG1=v((fG1)=>{Object.defineProperty(fG1,"__esModule",{value:!0});fG1.prepareSend=void 0;var _24=qH0();Object.defineProperty(fG1,"prepareSend",{enumerable:!0,get:function(){return _24.prepareSend}})});var KH0=v((VH0)=>{Object.defineProperty(VH0,"__esModule",{value:!0});VH0.SpanKind=void 0;var y24;(function(J){J.CLIENT="CLIENT",J.SERVER="SERVER",J.CONSUMER="CONSUMER",J.PRODUCER="PRODUCER"})(y24=VH0.SpanKind||(VH0.SpanKind={}))});var UH0=v((zH0)=>{Object.defineProperty(zH0,"__esModule",{value:!0});zH0._toZipkinAnnotations=zH0._toZipkinTags=zH0.toZipkinSpan=zH0.defaultStatusErrorTagName=zH0.defaultStatusCodeTagName=void 0;var IF=b6(),gG1=V8(),tc=KH0(),x24={[IF.SpanKind.CLIENT]:tc.SpanKind.CLIENT,[IF.SpanKind.SERVER]:tc.SpanKind.SERVER,[IF.SpanKind.CONSUMER]:tc.SpanKind.CONSUMER,[IF.SpanKind.PRODUCER]:tc.SpanKind.PRODUCER,[IF.SpanKind.INTERNAL]:void 0};zH0.defaultStatusCodeTagName="otel.status_code";zH0.defaultStatusErrorTagName="error";function v24(J,Q,Y,X){return{traceId:J.spanContext().traceId,parentId:J.parentSpanContext?.spanId,name:J.name,id:J.spanContext().spanId,kind:x24[J.kind],timestamp:(0,gG1.hrTimeToMicroseconds)(J.startTime),duration:Math.round((0,gG1.hrTimeToMicroseconds)(J.duration)),localEndpoint:{serviceName:Q},tags:WH0(J,Y,X),annotations:J.events.length?HH0(J.events):void 0}}zH0.toZipkinSpan=v24;function WH0({attributes:J,resource:Q,status:Y,droppedAttributesCount:X,droppedEventsCount:G,droppedLinksCount:Z},q,V){let K={};for(let W of Object.keys(J))K[W]=String(J[W]);if(Y.code!==IF.SpanStatusCode.UNSET)K[q]=String(IF.SpanStatusCode[Y.code]);if(Y.code===IF.SpanStatusCode.ERROR&&Y.message)K[V]=Y.message;if(X)K["otel.dropped_attributes_count"]=String(X);if(G)K["otel.dropped_events_count"]=String(G);if(Z)K["otel.dropped_links_count"]=String(Z);return Object.keys(Q.attributes).forEach((W)=>K[W]=String(Q.attributes[W])),K}zH0._toZipkinTags=WH0;function HH0(J){return J.map((Q)=>({timestamp:Math.round((0,gG1.hrTimeToMicroseconds)(Q.time)),value:Q.name}))}zH0._toZipkinAnnotations=HH0});var DH0=v((BH0)=>{Object.defineProperty(BH0,"__esModule",{value:!0});BH0.prepareGetHeaders=void 0;function m24(J){return function(){return J()}}BH0.prepareGetHeaders=m24});var IH0=v((wH0)=>{Object.defineProperty(wH0,"__esModule",{value:!0});wH0.ZipkinExporter=void 0;var MH0=b6(),LH0=V8(),AH0=hG1(),mG1=UH0(),uG1=YF(),u24=DH0();class OH0{DEFAULT_SERVICE_NAME="OpenTelemetry Service";_statusCodeTagName;_statusDescriptionTagName;_urlStr;_send;_getHeaders;_serviceName;_isShutdown;_sendingPromises=[];constructor(J={}){if(this._urlStr=J.url||((0,LH0.getStringFromEnv)("OTEL_EXPORTER_ZIPKIN_ENDPOINT")??"http://localhost:9411/api/v2/spans"),this._send=(0,AH0.prepareSend)(this._urlStr,J.headers),this._serviceName=J.serviceName,this._statusCodeTagName=J.statusCodeTagName||mG1.defaultStatusCodeTagName,this._statusDescriptionTagName=J.statusDescriptionTagName||mG1.defaultStatusErrorTagName,this._isShutdown=!1,typeof J.getExportRequestHeaders==="function")this._getHeaders=(0,u24.prepareGetHeaders)(J.getExportRequestHeaders);else this._beforeSend=function(){}}export(J,Q){let Y=String(this._serviceName||J[0].resource.attributes[uG1.ATTR_SERVICE_NAME]||this.DEFAULT_SERVICE_NAME);if(MH0.diag.debug("Zipkin exporter export"),this._isShutdown){setTimeout(()=>Q({code:LH0.ExportResultCode.FAILED,error:Error("Exporter has been shutdown")}));return}let X=new Promise((Z)=>{this._sendSpans(J,Y,(q)=>{Z(),Q(q)})});this._sendingPromises.push(X);let G=()=>{let Z=this._sendingPromises.indexOf(X);this._sendingPromises.splice(Z,1)};X.then(G,G)}shutdown(){return MH0.diag.debug("Zipkin exporter shutdown"),this._isShutdown=!0,this.forceFlush()}forceFlush(){return new Promise((J,Q)=>{Promise.all(this._sendingPromises).then(()=>{J()},Q)})}_beforeSend(){if(this._getHeaders)this._send=(0,AH0.prepareSend)(this._urlStr,this._getHeaders())}_sendSpans(J,Q,Y){let X=J.map((G)=>(0,mG1.toZipkinSpan)(G,String(G.attributes[uG1.ATTR_SERVICE_NAME]||G.resource.attributes[uG1.ATTR_SERVICE_NAME]||Q),this._statusCodeTagName,this._statusDescriptionTagName));return this._beforeSend(),this._send(X,(G)=>{if(Y)return Y(G)})}}wH0.ZipkinExporter=OH0});var PH0=v((ec)=>{Object.defineProperty(ec,"__esModule",{value:!0});ec.ZipkinExporter=ec.prepareSend=void 0;var p24=hG1();Object.defineProperty(ec,"prepareSend",{enumerable:!0,get:function(){return p24.prepareSend}});var d24=IH0();Object.defineProperty(ec,"ZipkinExporter",{enumerable:!0,get:function(){return d24.ZipkinExporter}})});var pG1=v((TH0)=>{Object.defineProperty(TH0,"__esModule",{value:!0});TH0.B3_DEBUG_FLAG_KEY=void 0;var l24=b6();TH0.B3_DEBUG_FLAG_KEY=(0,l24.createContextKey)("OpenTelemetry Context Key B3 Debug Flag")});var b_=v((CH0)=>{Object.defineProperty(CH0,"__esModule",{value:!0});CH0.X_B3_FLAGS=CH0.X_B3_PARENT_SPAN_ID=CH0.X_B3_SAMPLED=CH0.X_B3_SPAN_ID=CH0.X_B3_TRACE_ID=CH0.B3_CONTEXT_HEADER=void 0;CH0.B3_CONTEXT_HEADER="b3";CH0.X_B3_TRACE_ID="x-b3-traceid";CH0.X_B3_SPAN_ID="x-b3-spanid";CH0.X_B3_SAMPLED="x-b3-sampled";CH0.X_B3_PARENT_SPAN_ID="x-b3-parentspanid";CH0.X_B3_FLAGS="x-b3-flags"});var vH0=v((yH0)=>{Object.defineProperty(yH0,"__esModule",{value:!0});yH0.B3MultiPropagator=void 0;var L$=b6(),s24=V8(),SH0=pG1(),qX=b_(),t24=new Set([!0,"true","True","1",1]),e24=new Set([!1,"false","False","0",0]);function J34(J){return J===L$.TraceFlags.SAMPLED||J===L$.TraceFlags.NONE}function Q34(J){return Array.isArray(J)?J[0]:J}function Jl(J,Q,Y){let X=Q.get(J,Y);return Q34(X)}function Y34(J,Q){let Y=Jl(J,Q,qX.X_B3_TRACE_ID);if(typeof Y==="string")return Y.padStart(32,"0");return""}function X34(J,Q){let Y=Jl(J,Q,qX.X_B3_SPAN_ID);if(typeof Y==="string")return Y;return""}function _H0(J,Q){return Jl(J,Q,qX.X_B3_FLAGS)==="1"?"1":void 0}function G34(J,Q){let Y=Jl(J,Q,qX.X_B3_SAMPLED);if(_H0(J,Q)==="1"||t24.has(Y))return L$.TraceFlags.SAMPLED;if(Y===void 0||e24.has(Y))return L$.TraceFlags.NONE;return}class kH0{inject(J,Q,Y){let X=L$.trace.getSpanContext(J);if(!X||!(0,L$.isSpanContextValid)(X)||(0,s24.isTracingSuppressed)(J))return;let G=J.getValue(SH0.B3_DEBUG_FLAG_KEY);if(Y.set(Q,qX.X_B3_TRACE_ID,X.traceId),Y.set(Q,qX.X_B3_SPAN_ID,X.spanId),G==="1")Y.set(Q,qX.X_B3_FLAGS,G);else if(X.traceFlags!==void 0)Y.set(Q,qX.X_B3_SAMPLED,(L$.TraceFlags.SAMPLED&X.traceFlags)===L$.TraceFlags.SAMPLED?"1":"0")}extract(J,Q,Y){let X=Y34(Q,Y),G=X34(Q,Y),Z=G34(Q,Y),q=_H0(Q,Y);if((0,L$.isValidTraceId)(X)&&(0,L$.isValidSpanId)(G)&&J34(Z))return J=J.setValue(SH0.B3_DEBUG_FLAG_KEY,q),L$.trace.setSpanContext(J,{traceId:X,spanId:G,isRemote:!0,traceFlags:Z});return J}fields(){return[qX.X_B3_TRACE_ID,qX.X_B3_SPAN_ID,qX.X_B3_FLAGS,qX.X_B3_SAMPLED,qX.X_B3_PARENT_SPAN_ID]}}yH0.B3MultiPropagator=kH0});var mH0=v((bH0)=>{Object.defineProperty(bH0,"__esModule",{value:!0});bH0.B3SinglePropagator=void 0;var mD=b6(),Z34=V8(),fH0=pG1(),dG1=b_(),$34=/((?:[0-9a-f]{16}){1,2})-([0-9a-f]{16})(?:-([01d](?![0-9a-f])))?(?:-([0-9a-f]{16}))?/,q34="0".repeat(16),V34=new Set(["d","1"]),K34="d";function W34(J){return J.length===32?J:`${q34}${J}`}function H34(J){if(J&&V34.has(J))return mD.TraceFlags.SAMPLED;return mD.TraceFlags.NONE}class hH0{inject(J,Q,Y){let X=mD.trace.getSpanContext(J);if(!X||!(0,mD.isSpanContextValid)(X)||(0,Z34.isTracingSuppressed)(J))return;let G=J.getValue(fH0.B3_DEBUG_FLAG_KEY)||X.traceFlags&1,Z=`${X.traceId}-${X.spanId}-${G}`;Y.set(Q,dG1.B3_CONTEXT_HEADER,Z)}extract(J,Q,Y){let X=Y.get(Q,dG1.B3_CONTEXT_HEADER),G=Array.isArray(X)?X[0]:X;if(typeof G!=="string")return J;let Z=G.match($34);if(!Z)return J;let[,q,V,K]=Z,W=W34(q);if(!(0,mD.isValidTraceId)(W)||!(0,mD.isValidSpanId)(V))return J;let H=H34(K);if(K===K34)J=J.setValue(fH0.B3_DEBUG_FLAG_KEY,K);return mD.trace.setSpanContext(J,{traceId:W,spanId:V,isRemote:!0,traceFlags:H})}fields(){return[dG1.B3_CONTEXT_HEADER]}}bH0.B3SinglePropagator=hH0});var lG1=v((uH0)=>{Object.defineProperty(uH0,"__esModule",{value:!0});uH0.B3InjectEncoding=void 0;var z34;(function(J){J[J.SINGLE_HEADER=0]="SINGLE_HEADER",J[J.MULTI_HEADER=1]="MULTI_HEADER"})(z34=uH0.B3InjectEncoding||(uH0.B3InjectEncoding={}))});var lH0=v((dH0)=>{Object.defineProperty(dH0,"__esModule",{value:!0});dH0.B3Propagator=void 0;var F34=V8(),U34=vH0(),B34=mH0(),N34=b_(),D34=lG1();class pH0{_b3MultiPropagator=new U34.B3MultiPropagator;_b3SinglePropagator=new B34.B3SinglePropagator;_inject;_fields;constructor(J={}){if(J.injectEncoding===D34.B3InjectEncoding.MULTI_HEADER)this._inject=this._b3MultiPropagator.inject,this._fields=this._b3MultiPropagator.fields();else this._inject=this._b3SinglePropagator.inject,this._fields=this._b3SinglePropagator.fields()}inject(J,Q,Y){if((0,F34.isTracingSuppressed)(J))return;this._inject(J,Q,Y)}extract(J,Q,Y){let X=Y.get(Q,N34.B3_CONTEXT_HEADER);if(Array.isArray(X)?X[0]:X)return this._b3SinglePropagator.extract(J,Q,Y);else return this._b3MultiPropagator.extract(J,Q,Y)}fields(){return this._fields}}dH0.B3Propagator=pH0});var iH0=v((MV)=>{Object.defineProperty(MV,"__esModule",{value:!0});MV.B3InjectEncoding=MV.X_B3_TRACE_ID=MV.X_B3_SPAN_ID=MV.X_B3_SAMPLED=MV.X_B3_PARENT_SPAN_ID=MV.X_B3_FLAGS=MV.B3_CONTEXT_HEADER=MV.B3Propagator=void 0;var M34=lH0();Object.defineProperty(MV,"B3Propagator",{enumerable:!0,get:function(){return M34.B3Propagator}});var KE=b_();Object.defineProperty(MV,"B3_CONTEXT_HEADER",{enumerable:!0,get:function(){return KE.B3_CONTEXT_HEADER}});Object.defineProperty(MV,"X_B3_FLAGS",{enumerable:!0,get:function(){return KE.X_B3_FLAGS}});Object.defineProperty(MV,"X_B3_PARENT_SPAN_ID",{enumerable:!0,get:function(){return KE.X_B3_PARENT_SPAN_ID}});Object.defineProperty(MV,"X_B3_SAMPLED",{enumerable:!0,get:function(){return KE.X_B3_SAMPLED}});Object.defineProperty(MV,"X_B3_SPAN_ID",{enumerable:!0,get:function(){return KE.X_B3_SPAN_ID}});Object.defineProperty(MV,"X_B3_TRACE_ID",{enumerable:!0,get:function(){return KE.X_B3_TRACE_ID}});var L34=lG1();Object.defineProperty(MV,"B3InjectEncoding",{enumerable:!0,get:function(){return L34.B3InjectEncoding}})});var sH0=v((aH0)=>{Object.defineProperty(aH0,"__esModule",{value:!0});aH0.JaegerPropagator=aH0.UBER_BAGGAGE_HEADER_PREFIX=aH0.UBER_TRACE_ID_HEADER=void 0;var uD=b6(),O34=V8();aH0.UBER_TRACE_ID_HEADER="uber-trace-id";aH0.UBER_BAGGAGE_HEADER_PREFIX="uberctx";class nH0{_jaegerTraceHeader;_jaegerBaggageHeaderPrefix;constructor(J){if(typeof J==="string")this._jaegerTraceHeader=J,this._jaegerBaggageHeaderPrefix=aH0.UBER_BAGGAGE_HEADER_PREFIX;else this._jaegerTraceHeader=J?.customTraceHeader||aH0.UBER_TRACE_ID_HEADER,this._jaegerBaggageHeaderPrefix=J?.customBaggageHeaderPrefix||aH0.UBER_BAGGAGE_HEADER_PREFIX}inject(J,Q,Y){let X=uD.trace.getSpanContext(J),G=uD.propagation.getBaggage(J);if(X&&(0,O34.isTracingSuppressed)(J)===!1){let Z=`0${(X.traceFlags||uD.TraceFlags.NONE).toString(16)}`;Y.set(Q,this._jaegerTraceHeader,`${X.traceId}:${X.spanId}:0:${Z}`)}if(G)for(let[Z,q]of G.getAllEntries())Y.set(Q,`${this._jaegerBaggageHeaderPrefix}-${Z}`,encodeURIComponent(q.value))}extract(J,Q,Y){let X=Y.get(Q,this._jaegerTraceHeader),G=Array.isArray(X)?X[0]:X,Z=Y.keys(Q).filter((K)=>K.startsWith(`${this._jaegerBaggageHeaderPrefix}-`)).map((K)=>{let W=Y.get(Q,K);return{key:K.substring(this._jaegerBaggageHeaderPrefix.length+1),value:Array.isArray(W)?W[0]:W}}),q=J;if(typeof G==="string"){let K=E34(G);if(K)q=uD.trace.setSpanContext(q,K)}if(Z.length===0)return q;let V=uD.propagation.getBaggage(J)??uD.propagation.createBaggage();for(let K of Z){if(K.value===void 0)continue;V=V.setEntry(K.key,{value:decodeURIComponent(K.value)})}return q=uD.propagation.setBaggage(q,V),q}fields(){return[this._jaegerTraceHeader]}}aH0.JaegerPropagator=nH0;var w34=/^[0-9a-f]{1,2}$/i;function E34(J){let Q=decodeURIComponent(J).split(":");if(Q.length!==4)return null;let[Y,X,,G]=Q,Z=Y.padStart(32,"0"),q=X.padStart(16,"0"),V=w34.test(G)?parseInt(G,16)&1:1;return{traceId:Z,spanId:q,isRemote:!0,traceFlags:V}}});var tH0=v((g_)=>{Object.defineProperty(g_,"__esModule",{value:!0});g_.UBER_TRACE_ID_HEADER=g_.UBER_BAGGAGE_HEADER_PREFIX=g_.JaegerPropagator=void 0;var nG1=sH0();Object.defineProperty(g_,"JaegerPropagator",{enumerable:!0,get:function(){return nG1.JaegerPropagator}});Object.defineProperty(g_,"UBER_BAGGAGE_HEADER_PREFIX",{enumerable:!0,get:function(){return nG1.UBER_BAGGAGE_HEADER_PREFIX}});Object.defineProperty(g_,"UBER_TRACE_ID_HEADER",{enumerable:!0,get:function(){return nG1.UBER_TRACE_ID_HEADER}})});var Gz0=v((Yz0)=>{Object.defineProperty(Yz0,"__esModule",{value:!0});Yz0.setupPropagator=Yz0.setupContextManager=Yz0.getPropagatorFromEnv=Yz0.getSpanProcessorsFromEnv=Yz0.getOtlpProtocolFromEnv=Yz0.filterBlanksAndNulls=Yz0.getResourceDetectorsFromEnv=void 0;var vG=b6(),A$=V8(),eH0=dW0(),P34=sW0(),T34=XH0(),R34=PH0(),m_=BD(),Ql=wD(),aG1=iH0(),C34=tH0(),j34=cu(),S34="env",_34="host",k34="os",y34="process",x34="serviceinstance";function v34(){let J=new Map([[S34,m_.envDetector],[_34,m_.hostDetector],[k34,m_.osDetector],[x34,m_.serviceInstanceIdDetector],[y34,m_.processDetector]]),Q=(0,A$.getStringListFromEnv)("OTEL_NODE_RESOURCE_DETECTORS")??["all"];if(Q.includes("all"))return[...J.values()].flat();if(Q.includes("none"))return[];return Q.flatMap((Y)=>{let X=J.get(Y);if(!X)vG.diag.warn(`Invalid resource detector "${Y}" specified in the environment variable OTEL_NODE_RESOURCE_DETECTORS`);return X||[]})}Yz0.getResourceDetectorsFromEnv=v34;function Jz0(J){return J.map((Q)=>Q.trim()).filter((Q)=>Q!=="null"&&Q!=="")}Yz0.filterBlanksAndNulls=Jz0;function Qz0(){return(0,A$.getStringFromEnv)("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL")??(0,A$.getStringFromEnv)("OTEL_EXPORTER_OTLP_PROTOCOL")??"http/protobuf"}Yz0.getOtlpProtocolFromEnv=Qz0;function f34(){let J=Qz0();switch(J){case"grpc":return new T34.OTLPTraceExporter;case"http/json":return new P34.OTLPTraceExporter;case"http/protobuf":return new eH0.OTLPTraceExporter;default:return vG.diag.warn(`Unsupported OTLP traces protocol: ${J}. Using http/protobuf.`),new eH0.OTLPTraceExporter}}function h34(){let J=new Map([["otlp",()=>f34()],["zipkin",()=>new R34.ZipkinExporter],["console",()=>new Ql.ConsoleSpanExporter]]),Q=[],Y=[],X=Jz0(Array.from(new Set((0,A$.getStringListFromEnv)("OTEL_TRACES_EXPORTER"))));if(X[0]==="none")return vG.diag.warn('OTEL_TRACES_EXPORTER contains "none". SDK will not be initialized.'),[];if(X.length===0)vG.diag.debug("OTEL_TRACES_EXPORTER is empty. Using default otlp exporter."),X=["otlp"];else if(X.length>1&&X.includes("none"))vG.diag.warn('OTEL_TRACES_EXPORTER contains "none" along with other exporters. Using default otlp exporter.'),X=["otlp"];for(let G of X){let Z=J.get(G)?.();if(Z)Q.push(Z);else vG.diag.warn(`Unrecognized OTEL_TRACES_EXPORTER value: ${G}.`)}for(let G of Q)if(G instanceof Ql.ConsoleSpanExporter)Y.push(new Ql.SimpleSpanProcessor(G));else Y.push(new Ql.BatchSpanProcessor(G));if(Q.length===0)vG.diag.warn("Unable to set up trace exporter(s) due to invalid exporter and/or protocol values.");return Y}Yz0.getSpanProcessorsFromEnv=h34;function b34(){let J=(0,A$.getStringListFromEnv)("OTEL_PROPAGATORS");if(J==null)return;if(J.includes("none"))return null;let Q=new Map([["tracecontext",()=>new A$.W3CTraceContextPropagator],["baggage",()=>new A$.W3CBaggagePropagator],["b3",()=>new aG1.B3Propagator],["b3multi",()=>new aG1.B3Propagator({injectEncoding:aG1.B3InjectEncoding.MULTI_HEADER})],["jaeger",()=>new C34.JaegerPropagator]]),Y=Array.from(new Set(J)),G=Y.map((Z)=>{let q=Q.get(Z)?.();if(!q){vG.diag.warn(`Propagator "${Z}" requested through environment variable is unavailable.`);return}return q}).reduce((Z,q)=>{if(q)Z.push(q);return Z},[]);if(G.length===0)return null;else if(Y.length===1)return G[0];else return new A$.CompositePropagator({propagators:G})}Yz0.getPropagatorFromEnv=b34;function g34(J){if(J===null)return;if(J===void 0){let Q=new j34.AsyncLocalStorageContextManager;Q.enable(),vG.context.setGlobalContextManager(Q);return}J.enable(),vG.context.setGlobalContextManager(J)}Yz0.setupContextManager=g34;function m34(J){if(J===null)return;if(J===void 0){vG.propagation.setGlobalPropagator(new A$.CompositePropagator({propagators:[new A$.W3CTraceContextPropagator,new A$.W3CBaggagePropagator]}));return}vG.propagation.setGlobalPropagator(J)}Yz0.setupPropagator=m34});var Wz0=v((Vz0)=>{Object.defineProperty(Vz0,"__esModule",{value:!0});Vz0.NodeSDK=void 0;var dJ=b6(),n34=bS(),a34=xJ0(),WE=BD(),u_=gJ1(),o34=VY0(),r34=iK0(),oG1=JW0(),s34=MW0(),Zz0=TW0(),t34=nc(),e34=vW0(),pD=LD(),JJ4=wD(),QJ4=sJ1(),YJ4=YF(),PF=V8(),p_=Gz0();function $z0(J,Q){return parseInt(process.env[J]||"")||Q}function XJ4(){let J=[],Q=(0,PF.getStringListFromEnv)("OTEL_METRICS_EXPORTER");if(!Q)return J;if(Q.length===0)dJ.diag.debug("OTEL_METRICS_EXPORTER is empty. Using default otlp exporter.");if(Q.includes("none"))return dJ.diag.info('OTEL_METRICS_EXPORTER contains "none". Metric provider will not be initialized.'),J;return Q.forEach((Y)=>{if(Y==="otlp"){let X=process.env.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL?.trim()||process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim(),G=$z0("OTEL_METRIC_EXPORT_INTERVAL",60000),Z=$z0("OTEL_METRIC_EXPORT_TIMEOUT",30000);switch(X){case"grpc":J.push(new pD.PeriodicExportingMetricReader({exporter:new s34.OTLPMetricExporter,exportIntervalMillis:G,exportTimeoutMillis:Z}));break;case"http/json":J.push(new pD.PeriodicExportingMetricReader({exporter:new t34.OTLPMetricExporter,exportIntervalMillis:G,exportTimeoutMillis:Z}));break;case"http/protobuf":J.push(new pD.PeriodicExportingMetricReader({exporter:new Zz0.OTLPMetricExporter,exportIntervalMillis:G,exportTimeoutMillis:Z}));break;default:dJ.diag.warn(`Unsupported OTLP metrics protocol: "${X}". Using http/protobuf.`),J.push(new pD.PeriodicExportingMetricReader({exporter:new Zz0.OTLPMetricExporter,exportIntervalMillis:G,exportTimeoutMillis:Z}))}}else if(Y==="console")J.push(new pD.PeriodicExportingMetricReader({exporter:new pD.ConsoleMetricExporter}));else if(Y==="prometheus")J.push(new e34.PrometheusExporter);else dJ.diag.warn(`Unsupported OTEL_METRICS_EXPORTER value: "${Y}". Supported values are: otlp, console, prometheus, none.`)}),J}class qz0{_tracerProviderConfig;_loggerProviderConfig;_meterProviderConfig;_instrumentations;_resource;_resourceDetectors;_autoDetectResources;_tracerProvider;_loggerProvider;_meterProvider;_serviceName;_configuration;_disabled;constructor(J={}){if((0,PF.getBooleanFromEnv)("OTEL_SDK_DISABLED"))this._disabled=!0;let Q=(0,PF.getStringFromEnv)("OTEL_LOG_LEVEL");if(Q!=null)dJ.diag.setLogger(new dJ.DiagConsoleLogger,{logLevel:(0,PF.diagLogLevelFromString)(Q)});if(this._configuration=J,this._resource=J.resource??(0,WE.defaultResource)(),this._autoDetectResources=J.autoDetectResources??!0,!this._autoDetectResources)this._resourceDetectors=[];else if(J.resourceDetectors!=null)this._resourceDetectors=J.resourceDetectors;else if((0,PF.getStringFromEnv)("OTEL_NODE_RESOURCE_DETECTORS"))this._resourceDetectors=(0,p_.getResourceDetectorsFromEnv)();else this._resourceDetectors=[WE.envDetector,WE.processDetector,WE.hostDetector];if(this._serviceName=J.serviceName,J.traceExporter||J.spanProcessor||J.spanProcessors){let Y={};if(J.sampler)Y.sampler=J.sampler;if(J.spanLimits)Y.spanLimits=J.spanLimits;if(J.idGenerator)Y.idGenerator=J.idGenerator;if(J.spanProcessor)dJ.diag.warn("The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.");let X=J.spanProcessor??new JJ4.BatchSpanProcessor(J.traceExporter),G=J.spanProcessors??[X];this._tracerProviderConfig={tracerConfig:Y,spanProcessors:G}}if(J.logRecordProcessors)this._loggerProviderConfig={logRecordProcessors:J.logRecordProcessors};else if(J.logRecordProcessor)this._loggerProviderConfig={logRecordProcessors:[J.logRecordProcessor]},dJ.diag.warn("The 'logRecordProcessor' option is deprecated. Please use 'logRecordProcessors' instead.");else this.configureLoggerProviderFromEnv();if(J.metricReaders||J.metricReader||J.views){let Y={};if(J.metricReaders)Y.readers=J.metricReaders;else if(J.metricReader)Y.readers=[J.metricReader],dJ.diag.warn("The 'metricReader' option is deprecated. Please use 'metricReaders' instead.");if(J.views)Y.views=J.views;this._meterProviderConfig=Y}this._instrumentations=J.instrumentations?.flat()??[]}start(){if(this._disabled)return;if((0,a34.registerInstrumentations)({instrumentations:this._instrumentations}),(0,p_.setupContextManager)(this._configuration?.contextManager),(0,p_.setupPropagator)(this._configuration?.textMapPropagator===null?null:this._configuration?.textMapPropagator??(0,p_.getPropagatorFromEnv)()),this._autoDetectResources){let Y={detectors:this._resourceDetectors};this._resource=this._resource.merge((0,WE.detectResources)(Y))}this._resource=this._serviceName===void 0?this._resource:this._resource.merge((0,WE.resourceFromAttributes)({[YJ4.ATTR_SERVICE_NAME]:this._serviceName}));let J=this._tracerProviderConfig?this._tracerProviderConfig.spanProcessors:(0,p_.getSpanProcessorsFromEnv)();if(J.length>0)this._tracerProvider=new QJ4.NodeTracerProvider({...this._configuration,resource:this._resource,spanProcessors:J}),dJ.trace.setGlobalTracerProvider(this._tracerProvider);if(this._loggerProviderConfig){let Y=new u_.LoggerProvider({resource:this._resource,processors:this._loggerProviderConfig.logRecordProcessors});this._loggerProvider=Y,n34.logs.setGlobalLoggerProvider(Y)}let Q=XJ4();if(this._meterProviderConfig||Q.length>0){let Y=[];if(this._meterProviderConfig?.readers)Y.push(...this._meterProviderConfig.readers);if(Y.length===0)Q.forEach((G)=>Y.push(G));let X=new pD.MeterProvider({resource:this._resource,views:this._meterProviderConfig?.views??[],readers:Y});this._meterProvider=X,dJ.metrics.setGlobalMeterProvider(X);for(let G of this._instrumentations)G.setMeterProvider(dJ.metrics.getMeterProvider())}}shutdown(){let J=[];if(this._tracerProvider)J.push(this._tracerProvider.shutdown());if(this._loggerProvider)J.push(this._loggerProvider.shutdown());if(this._meterProvider)J.push(this._meterProvider.shutdown());return Promise.all(J).then(()=>{})}configureLoggerProviderFromEnv(){let J=(0,PF.getStringListFromEnv)("OTEL_LOGS_EXPORTER")??[];if(J.length===0)dJ.diag.debug("OTEL_LOGS_EXPORTER is empty. Using default otlp exporter."),J.push("otlp");if(J.includes("none")){dJ.diag.info('OTEL_LOGS_EXPORTER contains "none". Logger provider will not be initialized.');return}let Q=[];if(J.forEach((Y)=>{if(Y==="otlp"){let X=((0,PF.getStringFromEnv)("OTEL_EXPORTER_OTLP_LOGS_PROTOCOL")??(0,PF.getStringFromEnv)("OTEL_EXPORTER_OTLP_PROTOCOL"))?.trim();switch(X){case"grpc":Q.push(new r34.OTLPLogExporter);break;case"http/json":Q.push(new o34.OTLPLogExporter);break;case"http/protobuf":Q.push(new oG1.OTLPLogExporter);break;case void 0:case"":Q.push(new oG1.OTLPLogExporter);break;default:dJ.diag.warn(`Unsupported OTLP logs protocol: "${X}". Using http/protobuf.`),Q.push(new oG1.OTLPLogExporter)}}else if(Y==="console")Q.push(new u_.ConsoleLogRecordExporter);else dJ.diag.warn(`Unsupported OTEL_LOGS_EXPORTER value: "${Y}". Supported values are: otlp, console, none.`)}),Q.length>0)this._loggerProviderConfig={logRecordProcessors:Q.map((Y)=>{if(Y instanceof u_.ConsoleLogRecordExporter)return new u_.SimpleLogRecordProcessor(Y);else return new u_.BatchLogRecordProcessor(Y)})}}}Vz0.NodeSDK=qz0});var Hz0=v((rG1)=>{Object.defineProperty(rG1,"__esModule",{value:!0});rG1.NodeSDK=rG1.tracing=rG1.resources=rG1.node=rG1.metrics=rG1.logs=rG1.core=rG1.contextBase=rG1.api=void 0;rG1.api=b6();rG1.contextBase=b6();rG1.core=V8();rG1.logs=gJ1();rG1.metrics=LD();rG1.node=sJ1();rG1.resources=BD();rG1.tracing=wD();var GJ4=Wz0();Object.defineProperty(rG1,"NodeSDK",{enumerable:!0,get:function(){return GJ4.NodeSDK}})});import UJ4 from"os";import Yl from"path";var TF,dD,RF,CF,zz0,tf8,ef8,BJ4,NJ4;var HE=L1(()=>{TF=UJ4.homedir(),{env:dD}=process,RF=dD.XDG_DATA_HOME||(TF?Yl.join(TF,".local","share"):void 0),CF=dD.XDG_CONFIG_HOME||(TF?Yl.join(TF,".config"):void 0),zz0=dD.XDG_STATE_HOME||(TF?Yl.join(TF,".local","state"):void 0),tf8=dD.XDG_CACHE_HOME||(TF?Yl.join(TF,".cache"):void 0),ef8=dD.XDG_RUNTIME_DIR||void 0,BJ4=(dD.XDG_DATA_DIRS||"/usr/local/share/:/usr/share/").split(":");if(RF)BJ4.unshift(RF);NJ4=(dD.XDG_CONFIG_DIRS||"/etc/xdg").split(":");if(CF)NJ4.unshift(CF)});import{homedir as Xl}from"node:os";import cD from"node:path";var Fz0,DJ4,Uz0,MJ4,Gl,LJ4,zE,LV,Gh8;var kW=L1(()=>{HE();Fz0=cD.join(Xl(),".local/share"),DJ4=process.platform==="win32"||process.platform==="darwin"?Fz0:RF??Fz0,Uz0=cD.join(Xl(),".config"),MJ4=process.platform==="win32"||process.platform==="darwin"?Uz0:CF??Uz0,Gl=cD.join(DJ4,"amp"),LJ4=cD.join(MJ4,"amp"),zE=cD.join(LJ4,"tools"),LV=cD.join(Xl(),".cache","amp"),Gh8=cD.join(Xl(),".cache","amp","http-debug-logs")});function OJ4(){return AJ4}function Bz0(J){let Q=lD;return lD=J,Q}class AV{baseLogger;scope;context={};constructor(J=Nz0){this.baseLogger=J}with(J){let Q=new AV(this.baseLogger);return Q.scope=this.scope,Q.context={...this.context,...J},Q}scoped(J){let Q=new AV(this.baseLogger);return Q.scope=this.scope?`${this.scope}.${J}`:J,Q.context={...this.context},Q}error(J,...Q){let Y=this.mergeContextWithMeta(Q);this.baseLogger.error(this.messageWithPrefix(J),...Y)}warn(J,...Q){let Y=this.mergeContextWithMeta(Q);this.baseLogger.warn(this.messageWithPrefix(J),...Y)}info(J,...Q){let Y=this.mergeContextWithMeta(Q);this.baseLogger.info(this.messageWithPrefix(J),...Y)}debug(J,...Q){let Y=this.mergeContextWithMeta(Q);this.baseLogger.debug(this.messageWithPrefix(J),...Y)}audit(J,...Q){let Y=this.mergeContextWithMeta(Q);this.baseLogger.audit(this.messageWithPrefix(J),...Y)}messageWithPrefix(J){return this.scope?`${this.scope}: ${J}`:J}mergeContextWithMeta(J){let Q={...this.context},Y=sG1.trace.getActiveSpan();if(Y){let G=Y.spanContext();if(G.traceId)Q.traceId=G.traceId,Q.spanId=G.spanId}if(J.length===0)return[Q];let X=J[0];if(typeof X==="object"&&X!==null)return[{...X,...Q},...J.slice(1)];else return[Q,...J]}}var sG1,AJ4=!1,wJ4,lD,Nz0,f;var L0=L1(()=>{sG1=N6(b6(),1);wJ4={error:(J,...Q)=>console.error(J,...Q),warn:(J,...Q)=>console.warn(J,...Q),info:(J,...Q)=>console.info(J,...Q),debug:(J,...Q)=>{if(OJ4())console.debug(J,...Q)},audit:(J,...Q)=>{let Y=Q.length>0?Q[0]:{};if(typeof Y==="object"&&Y!==null&&!("audit"in Y))Y.audit=!0;let X=sG1.trace.getActiveSpan();if(X){let G=X.spanContext();if(G.traceId)Y.traceId=G.traceId,Y.spanId=G.spanId}console.info(J,Y)}},lD=wJ4;Nz0={error:(J,...Q)=>lD.error(J,...Q),warn:(J,...Q)=>lD.warn(J,...Q),info:(J,...Q)=>lD.info(J,...Q),debug:(J,...Q)=>lD.debug(J,...Q),audit:(J,...Q)=>lD.audit(J,...Q)};f=Nz0});function Ez0(){if(typeof process==="object")return process.platform==="win32"?"windows":"posix";else if(typeof navigator==="object")return navigator.userAgent.indexOf("Windows")>=0?"windows":"posix";return"posix"}function Iz0(J,Q){if(!J.scheme&&Q)throw Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${J.authority}", path: "${J.path}", query: "${J.query}", fragment: "${J.fragment}"}`);if(J.scheme&&!SJ4.test(J.scheme))throw Error("[UriError]: Scheme contains illegal characters.");if(J.path){if(J.authority){if(!_J4.test(J.path))throw Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(kJ4.test(J.path))throw Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}function yJ4(J,Q){if(!J&&!Q)return"file";return J}function xJ4(J,Q){switch(J){case"https":case"http":case"file":if(!Q)Q=O$;else if(Q[0]!==O$)Q=O$+Q;break}return Q}class n0{static isUri(J){if(J instanceof n0)return!0;if(!J)return!1;let Q=J;return typeof Q.authority==="string"&&typeof Q.fragment==="string"&&typeof Q.path==="string"&&typeof Q.query==="string"&&typeof Q.scheme==="string"&&typeof Q.fsPath==="string"&&typeof Q.with==="function"&&typeof Q.toString==="function"}scheme;authority;path;query;fragment;platform;constructor(J,Q,Y,X,G,Z=!1,q){if(typeof J==="object")this.scheme=J.scheme||h5,this.authority=J.authority||h5,this.path=J.path||h5,this.query=J.query||h5,this.fragment=J.fragment||h5,this.platform=J.platform;else this.scheme=yJ4(J,Z),this.authority=Q||h5,this.path=xJ4(this.scheme,Y||h5),this.query=X||h5,this.fragment=G||h5,this.platform=q,Iz0(this,Z)}get fsPath(){return jz0(this,!1)}with(J){if(!J)return this;let{scheme:Q,authority:Y,path:X,query:G,fragment:Z,platform:q}=J;if(Q===void 0)Q=this.scheme;else if(Q===null)Q=h5;if(Y===void 0)Y=this.authority;else if(Y===null)Y=h5;if(X===void 0)X=this.path;else if(X===null)X=h5;if(G===void 0)G=this.query;else if(G===null)G=h5;if(Z===void 0)Z=this.fragment;else if(Z===null)Z=h5;if(q===void 0)q=this.platform;else if(q===null)q=void 0;if(Q===this.scheme&&Y===this.authority&&X===this.path&&G===this.query&&Z===this.fragment&&q===this.platform)return this;return new iD(Q,Y,X,G,Z,!1,q)}static parse(J,Q=!1){let Y=vJ4.exec(J);if(!Y)return new iD(h5,h5,h5,h5,h5);return new iD(Y[2]||h5,$l(Y[4]||h5),$l(Y[5]||h5),$l(Y[7]||h5),$l(Y[9]||h5),Q)}static file(J,Q=Ez0()){let Y=h5;if(Q==="windows")J=J.replace(/\\/g,O$);if(J[0]===O$&&J[1]===O$){let X=J.indexOf(O$,2);if(X===-1)Y=J.substring(2),J=O$;else Y=J.substring(2,X),J=J.substring(X)||O$}return new iD("file",Y,J,h5,h5,!1,Q)}static from(J){let Q=new iD(J.scheme,J.authority,J.path,J.query,J.fragment,!0,J.platform);return Iz0(Q,!0),Q}toString(J=!1){return eG1(this,J)}toJSON(){return this}static revive(J){if(!J)return J;if(J instanceof n0)return J;let Q=new iD(J),Y=J;return Q._formatted=Y.external,Q._fsPath=Y._sep===Rz0(Q.platform)?Y.fsPath:null,Q}}function Rz0(J){return J==="windows"?1:void 0}function Pz0(J,Q,Y){let X=void 0;for(let G=0;G<J.length;G++){let Z=J.charCodeAt(G);if(Z>=97&&Z<=122||Z>=65&&Z<=90||Z>=48&&Z<=57||Z===45||Z===46||Z===95||Z===126||Q&&Z===47||Y&&Z===91||Y&&Z===93||Y&&Z===58){if(X!==void 0)X+=J.charAt(G)}else{if(X===void 0)X=J.substring(0,G);let q=Cz0[Z];if(q!==void 0)X+=q;else X+=encodeURIComponent(J.charAt(G))}}return X!==void 0?X:J}function fJ4(J){let Q=void 0;for(let Y=0;Y<J.length;Y++){let X=J.charCodeAt(Y);if(X===35||X===63){if(Q===void 0)Q=J.substring(0,Y);Q+=Cz0[X]}else if(Q!==void 0)Q+=J[Y]}return Q!==void 0?Q:J}function jz0(J,Q){let Y;if(J.authority&&J.path.length>1&&J.scheme==="file")Y=`//${J.authority}${J.path}`;else if(J.path.charCodeAt(0)===47&&(J.path.charCodeAt(1)>=65&&J.path.charCodeAt(1)<=90||J.path.charCodeAt(1)>=97&&J.path.charCodeAt(1)<=122)&&J.path.charCodeAt(2)===58)if(!Q)Y=J.path[1].toLowerCase()+J.path.substring(2);else Y=J.path.substring(1);else Y=J.path;if(J.platform==="windows")Y=Y.replace(/\//g,"\\");return Y}function eG1(J,Q){let Y=!Q?Pz0:fJ4,X="",{scheme:G,authority:Z,path:q,query:V,fragment:K}=J;if(G)X+=G,X+=":";if(Z||G==="file")X+=O$,X+=O$;if(Z){let W=Z.indexOf("@");if(W!==-1){let H=Z.substring(0,W);if(Z=Z.substring(W+1),W=H.lastIndexOf(":"),W===-1)X+=Y(H,!1,!1);else X+=Y(H.substring(0,W),!1,!1),X+=":",X+=Y(H.substring(W+1),!1,!0);X+="@"}if(Z=Z.toLowerCase(),W=Z.lastIndexOf(":"),W===-1)X+=Y(Z,!1,!0);else X+=Y(Z.substring(0,W),!1,!0),X+=Z.substring(W)}if(q){if(q.length>=3&&q.charCodeAt(0)===47&&q.charCodeAt(2)===58){let W=q.charCodeAt(1);if(W>=65&&W<=90)q=`/${String.fromCharCode(W+32)}:${q.substring(3)}`}else if(q.length>=2&&q.charCodeAt(1)===58){let W=q.charCodeAt(0);if(W>=65&&W<=90)q=`${String.fromCharCode(W+32)}:${q.substring(2)}`}X+=Y(q,!0,!1)}if(V)X+="?",X+=Y(V,!1,!1);if(K)X+="#",X+=!Q?Pz0(K,!1,!1):K;return X}function Sz0(J){try{return decodeURIComponent(J)}catch{if(J.length>3)return J.substring(0,3)+Sz0(J.substring(3));else return J}}function $l(J){if(!J.match(Tz0))return J;return J.replace(Tz0,(Q)=>Sz0(Q))}function jF(J){return J.scheme==="file"}function cJ(J){return n0.parse(J)}function A6(J){return J.toString()}function o4(J){if(typeof J==="string"||J instanceof URL)return n0.parse(J.toString());return J}function c_(J){if(!URL.canParse(J))throw Error(`invalid URI string: ${JSON.stringify(J)}`);return J}var SJ4,_J4,kJ4,h5="",O$="/",vJ4,iD,Cz0,Tz0;var l_=L1(()=>{SJ4=/^\w[\w\d+.-]*$/,_J4=/^\//,kJ4=/^\/\//;vJ4=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;iD=class iD extends n0{_formatted=null;_fsPath=null;get fsPath(){if(!this._fsPath)this._fsPath=jz0(this,!1);return this._fsPath}toString(J=!1){if(!J){if(!this._formatted)this._formatted=eG1(this,!1);return this._formatted}return eG1(this,!0)}toJSON(){let J={};if(this._fsPath)J.fsPath=this._fsPath,J._sep=Rz0(this.platform);if(this._formatted)J.external=this._formatted;if(J.scheme=this.scheme,J.authority=this.authority,J.path=this.path,J.query=this.query,J.fragment=this.fragment,this.platform)J.platform=this.platform;return J}};Cz0={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};Tz0=/(%[0-9A-Za-z][0-9A-Za-z])+/g});function JZ1(J){if(J==="/")return"/";if(J==="")return".";let Q=J.replace(/\/+$/,"");if(!Q)return".";let Y=Q.lastIndexOf("/");if(Y===-1)return".";if(Y===0)return"/";return Q.slice(0,Y)}function nD(J){let Q=J.replace(/\/+$/,"");if(!Q)return"";let Y=Q.lastIndexOf("/");return Y===-1?Q:Q.slice(Y+1)}function UE(...J){if(J.length===0)return".";let Q="";for(let q of J)if(q)if(Q)Q+="/"+q;else Q=q;if(!Q)return".";let Y=Q.endsWith("/"),X=Q.split("/").filter(Boolean),G=[];for(let q of X)if(q===".."){if(G.length>0&&G[G.length-1]!=="..")G.pop();else if(!Q.startsWith("/"))G.push("..")}else if(q!==".")G.push(q);let Z=Q.startsWith("/")?"/"+G.join("/"):G.join("/");if(!Z)Z=Q.startsWith("/")?"/":".";if(Y&&Z!=="/"&&Z!==".")Z+="/";return Z}function _z0(J,Q,Y="/",X="/",G=!0){function Z(z,U){return G?z===U:z.toLowerCase()===U.toLowerCase()}if(Y==="/")J=J.replaceAll(/\/{2,}/g,"/"),Q=Q.replaceAll(/\/{2,}/g,"/");else J=J.replaceAll(/\\{2,}/g,"\\"),Q=Q.replaceAll(/\\{2,}/g,"\\");if(J!==Y&&J.endsWith(Y))J=J.slice(0,-1);if(Q!==Y&&Q.endsWith(Y))Q=Q.slice(0,-1);if(Z(J,Q))return"";if(!J.startsWith(Y)&&Q.startsWith(Y))return Q;let q=J===Y?[""]:J.split(Y),V=Q===Y?[""]:Q.split(Y),K=0;while(K<q.length&&K<V.length&&Z(q[K],V[K]))K++;let W=q.length-K,H=[];for(let z=0;z<W;z++)H.push("..");return H.push(...V.slice(K)),H.join(X)}function ql(J){let Q=nD(J.replace(/\/+$/,"")),Y=Q.lastIndexOf(".");if(Y===0||Y===-1)return"";return Q.slice(Y)}function JJ(J){try{if(J=o4(J),J.scheme==="file")return J.fsPath}catch{}return J.toString()}var BE=L1(()=>{l_()});function hJ4(J,...Q){return J=o4(J),J.with({path:UE(J.path,...Q)})}function bJ4(J,...Q){let Y=J.path,X=!1;if(Y[0]!==Vl)Y=Vl+Y,X=!0;let G=Y;for(let Z of Q)if(Z.startsWith("/"))G=UE(Z);else G=UE(G,Z);if(G!=="/"&&G.endsWith("/"))G=G.replace(/\/+$/,"");if(X&&G[0]===Vl&&!J.authority)G=G.substring(1);return J.with({path:G})}function gJ4(J){if(J=o4(J),J.path.length===0||J.path===Vl)return J;let Q=JZ1(J.path);if(Q.length===1&&Q===".")Q="";return J.with({path:Q})}function mJ4(J,Q){if(Q.scheme!==J.scheme||(Q.authority??"")!==(J.authority??""))return!1;let Y=Q.scheme==="file"&&Q.path.match(/^\/[A-Za-z]:/),X=Y?Q.path.slice(0,2).toUpperCase()+Q.path.slice(2):Q.path,G=Y?J.path.slice(0,2).toUpperCase()+J.path.slice(2):J.path;return G===X||G.startsWith(X.endsWith("/")?X:`${X}/`)||X.endsWith("/")&&G===X.slice(0,-1)}function uJ4(J,Q){if(J.scheme!==Q.scheme||J.authority!==Q.authority||J.query!==Q.query||J.fragment!==Q.fragment)return null;let Y=J.platform==="windows"?"\\":"/";return _z0(J.path,Q.path,Y,Y)}function pJ4(J,Q){let Y=A6(J),X=A6(Q);if(Y.startsWith("file:///")&&X.startsWith("file:///"))return kz0(Y)===kz0(X);return Y===X}function kz0(J){return J.replace(/^file:\/\/\/([A-Za-z]):/,(Q)=>`file:///${Q.toLowerCase()}:`)}var Vl="/",Z6;var Kl=L1(()=>{BE();l_();Z6={joinPath:hJ4,resolvePath:bJ4,dirname:gJ4,basename:(J)=>nD(o4(J).path),extname:(J)=>ql(o4(J).path),hasPrefix:mJ4,relativePath:uJ4,equalURIs:pJ4}});function Wl(J){Promise.resolve().then(()=>{try{J()}catch(Q){console.error(Q)}})}function yz0(J){let Q=J._cleanup;if(Q===void 0)return;if(J._cleanup=void 0,!Q)return;try{if(typeof Q==="function")Q();else if(Q&&typeof Q.unsubscribe==="function")Q.unsubscribe()}catch(Y){console.error("cleanupSubscription",Y)}}function XZ1(J){J._observer=void 0,J._queue=void 0,J._state="closed"}function cJ4(J){let Q=J._queue;if(!Q)return;J._queue=void 0,J._state="ready";for(let Y of Q)if(xz0(J,Y.type,Y.value),J._state==="closed")break}function xz0(J,Q,Y){J._state="running";let X=J._observer;try{switch(Q){case"next":if(X&&typeof X.next==="function")X.next(Y);break;case"error":if(XZ1(J),X&&typeof X.error==="function")X.error(Y);else throw Y;break;case"complete":if(XZ1(J),X&&typeof X.complete==="function")X.complete();break}}catch(G){console.error("notifySubscription",G)}if(J._state==="closed")yz0(J);else if(J._state==="running")J._state="ready"}function YZ1(J,Q,Y){if(J._state==="closed")return;if(J._state==="buffering"){J._queue=J._queue||[],J._queue.push({type:Q,value:Y});return}if(J._state!=="ready"){J._state="buffering",J._queue=[{type:Q,value:Y}],Wl(()=>cJ4(J));return}xz0(J,Q,Y)}class vz0{_cleanup;_observer;_queue;_state;constructor(J,Q){this._cleanup=void 0,this._observer=J,this._queue=void 0,this._state="initializing";let Y=new fz0(this);try{this._cleanup=Q.call(void 0,Y)}catch(X){Y.error(X)}if(this._state==="initializing")this._state="ready"}get closed(){return this._state==="closed"}unsubscribe(){if(this._state!=="closed")XZ1(this),yz0(this)}}class fz0{_subscription;constructor(J){this._subscription=J}get closed(){return this._subscription._state==="closed"}next(J){YZ1(this._subscription,"next",J)}error(J){YZ1(this._subscription,"error",J)}complete(){YZ1(this._subscription,"complete")}}function b5(J){if(typeof J==="function")J();else if(J&&typeof J.unsubscribe==="function")J.unsubscribe()}class NE{_baseObserver;_pendingPromises;constructor(J){this._baseObserver=J,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch((J)=>this._baseObserver.error(J))}error(J){this._baseObserver.error(J)}schedule(J){let Q=Promise.all(this._pendingPromises),Y=[],X=(Z)=>Y.push(Z),G=Promise.resolve().then(async()=>{await Q,await J(X),this._pendingPromises.delete(G);for(let Z of Y)this._baseObserver.next(Z)}).catch((Z)=>{this._pendingPromises.delete(G),this._baseObserver.error(Z)});this._pendingPromises.add(G)}}function GZ1(J){return J&&typeof J.subscribe==="function"&&typeof J[Symbol.observable]==="function"}function ZZ1(J){if(GZ1(J))return J;return G0.of(J)}var G0;var DE=L1(()=>{if(!Symbol.observable)Symbol.observable=Symbol("observable");G0=class G0{_subscriber;constructor(J){if(!(this instanceof G0))throw TypeError("Observable cannot be called as a function");if(typeof J!=="function")throw TypeError("Observable initializer must be a function");this._subscriber=J}subscribe(J,Q,Y){if(typeof J!=="object"||J===null)J={next:J,error:Q,complete:Y};return new vz0(J,this._subscriber)}pipe(J,...Q){let Y=this;for(let X of[J,...Q])Y=X(Y);return Y}[Symbol.observable](){return this}static from(J){let Q=typeof this==="function"?this:G0;if(J==null)throw TypeError(J+" is not an object");let Y=J[Symbol.observable];if(typeof Y==="function"){let G=Y.call(J);if(Object(G)!==G)throw TypeError(G+" is not an object");if(G instanceof G0)return G;return new Q((Z)=>G.subscribe(Z))}let X=J[Symbol.iterator];if(typeof X==="function")return new Q((G)=>{Wl(()=>{if(G.closed)return;for(let Z of X.call(J))if(G.next(Z),G.closed)return;G.complete()})});if(Array.isArray(J))return new Q((G)=>{Wl(()=>{if(G.closed)return;for(let Z of J)if(G.next(Z),G.closed)return;G.complete()})});throw TypeError(J+" is not observable")}static of(...J){return new(typeof this==="function"?this:G0)((Y)=>{Wl(()=>{if(Y.closed)return;for(let X of J)if(Y.next(X),Y.closed)return;Y.complete()})})}static get[Symbol.species](){return this}}});var y4,g5;var Hl=L1(()=>{DE();y4=class y4 extends G0{_observers=new Set;constructor(){super((J)=>{return this._observers.add(J),()=>this._observers.delete(J)})}next(J){for(let Q of this._observers)Q.next(J)}error(J){for(let Q of this._observers)Q.error(J)}complete(){for(let J of this._observers)J.complete()}};g5=class g5 extends y4{currentValue;constructor(J){super();this.currentValue=J}next(J){this.currentValue=J,super.next(J)}subscribe(J,Q,Y){if(typeof J!=="object"||J===null){let X={};if(J)X.next=J;if(Q)X.error=Q;if(Y)X.complete=Y;J=X}return J.next?.(this.currentValue),super.subscribe(J)}getValue(){return this.currentValue}}});var $Z1,i_;var hz0=L1(()=>{DE();Hl();$Z1=class $Z1 extends Set{subject=new g5(this);add(J){return super.add(J),this.subject.next(this),this}delete(J){let Q=super.delete(J);if(Q)this.subject.next(this);return Q}clear(){super.clear(),this.subject.next(this)}get observable(){return G0.from(this.subject)}dispose(){this.subject.complete()}};i_=class i_ extends Map{subject=new g5(this);set(J,Q){return super.set(J,Q),this.subject.next(this),this}delete(J){let Q=super.delete(J);if(Q)this.subject.next(this);return Q}clear(){super.clear(),this.subject.next(this)}get observable(){return G0.from(this.subject)}dispose(){this.subject.complete()}}});function zl(J,Q){if(J===Q)return!0;if(J==null||Q==null||typeof J!=="object"||typeof Q!=="object")return!1;let Y=Array.isArray(J),X=Array.isArray(Q);if(Y!==X)return!1;if(Y&&X)return J.length===Q.length&&J.every((Z,q)=>zl(Z,Q[q]));let G=new Set([...Object.keys(J),...Object.keys(Q)]);for(let Z of G)if(!zl(J[Z],Q[Z]))return!1;return!0}function qZ1(J){return{dispose:J.unsubscribe.bind(J)}}function gz0(...J){return new G0((Q)=>{for(let Y of J)Q.next(Y);Q.complete()})}async function M6(J,Q){return new Promise((Y,X)=>{let G=void 0,Z=()=>{G?.unsubscribe(),X(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",Z,{once:!0}),G=J.subscribe({next:(q)=>{G?.unsubscribe(),Q?.removeEventListener("abort",Z),Y(q)},error:(q)=>{Q?.removeEventListener("abort",Z),X(q)},complete:()=>{Q?.removeEventListener("abort",Z),X("Observable completed without emitting a value")}})})}async function SF(J,Q){return new Promise((Y,X)=>{let G,Z=!1,q=void 0,V=()=>{q?.unsubscribe(),X(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",V,{once:!0}),q=J.subscribe({next:(K)=>{G=K,Z=!0},error:(K)=>{Q?.removeEventListener("abort",V),X(K)},complete:()=>{if(Q?.removeEventListener("abort",V),Z)Y(G);else X("Observable completed without emitting a value")}})})}async function mz0(J,Q){return new Promise((Y,X)=>{let G=J.subscribe({error:X,complete:()=>Y()});Q?.addEventListener("abort",()=>{G.unsubscribe(),X(new DOMException("Aborted","AbortError"))},{once:!0})})}function C3(J){return new G0((Q)=>{J.then((Y)=>{Q.next(Y),Q.complete()}).catch((Y)=>{Q.error(Y)})})}function e6(J){return new G0((Q)=>{let Y=!1,X=new AbortController,G=X.signal;return(async()=>{try{G?.throwIfAborted();let q=await J(G);if(G?.throwIfAborted(),!Y)Q.next(q),Q.complete()}catch(q){if(!Y)if(G.aborted)Q.complete();else Q.error(q)}})(),()=>{Y=!0,X.abort()}})}function q6(J){return(Q)=>{return new G0((Y)=>{let X=new NE(Y),G=0,Z=Q.subscribe({complete(){X.complete()},error(q){X.error(q)},next(q){X.schedule(async(V)=>{let K=await J(q,G);G++,V(K)})}});return()=>b5(Z)})}}function Fl(J){return new G0((Q)=>{let Y=0,X=setInterval(()=>{Q.next(Y++)},J);return()=>clearInterval(X)})}function yW(...J){return new G0((Q)=>{let Y=0,X=J.map((G)=>G.subscribe({next:(Z)=>Q.next(Z),error:(Z)=>Q.error(Z),complete:()=>{if(Y++,Y===J.length)Q.complete()}}));return()=>{uz0(X)}})}function u8(...J){if(J.length===0)return n_;return new G0((Q)=>{let Y=Array(J.length),X=Array(J.length).fill(0),G=Array(J.length).fill(!1),Z=0,q=[],V=new NE(Q);for(let K=0;K<J.length;K++){let W=J[K];q.push(W.subscribe({next(H){Y[K]=H,G[K]=!0;let z=++X[K];if(G.every(Boolean))V.schedule(async(U)=>{if(X[K]===z)U([...Y])})},error(H){V.error(H)},complete(){if(Z++,Z===J.length)V.complete()}}))}return()=>{uz0(q)}})}function o8(J){let Y=J?.shouldCountRefs??!0,X=lJ4++,G=(Z,...q)=>{};return(Z)=>{let q=new y4,V=null,K=!1,W,H=0;return new G0((z)=>{if(H++,K)G("new subscriber, emitting buffered value",W),z.next(W);else G("new subscriber, no buffered value to emit");if(!V)V=Z.subscribe({next:(N)=>{K=!0,W=N,q.next(N)},error:(N)=>q.error(N),complete:()=>q.complete()});let U=q.subscribe(z);return()=>{if(H--,U.unsubscribe(),Y&&H===0){if(V)b5(V),V=null;K=!1}}})}}function uz0(J){for(let Q of J)if(Q)b5(Q)}function _F(J){return(Q)=>{return new G0((Y)=>{let X=Q.subscribe({next:(Z)=>Y.next(Z),error:(Z)=>Y.error(Z),complete:()=>Y.complete()}),G=J.subscribe({next:()=>{Y.complete(),X.unsubscribe(),G.unsubscribe()},error:(Z)=>{Y.error(Z),X.unsubscribe()}});return()=>{X.unsubscribe(),G.unsubscribe()}})}}function wQ(J){return(Q)=>{return new G0((Y)=>{let X,G=Q.subscribe({next(Z){X=Z,Y.next(Z)},error(Z){Y.error(Z)},complete(){Y.complete()}});return()=>{b5(G),J(X)}})}}function x4(J=zl){return(Q)=>{return new G0((Y)=>{let X=bz0,G=new NE(Y),Z=Q.subscribe({complete(){G.complete()},error(q){G.error(q)},next(q){G.schedule(async(V)=>{if(X===bz0||!J(X,q))X=q,V(q)})}});return()=>b5(Z)})}}function VX(J){return iJ4(typeof J==="function"?{next:J}:J)}function iJ4(J){return(Q)=>new G0((Y)=>{let X=typeof J==="function"?J():J,G=Q.subscribe({next(Z){if(X.next)try{X.next(Z)}catch(q){Y.error(q);return}Y.next(Z)},error(Z){if(X.error)try{X.error(Z)}catch(q){Y.error(q);return}Y.error(Z)},complete(){if(X.complete)try{X.complete()}catch(Z){Y.error(Z);return}Y.complete()}});return()=>b5(G)})}function kF(J){return(Q)=>{return new G0((Y)=>{let X=!1,G=Q.subscribe({next:(q)=>{X=!0,clearTimeout(Z),Y.next(q)},error:(q)=>{clearTimeout(Z),Y.error(q)},complete:()=>{clearTimeout(Z),Y.complete()}}),Z=setTimeout(()=>{if(!X)G.unsubscribe(),Y.error(new Ul(`Operation timed out after ${J}ms`))},J);return()=>{clearTimeout(Z),G.unsubscribe()}})}}function k9(J){return(Q)=>new G0((Y)=>{let X;try{Y.next(J),X=Q.subscribe({next(G){Y.next(G)},error(G){Y.error(G)},complete(){Y.complete()}})}catch(G){Y.error(G)}return()=>{if(X)b5(X)}})}function ME(J){return(Q)=>new G0((Y)=>{let X=0,G=Q.subscribe({next(Z){if(X<J){if(Y.next(Z),X++,X===J)Y.complete(),b5(G)}},error(Z){Y.error(Z)},complete(){Y.complete()}});return()=>{b5(G)}})}function pz0(J){return(Q)=>new G0((Y)=>{let X=0,G=Q.subscribe({next(Z){if(X>=J)Y.next(Z);else X++},error(Z){Y.error(Z)},complete(){Y.complete()}});return()=>{b5(G)}})}function VZ1(J){return(Q)=>{return new G0((Y)=>{let X=0,G=new Set,Z=!1,q=()=>{if(Z&&G.size===0)Y.complete()},V=Q.subscribe({next(K){let H=J(K,X++).subscribe({next(z){Y.next(z)},error(z){Y.error(z)},complete(){G.delete(H),q()}});G.add(H)},error(K){Y.error(K)},complete(){Z=!0,q()}});return()=>{b5(V);for(let K of G)if(K)b5(K)}})}}function r4(J){return(Q)=>{return new G0((Y)=>{let X=0,G=null,Z=!1,q=()=>{if(Z&&!G)Y.complete()},V=Q.subscribe({next(K){if(G)b5(G),G=null;let W;try{W=J(K,X++)}catch(H){Y.error(H);return}G=W.subscribe({next(H){Y.next(H)},error(H){Y.error(H)},complete(){G=null,q()}})},error(K){Y.error(K)},complete(){Z=!0,q()}});return()=>{if(b5(V),G)b5(G)}})}}function w$(J){return(Q)=>new G0((Y)=>{let X=null,G=null,Z=!1,q=Q.subscribe({next:(V)=>{if(G=V,Z=!0,X===null)X=setTimeout(()=>{if(Z)Y.next(G),Z=!1;X=null},J)},error:(V)=>Y.error(V),complete:()=>{if(X!==null)clearTimeout(X);if(Z)Y.next(G);Y.complete()}});return()=>{if(b5(q),X!==null)clearTimeout(X)}})}function a_(J,Q){if(!Q.leading||!Q.trailing)throw Error("leading and trailing must be true");return(Y)=>new G0((X)=>{let G=0,Z=null,q=null,V=!1,K=Y.subscribe({next:(W)=>{let H=Date.now();if(q=W,V=!0,H-G>=J)X.next(W),G=H,V=!1;else if(Z===null)Z=setTimeout(()=>{if(V)X.next(q),G=Date.now(),V=!1;Z=null},J-(H-G));if(G===0)X.next(W),G=H,V=!1},error:(W)=>X.error(W),complete:()=>{if(Z!==null)clearTimeout(Z);if(V)X.next(q);X.complete()}});return()=>{if(b5(K),Z!==null)clearTimeout(Z)}})}function aD(...J){return new G0((Q)=>{let Y=0,X=null;function G(){if(Y>=J.length){Q.complete();return}X=J[Y].subscribe({next:(q)=>Q.next(q),error:(q)=>Q.error(q),complete:()=>{Y++,G()}})}return G(),()=>{if(X)b5(X)}})}function KX(J){return(Q)=>new G0((Y)=>{let X=0,G=!1,Z=null,q=Q.subscribe({next(V){try{let K=J(V,X++);if(Z)b5(Z);Z=K.subscribe({next(W){Y.next(W)},error(W){Y.error(W)},complete(){if(Z=null,G&&!Z)Y.complete()}})}catch(K){Y.error(K)}},error(V){Y.error(V)},complete(){if(G=!0,!Z)Y.complete()}});return()=>{if(b5(q),Z)b5(Z)}})}function o_({onSubscribe:J,onUnsubscribe:Q}){return(Y)=>new G0((X)=>{J?.();let G=Y.subscribe(X);return()=>{b5(G),Q?.()}})}function yF(J){return(Q)=>G0.from(Q).pipe(r4((Y)=>e6((X)=>J(Y,X))))}function Y3(J){return(Q)=>new G0((Y)=>{let X,G=Q.subscribe({next(Z){Y.next(Z)},error(Z){try{X=J(Z).subscribe({next(V){Y.next(V)},error(V){Y.error(V)},complete(){Y.complete()}})}catch(q){Y.error(q)}},complete(){Y.complete()}});return()=>{if(b5(G),X)b5(X)}})}function R7(J){return(Q)=>{return new G0((Y)=>{let X=Q.subscribe({next(G){if(J(G))Y.next(G)},error(G){Y.error(G)},complete(){Y.complete()}});return()=>b5(X)})}}function dz0(J,Q){return(Y)=>{return new G0((X)=>{let G,Z=0,q=new NE(X),V=Y.subscribe({complete(){q.complete()},error(K){q.error(K)},next(K){q.schedule(async(W)=>{G=await J(Z===0?typeof Q>"u"?K:Q:G,K,Z++),W(G)})}});return()=>b5(V)})}}var n_,fG,yh8,lJ4=0,bz0,Ul;var KZ1=L1(()=>{DE();Hl();n_=new G0((J)=>{J.complete()}),fG=new G0(()=>{});yh8=Symbol("noInitialValue");bz0={};Ul=class Ul extends Error{constructor(J="Timeout has occurred"){super(J);this.name="TimeoutError"}}});function oD(J,Q){return(Y)=>{return G0.from(Y).pipe(r4((X)=>X===QJ?G0.of(QJ):J(X).pipe(Y3((G)=>G0.of(G instanceof Error?G:Error(G))),k9(QJ))),o8(Q))}}function nJ4(){return(J)=>G0.from(J).pipe(R7((Q)=>Q!==QJ))}async function r_(J,Q){let Y=await M6(G0.from(J).pipe(nJ4()),Q);if(Y instanceof Error)throw Y;return Y}var QJ;var cz0=L1(()=>{DE();KZ1();QJ=Symbol.for("@@pendingOperation")});var o0=L1(()=>{hz0();DE();cz0();KZ1();Hl()});var H4=L1(()=>{l_();Kl();BE()});import{promises as aJ4}from"node:fs";import*as rD from"node:path";async function lz0(J){try{let Q=await aJ4.open(J,"r");try{let Y=Buffer.alloc(128);await Q.read(Y,0,128,0);let X=Y.toString("utf-8").split(`
48
- `)[0];if(!X?.startsWith("#!"))return{interpreter:null,isValid:!1};let G=X.slice(2).trim();if(!G)return{interpreter:null,isValid:!1};let Z=G.split(/\s+/).filter((q)=>q.length>0);if(Z[0]?.endsWith("/env")&&Z.length>1)return{interpreter:Z.slice(1),isValid:!0};return{interpreter:Z,isValid:!0}}finally{await Q.close()}}catch{return{interpreter:null,isValid:!1}}}function iz0(J,Q){let Y=(J&73)!==0;if(process.platform==="win32"){let X=rD.extname(Q).toLowerCase();return Y||[".exe",".bat",".cmd",".ps1"].includes(X)}return Y}function nz0(J){return rD.extname(J).toLowerCase()===".md"}function az0(J){let Q=J.replace(/\\/g,"/"),Y=rD.basename(Q);return rD.basename(Y,rD.extname(Y))}function oz0(J){return/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(J)&&J.length>0}var rz0=()=>{};var JF0={};a8(JF0,{CommandDiscovery:()=>ez0});import*as tz0 from"node:fs";import{promises as Bl}from"node:fs";import{homedir as sz0}from"node:os";import*as WX from"node:path";function HZ1(J,Q,Y){return Promise.race([J,new Promise((X,G)=>setTimeout(()=>G(Error(`${Y} timed out after ${Q}ms`)),Q))])}class ez0{config;workspaceRoots;watchFactory;debounceMs;changes=new y4;watchers=new Map;debounceTimer;disposed=!1;constructor(J,Q,Y={}){this.config=J,this.workspaceRoots=Q,this.watchFactory=Y.watchFactory??oJ4,this.debounceMs=Y.debounceMs??200}get commandChanges(){return this.changes}async discoverCommands(){if(this.disposed)return[];try{let[J,Q]=await Promise.all([this.discoverWorkspaceCommands(),this.discoverGlobalCommands()]),Y=new Map;for(let G of Q)Y.set(`${G.source}:${G.name}`,G);for(let G of J)Y.set(`${G.source}:${G.name}`,G);let X=Array.from(Y.values());if(f.debug("Discovered commands",{count:X.length,workspace:J.length,global:Q.length}),this.config.enableWatching)await this.setupWatching();return X}catch(J){return f.error("Failed to discover commands",{error:J}),[]}}async discoverWorkspaceCommands(){let J=[];for(let Q of this.workspaceRoots)for(let Y of this.config.workspacePaths){let X=Z6.joinPath(Q,Y),G=await this.discoverCommandsInDirectory(X,"workspace");J.push(...G)}return J}async discoverGlobalCommands(){let J=[];for(let Q of this.config.globalPaths){let Y=this.resolveGlobalPath(Q),X=n0.file(Y),G=await this.discoverCommandsInDirectory(X,"global");J.push(...G)}return J}async discoverCommandsInDirectory(J,Q){try{let Y=J.fsPath;try{await HZ1(Bl.access(Y),WZ1,"directory access")}catch{return[]}let G=(await HZ1(Bl.readdir(Y,{withFileTypes:!0}),WZ1,"directory read")).filter((q)=>q.isFile()),Z=[];for(let q of G){let V=WX.join(Y,q.name),K=await this.createCommand(V,Q);if(K)Z.push(K)}return f.debug(`Discovered ${Z.length} commands in ${Q} directory`,{directory:Y,commands:Z.map((q)=>q.name)}),Z}catch(Y){return f.warn(`Failed to discover commands in directory: ${J.fsPath}`,{error:Y}),[]}}ignoreCommandName(J){return J.startsWith(".")||J==="README.md"}async createCommand(J,Q){try{let Y=await Bl.stat(J),X=WX.basename(J);if(this.ignoreCommandName(X))return null;let G=az0(X);if(!oz0(G))return f.warn(`Invalid command name: ${G}`,{filePath:J}),null;if(nz0(X))return this.createMarkdownCommand(J,Y,G,Q);else return this.createExecutableCommand(J,Y,G,Q)}catch(Y){return f.warn(`Failed to process file: ${J}`,{error:Y}),null}}async createMarkdownCommand(J,Q,Y,X){return{kind:"markdown",name:Y,filePath:J,sourceDirectory:WX.dirname(J),lastModified:Q.mtimeMs,available:!0,unavailableReason:void 0,source:X}}async createExecutableCommand(J,Q,Y,X){let G=WX.basename(J),Z=iz0(Q.mode,G),q=await lz0(J),V=WX.extname(G);if(!Z&&!q.isValid&&!this.isNativeBinary(V))return f.debug(`Skipping non-executable file without shebang: ${J}`),null;let K=Z&&(q.isValid||this.isNativeBinary(V)),W=this.getExecutableUnavailableReason(Z,q.isValid,V);return{kind:"executable",name:Y,filePath:J,sourceDirectory:WX.dirname(J),lastModified:Q.mtimeMs,isExecutable:Z,interpreter:q.interpreter,extension:V,available:K,unavailableReason:W,source:X}}isNativeBinary(J){if(process.platform==="win32")return[".exe",".bat",".cmd",".ps1"].includes(J.toLowerCase());return J===""}getExecutableUnavailableReason(J,Q,Y){let X=this.isNativeBinary(Y);if(!J)return"File is not executable (missing execute permissions)";if(!Q&&!X)return"Missing shebang and not a recognized binary type";return}resolveGlobalPath(J){if(J.startsWith("~/"))return WX.join(sz0(),J.slice(2));if(J.startsWith("~/.config/amp/")){let Q=CF||WX.join(sz0(),".config");return WX.join(Q,J.slice(10))}return J}async setupWatching(){if(this.disposed)return;this.stopWatching();let J=new Set;for(let Q of this.workspaceRoots)for(let Y of this.config.workspacePaths){let X=Z6.joinPath(Q,Y);J.add(X.fsPath)}for(let Q of this.config.globalPaths){let Y=this.resolveGlobalPath(Q);J.add(Y)}for(let Q of J)await this.watchDirectory(Q)}async watchDirectory(J){try{await HZ1(Bl.access(J),WZ1,"watcher access check");try{let Q=this.watchFactory(J,(Y,X)=>{f.debug("Command directory change detected",{directory:J,eventType:Y,filename:X}),this.scheduleRefresh()});Q.on("error",(Y)=>{f.debug("transient file watcher error",{error:Y}),this.scheduleRefresh()}),this.watchers.set(J,Q),f.debug("Started watching command directory",{directory:J})}catch(Q){f.warn("Failed to setup file watcher",{directory:J,error:Q})}}catch(Q){f.debug("Skipping watch for non-existent directory",{directory:J})}}scheduleRefresh(){if(this.disposed)return;if(this.debounceTimer)clearTimeout(this.debounceTimer);this.debounceTimer=setTimeout(async()=>{try{let[J,Q]=await Promise.all([this.discoverWorkspaceCommands(),this.discoverGlobalCommands()]),Y=new Map;for(let G of Q)Y.set(`${G.source}:${G.name}`,G);for(let G of J)Y.set(`${G.source}:${G.name}`,G);let X=Array.from(Y.values());f.debug("Refreshed commands during file watch",{count:X.length,workspace:J.length,global:Q.length}),this.changes.next(X)}catch(J){f.warn("Failed to refresh commands during file watch",{error:J})}},this.debounceMs)}stopWatching(){try{for(let[J,Q]of this.watchers)try{Q.close(),f.debug("Stopped watching command directory",{directory:J})}catch(Y){f.warn("Failed to close watcher",{directory:J,error:Y})}this.watchers.clear()}finally{if(this.debounceTimer)clearTimeout(this.debounceTimer),this.debounceTimer=void 0}}dispose(){this.disposed=!0;try{this.stopWatching()}catch(J){f.warn("Error during command discovery cleanup",{error:J})}}}var WZ1=5000,oJ4=(J,Q)=>tz0.watch(J,Q);var QF0=L1(()=>{H4();o0();HE();L0();rz0()});function Z5(J,Q,Y=Q+"s"){return J===1?Q:Y}function xF(J){let Q=typeof J==="string"?J:J.toString();return Q===zY||Q===zY.slice(0,-1)}function OE(J){return xF(J)?zY:J}var UQ4,zY,BQ4,hb8;var vF=L1(()=>{UQ4=new URL("https://ampcode.com/"),zY=UQ4.toString(),BQ4=new URL("https://api.anthropic.com/"),hb8=BQ4.toString()});var B9,wZ1,y6,OV=(J)=>{switch(typeof J){case"undefined":return y6.undefined;case"string":return y6.string;case"number":return Number.isNaN(J)?y6.nan:y6.number;case"boolean":return y6.boolean;case"function":return y6.function;case"bigint":return y6.bigint;case"symbol":return y6.symbol;case"object":if(Array.isArray(J))return y6.array;if(J===null)return y6.null;if(J.then&&typeof J.then==="function"&&J.catch&&typeof J.catch==="function")return y6.promise;if(typeof Map<"u"&&J instanceof Map)return y6.map;if(typeof Set<"u"&&J instanceof Set)return y6.set;if(typeof Date<"u"&&J instanceof Date)return y6.date;return y6.object;default:return y6.unknown}};var Qk=L1(()=>{(function(J){J.assertEqual=(G)=>{};function Q(G){}J.assertIs=Q;function Y(G){throw Error()}J.assertNever=Y,J.arrayToEnum=(G)=>{let Z={};for(let q of G)Z[q]=q;return Z},J.getValidEnumValues=(G)=>{let Z=J.objectKeys(G).filter((V)=>typeof G[G[V]]!=="number"),q={};for(let V of Z)q[V]=G[V];return J.objectValues(q)},J.objectValues=(G)=>{return J.objectKeys(G).map(function(Z){return G[Z]})},J.objectKeys=typeof Object.keys==="function"?(G)=>Object.keys(G):(G)=>{let Z=[];for(let q in G)if(Object.prototype.hasOwnProperty.call(G,q))Z.push(q);return Z},J.find=(G,Z)=>{for(let q of G)if(Z(q))return q;return},J.isInteger=typeof Number.isInteger==="function"?(G)=>Number.isInteger(G):(G)=>typeof G==="number"&&Number.isFinite(G)&&Math.floor(G)===G;function X(G,Z=" | "){return G.map((q)=>typeof q==="string"?`'${q}'`:q).join(Z)}J.joinValues=X,J.jsonStringifyReplacer=(G,Z)=>{if(typeof Z==="bigint")return Z.toString();return Z}})(B9||(B9={}));(function(J){J.mergeShapes=(Q,Y)=>{return{...Q,...Y}}})(wZ1||(wZ1={}));y6=B9.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var z6,NQ4=(J)=>{return JSON.stringify(J,null,2).replace(/"([^"]+)":/g,"$1:")},FY;var Al=L1(()=>{Qk();z6=B9.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);FY=class FY extends Error{get errors(){return this.issues}constructor(J){super();this.issues=[],this.addIssue=(Y)=>{this.issues=[...this.issues,Y]},this.addIssues=(Y=[])=>{this.issues=[...this.issues,...Y]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=J}format(J){let Q=J||function(G){return G.message},Y={_errors:[]},X=(G)=>{for(let Z of G.issues)if(Z.code==="invalid_union")Z.unionErrors.map(X);else if(Z.code==="invalid_return_type")X(Z.returnTypeError);else if(Z.code==="invalid_arguments")X(Z.argumentsError);else if(Z.path.length===0)Y._errors.push(Q(Z));else{let q=Y,V=0;while(V<Z.path.length){let K=Z.path[V];if(V!==Z.path.length-1)q[K]=q[K]||{_errors:[]};else q[K]=q[K]||{_errors:[]},q[K]._errors.push(Q(Z));q=q[K],V++}}};return X(this),Y}static assert(J){if(!(J instanceof FY))throw Error(`Not a ZodError: ${J}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B9.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(J=(Q)=>Q.message){let Q={},Y=[];for(let X of this.issues)if(X.path.length>0){let G=X.path[0];Q[G]=Q[G]||[],Q[G].push(J(X))}else Y.push(J(X));return{formErrors:Y,fieldErrors:Q}}get formErrors(){return this.flatten()}};FY.create=(J)=>{return new FY(J)}});var DQ4=(J,Q)=>{let Y;switch(J.code){case z6.invalid_type:if(J.received===y6.undefined)Y="Required";else Y=`Expected ${J.expected}, received ${J.received}`;break;case z6.invalid_literal:Y=`Invalid literal value, expected ${JSON.stringify(J.expected,B9.jsonStringifyReplacer)}`;break;case z6.unrecognized_keys:Y=`Unrecognized key(s) in object: ${B9.joinValues(J.keys,", ")}`;break;case z6.invalid_union:Y="Invalid input";break;case z6.invalid_union_discriminator:Y=`Invalid discriminator value. Expected ${B9.joinValues(J.options)}`;break;case z6.invalid_enum_value:Y=`Invalid enum value. Expected ${B9.joinValues(J.options)}, received '${J.received}'`;break;case z6.invalid_arguments:Y="Invalid function arguments";break;case z6.invalid_return_type:Y="Invalid function return type";break;case z6.invalid_date:Y="Invalid date";break;case z6.invalid_string:if(typeof J.validation==="object")if("includes"in J.validation){if(Y=`Invalid input: must include "${J.validation.includes}"`,typeof J.validation.position==="number")Y=`${Y} at one or more positions greater than or equal to ${J.validation.position}`}else if("startsWith"in J.validation)Y=`Invalid input: must start with "${J.validation.startsWith}"`;else if("endsWith"in J.validation)Y=`Invalid input: must end with "${J.validation.endsWith}"`;else B9.assertNever(J.validation);else if(J.validation!=="regex")Y=`Invalid ${J.validation}`;else Y="Invalid";break;case z6.too_small:if(J.type==="array")Y=`Array must contain ${J.exact?"exactly":J.inclusive?"at least":"more than"} ${J.minimum} element(s)`;else if(J.type==="string")Y=`String must contain ${J.exact?"exactly":J.inclusive?"at least":"over"} ${J.minimum} character(s)`;else if(J.type==="number")Y=`Number must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${J.minimum}`;else if(J.type==="bigint")Y=`Number must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${J.minimum}`;else if(J.type==="date")Y=`Date must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(J.minimum))}`;else Y="Invalid input";break;case z6.too_big:if(J.type==="array")Y=`Array must contain ${J.exact?"exactly":J.inclusive?"at most":"less than"} ${J.maximum} element(s)`;else if(J.type==="string")Y=`String must contain ${J.exact?"exactly":J.inclusive?"at most":"under"} ${J.maximum} character(s)`;else if(J.type==="number")Y=`Number must be ${J.exact?"exactly":J.inclusive?"less than or equal to":"less than"} ${J.maximum}`;else if(J.type==="bigint")Y=`BigInt must be ${J.exact?"exactly":J.inclusive?"less than or equal to":"less than"} ${J.maximum}`;else if(J.type==="date")Y=`Date must be ${J.exact?"exactly":J.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(J.maximum))}`;else Y="Invalid input";break;case z6.custom:Y="Invalid input";break;case z6.invalid_intersection_types:Y="Intersection results could not be merged";break;case z6.not_multiple_of:Y=`Number must be a multiple of ${J.multipleOf}`;break;case z6.not_finite:Y="Number must be finite";break;default:Y=Q.defaultError,B9.assertNever(J)}return{message:Y}},xW;var EZ1=L1(()=>{Al();Qk();xW=DQ4});function MQ4(J){HF0=J}function wE(){return HF0}var HF0;var Ol=L1(()=>{EZ1();HF0=xW});function o6(J,Q){let Y=wE(),X=Yk({issueData:Q,data:J.data,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Y,Y===xW?void 0:xW].filter((G)=>!!G)});J.common.issues.push(X)}class YJ{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(J,Q){let Y=[];for(let X of Q){if(X.status==="aborted")return s4;if(X.status==="dirty")J.dirty();Y.push(X.value)}return{status:J.value,value:Y}}static async mergeObjectAsync(J,Q){let Y=[];for(let X of Q){let G=await X.key,Z=await X.value;Y.push({key:G,value:Z})}return YJ.mergeObjectSync(J,Y)}static mergeObjectSync(J,Q){let Y={};for(let X of Q){let{key:G,value:Z}=X;if(G.status==="aborted")return s4;if(Z.status==="aborted")return s4;if(G.status==="dirty")J.dirty();if(Z.status==="dirty")J.dirty();if(G.value!=="__proto__"&&(typeof Z.value<"u"||X.alwaysSet))Y[G.value]=Z.value}return{status:J.value,value:Y}}}var Yk=(J)=>{let{data:Q,path:Y,errorMaps:X,issueData:G}=J,Z=[...Y,...G.path||[]],q={...G,path:Z};if(G.message!==void 0)return{...G,path:Z,message:G.message};let V="",K=X.filter((W)=>!!W).slice().reverse();for(let W of K)V=W(q,{data:Q,defaultError:V}).message;return{...G,path:Z,message:V}},LQ4,s4,tD=(J)=>({status:"dirty",value:J}),lJ=(J)=>({status:"valid",value:J}),wl=(J)=>J.status==="aborted",El=(J)=>J.status==="dirty",fF=(J)=>J.status==="valid",EE=(J)=>typeof Promise<"u"&&J instanceof Promise;var IZ1=L1(()=>{Ol();EZ1();LQ4=[];s4=Object.freeze({status:"aborted"})});var zF0=()=>{};var L4;var FF0=L1(()=>{(function(J){J.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},J.toString=(Q)=>typeof Q==="string"?Q:Q?.message})(L4||(L4={}))});class T${constructor(J,Q,Y,X){this._cachedPath=[],this.parent=J,this.data=Q,this._path=Y,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function S8(J){if(!J)return{};let{errorMap:Q,invalid_type_error:Y,required_error:X,description:G}=J;if(Q&&(Y||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:G};return{errorMap:(q,V)=>{let{message:K}=J;if(q.code==="invalid_enum_value")return{message:K??V.defaultError};if(typeof V.data>"u")return{message:K??X??V.defaultError};if(q.code!=="invalid_type")return{message:V.defaultError};return{message:K??Y??V.defaultError}},description:G}}class r8{get description(){return this._def.description}_getType(J){return OV(J.data)}_getOrReturnCtx(J,Q){return Q||{common:J.parent.common,data:J.data,parsedType:OV(J.data),schemaErrorMap:this._def.errorMap,path:J.path,parent:J.parent}}_processInputParams(J){return{status:new YJ,ctx:{common:J.parent.common,data:J.data,parsedType:OV(J.data),schemaErrorMap:this._def.errorMap,path:J.path,parent:J.parent}}}_parseSync(J){let Q=this._parse(J);if(EE(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync(J){let Q=this._parse(J);return Promise.resolve(Q)}parse(J,Q){let Y=this.safeParse(J,Q);if(Y.success)return Y.data;throw Y.error}safeParse(J,Q){let Y={common:{issues:[],async:Q?.async??!1,contextualErrorMap:Q?.errorMap},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)},X=this._parseSync({data:J,path:Y.path,parent:Y});return UF0(Y,X)}"~validate"(J){let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)};if(!this["~standard"].async)try{let Y=this._parseSync({data:J,path:[],parent:Q});return fF(Y)?{value:Y.value}:{issues:Q.common.issues}}catch(Y){if(Y?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:J,path:[],parent:Q}).then((Y)=>fF(Y)?{value:Y.value}:{issues:Q.common.issues})}async parseAsync(J,Q){let Y=await this.safeParseAsync(J,Q);if(Y.success)return Y.data;throw Y.error}async safeParseAsync(J,Q){let Y={common:{issues:[],contextualErrorMap:Q?.errorMap,async:!0},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)},X=this._parse({data:J,path:Y.path,parent:Y}),G=await(EE(X)?X:Promise.resolve(X));return UF0(Y,G)}refine(J,Q){let Y=(X)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(X);else return Q};return this._refinement((X,G)=>{let Z=J(X),q=()=>G.addIssue({code:z6.custom,...Y(X)});if(typeof Promise<"u"&&Z instanceof Promise)return Z.then((V)=>{if(!V)return q(),!1;else return!0});if(!Z)return q(),!1;else return!0})}refinement(J,Q){return this._refinement((Y,X)=>{if(!J(Y))return X.addIssue(typeof Q==="function"?Q(Y,X):Q),!1;else return!0})}_refinement(J){return new R$({schema:this,typeName:q8.ZodEffects,effect:{type:"refinement",refinement:J}})}superRefine(J){return this._refinement(J)}constructor(J){this.spa=this.safeParseAsync,this._def=J,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(Q)=>this["~validate"](Q)}}optional(){return P$.create(this,this._def)}nullable(){return fW.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I$.create(this)}promise(){return YM.create(this,this._def)}or(J){return jE.create([this,J],this._def)}and(J){return SE.create(this,J,this._def)}transform(J){return new R$({...S8(this._def),schema:this,typeName:q8.ZodEffects,effect:{type:"transform",transform:J}})}default(J){let Q=typeof J==="function"?J:()=>J;return new xE({...S8(this._def),innerType:this,defaultValue:Q,typeName:q8.ZodDefault})}brand(){return new Pl({typeName:q8.ZodBranded,type:this,...S8(this._def)})}catch(J){let Q=typeof J==="function"?J:()=>J;return new vE({...S8(this._def),innerType:this,catchValue:Q,typeName:q8.ZodCatch})}describe(J){return new this.constructor({...this._def,description:J})}pipe(J){return Vk.create(this,J)}readonly(){return fE.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function DF0(J){let Q="[0-5]\\d";if(J.precision)Q=`${Q}\\.\\d{${J.precision}}`;else if(J.precision==null)Q=`${Q}(\\.\\d+)?`;let Y=J.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${Q})${Y}`}function fQ4(J){return new RegExp(`^${DF0(J)}$`)}function MF0(J){let Q=`${NF0}T${DF0(J)}`,Y=[];if(Y.push(J.local?"Z?":"Z"),J.offset)Y.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${Y.join("|")})`,new RegExp(`^${Q}$`)}function hQ4(J,Q){if((Q==="v4"||!Q)&&jQ4.test(J))return!0;if((Q==="v6"||!Q)&&_Q4.test(J))return!0;return!1}function bQ4(J,Q){if(!PQ4.test(J))return!1;try{let[Y]=J.split(".");if(!Y)return!1;let X=Y.replace(/-/g,"+").replace(/_/g,"/").padEnd(Y.length+(4-Y.length%4)%4,"="),G=JSON.parse(atob(X));if(typeof G!=="object"||G===null)return!1;if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Q&&G.alg!==Q)return!1;return!0}catch{return!1}}function gQ4(J,Q){if((Q==="v4"||!Q)&&SQ4.test(J))return!0;if((Q==="v6"||!Q)&&kQ4.test(J))return!0;return!1}function mQ4(J,Q){let Y=(J.toString().split(".")[1]||"").length,X=(Q.toString().split(".")[1]||"").length,G=Y>X?Y:X,Z=Number.parseInt(J.toFixed(G).replace(".","")),q=Number.parseInt(Q.toFixed(G).replace(".",""));return Z%q/10**G}function IE(J){if(J instanceof C7){let Q={};for(let Y in J.shape){let X=J.shape[Y];Q[Y]=P$.create(IE(X))}return new C7({...J._def,shape:()=>Q})}else if(J instanceof I$)return new I$({...J._def,type:IE(J.element)});else if(J instanceof P$)return P$.create(IE(J.unwrap()));else if(J instanceof fW)return fW.create(IE(J.unwrap()));else if(J instanceof EV)return EV.create(J.items.map((Q)=>IE(Q)));else return J}function TZ1(J,Q){let Y=OV(J),X=OV(Q);if(J===Q)return{valid:!0,data:J};else if(Y===y6.object&&X===y6.object){let G=B9.objectKeys(Q),Z=B9.objectKeys(J).filter((V)=>G.indexOf(V)!==-1),q={...J,...Q};for(let V of Z){let K=TZ1(J[V],Q[V]);if(!K.valid)return{valid:!1};q[V]=K.data}return{valid:!0,data:q}}else if(Y===y6.array&&X===y6.array){if(J.length!==Q.length)return{valid:!1};let G=[];for(let Z=0;Z<J.length;Z++){let q=J[Z],V=Q[Z],K=TZ1(q,V);if(!K.valid)return{valid:!1};G.push(K.data)}return{valid:!0,data:G}}else if(Y===y6.date&&X===y6.date&&+J===+Q)return{valid:!0,data:J};else return{valid:!1}}function LF0(J,Q){return new mF({values:J,typeName:q8.ZodEnum,...S8(Q)})}function BF0(J,Q){let Y=typeof J==="function"?J(Q):typeof J==="string"?{message:J}:J;return typeof Y==="string"?{message:Y}:Y}function AF0(J,Q={},Y){if(J)return JM.create().superRefine((X,G)=>{let Z=J(X);if(Z instanceof Promise)return Z.then((q)=>{if(!q){let V=BF0(Q,X),K=V.fatal??Y??!0;G.addIssue({code:"custom",...V,fatal:K})}});if(!Z){let q=BF0(Q,X),V=q.fatal??Y??!0;G.addIssue({code:"custom",...q,fatal:V})}return});return JM.create()}var UF0=(J,Q)=>{if(fF(Q))return{success:!0,data:Q.value};else{if(!J.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Y=new FY(J.common.issues);return this._error=Y,this._error}}}},AQ4,OQ4,wQ4,EQ4,IQ4,PQ4,TQ4,RQ4,CQ4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",PZ1,jQ4,SQ4,_Q4,kQ4,yQ4,xQ4,NF0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",vQ4,E$,bF,gF,TE,eD,Xk,RE,CE,JM,hF,wV,Gk,I$,C7,jE,vW=(J)=>{if(J instanceof _E)return vW(J.schema);else if(J instanceof R$)return vW(J.innerType());else if(J instanceof kE)return[J.value];else if(J instanceof mF)return J.options;else if(J instanceof yE)return B9.objectValues(J.enum);else if(J instanceof xE)return vW(J._def.innerType);else if(J instanceof RE)return[void 0];else if(J instanceof CE)return[null];else if(J instanceof P$)return[void 0,...vW(J.unwrap())];else if(J instanceof fW)return[null,...vW(J.unwrap())];else if(J instanceof Pl)return vW(J.unwrap());else if(J instanceof fE)return vW(J.unwrap());else if(J instanceof vE)return vW(J._def.innerType);else return[]},Il,SE,EV,Zk,$k,QM,PE,_E,kE,mF,yE,YM,R$,P$,fW,xE,vE,qk,uQ4,Pl,Vk,fE,pQ4,q8,dQ4=(J,Q={message:`Input not instance of ${J.name}`})=>AF0((Y)=>Y instanceof J,Q),OF0,wF0,cQ4,lQ4,EF0,iQ4,nQ4,aQ4,oQ4,rQ4,sQ4,tQ4,eQ4,JY4,QY4,YY4,XY4,GY4,ZY4,$Y4,qY4,VY4,KY4,WY4,HY4,zY4,FY4,UY4,BY4,NY4,DY4,MY4,LY4,AY4,OY4=()=>OF0().optional(),wY4=()=>wF0().optional(),EY4=()=>EF0().optional(),IY4,PY4;var IF0=L1(()=>{Al();Ol();FF0();IZ1();Qk();AQ4=/^c[^\s-]{8,}$/i,OQ4=/^[0-9a-z]+$/,wQ4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,EQ4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,IQ4=/^[a-z0-9_-]{21}$/i,PQ4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,TQ4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,RQ4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jQ4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,SQ4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,_Q4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,kQ4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yQ4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xQ4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,vQ4=new RegExp(`^${NF0}$`);E$=class E$ extends r8{_parse(J){if(this._def.coerce)J.data=String(J.data);if(this._getType(J)!==y6.string){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.string,received:G.parsedType}),s4}let Y=new YJ,X=void 0;for(let G of this._def.checks)if(G.kind==="min"){if(J.data.length<G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Y.dirty()}else if(G.kind==="max"){if(J.data.length>G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Y.dirty()}else if(G.kind==="length"){let Z=J.data.length>G.value,q=J.data.length<G.value;if(Z||q){if(X=this._getOrReturnCtx(J,X),Z)o6(X,{code:z6.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});else if(q)o6(X,{code:z6.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});Y.dirty()}}else if(G.kind==="email"){if(!RQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"email",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="emoji"){if(!PZ1)PZ1=new RegExp(CQ4,"u");if(!PZ1.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"emoji",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="uuid"){if(!EQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"uuid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="nanoid"){if(!IQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"nanoid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cuid"){if(!AQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cuid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cuid2"){if(!OQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cuid2",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="ulid"){if(!wQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"ulid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="url")try{new URL(J.data)}catch{X=this._getOrReturnCtx(J,X),o6(X,{validation:"url",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="regex"){if(G.regex.lastIndex=0,!G.regex.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"regex",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="trim")J.data=J.data.trim();else if(G.kind==="includes"){if(!J.data.includes(G.value,G.position))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{includes:G.value,position:G.position},message:G.message}),Y.dirty()}else if(G.kind==="toLowerCase")J.data=J.data.toLowerCase();else if(G.kind==="toUpperCase")J.data=J.data.toUpperCase();else if(G.kind==="startsWith"){if(!J.data.startsWith(G.value))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{startsWith:G.value},message:G.message}),Y.dirty()}else if(G.kind==="endsWith"){if(!J.data.endsWith(G.value))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{endsWith:G.value},message:G.message}),Y.dirty()}else if(G.kind==="datetime"){if(!MF0(G).test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"datetime",message:G.message}),Y.dirty()}else if(G.kind==="date"){if(!vQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"date",message:G.message}),Y.dirty()}else if(G.kind==="time"){if(!fQ4(G).test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"time",message:G.message}),Y.dirty()}else if(G.kind==="duration"){if(!TQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"duration",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="ip"){if(!hQ4(J.data,G.version))X=this._getOrReturnCtx(J,X),o6(X,{validation:"ip",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="jwt"){if(!bQ4(J.data,G.alg))X=this._getOrReturnCtx(J,X),o6(X,{validation:"jwt",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cidr"){if(!gQ4(J.data,G.version))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cidr",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="base64"){if(!yQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"base64",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="base64url"){if(!xQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"base64url",code:z6.invalid_string,message:G.message}),Y.dirty()}else B9.assertNever(G);return{status:Y.value,value:J.data}}_regex(J,Q,Y){return this.refinement((X)=>J.test(X),{validation:Q,code:z6.invalid_string,...L4.errToObj(Y)})}_addCheck(J){return new E$({...this._def,checks:[...this._def.checks,J]})}email(J){return this._addCheck({kind:"email",...L4.errToObj(J)})}url(J){return this._addCheck({kind:"url",...L4.errToObj(J)})}emoji(J){return this._addCheck({kind:"emoji",...L4.errToObj(J)})}uuid(J){return this._addCheck({kind:"uuid",...L4.errToObj(J)})}nanoid(J){return this._addCheck({kind:"nanoid",...L4.errToObj(J)})}cuid(J){return this._addCheck({kind:"cuid",...L4.errToObj(J)})}cuid2(J){return this._addCheck({kind:"cuid2",...L4.errToObj(J)})}ulid(J){return this._addCheck({kind:"ulid",...L4.errToObj(J)})}base64(J){return this._addCheck({kind:"base64",...L4.errToObj(J)})}base64url(J){return this._addCheck({kind:"base64url",...L4.errToObj(J)})}jwt(J){return this._addCheck({kind:"jwt",...L4.errToObj(J)})}ip(J){return this._addCheck({kind:"ip",...L4.errToObj(J)})}cidr(J){return this._addCheck({kind:"cidr",...L4.errToObj(J)})}datetime(J){if(typeof J==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:J});return this._addCheck({kind:"datetime",precision:typeof J?.precision>"u"?null:J?.precision,offset:J?.offset??!1,local:J?.local??!1,...L4.errToObj(J?.message)})}date(J){return this._addCheck({kind:"date",message:J})}time(J){if(typeof J==="string")return this._addCheck({kind:"time",precision:null,message:J});return this._addCheck({kind:"time",precision:typeof J?.precision>"u"?null:J?.precision,...L4.errToObj(J?.message)})}duration(J){return this._addCheck({kind:"duration",...L4.errToObj(J)})}regex(J,Q){return this._addCheck({kind:"regex",regex:J,...L4.errToObj(Q)})}includes(J,Q){return this._addCheck({kind:"includes",value:J,position:Q?.position,...L4.errToObj(Q?.message)})}startsWith(J,Q){return this._addCheck({kind:"startsWith",value:J,...L4.errToObj(Q)})}endsWith(J,Q){return this._addCheck({kind:"endsWith",value:J,...L4.errToObj(Q)})}min(J,Q){return this._addCheck({kind:"min",value:J,...L4.errToObj(Q)})}max(J,Q){return this._addCheck({kind:"max",value:J,...L4.errToObj(Q)})}length(J,Q){return this._addCheck({kind:"length",value:J,...L4.errToObj(Q)})}nonempty(J){return this.min(1,L4.errToObj(J))}trim(){return new E$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((J)=>J.kind==="datetime")}get isDate(){return!!this._def.checks.find((J)=>J.kind==="date")}get isTime(){return!!this._def.checks.find((J)=>J.kind==="time")}get isDuration(){return!!this._def.checks.find((J)=>J.kind==="duration")}get isEmail(){return!!this._def.checks.find((J)=>J.kind==="email")}get isURL(){return!!this._def.checks.find((J)=>J.kind==="url")}get isEmoji(){return!!this._def.checks.find((J)=>J.kind==="emoji")}get isUUID(){return!!this._def.checks.find((J)=>J.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((J)=>J.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((J)=>J.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((J)=>J.kind==="cuid2")}get isULID(){return!!this._def.checks.find((J)=>J.kind==="ulid")}get isIP(){return!!this._def.checks.find((J)=>J.kind==="ip")}get isCIDR(){return!!this._def.checks.find((J)=>J.kind==="cidr")}get isBase64(){return!!this._def.checks.find((J)=>J.kind==="base64")}get isBase64url(){return!!this._def.checks.find((J)=>J.kind==="base64url")}get minLength(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxLength(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}};E$.create=(J)=>{return new E$({checks:[],typeName:q8.ZodString,coerce:J?.coerce??!1,...S8(J)})};bF=class bF extends r8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(J){if(this._def.coerce)J.data=Number(J.data);if(this._getType(J)!==y6.number){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.number,received:G.parsedType}),s4}let Y=void 0,X=new YJ;for(let G of this._def.checks)if(G.kind==="int"){if(!B9.isInteger(J.data))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.invalid_type,expected:"integer",received:"float",message:G.message}),X.dirty()}else if(G.kind==="min"){if(G.inclusive?J.data<G.value:J.data<=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_small,minimum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),X.dirty()}else if(G.kind==="max"){if(G.inclusive?J.data>G.value:J.data>=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_big,maximum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),X.dirty()}else if(G.kind==="multipleOf"){if(mQ4(J.data,G.value)!==0)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_multiple_of,multipleOf:G.value,message:G.message}),X.dirty()}else if(G.kind==="finite"){if(!Number.isFinite(J.data))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_finite,message:G.message}),X.dirty()}else B9.assertNever(G);return{status:X.value,value:J.data}}gte(J,Q){return this.setLimit("min",J,!0,L4.toString(Q))}gt(J,Q){return this.setLimit("min",J,!1,L4.toString(Q))}lte(J,Q){return this.setLimit("max",J,!0,L4.toString(Q))}lt(J,Q){return this.setLimit("max",J,!1,L4.toString(Q))}setLimit(J,Q,Y,X){return new bF({...this._def,checks:[...this._def.checks,{kind:J,value:Q,inclusive:Y,message:L4.toString(X)}]})}_addCheck(J){return new bF({...this._def,checks:[...this._def.checks,J]})}int(J){return this._addCheck({kind:"int",message:L4.toString(J)})}positive(J){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L4.toString(J)})}negative(J){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L4.toString(J)})}nonpositive(J){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L4.toString(J)})}nonnegative(J){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L4.toString(J)})}multipleOf(J,Q){return this._addCheck({kind:"multipleOf",value:J,message:L4.toString(Q)})}finite(J){return this._addCheck({kind:"finite",message:L4.toString(J)})}safe(J){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L4.toString(J)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L4.toString(J)})}get minValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}get isInt(){return!!this._def.checks.find((J)=>J.kind==="int"||J.kind==="multipleOf"&&B9.isInteger(J.value))}get isFinite(){let J=null,Q=null;for(let Y of this._def.checks)if(Y.kind==="finite"||Y.kind==="int"||Y.kind==="multipleOf")return!0;else if(Y.kind==="min"){if(Q===null||Y.value>Q)Q=Y.value}else if(Y.kind==="max"){if(J===null||Y.value<J)J=Y.value}return Number.isFinite(Q)&&Number.isFinite(J)}};bF.create=(J)=>{return new bF({checks:[],typeName:q8.ZodNumber,coerce:J?.coerce||!1,...S8(J)})};gF=class gF extends r8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(J){if(this._def.coerce)try{J.data=BigInt(J.data)}catch{return this._getInvalidInput(J)}if(this._getType(J)!==y6.bigint)return this._getInvalidInput(J);let Y=void 0,X=new YJ;for(let G of this._def.checks)if(G.kind==="min"){if(G.inclusive?J.data<G.value:J.data<=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_small,type:"bigint",minimum:G.value,inclusive:G.inclusive,message:G.message}),X.dirty()}else if(G.kind==="max"){if(G.inclusive?J.data>G.value:J.data>=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_big,type:"bigint",maximum:G.value,inclusive:G.inclusive,message:G.message}),X.dirty()}else if(G.kind==="multipleOf"){if(J.data%G.value!==BigInt(0))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_multiple_of,multipleOf:G.value,message:G.message}),X.dirty()}else B9.assertNever(G);return{status:X.value,value:J.data}}_getInvalidInput(J){let Q=this._getOrReturnCtx(J);return o6(Q,{code:z6.invalid_type,expected:y6.bigint,received:Q.parsedType}),s4}gte(J,Q){return this.setLimit("min",J,!0,L4.toString(Q))}gt(J,Q){return this.setLimit("min",J,!1,L4.toString(Q))}lte(J,Q){return this.setLimit("max",J,!0,L4.toString(Q))}lt(J,Q){return this.setLimit("max",J,!1,L4.toString(Q))}setLimit(J,Q,Y,X){return new gF({...this._def,checks:[...this._def.checks,{kind:J,value:Q,inclusive:Y,message:L4.toString(X)}]})}_addCheck(J){return new gF({...this._def,checks:[...this._def.checks,J]})}positive(J){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L4.toString(J)})}negative(J){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L4.toString(J)})}nonpositive(J){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L4.toString(J)})}nonnegative(J){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L4.toString(J)})}multipleOf(J,Q){return this._addCheck({kind:"multipleOf",value:J,message:L4.toString(Q)})}get minValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}};gF.create=(J)=>{return new gF({checks:[],typeName:q8.ZodBigInt,coerce:J?.coerce??!1,...S8(J)})};TE=class TE extends r8{_parse(J){if(this._def.coerce)J.data=Boolean(J.data);if(this._getType(J)!==y6.boolean){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.boolean,received:Y.parsedType}),s4}return lJ(J.data)}};TE.create=(J)=>{return new TE({typeName:q8.ZodBoolean,coerce:J?.coerce||!1,...S8(J)})};eD=class eD extends r8{_parse(J){if(this._def.coerce)J.data=new Date(J.data);if(this._getType(J)!==y6.date){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.date,received:G.parsedType}),s4}if(Number.isNaN(J.data.getTime())){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_date}),s4}let Y=new YJ,X=void 0;for(let G of this._def.checks)if(G.kind==="min"){if(J.data.getTime()<G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_small,message:G.message,inclusive:!0,exact:!1,minimum:G.value,type:"date"}),Y.dirty()}else if(G.kind==="max"){if(J.data.getTime()>G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_big,message:G.message,inclusive:!0,exact:!1,maximum:G.value,type:"date"}),Y.dirty()}else B9.assertNever(G);return{status:Y.value,value:new Date(J.data.getTime())}}_addCheck(J){return new eD({...this._def,checks:[...this._def.checks,J]})}min(J,Q){return this._addCheck({kind:"min",value:J.getTime(),message:L4.toString(Q)})}max(J,Q){return this._addCheck({kind:"max",value:J.getTime(),message:L4.toString(Q)})}get minDate(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J!=null?new Date(J):null}get maxDate(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J!=null?new Date(J):null}};eD.create=(J)=>{return new eD({checks:[],coerce:J?.coerce||!1,typeName:q8.ZodDate,...S8(J)})};Xk=class Xk extends r8{_parse(J){if(this._getType(J)!==y6.symbol){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.symbol,received:Y.parsedType}),s4}return lJ(J.data)}};Xk.create=(J)=>{return new Xk({typeName:q8.ZodSymbol,...S8(J)})};RE=class RE extends r8{_parse(J){if(this._getType(J)!==y6.undefined){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.undefined,received:Y.parsedType}),s4}return lJ(J.data)}};RE.create=(J)=>{return new RE({typeName:q8.ZodUndefined,...S8(J)})};CE=class CE extends r8{_parse(J){if(this._getType(J)!==y6.null){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.null,received:Y.parsedType}),s4}return lJ(J.data)}};CE.create=(J)=>{return new CE({typeName:q8.ZodNull,...S8(J)})};JM=class JM extends r8{constructor(){super(...arguments);this._any=!0}_parse(J){return lJ(J.data)}};JM.create=(J)=>{return new JM({typeName:q8.ZodAny,...S8(J)})};hF=class hF extends r8{constructor(){super(...arguments);this._unknown=!0}_parse(J){return lJ(J.data)}};hF.create=(J)=>{return new hF({typeName:q8.ZodUnknown,...S8(J)})};wV=class wV extends r8{_parse(J){let Q=this._getOrReturnCtx(J);return o6(Q,{code:z6.invalid_type,expected:y6.never,received:Q.parsedType}),s4}};wV.create=(J)=>{return new wV({typeName:q8.ZodNever,...S8(J)})};Gk=class Gk extends r8{_parse(J){if(this._getType(J)!==y6.undefined){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.void,received:Y.parsedType}),s4}return lJ(J.data)}};Gk.create=(J)=>{return new Gk({typeName:q8.ZodVoid,...S8(J)})};I$=class I$ extends r8{_parse(J){let{ctx:Q,status:Y}=this._processInputParams(J),X=this._def;if(Q.parsedType!==y6.array)return o6(Q,{code:z6.invalid_type,expected:y6.array,received:Q.parsedType}),s4;if(X.exactLength!==null){let Z=Q.data.length>X.exactLength.value,q=Q.data.length<X.exactLength.value;if(Z||q)o6(Q,{code:Z?z6.too_big:z6.too_small,minimum:q?X.exactLength.value:void 0,maximum:Z?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),Y.dirty()}if(X.minLength!==null){if(Q.data.length<X.minLength.value)o6(Q,{code:z6.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),Y.dirty()}if(X.maxLength!==null){if(Q.data.length>X.maxLength.value)o6(Q,{code:z6.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),Y.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((Z,q)=>{return X.type._parseAsync(new T$(Q,Z,Q.path,q))})).then((Z)=>{return YJ.mergeArray(Y,Z)});let G=[...Q.data].map((Z,q)=>{return X.type._parseSync(new T$(Q,Z,Q.path,q))});return YJ.mergeArray(Y,G)}get element(){return this._def.type}min(J,Q){return new I$({...this._def,minLength:{value:J,message:L4.toString(Q)}})}max(J,Q){return new I$({...this._def,maxLength:{value:J,message:L4.toString(Q)}})}length(J,Q){return new I$({...this._def,exactLength:{value:J,message:L4.toString(Q)}})}nonempty(J){return this.min(1,J)}};I$.create=(J,Q)=>{return new I$({type:J,minLength:null,maxLength:null,exactLength:null,typeName:q8.ZodArray,...S8(Q)})};C7=class C7 extends r8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let J=this._def.shape(),Q=B9.objectKeys(J);return this._cached={shape:J,keys:Q},this._cached}_parse(J){if(this._getType(J)!==y6.object){let K=this._getOrReturnCtx(J);return o6(K,{code:z6.invalid_type,expected:y6.object,received:K.parsedType}),s4}let{status:Y,ctx:X}=this._processInputParams(J),{shape:G,keys:Z}=this._getCached(),q=[];if(!(this._def.catchall instanceof wV&&this._def.unknownKeys==="strip")){for(let K in X.data)if(!Z.includes(K))q.push(K)}let V=[];for(let K of Z){let W=G[K],H=X.data[K];V.push({key:{status:"valid",value:K},value:W._parse(new T$(X,H,X.path,K)),alwaysSet:K in X.data})}if(this._def.catchall instanceof wV){let K=this._def.unknownKeys;if(K==="passthrough")for(let W of q)V.push({key:{status:"valid",value:W},value:{status:"valid",value:X.data[W]}});else if(K==="strict"){if(q.length>0)o6(X,{code:z6.unrecognized_keys,keys:q}),Y.dirty()}else if(K==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let K=this._def.catchall;for(let W of q){let H=X.data[W];V.push({key:{status:"valid",value:W},value:K._parse(new T$(X,H,X.path,W)),alwaysSet:W in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let K=[];for(let W of V){let H=await W.key,z=await W.value;K.push({key:H,value:z,alwaysSet:W.alwaysSet})}return K}).then((K)=>{return YJ.mergeObjectSync(Y,K)});else return YJ.mergeObjectSync(Y,V)}get shape(){return this._def.shape()}strict(J){return L4.errToObj,new C7({...this._def,unknownKeys:"strict",...J!==void 0?{errorMap:(Q,Y)=>{let X=this._def.errorMap?.(Q,Y).message??Y.defaultError;if(Q.code==="unrecognized_keys")return{message:L4.errToObj(J).message??X};return{message:X}}}:{}})}strip(){return new C7({...this._def,unknownKeys:"strip"})}passthrough(){return new C7({...this._def,unknownKeys:"passthrough"})}extend(J){return new C7({...this._def,shape:()=>({...this._def.shape(),...J})})}merge(J){return new C7({unknownKeys:J._def.unknownKeys,catchall:J._def.catchall,shape:()=>({...this._def.shape(),...J._def.shape()}),typeName:q8.ZodObject})}setKey(J,Q){return this.augment({[J]:Q})}catchall(J){return new C7({...this._def,catchall:J})}pick(J){let Q={};for(let Y of B9.objectKeys(J))if(J[Y]&&this.shape[Y])Q[Y]=this.shape[Y];return new C7({...this._def,shape:()=>Q})}omit(J){let Q={};for(let Y of B9.objectKeys(this.shape))if(!J[Y])Q[Y]=this.shape[Y];return new C7({...this._def,shape:()=>Q})}deepPartial(){return IE(this)}partial(J){let Q={};for(let Y of B9.objectKeys(this.shape)){let X=this.shape[Y];if(J&&!J[Y])Q[Y]=X;else Q[Y]=X.optional()}return new C7({...this._def,shape:()=>Q})}required(J){let Q={};for(let Y of B9.objectKeys(this.shape))if(J&&!J[Y])Q[Y]=this.shape[Y];else{let G=this.shape[Y];while(G instanceof P$)G=G._def.innerType;Q[Y]=G}return new C7({...this._def,shape:()=>Q})}keyof(){return LF0(B9.objectKeys(this.shape))}};C7.create=(J,Q)=>{return new C7({shape:()=>J,unknownKeys:"strip",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};C7.strictCreate=(J,Q)=>{return new C7({shape:()=>J,unknownKeys:"strict",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};C7.lazycreate=(J,Q)=>{return new C7({shape:J,unknownKeys:"strip",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};jE=class jE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=this._def.options;function X(G){for(let q of G)if(q.result.status==="valid")return q.result;for(let q of G)if(q.result.status==="dirty")return Q.common.issues.push(...q.ctx.common.issues),q.result;let Z=G.map((q)=>new FY(q.ctx.common.issues));return o6(Q,{code:z6.invalid_union,unionErrors:Z}),s4}if(Q.common.async)return Promise.all(Y.map(async(G)=>{let Z={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await G._parseAsync({data:Q.data,path:Q.path,parent:Z}),ctx:Z}})).then(X);else{let G=void 0,Z=[];for(let V of Y){let K={...Q,common:{...Q.common,issues:[]},parent:null},W=V._parseSync({data:Q.data,path:Q.path,parent:K});if(W.status==="valid")return W;else if(W.status==="dirty"&&!G)G={result:W,ctx:K};if(K.common.issues.length)Z.push(K.common.issues)}if(G)return Q.common.issues.push(...G.ctx.common.issues),G.result;let q=Z.map((V)=>new FY(V));return o6(Q,{code:z6.invalid_union,unionErrors:q}),s4}}get options(){return this._def.options}};jE.create=(J,Q)=>{return new jE({options:J,typeName:q8.ZodUnion,...S8(Q)})};Il=class Il extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.object)return o6(Q,{code:z6.invalid_type,expected:y6.object,received:Q.parsedType}),s4;let Y=this.discriminator,X=Q.data[Y],G=this.optionsMap.get(X);if(!G)return o6(Q,{code:z6.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Y]}),s4;if(Q.common.async)return G._parseAsync({data:Q.data,path:Q.path,parent:Q});else return G._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(J,Q,Y){let X=new Map;for(let G of Q){let Z=vW(G.shape[J]);if(!Z.length)throw Error(`A discriminator value for key \`${J}\` could not be extracted from all schema options`);for(let q of Z){if(X.has(q))throw Error(`Discriminator property ${String(J)} has duplicate value ${String(q)}`);X.set(q,G)}}return new Il({typeName:q8.ZodDiscriminatedUnion,discriminator:J,options:Q,optionsMap:X,...S8(Y)})}};SE=class SE extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J),X=(G,Z)=>{if(wl(G)||wl(Z))return s4;let q=TZ1(G.value,Z.value);if(!q.valid)return o6(Y,{code:z6.invalid_intersection_types}),s4;if(El(G)||El(Z))Q.dirty();return{status:Q.value,value:q.data}};if(Y.common.async)return Promise.all([this._def.left._parseAsync({data:Y.data,path:Y.path,parent:Y}),this._def.right._parseAsync({data:Y.data,path:Y.path,parent:Y})]).then(([G,Z])=>X(G,Z));else return X(this._def.left._parseSync({data:Y.data,path:Y.path,parent:Y}),this._def.right._parseSync({data:Y.data,path:Y.path,parent:Y}))}};SE.create=(J,Q,Y)=>{return new SE({left:J,right:Q,typeName:q8.ZodIntersection,...S8(Y)})};EV=class EV extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.array)return o6(Y,{code:z6.invalid_type,expected:y6.array,received:Y.parsedType}),s4;if(Y.data.length<this._def.items.length)return o6(Y,{code:z6.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s4;if(!this._def.rest&&Y.data.length>this._def.items.length)o6(Y,{code:z6.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let G=[...Y.data].map((Z,q)=>{let V=this._def.items[q]||this._def.rest;if(!V)return null;return V._parse(new T$(Y,Z,Y.path,q))}).filter((Z)=>!!Z);if(Y.common.async)return Promise.all(G).then((Z)=>{return YJ.mergeArray(Q,Z)});else return YJ.mergeArray(Q,G)}get items(){return this._def.items}rest(J){return new EV({...this._def,rest:J})}};EV.create=(J,Q)=>{if(!Array.isArray(J))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new EV({items:J,typeName:q8.ZodTuple,rest:null,...S8(Q)})};Zk=class Zk extends r8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.object)return o6(Y,{code:z6.invalid_type,expected:y6.object,received:Y.parsedType}),s4;let X=[],G=this._def.keyType,Z=this._def.valueType;for(let q in Y.data)X.push({key:G._parse(new T$(Y,q,Y.path,q)),value:Z._parse(new T$(Y,Y.data[q],Y.path,q)),alwaysSet:q in Y.data});if(Y.common.async)return YJ.mergeObjectAsync(Q,X);else return YJ.mergeObjectSync(Q,X)}get element(){return this._def.valueType}static create(J,Q,Y){if(Q instanceof r8)return new Zk({keyType:J,valueType:Q,typeName:q8.ZodRecord,...S8(Y)});return new Zk({keyType:E$.create(),valueType:J,typeName:q8.ZodRecord,...S8(Q)})}};$k=class $k extends r8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.map)return o6(Y,{code:z6.invalid_type,expected:y6.map,received:Y.parsedType}),s4;let X=this._def.keyType,G=this._def.valueType,Z=[...Y.data.entries()].map(([q,V],K)=>{return{key:X._parse(new T$(Y,q,Y.path,[K,"key"])),value:G._parse(new T$(Y,V,Y.path,[K,"value"]))}});if(Y.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let V of Z){let K=await V.key,W=await V.value;if(K.status==="aborted"||W.status==="aborted")return s4;if(K.status==="dirty"||W.status==="dirty")Q.dirty();q.set(K.value,W.value)}return{status:Q.value,value:q}})}else{let q=new Map;for(let V of Z){let{key:K,value:W}=V;if(K.status==="aborted"||W.status==="aborted")return s4;if(K.status==="dirty"||W.status==="dirty")Q.dirty();q.set(K.value,W.value)}return{status:Q.value,value:q}}}};$k.create=(J,Q,Y)=>{return new $k({valueType:Q,keyType:J,typeName:q8.ZodMap,...S8(Y)})};QM=class QM extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.set)return o6(Y,{code:z6.invalid_type,expected:y6.set,received:Y.parsedType}),s4;let X=this._def;if(X.minSize!==null){if(Y.data.size<X.minSize.value)o6(Y,{code:z6.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),Q.dirty()}if(X.maxSize!==null){if(Y.data.size>X.maxSize.value)o6(Y,{code:z6.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),Q.dirty()}let G=this._def.valueType;function Z(V){let K=new Set;for(let W of V){if(W.status==="aborted")return s4;if(W.status==="dirty")Q.dirty();K.add(W.value)}return{status:Q.value,value:K}}let q=[...Y.data.values()].map((V,K)=>G._parse(new T$(Y,V,Y.path,K)));if(Y.common.async)return Promise.all(q).then((V)=>Z(V));else return Z(q)}min(J,Q){return new QM({...this._def,minSize:{value:J,message:L4.toString(Q)}})}max(J,Q){return new QM({...this._def,maxSize:{value:J,message:L4.toString(Q)}})}size(J,Q){return this.min(J,Q).max(J,Q)}nonempty(J){return this.min(1,J)}};QM.create=(J,Q)=>{return new QM({valueType:J,minSize:null,maxSize:null,typeName:q8.ZodSet,...S8(Q)})};PE=class PE extends r8{constructor(){super(...arguments);this.validate=this.implement}_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.function)return o6(Q,{code:z6.invalid_type,expected:y6.function,received:Q.parsedType}),s4;function Y(q,V){return Yk({data:q,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,wE(),xW].filter((K)=>!!K),issueData:{code:z6.invalid_arguments,argumentsError:V}})}function X(q,V){return Yk({data:q,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,wE(),xW].filter((K)=>!!K),issueData:{code:z6.invalid_return_type,returnTypeError:V}})}let G={errorMap:Q.common.contextualErrorMap},Z=Q.data;if(this._def.returns instanceof YM){let q=this;return lJ(async function(...V){let K=new FY([]),W=await q._def.args.parseAsync(V,G).catch((U)=>{throw K.addIssue(Y(V,U)),K}),H=await Reflect.apply(Z,this,W);return await q._def.returns._def.type.parseAsync(H,G).catch((U)=>{throw K.addIssue(X(H,U)),K})})}else{let q=this;return lJ(function(...V){let K=q._def.args.safeParse(V,G);if(!K.success)throw new FY([Y(V,K.error)]);let W=Reflect.apply(Z,this,K.data),H=q._def.returns.safeParse(W,G);if(!H.success)throw new FY([X(W,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...J){return new PE({...this._def,args:EV.create(J).rest(hF.create())})}returns(J){return new PE({...this._def,returns:J})}implement(J){return this.parse(J)}strictImplement(J){return this.parse(J)}static create(J,Q,Y){return new PE({args:J?J:EV.create([]).rest(hF.create()),returns:Q||hF.create(),typeName:q8.ZodFunction,...S8(Y)})}};_E=class _E extends r8{get schema(){return this._def.getter()}_parse(J){let{ctx:Q}=this._processInputParams(J);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}};_E.create=(J,Q)=>{return new _E({getter:J,typeName:q8.ZodLazy,...S8(Q)})};kE=class kE extends r8{_parse(J){if(J.data!==this._def.value){let Q=this._getOrReturnCtx(J);return o6(Q,{received:Q.data,code:z6.invalid_literal,expected:this._def.value}),s4}return{status:"valid",value:J.data}}get value(){return this._def.value}};kE.create=(J,Q)=>{return new kE({value:J,typeName:q8.ZodLiteral,...S8(Q)})};mF=class mF extends r8{_parse(J){if(typeof J.data!=="string"){let Q=this._getOrReturnCtx(J),Y=this._def.values;return o6(Q,{expected:B9.joinValues(Y),received:Q.parsedType,code:z6.invalid_type}),s4}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(J.data)){let Q=this._getOrReturnCtx(J),Y=this._def.values;return o6(Q,{received:Q.data,code:z6.invalid_enum_value,options:Y}),s4}return lJ(J.data)}get options(){return this._def.values}get enum(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}get Values(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}get Enum(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}extract(J,Q=this._def){return mF.create(J,{...this._def,...Q})}exclude(J,Q=this._def){return mF.create(this.options.filter((Y)=>!J.includes(Y)),{...this._def,...Q})}};mF.create=LF0;yE=class yE extends r8{_parse(J){let Q=B9.getValidEnumValues(this._def.values),Y=this._getOrReturnCtx(J);if(Y.parsedType!==y6.string&&Y.parsedType!==y6.number){let X=B9.objectValues(Q);return o6(Y,{expected:B9.joinValues(X),received:Y.parsedType,code:z6.invalid_type}),s4}if(!this._cache)this._cache=new Set(B9.getValidEnumValues(this._def.values));if(!this._cache.has(J.data)){let X=B9.objectValues(Q);return o6(Y,{received:Y.data,code:z6.invalid_enum_value,options:X}),s4}return lJ(J.data)}get enum(){return this._def.values}};yE.create=(J,Q)=>{return new yE({values:J,typeName:q8.ZodNativeEnum,...S8(Q)})};YM=class YM extends r8{unwrap(){return this._def.type}_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.promise&&Q.common.async===!1)return o6(Q,{code:z6.invalid_type,expected:y6.promise,received:Q.parsedType}),s4;let Y=Q.parsedType===y6.promise?Q.data:Promise.resolve(Q.data);return lJ(Y.then((X)=>{return this._def.type.parseAsync(X,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}};YM.create=(J,Q)=>{return new YM({type:J,typeName:q8.ZodPromise,...S8(Q)})};R$=class R$ extends r8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q8.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J),X=this._def.effect||null,G={addIssue:(Z)=>{if(o6(Y,Z),Z.fatal)Q.abort();else Q.dirty()},get path(){return Y.path}};if(G.addIssue=G.addIssue.bind(G),X.type==="preprocess"){let Z=X.transform(Y.data,G);if(Y.common.async)return Promise.resolve(Z).then(async(q)=>{if(Q.value==="aborted")return s4;let V=await this._def.schema._parseAsync({data:q,path:Y.path,parent:Y});if(V.status==="aborted")return s4;if(V.status==="dirty")return tD(V.value);if(Q.value==="dirty")return tD(V.value);return V});else{if(Q.value==="aborted")return s4;let q=this._def.schema._parseSync({data:Z,path:Y.path,parent:Y});if(q.status==="aborted")return s4;if(q.status==="dirty")return tD(q.value);if(Q.value==="dirty")return tD(q.value);return q}}if(X.type==="refinement"){let Z=(q)=>{let V=X.refinement(q,G);if(Y.common.async)return Promise.resolve(V);if(V instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(Y.common.async===!1){let q=this._def.schema._parseSync({data:Y.data,path:Y.path,parent:Y});if(q.status==="aborted")return s4;if(q.status==="dirty")Q.dirty();return Z(q.value),{status:Q.value,value:q.value}}else return this._def.schema._parseAsync({data:Y.data,path:Y.path,parent:Y}).then((q)=>{if(q.status==="aborted")return s4;if(q.status==="dirty")Q.dirty();return Z(q.value).then(()=>{return{status:Q.value,value:q.value}})})}if(X.type==="transform")if(Y.common.async===!1){let Z=this._def.schema._parseSync({data:Y.data,path:Y.path,parent:Y});if(!fF(Z))return s4;let q=X.transform(Z.value,G);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:q}}else return this._def.schema._parseAsync({data:Y.data,path:Y.path,parent:Y}).then((Z)=>{if(!fF(Z))return s4;return Promise.resolve(X.transform(Z.value,G)).then((q)=>({status:Q.value,value:q}))});B9.assertNever(X)}};R$.create=(J,Q,Y)=>{return new R$({schema:J,typeName:q8.ZodEffects,effect:Q,...S8(Y)})};R$.createWithPreprocess=(J,Q,Y)=>{return new R$({schema:Q,effect:{type:"preprocess",transform:J},typeName:q8.ZodEffects,...S8(Y)})};P$=class P$ extends r8{_parse(J){if(this._getType(J)===y6.undefined)return lJ(void 0);return this._def.innerType._parse(J)}unwrap(){return this._def.innerType}};P$.create=(J,Q)=>{return new P$({innerType:J,typeName:q8.ZodOptional,...S8(Q)})};fW=class fW extends r8{_parse(J){if(this._getType(J)===y6.null)return lJ(null);return this._def.innerType._parse(J)}unwrap(){return this._def.innerType}};fW.create=(J,Q)=>{return new fW({innerType:J,typeName:q8.ZodNullable,...S8(Q)})};xE=class xE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=Q.data;if(Q.parsedType===y6.undefined)Y=this._def.defaultValue();return this._def.innerType._parse({data:Y,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}};xE.create=(J,Q)=>{return new xE({innerType:J,typeName:q8.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...S8(Q)})};vE=class vE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y={...Q,common:{...Q.common,issues:[]}},X=this._def.innerType._parse({data:Y.data,path:Y.path,parent:{...Y}});if(EE(X))return X.then((G)=>{return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new FY(Y.common.issues)},input:Y.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new FY(Y.common.issues)},input:Y.data})}}removeCatch(){return this._def.innerType}};vE.create=(J,Q)=>{return new vE({innerType:J,typeName:q8.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...S8(Q)})};qk=class qk extends r8{_parse(J){if(this._getType(J)!==y6.nan){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.nan,received:Y.parsedType}),s4}return{status:"valid",value:J.data}}};qk.create=(J)=>{return new qk({typeName:q8.ZodNaN,...S8(J)})};uQ4=Symbol("zod_brand");Pl=class Pl extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=Q.data;return this._def.type._parse({data:Y,path:Q.path,parent:Q})}unwrap(){return this._def.type}};Vk=class Vk extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.common.async)return(async()=>{let G=await this._def.in._parseAsync({data:Y.data,path:Y.path,parent:Y});if(G.status==="aborted")return s4;if(G.status==="dirty")return Q.dirty(),tD(G.value);else return this._def.out._parseAsync({data:G.value,path:Y.path,parent:Y})})();else{let X=this._def.in._parseSync({data:Y.data,path:Y.path,parent:Y});if(X.status==="aborted")return s4;if(X.status==="dirty")return Q.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:Y.path,parent:Y})}}static create(J,Q){return new Vk({in:J,out:Q,typeName:q8.ZodPipeline})}};fE=class fE extends r8{_parse(J){let Q=this._def.innerType._parse(J),Y=(X)=>{if(fF(X))X.value=Object.freeze(X.value);return X};return EE(Q)?Q.then((X)=>Y(X)):Y(Q)}unwrap(){return this._def.innerType}};fE.create=(J,Q)=>{return new fE({innerType:J,typeName:q8.ZodReadonly,...S8(Q)})};pQ4={object:C7.lazycreate};(function(J){J.ZodString="ZodString",J.ZodNumber="ZodNumber",J.ZodNaN="ZodNaN",J.ZodBigInt="ZodBigInt",J.ZodBoolean="ZodBoolean",J.ZodDate="ZodDate",J.ZodSymbol="ZodSymbol",J.ZodUndefined="ZodUndefined",J.ZodNull="ZodNull",J.ZodAny="ZodAny",J.ZodUnknown="ZodUnknown",J.ZodNever="ZodNever",J.ZodVoid="ZodVoid",J.ZodArray="ZodArray",J.ZodObject="ZodObject",J.ZodUnion="ZodUnion",J.ZodDiscriminatedUnion="ZodDiscriminatedUnion",J.ZodIntersection="ZodIntersection",J.ZodTuple="ZodTuple",J.ZodRecord="ZodRecord",J.ZodMap="ZodMap",J.ZodSet="ZodSet",J.ZodFunction="ZodFunction",J.ZodLazy="ZodLazy",J.ZodLiteral="ZodLiteral",J.ZodEnum="ZodEnum",J.ZodEffects="ZodEffects",J.ZodNativeEnum="ZodNativeEnum",J.ZodOptional="ZodOptional",J.ZodNullable="ZodNullable",J.ZodDefault="ZodDefault",J.ZodCatch="ZodCatch",J.ZodPromise="ZodPromise",J.ZodBranded="ZodBranded",J.ZodPipeline="ZodPipeline",J.ZodReadonly="ZodReadonly"})(q8||(q8={}));OF0=E$.create,wF0=bF.create,cQ4=qk.create,lQ4=gF.create,EF0=TE.create,iQ4=eD.create,nQ4=Xk.create,aQ4=RE.create,oQ4=CE.create,rQ4=JM.create,sQ4=hF.create,tQ4=wV.create,eQ4=Gk.create,JY4=I$.create,QY4=C7.create,YY4=C7.strictCreate,XY4=jE.create,GY4=Il.create,ZY4=SE.create,$Y4=EV.create,qY4=Zk.create,VY4=$k.create,KY4=QM.create,WY4=PE.create,HY4=_E.create,zY4=kE.create,FY4=mF.create,UY4=yE.create,BY4=YM.create,NY4=R$.create,DY4=P$.create,MY4=fW.create,LY4=R$.createWithPreprocess,AY4=Vk.create,IY4={string:(J)=>E$.create({...J,coerce:!0}),number:(J)=>bF.create({...J,coerce:!0}),boolean:(J)=>TE.create({...J,coerce:!0}),bigint:(J)=>gF.create({...J,coerce:!0}),date:(J)=>eD.create({...J,coerce:!0})},PY4=s4});var e={};a8(e,{void:()=>eQ4,util:()=>B9,unknown:()=>sQ4,union:()=>XY4,undefined:()=>aQ4,tuple:()=>$Y4,transformer:()=>NY4,symbol:()=>nQ4,string:()=>OF0,strictObject:()=>YY4,setErrorMap:()=>MQ4,set:()=>KY4,record:()=>qY4,quotelessJson:()=>NQ4,promise:()=>BY4,preprocess:()=>LY4,pipeline:()=>AY4,ostring:()=>OY4,optional:()=>DY4,onumber:()=>wY4,oboolean:()=>EY4,objectUtil:()=>wZ1,object:()=>QY4,number:()=>wF0,nullable:()=>MY4,null:()=>oQ4,never:()=>tQ4,nativeEnum:()=>UY4,nan:()=>cQ4,map:()=>VY4,makeIssue:()=>Yk,literal:()=>zY4,lazy:()=>HY4,late:()=>pQ4,isValid:()=>fF,isDirty:()=>El,isAsync:()=>EE,isAborted:()=>wl,intersection:()=>ZY4,instanceof:()=>dQ4,getParsedType:()=>OV,getErrorMap:()=>wE,function:()=>WY4,enum:()=>FY4,effect:()=>NY4,discriminatedUnion:()=>GY4,defaultErrorMap:()=>xW,datetimeRegex:()=>MF0,date:()=>iQ4,custom:()=>AF0,coerce:()=>IY4,boolean:()=>EF0,bigint:()=>lQ4,array:()=>JY4,any:()=>rQ4,addIssueToContext:()=>o6,ZodVoid:()=>Gk,ZodUnknown:()=>hF,ZodUnion:()=>jE,ZodUndefined:()=>RE,ZodType:()=>r8,ZodTuple:()=>EV,ZodTransformer:()=>R$,ZodSymbol:()=>Xk,ZodString:()=>E$,ZodSet:()=>QM,ZodSchema:()=>r8,ZodRecord:()=>Zk,ZodReadonly:()=>fE,ZodPromise:()=>YM,ZodPipeline:()=>Vk,ZodParsedType:()=>y6,ZodOptional:()=>P$,ZodObject:()=>C7,ZodNumber:()=>bF,ZodNullable:()=>fW,ZodNull:()=>CE,ZodNever:()=>wV,ZodNativeEnum:()=>yE,ZodNaN:()=>qk,ZodMap:()=>$k,ZodLiteral:()=>kE,ZodLazy:()=>_E,ZodIssueCode:()=>z6,ZodIntersection:()=>SE,ZodFunction:()=>PE,ZodFirstPartyTypeKind:()=>q8,ZodError:()=>FY,ZodEnum:()=>mF,ZodEffects:()=>R$,ZodDiscriminatedUnion:()=>Il,ZodDefault:()=>xE,ZodDate:()=>eD,ZodCatch:()=>vE,ZodBranded:()=>Pl,ZodBoolean:()=>TE,ZodBigInt:()=>gF,ZodArray:()=>I$,ZodAny:()=>JM,Schema:()=>r8,ParseStatus:()=>YJ,OK:()=>lJ,NEVER:()=>PY4,INVALID:()=>s4,EMPTY_PATH:()=>LQ4,DIRTY:()=>tD,BRAND:()=>uQ4});var RZ1=L1(()=>{Ol();IZ1();zF0();Qk();IF0();Al()});var Kk=L1(()=>{RZ1();RZ1()});function iJ(J,Q){let Y=CY4(J,Q);return typeof Y==="string"?Y:Y.toString()}function CY4(J,Q,Y=!0){if(!Q)Q=jY4();let{workspaceFolders:X,isWindows:G,homeDir:Z}=Q,q=typeof J==="string"?n0.parse(J):n0.from(J);if(X)for(let V of X){let K=o4(V);if(Z6.hasPrefix(q,K)){let W=K.path.endsWith("/")?K.path.slice(0,-1):K.path,z=Y&&X&&X.length>=2?nD(K.path)+(G?"\\":"/"):"";return jZ1(z+q.path.slice(W.length+1),G,q.scheme)}}if(q?.scheme==="file"){if(Z){let V=o4(Z);if(Z6.hasPrefix(q,V)){let K=V.path.endsWith("/")?V.path.slice(0,-1):V.path,W=q.path.slice(K.length+1);return jZ1("~"+(G?"\\":"/")+W,G,q.scheme)}}return jZ1(q.fsPath,G,q.scheme)}return q}function jZ1(J,Q,Y){return Q&&Y==="file"?J.replaceAll("/","\\"):J}function Rl(J){let Q=Tl;return Tl=J,Q}function jY4(){if(Tl)return Tl;throw Error("must call setDisplayPathEnvInfo before calling displayPath() and related functions")}var Tl=null;var hW=L1(()=>{H4();BE();Kl()});var SY4=(J)=>{let Q=0,Y=[];while(Q<J.length){let X=J[Q];if(X==="\\"){Q++;continue}if(X==="{"){Y.push({type:"brace",value:"{"}),Q++;continue}if(X==="}"){Y.push({type:"brace",value:"}"}),Q++;continue}if(X==="["){Y.push({type:"paren",value:"["}),Q++;continue}if(X==="]"){Y.push({type:"paren",value:"]"}),Q++;continue}if(X===":"){Y.push({type:"separator",value:":"}),Q++;continue}if(X===","){Y.push({type:"delimiter",value:","}),Q++;continue}if(X==='"'){let V="",K=!1;X=J[++Q];while(X!=='"'){if(Q===J.length){K=!0;break}if(X==="\\"){if(Q++,Q===J.length){K=!0;break}V+=X+J[Q],X=J[++Q]}else V+=X,X=J[++Q]}if(X=J[++Q],!K)Y.push({type:"string",value:V});continue}if(X&&/\s/.test(X)){Q++;continue}let Z=/[0-9]/;if(X&&Z.test(X)||X==="-"||X==="."){let V="";if(X==="-")V+=X,X=J[++Q];while(X&&Z.test(X)||X===".")V+=X,X=J[++Q];Y.push({type:"number",value:V});continue}let q=/[a-z]/i;if(X&&q.test(X)){let V="";while(X&&q.test(X)){if(Q===J.length)break;V+=X,X=J[++Q]}if(V=="true"||V=="false"||V==="null")Y.push({type:"name",value:V});else{Q++;continue}continue}Q++}return Y},bE=(J)=>{if(J.length===0)return J;let Q=J[J.length-1];switch(Q.type){case"separator":return J=J.slice(0,J.length-1),bE(J);break;case"number":let Y=Q.value[Q.value.length-1];if(Y==="."||Y==="-")return J=J.slice(0,J.length-1),bE(J);case"string":let X=J[J.length-2];if(X?.type==="delimiter")return J=J.slice(0,J.length-1),bE(J);else if(X?.type==="brace"&&X.value==="{")return J=J.slice(0,J.length-1),bE(J);break;case"delimiter":return J=J.slice(0,J.length-1),bE(J);break}return J},_Y4=(J)=>{let Q=[];if(J.map((Y)=>{if(Y.type==="brace")if(Y.value==="{")Q.push("}");else Q.splice(Q.lastIndexOf("}"),1);if(Y.type==="paren")if(Y.value==="[")Q.push("]");else Q.splice(Q.lastIndexOf("]"),1)}),Q.length>0)Q.reverse().map((Y)=>{if(Y==="}")J.push({type:"brace",value:"}"});else if(Y==="]")J.push({type:"paren",value:"]"})});return J},kY4=(J)=>{let Q="";return J.map((Y)=>{switch(Y.type){case"string":Q+='"'+Y.value+'"';break;default:Q+=Y.value;break}}),Q},bG=(J)=>JSON.parse(kY4(_Y4(bE(SY4(J)))));var XM=()=>{};function nJ(J,...Q){throw Error(`[Immer] minified error nr: ${J}. Full error at: https://bit.ly/3cXEKWf`)}function $M(J){return!!J&&!!J[zX]}function pF(J){if(!J)return!1;return SF0(J)||Array.isArray(J)||!!J[Wk]||!!J.constructor?.[Wk]||Bk(J)||Nk(J)}function SF0(J){if(!J||typeof J!=="object")return!1;let Q=ZM(J);if(Q===null)return!0;let Y=Object.hasOwnProperty.call(Q,"constructor")&&Q.constructor;if(Y===Object)return!0;return typeof Y=="function"&&Function.toString.call(Y)===yY4}function Hk(J,Q){if(qM(J)===0)Reflect.ownKeys(J).forEach((Y)=>{Q(Y,J[Y],J)});else J.forEach((Y,X)=>Q(X,Y,J))}function qM(J){let Q=J[zX];return Q?Q.type_:Array.isArray(J)?1:Bk(J)?2:Nk(J)?3:0}function zk(J,Q){return qM(J)===2?J.has(Q):Object.prototype.hasOwnProperty.call(J,Q)}function SZ1(J,Q){return qM(J)===2?J.get(Q):J[Q]}function _F0(J,Q,Y){let X=qM(J);if(X===2)J.set(Q,Y);else if(X===3)J.add(Y);else J[Q]=Y}function xY4(J,Q){if(J===Q)return J!==0||1/J===1/Q;else return J!==J&&Q!==Q}function Bk(J){return J instanceof Map}function Nk(J){return J instanceof Set}function GM(J){return J.copy_||J.base_}function yZ1(J,Q){if(Bk(J))return new Map(J);if(Nk(J))return new Set(J);if(Array.isArray(J))return Array.prototype.slice.call(J);let Y=SF0(J);if(Q===!0||Q==="class_only"&&!Y){let X=Object.getOwnPropertyDescriptors(J);delete X[zX];let G=Reflect.ownKeys(X);for(let Z=0;Z<G.length;Z++){let q=G[Z],V=X[q];if(V.writable===!1)V.writable=!0,V.configurable=!0;if(V.get||V.set)X[q]={configurable:!0,writable:!0,enumerable:V.enumerable,value:J[q]}}return Object.create(ZM(J),X)}else{let X=ZM(J);if(X!==null&&Y)return{...J};let G=Object.create(X);return Object.assign(G,J)}}function UX(J,Q=!1){if(Sl(J)||$M(J)||!pF(J))return J;if(qM(J)>1)J.set=J.add=J.clear=J.delete=vY4;if(Object.freeze(J),Q)Object.entries(J).forEach(([Y,X])=>UX(X,!0));return J}function vY4(){nJ(2)}function Sl(J){return Object.isFrozen(J)}function VM(J){let Q=xZ1[J];if(!Q)nJ(0,J);return Q}function fY4(J,Q){if(!xZ1[J])xZ1[J]=Q}function kF0(){return Fk}function hY4(J,Q){return{drafts_:[],parent_:J,immer_:Q,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function TF0(J,Q){if(Q)VM("Patches"),J.patches_=[],J.inversePatches_=[],J.patchListener_=Q}function vZ1(J){fZ1(J),J.drafts_.forEach(bY4),J.drafts_=null}function fZ1(J){if(J===Fk)Fk=J.parent_}function RF0(J){return Fk=hY4(Fk,J)}function bY4(J){let Q=J[zX];if(Q.type_===0||Q.type_===1)Q.revoke_();else Q.revoked_=!0}function CF0(J,Q){Q.unfinalizedDrafts_=Q.drafts_.length;let Y=Q.drafts_[0];if(J!==void 0&&J!==Y){if(Y[zX].modified_)vZ1(Q),nJ(4);if(pF(J)){if(J=Cl(Q,J),!Q.parent_)jl(Q,J)}if(Q.patches_)VM("Patches").generateReplacementPatches_(Y[zX].base_,J,Q.patches_,Q.inversePatches_)}else J=Cl(Q,Y,[]);if(vZ1(Q),Q.patches_)Q.patchListener_(Q.patches_,Q.inversePatches_);return J!==gZ1?J:void 0}function Cl(J,Q,Y){if(Sl(Q))return Q;let X=Q[zX];if(!X)return Hk(Q,(G,Z)=>jF0(J,X,Q,G,Z,Y)),Q;if(X.scope_!==J)return Q;if(!X.modified_)return jl(J,X.base_,!0),X.base_;if(!X.finalized_){X.finalized_=!0,X.scope_.unfinalizedDrafts_--;let G=X.copy_,Z=G,q=!1;if(X.type_===3)Z=new Set(G),G.clear(),q=!0;if(Hk(Z,(V,K)=>jF0(J,X,G,V,K,Y,q)),jl(J,G,!1),Y&&J.patches_)VM("Patches").generatePatches_(X,Y,J.patches_,J.inversePatches_)}return X.copy_}function jF0(J,Q,Y,X,G,Z,q){if($M(G)){let V=Z&&Q&&Q.type_!==3&&!zk(Q.assigned_,X)?Z.concat(X):void 0,K=Cl(J,G,V);if(_F0(Y,X,K),$M(K))J.canAutoFreeze_=!1;else return}else if(q)Y.add(G);if(pF(G)&&!Sl(G)){if(!J.immer_.autoFreeze_&&J.unfinalizedDrafts_<1)return;if(Cl(J,G),(!Q||!Q.scope_.parent_)&&typeof X!=="symbol"&&Object.prototype.propertyIsEnumerable.call(Y,X))jl(J,G)}}function jl(J,Q,Y=!1){if(!J.parent_&&J.immer_.autoFreeze_&&J.canAutoFreeze_)UX(Q,Y)}function gY4(J,Q){let Y=Array.isArray(J),X={type_:Y?1:0,scope_:Q?Q.scope_:kF0(),modified_:!1,finalized_:!1,assigned_:{},parent_:Q,base_:J,draft_:null,copy_:null,revoke_:null,isManual_:!1},G=X,Z=mZ1;if(Y)G=[X],Z=Uk;let{revoke:q,proxy:V}=Proxy.revocable(G,Z);return X.draft_=V,X.revoke_=q,V}function _Z1(J,Q){let Y=J[zX];return(Y?GM(Y):J)[Q]}function mY4(J,Q,Y){let X=yF0(Q,Y);return X?"value"in X?X.value:X.get?.call(J.draft_):void 0}function yF0(J,Q){if(!(Q in J))return;let Y=ZM(J);while(Y){let X=Object.getOwnPropertyDescriptor(Y,Q);if(X)return X;Y=ZM(Y)}return}function hZ1(J){if(!J.modified_){if(J.modified_=!0,J.parent_)hZ1(J.parent_)}}function kZ1(J){if(!J.copy_)J.copy_=yZ1(J.base_,J.scope_.immer_.useStrictShallowCopy_)}function bZ1(J,Q){let Y=Bk(J)?VM("MapSet").proxyMap_(J,Q):Nk(J)?VM("MapSet").proxySet_(J,Q):gY4(J,Q);return(Q?Q.scope_:kF0()).drafts_.push(Y),Y}function pY4(J){if(!$M(J))nJ(10,J);return xF0(J)}function xF0(J){if(!pF(J)||Sl(J))return J;let Q=J[zX],Y;if(Q){if(!Q.modified_)return Q.base_;Q.finalized_=!0,Y=yZ1(J,Q.scope_.immer_.useStrictShallowCopy_)}else Y=yZ1(J,!0);if(Hk(Y,(X,G)=>{_F0(Y,X,xF0(G))}),Q)Q.finalized_=!1;return Y}function _l(){let Q="replace",Y="add",X="remove";function G(U,N,M,L){switch(U.type_){case 0:case 2:return q(U,N,M,L);case 1:return Z(U,N,M,L);case 3:return V(U,N,M,L)}}function Z(U,N,M,L){let{base_:A,assigned_:E}=U,P=U.copy_;if(P.length<A.length)[A,P]=[P,A],[M,L]=[L,M];for(let I=0;I<A.length;I++)if(E[I]&&P[I]!==A[I]){let R=N.concat([I]);M.push({op:Q,path:R,value:z(P[I])}),L.push({op:Q,path:R,value:z(A[I])})}for(let I=A.length;I<P.length;I++){let R=N.concat([I]);M.push({op:Y,path:R,value:z(P[I])})}for(let I=P.length-1;A.length<=I;--I){let R=N.concat([I]);L.push({op:X,path:R})}}function q(U,N,M,L){let{base_:A,copy_:E}=U;Hk(U.assigned_,(P,I)=>{let R=SZ1(A,P),S=SZ1(E,P),y=!I?X:zk(A,P)?Q:Y;if(R===S&&y===Q)return;let h=N.concat(P);M.push(y===X?{op:y,path:h}:{op:y,path:h,value:S}),L.push(y===Y?{op:X,path:h}:y===X?{op:Y,path:h,value:z(R)}:{op:Q,path:h,value:z(R)})})}function V(U,N,M,L){let{base_:A,copy_:E}=U,P=0;A.forEach((I)=>{if(!E.has(I)){let R=N.concat([P]);M.push({op:X,path:R,value:I}),L.unshift({op:Y,path:R,value:I})}P++}),P=0,E.forEach((I)=>{if(!A.has(I)){let R=N.concat([P]);M.push({op:Y,path:R,value:I}),L.unshift({op:X,path:R,value:I})}P++})}function K(U,N,M,L){M.push({op:Q,path:[],value:N===gZ1?void 0:N}),L.push({op:Q,path:[],value:U})}function W(U,N){return N.forEach((M)=>{let{path:L,op:A}=M,E=U;for(let S=0;S<L.length-1;S++){let y=qM(E),h=L[S];if(typeof h!=="string"&&typeof h!=="number")h=""+h;if((y===0||y===1)&&(h==="__proto__"||h==="constructor"))nJ(19);if(typeof E==="function"&&h==="prototype")nJ(19);if(E=SZ1(E,h),typeof E!=="object")nJ(18,L.join("/"))}let P=qM(E),I=H(M.value),R=L[L.length-1];switch(A){case Q:switch(P){case 2:return E.set(R,I);case 3:nJ(16);default:return E[R]=I}case Y:switch(P){case 1:return R==="-"?E.push(I):E.splice(R,0,I);case 2:return E.set(R,I);case 3:return E.add(I);default:return E[R]=I}case X:switch(P){case 1:return E.splice(R,1);case 2:return E.delete(R);case 3:return E.delete(M.value);default:return delete E[R]}default:nJ(17,A)}}),U}function H(U){if(!pF(U))return U;if(Array.isArray(U))return U.map(H);if(Bk(U))return new Map(Array.from(U.entries()).map(([M,L])=>[M,H(L)]));if(Nk(U))return new Set(Array.from(U).map(H));let N=Object.create(ZM(U));for(let M in U)N[M]=H(U[M]);if(zk(U,Wk))N[Wk]=U[Wk];return N}function z(U){if($M(U))return H(U);else return U}fY4("Patches",{applyPatches_:W,generatePatches_:G,generateReplacementPatches_:K})}function $9(J){return J}var gZ1,Wk,zX,ZM,yY4,xZ1,Fk,mZ1,Uk,uY4=class{constructor(J){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(Q,Y,X)=>{if(typeof Q==="function"&&typeof Y!=="function"){let Z=Y;Y=Q;let q=this;return function(K=Z,...W){return q.produce(K,(H)=>Y.call(this,H,...W))}}if(typeof Y!=="function")nJ(6);if(X!==void 0&&typeof X!=="function")nJ(7);let G;if(pF(Q)){let Z=RF0(this),q=bZ1(Q,void 0),V=!0;try{G=Y(q),V=!1}finally{if(V)vZ1(Z);else fZ1(Z)}return TF0(Z,X),CF0(G,Z)}else if(!Q||typeof Q!=="object"){if(G=Y(Q),G===void 0)G=Q;if(G===gZ1)G=void 0;if(this.autoFreeze_)UX(G,!0);if(X){let Z=[],q=[];VM("Patches").generateReplacementPatches_(Q,G,Z,q),X(Z,q)}return G}else nJ(1,Q)},this.produceWithPatches=(Q,Y)=>{if(typeof Q==="function")return(q,...V)=>this.produceWithPatches(q,(K)=>Q(K,...V));let X,G;return[this.produce(Q,Y,(q,V)=>{X=q,G=V}),X,G]},typeof J?.autoFreeze==="boolean")this.setAutoFreeze(J.autoFreeze);if(typeof J?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy(J.useStrictShallowCopy)}createDraft(J){if(!pF(J))nJ(8);if($M(J))J=pY4(J);let Q=RF0(this),Y=bZ1(J,void 0);return Y[zX].isManual_=!0,fZ1(Q),Y}finishDraft(J,Q){let Y=J&&J[zX];if(!Y||!Y.isManual_)nJ(9);let{scope_:X}=Y;return TF0(X,Q),CF0(void 0,X)}setAutoFreeze(J){this.autoFreeze_=J}setUseStrictShallowCopy(J){this.useStrictShallowCopy_=J}applyPatches(J,Q){let Y;for(Y=Q.length-1;Y>=0;Y--){let G=Q[Y];if(G.path.length===0&&G.op==="replace"){J=G.value;break}}if(Y>-1)Q=Q.slice(Y+1);let X=VM("Patches").applyPatches_;if($M(J))return X(J,Q);return this.produce(J,(G)=>X(G,Q))}},FX,dF,KM,Og8,wg8,vF0,Eg8,Ig8;var UY=L1(()=>{gZ1=Symbol.for("immer-nothing"),Wk=Symbol.for("immer-draftable"),zX=Symbol.for("immer-state");ZM=Object.getPrototypeOf;yY4=Object.prototype.constructor.toString();xZ1={};mZ1={get(J,Q){if(Q===zX)return J;let Y=GM(J);if(!zk(Y,Q))return mY4(J,Y,Q);let X=Y[Q];if(J.finalized_||!pF(X))return X;if(X===_Z1(J.base_,Q))return kZ1(J),J.copy_[Q]=bZ1(X,J);return X},has(J,Q){return Q in GM(J)},ownKeys(J){return Reflect.ownKeys(GM(J))},set(J,Q,Y){let X=yF0(GM(J),Q);if(X?.set)return X.set.call(J.draft_,Y),!0;if(!J.modified_){let G=_Z1(GM(J),Q),Z=G?.[zX];if(Z&&Z.base_===Y)return J.copy_[Q]=Y,J.assigned_[Q]=!1,!0;if(xY4(Y,G)&&(Y!==void 0||zk(J.base_,Q)))return!0;kZ1(J),hZ1(J)}if(J.copy_[Q]===Y&&(Y!==void 0||(Q in J.copy_))||Number.isNaN(Y)&&Number.isNaN(J.copy_[Q]))return!0;return J.copy_[Q]=Y,J.assigned_[Q]=!0,!0},deleteProperty(J,Q){if(_Z1(J.base_,Q)!==void 0||Q in J.base_)J.assigned_[Q]=!1,kZ1(J),hZ1(J);else delete J.assigned_[Q];if(J.copy_)delete J.copy_[Q];return!0},getOwnPropertyDescriptor(J,Q){let Y=GM(J),X=Reflect.getOwnPropertyDescriptor(Y,Q);if(!X)return X;return{writable:!0,configurable:J.type_!==1||Q!=="length",enumerable:X.enumerable,value:Y[Q]}},defineProperty(){nJ(11)},getPrototypeOf(J){return ZM(J.base_)},setPrototypeOf(){nJ(12)}},Uk={};Hk(mZ1,(J,Q)=>{Uk[J]=function(){return arguments[0]=arguments[0][0],Q.apply(this,arguments)}});Uk.deleteProperty=function(J,Q){return Uk.set.call(this,J,Q,void 0)};Uk.set=function(J,Q,Y){return mZ1.set.call(this,J[0],Q,Y,J[0])};FX=new uY4,dF=FX.produce,KM=FX.produceWithPatches.bind(FX),Og8=FX.setAutoFreeze.bind(FX),wg8=FX.setUseStrictShallowCopy.bind(FX),vF0=FX.applyPatches.bind(FX),Eg8=FX.createDraft.bind(FX),Ig8=FX.finishDraft.bind(FX)});function uZ1({onlyFirst:J=!1}={}){let Y=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(Y,J?void 0:"g")}function gE(J){if(typeof J!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof J}\``);return J.replace(dY4,"")}var dY4;var kl=L1(()=>{dY4=uZ1()});var hF0=v((Sg8,pZ1)=>{var cF={};if(typeof pZ1>"u")window.eastasianwidth=cF;else pZ1.exports=cF;cF.eastAsianWidth=function(J){var Q=J.charCodeAt(0),Y=J.length==2?J.charCodeAt(1):0,X=Q;if(55296<=Q&&Q<=56319&&(56320<=Y&&Y<=57343))Q&=1023,Y&=1023,X=Q<<10|Y,X+=65536;if(X==12288||65281<=X&&X<=65376||65504<=X&&X<=65510)return"F";if(X==8361||65377<=X&&X<=65470||65474<=X&&X<=65479||65482<=X&&X<=65487||65490<=X&&X<=65495||65498<=X&&X<=65500||65512<=X&&X<=65518)return"H";if(4352<=X&&X<=4447||4515<=X&&X<=4519||4602<=X&&X<=4607||9001<=X&&X<=9002||11904<=X&&X<=11929||11931<=X&&X<=12019||12032<=X&&X<=12245||12272<=X&&X<=12283||12289<=X&&X<=12350||12353<=X&&X<=12438||12441<=X&&X<=12543||12549<=X&&X<=12589||12593<=X&&X<=12686||12688<=X&&X<=12730||12736<=X&&X<=12771||12784<=X&&X<=12830||12832<=X&&X<=12871||12880<=X&&X<=13054||13056<=X&&X<=19903||19968<=X&&X<=42124||42128<=X&&X<=42182||43360<=X&&X<=43388||44032<=X&&X<=55203||55216<=X&&X<=55238||55243<=X&&X<=55291||63744<=X&&X<=64255||65040<=X&&X<=65049||65072<=X&&X<=65106||65108<=X&&X<=65126||65128<=X&&X<=65131||110592<=X&&X<=110593||127488<=X&&X<=127490||127504<=X&&X<=127546||127552<=X&&X<=127560||127568<=X&&X<=127569||131072<=X&&X<=194367||177984<=X&&X<=196605||196608<=X&&X<=262141)return"W";if(32<=X&&X<=126||162<=X&&X<=163||165<=X&&X<=166||X==172||X==175||10214<=X&&X<=10221||10629<=X&&X<=10630)return"Na";if(X==161||X==164||167<=X&&X<=168||X==170||173<=X&&X<=174||176<=X&&X<=180||182<=X&&X<=186||188<=X&&X<=191||X==198||X==208||215<=X&&X<=216||222<=X&&X<=225||X==230||232<=X&&X<=234||236<=X&&X<=237||X==240||242<=X&&X<=243||247<=X&&X<=250||X==252||X==254||X==257||X==273||X==275||X==283||294<=X&&X<=295||X==299||305<=X&&X<=307||X==312||319<=X&&X<=322||X==324||328<=X&&X<=331||X==333||338<=X&&X<=339||358<=X&&X<=359||X==363||X==462||X==464||X==466||X==468||X==470||X==472||X==474||X==476||X==593||X==609||X==708||X==711||713<=X&&X<=715||X==717||X==720||728<=X&&X<=731||X==733||X==735||768<=X&&X<=879||913<=X&&X<=929||931<=X&&X<=937||945<=X&&X<=961||963<=X&&X<=969||X==1025||1040<=X&&X<=1103||X==1105||X==8208||8211<=X&&X<=8214||8216<=X&&X<=8217||8220<=X&&X<=8221||8224<=X&&X<=8226||8228<=X&&X<=8231||X==8240||8242<=X&&X<=8243||X==8245||X==8251||X==8254||X==8308||X==8319||8321<=X&&X<=8324||X==8364||X==8451||X==8453||X==8457||X==8467||X==8470||8481<=X&&X<=8482||X==8486||X==8491||8531<=X&&X<=8532||8539<=X&&X<=8542||8544<=X&&X<=8555||8560<=X&&X<=8569||X==8585||8592<=X&&X<=8601||8632<=X&&X<=8633||X==8658||X==8660||X==8679||X==8704||8706<=X&&X<=8707||8711<=X&&X<=8712||X==8715||X==8719||X==8721||X==8725||X==8730||8733<=X&&X<=8736||X==8739||X==8741||8743<=X&&X<=8748||X==8750||8756<=X&&X<=8759||8764<=X&&X<=8765||X==8776||X==8780||X==8786||8800<=X&&X<=8801||8804<=X&&X<=8807||8810<=X&&X<=8811||8814<=X&&X<=8815||8834<=X&&X<=8835||8838<=X&&X<=8839||X==8853||X==8857||X==8869||X==8895||X==8978||9312<=X&&X<=9449||9451<=X&&X<=9547||9552<=X&&X<=9587||9600<=X&&X<=9615||9618<=X&&X<=9621||9632<=X&&X<=9633||9635<=X&&X<=9641||9650<=X&&X<=9651||9654<=X&&X<=9655||9660<=X&&X<=9661||9664<=X&&X<=9665||9670<=X&&X<=9672||X==9675||9678<=X&&X<=9681||9698<=X&&X<=9701||X==9711||9733<=X&&X<=9734||X==9737||9742<=X&&X<=9743||9748<=X&&X<=9749||X==9756||X==9758||X==9792||X==9794||9824<=X&&X<=9825||9827<=X&&X<=9829||9831<=X&&X<=9834||9836<=X&&X<=9837||X==9839||9886<=X&&X<=9887||9918<=X&&X<=9919||9924<=X&&X<=9933||9935<=X&&X<=9953||X==9955||9960<=X&&X<=9983||X==10045||X==10071||10102<=X&&X<=10111||11093<=X&&X<=11097||12872<=X&&X<=12879||57344<=X&&X<=63743||65024<=X&&X<=65039||X==65533||127232<=X&&X<=127242||127248<=X&&X<=127277||127280<=X&&X<=127337||127344<=X&&X<=127386||917760<=X&&X<=917999||983040<=X&&X<=1048573||1048576<=X&&X<=1114109)return"A";return"N"};cF.characterLength=function(J){var Q=this.eastAsianWidth(J);if(Q=="F"||Q=="W"||Q=="A")return 2;else return 1};function fF0(J){return J.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}cF.length=function(J){var Q=fF0(J),Y=0;for(var X=0;X<Q.length;X++)Y=Y+this.characterLength(Q[X]);return Y};cF.slice=function(J,Q,Y){if(textLen=cF.length(J),Q=Q?Q:0,Y=Y?Y:1,Q<0)Q=textLen+Q;if(Y<0)Y=textLen+Y;var X="",G=0,Z=fF0(J);for(var q=0;q<Z.length;q++){var V=Z[q],K=cF.length(V);if(G>=Q-(K==2?1:0))if(G+K<=Y)X+=V;else break;G+=K}return X}});var dZ1=v((_g8,bF0)=>{bF0.exports=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g}});var cY4,lY4;var gF0=L1(()=>{kl();cY4=N6(hF0(),1),lY4=N6(dZ1(),1)});function yl(J,Q,Y="..."){if(J.length<=Q)return J;return J.slice(0,Math.max(0,Q-Y.length))+Y}var cZ1=L1(()=>{gF0()});var mF0="run_terminal_command",uF0="read_file",XJ="Task",q9="finder",BY="get_diagnostics",p9="Bash",xl="InteractiveShell",o5="oracle",IV="mermaid",PV="todo_read",Z7="todo_write",V2="read_web_page",vl="read_thread",_5="create_file",X3="glob",fl="undo_edit",hl="read_mcp_resource",i6="Read",F7="edit_file",mE="format_file",S3="web_search",y8="Grep",WM="Check",BX="librarian",bl="kraken",pF0="read_artifact",dF0="edit_artifact",gl="read_plan",uE="edit_plan",ml="read_github",ul="search_github",pl="commit_search",dl="list_directory_github",cl="list_repositories",ll="glob_github",il="diff",cF0="bookkeeper",lF0="describe_workbook",iF0="execute_query",Dk="skill",nF0;var A4=L1(()=>{nF0=["Task","finder","get_diagnostics","Bash","InteractiveShell","oracle","mermaid","todo_read","todo_write","read_web_page","create_file","glob","Glob","undo_edit","Read","edit_file","delete_file","format_file","web_search","Grep","search_documents","get_document","Check","code_review","kraken","librarian","bookkeeper","read_thread","read_artifact","edit_artifact","read_plan","edit_plan","skill"]});var Mk=v((bg8,oF0)=>{var aF0={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},iY4={...aF0,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},nY4={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"};oF0.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:nY4,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,extglobChars(J){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${J.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(J){return J===!0?iY4:aF0}}});var Lk=v((tY4)=>{var{REGEX_BACKSLASH:aY4,REGEX_REMOVE_BACKSLASH:oY4,REGEX_SPECIAL_CHARS:rY4,REGEX_SPECIAL_CHARS_GLOBAL:sY4}=Mk();tY4.isObject=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J);tY4.hasRegexChars=(J)=>rY4.test(J);tY4.isRegexChar=(J)=>J.length===1&&tY4.hasRegexChars(J);tY4.escapeRegex=(J)=>J.replace(sY4,"\\$1");tY4.toPosixSlashes=(J)=>J.replace(aY4,"/");tY4.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let J=navigator.platform.toLowerCase();return J==="win32"||J==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};tY4.removeBackslashes=(J)=>{return J.replace(oY4,(Q)=>{return Q==="\\"?"":Q})};tY4.escapeLast=(J,Q,Y)=>{let X=J.lastIndexOf(Q,Y);if(X===-1)return J;if(J[X-1]==="\\")return tY4.escapeLast(J,Q,X-1);return`${J.slice(0,X)}\\${J.slice(X)}`};tY4.removePrefix=(J,Q={})=>{let Y=J;if(Y.startsWith("./"))Y=Y.slice(2),Q.prefix="./";return Y};tY4.wrapOutput=(J,Q={},Y={})=>{let X=Y.contains?"":"^",G=Y.contains?"":"$",Z=`${X}(?:${J})${G}`;if(Q.negated===!0)Z=`(?:^(?!${Z}).*$)`;return Z};tY4.basename=(J,{windows:Q}={})=>{let Y=J.split(Q?/[\\/]/:"/"),X=Y[Y.length-1];if(X==="")return Y[Y.length-2];return X}});var ZU0=v((mg8,GU0)=>{var tF0=Lk(),{CHAR_ASTERISK:lZ1,CHAR_AT:VX4,CHAR_BACKWARD_SLASH:Ak,CHAR_COMMA:KX4,CHAR_DOT:iZ1,CHAR_EXCLAMATION_MARK:nZ1,CHAR_FORWARD_SLASH:XU0,CHAR_LEFT_CURLY_BRACE:aZ1,CHAR_LEFT_PARENTHESES:oZ1,CHAR_LEFT_SQUARE_BRACKET:WX4,CHAR_PLUS:HX4,CHAR_QUESTION_MARK:eF0,CHAR_RIGHT_CURLY_BRACE:zX4,CHAR_RIGHT_PARENTHESES:JU0,CHAR_RIGHT_SQUARE_BRACKET:FX4}=Mk(),QU0=(J)=>{return J===XU0||J===Ak},YU0=(J)=>{if(J.isPrefix!==!0)J.depth=J.isGlobstar?1/0:1},UX4=(J,Q)=>{let Y=Q||{},X=J.length-1,G=Y.parts===!0||Y.scanToEnd===!0,Z=[],q=[],V=[],K=J,W=-1,H=0,z=0,U=!1,N=!1,M=!1,L=!1,A=!1,E=!1,P=!1,I=!1,R=!1,S=!1,y=0,h,u,p={value:"",depth:0,isGlob:!1},g=()=>W>=X,i=()=>K.charCodeAt(W+1),Y1=()=>{return h=u,K.charCodeAt(++W)};while(W<X){u=Y1();let K1;if(u===Ak){if(P=p.backslashes=!0,u=Y1(),u===aZ1)E=!0;continue}if(E===!0||u===aZ1){y++;while(g()!==!0&&(u=Y1())){if(u===Ak){P=p.backslashes=!0,Y1();continue}if(u===aZ1){y++;continue}if(E!==!0&&u===iZ1&&(u=Y1())===iZ1){if(U=p.isBrace=!0,M=p.isGlob=!0,S=!0,G===!0)continue;break}if(E!==!0&&u===KX4){if(U=p.isBrace=!0,M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===zX4){if(y--,y===0){E=!1,U=p.isBrace=!0,S=!0;break}}}if(G===!0)continue;break}if(u===XU0){if(Z.push(W),q.push(p),p={value:"",depth:0,isGlob:!1},S===!0)continue;if(h===iZ1&&W===H+1){H+=2;continue}z=W+1;continue}if(Y.noext!==!0){if((u===HX4||u===VX4||u===lZ1||u===eF0||u===nZ1)===!0&&i()===oZ1){if(M=p.isGlob=!0,L=p.isExtglob=!0,S=!0,u===nZ1&&W===H)R=!0;if(G===!0){while(g()!==!0&&(u=Y1())){if(u===Ak){P=p.backslashes=!0,u=Y1();continue}if(u===JU0){M=p.isGlob=!0,S=!0;break}}continue}break}}if(u===lZ1){if(h===lZ1)A=p.isGlobstar=!0;if(M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===eF0){if(M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===WX4){while(g()!==!0&&(K1=Y1())){if(K1===Ak){P=p.backslashes=!0,Y1();continue}if(K1===FX4){N=p.isBracket=!0,M=p.isGlob=!0,S=!0;break}}if(G===!0)continue;break}if(Y.nonegate!==!0&&u===nZ1&&W===H){I=p.negated=!0,H++;continue}if(Y.noparen!==!0&&u===oZ1){if(M=p.isGlob=!0,G===!0){while(g()!==!0&&(u=Y1())){if(u===oZ1){P=p.backslashes=!0,u=Y1();continue}if(u===JU0){S=!0;break}}continue}break}if(M===!0){if(S=!0,G===!0)continue;break}}if(Y.noext===!0)L=!1,M=!1;let a=K,b="",s="";if(H>0)b=K.slice(0,H),K=K.slice(H),z-=H;if(a&&M===!0&&z>0)a=K.slice(0,z),s=K.slice(z);else if(M===!0)a="",s=K;else a=K;if(a&&a!==""&&a!=="/"&&a!==K){if(QU0(a.charCodeAt(a.length-1)))a=a.slice(0,-1)}if(Y.unescape===!0){if(s)s=tF0.removeBackslashes(s);if(a&&P===!0)a=tF0.removeBackslashes(a)}let q1={prefix:b,input:J,start:H,base:a,glob:s,isBrace:U,isBracket:N,isGlob:M,isExtglob:L,isGlobstar:A,negated:I,negatedExtglob:R};if(Y.tokens===!0){if(q1.maxDepth=0,!QU0(u))q.push(p);q1.tokens=q}if(Y.parts===!0||Y.tokens===!0){let K1;for(let o=0;o<Z.length;o++){let r=K1?K1+1:H,l=Z[o],F1=J.slice(r,l);if(Y.tokens){if(o===0&&H!==0)q[o].isPrefix=!0,q[o].value=b;else q[o].value=F1;YU0(q[o]),q1.maxDepth+=q[o].depth}if(o!==0||F1!=="")V.push(F1);K1=l}if(K1&&K1+1<J.length){let o=J.slice(K1+1);if(V.push(o),Y.tokens)q[q.length-1].value=o,YU0(q[q.length-1]),q1.maxDepth+=q[q.length-1].depth}q1.slashes=Z,q1.parts=V}return q1};GU0.exports=UX4});var VU0=v((ug8,qU0)=>{var nl=Mk(),TV=Lk(),{MAX_LENGTH:al,POSIX_REGEX_SOURCE:BX4,REGEX_NON_SPECIAL_CHARS:NX4,REGEX_SPECIAL_CHARS_BACKREF:DX4,REPLACEMENTS:$U0}=nl,MX4=(J,Q)=>{if(typeof Q.expandRange==="function")return Q.expandRange(...J,Q);J.sort();let Y=`[${J.join("-")}]`;try{new RegExp(Y)}catch(X){return J.map((G)=>TV.escapeRegex(G)).join("..")}return Y},pE=(J,Q)=>{return`Missing ${J}: "${Q}" - use "\\\\${Q}" to match literal characters`},rZ1=(J,Q)=>{if(typeof J!=="string")throw TypeError("Expected a string");J=$U0[J]||J;let Y={...Q},X=typeof Y.maxLength==="number"?Math.min(al,Y.maxLength):al,G=J.length;if(G>X)throw SyntaxError(`Input length: ${G}, exceeds maximum allowed length: ${X}`);let Z={type:"bos",value:"",output:Y.prepend||""},q=[Z],V=Y.capture?"":"?:",K=nl.globChars(Y.windows),W=nl.extglobChars(K),{DOT_LITERAL:H,PLUS_LITERAL:z,SLASH_LITERAL:U,ONE_CHAR:N,DOTS_SLASH:M,NO_DOT:L,NO_DOT_SLASH:A,NO_DOTS_SLASH:E,QMARK:P,QMARK_NO_DOT:I,STAR:R,START_ANCHOR:S}=K,y=(s1)=>{return`(${V}(?:(?!${S}${s1.dot?M:H}).)*?)`},h=Y.dot?"":L,u=Y.dot?P:I,p=Y.bash===!0?y(Y):R;if(Y.capture)p=`(${p})`;if(typeof Y.noext==="boolean")Y.noextglob=Y.noext;let g={input:J,index:-1,start:0,dot:Y.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:q};J=TV.removePrefix(J,g),G=J.length;let i=[],Y1=[],a=[],b=Z,s,q1=()=>g.index===G-1,K1=g.peek=(s1=1)=>J[g.index+s1],o=g.advance=()=>J[++g.index]||"",r=()=>J.slice(g.index+1),l=(s1="",U1=0)=>{g.consumed+=s1,g.index+=U1},F1=(s1)=>{g.output+=s1.output!=null?s1.output:s1.value,l(s1.value)},y1=()=>{let s1=1;while(K1()==="!"&&(K1(2)!=="("||K1(3)==="?"))o(),g.start++,s1++;if(s1%2===0)return!1;return g.negated=!0,g.start++,!0},t=(s1)=>{g[s1]++,a.push(s1)},f1=(s1)=>{g[s1]--,a.pop()},j1=(s1)=>{if(b.type==="globstar"){let U1=g.braces>0&&(s1.type==="comma"||s1.type==="brace"),Q1=s1.extglob===!0||i.length&&(s1.type==="pipe"||s1.type==="paren");if(s1.type!=="slash"&&s1.type!=="paren"&&!U1&&!Q1)g.output=g.output.slice(0,-b.output.length),b.type="star",b.value="*",b.output=p,g.output+=b.output}if(i.length&&s1.type!=="paren")i[i.length-1].inner+=s1.value;if(s1.value||s1.output)F1(s1);if(b&&b.type==="text"&&s1.type==="text"){b.output=(b.output||b.value)+s1.value,b.value+=s1.value;return}s1.prev=b,q.push(s1),b=s1},w0=(s1,U1)=>{let Q1={...W[U1],conditions:1,inner:""};Q1.prev=b,Q1.parens=g.parens,Q1.output=g.output;let A1=(Y.capture?"(":"")+Q1.open;t("parens"),j1({type:s1,value:U1,output:g.output?"":N}),j1({type:"paren",extglob:!0,value:o(),output:A1}),i.push(Q1)},C1=(s1)=>{let U1=s1.close+(Y.capture?")":""),Q1;if(s1.type==="negate"){let A1=p;if(s1.inner&&s1.inner.length>1&&s1.inner.includes("/"))A1=y(Y);if(A1!==p||q1()||/^\)+$/.test(r()))U1=s1.close=`)$))${A1}`;if(s1.inner.includes("*")&&(Q1=r())&&/^\.[^\\/.]+$/.test(Q1)){let w1=rZ1(Q1,{...Q,fastpaths:!1}).output;U1=s1.close=`)${w1})${A1})`}if(s1.prev.type==="bos")g.negatedExtglob=!0}j1({type:"paren",extglob:!0,value:s,output:U1}),f1("parens")};if(Y.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(J)){let s1=!1,U1=J.replace(DX4,(Q1,A1,w1,I1,E1,p1)=>{if(I1==="\\")return s1=!0,Q1;if(I1==="?"){if(A1)return A1+I1+(E1?P.repeat(E1.length):"");if(p1===0)return u+(E1?P.repeat(E1.length):"");return P.repeat(w1.length)}if(I1===".")return H.repeat(w1.length);if(I1==="*"){if(A1)return A1+I1+(E1?p:"");return p}return A1?Q1:`\\${Q1}`});if(s1===!0)if(Y.unescape===!0)U1=U1.replace(/\\/g,"");else U1=U1.replace(/\\+/g,(Q1)=>{return Q1.length%2===0?"\\\\":Q1?"\\":""});if(U1===J&&Y.contains===!0)return g.output=J,g;return g.output=TV.wrapOutput(U1,g,Q),g}while(!q1()){if(s=o(),s==="\x00")continue;if(s==="\\"){let Q1=K1();if(Q1==="/"&&Y.bash!==!0)continue;if(Q1==="."||Q1===";")continue;if(!Q1){s+="\\",j1({type:"text",value:s});continue}let A1=/^\\+/.exec(r()),w1=0;if(A1&&A1[0].length>2){if(w1=A1[0].length,g.index+=w1,w1%2!==0)s+="\\"}if(Y.unescape===!0)s=o();else s+=o();if(g.brackets===0){j1({type:"text",value:s});continue}}if(g.brackets>0&&(s!=="]"||b.value==="["||b.value==="[^")){if(Y.posix!==!1&&s===":"){let Q1=b.value.slice(1);if(Q1.includes("[")){if(b.posix=!0,Q1.includes(":")){let A1=b.value.lastIndexOf("["),w1=b.value.slice(0,A1),I1=b.value.slice(A1+2),E1=BX4[I1];if(E1){if(b.value=w1+E1,g.backtrack=!0,o(),!Z.output&&q.indexOf(b)===1)Z.output=N;continue}}}}if(s==="["&&K1()!==":"||s==="-"&&K1()==="]")s=`\\${s}`;if(s==="]"&&(b.value==="["||b.value==="[^"))s=`\\${s}`;if(Y.posix===!0&&s==="!"&&b.value==="[")s="^";b.value+=s,F1({value:s});continue}if(g.quotes===1&&s!=='"'){s=TV.escapeRegex(s),b.value+=s,F1({value:s});continue}if(s==='"'){if(g.quotes=g.quotes===1?0:1,Y.keepQuotes===!0)j1({type:"text",value:s});continue}if(s==="("){t("parens"),j1({type:"paren",value:s});continue}if(s===")"){if(g.parens===0&&Y.strictBrackets===!0)throw SyntaxError(pE("opening","("));let Q1=i[i.length-1];if(Q1&&g.parens===Q1.parens+1){C1(i.pop());continue}j1({type:"paren",value:s,output:g.parens?")":"\\)"}),f1("parens");continue}if(s==="["){if(Y.nobracket===!0||!r().includes("]")){if(Y.nobracket!==!0&&Y.strictBrackets===!0)throw SyntaxError(pE("closing","]"));s=`\\${s}`}else t("brackets");j1({type:"bracket",value:s});continue}if(s==="]"){if(Y.nobracket===!0||b&&b.type==="bracket"&&b.value.length===1){j1({type:"text",value:s,output:`\\${s}`});continue}if(g.brackets===0){if(Y.strictBrackets===!0)throw SyntaxError(pE("opening","["));j1({type:"text",value:s,output:`\\${s}`});continue}f1("brackets");let Q1=b.value.slice(1);if(b.posix!==!0&&Q1[0]==="^"&&!Q1.includes("/"))s=`/${s}`;if(b.value+=s,F1({value:s}),Y.literalBrackets===!1||TV.hasRegexChars(Q1))continue;let A1=TV.escapeRegex(b.value);if(g.output=g.output.slice(0,-b.value.length),Y.literalBrackets===!0){g.output+=A1,b.value=A1;continue}b.value=`(${V}${A1}|${b.value})`,g.output+=b.value;continue}if(s==="{"&&Y.nobrace!==!0){t("braces");let Q1={type:"brace",value:s,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};Y1.push(Q1),j1(Q1);continue}if(s==="}"){let Q1=Y1[Y1.length-1];if(Y.nobrace===!0||!Q1){j1({type:"text",value:s,output:s});continue}let A1=")";if(Q1.dots===!0){let w1=q.slice(),I1=[];for(let E1=w1.length-1;E1>=0;E1--){if(q.pop(),w1[E1].type==="brace")break;if(w1[E1].type!=="dots")I1.unshift(w1[E1].value)}A1=MX4(I1,Y),g.backtrack=!0}if(Q1.comma!==!0&&Q1.dots!==!0){let w1=g.output.slice(0,Q1.outputIndex),I1=g.tokens.slice(Q1.tokensIndex);Q1.value=Q1.output="\\{",s=A1="\\}",g.output=w1;for(let E1 of I1)g.output+=E1.output||E1.value}j1({type:"brace",value:s,output:A1}),f1("braces"),Y1.pop();continue}if(s==="|"){if(i.length>0)i[i.length-1].conditions++;j1({type:"text",value:s});continue}if(s===","){let Q1=s,A1=Y1[Y1.length-1];if(A1&&a[a.length-1]==="braces")A1.comma=!0,Q1="|";j1({type:"comma",value:s,output:Q1});continue}if(s==="/"){if(b.type==="dot"&&g.index===g.start+1){g.start=g.index+1,g.consumed="",g.output="",q.pop(),b=Z;continue}j1({type:"slash",value:s,output:U});continue}if(s==="."){if(g.braces>0&&b.type==="dot"){if(b.value===".")b.output=H;let Q1=Y1[Y1.length-1];b.type="dots",b.output+=s,b.value+=s,Q1.dots=!0;continue}if(g.braces+g.parens===0&&b.type!=="bos"&&b.type!=="slash"){j1({type:"text",value:s,output:H});continue}j1({type:"dot",value:s,output:H});continue}if(s==="?"){if(!(b&&b.value==="(")&&Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){w0("qmark",s);continue}if(b&&b.type==="paren"){let A1=K1(),w1=s;if(b.value==="("&&!/[!=<:]/.test(A1)||A1==="<"&&!/<([!=]|\w+>)/.test(r()))w1=`\\${s}`;j1({type:"text",value:s,output:w1});continue}if(Y.dot!==!0&&(b.type==="slash"||b.type==="bos")){j1({type:"qmark",value:s,output:I});continue}j1({type:"qmark",value:s,output:P});continue}if(s==="!"){if(Y.noextglob!==!0&&K1()==="("){if(K1(2)!=="?"||!/[!=<:]/.test(K1(3))){w0("negate",s);continue}}if(Y.nonegate!==!0&&g.index===0){y1();continue}}if(s==="+"){if(Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){w0("plus",s);continue}if(b&&b.value==="("||Y.regex===!1){j1({type:"plus",value:s,output:z});continue}if(b&&(b.type==="bracket"||b.type==="paren"||b.type==="brace")||g.parens>0){j1({type:"plus",value:s});continue}j1({type:"plus",value:z});continue}if(s==="@"){if(Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){j1({type:"at",extglob:!0,value:s,output:""});continue}j1({type:"text",value:s});continue}if(s!=="*"){if(s==="$"||s==="^")s=`\\${s}`;let Q1=NX4.exec(r());if(Q1)s+=Q1[0],g.index+=Q1[0].length;j1({type:"text",value:s});continue}if(b&&(b.type==="globstar"||b.star===!0)){b.type="star",b.star=!0,b.value+=s,b.output=p,g.backtrack=!0,g.globstar=!0,l(s);continue}let s1=r();if(Y.noextglob!==!0&&/^\([^?]/.test(s1)){w0("star",s);continue}if(b.type==="star"){if(Y.noglobstar===!0){l(s);continue}let Q1=b.prev,A1=Q1.prev,w1=Q1.type==="slash"||Q1.type==="bos",I1=A1&&(A1.type==="star"||A1.type==="globstar");if(Y.bash===!0&&(!w1||s1[0]&&s1[0]!=="/")){j1({type:"star",value:s,output:""});continue}let E1=g.braces>0&&(Q1.type==="comma"||Q1.type==="brace"),p1=i.length&&(Q1.type==="pipe"||Q1.type==="paren");if(!w1&&Q1.type!=="paren"&&!E1&&!p1){j1({type:"star",value:s,output:""});continue}while(s1.slice(0,3)==="/**"){let h1=J[g.index+4];if(h1&&h1!=="/")break;s1=s1.slice(3),l("/**",3)}if(Q1.type==="bos"&&q1()){b.type="globstar",b.value+=s,b.output=y(Y),g.output=b.output,g.globstar=!0,l(s);continue}if(Q1.type==="slash"&&Q1.prev.type!=="bos"&&!I1&&q1()){g.output=g.output.slice(0,-(Q1.output+b.output).length),Q1.output=`(?:${Q1.output}`,b.type="globstar",b.output=y(Y)+(Y.strictSlashes?")":"|$)"),b.value+=s,g.globstar=!0,g.output+=Q1.output+b.output,l(s);continue}if(Q1.type==="slash"&&Q1.prev.type!=="bos"&&s1[0]==="/"){let h1=s1[1]!==void 0?"|$":"";g.output=g.output.slice(0,-(Q1.output+b.output).length),Q1.output=`(?:${Q1.output}`,b.type="globstar",b.output=`${y(Y)}${U}|${U}${h1})`,b.value+=s,g.output+=Q1.output+b.output,g.globstar=!0,l(s+o()),j1({type:"slash",value:"/",output:""});continue}if(Q1.type==="bos"&&s1[0]==="/"){b.type="globstar",b.value+=s,b.output=`(?:^|${U}|${y(Y)}${U})`,g.output=b.output,g.globstar=!0,l(s+o()),j1({type:"slash",value:"/",output:""});continue}g.output=g.output.slice(0,-b.output.length),b.type="globstar",b.output=y(Y),b.value+=s,g.output+=b.output,g.globstar=!0,l(s);continue}let U1={type:"star",value:s,output:p};if(Y.bash===!0){if(U1.output=".*?",b.type==="bos"||b.type==="slash")U1.output=h+U1.output;j1(U1);continue}if(b&&(b.type==="bracket"||b.type==="paren")&&Y.regex===!0){U1.output=s,j1(U1);continue}if(g.index===g.start||b.type==="slash"||b.type==="dot"){if(b.type==="dot")g.output+=A,b.output+=A;else if(Y.dot===!0)g.output+=E,b.output+=E;else g.output+=h,b.output+=h;if(K1()!=="*")g.output+=N,b.output+=N}j1(U1)}while(g.brackets>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing","]"));g.output=TV.escapeLast(g.output,"["),f1("brackets")}while(g.parens>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing",")"));g.output=TV.escapeLast(g.output,"("),f1("parens")}while(g.braces>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing","}"));g.output=TV.escapeLast(g.output,"{"),f1("braces")}if(Y.strictSlashes!==!0&&(b.type==="star"||b.type==="bracket"))j1({type:"maybe_slash",value:"",output:`${U}?`});if(g.backtrack===!0){g.output="";for(let s1 of g.tokens)if(g.output+=s1.output!=null?s1.output:s1.value,s1.suffix)g.output+=s1.suffix}return g};rZ1.fastpaths=(J,Q)=>{let Y={...Q},X=typeof Y.maxLength==="number"?Math.min(al,Y.maxLength):al,G=J.length;if(G>X)throw SyntaxError(`Input length: ${G}, exceeds maximum allowed length: ${X}`);J=$U0[J]||J;let{DOT_LITERAL:Z,SLASH_LITERAL:q,ONE_CHAR:V,DOTS_SLASH:K,NO_DOT:W,NO_DOTS:H,NO_DOTS_SLASH:z,STAR:U,START_ANCHOR:N}=nl.globChars(Y.windows),M=Y.dot?H:W,L=Y.dot?z:W,A=Y.capture?"":"?:",E={negated:!1,prefix:""},P=Y.bash===!0?".*?":U;if(Y.capture)P=`(${P})`;let I=(h)=>{if(h.noglobstar===!0)return P;return`(${A}(?:(?!${N}${h.dot?K:Z}).)*?)`},R=(h)=>{switch(h){case"*":return`${M}${V}${P}`;case".*":return`${Z}${V}${P}`;case"*.*":return`${M}${P}${Z}${V}${P}`;case"*/*":return`${M}${P}${q}${V}${L}${P}`;case"**":return M+I(Y);case"**/*":return`(?:${M}${I(Y)}${q})?${L}${V}${P}`;case"**/*.*":return`(?:${M}${I(Y)}${q})?${L}${P}${Z}${V}${P}`;case"**/.*":return`(?:${M}${I(Y)}${q})?${Z}${V}${P}`;default:{let u=/^(.*?)\.(\w+)$/.exec(h);if(!u)return;let p=R(u[1]);if(!p)return;return p+Z+u[2]}}},S=TV.removePrefix(J,E),y=R(S);if(y&&Y.strictSlashes!==!0)y+=`${q}?`;return y};qU0.exports=rZ1});var Ok=v((pg8,WU0)=>{var LX4=ZU0(),sZ1=VU0(),KU0=Lk(),AX4=Mk(),OX4=(J)=>J&&typeof J==="object"&&!Array.isArray(J),K2=(J,Q,Y=!1)=>{if(Array.isArray(J)){let H=J.map((U)=>K2(U,Q,Y));return(U)=>{for(let N of H){let M=N(U);if(M)return M}return!1}}let X=OX4(J)&&J.tokens&&J.input;if(J===""||typeof J!=="string"&&!X)throw TypeError("Expected pattern to be a non-empty string");let G=Q||{},Z=G.windows,q=X?K2.compileRe(J,Q):K2.makeRe(J,Q,!1,!0),V=q.state;delete q.state;let K=()=>!1;if(G.ignore){let H={...Q,ignore:null,onMatch:null,onResult:null};K=K2(G.ignore,H,Y)}let W=(H,z=!1)=>{let{isMatch:U,match:N,output:M}=K2.test(H,q,Q,{glob:J,posix:Z}),L={glob:J,state:V,regex:q,posix:Z,input:H,output:M,match:N,isMatch:U};if(typeof G.onResult==="function")G.onResult(L);if(U===!1)return L.isMatch=!1,z?L:!1;if(K(H)){if(typeof G.onIgnore==="function")G.onIgnore(L);return L.isMatch=!1,z?L:!1}if(typeof G.onMatch==="function")G.onMatch(L);return z?L:!0};if(Y)W.state=V;return W};K2.test=(J,Q,Y,{glob:X,posix:G}={})=>{if(typeof J!=="string")throw TypeError("Expected input to be a string");if(J==="")return{isMatch:!1,output:""};let Z=Y||{},q=Z.format||(G?KU0.toPosixSlashes:null),V=J===X,K=V&&q?q(J):J;if(V===!1)K=q?q(J):J,V=K===X;if(V===!1||Z.capture===!0)if(Z.matchBase===!0||Z.basename===!0)V=K2.matchBase(J,Q,Y,G);else V=Q.exec(K);return{isMatch:Boolean(V),match:V,output:K}};K2.matchBase=(J,Q,Y)=>{return(Q instanceof RegExp?Q:K2.makeRe(Q,Y)).test(KU0.basename(J))};K2.isMatch=(J,Q,Y)=>K2(Q,Y)(J);K2.parse=(J,Q)=>{if(Array.isArray(J))return J.map((Y)=>K2.parse(Y,Q));return sZ1(J,{...Q,fastpaths:!1})};K2.scan=(J,Q)=>LX4(J,Q);K2.compileRe=(J,Q,Y=!1,X=!1)=>{if(Y===!0)return J.output;let G=Q||{},Z=G.contains?"":"^",q=G.contains?"":"$",V=`${Z}(?:${J.output})${q}`;if(J&&J.negated===!0)V=`^(?!${V}).*$`;let K=K2.toRegex(V,Q);if(X===!0)K.state=J;return K};K2.makeRe=(J,Q={},Y=!1,X=!1)=>{if(!J||typeof J!=="string")throw TypeError("Expected a non-empty string");let G={negated:!1,fastpaths:!0};if(Q.fastpaths!==!1&&(J[0]==="."||J[0]==="*"))G.output=sZ1.fastpaths(J,Q);if(!G.output)G=sZ1(J,Q);return K2.compileRe(G,Q,Y,X)};K2.toRegex=(J,Q)=>{try{let Y=Q||{};return new RegExp(J,Y.flags||(Y.nocase?"i":""))}catch(Y){if(Q&&Q.debug===!0)throw Y;return/$^/}};K2.constants=AX4;WU0.exports=K2});var HM=v((dg8,FU0)=>{var HU0=Ok(),wX4=Lk();function zU0(J,Q,Y=!1){if(Q&&(Q.windows===null||Q.windows===void 0))Q={...Q,windows:wX4.isWindows()};return HU0(J,Q,Y)}Object.assign(zU0,HU0);FU0.exports=zU0});var dE;var tZ1=L1(()=>{dE={name:"amp",description:"The frontier coding agent, with a highly capable `smart` mode and a fast `free` mode. ",private:!0,displayName:"Amp (Research Preview)",version:"0.0.0-dev",publisher:"sourcegraph",license:"Apache-2.0",categories:["AI","Chat","Programming Languages","Machine Learning"],keywords:["sourcegraph","amp","amp code","ampcode","ai","assistant","llm","Claude","Claude Sonnet 4.5","GPT-5","agent","free","Claude Sonnet"],icon:"./resources/amp-icon.png",scripts:{dev:"pnpm run -s dev:desktop","dev:insiders":"pnpm run -s dev:desktop:insiders","dev:watch":"NODE_ENV=development bun run scripts/watch.ts","start:dev:desktop":"node scripts/start-dev.js","start:dev:desktop:insiders":"node scripts/start-dev.js --insiders","start:dev:debugger":"pnpm run -s build:dev:desktop && pnpm run -s ./src/autoedit/webview dev","dev:desktop":"pnpm run -s build:dev:desktop && pnpm run start:dev:desktop","dev:desktop:insiders":"pnpm run -s build:dev:desktop && pnpm run start:dev:desktop:insiders","build:dev:desktop":"NODE_ENV=development bun run scripts/build.ts",build:"pnpm run -s _build:extension && concurrently -n 'debugger,web,review' 'pnpm run -s _build:debugger' 'pnpm run -s _build:web' 'pnpm run -s _build:tab:review'","build:production":"pnpm run -s _build:extension:production && concurrently -n 'debugger,web,review' 'pnpm run -s _build:debugger:production' 'pnpm run -s _build:web:production' 'pnpm run -s _build:tab:review:production'","_build:extension":"NODE_ENV=development bun run scripts/build.ts","_build:extension:production":"NODE_ENV=production bun run scripts/build.ts","_build:web":"pnpm -C ../web run build && cp -R ../web/build dist/web-build","_build:web:production":"pnpm -C ../web run build:production && cp -R ../web/build dist/web-build","_build:debugger":"pnpm -C ./src/autoedit/webview run build && cp -R ./src/autoedit/webview/build dist/autoedit","_build:debugger:production":"cross-env NODE_ENV=production pnpm -C ./src/autoedit/webview run build && cp -R ./src/autoedit/webview/build dist/autoedit","_build:tab:review":"pnpm -C ./src/autoedit/review-panel-webview run build && mkdir -p dist/autoedit && cp -R ./src/autoedit/review-panel-webview/build dist/autoedit/review-panel","_build:tab:review:production":"cross-env NODE_ENV=production pnpm -C ./src/autoedit/review-panel-webview run build && mkdir -p dist/autoedit && cp -R ./src/autoedit/review-panel-webview/build dist/autoedit/review-panel","build:icon-font":"npx -y svgtofont --sources ./icon-font/svg --output ./icon-font/build && cp ./icon-font/build/amp-icons.woff ./resources","dev:forks":"pnpm dev:vsix && cursor --install-extension dist/amp-dev.vsix --force && windsurf --install-extension dist/amp-dev.vsix --force","dev:vsix":"pnpm run -s build && vsce package --no-dependencies --pre-release --out dist/amp-dev.vsix && code --install-extension dist/amp-dev.vsix --force","dev:insiders:vsix":"pnpm run -s build && vsce package --no-dependencies --pre-release --out dist/amp-dev.vsix && code-insiders --install-extension dist/amp-dev.vsix --force","prod:vsix":"pnpm run -s build:production && vsce package --no-dependencies --pre-release --out dist/amp-prod.vsix && code --install-extension dist/amp-prod.vsix --force","prod:vsix:test-manual":"bun run scripts/vsix-test-manual.ts","prod:vsix:test-ci":"bun run scripts/vsix-test-ci.ts",test:"vitest run","test:dev":"vitest"},homepage:"https://ampcode.com",repository:{type:"git",url:"https://github.com/sourcegraph/amp",directory:"vscode"},author:{name:"The Amp Team at Sourcegraph",email:"amp-devs@sourcegraph.com"},engines:{vscode:"^1.79.0",node:">=22.0.0"},main:"./dist/extension.cjs",activationEvents:["onStartupFinished"],extensionDependencies:["vscode.git"],contributes:{languages:[{id:"jsonc",filenamePatterns:["**/Library/Application Support/ampcode/managed-settings.json","**/etc/ampcode/managed-settings.json","**/ProgramData/ampcode/managed-settings.json"]}],viewsContainers:{activitybar:[{id:"sourcegraph-amp",title:"Amp",icon:"./resources/amp-mark.svg"}]},views:{"sourcegraph-amp":[{type:"webview",id:"amp.sidebarView",name:"Amp",icon:"./resources/amp-mark.svg",visibility:"visible"},{type:"webview",id:"amp.reviewPanel",name:"Review",icon:"$(compare-changes)",visibility:"visible",when:"config.amp.review.separatePanel"}]},commands:[{command:"amp.agent.newThread",title:"New Thread",category:"Amp",icon:"$(add)"},{command:"amp.agent.newWindow",title:"New Agent Window",category:"Amp",icon:"$(browser)",enablement:"amp.activated"},{command:"amp.agent.toggleVisibility",title:"Toggle Agent",category:"Amp"},{command:"amp.agent.openReview",title:"Open Amp Review",category:"Amp",icon:"$(compare-changes)",enablement:"amp.activated"},{command:"amp.agent.focusPromptEditor",title:"Focus Prompt Editor",category:"Amp"},{command:"amp.agent.addSelectionToPromptEditor",title:"Add Selection to Prompt",category:"Amp",enablement:"editorHasSelection"},{command:"amp.agent.switchAgentMode",title:"Switch Agent Mode for Current Thread",category:"Amp",enablement:"amp.hasMultipleVisibleModes"},{command:"amp.agent.setPromptFromRecentActions",title:"Create Prompt from Recent Actions",category:"Amp"},{command:"amp.agent.findInThread",title:"Find in Thread",category:"Amp",enablement:"amp.agent.active"},{command:"amp.agent.collapseAllInThread",title:"Collapse All Blocks in Thread",category:"Amp"},{command:"amp.agent.expandAllInThread",title:"Expand All Blocks in Thread",category:"Amp"},{command:"amp.agent.expandToggleInThread",title:"Toggle Expand All Blocks in Thread",category:"Amp"},{command:"amp.agent.toggleThreadSwitcher",title:"Switch to Thread...",category:"Amp",enablement:"amp.agent.active"},{command:"amp.agent.toggleCostDisplay",title:"Toggle Cost Display",category:"Amp"},{command:"amp.agent.navigateThreadPrevious",title:"Navigate to Previous Thread",category:"Amp",enablement:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.navigateThreadNext",title:"Navigate to Next Thread",category:"Amp",enablement:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.openThreadJSON",title:"Open Thread JSON",category:"Amp",enablement:"amp.isDevelopmentMode"},{command:"amp.testThreadSummary",title:"Test Thread Summary",category:"Amp",enablement:"amp.isDevelopmentMode"},{command:"amp.tab.quickPickMenu",title:"Show Tab Menu",category:"Amp",icon:"$(debug)",enablement:"amp.activated"},{command:"amp.tab.showDebugPanel",title:"Show Tab Debug Panel",category:"Amp",icon:"$(debug)",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.showDiff",title:"Tab: Show Diff",category:"Amp",icon:"$(diff)",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.diffPanel.acceptAll",title:"Tab Review: Accept All Changes",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.diffPanel.instruct",title:"Tab Review: Open Instruct Mode",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.manualTrigger",title:"Tab Manual Trigger",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.enable",title:"Enable Tab",category:"Amp",enablement:"amp.activated && !config.amp.tab.enabled"},{command:"amp.tab.disable",title:"Disable Tab",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.toggleForCurrentDocument",title:"Toggle Tab for Current Document",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.debugInfo",title:"Open Tab Debug Info",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.autoAcceptChain",title:"Accept Suggestion Chain",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.mcp.restartServers",title:"Restart MCP Servers",category:"Amp"},{command:"amp.connect.reconnect",title:"Reconnect",category:"Amp",enablement:"amp.activated"},{command:"amp.agent.editUserPermissions",title:"Edit User Permissions",category:"Amp"},{command:"amp.agent.editWorkspacePermissions",title:"Edit Workspace Permissions",category:"Amp"},{command:"amp.commandPalette.show",title:"Show Amp Command Palette",category:"Amp",icon:"$(list-flat)"}],menus:{"editor/context":[{command:"amp.agent.addSelectionToPromptEditor",when:"editorHasSelection",group:"amp@1"}]},keybindings:[{command:"amp.agent.newThread",key:"ctrl+l",mac:"cmd+l",when:"amp.primaryShortcuts"},{command:"amp.agent.newThread",key:"ctrl+alt+j",mac:"cmd+alt+j",when:"!amp.primaryShortcuts"},{command:"amp.agent.newWindow",key:"ctrl+shift+l",mac:"cmd+shift+l"},{command:"amp.agent.toggleVisibility",key:"ctrl+i",mac:"cmd+i",when:"amp.primaryShortcuts"},{command:"amp.agent.toggleVisibility",key:"ctrl+alt+u",mac:"cmd+alt+u",when:"!amp.primaryShortcuts"},{command:"amp.agent.findInThread",key:"ctrl+f",mac:"cmd+f",when:"amp.agent.active"},{command:"amp.agent.toggleThreadSwitcher",key:"ctrl+k",mac:"cmd+k",when:"amp.agent.active"},{command:"amp.agent.toggleCostDisplay",key:"ctrl+d",mac:"cmd+d",when:"amp.agent.active && amp.isSourcegraphTeammate || isWeb"},{command:"amp.agent.navigateThreadPrevious",key:"ctrl+shift+[",mac:"cmd+shift+[",when:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.navigateThreadNext",key:"ctrl+shift+]",mac:"cmd+shift+]",when:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.savePermissions",key:"ctrl+s",mac:"cmd+s",enablement:"editorTextFocus && resourcePath =~ /[\\\\/]amp[\\\\/]permissions-.*\\.sh$/i",when:"editorTextFocus && resourcePath =~ /[\\\\/]amp[\\\\/]permissions-.*\\.sh$/i"},{command:"amp.tab.diffPanel.acceptAll",key:"ctrl+enter",mac:"cmd+enter",when:"activeWebviewPanelId == 'ampTabDiff'"},{command:"amp.tab.diffPanel.instruct",key:"ctrl+i",mac:"cmd+i",when:"activeWebviewPanelId == 'ampTabDiff'"},{command:"amp.agent.openReview",key:"ctrl+;",mac:"cmd+;"},{command:"-extension.vim_tab",key:"tab",when:"editorTextFocus && vim.active && vim.mode != 'Insert' && !inlineEditIsVisible && !inDebugRepl"},{command:"-vscode-neovim.send",key:"tab",when:"neovim.init && (editorTextFocus && neovim.mode != insert && editorLangId not in neovim.editorLangIdExclusions || neovim.recording)"},{command:"amp.tab.accept",key:"tab",when:"editorTextFocus && amp.activated && amp.tab.active && !amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.showDiff",key:"shift+tab",when:"editorTextFocus && amp.activated && config.amp.tab.experimental.review && (amp.tab.active || inlineSuggestionVisible) && !amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.dismiss",key:"escape",when:"editorTextFocus && amp.activated && amp.tab.active && !amp.nextCursorSuggested && !suggestWidgetVisible && !amp.editorHasMultipleLineSelection"},{command:"amp.nextCursor.accept",key:"tab",when:"editorTextFocus && amp.activated && amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.nextCursor.discard",key:"escape",when:"editorTextFocus && amp.activated && amp.nextCursorSuggested && !suggestWidgetVisible && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.autoAcceptChain",key:"alt+shift+tab",when:"editorTextFocus && amp.activated && (amp.tab.active || amp.nextCursorSuggested) && !amp.editorHasMultipleLineSelection"},{command:"amp.autoImport.accept",key:"tab",when:"editorTextFocus && amp.activated && config.amp.tab.enabled && amp.autoImportSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.autoImport.discard",key:"escape",when:"editorTextFocus && amp.activated && config.amp.tab.enabled && amp.autoImportSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.commandPalette.show",key:"ctrl+shift+a",mac:"cmd+shift+a",when:"amp.activated"},{command:"amp.agent.switchAgentMode",key:"ctrl+shift+m",mac:"cmd+shift+m",when:"amp.activated && amp.hasMultipleVisibleModes"}],configuration:{type:"object",title:"Amp",properties:{"amp.url":{type:"string",examples:["https://ampcode.com/"],description:"URL to the Amp server, usually https://ampcode.com/",scope:"application"},"amp.notifications.enabled":{type:"boolean",default:!0,description:"Play notification sound when done or blocked",scope:"window"},"amp.mcpServers":{type:"object",description:"Model Context Protocol servers that expose tools",additionalProperties:{type:"object",oneOf:[{properties:{command:{type:"string"},args:{type:"array",items:{type:"string"}},env:{type:"object",additionalProperties:{type:"string"}}},required:["command"]},{properties:{url:{type:"string"},headers:{type:"object",description:"HTTP headers to send with requests to the MCP server",additionalProperties:{type:"string"}},oauth:{type:"object",description:"OAuth 2.0 configuration for MCP server authentication",properties:{clientId:{type:"string",description:"OAuth client ID"},clientSecret:{type:"string",description:"OAuth client secret (optional for public clients)"},authUrl:{type:"string",description:"OAuth authorization endpoint URL"},tokenUrl:{type:"string",description:"OAuth token endpoint URL"},scopes:{type:"array",description:"OAuth scopes to request",items:{type:"string"}},redirectUrl:{type:"string",description:"OAuth redirect URL (defaults to http://localhost:8976/oauth/callback)"}}}},required:["url"]}]}},"amp.mcpTrustedServers":{type:"array",markdownDescription:"MCP server trust decisions. **Security Note:** This setting is only read from user settings, never workspace settings, to prevent malicious repositories from auto-approving MCP servers.",scope:"application",items:{type:"object",properties:{serverName:{type:"string",description:"MCP server name"},specHash:{type:"string",description:"Hash of the server configuration"},allow:{type:"boolean",description:"Whether this server is approved"}},required:["serverName","specHash","allow"]}},"amp.workspaces":{type:"array",markdownDescription:"Workspace-level configuration. This setting is only read from user settings, never workspace settings.",scope:"application",items:{type:"object",properties:{path:{type:"string",description:"Absolute path to the workspace"},allowAllMcpServers:{type:"boolean",description:"Whether to automatically trust all MCP servers in this workspace"}},required:["path"]}},"amp.mcpPermissions":{type:"array",description:"Permissions for Model Context Protocol (MCP) servers. Controls which MCP servers can be used.",items:{type:"object",properties:{matches:{$ref:"https://static.ampcode.com/schemas/permissions.schema.json#/$defs/permissionMatchCondition"},action:{type:"string",enum:["allow","reject"],description:"Whether to allow or reject MCP servers matching the condition"}},required:["matches","action"],additionalProperties:!1},default:[],scope:"application"},"amp.permissions":{$ref:"https://static.ampcode.com/schemas/permissions.schema.json",description:"Entries checked in sequence to configure tool permissions",default:[]},"amp.experimental.promptAutocompleteMode":{type:"string",enum:["disabled","word-based"],enumDescriptions:["Disabled - no prompt autocomplete","Offline word completion from workspace and thread context"],default:"word-based",markdownDescription:"**Experimental:** Prompt autocomplete suggestions while typing.",scope:"application"},"amp.experimental.promptAutocomplete.verboseLogging":{type:"boolean",default:!1,markdownDescription:"Enable verbose logging for prompt autocomplete.",scope:"application"},"amp.experimental.tools":{type:"array",description:"Enable experimental tools by name. Available tools: kraken",items:{type:"string"},default:[],scope:"application"},"amp.tools.disable":{type:"array",markdownDescription:'Disable specific tools by name. Glob patterns using * are supported\n\nExamples:\n- Disable edit_file: `["builtin:edit_file"]`\n- Disable all playwright tab tools: `["mcp__playwright__browser_tab*"]`',items:{type:"string"},default:[]},"amp.toolbox.path":{type:"string",markdownDescription:"Path to the directory containing toolbox scripts. Supports colon-separated paths.",scope:"window"},"amp.dangerouslyAllowAll":{type:"boolean",description:"If true, never ask for confirmation when running commands",scope:"window",default:!1},"amp.model.sonnet":{type:"boolean",description:"Use Claude Sonnet 4.5 instead of Gemini 3",scope:"window",default:!1},"amp.guardedFiles.allowlist":{type:"array",description:"Glob patterns for files that should bypass guarded file protection. Files matching these patterns can be modified without user confirmation.",items:{type:"string"},default:[],scope:"window"},"amp.anthropic.thinking.enabled":{type:"boolean",default:!0,description:"Enable Claude's extended thinking capabilities",scope:"application"},"amp.tools.inactivityTimeout":{type:"number",default:300,minimum:1,maximum:3600,description:"How many seconds of no output to wait before canceling bash commands.",scope:"workspace"},"amp.tools.stopTimeout":{type:"number",default:300,description:"How many seconds to wait before canceling a running tool.",scope:"application"},"amp.terminal.commands.nodeSpawn.loadProfile":{type:"string",enum:["always","never","daily"],default:"always",description:"Before running commands (including MCP servers), whether to load environment variables from the user's profile (.bashrc, .zshrc, .envrc) as visible from the workspace root directory.",scope:"application"},"amp.todos.enabled":{type:"boolean",default:!0,description:"Enable TODOs tracking for managing tasks",scope:"application"},"amp.guidanceFiles.specs":{type:"boolean",default:!1,description:"[Experimental] Read `*.spec.md` files adjacent to `AGENT.md` files that are read",scope:"window"},"amp.security.audit.logMcpConnections":{type:"boolean",default:!1,description:"Enable telemetry logging for remote MCP server connections (for security auditing)",scope:"application"},"amp.review.separatePanel":{type:"boolean",default:!1,description:"Show the review panel as a separate container that's independently draggable to a different sidebar location.",scope:"window"},"amp.hooks":{type:"array",scope:"window",description:"[Experimental] Hooks are event handlers that can react to specific conditions.",items:{type:"object",properties:{compatibilityDate:{type:"string",const:"2025-05-13",default:"2025-05-13",description:"The version of the hook schema that this value was written to conform to"},id:{type:"string",description:"A unique identifier for the hook",examples:["run-vitest-with-env-vars"]},description:{type:"string",description:"A description of the hook"},on:{oneOf:[{type:"object",properties:{event:{type:"string",const:"tool:pre-execute",default:"tool:pre-execute",description:"Trigger when a tool is about to be executed"},tool:{oneOf:[{type:"string",description:"Tool name to match (e.g., 'edit_file')"},{type:"array",items:{type:"string"},description:"Tool names to match"}],description:"Trigger for the given tool name(s)"},"input.contains":{oneOf:[{type:"string",description:"String pattern to match in the tool input"},{type:"array",items:{type:"string"},description:"String patterns to match in the tool input"}],description:"Trigger only when the tool input contains the given literal string or strings"}},required:["event","tool","input.contains"]},{type:"object",properties:{event:{type:"string",const:"tool:post-execute",default:"tool:post-execute",description:"Trigger after a tool has been executed"},tool:{oneOf:[{type:"string",description:"Tool name to match (e.g., 'edit_file')"},{type:"array",items:{type:"string"},description:"Tool names to match"}],description:"Trigger for the given tool name(s)"}},required:["event","tool"]}]},action:{oneOf:[{type:"object",properties:{type:{type:"string",const:"send-user-message",default:"send-user-message",description:"Send a user message to interrupt the agent and cancel the tool call in the `tool:pre-execute` trigger before it starts to run"},message:{type:"string",description:"The text of the message to send"}},required:["type","message"]},{type:"object",properties:{type:{type:"string",const:"redact-tool-input",default:"redact-tool-input",description:"Redact the tool input after execution. Only allowed with `tool:post-execute` event."},redactedInput:{type:"object",description:"The replacement input data to use instead of the original tool input (must be an object)"}},required:["type","redactedInput"]}]},if:{type:"boolean",description:"A condition that determines whether the hook should be executed",default:!0}},required:["compatibilityDate","id","on","action"]},default:[]},"amp.tab.enabled":{type:"boolean",default:!1,description:"Enable Amp Tab",scope:"application"},"amp.tab.clipboard.enabled":{type:"boolean",default:!0,description:"Enable clipboard access for Amp Tab context",scope:"application"},"amp.tab.verboseLogs":{type:"boolean",default:!1,description:"Enable verbose logging for Amp Tab",scope:"application"},"amp.debugLogs":{type:"boolean",default:!1,description:"Enable debug logging in the Amp output channel",scope:"application"},"amp.tab.disabledLanguages":{type:"array",items:{type:"string"},default:[],examples:["markdown","python"],description:"List of language IDs for which Amp Tab is disabled",scope:"application"},"amp.tab.disableOnComment":{type:"boolean",default:!1,description:"Disable Amp Tab completions on comment lines",scope:"application"},"amp.tab.autoImport.enabled":{type:"boolean",default:!0,description:"Enable auto import in Amp Tab",scope:"application"},"amp.tab.dismissCommandIds":{type:"array",items:{type:"string"},default:["extension.vim_escape","vim.escape","vscode-neovim.escape","vscode-neovim.escapeKey"],description:"Command IDs to run when Escape is pressed to dismiss an Amp Tab suggestion",scope:"application"},"amp.tab.experimental.showHotStreakProgress":{type:"boolean",default:!1,description:"Experimental: Show hot streak progress in image-rendered suggestions",scope:"window"},"amp.tab.experimental.autoAccept.delayMs":{type:"number",default:0,description:"Experimental: Delay in milliseconds before auto-accepting Amp Tab suggestions",scope:"application"},"amp.tab.experimental.unobtrusiveDiffs":{type:"boolean",default:!1,description:"Experimental: Enable unobtrusive diffs mode for Amp Tab suggestions. When enabled, suggestions are shown as image overlays to avoid layout shifts and visual interference with existing code.",scope:"application"},"amp.tab.experimental.review":{type:"boolean",default:!1,description:"Experimental: Enable review mode for Amp Tab. When enabled, adds the ability to review suggestion changes with Shift+Tab shortcut and review panel.",scope:"window"},"amp.tab.diagnosticTracking":{type:"string",enum:["disabled","same_file","multi_file"],default:"multi_file",description:"Enable diagnostic tracking for Amp Tab suggestions. 'disabled' = no tracking, 'same_file' = track diagnostics within the same file, 'multi_file' = track diagnostics across multiple files.",scope:"application"},"amp.tab.hoverDiagnosticSuggestions":{type:"boolean",default:!1,description:"Show suggestions when hovering over diagnostics.",scope:"application"},"amp.tab.experimental.displayMode":{type:"string",enum:["eager","subtle"],default:"eager",description:"Experimental: Control how Amp Tab suggestions are displayed. 'eager' = show diff immediately, 'subtle' = show 'Tab to Jump' first, then show diff after user interaction.",scope:"application"},"amp.tab.experimental.disableClientFilters":{type:"array",items:{type:"string",enum:["recentlyRejectedCodeToRewrite","recentEdits","rewriteAreaOverlap","bigModification","incompatibleWithSelectedCompletionContextItem","recentlyRejectedDiff","whiteSpaceOnlyChange","formattingOnlyChange"]},default:[],description:"Experimental: Disable specific client-side filters to observe unfiltered model behavior.",scope:"application"},"amp.ui.zoomLevel":{type:"number",default:1,description:"Zoom level for the Amp UI",scope:"application"},"amp.experimental.bookkeeper":{type:"boolean",default:!1,description:"Enable the Bookkeeper subagent for reading and querying Excel workbooks (.xlsx)",scope:"window"},"amp.experimental.planMode":{type:"boolean",default:!1,description:"Enable plan mode for collaborative planning before execution",scope:"window"},"amp.experimental.dojoMode":{type:"boolean",default:!1,description:"Enable dojo mode - a learning mode that guides you to discover solutions yourself",scope:"window"},"amp.git.commit.coauthor.enabled":{type:"boolean",default:!0,description:"Enable adding Amp as co-author in git commits",scope:"window"},"amp.git.commit.ampThread.enabled":{type:"boolean",default:!0,description:"Enable adding Amp-Thread trailer in git commits",scope:"window"},"amp.tryOpus":{type:"boolean",default:!1,description:"Try Claude Opus 4.5 as the main agent model. See https://ampcode.com/news/try-opus",scope:"window"}}},icons:{"amp-agent-file":{description:"Amp agent file",default:{fontPath:"resources/amp-icons.woff",fontCharacter:"\\0041"}}}},capabilities:{untrustedWorkspaces:{supported:"limited",description:"Amp only uses MCP servers from trusted workspaces because they execute code.",restrictedConfigurations:["amp.mcpServers","amp.mcpPermissions","amp.url"]},virtualWorkspaces:{supported:!1,description:"Amp is not supported in virtual workspaces like GitHub.dev because Amp requires local file system access and terminal capabilities."}},dependencies:{"@anthropic-ai/sdk":"catalog:","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.57.2","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.57.2","@opentelemetry/exporter-metrics-otlp-http":"^0.57.2","@opentelemetry/exporter-trace-otlp-http":"^0.57.2","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-logs":"^0.57.2","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.57.2","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/sdk-trace-node":"^1.30.1","@opentelemetry/semantic-conventions":"^1.34.0","@sourcegraph/amp-core":"workspace:*","@sourcegraph/amp-uri":"workspace:*","@sourcegraph/observable":"workspace:*","canvaskit-wasm":"^0.40.0","detect-indent":"^7.0.1",diff:"catalog:","fast-json-stable-stringify":"^2.1.0","fast-myers-diff":"^3.2.0","fast-xml-parser":"^5.2.3",isbinaryfile:"^5.0.5","jsonc-parser":"^3.3.1",lodash:"^4.17.21","lru-cache":"^11.1.0","node-fetch":"^3.3.2",shiki:"3.8.1",systeminformation:"^5.27.7",uuid:"^11.1.0","vscode-languageserver-textdocument":"^1.0.12","wink-nlp-utils":"^2.1.0",ws:"^8.18.3"},devDependencies:{"@secretlint/secretlint-rule-no-dotenv":"^11.2.5","@secretlint/secretlint-rule-preset-recommend":"^11.2.5","@sourcegraph/amp-web":"workspace:*","@types/bun":"^1.2.17",dedent:"catalog:","@types/diff":"catalog:","@types/jest-image-snapshot":"^6.4.0","@types/lodash":"^4.17.15","@types/node":"catalog:","@types/uuid":"^10.0.0","@types/vscode":"^1.79.0","@types/ws":"^8.18.1","@vscode/test-electron":"^2.4.1","@vscode/vsce":"^3.2.2","cross-env":"^7.0.3","crypto-browserify":"^3.12.1","jest-image-snapshot":"^6.5.0","os-browserify":"^0.3.0","path-browserify":"^1.0.1","rollup-plugin-polyfill-node":"^0.13.0",tsx:"^4.19.4"}}});function IX4(J){return typeof J==="number"&&Number.isInteger(J)&&J>=1&&J<=3600}function BU0(J){let Q=J.settings["tools.inactivityTimeout"],Y=J.settings["tools.stopTimeout"],X=Q;if(X===void 0&&Y!==void 0)X=Y;if(X===void 0)X=dE.contributes.configuration.properties["amp.tools.inactivityTimeout"].default;if(!IX4(X))return null;return X*1000}function NU0(J){let Q=J.settings["tools.stopTimeout"],Y=dE.contributes.configuration.properties["amp.tools.stopTimeout"].default;return(Q??Y)*1000}var UU0;var ol=L1(()=>{tZ1();UU0=dE.contributes.configuration.properties});function aJ(J){let Q=p8[J];return`${Q.provider}/${Q.name}`}function gG(J){let[Q,Y]=J.split("/");for(let X of Object.values(p8))if(X.provider===Q&&X.name===Y)return X;switch(Q){case"anthropic":return p8.CLAUDE_SONNET_4_5;case"openai":return p8.GPT_5;case"xai":return p8.GROK_CODE_FAST_1;case"cerebras":return p8.Z_AI_GLM_4_6;case"fireworks":return p8.FIREWORKS_GLM_4P6;case"moonshotai":return p8.KIMI_K2_INSTRUCT;case"openrouter":return p8.SONOMA_SKY_ALPHA;case"groq":return p8.GPT_OSS_120B;case"vertexai":return p8.GEMINI_2_5_FLASH_PREVIEW_09_2025;default:throw Error(`Unknown provider: ${Q}`)}}function mG(J){let Q=J.indexOf("/");if(Q===-1)return J;return J.slice(Q+1)}function bW(J,Q){let Y=gG(J);if(Q&&Y.maxInputTokensInFreeMode)return Y.maxInputTokensInFreeMode;return Y.contextWindow-Y.maxOutputTokens}var C9,p8,eZ1;var gW=L1(()=>{C9={ANTHROPIC:"anthropic",OPENAI:"openai",XAI:"xai",CEREBRAS:"cerebras",FIREWORKS:"fireworks",GROQ:"groq",MOONSHOT:"moonshotai",OPENROUTER:"openrouter",VERTEXAI:"vertexai"},p8={CLAUDE_SONNET_4:{provider:C9.ANTHROPIC,name:"claude-sonnet-4-20250514",displayName:"Claude Sonnet 4",contextWindow:1e6,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_5:{provider:C9.ANTHROPIC,name:"claude-sonnet-4-5-20250929",displayName:"Claude Sonnet 4.5",contextWindow:1e6,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4:{provider:C9.ANTHROPIC,name:"claude-opus-4-20250514",displayName:"Claude Opus 4",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_1:{provider:C9.ANTHROPIC,name:"claude-opus-4-1-20250805",displayName:"Claude Opus 4.1",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_5:{provider:C9.ANTHROPIC,name:"claude-opus-4-5-20251101",displayName:"Claude Opus 4.5",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_HAIKU_4_5:{provider:C9.ANTHROPIC,name:"claude-haiku-4-5-20251001",displayName:"Claude Haiku 4.5",contextWindow:200000,maxOutputTokens:64000,capabilities:{reasoning:!0,vision:!0,tools:!0},freeTierEligible:!0,maxInputTokensInFreeMode:120000},GPT_5:{provider:C9.OPENAI,name:"gpt-5",displayName:"GPT-5",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_1:{provider:C9.OPENAI,name:"gpt-5.1",displayName:"GPT-5.1",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_CODEX:{provider:C9.OPENAI,name:"gpt-5-codex",displayName:"GPT-5 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_1_CODEX:{provider:C9.OPENAI,name:"gpt-5.1-codex",displayName:"GPT-5.1 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_MINI:{provider:C9.OPENAI,name:"gpt-5-mini",displayName:"GPT-5 Mini",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.25,output:2,cached:0.025},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_NANO:{provider:C9.OPENAI,name:"gpt-5-nano",displayName:"GPT-5 Nano",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.05,output:0.4,cached:0.005},capabilities:{reasoning:!0,vision:!0,tools:!0}},O3:{provider:C9.OPENAI,name:"o3",displayName:"o3",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:2,output:8,cached:0.5},capabilities:{reasoning:!0,tools:!0}},O3_MINI:{provider:C9.OPENAI,name:"o3-mini",displayName:"o3-mini",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:1.1,output:4.4,cached:0.55},capabilities:{reasoning:!0,tools:!0}},GPT_OSS_120B:{provider:C9.OPENAI,name:"openai/gpt-oss-120b",displayName:"GPT OSS 120B",contextWindow:128000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GROK_CODE_FAST_1:{provider:C9.XAI,name:"grok-code-fast-1",displayName:"Grok Code Fast 1",contextWindow:256000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0},freeTierEligible:!0},GEMINI_2_5_PRO:{provider:C9.VERTEXAI,name:"gemini-2.5-pro",displayName:"Gemini 2.5 Pro",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_2_5_FLASH:{provider:C9.VERTEXAI,name:"gemini-2.5-flash",displayName:"Gemini 2.5 Flash",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_2_5_FLASH_PREVIEW_09_2025:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-preview-09-2025",displayName:"Gemini 2.5 Flash (Preview)",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_2_5_FLASH_LITE:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-lite",displayName:"Gemini 2.5 Flash Lite",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-lite-preview-09-2025",displayName:"Gemini 2.5 Flash Lite (Preview)",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_3_PRO_PREVIEW:{provider:C9.VERTEXAI,name:"gemini-3-pro-preview",displayName:"Gemini 3 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},Z_AI_GLM_4_6:{provider:C9.CEREBRAS,name:"zai-glm-4.6",displayName:"Z.ai GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},FIREWORKS_QWEN3_CODER_480B:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/qwen3-coder-480b-a35b-instruct",displayName:"Qwen3 Coder 480B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_KIMI_K2_INSTRUCT:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_QWEN3_235B:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/qwen3-235b-a22b-instruct-2507",displayName:"Qwen3 235B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_GLM_4P6:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/glm-4p6",displayName:"GLM 4P6",contextWindow:162752,maxOutputTokens:40000,capabilities:{tools:!0}},KIMI_K2_INSTRUCT:{provider:C9.MOONSHOT,name:"kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:1e6,maxOutputTokens:32000,capabilities:{tools:!0}},SONOMA_SKY_ALPHA:{provider:C9.OPENROUTER,name:"sonoma-sky-alpha",displayName:"Sonoma Sky Alpha",contextWindow:256000,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_GLM_4_6:{provider:C9.OPENROUTER,name:"z-ai/glm-4.6",displayName:"OpenRouter GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},OPENROUTER_KIMI_K2_0905:{provider:C9.OPENROUTER,name:"moonshotai/kimi-k2-0905",displayName:"Kimi K2 0905 (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_CODER_480B:{provider:C9.OPENROUTER,name:"qwen/qwen3-coder",displayName:"Qwen3 Coder 480B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_235B:{provider:C9.OPENROUTER,name:"qwen/qwen3-235b-a22b-2507",displayName:"Qwen3 235B A22B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}}};eZ1={FINDER:"finder"}});function J$1(J,Q){let Y=mW(Q);if(!Y)return!1;if(PX4.has(J)){let X=Y.finder??eZ1.FINDER,G=TX4[X];if(J!==G)return!1}if(Y.includeTools)return Y.includeTools.includes(J);return!0}function uG(J,Q){let Y=J?.["internal.visibleModes"]??[];return Object.values(cE).filter((X)=>{if(Y.includes(`!${X.key}`))return!1;if(Q===!1&&F5(X.key))return!1;let Z="visible"in X?X.visible:!1,q=Y.includes(X.key),V=X.key==="plan"&&J?.["experimental.planMode"]===!0,K=J?.["experimental.dojoMode"]===!0;if(X.key==="free-dojo")return K&&(Q===!0||Q===void 0);if(X.key==="dojo")return K&&(Q===!1||Q===void 0);return Z||q||V}).map((X)=>({mode:X.key,description:"description"in X?X.description:void 0})).sort((X,G)=>X.mode.localeCompare(G.mode))}function mW(J){return Object.values(cE).find((Q)=>Q.key===J)}function wk(J){return mW(J)?.primaryModel??aJ("CLAUDE_SONNET_4_5")}function Ek(J){let Q=mW(J);if(!Q)return!1;return gG(Q.primaryModel).capabilities?.vision??!1}function F5(J){return J==="free"||J.startsWith("free-")}function Q$1(J,Q){return Q.find((Y)=>Y.mode===J)?.description}function Ik(J,Q){let X=(Q.findIndex((Z)=>Z.mode===J)+1)%Q.length;return Q[X]?.mode??"smart"}var PX4,TX4,MU0,LU0,RX4,CX4,jX4,SX4,_X4,DU0,kX4,yX4,cE,xX4;var C$=L1(()=>{gW();PX4=new Set(["finder"]),TX4={finder:"finder"},MU0={r:0,g:55,b:0},LU0={r:0,g:255,b:136},RX4={r:66,g:133,b:255},CX4={r:217,g:101,b:112},jX4=[{r:66,g:133,b:255},{r:155,g:114,b:203},{r:217,g:101,b:112}],SX4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","get_diagnostics","web_search","read_web_page","todo_read","todo_write","read_thread","skill"],_X4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","read_thread","skill","oracle","librarian","Task","kraken"],DU0=["Read","Grep","glob","finder","Bash","get_diagnostics","web_search","read_web_page","mermaid"],kX4=["Read","Grep","glob","finder","librarian","edit_plan","read_plan","web_search","read_web_page"],yX4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","todo_read","todo_write","read_thread","skill","oracle","librarian","Task","kraken","edit_plan","read_plan"],cE={SMART:{key:"smart",displayName:"Smart",description:"The most capable model and set of tools",primaryModel:aJ("GEMINI_3_PRO_PREVIEW"),includeTools:yX4,visible:!0,uiHints:{labelAnimation:"glow",primaryColor:RX4,secondaryColor:CX4,gradientStops:jX4}},FREE:{key:"free",displayName:"Free",description:"Amp Free",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:SX4,visible:!0,uiHints:{primaryColor:{r:0,g:26,b:51},secondaryColor:{r:0,g:184,b:255}}},RUSH:{key:"rush",displayName:"Rush",description:"Faster and cheaper for small, well-defined tasks",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:_X4,visible:!0,uiHints:{fasterAnimation:!0,labelAnimation:"jitter",primaryColor:{r:128,g:51,b:0},secondaryColor:{r:255,g:215,b:0}}},PLAN:{key:"plan",displayName:"Plan",description:"Collaborative planning mode",primaryModel:aJ("GPT_5_1_CODEX"),includeTools:kX4,visible:!1,uiHints:{primaryColor:{r:192,g:80,b:192},secondaryColor:{r:64,g:64,b:255}}},DOJO_FREE:{key:"free-dojo",displayName:"Dojo (Free)",description:"Learning mode - guides you to discover solutions yourself",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:DU0,visible:!1,uiHints:{primaryColor:{r:26,g:77,b:46},secondaryColor:{r:212,g:175,b:55}}},DOJO:{key:"dojo",displayName:"Dojo",description:"Learning mode - guides you to discover solutions yourself",primaryModel:aJ("CLAUDE_SONNET_4_5"),includeTools:DU0,visible:!1,uiHints:{primaryColor:{r:26,g:77,b:46},secondaryColor:{r:212,g:175,b:55}}}},xX4=Object.values(cE).map((J)=>J.key)});function rl(J,Q,Y){if(J.startsWith("mcp__"))return Q.allowMcp??!1;if(J.startsWith("tb__")){if(!(Q.allowToolbox??!1))return!1;let X="subagentType"in Q?Q.subagentType:void 0;if(X&&Y){if(!Y.subagentTypes)return!1;return Y.subagentTypes.includes("all")||Y.subagentTypes.includes(X)}return!0}return Q.includeTools.includes(J)}var vX4,fX4,Y$1,hX4,bX4,gX4,mX4,x2,sg8;var uW=L1(()=>{gW();vX4=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],fX4=["Grep","glob","Read"],Y$1=["Read","Grep","glob","web_search","read_web_page","read_thread"],hX4=["Grep","glob","Read","Bash","edit_file","create_file","format_file","read_web_page","get_diagnostics","web_search","finder"],bX4=["Read","glob","Grep","enqueue_file_edit","fastmod"],gX4=["create_file","edit_file","glob","Read","Grep","format_file","get_diagnostics"],mX4=["describe_workbook","execute_query"],x2={finder:{key:"finder",displayName:"Finder",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:fX4,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:aJ("GPT_5_1"),includeTools:Y$1,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:vX4,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:hX4,allowMcp:!0,allowToolbox:!0},"kraken-scope":{key:"kraken-scope",displayName:"Kraken Scope",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:bX4,allowMcp:!1,allowToolbox:!0,subagentType:"scope"},"kraken-executor":{key:"kraken-executor",displayName:"Kraken Executor",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:gX4,allowMcp:!1,allowToolbox:!0,subagentType:"executor"},bookkeeper:{key:"bookkeeper",displayName:"Bookkeeper",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:mX4,allowMcp:!1,allowToolbox:!1}},sg8=Object.keys(x2)});function sl(J,Q){return new G0((Y)=>{let X=setTimeout(G,Q);function G(){Y.error(Error(`Tool execution timed out after ${Q/1000} seconds`))}function Z(){if(X)clearTimeout(X);X=setTimeout(G,Q)}let q=J.subscribe({next:(V)=>{Z(),Y.next(V)},error:(V)=>{if(X)clearTimeout(X),X=null;Y.error(V)},complete:()=>{if(X)clearTimeout(X),X=null;Y.complete()}});return()=>{if(X)clearTimeout(X),X=null;q.unsubscribe()}})}var X$1=L1(()=>{o0()});function h7(J,Q){let Y={name:Q.name,description:Q.description,inputSchema:Q.inputSchema,source:Q.source,meta:Q.meta,customizedForModel:!1},X=Q.modelCustomizations;if(X){for(let G of X)if(G.modelSelector.test(J))Y={...Y,name:G.name??Y.name,description:G.description??Y.description,inputSchema:G.inputSchema??Y.inputSchema,customizedForModel:!0}}return Y}function W2(J){return["done","error","rejected-by-user","cancelled"].includes(J.status)}function wU0(J){return["done","error","cancelled"].includes(J.status)}function G$1(J){return typeof J==="object"&&"key"in J}function tl(J){let Q=[],Y=new y4,X;function G(q,V){let K=Q.filter((W)=>W.spec.name===q);if(K.length===0&&q==="Glob")K=Q.filter((W)=>W.spec.name==="glob");for(let W of K)if(iE(W.spec,V).enabled)return W;return}function Z(q,V,K){if(!q)throw Error("spec is required");let W=Q.findIndex((L)=>L.spec.name===q.name),H=W!==-1?Q[W]:void 0;if(q.source!=="builtin"&&H?.spec.source==="builtin")return f.warn("Ignoring external tool registration - builtin takes precedence",{toolName:q.name,externalSource:q.source}),{dispose:()=>{}};let N={spec:q,fn:Promise.resolve(V),preprocessArgs:K};if(H&&JSON.stringify(H.spec.source)===JSON.stringify(q.source))f.debug("Replacing existing tool registration (idempotent)",{toolName:q.name,source:q.source}),Q[W]=N;else Q.push(N);return Y.next(),{dispose:()=>{let L=Q.indexOf(N);if(L!==-1)Q.splice(L,1),Y.next()}}}return J.configService.config.subscribe((q)=>{X=q}),{registerTool({spec:q,fn:V,preprocessArgs:K}){if(!V)return uX4;return Z(q,V,K)},tools:u8(J.configService.config,Y.pipe(k9(void 0))).pipe(q6(([q])=>{return Q.map((V)=>({spec:V.spec,...iE(V.spec,q)})).sort((V,K)=>V.spec.name.localeCompare(K.spec.name))})),invokeTool(q,V,K){let W=performance.now(),H=()=>pX4.record(performance.now()-W,{toolName:q});if(q===$$1&&V.args&&"invalid_tool_name"in V.args&&typeof V.args.invalid_tool_name==="string"){lE.add(1,{toolName:q,error:"invalid"});let N=Z$1(V.args.invalid_tool_name);return new G0((M)=>{M.error(Error(N))})}let z=G(q,K.config);if(!z){let N=Q.filter((E)=>E.spec.name===q);if(N.length===0)return lE.add(1,{toolName:q,error:"not_found"}),new G0((E)=>{E.error(Error(`tool ${JSON.stringify(q)} not found`))});let M=N[0],L=iE(M.spec,K.config);lE.add(1,{toolName:q,error:"disabled"});let A=L.enabled?"unknown":L.disabledReason;return new G0((E)=>{E.error(Error(`tool ${JSON.stringify(q)} is disabled: ${A}`))})}let U=K.subagentSpec??K.agentMode;if(U&&!this.isToolAllowed(q,U)){lE.add(1,{toolName:q,error:"disabled"});let N=G$1(U)?U.displayName??U.key:`${U} mode`;return new G0((M)=>{M.error(Error(`tool ${JSON.stringify(q)} is not allowed for ${N}`))})}if(K.thread.mainThreadID&&!K.subagentSpec&&!rl(q,x2["task-subagent"]))return lE.add(1,{toolName:q,error:"disabled"}),new G0((N)=>{N.error(Error(`tool ${JSON.stringify(q)} is not allowed for subagents`))});return lE.add(1,{toolName:q}),e6(()=>z.fn).pipe(r4((N)=>{let M=N(V,K);if(z.spec.meta?.disableTimeout)return M;return sl(M,NU0(K.config))}),wQ(()=>H()))},preprocessArgs(q,V,K){let W=G(q,K.config);if(!W||!W.preprocessArgs)return;let H=W.preprocessArgs;try{return H(V,K)}catch(z){f.error("preprocessArgs",{id:q,args:V,error:String(z)});return}},isToolAllowed(q,V){if(G$1(V)){let K=Q.find((W)=>W.spec.name===q);return rl(q,V,K?.spec.meta)}return J$1(q,V)},getTools(q){return u8(J.configService.config,Y.pipe(k9(void 0))).pipe(q6(([V])=>{return Q.filter((K)=>{if(G$1(q))return rl(K.spec.name,q,K.spec.meta);return J$1(K.spec.name,q)}).map((K)=>({spec:K.spec,...iE(K.spec,V)})).sort((K,W)=>K.spec.name.localeCompare(W.spec.name))}))},getToolsForMode(q,V){if(V)return this.getTools(x2["task-subagent"]);return this.getTools(q)},getExecutionProfile(q){if(!X)return;return G(q,X)?.spec.executionProfile},dispose(){}}}function Pk(J,Q){for(let Y of Q){if(Y==="")continue;if(Y.length===1){if(Y==="*")return!0;if(Y===J)return!0;continue}if(J===Y)return!0;if(Y.includes("*")||Y.includes("?")||Y.includes("[")||Y.includes("{"))try{if(OU0.default(Y,{dot:!0})(J))return!0}catch(X){continue}}return!1}function iE(J,Q){let Y=Q.settings?.["tools.disable"]??[];if(Pk(J.name,Y))return{enabled:!1,disabledReason:"settings"};if(typeof J.source==="object"&&"mcp"in J.source){let X=dX4(J.name);if(X){if(J.source.mcp.replace(/[\s-]+/g,"_")===X.server){if(Pk(X.tool,Y))return{enabled:!1,disabledReason:"settings"};let Z=`mcp__${J.source.mcp}__${X.tool}`;if(Pk(Z,Y))return{enabled:!1,disabledReason:"settings"}}}}if(J.source==="builtin"&&Pk(`builtin:${J.name}`,Y))return{enabled:!1,disabledReason:"settings"};if(typeof J.source==="object"&&"toolbox"in J.source&&Pk(`toolbox:${J.name}`,Y))return{enabled:!1,disabledReason:"settings"};if(J.name===Z7||J.name===PV){if(Q.settings?.["todos.enabled"])return{enabled:!0};return{enabled:!1,disabledReason:"feature-flag"}}return{enabled:!0}}function Z$1(J){return`Invalid tool name ${JSON.stringify(J)}. Tool names must match the pattern ${Tk.toString()}. Try again with a valid tool name.`}function dX4(J){let[,Q,Y]=J.split(/mcp__([^ ]+)__([^ ]+)/);if(Q&&Y)return{server:Q,tool:Y};return}function q$1(J){if(J.status==="in-progress"||J.status==="done"||J.status==="cancelled"||J.status==="error")return J.progress;return}var AU0,OU0,uX4,$$1="invalid_tool",Tk,EU0,lE,pX4;var b7=L1(()=>{o0();L0();ol();C$();uW();X$1();A4();AU0=N6(b6(),1),OU0=N6(HM(),1);uX4={dispose(){}};Tk=/^[-a-zA-Z0-9_]{1,64}$/,EU0=AU0.metrics.getMeter("tool_service"),lE=EU0.createCounter("tool_service.invocation_count",{description:"Number of tool invocations"}),pX4=EU0.createHistogram("tool_service.invocation_latency",{description:"Latency of tool invocations",unit:"ms"})});var jU0=v((RU0)=>{Object.defineProperty(RU0,"__esModule",{value:!0});RU0.calcSlices=RU0.applyPatch=RU0.calcPatch=RU0.lcs=RU0.diff=RU0.diff_core=void 0;function cX4(J,Q){let{b:Y,eq:X,stack_base:G}=J,{i:Z,N:q,j:V,M:K,Z:W,stack_top:H}=J;for(;;)switch(Q){case 0:{J:while(q>0&&K>0){Y.fill(0,0,2*W);let z=q-K,U=q+K,N=U&1,M=Z+q-1,L=V+K-1,A=(U+N)/2,E;Q:for(let P=0;P<=A;P++){let I=2*Math.max(0,P-K)-P,R=P-2*Math.max(0,P-q);for(let S=I;S<=R;S+=2){let y=Y[S-1-W*Math.floor((S-1)/W)],h=Y[S+1-W*Math.floor((S+1)/W)],u=S===-P||S!==P&&y<h?h:y+1,p=u-S,g=u,i=p;while(g<q&&i<K&&X(Z+g,V+i))g++,i++;if(Y[S-W*Math.floor(S/W)]=g,N===1&&(E=z-S)>=1-P&&E<P&&g+Y[W+E-W*Math.floor(E/W)]>=q)if(P>1||g!==u){G[H++]=Z+g,G[H++]=q-g,G[H++]=V+i,G[H++]=K-i,q=u,K=p,W=2*(Math.min(q,K)+1);continue J}else break Q}for(let S=I;S<=R;S+=2){let y=Y[W+S-1-W*Math.floor((S-1)/W)],h=Y[W+S+1-W*Math.floor((S+1)/W)],u=S===-P||S!==P&&y<h?h:y+1,p=u-S,g=u,i=p;while(g<q&&i<K&&X(M-g,L-i))g++,i++;if(Y[W+S-W*Math.floor(S/W)]=g,N===0&&(E=z-S)>=-P&&E<=P&&g+Y[E-W*Math.floor(E/W)]>=q)if(P>0||g!==u){G[H++]=Z+q-u,G[H++]=u,G[H++]=V+K-p,G[H++]=p,q=q-g,K=K-i,W=2*(Math.min(q,K)+1);continue J}else break Q}}if(q===K)continue;if(K>q)Z+=q,V+=q,K-=q,q=0;else Z+=K,V+=K,q-=K,K=0;break}if(q+K!==0)if(J.pxe===Z||J.pye===V)J.pxe=Z+q,J.pye=V+K;else{let z=J.pxs;if(J.oxs=J.pxs,J.oxe=J.pxe,J.oys=J.pys,J.oye=J.pye,J.pxs=Z,J.pxe=Z+q,J.pys=V,J.pye=V+K,z>=0)return J.i=Z,J.N=q,J.j=V,J.M=K,J.Z=W,J.stack_top=H,1}}case 1:{if(H===0)return 2;K=G[--H],V=G[--H],q=G[--H],Z=G[--H],W=2*(Math.min(q,K)+1),Q=0}}}class IU0{constructor(J){this.state=J,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){let{state:J,result:Q}=this;if(this.c>1)return Q.done=!0,Q.value=void 0,Q;let Y=cX4(J,this.c);if(this.c=Y,Y===1)return Q.value=[J.oxs,J.oxe,J.oys,J.oye],Q;if(J.pxs>=0)return Q.value=[J.pxs,J.pxe,J.pys,J.pye],Q;return Q.done=!0,Q.value=void 0,Q}}function PU0(J,Q,Y,X,G){let Z=(Math.min(Q,X)+1)*2,q=Q+X,V=new(q<256?Uint8Array:q<65536?Uint16Array:Uint32Array)(2*Z);return new IU0({i:J,N:Q,j:Y,M:X,Z,b:V,eq:G,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}RU0.diff_core=PU0;function el(J,Q,Y){let[X,G,Z]=[0,J.length,Q.length];if(typeof Y==="function"){while(X<G&&X<Z&&Y(X,X))X++;if(X===G&&X===Z)return[][Symbol.iterator]();while(Y(--G,--Z)&&G>X&&Z>X);}else{while(X<G&&X<Z&&J[X]===Q[X])X++;if(X===G&&X===Z)return[][Symbol.iterator]();while(J[--G]===Q[--Z]&&G>X&&Z>X);Y=(q,V)=>J[q]===Q[V]}return PU0(X,G+1-X,X,Z+1-X,Y)}RU0.diff=el;class TU0{constructor(J,Q){this.diff=J,this.N=Q,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){let J=this.diff.next();if(J.done){let{i:V,j:K,N:W}=this;if(V<W)J.done=!1,J.value=[V,K,W-V],this.i=W;return J}let Q=J.value,Y=Q[0],X=Q[1],G=Q[3],{i:Z,j:q}=this;if(Z!==Y)Q.length--,Q[0]=Z,Q[1]=q,Q[2]=Y-Z;return this.i=X,this.j=G,J}}function lX4(J,Q,Y){return new TU0(el(J,Q,Y),J.length)}RU0.lcs=lX4;function*iX4(J,Q,Y){let X=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let G of el(J,Q,Y))G[2]=X.call(Q,G[2],G[3]),yield G}RU0.calcPatch=iX4;function*nX4(J,Q){let Y=0,X=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let[G,Z,q]of Q){if(Y<G)yield X.call(J,Y,G);if(q.length>0)yield q;Y=Z}if(Y<J.length)yield X.call(J,Y)}RU0.applyPatch=nX4;function*aX4(J,Q,Y){let X=0,G=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let[Z,q,V,K]of el(J,Q,Y)){if(X<Z)yield[0,G.call(J,X,Z)];if(Z<q)yield[-1,G.call(J,Z,q)];if(V<K)yield[1,G.call(Q,V,K)];X=q}if(X<J.length)yield[0,J.slice(X)]}RU0.calcSlices=aX4});function nE(J,Q){let Y={added:0,deleted:0,changed:0};if(typeof J!=="string"||typeof Q!=="string")return Y;if(J===Q)return Y;try{let X={added:0,deleted:0,changed:0};for(let[G,Z,q,V]of SU0.diff(J.split(`
48
+ `)[0];if(!X?.startsWith("#!"))return{interpreter:null,isValid:!1};let G=X.slice(2).trim();if(!G)return{interpreter:null,isValid:!1};let Z=G.split(/\s+/).filter((q)=>q.length>0);if(Z[0]?.endsWith("/env")&&Z.length>1)return{interpreter:Z.slice(1),isValid:!0};return{interpreter:Z,isValid:!0}}finally{await Q.close()}}catch{return{interpreter:null,isValid:!1}}}function iz0(J,Q){let Y=(J&73)!==0;if(process.platform==="win32"){let X=rD.extname(Q).toLowerCase();return Y||[".exe",".bat",".cmd",".ps1"].includes(X)}return Y}function nz0(J){return rD.extname(J).toLowerCase()===".md"}function az0(J){let Q=J.replace(/\\/g,"/"),Y=rD.basename(Q);return rD.basename(Y,rD.extname(Y))}function oz0(J){return/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(J)&&J.length>0}var rz0=()=>{};var JF0={};a8(JF0,{CommandDiscovery:()=>ez0});import*as tz0 from"node:fs";import{promises as Bl}from"node:fs";import{homedir as sz0}from"node:os";import*as WX from"node:path";function HZ1(J,Q,Y){return Promise.race([J,new Promise((X,G)=>setTimeout(()=>G(Error(`${Y} timed out after ${Q}ms`)),Q))])}class ez0{config;workspaceRoots;watchFactory;debounceMs;changes=new y4;watchers=new Map;debounceTimer;disposed=!1;constructor(J,Q,Y={}){this.config=J,this.workspaceRoots=Q,this.watchFactory=Y.watchFactory??oJ4,this.debounceMs=Y.debounceMs??200}get commandChanges(){return this.changes}async discoverCommands(){if(this.disposed)return[];try{let[J,Q]=await Promise.all([this.discoverWorkspaceCommands(),this.discoverGlobalCommands()]),Y=new Map;for(let G of Q)Y.set(`${G.source}:${G.name}`,G);for(let G of J)Y.set(`${G.source}:${G.name}`,G);let X=Array.from(Y.values());if(f.debug("Discovered commands",{count:X.length,workspace:J.length,global:Q.length}),this.config.enableWatching)await this.setupWatching();return X}catch(J){return f.error("Failed to discover commands",{error:J}),[]}}async discoverWorkspaceCommands(){let J=[];for(let Q of this.workspaceRoots)for(let Y of this.config.workspacePaths){let X=Z6.joinPath(Q,Y),G=await this.discoverCommandsInDirectory(X,"workspace");J.push(...G)}return J}async discoverGlobalCommands(){let J=[];for(let Q of this.config.globalPaths){let Y=this.resolveGlobalPath(Q),X=n0.file(Y),G=await this.discoverCommandsInDirectory(X,"global");J.push(...G)}return J}async discoverCommandsInDirectory(J,Q){try{let Y=J.fsPath;try{await HZ1(Bl.access(Y),WZ1,"directory access")}catch{return[]}let G=(await HZ1(Bl.readdir(Y,{withFileTypes:!0}),WZ1,"directory read")).filter((q)=>q.isFile()),Z=[];for(let q of G){let V=WX.join(Y,q.name),K=await this.createCommand(V,Q);if(K)Z.push(K)}return f.debug(`Discovered ${Z.length} commands in ${Q} directory`,{directory:Y,commands:Z.map((q)=>q.name)}),Z}catch(Y){return f.warn(`Failed to discover commands in directory: ${J.fsPath}`,{error:Y}),[]}}ignoreCommandName(J){return J.startsWith(".")||J==="README.md"}async createCommand(J,Q){try{let Y=await Bl.stat(J),X=WX.basename(J);if(this.ignoreCommandName(X))return null;let G=az0(X);if(!oz0(G))return f.warn(`Invalid command name: ${G}`,{filePath:J}),null;if(nz0(X))return this.createMarkdownCommand(J,Y,G,Q);else return this.createExecutableCommand(J,Y,G,Q)}catch(Y){return f.warn(`Failed to process file: ${J}`,{error:Y}),null}}async createMarkdownCommand(J,Q,Y,X){return{kind:"markdown",name:Y,filePath:J,sourceDirectory:WX.dirname(J),lastModified:Q.mtimeMs,available:!0,unavailableReason:void 0,source:X}}async createExecutableCommand(J,Q,Y,X){let G=WX.basename(J),Z=iz0(Q.mode,G),q=await lz0(J),V=WX.extname(G);if(!Z&&!q.isValid&&!this.isNativeBinary(V))return f.debug(`Skipping non-executable file without shebang: ${J}`),null;let K=Z&&(q.isValid||this.isNativeBinary(V)),W=this.getExecutableUnavailableReason(Z,q.isValid,V);return{kind:"executable",name:Y,filePath:J,sourceDirectory:WX.dirname(J),lastModified:Q.mtimeMs,isExecutable:Z,interpreter:q.interpreter,extension:V,available:K,unavailableReason:W,source:X}}isNativeBinary(J){if(process.platform==="win32")return[".exe",".bat",".cmd",".ps1"].includes(J.toLowerCase());return J===""}getExecutableUnavailableReason(J,Q,Y){let X=this.isNativeBinary(Y);if(!J)return"File is not executable (missing execute permissions)";if(!Q&&!X)return"Missing shebang and not a recognized binary type";return}resolveGlobalPath(J){if(J.startsWith("~/"))return WX.join(sz0(),J.slice(2));if(J.startsWith("~/.config/amp/")){let Q=CF||WX.join(sz0(),".config");return WX.join(Q,J.slice(10))}return J}async setupWatching(){if(this.disposed)return;this.stopWatching();let J=new Set;for(let Q of this.workspaceRoots)for(let Y of this.config.workspacePaths){let X=Z6.joinPath(Q,Y);J.add(X.fsPath)}for(let Q of this.config.globalPaths){let Y=this.resolveGlobalPath(Q);J.add(Y)}for(let Q of J)await this.watchDirectory(Q)}async watchDirectory(J){try{await HZ1(Bl.access(J),WZ1,"watcher access check");try{let Q=this.watchFactory(J,(Y,X)=>{f.debug("Command directory change detected",{directory:J,eventType:Y,filename:X}),this.scheduleRefresh()});Q.on("error",(Y)=>{f.debug("transient file watcher error",{error:Y}),this.scheduleRefresh()}),this.watchers.set(J,Q),f.debug("Started watching command directory",{directory:J})}catch(Q){f.warn("Failed to setup file watcher",{directory:J,error:Q})}}catch(Q){f.debug("Skipping watch for non-existent directory",{directory:J})}}scheduleRefresh(){if(this.disposed)return;if(this.debounceTimer)clearTimeout(this.debounceTimer);this.debounceTimer=setTimeout(async()=>{try{let[J,Q]=await Promise.all([this.discoverWorkspaceCommands(),this.discoverGlobalCommands()]),Y=new Map;for(let G of Q)Y.set(`${G.source}:${G.name}`,G);for(let G of J)Y.set(`${G.source}:${G.name}`,G);let X=Array.from(Y.values());f.debug("Refreshed commands during file watch",{count:X.length,workspace:J.length,global:Q.length}),this.changes.next(X)}catch(J){f.warn("Failed to refresh commands during file watch",{error:J})}},this.debounceMs)}stopWatching(){try{for(let[J,Q]of this.watchers)try{Q.close(),f.debug("Stopped watching command directory",{directory:J})}catch(Y){f.warn("Failed to close watcher",{directory:J,error:Y})}this.watchers.clear()}finally{if(this.debounceTimer)clearTimeout(this.debounceTimer),this.debounceTimer=void 0}}dispose(){this.disposed=!0;try{this.stopWatching()}catch(J){f.warn("Error during command discovery cleanup",{error:J})}}}var WZ1=5000,oJ4=(J,Q)=>tz0.watch(J,Q);var QF0=L1(()=>{H4();o0();HE();L0();rz0()});function Z5(J,Q,Y=Q+"s"){return J===1?Q:Y}function xF(J){let Q=typeof J==="string"?J:J.toString();return Q===zY||Q===zY.slice(0,-1)}function OE(J){return xF(J)?zY:J}var UQ4,zY,BQ4,hb8;var vF=L1(()=>{UQ4=new URL("https://ampcode.com/"),zY=UQ4.toString(),BQ4=new URL("https://api.anthropic.com/"),hb8=BQ4.toString()});var B9,wZ1,y6,OV=(J)=>{switch(typeof J){case"undefined":return y6.undefined;case"string":return y6.string;case"number":return Number.isNaN(J)?y6.nan:y6.number;case"boolean":return y6.boolean;case"function":return y6.function;case"bigint":return y6.bigint;case"symbol":return y6.symbol;case"object":if(Array.isArray(J))return y6.array;if(J===null)return y6.null;if(J.then&&typeof J.then==="function"&&J.catch&&typeof J.catch==="function")return y6.promise;if(typeof Map<"u"&&J instanceof Map)return y6.map;if(typeof Set<"u"&&J instanceof Set)return y6.set;if(typeof Date<"u"&&J instanceof Date)return y6.date;return y6.object;default:return y6.unknown}};var Qk=L1(()=>{(function(J){J.assertEqual=(G)=>{};function Q(G){}J.assertIs=Q;function Y(G){throw Error()}J.assertNever=Y,J.arrayToEnum=(G)=>{let Z={};for(let q of G)Z[q]=q;return Z},J.getValidEnumValues=(G)=>{let Z=J.objectKeys(G).filter((V)=>typeof G[G[V]]!=="number"),q={};for(let V of Z)q[V]=G[V];return J.objectValues(q)},J.objectValues=(G)=>{return J.objectKeys(G).map(function(Z){return G[Z]})},J.objectKeys=typeof Object.keys==="function"?(G)=>Object.keys(G):(G)=>{let Z=[];for(let q in G)if(Object.prototype.hasOwnProperty.call(G,q))Z.push(q);return Z},J.find=(G,Z)=>{for(let q of G)if(Z(q))return q;return},J.isInteger=typeof Number.isInteger==="function"?(G)=>Number.isInteger(G):(G)=>typeof G==="number"&&Number.isFinite(G)&&Math.floor(G)===G;function X(G,Z=" | "){return G.map((q)=>typeof q==="string"?`'${q}'`:q).join(Z)}J.joinValues=X,J.jsonStringifyReplacer=(G,Z)=>{if(typeof Z==="bigint")return Z.toString();return Z}})(B9||(B9={}));(function(J){J.mergeShapes=(Q,Y)=>{return{...Q,...Y}}})(wZ1||(wZ1={}));y6=B9.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var z6,NQ4=(J)=>{return JSON.stringify(J,null,2).replace(/"([^"]+)":/g,"$1:")},FY;var Al=L1(()=>{Qk();z6=B9.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);FY=class FY extends Error{get errors(){return this.issues}constructor(J){super();this.issues=[],this.addIssue=(Y)=>{this.issues=[...this.issues,Y]},this.addIssues=(Y=[])=>{this.issues=[...this.issues,...Y]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=J}format(J){let Q=J||function(G){return G.message},Y={_errors:[]},X=(G)=>{for(let Z of G.issues)if(Z.code==="invalid_union")Z.unionErrors.map(X);else if(Z.code==="invalid_return_type")X(Z.returnTypeError);else if(Z.code==="invalid_arguments")X(Z.argumentsError);else if(Z.path.length===0)Y._errors.push(Q(Z));else{let q=Y,V=0;while(V<Z.path.length){let K=Z.path[V];if(V!==Z.path.length-1)q[K]=q[K]||{_errors:[]};else q[K]=q[K]||{_errors:[]},q[K]._errors.push(Q(Z));q=q[K],V++}}};return X(this),Y}static assert(J){if(!(J instanceof FY))throw Error(`Not a ZodError: ${J}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B9.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(J=(Q)=>Q.message){let Q={},Y=[];for(let X of this.issues)if(X.path.length>0){let G=X.path[0];Q[G]=Q[G]||[],Q[G].push(J(X))}else Y.push(J(X));return{formErrors:Y,fieldErrors:Q}}get formErrors(){return this.flatten()}};FY.create=(J)=>{return new FY(J)}});var DQ4=(J,Q)=>{let Y;switch(J.code){case z6.invalid_type:if(J.received===y6.undefined)Y="Required";else Y=`Expected ${J.expected}, received ${J.received}`;break;case z6.invalid_literal:Y=`Invalid literal value, expected ${JSON.stringify(J.expected,B9.jsonStringifyReplacer)}`;break;case z6.unrecognized_keys:Y=`Unrecognized key(s) in object: ${B9.joinValues(J.keys,", ")}`;break;case z6.invalid_union:Y="Invalid input";break;case z6.invalid_union_discriminator:Y=`Invalid discriminator value. Expected ${B9.joinValues(J.options)}`;break;case z6.invalid_enum_value:Y=`Invalid enum value. Expected ${B9.joinValues(J.options)}, received '${J.received}'`;break;case z6.invalid_arguments:Y="Invalid function arguments";break;case z6.invalid_return_type:Y="Invalid function return type";break;case z6.invalid_date:Y="Invalid date";break;case z6.invalid_string:if(typeof J.validation==="object")if("includes"in J.validation){if(Y=`Invalid input: must include "${J.validation.includes}"`,typeof J.validation.position==="number")Y=`${Y} at one or more positions greater than or equal to ${J.validation.position}`}else if("startsWith"in J.validation)Y=`Invalid input: must start with "${J.validation.startsWith}"`;else if("endsWith"in J.validation)Y=`Invalid input: must end with "${J.validation.endsWith}"`;else B9.assertNever(J.validation);else if(J.validation!=="regex")Y=`Invalid ${J.validation}`;else Y="Invalid";break;case z6.too_small:if(J.type==="array")Y=`Array must contain ${J.exact?"exactly":J.inclusive?"at least":"more than"} ${J.minimum} element(s)`;else if(J.type==="string")Y=`String must contain ${J.exact?"exactly":J.inclusive?"at least":"over"} ${J.minimum} character(s)`;else if(J.type==="number")Y=`Number must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${J.minimum}`;else if(J.type==="bigint")Y=`Number must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${J.minimum}`;else if(J.type==="date")Y=`Date must be ${J.exact?"exactly equal to ":J.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(J.minimum))}`;else Y="Invalid input";break;case z6.too_big:if(J.type==="array")Y=`Array must contain ${J.exact?"exactly":J.inclusive?"at most":"less than"} ${J.maximum} element(s)`;else if(J.type==="string")Y=`String must contain ${J.exact?"exactly":J.inclusive?"at most":"under"} ${J.maximum} character(s)`;else if(J.type==="number")Y=`Number must be ${J.exact?"exactly":J.inclusive?"less than or equal to":"less than"} ${J.maximum}`;else if(J.type==="bigint")Y=`BigInt must be ${J.exact?"exactly":J.inclusive?"less than or equal to":"less than"} ${J.maximum}`;else if(J.type==="date")Y=`Date must be ${J.exact?"exactly":J.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(J.maximum))}`;else Y="Invalid input";break;case z6.custom:Y="Invalid input";break;case z6.invalid_intersection_types:Y="Intersection results could not be merged";break;case z6.not_multiple_of:Y=`Number must be a multiple of ${J.multipleOf}`;break;case z6.not_finite:Y="Number must be finite";break;default:Y=Q.defaultError,B9.assertNever(J)}return{message:Y}},xW;var EZ1=L1(()=>{Al();Qk();xW=DQ4});function MQ4(J){HF0=J}function wE(){return HF0}var HF0;var Ol=L1(()=>{EZ1();HF0=xW});function o6(J,Q){let Y=wE(),X=Yk({issueData:Q,data:J.data,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Y,Y===xW?void 0:xW].filter((G)=>!!G)});J.common.issues.push(X)}class YJ{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(J,Q){let Y=[];for(let X of Q){if(X.status==="aborted")return s4;if(X.status==="dirty")J.dirty();Y.push(X.value)}return{status:J.value,value:Y}}static async mergeObjectAsync(J,Q){let Y=[];for(let X of Q){let G=await X.key,Z=await X.value;Y.push({key:G,value:Z})}return YJ.mergeObjectSync(J,Y)}static mergeObjectSync(J,Q){let Y={};for(let X of Q){let{key:G,value:Z}=X;if(G.status==="aborted")return s4;if(Z.status==="aborted")return s4;if(G.status==="dirty")J.dirty();if(Z.status==="dirty")J.dirty();if(G.value!=="__proto__"&&(typeof Z.value<"u"||X.alwaysSet))Y[G.value]=Z.value}return{status:J.value,value:Y}}}var Yk=(J)=>{let{data:Q,path:Y,errorMaps:X,issueData:G}=J,Z=[...Y,...G.path||[]],q={...G,path:Z};if(G.message!==void 0)return{...G,path:Z,message:G.message};let V="",K=X.filter((W)=>!!W).slice().reverse();for(let W of K)V=W(q,{data:Q,defaultError:V}).message;return{...G,path:Z,message:V}},LQ4,s4,tD=(J)=>({status:"dirty",value:J}),lJ=(J)=>({status:"valid",value:J}),wl=(J)=>J.status==="aborted",El=(J)=>J.status==="dirty",fF=(J)=>J.status==="valid",EE=(J)=>typeof Promise<"u"&&J instanceof Promise;var IZ1=L1(()=>{Ol();EZ1();LQ4=[];s4=Object.freeze({status:"aborted"})});var zF0=()=>{};var L4;var FF0=L1(()=>{(function(J){J.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},J.toString=(Q)=>typeof Q==="string"?Q:Q?.message})(L4||(L4={}))});class T${constructor(J,Q,Y,X){this._cachedPath=[],this.parent=J,this.data=Q,this._path=Y,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function S8(J){if(!J)return{};let{errorMap:Q,invalid_type_error:Y,required_error:X,description:G}=J;if(Q&&(Y||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:G};return{errorMap:(q,V)=>{let{message:K}=J;if(q.code==="invalid_enum_value")return{message:K??V.defaultError};if(typeof V.data>"u")return{message:K??X??V.defaultError};if(q.code!=="invalid_type")return{message:V.defaultError};return{message:K??Y??V.defaultError}},description:G}}class r8{get description(){return this._def.description}_getType(J){return OV(J.data)}_getOrReturnCtx(J,Q){return Q||{common:J.parent.common,data:J.data,parsedType:OV(J.data),schemaErrorMap:this._def.errorMap,path:J.path,parent:J.parent}}_processInputParams(J){return{status:new YJ,ctx:{common:J.parent.common,data:J.data,parsedType:OV(J.data),schemaErrorMap:this._def.errorMap,path:J.path,parent:J.parent}}}_parseSync(J){let Q=this._parse(J);if(EE(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync(J){let Q=this._parse(J);return Promise.resolve(Q)}parse(J,Q){let Y=this.safeParse(J,Q);if(Y.success)return Y.data;throw Y.error}safeParse(J,Q){let Y={common:{issues:[],async:Q?.async??!1,contextualErrorMap:Q?.errorMap},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)},X=this._parseSync({data:J,path:Y.path,parent:Y});return UF0(Y,X)}"~validate"(J){let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)};if(!this["~standard"].async)try{let Y=this._parseSync({data:J,path:[],parent:Q});return fF(Y)?{value:Y.value}:{issues:Q.common.issues}}catch(Y){if(Y?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:J,path:[],parent:Q}).then((Y)=>fF(Y)?{value:Y.value}:{issues:Q.common.issues})}async parseAsync(J,Q){let Y=await this.safeParseAsync(J,Q);if(Y.success)return Y.data;throw Y.error}async safeParseAsync(J,Q){let Y={common:{issues:[],contextualErrorMap:Q?.errorMap,async:!0},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:J,parsedType:OV(J)},X=this._parse({data:J,path:Y.path,parent:Y}),G=await(EE(X)?X:Promise.resolve(X));return UF0(Y,G)}refine(J,Q){let Y=(X)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(X);else return Q};return this._refinement((X,G)=>{let Z=J(X),q=()=>G.addIssue({code:z6.custom,...Y(X)});if(typeof Promise<"u"&&Z instanceof Promise)return Z.then((V)=>{if(!V)return q(),!1;else return!0});if(!Z)return q(),!1;else return!0})}refinement(J,Q){return this._refinement((Y,X)=>{if(!J(Y))return X.addIssue(typeof Q==="function"?Q(Y,X):Q),!1;else return!0})}_refinement(J){return new R$({schema:this,typeName:q8.ZodEffects,effect:{type:"refinement",refinement:J}})}superRefine(J){return this._refinement(J)}constructor(J){this.spa=this.safeParseAsync,this._def=J,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(Q)=>this["~validate"](Q)}}optional(){return P$.create(this,this._def)}nullable(){return fW.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I$.create(this)}promise(){return YM.create(this,this._def)}or(J){return jE.create([this,J],this._def)}and(J){return SE.create(this,J,this._def)}transform(J){return new R$({...S8(this._def),schema:this,typeName:q8.ZodEffects,effect:{type:"transform",transform:J}})}default(J){let Q=typeof J==="function"?J:()=>J;return new xE({...S8(this._def),innerType:this,defaultValue:Q,typeName:q8.ZodDefault})}brand(){return new Pl({typeName:q8.ZodBranded,type:this,...S8(this._def)})}catch(J){let Q=typeof J==="function"?J:()=>J;return new vE({...S8(this._def),innerType:this,catchValue:Q,typeName:q8.ZodCatch})}describe(J){return new this.constructor({...this._def,description:J})}pipe(J){return Vk.create(this,J)}readonly(){return fE.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function DF0(J){let Q="[0-5]\\d";if(J.precision)Q=`${Q}\\.\\d{${J.precision}}`;else if(J.precision==null)Q=`${Q}(\\.\\d+)?`;let Y=J.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${Q})${Y}`}function fQ4(J){return new RegExp(`^${DF0(J)}$`)}function MF0(J){let Q=`${NF0}T${DF0(J)}`,Y=[];if(Y.push(J.local?"Z?":"Z"),J.offset)Y.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${Y.join("|")})`,new RegExp(`^${Q}$`)}function hQ4(J,Q){if((Q==="v4"||!Q)&&jQ4.test(J))return!0;if((Q==="v6"||!Q)&&_Q4.test(J))return!0;return!1}function bQ4(J,Q){if(!PQ4.test(J))return!1;try{let[Y]=J.split(".");if(!Y)return!1;let X=Y.replace(/-/g,"+").replace(/_/g,"/").padEnd(Y.length+(4-Y.length%4)%4,"="),G=JSON.parse(atob(X));if(typeof G!=="object"||G===null)return!1;if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Q&&G.alg!==Q)return!1;return!0}catch{return!1}}function gQ4(J,Q){if((Q==="v4"||!Q)&&SQ4.test(J))return!0;if((Q==="v6"||!Q)&&kQ4.test(J))return!0;return!1}function mQ4(J,Q){let Y=(J.toString().split(".")[1]||"").length,X=(Q.toString().split(".")[1]||"").length,G=Y>X?Y:X,Z=Number.parseInt(J.toFixed(G).replace(".","")),q=Number.parseInt(Q.toFixed(G).replace(".",""));return Z%q/10**G}function IE(J){if(J instanceof C7){let Q={};for(let Y in J.shape){let X=J.shape[Y];Q[Y]=P$.create(IE(X))}return new C7({...J._def,shape:()=>Q})}else if(J instanceof I$)return new I$({...J._def,type:IE(J.element)});else if(J instanceof P$)return P$.create(IE(J.unwrap()));else if(J instanceof fW)return fW.create(IE(J.unwrap()));else if(J instanceof EV)return EV.create(J.items.map((Q)=>IE(Q)));else return J}function TZ1(J,Q){let Y=OV(J),X=OV(Q);if(J===Q)return{valid:!0,data:J};else if(Y===y6.object&&X===y6.object){let G=B9.objectKeys(Q),Z=B9.objectKeys(J).filter((V)=>G.indexOf(V)!==-1),q={...J,...Q};for(let V of Z){let K=TZ1(J[V],Q[V]);if(!K.valid)return{valid:!1};q[V]=K.data}return{valid:!0,data:q}}else if(Y===y6.array&&X===y6.array){if(J.length!==Q.length)return{valid:!1};let G=[];for(let Z=0;Z<J.length;Z++){let q=J[Z],V=Q[Z],K=TZ1(q,V);if(!K.valid)return{valid:!1};G.push(K.data)}return{valid:!0,data:G}}else if(Y===y6.date&&X===y6.date&&+J===+Q)return{valid:!0,data:J};else return{valid:!1}}function LF0(J,Q){return new mF({values:J,typeName:q8.ZodEnum,...S8(Q)})}function BF0(J,Q){let Y=typeof J==="function"?J(Q):typeof J==="string"?{message:J}:J;return typeof Y==="string"?{message:Y}:Y}function AF0(J,Q={},Y){if(J)return JM.create().superRefine((X,G)=>{let Z=J(X);if(Z instanceof Promise)return Z.then((q)=>{if(!q){let V=BF0(Q,X),K=V.fatal??Y??!0;G.addIssue({code:"custom",...V,fatal:K})}});if(!Z){let q=BF0(Q,X),V=q.fatal??Y??!0;G.addIssue({code:"custom",...q,fatal:V})}return});return JM.create()}var UF0=(J,Q)=>{if(fF(Q))return{success:!0,data:Q.value};else{if(!J.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Y=new FY(J.common.issues);return this._error=Y,this._error}}}},AQ4,OQ4,wQ4,EQ4,IQ4,PQ4,TQ4,RQ4,CQ4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",PZ1,jQ4,SQ4,_Q4,kQ4,yQ4,xQ4,NF0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",vQ4,E$,bF,gF,TE,eD,Xk,RE,CE,JM,hF,wV,Gk,I$,C7,jE,vW=(J)=>{if(J instanceof _E)return vW(J.schema);else if(J instanceof R$)return vW(J.innerType());else if(J instanceof kE)return[J.value];else if(J instanceof mF)return J.options;else if(J instanceof yE)return B9.objectValues(J.enum);else if(J instanceof xE)return vW(J._def.innerType);else if(J instanceof RE)return[void 0];else if(J instanceof CE)return[null];else if(J instanceof P$)return[void 0,...vW(J.unwrap())];else if(J instanceof fW)return[null,...vW(J.unwrap())];else if(J instanceof Pl)return vW(J.unwrap());else if(J instanceof fE)return vW(J.unwrap());else if(J instanceof vE)return vW(J._def.innerType);else return[]},Il,SE,EV,Zk,$k,QM,PE,_E,kE,mF,yE,YM,R$,P$,fW,xE,vE,qk,uQ4,Pl,Vk,fE,pQ4,q8,dQ4=(J,Q={message:`Input not instance of ${J.name}`})=>AF0((Y)=>Y instanceof J,Q),OF0,wF0,cQ4,lQ4,EF0,iQ4,nQ4,aQ4,oQ4,rQ4,sQ4,tQ4,eQ4,JY4,QY4,YY4,XY4,GY4,ZY4,$Y4,qY4,VY4,KY4,WY4,HY4,zY4,FY4,UY4,BY4,NY4,DY4,MY4,LY4,AY4,OY4=()=>OF0().optional(),wY4=()=>wF0().optional(),EY4=()=>EF0().optional(),IY4,PY4;var IF0=L1(()=>{Al();Ol();FF0();IZ1();Qk();AQ4=/^c[^\s-]{8,}$/i,OQ4=/^[0-9a-z]+$/,wQ4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,EQ4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,IQ4=/^[a-z0-9_-]{21}$/i,PQ4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,TQ4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,RQ4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jQ4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,SQ4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,_Q4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,kQ4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yQ4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xQ4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,vQ4=new RegExp(`^${NF0}$`);E$=class E$ extends r8{_parse(J){if(this._def.coerce)J.data=String(J.data);if(this._getType(J)!==y6.string){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.string,received:G.parsedType}),s4}let Y=new YJ,X=void 0;for(let G of this._def.checks)if(G.kind==="min"){if(J.data.length<G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Y.dirty()}else if(G.kind==="max"){if(J.data.length>G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Y.dirty()}else if(G.kind==="length"){let Z=J.data.length>G.value,q=J.data.length<G.value;if(Z||q){if(X=this._getOrReturnCtx(J,X),Z)o6(X,{code:z6.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});else if(q)o6(X,{code:z6.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});Y.dirty()}}else if(G.kind==="email"){if(!RQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"email",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="emoji"){if(!PZ1)PZ1=new RegExp(CQ4,"u");if(!PZ1.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"emoji",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="uuid"){if(!EQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"uuid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="nanoid"){if(!IQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"nanoid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cuid"){if(!AQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cuid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cuid2"){if(!OQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cuid2",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="ulid"){if(!wQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"ulid",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="url")try{new URL(J.data)}catch{X=this._getOrReturnCtx(J,X),o6(X,{validation:"url",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="regex"){if(G.regex.lastIndex=0,!G.regex.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"regex",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="trim")J.data=J.data.trim();else if(G.kind==="includes"){if(!J.data.includes(G.value,G.position))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{includes:G.value,position:G.position},message:G.message}),Y.dirty()}else if(G.kind==="toLowerCase")J.data=J.data.toLowerCase();else if(G.kind==="toUpperCase")J.data=J.data.toUpperCase();else if(G.kind==="startsWith"){if(!J.data.startsWith(G.value))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{startsWith:G.value},message:G.message}),Y.dirty()}else if(G.kind==="endsWith"){if(!J.data.endsWith(G.value))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:{endsWith:G.value},message:G.message}),Y.dirty()}else if(G.kind==="datetime"){if(!MF0(G).test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"datetime",message:G.message}),Y.dirty()}else if(G.kind==="date"){if(!vQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"date",message:G.message}),Y.dirty()}else if(G.kind==="time"){if(!fQ4(G).test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{code:z6.invalid_string,validation:"time",message:G.message}),Y.dirty()}else if(G.kind==="duration"){if(!TQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"duration",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="ip"){if(!hQ4(J.data,G.version))X=this._getOrReturnCtx(J,X),o6(X,{validation:"ip",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="jwt"){if(!bQ4(J.data,G.alg))X=this._getOrReturnCtx(J,X),o6(X,{validation:"jwt",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="cidr"){if(!gQ4(J.data,G.version))X=this._getOrReturnCtx(J,X),o6(X,{validation:"cidr",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="base64"){if(!yQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"base64",code:z6.invalid_string,message:G.message}),Y.dirty()}else if(G.kind==="base64url"){if(!xQ4.test(J.data))X=this._getOrReturnCtx(J,X),o6(X,{validation:"base64url",code:z6.invalid_string,message:G.message}),Y.dirty()}else B9.assertNever(G);return{status:Y.value,value:J.data}}_regex(J,Q,Y){return this.refinement((X)=>J.test(X),{validation:Q,code:z6.invalid_string,...L4.errToObj(Y)})}_addCheck(J){return new E$({...this._def,checks:[...this._def.checks,J]})}email(J){return this._addCheck({kind:"email",...L4.errToObj(J)})}url(J){return this._addCheck({kind:"url",...L4.errToObj(J)})}emoji(J){return this._addCheck({kind:"emoji",...L4.errToObj(J)})}uuid(J){return this._addCheck({kind:"uuid",...L4.errToObj(J)})}nanoid(J){return this._addCheck({kind:"nanoid",...L4.errToObj(J)})}cuid(J){return this._addCheck({kind:"cuid",...L4.errToObj(J)})}cuid2(J){return this._addCheck({kind:"cuid2",...L4.errToObj(J)})}ulid(J){return this._addCheck({kind:"ulid",...L4.errToObj(J)})}base64(J){return this._addCheck({kind:"base64",...L4.errToObj(J)})}base64url(J){return this._addCheck({kind:"base64url",...L4.errToObj(J)})}jwt(J){return this._addCheck({kind:"jwt",...L4.errToObj(J)})}ip(J){return this._addCheck({kind:"ip",...L4.errToObj(J)})}cidr(J){return this._addCheck({kind:"cidr",...L4.errToObj(J)})}datetime(J){if(typeof J==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:J});return this._addCheck({kind:"datetime",precision:typeof J?.precision>"u"?null:J?.precision,offset:J?.offset??!1,local:J?.local??!1,...L4.errToObj(J?.message)})}date(J){return this._addCheck({kind:"date",message:J})}time(J){if(typeof J==="string")return this._addCheck({kind:"time",precision:null,message:J});return this._addCheck({kind:"time",precision:typeof J?.precision>"u"?null:J?.precision,...L4.errToObj(J?.message)})}duration(J){return this._addCheck({kind:"duration",...L4.errToObj(J)})}regex(J,Q){return this._addCheck({kind:"regex",regex:J,...L4.errToObj(Q)})}includes(J,Q){return this._addCheck({kind:"includes",value:J,position:Q?.position,...L4.errToObj(Q?.message)})}startsWith(J,Q){return this._addCheck({kind:"startsWith",value:J,...L4.errToObj(Q)})}endsWith(J,Q){return this._addCheck({kind:"endsWith",value:J,...L4.errToObj(Q)})}min(J,Q){return this._addCheck({kind:"min",value:J,...L4.errToObj(Q)})}max(J,Q){return this._addCheck({kind:"max",value:J,...L4.errToObj(Q)})}length(J,Q){return this._addCheck({kind:"length",value:J,...L4.errToObj(Q)})}nonempty(J){return this.min(1,L4.errToObj(J))}trim(){return new E$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((J)=>J.kind==="datetime")}get isDate(){return!!this._def.checks.find((J)=>J.kind==="date")}get isTime(){return!!this._def.checks.find((J)=>J.kind==="time")}get isDuration(){return!!this._def.checks.find((J)=>J.kind==="duration")}get isEmail(){return!!this._def.checks.find((J)=>J.kind==="email")}get isURL(){return!!this._def.checks.find((J)=>J.kind==="url")}get isEmoji(){return!!this._def.checks.find((J)=>J.kind==="emoji")}get isUUID(){return!!this._def.checks.find((J)=>J.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((J)=>J.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((J)=>J.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((J)=>J.kind==="cuid2")}get isULID(){return!!this._def.checks.find((J)=>J.kind==="ulid")}get isIP(){return!!this._def.checks.find((J)=>J.kind==="ip")}get isCIDR(){return!!this._def.checks.find((J)=>J.kind==="cidr")}get isBase64(){return!!this._def.checks.find((J)=>J.kind==="base64")}get isBase64url(){return!!this._def.checks.find((J)=>J.kind==="base64url")}get minLength(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxLength(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}};E$.create=(J)=>{return new E$({checks:[],typeName:q8.ZodString,coerce:J?.coerce??!1,...S8(J)})};bF=class bF extends r8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(J){if(this._def.coerce)J.data=Number(J.data);if(this._getType(J)!==y6.number){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.number,received:G.parsedType}),s4}let Y=void 0,X=new YJ;for(let G of this._def.checks)if(G.kind==="int"){if(!B9.isInteger(J.data))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.invalid_type,expected:"integer",received:"float",message:G.message}),X.dirty()}else if(G.kind==="min"){if(G.inclusive?J.data<G.value:J.data<=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_small,minimum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),X.dirty()}else if(G.kind==="max"){if(G.inclusive?J.data>G.value:J.data>=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_big,maximum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),X.dirty()}else if(G.kind==="multipleOf"){if(mQ4(J.data,G.value)!==0)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_multiple_of,multipleOf:G.value,message:G.message}),X.dirty()}else if(G.kind==="finite"){if(!Number.isFinite(J.data))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_finite,message:G.message}),X.dirty()}else B9.assertNever(G);return{status:X.value,value:J.data}}gte(J,Q){return this.setLimit("min",J,!0,L4.toString(Q))}gt(J,Q){return this.setLimit("min",J,!1,L4.toString(Q))}lte(J,Q){return this.setLimit("max",J,!0,L4.toString(Q))}lt(J,Q){return this.setLimit("max",J,!1,L4.toString(Q))}setLimit(J,Q,Y,X){return new bF({...this._def,checks:[...this._def.checks,{kind:J,value:Q,inclusive:Y,message:L4.toString(X)}]})}_addCheck(J){return new bF({...this._def,checks:[...this._def.checks,J]})}int(J){return this._addCheck({kind:"int",message:L4.toString(J)})}positive(J){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L4.toString(J)})}negative(J){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L4.toString(J)})}nonpositive(J){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L4.toString(J)})}nonnegative(J){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L4.toString(J)})}multipleOf(J,Q){return this._addCheck({kind:"multipleOf",value:J,message:L4.toString(Q)})}finite(J){return this._addCheck({kind:"finite",message:L4.toString(J)})}safe(J){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L4.toString(J)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L4.toString(J)})}get minValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}get isInt(){return!!this._def.checks.find((J)=>J.kind==="int"||J.kind==="multipleOf"&&B9.isInteger(J.value))}get isFinite(){let J=null,Q=null;for(let Y of this._def.checks)if(Y.kind==="finite"||Y.kind==="int"||Y.kind==="multipleOf")return!0;else if(Y.kind==="min"){if(Q===null||Y.value>Q)Q=Y.value}else if(Y.kind==="max"){if(J===null||Y.value<J)J=Y.value}return Number.isFinite(Q)&&Number.isFinite(J)}};bF.create=(J)=>{return new bF({checks:[],typeName:q8.ZodNumber,coerce:J?.coerce||!1,...S8(J)})};gF=class gF extends r8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(J){if(this._def.coerce)try{J.data=BigInt(J.data)}catch{return this._getInvalidInput(J)}if(this._getType(J)!==y6.bigint)return this._getInvalidInput(J);let Y=void 0,X=new YJ;for(let G of this._def.checks)if(G.kind==="min"){if(G.inclusive?J.data<G.value:J.data<=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_small,type:"bigint",minimum:G.value,inclusive:G.inclusive,message:G.message}),X.dirty()}else if(G.kind==="max"){if(G.inclusive?J.data>G.value:J.data>=G.value)Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.too_big,type:"bigint",maximum:G.value,inclusive:G.inclusive,message:G.message}),X.dirty()}else if(G.kind==="multipleOf"){if(J.data%G.value!==BigInt(0))Y=this._getOrReturnCtx(J,Y),o6(Y,{code:z6.not_multiple_of,multipleOf:G.value,message:G.message}),X.dirty()}else B9.assertNever(G);return{status:X.value,value:J.data}}_getInvalidInput(J){let Q=this._getOrReturnCtx(J);return o6(Q,{code:z6.invalid_type,expected:y6.bigint,received:Q.parsedType}),s4}gte(J,Q){return this.setLimit("min",J,!0,L4.toString(Q))}gt(J,Q){return this.setLimit("min",J,!1,L4.toString(Q))}lte(J,Q){return this.setLimit("max",J,!0,L4.toString(Q))}lt(J,Q){return this.setLimit("max",J,!1,L4.toString(Q))}setLimit(J,Q,Y,X){return new gF({...this._def,checks:[...this._def.checks,{kind:J,value:Q,inclusive:Y,message:L4.toString(X)}]})}_addCheck(J){return new gF({...this._def,checks:[...this._def.checks,J]})}positive(J){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L4.toString(J)})}negative(J){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L4.toString(J)})}nonpositive(J){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L4.toString(J)})}nonnegative(J){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L4.toString(J)})}multipleOf(J,Q){return this._addCheck({kind:"multipleOf",value:J,message:L4.toString(Q)})}get minValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J}get maxValue(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J}};gF.create=(J)=>{return new gF({checks:[],typeName:q8.ZodBigInt,coerce:J?.coerce??!1,...S8(J)})};TE=class TE extends r8{_parse(J){if(this._def.coerce)J.data=Boolean(J.data);if(this._getType(J)!==y6.boolean){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.boolean,received:Y.parsedType}),s4}return lJ(J.data)}};TE.create=(J)=>{return new TE({typeName:q8.ZodBoolean,coerce:J?.coerce||!1,...S8(J)})};eD=class eD extends r8{_parse(J){if(this._def.coerce)J.data=new Date(J.data);if(this._getType(J)!==y6.date){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_type,expected:y6.date,received:G.parsedType}),s4}if(Number.isNaN(J.data.getTime())){let G=this._getOrReturnCtx(J);return o6(G,{code:z6.invalid_date}),s4}let Y=new YJ,X=void 0;for(let G of this._def.checks)if(G.kind==="min"){if(J.data.getTime()<G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_small,message:G.message,inclusive:!0,exact:!1,minimum:G.value,type:"date"}),Y.dirty()}else if(G.kind==="max"){if(J.data.getTime()>G.value)X=this._getOrReturnCtx(J,X),o6(X,{code:z6.too_big,message:G.message,inclusive:!0,exact:!1,maximum:G.value,type:"date"}),Y.dirty()}else B9.assertNever(G);return{status:Y.value,value:new Date(J.data.getTime())}}_addCheck(J){return new eD({...this._def,checks:[...this._def.checks,J]})}min(J,Q){return this._addCheck({kind:"min",value:J.getTime(),message:L4.toString(Q)})}max(J,Q){return this._addCheck({kind:"max",value:J.getTime(),message:L4.toString(Q)})}get minDate(){let J=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}return J!=null?new Date(J):null}get maxDate(){let J=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(J===null||Q.value<J)J=Q.value}return J!=null?new Date(J):null}};eD.create=(J)=>{return new eD({checks:[],coerce:J?.coerce||!1,typeName:q8.ZodDate,...S8(J)})};Xk=class Xk extends r8{_parse(J){if(this._getType(J)!==y6.symbol){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.symbol,received:Y.parsedType}),s4}return lJ(J.data)}};Xk.create=(J)=>{return new Xk({typeName:q8.ZodSymbol,...S8(J)})};RE=class RE extends r8{_parse(J){if(this._getType(J)!==y6.undefined){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.undefined,received:Y.parsedType}),s4}return lJ(J.data)}};RE.create=(J)=>{return new RE({typeName:q8.ZodUndefined,...S8(J)})};CE=class CE extends r8{_parse(J){if(this._getType(J)!==y6.null){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.null,received:Y.parsedType}),s4}return lJ(J.data)}};CE.create=(J)=>{return new CE({typeName:q8.ZodNull,...S8(J)})};JM=class JM extends r8{constructor(){super(...arguments);this._any=!0}_parse(J){return lJ(J.data)}};JM.create=(J)=>{return new JM({typeName:q8.ZodAny,...S8(J)})};hF=class hF extends r8{constructor(){super(...arguments);this._unknown=!0}_parse(J){return lJ(J.data)}};hF.create=(J)=>{return new hF({typeName:q8.ZodUnknown,...S8(J)})};wV=class wV extends r8{_parse(J){let Q=this._getOrReturnCtx(J);return o6(Q,{code:z6.invalid_type,expected:y6.never,received:Q.parsedType}),s4}};wV.create=(J)=>{return new wV({typeName:q8.ZodNever,...S8(J)})};Gk=class Gk extends r8{_parse(J){if(this._getType(J)!==y6.undefined){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.void,received:Y.parsedType}),s4}return lJ(J.data)}};Gk.create=(J)=>{return new Gk({typeName:q8.ZodVoid,...S8(J)})};I$=class I$ extends r8{_parse(J){let{ctx:Q,status:Y}=this._processInputParams(J),X=this._def;if(Q.parsedType!==y6.array)return o6(Q,{code:z6.invalid_type,expected:y6.array,received:Q.parsedType}),s4;if(X.exactLength!==null){let Z=Q.data.length>X.exactLength.value,q=Q.data.length<X.exactLength.value;if(Z||q)o6(Q,{code:Z?z6.too_big:z6.too_small,minimum:q?X.exactLength.value:void 0,maximum:Z?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),Y.dirty()}if(X.minLength!==null){if(Q.data.length<X.minLength.value)o6(Q,{code:z6.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),Y.dirty()}if(X.maxLength!==null){if(Q.data.length>X.maxLength.value)o6(Q,{code:z6.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),Y.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((Z,q)=>{return X.type._parseAsync(new T$(Q,Z,Q.path,q))})).then((Z)=>{return YJ.mergeArray(Y,Z)});let G=[...Q.data].map((Z,q)=>{return X.type._parseSync(new T$(Q,Z,Q.path,q))});return YJ.mergeArray(Y,G)}get element(){return this._def.type}min(J,Q){return new I$({...this._def,minLength:{value:J,message:L4.toString(Q)}})}max(J,Q){return new I$({...this._def,maxLength:{value:J,message:L4.toString(Q)}})}length(J,Q){return new I$({...this._def,exactLength:{value:J,message:L4.toString(Q)}})}nonempty(J){return this.min(1,J)}};I$.create=(J,Q)=>{return new I$({type:J,minLength:null,maxLength:null,exactLength:null,typeName:q8.ZodArray,...S8(Q)})};C7=class C7 extends r8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let J=this._def.shape(),Q=B9.objectKeys(J);return this._cached={shape:J,keys:Q},this._cached}_parse(J){if(this._getType(J)!==y6.object){let K=this._getOrReturnCtx(J);return o6(K,{code:z6.invalid_type,expected:y6.object,received:K.parsedType}),s4}let{status:Y,ctx:X}=this._processInputParams(J),{shape:G,keys:Z}=this._getCached(),q=[];if(!(this._def.catchall instanceof wV&&this._def.unknownKeys==="strip")){for(let K in X.data)if(!Z.includes(K))q.push(K)}let V=[];for(let K of Z){let W=G[K],H=X.data[K];V.push({key:{status:"valid",value:K},value:W._parse(new T$(X,H,X.path,K)),alwaysSet:K in X.data})}if(this._def.catchall instanceof wV){let K=this._def.unknownKeys;if(K==="passthrough")for(let W of q)V.push({key:{status:"valid",value:W},value:{status:"valid",value:X.data[W]}});else if(K==="strict"){if(q.length>0)o6(X,{code:z6.unrecognized_keys,keys:q}),Y.dirty()}else if(K==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let K=this._def.catchall;for(let W of q){let H=X.data[W];V.push({key:{status:"valid",value:W},value:K._parse(new T$(X,H,X.path,W)),alwaysSet:W in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let K=[];for(let W of V){let H=await W.key,z=await W.value;K.push({key:H,value:z,alwaysSet:W.alwaysSet})}return K}).then((K)=>{return YJ.mergeObjectSync(Y,K)});else return YJ.mergeObjectSync(Y,V)}get shape(){return this._def.shape()}strict(J){return L4.errToObj,new C7({...this._def,unknownKeys:"strict",...J!==void 0?{errorMap:(Q,Y)=>{let X=this._def.errorMap?.(Q,Y).message??Y.defaultError;if(Q.code==="unrecognized_keys")return{message:L4.errToObj(J).message??X};return{message:X}}}:{}})}strip(){return new C7({...this._def,unknownKeys:"strip"})}passthrough(){return new C7({...this._def,unknownKeys:"passthrough"})}extend(J){return new C7({...this._def,shape:()=>({...this._def.shape(),...J})})}merge(J){return new C7({unknownKeys:J._def.unknownKeys,catchall:J._def.catchall,shape:()=>({...this._def.shape(),...J._def.shape()}),typeName:q8.ZodObject})}setKey(J,Q){return this.augment({[J]:Q})}catchall(J){return new C7({...this._def,catchall:J})}pick(J){let Q={};for(let Y of B9.objectKeys(J))if(J[Y]&&this.shape[Y])Q[Y]=this.shape[Y];return new C7({...this._def,shape:()=>Q})}omit(J){let Q={};for(let Y of B9.objectKeys(this.shape))if(!J[Y])Q[Y]=this.shape[Y];return new C7({...this._def,shape:()=>Q})}deepPartial(){return IE(this)}partial(J){let Q={};for(let Y of B9.objectKeys(this.shape)){let X=this.shape[Y];if(J&&!J[Y])Q[Y]=X;else Q[Y]=X.optional()}return new C7({...this._def,shape:()=>Q})}required(J){let Q={};for(let Y of B9.objectKeys(this.shape))if(J&&!J[Y])Q[Y]=this.shape[Y];else{let G=this.shape[Y];while(G instanceof P$)G=G._def.innerType;Q[Y]=G}return new C7({...this._def,shape:()=>Q})}keyof(){return LF0(B9.objectKeys(this.shape))}};C7.create=(J,Q)=>{return new C7({shape:()=>J,unknownKeys:"strip",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};C7.strictCreate=(J,Q)=>{return new C7({shape:()=>J,unknownKeys:"strict",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};C7.lazycreate=(J,Q)=>{return new C7({shape:J,unknownKeys:"strip",catchall:wV.create(),typeName:q8.ZodObject,...S8(Q)})};jE=class jE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=this._def.options;function X(G){for(let q of G)if(q.result.status==="valid")return q.result;for(let q of G)if(q.result.status==="dirty")return Q.common.issues.push(...q.ctx.common.issues),q.result;let Z=G.map((q)=>new FY(q.ctx.common.issues));return o6(Q,{code:z6.invalid_union,unionErrors:Z}),s4}if(Q.common.async)return Promise.all(Y.map(async(G)=>{let Z={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await G._parseAsync({data:Q.data,path:Q.path,parent:Z}),ctx:Z}})).then(X);else{let G=void 0,Z=[];for(let V of Y){let K={...Q,common:{...Q.common,issues:[]},parent:null},W=V._parseSync({data:Q.data,path:Q.path,parent:K});if(W.status==="valid")return W;else if(W.status==="dirty"&&!G)G={result:W,ctx:K};if(K.common.issues.length)Z.push(K.common.issues)}if(G)return Q.common.issues.push(...G.ctx.common.issues),G.result;let q=Z.map((V)=>new FY(V));return o6(Q,{code:z6.invalid_union,unionErrors:q}),s4}}get options(){return this._def.options}};jE.create=(J,Q)=>{return new jE({options:J,typeName:q8.ZodUnion,...S8(Q)})};Il=class Il extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.object)return o6(Q,{code:z6.invalid_type,expected:y6.object,received:Q.parsedType}),s4;let Y=this.discriminator,X=Q.data[Y],G=this.optionsMap.get(X);if(!G)return o6(Q,{code:z6.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Y]}),s4;if(Q.common.async)return G._parseAsync({data:Q.data,path:Q.path,parent:Q});else return G._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(J,Q,Y){let X=new Map;for(let G of Q){let Z=vW(G.shape[J]);if(!Z.length)throw Error(`A discriminator value for key \`${J}\` could not be extracted from all schema options`);for(let q of Z){if(X.has(q))throw Error(`Discriminator property ${String(J)} has duplicate value ${String(q)}`);X.set(q,G)}}return new Il({typeName:q8.ZodDiscriminatedUnion,discriminator:J,options:Q,optionsMap:X,...S8(Y)})}};SE=class SE extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J),X=(G,Z)=>{if(wl(G)||wl(Z))return s4;let q=TZ1(G.value,Z.value);if(!q.valid)return o6(Y,{code:z6.invalid_intersection_types}),s4;if(El(G)||El(Z))Q.dirty();return{status:Q.value,value:q.data}};if(Y.common.async)return Promise.all([this._def.left._parseAsync({data:Y.data,path:Y.path,parent:Y}),this._def.right._parseAsync({data:Y.data,path:Y.path,parent:Y})]).then(([G,Z])=>X(G,Z));else return X(this._def.left._parseSync({data:Y.data,path:Y.path,parent:Y}),this._def.right._parseSync({data:Y.data,path:Y.path,parent:Y}))}};SE.create=(J,Q,Y)=>{return new SE({left:J,right:Q,typeName:q8.ZodIntersection,...S8(Y)})};EV=class EV extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.array)return o6(Y,{code:z6.invalid_type,expected:y6.array,received:Y.parsedType}),s4;if(Y.data.length<this._def.items.length)return o6(Y,{code:z6.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s4;if(!this._def.rest&&Y.data.length>this._def.items.length)o6(Y,{code:z6.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let G=[...Y.data].map((Z,q)=>{let V=this._def.items[q]||this._def.rest;if(!V)return null;return V._parse(new T$(Y,Z,Y.path,q))}).filter((Z)=>!!Z);if(Y.common.async)return Promise.all(G).then((Z)=>{return YJ.mergeArray(Q,Z)});else return YJ.mergeArray(Q,G)}get items(){return this._def.items}rest(J){return new EV({...this._def,rest:J})}};EV.create=(J,Q)=>{if(!Array.isArray(J))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new EV({items:J,typeName:q8.ZodTuple,rest:null,...S8(Q)})};Zk=class Zk extends r8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.object)return o6(Y,{code:z6.invalid_type,expected:y6.object,received:Y.parsedType}),s4;let X=[],G=this._def.keyType,Z=this._def.valueType;for(let q in Y.data)X.push({key:G._parse(new T$(Y,q,Y.path,q)),value:Z._parse(new T$(Y,Y.data[q],Y.path,q)),alwaysSet:q in Y.data});if(Y.common.async)return YJ.mergeObjectAsync(Q,X);else return YJ.mergeObjectSync(Q,X)}get element(){return this._def.valueType}static create(J,Q,Y){if(Q instanceof r8)return new Zk({keyType:J,valueType:Q,typeName:q8.ZodRecord,...S8(Y)});return new Zk({keyType:E$.create(),valueType:J,typeName:q8.ZodRecord,...S8(Q)})}};$k=class $k extends r8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.map)return o6(Y,{code:z6.invalid_type,expected:y6.map,received:Y.parsedType}),s4;let X=this._def.keyType,G=this._def.valueType,Z=[...Y.data.entries()].map(([q,V],K)=>{return{key:X._parse(new T$(Y,q,Y.path,[K,"key"])),value:G._parse(new T$(Y,V,Y.path,[K,"value"]))}});if(Y.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let V of Z){let K=await V.key,W=await V.value;if(K.status==="aborted"||W.status==="aborted")return s4;if(K.status==="dirty"||W.status==="dirty")Q.dirty();q.set(K.value,W.value)}return{status:Q.value,value:q}})}else{let q=new Map;for(let V of Z){let{key:K,value:W}=V;if(K.status==="aborted"||W.status==="aborted")return s4;if(K.status==="dirty"||W.status==="dirty")Q.dirty();q.set(K.value,W.value)}return{status:Q.value,value:q}}}};$k.create=(J,Q,Y)=>{return new $k({valueType:Q,keyType:J,typeName:q8.ZodMap,...S8(Y)})};QM=class QM extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.parsedType!==y6.set)return o6(Y,{code:z6.invalid_type,expected:y6.set,received:Y.parsedType}),s4;let X=this._def;if(X.minSize!==null){if(Y.data.size<X.minSize.value)o6(Y,{code:z6.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),Q.dirty()}if(X.maxSize!==null){if(Y.data.size>X.maxSize.value)o6(Y,{code:z6.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),Q.dirty()}let G=this._def.valueType;function Z(V){let K=new Set;for(let W of V){if(W.status==="aborted")return s4;if(W.status==="dirty")Q.dirty();K.add(W.value)}return{status:Q.value,value:K}}let q=[...Y.data.values()].map((V,K)=>G._parse(new T$(Y,V,Y.path,K)));if(Y.common.async)return Promise.all(q).then((V)=>Z(V));else return Z(q)}min(J,Q){return new QM({...this._def,minSize:{value:J,message:L4.toString(Q)}})}max(J,Q){return new QM({...this._def,maxSize:{value:J,message:L4.toString(Q)}})}size(J,Q){return this.min(J,Q).max(J,Q)}nonempty(J){return this.min(1,J)}};QM.create=(J,Q)=>{return new QM({valueType:J,minSize:null,maxSize:null,typeName:q8.ZodSet,...S8(Q)})};PE=class PE extends r8{constructor(){super(...arguments);this.validate=this.implement}_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.function)return o6(Q,{code:z6.invalid_type,expected:y6.function,received:Q.parsedType}),s4;function Y(q,V){return Yk({data:q,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,wE(),xW].filter((K)=>!!K),issueData:{code:z6.invalid_arguments,argumentsError:V}})}function X(q,V){return Yk({data:q,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,wE(),xW].filter((K)=>!!K),issueData:{code:z6.invalid_return_type,returnTypeError:V}})}let G={errorMap:Q.common.contextualErrorMap},Z=Q.data;if(this._def.returns instanceof YM){let q=this;return lJ(async function(...V){let K=new FY([]),W=await q._def.args.parseAsync(V,G).catch((U)=>{throw K.addIssue(Y(V,U)),K}),H=await Reflect.apply(Z,this,W);return await q._def.returns._def.type.parseAsync(H,G).catch((U)=>{throw K.addIssue(X(H,U)),K})})}else{let q=this;return lJ(function(...V){let K=q._def.args.safeParse(V,G);if(!K.success)throw new FY([Y(V,K.error)]);let W=Reflect.apply(Z,this,K.data),H=q._def.returns.safeParse(W,G);if(!H.success)throw new FY([X(W,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...J){return new PE({...this._def,args:EV.create(J).rest(hF.create())})}returns(J){return new PE({...this._def,returns:J})}implement(J){return this.parse(J)}strictImplement(J){return this.parse(J)}static create(J,Q,Y){return new PE({args:J?J:EV.create([]).rest(hF.create()),returns:Q||hF.create(),typeName:q8.ZodFunction,...S8(Y)})}};_E=class _E extends r8{get schema(){return this._def.getter()}_parse(J){let{ctx:Q}=this._processInputParams(J);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}};_E.create=(J,Q)=>{return new _E({getter:J,typeName:q8.ZodLazy,...S8(Q)})};kE=class kE extends r8{_parse(J){if(J.data!==this._def.value){let Q=this._getOrReturnCtx(J);return o6(Q,{received:Q.data,code:z6.invalid_literal,expected:this._def.value}),s4}return{status:"valid",value:J.data}}get value(){return this._def.value}};kE.create=(J,Q)=>{return new kE({value:J,typeName:q8.ZodLiteral,...S8(Q)})};mF=class mF extends r8{_parse(J){if(typeof J.data!=="string"){let Q=this._getOrReturnCtx(J),Y=this._def.values;return o6(Q,{expected:B9.joinValues(Y),received:Q.parsedType,code:z6.invalid_type}),s4}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(J.data)){let Q=this._getOrReturnCtx(J),Y=this._def.values;return o6(Q,{received:Q.data,code:z6.invalid_enum_value,options:Y}),s4}return lJ(J.data)}get options(){return this._def.values}get enum(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}get Values(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}get Enum(){let J={};for(let Q of this._def.values)J[Q]=Q;return J}extract(J,Q=this._def){return mF.create(J,{...this._def,...Q})}exclude(J,Q=this._def){return mF.create(this.options.filter((Y)=>!J.includes(Y)),{...this._def,...Q})}};mF.create=LF0;yE=class yE extends r8{_parse(J){let Q=B9.getValidEnumValues(this._def.values),Y=this._getOrReturnCtx(J);if(Y.parsedType!==y6.string&&Y.parsedType!==y6.number){let X=B9.objectValues(Q);return o6(Y,{expected:B9.joinValues(X),received:Y.parsedType,code:z6.invalid_type}),s4}if(!this._cache)this._cache=new Set(B9.getValidEnumValues(this._def.values));if(!this._cache.has(J.data)){let X=B9.objectValues(Q);return o6(Y,{received:Y.data,code:z6.invalid_enum_value,options:X}),s4}return lJ(J.data)}get enum(){return this._def.values}};yE.create=(J,Q)=>{return new yE({values:J,typeName:q8.ZodNativeEnum,...S8(Q)})};YM=class YM extends r8{unwrap(){return this._def.type}_parse(J){let{ctx:Q}=this._processInputParams(J);if(Q.parsedType!==y6.promise&&Q.common.async===!1)return o6(Q,{code:z6.invalid_type,expected:y6.promise,received:Q.parsedType}),s4;let Y=Q.parsedType===y6.promise?Q.data:Promise.resolve(Q.data);return lJ(Y.then((X)=>{return this._def.type.parseAsync(X,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}};YM.create=(J,Q)=>{return new YM({type:J,typeName:q8.ZodPromise,...S8(Q)})};R$=class R$ extends r8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q8.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J),X=this._def.effect||null,G={addIssue:(Z)=>{if(o6(Y,Z),Z.fatal)Q.abort();else Q.dirty()},get path(){return Y.path}};if(G.addIssue=G.addIssue.bind(G),X.type==="preprocess"){let Z=X.transform(Y.data,G);if(Y.common.async)return Promise.resolve(Z).then(async(q)=>{if(Q.value==="aborted")return s4;let V=await this._def.schema._parseAsync({data:q,path:Y.path,parent:Y});if(V.status==="aborted")return s4;if(V.status==="dirty")return tD(V.value);if(Q.value==="dirty")return tD(V.value);return V});else{if(Q.value==="aborted")return s4;let q=this._def.schema._parseSync({data:Z,path:Y.path,parent:Y});if(q.status==="aborted")return s4;if(q.status==="dirty")return tD(q.value);if(Q.value==="dirty")return tD(q.value);return q}}if(X.type==="refinement"){let Z=(q)=>{let V=X.refinement(q,G);if(Y.common.async)return Promise.resolve(V);if(V instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(Y.common.async===!1){let q=this._def.schema._parseSync({data:Y.data,path:Y.path,parent:Y});if(q.status==="aborted")return s4;if(q.status==="dirty")Q.dirty();return Z(q.value),{status:Q.value,value:q.value}}else return this._def.schema._parseAsync({data:Y.data,path:Y.path,parent:Y}).then((q)=>{if(q.status==="aborted")return s4;if(q.status==="dirty")Q.dirty();return Z(q.value).then(()=>{return{status:Q.value,value:q.value}})})}if(X.type==="transform")if(Y.common.async===!1){let Z=this._def.schema._parseSync({data:Y.data,path:Y.path,parent:Y});if(!fF(Z))return s4;let q=X.transform(Z.value,G);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:q}}else return this._def.schema._parseAsync({data:Y.data,path:Y.path,parent:Y}).then((Z)=>{if(!fF(Z))return s4;return Promise.resolve(X.transform(Z.value,G)).then((q)=>({status:Q.value,value:q}))});B9.assertNever(X)}};R$.create=(J,Q,Y)=>{return new R$({schema:J,typeName:q8.ZodEffects,effect:Q,...S8(Y)})};R$.createWithPreprocess=(J,Q,Y)=>{return new R$({schema:Q,effect:{type:"preprocess",transform:J},typeName:q8.ZodEffects,...S8(Y)})};P$=class P$ extends r8{_parse(J){if(this._getType(J)===y6.undefined)return lJ(void 0);return this._def.innerType._parse(J)}unwrap(){return this._def.innerType}};P$.create=(J,Q)=>{return new P$({innerType:J,typeName:q8.ZodOptional,...S8(Q)})};fW=class fW extends r8{_parse(J){if(this._getType(J)===y6.null)return lJ(null);return this._def.innerType._parse(J)}unwrap(){return this._def.innerType}};fW.create=(J,Q)=>{return new fW({innerType:J,typeName:q8.ZodNullable,...S8(Q)})};xE=class xE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=Q.data;if(Q.parsedType===y6.undefined)Y=this._def.defaultValue();return this._def.innerType._parse({data:Y,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}};xE.create=(J,Q)=>{return new xE({innerType:J,typeName:q8.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...S8(Q)})};vE=class vE extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y={...Q,common:{...Q.common,issues:[]}},X=this._def.innerType._parse({data:Y.data,path:Y.path,parent:{...Y}});if(EE(X))return X.then((G)=>{return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new FY(Y.common.issues)},input:Y.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new FY(Y.common.issues)},input:Y.data})}}removeCatch(){return this._def.innerType}};vE.create=(J,Q)=>{return new vE({innerType:J,typeName:q8.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...S8(Q)})};qk=class qk extends r8{_parse(J){if(this._getType(J)!==y6.nan){let Y=this._getOrReturnCtx(J);return o6(Y,{code:z6.invalid_type,expected:y6.nan,received:Y.parsedType}),s4}return{status:"valid",value:J.data}}};qk.create=(J)=>{return new qk({typeName:q8.ZodNaN,...S8(J)})};uQ4=Symbol("zod_brand");Pl=class Pl extends r8{_parse(J){let{ctx:Q}=this._processInputParams(J),Y=Q.data;return this._def.type._parse({data:Y,path:Q.path,parent:Q})}unwrap(){return this._def.type}};Vk=class Vk extends r8{_parse(J){let{status:Q,ctx:Y}=this._processInputParams(J);if(Y.common.async)return(async()=>{let G=await this._def.in._parseAsync({data:Y.data,path:Y.path,parent:Y});if(G.status==="aborted")return s4;if(G.status==="dirty")return Q.dirty(),tD(G.value);else return this._def.out._parseAsync({data:G.value,path:Y.path,parent:Y})})();else{let X=this._def.in._parseSync({data:Y.data,path:Y.path,parent:Y});if(X.status==="aborted")return s4;if(X.status==="dirty")return Q.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:Y.path,parent:Y})}}static create(J,Q){return new Vk({in:J,out:Q,typeName:q8.ZodPipeline})}};fE=class fE extends r8{_parse(J){let Q=this._def.innerType._parse(J),Y=(X)=>{if(fF(X))X.value=Object.freeze(X.value);return X};return EE(Q)?Q.then((X)=>Y(X)):Y(Q)}unwrap(){return this._def.innerType}};fE.create=(J,Q)=>{return new fE({innerType:J,typeName:q8.ZodReadonly,...S8(Q)})};pQ4={object:C7.lazycreate};(function(J){J.ZodString="ZodString",J.ZodNumber="ZodNumber",J.ZodNaN="ZodNaN",J.ZodBigInt="ZodBigInt",J.ZodBoolean="ZodBoolean",J.ZodDate="ZodDate",J.ZodSymbol="ZodSymbol",J.ZodUndefined="ZodUndefined",J.ZodNull="ZodNull",J.ZodAny="ZodAny",J.ZodUnknown="ZodUnknown",J.ZodNever="ZodNever",J.ZodVoid="ZodVoid",J.ZodArray="ZodArray",J.ZodObject="ZodObject",J.ZodUnion="ZodUnion",J.ZodDiscriminatedUnion="ZodDiscriminatedUnion",J.ZodIntersection="ZodIntersection",J.ZodTuple="ZodTuple",J.ZodRecord="ZodRecord",J.ZodMap="ZodMap",J.ZodSet="ZodSet",J.ZodFunction="ZodFunction",J.ZodLazy="ZodLazy",J.ZodLiteral="ZodLiteral",J.ZodEnum="ZodEnum",J.ZodEffects="ZodEffects",J.ZodNativeEnum="ZodNativeEnum",J.ZodOptional="ZodOptional",J.ZodNullable="ZodNullable",J.ZodDefault="ZodDefault",J.ZodCatch="ZodCatch",J.ZodPromise="ZodPromise",J.ZodBranded="ZodBranded",J.ZodPipeline="ZodPipeline",J.ZodReadonly="ZodReadonly"})(q8||(q8={}));OF0=E$.create,wF0=bF.create,cQ4=qk.create,lQ4=gF.create,EF0=TE.create,iQ4=eD.create,nQ4=Xk.create,aQ4=RE.create,oQ4=CE.create,rQ4=JM.create,sQ4=hF.create,tQ4=wV.create,eQ4=Gk.create,JY4=I$.create,QY4=C7.create,YY4=C7.strictCreate,XY4=jE.create,GY4=Il.create,ZY4=SE.create,$Y4=EV.create,qY4=Zk.create,VY4=$k.create,KY4=QM.create,WY4=PE.create,HY4=_E.create,zY4=kE.create,FY4=mF.create,UY4=yE.create,BY4=YM.create,NY4=R$.create,DY4=P$.create,MY4=fW.create,LY4=R$.createWithPreprocess,AY4=Vk.create,IY4={string:(J)=>E$.create({...J,coerce:!0}),number:(J)=>bF.create({...J,coerce:!0}),boolean:(J)=>TE.create({...J,coerce:!0}),bigint:(J)=>gF.create({...J,coerce:!0}),date:(J)=>eD.create({...J,coerce:!0})},PY4=s4});var e={};a8(e,{void:()=>eQ4,util:()=>B9,unknown:()=>sQ4,union:()=>XY4,undefined:()=>aQ4,tuple:()=>$Y4,transformer:()=>NY4,symbol:()=>nQ4,string:()=>OF0,strictObject:()=>YY4,setErrorMap:()=>MQ4,set:()=>KY4,record:()=>qY4,quotelessJson:()=>NQ4,promise:()=>BY4,preprocess:()=>LY4,pipeline:()=>AY4,ostring:()=>OY4,optional:()=>DY4,onumber:()=>wY4,oboolean:()=>EY4,objectUtil:()=>wZ1,object:()=>QY4,number:()=>wF0,nullable:()=>MY4,null:()=>oQ4,never:()=>tQ4,nativeEnum:()=>UY4,nan:()=>cQ4,map:()=>VY4,makeIssue:()=>Yk,literal:()=>zY4,lazy:()=>HY4,late:()=>pQ4,isValid:()=>fF,isDirty:()=>El,isAsync:()=>EE,isAborted:()=>wl,intersection:()=>ZY4,instanceof:()=>dQ4,getParsedType:()=>OV,getErrorMap:()=>wE,function:()=>WY4,enum:()=>FY4,effect:()=>NY4,discriminatedUnion:()=>GY4,defaultErrorMap:()=>xW,datetimeRegex:()=>MF0,date:()=>iQ4,custom:()=>AF0,coerce:()=>IY4,boolean:()=>EF0,bigint:()=>lQ4,array:()=>JY4,any:()=>rQ4,addIssueToContext:()=>o6,ZodVoid:()=>Gk,ZodUnknown:()=>hF,ZodUnion:()=>jE,ZodUndefined:()=>RE,ZodType:()=>r8,ZodTuple:()=>EV,ZodTransformer:()=>R$,ZodSymbol:()=>Xk,ZodString:()=>E$,ZodSet:()=>QM,ZodSchema:()=>r8,ZodRecord:()=>Zk,ZodReadonly:()=>fE,ZodPromise:()=>YM,ZodPipeline:()=>Vk,ZodParsedType:()=>y6,ZodOptional:()=>P$,ZodObject:()=>C7,ZodNumber:()=>bF,ZodNullable:()=>fW,ZodNull:()=>CE,ZodNever:()=>wV,ZodNativeEnum:()=>yE,ZodNaN:()=>qk,ZodMap:()=>$k,ZodLiteral:()=>kE,ZodLazy:()=>_E,ZodIssueCode:()=>z6,ZodIntersection:()=>SE,ZodFunction:()=>PE,ZodFirstPartyTypeKind:()=>q8,ZodError:()=>FY,ZodEnum:()=>mF,ZodEffects:()=>R$,ZodDiscriminatedUnion:()=>Il,ZodDefault:()=>xE,ZodDate:()=>eD,ZodCatch:()=>vE,ZodBranded:()=>Pl,ZodBoolean:()=>TE,ZodBigInt:()=>gF,ZodArray:()=>I$,ZodAny:()=>JM,Schema:()=>r8,ParseStatus:()=>YJ,OK:()=>lJ,NEVER:()=>PY4,INVALID:()=>s4,EMPTY_PATH:()=>LQ4,DIRTY:()=>tD,BRAND:()=>uQ4});var RZ1=L1(()=>{Ol();IZ1();zF0();Qk();IF0();Al()});var Kk=L1(()=>{RZ1();RZ1()});function iJ(J,Q){let Y=CY4(J,Q);return typeof Y==="string"?Y:Y.toString()}function CY4(J,Q,Y=!0){if(!Q)Q=jY4();let{workspaceFolders:X,isWindows:G,homeDir:Z}=Q,q=typeof J==="string"?n0.parse(J):n0.from(J);if(X)for(let V of X){let K=o4(V);if(Z6.hasPrefix(q,K)){let W=K.path.endsWith("/")?K.path.slice(0,-1):K.path,z=Y&&X&&X.length>=2?nD(K.path)+(G?"\\":"/"):"";return jZ1(z+q.path.slice(W.length+1),G,q.scheme)}}if(q?.scheme==="file"){if(Z){let V=o4(Z);if(Z6.hasPrefix(q,V)){let K=V.path.endsWith("/")?V.path.slice(0,-1):V.path,W=q.path.slice(K.length+1);return jZ1("~"+(G?"\\":"/")+W,G,q.scheme)}}return jZ1(q.fsPath,G,q.scheme)}return q}function jZ1(J,Q,Y){return Q&&Y==="file"?J.replaceAll("/","\\"):J}function Rl(J){let Q=Tl;return Tl=J,Q}function jY4(){if(Tl)return Tl;throw Error("must call setDisplayPathEnvInfo before calling displayPath() and related functions")}var Tl=null;var hW=L1(()=>{H4();BE();Kl()});var SY4=(J)=>{let Q=0,Y=[];while(Q<J.length){let X=J[Q];if(X==="\\"){Q++;continue}if(X==="{"){Y.push({type:"brace",value:"{"}),Q++;continue}if(X==="}"){Y.push({type:"brace",value:"}"}),Q++;continue}if(X==="["){Y.push({type:"paren",value:"["}),Q++;continue}if(X==="]"){Y.push({type:"paren",value:"]"}),Q++;continue}if(X===":"){Y.push({type:"separator",value:":"}),Q++;continue}if(X===","){Y.push({type:"delimiter",value:","}),Q++;continue}if(X==='"'){let V="",K=!1;X=J[++Q];while(X!=='"'){if(Q===J.length){K=!0;break}if(X==="\\"){if(Q++,Q===J.length){K=!0;break}V+=X+J[Q],X=J[++Q]}else V+=X,X=J[++Q]}if(X=J[++Q],!K)Y.push({type:"string",value:V});continue}if(X&&/\s/.test(X)){Q++;continue}let Z=/[0-9]/;if(X&&Z.test(X)||X==="-"||X==="."){let V="";if(X==="-")V+=X,X=J[++Q];while(X&&Z.test(X)||X===".")V+=X,X=J[++Q];Y.push({type:"number",value:V});continue}let q=/[a-z]/i;if(X&&q.test(X)){let V="";while(X&&q.test(X)){if(Q===J.length)break;V+=X,X=J[++Q]}if(V=="true"||V=="false"||V==="null")Y.push({type:"name",value:V});else{Q++;continue}continue}Q++}return Y},bE=(J)=>{if(J.length===0)return J;let Q=J[J.length-1];switch(Q.type){case"separator":return J=J.slice(0,J.length-1),bE(J);break;case"number":let Y=Q.value[Q.value.length-1];if(Y==="."||Y==="-")return J=J.slice(0,J.length-1),bE(J);case"string":let X=J[J.length-2];if(X?.type==="delimiter")return J=J.slice(0,J.length-1),bE(J);else if(X?.type==="brace"&&X.value==="{")return J=J.slice(0,J.length-1),bE(J);break;case"delimiter":return J=J.slice(0,J.length-1),bE(J);break}return J},_Y4=(J)=>{let Q=[];if(J.map((Y)=>{if(Y.type==="brace")if(Y.value==="{")Q.push("}");else Q.splice(Q.lastIndexOf("}"),1);if(Y.type==="paren")if(Y.value==="[")Q.push("]");else Q.splice(Q.lastIndexOf("]"),1)}),Q.length>0)Q.reverse().map((Y)=>{if(Y==="}")J.push({type:"brace",value:"}"});else if(Y==="]")J.push({type:"paren",value:"]"})});return J},kY4=(J)=>{let Q="";return J.map((Y)=>{switch(Y.type){case"string":Q+='"'+Y.value+'"';break;default:Q+=Y.value;break}}),Q},bG=(J)=>JSON.parse(kY4(_Y4(bE(SY4(J)))));var XM=()=>{};function nJ(J,...Q){throw Error(`[Immer] minified error nr: ${J}. Full error at: https://bit.ly/3cXEKWf`)}function $M(J){return!!J&&!!J[zX]}function pF(J){if(!J)return!1;return SF0(J)||Array.isArray(J)||!!J[Wk]||!!J.constructor?.[Wk]||Bk(J)||Nk(J)}function SF0(J){if(!J||typeof J!=="object")return!1;let Q=ZM(J);if(Q===null)return!0;let Y=Object.hasOwnProperty.call(Q,"constructor")&&Q.constructor;if(Y===Object)return!0;return typeof Y=="function"&&Function.toString.call(Y)===yY4}function Hk(J,Q){if(qM(J)===0)Reflect.ownKeys(J).forEach((Y)=>{Q(Y,J[Y],J)});else J.forEach((Y,X)=>Q(X,Y,J))}function qM(J){let Q=J[zX];return Q?Q.type_:Array.isArray(J)?1:Bk(J)?2:Nk(J)?3:0}function zk(J,Q){return qM(J)===2?J.has(Q):Object.prototype.hasOwnProperty.call(J,Q)}function SZ1(J,Q){return qM(J)===2?J.get(Q):J[Q]}function _F0(J,Q,Y){let X=qM(J);if(X===2)J.set(Q,Y);else if(X===3)J.add(Y);else J[Q]=Y}function xY4(J,Q){if(J===Q)return J!==0||1/J===1/Q;else return J!==J&&Q!==Q}function Bk(J){return J instanceof Map}function Nk(J){return J instanceof Set}function GM(J){return J.copy_||J.base_}function yZ1(J,Q){if(Bk(J))return new Map(J);if(Nk(J))return new Set(J);if(Array.isArray(J))return Array.prototype.slice.call(J);let Y=SF0(J);if(Q===!0||Q==="class_only"&&!Y){let X=Object.getOwnPropertyDescriptors(J);delete X[zX];let G=Reflect.ownKeys(X);for(let Z=0;Z<G.length;Z++){let q=G[Z],V=X[q];if(V.writable===!1)V.writable=!0,V.configurable=!0;if(V.get||V.set)X[q]={configurable:!0,writable:!0,enumerable:V.enumerable,value:J[q]}}return Object.create(ZM(J),X)}else{let X=ZM(J);if(X!==null&&Y)return{...J};let G=Object.create(X);return Object.assign(G,J)}}function UX(J,Q=!1){if(Sl(J)||$M(J)||!pF(J))return J;if(qM(J)>1)J.set=J.add=J.clear=J.delete=vY4;if(Object.freeze(J),Q)Object.entries(J).forEach(([Y,X])=>UX(X,!0));return J}function vY4(){nJ(2)}function Sl(J){return Object.isFrozen(J)}function VM(J){let Q=xZ1[J];if(!Q)nJ(0,J);return Q}function fY4(J,Q){if(!xZ1[J])xZ1[J]=Q}function kF0(){return Fk}function hY4(J,Q){return{drafts_:[],parent_:J,immer_:Q,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function TF0(J,Q){if(Q)VM("Patches"),J.patches_=[],J.inversePatches_=[],J.patchListener_=Q}function vZ1(J){fZ1(J),J.drafts_.forEach(bY4),J.drafts_=null}function fZ1(J){if(J===Fk)Fk=J.parent_}function RF0(J){return Fk=hY4(Fk,J)}function bY4(J){let Q=J[zX];if(Q.type_===0||Q.type_===1)Q.revoke_();else Q.revoked_=!0}function CF0(J,Q){Q.unfinalizedDrafts_=Q.drafts_.length;let Y=Q.drafts_[0];if(J!==void 0&&J!==Y){if(Y[zX].modified_)vZ1(Q),nJ(4);if(pF(J)){if(J=Cl(Q,J),!Q.parent_)jl(Q,J)}if(Q.patches_)VM("Patches").generateReplacementPatches_(Y[zX].base_,J,Q.patches_,Q.inversePatches_)}else J=Cl(Q,Y,[]);if(vZ1(Q),Q.patches_)Q.patchListener_(Q.patches_,Q.inversePatches_);return J!==gZ1?J:void 0}function Cl(J,Q,Y){if(Sl(Q))return Q;let X=Q[zX];if(!X)return Hk(Q,(G,Z)=>jF0(J,X,Q,G,Z,Y)),Q;if(X.scope_!==J)return Q;if(!X.modified_)return jl(J,X.base_,!0),X.base_;if(!X.finalized_){X.finalized_=!0,X.scope_.unfinalizedDrafts_--;let G=X.copy_,Z=G,q=!1;if(X.type_===3)Z=new Set(G),G.clear(),q=!0;if(Hk(Z,(V,K)=>jF0(J,X,G,V,K,Y,q)),jl(J,G,!1),Y&&J.patches_)VM("Patches").generatePatches_(X,Y,J.patches_,J.inversePatches_)}return X.copy_}function jF0(J,Q,Y,X,G,Z,q){if($M(G)){let V=Z&&Q&&Q.type_!==3&&!zk(Q.assigned_,X)?Z.concat(X):void 0,K=Cl(J,G,V);if(_F0(Y,X,K),$M(K))J.canAutoFreeze_=!1;else return}else if(q)Y.add(G);if(pF(G)&&!Sl(G)){if(!J.immer_.autoFreeze_&&J.unfinalizedDrafts_<1)return;if(Cl(J,G),(!Q||!Q.scope_.parent_)&&typeof X!=="symbol"&&Object.prototype.propertyIsEnumerable.call(Y,X))jl(J,G)}}function jl(J,Q,Y=!1){if(!J.parent_&&J.immer_.autoFreeze_&&J.canAutoFreeze_)UX(Q,Y)}function gY4(J,Q){let Y=Array.isArray(J),X={type_:Y?1:0,scope_:Q?Q.scope_:kF0(),modified_:!1,finalized_:!1,assigned_:{},parent_:Q,base_:J,draft_:null,copy_:null,revoke_:null,isManual_:!1},G=X,Z=mZ1;if(Y)G=[X],Z=Uk;let{revoke:q,proxy:V}=Proxy.revocable(G,Z);return X.draft_=V,X.revoke_=q,V}function _Z1(J,Q){let Y=J[zX];return(Y?GM(Y):J)[Q]}function mY4(J,Q,Y){let X=yF0(Q,Y);return X?"value"in X?X.value:X.get?.call(J.draft_):void 0}function yF0(J,Q){if(!(Q in J))return;let Y=ZM(J);while(Y){let X=Object.getOwnPropertyDescriptor(Y,Q);if(X)return X;Y=ZM(Y)}return}function hZ1(J){if(!J.modified_){if(J.modified_=!0,J.parent_)hZ1(J.parent_)}}function kZ1(J){if(!J.copy_)J.copy_=yZ1(J.base_,J.scope_.immer_.useStrictShallowCopy_)}function bZ1(J,Q){let Y=Bk(J)?VM("MapSet").proxyMap_(J,Q):Nk(J)?VM("MapSet").proxySet_(J,Q):gY4(J,Q);return(Q?Q.scope_:kF0()).drafts_.push(Y),Y}function pY4(J){if(!$M(J))nJ(10,J);return xF0(J)}function xF0(J){if(!pF(J)||Sl(J))return J;let Q=J[zX],Y;if(Q){if(!Q.modified_)return Q.base_;Q.finalized_=!0,Y=yZ1(J,Q.scope_.immer_.useStrictShallowCopy_)}else Y=yZ1(J,!0);if(Hk(Y,(X,G)=>{_F0(Y,X,xF0(G))}),Q)Q.finalized_=!1;return Y}function _l(){let Q="replace",Y="add",X="remove";function G(U,N,M,L){switch(U.type_){case 0:case 2:return q(U,N,M,L);case 1:return Z(U,N,M,L);case 3:return V(U,N,M,L)}}function Z(U,N,M,L){let{base_:A,assigned_:E}=U,P=U.copy_;if(P.length<A.length)[A,P]=[P,A],[M,L]=[L,M];for(let I=0;I<A.length;I++)if(E[I]&&P[I]!==A[I]){let R=N.concat([I]);M.push({op:Q,path:R,value:z(P[I])}),L.push({op:Q,path:R,value:z(A[I])})}for(let I=A.length;I<P.length;I++){let R=N.concat([I]);M.push({op:Y,path:R,value:z(P[I])})}for(let I=P.length-1;A.length<=I;--I){let R=N.concat([I]);L.push({op:X,path:R})}}function q(U,N,M,L){let{base_:A,copy_:E}=U;Hk(U.assigned_,(P,I)=>{let R=SZ1(A,P),S=SZ1(E,P),y=!I?X:zk(A,P)?Q:Y;if(R===S&&y===Q)return;let h=N.concat(P);M.push(y===X?{op:y,path:h}:{op:y,path:h,value:S}),L.push(y===Y?{op:X,path:h}:y===X?{op:Y,path:h,value:z(R)}:{op:Q,path:h,value:z(R)})})}function V(U,N,M,L){let{base_:A,copy_:E}=U,P=0;A.forEach((I)=>{if(!E.has(I)){let R=N.concat([P]);M.push({op:X,path:R,value:I}),L.unshift({op:Y,path:R,value:I})}P++}),P=0,E.forEach((I)=>{if(!A.has(I)){let R=N.concat([P]);M.push({op:Y,path:R,value:I}),L.unshift({op:X,path:R,value:I})}P++})}function K(U,N,M,L){M.push({op:Q,path:[],value:N===gZ1?void 0:N}),L.push({op:Q,path:[],value:U})}function W(U,N){return N.forEach((M)=>{let{path:L,op:A}=M,E=U;for(let S=0;S<L.length-1;S++){let y=qM(E),h=L[S];if(typeof h!=="string"&&typeof h!=="number")h=""+h;if((y===0||y===1)&&(h==="__proto__"||h==="constructor"))nJ(19);if(typeof E==="function"&&h==="prototype")nJ(19);if(E=SZ1(E,h),typeof E!=="object")nJ(18,L.join("/"))}let P=qM(E),I=H(M.value),R=L[L.length-1];switch(A){case Q:switch(P){case 2:return E.set(R,I);case 3:nJ(16);default:return E[R]=I}case Y:switch(P){case 1:return R==="-"?E.push(I):E.splice(R,0,I);case 2:return E.set(R,I);case 3:return E.add(I);default:return E[R]=I}case X:switch(P){case 1:return E.splice(R,1);case 2:return E.delete(R);case 3:return E.delete(M.value);default:return delete E[R]}default:nJ(17,A)}}),U}function H(U){if(!pF(U))return U;if(Array.isArray(U))return U.map(H);if(Bk(U))return new Map(Array.from(U.entries()).map(([M,L])=>[M,H(L)]));if(Nk(U))return new Set(Array.from(U).map(H));let N=Object.create(ZM(U));for(let M in U)N[M]=H(U[M]);if(zk(U,Wk))N[Wk]=U[Wk];return N}function z(U){if($M(U))return H(U);else return U}fY4("Patches",{applyPatches_:W,generatePatches_:G,generateReplacementPatches_:K})}function $9(J){return J}var gZ1,Wk,zX,ZM,yY4,xZ1,Fk,mZ1,Uk,uY4=class{constructor(J){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(Q,Y,X)=>{if(typeof Q==="function"&&typeof Y!=="function"){let Z=Y;Y=Q;let q=this;return function(K=Z,...W){return q.produce(K,(H)=>Y.call(this,H,...W))}}if(typeof Y!=="function")nJ(6);if(X!==void 0&&typeof X!=="function")nJ(7);let G;if(pF(Q)){let Z=RF0(this),q=bZ1(Q,void 0),V=!0;try{G=Y(q),V=!1}finally{if(V)vZ1(Z);else fZ1(Z)}return TF0(Z,X),CF0(G,Z)}else if(!Q||typeof Q!=="object"){if(G=Y(Q),G===void 0)G=Q;if(G===gZ1)G=void 0;if(this.autoFreeze_)UX(G,!0);if(X){let Z=[],q=[];VM("Patches").generateReplacementPatches_(Q,G,Z,q),X(Z,q)}return G}else nJ(1,Q)},this.produceWithPatches=(Q,Y)=>{if(typeof Q==="function")return(q,...V)=>this.produceWithPatches(q,(K)=>Q(K,...V));let X,G;return[this.produce(Q,Y,(q,V)=>{X=q,G=V}),X,G]},typeof J?.autoFreeze==="boolean")this.setAutoFreeze(J.autoFreeze);if(typeof J?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy(J.useStrictShallowCopy)}createDraft(J){if(!pF(J))nJ(8);if($M(J))J=pY4(J);let Q=RF0(this),Y=bZ1(J,void 0);return Y[zX].isManual_=!0,fZ1(Q),Y}finishDraft(J,Q){let Y=J&&J[zX];if(!Y||!Y.isManual_)nJ(9);let{scope_:X}=Y;return TF0(X,Q),CF0(void 0,X)}setAutoFreeze(J){this.autoFreeze_=J}setUseStrictShallowCopy(J){this.useStrictShallowCopy_=J}applyPatches(J,Q){let Y;for(Y=Q.length-1;Y>=0;Y--){let G=Q[Y];if(G.path.length===0&&G.op==="replace"){J=G.value;break}}if(Y>-1)Q=Q.slice(Y+1);let X=VM("Patches").applyPatches_;if($M(J))return X(J,Q);return this.produce(J,(G)=>X(G,Q))}},FX,dF,KM,Og8,wg8,vF0,Eg8,Ig8;var UY=L1(()=>{gZ1=Symbol.for("immer-nothing"),Wk=Symbol.for("immer-draftable"),zX=Symbol.for("immer-state");ZM=Object.getPrototypeOf;yY4=Object.prototype.constructor.toString();xZ1={};mZ1={get(J,Q){if(Q===zX)return J;let Y=GM(J);if(!zk(Y,Q))return mY4(J,Y,Q);let X=Y[Q];if(J.finalized_||!pF(X))return X;if(X===_Z1(J.base_,Q))return kZ1(J),J.copy_[Q]=bZ1(X,J);return X},has(J,Q){return Q in GM(J)},ownKeys(J){return Reflect.ownKeys(GM(J))},set(J,Q,Y){let X=yF0(GM(J),Q);if(X?.set)return X.set.call(J.draft_,Y),!0;if(!J.modified_){let G=_Z1(GM(J),Q),Z=G?.[zX];if(Z&&Z.base_===Y)return J.copy_[Q]=Y,J.assigned_[Q]=!1,!0;if(xY4(Y,G)&&(Y!==void 0||zk(J.base_,Q)))return!0;kZ1(J),hZ1(J)}if(J.copy_[Q]===Y&&(Y!==void 0||(Q in J.copy_))||Number.isNaN(Y)&&Number.isNaN(J.copy_[Q]))return!0;return J.copy_[Q]=Y,J.assigned_[Q]=!0,!0},deleteProperty(J,Q){if(_Z1(J.base_,Q)!==void 0||Q in J.base_)J.assigned_[Q]=!1,kZ1(J),hZ1(J);else delete J.assigned_[Q];if(J.copy_)delete J.copy_[Q];return!0},getOwnPropertyDescriptor(J,Q){let Y=GM(J),X=Reflect.getOwnPropertyDescriptor(Y,Q);if(!X)return X;return{writable:!0,configurable:J.type_!==1||Q!=="length",enumerable:X.enumerable,value:Y[Q]}},defineProperty(){nJ(11)},getPrototypeOf(J){return ZM(J.base_)},setPrototypeOf(){nJ(12)}},Uk={};Hk(mZ1,(J,Q)=>{Uk[J]=function(){return arguments[0]=arguments[0][0],Q.apply(this,arguments)}});Uk.deleteProperty=function(J,Q){return Uk.set.call(this,J,Q,void 0)};Uk.set=function(J,Q,Y){return mZ1.set.call(this,J[0],Q,Y,J[0])};FX=new uY4,dF=FX.produce,KM=FX.produceWithPatches.bind(FX),Og8=FX.setAutoFreeze.bind(FX),wg8=FX.setUseStrictShallowCopy.bind(FX),vF0=FX.applyPatches.bind(FX),Eg8=FX.createDraft.bind(FX),Ig8=FX.finishDraft.bind(FX)});function uZ1({onlyFirst:J=!1}={}){let Y=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(Y,J?void 0:"g")}function gE(J){if(typeof J!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof J}\``);return J.replace(dY4,"")}var dY4;var kl=L1(()=>{dY4=uZ1()});var hF0=v((Sg8,pZ1)=>{var cF={};if(typeof pZ1>"u")window.eastasianwidth=cF;else pZ1.exports=cF;cF.eastAsianWidth=function(J){var Q=J.charCodeAt(0),Y=J.length==2?J.charCodeAt(1):0,X=Q;if(55296<=Q&&Q<=56319&&(56320<=Y&&Y<=57343))Q&=1023,Y&=1023,X=Q<<10|Y,X+=65536;if(X==12288||65281<=X&&X<=65376||65504<=X&&X<=65510)return"F";if(X==8361||65377<=X&&X<=65470||65474<=X&&X<=65479||65482<=X&&X<=65487||65490<=X&&X<=65495||65498<=X&&X<=65500||65512<=X&&X<=65518)return"H";if(4352<=X&&X<=4447||4515<=X&&X<=4519||4602<=X&&X<=4607||9001<=X&&X<=9002||11904<=X&&X<=11929||11931<=X&&X<=12019||12032<=X&&X<=12245||12272<=X&&X<=12283||12289<=X&&X<=12350||12353<=X&&X<=12438||12441<=X&&X<=12543||12549<=X&&X<=12589||12593<=X&&X<=12686||12688<=X&&X<=12730||12736<=X&&X<=12771||12784<=X&&X<=12830||12832<=X&&X<=12871||12880<=X&&X<=13054||13056<=X&&X<=19903||19968<=X&&X<=42124||42128<=X&&X<=42182||43360<=X&&X<=43388||44032<=X&&X<=55203||55216<=X&&X<=55238||55243<=X&&X<=55291||63744<=X&&X<=64255||65040<=X&&X<=65049||65072<=X&&X<=65106||65108<=X&&X<=65126||65128<=X&&X<=65131||110592<=X&&X<=110593||127488<=X&&X<=127490||127504<=X&&X<=127546||127552<=X&&X<=127560||127568<=X&&X<=127569||131072<=X&&X<=194367||177984<=X&&X<=196605||196608<=X&&X<=262141)return"W";if(32<=X&&X<=126||162<=X&&X<=163||165<=X&&X<=166||X==172||X==175||10214<=X&&X<=10221||10629<=X&&X<=10630)return"Na";if(X==161||X==164||167<=X&&X<=168||X==170||173<=X&&X<=174||176<=X&&X<=180||182<=X&&X<=186||188<=X&&X<=191||X==198||X==208||215<=X&&X<=216||222<=X&&X<=225||X==230||232<=X&&X<=234||236<=X&&X<=237||X==240||242<=X&&X<=243||247<=X&&X<=250||X==252||X==254||X==257||X==273||X==275||X==283||294<=X&&X<=295||X==299||305<=X&&X<=307||X==312||319<=X&&X<=322||X==324||328<=X&&X<=331||X==333||338<=X&&X<=339||358<=X&&X<=359||X==363||X==462||X==464||X==466||X==468||X==470||X==472||X==474||X==476||X==593||X==609||X==708||X==711||713<=X&&X<=715||X==717||X==720||728<=X&&X<=731||X==733||X==735||768<=X&&X<=879||913<=X&&X<=929||931<=X&&X<=937||945<=X&&X<=961||963<=X&&X<=969||X==1025||1040<=X&&X<=1103||X==1105||X==8208||8211<=X&&X<=8214||8216<=X&&X<=8217||8220<=X&&X<=8221||8224<=X&&X<=8226||8228<=X&&X<=8231||X==8240||8242<=X&&X<=8243||X==8245||X==8251||X==8254||X==8308||X==8319||8321<=X&&X<=8324||X==8364||X==8451||X==8453||X==8457||X==8467||X==8470||8481<=X&&X<=8482||X==8486||X==8491||8531<=X&&X<=8532||8539<=X&&X<=8542||8544<=X&&X<=8555||8560<=X&&X<=8569||X==8585||8592<=X&&X<=8601||8632<=X&&X<=8633||X==8658||X==8660||X==8679||X==8704||8706<=X&&X<=8707||8711<=X&&X<=8712||X==8715||X==8719||X==8721||X==8725||X==8730||8733<=X&&X<=8736||X==8739||X==8741||8743<=X&&X<=8748||X==8750||8756<=X&&X<=8759||8764<=X&&X<=8765||X==8776||X==8780||X==8786||8800<=X&&X<=8801||8804<=X&&X<=8807||8810<=X&&X<=8811||8814<=X&&X<=8815||8834<=X&&X<=8835||8838<=X&&X<=8839||X==8853||X==8857||X==8869||X==8895||X==8978||9312<=X&&X<=9449||9451<=X&&X<=9547||9552<=X&&X<=9587||9600<=X&&X<=9615||9618<=X&&X<=9621||9632<=X&&X<=9633||9635<=X&&X<=9641||9650<=X&&X<=9651||9654<=X&&X<=9655||9660<=X&&X<=9661||9664<=X&&X<=9665||9670<=X&&X<=9672||X==9675||9678<=X&&X<=9681||9698<=X&&X<=9701||X==9711||9733<=X&&X<=9734||X==9737||9742<=X&&X<=9743||9748<=X&&X<=9749||X==9756||X==9758||X==9792||X==9794||9824<=X&&X<=9825||9827<=X&&X<=9829||9831<=X&&X<=9834||9836<=X&&X<=9837||X==9839||9886<=X&&X<=9887||9918<=X&&X<=9919||9924<=X&&X<=9933||9935<=X&&X<=9953||X==9955||9960<=X&&X<=9983||X==10045||X==10071||10102<=X&&X<=10111||11093<=X&&X<=11097||12872<=X&&X<=12879||57344<=X&&X<=63743||65024<=X&&X<=65039||X==65533||127232<=X&&X<=127242||127248<=X&&X<=127277||127280<=X&&X<=127337||127344<=X&&X<=127386||917760<=X&&X<=917999||983040<=X&&X<=1048573||1048576<=X&&X<=1114109)return"A";return"N"};cF.characterLength=function(J){var Q=this.eastAsianWidth(J);if(Q=="F"||Q=="W"||Q=="A")return 2;else return 1};function fF0(J){return J.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}cF.length=function(J){var Q=fF0(J),Y=0;for(var X=0;X<Q.length;X++)Y=Y+this.characterLength(Q[X]);return Y};cF.slice=function(J,Q,Y){if(textLen=cF.length(J),Q=Q?Q:0,Y=Y?Y:1,Q<0)Q=textLen+Q;if(Y<0)Y=textLen+Y;var X="",G=0,Z=fF0(J);for(var q=0;q<Z.length;q++){var V=Z[q],K=cF.length(V);if(G>=Q-(K==2?1:0))if(G+K<=Y)X+=V;else break;G+=K}return X}});var dZ1=v((_g8,bF0)=>{bF0.exports=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g}});var cY4,lY4;var gF0=L1(()=>{kl();cY4=N6(hF0(),1),lY4=N6(dZ1(),1)});function yl(J,Q,Y="..."){if(J.length<=Q)return J;return J.slice(0,Math.max(0,Q-Y.length))+Y}var cZ1=L1(()=>{gF0()});var mF0="run_terminal_command",uF0="read_file",XJ="Task",q9="finder",BY="get_diagnostics",p9="Bash",xl="InteractiveShell",o5="oracle",IV="mermaid",PV="todo_read",Z7="todo_write",V2="read_web_page",vl="read_thread",_5="create_file",X3="glob",fl="undo_edit",hl="read_mcp_resource",i6="Read",F7="edit_file",mE="format_file",S3="web_search",y8="Grep",WM="Check",BX="librarian",bl="kraken",pF0="read_artifact",dF0="edit_artifact",gl="read_plan",uE="edit_plan",ml="read_github",ul="search_github",pl="commit_search",dl="list_directory_github",cl="list_repositories",ll="glob_github",il="diff",cF0="bookkeeper",lF0="describe_workbook",iF0="execute_query",Dk="skill",nF0;var A4=L1(()=>{nF0=["Task","finder","get_diagnostics","Bash","InteractiveShell","oracle","mermaid","todo_read","todo_write","read_web_page","create_file","glob","Glob","undo_edit","Read","edit_file","delete_file","format_file","web_search","Grep","search_documents","get_document","Check","code_review","kraken","librarian","bookkeeper","read_thread","read_artifact","edit_artifact","read_plan","edit_plan","skill"]});var Mk=v((bg8,oF0)=>{var aF0={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},iY4={...aF0,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},nY4={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"};oF0.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:nY4,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,extglobChars(J){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${J.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(J){return J===!0?iY4:aF0}}});var Lk=v((tY4)=>{var{REGEX_BACKSLASH:aY4,REGEX_REMOVE_BACKSLASH:oY4,REGEX_SPECIAL_CHARS:rY4,REGEX_SPECIAL_CHARS_GLOBAL:sY4}=Mk();tY4.isObject=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J);tY4.hasRegexChars=(J)=>rY4.test(J);tY4.isRegexChar=(J)=>J.length===1&&tY4.hasRegexChars(J);tY4.escapeRegex=(J)=>J.replace(sY4,"\\$1");tY4.toPosixSlashes=(J)=>J.replace(aY4,"/");tY4.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let J=navigator.platform.toLowerCase();return J==="win32"||J==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};tY4.removeBackslashes=(J)=>{return J.replace(oY4,(Q)=>{return Q==="\\"?"":Q})};tY4.escapeLast=(J,Q,Y)=>{let X=J.lastIndexOf(Q,Y);if(X===-1)return J;if(J[X-1]==="\\")return tY4.escapeLast(J,Q,X-1);return`${J.slice(0,X)}\\${J.slice(X)}`};tY4.removePrefix=(J,Q={})=>{let Y=J;if(Y.startsWith("./"))Y=Y.slice(2),Q.prefix="./";return Y};tY4.wrapOutput=(J,Q={},Y={})=>{let X=Y.contains?"":"^",G=Y.contains?"":"$",Z=`${X}(?:${J})${G}`;if(Q.negated===!0)Z=`(?:^(?!${Z}).*$)`;return Z};tY4.basename=(J,{windows:Q}={})=>{let Y=J.split(Q?/[\\/]/:"/"),X=Y[Y.length-1];if(X==="")return Y[Y.length-2];return X}});var ZU0=v((mg8,GU0)=>{var tF0=Lk(),{CHAR_ASTERISK:lZ1,CHAR_AT:VX4,CHAR_BACKWARD_SLASH:Ak,CHAR_COMMA:KX4,CHAR_DOT:iZ1,CHAR_EXCLAMATION_MARK:nZ1,CHAR_FORWARD_SLASH:XU0,CHAR_LEFT_CURLY_BRACE:aZ1,CHAR_LEFT_PARENTHESES:oZ1,CHAR_LEFT_SQUARE_BRACKET:WX4,CHAR_PLUS:HX4,CHAR_QUESTION_MARK:eF0,CHAR_RIGHT_CURLY_BRACE:zX4,CHAR_RIGHT_PARENTHESES:JU0,CHAR_RIGHT_SQUARE_BRACKET:FX4}=Mk(),QU0=(J)=>{return J===XU0||J===Ak},YU0=(J)=>{if(J.isPrefix!==!0)J.depth=J.isGlobstar?1/0:1},UX4=(J,Q)=>{let Y=Q||{},X=J.length-1,G=Y.parts===!0||Y.scanToEnd===!0,Z=[],q=[],V=[],K=J,W=-1,H=0,z=0,U=!1,N=!1,M=!1,L=!1,A=!1,E=!1,P=!1,I=!1,R=!1,S=!1,y=0,h,u,p={value:"",depth:0,isGlob:!1},g=()=>W>=X,i=()=>K.charCodeAt(W+1),Y1=()=>{return h=u,K.charCodeAt(++W)};while(W<X){u=Y1();let K1;if(u===Ak){if(P=p.backslashes=!0,u=Y1(),u===aZ1)E=!0;continue}if(E===!0||u===aZ1){y++;while(g()!==!0&&(u=Y1())){if(u===Ak){P=p.backslashes=!0,Y1();continue}if(u===aZ1){y++;continue}if(E!==!0&&u===iZ1&&(u=Y1())===iZ1){if(U=p.isBrace=!0,M=p.isGlob=!0,S=!0,G===!0)continue;break}if(E!==!0&&u===KX4){if(U=p.isBrace=!0,M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===zX4){if(y--,y===0){E=!1,U=p.isBrace=!0,S=!0;break}}}if(G===!0)continue;break}if(u===XU0){if(Z.push(W),q.push(p),p={value:"",depth:0,isGlob:!1},S===!0)continue;if(h===iZ1&&W===H+1){H+=2;continue}z=W+1;continue}if(Y.noext!==!0){if((u===HX4||u===VX4||u===lZ1||u===eF0||u===nZ1)===!0&&i()===oZ1){if(M=p.isGlob=!0,L=p.isExtglob=!0,S=!0,u===nZ1&&W===H)R=!0;if(G===!0){while(g()!==!0&&(u=Y1())){if(u===Ak){P=p.backslashes=!0,u=Y1();continue}if(u===JU0){M=p.isGlob=!0,S=!0;break}}continue}break}}if(u===lZ1){if(h===lZ1)A=p.isGlobstar=!0;if(M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===eF0){if(M=p.isGlob=!0,S=!0,G===!0)continue;break}if(u===WX4){while(g()!==!0&&(K1=Y1())){if(K1===Ak){P=p.backslashes=!0,Y1();continue}if(K1===FX4){N=p.isBracket=!0,M=p.isGlob=!0,S=!0;break}}if(G===!0)continue;break}if(Y.nonegate!==!0&&u===nZ1&&W===H){I=p.negated=!0,H++;continue}if(Y.noparen!==!0&&u===oZ1){if(M=p.isGlob=!0,G===!0){while(g()!==!0&&(u=Y1())){if(u===oZ1){P=p.backslashes=!0,u=Y1();continue}if(u===JU0){S=!0;break}}continue}break}if(M===!0){if(S=!0,G===!0)continue;break}}if(Y.noext===!0)L=!1,M=!1;let a=K,b="",s="";if(H>0)b=K.slice(0,H),K=K.slice(H),z-=H;if(a&&M===!0&&z>0)a=K.slice(0,z),s=K.slice(z);else if(M===!0)a="",s=K;else a=K;if(a&&a!==""&&a!=="/"&&a!==K){if(QU0(a.charCodeAt(a.length-1)))a=a.slice(0,-1)}if(Y.unescape===!0){if(s)s=tF0.removeBackslashes(s);if(a&&P===!0)a=tF0.removeBackslashes(a)}let q1={prefix:b,input:J,start:H,base:a,glob:s,isBrace:U,isBracket:N,isGlob:M,isExtglob:L,isGlobstar:A,negated:I,negatedExtglob:R};if(Y.tokens===!0){if(q1.maxDepth=0,!QU0(u))q.push(p);q1.tokens=q}if(Y.parts===!0||Y.tokens===!0){let K1;for(let o=0;o<Z.length;o++){let r=K1?K1+1:H,l=Z[o],F1=J.slice(r,l);if(Y.tokens){if(o===0&&H!==0)q[o].isPrefix=!0,q[o].value=b;else q[o].value=F1;YU0(q[o]),q1.maxDepth+=q[o].depth}if(o!==0||F1!=="")V.push(F1);K1=l}if(K1&&K1+1<J.length){let o=J.slice(K1+1);if(V.push(o),Y.tokens)q[q.length-1].value=o,YU0(q[q.length-1]),q1.maxDepth+=q[q.length-1].depth}q1.slashes=Z,q1.parts=V}return q1};GU0.exports=UX4});var VU0=v((ug8,qU0)=>{var nl=Mk(),TV=Lk(),{MAX_LENGTH:al,POSIX_REGEX_SOURCE:BX4,REGEX_NON_SPECIAL_CHARS:NX4,REGEX_SPECIAL_CHARS_BACKREF:DX4,REPLACEMENTS:$U0}=nl,MX4=(J,Q)=>{if(typeof Q.expandRange==="function")return Q.expandRange(...J,Q);J.sort();let Y=`[${J.join("-")}]`;try{new RegExp(Y)}catch(X){return J.map((G)=>TV.escapeRegex(G)).join("..")}return Y},pE=(J,Q)=>{return`Missing ${J}: "${Q}" - use "\\\\${Q}" to match literal characters`},rZ1=(J,Q)=>{if(typeof J!=="string")throw TypeError("Expected a string");J=$U0[J]||J;let Y={...Q},X=typeof Y.maxLength==="number"?Math.min(al,Y.maxLength):al,G=J.length;if(G>X)throw SyntaxError(`Input length: ${G}, exceeds maximum allowed length: ${X}`);let Z={type:"bos",value:"",output:Y.prepend||""},q=[Z],V=Y.capture?"":"?:",K=nl.globChars(Y.windows),W=nl.extglobChars(K),{DOT_LITERAL:H,PLUS_LITERAL:z,SLASH_LITERAL:U,ONE_CHAR:N,DOTS_SLASH:M,NO_DOT:L,NO_DOT_SLASH:A,NO_DOTS_SLASH:E,QMARK:P,QMARK_NO_DOT:I,STAR:R,START_ANCHOR:S}=K,y=(s1)=>{return`(${V}(?:(?!${S}${s1.dot?M:H}).)*?)`},h=Y.dot?"":L,u=Y.dot?P:I,p=Y.bash===!0?y(Y):R;if(Y.capture)p=`(${p})`;if(typeof Y.noext==="boolean")Y.noextglob=Y.noext;let g={input:J,index:-1,start:0,dot:Y.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:q};J=TV.removePrefix(J,g),G=J.length;let i=[],Y1=[],a=[],b=Z,s,q1=()=>g.index===G-1,K1=g.peek=(s1=1)=>J[g.index+s1],o=g.advance=()=>J[++g.index]||"",r=()=>J.slice(g.index+1),l=(s1="",U1=0)=>{g.consumed+=s1,g.index+=U1},F1=(s1)=>{g.output+=s1.output!=null?s1.output:s1.value,l(s1.value)},y1=()=>{let s1=1;while(K1()==="!"&&(K1(2)!=="("||K1(3)==="?"))o(),g.start++,s1++;if(s1%2===0)return!1;return g.negated=!0,g.start++,!0},t=(s1)=>{g[s1]++,a.push(s1)},f1=(s1)=>{g[s1]--,a.pop()},j1=(s1)=>{if(b.type==="globstar"){let U1=g.braces>0&&(s1.type==="comma"||s1.type==="brace"),Q1=s1.extglob===!0||i.length&&(s1.type==="pipe"||s1.type==="paren");if(s1.type!=="slash"&&s1.type!=="paren"&&!U1&&!Q1)g.output=g.output.slice(0,-b.output.length),b.type="star",b.value="*",b.output=p,g.output+=b.output}if(i.length&&s1.type!=="paren")i[i.length-1].inner+=s1.value;if(s1.value||s1.output)F1(s1);if(b&&b.type==="text"&&s1.type==="text"){b.output=(b.output||b.value)+s1.value,b.value+=s1.value;return}s1.prev=b,q.push(s1),b=s1},w0=(s1,U1)=>{let Q1={...W[U1],conditions:1,inner:""};Q1.prev=b,Q1.parens=g.parens,Q1.output=g.output;let A1=(Y.capture?"(":"")+Q1.open;t("parens"),j1({type:s1,value:U1,output:g.output?"":N}),j1({type:"paren",extglob:!0,value:o(),output:A1}),i.push(Q1)},C1=(s1)=>{let U1=s1.close+(Y.capture?")":""),Q1;if(s1.type==="negate"){let A1=p;if(s1.inner&&s1.inner.length>1&&s1.inner.includes("/"))A1=y(Y);if(A1!==p||q1()||/^\)+$/.test(r()))U1=s1.close=`)$))${A1}`;if(s1.inner.includes("*")&&(Q1=r())&&/^\.[^\\/.]+$/.test(Q1)){let w1=rZ1(Q1,{...Q,fastpaths:!1}).output;U1=s1.close=`)${w1})${A1})`}if(s1.prev.type==="bos")g.negatedExtglob=!0}j1({type:"paren",extglob:!0,value:s,output:U1}),f1("parens")};if(Y.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(J)){let s1=!1,U1=J.replace(DX4,(Q1,A1,w1,I1,E1,p1)=>{if(I1==="\\")return s1=!0,Q1;if(I1==="?"){if(A1)return A1+I1+(E1?P.repeat(E1.length):"");if(p1===0)return u+(E1?P.repeat(E1.length):"");return P.repeat(w1.length)}if(I1===".")return H.repeat(w1.length);if(I1==="*"){if(A1)return A1+I1+(E1?p:"");return p}return A1?Q1:`\\${Q1}`});if(s1===!0)if(Y.unescape===!0)U1=U1.replace(/\\/g,"");else U1=U1.replace(/\\+/g,(Q1)=>{return Q1.length%2===0?"\\\\":Q1?"\\":""});if(U1===J&&Y.contains===!0)return g.output=J,g;return g.output=TV.wrapOutput(U1,g,Q),g}while(!q1()){if(s=o(),s==="\x00")continue;if(s==="\\"){let Q1=K1();if(Q1==="/"&&Y.bash!==!0)continue;if(Q1==="."||Q1===";")continue;if(!Q1){s+="\\",j1({type:"text",value:s});continue}let A1=/^\\+/.exec(r()),w1=0;if(A1&&A1[0].length>2){if(w1=A1[0].length,g.index+=w1,w1%2!==0)s+="\\"}if(Y.unescape===!0)s=o();else s+=o();if(g.brackets===0){j1({type:"text",value:s});continue}}if(g.brackets>0&&(s!=="]"||b.value==="["||b.value==="[^")){if(Y.posix!==!1&&s===":"){let Q1=b.value.slice(1);if(Q1.includes("[")){if(b.posix=!0,Q1.includes(":")){let A1=b.value.lastIndexOf("["),w1=b.value.slice(0,A1),I1=b.value.slice(A1+2),E1=BX4[I1];if(E1){if(b.value=w1+E1,g.backtrack=!0,o(),!Z.output&&q.indexOf(b)===1)Z.output=N;continue}}}}if(s==="["&&K1()!==":"||s==="-"&&K1()==="]")s=`\\${s}`;if(s==="]"&&(b.value==="["||b.value==="[^"))s=`\\${s}`;if(Y.posix===!0&&s==="!"&&b.value==="[")s="^";b.value+=s,F1({value:s});continue}if(g.quotes===1&&s!=='"'){s=TV.escapeRegex(s),b.value+=s,F1({value:s});continue}if(s==='"'){if(g.quotes=g.quotes===1?0:1,Y.keepQuotes===!0)j1({type:"text",value:s});continue}if(s==="("){t("parens"),j1({type:"paren",value:s});continue}if(s===")"){if(g.parens===0&&Y.strictBrackets===!0)throw SyntaxError(pE("opening","("));let Q1=i[i.length-1];if(Q1&&g.parens===Q1.parens+1){C1(i.pop());continue}j1({type:"paren",value:s,output:g.parens?")":"\\)"}),f1("parens");continue}if(s==="["){if(Y.nobracket===!0||!r().includes("]")){if(Y.nobracket!==!0&&Y.strictBrackets===!0)throw SyntaxError(pE("closing","]"));s=`\\${s}`}else t("brackets");j1({type:"bracket",value:s});continue}if(s==="]"){if(Y.nobracket===!0||b&&b.type==="bracket"&&b.value.length===1){j1({type:"text",value:s,output:`\\${s}`});continue}if(g.brackets===0){if(Y.strictBrackets===!0)throw SyntaxError(pE("opening","["));j1({type:"text",value:s,output:`\\${s}`});continue}f1("brackets");let Q1=b.value.slice(1);if(b.posix!==!0&&Q1[0]==="^"&&!Q1.includes("/"))s=`/${s}`;if(b.value+=s,F1({value:s}),Y.literalBrackets===!1||TV.hasRegexChars(Q1))continue;let A1=TV.escapeRegex(b.value);if(g.output=g.output.slice(0,-b.value.length),Y.literalBrackets===!0){g.output+=A1,b.value=A1;continue}b.value=`(${V}${A1}|${b.value})`,g.output+=b.value;continue}if(s==="{"&&Y.nobrace!==!0){t("braces");let Q1={type:"brace",value:s,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};Y1.push(Q1),j1(Q1);continue}if(s==="}"){let Q1=Y1[Y1.length-1];if(Y.nobrace===!0||!Q1){j1({type:"text",value:s,output:s});continue}let A1=")";if(Q1.dots===!0){let w1=q.slice(),I1=[];for(let E1=w1.length-1;E1>=0;E1--){if(q.pop(),w1[E1].type==="brace")break;if(w1[E1].type!=="dots")I1.unshift(w1[E1].value)}A1=MX4(I1,Y),g.backtrack=!0}if(Q1.comma!==!0&&Q1.dots!==!0){let w1=g.output.slice(0,Q1.outputIndex),I1=g.tokens.slice(Q1.tokensIndex);Q1.value=Q1.output="\\{",s=A1="\\}",g.output=w1;for(let E1 of I1)g.output+=E1.output||E1.value}j1({type:"brace",value:s,output:A1}),f1("braces"),Y1.pop();continue}if(s==="|"){if(i.length>0)i[i.length-1].conditions++;j1({type:"text",value:s});continue}if(s===","){let Q1=s,A1=Y1[Y1.length-1];if(A1&&a[a.length-1]==="braces")A1.comma=!0,Q1="|";j1({type:"comma",value:s,output:Q1});continue}if(s==="/"){if(b.type==="dot"&&g.index===g.start+1){g.start=g.index+1,g.consumed="",g.output="",q.pop(),b=Z;continue}j1({type:"slash",value:s,output:U});continue}if(s==="."){if(g.braces>0&&b.type==="dot"){if(b.value===".")b.output=H;let Q1=Y1[Y1.length-1];b.type="dots",b.output+=s,b.value+=s,Q1.dots=!0;continue}if(g.braces+g.parens===0&&b.type!=="bos"&&b.type!=="slash"){j1({type:"text",value:s,output:H});continue}j1({type:"dot",value:s,output:H});continue}if(s==="?"){if(!(b&&b.value==="(")&&Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){w0("qmark",s);continue}if(b&&b.type==="paren"){let A1=K1(),w1=s;if(b.value==="("&&!/[!=<:]/.test(A1)||A1==="<"&&!/<([!=]|\w+>)/.test(r()))w1=`\\${s}`;j1({type:"text",value:s,output:w1});continue}if(Y.dot!==!0&&(b.type==="slash"||b.type==="bos")){j1({type:"qmark",value:s,output:I});continue}j1({type:"qmark",value:s,output:P});continue}if(s==="!"){if(Y.noextglob!==!0&&K1()==="("){if(K1(2)!=="?"||!/[!=<:]/.test(K1(3))){w0("negate",s);continue}}if(Y.nonegate!==!0&&g.index===0){y1();continue}}if(s==="+"){if(Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){w0("plus",s);continue}if(b&&b.value==="("||Y.regex===!1){j1({type:"plus",value:s,output:z});continue}if(b&&(b.type==="bracket"||b.type==="paren"||b.type==="brace")||g.parens>0){j1({type:"plus",value:s});continue}j1({type:"plus",value:z});continue}if(s==="@"){if(Y.noextglob!==!0&&K1()==="("&&K1(2)!=="?"){j1({type:"at",extglob:!0,value:s,output:""});continue}j1({type:"text",value:s});continue}if(s!=="*"){if(s==="$"||s==="^")s=`\\${s}`;let Q1=NX4.exec(r());if(Q1)s+=Q1[0],g.index+=Q1[0].length;j1({type:"text",value:s});continue}if(b&&(b.type==="globstar"||b.star===!0)){b.type="star",b.star=!0,b.value+=s,b.output=p,g.backtrack=!0,g.globstar=!0,l(s);continue}let s1=r();if(Y.noextglob!==!0&&/^\([^?]/.test(s1)){w0("star",s);continue}if(b.type==="star"){if(Y.noglobstar===!0){l(s);continue}let Q1=b.prev,A1=Q1.prev,w1=Q1.type==="slash"||Q1.type==="bos",I1=A1&&(A1.type==="star"||A1.type==="globstar");if(Y.bash===!0&&(!w1||s1[0]&&s1[0]!=="/")){j1({type:"star",value:s,output:""});continue}let E1=g.braces>0&&(Q1.type==="comma"||Q1.type==="brace"),p1=i.length&&(Q1.type==="pipe"||Q1.type==="paren");if(!w1&&Q1.type!=="paren"&&!E1&&!p1){j1({type:"star",value:s,output:""});continue}while(s1.slice(0,3)==="/**"){let h1=J[g.index+4];if(h1&&h1!=="/")break;s1=s1.slice(3),l("/**",3)}if(Q1.type==="bos"&&q1()){b.type="globstar",b.value+=s,b.output=y(Y),g.output=b.output,g.globstar=!0,l(s);continue}if(Q1.type==="slash"&&Q1.prev.type!=="bos"&&!I1&&q1()){g.output=g.output.slice(0,-(Q1.output+b.output).length),Q1.output=`(?:${Q1.output}`,b.type="globstar",b.output=y(Y)+(Y.strictSlashes?")":"|$)"),b.value+=s,g.globstar=!0,g.output+=Q1.output+b.output,l(s);continue}if(Q1.type==="slash"&&Q1.prev.type!=="bos"&&s1[0]==="/"){let h1=s1[1]!==void 0?"|$":"";g.output=g.output.slice(0,-(Q1.output+b.output).length),Q1.output=`(?:${Q1.output}`,b.type="globstar",b.output=`${y(Y)}${U}|${U}${h1})`,b.value+=s,g.output+=Q1.output+b.output,g.globstar=!0,l(s+o()),j1({type:"slash",value:"/",output:""});continue}if(Q1.type==="bos"&&s1[0]==="/"){b.type="globstar",b.value+=s,b.output=`(?:^|${U}|${y(Y)}${U})`,g.output=b.output,g.globstar=!0,l(s+o()),j1({type:"slash",value:"/",output:""});continue}g.output=g.output.slice(0,-b.output.length),b.type="globstar",b.output=y(Y),b.value+=s,g.output+=b.output,g.globstar=!0,l(s);continue}let U1={type:"star",value:s,output:p};if(Y.bash===!0){if(U1.output=".*?",b.type==="bos"||b.type==="slash")U1.output=h+U1.output;j1(U1);continue}if(b&&(b.type==="bracket"||b.type==="paren")&&Y.regex===!0){U1.output=s,j1(U1);continue}if(g.index===g.start||b.type==="slash"||b.type==="dot"){if(b.type==="dot")g.output+=A,b.output+=A;else if(Y.dot===!0)g.output+=E,b.output+=E;else g.output+=h,b.output+=h;if(K1()!=="*")g.output+=N,b.output+=N}j1(U1)}while(g.brackets>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing","]"));g.output=TV.escapeLast(g.output,"["),f1("brackets")}while(g.parens>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing",")"));g.output=TV.escapeLast(g.output,"("),f1("parens")}while(g.braces>0){if(Y.strictBrackets===!0)throw SyntaxError(pE("closing","}"));g.output=TV.escapeLast(g.output,"{"),f1("braces")}if(Y.strictSlashes!==!0&&(b.type==="star"||b.type==="bracket"))j1({type:"maybe_slash",value:"",output:`${U}?`});if(g.backtrack===!0){g.output="";for(let s1 of g.tokens)if(g.output+=s1.output!=null?s1.output:s1.value,s1.suffix)g.output+=s1.suffix}return g};rZ1.fastpaths=(J,Q)=>{let Y={...Q},X=typeof Y.maxLength==="number"?Math.min(al,Y.maxLength):al,G=J.length;if(G>X)throw SyntaxError(`Input length: ${G}, exceeds maximum allowed length: ${X}`);J=$U0[J]||J;let{DOT_LITERAL:Z,SLASH_LITERAL:q,ONE_CHAR:V,DOTS_SLASH:K,NO_DOT:W,NO_DOTS:H,NO_DOTS_SLASH:z,STAR:U,START_ANCHOR:N}=nl.globChars(Y.windows),M=Y.dot?H:W,L=Y.dot?z:W,A=Y.capture?"":"?:",E={negated:!1,prefix:""},P=Y.bash===!0?".*?":U;if(Y.capture)P=`(${P})`;let I=(h)=>{if(h.noglobstar===!0)return P;return`(${A}(?:(?!${N}${h.dot?K:Z}).)*?)`},R=(h)=>{switch(h){case"*":return`${M}${V}${P}`;case".*":return`${Z}${V}${P}`;case"*.*":return`${M}${P}${Z}${V}${P}`;case"*/*":return`${M}${P}${q}${V}${L}${P}`;case"**":return M+I(Y);case"**/*":return`(?:${M}${I(Y)}${q})?${L}${V}${P}`;case"**/*.*":return`(?:${M}${I(Y)}${q})?${L}${P}${Z}${V}${P}`;case"**/.*":return`(?:${M}${I(Y)}${q})?${Z}${V}${P}`;default:{let u=/^(.*?)\.(\w+)$/.exec(h);if(!u)return;let p=R(u[1]);if(!p)return;return p+Z+u[2]}}},S=TV.removePrefix(J,E),y=R(S);if(y&&Y.strictSlashes!==!0)y+=`${q}?`;return y};qU0.exports=rZ1});var Ok=v((pg8,WU0)=>{var LX4=ZU0(),sZ1=VU0(),KU0=Lk(),AX4=Mk(),OX4=(J)=>J&&typeof J==="object"&&!Array.isArray(J),K2=(J,Q,Y=!1)=>{if(Array.isArray(J)){let H=J.map((U)=>K2(U,Q,Y));return(U)=>{for(let N of H){let M=N(U);if(M)return M}return!1}}let X=OX4(J)&&J.tokens&&J.input;if(J===""||typeof J!=="string"&&!X)throw TypeError("Expected pattern to be a non-empty string");let G=Q||{},Z=G.windows,q=X?K2.compileRe(J,Q):K2.makeRe(J,Q,!1,!0),V=q.state;delete q.state;let K=()=>!1;if(G.ignore){let H={...Q,ignore:null,onMatch:null,onResult:null};K=K2(G.ignore,H,Y)}let W=(H,z=!1)=>{let{isMatch:U,match:N,output:M}=K2.test(H,q,Q,{glob:J,posix:Z}),L={glob:J,state:V,regex:q,posix:Z,input:H,output:M,match:N,isMatch:U};if(typeof G.onResult==="function")G.onResult(L);if(U===!1)return L.isMatch=!1,z?L:!1;if(K(H)){if(typeof G.onIgnore==="function")G.onIgnore(L);return L.isMatch=!1,z?L:!1}if(typeof G.onMatch==="function")G.onMatch(L);return z?L:!0};if(Y)W.state=V;return W};K2.test=(J,Q,Y,{glob:X,posix:G}={})=>{if(typeof J!=="string")throw TypeError("Expected input to be a string");if(J==="")return{isMatch:!1,output:""};let Z=Y||{},q=Z.format||(G?KU0.toPosixSlashes:null),V=J===X,K=V&&q?q(J):J;if(V===!1)K=q?q(J):J,V=K===X;if(V===!1||Z.capture===!0)if(Z.matchBase===!0||Z.basename===!0)V=K2.matchBase(J,Q,Y,G);else V=Q.exec(K);return{isMatch:Boolean(V),match:V,output:K}};K2.matchBase=(J,Q,Y)=>{return(Q instanceof RegExp?Q:K2.makeRe(Q,Y)).test(KU0.basename(J))};K2.isMatch=(J,Q,Y)=>K2(Q,Y)(J);K2.parse=(J,Q)=>{if(Array.isArray(J))return J.map((Y)=>K2.parse(Y,Q));return sZ1(J,{...Q,fastpaths:!1})};K2.scan=(J,Q)=>LX4(J,Q);K2.compileRe=(J,Q,Y=!1,X=!1)=>{if(Y===!0)return J.output;let G=Q||{},Z=G.contains?"":"^",q=G.contains?"":"$",V=`${Z}(?:${J.output})${q}`;if(J&&J.negated===!0)V=`^(?!${V}).*$`;let K=K2.toRegex(V,Q);if(X===!0)K.state=J;return K};K2.makeRe=(J,Q={},Y=!1,X=!1)=>{if(!J||typeof J!=="string")throw TypeError("Expected a non-empty string");let G={negated:!1,fastpaths:!0};if(Q.fastpaths!==!1&&(J[0]==="."||J[0]==="*"))G.output=sZ1.fastpaths(J,Q);if(!G.output)G=sZ1(J,Q);return K2.compileRe(G,Q,Y,X)};K2.toRegex=(J,Q)=>{try{let Y=Q||{};return new RegExp(J,Y.flags||(Y.nocase?"i":""))}catch(Y){if(Q&&Q.debug===!0)throw Y;return/$^/}};K2.constants=AX4;WU0.exports=K2});var HM=v((dg8,FU0)=>{var HU0=Ok(),wX4=Lk();function zU0(J,Q,Y=!1){if(Q&&(Q.windows===null||Q.windows===void 0))Q={...Q,windows:wX4.isWindows()};return HU0(J,Q,Y)}Object.assign(zU0,HU0);FU0.exports=zU0});var dE;var tZ1=L1(()=>{dE={name:"amp",description:"The frontier coding agent, with a highly capable `smart` mode and a fast `free` mode. ",private:!0,displayName:"Amp (Research Preview)",version:"0.0.0-dev",publisher:"sourcegraph",license:"Apache-2.0",categories:["AI","Chat","Programming Languages","Machine Learning"],keywords:["sourcegraph","amp","amp code","ampcode","ai","assistant","llm","Claude","Claude Sonnet 4.5","GPT-5","agent","free","Claude Sonnet"],icon:"./resources/amp-icon.png",scripts:{dev:"pnpm run -s dev:desktop","dev:insiders":"pnpm run -s dev:desktop:insiders","dev:watch":"NODE_ENV=development bun run scripts/watch.ts","start:dev:desktop":"node scripts/start-dev.js","start:dev:desktop:insiders":"node scripts/start-dev.js --insiders","start:dev:debugger":"pnpm run -s build:dev:desktop && pnpm run -s ./src/autoedit/webview dev","dev:desktop":"pnpm run -s build:dev:desktop && pnpm run start:dev:desktop","dev:desktop:insiders":"pnpm run -s build:dev:desktop && pnpm run start:dev:desktop:insiders","build:dev:desktop":"NODE_ENV=development bun run scripts/build.ts",build:"pnpm run -s _build:extension && concurrently -n 'debugger,web,review' 'pnpm run -s _build:debugger' 'pnpm run -s _build:web' 'pnpm run -s _build:tab:review'","build:production":"pnpm run -s _build:extension:production && concurrently -n 'debugger,web,review' 'pnpm run -s _build:debugger:production' 'pnpm run -s _build:web:production' 'pnpm run -s _build:tab:review:production'","_build:extension":"NODE_ENV=development bun run scripts/build.ts","_build:extension:production":"NODE_ENV=production bun run scripts/build.ts","_build:web":"pnpm -C ../web run build && cp -R ../web/build dist/web-build","_build:web:production":"pnpm -C ../web run build:production && cp -R ../web/build dist/web-build","_build:debugger":"pnpm -C ./src/autoedit/webview run build && cp -R ./src/autoedit/webview/build dist/autoedit","_build:debugger:production":"cross-env NODE_ENV=production pnpm -C ./src/autoedit/webview run build && cp -R ./src/autoedit/webview/build dist/autoedit","_build:tab:review":"pnpm -C ./src/autoedit/review-panel-webview run build && mkdir -p dist/autoedit && cp -R ./src/autoedit/review-panel-webview/build dist/autoedit/review-panel","_build:tab:review:production":"cross-env NODE_ENV=production pnpm -C ./src/autoedit/review-panel-webview run build && mkdir -p dist/autoedit && cp -R ./src/autoedit/review-panel-webview/build dist/autoedit/review-panel","build:icon-font":"npx -y svgtofont --sources ./icon-font/svg --output ./icon-font/build && cp ./icon-font/build/amp-icons.woff ./resources","dev:forks":"pnpm dev:vsix && cursor --install-extension dist/amp-dev.vsix --force && windsurf --install-extension dist/amp-dev.vsix --force","dev:vsix":"pnpm run -s build && vsce package --no-dependencies --pre-release --out dist/amp-dev.vsix && code --install-extension dist/amp-dev.vsix --force","dev:insiders:vsix":"pnpm run -s build && vsce package --no-dependencies --pre-release --out dist/amp-dev.vsix && code-insiders --install-extension dist/amp-dev.vsix --force","prod:vsix":"pnpm run -s build:production && vsce package --no-dependencies --pre-release --out dist/amp-prod.vsix && code --install-extension dist/amp-prod.vsix --force","prod:vsix:test-manual":"bun run scripts/vsix-test-manual.ts","prod:vsix:test-ci":"bun run scripts/vsix-test-ci.ts",test:"vitest run","test:dev":"vitest"},homepage:"https://ampcode.com",repository:{type:"git",url:"https://github.com/sourcegraph/amp",directory:"vscode"},author:{name:"The Amp Team at Sourcegraph",email:"amp-devs@sourcegraph.com"},engines:{vscode:"^1.79.0",node:">=22.0.0"},main:"./dist/extension.cjs",activationEvents:["onStartupFinished"],extensionDependencies:["vscode.git"],contributes:{languages:[{id:"jsonc",filenamePatterns:["**/Library/Application Support/ampcode/managed-settings.json","**/etc/ampcode/managed-settings.json","**/ProgramData/ampcode/managed-settings.json"]}],viewsContainers:{activitybar:[{id:"sourcegraph-amp",title:"Amp",icon:"./resources/amp-mark.svg"}]},views:{"sourcegraph-amp":[{type:"webview",id:"amp.sidebarView",name:"Amp",icon:"./resources/amp-mark.svg",visibility:"visible"},{type:"webview",id:"amp.reviewPanel",name:"Review",icon:"$(compare-changes)",visibility:"visible",when:"config.amp.review.separatePanel"}]},commands:[{command:"amp.agent.newThread",title:"New Thread",category:"Amp",icon:"$(add)"},{command:"amp.agent.newWindow",title:"New Agent Window",category:"Amp",icon:"$(browser)",enablement:"amp.activated"},{command:"amp.agent.toggleVisibility",title:"Toggle Agent",category:"Amp"},{command:"amp.agent.openReview",title:"Open Amp Review",category:"Amp",icon:"$(compare-changes)",enablement:"amp.activated"},{command:"amp.agent.focusPromptEditor",title:"Focus Prompt Editor",category:"Amp"},{command:"amp.agent.addSelectionToPromptEditor",title:"Add Selection to Prompt",category:"Amp",enablement:"editorHasSelection"},{command:"amp.agent.switchAgentMode",title:"Switch Agent Mode for Current Thread",category:"Amp",enablement:"amp.hasMultipleVisibleModes"},{command:"amp.agent.setPromptFromRecentActions",title:"Create Prompt from Recent Actions",category:"Amp"},{command:"amp.agent.findInThread",title:"Find in Thread",category:"Amp",enablement:"amp.agent.active"},{command:"amp.agent.collapseAllInThread",title:"Collapse All Blocks in Thread",category:"Amp"},{command:"amp.agent.expandAllInThread",title:"Expand All Blocks in Thread",category:"Amp"},{command:"amp.agent.expandToggleInThread",title:"Toggle Expand All Blocks in Thread",category:"Amp"},{command:"amp.agent.toggleThreadSwitcher",title:"Switch to Thread...",category:"Amp",enablement:"amp.agent.active"},{command:"amp.agent.toggleCostDisplay",title:"Toggle Cost Display",category:"Amp"},{command:"amp.agent.navigateThreadPrevious",title:"Navigate to Previous Thread",category:"Amp",enablement:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.navigateThreadNext",title:"Navigate to Next Thread",category:"Amp",enablement:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.openThreadJSON",title:"Open Thread JSON",category:"Amp",enablement:"amp.isDevelopmentMode"},{command:"amp.testThreadSummary",title:"Test Thread Summary",category:"Amp",enablement:"amp.isDevelopmentMode"},{command:"amp.tab.quickPickMenu",title:"Show Tab Menu",category:"Amp",icon:"$(debug)",enablement:"amp.activated"},{command:"amp.tab.showDebugPanel",title:"Show Tab Debug Panel",category:"Amp",icon:"$(debug)",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.showDiff",title:"Tab: Show Diff",category:"Amp",icon:"$(diff)",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.diffPanel.acceptAll",title:"Tab Review: Accept All Changes",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.diffPanel.instruct",title:"Tab Review: Open Instruct Mode",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled && config.amp.tab.experimental.review"},{command:"amp.tab.manualTrigger",title:"Tab Manual Trigger",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.enable",title:"Enable Tab",category:"Amp",enablement:"amp.activated && !config.amp.tab.enabled"},{command:"amp.tab.disable",title:"Disable Tab",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.toggleForCurrentDocument",title:"Toggle Tab for Current Document",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.debugInfo",title:"Open Tab Debug Info",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.tab.autoAcceptChain",title:"Accept Suggestion Chain",category:"Amp",enablement:"amp.activated && config.amp.tab.enabled"},{command:"amp.mcp.restartServers",title:"Restart MCP Servers",category:"Amp"},{command:"amp.connect.reconnect",title:"Reconnect",category:"Amp",enablement:"amp.activated"},{command:"amp.agent.editUserPermissions",title:"Edit User Permissions",category:"Amp"},{command:"amp.agent.editWorkspacePermissions",title:"Edit Workspace Permissions",category:"Amp"},{command:"amp.commandPalette.show",title:"Show Amp Command Palette",category:"Amp",icon:"$(list-flat)"}],menus:{"editor/context":[{command:"amp.agent.addSelectionToPromptEditor",when:"editorHasSelection",group:"amp@1"}]},keybindings:[{command:"amp.agent.newThread",key:"ctrl+l",mac:"cmd+l",when:"amp.primaryShortcuts"},{command:"amp.agent.newThread",key:"ctrl+alt+j",mac:"cmd+alt+j",when:"!amp.primaryShortcuts"},{command:"amp.agent.newWindow",key:"ctrl+shift+l",mac:"cmd+shift+l"},{command:"amp.agent.toggleVisibility",key:"ctrl+i",mac:"cmd+i",when:"amp.primaryShortcuts"},{command:"amp.agent.toggleVisibility",key:"ctrl+alt+u",mac:"cmd+alt+u",when:"!amp.primaryShortcuts"},{command:"amp.agent.findInThread",key:"ctrl+f",mac:"cmd+f",when:"amp.agent.active"},{command:"amp.agent.toggleThreadSwitcher",key:"ctrl+k",mac:"cmd+k",when:"amp.agent.active"},{command:"amp.agent.toggleCostDisplay",key:"ctrl+d",mac:"cmd+d",when:"amp.agent.active && amp.isSourcegraphTeammate || isWeb"},{command:"amp.agent.navigateThreadPrevious",key:"ctrl+shift+[",mac:"cmd+shift+[",when:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.navigateThreadNext",key:"ctrl+shift+]",mac:"cmd+shift+]",when:"amp.agent.active && amp.agent.activeView == 'sidebar'"},{command:"amp.agent.savePermissions",key:"ctrl+s",mac:"cmd+s",enablement:"editorTextFocus && resourcePath =~ /[\\\\/]amp[\\\\/]permissions-.*\\.sh$/i",when:"editorTextFocus && resourcePath =~ /[\\\\/]amp[\\\\/]permissions-.*\\.sh$/i"},{command:"amp.tab.diffPanel.acceptAll",key:"ctrl+enter",mac:"cmd+enter",when:"activeWebviewPanelId == 'ampTabDiff'"},{command:"amp.tab.diffPanel.instruct",key:"ctrl+i",mac:"cmd+i",when:"activeWebviewPanelId == 'ampTabDiff'"},{command:"amp.agent.openReview",key:"ctrl+;",mac:"cmd+;"},{command:"-extension.vim_tab",key:"tab",when:"editorTextFocus && vim.active && vim.mode != 'Insert' && !inlineEditIsVisible && !inDebugRepl"},{command:"-vscode-neovim.send",key:"tab",when:"neovim.init && (editorTextFocus && neovim.mode != insert && editorLangId not in neovim.editorLangIdExclusions || neovim.recording)"},{command:"amp.tab.accept",key:"tab",when:"editorTextFocus && amp.activated && amp.tab.active && !amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.showDiff",key:"shift+tab",when:"editorTextFocus && amp.activated && config.amp.tab.experimental.review && (amp.tab.active || inlineSuggestionVisible) && !amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.dismiss",key:"escape",when:"editorTextFocus && amp.activated && amp.tab.active && !amp.nextCursorSuggested && !suggestWidgetVisible && !amp.editorHasMultipleLineSelection"},{command:"amp.nextCursor.accept",key:"tab",when:"editorTextFocus && amp.activated && amp.nextCursorSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.nextCursor.discard",key:"escape",when:"editorTextFocus && amp.activated && amp.nextCursorSuggested && !suggestWidgetVisible && !amp.editorHasMultipleLineSelection"},{command:"amp.tab.autoAcceptChain",key:"alt+shift+tab",when:"editorTextFocus && amp.activated && (amp.tab.active || amp.nextCursorSuggested) && !amp.editorHasMultipleLineSelection"},{command:"amp.autoImport.accept",key:"tab",when:"editorTextFocus && amp.activated && config.amp.tab.enabled && amp.autoImportSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.autoImport.discard",key:"escape",when:"editorTextFocus && amp.activated && config.amp.tab.enabled && amp.autoImportSuggested && !amp.editorHasMultipleLineSelection"},{command:"amp.commandPalette.show",key:"ctrl+shift+a",mac:"cmd+shift+a",when:"amp.activated"},{command:"amp.agent.switchAgentMode",key:"ctrl+shift+m",mac:"cmd+shift+m",when:"amp.activated && amp.hasMultipleVisibleModes"}],configuration:{type:"object",title:"Amp",properties:{"amp.url":{type:"string",examples:["https://ampcode.com/"],description:"URL to the Amp server, usually https://ampcode.com/",scope:"application"},"amp.notifications.enabled":{type:"boolean",default:!0,description:"Play notification sound when done or blocked",scope:"window"},"amp.mcpServers":{type:"object",description:"Model Context Protocol servers that expose tools",additionalProperties:{type:"object",oneOf:[{properties:{command:{type:"string"},args:{type:"array",items:{type:"string"}},env:{type:"object",additionalProperties:{type:"string"}}},required:["command"]},{properties:{url:{type:"string"},headers:{type:"object",description:"HTTP headers to send with requests to the MCP server",additionalProperties:{type:"string"}},oauth:{type:"object",description:"OAuth 2.0 configuration for MCP server authentication",properties:{clientId:{type:"string",description:"OAuth client ID"},clientSecret:{type:"string",description:"OAuth client secret (optional for public clients)"},authUrl:{type:"string",description:"OAuth authorization endpoint URL"},tokenUrl:{type:"string",description:"OAuth token endpoint URL"},scopes:{type:"array",description:"OAuth scopes to request",items:{type:"string"}},redirectUrl:{type:"string",description:"OAuth redirect URL (defaults to http://localhost:8976/oauth/callback)"}}}},required:["url"]}]}},"amp.mcpTrustedServers":{type:"array",markdownDescription:"MCP server trust decisions. **Security Note:** This setting is only read from user settings, never workspace settings, to prevent malicious repositories from auto-approving MCP servers.",scope:"application",items:{type:"object",properties:{serverName:{type:"string",description:"MCP server name"},specHash:{type:"string",description:"Hash of the server configuration"},allow:{type:"boolean",description:"Whether this server is approved"}},required:["serverName","specHash","allow"]}},"amp.workspaces":{type:"array",markdownDescription:"Workspace-level configuration. This setting is only read from user settings, never workspace settings.",scope:"application",items:{type:"object",properties:{path:{type:"string",description:"Absolute path to the workspace"},allowAllMcpServers:{type:"boolean",description:"Whether to automatically trust all MCP servers in this workspace"}},required:["path"]}},"amp.mcpPermissions":{type:"array",description:"Permissions for Model Context Protocol (MCP) servers. Controls which MCP servers can be used.",items:{type:"object",properties:{matches:{$ref:"https://static.ampcode.com/schemas/permissions.schema.json#/$defs/permissionMatchCondition"},action:{type:"string",enum:["allow","reject"],description:"Whether to allow or reject MCP servers matching the condition"}},required:["matches","action"],additionalProperties:!1},default:[],scope:"application"},"amp.permissions":{$ref:"https://static.ampcode.com/schemas/permissions.schema.json",description:"Entries checked in sequence to configure tool permissions",default:[]},"amp.experimental.promptAutocompleteMode":{type:"string",enum:["disabled","word-based"],enumDescriptions:["Disabled - no prompt autocomplete","Offline word completion from workspace and thread context"],default:"word-based",markdownDescription:"**Experimental:** Prompt autocomplete suggestions while typing.",scope:"application"},"amp.experimental.promptAutocomplete.verboseLogging":{type:"boolean",default:!1,markdownDescription:"Enable verbose logging for prompt autocomplete.",scope:"application"},"amp.experimental.tools":{type:"array",description:"Enable experimental tools by name. Available tools: kraken",items:{type:"string"},default:[],scope:"application"},"amp.tools.disable":{type:"array",markdownDescription:'Disable specific tools by name. Glob patterns using * are supported\n\nExamples:\n- Disable edit_file: `["builtin:edit_file"]`\n- Disable all playwright tab tools: `["mcp__playwright__browser_tab*"]`',items:{type:"string"},default:[]},"amp.toolbox.path":{type:"string",markdownDescription:"Path to the directory containing toolbox scripts. Supports colon-separated paths.",scope:"window"},"amp.dangerouslyAllowAll":{type:"boolean",description:"If true, never ask for confirmation when running commands",scope:"window",default:!1},"amp.model.sonnet":{type:"boolean",description:"Use Claude Sonnet 4.5 instead of Gemini 3",scope:"window",default:!1},"amp.guardedFiles.allowlist":{type:"array",description:"Glob patterns for files that should bypass guarded file protection. Files matching these patterns can be modified without user confirmation.",items:{type:"string"},default:[],scope:"window"},"amp.anthropic.thinking.enabled":{type:"boolean",default:!0,description:"Enable Claude's extended thinking capabilities",scope:"application"},"amp.tools.inactivityTimeout":{type:"number",default:300,minimum:1,maximum:3600,description:"How many seconds of no output to wait before canceling bash commands.",scope:"workspace"},"amp.tools.stopTimeout":{type:"number",default:300,description:"How many seconds to wait before canceling a running tool.",scope:"application"},"amp.terminal.commands.nodeSpawn.loadProfile":{type:"string",enum:["always","never","daily"],default:"always",description:"Before running commands (including MCP servers), whether to load environment variables from the user's profile (.bashrc, .zshrc, .envrc) as visible from the workspace root directory.",scope:"application"},"amp.todos.enabled":{type:"boolean",default:!0,description:"Enable TODOs tracking for managing tasks",scope:"application"},"amp.guidanceFiles.specs":{type:"boolean",default:!1,description:"[Experimental] Read `*.spec.md` files adjacent to `AGENT.md` files that are read",scope:"window"},"amp.security.audit.logMcpConnections":{type:"boolean",default:!1,description:"Enable telemetry logging for remote MCP server connections (for security auditing)",scope:"application"},"amp.review.separatePanel":{type:"boolean",default:!1,description:"Show the review panel as a separate container that's independently draggable to a different sidebar location.",scope:"window"},"amp.hooks":{type:"array",scope:"window",description:"[Experimental] Hooks are event handlers that can react to specific conditions.",items:{type:"object",properties:{compatibilityDate:{type:"string",const:"2025-05-13",default:"2025-05-13",description:"The version of the hook schema that this value was written to conform to"},id:{type:"string",description:"A unique identifier for the hook",examples:["run-vitest-with-env-vars"]},description:{type:"string",description:"A description of the hook"},on:{oneOf:[{type:"object",properties:{event:{type:"string",const:"tool:pre-execute",default:"tool:pre-execute",description:"Trigger when a tool is about to be executed"},tool:{oneOf:[{type:"string",description:"Tool name to match (e.g., 'edit_file')"},{type:"array",items:{type:"string"},description:"Tool names to match"}],description:"Trigger for the given tool name(s)"},"input.contains":{oneOf:[{type:"string",description:"String pattern to match in the tool input"},{type:"array",items:{type:"string"},description:"String patterns to match in the tool input"}],description:"Trigger only when the tool input contains the given literal string or strings"}},required:["event","tool","input.contains"]},{type:"object",properties:{event:{type:"string",const:"tool:post-execute",default:"tool:post-execute",description:"Trigger after a tool has been executed"},tool:{oneOf:[{type:"string",description:"Tool name to match (e.g., 'edit_file')"},{type:"array",items:{type:"string"},description:"Tool names to match"}],description:"Trigger for the given tool name(s)"}},required:["event","tool"]}]},action:{oneOf:[{type:"object",properties:{type:{type:"string",const:"send-user-message",default:"send-user-message",description:"Send a user message to interrupt the agent and cancel the tool call in the `tool:pre-execute` trigger before it starts to run"},message:{type:"string",description:"The text of the message to send"}},required:["type","message"]},{type:"object",properties:{type:{type:"string",const:"redact-tool-input",default:"redact-tool-input",description:"Redact the tool input after execution. Only allowed with `tool:post-execute` event."},redactedInput:{type:"object",description:"The replacement input data to use instead of the original tool input (must be an object)"}},required:["type","redactedInput"]}]},if:{type:"boolean",description:"A condition that determines whether the hook should be executed",default:!0}},required:["compatibilityDate","id","on","action"]},default:[]},"amp.tab.enabled":{type:"boolean",default:!1,description:"Enable Amp Tab",scope:"application"},"amp.tab.clipboard.enabled":{type:"boolean",default:!0,description:"Enable clipboard access for Amp Tab context",scope:"application"},"amp.tab.verboseLogs":{type:"boolean",default:!1,description:"Enable verbose logging for Amp Tab",scope:"application"},"amp.debugLogs":{type:"boolean",default:!1,description:"Enable debug logging in the Amp output channel",scope:"application"},"amp.tab.disabledLanguages":{type:"array",items:{type:"string"},default:[],examples:["markdown","python"],description:"List of language IDs for which Amp Tab is disabled",scope:"application"},"amp.tab.disableOnComment":{type:"boolean",default:!1,description:"Disable Amp Tab completions on comment lines",scope:"application"},"amp.tab.autoImport.enabled":{type:"boolean",default:!0,description:"Enable auto import in Amp Tab",scope:"application"},"amp.tab.dismissCommandIds":{type:"array",items:{type:"string"},default:["extension.vim_escape","vim.escape","vscode-neovim.escape","vscode-neovim.escapeKey"],description:"Command IDs to run when Escape is pressed to dismiss an Amp Tab suggestion",scope:"application"},"amp.tab.experimental.showHotStreakProgress":{type:"boolean",default:!1,description:"Experimental: Show hot streak progress in image-rendered suggestions",scope:"window"},"amp.tab.experimental.autoAccept.delayMs":{type:"number",default:0,description:"Experimental: Delay in milliseconds before auto-accepting Amp Tab suggestions",scope:"application"},"amp.tab.experimental.unobtrusiveDiffs":{type:"boolean",default:!1,description:"Experimental: Enable unobtrusive diffs mode for Amp Tab suggestions. When enabled, suggestions are shown as image overlays to avoid layout shifts and visual interference with existing code.",scope:"application"},"amp.tab.experimental.review":{type:"boolean",default:!1,description:"Experimental: Enable review mode for Amp Tab. When enabled, adds the ability to review suggestion changes with Shift+Tab shortcut and review panel.",scope:"window"},"amp.tab.diagnosticTracking":{type:"string",enum:["disabled","same_file","multi_file"],default:"multi_file",description:"Enable diagnostic tracking for Amp Tab suggestions. 'disabled' = no tracking, 'same_file' = track diagnostics within the same file, 'multi_file' = track diagnostics across multiple files.",scope:"application"},"amp.tab.hoverDiagnosticSuggestions":{type:"boolean",default:!1,description:"Show suggestions when hovering over diagnostics.",scope:"application"},"amp.tab.experimental.displayMode":{type:"string",enum:["eager","subtle"],default:"eager",description:"Experimental: Control how Amp Tab suggestions are displayed. 'eager' = show diff immediately, 'subtle' = show 'Tab to Jump' first, then show diff after user interaction.",scope:"application"},"amp.tab.experimental.disableClientFilters":{type:"array",items:{type:"string",enum:["recentlyRejectedCodeToRewrite","recentEdits","rewriteAreaOverlap","bigModification","incompatibleWithSelectedCompletionContextItem","recentlyRejectedDiff","whiteSpaceOnlyChange","formattingOnlyChange"]},default:[],description:"Experimental: Disable specific client-side filters to observe unfiltered model behavior.",scope:"application"},"amp.ui.zoomLevel":{type:"number",default:1,description:"Zoom level for the Amp UI",scope:"application"},"amp.experimental.bookkeeper":{type:"boolean",default:!1,description:"Enable the Bookkeeper subagent for reading and querying Excel workbooks (.xlsx)",scope:"window"},"amp.experimental.planMode":{type:"boolean",default:!1,description:"Enable plan mode for collaborative planning before execution",scope:"window"},"amp.experimental.dojoMode":{type:"boolean",default:!1,description:"Enable dojo mode - a learning mode that guides you to discover solutions yourself",scope:"window"},"amp.git.commit.coauthor.enabled":{type:"boolean",default:!0,description:"Enable adding Amp as co-author in git commits",scope:"window"},"amp.git.commit.ampThread.enabled":{type:"boolean",default:!0,description:"Enable adding Amp-Thread trailer in git commits",scope:"window"},"amp.tryOpus":{type:"boolean",default:!1,description:"Try Claude Opus 4.5 as the main agent model. See https://ampcode.com/news/try-opus",scope:"window"}}},icons:{"amp-agent-file":{description:"Amp agent file",default:{fontPath:"resources/amp-icons.woff",fontCharacter:"\\0041"}}}},capabilities:{untrustedWorkspaces:{supported:"limited",description:"Amp only uses MCP servers from trusted workspaces because they execute code.",restrictedConfigurations:["amp.mcpServers","amp.mcpPermissions","amp.url"]},virtualWorkspaces:{supported:!1,description:"Amp is not supported in virtual workspaces like GitHub.dev because Amp requires local file system access and terminal capabilities."}},dependencies:{"@anthropic-ai/sdk":"catalog:","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.57.2","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.57.2","@opentelemetry/exporter-metrics-otlp-http":"^0.57.2","@opentelemetry/exporter-trace-otlp-http":"^0.57.2","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-logs":"^0.57.2","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.57.2","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/sdk-trace-node":"^1.30.1","@opentelemetry/semantic-conventions":"^1.34.0","@sourcegraph/amp-core":"workspace:*","@sourcegraph/amp-uri":"workspace:*","@sourcegraph/observable":"workspace:*","canvaskit-wasm":"^0.40.0","detect-indent":"^7.0.1",diff:"catalog:","fast-json-stable-stringify":"^2.1.0","fast-myers-diff":"^3.2.0","fast-xml-parser":"^5.2.3",isbinaryfile:"^5.0.5","jsonc-parser":"^3.3.1",lodash:"^4.17.21","lru-cache":"^11.1.0","node-fetch":"^3.3.2",shiki:"3.8.1",systeminformation:"^5.27.7",uuid:"^11.1.0","vscode-languageserver-textdocument":"^1.0.12","wink-nlp-utils":"^2.1.0",ws:"^8.18.3"},devDependencies:{"@secretlint/secretlint-rule-no-dotenv":"^11.2.5","@secretlint/secretlint-rule-preset-recommend":"^11.2.5","@sourcegraph/amp-web":"workspace:*","@types/bun":"^1.2.17",dedent:"catalog:","@types/diff":"catalog:","@types/jest-image-snapshot":"^6.4.0","@types/lodash":"^4.17.15","@types/node":"catalog:","@types/uuid":"^10.0.0","@types/vscode":"^1.79.0","@types/ws":"^8.18.1","@vscode/test-electron":"^2.4.1","@vscode/vsce":"^3.2.2","cross-env":"^7.0.3","crypto-browserify":"^3.12.1","jest-image-snapshot":"^6.5.0","os-browserify":"^0.3.0","path-browserify":"^1.0.1","rollup-plugin-polyfill-node":"^0.13.0",tsx:"^4.19.4"}}});function IX4(J){return typeof J==="number"&&Number.isInteger(J)&&J>=1&&J<=3600}function BU0(J){let Q=J.settings["tools.inactivityTimeout"],Y=J.settings["tools.stopTimeout"],X=Q;if(X===void 0&&Y!==void 0)X=Y;if(X===void 0)X=dE.contributes.configuration.properties["amp.tools.inactivityTimeout"].default;if(!IX4(X))return null;return X*1000}function NU0(J){let Q=J.settings["tools.stopTimeout"],Y=dE.contributes.configuration.properties["amp.tools.stopTimeout"].default;return(Q??Y)*1000}var UU0;var ol=L1(()=>{tZ1();UU0=dE.contributes.configuration.properties});function aJ(J){let Q=p8[J];return`${Q.provider}/${Q.name}`}function gG(J){let[Q,Y]=J.split("/");for(let X of Object.values(p8))if(X.provider===Q&&X.name===Y)return X;switch(Q){case"anthropic":return p8.CLAUDE_SONNET_4_5;case"openai":return p8.GPT_5;case"xai":return p8.GROK_CODE_FAST_1;case"cerebras":return p8.Z_AI_GLM_4_6;case"fireworks":return p8.FIREWORKS_GLM_4P6;case"moonshotai":return p8.KIMI_K2_INSTRUCT;case"openrouter":return p8.SONOMA_SKY_ALPHA;case"groq":return p8.GPT_OSS_120B;case"vertexai":return p8.GEMINI_2_5_FLASH_PREVIEW_09_2025;default:throw Error(`Unknown provider: ${Q}`)}}function mG(J){let Q=J.indexOf("/");if(Q===-1)return J;return J.slice(Q+1)}function bW(J,Q){let Y=gG(J);if(Q&&Y.maxInputTokensInFreeMode)return Y.maxInputTokensInFreeMode;return Y.contextWindow-Y.maxOutputTokens}var C9,p8,eZ1;var gW=L1(()=>{C9={ANTHROPIC:"anthropic",OPENAI:"openai",XAI:"xai",CEREBRAS:"cerebras",FIREWORKS:"fireworks",GROQ:"groq",MOONSHOT:"moonshotai",OPENROUTER:"openrouter",VERTEXAI:"vertexai"},p8={CLAUDE_SONNET_4:{provider:C9.ANTHROPIC,name:"claude-sonnet-4-20250514",displayName:"Claude Sonnet 4",contextWindow:1e6,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_5:{provider:C9.ANTHROPIC,name:"claude-sonnet-4-5-20250929",displayName:"Claude Sonnet 4.5",contextWindow:1e6,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4:{provider:C9.ANTHROPIC,name:"claude-opus-4-20250514",displayName:"Claude Opus 4",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_1:{provider:C9.ANTHROPIC,name:"claude-opus-4-1-20250805",displayName:"Claude Opus 4.1",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_5:{provider:C9.ANTHROPIC,name:"claude-opus-4-5-20251101",displayName:"Claude Opus 4.5",contextWindow:200000,maxOutputTokens:32000,capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_HAIKU_4_5:{provider:C9.ANTHROPIC,name:"claude-haiku-4-5-20251001",displayName:"Claude Haiku 4.5",contextWindow:200000,maxOutputTokens:64000,capabilities:{reasoning:!0,vision:!0,tools:!0},freeTierEligible:!0,maxInputTokensInFreeMode:120000},GPT_5:{provider:C9.OPENAI,name:"gpt-5",displayName:"GPT-5",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_1:{provider:C9.OPENAI,name:"gpt-5.1",displayName:"GPT-5.1",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_CODEX:{provider:C9.OPENAI,name:"gpt-5-codex",displayName:"GPT-5 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_1_CODEX:{provider:C9.OPENAI,name:"gpt-5.1-codex",displayName:"GPT-5.1 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_MINI:{provider:C9.OPENAI,name:"gpt-5-mini",displayName:"GPT-5 Mini",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.25,output:2,cached:0.025},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_NANO:{provider:C9.OPENAI,name:"gpt-5-nano",displayName:"GPT-5 Nano",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.05,output:0.4,cached:0.005},capabilities:{reasoning:!0,vision:!0,tools:!0}},O3:{provider:C9.OPENAI,name:"o3",displayName:"o3",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:2,output:8,cached:0.5},capabilities:{reasoning:!0,tools:!0}},O3_MINI:{provider:C9.OPENAI,name:"o3-mini",displayName:"o3-mini",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:1.1,output:4.4,cached:0.55},capabilities:{reasoning:!0,tools:!0}},GPT_OSS_120B:{provider:C9.OPENAI,name:"openai/gpt-oss-120b",displayName:"GPT OSS 120B",contextWindow:128000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GROK_CODE_FAST_1:{provider:C9.XAI,name:"grok-code-fast-1",displayName:"Grok Code Fast 1",contextWindow:256000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0},freeTierEligible:!0},GEMINI_2_5_PRO:{provider:C9.VERTEXAI,name:"gemini-2.5-pro",displayName:"Gemini 2.5 Pro",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_2_5_FLASH:{provider:C9.VERTEXAI,name:"gemini-2.5-flash",displayName:"Gemini 2.5 Flash",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_2_5_FLASH_PREVIEW_09_2025:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-preview-09-2025",displayName:"Gemini 2.5 Flash (Preview)",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_2_5_FLASH_LITE:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-lite",displayName:"Gemini 2.5 Flash Lite",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:{provider:C9.VERTEXAI,name:"gemini-2.5-flash-lite-preview-09-2025",displayName:"Gemini 2.5 Flash Lite (Preview)",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0},freeTierEligible:!0},GEMINI_3_PRO_PREVIEW:{provider:C9.VERTEXAI,name:"gemini-3-pro-preview",displayName:"Gemini 3 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},Z_AI_GLM_4_6:{provider:C9.CEREBRAS,name:"zai-glm-4.6",displayName:"Z.ai GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},FIREWORKS_QWEN3_CODER_480B:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/qwen3-coder-480b-a35b-instruct",displayName:"Qwen3 Coder 480B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_KIMI_K2_INSTRUCT:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_QWEN3_235B:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/qwen3-235b-a22b-instruct-2507",displayName:"Qwen3 235B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_GLM_4P6:{provider:C9.FIREWORKS,name:"accounts/fireworks/models/glm-4p6",displayName:"GLM 4P6",contextWindow:162752,maxOutputTokens:40000,capabilities:{tools:!0}},KIMI_K2_INSTRUCT:{provider:C9.MOONSHOT,name:"kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:1e6,maxOutputTokens:32000,capabilities:{tools:!0}},SONOMA_SKY_ALPHA:{provider:C9.OPENROUTER,name:"sonoma-sky-alpha",displayName:"Sonoma Sky Alpha",contextWindow:256000,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_GLM_4_6:{provider:C9.OPENROUTER,name:"z-ai/glm-4.6",displayName:"OpenRouter GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},OPENROUTER_KIMI_K2_0905:{provider:C9.OPENROUTER,name:"moonshotai/kimi-k2-0905",displayName:"Kimi K2 0905 (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_CODER_480B:{provider:C9.OPENROUTER,name:"qwen/qwen3-coder",displayName:"Qwen3 Coder 480B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_235B:{provider:C9.OPENROUTER,name:"qwen/qwen3-235b-a22b-2507",displayName:"Qwen3 235B A22B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}}};eZ1={FINDER:"finder"}});function J$1(J,Q){let Y=mW(Q);if(!Y)return!1;if(PX4.has(J)){let X=Y.finder??eZ1.FINDER,G=TX4[X];if(J!==G)return!1}if(Y.includeTools)return Y.includeTools.includes(J);return!0}function uG(J,Q){let Y=J?.["internal.visibleModes"]??[];return Object.values(cE).filter((X)=>{if(Y.includes(`!${X.key}`))return!1;if(Q===!1&&F5(X.key))return!1;let Z="visible"in X?X.visible:!1,q=Y.includes(X.key),V=X.key==="plan"&&J?.["experimental.planMode"]===!0,K=J?.["experimental.dojoMode"]===!0;if(X.key==="free-dojo")return K&&(Q===!0||Q===void 0);if(X.key==="dojo")return K&&(Q===!1||Q===void 0);return Z||q||V}).map((X)=>({mode:X.key,description:"description"in X?X.description:void 0})).sort((X,G)=>X.mode.localeCompare(G.mode))}function mW(J){return Object.values(cE).find((Q)=>Q.key===J)}function wk(J){return mW(J)?.primaryModel??aJ("CLAUDE_SONNET_4_5")}function Ek(J){let Q=mW(J);if(!Q)return!1;return gG(Q.primaryModel).capabilities?.vision??!1}function F5(J){return J==="free"||J.startsWith("free-")}function Q$1(J,Q){return Q.find((Y)=>Y.mode===J)?.description}function Ik(J,Q){let X=(Q.findIndex((Z)=>Z.mode===J)+1)%Q.length;return Q[X]?.mode??"smart"}var PX4,TX4,MU0,LU0,RX4,CX4,jX4,SX4,_X4,DU0,kX4,yX4,cE,xX4;var C$=L1(()=>{gW();PX4=new Set(["finder"]),TX4={finder:"finder"},MU0={r:0,g:55,b:0},LU0={r:0,g:255,b:136},RX4={r:66,g:133,b:255},CX4={r:217,g:101,b:112},jX4=[{r:66,g:133,b:255},{r:155,g:114,b:203},{r:217,g:101,b:112}],SX4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","get_diagnostics","web_search","read_web_page","todo_read","todo_write","read_thread","skill"],_X4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","read_thread","skill","oracle","librarian","Task","kraken"],DU0=["Read","Grep","glob","finder","Bash","get_diagnostics","web_search","read_web_page","mermaid"],kX4=["Read","Grep","glob","finder","librarian","edit_plan","read_plan","web_search","read_web_page"],yX4=["Read","Grep","glob","finder","Bash","InteractiveShell","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","todo_read","todo_write","read_thread","skill","oracle","librarian","Task","kraken","edit_plan","read_plan"],cE={SMART:{key:"smart",displayName:"Smart",description:"The most capable model and set of tools",primaryModel:aJ("GEMINI_3_PRO_PREVIEW"),includeTools:yX4,visible:!0,uiHints:{labelAnimation:"glow",primaryColor:RX4,secondaryColor:CX4,gradientStops:jX4}},FREE:{key:"free",displayName:"Free",description:"Amp Free",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:SX4,visible:!0,uiHints:{primaryColor:{r:0,g:26,b:51},secondaryColor:{r:0,g:184,b:255}}},RUSH:{key:"rush",displayName:"Rush",description:"Faster and cheaper for small, well-defined tasks",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:_X4,visible:!0,uiHints:{fasterAnimation:!0,labelAnimation:"jitter",primaryColor:{r:128,g:51,b:0},secondaryColor:{r:255,g:215,b:0}}},PLAN:{key:"plan",displayName:"Plan",description:"Collaborative planning mode",primaryModel:aJ("GPT_5_1_CODEX"),includeTools:kX4,visible:!1,uiHints:{primaryColor:{r:192,g:80,b:192},secondaryColor:{r:64,g:64,b:255}}},DOJO_FREE:{key:"free-dojo",displayName:"Dojo (Free)",description:"Learning mode - guides you to discover solutions yourself",primaryModel:aJ("CLAUDE_HAIKU_4_5"),includeTools:DU0,visible:!1,uiHints:{primaryColor:{r:26,g:77,b:46},secondaryColor:{r:212,g:175,b:55}}},DOJO:{key:"dojo",displayName:"Dojo",description:"Learning mode - guides you to discover solutions yourself",primaryModel:aJ("CLAUDE_SONNET_4_5"),includeTools:DU0,visible:!1,uiHints:{primaryColor:{r:26,g:77,b:46},secondaryColor:{r:212,g:175,b:55}}}},xX4=Object.values(cE).map((J)=>J.key)});function rl(J,Q,Y){if(J.startsWith("mcp__"))return Q.allowMcp??!1;if(J.startsWith("tb__")){if(!(Q.allowToolbox??!1))return!1;let X="subagentType"in Q?Q.subagentType:void 0;if(X&&Y){if(!Y.subagentTypes)return!1;return Y.subagentTypes.includes("all")||Y.subagentTypes.includes(X)}return!0}return Q.includeTools.includes(J)}var vX4,fX4,Y$1,hX4,bX4,gX4,mX4,x2,sg8;var uW=L1(()=>{gW();vX4=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],fX4=["Grep","glob","Read"],Y$1=["Read","Grep","glob","web_search","read_web_page","read_thread"],hX4=["Grep","glob","Read","Bash","edit_file","create_file","format_file","read_web_page","get_diagnostics","web_search","finder"],bX4=["Read","glob","Grep","enqueue_file_edit","fastmod"],gX4=["create_file","edit_file","glob","Read","Grep","format_file","get_diagnostics"],mX4=["describe_workbook","execute_query"],x2={finder:{key:"finder",displayName:"Finder",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:fX4,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:aJ("GPT_5_1"),includeTools:Y$1,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:vX4,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:hX4,allowMcp:!0,allowToolbox:!0},"kraken-scope":{key:"kraken-scope",displayName:"Kraken Scope",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:bX4,allowMcp:!1,allowToolbox:!0,subagentType:"scope"},"kraken-executor":{key:"kraken-executor",displayName:"Kraken Executor",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:gX4,allowMcp:!1,allowToolbox:!0,subagentType:"executor"},bookkeeper:{key:"bookkeeper",displayName:"Bookkeeper",model:aJ("CLAUDE_HAIKU_4_5"),includeTools:mX4,allowMcp:!1,allowToolbox:!1}},sg8=Object.keys(x2)});function sl(J,Q){return new G0((Y)=>{let X=setTimeout(G,Q);function G(){Y.error(Error(`Tool execution timed out after ${Q/1000} seconds`))}function Z(){if(X)clearTimeout(X);X=setTimeout(G,Q)}let q=J.subscribe({next:(V)=>{Z(),Y.next(V)},error:(V)=>{if(X)clearTimeout(X),X=null;Y.error(V)},complete:()=>{if(X)clearTimeout(X),X=null;Y.complete()}});return()=>{if(X)clearTimeout(X),X=null;q.unsubscribe()}})}var X$1=L1(()=>{o0()});function h7(J,Q){let Y={name:Q.name,description:Q.description,inputSchema:Q.inputSchema,source:Q.source,meta:Q.meta,customizedForModel:!1},X=Q.modelCustomizations;if(X){for(let G of X)if(G.modelSelector.test(J))Y={...Y,name:G.name??Y.name,description:G.description??Y.description,inputSchema:G.inputSchema??Y.inputSchema,customizedForModel:!0}}return Y}function W2(J){return["done","error","rejected-by-user","cancelled"].includes(J.status)}function wU0(J){return["done","error","cancelled"].includes(J.status)}function G$1(J){return typeof J==="object"&&"key"in J}function tl(J){let Q=[],Y=new y4,X;function G(q,V){let K=Q.filter((W)=>W.spec.name===q);if(K.length===0&&q==="Glob")K=Q.filter((W)=>W.spec.name==="glob");for(let W of K)if(iE(W.spec,V).enabled)return W;return}function Z(q,V,K){if(!q)throw Error("spec is required");let W=Q.findIndex((L)=>L.spec.name===q.name),H=W!==-1?Q[W]:void 0;if(q.source!=="builtin"&&H?.spec.source==="builtin")return f.warn("Ignoring external tool registration - builtin takes precedence",{toolName:q.name,externalSource:q.source}),{dispose:()=>{}};let N={spec:q,fn:Promise.resolve(V),preprocessArgs:K};if(H&&JSON.stringify(H.spec.source)===JSON.stringify(q.source))f.debug("Replacing existing tool registration (idempotent)",{toolName:q.name,source:q.source}),Q[W]=N;else Q.push(N);return Y.next(),{dispose:()=>{let L=Q.indexOf(N);if(L!==-1)Q.splice(L,1),Y.next()}}}return J.configService.config.subscribe((q)=>{X=q}),{registerTool({spec:q,fn:V,preprocessArgs:K}){if(!V)return uX4;return Z(q,V,K)},tools:u8(J.configService.config,Y.pipe(k9(void 0))).pipe(q6(([q])=>{return Q.map((V)=>({spec:V.spec,...iE(V.spec,q)})).sort((V,K)=>V.spec.name.localeCompare(K.spec.name))})),invokeTool(q,V,K){let W=performance.now(),H=()=>pX4.record(performance.now()-W,{toolName:q});if(q===$$1&&V.args&&"invalid_tool_name"in V.args&&typeof V.args.invalid_tool_name==="string"){lE.add(1,{toolName:q,error:"invalid"});let N=Z$1(V.args.invalid_tool_name);return new G0((M)=>{M.error(Error(N))})}let z=G(q,K.config);if(!z){let N=Q.filter((E)=>E.spec.name===q);if(N.length===0)return lE.add(1,{toolName:q,error:"not_found"}),new G0((E)=>{E.error(Error(`tool ${JSON.stringify(q)} not found`))});let M=N[0],L=iE(M.spec,K.config);lE.add(1,{toolName:q,error:"disabled"});let A=L.enabled?"unknown":L.disabledReason;return new G0((E)=>{E.error(Error(`tool ${JSON.stringify(q)} is disabled: ${A}`))})}let U=K.subagentSpec??K.agentMode;if(U&&!this.isToolAllowed(q,U)){lE.add(1,{toolName:q,error:"disabled"});let N=G$1(U)?U.displayName??U.key:`${U} mode`;return new G0((M)=>{M.error(Error(`tool ${JSON.stringify(q)} is not allowed for ${N}`))})}if(K.thread.mainThreadID&&!K.subagentSpec&&!rl(q,x2["task-subagent"]))return lE.add(1,{toolName:q,error:"disabled"}),new G0((N)=>{N.error(Error(`tool ${JSON.stringify(q)} is not allowed for subagents`))});return lE.add(1,{toolName:q}),e6(()=>z.fn).pipe(r4((N)=>{let M=N(V,K);if(z.spec.meta?.disableTimeout)return M;return sl(M,NU0(K.config))}),wQ(()=>H()))},preprocessArgs(q,V,K){let W=G(q,K.config);if(!W||!W.preprocessArgs)return;let H=W.preprocessArgs;try{return H(V,K)}catch(z){f.error("preprocessArgs",{id:q,args:V,error:String(z)});return}},isToolAllowed(q,V){let K=Q.find((H)=>H.spec.name===q),W=K?.spec.source;if(typeof W==="object"&&(("mcp"in W)||("toolbox"in W)))return!0;if(G$1(V))return rl(q,V,K?.spec.meta);return J$1(q,V)},getTools(q){return u8(J.configService.config,Y.pipe(k9(void 0))).pipe(q6(([V])=>{return Q.filter((K)=>{let W=K.spec.source;if(typeof W==="object"&&(("mcp"in W)||("toolbox"in W)))return!0;if(G$1(q))return rl(K.spec.name,q,K.spec.meta);return J$1(K.spec.name,q)}).map((K)=>({spec:K.spec,...iE(K.spec,V)})).sort((K,W)=>K.spec.name.localeCompare(W.spec.name))}))},getToolsForMode(q,V){if(V)return this.getTools(x2["task-subagent"]);return this.getTools(q)},getExecutionProfile(q){if(!X)return;return G(q,X)?.spec.executionProfile},dispose(){}}}function Pk(J,Q){for(let Y of Q){if(Y==="")continue;if(Y.length===1){if(Y==="*")return!0;if(Y===J)return!0;continue}if(J===Y)return!0;if(Y.includes("*")||Y.includes("?")||Y.includes("[")||Y.includes("{"))try{if(OU0.default(Y,{dot:!0})(J))return!0}catch(X){continue}}return!1}function iE(J,Q){let Y=Q.settings?.["tools.disable"]??[];if(Pk(J.name,Y))return{enabled:!1,disabledReason:"settings"};if(typeof J.source==="object"&&"mcp"in J.source){let X=dX4(J.name);if(X){if(J.source.mcp.replace(/[\s-]+/g,"_")===X.server){if(Pk(X.tool,Y))return{enabled:!1,disabledReason:"settings"};let Z=`mcp__${J.source.mcp}__${X.tool}`;if(Pk(Z,Y))return{enabled:!1,disabledReason:"settings"}}}}if(J.source==="builtin"&&Pk(`builtin:${J.name}`,Y))return{enabled:!1,disabledReason:"settings"};if(typeof J.source==="object"&&"toolbox"in J.source&&Pk(`toolbox:${J.name}`,Y))return{enabled:!1,disabledReason:"settings"};if(J.name===Z7||J.name===PV){if(Q.settings?.["todos.enabled"])return{enabled:!0};return{enabled:!1,disabledReason:"feature-flag"}}return{enabled:!0}}function Z$1(J){return`Invalid tool name ${JSON.stringify(J)}. Tool names must match the pattern ${Tk.toString()}. Try again with a valid tool name.`}function dX4(J){let[,Q,Y]=J.split(/mcp__([^ ]+)__([^ ]+)/);if(Q&&Y)return{server:Q,tool:Y};return}function q$1(J){if(J.status==="in-progress"||J.status==="done"||J.status==="cancelled"||J.status==="error")return J.progress;return}var AU0,OU0,uX4,$$1="invalid_tool",Tk,EU0,lE,pX4;var b7=L1(()=>{o0();L0();ol();C$();uW();X$1();A4();AU0=N6(b6(),1),OU0=N6(HM(),1);uX4={dispose(){}};Tk=/^[-a-zA-Z0-9_]{1,64}$/,EU0=AU0.metrics.getMeter("tool_service"),lE=EU0.createCounter("tool_service.invocation_count",{description:"Number of tool invocations"}),pX4=EU0.createHistogram("tool_service.invocation_latency",{description:"Latency of tool invocations",unit:"ms"})});var jU0=v((RU0)=>{Object.defineProperty(RU0,"__esModule",{value:!0});RU0.calcSlices=RU0.applyPatch=RU0.calcPatch=RU0.lcs=RU0.diff=RU0.diff_core=void 0;function cX4(J,Q){let{b:Y,eq:X,stack_base:G}=J,{i:Z,N:q,j:V,M:K,Z:W,stack_top:H}=J;for(;;)switch(Q){case 0:{J:while(q>0&&K>0){Y.fill(0,0,2*W);let z=q-K,U=q+K,N=U&1,M=Z+q-1,L=V+K-1,A=(U+N)/2,E;Q:for(let P=0;P<=A;P++){let I=2*Math.max(0,P-K)-P,R=P-2*Math.max(0,P-q);for(let S=I;S<=R;S+=2){let y=Y[S-1-W*Math.floor((S-1)/W)],h=Y[S+1-W*Math.floor((S+1)/W)],u=S===-P||S!==P&&y<h?h:y+1,p=u-S,g=u,i=p;while(g<q&&i<K&&X(Z+g,V+i))g++,i++;if(Y[S-W*Math.floor(S/W)]=g,N===1&&(E=z-S)>=1-P&&E<P&&g+Y[W+E-W*Math.floor(E/W)]>=q)if(P>1||g!==u){G[H++]=Z+g,G[H++]=q-g,G[H++]=V+i,G[H++]=K-i,q=u,K=p,W=2*(Math.min(q,K)+1);continue J}else break Q}for(let S=I;S<=R;S+=2){let y=Y[W+S-1-W*Math.floor((S-1)/W)],h=Y[W+S+1-W*Math.floor((S+1)/W)],u=S===-P||S!==P&&y<h?h:y+1,p=u-S,g=u,i=p;while(g<q&&i<K&&X(M-g,L-i))g++,i++;if(Y[W+S-W*Math.floor(S/W)]=g,N===0&&(E=z-S)>=-P&&E<=P&&g+Y[E-W*Math.floor(E/W)]>=q)if(P>0||g!==u){G[H++]=Z+q-u,G[H++]=u,G[H++]=V+K-p,G[H++]=p,q=q-g,K=K-i,W=2*(Math.min(q,K)+1);continue J}else break Q}}if(q===K)continue;if(K>q)Z+=q,V+=q,K-=q,q=0;else Z+=K,V+=K,q-=K,K=0;break}if(q+K!==0)if(J.pxe===Z||J.pye===V)J.pxe=Z+q,J.pye=V+K;else{let z=J.pxs;if(J.oxs=J.pxs,J.oxe=J.pxe,J.oys=J.pys,J.oye=J.pye,J.pxs=Z,J.pxe=Z+q,J.pys=V,J.pye=V+K,z>=0)return J.i=Z,J.N=q,J.j=V,J.M=K,J.Z=W,J.stack_top=H,1}}case 1:{if(H===0)return 2;K=G[--H],V=G[--H],q=G[--H],Z=G[--H],W=2*(Math.min(q,K)+1),Q=0}}}class IU0{constructor(J){this.state=J,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){let{state:J,result:Q}=this;if(this.c>1)return Q.done=!0,Q.value=void 0,Q;let Y=cX4(J,this.c);if(this.c=Y,Y===1)return Q.value=[J.oxs,J.oxe,J.oys,J.oye],Q;if(J.pxs>=0)return Q.value=[J.pxs,J.pxe,J.pys,J.pye],Q;return Q.done=!0,Q.value=void 0,Q}}function PU0(J,Q,Y,X,G){let Z=(Math.min(Q,X)+1)*2,q=Q+X,V=new(q<256?Uint8Array:q<65536?Uint16Array:Uint32Array)(2*Z);return new IU0({i:J,N:Q,j:Y,M:X,Z,b:V,eq:G,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}RU0.diff_core=PU0;function el(J,Q,Y){let[X,G,Z]=[0,J.length,Q.length];if(typeof Y==="function"){while(X<G&&X<Z&&Y(X,X))X++;if(X===G&&X===Z)return[][Symbol.iterator]();while(Y(--G,--Z)&&G>X&&Z>X);}else{while(X<G&&X<Z&&J[X]===Q[X])X++;if(X===G&&X===Z)return[][Symbol.iterator]();while(J[--G]===Q[--Z]&&G>X&&Z>X);Y=(q,V)=>J[q]===Q[V]}return PU0(X,G+1-X,X,Z+1-X,Y)}RU0.diff=el;class TU0{constructor(J,Q){this.diff=J,this.N=Q,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){let J=this.diff.next();if(J.done){let{i:V,j:K,N:W}=this;if(V<W)J.done=!1,J.value=[V,K,W-V],this.i=W;return J}let Q=J.value,Y=Q[0],X=Q[1],G=Q[3],{i:Z,j:q}=this;if(Z!==Y)Q.length--,Q[0]=Z,Q[1]=q,Q[2]=Y-Z;return this.i=X,this.j=G,J}}function lX4(J,Q,Y){return new TU0(el(J,Q,Y),J.length)}RU0.lcs=lX4;function*iX4(J,Q,Y){let X=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let G of el(J,Q,Y))G[2]=X.call(Q,G[2],G[3]),yield G}RU0.calcPatch=iX4;function*nX4(J,Q){let Y=0,X=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let[G,Z,q]of Q){if(Y<G)yield X.call(J,Y,G);if(q.length>0)yield q;Y=Z}if(Y<J.length)yield X.call(J,Y)}RU0.applyPatch=nX4;function*aX4(J,Q,Y){let X=0,G=ArrayBuffer.isView(J)?Uint8Array.prototype.subarray:J.slice;for(let[Z,q,V,K]of el(J,Q,Y)){if(X<Z)yield[0,G.call(J,X,Z)];if(Z<q)yield[-1,G.call(J,Z,q)];if(V<K)yield[1,G.call(Q,V,K)];X=q}if(X<J.length)yield[0,J.slice(X)]}RU0.calcSlices=aX4});function nE(J,Q){let Y={added:0,deleted:0,changed:0};if(typeof J!=="string"||typeof Q!=="string")return Y;if(J===Q)return Y;try{let X={added:0,deleted:0,changed:0};for(let[G,Z,q,V]of SU0.diff(J.split(`
49
49
  `),Q.split(`
50
50
  `)))X.deleted+=Z-G,X.added+=V-q,X.changed+=Math.min(Z-G,V-q);return X}catch{return Y}}function _U0(J){if(typeof J!=="string")return{added:0,deleted:0,changed:0};return{added:J.split(`
51
51
  `).length,deleted:0,changed:0}}function V$1(J){if(!J)return{totalFiles:0,createdFiles:0,totalAdded:0,totalRemoved:0,totalModified:0,revertedFiles:0,allReverted:!1};let Q=J.files.length,Y=J.files.filter((K)=>K.created).length,X=J.files.filter((K)=>K.reverted).length,G=X===Q&&Q>0,Z=0,q=0,V=0;for(let K of J.files){if(K.reverted)continue;Z+=K.diffStat.added,q+=K.diffStat.removed,V+=K.diffStat.modified}return{totalFiles:Q,createdFiles:Y,totalAdded:Z,totalRemoved:q,totalModified:V,revertedFiles:X,allReverted:G}}var SU0;var Rk=L1(()=>{SU0=N6(jU0(),1)});function j$(){return`T-${crypto.randomUUID()}`}function S$(J){if(!J.startsWith("T-"))return!1;let Q=J.slice(2);return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(Q)}function zM(){return`toolu_${crypto.randomUUID()}`}function aE(J,Q,Y=zM()){return{type:"tool_use",complete:!0,id:Y,name:J,input:Q}}function v2(J){if("complete"in J)return J.complete;return!("inputPartialJSON"in J)}function kU0(J){for(let Q=J.messages.length-1;Q>=0;Q--){let Y=J.messages[Q];if(Y?.role==="info"){let X=Y.content[0];if(X?.type==="summary"&&X?.summary.type==="message")return}if(Y?.role==="assistant"&&Y.usage){if(Y.usage.totalInputTokens===0)continue;return Y.usage}}return J["~debug"]?.lastInferenceUsage}function NX(J,Q){for(let Y of J.messages){if(Y.role!=="assistant")continue;for(let X of Y.content)if(X.type==="tool_use"&&X.id===Q)return X}return}function oE(J,Q){for(let[Y,X]of J.messages.entries()){if(X.role!=="assistant")continue;for(let[G,Z]of X.content.entries())if(Z.type==="tool_use"&&Z.id===Q)return{message:X,messageIndex:Y,block:Z,blockIndex:G}}return null}function lF(J,Q){for(let Y of J.messages){if(Y.role!=="user")continue;for(let X of Y.content)if(X.type==="tool_result"&&X.toolUseID===Q)return X}return}function oJ(J){return J.messages.filter((Q)=>Q.role==="user").flatMap((Q)=>Q.content).filter((Q)=>Q.type==="tool_result").reduce((Q,Y)=>{return Q.set(Y.toolUseID,Y),Q},new Map)}function K$1(J){if(J&&typeof J==="object"&&"threadID"in J){let Q=J.threadID;if(typeof Q==="string"&&S$(Q))return Q}return}function W$1(J){let Q=[],Y=new Map;for(let X of J)if(X.role==="assistant"){for(let G of X.content)if(G.type==="tool_use"&&G.name===XJ)Y.set(G.id,G)}else if(X.role==="user"){for(let G of X.content)if(G.type==="tool_result"){let Z=Y.get(G.toolUseID);if(Z){let q=G.run,V=(q.status==="in-progress"||q.status==="cancelled"||q.status==="done"||q.status==="error")&&q.progress?K$1(q.progress):void 0;if(V)Q.push({toolUseID:G.toolUseID,threadID:V,toolUse:Z,toolResult:G})}}}return Q}function yU0(J,Q="Untitled"){if(J.title)return yl(J.title,300);return Q}function xU0(J){if(!J)return!1;if(J.role==="assistant")return J.state?.type==="cancelled";if(J.role==="user")return J.content.some((Q)=>Q.type==="tool_result"&&Q.run.status==="cancelled");return!1}function vU0(J){if(!J)return!1;if(J.role==="user")return J.content.some((Q)=>Q.type==="tool_result"&&Q.run.status==="rejected-by-user");return!1}function H$1(J){if(!J)return!1;return J.role==="info"}function rE(J){return J.role==="info"&&J.content.some((Q)=>Q.type==="manual_bash_invocation")}function Ji(J){if(J.role!=="info")return;return J.content.find((Q)=>Q.type==="manual_bash_invocation")}function JG4(J){return J.replace(/u([0-9A-Fa-f]{4})(\s)/gi,(Q,Y,X)=>{try{return String.fromCodePoint(parseInt(Y,16))+X}catch{return`u${Y}${X}`}})}function sE(J){for(let Q=J.messages.length-1;Q>=0;Q--){let Y=J.messages[Q];if(Y?.role==="info"){if(Y.content.some((G)=>G.type==="summary"&&G.summary.type==="message"))break}if(Y?.role!=="assistant"||!Y.state||Y.state.type!=="complete"||Y.state.stopReason!=="tool_use")continue;for(let X of Y.content)if(X.type==="tool_use"&&X.name===Z7&&X.input){let G=X.input.todos;if(Array.isArray(G))return G;let Z=X.input.content;if(typeof Z==="string")return JG4(Z)}}return}function f2(J){return J.map((Q)=>Q.type==="text"?Q.text:null).filter((Q)=>Q!==null).join(`
@@ -3222,8 +3222,7 @@ Use the create_handoff_context tool to extract relevant information and files.`;
3222
3222
  - Prioritize by importance, up to 12 items
3223
3223
  - Return workspace-relative paths (e.g., "core/src/threads/thread.ts")
3224
3224
  - Do not use absolute paths or invent files
3225
- `}},required:["relevantInformation","relevantFiles"]},source:"builtin",customizedForModel:!1};$Z();NH();H2();function Hn4(J){return typeof J==="object"&&J!==null&&"credits"in J}function yc0(J){if(!Hn4(J))return 0;let Q=J.credits,Y=typeof Q==="string"?Number(Q):Q;return typeof Y==="number"&&Number.isFinite(Y)?Y:0}CV();N9();async function xc0(J,Q,Y,X){let G=f2(J.content);if(!G)return{title:void 0,usage:void 0};let Z=await wP({configService:Y},X),q=crypto.randomUUID(),V=await Z.messages.create({model:Xr,max_tokens:60,temperature:0.7,system:`You are an assistant that generates short, descriptive titles (maximum 7 words, "Sentence case" with the first word capitalized not "Title Case") based on user's message to an agentic coding tool. Your titles should be concise (max 7 words) and capture the essence of the query or topic. DO NOT ASSUME OR GUESS the user's intent beyond what is in their message. Omit generic words like "question", "request", etc. Be professional and precise. Use common software engineering terms and acronyms if they are helpful. Use the set_title tool to provide your answer.`,messages:[{role:"user",content:`<message>${G}</message>`}],tools:[{name:"set_title",input_schema:{type:"object",properties:{title:{type:"string",description:'The short thread title (maximum 7 words, "Sentence case" with the first word capitalized not "Title Case") that you generated for the message'}},required:["title"]}}],tool_choice:{type:"tool",name:"set_title",disable_parallel_tool_use:!0}},{stream:!1,signal:X,headers:{...MY(Q),[DY]:q}}),K=`anthropic/${Xr.replace(/^[^/]+\//,"")}`,W=gG(K),H={model:Xr,maxInputTokens:W.contextWindow-W.maxOutputTokens,inputTokens:V.usage.input_tokens,outputTokens:V.usage.output_tokens,cacheCreationInputTokens:V.usage.cache_creation_input_tokens,cacheReadInputTokens:V.usage.cache_read_input_tokens,totalInputTokens:V.usage.input_tokens+(V.usage.cache_creation_input_tokens??0)+(V.usage.cache_read_input_tokens??0),credits:yc0(V.usage)},z=await CQ(q,Y);H.credits=z??0;let U=V.content.at(0);if(!U)throw Error("no content in generateThreadTitle response");if(U.type!=="tool_use"||U.name!=="set_title")throw Error("missing or invalid tool_use in generateThreadTitle response");return{title:U.input&&typeof U.input==="object"&&"title"in U.input&&typeof U.input.title==="string"?U.input.title:void 0,usage:H}}function vc0(J){let Q=/^Forked(?:\((\d+)\))?: (.+)$/,Y=J.match(Q);if(!Y)return`Forked: ${J||"Untitled"}`;let X=Y[1]?Number.parseInt(Y[1],10):1,G=Y[2];return`Forked(${X+1}): ${G}`}_l();class AE1{storage;configService;exclusiveThreads=new i_;get exclusiveThreadsChanges(){return this.exclusiveThreads.observable}dirtyThreads=new Set;flushRequests=new y4;flusher=this.flushRequests.pipe(k9(void 0),w$(100),r4(()=>{let J=Array.from(this.dirtyThreads);if(this.dirtyThreads=new Set,J.length===0)return n_;let Q=J.slice(0,3).map(async(Y)=>{try{await this.flushThread(Y)}catch(X){f.error("Error flushing thread to storage:",X,{name:"ThreadService",threadID:Y}),this.dirtyThreads.add(Y)}});if(J.length>3){for(let Y of J.slice(3))this.dirtyThreads.add(Y);setTimeout(()=>this.flushRequests.next(),100)}return e6(async()=>{await Promise.all(Q)})})).subscribe({});constructor(J,Q){this.storage=J;this.configService=Q}async flushThread(J){let Q=this.exclusiveThreads.get(J);if(!Q)return;let[Y]=Q.getValue();await this.storage.set(J,Y)}observeRaw(J){return this.exclusiveThreads.observable.pipe(q6((Q)=>Q.get(J)),x4(),r4((Q)=>{if(Q!==void 0)return Q;return new G0((Y)=>{this.storage.get(J).then((X)=>{if(X)Y.next([UX(X,!0),[]])})})}))}async getUnfrozen(J,Q){let Y=this.exclusiveThreads.get(J);if(Y)return Y.getValue()[0];let X=await this.storage.get(J);if(Q?.throwIfAborted(),!X)return null;return X}async get(J,Q){let Y=await this.getUnfrozen(J,Q);if(!Y)return null;return UX(Y,!0)}async getPrimitiveProperty(J,Q){let Y=await this.getUnfrozen(J);if(!Y)return null;return Y[Q]}observe(J){return this.observeRaw(J).pipe(q6(([Q,Y])=>Q),a_(100,{leading:!0,trailing:!0}))}observePatches(J){return this.observeRaw(J).pipe(q6(([Q,Y],X)=>X===0?Q:Y),Fn4(100))}async exclusiveSyncReadWriter(J){if(this.exclusiveThreads.has(J))throw Error(`Thread ${J} already has an exclusive read-writer`);let Q=this.exclusiveThreads.get(J);if(!Q){let X=await this.storage.get(J);if(!X)X=zn4(J),await this.storage.set(J,X);X=UX(X,!0),Q=new g5([X,[]]),this.exclusiveThreads.set(J,Q),await NR0()}let Y=!1;return{read:()=>{if(Y)throw Error("thread exclusive read-writer was disposed");return Q.getValue()[0]},write:(X)=>{if(Y)throw Error("thread exclusive read-writer was disposed");let[G,Z]=KM(Q.getValue()[0],()=>{return X});Q.next([G,Z]),this.dirtyThreads.add(J),this.flushRequests.next()},update:(X)=>{if(Y)throw Error("thread exclusive read-writer was disposed");let[G,Z]=KM(Q.getValue()[0],X);return Q.next([G,Z]),this.dirtyThreads.add(J),this.flushRequests.next(),G},asyncDispose:async()=>{if(Y)return;Y=!0;let[X]=Q.getValue();try{await this.storage.set(J,X)}catch(G){f.error("Error flushing thread on dispose:",G,{name:"ThreadService",threadID:J})}this.dirtyThreads.delete(J),this.exclusiveThreads.delete(J)}}}flush(){this.flushRequests.next()}async flushVersion(J,Q,Y=5000){this.dirtyThreads.add(J),await this.flushThread(J);let X=Date.now();while(!0){if(Date.now()-X>Y)throw Error(`Timed out waiting for thread ${J} to reach version ${Q}`);let G=await this.storage.get(J);if(G&&G.v>=Q)return;await new Promise((Z)=>setTimeout(Z,10))}}async forkThread(J,Q){let Y=await this.get(J);if(!Y)throw Error(`Thread ${J} not found`);let X=Y.messages.slice(0,Q+1);return{threadID:await this.createForkedThread(J,X,Q)}}async createForkedThread(J,Q,Y){let X=await this.get(J);if(!X)throw Error(`Thread ${J} not found`);let G=j$(),Z=Date.now(),q=await this.exclusiveSyncReadWriter(G),V=vc0(X.title||"Untitled"),K=q.update((z)=>{if(z.originThreadID=J,z.forkPointIndex=Y,z.v++,z.title=V,z.relationships=[{threadID:J,type:"fork",role:"child",messageIndex:Y,createdAt:Z}],X.env)z.env=$9(X.env);for(let U of Q)z.messages.push($9(U))});await q.asyncDispose();let W=this.exclusiveThreads.get(J);if(W){let[z]=W.getValue(),[U,N]=KM(z,(M)=>{if(M.v++,M.forkThreads??={},M.forkThreads[Y]??=[],!M.forkThreads[Y].includes(G))M.forkThreads[Y].push(G);if(M.relationships??=[],!M.relationships.some((A)=>A.threadID===G&&A.type==="fork"&&A.role==="parent"&&A.messageIndex===Y))M.relationships.push({threadID:G,type:"fork",role:"parent",messageIndex:Y,createdAt:Z})});W.next([U,N]),this.dirtyThreads.add(J),this.flushRequests.next()}else{let z=await this.exclusiveSyncReadWriter(J);z.update((U)=>{if(U.v++,U.forkThreads??={},U.forkThreads[Y]??=[],!U.forkThreads[Y].includes(G))U.forkThreads[Y].push(G);if(U.relationships??=[],!U.relationships.some((M)=>M.threadID===G&&M.type==="fork"&&M.role==="child"&&M.messageIndex===Y))U.relationships.push({threadID:G,type:"fork",role:"child",messageIndex:Y,createdAt:Z})}),await z.asyncDispose()}let H=K.v;return await this.flushVersion(G,H),G}async generateHandoffPrompt(J,Q,Y,X,G){let Z=await this.get(J);if(!Z)throw Error(`Thread ${J} not found`);return LE1(Z,Q,Y,X,G)}async createHandoffThread(J,Q,Y,X){let{goal:G,generatedPrompt:Z,images:q,messageIndex:V}=Q;if(!G&&!Z)throw Error("Either goal or generatedPrompt must be provided");let K=await this.get(J);if(!K)throw Error(`Thread ${J} not found`);let H=Z!==void 0?Z:await LE1(K,G,q,Y,X),z=60,U=G??(typeof H==="string"?H.split(`
3226
- `)[0]||"Handoff from parent thread":"Handoff from parent thread"),N=U.length>z?`${U.slice(0,z-3)}...`:U,M=j$(),L=V??(K.messages.length?K.messages.length-1:void 0),A=Date.now(),E=await this.exclusiveSyncReadWriter(M);E.update((I)=>{if(I.v++,I.title=N||`Handoff: ${K.title||"Untitled"}`,K.env)I.env=$9(K.env);if(K.agentMode)I.agentMode=K.agentMode==="plan"?"smart":K.agentMode;I.draft=$9(H),I.relationships=[{threadID:J,type:"handoff",role:"child",messageIndex:L,createdAt:A,comment:G??U}]}),await E.asyncDispose();let P=this.exclusiveThreads.get(J);if(P){let[I]=P.getValue(),[R,S]=KM(I,(y)=>{if(y.v++,y.relationships??=[],!y.relationships.some((u)=>u.threadID===M&&u.type==="handoff"&&u.role==="parent"&&u.messageIndex===L))y.relationships.push({threadID:M,type:"handoff",role:"parent",messageIndex:L,createdAt:A,comment:G??U})});P.next([R,S]),this.dirtyThreads.add(J),await this.flushThread(J)}else{let I=await this.exclusiveSyncReadWriter(J);I.update((R)=>{if(R.v++,R.relationships??=[],!R.relationships.some((y)=>y.threadID===M&&y.type==="handoff"&&y.role==="parent"&&y.messageIndex===L))R.relationships.push({threadID:M,type:"handoff",role:"parent",messageIndex:L,createdAt:A,comment:G??U})}),await I.asyncDispose()}return M}async delete(J){let Q=await this.storage.keys(),Y=[];for(let X of Q){let G=await this.storage.get(X);if(G&&G.mainThreadID===J)Y.push(G.id)}for(let X of Y)try{await this.storage.delete(X)}catch(G){if(!rJ(G))throw G}try{await this.storage.delete(J)}catch(X){if(!rJ(X))throw X}this.exclusiveThreads.delete(J),this.dirtyThreads.delete(J);try{let X=await E5.deleteThread({thread:J},{config:this.configService});if(!X.ok&&X.error.code!=="thread-not-found")throw Error(`Error deleting thread from server: ${X.error.message??X.error.code}`)}catch(X){if(X instanceof Error&&X.message.includes("404"))return;throw X}}getRecentlyActiveThread(){let J=null,Q=0;for(let[,Y]of this.exclusiveThreads.entries()){let[X]=Y.getValue();if(z11(X)>Q)J=X,Q=z11(X)}return J}async discardHandoffThread(J){let Q=await this.get(J);if(!Q?.relationships)return null;if(Q.messages.length>0)return null;let Y=Q.relationships.find((G)=>G.type==="handoff"&&G.role==="child");if(!Y)return null;let X=this.exclusiveThreads.get(Y.threadID);if(X){let[G]=X.getValue(),[Z,q]=KM(G,(V)=>{V.v++,V.relationships=V.relationships?.filter((K)=>!(K.threadID===J&&K.type==="handoff"&&K.role==="parent"))});X.next([Z,q]),this.dirtyThreads.add(Y.threadID),await this.flushThread(Y.threadID)}else{let G=await this.exclusiveSyncReadWriter(Y.threadID);G.update((Z)=>{Z.v++,Z.relationships=Z.relationships?.filter((q)=>!(q.threadID===J&&q.type==="handoff"&&q.role==="parent"))}),await G.asyncDispose(),await this.flushThread(Y.threadID)}return await this.delete(J),Y.threadID}async createPlanExecutionThread(J,Q="smart"){let Y=await this.get(J);if(!Y)throw Error(`Thread ${J} not found`);Rc0(Y);let X=xU(Y),G=Cc0(X),Z=jc0(X,Y),q=j$(),V=Date.now(),K=await this.exclusiveSyncReadWriter(q),W=K.update((U)=>{if(U.v++,U.title=G?`Execute: ${G}`:"Execute Plan",U.agentMode=Q,Y.env)U.env=$9(Y.env);U.artifacts={plan:{type:"plan",content:X,created:Y.artifacts?.plan?.created??V,updated:V}},U.relationships=[{threadID:J,type:"handoff",role:"child",createdAt:V,comment:"Execution thread for plan"}],U.draft=Z});await K.asyncDispose();let H=W.v;await this.flushVersion(q,H);let z=this.exclusiveThreads.get(J);if(z){let[U]=z.getValue(),[N,M]=KM(U,(L)=>{if(L.v++,L.relationships??=[],!L.relationships.some((E)=>E.threadID===q&&E.type==="handoff"&&E.role==="parent"))L.relationships.push({threadID:q,type:"handoff",role:"parent",createdAt:V,comment:"Execution thread created from plan"})});z.next([N,M]),this.dirtyThreads.add(J),this.flushRequests.next()}else{let U=await this.exclusiveSyncReadWriter(J);U.update((N)=>{if(N.v++,N.relationships??=[],!N.relationships.some((L)=>L.threadID===q&&L.type==="handoff"&&L.role==="parent"))N.relationships.push({threadID:q,type:"handoff",role:"parent",createdAt:V,comment:"Execution thread created from plan"})}),await U.asyncDispose()}return q}async asyncDispose(){this.flusher.unsubscribe(),await Promise.all(Array.from(this.dirtyThreads).map((J)=>this.flushThread(J))),this.exclusiveThreads.dispose()}}function zn4(J){return{v:0,id:J,created:Date.now(),messages:[]}}function Fn4(J){return(Q)=>new G0((Y)=>{let X=[],G=null,Z=()=>{if(G)clearTimeout(G),G=null;if(X.length>0)Y.next(X),X=[]};return Q.subscribe({next:(q)=>{if(!(q instanceof Array)){Z(),Y.next(q);return}X.push(...q),G=setTimeout(Z,J)},error:(q)=>{Z(),Y.error(q)},complete:()=>{Z(),Y.complete()}})})}o0();L0();vF();ZZ();u$();function fc0({threadService:J,threadHistoryService:Q,configService:Y,isExtensionDevelopment:X=!1,retryIntervalMs:G=30000}){let Z=!1,q=[],V=new $Z1,K=new g5(new Map),W=async()=>{if(Z)return!1;if(!await M6(xT0(Y)))return!1;let I=await Y.getLatest(new AbortController().signal);if(X&&xF(I.settings.url)&&process.env.FORCE_ENABLE_SYNC!=="1")return f.debug(`Skipping sync to ${zY} in extension development mode to avoid polluting the production server`,{name:"ThreadSyncService"}),!1;return!0},H=async(I)=>{if(!M(I))return;let R=await J.get(I);if(!R){V.delete(I);return}if(R.messages.length===0)return;if(!await W())return;let S=new AbortController,y={dispose:()=>S.abort()};q.push(y);try{try{let h=await E5.uploadThread({thread:R,createdOnServer:!1},{signal:S.signal,config:Y});if(!h.ok)throw Error(`Failed to upload thread: ${h.error.code}`)}catch(h){throw f.warn(`Failed to upload thread ${I}`,{name:"ThreadSyncService",threadID:I,error:h}),h}}finally{let h=q.indexOf(y);if(h!==-1)q.splice(h,1);if(S.abort(),q.length>30)f.debug("[AbortController] High disposables count detected: ",q.length,{name:"ThreadSyncService",operation:"uploadThread"})}},z=new Map,U=new Set,N=60000,M=(I)=>{if(U.has(I))return!1;let R=z.get(I);if(!R)return!0;let S=Date.now()-R,y=S>=N;if(!y)f.debug(`Skipping thread ${I} sync due to backoff (${Math.round(S/1000)}s elapsed of ${N/1000}s backoff)`,{name:"ThreadSyncService"});return y},L=async()=>{for(let I of V){if(!M(I))continue;try{await H(I),V.delete(I),z.delete(I)}catch(R){let S=R instanceof Error?R.message:String(R);if(S.includes("404")&&S.includes("Thread not found"))U.add(I),V.delete(I),z.delete(I),f.warn(`Thread ${I} not found on server, stopping sync attempts`,{name:"ThreadSyncService"});else z.set(I,Date.now()),f.warn(`Failed to sync thread ${I}, will retry after backoff`,{name:"ThreadSyncService",error:R})}}},A=async(I,R=!1)=>{if(!await W())return;let S;if(I)S=(await Promise.all(I.map(async(g)=>{let i=await J.get(g);return i?{id:i.id,v:i.v}:{id:g,v:-1}}))).filter((g)=>g!==null);else{let g=await M6(Q.observeHistory().pipe(q6((Y1)=>Y1.map((a)=>({id:a.id,v:a.v}))))),i=await M6(J.exclusiveThreadsChanges.pipe(q6((Y1)=>Array.from(Y1.values()).map((a)=>{let[b,s]=a.getValue();return{id:b.id,v:b.v}}))));S=g.concat(i)}let y={threadVersions:[],threadMetas:[]},h=new Set;for(let g of S){if(h.has(g.id))continue;if(h.add(g.id),U.has(g.id))continue;if(!R)y.threadVersions.push({id:g.id,v:g.v});let i=K.getValue().get(g.id);y.threadMetas.push({id:g.id,meta:i?.status==="synced"&&i.info?i.info?.meta.visibility==="private"?{visibility:"private",sharedGroupIDs:i.info.meta.sharedGroupIDs}:{visibility:i.info.meta.visibility}:void 0})}if(y.threadVersions.length===0&&y.threadMetas.length===0)return;if(!await W())return;let u=new AbortController,p={dispose:()=>u.abort()};q.push(p);try{f.debug("Sending threads sync request",{name:"ThreadSyncService",source:R?"metadata":"full",threadCount:y.threadVersions.length+y.threadMetas.length});let g=await RQ("/api/threads/sync",{method:"POST",body:JSON.stringify(y),signal:u.signal},Y);if(!g.ok){let a=await g.text().catch(()=>"Unable to read response body");throw f.warn("Threads sync request failed",{name:"ThreadSyncService",status:g.status,text:a}),Error(`Threads sync API responded with status: ${g.status}${a?`: ${a}`:""}`)}f.debug("Got response for threads sync request",{name:"ThreadSyncService",status:g.status});let i=await g.json(),Y1=0;for(let a of i.threadActions){if(!(("action"in a)&&typeof a.action==="string"))continue;switch(a.action){case"upload":{if(!U.has(a.id))V.add(a.id),Y1++;break}case"meta":{K.getValue().set(a.id,{status:"synced",info:{meta:a.meta}});break}case"download":{f.debug(`Processing download action for thread ${a.id}`,{name:"ThreadSyncService",threadID:a.id,hasThread:!!a.thread,threadV:a.thread?.v,hasEnv:!!a.thread?.env,treeCount:a.thread?.env?.initial?.trees?.length});try{let b=await J.exclusiveSyncReadWriter(a.id);try{let q1=structuredClone(a.thread);if(q1.env?.initial?.trees){let o=q1.env.initial.trees.map((r)=>({repository:r.repository,displayName:r.displayName,uri:void 0,fs:void 0}));q1.env={initial:{...q1.env.initial,trees:o}}}b.write(q1),f.debug(`Successfully wrote thread ${a.id} to storage`,{name:"ThreadSyncService",threadID:a.id}),await J.flushThread(a.id)}finally{await b.asyncDispose()}let s=new AbortController;try{let q1=await J.get(a.id);if(q1){let K1=await E5.uploadThread({thread:q1,createdOnServer:!1},{signal:s.signal,config:Y});if(!K1.ok){let o=K1.error.code==="thread-not-found"||K1.error.message?.includes("404"),r=K1.error.code==="permission-denied"||K1.error.message?.includes("403");if(o||r)f.warn(`Permanently failing thread ${a.id} due to unrecoverable error: ${K1.error.code}`,{error:K1.error}),U.add(a.id);else f.warn(`Failed to claim ownership of downloaded thread ${a.id} (will retry with backoff)`,{error:K1.error}),z.set(a.id,Date.now())}}}catch(q1){f.error(`Error claiming thread ${a.id} (will retry with backoff)`,q1,{name:"ThreadSyncService",threadID:a.id}),z.set(a.id,Date.now())}finally{s.abort()}K.getValue().set(a.id,{status:"synced",info:null}),f.debug(`Thread ${a.id} download complete and flushed to storage`,{name:"ThreadSyncService",threadID:a.id})}catch(b){f.error(`Failed to store downloaded thread ${a.id}`,b,{name:"ThreadSyncService",threadID:a.id})}break}default:continue}}if(I){for(let a of I)if(K.getValue().get(a)?.status==="unknown")K.getValue().set(a,{status:"synced",info:null})}K.next(K.getValue()),await L(),f.debug(`Sync completed (${I?I.length:"all"} threads checked, ${Y1} threads needed sync)`,{name:"ThreadSyncService"})}finally{let g=q.indexOf(p);if(g!==-1)q.splice(g,1);if(u.abort(),q.length>30)f.debug("[AbortController] High disposables count detected: ",q.length,{name:"ThreadSyncService",operation:"sync"})}};f.debug("Thread sync service initialized (on-demand sync mode)",{name:"ThreadSyncService"});let E=Promise.resolve();if(G>0){let I=setInterval(()=>{if(V.size>0)L().catch((R)=>f.error("Error in periodic sync retry:",R,{name:"ThreadSyncService"}))},G);q.push({dispose:()=>clearInterval(I)})}q.push(qZ1(V.observable.pipe(R7((I)=>I.size>0),w$(3000),yF(()=>L().catch((I)=>f.error("Error processing sync queue:",I,{name:"ThreadSyncService"})))).subscribe({}))),q.push(qZ1(J.exclusiveThreadsChanges.pipe(r4((I)=>yW(...Array.from(I.entries()).map(([,R])=>R.pipe(VX(([S,y])=>{if(!U.has(S.id))V.add(S.id)})))))).subscribe({})));let P=async()=>{if(!await W())return[];let I=new AbortController,R={dispose:()=>I.abort()};q.push(R);try{let S=await E5.discoverThreads({},{signal:I.signal,config:Y});if(!S.ok)return f.warn("Thread discovery failed",{name:"ThreadSyncService",error:S.error}),[];let{threadIDs:y}=S.result;if(y.length===0)return[];return f.debug("Discovered available threads from server",{name:"ThreadSyncService",threadCount:y.length}),await A(y,!1),y}finally{let S=q.indexOf(R);if(S!==-1)q.splice(S,1);I.abort()}};return{async sync(){return A()},async uploadThread(I){return H(I)},async discoverThreads(){return P()},initialSyncComplete:E,async updateThreadMeta(I,R){let S=K.getValue().get(I),y=new AbortController,h={dispose:()=>y.abort()};q.push(h);try{K.getValue().set(I,{status:"synced",info:{meta:{visibility:R.visibility,sharedGroupIDs:"sharedGroupIDs"in R?R.sharedGroupIDs:[]}}}),K.next(K.getValue());let u=await E5.setThreadMeta({thread:I,meta:R},{signal:y.signal,config:Y});if(!u.ok)throw f.debug("Failed to update sharing status (USE_NEW_INTERNAL_API=true)",{error:u.error}),Error(`Failed to update sharing status: ${u.error.code}`)}catch(u){if(S)K.getValue().set(I,S);else K.getValue().delete(I);throw K.next(K.getValue()),u}finally{let u=q.indexOf(h);if(u!==-1)q.splice(u,1);y.abort(),f.debug(`[AbortController] Cleaned up for updateThreadMeta ${I}, disposables count: ${q.length}`,{name:"ThreadSyncService",threadID:I,operation:"updateThreadMeta",wasTracked:u!==-1})}},threadSyncInfo(I){let R=[];for(let S of I){if(U.has(S)){if(!K.getValue().has(S))K.getValue().set(S,{status:"synced",info:null});continue}if(!K.getValue().has(S))K.getValue().set(S,{status:"unknown"}),R.push(S)}if(R.length>0)A(R,!0).catch((S)=>f.error("Error syncing thread metadata:",S,{name:"ThreadSyncService"}));return K.pipe(q6((S)=>{let y={};for(let h of I)y[h]=S.get(h)??{status:"synced",info:null};return y}))},dispose(){if(Z)return;Z=!0;for(let I of q)I.dispose()}}}o0();L0();async function qR(J,Q,Y,X){let G=await J.forkThread(Y);return await Un4(Q,J.threadID,G,X),G}async function Un4(J,Q,Y,X={}){let{originMetaTimeout:G=5000,forkedThreadTimeout:Z=1e4,waitForForkedUpload:q=!0}=X;try{let K=(await M6(J.threadSyncInfo([Q]).pipe(R7((H)=>H[Q]?.status==="synced"),kF(G))))[Q];if(K?.status!=="synced"||!K.info?.meta){f.debug("Origin thread has no metadata to inherit",{name:"inheritThreadVisibility",originThreadID:Q,forkedThreadID:Y});return}if(q)await M6(J.threadSyncInfo([Y]).pipe(R7((H)=>H[Y]?.status==="synced"),kF(Z)));let W=K.info.meta.visibility==="private"?{visibility:K.info.meta.visibility,sharedGroupIDs:K.info.meta.sharedGroupIDs}:{visibility:K.info.meta.visibility};await J.updateThreadMeta(Y,W),f.debug("Successfully inherited thread visibility",{name:"inheritThreadVisibility",originThreadID:Q,forkedThreadID:Y,metadata:K.info.meta})}catch(V){f.debug("Failed to inherit thread visibility settings",{name:"inheritThreadVisibility",error:V,originThreadID:Q,forkedThreadID:Y})}}vb();xI1();o0();A4();var j48=`Executes the given shell command in the user's interactive terminal foreground.
3225
+ `}},required:["relevantInformation","relevantFiles"]},source:"builtin",customizedForModel:!1};$Z();NH();H2();function Hn4(J){return typeof J==="object"&&J!==null&&"credits"in J}function yc0(J){if(!Hn4(J))return 0;let Q=J.credits,Y=typeof Q==="string"?Number(Q):Q;return typeof Y==="number"&&Number.isFinite(Y)?Y:0}CV();N9();async function xc0(J,Q,Y,X){let G=f2(J.content);if(!G)return{title:void 0,usage:void 0};let Z=await wP({configService:Y},X),q=crypto.randomUUID(),V=await Z.messages.create({model:Xr,max_tokens:60,temperature:0.7,system:`You are an assistant that generates short, descriptive titles (maximum 7 words, "Sentence case" with the first word capitalized not "Title Case") based on user's message to an agentic coding tool. Your titles should be concise (max 7 words) and capture the essence of the query or topic. DO NOT ASSUME OR GUESS the user's intent beyond what is in their message. Omit generic words like "question", "request", etc. Be professional and precise. Use common software engineering terms and acronyms if they are helpful. Use the set_title tool to provide your answer.`,messages:[{role:"user",content:`<message>${G}</message>`}],tools:[{name:"set_title",input_schema:{type:"object",properties:{title:{type:"string",description:'The short thread title (maximum 7 words, "Sentence case" with the first word capitalized not "Title Case") that you generated for the message'}},required:["title"]}}],tool_choice:{type:"tool",name:"set_title",disable_parallel_tool_use:!0}},{stream:!1,signal:X,headers:{...MY(Q),[DY]:q}}),K=`anthropic/${Xr.replace(/^[^/]+\//,"")}`,W=gG(K),H={model:Xr,maxInputTokens:W.contextWindow-W.maxOutputTokens,inputTokens:V.usage.input_tokens,outputTokens:V.usage.output_tokens,cacheCreationInputTokens:V.usage.cache_creation_input_tokens,cacheReadInputTokens:V.usage.cache_read_input_tokens,totalInputTokens:V.usage.input_tokens+(V.usage.cache_creation_input_tokens??0)+(V.usage.cache_read_input_tokens??0),credits:yc0(V.usage)},z=await CQ(q,Y);H.credits=z??0;let U=V.content.at(0);if(!U)throw Error("no content in generateThreadTitle response");if(U.type!=="tool_use"||U.name!=="set_title")throw Error("missing or invalid tool_use in generateThreadTitle response");return{title:U.input&&typeof U.input==="object"&&"title"in U.input&&typeof U.input.title==="string"?U.input.title:void 0,usage:H}}function vc0(J){let Q=/^Forked(?:\((\d+)\))?: (.+)$/,Y=J.match(Q);if(!Y)return`Forked: ${J||"Untitled"}`;let X=Y[1]?Number.parseInt(Y[1],10):1,G=Y[2];return`Forked(${X+1}): ${G}`}_l();class AE1{storage;configService;exclusiveThreads=new i_;get exclusiveThreadsChanges(){return this.exclusiveThreads.observable}dirtyThreads=new Set;flushRequests=new y4;flusher=this.flushRequests.pipe(k9(void 0),w$(100),r4(()=>{let J=Array.from(this.dirtyThreads);if(this.dirtyThreads=new Set,J.length===0)return n_;let Q=J.slice(0,3).map(async(Y)=>{try{await this.flushThread(Y)}catch(X){f.error("Error flushing thread to storage:",X,{name:"ThreadService",threadID:Y}),this.dirtyThreads.add(Y)}});if(J.length>3){for(let Y of J.slice(3))this.dirtyThreads.add(Y);setTimeout(()=>this.flushRequests.next(),100)}return e6(async()=>{await Promise.all(Q)})})).subscribe({});constructor(J,Q){this.storage=J;this.configService=Q}async flushThread(J){let Q=this.exclusiveThreads.get(J);if(!Q)return;let[Y]=Q.getValue();await this.storage.set(J,Y)}observeRaw(J){return this.exclusiveThreads.observable.pipe(q6((Q)=>Q.get(J)),x4(),r4((Q)=>{if(Q!==void 0)return Q;return new G0((Y)=>{this.storage.get(J).then((X)=>{if(X)Y.next([UX(X,!0),[]])})})}))}async getUnfrozen(J,Q){let Y=this.exclusiveThreads.get(J);if(Y)return Y.getValue()[0];let X=await this.storage.get(J);if(Q?.throwIfAborted(),!X)return null;return X}async get(J,Q){let Y=await this.getUnfrozen(J,Q);if(!Y)return null;return UX(Y,!0)}async getPrimitiveProperty(J,Q){let Y=await this.getUnfrozen(J);if(!Y)return null;return Y[Q]}observe(J){return this.observeRaw(J).pipe(q6(([Q,Y])=>Q),a_(100,{leading:!0,trailing:!0}))}observePatches(J){return this.observeRaw(J).pipe(q6(([Q,Y],X)=>X===0?Q:Y),Fn4(100))}async exclusiveSyncReadWriter(J){if(this.exclusiveThreads.has(J))throw Error(`Thread ${J} already has an exclusive read-writer`);let Q=this.exclusiveThreads.get(J);if(!Q){let X=await this.storage.get(J);if(!X)X=zn4(J),await this.storage.set(J,X);X=UX(X,!0),Q=new g5([X,[]]),this.exclusiveThreads.set(J,Q),await NR0()}let Y=!1;return{read:()=>{if(Y)throw Error("thread exclusive read-writer was disposed");return Q.getValue()[0]},write:(X)=>{if(Y)throw Error("thread exclusive read-writer was disposed");let[G,Z]=KM(Q.getValue()[0],()=>{return X});Q.next([G,Z]),this.dirtyThreads.add(J),this.flushRequests.next()},update:(X)=>{if(Y)throw Error("thread exclusive read-writer was disposed");let[G,Z]=KM(Q.getValue()[0],X);return Q.next([G,Z]),this.dirtyThreads.add(J),this.flushRequests.next(),G},asyncDispose:async()=>{if(Y)return;Y=!0;let[X]=Q.getValue();try{await this.storage.set(J,X)}catch(G){f.error("Error flushing thread on dispose:",G,{name:"ThreadService",threadID:J})}this.dirtyThreads.delete(J),this.exclusiveThreads.delete(J)}}}flush(){this.flushRequests.next()}async flushVersion(J,Q,Y=5000){this.dirtyThreads.add(J),await this.flushThread(J);let X=Date.now();while(!0){if(Date.now()-X>Y)throw Error(`Timed out waiting for thread ${J} to reach version ${Q}`);let G=await this.storage.get(J);if(G&&G.v>=Q)return;await new Promise((Z)=>setTimeout(Z,10))}}async forkThread(J,Q){let Y=await this.get(J);if(!Y)throw Error(`Thread ${J} not found`);let X=Y.messages.slice(0,Q+1);return{threadID:await this.createForkedThread(J,X,Q)}}async createForkedThread(J,Q,Y){let X=await this.get(J);if(!X)throw Error(`Thread ${J} not found`);let G=j$(),Z=Date.now(),q=await this.exclusiveSyncReadWriter(G),V=vc0(X.title||"Untitled"),K=q.update((z)=>{if(z.originThreadID=J,z.forkPointIndex=Y,z.v++,z.title=V,z.relationships=[{threadID:J,type:"fork",role:"child",messageIndex:Y,createdAt:Z}],X.env)z.env=$9(X.env);for(let U of Q)z.messages.push($9(U))});await q.asyncDispose();let W=this.exclusiveThreads.get(J);if(W){let[z]=W.getValue(),[U,N]=KM(z,(M)=>{if(M.v++,M.forkThreads??={},M.forkThreads[Y]??=[],!M.forkThreads[Y].includes(G))M.forkThreads[Y].push(G);if(M.relationships??=[],!M.relationships.some((A)=>A.threadID===G&&A.type==="fork"&&A.role==="parent"&&A.messageIndex===Y))M.relationships.push({threadID:G,type:"fork",role:"parent",messageIndex:Y,createdAt:Z})});W.next([U,N]),this.dirtyThreads.add(J),this.flushRequests.next()}else{let z=await this.exclusiveSyncReadWriter(J);z.update((U)=>{if(U.v++,U.forkThreads??={},U.forkThreads[Y]??=[],!U.forkThreads[Y].includes(G))U.forkThreads[Y].push(G);if(U.relationships??=[],!U.relationships.some((M)=>M.threadID===G&&M.type==="fork"&&M.role==="child"&&M.messageIndex===Y))U.relationships.push({threadID:G,type:"fork",role:"child",messageIndex:Y,createdAt:Z})}),await z.asyncDispose()}let H=K.v;return await this.flushVersion(G,H),G}async generateHandoffPrompt(J,Q,Y,X,G){let Z=await this.get(J);if(!Z)throw Error(`Thread ${J} not found`);return LE1(Z,Q,Y,X,G)}async createHandoffThread(J,Q,Y,X){let{goal:G,generatedPrompt:Z,images:q,messageIndex:V}=Q;if(!G&&!Z)throw Error("Either goal or generatedPrompt must be provided");let K=await this.get(J);if(!K)throw Error(`Thread ${J} not found`);let H=Z!==void 0?Z:await LE1(K,G,q,Y,X),z=j$(),U=V??(K.messages.length?K.messages.length-1:void 0),N=Date.now(),M=await this.exclusiveSyncReadWriter(z);M.update((A)=>{if(A.v++,K.env)A.env=$9(K.env);if(K.agentMode)A.agentMode=K.agentMode==="plan"?"smart":K.agentMode;A.draft=$9(H),A.relationships=[{threadID:J,type:"handoff",role:"child",messageIndex:U,createdAt:N,comment:G}]}),await M.asyncDispose();let L=this.exclusiveThreads.get(J);if(L){let[A]=L.getValue(),[E,P]=KM(A,(I)=>{if(I.v++,I.relationships??=[],!I.relationships.some((S)=>S.threadID===z&&S.type==="handoff"&&S.role==="parent"&&S.messageIndex===U))I.relationships.push({threadID:z,type:"handoff",role:"parent",messageIndex:U,createdAt:N,comment:G})});L.next([E,P]),this.dirtyThreads.add(J),await this.flushThread(J)}else{let A=await this.exclusiveSyncReadWriter(J);A.update((E)=>{if(E.v++,E.relationships??=[],!E.relationships.some((I)=>I.threadID===z&&I.type==="handoff"&&I.role==="parent"&&I.messageIndex===U))E.relationships.push({threadID:z,type:"handoff",role:"parent",messageIndex:U,createdAt:N,comment:G})}),await A.asyncDispose()}return z}async delete(J){let Q=await this.storage.keys(),Y=[];for(let X of Q){let G=await this.storage.get(X);if(G&&G.mainThreadID===J)Y.push(G.id)}for(let X of Y)try{await this.storage.delete(X)}catch(G){if(!rJ(G))throw G}try{await this.storage.delete(J)}catch(X){if(!rJ(X))throw X}this.exclusiveThreads.delete(J),this.dirtyThreads.delete(J);try{let X=await E5.deleteThread({thread:J},{config:this.configService});if(!X.ok&&X.error.code!=="thread-not-found")throw Error(`Error deleting thread from server: ${X.error.message??X.error.code}`)}catch(X){if(X instanceof Error&&X.message.includes("404"))return;throw X}}getRecentlyActiveThread(){let J=null,Q=0;for(let[,Y]of this.exclusiveThreads.entries()){let[X]=Y.getValue();if(z11(X)>Q)J=X,Q=z11(X)}return J}async discardHandoffThread(J){let Q=await this.get(J);if(!Q?.relationships)return null;if(Q.messages.length>0)return null;let Y=Q.relationships.find((G)=>G.type==="handoff"&&G.role==="child");if(!Y)return null;let X=this.exclusiveThreads.get(Y.threadID);if(X){let[G]=X.getValue(),[Z,q]=KM(G,(V)=>{V.v++,V.relationships=V.relationships?.filter((K)=>!(K.threadID===J&&K.type==="handoff"&&K.role==="parent"))});X.next([Z,q]),this.dirtyThreads.add(Y.threadID),await this.flushThread(Y.threadID)}else{let G=await this.exclusiveSyncReadWriter(Y.threadID);G.update((Z)=>{Z.v++,Z.relationships=Z.relationships?.filter((q)=>!(q.threadID===J&&q.type==="handoff"&&q.role==="parent"))}),await G.asyncDispose(),await this.flushThread(Y.threadID)}return await this.delete(J),Y.threadID}async createPlanExecutionThread(J,Q="smart"){let Y=await this.get(J);if(!Y)throw Error(`Thread ${J} not found`);Rc0(Y);let X=xU(Y),G=Cc0(X),Z=jc0(X,Y),q=j$(),V=Date.now(),K=await this.exclusiveSyncReadWriter(q),W=K.update((U)=>{if(U.v++,U.title=G?`Execute: ${G}`:"Execute Plan",U.agentMode=Q,Y.env)U.env=$9(Y.env);U.artifacts={plan:{type:"plan",content:X,created:Y.artifacts?.plan?.created??V,updated:V}},U.relationships=[{threadID:J,type:"handoff",role:"child",createdAt:V,comment:"Execution thread for plan"}],U.draft=Z});await K.asyncDispose();let H=W.v;await this.flushVersion(q,H);let z=this.exclusiveThreads.get(J);if(z){let[U]=z.getValue(),[N,M]=KM(U,(L)=>{if(L.v++,L.relationships??=[],!L.relationships.some((E)=>E.threadID===q&&E.type==="handoff"&&E.role==="parent"))L.relationships.push({threadID:q,type:"handoff",role:"parent",createdAt:V,comment:"Execution thread created from plan"})});z.next([N,M]),this.dirtyThreads.add(J),this.flushRequests.next()}else{let U=await this.exclusiveSyncReadWriter(J);U.update((N)=>{if(N.v++,N.relationships??=[],!N.relationships.some((L)=>L.threadID===q&&L.type==="handoff"&&L.role==="parent"))N.relationships.push({threadID:q,type:"handoff",role:"parent",createdAt:V,comment:"Execution thread created from plan"})}),await U.asyncDispose()}return q}async asyncDispose(){this.flusher.unsubscribe(),await Promise.all(Array.from(this.dirtyThreads).map((J)=>this.flushThread(J))),this.exclusiveThreads.dispose()}}function zn4(J){return{v:0,id:J,created:Date.now(),messages:[]}}function Fn4(J){return(Q)=>new G0((Y)=>{let X=[],G=null,Z=()=>{if(G)clearTimeout(G),G=null;if(X.length>0)Y.next(X),X=[]};return Q.subscribe({next:(q)=>{if(!(q instanceof Array)){Z(),Y.next(q);return}X.push(...q),G=setTimeout(Z,J)},error:(q)=>{Z(),Y.error(q)},complete:()=>{Z(),Y.complete()}})})}o0();L0();vF();ZZ();u$();function fc0({threadService:J,threadHistoryService:Q,configService:Y,isExtensionDevelopment:X=!1,retryIntervalMs:G=30000}){let Z=!1,q=[],V=new $Z1,K=new g5(new Map),W=async()=>{if(Z)return!1;if(!await M6(xT0(Y)))return!1;let I=await Y.getLatest(new AbortController().signal);if(X&&xF(I.settings.url)&&process.env.FORCE_ENABLE_SYNC!=="1")return f.debug(`Skipping sync to ${zY} in extension development mode to avoid polluting the production server`,{name:"ThreadSyncService"}),!1;return!0},H=async(I)=>{if(!M(I))return;let R=await J.get(I);if(!R){V.delete(I);return}if(R.messages.length===0)return;if(!await W())return;let S=new AbortController,y={dispose:()=>S.abort()};q.push(y);try{try{let h=await E5.uploadThread({thread:R,createdOnServer:!1},{signal:S.signal,config:Y});if(!h.ok)throw Error(`Failed to upload thread: ${h.error.code}`)}catch(h){throw f.warn(`Failed to upload thread ${I}`,{name:"ThreadSyncService",threadID:I,error:h}),h}}finally{let h=q.indexOf(y);if(h!==-1)q.splice(h,1);if(S.abort(),q.length>30)f.debug("[AbortController] High disposables count detected: ",q.length,{name:"ThreadSyncService",operation:"uploadThread"})}},z=new Map,U=new Set,N=60000,M=(I)=>{if(U.has(I))return!1;let R=z.get(I);if(!R)return!0;let S=Date.now()-R,y=S>=N;if(!y)f.debug(`Skipping thread ${I} sync due to backoff (${Math.round(S/1000)}s elapsed of ${N/1000}s backoff)`,{name:"ThreadSyncService"});return y},L=async()=>{for(let I of V){if(!M(I))continue;try{await H(I),V.delete(I),z.delete(I)}catch(R){let S=R instanceof Error?R.message:String(R);if(S.includes("404")&&S.includes("Thread not found"))U.add(I),V.delete(I),z.delete(I),f.warn(`Thread ${I} not found on server, stopping sync attempts`,{name:"ThreadSyncService"});else z.set(I,Date.now()),f.warn(`Failed to sync thread ${I}, will retry after backoff`,{name:"ThreadSyncService",error:R})}}},A=async(I,R=!1)=>{if(!await W())return;let S;if(I)S=(await Promise.all(I.map(async(g)=>{let i=await J.get(g);return i?{id:i.id,v:i.v}:{id:g,v:-1}}))).filter((g)=>g!==null);else{let g=await M6(Q.observeHistory().pipe(q6((Y1)=>Y1.map((a)=>({id:a.id,v:a.v}))))),i=await M6(J.exclusiveThreadsChanges.pipe(q6((Y1)=>Array.from(Y1.values()).map((a)=>{let[b,s]=a.getValue();return{id:b.id,v:b.v}}))));S=g.concat(i)}let y={threadVersions:[],threadMetas:[]},h=new Set;for(let g of S){if(h.has(g.id))continue;if(h.add(g.id),U.has(g.id))continue;if(!R)y.threadVersions.push({id:g.id,v:g.v});let i=K.getValue().get(g.id);y.threadMetas.push({id:g.id,meta:i?.status==="synced"&&i.info?i.info?.meta.visibility==="private"?{visibility:"private",sharedGroupIDs:i.info.meta.sharedGroupIDs}:{visibility:i.info.meta.visibility}:void 0})}if(y.threadVersions.length===0&&y.threadMetas.length===0)return;if(!await W())return;let u=new AbortController,p={dispose:()=>u.abort()};q.push(p);try{f.debug("Sending threads sync request",{name:"ThreadSyncService",source:R?"metadata":"full",threadCount:y.threadVersions.length+y.threadMetas.length});let g=await RQ("/api/threads/sync",{method:"POST",body:JSON.stringify(y),signal:u.signal},Y);if(!g.ok){let a=await g.text().catch(()=>"Unable to read response body");throw f.warn("Threads sync request failed",{name:"ThreadSyncService",status:g.status,text:a}),Error(`Threads sync API responded with status: ${g.status}${a?`: ${a}`:""}`)}f.debug("Got response for threads sync request",{name:"ThreadSyncService",status:g.status});let i=await g.json(),Y1=0;for(let a of i.threadActions){if(!(("action"in a)&&typeof a.action==="string"))continue;switch(a.action){case"upload":{if(!U.has(a.id))V.add(a.id),Y1++;break}case"meta":{K.getValue().set(a.id,{status:"synced",info:{meta:a.meta}});break}case"download":{f.debug(`Processing download action for thread ${a.id}`,{name:"ThreadSyncService",threadID:a.id,hasThread:!!a.thread,threadV:a.thread?.v,hasEnv:!!a.thread?.env,treeCount:a.thread?.env?.initial?.trees?.length});try{let b=await J.exclusiveSyncReadWriter(a.id);try{let q1=structuredClone(a.thread);if(q1.env?.initial?.trees){let o=q1.env.initial.trees.map((r)=>({repository:r.repository,displayName:r.displayName,uri:void 0,fs:void 0}));q1.env={initial:{...q1.env.initial,trees:o}}}b.write(q1),f.debug(`Successfully wrote thread ${a.id} to storage`,{name:"ThreadSyncService",threadID:a.id}),await J.flushThread(a.id)}finally{await b.asyncDispose()}let s=new AbortController;try{let q1=await J.get(a.id);if(q1){let K1=await E5.uploadThread({thread:q1,createdOnServer:!1},{signal:s.signal,config:Y});if(!K1.ok){let o=K1.error.code==="thread-not-found"||K1.error.message?.includes("404"),r=K1.error.code==="permission-denied"||K1.error.message?.includes("403");if(o||r)f.warn(`Permanently failing thread ${a.id} due to unrecoverable error: ${K1.error.code}`,{error:K1.error}),U.add(a.id);else f.warn(`Failed to claim ownership of downloaded thread ${a.id} (will retry with backoff)`,{error:K1.error}),z.set(a.id,Date.now())}}}catch(q1){f.error(`Error claiming thread ${a.id} (will retry with backoff)`,q1,{name:"ThreadSyncService",threadID:a.id}),z.set(a.id,Date.now())}finally{s.abort()}K.getValue().set(a.id,{status:"synced",info:null}),f.debug(`Thread ${a.id} download complete and flushed to storage`,{name:"ThreadSyncService",threadID:a.id})}catch(b){f.error(`Failed to store downloaded thread ${a.id}`,b,{name:"ThreadSyncService",threadID:a.id})}break}default:continue}}if(I){for(let a of I)if(K.getValue().get(a)?.status==="unknown")K.getValue().set(a,{status:"synced",info:null})}K.next(K.getValue()),await L(),f.debug(`Sync completed (${I?I.length:"all"} threads checked, ${Y1} threads needed sync)`,{name:"ThreadSyncService"})}finally{let g=q.indexOf(p);if(g!==-1)q.splice(g,1);if(u.abort(),q.length>30)f.debug("[AbortController] High disposables count detected: ",q.length,{name:"ThreadSyncService",operation:"sync"})}};f.debug("Thread sync service initialized (on-demand sync mode)",{name:"ThreadSyncService"});let E=Promise.resolve();if(G>0){let I=setInterval(()=>{if(V.size>0)L().catch((R)=>f.error("Error in periodic sync retry:",R,{name:"ThreadSyncService"}))},G);q.push({dispose:()=>clearInterval(I)})}q.push(qZ1(V.observable.pipe(R7((I)=>I.size>0),w$(3000),yF(()=>L().catch((I)=>f.error("Error processing sync queue:",I,{name:"ThreadSyncService"})))).subscribe({}))),q.push(qZ1(J.exclusiveThreadsChanges.pipe(r4((I)=>yW(...Array.from(I.entries()).map(([,R])=>R.pipe(VX(([S,y])=>{if(!U.has(S.id))V.add(S.id)})))))).subscribe({})));let P=async()=>{if(!await W())return[];let I=new AbortController,R={dispose:()=>I.abort()};q.push(R);try{let S=await E5.discoverThreads({},{signal:I.signal,config:Y});if(!S.ok)return f.warn("Thread discovery failed",{name:"ThreadSyncService",error:S.error}),[];let{threadIDs:y}=S.result;if(y.length===0)return[];return f.debug("Discovered available threads from server",{name:"ThreadSyncService",threadCount:y.length}),await A(y,!1),y}finally{let S=q.indexOf(R);if(S!==-1)q.splice(S,1);I.abort()}};return{async sync(){return A()},async uploadThread(I){return H(I)},async discoverThreads(){return P()},initialSyncComplete:E,async updateThreadMeta(I,R){let S=K.getValue().get(I),y=new AbortController,h={dispose:()=>y.abort()};q.push(h);try{K.getValue().set(I,{status:"synced",info:{meta:{visibility:R.visibility,sharedGroupIDs:"sharedGroupIDs"in R?R.sharedGroupIDs:[]}}}),K.next(K.getValue());let u=await E5.setThreadMeta({thread:I,meta:R},{signal:y.signal,config:Y});if(!u.ok)throw f.debug("Failed to update sharing status (USE_NEW_INTERNAL_API=true)",{error:u.error}),Error(`Failed to update sharing status: ${u.error.code}`)}catch(u){if(S)K.getValue().set(I,S);else K.getValue().delete(I);throw K.next(K.getValue()),u}finally{let u=q.indexOf(h);if(u!==-1)q.splice(u,1);y.abort(),f.debug(`[AbortController] Cleaned up for updateThreadMeta ${I}, disposables count: ${q.length}`,{name:"ThreadSyncService",threadID:I,operation:"updateThreadMeta",wasTracked:u!==-1})}},threadSyncInfo(I){let R=[];for(let S of I){if(U.has(S)){if(!K.getValue().has(S))K.getValue().set(S,{status:"synced",info:null});continue}if(!K.getValue().has(S))K.getValue().set(S,{status:"unknown"}),R.push(S)}if(R.length>0)A(R,!0).catch((S)=>f.error("Error syncing thread metadata:",S,{name:"ThreadSyncService"}));return K.pipe(q6((S)=>{let y={};for(let h of I)y[h]=S.get(h)??{status:"synced",info:null};return y}))},dispose(){if(Z)return;Z=!0;for(let I of q)I.dispose()}}}o0();L0();async function qR(J,Q,Y,X){let G=await J.forkThread(Y);return await Un4(Q,J.threadID,G,X),G}async function Un4(J,Q,Y,X={}){let{originMetaTimeout:G=5000,forkedThreadTimeout:Z=1e4,waitForForkedUpload:q=!0}=X;try{let K=(await M6(J.threadSyncInfo([Q]).pipe(R7((H)=>H[Q]?.status==="synced"),kF(G))))[Q];if(K?.status!=="synced"||!K.info?.meta){f.debug("Origin thread has no metadata to inherit",{name:"inheritThreadVisibility",originThreadID:Q,forkedThreadID:Y});return}if(q)await M6(J.threadSyncInfo([Y]).pipe(R7((H)=>H[Y]?.status==="synced"),kF(Z)));let W=K.info.meta.visibility==="private"?{visibility:K.info.meta.visibility,sharedGroupIDs:K.info.meta.sharedGroupIDs}:{visibility:K.info.meta.visibility};await J.updateThreadMeta(Y,W),f.debug("Successfully inherited thread visibility",{name:"inheritThreadVisibility",originThreadID:Q,forkedThreadID:Y,metadata:K.info.meta})}catch(V){f.debug("Failed to inherit thread visibility settings",{name:"inheritThreadVisibility",error:V,originThreadID:Q,forkedThreadID:Y})}}vb();xI1();o0();A4();var j48=`Executes the given shell command in the user's interactive terminal foreground.
3227
3226
 
3228
3227
  Use this tool when the user explicitly asks to:
3229
3228
  - Open an interactive tool (e.g., 'vim', 'nano', 'htop', 'less').
@@ -4102,11 +4101,11 @@ Actual: ${G}`)}async function uG8(J,Q,Y){let{execSync:X}=await import("node:ch
4102
4101
  ${N}`;if(G==="pnpm"&&N.includes("Unable to find the global bin directory"))M+=`
4103
4102
 
4104
4103
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4105
- npm install -g @sourcegraph/amp`;V(Error(M))}},error:(U)=>{if(!H)H=!0,V(Error(`Failed to spawn ${G}: ${U.message}`))},complete:()=>{if(!H)H=!0,q()}})})}L0();L0();async function R61(J,Q){let X=Q||"https://registry.npmjs.org";try{let G=new AbortController,Z=setTimeout(()=>G.abort(),5000),q=await fetch(`${X}/@sourcegraph/amp`,{signal:G.signal});if(clearTimeout(Z),!q.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let V=await q.json(),K=V["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=iG8(J,K),H=W<0,z,U;if(V.time){let N=V.time[J],M=V.time[K],L=Date.now();if(N)z=Math.floor((L-new Date(N).getTime())/3600000);if(M)U=Math.floor((L-new Date(M).getTime())/3600000)}return f.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:W,hasUpdate:H,currentVersionAge:z,latestVersionAge:U}),{hasUpdate:H,latestVersion:K,currentVersion:J,currentVersionAge:z,latestVersionAge:U,source:"npm"}}catch(G){return f.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function iG8(J,Q){let Y=(q)=>{let[V,K]=q.split("-");return{parts:V?.split(".").map(Number)||[],label:K}},X=Y(J),G=Y(Q),Z=Math.max(X.parts.length,G.parts.length);for(let q=0;q<Z;q++){let V=X.parts[q]||0,K=G.parts[q]||0;if(V<K)return-1;if(V>K)return 1}if(X.label===G.label)return 0;if(!X.label&&G.label)return 1;if(X.label&&!G.label)return-1;if(X.label&&G.label)return X.label<G.label?-1:1;return 0}o0();function C61(J,Q){let Y=new y4,X=Y.pipe(o8({shouldCountRefs:!1}));return setImmediate(async()=>{let G=new AV().scoped("update"),Z=X.subscribe({next:(q)=>{G.debug("emit new state",q)}});try{let q=process.env.AMP_TEST_UPDATE_STATUS;if(q){G.debug("using fake update status for testing",{status:q}),await SU(500),Y.next(q);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){G.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let V=await Q.get("updates.mode");if(V==="disabled"){G.debug("checking disabled");return}G.debug("checking",{currentVersion:J,mode:V});let K=mA(),W=await R61(J,K);if(!(W.latestVersion&&W.hasUpdate)){G.debug("no update available");return}let H=()=>{if(W.currentVersionAge!==void 0&&W.latestVersionAge!==void 0){let U=W.currentVersionAge-W.latestVersionAge,N=0.5;if(Math.abs(U)<0.5)return G.debug("versions too close together, suppressing update warning",{currentVersionAge:W.currentVersionAge,latestVersionAge:W.latestVersionAge,ageDifferenceHours:U}),!0}return!1},z=await T61();if(!V)V=z==="pnpm"?"warn":"auto",G.debug("no configured update mode; selected default based on package manager",{packageManager:z,mode:V});if(V==="warn"){if(!H())Y.next("update-available");return}if(!z){if(G.debug("auto-update not supported, falling back to warn mode"),!H())Y.next("update-available");return}try{await Pg(W.latestVersion,z);let U=await cB(W.latestVersion),N={from:W.currentVersion,to:W.latestVersion,...U};if(U.status==="same")G.info("success",N),Y.next("updated");else G.warn("success with warning",N),Y.next("updated-with-warning")}catch(U){Y.next("update-error")}}catch(q){G.debug("check failed",{error:q})}finally{await SU(5000),Y.next("hidden"),Z.unsubscribe(),Y.complete()}}),{state:X}}import{stderr as CK}from"node:process";function E86(J){let Q=new TA().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await AR1(X.force||!1,X.verbose||!1,"0.0.1764165115-gcd064d"),process.exit()});J.addCommand(Q,{hidden:!0});let Y=new TA("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await nG8(X.targetVersion)});J.addCommand(Y)}async function nG8(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")CK.write(h4.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4104
+ npm install -g @sourcegraph/amp`;V(Error(M))}},error:(U)=>{if(!H)H=!0,V(Error(`Failed to spawn ${G}: ${U.message}`))},complete:()=>{if(!H)H=!0,q()}})})}L0();L0();async function R61(J,Q){let X=Q||"https://registry.npmjs.org";try{let G=new AbortController,Z=setTimeout(()=>G.abort(),5000),q=await fetch(`${X}/@sourcegraph/amp`,{signal:G.signal});if(clearTimeout(Z),!q.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let V=await q.json(),K=V["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=iG8(J,K),H=W<0,z,U;if(V.time){let N=V.time[J],M=V.time[K],L=Date.now();if(N)z=Math.floor((L-new Date(N).getTime())/3600000);if(M)U=Math.floor((L-new Date(M).getTime())/3600000)}return f.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:W,hasUpdate:H,currentVersionAge:z,latestVersionAge:U}),{hasUpdate:H,latestVersion:K,currentVersion:J,currentVersionAge:z,latestVersionAge:U,source:"npm"}}catch(G){return f.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}}function iG8(J,Q){let Y=(q)=>{let[V,K]=q.split("-");return{parts:V?.split(".").map(Number)||[],label:K}},X=Y(J),G=Y(Q),Z=Math.max(X.parts.length,G.parts.length);for(let q=0;q<Z;q++){let V=X.parts[q]||0,K=G.parts[q]||0;if(V<K)return-1;if(V>K)return 1}if(X.label===G.label)return 0;if(!X.label&&G.label)return 1;if(X.label&&!G.label)return-1;if(X.label&&G.label)return X.label<G.label?-1:1;return 0}o0();function C61(J,Q){let Y=new y4,X=Y.pipe(o8({shouldCountRefs:!1}));return setImmediate(async()=>{let G=new AV().scoped("update"),Z=X.subscribe({next:(q)=>{G.debug("emit new state",q)}});try{let q=process.env.AMP_TEST_UPDATE_STATUS;if(q){G.debug("using fake update status for testing",{status:q}),await SU(500),Y.next(q);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){G.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let V=await Q.get("updates.mode");if(V==="disabled"){G.debug("checking disabled");return}G.debug("checking",{currentVersion:J,mode:V});let K=mA(),W=await R61(J,K);if(!(W.latestVersion&&W.hasUpdate)){G.debug("no update available");return}let H=()=>{if(W.currentVersionAge!==void 0&&W.latestVersionAge!==void 0){let U=W.currentVersionAge-W.latestVersionAge,N=0.5;if(Math.abs(U)<0.5)return G.debug("versions too close together, suppressing update warning",{currentVersionAge:W.currentVersionAge,latestVersionAge:W.latestVersionAge,ageDifferenceHours:U}),!0}return!1},z=await T61();if(!V)V=z==="pnpm"?"warn":"auto",G.debug("no configured update mode; selected default based on package manager",{packageManager:z,mode:V});if(V==="warn"){if(!H())Y.next("update-available");return}if(!z){if(G.debug("auto-update not supported, falling back to warn mode"),!H())Y.next("update-available");return}try{await Pg(W.latestVersion,z);let U=await cB(W.latestVersion),N={from:W.currentVersion,to:W.latestVersion,...U};if(U.status==="same")G.info("success",N),Y.next("updated");else G.warn("success with warning",N),Y.next("updated-with-warning")}catch(U){Y.next("update-error")}}catch(q){G.debug("check failed",{error:q})}finally{await SU(5000),Y.next("hidden"),Z.unsubscribe(),Y.complete()}}),{state:X}}import{stderr as CK}from"node:process";function E86(J){let Q=new TA().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await AR1(X.force||!1,X.verbose||!1,"0.0.1764172241-gaca8cf"),process.exit()});J.addCommand(Q,{hidden:!0});let Y=new TA("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await nG8(X.targetVersion)});J.addCommand(Y)}async function nG8(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")CK.write(h4.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4106
4105
 
4107
4106
  `));try{if(!J){CK.write(h4.blue(`Checking for updates...
4108
- `));let Y=mA(),{hasUpdate:X,latestVersion:G}=await R61("0.0.1764165115-gcd064d",Y);if(!X){CK.write(h4.green(`✓ Amp CLI is already up to date.
4109
- `));let Z=await cB("0.0.1764165115-gcd064d");if(Z.warning)CK.write(`
4107
+ `));let Y=mA(),{hasUpdate:X,latestVersion:G}=await R61("0.0.1764172241-gaca8cf",Y);if(!X){CK.write(h4.green(`✓ Amp CLI is already up to date.
4108
+ `));let Z=await cB("0.0.1764172241-gaca8cf");if(Z.warning)CK.write(`
4110
4109
  `+h4.yellow(Z.warning)+`
4111
4110
  `);process.exit(0)}if(!G)CK.write(h4.yellow("[WARN] could not find latest version")),process.exit(0);J=G}CK.write(h4.blue(`Updating to version ${J}...
4112
4111
  `)),await Pg(J,void 0,(Y)=>{CK.write(h4.dim(`Running: ${Y}
@@ -4731,7 +4730,7 @@ exit code: ${Z}`,new H1({color:X.foreground,dim:!0,italic:!0})));if(q)V.push(new
4731
4730
  `,M),...L],E=[new d1({text:new J1("",void 0,A)})];if(W.url){let I=W.url.replace(/^https?:\/\//,"");E.push(new Q4({children:[new d1({text:new J1("See more: ",M)}),new i2({uri:W.url,text:I,style:new H1({color:Y.secondary,underline:!0})})]}))}let P=new s0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:E});return H8.child(new J6({constraints:new r6(40,120,0,1/0),child:new Q4({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[new z4({flex:1,child:new bC1({width:40,height:40,agentMode:this.agentMode,...V&&{primaryColor:{r:0,g:55,b:0},secondaryColor:{r:0,g:255,b:136}},fps:q==="fast"?60:q==="slow"?15:0,...q==="disabled"&&{seed:42,t:3}})}),new U0({width:1}),new z4({flex:2,child:P})]})}))}}L0();N9();A4();b7();N9();o0();function UB8(J,Q){return`${J}:${Q}`}class z_1{threadService;workers=new Map;threadsMap=new Map;subthreadsMap=new Map;mainThreadSubs=new Map;subthreadsSubs=new Map;workerStatusSubs=new Map;subthreadPatchSubs=new Map;mainThreadObservable;subthreadObservable;workerStatusObservable;emitMainThread=null;emitSubthread=null;emitWorkerStatus=null;constructor(J){this.threadService=J;this.mainThreadObservable=new G0((Q)=>{return this.emitMainThread=(Y)=>Q.next(Y),()=>{this.emitMainThread=null}}),this.subthreadObservable=new G0((Q)=>{return this.emitSubthread=(Y)=>Q.next(Y),()=>{this.emitSubthread=null}}),this.workerStatusObservable=new G0((Q)=>{return this.emitWorkerStatus=(Y)=>Q.next(Y),()=>{this.emitWorkerStatus=null}})}registerWorker(J){let Q=J.thread.id;if(this.workers.has(Q))this.unregisterWorker(Q);this.threadsMap.set(Q,J.thread),this.subthreadsMap.set(Q,[]),this.workers.set(Q,{state:"initial"});let Y=this.threadService.observePatches(Q).pipe(FM()).subscribe((Z)=>{this.threadsMap.set(Q,Z);let q=this.subthreadsMap.get(Q)||[],V=this.workers.get(Q)||{state:"initial"};if(this.emitMainThread)this.emitMainThread({threadID:Q,mainThread:Z,subthreads:q,workerStatus:V})});this.mainThreadSubs.set(Q,Y);let X=J.status.subscribe((Z)=>{if(this.workers.set(Q,Z),this.emitWorkerStatus)this.emitWorkerStatus({threadID:Q,status:Z})});this.workerStatusSubs.set(Q,X);let G=J.subthreads.subscribe((Z)=>{this.subthreadsMap.set(Q,Z);for(let q of Z){let V=UB8(Q,q.toolUse.id);if(this.subthreadPatchSubs.has(V))continue;let K=this.threadService.observePatches(q.threadID).pipe(FM()).subscribe((W)=>{if(this.emitSubthread)this.emitSubthread({threadID:Q,thread:W,subthread:q})});this.subthreadPatchSubs.set(V,K)}});this.subthreadsSubs.set(Q,G)}unregisterWorker(J){let Q=this.mainThreadSubs.get(J);if(Q)Q.unsubscribe(),this.mainThreadSubs.delete(J);let Y=this.workerStatusSubs.get(J);if(Y)Y.unsubscribe(),this.workerStatusSubs.delete(J);let X=this.subthreadsSubs.get(J);if(X)X.unsubscribe(),this.subthreadsSubs.delete(J);for(let[G,Z]of this.subthreadPatchSubs.entries())if(G.startsWith(`${J}:`))Z.unsubscribe(),this.subthreadPatchSubs.delete(G);this.workers.delete(J),this.threadsMap.delete(J),this.subthreadsMap.delete(J)}observeThread(J){return{mainThread:new G0((Q)=>{return this.mainThreadObservable.subscribe((Y)=>{if(Y.threadID===J)Q.next(Y)})}),subthreads:new G0((Q)=>{return this.subthreadObservable.subscribe((Y)=>{if(Y.threadID===J)Q.next(Y)})}),workerStatus:new G0((Q)=>{return this.workerStatusObservable.subscribe((Y)=>{if(Y.threadID===J)Q.next(Y)})})}}get threadViewStates(){let J={};for(let[Q,Y]of this.threadsMap){let X=this.workers.get(Q);if(X)J[Q]=qA(Y,X)}return J}dispose(){for(let J of this.mainThreadSubs.values())J.unsubscribe();for(let J of this.subthreadsSubs.values())J.unsubscribe();for(let J of this.workerStatusSubs.values())J.unsubscribe();for(let J of this.subthreadPatchSubs.values())J.unsubscribe();this.mainThreadSubs.clear(),this.subthreadsSubs.clear(),this.workerStatusSubs.clear(),this.subthreadPatchSubs.clear(),this.workers.clear(),this.threadsMap.clear(),this.subthreadsMap.clear()}}function BB8(J,Q){switch(Q.type){case"subthread-patch":{let{thread:Y,subthread:X}=Q,G=J.subagents[X.threadID];if(!G){if(G={subThreadID:Y.id,parentToolID:X.toolUse.id,taskDescription:X.toolUse.input.description||"Task",isCompleted:!1,agentState:{type:"idle"}},J.mainThread){let W=oJ(J.mainThread);G.isCompleted=tJ6(W,X.toolUse.id)}}let Z=NB8(Y,G.agentState),q=G.agentState===Z?G:{...G,agentState:Z},V={...J.tools},K=jC(Y).items.filter((W)=>W.type==="toolResult");for(let W of K)V[W.id]={id:W.id,subthreadID:Y.id,toolRun:W.toolResult.run,toolUse:W.toolUse};return{subagents:{...J.subagents,[X.threadID]:q},tools:V,items:J.items,viewState:J.viewState,todosList:J.todosList,mainThread:J.mainThread}}case"main-thread-patch":{let{thread:Y,subthreads:X,workerStatus:G}=Q,Z=oJ(Y),q={...J.subagents};for(let z of X){let U=q[z.threadID];if(!U)continue;let N=tJ6(Z,z.toolUse.id);q[z.threadID]={...U,isCompleted:N}}let{items:V}=jC(Y),K=qA(Y,G),W=sE({messages:Y.messages}),H=Array.isArray(W)?W:[];return{...J,subagents:q,items:V,viewState:K,todosList:H,mainThread:Y}}case"worker-status-change":{if(!J.mainThread)return J;let Y=qA(J.mainThread,Q.workerStatus);if(Y===J.viewState)return J;return{...J,viewState:Y}}default:return J}}function jC(J){let Q=[],Y=new Map,X=new Set;for(let[G,Z]of J.messages.entries()){let q=`${Z.role}-${G}`;switch(Z.role){case"assistant":{let V=Z.state.type==="streaming";for(let W of Z.content)if(W.type==="tool_use"){if(Y.set(W.id,W),V)X.add(W.id)}if(Z.content.some((W)=>W.type==="text"&&W.text.trim()||W.type==="thinking"))Q.push({type:"message",id:q,message:Z});for(let W of Z.content)if(W.type==="tool_use"){let H=!1;for(let z=G+1;z<J.messages.length;z++){let U=J.messages[z];if(U){for(let N of U.content)if(N.type==="tool_result"&&N.toolUseID===W.id){H=!0;break}}if(H)break}if(!H)Q.push({type:"toolResult",id:W.id,toolUse:W,toolResult:{type:"tool_result",toolUseID:W.id,run:{status:V?"in-progress":"queued"}}})}break}case"info":Q.push({type:"message",id:q,message:Z});break;case"user":{if(Z.content.some((K)=>K.type==="text"&&K.text.trim()||K.type==="image"))Q.push({type:"message",id:q,message:Z});for(let K of Z.content)if(K.type==="tool_result"){let W=Y.get(K.toolUseID)??NX(J,K.toolUseID);if(!W)throw Error(`(bug) tool use ${K.toolUseID} not found`);Q.push({type:"toolResult",id:K.toolUseID,toolUse:W,toolResult:K})}break}}}return{items:Q}}function tJ6(J,Q){let Y=J.get(Q);return(Y&&W2(Y.run))??!1}function NB8(J,Q){let Y=J.messages.at(-1);if(Y?.content.some((G)=>G.type==="tool_result"&&G.run.status==="blocked-on-user"))return f.info("Subagent status: idle (blocked-on-user)",{threadID:J.id}),{type:"idle"};if(jC(J).items.some((G)=>G.type==="toolResult"&&G.toolResult.run.status==="in-progress")){let G=Q?.type==="running-tools"?Q.startTime:Date.now();return f.info("Subagent status: running-tools",{threadID:J.id,startTime:G,hasStartTime:!!G}),{type:"running-tools",startTime:G}}if(Y&&Y.role==="assistant"&&Y.state.type==="streaming")switch(Y.content.at(-1)?.type){case"text":return f.info("Subagent status: streaming-text",{threadID:J.id}),{type:"streaming-text"};case"thinking":return f.info("Subagent status: streaming-thinking",{threadID:J.id}),{type:"streaming-thinking"};case"tool_use":{let Z=Q?.type==="running-tools"?Q.startTime:Date.now();return f.info("Subagent status: running-tools (streaming tool_use)",{threadID:J.id,startTime:Z,hasStartTime:!!Z}),{type:"running-tools",startTime:Z}}default:return f.info("Subagent status: streaming-text (default)",{threadID:J.id}),{type:"streaming-text"}}return f.info("Subagent status: idle (default)",{threadID:J.id}),{type:"idle"}}class F_1 extends G6{props;constructor(J){super();this.props=J}createState(){return new eJ6}}class eJ6 extends X6{state={subagents:{},tools:{},items:[],viewState:{state:"initial",interactionState:!1,toolState:{running:0,blocked:0}},todosList:[],mainThread:null};workerController;subscriptions=[];recentThreadIDs=[];currentWorker;constructor(){super();this.workerController=null,this.currentWorker=null}addToRecentThreads(J){this.setState(()=>{let Q=this.recentThreadIDs.indexOf(J);if(Q!==-1)this.recentThreadIDs.splice(Q,1);if(this.recentThreadIDs.unshift(J),this.recentThreadIDs.length>50)this.recentThreadIDs.pop()})}initState(){let{threadService:J,worker:Q}=this.widget.props;this.workerController=new z_1(J),this.currentWorker=Q,this.setupSubscriptions(Q),this.addToRecentThreads(Q.thread.id)}dispose(){this.cleanup()}didUpdateWidget(J){if(J.props.threadService!==this.widget.props.threadService||J.props.worker!==this.widget.props.worker)this.cleanup(),this.setupSubscriptions(this.widget.props.worker)}setupSubscriptions(J){this.workerController.registerWorker(J);let Q=this.workerController.observeThread(J.thread.id),Y=Q.mainThread.subscribe((Z)=>{this.dispatch({type:"main-thread-patch",thread:Z.mainThread,subthreads:Z.subthreads,workerStatus:Z.workerStatus})});this.subscriptions.push(Y);let X=Q.subthreads.subscribe((Z)=>{this.dispatch({type:"subthread-patch",thread:Z.thread,subthread:Z.subthread})});this.subscriptions.push(X);let G=Q.workerStatus.subscribe((Z)=>{this.dispatch({type:"worker-status-change",workerStatus:Z.status})});this.subscriptions.push(G)}cleanup(){this.subscriptions.forEach((J)=>J.unsubscribe()),this.subscriptions=[]}switchWorker(J){this.cleanup(),this.setState(()=>{this.currentWorker=J}),this.setState(()=>{this.state={subagents:{},tools:{},items:[],viewState:{state:"initial",interactionState:!1,toolState:{running:0,blocked:0}},todosList:[],mainThread:null}}),this.setupSubscriptions(J),this.addToRecentThreads(J.thread.id)}dispatch(J){this.setState(()=>{this.state=BB8(this.state,J)})}getThreadData(){let J=Object.values(this.state.tools).map((Z)=>({toolUse:Z.toolUse,toolRun:Z.toolRun,subthreadID:Z.subthreadID})),Q={};for(let Z of Object.values(this.state.subagents)){let q=J.filter((V)=>V.subthreadID===Z.subThreadID);Q[Z.parentToolID]=q}let Y=(Z)=>Z===o5||Z===q9||Z===BX,X=new Map;for(let Z of this.state.items)if(Z.type==="toolResult"&&Y(Z.toolUse.name))X.set(Z.toolUse.id,{toolUseId:Z.toolUse.id,toolName:Z.toolUse.name,toolRun:Z.toolResult.run});let G=Array.from(X.values());for(let{toolUseId:Z,toolRun:q}of G){let V=[],K;if(q.status==="in-progress"||q.status==="done"||q.status==="error"||q.status==="cancelled")K=q.progress;if(K){let W=0;for(let H of K)if(H.tool_uses)for(let z of H.tool_uses){let U=`${Z}:progress:${W++}`;V.push({toolUse:aE(z.tool_name,z.input,U),toolRun:{status:z.status}})}}Q[Z]=V}return{...this.state,subagents:Object.values(this.state.subagents),subagentActiveTools:J,subagentToolsByParentID:Q}}build(J){let Q=this.getThreadData();return this.widget.props.builder(J,Q,this.workerController,(Y)=>this.switchWorker(Y),()=>this.currentWorker,this.recentThreadIDs)}}class U_1 extends G6{props;constructor(J){super({key:J.key});this.props=J}createState(){return new JQ6}}class JQ6 extends X6{build(J){let Y=x6.of(J).colors,{todos:X,title:G="TODOs"}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new U0({width:0,height:0});let Z=X.map((q)=>this.buildTodoItem(q,Y));return new J6({child:new c6({padding:f0.symmetric(1,0),child:new s0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new d1({text:new J1(G,new H1({bold:!0,color:Y.foreground}))}),...Z]})})})}buildTodoItem(J,Q){let Y=this.getStatusIcon(J.status),X=J.status==="completed",G=new H1({bold:J.status==="in-progress",color:Q.foreground,dim:X}),Z=new H1({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Q.foreground,dim:X});return new Q4({crossAxisAlignment:"start",children:[new d1({text:new J1(Y,G)}),new U0({width:1}),new z4({child:new d1({text:new J1(J.content,Z)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class B_1 extends I6{ad;onDismiss;onButtonClick;constructor({key:J,ad:Q,onDismiss:Y,onButtonClick:X}){super({key:J});this.ad=Q,this.onDismiss=Y,this.onButtonClick=X}build(J){let Q=x6.of(J),Y=Q.colors.primary,X=Q.colors.foreground;return new J6({decoration:new O8(void 0,new p4(new P4(Y,1,"rounded"),new P4(Y,1,"rounded"),void 0,new P4(Y,1,"rounded"))),child:new c6({padding:f0.horizontal(1),child:new s0({children:[new Q4({crossAxisAlignment:"start",children:[new z4({child:new d1({text:new J1(this.ad.content,new H1({color:X}))})}),new U0({width:4}),new i2({uri:"https://ampcode.com/free",text:"Ad",style:new H1({color:X,dim:!0}),onError:(G)=>{}})]}),new Q4({crossAxisAlignment:"start",children:[new rC1({text:this.ad.buttonLabel,onPressed:()=>this.onButtonClick?.(),padding:f0.horizontal(1),color:Y,reverse:!0}),new U0({width:2}),new d1({text:new J1(this.ad.destinationUrlHostname,new H1({color:X,dim:!0}))})]})]})})})}}class N_1 extends G6{props;constructor(J){super();this.props=J}createState(){return new QQ6(this.props.autofocus??!0)}}class QQ6 extends X6{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=(V)=>{if(V.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(V.ctrlKey&&V.key==="c"||V.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Y=U8.sizeOf(J),X=Math.min(60,Y.width-4),G=Y.height-4,Z=[];if(this.widget.props.title)Z.push(new d1({text:new J1(this.widget.props.title,new H1({bold:!0,color:O1.blue}))}),new U0({height:1}));if(this.widget.props.message)Z.push(new d1({text:new J1(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)Z.push(new U0({height:1}));let q=[];if(this.widget.props.showCopyOption)q.push(new d1({text:new J1("Enter to copy",new H1({dim:!0}))}));return q.push(new d1({text:new J1("Escape to close",new H1({dim:!0}))})),Z.push(new Q4({children:q.flatMap((V,K)=>K<q.length-1?[V,new U0({width:1}),new d1({text:new J1("•",new H1({dim:!0}))}),new U0({width:1})]:[V]),mainAxisSize:"min"})),new H8({child:new J6({constraints:new r6(X,X,0,G),decoration:new O8(O1.default(),new p4(new P4(O1.blue,1,"rounded"),new P4(O1.blue,1,"rounded"),new P4(O1.blue,1,"rounded"),new P4(O1.blue,1,"rounded"))),padding:new f0(2,2,2,2),child:new Y9({autofocus:this.autofocus,onKey:Q,child:new s0({children:Z,mainAxisSize:"min"})})})})}}class i81 extends Error{constructor(J="Command timed out"){super(J);this.name="CommandTimeoutError",Object.setPrototypeOf(this,i81.prototype)}}class n81 extends Error{constructor(J){let Q=`${J.noun}: ${J.verb} command cancelled`;super(Q);this.name="CommandCancelledError",Object.setPrototypeOf(this,n81.prototype)}}function D_1(J){let Q=J.match(/"([^"]*)"|'([^']*)'|([^\s"']+)/g);if(!Q)return[];return Q.map((Y)=>{if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);return Y})}$U();L0();import{spawn as DB8}from"node:child_process";import{promises as MB8}from"node:fs";function YQ6(J){return J.kind==="executable"}function XQ6(J){return J.kind==="markdown"}var wz=50000,GQ6=300000;async function M_1(J,Q,Y,X={}){let{timeoutMs:G=GQ6,signal:Z,source:q}=X;try{let V=await Y.getCommand(J,q);if(!V)return{success:!1,output:"",error:`Command '${J}' not found`};if(!await Y.isCommandAvailable(J,q))return{success:!1,output:"",error:`Command '${J}' is not available for execution`};if(f.debug("Executing command",{commandName:J,filePath:V.filePath,args:Q}),XQ6(V))return await LB8(V,Q);else if(YQ6(V))return await AB8(V,Q,G,Z);else return{success:!1,output:"",error:"Unsupported command type"}}catch(V){return f.error("Failed to execute command",{commandName:J,error:V}),{success:!1,output:"",error:V instanceof Error?V.message:"Unknown error occurred"}}}async function LB8(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Y=await MB8.readFile(J.filePath,"utf8");return{success:!0,output:(Y.length>wz?Y.slice(0,wz)+`
4732
4731
  ... (output truncated at ${wz} characters)`:Y).trim(),exitCode:0}}catch(Y){return{success:!1,output:"",error:Y instanceof Error?Y.message:"Failed to read markdown file"}}}async function AB8(J,Q,Y=GQ6,X){return new Promise((G)=>{let[Z,q]=OB8(J,Q);f.debug("Spawning command",{spawnCommand:Z,spawnArgs:q.slice(0,10),filePath:J.filePath,timeoutMs:Y});let V=jO0(X),K=!1,W=setTimeout(()=>{K=!0,V.abort(),f.warn("Command execution timed out",{commandName:J.name,timeoutMs:Y})},Y),H=DB8(Z,q,{stdio:["pipe","pipe","pipe"],signal:V.signal,detached:!0}),z=[],U=[],N=0;H.stdout?.on("data",(M)=>{let L=M.toString();if(N+=L.length,N<=wz)z.push(L);else{let A=wz-(N-L.length);if(A>0)z.push(L.slice(0,A))}}),H.stderr?.on("data",(M)=>{let L=M.toString();if(N+=L.length,N<=wz)U.push(L);else{let A=wz-(N-L.length);if(A>0)U.push(L.slice(0,A))}}),H.on("close",(M)=>{if(clearTimeout(W),K){G({success:!1,output:z.join(""),error:`Command timed out after ${Y}ms`,exitCode:void 0});return}if(V.signal.aborted){G({success:!1,output:z.join(""),error:"The command was aborted",exitCode:M??void 0});return}let L=M===0||M===1,A=z.join(""),E=U.join(""),P=A;if(!L&&!A.trim()&&E.trim())P=E;else if(E.trim())P+=A?`
4733
4732
  ${E}`:E;if(N>wz)P+=`
4734
- ... (output truncated at ${wz} characters)`;G({success:L,output:P.trim(),error:!L?E.trim()||"Command failed":void 0,exitCode:M??void 0})}),H.on("error",(M)=>{clearTimeout(W);let L=M.message;if(K)L=`Command timed out after ${Y}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")L="The command was aborted";G({success:!1,output:z.join(""),error:L})})})}function OB8(J,Q){let{filePath:Y,interpreter:X,extension:G}=J;if(process.platform==="win32")return EB8(Y,X?[...X]:null,G,Q);else return wB8(Y,X?[...X]:null,G,Q)}function wB8(J,Q,Y,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function EB8(J,Q,Y,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Y.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}L0();C$();H2();hW();ZZ();u$();QH();BH();b7();l_();o0();var UQ6=N6(WP(),1);import{writeFile as HQ6}from"fs/promises";import zQ6 from"path";L0();ZZ();class L_1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Y])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1764165115-gcd064d"},parameters:{metadata:{count:Y}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await eo(Q,this.configService)}catch(Q){f.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class A_1 extends G6{props;constructor(J){super();this.props=J}createState(){return new ZQ6}}class ZQ6 extends X6{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Y)=>{this.setState(()=>{this._state=Y(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class $Q6 extends X6{controller=new hZ;focusNode=new c8({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Q=x6.of(J),{colors:Y,app:X}=Q,G=this.widget.props.isRequiredArg??!0,Z=this.controller.text.trim().length>0,q=!G||Z,V=p4.all(new P4(Y.foreground,1,"solid")),K=new JO({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(N)=>{let M=N.trim();if(G&&M.length===0)return;this.widget.props.onSubmit(M)},autofocus:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),W=new Q4({children:[new J6({decoration:{color:O1.default()},child:new d1({text:new J1(">",new H1({color:Y.foreground}))})}),new z4({child:K})]}),H=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,[new J1("Command: ",new H1({color:Y.foreground})),new J1(this.widget.props.commandName,new H1({color:O1.yellow,bold:!0}))])})}),z=[];if(q)z.push(new J1("Enter",new H1({color:X.keybind}))),z.push(new J1(" to submit, ",new H1({color:Y.foreground,dim:!0})));z.push(new J1("Esc",new H1({color:X.keybind}))),z.push(new J1(" to cancel",new H1({color:Y.foreground,dim:!0})));let U=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,z)})});return new J6({decoration:{border:V,color:O1.default()},padding:f0.all(1),child:new s0({children:[H,new U0({height:1}),W,new c5,U]})})}}class a81 extends G6{props;constructor(J){super();this.props=J}createState(){return new $Q6}}QH();class qQ6 extends X6{controller=new hZ;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new c8({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=(J)=>{if(this.imageAttachments.length>=qU)return!1;let Q=zC(J);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,J]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(J){let Q=x6.of(J),{colors:Y,app:X}=Q,Z=U8.of(J).size.height,q=Math.max(Math.floor(Z*0.5),10),V=new BO({controller:this.controller,triggers:[new VN],completionBuilder:this.widget.props.completionBuilder,ampURL:this.widget.props.ampURL,onSubmitted:(N)=>{this.widget.props.onSubmit(N.trim(),this.imageAttachments)},theme:Y,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:E9.instance.tuiInstance.clipboard,showMenuBelow:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),K=new Y9({focusNode:this.focusNode,child:V}),W=new J6({constraints:new r6({maxHeight:q}),padding:f0.symmetric(1,0),child:K}),H=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,[new J1("Command: ",new H1({color:Y.foreground})),new J1(this.widget.props.commandName,new H1({color:O1.yellow,bold:!0}))])})}),z=new J6({padding:f0.symmetric(1,0),child:new d1({text:this.isConfirmingClearInput?new J1("",void 0,[new J1("Esc",new H1({color:X.keybind})),new J1(" again to clear input",new H1({color:Y.foreground,dim:!0}))]):new J1("",void 0,[new J1("Press ",new H1({color:Y.foreground,dim:!0})),new J1("Enter",new H1({color:X.keybind})),new J1(" to submit, ",new H1({color:Y.foreground,dim:!0})),new J1("Esc",new H1({color:X.keybind})),new J1(" to clear",new H1({color:Y.foreground,dim:!0}))])})}),U=[H,new U0({height:1}),new z4({child:W}),new U0({height:1}),z];return new J6({decoration:{border:p4.all(new P4(Y.foreground,1,"solid")),color:O1.default()},padding:f0.all(1),child:new s0({children:U})})}}class NO extends G6{props;constructor(J){super();this.props=J}createState(){return new qQ6}}function VQ6(J){let Y=new Date().getTime()-J.getTime(),X=Math.floor(Y/60000),G=Math.floor(Y/3600000),Z=Math.floor(Y/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(G<24)return`${G}h ago`;if(Z<7)return`${Z}d ago`;return J.toLocaleDateString()}class O_1 extends I6{props;debugLabel="ThreadFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((G,Z)=>Z.pubDate.getTime()-G.pubDate.getTime()),Y=Math.max(0,...Q.map((G)=>VQ6(G.pubDate).length));return new yK({items:Q,getLabel:(G)=>G.title,onAccept:(G)=>this.props.onSelect?.(G),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No thread feed entries available",maxRenderItems:100,renderItem:(G,Z,q,V)=>{let K=x6.of(V),{colors:W}=K,H=Z?O1.yellow:void 0,z=Z?O1.black:W.foreground,U=O1.index(8),N=G.authors.map((L)=>L.name).join(", ")||"Community",M=(L,A)=>new U0({width:A,child:Q4.end([new d1({text:new J1(L,new H1({color:U}))})])});return new J6({decoration:H?{color:H}:void 0,padding:f0.symmetric(2,0),child:new Q4({children:[new z4({child:new d1({text:new J1(G.title,new H1({color:z})),overflow:"ellipsis",maxLines:1})}),new U0({width:2}),new d1({text:new J1(N,new H1({color:U})),maxLines:1}),new U0({width:2}),M(VQ6(G.pubDate),Y)]})})}})}}class w_1 extends I6{props;constructor(J){super();this.props=J}build(){return new H8({child:new d1({text:new J1("",void 0,[new J1(`Forked to new thread:
4733
+ ... (output truncated at ${wz} characters)`;G({success:L,output:P.trim(),error:!L?E.trim()||"Command failed":void 0,exitCode:M??void 0})}),H.on("error",(M)=>{clearTimeout(W);let L=M.message;if(K)L=`Command timed out after ${Y}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")L="The command was aborted";G({success:!1,output:z.join(""),error:L})})})}function OB8(J,Q){let{filePath:Y,interpreter:X,extension:G}=J;if(process.platform==="win32")return EB8(Y,X?[...X]:null,G,Q);else return wB8(Y,X?[...X]:null,G,Q)}function wB8(J,Q,Y,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function EB8(J,Q,Y,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Y.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}L0();C$();H2();hW();ZZ();u$();QH();BH();b7();l_();o0();var UQ6=N6(WP(),1);import{writeFile as HQ6}from"fs/promises";import zQ6 from"path";L0();ZZ();class L_1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Y])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1764172241-gaca8cf"},parameters:{metadata:{count:Y}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await eo(Q,this.configService)}catch(Q){f.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class A_1 extends G6{props;constructor(J){super();this.props=J}createState(){return new ZQ6}}class ZQ6 extends X6{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Y)=>{this.setState(()=>{this._state=Y(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class $Q6 extends X6{controller=new hZ;focusNode=new c8({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Q=x6.of(J),{colors:Y,app:X}=Q,G=this.widget.props.isRequiredArg??!0,Z=this.controller.text.trim().length>0,q=!G||Z,V=p4.all(new P4(Y.foreground,1,"solid")),K=new JO({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(N)=>{let M=N.trim();if(G&&M.length===0)return;this.widget.props.onSubmit(M)},autofocus:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),W=new Q4({children:[new J6({decoration:{color:O1.default()},child:new d1({text:new J1(">",new H1({color:Y.foreground}))})}),new z4({child:K})]}),H=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,[new J1("Command: ",new H1({color:Y.foreground})),new J1(this.widget.props.commandName,new H1({color:O1.yellow,bold:!0}))])})}),z=[];if(q)z.push(new J1("Enter",new H1({color:X.keybind}))),z.push(new J1(" to submit, ",new H1({color:Y.foreground,dim:!0})));z.push(new J1("Esc",new H1({color:X.keybind}))),z.push(new J1(" to cancel",new H1({color:Y.foreground,dim:!0})));let U=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,z)})});return new J6({decoration:{border:V,color:O1.default()},padding:f0.all(1),child:new s0({children:[H,new U0({height:1}),W,new c5,U]})})}}class a81 extends G6{props;constructor(J){super();this.props=J}createState(){return new $Q6}}QH();class qQ6 extends X6{controller=new hZ;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new c8({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=(J)=>{if(this.imageAttachments.length>=qU)return!1;let Q=zC(J);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,J]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(J){let Q=x6.of(J),{colors:Y,app:X}=Q,Z=U8.of(J).size.height,q=Math.max(Math.floor(Z*0.5),10),V=new BO({controller:this.controller,triggers:[new VN],completionBuilder:this.widget.props.completionBuilder,ampURL:this.widget.props.ampURL,onSubmitted:(N)=>{this.widget.props.onSubmit(N.trim(),this.imageAttachments)},theme:Y,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:E9.instance.tuiInstance.clipboard,showMenuBelow:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),K=new Y9({focusNode:this.focusNode,child:V}),W=new J6({constraints:new r6({maxHeight:q}),padding:f0.symmetric(1,0),child:K}),H=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1("",void 0,[new J1("Command: ",new H1({color:Y.foreground})),new J1(this.widget.props.commandName,new H1({color:O1.yellow,bold:!0}))])})}),z=new J6({padding:f0.symmetric(1,0),child:new d1({text:this.isConfirmingClearInput?new J1("",void 0,[new J1("Esc",new H1({color:X.keybind})),new J1(" again to clear input",new H1({color:Y.foreground,dim:!0}))]):new J1("",void 0,[new J1("Press ",new H1({color:Y.foreground,dim:!0})),new J1("Enter",new H1({color:X.keybind})),new J1(" to submit, ",new H1({color:Y.foreground,dim:!0})),new J1("Esc",new H1({color:X.keybind})),new J1(" to clear",new H1({color:Y.foreground,dim:!0}))])})}),U=[H,new U0({height:1}),new z4({child:W}),new U0({height:1}),z];return new J6({decoration:{border:p4.all(new P4(Y.foreground,1,"solid")),color:O1.default()},padding:f0.all(1),child:new s0({children:U})})}}class NO extends G6{props;constructor(J){super();this.props=J}createState(){return new qQ6}}function VQ6(J){let Y=new Date().getTime()-J.getTime(),X=Math.floor(Y/60000),G=Math.floor(Y/3600000),Z=Math.floor(Y/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(G<24)return`${G}h ago`;if(Z<7)return`${Z}d ago`;return J.toLocaleDateString()}class O_1 extends I6{props;debugLabel="ThreadFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((G,Z)=>Z.pubDate.getTime()-G.pubDate.getTime()),Y=Math.max(0,...Q.map((G)=>VQ6(G.pubDate).length));return new yK({items:Q,getLabel:(G)=>G.title,onAccept:(G)=>this.props.onSelect?.(G),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No thread feed entries available",maxRenderItems:100,renderItem:(G,Z,q,V)=>{let K=x6.of(V),{colors:W}=K,H=Z?O1.yellow:void 0,z=Z?O1.black:W.foreground,U=O1.index(8),N=G.authors.map((L)=>L.name).join(", ")||"Community",M=(L,A)=>new U0({width:A,child:Q4.end([new d1({text:new J1(L,new H1({color:U}))})])});return new J6({decoration:H?{color:H}:void 0,padding:f0.symmetric(2,0),child:new Q4({children:[new z4({child:new d1({text:new J1(G.title,new H1({color:z})),overflow:"ellipsis",maxLines:1})}),new U0({width:2}),new d1({text:new J1(N,new H1({color:U})),maxLines:1}),new U0({width:2}),M(VQ6(G.pubDate),Y)]})})}})}}class w_1 extends I6{props;constructor(J){super();this.props=J}build(){return new H8({child:new d1({text:new J1("",void 0,[new J1(`Forked to new thread:
4735
4734
 
4736
4735
  `,new H1({color:O1.white,dim:!0})),new J1(`"${this.props.newThreadTitle||"Untitled"}"`,new H1({color:O1.white}))]),textAlign:"center"})})}}class Ez extends G6{props;constructor(J){super();this.props=J}createState(){return new KQ6}}class KQ6 extends X6{_spinner=new bK;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Q=x6.of(J),{colors:Y}=Q,X=p4.all(new P4(Y.foreground,1,"solid")),G=this._spinner.toBraille(),Z=new d1({textAlign:"center",text:new J1("",void 0,[new J1(G,new H1({color:O1.yellow})),new J1(" ",void 0),new J1(this.widget.props.message,new H1({color:Y.foreground}))])}),V=[new z4({child:new s0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[Z]})})];if(this.widget.props.onAbort)V.push(new U0({height:2,child:new J6({padding:f0.symmetric(2,0),child:new d1({text:new J1("",new H1({dim:!0}),[new J1("Press ",new H1({color:Y.foreground})),new J1("Esc",new H1({color:Y.info})),new J1(" to cancel",new H1({color:Y.foreground}))])})})}));let K=new J6({decoration:new O8(O1.default(),X),child:new U0({width:60,height:7,child:new s0({mainAxisAlignment:"start",children:V})})});if(this.widget.props.onAbort)return new Y9({debugLabel:"LoadingDialog",autofocus:!0,onKey:(W)=>{if(W.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:K});return K}}class Iz extends G6{props;constructor(J){super();this.props=J}createState(){return new WQ6}}class WQ6 extends X6{dispose(){super.dispose()}isWidgetMessage(J){return J instanceof xK}build(J){let Q=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let W=J81(Q);return{title:W.title,type:W.type,description:W.description}})(),X=Y.type==="error"?O1.red:O1.yellow,G=p4.all(new P4(O1.default(),1,"solid")),Z=new J6({padding:f0.symmetric(1,0),child:new d1({text:new J1(Y.title,new H1({color:X,bold:!0}))})}),q=this.isWidgetMessage(Q)?Q.widget:new d1({text:new J1(Y.description,new H1({color:O1.default()})),selectable:!0}),V=new z4({child:new sA({child:new J6({padding:f0.symmetric(1,0),child:q})})}),K=new J6({padding:f0.symmetric(1,0),child:new d1({text:this.widget.props.onRetry?new J1("",void 0,[new J1("Press ",new H1({color:O1.default(),dim:!0})),new J1("R",new H1({color:O1.yellow})),new J1(" to retry, ",new H1({color:O1.default(),dim:!0})),new J1("Esc",new H1({color:O1.yellow})),new J1(" to cancel",new H1({color:O1.default(),dim:!0}))]):new J1("Press any key to close",new H1({color:O1.default(),dim:!0,italic:!0}))})});return new Y9({onKey:(W)=>{if(this.widget.props.onRetry&&W.key==="r")return this.widget.props.onRetry(),"handled";if(W.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!0,child:new J6({decoration:{border:G,color:O1.default()},padding:f0.all(1),child:new s0({mainAxisAlignment:"center",children:[Z,new U0({height:1}),V,K]})})})}}class E_1 extends I6{build(){return new H8({child:new d1({text:new J1("",void 0,[new J1(`✓ Thread Shared
4737
4736
 
@@ -4817,7 +4816,7 @@ https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_di
4817
4816
  `)?`${V}...`:G,W=new H1({color:O1.index(8)}),H=[new J1(K,W)];if(q>0){let z=new H1({color:Y.success});for(let U=1;U<=q;U++)H.push(new J1(" ")),H.push(new J1(`[${U}]`,z))}return new c6({padding:f0.only({bottom:0}),child:new Q4({crossAxisAlignment:"start",children:[new c6({padding:f0.only({right:1}),child:new d1({text:new J1("•",new H1({color:O1.index(8)}))})}),new z4({child:new d1({text:new J1("",void 0,H)})})]})})}}class e_1 extends G6{createState(){return new $Y6}}class $Y6 extends X6{_animationTimer;_visible=!0;initState(){super.initState(),this._startAnimation()}dispose(){this._stopAnimation(),super.dispose()}_startAnimation(){this._animationTimer=setInterval(()=>{this.setState(()=>{this._visible=!this._visible})},500)}_stopAnimation(){if(this._animationTimer)clearInterval(this._animationTimer),this._animationTimer=void 0}build(J){let Q=new H1({color:O1.red}),Y=new H1({color:this._visible?O1.red:O1.transparent()});return new Q4({children:[new d1({text:new J1("⏺",Y)}),new U0({width:1}),new d1({text:new J1("Replay",Q)})]})}}class Jk1 extends I6{entry;constructor({key:J,entry:Q}){super({key:J});this.entry=Q}build(J){let Q=x6.of(J),Y=Q.colors.secondary,X=Q.colors.foreground,G=this.entry.authors.map((Z)=>Z.name).join(", ");return new J6({decoration:new O8(void 0,new p4(new P4(Y,1,"rounded"),new P4(Y,1,"rounded"),void 0,new P4(Y,1,"rounded"))),child:new c6({padding:f0.horizontal(1),child:new s0({children:[new Q4({crossAxisAlignment:"start",children:[new z4({child:new d1({text:new J1(this.entry.title,new H1({color:X,bold:!0}))})}),new U0({width:4}),new d1({text:new J1(G||"Community",new H1({color:X,dim:!0}))})]}),new Q4({crossAxisAlignment:"start",children:[new z4({child:new d1({text:new J1(this.truncateDescription(this.entry.description),new H1({color:X,dim:!0}))})}),new U0({width:2}),new i2({uri:this.entry.link,text:"View Thread",style:new H1({color:Y,underline:!0}),onError:()=>{}})]})]})})})}truncateDescription(J){let Y=J.replace(/\s+/g," ").trim();if(Y.length<=80)return Y;return Y.slice(0,79)+"…"}}o0();function yN8(J){let Y=new Date().getTime()-J.getTime(),X=Math.floor(Y/3600000),G=Math.floor(X/24),Z=Math.floor(G/7),q=Math.floor(G/30);if(X<1)return"Just now";if(X<24)return`${X}h ago`;if(G<7)return`${G}d ago`;if(Z<=4)return`${Z}w ago`;return`${q}mo ago`}class Qk1{threadHistoryService;constructor(J){this.threadHistoryService=J}async fetchThreadSummaries(J=""){try{let Q=await new Promise((Y)=>{let X=this.threadHistoryService.observeThreadList().subscribe((G)=>{X.unsubscribe(),Y(G)})});return{ok:!0,threads:this.formatThreadSummaries(Q,J)}}catch(Q){return{ok:!1,errorMsg:Q instanceof Error?Q.message:"An unexpected error occurred"}}}observeThreadSummaries(J=""){return this.threadHistoryService.observeHistory().pipe(q6((Q)=>this.formatThreadSummaries(Q,J)))}formatThreadSummaries(J,Q){return J.filter((X)=>{if(!Q.trim())return!0;let G=X.title?.toLowerCase()||"untitled",Z=X.id.toLowerCase(),q=Q.toLowerCase();return G.includes(q)||Z.includes(q)}).map((X)=>{let G=new Date(X.userLastInteractedAt),Z=yN8(G),q=X.id.slice(-8),V=X.env?.initial.trees?.[0]?.uri;return{id:X.id,title:X.title||"Untitled",updatedAt:new Date(X.userLastInteractedAt).toISOString(),description:{timeAgo:Z,title:X.title||"Untitled",shortThreadID:q},diffStats:X.summaryStats?.diffStats,workspaceURI:V,parentRelationships:X.parentRelationships}})}}L0();N9();class Yk1{currentId=null;current=null;subscribeTimer=null;subscription=null;listeners=[];threadService=null;scrollController=new p3;constructor(){}setThreadService(J){this.threadService=J}async select(J){if(!this.threadService){f.error("TUI assert failed: ThreadService used before being set");return}if(this.currentId===J)return;this.cancelTimerAndSubscription(),this.currentId=J;let Q=await this.threadService.get(J);if(Q){if(this.currentId===J)this.current=Q,this.notifyListeners()}this.subscribeTimer=setTimeout(()=>{this.subscribeLive(J)},1000)}clear(){this.cancelTimerAndSubscription(),this.currentId=null,this.current=null,this.notifyListeners()}addListener(J){this.listeners.push(J)}removeListener(J){let Q=this.listeners.indexOf(J);if(Q!==-1)this.listeners.splice(Q,1)}dispose(){this.cancelTimerAndSubscription(),this.scrollController.dispose(),this.listeners=[]}subscribeLive(J){if(!this.threadService){f.error("TUI assert failed: ThreadService used before being set");return}if(this.currentId!==J)return;this.subscription=this.threadService.observePatches(J).pipe(FM()).subscribe((Q)=>{if(this.currentId===J)this.current=Q,this.notifyListeners()})}cancelTimerAndSubscription(){if(this.subscribeTimer)clearTimeout(this.subscribeTimer),this.subscribeTimer=null;if(this.subscription)this.subscription.unsubscribe(),this.subscription=null}notifyListeners(){for(let J of this.listeners)J(this.current)}}function qY6(J,Q){switch(J){case"update-available":return[new J1("A newer Amp is available. Run ",new H1({color:Q.foreground,dim:!0})),new J1("amp update",new H1({color:Q.warning}))];case"updated":return null;case"updated-with-warning":return[new J1("Update complete, run ",new H1({color:Q.foreground,dim:!0})),new J1("amp update",new H1({color:Q.warning})),new J1(" to see warnings",new H1({color:Q.foreground,dim:!0}))];case"update-error":return[new J1("Update failed, run ",new H1({color:Q.foreground,dim:!0})),new J1("amp update",new H1({color:Q.warning})),new J1(" to see warnings",new H1({color:Q.foreground,dim:!0}))];case"hidden":return null}}async function bN8(J){return new Promise((Q)=>{vN8("git",["branch","--show-current"],{cwd:J},(Y,X)=>{if(Y){Q(null);return}let G=X.trim();Q(G||null)})})}class HY6 extends G6{dependencies;constructor(J){super();this.dependencies=J}createState(){return new zY6}}class zY6 extends X6{themeColors=null;themeApp=null;selectionListener=null;ideStatus=null;connectedClientsStatus=null;connectedClientsStatusExpanded=!1;randomAd=null;adSubscription=null;threadLoadSubscription=null;lastAdImpressionId=null;lastUserInteractionTime=Date.now();isConfirmingExit=!1;isExiting=!1;isConfirmingClearInput=!1;isConfirmingCancelProcessing=!1;copyMessageTimer=null;isShowingHelp=!1;isShowingConsoleOverlay=!1;isShowingConfirmationOverlay=!1;isShowingFileChangesOverlay=!1;isShowingCostBreakdownOverlay=!1;confirmationOverlayContent="";exitConfirmTimeout=null;clearInputConfirmTimeout=null;cancelProcessingConfirmTimeout=null;historyIndex=-1;historyDraft=null;bashInvocations=[];dismissedEphemeralErrorKey=null;currentTitle=void 0;currentShellModeStatus=void 0;imageAttachments=[];displayMessage=null;executingCommand=null;isShowingJetBrainsInstaller=!1;isShowingIdePicker=!1;isShowingPalette=!1;paletteInitialCommandId=null;threadsForPicker=[];isLoadingThreads=!1;threadPreviewController=new Yk1;previewThread=null;planScrollController=(()=>{let J=new p3;return J.followMode=!1,J})();todoScrollController=(()=>{let J=new p3;return J.followMode=!1,J})();showingSelectionCopiedHint=!1;isShowingStandaloneThreadPicker=!1;filterThreadPickerByWorkspace=!0;agentModePulseSeq=0;currentGitBranch=null;messageViewFocusNode=new c8({debugLabel:"MessageViewFocus"});autocompleteFocusNode=new c8({debugLabel:"AutocompleteFocus"});isTextfieldAndAutocompleteFocused=!1;submitDisabledHint=null;submitDisabledHintTimer=null;showingCannotToggleMessage=null;showImageUnsupportedHint=!1;imageUnsupportedHintTimer=null;adActionModal=null;threadFeedReader=null;currentThreadFeedEntry=null;threadFeedEntries=[];threadFeedSubscription=null;threadFeedRotationTimer=null;threadFeedHidden=!1;threadFeedShownIDs=new Set;threadFeedLatestShownPubDate=null;currentUserInfo=null;bottomGridUserHeight=void 0;bottomGridDragStartY=null;bottomGridDragStartHeight=null;pendingMCPServers=[];mcpTrustSubscription=null;agentModeSubscription=null;currentAgentMode="smart";hasToggledAgentMode=!1;inMemoryAgentModeOverride=null;cachedVisibleModes=uG();freeTierStatus=void 0;tryOpus=!1;updateState="hidden";updateServiceSubscription=null;isMessageViewInSelectionMode=!1;threadBackStack=[];threadForwardStack=[];replayDisplayedMessages=[];replayAbortController=new AbortController;replayTypingTimer=null;async initThreadFeed(){let Q=(await M6(this.widget.dependencies.configService.config)).settings.url,Y=Q.includes("localhost")||Q.includes("127.0.0.1");try{let q=await this.widget.dependencies.internalAPIClient.getUserInfo({},{config:this.widget.dependencies.configService});if(q.ok){let V=q.result,K="user"in V?V.user:V;this.currentUserInfo={username:K.username??void 0,displayName:K.displayName??void 0};let W="ffe10a0c-6c42-41ce-a3a6-38990fd6caf8";if(!Y&&V.team?.id!==W)return}else return}catch(q){f.debug("Failed to fetch user info for thread feed filtering",q);return}let X="/threads.rss",G=async(q,V)=>{let K=q instanceof Request?q.url:q.toString();return RQ(K,V,this.widget.dependencies.configService)},Z=Tc0();Z.get("entries").then((q)=>{if(q){let V=this.filterEntries(q);if(this.threadFeedEntries=V,V.length>0&&!this.currentThreadFeedEntry){let K=this.getNextFeedEntry(V);if(K)this.setState(()=>{this.currentThreadFeedEntry=K})}}}),this.threadFeedReader=new OC1(Z,G,{url:X}),this.threadFeedSubscription=this.threadFeedReader.stream().subscribe({next:(q)=>{try{let V=this.filterEntries(q);if(V.length>0){this.threadFeedEntries=[...V,...this.threadFeedEntries];let K=this.getNextFeedEntry(V);if(K)this.setState(()=>{this.currentThreadFeedEntry=K}),this.resetThreadFeedRotation()}}catch(V){f.error("Thread feed: error in next handler",V)}},error:(q)=>{f.error("Thread feed error:",q)}}),this.resetThreadFeedRotation()}filterEntries(J){if(!this.currentUserInfo)return J;let{username:Q,displayName:Y}=this.currentUserInfo;return J.filter((X)=>{return!X.authors.some((G)=>{let Z=G.name;if(!Z)return!1;return Q&&Z===Q||Y&&Z===Y||Q&&Z.includes(Q)})})}rotateThreadFeed(){if(this.threadFeedRotationTimer)clearInterval(this.threadFeedRotationTimer);this.threadFeedRotationTimer=setInterval(()=>{if(this.threadFeedEntries.length>0){let J=this.getNextFeedEntry(this.threadFeedEntries);if(J)this.setState(()=>{this.currentThreadFeedEntry=J})}},30000)}resetThreadFeedRotation(){this.rotateThreadFeed()}getNextFeedEntry(J){let Q=J.filter((X)=>!this.threadFeedShownIDs.has(X.id));if(this.threadFeedLatestShownPubDate)Q=Q.filter((X)=>X.pubDate.getTime()>=this.threadFeedLatestShownPubDate.getTime());if(Q.length===0&&J.length>0)this.threadFeedShownIDs.clear(),this.threadFeedLatestShownPubDate=null,Q=J;if(Q.length===0)return null;Q.sort((X,G)=>G.pubDate.getTime()-X.pubDate.getTime());let Y=Q[0];if(this.threadFeedShownIDs.add(Y.id),!this.threadFeedLatestShownPubDate||Y.pubDate>this.threadFeedLatestShownPubDate)this.threadFeedLatestShownPubDate=Y.pubDate;return Y}recordNavigation(J){this.threadBackStack.push(J),this.threadForwardStack=[]}navigateBack=async()=>{if(this.threadBackStack.length===0)return;let J=this.widget.dependencies.worker.thread.id,Q=this.threadBackStack.pop();this.threadForwardStack.push(J),await this.switchToExistingThread(Q,{recordInNavigationHistory:!1})};navigateForward=async()=>{if(this.threadForwardStack.length===0)return;let J=this.widget.dependencies.worker.thread.id,Q=this.threadForwardStack.pop();this.threadBackStack.push(J),await this.switchToExistingThread(Q,{recordInNavigationHistory:!1})};startAndSwitchToNewThread=async()=>{let J=this.widget.dependencies.worker.thread.id;this.recordNavigation(J);let Q=await this.widget.dependencies.startNewThread();return this.widget.dependencies.worker=Q,this.widget.dependencies.threadID=Q.thread.id,this.widget.dependencies.switchWorker(Q),this.setState(()=>{this.isMessageViewInSelectionMode=!1}),Q};async startReplay(){let J=this.widget.dependencies.replayMode;if(!J)return;let{thread:Q,typingEnabled:Y,baseWpm:X}=J,G=Q.messages;for(let Z=0;Z<G.length;Z++){if(this.replayAbortController.signal.aborted)break;let q=G[Z];if(!q)continue;if(Z>0)await this.replaySleep(J.messageDelayMs);if(q.role==="user"&&Y){let W=q.content.filter((H)=>H.type==="text").map((H)=>H.text).join(`
4818
4817
  `);if(W)await this.replayTypeMessage(W,X)}if(q.role==="assistant"){let W=q.content.some((U)=>U.type==="tool_use"),H=G[Z+1],z=H?.role==="user"&&H.content.some((U)=>U.type==="tool_result");if(W&&z){let U={...q,state:{type:"streaming"}};this.setState(()=>{this.replayDisplayedMessages=[...this.replayDisplayedMessages,U],this.textController.clear()});let N=J.thread.id;this.getMessageScrollController(N).scrollToBottom(),await this.replaySleep(J.toolProgressDelayMs),this.setState(()=>{this.replayDisplayedMessages=[...this.replayDisplayedMessages.slice(0,-1),q]});continue}}this.setState(()=>{this.replayDisplayedMessages=[...this.replayDisplayedMessages,q],this.textController.clear()});let V=J.thread.id;this.getMessageScrollController(V).scrollToBottom()}await this.replaySleep(J.exitDelayMs),E9.instance.stop()}async replayTypeMessage(J,Q){this.textController.clear();let Y=J.split(/(?<=\s)/),X=60000/Q;for(let G of Y){if(this.replayAbortController.signal.aborted)break;let Z=X/G.length;for(let q of G){this.textController.text=this.textController.text+q,this.textController.cursorPosition=this.textController.text.length,this.setState(()=>{});let V=0.8+Math.random()*0.4,K=Z*V;await this.replaySleep(K)}}}replaySleep(J){return new Promise((Q)=>{this.replayTypingTimer=setTimeout(Q,J)})}getEffectiveAgentMode(){return T41(this.widget.dependencies.worker.thread,this.inMemoryAgentModeOverride?{agentMode:this.inMemoryAgentModeOverride}:null,this.freeTierStatus,{"experimental.agentMode":this.currentAgentMode})}isProcessing(){let{threadState:J}=this.widget.dependencies;if(!J.mainThread)return!1;if(J.viewState.state!=="active")return!1;if(Boolean(J.viewState.inferenceState==="running"))return!0;let Y=J.items.filter((Z)=>Z.type==="toolResult").filter((Z)=>Z.toolResult.run.status==="in-progress"||Z.toolResult.run.status==="queued"),X=J.subagentActiveTools.filter((Z)=>Z.toolRun.status==="in-progress"||Z.toolRun.status==="queued");return[...Y,...X].length>0}showSubmitDisabledHint(J){if(this.submitDisabledHintTimer)clearTimeout(this.submitDisabledHintTimer);this.setState(()=>{this.submitDisabledHint=J}),this.submitDisabledHintTimer=setTimeout(()=>{this.setState(()=>{this.submitDisabledHint=null}),this.submitDisabledHintTimer=null},3000)}getUIHint(){let J=this.themeColors?.colorScheme;if(!J)return null;let Q=this.themeApp;if(!Q)return null;if(this.submitDisabledHint)return new J1(this.submitDisabledHint,new H1({color:J.foreground,dim:!0}));if(this.isExiting)return new J1("Exiting...",new H1({color:J.foreground,dim:!0}));if(this.isConfirmingExit)return new J1("",void 0,[new J1("Ctrl+C",new H1({color:Q.keybind})),new J1(" again to exit",new H1({color:J.foreground,dim:!0}))]);if(this.isConfirmingClearInput)return new J1("",void 0,[new J1("Esc",new H1({color:Q.keybind})),new J1(" again to clear input",new H1({color:J.foreground,dim:!0}))]);if(this.isShowingHelp)return new J1("",void 0,[new J1("Escape",new H1({color:Q.keybind})),new J1(" to close help",new H1({color:J.foreground,dim:!0}))]);if(this.showImageUnsupportedHint){let G=this.getEffectiveAgentMode(),Z=$k1(G,this.tryOpus);return new J1("",void 0,[new J1("Images aren't supported in ",new H1({color:J.warning,dim:!1})),new J1(G,new H1({color:Z})),new J1(" mode.",new H1({color:J.warning,dim:!1}))])}if(this.isProcessing()||this.bashInvocations.length>0){if(this.isConfirmingCancelProcessing)return new J1("",void 0,[new J1("Esc",new H1({color:Q.keybind})),new J1(" again to cancel",new H1({color:J.foreground,dim:!0}))]);return new J1("",void 0,[new J1("Esc",new H1({color:Q.keybind})),new J1(" to cancel",new H1({color:J.foreground,dim:!0}))])}if(this.showingSelectionCopiedHint)return new J1("Selection copied to clipboard",new H1({color:J.foreground,dim:!0}));if(this.showingCannotToggleMessage)return new J1(this.showingCannotToggleMessage,new H1({color:J.warning,dim:!1}));let Y=qY6(this.updateState,J);if(Y)return new J1("",void 0,Y);let X=this.widget.dependencies.worker.thread;if(X.agentMode==="plan"&&dA(X))return new J1("",void 0,[new J1("Ctrl+O",new H1({color:Q.keybind})),new J1(" → Execute Plan",new H1({color:J.foreground,dim:!0}))]);return null}isTranscriptEmpty(){let{threadState:J}=this.widget.dependencies;return J.items.length===0}handleMessageRestoreSubmit=async(J)=>{let{threadState:Q,worker:Y}=this.widget.dependencies;if(!Q.mainThread?.id)return;let G=Q.mainThread?.messages.findIndex((Z)=>Z===J);if(G===void 0||G===-1)return;try{this.cancelBashInvocations(),await Y.cancel(),await Y.handle({type:"thread:truncate",fromIndex:G}),this.scrollMessageViewToBottom(),this.setState(()=>{this.imageAttachments=[]})}catch(Z){f.error("Failed to edit message:",Z)}};forkMessage=async(J)=>{let{threadState:Q,workerDeps:Y,threadSyncService:X}=this.widget.dependencies,G=Q.mainThread?.id;if(!G)return;let Z=Q.mainThread?.messages.findIndex((q)=>q===J);if(Z===void 0||Z<=0)return;try{let q=await N3.getOrCreateForThread(Y,G),V=await qR(q,X,Z-1);await this.switchToExistingThread(V)}catch(q){f.error("Failed to fork thread:",q),this.showErrorMessage(`Failed to fork thread: ${q}`)}};handleMessageEditSubmit=async(J,Q)=>{let{threadState:Y,worker:X}=this.widget.dependencies,G=Y.mainThread;if(!G)return;let Z=G.messages.findIndex((q)=>q.messageId!==void 0&&q.messageId===J.messageId);if(Z===-1)return;try{this.cancelBashInvocations(),await X.cancel(),this.widget.dependencies.history.add(Q);let q=JN(Q);if(q)await X.handle({type:"thread:truncate",fromIndex:Z}),this.invokeBashCommand(q.cmd,{visibility:q.visibility});else{let V=[{type:"text",text:Q}];if(this.imageAttachments.length>0)V.push(...this.imageAttachments);let K={content:V,agentMode:G.agentMode},W=Z===0;if(G.agentMode&&!W&&K.agentMode!==G.agentMode){f.error(`Cannot edit message: This thread uses ${G.agentMode} mode. To change mode, create a new thread.`);return}await X.handle({type:"user:message",message:K,index:Z})}this.scrollMessageViewToBottom(),this.setState(()=>{this.imageAttachments=[]})}catch(q){f.error("Failed to edit message:",q)}};getAffectedFiles=async(J)=>{let{worker:Q}=this.widget.dependencies;try{return(await Q.getFilesAffectedByTruncation(J)).map(JJ)}catch(Y){return f.error("Failed to get affected files:",Y),[]}};textController=new hZ;messageScrollControllers=new Map;getMessageScrollController(J){if(!this.messageScrollControllers.has(J))this.messageScrollControllers.set(J,new p3);return this.messageScrollControllers.get(J)}scrollMessageViewToBottom(){let{threadState:J}=this.widget.dependencies,Q=J.mainThread?.id;if(!Q)return;this.getMessageScrollController(Q).scrollToBottom()}findElementByKey(J){return this.searchElementTreeByKey(this.context.element,J)}searchElementTreeByKey(J,Q){if(!J)return null;if(J?.widget?.key?.value===Q)return J;if(J?.child){let X=this.searchElementTreeByKey(J.child,Q);if(X)return X}if(J?.children)for(let X of J.children){let G=this.searchElementTreeByKey(X,Q);if(G)return G}return null}setupSelectionListener(){let J=this.findElementByKey("message-view-selection-area");if(J?.state){let Q=J.state;if(Q?.controller&&!this.selectionListener)this.selectionListener=()=>{this.setState(()=>{})},Q.controller.addListener(this.selectionListener),Q.controller.onSelectionCopied=()=>{if(this.copyMessageTimer)clearTimeout(this.copyMessageTimer);this.setState(()=>{this.showingSelectionCopiedHint=!0}),this.copyMessageTimer=setTimeout(()=>{this.setState(()=>{this.showingSelectionCopiedHint=!1}),this.copyMessageTimer=null},2000)}}}updateTerminalTitle(){let{threadState:J}=this.widget.dependencies,Q=J.mainThread?.title;if(Q!==this.currentTitle){this.currentTitle=Q;let Y=process.cwd().replace(process.env.HOME||"","~"),X=Q?`amp - ${Q} - ${Y}`:"";process.stdout.write(vR1(X))}}_handleTextCopy(J){if(J&&J.length>0){if(this.setState(()=>{this.showingSelectionCopiedHint=!0}),this.copyMessageTimer)clearTimeout(this.copyMessageTimer);this.copyMessageTimer=setTimeout(()=>{this.setState(()=>{this.showingSelectionCopiedHint=!1}),this.copyMessageTimer=null},2000)}}textFieldKey=new i7("text-field");ideStatusSubscription=null;ideMessageSubscription=null;ideAppendToPromptSubscription=null;connectedClientsStatusSubscription=null;paletteCommands=null;completionBuilder=null;textChangeListener=()=>{let J=this.textController.text;if(J==="/"){this.showCommandPalette(),this.textController.clear();return}let Y=JN(J)?.visibility;if(Y!==this.currentShellModeStatus)this.currentShellModeStatus=Y,this.setState(()=>{})};navigateHistoryPrevious=()=>{let J=this.widget.dependencies.history.previous();if(J!==null){if(this.historyIndex===-1)this.historyDraft=this.textController.text;this.historyIndex++,this.textController.text=J,this.textController.moveCursorToStart()}};navigateHistoryNext=()=>{let J=this.widget.dependencies.history.next();if(J!==null)this.historyIndex--,this.textController.text=J,this.textController.moveCursorToEnd();else if(this.historyIndex>-1)this.historyIndex=-1,this.textController.text=this.historyDraft||"",this.textController.moveCursorToEnd(),this.historyDraft=null};resetHistory=()=>{this.widget.dependencies.history.reset(),this.historyIndex=-1,this.historyDraft=null};openJetBrainsInstaller=()=>{this.setState(()=>{this.isShowingJetBrainsInstaller=!0})};dismissJetBrainsInstaller=()=>{this.setState(()=>{this.isShowingJetBrainsInstaller=!1})};openIdePicker=()=>{this.setState(()=>{this.isShowingIdePicker=!0})};dismissIdePicker=()=>{this.setState(()=>{this.isShowingIdePicker=!1}),J9.instance.addPostFrameCallback(()=>{this.autocompleteFocusNode.requestFocus()})};handleIdeSelection=async(J,Q)=>{if(this.widget.dependencies.ideClient.getSelectedConfig()?.pid===J.pid){this.dismissIdePicker();return}try{await this.connectToSelectedIde(J,Q)}catch(Y){let X=Y instanceof Error?Y.message:String(Y);this.setState(()=>{this.displayMessage=Error(`Failed to connect to IDE: ${X}`)})}this.widget.dependencies.ideClient.selectConfig(J),this.dismissIdePicker()};async connectToSelectedIde(J,Q){await this.widget.dependencies.ideClient.start(J,!0,Q)}previewControllerListener=(J)=>{this.setState(()=>{this.previewThread=J})};showStandaloneThreadPicker=()=>{this.loadThreadsForPicker(),this.setState(()=>{this.isShowingStandaloneThreadPicker=!0})};dismissStandaloneThreadPicker=()=>{this.exitApplication()};handleStandaloneThreadSelect=async(J)=>{try{await this.switchToExistingThread(J,{recordInNavigationHistory:!1}),this.threadPreviewController.clear(),this.setState(()=>{this.isShowingStandaloneThreadPicker=!1}),J9.instance.addPostFrameCallback(()=>{if(!this.isMessageViewInSelectionMode&&!this.isShowingPalette&&!this.isShowingStandaloneThreadPicker)this.autocompleteFocusNode.requestFocus()})}catch(Q){f.error("Failed to switch thread:",Q),this.showErrorMessage(`Failed to switch thread: ${Q}`)}};toggleThreadPickerWorkspaceFilter=()=>{this.setState(()=>{this.filterThreadPickerByWorkspace=!this.filterThreadPickerByWorkspace})};showCommandPalette(J){if(this.setState(()=>{this.isShowingPalette=!this.isShowingPalette,this.paletteInitialCommandId=J??null}),this.isShowingPalette)this.loadThreadsForPicker()}getPaletteCommands(){if(!this.paletteCommands)this.paletteCommands=new P_1(this.widget.dependencies.configService,this.widget.dependencies.commandRegistry,(J)=>{this.setState(()=>{this.executingCommand=J})},()=>{this.setState(()=>{this.executingCommand=null})},this.widget.dependencies.isDogfooding);return this.paletteCommands}getCompletionBuilder(){if(!this.completionBuilder)this.completionBuilder=new C_1(this.widget.dependencies.fuzzyServer,this.widget.dependencies.threadFuzzyIndexer);return this.completionBuilder}dismissPalette=()=>{this.setState(()=>{this.isShowingPalette=!1,this.paletteInitialCommandId=null})};getCommandPaletteContext=()=>{let{threadState:J,recentThreadIDs:Q}=this.widget.dependencies;if(!J.mainThread)return null;let Y=n0.file(process.cwd()),X=A6(Y);return{recentThreadIDs:Q,currentThreadID:J.mainThread.id,worker:this.widget.dependencies.worker,editorState:this.textController,isProcessing:this.isProcessing(),thread:J.mainThread,ampURL:this.widget.dependencies.ampURL,threadSyncService:this.widget.dependencies.threadSyncService,configService:this.widget.dependencies.configService,openInEditor:this.openInEditor,takeImageAttachments:()=>{let G=this.imageAttachments;return this.setState(()=>{this.imageAttachments=[]}),G},setImageAttachments:(G)=>{this.setState(()=>{this.imageAttachments=G})},editorDispatch:(G)=>{switch(G.type){case"set-input":this.textController.clear(),this.textController.insertText(G.input);break;case"insert-text":this.textController.insertText(G.text);break;case"clear":this.textController.clear();break}},submitMessage:(G)=>{return this.proceedWithUserMessage(G)},exitApp:this.exitApplication,openHelp:()=>{this.setState(()=>{this.isShowingHelp=!0})},settingsStorage:this.widget.dependencies.settingsStorage,clientId:this.widget.dependencies.clientId,connectedClientsService:this.widget.dependencies.connectedClientsService,mcpService:this.widget.dependencies.mcpService,startNewThread:async()=>{await this.startAndSwitchToNewThread()},navigateBack:this.navigateBack,navigateForward:this.navigateForward,canNavigateBack:this.threadBackStack.length>0,canNavigateForward:this.threadForwardStack.length>0,canUseAmpFree:this.widget.dependencies.freeTierStatus?.canUseAmpFree??!1,switchToThread:async(G)=>{return await this.switchToExistingThread(G),this.setState(()=>{this.isMessageViewInSelectionMode=!1}),this.widget.dependencies.worker},generateHandoffPrompt:async(G,Z,q)=>{let V=this.widget.dependencies.threadState.mainThread?.id;if(!V)throw Error("No active thread");let K=setTimeout(()=>{q.throwIfAborted()},60000);try{let W=await this.widget.dependencies.threadService.generateHandoffPrompt(V,G,Z,this.widget.dependencies.configService,q);return clearTimeout(K),W}catch(W){throw clearTimeout(K),W}},handleHandoff:async(G,Z)=>{let{goal:q,generatedPrompt:V,images:K}=Z;if(!q&&!V)return{ok:!1,error:Error("Either goal or generatedPrompt required")};try{let W=this.widget.dependencies.threadState.mainThread?.id;if(!W)return{ok:!1,error:Error("No active thread")};let H=setTimeout(()=>G.abort(new i81("Handoff took too long and was aborted (timeout: 60s)")),60000);try{let z=await this.widget.dependencies.threadService.createHandoffThread(W,{goal:q,generatedPrompt:V,images:K},this.widget.dependencies.configService,G.signal);return clearTimeout(H),await this.switchToExistingThread(z),{ok:!0}}catch(z){if(clearTimeout(H),z instanceof Error&&(z.name==="AbortError"||z.message.includes("aborted")))throw G.signal.reason;throw z}}catch(W){return f.error("Failed to create handoff thread",W),{ok:!1,error:W instanceof Error?W:Error(String(W))}}},getGuidanceFiles:async(G)=>{if(!J.mainThread)return[];return(await go({filesystem:this.widget.dependencies.worker.fs.fileSystemReader(),configService:this.widget.dependencies.configService,threadService:this.widget.dependencies.threadService},J.mainThread,G)).map((q)=>({uri:q.uri,type:q.type}))},openIdePicker:()=>{this.openIdePicker()},getInMemoryAgentModeOverride:()=>{return this.inMemoryAgentModeOverride},setInMemoryAgentModeOverride:(G)=>{this.setState(()=>{this.inMemoryAgentModeOverride=G,this.hasToggledAgentMode=!0})},toggleAgentMode:this.toggleAgentMode,getEffectiveAgentMode:()=>this.getEffectiveAgentMode(),getEditorText:()=>this.textController.text,workspace:this.widget.dependencies.workspace??null,handleExecutePlan:async()=>{try{let G=J.mainThread?.id;if(!G){this.setState(()=>{this.displayMessage=Error("No active thread")});return}let Z=await this.widget.dependencies.threadService.createPlanExecutionThread(G,"smart");await this.switchToExistingThread(Z)}catch(G){f.error("Failed to execute plan",G),this.setState(()=>{this.displayMessage=Error(`Failed to execute plan: ${G instanceof Error?G.message:String(G)}`)})}},planFileManager:this.widget.dependencies.planFileManager,completionBuilder:this.getCompletionBuilder(),threads:this.threadsForPicker,previewController:this.threadPreviewController,isLoadingThreads:this.isLoadingThreads,filterByWorkspace:this.filterThreadPickerByWorkspace,currentWorkspace:X,threadViewStates:this.widget.dependencies.workerController.threadViewStates,currentThreadFeedEntry:this.currentThreadFeedEntry,threadFeedEntries:this.threadFeedEntries,threadFeedHidden:this.threadFeedHidden,setThreadFeedHidden:(G)=>{this.setState(()=>{this.threadFeedHidden=G})}}};loadThreadsForPicker(){if(this.threadLoadSubscription)return;this.setState(()=>{this.isLoadingThreads=!0});let J=new Qk1(this.widget.dependencies.threadHistoryService);this.threadLoadSubscription=J.observeThreadSummaries("").subscribe({next:(Q)=>{this.setState(()=>{this.threadsForPicker=Q,this.isLoadingThreads=!1})},error:()=>{this.setState(()=>{this.isLoadingThreads=!1})}})}updateGitBranch=async()=>{let J=await bN8(process.cwd());this.setState(()=>{this.currentGitBranch=J})};removeBashInvocation=(J)=>{this.setState(()=>{this.bashInvocations=this.bashInvocations.filter((Q)=>Q.id!==J)})};invokeBashCommand=(J,{visibility:Q})=>{let Y=Date.now(),X=`bash-${Y}-${Math.random().toString(36).substring(7)}`,G={cmd:J},Z=new AbortController;this.widget.dependencies.worker.invokeBashTool(G,Z.signal,Q===eB).subscribe({next:(q)=>{this.setState(()=>{if(this.bashInvocations.find((K)=>K.id===X))this.bashInvocations=this.bashInvocations.map((K)=>K.id===X?{...K,toolRun:q}:K);else{let K={id:X,args:G,toolRun:q,startTime:Y,abortController:Z,hidden:Q===eB};this.bashInvocations=[...this.bashInvocations,K]}})},error:()=>this.removeBashInvocation(X),complete:()=>this.removeBashInvocation(X)})};cancelBashInvocations=()=>{let J=this.bashInvocations.find((Q)=>Q.toolRun.status==="in-progress");if(J)J.abortController.abort()};toggleConnectedClientsStatus=()=>{this.setState(()=>{this.connectedClientsStatusExpanded=!this.connectedClientsStatusExpanded})};toggleAgentMode=()=>{let J=this.widget.dependencies.getCurrentWorker()||this.widget.dependencies.worker;if(_$(J.thread)>0)return;if(this.freeTierStatus?.canUseAmpFree){let X=this.getEffectiveAgentMode(),G=Ik(X,this.cachedVisibleModes);if(G!==X)this.setState(()=>{this.hasToggledAgentMode=!0,this.inMemoryAgentModeOverride=G,this.agentModePulseSeq++,this.showingCannotToggleMessage=null,this.showImageUnsupportedHint=!1});return}let Q=this.getEffectiveAgentMode(),Y=Ik(Q,this.cachedVisibleModes);if(Y===Q)return;if(this.setState(()=>{this.hasToggledAgentMode=!0,this.inMemoryAgentModeOverride=Y,this.agentModePulseSeq++,this.showingCannotToggleMessage=null,this.showImageUnsupportedHint=!1}),F5(Y))this.checkAndShowFreeModeModal()};checkAndShowFreeModeModal=()=>{if(this.freeTierStatus?.canUseAmpFree)return;if(this.freeTierStatus){if(!this.freeTierStatus.eligible){this.setState(()=>{this.showingCannotToggleMessage="Amp Free is unavailable. Switch to another mode."}),setTimeout(()=>{this.setState(()=>{this.showingCannotToggleMessage=null})},3000);return}else if(!this.freeTierStatus.workspaceAllowsAmpFree){this.setState(()=>{this.showingCannotToggleMessage="Your workspace does not allow Amp Free. Switch to another mode."}),setTimeout(()=>{this.setState(()=>{this.showingCannotToggleMessage=null})},3000);return}}};isInRestrictedFreeMode(){if(this.getEffectiveAgentMode()!=="free")return!1;if(this.freeTierStatus?.canUseAmpFree)return!1;return!0}handleInsertImage=(J)=>{let Q=this.getEffectiveAgentMode();if(!Ek(Q)){if(this.imageUnsupportedHintTimer)clearTimeout(this.imageUnsupportedHintTimer);return this.setState(()=>{this.showImageUnsupportedHint=!0}),this.imageUnsupportedHintTimer=setTimeout(()=>{this.setState(()=>{this.showImageUnsupportedHint=!1}),this.imageUnsupportedHintTimer=null},5000),!1}if(this.imageAttachments.length>=qU)return!1;let Y=zC(J);if(typeof Y==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Y]}),!1;return this.setState(()=>{this.displayMessage=Error(`Failed to attach image: ${Y}`)}),!1};handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1)})};openInEditor=async(J)=>{let{mkdtemp:Q,readFile:Y,unlink:X,rmdir:G,writeFile:Z}=await import("node:fs/promises"),{tmpdir:q}=await import("node:os"),V=await import("node:path");try{let K=await Q(V.join(q(),"amp-edit-")),W=V.join(K,"message.amp.md");await Z(W,J,"utf-8"),await Bz(W);try{let H=await Y(W,"utf-8");this.textController.text=H}catch(H){if(H?.code!=="ENOENT")f.error("Failed to read temporary file",H)}try{await X(W),await G(K)}catch(H){f.warn("Failed to clean up temporary file",H)}}catch(K){f.error("Error opening editor:",K)}};onTextSubmitted=async(J)=>{if(!J.trim())return;let Q=JN(J);if(Q)if(!Q.cmd){this.showSubmitDisabledHint("No command provided");return}else if(this.isProcessing()){this.showSubmitDisabledHint("Unable to use shell mode while agent is active");return}else{this.invokeBashCommand(Q.cmd,{visibility:Q.visibility}),this.widget.dependencies.history.add(J),this.textController.clear(),this.resetHistory();return}this.textController.clear(),this.resetHistory(),await this.updateGitBranch(),await this.sendUserMessage(J)};initState(){if(oX.getInstance().interceptConsole(),this.threadPreviewController.setThreadService(this.widget.dependencies.threadService),this.threadPreviewController.addListener(this.previewControllerListener),this.widget.dependencies.openThreadSwitcher)this.showStandaloneThreadPicker();E9.instance.on("key",()=>{this.lastUserInteractionTime=Date.now()}),E9.instance.on("mouse",()=>{this.lastUserInteractionTime=Date.now()}),E9.instance.on("paste",()=>{this.lastUserInteractionTime=Date.now()}),this.autocompleteFocusNode.addListener((Y)=>{J9.instance.addPostFrameCallback(()=>{this.setState(()=>{this.isTextfieldAndAutocompleteFocused=Y.hasFocus})})}),this.freeTierStatus=this.widget.dependencies.freeTierStatus,M6(this.widget.dependencies.configService.config).then((Y)=>{let X=T41(this.widget.dependencies.worker.thread,this.widget.dependencies.sessionState??null,this.freeTierStatus,Y.settings);if(f.info(`[initState] Resolved agentMode: ${X}`),this.widget.dependencies.sessionState?.agentMode)this.setState(()=>{this.inMemoryAgentModeOverride=X})}),this.updateGitBranch(),this.adSubscription=QC1(this.widget.dependencies.internalAPIClient,this.widget.dependencies.configService,()=>{return(this.inMemoryAgentModeOverride&&F5(this.inMemoryAgentModeOverride)||this.randomAd===null)&&JC1(this.lastUserInteractionTime)}).subscribe({next:(Y)=>{if(Y){let X=fN8(16).toString("hex");this.lastAdImpressionId=X,Promise.resolve().then(() => (F91(),z91)).then(({recordAdEvent:G})=>{let Z=this.widget.dependencies.worker.thread,q=Z.messages[Z.messages.length-1];G("viewed",{adId:Y.id,advertiserId:Y.advertiserId,threadId:Z.id,messageId:q?.messageId,impressionId:X,placement:"tui",matchType:Y.metadata?.matchType,matchedPatterns:Y.metadata?.matchedPatterns,candidateAdPoolCount:Y.metadata?.candidateAdPoolCount,clientRegion:Y.metadata?.clientRegion})})}this.setState(()=>{this.randomAd=Y}),J9.instance.addPostFrameCallback(()=>{if(!this.isMessageViewInSelectionMode&&!this.isShowingPalette&&!this.isShowingStandaloneThreadPicker&&!this.isShowingIdePicker)this.autocompleteFocusNode.requestFocus()})}});let{mcpTrustHandler:J}=this.widget.dependencies;this.mcpTrustSubscription=J.pendingServers$.subscribe((Y)=>{this.setState(()=>{this.pendingMCPServers=Y})}),this.ideStatusSubscription=this.widget.dependencies.ideClient.status.subscribe((Y)=>{this.setState(()=>{this.ideStatus=Y})}),this.ideMessageSubscription=this.widget.dependencies.ideClient.messages.subscribe(async(Y)=>{let X=this.widget.dependencies.getCurrentWorker();if(!X){f.warn("No active thread worker found to handle IDE message");return}await new Promise((G)=>setTimeout(G,50)),await X.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}}),f.debug("Message sent from IDE to agent",{message:Y.slice(0,100)})}),this.ideAppendToPromptSubscription=this.widget.dependencies.ideClient.appendToPrompt.subscribe((Y)=>{this.textController.insertText(Y),f.debug("Appended text to CLI prompt from IDE",{text:Y.slice(0,100)})}),this.connectedClientsStatusSubscription=this.widget.dependencies.connectedClientsService.status.subscribe((Y)=>{this.setState(()=>{this.connectedClientsStatus=Y})}),this.updateServiceSubscription=this.widget.dependencies.updateService.state.subscribe((Y)=>{this.setState(()=>{this.updateState=Y})}),this.agentModeSubscription=this.widget.dependencies.configService.config.subscribe((Y)=>{let X=uG(Y.settings,this.freeTierStatus?.canUseAmpFree);this.setState(()=>{this.cachedVisibleModes=X,this.tryOpus=Y.settings.tryOpus??!1})}),this.textController.addListener(this.textChangeListener),this.updateTerminalTitle();let Q=this.widget.dependencies.ideClient.getSelectedConfig();if(Q)this.connectToSelectedIde(Q,"auto-startup").catch((Y)=>{let X=Y instanceof Error?Y.message:String(Y);this.setState(()=>{this.displayMessage=Error(`Failed to connect to IDE: ${X}`)})});else if(this.widget.dependencies.showIdePicker)this.openIdePicker();else if(this.widget.dependencies.showJetBrainsInstaller)this.openJetBrainsInstaller();if(this.widget.dependencies.replayMode)setTimeout(()=>this.startReplay(),100);this.initThreadFeed()}didUpdateWidget(J){super.didUpdateWidget(J),this.setupSelectionListener()}dispose(){if(this.replayAbortController.abort(),this.replayTypingTimer)clearTimeout(this.replayTypingTimer);if(this.ideStatusSubscription)this.ideStatusSubscription.unsubscribe();if(this.ideMessageSubscription)this.ideMessageSubscription.unsubscribe();if(this.ideAppendToPromptSubscription)this.ideAppendToPromptSubscription.unsubscribe();if(this.connectedClientsStatusSubscription)this.connectedClientsStatusSubscription.unsubscribe();if(this.updateServiceSubscription)this.updateServiceSubscription.unsubscribe();if(this.agentModeSubscription)this.agentModeSubscription.unsubscribe();if(this.adSubscription)this.adSubscription.unsubscribe();if(this.mcpTrustSubscription)this.mcpTrustSubscription.unsubscribe();if(this.threadLoadSubscription)this.threadLoadSubscription.unsubscribe();if(this.threadFeedSubscription)this.threadFeedSubscription.unsubscribe();if(this.threadFeedRotationTimer)clearInterval(this.threadFeedRotationTimer);if(this.threadPreviewController.removeListener(this.previewControllerListener),this.threadPreviewController.dispose(),this.exitConfirmTimeout)clearTimeout(this.exitConfirmTimeout),this.exitConfirmTimeout=null;if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.textController.removeListener(this.textChangeListener);for(let J of this.messageScrollControllers.values())J.dispose();if(this.messageScrollControllers.clear(),process.stdout.write(vR1("")),this.shouldUseProgressBar())process.stdout.write(z96())}getCurrentConfirmation(){let{threadState:J}=this.widget.dependencies,X=[...J.items.filter((V)=>V.type==="toolResult").map((V)=>({toolUse:V.toolUse,toolRun:V.toolResult.run,subthreadID:void 0})),...J.subagentActiveTools].filter((V)=>V.toolRun.status==="blocked-on-user");if(X.length===0)return null;let G=X[0],Z=G.toolRun.status==="blocked-on-user"?G.toolRun.toAllow??[]:[],q=G.toolRun.status==="blocked-on-user"?G.toolRun.reason:void 0;return{type:"tool-use",tools:[{useBlock:G.toolUse,toAllow:Z}],subthreadID:G.subthreadID,reason:q}}shouldUseProgressBar(){return!1}updateProgressBar(){}onConfirmationResponse=async(J)=>{let Q=this.getCurrentConfirmation();if(!Q||Q.type!=="tool-use"){f.error("No current tool confirmation found");return}let Y=Q.tools[0]?.useBlock;if(!Y){f.error("No tool use block found in confirmation");return}if(J==="allow-all-session")hG("dangerouslyAllowAll",!0);if(J==="allow-all-persistent")try{await this.widget.dependencies.settingsStorage.set("dangerouslyAllowAll",!0,"global")}catch(G){if(G&&G instanceof Error)this.setState(()=>{this.displayMessage=G});else f.error("Failed to write dangerouslyAllowAll setting:",G);return}if(J==="always-guarded"){let G=Q.tools[0]?.toAllow??[],Z=await this.widget.dependencies.settingsStorage.get("guardedFiles.allowlist")||[],q=[...G,...Z];await this.widget.dependencies.settingsStorage.set("guardedFiles.allowlist",q,"global")}if(J==="connect-github"){let G=new URL("/settings#code-host-connections",this.widget.dependencies.ampURL).toString();try{await j3(G)}catch(Z){f.error("Failed to open settings page:",Z),await this.showErrorMessage(`Cannot open browser. Please go to ${G} to connect to GitHub`)}return}if(J==="disable-librarian"){let G=await this.widget.dependencies.settingsStorage.get("tools.disable")??[];if(!G.includes(BX))await this.widget.dependencies.settingsStorage.set("tools.disable",[...G,BX],"global")}let X=J!==null&&["yes","allow-all-session","allow-all-persistent","always-guarded"].includes(J);try{let G={type:"user:tool-input",toolUse:Y.id,value:{accepted:X}};if(Q.subthreadID)await(await N3.getOrCreateForThread(this.widget.dependencies.workerDeps,Q.subthreadID)).handle(G);else await this.widget.dependencies.worker.handle(G)}catch(G){f.error("Failed to send tool confirmation:",G)}};showConfirmationOverlay=(J)=>{this.setState(()=>{this.isShowingConfirmationOverlay=!0,this.confirmationOverlayContent=J})};getErrorKey(J){return`${J.constructor.name}:${J.message}`}getCurrentEphemeralError(){let{threadState:J}=this.widget.dependencies,Q=J.viewState;if(Q.state!=="active"||!Q.ephemeralError)return null;let Y=this.getErrorKey(Q.ephemeralError);if(this.dismissedEphemeralErrorKey===Y)return null;return Q.ephemeralError}handleEphemeralErrorResponse=async(J)=>{let Q=this.getCurrentEphemeralError(),Y=this.widget.dependencies.worker;switch(J){case"retry":this.dismissedEphemeralErrorKey=null,await Y.retry();break;case"dismiss":if(Q)this.dismissedEphemeralErrorKey=this.getErrorKey(Q);break;case"new-thread":{this.setState(()=>{this.dismissedEphemeralErrorKey=null}),await this.startAndSwitchToNewThread();break}case"new-smart-thread":{this.setState(()=>{this.inMemoryAgentModeOverride="smart",this.dismissedEphemeralErrorKey=null}),y61({agentMode:"smart"}),await this.startAndSwitchToNewThread();break}case"handoff":{if(Q)this.dismissedEphemeralErrorKey=this.getErrorKey(Q);this.showCommandPalette("handoff");break}}this.setState(()=>{})};handleDisplayMessageDismiss=()=>{this.setState(()=>{this.displayMessage=null})};handleMCPTrustOpenSettings=async()=>{let{mcpTrustHandler:J,settingsStorage:Q}=this.widget.dependencies;await J.deny();try{await Bz(Q.getSettingsFilePath())}catch(Y){let X=Y instanceof Error?Y.message:String(Y);await this.showErrorMessage(`Failed to open settings: ${X}`)}};cancelStreamingMessage=async()=>{await N3.cancel(this.widget.dependencies.threadID)};markLastUserMessageAsInterrupted=async()=>{let J=this.widget.dependencies.threadState.mainThread;if(!J)return;for(let Q=J.messages.length-1;Q>=0;Q--){let Y=J.messages[Q];if(Y?.role==="user"&&!Y.interrupted){await this.widget.dependencies.worker.handle({type:"user:message:interrupt",messageIndex:Q});break}}};switchToExistingThread=async(J,Q={})=>{let{recordInNavigationHistory:Y=!0}=Q;if(Y){let X=this.widget.dependencies.worker.thread.id;if(X!==J)this.recordNavigation(X)}try{f.info(`[switchToExistingThread] Switching to thread: ${J}`);let X=await this.widget.dependencies.switchToThread(J);f.info(`[switchToExistingThread] Got worker for thread ${J}, thread.agentMode: ${X.thread.agentMode}`);let G=await this.widget.dependencies.configService.getLatest(),Z=T41(X.thread,this.widget.dependencies.sessionState??null,this.freeTierStatus,G.settings);if(f.info(`[switchToExistingThread] Thread ${J} resolved agentMode: ${Z}`),this.widget.dependencies.worker=X,this.widget.dependencies.threadID=X.thread.id,this.widget.dependencies.switchWorker(X),this.setState(()=>{f.info("[switchToExistingThread] Clearing inMemoryAgentModeOverride"),this.inMemoryAgentModeOverride=null}),X.thread.draft)if(f.info("[switchToExistingThread] Loading draft content into text controller"),this.textController.clear(),typeof X.thread.draft==="string")this.textController.insertText(X.thread.draft);else{let q=X.thread.draft.filter((W)=>W.type==="text"),V=X.thread.draft.filter((W)=>W.type==="image"),K=q.map((W)=>W.text).join(`
4819
4818
  `);if(K)this.textController.insertText(K);if(V.length>0)this.setState(()=>{this.imageAttachments=V})}}catch(X){throw f.error("Failed to switch to thread:",J,X),Error(`Failed to switch to thread: ${J}`)}};sendUserMessage=async(J)=>{await this.proceedWithUserMessage(J)};proceedWithUserMessage=async(J)=>{this.cancelBashInvocations(),this.widget.dependencies.history.add(J);let Q=this.widget.dependencies.getCurrentWorker()||this.widget.dependencies.worker,Y=_$(Q.thread)===0,X=this.getEffectiveAgentMode();if(Q.thread.agentMode&&!Y&&X!==Q.thread.agentMode){await this.showErrorMessage(`This thread uses ${Q.thread.agentMode} mode. To change mode, edit the first message or create a new thread.`);return}let G=[{type:"text",text:J}];if(this.imageAttachments.length>0)G.push(...this.imageAttachments);if(await Q.handle({type:"user:message",message:{content:G,agentMode:X}}),Y)y61({agentMode:X});this.scrollMessageViewToBottom(),this.setState(()=>{this.imageAttachments=[]}),J9.instance.addPostFrameCallback(()=>{if(!this.isMessageViewInSelectionMode&&!this.isShowingPalette&&!this.isShowingStandaloneThreadPicker&&!this.isShowingIdePicker)this.autocompleteFocusNode.requestFocus()})};async showErrorMessage(J){this.setState(()=>{this.displayMessage=Error(J)})}exitApplication=async()=>{this.setState(()=>{this.isExiting=!0});let J=this.widget.dependencies.threadState.mainThread;if(J?.messages.length===0){if(J.relationships?.find((X)=>X.type==="handoff"&&X.role==="child"))await this.widget.dependencies.threadService.discardHandoffThread(J.id).catch(()=>{})}let Q=this.getEffectiveAgentMode();y61({agentMode:Q}).catch((Y)=>{f.warn("Failed to save session state on exit:",Y)}).finally(()=>{E9.instance.stop()})};onExitPressed=()=>{if(this.isConfirmingExit){if(this.exitConfirmTimeout)clearTimeout(this.exitConfirmTimeout),this.exitConfirmTimeout=null;this.exitApplication()}else{if(this.setState(()=>{this.isConfirmingExit=!0}),this.exitConfirmTimeout)clearTimeout(this.exitConfirmTimeout);this.exitConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingExit=!1}),this.exitConfirmTimeout=null},1000)}};toHomeRelative(J){let Q=hN8();if(J===Q)return"~";if(J.startsWith(Q+wm.sep))return"~"+J.slice(Q.length);return J}shorten(J){let Q=J.split(wm.sep).filter(Boolean);if(Q.length<=5)return J;return[Q.slice(0,2).join(wm.sep),"…",Q.slice(-2).join(wm.sep)].join(wm.sep)}build(J){let Q=U8.of(J),Y=x6.of(J),X=Y.base;this.themeColors=X;let{colors:G,app:Z}=Y;this.themeApp=Z;let q=this.widget.dependencies.getCurrentWorker()||this.widget.dependencies.worker,V=q.thread.agentMode&&F5(q.thread.agentMode),K=V&&this.randomAd!==null,W=!V&&this.currentThreadFeedEntry!==null&&!this.threadFeedHidden,H=K||W,{threadState:z}=this.widget.dependencies;this.updateTerminalTitle(),this.updateProgressBar();let U=this.getCurrentConfirmation(),N=this.widget.dependencies.replayMode,M=Boolean(N),L=z.items,A=z.mainThread||void 0,E=z.subagentToolsByParentID,P=z.todosList;if(M){let d6={...N.thread,messages:this.replayDisplayedMessages};L=jC(d6).items,A=d6,E={};let _4=sE({messages:this.replayDisplayedMessages});P=Array.isArray(_4)?_4:[]}let I=A?.id,R=A,S=M?this.replayDisplayedMessages.length===0:this.isTranscriptEmpty(),y=(d6)=>new d81({key:new i7(`preview-message-view-${d6.id}`),items:jC(d6).items,controller:this.threadPreviewController.scrollController,autofocus:!1,thread:d6,focusNode:new c8({debugLabel:"PreviewFocus"})}),h=this.previewThread,u=h?h.messages.length>2000?new s0({mainAxisSize:"max",children:[new z4({child:new U0}),new c6({padding:f0.all(2),child:new H8({child:new d1({text:new J1("Thread too long for preview",new H1({color:G.mutedForeground,dim:!0}))})})})]}):y(h):S?new l81({agentMode:this.getEffectiveAgentMode(),tryOpus:this.tryOpus}):new d81({key:I?new i7(`message-view-${I}`):void 0,items:L,subagentToolsByParentID:E,controller:I?this.getMessageScrollController(I):new p3,autofocus:!1,onCopy:M?void 0:this._handleTextCopy.bind(this),thread:R,onMessageEditSubmit:M?void 0:this.handleMessageEditSubmit,onMessageRestoreSubmit:M?void 0:this.handleMessageRestoreSubmit,onMessageForkSubmit:M?void 0:this.forkMessage,getAffectedFiles:M?void 0:this.getAffectedFiles,focusNode:this.messageViewFocusNode,onDismissFocus:()=>{if(this.setState(()=>{this.isMessageViewInSelectionMode=!1}),!this.isShowingIdePicker)this.autocompleteFocusNode.requestFocus()},isInSelectionMode:this.isMessageViewInSelectionMode}),p=Math.max(Math.floor(Q.size.height*0.4),12),g=this.getCurrentEphemeralError(),i=this.buildBottomWidget(g,U,G,Y,z,P,p,H,M),Y1=Q.size.width<40,a=z.mainThread?kU0(z.mainThread):void 0,b=new Z81({threadViewState:z.viewState,threadTokenUsage:a,threadID:I??null,thread:z.mainThread??void 0,onFileChangesClick:()=>{this.setState(()=>{this.isShowingFileChangesOverlay=!this.isShowingFileChangesOverlay})},onCostBreakdownClick:()=>{this.setState(()=>{this.isShowingCostBreakdownOverlay=!this.isShowingCostBreakdownOverlay})},onShowIdePicker:this.openIdePicker,ideStatus:this.ideStatus,connectedClientsStatus:this.connectedClientsStatus,isNarrow:Y1,uiHint:this.getUIHint()??void 0,waitingForConfirmation:!!U,showingEphemeralError:Boolean(z.viewState.state==="active"&&z.viewState.ephemeralError),runningBashInvocations:this.bashInvocations.length>0,executingCommand:this.executingCommand?.name??null,executingCommandMessage:this.executingCommand?.statusMessage??null}),s=new G81({bashInvocations:this.bashInvocations}),q1=[],K1=this.getEffectiveAgentMode(),o=this.currentShellModeStatus,r=$k1(K1,this.tryOpus),l=!o?K1.length+1:0,F1=Q.capabilities.animationSupport,y1=F1==="disabled"?0:F1==="slow"?30:60,t=mW(K1)?.uiHints?.fasterAnimation?3:1,f1=y1>0&&this.agentModePulseSeq>0?new e5({children:[i,new u3({top:0,left:1,right:1,height:1,child:new r_1({color:r,trigger:this.agentModePulseSeq,fps:y1,speed:t,leftOffset:l})})]}):i;q1.push(new z4({child:u}),s);let j1=new e5({children:[new s0({mainAxisSize:"min",children:[K?new B_1({ad:this.randomAd,onButtonClick:async()=>{let d6=this.randomAd;if(this.lastAdImpressionId)Promise.resolve().then(() => (F91(),z91)).then(({recordAdEvent:_4})=>{let l4=this.widget.dependencies.worker.thread,u4=l4.messages[l4.messages.length-1];_4("clicked",{adId:d6.id,advertiserId:d6.advertiserId,threadId:l4.id,messageId:u4?.messageId,impressionId:this.lastAdImpressionId,placement:"tui",actionType:"link_to",matchType:d6.metadata?.matchType,matchedPatterns:d6.metadata?.matchedPatterns,candidateAdPoolCount:d6.metadata?.candidateAdPoolCount,clientRegion:d6.metadata?.clientRegion})});try{await j3(d6.shortDestinationUrl)}catch(_4){let u4=E9.instance.tuiInstance.clipboard.isOsc52Supported();this.setState(()=>{this.adActionModal={showCopyOption:u4,url:d6.shortDestinationUrl}})}}}):W?new Jk1({entry:this.currentThreadFeedEntry}):new U0({height:0}),new J6({constraints:new r6(0,Q.size.width,0,p),child:f1})]}),H?new u3({top:0,left:0,right:0,child:new BY6({userHeight:this.bottomGridUserHeight,maxHeight:p,onInitializeHeight:(d6)=>{this.setState(()=>{this.bottomGridUserHeight=Math.min(d6,p)})},onDrag:(d6)=>{if(this.bottomGridDragStartY===null)this.bottomGridDragStartY=Math.floor(d6.localPosition.y),this.bottomGridDragStartHeight=this.bottomGridUserHeight;let _4=Math.floor(d6.localPosition.y)-this.bottomGridDragStartY,l4=Math.max(4,this.bottomGridDragStartHeight-_4),u4=Math.min(l4,p),w4=Math.floor(u4);if(this.bottomGridUserHeight!==w4)this.setState(()=>{this.bottomGridUserHeight=w4})},onRelease:()=>{this.bottomGridDragStartY=null,this.bottomGridDragStartHeight=null}})}):new U0({height:0})]});q1.push(j1,new U0({height:1,child:new c6({padding:f0.horizontal(1),child:b})}));let w0=new s0({crossAxisAlignment:"stretch",mainAxisSize:"max",children:q1}),C1=M?new e5({children:[w0,new u3({top:0,left:0,child:new e_1})]}):w0,s1=new Q9(()=>{if(this.isShowingPalette)return this.dismissPalette(),"handled";if(this.pendingMCPServers.length>0)return this.widget.dependencies.mcpTrustHandler.deny(),"handled";if(this.getCurrentEphemeralError())return this.handleEphemeralErrorResponse("dismiss"),"handled";if(this.displayMessage)return this.handleDisplayMessageDismiss(),"handled";if(this.isShowingHelp)return this.setState(()=>{this.isShowingHelp=!1}),"handled";if(this.isShowingFileChangesOverlay)return this.setState(()=>{this.isShowingFileChangesOverlay=!1}),"handled";if(this.isShowingCostBreakdownOverlay)return this.setState(()=>{this.isShowingCostBreakdownOverlay=!1}),"handled";if(this.isShowingIdePicker)return this.dismissIdePicker(),"handled";if(this.isShowingJetBrainsInstaller)return this.dismissJetBrainsInstaller(),"handled";if(this.isShowingConfirmationOverlay)return this.setState(()=>{this.isShowingConfirmationOverlay=!1,this.confirmationOverlayContent=""}),"handled";if(this.isShowingConsoleOverlay)return this.setState(()=>{this.isShowingConsoleOverlay=!1}),"handled";if(this.textController.hasSelection)return this.textController.clearSelection(),"handled";if(this.isConfirmingClearInput){if(this.textController.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.isConfirmingCancelProcessing){if(this.bashInvocations.length>0)this.cancelBashInvocations();if(this.isProcessing())this.markLastUserMessageAsInterrupted().catch((_4)=>{f.error("Failed to mark message as interrupted:",_4)}),this.cancelStreamingMessage().catch((_4)=>{f.error("Failed to cancel streaming message:",_4)});if(this.setState(()=>{this.isConfirmingCancelProcessing=!1}),this.cancelProcessingConfirmTimeout)clearTimeout(this.cancelProcessingConfirmTimeout),this.cancelProcessingConfirmTimeout=null;return"handled"}if(this.executingCommand)return f.info("Canceling executing command:",this.executingCommand.name),this.executingCommand.abortController.abort(),"handled";if(this.bashInvocations.length>0||this.isProcessing()){if(this.setState(()=>{this.isConfirmingCancelProcessing=!0}),this.cancelProcessingConfirmTimeout)clearTimeout(this.cancelProcessingConfirmTimeout);return this.cancelProcessingConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingCancelProcessing=!1}),this.cancelProcessingConfirmTimeout=null},1000),"handled"}if(this.textController.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return"ignored"}),U1=new Q9(()=>{return this.onExitPressed(),"handled"}),Q1=new Q9(()=>{return this.setState(()=>{this.isShowingConsoleOverlay=!this.isShowingConsoleOverlay}),"handled"}),A1=new Q9(()=>{return AJ.instance.toggleAll(),"handled"}),w1=new Q9(()=>{return this.widget.dependencies.configService.getLatest().then((d6)=>{hG("internal.showCost",!(d6.settings["internal.showCost"]??!0))}),"handled"}),I1=new Q9(()=>{return E9.instance.toggleFrameStatsOverlay(),"handled"}),E1=new Q9(()=>{return E9.instance.tuiInstance.getScreen().markForRefresh(),J9.instance.requestFrame(),"handled"}),p1=new Q9(()=>{return this.toggleAgentMode(),"handled"}),h1=new Q9(()=>{let _4=this.isShowingPalette&&this.previewThread?this.threadPreviewController.scrollController:(()=>{let{threadState:l4}=this.widget.dependencies,u4=l4.mainThread?.id;return u4?this.getMessageScrollController(u4):null})();if(_4){let l4=Math.max(Math.floor(Q.size.height*0.4),10),u4=Q.size.height-l4;_4.animatePageUp(u4,100)}return"handled"}),r1=new Q9(()=>{let _4=this.isShowingPalette&&this.previewThread?this.threadPreviewController.scrollController:(()=>{let{threadState:l4}=this.widget.dependencies,u4=l4.mainThread?.id;return u4?this.getMessageScrollController(u4):null})();if(_4){let l4=Math.max(Math.floor(Q.size.height*0.4),10),u4=Q.size.height-l4;_4.animatePageDown(u4,100)}return"handled"}),$0=new Q9(()=>{let _4=this.isShowingPalette&&this.previewThread?this.threadPreviewController.scrollController:(()=>{let{threadState:l4}=this.widget.dependencies,u4=l4.mainThread?.id;return u4?this.getMessageScrollController(u4):null})();if(_4)_4.animateTo(0,100);return"handled"}),X0=new Q9(()=>{let _4=this.isShowingPalette&&this.previewThread?this.threadPreviewController.scrollController:(()=>{let{threadState:l4}=this.widget.dependencies,u4=l4.mainThread?.id;return u4?this.getMessageScrollController(u4):null})();if(_4)_4.animateTo(Number.MAX_SAFE_INTEGER,100);return"handled"}),R0=new Q9(()=>{if(!this.isTextfieldAndAutocompleteFocused)return"ignored";let{threadState:d6}=this.widget.dependencies;if(!d6.mainThread?.messages.some((l4)=>l4.role==="user"||rE(l4)))return"ignored";return this.setState(()=>{this.isMessageViewInSelectionMode=!0}),"handled"}),F6=new Q9((d6)=>{if(d6.direction==="previous")this.navigateHistoryPrevious();else this.navigateHistoryNext();return"handled"}),D6=new Q9(()=>{if(!this.isTextfieldAndAutocompleteFocused)return"ignored";return e41().then(async(d6)=>{if(d6)try{this.handleInsertImage(d6)}finally{try{let{unlink:_4}=await import("node:fs/promises");await _4(d6)}catch{}}}),"handled"}),N4=new Map([[B4.ctrl("c"),new rg],[B4.ctrl("l"),new Qm],[B4.ctrl("o"),new d41],[B4.ctrl("v"),new ag],[B4.alt("s"),new UC],[B4.ctrl("s"),new UC],[B4.alt("p"),new Jm],[B4.ctrl("r"),new tg],[B4.alt("d"),new eg],[B4.ctrl("t"),new Ym],[B4.key("PageUp"),new g41],[B4.key("PageDown"),new m41],[B4.key("Home"),new u41],[B4.key("End"),new p41],[B4.key("Escape"),new og],[B4.ctrl("p"),new BC("previous")],[B4.ctrl("n"),new BC("next")],[B4.key("Tab"),new Xm]]);if(!c2())N4.set(B4.key("ArrowUp"),new Xm);if(!1)N4.set(B4.alt("c"),new sg);let S9=new Q9(()=>{if(this.isShowingStandaloneThreadPicker)return"handled";return this.showCommandPalette(),"handled"}),I0=new Q9(()=>{return this.toggleThreadPickerWorkspaceFilter(),"handled"}),u0=new Map([[og,s1],[Qm,E1],[UC,p1],[d41,S9],[ag,D6],[sg,Q1],[tg,A1],[eg,w1],[Jm,I1],[Ym,I0],[rg,U1],[g41,h1],[m41,r1],[u41,$0],[p41,X0],[Xm,R0],[BC,F6]]),_6=[C1];if(this.isShowingConsoleOverlay)_6.push(new __1);if(this.isShowingHelp){let d6=this.getPaletteCommands().getAllCommands();_6.push(new x_1({commands:d6}))}if(this.adActionModal)_6.push(new N_1({title:"Failed to open browser",message:this.adActionModal.url,showCopyOption:this.adActionModal.showCopyOption,onSelect:async(d6)=>{let _4=this.adActionModal.url;if(d6==="copy")try{await E9.instance.tuiInstance.clipboard.writeText(_4),this.setState(()=>{this.displayMessage=new QG("Link copied to clipboard")})}catch(l4){f.error("Failed to copy to clipboard",{error:l4}),this.setState(()=>{this.displayMessage=Error("Failed to copy to clipboard")})}this.setState(()=>{this.adActionModal=null})}}));if(this.pendingMCPServers.length>0){let{mcpTrustHandler:d6}=this.widget.dependencies;_6.push(new s_1({servers:this.pendingMCPServers,onAlwaysTrust:d6.trustAlways.bind(d6),onTrustOnce:d6.trustOnce.bind(d6),onOpenSettings:this.handleMCPTrustOpenSettings,onDismiss:d6.deny.bind(d6)}))}if(this.isShowingFileChangesOverlay)_6.push(new Dj1({threadData:z}));if(this.isShowingCostBreakdownOverlay&&z.mainThread)_6.push(new k_1({thread:z.mainThread}));if(this.isShowingConfirmationOverlay)_6.push(new j_1({details:this.confirmationOverlayContent}));let Q8=this.getCommandPaletteContext();if(Q8&&this.isShowingPalette)_6.push(new H8({child:new J6({constraints:r6.loose(80,20),child:new R_1({commandContext:Q8,mainThread:z.mainThread,commands:this.getPaletteCommands(),onDismiss:this.dismissPalette,initialCommandId:this.paletteInitialCommandId??void 0})})}));if(this.isShowingIdePicker)_6.push(new f_1({onCancel:this.dismissIdePicker,onSelect:this.handleIdeSelection,jetbrainsMode:this.widget.dependencies.jetbrainsMode}));if(this.isShowingStandaloneThreadPicker){let d6=n0.file(process.cwd()),_4=A6(d6);_6.push(new H8({child:new J6({constraints:r6.loose(80,20),child:new AC({threads:this.threadsForPicker,title:"Continue Thread",onSelect:this.handleStandaloneThreadSelect,onDismiss:this.dismissStandaloneThreadPicker,previewController:this.threadPreviewController,isLoading:this.isLoadingThreads,currentWorkspaceURI:_4,filterByWorkspace:this.filterThreadPickerByWorkspace,threadViewStates:this.widget.dependencies.workerController.threadViewStates,recentThreadIDs:this.widget.dependencies.recentThreadIDs,currentThreadID:this.widget.dependencies.threadState.mainThread?.id})})}))}let k8=new e5({children:_6});if(this.isShowingJetBrainsInstaller)return new eA({child:new cQ({actions:u0,child:new Pq({shortcuts:N4,debugLabel:"jetbrains-installer-shortcuts",child:new o_1({configService:this.widget.dependencies.configService,ideClient:this.widget.dependencies.ideClient,onExit:()=>process.exit(0),onContinue:this.dismissJetBrainsInstaller})})})});let N5=new QN({onError:(d6)=>{this.showErrorMessage(d6.message)},child:k8});return new eA({child:new cQ({actions:u0,child:new Pq({shortcuts:N4,debugLabel:"main-app-shortcuts",child:N5})})})}buildScrollableTodoList(J,Q,Y){return new FY6({todos:J,enabled:Q,controller:this.todoScrollController,appTheme:Y})}buildBottomWidget(J,Q,Y,X,G,Z,q,V,K){if(J)return new y_1({error:J,ampURL:this.widget.dependencies.ampURL,onResponse:this.handleEphemeralErrorResponse});if(Q){if(this.displayMessage)this.handleDisplayMessageDismiss();return new S_1({confirmationRequest:Q,onResponse:this.onConfirmationResponse,onShowOverlay:this.showConfirmationOverlay})}if(this.displayMessage)return new t_1({message:this.displayMessage,onDismiss:this.handleDisplayMessageDismiss});let W=X.app,H=X81(X),z=this.isInRestrictedFreeMode(),U=new BO({key:this.textFieldKey,controller:this.textController,triggers:K?[]:[new VN],completionBuilder:K?void 0:this.getCompletionBuilder(),ampURL:this.widget.dependencies.ampURL,onSubmitted:K?void 0:this.onTextSubmitted,theme:Y,placeholder:K?"Press Ctrl+C to exit":z?"Amp Free is not enabled. Press Ctrl+S to switch modes.":void 0,enabled:this.isTextfieldAndAutocompleteFocused&&!z&&!this.isShowingStandaloneThreadPicker,shellPromptRules:H,focusNode:this.autocompleteFocusNode,autofocus:!this.isMessageViewInSelectionMode&&!this.isShowingStandaloneThreadPicker&&!this.isShowingIdePicker,clipboard:E9.instance.tuiInstance.clipboard,onCopy:this._handleTextCopy.bind(this),onInsertImage:this.handleInsertImage,imageAttachments:this.imageAttachments,popImage:this.handlePopImage}),N=G.mainThread?.queuedMessages??[],M=Array.isArray(Z)&&Z.length>0,L=Array.isArray(N)&&N.length>0,A=G.mainThread?.agentMode==="plan"&&dA(G.mainThread),E,P;if(A){if(E=new mC1(new c81({thread:G.mainThread,onExecute:async()=>{let g=this.getCommandPaletteContext();if(g)await this.getPaletteCommands().execute("execute-plan",g,void 0,new AbortController)},onEdit:async()=>{try{let g=process.env.EDITOR||process.env.VISUAL||"nano",{filePath:i}=await this.widget.dependencies.planFileManager.ensureSync(G.mainThread.id);E9.instance.tuiInstance.suspend();let{execSync:Y1}=await import("child_process");Y1(`${g} "${i}"`,{stdio:"inherit"}),E9.instance.tuiInstance.resume()}catch(g){f.error("Failed to edit plan",g),this.setState(()=>{this.displayMessage=Error("Failed to edit plan")})}},controller:this.planScrollController,appTheme:X}),{clipBehavior:"antiAlias"}),L)P=new H91({queuedMessages:N});else if(M)P=this.buildScrollableTodoList(Z,this.isTextfieldAndAutocompleteFocused&&!z,X)}else E=L?new H91({queuedMessages:N}):void 0,P=M?this.buildScrollableTodoList(Z,this.isTextfieldAndAutocompleteFocused&&!z,X):void 0;let I=[],R=this.currentShellModeStatus;if(R)I.push({text:new J1(R==="hidden"?"shell mode (incognito)":"shell mode",new H1({color:R==="hidden"?X.app.shellModeHidden:X.app.shellMode})),position:"top-left"});if(!R&&this.cachedVisibleModes.length>1){let g=this.previewThread,i=g?g.agentMode??this.getEffectiveAgentMode():this.getEffectiveAgentMode(),Y1=$k1(i,this.tryOpus);if(g)I.push({text:new J1(i,new H1({color:Y1})),position:"top-left",offsetY:0});else{let b=Ik(i,this.cachedVisibleModes)!==i,s=this.widget.dependencies.getCurrentWorker()||this.widget.dependencies.worker,q1=_$(s.thread)===0,o=z||!this.hasToggledAgentMode&&b&&q1?new J1("",void 0,[new J1(i,new H1({color:Y1})),new J1(" (click or ",new H1({color:Y.foreground,dim:!0})),new J1("Ctrl+S",new H1({color:W.keybind})),new J1(" to switch)",new H1({color:Y.foreground,dim:!0}))]):new J1(i,new H1({color:Y1}));I.push({text:o,position:"top-left",offsetY:0,onClick:q1?this.toggleAgentMode:void 0})}}if(this.connectedClientsStatus&&this.connectedClientsStatus.enabled){let g=this.connectedClientsStatus,i=g.mode||"disconnected",Y1=!!g.errorMessage,a=g.clientID||"unknown",b,s;if(Y1)b="●",s=O1.red;else if(i==="presence")b="○",s=O1.yellow;else if(i==="connected"&&g.connected)b="●",s=O1.green;else b="○",s=O1.yellow;let q1=this.connectedClientsStatusExpanded?`${a} ${b}`:b;I.push({text:new J1(q1,new H1({color:s})),position:"top-right",offsetX:-2,offsetY:0,onClick:this.toggleConnectedClientsStatus})}let S=K?this.widget.dependencies.replayMode.thread.env?.initial.trees?.[0]?.uri:G.mainThread?.env?.initial.trees?.[0]?.uri,y;if(S)y=n0.parse(S).fsPath;else y=process.cwd();let h=this.toHomeRelative(y),u=this.shorten(h),p=!K&&this.currentGitBranch?`${u} (${this.currentGitBranch})`:u;return I.push({text:new J1(p,new H1({color:Y.foreground,dim:!0})),position:"bottom-right"}),new Vj1({leftChild:new z4({child:U}),rightChild1:E,rightChild2:P,maxHeight:q,overlayTexts:I,borderColor:z||!this.isTextfieldAndAutocompleteFocused?O1.index(8):void 0,hasBanner:V,userHeight:this.bottomGridUserHeight,onInitializeHeight:(g)=>{this.setState(()=>{this.bottomGridUserHeight=Math.min(g,q)})},onDrag:(g)=>{if(this.bottomGridDragStartY===null)this.bottomGridDragStartY=Math.floor(g.localPosition.y),this.bottomGridDragStartHeight=this.bottomGridUserHeight;let i=Math.floor(g.localPosition.y)-this.bottomGridDragStartY,Y1=Math.max(4,this.bottomGridDragStartHeight-i),a=Math.min(Y1,q),b=Math.floor(a);if(this.bottomGridUserHeight!==b)this.setState(()=>{this.bottomGridUserHeight=b})},onDragRelease:()=>{this.bottomGridDragStartY=null,this.bottomGridDragStartHeight=null},enableResize:!V})}}async function qk1(J){if((await J.configService.getLatest()).settings["terminal.animation"]===!1)E9.instance.tuiInstance.setOptions({queryOptions:{animationDisabled:!0}});let X=()=>null,Z=!1,q=new Vz(Z,1000,J.inspectorPort),V=J.features?.find((A)=>A.name==="amp-connect")?.enabled??!1,K=new F_1({threadService:J.threadService,worker:J.worker,builder:(A,E,P,I,R,S)=>{if(X=R,J.threadDependencies&&V)PC1(J.threadDependencies,J.configService,R,I,J.connectedClientsService,J.startNewThread,J.switchToThread,J.clientId).catch((u)=>{f.error("Failed to start automatic presence:",u)});let y=R(),h={...J,worker:y,threadID:y.thread.id};return new HY6({...h,threadState:E,workerController:P,switchWorker:I,getCurrentWorker:R,recentThreadIDs:S})}}),W=new Fj1({configService:J.configService,child:K}),H=new Wj1({configService:J.configService,child:W}),z=new sC1(H),U=new x6({data:DC.fromBaseTheme(fZ.default()),child:z});try{await rR1(U,{onRootElementMounted:(A)=>{if(f.info("TUI input ready for user interaction"),Z)q.start(A)}})}finally{if(Z)q.stop();if(J.threadDependencies&&V){let{stopGlobalSession:A}=await Promise.resolve().then(() => (TC1(),H76));A()}}let M=X()?.thread.id||J.threadID,L=await J.threadService.get(M);if(L&&L.messages.length>0){let A=`${J.ampURL.replace(/\/$/,"")}/threads/${M}`;y76(L,A,J.stdout)}}function $k1(J,Q){return J==="smart"?Q?O1.rgb(0,255,136):O1.rgb(145,119,199):J==="rush"?O1.rgb(228,180,2):F5(J)?O1.rgb(0,184,255):J==="plan"?O1.rgb(153,102,255):gN8(J)}class FY6 extends G6{props;constructor(J){super();this.props=J}createState(){return new UY6}}class UY6 extends X6{viewportHeight=1;scrollListenerAttached=!1;initState(){if(!this.scrollListenerAttached)this.widget.props.controller.addListener(()=>{this.updateViewportHeight()}),this.scrollListenerAttached=!0}build(J){let{todos:Q,controller:Y,appTheme:X}=this.widget.props;return new Q4({crossAxisAlignment:"stretch",children:[new z4({child:new O2({controller:Y,autofocus:!1,child:new U_1({todos:Q})})}),new XG({controller:Y,thumbColor:X.app.scrollbarThumb,trackColor:X.app.scrollbarTrack,getScrollInfo:()=>{let{maxScrollExtent:G,offset:Z}=Y,q=this.viewportHeight,V=G+q;return{totalContentHeight:Math.max(V,0),viewportHeight:Math.max(q,1),scrollOffset:Math.max(Z,0)}}})]})}updateViewportHeight(){let J=this.getViewportHeight();if(J!==this.viewportHeight)this.viewportHeight=J}getViewportHeight(){let J=this.context.findRenderObject();if(!J)return this.viewportHeight;let Q=(X,G=0)=>{if(X&&"size"in X&&"children"in X){let Z=X.children||[];for(let q of Z){if(q&&"size"in q){let K=q.size;if(typeof K?.height==="number"&&K.height>0)return K.height}let V=Q(q,G+1);if(V>0)return V}}return 0},Y=Q(J);if(Y>0)return Y;if("size"in J){let X=J.size;if(typeof X?.height==="number"&&X.height>0)return X.height}return this.viewportHeight}}class BY6 extends I6{props;constructor(J){super();this.props=J}build(J){return new _8({child:new U0({height:1}),cursor:l9.NS_RESIZE,onDrag:(Q)=>{if(this.props.userHeight===void 0){let X=J.findRenderObject()?.size.height??0;if(X>0){this.props.onInitializeHeight(X);return}}this.props.onDrag(Q)},onRelease:this.props.onRelease})}}function gN8(J){let Q=0;for(let G=0;G<J.length;G++){let Z=J.charCodeAt(G);Q=(Q<<5)-Q+Z,Q=Q&Q}let Y=[9,10,11,12,13,14,15,208,209,210,211,212,213,214,215],X=Math.abs(Q)%Y.length;return O1.index(Y[X])}oR1();try{if(process.platform==="win32")await Promise.resolve().then(() => N6(aC(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){iZ.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
4820
- `)}var fy1=vy1.join(zz0||vy1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function $O8(J){process.emitWarning=function(Q,Y,X,G){let Z=typeof Q==="string"?Q:Q.message||String(Q),q=Y||"Warning",V=!1;J.warn(Z,{name:q,code:X})}}function kq(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")hG("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")hG("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("tryOpus")==="cli"&&Q.tryOpus)hG("tryOpus",!0);if(J.getOptionValueSourceWithGlobals("useSonnet")==="cli")hG("model.sonnet",Q.useSonnet)}async function by1(J){try{await XO8(vy1.dirname(fy1),{recursive:!0}),await GO8(fy1,J,"utf-8")}catch(Q){f.debug("Failed to save last thread ID",Q)}}async function qO8(){try{return(await uZ6(fy1,"utf-8")).trim()}catch(J){return null}}var bZ6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??SZ,description:`Custom settings file path (overrides the default location ${SZ})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(f).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${JR1})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:c2(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Gemini 3":"Use default model (Gemini 3)"},{name:"tryOpus",long:"try-opus",type:"switch",default:!1,description:"Try Claude Opus 4.5 in Amp's smart mode",hidden:!1},{name:"mode",long:"mode",short:"m",type:"option",default:cE.SMART.key,description:`Set the agent mode (${uG().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:uG().map((J)=>J.mode)}],gZ6=(J)=>("deprecated"in J)&&J.deprecated===!0,VO8=(J)=>("hidden"in J)&&J.hidden===!0,KO8=(J)=>("default"in J),WO8=(J)=>("default"in J)?J.default:void 0;function HO8(J,Q){let Y=Q.args[0],X=Q.commands.map((Z)=>Z.name());if(Y&&!Y.includes(" ")&&Y.length<30&&!/[./\\]/.test(Y)){let Z=X.filter((V)=>Y.includes(V)||V.includes(Y)),q="Run amp --help for a list of available commands.";if(Z.length>0)q=`Did you mean: ${Z.join(", ")}? Or run amp --help for all commands.`;throw new j8(jZ.unknownCommand(Y),1,q)}}var pZ6=null;function tz5(){return pZ6}function lm(J){return{...J,getThreadEnvironment:V61,vfs:Mj0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new vv(J.fileSystem),generateThreadTitle:xc0,deleteThread:(Q)=>J.threadService.delete(Q)}}var gy1=n0.file(ZO8.homedir()),dZ6=process.env.XDG_CONFIG_HOME?n0.file(process.env.XDG_CONFIG_HOME):Z6.joinPath(gy1,".config");async function yq(J,Q){cU0("0.0.1764165115-gcd064d");let Y=N$1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:G0.of([n0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:gy1,userConfigDir:dZ6}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (F91(),z91));X(Y);let G=await Y.getLatest();f.debug("Global configuration initialized",{settingsKeys:Object.keys(G.settings)});let{toolService:Z,dispose:q}=Xt0({configService:Y}),V=new Map,K=()=>V.clear(),W=new BN1(Y,J.settings.getWorkspaceRootPath()),H=CC0({configService:Y,trustStore:W,createOAuthProvider:async(a)=>{let b=V.get(a);if(b)return f.debug("Reusing existing OAuth provider for server",{serverName:a}),b;f.debug("Creating OAuth provider for server",{serverName:a});let s=(async()=>{let q1=new _M(J.secrets),K1=await q1.getClientInfo(a),o=new gz1({storage:q1,serverName:a,clientId:K1?.clientId,clientSecret:K1?.clientSecret,scopes:K1?.scopes});return f.debug("OAuth provider created",{serverName:a,hasManualClientId:!!K1?.clientId,willUseDCR:!K1?.clientId}),o})();return V.set(a,s),s}}),z=M01({configService:Y,filesystem:U5,spawn:OA}),{initializeToolProviders:U}=await Promise.resolve().then(() => (hZ6(),fZ6)),{registrations:N,initErrors:M}=await U({toolService:Z,providers:[H,z],initialTimeout:J.executeMode?15000:5000});for(let[a,b]of M)f.warn(`${a} provider initialization slow or failed:`,b);if(Q.jetbrains)eE("JetBrains");else if(Q.ide&&$86())eE("VS Code");else if(Q.ide&&q86())eE("Neovim");if(J.executeMode)lU0(!0);let L,A=z2.status.pipe(q6((a)=>Boolean(a.connected&&a.authenticated)),x4()).subscribe((a)=>{if(a){if(!L)L=Z.registerTool(ur0)}else L?.dispose(),L=void 0}),E;if(!J.executeMode)E=new L61(process.cwd(),{},!0);else E=new class extends L61{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(i5.write(`No API key found. Starting login flow...
4819
+ `)}var fy1=vy1.join(zz0||vy1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function $O8(J){process.emitWarning=function(Q,Y,X,G){let Z=typeof Q==="string"?Q:Q.message||String(Q),q=Y||"Warning",V=!1;J.warn(Z,{name:q,code:X})}}function kq(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")hG("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")hG("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("tryOpus")==="cli"&&Q.tryOpus)hG("tryOpus",!0);if(J.getOptionValueSourceWithGlobals("useSonnet")==="cli")hG("model.sonnet",Q.useSonnet)}async function by1(J){try{await XO8(vy1.dirname(fy1),{recursive:!0}),await GO8(fy1,J,"utf-8")}catch(Q){f.debug("Failed to save last thread ID",Q)}}async function qO8(){try{return(await uZ6(fy1,"utf-8")).trim()}catch(J){return null}}var bZ6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??SZ,description:`Custom settings file path (overrides the default location ${SZ})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(f).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${JR1})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:c2(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Gemini 3":"Use default model (Gemini 3)"},{name:"tryOpus",long:"try-opus",type:"switch",default:!1,description:"Try Claude Opus 4.5 in Amp's smart mode",hidden:!1},{name:"mode",long:"mode",short:"m",type:"option",default:cE.SMART.key,description:`Set the agent mode (${uG().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:uG().map((J)=>J.mode)}],gZ6=(J)=>("deprecated"in J)&&J.deprecated===!0,VO8=(J)=>("hidden"in J)&&J.hidden===!0,KO8=(J)=>("default"in J),WO8=(J)=>("default"in J)?J.default:void 0;function HO8(J,Q){let Y=Q.args[0],X=Q.commands.map((Z)=>Z.name());if(Y&&!Y.includes(" ")&&Y.length<30&&!/[./\\]/.test(Y)){let Z=X.filter((V)=>Y.includes(V)||V.includes(Y)),q="Run amp --help for a list of available commands.";if(Z.length>0)q=`Did you mean: ${Z.join(", ")}? Or run amp --help for all commands.`;throw new j8(jZ.unknownCommand(Y),1,q)}}var pZ6=null;function tz5(){return pZ6}function lm(J){return{...J,getThreadEnvironment:V61,vfs:Mj0({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new vv(J.fileSystem),generateThreadTitle:xc0,deleteThread:(Q)=>J.threadService.delete(Q)}}var gy1=n0.file(ZO8.homedir()),dZ6=process.env.XDG_CONFIG_HOME?n0.file(process.env.XDG_CONFIG_HOME):Z6.joinPath(gy1,".config");async function yq(J,Q){cU0("0.0.1764172241-gaca8cf");let Y=N$1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:G0.of([n0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:gy1,userConfigDir:dZ6}),{initializeCLITelemetry:X}=await Promise.resolve().then(() => (F91(),z91));X(Y);let G=await Y.getLatest();f.debug("Global configuration initialized",{settingsKeys:Object.keys(G.settings)});let{toolService:Z,dispose:q}=Xt0({configService:Y}),V=new Map,K=()=>V.clear(),W=new BN1(Y,J.settings.getWorkspaceRootPath()),H=CC0({configService:Y,trustStore:W,createOAuthProvider:async(a)=>{let b=V.get(a);if(b)return f.debug("Reusing existing OAuth provider for server",{serverName:a}),b;f.debug("Creating OAuth provider for server",{serverName:a});let s=(async()=>{let q1=new _M(J.secrets),K1=await q1.getClientInfo(a),o=new gz1({storage:q1,serverName:a,clientId:K1?.clientId,clientSecret:K1?.clientSecret,scopes:K1?.scopes});return f.debug("OAuth provider created",{serverName:a,hasManualClientId:!!K1?.clientId,willUseDCR:!K1?.clientId}),o})();return V.set(a,s),s}}),z=M01({configService:Y,filesystem:U5,spawn:OA}),{initializeToolProviders:U}=await Promise.resolve().then(() => (hZ6(),fZ6)),{registrations:N,initErrors:M}=await U({toolService:Z,providers:[H,z],initialTimeout:J.executeMode?15000:5000});for(let[a,b]of M)f.warn(`${a} provider initialization slow or failed:`,b);if(Q.jetbrains)eE("JetBrains");else if(Q.ide&&$86())eE("VS Code");else if(Q.ide&&q86())eE("Neovim");if(J.executeMode)lU0(!0);let L,A=z2.status.pipe(q6((a)=>Boolean(a.connected&&a.authenticated)),x4()).subscribe((a)=>{if(a){if(!L)L=Z.registerTool(ur0)}else L?.dispose(),L=void 0}),E;if(!J.executeMode)E=new L61(process.cwd(),{},!0);else E=new class extends L61{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(i5.write(`No API key found. Starting login flow...
4821
4820
  `),!await zO8(J))await bA(),process.exit(1)}let P=await Ij0({isDevelopment:!1}),I=new AE1(P,Y),R=new BE1(P,{lazy:!0}),S=new PN1(I,(a,b)=>{let s=N3.get(a);if(s)s.handle(b).catch((q1)=>{f.error("Failed to apply artifact delta",q1)})}),y=Q.notifications!==void 0?Q.notifications:!J.executeMode,h=Zt0({playNotificationSound:async(a)=>{if(y){Gt0(a);let b=nR1(),s=aR1();if((!b||s)&&G.settings["notifications.system.enabled"]!==!1){if(a==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(a==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:I,configService:Y});f.info("Starting Amp background services");let u=fc0({threadService:I,threadHistoryService:R,configService:Y,isExtensionDevelopment:!1}),p;z2.status.subscribe((a)=>{p=a});let g=new QZ1({workspaceRoots:[n0.file(process.cwd())],getCurrentFile:()=>{if(!p?.openFile)return;try{return n0.parse(p.openFile)}catch(a){f.warn("Failed to parse current file URI",{uri:p.openFile,error:a});return}},getOpenFiles:()=>{if(!p?.visibleFiles?.length)return[];let a=p.openFile;return p.visibleFiles.filter((b)=>b!==a).map((b)=>{try{return n0.parse(b)}catch(s){return f.warn("Failed to parse visible file URI",{uri:b,error:s}),null}}).filter((b)=>b!==null)}}),i=new sR1,Y1={codebaseContextService:g,configService:Y,toolService:Z,mcpService:H,trustStore:W,threadService:I,threadHistoryService:R,threadSyncService:u,planFileManager:S,threadStorage:P,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:E,notificationService:h,fileSystem:Q.jetbrains||Q.ide?Bj0:U5,terminal:i};return{...Y1,async asyncDispose(){for(let a of N.values())a.dispose();await Y1.mcpService.dispose(),K(),await Y1.threadService.asyncDispose(),Y1.configService.unsubscribe(),q(),Y1.fuzzyServer.dispose(),Y1.threadSyncService.dispose(),Y1.settingsStorage[Symbol.dispose](),A.unsubscribe(),L?.dispose()}}}async function zO8(J){if(!J.executeMode){if(!await PR1("Would you like to log in to Amp? [(y)es, (n)o]: "))return i5.write(`Login cancelled. Run the command again to retry.
4822
4821
  `),!1}return await cZ6(J)}async function cZ6(J){let Q=YO8(32).toString("hex"),Y=await IR1(J.ampURL,Q),X=new AbortController;try{await j3(Y,X.signal)}catch(Z){f.error("Error opening browser",{error:Z})}let G=await IR1(J.ampURL,Q,!1);i5.write(`If your browser does not open automatically, visit:
4823
4822
 
@@ -4827,15 +4826,15 @@ ${h4.blue.bold(G)}
4827
4826
  Login successful! You can now use the Amp CLI.
4828
4827
  `),!0}catch(Z){return f.error("Login failed",{error:Z}),iZ.write(`
4829
4828
  Login failed: ${Z instanceof Error?Z.message:String(Z)}
4830
- `),!1}}function FO8(){let J=new TA().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)hR(),process.exit(0);let z=H.originalError??H;Q46(z)}),J.option("-V, --version","Print the version number and exit",()=>{i5.write(`0.0.1764165115-gcd064d (released 2025-11-26T13:57:15.335Z)
4829
+ `),!1}}function FO8(){let J=new TA().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)hR(),process.exit(0);let z=H.originalError??H;Q46(z)}),J.option("-V, --version","Print the version number and exit",()=>{i5.write(`0.0.1764172241-gaca8cf (released 2025-11-26T15:56:07.011Z)
4831
4830
  `),process.exit(0)}),J.addHelpText("after",X86()),J.configureHelp({formatHelp:G86}),J.command("logout").description("Log out by removing stored API key").action(async(H,z)=>{let U=z.optsWithGlobals(),N=await tQ(U);await DO8(N)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(H,z)=>{let U=z.optsWithGlobals(),N=await tQ(U);await NO8(N,await FR1(U,N.settings))});let Q=async(H,z,U)=>{N$1({storage:z.settings,secretStorage:z.secrets,workspaceRoots:G0.of([n0.file(process.cwd())]),defaultAmpURL:z.ampURL,homeDir:gy1,userConfigDir:dZ6});let N={...z,executeMode:!1};await hy1(N,{...H,openThreadSwitcher:!0},U)},Y=J.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").action(async(H,z)=>{let U=z.optsWithGlobals(),N=await tQ(U);await mZ6(U,N,z)});Y.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(H,z)=>{let U=z.optsWithGlobals(),N=await tQ(U);await IO8(U,N,z)}),Y.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. By default, shows an interactive picker with the most recently used thread at the top. Use --last to continue the last thread directly without the picker.").option("--last","Continue the last thread directly without showing the picker").option("--pick","Pick a thread interactively from a list (DEPRECATED: picker is now the default)").action(async(H,z,U)=>{let N=U.optsWithGlobals(),M=await tQ(N);if(z.pick)iZ.write(`${h4.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
4832
4831
  `);if(z.last||H||M.executeMode)await EO8(N,M,H,U);else await Q(N,M,U)}),Y.command("fork [threadId]").alias("f").summary("Fork an existing thread").description("Create a new thread by forking an existing one. This copies the conversation history up to the current point and creates a new thread where you can explore different directions. If no thread ID is provided, the most recently used thread will be forked.").action(async(H,z,U)=>{let N=U.optsWithGlobals(),M=await tQ(N);await wO8(N,M,H,U)}),Y.command("list").alias("l").alias("ls").summary("List all threads").description("List all your threads with their IDs, names, and last modified times.").action(async(H,z)=>{let U=z.optsWithGlobals(),N=await tQ(U);await mZ6(U,N,z)}),Y.command("share <threadId>").summary("Share a thread").description("Change thread visibility (private, public, unlisted, workspace, group) or share with Amp support for debugging. Use --visibility to change who can access the thread, or --support to share with the Amp team for troubleshooting.").alias("s").option("--visibility <visibility>","Set thread visibility (private, public, unlisted, workspace, group)").option("--support [message]","Share thread with Amp support for debugging").action(async(H,z,U)=>{let N=U.optsWithGlobals(),M=await tQ(N);await OO8(N,M,H,U,z.support)}),Y.command("rename <threadId> <newName>").alias("r").summary("Rename a thread").description('Change the title of a thread. Quote names with spaces: amp threads rename T-123 "New thread name"').action(async(H,z,U,N)=>{let M=N.optsWithGlobals(),L=await tQ(M);await MO8(M,L,H,z,N)}),Y.command("markdown <threadId>").alias("md").summary("Render thread as markdown").description("Render a thread as markdown. This outputs the entire conversation history in a readable markdown format.").action(async(H,z,U)=>{let N=U.optsWithGlobals(),M=await tQ(N);await LO8(N,M,H,U)}),Y.command("replay <threadId>").alias("p").summary("Replay a thread").description("Replay a thread by downloading it and playing through all interactions. User messages are simulated with variable typing speed.").option("--wpm <wpm>","Typing speed in words per minute (default: 120)","120").option("--no-typing","Disable typing simulation and display messages instantly").option("--message-delay <ms>","Delay between messages in milliseconds (default: 1000)","1000").option("--tool-progress-delay <ms>","Delay to show tool in-progress state in milliseconds (default: 800)","800").option("--exit-delay <seconds>","Delay in seconds before exiting after replay completes (default: 3)","3").option("--no-indicator","Hide the replay progress indicator").action(async(H,z,U)=>{let N=U.optsWithGlobals(),M=await tQ(N);await AO8(N,M,H,z,U)}),e96(J,async(H,z)=>{let U=await tQ(z);kq(H,z);let N=await yq(U,z);return{context:U,mcpService:N.mcpService,toolService:N.toolService,toolServices:N.toolService,configService:N.configService,cleanupTerminal:hR,asyncDispose:N.asyncDispose.bind(N)}}),u86(J,async(H)=>{let z=H.optsWithGlobals();return await tQ(z)}),_86(J,async(H)=>{let z=await tQ(H);return{settings:z.settings,secretStorage:z.secrets,getThreadDeps:async(U)=>{kq(U,H);let N=await yq(z,H);return{mcpService:N.mcpService,settings:z.settings,asyncDispose:N.asyncDispose.bind(N)}}}});function G(H,z,U){let M=typeof H.description==="string"?H.description:U===void 0?H.description(!0):H.description(U),L=new vB(z,M),A=WO8(H);if(A)L.default(A);if(L.hidden=VO8(H)||gZ6(H),"choices"in H)L.choices([...H.choices]);return L}for(let H of bZ6)switch(H.type){case"flag":{J.addOption(G(H,`--${H.long}`)),J.addOption(G(H,`--no-${H.long}`,!1));break}case"switch":{J.addOption(G(H,`--${H.long}`,!0));break}default:{J.addOption(G(H,`${"short"in H?`-${H.short}, `:""}--${H.long} <value>`));break}}let Z=new vB("-x, --execute [message]","Use execute mode, optionally with user message. In execute mode, agent will execute provided prompt (either as argument, or via stdin). Only last assistant message is printed. Enabled automatically when redirecting stdout.").default(!1);J.addOption(Z);let q=new vB("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1).hideHelp();J.addOption(q);let V=new vB("--stream-json","When used with --execute, output in Claude Code-compatible stream JSON format instead of plain text.").default(!1);J.addOption(V);let K=new vB("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(K);let W=new vB("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);if(J.addOption(W),process.env.AMP_CONNECT==="1"){let H=new vB("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(H)}return J.action(async(H,z)=>{let U=H,N=await tQ(U);if(Object.keys(U).forEach((M)=>{let L=bZ6.find((A)=>A.name===M);if(L&&gZ6(L)&&!KO8(L))iZ.write(h4.yellow(`Warning: '--${M}' flag is deprecated
4833
4832
  `))}),z.args.length>0)HO8(N,z);await hy1(N,U,z)}),E86(J),J}async function Q51(J,Q){let{thread:Y,visibility:X}=Q,G=Y?.id??j$(),Z=lm(J);if(Y)await J.threadStorage.set(G,Y);let q=await N3.getOrCreateForThread(Z,G),V=await J.threadStorage.get(G);if(Q.agentMode&&!V?.agentMode&&_$(q.thread)===0)await q.handle({type:"agent-mode",mode:Q.agentMode});if(X)await J.threadSyncService.updateThreadMeta(G,_61(X));let K=J.threadService.observe(G).subscribe(async(W)=>{if(GJ(W,"assistant"))await by1(G),K.unsubscribe()});return await q.resume(),q}async function hy1(J,Q,Y){let X=S61(Q);if(X instanceof Error)lZ(X.message);let G,Z=null;if(Q.streamJsonInput)G="";else if(typeof Q.execute==="string"){G=Q.execute;let i=(await TR1()).trimEnd();if(i)Z=i}else G=(await TR1()).trimEnd();if(Q.remote&&!J.executeMode)throw new j8("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new j8("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new j8("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new j8("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if((J.executeMode||Q.streamJson)&&F5(Q.mode))throw new j8(`Execute mode is not permitted with --mode '${Q.mode}'`,1);if(Q.stats&&!J.executeMode)throw new j8("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(Q.streamJsonInput&&typeof Q.execute==="string"&&Q.execute.trim()!=="")throw new j8("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(J.executeMode&&G===""&&!Q.streamJsonInput)throw new j8("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp --execute "your message"
4834
4833
  Or pipe via stdin: echo "your message" | amp --execute`);kq(Y,Q);let q=await yq(J,Q);pZ6=q;let V=lm(q),K=async(i)=>{let Y1=await uZ6(i,"utf-8"),a=JSON.parse(Y1);if(!S$(a.id))throw new j8(jZ.invalidThreadId);return Q51(q,{visibility:X,agentMode:Q.mode,thread:a})},W=async(i)=>{if(!S$(i))throw new j8(jZ.invalidThreadId);try{let[a,b]=await Promise.all([E5.getThreadLinkInfo({thread:i},{config:q.configService}),E5.getUserInfo({},{config:q.configService})]);if(a.ok&&b.ok){let s=a.result.creatorUserID,q1=b.result.id;if(s&&s!==q1&&!process.env.AMP_RESUME_OTHER_USER_THREADS_INSECURE)throw new j8(`Cannot resume thread created by another user.
4835
4834
 
4836
4835
  This thread belongs to a different user and cannot be continued for security reasons. Set AMP_RESUME_OTHER_USER_THREADS_INSECURE=1 to bypass this check.`)}}catch(a){if(a instanceof j8)throw a;f.warn("Failed to validate thread ownership in CLI, allowing to open",{error:a})}let Y1=await q.threadService.get(i)??void 0;return f.info(`[fetchAndStartThread] Loaded thread ${i}, agentMode: ${Y1?.agentMode??"undefined"}`),Q51(q,{visibility:X,agentMode:Y1?void 0:Q.mode,thread:Y1})},H=async()=>{try{if(Q.threadId)return W(Q.threadId);else return Q51(q,{visibility:X})}catch(i){if(i instanceof j8)throw i;throw await Fg(i,Q.threadId),Error("handleError should have called process.exit()")}},z=async()=>{return Q51(q,{visibility:X})};if(Q.format==="jsonl")iZ.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
4837
- `),await bA(),process.exit(1);if(J.executeMode&&Q.remote)await p86(G,Z,q.configService),await q.asyncDispose(),process.exit(0);let U=await H();if(J.executeMode)x86(q.mcpService,J.settings),await B46(U,U.threadID,G,Z,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let N=!1,M=!1;if(Q.jetbrains||Q.ide){await VD0();let i=BI({jetbrainsOnly:Q.jetbrains});if(i.length===0){if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall")}else if(i.length===1){let Y1=i[0];if(Y1)z2.selectConfig(Y1)}else N=!0}let L=C61("0.0.1764165115-gcd064d",q.settingsStorage),A=new H11(q.threadStorage),E=G0.of([n0.file(process.cwd())]),P=zZ1(void 0,E),I=new j61(q.mcpService,J.settings.getWorkspaceRootPath());if(G)U.handle({type:"user:message",message:{content:[{type:"text",text:G}]}});let R=(async()=>{try{let i=await E5.getUserFreeTierStatus({},{config:q.configService,signal:AbortSignal.timeout(5000)});if(i.ok)return f.info("User free tier status:",i),i.result}catch(i){f.error("Failed to fetch free tier status:",i)}})(),S=(async()=>{try{let i=await E5.getUserInfo({},{config:q.configService});if(i.ok)return i.result}catch(i){f.debug("Failed to fetch user workspace info:",i)}})(),[y,h]=await Promise.all([R,S]),u=h?.email,p=u&&(u.endsWith("@sourcegraph.com")||u.endsWith("@ampcode.com")||u==="auth-bypass-user@example.com");if(p)q.toolService.registerTool(cr0);let g=await i86();f.info("Loaded session state:",g),await qk1({codebaseContextService:q.codebaseContextService,stdout:process.stdout,history:new z61,fuzzyServer:q.fuzzyServer,settingsStorage:q.settingsStorage,threadService:q.threadService,threadHistoryService:q.threadHistoryService,threadSyncService:q.threadSyncService,planFileManager:q.planFileManager,threadID:U.threadID,threadFuzzyIndexer:A,worker:U,workerDeps:V,configService:q.configService,internalAPIClient:E5,ampURL:J.ampURL,startNewThread:z,switchToThread:W,ideClient:z2,connectedClientsService:new Zi,commandRegistry:P,mcpService:q.mcpService,mcpTrustHandler:I,showJetBrainsInstaller:M,showIdePicker:N,openThreadSwitcher:Q.openThreadSwitcher,updateService:L,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:g,freeTierStatus:y,workspace:h?.team??null,features:h?.features??[],isDogfooding:p||!1,threadDependencies:q}),await q.asyncDispose(),process.exit(0)}async function tQ(J){if(J.interactive)iZ.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
4838
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Y=process.stdout.isTTY&&process.stderr.isTTY,X=await u46({...J,workspaceTrust:{current:!0,changes:n_},getHook:process.env.AMP_URL?(Z,q)=>{if(Z==="url")return Promise.resolve(process.env.AMP_URL);return q()}:void 0});if(J.mcpConfig){let Z=await k86(J.mcpConfig);X=y86(X,Z)}let G=await X.get("url","global");if(!G)G=zY;if(!xF(G))f.info("Targeting custom Amp server",{ampURL:G});return X=WF0(X),{executeMode:Q,isTTY:Y,ampURL:G,settings:X,secrets:d86(await FR1(J,X))}}function UO8(J){let Q={};for(let Y=0;Y<J.length;Y++){let X=J[Y];if(X?.startsWith("--")){let Z=X.slice(2).replace(/-([a-z])/g,(V,K)=>K.toUpperCase()),q=J[Y+1];if(q&&!q.startsWith("--"))Q[Z]=q,Y++}}return Q}async function BO8(){let J=UO8(process.argv);if(i66({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),$O8(f),f.info("Starting Amp CLI.",{version:"0.0.1764165115-gcd064d",buildTimestamp:"2025-11-26T13:57:15.335Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new j8(jZ.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await FO8().parseAsync(process.argv)}WE1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await BO8().catch(Fg)});async function NO8(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),i5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
4836
+ `),await bA(),process.exit(1);if(J.executeMode&&Q.remote)await p86(G,Z,q.configService),await q.asyncDispose(),process.exit(0);let U=await H();if(J.executeMode)x86(q.mcpService,J.settings),await B46(U,U.threadID,G,Z,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let N=!1,M=!1;if(Q.jetbrains||Q.ide){await VD0();let i=BI({jetbrainsOnly:Q.jetbrains});if(i.length===0){if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall")}else if(i.length===1){let Y1=i[0];if(Y1)z2.selectConfig(Y1)}else N=!0}let L=C61("0.0.1764172241-gaca8cf",q.settingsStorage),A=new H11(q.threadStorage),E=G0.of([n0.file(process.cwd())]),P=zZ1(void 0,E),I=new j61(q.mcpService,J.settings.getWorkspaceRootPath());if(G)U.handle({type:"user:message",message:{content:[{type:"text",text:G}]}});let R=(async()=>{try{let i=await E5.getUserFreeTierStatus({},{config:q.configService,signal:AbortSignal.timeout(5000)});if(i.ok)return f.info("User free tier status:",i),i.result}catch(i){f.error("Failed to fetch free tier status:",i)}})(),S=(async()=>{try{let i=await E5.getUserInfo({},{config:q.configService});if(i.ok)return i.result}catch(i){f.debug("Failed to fetch user workspace info:",i)}})(),[y,h]=await Promise.all([R,S]),u=h?.email,p=u&&(u.endsWith("@sourcegraph.com")||u.endsWith("@ampcode.com")||u==="auth-bypass-user@example.com");if(p)q.toolService.registerTool(cr0);let g=await i86();f.info("Loaded session state:",g),await qk1({codebaseContextService:q.codebaseContextService,stdout:process.stdout,history:new z61,fuzzyServer:q.fuzzyServer,settingsStorage:q.settingsStorage,threadService:q.threadService,threadHistoryService:q.threadHistoryService,threadSyncService:q.threadSyncService,planFileManager:q.planFileManager,threadID:U.threadID,threadFuzzyIndexer:A,worker:U,workerDeps:V,configService:q.configService,internalAPIClient:E5,ampURL:J.ampURL,startNewThread:z,switchToThread:W,ideClient:z2,connectedClientsService:new Zi,commandRegistry:P,mcpService:q.mcpService,mcpTrustHandler:I,showJetBrainsInstaller:M,showIdePicker:N,openThreadSwitcher:Q.openThreadSwitcher,updateService:L,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:g,freeTierStatus:y,workspace:h?.team??null,features:h?.features??[],isDogfooding:p||!1,threadDependencies:q}),await q.asyncDispose(),process.exit(0)}async function tQ(J){if(J.interactive)iZ.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
4837
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Y=process.stdout.isTTY&&process.stderr.isTTY,X=await u46({...J,workspaceTrust:{current:!0,changes:n_},getHook:process.env.AMP_URL?(Z,q)=>{if(Z==="url")return Promise.resolve(process.env.AMP_URL);return q()}:void 0});if(J.mcpConfig){let Z=await k86(J.mcpConfig);X=y86(X,Z)}let G=await X.get("url","global");if(!G)G=zY;if(!xF(G))f.info("Targeting custom Amp server",{ampURL:G});return X=WF0(X),{executeMode:Q,isTTY:Y,ampURL:G,settings:X,secrets:d86(await FR1(J,X))}}function UO8(J){let Q={};for(let Y=0;Y<J.length;Y++){let X=J[Y];if(X?.startsWith("--")){let Z=X.slice(2).replace(/-([a-z])/g,(V,K)=>K.toUpperCase()),q=J[Y+1];if(q&&!q.startsWith("--"))Q[Z]=q,Y++}}return Q}async function BO8(){let J=UO8(process.argv);if(i66({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),$O8(f),f.info("Starting Amp CLI.",{version:"0.0.1764172241-gaca8cf",buildTimestamp:"2025-11-26T15:56:07.011Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new j8(jZ.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await FO8().parseAsync(process.argv)}WE1().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await BO8().catch(Fg)});async function NO8(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),i5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
4839
4838
  `);else if(!xF(J.ampURL))i5.write(`Logging in to ${new URL(J.ampURL).hostname}
4840
4839
  `);let Y=process.env.AMP_API_KEY;if(Y)i5.write(`API key found in environment variable, storing...
4841
4840
  `),await Q.set("apiKey",Y,J.ampURL),i5.write(`API key successfully stored.
@@ -4848,7 +4847,7 @@ This thread belongs to a different user and cannot be continued for security rea
4848
4847
  `);else i5.write(`Successfully logged out from ${new URL(J.ampURL).hostname}.
4849
4848
  `);process.exit(0)}async function MO8(J,Q,Y,X,G){kq(G,J);let Z=await yq(Q,J);try{let q=Y51(Y);if(!q)X51(Y);let V=q,K=X.trim();if(K.length===0)lZ("Thread name cannot be empty");if(K.length>256)lZ("Thread name cannot exceed 256 characters");if(!(await oC(V,Z)).messages.length)lZ("Cannot rename an empty thread.");let H=lm(Z);await(await N3.getOrCreateForThread(H,V)).handle({type:"title",value:K}),f.info("GOT HERE"),await Z.threadSyncService.sync(),f.info("GOT THERE"),i5.write(h4.green(`✓ Thread ${V} renamed to "${K}"
4850
4849
  `)),await Z.asyncDispose(),process.exit(0)}catch(q){await Z.asyncDispose();let V=`Failed to rename thread: ${q instanceof Error?q.message:String(q)}`;lZ(V)}}async function LO8(J,Q,Y,X){kq(X,J);let G=await yq(Q,J);try{let Z=Y51(Y);if(!Z)X51(Y);let V=await oC(Z,G),K=$R(V);i5.write(K+`
4851
- `),await G.asyncDispose(),process.exit(0)}catch(Z){await G.asyncDispose();let q=`Failed to render thread as markdown: ${Z instanceof Error?Z.message:String(Z)}`;lZ(q)}}async function AO8(J,Q,Y,X,G){kq(G,J);let Z=await yq(Q,J);try{let q=await my1(Y),V=await oC(q,Z),K=X.typing!==!1,W=parseInt(X.wpm||"120",10),H=parseInt(X.messageDelay||"1000",10),z=parseInt(X.toolProgressDelay||"800",10),U=parseInt(X.exitDelay||"3",10)*1000,N=X.indicator!==!1,M=lm(Z),L=V.id;await Z.threadStorage.set(L,V);let A=await N3.getOrCreateForThread(M,L);await A.resume();let E=W11.fromWorker(A),P=new H11(Z.threadStorage),I=G0.of([n0.file(process.cwd())]),R=zZ1(void 0,I),S=new j61(Z.mcpService,Q.settings.getWorkspaceRootPath()),y=C61("0.0.1764165115-gcd064d",Z.settingsStorage);await qk1({codebaseContextService:Z.codebaseContextService,stdout:process.stdout,history:new z61,fuzzyServer:Z.fuzzyServer,settingsStorage:Z.settingsStorage,threadService:Z.threadService,threadHistoryService:Z.threadHistoryService,threadSyncService:Z.threadSyncService,planFileManager:Z.planFileManager,threadID:L,threadFuzzyIndexer:P,worker:E,workerDeps:M,configService:Z.configService,internalAPIClient:E5,ampURL:Q.ampURL,startNewThread:async()=>E,switchToThread:async()=>E,ideClient:z2,connectedClientsService:new Zi,commandRegistry:R,mcpService:Z.mcpService,mcpTrustHandler:S,showJetBrainsInstaller:!1,updateService:y,isDogfooding:!1,replayMode:{thread:V,typingEnabled:K,baseWpm:W,messageDelayMs:H,toolProgressDelayMs:z,exitDelayMs:U,showIndicator:N}}),await Z.asyncDispose(),process.exit(0)}catch(q){await Z.asyncDispose(),await Fg(q,Y)}}async function OO8(J,Q,Y,X,G){kq(X,J);let Z=await yq(Q,J);try{let q=Y51(Y);if(!q)X51(Y);let V=q,K=await E5.getUserInfo({},{config:Z.configService}),W=K.ok?K.result:null,H=S61(J,W);if(!H&&!G)lZ("Must specify either --visibility or --support");if(H&&G)lZ("Cannot specify both --visibility and --support at the same time");if(H instanceof Error)lZ(H.message);if(H)await Z.threadSyncService.updateThreadMeta(V,_61(H)),i5.write(h4.green("✓ ")+`Thread ${V} visibility changed to ${H}.
4850
+ `),await G.asyncDispose(),process.exit(0)}catch(Z){await G.asyncDispose();let q=`Failed to render thread as markdown: ${Z instanceof Error?Z.message:String(Z)}`;lZ(q)}}async function AO8(J,Q,Y,X,G){kq(G,J);let Z=await yq(Q,J);try{let q=await my1(Y),V=await oC(q,Z),K=X.typing!==!1,W=parseInt(X.wpm||"120",10),H=parseInt(X.messageDelay||"1000",10),z=parseInt(X.toolProgressDelay||"800",10),U=parseInt(X.exitDelay||"3",10)*1000,N=X.indicator!==!1,M=lm(Z),L=V.id;await Z.threadStorage.set(L,V);let A=await N3.getOrCreateForThread(M,L);await A.resume();let E=W11.fromWorker(A),P=new H11(Z.threadStorage),I=G0.of([n0.file(process.cwd())]),R=zZ1(void 0,I),S=new j61(Z.mcpService,Q.settings.getWorkspaceRootPath()),y=C61("0.0.1764172241-gaca8cf",Z.settingsStorage);await qk1({codebaseContextService:Z.codebaseContextService,stdout:process.stdout,history:new z61,fuzzyServer:Z.fuzzyServer,settingsStorage:Z.settingsStorage,threadService:Z.threadService,threadHistoryService:Z.threadHistoryService,threadSyncService:Z.threadSyncService,planFileManager:Z.planFileManager,threadID:L,threadFuzzyIndexer:P,worker:E,workerDeps:M,configService:Z.configService,internalAPIClient:E5,ampURL:Q.ampURL,startNewThread:async()=>E,switchToThread:async()=>E,ideClient:z2,connectedClientsService:new Zi,commandRegistry:R,mcpService:Z.mcpService,mcpTrustHandler:S,showJetBrainsInstaller:!1,updateService:y,isDogfooding:!1,replayMode:{thread:V,typingEnabled:K,baseWpm:W,messageDelayMs:H,toolProgressDelayMs:z,exitDelayMs:U,showIndicator:N}}),await Z.asyncDispose(),process.exit(0)}catch(q){await Z.asyncDispose(),await Fg(q,Y)}}async function OO8(J,Q,Y,X,G){kq(X,J);let Z=await yq(Q,J);try{let q=Y51(Y);if(!q)X51(Y);let V=q,K=await E5.getUserInfo({},{config:Z.configService}),W=K.ok?K.result:null,H=S61(J,W);if(!H&&!G)lZ("Must specify either --visibility or --support");if(H&&G)lZ("Cannot specify both --visibility and --support at the same time");if(H instanceof Error)lZ(H.message);if(H)await Z.threadSyncService.updateThreadMeta(V,_61(H)),i5.write(h4.green("✓ ")+`Thread ${V} visibility changed to ${H}.
4852
4851
  `);if(G){await oC(V,Z);let z=typeof G==="string"?G:void 0;await vT0(Z.threadService,V,Z.configService,z),i5.write(h4.green("✓ ")+`Thread ${V} has been shared with Amp support. These thread reports will be aggregated and analysed.
4853
4852
  `)}await Z.asyncDispose(),process.exit(0)}catch(q){await Z.asyncDispose(),lZ(`Failed to update thread: ${q instanceof Error?q.message:String(q)}`)}}async function wO8(J,Q,Y,X){kq(X,J);let G=await yq(Q,J),Z=lm(G);try{let q=await my1(Y),K=(await oC(q,G)).messages.length-1,W=await N3.getOrCreateForThread(Z,q),H=await qR(W,G.threadSyncService,K);await Promise.all([G.threadSyncService.uploadThread(q),G.threadSyncService.uploadThread(H)]),await by1(H),i5.write(`${H}
4854
4853
  `),await G.asyncDispose(),process.exit(0)}catch(q){iZ.write(`Error forking thread: ${q instanceof Error?q.message:String(q)}