@sourcegraph/amp 0.0.1779859522-gba0d26 → 0.0.1779886645-g59fcb2

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 -11
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -213,7 +213,7 @@ ${D}
213
213
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let E of A.seen.entries()){let F=E[1];if(Q===E[0]){J(E);continue}if(A.external){let Z=A.external.registry.get(E[0])?.id;if(Q!==E[0]&&Z){J(E);continue}}if(A.metadataRegistry.get(E[0])?.id){J(E);continue}if(F.cycle){J(E);continue}if(F.count>1){if(A.reused==="ref"){J(E);continue}}}}function AH(A,Q){let $=A.seen.get(Q);if(!$)throw Error("Unprocessed schema. This is a bug in Zod.");let B=(E)=>{let F=A.seen.get(E);if(F.ref===null)return;let Y=F.def??F.schema,Z={...Y},U=F.ref;if(F.ref=null,U){B(U);let G=A.seen.get(U),V=G.schema;if(V.$ref&&(A.target==="draft-07"||A.target==="draft-04"||A.target==="openapi-3.0"))Y.allOf=Y.allOf??[],Y.allOf.push(V);else Object.assign(Y,V);if(Object.assign(Y,Z),E._zod.parent===U)for(let z in Y){if(z==="$ref"||z==="allOf")continue;if(!(z in Z))delete Y[z]}if(V.$ref&&G.def)for(let z in Y){if(z==="$ref"||z==="allOf")continue;if(z in G.def&&JSON.stringify(Y[z])===JSON.stringify(G.def[z]))delete Y[z]}}let X=E._zod.parent;if(X&&X!==U){B(X);let G=A.seen.get(X);if(G?.schema.$ref){if(Y.$ref=G.schema.$ref,G.def)for(let V in Y){if(V==="$ref"||V==="allOf")continue;if(V in G.def&&JSON.stringify(Y[V])===JSON.stringify(G.def[V]))delete Y[V]}}}A.override({zodSchema:E,jsonSchema:Y,path:F.path??[]})};for(let E of[...A.seen.entries()].reverse())B(E[0]);let D={};if(A.target==="draft-2020-12")D.$schema="https://json-schema.org/draft/2020-12/schema";else if(A.target==="draft-07")D.$schema="http://json-schema.org/draft-07/schema#";else if(A.target==="draft-04")D.$schema="http://json-schema.org/draft-04/schema#";else if(A.target==="openapi-3.0");if(A.external?.uri){let E=A.external.registry.get(Q)?.id;if(!E)throw Error("Schema is missing an `id` property");D.$id=A.external.uri(E)}Object.assign(D,$.def??$.schema);let J=A.external?.defs??{};for(let E of A.seen.entries()){let F=E[1];if(F.def&&F.defId)J[F.defId]=F.def}if(A.external);else if(Object.keys(J).length>0)if(A.target==="draft-2020-12")D.$defs=J;else D.definitions=J;try{let E=JSON.parse(JSON.stringify(D));return Object.defineProperty(E,"~standard",{value:{...Q["~standard"],jsonSchema:{input:ZT(Q,"input",A.processors),output:ZT(Q,"output",A.processors)}},enumerable:!1,writable:!1}),E}catch(E){throw Error("Error converting schema to JSON.")}}function k$(A,Q){let $=Q??{seen:new Set};if($.seen.has(A))return!1;$.seen.add(A);let B=A._zod.def;if(B.type==="transform")return!0;if(B.type==="array")return k$(B.element,$);if(B.type==="set")return k$(B.valueType,$);if(B.type==="lazy")return k$(B.getter(),$);if(B.type==="promise"||B.type==="optional"||B.type==="nonoptional"||B.type==="nullable"||B.type==="readonly"||B.type==="default"||B.type==="prefault")return k$(B.innerType,$);if(B.type==="intersection")return k$(B.left,$)||k$(B.right,$);if(B.type==="record"||B.type==="map")return k$(B.keyType,$)||k$(B.valueType,$);if(B.type==="pipe")return k$(B.in,$)||k$(B.out,$);if(B.type==="object"){for(let D in B.shape)if(k$(B.shape[D],$))return!0;return!1}if(B.type==="union"){for(let D of B.options)if(k$(D,$))return!0;return!1}if(B.type==="tuple"){for(let D of B.items)if(k$(D,$))return!0;if(B.rest&&k$(B.rest,$))return!0;return!1}return!1}var E_0=(A,Q={})=>($)=>{let B=tI({...$,processors:Q});return A5(A,B),eI(B,A),AH(B,A)},ZT=(A,Q,$={})=>(B)=>{let{libraryOptions:D,target:J}=B??{},E=tI({...D??{},target:J,io:Q,processors:$});return A5(A,E),eI(E,A),AH(E,A)};var Dc=o(()=>{qp()});function UT(A,Q){if("_idmap"in A){let B=A,D=tI({...Q,processors:G20}),J={};for(let Y of B._idmap.entries()){let[Z,U]=Y;A5(U,D)}let E={},F={registry:B,uri:Q?.uri,defs:J};D.external=F;for(let Y of B._idmap.entries()){let[Z,U]=Y;eI(D,U),E[Z]=AH(D,U)}if(Object.keys(J).length>0){let Y=D.target==="draft-2020-12"?"$defs":"definitions";E.__shared={[Y]:J}}return{schemas:E}}let $=tI({...Q,processors:G20});return A5(A,$),eI($,A),AH($,A)}var d8A,F_0=(A,Q,$,B)=>{let D=$;D.type="string";let{minimum:J,maximum:E,format:F,patterns:Y,contentEncoding:Z}=A._zod.bag;if(typeof J==="number")D.minLength=J;if(typeof E==="number")D.maxLength=E;if(F){if(D.format=d8A[F]??F,D.format==="")delete D.format;if(F==="time")delete D.format}if(Z)D.contentEncoding=Z;if(Y&&Y.size>0){let U=[...Y];if(U.length===1)D.pattern=U[0].source;else if(U.length>1)D.allOf=[...U.map((X)=>({...Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},Y_0=(A,Q,$,B)=>{let D=$,{minimum:J,maximum:E,format:F,multipleOf:Y,exclusiveMaximum:Z,exclusiveMinimum:U}=A._zod.bag;if(typeof F==="string"&&F.includes("int"))D.type="integer";else D.type="number";if(typeof U==="number")if(Q.target==="draft-04"||Q.target==="openapi-3.0")D.minimum=U,D.exclusiveMinimum=!0;else D.exclusiveMinimum=U;if(typeof J==="number"){if(D.minimum=J,typeof U==="number"&&Q.target!=="draft-04")if(U>=J)delete D.minimum;else delete D.exclusiveMinimum}if(typeof Z==="number")if(Q.target==="draft-04"||Q.target==="openapi-3.0")D.maximum=Z,D.exclusiveMaximum=!0;else D.exclusiveMaximum=Z;if(typeof E==="number"){if(D.maximum=E,typeof Z==="number"&&Q.target!=="draft-04")if(Z<=E)delete D.maximum;else delete D.exclusiveMaximum}if(typeof Y==="number")D.multipleOf=Y},Z_0=(A,Q,$,B)=>{$.type="boolean"},U_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},X_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},G_0=(A,Q,$,B)=>{if(Q.target==="openapi-3.0")$.type="string",$.nullable=!0,$.enum=[null];else $.type="null"},V_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},K_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},z_0=(A,Q,$,B)=>{$.not={}},W_0=(A,Q,$,B)=>{},I_0=(A,Q,$,B)=>{},H_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},q_0=(A,Q,$,B)=>{let D=A._zod.def,J=om(D.entries);if(J.every((E)=>typeof E==="number"))$.type="number";if(J.every((E)=>typeof E==="string"))$.type="string";$.enum=J},N_0=(A,Q,$,B)=>{let D=A._zod.def,J=[];for(let E of D.values)if(E===void 0){if(Q.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof E==="bigint")if(Q.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else J.push(Number(E));else J.push(E);if(J.length===0);else if(J.length===1){let E=J[0];if($.type=E===null?"null":typeof E,Q.target==="draft-04"||Q.target==="openapi-3.0")$.enum=[E];else $.const=E}else{if(J.every((E)=>typeof E==="number"))$.type="number";if(J.every((E)=>typeof E==="string"))$.type="string";if(J.every((E)=>typeof E==="boolean"))$.type="boolean";if(J.every((E)=>E===null))$.type="null";$.enum=J}},C_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},w_0=(A,Q,$,B)=>{let D=$,J=A._zod.pattern;if(!J)throw Error("Pattern not found in template literal");D.type="string",D.pattern=J.source},M_0=(A,Q,$,B)=>{let D=$,J={type:"string",format:"binary",contentEncoding:"binary"},{minimum:E,maximum:F,mime:Y}=A._zod.bag;if(E!==void 0)J.minLength=E;if(F!==void 0)J.maxLength=F;if(Y)if(Y.length===1)J.contentMediaType=Y[0],Object.assign(D,J);else Object.assign(D,J),D.anyOf=Y.map((Z)=>({contentMediaType:Z}));else Object.assign(D,J)},L_0=(A,Q,$,B)=>{$.type="boolean"},O_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},j_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},R_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},u_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},P_0=(A,Q,$,B)=>{if(Q.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},__0=(A,Q,$,B)=>{let D=$,J=A._zod.def,{minimum:E,maximum:F}=A._zod.bag;if(typeof E==="number")D.minItems=E;if(typeof F==="number")D.maxItems=F;D.type="array",D.items=A5(J.element,Q,{...B,path:[...B.path,"items"]})},T_0=(A,Q,$,B)=>{let D=$,J=A._zod.def;D.type="object",D.properties={};let E=J.shape;for(let Z in E)D.properties[Z]=A5(E[Z],Q,{...B,path:[...B.path,"properties",Z]});let F=new Set(Object.keys(E)),Y=new Set([...F].filter((Z)=>{let U=J.shape[Z]._zod;if(Q.io==="input")return U.optin===void 0;else return U.optout===void 0}));if(Y.size>0)D.required=Array.from(Y);if(J.catchall?._zod.def.type==="never")D.additionalProperties=!1;else if(!J.catchall){if(Q.io==="output")D.additionalProperties=!1}else if(J.catchall)D.additionalProperties=A5(J.catchall,Q,{...B,path:[...B.path,"additionalProperties"]})},V20=(A,Q,$,B)=>{let D=A._zod.def,J=D.inclusive===!1,E=D.options.map((F,Y)=>A5(F,Q,{...B,path:[...B.path,J?"oneOf":"anyOf",Y]}));if(J)$.oneOf=E;else $.anyOf=E},v_0=(A,Q,$,B)=>{let D=A._zod.def,J=A5(D.left,Q,{...B,path:[...B.path,"allOf",0]}),E=A5(D.right,Q,{...B,path:[...B.path,"allOf",1]}),F=(Z)=>("allOf"in Z)&&Object.keys(Z).length===1,Y=[...F(J)?J.allOf:[J],...F(E)?E.allOf:[E]];$.allOf=Y},k_0=(A,Q,$,B)=>{let D=$,J=A._zod.def;D.type="array";let E=Q.target==="draft-2020-12"?"prefixItems":"items",F=Q.target==="draft-2020-12"?"items":Q.target==="openapi-3.0"?"items":"additionalItems",Y=J.items.map((G,V)=>A5(G,Q,{...B,path:[...B.path,E,V]})),Z=J.rest?A5(J.rest,Q,{...B,path:[...B.path,F,...Q.target==="openapi-3.0"?[J.items.length]:[]]}):null;if(Q.target==="draft-2020-12"){if(D.prefixItems=Y,Z)D.items=Z}else if(Q.target==="openapi-3.0"){if(D.items={anyOf:Y},Z)D.items.anyOf.push(Z);if(D.minItems=Y.length,!Z)D.maxItems=Y.length}else if(D.items=Y,Z)D.additionalItems=Z;let{minimum:U,maximum:X}=A._zod.bag;if(typeof U==="number")D.minItems=U;if(typeof X==="number")D.maxItems=X},S_0=(A,Q,$,B)=>{let D=$,J=A._zod.def;D.type="object";let E=J.keyType,Y=E._zod.bag?.patterns;if(J.mode==="loose"&&Y&&Y.size>0){let U=A5(J.valueType,Q,{...B,path:[...B.path,"patternProperties","*"]});D.patternProperties={};for(let X of Y)D.patternProperties[X.source]=U}else{if(Q.target==="draft-07"||Q.target==="draft-2020-12")D.propertyNames=A5(J.keyType,Q,{...B,path:[...B.path,"propertyNames"]});D.additionalProperties=A5(J.valueType,Q,{...B,path:[...B.path,"additionalProperties"]})}let Z=E._zod.values;if(Z){let U=[...Z].filter((X)=>typeof X==="string"||typeof X==="number");if(U.length>0)D.required=U}},f_0=(A,Q,$,B)=>{let D=A._zod.def,J=A5(D.innerType,Q,B),E=Q.seen.get(A);if(Q.target==="openapi-3.0")E.ref=D.innerType,$.nullable=!0;else $.anyOf=[J,{type:"null"}]},y_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType},x_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType,$.default=JSON.parse(JSON.stringify(D.defaultValue))},b_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);if(J.ref=D.innerType,Q.io==="input")$._prefault=JSON.parse(JSON.stringify(D.defaultValue))},h_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType;let E;try{E=D.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}$.default=E},g_0=(A,Q,$,B)=>{let D=A._zod.def,J=Q.io==="input"?D.in._zod.def.type==="transform"?D.out:D.in:D.out;A5(J,Q,B);let E=Q.seen.get(A);E.ref=J},m_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType,$.readOnly=!0},d_0=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType},K20=(A,Q,$,B)=>{let D=A._zod.def;A5(D.innerType,Q,B);let J=Q.seen.get(A);J.ref=D.innerType},p_0=(A,Q,$,B)=>{let D=A._zod.innerType;A5(D,Q,B);let J=Q.seen.get(A);J.ref=D},G20;var XT=o(()=>{Dc();J6();d8A={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},G20={string:F_0,number:Y_0,boolean:Z_0,bigint:U_0,symbol:X_0,null:G_0,undefined:V_0,void:K_0,never:z_0,any:W_0,unknown:I_0,date:H_0,enum:q_0,literal:N_0,nan:C_0,template_literal:w_0,file:M_0,success:L_0,custom:O_0,function:j_0,transform:R_0,map:u_0,set:P_0,array:__0,object:T_0,union:V20,intersection:v_0,tuple:k_0,record:S_0,nullable:f_0,nonoptional:y_0,default:x_0,prefault:b_0,catch:h_0,pipe:g_0,readonly:m_0,promise:d_0,optional:K20,lazy:p_0}});class c_0{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(A){this.ctx.counter=A}get seen(){return this.ctx.seen}constructor(A){let Q=A?.target??"draft-2020-12";if(Q==="draft-4")Q="draft-04";if(Q==="draft-7")Q="draft-07";this.ctx=tI({processors:G20,target:Q,...A?.metadata&&{metadata:A.metadata},...A?.unrepresentable&&{unrepresentable:A.unrepresentable},...A?.override&&{override:A.override},...A?.io&&{io:A.io}})}process(A,Q={path:[],schemaPath:[]}){return A5(A,this.ctx,Q)}emit(A,Q){if(Q){if(Q.cycles)this.ctx.cycles=Q.cycles;if(Q.reused)this.ctx.reused=Q.reused;if(Q.external)this.ctx.external=Q.external}eI(this.ctx,A);let $=AH(this.ctx,A),{"~standard":B,...D}=$;return D}}var xr1=o(()=>{XT();Dc()});var br1={};var hr1=()=>{};var iB={};H2(iB,{version:()=>BP0,util:()=>e1,treeifyError:()=>Qd,toJSONSchema:()=>UT,toDotPath:()=>Wo1,safeParseAsync:()=>hI,safeParse:()=>BK,safeEncodeAsync:()=>Yu0,safeEncode:()=>Eu0,safeDecodeAsync:()=>Zu0,safeDecode:()=>Fu0,registry:()=>y_,regexes:()=>v9,process:()=>A5,prettifyError:()=>$d,parseAsync:()=>bI,parse:()=>xI,meta:()=>$c,locales:()=>eM,isValidJWT:()=>fo1,isValidBase64URL:()=>So1,isValidBase64:()=>EP0,initializeContext:()=>tI,globalRegistry:()=>k9,globalConfig:()=>im,formatError:()=>aM,flattenError:()=>nM,finalize:()=>AH,extractDefs:()=>eI,encodeAsync:()=>Du0,encode:()=>$u0,describe:()=>Qc,decodeAsync:()=>Ju0,decode:()=>Bu0,createToJSONSchemaMethod:()=>E_0,createStandardJSONSchemaMethod:()=>ZT,config:()=>h2,clone:()=>D9,_xor:()=>N8A,_xid:()=>n_,_void:()=>np,_uuidv7:()=>m_,_uuidv6:()=>g_,_uuidv4:()=>h_,_uuid:()=>b_,_url:()=>gI,_uppercase:()=>pI,_unknown:()=>lp,_union:()=>q8A,_undefined:()=>dp,_ulid:()=>i_,_uint64:()=>gp,_uint32:()=>Sp,_tuple:()=>M8A,_trim:()=>oI,_transform:()=>_8A,_toUpperCase:()=>sI,_toLowerCase:()=>rI,_templateLiteral:()=>h8A,_symbol:()=>mp,_superRefine:()=>Ac,_success:()=>f8A,_stringbool:()=>Bc,_stringFormat:()=>iY,_string:()=>Np,_startsWith:()=>lI,_slugify:()=>YT,_size:()=>JK,_set:()=>j8A,_safeParseAsync:()=>P_,_safeParse:()=>u_,_safeEncodeAsync:()=>s50,_safeEncode:()=>o50,_safeDecodeAsync:()=>t50,_safeDecode:()=>r50,_regex:()=>mI,_refine:()=>ep,_record:()=>L8A,_readonly:()=>b8A,_property:()=>FT,_promise:()=>m8A,_positive:()=>BT,_pipe:()=>x8A,_parseAsync:()=>R_,_parse:()=>j_,_overwrite:()=>KJ,_optional:()=>T8A,_number:()=>up,_nullable:()=>v8A,_null:()=>pp,_normalize:()=>aI,_nonpositive:()=>JT,_nonoptional:()=>S8A,_nonnegative:()=>ET,_never:()=>ip,_negative:()=>DT,_nativeEnum:()=>u8A,_nanoid:()=>p_,_nan:()=>rp,_multipleOf:()=>FX,_minSize:()=>rE,_minLength:()=>lY,_min:()=>V7,_mime:()=>nI,_maxSize:()=>YX,_maxLength:()=>EK,_max:()=>yQ,_map:()=>O8A,_mac:()=>wp,_lte:()=>yQ,_lt:()=>aE,_lowercase:()=>dI,_literal:()=>P8A,_length:()=>FK,_lazy:()=>g8A,_ksuid:()=>a_,_jwt:()=>$T,_isoTime:()=>jp,_isoDuration:()=>Rp,_isoDateTime:()=>Lp,_isoDate:()=>Op,_ipv6:()=>r_,_ipv4:()=>o_,_intersection:()=>w8A,_int64:()=>hp,_int32:()=>kp,_int:()=>_p,_includes:()=>cI,_guid:()=>AL,_gte:()=>V7,_gt:()=>oE,_float64:()=>vp,_float32:()=>Tp,_file:()=>sp,_enum:()=>R8A,_endsWith:()=>iI,_encodeAsync:()=>n50,_encode:()=>l50,_emoji:()=>d_,_email:()=>x_,_e164:()=>QT,_discriminatedUnion:()=>C8A,_default:()=>k8A,_decodeAsync:()=>a50,_decode:()=>i50,_date:()=>ap,_custom:()=>tp,_cuid2:()=>l_,_cuid:()=>c_,_coercedString:()=>Cp,_coercedNumber:()=>Pp,_coercedDate:()=>op,_coercedBoolean:()=>yp,_coercedBigint:()=>bp,_cidrv6:()=>t_,_cidrv4:()=>s_,_check:()=>fr1,_catch:()=>y8A,_boolean:()=>fp,_bigint:()=>xp,_base64url:()=>AT,_base64:()=>e_,_array:()=>J_0,_any:()=>cp,TimePrecision:()=>Mp,NEVER:()=>cM,JSONSchemaGenerator:()=>c_0,JSONSchema:()=>br1,Doc:()=>D20,$output:()=>Ip,$input:()=>Hp,$constructor:()=>f0,$brand:()=>nm,$ZodXor:()=>dd,$ZodXID:()=>zd,$ZodVoid:()=>hd,$ZodUnknown:()=>xd,$ZodUnion:()=>sM,$ZodUndefined:()=>Sd,$ZodUUID:()=>Fd,$ZodURL:()=>Zd,$ZodULID:()=>Kd,$ZodType:()=>g6,$ZodTuple:()=>k_,$ZodTransform:()=>sd,$ZodTemplateLiteral:()=>Yp,$ZodSymbol:()=>kd,$ZodSuccess:()=>Bp,$ZodStringFormat:()=>e3,$ZodString:()=>DK,$ZodSet:()=>nd,$ZodRegistry:()=>D_0,$ZodRecord:()=>ld,$ZodRealError:()=>lB,$ZodReadonly:()=>Fp,$ZodPromise:()=>Up,$ZodPrefault:()=>Qp,$ZodPipe:()=>Ep,$ZodOptional:()=>S_,$ZodObjectJIT:()=>FP0,$ZodObject:()=>U20,$ZodNumberFormat:()=>Td,$ZodNumber:()=>T_,$ZodNullable:()=>ed,$ZodNull:()=>fd,$ZodNonOptional:()=>$p,$ZodNever:()=>bd,$ZodNanoID:()=>Xd,$ZodNaN:()=>Jp,$ZodMap:()=>id,$ZodMAC:()=>Md,$ZodLiteral:()=>od,$ZodLazy:()=>Xp,$ZodKSUID:()=>Wd,$ZodJWT:()=>Pd,$ZodIntersection:()=>cd,$ZodISOTime:()=>qd,$ZodISODuration:()=>Nd,$ZodISODateTime:()=>Id,$ZodISODate:()=>Hd,$ZodIPv6:()=>wd,$ZodIPv4:()=>Cd,$ZodGUID:()=>Ed,$ZodFunction:()=>Zp,$ZodFile:()=>rd,$ZodExactOptional:()=>td,$ZodError:()=>Ad,$ZodEnum:()=>ad,$ZodEncodeError:()=>lM,$ZodEmoji:()=>Ud,$ZodEmail:()=>Yd,$ZodE164:()=>ud,$ZodDiscriminatedUnion:()=>pd,$ZodDefault:()=>Ap,$ZodDate:()=>gd,$ZodCustomStringFormat:()=>_d,$ZodCustom:()=>Gp,$ZodCodec:()=>tM,$ZodCheckUpperCase:()=>ru0,$ZodCheckStringFormat:()=>__,$ZodCheckStartsWith:()=>tu0,$ZodCheckSizeEquals:()=>cu0,$ZodCheckRegex:()=>au0,$ZodCheckProperty:()=>AP0,$ZodCheckOverwrite:()=>$P0,$ZodCheckNumberFormat:()=>gu0,$ZodCheckMultipleOf:()=>hu0,$ZodCheckMinSize:()=>pu0,$ZodCheckMinLength:()=>iu0,$ZodCheckMimeType:()=>QP0,$ZodCheckMaxSize:()=>du0,$ZodCheckMaxLength:()=>lu0,$ZodCheckLowerCase:()=>ou0,$ZodCheckLessThan:()=>Q20,$ZodCheckLengthEquals:()=>nu0,$ZodCheckIncludes:()=>su0,$ZodCheckGreaterThan:()=>$20,$ZodCheckEndsWith:()=>eu0,$ZodCheckBigIntFormat:()=>mu0,$ZodCheck:()=>U5,$ZodCatch:()=>Dp,$ZodCUID2:()=>Vd,$ZodCUID:()=>Gd,$ZodCIDRv6:()=>Od,$ZodCIDRv4:()=>Ld,$ZodBoolean:()=>rM,$ZodBigIntFormat:()=>vd,$ZodBigInt:()=>v_,$ZodBase64URL:()=>Rd,$ZodBase64:()=>jd,$ZodAsyncError:()=>EX,$ZodArray:()=>md,$ZodAny:()=>yd});var J9=o(()=>{J6();A20();X20();XT();xr1();hr1();C_();Uu0();Qu0();YP0();B20();DP0();qp();yr1();Dc()});var z20={};H2(z20,{uppercase:()=>pI,trim:()=>oI,toUpperCase:()=>sI,toLowerCase:()=>rI,startsWith:()=>lI,slugify:()=>YT,size:()=>JK,regex:()=>mI,property:()=>FT,positive:()=>BT,overwrite:()=>KJ,normalize:()=>aI,nonpositive:()=>JT,nonnegative:()=>ET,negative:()=>DT,multipleOf:()=>FX,minSize:()=>rE,minLength:()=>lY,mime:()=>nI,maxSize:()=>YX,maxLength:()=>EK,lte:()=>yQ,lt:()=>aE,lowercase:()=>dI,length:()=>FK,includes:()=>cI,gte:()=>V7,gt:()=>oE,endsWith:()=>iI});var W20=o(()=>{J9()});var QH={};H2(QH,{time:()=>n_0,duration:()=>a_0,datetime:()=>l_0,date:()=>i_0,ZodISOTime:()=>q20,ZodISODuration:()=>N20,ZodISODateTime:()=>I20,ZodISODate:()=>H20});function l_0(A){return Lp(I20,A)}function i_0(A){return Op(H20,A)}function n_0(A){return jp(q20,A)}function a_0(A){return Rp(N20,A)}var I20,H20,q20,N20;var Jc=o(()=>{J9();Fc();I20=f0("ZodISODateTime",(A,Q)=>{Id.init(A,Q),C5.init(A,Q)});H20=f0("ZodISODate",(A,Q)=>{Hd.init(A,Q),C5.init(A,Q)});q20=f0("ZodISOTime",(A,Q)=>{qd.init(A,Q),C5.init(A,Q)});N20=f0("ZodISODuration",(A,Q)=>{Nd.init(A,Q),C5.init(A,Q)})});var gr1=(A,Q)=>{Ad.init(A,Q),A.name="ZodError",Object.defineProperties(A,{format:{value:($)=>aM(A,$)},flatten:{value:($)=>nM(A,$)},addIssue:{value:($)=>{A.issues.push($),A.message=JSON.stringify(A.issues,w_,2)}},addIssues:{value:($)=>{A.issues.push(...$),A.message=JSON.stringify(A.issues,w_,2)}},isEmpty:{get(){return A.issues.length===0}}})},c8A,nB;var o_0=o(()=>{J9();J9();J6();c8A=f0("ZodError",gr1),nB=f0("ZodError",gr1,{Parent:Error})});var r_0,s_0,t_0,e_0,AT0,QT0,$T0,BT0,DT0,JT0,ET0,FT0;var YT0=o(()=>{J9();o_0();r_0=j_(nB),s_0=R_(nB),t_0=u_(nB),e_0=P_(nB),AT0=l50(nB),QT0=i50(nB),$T0=n50(nB),BT0=a50(nB),DT0=o50(nB),JT0=r50(nB),ET0=s50(nB),FT0=t50(nB)});var Ec={};H2(Ec,{xor:()=>Rs1,xid:()=>er1,void:()=>Ms1,uuidv7:()=>ir1,uuidv6:()=>lr1,uuidv4:()=>cr1,uuid:()=>pr1,url:()=>L20,unknown:()=>w5,union:()=>X5,undefined:()=>ws1,ulid:()=>tr1,uint64:()=>Ns1,uint32:()=>Is1,tuple:()=>wT0,transform:()=>p20,templateLiteral:()=>bs1,symbol:()=>Cs1,superRefine:()=>aT0,success:()=>fs1,stringbool:()=>ls1,stringFormat:()=>Us1,string:()=>l0,strictObject:()=>js1,set:()=>Ts1,refine:()=>nT0,record:()=>S5,readonly:()=>mT0,promise:()=>hs1,preprocess:()=>Hc,prefault:()=>ST0,pipe:()=>Uc,partialRecord:()=>us1,optional:()=>l5,object:()=>M4,number:()=>D3,nullish:()=>Ss1,nullable:()=>Zc,null:()=>HT,nonoptional:()=>fT0,never:()=>d20,nativeEnum:()=>vs1,nanoid:()=>or1,nan:()=>ys1,meta:()=>ps1,map:()=>_s1,mac:()=>$s1,looseRecord:()=>Ps1,looseObject:()=>R8,literal:()=>e4,lazy:()=>cT0,ksuid:()=>As1,keyof:()=>Os1,jwt:()=>Zs1,json:()=>is1,ipv6:()=>Bs1,ipv4:()=>Qs1,intersection:()=>qT,int64:()=>qs1,int32:()=>Ws1,int:()=>C20,instanceof:()=>cs1,httpUrl:()=>nr1,hostname:()=>Xs1,hex:()=>Gs1,hash:()=>Vs1,guid:()=>dr1,function:()=>gs1,float64:()=>zs1,float32:()=>Ks1,file:()=>ks1,exactOptional:()=>PT0,enum:()=>a7,emoji:()=>ar1,email:()=>mr1,e164:()=>Ys1,discriminatedUnion:()=>zc,describe:()=>ds1,date:()=>Ls1,custom:()=>a20,cuid2:()=>sr1,cuid:()=>rr1,codec:()=>xs1,cidrv6:()=>Js1,cidrv4:()=>Ds1,check:()=>ms1,catch:()=>bT0,boolean:()=>Q5,bigint:()=>Hs1,base64url:()=>Fs1,base64:()=>Es1,array:()=>N4,any:()=>m20,_function:()=>gs1,_default:()=>vT0,_ZodString:()=>w20,ZodXor:()=>HT0,ZodXID:()=>_20,ZodVoid:()=>WT0,ZodUnknown:()=>KT0,ZodUnion:()=>Kc,ZodUndefined:()=>XT0,ZodUUID:()=>ZX,ZodURL:()=>Xc,ZodULID:()=>P20,ZodType:()=>WA,ZodTuple:()=>CT0,ZodTransform:()=>RT0,ZodTemplateLiteral:()=>dT0,ZodSymbol:()=>UT0,ZodSuccess:()=>yT0,ZodStringFormat:()=>C5,ZodString:()=>VT,ZodSet:()=>LT0,ZodRecord:()=>Wc,ZodReadonly:()=>gT0,ZodPromise:()=>lT0,ZodPrefault:()=>kT0,ZodPipe:()=>i20,ZodOptional:()=>c20,ZodObject:()=>Vc,ZodNumberFormat:()=>QL,ZodNumber:()=>zT,ZodNullable:()=>_T0,ZodNull:()=>GT0,ZodNonOptional:()=>l20,ZodNever:()=>zT0,ZodNanoID:()=>j20,ZodNaN:()=>hT0,ZodMap:()=>MT0,ZodMAC:()=>ZT0,ZodLiteral:()=>OT0,ZodLazy:()=>pT0,ZodKSUID:()=>T20,ZodJWT:()=>h20,ZodIntersection:()=>NT0,ZodIPv6:()=>k20,ZodIPv4:()=>v20,ZodGUID:()=>Yc,ZodFunction:()=>iT0,ZodFile:()=>jT0,ZodExactOptional:()=>uT0,ZodEnum:()=>GT,ZodEmoji:()=>O20,ZodEmail:()=>M20,ZodE164:()=>b20,ZodDiscriminatedUnion:()=>qT0,ZodDefault:()=>TT0,ZodDate:()=>Gc,ZodCustomStringFormat:()=>KT,ZodCustom:()=>Ic,ZodCodec:()=>n20,ZodCatch:()=>xT0,ZodCUID2:()=>u20,ZodCUID:()=>R20,ZodCIDRv6:()=>f20,ZodCIDRv4:()=>S20,ZodBoolean:()=>WT,ZodBigIntFormat:()=>g20,ZodBigInt:()=>IT,ZodBase64URL:()=>x20,ZodBase64:()=>y20,ZodArray:()=>IT0,ZodAny:()=>VT0});function l0(A){return Np(VT,A)}function mr1(A){return x_(M20,A)}function dr1(A){return AL(Yc,A)}function pr1(A){return b_(ZX,A)}function cr1(A){return h_(ZX,A)}function lr1(A){return g_(ZX,A)}function ir1(A){return m_(ZX,A)}function L20(A){return gI(Xc,A)}function nr1(A){return gI(Xc,{protocol:/^https?$/,hostname:v9.domain,...e1.normalizeParams(A)})}function ar1(A){return d_(O20,A)}function or1(A){return p_(j20,A)}function rr1(A){return c_(R20,A)}function sr1(A){return l_(u20,A)}function tr1(A){return i_(P20,A)}function er1(A){return n_(_20,A)}function As1(A){return a_(T20,A)}function Qs1(A){return o_(v20,A)}function $s1(A){return wp(ZT0,A)}function Bs1(A){return r_(k20,A)}function Ds1(A){return s_(S20,A)}function Js1(A){return t_(f20,A)}function Es1(A){return e_(y20,A)}function Fs1(A){return AT(x20,A)}function Ys1(A){return QT(b20,A)}function Zs1(A){return $T(h20,A)}function Us1(A,Q,$={}){return iY(KT,A,Q,$)}function Xs1(A){return iY(KT,"hostname",v9.hostname,A)}function Gs1(A){return iY(KT,"hex",v9.hex,A)}function Vs1(A,Q){let $=Q?.enc??"hex",B=`${A}_${$}`,D=v9[B];if(!D)throw Error(`Unrecognized hash format: ${B}`);return iY(KT,B,D,Q)}function D3(A){return up(zT,A)}function C20(A){return _p(QL,A)}function Ks1(A){return Tp(QL,A)}function zs1(A){return vp(QL,A)}function Ws1(A){return kp(QL,A)}function Is1(A){return Sp(QL,A)}function Q5(A){return fp(WT,A)}function Hs1(A){return xp(IT,A)}function qs1(A){return hp(g20,A)}function Ns1(A){return gp(g20,A)}function Cs1(A){return mp(UT0,A)}function ws1(A){return dp(XT0,A)}function HT(A){return pp(GT0,A)}function m20(){return cp(VT0)}function w5(){return lp(KT0)}function d20(A){return ip(zT0,A)}function Ms1(A){return np(WT0,A)}function Ls1(A){return ap(Gc,A)}function N4(A,Q){return J_0(IT0,A,Q)}function Os1(A){let Q=A._zod.def.shape;return a7(Object.keys(Q))}function M4(A,Q){let $={type:"object",shape:A??{},...e1.normalizeParams(Q)};return new Vc($)}function js1(A,Q){return new Vc({type:"object",shape:A,catchall:d20(),...e1.normalizeParams(Q)})}function R8(A,Q){return new Vc({type:"object",shape:A,catchall:w5(),...e1.normalizeParams(Q)})}function X5(A,Q){return new Kc({type:"union",options:A,...e1.normalizeParams(Q)})}function Rs1(A,Q){return new HT0({type:"union",options:A,inclusive:!1,...e1.normalizeParams(Q)})}function zc(A,Q,$){return new qT0({type:"union",options:Q,discriminator:A,...e1.normalizeParams($)})}function qT(A,Q){return new NT0({type:"intersection",left:A,right:Q})}function wT0(A,Q,$){let B=Q instanceof g6,D=B?$:Q;return new CT0({type:"tuple",items:A,rest:B?Q:null,...e1.normalizeParams(D)})}function S5(A,Q,$){return new Wc({type:"record",keyType:A,valueType:Q,...e1.normalizeParams($)})}function us1(A,Q,$){let B=D9(A);return B._zod.values=void 0,new Wc({type:"record",keyType:B,valueType:Q,...e1.normalizeParams($)})}function Ps1(A,Q,$){return new Wc({type:"record",keyType:A,valueType:Q,mode:"loose",...e1.normalizeParams($)})}function _s1(A,Q,$){return new MT0({type:"map",keyType:A,valueType:Q,...e1.normalizeParams($)})}function Ts1(A,Q){return new LT0({type:"set",valueType:A,...e1.normalizeParams(Q)})}function a7(A,Q){let $=Array.isArray(A)?Object.fromEntries(A.map((B)=>[B,B])):A;return new GT({type:"enum",entries:$,...e1.normalizeParams(Q)})}function vs1(A,Q){return new GT({type:"enum",entries:A,...e1.normalizeParams(Q)})}function e4(A,Q){return new OT0({type:"literal",values:Array.isArray(A)?A:[A],...e1.normalizeParams(Q)})}function ks1(A){return sp(jT0,A)}function p20(A){return new RT0({type:"transform",transform:A})}function l5(A){return new c20({type:"optional",innerType:A})}function PT0(A){return new uT0({type:"optional",innerType:A})}function Zc(A){return new _T0({type:"nullable",innerType:A})}function Ss1(A){return l5(Zc(A))}function vT0(A,Q){return new TT0({type:"default",innerType:A,get defaultValue(){return typeof Q==="function"?Q():e1.shallowClone(Q)}})}function ST0(A,Q){return new kT0({type:"prefault",innerType:A,get defaultValue(){return typeof Q==="function"?Q():e1.shallowClone(Q)}})}function fT0(A,Q){return new l20({type:"nonoptional",innerType:A,...e1.normalizeParams(Q)})}function fs1(A){return new yT0({type:"success",innerType:A})}function bT0(A,Q){return new xT0({type:"catch",innerType:A,catchValue:typeof Q==="function"?Q:()=>Q})}function ys1(A){return rp(hT0,A)}function Uc(A,Q){return new i20({type:"pipe",in:A,out:Q})}function xs1(A,Q,$){return new n20({type:"pipe",in:A,out:Q,transform:$.decode,reverseTransform:$.encode})}function mT0(A){return new gT0({type:"readonly",innerType:A})}function bs1(A,Q){return new dT0({type:"template_literal",parts:A,...e1.normalizeParams(Q)})}function cT0(A){return new pT0({type:"lazy",getter:A})}function hs1(A){return new lT0({type:"promise",innerType:A})}function gs1(A){return new iT0({type:"function",input:Array.isArray(A?.input)?wT0(A?.input):A?.input??N4(w5()),output:A?.output??w5()})}function ms1(A){let Q=new U5({check:"custom"});return Q._zod.check=A,Q}function a20(A,Q){return tp(Ic,A??(()=>!0),Q)}function nT0(A,Q={}){return ep(Ic,A,Q)}function aT0(A){return Ac(A)}function cs1(A,Q={}){let $=new Ic({type:"custom",check:"custom",fn:(B)=>B instanceof A,abort:!0,...e1.normalizeParams(Q)});return $._zod.bag.Class=A,$._zod.check=(B)=>{if(!(B.value instanceof A))B.issues.push({code:"invalid_type",expected:A.name,input:B.value,inst:$,path:[...$._zod.def.path??[]]})},$}function is1(A){let Q=cT0(()=>{return X5([l0(A),D3(),Q5(),HT(),N4(Q),S5(l0(),Q)])});return Q}function Hc(A,Q){return Uc(p20(A),Q)}var WA,w20,VT,C5,M20,Yc,ZX,Xc,O20,j20,R20,u20,P20,_20,T20,v20,ZT0,k20,S20,f20,y20,x20,b20,h20,KT,zT,QL,WT,IT,g20,UT0,XT0,GT0,VT0,KT0,zT0,WT0,Gc,IT0,Vc,Kc,HT0,qT0,NT0,CT0,Wc,MT0,LT0,GT,OT0,jT0,RT0,c20,uT0,_T0,TT0,kT0,l20,yT0,xT0,hT0,i20,n20,gT0,dT0,pT0,lT0,iT0,Ic,ds1,ps1,ls1=(...A)=>Bc({Codec:n20,Boolean:WT,String:VT},...A);var Fc=o(()=>{J9();J9();XT();Dc();W20();Jc();YT0();WA=f0("ZodType",(A,Q)=>{return g6.init(A,Q),Object.assign(A["~standard"],{jsonSchema:{input:ZT(A,"input"),output:ZT(A,"output")}}),A.toJSONSchema=E_0(A,{}),A.def=Q,A.type=Q.type,Object.defineProperty(A,"_def",{value:Q}),A.check=(...$)=>{return A.clone(e1.mergeDefs(Q,{checks:[...Q.checks??[],...$.map((B)=>typeof B==="function"?{_zod:{check:B,def:{check:"custom"},onattach:[]}}:B)]}),{parent:!0})},A.with=A.check,A.clone=($,B)=>D9(A,$,B),A.brand=()=>A,A.register=($,B)=>{return $.add(A,B),A},A.parse=($,B)=>r_0(A,$,B,{callee:A.parse}),A.safeParse=($,B)=>t_0(A,$,B),A.parseAsync=async($,B)=>s_0(A,$,B,{callee:A.parseAsync}),A.safeParseAsync=async($,B)=>e_0(A,$,B),A.spa=A.safeParseAsync,A.encode=($,B)=>AT0(A,$,B),A.decode=($,B)=>QT0(A,$,B),A.encodeAsync=async($,B)=>$T0(A,$,B),A.decodeAsync=async($,B)=>BT0(A,$,B),A.safeEncode=($,B)=>DT0(A,$,B),A.safeDecode=($,B)=>JT0(A,$,B),A.safeEncodeAsync=async($,B)=>ET0(A,$,B),A.safeDecodeAsync=async($,B)=>FT0(A,$,B),A.refine=($,B)=>A.check(nT0($,B)),A.superRefine=($)=>A.check(aT0($)),A.overwrite=($)=>A.check(KJ($)),A.optional=()=>l5(A),A.exactOptional=()=>PT0(A),A.nullable=()=>Zc(A),A.nullish=()=>l5(Zc(A)),A.nonoptional=($)=>fT0(A,$),A.array=()=>N4(A),A.or=($)=>X5([A,$]),A.and=($)=>qT(A,$),A.transform=($)=>Uc(A,p20($)),A.default=($)=>vT0(A,$),A.prefault=($)=>ST0(A,$),A.catch=($)=>bT0(A,$),A.pipe=($)=>Uc(A,$),A.readonly=()=>mT0(A),A.describe=($)=>{let B=A.clone();return k9.add(B,{description:$}),B},Object.defineProperty(A,"description",{get(){return k9.get(A)?.description},configurable:!0}),A.meta=(...$)=>{if($.length===0)return k9.get(A);let B=A.clone();return k9.add(B,$[0]),B},A.isOptional=()=>A.safeParse(void 0).success,A.isNullable=()=>A.safeParse(null).success,A.apply=($)=>$(A),A}),w20=f0("_ZodString",(A,Q)=>{DK.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=(B,D,J)=>F_0(A,B,D,J);let $=A._zod.bag;A.format=$.format??null,A.minLength=$.minimum??null,A.maxLength=$.maximum??null,A.regex=(...B)=>A.check(mI(...B)),A.includes=(...B)=>A.check(cI(...B)),A.startsWith=(...B)=>A.check(lI(...B)),A.endsWith=(...B)=>A.check(iI(...B)),A.min=(...B)=>A.check(lY(...B)),A.max=(...B)=>A.check(EK(...B)),A.length=(...B)=>A.check(FK(...B)),A.nonempty=(...B)=>A.check(lY(1,...B)),A.lowercase=(B)=>A.check(dI(B)),A.uppercase=(B)=>A.check(pI(B)),A.trim=()=>A.check(oI()),A.normalize=(...B)=>A.check(aI(...B)),A.toLowerCase=()=>A.check(rI()),A.toUpperCase=()=>A.check(sI()),A.slugify=()=>A.check(YT())}),VT=f0("ZodString",(A,Q)=>{DK.init(A,Q),w20.init(A,Q),A.email=($)=>A.check(x_(M20,$)),A.url=($)=>A.check(gI(Xc,$)),A.jwt=($)=>A.check($T(h20,$)),A.emoji=($)=>A.check(d_(O20,$)),A.guid=($)=>A.check(AL(Yc,$)),A.uuid=($)=>A.check(b_(ZX,$)),A.uuidv4=($)=>A.check(h_(ZX,$)),A.uuidv6=($)=>A.check(g_(ZX,$)),A.uuidv7=($)=>A.check(m_(ZX,$)),A.nanoid=($)=>A.check(p_(j20,$)),A.guid=($)=>A.check(AL(Yc,$)),A.cuid=($)=>A.check(c_(R20,$)),A.cuid2=($)=>A.check(l_(u20,$)),A.ulid=($)=>A.check(i_(P20,$)),A.base64=($)=>A.check(e_(y20,$)),A.base64url=($)=>A.check(AT(x20,$)),A.xid=($)=>A.check(n_(_20,$)),A.ksuid=($)=>A.check(a_(T20,$)),A.ipv4=($)=>A.check(o_(v20,$)),A.ipv6=($)=>A.check(r_(k20,$)),A.cidrv4=($)=>A.check(s_(S20,$)),A.cidrv6=($)=>A.check(t_(f20,$)),A.e164=($)=>A.check(QT(b20,$)),A.datetime=($)=>A.check(l_0($)),A.date=($)=>A.check(i_0($)),A.time=($)=>A.check(n_0($)),A.duration=($)=>A.check(a_0($))});C5=f0("ZodStringFormat",(A,Q)=>{e3.init(A,Q),w20.init(A,Q)}),M20=f0("ZodEmail",(A,Q)=>{Yd.init(A,Q),C5.init(A,Q)});Yc=f0("ZodGUID",(A,Q)=>{Ed.init(A,Q),C5.init(A,Q)});ZX=f0("ZodUUID",(A,Q)=>{Fd.init(A,Q),C5.init(A,Q)});Xc=f0("ZodURL",(A,Q)=>{Zd.init(A,Q),C5.init(A,Q)});O20=f0("ZodEmoji",(A,Q)=>{Ud.init(A,Q),C5.init(A,Q)});j20=f0("ZodNanoID",(A,Q)=>{Xd.init(A,Q),C5.init(A,Q)});R20=f0("ZodCUID",(A,Q)=>{Gd.init(A,Q),C5.init(A,Q)});u20=f0("ZodCUID2",(A,Q)=>{Vd.init(A,Q),C5.init(A,Q)});P20=f0("ZodULID",(A,Q)=>{Kd.init(A,Q),C5.init(A,Q)});_20=f0("ZodXID",(A,Q)=>{zd.init(A,Q),C5.init(A,Q)});T20=f0("ZodKSUID",(A,Q)=>{Wd.init(A,Q),C5.init(A,Q)});v20=f0("ZodIPv4",(A,Q)=>{Cd.init(A,Q),C5.init(A,Q)});ZT0=f0("ZodMAC",(A,Q)=>{Md.init(A,Q),C5.init(A,Q)});k20=f0("ZodIPv6",(A,Q)=>{wd.init(A,Q),C5.init(A,Q)});S20=f0("ZodCIDRv4",(A,Q)=>{Ld.init(A,Q),C5.init(A,Q)});f20=f0("ZodCIDRv6",(A,Q)=>{Od.init(A,Q),C5.init(A,Q)});y20=f0("ZodBase64",(A,Q)=>{jd.init(A,Q),C5.init(A,Q)});x20=f0("ZodBase64URL",(A,Q)=>{Rd.init(A,Q),C5.init(A,Q)});b20=f0("ZodE164",(A,Q)=>{ud.init(A,Q),C5.init(A,Q)});h20=f0("ZodJWT",(A,Q)=>{Pd.init(A,Q),C5.init(A,Q)});KT=f0("ZodCustomStringFormat",(A,Q)=>{_d.init(A,Q),C5.init(A,Q)});zT=f0("ZodNumber",(A,Q)=>{T_.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=(B,D,J)=>Y_0(A,B,D,J),A.gt=(B,D)=>A.check(oE(B,D)),A.gte=(B,D)=>A.check(V7(B,D)),A.min=(B,D)=>A.check(V7(B,D)),A.lt=(B,D)=>A.check(aE(B,D)),A.lte=(B,D)=>A.check(yQ(B,D)),A.max=(B,D)=>A.check(yQ(B,D)),A.int=(B)=>A.check(C20(B)),A.safe=(B)=>A.check(C20(B)),A.positive=(B)=>A.check(oE(0,B)),A.nonnegative=(B)=>A.check(V7(0,B)),A.negative=(B)=>A.check(aE(0,B)),A.nonpositive=(B)=>A.check(yQ(0,B)),A.multipleOf=(B,D)=>A.check(FX(B,D)),A.step=(B,D)=>A.check(FX(B,D)),A.finite=()=>A;let $=A._zod.bag;A.minValue=Math.max($.minimum??Number.NEGATIVE_INFINITY,$.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,A.maxValue=Math.min($.maximum??Number.POSITIVE_INFINITY,$.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,A.isInt=($.format??"").includes("int")||Number.isSafeInteger($.multipleOf??0.5),A.isFinite=!0,A.format=$.format??null});QL=f0("ZodNumberFormat",(A,Q)=>{Td.init(A,Q),zT.init(A,Q)});WT=f0("ZodBoolean",(A,Q)=>{rM.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>Z_0(A,$,B,D)});IT=f0("ZodBigInt",(A,Q)=>{v_.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=(B,D,J)=>U_0(A,B,D,J),A.gte=(B,D)=>A.check(V7(B,D)),A.min=(B,D)=>A.check(V7(B,D)),A.gt=(B,D)=>A.check(oE(B,D)),A.gte=(B,D)=>A.check(V7(B,D)),A.min=(B,D)=>A.check(V7(B,D)),A.lt=(B,D)=>A.check(aE(B,D)),A.lte=(B,D)=>A.check(yQ(B,D)),A.max=(B,D)=>A.check(yQ(B,D)),A.positive=(B)=>A.check(oE(BigInt(0),B)),A.negative=(B)=>A.check(aE(BigInt(0),B)),A.nonpositive=(B)=>A.check(yQ(BigInt(0),B)),A.nonnegative=(B)=>A.check(V7(BigInt(0),B)),A.multipleOf=(B,D)=>A.check(FX(B,D));let $=A._zod.bag;A.minValue=$.minimum??null,A.maxValue=$.maximum??null,A.format=$.format??null});g20=f0("ZodBigIntFormat",(A,Q)=>{vd.init(A,Q),IT.init(A,Q)});UT0=f0("ZodSymbol",(A,Q)=>{kd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>X_0(A,$,B,D)});XT0=f0("ZodUndefined",(A,Q)=>{Sd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>V_0(A,$,B,D)});GT0=f0("ZodNull",(A,Q)=>{fd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>G_0(A,$,B,D)});VT0=f0("ZodAny",(A,Q)=>{yd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>W_0(A,$,B,D)});KT0=f0("ZodUnknown",(A,Q)=>{xd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>I_0(A,$,B,D)});zT0=f0("ZodNever",(A,Q)=>{bd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>z_0(A,$,B,D)});WT0=f0("ZodVoid",(A,Q)=>{hd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>K_0(A,$,B,D)});Gc=f0("ZodDate",(A,Q)=>{gd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=(B,D,J)=>H_0(A,B,D,J),A.min=(B,D)=>A.check(V7(B,D)),A.max=(B,D)=>A.check(yQ(B,D));let $=A._zod.bag;A.minDate=$.minimum?new Date($.minimum):null,A.maxDate=$.maximum?new Date($.maximum):null});IT0=f0("ZodArray",(A,Q)=>{md.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>__0(A,$,B,D),A.element=Q.element,A.min=($,B)=>A.check(lY($,B)),A.nonempty=($)=>A.check(lY(1,$)),A.max=($,B)=>A.check(EK($,B)),A.length=($,B)=>A.check(FK($,B)),A.unwrap=()=>A.element});Vc=f0("ZodObject",(A,Q)=>{FP0.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>T_0(A,$,B,D),e1.defineLazy(A,"shape",()=>{return Q.shape}),A.keyof=()=>a7(Object.keys(A._zod.def.shape)),A.catchall=($)=>A.clone({...A._zod.def,catchall:$}),A.passthrough=()=>A.clone({...A._zod.def,catchall:w5()}),A.loose=()=>A.clone({...A._zod.def,catchall:w5()}),A.strict=()=>A.clone({...A._zod.def,catchall:d20()}),A.strip=()=>A.clone({...A._zod.def,catchall:void 0}),A.extend=($)=>{return e1.extend(A,$)},A.safeExtend=($)=>{return e1.safeExtend(A,$)},A.merge=($)=>e1.merge(A,$),A.pick=($)=>e1.pick(A,$),A.omit=($)=>e1.omit(A,$),A.partial=(...$)=>e1.partial(c20,A,$[0]),A.required=(...$)=>e1.required(l20,A,$[0])});Kc=f0("ZodUnion",(A,Q)=>{sM.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>V20(A,$,B,D),A.options=Q.options});HT0=f0("ZodXor",(A,Q)=>{Kc.init(A,Q),dd.init(A,Q),A._zod.processJSONSchema=($,B,D)=>V20(A,$,B,D),A.options=Q.options});qT0=f0("ZodDiscriminatedUnion",(A,Q)=>{Kc.init(A,Q),pd.init(A,Q)});NT0=f0("ZodIntersection",(A,Q)=>{cd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>v_0(A,$,B,D)});CT0=f0("ZodTuple",(A,Q)=>{k_.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>k_0(A,$,B,D),A.rest=($)=>A.clone({...A._zod.def,rest:$})});Wc=f0("ZodRecord",(A,Q)=>{ld.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>S_0(A,$,B,D),A.keyType=Q.keyType,A.valueType=Q.valueType});MT0=f0("ZodMap",(A,Q)=>{id.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>u_0(A,$,B,D),A.keyType=Q.keyType,A.valueType=Q.valueType,A.min=(...$)=>A.check(rE(...$)),A.nonempty=($)=>A.check(rE(1,$)),A.max=(...$)=>A.check(YX(...$)),A.size=(...$)=>A.check(JK(...$))});LT0=f0("ZodSet",(A,Q)=>{nd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>P_0(A,$,B,D),A.min=(...$)=>A.check(rE(...$)),A.nonempty=($)=>A.check(rE(1,$)),A.max=(...$)=>A.check(YX(...$)),A.size=(...$)=>A.check(JK(...$))});GT=f0("ZodEnum",(A,Q)=>{ad.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=(B,D,J)=>q_0(A,B,D,J),A.enum=Q.entries,A.options=Object.values(Q.entries);let $=new Set(Object.keys(Q.entries));A.extract=(B,D)=>{let J={};for(let E of B)if($.has(E))J[E]=Q.entries[E];else throw Error(`Key ${E} not found in enum`);return new GT({...Q,checks:[],...e1.normalizeParams(D),entries:J})},A.exclude=(B,D)=>{let J={...Q.entries};for(let E of B)if($.has(E))delete J[E];else throw Error(`Key ${E} not found in enum`);return new GT({...Q,checks:[],...e1.normalizeParams(D),entries:J})}});OT0=f0("ZodLiteral",(A,Q)=>{od.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>N_0(A,$,B,D),A.values=new Set(Q.values),Object.defineProperty(A,"value",{get(){if(Q.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Q.values[0]}})});jT0=f0("ZodFile",(A,Q)=>{rd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>M_0(A,$,B,D),A.min=($,B)=>A.check(rE($,B)),A.max=($,B)=>A.check(YX($,B)),A.mime=($,B)=>A.check(nI(Array.isArray($)?$:[$],B))});RT0=f0("ZodTransform",(A,Q)=>{sd.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>R_0(A,$,B,D),A._zod.parse=($,B)=>{if(B.direction==="backward")throw new lM(A.constructor.name);$.addIssue=(J)=>{if(typeof J==="string")$.issues.push(e1.issue(J,$.value,Q));else{let E=J;if(E.fatal)E.continue=!1;E.code??(E.code="custom"),E.input??(E.input=$.value),E.inst??(E.inst=A),$.issues.push(e1.issue(E))}};let D=Q.transform($.value,$);if(D instanceof Promise)return D.then((J)=>{return $.value=J,$});return $.value=D,$}});c20=f0("ZodOptional",(A,Q)=>{S_.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>K20(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});uT0=f0("ZodExactOptional",(A,Q)=>{td.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>K20(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});_T0=f0("ZodNullable",(A,Q)=>{ed.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>f_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});TT0=f0("ZodDefault",(A,Q)=>{Ap.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>x_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType,A.removeDefault=A.unwrap});kT0=f0("ZodPrefault",(A,Q)=>{Qp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>b_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});l20=f0("ZodNonOptional",(A,Q)=>{$p.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>y_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});yT0=f0("ZodSuccess",(A,Q)=>{Bp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>L_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});xT0=f0("ZodCatch",(A,Q)=>{Dp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>h_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType,A.removeCatch=A.unwrap});hT0=f0("ZodNaN",(A,Q)=>{Jp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>C_0(A,$,B,D)});i20=f0("ZodPipe",(A,Q)=>{Ep.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>g_0(A,$,B,D),A.in=Q.in,A.out=Q.out});n20=f0("ZodCodec",(A,Q)=>{i20.init(A,Q),tM.init(A,Q)});gT0=f0("ZodReadonly",(A,Q)=>{Fp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>m_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});dT0=f0("ZodTemplateLiteral",(A,Q)=>{Yp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>w_0(A,$,B,D)});pT0=f0("ZodLazy",(A,Q)=>{Xp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>p_0(A,$,B,D),A.unwrap=()=>A._zod.def.getter()});lT0=f0("ZodPromise",(A,Q)=>{Up.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>d_0(A,$,B,D),A.unwrap=()=>A._zod.def.innerType});iT0=f0("ZodFunction",(A,Q)=>{Zp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>j_0(A,$,B,D)});Ic=f0("ZodCustom",(A,Q)=>{Gp.init(A,Q),WA.init(A,Q),A._zod.processJSONSchema=($,B,D)=>O_0(A,$,B,D)});ds1=Qc,ps1=$c});function i8A(A){h2({customError:A})}function n8A(){return h2().customError}var rT0,oT0;var ns1=o(()=>{J9();rT0={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};(function(A){})(oT0||(oT0={}))});function o8A(A,Q){let $=A.$schema;if($==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if($==="http://json-schema.org/draft-07/schema#")return"draft-7";if($==="http://json-schema.org/draft-04/schema#")return"draft-4";return Q??"draft-2020-12"}function r8A(A,Q){if(!A.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let $=A.slice(1).split("/").filter(Boolean);if($.length===0)return Q.rootSchema;let B=Q.version==="draft-2020-12"?"$defs":"definitions";if($[0]===B){let D=$[1];if(!D||!Q.defs[D])throw Error(`Reference not found: ${A}`);return Q.defs[D]}throw Error(`Reference not found: ${A}`)}function as1(A,Q){if(A.not!==void 0){if(typeof A.not==="object"&&Object.keys(A.not).length===0)return P4.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(A.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(A.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(A.if!==void 0||A.then!==void 0||A.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(A.dependentSchemas!==void 0||A.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(A.$ref){let D=A.$ref;if(Q.refs.has(D))return Q.refs.get(D);if(Q.processing.has(D))return P4.lazy(()=>{if(!Q.refs.has(D))throw Error(`Circular reference not resolved: ${D}`);return Q.refs.get(D)});Q.processing.add(D);let J=r8A(D,Q),E=xQ(J,Q);return Q.refs.set(D,E),Q.processing.delete(D),E}if(A.enum!==void 0){let D=A.enum;if(Q.version==="openapi-3.0"&&A.nullable===!0&&D.length===1&&D[0]===null)return P4.null();if(D.length===0)return P4.never();if(D.length===1)return P4.literal(D[0]);if(D.every((E)=>typeof E==="string"))return P4.enum(D);let J=D.map((E)=>P4.literal(E));if(J.length<2)return J[0];return P4.union([J[0],J[1],...J.slice(2)])}if(A.const!==void 0)return P4.literal(A.const);let $=A.type;if(Array.isArray($)){let D=$.map((J)=>{let E={...A,type:J};return as1(E,Q)});if(D.length===0)return P4.never();if(D.length===1)return D[0];return P4.union(D)}if(!$)return P4.any();let B;switch($){case"string":{let D=P4.string();if(A.format){let J=A.format;if(J==="email")D=D.check(P4.email());else if(J==="uri"||J==="uri-reference")D=D.check(P4.url());else if(J==="uuid"||J==="guid")D=D.check(P4.uuid());else if(J==="date-time")D=D.check(P4.iso.datetime());else if(J==="date")D=D.check(P4.iso.date());else if(J==="time")D=D.check(P4.iso.time());else if(J==="duration")D=D.check(P4.iso.duration());else if(J==="ipv4")D=D.check(P4.ipv4());else if(J==="ipv6")D=D.check(P4.ipv6());else if(J==="mac")D=D.check(P4.mac());else if(J==="cidr")D=D.check(P4.cidrv4());else if(J==="cidr-v6")D=D.check(P4.cidrv6());else if(J==="base64")D=D.check(P4.base64());else if(J==="base64url")D=D.check(P4.base64url());else if(J==="e164")D=D.check(P4.e164());else if(J==="jwt")D=D.check(P4.jwt());else if(J==="emoji")D=D.check(P4.emoji());else if(J==="nanoid")D=D.check(P4.nanoid());else if(J==="cuid")D=D.check(P4.cuid());else if(J==="cuid2")D=D.check(P4.cuid2());else if(J==="ulid")D=D.check(P4.ulid());else if(J==="xid")D=D.check(P4.xid());else if(J==="ksuid")D=D.check(P4.ksuid())}if(typeof A.minLength==="number")D=D.min(A.minLength);if(typeof A.maxLength==="number")D=D.max(A.maxLength);if(A.pattern)D=D.regex(new RegExp(A.pattern));B=D;break}case"number":case"integer":{let D=$==="integer"?P4.number().int():P4.number();if(typeof A.minimum==="number")D=D.min(A.minimum);if(typeof A.maximum==="number")D=D.max(A.maximum);if(typeof A.exclusiveMinimum==="number")D=D.gt(A.exclusiveMinimum);else if(A.exclusiveMinimum===!0&&typeof A.minimum==="number")D=D.gt(A.minimum);if(typeof A.exclusiveMaximum==="number")D=D.lt(A.exclusiveMaximum);else if(A.exclusiveMaximum===!0&&typeof A.maximum==="number")D=D.lt(A.maximum);if(typeof A.multipleOf==="number")D=D.multipleOf(A.multipleOf);B=D;break}case"boolean":{B=P4.boolean();break}case"null":{B=P4.null();break}case"object":{let D={},J=A.properties||{},E=new Set(A.required||[]);for(let[Y,Z]of Object.entries(J)){let U=xQ(Z,Q);D[Y]=E.has(Y)?U:U.optional()}if(A.propertyNames){let Y=xQ(A.propertyNames,Q),Z=A.additionalProperties&&typeof A.additionalProperties==="object"?xQ(A.additionalProperties,Q):P4.any();if(Object.keys(D).length===0){B=P4.record(Y,Z);break}let U=P4.object(D).passthrough(),X=P4.looseRecord(Y,Z);B=P4.intersection(U,X);break}if(A.patternProperties){let Y=A.patternProperties,Z=Object.keys(Y),U=[];for(let G of Z){let V=xQ(Y[G],Q),K=P4.string().regex(new RegExp(G));U.push(P4.looseRecord(K,V))}let X=[];if(Object.keys(D).length>0)X.push(P4.object(D).passthrough());if(X.push(...U),X.length===0)B=P4.object({}).passthrough();else if(X.length===1)B=X[0];else{let G=P4.intersection(X[0],X[1]);for(let V=2;V<X.length;V++)G=P4.intersection(G,X[V]);B=G}break}let F=P4.object(D);if(A.additionalProperties===!1)B=F.strict();else if(typeof A.additionalProperties==="object")B=F.catchall(xQ(A.additionalProperties,Q));else B=F.passthrough();break}case"array":{let{prefixItems:D,items:J}=A;if(D&&Array.isArray(D)){let E=D.map((Y)=>xQ(Y,Q)),F=J&&typeof J==="object"&&!Array.isArray(J)?xQ(J,Q):void 0;if(F)B=P4.tuple(E).rest(F);else B=P4.tuple(E);if(typeof A.minItems==="number")B=B.check(P4.minLength(A.minItems));if(typeof A.maxItems==="number")B=B.check(P4.maxLength(A.maxItems))}else if(Array.isArray(J)){let E=J.map((Y)=>xQ(Y,Q)),F=A.additionalItems&&typeof A.additionalItems==="object"?xQ(A.additionalItems,Q):void 0;if(F)B=P4.tuple(E).rest(F);else B=P4.tuple(E);if(typeof A.minItems==="number")B=B.check(P4.minLength(A.minItems));if(typeof A.maxItems==="number")B=B.check(P4.maxLength(A.maxItems))}else if(J!==void 0){let E=xQ(J,Q),F=P4.array(E);if(typeof A.minItems==="number")F=F.min(A.minItems);if(typeof A.maxItems==="number")F=F.max(A.maxItems);B=F}else B=P4.array(P4.any());break}default:throw Error(`Unsupported type: ${$}`)}if(A.description)B=B.describe(A.description);if(A.default!==void 0)B=B.default(A.default);return B}function xQ(A,Q){if(typeof A==="boolean")return A?P4.any():P4.never();let $=as1(A,Q),B=A.type||A.enum!==void 0||A.const!==void 0;if(A.anyOf&&Array.isArray(A.anyOf)){let F=A.anyOf.map((Z)=>xQ(Z,Q)),Y=P4.union(F);$=B?P4.intersection($,Y):Y}if(A.oneOf&&Array.isArray(A.oneOf)){let F=A.oneOf.map((Z)=>xQ(Z,Q)),Y=P4.xor(F);$=B?P4.intersection($,Y):Y}if(A.allOf&&Array.isArray(A.allOf))if(A.allOf.length===0)$=B?$:P4.any();else{let F=B?$:xQ(A.allOf[0],Q),Y=B?0:1;for(let Z=Y;Z<A.allOf.length;Z++)F=P4.intersection(F,xQ(A.allOf[Z],Q));$=F}if(A.nullable===!0&&Q.version==="openapi-3.0")$=P4.nullable($);if(A.readOnly===!0)$=P4.readonly($);let D={},J=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let F of J)if(F in A)D[F]=A[F];let E=["contentEncoding","contentMediaType","contentSchema"];for(let F of E)if(F in A)D[F]=A[F];for(let F of Object.keys(A))if(!a8A.has(F))D[F]=A[F];if(Object.keys(D).length>0)Q.registry.add($,D);return $}function os1(A,Q){if(typeof A==="boolean")return A?P4.any():P4.never();let $=o8A(A,Q?.defaultTarget),B=A.$defs||A.definitions||{},D={version:$,defs:B,refs:new Map,processing:new Set,rootSchema:A,registry:Q?.registry??k9};return xQ(A,D)}var P4,a8A;var rs1=o(()=>{qp();W20();Jc();Fc();P4={...Ec,...z20,iso:QH},a8A=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var qc={};H2(qc,{string:()=>s8A,number:()=>t8A,date:()=>Q9A,boolean:()=>e8A,bigint:()=>A9A});function s8A(A){return Cp(VT,A)}function t8A(A){return Pp(zT,A)}function e8A(A){return yp(WT,A)}function A9A(A){return bp(IT,A)}function Q9A(A){return op(Gc,A)}var ss1=o(()=>{J9();Fc()});var S={};H2(S,{xor:()=>Rs1,xid:()=>er1,void:()=>Ms1,uuidv7:()=>ir1,uuidv6:()=>lr1,uuidv4:()=>cr1,uuid:()=>pr1,util:()=>e1,url:()=>L20,uppercase:()=>pI,unknown:()=>w5,union:()=>X5,undefined:()=>ws1,ulid:()=>tr1,uint64:()=>Ns1,uint32:()=>Is1,tuple:()=>wT0,trim:()=>oI,treeifyError:()=>Qd,transform:()=>p20,toUpperCase:()=>sI,toLowerCase:()=>rI,toJSONSchema:()=>UT,templateLiteral:()=>bs1,symbol:()=>Cs1,superRefine:()=>aT0,success:()=>fs1,stringbool:()=>ls1,stringFormat:()=>Us1,string:()=>l0,strictObject:()=>js1,startsWith:()=>lI,slugify:()=>YT,size:()=>JK,setErrorMap:()=>i8A,set:()=>Ts1,safeParseAsync:()=>e_0,safeParse:()=>t_0,safeEncodeAsync:()=>ET0,safeEncode:()=>DT0,safeDecodeAsync:()=>FT0,safeDecode:()=>JT0,registry:()=>y_,regexes:()=>v9,regex:()=>mI,refine:()=>nT0,record:()=>S5,readonly:()=>mT0,property:()=>FT,promise:()=>hs1,prettifyError:()=>$d,preprocess:()=>Hc,prefault:()=>ST0,positive:()=>BT,pipe:()=>Uc,partialRecord:()=>us1,parseAsync:()=>s_0,parse:()=>r_0,overwrite:()=>KJ,optional:()=>l5,object:()=>M4,number:()=>D3,nullish:()=>Ss1,nullable:()=>Zc,null:()=>HT,normalize:()=>aI,nonpositive:()=>JT,nonoptional:()=>fT0,nonnegative:()=>ET,never:()=>d20,negative:()=>DT,nativeEnum:()=>vs1,nanoid:()=>or1,nan:()=>ys1,multipleOf:()=>FX,minSize:()=>rE,minLength:()=>lY,mime:()=>nI,meta:()=>ps1,maxSize:()=>YX,maxLength:()=>EK,map:()=>_s1,mac:()=>$s1,lte:()=>yQ,lt:()=>aE,lowercase:()=>dI,looseRecord:()=>Ps1,looseObject:()=>R8,locales:()=>eM,literal:()=>e4,length:()=>FK,lazy:()=>cT0,ksuid:()=>As1,keyof:()=>Os1,jwt:()=>Zs1,json:()=>is1,iso:()=>QH,ipv6:()=>Bs1,ipv4:()=>Qs1,intersection:()=>qT,int64:()=>qs1,int32:()=>Ws1,int:()=>C20,instanceof:()=>cs1,includes:()=>cI,httpUrl:()=>nr1,hostname:()=>Xs1,hex:()=>Gs1,hash:()=>Vs1,guid:()=>dr1,gte:()=>V7,gt:()=>oE,globalRegistry:()=>k9,getErrorMap:()=>n8A,function:()=>gs1,fromJSONSchema:()=>os1,formatError:()=>aM,float64:()=>zs1,float32:()=>Ks1,flattenError:()=>nM,file:()=>ks1,exactOptional:()=>PT0,enum:()=>a7,endsWith:()=>iI,encodeAsync:()=>$T0,encode:()=>AT0,emoji:()=>ar1,email:()=>mr1,e164:()=>Ys1,discriminatedUnion:()=>zc,describe:()=>ds1,decodeAsync:()=>BT0,decode:()=>QT0,date:()=>Ls1,custom:()=>a20,cuid2:()=>sr1,cuid:()=>rr1,core:()=>iB,config:()=>h2,coerce:()=>qc,codec:()=>xs1,clone:()=>D9,cidrv6:()=>Js1,cidrv4:()=>Ds1,check:()=>ms1,catch:()=>bT0,boolean:()=>Q5,bigint:()=>Hs1,base64url:()=>Fs1,base64:()=>Es1,array:()=>N4,any:()=>m20,_function:()=>gs1,_default:()=>vT0,_ZodString:()=>w20,ZodXor:()=>HT0,ZodXID:()=>_20,ZodVoid:()=>WT0,ZodUnknown:()=>KT0,ZodUnion:()=>Kc,ZodUndefined:()=>XT0,ZodUUID:()=>ZX,ZodURL:()=>Xc,ZodULID:()=>P20,ZodType:()=>WA,ZodTuple:()=>CT0,ZodTransform:()=>RT0,ZodTemplateLiteral:()=>dT0,ZodSymbol:()=>UT0,ZodSuccess:()=>yT0,ZodStringFormat:()=>C5,ZodString:()=>VT,ZodSet:()=>LT0,ZodRecord:()=>Wc,ZodRealError:()=>nB,ZodReadonly:()=>gT0,ZodPromise:()=>lT0,ZodPrefault:()=>kT0,ZodPipe:()=>i20,ZodOptional:()=>c20,ZodObject:()=>Vc,ZodNumberFormat:()=>QL,ZodNumber:()=>zT,ZodNullable:()=>_T0,ZodNull:()=>GT0,ZodNonOptional:()=>l20,ZodNever:()=>zT0,ZodNanoID:()=>j20,ZodNaN:()=>hT0,ZodMap:()=>MT0,ZodMAC:()=>ZT0,ZodLiteral:()=>OT0,ZodLazy:()=>pT0,ZodKSUID:()=>T20,ZodJWT:()=>h20,ZodIssueCode:()=>rT0,ZodIntersection:()=>NT0,ZodISOTime:()=>q20,ZodISODuration:()=>N20,ZodISODateTime:()=>I20,ZodISODate:()=>H20,ZodIPv6:()=>k20,ZodIPv4:()=>v20,ZodGUID:()=>Yc,ZodFunction:()=>iT0,ZodFirstPartyTypeKind:()=>oT0,ZodFile:()=>jT0,ZodExactOptional:()=>uT0,ZodError:()=>c8A,ZodEnum:()=>GT,ZodEmoji:()=>O20,ZodEmail:()=>M20,ZodE164:()=>b20,ZodDiscriminatedUnion:()=>qT0,ZodDefault:()=>TT0,ZodDate:()=>Gc,ZodCustomStringFormat:()=>KT,ZodCustom:()=>Ic,ZodCodec:()=>n20,ZodCatch:()=>xT0,ZodCUID2:()=>u20,ZodCUID:()=>R20,ZodCIDRv6:()=>f20,ZodCIDRv4:()=>S20,ZodBoolean:()=>WT,ZodBigIntFormat:()=>g20,ZodBigInt:()=>IT,ZodBase64URL:()=>x20,ZodBase64:()=>y20,ZodArray:()=>IT0,ZodAny:()=>VT0,TimePrecision:()=>Mp,NEVER:()=>cM,$output:()=>Ip,$input:()=>Hp,$brand:()=>nm});var Nc=o(()=>{J9();J9();IP0();J9();XT();rs1();X20();Jc();Jc();ss1();Fc();W20();o_0();YT0();ns1();h2(Vp())});var NT;var bQ=o(()=>{Nc();Nc();NT=S});function ts1(){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 es1(A,Q){if(!A.scheme&&Q)throw Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${A.authority}", path: "${A.path}", query: "${A.query}", fragment: "${A.fragment}"}`);if(A.scheme&&!$9A.test(A.scheme))throw Error("[UriError]: Scheme contains illegal characters.");if(A.path){if(A.authority){if(!B9A.test(A.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(D9A.test(A.path))throw Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}function J9A(A,Q){if(!A&&!Q)return"file";return A}function E9A(A,Q){switch(A){case"https":case"http":case"file":if(!Q)Q=nY;else if(Q[0]!==nY)Q=nY+Q;break}return Q}class n0{static isUri(A){if(A instanceof n0)return!0;if(!A)return!1;let Q=A;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(A,Q,$,B,D,J=!1,E){if(typeof A==="object")this.scheme=A.scheme||f5,this.authority=A.authority||f5,this.path=A.path||f5,this.query=A.query||f5,this.fragment=A.fragment||f5,this.platform=A.platform;else this.scheme=J9A(A,J),this.authority=Q||f5,this.path=E9A(this.scheme,$||f5),this.query=B||f5,this.fragment=D||f5,this.platform=E,es1(this,J)}get fsPath(){return Dt1(this,!1)}with(A){if(!A)return this;let{scheme:Q,authority:$,path:B,query:D,fragment:J,platform:E}=A;if(Q===void 0)Q=this.scheme;else if(Q===null)Q=f5;if($===void 0)$=this.authority;else if($===null)$=f5;if(B===void 0)B=this.path;else if(B===null)B=f5;if(D===void 0)D=this.query;else if(D===null)D=f5;if(J===void 0)J=this.fragment;else if(J===null)J=f5;if(E===void 0)E=this.platform;else if(E===null)E=void 0;if(Q===this.scheme&&$===this.authority&&B===this.path&&D===this.query&&J===this.fragment&&E===this.platform)return this;return new $L(Q,$,B,D,J,!1,E)}static parse(A,Q=!1){let $=F9A.exec(A);if(!$)return new $L(f5,f5,f5,f5,f5);return new $L($[2]||f5,o20($[4]||f5),o20($[5]||f5),o20($[7]||f5),o20($[9]||f5),Q)}static file(A,Q=ts1()){let $=f5;if(Q==="windows")A=A.replace(/\\/g,nY);if(A[0]===nY&&A[1]===nY){let B=A.indexOf(nY,2);if(B===-1)$=A.substring(2),A=nY;else $=A.substring(2,B),A=A.substring(B)||nY}return new $L("file",$,A,f5,f5,!1,Q)}static from(A){let Q=new $L(A.scheme,A.authority,A.path,A.query,A.fragment,!0,A.platform);return es1(Q,!0),Q}toString(A=!1){return sT0(this,A)}toJSON(){return this}static revive(A){if(!A)return A;if(A instanceof n0)return A;let Q=new $L(A),$=A;return Q._formatted=$.external,Q._fsPath=$._sep===$t1(Q.platform)?$.fsPath:null,Q}}function $t1(A){return A==="windows"?1:void 0}function At1(A,Q,$){let B;for(let D=0;D<A.length;D++){let J=A.charCodeAt(D);if(J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===45||J===46||J===95||J===126||Q&&J===47||$&&J===91||$&&J===93||$&&J===58){if(B!==void 0)B+=A.charAt(D)}else{if(B===void 0)B=A.substring(0,D);let E=Bt1[J];if(E!==void 0)B+=E;else B+=encodeURIComponent(A.charAt(D))}}return B!==void 0?B:A}function Y9A(A){let Q;for(let $=0;$<A.length;$++){let B=A.charCodeAt($);if(B===35||B===63){if(Q===void 0)Q=A.substring(0,$);Q+=Bt1[B]}else if(Q!==void 0)Q+=A[$]}return Q!==void 0?Q:A}function Dt1(A,Q){let $;if(A.authority&&A.path.length>1&&A.scheme==="file")$=`//${A.authority}${A.path}`;else if(A.path.charCodeAt(0)===47&&(A.path.charCodeAt(1)>=65&&A.path.charCodeAt(1)<=90||A.path.charCodeAt(1)>=97&&A.path.charCodeAt(1)<=122)&&A.path.charCodeAt(2)===58)if(!Q)$=A.path[1].toLowerCase()+A.path.substring(2);else $=A.path.substring(1);else $=A.path;if(A.platform==="windows")$=$.replace(/\//g,"\\");return $}function sT0(A,Q){let $=!Q?At1:Y9A,B="",{scheme:D,authority:J,path:E,query:F,fragment:Y}=A;if(D)B+=D,B+=":";if(J||D==="file")B+=nY,B+=nY;if(J){let Z=J.indexOf("@");if(Z!==-1){let U=J.substring(0,Z);if(J=J.substring(Z+1),Z=U.lastIndexOf(":"),Z===-1)B+=$(U,!1,!1);else B+=$(U.substring(0,Z),!1,!1),B+=":",B+=$(U.substring(Z+1),!1,!0);B+="@"}if(J=J.toLowerCase(),Z=J.lastIndexOf(":"),Z===-1)B+=$(J,!1,!0);else B+=$(J.substring(0,Z),!1,!0),B+=J.substring(Z)}if(E){if(E.length>=3&&E.charCodeAt(0)===47&&E.charCodeAt(2)===58){let Z=E.charCodeAt(1);if(Z>=65&&Z<=90)E=`/${String.fromCharCode(Z+32)}:${E.substring(3)}`}else if(E.length>=2&&E.charCodeAt(1)===58){let Z=E.charCodeAt(0);if(Z>=65&&Z<=90)E=`${String.fromCharCode(Z+32)}:${E.substring(2)}`}B+=$(E,!0,!1)}if(F)B+="?",B+=$(F,!1,!1);if(Y)B+="#",B+=!Q?At1(Y,!1,!1):Y;return B}function Jt1(A){try{return decodeURIComponent(A)}catch{if(A.length>3)return A.substring(0,3)+Jt1(A.substring(3));else return A}}function o20(A){if(!A.match(Qt1))return A;return A.replace(Qt1,(Q)=>Jt1(Q))}function Cc(A){return A.scheme==="file"}function $8(A){return n0.parse(A)}function A4(A){return aY.parse(A.toString())}function XA(A){if(typeof A==="string"||A instanceof URL)return n0.parse(A.toString());return A}var $9A,B9A,D9A,f5="",nY="/",F9A,$L,Bt1,Qt1,aY;var CT=o(()=>{bQ();$9A=/^\w[\w\d+.-]*$/,B9A=/^\//,D9A=/^\/\//;F9A=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;$L=class $L extends n0{_formatted=null;_fsPath=null;get fsPath(){if(!this._fsPath)this._fsPath=Dt1(this,!1);return this._fsPath}toString(A=!1){if(!A){if(!this._formatted)this._formatted=sT0(this,!1);return this._formatted}return sT0(this,!0)}toJSON(){let A={};if(this._fsPath)A.fsPath=this._fsPath,A._sep=$t1(this.platform);if(this._formatted)A.external=this._formatted;if(A.scheme=this.scheme,A.authority=this.authority,A.path=this.path,A.query=this.query,A.fragment=this.fragment,this.platform)A.platform=this.platform;return A}};Bt1={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"};Qt1=/(%[0-9A-Za-z][0-9A-Za-z])+/g;aY=S.string().brand()});function tT0(A){if(A==="/")return"/";if(A==="")return".";let Q=A.replace(/\/+$/,"");if(!Q)return".";let $=Q.lastIndexOf("/");if($===-1)return".";if($===0)return"/";return Q.slice(0,$)}function S$(A){let Q=A.replace(/\/+$/,"");if(!Q)return"";let $=Q.lastIndexOf("/");return $===-1?Q:Q.slice($+1)}function wT(...A){if(A.length===0)return".";let Q="";for(let E of A)if(E)if(Q)Q+="/"+E;else Q=E;if(!Q)return".";let $=Q.endsWith("/"),B=Q.split("/").filter(Boolean),D=[];for(let E of B)if(E===".."){if(D.length>0&&D[D.length-1]!=="..")D.pop();else if(!Q.startsWith("/"))D.push("..")}else if(E!==".")D.push(E);let J=Q.startsWith("/")?"/"+D.join("/"):D.join("/");if(!J)J=Q.startsWith("/")?"/":".";if($&&J!=="/"&&J!==".")J+="/";return J}function Et1(A,Q,$="/",B="/",D=!0){function J(X,G){return D?X===G:X.toLowerCase()===G.toLowerCase()}if($==="/")A=A.replaceAll(/\/{2,}/g,"/"),Q=Q.replaceAll(/\/{2,}/g,"/");else A=A.replaceAll(/\\{2,}/g,"\\"),Q=Q.replaceAll(/\\{2,}/g,"\\");if(A!==$&&A.endsWith($))A=A.slice(0,-1);if(Q!==$&&Q.endsWith($))Q=Q.slice(0,-1);if(J(A,Q))return"";if(!A.startsWith($)&&Q.startsWith($))return Q;let E=A===$?[""]:A.split($),F=Q===$?[""]:Q.split($),Y=0;while(Y<E.length&&Y<F.length&&J(E[Y],F[Y]))Y++;let Z=E.length-Y,U=[];for(let X=0;X<Z;X++)U.push("..");return U.push(...F.slice(Y)),U.join(B)}function r20(A){let Q=S$(A.replace(/\/+$/,"")),$=Q.lastIndexOf(".");if($===0||$===-1)return"";return Q.slice($)}function l3(A){try{if(A=XA(A),A.scheme==="file")return A.fsPath}catch{}return A.toString()}var $H=o(()=>{CT()});function U9A(A){if(A.startsWith(BL))return A;if(Z9A.test(A))return`${BL}${A.replace(/\\/g,BL)}`;return}function X9A(A,...Q){return A=XA(A),A.with({path:wT(A.path,...Q)})}function G9A(A,...Q){let $=A.path,B=!1;if($[0]!==BL)$=BL+$,B=!0;let D=$;for(let J of Q){let E=U9A(J);if(E)D=wT(E);else D=wT(D,J)}if(D!=="/"&&D.endsWith("/"))D=D.replace(/\/+$/,"");if(B&&D[0]===BL&&!A.authority)D=D.substring(1);return A.with({path:D})}function V9A(A){if(A=XA(A),A.path.length===0||A.path===BL)return A;let Q=tT0(A.path);if(Q.length===1&&Q===".")Q="";return A.with({path:Q})}function K9A(A,Q){if(Q.scheme!==A.scheme||(Q.authority??"")!==(A.authority??""))return!1;let $=Q.scheme==="file"&&Q.path.match(/^\/[A-Za-z]:/),B=$?Q.path.slice(0,2).toUpperCase()+Q.path.slice(2):Q.path,D=$?A.path.slice(0,2).toUpperCase()+A.path.slice(2):A.path;return D===B||D.startsWith(B.endsWith("/")?B:`${B}/`)||B.endsWith("/")&&D===B.slice(0,-1)}function z9A(A,Q){if(A.scheme!==Q.scheme||A.authority!==Q.authority||A.query!==Q.query||A.fragment!==Q.fragment)return null;let $=A.scheme==="file"&&/^\/[A-Za-z]:/.test(A.path)&&/^\/[A-Za-z]:/.test(Q.path);return Et1(A.path,Q.path,"/","/",!$)}function W9A(A,Q){let $=A4(A),B=A4(Q);if($.startsWith("file:///")&&B.startsWith("file:///"))return Ft1($)===Ft1(B);return $===B}function Ft1(A){return A.replace(/^file:\/\/\/([A-Za-z]):/,(Q)=>`file:///${Q.toLowerCase()}:`)}var BL="/",Z9A,B1;var eT0=o(()=>{$H();CT();Z9A=/^[A-Za-z]:[\\/]/;B1={joinPath:X9A,resolvePath:G9A,dirname:V9A,basename:(A)=>S$(XA(A).path),extname:(A)=>r20(XA(A).path),hasPrefix:K9A,relativePath:z9A,equalURIs:W9A}});var B4=o(()=>{CT();eT0();$H()});function Av0(){let Q=UX.getLogger().contextLocalStorage?.getStore();if(Q==null)return[];let $=Q[I9A];return Array.isArray($)?$:[]}function s20(){let Q=UX.getLogger().contextLocalStorage?.getStore();if(Q==null)return{};let $={};for(let B of Object.keys(Q))$[B]=Q[B];return $}var I9A;var Yt1=o(()=>{t20();I9A=Symbol.for("logtape.categoryPrefix")});function e20(A,Q){let $=Zt1.indexOf(A);if($<0)throw TypeError(`Invalid log level: ${JSON.stringify(A)}.`);let B=Zt1.indexOf(Q);if(B<0)throw TypeError(`Invalid log level: ${JSON.stringify(Q)}.`);return $-B}var Zt1;var Ut1=o(()=>{Zt1=["trace","debug","info","warning","error","fatal"]});function zt1(A){return A!=null&&typeof A==="object"&&Xt1 in A&&A[Xt1]===!0}function BH(A){let Q={};for(let $ in A){let B=A[$];Q[$]=zt1(B)?B.getter():B}return Q}function H9A(A){let Q=BH(A.properties),$=Object.getOwnPropertyDescriptors(A);return $.properties={value:Q,enumerable:!0,configurable:!0},Object.defineProperties({},$)}function $v0(A=[]){return UX.getLogger(A)}function Gt1(A){return A.length===2&&A[0]==="logtape"&&A[1]==="meta"}function C9A(A){return A.includes(".")||A.includes("[")||A.includes("?.")}function w9A(A,Q){if(Q==="__proto__"||Q==="prototype"||Q==="constructor")return;if((typeof A==="object"||typeof A==="function")&&A!==null)return Object.prototype.hasOwnProperty.call(A,Q)?A[Q]:void 0;return}function M9A(A,Q){let $=A.length,B=Q;if(B>=$)return null;let D;if(A[B]==="["){if(B++,B>=$)return null;if(A[B]==='"'||A[B]==="'"){let J=A[B];B++;let E="";while(B<$&&A[B]!==J)if(A[B]==="\\"){if(B++,B<$){let F=A[B];switch(F){case"n":E+=`
214
214
  `;break;case"t":E+="\t";break;case"r":E+="\r";break;case"b":E+="\b";break;case"f":E+="\f";break;case"v":E+="\v";break;case"0":E+="\x00";break;case"\\":E+="\\";break;case'"':E+='"';break;case"'":E+="'";break;case"u":if(B+4<$){let Y=A.slice(B+1,B+5),Z=Number.parseInt(Y,16);if(!Number.isNaN(Z))E+=String.fromCharCode(Z),B+=4;else E+=F}else E+=F;break;default:E+=F}B++}}else E+=A[B],B++;if(B>=$)return null;D=E,B++}else{let J=B;while(B<$&&A[B]!=="]"&&A[B]!=="'"&&A[B]!=='"')B++;if(B>=$)return null;let E=A.slice(J,B);if(E.length===0)return null;let F=Number(E);D=Number.isNaN(F)?E:F}while(B<$&&A[B]!=="]")B++;if(B<$)B++}else{let J=B;while(B<$&&A[B]!=="."&&A[B]!=="["&&A[B]!=="?"&&A[B]!=="]")B++;if(D=A.slice(J,B),D.length===0)return null}if(B<$&&A[B]===".")B++;return{segment:D,nextIndex:B}}function L9A(A,Q){if(typeof Q==="string")return w9A(A,Q);if(Array.isArray(A)&&Q>=0&&Q<A.length)return A[Q];return}function O9A(A,Q){if(A==null)return;if(Q.length===0||Q.endsWith("."))return;let $=A,B=0,D=Q.length;while(B<D){if(Q.slice(B,B+2)==="?."){if(B+=2,$==null)return}else if($==null)return;let E=M9A(Q,B);if(E===null)return;let{segment:F,nextIndex:Y}=E;if(B=Y,$=L9A($,F),$===void 0)return}return $}function Vt1(A,Q){let $=A.length;if($===0)return[""];if(!A.includes("{"))return[A];let B=[],D=0;for(let E=0;E<$;E++){let F=A[E];if(F==="{"){if((E+1<$?A[E+1]:"")==="{"){E++;continue}let Z=A.indexOf("}",E+1);if(Z===-1)continue;let U=A.slice(D,E);B.push(U.replace(/{{/g,"{").replace(/}}/g,"}"));let X=A.slice(E+1,Z),G,V=X.trim();if(V==="*")G=X in Q?Q[X]:("*"in Q)?Q["*"]:Q;else{if(X!==V)G=X in Q?Q[X]:Q[V];else G=Q[X];if(G===void 0&&C9A(V))G=O9A(Q,V)}B.push(G),E=Z,D=E+1}else if(F==="}"&&E+1<$&&A[E+1]==="}")E++}let J=A.slice(D);return B.push(J.replace(/{{/g,"{").replace(/}}/g,"}")),B}function Kt1(A,Q){let $=[];for(let B=0;B<A.length;B++)if($.push(A[B]),B<Q.length)$.push(Q[B]);return $}var Xt1,Qv0,UX=class A{parent;children;category;sinks;parentSinks="inherit";filters;lowestLevel="trace";contextLocalStorage;static getLogger(Q=[]){let $=Qv0 in globalThis?globalThis[Qv0]??null:null;if($==null)$=new A(null,[]),globalThis[Qv0]=$;if(typeof Q==="string")return $.getChild(Q);if(Q.length===0)return $;return $.getChild(Q)}static getNearestExistingLogger(Q){let $=A.getLogger();for(let B of Q){let D=$.children[B],J=D instanceof A?D:D?.deref();if(J==null)break;$=J}return $}constructor(Q,$){this.parent=Q,this.children={},this.category=$,this.sinks=[],this.filters=[]}getChild(Q){let $=typeof Q==="string"?Q:Q[0],B=this.children[$],D=B instanceof A?B:B?.deref();if(D==null)D=new A(this,[...this.category,$]),this.children[$]="WeakRef"in globalThis?new WeakRef(D):D;if(typeof Q==="string"||Q.length===1)return D;return D.getChild(Q.slice(1))}reset(){while(this.sinks.length>0)this.sinks.shift();this.parentSinks="inherit";while(this.filters.length>0)this.filters.shift();this.lowestLevel="trace"}resetDescendants(){for(let Q of Object.values(this.children)){let $=Q instanceof A?Q:Q.deref();if($!=null)$.resetDescendants()}this.reset()}with(Q){return new q9A(this,{...Q})}filter(Q){for(let $ of this.filters)if(!$(Q))return!1;if(this.filters.length<1)return this.parent?.filter(Q)??!0;return!0}*getSinks(Q){if(this.lowestLevel===null||e20(Q,this.lowestLevel)<0)return;if(this.parent!=null&&this.parentSinks==="inherit")for(let $ of this.parent.getSinks(Q))yield $;for(let $ of this.sinks)yield $}isEnabledFor(Q){let $=Gt1(this.category)?[]:Av0();return($.length>0?A.getNearestExistingLogger([...$,...this.category]):this).isEnabledForResolved(Q)}isEnabledForResolved(Q){if(this.lowestLevel===null||e20(Q,this.lowestLevel)<0)return!1;for(let $ of this.getSinks(Q))return!0;return!1}emit(Q,$){let B="category"in Q?Q.category:this.category,D=Gt1(B)?[]:Av0(),J=D.length>0?[...D,...B]:B,E=Object.getOwnPropertyDescriptors(Q);E.category={value:J,enumerable:!0,configurable:!0};let F=Object.defineProperties({},E);(D.length>0?A.getNearestExistingLogger(J):this).emitResolved(F,$)}emitResolved(Q,$){if(this.lowestLevel===null||e20(Q.level,this.lowestLevel)<0||!this.filter(Q))return;let B=[...this.getSinks(Q.level)];if(B.length<1)return;let D,J=!1;for(let E of B){if($?.has(E))continue;try{if(D==null&&!J)try{D=H9A(Q)}catch{J=!0,D=Q}E(D??Q)}catch(F){let Y=new Set($);Y.add(E),N9A.log("fatal","Failed to emit a log record to sink {sink}: {error}",{sink:E,error:F,record:Q},Y)}}}log(Q,$,B,D){let J=s20(),E=void 0,F=void 0,Y=typeof B==="function"?{category:this.category,level:Q,timestamp:Date.now(),get message(){if(F==null)F=Vt1($,this.properties);return F},rawMessage:$,get properties(){if(E==null)E=BH({...J,...B()});return E}}:{category:this.category,level:Q,timestamp:Date.now(),get message(){if(F==null)F=Vt1($,this.properties);return F},rawMessage:$,get properties(){if(E==null)E=BH({...J,...B});return E}};this.emit(Y,D)}logLazily(Q,$,B={}){let D=s20(),J=void 0,E=void 0;function F(){if(E==null||J==null){if(E=$((Y,...Z)=>{return J=Y,Kt1(Y,Z)}),J==null)throw TypeError("No log record was made.")}return[E,J]}this.emit({category:this.category,level:Q,get message(){return F()[0]},get rawMessage(){return F()[1]},timestamp:Date.now(),properties:{...D,...B}})}logTemplate(Q,$,B,D={}){let J=s20();this.emit({category:this.category,level:Q,message:Kt1($,B),rawMessage:$,timestamp:Date.now(),properties:{...J,...D}})}trace(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("trace"))return Promise.resolve();return B().then((J)=>{this.log("trace",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("trace"))return Promise.resolve();return D.then((J)=>{this.log("trace",Q,J)})}this.log("trace",Q,D);return}this.log("trace",Q,B??{})}else if(typeof Q==="function")this.logLazily("trace",Q);else if(!Array.isArray(Q))this.log("trace","{*}",Q);else this.logTemplate("trace",Q,$)}debug(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("debug"))return Promise.resolve();return B().then((J)=>{this.log("debug",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("debug"))return Promise.resolve();return D.then((J)=>{this.log("debug",Q,J)})}this.log("debug",Q,D);return}this.log("debug",Q,B??{})}else if(typeof Q==="function")this.logLazily("debug",Q);else if(!Array.isArray(Q))this.log("debug","{*}",Q);else this.logTemplate("debug",Q,$)}info(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("info"))return Promise.resolve();return B().then((J)=>{this.log("info",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("info"))return Promise.resolve();return D.then((J)=>{this.log("info",Q,J)})}this.log("info",Q,D);return}this.log("info",Q,B??{})}else if(typeof Q==="function")this.logLazily("info",Q);else if(!Array.isArray(Q))this.log("info","{*}",Q);else this.logTemplate("info",Q,$)}warn(Q,...$){if(Q instanceof Error)this.log("warning","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("warning",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("warning"))return Promise.resolve();return B().then((J)=>{this.log("warning",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("warning"))return Promise.resolve();return D.then((J)=>{this.log("warning",Q,J)})}this.log("warning",Q,D);return}this.log("warning",Q,B??{})}else if(typeof Q==="function")this.logLazily("warning",Q);else if(!Array.isArray(Q))this.log("warning","{*}",Q);else this.logTemplate("warning",Q,$)}warning(Q,...$){if(Q instanceof Error)this.log("warning","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("warning",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("warning"))return Promise.resolve();return B().then((J)=>{this.log("warning",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("warning"))return Promise.resolve();return D.then((J)=>{this.log("warning",Q,J)})}this.log("warning",Q,D);return}this.log("warning",Q,B??{})}else if(typeof Q==="function")this.logLazily("warning",Q);else if(!Array.isArray(Q))this.log("warning","{*}",Q);else this.logTemplate("warning",Q,$)}error(Q,...$){if(Q instanceof Error)this.log("error","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("error",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("error"))return Promise.resolve();return B().then((J)=>{this.log("error",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("error"))return Promise.resolve();return D.then((J)=>{this.log("error",Q,J)})}this.log("error",Q,D);return}this.log("error",Q,B??{})}else if(typeof Q==="function")this.logLazily("error",Q);else if(!Array.isArray(Q))this.log("error","{*}",Q);else this.logTemplate("error",Q,$)}fatal(Q,...$){if(Q instanceof Error)this.log("fatal","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("fatal",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("fatal"))return Promise.resolve();return B().then((J)=>{this.log("fatal",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("fatal"))return Promise.resolve();return D.then((J)=>{this.log("fatal",Q,J)})}this.log("fatal",Q,D);return}this.log("fatal",Q,B??{})}else if(typeof Q==="function")this.logLazily("fatal",Q);else if(!Array.isArray(Q))this.log("fatal","{*}",Q);else this.logTemplate("fatal",Q,$)}},q9A=class A{logger;properties;constructor(Q,$){this.logger=Q,this.properties=$}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(Q){return this.logger.getChild(Q).with(this.properties)}with(Q){return new A(this.logger,{...this.properties,...Q})}log(Q,$,B,D){let J=this.properties;this.logger.log(Q,$,typeof B==="function"?()=>BH({...J,...B()}):()=>BH({...J,...B}),D)}logLazily(Q,$){this.logger.logLazily(Q,$,BH(this.properties))}logTemplate(Q,$,B){this.logger.logTemplate(Q,$,B,BH(this.properties))}emit(Q){let $={...Q,properties:BH({...this.properties,...Q.properties})};this.logger.emit($)}isEnabledFor(Q){return this.logger.isEnabledFor(Q)}trace(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("trace"))return Promise.resolve();return B().then((J)=>{this.log("trace",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("trace"))return Promise.resolve();return D.then((J)=>{this.log("trace",Q,J)})}this.log("trace",Q,D);return}this.log("trace",Q,B??{})}else if(typeof Q==="function")this.logLazily("trace",Q);else if(!Array.isArray(Q))this.log("trace","{*}",Q);else this.logTemplate("trace",Q,$)}debug(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("debug"))return Promise.resolve();return B().then((J)=>{this.log("debug",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("debug"))return Promise.resolve();return D.then((J)=>{this.log("debug",Q,J)})}this.log("debug",Q,D);return}this.log("debug",Q,B??{})}else if(typeof Q==="function")this.logLazily("debug",Q);else if(!Array.isArray(Q))this.log("debug","{*}",Q);else this.logTemplate("debug",Q,$)}info(Q,...$){if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("info"))return Promise.resolve();return B().then((J)=>{this.log("info",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("info"))return Promise.resolve();return D.then((J)=>{this.log("info",Q,J)})}this.log("info",Q,D);return}this.log("info",Q,B??{})}else if(typeof Q==="function")this.logLazily("info",Q);else if(!Array.isArray(Q))this.log("info","{*}",Q);else this.logTemplate("info",Q,$)}warn(Q,...$){if(Q instanceof Error)this.log("warning","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("warning",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("warning"))return Promise.resolve();return B().then((J)=>{this.log("warning",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("warning"))return Promise.resolve();return D.then((J)=>{this.log("warning",Q,J)})}this.log("warning",Q,D);return}this.log("warning",Q,B??{})}else if(typeof Q==="function")this.logLazily("warning",Q);else if(!Array.isArray(Q))this.log("warning","{*}",Q);else this.logTemplate("warning",Q,$)}warning(Q,...$){if(Q instanceof Error)this.log("warning","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("warning",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("warning"))return Promise.resolve();return B().then((J)=>{this.log("warning",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("warning"))return Promise.resolve();return D.then((J)=>{this.log("warning",Q,J)})}this.log("warning",Q,D);return}this.log("warning",Q,B??{})}else if(typeof Q==="function")this.logLazily("warning",Q);else if(!Array.isArray(Q))this.log("warning","{*}",Q);else this.logTemplate("warning",Q,$)}error(Q,...$){if(Q instanceof Error)this.log("error","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("error",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("error"))return Promise.resolve();return B().then((J)=>{this.log("error",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("error"))return Promise.resolve();return D.then((J)=>{this.log("error",Q,J)})}this.log("error",Q,D);return}this.log("error",Q,B??{})}else if(typeof Q==="function")this.logLazily("error",Q);else if(!Array.isArray(Q))this.log("error","{*}",Q);else this.logTemplate("error",Q,$)}fatal(Q,...$){if(Q instanceof Error)this.log("fatal","{error.message}",{error:Q});else if(typeof Q==="string"&&$[0]instanceof Error)this.log("fatal",Q,{error:$[0]});else if(typeof Q==="string"){let B=$[0];if(typeof B==="function"){if(B.constructor.name==="AsyncFunction"){if(!this.isEnabledFor("fatal"))return Promise.resolve();return B().then((J)=>{this.log("fatal",Q,J)})}let D=B();if(D instanceof Promise){if(!this.isEnabledFor("fatal"))return Promise.resolve();return D.then((J)=>{this.log("fatal",Q,J)})}this.log("fatal",Q,D);return}this.log("fatal",Q,B??{})}else if(typeof Q==="function")this.logLazily("fatal",Q);else if(!Array.isArray(Q))this.log("fatal","{*}",Q);else this.logTemplate("fatal",Q,$)}},N9A;var t20=o(()=>{Yt1();Ut1();Xt1=Symbol.for("logtape.lazy");Qv0=Symbol.for("logtape.rootLogger");N9A=UX.getLogger(["logtape","meta"])});var Q80={};H2(Q80,{inspect:()=>A80});import j9A from"node:util";function A80(A,Q){return j9A.inspect(A,Q)}var Wt1=()=>{};function i5(A){return A<10?`0${A}`:`${A}`}function MT(A){return A<10?`00${A}`:A<100?`0${A}`:`${A}`}function qt1(A){return A==="crlf"?`\r
215
215
  `:`
216
- `}function B80(A,Q){if(!(Q instanceof Error))return Q;let $={name:Q.name,message:Q.message};if(typeof Q.stack==="string")$.stack=Q.stack;let B=Q.cause;if(B!==void 0)$.cause=B;if(typeof AggregateError<"u"&&Q instanceof AggregateError)$.errors=Q.errors;for(let D of Object.keys(Q))if(!(D in $))$[D]=Q[D];return $}function Ev0(A={}){let Q=(()=>{let F=A.timestamp;if(F==null)return $80["date-time-timezone"];else if(F==="disabled")return $80.none;else if(typeof F==="string"&&F in $80)return $80[F];else return F})(),$=A.category??"·",B=A.value?(F)=>A.value(F,It1):It1,D=(()=>{let F=A.level;if(F==null||F==="ABBR")return(Y)=>LT.ABBR[Y];else if(F==="abbr")return(Y)=>LT.abbr[Y];else if(F==="FULL")return(Y)=>LT.FULL[Y];else if(F==="full")return(Y)=>LT.full[Y];else if(F==="L")return(Y)=>LT.L[Y];else if(F==="l")return(Y)=>LT.l[Y];else return F})(),J=qt1(A.lineEnding),E=A.format??(({timestamp:F,level:Y,category:Z,message:U})=>`${F?`${F} `:""}[${Y}] ${Z}: ${U}`);return(F)=>{let Y=F.message,Z=Y.length,U;if(Z===1)U=Y[0];else if(Z<=6){U="";for(let z=0;z<Z;z++)U+=z%2===0?Y[z]:B(Y[z])}else{let z=Array(Z);for(let W=0;W<Z;W++)z[W]=W%2===0?Y[W]:B(Y[W]);U=z.join("")}let X=Q(F.timestamp),G=D(F.level),V=typeof $==="function"?$(F.category):F.category.join($);return`${E({timestamp:X,level:G,category:V,message:U,record:F})}${J}`}}function Nt1(A={}){let Q=A.format,$=typeof A.timestampStyle>"u"?"dim":A.timestampStyle,B=A.timestampColor??null,D=`${$==null?"":Jv0[$]}${B==null?"":Dv0[B]}`,J=$==null&&B==null?"":Bv0,E=typeof A.levelStyle>"u"?"bold":A.levelStyle,F=A.levelColors??R9A,Y=typeof A.categoryStyle>"u"?"dim":A.categoryStyle,Z=A.categoryColor??null,U=`${Y==null?"":Jv0[Y]}${Z==null?"":Dv0[Z]}`,X=Y==null&&Z==null?"":Bv0;return Ev0({timestamp:"date-time-tz",value(G,V){return V(G,{colors:!0})},...A,format({timestamp:G,level:V,category:K,message:z,record:W}){let I=F[W.level];return G=G==null?null:`${D}${G}${J}`,V=`${E==null?"":Jv0[E]}${I==null?"":Dv0[I]}${V}${E==null&&I==null?"":Bv0}`,Q==null?`${G==null?"":`${G} `}${V} ${U}${K}:${X} ${z}`:Q({timestamp:G,level:V,category:`${U}${K}${X}`,message:z,record:W})}})}function J80(A={}){let Q=qt1(A.lineEnding);if(!A.categorySeparator&&!A.message&&!A.properties)return(F)=>{if(F.message.length===3)return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:F.message[0]+JSON.stringify(F.message[1])+F.message[2],logger:F.category.join("."),properties:F.properties},B80)+Q;if(F.message.length===1)return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:F.message[0],logger:F.category.join("."),properties:F.properties},B80)+Q;let Y=F.message[0];for(let Z=1;Z<F.message.length;Z++)Y+=Z&1?JSON.stringify(F.message[Z]):F.message[Z];return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:Y,logger:F.category.join("."),properties:F.properties},B80)+Q};let $=A.message==="template",B=A.properties??"nest:properties",D;if(typeof A.categorySeparator==="function")D=A.categorySeparator;else{let F=A.categorySeparator??".";D=(Y)=>Y.join(F)}let J;if(B==="flatten")J=(F)=>F;else if(B.startsWith("prepend:")){let F=B.substring(8);if(F==="")throw TypeError(`Invalid properties option: ${JSON.stringify(B)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);J=(Y)=>{let Z={};for(let U in Y)Z[`${F}${U}`]=Y[U];return Z}}else if(B.startsWith("nest:")){let F=B.substring(5);J=(Y)=>({[F]:Y})}else throw TypeError(`Invalid properties option: ${JSON.stringify(B)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let E;if($)E=(F)=>{if(typeof F.rawMessage==="string")return F.rawMessage;let Y="";for(let Z=0;Z<F.rawMessage.length;Z++)Y+=Z%2<1?F.rawMessage[Z]:"{}";return Y};else E=(F)=>{let Y=F.message.length;if(Y===1)return F.message[0];let Z="";for(let U=0;U<Y;U++)Z+=U%2<1?F.message[U]:JSON.stringify(F.message[U]);return Z};return(F)=>{return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:E(F),logger:D(F.category),...J(F.properties)},B80)+Q}}function wc(A){let Q="",$=[];for(let J=0;J<A.message.length;J++)if(J%2===0)Q+=A.message[J];else Q+="%o",$.push(A.message[J]);let B=new Date(A.timestamp);return[`%c${`${B.getUTCHours().toString().padStart(2,"0")}:${B.getUTCMinutes().toString().padStart(2,"0")}:${B.getUTCSeconds().toString().padStart(2,"0")}.${B.getUTCMilliseconds().toString().padStart(3,"0")}`} %c${Ht1[A.level]}%c %c${A.category.join("·")} %c${Q}`,"color: gray;",_9A[A.level],"background-color: default;","color: gray;","color: default;",...$]}var Ht1,It1,$80,LT,D80,Bv0="\x1B[0m",Dv0,Jv0,R9A,u9A,P9A,_9A;var Fv0=o(()=>{Wt1();Ht1={trace:"TRC",debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},It1=typeof document<"u"||typeof navigator<"u"&&navigator.product==="ReactNative"?(A)=>JSON.stringify(A):("Deno"in globalThis)&&("inspect"in globalThis.Deno)&&typeof globalThis.Deno.inspect==="function"?(A,Q)=>globalThis.Deno.inspect(A,{strAbbreviateSize:1/0,iterableLimit:1/0,...Q}):Q80!=null&&("inspect"in Q80)&&typeof A80==="function"?(A,Q)=>A80(A,{maxArrayLength:1/0,maxStringLength:1/0,...Q}):(A)=>JSON.stringify(A);$80={"date-time-timezone":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y} +00:00`},"date-time-tz":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y} +00`},"date-time":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y}`},"time-timezone":(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J} +00:00`},"time-tz":(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J} +00`},time:(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J}`},date:(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate());return`${$}-${B}-${D}`},rfc3339:(A)=>new Date(A).toISOString(),none:()=>null},LT={ABBR:Ht1,abbr:{trace:"trc",debug:"dbg",info:"inf",warning:"wrn",error:"err",fatal:"ftl"},FULL:{trace:"TRACE",debug:"DEBUG",info:"INFO",warning:"WARNING",error:"ERROR",fatal:"FATAL"},full:{trace:"trace",debug:"debug",info:"info",warning:"warning",error:"error",fatal:"fatal"},L:{trace:"T",debug:"D",info:"I",warning:"W",error:"E",fatal:"F"},l:{trace:"t",debug:"d",info:"i",warning:"w",error:"e",fatal:"f"}};D80=Ev0(),Dv0={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},Jv0={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},R9A={trace:null,debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};u9A=Nt1();P9A=J80(),_9A={trace:"background-color: gray; color: white;",debug:"background-color: gray; color: white;",info:"background-color: white; color: black;",warning:"background-color: orange; color: black;",error:"background-color: red; color: white;",fatal:"background-color: maroon; color: white;"}});function Ct1(A){if(typeof A==="function")return A;return T9A(A)}function T9A(A){if(A==null)return()=>!1;if(A==="fatal")return(Q)=>Q.level==="fatal";else if(A==="error")return(Q)=>Q.level==="fatal"||Q.level==="error";else if(A==="warning")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning";else if(A==="info")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning"||Q.level==="info";else if(A==="debug")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning"||Q.level==="info"||Q.level==="debug";else if(A==="trace")return()=>!0;throw TypeError(`Invalid log level: ${A}.`)}var wt1=()=>{};function Mc(A={}){let Q=A.formatter??wc,$={trace:"debug",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"error",...A.levelMap??{}},B=A.console??globalThis.console,D=(I)=>{let H=Q(I),q=$[I.level];if(q===void 0)throw TypeError(`Invalid log level: ${I.level}.`);if(typeof H==="string"){let N=H.replace(/\r?\n$/,"");B[q](N)}else B[q](...H)};if(!A.nonBlocking)return D;let J=A.nonBlocking===!0?{}:A.nonBlocking,E=J.bufferSize??100,F=J.flushInterval??100,Y=[],Z=null,U=!1,X=!1,G=E*2;function V(){if(Y.length===0)return;let I=Y.splice(0);for(let H of I)try{D(H)}catch{}}function K(){if(X)return;X=!0,setTimeout(()=>{X=!1,V()},0)}function z(){if(Z!==null||U)return;Z=setInterval(()=>{V()},F)}let W=(I)=>{if(U)return;if(Y.length>=G)Y.shift();if(Y.push(I),Y.length>=E)K();else if(Z===null)z()};return W[Symbol.dispose]=()=>{if(U=!0,Z!==null)clearInterval(Z),Z=null;V()},W}var Yv0=o(()=>{Fv0()});function v9A(A){return A.category.length===0||A.category.length===1&&A.category[0]==="logtape"||A.category.length===2&&A.category[0]==="logtape"&&A.category[1]==="meta"}function k9A(A){let Q=A?Y80:Z80;if(typeof globalThis.EdgeRuntime!=="string"&&"process"in globalThis&&!("Deno"in globalThis)){let B=globalThis.process,D=B?.on;if(typeof D==="function"){D.call(B,"exit",Q);return}}let $=globalThis.addEventListener;if(typeof $!=="function")return;if("Deno"in globalThis)$.call(globalThis,"unload",Q);else $.call(globalThis,"pagehide",Q)}function Oc(A){if(F80!=null&&!A.reset)throw new YK("Already configured; if you want to reset, turn on the reset flag.");if(Lc.size>0)throw new YK("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");OT();try{S9A(A,!1)}catch(Q){if(Q instanceof YK)OT();throw Q}}function S9A(A,Q){F80=A;let $=!1,B=new Set;for(let J of A.loggers){if(v9A(J))$=!0;let E=Array.isArray(J.category)?JSON.stringify(J.category):JSON.stringify([J.category]);if(B.has(E))throw new YK(`Duplicate logger configuration for category: ${E}. Each category can only be configured once.`);B.add(E);let F=UX.getLogger(J.category);for(let Y of J.sinks??[]){let Z=A.sinks[Y];if(!Z)throw new YK(`Sink not found: ${Y}.`);F.sinks.push(Z)}if(F.parentSinks=J.parentSinks??"inherit",J.lowestLevel!==void 0)F.lowestLevel=J.lowestLevel;for(let Y of J.filters??[]){let Z=A.filters?.[Y];if(Z===void 0)throw new YK(`Filter not found: ${Y}.`);F.filters.push(Ct1(Z))}Mt1.add(F)}UX.getLogger().contextLocalStorage=A.contextLocalStorage;for(let J of Object.values(A.sinks)){if(Symbol.asyncDispose in J)if(Q)Lc.add(J);else throw new YK("Async disposables cannot be used with configureSync().");if(Symbol.dispose in J)E80.add(J)}for(let J of Object.values(A.filters??{})){if(J==null||typeof J==="string")continue;if(Symbol.asyncDispose in J)if(Q)Lc.add(J);else throw new YK("Async disposables cannot be used with configureSync().");if(Symbol.dispose in J)E80.add(J)}k9A(Q);let D=UX.getLogger(["logtape","meta"]);if(!$)D.sinks.push(Mc());D.info("LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.",{metaLoggerCategory:["logtape","meta"],dismissLevel:"info"})}function Zv0(){return F80}function OT(){Z80(),f9A()}function f9A(){let A=UX.getLogger([]);A.resetDescendants(),delete A.contextLocalStorage,Mt1.clear(),F80=null}async function Y80(){Z80();let A=[];for(let Q of Lc)A.push(Q[Symbol.asyncDispose]()),Lc.delete(Q);await Promise.all(A)}function Z80(){for(let A of E80)A[Symbol.dispose]();E80.clear()}var F80=null,Mt1,E80,Lc,YK;var Lt1=o(()=>{wt1();t20();Yv0();Mt1=new Set,E80=new Set,Lc=new Set;YK=class extends Error{constructor(A){super(A);this.name="ConfigureError"}}});var U80=o(()=>{t20();Fv0();Yv0();Lt1()});var Ot1,y9A,u;var c0=o(()=>{U80();bQ();if(Zv0()===null)Oc({sinks:{console:Mc({formatter:(A)=>{let Q=wc(A);return Object.keys(A.properties).length>0?[...Q,A.properties]:Q}})},loggers:[{category:["logtape","meta"],sinks:["console"],lowestLevel:"warning"},{category:[],sinks:["console"]}]});Ot1=NT.union([NT.literal("error"),NT.literal("warn"),NT.literal("info"),NT.literal("debug")]),y9A=$v0(),u=y9A});import g9A from"os";import X80 from"path";var DH,DL,JH,jT,Qq5,$q5,Bq5,m9A,d9A;var G80=o(()=>{DH=g9A.homedir(),{env:DL}=process,JH=DL.XDG_DATA_HOME||(DH?X80.join(DH,".local","share"):void 0),jT=DL.XDG_CONFIG_HOME||(DH?X80.join(DH,".config"):void 0),Qq5=DL.XDG_STATE_HOME||(DH?X80.join(DH,".local","state"):void 0),$q5=DL.XDG_CACHE_HOME||(DH?X80.join(DH,".cache"):void 0),Bq5=DL.XDG_RUNTIME_DIR||void 0,m9A=(DL.XDG_DATA_DIRS||"/usr/local/share/:/usr/share/").split(":");if(JH)m9A.unshift(JH);d9A=(DL.XDG_CONFIG_DIRS||"/etc/xdg").split(":");if(jT)d9A.unshift(jT)});import{homedir as V80}from"node:os";import ZK from"node:path";var jt1,p9A,Rt1,c9A,RT,l9A,jc,i9A,aB;var sE=o(()=>{G80();jt1=ZK.join(V80(),".local/share"),p9A=process.platform==="win32"||process.platform==="darwin"?jt1:JH??jt1,Rt1=ZK.join(V80(),".config"),c9A=process.platform==="win32"||process.platform==="darwin"?Rt1:jT??Rt1,RT=ZK.join(p9A,"amp"),l9A=ZK.join(c9A,"amp"),jc=ZK.join(l9A,"tools"),i9A=process.platform==="win32"?ZK.join(process.env.LOCALAPPDATA??ZK.join(V80(),"AppData","Local"),"amp"):ZK.join(process.env.XDG_CACHE_HOME??ZK.join(V80(),".cache"),"amp"),aB=i9A});function n9A(A){return A.trim().toLowerCase()}function E9(A){let Q=n9A(A);if(Q.length===0)return!1;if(Q.endsWith("@ampcode.com")||Q==="auth-bypass-user@example.com")return!0;return!1}function U4(A,Q,$=Q+"s"){return A===1?Q:$}var G5=()=>{};function K80(A){Promise.resolve().then(()=>{try{A()}catch(Q){console.error(Q)}})}function _t1(A){let Q=A._cleanup;if(Q===void 0)return;if(A._cleanup=void 0,!Q)return;try{if(typeof Q==="function")Q();else if(Q&&typeof Q.unsubscribe==="function")Q.unsubscribe()}catch($){console.error("cleanupSubscription",$)}}function Vv0(A){A._observer=void 0,A._queue=void 0,A._state="closed"}function o9A(A){let Q=A._queue;if(!Q)return;A._queue=void 0,A._state="ready";for(let $ of Q)if(Tt1(A,$.type,$.value),A._state==="closed")break}function Tt1(A,Q,$){A._state="running";let B=A._observer;try{switch(Q){case"next":if(B&&typeof B.next==="function")B.next($);break;case"error":if(Vv0(A),B&&typeof B.error==="function")B.error($);else throw $;break;case"complete":if(Vv0(A),B&&typeof B.complete==="function")B.complete();break}}catch(D){console.error("notifySubscription",D)}if(A._state==="closed")_t1(A);else if(A._state==="running")A._state="ready"}function Gv0(A,Q,$){if(A._state==="closed")return;if(A._state==="buffering"){A._queue=A._queue||[],A._queue.push({type:Q,value:$});return}if(A._state!=="ready"){A._state="buffering",A._queue=[{type:Q,value:$}],K80(()=>o9A(A));return}Tt1(A,Q,$)}class vt1{_cleanup;_observer;_queue;_state;constructor(A,Q){this._cleanup=void 0,this._observer=A,this._queue=void 0,this._state="initializing";let $=new kt1(this);try{this._cleanup=Q.call(void 0,$)}catch(B){$.error(B)}if(this._state==="initializing")this._state="ready"}get closed(){return this._state==="closed"}unsubscribe(){if(this._state!=="closed")Vv0(this),_t1(this)}}class kt1{_subscription;constructor(A){this._subscription=A}get closed(){return this._subscription._state==="closed"}next(A){Gv0(this._subscription,"next",A)}error(A){Gv0(this._subscription,"error",A)}complete(){Gv0(this._subscription,"complete")}}function Y2(A){if(typeof A==="function")A();else if(A&&typeof A.unsubscribe==="function")A.unsubscribe()}class uT{_baseObserver;_pendingPromises;constructor(A){this._baseObserver=A,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch((A)=>this._baseObserver.error(A))}error(A){this._baseObserver.error(A)}schedule(A){let Q=Promise.all(this._pendingPromises),$=[],B=(J)=>$.push(J),D=Promise.resolve().then(async()=>{await Q,await A(B),this._pendingPromises.delete(D);for(let J of $)this._baseObserver.next(J)}).catch((J)=>{this._pendingPromises.delete(D),this._baseObserver.error(J)});this._pendingPromises.add(D)}}var g0;var PT=o(()=>{if(!Symbol.observable)Symbol.observable=Symbol("observable");g0=class g0{_subscriber;constructor(A){if(!(this instanceof g0))throw TypeError("Observable cannot be called as a function");if(typeof A!=="function")throw TypeError("Observable initializer must be a function");this._subscriber=A}subscribe(A,Q,$){if(typeof A!=="object"||A===null)A={next:A,error:Q,complete:$};return new vt1(A,this._subscriber)}pipe(A,...Q){let $=this;for(let B of[A,...Q])$=B($);return $}[Symbol.observable](){return this}static from(A){let Q=typeof g0==="function"?g0:g0;if(A==null)throw TypeError(A+" is not an object");let $=A[Symbol.observable];if(typeof $==="function"){let D=$.call(A);if(Object(D)!==D)throw TypeError(D+" is not an object");if(D instanceof g0)return D;return new Q((J)=>D.subscribe(J))}let B=A[Symbol.iterator];if(typeof B==="function")return new Q((D)=>{K80(()=>{if(D.closed)return;for(let J of B.call(A))if(D.next(J),D.closed)return;D.complete()})});if(Array.isArray(A))return new Q((D)=>{K80(()=>{if(D.closed)return;for(let J of A)if(D.next(J),D.closed)return;D.complete()})});throw TypeError(A+" is not observable")}static of(...A){return new(typeof g0==="function"?g0:g0)(($)=>{K80(()=>{if($.closed)return;for(let B of A)if($.next(B),$.closed)return;$.complete()})})}static get[Symbol.species](){return g0}}});var d4,o1;var z80=o(()=>{PT();d4=class d4 extends g0{_observers=new Set;constructor(){super((A)=>{return this._observers.add(A),()=>this._observers.delete(A)})}next(A){for(let Q of this._observers)Q.next(A)}error(A){for(let Q of this._observers)Q.error(A)}complete(){for(let A of this._observers)A.complete()}};o1=class o1 extends d4{currentValue;constructor(A){super();this.currentValue=A}next(A){this.currentValue=A,super.next(A)}subscribe(A,Q,$){if(typeof A!=="object"||A===null){let B={};if(A)B.next=A;if(Q)B.error=Q;if($)B.complete=$;A=B}return A.next?.(this.currentValue),super.subscribe(A)}getValue(){return this.currentValue}}});var r9A,Kv0;var St1=o(()=>{PT();z80();r9A=class r9A extends Set{subject=new o1(this);add(A){return super.add(A),this.subject.next(this),this}delete(A){let Q=super.delete(A);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()}};Kv0=class Kv0 extends Map{subject=new o1(this);set(A,Q){return super.set(A,Q),this.subject.next(this),this}delete(A){let Q=super.delete(A);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 W80(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let $=Array.isArray(A),B=Array.isArray(Q);if($!==B)return!1;if($&&B)return A.length===Q.length&&A.every((J,E)=>W80(J,Q[E]));let D=new Set([...Object.keys(A),...Object.keys(Q)]);for(let J of D)if(!W80(A[J],Q[J]))return!1;return!0}var I80;var zv0=o(()=>{I80={now:()=>Date.now(),schedule:(A,Q)=>{let $=setTimeout(A,Q);return()=>clearTimeout($)}}});async function S1(A,Q){return new Promise(($,B)=>{let D,J=()=>{D?.unsubscribe(),B(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",J,{once:!0}),D=A.subscribe({next:(E)=>{D?.unsubscribe(),Q?.removeEventListener("abort",J),$(E)},error:(E)=>{Q?.removeEventListener("abort",J),B(E)},complete:()=>{Q?.removeEventListener("abort",J),B("Observable completed without emitting a value")}})})}async function EH(A,Q){return new Promise(($,B)=>{let D,J=!1,E,F=()=>{E?.unsubscribe(),B(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",F,{once:!0}),E=A.subscribe({next:(Y)=>{D=Y,J=!0},error:(Y)=>{Q?.removeEventListener("abort",F),B(Y)},complete:()=>{if(Q?.removeEventListener("abort",F),J)$(D);else B("Observable completed without emitting a value")}})})}async function yt1(A,Q){return new Promise(($,B)=>{let D=A.subscribe({error:B,complete:()=>$()});Q?.addEventListener("abort",()=>{D.unsubscribe(),B(new DOMException("Aborted","AbortError"))},{once:!0})})}function N2(A){return new g0((Q)=>{A.then(($)=>{Q.next($),Q.complete()}).catch(($)=>{Q.error($)})})}function E6(A){return new g0((Q)=>{let $=!1,B=new AbortController,D=B.signal;return(async()=>{try{D?.throwIfAborted();let E=await A(D);if(D?.throwIfAborted(),!$)Q.next(E),Q.complete()}catch(E){if(!$)if(D.aborted)Q.complete();else Q.error(E)}})(),()=>{$=!0,B.abort()}})}function N1(A){return(Q)=>{return new g0(($)=>{let B=new uT($),D=0,J=Q.subscribe({complete(){B.complete()},error(E){B.error(E)},next(E){B.schedule(async(F)=>{let Y=await A(E,D);D++,F(Y)})}});return()=>Y2(J)})}}function _T(A,Q=I80){return new g0(($)=>{let B=0,D=null,J=()=>{$.next(B++),D=Q.schedule(J,A)};return D=Q.schedule(J,A),()=>{if(D)D()}})}function UK(...A){return new g0((Q)=>{let $=0,B=A.map((D)=>D.subscribe({next:(J)=>Q.next(J),error:(J)=>Q.error(J),complete:()=>{if($++,$===A.length)Q.complete()}}));return()=>{xt1(B)}})}function jA(...A){if(A.length===0)return uc;return new g0((Q)=>{let $=Array(A.length),B=Array(A.length).fill(0),D=Array(A.length).fill(!1),J=0,E=[],F=new uT(Q);for(let Y=0;Y<A.length;Y++){let Z=A[Y];E.push(Z.subscribe({next(U){$[Y]=U,D[Y]=!0;let X=++B[Y];if(D.every(Boolean))F.schedule(async(G)=>{if(B[Y]===X)G([...$])})},error(U){F.error(U)},complete(){if(J++,J===A.length)F.complete()}}))}return()=>{xt1(E)}})}function e6(A){let $=A?.shouldCountRefs??!0,B=s9A++,D=(J,...E)=>{};return(J)=>{let E=new d4,F=null,Y=!1,Z,U=0;return new g0((X)=>{if(U++,Y)D("new subscriber, emitting buffered value",Z),X.next(Z);else D("new subscriber, no buffered value to emit");if(!F)F=J.subscribe({next:(V)=>{Y=!0,Z=V,E.next(V)},error:(V)=>E.error(V),complete:()=>E.complete()});let G=E.subscribe(X);return()=>{if(U--,G.unsubscribe(),$&&U===0){if(F)Y2(F),F=null;Y=!1}}})}}function xt1(A){for(let Q of A)if(Q)Y2(Q)}function XK(A){return(Q)=>{return new g0(($)=>{let B=Q.subscribe({next:(J)=>$.next(J),error:(J)=>$.error(J),complete:()=>$.complete()}),D=A.subscribe({next:()=>{$.complete(),B.unsubscribe(),D.unsubscribe()},error:(J)=>{$.error(J),B.unsubscribe()}});return()=>{B.unsubscribe(),D.unsubscribe()}})}}function FH(A){return(Q)=>{return new g0(($)=>{let B,D=Q.subscribe({next(J){B=J,$.next(J)},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D),A(B)}})}}function T4(A=W80){return(Q)=>{return new g0(($)=>{let B=ft1,D=new uT($),J=Q.subscribe({complete(){D.complete()},error(E){D.error(E)},next(E){D.schedule(async(F)=>{if(B===ft1||!A(B,E))B=E,F(E)})}});return()=>Y2(J)})}}function TT(A){return t9A(typeof A==="function"?{next:A}:A)}function t9A(A){return(Q)=>new g0(($)=>{let B=typeof A==="function"?A():A,D=Q.subscribe({next(J){if(B.next)try{B.next(J)}catch(E){$.error(E);return}$.next(J)},error(J){if(B.error)try{B.error(J)}catch(E){$.error(E);return}$.error(J)},complete(){if(B.complete)try{B.complete()}catch(J){$.error(J);return}$.complete()}});return()=>Y2(D)})}function f$(A){return(Q)=>{return new g0(($)=>{let B=!1,D=Q.subscribe({next:(E)=>{B=!0,clearTimeout(J),$.next(E)},error:(E)=>{clearTimeout(J),$.error(E)},complete:()=>{clearTimeout(J),$.complete()}}),J=setTimeout(()=>{if(!B)D.unsubscribe(),$.error(new H80(`Operation timed out after ${A}ms`))},A);return()=>{clearTimeout(J),D.unsubscribe()}})}}function IA(A){return(Q)=>new g0(($)=>{let B;try{$.next(A),B=Q.subscribe({next(D){$.next(D)},error(D){$.error(D)},complete(){$.complete()}})}catch(D){$.error(D)}return()=>{if(B)Y2(B)}})}function u8(A){return(Q)=>new g0(($)=>{let B=0,D=Q.subscribe({next(J){if(B<A){if($.next(J),B++,B===A)$.complete(),Y2(D)}},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D)}})}function bt1(A){return(Q)=>new g0(($)=>{let B=0,D=Q.subscribe({next(J){if(B>=A)$.next(J);else B++},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D)}})}function y4(A){return(Q)=>{return new g0(($)=>{let B=0,D=null,J=!1,E=()=>{if(J&&!D)$.complete()},F=Q.subscribe({next(Y){if(D)Y2(D),D=null;let Z;try{Z=A(Y,B++)}catch(U){$.error(U);return}D=Z.subscribe({next(U){$.next(U)},error(U){$.error(U)},complete(){D=null,E()}})},error(Y){$.error(Y)},complete(){J=!0,E()}});return()=>{if(Y2(F),D)Y2(D)}})}}function GK(A,Q){let $=Q?.scheduler??I80;return(B)=>new g0((D)=>{let J=null,E=null,F=!1,Y=B.subscribe({next:(Z)=>{if(E=Z,F=!0,J===null)J=$.schedule(()=>{if(F)D.next(E),F=!1;J=null},A)},error:(Z)=>D.error(Z),complete:()=>{if(J!==null)J();if(F)D.next(E);D.complete()}});return()=>{if(Y2(Y),J!==null)J()}})}function Iv0(A,Q){if(!Q.leading||!Q.trailing)throw Error("leading and trailing must be true");let $=Q.scheduler??I80;return(B)=>new g0((D)=>{let J=0,E=null,F=null,Y=!1,Z=B.subscribe({next:(U)=>{let X=$.now();if(F=U,Y=!0,X-J>=A)D.next(U),J=X,Y=!1;else if(E===null)E=$.schedule(()=>{if(Y)D.next(F),J=$.now(),Y=!1;E=null},A-(X-J));if(J===0)D.next(U),J=X,Y=!1},error:(U)=>D.error(U),complete:()=>{if(E!==null)E();if(Y)D.next(F);D.complete()}});return()=>{if(Y2(Z),E!==null)E()}})}function Pc(...A){return new g0((Q)=>{let $=0,B=null;function D(){if($>=A.length){Q.complete();return}B=A[$].subscribe({next:(E)=>Q.next(E),error:(E)=>Q.error(E),complete:()=>{$++,D()}})}return D(),()=>{if(B)Y2(B)}})}function YH(A){return(Q)=>new g0(($)=>{let B=0,D=!1,J=null,E=Q.subscribe({next(F){try{let Y=A(F,B++);if(J)Y2(J);J=Y.subscribe({next(Z){$.next(Z)},error(Z){$.error(Z)},complete(){if(J=null,D&&!J)$.complete()}})}catch(Y){$.error(Y)}},error(F){$.error(F)},complete(){if(D=!0,!J)$.complete()}});return()=>{if(Y2(E),J)Y2(J)}})}function _c({onSubscribe:A,onUnsubscribe:Q}){return($)=>new g0((B)=>{A?.();let D=$.subscribe(B);return()=>{Y2(D),Q?.()}})}function Tc(A){return(Q)=>g0.from(Q).pipe(y4(($)=>E6((B)=>A($,B))))}function y$(A){return(Q)=>new g0(($)=>{let B,D=Q.subscribe({next(J){$.next(J)},error(J){try{B=A(J).subscribe({next(F){$.next(F)},error(F){$.error(F)},complete(){$.complete()}})}catch(E){$.error(E)}},complete(){$.complete()}});return()=>{if(Y2(D),B)Y2(B)}})}function i3(A){return(Q)=>{return new g0(($)=>{let B=Q.subscribe({next(D){if(A(D))$.next(D)},error(D){$.error(D)},complete(){$.complete()}});return()=>Y2(B)})}}function ht1(A,Q){return($)=>{return new g0((B)=>{let D,J=0,E=new uT(B),F=$.subscribe({complete(){E.complete()},error(Y){E.error(Y)},next(Y){E.schedule(async(Z)=>{D=await A(J===0?typeof Q>"u"?Y:Q:D,Y,J++),Z(D)})}});return()=>Y2(F)})}}var uc,Wv0,s9A=0,ft1,H80;var Hv0=o(()=>{PT();zv0();z80();uc=new g0((A)=>{A.complete()}),Wv0=new g0(()=>{});ft1={};H80=class H80 extends Error{constructor(A="Timeout has occurred"){super(A);this.name="TimeoutError"}}});function vT(A,Q){return($)=>{return g0.from($).pipe(y4((B)=>B===XX?g0.of(XX):A(B).pipe(y$((D)=>g0.of(D instanceof Error?D:Error(D))),IA(XX))),e6(Q))}}function qv0(){return(A)=>g0.from(A).pipe(i3((Q)=>Q!==XX))}async function gt1(A,Q){let $=await S1(g0.from(A).pipe(qv0()),Q);if($ instanceof Error)throw $;return $}var XX;var mt1=o(()=>{PT();Hv0();XX=Symbol.for("@@pendingOperation")});var dt1=()=>{};var pt1=()=>{};var u1=o(()=>{St1();PT();mt1();Hv0();dt1();zv0();z80();pt1()});function E7A(){let A=typeof process==="object"?process.env.ProgramData:void 0;return A?`${A}\\ampcode`:"C:\\ProgramData\\ampcode"}function uv0(A){switch(A){case"darwin":return"/Library/Application Support/ampcode";case"android":case"cygwin":case"freebsd":case"netbsd":case"openbsd":case"linux":return"/etc/ampcode";case"win32":return E7A();case"aix":case"haiku":case"sunos":default:return null}}function st1(A){return uv0(A)}function tE(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let $=Array.isArray(A),B=Array.isArray(Q);if($!==B)return!1;if($&&B)return A.length===Q.length&&A.every((J,E)=>tE(J,Q[E]));let D=new Set([...Object.keys(A),...Object.keys(Q)]);for(let J of D)if(!tE(A[J],Q[J]))return!1;return!0}class WJ{#A=!1;#Q=[];async acquire(){return new Promise((A)=>{if(!this.#A)this.#A=!0,A();else this.#Q.push({resolve:A})})}async acquireWithTimeout(A,Q=`Mutex acquire timed out after ${A}ms`){return new Promise(($,B)=>{if(!this.#A){this.#A=!0,$();return}let D=!1,J,E={resolve:()=>{if(D)return;D=!0,clearTimeout(J),$()}};J=setTimeout(()=>{if(D)return;D=!0;let F=this.#Q.indexOf(E);if(F!==-1)this.#Q.splice(F,1);B(Error(Q))},A),this.#Q.push(E)})}release(){if(this.#Q.length>0)this.#Q.shift()?.resolve();else this.#A=!1}}var x$;var yT=o(()=>{x$={BITBUCKET_ENTERPRISE:"bitbucket-enterprise",CUSTOMER_MODEL_PROVIDER_KEYS:"customer-model-provider-keys",ACCEPT_ABUSE_DATA_RETENTION:"accept-abuse-data-retention",HARNESS_SYSTEM_PROMPT:"harness-system-prompt",NAMESPACE_REPOSITORIES_PAGE:"namespace-repositories-page",NAMESPACE_SKILLS_PAGE:"namespace-skills-page",OLD_CODEMIRROR_DIFFS:"old-codemirror-diffs",OPENAI_REGIONAL_NONENT:"openai-regional-nonent",PAYMENT_METHOD_EXEMPT:"payment-method-exempt",PIERRE_DIFFS:"pierre-diffs",RECV_OLD_CLIENT_EMAILS:"recv-old-client-emails",SIGNING_KEYS:"signing-keys",SUDO:"sudo",THREAD_ACTORS_TUI:"thread-actors-tui",THREAD_ACTORS_TRACES:"thread-actors-traces",V2:"v2",SERVER_PLUGINS:"server-plugins",THREAD_TIMING:"thread-timing",THREAD_TRACE_VIEWER:"thread-trace-viewer",USAGE_TOKEN_COUNT:"usage-token-count",WORKSPACE_ROLES:"workspace-roles"}});function dT(A){let Q=A.length;while(--Q>=0)A[Q]=0}function Tv0(A,Q,$,B,D){this.static_tree=A,this.extra_bits=Q,this.extra_base=$,this.elems=B,this.max_length=D,this.has_stree=A&&A.length}function vv0(A,Q){this.dyn_tree=A,this.max_code=0,this.stat_desc=Q}function GX(A,Q,$,B,D){this.good_length=A,this.max_lazy=Q,this.nice_length=$,this.max_chain=B,this.func=D}function qQA(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=k80,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(UQA*2),this.dyn_dtree=new Uint16Array((2*YQA+1)*2),this.bl_tree=new Uint16Array((2*ZQA+1)*2),UH(this.dyn_ltree),UH(this.dyn_dtree),UH(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(XQA+1),this.heap=new Uint16Array(2*nv0+1),UH(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*nv0+1),UH(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function mQA(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function ec(A){this.options=S80.assign({level:nQA,method:oQA,chunkSize:16384,windowBits:15,memLevel:8,strategy:aQA},A||{});let Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new U04,this.strm.avail_out=0;let $=mc.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if($!==T80)throw Error(ZL[$]);if(Q.header)mc.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let B;if(typeof Q.dictionary==="string")B=oc.string2buf(Q.dictionary);else if(X04.call(Q.dictionary)==="[object ArrayBuffer]")B=new Uint8Array(Q.dictionary);else B=Q.dictionary;if($=mc.deflateSetDictionary(this.strm,B),$!==T80)throw Error(ZL[$]);this._dict_set=!0}}function Dk0(A,Q){let $=new ec(Q);if($.push(A,!0),$.err)throw $.msg||ZL[$.err];return $.result}function rQA(A,Q){return Q=Q||{},Q.raw=!0,Dk0(A,Q)}function sQA(A,Q){return Q=Q||{},Q.gzip=!0,Dk0(A,Q)}function N$A(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x$A(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}function Al(A){this.options=S80.assign({chunkSize:65536,windowBits:15,to:""},A||{});let Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!(A&&A.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new U04,this.strm.avail_out=0;let $=zK.inflateInit2(this.strm,Q.windowBits);if($!==rc)throw Error(ZL[$]);if(this.header=new b$A,zK.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=oc.string2buf(Q.dictionary);else if(M04.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if($=zK.inflateSetDictionary(this.strm,Q.dictionary),$!==rc)throw Error(ZL[$])}}}function Jk0(A,Q){let $=new Al(Q);if($.push(A),$.err)throw $.msg||ZL[$.err];return $.result}function p$A(A,Q){return Q=Q||{},Q.raw=!0,Jk0(A,Q)}var H7A=0,pe1=1,q7A=2,N7A=3,C7A=258,ev0=29,sc=256,pc,hT=30,Ak0=19,ce1,EL=15,_v0=16,w7A=7,Qk0=256,le1=16,ie1=17,ne1=18,cv0,P80,M7A,ae1,L7A=512,KK,gc,cc,lc,$k0,_80,oe1,re1,se1,te1=(A)=>{return A<256?cc[A]:cc[256+(A>>>7)]},ic=(A,Q)=>{A.pending_buf[A.pending++]=Q&255,A.pending_buf[A.pending++]=Q>>>8&255},oB=(A,Q,$)=>{if(A.bi_valid>_v0-$)A.bi_buf|=Q<<A.bi_valid&65535,ic(A,A.bi_buf),A.bi_buf=Q>>_v0-A.bi_valid,A.bi_valid+=$-_v0;else A.bi_buf|=Q<<A.bi_valid&65535,A.bi_valid+=$},VX=(A,Q,$)=>{oB(A,$[Q*2],$[Q*2+1])},ee1=(A,Q)=>{let $=0;do $|=A&1,A>>>=1,$<<=1;while(--Q>0);return $>>>1},O7A=(A)=>{if(A.bi_valid===16)ic(A,A.bi_buf),A.bi_buf=0,A.bi_valid=0;else if(A.bi_valid>=8)A.pending_buf[A.pending++]=A.bi_buf&255,A.bi_buf>>=8,A.bi_valid-=8},j7A=(A,Q)=>{let{dyn_tree:$,max_code:B}=Q,D=Q.stat_desc.static_tree,J=Q.stat_desc.has_stree,E=Q.stat_desc.extra_bits,F=Q.stat_desc.extra_base,Y=Q.stat_desc.max_length,Z,U,X,G,V,K,z=0;for(G=0;G<=EL;G++)A.bl_count[G]=0;$[A.heap[A.heap_max]*2+1]=0;for(Z=A.heap_max+1;Z<ce1;Z++){if(U=A.heap[Z],G=$[$[U*2+1]*2+1]+1,G>Y)G=Y,z++;if($[U*2+1]=G,U>B)continue;if(A.bl_count[G]++,V=0,U>=F)V=E[U-F];if(K=$[U*2],A.opt_len+=K*(G+V),J)A.static_len+=K*(D[U*2+1]+V)}if(z===0)return;do{G=Y-1;while(A.bl_count[G]===0)G--;A.bl_count[G]--,A.bl_count[G+1]+=2,A.bl_count[Y]--,z-=2}while(z>0);for(G=Y;G!==0;G--){U=A.bl_count[G];while(U!==0){if(X=A.heap[--Z],X>B)continue;if($[X*2+1]!==G)A.opt_len+=(G-$[X*2+1])*$[X*2],$[X*2+1]=G;U--}}},A04=(A,Q,$)=>{let B=Array(EL+1),D=0,J,E;for(J=1;J<=EL;J++)D=D+$[J-1]<<1,B[J]=D;for(E=0;E<=Q;E++){let F=A[E*2+1];if(F===0)continue;A[E*2]=ee1(B[F]++,F)}},R7A=()=>{let A,Q,$,B,D,J=Array(EL+1);$=0;for(B=0;B<ev0-1;B++){$k0[B]=$;for(A=0;A<1<<cv0[B];A++)lc[$++]=B}lc[$-1]=B,D=0;for(B=0;B<16;B++){_80[B]=D;for(A=0;A<1<<P80[B];A++)cc[D++]=B}D>>=7;for(;B<hT;B++){_80[B]=D<<7;for(A=0;A<1<<P80[B]-7;A++)cc[256+D++]=B}for(Q=0;Q<=EL;Q++)J[Q]=0;A=0;while(A<=143)KK[A*2+1]=8,A++,J[8]++;while(A<=255)KK[A*2+1]=9,A++,J[9]++;while(A<=279)KK[A*2+1]=7,A++,J[7]++;while(A<=287)KK[A*2+1]=8,A++,J[8]++;A04(KK,pc+1,J);for(A=0;A<hT;A++)gc[A*2+1]=5,gc[A*2]=ee1(A,5);oe1=new Tv0(KK,cv0,sc+1,pc,EL),re1=new Tv0(gc,P80,0,hT,EL),se1=new Tv0([],M7A,0,Ak0,w7A)},Q04=(A)=>{let Q;for(Q=0;Q<pc;Q++)A.dyn_ltree[Q*2]=0;for(Q=0;Q<hT;Q++)A.dyn_dtree[Q*2]=0;for(Q=0;Q<Ak0;Q++)A.bl_tree[Q*2]=0;A.dyn_ltree[Qk0*2]=1,A.opt_len=A.static_len=0,A.sym_next=A.matches=0},$04=(A)=>{if(A.bi_valid>8)ic(A,A.bi_buf);else if(A.bi_valid>0)A.pending_buf[A.pending++]=A.bi_buf;A.bi_buf=0,A.bi_valid=0},Je1=(A,Q,$,B)=>{let D=Q*2,J=$*2;return A[D]<A[J]||A[D]===A[J]&&B[Q]<=B[$]},kv0=(A,Q,$)=>{let B=A.heap[$],D=$<<1;while(D<=A.heap_len){if(D<A.heap_len&&Je1(Q,A.heap[D+1],A.heap[D],A.depth))D++;if(Je1(Q,B,A.heap[D],A.depth))break;A.heap[$]=A.heap[D],$=D,D<<=1}A.heap[$]=B},Ee1=(A,Q,$)=>{let B,D,J=0,E,F;if(A.sym_next!==0)do if(B=A.pending_buf[A.sym_buf+J++]&255,B+=(A.pending_buf[A.sym_buf+J++]&255)<<8,D=A.pending_buf[A.sym_buf+J++],B===0)VX(A,D,Q);else{if(E=lc[D],VX(A,E+sc+1,Q),F=cv0[E],F!==0)D-=$k0[E],oB(A,D,F);if(B--,E=te1(B),VX(A,E,$),F=P80[E],F!==0)B-=_80[E],oB(A,B,F)}while(J<A.sym_next);VX(A,Qk0,Q)},lv0=(A,Q)=>{let $=Q.dyn_tree,B=Q.stat_desc.static_tree,D=Q.stat_desc.has_stree,J=Q.stat_desc.elems,E,F,Y=-1,Z;A.heap_len=0,A.heap_max=ce1;for(E=0;E<J;E++)if($[E*2]!==0)A.heap[++A.heap_len]=Y=E,A.depth[E]=0;else $[E*2+1]=0;while(A.heap_len<2)if(Z=A.heap[++A.heap_len]=Y<2?++Y:0,$[Z*2]=1,A.depth[Z]=0,A.opt_len--,D)A.static_len-=B[Z*2+1];Q.max_code=Y;for(E=A.heap_len>>1;E>=1;E--)kv0(A,$,E);Z=J;do E=A.heap[1],A.heap[1]=A.heap[A.heap_len--],kv0(A,$,1),F=A.heap[1],A.heap[--A.heap_max]=E,A.heap[--A.heap_max]=F,$[Z*2]=$[E*2]+$[F*2],A.depth[Z]=(A.depth[E]>=A.depth[F]?A.depth[E]:A.depth[F])+1,$[E*2+1]=$[F*2+1]=Z,A.heap[1]=Z++,kv0(A,$,1);while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],j7A(A,Q),A04($,Y,A.bl_count)},Fe1=(A,Q,$)=>{let B,D=-1,J,E=Q[1],F=0,Y=7,Z=4;if(E===0)Y=138,Z=3;Q[($+1)*2+1]=65535;for(B=0;B<=$;B++){if(J=E,E=Q[(B+1)*2+1],++F<Y&&J===E)continue;else if(F<Z)A.bl_tree[J*2]+=F;else if(J!==0){if(J!==D)A.bl_tree[J*2]++;A.bl_tree[le1*2]++}else if(F<=10)A.bl_tree[ie1*2]++;else A.bl_tree[ne1*2]++;if(F=0,D=J,E===0)Y=138,Z=3;else if(J===E)Y=6,Z=3;else Y=7,Z=4}},Ye1=(A,Q,$)=>{let B,D=-1,J,E=Q[1],F=0,Y=7,Z=4;if(E===0)Y=138,Z=3;for(B=0;B<=$;B++){if(J=E,E=Q[(B+1)*2+1],++F<Y&&J===E)continue;else if(F<Z)do VX(A,J,A.bl_tree);while(--F!==0);else if(J!==0){if(J!==D)VX(A,J,A.bl_tree),F--;VX(A,le1,A.bl_tree),oB(A,F-3,2)}else if(F<=10)VX(A,ie1,A.bl_tree),oB(A,F-3,3);else VX(A,ne1,A.bl_tree),oB(A,F-11,7);if(F=0,D=J,E===0)Y=138,Z=3;else if(J===E)Y=6,Z=3;else Y=7,Z=4}},u7A=(A)=>{let Q;Fe1(A,A.dyn_ltree,A.l_desc.max_code),Fe1(A,A.dyn_dtree,A.d_desc.max_code),lv0(A,A.bl_desc);for(Q=Ak0-1;Q>=3;Q--)if(A.bl_tree[ae1[Q]*2+1]!==0)break;return A.opt_len+=3*(Q+1)+5+5+4,Q},P7A=(A,Q,$,B)=>{let D;oB(A,Q-257,5),oB(A,$-1,5),oB(A,B-4,4);for(D=0;D<B;D++)oB(A,A.bl_tree[ae1[D]*2+1],3);Ye1(A,A.dyn_ltree,Q-1),Ye1(A,A.dyn_dtree,$-1)},_7A=(A)=>{let Q=4093624447,$;for($=0;$<=31;$++,Q>>>=1)if(Q&1&&A.dyn_ltree[$*2]!==0)return 0;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return 1;for($=32;$<sc;$++)if(A.dyn_ltree[$*2]!==0)return 1;return 0},Ze1=!1,T7A=(A)=>{if(!Ze1)R7A(),Ze1=!0;A.l_desc=new vv0(A.dyn_ltree,oe1),A.d_desc=new vv0(A.dyn_dtree,re1),A.bl_desc=new vv0(A.bl_tree,se1),A.bi_buf=0,A.bi_valid=0,Q04(A)},B04=(A,Q,$,B)=>{if(oB(A,(H7A<<1)+(B?1:0),3),$04(A),ic(A,$),ic(A,~$),$)A.pending_buf.set(A.window.subarray(Q,Q+$),A.pending);A.pending+=$},v7A=(A)=>{oB(A,pe1<<1,3),VX(A,Qk0,KK),O7A(A)},k7A=(A,Q,$,B)=>{let D,J,E=0;if(A.level>0){if(A.strm.data_type===2)A.strm.data_type=_7A(A);if(lv0(A,A.l_desc),lv0(A,A.d_desc),E=u7A(A),D=A.opt_len+3+7>>>3,J=A.static_len+3+7>>>3,J<=D)D=J}else D=J=$+5;if($+4<=D&&Q!==-1)B04(A,Q,$,B);else if(A.strategy===4||J===D)oB(A,(pe1<<1)+(B?1:0),3),Ee1(A,KK,gc);else oB(A,(q7A<<1)+(B?1:0),3),P7A(A,A.l_desc.max_code+1,A.d_desc.max_code+1,E+1),Ee1(A,A.dyn_ltree,A.dyn_dtree);if(Q04(A),B)$04(A)},S7A=(A,Q,$)=>{if(A.pending_buf[A.sym_buf+A.sym_next++]=Q,A.pending_buf[A.sym_buf+A.sym_next++]=Q>>8,A.pending_buf[A.sym_buf+A.sym_next++]=$,Q===0)A.dyn_ltree[$*2]++;else A.matches++,Q--,A.dyn_ltree[(lc[$]+sc+1)*2]++,A.dyn_dtree[te1(Q)*2]++;return A.sym_next===A.sym_end},f7A,y7A,x7A,b7A,h7A,g7A,m7A=(A,Q,$,B)=>{let D=A&65535|0,J=A>>>16&65535|0,E=0;while($!==0){E=$>2000?2000:$,$-=E;do D=D+Q[B++]|0,J=J+D|0;while(--E);D%=65521,J%=65521}return D|J<<16|0},nc,d7A=()=>{let A,Q=[];for(var $=0;$<256;$++){A=$;for(var B=0;B<8;B++)A=A&1?3988292384^A>>>1:A>>>1;Q[$]=A}return Q},p7A,c7A=(A,Q,$,B)=>{let D=p7A,J=B+$;A^=-1;for(let E=B;E<J;E++)A=A>>>8^D[(A^Q[E])&255];return A^-1},K7,ZL,GL,l7A,iv0,i7A,GH,n7A,VH,a7A,o7A,eE,Ue1,o7,Xe1,KX,r7A,Sv0,s7A,t7A,L80,e7A,AQA,QQA,$QA,k80,BQA=9,DQA=15,JQA=8,EQA=29,FQA=256,nv0,YQA=30,ZQA=19,UQA,XQA=15,J3=3,XH=258,zX,GQA=32,gT=42,Bk0=57,av0=69,ov0=73,rv0=91,sv0=103,FL=113,bc=666,b$=1,pT=2,UL=3,cT=4,VQA=3,YL=(A,Q)=>{return A.msg=ZL[Q],Q},Ge1=(A)=>{return A*2-(A>4?9:0)},UH=(A)=>{let Q=A.length;while(--Q>=0)A[Q]=0},KQA=(A)=>{let Q,$,B,D=A.w_size;Q=A.hash_size,B=Q;do $=A.head[--B],A.head[B]=$>=D?$-D:0;while(--Q);Q=D,B=Q;do $=A.prev[--B],A.prev[B]=$>=D?$-D:0;while(--Q)},zQA=(A,Q,$)=>(Q<<A.hash_shift^$)&A.hash_mask,KH,IJ=(A)=>{let Q=A.state,$=Q.pending;if($>A.avail_out)$=A.avail_out;if($===0)return;if(A.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+$),A.next_out),A.next_out+=$,Q.pending_out+=$,A.total_out+=$,A.avail_out-=$,Q.pending-=$,Q.pending===0)Q.pending_out=0},HJ=(A,Q)=>{i7A(A,A.block_start>=0?A.block_start:-1,A.strstart-A.block_start,Q),A.block_start=A.strstart,IJ(A.strm)},n3=(A,Q)=>{A.pending_buf[A.pending++]=Q},xc=(A,Q)=>{A.pending_buf[A.pending++]=Q>>>8&255,A.pending_buf[A.pending++]=Q&255},tv0=(A,Q,$,B)=>{let D=A.avail_in;if(D>B)D=B;if(D===0)return 0;if(A.avail_in-=D,Q.set(A.input.subarray(A.next_in,A.next_in+D),$),A.state.wrap===1)A.adler=nc(A.adler,Q,D,$);else if(A.state.wrap===2)A.adler=K7(A.adler,Q,D,$);return A.next_in+=D,A.total_in+=D,D},D04=(A,Q)=>{let{max_chain_length:$,strstart:B}=A,D,J,E=A.prev_length,F=A.nice_match,Y=A.strstart>A.w_size-zX?A.strstart-(A.w_size-zX):0,Z=A.window,U=A.w_mask,X=A.prev,G=A.strstart+XH,V=Z[B+E-1],K=Z[B+E];if(A.prev_length>=A.good_match)$>>=2;if(F>A.lookahead)F=A.lookahead;do{if(D=Q,Z[D+E]!==K||Z[D+E-1]!==V||Z[D]!==Z[B]||Z[++D]!==Z[B+1])continue;B+=2,D++;do;while(Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&B<G);if(J=XH-(G-B),B=G-XH,J>E){if(A.match_start=Q,E=J,J>=F)break;V=Z[B+E-1],K=Z[B+E]}}while((Q=X[Q&U])>Y&&--$!==0);if(E<=A.lookahead)return E;return A.lookahead},mT=(A)=>{let Q=A.w_size,$,B,D;do{if(B=A.window_size-A.lookahead-A.strstart,A.strstart>=Q+(Q-zX)){if(A.window.set(A.window.subarray(Q,Q+Q-B),0),A.match_start-=Q,A.strstart-=Q,A.block_start-=Q,A.insert>A.strstart)A.insert=A.strstart;KQA(A),B+=Q}if(A.strm.avail_in===0)break;if($=tv0(A.strm,A.window,A.strstart+A.lookahead,B),A.lookahead+=$,A.lookahead+A.insert>=J3){D=A.strstart-A.insert,A.ins_h=A.window[D],A.ins_h=KH(A,A.ins_h,A.window[D+1]);while(A.insert)if(A.ins_h=KH(A,A.ins_h,A.window[D+J3-1]),A.prev[D&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=D,D++,A.insert--,A.lookahead+A.insert<J3)break}}while(A.lookahead<zX&&A.strm.avail_in!==0)},J04=(A,Q)=>{let $=A.pending_buf_size-5>A.w_size?A.w_size:A.pending_buf_size-5,B,D,J,E=0,F=A.strm.avail_in;do{if(B=65535,J=A.bi_valid+42>>3,A.strm.avail_out<J)break;if(J=A.strm.avail_out-J,D=A.strstart-A.block_start,B>D+A.strm.avail_in)B=D+A.strm.avail_in;if(B>J)B=J;if(B<$&&(B===0&&Q!==eE||Q===VH||B!==D+A.strm.avail_in))break;if(E=Q===eE&&B===D+A.strm.avail_in?1:0,iv0(A,0,0,E),A.pending_buf[A.pending-4]=B,A.pending_buf[A.pending-3]=B>>8,A.pending_buf[A.pending-2]=~B,A.pending_buf[A.pending-1]=~B>>8,IJ(A.strm),D){if(D>B)D=B;A.strm.output.set(A.window.subarray(A.block_start,A.block_start+D),A.strm.next_out),A.strm.next_out+=D,A.strm.avail_out-=D,A.strm.total_out+=D,A.block_start+=D,B-=D}if(B)tv0(A.strm,A.strm.output,A.strm.next_out,B),A.strm.next_out+=B,A.strm.avail_out-=B,A.strm.total_out+=B}while(E===0);if(F-=A.strm.avail_in,F){if(F>=A.w_size)A.matches=2,A.window.set(A.strm.input.subarray(A.strm.next_in-A.w_size,A.strm.next_in),0),A.strstart=A.w_size,A.insert=A.strstart;else{if(A.window_size-A.strstart<=F){if(A.strstart-=A.w_size,A.window.set(A.window.subarray(A.w_size,A.w_size+A.strstart),0),A.matches<2)A.matches++;if(A.insert>A.strstart)A.insert=A.strstart}A.window.set(A.strm.input.subarray(A.strm.next_in-F,A.strm.next_in),A.strstart),A.strstart+=F,A.insert+=F>A.w_size-A.insert?A.w_size-A.insert:F}A.block_start=A.strstart}if(A.high_water<A.strstart)A.high_water=A.strstart;if(E)return cT;if(Q!==VH&&Q!==eE&&A.strm.avail_in===0&&A.strstart===A.block_start)return pT;if(J=A.window_size-A.strstart,A.strm.avail_in>J&&A.block_start>=A.w_size){if(A.block_start-=A.w_size,A.strstart-=A.w_size,A.window.set(A.window.subarray(A.w_size,A.w_size+A.strstart),0),A.matches<2)A.matches++;if(J+=A.w_size,A.insert>A.strstart)A.insert=A.strstart}if(J>A.strm.avail_in)J=A.strm.avail_in;if(J)tv0(A.strm,A.window,A.strstart,J),A.strstart+=J,A.insert+=J>A.w_size-A.insert?A.w_size-A.insert:J;if(A.high_water<A.strstart)A.high_water=A.strstart;if(J=A.bi_valid+42>>3,J=A.pending_buf_size-J>65535?65535:A.pending_buf_size-J,$=J>A.w_size?A.w_size:J,D=A.strstart-A.block_start,D>=$||(D||Q===eE)&&Q!==VH&&A.strm.avail_in===0&&D<=J)B=D>J?J:D,E=Q===eE&&A.strm.avail_in===0&&B===D?1:0,iv0(A,A.block_start,B,E),A.block_start+=B,IJ(A.strm);return E?UL:b$},fv0=(A,Q)=>{let $,B;for(;;){if(A.lookahead<zX){if(mT(A),A.lookahead<zX&&Q===VH)return b$;if(A.lookahead===0)break}if($=0,A.lookahead>=J3)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if($!==0&&A.strstart-$<=A.w_size-zX)A.match_length=D04(A,$);if(A.match_length>=J3)if(B=GH(A,A.strstart-A.match_start,A.match_length-J3),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=J3){A.match_length--;do A.strstart++,A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;while(--A.match_length!==0);A.strstart++}else A.strstart+=A.match_length,A.match_length=0,A.ins_h=A.window[A.strstart],A.ins_h=KH(A,A.ins_h,A.window[A.strstart+1]);else B=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if(B){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=A.strstart<J3-1?A.strstart:J3-1,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},xT=(A,Q)=>{let $,B,D;for(;;){if(A.lookahead<zX){if(mT(A),A.lookahead<zX&&Q===VH)return b$;if(A.lookahead===0)break}if($=0,A.lookahead>=J3)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if(A.prev_length=A.match_length,A.prev_match=A.match_start,A.match_length=J3-1,$!==0&&A.prev_length<A.max_lazy_match&&A.strstart-$<=A.w_size-zX){if(A.match_length=D04(A,$),A.match_length<=5&&(A.strategy===t7A||A.match_length===J3&&A.strstart-A.match_start>4096))A.match_length=J3-1}if(A.prev_length>=J3&&A.match_length<=A.prev_length){D=A.strstart+A.lookahead-J3,B=GH(A,A.strstart-1-A.prev_match,A.prev_length-J3),A.lookahead-=A.prev_length-1,A.prev_length-=2;do if(++A.strstart<=D)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;while(--A.prev_length!==0);if(A.match_available=0,A.match_length=J3-1,A.strstart++,B){if(HJ(A,!1),A.strm.avail_out===0)return b$}}else if(A.match_available){if(B=GH(A,0,A.window[A.strstart-1]),B)HJ(A,!1);if(A.strstart++,A.lookahead--,A.strm.avail_out===0)return b$}else A.match_available=1,A.strstart++,A.lookahead--}if(A.match_available)B=GH(A,0,A.window[A.strstart-1]),A.match_available=0;if(A.insert=A.strstart<J3-1?A.strstart:J3-1,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},WQA=(A,Q)=>{let $,B,D,J,E=A.window;for(;;){if(A.lookahead<=XH){if(mT(A),A.lookahead<=XH&&Q===VH)return b$;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=J3&&A.strstart>0){if(D=A.strstart-1,B=E[D],B===E[++D]&&B===E[++D]&&B===E[++D]){J=A.strstart+XH;do;while(B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&D<J);if(A.match_length=XH-(J-D),A.match_length>A.lookahead)A.match_length=A.lookahead}}if(A.match_length>=J3)$=GH(A,1,A.match_length-J3),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0;else $=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if($){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=0,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},IQA=(A,Q)=>{let $;for(;;){if(A.lookahead===0){if(mT(A),A.lookahead===0){if(Q===VH)return b$;break}}if(A.match_length=0,$=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,$){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=0,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},hc,HQA=(A)=>{A.window_size=2*A.w_size,UH(A.head),A.max_lazy_match=hc[A.level].max_lazy,A.good_match=hc[A.level].good_length,A.nice_match=hc[A.level].nice_length,A.max_chain_length=hc[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=J3-1,A.match_available=0,A.ins_h=0},tc=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.status!==gT&&Q.status!==Bk0&&Q.status!==av0&&Q.status!==ov0&&Q.status!==rv0&&Q.status!==sv0&&Q.status!==FL&&Q.status!==bc)return 1;return 0},E04=(A)=>{if(tc(A))return YL(A,KX);A.total_in=A.total_out=0,A.data_type=$QA;let Q=A.state;if(Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap===2?Bk0:Q.wrap?gT:FL,A.adler=Q.wrap===2?0:1,Q.last_flush=-2,l7A(Q),o7},F04=(A)=>{let Q=E04(A);if(Q===o7)HQA(A.state);return Q},NQA=(A,Q)=>{if(tc(A)||A.state.wrap!==2)return KX;return A.state.gzhead=Q,o7},Y04=(A,Q,$,B,D,J)=>{if(!A)return KX;let E=1;if(Q===s7A)Q=6;if(B<0)E=0,B=-B;else if(B>15)E=2,B-=16;if(D<1||D>BQA||$!==k80||B<8||B>15||Q<0||Q>9||J<0||J>AQA||B===8&&E!==1)return YL(A,KX);if(B===8)B=9;let F=new qQA;return A.state=F,F.strm=A,F.status=gT,F.wrap=E,F.gzhead=null,F.w_bits=B,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=D+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+J3-1)/J3),F.window=new Uint8Array(F.w_size*2),F.head=new Uint16Array(F.hash_size),F.prev=new Uint16Array(F.w_size),F.lit_bufsize=1<<D+6,F.pending_buf_size=F.lit_bufsize*4,F.pending_buf=new Uint8Array(F.pending_buf_size),F.sym_buf=F.lit_bufsize,F.sym_end=(F.lit_bufsize-1)*3,F.level=Q,F.strategy=J,F.method=$,F04(A)},CQA=(A,Q)=>{return Y04(A,Q,k80,DQA,JQA,QQA)},wQA=(A,Q)=>{if(tc(A)||Q>Ue1||Q<0)return A?YL(A,KX):KX;let $=A.state;if(!A.output||A.avail_in!==0&&!A.input||$.status===bc&&Q!==eE)return YL(A,A.avail_out===0?Sv0:KX);let B=$.last_flush;if($.last_flush=Q,$.pending!==0){if(IJ(A),A.avail_out===0)return $.last_flush=-1,o7}else if(A.avail_in===0&&Ge1(Q)<=Ge1(B)&&Q!==eE)return YL(A,Sv0);if($.status===bc&&A.avail_in!==0)return YL(A,Sv0);if($.status===gT&&$.wrap===0)$.status=FL;if($.status===gT){let D=k80+($.w_bits-8<<4)<<8,J=-1;if($.strategy>=L80||$.level<2)J=0;else if($.level<6)J=1;else if($.level===6)J=2;else J=3;if(D|=J<<6,$.strstart!==0)D|=GQA;if(D+=31-D%31,xc($,D),$.strstart!==0)xc($,A.adler>>>16),xc($,A.adler&65535);if(A.adler=1,$.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}if($.status===Bk0)if(A.adler=0,n3($,31),n3($,139),n3($,8),!$.gzhead){if(n3($,0),n3($,0),n3($,0),n3($,0),n3($,0),n3($,$.level===9?2:$.strategy>=L80||$.level<2?4:0),n3($,VQA),$.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}else{if(n3($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+(!$.gzhead.extra?0:4)+(!$.gzhead.name?0:8)+(!$.gzhead.comment?0:16)),n3($,$.gzhead.time&255),n3($,$.gzhead.time>>8&255),n3($,$.gzhead.time>>16&255),n3($,$.gzhead.time>>24&255),n3($,$.level===9?2:$.strategy>=L80||$.level<2?4:0),n3($,$.gzhead.os&255),$.gzhead.extra&&$.gzhead.extra.length)n3($,$.gzhead.extra.length&255),n3($,$.gzhead.extra.length>>8&255);if($.gzhead.hcrc)A.adler=K7(A.adler,$.pending_buf,$.pending,0);$.gzindex=0,$.status=av0}if($.status===av0){if($.gzhead.extra){let D=$.pending,J=($.gzhead.extra.length&65535)-$.gzindex;while($.pending+J>$.pending_buf_size){let F=$.pending_buf_size-$.pending;if($.pending_buf.set($.gzhead.extra.subarray($.gzindex,$.gzindex+F),$.pending),$.pending=$.pending_buf_size,$.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if($.gzindex+=F,IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0,J-=F}let E=new Uint8Array($.gzhead.extra);if($.pending_buf.set(E.subarray($.gzindex,$.gzindex+J),$.pending),$.pending+=J,$.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);$.gzindex=0}$.status=ov0}if($.status===ov0){if($.gzhead.name){let D=$.pending,J;do{if($.pending===$.pending_buf_size){if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if(IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0}if($.gzindex<$.gzhead.name.length)J=$.gzhead.name.charCodeAt($.gzindex++)&255;else J=0;n3($,J)}while(J!==0);if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);$.gzindex=0}$.status=rv0}if($.status===rv0){if($.gzhead.comment){let D=$.pending,J;do{if($.pending===$.pending_buf_size){if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if(IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0}if($.gzindex<$.gzhead.comment.length)J=$.gzhead.comment.charCodeAt($.gzindex++)&255;else J=0;n3($,J)}while(J!==0);if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D)}$.status=sv0}if($.status===sv0){if($.gzhead.hcrc){if($.pending+2>$.pending_buf_size){if(IJ(A),$.pending!==0)return $.last_flush=-1,o7}n3($,A.adler&255),n3($,A.adler>>8&255),A.adler=0}if($.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}if(A.avail_in!==0||$.lookahead!==0||Q!==VH&&$.status!==bc){let D=$.level===0?J04($,Q):$.strategy===L80?IQA($,Q):$.strategy===e7A?WQA($,Q):hc[$.level].func($,Q);if(D===UL||D===cT)$.status=bc;if(D===b$||D===UL){if(A.avail_out===0)$.last_flush=-1;return o7}if(D===pT){if(Q===a7A)n7A($);else if(Q!==Ue1){if(iv0($,0,0,!1),Q===o7A){if(UH($.head),$.lookahead===0)$.strstart=0,$.block_start=0,$.insert=0}}if(IJ(A),A.avail_out===0)return $.last_flush=-1,o7}}if(Q!==eE)return o7;if($.wrap<=0)return Xe1;if($.wrap===2)n3($,A.adler&255),n3($,A.adler>>8&255),n3($,A.adler>>16&255),n3($,A.adler>>24&255),n3($,A.total_in&255),n3($,A.total_in>>8&255),n3($,A.total_in>>16&255),n3($,A.total_in>>24&255);else xc($,A.adler>>>16),xc($,A.adler&65535);if(IJ(A),$.wrap>0)$.wrap=-$.wrap;return $.pending!==0?o7:Xe1},MQA=(A)=>{if(tc(A))return KX;let Q=A.state.status;return A.state=null,Q===FL?YL(A,r7A):o7},LQA=(A,Q)=>{let $=Q.length;if(tc(A))return KX;let B=A.state,D=B.wrap;if(D===2||D===1&&B.status!==gT||B.lookahead)return KX;if(D===1)A.adler=nc(A.adler,Q,$,0);if(B.wrap=0,$>=B.w_size){if(D===0)UH(B.head),B.strstart=0,B.block_start=0,B.insert=0;let Y=new Uint8Array(B.w_size);Y.set(Q.subarray($-B.w_size,$),0),Q=Y,$=B.w_size}let{avail_in:J,next_in:E,input:F}=A;A.avail_in=$,A.next_in=0,A.input=Q,mT(B);while(B.lookahead>=J3){let Y=B.strstart,Z=B.lookahead-(J3-1);do B.ins_h=KH(B,B.ins_h,B.window[Y+J3-1]),B.prev[Y&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=Y,Y++;while(--Z);B.strstart=Y,B.lookahead=J3-1,mT(B)}return B.strstart+=B.lookahead,B.block_start=B.strstart,B.insert=B.lookahead,B.lookahead=0,B.match_length=B.prev_length=J3-1,B.match_available=0,A.next_in=E,A.input=F,A.avail_in=J,B.wrap=D,o7},OQA,jQA,RQA,uQA,PQA,_QA,TQA,vQA,kQA="pako deflate (from Nodeca project)",mc,SQA=(A,Q)=>{return Object.prototype.hasOwnProperty.call(A,Q)},fQA=function(A){let Q=Array.prototype.slice.call(arguments,1);while(Q.length){let $=Q.shift();if(!$)continue;if(typeof $!=="object")throw TypeError($+"must be non-object");for(let B in $)if(SQA($,B))A[B]=$[B]}return A},yQA=(A)=>{let Q=0;for(let B=0,D=A.length;B<D;B++)Q+=A[B].length;let $=new Uint8Array(Q);for(let B=0,D=0,J=A.length;B<J;B++){let E=A[B];$.set(E,D),D+=E.length}return $},S80,Z04=!0,ac,xQA=(A)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(A);let Q,$,B,D,J,E=A.length,F=0;for(D=0;D<E;D++){if($=A.charCodeAt(D),($&64512)===55296&&D+1<E){if(B=A.charCodeAt(D+1),(B&64512)===56320)$=65536+($-55296<<10)+(B-56320),D++}F+=$<128?1:$<2048?2:$<65536?3:4}Q=new Uint8Array(F);for(J=0,D=0;J<F;D++){if($=A.charCodeAt(D),($&64512)===55296&&D+1<E){if(B=A.charCodeAt(D+1),(B&64512)===56320)$=65536+($-55296<<10)+(B-56320),D++}if($<128)Q[J++]=$;else if($<2048)Q[J++]=192|$>>>6,Q[J++]=128|$&63;else if($<65536)Q[J++]=224|$>>>12,Q[J++]=128|$>>>6&63,Q[J++]=128|$&63;else Q[J++]=240|$>>>18,Q[J++]=128|$>>>12&63,Q[J++]=128|$>>>6&63,Q[J++]=128|$&63}return Q},bQA=(A,Q)=>{if(Q<65534){if(A.subarray&&Z04)return String.fromCharCode.apply(null,A.length===Q?A:A.subarray(0,Q))}let $="";for(let B=0;B<Q;B++)$+=String.fromCharCode(A[B]);return $},hQA=(A,Q)=>{let $=Q||A.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(A.subarray(0,Q));let B,D,J=Array($*2);for(D=0,B=0;B<$;){let E=A[B++];if(E<128){J[D++]=E;continue}let F=ac[E];if(F>4){J[D++]=65533,B+=F-1;continue}E&=F===2?31:F===3?15:7;while(F>1&&B<$)E=E<<6|A[B++]&63,F--;if(F>1){J[D++]=65533;continue}if(E<65536)J[D++]=E;else E-=65536,J[D++]=55296|E>>10&1023,J[D++]=56320|E&1023}return bQA(J,D)},gQA=(A,Q)=>{if(Q=Q||A.length,Q>A.length)Q=A.length;let $=Q-1;while($>=0&&(A[$]&192)===128)$--;if($<0)return Q;if($===0)return Q;return $+ac[A[$]]>Q?$:Q},oc,U04,X04,dQA,pQA,cQA,lQA,T80,iQA,nQA,aQA,oQA,tQA,eQA,A$A,Q$A,$$A,B$A,O80=16209,D$A=16191,J$A=function(Q,$){let B,D,J,E,F,Y,Z,U,X,G,V,K,z,W,I,H,q,N,C,M,O,R,k,_,f=Q.state;B=Q.next_in,k=Q.input,D=B+(Q.avail_in-5),J=Q.next_out,_=Q.output,E=J-($-Q.avail_out),F=J+(Q.avail_out-257),Y=f.dmax,Z=f.wsize,U=f.whave,X=f.wnext,G=f.window,V=f.hold,K=f.bits,z=f.lencode,W=f.distcode,I=(1<<f.lenbits)-1,H=(1<<f.distbits)-1;A:do{if(K<15)V+=k[B++]<<K,K+=8,V+=k[B++]<<K,K+=8;q=z[V&I];Q:for(;;){if(N=q>>>24,V>>>=N,K-=N,N=q>>>16&255,N===0)_[J++]=q&65535;else if(N&16){if(C=q&65535,N&=15,N){if(K<N)V+=k[B++]<<K,K+=8;C+=V&(1<<N)-1,V>>>=N,K-=N}if(K<15)V+=k[B++]<<K,K+=8,V+=k[B++]<<K,K+=8;q=W[V&H];$:for(;;){if(N=q>>>24,V>>>=N,K-=N,N=q>>>16&255,N&16){if(M=q&65535,N&=15,K<N){if(V+=k[B++]<<K,K+=8,K<N)V+=k[B++]<<K,K+=8}if(M+=V&(1<<N)-1,M>Y){Q.msg="invalid distance too far back",f.mode=O80;break A}if(V>>>=N,K-=N,N=J-E,M>N){if(N=M-N,N>U){if(f.sane){Q.msg="invalid distance too far back",f.mode=O80;break A}}if(O=0,R=G,X===0){if(O+=Z-N,N<C){C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}}else if(X<N){if(O+=Z+X-N,N-=X,N<C){C-=N;do _[J++]=G[O++];while(--N);if(O=0,X<C){N=X,C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}}}else if(O+=X-N,N<C){C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}while(C>2)_[J++]=R[O++],_[J++]=R[O++],_[J++]=R[O++],C-=3;if(C){if(_[J++]=R[O++],C>1)_[J++]=R[O++]}}else{O=J-M;do _[J++]=_[O++],_[J++]=_[O++],_[J++]=_[O++],C-=3;while(C>2);if(C){if(_[J++]=_[O++],C>1)_[J++]=_[O++]}}}else if((N&64)===0){q=W[(q&65535)+(V&(1<<N)-1)];continue $}else{Q.msg="invalid distance code",f.mode=O80;break A}break}}else if((N&64)===0){q=z[(q&65535)+(V&(1<<N)-1)];continue Q}else if(N&32){f.mode=D$A;break A}else{Q.msg="invalid literal/length code",f.mode=O80;break A}break}}while(B<D&&J<F);C=K>>3,B-=C,K-=C<<3,V&=(1<<K)-1,Q.next_in=B,Q.next_out=J,Q.avail_in=B<D?5+(D-B):5-(B-D),Q.avail_out=J<F?257+(F-J):257-(J-F),f.hold=V,f.bits=K;return},bT=15,Ve1=852,Ke1=592,ze1=0,yv0=1,We1=2,E$A,F$A,Y$A,Z$A,U$A=(A,Q,$,B,D,J,E,F)=>{let Y=F.bits,Z=0,U=0,X=0,G=0,V=0,K=0,z=0,W=0,I=0,H=0,q,N,C,M,O,R=null,k,_=new Uint16Array(bT+1),f=new Uint16Array(bT+1),g=null,b,v,x;for(Z=0;Z<=bT;Z++)_[Z]=0;for(U=0;U<B;U++)_[Q[$+U]]++;V=Y;for(G=bT;G>=1;G--)if(_[G]!==0)break;if(V>G)V=G;if(G===0)return D[J++]=20971520,D[J++]=20971520,F.bits=1,0;for(X=1;X<G;X++)if(_[X]!==0)break;if(V<X)V=X;W=1;for(Z=1;Z<=bT;Z++)if(W<<=1,W-=_[Z],W<0)return-1;if(W>0&&(A===ze1||G!==1))return-1;f[1]=0;for(Z=1;Z<bT;Z++)f[Z+1]=f[Z]+_[Z];for(U=0;U<B;U++)if(Q[$+U]!==0)E[f[Q[$+U]]++]=U;if(A===ze1)R=g=E,k=20;else if(A===yv0)R=E$A,g=F$A,k=257;else R=Y$A,g=Z$A,k=0;if(H=0,U=0,Z=X,O=J,K=V,z=0,C=-1,I=1<<V,M=I-1,A===yv0&&I>Ve1||A===We1&&I>Ke1)return 1;for(;;){if(b=Z-z,E[U]+1<k)v=0,x=E[U];else if(E[U]>=k)v=g[E[U]-k],x=R[E[U]-k];else v=96,x=0;q=1<<Z-z,N=1<<K,X=N;do N-=q,D[O+(H>>z)+N]=b<<24|v<<16|x|0;while(N!==0);q=1<<Z-1;while(H&q)q>>=1;if(q!==0)H&=q-1,H+=q;else H=0;if(U++,--_[Z]===0){if(Z===G)break;Z=Q[$+E[U]]}if(Z>V&&(H&M)!==C){if(z===0)z=V;O+=X,K=Z-z,W=1<<K;while(K+z<G){if(W-=_[K+z],W<=0)break;K++,W<<=1}if(I+=1<<K,A===yv0&&I>Ve1||A===We1&&I>Ke1)return 1;C=H&M,D[C]=V<<24|K<<16|O-J|0}}if(H!==0)D[O+H]=Z-z<<24|4194304|0;return F.bits=V,0},dc,X$A=0,G04=1,V04=2,Ie1,G$A,j80,XL,V$A,K$A,AF,K04,z04,z$A,He1,f80=16180,qe1=16181,Ne1=16182,Ce1=16183,we1=16184,Me1=16185,Le1=16186,Oe1=16187,je1=16188,Re1=16189,v80=16190,VK=16191,xv0=16192,ue1=16193,bv0=16194,Pe1=16195,_e1=16196,Te1=16197,ve1=16198,R80=16199,u80=16200,ke1=16201,Se1=16202,fe1=16203,ye1=16204,xe1=16205,hv0=16206,be1=16207,he1=16208,C2=16209,W04=16210,I04=16211,W$A=852,I$A=592,H$A=15,q$A,ge1=(A)=>{return(A>>>24&255)+(A>>>8&65280)+((A&65280)<<8)+((A&255)<<24)},VL=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.mode<f80||Q.mode>I04)return 1;return 0},H04=(A)=>{if(VL(A))return AF;let Q=A.state;if(A.total_in=A.total_out=Q.total=0,A.msg="",Q.wrap)A.adler=Q.wrap&1;return Q.mode=f80,Q.last=0,Q.havedict=0,Q.flags=-1,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Int32Array(W$A),Q.distcode=Q.distdyn=new Int32Array(I$A),Q.sane=1,Q.back=-1,XL},q04=(A)=>{if(VL(A))return AF;let Q=A.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,H04(A)},N04=(A,Q)=>{let $;if(VL(A))return AF;let B=A.state;if(Q<0)$=0,Q=-Q;else if($=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return AF;if(B.window!==null&&B.wbits!==Q)B.window=null;return B.wrap=$,B.wbits=Q,q04(A)},C04=(A,Q)=>{if(!A)return AF;let $=new N$A;A.state=$,$.strm=A,$.window=null,$.mode=f80;let B=N04(A,Q);if(B!==XL)A.state=null;return B},C$A=(A)=>{return C04(A,q$A)},me1=!0,gv0,mv0,w$A=(A)=>{if(me1){gv0=new Int32Array(512),mv0=new Int32Array(32);let Q=0;while(Q<144)A.lens[Q++]=8;while(Q<256)A.lens[Q++]=9;while(Q<280)A.lens[Q++]=7;while(Q<288)A.lens[Q++]=8;dc(G04,A.lens,0,288,gv0,0,A.work,{bits:9}),Q=0;while(Q<32)A.lens[Q++]=5;dc(V04,A.lens,0,32,mv0,0,A.work,{bits:5}),me1=!1}A.lencode=gv0,A.lenbits=9,A.distcode=mv0,A.distbits=5},w04=(A,Q,$,B)=>{let D,J=A.state;if(J.window===null)J.wsize=1<<J.wbits,J.wnext=0,J.whave=0,J.window=new Uint8Array(J.wsize);if(B>=J.wsize)J.window.set(Q.subarray($-J.wsize,$),0),J.wnext=0,J.whave=J.wsize;else{if(D=J.wsize-J.wnext,D>B)D=B;if(J.window.set(Q.subarray($-B,$-B+D),J.wnext),B-=D,B)J.window.set(Q.subarray($-B,$),0),J.wnext=B,J.whave=J.wsize;else{if(J.wnext+=D,J.wnext===J.wsize)J.wnext=0;if(J.whave<J.wsize)J.whave+=D}}return 0},M$A=(A,Q)=>{let $,B,D,J,E,F,Y,Z,U,X,G,V,K,z,W=0,I,H,q,N,C,M,O,R,k=new Uint8Array(4),_,f,g=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(VL(A)||!A.output||!A.input&&A.avail_in!==0)return AF;if($=A.state,$.mode===VK)$.mode=xv0;E=A.next_out,D=A.output,Y=A.avail_out,J=A.next_in,B=A.input,F=A.avail_in,Z=$.hold,U=$.bits,X=F,G=Y,R=XL;A:for(;;)switch($.mode){case f80:if($.wrap===0){$.mode=xv0;break}while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&2&&Z===35615){if($.wbits===0)$.wbits=15;$.check=0,k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0),Z=0,U=0,$.mode=qe1;break}if($.head)$.head.done=!1;if(!($.wrap&1)||(((Z&255)<<8)+(Z>>8))%31){A.msg="incorrect header check",$.mode=C2;break}if((Z&15)!==He1){A.msg="unknown compression method",$.mode=C2;break}if(Z>>>=4,U-=4,O=(Z&15)+8,$.wbits===0)$.wbits=O;if(O>15||O>$.wbits){A.msg="invalid window size",$.mode=C2;break}$.dmax=1<<$.wbits,$.flags=0,A.adler=$.check=1,$.mode=Z&512?Re1:VK,Z=0,U=0;break;case qe1:while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.flags=Z,($.flags&255)!==He1){A.msg="unknown compression method",$.mode=C2;break}if($.flags&57344){A.msg="unknown header flags set",$.mode=C2;break}if($.head)$.head.text=Z>>8&1;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0,$.mode=Ne1;case Ne1:while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.head)$.head.time=Z;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,k[2]=Z>>>16&255,k[3]=Z>>>24&255,$.check=K7($.check,k,4,0);Z=0,U=0,$.mode=Ce1;case Ce1:while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.head)$.head.xflags=Z&255,$.head.os=Z>>8;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0,$.mode=we1;case we1:if($.flags&1024){while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.length=Z,$.head)$.head.extra_len=Z;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0}else if($.head)$.head.extra=null;$.mode=Me1;case Me1:if($.flags&1024){if(V=$.length,V>F)V=F;if(V){if($.head){if(O=$.head.extra_len-$.length,!$.head.extra)$.head.extra=new Uint8Array($.head.extra_len);$.head.extra.set(B.subarray(J,J+V),O)}if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);F-=V,J+=V,$.length-=V}if($.length)break A}$.length=0,$.mode=Le1;case Le1:if($.flags&2048){if(F===0)break A;V=0;do if(O=B[J+V++],$.head&&O&&$.length<65536)$.head.name+=String.fromCharCode(O);while(O&&V<F);if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);if(F-=V,J+=V,O)break A}else if($.head)$.head.name=null;$.length=0,$.mode=Oe1;case Oe1:if($.flags&4096){if(F===0)break A;V=0;do if(O=B[J+V++],$.head&&O&&$.length<65536)$.head.comment+=String.fromCharCode(O);while(O&&V<F);if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);if(F-=V,J+=V,O)break A}else if($.head)$.head.comment=null;$.mode=je1;case je1:if($.flags&512){while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&4&&Z!==($.check&65535)){A.msg="header crc mismatch",$.mode=C2;break}Z=0,U=0}if($.head)$.head.hcrc=$.flags>>9&1,$.head.done=!0;A.adler=$.check=0,$.mode=VK;break;case Re1:while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}A.adler=$.check=ge1(Z),Z=0,U=0,$.mode=v80;case v80:if($.havedict===0)return A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,K$A;A.adler=$.check=1,$.mode=VK;case VK:if(Q===G$A||Q===j80)break A;case xv0:if($.last){Z>>>=U&7,U-=U&7,$.mode=hv0;break}while(U<3){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}switch($.last=Z&1,Z>>>=1,U-=1,Z&3){case 0:$.mode=ue1;break;case 1:if(w$A($),$.mode=R80,Q===j80){Z>>>=2,U-=2;break A}break;case 2:$.mode=_e1;break;case 3:A.msg="invalid block type",$.mode=C2}Z>>>=2,U-=2;break;case ue1:Z>>>=U&7,U-=U&7;while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if((Z&65535)!==(Z>>>16^65535)){A.msg="invalid stored block lengths",$.mode=C2;break}if($.length=Z&65535,Z=0,U=0,$.mode=bv0,Q===j80)break A;case bv0:$.mode=Pe1;case Pe1:if(V=$.length,V){if(V>F)V=F;if(V>Y)V=Y;if(V===0)break A;D.set(B.subarray(J,J+V),E),F-=V,J+=V,Y-=V,E+=V,$.length-=V;break}$.mode=VK;break;case _e1:while(U<14){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.nlen=(Z&31)+257,Z>>>=5,U-=5,$.ndist=(Z&31)+1,Z>>>=5,U-=5,$.ncode=(Z&15)+4,Z>>>=4,U-=4,$.nlen>286||$.ndist>30){A.msg="too many length or distance symbols",$.mode=C2;break}$.have=0,$.mode=Te1;case Te1:while($.have<$.ncode){while(U<3){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.lens[g[$.have++]]=Z&7,Z>>>=3,U-=3}while($.have<19)$.lens[g[$.have++]]=0;if($.lencode=$.lendyn,$.lenbits=7,_={bits:$.lenbits},R=dc(X$A,$.lens,0,19,$.lencode,0,$.work,_),$.lenbits=_.bits,R){A.msg="invalid code lengths set",$.mode=C2;break}$.have=0,$.mode=ve1;case ve1:while($.have<$.nlen+$.ndist){for(;;){if(W=$.lencode[Z&(1<<$.lenbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(q<16)Z>>>=I,U-=I,$.lens[$.have++]=q;else{if(q===16){f=I+2;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(Z>>>=I,U-=I,$.have===0){A.msg="invalid bit length repeat",$.mode=C2;break}O=$.lens[$.have-1],V=3+(Z&3),Z>>>=2,U-=2}else if(q===17){f=I+3;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=I,U-=I,O=0,V=3+(Z&7),Z>>>=3,U-=3}else{f=I+7;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=I,U-=I,O=0,V=11+(Z&127),Z>>>=7,U-=7}if($.have+V>$.nlen+$.ndist){A.msg="invalid bit length repeat",$.mode=C2;break}while(V--)$.lens[$.have++]=O}}if($.mode===C2)break;if($.lens[256]===0){A.msg="invalid code -- missing end-of-block",$.mode=C2;break}if($.lenbits=9,_={bits:$.lenbits},R=dc(G04,$.lens,0,$.nlen,$.lencode,0,$.work,_),$.lenbits=_.bits,R){A.msg="invalid literal/lengths set",$.mode=C2;break}if($.distbits=6,$.distcode=$.distdyn,_={bits:$.distbits},R=dc(V04,$.lens,$.nlen,$.ndist,$.distcode,0,$.work,_),$.distbits=_.bits,R){A.msg="invalid distances set",$.mode=C2;break}if($.mode=R80,Q===j80)break A;case R80:$.mode=u80;case u80:if(F>=6&&Y>=258){if(A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,J$A(A,G),E=A.next_out,D=A.output,Y=A.avail_out,J=A.next_in,B=A.input,F=A.avail_in,Z=$.hold,U=$.bits,$.mode===VK)$.back=-1;break}$.back=0;for(;;){if(W=$.lencode[Z&(1<<$.lenbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(H&&(H&240)===0){N=I,C=H,M=q;for(;;){if(W=$.lencode[M+((Z&(1<<N+C)-1)>>N)],I=W>>>24,H=W>>>16&255,q=W&65535,N+I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=N,U-=N,$.back+=N}if(Z>>>=I,U-=I,$.back+=I,$.length=q,H===0){$.mode=xe1;break}if(H&32){$.back=-1,$.mode=VK;break}if(H&64){A.msg="invalid literal/length code",$.mode=C2;break}$.extra=H&15,$.mode=ke1;case ke1:if($.extra){f=$.extra;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.length+=Z&(1<<$.extra)-1,Z>>>=$.extra,U-=$.extra,$.back+=$.extra}$.was=$.length,$.mode=Se1;case Se1:for(;;){if(W=$.distcode[Z&(1<<$.distbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if((H&240)===0){N=I,C=H,M=q;for(;;){if(W=$.distcode[M+((Z&(1<<N+C)-1)>>N)],I=W>>>24,H=W>>>16&255,q=W&65535,N+I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=N,U-=N,$.back+=N}if(Z>>>=I,U-=I,$.back+=I,H&64){A.msg="invalid distance code",$.mode=C2;break}$.offset=q,$.extra=H&15,$.mode=fe1;case fe1:if($.extra){f=$.extra;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.offset+=Z&(1<<$.extra)-1,Z>>>=$.extra,U-=$.extra,$.back+=$.extra}if($.offset>$.dmax){A.msg="invalid distance too far back",$.mode=C2;break}$.mode=ye1;case ye1:if(Y===0)break A;if(V=G-Y,$.offset>V){if(V=$.offset-V,V>$.whave){if($.sane){A.msg="invalid distance too far back",$.mode=C2;break}}if(V>$.wnext)V-=$.wnext,K=$.wsize-V;else K=$.wnext-V;if(V>$.length)V=$.length;z=$.window}else z=D,K=E-$.offset,V=$.length;if(V>Y)V=Y;Y-=V,$.length-=V;do D[E++]=z[K++];while(--V);if($.length===0)$.mode=u80;break;case xe1:if(Y===0)break A;D[E++]=$.length,Y--,$.mode=u80;break;case hv0:if($.wrap){while(U<32){if(F===0)break A;F--,Z|=B[J++]<<U,U+=8}if(G-=Y,A.total_out+=G,$.total+=G,$.wrap&4&&G)A.adler=$.check=$.flags?K7($.check,D,G,E-G):nc($.check,D,G,E-G);if(G=Y,$.wrap&4&&($.flags?Z:ge1(Z))!==$.check){A.msg="incorrect data check",$.mode=C2;break}Z=0,U=0}$.mode=be1;case be1:if($.wrap&&$.flags){while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&4&&Z!==($.total&4294967295)){A.msg="incorrect length check",$.mode=C2;break}Z=0,U=0}$.mode=he1;case he1:R=V$A;break A;case C2:R=K04;break A;case W04:return z04;case I04:default:return AF}if(A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,$.wsize||G!==A.avail_out&&$.mode<C2&&($.mode<hv0||Q!==Ie1)){if(w04(A,A.output,A.next_out,G-A.avail_out));}if(X-=A.avail_in,G-=A.avail_out,A.total_in+=X,A.total_out+=G,$.total+=G,$.wrap&4&&G)A.adler=$.check=$.flags?K7($.check,D,G,A.next_out-G):nc($.check,D,G,A.next_out-G);if(A.data_type=$.bits+($.last?64:0)+($.mode===VK?128:0)+($.mode===R80||$.mode===bv0?256:0),(X===0&&G===0||Q===Ie1)&&R===XL)R=z$A;return R},L$A=(A)=>{if(VL(A))return AF;let Q=A.state;if(Q.window)Q.window=null;return A.state=null,XL},O$A=(A,Q)=>{if(VL(A))return AF;let $=A.state;if(($.wrap&2)===0)return AF;return $.head=Q,Q.done=!1,XL},j$A=(A,Q)=>{let $=Q.length,B,D,J;if(VL(A))return AF;if(B=A.state,B.wrap!==0&&B.mode!==v80)return AF;if(B.mode===v80){if(D=1,D=nc(D,Q,$,0),D!==B.check)return K04}if(J=w04(A,Q,$,$),J)return B.mode=W04,z04;return B.havedict=1,XL},R$A,u$A,P$A,_$A,T$A,v$A,k$A,S$A,f$A,y$A="pako inflate (from Nodeca project)",zK,b$A,M04,h$A,g$A,rc,dv0,pv0,m$A,de1,d$A,c$A,l$A,i$A,n$A,a$A,o$A,r$A,s$A,t$A,e$A,ABA,QBA,$BA,BBA,DBA,JBA,EBA,FBA,YBA,ZBA,UBA,XBA,GBA,L04;var O04=o(()=>{/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */pc=sc+1+ev0,ce1=2*pc+1,cv0=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),P80=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),M7A=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ae1=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),KK=Array((pc+2)*2);dT(KK);gc=Array(hT*2);dT(gc);cc=Array(L7A);dT(cc);lc=Array(C7A-N7A+1);dT(lc);$k0=Array(ev0);dT($k0);_80=Array(hT);dT(_80);f7A=T7A,y7A=B04,x7A=k7A,b7A=S7A,h7A=v7A,g7A={_tr_init:f7A,_tr_stored_block:y7A,_tr_flush_block:x7A,_tr_tally:b7A,_tr_align:h7A},nc=m7A,p7A=new Uint32Array(d7A()),K7=c7A,ZL={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},GL={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:l7A,_tr_stored_block:iv0,_tr_flush_block:i7A,_tr_tally:GH,_tr_align:n7A}=g7A,{Z_NO_FLUSH:VH,Z_PARTIAL_FLUSH:a7A,Z_FULL_FLUSH:o7A,Z_FINISH:eE,Z_BLOCK:Ue1,Z_OK:o7,Z_STREAM_END:Xe1,Z_STREAM_ERROR:KX,Z_DATA_ERROR:r7A,Z_BUF_ERROR:Sv0,Z_DEFAULT_COMPRESSION:s7A,Z_FILTERED:t7A,Z_HUFFMAN_ONLY:L80,Z_RLE:e7A,Z_FIXED:AQA,Z_DEFAULT_STRATEGY:QQA,Z_UNKNOWN:$QA,Z_DEFLATED:k80}=GL,nv0=FQA+1+EQA,UQA=2*nv0+1,zX=XH+J3+1,KH=zQA;hc=[new GX(0,0,0,0,J04),new GX(4,4,8,4,fv0),new GX(4,5,16,8,fv0),new GX(4,6,32,32,fv0),new GX(4,4,16,16,xT),new GX(8,16,32,32,xT),new GX(8,16,128,128,xT),new GX(8,32,128,256,xT),new GX(32,128,258,1024,xT),new GX(32,258,258,4096,xT)];OQA=CQA,jQA=Y04,RQA=F04,uQA=E04,PQA=NQA,_QA=wQA,TQA=MQA,vQA=LQA,mc={deflateInit:OQA,deflateInit2:jQA,deflateReset:RQA,deflateResetKeep:uQA,deflateSetHeader:PQA,deflate:_QA,deflateEnd:TQA,deflateSetDictionary:vQA,deflateInfo:kQA},S80={assign:fQA,flattenChunks:yQA};try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){Z04=!1}ac=new Uint8Array(256);for(let A=0;A<256;A++)ac[A]=A>=252?6:A>=248?5:A>=240?4:A>=224?3:A>=192?2:1;ac[254]=ac[254]=1;oc={string2buf:xQA,buf2string:hQA,utf8border:gQA};U04=mQA,X04=Object.prototype.toString,{Z_NO_FLUSH:dQA,Z_SYNC_FLUSH:pQA,Z_FULL_FLUSH:cQA,Z_FINISH:lQA,Z_OK:T80,Z_STREAM_END:iQA,Z_DEFAULT_COMPRESSION:nQA,Z_DEFAULT_STRATEGY:aQA,Z_DEFLATED:oQA}=GL;ec.prototype.push=function(A,Q){let $=this.strm,B=this.options.chunkSize,D,J;if(this.ended)return!1;if(Q===~~Q)J=Q;else J=Q===!0?lQA:dQA;if(typeof A==="string")$.input=oc.string2buf(A);else if(X04.call(A)==="[object ArrayBuffer]")$.input=new Uint8Array(A);else $.input=A;$.next_in=0,$.avail_in=$.input.length;for(;;){if($.avail_out===0)$.output=new Uint8Array(B),$.next_out=0,$.avail_out=B;if((J===pQA||J===cQA)&&$.avail_out<=6){this.onData($.output.subarray(0,$.next_out)),$.avail_out=0;continue}if(D=mc.deflate($,J),D===iQA){if($.next_out>0)this.onData($.output.subarray(0,$.next_out));return D=mc.deflateEnd(this.strm),this.onEnd(D),this.ended=!0,D===T80}if($.avail_out===0){this.onData($.output);continue}if(J>0&&$.next_out>0){this.onData($.output.subarray(0,$.next_out)),$.avail_out=0;continue}if($.avail_in===0)break}return!0};ec.prototype.onData=function(A){this.chunks.push(A)};ec.prototype.onEnd=function(A){if(A===T80)this.result=S80.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};tQA=ec,eQA=Dk0,A$A=rQA,Q$A=sQA,$$A=GL,B$A={Deflate:tQA,deflate:eQA,deflateRaw:A$A,gzip:Q$A,constants:$$A},E$A=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),F$A=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Y$A=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Z$A=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),dc=U$A,{Z_FINISH:Ie1,Z_BLOCK:G$A,Z_TREES:j80,Z_OK:XL,Z_STREAM_END:V$A,Z_NEED_DICT:K$A,Z_STREAM_ERROR:AF,Z_DATA_ERROR:K04,Z_MEM_ERROR:z04,Z_BUF_ERROR:z$A,Z_DEFLATED:He1}=GL,q$A=H$A;R$A=q04,u$A=N04,P$A=H04,_$A=C$A,T$A=C04,v$A=M$A,k$A=L$A,S$A=O$A,f$A=j$A,zK={inflateReset:R$A,inflateReset2:u$A,inflateResetKeep:P$A,inflateInit:_$A,inflateInit2:T$A,inflate:v$A,inflateEnd:k$A,inflateGetHeader:S$A,inflateSetDictionary:f$A,inflateInfo:y$A};b$A=x$A,M04=Object.prototype.toString,{Z_NO_FLUSH:h$A,Z_FINISH:g$A,Z_OK:rc,Z_STREAM_END:dv0,Z_NEED_DICT:pv0,Z_STREAM_ERROR:m$A,Z_DATA_ERROR:de1,Z_MEM_ERROR:d$A}=GL;Al.prototype.push=function(A,Q){let $=this.strm,B=this.options.chunkSize,D=this.options.dictionary,J,E,F;if(this.ended)return!1;if(Q===~~Q)E=Q;else E=Q===!0?g$A:h$A;if(M04.call(A)==="[object ArrayBuffer]")$.input=new Uint8Array(A);else $.input=A;$.next_in=0,$.avail_in=$.input.length;for(;;){if($.avail_out===0)$.output=new Uint8Array(B),$.next_out=0,$.avail_out=B;if(J=zK.inflate($,E),J===pv0&&D){if(J=zK.inflateSetDictionary($,D),J===rc)J=zK.inflate($,E);else if(J===de1)J=pv0}while($.avail_in>0&&J===dv0&&$.state.wrap>0&&A[$.next_in]!==0)zK.inflateReset($),J=zK.inflate($,E);switch(J){case m$A:case de1:case pv0:case d$A:return this.onEnd(J),this.ended=!0,!1}if(F=$.avail_out,$.next_out){if($.avail_out===0||J===dv0)if(this.options.to==="string"){let Y=oc.utf8border($.output,$.next_out),Z=$.next_out-Y,U=oc.buf2string($.output,Y);if($.next_out=Z,$.avail_out=B-Z,Z)$.output.set($.output.subarray(Y,Y+Z),0);this.onData(U)}else this.onData($.output.length===$.next_out?$.output:$.output.subarray(0,$.next_out))}if(J===rc&&F===0)continue;if(J===dv0)return J=zK.inflateEnd(this.strm),this.onEnd(J),this.ended=!0,!0;if($.avail_in===0)break}return!0};Al.prototype.onData=function(A){this.chunks.push(A)};Al.prototype.onEnd=function(A){if(A===rc)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=S80.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};c$A=Al,l$A=Jk0,i$A=p$A,n$A=Jk0,a$A=GL,o$A={Inflate:c$A,inflate:l$A,inflateRaw:i$A,ungzip:n$A,constants:a$A},{Deflate:r$A,deflate:s$A,deflateRaw:t$A,gzip:e$A}=B$A,{Inflate:ABA,inflate:QBA,inflateRaw:$BA,ungzip:BBA}=o$A,DBA=r$A,JBA=s$A,EBA=t$A,FBA=e$A,YBA=ABA,ZBA=QBA,UBA=$BA,XBA=BBA,GBA=GL,L04={Deflate:DBA,deflate:JBA,deflateRaw:EBA,gzip:FBA,Inflate:YBA,inflate:ZBA,inflateRaw:UBA,ungzip:XBA,constants:GBA}});var j04="This cost reflects only Amp credits consumed. It does not include any model provider usage billed directly to customer-managed model provider keys.";var VBA,RN5,uN5,WX=64,KL,Ek0=1024,Fk0=500,PN5;var Ql=o(()=>{bQ();VBA=["private","public_unlisted","public_discoverable","thread_workspace_shared"],RN5=S.enum(VBA),uN5=S.union([S.object({visibility:S.literal("private"),sharedGroupIDs:S.array(S.string())}),S.object({visibility:S.literal("private"),shareWithAllCreatorGroups:S.literal(!0)}),S.object({visibility:S.enum(["thread_workspace_shared","public_unlisted","public_discoverable"])})]),KL=/^[a-z0-9](?:[a-z0-9]*(?:-[a-z0-9]+)*)?$/,PN5=S.string().regex(KL,"Must be lowercase a-z, 0-9, hyphens only, no start/end hyphen, no consecutive hyphens").min(1).max(WX)});function Yk0(A){switch(A){case"open":return"Open";case"in_progress":return"In Progress";case"completed":return"Completed";case"canceled":return"Canceled"}}var Zk0=()=>{};var Uk0=o(()=>{J9()});function Xk0(A){return Np(lT,A)}function zBA(A){return x_(R04,A)}function WBA(A){return AL(u04,A)}function IBA(A){return b_($l,A)}function HBA(A){return h_($l,A)}function qBA(A){return g_($l,A)}function NBA(A){return m_($l,A)}function CBA(A){return gI(Gk0,A)}function wBA(A){return gI(Gk0,{protocol:/^https?$/,hostname:v9.domain,...k1(A)})}function MBA(A){return d_(P04,A)}function LBA(A){return p_(_04,A)}function OBA(A){return c_(T04,A)}function jBA(A){return l_(v04,A)}function RBA(A){return i_(k04,A)}function uBA(A){return n_(S04,A)}function PBA(A){return a_(f04,A)}function _BA(A){return o_(y04,A)}function TBA(A){return r_(x04,A)}function vBA(A){return s_(b04,A)}function kBA(A){return t_(h04,A)}function SBA(A){return wp(g04,A)}function fBA(A){return e_(m04,A)}function yBA(A){return AT(d04,A)}function xBA(A){return QT(p04,A)}function bBA(A){return $T(c04,A)}function hBA(A,Q,$={}){return iY(Bl,A,Q,$)}function gBA(A){return iY(Bl,"hostname",v9.hostname,A)}function mBA(A){return iY(Bl,"hex",v9.hex,A)}function dBA(A,Q){let $=Q?.enc??"hex",B=`${A}_${$}`,D=v9[B];if(!D)throw Error(`Unrecognized hash format: ${B}`);return iY(Bl,B,D,Q)}function l04(A){return up(Dl,A)}function pBA(A){return _p(iT,A)}function cBA(A){return Tp(iT,A)}function lBA(A){return vp(iT,A)}function iBA(A){return kp(iT,A)}function nBA(A){return Sp(iT,A)}function i04(A){return fp(Jl,A)}function aBA(A){return xp(El,A)}function oBA(A){return hp(Vk0,A)}function rBA(A){return gp(Vk0,A)}function sBA(A){return mp(n04,A)}function tBA(A){return dp(a04,A)}function r04(A){return pp(o04,A)}function eBA(){return cp(s04)}function y80(){return lp(t04)}function A14(A){return ip(e04,A)}function ADA(A){return np(Q14,A)}function QDA(A){return ap(x80,A)}function Kk0(A,Q){return new $14({type:"array",element:A,...k1(Q)})}function $DA(A){let Q=A._zod.def.shape;return V14(Object.keys(Q))}function B14(A,Q){let $={type:"object",shape:A??{},...k1(Q)};return new b80($)}function BDA(A,Q){return new b80({type:"object",shape:A,catchall:A14(),...k1(Q)})}function DDA(A,Q){return new b80({type:"object",shape:A,catchall:y80(),...k1(Q)})}function JDA(A,Q){return c50(A,Q)}function EDA(A,Q){return tR0(A,Q)}function FDA(A,Q){return c50(A,Q)}function YDA(A,Q){return rR0(A,Q)}function ZDA(A,Q){return sR0(A,Q)}function UDA(A,Q){return eR0(Ik0,A,Q)}function XDA(A,Q){return Au0(Hk0,A,Q)}function GDA(A,Q){return A.clone({...A._zod.def,catchall:Q})}function D14(A,Q){return new zk0({type:"union",options:A,...k1(Q)})}function VDA(A,Q){return new J14({type:"union",options:A,inclusive:!1,...k1(Q)})}function KDA(A,Q,$){return new E14({type:"union",options:Q,discriminator:A,...k1($)})}function zDA(A,Q){return new F14({type:"intersection",left:A,right:Q})}function Z14(A,Q,$){let B=Q instanceof g6;return new Y14({type:"tuple",items:A,rest:B?Q:null,...k1(B?$:Q)})}function U14(A,Q,$){return new h80({type:"record",keyType:A,valueType:Q,...k1($)})}function WDA(A,Q,$){let B=D9(A);return B._zod.values=void 0,new h80({type:"record",keyType:B,valueType:Q,...k1($)})}function IDA(A,Q,$){return new h80({type:"record",keyType:A,valueType:Q,mode:"loose",...k1($)})}function HDA(A,Q,$){return new X14({type:"map",keyType:A,valueType:Q,...k1($)})}function qDA(A,Q){return new G14({type:"set",valueType:A,...k1(Q)})}function V14(A,Q){let $=Array.isArray(A)?Object.fromEntries(A.map((B)=>[B,B])):A;return new Wk0({type:"enum",entries:$,...k1(Q)})}function NDA(A,Q){return new Wk0({type:"enum",entries:A,...k1(Q)})}function CDA(A,Q){return new K14({type:"literal",values:Array.isArray(A)?A:[A],...k1(Q)})}function wDA(A){return sp(z14,A)}function MDA(A){return new W14({type:"transform",transform:A})}function I14(A){return new Ik0({type:"optional",innerType:A})}function LDA(A){return new H14({type:"optional",innerType:A})}function N14(A){return new q14({type:"nullable",innerType:A})}function ODA(A){return I14(N14(A))}function jDA(A,Q){return new C14({type:"default",innerType:A,get defaultValue(){return typeof Q==="function"?Q():L_(Q)}})}function RDA(A,Q){return new w14({type:"prefault",innerType:A,get defaultValue(){return typeof Q==="function"?Q():L_(Q)}})}function uDA(A,Q){return new Hk0({type:"nonoptional",innerType:A,...k1(Q)})}function PDA(A){return new M14({type:"success",innerType:A})}function _DA(A,Q){return new L14({type:"catch",innerType:A,catchValue:typeof Q==="function"?Q:()=>Q})}function TDA(A){return rp(O14,A)}function vDA(A,Q){return new qk0({type:"pipe",in:A,out:Q})}function kDA(A,Q,$){return new Nk0({type:"pipe",in:A,out:Q,transform:$.decode,reverseTransform:$.encode})}function SDA(A){return new j14({type:"readonly",innerType:A})}function fDA(A,Q){return new R14({type:"template_literal",parts:A,...k1(Q)})}function P14(A){return new u14({type:"lazy",getter:A})}function yDA(A){return new _14({type:"promise",innerType:A})}function xDA(A,Q){let $=new U5({check:"custom",...k1(Q)});return $._zod.check=A,$}function T14(A,Q){return tp(Ck0,A??(()=>!0),Q)}function bDA(A,Q={}){return ep(Ck0,A,Q)}function hDA(A){return Ac(A)}function dDA(A,Q={}){let $=T14((B)=>B instanceof A,Q);return $._zod.bag.Class=A,$._zod.check=(B)=>{if(!(B.value instanceof A))B.issues.push({code:"invalid_type",expected:A.name,input:B.value,inst:$,path:[...$._zod.def.path??[]]})},$}function cDA(){let A=P14(()=>{return D14([Xk0(),l04(),i04(),r04(),Kk0(A),U14(Xk0(),A)])});return A}function lDA(A){return new v14({type:"function",input:Array.isArray(A?.input)?Z14(A?.input):A?.input??Kk0(y80()),output:A?.output??y80()})}var HA,lT,y5,R04,u04,$l,Gk0,P04,_04,T04,v04,k04,S04,f04,y04,x04,b04,h04,g04,m04,d04,p04,c04,Bl,Dl,iT,Jl,El,Vk0,n04,a04,o04,s04,t04,e04,Q14,x80,$14,b80,zk0,J14,E14,F14,Y14,h80,X14,G14,Wk0,K14,z14,W14,Ik0,H14,q14,C14,w14,Hk0,M14,L14,O14,qk0,Nk0,j14,R14,u14,_14,Ck0,gDA,mDA,pDA=(...A)=>Bc({Codec:Nk0,Boolean:Jl,String:lT},...A),v14;var g80=o(()=>{J9();J6();Uk0();HA=f0("ZodMiniType",(A,Q)=>{if(!A._zod)throw Error("Uninitialized schema in ZodMiniType.");g6.init(A,Q),A.def=Q,A.type=Q.type,A.parse=($,B)=>xI(A,$,B,{callee:A.parse}),A.safeParse=($,B)=>BK(A,$,B),A.parseAsync=async($,B)=>bI(A,$,B,{callee:A.parseAsync}),A.safeParseAsync=async($,B)=>hI(A,$,B),A.check=(...$)=>{return A.clone({...Q,checks:[...Q.checks??[],...$.map((B)=>typeof B==="function"?{_zod:{check:B,def:{check:"custom"},onattach:[]}}:B)]},{parent:!0})},A.with=A.check,A.clone=($,B)=>D9(A,$,B),A.brand=()=>A,A.register=($,B)=>{return $.add(A,B),A},A.apply=($)=>$(A)}),lT=f0("ZodMiniString",(A,Q)=>{DK.init(A,Q),HA.init(A,Q)});y5=f0("ZodMiniStringFormat",(A,Q)=>{e3.init(A,Q),lT.init(A,Q)}),R04=f0("ZodMiniEmail",(A,Q)=>{Yd.init(A,Q),y5.init(A,Q)});u04=f0("ZodMiniGUID",(A,Q)=>{Ed.init(A,Q),y5.init(A,Q)});$l=f0("ZodMiniUUID",(A,Q)=>{Fd.init(A,Q),y5.init(A,Q)});Gk0=f0("ZodMiniURL",(A,Q)=>{Zd.init(A,Q),y5.init(A,Q)});P04=f0("ZodMiniEmoji",(A,Q)=>{Ud.init(A,Q),y5.init(A,Q)});_04=f0("ZodMiniNanoID",(A,Q)=>{Xd.init(A,Q),y5.init(A,Q)});T04=f0("ZodMiniCUID",(A,Q)=>{Gd.init(A,Q),y5.init(A,Q)});v04=f0("ZodMiniCUID2",(A,Q)=>{Vd.init(A,Q),y5.init(A,Q)});k04=f0("ZodMiniULID",(A,Q)=>{Kd.init(A,Q),y5.init(A,Q)});S04=f0("ZodMiniXID",(A,Q)=>{zd.init(A,Q),y5.init(A,Q)});f04=f0("ZodMiniKSUID",(A,Q)=>{Wd.init(A,Q),y5.init(A,Q)});y04=f0("ZodMiniIPv4",(A,Q)=>{Cd.init(A,Q),y5.init(A,Q)});x04=f0("ZodMiniIPv6",(A,Q)=>{wd.init(A,Q),y5.init(A,Q)});b04=f0("ZodMiniCIDRv4",(A,Q)=>{Ld.init(A,Q),y5.init(A,Q)});h04=f0("ZodMiniCIDRv6",(A,Q)=>{Od.init(A,Q),y5.init(A,Q)});g04=f0("ZodMiniMAC",(A,Q)=>{Md.init(A,Q),y5.init(A,Q)});m04=f0("ZodMiniBase64",(A,Q)=>{jd.init(A,Q),y5.init(A,Q)});d04=f0("ZodMiniBase64URL",(A,Q)=>{Rd.init(A,Q),y5.init(A,Q)});p04=f0("ZodMiniE164",(A,Q)=>{ud.init(A,Q),y5.init(A,Q)});c04=f0("ZodMiniJWT",(A,Q)=>{Pd.init(A,Q),y5.init(A,Q)});Bl=f0("ZodMiniCustomStringFormat",(A,Q)=>{_d.init(A,Q),y5.init(A,Q)});Dl=f0("ZodMiniNumber",(A,Q)=>{T_.init(A,Q),HA.init(A,Q)});iT=f0("ZodMiniNumberFormat",(A,Q)=>{Td.init(A,Q),Dl.init(A,Q)});Jl=f0("ZodMiniBoolean",(A,Q)=>{rM.init(A,Q),HA.init(A,Q)});El=f0("ZodMiniBigInt",(A,Q)=>{v_.init(A,Q),HA.init(A,Q)});Vk0=f0("ZodMiniBigIntFormat",(A,Q)=>{vd.init(A,Q),El.init(A,Q)});n04=f0("ZodMiniSymbol",(A,Q)=>{kd.init(A,Q),HA.init(A,Q)});a04=f0("ZodMiniUndefined",(A,Q)=>{Sd.init(A,Q),HA.init(A,Q)});o04=f0("ZodMiniNull",(A,Q)=>{fd.init(A,Q),HA.init(A,Q)});s04=f0("ZodMiniAny",(A,Q)=>{yd.init(A,Q),HA.init(A,Q)});t04=f0("ZodMiniUnknown",(A,Q)=>{xd.init(A,Q),HA.init(A,Q)});e04=f0("ZodMiniNever",(A,Q)=>{bd.init(A,Q),HA.init(A,Q)});Q14=f0("ZodMiniVoid",(A,Q)=>{hd.init(A,Q),HA.init(A,Q)});x80=f0("ZodMiniDate",(A,Q)=>{gd.init(A,Q),HA.init(A,Q)});$14=f0("ZodMiniArray",(A,Q)=>{md.init(A,Q),HA.init(A,Q)});b80=f0("ZodMiniObject",(A,Q)=>{U20.init(A,Q),HA.init(A,Q),zA(A,"shape",()=>Q.shape)});zk0=f0("ZodMiniUnion",(A,Q)=>{sM.init(A,Q),HA.init(A,Q)});J14=f0("ZodMiniXor",(A,Q)=>{zk0.init(A,Q),dd.init(A,Q)});E14=f0("ZodMiniDiscriminatedUnion",(A,Q)=>{pd.init(A,Q),HA.init(A,Q)});F14=f0("ZodMiniIntersection",(A,Q)=>{cd.init(A,Q),HA.init(A,Q)});Y14=f0("ZodMiniTuple",(A,Q)=>{k_.init(A,Q),HA.init(A,Q)});h80=f0("ZodMiniRecord",(A,Q)=>{ld.init(A,Q),HA.init(A,Q)});X14=f0("ZodMiniMap",(A,Q)=>{id.init(A,Q),HA.init(A,Q)});G14=f0("ZodMiniSet",(A,Q)=>{nd.init(A,Q),HA.init(A,Q)});Wk0=f0("ZodMiniEnum",(A,Q)=>{ad.init(A,Q),HA.init(A,Q),A.options=Object.values(Q.entries)});K14=f0("ZodMiniLiteral",(A,Q)=>{od.init(A,Q),HA.init(A,Q)});z14=f0("ZodMiniFile",(A,Q)=>{rd.init(A,Q),HA.init(A,Q)});W14=f0("ZodMiniTransform",(A,Q)=>{sd.init(A,Q),HA.init(A,Q)});Ik0=f0("ZodMiniOptional",(A,Q)=>{S_.init(A,Q),HA.init(A,Q)});H14=f0("ZodMiniExactOptional",(A,Q)=>{td.init(A,Q),HA.init(A,Q)});q14=f0("ZodMiniNullable",(A,Q)=>{ed.init(A,Q),HA.init(A,Q)});C14=f0("ZodMiniDefault",(A,Q)=>{Ap.init(A,Q),HA.init(A,Q)});w14=f0("ZodMiniPrefault",(A,Q)=>{Qp.init(A,Q),HA.init(A,Q)});Hk0=f0("ZodMiniNonOptional",(A,Q)=>{$p.init(A,Q),HA.init(A,Q)});M14=f0("ZodMiniSuccess",(A,Q)=>{Bp.init(A,Q),HA.init(A,Q)});L14=f0("ZodMiniCatch",(A,Q)=>{Dp.init(A,Q),HA.init(A,Q)});O14=f0("ZodMiniNaN",(A,Q)=>{Jp.init(A,Q),HA.init(A,Q)});qk0=f0("ZodMiniPipe",(A,Q)=>{Ep.init(A,Q),HA.init(A,Q)});Nk0=f0("ZodMiniCodec",(A,Q)=>{qk0.init(A,Q),tM.init(A,Q)});j14=f0("ZodMiniReadonly",(A,Q)=>{Fp.init(A,Q),HA.init(A,Q)});R14=f0("ZodMiniTemplateLiteral",(A,Q)=>{Yp.init(A,Q),HA.init(A,Q)});u14=f0("ZodMiniLazy",(A,Q)=>{Xp.init(A,Q),HA.init(A,Q)});_14=f0("ZodMiniPromise",(A,Q)=>{Up.init(A,Q),HA.init(A,Q)});Ck0=f0("ZodMiniCustom",(A,Q)=>{Gp.init(A,Q),HA.init(A,Q)});gDA=Qc,mDA=$c;v14=f0("ZodMiniFunction",(A,Q)=>{Zp.init(A,Q),HA.init(A,Q)})});var S14=o(()=>{J9()});var wk0={};H2(wk0,{time:()=>aDA,duration:()=>oDA,datetime:()=>iDA,date:()=>nDA,ZodMiniISOTime:()=>p80,ZodMiniISODuration:()=>c80,ZodMiniISODateTime:()=>m80,ZodMiniISODate:()=>d80});function iDA(A){return Lp(m80,A)}function nDA(A){return Op(d80,A)}function aDA(A){return jp(p80,A)}function oDA(A){return Rp(c80,A)}var m80,d80,p80,c80;var Mk0=o(()=>{J9();g80();m80=f0("ZodMiniISODateTime",(A,Q)=>{Id.init(A,Q),y5.init(A,Q)});d80=f0("ZodMiniISODate",(A,Q)=>{Hd.init(A,Q),y5.init(A,Q)});p80=f0("ZodMiniISOTime",(A,Q)=>{qd.init(A,Q),y5.init(A,Q)});c80=f0("ZodMiniISODuration",(A,Q)=>{Nd.init(A,Q),y5.init(A,Q)})});var Lk0={};H2(Lk0,{string:()=>rDA,number:()=>sDA,date:()=>AJA,boolean:()=>tDA,bigint:()=>eDA});function rDA(A){return Cp(lT,A)}function sDA(A){return Pp(Dl,A)}function tDA(A){return yp(Jl,A)}function eDA(A){return bp(El,A)}function AJA(A){return op(x80,A)}var f14=o(()=>{J9();g80()});var rB={};H2(rB,{xor:()=>VDA,xid:()=>uBA,void:()=>ADA,uuidv7:()=>NBA,uuidv6:()=>qBA,uuidv4:()=>HBA,uuid:()=>IBA,util:()=>e1,url:()=>CBA,uppercase:()=>pI,unknown:()=>y80,union:()=>D14,undefined:()=>tBA,ulid:()=>RBA,uint64:()=>rBA,uint32:()=>nBA,tuple:()=>Z14,trim:()=>oI,treeifyError:()=>Qd,transform:()=>MDA,toUpperCase:()=>sI,toLowerCase:()=>rI,toJSONSchema:()=>UT,templateLiteral:()=>fDA,symbol:()=>sBA,superRefine:()=>hDA,success:()=>PDA,stringbool:()=>pDA,stringFormat:()=>hBA,string:()=>Xk0,strictObject:()=>BDA,startsWith:()=>lI,size:()=>JK,set:()=>qDA,safeParseAsync:()=>hI,safeParse:()=>BK,safeExtend:()=>EDA,safeEncodeAsync:()=>Yu0,safeEncode:()=>Eu0,safeDecodeAsync:()=>Zu0,safeDecode:()=>Fu0,required:()=>XDA,registry:()=>y_,regexes:()=>v9,regex:()=>mI,refine:()=>bDA,record:()=>U14,readonly:()=>SDA,property:()=>FT,promise:()=>yDA,prettifyError:()=>$d,prefault:()=>RDA,positive:()=>BT,pipe:()=>vDA,pick:()=>YDA,partialRecord:()=>WDA,partial:()=>UDA,parseAsync:()=>bI,parse:()=>xI,overwrite:()=>KJ,optional:()=>I14,omit:()=>ZDA,object:()=>B14,number:()=>l04,nullish:()=>ODA,nullable:()=>N14,null:()=>r04,normalize:()=>aI,nonpositive:()=>JT,nonoptional:()=>uDA,nonnegative:()=>ET,never:()=>A14,negative:()=>DT,nativeEnum:()=>NDA,nanoid:()=>LBA,nan:()=>TDA,multipleOf:()=>FX,minimum:()=>V7,minSize:()=>rE,minLength:()=>lY,mime:()=>nI,meta:()=>mDA,merge:()=>FDA,maximum:()=>yQ,maxSize:()=>YX,maxLength:()=>EK,map:()=>HDA,mac:()=>SBA,lte:()=>yQ,lt:()=>aE,lowercase:()=>dI,looseRecord:()=>IDA,looseObject:()=>DDA,locales:()=>eM,literal:()=>CDA,length:()=>FK,lazy:()=>P14,ksuid:()=>PBA,keyof:()=>$DA,jwt:()=>bBA,json:()=>cDA,iso:()=>wk0,ipv6:()=>TBA,ipv4:()=>_BA,intersection:()=>zDA,int64:()=>oBA,int32:()=>iBA,int:()=>pBA,instanceof:()=>dDA,includes:()=>cI,httpUrl:()=>wBA,hostname:()=>gBA,hex:()=>mBA,hash:()=>dBA,guid:()=>WBA,gte:()=>V7,gt:()=>oE,globalRegistry:()=>k9,function:()=>lDA,formatError:()=>aM,float64:()=>lBA,float32:()=>cBA,flattenError:()=>nM,file:()=>wDA,extend:()=>JDA,exactOptional:()=>LDA,enum:()=>V14,endsWith:()=>iI,encodeAsync:()=>Du0,encode:()=>$u0,emoji:()=>MBA,email:()=>zBA,e164:()=>xBA,discriminatedUnion:()=>KDA,describe:()=>gDA,decodeAsync:()=>Ju0,decode:()=>Bu0,date:()=>QDA,custom:()=>T14,cuid2:()=>jBA,cuid:()=>OBA,core:()=>iB,config:()=>h2,coerce:()=>Lk0,codec:()=>kDA,clone:()=>D9,cidrv6:()=>kBA,cidrv4:()=>vBA,check:()=>xDA,catchall:()=>GDA,catch:()=>_DA,boolean:()=>i04,bigint:()=>aBA,base64url:()=>yBA,base64:()=>fBA,array:()=>Kk0,any:()=>eBA,_function:()=>lDA,_default:()=>jDA,ZodMiniXor:()=>J14,ZodMiniXID:()=>S04,ZodMiniVoid:()=>Q14,ZodMiniUnknown:()=>t04,ZodMiniUnion:()=>zk0,ZodMiniUndefined:()=>a04,ZodMiniUUID:()=>$l,ZodMiniURL:()=>Gk0,ZodMiniULID:()=>k04,ZodMiniType:()=>HA,ZodMiniTuple:()=>Y14,ZodMiniTransform:()=>W14,ZodMiniTemplateLiteral:()=>R14,ZodMiniSymbol:()=>n04,ZodMiniSuccess:()=>M14,ZodMiniStringFormat:()=>y5,ZodMiniString:()=>lT,ZodMiniSet:()=>G14,ZodMiniRecord:()=>h80,ZodMiniReadonly:()=>j14,ZodMiniPromise:()=>_14,ZodMiniPrefault:()=>w14,ZodMiniPipe:()=>qk0,ZodMiniOptional:()=>Ik0,ZodMiniObject:()=>b80,ZodMiniNumberFormat:()=>iT,ZodMiniNumber:()=>Dl,ZodMiniNullable:()=>q14,ZodMiniNull:()=>o04,ZodMiniNonOptional:()=>Hk0,ZodMiniNever:()=>e04,ZodMiniNanoID:()=>_04,ZodMiniNaN:()=>O14,ZodMiniMap:()=>X14,ZodMiniMAC:()=>g04,ZodMiniLiteral:()=>K14,ZodMiniLazy:()=>u14,ZodMiniKSUID:()=>f04,ZodMiniJWT:()=>c04,ZodMiniIntersection:()=>F14,ZodMiniISOTime:()=>p80,ZodMiniISODuration:()=>c80,ZodMiniISODateTime:()=>m80,ZodMiniISODate:()=>d80,ZodMiniIPv6:()=>x04,ZodMiniIPv4:()=>y04,ZodMiniGUID:()=>u04,ZodMiniFunction:()=>v14,ZodMiniFile:()=>z14,ZodMiniExactOptional:()=>H14,ZodMiniEnum:()=>Wk0,ZodMiniEmoji:()=>P04,ZodMiniEmail:()=>R04,ZodMiniE164:()=>p04,ZodMiniDiscriminatedUnion:()=>E14,ZodMiniDefault:()=>C14,ZodMiniDate:()=>x80,ZodMiniCustomStringFormat:()=>Bl,ZodMiniCustom:()=>Ck0,ZodMiniCodec:()=>Nk0,ZodMiniCatch:()=>L14,ZodMiniCUID2:()=>v04,ZodMiniCUID:()=>T04,ZodMiniCIDRv6:()=>h04,ZodMiniCIDRv4:()=>b04,ZodMiniBoolean:()=>Jl,ZodMiniBigIntFormat:()=>Vk0,ZodMiniBigInt:()=>El,ZodMiniBase64URL:()=>d04,ZodMiniBase64:()=>m04,ZodMiniArray:()=>$14,ZodMiniAny:()=>s04,TimePrecision:()=>Mp,NEVER:()=>cM,$output:()=>Ip,$input:()=>Hp,$brand:()=>nm});var Ok0=o(()=>{J9();J9();XT();X20();Mk0();Mk0();f14();Uk0();g80();S14()});var jk0=o(()=>{Ok0();Ok0()});var $JA,y14,cN5,BJA,lN5;var x14=o(()=>{bQ();jk0();$JA=S.templateLiteral([S.string().regex(/^[0-9a-f]{8}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{12}$/)]),y14=S.templateLiteral(["T-",$JA]),cN5=rB.union([rB.object({visibility:rB.literal("private"),sharedGroupIDs:rB.array(rB.string())}),rB.object({visibility:rB.literal("thread_group_shared"),sharedGroupIDs:rB.array(rB.string())}),rB.object({visibility:rB.enum(["thread_workspace_shared","public_unlisted","public_discoverable"])})]),BJA=S.string(),lN5=S.object({id:BJA,title:S.string().optional(),messageCount:S.number(),updatedAt:S.string(),firstSyncAt:S.string(),created:S.number(),creatorUserID:S.string(),meta:S.object({visibility:S.enum(["private","thread_group_shared","public_unlisted","public_discoverable","thread_workspace_shared"]),sharedGroupIDs:S.array(S.string())}),labels:S.array(S.object({id:S.string(),name:S.string(),createdAt:S.string()}))})});var b14=()=>{};var h14=()=>{};var Rk0=o(()=>{Ql();Zk0();x14();b14();h14()});import{randomFillSync as DJA}from"crypto";function n80(){if(l80>i80.length-16)DJA(i80),l80=0;return i80.slice(l80,l80+=16)}var i80,l80;var g14=o(()=>{i80=new Uint8Array(256),l80=i80.length});function m14(A,Q=0){return(r7[A[Q+0]]+r7[A[Q+1]]+r7[A[Q+2]]+r7[A[Q+3]]+"-"+r7[A[Q+4]]+r7[A[Q+5]]+"-"+r7[A[Q+6]]+r7[A[Q+7]]+"-"+r7[A[Q+8]]+r7[A[Q+9]]+"-"+r7[A[Q+10]]+r7[A[Q+11]]+r7[A[Q+12]]+r7[A[Q+13]]+r7[A[Q+14]]+r7[A[Q+15]]).toLowerCase()}var r7;var d14=o(()=>{r7=[];for(let A=0;A<256;++A)r7.push((A+256).toString(16).slice(1))});function JJA(A,Q,$){let B;if(A)B=p14(A.random??A.rng?.()??n80(),A.msecs,A.seq,Q,$);else{let D=Date.now(),J=n80();EJA(uk0,D,J),B=p14(J,uk0.msecs,uk0.seq,Q,$)}return Q??m14(B)}function EJA(A,Q,$){if(A.msecs??=-1/0,A.seq??=0,Q>A.msecs)A.seq=$[6]<<23|$[7]<<16|$[8]<<8|$[9],A.msecs=Q;else if(A.seq=A.seq+1|0,A.seq===0)A.msecs++;return A}function p14(A,Q,$,B,D=0){if(A.length<16)throw Error("Random bytes length must be >= 16");if(!B)B=new Uint8Array(16),D=0;else if(D<0||D+16>B.length)throw RangeError(`UUID byte range ${D}:${D+15} is out of buffer bounds`);return Q??=Date.now(),$??=A[6]*127<<24|A[7]<<16|A[8]<<8|A[9],B[D++]=Q/1099511627776&255,B[D++]=Q/4294967296&255,B[D++]=Q/16777216&255,B[D++]=Q/65536&255,B[D++]=Q/256&255,B[D++]=Q&255,B[D++]=112|$>>>28&15,B[D++]=$>>>20&255,B[D++]=128|$>>>14&63,B[D++]=$>>>6&255,B[D++]=$<<2&255|A[10]&3,B[D++]=A[11],B[D++]=A[12],B[D++]=A[13],B[D++]=A[14],B[D++]=A[15],B}var uk0,nT;var c14=o(()=>{g14();d14();uk0={};nT=JJA});var Pk0=o(()=>{c14()});function FJA(A){let Q=0,$=[];while(Q<A.length){let B=A[Q];if(B==="\\"){Q++;continue}if(B==="{"){$.push({type:"brace",value:"{"}),Q++;continue}if(B==="}"){$.push({type:"brace",value:"}"}),Q++;continue}if(B==="["){$.push({type:"paren",value:"["}),Q++;continue}if(B==="]"){$.push({type:"paren",value:"]"}),Q++;continue}if(B===":"){$.push({type:"separator",value:":"}),Q++;continue}if(B===","){$.push({type:"delimiter",value:","}),Q++;continue}if(B==='"'){let F="",Y=!1;B=A[++Q];while(B!=='"'){if(Q===A.length){Y=!0;break}if(B==="\\"){if(Q++,Q===A.length){Y=!0;break}F+=B+A[Q],B=A[++Q]}else F+=B,B=A[++Q]}if(B=A[++Q],!Y)$.push({type:"string",value:F});continue}if(B&&/\s/.test(B)){Q++;continue}let J=/[0-9]/;if(B&&J.test(B)||B==="-"||B==="."){let F="";if(B==="-")F+=B,B=A[++Q];while(B&&J.test(B)||B===".")F+=B,B=A[++Q];$.push({type:"number",value:F});continue}let E=/[a-z]/i;if(B&&E.test(B)){let F="";while(B&&E.test(B)){if(Q===A.length)break;F+=B,B=A[++Q]}if(F==="true"||F==="false"||F==="null")$.push({type:"name",value:F});else{Q++;continue}continue}Q++}return $}function aT(A){if(A.length===0)return A;let Q=A[A.length-1];if(!Q)return A;switch(Q.type){case"separator":return aT(A.slice(0,A.length-1));case"number":{let $=Q.value[Q.value.length-1];if($==="."||$==="-")return aT(A.slice(0,A.length-1));break}case"string":{let $=A[A.length-2];if($?.type==="delimiter")return aT(A.slice(0,A.length-1));else if($?.type==="brace"&&$.value==="{")return aT(A.slice(0,A.length-1));break}case"delimiter":return aT(A.slice(0,A.length-1))}return A}function YJA(A){let Q=[];for(let $ of A){if($.type==="brace")if($.value==="{")Q.push("}");else{let B=Q.lastIndexOf("}");if(B!==-1)Q.splice(B,1)}if($.type==="paren")if($.value==="[")Q.push("]");else{let B=Q.lastIndexOf("]");if(B!==-1)Q.splice(B,1)}}if(Q.length>0){Q.reverse();for(let $ of Q)if($==="}")A.push({type:"brace",value:"}"});else if($==="]")A.push({type:"paren",value:"]"})}return A}function ZJA(A){let Q="";for(let $ of A)switch($.type){case"string":Q+='"'+$.value+'"';break;default:Q+=$.value;break}return Q}function a80(A){let Q=ZJA(YJA(aT(FJA(A))));return JSON.parse(Q)}function o80(A){try{let Q=a80(A);if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q))return Q;return{}}catch{return{}}}function r80(A,Q,$="..."){if(A.length<=Q)return A;return A.slice(0,Math.max(0,Q-$.length))+$}function UJA(A){let Q=A.match(/^(?:cat\s+)?<<['"]?(\w+)['"]?\s*\n([\s\S]*?)\n\1\s*$/);if(Q)return Q[2];return A}function XJA(A,Q){let $=A[Q];if(!$)return null;let B=$.match(/^\*\*\* Add File: (.+)$/);if(B)return{filePath:B[1],nextIdx:Q+1};let D=$.match(/^\*\*\* Delete File: (.+)$/);if(D)return{filePath:D[1],nextIdx:Q+1};let J=$.match(/^\*\*\* Update File: (.+)$/);if(J){let E,F=Q+1,Y=A[F];if(Y){let Z=Y.match(/^\*\*\* Move to: (.+)$/);if(Z)E=Z[1],F++}return{filePath:J[1],movePath:E,nextIdx:F}}return null}function _k0(A){return A.startsWith("*** Add File:")||A.startsWith("*** Update File:")||A.startsWith("*** Delete File:")||A.trim()==="*** End Patch"}function GJA(A,Q){let $=[],B=Q;while(B<A.length){let D=A[B];if(_k0(D))break;if(D.startsWith("+"))$.push(D.slice(1));else if(D==="")$.push("");else throw Error(`Invalid patch format: Add File lines must start with '+', got: "${D.slice(0,20)}${D.length>20?"...":""}"`);B++}return{content:$.join(`
216
+ `}function B80(A,Q){if(!(Q instanceof Error))return Q;let $={name:Q.name,message:Q.message};if(typeof Q.stack==="string")$.stack=Q.stack;let B=Q.cause;if(B!==void 0)$.cause=B;if(typeof AggregateError<"u"&&Q instanceof AggregateError)$.errors=Q.errors;for(let D of Object.keys(Q))if(!(D in $))$[D]=Q[D];return $}function Ev0(A={}){let Q=(()=>{let F=A.timestamp;if(F==null)return $80["date-time-timezone"];else if(F==="disabled")return $80.none;else if(typeof F==="string"&&F in $80)return $80[F];else return F})(),$=A.category??"·",B=A.value?(F)=>A.value(F,It1):It1,D=(()=>{let F=A.level;if(F==null||F==="ABBR")return(Y)=>LT.ABBR[Y];else if(F==="abbr")return(Y)=>LT.abbr[Y];else if(F==="FULL")return(Y)=>LT.FULL[Y];else if(F==="full")return(Y)=>LT.full[Y];else if(F==="L")return(Y)=>LT.L[Y];else if(F==="l")return(Y)=>LT.l[Y];else return F})(),J=qt1(A.lineEnding),E=A.format??(({timestamp:F,level:Y,category:Z,message:U})=>`${F?`${F} `:""}[${Y}] ${Z}: ${U}`);return(F)=>{let Y=F.message,Z=Y.length,U;if(Z===1)U=Y[0];else if(Z<=6){U="";for(let z=0;z<Z;z++)U+=z%2===0?Y[z]:B(Y[z])}else{let z=Array(Z);for(let W=0;W<Z;W++)z[W]=W%2===0?Y[W]:B(Y[W]);U=z.join("")}let X=Q(F.timestamp),G=D(F.level),V=typeof $==="function"?$(F.category):F.category.join($);return`${E({timestamp:X,level:G,category:V,message:U,record:F})}${J}`}}function Nt1(A={}){let Q=A.format,$=typeof A.timestampStyle>"u"?"dim":A.timestampStyle,B=A.timestampColor??null,D=`${$==null?"":Jv0[$]}${B==null?"":Dv0[B]}`,J=$==null&&B==null?"":Bv0,E=typeof A.levelStyle>"u"?"bold":A.levelStyle,F=A.levelColors??R9A,Y=typeof A.categoryStyle>"u"?"dim":A.categoryStyle,Z=A.categoryColor??null,U=`${Y==null?"":Jv0[Y]}${Z==null?"":Dv0[Z]}`,X=Y==null&&Z==null?"":Bv0;return Ev0({timestamp:"date-time-tz",value(G,V){return V(G,{colors:!0})},...A,format({timestamp:G,level:V,category:K,message:z,record:W}){let I=F[W.level];return G=G==null?null:`${D}${G}${J}`,V=`${E==null?"":Jv0[E]}${I==null?"":Dv0[I]}${V}${E==null&&I==null?"":Bv0}`,Q==null?`${G==null?"":`${G} `}${V} ${U}${K}:${X} ${z}`:Q({timestamp:G,level:V,category:`${U}${K}${X}`,message:z,record:W})}})}function J80(A={}){let Q=qt1(A.lineEnding);if(!A.categorySeparator&&!A.message&&!A.properties)return(F)=>{if(F.message.length===3)return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:F.message[0]+JSON.stringify(F.message[1])+F.message[2],logger:F.category.join("."),properties:F.properties},B80)+Q;if(F.message.length===1)return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:F.message[0],logger:F.category.join("."),properties:F.properties},B80)+Q;let Y=F.message[0];for(let Z=1;Z<F.message.length;Z++)Y+=Z&1?JSON.stringify(F.message[Z]):F.message[Z];return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:Y,logger:F.category.join("."),properties:F.properties},B80)+Q};let $=A.message==="template",B=A.properties??"nest:properties",D;if(typeof A.categorySeparator==="function")D=A.categorySeparator;else{let F=A.categorySeparator??".";D=(Y)=>Y.join(F)}let J;if(B==="flatten")J=(F)=>F;else if(B.startsWith("prepend:")){let F=B.substring(8);if(F==="")throw TypeError(`Invalid properties option: ${JSON.stringify(B)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);J=(Y)=>{let Z={};for(let U in Y)Z[`${F}${U}`]=Y[U];return Z}}else if(B.startsWith("nest:")){let F=B.substring(5);J=(Y)=>({[F]:Y})}else throw TypeError(`Invalid properties option: ${JSON.stringify(B)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let E;if($)E=(F)=>{if(typeof F.rawMessage==="string")return F.rawMessage;let Y="";for(let Z=0;Z<F.rawMessage.length;Z++)Y+=Z%2<1?F.rawMessage[Z]:"{}";return Y};else E=(F)=>{let Y=F.message.length;if(Y===1)return F.message[0];let Z="";for(let U=0;U<Y;U++)Z+=U%2<1?F.message[U]:JSON.stringify(F.message[U]);return Z};return(F)=>{return JSON.stringify({"@timestamp":new Date(F.timestamp).toISOString(),level:F.level==="warning"?"WARN":F.level.toUpperCase(),message:E(F),logger:D(F.category),...J(F.properties)},B80)+Q}}function wc(A){let Q="",$=[];for(let J=0;J<A.message.length;J++)if(J%2===0)Q+=A.message[J];else Q+="%o",$.push(A.message[J]);let B=new Date(A.timestamp);return[`%c${`${B.getUTCHours().toString().padStart(2,"0")}:${B.getUTCMinutes().toString().padStart(2,"0")}:${B.getUTCSeconds().toString().padStart(2,"0")}.${B.getUTCMilliseconds().toString().padStart(3,"0")}`} %c${Ht1[A.level]}%c %c${A.category.join("·")} %c${Q}`,"color: gray;",_9A[A.level],"background-color: default;","color: gray;","color: default;",...$]}var Ht1,It1,$80,LT,D80,Bv0="\x1B[0m",Dv0,Jv0,R9A,u9A,P9A,_9A;var Fv0=o(()=>{Wt1();Ht1={trace:"TRC",debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},It1=typeof document<"u"||typeof navigator<"u"&&navigator.product==="ReactNative"?(A)=>JSON.stringify(A):("Deno"in globalThis)&&("inspect"in globalThis.Deno)&&typeof globalThis.Deno.inspect==="function"?(A,Q)=>globalThis.Deno.inspect(A,{strAbbreviateSize:1/0,iterableLimit:1/0,...Q}):Q80!=null&&("inspect"in Q80)&&typeof A80==="function"?(A,Q)=>A80(A,{maxArrayLength:1/0,maxStringLength:1/0,...Q}):(A)=>JSON.stringify(A);$80={"date-time-timezone":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y} +00:00`},"date-time-tz":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y} +00`},"date-time":(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate()),J=i5(Q.getUTCHours()),E=i5(Q.getUTCMinutes()),F=i5(Q.getUTCSeconds()),Y=MT(Q.getUTCMilliseconds());return`${$}-${B}-${D} ${J}:${E}:${F}.${Y}`},"time-timezone":(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J} +00:00`},"time-tz":(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J} +00`},time:(A)=>{let Q=new Date(A),$=i5(Q.getUTCHours()),B=i5(Q.getUTCMinutes()),D=i5(Q.getUTCSeconds()),J=MT(Q.getUTCMilliseconds());return`${$}:${B}:${D}.${J}`},date:(A)=>{let Q=new Date(A),$=Q.getUTCFullYear(),B=i5(Q.getUTCMonth()+1),D=i5(Q.getUTCDate());return`${$}-${B}-${D}`},rfc3339:(A)=>new Date(A).toISOString(),none:()=>null},LT={ABBR:Ht1,abbr:{trace:"trc",debug:"dbg",info:"inf",warning:"wrn",error:"err",fatal:"ftl"},FULL:{trace:"TRACE",debug:"DEBUG",info:"INFO",warning:"WARNING",error:"ERROR",fatal:"FATAL"},full:{trace:"trace",debug:"debug",info:"info",warning:"warning",error:"error",fatal:"fatal"},L:{trace:"T",debug:"D",info:"I",warning:"W",error:"E",fatal:"F"},l:{trace:"t",debug:"d",info:"i",warning:"w",error:"e",fatal:"f"}};D80=Ev0(),Dv0={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},Jv0={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},R9A={trace:null,debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};u9A=Nt1();P9A=J80(),_9A={trace:"background-color: gray; color: white;",debug:"background-color: gray; color: white;",info:"background-color: white; color: black;",warning:"background-color: orange; color: black;",error:"background-color: red; color: white;",fatal:"background-color: maroon; color: white;"}});function Ct1(A){if(typeof A==="function")return A;return T9A(A)}function T9A(A){if(A==null)return()=>!1;if(A==="fatal")return(Q)=>Q.level==="fatal";else if(A==="error")return(Q)=>Q.level==="fatal"||Q.level==="error";else if(A==="warning")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning";else if(A==="info")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning"||Q.level==="info";else if(A==="debug")return(Q)=>Q.level==="fatal"||Q.level==="error"||Q.level==="warning"||Q.level==="info"||Q.level==="debug";else if(A==="trace")return()=>!0;throw TypeError(`Invalid log level: ${A}.`)}var wt1=()=>{};function Mc(A={}){let Q=A.formatter??wc,$={trace:"debug",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"error",...A.levelMap??{}},B=A.console??globalThis.console,D=(I)=>{let H=Q(I),q=$[I.level];if(q===void 0)throw TypeError(`Invalid log level: ${I.level}.`);if(typeof H==="string"){let N=H.replace(/\r?\n$/,"");B[q](N)}else B[q](...H)};if(!A.nonBlocking)return D;let J=A.nonBlocking===!0?{}:A.nonBlocking,E=J.bufferSize??100,F=J.flushInterval??100,Y=[],Z=null,U=!1,X=!1,G=E*2;function V(){if(Y.length===0)return;let I=Y.splice(0);for(let H of I)try{D(H)}catch{}}function K(){if(X)return;X=!0,setTimeout(()=>{X=!1,V()},0)}function z(){if(Z!==null||U)return;Z=setInterval(()=>{V()},F)}let W=(I)=>{if(U)return;if(Y.length>=G)Y.shift();if(Y.push(I),Y.length>=E)K();else if(Z===null)z()};return W[Symbol.dispose]=()=>{if(U=!0,Z!==null)clearInterval(Z),Z=null;V()},W}var Yv0=o(()=>{Fv0()});function v9A(A){return A.category.length===0||A.category.length===1&&A.category[0]==="logtape"||A.category.length===2&&A.category[0]==="logtape"&&A.category[1]==="meta"}function k9A(A){let Q=A?Y80:Z80;if(typeof globalThis.EdgeRuntime!=="string"&&"process"in globalThis&&!("Deno"in globalThis)){let B=globalThis.process,D=B?.on;if(typeof D==="function"){D.call(B,"exit",Q);return}}let $=globalThis.addEventListener;if(typeof $!=="function")return;if("Deno"in globalThis)$.call(globalThis,"unload",Q);else $.call(globalThis,"pagehide",Q)}function Oc(A){if(F80!=null&&!A.reset)throw new YK("Already configured; if you want to reset, turn on the reset flag.");if(Lc.size>0)throw new YK("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");OT();try{S9A(A,!1)}catch(Q){if(Q instanceof YK)OT();throw Q}}function S9A(A,Q){F80=A;let $=!1,B=new Set;for(let J of A.loggers){if(v9A(J))$=!0;let E=Array.isArray(J.category)?JSON.stringify(J.category):JSON.stringify([J.category]);if(B.has(E))throw new YK(`Duplicate logger configuration for category: ${E}. Each category can only be configured once.`);B.add(E);let F=UX.getLogger(J.category);for(let Y of J.sinks??[]){let Z=A.sinks[Y];if(!Z)throw new YK(`Sink not found: ${Y}.`);F.sinks.push(Z)}if(F.parentSinks=J.parentSinks??"inherit",J.lowestLevel!==void 0)F.lowestLevel=J.lowestLevel;for(let Y of J.filters??[]){let Z=A.filters?.[Y];if(Z===void 0)throw new YK(`Filter not found: ${Y}.`);F.filters.push(Ct1(Z))}Mt1.add(F)}UX.getLogger().contextLocalStorage=A.contextLocalStorage;for(let J of Object.values(A.sinks)){if(Symbol.asyncDispose in J)if(Q)Lc.add(J);else throw new YK("Async disposables cannot be used with configureSync().");if(Symbol.dispose in J)E80.add(J)}for(let J of Object.values(A.filters??{})){if(J==null||typeof J==="string")continue;if(Symbol.asyncDispose in J)if(Q)Lc.add(J);else throw new YK("Async disposables cannot be used with configureSync().");if(Symbol.dispose in J)E80.add(J)}k9A(Q);let D=UX.getLogger(["logtape","meta"]);if(!$)D.sinks.push(Mc());D.info("LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.",{metaLoggerCategory:["logtape","meta"],dismissLevel:"info"})}function Zv0(){return F80}function OT(){Z80(),f9A()}function f9A(){let A=UX.getLogger([]);A.resetDescendants(),delete A.contextLocalStorage,Mt1.clear(),F80=null}async function Y80(){Z80();let A=[];for(let Q of Lc)A.push(Q[Symbol.asyncDispose]()),Lc.delete(Q);await Promise.all(A)}function Z80(){for(let A of E80)A[Symbol.dispose]();E80.clear()}var F80=null,Mt1,E80,Lc,YK;var Lt1=o(()=>{wt1();t20();Yv0();Mt1=new Set,E80=new Set,Lc=new Set;YK=class extends Error{constructor(A){super(A);this.name="ConfigureError"}}});var U80=o(()=>{t20();Fv0();Yv0();Lt1()});var Ot1,y9A,u;var c0=o(()=>{U80();bQ();if(Zv0()===null)Oc({sinks:{console:Mc({formatter:(A)=>{let Q=wc(A);return Object.keys(A.properties).length>0?[...Q,A.properties]:Q}})},loggers:[{category:["logtape","meta"],sinks:["console"],lowestLevel:"warning"},{category:[],sinks:["console"]}]});Ot1=NT.union([NT.literal("error"),NT.literal("warn"),NT.literal("info"),NT.literal("debug")]),y9A=$v0(),u=y9A});import g9A from"os";import X80 from"path";var DH,DL,JH,jT,Qq5,$q5,Bq5,m9A,d9A;var G80=o(()=>{DH=g9A.homedir(),{env:DL}=process,JH=DL.XDG_DATA_HOME||(DH?X80.join(DH,".local","share"):void 0),jT=DL.XDG_CONFIG_HOME||(DH?X80.join(DH,".config"):void 0),Qq5=DL.XDG_STATE_HOME||(DH?X80.join(DH,".local","state"):void 0),$q5=DL.XDG_CACHE_HOME||(DH?X80.join(DH,".cache"):void 0),Bq5=DL.XDG_RUNTIME_DIR||void 0,m9A=(DL.XDG_DATA_DIRS||"/usr/local/share/:/usr/share/").split(":");if(JH)m9A.unshift(JH);d9A=(DL.XDG_CONFIG_DIRS||"/etc/xdg").split(":");if(jT)d9A.unshift(jT)});import{homedir as V80}from"node:os";import ZK from"node:path";var jt1,p9A,Rt1,c9A,RT,l9A,jc,i9A,aB;var sE=o(()=>{G80();jt1=ZK.join(V80(),".local/share"),p9A=process.platform==="win32"||process.platform==="darwin"?jt1:JH??jt1,Rt1=ZK.join(V80(),".config"),c9A=process.platform==="win32"||process.platform==="darwin"?Rt1:jT??Rt1,RT=ZK.join(p9A,"amp"),l9A=ZK.join(c9A,"amp"),jc=ZK.join(l9A,"tools"),i9A=process.platform==="win32"?ZK.join(process.env.LOCALAPPDATA??ZK.join(V80(),"AppData","Local"),"amp"):ZK.join(process.env.XDG_CACHE_HOME??ZK.join(V80(),".cache"),"amp"),aB=i9A});function n9A(A){return A.trim().toLowerCase()}function E9(A){let Q=n9A(A);if(Q.length===0)return!1;if(Q.endsWith("@ampcode.com")||Q==="auth-bypass-user@example.com")return!0;return!1}function U4(A,Q,$=Q+"s"){return A===1?Q:$}var G5=()=>{};function K80(A){Promise.resolve().then(()=>{try{A()}catch(Q){console.error(Q)}})}function _t1(A){let Q=A._cleanup;if(Q===void 0)return;if(A._cleanup=void 0,!Q)return;try{if(typeof Q==="function")Q();else if(Q&&typeof Q.unsubscribe==="function")Q.unsubscribe()}catch($){console.error("cleanupSubscription",$)}}function Vv0(A){A._observer=void 0,A._queue=void 0,A._state="closed"}function o9A(A){let Q=A._queue;if(!Q)return;A._queue=void 0,A._state="ready";for(let $ of Q)if(Tt1(A,$.type,$.value),A._state==="closed")break}function Tt1(A,Q,$){A._state="running";let B=A._observer;try{switch(Q){case"next":if(B&&typeof B.next==="function")B.next($);break;case"error":if(Vv0(A),B&&typeof B.error==="function")B.error($);else throw $;break;case"complete":if(Vv0(A),B&&typeof B.complete==="function")B.complete();break}}catch(D){console.error("notifySubscription",D)}if(A._state==="closed")_t1(A);else if(A._state==="running")A._state="ready"}function Gv0(A,Q,$){if(A._state==="closed")return;if(A._state==="buffering"){A._queue=A._queue||[],A._queue.push({type:Q,value:$});return}if(A._state!=="ready"){A._state="buffering",A._queue=[{type:Q,value:$}],K80(()=>o9A(A));return}Tt1(A,Q,$)}class vt1{_cleanup;_observer;_queue;_state;constructor(A,Q){this._cleanup=void 0,this._observer=A,this._queue=void 0,this._state="initializing";let $=new kt1(this);try{this._cleanup=Q.call(void 0,$)}catch(B){$.error(B)}if(this._state==="initializing")this._state="ready"}get closed(){return this._state==="closed"}unsubscribe(){if(this._state!=="closed")Vv0(this),_t1(this)}}class kt1{_subscription;constructor(A){this._subscription=A}get closed(){return this._subscription._state==="closed"}next(A){Gv0(this._subscription,"next",A)}error(A){Gv0(this._subscription,"error",A)}complete(){Gv0(this._subscription,"complete")}}function Y2(A){if(typeof A==="function")A();else if(A&&typeof A.unsubscribe==="function")A.unsubscribe()}class uT{_baseObserver;_pendingPromises;constructor(A){this._baseObserver=A,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch((A)=>this._baseObserver.error(A))}error(A){this._baseObserver.error(A)}schedule(A){let Q=Promise.all(this._pendingPromises),$=[],B=(J)=>$.push(J),D=Promise.resolve().then(async()=>{await Q,await A(B),this._pendingPromises.delete(D);for(let J of $)this._baseObserver.next(J)}).catch((J)=>{this._pendingPromises.delete(D),this._baseObserver.error(J)});this._pendingPromises.add(D)}}var g0;var PT=o(()=>{if(!Symbol.observable)Symbol.observable=Symbol("observable");g0=class g0{_subscriber;constructor(A){if(!(this instanceof g0))throw TypeError("Observable cannot be called as a function");if(typeof A!=="function")throw TypeError("Observable initializer must be a function");this._subscriber=A}subscribe(A,Q,$){if(typeof A!=="object"||A===null)A={next:A,error:Q,complete:$};return new vt1(A,this._subscriber)}pipe(A,...Q){let $=this;for(let B of[A,...Q])$=B($);return $}[Symbol.observable](){return this}static from(A){let Q=typeof g0==="function"?g0:g0;if(A==null)throw TypeError(A+" is not an object");let $=A[Symbol.observable];if(typeof $==="function"){let D=$.call(A);if(Object(D)!==D)throw TypeError(D+" is not an object");if(D instanceof g0)return D;return new Q((J)=>D.subscribe(J))}let B=A[Symbol.iterator];if(typeof B==="function")return new Q((D)=>{K80(()=>{if(D.closed)return;for(let J of B.call(A))if(D.next(J),D.closed)return;D.complete()})});if(Array.isArray(A))return new Q((D)=>{K80(()=>{if(D.closed)return;for(let J of A)if(D.next(J),D.closed)return;D.complete()})});throw TypeError(A+" is not observable")}static of(...A){return new(typeof g0==="function"?g0:g0)(($)=>{K80(()=>{if($.closed)return;for(let B of A)if($.next(B),$.closed)return;$.complete()})})}static get[Symbol.species](){return g0}}});var d4,o1;var z80=o(()=>{PT();d4=class d4 extends g0{_observers=new Set;constructor(){super((A)=>{return this._observers.add(A),()=>this._observers.delete(A)})}next(A){for(let Q of this._observers)Q.next(A)}error(A){for(let Q of this._observers)Q.error(A)}complete(){for(let A of this._observers)A.complete()}};o1=class o1 extends d4{currentValue;constructor(A){super();this.currentValue=A}next(A){this.currentValue=A,super.next(A)}subscribe(A,Q,$){if(typeof A!=="object"||A===null){let B={};if(A)B.next=A;if(Q)B.error=Q;if($)B.complete=$;A=B}return A.next?.(this.currentValue),super.subscribe(A)}getValue(){return this.currentValue}}});var r9A,Kv0;var St1=o(()=>{PT();z80();r9A=class r9A extends Set{subject=new o1(this);add(A){return super.add(A),this.subject.next(this),this}delete(A){let Q=super.delete(A);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()}};Kv0=class Kv0 extends Map{subject=new o1(this);set(A,Q){return super.set(A,Q),this.subject.next(this),this}delete(A){let Q=super.delete(A);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 W80(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let $=Array.isArray(A),B=Array.isArray(Q);if($!==B)return!1;if($&&B)return A.length===Q.length&&A.every((J,E)=>W80(J,Q[E]));let D=new Set([...Object.keys(A),...Object.keys(Q)]);for(let J of D)if(!W80(A[J],Q[J]))return!1;return!0}var I80;var zv0=o(()=>{I80={now:()=>Date.now(),schedule:(A,Q)=>{let $=setTimeout(A,Q);return()=>clearTimeout($)}}});async function S1(A,Q){return new Promise(($,B)=>{let D,J=()=>{D?.unsubscribe(),B(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",J,{once:!0}),D=A.subscribe({next:(E)=>{D?.unsubscribe(),Q?.removeEventListener("abort",J),$(E)},error:(E)=>{Q?.removeEventListener("abort",J),B(E)},complete:()=>{Q?.removeEventListener("abort",J),B("Observable completed without emitting a value")}})})}async function EH(A,Q){return new Promise(($,B)=>{let D,J=!1,E,F=()=>{E?.unsubscribe(),B(new DOMException("Aborted","AbortError"))};Q?.addEventListener("abort",F,{once:!0}),E=A.subscribe({next:(Y)=>{D=Y,J=!0},error:(Y)=>{Q?.removeEventListener("abort",F),B(Y)},complete:()=>{if(Q?.removeEventListener("abort",F),J)$(D);else B("Observable completed without emitting a value")}})})}async function yt1(A,Q){return new Promise(($,B)=>{let D=A.subscribe({error:B,complete:()=>$()});Q?.addEventListener("abort",()=>{D.unsubscribe(),B(new DOMException("Aborted","AbortError"))},{once:!0})})}function N2(A){return new g0((Q)=>{A.then(($)=>{Q.next($),Q.complete()}).catch(($)=>{Q.error($)})})}function E6(A){return new g0((Q)=>{let $=!1,B=new AbortController,D=B.signal;return(async()=>{try{D?.throwIfAborted();let E=await A(D);if(D?.throwIfAborted(),!$)Q.next(E),Q.complete()}catch(E){if(!$)if(D.aborted)Q.complete();else Q.error(E)}})(),()=>{$=!0,B.abort()}})}function N1(A){return(Q)=>{return new g0(($)=>{let B=new uT($),D=0,J=Q.subscribe({complete(){B.complete()},error(E){B.error(E)},next(E){B.schedule(async(F)=>{let Y=await A(E,D);D++,F(Y)})}});return()=>Y2(J)})}}function _T(A,Q=I80){return new g0(($)=>{let B=0,D=null,J=()=>{$.next(B++),D=Q.schedule(J,A)};return D=Q.schedule(J,A),()=>{if(D)D()}})}function UK(...A){return new g0((Q)=>{let $=0,B=A.map((D)=>D.subscribe({next:(J)=>Q.next(J),error:(J)=>Q.error(J),complete:()=>{if($++,$===A.length)Q.complete()}}));return()=>{xt1(B)}})}function jA(...A){if(A.length===0)return uc;return new g0((Q)=>{let $=Array(A.length),B=Array(A.length).fill(0),D=Array(A.length).fill(!1),J=0,E=[],F=new uT(Q);for(let Y=0;Y<A.length;Y++){let Z=A[Y];E.push(Z.subscribe({next(U){$[Y]=U,D[Y]=!0;let X=++B[Y];if(D.every(Boolean))F.schedule(async(G)=>{if(B[Y]===X)G([...$])})},error(U){F.error(U)},complete(){if(J++,J===A.length)F.complete()}}))}return()=>{xt1(E)}})}function e6(A){let $=A?.shouldCountRefs??!0,B=s9A++,D=(J,...E)=>{};return(J)=>{let E=new d4,F=null,Y=!1,Z,U=0;return new g0((X)=>{if(U++,Y)D("new subscriber, emitting buffered value",Z),X.next(Z);else D("new subscriber, no buffered value to emit");if(!F)F=J.subscribe({next:(V)=>{Y=!0,Z=V,E.next(V)},error:(V)=>E.error(V),complete:()=>E.complete()});let G=E.subscribe(X);return()=>{if(U--,G.unsubscribe(),$&&U===0){if(F)Y2(F),F=null;Y=!1}}})}}function xt1(A){for(let Q of A)if(Q)Y2(Q)}function XK(A){return(Q)=>{return new g0(($)=>{let B=Q.subscribe({next:(J)=>$.next(J),error:(J)=>$.error(J),complete:()=>$.complete()}),D=A.subscribe({next:()=>{$.complete(),B.unsubscribe(),D.unsubscribe()},error:(J)=>{$.error(J),B.unsubscribe()}});return()=>{B.unsubscribe(),D.unsubscribe()}})}}function FH(A){return(Q)=>{return new g0(($)=>{let B,D=Q.subscribe({next(J){B=J,$.next(J)},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D),A(B)}})}}function T4(A=W80){return(Q)=>{return new g0(($)=>{let B=ft1,D=new uT($),J=Q.subscribe({complete(){D.complete()},error(E){D.error(E)},next(E){D.schedule(async(F)=>{if(B===ft1||!A(B,E))B=E,F(E)})}});return()=>Y2(J)})}}function TT(A){return t9A(typeof A==="function"?{next:A}:A)}function t9A(A){return(Q)=>new g0(($)=>{let B=typeof A==="function"?A():A,D=Q.subscribe({next(J){if(B.next)try{B.next(J)}catch(E){$.error(E);return}$.next(J)},error(J){if(B.error)try{B.error(J)}catch(E){$.error(E);return}$.error(J)},complete(){if(B.complete)try{B.complete()}catch(J){$.error(J);return}$.complete()}});return()=>Y2(D)})}function f$(A){return(Q)=>{return new g0(($)=>{let B=!1,D=Q.subscribe({next:(E)=>{B=!0,clearTimeout(J),$.next(E)},error:(E)=>{clearTimeout(J),$.error(E)},complete:()=>{clearTimeout(J),$.complete()}}),J=setTimeout(()=>{if(!B)D.unsubscribe(),$.error(new H80(`Operation timed out after ${A}ms`))},A);return()=>{clearTimeout(J),D.unsubscribe()}})}}function IA(A){return(Q)=>new g0(($)=>{let B;try{$.next(A),B=Q.subscribe({next(D){$.next(D)},error(D){$.error(D)},complete(){$.complete()}})}catch(D){$.error(D)}return()=>{if(B)Y2(B)}})}function u8(A){return(Q)=>new g0(($)=>{let B=0,D=Q.subscribe({next(J){if(B<A){if($.next(J),B++,B===A)$.complete(),Y2(D)}},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D)}})}function bt1(A){return(Q)=>new g0(($)=>{let B=0,D=Q.subscribe({next(J){if(B>=A)$.next(J);else B++},error(J){$.error(J)},complete(){$.complete()}});return()=>{Y2(D)}})}function y4(A){return(Q)=>{return new g0(($)=>{let B=0,D=null,J=!1,E=()=>{if(J&&!D)$.complete()},F=Q.subscribe({next(Y){if(D)Y2(D),D=null;let Z;try{Z=A(Y,B++)}catch(U){$.error(U);return}D=Z.subscribe({next(U){$.next(U)},error(U){$.error(U)},complete(){D=null,E()}})},error(Y){$.error(Y)},complete(){J=!0,E()}});return()=>{if(Y2(F),D)Y2(D)}})}}function GK(A,Q){let $=Q?.scheduler??I80;return(B)=>new g0((D)=>{let J=null,E=null,F=!1,Y=B.subscribe({next:(Z)=>{if(E=Z,F=!0,J===null)J=$.schedule(()=>{if(F)D.next(E),F=!1;J=null},A)},error:(Z)=>D.error(Z),complete:()=>{if(J!==null)J();if(F)D.next(E);D.complete()}});return()=>{if(Y2(Y),J!==null)J()}})}function Iv0(A,Q){if(!Q.leading||!Q.trailing)throw Error("leading and trailing must be true");let $=Q.scheduler??I80;return(B)=>new g0((D)=>{let J=0,E=null,F=null,Y=!1,Z=B.subscribe({next:(U)=>{let X=$.now();if(F=U,Y=!0,X-J>=A)D.next(U),J=X,Y=!1;else if(E===null)E=$.schedule(()=>{if(Y)D.next(F),J=$.now(),Y=!1;E=null},A-(X-J));if(J===0)D.next(U),J=X,Y=!1},error:(U)=>D.error(U),complete:()=>{if(E!==null)E();if(Y)D.next(F);D.complete()}});return()=>{if(Y2(Z),E!==null)E()}})}function Pc(...A){return new g0((Q)=>{let $=0,B=null;function D(){if($>=A.length){Q.complete();return}B=A[$].subscribe({next:(E)=>Q.next(E),error:(E)=>Q.error(E),complete:()=>{$++,D()}})}return D(),()=>{if(B)Y2(B)}})}function YH(A){return(Q)=>new g0(($)=>{let B=0,D=!1,J=null,E=Q.subscribe({next(F){try{let Y=A(F,B++);if(J)Y2(J);J=Y.subscribe({next(Z){$.next(Z)},error(Z){$.error(Z)},complete(){if(J=null,D&&!J)$.complete()}})}catch(Y){$.error(Y)}},error(F){$.error(F)},complete(){if(D=!0,!J)$.complete()}});return()=>{if(Y2(E),J)Y2(J)}})}function _c({onSubscribe:A,onUnsubscribe:Q}){return($)=>new g0((B)=>{A?.();let D=$.subscribe(B);return()=>{Y2(D),Q?.()}})}function Tc(A){return(Q)=>g0.from(Q).pipe(y4(($)=>E6((B)=>A($,B))))}function y$(A){return(Q)=>new g0(($)=>{let B,D=Q.subscribe({next(J){$.next(J)},error(J){try{B=A(J).subscribe({next(F){$.next(F)},error(F){$.error(F)},complete(){$.complete()}})}catch(E){$.error(E)}},complete(){$.complete()}});return()=>{if(Y2(D),B)Y2(B)}})}function i3(A){return(Q)=>{return new g0(($)=>{let B=Q.subscribe({next(D){if(A(D))$.next(D)},error(D){$.error(D)},complete(){$.complete()}});return()=>Y2(B)})}}function ht1(A,Q){return($)=>{return new g0((B)=>{let D,J=0,E=new uT(B),F=$.subscribe({complete(){E.complete()},error(Y){E.error(Y)},next(Y){E.schedule(async(Z)=>{D=await A(J===0?typeof Q>"u"?Y:Q:D,Y,J++),Z(D)})}});return()=>Y2(F)})}}var uc,Wv0,s9A=0,ft1,H80;var Hv0=o(()=>{PT();zv0();z80();uc=new g0((A)=>{A.complete()}),Wv0=new g0(()=>{});ft1={};H80=class H80 extends Error{constructor(A="Timeout has occurred"){super(A);this.name="TimeoutError"}}});function vT(A,Q){return($)=>{return g0.from($).pipe(y4((B)=>B===XX?g0.of(XX):A(B).pipe(y$((D)=>g0.of(D instanceof Error?D:Error(D))),IA(XX))),e6(Q))}}function qv0(){return(A)=>g0.from(A).pipe(i3((Q)=>Q!==XX))}async function gt1(A,Q){let $=await S1(g0.from(A).pipe(qv0()),Q);if($ instanceof Error)throw $;return $}var XX;var mt1=o(()=>{PT();Hv0();XX=Symbol.for("@@pendingOperation")});var dt1=()=>{};var pt1=()=>{};var u1=o(()=>{St1();PT();mt1();Hv0();dt1();zv0();z80();pt1()});function E7A(){let A=typeof process==="object"?process.env.ProgramData:void 0;return A?`${A}\\ampcode`:"C:\\ProgramData\\ampcode"}function uv0(A){switch(A){case"darwin":return"/Library/Application Support/ampcode";case"android":case"cygwin":case"freebsd":case"netbsd":case"openbsd":case"linux":return"/etc/ampcode";case"win32":return E7A();case"aix":case"haiku":case"sunos":default:return null}}function st1(A){return uv0(A)}function tE(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let $=Array.isArray(A),B=Array.isArray(Q);if($!==B)return!1;if($&&B)return A.length===Q.length&&A.every((J,E)=>tE(J,Q[E]));let D=new Set([...Object.keys(A),...Object.keys(Q)]);for(let J of D)if(!tE(A[J],Q[J]))return!1;return!0}class WJ{#A=!1;#Q=[];async acquire(){return new Promise((A)=>{if(!this.#A)this.#A=!0,A();else this.#Q.push({resolve:A})})}async acquireWithTimeout(A,Q=`Mutex acquire timed out after ${A}ms`){return new Promise(($,B)=>{if(!this.#A){this.#A=!0,$();return}let D=!1,J,E={resolve:()=>{if(D)return;D=!0,clearTimeout(J),$()}};J=setTimeout(()=>{if(D)return;D=!0;let F=this.#Q.indexOf(E);if(F!==-1)this.#Q.splice(F,1);B(Error(Q))},A),this.#Q.push(E)})}release(){if(this.#Q.length>0)this.#Q.shift()?.resolve();else this.#A=!1}}var x$;var yT=o(()=>{x$={BITBUCKET_ENTERPRISE:"bitbucket-enterprise",CUSTOMER_MODEL_PROVIDER_KEYS:"customer-model-provider-keys",ACCEPT_ABUSE_DATA_RETENTION:"accept-abuse-data-retention",HARNESS_SYSTEM_PROMPT:"harness-system-prompt",NAMESPACE_REPOSITORIES_PAGE:"namespace-repositories-page",NAMESPACE_SKILLS_PAGE:"namespace-skills-page",OLD_CODEMIRROR_DIFFS:"old-codemirror-diffs",OPENAI_REGIONAL_NONENT:"openai-regional-nonent",PAYMENT_METHOD_EXEMPT:"payment-method-exempt",PIERRE_DIFFS:"pierre-diffs",RECV_OLD_CLIENT_EMAILS:"recv-old-client-emails",SIGNING_KEYS:"signing-keys",THREAD_ACTORS_TUI:"thread-actors-tui",THREAD_ACTORS_TRACES:"thread-actors-traces",V2:"v2",SERVER_PLUGINS:"server-plugins",THREAD_TIMING:"thread-timing",THREAD_TRACE_VIEWER:"thread-trace-viewer",USAGE_TOKEN_COUNT:"usage-token-count",WORKSPACE_ROLES:"workspace-roles"}});function dT(A){let Q=A.length;while(--Q>=0)A[Q]=0}function Tv0(A,Q,$,B,D){this.static_tree=A,this.extra_bits=Q,this.extra_base=$,this.elems=B,this.max_length=D,this.has_stree=A&&A.length}function vv0(A,Q){this.dyn_tree=A,this.max_code=0,this.stat_desc=Q}function GX(A,Q,$,B,D){this.good_length=A,this.max_lazy=Q,this.nice_length=$,this.max_chain=B,this.func=D}function qQA(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=k80,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(UQA*2),this.dyn_dtree=new Uint16Array((2*YQA+1)*2),this.bl_tree=new Uint16Array((2*ZQA+1)*2),UH(this.dyn_ltree),UH(this.dyn_dtree),UH(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(XQA+1),this.heap=new Uint16Array(2*nv0+1),UH(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*nv0+1),UH(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function mQA(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function ec(A){this.options=S80.assign({level:nQA,method:oQA,chunkSize:16384,windowBits:15,memLevel:8,strategy:aQA},A||{});let Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new U04,this.strm.avail_out=0;let $=mc.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if($!==T80)throw Error(ZL[$]);if(Q.header)mc.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let B;if(typeof Q.dictionary==="string")B=oc.string2buf(Q.dictionary);else if(X04.call(Q.dictionary)==="[object ArrayBuffer]")B=new Uint8Array(Q.dictionary);else B=Q.dictionary;if($=mc.deflateSetDictionary(this.strm,B),$!==T80)throw Error(ZL[$]);this._dict_set=!0}}function Dk0(A,Q){let $=new ec(Q);if($.push(A,!0),$.err)throw $.msg||ZL[$.err];return $.result}function rQA(A,Q){return Q=Q||{},Q.raw=!0,Dk0(A,Q)}function sQA(A,Q){return Q=Q||{},Q.gzip=!0,Dk0(A,Q)}function N$A(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x$A(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}function Al(A){this.options=S80.assign({chunkSize:65536,windowBits:15,to:""},A||{});let Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!(A&&A.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new U04,this.strm.avail_out=0;let $=zK.inflateInit2(this.strm,Q.windowBits);if($!==rc)throw Error(ZL[$]);if(this.header=new b$A,zK.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=oc.string2buf(Q.dictionary);else if(M04.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if($=zK.inflateSetDictionary(this.strm,Q.dictionary),$!==rc)throw Error(ZL[$])}}}function Jk0(A,Q){let $=new Al(Q);if($.push(A),$.err)throw $.msg||ZL[$.err];return $.result}function p$A(A,Q){return Q=Q||{},Q.raw=!0,Jk0(A,Q)}var H7A=0,pe1=1,q7A=2,N7A=3,C7A=258,ev0=29,sc=256,pc,hT=30,Ak0=19,ce1,EL=15,_v0=16,w7A=7,Qk0=256,le1=16,ie1=17,ne1=18,cv0,P80,M7A,ae1,L7A=512,KK,gc,cc,lc,$k0,_80,oe1,re1,se1,te1=(A)=>{return A<256?cc[A]:cc[256+(A>>>7)]},ic=(A,Q)=>{A.pending_buf[A.pending++]=Q&255,A.pending_buf[A.pending++]=Q>>>8&255},oB=(A,Q,$)=>{if(A.bi_valid>_v0-$)A.bi_buf|=Q<<A.bi_valid&65535,ic(A,A.bi_buf),A.bi_buf=Q>>_v0-A.bi_valid,A.bi_valid+=$-_v0;else A.bi_buf|=Q<<A.bi_valid&65535,A.bi_valid+=$},VX=(A,Q,$)=>{oB(A,$[Q*2],$[Q*2+1])},ee1=(A,Q)=>{let $=0;do $|=A&1,A>>>=1,$<<=1;while(--Q>0);return $>>>1},O7A=(A)=>{if(A.bi_valid===16)ic(A,A.bi_buf),A.bi_buf=0,A.bi_valid=0;else if(A.bi_valid>=8)A.pending_buf[A.pending++]=A.bi_buf&255,A.bi_buf>>=8,A.bi_valid-=8},j7A=(A,Q)=>{let{dyn_tree:$,max_code:B}=Q,D=Q.stat_desc.static_tree,J=Q.stat_desc.has_stree,E=Q.stat_desc.extra_bits,F=Q.stat_desc.extra_base,Y=Q.stat_desc.max_length,Z,U,X,G,V,K,z=0;for(G=0;G<=EL;G++)A.bl_count[G]=0;$[A.heap[A.heap_max]*2+1]=0;for(Z=A.heap_max+1;Z<ce1;Z++){if(U=A.heap[Z],G=$[$[U*2+1]*2+1]+1,G>Y)G=Y,z++;if($[U*2+1]=G,U>B)continue;if(A.bl_count[G]++,V=0,U>=F)V=E[U-F];if(K=$[U*2],A.opt_len+=K*(G+V),J)A.static_len+=K*(D[U*2+1]+V)}if(z===0)return;do{G=Y-1;while(A.bl_count[G]===0)G--;A.bl_count[G]--,A.bl_count[G+1]+=2,A.bl_count[Y]--,z-=2}while(z>0);for(G=Y;G!==0;G--){U=A.bl_count[G];while(U!==0){if(X=A.heap[--Z],X>B)continue;if($[X*2+1]!==G)A.opt_len+=(G-$[X*2+1])*$[X*2],$[X*2+1]=G;U--}}},A04=(A,Q,$)=>{let B=Array(EL+1),D=0,J,E;for(J=1;J<=EL;J++)D=D+$[J-1]<<1,B[J]=D;for(E=0;E<=Q;E++){let F=A[E*2+1];if(F===0)continue;A[E*2]=ee1(B[F]++,F)}},R7A=()=>{let A,Q,$,B,D,J=Array(EL+1);$=0;for(B=0;B<ev0-1;B++){$k0[B]=$;for(A=0;A<1<<cv0[B];A++)lc[$++]=B}lc[$-1]=B,D=0;for(B=0;B<16;B++){_80[B]=D;for(A=0;A<1<<P80[B];A++)cc[D++]=B}D>>=7;for(;B<hT;B++){_80[B]=D<<7;for(A=0;A<1<<P80[B]-7;A++)cc[256+D++]=B}for(Q=0;Q<=EL;Q++)J[Q]=0;A=0;while(A<=143)KK[A*2+1]=8,A++,J[8]++;while(A<=255)KK[A*2+1]=9,A++,J[9]++;while(A<=279)KK[A*2+1]=7,A++,J[7]++;while(A<=287)KK[A*2+1]=8,A++,J[8]++;A04(KK,pc+1,J);for(A=0;A<hT;A++)gc[A*2+1]=5,gc[A*2]=ee1(A,5);oe1=new Tv0(KK,cv0,sc+1,pc,EL),re1=new Tv0(gc,P80,0,hT,EL),se1=new Tv0([],M7A,0,Ak0,w7A)},Q04=(A)=>{let Q;for(Q=0;Q<pc;Q++)A.dyn_ltree[Q*2]=0;for(Q=0;Q<hT;Q++)A.dyn_dtree[Q*2]=0;for(Q=0;Q<Ak0;Q++)A.bl_tree[Q*2]=0;A.dyn_ltree[Qk0*2]=1,A.opt_len=A.static_len=0,A.sym_next=A.matches=0},$04=(A)=>{if(A.bi_valid>8)ic(A,A.bi_buf);else if(A.bi_valid>0)A.pending_buf[A.pending++]=A.bi_buf;A.bi_buf=0,A.bi_valid=0},Je1=(A,Q,$,B)=>{let D=Q*2,J=$*2;return A[D]<A[J]||A[D]===A[J]&&B[Q]<=B[$]},kv0=(A,Q,$)=>{let B=A.heap[$],D=$<<1;while(D<=A.heap_len){if(D<A.heap_len&&Je1(Q,A.heap[D+1],A.heap[D],A.depth))D++;if(Je1(Q,B,A.heap[D],A.depth))break;A.heap[$]=A.heap[D],$=D,D<<=1}A.heap[$]=B},Ee1=(A,Q,$)=>{let B,D,J=0,E,F;if(A.sym_next!==0)do if(B=A.pending_buf[A.sym_buf+J++]&255,B+=(A.pending_buf[A.sym_buf+J++]&255)<<8,D=A.pending_buf[A.sym_buf+J++],B===0)VX(A,D,Q);else{if(E=lc[D],VX(A,E+sc+1,Q),F=cv0[E],F!==0)D-=$k0[E],oB(A,D,F);if(B--,E=te1(B),VX(A,E,$),F=P80[E],F!==0)B-=_80[E],oB(A,B,F)}while(J<A.sym_next);VX(A,Qk0,Q)},lv0=(A,Q)=>{let $=Q.dyn_tree,B=Q.stat_desc.static_tree,D=Q.stat_desc.has_stree,J=Q.stat_desc.elems,E,F,Y=-1,Z;A.heap_len=0,A.heap_max=ce1;for(E=0;E<J;E++)if($[E*2]!==0)A.heap[++A.heap_len]=Y=E,A.depth[E]=0;else $[E*2+1]=0;while(A.heap_len<2)if(Z=A.heap[++A.heap_len]=Y<2?++Y:0,$[Z*2]=1,A.depth[Z]=0,A.opt_len--,D)A.static_len-=B[Z*2+1];Q.max_code=Y;for(E=A.heap_len>>1;E>=1;E--)kv0(A,$,E);Z=J;do E=A.heap[1],A.heap[1]=A.heap[A.heap_len--],kv0(A,$,1),F=A.heap[1],A.heap[--A.heap_max]=E,A.heap[--A.heap_max]=F,$[Z*2]=$[E*2]+$[F*2],A.depth[Z]=(A.depth[E]>=A.depth[F]?A.depth[E]:A.depth[F])+1,$[E*2+1]=$[F*2+1]=Z,A.heap[1]=Z++,kv0(A,$,1);while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],j7A(A,Q),A04($,Y,A.bl_count)},Fe1=(A,Q,$)=>{let B,D=-1,J,E=Q[1],F=0,Y=7,Z=4;if(E===0)Y=138,Z=3;Q[($+1)*2+1]=65535;for(B=0;B<=$;B++){if(J=E,E=Q[(B+1)*2+1],++F<Y&&J===E)continue;else if(F<Z)A.bl_tree[J*2]+=F;else if(J!==0){if(J!==D)A.bl_tree[J*2]++;A.bl_tree[le1*2]++}else if(F<=10)A.bl_tree[ie1*2]++;else A.bl_tree[ne1*2]++;if(F=0,D=J,E===0)Y=138,Z=3;else if(J===E)Y=6,Z=3;else Y=7,Z=4}},Ye1=(A,Q,$)=>{let B,D=-1,J,E=Q[1],F=0,Y=7,Z=4;if(E===0)Y=138,Z=3;for(B=0;B<=$;B++){if(J=E,E=Q[(B+1)*2+1],++F<Y&&J===E)continue;else if(F<Z)do VX(A,J,A.bl_tree);while(--F!==0);else if(J!==0){if(J!==D)VX(A,J,A.bl_tree),F--;VX(A,le1,A.bl_tree),oB(A,F-3,2)}else if(F<=10)VX(A,ie1,A.bl_tree),oB(A,F-3,3);else VX(A,ne1,A.bl_tree),oB(A,F-11,7);if(F=0,D=J,E===0)Y=138,Z=3;else if(J===E)Y=6,Z=3;else Y=7,Z=4}},u7A=(A)=>{let Q;Fe1(A,A.dyn_ltree,A.l_desc.max_code),Fe1(A,A.dyn_dtree,A.d_desc.max_code),lv0(A,A.bl_desc);for(Q=Ak0-1;Q>=3;Q--)if(A.bl_tree[ae1[Q]*2+1]!==0)break;return A.opt_len+=3*(Q+1)+5+5+4,Q},P7A=(A,Q,$,B)=>{let D;oB(A,Q-257,5),oB(A,$-1,5),oB(A,B-4,4);for(D=0;D<B;D++)oB(A,A.bl_tree[ae1[D]*2+1],3);Ye1(A,A.dyn_ltree,Q-1),Ye1(A,A.dyn_dtree,$-1)},_7A=(A)=>{let Q=4093624447,$;for($=0;$<=31;$++,Q>>>=1)if(Q&1&&A.dyn_ltree[$*2]!==0)return 0;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return 1;for($=32;$<sc;$++)if(A.dyn_ltree[$*2]!==0)return 1;return 0},Ze1=!1,T7A=(A)=>{if(!Ze1)R7A(),Ze1=!0;A.l_desc=new vv0(A.dyn_ltree,oe1),A.d_desc=new vv0(A.dyn_dtree,re1),A.bl_desc=new vv0(A.bl_tree,se1),A.bi_buf=0,A.bi_valid=0,Q04(A)},B04=(A,Q,$,B)=>{if(oB(A,(H7A<<1)+(B?1:0),3),$04(A),ic(A,$),ic(A,~$),$)A.pending_buf.set(A.window.subarray(Q,Q+$),A.pending);A.pending+=$},v7A=(A)=>{oB(A,pe1<<1,3),VX(A,Qk0,KK),O7A(A)},k7A=(A,Q,$,B)=>{let D,J,E=0;if(A.level>0){if(A.strm.data_type===2)A.strm.data_type=_7A(A);if(lv0(A,A.l_desc),lv0(A,A.d_desc),E=u7A(A),D=A.opt_len+3+7>>>3,J=A.static_len+3+7>>>3,J<=D)D=J}else D=J=$+5;if($+4<=D&&Q!==-1)B04(A,Q,$,B);else if(A.strategy===4||J===D)oB(A,(pe1<<1)+(B?1:0),3),Ee1(A,KK,gc);else oB(A,(q7A<<1)+(B?1:0),3),P7A(A,A.l_desc.max_code+1,A.d_desc.max_code+1,E+1),Ee1(A,A.dyn_ltree,A.dyn_dtree);if(Q04(A),B)$04(A)},S7A=(A,Q,$)=>{if(A.pending_buf[A.sym_buf+A.sym_next++]=Q,A.pending_buf[A.sym_buf+A.sym_next++]=Q>>8,A.pending_buf[A.sym_buf+A.sym_next++]=$,Q===0)A.dyn_ltree[$*2]++;else A.matches++,Q--,A.dyn_ltree[(lc[$]+sc+1)*2]++,A.dyn_dtree[te1(Q)*2]++;return A.sym_next===A.sym_end},f7A,y7A,x7A,b7A,h7A,g7A,m7A=(A,Q,$,B)=>{let D=A&65535|0,J=A>>>16&65535|0,E=0;while($!==0){E=$>2000?2000:$,$-=E;do D=D+Q[B++]|0,J=J+D|0;while(--E);D%=65521,J%=65521}return D|J<<16|0},nc,d7A=()=>{let A,Q=[];for(var $=0;$<256;$++){A=$;for(var B=0;B<8;B++)A=A&1?3988292384^A>>>1:A>>>1;Q[$]=A}return Q},p7A,c7A=(A,Q,$,B)=>{let D=p7A,J=B+$;A^=-1;for(let E=B;E<J;E++)A=A>>>8^D[(A^Q[E])&255];return A^-1},K7,ZL,GL,l7A,iv0,i7A,GH,n7A,VH,a7A,o7A,eE,Ue1,o7,Xe1,KX,r7A,Sv0,s7A,t7A,L80,e7A,AQA,QQA,$QA,k80,BQA=9,DQA=15,JQA=8,EQA=29,FQA=256,nv0,YQA=30,ZQA=19,UQA,XQA=15,J3=3,XH=258,zX,GQA=32,gT=42,Bk0=57,av0=69,ov0=73,rv0=91,sv0=103,FL=113,bc=666,b$=1,pT=2,UL=3,cT=4,VQA=3,YL=(A,Q)=>{return A.msg=ZL[Q],Q},Ge1=(A)=>{return A*2-(A>4?9:0)},UH=(A)=>{let Q=A.length;while(--Q>=0)A[Q]=0},KQA=(A)=>{let Q,$,B,D=A.w_size;Q=A.hash_size,B=Q;do $=A.head[--B],A.head[B]=$>=D?$-D:0;while(--Q);Q=D,B=Q;do $=A.prev[--B],A.prev[B]=$>=D?$-D:0;while(--Q)},zQA=(A,Q,$)=>(Q<<A.hash_shift^$)&A.hash_mask,KH,IJ=(A)=>{let Q=A.state,$=Q.pending;if($>A.avail_out)$=A.avail_out;if($===0)return;if(A.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+$),A.next_out),A.next_out+=$,Q.pending_out+=$,A.total_out+=$,A.avail_out-=$,Q.pending-=$,Q.pending===0)Q.pending_out=0},HJ=(A,Q)=>{i7A(A,A.block_start>=0?A.block_start:-1,A.strstart-A.block_start,Q),A.block_start=A.strstart,IJ(A.strm)},n3=(A,Q)=>{A.pending_buf[A.pending++]=Q},xc=(A,Q)=>{A.pending_buf[A.pending++]=Q>>>8&255,A.pending_buf[A.pending++]=Q&255},tv0=(A,Q,$,B)=>{let D=A.avail_in;if(D>B)D=B;if(D===0)return 0;if(A.avail_in-=D,Q.set(A.input.subarray(A.next_in,A.next_in+D),$),A.state.wrap===1)A.adler=nc(A.adler,Q,D,$);else if(A.state.wrap===2)A.adler=K7(A.adler,Q,D,$);return A.next_in+=D,A.total_in+=D,D},D04=(A,Q)=>{let{max_chain_length:$,strstart:B}=A,D,J,E=A.prev_length,F=A.nice_match,Y=A.strstart>A.w_size-zX?A.strstart-(A.w_size-zX):0,Z=A.window,U=A.w_mask,X=A.prev,G=A.strstart+XH,V=Z[B+E-1],K=Z[B+E];if(A.prev_length>=A.good_match)$>>=2;if(F>A.lookahead)F=A.lookahead;do{if(D=Q,Z[D+E]!==K||Z[D+E-1]!==V||Z[D]!==Z[B]||Z[++D]!==Z[B+1])continue;B+=2,D++;do;while(Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&Z[++B]===Z[++D]&&B<G);if(J=XH-(G-B),B=G-XH,J>E){if(A.match_start=Q,E=J,J>=F)break;V=Z[B+E-1],K=Z[B+E]}}while((Q=X[Q&U])>Y&&--$!==0);if(E<=A.lookahead)return E;return A.lookahead},mT=(A)=>{let Q=A.w_size,$,B,D;do{if(B=A.window_size-A.lookahead-A.strstart,A.strstart>=Q+(Q-zX)){if(A.window.set(A.window.subarray(Q,Q+Q-B),0),A.match_start-=Q,A.strstart-=Q,A.block_start-=Q,A.insert>A.strstart)A.insert=A.strstart;KQA(A),B+=Q}if(A.strm.avail_in===0)break;if($=tv0(A.strm,A.window,A.strstart+A.lookahead,B),A.lookahead+=$,A.lookahead+A.insert>=J3){D=A.strstart-A.insert,A.ins_h=A.window[D],A.ins_h=KH(A,A.ins_h,A.window[D+1]);while(A.insert)if(A.ins_h=KH(A,A.ins_h,A.window[D+J3-1]),A.prev[D&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=D,D++,A.insert--,A.lookahead+A.insert<J3)break}}while(A.lookahead<zX&&A.strm.avail_in!==0)},J04=(A,Q)=>{let $=A.pending_buf_size-5>A.w_size?A.w_size:A.pending_buf_size-5,B,D,J,E=0,F=A.strm.avail_in;do{if(B=65535,J=A.bi_valid+42>>3,A.strm.avail_out<J)break;if(J=A.strm.avail_out-J,D=A.strstart-A.block_start,B>D+A.strm.avail_in)B=D+A.strm.avail_in;if(B>J)B=J;if(B<$&&(B===0&&Q!==eE||Q===VH||B!==D+A.strm.avail_in))break;if(E=Q===eE&&B===D+A.strm.avail_in?1:0,iv0(A,0,0,E),A.pending_buf[A.pending-4]=B,A.pending_buf[A.pending-3]=B>>8,A.pending_buf[A.pending-2]=~B,A.pending_buf[A.pending-1]=~B>>8,IJ(A.strm),D){if(D>B)D=B;A.strm.output.set(A.window.subarray(A.block_start,A.block_start+D),A.strm.next_out),A.strm.next_out+=D,A.strm.avail_out-=D,A.strm.total_out+=D,A.block_start+=D,B-=D}if(B)tv0(A.strm,A.strm.output,A.strm.next_out,B),A.strm.next_out+=B,A.strm.avail_out-=B,A.strm.total_out+=B}while(E===0);if(F-=A.strm.avail_in,F){if(F>=A.w_size)A.matches=2,A.window.set(A.strm.input.subarray(A.strm.next_in-A.w_size,A.strm.next_in),0),A.strstart=A.w_size,A.insert=A.strstart;else{if(A.window_size-A.strstart<=F){if(A.strstart-=A.w_size,A.window.set(A.window.subarray(A.w_size,A.w_size+A.strstart),0),A.matches<2)A.matches++;if(A.insert>A.strstart)A.insert=A.strstart}A.window.set(A.strm.input.subarray(A.strm.next_in-F,A.strm.next_in),A.strstart),A.strstart+=F,A.insert+=F>A.w_size-A.insert?A.w_size-A.insert:F}A.block_start=A.strstart}if(A.high_water<A.strstart)A.high_water=A.strstart;if(E)return cT;if(Q!==VH&&Q!==eE&&A.strm.avail_in===0&&A.strstart===A.block_start)return pT;if(J=A.window_size-A.strstart,A.strm.avail_in>J&&A.block_start>=A.w_size){if(A.block_start-=A.w_size,A.strstart-=A.w_size,A.window.set(A.window.subarray(A.w_size,A.w_size+A.strstart),0),A.matches<2)A.matches++;if(J+=A.w_size,A.insert>A.strstart)A.insert=A.strstart}if(J>A.strm.avail_in)J=A.strm.avail_in;if(J)tv0(A.strm,A.window,A.strstart,J),A.strstart+=J,A.insert+=J>A.w_size-A.insert?A.w_size-A.insert:J;if(A.high_water<A.strstart)A.high_water=A.strstart;if(J=A.bi_valid+42>>3,J=A.pending_buf_size-J>65535?65535:A.pending_buf_size-J,$=J>A.w_size?A.w_size:J,D=A.strstart-A.block_start,D>=$||(D||Q===eE)&&Q!==VH&&A.strm.avail_in===0&&D<=J)B=D>J?J:D,E=Q===eE&&A.strm.avail_in===0&&B===D?1:0,iv0(A,A.block_start,B,E),A.block_start+=B,IJ(A.strm);return E?UL:b$},fv0=(A,Q)=>{let $,B;for(;;){if(A.lookahead<zX){if(mT(A),A.lookahead<zX&&Q===VH)return b$;if(A.lookahead===0)break}if($=0,A.lookahead>=J3)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if($!==0&&A.strstart-$<=A.w_size-zX)A.match_length=D04(A,$);if(A.match_length>=J3)if(B=GH(A,A.strstart-A.match_start,A.match_length-J3),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=J3){A.match_length--;do A.strstart++,A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;while(--A.match_length!==0);A.strstart++}else A.strstart+=A.match_length,A.match_length=0,A.ins_h=A.window[A.strstart],A.ins_h=KH(A,A.ins_h,A.window[A.strstart+1]);else B=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if(B){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=A.strstart<J3-1?A.strstart:J3-1,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},xT=(A,Q)=>{let $,B,D;for(;;){if(A.lookahead<zX){if(mT(A),A.lookahead<zX&&Q===VH)return b$;if(A.lookahead===0)break}if($=0,A.lookahead>=J3)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if(A.prev_length=A.match_length,A.prev_match=A.match_start,A.match_length=J3-1,$!==0&&A.prev_length<A.max_lazy_match&&A.strstart-$<=A.w_size-zX){if(A.match_length=D04(A,$),A.match_length<=5&&(A.strategy===t7A||A.match_length===J3&&A.strstart-A.match_start>4096))A.match_length=J3-1}if(A.prev_length>=J3&&A.match_length<=A.prev_length){D=A.strstart+A.lookahead-J3,B=GH(A,A.strstart-1-A.prev_match,A.prev_length-J3),A.lookahead-=A.prev_length-1,A.prev_length-=2;do if(++A.strstart<=D)A.ins_h=KH(A,A.ins_h,A.window[A.strstart+J3-1]),$=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;while(--A.prev_length!==0);if(A.match_available=0,A.match_length=J3-1,A.strstart++,B){if(HJ(A,!1),A.strm.avail_out===0)return b$}}else if(A.match_available){if(B=GH(A,0,A.window[A.strstart-1]),B)HJ(A,!1);if(A.strstart++,A.lookahead--,A.strm.avail_out===0)return b$}else A.match_available=1,A.strstart++,A.lookahead--}if(A.match_available)B=GH(A,0,A.window[A.strstart-1]),A.match_available=0;if(A.insert=A.strstart<J3-1?A.strstart:J3-1,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},WQA=(A,Q)=>{let $,B,D,J,E=A.window;for(;;){if(A.lookahead<=XH){if(mT(A),A.lookahead<=XH&&Q===VH)return b$;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=J3&&A.strstart>0){if(D=A.strstart-1,B=E[D],B===E[++D]&&B===E[++D]&&B===E[++D]){J=A.strstart+XH;do;while(B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&B===E[++D]&&D<J);if(A.match_length=XH-(J-D),A.match_length>A.lookahead)A.match_length=A.lookahead}}if(A.match_length>=J3)$=GH(A,1,A.match_length-J3),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0;else $=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if($){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=0,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},IQA=(A,Q)=>{let $;for(;;){if(A.lookahead===0){if(mT(A),A.lookahead===0){if(Q===VH)return b$;break}}if(A.match_length=0,$=GH(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,$){if(HJ(A,!1),A.strm.avail_out===0)return b$}}if(A.insert=0,Q===eE){if(HJ(A,!0),A.strm.avail_out===0)return UL;return cT}if(A.sym_next){if(HJ(A,!1),A.strm.avail_out===0)return b$}return pT},hc,HQA=(A)=>{A.window_size=2*A.w_size,UH(A.head),A.max_lazy_match=hc[A.level].max_lazy,A.good_match=hc[A.level].good_length,A.nice_match=hc[A.level].nice_length,A.max_chain_length=hc[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=J3-1,A.match_available=0,A.ins_h=0},tc=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.status!==gT&&Q.status!==Bk0&&Q.status!==av0&&Q.status!==ov0&&Q.status!==rv0&&Q.status!==sv0&&Q.status!==FL&&Q.status!==bc)return 1;return 0},E04=(A)=>{if(tc(A))return YL(A,KX);A.total_in=A.total_out=0,A.data_type=$QA;let Q=A.state;if(Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap===2?Bk0:Q.wrap?gT:FL,A.adler=Q.wrap===2?0:1,Q.last_flush=-2,l7A(Q),o7},F04=(A)=>{let Q=E04(A);if(Q===o7)HQA(A.state);return Q},NQA=(A,Q)=>{if(tc(A)||A.state.wrap!==2)return KX;return A.state.gzhead=Q,o7},Y04=(A,Q,$,B,D,J)=>{if(!A)return KX;let E=1;if(Q===s7A)Q=6;if(B<0)E=0,B=-B;else if(B>15)E=2,B-=16;if(D<1||D>BQA||$!==k80||B<8||B>15||Q<0||Q>9||J<0||J>AQA||B===8&&E!==1)return YL(A,KX);if(B===8)B=9;let F=new qQA;return A.state=F,F.strm=A,F.status=gT,F.wrap=E,F.gzhead=null,F.w_bits=B,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=D+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+J3-1)/J3),F.window=new Uint8Array(F.w_size*2),F.head=new Uint16Array(F.hash_size),F.prev=new Uint16Array(F.w_size),F.lit_bufsize=1<<D+6,F.pending_buf_size=F.lit_bufsize*4,F.pending_buf=new Uint8Array(F.pending_buf_size),F.sym_buf=F.lit_bufsize,F.sym_end=(F.lit_bufsize-1)*3,F.level=Q,F.strategy=J,F.method=$,F04(A)},CQA=(A,Q)=>{return Y04(A,Q,k80,DQA,JQA,QQA)},wQA=(A,Q)=>{if(tc(A)||Q>Ue1||Q<0)return A?YL(A,KX):KX;let $=A.state;if(!A.output||A.avail_in!==0&&!A.input||$.status===bc&&Q!==eE)return YL(A,A.avail_out===0?Sv0:KX);let B=$.last_flush;if($.last_flush=Q,$.pending!==0){if(IJ(A),A.avail_out===0)return $.last_flush=-1,o7}else if(A.avail_in===0&&Ge1(Q)<=Ge1(B)&&Q!==eE)return YL(A,Sv0);if($.status===bc&&A.avail_in!==0)return YL(A,Sv0);if($.status===gT&&$.wrap===0)$.status=FL;if($.status===gT){let D=k80+($.w_bits-8<<4)<<8,J=-1;if($.strategy>=L80||$.level<2)J=0;else if($.level<6)J=1;else if($.level===6)J=2;else J=3;if(D|=J<<6,$.strstart!==0)D|=GQA;if(D+=31-D%31,xc($,D),$.strstart!==0)xc($,A.adler>>>16),xc($,A.adler&65535);if(A.adler=1,$.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}if($.status===Bk0)if(A.adler=0,n3($,31),n3($,139),n3($,8),!$.gzhead){if(n3($,0),n3($,0),n3($,0),n3($,0),n3($,0),n3($,$.level===9?2:$.strategy>=L80||$.level<2?4:0),n3($,VQA),$.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}else{if(n3($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+(!$.gzhead.extra?0:4)+(!$.gzhead.name?0:8)+(!$.gzhead.comment?0:16)),n3($,$.gzhead.time&255),n3($,$.gzhead.time>>8&255),n3($,$.gzhead.time>>16&255),n3($,$.gzhead.time>>24&255),n3($,$.level===9?2:$.strategy>=L80||$.level<2?4:0),n3($,$.gzhead.os&255),$.gzhead.extra&&$.gzhead.extra.length)n3($,$.gzhead.extra.length&255),n3($,$.gzhead.extra.length>>8&255);if($.gzhead.hcrc)A.adler=K7(A.adler,$.pending_buf,$.pending,0);$.gzindex=0,$.status=av0}if($.status===av0){if($.gzhead.extra){let D=$.pending,J=($.gzhead.extra.length&65535)-$.gzindex;while($.pending+J>$.pending_buf_size){let F=$.pending_buf_size-$.pending;if($.pending_buf.set($.gzhead.extra.subarray($.gzindex,$.gzindex+F),$.pending),$.pending=$.pending_buf_size,$.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if($.gzindex+=F,IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0,J-=F}let E=new Uint8Array($.gzhead.extra);if($.pending_buf.set(E.subarray($.gzindex,$.gzindex+J),$.pending),$.pending+=J,$.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);$.gzindex=0}$.status=ov0}if($.status===ov0){if($.gzhead.name){let D=$.pending,J;do{if($.pending===$.pending_buf_size){if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if(IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0}if($.gzindex<$.gzhead.name.length)J=$.gzhead.name.charCodeAt($.gzindex++)&255;else J=0;n3($,J)}while(J!==0);if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);$.gzindex=0}$.status=rv0}if($.status===rv0){if($.gzhead.comment){let D=$.pending,J;do{if($.pending===$.pending_buf_size){if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D);if(IJ(A),$.pending!==0)return $.last_flush=-1,o7;D=0}if($.gzindex<$.gzhead.comment.length)J=$.gzhead.comment.charCodeAt($.gzindex++)&255;else J=0;n3($,J)}while(J!==0);if($.gzhead.hcrc&&$.pending>D)A.adler=K7(A.adler,$.pending_buf,$.pending-D,D)}$.status=sv0}if($.status===sv0){if($.gzhead.hcrc){if($.pending+2>$.pending_buf_size){if(IJ(A),$.pending!==0)return $.last_flush=-1,o7}n3($,A.adler&255),n3($,A.adler>>8&255),A.adler=0}if($.status=FL,IJ(A),$.pending!==0)return $.last_flush=-1,o7}if(A.avail_in!==0||$.lookahead!==0||Q!==VH&&$.status!==bc){let D=$.level===0?J04($,Q):$.strategy===L80?IQA($,Q):$.strategy===e7A?WQA($,Q):hc[$.level].func($,Q);if(D===UL||D===cT)$.status=bc;if(D===b$||D===UL){if(A.avail_out===0)$.last_flush=-1;return o7}if(D===pT){if(Q===a7A)n7A($);else if(Q!==Ue1){if(iv0($,0,0,!1),Q===o7A){if(UH($.head),$.lookahead===0)$.strstart=0,$.block_start=0,$.insert=0}}if(IJ(A),A.avail_out===0)return $.last_flush=-1,o7}}if(Q!==eE)return o7;if($.wrap<=0)return Xe1;if($.wrap===2)n3($,A.adler&255),n3($,A.adler>>8&255),n3($,A.adler>>16&255),n3($,A.adler>>24&255),n3($,A.total_in&255),n3($,A.total_in>>8&255),n3($,A.total_in>>16&255),n3($,A.total_in>>24&255);else xc($,A.adler>>>16),xc($,A.adler&65535);if(IJ(A),$.wrap>0)$.wrap=-$.wrap;return $.pending!==0?o7:Xe1},MQA=(A)=>{if(tc(A))return KX;let Q=A.state.status;return A.state=null,Q===FL?YL(A,r7A):o7},LQA=(A,Q)=>{let $=Q.length;if(tc(A))return KX;let B=A.state,D=B.wrap;if(D===2||D===1&&B.status!==gT||B.lookahead)return KX;if(D===1)A.adler=nc(A.adler,Q,$,0);if(B.wrap=0,$>=B.w_size){if(D===0)UH(B.head),B.strstart=0,B.block_start=0,B.insert=0;let Y=new Uint8Array(B.w_size);Y.set(Q.subarray($-B.w_size,$),0),Q=Y,$=B.w_size}let{avail_in:J,next_in:E,input:F}=A;A.avail_in=$,A.next_in=0,A.input=Q,mT(B);while(B.lookahead>=J3){let Y=B.strstart,Z=B.lookahead-(J3-1);do B.ins_h=KH(B,B.ins_h,B.window[Y+J3-1]),B.prev[Y&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=Y,Y++;while(--Z);B.strstart=Y,B.lookahead=J3-1,mT(B)}return B.strstart+=B.lookahead,B.block_start=B.strstart,B.insert=B.lookahead,B.lookahead=0,B.match_length=B.prev_length=J3-1,B.match_available=0,A.next_in=E,A.input=F,A.avail_in=J,B.wrap=D,o7},OQA,jQA,RQA,uQA,PQA,_QA,TQA,vQA,kQA="pako deflate (from Nodeca project)",mc,SQA=(A,Q)=>{return Object.prototype.hasOwnProperty.call(A,Q)},fQA=function(A){let Q=Array.prototype.slice.call(arguments,1);while(Q.length){let $=Q.shift();if(!$)continue;if(typeof $!=="object")throw TypeError($+"must be non-object");for(let B in $)if(SQA($,B))A[B]=$[B]}return A},yQA=(A)=>{let Q=0;for(let B=0,D=A.length;B<D;B++)Q+=A[B].length;let $=new Uint8Array(Q);for(let B=0,D=0,J=A.length;B<J;B++){let E=A[B];$.set(E,D),D+=E.length}return $},S80,Z04=!0,ac,xQA=(A)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(A);let Q,$,B,D,J,E=A.length,F=0;for(D=0;D<E;D++){if($=A.charCodeAt(D),($&64512)===55296&&D+1<E){if(B=A.charCodeAt(D+1),(B&64512)===56320)$=65536+($-55296<<10)+(B-56320),D++}F+=$<128?1:$<2048?2:$<65536?3:4}Q=new Uint8Array(F);for(J=0,D=0;J<F;D++){if($=A.charCodeAt(D),($&64512)===55296&&D+1<E){if(B=A.charCodeAt(D+1),(B&64512)===56320)$=65536+($-55296<<10)+(B-56320),D++}if($<128)Q[J++]=$;else if($<2048)Q[J++]=192|$>>>6,Q[J++]=128|$&63;else if($<65536)Q[J++]=224|$>>>12,Q[J++]=128|$>>>6&63,Q[J++]=128|$&63;else Q[J++]=240|$>>>18,Q[J++]=128|$>>>12&63,Q[J++]=128|$>>>6&63,Q[J++]=128|$&63}return Q},bQA=(A,Q)=>{if(Q<65534){if(A.subarray&&Z04)return String.fromCharCode.apply(null,A.length===Q?A:A.subarray(0,Q))}let $="";for(let B=0;B<Q;B++)$+=String.fromCharCode(A[B]);return $},hQA=(A,Q)=>{let $=Q||A.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(A.subarray(0,Q));let B,D,J=Array($*2);for(D=0,B=0;B<$;){let E=A[B++];if(E<128){J[D++]=E;continue}let F=ac[E];if(F>4){J[D++]=65533,B+=F-1;continue}E&=F===2?31:F===3?15:7;while(F>1&&B<$)E=E<<6|A[B++]&63,F--;if(F>1){J[D++]=65533;continue}if(E<65536)J[D++]=E;else E-=65536,J[D++]=55296|E>>10&1023,J[D++]=56320|E&1023}return bQA(J,D)},gQA=(A,Q)=>{if(Q=Q||A.length,Q>A.length)Q=A.length;let $=Q-1;while($>=0&&(A[$]&192)===128)$--;if($<0)return Q;if($===0)return Q;return $+ac[A[$]]>Q?$:Q},oc,U04,X04,dQA,pQA,cQA,lQA,T80,iQA,nQA,aQA,oQA,tQA,eQA,A$A,Q$A,$$A,B$A,O80=16209,D$A=16191,J$A=function(Q,$){let B,D,J,E,F,Y,Z,U,X,G,V,K,z,W,I,H,q,N,C,M,O,R,k,_,f=Q.state;B=Q.next_in,k=Q.input,D=B+(Q.avail_in-5),J=Q.next_out,_=Q.output,E=J-($-Q.avail_out),F=J+(Q.avail_out-257),Y=f.dmax,Z=f.wsize,U=f.whave,X=f.wnext,G=f.window,V=f.hold,K=f.bits,z=f.lencode,W=f.distcode,I=(1<<f.lenbits)-1,H=(1<<f.distbits)-1;A:do{if(K<15)V+=k[B++]<<K,K+=8,V+=k[B++]<<K,K+=8;q=z[V&I];Q:for(;;){if(N=q>>>24,V>>>=N,K-=N,N=q>>>16&255,N===0)_[J++]=q&65535;else if(N&16){if(C=q&65535,N&=15,N){if(K<N)V+=k[B++]<<K,K+=8;C+=V&(1<<N)-1,V>>>=N,K-=N}if(K<15)V+=k[B++]<<K,K+=8,V+=k[B++]<<K,K+=8;q=W[V&H];$:for(;;){if(N=q>>>24,V>>>=N,K-=N,N=q>>>16&255,N&16){if(M=q&65535,N&=15,K<N){if(V+=k[B++]<<K,K+=8,K<N)V+=k[B++]<<K,K+=8}if(M+=V&(1<<N)-1,M>Y){Q.msg="invalid distance too far back",f.mode=O80;break A}if(V>>>=N,K-=N,N=J-E,M>N){if(N=M-N,N>U){if(f.sane){Q.msg="invalid distance too far back",f.mode=O80;break A}}if(O=0,R=G,X===0){if(O+=Z-N,N<C){C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}}else if(X<N){if(O+=Z+X-N,N-=X,N<C){C-=N;do _[J++]=G[O++];while(--N);if(O=0,X<C){N=X,C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}}}else if(O+=X-N,N<C){C-=N;do _[J++]=G[O++];while(--N);O=J-M,R=_}while(C>2)_[J++]=R[O++],_[J++]=R[O++],_[J++]=R[O++],C-=3;if(C){if(_[J++]=R[O++],C>1)_[J++]=R[O++]}}else{O=J-M;do _[J++]=_[O++],_[J++]=_[O++],_[J++]=_[O++],C-=3;while(C>2);if(C){if(_[J++]=_[O++],C>1)_[J++]=_[O++]}}}else if((N&64)===0){q=W[(q&65535)+(V&(1<<N)-1)];continue $}else{Q.msg="invalid distance code",f.mode=O80;break A}break}}else if((N&64)===0){q=z[(q&65535)+(V&(1<<N)-1)];continue Q}else if(N&32){f.mode=D$A;break A}else{Q.msg="invalid literal/length code",f.mode=O80;break A}break}}while(B<D&&J<F);C=K>>3,B-=C,K-=C<<3,V&=(1<<K)-1,Q.next_in=B,Q.next_out=J,Q.avail_in=B<D?5+(D-B):5-(B-D),Q.avail_out=J<F?257+(F-J):257-(J-F),f.hold=V,f.bits=K;return},bT=15,Ve1=852,Ke1=592,ze1=0,yv0=1,We1=2,E$A,F$A,Y$A,Z$A,U$A=(A,Q,$,B,D,J,E,F)=>{let Y=F.bits,Z=0,U=0,X=0,G=0,V=0,K=0,z=0,W=0,I=0,H=0,q,N,C,M,O,R=null,k,_=new Uint16Array(bT+1),f=new Uint16Array(bT+1),g=null,b,v,x;for(Z=0;Z<=bT;Z++)_[Z]=0;for(U=0;U<B;U++)_[Q[$+U]]++;V=Y;for(G=bT;G>=1;G--)if(_[G]!==0)break;if(V>G)V=G;if(G===0)return D[J++]=20971520,D[J++]=20971520,F.bits=1,0;for(X=1;X<G;X++)if(_[X]!==0)break;if(V<X)V=X;W=1;for(Z=1;Z<=bT;Z++)if(W<<=1,W-=_[Z],W<0)return-1;if(W>0&&(A===ze1||G!==1))return-1;f[1]=0;for(Z=1;Z<bT;Z++)f[Z+1]=f[Z]+_[Z];for(U=0;U<B;U++)if(Q[$+U]!==0)E[f[Q[$+U]]++]=U;if(A===ze1)R=g=E,k=20;else if(A===yv0)R=E$A,g=F$A,k=257;else R=Y$A,g=Z$A,k=0;if(H=0,U=0,Z=X,O=J,K=V,z=0,C=-1,I=1<<V,M=I-1,A===yv0&&I>Ve1||A===We1&&I>Ke1)return 1;for(;;){if(b=Z-z,E[U]+1<k)v=0,x=E[U];else if(E[U]>=k)v=g[E[U]-k],x=R[E[U]-k];else v=96,x=0;q=1<<Z-z,N=1<<K,X=N;do N-=q,D[O+(H>>z)+N]=b<<24|v<<16|x|0;while(N!==0);q=1<<Z-1;while(H&q)q>>=1;if(q!==0)H&=q-1,H+=q;else H=0;if(U++,--_[Z]===0){if(Z===G)break;Z=Q[$+E[U]]}if(Z>V&&(H&M)!==C){if(z===0)z=V;O+=X,K=Z-z,W=1<<K;while(K+z<G){if(W-=_[K+z],W<=0)break;K++,W<<=1}if(I+=1<<K,A===yv0&&I>Ve1||A===We1&&I>Ke1)return 1;C=H&M,D[C]=V<<24|K<<16|O-J|0}}if(H!==0)D[O+H]=Z-z<<24|4194304|0;return F.bits=V,0},dc,X$A=0,G04=1,V04=2,Ie1,G$A,j80,XL,V$A,K$A,AF,K04,z04,z$A,He1,f80=16180,qe1=16181,Ne1=16182,Ce1=16183,we1=16184,Me1=16185,Le1=16186,Oe1=16187,je1=16188,Re1=16189,v80=16190,VK=16191,xv0=16192,ue1=16193,bv0=16194,Pe1=16195,_e1=16196,Te1=16197,ve1=16198,R80=16199,u80=16200,ke1=16201,Se1=16202,fe1=16203,ye1=16204,xe1=16205,hv0=16206,be1=16207,he1=16208,C2=16209,W04=16210,I04=16211,W$A=852,I$A=592,H$A=15,q$A,ge1=(A)=>{return(A>>>24&255)+(A>>>8&65280)+((A&65280)<<8)+((A&255)<<24)},VL=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.mode<f80||Q.mode>I04)return 1;return 0},H04=(A)=>{if(VL(A))return AF;let Q=A.state;if(A.total_in=A.total_out=Q.total=0,A.msg="",Q.wrap)A.adler=Q.wrap&1;return Q.mode=f80,Q.last=0,Q.havedict=0,Q.flags=-1,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Int32Array(W$A),Q.distcode=Q.distdyn=new Int32Array(I$A),Q.sane=1,Q.back=-1,XL},q04=(A)=>{if(VL(A))return AF;let Q=A.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,H04(A)},N04=(A,Q)=>{let $;if(VL(A))return AF;let B=A.state;if(Q<0)$=0,Q=-Q;else if($=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return AF;if(B.window!==null&&B.wbits!==Q)B.window=null;return B.wrap=$,B.wbits=Q,q04(A)},C04=(A,Q)=>{if(!A)return AF;let $=new N$A;A.state=$,$.strm=A,$.window=null,$.mode=f80;let B=N04(A,Q);if(B!==XL)A.state=null;return B},C$A=(A)=>{return C04(A,q$A)},me1=!0,gv0,mv0,w$A=(A)=>{if(me1){gv0=new Int32Array(512),mv0=new Int32Array(32);let Q=0;while(Q<144)A.lens[Q++]=8;while(Q<256)A.lens[Q++]=9;while(Q<280)A.lens[Q++]=7;while(Q<288)A.lens[Q++]=8;dc(G04,A.lens,0,288,gv0,0,A.work,{bits:9}),Q=0;while(Q<32)A.lens[Q++]=5;dc(V04,A.lens,0,32,mv0,0,A.work,{bits:5}),me1=!1}A.lencode=gv0,A.lenbits=9,A.distcode=mv0,A.distbits=5},w04=(A,Q,$,B)=>{let D,J=A.state;if(J.window===null)J.wsize=1<<J.wbits,J.wnext=0,J.whave=0,J.window=new Uint8Array(J.wsize);if(B>=J.wsize)J.window.set(Q.subarray($-J.wsize,$),0),J.wnext=0,J.whave=J.wsize;else{if(D=J.wsize-J.wnext,D>B)D=B;if(J.window.set(Q.subarray($-B,$-B+D),J.wnext),B-=D,B)J.window.set(Q.subarray($-B,$),0),J.wnext=B,J.whave=J.wsize;else{if(J.wnext+=D,J.wnext===J.wsize)J.wnext=0;if(J.whave<J.wsize)J.whave+=D}}return 0},M$A=(A,Q)=>{let $,B,D,J,E,F,Y,Z,U,X,G,V,K,z,W=0,I,H,q,N,C,M,O,R,k=new Uint8Array(4),_,f,g=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(VL(A)||!A.output||!A.input&&A.avail_in!==0)return AF;if($=A.state,$.mode===VK)$.mode=xv0;E=A.next_out,D=A.output,Y=A.avail_out,J=A.next_in,B=A.input,F=A.avail_in,Z=$.hold,U=$.bits,X=F,G=Y,R=XL;A:for(;;)switch($.mode){case f80:if($.wrap===0){$.mode=xv0;break}while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&2&&Z===35615){if($.wbits===0)$.wbits=15;$.check=0,k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0),Z=0,U=0,$.mode=qe1;break}if($.head)$.head.done=!1;if(!($.wrap&1)||(((Z&255)<<8)+(Z>>8))%31){A.msg="incorrect header check",$.mode=C2;break}if((Z&15)!==He1){A.msg="unknown compression method",$.mode=C2;break}if(Z>>>=4,U-=4,O=(Z&15)+8,$.wbits===0)$.wbits=O;if(O>15||O>$.wbits){A.msg="invalid window size",$.mode=C2;break}$.dmax=1<<$.wbits,$.flags=0,A.adler=$.check=1,$.mode=Z&512?Re1:VK,Z=0,U=0;break;case qe1:while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.flags=Z,($.flags&255)!==He1){A.msg="unknown compression method",$.mode=C2;break}if($.flags&57344){A.msg="unknown header flags set",$.mode=C2;break}if($.head)$.head.text=Z>>8&1;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0,$.mode=Ne1;case Ne1:while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.head)$.head.time=Z;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,k[2]=Z>>>16&255,k[3]=Z>>>24&255,$.check=K7($.check,k,4,0);Z=0,U=0,$.mode=Ce1;case Ce1:while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.head)$.head.xflags=Z&255,$.head.os=Z>>8;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0,$.mode=we1;case we1:if($.flags&1024){while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.length=Z,$.head)$.head.extra_len=Z;if($.flags&512&&$.wrap&4)k[0]=Z&255,k[1]=Z>>>8&255,$.check=K7($.check,k,2,0);Z=0,U=0}else if($.head)$.head.extra=null;$.mode=Me1;case Me1:if($.flags&1024){if(V=$.length,V>F)V=F;if(V){if($.head){if(O=$.head.extra_len-$.length,!$.head.extra)$.head.extra=new Uint8Array($.head.extra_len);$.head.extra.set(B.subarray(J,J+V),O)}if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);F-=V,J+=V,$.length-=V}if($.length)break A}$.length=0,$.mode=Le1;case Le1:if($.flags&2048){if(F===0)break A;V=0;do if(O=B[J+V++],$.head&&O&&$.length<65536)$.head.name+=String.fromCharCode(O);while(O&&V<F);if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);if(F-=V,J+=V,O)break A}else if($.head)$.head.name=null;$.length=0,$.mode=Oe1;case Oe1:if($.flags&4096){if(F===0)break A;V=0;do if(O=B[J+V++],$.head&&O&&$.length<65536)$.head.comment+=String.fromCharCode(O);while(O&&V<F);if($.flags&512&&$.wrap&4)$.check=K7($.check,B,V,J);if(F-=V,J+=V,O)break A}else if($.head)$.head.comment=null;$.mode=je1;case je1:if($.flags&512){while(U<16){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&4&&Z!==($.check&65535)){A.msg="header crc mismatch",$.mode=C2;break}Z=0,U=0}if($.head)$.head.hcrc=$.flags>>9&1,$.head.done=!0;A.adler=$.check=0,$.mode=VK;break;case Re1:while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}A.adler=$.check=ge1(Z),Z=0,U=0,$.mode=v80;case v80:if($.havedict===0)return A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,K$A;A.adler=$.check=1,$.mode=VK;case VK:if(Q===G$A||Q===j80)break A;case xv0:if($.last){Z>>>=U&7,U-=U&7,$.mode=hv0;break}while(U<3){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}switch($.last=Z&1,Z>>>=1,U-=1,Z&3){case 0:$.mode=ue1;break;case 1:if(w$A($),$.mode=R80,Q===j80){Z>>>=2,U-=2;break A}break;case 2:$.mode=_e1;break;case 3:A.msg="invalid block type",$.mode=C2}Z>>>=2,U-=2;break;case ue1:Z>>>=U&7,U-=U&7;while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if((Z&65535)!==(Z>>>16^65535)){A.msg="invalid stored block lengths",$.mode=C2;break}if($.length=Z&65535,Z=0,U=0,$.mode=bv0,Q===j80)break A;case bv0:$.mode=Pe1;case Pe1:if(V=$.length,V){if(V>F)V=F;if(V>Y)V=Y;if(V===0)break A;D.set(B.subarray(J,J+V),E),F-=V,J+=V,Y-=V,E+=V,$.length-=V;break}$.mode=VK;break;case _e1:while(U<14){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.nlen=(Z&31)+257,Z>>>=5,U-=5,$.ndist=(Z&31)+1,Z>>>=5,U-=5,$.ncode=(Z&15)+4,Z>>>=4,U-=4,$.nlen>286||$.ndist>30){A.msg="too many length or distance symbols",$.mode=C2;break}$.have=0,$.mode=Te1;case Te1:while($.have<$.ncode){while(U<3){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.lens[g[$.have++]]=Z&7,Z>>>=3,U-=3}while($.have<19)$.lens[g[$.have++]]=0;if($.lencode=$.lendyn,$.lenbits=7,_={bits:$.lenbits},R=dc(X$A,$.lens,0,19,$.lencode,0,$.work,_),$.lenbits=_.bits,R){A.msg="invalid code lengths set",$.mode=C2;break}$.have=0,$.mode=ve1;case ve1:while($.have<$.nlen+$.ndist){for(;;){if(W=$.lencode[Z&(1<<$.lenbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(q<16)Z>>>=I,U-=I,$.lens[$.have++]=q;else{if(q===16){f=I+2;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(Z>>>=I,U-=I,$.have===0){A.msg="invalid bit length repeat",$.mode=C2;break}O=$.lens[$.have-1],V=3+(Z&3),Z>>>=2,U-=2}else if(q===17){f=I+3;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=I,U-=I,O=0,V=3+(Z&7),Z>>>=3,U-=3}else{f=I+7;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=I,U-=I,O=0,V=11+(Z&127),Z>>>=7,U-=7}if($.have+V>$.nlen+$.ndist){A.msg="invalid bit length repeat",$.mode=C2;break}while(V--)$.lens[$.have++]=O}}if($.mode===C2)break;if($.lens[256]===0){A.msg="invalid code -- missing end-of-block",$.mode=C2;break}if($.lenbits=9,_={bits:$.lenbits},R=dc(G04,$.lens,0,$.nlen,$.lencode,0,$.work,_),$.lenbits=_.bits,R){A.msg="invalid literal/lengths set",$.mode=C2;break}if($.distbits=6,$.distcode=$.distdyn,_={bits:$.distbits},R=dc(V04,$.lens,$.nlen,$.ndist,$.distcode,0,$.work,_),$.distbits=_.bits,R){A.msg="invalid distances set",$.mode=C2;break}if($.mode=R80,Q===j80)break A;case R80:$.mode=u80;case u80:if(F>=6&&Y>=258){if(A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,J$A(A,G),E=A.next_out,D=A.output,Y=A.avail_out,J=A.next_in,B=A.input,F=A.avail_in,Z=$.hold,U=$.bits,$.mode===VK)$.back=-1;break}$.back=0;for(;;){if(W=$.lencode[Z&(1<<$.lenbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if(H&&(H&240)===0){N=I,C=H,M=q;for(;;){if(W=$.lencode[M+((Z&(1<<N+C)-1)>>N)],I=W>>>24,H=W>>>16&255,q=W&65535,N+I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=N,U-=N,$.back+=N}if(Z>>>=I,U-=I,$.back+=I,$.length=q,H===0){$.mode=xe1;break}if(H&32){$.back=-1,$.mode=VK;break}if(H&64){A.msg="invalid literal/length code",$.mode=C2;break}$.extra=H&15,$.mode=ke1;case ke1:if($.extra){f=$.extra;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.length+=Z&(1<<$.extra)-1,Z>>>=$.extra,U-=$.extra,$.back+=$.extra}$.was=$.length,$.mode=Se1;case Se1:for(;;){if(W=$.distcode[Z&(1<<$.distbits)-1],I=W>>>24,H=W>>>16&255,q=W&65535,I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if((H&240)===0){N=I,C=H,M=q;for(;;){if(W=$.distcode[M+((Z&(1<<N+C)-1)>>N)],I=W>>>24,H=W>>>16&255,q=W&65535,N+I<=U)break;if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}Z>>>=N,U-=N,$.back+=N}if(Z>>>=I,U-=I,$.back+=I,H&64){A.msg="invalid distance code",$.mode=C2;break}$.offset=q,$.extra=H&15,$.mode=fe1;case fe1:if($.extra){f=$.extra;while(U<f){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}$.offset+=Z&(1<<$.extra)-1,Z>>>=$.extra,U-=$.extra,$.back+=$.extra}if($.offset>$.dmax){A.msg="invalid distance too far back",$.mode=C2;break}$.mode=ye1;case ye1:if(Y===0)break A;if(V=G-Y,$.offset>V){if(V=$.offset-V,V>$.whave){if($.sane){A.msg="invalid distance too far back",$.mode=C2;break}}if(V>$.wnext)V-=$.wnext,K=$.wsize-V;else K=$.wnext-V;if(V>$.length)V=$.length;z=$.window}else z=D,K=E-$.offset,V=$.length;if(V>Y)V=Y;Y-=V,$.length-=V;do D[E++]=z[K++];while(--V);if($.length===0)$.mode=u80;break;case xe1:if(Y===0)break A;D[E++]=$.length,Y--,$.mode=u80;break;case hv0:if($.wrap){while(U<32){if(F===0)break A;F--,Z|=B[J++]<<U,U+=8}if(G-=Y,A.total_out+=G,$.total+=G,$.wrap&4&&G)A.adler=$.check=$.flags?K7($.check,D,G,E-G):nc($.check,D,G,E-G);if(G=Y,$.wrap&4&&($.flags?Z:ge1(Z))!==$.check){A.msg="incorrect data check",$.mode=C2;break}Z=0,U=0}$.mode=be1;case be1:if($.wrap&&$.flags){while(U<32){if(F===0)break A;F--,Z+=B[J++]<<U,U+=8}if($.wrap&4&&Z!==($.total&4294967295)){A.msg="incorrect length check",$.mode=C2;break}Z=0,U=0}$.mode=he1;case he1:R=V$A;break A;case C2:R=K04;break A;case W04:return z04;case I04:default:return AF}if(A.next_out=E,A.avail_out=Y,A.next_in=J,A.avail_in=F,$.hold=Z,$.bits=U,$.wsize||G!==A.avail_out&&$.mode<C2&&($.mode<hv0||Q!==Ie1)){if(w04(A,A.output,A.next_out,G-A.avail_out));}if(X-=A.avail_in,G-=A.avail_out,A.total_in+=X,A.total_out+=G,$.total+=G,$.wrap&4&&G)A.adler=$.check=$.flags?K7($.check,D,G,A.next_out-G):nc($.check,D,G,A.next_out-G);if(A.data_type=$.bits+($.last?64:0)+($.mode===VK?128:0)+($.mode===R80||$.mode===bv0?256:0),(X===0&&G===0||Q===Ie1)&&R===XL)R=z$A;return R},L$A=(A)=>{if(VL(A))return AF;let Q=A.state;if(Q.window)Q.window=null;return A.state=null,XL},O$A=(A,Q)=>{if(VL(A))return AF;let $=A.state;if(($.wrap&2)===0)return AF;return $.head=Q,Q.done=!1,XL},j$A=(A,Q)=>{let $=Q.length,B,D,J;if(VL(A))return AF;if(B=A.state,B.wrap!==0&&B.mode!==v80)return AF;if(B.mode===v80){if(D=1,D=nc(D,Q,$,0),D!==B.check)return K04}if(J=w04(A,Q,$,$),J)return B.mode=W04,z04;return B.havedict=1,XL},R$A,u$A,P$A,_$A,T$A,v$A,k$A,S$A,f$A,y$A="pako inflate (from Nodeca project)",zK,b$A,M04,h$A,g$A,rc,dv0,pv0,m$A,de1,d$A,c$A,l$A,i$A,n$A,a$A,o$A,r$A,s$A,t$A,e$A,ABA,QBA,$BA,BBA,DBA,JBA,EBA,FBA,YBA,ZBA,UBA,XBA,GBA,L04;var O04=o(()=>{/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */pc=sc+1+ev0,ce1=2*pc+1,cv0=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),P80=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),M7A=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ae1=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),KK=Array((pc+2)*2);dT(KK);gc=Array(hT*2);dT(gc);cc=Array(L7A);dT(cc);lc=Array(C7A-N7A+1);dT(lc);$k0=Array(ev0);dT($k0);_80=Array(hT);dT(_80);f7A=T7A,y7A=B04,x7A=k7A,b7A=S7A,h7A=v7A,g7A={_tr_init:f7A,_tr_stored_block:y7A,_tr_flush_block:x7A,_tr_tally:b7A,_tr_align:h7A},nc=m7A,p7A=new Uint32Array(d7A()),K7=c7A,ZL={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},GL={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:l7A,_tr_stored_block:iv0,_tr_flush_block:i7A,_tr_tally:GH,_tr_align:n7A}=g7A,{Z_NO_FLUSH:VH,Z_PARTIAL_FLUSH:a7A,Z_FULL_FLUSH:o7A,Z_FINISH:eE,Z_BLOCK:Ue1,Z_OK:o7,Z_STREAM_END:Xe1,Z_STREAM_ERROR:KX,Z_DATA_ERROR:r7A,Z_BUF_ERROR:Sv0,Z_DEFAULT_COMPRESSION:s7A,Z_FILTERED:t7A,Z_HUFFMAN_ONLY:L80,Z_RLE:e7A,Z_FIXED:AQA,Z_DEFAULT_STRATEGY:QQA,Z_UNKNOWN:$QA,Z_DEFLATED:k80}=GL,nv0=FQA+1+EQA,UQA=2*nv0+1,zX=XH+J3+1,KH=zQA;hc=[new GX(0,0,0,0,J04),new GX(4,4,8,4,fv0),new GX(4,5,16,8,fv0),new GX(4,6,32,32,fv0),new GX(4,4,16,16,xT),new GX(8,16,32,32,xT),new GX(8,16,128,128,xT),new GX(8,32,128,256,xT),new GX(32,128,258,1024,xT),new GX(32,258,258,4096,xT)];OQA=CQA,jQA=Y04,RQA=F04,uQA=E04,PQA=NQA,_QA=wQA,TQA=MQA,vQA=LQA,mc={deflateInit:OQA,deflateInit2:jQA,deflateReset:RQA,deflateResetKeep:uQA,deflateSetHeader:PQA,deflate:_QA,deflateEnd:TQA,deflateSetDictionary:vQA,deflateInfo:kQA},S80={assign:fQA,flattenChunks:yQA};try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){Z04=!1}ac=new Uint8Array(256);for(let A=0;A<256;A++)ac[A]=A>=252?6:A>=248?5:A>=240?4:A>=224?3:A>=192?2:1;ac[254]=ac[254]=1;oc={string2buf:xQA,buf2string:hQA,utf8border:gQA};U04=mQA,X04=Object.prototype.toString,{Z_NO_FLUSH:dQA,Z_SYNC_FLUSH:pQA,Z_FULL_FLUSH:cQA,Z_FINISH:lQA,Z_OK:T80,Z_STREAM_END:iQA,Z_DEFAULT_COMPRESSION:nQA,Z_DEFAULT_STRATEGY:aQA,Z_DEFLATED:oQA}=GL;ec.prototype.push=function(A,Q){let $=this.strm,B=this.options.chunkSize,D,J;if(this.ended)return!1;if(Q===~~Q)J=Q;else J=Q===!0?lQA:dQA;if(typeof A==="string")$.input=oc.string2buf(A);else if(X04.call(A)==="[object ArrayBuffer]")$.input=new Uint8Array(A);else $.input=A;$.next_in=0,$.avail_in=$.input.length;for(;;){if($.avail_out===0)$.output=new Uint8Array(B),$.next_out=0,$.avail_out=B;if((J===pQA||J===cQA)&&$.avail_out<=6){this.onData($.output.subarray(0,$.next_out)),$.avail_out=0;continue}if(D=mc.deflate($,J),D===iQA){if($.next_out>0)this.onData($.output.subarray(0,$.next_out));return D=mc.deflateEnd(this.strm),this.onEnd(D),this.ended=!0,D===T80}if($.avail_out===0){this.onData($.output);continue}if(J>0&&$.next_out>0){this.onData($.output.subarray(0,$.next_out)),$.avail_out=0;continue}if($.avail_in===0)break}return!0};ec.prototype.onData=function(A){this.chunks.push(A)};ec.prototype.onEnd=function(A){if(A===T80)this.result=S80.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};tQA=ec,eQA=Dk0,A$A=rQA,Q$A=sQA,$$A=GL,B$A={Deflate:tQA,deflate:eQA,deflateRaw:A$A,gzip:Q$A,constants:$$A},E$A=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),F$A=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Y$A=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Z$A=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),dc=U$A,{Z_FINISH:Ie1,Z_BLOCK:G$A,Z_TREES:j80,Z_OK:XL,Z_STREAM_END:V$A,Z_NEED_DICT:K$A,Z_STREAM_ERROR:AF,Z_DATA_ERROR:K04,Z_MEM_ERROR:z04,Z_BUF_ERROR:z$A,Z_DEFLATED:He1}=GL,q$A=H$A;R$A=q04,u$A=N04,P$A=H04,_$A=C$A,T$A=C04,v$A=M$A,k$A=L$A,S$A=O$A,f$A=j$A,zK={inflateReset:R$A,inflateReset2:u$A,inflateResetKeep:P$A,inflateInit:_$A,inflateInit2:T$A,inflate:v$A,inflateEnd:k$A,inflateGetHeader:S$A,inflateSetDictionary:f$A,inflateInfo:y$A};b$A=x$A,M04=Object.prototype.toString,{Z_NO_FLUSH:h$A,Z_FINISH:g$A,Z_OK:rc,Z_STREAM_END:dv0,Z_NEED_DICT:pv0,Z_STREAM_ERROR:m$A,Z_DATA_ERROR:de1,Z_MEM_ERROR:d$A}=GL;Al.prototype.push=function(A,Q){let $=this.strm,B=this.options.chunkSize,D=this.options.dictionary,J,E,F;if(this.ended)return!1;if(Q===~~Q)E=Q;else E=Q===!0?g$A:h$A;if(M04.call(A)==="[object ArrayBuffer]")$.input=new Uint8Array(A);else $.input=A;$.next_in=0,$.avail_in=$.input.length;for(;;){if($.avail_out===0)$.output=new Uint8Array(B),$.next_out=0,$.avail_out=B;if(J=zK.inflate($,E),J===pv0&&D){if(J=zK.inflateSetDictionary($,D),J===rc)J=zK.inflate($,E);else if(J===de1)J=pv0}while($.avail_in>0&&J===dv0&&$.state.wrap>0&&A[$.next_in]!==0)zK.inflateReset($),J=zK.inflate($,E);switch(J){case m$A:case de1:case pv0:case d$A:return this.onEnd(J),this.ended=!0,!1}if(F=$.avail_out,$.next_out){if($.avail_out===0||J===dv0)if(this.options.to==="string"){let Y=oc.utf8border($.output,$.next_out),Z=$.next_out-Y,U=oc.buf2string($.output,Y);if($.next_out=Z,$.avail_out=B-Z,Z)$.output.set($.output.subarray(Y,Y+Z),0);this.onData(U)}else this.onData($.output.length===$.next_out?$.output:$.output.subarray(0,$.next_out))}if(J===rc&&F===0)continue;if(J===dv0)return J=zK.inflateEnd(this.strm),this.onEnd(J),this.ended=!0,!0;if($.avail_in===0)break}return!0};Al.prototype.onData=function(A){this.chunks.push(A)};Al.prototype.onEnd=function(A){if(A===rc)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=S80.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};c$A=Al,l$A=Jk0,i$A=p$A,n$A=Jk0,a$A=GL,o$A={Inflate:c$A,inflate:l$A,inflateRaw:i$A,ungzip:n$A,constants:a$A},{Deflate:r$A,deflate:s$A,deflateRaw:t$A,gzip:e$A}=B$A,{Inflate:ABA,inflate:QBA,inflateRaw:$BA,ungzip:BBA}=o$A,DBA=r$A,JBA=s$A,EBA=t$A,FBA=e$A,YBA=ABA,ZBA=QBA,UBA=$BA,XBA=BBA,GBA=GL,L04={Deflate:DBA,deflate:JBA,deflateRaw:EBA,gzip:FBA,Inflate:YBA,inflate:ZBA,inflateRaw:UBA,ungzip:XBA,constants:GBA}});var j04="This cost reflects only Amp credits consumed. It does not include any model provider usage billed directly to customer-managed model provider keys.";var VBA,RN5,uN5,WX=64,KL,Ek0=1024,Fk0=500,PN5;var Ql=o(()=>{bQ();VBA=["private","public_unlisted","public_discoverable","thread_workspace_shared"],RN5=S.enum(VBA),uN5=S.union([S.object({visibility:S.literal("private"),sharedGroupIDs:S.array(S.string())}),S.object({visibility:S.literal("private"),shareWithAllCreatorGroups:S.literal(!0)}),S.object({visibility:S.enum(["thread_workspace_shared","public_unlisted","public_discoverable"])})]),KL=/^[a-z0-9](?:[a-z0-9]*(?:-[a-z0-9]+)*)?$/,PN5=S.string().regex(KL,"Must be lowercase a-z, 0-9, hyphens only, no start/end hyphen, no consecutive hyphens").min(1).max(WX)});function Yk0(A){switch(A){case"open":return"Open";case"in_progress":return"In Progress";case"completed":return"Completed";case"canceled":return"Canceled"}}var Zk0=()=>{};var Uk0=o(()=>{J9()});function Xk0(A){return Np(lT,A)}function zBA(A){return x_(R04,A)}function WBA(A){return AL(u04,A)}function IBA(A){return b_($l,A)}function HBA(A){return h_($l,A)}function qBA(A){return g_($l,A)}function NBA(A){return m_($l,A)}function CBA(A){return gI(Gk0,A)}function wBA(A){return gI(Gk0,{protocol:/^https?$/,hostname:v9.domain,...k1(A)})}function MBA(A){return d_(P04,A)}function LBA(A){return p_(_04,A)}function OBA(A){return c_(T04,A)}function jBA(A){return l_(v04,A)}function RBA(A){return i_(k04,A)}function uBA(A){return n_(S04,A)}function PBA(A){return a_(f04,A)}function _BA(A){return o_(y04,A)}function TBA(A){return r_(x04,A)}function vBA(A){return s_(b04,A)}function kBA(A){return t_(h04,A)}function SBA(A){return wp(g04,A)}function fBA(A){return e_(m04,A)}function yBA(A){return AT(d04,A)}function xBA(A){return QT(p04,A)}function bBA(A){return $T(c04,A)}function hBA(A,Q,$={}){return iY(Bl,A,Q,$)}function gBA(A){return iY(Bl,"hostname",v9.hostname,A)}function mBA(A){return iY(Bl,"hex",v9.hex,A)}function dBA(A,Q){let $=Q?.enc??"hex",B=`${A}_${$}`,D=v9[B];if(!D)throw Error(`Unrecognized hash format: ${B}`);return iY(Bl,B,D,Q)}function l04(A){return up(Dl,A)}function pBA(A){return _p(iT,A)}function cBA(A){return Tp(iT,A)}function lBA(A){return vp(iT,A)}function iBA(A){return kp(iT,A)}function nBA(A){return Sp(iT,A)}function i04(A){return fp(Jl,A)}function aBA(A){return xp(El,A)}function oBA(A){return hp(Vk0,A)}function rBA(A){return gp(Vk0,A)}function sBA(A){return mp(n04,A)}function tBA(A){return dp(a04,A)}function r04(A){return pp(o04,A)}function eBA(){return cp(s04)}function y80(){return lp(t04)}function A14(A){return ip(e04,A)}function ADA(A){return np(Q14,A)}function QDA(A){return ap(x80,A)}function Kk0(A,Q){return new $14({type:"array",element:A,...k1(Q)})}function $DA(A){let Q=A._zod.def.shape;return V14(Object.keys(Q))}function B14(A,Q){let $={type:"object",shape:A??{},...k1(Q)};return new b80($)}function BDA(A,Q){return new b80({type:"object",shape:A,catchall:A14(),...k1(Q)})}function DDA(A,Q){return new b80({type:"object",shape:A,catchall:y80(),...k1(Q)})}function JDA(A,Q){return c50(A,Q)}function EDA(A,Q){return tR0(A,Q)}function FDA(A,Q){return c50(A,Q)}function YDA(A,Q){return rR0(A,Q)}function ZDA(A,Q){return sR0(A,Q)}function UDA(A,Q){return eR0(Ik0,A,Q)}function XDA(A,Q){return Au0(Hk0,A,Q)}function GDA(A,Q){return A.clone({...A._zod.def,catchall:Q})}function D14(A,Q){return new zk0({type:"union",options:A,...k1(Q)})}function VDA(A,Q){return new J14({type:"union",options:A,inclusive:!1,...k1(Q)})}function KDA(A,Q,$){return new E14({type:"union",options:Q,discriminator:A,...k1($)})}function zDA(A,Q){return new F14({type:"intersection",left:A,right:Q})}function Z14(A,Q,$){let B=Q instanceof g6;return new Y14({type:"tuple",items:A,rest:B?Q:null,...k1(B?$:Q)})}function U14(A,Q,$){return new h80({type:"record",keyType:A,valueType:Q,...k1($)})}function WDA(A,Q,$){let B=D9(A);return B._zod.values=void 0,new h80({type:"record",keyType:B,valueType:Q,...k1($)})}function IDA(A,Q,$){return new h80({type:"record",keyType:A,valueType:Q,mode:"loose",...k1($)})}function HDA(A,Q,$){return new X14({type:"map",keyType:A,valueType:Q,...k1($)})}function qDA(A,Q){return new G14({type:"set",valueType:A,...k1(Q)})}function V14(A,Q){let $=Array.isArray(A)?Object.fromEntries(A.map((B)=>[B,B])):A;return new Wk0({type:"enum",entries:$,...k1(Q)})}function NDA(A,Q){return new Wk0({type:"enum",entries:A,...k1(Q)})}function CDA(A,Q){return new K14({type:"literal",values:Array.isArray(A)?A:[A],...k1(Q)})}function wDA(A){return sp(z14,A)}function MDA(A){return new W14({type:"transform",transform:A})}function I14(A){return new Ik0({type:"optional",innerType:A})}function LDA(A){return new H14({type:"optional",innerType:A})}function N14(A){return new q14({type:"nullable",innerType:A})}function ODA(A){return I14(N14(A))}function jDA(A,Q){return new C14({type:"default",innerType:A,get defaultValue(){return typeof Q==="function"?Q():L_(Q)}})}function RDA(A,Q){return new w14({type:"prefault",innerType:A,get defaultValue(){return typeof Q==="function"?Q():L_(Q)}})}function uDA(A,Q){return new Hk0({type:"nonoptional",innerType:A,...k1(Q)})}function PDA(A){return new M14({type:"success",innerType:A})}function _DA(A,Q){return new L14({type:"catch",innerType:A,catchValue:typeof Q==="function"?Q:()=>Q})}function TDA(A){return rp(O14,A)}function vDA(A,Q){return new qk0({type:"pipe",in:A,out:Q})}function kDA(A,Q,$){return new Nk0({type:"pipe",in:A,out:Q,transform:$.decode,reverseTransform:$.encode})}function SDA(A){return new j14({type:"readonly",innerType:A})}function fDA(A,Q){return new R14({type:"template_literal",parts:A,...k1(Q)})}function P14(A){return new u14({type:"lazy",getter:A})}function yDA(A){return new _14({type:"promise",innerType:A})}function xDA(A,Q){let $=new U5({check:"custom",...k1(Q)});return $._zod.check=A,$}function T14(A,Q){return tp(Ck0,A??(()=>!0),Q)}function bDA(A,Q={}){return ep(Ck0,A,Q)}function hDA(A){return Ac(A)}function dDA(A,Q={}){let $=T14((B)=>B instanceof A,Q);return $._zod.bag.Class=A,$._zod.check=(B)=>{if(!(B.value instanceof A))B.issues.push({code:"invalid_type",expected:A.name,input:B.value,inst:$,path:[...$._zod.def.path??[]]})},$}function cDA(){let A=P14(()=>{return D14([Xk0(),l04(),i04(),r04(),Kk0(A),U14(Xk0(),A)])});return A}function lDA(A){return new v14({type:"function",input:Array.isArray(A?.input)?Z14(A?.input):A?.input??Kk0(y80()),output:A?.output??y80()})}var HA,lT,y5,R04,u04,$l,Gk0,P04,_04,T04,v04,k04,S04,f04,y04,x04,b04,h04,g04,m04,d04,p04,c04,Bl,Dl,iT,Jl,El,Vk0,n04,a04,o04,s04,t04,e04,Q14,x80,$14,b80,zk0,J14,E14,F14,Y14,h80,X14,G14,Wk0,K14,z14,W14,Ik0,H14,q14,C14,w14,Hk0,M14,L14,O14,qk0,Nk0,j14,R14,u14,_14,Ck0,gDA,mDA,pDA=(...A)=>Bc({Codec:Nk0,Boolean:Jl,String:lT},...A),v14;var g80=o(()=>{J9();J6();Uk0();HA=f0("ZodMiniType",(A,Q)=>{if(!A._zod)throw Error("Uninitialized schema in ZodMiniType.");g6.init(A,Q),A.def=Q,A.type=Q.type,A.parse=($,B)=>xI(A,$,B,{callee:A.parse}),A.safeParse=($,B)=>BK(A,$,B),A.parseAsync=async($,B)=>bI(A,$,B,{callee:A.parseAsync}),A.safeParseAsync=async($,B)=>hI(A,$,B),A.check=(...$)=>{return A.clone({...Q,checks:[...Q.checks??[],...$.map((B)=>typeof B==="function"?{_zod:{check:B,def:{check:"custom"},onattach:[]}}:B)]},{parent:!0})},A.with=A.check,A.clone=($,B)=>D9(A,$,B),A.brand=()=>A,A.register=($,B)=>{return $.add(A,B),A},A.apply=($)=>$(A)}),lT=f0("ZodMiniString",(A,Q)=>{DK.init(A,Q),HA.init(A,Q)});y5=f0("ZodMiniStringFormat",(A,Q)=>{e3.init(A,Q),lT.init(A,Q)}),R04=f0("ZodMiniEmail",(A,Q)=>{Yd.init(A,Q),y5.init(A,Q)});u04=f0("ZodMiniGUID",(A,Q)=>{Ed.init(A,Q),y5.init(A,Q)});$l=f0("ZodMiniUUID",(A,Q)=>{Fd.init(A,Q),y5.init(A,Q)});Gk0=f0("ZodMiniURL",(A,Q)=>{Zd.init(A,Q),y5.init(A,Q)});P04=f0("ZodMiniEmoji",(A,Q)=>{Ud.init(A,Q),y5.init(A,Q)});_04=f0("ZodMiniNanoID",(A,Q)=>{Xd.init(A,Q),y5.init(A,Q)});T04=f0("ZodMiniCUID",(A,Q)=>{Gd.init(A,Q),y5.init(A,Q)});v04=f0("ZodMiniCUID2",(A,Q)=>{Vd.init(A,Q),y5.init(A,Q)});k04=f0("ZodMiniULID",(A,Q)=>{Kd.init(A,Q),y5.init(A,Q)});S04=f0("ZodMiniXID",(A,Q)=>{zd.init(A,Q),y5.init(A,Q)});f04=f0("ZodMiniKSUID",(A,Q)=>{Wd.init(A,Q),y5.init(A,Q)});y04=f0("ZodMiniIPv4",(A,Q)=>{Cd.init(A,Q),y5.init(A,Q)});x04=f0("ZodMiniIPv6",(A,Q)=>{wd.init(A,Q),y5.init(A,Q)});b04=f0("ZodMiniCIDRv4",(A,Q)=>{Ld.init(A,Q),y5.init(A,Q)});h04=f0("ZodMiniCIDRv6",(A,Q)=>{Od.init(A,Q),y5.init(A,Q)});g04=f0("ZodMiniMAC",(A,Q)=>{Md.init(A,Q),y5.init(A,Q)});m04=f0("ZodMiniBase64",(A,Q)=>{jd.init(A,Q),y5.init(A,Q)});d04=f0("ZodMiniBase64URL",(A,Q)=>{Rd.init(A,Q),y5.init(A,Q)});p04=f0("ZodMiniE164",(A,Q)=>{ud.init(A,Q),y5.init(A,Q)});c04=f0("ZodMiniJWT",(A,Q)=>{Pd.init(A,Q),y5.init(A,Q)});Bl=f0("ZodMiniCustomStringFormat",(A,Q)=>{_d.init(A,Q),y5.init(A,Q)});Dl=f0("ZodMiniNumber",(A,Q)=>{T_.init(A,Q),HA.init(A,Q)});iT=f0("ZodMiniNumberFormat",(A,Q)=>{Td.init(A,Q),Dl.init(A,Q)});Jl=f0("ZodMiniBoolean",(A,Q)=>{rM.init(A,Q),HA.init(A,Q)});El=f0("ZodMiniBigInt",(A,Q)=>{v_.init(A,Q),HA.init(A,Q)});Vk0=f0("ZodMiniBigIntFormat",(A,Q)=>{vd.init(A,Q),El.init(A,Q)});n04=f0("ZodMiniSymbol",(A,Q)=>{kd.init(A,Q),HA.init(A,Q)});a04=f0("ZodMiniUndefined",(A,Q)=>{Sd.init(A,Q),HA.init(A,Q)});o04=f0("ZodMiniNull",(A,Q)=>{fd.init(A,Q),HA.init(A,Q)});s04=f0("ZodMiniAny",(A,Q)=>{yd.init(A,Q),HA.init(A,Q)});t04=f0("ZodMiniUnknown",(A,Q)=>{xd.init(A,Q),HA.init(A,Q)});e04=f0("ZodMiniNever",(A,Q)=>{bd.init(A,Q),HA.init(A,Q)});Q14=f0("ZodMiniVoid",(A,Q)=>{hd.init(A,Q),HA.init(A,Q)});x80=f0("ZodMiniDate",(A,Q)=>{gd.init(A,Q),HA.init(A,Q)});$14=f0("ZodMiniArray",(A,Q)=>{md.init(A,Q),HA.init(A,Q)});b80=f0("ZodMiniObject",(A,Q)=>{U20.init(A,Q),HA.init(A,Q),zA(A,"shape",()=>Q.shape)});zk0=f0("ZodMiniUnion",(A,Q)=>{sM.init(A,Q),HA.init(A,Q)});J14=f0("ZodMiniXor",(A,Q)=>{zk0.init(A,Q),dd.init(A,Q)});E14=f0("ZodMiniDiscriminatedUnion",(A,Q)=>{pd.init(A,Q),HA.init(A,Q)});F14=f0("ZodMiniIntersection",(A,Q)=>{cd.init(A,Q),HA.init(A,Q)});Y14=f0("ZodMiniTuple",(A,Q)=>{k_.init(A,Q),HA.init(A,Q)});h80=f0("ZodMiniRecord",(A,Q)=>{ld.init(A,Q),HA.init(A,Q)});X14=f0("ZodMiniMap",(A,Q)=>{id.init(A,Q),HA.init(A,Q)});G14=f0("ZodMiniSet",(A,Q)=>{nd.init(A,Q),HA.init(A,Q)});Wk0=f0("ZodMiniEnum",(A,Q)=>{ad.init(A,Q),HA.init(A,Q),A.options=Object.values(Q.entries)});K14=f0("ZodMiniLiteral",(A,Q)=>{od.init(A,Q),HA.init(A,Q)});z14=f0("ZodMiniFile",(A,Q)=>{rd.init(A,Q),HA.init(A,Q)});W14=f0("ZodMiniTransform",(A,Q)=>{sd.init(A,Q),HA.init(A,Q)});Ik0=f0("ZodMiniOptional",(A,Q)=>{S_.init(A,Q),HA.init(A,Q)});H14=f0("ZodMiniExactOptional",(A,Q)=>{td.init(A,Q),HA.init(A,Q)});q14=f0("ZodMiniNullable",(A,Q)=>{ed.init(A,Q),HA.init(A,Q)});C14=f0("ZodMiniDefault",(A,Q)=>{Ap.init(A,Q),HA.init(A,Q)});w14=f0("ZodMiniPrefault",(A,Q)=>{Qp.init(A,Q),HA.init(A,Q)});Hk0=f0("ZodMiniNonOptional",(A,Q)=>{$p.init(A,Q),HA.init(A,Q)});M14=f0("ZodMiniSuccess",(A,Q)=>{Bp.init(A,Q),HA.init(A,Q)});L14=f0("ZodMiniCatch",(A,Q)=>{Dp.init(A,Q),HA.init(A,Q)});O14=f0("ZodMiniNaN",(A,Q)=>{Jp.init(A,Q),HA.init(A,Q)});qk0=f0("ZodMiniPipe",(A,Q)=>{Ep.init(A,Q),HA.init(A,Q)});Nk0=f0("ZodMiniCodec",(A,Q)=>{qk0.init(A,Q),tM.init(A,Q)});j14=f0("ZodMiniReadonly",(A,Q)=>{Fp.init(A,Q),HA.init(A,Q)});R14=f0("ZodMiniTemplateLiteral",(A,Q)=>{Yp.init(A,Q),HA.init(A,Q)});u14=f0("ZodMiniLazy",(A,Q)=>{Xp.init(A,Q),HA.init(A,Q)});_14=f0("ZodMiniPromise",(A,Q)=>{Up.init(A,Q),HA.init(A,Q)});Ck0=f0("ZodMiniCustom",(A,Q)=>{Gp.init(A,Q),HA.init(A,Q)});gDA=Qc,mDA=$c;v14=f0("ZodMiniFunction",(A,Q)=>{Zp.init(A,Q),HA.init(A,Q)})});var S14=o(()=>{J9()});var wk0={};H2(wk0,{time:()=>aDA,duration:()=>oDA,datetime:()=>iDA,date:()=>nDA,ZodMiniISOTime:()=>p80,ZodMiniISODuration:()=>c80,ZodMiniISODateTime:()=>m80,ZodMiniISODate:()=>d80});function iDA(A){return Lp(m80,A)}function nDA(A){return Op(d80,A)}function aDA(A){return jp(p80,A)}function oDA(A){return Rp(c80,A)}var m80,d80,p80,c80;var Mk0=o(()=>{J9();g80();m80=f0("ZodMiniISODateTime",(A,Q)=>{Id.init(A,Q),y5.init(A,Q)});d80=f0("ZodMiniISODate",(A,Q)=>{Hd.init(A,Q),y5.init(A,Q)});p80=f0("ZodMiniISOTime",(A,Q)=>{qd.init(A,Q),y5.init(A,Q)});c80=f0("ZodMiniISODuration",(A,Q)=>{Nd.init(A,Q),y5.init(A,Q)})});var Lk0={};H2(Lk0,{string:()=>rDA,number:()=>sDA,date:()=>AJA,boolean:()=>tDA,bigint:()=>eDA});function rDA(A){return Cp(lT,A)}function sDA(A){return Pp(Dl,A)}function tDA(A){return yp(Jl,A)}function eDA(A){return bp(El,A)}function AJA(A){return op(x80,A)}var f14=o(()=>{J9();g80()});var rB={};H2(rB,{xor:()=>VDA,xid:()=>uBA,void:()=>ADA,uuidv7:()=>NBA,uuidv6:()=>qBA,uuidv4:()=>HBA,uuid:()=>IBA,util:()=>e1,url:()=>CBA,uppercase:()=>pI,unknown:()=>y80,union:()=>D14,undefined:()=>tBA,ulid:()=>RBA,uint64:()=>rBA,uint32:()=>nBA,tuple:()=>Z14,trim:()=>oI,treeifyError:()=>Qd,transform:()=>MDA,toUpperCase:()=>sI,toLowerCase:()=>rI,toJSONSchema:()=>UT,templateLiteral:()=>fDA,symbol:()=>sBA,superRefine:()=>hDA,success:()=>PDA,stringbool:()=>pDA,stringFormat:()=>hBA,string:()=>Xk0,strictObject:()=>BDA,startsWith:()=>lI,size:()=>JK,set:()=>qDA,safeParseAsync:()=>hI,safeParse:()=>BK,safeExtend:()=>EDA,safeEncodeAsync:()=>Yu0,safeEncode:()=>Eu0,safeDecodeAsync:()=>Zu0,safeDecode:()=>Fu0,required:()=>XDA,registry:()=>y_,regexes:()=>v9,regex:()=>mI,refine:()=>bDA,record:()=>U14,readonly:()=>SDA,property:()=>FT,promise:()=>yDA,prettifyError:()=>$d,prefault:()=>RDA,positive:()=>BT,pipe:()=>vDA,pick:()=>YDA,partialRecord:()=>WDA,partial:()=>UDA,parseAsync:()=>bI,parse:()=>xI,overwrite:()=>KJ,optional:()=>I14,omit:()=>ZDA,object:()=>B14,number:()=>l04,nullish:()=>ODA,nullable:()=>N14,null:()=>r04,normalize:()=>aI,nonpositive:()=>JT,nonoptional:()=>uDA,nonnegative:()=>ET,never:()=>A14,negative:()=>DT,nativeEnum:()=>NDA,nanoid:()=>LBA,nan:()=>TDA,multipleOf:()=>FX,minimum:()=>V7,minSize:()=>rE,minLength:()=>lY,mime:()=>nI,meta:()=>mDA,merge:()=>FDA,maximum:()=>yQ,maxSize:()=>YX,maxLength:()=>EK,map:()=>HDA,mac:()=>SBA,lte:()=>yQ,lt:()=>aE,lowercase:()=>dI,looseRecord:()=>IDA,looseObject:()=>DDA,locales:()=>eM,literal:()=>CDA,length:()=>FK,lazy:()=>P14,ksuid:()=>PBA,keyof:()=>$DA,jwt:()=>bBA,json:()=>cDA,iso:()=>wk0,ipv6:()=>TBA,ipv4:()=>_BA,intersection:()=>zDA,int64:()=>oBA,int32:()=>iBA,int:()=>pBA,instanceof:()=>dDA,includes:()=>cI,httpUrl:()=>wBA,hostname:()=>gBA,hex:()=>mBA,hash:()=>dBA,guid:()=>WBA,gte:()=>V7,gt:()=>oE,globalRegistry:()=>k9,function:()=>lDA,formatError:()=>aM,float64:()=>lBA,float32:()=>cBA,flattenError:()=>nM,file:()=>wDA,extend:()=>JDA,exactOptional:()=>LDA,enum:()=>V14,endsWith:()=>iI,encodeAsync:()=>Du0,encode:()=>$u0,emoji:()=>MBA,email:()=>zBA,e164:()=>xBA,discriminatedUnion:()=>KDA,describe:()=>gDA,decodeAsync:()=>Ju0,decode:()=>Bu0,date:()=>QDA,custom:()=>T14,cuid2:()=>jBA,cuid:()=>OBA,core:()=>iB,config:()=>h2,coerce:()=>Lk0,codec:()=>kDA,clone:()=>D9,cidrv6:()=>kBA,cidrv4:()=>vBA,check:()=>xDA,catchall:()=>GDA,catch:()=>_DA,boolean:()=>i04,bigint:()=>aBA,base64url:()=>yBA,base64:()=>fBA,array:()=>Kk0,any:()=>eBA,_function:()=>lDA,_default:()=>jDA,ZodMiniXor:()=>J14,ZodMiniXID:()=>S04,ZodMiniVoid:()=>Q14,ZodMiniUnknown:()=>t04,ZodMiniUnion:()=>zk0,ZodMiniUndefined:()=>a04,ZodMiniUUID:()=>$l,ZodMiniURL:()=>Gk0,ZodMiniULID:()=>k04,ZodMiniType:()=>HA,ZodMiniTuple:()=>Y14,ZodMiniTransform:()=>W14,ZodMiniTemplateLiteral:()=>R14,ZodMiniSymbol:()=>n04,ZodMiniSuccess:()=>M14,ZodMiniStringFormat:()=>y5,ZodMiniString:()=>lT,ZodMiniSet:()=>G14,ZodMiniRecord:()=>h80,ZodMiniReadonly:()=>j14,ZodMiniPromise:()=>_14,ZodMiniPrefault:()=>w14,ZodMiniPipe:()=>qk0,ZodMiniOptional:()=>Ik0,ZodMiniObject:()=>b80,ZodMiniNumberFormat:()=>iT,ZodMiniNumber:()=>Dl,ZodMiniNullable:()=>q14,ZodMiniNull:()=>o04,ZodMiniNonOptional:()=>Hk0,ZodMiniNever:()=>e04,ZodMiniNanoID:()=>_04,ZodMiniNaN:()=>O14,ZodMiniMap:()=>X14,ZodMiniMAC:()=>g04,ZodMiniLiteral:()=>K14,ZodMiniLazy:()=>u14,ZodMiniKSUID:()=>f04,ZodMiniJWT:()=>c04,ZodMiniIntersection:()=>F14,ZodMiniISOTime:()=>p80,ZodMiniISODuration:()=>c80,ZodMiniISODateTime:()=>m80,ZodMiniISODate:()=>d80,ZodMiniIPv6:()=>x04,ZodMiniIPv4:()=>y04,ZodMiniGUID:()=>u04,ZodMiniFunction:()=>v14,ZodMiniFile:()=>z14,ZodMiniExactOptional:()=>H14,ZodMiniEnum:()=>Wk0,ZodMiniEmoji:()=>P04,ZodMiniEmail:()=>R04,ZodMiniE164:()=>p04,ZodMiniDiscriminatedUnion:()=>E14,ZodMiniDefault:()=>C14,ZodMiniDate:()=>x80,ZodMiniCustomStringFormat:()=>Bl,ZodMiniCustom:()=>Ck0,ZodMiniCodec:()=>Nk0,ZodMiniCatch:()=>L14,ZodMiniCUID2:()=>v04,ZodMiniCUID:()=>T04,ZodMiniCIDRv6:()=>h04,ZodMiniCIDRv4:()=>b04,ZodMiniBoolean:()=>Jl,ZodMiniBigIntFormat:()=>Vk0,ZodMiniBigInt:()=>El,ZodMiniBase64URL:()=>d04,ZodMiniBase64:()=>m04,ZodMiniArray:()=>$14,ZodMiniAny:()=>s04,TimePrecision:()=>Mp,NEVER:()=>cM,$output:()=>Ip,$input:()=>Hp,$brand:()=>nm});var Ok0=o(()=>{J9();J9();XT();X20();Mk0();Mk0();f14();Uk0();g80();S14()});var jk0=o(()=>{Ok0();Ok0()});var $JA,y14,cN5,BJA,lN5;var x14=o(()=>{bQ();jk0();$JA=S.templateLiteral([S.string().regex(/^[0-9a-f]{8}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{4}$/),"-",S.string().regex(/^[0-9a-f]{12}$/)]),y14=S.templateLiteral(["T-",$JA]),cN5=rB.union([rB.object({visibility:rB.literal("private"),sharedGroupIDs:rB.array(rB.string())}),rB.object({visibility:rB.literal("thread_group_shared"),sharedGroupIDs:rB.array(rB.string())}),rB.object({visibility:rB.enum(["thread_workspace_shared","public_unlisted","public_discoverable"])})]),BJA=S.string(),lN5=S.object({id:BJA,title:S.string().optional(),messageCount:S.number(),updatedAt:S.string(),firstSyncAt:S.string(),created:S.number(),creatorUserID:S.string(),meta:S.object({visibility:S.enum(["private","thread_group_shared","public_unlisted","public_discoverable","thread_workspace_shared"]),sharedGroupIDs:S.array(S.string())}),labels:S.array(S.object({id:S.string(),name:S.string(),createdAt:S.string()}))})});var b14=()=>{};var h14=()=>{};var Rk0=o(()=>{Ql();Zk0();x14();b14();h14()});import{randomFillSync as DJA}from"crypto";function n80(){if(l80>i80.length-16)DJA(i80),l80=0;return i80.slice(l80,l80+=16)}var i80,l80;var g14=o(()=>{i80=new Uint8Array(256),l80=i80.length});function m14(A,Q=0){return(r7[A[Q+0]]+r7[A[Q+1]]+r7[A[Q+2]]+r7[A[Q+3]]+"-"+r7[A[Q+4]]+r7[A[Q+5]]+"-"+r7[A[Q+6]]+r7[A[Q+7]]+"-"+r7[A[Q+8]]+r7[A[Q+9]]+"-"+r7[A[Q+10]]+r7[A[Q+11]]+r7[A[Q+12]]+r7[A[Q+13]]+r7[A[Q+14]]+r7[A[Q+15]]).toLowerCase()}var r7;var d14=o(()=>{r7=[];for(let A=0;A<256;++A)r7.push((A+256).toString(16).slice(1))});function JJA(A,Q,$){let B;if(A)B=p14(A.random??A.rng?.()??n80(),A.msecs,A.seq,Q,$);else{let D=Date.now(),J=n80();EJA(uk0,D,J),B=p14(J,uk0.msecs,uk0.seq,Q,$)}return Q??m14(B)}function EJA(A,Q,$){if(A.msecs??=-1/0,A.seq??=0,Q>A.msecs)A.seq=$[6]<<23|$[7]<<16|$[8]<<8|$[9],A.msecs=Q;else if(A.seq=A.seq+1|0,A.seq===0)A.msecs++;return A}function p14(A,Q,$,B,D=0){if(A.length<16)throw Error("Random bytes length must be >= 16");if(!B)B=new Uint8Array(16),D=0;else if(D<0||D+16>B.length)throw RangeError(`UUID byte range ${D}:${D+15} is out of buffer bounds`);return Q??=Date.now(),$??=A[6]*127<<24|A[7]<<16|A[8]<<8|A[9],B[D++]=Q/1099511627776&255,B[D++]=Q/4294967296&255,B[D++]=Q/16777216&255,B[D++]=Q/65536&255,B[D++]=Q/256&255,B[D++]=Q&255,B[D++]=112|$>>>28&15,B[D++]=$>>>20&255,B[D++]=128|$>>>14&63,B[D++]=$>>>6&255,B[D++]=$<<2&255|A[10]&3,B[D++]=A[11],B[D++]=A[12],B[D++]=A[13],B[D++]=A[14],B[D++]=A[15],B}var uk0,nT;var c14=o(()=>{g14();d14();uk0={};nT=JJA});var Pk0=o(()=>{c14()});function FJA(A){let Q=0,$=[];while(Q<A.length){let B=A[Q];if(B==="\\"){Q++;continue}if(B==="{"){$.push({type:"brace",value:"{"}),Q++;continue}if(B==="}"){$.push({type:"brace",value:"}"}),Q++;continue}if(B==="["){$.push({type:"paren",value:"["}),Q++;continue}if(B==="]"){$.push({type:"paren",value:"]"}),Q++;continue}if(B===":"){$.push({type:"separator",value:":"}),Q++;continue}if(B===","){$.push({type:"delimiter",value:","}),Q++;continue}if(B==='"'){let F="",Y=!1;B=A[++Q];while(B!=='"'){if(Q===A.length){Y=!0;break}if(B==="\\"){if(Q++,Q===A.length){Y=!0;break}F+=B+A[Q],B=A[++Q]}else F+=B,B=A[++Q]}if(B=A[++Q],!Y)$.push({type:"string",value:F});continue}if(B&&/\s/.test(B)){Q++;continue}let J=/[0-9]/;if(B&&J.test(B)||B==="-"||B==="."){let F="";if(B==="-")F+=B,B=A[++Q];while(B&&J.test(B)||B===".")F+=B,B=A[++Q];$.push({type:"number",value:F});continue}let E=/[a-z]/i;if(B&&E.test(B)){let F="";while(B&&E.test(B)){if(Q===A.length)break;F+=B,B=A[++Q]}if(F==="true"||F==="false"||F==="null")$.push({type:"name",value:F});else{Q++;continue}continue}Q++}return $}function aT(A){if(A.length===0)return A;let Q=A[A.length-1];if(!Q)return A;switch(Q.type){case"separator":return aT(A.slice(0,A.length-1));case"number":{let $=Q.value[Q.value.length-1];if($==="."||$==="-")return aT(A.slice(0,A.length-1));break}case"string":{let $=A[A.length-2];if($?.type==="delimiter")return aT(A.slice(0,A.length-1));else if($?.type==="brace"&&$.value==="{")return aT(A.slice(0,A.length-1));break}case"delimiter":return aT(A.slice(0,A.length-1))}return A}function YJA(A){let Q=[];for(let $ of A){if($.type==="brace")if($.value==="{")Q.push("}");else{let B=Q.lastIndexOf("}");if(B!==-1)Q.splice(B,1)}if($.type==="paren")if($.value==="[")Q.push("]");else{let B=Q.lastIndexOf("]");if(B!==-1)Q.splice(B,1)}}if(Q.length>0){Q.reverse();for(let $ of Q)if($==="}")A.push({type:"brace",value:"}"});else if($==="]")A.push({type:"paren",value:"]"})}return A}function ZJA(A){let Q="";for(let $ of A)switch($.type){case"string":Q+='"'+$.value+'"';break;default:Q+=$.value;break}return Q}function a80(A){let Q=ZJA(YJA(aT(FJA(A))));return JSON.parse(Q)}function o80(A){try{let Q=a80(A);if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q))return Q;return{}}catch{return{}}}function r80(A,Q,$="..."){if(A.length<=Q)return A;return A.slice(0,Math.max(0,Q-$.length))+$}function UJA(A){let Q=A.match(/^(?:cat\s+)?<<['"]?(\w+)['"]?\s*\n([\s\S]*?)\n\1\s*$/);if(Q)return Q[2];return A}function XJA(A,Q){let $=A[Q];if(!$)return null;let B=$.match(/^\*\*\* Add File: (.+)$/);if(B)return{filePath:B[1],nextIdx:Q+1};let D=$.match(/^\*\*\* Delete File: (.+)$/);if(D)return{filePath:D[1],nextIdx:Q+1};let J=$.match(/^\*\*\* Update File: (.+)$/);if(J){let E,F=Q+1,Y=A[F];if(Y){let Z=Y.match(/^\*\*\* Move to: (.+)$/);if(Z)E=Z[1],F++}return{filePath:J[1],movePath:E,nextIdx:F}}return null}function _k0(A){return A.startsWith("*** Add File:")||A.startsWith("*** Update File:")||A.startsWith("*** Delete File:")||A.trim()==="*** End Patch"}function GJA(A,Q){let $=[],B=Q;while(B<A.length){let D=A[B];if(_k0(D))break;if(D.startsWith("+"))$.push(D.slice(1));else if(D==="")$.push("");else throw Error(`Invalid patch format: Add File lines must start with '+', got: "${D.slice(0,20)}${D.length>20?"...":""}"`);B++}return{content:$.join(`
217
217
  `),nextIdx:B}}function l14(A){return A.startsWith("+")||A.startsWith("-")||A.startsWith(" ")}function VJA(A,Q){let $=[],B=Q;while(B<A.length){let D=A[B];if(_k0(D))break;if(D.trim()==="*** End of File"){B++;continue}if(D.startsWith("@@")||l14(D)){let{chunk:J,nextIdx:E}=KJA(A,B);$.push(J),B=E;continue}throw Error(`Invalid patch format: unexpected line in Update File: "${D.slice(0,30)}..."`)}return{chunks:$,nextIdx:B}}function KJA(A,Q){let $=Q,B=[],D=[],J=!1,E=[];while($<A.length&&A[$].startsWith("@@")){let Z=A[$].slice(2).trimStart();if(Z)E.push(Z);$++}while($<A.length){let Y=A[$];if(Y.trim()==="*** End of File"){J=!0,$++;break}if(Y.startsWith("@@")||_k0(Y))break;if(!l14(Y))throw Error(`Invalid patch format: hunk lines must start with ' ', '-', or '+', got: "${Y.slice(0,20)}..."`);if(Y.startsWith("-"))B.push(Y.slice(1));else if(Y.startsWith("+"))D.push(Y.slice(1));else if(Y.startsWith(" "))B.push(Y.slice(1)),D.push(Y.slice(1));$++}let F=E.length>0?E.filter(Boolean).join(`
218
218
  `):void 0;return{chunk:{oldLines:B,newLines:D,changeContext:F,isEndOfFile:J},nextIdx:$}}function IX(A){let $=UJA(A.trim()).split(`
219
219
  `),B=[],D=[],J="*** Begin Patch",E="*** End Patch",F=$.findIndex((V)=>V.trim()==="*** Begin Patch"),Y=$.findIndex((V)=>V.trim()==="*** End Patch");if(F===-1&&Y===-1)throw Error(`Invalid patch format: missing *** Begin Patch and *** End Patch markers.
@@ -4787,13 +4787,13 @@ ${z}`))}},error:(K)=>{if(!V)V=!0,Z(Error(`Failed to spawn brew: ${K.message}`))}
4787
4787
  ${z}`;if(E==="pnpm"&&z.includes("Unable to find the global bin directory"))W+=`
4788
4788
 
4789
4789
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4790
- npm install -g ${J}`;Z(Error(W))}},error:(K)=>{if(!G)G=!0,Z(Error(`Failed to spawn ${E}: ${K.message}`))},complete:()=>{if(!G)G=!0,Y()}})})}c0();c0();Cz();var lM3="@ampcode/cli";async function SU0(A,Q,$=lM3){let D=`${Q||"https://registry.npmjs.org"}/${$}/latest`,J=new AbortController,E=setTimeout(()=>J.abort(),5000);try{let F=await fetch(D,{signal:J.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let Y=await F.json(),Z=Y.version??Y["dist-tags"]?.latest;if(!Z)return{hasUpdate:!1,currentVersion:A,source:"npm"};let U=Ct(A,Z),X=U<0,G,V;if(Y.time){let K=Y.time[A],z=Y.time[Z],W=Date.now();if(K)G=Math.floor((W-new Date(K).getTime())/3600000);if(z)V=Math.floor((W-new Date(z).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:A,latestVersion:Z,compareResult:U,hasUpdate:X,currentVersionAge:G,latestVersionAge:V}),{hasUpdate:X,latestVersion:Z,currentVersion:A,currentVersionAge:G,latestVersionAge:V,source:"npm"}}catch(F){return u.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(E)}}var iM3="https://static.ampcode.com/cli/cli-version.txt";async function fU0(A){let Q=new AbortController,$=setTimeout(()=>Q.abort(),5000);try{let B=await fetch(`${iM3}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!B.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let D=(await B.text()).trim();if(!D||!/^\d+\.\d+\.\d+/.test(D))return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=Ct(A,D),E=J<0;return u.info("Bin version comparison",{currentVersion:A,latestVersion:D,compareResult:J,hasUpdate:E}),{hasUpdate:E,latestVersion:D,currentVersion:A,source:"bin"}}catch(B){return u.debug("Error checking bin version",{error:B}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout($)}}var nM3=604800000;function _b4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let $=Date.now()-Q;if($>nM3)return{ageMs:$};return null}function Ct(A,Q){let $=(E)=>{let[F,Y]=E.split("-");return{parts:F?.split(".").map(Number)||[],label:Y}},B=$(A),D=$(Q),J=Math.max(B.parts.length,D.parts.length);for(let E=0;E<J;E++){let F=B.parts[E]||0,Y=D.parts[E]||0;if(F<Y)return-1;if(F>Y)return 1}if(B.label===D.label)return 0;if(!B.label&&D.label)return 1;if(B.label&&!D.label)return-1;if(B.label&&D.label)return B.label<D.label?-1:1;return 0}function wt(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-(.+))?/);if(!Q)return null;let $=parseInt(Q[1],10),B=$!==0?$*1000:void 0,J=Q[2]?.match(/^g?([a-f0-9]+)$/)?.[1],E=B!==void 0?fF(B):void 0;return{sha:J,timestamp:B,age:E}}catch{return null}}u1();c0();import{readFile as aM3,realpath as oM3}from"node:fs/promises";import{dirname as Tb4,join as rM3}from"node:path";async function vb4(A){switch(A){case"binary":case"brew":return sM3(qt());case"npm":case"pnpm":case"yarn":case"bun":return tM3()}}async function sM3(A){let Q=await hN(A,["--version"],5000);if(Q.reason!=="success")return u.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function tM3(){try{let A=process.argv[1];if(!A)return null;let Q=await oM3(A),$=Tb4(Tb4(Q));return await eM3(rM3($,"package.json"))}catch(A){return u.debug("failed to read installed version from package.json",{error:A}),null}}async function eM3(A){let Q=await aM3(A,"utf8"),$=JSON.parse(Q);if(!$.name||!he0($.name))return u.debug("package.json name mismatch",{pkgJsonPath:A,name:$.name}),null;return $.version||null}c0();import{spawn as AL3}from"node:child_process";function ie0(A){if(A=A.replace(/\/$/,""),!A.startsWith("http://")&&!A.startsWith("https://"))A=`https://${A}`;try{return new URL(A),A}catch{return u.warn(`Invalid registry URL: ${A}, falling back to npmjs.org`),"https://registry.npmjs.org"}}var yU0=null,Mt=null;function kb4(A){return new Promise((Q)=>{let $=AL3("npm",["config","get",A],{stdio:["ignore","pipe","ignore"],timeout:5000,shell:process.platform==="win32"}),B="";$.stdout.on("data",(D)=>{B+=D.toString()}),$.on("close",(D,J)=>{if(D!==0||J==="SIGTERM"){Q(null);return}let E=B.trim();Q(E&&E!=="undefined"?E:null)}),$.on("error",()=>{Q(null)})})}async function xU0(){if(yU0)return yU0;if(Mt)return Mt;Mt=(async()=>{let A=process.env.NPM_CONFIG_REGISTRY??process.env.npm_config_registry;if(A)return ie0(A);let Q=await kb4("@sourcegraph:registry");if(Q)return ie0(Q);let $=await kb4("registry");if($)return ie0($);return"https://registry.npmjs.org"})();try{return yU0=await Mt,yU0}finally{Mt=null}}var QL3=3600000,$L3=5000;function bU0(A,Q,$={}){let B=new d4,D=B.pipe(e6({shouldCountRefs:!1})),J=$.startDelayMs??0,E=$.checkIntervalMs??QL3,F=!1,Y=()=>{F=!0};return setImmediate(async()=>{let Z=u.getChild("update");if(J>0){if(await YG(J),F)return}let U=D.subscribe({next:(G)=>{Z.debug("emit new state",G)}}),X=A;try{while(!F){let G=await BL3(X,Q,Z,B);if(G.stop)return;if(G.updatedTo)X=G.updatedTo;if(G.emittedVisibleState){if(await YG($L3),F)return;B.next("hidden")}if(E<=0)return;let V=1000,K=E;while(K>0&&!F){let z=Math.min(V,K);await YG(z),K-=z}}}finally{U.unsubscribe(),B.complete()}}),{state:D,dispose:Y}}async function BL3(A,Q,$,B){let D={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return $.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),D.stop=!0,D;let J=await Q.get("updates.mode");if(J==="disabled")return $.debug("checking disabled"),D.stop=!0,D;let E=await xG(),F=E==="binary"||E==="brew",Y=F?void 0:await gN();$.debug("checking",{currentVersion:A,mode:J,packageManager:E,isBinaryDistribution:F,npmPackageName:Y});let Z;if(F)Z=await fU0(A);else{let G=await xU0();Z=await SU0(A,G,Y)}if(!(Z.latestVersion&&Z.hasUpdate))return $.debug("no update available"),D;let U=(G)=>{B.next(G),D.emittedVisibleState=!0};if(E){let G=await vb4(E);if(G&&Ct(G,Z.latestVersion)>=0){if($.debug("on-disk version already up to date",{currentVersion:A,installedVersion:G,latestVersion:Z.latestVersion}),D.updatedTo=G,Ct(A,G)<0){let V=await pz(G),K={from:A,to:G,externallyUpdated:!0,...V};if(V.status==="same")$.info("on-disk already updated by another instance",K),U("updated");else $.warn("on-disk already updated by another instance, with PATH warning",K),U("updated-with-warning")}return D}}let X=()=>{if(Z.currentVersionAge!==void 0&&Z.latestVersionAge!==void 0){let G=Z.currentVersionAge-Z.latestVersionAge,V=0.5;if(Math.abs(G)<0.5)return $.debug("versions too close together, suppressing update warning",{currentVersionAge:Z.currentVersionAge,latestVersionAge:Z.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!J)J=E==="pnpm"?"warn":"auto",$.debug("no configured update mode; selected default based on package manager",{packageManager:E,mode:J});if(E==="brew"){if(!X())U("update-available-brew");return D}if(E==="binary"&&process.execPath!==qt()){if($.debug("non-standard binary path, showing warning"),!X())U("update-available-unrecognized-path");return D}if(J==="warn"){if(!X())U("update-available");return D}if(!E){if($.debug("auto-update not supported, falling back to warn mode"),!X())U("update-available");return D}try{await Nt(Z.latestVersion,E),D.updatedTo=Z.latestVersion;let G=await pz(Z.latestVersion),V={from:Z.currentVersion,to:Z.latestVersion,...G};if(G.status==="same")$.info("success",V),U("updated");else $.warn("success with warning",V),U("updated-with-warning")}catch(G){U("update-error")}return D}catch(J){return $.debug("check failed",{error:J}),D}}Cz();import{stderr as tF}from"node:process";function Sb4(A){let Q=new NN().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(B)=>{await xe0(B.force||!1,B.verbose||!1,"0.0.1779859522-gba0d26"),process.exit()});A.addCommand(Q,{hidden:!0});let $=new NN("update").alias("up").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(B)=>{await EL3(B.targetVersion)});A.addCommand($)}function DL3(A){let Q=Boolean(A.isTTY),$=0,B=!1;function D(){if(!Q||!B)return;A.write(`
4790
+ npm install -g ${J}`;Z(Error(W))}},error:(K)=>{if(!G)G=!0,Z(Error(`Failed to spawn ${E}: ${K.message}`))},complete:()=>{if(!G)G=!0,Y()}})})}c0();c0();Cz();var lM3="@ampcode/cli";async function SU0(A,Q,$=lM3){let D=`${Q||"https://registry.npmjs.org"}/${$}/latest`,J=new AbortController,E=setTimeout(()=>J.abort(),5000);try{let F=await fetch(D,{signal:J.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let Y=await F.json(),Z=Y.version??Y["dist-tags"]?.latest;if(!Z)return{hasUpdate:!1,currentVersion:A,source:"npm"};let U=Ct(A,Z),X=U<0,G,V;if(Y.time){let K=Y.time[A],z=Y.time[Z],W=Date.now();if(K)G=Math.floor((W-new Date(K).getTime())/3600000);if(z)V=Math.floor((W-new Date(z).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:A,latestVersion:Z,compareResult:U,hasUpdate:X,currentVersionAge:G,latestVersionAge:V}),{hasUpdate:X,latestVersion:Z,currentVersion:A,currentVersionAge:G,latestVersionAge:V,source:"npm"}}catch(F){return u.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(E)}}var iM3="https://static.ampcode.com/cli/cli-version.txt";async function fU0(A){let Q=new AbortController,$=setTimeout(()=>Q.abort(),5000);try{let B=await fetch(`${iM3}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!B.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let D=(await B.text()).trim();if(!D||!/^\d+\.\d+\.\d+/.test(D))return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=Ct(A,D),E=J<0;return u.info("Bin version comparison",{currentVersion:A,latestVersion:D,compareResult:J,hasUpdate:E}),{hasUpdate:E,latestVersion:D,currentVersion:A,source:"bin"}}catch(B){return u.debug("Error checking bin version",{error:B}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout($)}}var nM3=604800000;function _b4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let $=Date.now()-Q;if($>nM3)return{ageMs:$};return null}function Ct(A,Q){let $=(E)=>{let[F,Y]=E.split("-");return{parts:F?.split(".").map(Number)||[],label:Y}},B=$(A),D=$(Q),J=Math.max(B.parts.length,D.parts.length);for(let E=0;E<J;E++){let F=B.parts[E]||0,Y=D.parts[E]||0;if(F<Y)return-1;if(F>Y)return 1}if(B.label===D.label)return 0;if(!B.label&&D.label)return 1;if(B.label&&!D.label)return-1;if(B.label&&D.label)return B.label<D.label?-1:1;return 0}function wt(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-(.+))?/);if(!Q)return null;let $=parseInt(Q[1],10),B=$!==0?$*1000:void 0,J=Q[2]?.match(/^g?([a-f0-9]+)$/)?.[1],E=B!==void 0?fF(B):void 0;return{sha:J,timestamp:B,age:E}}catch{return null}}u1();c0();import{readFile as aM3,realpath as oM3}from"node:fs/promises";import{dirname as Tb4,join as rM3}from"node:path";async function vb4(A){switch(A){case"binary":case"brew":return sM3(qt());case"npm":case"pnpm":case"yarn":case"bun":return tM3()}}async function sM3(A){let Q=await hN(A,["--version"],5000);if(Q.reason!=="success")return u.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function tM3(){try{let A=process.argv[1];if(!A)return null;let Q=await oM3(A),$=Tb4(Tb4(Q));return await eM3(rM3($,"package.json"))}catch(A){return u.debug("failed to read installed version from package.json",{error:A}),null}}async function eM3(A){let Q=await aM3(A,"utf8"),$=JSON.parse(Q);if(!$.name||!he0($.name))return u.debug("package.json name mismatch",{pkgJsonPath:A,name:$.name}),null;return $.version||null}c0();import{spawn as AL3}from"node:child_process";function ie0(A){if(A=A.replace(/\/$/,""),!A.startsWith("http://")&&!A.startsWith("https://"))A=`https://${A}`;try{return new URL(A),A}catch{return u.warn(`Invalid registry URL: ${A}, falling back to npmjs.org`),"https://registry.npmjs.org"}}var yU0=null,Mt=null;function kb4(A){return new Promise((Q)=>{let $=AL3("npm",["config","get",A],{stdio:["ignore","pipe","ignore"],timeout:5000,shell:process.platform==="win32"}),B="";$.stdout.on("data",(D)=>{B+=D.toString()}),$.on("close",(D,J)=>{if(D!==0||J==="SIGTERM"){Q(null);return}let E=B.trim();Q(E&&E!=="undefined"?E:null)}),$.on("error",()=>{Q(null)})})}async function xU0(){if(yU0)return yU0;if(Mt)return Mt;Mt=(async()=>{let A=process.env.NPM_CONFIG_REGISTRY??process.env.npm_config_registry;if(A)return ie0(A);let Q=await kb4("@sourcegraph:registry");if(Q)return ie0(Q);let $=await kb4("registry");if($)return ie0($);return"https://registry.npmjs.org"})();try{return yU0=await Mt,yU0}finally{Mt=null}}var QL3=3600000,$L3=5000;function bU0(A,Q,$={}){let B=new d4,D=B.pipe(e6({shouldCountRefs:!1})),J=$.startDelayMs??0,E=$.checkIntervalMs??QL3,F=!1,Y=()=>{F=!0};return setImmediate(async()=>{let Z=u.getChild("update");if(J>0){if(await YG(J),F)return}let U=D.subscribe({next:(G)=>{Z.debug("emit new state",G)}}),X=A;try{while(!F){let G=await BL3(X,Q,Z,B);if(G.stop)return;if(G.updatedTo)X=G.updatedTo;if(G.emittedVisibleState){if(await YG($L3),F)return;B.next("hidden")}if(E<=0)return;let V=1000,K=E;while(K>0&&!F){let z=Math.min(V,K);await YG(z),K-=z}}}finally{U.unsubscribe(),B.complete()}}),{state:D,dispose:Y}}async function BL3(A,Q,$,B){let D={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return $.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),D.stop=!0,D;let J=await Q.get("updates.mode");if(J==="disabled")return $.debug("checking disabled"),D.stop=!0,D;let E=await xG(),F=E==="binary"||E==="brew",Y=F?void 0:await gN();$.debug("checking",{currentVersion:A,mode:J,packageManager:E,isBinaryDistribution:F,npmPackageName:Y});let Z;if(F)Z=await fU0(A);else{let G=await xU0();Z=await SU0(A,G,Y)}if(!(Z.latestVersion&&Z.hasUpdate))return $.debug("no update available"),D;let U=(G)=>{B.next(G),D.emittedVisibleState=!0};if(E){let G=await vb4(E);if(G&&Ct(G,Z.latestVersion)>=0){if($.debug("on-disk version already up to date",{currentVersion:A,installedVersion:G,latestVersion:Z.latestVersion}),D.updatedTo=G,Ct(A,G)<0){let V=await pz(G),K={from:A,to:G,externallyUpdated:!0,...V};if(V.status==="same")$.info("on-disk already updated by another instance",K),U("updated");else $.warn("on-disk already updated by another instance, with PATH warning",K),U("updated-with-warning")}return D}}let X=()=>{if(Z.currentVersionAge!==void 0&&Z.latestVersionAge!==void 0){let G=Z.currentVersionAge-Z.latestVersionAge,V=0.5;if(Math.abs(G)<0.5)return $.debug("versions too close together, suppressing update warning",{currentVersionAge:Z.currentVersionAge,latestVersionAge:Z.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!J)J=E==="pnpm"?"warn":"auto",$.debug("no configured update mode; selected default based on package manager",{packageManager:E,mode:J});if(E==="brew"){if(!X())U("update-available-brew");return D}if(E==="binary"&&process.execPath!==qt()){if($.debug("non-standard binary path, showing warning"),!X())U("update-available-unrecognized-path");return D}if(J==="warn"){if(!X())U("update-available");return D}if(!E){if($.debug("auto-update not supported, falling back to warn mode"),!X())U("update-available");return D}try{await Nt(Z.latestVersion,E),D.updatedTo=Z.latestVersion;let G=await pz(Z.latestVersion),V={from:Z.currentVersion,to:Z.latestVersion,...G};if(G.status==="same")$.info("success",V),U("updated");else $.warn("success with warning",V),U("updated-with-warning")}catch(G){U("update-error")}return D}catch(J){return $.debug("check failed",{error:J}),D}}Cz();import{stderr as tF}from"node:process";function Sb4(A){let Q=new NN().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(B)=>{await xe0(B.force||!1,B.verbose||!1,"0.0.1779886645-g59fcb2"),process.exit()});A.addCommand(Q,{hidden:!0});let $=new NN("update").alias("up").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(B)=>{await EL3(B.targetVersion)});A.addCommand($)}function DL3(A){let Q=Boolean(A.isTTY),$=0,B=!1;function D(){if(!Q||!B)return;A.write(`
4791
4791
  `),B=!1,$=0}function J(E){if(!Q)return;let F=E.padEnd($," ");A.write(`\r${F}`),B=!0,$=F.length}return{flushProgressLine:D,renderProgress:J}}function JL3(A){if(A.source==="npm"&&A.latestVersionAge!==void 0&&A.latestVersionAge>36)tF.write(e0.yellow(`The latest Amp CLI version reported by npm is older than expected. Be aware that you may be using an npm proxy with a corporate policy to delay package updates.
4792
4792
  `))}async function EL3(A){let $=process.platform==="win32"&&BR()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:B,renderProgress:D}=DL3(tF);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")tF.write(e0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4793
4793
 
4794
4794
  `));try{if(!A){tF.write(e0.blue(`Checking for updates...
4795
- `));let F=!1,Y;if(BR()){let Z=await fU0("0.0.1779859522-gba0d26");F=Z.hasUpdate,Y=Z.latestVersion}else{let Z=await xU0(),U=await gN(),X=await SU0("0.0.1779859522-gba0d26",Z,U);JL3(X),F=X.hasUpdate,Y=X.latestVersion}if(!F){let Z=wt("0.0.1779859522-gba0d26"),U=Z?.age?`released ${Z.age} ago`:`built ${fF(new Date("2026-05-27T05:30:48.321Z"))} ago`;tF.write(e0.green(`✓ Amp is already up to date on version ${"0.0.1779859522-gba0d26"} (${U})
4796
- `));let X=await pz("0.0.1779859522-gba0d26",$);if(X.warning)tF.write(`
4795
+ `));let F=!1,Y;if(BR()){let Z=await fU0("0.0.1779886645-g59fcb2");F=Z.hasUpdate,Y=Z.latestVersion}else{let Z=await xU0(),U=await gN(),X=await SU0("0.0.1779886645-g59fcb2",Z,U);JL3(X),F=X.hasUpdate,Y=X.latestVersion}if(!F){let Z=wt("0.0.1779886645-g59fcb2"),U=Z?.age?`released ${Z.age} ago`:`built ${fF(new Date("2026-05-27T13:02:21.391Z"))} ago`;tF.write(e0.green(`✓ Amp is already up to date on version ${"0.0.1779886645-g59fcb2"} (${U})
4796
+ `));let X=await pz("0.0.1779886645-g59fcb2",$);if(X.warning)tF.write(`
4797
4797
  `+e0.yellow(X.warning)+`
4798
4798
  `);process.exit(0)}if(!Y)tF.write(e0.yellow("[WARN] could not find latest version")),process.exit(0);A=Y}tF.write(e0.blue(`Updating to version ${A}...
4799
4799
  `)),await Nt(A,void 0,(F)=>{B(),tF.write(e0.dim(`Running: ${F}
@@ -5222,7 +5222,7 @@ ${B}`).join(`
5222
5222
  `).length,D=new d({text:new w(A,new T({color:$}))});if(B<=GV0)return D;return new X0({width:1/0,height:GV0,child:new a8({autofocus:!1,controller:Q,child:D})})}function Ch3(){return new Map([[G1.key("PageUp"),new VV0],[G1.key("PageDown"),new m61],[G1.ctrl("u"),new VV0],[G1.shift("Home"),new d61],[G1.shift("End"),new p61]])}function wh3(A,Q,$){return Math.max(Q,Math.min(A,$))}var c61=8,ja4=1,Ra4=c61-1;class l61 extends V4{}class i61 extends V4{}class KV0 extends V4{}class zV0 extends V4{}class n61 extends V4{}class a61 extends V4{}class o61 extends u0{props;constructor(A){super(A.key===void 0?{}:{key:A.key});this.props=A}createState(){return new ua4}}class ua4 extends R0{messageScroll=new v6;initState(){super.initState(),this.messageScroll.followMode=!1,this.messageScroll.jumpTo(0)}dispose(){this.messageScroll.dispose(),super.dispose()}build(A){let Q=this.widget.props,$=Mh3(Q,this.messageScroll),B=Lh3(Q.options.message),D=B?new b4({actions:this.buildScrollActions(),child:new kA({debugLabel:"NeoSelectDialogScrollShortcuts",shortcuts:jh3(),child:$})}):$,J=[{keys:["↑/↓","j/k"],label:"move"},{keys:["Enter"],label:"select"}];if(B)J.push({keys:["Ctrl+E","Ctrl+Y"],label:"scroll"});return J.push({keys:["Esc"],label:"cancel"}),new C6({header:Q.options.title,minWidth:64,maxWidth:80,footer:J,autofocus:!1,onDismiss:Q.onCancel,child:D})}buildScrollActions(){let A=(Q)=>{let $=Rh3(this.messageScroll.offset+Q,0,this.messageScroll.maxScrollExtent);this.messageScroll.jumpTo($)};return new Map([[l61,new T1(()=>A(-ja4))],[i61,new T1(()=>A(ja4))],[KV0,new T1(()=>A(-Ra4))],[zV0,new T1(()=>A(Ra4))],[n61,new T1(()=>this.messageScroll.jumpTo(0))],[a61,new T1(()=>this.messageScroll.jumpTo(this.messageScroll.maxScrollExtent))]])}}function Mh3(A,Q){let $=A.options.options.map((D)=>({value:D,label:D})),B=Math.max(0,$.findIndex((D)=>D.value===A.options.initialValue));return new W8({options:$,selectedIndex:B,body:Oh3(A.options.message,Q),onSelect:(D)=>{if(D===null){A.onCancel();return}A.onSelect(D)},padding:K0.all(0),showBorder:!1,showDismissalMessage:!1,enableMouseInteraction:!0,wrapOptions:!0})}function Lh3(A){if(A===void 0)return!1;return A.split(`
5223
5223
  `).length>c61}function Oh3(A,Q){if(A===void 0)return;let $=A.split(`
5224
5224
  `).length,B=Math.min($,c61);return new X0({width:1/0,height:B,child:new a8({autofocus:!1,controller:Q,child:new d({text:new w(A)})})})}function jh3(){return new Map([[G1.key("PageUp"),new KV0],[G1.key("PageDown"),new zV0],[G1.ctrl("u"),new KV0],[G1.ctrl("d"),new zV0],[G1.ctrl("y"),new l61],[G1.ctrl("e"),new i61],[G1.shift("Home"),new n61],[G1.shift("End"),new a61]])}function Rh3(A,Q,$){return Math.max(Q,Math.min(A,$))}var uh3=3,Ph3=new y6("NeoPluginDialogOverlay");function Pa4(A,Q,$){if($!==void 0)return{type:"response",id:A,error:$};if(Q===void 0)return{type:"response",id:A};return{type:"response",id:A,result:Q}}class r61{options;unregisterPluginCommands=null;pluginCommandSubscriptions=[];pluginErrorToastKeys=new Set;activeDialog=null;queuedDialogs=[];resolvingDialog=null;pendingOwnerUIRequests=new Map;pendingActorUIRequests=new Map;stateBackedRequestIDs=new Set;pluginUIRespondRequestCounter=0;statusItems=new Map;blockingConfirmDialog=!1;disposed=!1;constructor(A){this.options=A}init(){this.disposed=!1,this.configurePluginPlatform(),this.subscribePluginCommands()}dispose(){this.disposed=!0,this.unregisterPluginCommands?.(),this.unregisterPluginCommands=null;for(let A of this.pluginCommandSubscriptions)A.unsubscribe();this.pluginCommandSubscriptions=[],this.cancelOwnerUIRequests(),this.cancelPendingDialogs(),this.statusItems.clear(),this.clearPluginPlatformStatusHandlers()}handlePluginMessage(A,Q){let $=A.message;if($.type==="response"){this.cancelOwnerUIRequest($.id),this.cancelActorUIRequest($.id);return}if($.type==="event"){if(this.handlePluginUIStateEvent($,Q))return;this.handlePluginEvent($);return}if(this.stateBackedRequestIDs.has($.id))return;if(!yZ0($.method))return;this.handleOwnerUIRequest($,Q)}cancelOwnerUIRequests(){let A=[...this.pendingOwnerUIRequests.values(),...this.pendingActorUIRequests.values()];this.pendingOwnerUIRequests.clear(),this.pendingActorUIRequests.clear(),this.stateBackedRequestIDs.clear();for(let Q of A)Q.abort()}hasBlockingDialog(){return this.activeDialog!==null}hasBlockingConfirmDialog(){return this.activeDialog?.kind==="confirm"}buildDialogLayers(){let A=this.activeDialog;if(!A)return[];return[new k4({key:Ph3,debugLabel:"PluginDialogOverlay",autofocus:!1,canRequestFocus:!0,child:this.buildActiveDialog(A)})]}buildActiveDialog(A){switch(A.kind){case"input":return new X00({key:new nz(A),header:A.options.title??"Input",helpText:A.options.helpText,initialValue:A.options.initialValue,isRequired:!1,onSubmit:(Q)=>this.resolveInputDialog(A,Q),onDismiss:()=>this.resolveInputDialog(A,void 0)});case"confirm":return new g61({key:new nz(A),options:A.options,onConfirm:()=>this.resolveConfirmDialog(A,!0),onCancel:()=>this.resolveConfirmDialog(A,!1)});case"select":return new o61({key:new nz(A),options:A.options,onSelect:(Q)=>this.resolveSelectDialog(A,Q),onCancel:()=>this.resolveSelectDialog(A,void 0)})}}getStatusItems(){return[...this.statusItems.values()].flatMap((A)=>A.value===void 0?[]:[{pluginURI:A.pluginURI,id:A.id,value:A.value}])}configurePluginPlatform(){let A=this.options.neoContext.pluginPlatform;if(!A)return;A.showToast=(Q)=>this.options.toastController.show(Q,"success"),A.showOpenedURLToast=(Q)=>{this.options.toastController.show(`Opened URL: ${Q}`,"success",8000)},A.appendToThreadHandler=this.options.neoContext.observerOnly?async()=>{throw Error("thread.append is only available from an executor-owned plugin runtime")}:this.options.appendToThread,A.showInputDialog=this.showInputDialog,A.showConfirmDialog=this.showConfirmDialog,A.showSelectDialog=this.showSelectDialog,A.createStatusItemHandler=this.createStatusItem,A.updateStatusItemHandler=this.updateStatusItem,A.removeStatusItemHandler=this.removeStatusItem}handlePluginEvent(A){if(A.event!=="ui.notify")return;let Q=A.data;if(typeof Q.message==="string")this.options.toastController.show(Q.message,"success")}async handleOwnerUIRequest(A,Q){let $=new AbortController;this.pendingOwnerUIRequests.set(A.id,$);try{let B=await this.dispatchOwnerUIRequest(A,$.signal);if(this.pendingOwnerUIRequests.get(A.id)!==$)return;this.pendingOwnerUIRequests.delete(A.id),Q(Pa4(A.id,B))}catch(B){if(this.pendingOwnerUIRequests.get(A.id)!==$)return;this.pendingOwnerUIRequests.delete(A.id),Q(Pa4(A.id,void 0,B instanceof Error?B.message:String(B)))}}dispatchOwnerUIRequest(A,Q){switch(A.method){case"ui.input":return this.showInputDialog(A.params.options,Q);case"ui.confirm":return this.showConfirmDialog(A.params.options,Q);case"ui.select":return this.showSelectDialog(A.params.options,Q);default:throw Error(`Unknown owner UI request method: ${A.method}`)}}cancelOwnerUIRequest(A){let Q=this.pendingOwnerUIRequests.get(A);if(!Q)return;this.pendingOwnerUIRequests.delete(A),Q.abort()}cancelActorUIRequest(A){let Q=this.pendingActorUIRequests.get(A);if(!Q)return;this.pendingActorUIRequests.delete(A),Q.abort()}buildPluginUIRespondRequest(A,Q,$){this.pluginUIRespondRequestCounter+=1;let B={requestId:A};if($!==void 0)B.error=$;else if(Q!==void 0)B.result=Q;return{type:"request",id:`plugin-ui-respond-${A}-${this.pluginUIRespondRequestCounter}`,method:"plugin.ui.respond",params:B}}async handleActorUIRequest(A,Q){let $=new AbortController;this.pendingActorUIRequests.set(A.requestId,$);let B={type:"request",id:A.requestId,method:A.method,params:A.params};try{let D=await this.dispatchOwnerUIRequest(B,$.signal);if(this.pendingActorUIRequests.get(A.requestId)!==$)return;this.pendingActorUIRequests.delete(A.requestId),Q(this.buildPluginUIRespondRequest(A.requestId,D))}catch(D){if(this.pendingActorUIRequests.get(A.requestId)!==$)return;this.pendingActorUIRequests.delete(A.requestId),Q(this.buildPluginUIRespondRequest(A.requestId,void 0,D instanceof Error?D.message:String(D)))}}upsertActorUIState(A,Q){if(this.stateBackedRequestIDs.add(A.requestId),A.status!=="pending"){this.cancelActorUIRequest(A.requestId);return}if(this.pendingActorUIRequests.has(A.requestId))return;this.handleActorUIRequest(A,Q)}handlePluginUISnapshot(A,Q){let $=new Set(A.requests.map((B)=>B.requestId));for(let B of this.pendingActorUIRequests.keys())if(!$.has(B))this.cancelActorUIRequest(B);for(let B of this.stateBackedRequestIDs)if(!$.has(B))this.stateBackedRequestIDs.delete(B);for(let B of A.requests)this.upsertActorUIState(B,Q)}handlePluginUIRequestAdded(A,Q){this.upsertActorUIState(A.request,Q)}handlePluginUIRequestSettled(A,Q){this.upsertActorUIState(A.request,Q)}handlePluginUIRequestRemoved(A){this.cancelActorUIRequest(A.requestId),this.stateBackedRequestIDs.delete(A.requestId)}handlePluginUIStateEvent(A,Q){if(A.event==="plugin.ui.snapshot"){let $=Gk4.safeParse(A.data);if($.success)this.handlePluginUISnapshot($.data,Q);return!0}if(A.event==="plugin.ui.request_added"){let $=Vk4.safeParse(A.data);if($.success)this.handlePluginUIRequestAdded($.data,Q);return!0}if(A.event==="plugin.ui.request_settled"){let $=Kk4.safeParse(A.data);if($.success)this.handlePluginUIRequestSettled($.data,Q);return!0}if(A.event==="plugin.ui.request_removed"){let $=zk4.safeParse(A.data);if($.success)this.handlePluginUIRequestRemoved($.data);return!0}return!1}clearPluginPlatformStatusHandlers(){let A=this.options.neoContext.pluginPlatform;if(!A)return;if(A.createStatusItemHandler===this.createStatusItem)A.createStatusItemHandler=null;if(A.updateStatusItemHandler===this.updateStatusItem)A.updateStatusItemHandler=null;if(A.removeStatusItemHandler===this.removeStatusItem)A.removeStatusItemHandler=null}subscribePluginCommands(){let A=this.options.neoContext.pluginService;if(!A)return;this.refreshPluginCommands(A.commands.list()),this.pluginCommandSubscriptions=[A.plugins.subscribe((Q)=>{this.removeInactivePluginStatusItems(Q),this.showNewPluginErrorToasts(Q),this.refreshPluginCommands(A.commands.list())}),A.commands.changed.subscribe(()=>{this.refreshPluginCommands(A.commands.list())})]}refreshPluginCommands(A){this.unregisterPluginCommands?.();let $=A.map((B)=>this.createPluginCommand(B)).map((B)=>this.options.commandRegistry.register(B));this.unregisterPluginCommands=()=>{for(let B of $)B()}}showNewPluginErrorToasts(A){let Q=new Set;for(let $ of A){if($.status!=="error")continue;if(ai($.errorMessage))continue;let B=`${$.uri.toString()}
5225
- ${$.errorMessage??""}`;if(Q.add(B),this.pluginErrorToastKeys.has(B))continue;this.options.toastController.show(this.formatPluginErrorToast($),"error",8000)}this.pluginErrorToastKeys=Q}removeInactivePluginStatusItems(A){let Q=new Set(A.filter((B)=>B.status==="active").map((B)=>B.uri.toString())),$=[];for(let[B,D]of this.statusItems){if(Q.has(D.pluginURI))continue;$.push(B)}if($.length===0)return;this.updateStatusItemState(()=>{for(let B of $)this.statusItems.delete(B)})}formatPluginErrorToast(A){let Q=A.uri.toString();return`Plugin failed: ${Q.split("/").pop()??Q}. See logs: ${this.options.neoContext.logFilePath}`}createPluginCommand(A){return{id:A.id,noun:A.category,verb:A.title,description:A.description??`Run plugin command ${A.category}: ${A.title}`,status:A.availability,run:async(Q,$,B)=>{B();try{await this.options.neoContext.pluginService?.commands.execute(A.pluginName,A.id,{threadID:this.options.getActiveThreadID()})}catch(D){u.error("Neo plugin command failed",{error:D,command:A}),this.options.toastController.show(D instanceof Error?D.message:String(D),"error",5000)}}}}showInputDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(void 0);return}let B={kind:"input",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};showConfirmDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(!1);return}let B={kind:"confirm",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};showSelectDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(void 0);return}let B={kind:"select",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};createStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{let B=this.statusItemKey(A,Q),D={pluginURI:A,id:Q};if($!==void 0)D.value=$;this.statusItems.set(B,D)})};updateStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.set(this.statusItemKey(A,Q),{pluginURI:A,id:Q,value:$})})};removeStatusItem=(A,Q)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.delete(this.statusItemKey(A,Q))})};updateStatusItemState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}statusItemKey(A,Q){return`${A}\x00${Q}`}cancelPendingDialogs(){let A=[];if(this.activeDialog)A.push(this.activeDialog);A.push(...this.queuedDialogs),this.activeDialog=null,this.queuedDialogs=[],this.resolvingDialog=null,this.emitBlockingConfirmDialogChange();for(let Q of A)this.cancelDialog(Q)}cancelDialog(A){switch(A.abortUnsubscribe(),A.kind){case"input":A.resolve(void 0);return;case"confirm":A.resolve(!1);return;case"select":A.resolve(void 0);return}}abortDialog(A){if(this.activeDialog===A){this.advanceDialog(),this.cancelDialog(A);return}let Q=this.queuedDialogs.indexOf(A);if(Q===-1)return;this.updateDialogState(()=>{this.queuedDialogs.splice(Q,1)}),this.cancelDialog(A)}enqueueDialog(A){if(this.activeDialog){if(this.queuedDialogs.push(A),this.resolvingDialog===this.activeDialog)this.advanceResolvingDialog(this.activeDialog);return}this.options.commandPalette.disable(),this.options.state.setState(()=>{this.activeDialog=A}),this.emitBlockingConfirmDialogChange()}resolveInputDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveConfirmDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveSelectDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveDialog(A,Q){if(this.activeDialog!==A||this.resolvingDialog===A)return;this.resolvingDialog=A,A.abortUnsubscribe(),Q(),this.scheduleResolvingDialogAdvance(A,uh3)}scheduleResolvingDialogAdvance(A,Q){a6.instance.addPostFrameCallback(()=>{if(this.activeDialog!==A)return;if(this.queuedDialogs.length>0||Q<=1){this.advanceResolvingDialog(A);return}this.scheduleResolvingDialogAdvance(A,Q-1)},"NeoPluginIntegration.advanceDialog")}advanceResolvingDialog(A){if(this.resolvingDialog===A)this.resolvingDialog=null;if(this.activeDialog!==A)return;this.advanceDialog()}advanceDialog(){this.updateDialogState(()=>{this.activeDialog=this.queuedDialogs.shift()??null})}updateDialogState(A){if(this.options.state.mounted)this.options.state.setState(A);else A();this.emitBlockingConfirmDialogChange()}emitBlockingConfirmDialogChange(){let A=this.hasBlockingConfirmDialog();if(A===this.blockingConfirmDialog)return;this.blockingConfirmDialog=A,this.options.onBlockingConfirmDialogChange?.(A)}}var _h3=48;class s61{visible=!1;onClick=void 0;listeners=new Set;show(A){this.visible=!0,this.onClick=A,this.notifyListeners()}activate(){this.onClick?.()}get isVisible(){return this.visible}dismiss(){this.visible=!1,this.onClick=void 0,this.notifyListeners()}addListener(A){this.listeners.add(A)}removeListener(A){this.listeners.delete(A)}buildComplexToast(){if(!this.visible||!this.onClick)return null;return new Y00({width:_h3,title:"Relaunch to Update Amp",message:"Your threads will resume.",variant:"success",mouseBehavior:"click-anywhere",action:{keyboardShortcut:"Ctrl+O",command:"amp: relaunch",confirmShortcut:"Enter",label:"relaunch",onAction:()=>this.activate()}})}notifyListeners(){for(let A of this.listeners)A()}}c0();import{spawnSync as Th3}from"node:child_process";import yD from"node:process";var _a4={options:new Set(["settings-file","log-level","log-file","mcp-config"]),booleans:new Set(["color","dangerously-allow-all","ide","jetbrains","neo-orb","notifications"])};function G00(A){let Q=A.getRelaunchThreadIDs();if(A.onRelaunchRequested?.(Q),A.stop)A.stop();else z4.instance.stop()}function Ta4(A){return{noun:"amp",verb:"Relaunch (Quit & Reopen)",description:"Quit, reopen Amp, and resume active threads",keywords:["restart","update"],shortcut:yD.env.NODE_ENV==="development"&&yD.platform==="darwin"?G1.meta("r"):void 0,status:{type:"enabled"},sortBoost:90,run:(Q,$,B)=>{B(),G00(A)}}}function vh3(A,Q){let{command:$,args:B}=kh3(A),D=yD.execve,J=yD.platform==="win32"||!D,E=J?"spawnSync":"execve";if(u.info("Relaunching Amp; threads will be resumed",{threadIDs:A,relaunchMethod:E}),J){let F=Th3($,B,{cwd:Q,env:yD.env,stdio:"inherit"});if(F.error)return u.error("Failed to relaunch Amp",{error:F.error}),1;return F.status??1}try{if(yD.chdir(Q),$.includes("/"))return D($,[$,...B],yD.env);return D("/usr/bin/env",["env",$,...B],yD.env)}catch(F){return u.error("Failed to relaunch Amp",{error:F}),1}}class t61{relaunchRequested=!1;requestedThreadIDs=[];request=(A)=>{u.info("Relaunch requested; threads will be resumed",{threadIDs:A}),this.relaunchRequested=!0,this.requestedThreadIDs=A};get shouldShowExitSummary(){return!this.relaunchRequested}relaunchIfRequested(A){if(!this.relaunchRequested)return;return vh3(this.requestedThreadIDs,A)}}function kh3(A){let Q=A.length>0?["threads","continue",...A]:[],$=Sh3(yD.argv),B=yh3();if(B)return{command:B.command,args:[...B.args,...$,...Q]};let D=yD.argv[1],J=D&&fh3(D)?[D]:[];return{command:yD.execPath,args:[...J,...$,...Q]}}function Sh3(A){let Q=[],$=A.slice(2);for(let B=0;B<$.length;B+=1){let D=$[B];if(!D?.startsWith("--"))continue;let[J,E]=D.split("=",2);if(!J)continue;let F=J.slice(2),Y=F.startsWith("no-")?F.slice(3):F;if(_a4.booleans.has(Y)){Q.push(D);continue}if(!_a4.options.has(F))continue;if(E!==void 0){Q.push(D);continue}let Z=$[B+1];if(Z===void 0||Z.startsWith("--"))continue;Q.push(D,Z),B+=1}return Q}function fh3(A){return A!==yD.execPath&&!A.startsWith("/$bunfs/")}function yh3(){if(yD.env.NODE_ENV!=="development")return null;let A=yD.env.AMP_DEV_RELAUNCH_COMMAND?.trim();if(!A)return null;let Q=xh3(A),$=Q[0];if(!$)return null;return{command:$,args:Q.slice(1)}}function xh3(A){if(A.startsWith("["))try{let Q=JSON.parse(A);if(Array.isArray(Q)&&Q.every(($)=>typeof $==="string"))return Q}catch{return[]}return A.split(/\s+/).filter(Boolean)}var bh3=18000000;class e61{options;subscription=null;relaunchNotificationShown=!1;relaunchNotificationPending=!1;relaunchNotificationTimer=null;openedAt=Date.now();constructor(A){this.options=A}init(){if(this.subscription=this.options.updateService?.state.subscribe((A)=>{this.handleUpdateState(A)})??null,process.env.DEV_SHOW_RELAUNCH_NOTIF_ON_STARTUP==="1")this.showUpdateRelaunchNotification(!0)}dispose(){if(this.subscription?.unsubscribe(),this.subscription=null,this.relaunchNotificationTimer)clearTimeout(this.relaunchNotificationTimer),this.relaunchNotificationTimer=null}handleUpdateState(A){if(A!=="updated")return;this.showUpdateRelaunchNotification()}showUpdateRelaunchNotification(A=!1){if(this.relaunchNotificationShown)return;let $=(this.options.minimumOpenDurationMs??bh3)-(Date.now()-this.openedAt);if($>0&&!A){if(this.relaunchNotificationPending=!0,!this.relaunchNotificationTimer)this.relaunchNotificationTimer=setTimeout(()=>{if(this.relaunchNotificationTimer=null,!this.relaunchNotificationPending)return;this.relaunchNotificationPending=!1,this.showUpdateRelaunchNotification()},$),this.relaunchNotificationTimer.unref();return}this.relaunchNotificationPending=!1,this.relaunchNotificationShown=!0,this.options.relaunchNotificationController.show(()=>G00(this.options))}}wa();g2();import{readFile as hh3}from"node:fs/promises";import AA1 from"node:os";function gh3(A=new Date){return A.toISOString().replaceAll("-","").replaceAll(":","").slice(0,15)+"Z"}async function va4(A,Q){try{return{path:Q,contents:Om0(await hh3(A,"utf8"))}}catch{return null}}async function WV0(A,Q){let $=[],B=gh3(),D=await o4.getThread({thread:Q},{config:A.configService}),J=D.ok?D.result.thread.data:null;$.push({path:`${B}/thread.json`,contents:JSON.stringify(WD(J),null,2)});let E=await va4(Ay(Q),`${B}/logs/${Q}.log`);if(E)$.push(E);let F=await va4(A.settingsFilePath,`${B}/settings/global.json`);if(F)$.push(F);let Y=await xG()??"unknown",Z=await o4.sendReport({threadID:Q,files:$,metadata:{clientVersion:"0.0.1779859522-gba0d26",clientOS:`${AA1.platform()} ${AA1.release()} ${AA1.arch()}`,installMethod:Y}},{config:A.configService});if(!Z.ok)throw Error(`Failed to submit report: ${Z.error.message}`);return Z.result.reportID}class QA1{backStack=[];forwardStack=[];canNavigateBack(){return this.backStack.length>0}canNavigateForward(){return this.forwardStack.length>0}recordNavigation(A){if(!A)return;this.backStack.push(A),this.forwardStack.length=0}startBackNavigation(A){let Q=this.backStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.forwardStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.forwardStack.pop();this.backStack.push(Q)}}}startForwardNavigation(A){let Q=this.forwardStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.backStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.backStack.pop();this.forwardStack.push(Q)}}}}class IV0 extends g3{offstage;constructor({key:A,offstage:Q=!0,child:$}){super({key:A,child:$});this.offstage=Q}createRenderObject(){return new $A1(this.offstage)}updateRenderObject(A){if(A instanceof $A1)A.offstage=this.offstage}}class $A1 extends i1{_offstage;constructor(A){super();this._offstage=A}get offstage(){return this._offstage}set offstage(A){if(A===this._offstage)return;this._offstage=A,this.markNeedsLayout()}getMinIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicWidth(A)??0}getMaxIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicWidth(A)??0}getMinIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicHeight(A)??0}getMaxIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicHeight(A)??0}performLayout(){let A=this._lastConstraints;q4(!!A,"performLayout called without constraints");let Q=this.children[0];if(this._offstage){if(this.setSize(0,0),Q)Q.layout(A),Q.setOffset(0,0)}else if(Q){Q.layout(A);let $=A.constrain(Q.size.width,Q.size.height);this.setSize($.width,$.height),Q.setOffset(0,0)}else{let $=A.smallest;this.setSize($.width,$.height)}super.performLayout()}paint(A,Q,$){if(this._offstage)return;super.paint(A,Q,$)}hitTest(A,Q,$,B){if(this._offstage)return!1;return super.hitTest(A,Q,$,B)}}class V00{_state=null;_attach(A){this._state=A}_detach(){this._state=null}push(A){this._state?.push(A)}pushWithDismiss(A){this._state?.pushWithDismiss(A)}pop(){return this._state?.pop()??!1}get canPop(){return this._state?.canPop??!1}}class BA1 extends u0{root;controller;constructor(A){super();this.root=A.root,this.controller=A.controller}createState(){return new ka4}}class ka4 extends R0{entries=[];initState(){this.widget.controller._attach(this)}didUpdateWidget(A){if(A.controller!==this.widget.controller)A.controller._detach(),this.widget.controller._attach(this)}dispose(){this.widget.controller._detach(),super.dispose()}push(A){let Q=new ZR,$=this.makeScopedDismiss(Q);this.setState(()=>{this.entries.push({key:Q,widget:A,dismiss:$})})}pushWithDismiss(A){let Q=new ZR,$=this.makeScopedDismiss(Q),B=A($);this.setState(()=>{this.entries.push({key:Q,widget:B,dismiss:$})})}pop(){if(this.entries.length===0)return!1;return this.setState(()=>{this.entries.pop()}),!0}get canPop(){return this.entries.length>0}makeScopedDismiss(A){return()=>{if(!this.mounted)return;let Q=this.entries[this.entries.length-1];if(!Q||Q.key!==A)return;this.setState(()=>{this.entries.pop()})}}build(A){let Q=[];Q.push(new IV0({offstage:this.entries.length>0,child:this.widget.root}));for(let $=0;$<this.entries.length;$++){let B=this.entries[$],D=$===this.entries.length-1,J=D?new k4({autofocus:!0,debugLabel:`ModalStackEntry[${$}]`,onKey:(E)=>{if(E.key!=="Escape")return"ignored";return B.dismiss(),"handled"},child:B.widget}):B.widget;Q.push(new IV0({key:B.key,offstage:!D,child:J}))}return new i4({fit:"expand",children:Q})}}class JA1 extends H1{props;constructor(A){super();this.props=A}build(A){let Q=this.props.commands.filter((D)=>D.status.type!=="hidden"),$=dh3(Q),B="";return new C6({header:"Command Palette",autofocus:!1,barrierOpaque:!1,chromePadding:K0.only({left:1,top:1,right:1}),footer:"none",onDismiss:this.props.onDismiss,child:new cA({items:Q,showBorder:!1,getLabel:(D)=>{let J=DA1(D);return D.keywords&&D.keywords.length>0?`${J} ${D.keywords.join(" ").toLowerCase()}`:J},onQueryChange:(D)=>{B=D},sortItems:(D,J,E)=>{B=E;let F=E.trim().toLowerCase();if(F===""){let K=D.item.status.type==="disabled"?1:0,z=J.item.status.type==="disabled"?1:0;if(K!==z)return K-z;let W=D.item.sortBoost??0,I=J.item.sortBoost??0;if(W!==I)return I-W;let H=D.item.noun?.toLowerCase()??"",q=J.item.noun?.toLowerCase()??"";if(H!==q)return H<q?-1:1;return 0}let Y=Sa4(D.item,F),Z=Sa4(J.item,F);if(Y!==Z)return Y?-1:1;let U=uR(D.item.verb.toLowerCase(),E),X=uR(J.item.verb.toLowerCase(),E);if(U!==X)return X-U;let G=uR(DA1(D.item),E),V=uR(DA1(J.item),E);if(G!==V)return V-G;return J.score-D.score},isItemDisabled:(D)=>D.status.type==="disabled",buildDisabledReasonWidget:(D,J)=>{if(D.status.type!=="disabled")return;let{colors:E}=O0.of(J);return new d({text:new w(D.status.reason,new T({color:E.mutedForeground,dim:!0})),textAlign:"center"})},renderItem:(D,J,E,F)=>new fa4({command:D,isSelected:J,isDisabled:E,categoryWidth:$,query:B,buildContext:F}),onAccept:(D)=>{this.props.onAccept(D)},onDismiss:this.props.onDismiss})})}}class fa4 extends H1{props;constructor(A){super();this.props=A}build(A){let{command:Q,isSelected:$,isDisabled:B,categoryWidth:D,query:J,buildContext:E}=this.props,F=O0.of(E),{colors:Y,app:Z}=F,U=$?Z.selectionBackground:void 0,X=$?Z.selectionForeground:Y.foreground,G=$?X:Y.mutedForeground,V=new d({text:new w(Q.noun?.toLowerCase()??"",new T({color:G,dim:B||!$})),textAlign:"right"}),K=[new w(Q.verb.toLowerCase(),new T({color:X,bold:!0,dim:B}))];if(B)K.push(new w(" (unavailable)",new T({color:X,dim:!0})));let z=mh3(Q,J);if(z)K.push(new w(" (alias: ",new T({color:X,dim:B}))),K.push(new w(z,new T({color:X,dim:B}))),K.push(new w(")",new T({color:X,dim:B})));let W=d.spans(K),I=[{child:V,fixedWidth:D},{child:W,expanded:!0}];if(Q.shortcut)I.push({child:ph3(Q.shortcut,F,B)});return new ya4({columns:I,padding:K0.horizontal(1),backgroundColor:U})}}function DA1(A){return A.noun?`${A.noun.toLowerCase()} ${A.verb.toLowerCase()}`:A.verb.toLowerCase()}function Sa4(A,Q){return A.keywords?.some(($)=>$.trim().toLowerCase()===Q)??!1}function mh3(A,Q){let $=Q.trim().toLowerCase();if($==="")return;return A.keywords?.find((B)=>B.trim().toLowerCase()===$)}function dh3(A){return A.reduce((Q,$)=>{return $.noun?Math.max(Q,E4($.noun)):Q},0)}function ph3(A,Q,$){let{app:B}=Q,D=new T({color:B.keybind,bold:!0,dim:$}),J=[],E=EE(A.toString()).split("+");for(let F=0;F<E.length;F++){if(F>0)J.push(new w("+",D));J.push(new w(E[F],D))}return d.spans(J)}class ya4 extends H1{props;constructor(A){super();this.props=A}build(A){let{columns:Q,gap:$=2,padding:B,backgroundColor:D}=this.props,J=[];for(let F=0;F<Q.length;F++){let Y=Q[F];if(F>0&&$>0)J.push(new X0({width:$}));if(Y.fixedWidth!==void 0)J.push(new X0({width:Y.fixedWidth,child:Y.child}));else if(Y.expanded)J.push(new R1({child:Y.child}));else J.push(Y.child)}let E=new s0({crossAxisAlignment:"start",children:J});if(!B&&!D)return E;return new b0({decoration:D?{color:D}:void 0,padding:B,child:E})}}class EA1{#A=[];#Q=new Set;get commands(){return this.#A}register(A){return this.#A.push(A),this.#$(),()=>{let Q=this.#A.indexOf(A);if(Q===-1)return;this.#A.splice(Q,1),this.#$()}}findByID(A){return this.#A.find((Q)=>Q.id===A)}runByID(A,Q){let $=this.findByID(A);if(!$||$.status.type!=="enabled")return!1;return $.run(new V00,Q,()=>{}),!0}addListener(A){this.#Q.add(A)}removeListener(A){this.#Q.delete(A)}#$(){for(let A of this.#Q)A()}}class R9 extends GA{commandRegistry;constructor({commandRegistry:A,child:Q}){super({child:Q});this.commandRegistry=A}updateShouldNotify(A){return!1}static of(A){let Q=R9.maybeOf(A);if(!Q)throw Error("No NeoCommandRegistryProvider found in widget tree");return Q}static maybeOf(A){return A.dependOnInheritedWidgetOfExactType(R9)?.commandRegistry??null}}class FA1 extends u0{onDismiss;constructor(A){super();this.onDismiss=A.onDismiss}createState(){return new xa4}}class xa4 extends R0{modalStack=new V00;commandRegistry=null;initState(){super.initState(),queueMicrotask(()=>{if(!this.mounted)return;let A=R9.of(this.context);this.commandRegistry=A,A.addListener(this.onCommandsChanged)})}dispose(){this.commandRegistry?.removeListener(this.onCommandsChanged),this.commandRegistry=null,super.dispose()}onCommandsChanged=()=>{this.setState()};build(A){let Q=R9.of(A).commands,$=new JA1({commands:Q,onAccept:(B)=>{B.run(this.modalStack,A,this.widget.onDismiss)},onDismiss:()=>{if(this.modalStack.canPop)this.modalStack.pop();else this.widget.onDismiss()}});return new BA1({root:$,controller:this.modalStack})}}var YA1=[{description:"Move cursor up/down",methods:[{keys:["↑"]},{keys:["↓"]}]},{description:"Move cursor left/right",methods:[{keys:["←"]},{keys:["→"]},{input:"B",keys:["Ctrl"]},{input:"F",keys:["Ctrl"]}]},{description:"Insert newline",methods:[{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!0},{description:"Insert newline",methods:[{keys:["Enter"]},{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!1},{description:"Submit message",methods:[{keys:["Enter"]}],submitOnEnterOnly:!0},{description:"Submit message",methods:[{keys:["Ctrl/Cmd","Enter"]}],submitOnEnterOnly:!1},{description:"Clear input",methods:[{keys:["Escape"]}]},{description:"Edit prompt in $EDITOR",methods:[{input:"G",keys:["Ctrl"]}]},{description:"Navigate history (previous/next)",methods:[{input:"P",keys:["Ctrl"]},{input:"N",keys:["Ctrl"]}]},{description:"Jump to start of line",methods:[{keys:["Cmd","←"]},{input:"A",keys:["Ctrl"]}]},{description:"Jump to end of line",methods:[{keys:["Cmd","→"]},{input:"E",keys:["Ctrl"]}]},{description:"Jump to previous word",methods:[{keys:["Alt","←"]},{keys:["Ctrl","←"]},{input:"B",keys:["Alt"]}]},{description:"Jump to next word",methods:[{keys:["Alt","→"]},{keys:["Ctrl","→"]},{input:"F",keys:["Alt"]}]},{description:"Delete character backward",methods:[{keys:["Backspace"]},{input:"H",keys:["Ctrl"]}]},{description:"Delete word backward",methods:[{keys:["Alt","Backspace"]},{input:"W",keys:["Ctrl"]}]},{description:"Delete character forward",methods:[{keys:["Delete"]},{input:"D",keys:["Ctrl"]}]},{description:"Delete to start of line",methods:[{keys:["Cmd","Backspace"]},{input:"U",keys:["Ctrl"]}]},{description:"Delete to end of line",methods:[{input:"K",keys:["Ctrl"]}]},{description:"Yank (paste deleted text)",methods:[{input:"Y",keys:["Ctrl"]}]},{description:"Paste image from clipboard",methods:[{input:"V",keys:["Ctrl"]}]},{description:"Switch agent mode",methods:[{input:"S",keys:["Ctrl"]}]},{description:"Toggle reasoning effort",methods:[{input:"D",keys:["Alt"]}]},{description:"Open command palette",methods:[{input:"O",keys:["Ctrl"]}]},{description:"Mention files",methods:[{keys:["@"]}]},{description:"Mention threads",methods:[{keys:["@@"]}]},{description:"Show prompt history",methods:[{input:"R",keys:["Ctrl"]}]},{description:"Toggle inline shortcuts help",methods:[{keys:["?"]}]},{description:"Toggle thinking/dense view",methods:[{input:"T",keys:["Alt"]}]}],ZA1=[{description:"Page scroll",methods:[{keys:["Pg Up"]},{keys:["Pg Down"]}]},{description:"Half-page scroll",methods:[{input:"K",keys:["Alt"]},{input:"J",keys:["Alt"]}]},{description:"Mouse wheel scroll",methods:[{keys:["Mouse Wheel"]}]},{description:"Jump to first message",methods:[{keys:["Home"]}]},{description:"Jump to bottom of screen",methods:[{keys:["End"]}]},{description:"Navigate to previous messages",methods:[{keys:["Tab"]},{keys:["Shift","Tab"]}]}];class HV0 extends H1{items;renderRow;constructor({items:A,renderRow:Q}){super();this.items=A,this.renderRow=Q}build(A){let $=g1.of(A).size.width,B=50,D=$<50,J=[];for(let E of this.items){let[F,Y]=this.renderRow(E),Z;if(D)Z=new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[F,new y0({padding:K0.only({left:4}),child:Y})]});else Z=new s0({crossAxisAlignment:"start",children:[new R1({flex:1,child:F}),new X0({width:1}),new R1({flex:1,child:Y})]});J.push(new y0({padding:K0.horizontal(6),child:Z}))}return new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:J})}}class UA1 extends u0{commands;submitOnEnter;constructor({key:A,commands:Q,submitOnEnter:$}){super(A?{key:A}:{});this.commands=Q,this.submitOnEnter=$??!0}createState(){return new ba4}}class ba4 extends R0{scrollController;initState(){this.scrollController=new v6,this.scrollController.disableFollowMode(),this.scrollController.jumpTo(0)}dispose(){}build(A){let $=L1.of(A).colorScheme,D=O0.of(A).app,J=g1.of(A),E=new T({color:$.primary,bold:!0}),F=new T({color:$.secondary,bold:!0}),Y=new T({color:D.keybind}),Z=new T({color:D.command}),U=new T({color:$.foreground}),X=new T({color:$.foreground}),G=J.size.width,V=J.size.height,K=G-4,z=V-4,W=Math.max(40,Math.min(80,K)),I=new Set(["permissions-disable"]),q=[...this.widget.commands.filter((O)=>{let R=O.noun?.toLowerCase();return R!=="dev"&&R!=="debug"&&!O.id.startsWith("debug-")&&!I.has(O.id)})].sort((O,R)=>{let k=(O.noun??"").toLowerCase(),_=(R.noun??"").toLowerCase(),f=k.localeCompare(_);if(f!==0)return f;let g=O.verb.toLowerCase(),b=R.verb.toLowerCase(),v=g.localeCompare(b);if(v!==0)return v;return O.id.localeCompare(R.id)}),N=new k6({autofocus:!0,controller:this.scrollController,child:new b0({constraints:new w1(W,W,0,Number.POSITIVE_INFINITY),child:new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[new D4({child:new d({text:new w(`Amp CLI - Help & Keyboard Shortcuts
5225
+ ${$.errorMessage??""}`;if(Q.add(B),this.pluginErrorToastKeys.has(B))continue;this.options.toastController.show(this.formatPluginErrorToast($),"error",8000)}this.pluginErrorToastKeys=Q}removeInactivePluginStatusItems(A){let Q=new Set(A.filter((B)=>B.status==="active").map((B)=>B.uri.toString())),$=[];for(let[B,D]of this.statusItems){if(Q.has(D.pluginURI))continue;$.push(B)}if($.length===0)return;this.updateStatusItemState(()=>{for(let B of $)this.statusItems.delete(B)})}formatPluginErrorToast(A){let Q=A.uri.toString();return`Plugin failed: ${Q.split("/").pop()??Q}. See logs: ${this.options.neoContext.logFilePath}`}createPluginCommand(A){return{id:A.id,noun:A.category,verb:A.title,description:A.description??`Run plugin command ${A.category}: ${A.title}`,status:A.availability,run:async(Q,$,B)=>{B();try{await this.options.neoContext.pluginService?.commands.execute(A.pluginName,A.id,{threadID:this.options.getActiveThreadID()})}catch(D){u.error("Neo plugin command failed",{error:D,command:A}),this.options.toastController.show(D instanceof Error?D.message:String(D),"error",5000)}}}}showInputDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(void 0);return}let B={kind:"input",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};showConfirmDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(!1);return}let B={kind:"confirm",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};showSelectDialog=(A,Q)=>{return new Promise(($)=>{if(this.disposed||!this.options.state.mounted||Q?.aborted){$(void 0);return}let B={kind:"select",options:A,resolve:$,abortUnsubscribe:()=>{}};B.abortUnsubscribe=FF(Q,()=>this.abortDialog(B)),this.enqueueDialog(B)})};createStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{let B=this.statusItemKey(A,Q),D={pluginURI:A,id:Q};if($!==void 0)D.value=$;this.statusItems.set(B,D)})};updateStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.set(this.statusItemKey(A,Q),{pluginURI:A,id:Q,value:$})})};removeStatusItem=(A,Q)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.delete(this.statusItemKey(A,Q))})};updateStatusItemState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}statusItemKey(A,Q){return`${A}\x00${Q}`}cancelPendingDialogs(){let A=[];if(this.activeDialog)A.push(this.activeDialog);A.push(...this.queuedDialogs),this.activeDialog=null,this.queuedDialogs=[],this.resolvingDialog=null,this.emitBlockingConfirmDialogChange();for(let Q of A)this.cancelDialog(Q)}cancelDialog(A){switch(A.abortUnsubscribe(),A.kind){case"input":A.resolve(void 0);return;case"confirm":A.resolve(!1);return;case"select":A.resolve(void 0);return}}abortDialog(A){if(this.activeDialog===A){this.advanceDialog(),this.cancelDialog(A);return}let Q=this.queuedDialogs.indexOf(A);if(Q===-1)return;this.updateDialogState(()=>{this.queuedDialogs.splice(Q,1)}),this.cancelDialog(A)}enqueueDialog(A){if(this.activeDialog){if(this.queuedDialogs.push(A),this.resolvingDialog===this.activeDialog)this.advanceResolvingDialog(this.activeDialog);return}this.options.commandPalette.disable(),this.options.state.setState(()=>{this.activeDialog=A}),this.emitBlockingConfirmDialogChange()}resolveInputDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveConfirmDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveSelectDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveDialog(A,Q){if(this.activeDialog!==A||this.resolvingDialog===A)return;this.resolvingDialog=A,A.abortUnsubscribe(),Q(),this.scheduleResolvingDialogAdvance(A,uh3)}scheduleResolvingDialogAdvance(A,Q){a6.instance.addPostFrameCallback(()=>{if(this.activeDialog!==A)return;if(this.queuedDialogs.length>0||Q<=1){this.advanceResolvingDialog(A);return}this.scheduleResolvingDialogAdvance(A,Q-1)},"NeoPluginIntegration.advanceDialog")}advanceResolvingDialog(A){if(this.resolvingDialog===A)this.resolvingDialog=null;if(this.activeDialog!==A)return;this.advanceDialog()}advanceDialog(){this.updateDialogState(()=>{this.activeDialog=this.queuedDialogs.shift()??null})}updateDialogState(A){if(this.options.state.mounted)this.options.state.setState(A);else A();this.emitBlockingConfirmDialogChange()}emitBlockingConfirmDialogChange(){let A=this.hasBlockingConfirmDialog();if(A===this.blockingConfirmDialog)return;this.blockingConfirmDialog=A,this.options.onBlockingConfirmDialogChange?.(A)}}var _h3=48;class s61{visible=!1;onClick=void 0;listeners=new Set;show(A){this.visible=!0,this.onClick=A,this.notifyListeners()}activate(){this.onClick?.()}get isVisible(){return this.visible}dismiss(){this.visible=!1,this.onClick=void 0,this.notifyListeners()}addListener(A){this.listeners.add(A)}removeListener(A){this.listeners.delete(A)}buildComplexToast(){if(!this.visible||!this.onClick)return null;return new Y00({width:_h3,title:"Relaunch to Update Amp",message:"Your threads will resume.",variant:"success",mouseBehavior:"click-anywhere",action:{keyboardShortcut:"Ctrl+O",command:"amp: relaunch",confirmShortcut:"Enter",label:"relaunch",onAction:()=>this.activate()}})}notifyListeners(){for(let A of this.listeners)A()}}c0();import{spawnSync as Th3}from"node:child_process";import yD from"node:process";var _a4={options:new Set(["settings-file","log-level","log-file","mcp-config"]),booleans:new Set(["color","dangerously-allow-all","ide","jetbrains","neo-orb","notifications"])};function G00(A){let Q=A.getRelaunchThreadIDs();if(A.onRelaunchRequested?.(Q),A.stop)A.stop();else z4.instance.stop()}function Ta4(A){return{noun:"amp",verb:"Relaunch (Quit & Reopen)",description:"Quit, reopen Amp, and resume active threads",keywords:["restart","update"],shortcut:yD.env.NODE_ENV==="development"&&yD.platform==="darwin"?G1.meta("r"):void 0,status:{type:"enabled"},sortBoost:90,run:(Q,$,B)=>{B(),G00(A)}}}function vh3(A,Q){let{command:$,args:B}=kh3(A),D=yD.execve,J=yD.platform==="win32"||!D,E=J?"spawnSync":"execve";if(u.info("Relaunching Amp; threads will be resumed",{threadIDs:A,relaunchMethod:E}),J){let F=Th3($,B,{cwd:Q,env:yD.env,stdio:"inherit"});if(F.error)return u.error("Failed to relaunch Amp",{error:F.error}),1;return F.status??1}try{if(yD.chdir(Q),$.includes("/"))return D($,[$,...B],yD.env);return D("/usr/bin/env",["env",$,...B],yD.env)}catch(F){return u.error("Failed to relaunch Amp",{error:F}),1}}class t61{relaunchRequested=!1;requestedThreadIDs=[];request=(A)=>{u.info("Relaunch requested; threads will be resumed",{threadIDs:A}),this.relaunchRequested=!0,this.requestedThreadIDs=A};get shouldShowExitSummary(){return!this.relaunchRequested}relaunchIfRequested(A){if(!this.relaunchRequested)return;return vh3(this.requestedThreadIDs,A)}}function kh3(A){let Q=A.length>0?["threads","continue",...A]:[],$=Sh3(yD.argv),B=yh3();if(B)return{command:B.command,args:[...B.args,...$,...Q]};let D=yD.argv[1],J=D&&fh3(D)?[D]:[];return{command:yD.execPath,args:[...J,...$,...Q]}}function Sh3(A){let Q=[],$=A.slice(2);for(let B=0;B<$.length;B+=1){let D=$[B];if(!D?.startsWith("--"))continue;let[J,E]=D.split("=",2);if(!J)continue;let F=J.slice(2),Y=F.startsWith("no-")?F.slice(3):F;if(_a4.booleans.has(Y)){Q.push(D);continue}if(!_a4.options.has(F))continue;if(E!==void 0){Q.push(D);continue}let Z=$[B+1];if(Z===void 0||Z.startsWith("--"))continue;Q.push(D,Z),B+=1}return Q}function fh3(A){return A!==yD.execPath&&!A.startsWith("/$bunfs/")}function yh3(){if(yD.env.NODE_ENV!=="development")return null;let A=yD.env.AMP_DEV_RELAUNCH_COMMAND?.trim();if(!A)return null;let Q=xh3(A),$=Q[0];if(!$)return null;return{command:$,args:Q.slice(1)}}function xh3(A){if(A.startsWith("["))try{let Q=JSON.parse(A);if(Array.isArray(Q)&&Q.every(($)=>typeof $==="string"))return Q}catch{return[]}return A.split(/\s+/).filter(Boolean)}var bh3=18000000;class e61{options;subscription=null;relaunchNotificationShown=!1;relaunchNotificationPending=!1;relaunchNotificationTimer=null;openedAt=Date.now();constructor(A){this.options=A}init(){if(this.subscription=this.options.updateService?.state.subscribe((A)=>{this.handleUpdateState(A)})??null,process.env.DEV_SHOW_RELAUNCH_NOTIF_ON_STARTUP==="1")this.showUpdateRelaunchNotification(!0)}dispose(){if(this.subscription?.unsubscribe(),this.subscription=null,this.relaunchNotificationTimer)clearTimeout(this.relaunchNotificationTimer),this.relaunchNotificationTimer=null}handleUpdateState(A){if(A!=="updated")return;this.showUpdateRelaunchNotification()}showUpdateRelaunchNotification(A=!1){if(this.relaunchNotificationShown)return;let $=(this.options.minimumOpenDurationMs??bh3)-(Date.now()-this.openedAt);if($>0&&!A){if(this.relaunchNotificationPending=!0,!this.relaunchNotificationTimer)this.relaunchNotificationTimer=setTimeout(()=>{if(this.relaunchNotificationTimer=null,!this.relaunchNotificationPending)return;this.relaunchNotificationPending=!1,this.showUpdateRelaunchNotification()},$),this.relaunchNotificationTimer.unref();return}this.relaunchNotificationPending=!1,this.relaunchNotificationShown=!0,this.options.relaunchNotificationController.show(()=>G00(this.options))}}wa();g2();import{readFile as hh3}from"node:fs/promises";import AA1 from"node:os";function gh3(A=new Date){return A.toISOString().replaceAll("-","").replaceAll(":","").slice(0,15)+"Z"}async function va4(A,Q){try{return{path:Q,contents:Om0(await hh3(A,"utf8"))}}catch{return null}}async function WV0(A,Q){let $=[],B=gh3(),D=await o4.getThread({thread:Q},{config:A.configService}),J=D.ok?D.result.thread.data:null;$.push({path:`${B}/thread.json`,contents:JSON.stringify(WD(J),null,2)});let E=await va4(Ay(Q),`${B}/logs/${Q}.log`);if(E)$.push(E);let F=await va4(A.settingsFilePath,`${B}/settings/global.json`);if(F)$.push(F);let Y=await xG()??"unknown",Z=await o4.sendReport({threadID:Q,files:$,metadata:{clientVersion:"0.0.1779886645-g59fcb2",clientOS:`${AA1.platform()} ${AA1.release()} ${AA1.arch()}`,installMethod:Y}},{config:A.configService});if(!Z.ok)throw Error(`Failed to submit report: ${Z.error.message}`);return Z.result.reportID}class QA1{backStack=[];forwardStack=[];canNavigateBack(){return this.backStack.length>0}canNavigateForward(){return this.forwardStack.length>0}recordNavigation(A){if(!A)return;this.backStack.push(A),this.forwardStack.length=0}startBackNavigation(A){let Q=this.backStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.forwardStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.forwardStack.pop();this.backStack.push(Q)}}}startForwardNavigation(A){let Q=this.forwardStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.backStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.backStack.pop();this.forwardStack.push(Q)}}}}class IV0 extends g3{offstage;constructor({key:A,offstage:Q=!0,child:$}){super({key:A,child:$});this.offstage=Q}createRenderObject(){return new $A1(this.offstage)}updateRenderObject(A){if(A instanceof $A1)A.offstage=this.offstage}}class $A1 extends i1{_offstage;constructor(A){super();this._offstage=A}get offstage(){return this._offstage}set offstage(A){if(A===this._offstage)return;this._offstage=A,this.markNeedsLayout()}getMinIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicWidth(A)??0}getMaxIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicWidth(A)??0}getMinIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicHeight(A)??0}getMaxIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicHeight(A)??0}performLayout(){let A=this._lastConstraints;q4(!!A,"performLayout called without constraints");let Q=this.children[0];if(this._offstage){if(this.setSize(0,0),Q)Q.layout(A),Q.setOffset(0,0)}else if(Q){Q.layout(A);let $=A.constrain(Q.size.width,Q.size.height);this.setSize($.width,$.height),Q.setOffset(0,0)}else{let $=A.smallest;this.setSize($.width,$.height)}super.performLayout()}paint(A,Q,$){if(this._offstage)return;super.paint(A,Q,$)}hitTest(A,Q,$,B){if(this._offstage)return!1;return super.hitTest(A,Q,$,B)}}class V00{_state=null;_attach(A){this._state=A}_detach(){this._state=null}push(A){this._state?.push(A)}pushWithDismiss(A){this._state?.pushWithDismiss(A)}pop(){return this._state?.pop()??!1}get canPop(){return this._state?.canPop??!1}}class BA1 extends u0{root;controller;constructor(A){super();this.root=A.root,this.controller=A.controller}createState(){return new ka4}}class ka4 extends R0{entries=[];initState(){this.widget.controller._attach(this)}didUpdateWidget(A){if(A.controller!==this.widget.controller)A.controller._detach(),this.widget.controller._attach(this)}dispose(){this.widget.controller._detach(),super.dispose()}push(A){let Q=new ZR,$=this.makeScopedDismiss(Q);this.setState(()=>{this.entries.push({key:Q,widget:A,dismiss:$})})}pushWithDismiss(A){let Q=new ZR,$=this.makeScopedDismiss(Q),B=A($);this.setState(()=>{this.entries.push({key:Q,widget:B,dismiss:$})})}pop(){if(this.entries.length===0)return!1;return this.setState(()=>{this.entries.pop()}),!0}get canPop(){return this.entries.length>0}makeScopedDismiss(A){return()=>{if(!this.mounted)return;let Q=this.entries[this.entries.length-1];if(!Q||Q.key!==A)return;this.setState(()=>{this.entries.pop()})}}build(A){let Q=[];Q.push(new IV0({offstage:this.entries.length>0,child:this.widget.root}));for(let $=0;$<this.entries.length;$++){let B=this.entries[$],D=$===this.entries.length-1,J=D?new k4({autofocus:!0,debugLabel:`ModalStackEntry[${$}]`,onKey:(E)=>{if(E.key!=="Escape")return"ignored";return B.dismiss(),"handled"},child:B.widget}):B.widget;Q.push(new IV0({key:B.key,offstage:!D,child:J}))}return new i4({fit:"expand",children:Q})}}class JA1 extends H1{props;constructor(A){super();this.props=A}build(A){let Q=this.props.commands.filter((D)=>D.status.type!=="hidden"),$=dh3(Q),B="";return new C6({header:"Command Palette",autofocus:!1,barrierOpaque:!1,chromePadding:K0.only({left:1,top:1,right:1}),footer:"none",onDismiss:this.props.onDismiss,child:new cA({items:Q,showBorder:!1,getLabel:(D)=>{let J=DA1(D);return D.keywords&&D.keywords.length>0?`${J} ${D.keywords.join(" ").toLowerCase()}`:J},onQueryChange:(D)=>{B=D},sortItems:(D,J,E)=>{B=E;let F=E.trim().toLowerCase();if(F===""){let K=D.item.status.type==="disabled"?1:0,z=J.item.status.type==="disabled"?1:0;if(K!==z)return K-z;let W=D.item.sortBoost??0,I=J.item.sortBoost??0;if(W!==I)return I-W;let H=D.item.noun?.toLowerCase()??"",q=J.item.noun?.toLowerCase()??"";if(H!==q)return H<q?-1:1;return 0}let Y=Sa4(D.item,F),Z=Sa4(J.item,F);if(Y!==Z)return Y?-1:1;let U=uR(D.item.verb.toLowerCase(),E),X=uR(J.item.verb.toLowerCase(),E);if(U!==X)return X-U;let G=uR(DA1(D.item),E),V=uR(DA1(J.item),E);if(G!==V)return V-G;return J.score-D.score},isItemDisabled:(D)=>D.status.type==="disabled",buildDisabledReasonWidget:(D,J)=>{if(D.status.type!=="disabled")return;let{colors:E}=O0.of(J);return new d({text:new w(D.status.reason,new T({color:E.mutedForeground,dim:!0})),textAlign:"center"})},renderItem:(D,J,E,F)=>new fa4({command:D,isSelected:J,isDisabled:E,categoryWidth:$,query:B,buildContext:F}),onAccept:(D)=>{this.props.onAccept(D)},onDismiss:this.props.onDismiss})})}}class fa4 extends H1{props;constructor(A){super();this.props=A}build(A){let{command:Q,isSelected:$,isDisabled:B,categoryWidth:D,query:J,buildContext:E}=this.props,F=O0.of(E),{colors:Y,app:Z}=F,U=$?Z.selectionBackground:void 0,X=$?Z.selectionForeground:Y.foreground,G=$?X:Y.mutedForeground,V=new d({text:new w(Q.noun?.toLowerCase()??"",new T({color:G,dim:B||!$})),textAlign:"right"}),K=[new w(Q.verb.toLowerCase(),new T({color:X,bold:!0,dim:B}))];if(B)K.push(new w(" (unavailable)",new T({color:X,dim:!0})));let z=mh3(Q,J);if(z)K.push(new w(" (alias: ",new T({color:X,dim:B}))),K.push(new w(z,new T({color:X,dim:B}))),K.push(new w(")",new T({color:X,dim:B})));let W=d.spans(K),I=[{child:V,fixedWidth:D},{child:W,expanded:!0}];if(Q.shortcut)I.push({child:ph3(Q.shortcut,F,B)});return new ya4({columns:I,padding:K0.horizontal(1),backgroundColor:U})}}function DA1(A){return A.noun?`${A.noun.toLowerCase()} ${A.verb.toLowerCase()}`:A.verb.toLowerCase()}function Sa4(A,Q){return A.keywords?.some(($)=>$.trim().toLowerCase()===Q)??!1}function mh3(A,Q){let $=Q.trim().toLowerCase();if($==="")return;return A.keywords?.find((B)=>B.trim().toLowerCase()===$)}function dh3(A){return A.reduce((Q,$)=>{return $.noun?Math.max(Q,E4($.noun)):Q},0)}function ph3(A,Q,$){let{app:B}=Q,D=new T({color:B.keybind,bold:!0,dim:$}),J=[],E=EE(A.toString()).split("+");for(let F=0;F<E.length;F++){if(F>0)J.push(new w("+",D));J.push(new w(E[F],D))}return d.spans(J)}class ya4 extends H1{props;constructor(A){super();this.props=A}build(A){let{columns:Q,gap:$=2,padding:B,backgroundColor:D}=this.props,J=[];for(let F=0;F<Q.length;F++){let Y=Q[F];if(F>0&&$>0)J.push(new X0({width:$}));if(Y.fixedWidth!==void 0)J.push(new X0({width:Y.fixedWidth,child:Y.child}));else if(Y.expanded)J.push(new R1({child:Y.child}));else J.push(Y.child)}let E=new s0({crossAxisAlignment:"start",children:J});if(!B&&!D)return E;return new b0({decoration:D?{color:D}:void 0,padding:B,child:E})}}class EA1{#A=[];#Q=new Set;get commands(){return this.#A}register(A){return this.#A.push(A),this.#$(),()=>{let Q=this.#A.indexOf(A);if(Q===-1)return;this.#A.splice(Q,1),this.#$()}}findByID(A){return this.#A.find((Q)=>Q.id===A)}runByID(A,Q){let $=this.findByID(A);if(!$||$.status.type!=="enabled")return!1;return $.run(new V00,Q,()=>{}),!0}addListener(A){this.#Q.add(A)}removeListener(A){this.#Q.delete(A)}#$(){for(let A of this.#Q)A()}}class R9 extends GA{commandRegistry;constructor({commandRegistry:A,child:Q}){super({child:Q});this.commandRegistry=A}updateShouldNotify(A){return!1}static of(A){let Q=R9.maybeOf(A);if(!Q)throw Error("No NeoCommandRegistryProvider found in widget tree");return Q}static maybeOf(A){return A.dependOnInheritedWidgetOfExactType(R9)?.commandRegistry??null}}class FA1 extends u0{onDismiss;constructor(A){super();this.onDismiss=A.onDismiss}createState(){return new xa4}}class xa4 extends R0{modalStack=new V00;commandRegistry=null;initState(){super.initState(),queueMicrotask(()=>{if(!this.mounted)return;let A=R9.of(this.context);this.commandRegistry=A,A.addListener(this.onCommandsChanged)})}dispose(){this.commandRegistry?.removeListener(this.onCommandsChanged),this.commandRegistry=null,super.dispose()}onCommandsChanged=()=>{this.setState()};build(A){let Q=R9.of(A).commands,$=new JA1({commands:Q,onAccept:(B)=>{B.run(this.modalStack,A,this.widget.onDismiss)},onDismiss:()=>{if(this.modalStack.canPop)this.modalStack.pop();else this.widget.onDismiss()}});return new BA1({root:$,controller:this.modalStack})}}var YA1=[{description:"Move cursor up/down",methods:[{keys:["↑"]},{keys:["↓"]}]},{description:"Move cursor left/right",methods:[{keys:["←"]},{keys:["→"]},{input:"B",keys:["Ctrl"]},{input:"F",keys:["Ctrl"]}]},{description:"Insert newline",methods:[{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!0},{description:"Insert newline",methods:[{keys:["Enter"]},{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!1},{description:"Submit message",methods:[{keys:["Enter"]}],submitOnEnterOnly:!0},{description:"Submit message",methods:[{keys:["Ctrl/Cmd","Enter"]}],submitOnEnterOnly:!1},{description:"Clear input",methods:[{keys:["Escape"]}]},{description:"Edit prompt in $EDITOR",methods:[{input:"G",keys:["Ctrl"]}]},{description:"Navigate history (previous/next)",methods:[{input:"P",keys:["Ctrl"]},{input:"N",keys:["Ctrl"]}]},{description:"Jump to start of line",methods:[{keys:["Cmd","←"]},{input:"A",keys:["Ctrl"]}]},{description:"Jump to end of line",methods:[{keys:["Cmd","→"]},{input:"E",keys:["Ctrl"]}]},{description:"Jump to previous word",methods:[{keys:["Alt","←"]},{keys:["Ctrl","←"]},{input:"B",keys:["Alt"]}]},{description:"Jump to next word",methods:[{keys:["Alt","→"]},{keys:["Ctrl","→"]},{input:"F",keys:["Alt"]}]},{description:"Delete character backward",methods:[{keys:["Backspace"]},{input:"H",keys:["Ctrl"]}]},{description:"Delete word backward",methods:[{keys:["Alt","Backspace"]},{input:"W",keys:["Ctrl"]}]},{description:"Delete character forward",methods:[{keys:["Delete"]},{input:"D",keys:["Ctrl"]}]},{description:"Delete to start of line",methods:[{keys:["Cmd","Backspace"]},{input:"U",keys:["Ctrl"]}]},{description:"Delete to end of line",methods:[{input:"K",keys:["Ctrl"]}]},{description:"Yank (paste deleted text)",methods:[{input:"Y",keys:["Ctrl"]}]},{description:"Paste image from clipboard",methods:[{input:"V",keys:["Ctrl"]}]},{description:"Switch agent mode",methods:[{input:"S",keys:["Ctrl"]}]},{description:"Toggle reasoning effort",methods:[{input:"D",keys:["Alt"]}]},{description:"Open command palette",methods:[{input:"O",keys:["Ctrl"]}]},{description:"Mention files",methods:[{keys:["@"]}]},{description:"Mention threads",methods:[{keys:["@@"]}]},{description:"Show prompt history",methods:[{input:"R",keys:["Ctrl"]}]},{description:"Toggle inline shortcuts help",methods:[{keys:["?"]}]},{description:"Toggle thinking/dense view",methods:[{input:"T",keys:["Alt"]}]}],ZA1=[{description:"Page scroll",methods:[{keys:["Pg Up"]},{keys:["Pg Down"]}]},{description:"Half-page scroll",methods:[{input:"K",keys:["Alt"]},{input:"J",keys:["Alt"]}]},{description:"Mouse wheel scroll",methods:[{keys:["Mouse Wheel"]}]},{description:"Jump to first message",methods:[{keys:["Home"]}]},{description:"Jump to bottom of screen",methods:[{keys:["End"]}]},{description:"Navigate to previous messages",methods:[{keys:["Tab"]},{keys:["Shift","Tab"]}]}];class HV0 extends H1{items;renderRow;constructor({items:A,renderRow:Q}){super();this.items=A,this.renderRow=Q}build(A){let $=g1.of(A).size.width,B=50,D=$<50,J=[];for(let E of this.items){let[F,Y]=this.renderRow(E),Z;if(D)Z=new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[F,new y0({padding:K0.only({left:4}),child:Y})]});else Z=new s0({crossAxisAlignment:"start",children:[new R1({flex:1,child:F}),new X0({width:1}),new R1({flex:1,child:Y})]});J.push(new y0({padding:K0.horizontal(6),child:Z}))}return new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:J})}}class UA1 extends u0{commands;submitOnEnter;constructor({key:A,commands:Q,submitOnEnter:$}){super(A?{key:A}:{});this.commands=Q,this.submitOnEnter=$??!0}createState(){return new ba4}}class ba4 extends R0{scrollController;initState(){this.scrollController=new v6,this.scrollController.disableFollowMode(),this.scrollController.jumpTo(0)}dispose(){}build(A){let $=L1.of(A).colorScheme,D=O0.of(A).app,J=g1.of(A),E=new T({color:$.primary,bold:!0}),F=new T({color:$.secondary,bold:!0}),Y=new T({color:D.keybind}),Z=new T({color:D.command}),U=new T({color:$.foreground}),X=new T({color:$.foreground}),G=J.size.width,V=J.size.height,K=G-4,z=V-4,W=Math.max(40,Math.min(80,K)),I=new Set(["permissions-disable"]),q=[...this.widget.commands.filter((O)=>{let R=O.noun?.toLowerCase();return R!=="dev"&&R!=="debug"&&!O.id.startsWith("debug-")&&!I.has(O.id)})].sort((O,R)=>{let k=(O.noun??"").toLowerCase(),_=(R.noun??"").toLowerCase(),f=k.localeCompare(_);if(f!==0)return f;let g=O.verb.toLowerCase(),b=R.verb.toLowerCase(),v=g.localeCompare(b);if(v!==0)return v;return O.id.localeCompare(R.id)}),N=new k6({autofocus:!0,controller:this.scrollController,child:new b0({constraints:new w1(W,W,0,Number.POSITIVE_INFINITY),child:new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[new D4({child:new d({text:new w(`Amp CLI - Help & Keyboard Shortcuts
5226
5226
  `,E)})}),new X0({height:1}),new y0({padding:K0.horizontal(2),child:new d({text:new w(`Editor Shortcuts
5227
5227
  `,F)})}),new HV0({items:YA1.filter((O)=>O.submitOnEnterOnly===void 0||O.submitOnEnterOnly===this.widget.submitOnEnter),renderRow:(O)=>{let R=[];for(let _ of O.methods){let f=this.buildCleanKeyCombination(_);R.push(f)}let k=R.join(", ");return[new d({text:new w(k,Y)}),new d({text:new w(O.description,U)})]}}),new X0({height:1}),new y0({padding:K0.horizontal(2),child:new d({text:new w(`Scrolling & Navigation
5228
5228
  `,F)})}),new HV0({items:ZA1,renderRow:(O)=>{let R=[];for(let _ of O.methods){let f=this.buildCleanKeyCombination(_);R.push(f)}let k=R.join(", ");return[new d({text:new w(k,Y)}),new d({text:new w(O.description,U)})]}}),new X0({height:1}),new y0({padding:K0.horizontal(2),child:new d({text:new w(`Command Palette Commands
@@ -5313,7 +5313,7 @@ Ctrl-X, Y, Z to unlock`;if(this.widget.centerContent)g=this.widget.centerContent
5313
5313
  `))}return E}function Dn3(A,Q,$){let{colors:B,app:D}=$,J=Jn3(Q.status,$);if(A.push(new w(` ${J.icon} `,new T({color:J.color}))),A.push(new w(Q.name,new T({color:Q.status==="pending"?B.warning:D.command}))),Q.status==="pending")A.push(new w(" discovering...",new T({color:B.foreground,dim:!0})));else if(Q.description)A.push(new w(` ${Ie4(Q.description,50)}`,new T({color:B.foreground,dim:!0})));if(Q.error)A.push(new w(` ${Ie4(Q.error,40)}`,new T({color:D.toolError})));A.push(new w(`
5314
5314
  `))}function Jn3(A,Q){let{colors:$,app:B}=Q;switch(A){case"pending":return{icon:"◌",color:$.warning};case"registered":return{icon:"•",color:$.mutedForeground};case"failed":return{icon:"✗",color:B.toolError};case"duplicate":return{icon:"◇",color:$.warning};default:return{icon:"?",color:$.foreground}}}function Ie4(A,Q){let $=A.replace(/\s+/g," ").trim();if(E4($)<=Q)return $;let B="...",D=E4(B);if(Q<=D)return IQ(B,Q);return`${IQ($,Q-D,!0,"")}${B}`}var C51="https://ampcode.com/news/neo",w51=[{title:"Meet the new Amp CLI",body:[]},{title:"Rebuilt From The Ground Up",body:["Same close-up terminal workflow. Completely different underneath."]},{title:"Just Keep Typing",body:["Context is summarized automatically at ~90%.","No handoff flow. No context percentage to babysit."]},{title:"Queueing and Steering",body:["Sending a message now queues by default instead of cancelling tools.","Use steering when you want the agent to see something sooner."]},{title:"Remote Control",body:["Start a thread in the CLI, then keep going from ampcode.com.","Watch live updates and queue follow-ups from any device."]},{title:"Customize Amp with Amp",body:[{text:"Amp now has a ",linkText:"complete plugin API",href:"https://ampcode.com/manual/plugin-api",textAfter:"."},"Add tools, commands, control UI, and hook into events."]},{title:"Permissions",body:[{text:"By default (when no ",highlightText:"amp.permissions",textAfterHighlight:" setting is present), Amp no longer asks for confirmation before running any tools and commands. And you can now implement your own custom permission logic with ",linkText:"plugins",href:"https://ampcode.com/manual/plugin-api",textAfter:"."}]},{title:null,body:["Check out the full news post for more:",{text:C51,href:C51},"","",{text:"Need old Amp for a bit? Use ",keybind:"amp --take-me-back"}]}];function En3(A){return[{title:"Upgrade your Amp CLI",body:[{text:"This npm-based distribution of Amp CLI has been deprecated. To use the ",linkText:"new Amp CLI",href:C51,textAfter:" you'll need to switch to the binary install:",linkWidget:!0},"",{codeBlock:["npm uninstall -g @sourcegraph/amp",A]}]}]}function Fn3(){if(process.platform==="win32")return'powershell -c "irm https://ampcode.com/install.ps1 | iex"';return"curl -fsSL https://ampcode.com/install.sh | bash"}var px=50,sR=40,q51=1000,Yn3=420,Zn3=760,Un3=-250,Xn3=1100,VK0=33,Ce4=0.999,Gn3=2.1,Vn3=720,Kn3=420,Pe4="Meet the new",_e4="Amp",Te4="CLI",M51=G4(Pe4).length,zn3=G4(_e4).length,Wn3=G4(Te4).length,KK0={primary:{r:140,g:38,b:0},secondary:{r:255,g:225,b:102}},we4={primary:{r:10,g:42,b:18},secondary:{r:200,g:230,b:68}},Me4={primary:{r:18,g:0,b:107},secondary:{r:103,g:255,b:168}},Le4=[KK0,we4,Me4,KK0,we4,Me4,KK0],In3=KK0;class L51 extends u0{onDismiss;onQuit;animationProgress;animationsEnabled;variant;binaryInstallCommand;introStages;dismissible;constructor(A){super();this.onDismiss=A.onDismiss,this.onQuit=A.onQuit,this.animationProgress=A.animationProgress,this.animationsEnabled=A.animationsEnabled??!0,this.variant=A.variant??"intro",this.binaryInstallCommand=A.binaryInstallCommand??Fn3(),this.introStages=this.variant==="npm-migration"?En3(this.binaryInstallCommand):w51,this.dismissible=this.variant!=="npm-migration"}createState(){return new ve4}}class ve4 extends R0{startedAt=performance.now();animationTimer=null;stageTransitionTimer=null;firstStageTitleTimer=null;firstStageHintTimer=null;firstStageRevealTimer=null;firstStageTitleRevealStartedAt=null;firstStageHintRevealStartedAt=null;stageTransitionStartedAt=performance.now();animationStartProgress=0;animationTargetProgress=1;animationDurationMs=q51;onAnimationComplete=null;animationProgress=0;introStage=0;previousIntroStage=null;stageTransitionProgress=1;stageTransitionDirection=1;firstStageTitleVisible=!1;firstStageHintVisible=!1;firstStageTitleRevealProgress=0;firstStageHintRevealProgress=0;dismissTimer=null;dismissStartedAt=performance.now();dismissProgress=0;isDismissing=!1;splashOrbGlow=new A7(42);initState(){super.initState(),this.startAnimationIfNeeded()}didUpdateWidget(A){if(super.didUpdateWidget(A),A.animationProgress!==this.widget.animationProgress||A.animationsEnabled!==this.widget.animationsEnabled)this.startAnimationIfNeeded()}dispose(){this.stopAnimation(),this.stopStageTransitionTimer(),this.stopFirstStageRevealTimers(),this.stopDismissAnimation(),super.dispose()}startAnimationIfNeeded(){if(this.stopAnimation(),this.stopFirstStageRevealTimers(),this.widget.animationProgress!==void 0){this.animationProgress=XE(this.widget.animationProgress),this.firstStageTitleVisible=this.animationProgress>=Ce4,this.firstStageHintVisible=this.animationProgress>=Ce4,this.firstStageTitleRevealProgress=this.firstStageTitleVisible?1:0,this.firstStageHintRevealProgress=this.firstStageHintVisible?1:0;return}if(!this.widget.animationsEnabled){this.stopStageTransitionTimer(),this.stopDismissAnimation(),this.animationProgress=1,this.isDismissing=!1,this.dismissProgress=0,this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1,this.previousIntroStage=null,this.stageTransitionProgress=1;return}if(this.firstStageTitleVisible=!1,this.firstStageHintVisible=!1,this.firstStageTitleRevealProgress=0,this.firstStageHintRevealProgress=0,this.startProgressAnimation({from:0,to:1,durationMs:q51,onComplete:()=>{if(!this.widget.dismissible)this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1})}}),this.widget.dismissible)this.startFirstStageRevealSequence()}startDismissAnimation(){if(this.isDismissing)return;if(!this.widget.animationsEnabled){this.widget.onDismiss();return}this.stopFirstStageRevealTimers(),this.stopStageTransitionTimer(),this.dismissStartedAt=performance.now(),this.setState(()=>{this.isDismissing=!0,this.dismissProgress=0}),this.dismissTimer=setInterval(()=>{let A=performance.now()-this.dismissStartedAt,Q=XE(A/Zn3);if(this.setState(()=>{this.dismissProgress=Q}),Q>=1)this.stopDismissAnimation(),this.widget.onDismiss()},VK0)}canNavigateIntroStage(){if(this.isDismissing)return!1;if(!this.firstStageHintVisible)return!1;if(this.introStage===0&&this.firstStageHintRevealProgress<1)return!1;return!0}advanceIntroStage(){if(!this.canNavigateIntroStage())return;if(this.isFinalIntroStage()){if(this.widget.dismissible)this.startDismissAnimation();return}this.moveIntroStage(1)}dismissFromFinalIntroStage(){if(!this.widget.dismissible||!this.canNavigateIntroStage()||!this.isFinalIntroStage())return!1;return this.startDismissAnimation(),!0}nextIntroStage(){if(!this.canNavigateIntroStage()||this.isFinalIntroStage())return;this.moveIntroStage(1)}goToPreviousIntroStage(){if(!this.canNavigateIntroStage()||this.introStage<=0)return;this.moveIntroStage(-1)}isFinalIntroStage(){return this.introStage>=this.widget.introStages.length-1}moveIntroStage(A){let Q=this.introStage+A;if(this.stopStageTransitionTimer(),this.stageTransitionStartedAt=performance.now(),this.setState(()=>{this.previousIntroStage=this.introStage,this.introStage=Q,this.stageTransitionDirection=A}),this.widget.animationProgress!==void 0||!this.widget.animationsEnabled){this.setState(()=>{this.previousIntroStage=null,this.stageTransitionProgress=1});return}this.setState(()=>{this.stageTransitionProgress=0}),this.stageTransitionTimer=setInterval(()=>{let $=performance.now()-this.stageTransitionStartedAt,B=XE($/Yn3);if(this.setState(()=>{if(this.stageTransitionProgress=B,B>=1)this.previousIntroStage=null}),B>=1)this.stopStageTransitionTimer()},VK0)}startProgressAnimation({from:A,to:Q,durationMs:$,onComplete:B}){this.stopAnimation(),this.startedAt=performance.now(),this.animationStartProgress=A,this.animationTargetProgress=Q,this.animationDurationMs=$,this.onAnimationComplete=B,this.animationProgress=A,this.animationTimer=setInterval(()=>{let D=performance.now()-this.startedAt,J=XE(D/this.animationDurationMs),E=this.animationStartProgress+(this.animationTargetProgress-this.animationStartProgress)*cx(J);if(this.setState(()=>{this.animationProgress=E}),J>=1)this.stopAnimation(),this.onAnimationComplete?.(),this.onAnimationComplete=null},VK0)}stopAnimation(){if(this.animationTimer)clearInterval(this.animationTimer),this.animationTimer=null}stopStageTransitionTimer(){if(this.stageTransitionTimer)clearInterval(this.stageTransitionTimer),this.stageTransitionTimer=null}startFirstStageRevealSequence(){if(this.stopFirstStageRevealTimers(),!this.widget.animationsEnabled){this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1});return}this.setState(()=>{this.firstStageTitleVisible=!1,this.firstStageHintVisible=!1,this.firstStageTitleRevealProgress=0,this.firstStageHintRevealProgress=0});let A=Math.max(0,q51+Un3),Q=A+Xn3;this.firstStageTitleTimer=setTimeout(()=>{this.firstStageTitleRevealStartedAt=performance.now(),this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageTitleRevealProgress=0}),this.startFirstStageRevealTimer()},A),this.firstStageHintTimer=setTimeout(()=>{this.firstStageHintRevealStartedAt=performance.now(),this.setState(()=>{this.firstStageHintVisible=!0,this.firstStageHintRevealProgress=0}),this.startFirstStageRevealTimer()},Q)}startFirstStageRevealTimer(){if(this.firstStageRevealTimer)return;this.firstStageRevealTimer=setInterval(()=>{let A=performance.now(),Q=this.firstStageTitleRevealStartedAt?XE((A-this.firstStageTitleRevealStartedAt)/Vn3):this.firstStageTitleRevealProgress,$=this.firstStageHintRevealStartedAt?XE((A-this.firstStageHintRevealStartedAt)/Kn3):this.firstStageHintRevealProgress;if(this.setState(()=>{this.firstStageTitleRevealProgress=Q,this.firstStageHintRevealProgress=$}),Q>=1&&$>=1)this.stopFirstStageRevealTimer()},VK0)}stopFirstStageRevealTimers(){if(this.stopFirstStageRevealTimer(),this.firstStageTitleRevealStartedAt=null,this.firstStageHintRevealStartedAt=null,this.firstStageTitleTimer)clearTimeout(this.firstStageTitleTimer),this.firstStageTitleTimer=null;if(this.firstStageHintTimer)clearTimeout(this.firstStageHintTimer),this.firstStageHintTimer=null}stopFirstStageRevealTimer(){if(this.firstStageRevealTimer)clearInterval(this.firstStageRevealTimer),this.firstStageRevealTimer=null}stopDismissAnimation(){if(this.dismissTimer)clearInterval(this.dismissTimer),this.dismissTimer=null}currentOrbPalette(){let A=Oe4(this.introStage),Q=this.previousIntroStage===null||this.stageTransitionProgress>=1?A:je4(Oe4(this.previousIntroStage),A,cx(this.stageTransitionProgress));return this.dismissProgress>0?je4(Q,In3,cx(this.dismissProgress)):Q}build(A){let Q=L1.of(A).colorScheme,$=O0.of(A),B=this.currentOrbPalette(),D=G$(1,"frontier",B),J=g1.of(A).size,F=this.widget.animationProgress??this.animationProgress,Y=Math.max(J.width/px,J.height/sR)*Gn3,Z=Y+(1-Y)*F,U=cx(this.dismissProgress),X=Math.max(px,Math.round(px*Z)),G=Math.max(sR,Math.round(sR*Z)),V=Math.round((J.width-X)/2),K=Math.round((J.height-G)/2),z=Math.max(0,Math.floor((J.width-px)/2)),W=-Math.floor(sR/2),I=Math.round(V+(z-V)*F),H=Math.round(K+(W-K)*F),q=I+X/2,N=H+G/2,C=Hn3({dismissProgress:this.dismissProgress,easedDismissProgress:U,introOrbScale:Z,normalOrbCenterX:q,normalOrbCenterY:N,size:J}),M=Math.max(px,Math.round(px*C.orbScale)),O=Math.max(sR,Math.round(sR*C.orbScale)),R=C.orbCenterX,k=C.orbCenterY,_=Math.round(R-M/2),f=Math.round(k-O/2),g=Math.max(3,Math.min(J.height-5,Math.floor(sR/2)+2)),b=Math.max(g+3,J.height-3),v=C.textDissolveProgress,x=this.isFinalIntroStage()?C.backdropDissolveProgress:0,c=this.firstStageTitleVisible&&v<1,p=c&&this.firstStageHintVisible,h=p&&this.widget.dismissible&&this.introStage>0&&!this.isFinalIntroStage(),i=this.introStage===0?this.firstStageTitleRevealProgress:1,r=this.introStage===0?this.firstStageHintRevealProgress:1,A0=Math.max(24,Math.min(74,J.width-4)),V0=Math.min(12,Math.max(8,J.height-g-6)),Y0=Math.max(0,Math.floor((J.width-A0)/2)),I0=Math.max(0,Math.min(J.height-V0,Math.floor(J.height*0.55-V0/2))),j0=this.widget.animationProgress!==void 0||!this.widget.animationsEnabled?new lN({width:M,height:O,agentMode:"frontier",visualStyle:"neo",neoGlyphSet:"dotField",backgroundColor:Q.background,primaryColor:B.primary,secondaryColor:B.secondary,glow:this.splashOrbGlow,seed:42,fps:0,onClick:()=>{}}):new lN({width:M,height:O,agentMode:"frontier",visualStyle:"neo",neoGlyphSet:"dotField",backgroundColor:Q.background,primaryColor:B.primary,secondaryColor:B.secondary,glow:this.splashOrbGlow,onClick:()=>{}});return new k4({autofocus:!0,canRequestFocus:!0,debugLabel:"NeoWelcomeTakeover",onKey:(Q0)=>{if(Q0.key==="Enter")return this.advanceIntroStage(),"handled";if(!this.widget.dismissible&&Q0.key==="c"&&Q0.ctrlKey)return this.widget.onQuit?.(),"handled";if(!this.widget.dismissible&&Q0.key==="q")return this.widget.onQuit?.(),"handled";if((Q0.key===" "||Q0.key==="Space")&&!this.isFinalIntroStage())return this.advanceIntroStage(),"handled";if(Q0.key==="Escape"||Q0.key==="Esc"){if(!this.widget.dismissible)return this.widget.onQuit?.(),"handled";return this.dismissFromFinalIntroStage()?"handled":"ignored"}if(Q0.key==="ArrowRight")return this.nextIntroStage(),"handled";if(Q0.key==="ArrowLeft")return this.goToPreviousIntroStage(),"handled";return"ignored"},child:new i4({fit:"expand",children:[new ke4({color:Q.background,dissolveProgress:x}),new i4({fit:"expand",children:[new O1({onClick:()=>{},child:X0.expand()}),new r4({left:_,top:f,width:M,height:O,child:j0}),...c?[new r4({left:Y0,top:I0,width:A0,height:V0,child:Nn3({introStages:this.widget.introStages,stage:this.introStage,previousStage:this.previousIntroStage,progress:this.stageTransitionProgress,direction:this.stageTransitionDirection,width:A0,height:V0,foreground:Q.foreground,mutedForeground:Q.mutedForeground,accent:D,link:$.app.link,keybind:$.app.keybind,titleRevealProgress:i,dissolveProgress:v,context:A})})]:[],...p?[...h?[new r4({left:Y0,top:Math.max(0,b-1),width:A0,height:1,child:new d({text:jn3({stage:this.introStage,featureStageCount:Math.max(0,this.widget.introStages.length-2),foreground:Q.mutedForeground,dissolveProgress:v}),textAlign:"center"})})]:[],new r4({left:Y0,top:b,width:A0,height:1,child:un3({finalStage:this.isFinalIntroStage(),dismissible:this.widget.dismissible,foreground:Q.mutedForeground,keybind:$.app.keybind,revealProgress:r,dissolveProgress:v,context:A})})]:[]]})]})})}}class ke4 extends u5{color;dissolveProgress;constructor({color:A,dissolveProgress:Q}){super();this.color=A,this.dissolveProgress=Q}createRenderObject(){return new Se4(this.color,this.dissolveProgress)}updateRenderObject(A){A.update(this.color,this.dissolveProgress)}}class Se4 extends i1{color;dissolveProgress;constructor(A,Q){super();this.color=A,this.dissolveProgress=Q}update(A,Q){this.color=A,this.dissolveProgress=Q,this.markNeedsPaint()}performLayout(){let A=this._lastConstraints;q4(!!A,"performLayout called without constraints");let Q=A.constrain(A.biggest.width,A.biggest.height);this.setSize(Q.width,Q.height),super.performLayout()}paint(A,Q=0,$=0){let B=Math.floor(Q+this.offset.x),D=Math.floor($+this.offset.y),J=Math.floor(this.size.width),E=Math.floor(this.size.height),F={bg:this.color},Y=XE(this.dissolveProgress);if(Y<=0){A.fill(B,D,J,E," ",F);return}if(Y>=1)return;for(let Z=0;Z<E;Z++)for(let U=0;U<J;U++)if(!qn3(U,Z,J,E,Y))A.fill(B+U,D+Z,1,1," ",F)}}function XE(A){return Math.min(1,Math.max(0,A))}function cx(A){return 1-(1-A)**3}function Oe4(A){return Le4[A]??Le4[0]}function je4(A,Q,$){return{primary:XR(A.primary,Q.primary,$),secondary:XR(A.secondary,Q.secondary,$)}}function Hn3({dismissProgress:A,easedDismissProgress:Q,introOrbScale:$,normalOrbCenterX:B,normalOrbCenterY:D,size:J}){return{orbScale:$+($*0.86-$)*Q,orbCenterX:B+(J.width*0.54-B)*Q,orbCenterY:D-J.height*0.44*Q,textDissolveProgress:XE(A/0.52),backdropDissolveProgress:cx(XE((A-0.12)/0.88))}}function qn3(A,Q,$,B,D){let J=B<=1?0:Q/(B-1),E=fe4(A+Q*Math.max(1,$));return(1-J)*0.72+E*0.28<D}function Nn3({introStages:A,stage:Q,previousStage:$,progress:B,direction:D,width:J,height:E,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:K}){if($===null||B>=1)return N51({introStages:A,stage:Q,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:K});let z=cx(B),W=D*Math.round((1-z)*J),I=-D*Math.round(z*J);return new tz(new i4({fit:"expand",children:[new r4({left:I,top:0,width:J,height:E,child:N51({introStages:A,stage:$,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:$===0?1:G,dissolveProgress:V,context:K})}),new r4({left:W,top:0,width:J,height:E,child:N51({introStages:A,stage:Q,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:K})})]}))}function N51({introStages:A,stage:Q,foreground:$,mutedForeground:B,accent:D,link:J,keybind:E,titleRevealProgress:F,dissolveProgress:Y,context:Z}){let U=A[Q]??A[0]??w51[0],X=new T({color:D,bold:!0}),G=new T({color:$}),V=A===w51&&Q===0,K=[...U.title===null?[]:[new d({text:V?zK0(Mn3({progress:F,foreground:D,pulseColor:D}),Y):new w(IB(U.title,Y),X),textAlign:"center"})],...U.body.length>0?[Cn3()]:[],...U.body.map((z)=>wn3(z,G,B,J,E,Y,Z))];return new D4({child:new y0({padding:K0.horizontal(1),child:new S0({crossAxisAlignment:"stretch",mainAxisAlignment:"center",mainAxisSize:"min",children:K})})})}function Cn3(){return X0.height(1)}function wn3(A,Q,$,B,D,J,E){if(typeof A==="string")return new d({text:new w(IB(A,J),Q),textAlign:"center"});if("codeBlock"in A)return new K5({onCopy:(F,Y)=>{if(Y)M3.success(E,"Copied to clipboard",2000)},child:new S0({mainAxisSize:"min",children:A.codeBlock.map((F)=>new d({text:new w(IB(F,J),new T({color:D})),textAlign:"center",selectable:!0}))})});if("keybind"in A){let F=new d({text:new w("",void 0,[new w(IB(A.text,J),new T({color:$,dim:!0})),new w(IB(A.keybind,J,G4(A.text).length),new T({color:D}))]),textAlign:"center",selectable:"selectable"in A?A.selectable:!1});if("selectable"in A)return new D4({child:new K5({child:F})});return F}if("highlightText"in A){let F=P6.createSpan(A.href,A.linkText,new T({color:B,underline:!0})),Y=YU.of(E),Z=new w("",void 0,[new w(A.text,Q),new w(A.highlightText,new T({color:D})),new w(A.textAfterHighlight,Q),new w(F.text,F.style,F.children,F.hyperlink,()=>{o6(E,A.href,{forceExternal:!1,onShowImagePreview:Y})}),new w(A.textAfter,Q)]);return new d({text:zK0(Z,J),textAlign:"center"})}if("linkText"in A){if(A.linkWidget)return new S0({mainAxisSize:"min",children:[new d({text:new w(IB(A.text,J),Q),textAlign:"center"}),new D4({child:new s0({mainAxisSize:"min",children:[P6.createWidget(E,A.href,IB(A.linkText,J),new T({color:B,underline:!0})),new d({text:new w(IB(A.textAfter,J),Q)})]})})]});let F=P6.createSpan(A.href,A.linkText,new T({color:B,underline:!0})),Y=YU.of(E),Z=new w("",void 0,[new w(A.text,Q),new w(F.text,F.style,F.children,F.hyperlink,()=>{o6(E,A.href,{forceExternal:!1,onShowImagePreview:Y})}),new w(A.textAfter,Q)]);return new d({text:zK0(Z,J),textAlign:"center"})}if(J>0)return new d({text:new w(IB(A.text,J),new T({color:B,underline:!0})),textAlign:"center"});return new D4({child:P6.createWidget(E,A.href,A.text,new T({color:B,underline:!0}))})}function Mn3({progress:A,foreground:Q,pulseColor:$}){let B=new T({color:Q,bold:!0}),D=new T({color:On3({progress:A,foreground:Q,pulseColor:$}),bold:!0});return new w("",void 0,[new w(Ln3(A).padEnd(M51," "),B),new w(" ",B),new w(Re4(_e4,zn3,A,0.72),B),new w(" ",B),new w(Re4(Te4,Wn3,A,0.88),D)])}function Ln3(A){let Q=G4(Pe4),$=Math.min(M51,Math.ceil(XE(A/0.62)*M51));return Q.slice(0,$).join("")}function Re4(A,Q,$,B){return $>=B?A:"".padEnd(Q," ")}function On3({progress:A,foreground:Q,pulseColor:$}){if(A<0.88||A>=1)return Q;let B=XE((A-0.88)/0.12);return Math.cos(B*Math.PI*4)*(1-B)>0.12?$:Q}function jn3({stage:A,featureStageCount:Q,foreground:$,dissolveProgress:B}){return new w(IB(`${A}/${Q}`,B),new T({color:$,dim:!0}))}function Rn3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J}){let E=new T({color:B}),F=new T({color:$,dim:!0}),Y=Q?A?"Enter":"Space":"Esc",Z=Q?A?" to get started":" to continue":" to quit, or use ",U=Q?"":"amp --take-me-back",X=Q?"":" to use the old version",G=`${Z}${U}${X}`;if(!Q)return new w("",void 0,[new w(Y,E),new w(Z,F),new w(U,E),new w(X,F)]);let V=ue4(Y,D),K=ue4(G,XE((D*(G4(Y).length+G4(G).length)-G4(Y).length)/G4(G).length));return new w("",void 0,[new w(IB(V,J),E),new w(IB(K.slice(0,Z.length),J),F),new w(IB(K.slice(Z.length,Z.length+U.length),J),E),new w(IB(K.slice(Z.length+U.length),J),F)])}function un3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J,context:E}){if(Q)return new d({text:Rn3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J}),textAlign:"center"});let F=new T({color:B}),Y=new T({color:$,dim:!0});return new K5({onCopy:(Z,U)=>{if(U)M3.success(E,"Copied to clipboard",2000)},child:new d({text:new w("",void 0,[new w("q",F),new w(" to quit, or use ",Y),new w("amp --take-me-back",F),new w(" to use the old version",Y)]),textAlign:"center",selectable:!0})})}function ue4(A,Q){let $=G4(A),B=Math.min($.length,Math.ceil(XE(Q)*$.length));return $.slice(0,B).join("").padEnd($.length," ")}function zK0(A,Q,$=0){if(Q<=0)return A;let B=$+G4(A.text??"").length,D=A.children?.map((J)=>{let E=zK0(J,Q,B);return B+=G4(J.toPlainText()).length,E});return new w(A.text?IB(A.text,Q,$):A.text,A.style,D,A.hyperlink,A.onClick)}function IB(A,Q,$=0){if(Q<=0)return A;return G4(A).map((D,J)=>{if(D.trim()==="")return D;return fe4($+J)<Q?" ":D}).join("")}function fe4(A){let Q=Math.sin((A+1)*12.9898)*43758.5453;return Q-Math.floor(Q)}c0();g2();function uC(A,Q){let{colors:$,dim:B}=Q,D=[];if(A.totalCostUSD===null)return D;let J=A.costBreakdown,E=J?.freeUSD??0,F=J?.paidUSD??0;if(E===0&&F===0)return D;let Z={decimalPlaces:"more-if-tiny",intent:"cost"};if(F===0)D.push(new w(BV(E,Z),new T({color:$.foreground,dim:B}))),D.push(new w(" (free)",new T({color:$.foreground,dim:B})));else if(E>0)D.push(new w(BV(E,Z),new T({color:$.foreground,dim:B}))),D.push(new w(" (free)",new T({color:$.foreground,dim:B}))),D.push(new w(" + ",new T({color:$.foreground,dim:B}))),D.push(new w(BV(F,Z),new T({color:$.foreground,dim:B,bold:!B})));else D.push(new w(BV(F,Z),new T({color:$.foreground,dim:B,bold:!B})));return D}class O51 extends V4{}class j51 extends V4{}function Pn3(A,Q){if(Q.code==="auth-required")return"You must be logged in to view thread usage. Run `amp login` first.";if(Q.code==="thread-not-found")return`Thread ${A} not found.`;return`Failed to load thread usage: ${Q.message??Q.code}`}function _n3(A,Q){let $=O0.of(Q),{colors:B}=$,D=uC(A,{colors:{foreground:B.foreground}}),J=[];if(D.length>0)J.push(new w("Total: ",new T({color:B.mutedForeground}))),J.push(...D);else if(A.totalCostUSD===null)J.push(new w("Usage information is currently unavailable."));else J.push(new w("No usage recorded for this thread yet."));if(A.costBreakdownURL)J.push(new w(`
5315
5315
 
5316
- `)),J.push(new w("Details: ",new T({color:B.mutedForeground}))),J.push(new w(A.costBreakdownURL,new T({color:$.app.link})));return new d({text:new w("",void 0,J)})}function Tn3(A,Q,$){let B=_n3(A,Q);if(!A.costBreakdownURL)return new C6({header:"Thread Cost",minWidth:80,maxWidth:100,onDismiss:$,child:B});let D=A.costBreakdownURL,J=new T1(()=>{return b4.maybeInvoke(Q,new H8(D,"Cost breakdown URL copied to clipboard","Failed to copy cost breakdown URL")),"handled"}),E=new T1(()=>{return o6(Q,D),"handled"});return new C6({header:"Thread Cost",minWidth:80,maxWidth:100,autofocus:!1,footer:[{keys:["Esc"],label:"close"},{keys:["o"],label:"open in browser"},{keys:["y"],label:"copy url"}],onDismiss:$,child:new b4({actions:new Map([[O51,J],[j51,E]]),child:new kA({debugLabel:"ThreadCostShortcuts",shortcuts:new Map([[G1.key("o"),new j51],[G1.key("y"),new O51]]),child:new v4({autofocus:!0,debugLabel:"ThreadCostBody",child:B})})})})}function ye4(A){return{noun:"thread",verb:"show cost",description:"Show usage cost for the active thread",keywords:["billing","spend"],get status(){return A.getActiveThreadID()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(Q,$,B)=>{let D=A.getActiveThreadID();if(!D)return;try{let J=await o4.threadDisplayCostInfo({threadID:D},{config:A.configService});if(!J.ok){A.toastController.show(Pn3(D,J.error),"error",5000),B();return}Q.push(Tn3(J.result,$,B))}catch(J){u.error("Failed to load Neo thread cost",{error:J,threadID:D}),A.toastController.show(`Failed to show thread cost: ${J instanceof Error?J.message:String(J)}`,"error",5000),B()}}}}c0();f9();B4();class XW extends V4{direction;constructor(A){super();this.direction=A}}class WK0 extends V4{}class b00 extends V4{}class IK0 extends V4{index;constructor(A){super();this.index=A}}function R51(A){return A.length+2}class u51 extends u0{props;constructor(A){super();this.props=A}createState(){return new xe4}}class xe4 extends R0{selectedIndex=0;initState(){super.initState(),this.selectedIndex=this.findSelectableIndex(this.widget.props.initialSelectedIndex??0)}didUpdateWidget(A){this.selectedIndex=this.findSelectableIndex(this.selectedIndex)}isSelectable(A){let Q=this.widget.props.entries[A];return Q?.type==="item"&&(Q.enabled??!0)}findSelectableIndex(A){let{entries:Q}=this.widget.props;if(Q.length===0)return 0;let $=Math.max(0,Math.min(A,Q.length-1));if(this.isSelectable($))return $;for(let B=1;B<Q.length;B++){let D=$+B;if(D<Q.length&&this.isSelectable(D))return D;let J=$-B;if(J>=0&&this.isSelectable(J))return J}return 0}moveSelection(A){let Q=this.findNextSelectableIndex(A);if(Q===this.selectedIndex)return;this.setState(()=>{this.selectedIndex=Q})}findNextSelectableIndex(A){let{entries:Q}=this.widget.props;for(let $=this.selectedIndex+A;$>=0&&$<Q.length;$+=A)if(this.isSelectable($))return $;return this.selectedIndex}acceptIndex(A){let Q=this.widget.props.entries[A];if(Q?.type!=="item"||!(Q.enabled??!0))return;this.setState(()=>{this.selectedIndex=A}),this.widget.props.onAccept(Q.value)}invoke=(A)=>{if(A instanceof XW)return this.moveSelection(A.direction),"handled";if(A instanceof WK0)return this.acceptIndex(this.selectedIndex),"handled";if(A instanceof b00)return this.widget.props.onDismiss(),"handled";if(A instanceof IK0)return this.acceptIndex(A.index),"handled";return"ignored"};buildShortcuts(){let A=new Map([[G1.key("ArrowDown"),new XW(1)],[G1.key("j"),new XW(1)],[G1.ctrl("n"),new XW(1)],[G1.key("ArrowUp"),new XW(-1)],[G1.key("k"),new XW(-1)],[G1.ctrl("p"),new XW(-1)],[G1.key("Enter"),new WK0],[G1.key("Escape"),new b00],[G1.ctrl("."),new b00]]);return this.widget.props.entries.forEach((Q,$)=>{if(Q.type==="item"&&Q.shortcut)A.set(Q.shortcut,new IK0($))}),A}buildActions(){return new Map([[XW,new T1(this.invoke)],[WK0,new T1(this.invoke)],[b00,new T1(this.invoke)],[IK0,new T1(this.invoke)]])}build(A){let Q=O0.of(A),$=vn3(this.widget.props.entries,g1.of(A).supportsEmojiWidth);return new b0({width:this.widget.props.width,height:R51(this.widget.props.entries),decoration:new R4(Q.colors.background,c1.all(new l1(Q.colors.border,1,"solid"))),child:new b4({actions:this.buildActions(),child:new kA({debugLabel:"NeoContextPickerShortcuts",shortcuts:this.buildShortcuts(),child:new v4({autofocus:!0,debugLabel:"NeoContextPicker",child:new S0({mainAxisSize:"min",crossAxisAlignment:"stretch",children:this.widget.props.entries.map((B,D)=>this.buildEntry(B,D,$,Q))})})})})})}buildEntry(A,Q,$,B){if(A.type==="separator")return new b0({height:1,decoration:{border:new c1(new l1(B.colors.border,1,"solid"))}});let D=Q===this.selectedIndex,J=A.enabled??!0,E=new T({color:D?B.app.selectionForeground:B.colors.foreground,dim:!J}),F=new T({color:D?B.app.selectionForeground:B.app.keybind,bold:!0,dim:!J});return new O1({onClick:()=>this.acceptIndex(Q),child:new b0({padding:K0.symmetric(1,0),decoration:D?new R4(B.app.selectionBackground):void 0,child:new s0({crossAxisAlignment:"start",children:[new R1({child:new d({text:new w(A.label,E),maxLines:1,overflow:"ellipsis"})}),new X0({width:1}),new X0({width:$,child:new d({text:new w(be4(A),F),textAlign:"right",maxLines:1,overflow:"ellipsis"})})]})})})}}function vn3(A,Q){return A.reduce(($,B)=>{return B.type==="item"?Math.max($,E4(be4(B),Q)):$},0)}function be4(A){return A.shortcutLabel??A.shortcut?.toString().toLowerCase()??""}var kn3=36,Sn3=24,fn3=72;class he4 extends u0{child;onContext;constructor(A,Q){super();this.child=A;this.onContext=Q}createState(){return new ge4}}class ge4 extends R0{build(A){return this.widget.onContext(A),this.widget.child}}function me4(A){return A.replace(/ ago$/,"")}function HK0(A){return A.reduce((Q,$)=>Math.max(Q,E4(me4($.description.timeAgo))),0)}function de4(A){return Math.max(Sn3,Math.min(A,fn3))}class P51 extends V4{}class _51 extends V4{}class T51{options;visibility;width=kn3;constructor(A){this.options=A;this.visibility=new Ee(A.state)}isVisible(){return this.visibility.isEnabled()}buildBody(A){return new s0({crossAxisAlignment:"stretch",children:[this.buildSlot(),new R1({child:A})]})}buildSlot(){if(!this.options.isAvailable()||this.visibility.isDisabled())return new X0({width:0});return new X0({width:this.width,child:new k4({debugLabel:"ThreadListSidebar",child:new pe4({activeThreadID:this.options.getActiveThreadID(),currentWorkspaceURI:A4(n0.file(this.options.getWorkspaceRoot())),width:this.width,loadThreads:this.options.loadThreads,onSelectThread:this.options.onSelectThread,onDismiss:this.close,onResizeWidth:this.resize})})})}commands(){if(!this.options.isAvailable())return[];return[{noun:"thread",verb:"toggle sidebar",description:"Show or hide the thread sidebar",shortcut:G1.alt("s"),status:{type:"enabled"},run:(A,Q,$)=>{$(),this.toggle()}}]}shortcutEntries(){return this.options.isAvailable()?[[G1.alt("s"),new BV0]]:[]}actionEntries(){if(!this.options.isAvailable())return[];return[[BV0,new T1(()=>this.toggle())]]}toggle=()=>{if(!this.options.isAvailable())return"ignored";if(this.visibility.isDisabled()&&this.options.isBlocked())return"ignored";return this.visibility.toggle(),"handled"};close=()=>{this.visibility.disable()};resize=(A)=>{let Q=de4(A);if(Q===this.width)return;this.options.state.setState(()=>{this.width=Q})}}class pe4 extends u0{props;constructor(A){super();this.props=A}createState(){return new ce4}}class ce4 extends R0{threads=[];isLoading=!0;isSwitchingThread=!1;hasError=!1;filterByWorkspace=!0;timeColWidth=0;contextMenu=null;pendingThreadMutations=new Map;resizeSession=null;isResizeHandleHovered=!1;pickerController=new Le;threadItemContexts=new Map;shortcuts=new Map([[G1.alt("w"),new P51],[G1.ctrl("."),new _51]]);actions=new Map([[P51,new T1(()=>{return this.setState(()=>{this.filterByWorkspace=!this.filterByWorkspace,this.contextMenu=null}),"handled"})],[_51,new T1(()=>this.openContextMenu())]]);get isBusy(){return this.isLoading||this.isSwitchingThread}get isResizeActive(){return this.resizeSession!==null||this.isResizeHandleHovered}didUpdateWidget(A){if(this.contextMenu&&(A.props.width!==this.widget.props.width||A.props.currentWorkspaceURI!==this.widget.props.currentWorkspaceURI))this.contextMenu=null}initState(){super.initState(),this.loadThreadSummaries()}async loadThreadSummaries(){try{let A=await this.widget.props.loadThreads(),Q=q31(A);if(!this.mounted)return;this.setState(()=>{this.pickerController.selectedItem=Q.find(($)=>$.id===this.widget.props.activeThreadID)??null,this.threads=Q,this.timeColWidth=HK0(Q),this.isLoading=!1,this.hasError=!1})}catch(A){if(u.error("Failed to load threads for Neo sidebar",{error:A}),!this.mounted)return;this.setState(()=>{this.isLoading=!1,this.hasError=!0})}}handleSelectThread=async(A)=>{if(this.isSwitchingThread)return;this.setState(()=>{this.isSwitchingThread=!0});try{await this.widget.props.onSelectThread(A),this.widget.props.onDismiss()}catch(Q){u.error("Failed to switch thread from Neo sidebar",{error:Q,threadID:A})}finally{if(this.mounted)this.setState(()=>{this.isSwitchingThread=!1})}};getOptimisticThreads(){return this.threads.flatMap((A)=>{if(this.pendingThreadMutations.get(A.id)?.kind==="archive")return[];return[A]})}getThreadsForDisplay(){let A=this.getOptimisticThreads();return this.filterByWorkspace?A.filter((Q)=>!Q.workspaceURI||Q.workspaceURI===this.widget.props.currentWorkspaceURI):A}buildContextMenuEntries(){return[{type:"item",value:"archive",label:"Archive Thread",shortcut:G1.key("a"),shortcutLabel:"a"},{type:"separator"},{type:"item",value:"copy-id",label:"Copy ID",shortcut:G1.ctrl("c"),shortcutLabel:"ctrl+c"},{type:"item",value:"copy-url",label:"Copy URL",shortcut:new G1("c",{shift:!0,ctrl:!0}),shortcutLabel:"shift+ctrl+c"}]}openContextMenu(){let A=this.pickerController.selectedItem;if(!A||this.isBusy||this.hasError)return"ignored";let Q=this.buildContextMenuEntries(),$=R51(Q),B=this.getContextMenuWidth(),D=this.getContextMenuPosition(A.id,$,B);return this.setState(()=>{this.contextMenu={threadID:A.id,left:D.left,top:D.top,width:B,height:$}}),"handled"}getContextMenuWidth(){let A=Math.max(24,this.widget.props.width-3);return Math.max(1,Math.min(A,this.widget.props.width-2))}getContextMenuPosition(A,Q,$){let B=Math.max(0,Math.min(2,this.widget.props.width-$)),D=1,J=this.threadItemContexts.get(A)?.findRenderObject(),E=this.context.findRenderObject();if(!(J instanceof i1)||!(E instanceof i1))return{left:B,top:1};let F=J.localToGlobal({x:0,y:0}),Y=E.localToGlobal({x:0,y:0}),Z=F.y-Y.y,U=Z+J.size.height,X=g1.sizeOf(this.context).height,G=Math.max(1,Math.min(E.size.height,X-Y.y)),z=G-U>=Q||Z<G/2?U:Z-Q,W=Math.max(0,G-Q);return{left:B,top:Math.max(0,Math.min(z,W))}}closeContextMenu=()=>{if(!this.contextMenu)return;this.setState(()=>{this.contextMenu=null})};handleContextMenuAccept=(A)=>{let Q=this.contextMenu?.threadID;if(!Q)return;if(this.closeContextMenu(),A==="archive"){this.archiveContextMenuThread(Q);return}if(A==="copy-id"){b4.maybeInvoke(this.context,new H8(Q,"Thread ID copied to clipboard","Failed to copy thread ID"));return}b4.maybeInvoke(this.context,new H8(this.getThreadURL(Q),"Thread URL copied to clipboard","Failed to copy thread URL"))};beginOptimisticArchive(A){if(this.pendingThreadMutations.has(A))return!1;if(!this.threads.some(($)=>$.id===A))return!1;let Q={kind:"archive",fallbackSelectedThreadID:null};return this.setState(()=>{this.pendingThreadMutations.set(A,Q),this.timeColWidth=HK0(this.getOptimisticThreads())}),a6.instance.addPostFrameCallback(()=>{if(!this.mounted)return;let $=this.pendingThreadMutations.get(A);if($?.kind!=="archive")return;$.fallbackSelectedThreadID=this.pickerController.selectedItem?.id??null}),!0}commitOptimisticArchive(A){if(this.pendingThreadMutations.get(A)?.kind!=="archive")return;this.pendingThreadMutations.delete(A),this.threads=this.threads.filter(($)=>$.id!==A),this.timeColWidth=HK0(this.getOptimisticThreads())}rollbackOptimisticArchive(A){let Q=this.pendingThreadMutations.get(A);if(Q?.kind!=="archive")return;let $=this.threads.find((B)=>B.id===A);if(!$){this.pendingThreadMutations.delete(A);return}this.setState(()=>{this.pendingThreadMutations.delete(A),this.timeColWidth=HK0(this.getOptimisticThreads());let B=this.pickerController.selectedItem?.id??null;if(B===null||B===Q.fallbackSelectedThreadID)this.pickerController.selectedItem=$})}async archiveContextMenuThread(A){let Q=M3.maybeOf(this.context),{configService:$}=W5.of(this.context);if(!this.beginOptimisticArchive(A))return;try{let B=await FG0({configService:$},A);if(!this.mounted)return;if(B){this.rollbackOptimisticArchive(A),Q?.show(B.message,"error");return}this.commitOptimisticArchive(A)}catch(B){if(u.error("Failed to archive thread from Neo sidebar context menu",{error:B,threadID:A}),!this.mounted)return;this.rollbackOptimisticArchive(A),Q?.show("Failed to archive thread","error")}}getThreadURL(A){return h$(new URL(W5.of(this.context).ampURL),A).toString()}buildContextMenuOverlay(){let A=this.contextMenu;if(!A||!this.getThreadsForDisplay().some((Q)=>Q.id===A.threadID))return null;return new r4({left:A.left,top:A.top,width:A.width,height:A.height,child:new k4({debugLabel:"ThreadListSidebarContextMenu",onFocusChange:(Q)=>{if(!Q)this.closeContextMenu()},child:new u51({entries:this.buildContextMenuEntries(),width:A.width,onAccept:this.handleContextMenuAccept,onDismiss:this.closeContextMenu})})})}buildContextMenuBackdrop(){return new r4({left:0,top:0,right:0,bottom:0,child:new O1({onClick:()=>this.closeContextMenu(),child:X0.expand()})})}buildThreadItem(A,Q,$,B){let D=O0.of(B),{app:J,colors:E}=D,F=!Q,Y=Q?J.selectionForeground:E.foreground,Z=Q?J.selectionForeground:E.mutedForeground,X=A.id===this.widget.props.activeThreadID?new d({text:new w("*",new T({color:Q?J.selectionForeground:E.success,dim:F}))}):void 0,G=me4(A.description.timeAgo);return new he4(new b0({padding:K0.symmetric(1,0),child:new s0({children:[new X0({width:2,child:X}),new R1({child:new d({text:new w(A.title,new T({color:Y,dim:F})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),new X0({width:$,child:s0.end([new d({text:new w(G,new T({color:Z,dim:F}))})])})]})}),(V)=>{this.threadItemContexts.set(A.id,V)})}handleResizeHandlePress=(A)=>{if(A.button!=="left")return;this.setState(()=>{this.resizeSession={baseWidthColumns:this.widget.props.width,startColumn:Math.floor(A.position.x)}})};handleResizeHandleDrag=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;let Q=Math.floor(A.position.x)-this.resizeSession.startColumn,$=de4(this.resizeSession.baseWidthColumns+Q);if($!==this.widget.props.width)this.widget.props.onResizeWidth($)};handleResizeHandleRelease=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;this.setState(()=>{this.resizeSession=null})};handleResizeHandleEnter=()=>{if(this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!0})};handleResizeHandleExit=()=>{if(!this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!1})};buildResizeHandle(){return new r4({top:0,right:0,bottom:0,width:1,child:new O1({cursor:YA.EW_RESIZE,onClick:this.handleResizeHandlePress,onDrag:this.handleResizeHandleDrag,onRelease:this.handleResizeHandleRelease,onEnter:this.handleResizeHandleEnter,onExit:this.handleResizeHandleExit,child:new X0({width:1})})})}build(A){let Q=O0.of(A),$=this.getThreadsForDisplay(),B=this.hasError?[]:$;this.threadItemContexts.clear();let D=this.isSwitchingThread?"Switching thread...":"Loading threads...",J=this.hasError?"Failed to load threads":"No threads match your filter",E=this.isResizeActive?2:1,F=new c1(void 0,new l1(Q.colors.border,E),void 0,void 0),Y=this.buildContextMenuOverlay(),Z=[new b0({decoration:new R4(Q.colors.background,F),child:new b4({actions:this.actions,child:new kA({shortcuts:this.shortcuts,debugLabel:"ThreadListSidebarFilter",child:new cA({items:B,getLabel:(U)=>`${U.title} ${U.id}`,controller:this.pickerController,onAccept:(U)=>void this.handleSelectThread(U.id),onDismiss:this.widget.props.onDismiss,renderItem:(U,X,G,V)=>this.buildThreadItem(U,X,this.timeColWidth,V),enabled:!this.isBusy,isLoading:this.isBusy,hidePromptWhenLoading:!0,loadingText:D,emptyStateText:J,maxRenderItems:200,showBorder:!1})})})}),this.buildResizeHandle()];if(Y)Z.push(this.buildContextMenuBackdrop()),Z.push(Y);return new b0({width:this.widget.props.width,child:new i4({fit:"expand",children:Z})})}}class v51 extends u0{listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;updateService;initialThreadIDs;showNeoWelcome;neoWelcomeVariant;onNeoWelcomeDismissed;notificationService;mcpTrustHandler;onThreadArchived;onActiveThreadChange;onRelaunchRequested;onFirstFrame;initialUserInput;getDefaultNewThreadVisibility;openThreadPickerOnStart;workspaceSettingsFilePath;neoContext;constructor(A){super();this.listSkillsForThread=A.listSkillsForThread,this.clientPool=A.clientPool,this.completionBuilder=A.completionBuilder,this.history=A.history,this.ideManager=A.ideManager,this.configService=A.configService,this.updateService=A.updateService,this.initialThreadIDs=A.initialThreadIDs??[],this.showNeoWelcome=A.showNeoWelcome??!1,this.neoWelcomeVariant=A.neoWelcomeVariant??"intro",this.onNeoWelcomeDismissed=A.onNeoWelcomeDismissed,this.notificationService=A.notificationService,this.mcpTrustHandler=A.mcpTrustHandler,this.onThreadArchived=A.onThreadArchived,this.onActiveThreadChange=A.onActiveThreadChange,this.onRelaunchRequested=A.onRelaunchRequested,this.onFirstFrame=A.onFirstFrame,this.initialUserInput=A.initialUserInput,this.getDefaultNewThreadVisibility=A.getDefaultNewThreadVisibility,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.workspaceSettingsFilePath=A.workspaceSettingsFilePath,this.neoContext=A.neoContext}createState(){return new ie4}}class ie4 extends R0{editorController=new k2;commandPalette=new Ee(this);commandRegistry=new EA1;toastController=new C11;relaunchNotificationController=new s61;exitHintTimer=new Je(this,1000);ideStatus=new z8(this,{});threadNavigationHistory=new QA1;draftThreadSettings={};draftThreadSettingsSeed={};hasDraftThreadSettingsSeed=!1;draftThreadSettingsInitPromise=null;activeThreadContext=null;activeThreadIDSubscription=null;activePluginMessageSubscription=null;activePluginUIRequestsSubscription=null;connectionErrorsSubscription=null;configSubscription=null;connectingToThreadID=null;executorAlreadyConnectedDialog=null;switchThreadPickerVisible=!1;neoWelcomeVisible=!1;endCreditsVisible=!1;neoInvadersHighScore=0;debugOverlayVisible=!1;focusDebugVisible=!1;unregisterCommands=null;emptyThreadTerminalTitleController=new q00;pluginIntegration=null;mcpTrustIntegration=null;updateRelaunchIntegration=null;noticesPollingTimeout=null;notices;loadThreads=async()=>{return this.widget.neoContext.listThreads()};analyzeContextForThread=async(A,Q)=>{return Fd4({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService,threadID:A,signal:Q})};onSwitchThread=(A)=>{return this.connectToExistingThread(A,{recordNavigation:!0,rethrowError:!0})};threadListSidebar=new T51({state:this,isAvailable:()=>this.widget.neoContext.isInternalUser,isBlocked:()=>this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal(),getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,getWorkspaceRoot:()=>this.widget.neoContext.workspaceRoot,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread});sendFeedbackReport=async(A)=>WV0({configService:this.widget.configService,settingsFilePath:this.widget.neoContext.settingsFilePath},A);archiveThread=async(A)=>{let Q=await FG0({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let $=await zl4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};removeThreadLabel=async(A,Q)=>{let $=await Wl4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};initState(){if(ZB.getInstance().interceptConsole(),this.neoInvadersHighScore=this.widget.neoContext.neoInvadersHighScore??0,this.notices=new y61(this.widget.configService,($)=>this.setState($)),a6.instance.addPostFrameCallback(()=>{setTimeout(()=>this.widget.onFirstFrame?.(),0),this.noticesPollingTimeout=setTimeout(()=>{this.noticesPollingTimeout=null,this.notices.startPolling()},500)},"Neo notices polling"),this.widget.showNeoWelcome)this.neoWelcomeVisible=!0;if(this.connectionErrorsSubscription=this.widget.clientPool.connectionErrors$.subscribe(({threadID:$,error:B})=>{if(u.error("Neo failed to connect to thread",{threadID:$,error:B}),!$)this.toastController.show(`Connection failed: ${B.message}`,"error",4000)}),this.configSubscription=this.widget.configService.config.subscribe(($)=>{this.applyDraftThreadSettingsSeed(this.applySessionDefaultsToThreadSettings(C90($.settings)))}),this.updateRelaunchIntegration=new e61({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested,relaunchNotificationController:this.relaunchNotificationController,updateService:this.widget.updateService}),this.updateRelaunchIntegration.init(),this.ideStatus.subscribe(this.widget.ideManager.status),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput,Q=this.widget.initialThreadIDs[0];if(Q){let $={};if(A)$.initialUserInput=A;this.connectToInitialThreads(Q,$)}else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.pluginIntegration=new r61({state:this,commandPalette:this.commandPalette,commandRegistry:this.commandRegistry,toastController:this.toastController,neoContext:this.widget.neoContext,getActiveThreadID:this.getActiveThreadID,appendToThread:this.appendPluginMessagesToThread,onBlockingConfirmDialogChange:this.syncEmptyThreadPluginConfirmationTitle}),this.pluginIntegration.init(),this.mcpTrustIntegration=new f61({state:this,mcpTrustHandler:this.widget.mcpTrustHandler,toastController:this.toastController,workspaceSettingsFilePath:this.widget.workspaceSettingsFilePath}),this.mcpTrustIntegration.init(),this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=z4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let A=this,Q=this.widget.neoContext.pluginService?wa4({pluginService:this.widget.neoContext.pluginService,workspaceRoot:this.widget.neoContext.workspaceRoot,logFilePath:this.widget.neoContext.logFilePath,toastController:this.toastController}):[],B=[Ta4({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["resume"],status:{type:"enabled"},sortBoost:100,run:(D,J,E)=>{D.pushWithDismiss((F)=>N31({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:F,onThreadSelected:E}))}},...this.threadListSidebar.commands(),{noun:"thread",verb:"switch to previous",description:"Switch to previous thread",keywords:["back"],get status(){return A.threadNavigationHistory.canNavigateBack()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to previous with no previous thread"}},run:(D,J,E)=>{A.navigateBack(),E()}},ye4({configService:this.widget.configService,getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??void 0,toastController:this.toastController}),{noun:"thread",verb:"switch to next",description:"Switch to next thread",keywords:["forward"],get status(){return A.threadNavigationHistory.canNavigateForward()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to next with no next thread"}},run:(D,J,E)=>{A.navigateForward(),E()}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",status:{type:"enabled"},run:(D,J,E)=>{D.push(new pA1({mcpServers:this.widget.neoContext.mcpServers,onDismiss:E}))}},{noun:"toolbox",verb:"list",description:"List all toolboxes and their tools",status:{type:"enabled"},run:(D)=>{D.pushWithDismiss((J)=>new H51({toolboxes:this.widget.neoContext.toolboxes,onDismiss:J}))}},{noun:"news",verb:"open",description:"Open Amp Chronicle in browser",keywords:["chronicle","blog","announcements"],status:{type:"enabled"},run:async(D,J,E)=>{try{await o6(J,"https://ampcode.com/chronicle")}finally{E()}}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config"],status:{type:"enabled"},run:()=>{V$(this.widget.neoContext.settingsFilePath).catch((D)=>{u.error("Failed to open settings file in editor",{error:D})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains"],status:{type:"enabled"},run:(D,J,E)=>{D.pushWithDismiss((F)=>new mA1({onCancel:F,onSelect:(Y)=>{this.handleIdeSelection(Y),E()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["manual","?"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new XA1({commands:R9.of(J).commands,onDismiss:E}))}},{noun:"amp",verb:"show welcome",description:"Show the welcome message again",status:{type:"enabled"},run:(D,J,E)=>{E(),A.showNeoWelcome()}},{noun:"amp",verb:"end credits",description:"Roll the full-screen Amp credits",status:{type:"enabled"},run:(D,J,E)=>{E(),A.showEndCredits()}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["v"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new C6({header:"Amp Version",maxWidth:72,onDismiss:E,child:new d({text:new w(SX0({version:"0.0.1779859522-gba0d26",buildTimestamp:"2026-05-27T05:30:48.321Z",buildType:"release"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","bye"],shortcut:G1.ctrl("c"),status:{type:"enabled"},run:(D,J)=>{b4.maybeInvoke(J,new Mx)}},...Q,...Da4(this.widget.neoContext.logFilePath)].map((D)=>this.commandRegistry.register(D));return()=>{for(let D of B)D()}}build(A){let Q=this.buildHints(),$=this.ideStatus.getValue(),B=this.notices.current,D=new I51({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,sendFeedbackReport:this.sendFeedbackReport,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,hints:Q,ideStatus:$,statusItems:this.pluginIntegration?.getStatusItems()??[],pluginConfirmationBlocked:this.pluginIntegration?.hasBlockingConfirmDialog()??!1,notificationService:this.widget.notificationService,notice:this.activeThreadContext||this.neoWelcomeVisible?null:B,onDismissNotice:(U)=>this.notices.dismiss(U)}),J=g1.of(A),E=J.capabilities.animationSupport!=="disabled",Y=[new b0({constraints:w1.tight(J.size.width,J.size.height),child:this.threadListSidebar.buildBody(D)})];if(this.commandPalette.isEnabled())Y.push(new k4({debugLabel:"CommandPaletteOverlay",onFocusChange:this.closeCommandPaletteOnFocusLoss,child:new FA1({onDismiss:this.commandPalette.disable})}));if(this.switchThreadPickerVisible&&!this.neoWelcomeVisible)Y.push(N31({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.neoWelcomeVisible)Y.push(new k4({debugLabel:"NeoWelcomeDialogOverlay",child:new L51({onDismiss:this.dismissNeoWelcome,onQuit:()=>z4.instance.stop(),animationsEnabled:E,variant:this.widget.neoWelcomeVariant})}));let Z=this.executorAlreadyConnectedDialog;if(Z)Y.push(new k4({debugLabel:"NeoExecutorAlreadyConnectedDialogOverlay",child:new hA1({existingExecutorPid:Z.existingExecutorPid,onChoice:this.handleExecutorAlreadyConnectedChoice})}));if(Y.push(...this.mcpTrustIntegration?.buildDialogLayers()??[]),Y.push(...this.pluginIntegration?.buildDialogLayers()??[]),this.widget.neoContext.isInternalUser)Y.push(new VA1({top:this.focusDebugVisible?33:1,visible:this.debugOverlayVisible,pid:qK0.pid,activeThreadID:this.activeThreadContext?.client.getThreadId()??null,connectionInfo$:this.activeThreadContext?.observer.connectionInfo()??null}));if(this.focusDebugVisible)Y.push(new gA1);if(this.endCreditsVisible)Y.push(new kA1({onComplete:this.completeEndCredits,highScore:this.neoInvadersHighScore,onHighScoreChange:this.updateNeoInvadersHighScore}));return new W5({neoContext:this.widget.neoContext,child:new R9({commandRegistry:this.commandRegistry,child:new Ox({completionBuilder:this.widget.completionBuilder,child:new M3({controller:this.toastController,child:new b4({actions:this.buildActions(),child:new kA({debugLabel:"NeoAppShortcuts",shortcuts:this.buildShortcuts(),child:new v4({debugLabel:"AppShellFocus",child:new w11({controller:this.toastController,complexToastControllers:[this.relaunchNotificationController,...B&&this.activeThreadContext&&!this.neoWelcomeVisible?[this.notices]:[]],child:new GA1({configReloadEvents:this.widget.configService.configReloadEvents,toastController:this.toastController,child:new i4({children:Y})})})})})})})})})})}buildShortcuts(){let A=new Map([[G1.ctrl("c"),new tG0],[G1.ctrl("o"),new AV0],[G1.alt("i"),new $V0],[G1.alt("p"),new tN],[G1.ctrl("."),new JV0],[G1.ctrl("t"),new YV0],...this.threadListSidebar.shortcutEntries()]);if(qK0.env.NODE_ENV==="development"&&qK0.platform==="darwin")A.set(G1.meta("r"),new eG0);return A}buildActions(){let A=new T1(()=>{if(TD.hasAnyCopyableSelection())return TD.tryCopyAnyActiveSelection(),"handled";return this.onExitPressed(),"handled"}),Q=new T1(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),$=new T1(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),B=new T1(()=>{return this.startNewDraftThread(),"handled"}),D=new T1(()=>{return z4.instance.stop(),"handled"}),J=new T1(()=>{return G00({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),"handled"}),E=new T1((G)=>{if(!G.text)return"ignored";return z4.instance.tuiInstance.clipboard.writeText(G.text).then((V)=>{if(V.ok)this.toastController.show(G.successMessage,"success",2000);else this.toastController.show(`${G.failureMessage}: ${V.userFacingErrorMessage}`,"error",4000)}).catch((V)=>{u.error("Failed to copy Neo text to clipboard",{error:V}),this.toastController.show(G.failureMessage,"error",2000)}),"handled"}),F=new T1(()=>{return z4.instance.toggleFrameStatsOverlay(),"handled"}),Y=new T1(()=>this.notices.dismissCurrent()?"handled":"ignored"),Z=new T1(()=>{if(!this.widget.neoContext.isInternalUser)return"ignored";return this.setState(()=>{this.debugOverlayVisible=!this.debugOverlayVisible}),"handled"}),U=da4({getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,neoContext:this.widget.neoContext,toastController:this.toastController,startNewDraftThread:this.startNewDraftThread,sendFeedbackReport:this.sendFeedbackReport}),X=new T1(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[tG0,A],[B00,B],[Mx,D],[eG0,J],[H8,E],[F00,$],[AV0,Q],[$V0,Z],...this.threadListSidebar.actionEntries(),[JV0,Y],...U,[tN,F],[YV0,X]])}startNewDraftThread(A={}){let Q=this.activeThreadContext?.client.getThreadId();if(this.commandPalette.disable(),this.threadNavigationHistory.recordNavigation(Q),this.setState(()=>{if(this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.activePluginMessageSubscription?.unsubscribe(),this.activePluginMessageSubscription=null,this.activePluginUIRequestsSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription=null,this.pluginIntegration?.cancelOwnerUIRequests(),this.activeThreadContext=null,this.connectingToThreadID=null,A.hideDebugOverlay)this.debugOverlayVisible=!1}),this.widget.onActiveThreadChange?.(null),this.syncEmptyThreadPluginConfirmationTitle(),A.prompt!==void 0)this.editorController.text=A.prompt}syncEmptyThreadPluginConfirmationTitle=()=>{this.emptyThreadTerminalTitleController.setPluginConfirmationBlocked(this.activeThreadContext===null&&(this.pluginIntegration?.hasBlockingConfirmDialog()??!1))};closeCommandPaletteOnFocusLoss=(A)=>{if(A||!this.commandPalette.isEnabled())return;this.commandPalette.disable()};ensureDraftThreadSettingsInitialized(){if(this.hasDraftThreadSettingsSeed)return Promise.resolve();if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=this.applySessionDefaultsToThreadSettings(await gy(this.widget.configService));this.applyDraftThreadSettingsSeed(A)}catch(A){u.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}applySessionDefaultsToThreadSettings(A){let Q=this.widget.neoContext.sessionAgentMode,$=A,B=UB(Q),D=qX0(this.widget.neoContext,Q);if(B!==void 0&&D!==void 0)$={...$,[B]:D};return HX0($,{agentMode:Q,explicitEffort:this.widget.neoContext.explicitReasoningEffort,sessionState:this.widget.neoContext})}applyDraftThreadSettingsSeed(A){if(!this.mounted)return;if(!this.hasDraftThreadSettingsSeed){this.setState(()=>{this.hasDraftThreadSettingsSeed=!0,this.draftThreadSettings=le4(this.draftThreadSettings,{},A),this.draftThreadSettingsSeed={...A}});return}if(tE(this.draftThreadSettingsSeed,A))return;this.setState(()=>{this.draftThreadSettings=le4(this.draftThreadSettings,this.draftThreadSettingsSeed,A),this.draftThreadSettingsSeed={...A}})}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(WC);if(this.exitHintTimer.isActive())A.add(Hx);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),z4.instance.stop();else this.exitHintTimer.activate()};dismissNeoWelcome=()=>{if(!this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!1}),this.widget.onNeoWelcomeDismissed?.()};updateNeoInvadersHighScore=(A)=>{if(A<=this.neoInvadersHighScore)return;this.setState(()=>{this.neoInvadersHighScore=A}),qQ((Q)=>({...Q,neoInvadersHighScore:Math.max(Q.neoInvadersHighScore,A)})).catch((Q)=>{u.warn("Failed to save Neo Invaders high score",{error:Q instanceof Error?Q.message:String(Q)})})};showNeoWelcome=()=>{if(this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!0})};showEndCredits=()=>{if(this.endCreditsVisible)return;this.setState(()=>{this.endCreditsVisible=!0})};completeEndCredits=()=>{if(!this.endCreditsVisible)return;this.setState(()=>{this.endCreditsVisible=!1})};promptExecutorAlreadyConnected(A){return new Promise((Q)=>{this.setState(()=>{this.executorAlreadyConnectedDialog={existingExecutorPid:A.existingExecutorPid,resolve:($)=>{Q($==="watch"?"observe":"disconnect")}}})})}handleExecutorAlreadyConnectedChoice=(A)=>{if(this.resolveExecutorAlreadyConnectedDialog(A),A==="exit")z4.instance.stop()};resolveExecutorAlreadyConnectedDialog(A){let Q=this.executorAlreadyConnectedDialog;if(!Q)return;this.setState(()=>{this.executorAlreadyConnectedDialog=null}),Q.resolve(A)}closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q,$=null,B)=>{await this.ensureDraftThreadSettingsInitialized();let D=this.activeThreadContext?.client.getThreadId(),J=A.find(X90);if(J)this.widget.history.add(J.text,qK0.cwd()),this.widget.history.reset();let E=$?void 0:await this.widget.getDefaultNewThreadVisibility?.(),F=$??E??null,Y=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings,F??void 0);this.sendUserMessage(Y,A,Q,B),this.rememberSessionDefaultsForNewMessage(Q,this.draftThreadSettings),this.threadNavigationHistory.recordNavigation(D),this.setActiveClient(Y)};rememberSessionDefaultsForNewMessage(A,Q){this.widget.neoContext.sessionAgentMode=A;let $=Q["reasoning.effort"];if($!==void 0)this.widget.neoContext.lastReasoningEffortByMode={...this.widget.neoContext.lastReasoningEffortByMode??{},[A]:$};let B=UB(A),D=B?Q[B]:void 0;if(D!==void 0)this.widget.neoContext.lastSpeedByMode={...this.widget.neoContext.lastSpeedByMode??{},[A]:D};qQ((J)=>{let E={...J,agentMode:A};if($!==void 0)E={...E,lastReasoningEffortByMode:{...E.lastReasoningEffortByMode??{},[A]:$}};if(D!==void 0)E={...E,lastSpeedByMode:{...E.lastSpeedByMode??{},[A]:D}};return E}).catch((J)=>{u.warn("Failed to persist Neo session defaults for new message",{error:J instanceof Error?J.message:String(J)})})}sendUserMessage(A,Q,$,B){let D=FY0(this.ideStatus.getValue());if(B===void 0){A.client.sendUserMessage(Q,$,{userState:D});return}A.client.sendUserMessage(Q,$,{reasoningEffort:B,userState:D})}getActiveThreadID=()=>{return this.activeThreadContext?.client.getThreadId()??void 0};getRelaunchThreadIDs=()=>{let A=new Set,Q=this.getActiveThreadID();if(Q)A.add(Q);for(let $ of this.widget.clientPool.activeThreadIDs)A.add($);return[...A]};appendPluginMessagesToThread=async(A,Q)=>{let $=this.activeThreadContext;if(!$)throw Error("appendToThread is not available - no active thread");let B=$.client.getThreadId();if(Q&&B!==Q)throw Error("thread.append is only available for the active executor thread");for(let D of A)this.sendUserMessage($,[{type:"text",text:D.content}])};async connectToExistingThread(A,Q={}){let $=this.activeThreadContext?.client.getThreadId();this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:(D)=>this.promptExecutorAlreadyConnected(D)});if(this.setActiveClient(B),Q.recordNavigation&&$!==A)this.threadNavigationHistory.recordNavigation($);if(Q.initialUserInput)this.sendUserMessage(B,[{type:"text",text:Q.initialUserInput}])}catch(B){if(u.error("Failed to load thread",{error:B,threadID:A}),this.toastController.show(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`,"error",4000),Q.rethrowError)throw B}finally{this.setState(()=>{this.connectingToThreadID=null})}}async connectToInitialThreads(A,Q={}){await this.connectToExistingThread(A,Q);let $=this.widget.initialThreadIDs.filter((B)=>B!==A);await Promise.all($.map((B)=>this.resumeBackgroundThread(B)))}async resumeBackgroundThread(A){try{await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:async()=>"observe"})}catch(Q){u.error("Failed to resume background thread",{error:Q,threadID:A}),this.toastController.show(`Failed to resume ${A}: ${Q instanceof Error?Q.message:String(Q)}`,"error",4000)}}async navigateBack(){let A=this.threadNavigationHistory.startBackNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateForward(){let A=this.threadNavigationHistory.startForwardNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateToThread(A){try{await this.connectToExistingThread(A.targetThreadID,{rethrowError:!0})}catch{A.rollback()}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q}}),this.syncEmptyThreadPluginConfirmationTitle(),this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=Q.threadID().subscribe(($)=>{this.widget.onActiveThreadChange?.($)}),this.activePluginMessageSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription?.unsubscribe(),this.pluginIntegration?.cancelOwnerUIRequests(),this.activePluginMessageSubscription=Q.pluginMessages().subscribe(($)=>{this.pluginIntegration?.handlePluginMessage($,(B)=>{A.sendPluginMessage(B)})}),this.activePluginUIRequestsSubscription=Q.pluginUIRequests().subscribe(($)=>{this.pluginIntegration?.handlePluginMessage({type:"plugin_message",message:{type:"event",event:"plugin.ui.snapshot",data:{requests:[...$]}}},(B)=>{A.sendPluginMessage(B)})})}handleIdeSelection=async(A)=>{try{await this.widget.ideManager.connect(A)}catch(Q){u.error("Failed to connect to IDE",{error:Q});let $=Q instanceof Error?Q.message:String(Q);this.toastController.show(`IDE connection failed: ${$}`,"error",4000)}};dispose(){if(this.unregisterCommands?.(),this.unregisterCommands=null,this.activePluginMessageSubscription?.unsubscribe(),this.activePluginMessageSubscription=null,this.activePluginUIRequestsSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription=null,this.pluginIntegration?.dispose(),this.pluginIntegration=null,this.emptyThreadTerminalTitleController.dispose(),this.mcpTrustIntegration?.dispose(),this.mcpTrustIntegration=null,this.updateRelaunchIntegration?.dispose(),this.updateRelaunchIntegration=null,this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.noticesPollingTimeout)clearTimeout(this.noticesPollingTimeout),this.noticesPollingTimeout=null;this.connectionErrorsSubscription?.unsubscribe(),this.configSubscription?.unsubscribe(),this.configSubscription=null,this.notices.dispose(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.executorAlreadyConnectedDialog!==null||this.neoWelcomeVisible||(this.mcpTrustIntegration?.hasBlockingDialog()??!1)||this.endCreditsVisible||(this.pluginIntegration?.hasBlockingDialog()??!1)}}function le4(A,Q,$){let B={...A};for(let D of yn3(Q,$)){if(!tE(A[D],Q[D]))continue;let J=$[D];if(J===void 0)delete B[D];else B[D]=J}return B}function yn3(...A){return Array.from(new Set(A.flatMap((Q)=>Object.keys(Q))))}a4();function ne4(A,Q,$,B){let D=Dv(A),J="\x1B[0m",E="\x1B[34m",F="\x1B[90m",Y="\x1B[2m",Z=[];if(A.archived)Z.push("\x1B[90m\x1B[2mArchived\x1B[0m");Z.push(`${D}`),Z.push(`\x1B[34m${Q}\x1B[0m`),Z.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let U=14,X=7,G=new QE(U,X),V=new A7(42),K=new iN(U,X,U,X,U,X,0,A.agentMode??"smart","intensity","classic","braille",void 0,void 0,z0.default(),V);K.layout(w1.tight(U,X)),K.paint(G,0,0);let z=G.getBuffer().getCells(),W=0;for(let R=0;R<X;R++)if(z[R].some((k)=>k.char!==" ")){W=R;break}let I=X-1;for(let R=X-1;R>=0;R--)if(z[R].some((k)=>k.char!==" ")){I=R;break}function H(R,k){if(!R)return"";if(R.type==="rgb"){let{r:_,g:f,b:g}=R.value;if($.getColorDepth()>=24)return`\x1B[${k?38:48};2;${_};${f};${g}m`;let b=FR(_,f,g);return`\x1B[${k?38:48};5;${b}m`}return""}let q=[];if(I>=W)for(let R=W;R<=I;R++){let k="";for(let _=0;_<U;_++){let f=z[R][_],g=f.char,b=H(f.style.fg,!0);k+=b+g+"\x1B[0m"}q.push(k)}let N=q.length,C=Math.max(N,Z.length),M=Math.floor((C-N)/2),O=Math.floor((C-Z.length)/2);for(let R=0;R<C;R++){let k=" ".repeat(U);if(R>=M&&R<M+N)k=q[R-M];let _=" ",f="";if(R>=O&&R<O+Z.length)f=Z[R-O];$.write(k+_+f+`
5316
+ `)),J.push(new w("Details: ",new T({color:B.mutedForeground}))),J.push(new w(A.costBreakdownURL,new T({color:$.app.link})));return new d({text:new w("",void 0,J)})}function Tn3(A,Q,$){let B=_n3(A,Q);if(!A.costBreakdownURL)return new C6({header:"Thread Cost",minWidth:80,maxWidth:100,onDismiss:$,child:B});let D=A.costBreakdownURL,J=new T1(()=>{return b4.maybeInvoke(Q,new H8(D,"Cost breakdown URL copied to clipboard","Failed to copy cost breakdown URL")),"handled"}),E=new T1(()=>{return o6(Q,D),"handled"});return new C6({header:"Thread Cost",minWidth:80,maxWidth:100,autofocus:!1,footer:[{keys:["Esc"],label:"close"},{keys:["o"],label:"open in browser"},{keys:["y"],label:"copy url"}],onDismiss:$,child:new b4({actions:new Map([[O51,J],[j51,E]]),child:new kA({debugLabel:"ThreadCostShortcuts",shortcuts:new Map([[G1.key("o"),new j51],[G1.key("y"),new O51]]),child:new v4({autofocus:!0,debugLabel:"ThreadCostBody",child:B})})})})}function ye4(A){return{noun:"thread",verb:"show cost",description:"Show usage cost for the active thread",keywords:["billing","spend"],get status(){return A.getActiveThreadID()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(Q,$,B)=>{let D=A.getActiveThreadID();if(!D)return;try{let J=await o4.threadDisplayCostInfo({threadID:D},{config:A.configService});if(!J.ok){A.toastController.show(Pn3(D,J.error),"error",5000),B();return}Q.push(Tn3(J.result,$,B))}catch(J){u.error("Failed to load Neo thread cost",{error:J,threadID:D}),A.toastController.show(`Failed to show thread cost: ${J instanceof Error?J.message:String(J)}`,"error",5000),B()}}}}c0();f9();B4();class XW extends V4{direction;constructor(A){super();this.direction=A}}class WK0 extends V4{}class b00 extends V4{}class IK0 extends V4{index;constructor(A){super();this.index=A}}function R51(A){return A.length+2}class u51 extends u0{props;constructor(A){super();this.props=A}createState(){return new xe4}}class xe4 extends R0{selectedIndex=0;initState(){super.initState(),this.selectedIndex=this.findSelectableIndex(this.widget.props.initialSelectedIndex??0)}didUpdateWidget(A){this.selectedIndex=this.findSelectableIndex(this.selectedIndex)}isSelectable(A){let Q=this.widget.props.entries[A];return Q?.type==="item"&&(Q.enabled??!0)}findSelectableIndex(A){let{entries:Q}=this.widget.props;if(Q.length===0)return 0;let $=Math.max(0,Math.min(A,Q.length-1));if(this.isSelectable($))return $;for(let B=1;B<Q.length;B++){let D=$+B;if(D<Q.length&&this.isSelectable(D))return D;let J=$-B;if(J>=0&&this.isSelectable(J))return J}return 0}moveSelection(A){let Q=this.findNextSelectableIndex(A);if(Q===this.selectedIndex)return;this.setState(()=>{this.selectedIndex=Q})}findNextSelectableIndex(A){let{entries:Q}=this.widget.props;for(let $=this.selectedIndex+A;$>=0&&$<Q.length;$+=A)if(this.isSelectable($))return $;return this.selectedIndex}acceptIndex(A){let Q=this.widget.props.entries[A];if(Q?.type!=="item"||!(Q.enabled??!0))return;this.setState(()=>{this.selectedIndex=A}),this.widget.props.onAccept(Q.value)}invoke=(A)=>{if(A instanceof XW)return this.moveSelection(A.direction),"handled";if(A instanceof WK0)return this.acceptIndex(this.selectedIndex),"handled";if(A instanceof b00)return this.widget.props.onDismiss(),"handled";if(A instanceof IK0)return this.acceptIndex(A.index),"handled";return"ignored"};buildShortcuts(){let A=new Map([[G1.key("ArrowDown"),new XW(1)],[G1.key("j"),new XW(1)],[G1.ctrl("n"),new XW(1)],[G1.key("ArrowUp"),new XW(-1)],[G1.key("k"),new XW(-1)],[G1.ctrl("p"),new XW(-1)],[G1.key("Enter"),new WK0],[G1.key("Escape"),new b00],[G1.ctrl("."),new b00]]);return this.widget.props.entries.forEach((Q,$)=>{if(Q.type==="item"&&Q.shortcut)A.set(Q.shortcut,new IK0($))}),A}buildActions(){return new Map([[XW,new T1(this.invoke)],[WK0,new T1(this.invoke)],[b00,new T1(this.invoke)],[IK0,new T1(this.invoke)]])}build(A){let Q=O0.of(A),$=vn3(this.widget.props.entries,g1.of(A).supportsEmojiWidth);return new b0({width:this.widget.props.width,height:R51(this.widget.props.entries),decoration:new R4(Q.colors.background,c1.all(new l1(Q.colors.border,1,"solid"))),child:new b4({actions:this.buildActions(),child:new kA({debugLabel:"NeoContextPickerShortcuts",shortcuts:this.buildShortcuts(),child:new v4({autofocus:!0,debugLabel:"NeoContextPicker",child:new S0({mainAxisSize:"min",crossAxisAlignment:"stretch",children:this.widget.props.entries.map((B,D)=>this.buildEntry(B,D,$,Q))})})})})})}buildEntry(A,Q,$,B){if(A.type==="separator")return new b0({height:1,decoration:{border:new c1(new l1(B.colors.border,1,"solid"))}});let D=Q===this.selectedIndex,J=A.enabled??!0,E=new T({color:D?B.app.selectionForeground:B.colors.foreground,dim:!J}),F=new T({color:D?B.app.selectionForeground:B.app.keybind,bold:!0,dim:!J});return new O1({onClick:()=>this.acceptIndex(Q),child:new b0({padding:K0.symmetric(1,0),decoration:D?new R4(B.app.selectionBackground):void 0,child:new s0({crossAxisAlignment:"start",children:[new R1({child:new d({text:new w(A.label,E),maxLines:1,overflow:"ellipsis"})}),new X0({width:1}),new X0({width:$,child:new d({text:new w(be4(A),F),textAlign:"right",maxLines:1,overflow:"ellipsis"})})]})})})}}function vn3(A,Q){return A.reduce(($,B)=>{return B.type==="item"?Math.max($,E4(be4(B),Q)):$},0)}function be4(A){return A.shortcutLabel??A.shortcut?.toString().toLowerCase()??""}var kn3=36,Sn3=24,fn3=72;class he4 extends u0{child;onContext;constructor(A,Q){super();this.child=A;this.onContext=Q}createState(){return new ge4}}class ge4 extends R0{build(A){return this.widget.onContext(A),this.widget.child}}function me4(A){return A.replace(/ ago$/,"")}function HK0(A){return A.reduce((Q,$)=>Math.max(Q,E4(me4($.description.timeAgo))),0)}function de4(A){return Math.max(Sn3,Math.min(A,fn3))}class P51 extends V4{}class _51 extends V4{}class T51{options;visibility;width=kn3;constructor(A){this.options=A;this.visibility=new Ee(A.state)}isVisible(){return this.visibility.isEnabled()}buildBody(A){return new s0({crossAxisAlignment:"stretch",children:[this.buildSlot(),new R1({child:A})]})}buildSlot(){if(!this.options.isAvailable()||this.visibility.isDisabled())return new X0({width:0});return new X0({width:this.width,child:new k4({debugLabel:"ThreadListSidebar",child:new pe4({activeThreadID:this.options.getActiveThreadID(),currentWorkspaceURI:A4(n0.file(this.options.getWorkspaceRoot())),width:this.width,loadThreads:this.options.loadThreads,onSelectThread:this.options.onSelectThread,onDismiss:this.close,onResizeWidth:this.resize})})})}commands(){if(!this.options.isAvailable())return[];return[{noun:"thread",verb:"toggle sidebar",description:"Show or hide the thread sidebar",shortcut:G1.alt("s"),status:{type:"enabled"},run:(A,Q,$)=>{$(),this.toggle()}}]}shortcutEntries(){return this.options.isAvailable()?[[G1.alt("s"),new BV0]]:[]}actionEntries(){if(!this.options.isAvailable())return[];return[[BV0,new T1(()=>this.toggle())]]}toggle=()=>{if(!this.options.isAvailable())return"ignored";if(this.visibility.isDisabled()&&this.options.isBlocked())return"ignored";return this.visibility.toggle(),"handled"};close=()=>{this.visibility.disable()};resize=(A)=>{let Q=de4(A);if(Q===this.width)return;this.options.state.setState(()=>{this.width=Q})}}class pe4 extends u0{props;constructor(A){super();this.props=A}createState(){return new ce4}}class ce4 extends R0{threads=[];isLoading=!0;isSwitchingThread=!1;hasError=!1;filterByWorkspace=!0;timeColWidth=0;contextMenu=null;pendingThreadMutations=new Map;resizeSession=null;isResizeHandleHovered=!1;pickerController=new Le;threadItemContexts=new Map;shortcuts=new Map([[G1.alt("w"),new P51],[G1.ctrl("."),new _51]]);actions=new Map([[P51,new T1(()=>{return this.setState(()=>{this.filterByWorkspace=!this.filterByWorkspace,this.contextMenu=null}),"handled"})],[_51,new T1(()=>this.openContextMenu())]]);get isBusy(){return this.isLoading||this.isSwitchingThread}get isResizeActive(){return this.resizeSession!==null||this.isResizeHandleHovered}didUpdateWidget(A){if(this.contextMenu&&(A.props.width!==this.widget.props.width||A.props.currentWorkspaceURI!==this.widget.props.currentWorkspaceURI))this.contextMenu=null}initState(){super.initState(),this.loadThreadSummaries()}async loadThreadSummaries(){try{let A=await this.widget.props.loadThreads(),Q=q31(A);if(!this.mounted)return;this.setState(()=>{this.pickerController.selectedItem=Q.find(($)=>$.id===this.widget.props.activeThreadID)??null,this.threads=Q,this.timeColWidth=HK0(Q),this.isLoading=!1,this.hasError=!1})}catch(A){if(u.error("Failed to load threads for Neo sidebar",{error:A}),!this.mounted)return;this.setState(()=>{this.isLoading=!1,this.hasError=!0})}}handleSelectThread=async(A)=>{if(this.isSwitchingThread)return;this.setState(()=>{this.isSwitchingThread=!0});try{await this.widget.props.onSelectThread(A),this.widget.props.onDismiss()}catch(Q){u.error("Failed to switch thread from Neo sidebar",{error:Q,threadID:A})}finally{if(this.mounted)this.setState(()=>{this.isSwitchingThread=!1})}};getOptimisticThreads(){return this.threads.flatMap((A)=>{if(this.pendingThreadMutations.get(A.id)?.kind==="archive")return[];return[A]})}getThreadsForDisplay(){let A=this.getOptimisticThreads();return this.filterByWorkspace?A.filter((Q)=>!Q.workspaceURI||Q.workspaceURI===this.widget.props.currentWorkspaceURI):A}buildContextMenuEntries(){return[{type:"item",value:"archive",label:"Archive Thread",shortcut:G1.key("a"),shortcutLabel:"a"},{type:"separator"},{type:"item",value:"copy-id",label:"Copy ID",shortcut:G1.ctrl("c"),shortcutLabel:"ctrl+c"},{type:"item",value:"copy-url",label:"Copy URL",shortcut:new G1("c",{shift:!0,ctrl:!0}),shortcutLabel:"shift+ctrl+c"}]}openContextMenu(){let A=this.pickerController.selectedItem;if(!A||this.isBusy||this.hasError)return"ignored";let Q=this.buildContextMenuEntries(),$=R51(Q),B=this.getContextMenuWidth(),D=this.getContextMenuPosition(A.id,$,B);return this.setState(()=>{this.contextMenu={threadID:A.id,left:D.left,top:D.top,width:B,height:$}}),"handled"}getContextMenuWidth(){let A=Math.max(24,this.widget.props.width-3);return Math.max(1,Math.min(A,this.widget.props.width-2))}getContextMenuPosition(A,Q,$){let B=Math.max(0,Math.min(2,this.widget.props.width-$)),D=1,J=this.threadItemContexts.get(A)?.findRenderObject(),E=this.context.findRenderObject();if(!(J instanceof i1)||!(E instanceof i1))return{left:B,top:1};let F=J.localToGlobal({x:0,y:0}),Y=E.localToGlobal({x:0,y:0}),Z=F.y-Y.y,U=Z+J.size.height,X=g1.sizeOf(this.context).height,G=Math.max(1,Math.min(E.size.height,X-Y.y)),z=G-U>=Q||Z<G/2?U:Z-Q,W=Math.max(0,G-Q);return{left:B,top:Math.max(0,Math.min(z,W))}}closeContextMenu=()=>{if(!this.contextMenu)return;this.setState(()=>{this.contextMenu=null})};handleContextMenuAccept=(A)=>{let Q=this.contextMenu?.threadID;if(!Q)return;if(this.closeContextMenu(),A==="archive"){this.archiveContextMenuThread(Q);return}if(A==="copy-id"){b4.maybeInvoke(this.context,new H8(Q,"Thread ID copied to clipboard","Failed to copy thread ID"));return}b4.maybeInvoke(this.context,new H8(this.getThreadURL(Q),"Thread URL copied to clipboard","Failed to copy thread URL"))};beginOptimisticArchive(A){if(this.pendingThreadMutations.has(A))return!1;if(!this.threads.some(($)=>$.id===A))return!1;let Q={kind:"archive",fallbackSelectedThreadID:null};return this.setState(()=>{this.pendingThreadMutations.set(A,Q),this.timeColWidth=HK0(this.getOptimisticThreads())}),a6.instance.addPostFrameCallback(()=>{if(!this.mounted)return;let $=this.pendingThreadMutations.get(A);if($?.kind!=="archive")return;$.fallbackSelectedThreadID=this.pickerController.selectedItem?.id??null}),!0}commitOptimisticArchive(A){if(this.pendingThreadMutations.get(A)?.kind!=="archive")return;this.pendingThreadMutations.delete(A),this.threads=this.threads.filter(($)=>$.id!==A),this.timeColWidth=HK0(this.getOptimisticThreads())}rollbackOptimisticArchive(A){let Q=this.pendingThreadMutations.get(A);if(Q?.kind!=="archive")return;let $=this.threads.find((B)=>B.id===A);if(!$){this.pendingThreadMutations.delete(A);return}this.setState(()=>{this.pendingThreadMutations.delete(A),this.timeColWidth=HK0(this.getOptimisticThreads());let B=this.pickerController.selectedItem?.id??null;if(B===null||B===Q.fallbackSelectedThreadID)this.pickerController.selectedItem=$})}async archiveContextMenuThread(A){let Q=M3.maybeOf(this.context),{configService:$}=W5.of(this.context);if(!this.beginOptimisticArchive(A))return;try{let B=await FG0({configService:$},A);if(!this.mounted)return;if(B){this.rollbackOptimisticArchive(A),Q?.show(B.message,"error");return}this.commitOptimisticArchive(A)}catch(B){if(u.error("Failed to archive thread from Neo sidebar context menu",{error:B,threadID:A}),!this.mounted)return;this.rollbackOptimisticArchive(A),Q?.show("Failed to archive thread","error")}}getThreadURL(A){return h$(new URL(W5.of(this.context).ampURL),A).toString()}buildContextMenuOverlay(){let A=this.contextMenu;if(!A||!this.getThreadsForDisplay().some((Q)=>Q.id===A.threadID))return null;return new r4({left:A.left,top:A.top,width:A.width,height:A.height,child:new k4({debugLabel:"ThreadListSidebarContextMenu",onFocusChange:(Q)=>{if(!Q)this.closeContextMenu()},child:new u51({entries:this.buildContextMenuEntries(),width:A.width,onAccept:this.handleContextMenuAccept,onDismiss:this.closeContextMenu})})})}buildContextMenuBackdrop(){return new r4({left:0,top:0,right:0,bottom:0,child:new O1({onClick:()=>this.closeContextMenu(),child:X0.expand()})})}buildThreadItem(A,Q,$,B){let D=O0.of(B),{app:J,colors:E}=D,F=!Q,Y=Q?J.selectionForeground:E.foreground,Z=Q?J.selectionForeground:E.mutedForeground,X=A.id===this.widget.props.activeThreadID?new d({text:new w("*",new T({color:Q?J.selectionForeground:E.success,dim:F}))}):void 0,G=me4(A.description.timeAgo);return new he4(new b0({padding:K0.symmetric(1,0),child:new s0({children:[new X0({width:2,child:X}),new R1({child:new d({text:new w(A.title,new T({color:Y,dim:F})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),new X0({width:$,child:s0.end([new d({text:new w(G,new T({color:Z,dim:F}))})])})]})}),(V)=>{this.threadItemContexts.set(A.id,V)})}handleResizeHandlePress=(A)=>{if(A.button!=="left")return;this.setState(()=>{this.resizeSession={baseWidthColumns:this.widget.props.width,startColumn:Math.floor(A.position.x)}})};handleResizeHandleDrag=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;let Q=Math.floor(A.position.x)-this.resizeSession.startColumn,$=de4(this.resizeSession.baseWidthColumns+Q);if($!==this.widget.props.width)this.widget.props.onResizeWidth($)};handleResizeHandleRelease=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;this.setState(()=>{this.resizeSession=null})};handleResizeHandleEnter=()=>{if(this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!0})};handleResizeHandleExit=()=>{if(!this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!1})};buildResizeHandle(){return new r4({top:0,right:0,bottom:0,width:1,child:new O1({cursor:YA.EW_RESIZE,onClick:this.handleResizeHandlePress,onDrag:this.handleResizeHandleDrag,onRelease:this.handleResizeHandleRelease,onEnter:this.handleResizeHandleEnter,onExit:this.handleResizeHandleExit,child:new X0({width:1})})})}build(A){let Q=O0.of(A),$=this.getThreadsForDisplay(),B=this.hasError?[]:$;this.threadItemContexts.clear();let D=this.isSwitchingThread?"Switching thread...":"Loading threads...",J=this.hasError?"Failed to load threads":"No threads match your filter",E=this.isResizeActive?2:1,F=new c1(void 0,new l1(Q.colors.border,E),void 0,void 0),Y=this.buildContextMenuOverlay(),Z=[new b0({decoration:new R4(Q.colors.background,F),child:new b4({actions:this.actions,child:new kA({shortcuts:this.shortcuts,debugLabel:"ThreadListSidebarFilter",child:new cA({items:B,getLabel:(U)=>`${U.title} ${U.id}`,controller:this.pickerController,onAccept:(U)=>void this.handleSelectThread(U.id),onDismiss:this.widget.props.onDismiss,renderItem:(U,X,G,V)=>this.buildThreadItem(U,X,this.timeColWidth,V),enabled:!this.isBusy,isLoading:this.isBusy,hidePromptWhenLoading:!0,loadingText:D,emptyStateText:J,maxRenderItems:200,showBorder:!1})})})}),this.buildResizeHandle()];if(Y)Z.push(this.buildContextMenuBackdrop()),Z.push(Y);return new b0({width:this.widget.props.width,child:new i4({fit:"expand",children:Z})})}}class v51 extends u0{listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;updateService;initialThreadIDs;showNeoWelcome;neoWelcomeVariant;onNeoWelcomeDismissed;notificationService;mcpTrustHandler;onThreadArchived;onActiveThreadChange;onRelaunchRequested;onFirstFrame;initialUserInput;getDefaultNewThreadVisibility;openThreadPickerOnStart;workspaceSettingsFilePath;neoContext;constructor(A){super();this.listSkillsForThread=A.listSkillsForThread,this.clientPool=A.clientPool,this.completionBuilder=A.completionBuilder,this.history=A.history,this.ideManager=A.ideManager,this.configService=A.configService,this.updateService=A.updateService,this.initialThreadIDs=A.initialThreadIDs??[],this.showNeoWelcome=A.showNeoWelcome??!1,this.neoWelcomeVariant=A.neoWelcomeVariant??"intro",this.onNeoWelcomeDismissed=A.onNeoWelcomeDismissed,this.notificationService=A.notificationService,this.mcpTrustHandler=A.mcpTrustHandler,this.onThreadArchived=A.onThreadArchived,this.onActiveThreadChange=A.onActiveThreadChange,this.onRelaunchRequested=A.onRelaunchRequested,this.onFirstFrame=A.onFirstFrame,this.initialUserInput=A.initialUserInput,this.getDefaultNewThreadVisibility=A.getDefaultNewThreadVisibility,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.workspaceSettingsFilePath=A.workspaceSettingsFilePath,this.neoContext=A.neoContext}createState(){return new ie4}}class ie4 extends R0{editorController=new k2;commandPalette=new Ee(this);commandRegistry=new EA1;toastController=new C11;relaunchNotificationController=new s61;exitHintTimer=new Je(this,1000);ideStatus=new z8(this,{});threadNavigationHistory=new QA1;draftThreadSettings={};draftThreadSettingsSeed={};hasDraftThreadSettingsSeed=!1;draftThreadSettingsInitPromise=null;activeThreadContext=null;activeThreadIDSubscription=null;activePluginMessageSubscription=null;activePluginUIRequestsSubscription=null;connectionErrorsSubscription=null;configSubscription=null;connectingToThreadID=null;executorAlreadyConnectedDialog=null;switchThreadPickerVisible=!1;neoWelcomeVisible=!1;endCreditsVisible=!1;neoInvadersHighScore=0;debugOverlayVisible=!1;focusDebugVisible=!1;unregisterCommands=null;emptyThreadTerminalTitleController=new q00;pluginIntegration=null;mcpTrustIntegration=null;updateRelaunchIntegration=null;noticesPollingTimeout=null;notices;loadThreads=async()=>{return this.widget.neoContext.listThreads()};analyzeContextForThread=async(A,Q)=>{return Fd4({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService,threadID:A,signal:Q})};onSwitchThread=(A)=>{return this.connectToExistingThread(A,{recordNavigation:!0,rethrowError:!0})};threadListSidebar=new T51({state:this,isAvailable:()=>this.widget.neoContext.isInternalUser,isBlocked:()=>this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal(),getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,getWorkspaceRoot:()=>this.widget.neoContext.workspaceRoot,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread});sendFeedbackReport=async(A)=>WV0({configService:this.widget.configService,settingsFilePath:this.widget.neoContext.settingsFilePath},A);archiveThread=async(A)=>{let Q=await FG0({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let $=await zl4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};removeThreadLabel=async(A,Q)=>{let $=await Wl4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};initState(){if(ZB.getInstance().interceptConsole(),this.neoInvadersHighScore=this.widget.neoContext.neoInvadersHighScore??0,this.notices=new y61(this.widget.configService,($)=>this.setState($)),a6.instance.addPostFrameCallback(()=>{setTimeout(()=>this.widget.onFirstFrame?.(),0),this.noticesPollingTimeout=setTimeout(()=>{this.noticesPollingTimeout=null,this.notices.startPolling()},500)},"Neo notices polling"),this.widget.showNeoWelcome)this.neoWelcomeVisible=!0;if(this.connectionErrorsSubscription=this.widget.clientPool.connectionErrors$.subscribe(({threadID:$,error:B})=>{if(u.error("Neo failed to connect to thread",{threadID:$,error:B}),!$)this.toastController.show(`Connection failed: ${B.message}`,"error",4000)}),this.configSubscription=this.widget.configService.config.subscribe(($)=>{this.applyDraftThreadSettingsSeed(this.applySessionDefaultsToThreadSettings(C90($.settings)))}),this.updateRelaunchIntegration=new e61({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested,relaunchNotificationController:this.relaunchNotificationController,updateService:this.widget.updateService}),this.updateRelaunchIntegration.init(),this.ideStatus.subscribe(this.widget.ideManager.status),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput,Q=this.widget.initialThreadIDs[0];if(Q){let $={};if(A)$.initialUserInput=A;this.connectToInitialThreads(Q,$)}else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.pluginIntegration=new r61({state:this,commandPalette:this.commandPalette,commandRegistry:this.commandRegistry,toastController:this.toastController,neoContext:this.widget.neoContext,getActiveThreadID:this.getActiveThreadID,appendToThread:this.appendPluginMessagesToThread,onBlockingConfirmDialogChange:this.syncEmptyThreadPluginConfirmationTitle}),this.pluginIntegration.init(),this.mcpTrustIntegration=new f61({state:this,mcpTrustHandler:this.widget.mcpTrustHandler,toastController:this.toastController,workspaceSettingsFilePath:this.widget.workspaceSettingsFilePath}),this.mcpTrustIntegration.init(),this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=z4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let A=this,Q=this.widget.neoContext.pluginService?wa4({pluginService:this.widget.neoContext.pluginService,workspaceRoot:this.widget.neoContext.workspaceRoot,logFilePath:this.widget.neoContext.logFilePath,toastController:this.toastController}):[],B=[Ta4({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["resume"],status:{type:"enabled"},sortBoost:100,run:(D,J,E)=>{D.pushWithDismiss((F)=>N31({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:F,onThreadSelected:E}))}},...this.threadListSidebar.commands(),{noun:"thread",verb:"switch to previous",description:"Switch to previous thread",keywords:["back"],get status(){return A.threadNavigationHistory.canNavigateBack()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to previous with no previous thread"}},run:(D,J,E)=>{A.navigateBack(),E()}},ye4({configService:this.widget.configService,getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??void 0,toastController:this.toastController}),{noun:"thread",verb:"switch to next",description:"Switch to next thread",keywords:["forward"],get status(){return A.threadNavigationHistory.canNavigateForward()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to next with no next thread"}},run:(D,J,E)=>{A.navigateForward(),E()}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",status:{type:"enabled"},run:(D,J,E)=>{D.push(new pA1({mcpServers:this.widget.neoContext.mcpServers,onDismiss:E}))}},{noun:"toolbox",verb:"list",description:"List all toolboxes and their tools",status:{type:"enabled"},run:(D)=>{D.pushWithDismiss((J)=>new H51({toolboxes:this.widget.neoContext.toolboxes,onDismiss:J}))}},{noun:"news",verb:"open",description:"Open Amp Chronicle in browser",keywords:["chronicle","blog","announcements"],status:{type:"enabled"},run:async(D,J,E)=>{try{await o6(J,"https://ampcode.com/chronicle")}finally{E()}}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config"],status:{type:"enabled"},run:()=>{V$(this.widget.neoContext.settingsFilePath).catch((D)=>{u.error("Failed to open settings file in editor",{error:D})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains"],status:{type:"enabled"},run:(D,J,E)=>{D.pushWithDismiss((F)=>new mA1({onCancel:F,onSelect:(Y)=>{this.handleIdeSelection(Y),E()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["manual","?"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new XA1({commands:R9.of(J).commands,onDismiss:E}))}},{noun:"amp",verb:"show welcome",description:"Show the welcome message again",status:{type:"enabled"},run:(D,J,E)=>{E(),A.showNeoWelcome()}},{noun:"amp",verb:"end credits",description:"Roll the full-screen Amp credits",status:{type:"enabled"},run:(D,J,E)=>{E(),A.showEndCredits()}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["v"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new C6({header:"Amp Version",maxWidth:72,onDismiss:E,child:new d({text:new w(SX0({version:"0.0.1779886645-g59fcb2",buildTimestamp:"2026-05-27T13:02:21.391Z",buildType:"release"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","bye"],shortcut:G1.ctrl("c"),status:{type:"enabled"},run:(D,J)=>{b4.maybeInvoke(J,new Mx)}},...Q,...Da4(this.widget.neoContext.logFilePath)].map((D)=>this.commandRegistry.register(D));return()=>{for(let D of B)D()}}build(A){let Q=this.buildHints(),$=this.ideStatus.getValue(),B=this.notices.current,D=new I51({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,sendFeedbackReport:this.sendFeedbackReport,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,hints:Q,ideStatus:$,statusItems:this.pluginIntegration?.getStatusItems()??[],pluginConfirmationBlocked:this.pluginIntegration?.hasBlockingConfirmDialog()??!1,notificationService:this.widget.notificationService,notice:this.activeThreadContext||this.neoWelcomeVisible?null:B,onDismissNotice:(U)=>this.notices.dismiss(U)}),J=g1.of(A),E=J.capabilities.animationSupport!=="disabled",Y=[new b0({constraints:w1.tight(J.size.width,J.size.height),child:this.threadListSidebar.buildBody(D)})];if(this.commandPalette.isEnabled())Y.push(new k4({debugLabel:"CommandPaletteOverlay",onFocusChange:this.closeCommandPaletteOnFocusLoss,child:new FA1({onDismiss:this.commandPalette.disable})}));if(this.switchThreadPickerVisible&&!this.neoWelcomeVisible)Y.push(N31({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.neoWelcomeVisible)Y.push(new k4({debugLabel:"NeoWelcomeDialogOverlay",child:new L51({onDismiss:this.dismissNeoWelcome,onQuit:()=>z4.instance.stop(),animationsEnabled:E,variant:this.widget.neoWelcomeVariant})}));let Z=this.executorAlreadyConnectedDialog;if(Z)Y.push(new k4({debugLabel:"NeoExecutorAlreadyConnectedDialogOverlay",child:new hA1({existingExecutorPid:Z.existingExecutorPid,onChoice:this.handleExecutorAlreadyConnectedChoice})}));if(Y.push(...this.mcpTrustIntegration?.buildDialogLayers()??[]),Y.push(...this.pluginIntegration?.buildDialogLayers()??[]),this.widget.neoContext.isInternalUser)Y.push(new VA1({top:this.focusDebugVisible?33:1,visible:this.debugOverlayVisible,pid:qK0.pid,activeThreadID:this.activeThreadContext?.client.getThreadId()??null,connectionInfo$:this.activeThreadContext?.observer.connectionInfo()??null}));if(this.focusDebugVisible)Y.push(new gA1);if(this.endCreditsVisible)Y.push(new kA1({onComplete:this.completeEndCredits,highScore:this.neoInvadersHighScore,onHighScoreChange:this.updateNeoInvadersHighScore}));return new W5({neoContext:this.widget.neoContext,child:new R9({commandRegistry:this.commandRegistry,child:new Ox({completionBuilder:this.widget.completionBuilder,child:new M3({controller:this.toastController,child:new b4({actions:this.buildActions(),child:new kA({debugLabel:"NeoAppShortcuts",shortcuts:this.buildShortcuts(),child:new v4({debugLabel:"AppShellFocus",child:new w11({controller:this.toastController,complexToastControllers:[this.relaunchNotificationController,...B&&this.activeThreadContext&&!this.neoWelcomeVisible?[this.notices]:[]],child:new GA1({configReloadEvents:this.widget.configService.configReloadEvents,toastController:this.toastController,child:new i4({children:Y})})})})})})})})})})}buildShortcuts(){let A=new Map([[G1.ctrl("c"),new tG0],[G1.ctrl("o"),new AV0],[G1.alt("i"),new $V0],[G1.alt("p"),new tN],[G1.ctrl("."),new JV0],[G1.ctrl("t"),new YV0],...this.threadListSidebar.shortcutEntries()]);if(qK0.env.NODE_ENV==="development"&&qK0.platform==="darwin")A.set(G1.meta("r"),new eG0);return A}buildActions(){let A=new T1(()=>{if(TD.hasAnyCopyableSelection())return TD.tryCopyAnyActiveSelection(),"handled";return this.onExitPressed(),"handled"}),Q=new T1(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),$=new T1(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),B=new T1(()=>{return this.startNewDraftThread(),"handled"}),D=new T1(()=>{return z4.instance.stop(),"handled"}),J=new T1(()=>{return G00({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),"handled"}),E=new T1((G)=>{if(!G.text)return"ignored";return z4.instance.tuiInstance.clipboard.writeText(G.text).then((V)=>{if(V.ok)this.toastController.show(G.successMessage,"success",2000);else this.toastController.show(`${G.failureMessage}: ${V.userFacingErrorMessage}`,"error",4000)}).catch((V)=>{u.error("Failed to copy Neo text to clipboard",{error:V}),this.toastController.show(G.failureMessage,"error",2000)}),"handled"}),F=new T1(()=>{return z4.instance.toggleFrameStatsOverlay(),"handled"}),Y=new T1(()=>this.notices.dismissCurrent()?"handled":"ignored"),Z=new T1(()=>{if(!this.widget.neoContext.isInternalUser)return"ignored";return this.setState(()=>{this.debugOverlayVisible=!this.debugOverlayVisible}),"handled"}),U=da4({getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,neoContext:this.widget.neoContext,toastController:this.toastController,startNewDraftThread:this.startNewDraftThread,sendFeedbackReport:this.sendFeedbackReport}),X=new T1(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[tG0,A],[B00,B],[Mx,D],[eG0,J],[H8,E],[F00,$],[AV0,Q],[$V0,Z],...this.threadListSidebar.actionEntries(),[JV0,Y],...U,[tN,F],[YV0,X]])}startNewDraftThread(A={}){let Q=this.activeThreadContext?.client.getThreadId();if(this.commandPalette.disable(),this.threadNavigationHistory.recordNavigation(Q),this.setState(()=>{if(this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.activePluginMessageSubscription?.unsubscribe(),this.activePluginMessageSubscription=null,this.activePluginUIRequestsSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription=null,this.pluginIntegration?.cancelOwnerUIRequests(),this.activeThreadContext=null,this.connectingToThreadID=null,A.hideDebugOverlay)this.debugOverlayVisible=!1}),this.widget.onActiveThreadChange?.(null),this.syncEmptyThreadPluginConfirmationTitle(),A.prompt!==void 0)this.editorController.text=A.prompt}syncEmptyThreadPluginConfirmationTitle=()=>{this.emptyThreadTerminalTitleController.setPluginConfirmationBlocked(this.activeThreadContext===null&&(this.pluginIntegration?.hasBlockingConfirmDialog()??!1))};closeCommandPaletteOnFocusLoss=(A)=>{if(A||!this.commandPalette.isEnabled())return;this.commandPalette.disable()};ensureDraftThreadSettingsInitialized(){if(this.hasDraftThreadSettingsSeed)return Promise.resolve();if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=this.applySessionDefaultsToThreadSettings(await gy(this.widget.configService));this.applyDraftThreadSettingsSeed(A)}catch(A){u.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}applySessionDefaultsToThreadSettings(A){let Q=this.widget.neoContext.sessionAgentMode,$=A,B=UB(Q),D=qX0(this.widget.neoContext,Q);if(B!==void 0&&D!==void 0)$={...$,[B]:D};return HX0($,{agentMode:Q,explicitEffort:this.widget.neoContext.explicitReasoningEffort,sessionState:this.widget.neoContext})}applyDraftThreadSettingsSeed(A){if(!this.mounted)return;if(!this.hasDraftThreadSettingsSeed){this.setState(()=>{this.hasDraftThreadSettingsSeed=!0,this.draftThreadSettings=le4(this.draftThreadSettings,{},A),this.draftThreadSettingsSeed={...A}});return}if(tE(this.draftThreadSettingsSeed,A))return;this.setState(()=>{this.draftThreadSettings=le4(this.draftThreadSettings,this.draftThreadSettingsSeed,A),this.draftThreadSettingsSeed={...A}})}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(WC);if(this.exitHintTimer.isActive())A.add(Hx);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),z4.instance.stop();else this.exitHintTimer.activate()};dismissNeoWelcome=()=>{if(!this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!1}),this.widget.onNeoWelcomeDismissed?.()};updateNeoInvadersHighScore=(A)=>{if(A<=this.neoInvadersHighScore)return;this.setState(()=>{this.neoInvadersHighScore=A}),qQ((Q)=>({...Q,neoInvadersHighScore:Math.max(Q.neoInvadersHighScore,A)})).catch((Q)=>{u.warn("Failed to save Neo Invaders high score",{error:Q instanceof Error?Q.message:String(Q)})})};showNeoWelcome=()=>{if(this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!0})};showEndCredits=()=>{if(this.endCreditsVisible)return;this.setState(()=>{this.endCreditsVisible=!0})};completeEndCredits=()=>{if(!this.endCreditsVisible)return;this.setState(()=>{this.endCreditsVisible=!1})};promptExecutorAlreadyConnected(A){return new Promise((Q)=>{this.setState(()=>{this.executorAlreadyConnectedDialog={existingExecutorPid:A.existingExecutorPid,resolve:($)=>{Q($==="watch"?"observe":"disconnect")}}})})}handleExecutorAlreadyConnectedChoice=(A)=>{if(this.resolveExecutorAlreadyConnectedDialog(A),A==="exit")z4.instance.stop()};resolveExecutorAlreadyConnectedDialog(A){let Q=this.executorAlreadyConnectedDialog;if(!Q)return;this.setState(()=>{this.executorAlreadyConnectedDialog=null}),Q.resolve(A)}closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q,$=null,B)=>{await this.ensureDraftThreadSettingsInitialized();let D=this.activeThreadContext?.client.getThreadId(),J=A.find(X90);if(J)this.widget.history.add(J.text,qK0.cwd()),this.widget.history.reset();let E=$?void 0:await this.widget.getDefaultNewThreadVisibility?.(),F=$??E??null,Y=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings,F??void 0);this.sendUserMessage(Y,A,Q,B),this.rememberSessionDefaultsForNewMessage(Q,this.draftThreadSettings),this.threadNavigationHistory.recordNavigation(D),this.setActiveClient(Y)};rememberSessionDefaultsForNewMessage(A,Q){this.widget.neoContext.sessionAgentMode=A;let $=Q["reasoning.effort"];if($!==void 0)this.widget.neoContext.lastReasoningEffortByMode={...this.widget.neoContext.lastReasoningEffortByMode??{},[A]:$};let B=UB(A),D=B?Q[B]:void 0;if(D!==void 0)this.widget.neoContext.lastSpeedByMode={...this.widget.neoContext.lastSpeedByMode??{},[A]:D};qQ((J)=>{let E={...J,agentMode:A};if($!==void 0)E={...E,lastReasoningEffortByMode:{...E.lastReasoningEffortByMode??{},[A]:$}};if(D!==void 0)E={...E,lastSpeedByMode:{...E.lastSpeedByMode??{},[A]:D}};return E}).catch((J)=>{u.warn("Failed to persist Neo session defaults for new message",{error:J instanceof Error?J.message:String(J)})})}sendUserMessage(A,Q,$,B){let D=FY0(this.ideStatus.getValue());if(B===void 0){A.client.sendUserMessage(Q,$,{userState:D});return}A.client.sendUserMessage(Q,$,{reasoningEffort:B,userState:D})}getActiveThreadID=()=>{return this.activeThreadContext?.client.getThreadId()??void 0};getRelaunchThreadIDs=()=>{let A=new Set,Q=this.getActiveThreadID();if(Q)A.add(Q);for(let $ of this.widget.clientPool.activeThreadIDs)A.add($);return[...A]};appendPluginMessagesToThread=async(A,Q)=>{let $=this.activeThreadContext;if(!$)throw Error("appendToThread is not available - no active thread");let B=$.client.getThreadId();if(Q&&B!==Q)throw Error("thread.append is only available for the active executor thread");for(let D of A)this.sendUserMessage($,[{type:"text",text:D.content}])};async connectToExistingThread(A,Q={}){let $=this.activeThreadContext?.client.getThreadId();this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:(D)=>this.promptExecutorAlreadyConnected(D)});if(this.setActiveClient(B),Q.recordNavigation&&$!==A)this.threadNavigationHistory.recordNavigation($);if(Q.initialUserInput)this.sendUserMessage(B,[{type:"text",text:Q.initialUserInput}])}catch(B){if(u.error("Failed to load thread",{error:B,threadID:A}),this.toastController.show(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`,"error",4000),Q.rethrowError)throw B}finally{this.setState(()=>{this.connectingToThreadID=null})}}async connectToInitialThreads(A,Q={}){await this.connectToExistingThread(A,Q);let $=this.widget.initialThreadIDs.filter((B)=>B!==A);await Promise.all($.map((B)=>this.resumeBackgroundThread(B)))}async resumeBackgroundThread(A){try{await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:async()=>"observe"})}catch(Q){u.error("Failed to resume background thread",{error:Q,threadID:A}),this.toastController.show(`Failed to resume ${A}: ${Q instanceof Error?Q.message:String(Q)}`,"error",4000)}}async navigateBack(){let A=this.threadNavigationHistory.startBackNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateForward(){let A=this.threadNavigationHistory.startForwardNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateToThread(A){try{await this.connectToExistingThread(A.targetThreadID,{rethrowError:!0})}catch{A.rollback()}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q}}),this.syncEmptyThreadPluginConfirmationTitle(),this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=Q.threadID().subscribe(($)=>{this.widget.onActiveThreadChange?.($)}),this.activePluginMessageSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription?.unsubscribe(),this.pluginIntegration?.cancelOwnerUIRequests(),this.activePluginMessageSubscription=Q.pluginMessages().subscribe(($)=>{this.pluginIntegration?.handlePluginMessage($,(B)=>{A.sendPluginMessage(B)})}),this.activePluginUIRequestsSubscription=Q.pluginUIRequests().subscribe(($)=>{this.pluginIntegration?.handlePluginMessage({type:"plugin_message",message:{type:"event",event:"plugin.ui.snapshot",data:{requests:[...$]}}},(B)=>{A.sendPluginMessage(B)})})}handleIdeSelection=async(A)=>{try{await this.widget.ideManager.connect(A)}catch(Q){u.error("Failed to connect to IDE",{error:Q});let $=Q instanceof Error?Q.message:String(Q);this.toastController.show(`IDE connection failed: ${$}`,"error",4000)}};dispose(){if(this.unregisterCommands?.(),this.unregisterCommands=null,this.activePluginMessageSubscription?.unsubscribe(),this.activePluginMessageSubscription=null,this.activePluginUIRequestsSubscription?.unsubscribe(),this.activePluginUIRequestsSubscription=null,this.pluginIntegration?.dispose(),this.pluginIntegration=null,this.emptyThreadTerminalTitleController.dispose(),this.mcpTrustIntegration?.dispose(),this.mcpTrustIntegration=null,this.updateRelaunchIntegration?.dispose(),this.updateRelaunchIntegration=null,this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.noticesPollingTimeout)clearTimeout(this.noticesPollingTimeout),this.noticesPollingTimeout=null;this.connectionErrorsSubscription?.unsubscribe(),this.configSubscription?.unsubscribe(),this.configSubscription=null,this.notices.dispose(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.executorAlreadyConnectedDialog!==null||this.neoWelcomeVisible||(this.mcpTrustIntegration?.hasBlockingDialog()??!1)||this.endCreditsVisible||(this.pluginIntegration?.hasBlockingDialog()??!1)}}function le4(A,Q,$){let B={...A};for(let D of yn3(Q,$)){if(!tE(A[D],Q[D]))continue;let J=$[D];if(J===void 0)delete B[D];else B[D]=J}return B}function yn3(...A){return Array.from(new Set(A.flatMap((Q)=>Object.keys(Q))))}a4();function ne4(A,Q,$,B){let D=Dv(A),J="\x1B[0m",E="\x1B[34m",F="\x1B[90m",Y="\x1B[2m",Z=[];if(A.archived)Z.push("\x1B[90m\x1B[2mArchived\x1B[0m");Z.push(`${D}`),Z.push(`\x1B[34m${Q}\x1B[0m`),Z.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let U=14,X=7,G=new QE(U,X),V=new A7(42),K=new iN(U,X,U,X,U,X,0,A.agentMode??"smart","intensity","classic","braille",void 0,void 0,z0.default(),V);K.layout(w1.tight(U,X)),K.paint(G,0,0);let z=G.getBuffer().getCells(),W=0;for(let R=0;R<X;R++)if(z[R].some((k)=>k.char!==" ")){W=R;break}let I=X-1;for(let R=X-1;R>=0;R--)if(z[R].some((k)=>k.char!==" ")){I=R;break}function H(R,k){if(!R)return"";if(R.type==="rgb"){let{r:_,g:f,b:g}=R.value;if($.getColorDepth()>=24)return`\x1B[${k?38:48};2;${_};${f};${g}m`;let b=FR(_,f,g);return`\x1B[${k?38:48};5;${b}m`}return""}let q=[];if(I>=W)for(let R=W;R<=I;R++){let k="";for(let _=0;_<U;_++){let f=z[R][_],g=f.char,b=H(f.style.fg,!0);k+=b+g+"\x1B[0m"}q.push(k)}let N=q.length,C=Math.max(N,Z.length),M=Math.floor((C-N)/2),O=Math.floor((C-Z.length)/2);for(let R=0;R<C;R++){let k=" ".repeat(U);if(R>=M&&R<M+N)k=q[R-M];let _=" ",f="";if(R>=O&&R<O+Z.length)f=Z[R-O];$.write(k+_+f+`
5317
5317
  `)}if(B)$.write(`
5318
5318
  \x1B[90m${B}\x1B[0m
5319
5319
  `)}c0();c0();import{exec as tR}from"node:child_process";function NK0(A="idle"){try{if(A==="idle"){if(process.platform==="darwin")tR("afplay /System/Library/Sounds/Submarine.aiff");else if(process.platform==="win32")tR("powershell [console]::beep(800,200)");else if(process.platform==="linux")tR("paplay /usr/share/sounds/freedesktop/stereo/message.oga || beep")}else if(A==="idle-review"){if(process.platform==="darwin")tR("afplay /System/Library/Sounds/Glass.aiff")}else if(A==="requires-user-input"){if(process.platform==="darwin")tR("afplay /System/Library/Sounds/Ping.aiff");else if(process.platform==="win32")tR("powershell [console]::beep(1000,300)");else if(process.platform==="linux")tR("paplay /usr/share/sounds/freedesktop/stereo/dialog-information.oga || beep -f 1000 -l 100")}}catch(Q){u.error(`Failed to play notification sound (${A}):`,Q)}}st();_X0();var xn3=2000,bn3="Agent is ready",hn3="Waiting for approval";function ae4(A){let Q=!0,$=!0,B=A.configService.config.subscribe((I)=>{Q=I.settings["notifications.enabled"]??!0,$=I.settings["notifications.system.enabled"]!==!1}),D=0,J=()=>{let I=V?.prepareTerminalTitleForNotification();if(I!==void 0)process.stdout.write(aU0(I))},E=(I)=>{if(!Q)return;let H=Date.now();if(H-D<xn3)return;if(D=H,sz())return;if(RU0())J(),setTimeout(uU0,vt);else NK0(I)},F=()=>{E("idle"),K(bn3)},Y=()=>{E("requires-user-input"),K(hn3)},Z=(I)=>I?.attempt===void 0||I.attempt===0,U=null,X=null,G=null,V,K=(I)=>{if(!Q||!$)return;if(sz()&&!tt()&&!Ty())return;J(),setTimeout(()=>{process.stdout.write(kt(I))},vt)},z=()=>{U?.unsubscribe(),X?.unsubscribe(),U=null,X=null,G=null,V=void 0};return{attach:(I,H,q)=>{if(z(),V=q,H)X=H.subscribe({next:(N)=>{if(N===null)return;if(!Z(N))return;F()},error:(N)=>{u.debug("Neo notification active error stream errored",{error:N})}});U=I.subscribe({next:(N)=>{try{let C=G!==null&&J$(G),M=G==="awaiting_approval",O=C||M;if(N==="awaiting_approval"&&!M)Y();else if(N==="idle"&&O)F()}catch(C){u.debug("Neo notification handling failed",{error:C})}finally{G=N}},error:(N)=>{u.debug("Neo notification agent state stream errored",{error:N})}})},detach:z,unsubscribe(){z(),B.unsubscribe()}}}function gn3({initialUserInput:A,showNeoWelcome:Q,hideNeoWelcome:$,neoWelcomeVariant:B,neoWelcomeDismissed:D}){if($)return{show:!1,markDismissedOnDismiss:!1};if(B==="npm-migration")return{show:!0,markDismissedOnDismiss:!1};if(Q)return{show:!0,markDismissedOnDismiss:!0};let J=!A&&!D;return{show:J,markDismissedOnDismiss:J}}async function mn3(A){await qQ((Q)=>py(Q,A,"interactive"))}async function oe4(A,Q={}){let{initialThreadIDs:$=[],initialUserInput:B,getDefaultNewThreadVisibility:D,openThreadPickerOnStart:J=!1,observerOnly:E=!1,initialAgentMode:F,initialReasoningEffort:Y,onFirstFrame:Z,showNeoWelcome:U=!1,hideNeoWelcome:X=!1,neoWelcomeVariant:G="intro"}=Q,V=G==="npm-migration";if($.length>1)u.info("Resuming multiple initial threads",{threadIDs:$});let K=async(_)=>{let f=await A.getThreadFromServer(_);if(!f)return null;return WU0(f)},z=async(_)=>{let f=await A.getThreadFromServer(_);if(!f)throw Error(`Thread ${_} not found`);let g=await s9(_,A.configService,A.apiKey,{usesThreadActors:!0}),b=fG({endpoint:A.rivetEndpoint,poolName:g.poolName}),v={wsToken:g.wsToken,transport:"json-rpc"},c=await b.threadActor.getOrCreate([_],{params:v,createWithInput:{threadId:g.threadId,threadVersion:g.threadVersion,ownerUserId:g.ownerUserId,...g.agentMode?{agentMode:g.agentMode}:{}}}).fetch("/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({thread:uy4(f)}),skipReadyWait:!0});if(!c.ok&&c.status!==409)throw Error(`Thread import failed (${c.status}): ${await c.text()}`);try{await Dx4(_,A.configService,A.apiKey,{executorType:"local-client"})}catch(p){u.warn("failed to mark thread as imported on server",{threadID:_,error:p instanceof Error?p.message:String(p)})}},W=new n01(A.rivetEndpoint,A.apiKey,A.configService,{clientID:ON.parse(`neo-${crypto.randomUUID()}`),toolService:A.toolService,skillService:A.skillService,requestPluginToolCall:(_)=>A.pluginService.event.toolCall(_),requestPluginToolResult:(_)=>A.pluginService.event.toolResult(_),pluginService:A.pluginService,pluginPlatform:A.pluginPlatform,invokeTool:async(_,f)=>{let g=typeof f.args==="object"&&f.args!==null?f.args:{},b=await xN({toolName:f.toolName,configService:A.configService,toolService:A.toolService,mcpService:A.mcpService,skillService:A.skillService,toolUseID:f.toolCallId,threadId:_});return A.toolService.invokeTool(f.toolName,{args:g},b)},persistLastThreadID:mn3,readFileSystemDirectory:A.readFileSystemDirectory},K,z),I=await rz(),H=gn3({initialUserInput:B,showNeoWelcome:U,hideNeoWelcome:X,neoWelcomeVariant:G,neoWelcomeDismissed:I.neoWelcomeDismissed}),q={ampURL:A.ampURL,configService:A.configService,getThreadMarkdown:async(_)=>{let f=await A.getThreadFromServer(_);return f?pX(f):null},isInternalUser:A.isInternalUser,listThreads:A.listThreads,logFilePath:Ms,mcpServers:A.mcpService.servers,pluginPlatform:A.pluginPlatform,pluginService:A.pluginService,toolboxes:A.toolboxes,observerOnly:V?!1:E,neoInvadersHighScore:I.neoInvadersHighScore,sessionAgentMode:F??I.agentMode,explicitReasoningEffort:Y,lastReasoningEffortByMode:I.lastReasoningEffortByMode,lastSpeedByMode:I.lastSpeedByMode,settingsFilePath:A.settingsFilePath,splashOrbVisualStyle:Q.splashOrbVisualStyle??"neo",workspaceRoot:A.workspaceRoot},N=(_,f)=>{return zm4({ampURL:A.ampURL,configService:A.configService,threadID:_,signal:f})},C=new z11,M=ae4({configService:A.configService}),O=await A.configService.getLatest();z4.instance.tuiInstance.setOptions({queryOptions:{animationDisabled:O.settings["terminal.animation"]===!1}});let R=new Set,k=new t61;try{await et(new v51({clientPool:W,listSkillsForThread:N,completionBuilder:A.completionBuilder,history:new Ut,ideManager:C,configService:A.configService,updateService:A.updateService,initialThreadIDs:V?[]:$,notificationService:M,mcpTrustHandler:A.mcpTrustHandler,initialUserInput:V?void 0:B,getDefaultNewThreadVisibility:D,openThreadPickerOnStart:V?!1:J,workspaceSettingsFilePath:A.workspaceSettingsFilePath,neoContext:q,showNeoWelcome:H.show,neoWelcomeVariant:G,onActiveThreadChange:A.setActiveThreadID,onRelaunchRequested:k.request,onNeoWelcomeDismissed:H.markDismissedOnDismiss?()=>{qQ(Hm4).catch((f)=>{u.warn("Failed to mark Neo welcome as dismissed",{error:f})})}:void 0,onThreadArchived:(f)=>{R.add(f)},onFirstFrame:Z}));let _=W.lastActiveObservingClient;if(_&&k.shouldShowExitSummary){let{client:f,observer:g}=_,b=f.getThreadId();if(b){let v={id:b,title:g.title().getValue(),agentMode:g.agentMode,archived:R.has(b)},x=`${A.ampURL.replace(/\/$/,"")}/threads/${b}`;ne4(v,x,process.stdout)}}}finally{process.stdout.write(dN("")),M.unsubscribe(),W.dispose(),await A.dispose?.()}process.exit(k.relaunchIfRequested(A.workspaceRoot)??0)}G5();function lx(A){let Q=[],$={meta:{visibility:"private",sharedGroupIDs:[]}};if(A.workspace?.disablePrivateThreads)$.disabledReason="Disabled by workspace policy";if(Q.push($),A.workspace?.groups&&A.workspace.groups.length>0){let E={meta:{visibility:"private",shareWithAllCreatorGroups:!0}};if(A.creatorIsViewer===!1)E.disabledReason="Can only be set by thread creator";Q.push(E)}if(A.workspace)Q.push({meta:{visibility:"thread_workspace_shared"}});let B=A.workspace?.disablePublicSharing?"Disabled by workspace policy":void 0,D={meta:{visibility:"public_unlisted"}},J={meta:{visibility:"public_discoverable"}};if(B)D.disabledReason=B,J.disabledReason=B;return Q.push(D,J),Q}function re4(A){if(A.visibility==="thread_group_shared")return"sharedGroupIDs"in A&&A.sharedGroupIDs.length>0;if(A.visibility!=="private")return!0;if("shareWithAllCreatorGroups"in A&&A.shareWithAllCreatorGroups)return!0;return"sharedGroupIDs"in A&&A.sharedGroupIDs.length>0}function eR(A,Q={}){switch(A.visibility){case"thread_workspace_shared":return{text:"Workspace",description:"Visible to all members of the workspace"};case"public_discoverable":return{text:"Public",description:"Visible on public profile & publicly searchable"};case"public_unlisted":return{text:"Unlisted",description:"Visible to anyone on the Internet who has the link"};case"thread_group_shared":case"private":{let $=A.visibility==="private"&&"shareWithAllCreatorGroups"in A&&A.shareWithAllCreatorGroups,B=$?Q.workspace?.groups.map((J)=>J.id)??[]:("sharedGroupIDs"in A)?A.sharedGroupIDs:[],D=B.reduce((J,E)=>{let F=Q.workspace?.groups.find((Y)=>Y.id===E)?.name;if(F)J.push(`'${F}'`);return J},[]);if(D.length>0)return{text:"Group",description:`Shared with ${U4(D.length,"group")} ${D.join(", ")} and workspace admins`};if($)return{text:"Group",description:"Shared with creator groups and workspace admins"};if(B.length>0)return{text:"Group",description:`Shared with ${U4(B.length,"group")} and workspace admins`};return{text:"Private",description:Q.workspace?"Only visible to you and workspace admins":"Only you can see this thread"}}}}function CK0(A){if(A.visibility==="private")return"shareWithAllCreatorGroups"in A?"group":"private";if(A.visibility==="thread_workspace_shared")return"workspace";if(A.visibility==="public_unlisted")return"unlisted";return"public"}function ix(A,Q=null){let $=A!==null&&typeof A==="object"&&"visibility"in A?A.visibility:void 0;if(!$||typeof $!=="string")return;let D=lx({workspace:Q?.team??void 0}).filter((J)=>!J.disabledReason).map((J)=>CK0(J.meta));if(D.includes($))return dn3($);if($==="group"&&!D.includes("group")){if(Q?.team?.groups!==void 0)return Error(`Group visibility is not available. You are not a member of any group in this workspace.
@@ -7081,7 +7081,7 @@ ${D}`,Q);this.line=$,this.column=B,this.codeblock=D}}/*!
7081
7081
  `),J=[];for(let E=0;E<D.length;E++){let Z=D[E].replace(/\b(SELECT|FROM|WHERE|GROUP BY|ORDER BY|HAVING|LIMIT|JOIN|LEFT JOIN|RIGHT JOIN|INNER JOIN|ON|AND|OR|AS|IN|NOT|NULL|IS|BETWEEN|LIKE|EXISTS|UNION|DISTINCT|COUNT|SUM|AVG|MIN|MAX|DATE|TIMESTAMP_TRUNC|TIMESTAMP_SUB|CURRENT_TIMESTAMP|INTERVAL|CASE|WHEN|THEN|ELSE|END|WITH|INSERT|UPDATE|DELETE|SET|VALUES|INTO|CREATE|ALTER|DROP|TRUE|FALSE|ASC|DESC)\b/gi,"\x00$1\x01").split(/(\x00[^\x01]+\x01)/);for(let U of Z)if(U.startsWith("\x00")&&U.endsWith("\x01"))J.push(new w(U.slice(1,-1),new T({color:B.app.keybind,bold:!0})));else J.push(new w(U,new T({color:$.colorScheme.foreground})));if(E<D.length-1)J.push(new w(`
7082
7082
  `))}return new b0({decoration:{color:$.colorScheme.background,border:c1.all(new l1(B.app.keybind,1,"rounded"))},child:new y0({padding:K0.symmetric(0,1),child:new d({text:new w(void 0,void 0,J)})})})}}class d21 extends u5{chartData;highlightIndex;showAxes;colors;constructor({key:A,chartData:Q,highlightIndex:$=null,showAxes:B=!0,colors:D=xz0}){super(A?{key:A}:{});this.chartData=Q,this.highlightIndex=$,this.showAxes=B,this.colors=D}createRenderObject(){return new g21({chartData:this.chartData,highlightIndex:this.highlightIndex,showAxes:this.showAxes,colors:this.colors})}updateRenderObject(A){let Q=A;Q.chartData=this.chartData,Q.highlightIndex=this.highlightIndex,Q.showAxes=this.showAxes,Q.colors=this.colors,Q.markNeedsLayout()}}function P66(A,Q,$,B,D,J,E){if(J<=0)return null;switch(A){case"horizontal-bar":{let F=$;return F>=0&&F<J?F:null}case"bar":case"stacked-bar":{let F=E?r2:0,Y=B-F;if(Y<=0)return null;let Z=Q-F;if(Z<0||Z>=Y)return null;let U=Math.max(1,Math.floor(Y/J)),X=Math.floor(Z/U);return X>=0&&X<J?X:null}case"line":case"sparkline":case"stacked-area":{let F=E?r2:0,Y=B-F;if(Y<=0)return null;let Z=Math.max(0,Math.min(Y-1,Q-F));if(J===1)return 0;let U=Y/(J-1),X=Math.round(Z/U);return Math.max(0,Math.min(J-1,X))}default:return null}}function V05(A,Q,$,B,D,J,E,F){if(D<=0||Q<0||Q>=D)return null;let Y=2;switch(A){case"horizontal-bar":return{x:Math.floor($/2),y:Q};case"bar":case"stacked-bar":{let Z=J?r2:0,U=$-Z,X=B-(J?Y:0);if(U<=0||X<=0)return null;let G=Math.max(1,Math.floor(U/D)),V=Z+Q*G+Math.floor(G/2),K=F>0?E/F:0,z=Math.round((1-K)*(X-1));return{x:V,y:z}}case"line":case"sparkline":case"stacked-area":{let Z=J?r2:0,U=$-Z,X=B-(J?Y:0);if(U<=0||X<=0)return null;let G=D>1?Z+Math.round(Q/(D-1)*(U-1)):Z+Math.floor(U/2),V=F>0?E/F:0,K=Math.round((1-V)*(X-1));return{x:G,y:K}}default:return null}}function K05(A){let Q=0;for(let $ of A)for(let B of $.points)if(B.value>Q)Q=B.value;return Q||1}function z05(A,Q,$,B,D){if($.length<=1){let F=B(A.value),Y=A.meta?` (${A.meta})`:"";return A.label.length+2+F.length+Y.length}let J=A.label.length,E=0;for(let F of $){let Y=F.points[Q];if(!Y)continue;E+=Y.value;let Z=2+F.name.length+2+B(Y.value).length;J=Math.max(J,Z)}if(D){let F=9+B(E).length;J=Math.max(J,F)}return J}function W05(A,Q,$,B,D,J,E){let F;try{let K=L1.of(A),z=O0.of(A);F={foreground:K.colorScheme.foreground,background:K.colorScheme.background,border:z.app.keybind}}catch{F={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let Y=new T({color:F.foreground,bold:!0}),Z=new T({color:F.foreground}),U=new T({color:F.foreground,dim:!0}),X=[],G=new T({color:F.foreground,underline:!0}),V=(K,z)=>new w(z,G,void 0,lz(K),()=>{o6(A,K)});if(B.length<=1){if(X.push(new w(`${Q.label}: `,Y)),Q.link)X.push(V(Q.link,J(Q.value)));else X.push(new w(J(Q.value),Z));if(Q.meta)X.push(new w(` (${Q.meta})`,U))}else{let K=E==="stacked-bar"||E==="stacked-area";X.push(new w(`${Q.label}
7083
7083
  `,Y));let z=0;for(let W=0;W<B.length;W++){let I=B[W],H=I.points[$];if(!H)continue;z+=H.value;let q=I.color??D[W%D.length]??F.foreground;if(X.push(new w("● ",new T({color:q}))),X.push(new w(`${I.name}: `,U)),H.link)X.push(V(H.link,J(H.value)));else X.push(new w(J(H.value),Z));if(W<B.length-1||K)X.push(new w(`
7084
- `))}if(K)X.push(new w(" ",U)),X.push(new w("Total: ",U)),X.push(new w(J(z),Z))}return new b0({decoration:{color:F.background,border:c1.all(new l1(F.border,1,"rounded"))},child:new d({text:new w(void 0,void 0,X)})})}c0();function _66(A){return A.length===0?A:A[0].toLowerCase()+A.slice(1)}G5();r5();b5();d$();f9();g2();cQ();Hq();a4();sk();CT();u1();c0();f9();class p21{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(A,Q){this.enabled=A;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 A=Array.from(this.commandCounts.entries()).map(([Q,$])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1779859522-gba0d26"},parameters:{metadata:{count:$}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await z90(Q,this.configService)}catch(Q){u.error("Failed to export command telemetry events",Q)}}async submit(A){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(A)||0;this.commandCounts.set(A,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class mC extends u0{props;constructor(A){super();this.props=A}createState(){return new T66}}class T66 extends R0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=($)=>{this.setState(()=>{this._state=$(this._state)})};return this.widget.props.builder(A,Q,this._state)}}class v66 extends R0{controller=new k2;focusNode=new s6({debugLabel:"CommandArgumentPrompt",onKey:(A)=>{if(A.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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=this.widget.props.isRequiredArg??!0,J=this.controller.text.trim().length>0,E=!D||J,F=c1.all(new l1($.foreground,1,"solid")),Y=new GB({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(V)=>{let K=V.trim();if(D&&K.length===0)return;this.widget.props.onSubmit(K)},autofocus:!0,style:{textColor:$.foreground,border:null},maxLines:1}),Z=new s0({children:[new b0({decoration:{color:$.background},child:new d({text:new w(">",new T({color:$.foreground}))})}),new R1({child:Y})]}),U=new b0({padding:K0.symmetric(1,0),child:new d({text:this.widget.props.title?new w(this.widget.props.title,new T({color:B.command,bold:!0})):new w("",void 0,[new w("Command: ",new T({color:$.foreground})),new w(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=[];if(E)X.push(new w("Enter",new T({color:B.keybind}))),X.push(new w(" to submit, ",new T({color:$.foreground,dim:!0})));X.push(new w("Esc",new T({color:B.keybind}))),X.push(new w(" to cancel",new T({color:$.foreground,dim:!0})));let G=new b0({padding:K0.symmetric(1,0),child:new d({text:new w("",void 0,X)})});return new b0({decoration:{border:F,color:$.background},padding:K0.all(1),child:new S0({children:[U,new X0({height:1}),Z,new U3,G]})})}}class B10 extends u0{props;constructor(A){super();this.props=A}createState(){return new v66}}cQ();class k66 extends R0{controller=new k2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new s6({debugLabel:"CommandMultilinePrompt",onKey:(A)=>{if(A.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=async(A)=>{if(this.imageAttachments.length>=x9)return!1;let Q=await AV(A);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,A]}),!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(A){let Q=O0.of(A),{colors:$,app:B}=Q,J=g1.of(A).size.height,E=Math.max(Math.floor(J*0.5),10),F=new ZW({controller:this.controller,triggers:[new XY],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(V)=>{this.widget.props.onSubmit(V.trim(),this.imageAttachments)},theme:$,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:z4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),Y=new v4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),Z=new b0({constraints:new w1({maxHeight:E}),padding:K0.symmetric(1,0),child:Y}),U=new b0({padding:K0.symmetric(1,0),child:new d({text:new w("",void 0,[new w("Command: ",new T({color:$.foreground})),new w(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=new b0({padding:K0.symmetric(1,0),child:new d({text:this.isConfirmingClearInput?new w("",void 0,[new w("Esc",new T({color:B.keybind})),new w(" again to clear input",new T({color:$.foreground,dim:!0}))]):new w("",void 0,[new w("Press ",new T({color:$.foreground,dim:!0})),new w("Enter",new T({color:B.keybind})),new w(" to submit, ",new T({color:$.foreground,dim:!0})),new w("Esc",new T({color:B.keybind})),new w(" to clear",new T({color:$.foreground,dim:!0}))])})}),G=[U,new X0({height:1}),new R1({child:Z}),new X0({height:1}),X];return new b0({decoration:{border:c1.all(new l1($.foreground,1,"solid")),color:$.background},padding:K0.all(1),child:new S0({children:G})})}}class c21 extends u0{props;constructor(A){super();this.props=A}createState(){return new k66}}function S66(A){let $=new Date().getTime()-A.getTime(),B=Math.floor($/60000),D=Math.floor($/3600000),J=Math.floor($/86400000);if(B<1)return"just now";if(B<60)return`${B}m ago`;if(D<24)return`${D}h ago`;if(J<7)return`${J}d ago`;return A.toLocaleDateString()}class l21 extends H1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((D,J)=>J.pubDate.getTime()-D.pubDate.getTime()),$=Math.max(0,...Q.map((D)=>S66(D.pubDate).length));return new cA({items:Q,getLabel:(D)=>D.title,onAccept:(D)=>this.props.onSelect?.(D),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(D,J,E,F)=>{let Y=O0.of(F),{colors:Z}=Y,U=Y.app,X=J?U.selectionBackground:void 0,G=J?U.selectionForeground:Z.foreground,V=Z.mutedForeground,K=(z,W)=>new X0({width:W,child:s0.end([new d({text:new w(z,new T({color:V}))})])});return new b0({decoration:X?{color:X}:void 0,padding:K0.symmetric(2,0),child:new s0({children:[new R1({child:new d({text:new w(D.title,new T({color:G})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),K(S66(D.pubDate),$)]})})}})}}class L${static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!L$._instance)L$._instance=new L$;return L$._instance}get allExpanded(){return this._allExpanded}setAllExpanded(A){if(this._allExpanded===A)return;this._allExpanded=A,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(A){return this._listeners.add(A),()=>this.removeListener(A)}removeListener(A){this._listeners.delete(A)}_notifyListeners(){for(let A of this._listeners)A()}}c0();class f66 extends R0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let A=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!A.ok){u.error("Failed to load labels",A.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=A.result,this.isLoading=!1,this.setState()}catch(A){u.error("Failed to load labels",A),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(A){let Q=A.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(A){return this.getValidationError(A)===null&&A.length>0}getAvailableLabels(){let A=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!A.includes(Q.name))}shouldShowCreateMarker(A){if(A.length===0||this.isLoading)return!1;let Q=A.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let $=this.widget.props.currentLabels||[],B=this.labels.some((J)=>J.name===Q),D=$.includes(Q);return!B&&!D}build(A){let Q=O0.of(A),{app:$,colors:B}=Q,D=this.currentQuery.trim().toLowerCase(),J=D.length>0?this.getValidationError(D):null,E=this.getAvailableLabels(),Y=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...E];return new cA({title:"Add Label",items:Y,getLabel:(Z)=>{if("__isCreateMarker"in Z)return this.currentQuery.trim().toLowerCase();return Z.name},onAccept:(Z)=>{if("__isCreateMarker"in Z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(Z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:J||"Type to create a new label",renderItem:(Z,U,X,G)=>{let V=U?$.selectionBackground:void 0,K=U?$.selectionForeground:B.foreground;if("__isCreateMarker"in Z&&Z.__isCreateMarker){let W=this.currentQuery.trim().toLowerCase();return new b0({decoration:V?{color:V}:void 0,padding:K0.symmetric(2,0),child:new d({text:new w("",void 0,[new w("Create new label: ",new T({color:K})),new w(W,new T({color:K,bold:!0}))])})})}return new b0({decoration:V?{color:V}:void 0,padding:K0.symmetric(2,0),child:new d({text:new w(Z.name,new T({color:K}))})})},filterItem:(Z,U)=>{if(this.currentQuery!==U)this.currentQuery=U,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in Z&&Z.__isCreateMarker)return this.shouldShowCreateMarker(U);let G=U.trim().toLowerCase();return G.length===0||Z.name.includes(G)},sortItems:(Z,U,X)=>{let G="__isCreateMarker"in Z.item&&Z.item.__isCreateMarker,V="__isCreateMarker"in U.item&&U.item.__isCreateMarker;if(G&&!V)return-1;if(!G&&V)return 1;return U.score-Z.score}})}}class i21 extends u0{props;constructor(A){super();this.props=A}createState(){return new f66}}class VU extends u0{props;constructor(A){super();this.props=A}createState(){return new y66}}class y66 extends R0{_spinner=new CA;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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=c1.all(new l1($.foreground,1,"solid")),J=this._spinner.toBraille(),E=new d({textAlign:"center",text:new w("",void 0,[new w(J,new T({color:B.processing})),new w(" ",void 0),new w(this.widget.props.message,new T({color:$.foreground}))])}),Y=[new R1({child:new S0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[E]})})];if(this.widget.props.onAbort)Y.push(new X0({height:2,child:new b0({padding:K0.symmetric(2,0),child:new d({text:new w("",new T({dim:!0}),[new w("Press ",new T({color:$.foreground})),new w("Esc",new T({color:$.info})),new w(" to cancel",new T({color:$.foreground}))])})})}));let Z=new b0({decoration:new R4($.background,D),child:new X0({width:60,height:7,child:new S0({mainAxisAlignment:"start",children:Y})})});if(this.widget.props.onAbort)return new k4({debugLabel:"LoadingDialog",child:new v4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(U)=>{if(U.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:Z})});return Z}}class EV extends u0{props;constructor(A){super();this.props=A}createState(){return new x66}}class x66 extends R0{scrollController=new v6;scrollAreaKey=new G8("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(A){return A instanceof n8}resolveFooterStyle(A){if(this.isWidgetMessage(A))return A.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let $=Q.size;if(typeof $.height==="number"&&$.height>0)return this.viewportHeight=$.height,$.height}return this.viewportHeight}build(A){let Q=O0.of(A),$=this.widget.props.message,B=(()=>{if(this.isWidgetMessage($))return{title:$.title,type:$.type};if($ instanceof Error&&$.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:$.message};if($ instanceof Error&&$.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:$.message};let U=GG0($);return{title:U.title,type:U.type,description:U.description}})(),D=B.type==="error"?Q.app.toolError:Q.app.command,J=c1.all(new l1(Q.colors.border,1,"solid")),E=new b0({padding:K0.symmetric(1,0),child:new d({text:new w(B.title,new T({color:D,bold:!0}))})}),F=this.isWidgetMessage($)?$.widget:new d({text:new w(B.description,new T({color:Q.colors.foreground})),selectable:!0}),Y=new R1({child:new K5({child:new b0({padding:K0.symmetric(1,0),child:new s0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new R1({child:new k6({controller:this.scrollController,autofocus:!0,child:F})}),new q8({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let U=this.scrollController.maxScrollExtent,X=this.scrollController.offset,G=this.getViewportHeight(),V=U+G;return{totalContentHeight:Math.max(V,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(X,0)}}})]})})})}),Z=new b0({padding:K0.symmetric(1,0),child:new d({text:(()=>{if(this.widget.props.onRetry)return new w("",void 0,[new w("Press ",new T({color:Q.colors.foreground,dim:!0})),new w("R",new T({color:Q.app.keybind})),new w(" to retry, ",new T({color:Q.colors.foreground,dim:!0})),new w("Esc",new T({color:Q.app.keybind})),new w(" to cancel",new T({color:Q.colors.foreground,dim:!0}))]);let U=this.resolveFooterStyle(this.widget.props.message);if(U==="none")return new w("",new T({color:Q.colors.foreground,dim:!0}));if(U==="help"){let X=new T({color:Q.app.keybind}),G=new T({color:Q.colors.foreground,dim:!0});return new w("",G,[new w("Press ",G),new w("Escape",X),new w(" to close • Use ",G),new w("↑↓",X),new w(" or ",G),new w("j/k",X),new w(" to scroll",G)])}return new w("Press any key to close",new T({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new k4({debugLabel:"MessageDialog",child:new i4({fit:"expand",children:[new O1({onClick:()=>{},child:new X0}),new v4({onKey:(U)=>{if(this.widget.props.onRetry&&U.key==="r")return this.widget.props.onRetry(),"handled";if(U.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new b0({decoration:{border:J,color:Q.colors.background},padding:K0.all(1),child:new S0({mainAxisAlignment:"center",children:[E,new X0({height:1}),Y,Z]})})})]})})}}G5();B4();class b66 extends u0{props;constructor(A){super();this.props=A}createState(){return new h66}}class h66 extends R0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((A)=>{this.plugins=A,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(A){let Q=n0.file(this.widget.props.cwd),$=B1.relativePath(Q,XA(A));if($!==null&&$!==""&&$!==".."&&!$.startsWith("../"))return $;return l3(A)}statusIcon(A){let Q=n2.default(),{colors:$,app:B}=Q;switch(A){case"loading":return{icon:"◌",color:$.warning};case"active":return{icon:"✓",color:B.toolSuccess};case"error":return{icon:"✗",color:B.toolError}}}build(A){let Q=O0.of(A),{app:$}=Q;if(this.plugins.length===0)return new d({text:new w("No plugins found.",new T({dim:!0}))});let B=[],D=this.plugins.length,J=this.plugins.filter((Y)=>Y.status==="active").length,E=this.plugins.reduce((Y,Z)=>Y+Z.registeredCommands.length,0),F=this.plugins.reduce((Y,Z)=>Y+Z.registeredTools.length,0);if(B.push(new w(`${J}/${D} ${U4(D,"plugin")} active`,new T({bold:!0}))),E>0||F>0)B.push(new w(` (${E} ${U4(E,"command")}, ${F} ${U4(F,"tool")})`,new T({dim:!0})));B.push(new w(`
7084
+ `))}if(K)X.push(new w(" ",U)),X.push(new w("Total: ",U)),X.push(new w(J(z),Z))}return new b0({decoration:{color:F.background,border:c1.all(new l1(F.border,1,"rounded"))},child:new d({text:new w(void 0,void 0,X)})})}c0();function _66(A){return A.length===0?A:A[0].toLowerCase()+A.slice(1)}G5();r5();b5();d$();f9();g2();cQ();Hq();a4();sk();CT();u1();c0();f9();class p21{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(A,Q){this.enabled=A;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 A=Array.from(this.commandCounts.entries()).map(([Q,$])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1779886645-g59fcb2"},parameters:{metadata:{count:$}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await z90(Q,this.configService)}catch(Q){u.error("Failed to export command telemetry events",Q)}}async submit(A){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(A)||0;this.commandCounts.set(A,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class mC extends u0{props;constructor(A){super();this.props=A}createState(){return new T66}}class T66 extends R0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=($)=>{this.setState(()=>{this._state=$(this._state)})};return this.widget.props.builder(A,Q,this._state)}}class v66 extends R0{controller=new k2;focusNode=new s6({debugLabel:"CommandArgumentPrompt",onKey:(A)=>{if(A.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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=this.widget.props.isRequiredArg??!0,J=this.controller.text.trim().length>0,E=!D||J,F=c1.all(new l1($.foreground,1,"solid")),Y=new GB({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(V)=>{let K=V.trim();if(D&&K.length===0)return;this.widget.props.onSubmit(K)},autofocus:!0,style:{textColor:$.foreground,border:null},maxLines:1}),Z=new s0({children:[new b0({decoration:{color:$.background},child:new d({text:new w(">",new T({color:$.foreground}))})}),new R1({child:Y})]}),U=new b0({padding:K0.symmetric(1,0),child:new d({text:this.widget.props.title?new w(this.widget.props.title,new T({color:B.command,bold:!0})):new w("",void 0,[new w("Command: ",new T({color:$.foreground})),new w(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=[];if(E)X.push(new w("Enter",new T({color:B.keybind}))),X.push(new w(" to submit, ",new T({color:$.foreground,dim:!0})));X.push(new w("Esc",new T({color:B.keybind}))),X.push(new w(" to cancel",new T({color:$.foreground,dim:!0})));let G=new b0({padding:K0.symmetric(1,0),child:new d({text:new w("",void 0,X)})});return new b0({decoration:{border:F,color:$.background},padding:K0.all(1),child:new S0({children:[U,new X0({height:1}),Z,new U3,G]})})}}class B10 extends u0{props;constructor(A){super();this.props=A}createState(){return new v66}}cQ();class k66 extends R0{controller=new k2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new s6({debugLabel:"CommandMultilinePrompt",onKey:(A)=>{if(A.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=async(A)=>{if(this.imageAttachments.length>=x9)return!1;let Q=await AV(A);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,A]}),!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(A){let Q=O0.of(A),{colors:$,app:B}=Q,J=g1.of(A).size.height,E=Math.max(Math.floor(J*0.5),10),F=new ZW({controller:this.controller,triggers:[new XY],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(V)=>{this.widget.props.onSubmit(V.trim(),this.imageAttachments)},theme:$,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:z4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),Y=new v4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),Z=new b0({constraints:new w1({maxHeight:E}),padding:K0.symmetric(1,0),child:Y}),U=new b0({padding:K0.symmetric(1,0),child:new d({text:new w("",void 0,[new w("Command: ",new T({color:$.foreground})),new w(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=new b0({padding:K0.symmetric(1,0),child:new d({text:this.isConfirmingClearInput?new w("",void 0,[new w("Esc",new T({color:B.keybind})),new w(" again to clear input",new T({color:$.foreground,dim:!0}))]):new w("",void 0,[new w("Press ",new T({color:$.foreground,dim:!0})),new w("Enter",new T({color:B.keybind})),new w(" to submit, ",new T({color:$.foreground,dim:!0})),new w("Esc",new T({color:B.keybind})),new w(" to clear",new T({color:$.foreground,dim:!0}))])})}),G=[U,new X0({height:1}),new R1({child:Z}),new X0({height:1}),X];return new b0({decoration:{border:c1.all(new l1($.foreground,1,"solid")),color:$.background},padding:K0.all(1),child:new S0({children:G})})}}class c21 extends u0{props;constructor(A){super();this.props=A}createState(){return new k66}}function S66(A){let $=new Date().getTime()-A.getTime(),B=Math.floor($/60000),D=Math.floor($/3600000),J=Math.floor($/86400000);if(B<1)return"just now";if(B<60)return`${B}m ago`;if(D<24)return`${D}h ago`;if(J<7)return`${J}d ago`;return A.toLocaleDateString()}class l21 extends H1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((D,J)=>J.pubDate.getTime()-D.pubDate.getTime()),$=Math.max(0,...Q.map((D)=>S66(D.pubDate).length));return new cA({items:Q,getLabel:(D)=>D.title,onAccept:(D)=>this.props.onSelect?.(D),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(D,J,E,F)=>{let Y=O0.of(F),{colors:Z}=Y,U=Y.app,X=J?U.selectionBackground:void 0,G=J?U.selectionForeground:Z.foreground,V=Z.mutedForeground,K=(z,W)=>new X0({width:W,child:s0.end([new d({text:new w(z,new T({color:V}))})])});return new b0({decoration:X?{color:X}:void 0,padding:K0.symmetric(2,0),child:new s0({children:[new R1({child:new d({text:new w(D.title,new T({color:G})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),K(S66(D.pubDate),$)]})})}})}}class L${static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!L$._instance)L$._instance=new L$;return L$._instance}get allExpanded(){return this._allExpanded}setAllExpanded(A){if(this._allExpanded===A)return;this._allExpanded=A,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(A){return this._listeners.add(A),()=>this.removeListener(A)}removeListener(A){this._listeners.delete(A)}_notifyListeners(){for(let A of this._listeners)A()}}c0();class f66 extends R0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let A=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!A.ok){u.error("Failed to load labels",A.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=A.result,this.isLoading=!1,this.setState()}catch(A){u.error("Failed to load labels",A),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(A){let Q=A.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(A){return this.getValidationError(A)===null&&A.length>0}getAvailableLabels(){let A=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!A.includes(Q.name))}shouldShowCreateMarker(A){if(A.length===0||this.isLoading)return!1;let Q=A.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let $=this.widget.props.currentLabels||[],B=this.labels.some((J)=>J.name===Q),D=$.includes(Q);return!B&&!D}build(A){let Q=O0.of(A),{app:$,colors:B}=Q,D=this.currentQuery.trim().toLowerCase(),J=D.length>0?this.getValidationError(D):null,E=this.getAvailableLabels(),Y=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...E];return new cA({title:"Add Label",items:Y,getLabel:(Z)=>{if("__isCreateMarker"in Z)return this.currentQuery.trim().toLowerCase();return Z.name},onAccept:(Z)=>{if("__isCreateMarker"in Z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(Z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:J||"Type to create a new label",renderItem:(Z,U,X,G)=>{let V=U?$.selectionBackground:void 0,K=U?$.selectionForeground:B.foreground;if("__isCreateMarker"in Z&&Z.__isCreateMarker){let W=this.currentQuery.trim().toLowerCase();return new b0({decoration:V?{color:V}:void 0,padding:K0.symmetric(2,0),child:new d({text:new w("",void 0,[new w("Create new label: ",new T({color:K})),new w(W,new T({color:K,bold:!0}))])})})}return new b0({decoration:V?{color:V}:void 0,padding:K0.symmetric(2,0),child:new d({text:new w(Z.name,new T({color:K}))})})},filterItem:(Z,U)=>{if(this.currentQuery!==U)this.currentQuery=U,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in Z&&Z.__isCreateMarker)return this.shouldShowCreateMarker(U);let G=U.trim().toLowerCase();return G.length===0||Z.name.includes(G)},sortItems:(Z,U,X)=>{let G="__isCreateMarker"in Z.item&&Z.item.__isCreateMarker,V="__isCreateMarker"in U.item&&U.item.__isCreateMarker;if(G&&!V)return-1;if(!G&&V)return 1;return U.score-Z.score}})}}class i21 extends u0{props;constructor(A){super();this.props=A}createState(){return new f66}}class VU extends u0{props;constructor(A){super();this.props=A}createState(){return new y66}}class y66 extends R0{_spinner=new CA;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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=c1.all(new l1($.foreground,1,"solid")),J=this._spinner.toBraille(),E=new d({textAlign:"center",text:new w("",void 0,[new w(J,new T({color:B.processing})),new w(" ",void 0),new w(this.widget.props.message,new T({color:$.foreground}))])}),Y=[new R1({child:new S0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[E]})})];if(this.widget.props.onAbort)Y.push(new X0({height:2,child:new b0({padding:K0.symmetric(2,0),child:new d({text:new w("",new T({dim:!0}),[new w("Press ",new T({color:$.foreground})),new w("Esc",new T({color:$.info})),new w(" to cancel",new T({color:$.foreground}))])})})}));let Z=new b0({decoration:new R4($.background,D),child:new X0({width:60,height:7,child:new S0({mainAxisAlignment:"start",children:Y})})});if(this.widget.props.onAbort)return new k4({debugLabel:"LoadingDialog",child:new v4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(U)=>{if(U.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:Z})});return Z}}class EV extends u0{props;constructor(A){super();this.props=A}createState(){return new x66}}class x66 extends R0{scrollController=new v6;scrollAreaKey=new G8("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(A){return A instanceof n8}resolveFooterStyle(A){if(this.isWidgetMessage(A))return A.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let $=Q.size;if(typeof $.height==="number"&&$.height>0)return this.viewportHeight=$.height,$.height}return this.viewportHeight}build(A){let Q=O0.of(A),$=this.widget.props.message,B=(()=>{if(this.isWidgetMessage($))return{title:$.title,type:$.type};if($ instanceof Error&&$.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:$.message};if($ instanceof Error&&$.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:$.message};let U=GG0($);return{title:U.title,type:U.type,description:U.description}})(),D=B.type==="error"?Q.app.toolError:Q.app.command,J=c1.all(new l1(Q.colors.border,1,"solid")),E=new b0({padding:K0.symmetric(1,0),child:new d({text:new w(B.title,new T({color:D,bold:!0}))})}),F=this.isWidgetMessage($)?$.widget:new d({text:new w(B.description,new T({color:Q.colors.foreground})),selectable:!0}),Y=new R1({child:new K5({child:new b0({padding:K0.symmetric(1,0),child:new s0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new R1({child:new k6({controller:this.scrollController,autofocus:!0,child:F})}),new q8({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let U=this.scrollController.maxScrollExtent,X=this.scrollController.offset,G=this.getViewportHeight(),V=U+G;return{totalContentHeight:Math.max(V,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(X,0)}}})]})})})}),Z=new b0({padding:K0.symmetric(1,0),child:new d({text:(()=>{if(this.widget.props.onRetry)return new w("",void 0,[new w("Press ",new T({color:Q.colors.foreground,dim:!0})),new w("R",new T({color:Q.app.keybind})),new w(" to retry, ",new T({color:Q.colors.foreground,dim:!0})),new w("Esc",new T({color:Q.app.keybind})),new w(" to cancel",new T({color:Q.colors.foreground,dim:!0}))]);let U=this.resolveFooterStyle(this.widget.props.message);if(U==="none")return new w("",new T({color:Q.colors.foreground,dim:!0}));if(U==="help"){let X=new T({color:Q.app.keybind}),G=new T({color:Q.colors.foreground,dim:!0});return new w("",G,[new w("Press ",G),new w("Escape",X),new w(" to close • Use ",G),new w("↑↓",X),new w(" or ",G),new w("j/k",X),new w(" to scroll",G)])}return new w("Press any key to close",new T({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new k4({debugLabel:"MessageDialog",child:new i4({fit:"expand",children:[new O1({onClick:()=>{},child:new X0}),new v4({onKey:(U)=>{if(this.widget.props.onRetry&&U.key==="r")return this.widget.props.onRetry(),"handled";if(U.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new b0({decoration:{border:J,color:Q.colors.background},padding:K0.all(1),child:new S0({mainAxisAlignment:"center",children:[E,new X0({height:1}),Y,Z]})})})]})})}}G5();B4();class b66 extends u0{props;constructor(A){super();this.props=A}createState(){return new h66}}class h66 extends R0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((A)=>{this.plugins=A,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(A){let Q=n0.file(this.widget.props.cwd),$=B1.relativePath(Q,XA(A));if($!==null&&$!==""&&$!==".."&&!$.startsWith("../"))return $;return l3(A)}statusIcon(A){let Q=n2.default(),{colors:$,app:B}=Q;switch(A){case"loading":return{icon:"◌",color:$.warning};case"active":return{icon:"✓",color:B.toolSuccess};case"error":return{icon:"✗",color:B.toolError}}}build(A){let Q=O0.of(A),{app:$}=Q;if(this.plugins.length===0)return new d({text:new w("No plugins found.",new T({dim:!0}))});let B=[],D=this.plugins.length,J=this.plugins.filter((Y)=>Y.status==="active").length,E=this.plugins.reduce((Y,Z)=>Y+Z.registeredCommands.length,0),F=this.plugins.reduce((Y,Z)=>Y+Z.registeredTools.length,0);if(B.push(new w(`${J}/${D} ${U4(D,"plugin")} active`,new T({bold:!0}))),E>0||F>0)B.push(new w(` (${E} ${U4(E,"command")}, ${F} ${U4(F,"tool")})`,new T({dim:!0})));B.push(new w(`
7085
7085
 
7086
7086
  `));for(let Y of this.plugins){let{icon:Z,color:U}=this.statusIcon(Y.status),X=this.getRelativePath(Y.uri);if(B.push(new w(`${Z} `,new T({color:U}))),B.push(new w(X,new T({bold:!0}))),B.push(new w(` ${Y.status}`,new T({dim:!0}))),B.push(new w(`
7087
7087
  `)),Y.status==="active"&&Y.registeredEvents.length>0)B.push(new w(" Events: ",new T({dim:!0}))),B.push(new w(Y.registeredEvents.join(", "),new T({color:$.link}))),B.push(new w(`
@@ -7260,7 +7260,7 @@ ${t.content||""}`:t.content||"",p0=[],h0=t.baseDir.startsWith("file://")?XW0(t.b
7260
7260
  `)}function N56(A,Q){A.command("usage").description("Show your current Amp usage and credit balance").action(async($,B)=>{let D=B.optsWithGlobals(),J=await Q(D),E=await J.settings.get("proxy"),F=X64({settings:{url:J.ampURL,proxy:E},secrets:{getToken:(Z,U)=>J.secrets.get(Z,U)}}),Y=await o4.userDisplayBalanceInfo({},{config:F});if(!Y.ok){if(Y.error.code==="auth-required")process.stderr.write(e0.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(e0.red("Error: ")+Y.error.message+`
7261
7261
  `),process.exit(1)}process.stdout.write(await f65(Y.result.displayText)+`
7262
7262
  `),process.exit(0)})}var B85=m10.join(aB,"logs","headless.log"),o71=m10.join(Hl,"device-id.json"),D85=`cli-tui-${a96(16).toString("hex")}`;Vv4();async function J85(){let A=await Promise.all(ML.map(async(Q)=>{try{return{query:Q,hasConfigs:(await Q.listConfigs()).length>0}}catch($){return u.debug("Failed to detect query-based IDE integration",{ideName:Q.ideName,error:$}),{query:Q,hasConfigs:!1}}}));for(let Q of A)if(Q.hasConfigs)return Q.query;return}function r96(){J85().then((A)=>{if(A){let Q=x90(A.ideName);if(Q)WL(Q)}})}try{if(process.platform==="win32")await Promise.resolve().then(() => h4(yb(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(A){O$.write(`Failed to change directory to ${process.env.AMP_PWD}: ${A}
7263
- `)}function E85(A){process.emitWarning=(Q,$,B,D)=>{let J=typeof Q==="string"?Q:Q.message||String(Q),E=$||"Warning",F=!1;A.warn(J,{name:E,code:B})}}function t8(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")BD("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")BD("experimental.agentMode",Q.mode)}function F85(A,Q){if(!i6(Q))return;if(!E9(Q.user.email)){if(A.model)throw new h1("The --model flag is only available for Amp employees.",1);BD("internal.model",void 0);return}if(A.model)BD("internal.model",U85(A.model))}function m96(A){let Q=A.indexOf(":");if(Q===-1)throw new h1(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let $=A.slice(0,Q).trim(),B=A.slice(Q+1).trim();if(!$||!B)throw new h1(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Y85(A){if(A===void 0)return;let Q=A.trim();if(I90(Q))return Q;throw new h1(`Invalid effort "${A}". Expected one of: none, minimal, low, medium, high, xhigh, max.`,1)}function Z85(A,Q){if(o5(A,Q))return;let $=$D(A)?.levels,B=$?` Allowed for ${A}: ${$.join(", ")}.`:"";throw new h1(`Reasoning effort "${Q}" is not available for ${A} mode.${B}`,1)}function U85(A){if(!A.includes("="))return m96(A),A;let Q={};for(let $ of A.split(",")){let B=$.trim();if(!B)continue;let D=B.indexOf("=");if(D===-1)throw new h1(`Invalid mode-specific model entry "${B}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let J=B.slice(0,D).trim(),E=B.slice(D+1).trim();if(!J)throw new h1(`Missing mode name in "${B}". Expected "mode=provider:model".`,1);if(!E)throw new h1(`Missing model value for mode "${J}". Expected "${J}=provider:model".`,1);m96(E),Q[J]=E}if(Object.keys(Q).length===0)throw new h1("No valid model overrides found in --model flag value.",1);return Q}function AI0(A,Q,$){let B=Number(A);if(!Number.isInteger(B)||B<$.min)throw new lY0(`${Q} must be an integer >= ${$.min}`);if($.max!==void 0&&B>$.max)throw new lY0(`${Q} must be an integer <= ${$.max}`);return B}function X85(A,Q){if(A.getOptionValueSourceWithGlobals("sp")==="cli"&&Q.sp)return Q.sp;if(A.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Q.systemPrompt)return Q.systemPrompt;return}async function G85(A){try{return await o96(A,"utf-8")}catch{return A}}async function r71(A,Q,$){let B=X85(A,Q);if(!B)return;let D=i6($)?$.features:[],J=i6($)?$.user.email:void 0;if(!c10(D,x$.HARNESS_SYSTEM_PROMPT)&&!(J&&E9(J)))throw new h1("You are not allowed to do this.",1);BD("systemPrompt",await G85(B))}function c10(A,Q){return A?.some(($)=>$.name===Q&&$.enabled)??!1}function V85(A){return A!=="pending"}function vW(A){if(!i6(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function K85(A){let Q=vW(A);if(Q)return Q.id;if(sY(A))throw Error(A.error.message);throw Error("unreachable")}function z85(A){try{let Q=new URL(A);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return A.includes("localhost")||A.includes("127.0.0.1")}}function W85(A){let B=z85(A)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new h1(`Couldn't connect to the Amp server at ${A}.`,1,B)}function d10(A,Q){let $=Qs0(Error(A.error.message));if($.message===a9.networkOffline||$.message===a9.networkTimeout)return W85(Q);if($.message!==a9.internalBug)return new h1($.message,1,$.suggestion);return new h1(A.error.message.replace(/^Error: /,""),1)}async function I85(){if(process.versions.bun)return!1;try{return await xG()==="npm"}catch(A){return u.debug("Failed to detect package manager for Neo npm migration welcome",{error:A}),!1}}var d96=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH or with AMP_FORCE_BEL; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??eY,description:`Custom settings file path (overrides the default location ${eY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${Ms})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","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:O9(),description:(A)=>A?"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:(A)=>A?"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:(A)=>A?"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:"mode",long:"mode",short:"m",type:"option",default:NL.SMART.key,description:`Set the agent mode (${QD({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:Array.from(new Set(QD().map((A)=>A.mode))),hiddenChoices:["frontier"]},{name:"effort",long:"effort",type:"option",description:"Set reasoning effort for the new thread, when supported by the selected mode",choices:["none","minimal","low","medium","high","xhigh","max"]},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neoOrb",long:"neo-orb",type:"switch",description:"Use the experimental Neo splash orb",hidden:!0},{name:"hideWelcome",long:"hide-welcome",type:"switch",description:"Skip the welcome experience on startup",hidden:!0},{name:"showWelcome",long:"show-welcome",type:"switch",description:"Show the welcome experience on startup",hidden:!0},{name:"observe",long:"observe",type:"option",description:"Open the Neo TUI as an observer of an existing thread (thread ID or URL)",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless thread-actor executor (no TUI). Optionally provide a thread ID to connect to existing thread, otherwise create one.",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],p96=(A)=>("deprecated"in A)&&A.deprecated===!0,H85=(A)=>("hidden"in A)&&A.hidden===!0,q85=(A)=>("default"in A),N85=(A)=>("default"in A)?A.default:void 0;function QI0(A,Q){if(A.getOptionValueSourceWithGlobals("effort")!=="cli")return;let $=Y85(Q.effort);if($!==void 0)Z85(Q.mode,$);return $}function C85(A,Q){let $=Q.args[0],B=Q.commands.map((J)=>J.name());if($&&!$.includes(" ")&&$.length<30&&!/[./\\]/.test($)){let J=B.filter((F)=>$.includes(F)||F.includes($)),E="Run amp --help for a list of available commands.";if(J.length>0)E=`Did you mean: ${J.join(", ")}? Or run amp --help for all commands.`;throw new h1(a9.unknownCommand($),1,E)}}async function DI0(A){return{...A,getThreadEnvironment:nZ,getEnvironmentData:(Q,$)=>$z(Q,$),skillService:A.skillService,fileChangeTrackerStorage:new FO,generateThreadTitle:dZ4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>BF(A.configService),pluginService:A.pluginService}}function s96(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:nZ,getEnvironmentData:(Q,$)=>$z(Q,$)}}var $I0=n0.file($85.homedir()),s71=process.env.XDG_CONFIG_HOME?n0.file(process.env.XDG_CONFIG_HOME):B1.joinPath($I0,".config");async function s2(A,Q,$){let B=$?.deferAuth??!1,D=$?.skipToolProviders??!1;x44("0.0.1779859522-gba0d26");let J=P90({storage:A.settings,secretStorage:A.secrets,workspaceRoot:g0.of(n0.file(process.cwd())),defaultAmpURL:A.ampURL,homeDir:$I0,userConfigDir:s71}),E=A.secrets.get("apiKey",A.ampURL),F=BF(J),Y=null,Z=()=>{return},U=new Promise((Q0)=>{Z=Q0}),X=E.then(async(Q0)=>{if(!Q0&&!B)await U;return Y??=F.subscribe(()=>{}),S1(F.pipe(i3(V85)))});X.catch(()=>{return}),T06(J);let G=await J.getLatest();u.debug("Global configuration initialized",{settingsKeys:Object.keys(G.settings)});let V=!1;{let Q0=await E;if(V=Boolean(Q0),u.info("API key lookup before login",{found:Boolean(Q0),ampURL:A.ampURL,deferAuth:B}),!Q0)if(B)u.info("No API key found, continuing startup with deferred auth");else{Q3.write(`No API key found. Starting login flow...
7263
+ `)}function E85(A){process.emitWarning=(Q,$,B,D)=>{let J=typeof Q==="string"?Q:Q.message||String(Q),E=$||"Warning",F=!1;A.warn(J,{name:E,code:B})}}function t8(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")BD("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")BD("experimental.agentMode",Q.mode)}function F85(A,Q){if(!i6(Q))return;if(!E9(Q.user.email)){if(A.model)throw new h1("The --model flag is only available for Amp employees.",1);BD("internal.model",void 0);return}if(A.model)BD("internal.model",U85(A.model))}function m96(A){let Q=A.indexOf(":");if(Q===-1)throw new h1(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let $=A.slice(0,Q).trim(),B=A.slice(Q+1).trim();if(!$||!B)throw new h1(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Y85(A){if(A===void 0)return;let Q=A.trim();if(I90(Q))return Q;throw new h1(`Invalid effort "${A}". Expected one of: none, minimal, low, medium, high, xhigh, max.`,1)}function Z85(A,Q){if(o5(A,Q))return;let $=$D(A)?.levels,B=$?` Allowed for ${A}: ${$.join(", ")}.`:"";throw new h1(`Reasoning effort "${Q}" is not available for ${A} mode.${B}`,1)}function U85(A){if(!A.includes("="))return m96(A),A;let Q={};for(let $ of A.split(",")){let B=$.trim();if(!B)continue;let D=B.indexOf("=");if(D===-1)throw new h1(`Invalid mode-specific model entry "${B}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let J=B.slice(0,D).trim(),E=B.slice(D+1).trim();if(!J)throw new h1(`Missing mode name in "${B}". Expected "mode=provider:model".`,1);if(!E)throw new h1(`Missing model value for mode "${J}". Expected "${J}=provider:model".`,1);m96(E),Q[J]=E}if(Object.keys(Q).length===0)throw new h1("No valid model overrides found in --model flag value.",1);return Q}function AI0(A,Q,$){let B=Number(A);if(!Number.isInteger(B)||B<$.min)throw new lY0(`${Q} must be an integer >= ${$.min}`);if($.max!==void 0&&B>$.max)throw new lY0(`${Q} must be an integer <= ${$.max}`);return B}function X85(A,Q){if(A.getOptionValueSourceWithGlobals("sp")==="cli"&&Q.sp)return Q.sp;if(A.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Q.systemPrompt)return Q.systemPrompt;return}async function G85(A){try{return await o96(A,"utf-8")}catch{return A}}async function r71(A,Q,$){let B=X85(A,Q);if(!B)return;let D=i6($)?$.features:[],J=i6($)?$.user.email:void 0;if(!c10(D,x$.HARNESS_SYSTEM_PROMPT)&&!(J&&E9(J)))throw new h1("You are not allowed to do this.",1);BD("systemPrompt",await G85(B))}function c10(A,Q){return A?.some(($)=>$.name===Q&&$.enabled)??!1}function V85(A){return A!=="pending"}function vW(A){if(!i6(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function K85(A){let Q=vW(A);if(Q)return Q.id;if(sY(A))throw Error(A.error.message);throw Error("unreachable")}function z85(A){try{let Q=new URL(A);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return A.includes("localhost")||A.includes("127.0.0.1")}}function W85(A){let B=z85(A)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new h1(`Couldn't connect to the Amp server at ${A}.`,1,B)}function d10(A,Q){let $=Qs0(Error(A.error.message));if($.message===a9.networkOffline||$.message===a9.networkTimeout)return W85(Q);if($.message!==a9.internalBug)return new h1($.message,1,$.suggestion);return new h1(A.error.message.replace(/^Error: /,""),1)}async function I85(){if(process.versions.bun)return!1;try{return await xG()==="npm"}catch(A){return u.debug("Failed to detect package manager for Neo npm migration welcome",{error:A}),!1}}var d96=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH or with AMP_FORCE_BEL; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??eY,description:`Custom settings file path (overrides the default location ${eY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${Ms})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","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:O9(),description:(A)=>A?"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:(A)=>A?"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:(A)=>A?"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:"mode",long:"mode",short:"m",type:"option",default:NL.SMART.key,description:`Set the agent mode (${QD({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:Array.from(new Set(QD().map((A)=>A.mode))),hiddenChoices:["frontier"]},{name:"effort",long:"effort",type:"option",description:"Set reasoning effort for the new thread, when supported by the selected mode",choices:["none","minimal","low","medium","high","xhigh","max"]},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neoOrb",long:"neo-orb",type:"switch",description:"Use the experimental Neo splash orb",hidden:!0},{name:"hideWelcome",long:"hide-welcome",type:"switch",description:"Skip the welcome experience on startup",hidden:!0},{name:"showWelcome",long:"show-welcome",type:"switch",description:"Show the welcome experience on startup",hidden:!0},{name:"observe",long:"observe",type:"option",description:"Open the Neo TUI as an observer of an existing thread (thread ID or URL)",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless thread-actor executor (no TUI). Optionally provide a thread ID to connect to existing thread, otherwise create one.",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],p96=(A)=>("deprecated"in A)&&A.deprecated===!0,H85=(A)=>("hidden"in A)&&A.hidden===!0,q85=(A)=>("default"in A),N85=(A)=>("default"in A)?A.default:void 0;function QI0(A,Q){if(A.getOptionValueSourceWithGlobals("effort")!=="cli")return;let $=Y85(Q.effort);if($!==void 0)Z85(Q.mode,$);return $}function C85(A,Q){let $=Q.args[0],B=Q.commands.map((J)=>J.name());if($&&!$.includes(" ")&&$.length<30&&!/[./\\]/.test($)){let J=B.filter((F)=>$.includes(F)||F.includes($)),E="Run amp --help for a list of available commands.";if(J.length>0)E=`Did you mean: ${J.join(", ")}? Or run amp --help for all commands.`;throw new h1(a9.unknownCommand($),1,E)}}async function DI0(A){return{...A,getThreadEnvironment:nZ,getEnvironmentData:(Q,$)=>$z(Q,$),skillService:A.skillService,fileChangeTrackerStorage:new FO,generateThreadTitle:dZ4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>BF(A.configService),pluginService:A.pluginService}}function s96(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:nZ,getEnvironmentData:(Q,$)=>$z(Q,$)}}var $I0=n0.file($85.homedir()),s71=process.env.XDG_CONFIG_HOME?n0.file(process.env.XDG_CONFIG_HOME):B1.joinPath($I0,".config");async function s2(A,Q,$){let B=$?.deferAuth??!1,D=$?.skipToolProviders??!1;x44("0.0.1779886645-g59fcb2");let J=P90({storage:A.settings,secretStorage:A.secrets,workspaceRoot:g0.of(n0.file(process.cwd())),defaultAmpURL:A.ampURL,homeDir:$I0,userConfigDir:s71}),E=A.secrets.get("apiKey",A.ampURL),F=BF(J),Y=null,Z=()=>{return},U=new Promise((Q0)=>{Z=Q0}),X=E.then(async(Q0)=>{if(!Q0&&!B)await U;return Y??=F.subscribe(()=>{}),S1(F.pipe(i3(V85)))});X.catch(()=>{return}),T06(J);let G=await J.getLatest();u.debug("Global configuration initialized",{settingsKeys:Object.keys(G.settings)});let V=!1;{let Q0=await E;if(V=Boolean(Q0),u.info("API key lookup before login",{found:Boolean(Q0),ampURL:A.ampURL,deferAuth:B}),!Q0)if(B)u.info("No API key found, continuing startup with deferred auth");else{Q3.write(`No API key found. Starting login flow...
7264
7264
  `);let M0=await w85(A),n=await A.secrets.get("apiKey",A.ampURL);if(u.info("Login flow completed",{success:M0,storedKeyPresent:Boolean(n),ampURL:A.ampURL}),!M0)await MG(),process.exit(1);V=!0,Z()}}{let Q0=await J.getLatest(),M0=Q0.settings.url,n=Q0.secrets.isSet?.[M0];u.info("Config secrets state after login",{configURL:M0,apiKeySet:n?.apiKey??!1})}let K=B?"pending":await X;if(!B)u.info("Server status resolved",{status:"ready",isAuthenticated:i6(K),isError:sY(K),errorMessage:sY(K)?K.error.message:void 0});F85(Q,K);let z=X.then((Q0)=>K85(Q0));z.catch(()=>{return});let W=!Q.takeMeBack&&i6(K)&&c10(K.features,x$.THREAD_ACTORS_TUI),I=!1;if(process.env.AMP_DISABLE_PLUGINS==="1")u.warn("Ignoring AMP_DISABLE_PLUGINS outside development");let H=I?"off":W?"all":process.env.PLUGINS??"permissions",{toolService:q,dispose:N}=zP4({configService:J}),C=new Map,M=()=>C.clear(),O=new Rb0(J,A.settings.getWorkspaceRootPath()),R=IF4({configService:J}),k=AB4({configService:J,trustStore:O,skillMCPServers:R.skillMCPServers,uploadImageAttachments:W,createOAuthProvider:async(Q0,M0,n)=>{let a=`${Q0}:${M0}`,t=C.get(a);if(t)return u.debug("Reusing existing OAuth provider for server",{serverName:Q0,serverUrl:M0}),t;u.debug("Creating OAuth provider for server",{serverName:Q0,serverUrl:M0});let e=(async()=>{let E0=new PL(A.secrets),J0=await E0.getClientInfo(Q0,M0),C0=n?.scopes??J0?.scopes,w0=Sx4();u.info("OAuth headless mode check",{useHeadless:w0,executeMode:A.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:Q3.isTTY});let _0;if(w0)_0=A.executeMode?kx4():vx4(Q0);let U0=new xS0({storage:E0,serverName:Q0,serverUrl:M0,clientId:n?.clientId??J0?.clientId,clientSecret:n?.clientSecret??J0?.clientSecret,authUrl:n?.authUrl??J0?.authUrl,tokenUrl:n?.tokenUrl??J0?.tokenUrl,scopes:C0,headlessAuthHandler:_0});return u.debug("OAuth provider created",{serverName:Q0,serverUrl:M0,hasManualClientId:!!(n?.clientId??J0?.clientId),willUseDCR:!(n?.clientId??J0?.clientId),scopes:C0,headlessMode:w0,executeMode:A.executeMode}),U0})();return C.set(a,e),e}}),_=na0({configService:J,spawn:GY0}),f=Q.headless?B06():void 0,g=f??new wK0({configService:J}),b=g instanceof wK0?g:void 0;if(b)b.pluginExecutorKind="local";let v=new o1(null),x=null,c=W&&!I?[...E06(G.settings)?[{name:"permissions",entryPoint:y51}]:[],{name:"thread-visibility",entryPoint:Z06(J,()=>X.then(vW),()=>x,(Q0)=>{x=Q0}),alwaysLoad:!0}]:[],p=db0({configService:J,platform:g,loadGlobalPlugins:qe0(J),pluginFilter:H,activeThread$:v,internalPlugins:c}),h=nB4(p),i=[k,_,h],r;if(D)r=new Map;else if(A.executeMode){let Q0=await QR4({toolService:q,providers:i,initialTimeout:15000});r=Q0.registrations;for(let[M0,n]of Q0.initErrors)u.warn(`${M0} provider initialization slow or failed:`,n)}else r=aa0({toolService:q,providers:i});if(Q.jetbrains)WL("JetBrains");else if(Q.ide&&Jb4())WL("VS Code");else if(Q.ide&&Eb4())WL("Neovim");else if(Q.ide&&(!W||A.executeMode||Q.takeMeBack))r96();if(A.executeMode)b44(!0);let A0,V0=s5.status.pipe(N1((Q0)=>Boolean(Q0.connected&&Q0.authenticated&&Q0.ideName&&g64(Q0.ideName))),T4()).subscribe((Q0)=>{if(Q0){if(!A0)A0=q.registerTool(AR4)}else A0?.dispose(),A0=void 0}),Y0;if(!A.executeMode){let Q0=await A.settings.get("fuzzy.alwaysIncludePaths")??[];Y0=new LU0(process.cwd(),{alwaysIncludePaths:Q0},!0)}else Y0=new class extends LU0{async start(){}async query(){return[]}async queryCompletions(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let I0=new dm0(va(J,{usesThreadActors:!1}),{maxThreads:200});u.info("Starting Amp background services");let B0=new p51,j0={configService:J,toolService:q,mcpService:k,skillService:R,toolboxService:_,trustStore:O,threadService:I0,secretStorage:A.secrets,settingsStorage:A.settings,fuzzyServer:Y0,terminal:B0,pluginService:p,pluginPlatform:b,headlessPluginPlatform:f,activeThread$:v,serverStatus:K,serverStatusPromise:X,viewerUserIDPromise:z,hasAPIKeyAtStartup:V,consumeDraftNewThreadVisibility:()=>{let Q0=x;return x=null,Q0}};return{...j0,async asyncDispose(){if(j0.mcpService.hasAuthenticatingClients())u.info("Waiting for OAuth authentication to complete before exit..."),await j0.mcpService.waitForAuthentication();for(let Q0 of r.values())Q0.dispose();await j0.mcpService.dispose(),M(),await j0.threadService.asyncDispose(),j0.configService.unsubscribe(),Y?.unsubscribe(),N(),j0.fuzzyServer.dispose(),j0.settingsStorage[Symbol.dispose](),V0.unsubscribe(),A0?.dispose(),await j0.pluginService.dispose()}}}async function w85(A){if(!A.executeMode){if(!await zX0("Would you like to log in to Amp? [(y)es, (n)o]: "))return Q3.write(`Login cancelled. Run the command again to retry.
7265
7265
  `),!1}return await t96(A)}async function t96(A){let Q=a96(32).toString("hex"),$=await hy(A.ampURL,Q),B=new AbortController;try{await oY($,B.signal)}catch(J){u.error("Error opening browser",{error:J})}let D=await hy(A.ampURL,Q,!1);Q3.write(`If your browser does not open automatically, visit:
7266
7266
 
@@ -7268,7 +7268,7 @@ ${e0.blue.bold(D)}
7268
7268
 
7269
7269
  `);try{return await Cg4(A.ampURL,Q,A.secrets,B),Q3.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(J){return u.error("Login failed",{error:J}),O$.write(`
7270
7270
  Login failed: ${J instanceof Error?J.message:String(J)}
7271
- `),!1}}async function M85(A,Q,$){let B=await Q.get("apiKey",A);if(!B)throw new h1("No Amp API key found. Run `amp login` first.",1);let D=e25("curl",["-H",`Authorization: Bearer ${B}`,...$],{stdio:"inherit"});process.exitCode=await new Promise((J,E)=>{D.on("error",E),D.on("close",(F)=>J(F??1))})}function L85(A){let Q=new NN().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((I)=>{if(I.code==="commander.help"||I.code==="commander.version"||I.exitCode===0)kj(),process.exit(0);let H=I.originalError??I;fv4(H)}),Zd4(Q,{version:"0.0.1779859522-gba0d26",buildTimestamp:"2026-05-27T05:30:48.321Z",buildType:"release"}),Q.addHelpText("after",$b4()),Q.configureHelp({formatHelp:Bb4}),Q.command("logout").description("Log out by removing stored API key").action(async(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await S85(N)}),Q.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(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await k85(N,await h51(q,N.settings))}),vv4(Q,d3);let B=Q.command("internal",{hidden:!0}).description("Internal commands").command("curl [args...]").description("Internal: run curl with the current Amp API key as a bearer token").allowUnknownOption(!0).allowExcessArguments(!0).action(async(...I)=>{let H=I.find((M)=>typeof M==="object"&&M!==null&&typeof M.optsWithGlobals==="function")??B,q=I.filter((M)=>M!==H).flatMap((M)=>Array.isArray(M)?M:typeof M==="string"?[M]:[]),N=H.optsWithGlobals(),C=await d3(N);await M85(C.ampURL,C.secrets,q),process.exit(process.exitCode??0)});Q.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(I,H,q)=>{let N=q.optsWithGlobals(),C=await d3(N);await Lx4(I??"get",C.ampURL,C.secrets),process.exit(process.exitCode??0)}),Q.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await Ox4(N.ampURL,N.secrets),process.exit(process.exitCode??0)}),Q.command("keyboard-tester",{hidden:!0}).summary("Keyboard input tester").description("Internal: stream parsed terminal input events as JSONL.").option("--raw","Log raw incoming terminal bytes before parsing").action(async(I)=>{await Nh4({raw:I.raw===!0}),process.exit(process.exitCode??0)}),Q.command("live-sync [threadIDOrURL]",{hidden:!0}).summary("Mirror live DTW thread changes into the current checkout").description("Experimental: watch a v2 thread URL or ID and mirror its live working-tree changes into your local checkout, or apply the current snapshot once and exit.").addHelpText("after",["","Examples:"," amp live-sync T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync --apply T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee"].join(`
7271
+ `),!1}}async function M85(A,Q,$){let B=await Q.get("apiKey",A);if(!B)throw new h1("No Amp API key found. Run `amp login` first.",1);let D=e25("curl",["-H",`Authorization: Bearer ${B}`,...$],{stdio:"inherit"});process.exitCode=await new Promise((J,E)=>{D.on("error",E),D.on("close",(F)=>J(F??1))})}function L85(A){let Q=new NN().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((I)=>{if(I.code==="commander.help"||I.code==="commander.version"||I.exitCode===0)kj(),process.exit(0);let H=I.originalError??I;fv4(H)}),Zd4(Q,{version:"0.0.1779886645-g59fcb2",buildTimestamp:"2026-05-27T13:02:21.391Z",buildType:"release"}),Q.addHelpText("after",$b4()),Q.configureHelp({formatHelp:Bb4}),Q.command("logout").description("Log out by removing stored API key").action(async(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await S85(N)}),Q.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(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await k85(N,await h51(q,N.settings))}),vv4(Q,d3);let B=Q.command("internal",{hidden:!0}).description("Internal commands").command("curl [args...]").description("Internal: run curl with the current Amp API key as a bearer token").allowUnknownOption(!0).allowExcessArguments(!0).action(async(...I)=>{let H=I.find((M)=>typeof M==="object"&&M!==null&&typeof M.optsWithGlobals==="function")??B,q=I.filter((M)=>M!==H).flatMap((M)=>Array.isArray(M)?M:typeof M==="string"?[M]:[]),N=H.optsWithGlobals(),C=await d3(N);await M85(C.ampURL,C.secrets,q),process.exit(process.exitCode??0)});Q.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(I,H,q)=>{let N=q.optsWithGlobals(),C=await d3(N);await Lx4(I??"get",C.ampURL,C.secrets),process.exit(process.exitCode??0)}),Q.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await Ox4(N.ampURL,N.secrets),process.exit(process.exitCode??0)}),Q.command("keyboard-tester",{hidden:!0}).summary("Keyboard input tester").description("Internal: stream parsed terminal input events as JSONL.").option("--raw","Log raw incoming terminal bytes before parsing").action(async(I)=>{await Nh4({raw:I.raw===!0}),process.exit(process.exitCode??0)}),Q.command("live-sync [threadIDOrURL]",{hidden:!0}).summary("Mirror live DTW thread changes into the current checkout").description("Experimental: watch a v2 thread URL or ID and mirror its live working-tree changes into your local checkout, or apply the current snapshot once and exit.").addHelpText("after",["","Examples:"," amp live-sync T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync --apply T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee"].join(`
7272
7272
  `)).option("--apply <threadIDOrURL>","Apply the current DTW thread snapshot once and exit").option("--checkout","Automatically check out the thread commit when it differs").option("--skip-checkout","Skip the startup checkout prompt when commits differ").action(async(I,H,q)=>{if(I&&H.apply)throw new h1("Choose either a positional thread ID/URL or --apply <thread-id>, not both.",1);let N=H.apply??I;if(!N||N.trim().length===0)Q3.write(`live-sync watches a v2 thread and mirrors its live changes locally. Use --apply <thread-id> to materialize the current snapshot once and exit.
7273
7273
 
7274
7274
  `),q.outputHelp(),process.exit(0);let C=S8(N)??EB(N),M=q.optsWithGlobals(),O=await d3(M);t8(q,M);let R=await s2(O,M),k=!1;try{if(H.checkout&&H.skipCheckout)throw new h1("Choose either --checkout or --skip-checkout, not both.",1);if(sY(R.serverStatus))throw d10(R.serverStatus,O.ampURL);let _=i6(R.serverStatus)?R.serverStatus.features:void 0;if(!c10(_,x$.V2))throw new h1("live-sync is not enabled for your user",1);await Ug4({ampURL:O.ampURL,threadId:C,configService:R.configService,threadService:R.threadService,apiKey:process.env.AMP_API_KEY,applyOnce:typeof H.apply==="string",checkoutMode:H.checkout?"always":H.skipCheckout?"never":"prompt",promptForYesNo:zX0}),k=!0}finally{if(await R.asyncDispose(),k)process.exit(0)}});let D=async(I,H,q)=>{P90({storage:H.settings,secretStorage:H.secrets,workspaceRoot:g0.of(n0.file(process.cwd())),defaultAmpURL:H.ampURL,homeDir:$I0,userConfigDir:s71});let N={...H,executeMode:!1};await BI0(N,{...I,openThreadSwitcher:!0},q,A)},J=Q.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").option("--include-archived","Include archived threads in the list").option("--limit <number>","Maximum number of threads to return",(I)=>AI0(I,"--limit",{min:1,max:500})).option("--offset <number>","Number of threads to skip",(I)=>AI0(I,"--offset",{min:0})).action(async(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await n96(q,N,H)});J.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(I,H)=>{let q=H.optsWithGlobals(),N=await d3(q);await n85(q,N,H)}),J.command("continue [threadIDOrURLs...]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. By default, interactive mode shows a picker. Use --last to continue the last thread for the current mode directly. When multiple thread are given, all are resumed and the first is shown in the foreground.").option("--last","Continue the last thread for the current mode directly").option("--pick","Pick a thread interactively from a list (DEPRECATED: picker is now the default)").action(async(I,H,q)=>{let N=q.optsWithGlobals(),C=await d3(N),M=Array.isArray(I)?I:[];if(H.pick)O$.write(`${e0.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
@@ -7301,8 +7301,8 @@ ${O}
7301
7301
  `))}),H.args.length>0)C85(N,H);await BI0(N,q,H,A)}),Sb4(Q),Q}async function p10(A,Q){await qQ(($)=>py($,A,Q))}async function c96(A,Q,$){let B=Date.now(),[D,J]=await Promise.all([o4.getThreadLinkInfo({thread:A},{config:Q}),$]);if(u.getChild("fetchAndStartThread").info(`Ownership check in ${Date.now()-B}ms`),D.ok){let E=D.result.creatorUserID;if(E&&E!==J&&!process.env.AMP_RESUME_OTHER_USER_THREADS_INSECURE)throw new h1(`Cannot resume thread created by another user.
7302
7302
 
7303
7303
  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.`)}}async function e96(A){if(A.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof A.execute==="string"){let Q=(await RK0()).trimEnd();return{userInput:A.execute,stdinInput:Q||null}}return{userInput:(await RK0()).trimEnd(),stdinInput:null}}function A76(A,Q,$){if(A.remote&&!Q)throw new h1("The -r/--remote flag requires --execute mode",1,'Use: amp --remote --execute "your message"');if(A.streamJson&&!Q)throw new h1("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(A.streamJsonInput&&!Q)throw new h1("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(A.streamJsonInput&&!A.streamJson)throw new h1("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(A.stats&&A.streamJson)throw new h1("The --stats and --stream-json flags are mutually exclusive output formats",1,'Use one or the other: amp --execute "your message" --stats OR amp --execute "your message" --stream-json');if(A.stats&&!Q)throw new h1("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(A.archive&&!Q)throw new h1("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(A.streamJsonInput&&typeof A.execute==="string"&&A.execute.trim()!=="")throw new h1("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"},{"type":"image","source":{"type":"base64","media_type":"image/png","data":"..."}}]}}' | amp --execute --stream-json --stream-json-input`);if(Q&&$===""&&!A.streamJsonInput&&!A.headless)throw new h1("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"
7304
- Or pipe via stdin: echo "your message" | amp --execute`)}function O85(){G54([j90.parse({tool:"*",action:"allow"})]),b34({bypass:!0})}function j85(A){if(A.threadId&&!S9(A.threadId))delete A.threadId}async function BI0(A,Q,$,B){if(Q.headless)return R85(A,Q,$);let D=await s2(A,Q),J=await D.serverStatusPromise,E=i6(J)&&c10(J.features,x$.THREAD_ACTORS_TUI),F=E&&!Q.takeMeBack;if(Q.showWelcome&&Q.hideWelcome)throw await D.asyncDispose(),new h1("Cannot use --show-welcome and --hide-welcome together",1);if(Q.showWelcome&&!E)throw await D.asyncDispose(),new h1("--show-welcome is only available with the new Amp CLI feature flag",1);if(F){let Y=!A.executeMode&&await I85();return O85(),j85(Q),u85(A,Q,$,D,{showNpmMigrationWelcome:Y})}else{if(Q.threadId&&S9(Q.threadId)){let Y=await o4.getThreadLinkInfo({thread:Q.threadId},{config:D.configService}).catch(()=>null);if(Y?.ok&&Y.result.usesThreadActors)throw await D.asyncDispose(),new h1(`Thread ${Q.threadId} was created with the Neo TUI and cannot be continued in the legacy CLI.`,1,"Re-run without --take-me-back to continue this thread.")}return P85(A,Q,$,B,{dependencies:D})}}async function R85(A,Q,$){let B=(I,H)=>{let q=Number(process.hrtime.bigint()-H)/1e6,N=lr0();u.info("Startup phase",{phase:I,phaseMs:Math.round(q),sinceMainMs:N===null?void 0:Math.round(N)})};t8($,Q);let D=process.hrtime.bigint(),J=await s2(A,Q);B("runMainThread:createThreadDependencies",D);let{serverStatus:E}=J;if(sY(E))throw d10(E,A.ampURL);let F=i6(E)?E:null,Y=F?.user.email;await r71($,Q,E);let Z=vW(E),U=ix(Q,Z);if(U instanceof Error)R3(U.message);if(F&&!qL(Q.mode,Y))throw new h1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(process.env.AMP_EXECUTOR!=="1"&&(!Y||!E9(Y)))throw new h1("Headless executor mode is only available for Amp employees",1);LZ0();let G=await J.secretStorage.get("apiKey",A.ampURL);if(!G)throw new h1("API key required for headless mode. Please run `amp login` first.",1);let V=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(V&&!S9(V))throw new h1(`Invalid thread ID: ${V}`,1);let K=V?void 0:await l85({dependencies:J,apiKey:G,visibility:U??void 0}),z=V??K?.threadId;if(!z)throw new h1("Failed to resolve headless thread ID",1);let W=await bx4(z);if(W.status==="already-running")await J.asyncDispose(),await MG(),process.exit(0);try{await Px4({ampURL:A.ampURL,apiKey:G,workspaceRoot:process.cwd(),threadId:z,ownerUserId:K?.ownerUserId,threadVersion:K?.threadVersion,agentMode:K?.agentMode,initialToolDiscovery:Promise.all([J.mcpService.initialized,J.toolboxService.initialized,J.pluginService.initialized]).then(()=>{return}),configService:J.configService,mcpService:J.mcpService,toolService:J.toolService,skillService:J.skillService,pluginService:J.pluginService,pluginPlatform:J.headlessPluginPlatform})}finally{await W.release(),await J.asyncDispose()}await MG(),process.exit(0)}async function u85(A,Q,$,B,D){let{userInput:J,stdinInput:E}=await e96(Q),F=!!Q.streamJson||!!Q.streamJsonThinking;A76({...Q,streamJson:F},A.executeMode,J),t8($,Q),qv4(),LZ0();let Y=Q.threadId,Z=Q.resumeThreadIDs??(Y?[Y]:[]),U=Q.observe?S8(Q.observe)??EB(Q.observe):void 0,X=await B.serverStatusPromise;if(sY(X))throw d10(X,A.ampURL);let G=vW(X),V=ix(Q,G);if(V instanceof Error)R3(V.message);if(A.executeMode&&Q.remote){if(!i6(X)||!E9(X.user.email))throw new h1("Remote execute mode is only available for Amp employees",1);await x51(J,E,B.configService,Q.mode),await B.asyncDispose(),await MG(),process.exit(0)}let K=null,z=async()=>{let H=B.consumeDraftNewThreadVisibility();if(H!==null)return H;return K??=(async()=>{let q=await Ls(A.settings,process.cwd(),G,V);if(q instanceof Error)R3(q.message);return q})(),K},W=await B.secretStorage.get("apiKey",A.ampURL);if(!W)throw new h1("API key required. Please run `amp login` first.",1);let I=i6(X)&&E9(X.user.email);if(A.executeMode){if(Z.length>1)throw new h1("Execute mode can only resume one thread.",1);j01(B.mcpService,A.settings);try{let H=QI0($,Q),q=await rz(),N=Y?H:IX0({agentMode:Q.mode,explicitEffort:H,sessionState:q}),C=Y?void 0:HX0(await gy(B.configService),{agentMode:Q.mode,explicitEffort:H,sessionState:q}),M=Y?void 0:await z(),O=await Xx4({apiKey:W,ampURL:A.ampURL,workspaceRoot:process.cwd(),dependencies:B,userInput:J,stdinInput:E,stats:!!Q.stats,streamJson:F,streamJsonThinking:!!Q.streamJsonThinking,streamJsonInput:!!Q.streamJsonInput,stdin:process.stdin,agentMode:Q.mode,reasoningEffort:N,labels:Q.label,initialThreadID:Y,initialThreadMeta:M,initialSettings:C});if(await p10(O,"execute"),Q.archive)await B.threadService.archive(O,!0)}finally{await B.asyncDispose()}await MG(),process.exit(0)}else{let H=QI0($,Q),q=D.showNpmMigrationWelcome?"npm-migration":"intro",N=bU0("0.0.1779859522-gba0d26",B.settingsStorage,{startDelayMs:3000}),C=new WX0(B.mcpService,A.settings.getWorkspaceRootPath()),M=va(B.configService),O=new D10(B.fuzzyServer),R=process.cwd();await oe4({ampURL:A.ampURL,apiKey:W,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??eJ(A.ampURL),configService:B.configService,toolService:B.toolService,pluginPlatform:B.pluginPlatform,pluginService:B.pluginService,skillService:B.skillService,mcpService:B.mcpService,readFileSystemDirectory:({uri:k})=>wy({workspaceRoot:R},k),completionBuilder:O,updateService:N,workspaceRoot:R,listThreads:()=>M.listThreads(),getThreadFromServer:(k)=>M.getThread(k),toolboxes:B.toolboxService.toolboxes,isInternalUser:I,settingsFilePath:B.settingsStorage.getSettingsFilePath(),workspaceSettingsFilePath:B.settingsStorage.getWorkspaceSettingsPath(),mcpTrustHandler:C,setActiveThreadID:(k)=>B.activeThread$.next(k),dispose:()=>{return C.dispose(),N.dispose(),B.asyncDispose()}},{initialThreadIDs:U?[U]:Z,initialUserInput:J||void 0,getDefaultNewThreadVisibility:z,onFirstFrame:Q.ide?r96:void 0,openThreadPickerOnStart:Q.openThreadSwitcher,observerOnly:!!U,splashOrbVisualStyle:"neo",hideNeoWelcome:!!Q.hideWelcome,showNeoWelcome:Q.showWelcome,neoWelcomeVariant:q,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,initialReasoningEffort:H}),process.exit(0)}}async function P85(A,Q,$,B,D){let J=process.hrtime.bigint(),E=(B0,j0)=>{let Q0=Number(process.hrtime.bigint()-j0)/1e6,M0=lr0();u.info("Startup phase",{phase:B0,phaseMs:Math.round(Q0),sinceMainMs:M0===null?void 0:Math.round(M0)})},{userInput:F,stdinInput:Y}=await e96(Q),Z=!!Q.streamJson||!!Q.streamJsonThinking;A76({...Q,streamJson:Z},A.executeMode,F),t8($,Q);let U=process.hrtime.bigint(),X=D?.dependencies??await s2(A,Q),G=X.hasAPIKeyAtStartup,V=X.serverStatus==="pending";if(u.info("Interactive auth startup mode",{deferInteractiveAuth:V,hasAPIKeyAtStartup:G,executeMode:A.executeMode,headless:Boolean(Q.headless)}),!D)E("runMainThread:createThreadDependencies",U);let{serverStatus:K}=X;if(!V&&sY(K))throw d10(K,A.ampURL);let z=i6(K)?K:null,W=z?.user.email,I=!!(W&&E9(W));if(I)LZ0();if(!V)await r71($,Q,K);let H=vW(K),q=H?.features??[],N=H?.team??null,C=ix(Q,H);if(C instanceof Error)R3(C.message);if(z&&!qL(Q.mode,W))throw new h1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(A.executeMode&&Q.remote){if(!W||!E9(W))throw new h1("Remote execute mode is only available for Amp employees",1);await x51(F,Y,X.configService,Q.mode),await X.asyncDispose(),process.exit(0)}let M=Q.threadId&&S9(Q.threadId)?Q.threadId:void 0;U=process.hrtime.bigint();let O=await DI0(X);E("runMainThread:createWorkerDeps",U);let R=A.executeMode?void 0:async(B0)=>p10(B0,"interactive"),k={threadService:X.threadService,workerDeps:O,createThread:async(B0)=>{let j0=V?await X.serverStatusPromise:K,Q0=await Ls(A.settings,process.cwd(),vW(j0),C);if(Q0 instanceof Error)R3(Q0.message);return w91(O,{threadMeta:Q0,agentMode:B0??Q.mode,onFirstAssistantMessage:R})},validateThreadOwnership:async(B0,j0)=>{if(j0?.nonBlockingOwnershipCheck){c96(B0,X.configService,X.viewerUserIDPromise).catch((Q0)=>{if(Q0 instanceof h1){if(j0.onOwnershipError){j0.onOwnershipError(Q0,B0);return}fz(Q0,B0);return}u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})});return}try{await c96(B0,X.configService,X.viewerUserIDPromise)}catch(Q0){if(Q0 instanceof h1)throw Q0;u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})}},switchThreadVisibility:C,switchThreadAgentMode:Q.mode,onFirstAssistantMessage:R,handleError:fz},_=async()=>{try{return W56(k,Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck})}catch(B0){if(B0 instanceof h1)throw B0;throw await fz(B0,Q.threadId),Error("handleError should have called process.exit()")}},f=(async()=>{if(V){u.info("Skipping initial free tier status fetch until auth is complete");return}try{let B0=await X.configService.getLatest(),j0=Rc(B0),Q0=await o4.getUserFreeTierStatus({},{config:X.configService,signal:AbortSignal.timeout(j0)});if(Q0.ok)return u.info("User free tier status:",Q0),Q0.result;return}catch(B0){u.error("Failed to fetch free tier status:",B0);return}})(),b=!A.executeMode?new n51:null,v,x=null;if(b)v=b,x=(async()=>{let B0=V?await X.serverStatusPromise:X.serverStatus;if(sY(B0))throw d10(B0,A.ampURL);await r71($,Q,B0);let j0=process.hrtime.bigint(),Q0=await _();if(E("runMainThread:createThreadPool",j0),b.attach(Q0),F){let M0=await S1(Q0.threadHandles$);if(!M0)throw new h1("No active thread is available yet.",1);await M0.sendMessage({content:[{type:"text",text:F}]})}})(),x.catch(async(B0)=>{let j0=B0 instanceof Error?B0:Error(String(B0));b.setInitError(j0),await fz(B0,Q.threadId)});else U=process.hrtime.bigint(),v=await _(),E("runMainThread:createThreadPool",U);let c=Q.notifications!==void 0?Q.notifications:!A.executeMode;U=process.hrtime.bigint();let p=await X.configService.getLatest();if(E("runMainThread:configService.getLatest",U),U=process.hrtime.bigint(),$16({configService:X.configService,threadService:X.threadService,threadPool:v,config:p,useNotifications:c}),E("runMainThread:createLegacyTuiNotificationService",U),A.executeMode){j01(X.mcpService,A.settings);let B0=QI0($,Q),j0=await rz(),Q0=M?B0:IX0({agentMode:Q.mode,explicitEffort:B0,sessionState:j0}),M0={userInput:F,stdinInput:Y,dependencies:X,streamJson:Z,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:I,agentMode:Q.mode,reasoningEffort:Q0,labels:Q.label},n=await $k4({threadPool:v,...M0});if(await p10(n,"execute"),Q.archive)await X.threadService.archive(n,!0);await X.asyncDispose(),process.exit(0)}let h=!1,i=!1;if(Q.jetbrains||Q.ide){await h90();let B0=await QZ({jetbrainsOnly:Q.jetbrains});if(B0.length===0){if(Q.jetbrains)h=!await X.configService.get("jetbrains.skipInstall")}else if(B0.length===1){let j0=B0[0];if(j0)s5.selectConfig(j0)}else i=!0}U=process.hrtime.bigint();let r=bU0("0.0.1779859522-gba0d26",X.settingsStorage,{startDelayMs:3000});E("runMainThread:createUpdateService",U),U=process.hrtime.bigint();let A0=new WX0(X.mcpService,A.settings.getWorkspaceRootPath());if(E("runMainThread:createMcpTrustHandler",U),F&&A.executeMode){let B0=await S1(v.threadHandles$);if(!B0)throw new h1("No active thread is available yet.",1);await B0.sendMessage({content:[{type:"text",text:F}]})}U=process.hrtime.bigint();let V0=await rz();E("runMainThread:loadSessionState",U),u.info("Loaded session state:",V0);let Y0=QI0($,Q),I0={...V0,launchCount:V0.launchCount+1,lastReasoningEffortByMode:Y0?{...V0.lastReasoningEffortByMode,[Q.mode]:Y0}:V0.lastReasoningEffortByMode};qQ((B0)=>({...B0,launchCount:B0.launchCount+1}));try{if(U=process.hrtime.bigint(),await P16({history:new Ut,fuzzyServer:X.fuzzyServer,settingsStorage:X.settingsStorage,threadService:X.threadService,skillService:X.skillService,configService:X.configService,secretStorage:X.secretStorage,internalAPIClient:o4,threadPool:v,createSystemPromptDeps:async()=>s96(X),ideClient:s5,mcpService:X.mcpService,toolboxService:X.toolboxService,mcpTrustHandler:A0,updateService:r,pluginPlatform:X.pluginPlatform,pluginService:X.pluginService},{initialServerStatus:X.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:X.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:M,showJetBrainsInstaller:h,showIdePickerHint:i,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:D85,logFile:{path:B},sessionState:I0,freeTierStatusPromise:f,workspace:N??null,features:q,isInternalUser:I,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,splashOrbVisualStyle:Q.neoOrb?"neo":"classic",buildTimestamp:"2026-05-27T05:30:48.321Z"},(B0)=>new A21({...B0,threadPool:B0.threadPool},(j0)=>new N91({...j0,threadState:j0.threadState}))),E("runMainThread:mountApp-returned",U),x)await x}finally{await v.dispose().catch((B0)=>{u.error("Failed to dispose thread pool during shutdown",B0)})}await X.asyncDispose(),E("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function d3(A){if(u.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),A.interactive)O$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7305
- `);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,$=process.stdout.isTTY&&process.stderr.isTTY;u.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let B=await JB4({get:async(F)=>{if(F!==gi)return;try{let Y=await o96(o71,"utf-8");return JSON.parse(Y).installationID}catch{return}},set:async(F,Y)=>{if(F!==gi)return;await A85(m10.dirname(o71),{recursive:!0}),await Q85(o71,JSON.stringify({installationID:Y},null,2),{mode:384})}},{clientType:"cli",platform:D$0()});h44(B);let D=await R06({...A,workspaceTrust:{current:!0,changes:uc},getHook:process.env.AMP_URL?(F,Y)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return Y()}:void 0});if(A.mcpConfig){let F=await Tg4(A.mcpConfig);D=vg4(D,F)}let J=m10.dirname(D.getSettingsFilePath());qP4(Hl,J),D=et1(D);let E=await D.get("url","admin")??await D.get("url","global");if(!E)E=e7;if(u.info("Resolved Amp URL",{ampURL:E,settingsFile:D.getSettingsFilePath(),workspaceRoot:D.getWorkspaceRootPath()}),!IH(E))u.info("Targeting custom Amp server",{ampURL:E});return{executeMode:Q,isTTY:$,ampURL:E,settings:D,secrets:C06(await h51(A,D))}}function _85(A){let Q={};for(let $=0;$<A.length;$++){let B=A[$];if(B?.startsWith("--")){let J=B.slice(2).replace(/-([a-z])/g,(F,Y)=>Y.toUpperCase()),E=A[$+1];if(E&&!E.startsWith("--"))Q[J]=E,$++}}return Q}function T85(A,Q){let $=A.includes("--headless")||A.some((D)=>D.startsWith("--headless=")),B=m10.resolve(Q.logFile??process.env.AMP_LOG_FILE??($?B85:Ms));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:B}}async function v85(){Gv4();let A=_85(process.argv),Q=T85(process.argv,A),$=Nv4(Q);zZ0("silent");let B=process.argv.includes("--no-color"),D=process.argv.includes("--color"),J=process.stdout.isTTY&&process.stderr.isTTY;if(B||!D&&!J)e0.level=0;if(E85(u),u.info("Starting Amp CLI.",{version:"0.0.1779859522-gba0d26",buildTimestamp:"2026-05-27T05:30:48.321Z"}),process.platform==="win32"&&BR())ub4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new h1(a9.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await L85($).parseAsync(process.argv)}IP4().startActiveSpan("main",async(A)=>{process.on("exit",()=>A.end()),await v85().catch(fz)});async function k85(A,Q){let $=A.ampURL.includes("localhost")||A.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!$)await A.settings.set("url",process.env.AMP_URL,"global"),Q3.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7304
+ Or pipe via stdin: echo "your message" | amp --execute`)}function O85(){G54([j90.parse({tool:"*",action:"allow"})]),b34({bypass:!0})}function j85(A){if(A.threadId&&!S9(A.threadId))delete A.threadId}async function BI0(A,Q,$,B){if(Q.headless)return R85(A,Q,$);let D=await s2(A,Q),J=await D.serverStatusPromise,E=i6(J)&&c10(J.features,x$.THREAD_ACTORS_TUI),F=E&&!Q.takeMeBack;if(Q.showWelcome&&Q.hideWelcome)throw await D.asyncDispose(),new h1("Cannot use --show-welcome and --hide-welcome together",1);if(Q.showWelcome&&!E)throw await D.asyncDispose(),new h1("--show-welcome is only available with the new Amp CLI feature flag",1);if(F){let Y=!A.executeMode&&await I85();return O85(),j85(Q),u85(A,Q,$,D,{showNpmMigrationWelcome:Y})}else{if(Q.threadId&&S9(Q.threadId)){let Y=await o4.getThreadLinkInfo({thread:Q.threadId},{config:D.configService}).catch(()=>null);if(Y?.ok&&Y.result.usesThreadActors)throw await D.asyncDispose(),new h1(`Thread ${Q.threadId} was created with the Neo TUI and cannot be continued in the legacy CLI.`,1,"Re-run without --take-me-back to continue this thread.")}return P85(A,Q,$,B,{dependencies:D})}}async function R85(A,Q,$){let B=(I,H)=>{let q=Number(process.hrtime.bigint()-H)/1e6,N=lr0();u.info("Startup phase",{phase:I,phaseMs:Math.round(q),sinceMainMs:N===null?void 0:Math.round(N)})};t8($,Q);let D=process.hrtime.bigint(),J=await s2(A,Q);B("runMainThread:createThreadDependencies",D);let{serverStatus:E}=J;if(sY(E))throw d10(E,A.ampURL);let F=i6(E)?E:null,Y=F?.user.email;await r71($,Q,E);let Z=vW(E),U=ix(Q,Z);if(U instanceof Error)R3(U.message);if(F&&!qL(Q.mode,Y))throw new h1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(process.env.AMP_EXECUTOR!=="1"&&(!Y||!E9(Y)))throw new h1("Headless executor mode is only available for Amp employees",1);LZ0();let G=await J.secretStorage.get("apiKey",A.ampURL);if(!G)throw new h1("API key required for headless mode. Please run `amp login` first.",1);let V=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(V&&!S9(V))throw new h1(`Invalid thread ID: ${V}`,1);let K=V?void 0:await l85({dependencies:J,apiKey:G,visibility:U??void 0}),z=V??K?.threadId;if(!z)throw new h1("Failed to resolve headless thread ID",1);let W=await bx4(z);if(W.status==="already-running")await J.asyncDispose(),await MG(),process.exit(0);try{await Px4({ampURL:A.ampURL,apiKey:G,workspaceRoot:process.cwd(),threadId:z,ownerUserId:K?.ownerUserId,threadVersion:K?.threadVersion,agentMode:K?.agentMode,initialToolDiscovery:Promise.all([J.mcpService.initialized,J.toolboxService.initialized,J.pluginService.initialized]).then(()=>{return}),configService:J.configService,mcpService:J.mcpService,toolService:J.toolService,skillService:J.skillService,pluginService:J.pluginService,pluginPlatform:J.headlessPluginPlatform})}finally{await W.release(),await J.asyncDispose()}await MG(),process.exit(0)}async function u85(A,Q,$,B,D){let{userInput:J,stdinInput:E}=await e96(Q),F=!!Q.streamJson||!!Q.streamJsonThinking;A76({...Q,streamJson:F},A.executeMode,J),t8($,Q),qv4(),LZ0();let Y=Q.threadId,Z=Q.resumeThreadIDs??(Y?[Y]:[]),U=Q.observe?S8(Q.observe)??EB(Q.observe):void 0,X=await B.serverStatusPromise;if(sY(X))throw d10(X,A.ampURL);let G=vW(X),V=ix(Q,G);if(V instanceof Error)R3(V.message);if(A.executeMode&&Q.remote){if(!i6(X)||!E9(X.user.email))throw new h1("Remote execute mode is only available for Amp employees",1);await x51(J,E,B.configService,Q.mode),await B.asyncDispose(),await MG(),process.exit(0)}let K=null,z=async()=>{let H=B.consumeDraftNewThreadVisibility();if(H!==null)return H;return K??=(async()=>{let q=await Ls(A.settings,process.cwd(),G,V);if(q instanceof Error)R3(q.message);return q})(),K},W=await B.secretStorage.get("apiKey",A.ampURL);if(!W)throw new h1("API key required. Please run `amp login` first.",1);let I=i6(X)&&E9(X.user.email);if(A.executeMode){if(Z.length>1)throw new h1("Execute mode can only resume one thread.",1);j01(B.mcpService,A.settings);try{let H=QI0($,Q),q=await rz(),N=Y?H:IX0({agentMode:Q.mode,explicitEffort:H,sessionState:q}),C=Y?void 0:HX0(await gy(B.configService),{agentMode:Q.mode,explicitEffort:H,sessionState:q}),M=Y?void 0:await z(),O=await Xx4({apiKey:W,ampURL:A.ampURL,workspaceRoot:process.cwd(),dependencies:B,userInput:J,stdinInput:E,stats:!!Q.stats,streamJson:F,streamJsonThinking:!!Q.streamJsonThinking,streamJsonInput:!!Q.streamJsonInput,stdin:process.stdin,agentMode:Q.mode,reasoningEffort:N,labels:Q.label,initialThreadID:Y,initialThreadMeta:M,initialSettings:C});if(await p10(O,"execute"),Q.archive)await B.threadService.archive(O,!0)}finally{await B.asyncDispose()}await MG(),process.exit(0)}else{let H=QI0($,Q),q=D.showNpmMigrationWelcome?"npm-migration":"intro",N=bU0("0.0.1779886645-g59fcb2",B.settingsStorage,{startDelayMs:3000}),C=new WX0(B.mcpService,A.settings.getWorkspaceRootPath()),M=va(B.configService),O=new D10(B.fuzzyServer),R=process.cwd();await oe4({ampURL:A.ampURL,apiKey:W,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??eJ(A.ampURL),configService:B.configService,toolService:B.toolService,pluginPlatform:B.pluginPlatform,pluginService:B.pluginService,skillService:B.skillService,mcpService:B.mcpService,readFileSystemDirectory:({uri:k})=>wy({workspaceRoot:R},k),completionBuilder:O,updateService:N,workspaceRoot:R,listThreads:()=>M.listThreads(),getThreadFromServer:(k)=>M.getThread(k),toolboxes:B.toolboxService.toolboxes,isInternalUser:I,settingsFilePath:B.settingsStorage.getSettingsFilePath(),workspaceSettingsFilePath:B.settingsStorage.getWorkspaceSettingsPath(),mcpTrustHandler:C,setActiveThreadID:(k)=>B.activeThread$.next(k),dispose:()=>{return C.dispose(),N.dispose(),B.asyncDispose()}},{initialThreadIDs:U?[U]:Z,initialUserInput:J||void 0,getDefaultNewThreadVisibility:z,onFirstFrame:Q.ide?r96:void 0,openThreadPickerOnStart:Q.openThreadSwitcher,observerOnly:!!U,splashOrbVisualStyle:"neo",hideNeoWelcome:!!Q.hideWelcome,showNeoWelcome:Q.showWelcome,neoWelcomeVariant:q,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,initialReasoningEffort:H}),process.exit(0)}}async function P85(A,Q,$,B,D){let J=process.hrtime.bigint(),E=(B0,j0)=>{let Q0=Number(process.hrtime.bigint()-j0)/1e6,M0=lr0();u.info("Startup phase",{phase:B0,phaseMs:Math.round(Q0),sinceMainMs:M0===null?void 0:Math.round(M0)})},{userInput:F,stdinInput:Y}=await e96(Q),Z=!!Q.streamJson||!!Q.streamJsonThinking;A76({...Q,streamJson:Z},A.executeMode,F),t8($,Q);let U=process.hrtime.bigint(),X=D?.dependencies??await s2(A,Q),G=X.hasAPIKeyAtStartup,V=X.serverStatus==="pending";if(u.info("Interactive auth startup mode",{deferInteractiveAuth:V,hasAPIKeyAtStartup:G,executeMode:A.executeMode,headless:Boolean(Q.headless)}),!D)E("runMainThread:createThreadDependencies",U);let{serverStatus:K}=X;if(!V&&sY(K))throw d10(K,A.ampURL);let z=i6(K)?K:null,W=z?.user.email,I=!!(W&&E9(W));if(I)LZ0();if(!V)await r71($,Q,K);let H=vW(K),q=H?.features??[],N=H?.team??null,C=ix(Q,H);if(C instanceof Error)R3(C.message);if(z&&!qL(Q.mode,W))throw new h1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(A.executeMode&&Q.remote){if(!W||!E9(W))throw new h1("Remote execute mode is only available for Amp employees",1);await x51(F,Y,X.configService,Q.mode),await X.asyncDispose(),process.exit(0)}let M=Q.threadId&&S9(Q.threadId)?Q.threadId:void 0;U=process.hrtime.bigint();let O=await DI0(X);E("runMainThread:createWorkerDeps",U);let R=A.executeMode?void 0:async(B0)=>p10(B0,"interactive"),k={threadService:X.threadService,workerDeps:O,createThread:async(B0)=>{let j0=V?await X.serverStatusPromise:K,Q0=await Ls(A.settings,process.cwd(),vW(j0),C);if(Q0 instanceof Error)R3(Q0.message);return w91(O,{threadMeta:Q0,agentMode:B0??Q.mode,onFirstAssistantMessage:R})},validateThreadOwnership:async(B0,j0)=>{if(j0?.nonBlockingOwnershipCheck){c96(B0,X.configService,X.viewerUserIDPromise).catch((Q0)=>{if(Q0 instanceof h1){if(j0.onOwnershipError){j0.onOwnershipError(Q0,B0);return}fz(Q0,B0);return}u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})});return}try{await c96(B0,X.configService,X.viewerUserIDPromise)}catch(Q0){if(Q0 instanceof h1)throw Q0;u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})}},switchThreadVisibility:C,switchThreadAgentMode:Q.mode,onFirstAssistantMessage:R,handleError:fz},_=async()=>{try{return W56(k,Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck})}catch(B0){if(B0 instanceof h1)throw B0;throw await fz(B0,Q.threadId),Error("handleError should have called process.exit()")}},f=(async()=>{if(V){u.info("Skipping initial free tier status fetch until auth is complete");return}try{let B0=await X.configService.getLatest(),j0=Rc(B0),Q0=await o4.getUserFreeTierStatus({},{config:X.configService,signal:AbortSignal.timeout(j0)});if(Q0.ok)return u.info("User free tier status:",Q0),Q0.result;return}catch(B0){u.error("Failed to fetch free tier status:",B0);return}})(),b=!A.executeMode?new n51:null,v,x=null;if(b)v=b,x=(async()=>{let B0=V?await X.serverStatusPromise:X.serverStatus;if(sY(B0))throw d10(B0,A.ampURL);await r71($,Q,B0);let j0=process.hrtime.bigint(),Q0=await _();if(E("runMainThread:createThreadPool",j0),b.attach(Q0),F){let M0=await S1(Q0.threadHandles$);if(!M0)throw new h1("No active thread is available yet.",1);await M0.sendMessage({content:[{type:"text",text:F}]})}})(),x.catch(async(B0)=>{let j0=B0 instanceof Error?B0:Error(String(B0));b.setInitError(j0),await fz(B0,Q.threadId)});else U=process.hrtime.bigint(),v=await _(),E("runMainThread:createThreadPool",U);let c=Q.notifications!==void 0?Q.notifications:!A.executeMode;U=process.hrtime.bigint();let p=await X.configService.getLatest();if(E("runMainThread:configService.getLatest",U),U=process.hrtime.bigint(),$16({configService:X.configService,threadService:X.threadService,threadPool:v,config:p,useNotifications:c}),E("runMainThread:createLegacyTuiNotificationService",U),A.executeMode){j01(X.mcpService,A.settings);let B0=QI0($,Q),j0=await rz(),Q0=M?B0:IX0({agentMode:Q.mode,explicitEffort:B0,sessionState:j0}),M0={userInput:F,stdinInput:Y,dependencies:X,streamJson:Z,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:I,agentMode:Q.mode,reasoningEffort:Q0,labels:Q.label},n=await $k4({threadPool:v,...M0});if(await p10(n,"execute"),Q.archive)await X.threadService.archive(n,!0);await X.asyncDispose(),process.exit(0)}let h=!1,i=!1;if(Q.jetbrains||Q.ide){await h90();let B0=await QZ({jetbrainsOnly:Q.jetbrains});if(B0.length===0){if(Q.jetbrains)h=!await X.configService.get("jetbrains.skipInstall")}else if(B0.length===1){let j0=B0[0];if(j0)s5.selectConfig(j0)}else i=!0}U=process.hrtime.bigint();let r=bU0("0.0.1779886645-g59fcb2",X.settingsStorage,{startDelayMs:3000});E("runMainThread:createUpdateService",U),U=process.hrtime.bigint();let A0=new WX0(X.mcpService,A.settings.getWorkspaceRootPath());if(E("runMainThread:createMcpTrustHandler",U),F&&A.executeMode){let B0=await S1(v.threadHandles$);if(!B0)throw new h1("No active thread is available yet.",1);await B0.sendMessage({content:[{type:"text",text:F}]})}U=process.hrtime.bigint();let V0=await rz();E("runMainThread:loadSessionState",U),u.info("Loaded session state:",V0);let Y0=QI0($,Q),I0={...V0,launchCount:V0.launchCount+1,lastReasoningEffortByMode:Y0?{...V0.lastReasoningEffortByMode,[Q.mode]:Y0}:V0.lastReasoningEffortByMode};qQ((B0)=>({...B0,launchCount:B0.launchCount+1}));try{if(U=process.hrtime.bigint(),await P16({history:new Ut,fuzzyServer:X.fuzzyServer,settingsStorage:X.settingsStorage,threadService:X.threadService,skillService:X.skillService,configService:X.configService,secretStorage:X.secretStorage,internalAPIClient:o4,threadPool:v,createSystemPromptDeps:async()=>s96(X),ideClient:s5,mcpService:X.mcpService,toolboxService:X.toolboxService,mcpTrustHandler:A0,updateService:r,pluginPlatform:X.pluginPlatform,pluginService:X.pluginService},{initialServerStatus:X.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:X.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:M,showJetBrainsInstaller:h,showIdePickerHint:i,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:D85,logFile:{path:B},sessionState:I0,freeTierStatusPromise:f,workspace:N??null,features:q,isInternalUser:I,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,splashOrbVisualStyle:Q.neoOrb?"neo":"classic",buildTimestamp:"2026-05-27T13:02:21.391Z"},(B0)=>new A21({...B0,threadPool:B0.threadPool},(j0)=>new N91({...j0,threadState:j0.threadState}))),E("runMainThread:mountApp-returned",U),x)await x}finally{await v.dispose().catch((B0)=>{u.error("Failed to dispose thread pool during shutdown",B0)})}await X.asyncDispose(),E("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function d3(A){if(u.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),A.interactive)O$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7305
+ `);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,$=process.stdout.isTTY&&process.stderr.isTTY;u.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let B=await JB4({get:async(F)=>{if(F!==gi)return;try{let Y=await o96(o71,"utf-8");return JSON.parse(Y).installationID}catch{return}},set:async(F,Y)=>{if(F!==gi)return;await A85(m10.dirname(o71),{recursive:!0}),await Q85(o71,JSON.stringify({installationID:Y},null,2),{mode:384})}},{clientType:"cli",platform:D$0()});h44(B);let D=await R06({...A,workspaceTrust:{current:!0,changes:uc},getHook:process.env.AMP_URL?(F,Y)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return Y()}:void 0});if(A.mcpConfig){let F=await Tg4(A.mcpConfig);D=vg4(D,F)}let J=m10.dirname(D.getSettingsFilePath());qP4(Hl,J),D=et1(D);let E=await D.get("url","admin")??await D.get("url","global");if(!E)E=e7;if(u.info("Resolved Amp URL",{ampURL:E,settingsFile:D.getSettingsFilePath(),workspaceRoot:D.getWorkspaceRootPath()}),!IH(E))u.info("Targeting custom Amp server",{ampURL:E});return{executeMode:Q,isTTY:$,ampURL:E,settings:D,secrets:C06(await h51(A,D))}}function _85(A){let Q={};for(let $=0;$<A.length;$++){let B=A[$];if(B?.startsWith("--")){let J=B.slice(2).replace(/-([a-z])/g,(F,Y)=>Y.toUpperCase()),E=A[$+1];if(E&&!E.startsWith("--"))Q[J]=E,$++}}return Q}function T85(A,Q){let $=A.includes("--headless")||A.some((D)=>D.startsWith("--headless=")),B=m10.resolve(Q.logFile??process.env.AMP_LOG_FILE??($?B85:Ms));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:B}}async function v85(){Gv4();let A=_85(process.argv),Q=T85(process.argv,A),$=Nv4(Q);zZ0("silent");let B=process.argv.includes("--no-color"),D=process.argv.includes("--color"),J=process.stdout.isTTY&&process.stderr.isTTY;if(B||!D&&!J)e0.level=0;if(E85(u),u.info("Starting Amp CLI.",{version:"0.0.1779886645-g59fcb2",buildTimestamp:"2026-05-27T13:02:21.391Z"}),process.platform==="win32"&&BR())ub4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new h1(a9.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await L85($).parseAsync(process.argv)}IP4().startActiveSpan("main",async(A)=>{process.on("exit",()=>A.end()),await v85().catch(fz)});async function k85(A,Q){let $=A.ampURL.includes("localhost")||A.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!$)await A.settings.set("url",process.env.AMP_URL,"global"),Q3.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7306
7306
  `);else if(!IH(A.ampURL))Q3.write(`Logging in to ${new URL(A.ampURL).hostname}
7307
7307
  `);let B=process.env.AMP_API_KEY;if(B)Q3.write(`API key found in environment variable, storing...
7308
7308
  `),await Q.set("apiKey",B,A.ampURL),Q3.write(`API key successfully stored.