@sourcegraph/amp 0.0.1777072801-g023a81 → 0.0.1777076476-ge780d5

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 +130 -26
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -241,7 +241,7 @@ Expected format:
241
241
  `+Object.keys($).map((J)=>`${J}: ${$[J]}`).join(`\r
242
242
  `)+`\r
243
243
  \r
244
- `+B)}function tL(A,Q,B,$,J,Y){if(A.listenerCount("wsClientError")){let Z=Error(J);Error.captureStackTrace(Z,tL),A.emit("wsClientError",Z,B,Q)}else yc(B,$,J,Y)}});var fc={};L2(fc,{subprotocol:()=>t34.default,extension:()=>a34.default,default:()=>MK6,createWebSocketStream:()=>n34.default,WebSocketServer:()=>e34.default,WebSocket:()=>xc.default,Sender:()=>s34.default,Receiver:()=>r34.default,PerMessageDeflate:()=>o34.default});var n34,a34,o34,r34,s34,t34,xc,e34,MK6;var bc=J0(()=>{n34=H4(g34(),1),a34=H4(s90(),1),o34=H4(tk(),1),r34=H4(kf0(),1),s34=H4(yf0(),1),t34=H4(gf0(),1),xc=H4(Q70(),1),e34=H4(i34(),1),MK6=xc.default});class Q24{_status={};statusSubject=new M4(this._status);projectConfig;queryPollTimeout;queryPollToken=0;querySource;ws;id=1;reconnectTimeoutId;reconnectStartTime;isReconnecting=!1;connectionSource="never-connected";pendingRequests=new Map;constructor(){this.statusSubject.subscribe((A)=>{if(A.ideName){let Q=p90(A.ideName);if(Q)iL(Q)}})}get status(){return new g0((A)=>{A.next(this._status);let Q=this.statusSubject.subscribe(A);return()=>Q.unsubscribe()})}sendStatus(A){this._status={...this._status,...A},this.statusSubject.next(this._status)}getIdeName(){return this._status.ideName||"ide"}async start(A,Q=!1,B){if(A.connection!=="query"&&ak(A.ideName)){this.projectConfig=void 0,this.clearReconnectTimeout(),this.ws?.close(),this.ws=void 0,this.clearPendingRequests(),this.stopQueryPolling(),this.sendStatus({enabled:!0,ideName:A.ideName,connected:!1,authenticated:!1,connectionState:"disconnected",reconnectElapsedMs:void 0,errorMessage:`Amp connects to ${A.ideName} through file queries, not websockets`,openFile:void 0,selections:void 0,visibleFiles:void 0});return}let $=Q||!this.projectConfig||this.projectConfig.port!==A.port||this.projectConfig.authToken!==A.authToken||this.projectConfig.connection!==A.connection||this.projectConfig.workspaceId!==A.workspaceId;if(this.projectConfig=A,this.sendStatus({enabled:!0}),this.connectionSource=B??"auto-startup",$&&this.ws)this.ws.close(),this.ws=void 0,this.clearPendingRequests();this.stopQueryPolling(),await this.tryConnect(this.projectConfig)}sendRequest=(A,Q)=>{let B=this.ws;if(!B)return Promise.resolve(void 0);if(!this.isWsOpen())return Promise.reject(Error("WebSocket is not open"));return new Promise(($,J)=>{let Y=`${this.id++}`,Z={clientRequest:{id:Y,[A]:Q}},F=setTimeout(()=>{this.pendingRequests.delete(Y),J(Error(`Timeout after ${A24}ms for request ${JSON.stringify(Z,null,2)}`))},A24);this.pendingRequests.set(Y,{resolve:$,reject:J,timeout:F,method:A}),B.send(JSON.stringify(Z))})};clearPendingRequests(){for(let[A,Q]of this.pendingRequests.entries())clearTimeout(Q.timeout),Q.reject(Error("WebSocket connection closed"));this.pendingRequests.clear()}handleResponse(A){if(!A?.id)return;let Q=this.pendingRequests.get(A.id);if(!Q)return;if(T.debug("ide-client: received response",{type:"response_received",source:this.getIdeName(),responseId:A?.id,hasError:!!A?.error}),clearTimeout(Q.timeout),this.pendingRequests.delete(A.id),A.error){Q.reject(Error(JSON.stringify(A.error)));return}let B=A[Q.method];if(B)Q.resolve(B);else Q.reject(Error(`Invalid response for method ${Q.method}. Got ${JSON.stringify(A,null,2)}`))}async tryConnect(A){if(A.connection==="query"){let $=this.resolveQuery(A);if($)this.startQueryPolling(A,$);return}if(await this.isConnected()){T.debug("ide-client: already connected",{type:"already_connected",source:this.getIdeName()});return}if(this.clearReconnectTimeout(),this.ws?.close(),this.clearPendingRequests(),!A){this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"});return}this.sendStatus({ideName:A.ideName});let B=new(await RK6())(`ws://localhost:${A.port}?auth=${encodeURIComponent(A.authToken)}`);this.ws=B,this.id=1,B.onopen=async()=>{try{if(T.info("ide-client: connected",{type:"connected",source:this.getIdeName(),ideName:A.ideName,port:A.port}),this.connectionSource!=="never-connected")this.connectionSource="user-initiated";this.clearReconnectTimeout(),this.reconnectStartTime=void 0,this.isReconnecting=!1,this.sendStatus({connected:!0,authenticated:!0,connectionState:"connected",reconnectElapsedMs:void 0,errorMessage:void 0})}catch($){T.error("ide-client: connection error",$),this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"})}},B.onclose=($)=>{try{if(this.clearPendingRequests(),$.code===1000&&$.reason==="Authentication failed")this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE authentication failed - try restarting your IDE"});else T.warn("ide-client: disconnected",{code:$.code,reason:$.reason}),this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"});this.ws=void 0,this.scheduleReconnect()}catch(J){T.error("ide-client: disconnect error",J)}},B.onerror=()=>{this.clearPendingRequests()},B.onmessage=async($)=>{let J=$.data.toString();try{let Y=q84.safeParse(JSON.parse(J));if(Y.error){T.error("ide-client: failed to parse server message",v.prettifyError(Y.error));return}if(Y.data?.serverResponse)this.handleResponse(Y.data.serverResponse);this.handleNotification(Y.data?.serverNotification)}catch(Y){T.error("ide-client: error handling server message",{error:Y,data:J})}}}clearReconnectTimeout(){if(this.reconnectTimeoutId)clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=void 0}scheduleReconnect(){if(this.connectionSource==="never-connected")return;if(this.isReconnecting)return;if(!this.reconnectStartTime)this.reconnectStartTime=Date.now();let A=Date.now()-this.reconnectStartTime;if(A>=OK6){this.sendStatus({connectionState:"disconnected",reconnectElapsedMs:A});let Q=60000-A;if(Q>0)this.clearReconnectTimeout(),this.reconnectTimeoutId=setTimeout(()=>{let B=Date.now()-(this.reconnectStartTime||Date.now());this.sendStatus({connectionState:"disconnected",reconnectElapsedMs:B})},Q);return}this.isReconnecting=!0,this.sendStatus({connectionState:"reconnecting",reconnectElapsedMs:A,ideName:this.projectConfig?.ideName}),this.reconnectTimeoutId=setTimeout(()=>{this.executeReconnectAttempt().catch((Q)=>{T.error("ide-client: reconnect timer failed",Q)})},LK6)}async executeReconnectAttempt(){try{if(!this.projectConfig){T.debug("ide-client: no config available during reconnect, will retry");return}let A=await this.resolveActiveConfig(this.projectConfig);this.projectConfig=A,await this.tryConnect(A)}catch(A){T.error("ide-client: reconnect loop error",A)}finally{this.handleReconnectResult(await this.isConnected())}}async resolveActiveConfig(A){if(A.connection==="query"){let{config:B}=await this.findQueryConfig(A);return B??A}if(eE(A.pid))return A;return(await ID()).find((B)=>B.ideName===A.ideName&&B.workspaceFolders.length===A.workspaceFolders.length&&B.workspaceFolders.every(($)=>A.workspaceFolders.includes($)))??A}handleReconnectResult(A){if(this.isReconnecting=!1,!A)this.scheduleReconnect();else this.clearReconnectTimeout(),this.reconnectStartTime=void 0,this.sendStatus({connectionState:"connected",reconnectElapsedMs:void 0})}startQueryPolling(A,Q){this.stopQueryPolling();let B=++this.queryPollToken;this.querySource={config:A,query:Q},this.sendStatus({ideName:Q.ideName,workspace:A.workspaceFolders[0],connected:!0,authenticated:!0,connectionState:"connected",reconnectElapsedMs:void 0,errorMessage:void 0});let $=async()=>{if(B!==this.queryPollToken)return;let J;try{J=await Q.readWorkspaceState(A)}catch(Y){T.warn("ide-client: query poll failed",{ideName:Q.ideName,error:Y}),J=null}if(B!==this.queryPollToken)return;if(!J){this.sendStatus({connected:!1,authenticated:!1,connectionState:"disconnected",errorMessage:`${Q.ideName} Not Connected`,openFile:void 0,selections:void 0,visibleFiles:void 0}),this.stopQueryPolling(),this.scheduleReconnect();return}this.sendStatus({connected:!0,authenticated:!0,connectionState:"connected",openFile:J.openFile,selections:J.selection?[J.selection]:void 0,visibleFiles:J.openFiles}),this.queryPollTimeout=setTimeout(()=>{$()},jK6)};$()}stopQueryPolling(){if(this.queryPollToken+=1,this.queryPollTimeout)clearTimeout(this.queryPollTimeout),this.queryPollTimeout=void 0}isWsOpen(){return this.ws?.readyState===1}async isConnected(){if(this.projectConfig?.connection==="query")return this._status.connected===!0;if(!this._status.authenticated)return!1;if(!this.isWsOpen())return!1;try{return(await this.sendRequest("ping",{message:"beepboop"}))?.message==="beepboop"}catch(A){return T.debug("isConnected ping failed",{error:A}),!1}}async requestDiagnosticsFromIDE(A){try{return await this.sendRequest("getDiagnostics",{path:A})}catch(Q){T.debug("ide-diags: failed to request diagnostics from IDE",{error:Q,path:A});return}}async openURIInIDE(A){if(this.projectConfig?.connection==="query")return this.querySource?.query.openURI(A);if(!this.isWsOpen())return;try{let Q=await this.sendRequest("openURI",{uri:A});if(!Q)return!1;return!!Q.success}catch(Q){return T.debug("ide-client: openURI request failed",{error:Q,uri:A}),!1}}handleNotification(A){if(!A)return;if(A.selectionDidChange)this.sendStatus({selections:A.selectionDidChange.selections,openFile:A.selectionDidChange.uri});else if(A.visibleFilesDidChange){let Q=A.visibleFilesDidChange.uris;this.sendStatus({visibleFiles:Q,...Q.length===0&&{openFile:void 0,selections:void 0}})}else if(A.pluginMetadata)this.sendStatus({pluginVersion:A.pluginMetadata.version,pluginDirectory:A.pluginMetadata.pluginDirectory})}async findQueryConfig(A){let B=(A.workspaceId?A:(await this.listQueryConfigs()).find((J)=>J.workspaceFolders.every((Y)=>A.workspaceFolders.includes(Y))))??(await ID({includeAll:!0})).find((J)=>J.connection==="query"&&J.workspaceId===A.workspaceId);if(!B)return{};let $=this.resolveQuery(B);if(!$)return{config:B};return{query:$,config:B}}async listQueryConfigs(){return(await Promise.all(aL.map(async(Q)=>{try{return await Q.listConfigs()}catch(B){return T.debug("ide-client: failed to list query configs",{ideName:Q.ideName,error:B}),[]}}))).flat()}resolveQuery(A){return aL.find((Q)=>Q.ideName===A.ideName)}selectConfig(A){this.projectConfig=A}getSelectedConfig(){return this.projectConfig}}async function RK6(){if(typeof WebSocket<"u")return WebSocket;let{default:A}=await Promise.resolve().then(() => (bc(),fc));return A}var A24=2000,LK6=1000,OK6=30000,jK6=1000,i8;var JW=J0(()=>{O1();h3();l0();sQ();g90();dq();ok();Ef0();i8=new Q24});var pf0,df0,cf0,uc;var $70=J0(()=>{pf0=class pf0 extends Error{constructor(A="Unauthorized"){super(A);this.name="UnauthorizedError"}};df0=class df0 extends Error{constructor(A="OAuth callback timeout"){super(A);this.name="OAuthTimeoutError"}};cf0=class cf0 extends Error{serverName;constructor(A){super(`OAuth flow skipped for "${A}"`);this.serverName=A;this.name="OAuthSkippedError"}};uc=class uc extends Error{serverName;holderPid;constructor(A,Q){super(`OAuth flow already in progress for "${A}" (held by PID ${Q})`);this.serverName=A;this.holderPid=Q;this.name="OAuthFlowInProgressError"}}});import{randomBytes as bK6}from"node:crypto";import*as $J from"node:fs/promises";import*as nf0 from"node:path";function Y24(A){return X70(A)}function hK6(A){return A.replace(/[^a-zA-Z0-9_-]/g,"_")}function X70(A){return nf0.join(J24,`${hK6(A)}.lock`)}async function gK6(){await $J.mkdir(J24,{recursive:!0,mode:448})}function mK6(A){try{return process.kill(A,0),!0}catch{return!1}}function if0(A){if(Date.now()-A.timestamp>uK6)return!0;let B=U0("node:os").hostname();if(A.hostname===B&&!mK6(A.pid))return!0;return!1}async function Y70(A){let Q=X70(A);try{let B=await $J.readFile(Q,"utf8"),$=JSON.parse(B);if(typeof $.pid!=="number"||typeof $.timestamp!=="number")return T.warn("Invalid lock file structure, treating as stale",{serverName:A,lockPath:Q}),null;return $}catch(B){if(B?.code==="ENOENT")return null;return T.debug("Failed to read lock file",{serverName:A,error:B.message}),null}}async function eL(A){await gK6();let Q=X70(A),B=await Y70(A);if(B)if(if0(B)){T.info("Removing stale OAuth lock",{serverName:A,stalePid:B.pid,ageMs:Date.now()-B.timestamp});try{await $J.unlink(Q)}catch{}}else return T.debug("OAuth lock held by another process",{serverName:A,holderPid:B.pid,ageMs:Date.now()-B.timestamp}),{acquired:!1,holder:B};let $={pid:process.pid,timestamp:Date.now(),hostname:U0("node:os").hostname()},J=JSON.stringify($),Y=`${Q}.${process.pid}.${bK6(4).toString("hex")}`;try{let Z=await $J.open(Y,"wx",384);try{await Z.writeFile(J),await Z.sync()}finally{await Z.close()}try{return await $J.link(Y,Q),await $J.unlink(Y).catch(()=>{}),T.info("Acquired OAuth lock",{serverName:A,pid:process.pid}),{acquired:!0}}catch(F){if(await $J.unlink(Y).catch(()=>{}),F?.code==="EEXIST"){let X=await Y70(A);if(X&&!if0(X))return T.debug("Lost OAuth lock race to another process",{serverName:A,winnerPid:X.pid}),{acquired:!1,holder:X};return eL(A)}throw F}}catch(Z){if(await $J.unlink(Y).catch(()=>{}),Z?.code==="EEXIST"){let F=await Y70(A);if(F&&!if0(F))return{acquired:!1,holder:F};return eL(A)}throw T.error("Failed to acquire OAuth lock",{serverName:A,error:Z.message}),Z}}async function Yv(A){let Q=X70(A);try{let B=await Y70(A);if(!B){T.debug("No lock to release",{serverName:A});return}if(B.pid!==process.pid){T.warn("Cannot release lock owned by another process",{serverName:A,ownerPid:B.pid,ourPid:process.pid});return}await $J.unlink(Q),T.info("Released OAuth lock",{serverName:A,pid:process.pid})}catch(B){if(B?.code==="ENOENT")return;T.error("Failed to release OAuth lock",{serverName:A,error:B.message})}}var J24,uK6=300000,Z70=2000,F70=300000;var af0=J0(()=>{KD();l0();J24=nf0.join(Ik,"oauth","locks")});function X24(A){return A.replace(/ /g,"\\ ")}var F24=100;var sf0=()=>{};var gc=y((mm8,G24)=>{var D24={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},lK6={...D24,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},iK6={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};G24.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:65536,POSIX_REGEX_SOURCE:iK6,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(A){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${A.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(A){return A===!0?lK6:D24}}});var mc=y((sK6)=>{var{REGEX_BACKSLASH:nK6,REGEX_REMOVE_BACKSLASH:aK6,REGEX_SPECIAL_CHARS:oK6,REGEX_SPECIAL_CHARS_GLOBAL:rK6}=gc();sK6.isObject=(A)=>A!==null&&typeof A==="object"&&!Array.isArray(A);sK6.hasRegexChars=(A)=>oK6.test(A);sK6.isRegexChar=(A)=>A.length===1&&sK6.hasRegexChars(A);sK6.escapeRegex=(A)=>A.replace(rK6,"\\$1");sK6.toPosixSlashes=(A)=>A.replace(nK6,"/");sK6.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let A=navigator.platform.toLowerCase();return A==="win32"||A==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};sK6.removeBackslashes=(A)=>{return A.replace(aK6,(Q)=>{return Q==="\\"?"":Q})};sK6.escapeLast=(A,Q,B)=>{let $=A.lastIndexOf(Q,B);if($===-1)return A;if(A[$-1]==="\\")return sK6.escapeLast(A,Q,$-1);return`${A.slice(0,$)}\\${A.slice($)}`};sK6.removePrefix=(A,Q={})=>{let B=A;if(B.startsWith("./"))B=B.slice(2),Q.prefix="./";return B};sK6.wrapOutput=(A,Q={},B={})=>{let $=B.contains?"":"^",J=B.contains?"":"$",Y=`${$}(?:${A})${J}`;if(Q.negated===!0)Y=`(?:^(?!${Y}).*$)`;return Y};sK6.basename=(A,{windows:Q}={})=>{let B=A.split(Q?/[\\/]/:"/"),$=B[B.length-1];if($==="")return B[B.length-2];return $}});var I24=y((dm8,N24)=>{var K24=mc(),{CHAR_ASTERISK:tf0,CHAR_AT:FE6,CHAR_BACKWARD_SLASH:pc,CHAR_COMMA:XE6,CHAR_DOT:ef0,CHAR_EXCLAMATION_MARK:Ab0,CHAR_FORWARD_SLASH:q24,CHAR_LEFT_CURLY_BRACE:Qb0,CHAR_LEFT_PARENTHESES:Bb0,CHAR_LEFT_SQUARE_BRACKET:DE6,CHAR_PLUS:GE6,CHAR_QUESTION_MARK:E24,CHAR_RIGHT_CURLY_BRACE:VE6,CHAR_RIGHT_PARENTHESES:W24,CHAR_RIGHT_SQUARE_BRACKET:UE6}=gc(),H24=(A)=>{return A===q24||A===pc},z24=(A)=>{if(A.isPrefix!==!0)A.depth=A.isGlobstar?1/0:1},KE6=(A,Q)=>{let B=Q||{},$=A.length-1,J=B.parts===!0||B.scanToEnd===!0,Y=[],Z=[],F=[],X=A,D=-1,G=0,V=0,U=!1,K=!1,E=!1,W=!1,H=!1,z=!1,q=!1,N=!1,I=!1,C=!1,w=0,M,j,P={value:"",depth:0,isGlob:!1},R=()=>D>=$,b=()=>X.charCodeAt(D+1),g=()=>{return M=j,X.charCodeAt(++D)};while(D<$){j=g();let p;if(j===pc){if(q=P.backslashes=!0,j=g(),j===Qb0)z=!0;continue}if(z===!0||j===Qb0){w++;while(R()!==!0&&(j=g())){if(j===pc){q=P.backslashes=!0,g();continue}if(j===Qb0){w++;continue}if(z!==!0&&j===ef0&&(j=g())===ef0){if(U=P.isBrace=!0,E=P.isGlob=!0,C=!0,J===!0)continue;break}if(z!==!0&&j===XE6){if(U=P.isBrace=!0,E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===VE6){if(w--,w===0){z=!1,U=P.isBrace=!0,C=!0;break}}}if(J===!0)continue;break}if(j===q24){if(Y.push(D),Z.push(P),P={value:"",depth:0,isGlob:!1},C===!0)continue;if(M===ef0&&D===G+1){G+=2;continue}V=D+1;continue}if(B.noext!==!0){if((j===GE6||j===FE6||j===tf0||j===E24||j===Ab0)===!0&&b()===Bb0){if(E=P.isGlob=!0,W=P.isExtglob=!0,C=!0,j===Ab0&&D===G)I=!0;if(J===!0){while(R()!==!0&&(j=g())){if(j===pc){q=P.backslashes=!0,j=g();continue}if(j===W24){E=P.isGlob=!0,C=!0;break}}continue}break}}if(j===tf0){if(M===tf0)H=P.isGlobstar=!0;if(E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===E24){if(E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===DE6){while(R()!==!0&&(p=g())){if(p===pc){q=P.backslashes=!0,g();continue}if(p===UE6){K=P.isBracket=!0,E=P.isGlob=!0,C=!0;break}}if(J===!0)continue;break}if(B.nonegate!==!0&&j===Ab0&&D===G){N=P.negated=!0,G++;continue}if(B.noparen!==!0&&j===Bb0){if(E=P.isGlob=!0,J===!0){while(R()!==!0&&(j=g())){if(j===Bb0){q=P.backslashes=!0,j=g();continue}if(j===W24){C=!0;break}}continue}break}if(E===!0){if(C=!0,J===!0)continue;break}}if(B.noext===!0)W=!1,E=!1;let f=X,k="",x="";if(G>0)k=X.slice(0,G),X=X.slice(G),V-=G;if(f&&E===!0&&V>0)f=X.slice(0,V),x=X.slice(V);else if(E===!0)f="",x=X;else f=X;if(f&&f!==""&&f!=="/"&&f!==X){if(H24(f.charCodeAt(f.length-1)))f=f.slice(0,-1)}if(B.unescape===!0){if(x)x=K24.removeBackslashes(x);if(f&&q===!0)f=K24.removeBackslashes(f)}let m={prefix:k,input:A,start:G,base:f,glob:x,isBrace:U,isBracket:K,isGlob:E,isExtglob:W,isGlobstar:H,negated:N,negatedExtglob:I};if(B.tokens===!0){if(m.maxDepth=0,!H24(j))Z.push(P);m.tokens=Z}if(B.parts===!0||B.tokens===!0){let p;for(let u=0;u<Y.length;u++){let a=p?p+1:G,c=Y[u],s=A.slice(a,c);if(B.tokens){if(u===0&&G!==0)Z[u].isPrefix=!0,Z[u].value=k;else Z[u].value=s;z24(Z[u]),m.maxDepth+=Z[u].depth}if(u!==0||s!=="")F.push(s);p=c}if(p&&p+1<A.length){let u=A.slice(p+1);if(F.push(u),B.tokens)Z[Z.length-1].value=u,z24(Z[Z.length-1]),m.maxDepth+=Z[Z.length-1].depth}m.slashes=Y,m.parts=F}return m};N24.exports=KE6});var O24=y((cm8,L24)=>{var dc=gc(),jY=mc(),{MAX_LENGTH:D70,POSIX_REGEX_SOURCE:EE6,REGEX_NON_SPECIAL_CHARS:WE6,REGEX_SPECIAL_CHARS_BACKREF:HE6,REPLACEMENTS:C24}=dc,zE6=(A,Q)=>{if(typeof Q.expandRange==="function")return Q.expandRange(...A,Q);A.sort();let B=`[${A.join("-")}]`;try{new RegExp(B)}catch($){return A.map((J)=>jY.escapeRegex(J)).join("..")}return B},Zv=(A,Q)=>{return`Missing ${A}: "${Q}" - use "\\\\${Q}" to match literal characters`},w24=(A)=>{let Q=[],B=0,$=0,J=0,Y="",Z=!1;for(let F of A){if(Z===!0){Y+=F,Z=!1;continue}if(F==="\\"){Y+=F,Z=!0;continue}if(F==='"'){J=J===1?0:1,Y+=F;continue}if(J===0){if(F==="[")B++;else if(F==="]"&&B>0)B--;else if(B===0){if(F==="(")$++;else if(F===")"&&$>0)$--;else if(F==="|"&&$===0){Q.push(Y),Y="";continue}}}Y+=F}return Q.push(Y),Q},qE6=(A)=>{let Q=!1;for(let B of A){if(Q===!0){Q=!1;continue}if(B==="\\"){Q=!0;continue}if(/[?*+@!()[\]{}]/.test(B))return!1}return!0},M24=(A)=>{let Q=A.trim(),B=!0;while(B===!0)if(B=!1,/^@\([^\\()[\]{}|]+\)$/.test(Q))Q=Q.slice(2,-1),B=!0;if(!qE6(Q))return;return Q.replace(/\\(.)/g,"$1")},NE6=(A)=>{let Q=A.map(M24).filter(Boolean);for(let B=0;B<Q.length;B++)for(let $=B+1;$<Q.length;$++){let J=Q[B],Y=Q[$],Z=J[0];if(!Z||J!==Z.repeat(J.length)||Y!==Z.repeat(Y.length))continue;if(J===Y||J.startsWith(Y)||Y.startsWith(J))return!0}return!1},$b0=(A,Q=!0)=>{if(A[0]!=="+"&&A[0]!=="*"||A[1]!=="(")return;let B=0,$=0,J=0,Y=!1;for(let Z=1;Z<A.length;Z++){let F=A[Z];if(Y===!0){Y=!1;continue}if(F==="\\"){Y=!0;continue}if(F==='"'){J=J===1?0:1;continue}if(J===1)continue;if(F==="["){B++;continue}if(F==="]"&&B>0){B--;continue}if(B>0)continue;if(F==="("){$++;continue}if(F===")"){if($--,$===0){if(Q===!0&&Z!==A.length-1)return;return{type:A[0],body:A.slice(2,Z),end:Z}}}}},IE6=(A)=>{let Q=0,B=[];while(Q<A.length){let J=$b0(A.slice(Q),!1);if(!J||J.type!=="*")return;let Y=w24(J.body).map((F)=>F.trim());if(Y.length!==1)return;let Z=M24(Y[0]);if(!Z||Z.length!==1)return;B.push(Z),Q+=J.end+1}if(B.length<1)return;return`${B.length===1?jY.escapeRegex(B[0]):`[${B.map((J)=>jY.escapeRegex(J)).join("")}]`}*`},CE6=(A)=>{let Q=0,B=A.trim(),$=$b0(B);while($)Q++,B=$.body.trim(),$=$b0(B);return Q},wE6=(A,Q)=>{if(Q.maxExtglobRecursion===!1)return{risky:!1};let B=typeof Q.maxExtglobRecursion==="number"?Q.maxExtglobRecursion:dc.DEFAULT_MAX_EXTGLOB_RECURSION,$=w24(A).map((J)=>J.trim());if($.length>1){if($.some((J)=>J==="")||$.some((J)=>/^[*?]+$/.test(J))||NE6($))return{risky:!0}}for(let J of $){let Y=IE6(J);if(Y)return{risky:!0,safeOutput:Y};if(CE6(J)>B)return{risky:!0}}return{risky:!1}},Jb0=(A,Q)=>{if(typeof A!=="string")throw TypeError("Expected a string");A=C24[A]||A;let B={...Q},$=typeof B.maxLength==="number"?Math.min(D70,B.maxLength):D70,J=A.length;if(J>$)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${$}`);let Y={type:"bos",value:"",output:B.prepend||""},Z=[Y],F=B.capture?"":"?:",X=dc.globChars(B.windows),D=dc.extglobChars(X),{DOT_LITERAL:G,PLUS_LITERAL:V,SLASH_LITERAL:U,ONE_CHAR:K,DOTS_SLASH:E,NO_DOT:W,NO_DOT_SLASH:H,NO_DOTS_SLASH:z,QMARK:q,QMARK_NO_DOT:N,STAR:I,START_ANCHOR:C}=X,w=(Z0)=>{return`(${F}(?:(?!${C}${Z0.dot?E:G}).)*?)`},M=B.dot?"":W,j=B.dot?q:N,P=B.bash===!0?w(B):I;if(B.capture)P=`(${P})`;if(typeof B.noext==="boolean")B.noextglob=B.noext;let R={input:A,index:-1,start:0,dot:B.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:Z};A=jY.removePrefix(A,R),J=A.length;let b=[],g=[],f=[],k=Y,x,m=()=>R.index===J-1,p=R.peek=(Z0=1)=>A[R.index+Z0],u=R.advance=()=>A[++R.index]||"",a=()=>A.slice(R.index+1),c=(Z0="",d=0)=>{R.consumed+=Z0,R.index+=d},s=(Z0)=>{R.output+=Z0.output!=null?Z0.output:Z0.value,c(Z0.value)},W0=()=>{let Z0=1;while(p()==="!"&&(p(2)!=="("||p(3)==="?"))u(),R.start++,Z0++;if(Z0%2===0)return!1;return R.negated=!0,R.start++,!0},i=(Z0)=>{R[Z0]++,f.push(Z0)},A0=(Z0)=>{R[Z0]--,f.pop()},D0=(Z0)=>{if(k.type==="globstar"){let d=R.braces>0&&(Z0.type==="comma"||Z0.type==="brace"),n=Z0.extglob===!0||b.length&&(Z0.type==="pipe"||Z0.type==="paren");if(Z0.type!=="slash"&&Z0.type!=="paren"&&!d&&!n)R.output=R.output.slice(0,-k.output.length),k.type="star",k.value="*",k.output=P,R.output+=k.output}if(b.length&&Z0.type!=="paren")b[b.length-1].inner+=Z0.value;if(Z0.value||Z0.output)s(Z0);if(k&&k.type==="text"&&Z0.type==="text"){k.output=(k.output||k.value)+Z0.value,k.value+=Z0.value;return}Z0.prev=k,Z.push(Z0),k=Z0},z0=(Z0,d)=>{let n={...D[d],conditions:1,inner:""};n.prev=k,n.parens=R.parens,n.output=R.output,n.startIndex=R.index,n.tokensIndex=Z.length;let o=(B.capture?"(":"")+n.open;i("parens"),D0({type:Z0,value:d,output:R.output?"":K}),D0({type:"paren",extglob:!0,value:u(),output:o}),b.push(n)},B0=(Z0)=>{let d=A.slice(Z0.startIndex,R.index+1),n=A.slice(Z0.startIndex+2,R.index),o=wE6(n,B);if((Z0.type==="plus"||Z0.type==="star")&&o.risky){let $0=o.safeOutput?(Z0.output?"":K)+(B.capture?`(${o.safeOutput})`:o.safeOutput):void 0,K0=Z[Z0.tokensIndex];K0.type="text",K0.value=d,K0.output=$0||jY.escapeRegex(d);for(let N0=Z0.tokensIndex+1;N0<Z.length;N0++)Z[N0].value="",Z[N0].output="",delete Z[N0].suffix;R.output=Z0.output+K0.output,R.backtrack=!0,D0({type:"paren",extglob:!0,value:x,output:""}),A0("parens");return}let e=Z0.close+(B.capture?")":""),Y0;if(Z0.type==="negate"){let $0=P;if(Z0.inner&&Z0.inner.length>1&&Z0.inner.includes("/"))$0=w(B);if($0!==P||m()||/^\)+$/.test(a()))e=Z0.close=`)$))${$0}`;if(Z0.inner.includes("*")&&(Y0=a())&&/^\.[^\\/.]+$/.test(Y0)){let K0=Jb0(Y0,{...Q,fastpaths:!1}).output;e=Z0.close=`)${K0})${$0})`}if(Z0.prev.type==="bos")R.negatedExtglob=!0}D0({type:"paren",extglob:!0,value:x,output:e}),A0("parens")};if(B.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(A)){let Z0=!1,d=A.replace(HE6,(n,o,e,Y0,$0,K0)=>{if(Y0==="\\")return Z0=!0,n;if(Y0==="?"){if(o)return o+Y0+($0?q.repeat($0.length):"");if(K0===0)return j+($0?q.repeat($0.length):"");return q.repeat(e.length)}if(Y0===".")return G.repeat(e.length);if(Y0==="*"){if(o)return o+Y0+($0?P:"");return P}return o?n:`\\${n}`});if(Z0===!0)if(B.unescape===!0)d=d.replace(/\\/g,"");else d=d.replace(/\\+/g,(n)=>{return n.length%2===0?"\\\\":n?"\\":""});if(d===A&&B.contains===!0)return R.output=A,R;return R.output=jY.wrapOutput(d,R,Q),R}while(!m()){if(x=u(),x==="\x00")continue;if(x==="\\"){let n=p();if(n==="/"&&B.bash!==!0)continue;if(n==="."||n===";")continue;if(!n){x+="\\",D0({type:"text",value:x});continue}let o=/^\\+/.exec(a()),e=0;if(o&&o[0].length>2){if(e=o[0].length,R.index+=e,e%2!==0)x+="\\"}if(B.unescape===!0)x=u();else x+=u();if(R.brackets===0){D0({type:"text",value:x});continue}}if(R.brackets>0&&(x!=="]"||k.value==="["||k.value==="[^")){if(B.posix!==!1&&x===":"){let n=k.value.slice(1);if(n.includes("[")){if(k.posix=!0,n.includes(":")){let o=k.value.lastIndexOf("["),e=k.value.slice(0,o),Y0=k.value.slice(o+2),$0=EE6[Y0];if($0){if(k.value=e+$0,R.backtrack=!0,u(),!Y.output&&Z.indexOf(k)===1)Y.output=K;continue}}}}if(x==="["&&p()!==":"||x==="-"&&p()==="]")x=`\\${x}`;if(x==="]"&&(k.value==="["||k.value==="[^"))x=`\\${x}`;if(B.posix===!0&&x==="!"&&k.value==="[")x="^";k.value+=x,s({value:x});continue}if(R.quotes===1&&x!=='"'){x=jY.escapeRegex(x),k.value+=x,s({value:x});continue}if(x==='"'){if(R.quotes=R.quotes===1?0:1,B.keepQuotes===!0)D0({type:"text",value:x});continue}if(x==="("){i("parens"),D0({type:"paren",value:x});continue}if(x===")"){if(R.parens===0&&B.strictBrackets===!0)throw SyntaxError(Zv("opening","("));let n=b[b.length-1];if(n&&R.parens===n.parens+1){B0(b.pop());continue}D0({type:"paren",value:x,output:R.parens?")":"\\)"}),A0("parens");continue}if(x==="["){if(B.nobracket===!0||!a().includes("]")){if(B.nobracket!==!0&&B.strictBrackets===!0)throw SyntaxError(Zv("closing","]"));x=`\\${x}`}else i("brackets");D0({type:"bracket",value:x});continue}if(x==="]"){if(B.nobracket===!0||k&&k.type==="bracket"&&k.value.length===1){D0({type:"text",value:x,output:`\\${x}`});continue}if(R.brackets===0){if(B.strictBrackets===!0)throw SyntaxError(Zv("opening","["));D0({type:"text",value:x,output:`\\${x}`});continue}A0("brackets");let n=k.value.slice(1);if(k.posix!==!0&&n[0]==="^"&&!n.includes("/"))x=`/${x}`;if(k.value+=x,s({value:x}),B.literalBrackets===!1||jY.hasRegexChars(n))continue;let o=jY.escapeRegex(k.value);if(R.output=R.output.slice(0,-k.value.length),B.literalBrackets===!0){R.output+=o,k.value=o;continue}k.value=`(${F}${o}|${k.value})`,R.output+=k.value;continue}if(x==="{"&&B.nobrace!==!0){i("braces");let n={type:"brace",value:x,output:"(",outputIndex:R.output.length,tokensIndex:R.tokens.length};g.push(n),D0(n);continue}if(x==="}"){let n=g[g.length-1];if(B.nobrace===!0||!n){D0({type:"text",value:x,output:x});continue}let o=")";if(n.dots===!0){let e=Z.slice(),Y0=[];for(let $0=e.length-1;$0>=0;$0--){if(Z.pop(),e[$0].type==="brace")break;if(e[$0].type!=="dots")Y0.unshift(e[$0].value)}o=zE6(Y0,B),R.backtrack=!0}if(n.comma!==!0&&n.dots!==!0){let e=R.output.slice(0,n.outputIndex),Y0=R.tokens.slice(n.tokensIndex);n.value=n.output="\\{",x=o="\\}",R.output=e;for(let $0 of Y0)R.output+=$0.output||$0.value}D0({type:"brace",value:x,output:o}),A0("braces"),g.pop();continue}if(x==="|"){if(b.length>0)b[b.length-1].conditions++;D0({type:"text",value:x});continue}if(x===","){let n=x,o=g[g.length-1];if(o&&f[f.length-1]==="braces")o.comma=!0,n="|";D0({type:"comma",value:x,output:n});continue}if(x==="/"){if(k.type==="dot"&&R.index===R.start+1){R.start=R.index+1,R.consumed="",R.output="",Z.pop(),k=Y;continue}D0({type:"slash",value:x,output:U});continue}if(x==="."){if(R.braces>0&&k.type==="dot"){if(k.value===".")k.output=G;let n=g[g.length-1];k.type="dots",k.output+=x,k.value+=x,n.dots=!0;continue}if(R.braces+R.parens===0&&k.type!=="bos"&&k.type!=="slash"){D0({type:"text",value:x,output:G});continue}D0({type:"dot",value:x,output:G});continue}if(x==="?"){if(!(k&&k.value==="(")&&B.noextglob!==!0&&p()==="("&&p(2)!=="?"){z0("qmark",x);continue}if(k&&k.type==="paren"){let o=p(),e=x;if(k.value==="("&&!/[!=<:]/.test(o)||o==="<"&&!/<([!=]|\w+>)/.test(a()))e=`\\${x}`;D0({type:"text",value:x,output:e});continue}if(B.dot!==!0&&(k.type==="slash"||k.type==="bos")){D0({type:"qmark",value:x,output:N});continue}D0({type:"qmark",value:x,output:q});continue}if(x==="!"){if(B.noextglob!==!0&&p()==="("){if(p(2)!=="?"||!/[!=<:]/.test(p(3))){z0("negate",x);continue}}if(B.nonegate!==!0&&R.index===0){W0();continue}}if(x==="+"){if(B.noextglob!==!0&&p()==="("&&p(2)!=="?"){z0("plus",x);continue}if(k&&k.value==="("||B.regex===!1){D0({type:"plus",value:x,output:V});continue}if(k&&(k.type==="bracket"||k.type==="paren"||k.type==="brace")||R.parens>0){D0({type:"plus",value:x});continue}D0({type:"plus",value:V});continue}if(x==="@"){if(B.noextglob!==!0&&p()==="("&&p(2)!=="?"){D0({type:"at",extglob:!0,value:x,output:""});continue}D0({type:"text",value:x});continue}if(x!=="*"){if(x==="$"||x==="^")x=`\\${x}`;let n=WE6.exec(a());if(n)x+=n[0],R.index+=n[0].length;D0({type:"text",value:x});continue}if(k&&(k.type==="globstar"||k.star===!0)){k.type="star",k.star=!0,k.value+=x,k.output=P,R.backtrack=!0,R.globstar=!0,c(x);continue}let Z0=a();if(B.noextglob!==!0&&/^\([^?]/.test(Z0)){z0("star",x);continue}if(k.type==="star"){if(B.noglobstar===!0){c(x);continue}let n=k.prev,o=n.prev,e=n.type==="slash"||n.type==="bos",Y0=o&&(o.type==="star"||o.type==="globstar");if(B.bash===!0&&(!e||Z0[0]&&Z0[0]!=="/")){D0({type:"star",value:x,output:""});continue}let $0=R.braces>0&&(n.type==="comma"||n.type==="brace"),K0=b.length&&(n.type==="pipe"||n.type==="paren");if(!e&&n.type!=="paren"&&!$0&&!K0){D0({type:"star",value:x,output:""});continue}while(Z0.slice(0,3)==="/**"){let N0=A[R.index+4];if(N0&&N0!=="/")break;Z0=Z0.slice(3),c("/**",3)}if(n.type==="bos"&&m()){k.type="globstar",k.value+=x,k.output=w(B),R.output=k.output,R.globstar=!0,c(x);continue}if(n.type==="slash"&&n.prev.type!=="bos"&&!Y0&&m()){R.output=R.output.slice(0,-(n.output+k.output).length),n.output=`(?:${n.output}`,k.type="globstar",k.output=w(B)+(B.strictSlashes?")":"|$)"),k.value+=x,R.globstar=!0,R.output+=n.output+k.output,c(x);continue}if(n.type==="slash"&&n.prev.type!=="bos"&&Z0[0]==="/"){let N0=Z0[1]!==void 0?"|$":"";R.output=R.output.slice(0,-(n.output+k.output).length),n.output=`(?:${n.output}`,k.type="globstar",k.output=`${w(B)}${U}|${U}${N0})`,k.value+=x,R.output+=n.output+k.output,R.globstar=!0,c(x+u()),D0({type:"slash",value:"/",output:""});continue}if(n.type==="bos"&&Z0[0]==="/"){k.type="globstar",k.value+=x,k.output=`(?:^|${U}|${w(B)}${U})`,R.output=k.output,R.globstar=!0,c(x+u()),D0({type:"slash",value:"/",output:""});continue}R.output=R.output.slice(0,-k.output.length),k.type="globstar",k.output=w(B),k.value+=x,R.output+=k.output,R.globstar=!0,c(x);continue}let d={type:"star",value:x,output:P};if(B.bash===!0){if(d.output=".*?",k.type==="bos"||k.type==="slash")d.output=M+d.output;D0(d);continue}if(k&&(k.type==="bracket"||k.type==="paren")&&B.regex===!0){d.output=x,D0(d);continue}if(R.index===R.start||k.type==="slash"||k.type==="dot"){if(k.type==="dot")R.output+=H,k.output+=H;else if(B.dot===!0)R.output+=z,k.output+=z;else R.output+=M,k.output+=M;if(p()!=="*")R.output+=K,k.output+=K}D0(d)}while(R.brackets>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing","]"));R.output=jY.escapeLast(R.output,"["),A0("brackets")}while(R.parens>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing",")"));R.output=jY.escapeLast(R.output,"("),A0("parens")}while(R.braces>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing","}"));R.output=jY.escapeLast(R.output,"{"),A0("braces")}if(B.strictSlashes!==!0&&(k.type==="star"||k.type==="bracket"))D0({type:"maybe_slash",value:"",output:`${U}?`});if(R.backtrack===!0){R.output="";for(let Z0 of R.tokens)if(R.output+=Z0.output!=null?Z0.output:Z0.value,Z0.suffix)R.output+=Z0.suffix}return R};Jb0.fastpaths=(A,Q)=>{let B={...Q},$=typeof B.maxLength==="number"?Math.min(D70,B.maxLength):D70,J=A.length;if(J>$)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${$}`);A=C24[A]||A;let{DOT_LITERAL:Y,SLASH_LITERAL:Z,ONE_CHAR:F,DOTS_SLASH:X,NO_DOT:D,NO_DOTS:G,NO_DOTS_SLASH:V,STAR:U,START_ANCHOR:K}=dc.globChars(B.windows),E=B.dot?G:D,W=B.dot?V:D,H=B.capture?"":"?:",z={negated:!1,prefix:""},q=B.bash===!0?".*?":U;if(B.capture)q=`(${q})`;let N=(M)=>{if(M.noglobstar===!0)return q;return`(${H}(?:(?!${K}${M.dot?X:Y}).)*?)`},I=(M)=>{switch(M){case"*":return`${E}${F}${q}`;case".*":return`${Y}${F}${q}`;case"*.*":return`${E}${q}${Y}${F}${q}`;case"*/*":return`${E}${q}${Z}${F}${W}${q}`;case"**":return E+N(B);case"**/*":return`(?:${E}${N(B)}${Z})?${W}${F}${q}`;case"**/*.*":return`(?:${E}${N(B)}${Z})?${W}${q}${Y}${F}${q}`;case"**/.*":return`(?:${E}${N(B)}${Z})?${Y}${F}${q}`;default:{let j=/^(.*?)\.(\w+)$/.exec(M);if(!j)return;let P=I(j[1]);if(!P)return;return P+Y+j[2]}}},C=jY.removePrefix(A,z),w=I(C);if(w&&B.strictSlashes!==!0)w+=`${Z}?`;return w};L24.exports=Jb0});var Zb0=y((lm8,R24)=>{var ME6=I24(),Yb0=O24(),j24=mc(),LE6=gc(),OE6=(A)=>A&&typeof A==="object"&&!Array.isArray(A),x2=(A,Q,B=!1)=>{if(Array.isArray(A)){let G=A.map((U)=>x2(U,Q,B));return(U)=>{for(let K of G){let E=K(U);if(E)return E}return!1}}let $=OE6(A)&&A.tokens&&A.input;if(A===""||typeof A!=="string"&&!$)throw TypeError("Expected pattern to be a non-empty string");let J=Q||{},Y=J.windows,Z=$?x2.compileRe(A,Q):x2.makeRe(A,Q,!1,!0),F=Z.state;delete Z.state;let X=()=>!1;if(J.ignore){let G={...Q,ignore:null,onMatch:null,onResult:null};X=x2(J.ignore,G,B)}let D=(G,V=!1)=>{let{isMatch:U,match:K,output:E}=x2.test(G,Z,Q,{glob:A,posix:Y}),W={glob:A,state:F,regex:Z,posix:Y,input:G,output:E,match:K,isMatch:U};if(typeof J.onResult==="function")J.onResult(W);if(U===!1)return W.isMatch=!1,V?W:!1;if(X(G)){if(typeof J.onIgnore==="function")J.onIgnore(W);return W.isMatch=!1,V?W:!1}if(typeof J.onMatch==="function")J.onMatch(W);return V?W:!0};if(B)D.state=F;return D};x2.test=(A,Q,B,{glob:$,posix:J}={})=>{if(typeof A!=="string")throw TypeError("Expected input to be a string");if(A==="")return{isMatch:!1,output:""};let Y=B||{},Z=Y.format||(J?j24.toPosixSlashes:null),F=A===$,X=F&&Z?Z(A):A;if(F===!1)X=Z?Z(A):A,F=X===$;if(F===!1||Y.capture===!0)if(Y.matchBase===!0||Y.basename===!0)F=x2.matchBase(A,Q,B,J);else F=Q.exec(X);return{isMatch:Boolean(F),match:F,output:X}};x2.matchBase=(A,Q,B)=>{return(Q instanceof RegExp?Q:x2.makeRe(Q,B)).test(j24.basename(A))};x2.isMatch=(A,Q,B)=>x2(Q,B)(A);x2.parse=(A,Q)=>{if(Array.isArray(A))return A.map((B)=>x2.parse(B,Q));return Yb0(A,{...Q,fastpaths:!1})};x2.scan=(A,Q)=>ME6(A,Q);x2.compileRe=(A,Q,B=!1,$=!1)=>{if(B===!0)return A.output;let J=Q||{},Y=J.contains?"":"^",Z=J.contains?"":"$",F=`${Y}(?:${A.output})${Z}`;if(A&&A.negated===!0)F=`^(?!${F}).*$`;let X=x2.toRegex(F,Q);if($===!0)X.state=A;return X};x2.makeRe=(A,Q={},B=!1,$=!1)=>{if(!A||typeof A!=="string")throw TypeError("Expected a non-empty string");let J={negated:!1,fastpaths:!0};if(Q.fastpaths!==!1&&(A[0]==="."||A[0]==="*"))J.output=Yb0.fastpaths(A,Q);if(!J.output)J=Yb0(A,Q);return x2.compileRe(J,Q,B,$)};x2.toRegex=(A,Q)=>{try{let B=Q||{};return new RegExp(A,B.flags||(B.nocase?"i":""))}catch(B){if(Q&&Q.debug===!0)throw B;return/$^/}};x2.constants=LE6;R24.exports=x2});var YW=y((im8,T24)=>{var P24=Zb0(),jE6=mc();function _24(A,Q,B=!1){if(Q&&(Q.windows===null||Q.windows===void 0))Q={...Q,windows:jE6.isWindows()};return P24(A,Q,B)}Object.assign(_24,P24);T24.exports=_24});function Db0(A){let Q=A;if(Q.startsWith("~/")){let B=process.env.HOME||process.env.USERPROFILE||"";Q=Q.replace("~/",`${B}/`)}else if(Q==="~")Q=process.env.HOME||process.env.USERPROFILE||"";if(Q=Q.replace(/%([^%]+)%/g,(B,$)=>{return process.env[$]||`%${$}%`}),Q.includes("%USERPROFILE%")&&process.env.USERPROFILE)Q=Q.replace(/%USERPROFILE%/g,process.env.USERPROFILE);return Z1.file(Q)}function Fb0(A,Q){let B=Db0(Q);if(B.path.includes("*")){let $=A.toString(),J=B.path;if(!J.startsWith("file://")){if(!J.startsWith("/"))J=`/${J}`;J=`file://${J}`}let Y=J.replace(/\./g,"\\.").replace(/\*\*/g,"§DOUBLESTAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLESTAR§/g,".*");return new RegExp(`^${Y}$`,"i").test($)}else return B.toString().toLowerCase()===A.toString().toLowerCase()}function S24(A,Q){return Q.some((B)=>Fb0(A,B))}async function RE6(A,Q){try{return await Q.realpath(A)}catch{}let B=[],$=A;while(!0){let J=G1.dirname($);if(J.toString()===$.toString())break;B.unshift(G1.basename($)),$=J;try{let Z=await Q.realpath($);for(let F of B)Z=G1.joinPath(Z,F);return Z}catch{}}return A}async function PE6(A,Q,B){try{let $=await RE6(A,Q),Y=[...["~/.config/AGENT.md"],...B];for(let Z of Y)if(Fb0($,Z)||Fb0(A,Z))return null;for(let{key:Z,pattern:F}of Xb0)if(S24($,F.patterns)||S24(A,F.patterns))return{key:Z,pattern:F};return null}catch{return null}}async function Gb0(A,Q,B){if(B?.dangerouslyAllowAll??!1)return{requiresConsent:!1};try{let J=await PE6(A,Q,B["guardedFiles.allowlist"]??[]);if(J)return{requiresConsent:!0,reason:`${J.pattern.description}`,toAllow:A.fsPath};return{requiresConsent:!1}}catch{return{requiresConsent:!0,reason:"Unable to resolve file path",toAllow:A.fsPath}}}var Xb0;var G70=J0(()=>{z4();Xb0=[{key:"cursor-config",pattern:{description:"Cursor Configuration",patterns:["**/.cursor/**","~/.cursor/**","~/Library/Application Support/Cursor/**","~/.config/Cursor/**","%APPDATA%/Cursor/**"]}},{key:"windsurf-config",pattern:{description:"Windsurf Configuration",patterns:["**/.windsurf/**","~/.codeium/windsurf/**","~/Library/Application Support/Windsurf/**","~/.config/Windsurf/**","%APPDATA%/Windsurf/**","/Library/Application Support/Windsurf/**","/etc/windsurf/**","%ProgramData%/Windsurf/**"]}},{key:"antigravity-config",pattern:{description:"Antigravity Configuration",patterns:["~/.gemini/**"]}},{key:"jetbrains-config",pattern:{description:"JetBrains IDE Configuration",patterns:["~/Library/Application Support/JetBrains/**","~/.config/JetBrains/**","~/.local/share/JetBrains/**","%APPDATA%/JetBrains/**","%LOCALAPPDATA%/JetBrains/**"]}},{key:"jetbrains-idea-config",pattern:{description:"JetBrains IDE Project Configuration",patterns:["**/.idea/**"]}},{key:"neovim-config",pattern:{description:"Neovim Configuration",patterns:["~/.config/nvim/**","~/.local/share/nvim/**","~/.local/state/nvim/**"]}},{key:"amp-settings",pattern:{description:"Amp Configuration Files",patterns:["**/amp.json","**/.amp/**"]}},{key:"shell-configs",pattern:{description:"Shell Configuration Files",patterns:["~/.bashrc","~/.zshrc","~/.fishrc","~/.cshrc","~/.tcshrc"]}},{key:"ssh-keys",pattern:{description:"SSH Keys and Configuration",patterns:["**/.ssh/**","~/.ssh/**"]}},{key:"gnupg-keys",pattern:{description:"GnuPG Keys and Configuration",patterns:["**/.gnupg/**","~/.gnupg/**"]}},{key:"environment-files",pattern:{description:"Environment Variable Files",patterns:["**/.env","**/.env.*"]}},{key:"claude-config",pattern:{description:"Claude AI Configuration",patterns:["**/.claude/**","~/.claude/**"]}},{key:"codex-config",pattern:{description:"Codex Configuration",patterns:["**/.codex/**","~/.codex/**"]}},{key:"git-internals",pattern:{description:"Git Internal Files",patterns:["**/.git/**"]}},{key:"kubernetes-config",pattern:{description:"Kubernetes Configuration",patterns:["**/.kube/**","~/.kube/**"]}},{key:"cache-directories",pattern:{description:"Cache Directories",patterns:["**/.cache/**","~/.cache/**"]}},{key:"windows-appdata",pattern:{description:"Windows Application Data",patterns:["%APPDATA%/**"]}},{key:"windows-system-directories",pattern:{description:"Windows System Directories",patterns:["%WINDIR%/**","%SYSTEMROOT%/**","%ProgramFiles%/**","%ProgramFiles(x86)%/**","%ProgramData%/**"]}},{key:"sqlite3-files",pattern:{description:"SQLite Database Files",patterns:["**/*.db","**/*.sqlite","**/*.sqlite3"]}},{key:"common-configuration-patterns",pattern:{description:"Configuration Directories",patterns:["~/.*","~/.*/**","~/.config/**","~/Library/**","~/Library/Preferences/**"]}},{key:"macos-applications",pattern:{description:"macOS Applications",patterns:["/Applications/**","~/Applications/**"]}},{key:"macos-system-library",pattern:{description:"macOS System Library",patterns:["/Library/**"]}},{key:"unix-system-directories",pattern:{description:"Unix System Directories",patterns:["/usr/**","/bin/**","/sbin/**","/lib/**","/lib64/**","/boot/**"]}},{key:"system-config-directories",pattern:{description:"System Configuration and State",patterns:["/private/etc/**","/etc/**","/private/var/**","/var/**"]}},{key:"opt-directory",pattern:{description:"Optional Software Installs (/opt, e.g., Homebrew)",patterns:["/opt/**"]}}]});function _E6(){if(ZW.size===0)return;T.info("Killing all child processes");for(let A of ZW)Vb0(A);ZW.clear(),T.info("All child processes killed")}function Vb0(A){if(!A.pid){try{A.kill("SIGKILL")}catch(Q){T.error("Failed to kill process without PID",Q)}return}if(cc.has(A.pid)){T.debug(`Process ${A.pid} already being killed, skipping`);return}cc.add(A.pid);try{if(process.platform==="win32"){let{spawn:Q}=U0("node:child_process"),B=Q("taskkill",["/F","/T","/PID",A.pid.toString()],{stdio:"ignore"});B.on("error",($)=>{T.error(`Failed to kill Windows process tree ${A.pid}`,$);try{A.kill("SIGKILL")}catch(J){T.error(`Fallback kill also failed for ${A.pid}`,J)}}),B.on("exit",()=>{cc.delete(A.pid)})}else{try{process.kill(A.pid,0),process.kill(-A.pid,"SIGKILL")}catch(Q){T.debug(`Process ${A.pid} no longer exists, skipping kill`)}cc.delete(A.pid)}}catch(Q){T.error(`Failed to kill process ${A.pid}`,Q),cc.delete(A.pid)}}function Ub0(A){Vb0(A),ZW.delete(A)}function k24(A){ZW.add(A)}function TE6(A){let Q={...A,detached:process.platform!=="win32",env:{...process.env,...A?.env||{},NONINTERACTIVE:"1",DEBIAN_FRONTEND:"noninteractive"}};if(!Q.stdio)Q.stdio=["pipe","pipe","pipe"];return Q}function Kb0(...A){return new g0((Q)=>{let B=!1,$,J=!1;return(async()=>{try{let{spawn:Z}=await import("node:child_process");if(B)return;$=Z(A[0],A[1],TE6(A[2])),ZW.add($),$.on("spawn",()=>{Q.next({type:"spawn",pid:$?.pid,process:$})}),$.stdout?.on("data",(F)=>{if(B||J)return;Q.next({type:"data",stream:"stdout",chunk:Buffer.isBuffer(F)?F:Buffer.from(String(F)),pid:$?.pid,process:$})}),$.stderr?.on("data",(F)=>{if(B||J)return;Q.next({type:"data",stream:"stderr",chunk:Buffer.isBuffer(F)?F:Buffer.from(String(F)),pid:$?.pid,process:$})}),$.on("exit",(F)=>{if(B||J)return;Q.next({type:"exit",exitCode:F})}),$.on("close",(F)=>{if(B)return;if(J)return;if(J=!0,Q.next({type:"close",exitCode:F}),Q.complete(),$)ZW.delete($)}),$.on("error",(F)=>{if(B||J)return;if(J=!0,Q.error(F),$)ZW.delete($)})}catch(Z){if(B)return;Q.error(Z)}})(),()=>{if(B=!0,$&&!J)Vb0($),ZW.delete($)}})}function FW(...A){return new g0((Q)=>{let B={stdout:"",stderr:"",combinedOutput:"",exitCode:null,exited:!1},$=Kb0(...A).subscribe({next:(J)=>{switch(J.type){case"spawn":B.pid=J.pid,B.process=J.process,Q.next({...B,process:J.process});break;case"data":{let Y=J.chunk.toString();if(J.stream==="stdout")B.stdout+=Y;else B.stderr+=Y;B.combinedOutput+=Y,B.lastData=J.chunk,Q.next({...B,process:J.process??B.process});break}case"exit":B.exitCode=J.exitCode??-1,B.exited=!0;break;case"close":if(B.exitCode===null)B.exitCode=J.exitCode??-1;B.exited=!0,B.lastData=void 0,Q.next({...B,process:B.process}),Q.complete();break}},error:(J)=>Q.error(J)});return()=>$.unsubscribe()})}function V70(A){if(typeof A!=="string")throw Error("arg is not a string");if(A.startsWith("-"))throw Error("arg is not safe")}function U70(A){if(!A)throw Error("tool requires a working directory");if(A.scheme!=="file")throw Error(`tool requires a dir with a file: URI (got ${JSON.stringify(A.scheme)})`)}var ZW,cc;var XW=J0(()=>{O1();l0();ZW=new Set,cc=new Set;if(typeof process<"u")process.on("exit",()=>{_E6()})});function QO(A,Q){if(Q==="")return!1;let B=A.toLowerCase(),$=Q.toLowerCase();if($.length===1){if($==="*")return!0;return $===B}if(B===$)return!0;if($.includes("*")||$.includes("?")||$.includes("[")||$.includes("{"))try{return v24.default($,{dot:!0})(B)}catch(J){return!1}return!1}function Eb0(A,Q){let B=Q.split("."),$=A;for(let J of B){if($===null||$===void 0)return;if(Array.isArray($)){let Y=parseInt(J,10);if(isNaN(Y)||Y<0||Y>=$.length)return;$=$[Y]}else if(typeof $==="object")$=$[J];else return}return $}function SE6(A,Q,B,$){if(!QO(Q,A.tool))return!1;if(A.context&&A.context!==$)return!1;if(!A.matches||Object.keys(A.matches).length===0)return!0;return Object.entries(A.matches).every(([J,Y])=>{if(Y===void 0){if(J.includes("."))return Eb0(B,J)===void 0;return J in B&&B[J]===void 0}let Z=J.includes(".")?Eb0(B,J):B[J];return K70(Z,Y)})}async function kE6(A,Q,B,$,J,Y){if(A.action!=="delegate"){if(A.action==="reject"&&A.message)return{action:A.action,matchedEntry:A,error:A.message};return{action:A.action,matchedEntry:A}}if(!B||!A.to)return{action:null,matchedEntry:A,error:"No spawn function provided"};try{let Z=await vE6(A.to,Q,B,$,J,Y);return yE6(Z,A)}catch(Z){return{action:"reject",error:Z instanceof Error?Z.message:"Unknown error",matchedEntry:A}}}async function vE6(A,Q,B,$,J,Y){let Z={AGENT:"amp"};if($)Z.AMP_THREAD_ID=$;if(J)Z.AGENT_TOOL_NAME=J;if(Y)Z.AGENT_TOOL_USE_ID=Y;let X=A.includes("~")||A.includes("%")?Db0(A).path:A,G=B(X,[],{env:Z});return new Promise((V,U)=>{let K;G.subscribe({next:(E)=>{if(typeof E==="object"&&E!==null&&"status"in E&&E.status==="error"){U(Error("Delegate command timed out after 10 seconds"));return}if(E.process&&!E.exited)E.process.stdin?.write(JSON.stringify(Q)),E.process.stdin?.end();K=E},complete:()=>{if(K?.exited)V({exitCode:K.exitCode??-1,stdout:K.stdout,stderr:K.stderr});else U(Error("Process did not exit properly"))},error:(E)=>{U(E)}})})}function yE6({exitCode:A,stderr:Q},B){switch(A){case 0:return{action:"allow",matchedEntry:B};case 1:return{action:"ask",matchedEntry:B};default:return{action:"reject",matchedEntry:B,error:Q}}}async function Fv(A,Q,B,$,J,Y,Z,F){let X=0;for(let D of B)try{if(!SE6(D,A,Q,$)){X=X+1;continue}let G=await kE6(D,Q,J,Y,A,F);if(G.matchIndex=X,Z)G.source=Z;return G}catch(G){return{action:null,error:G instanceof Error?G.message:"Unknown error"}}return{action:null}}function K70(A,Q){if(typeof Q==="string"){if(typeof A!=="string")return!1;return fE6(A,Q)}if(Array.isArray(Q))return Q.some((B)=>{if(typeof B==="string")return typeof A==="string"&&Wb0(A,B);return A===B});if(typeof Q==="object"&&Q!==null)return xE6(A,Q);return A===Q}function xE6(A,Q){if(Object.keys(Q).length===0)return typeof A==="object"&&A!==null;if(typeof A!=="object"||A===null)return!1;for(let[B,$]of Object.entries(Q)){let J=Eb0(A,B);if(!K70(J,$))return!1}return!0}function fE6(A,Q){if(typeof Q==="string")return Wb0(A,Q);if(Array.isArray(Q))return Q.some((B)=>typeof B==="string"&&Wb0(A,B));return!1}function Wb0(A,Q){if(Q.length>=3&&Q.startsWith("/")&&Q.endsWith("/"))try{let J=Q.slice(1,-1);return new RegExp(J,"m").test(A)}catch(J){throw Error(`Invalid regex pattern: ${Q}`)}if(Q==="*")return!0;if(!Q.includes("*"))return A===Q;let B=Q.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${B}$`,"m").test(A)}var v24,lc;var Xv=J0(()=>{G70();XW();v24=H4(YW(),1),lc=FW});function ic(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let B=Array.isArray(A),$=Array.isArray(Q);if(B!==$)return!1;if(B&&$)return A.length===Q.length&&A.every((Y,Z)=>ic(Y,Q[Z]));let J=new Set([...Object.keys(A),...Object.keys(Q)]);for(let Y of J)if(!ic(A[Y],Q[Y]))return!1;return!0}function Ev(A){let Q=A.length;while(--Q>=0)A[Q]=0}function zb0(A,Q,B,$,J){this.static_tree=A,this.extra_bits=Q,this.extra_base=B,this.elems=$,this.max_length=J,this.has_stree=A&&A.length}function qb0(A,Q){this.dyn_tree=A,this.max_code=0,this.stat_desc=Q}function eV(A,Q,B,$,J){this.good_length=A,this.max_lazy=Q,this.nice_length=B,this.max_chain=$,this.func=J}function uW6(){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=M70,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(_W6*2),this.dyn_dtree=new Uint16Array((2*RW6+1)*2),this.bl_tree=new Uint16Array((2*PW6+1)*2),aq(this.dyn_ltree),aq(this.dyn_dtree),aq(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(TW6+1),this.heap=new Uint16Array(2*vb0+1),aq(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*vb0+1),aq(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 ZH6(){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 Dl(A){this.options=L70.assign({level:UH6,method:EH6,chunkSize:16384,windowBits:15,memLevel:8,strategy:KH6},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 h94,this.strm.avail_out=0;let B=sc.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(B!==C70)throw Error(YO[B]);if(Q.header)sc.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let $;if(typeof Q.dictionary==="string")$=Yl.string2buf(Q.dictionary);else if(g94.call(Q.dictionary)==="[object ArrayBuffer]")$=new Uint8Array(Q.dictionary);else $=Q.dictionary;if(B=sc.deflateSetDictionary(this.strm,$),B!==C70)throw Error(YO[B]);this._dict_set=!0}}function cb0(A,Q){let B=new Dl(Q);if(B.push(A,!0),B.err)throw B.msg||YO[B.err];return B.result}function WH6(A,Q){return Q=Q||{},Q.raw=!0,cb0(A,Q)}function HH6(A,Q){return Q=Q||{},Q.gzip=!0,cb0(A,Q)}function hH6(){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 Bz6(){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 Gl(A){this.options=L70.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 h94,this.strm.avail_out=0;let B=VW.inflateInit2(this.strm,Q.windowBits);if(B!==Zl)throw Error(YO[B]);if(this.header=new $z6,VW.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=Yl.string2buf(Q.dictionary);else if(t94.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(B=VW.inflateSetDictionary(this.strm,Q.dictionary),B!==Zl)throw Error(YO[B])}}}function lb0(A,Q){let B=new Gl(Q);if(B.push(A),B.err)throw B.msg||YO[B.err];return B.result}function Xz6(A,Q){return Q=Q||{},Q.raw=!0,lb0(A,Q)}var bE6=0,q94=1,uE6=2,hE6=3,gE6=258,hb0=29,Fl=256,ec,Vv=30,gb0=19,N94,BO=15,Hb0=16,mE6=7,mb0=256,I94=16,C94=17,w94=18,Tb0,N70,pE6,M94,dE6=512,GW,rc,Al,Ql,pb0,I70,L94,O94,j94,R94=(A)=>{return A<256?Al[A]:Al[256+(A>>>7)]},Bl=(A,Q)=>{A.pending_buf[A.pending++]=Q&255,A.pending_buf[A.pending++]=Q>>>8&255},JJ=(A,Q,B)=>{if(A.bi_valid>Hb0-B)A.bi_buf|=Q<<A.bi_valid&65535,Bl(A,A.bi_buf),A.bi_buf=Q>>Hb0-A.bi_valid,A.bi_valid+=B-Hb0;else A.bi_buf|=Q<<A.bi_valid&65535,A.bi_valid+=B},AU=(A,Q,B)=>{JJ(A,B[Q*2],B[Q*2+1])},P94=(A,Q)=>{let B=0;do B|=A&1,A>>>=1,B<<=1;while(--Q>0);return B>>>1},cE6=(A)=>{if(A.bi_valid===16)Bl(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},lE6=(A,Q)=>{let{dyn_tree:B,max_code:$}=Q,J=Q.stat_desc.static_tree,Y=Q.stat_desc.has_stree,Z=Q.stat_desc.extra_bits,F=Q.stat_desc.extra_base,X=Q.stat_desc.max_length,D,G,V,U,K,E,W=0;for(U=0;U<=BO;U++)A.bl_count[U]=0;B[A.heap[A.heap_max]*2+1]=0;for(D=A.heap_max+1;D<N94;D++){if(G=A.heap[D],U=B[B[G*2+1]*2+1]+1,U>X)U=X,W++;if(B[G*2+1]=U,G>$)continue;if(A.bl_count[U]++,K=0,G>=F)K=Z[G-F];if(E=B[G*2],A.opt_len+=E*(U+K),Y)A.static_len+=E*(J[G*2+1]+K)}if(W===0)return;do{U=X-1;while(A.bl_count[U]===0)U--;A.bl_count[U]--,A.bl_count[U+1]+=2,A.bl_count[X]--,W-=2}while(W>0);for(U=X;U!==0;U--){G=A.bl_count[U];while(G!==0){if(V=A.heap[--D],V>$)continue;if(B[V*2+1]!==U)A.opt_len+=(U-B[V*2+1])*B[V*2],B[V*2+1]=U;G--}}},_94=(A,Q,B)=>{let $=Array(BO+1),J=0,Y,Z;for(Y=1;Y<=BO;Y++)J=J+B[Y-1]<<1,$[Y]=J;for(Z=0;Z<=Q;Z++){let F=A[Z*2+1];if(F===0)continue;A[Z*2]=P94($[F]++,F)}},iE6=()=>{let A,Q,B,$,J,Y=Array(BO+1);B=0;for($=0;$<hb0-1;$++){pb0[$]=B;for(A=0;A<1<<Tb0[$];A++)Ql[B++]=$}Ql[B-1]=$,J=0;for($=0;$<16;$++){I70[$]=J;for(A=0;A<1<<N70[$];A++)Al[J++]=$}J>>=7;for(;$<Vv;$++){I70[$]=J<<7;for(A=0;A<1<<N70[$]-7;A++)Al[256+J++]=$}for(Q=0;Q<=BO;Q++)Y[Q]=0;A=0;while(A<=143)GW[A*2+1]=8,A++,Y[8]++;while(A<=255)GW[A*2+1]=9,A++,Y[9]++;while(A<=279)GW[A*2+1]=7,A++,Y[7]++;while(A<=287)GW[A*2+1]=8,A++,Y[8]++;_94(GW,ec+1,Y);for(A=0;A<Vv;A++)rc[A*2+1]=5,rc[A*2]=P94(A,5);L94=new zb0(GW,Tb0,Fl+1,ec,BO),O94=new zb0(rc,N70,0,Vv,BO),j94=new zb0([],pE6,0,gb0,mE6)},T94=(A)=>{let Q;for(Q=0;Q<ec;Q++)A.dyn_ltree[Q*2]=0;for(Q=0;Q<Vv;Q++)A.dyn_dtree[Q*2]=0;for(Q=0;Q<gb0;Q++)A.bl_tree[Q*2]=0;A.dyn_ltree[mb0*2]=1,A.opt_len=A.static_len=0,A.sym_next=A.matches=0},S94=(A)=>{if(A.bi_valid>8)Bl(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},y24=(A,Q,B,$)=>{let J=Q*2,Y=B*2;return A[J]<A[Y]||A[J]===A[Y]&&$[Q]<=$[B]},Nb0=(A,Q,B)=>{let $=A.heap[B],J=B<<1;while(J<=A.heap_len){if(J<A.heap_len&&y24(Q,A.heap[J+1],A.heap[J],A.depth))J++;if(y24(Q,$,A.heap[J],A.depth))break;A.heap[B]=A.heap[J],B=J,J<<=1}A.heap[B]=$},x24=(A,Q,B)=>{let $,J,Y=0,Z,F;if(A.sym_next!==0)do if($=A.pending_buf[A.sym_buf+Y++]&255,$+=(A.pending_buf[A.sym_buf+Y++]&255)<<8,J=A.pending_buf[A.sym_buf+Y++],$===0)AU(A,J,Q);else{if(Z=Ql[J],AU(A,Z+Fl+1,Q),F=Tb0[Z],F!==0)J-=pb0[Z],JJ(A,J,F);if($--,Z=R94($),AU(A,Z,B),F=N70[Z],F!==0)$-=I70[Z],JJ(A,$,F)}while(Y<A.sym_next);AU(A,mb0,Q)},Sb0=(A,Q)=>{let B=Q.dyn_tree,$=Q.stat_desc.static_tree,J=Q.stat_desc.has_stree,Y=Q.stat_desc.elems,Z,F,X=-1,D;A.heap_len=0,A.heap_max=N94;for(Z=0;Z<Y;Z++)if(B[Z*2]!==0)A.heap[++A.heap_len]=X=Z,A.depth[Z]=0;else B[Z*2+1]=0;while(A.heap_len<2)if(D=A.heap[++A.heap_len]=X<2?++X:0,B[D*2]=1,A.depth[D]=0,A.opt_len--,J)A.static_len-=$[D*2+1];Q.max_code=X;for(Z=A.heap_len>>1;Z>=1;Z--)Nb0(A,B,Z);D=Y;do Z=A.heap[1],A.heap[1]=A.heap[A.heap_len--],Nb0(A,B,1),F=A.heap[1],A.heap[--A.heap_max]=Z,A.heap[--A.heap_max]=F,B[D*2]=B[Z*2]+B[F*2],A.depth[D]=(A.depth[Z]>=A.depth[F]?A.depth[Z]:A.depth[F])+1,B[Z*2+1]=B[F*2+1]=D,A.heap[1]=D++,Nb0(A,B,1);while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],lE6(A,Q),_94(B,X,A.bl_count)},f24=(A,Q,B)=>{let $,J=-1,Y,Z=Q[1],F=0,X=7,D=4;if(Z===0)X=138,D=3;Q[(B+1)*2+1]=65535;for($=0;$<=B;$++){if(Y=Z,Z=Q[($+1)*2+1],++F<X&&Y===Z)continue;else if(F<D)A.bl_tree[Y*2]+=F;else if(Y!==0){if(Y!==J)A.bl_tree[Y*2]++;A.bl_tree[I94*2]++}else if(F<=10)A.bl_tree[C94*2]++;else A.bl_tree[w94*2]++;if(F=0,J=Y,Z===0)X=138,D=3;else if(Y===Z)X=6,D=3;else X=7,D=4}},b24=(A,Q,B)=>{let $,J=-1,Y,Z=Q[1],F=0,X=7,D=4;if(Z===0)X=138,D=3;for($=0;$<=B;$++){if(Y=Z,Z=Q[($+1)*2+1],++F<X&&Y===Z)continue;else if(F<D)do AU(A,Y,A.bl_tree);while(--F!==0);else if(Y!==0){if(Y!==J)AU(A,Y,A.bl_tree),F--;AU(A,I94,A.bl_tree),JJ(A,F-3,2)}else if(F<=10)AU(A,C94,A.bl_tree),JJ(A,F-3,3);else AU(A,w94,A.bl_tree),JJ(A,F-11,7);if(F=0,J=Y,Z===0)X=138,D=3;else if(Y===Z)X=6,D=3;else X=7,D=4}},nE6=(A)=>{let Q;f24(A,A.dyn_ltree,A.l_desc.max_code),f24(A,A.dyn_dtree,A.d_desc.max_code),Sb0(A,A.bl_desc);for(Q=gb0-1;Q>=3;Q--)if(A.bl_tree[M94[Q]*2+1]!==0)break;return A.opt_len+=3*(Q+1)+5+5+4,Q},aE6=(A,Q,B,$)=>{let J;JJ(A,Q-257,5),JJ(A,B-1,5),JJ(A,$-4,4);for(J=0;J<$;J++)JJ(A,A.bl_tree[M94[J]*2+1],3);b24(A,A.dyn_ltree,Q-1),b24(A,A.dyn_dtree,B-1)},oE6=(A)=>{let Q=4093624447,B;for(B=0;B<=31;B++,Q>>>=1)if(Q&1&&A.dyn_ltree[B*2]!==0)return 0;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return 1;for(B=32;B<Fl;B++)if(A.dyn_ltree[B*2]!==0)return 1;return 0},u24=!1,rE6=(A)=>{if(!u24)iE6(),u24=!0;A.l_desc=new qb0(A.dyn_ltree,L94),A.d_desc=new qb0(A.dyn_dtree,O94),A.bl_desc=new qb0(A.bl_tree,j94),A.bi_buf=0,A.bi_valid=0,T94(A)},k94=(A,Q,B,$)=>{if(JJ(A,(bE6<<1)+($?1:0),3),S94(A),Bl(A,B),Bl(A,~B),B)A.pending_buf.set(A.window.subarray(Q,Q+B),A.pending);A.pending+=B},sE6=(A)=>{JJ(A,q94<<1,3),AU(A,mb0,GW),cE6(A)},tE6=(A,Q,B,$)=>{let J,Y,Z=0;if(A.level>0){if(A.strm.data_type===2)A.strm.data_type=oE6(A);if(Sb0(A,A.l_desc),Sb0(A,A.d_desc),Z=nE6(A),J=A.opt_len+3+7>>>3,Y=A.static_len+3+7>>>3,Y<=J)J=Y}else J=Y=B+5;if(B+4<=J&&Q!==-1)k94(A,Q,B,$);else if(A.strategy===4||Y===J)JJ(A,(q94<<1)+($?1:0),3),x24(A,GW,rc);else JJ(A,(uE6<<1)+($?1:0),3),aE6(A,A.l_desc.max_code+1,A.d_desc.max_code+1,Z+1),x24(A,A.dyn_ltree,A.dyn_dtree);if(T94(A),$)S94(A)},eE6=(A,Q,B)=>{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++]=B,Q===0)A.dyn_ltree[B*2]++;else A.matches++,Q--,A.dyn_ltree[(Ql[B]+Fl+1)*2]++,A.dyn_dtree[R94(Q)*2]++;return A.sym_next===A.sym_end},AW6,QW6,BW6,$W6,JW6,YW6,ZW6=(A,Q,B,$)=>{let J=A&65535|0,Y=A>>>16&65535|0,Z=0;while(B!==0){Z=B>2000?2000:B,B-=Z;do J=J+Q[$++]|0,Y=Y+J|0;while(--Z);J%=65521,Y%=65521}return J|Y<<16|0},$l,FW6=()=>{let A,Q=[];for(var B=0;B<256;B++){A=B;for(var $=0;$<8;$++)A=A&1?3988292384^A>>>1:A>>>1;Q[B]=A}return Q},XW6,DW6=(A,Q,B,$)=>{let J=XW6,Y=$+B;A^=-1;for(let Z=$;Z<Y;Z++)A=A>>>8^J[(A^Q[Z])&255];return A^-1},z7,YO,XO,GW6,kb0,VW6,rq,UW6,sq,KW6,EW6,qF,h24,UQ,g24,QU,WW6,Ib0,HW6,zW6,E70,qW6,NW6,IW6,CW6,M70,wW6=9,MW6=15,LW6=8,OW6=29,jW6=256,vb0,RW6=30,PW6=19,_W6,TW6=15,F5=3,oq=258,BU,SW6=32,Uv=42,db0=57,yb0=69,xb0=73,fb0=91,bb0=103,$O=113,ac=666,iB=1,Wv=2,ZO=3,Hv=4,kW6=3,JO=(A,Q)=>{return A.msg=YO[Q],Q},m24=(A)=>{return A*2-(A>4?9:0)},aq=(A)=>{let Q=A.length;while(--Q>=0)A[Q]=0},vW6=(A)=>{let Q,B,$,J=A.w_size;Q=A.hash_size,$=Q;do B=A.head[--$],A.head[$]=B>=J?B-J:0;while(--Q);Q=J,$=Q;do B=A.prev[--$],A.prev[$]=B>=J?B-J:0;while(--Q)},yW6=(A,Q,B)=>(Q<<A.hash_shift^B)&A.hash_mask,tq,RY=(A)=>{let Q=A.state,B=Q.pending;if(B>A.avail_out)B=A.avail_out;if(B===0)return;if(A.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+B),A.next_out),A.next_out+=B,Q.pending_out+=B,A.total_out+=B,A.avail_out-=B,Q.pending-=B,Q.pending===0)Q.pending_out=0},PY=(A,Q)=>{VW6(A,A.block_start>=0?A.block_start:-1,A.strstart-A.block_start,Q),A.block_start=A.strstart,RY(A.strm)},l5=(A,Q)=>{A.pending_buf[A.pending++]=Q},nc=(A,Q)=>{A.pending_buf[A.pending++]=Q>>>8&255,A.pending_buf[A.pending++]=Q&255},ub0=(A,Q,B,$)=>{let J=A.avail_in;if(J>$)J=$;if(J===0)return 0;if(A.avail_in-=J,Q.set(A.input.subarray(A.next_in,A.next_in+J),B),A.state.wrap===1)A.adler=$l(A.adler,Q,J,B);else if(A.state.wrap===2)A.adler=z7(A.adler,Q,J,B);return A.next_in+=J,A.total_in+=J,J},v94=(A,Q)=>{let{max_chain_length:B,strstart:$}=A,J,Y,Z=A.prev_length,F=A.nice_match,X=A.strstart>A.w_size-BU?A.strstart-(A.w_size-BU):0,D=A.window,G=A.w_mask,V=A.prev,U=A.strstart+oq,K=D[$+Z-1],E=D[$+Z];if(A.prev_length>=A.good_match)B>>=2;if(F>A.lookahead)F=A.lookahead;do{if(J=Q,D[J+Z]!==E||D[J+Z-1]!==K||D[J]!==D[$]||D[++J]!==D[$+1])continue;$+=2,J++;do;while(D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&$<U);if(Y=oq-(U-$),$=U-oq,Y>Z){if(A.match_start=Q,Z=Y,Y>=F)break;K=D[$+Z-1],E=D[$+Z]}}while((Q=V[Q&G])>X&&--B!==0);if(Z<=A.lookahead)return Z;return A.lookahead},Kv=(A)=>{let Q=A.w_size,B,$,J;do{if($=A.window_size-A.lookahead-A.strstart,A.strstart>=Q+(Q-BU)){if(A.window.set(A.window.subarray(Q,Q+Q-$),0),A.match_start-=Q,A.strstart-=Q,A.block_start-=Q,A.insert>A.strstart)A.insert=A.strstart;vW6(A),$+=Q}if(A.strm.avail_in===0)break;if(B=ub0(A.strm,A.window,A.strstart+A.lookahead,$),A.lookahead+=B,A.lookahead+A.insert>=F5){J=A.strstart-A.insert,A.ins_h=A.window[J],A.ins_h=tq(A,A.ins_h,A.window[J+1]);while(A.insert)if(A.ins_h=tq(A,A.ins_h,A.window[J+F5-1]),A.prev[J&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=J,J++,A.insert--,A.lookahead+A.insert<F5)break}}while(A.lookahead<BU&&A.strm.avail_in!==0)},y94=(A,Q)=>{let B=A.pending_buf_size-5>A.w_size?A.w_size:A.pending_buf_size-5,$,J,Y,Z=0,F=A.strm.avail_in;do{if($=65535,Y=A.bi_valid+42>>3,A.strm.avail_out<Y)break;if(Y=A.strm.avail_out-Y,J=A.strstart-A.block_start,$>J+A.strm.avail_in)$=J+A.strm.avail_in;if($>Y)$=Y;if($<B&&($===0&&Q!==qF||Q===sq||$!==J+A.strm.avail_in))break;if(Z=Q===qF&&$===J+A.strm.avail_in?1:0,kb0(A,0,0,Z),A.pending_buf[A.pending-4]=$,A.pending_buf[A.pending-3]=$>>8,A.pending_buf[A.pending-2]=~$,A.pending_buf[A.pending-1]=~$>>8,RY(A.strm),J){if(J>$)J=$;A.strm.output.set(A.window.subarray(A.block_start,A.block_start+J),A.strm.next_out),A.strm.next_out+=J,A.strm.avail_out-=J,A.strm.total_out+=J,A.block_start+=J,$-=J}if($)ub0(A.strm,A.strm.output,A.strm.next_out,$),A.strm.next_out+=$,A.strm.avail_out-=$,A.strm.total_out+=$}while(Z===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(Z)return Hv;if(Q!==sq&&Q!==qF&&A.strm.avail_in===0&&A.strstart===A.block_start)return Wv;if(Y=A.window_size-A.strstart,A.strm.avail_in>Y&&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(Y+=A.w_size,A.insert>A.strstart)A.insert=A.strstart}if(Y>A.strm.avail_in)Y=A.strm.avail_in;if(Y)ub0(A.strm,A.window,A.strstart,Y),A.strstart+=Y,A.insert+=Y>A.w_size-A.insert?A.w_size-A.insert:Y;if(A.high_water<A.strstart)A.high_water=A.strstart;if(Y=A.bi_valid+42>>3,Y=A.pending_buf_size-Y>65535?65535:A.pending_buf_size-Y,B=Y>A.w_size?A.w_size:Y,J=A.strstart-A.block_start,J>=B||(J||Q===qF)&&Q!==sq&&A.strm.avail_in===0&&J<=Y)$=J>Y?Y:J,Z=Q===qF&&A.strm.avail_in===0&&$===J?1:0,kb0(A,A.block_start,$,Z),A.block_start+=$,RY(A.strm);return Z?ZO:iB},Cb0=(A,Q)=>{let B,$;for(;;){if(A.lookahead<BU){if(Kv(A),A.lookahead<BU&&Q===sq)return iB;if(A.lookahead===0)break}if(B=0,A.lookahead>=F5)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if(B!==0&&A.strstart-B<=A.w_size-BU)A.match_length=v94(A,B);if(A.match_length>=F5)if($=rq(A,A.strstart-A.match_start,A.match_length-F5),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=F5){A.match_length--;do A.strstart++,A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=tq(A,A.ins_h,A.window[A.strstart+1]);else $=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if($){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=A.strstart<F5-1?A.strstart:F5-1,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},Dv=(A,Q)=>{let B,$,J;for(;;){if(A.lookahead<BU){if(Kv(A),A.lookahead<BU&&Q===sq)return iB;if(A.lookahead===0)break}if(B=0,A.lookahead>=F5)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=F5-1,B!==0&&A.prev_length<A.max_lazy_match&&A.strstart-B<=A.w_size-BU){if(A.match_length=v94(A,B),A.match_length<=5&&(A.strategy===zW6||A.match_length===F5&&A.strstart-A.match_start>4096))A.match_length=F5-1}if(A.prev_length>=F5&&A.match_length<=A.prev_length){J=A.strstart+A.lookahead-F5,$=rq(A,A.strstart-1-A.prev_match,A.prev_length-F5),A.lookahead-=A.prev_length-1,A.prev_length-=2;do if(++A.strstart<=J)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=F5-1,A.strstart++,$){if(PY(A,!1),A.strm.avail_out===0)return iB}}else if(A.match_available){if($=rq(A,0,A.window[A.strstart-1]),$)PY(A,!1);if(A.strstart++,A.lookahead--,A.strm.avail_out===0)return iB}else A.match_available=1,A.strstart++,A.lookahead--}if(A.match_available)$=rq(A,0,A.window[A.strstart-1]),A.match_available=0;if(A.insert=A.strstart<F5-1?A.strstart:F5-1,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},xW6=(A,Q)=>{let B,$,J,Y,Z=A.window;for(;;){if(A.lookahead<=oq){if(Kv(A),A.lookahead<=oq&&Q===sq)return iB;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=F5&&A.strstart>0){if(J=A.strstart-1,$=Z[J],$===Z[++J]&&$===Z[++J]&&$===Z[++J]){Y=A.strstart+oq;do;while($===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&J<Y);if(A.match_length=oq-(Y-J),A.match_length>A.lookahead)A.match_length=A.lookahead}}if(A.match_length>=F5)B=rq(A,1,A.match_length-F5),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0;else B=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if(B){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=0,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},fW6=(A,Q)=>{let B;for(;;){if(A.lookahead===0){if(Kv(A),A.lookahead===0){if(Q===sq)return iB;break}}if(A.match_length=0,B=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,B){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=0,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},oc,bW6=(A)=>{A.window_size=2*A.w_size,aq(A.head),A.max_lazy_match=oc[A.level].max_lazy,A.good_match=oc[A.level].good_length,A.nice_match=oc[A.level].nice_length,A.max_chain_length=oc[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=F5-1,A.match_available=0,A.ins_h=0},Xl=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.status!==Uv&&Q.status!==db0&&Q.status!==yb0&&Q.status!==xb0&&Q.status!==fb0&&Q.status!==bb0&&Q.status!==$O&&Q.status!==ac)return 1;return 0},x94=(A)=>{if(Xl(A))return JO(A,QU);A.total_in=A.total_out=0,A.data_type=CW6;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?db0:Q.wrap?Uv:$O,A.adler=Q.wrap===2?0:1,Q.last_flush=-2,GW6(Q),UQ},f94=(A)=>{let Q=x94(A);if(Q===UQ)bW6(A.state);return Q},hW6=(A,Q)=>{if(Xl(A)||A.state.wrap!==2)return QU;return A.state.gzhead=Q,UQ},b94=(A,Q,B,$,J,Y)=>{if(!A)return QU;let Z=1;if(Q===HW6)Q=6;if($<0)Z=0,$=-$;else if($>15)Z=2,$-=16;if(J<1||J>wW6||B!==M70||$<8||$>15||Q<0||Q>9||Y<0||Y>NW6||$===8&&Z!==1)return JO(A,QU);if($===8)$=9;let F=new uW6;return A.state=F,F.strm=A,F.status=Uv,F.wrap=Z,F.gzhead=null,F.w_bits=$,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=J+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+F5-1)/F5),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<<J+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=Y,F.method=B,f94(A)},gW6=(A,Q)=>{return b94(A,Q,M70,MW6,LW6,IW6)},mW6=(A,Q)=>{if(Xl(A)||Q>h24||Q<0)return A?JO(A,QU):QU;let B=A.state;if(!A.output||A.avail_in!==0&&!A.input||B.status===ac&&Q!==qF)return JO(A,A.avail_out===0?Ib0:QU);let $=B.last_flush;if(B.last_flush=Q,B.pending!==0){if(RY(A),A.avail_out===0)return B.last_flush=-1,UQ}else if(A.avail_in===0&&m24(Q)<=m24($)&&Q!==qF)return JO(A,Ib0);if(B.status===ac&&A.avail_in!==0)return JO(A,Ib0);if(B.status===Uv&&B.wrap===0)B.status=$O;if(B.status===Uv){let J=M70+(B.w_bits-8<<4)<<8,Y=-1;if(B.strategy>=E70||B.level<2)Y=0;else if(B.level<6)Y=1;else if(B.level===6)Y=2;else Y=3;if(J|=Y<<6,B.strstart!==0)J|=SW6;if(J+=31-J%31,nc(B,J),B.strstart!==0)nc(B,A.adler>>>16),nc(B,A.adler&65535);if(A.adler=1,B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}if(B.status===db0)if(A.adler=0,l5(B,31),l5(B,139),l5(B,8),!B.gzhead){if(l5(B,0),l5(B,0),l5(B,0),l5(B,0),l5(B,0),l5(B,B.level===9?2:B.strategy>=E70||B.level<2?4:0),l5(B,kW6),B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}else{if(l5(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(!B.gzhead.extra?0:4)+(!B.gzhead.name?0:8)+(!B.gzhead.comment?0:16)),l5(B,B.gzhead.time&255),l5(B,B.gzhead.time>>8&255),l5(B,B.gzhead.time>>16&255),l5(B,B.gzhead.time>>24&255),l5(B,B.level===9?2:B.strategy>=E70||B.level<2?4:0),l5(B,B.gzhead.os&255),B.gzhead.extra&&B.gzhead.extra.length)l5(B,B.gzhead.extra.length&255),l5(B,B.gzhead.extra.length>>8&255);if(B.gzhead.hcrc)A.adler=z7(A.adler,B.pending_buf,B.pending,0);B.gzindex=0,B.status=yb0}if(B.status===yb0){if(B.gzhead.extra){let J=B.pending,Y=(B.gzhead.extra.length&65535)-B.gzindex;while(B.pending+Y>B.pending_buf_size){let F=B.pending_buf_size-B.pending;if(B.pending_buf.set(B.gzhead.extra.subarray(B.gzindex,B.gzindex+F),B.pending),B.pending=B.pending_buf_size,B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(B.gzindex+=F,RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0,Y-=F}let Z=new Uint8Array(B.gzhead.extra);if(B.pending_buf.set(Z.subarray(B.gzindex,B.gzindex+Y),B.pending),B.pending+=Y,B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);B.gzindex=0}B.status=xb0}if(B.status===xb0){if(B.gzhead.name){let J=B.pending,Y;do{if(B.pending===B.pending_buf_size){if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0}if(B.gzindex<B.gzhead.name.length)Y=B.gzhead.name.charCodeAt(B.gzindex++)&255;else Y=0;l5(B,Y)}while(Y!==0);if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);B.gzindex=0}B.status=fb0}if(B.status===fb0){if(B.gzhead.comment){let J=B.pending,Y;do{if(B.pending===B.pending_buf_size){if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0}if(B.gzindex<B.gzhead.comment.length)Y=B.gzhead.comment.charCodeAt(B.gzindex++)&255;else Y=0;l5(B,Y)}while(Y!==0);if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J)}B.status=bb0}if(B.status===bb0){if(B.gzhead.hcrc){if(B.pending+2>B.pending_buf_size){if(RY(A),B.pending!==0)return B.last_flush=-1,UQ}l5(B,A.adler&255),l5(B,A.adler>>8&255),A.adler=0}if(B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}if(A.avail_in!==0||B.lookahead!==0||Q!==sq&&B.status!==ac){let J=B.level===0?y94(B,Q):B.strategy===E70?fW6(B,Q):B.strategy===qW6?xW6(B,Q):oc[B.level].func(B,Q);if(J===ZO||J===Hv)B.status=ac;if(J===iB||J===ZO){if(A.avail_out===0)B.last_flush=-1;return UQ}if(J===Wv){if(Q===KW6)UW6(B);else if(Q!==h24){if(kb0(B,0,0,!1),Q===EW6){if(aq(B.head),B.lookahead===0)B.strstart=0,B.block_start=0,B.insert=0}}if(RY(A),A.avail_out===0)return B.last_flush=-1,UQ}}if(Q!==qF)return UQ;if(B.wrap<=0)return g24;if(B.wrap===2)l5(B,A.adler&255),l5(B,A.adler>>8&255),l5(B,A.adler>>16&255),l5(B,A.adler>>24&255),l5(B,A.total_in&255),l5(B,A.total_in>>8&255),l5(B,A.total_in>>16&255),l5(B,A.total_in>>24&255);else nc(B,A.adler>>>16),nc(B,A.adler&65535);if(RY(A),B.wrap>0)B.wrap=-B.wrap;return B.pending!==0?UQ:g24},pW6=(A)=>{if(Xl(A))return QU;let Q=A.state.status;return A.state=null,Q===$O?JO(A,WW6):UQ},dW6=(A,Q)=>{let B=Q.length;if(Xl(A))return QU;let $=A.state,J=$.wrap;if(J===2||J===1&&$.status!==Uv||$.lookahead)return QU;if(J===1)A.adler=$l(A.adler,Q,B,0);if($.wrap=0,B>=$.w_size){if(J===0)aq($.head),$.strstart=0,$.block_start=0,$.insert=0;let X=new Uint8Array($.w_size);X.set(Q.subarray(B-$.w_size,B),0),Q=X,B=$.w_size}let{avail_in:Y,next_in:Z,input:F}=A;A.avail_in=B,A.next_in=0,A.input=Q,Kv($);while($.lookahead>=F5){let X=$.strstart,D=$.lookahead-(F5-1);do $.ins_h=tq($,$.ins_h,$.window[X+F5-1]),$.prev[X&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=X,X++;while(--D);$.strstart=X,$.lookahead=F5-1,Kv($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=F5-1,$.match_available=0,A.next_in=Z,A.input=F,A.avail_in=Y,$.wrap=J,UQ},cW6,lW6,iW6,nW6,aW6,oW6,rW6,sW6,tW6="pako deflate (from Nodeca project)",sc,eW6=(A,Q)=>{return Object.prototype.hasOwnProperty.call(A,Q)},AH6=function(A){let Q=Array.prototype.slice.call(arguments,1);while(Q.length){let B=Q.shift();if(!B)continue;if(typeof B!=="object")throw TypeError(B+"must be non-object");for(let $ in B)if(eW6(B,$))A[$]=B[$]}return A},QH6=(A)=>{let Q=0;for(let $=0,J=A.length;$<J;$++)Q+=A[$].length;let B=new Uint8Array(Q);for(let $=0,J=0,Y=A.length;$<Y;$++){let Z=A[$];B.set(Z,J),J+=Z.length}return B},L70,u94=!0,Jl,BH6=(A)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(A);let Q,B,$,J,Y,Z=A.length,F=0;for(J=0;J<Z;J++){if(B=A.charCodeAt(J),(B&64512)===55296&&J+1<Z){if($=A.charCodeAt(J+1),($&64512)===56320)B=65536+(B-55296<<10)+($-56320),J++}F+=B<128?1:B<2048?2:B<65536?3:4}Q=new Uint8Array(F);for(Y=0,J=0;Y<F;J++){if(B=A.charCodeAt(J),(B&64512)===55296&&J+1<Z){if($=A.charCodeAt(J+1),($&64512)===56320)B=65536+(B-55296<<10)+($-56320),J++}if(B<128)Q[Y++]=B;else if(B<2048)Q[Y++]=192|B>>>6,Q[Y++]=128|B&63;else if(B<65536)Q[Y++]=224|B>>>12,Q[Y++]=128|B>>>6&63,Q[Y++]=128|B&63;else Q[Y++]=240|B>>>18,Q[Y++]=128|B>>>12&63,Q[Y++]=128|B>>>6&63,Q[Y++]=128|B&63}return Q},$H6=(A,Q)=>{if(Q<65534){if(A.subarray&&u94)return String.fromCharCode.apply(null,A.length===Q?A:A.subarray(0,Q))}let B="";for(let $=0;$<Q;$++)B+=String.fromCharCode(A[$]);return B},JH6=(A,Q)=>{let B=Q||A.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(A.subarray(0,Q));let $,J,Y=Array(B*2);for(J=0,$=0;$<B;){let Z=A[$++];if(Z<128){Y[J++]=Z;continue}let F=Jl[Z];if(F>4){Y[J++]=65533,$+=F-1;continue}Z&=F===2?31:F===3?15:7;while(F>1&&$<B)Z=Z<<6|A[$++]&63,F--;if(F>1){Y[J++]=65533;continue}if(Z<65536)Y[J++]=Z;else Z-=65536,Y[J++]=55296|Z>>10&1023,Y[J++]=56320|Z&1023}return $H6(Y,J)},YH6=(A,Q)=>{if(Q=Q||A.length,Q>A.length)Q=A.length;let B=Q-1;while(B>=0&&(A[B]&192)===128)B--;if(B<0)return Q;if(B===0)return Q;return B+Jl[A[B]]>Q?B:Q},Yl,h94,g94,FH6,XH6,DH6,GH6,C70,VH6,UH6,KH6,EH6,zH6,qH6,NH6,IH6,CH6,wH6,W70=16209,MH6=16191,LH6=function(Q,B){let $,J,Y,Z,F,X,D,G,V,U,K,E,W,H,z,q,N,I,C,w,M,j,P,R,b=Q.state;$=Q.next_in,P=Q.input,J=$+(Q.avail_in-5),Y=Q.next_out,R=Q.output,Z=Y-(B-Q.avail_out),F=Y+(Q.avail_out-257),X=b.dmax,D=b.wsize,G=b.whave,V=b.wnext,U=b.window,K=b.hold,E=b.bits,W=b.lencode,H=b.distcode,z=(1<<b.lenbits)-1,q=(1<<b.distbits)-1;A:do{if(E<15)K+=P[$++]<<E,E+=8,K+=P[$++]<<E,E+=8;N=W[K&z];Q:for(;;){if(I=N>>>24,K>>>=I,E-=I,I=N>>>16&255,I===0)R[Y++]=N&65535;else if(I&16){if(C=N&65535,I&=15,I){if(E<I)K+=P[$++]<<E,E+=8;C+=K&(1<<I)-1,K>>>=I,E-=I}if(E<15)K+=P[$++]<<E,E+=8,K+=P[$++]<<E,E+=8;N=H[K&q];B:for(;;){if(I=N>>>24,K>>>=I,E-=I,I=N>>>16&255,I&16){if(w=N&65535,I&=15,E<I){if(K+=P[$++]<<E,E+=8,E<I)K+=P[$++]<<E,E+=8}if(w+=K&(1<<I)-1,w>X){Q.msg="invalid distance too far back",b.mode=W70;break A}if(K>>>=I,E-=I,I=Y-Z,w>I){if(I=w-I,I>G){if(b.sane){Q.msg="invalid distance too far back",b.mode=W70;break A}}if(M=0,j=U,V===0){if(M+=D-I,I<C){C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}}else if(V<I){if(M+=D+V-I,I-=V,I<C){C-=I;do R[Y++]=U[M++];while(--I);if(M=0,V<C){I=V,C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}}}else if(M+=V-I,I<C){C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}while(C>2)R[Y++]=j[M++],R[Y++]=j[M++],R[Y++]=j[M++],C-=3;if(C){if(R[Y++]=j[M++],C>1)R[Y++]=j[M++]}}else{M=Y-w;do R[Y++]=R[M++],R[Y++]=R[M++],R[Y++]=R[M++],C-=3;while(C>2);if(C){if(R[Y++]=R[M++],C>1)R[Y++]=R[M++]}}}else if((I&64)===0){N=H[(N&65535)+(K&(1<<I)-1)];continue B}else{Q.msg="invalid distance code",b.mode=W70;break A}break}}else if((I&64)===0){N=W[(N&65535)+(K&(1<<I)-1)];continue Q}else if(I&32){b.mode=MH6;break A}else{Q.msg="invalid literal/length code",b.mode=W70;break A}break}}while($<J&&Y<F);C=E>>3,$-=C,E-=C<<3,K&=(1<<E)-1,Q.next_in=$,Q.next_out=Y,Q.avail_in=$<J?5+(J-$):5-($-J),Q.avail_out=Y<F?257+(F-Y):257-(Y-F),b.hold=K,b.bits=E;return},Gv=15,p24=852,d24=592,c24=0,wb0=1,l24=2,OH6,jH6,RH6,PH6,_H6=(A,Q,B,$,J,Y,Z,F)=>{let X=F.bits,D=0,G=0,V=0,U=0,K=0,E=0,W=0,H=0,z=0,q=0,N,I,C,w,M,j=null,P,R=new Uint16Array(Gv+1),b=new Uint16Array(Gv+1),g=null,f,k,x;for(D=0;D<=Gv;D++)R[D]=0;for(G=0;G<$;G++)R[Q[B+G]]++;K=X;for(U=Gv;U>=1;U--)if(R[U]!==0)break;if(K>U)K=U;if(U===0)return J[Y++]=20971520,J[Y++]=20971520,F.bits=1,0;for(V=1;V<U;V++)if(R[V]!==0)break;if(K<V)K=V;H=1;for(D=1;D<=Gv;D++)if(H<<=1,H-=R[D],H<0)return-1;if(H>0&&(A===c24||U!==1))return-1;b[1]=0;for(D=1;D<Gv;D++)b[D+1]=b[D]+R[D];for(G=0;G<$;G++)if(Q[B+G]!==0)Z[b[Q[B+G]]++]=G;if(A===c24)j=g=Z,P=20;else if(A===wb0)j=OH6,g=jH6,P=257;else j=RH6,g=PH6,P=0;if(q=0,G=0,D=V,M=Y,E=K,W=0,C=-1,z=1<<K,w=z-1,A===wb0&&z>p24||A===l24&&z>d24)return 1;for(;;){if(f=D-W,Z[G]+1<P)k=0,x=Z[G];else if(Z[G]>=P)k=g[Z[G]-P],x=j[Z[G]-P];else k=96,x=0;N=1<<D-W,I=1<<E,V=I;do I-=N,J[M+(q>>W)+I]=f<<24|k<<16|x|0;while(I!==0);N=1<<D-1;while(q&N)N>>=1;if(N!==0)q&=N-1,q+=N;else q=0;if(G++,--R[D]===0){if(D===U)break;D=Q[B+Z[G]]}if(D>K&&(q&w)!==C){if(W===0)W=K;M+=V,E=D-W,H=1<<E;while(E+W<U){if(H-=R[E+W],H<=0)break;E++,H<<=1}if(z+=1<<E,A===wb0&&z>p24||A===l24&&z>d24)return 1;C=q&w,J[C]=K<<24|E<<16|M-Y|0}}if(q!==0)J[M+q]=D-W<<24|4194304|0;return F.bits=K,0},tc,TH6=0,m94=1,p94=2,i24,SH6,H70,FO,kH6,vH6,NF,d94,c94,yH6,n24,O70=16180,a24=16181,o24=16182,r24=16183,s24=16184,t24=16185,e24=16186,A94=16187,Q94=16188,B94=16189,w70=16190,DW=16191,Mb0=16192,$94=16193,Lb0=16194,J94=16195,Y94=16196,Z94=16197,F94=16198,z70=16199,q70=16200,X94=16201,D94=16202,G94=16203,V94=16204,U94=16205,Ob0=16206,K94=16207,E94=16208,C3=16209,l94=16210,i94=16211,xH6=852,fH6=592,bH6=15,uH6,W94=(A)=>{return(A>>>24&255)+(A>>>8&65280)+((A&65280)<<8)+((A&255)<<24)},DO=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.mode<O70||Q.mode>i94)return 1;return 0},n94=(A)=>{if(DO(A))return NF;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=O70,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(xH6),Q.distcode=Q.distdyn=new Int32Array(fH6),Q.sane=1,Q.back=-1,FO},a94=(A)=>{if(DO(A))return NF;let Q=A.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,n94(A)},o94=(A,Q)=>{let B;if(DO(A))return NF;let $=A.state;if(Q<0)B=0,Q=-Q;else if(B=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return NF;if($.window!==null&&$.wbits!==Q)$.window=null;return $.wrap=B,$.wbits=Q,a94(A)},r94=(A,Q)=>{if(!A)return NF;let B=new hH6;A.state=B,B.strm=A,B.window=null,B.mode=O70;let $=o94(A,Q);if($!==FO)A.state=null;return $},gH6=(A)=>{return r94(A,uH6)},H94=!0,jb0,Rb0,mH6=(A)=>{if(H94){jb0=new Int32Array(512),Rb0=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;tc(m94,A.lens,0,288,jb0,0,A.work,{bits:9}),Q=0;while(Q<32)A.lens[Q++]=5;tc(p94,A.lens,0,32,Rb0,0,A.work,{bits:5}),H94=!1}A.lencode=jb0,A.lenbits=9,A.distcode=Rb0,A.distbits=5},s94=(A,Q,B,$)=>{let J,Y=A.state;if(Y.window===null)Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new Uint8Array(Y.wsize);if($>=Y.wsize)Y.window.set(Q.subarray(B-Y.wsize,B),0),Y.wnext=0,Y.whave=Y.wsize;else{if(J=Y.wsize-Y.wnext,J>$)J=$;if(Y.window.set(Q.subarray(B-$,B-$+J),Y.wnext),$-=J,$)Y.window.set(Q.subarray(B-$,B),0),Y.wnext=$,Y.whave=Y.wsize;else{if(Y.wnext+=J,Y.wnext===Y.wsize)Y.wnext=0;if(Y.whave<Y.wsize)Y.whave+=J}}return 0},pH6=(A,Q)=>{let B,$,J,Y,Z,F,X,D,G,V,U,K,E,W,H=0,z,q,N,I,C,w,M,j,P=new Uint8Array(4),R,b,g=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(DO(A)||!A.output||!A.input&&A.avail_in!==0)return NF;if(B=A.state,B.mode===DW)B.mode=Mb0;Z=A.next_out,J=A.output,X=A.avail_out,Y=A.next_in,$=A.input,F=A.avail_in,D=B.hold,G=B.bits,V=F,U=X,j=FO;A:for(;;)switch(B.mode){case O70:if(B.wrap===0){B.mode=Mb0;break}while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&2&&D===35615){if(B.wbits===0)B.wbits=15;B.check=0,P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0),D=0,G=0,B.mode=a24;break}if(B.head)B.head.done=!1;if(!(B.wrap&1)||(((D&255)<<8)+(D>>8))%31){A.msg="incorrect header check",B.mode=C3;break}if((D&15)!==n24){A.msg="unknown compression method",B.mode=C3;break}if(D>>>=4,G-=4,M=(D&15)+8,B.wbits===0)B.wbits=M;if(M>15||M>B.wbits){A.msg="invalid window size",B.mode=C3;break}B.dmax=1<<B.wbits,B.flags=0,A.adler=B.check=1,B.mode=D&512?B94:DW,D=0,G=0;break;case a24:while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.flags=D,(B.flags&255)!==n24){A.msg="unknown compression method",B.mode=C3;break}if(B.flags&57344){A.msg="unknown header flags set",B.mode=C3;break}if(B.head)B.head.text=D>>8&1;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0,B.mode=o24;case o24:while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.head)B.head.time=D;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,P[2]=D>>>16&255,P[3]=D>>>24&255,B.check=z7(B.check,P,4,0);D=0,G=0,B.mode=r24;case r24:while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.head)B.head.xflags=D&255,B.head.os=D>>8;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0,B.mode=s24;case s24:if(B.flags&1024){while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.length=D,B.head)B.head.extra_len=D;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0}else if(B.head)B.head.extra=null;B.mode=t24;case t24:if(B.flags&1024){if(K=B.length,K>F)K=F;if(K){if(B.head){if(M=B.head.extra_len-B.length,!B.head.extra)B.head.extra=new Uint8Array(B.head.extra_len);B.head.extra.set($.subarray(Y,Y+K),M)}if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);F-=K,Y+=K,B.length-=K}if(B.length)break A}B.length=0,B.mode=e24;case e24:if(B.flags&2048){if(F===0)break A;K=0;do if(M=$[Y+K++],B.head&&M&&B.length<65536)B.head.name+=String.fromCharCode(M);while(M&&K<F);if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);if(F-=K,Y+=K,M)break A}else if(B.head)B.head.name=null;B.length=0,B.mode=A94;case A94:if(B.flags&4096){if(F===0)break A;K=0;do if(M=$[Y+K++],B.head&&M&&B.length<65536)B.head.comment+=String.fromCharCode(M);while(M&&K<F);if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);if(F-=K,Y+=K,M)break A}else if(B.head)B.head.comment=null;B.mode=Q94;case Q94:if(B.flags&512){while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&4&&D!==(B.check&65535)){A.msg="header crc mismatch",B.mode=C3;break}D=0,G=0}if(B.head)B.head.hcrc=B.flags>>9&1,B.head.done=!0;A.adler=B.check=0,B.mode=DW;break;case B94:while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}A.adler=B.check=W94(D),D=0,G=0,B.mode=w70;case w70:if(B.havedict===0)return A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,vH6;A.adler=B.check=1,B.mode=DW;case DW:if(Q===SH6||Q===H70)break A;case Mb0:if(B.last){D>>>=G&7,G-=G&7,B.mode=Ob0;break}while(G<3){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}switch(B.last=D&1,D>>>=1,G-=1,D&3){case 0:B.mode=$94;break;case 1:if(mH6(B),B.mode=z70,Q===H70){D>>>=2,G-=2;break A}break;case 2:B.mode=Y94;break;case 3:A.msg="invalid block type",B.mode=C3}D>>>=2,G-=2;break;case $94:D>>>=G&7,G-=G&7;while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if((D&65535)!==(D>>>16^65535)){A.msg="invalid stored block lengths",B.mode=C3;break}if(B.length=D&65535,D=0,G=0,B.mode=Lb0,Q===H70)break A;case Lb0:B.mode=J94;case J94:if(K=B.length,K){if(K>F)K=F;if(K>X)K=X;if(K===0)break A;J.set($.subarray(Y,Y+K),Z),F-=K,Y+=K,X-=K,Z+=K,B.length-=K;break}B.mode=DW;break;case Y94:while(G<14){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.nlen=(D&31)+257,D>>>=5,G-=5,B.ndist=(D&31)+1,D>>>=5,G-=5,B.ncode=(D&15)+4,D>>>=4,G-=4,B.nlen>286||B.ndist>30){A.msg="too many length or distance symbols",B.mode=C3;break}B.have=0,B.mode=Z94;case Z94:while(B.have<B.ncode){while(G<3){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.lens[g[B.have++]]=D&7,D>>>=3,G-=3}while(B.have<19)B.lens[g[B.have++]]=0;if(B.lencode=B.lendyn,B.lenbits=7,R={bits:B.lenbits},j=tc(TH6,B.lens,0,19,B.lencode,0,B.work,R),B.lenbits=R.bits,j){A.msg="invalid code lengths set",B.mode=C3;break}B.have=0,B.mode=F94;case F94:while(B.have<B.nlen+B.ndist){for(;;){if(H=B.lencode[D&(1<<B.lenbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(N<16)D>>>=z,G-=z,B.lens[B.have++]=N;else{if(N===16){b=z+2;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(D>>>=z,G-=z,B.have===0){A.msg="invalid bit length repeat",B.mode=C3;break}M=B.lens[B.have-1],K=3+(D&3),D>>>=2,G-=2}else if(N===17){b=z+3;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=z,G-=z,M=0,K=3+(D&7),D>>>=3,G-=3}else{b=z+7;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=z,G-=z,M=0,K=11+(D&127),D>>>=7,G-=7}if(B.have+K>B.nlen+B.ndist){A.msg="invalid bit length repeat",B.mode=C3;break}while(K--)B.lens[B.have++]=M}}if(B.mode===C3)break;if(B.lens[256]===0){A.msg="invalid code -- missing end-of-block",B.mode=C3;break}if(B.lenbits=9,R={bits:B.lenbits},j=tc(m94,B.lens,0,B.nlen,B.lencode,0,B.work,R),B.lenbits=R.bits,j){A.msg="invalid literal/lengths set",B.mode=C3;break}if(B.distbits=6,B.distcode=B.distdyn,R={bits:B.distbits},j=tc(p94,B.lens,B.nlen,B.ndist,B.distcode,0,B.work,R),B.distbits=R.bits,j){A.msg="invalid distances set",B.mode=C3;break}if(B.mode=z70,Q===H70)break A;case z70:B.mode=q70;case q70:if(F>=6&&X>=258){if(A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,LH6(A,U),Z=A.next_out,J=A.output,X=A.avail_out,Y=A.next_in,$=A.input,F=A.avail_in,D=B.hold,G=B.bits,B.mode===DW)B.back=-1;break}B.back=0;for(;;){if(H=B.lencode[D&(1<<B.lenbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(q&&(q&240)===0){I=z,C=q,w=N;for(;;){if(H=B.lencode[w+((D&(1<<I+C)-1)>>I)],z=H>>>24,q=H>>>16&255,N=H&65535,I+z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=I,G-=I,B.back+=I}if(D>>>=z,G-=z,B.back+=z,B.length=N,q===0){B.mode=U94;break}if(q&32){B.back=-1,B.mode=DW;break}if(q&64){A.msg="invalid literal/length code",B.mode=C3;break}B.extra=q&15,B.mode=X94;case X94:if(B.extra){b=B.extra;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.length+=D&(1<<B.extra)-1,D>>>=B.extra,G-=B.extra,B.back+=B.extra}B.was=B.length,B.mode=D94;case D94:for(;;){if(H=B.distcode[D&(1<<B.distbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if((q&240)===0){I=z,C=q,w=N;for(;;){if(H=B.distcode[w+((D&(1<<I+C)-1)>>I)],z=H>>>24,q=H>>>16&255,N=H&65535,I+z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=I,G-=I,B.back+=I}if(D>>>=z,G-=z,B.back+=z,q&64){A.msg="invalid distance code",B.mode=C3;break}B.offset=N,B.extra=q&15,B.mode=G94;case G94:if(B.extra){b=B.extra;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.offset+=D&(1<<B.extra)-1,D>>>=B.extra,G-=B.extra,B.back+=B.extra}if(B.offset>B.dmax){A.msg="invalid distance too far back",B.mode=C3;break}B.mode=V94;case V94:if(X===0)break A;if(K=U-X,B.offset>K){if(K=B.offset-K,K>B.whave){if(B.sane){A.msg="invalid distance too far back",B.mode=C3;break}}if(K>B.wnext)K-=B.wnext,E=B.wsize-K;else E=B.wnext-K;if(K>B.length)K=B.length;W=B.window}else W=J,E=Z-B.offset,K=B.length;if(K>X)K=X;X-=K,B.length-=K;do J[Z++]=W[E++];while(--K);if(B.length===0)B.mode=q70;break;case U94:if(X===0)break A;J[Z++]=B.length,X--,B.mode=q70;break;case Ob0:if(B.wrap){while(G<32){if(F===0)break A;F--,D|=$[Y++]<<G,G+=8}if(U-=X,A.total_out+=U,B.total+=U,B.wrap&4&&U)A.adler=B.check=B.flags?z7(B.check,J,U,Z-U):$l(B.check,J,U,Z-U);if(U=X,B.wrap&4&&(B.flags?D:W94(D))!==B.check){A.msg="incorrect data check",B.mode=C3;break}D=0,G=0}B.mode=K94;case K94:if(B.wrap&&B.flags){while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&4&&D!==(B.total&4294967295)){A.msg="incorrect length check",B.mode=C3;break}D=0,G=0}B.mode=E94;case E94:j=kH6;break A;case C3:j=d94;break A;case l94:return c94;case i94:default:return NF}if(A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,B.wsize||U!==A.avail_out&&B.mode<C3&&(B.mode<Ob0||Q!==i24)){if(s94(A,A.output,A.next_out,U-A.avail_out));}if(V-=A.avail_in,U-=A.avail_out,A.total_in+=V,A.total_out+=U,B.total+=U,B.wrap&4&&U)A.adler=B.check=B.flags?z7(B.check,J,U,A.next_out-U):$l(B.check,J,U,A.next_out-U);if(A.data_type=B.bits+(B.last?64:0)+(B.mode===DW?128:0)+(B.mode===z70||B.mode===Lb0?256:0),(V===0&&U===0||Q===i24)&&j===FO)j=yH6;return j},dH6=(A)=>{if(DO(A))return NF;let Q=A.state;if(Q.window)Q.window=null;return A.state=null,FO},cH6=(A,Q)=>{if(DO(A))return NF;let B=A.state;if((B.wrap&2)===0)return NF;return B.head=Q,Q.done=!1,FO},lH6=(A,Q)=>{let B=Q.length,$,J,Y;if(DO(A))return NF;if($=A.state,$.wrap!==0&&$.mode!==w70)return NF;if($.mode===w70){if(J=1,J=$l(J,Q,B,0),J!==$.check)return d94}if(Y=s94(A,Q,B,B),Y)return $.mode=l94,c94;return $.havedict=1,FO},iH6,nH6,aH6,oH6,rH6,sH6,tH6,eH6,Az6,Qz6="pako inflate (from Nodeca project)",VW,$z6,t94,Jz6,Yz6,Zl,Pb0,_b0,Zz6,z94,Fz6,Dz6,Gz6,Vz6,Uz6,Kz6,Ez6,Wz6,Hz6,zz6,qz6,Nz6,Iz6,Cz6,wz6,Mz6,Lz6,Oz6,jz6,Rz6,Pz6,_z6,Tz6,Sz6,e94;var A74=J0(()=>{/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */ec=Fl+1+hb0,N94=2*ec+1,Tb0=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]),N70=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]),pE6=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),M94=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),GW=Array((ec+2)*2);Ev(GW);rc=Array(Vv*2);Ev(rc);Al=Array(dE6);Ev(Al);Ql=Array(gE6-hE6+1);Ev(Ql);pb0=Array(hb0);Ev(pb0);I70=Array(Vv);Ev(I70);AW6=rE6,QW6=k94,BW6=tE6,$W6=eE6,JW6=sE6,YW6={_tr_init:AW6,_tr_stored_block:QW6,_tr_flush_block:BW6,_tr_tally:$W6,_tr_align:JW6},$l=ZW6,XW6=new Uint32Array(FW6()),z7=DW6,YO={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"},XO={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:GW6,_tr_stored_block:kb0,_tr_flush_block:VW6,_tr_tally:rq,_tr_align:UW6}=YW6,{Z_NO_FLUSH:sq,Z_PARTIAL_FLUSH:KW6,Z_FULL_FLUSH:EW6,Z_FINISH:qF,Z_BLOCK:h24,Z_OK:UQ,Z_STREAM_END:g24,Z_STREAM_ERROR:QU,Z_DATA_ERROR:WW6,Z_BUF_ERROR:Ib0,Z_DEFAULT_COMPRESSION:HW6,Z_FILTERED:zW6,Z_HUFFMAN_ONLY:E70,Z_RLE:qW6,Z_FIXED:NW6,Z_DEFAULT_STRATEGY:IW6,Z_UNKNOWN:CW6,Z_DEFLATED:M70}=XO,vb0=jW6+1+OW6,_W6=2*vb0+1,BU=oq+F5+1,tq=yW6;oc=[new eV(0,0,0,0,y94),new eV(4,4,8,4,Cb0),new eV(4,5,16,8,Cb0),new eV(4,6,32,32,Cb0),new eV(4,4,16,16,Dv),new eV(8,16,32,32,Dv),new eV(8,16,128,128,Dv),new eV(8,32,128,256,Dv),new eV(32,128,258,1024,Dv),new eV(32,258,258,4096,Dv)];cW6=gW6,lW6=b94,iW6=f94,nW6=x94,aW6=hW6,oW6=mW6,rW6=pW6,sW6=dW6,sc={deflateInit:cW6,deflateInit2:lW6,deflateReset:iW6,deflateResetKeep:nW6,deflateSetHeader:aW6,deflate:oW6,deflateEnd:rW6,deflateSetDictionary:sW6,deflateInfo:tW6},L70={assign:AH6,flattenChunks:QH6};try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){u94=!1}Jl=new Uint8Array(256);for(let A=0;A<256;A++)Jl[A]=A>=252?6:A>=248?5:A>=240?4:A>=224?3:A>=192?2:1;Jl[254]=Jl[254]=1;Yl={string2buf:BH6,buf2string:JH6,utf8border:YH6};h94=ZH6,g94=Object.prototype.toString,{Z_NO_FLUSH:FH6,Z_SYNC_FLUSH:XH6,Z_FULL_FLUSH:DH6,Z_FINISH:GH6,Z_OK:C70,Z_STREAM_END:VH6,Z_DEFAULT_COMPRESSION:UH6,Z_DEFAULT_STRATEGY:KH6,Z_DEFLATED:EH6}=XO;Dl.prototype.push=function(A,Q){let B=this.strm,$=this.options.chunkSize,J,Y;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?GH6:FH6;if(typeof A==="string")B.input=Yl.string2buf(A);else if(g94.call(A)==="[object ArrayBuffer]")B.input=new Uint8Array(A);else B.input=A;B.next_in=0,B.avail_in=B.input.length;for(;;){if(B.avail_out===0)B.output=new Uint8Array($),B.next_out=0,B.avail_out=$;if((Y===XH6||Y===DH6)&&B.avail_out<=6){this.onData(B.output.subarray(0,B.next_out)),B.avail_out=0;continue}if(J=sc.deflate(B,Y),J===VH6){if(B.next_out>0)this.onData(B.output.subarray(0,B.next_out));return J=sc.deflateEnd(this.strm),this.onEnd(J),this.ended=!0,J===C70}if(B.avail_out===0){this.onData(B.output);continue}if(Y>0&&B.next_out>0){this.onData(B.output.subarray(0,B.next_out)),B.avail_out=0;continue}if(B.avail_in===0)break}return!0};Dl.prototype.onData=function(A){this.chunks.push(A)};Dl.prototype.onEnd=function(A){if(A===C70)this.result=L70.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};zH6=Dl,qH6=cb0,NH6=WH6,IH6=HH6,CH6=XO,wH6={Deflate:zH6,deflate:qH6,deflateRaw:NH6,gzip:IH6,constants:CH6},OH6=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]),jH6=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]),RH6=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]),PH6=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]),tc=_H6,{Z_FINISH:i24,Z_BLOCK:SH6,Z_TREES:H70,Z_OK:FO,Z_STREAM_END:kH6,Z_NEED_DICT:vH6,Z_STREAM_ERROR:NF,Z_DATA_ERROR:d94,Z_MEM_ERROR:c94,Z_BUF_ERROR:yH6,Z_DEFLATED:n24}=XO,uH6=bH6;iH6=a94,nH6=o94,aH6=n94,oH6=gH6,rH6=r94,sH6=pH6,tH6=dH6,eH6=cH6,Az6=lH6,VW={inflateReset:iH6,inflateReset2:nH6,inflateResetKeep:aH6,inflateInit:oH6,inflateInit2:rH6,inflate:sH6,inflateEnd:tH6,inflateGetHeader:eH6,inflateSetDictionary:Az6,inflateInfo:Qz6};$z6=Bz6,t94=Object.prototype.toString,{Z_NO_FLUSH:Jz6,Z_FINISH:Yz6,Z_OK:Zl,Z_STREAM_END:Pb0,Z_NEED_DICT:_b0,Z_STREAM_ERROR:Zz6,Z_DATA_ERROR:z94,Z_MEM_ERROR:Fz6}=XO;Gl.prototype.push=function(A,Q){let B=this.strm,$=this.options.chunkSize,J=this.options.dictionary,Y,Z,F;if(this.ended)return!1;if(Q===~~Q)Z=Q;else Z=Q===!0?Yz6:Jz6;if(t94.call(A)==="[object ArrayBuffer]")B.input=new Uint8Array(A);else B.input=A;B.next_in=0,B.avail_in=B.input.length;for(;;){if(B.avail_out===0)B.output=new Uint8Array($),B.next_out=0,B.avail_out=$;if(Y=VW.inflate(B,Z),Y===_b0&&J){if(Y=VW.inflateSetDictionary(B,J),Y===Zl)Y=VW.inflate(B,Z);else if(Y===z94)Y=_b0}while(B.avail_in>0&&Y===Pb0&&B.state.wrap>0&&A[B.next_in]!==0)VW.inflateReset(B),Y=VW.inflate(B,Z);switch(Y){case Zz6:case z94:case _b0:case Fz6:return this.onEnd(Y),this.ended=!0,!1}if(F=B.avail_out,B.next_out){if(B.avail_out===0||Y===Pb0)if(this.options.to==="string"){let X=Yl.utf8border(B.output,B.next_out),D=B.next_out-X,G=Yl.buf2string(B.output,X);if(B.next_out=D,B.avail_out=$-D,D)B.output.set(B.output.subarray(X,X+D),0);this.onData(G)}else this.onData(B.output.length===B.next_out?B.output:B.output.subarray(0,B.next_out))}if(Y===Zl&&F===0)continue;if(Y===Pb0)return Y=VW.inflateEnd(this.strm),this.onEnd(Y),this.ended=!0,!0;if(B.avail_in===0)break}return!0};Gl.prototype.onData=function(A){this.chunks.push(A)};Gl.prototype.onEnd=function(A){if(A===Zl)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=L70.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};Dz6=Gl,Gz6=lb0,Vz6=Xz6,Uz6=lb0,Kz6=XO,Ez6={Inflate:Dz6,inflate:Gz6,inflateRaw:Vz6,ungzip:Uz6,constants:Kz6},{Deflate:Wz6,deflate:Hz6,deflateRaw:zz6,gzip:qz6}=wH6,{Inflate:Nz6,inflate:Iz6,inflateRaw:Cz6,ungzip:wz6}=Ez6,Mz6=Wz6,Lz6=Hz6,Oz6=zz6,jz6=qz6,Rz6=Nz6,Pz6=Iz6,_z6=Cz6,Tz6=wz6,Sz6=XO,e94={Deflate:Mz6,deflate:Lz6,deflateRaw:Oz6,gzip:jz6,Inflate:Rz6,inflate:Pz6,inflateRaw:_z6,ungzip:Tz6,constants:Sz6}});function kz6(A){if(A.proxy&&!process.env.HTTP_PROXY&&!process.env.http_proxy)process.env.HTTP_PROXY=A.proxy;if(A.proxy&&!process.env.HTTPS_PROXY&&!process.env.https_proxy)process.env.HTTPS_PROXY=A.proxy}function _Y(A,Q,B){let $=B?`/threads/${Q}/${B}`:`/threads/${Q}`;return new URL($,A)}async function q7(A,Q,B){let $=await B.getLatest(Q?.signal??void 0),J=await B74(A,Q,$);return fetch(J)}async function Q74(A,Q,B){let $=await B74(Q,B,A);return fetch($)}async function B74(A,Q,B){if(A.startsWith("http:")||A.startsWith("https:"))throw Error("input must be a path, not an absolute URL");if(!A.startsWith("/"))throw Error("pathAndQuery must start with /");let $=B.settings.url;if(!$)throw Error("amp.url is not set");let J=await B.secrets.getToken("apiKey",$);kz6({proxy:B.settings.proxy});let Y=new URL(A,$);return new Request(Y,{...Q,duplex:"half",headers:{"Content-Type":"application/json",...Q?.headers,...Z9(),...J?{Authorization:`Bearer ${J}`}:{}}})}async function $74(A,Q,B,$){let J=await lA.shareThreadWithOperator({threadID:A,message:B||void 0,ephemeralError:$||void 0},{config:Q});if(!J.ok)throw Error(`Failed to share thread: ${J.error.message}`)}async function j70(A,Q){let B=await q7("/api/telemetry",{method:"POST",redirect:"manual",body:A},Q);if(!B.ok){let $=await B.text(),J;try{J=JSON.parse($).error||`HTTP ${B.status}`}catch{J=$||`HTTP ${B.status}`}throw Error(`Failed to submit telemetry: ${J}`)}}var KQ=J0(()=>{sQ();EQ()});function yz6(A){if(new Blob([A]).size<=vz6)return{body:A};return{body:e94.gzip(A),headers:{"Content-Encoding":"gzip"}}}function xz6(){return new Proxy({},{get:(A,Q)=>{return async(...B)=>{let $=B.at(1),J=B.at(0);if(!$?.config)throw Error("Internal API client requires configService in options. Call with { config: configService }");let{body:Y,headers:Z={}}=yz6(JSON.stringify({method:Q,params:J})),F=await q7("/api/internal?"+encodeURIComponent(Q),{method:"POST",body:Y,headers:Z,signal:$?.signal},$.config);if(!F.ok)throw Error(`API request for ${Q} failed: ${F.status}`);return await F.json()}}})}var vz6=25600,lA;var EQ=J0(()=>{A74();KQ();lA=xz6()});function fz6(A){return A.config.pipe(w1(({settings:Q,secrets:B})=>({url:Q.url,proxy:Q.proxy,secrets:B})),l4(ic),c4((Q)=>B90(600000).pipe(R6(void 0),jk(()=>JA(async(B)=>{let $=await lA.getUserInfo({},{signal:B,config:A});if($.ok)return $.result;if($.error&&$.error.code==="auth-required")return null;throw T.error("getUserInfo failed",{error:$.error}),Error(`getUserInfo error: ${$.error.code}`)})))),w1((Q)=>{return Q instanceof Error?{error:{message:String(Q)}}:Q===dV?"pending":Q?{user:Q,features:Q.features,workspace:Q?.team,mysteriousMessage:Q?.mysteriousMessage}:{error:{message:"User not found"}}}),l4((Q,B)=>ic(Q,B)),sA({shouldCountRefs:!0}))}function YJ(A){let Q=J74.get(A);if(Q)return Q;let B=fz6(A);return J74.set(A,B),B}function gA(A){return Boolean(typeof A==="object"&&"user"in A&&A.user)}function UW(A){return typeof A==="object"&&"error"in A}var J74;var IF=J0(()=>{O1();l0();EQ();J74=new WeakMap});function R70(A,Q,B){if(A.startsWith("mcp__"))return Q.allowMcp??!1;if(A.startsWith("tb__")){if(!(Q.allowToolbox??!1))return!1;let $="subagentType"in Q?Q.subagentType:void 0;if($&&B){if(!B.subagentTypes)return!1;return B.subagentTypes.includes("all")||B.subagentTypes.includes($)}return!0}return Q.includeTools.includes(A)}var ib0,Y74,bz6,nb0,uz6,hz6,gz6=24,mz6=36,pz6,dz6,m3;var $U=J0(()=>{E7();ib0=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],Y74=["read_bitbucket_enterprise","search_bitbucket_enterprise","commit_search_bitbucket_enterprise","diff_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise"],bz6=["Grep","glob","Read"],nb0=["Read","Grep","glob","web_search","read_web_page","read_thread","find_thread"],uz6=["Grep","glob","Read","Bash","edit_file","create_file","read_web_page","get_diagnostics","web_search","finder","skill","task_list","look_at"],hz6=["Read","Grep","glob","web_search","read_web_page","Bash"],pz6=["Read","Grep","glob","web_search","read_web_page","Bash","eval_git_diff","post_explanation"],dz6=["Read","Grep","glob","Bash"],m3={finder:{key:"finder",displayName:"Finder",model:c5("CLAUDE_HAIKU_4_5"),includeTools:bz6,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:c5("GPT_5_4"),includeTools:nb0,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:c5("CLAUDE_SONNET_4_6"),includeTools:ib0,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:uz6,allowMcp:!0,allowToolbox:!0},"code-review":{key:"code-review",displayName:"Code Review",model:c5("GEMINI_3_1_PRO_PREVIEW"),maxTurns:gz6,includeTools:hz6,allowMcp:!1,allowToolbox:!1},"code-tour":{key:"code-tour",displayName:"Code Tour",model:c5("CLAUDE_OPUS_4_6"),includeTools:pz6,allowMcp:!1,allowToolbox:!1},"codereview-check":{key:"codereview-check",displayName:"Codereview Check",model:c5("CLAUDE_HAIKU_4_5"),maxTurns:mz6,includeTools:dz6,allowMcp:!1,allowToolbox:!1}}});function Z74(A,Q){return new g0((B)=>{let $=setTimeout(J,Q);function J(){B.error(Error(`Tool execution timed out after ${Q/1000} seconds`))}function Y(){if($)clearTimeout($);$=setTimeout(J,Q)}let Z=A.subscribe({next:(F)=>{Y(),B.next(F)},error:(F)=>{if($)clearTimeout($),$=null;B.error(F)},complete:()=>{if($)clearTimeout($),$=null;B.complete()}});return()=>{if($)clearTimeout($),$=null;Z.unsubscribe()}})}var F74=J0(()=>{O1()});function D74(A){return{tool:A,action:"allow"}}function cz6(A){if(!A||!("cmd"in A))return A;let{cmd:Q,...B}=A;return{...B,command:Q}}function lz6(A){return A.flatMap((Q)=>{if(Q.tool!==I6)return[];return[{...Q,tool:LY,matches:cz6(Q.matches)}]})}var X74,zv;var P70=J0(()=>{v4();X74=[{tool:"Bash",action:"ask",matches:{cmd:"*git*push*"}},{tool:"mcp__*",action:"allow"},{tool:G90,action:"allow"},{tool:"tb__*",action:"allow"},{tool:"Bash",matches:{cmd:"/^(.*\\s+)?(bazel|ibazel)\\s+.*\\/\\/[^\\s]*.*$/"},action:"allow"},{tool:"Bash",matches:{cmd:["ls","ls *","dir","dir *","cat *","head *","tail *","less *","more *","grep *","egrep *","fgrep *","tree","tree *","file *","wc *","pwd","stat *","du *","df *","ps *","top","htop","echo *","printenv *","id","which *","whereis *","date","cal *","uptime","free *","ping *","dig *","nslookup *","host *","netstat *","ss *","lsof *","ifconfig *","ip *","man *","info *","mkdir *","touch *","uname *","whoami","go version","go env *","go help *","cargo version","cargo --version","cargo help *","rustc --version","rustc --help","rustc --explain *","javac --version","javac -version","javac -help","javac --help","dotnet --info","dotnet --version","dotnet --help","dotnet help *","gcc --version","gcc -v","gcc --help","gcc -dumpversion","g++ --version","g++ -v","g++ --help","g++ -dumpversion","clang --version","clang --help","clang++ --version","clang++ --help","python -V","python --version","python -h","python --help","python3 -V","python3 --version","python3 -h","python3 --help","ruby -v","ruby --version","ruby -h","ruby --help","node -v","node --version","node -h","node --help","npm --help","npm --version","npm -v","npm help *","yarn --help","yarn --version","yarn -v","yarn help *","pnpm --help","pnpm --version","pnpm -v","pnpm help *","pytest -h","pytest --help","pytest --version","jest --help","jest --version","mocha --help","mocha --version","make --version","make --help","docker --version","docker --help","docker version","docker help *","git --version","git --help","git help *","git version"]},action:"allow"},{tool:"Bash",matches:{cmd:["go test *","go run *","go build *","go vet *","go fmt *","go list *","cargo test *","cargo run *","cargo build *","cargo check *","cargo fmt *","cargo tree *","make -n *","make --dry-run *","mvn test *","mvn verify *","mvn dependency:tree *","gradle tasks *","gradle dependencies *","gradle properties *","dotnet test *","dotnet list *","python -c *","ruby -e *","node -e *","npm list *","npm ls *","npm outdated *","npm test*","npm run*","npm view *","npm info *","yarn list*","yarn ls *","yarn info *","yarn test*","yarn run *","yarn why *","pnpm list*","pnpm ls *","pnpm outdated *","pnpm test*","pnpm run *","pytest --collect-only *","jest --listTests *","jest --showConfig *","mocha --list *","git status*","git show *","git diff*","git grep *","git branch *","git tag *","git remote -v *","git rev-parse --is-inside-work-tree *","git rev-parse --show-toplevel *","git config --list *","git log *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./gradlew *","./mvnw *","./build.sh *","./configure *","cmake *","./node_modules/.bin/tsc *","./node_modules/.bin/eslint *","./node_modules/.bin/prettier *","prettier *","./node_modules/.bin/tailwindcss *","./node_modules/.bin/tsx *","./node_modules/.bin/vite *","bun *","tsx *","vite *"]},action:"allow"},{tool:"Bash",matches:{cmd:[".venv/bin/activate *",".venv/Scripts/activate *","source .venv/bin/activate *","source venv/bin/activate *","pip list *","pip show *","pip check *","pip freeze *","uv *","poetry show *","poetry check *","pipenv check *"]},action:"allow"},{tool:"Bash",matches:{cmd:["asdf list *","asdf current *","asdf which *","mise list *","mise current *","mise which *","mise use *","rbenv version *","rbenv versions *","rbenv which *","nvm list *","nvm current *","nvm which *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./test*","./run_tests.sh *","./run_*_tests.sh *","vitest *","bundle exec rspec *","bundle exec rubocop *","rspec *","rubocop *","swiftlint *","clippy *","ruff *","black *","isort *","mypy *","flake8 *","bandit *","safety *","biome check *","biome format *"]},action:"allow"},{tool:"Bash",matches:{cmd:["rails server *","rails s *","bin/rails server *","bin/rails s *","flask run *","django-admin runserver *","python manage.py runserver *","uvicorn *","streamlit run *"]},action:"allow"},{tool:"Bash",matches:{cmd:["bin/rails db:status","bin/rails db:version","rails db:rollback *","rails db:status *","rails db:version *","alembic current *","alembic history *","bundle exec rails db:status","bundle exec rails db:version"]},action:"allow"},{tool:"Bash",matches:{cmd:["docker ps *","docker images *","docker logs *","docker inspect *","docker info *","docker stats *","docker system df *","docker system info *","podman ps *","podman images *","podman logs *","podman inspect *","podman info *"]},action:"allow"},{tool:"Bash",matches:{cmd:["aws --version *","aws configure list *","aws sts get-caller-identity *","aws s3 ls *","gcloud config list *","gcloud auth list *","gcloud projects list *","az account list *","az account show *","kubectl get *","kubectl describe *","kubectl logs *","kubectl version *","helm list *","helm status *","helm version *"]},action:"allow"},{tool:"Bash",matches:{cmd:["swift build *","swift test *","zig build *","zig build test*","kotlinc *","scalac *","javac *","javap *","clang *","jar *","sbt *","gradle *","bazel build *","bazel test *","bazel run *","mix *","lua *","ruby *","php *"]},action:"allow"},{tool:"Bash",matches:{cmd:["mkdir -p *","chmod +x *","dos2unix *","unix2dos *","ln -s *"]},action:"allow"},{tool:"Bash",matches:{cmd:["for *","while *","do *","done *","if *","then *","else *","elif *","fi *","case *","esac *","in *","function *","select *","until *","{ *","} *","[[ *","]] *"]},action:"ask"},{tool:"Bash",matches:{cmd:"/^find(?!.*(-delete|-exec|-execdir)).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(echo|ls|pwd|date|whoami|id|uname)\\s.*[&|;].*\\s*(echo|ls|pwd|date|whoami|id|uname)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(cat|grep|head|tail|less|more|find)\\s.*\\|\\s*(grep|head|tail|less|more|wc|sort|uniq)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^rm\\s+.*(-[rf].*-[rf]|-[rf]{2,}|--recursive.*--force|--force.*--recursive).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^find.*(-delete|-exec|-execdir).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^(ls|cat|grep|head|tail|file|stat)\\s+[^/]*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/(^|\\s)(\\/(?!dev\\/(null|zero|stdout|stderr|stdin))[^\\s]*|\\.\\.\\/)(?![^\\s]*\\.(log|txt|md|json|yml|yaml)$)/"},action:"ask"},{tool:"Bash",action:"ask"},D74("Glob")],zv=[...X74,...lz6(X74),...l64.map(D74)]});class G74{input;position=0;line=1;column=1;tokens=[];constructor(A){this.input=A}current(){return this.position<this.input.length?this.input[this.position]:""}peek(){return this.position+1<this.input.length?this.input[this.position+1]:""}advance(){let A=this.current();if(this.position++,A===`
244
+ `+B)}function tL(A,Q,B,$,J,Y){if(A.listenerCount("wsClientError")){let Z=Error(J);Error.captureStackTrace(Z,tL),A.emit("wsClientError",Z,B,Q)}else yc(B,$,J,Y)}});var fc={};L2(fc,{subprotocol:()=>t34.default,extension:()=>a34.default,default:()=>MK6,createWebSocketStream:()=>n34.default,WebSocketServer:()=>e34.default,WebSocket:()=>xc.default,Sender:()=>s34.default,Receiver:()=>r34.default,PerMessageDeflate:()=>o34.default});var n34,a34,o34,r34,s34,t34,xc,e34,MK6;var bc=J0(()=>{n34=H4(g34(),1),a34=H4(s90(),1),o34=H4(tk(),1),r34=H4(kf0(),1),s34=H4(yf0(),1),t34=H4(gf0(),1),xc=H4(Q70(),1),e34=H4(i34(),1),MK6=xc.default});class Q24{_status={};statusSubject=new M4(this._status);projectConfig;queryPollTimeout;queryPollToken=0;querySource;ws;id=1;reconnectTimeoutId;reconnectStartTime;isReconnecting=!1;connectionSource="never-connected";pendingRequests=new Map;constructor(){this.statusSubject.subscribe((A)=>{if(A.ideName){let Q=p90(A.ideName);if(Q)iL(Q)}})}get status(){return new g0((A)=>{A.next(this._status);let Q=this.statusSubject.subscribe(A);return()=>Q.unsubscribe()})}sendStatus(A){this._status={...this._status,...A},this.statusSubject.next(this._status)}getIdeName(){return this._status.ideName||"ide"}async start(A,Q=!1,B){if(A.connection!=="query"&&ak(A.ideName)){this.projectConfig=void 0,this.clearReconnectTimeout(),this.ws?.close(),this.ws=void 0,this.clearPendingRequests(),this.stopQueryPolling(),this.sendStatus({enabled:!0,ideName:A.ideName,connected:!1,authenticated:!1,connectionState:"disconnected",reconnectElapsedMs:void 0,errorMessage:`Amp connects to ${A.ideName} through file queries, not websockets`,openFile:void 0,selections:void 0,visibleFiles:void 0});return}let $=Q||!this.projectConfig||this.projectConfig.port!==A.port||this.projectConfig.authToken!==A.authToken||this.projectConfig.connection!==A.connection||this.projectConfig.workspaceId!==A.workspaceId;if(this.projectConfig=A,this.sendStatus({enabled:!0}),this.connectionSource=B??"auto-startup",$&&this.ws)this.ws.close(),this.ws=void 0,this.clearPendingRequests();this.stopQueryPolling(),await this.tryConnect(this.projectConfig)}sendRequest=(A,Q)=>{let B=this.ws;if(!B)return Promise.resolve(void 0);if(!this.isWsOpen())return Promise.reject(Error("WebSocket is not open"));return new Promise(($,J)=>{let Y=`${this.id++}`,Z={clientRequest:{id:Y,[A]:Q}},F=setTimeout(()=>{this.pendingRequests.delete(Y),J(Error(`Timeout after ${A24}ms for request ${JSON.stringify(Z,null,2)}`))},A24);this.pendingRequests.set(Y,{resolve:$,reject:J,timeout:F,method:A}),B.send(JSON.stringify(Z))})};clearPendingRequests(){for(let[A,Q]of this.pendingRequests.entries())clearTimeout(Q.timeout),Q.reject(Error("WebSocket connection closed"));this.pendingRequests.clear()}handleResponse(A){if(!A?.id)return;let Q=this.pendingRequests.get(A.id);if(!Q)return;if(T.debug("ide-client: received response",{type:"response_received",source:this.getIdeName(),responseId:A?.id,hasError:!!A?.error}),clearTimeout(Q.timeout),this.pendingRequests.delete(A.id),A.error){Q.reject(Error(JSON.stringify(A.error)));return}let B=A[Q.method];if(B)Q.resolve(B);else Q.reject(Error(`Invalid response for method ${Q.method}. Got ${JSON.stringify(A,null,2)}`))}async tryConnect(A){if(A.connection==="query"){let $=this.resolveQuery(A);if($)this.startQueryPolling(A,$);return}if(await this.isConnected()){T.debug("ide-client: already connected",{type:"already_connected",source:this.getIdeName()});return}if(this.clearReconnectTimeout(),this.ws?.close(),this.clearPendingRequests(),!A){this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"});return}this.sendStatus({ideName:A.ideName});let B=new(await RK6())(`ws://localhost:${A.port}?auth=${encodeURIComponent(A.authToken)}`);this.ws=B,this.id=1,B.onopen=async()=>{try{if(T.info("ide-client: connected",{type:"connected",source:this.getIdeName(),ideName:A.ideName,port:A.port}),this.connectionSource!=="never-connected")this.connectionSource="user-initiated";this.clearReconnectTimeout(),this.reconnectStartTime=void 0,this.isReconnecting=!1,this.sendStatus({connected:!0,authenticated:!0,connectionState:"connected",reconnectElapsedMs:void 0,errorMessage:void 0})}catch($){T.error("ide-client: connection error",$),this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"})}},B.onclose=($)=>{try{if(this.clearPendingRequests(),$.code===1000&&$.reason==="Authentication failed")this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE authentication failed - try restarting your IDE"});else T.warn("ide-client: disconnected",{code:$.code,reason:$.reason}),this.sendStatus({connected:!1,authenticated:!1,openFile:void 0,selections:void 0,errorMessage:"IDE Not Connected"});this.ws=void 0,this.scheduleReconnect()}catch(J){T.error("ide-client: disconnect error",J)}},B.onerror=()=>{this.clearPendingRequests()},B.onmessage=async($)=>{let J=$.data.toString();try{let Y=q84.safeParse(JSON.parse(J));if(Y.error){T.error("ide-client: failed to parse server message",v.prettifyError(Y.error));return}if(Y.data?.serverResponse)this.handleResponse(Y.data.serverResponse);this.handleNotification(Y.data?.serverNotification)}catch(Y){T.error("ide-client: error handling server message",{error:Y,data:J})}}}clearReconnectTimeout(){if(this.reconnectTimeoutId)clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=void 0}scheduleReconnect(){if(this.connectionSource==="never-connected")return;if(this.isReconnecting)return;if(!this.reconnectStartTime)this.reconnectStartTime=Date.now();let A=Date.now()-this.reconnectStartTime;if(A>=OK6){this.sendStatus({connectionState:"disconnected",reconnectElapsedMs:A});let Q=60000-A;if(Q>0)this.clearReconnectTimeout(),this.reconnectTimeoutId=setTimeout(()=>{let B=Date.now()-(this.reconnectStartTime||Date.now());this.sendStatus({connectionState:"disconnected",reconnectElapsedMs:B})},Q);return}this.isReconnecting=!0,this.sendStatus({connectionState:"reconnecting",reconnectElapsedMs:A,ideName:this.projectConfig?.ideName}),this.reconnectTimeoutId=setTimeout(()=>{this.executeReconnectAttempt().catch((Q)=>{T.error("ide-client: reconnect timer failed",Q)})},LK6)}async executeReconnectAttempt(){try{if(!this.projectConfig){T.debug("ide-client: no config available during reconnect, will retry");return}let A=await this.resolveActiveConfig(this.projectConfig);this.projectConfig=A,await this.tryConnect(A)}catch(A){T.error("ide-client: reconnect loop error",A)}finally{this.handleReconnectResult(await this.isConnected())}}async resolveActiveConfig(A){if(A.connection==="query"){let{config:B}=await this.findQueryConfig(A);return B??A}if(eE(A.pid))return A;return(await ID()).find((B)=>B.ideName===A.ideName&&B.workspaceFolders.length===A.workspaceFolders.length&&B.workspaceFolders.every(($)=>A.workspaceFolders.includes($)))??A}handleReconnectResult(A){if(this.isReconnecting=!1,!A)this.scheduleReconnect();else this.clearReconnectTimeout(),this.reconnectStartTime=void 0,this.sendStatus({connectionState:"connected",reconnectElapsedMs:void 0})}startQueryPolling(A,Q){this.stopQueryPolling();let B=++this.queryPollToken;this.querySource={config:A,query:Q},this.sendStatus({ideName:Q.ideName,workspace:A.workspaceFolders[0],connected:!0,authenticated:!0,connectionState:"connected",reconnectElapsedMs:void 0,errorMessage:void 0});let $=async()=>{if(B!==this.queryPollToken)return;let J;try{J=await Q.readWorkspaceState(A)}catch(Y){T.warn("ide-client: query poll failed",{ideName:Q.ideName,error:Y}),J=null}if(B!==this.queryPollToken)return;if(!J){this.sendStatus({connected:!1,authenticated:!1,connectionState:"disconnected",errorMessage:`${Q.ideName} Not Connected`,openFile:void 0,selections:void 0,visibleFiles:void 0}),this.stopQueryPolling(),this.scheduleReconnect();return}this.sendStatus({connected:!0,authenticated:!0,connectionState:"connected",openFile:J.openFile,selections:J.selection?[J.selection]:void 0,visibleFiles:J.openFiles}),this.queryPollTimeout=setTimeout(()=>{$()},jK6)};$()}stopQueryPolling(){if(this.queryPollToken+=1,this.queryPollTimeout)clearTimeout(this.queryPollTimeout),this.queryPollTimeout=void 0}isWsOpen(){return this.ws?.readyState===1}async isConnected(){if(this.projectConfig?.connection==="query")return this._status.connected===!0;if(!this._status.authenticated)return!1;if(!this.isWsOpen())return!1;try{return(await this.sendRequest("ping",{message:"beepboop"}))?.message==="beepboop"}catch(A){return T.debug("isConnected ping failed",{error:A}),!1}}async requestDiagnosticsFromIDE(A){try{return await this.sendRequest("getDiagnostics",{path:A})}catch(Q){T.debug("ide-diags: failed to request diagnostics from IDE",{error:Q,path:A});return}}async openURIInIDE(A){if(this.projectConfig?.connection==="query")return this.querySource?.query.openURI(A);if(!this.isWsOpen())return;try{let Q=await this.sendRequest("openURI",{uri:A});if(!Q)return!1;return!!Q.success}catch(Q){return T.debug("ide-client: openURI request failed",{error:Q,uri:A}),!1}}handleNotification(A){if(!A)return;if(A.selectionDidChange)this.sendStatus({selections:A.selectionDidChange.selections,openFile:A.selectionDidChange.uri});else if(A.visibleFilesDidChange){let Q=A.visibleFilesDidChange.uris;this.sendStatus({visibleFiles:Q,...Q.length===0&&{openFile:void 0,selections:void 0}})}else if(A.pluginMetadata)this.sendStatus({pluginVersion:A.pluginMetadata.version,pluginDirectory:A.pluginMetadata.pluginDirectory})}async findQueryConfig(A){let B=(A.workspaceId?A:(await this.listQueryConfigs()).find((J)=>J.workspaceFolders.every((Y)=>A.workspaceFolders.includes(Y))))??(await ID({includeAll:!0})).find((J)=>J.connection==="query"&&J.workspaceId===A.workspaceId);if(!B)return{};let $=this.resolveQuery(B);if(!$)return{config:B};return{query:$,config:B}}async listQueryConfigs(){return(await Promise.all(aL.map(async(Q)=>{try{return await Q.listConfigs()}catch(B){return T.debug("ide-client: failed to list query configs",{ideName:Q.ideName,error:B}),[]}}))).flat()}resolveQuery(A){return aL.find((Q)=>Q.ideName===A.ideName)}selectConfig(A){this.projectConfig=A}getSelectedConfig(){return this.projectConfig}}async function RK6(){if(typeof WebSocket<"u")return WebSocket;let{default:A}=await Promise.resolve().then(() => (bc(),fc));return A}var A24=2000,LK6=1000,OK6=30000,jK6=1000,i8;var JW=J0(()=>{O1();h3();l0();sQ();g90();dq();ok();Ef0();i8=new Q24});var pf0,df0,cf0,uc;var $70=J0(()=>{pf0=class pf0 extends Error{constructor(A="Unauthorized"){super(A);this.name="UnauthorizedError"}};df0=class df0 extends Error{constructor(A="OAuth callback timeout"){super(A);this.name="OAuthTimeoutError"}};cf0=class cf0 extends Error{serverName;constructor(A){super(`OAuth flow skipped for "${A}"`);this.serverName=A;this.name="OAuthSkippedError"}};uc=class uc extends Error{serverName;holderPid;constructor(A,Q){super(`OAuth flow already in progress for "${A}" (held by PID ${Q})`);this.serverName=A;this.holderPid=Q;this.name="OAuthFlowInProgressError"}}});import{randomBytes as bK6}from"node:crypto";import*as $J from"node:fs/promises";import*as nf0 from"node:path";function Y24(A){return X70(A)}function hK6(A){return A.replace(/[^a-zA-Z0-9_-]/g,"_")}function X70(A){return nf0.join(J24,`${hK6(A)}.lock`)}async function gK6(){await $J.mkdir(J24,{recursive:!0,mode:448})}function mK6(A){try{return process.kill(A,0),!0}catch{return!1}}function if0(A){if(Date.now()-A.timestamp>uK6)return!0;let B=U0("node:os").hostname();if(A.hostname===B&&!mK6(A.pid))return!0;return!1}async function Y70(A){let Q=X70(A);try{let B=await $J.readFile(Q,"utf8"),$=JSON.parse(B);if(typeof $.pid!=="number"||typeof $.timestamp!=="number")return T.warn("Invalid lock file structure, treating as stale",{serverName:A,lockPath:Q}),null;return $}catch(B){if(B?.code==="ENOENT")return null;return T.debug("Failed to read lock file",{serverName:A,error:B.message}),null}}async function eL(A){await gK6();let Q=X70(A),B=await Y70(A);if(B)if(if0(B)){T.info("Removing stale OAuth lock",{serverName:A,stalePid:B.pid,ageMs:Date.now()-B.timestamp});try{await $J.unlink(Q)}catch{}}else return T.debug("OAuth lock held by another process",{serverName:A,holderPid:B.pid,ageMs:Date.now()-B.timestamp}),{acquired:!1,holder:B};let $={pid:process.pid,timestamp:Date.now(),hostname:U0("node:os").hostname()},J=JSON.stringify($),Y=`${Q}.${process.pid}.${bK6(4).toString("hex")}`;try{let Z=await $J.open(Y,"wx",384);try{await Z.writeFile(J),await Z.sync()}finally{await Z.close()}try{return await $J.link(Y,Q),await $J.unlink(Y).catch(()=>{}),T.info("Acquired OAuth lock",{serverName:A,pid:process.pid}),{acquired:!0}}catch(F){if(await $J.unlink(Y).catch(()=>{}),F?.code==="EEXIST"){let X=await Y70(A);if(X&&!if0(X))return T.debug("Lost OAuth lock race to another process",{serverName:A,winnerPid:X.pid}),{acquired:!1,holder:X};return eL(A)}throw F}}catch(Z){if(await $J.unlink(Y).catch(()=>{}),Z?.code==="EEXIST"){let F=await Y70(A);if(F&&!if0(F))return{acquired:!1,holder:F};return eL(A)}throw T.error("Failed to acquire OAuth lock",{serverName:A,error:Z.message}),Z}}async function Yv(A){let Q=X70(A);try{let B=await Y70(A);if(!B){T.debug("No lock to release",{serverName:A});return}if(B.pid!==process.pid){T.warn("Cannot release lock owned by another process",{serverName:A,ownerPid:B.pid,ourPid:process.pid});return}await $J.unlink(Q),T.info("Released OAuth lock",{serverName:A,pid:process.pid})}catch(B){if(B?.code==="ENOENT")return;T.error("Failed to release OAuth lock",{serverName:A,error:B.message})}}var J24,uK6=300000,Z70=2000,F70=300000;var af0=J0(()=>{KD();l0();J24=nf0.join(Ik,"oauth","locks")});function X24(A){return A.replace(/ /g,"\\ ")}var F24=100;var sf0=()=>{};var gc=y((mm8,G24)=>{var D24={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},lK6={...D24,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},iK6={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};G24.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:65536,POSIX_REGEX_SOURCE:iK6,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(A){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${A.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(A){return A===!0?lK6:D24}}});var mc=y((sK6)=>{var{REGEX_BACKSLASH:nK6,REGEX_REMOVE_BACKSLASH:aK6,REGEX_SPECIAL_CHARS:oK6,REGEX_SPECIAL_CHARS_GLOBAL:rK6}=gc();sK6.isObject=(A)=>A!==null&&typeof A==="object"&&!Array.isArray(A);sK6.hasRegexChars=(A)=>oK6.test(A);sK6.isRegexChar=(A)=>A.length===1&&sK6.hasRegexChars(A);sK6.escapeRegex=(A)=>A.replace(rK6,"\\$1");sK6.toPosixSlashes=(A)=>A.replace(nK6,"/");sK6.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let A=navigator.platform.toLowerCase();return A==="win32"||A==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};sK6.removeBackslashes=(A)=>{return A.replace(aK6,(Q)=>{return Q==="\\"?"":Q})};sK6.escapeLast=(A,Q,B)=>{let $=A.lastIndexOf(Q,B);if($===-1)return A;if(A[$-1]==="\\")return sK6.escapeLast(A,Q,$-1);return`${A.slice(0,$)}\\${A.slice($)}`};sK6.removePrefix=(A,Q={})=>{let B=A;if(B.startsWith("./"))B=B.slice(2),Q.prefix="./";return B};sK6.wrapOutput=(A,Q={},B={})=>{let $=B.contains?"":"^",J=B.contains?"":"$",Y=`${$}(?:${A})${J}`;if(Q.negated===!0)Y=`(?:^(?!${Y}).*$)`;return Y};sK6.basename=(A,{windows:Q}={})=>{let B=A.split(Q?/[\\/]/:"/"),$=B[B.length-1];if($==="")return B[B.length-2];return $}});var I24=y((dm8,N24)=>{var K24=mc(),{CHAR_ASTERISK:tf0,CHAR_AT:FE6,CHAR_BACKWARD_SLASH:pc,CHAR_COMMA:XE6,CHAR_DOT:ef0,CHAR_EXCLAMATION_MARK:Ab0,CHAR_FORWARD_SLASH:q24,CHAR_LEFT_CURLY_BRACE:Qb0,CHAR_LEFT_PARENTHESES:Bb0,CHAR_LEFT_SQUARE_BRACKET:DE6,CHAR_PLUS:GE6,CHAR_QUESTION_MARK:E24,CHAR_RIGHT_CURLY_BRACE:VE6,CHAR_RIGHT_PARENTHESES:W24,CHAR_RIGHT_SQUARE_BRACKET:UE6}=gc(),H24=(A)=>{return A===q24||A===pc},z24=(A)=>{if(A.isPrefix!==!0)A.depth=A.isGlobstar?1/0:1},KE6=(A,Q)=>{let B=Q||{},$=A.length-1,J=B.parts===!0||B.scanToEnd===!0,Y=[],Z=[],F=[],X=A,D=-1,G=0,V=0,U=!1,K=!1,E=!1,W=!1,H=!1,z=!1,q=!1,N=!1,I=!1,C=!1,w=0,M,j,P={value:"",depth:0,isGlob:!1},R=()=>D>=$,b=()=>X.charCodeAt(D+1),g=()=>{return M=j,X.charCodeAt(++D)};while(D<$){j=g();let p;if(j===pc){if(q=P.backslashes=!0,j=g(),j===Qb0)z=!0;continue}if(z===!0||j===Qb0){w++;while(R()!==!0&&(j=g())){if(j===pc){q=P.backslashes=!0,g();continue}if(j===Qb0){w++;continue}if(z!==!0&&j===ef0&&(j=g())===ef0){if(U=P.isBrace=!0,E=P.isGlob=!0,C=!0,J===!0)continue;break}if(z!==!0&&j===XE6){if(U=P.isBrace=!0,E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===VE6){if(w--,w===0){z=!1,U=P.isBrace=!0,C=!0;break}}}if(J===!0)continue;break}if(j===q24){if(Y.push(D),Z.push(P),P={value:"",depth:0,isGlob:!1},C===!0)continue;if(M===ef0&&D===G+1){G+=2;continue}V=D+1;continue}if(B.noext!==!0){if((j===GE6||j===FE6||j===tf0||j===E24||j===Ab0)===!0&&b()===Bb0){if(E=P.isGlob=!0,W=P.isExtglob=!0,C=!0,j===Ab0&&D===G)I=!0;if(J===!0){while(R()!==!0&&(j=g())){if(j===pc){q=P.backslashes=!0,j=g();continue}if(j===W24){E=P.isGlob=!0,C=!0;break}}continue}break}}if(j===tf0){if(M===tf0)H=P.isGlobstar=!0;if(E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===E24){if(E=P.isGlob=!0,C=!0,J===!0)continue;break}if(j===DE6){while(R()!==!0&&(p=g())){if(p===pc){q=P.backslashes=!0,g();continue}if(p===UE6){K=P.isBracket=!0,E=P.isGlob=!0,C=!0;break}}if(J===!0)continue;break}if(B.nonegate!==!0&&j===Ab0&&D===G){N=P.negated=!0,G++;continue}if(B.noparen!==!0&&j===Bb0){if(E=P.isGlob=!0,J===!0){while(R()!==!0&&(j=g())){if(j===Bb0){q=P.backslashes=!0,j=g();continue}if(j===W24){C=!0;break}}continue}break}if(E===!0){if(C=!0,J===!0)continue;break}}if(B.noext===!0)W=!1,E=!1;let f=X,k="",x="";if(G>0)k=X.slice(0,G),X=X.slice(G),V-=G;if(f&&E===!0&&V>0)f=X.slice(0,V),x=X.slice(V);else if(E===!0)f="",x=X;else f=X;if(f&&f!==""&&f!=="/"&&f!==X){if(H24(f.charCodeAt(f.length-1)))f=f.slice(0,-1)}if(B.unescape===!0){if(x)x=K24.removeBackslashes(x);if(f&&q===!0)f=K24.removeBackslashes(f)}let m={prefix:k,input:A,start:G,base:f,glob:x,isBrace:U,isBracket:K,isGlob:E,isExtglob:W,isGlobstar:H,negated:N,negatedExtglob:I};if(B.tokens===!0){if(m.maxDepth=0,!H24(j))Z.push(P);m.tokens=Z}if(B.parts===!0||B.tokens===!0){let p;for(let u=0;u<Y.length;u++){let a=p?p+1:G,c=Y[u],s=A.slice(a,c);if(B.tokens){if(u===0&&G!==0)Z[u].isPrefix=!0,Z[u].value=k;else Z[u].value=s;z24(Z[u]),m.maxDepth+=Z[u].depth}if(u!==0||s!=="")F.push(s);p=c}if(p&&p+1<A.length){let u=A.slice(p+1);if(F.push(u),B.tokens)Z[Z.length-1].value=u,z24(Z[Z.length-1]),m.maxDepth+=Z[Z.length-1].depth}m.slashes=Y,m.parts=F}return m};N24.exports=KE6});var O24=y((cm8,L24)=>{var dc=gc(),jY=mc(),{MAX_LENGTH:D70,POSIX_REGEX_SOURCE:EE6,REGEX_NON_SPECIAL_CHARS:WE6,REGEX_SPECIAL_CHARS_BACKREF:HE6,REPLACEMENTS:C24}=dc,zE6=(A,Q)=>{if(typeof Q.expandRange==="function")return Q.expandRange(...A,Q);A.sort();let B=`[${A.join("-")}]`;try{new RegExp(B)}catch($){return A.map((J)=>jY.escapeRegex(J)).join("..")}return B},Zv=(A,Q)=>{return`Missing ${A}: "${Q}" - use "\\\\${Q}" to match literal characters`},w24=(A)=>{let Q=[],B=0,$=0,J=0,Y="",Z=!1;for(let F of A){if(Z===!0){Y+=F,Z=!1;continue}if(F==="\\"){Y+=F,Z=!0;continue}if(F==='"'){J=J===1?0:1,Y+=F;continue}if(J===0){if(F==="[")B++;else if(F==="]"&&B>0)B--;else if(B===0){if(F==="(")$++;else if(F===")"&&$>0)$--;else if(F==="|"&&$===0){Q.push(Y),Y="";continue}}}Y+=F}return Q.push(Y),Q},qE6=(A)=>{let Q=!1;for(let B of A){if(Q===!0){Q=!1;continue}if(B==="\\"){Q=!0;continue}if(/[?*+@!()[\]{}]/.test(B))return!1}return!0},M24=(A)=>{let Q=A.trim(),B=!0;while(B===!0)if(B=!1,/^@\([^\\()[\]{}|]+\)$/.test(Q))Q=Q.slice(2,-1),B=!0;if(!qE6(Q))return;return Q.replace(/\\(.)/g,"$1")},NE6=(A)=>{let Q=A.map(M24).filter(Boolean);for(let B=0;B<Q.length;B++)for(let $=B+1;$<Q.length;$++){let J=Q[B],Y=Q[$],Z=J[0];if(!Z||J!==Z.repeat(J.length)||Y!==Z.repeat(Y.length))continue;if(J===Y||J.startsWith(Y)||Y.startsWith(J))return!0}return!1},$b0=(A,Q=!0)=>{if(A[0]!=="+"&&A[0]!=="*"||A[1]!=="(")return;let B=0,$=0,J=0,Y=!1;for(let Z=1;Z<A.length;Z++){let F=A[Z];if(Y===!0){Y=!1;continue}if(F==="\\"){Y=!0;continue}if(F==='"'){J=J===1?0:1;continue}if(J===1)continue;if(F==="["){B++;continue}if(F==="]"&&B>0){B--;continue}if(B>0)continue;if(F==="("){$++;continue}if(F===")"){if($--,$===0){if(Q===!0&&Z!==A.length-1)return;return{type:A[0],body:A.slice(2,Z),end:Z}}}}},IE6=(A)=>{let Q=0,B=[];while(Q<A.length){let J=$b0(A.slice(Q),!1);if(!J||J.type!=="*")return;let Y=w24(J.body).map((F)=>F.trim());if(Y.length!==1)return;let Z=M24(Y[0]);if(!Z||Z.length!==1)return;B.push(Z),Q+=J.end+1}if(B.length<1)return;return`${B.length===1?jY.escapeRegex(B[0]):`[${B.map((J)=>jY.escapeRegex(J)).join("")}]`}*`},CE6=(A)=>{let Q=0,B=A.trim(),$=$b0(B);while($)Q++,B=$.body.trim(),$=$b0(B);return Q},wE6=(A,Q)=>{if(Q.maxExtglobRecursion===!1)return{risky:!1};let B=typeof Q.maxExtglobRecursion==="number"?Q.maxExtglobRecursion:dc.DEFAULT_MAX_EXTGLOB_RECURSION,$=w24(A).map((J)=>J.trim());if($.length>1){if($.some((J)=>J==="")||$.some((J)=>/^[*?]+$/.test(J))||NE6($))return{risky:!0}}for(let J of $){let Y=IE6(J);if(Y)return{risky:!0,safeOutput:Y};if(CE6(J)>B)return{risky:!0}}return{risky:!1}},Jb0=(A,Q)=>{if(typeof A!=="string")throw TypeError("Expected a string");A=C24[A]||A;let B={...Q},$=typeof B.maxLength==="number"?Math.min(D70,B.maxLength):D70,J=A.length;if(J>$)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${$}`);let Y={type:"bos",value:"",output:B.prepend||""},Z=[Y],F=B.capture?"":"?:",X=dc.globChars(B.windows),D=dc.extglobChars(X),{DOT_LITERAL:G,PLUS_LITERAL:V,SLASH_LITERAL:U,ONE_CHAR:K,DOTS_SLASH:E,NO_DOT:W,NO_DOT_SLASH:H,NO_DOTS_SLASH:z,QMARK:q,QMARK_NO_DOT:N,STAR:I,START_ANCHOR:C}=X,w=(Z0)=>{return`(${F}(?:(?!${C}${Z0.dot?E:G}).)*?)`},M=B.dot?"":W,j=B.dot?q:N,P=B.bash===!0?w(B):I;if(B.capture)P=`(${P})`;if(typeof B.noext==="boolean")B.noextglob=B.noext;let R={input:A,index:-1,start:0,dot:B.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:Z};A=jY.removePrefix(A,R),J=A.length;let b=[],g=[],f=[],k=Y,x,m=()=>R.index===J-1,p=R.peek=(Z0=1)=>A[R.index+Z0],u=R.advance=()=>A[++R.index]||"",a=()=>A.slice(R.index+1),c=(Z0="",d=0)=>{R.consumed+=Z0,R.index+=d},s=(Z0)=>{R.output+=Z0.output!=null?Z0.output:Z0.value,c(Z0.value)},W0=()=>{let Z0=1;while(p()==="!"&&(p(2)!=="("||p(3)==="?"))u(),R.start++,Z0++;if(Z0%2===0)return!1;return R.negated=!0,R.start++,!0},i=(Z0)=>{R[Z0]++,f.push(Z0)},A0=(Z0)=>{R[Z0]--,f.pop()},D0=(Z0)=>{if(k.type==="globstar"){let d=R.braces>0&&(Z0.type==="comma"||Z0.type==="brace"),n=Z0.extglob===!0||b.length&&(Z0.type==="pipe"||Z0.type==="paren");if(Z0.type!=="slash"&&Z0.type!=="paren"&&!d&&!n)R.output=R.output.slice(0,-k.output.length),k.type="star",k.value="*",k.output=P,R.output+=k.output}if(b.length&&Z0.type!=="paren")b[b.length-1].inner+=Z0.value;if(Z0.value||Z0.output)s(Z0);if(k&&k.type==="text"&&Z0.type==="text"){k.output=(k.output||k.value)+Z0.value,k.value+=Z0.value;return}Z0.prev=k,Z.push(Z0),k=Z0},z0=(Z0,d)=>{let n={...D[d],conditions:1,inner:""};n.prev=k,n.parens=R.parens,n.output=R.output,n.startIndex=R.index,n.tokensIndex=Z.length;let o=(B.capture?"(":"")+n.open;i("parens"),D0({type:Z0,value:d,output:R.output?"":K}),D0({type:"paren",extglob:!0,value:u(),output:o}),b.push(n)},B0=(Z0)=>{let d=A.slice(Z0.startIndex,R.index+1),n=A.slice(Z0.startIndex+2,R.index),o=wE6(n,B);if((Z0.type==="plus"||Z0.type==="star")&&o.risky){let $0=o.safeOutput?(Z0.output?"":K)+(B.capture?`(${o.safeOutput})`:o.safeOutput):void 0,K0=Z[Z0.tokensIndex];K0.type="text",K0.value=d,K0.output=$0||jY.escapeRegex(d);for(let N0=Z0.tokensIndex+1;N0<Z.length;N0++)Z[N0].value="",Z[N0].output="",delete Z[N0].suffix;R.output=Z0.output+K0.output,R.backtrack=!0,D0({type:"paren",extglob:!0,value:x,output:""}),A0("parens");return}let e=Z0.close+(B.capture?")":""),Y0;if(Z0.type==="negate"){let $0=P;if(Z0.inner&&Z0.inner.length>1&&Z0.inner.includes("/"))$0=w(B);if($0!==P||m()||/^\)+$/.test(a()))e=Z0.close=`)$))${$0}`;if(Z0.inner.includes("*")&&(Y0=a())&&/^\.[^\\/.]+$/.test(Y0)){let K0=Jb0(Y0,{...Q,fastpaths:!1}).output;e=Z0.close=`)${K0})${$0})`}if(Z0.prev.type==="bos")R.negatedExtglob=!0}D0({type:"paren",extglob:!0,value:x,output:e}),A0("parens")};if(B.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(A)){let Z0=!1,d=A.replace(HE6,(n,o,e,Y0,$0,K0)=>{if(Y0==="\\")return Z0=!0,n;if(Y0==="?"){if(o)return o+Y0+($0?q.repeat($0.length):"");if(K0===0)return j+($0?q.repeat($0.length):"");return q.repeat(e.length)}if(Y0===".")return G.repeat(e.length);if(Y0==="*"){if(o)return o+Y0+($0?P:"");return P}return o?n:`\\${n}`});if(Z0===!0)if(B.unescape===!0)d=d.replace(/\\/g,"");else d=d.replace(/\\+/g,(n)=>{return n.length%2===0?"\\\\":n?"\\":""});if(d===A&&B.contains===!0)return R.output=A,R;return R.output=jY.wrapOutput(d,R,Q),R}while(!m()){if(x=u(),x==="\x00")continue;if(x==="\\"){let n=p();if(n==="/"&&B.bash!==!0)continue;if(n==="."||n===";")continue;if(!n){x+="\\",D0({type:"text",value:x});continue}let o=/^\\+/.exec(a()),e=0;if(o&&o[0].length>2){if(e=o[0].length,R.index+=e,e%2!==0)x+="\\"}if(B.unescape===!0)x=u();else x+=u();if(R.brackets===0){D0({type:"text",value:x});continue}}if(R.brackets>0&&(x!=="]"||k.value==="["||k.value==="[^")){if(B.posix!==!1&&x===":"){let n=k.value.slice(1);if(n.includes("[")){if(k.posix=!0,n.includes(":")){let o=k.value.lastIndexOf("["),e=k.value.slice(0,o),Y0=k.value.slice(o+2),$0=EE6[Y0];if($0){if(k.value=e+$0,R.backtrack=!0,u(),!Y.output&&Z.indexOf(k)===1)Y.output=K;continue}}}}if(x==="["&&p()!==":"||x==="-"&&p()==="]")x=`\\${x}`;if(x==="]"&&(k.value==="["||k.value==="[^"))x=`\\${x}`;if(B.posix===!0&&x==="!"&&k.value==="[")x="^";k.value+=x,s({value:x});continue}if(R.quotes===1&&x!=='"'){x=jY.escapeRegex(x),k.value+=x,s({value:x});continue}if(x==='"'){if(R.quotes=R.quotes===1?0:1,B.keepQuotes===!0)D0({type:"text",value:x});continue}if(x==="("){i("parens"),D0({type:"paren",value:x});continue}if(x===")"){if(R.parens===0&&B.strictBrackets===!0)throw SyntaxError(Zv("opening","("));let n=b[b.length-1];if(n&&R.parens===n.parens+1){B0(b.pop());continue}D0({type:"paren",value:x,output:R.parens?")":"\\)"}),A0("parens");continue}if(x==="["){if(B.nobracket===!0||!a().includes("]")){if(B.nobracket!==!0&&B.strictBrackets===!0)throw SyntaxError(Zv("closing","]"));x=`\\${x}`}else i("brackets");D0({type:"bracket",value:x});continue}if(x==="]"){if(B.nobracket===!0||k&&k.type==="bracket"&&k.value.length===1){D0({type:"text",value:x,output:`\\${x}`});continue}if(R.brackets===0){if(B.strictBrackets===!0)throw SyntaxError(Zv("opening","["));D0({type:"text",value:x,output:`\\${x}`});continue}A0("brackets");let n=k.value.slice(1);if(k.posix!==!0&&n[0]==="^"&&!n.includes("/"))x=`/${x}`;if(k.value+=x,s({value:x}),B.literalBrackets===!1||jY.hasRegexChars(n))continue;let o=jY.escapeRegex(k.value);if(R.output=R.output.slice(0,-k.value.length),B.literalBrackets===!0){R.output+=o,k.value=o;continue}k.value=`(${F}${o}|${k.value})`,R.output+=k.value;continue}if(x==="{"&&B.nobrace!==!0){i("braces");let n={type:"brace",value:x,output:"(",outputIndex:R.output.length,tokensIndex:R.tokens.length};g.push(n),D0(n);continue}if(x==="}"){let n=g[g.length-1];if(B.nobrace===!0||!n){D0({type:"text",value:x,output:x});continue}let o=")";if(n.dots===!0){let e=Z.slice(),Y0=[];for(let $0=e.length-1;$0>=0;$0--){if(Z.pop(),e[$0].type==="brace")break;if(e[$0].type!=="dots")Y0.unshift(e[$0].value)}o=zE6(Y0,B),R.backtrack=!0}if(n.comma!==!0&&n.dots!==!0){let e=R.output.slice(0,n.outputIndex),Y0=R.tokens.slice(n.tokensIndex);n.value=n.output="\\{",x=o="\\}",R.output=e;for(let $0 of Y0)R.output+=$0.output||$0.value}D0({type:"brace",value:x,output:o}),A0("braces"),g.pop();continue}if(x==="|"){if(b.length>0)b[b.length-1].conditions++;D0({type:"text",value:x});continue}if(x===","){let n=x,o=g[g.length-1];if(o&&f[f.length-1]==="braces")o.comma=!0,n="|";D0({type:"comma",value:x,output:n});continue}if(x==="/"){if(k.type==="dot"&&R.index===R.start+1){R.start=R.index+1,R.consumed="",R.output="",Z.pop(),k=Y;continue}D0({type:"slash",value:x,output:U});continue}if(x==="."){if(R.braces>0&&k.type==="dot"){if(k.value===".")k.output=G;let n=g[g.length-1];k.type="dots",k.output+=x,k.value+=x,n.dots=!0;continue}if(R.braces+R.parens===0&&k.type!=="bos"&&k.type!=="slash"){D0({type:"text",value:x,output:G});continue}D0({type:"dot",value:x,output:G});continue}if(x==="?"){if(!(k&&k.value==="(")&&B.noextglob!==!0&&p()==="("&&p(2)!=="?"){z0("qmark",x);continue}if(k&&k.type==="paren"){let o=p(),e=x;if(k.value==="("&&!/[!=<:]/.test(o)||o==="<"&&!/<([!=]|\w+>)/.test(a()))e=`\\${x}`;D0({type:"text",value:x,output:e});continue}if(B.dot!==!0&&(k.type==="slash"||k.type==="bos")){D0({type:"qmark",value:x,output:N});continue}D0({type:"qmark",value:x,output:q});continue}if(x==="!"){if(B.noextglob!==!0&&p()==="("){if(p(2)!=="?"||!/[!=<:]/.test(p(3))){z0("negate",x);continue}}if(B.nonegate!==!0&&R.index===0){W0();continue}}if(x==="+"){if(B.noextglob!==!0&&p()==="("&&p(2)!=="?"){z0("plus",x);continue}if(k&&k.value==="("||B.regex===!1){D0({type:"plus",value:x,output:V});continue}if(k&&(k.type==="bracket"||k.type==="paren"||k.type==="brace")||R.parens>0){D0({type:"plus",value:x});continue}D0({type:"plus",value:V});continue}if(x==="@"){if(B.noextglob!==!0&&p()==="("&&p(2)!=="?"){D0({type:"at",extglob:!0,value:x,output:""});continue}D0({type:"text",value:x});continue}if(x!=="*"){if(x==="$"||x==="^")x=`\\${x}`;let n=WE6.exec(a());if(n)x+=n[0],R.index+=n[0].length;D0({type:"text",value:x});continue}if(k&&(k.type==="globstar"||k.star===!0)){k.type="star",k.star=!0,k.value+=x,k.output=P,R.backtrack=!0,R.globstar=!0,c(x);continue}let Z0=a();if(B.noextglob!==!0&&/^\([^?]/.test(Z0)){z0("star",x);continue}if(k.type==="star"){if(B.noglobstar===!0){c(x);continue}let n=k.prev,o=n.prev,e=n.type==="slash"||n.type==="bos",Y0=o&&(o.type==="star"||o.type==="globstar");if(B.bash===!0&&(!e||Z0[0]&&Z0[0]!=="/")){D0({type:"star",value:x,output:""});continue}let $0=R.braces>0&&(n.type==="comma"||n.type==="brace"),K0=b.length&&(n.type==="pipe"||n.type==="paren");if(!e&&n.type!=="paren"&&!$0&&!K0){D0({type:"star",value:x,output:""});continue}while(Z0.slice(0,3)==="/**"){let N0=A[R.index+4];if(N0&&N0!=="/")break;Z0=Z0.slice(3),c("/**",3)}if(n.type==="bos"&&m()){k.type="globstar",k.value+=x,k.output=w(B),R.output=k.output,R.globstar=!0,c(x);continue}if(n.type==="slash"&&n.prev.type!=="bos"&&!Y0&&m()){R.output=R.output.slice(0,-(n.output+k.output).length),n.output=`(?:${n.output}`,k.type="globstar",k.output=w(B)+(B.strictSlashes?")":"|$)"),k.value+=x,R.globstar=!0,R.output+=n.output+k.output,c(x);continue}if(n.type==="slash"&&n.prev.type!=="bos"&&Z0[0]==="/"){let N0=Z0[1]!==void 0?"|$":"";R.output=R.output.slice(0,-(n.output+k.output).length),n.output=`(?:${n.output}`,k.type="globstar",k.output=`${w(B)}${U}|${U}${N0})`,k.value+=x,R.output+=n.output+k.output,R.globstar=!0,c(x+u()),D0({type:"slash",value:"/",output:""});continue}if(n.type==="bos"&&Z0[0]==="/"){k.type="globstar",k.value+=x,k.output=`(?:^|${U}|${w(B)}${U})`,R.output=k.output,R.globstar=!0,c(x+u()),D0({type:"slash",value:"/",output:""});continue}R.output=R.output.slice(0,-k.output.length),k.type="globstar",k.output=w(B),k.value+=x,R.output+=k.output,R.globstar=!0,c(x);continue}let d={type:"star",value:x,output:P};if(B.bash===!0){if(d.output=".*?",k.type==="bos"||k.type==="slash")d.output=M+d.output;D0(d);continue}if(k&&(k.type==="bracket"||k.type==="paren")&&B.regex===!0){d.output=x,D0(d);continue}if(R.index===R.start||k.type==="slash"||k.type==="dot"){if(k.type==="dot")R.output+=H,k.output+=H;else if(B.dot===!0)R.output+=z,k.output+=z;else R.output+=M,k.output+=M;if(p()!=="*")R.output+=K,k.output+=K}D0(d)}while(R.brackets>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing","]"));R.output=jY.escapeLast(R.output,"["),A0("brackets")}while(R.parens>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing",")"));R.output=jY.escapeLast(R.output,"("),A0("parens")}while(R.braces>0){if(B.strictBrackets===!0)throw SyntaxError(Zv("closing","}"));R.output=jY.escapeLast(R.output,"{"),A0("braces")}if(B.strictSlashes!==!0&&(k.type==="star"||k.type==="bracket"))D0({type:"maybe_slash",value:"",output:`${U}?`});if(R.backtrack===!0){R.output="";for(let Z0 of R.tokens)if(R.output+=Z0.output!=null?Z0.output:Z0.value,Z0.suffix)R.output+=Z0.suffix}return R};Jb0.fastpaths=(A,Q)=>{let B={...Q},$=typeof B.maxLength==="number"?Math.min(D70,B.maxLength):D70,J=A.length;if(J>$)throw SyntaxError(`Input length: ${J}, exceeds maximum allowed length: ${$}`);A=C24[A]||A;let{DOT_LITERAL:Y,SLASH_LITERAL:Z,ONE_CHAR:F,DOTS_SLASH:X,NO_DOT:D,NO_DOTS:G,NO_DOTS_SLASH:V,STAR:U,START_ANCHOR:K}=dc.globChars(B.windows),E=B.dot?G:D,W=B.dot?V:D,H=B.capture?"":"?:",z={negated:!1,prefix:""},q=B.bash===!0?".*?":U;if(B.capture)q=`(${q})`;let N=(M)=>{if(M.noglobstar===!0)return q;return`(${H}(?:(?!${K}${M.dot?X:Y}).)*?)`},I=(M)=>{switch(M){case"*":return`${E}${F}${q}`;case".*":return`${Y}${F}${q}`;case"*.*":return`${E}${q}${Y}${F}${q}`;case"*/*":return`${E}${q}${Z}${F}${W}${q}`;case"**":return E+N(B);case"**/*":return`(?:${E}${N(B)}${Z})?${W}${F}${q}`;case"**/*.*":return`(?:${E}${N(B)}${Z})?${W}${q}${Y}${F}${q}`;case"**/.*":return`(?:${E}${N(B)}${Z})?${Y}${F}${q}`;default:{let j=/^(.*?)\.(\w+)$/.exec(M);if(!j)return;let P=I(j[1]);if(!P)return;return P+Y+j[2]}}},C=jY.removePrefix(A,z),w=I(C);if(w&&B.strictSlashes!==!0)w+=`${Z}?`;return w};L24.exports=Jb0});var Zb0=y((lm8,R24)=>{var ME6=I24(),Yb0=O24(),j24=mc(),LE6=gc(),OE6=(A)=>A&&typeof A==="object"&&!Array.isArray(A),x2=(A,Q,B=!1)=>{if(Array.isArray(A)){let G=A.map((U)=>x2(U,Q,B));return(U)=>{for(let K of G){let E=K(U);if(E)return E}return!1}}let $=OE6(A)&&A.tokens&&A.input;if(A===""||typeof A!=="string"&&!$)throw TypeError("Expected pattern to be a non-empty string");let J=Q||{},Y=J.windows,Z=$?x2.compileRe(A,Q):x2.makeRe(A,Q,!1,!0),F=Z.state;delete Z.state;let X=()=>!1;if(J.ignore){let G={...Q,ignore:null,onMatch:null,onResult:null};X=x2(J.ignore,G,B)}let D=(G,V=!1)=>{let{isMatch:U,match:K,output:E}=x2.test(G,Z,Q,{glob:A,posix:Y}),W={glob:A,state:F,regex:Z,posix:Y,input:G,output:E,match:K,isMatch:U};if(typeof J.onResult==="function")J.onResult(W);if(U===!1)return W.isMatch=!1,V?W:!1;if(X(G)){if(typeof J.onIgnore==="function")J.onIgnore(W);return W.isMatch=!1,V?W:!1}if(typeof J.onMatch==="function")J.onMatch(W);return V?W:!0};if(B)D.state=F;return D};x2.test=(A,Q,B,{glob:$,posix:J}={})=>{if(typeof A!=="string")throw TypeError("Expected input to be a string");if(A==="")return{isMatch:!1,output:""};let Y=B||{},Z=Y.format||(J?j24.toPosixSlashes:null),F=A===$,X=F&&Z?Z(A):A;if(F===!1)X=Z?Z(A):A,F=X===$;if(F===!1||Y.capture===!0)if(Y.matchBase===!0||Y.basename===!0)F=x2.matchBase(A,Q,B,J);else F=Q.exec(X);return{isMatch:Boolean(F),match:F,output:X}};x2.matchBase=(A,Q,B)=>{return(Q instanceof RegExp?Q:x2.makeRe(Q,B)).test(j24.basename(A))};x2.isMatch=(A,Q,B)=>x2(Q,B)(A);x2.parse=(A,Q)=>{if(Array.isArray(A))return A.map((B)=>x2.parse(B,Q));return Yb0(A,{...Q,fastpaths:!1})};x2.scan=(A,Q)=>ME6(A,Q);x2.compileRe=(A,Q,B=!1,$=!1)=>{if(B===!0)return A.output;let J=Q||{},Y=J.contains?"":"^",Z=J.contains?"":"$",F=`${Y}(?:${A.output})${Z}`;if(A&&A.negated===!0)F=`^(?!${F}).*$`;let X=x2.toRegex(F,Q);if($===!0)X.state=A;return X};x2.makeRe=(A,Q={},B=!1,$=!1)=>{if(!A||typeof A!=="string")throw TypeError("Expected a non-empty string");let J={negated:!1,fastpaths:!0};if(Q.fastpaths!==!1&&(A[0]==="."||A[0]==="*"))J.output=Yb0.fastpaths(A,Q);if(!J.output)J=Yb0(A,Q);return x2.compileRe(J,Q,B,$)};x2.toRegex=(A,Q)=>{try{let B=Q||{};return new RegExp(A,B.flags||(B.nocase?"i":""))}catch(B){if(Q&&Q.debug===!0)throw B;return/$^/}};x2.constants=LE6;R24.exports=x2});var YW=y((im8,T24)=>{var P24=Zb0(),jE6=mc();function _24(A,Q,B=!1){if(Q&&(Q.windows===null||Q.windows===void 0))Q={...Q,windows:jE6.isWindows()};return P24(A,Q,B)}Object.assign(_24,P24);T24.exports=_24});function Db0(A){let Q=A;if(Q.startsWith("~/")){let B=process.env.HOME||process.env.USERPROFILE||"";Q=Q.replace("~/",`${B}/`)}else if(Q==="~")Q=process.env.HOME||process.env.USERPROFILE||"";if(Q=Q.replace(/%([^%]+)%/g,(B,$)=>{return process.env[$]||`%${$}%`}),Q.includes("%USERPROFILE%")&&process.env.USERPROFILE)Q=Q.replace(/%USERPROFILE%/g,process.env.USERPROFILE);return Z1.file(Q)}function Fb0(A,Q){let B=Db0(Q);if(B.path.includes("*")){let $=A.toString(),J=B.path;if(!J.startsWith("file://")){if(!J.startsWith("/"))J=`/${J}`;J=`file://${J}`}let Y=J.replace(/\./g,"\\.").replace(/\*\*/g,"§DOUBLESTAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLESTAR§/g,".*");return new RegExp(`^${Y}$`,"i").test($)}else return B.toString().toLowerCase()===A.toString().toLowerCase()}function S24(A,Q){return Q.some((B)=>Fb0(A,B))}async function RE6(A,Q){try{return await Q.realpath(A)}catch{}let B=[],$=A;while(!0){let J=G1.dirname($);if(J.toString()===$.toString())break;B.unshift(G1.basename($)),$=J;try{let Z=await Q.realpath($);for(let F of B)Z=G1.joinPath(Z,F);return Z}catch{}}return A}async function PE6(A,Q,B){try{let $=await RE6(A,Q),Y=[...["~/.config/AGENT.md"],...B];for(let Z of Y)if(Fb0($,Z)||Fb0(A,Z))return null;for(let{key:Z,pattern:F}of Xb0)if(S24($,F.patterns)||S24(A,F.patterns))return{key:Z,pattern:F};return null}catch{return null}}async function Gb0(A,Q,B){if(B?.dangerouslyAllowAll??!1)return{requiresConsent:!1};try{let J=await PE6(A,Q,B["guardedFiles.allowlist"]??[]);if(J)return{requiresConsent:!0,reason:`${J.pattern.description}`,toAllow:A.fsPath};return{requiresConsent:!1}}catch{return{requiresConsent:!0,reason:"Unable to resolve file path",toAllow:A.fsPath}}}var Xb0;var G70=J0(()=>{z4();Xb0=[{key:"cursor-config",pattern:{description:"Cursor Configuration",patterns:["**/.cursor/**","~/.cursor/**","~/Library/Application Support/Cursor/**","~/.config/Cursor/**","%APPDATA%/Cursor/**"]}},{key:"windsurf-config",pattern:{description:"Windsurf Configuration",patterns:["**/.windsurf/**","~/.codeium/windsurf/**","~/Library/Application Support/Windsurf/**","~/.config/Windsurf/**","%APPDATA%/Windsurf/**","/Library/Application Support/Windsurf/**","/etc/windsurf/**","%ProgramData%/Windsurf/**"]}},{key:"antigravity-config",pattern:{description:"Antigravity Configuration",patterns:["~/.gemini/**"]}},{key:"jetbrains-config",pattern:{description:"JetBrains IDE Configuration",patterns:["~/Library/Application Support/JetBrains/**","~/.config/JetBrains/**","~/.local/share/JetBrains/**","%APPDATA%/JetBrains/**","%LOCALAPPDATA%/JetBrains/**"]}},{key:"jetbrains-idea-config",pattern:{description:"JetBrains IDE Project Configuration",patterns:["**/.idea/**"]}},{key:"neovim-config",pattern:{description:"Neovim Configuration",patterns:["~/.config/nvim/**","~/.local/share/nvim/**","~/.local/state/nvim/**"]}},{key:"amp-settings",pattern:{description:"Amp Configuration Files",patterns:["**/amp.json","**/.amp/**"]}},{key:"shell-configs",pattern:{description:"Shell Configuration Files",patterns:["~/.bashrc","~/.zshrc","~/.fishrc","~/.cshrc","~/.tcshrc"]}},{key:"ssh-keys",pattern:{description:"SSH Keys and Configuration",patterns:["**/.ssh/**","~/.ssh/**"]}},{key:"gnupg-keys",pattern:{description:"GnuPG Keys and Configuration",patterns:["**/.gnupg/**","~/.gnupg/**"]}},{key:"environment-files",pattern:{description:"Environment Variable Files",patterns:["**/.env","**/.env.*"]}},{key:"claude-config",pattern:{description:"Claude AI Configuration",patterns:["**/.claude/**","~/.claude/**"]}},{key:"codex-config",pattern:{description:"Codex Configuration",patterns:["**/.codex/**","~/.codex/**"]}},{key:"git-internals",pattern:{description:"Git Internal Files",patterns:["**/.git/**"]}},{key:"kubernetes-config",pattern:{description:"Kubernetes Configuration",patterns:["**/.kube/**","~/.kube/**"]}},{key:"cache-directories",pattern:{description:"Cache Directories",patterns:["**/.cache/**","~/.cache/**"]}},{key:"windows-appdata",pattern:{description:"Windows Application Data",patterns:["%APPDATA%/**"]}},{key:"windows-system-directories",pattern:{description:"Windows System Directories",patterns:["%WINDIR%/**","%SYSTEMROOT%/**","%ProgramFiles%/**","%ProgramFiles(x86)%/**","%ProgramData%/**"]}},{key:"sqlite3-files",pattern:{description:"SQLite Database Files",patterns:["**/*.db","**/*.sqlite","**/*.sqlite3"]}},{key:"common-configuration-patterns",pattern:{description:"Configuration Directories",patterns:["~/.*","~/.*/**","~/.config/**","~/Library/**","~/Library/Preferences/**"]}},{key:"macos-applications",pattern:{description:"macOS Applications",patterns:["/Applications/**","~/Applications/**"]}},{key:"macos-system-library",pattern:{description:"macOS System Library",patterns:["/Library/**"]}},{key:"unix-system-directories",pattern:{description:"Unix System Directories",patterns:["/usr/**","/bin/**","/sbin/**","/lib/**","/lib64/**","/boot/**"]}},{key:"system-config-directories",pattern:{description:"System Configuration and State",patterns:["/private/etc/**","/etc/**","/private/var/**","/var/**"]}},{key:"opt-directory",pattern:{description:"Optional Software Installs (/opt, e.g., Homebrew)",patterns:["/opt/**"]}}]});function _E6(){if(ZW.size===0)return;T.info("Killing all child processes");for(let A of ZW)Vb0(A);ZW.clear(),T.info("All child processes killed")}function Vb0(A){if(!A.pid){try{A.kill("SIGKILL")}catch(Q){T.error("Failed to kill process without PID",Q)}return}if(cc.has(A.pid)){T.debug(`Process ${A.pid} already being killed, skipping`);return}cc.add(A.pid);try{if(process.platform==="win32"){let{spawn:Q}=U0("node:child_process"),B=Q("taskkill",["/F","/T","/PID",A.pid.toString()],{stdio:"ignore"});B.on("error",($)=>{T.error(`Failed to kill Windows process tree ${A.pid}`,$);try{A.kill("SIGKILL")}catch(J){T.error(`Fallback kill also failed for ${A.pid}`,J)}}),B.on("exit",()=>{cc.delete(A.pid)})}else{try{process.kill(A.pid,0),process.kill(-A.pid,"SIGKILL")}catch(Q){T.debug(`Process ${A.pid} no longer exists, skipping kill`)}cc.delete(A.pid)}}catch(Q){T.error(`Failed to kill process ${A.pid}`,Q),cc.delete(A.pid)}}function Ub0(A){Vb0(A),ZW.delete(A)}function k24(A){ZW.add(A)}function TE6(A){let Q={...A,detached:process.platform!=="win32",env:{...process.env,...A?.env||{},NONINTERACTIVE:"1",DEBIAN_FRONTEND:"noninteractive"}};if(!Q.stdio)Q.stdio=["pipe","pipe","pipe"];return Q}function Kb0(...A){return new g0((Q)=>{let B=!1,$,J=!1;return(async()=>{try{let{spawn:Z}=await import("node:child_process");if(B)return;$=Z(A[0],A[1],TE6(A[2])),ZW.add($),$.on("spawn",()=>{Q.next({type:"spawn",pid:$?.pid,process:$})}),$.stdout?.on("data",(F)=>{if(B||J)return;Q.next({type:"data",stream:"stdout",chunk:Buffer.isBuffer(F)?F:Buffer.from(String(F)),pid:$?.pid,process:$})}),$.stderr?.on("data",(F)=>{if(B||J)return;Q.next({type:"data",stream:"stderr",chunk:Buffer.isBuffer(F)?F:Buffer.from(String(F)),pid:$?.pid,process:$})}),$.on("exit",(F)=>{if(B||J)return;Q.next({type:"exit",exitCode:F})}),$.on("close",(F)=>{if(B)return;if(J)return;if(J=!0,Q.next({type:"close",exitCode:F}),Q.complete(),$)ZW.delete($)}),$.on("error",(F)=>{if(B||J)return;if(J=!0,Q.error(F),$)ZW.delete($)})}catch(Z){if(B)return;Q.error(Z)}})(),()=>{if(B=!0,$&&!J)Vb0($),ZW.delete($)}})}function FW(...A){return new g0((Q)=>{let B={stdout:"",stderr:"",combinedOutput:"",exitCode:null,exited:!1},$=Kb0(...A).subscribe({next:(J)=>{switch(J.type){case"spawn":B.pid=J.pid,B.process=J.process,Q.next({...B,process:J.process});break;case"data":{let Y=J.chunk.toString();if(J.stream==="stdout")B.stdout+=Y;else B.stderr+=Y;B.combinedOutput+=Y,B.lastData=J.chunk,Q.next({...B,process:J.process??B.process});break}case"exit":B.exitCode=J.exitCode??-1,B.exited=!0;break;case"close":if(B.exitCode===null)B.exitCode=J.exitCode??-1;B.exited=!0,B.lastData=void 0,Q.next({...B,process:B.process}),Q.complete();break}},error:(J)=>Q.error(J)});return()=>$.unsubscribe()})}function V70(A){if(typeof A!=="string")throw Error("arg is not a string");if(A.startsWith("-"))throw Error("arg is not safe")}function U70(A){if(!A)throw Error("tool requires a working directory");if(A.scheme!=="file")throw Error(`tool requires a dir with a file: URI (got ${JSON.stringify(A.scheme)})`)}var ZW,cc;var XW=J0(()=>{O1();l0();ZW=new Set,cc=new Set;if(typeof process<"u")process.on("exit",()=>{_E6()})});function QO(A,Q){if(Q==="")return!1;let B=A.toLowerCase(),$=Q.toLowerCase();if($.length===1){if($==="*")return!0;return $===B}if(B===$)return!0;if($.includes("*")||$.includes("?")||$.includes("[")||$.includes("{"))try{return v24.default($,{dot:!0})(B)}catch(J){return!1}return!1}function Eb0(A,Q){let B=Q.split("."),$=A;for(let J of B){if($===null||$===void 0)return;if(Array.isArray($)){let Y=parseInt(J,10);if(isNaN(Y)||Y<0||Y>=$.length)return;$=$[Y]}else if(typeof $==="object")$=$[J];else return}return $}function SE6(A,Q,B,$){if(!QO(Q,A.tool))return!1;if(A.context&&A.context!==$)return!1;if(!A.matches||Object.keys(A.matches).length===0)return!0;return Object.entries(A.matches).every(([J,Y])=>{if(Y===void 0){if(J.includes("."))return Eb0(B,J)===void 0;return J in B&&B[J]===void 0}let Z=J.includes(".")?Eb0(B,J):B[J];return K70(Z,Y)})}async function kE6(A,Q,B,$,J,Y){if(A.action!=="delegate"){if(A.action==="reject"&&A.message)return{action:A.action,matchedEntry:A,error:A.message};return{action:A.action,matchedEntry:A}}if(!B||!A.to)return{action:null,matchedEntry:A,error:"No spawn function provided"};try{let Z=await vE6(A.to,Q,B,$,J,Y);return yE6(Z,A)}catch(Z){return{action:"reject",error:Z instanceof Error?Z.message:"Unknown error",matchedEntry:A}}}async function vE6(A,Q,B,$,J,Y){let Z={AGENT:"amp"};if($)Z.AMP_THREAD_ID=$;if(J)Z.AGENT_TOOL_NAME=J;if(Y)Z.AGENT_TOOL_USE_ID=Y;let X=A.includes("~")||A.includes("%")?Db0(A).path:A,G=B(X,[],{env:Z});return new Promise((V,U)=>{let K;G.subscribe({next:(E)=>{if(typeof E==="object"&&E!==null&&"status"in E&&E.status==="error"){U(Error("Delegate command timed out after 10 seconds"));return}if(E.process&&!E.exited)E.process.stdin?.write(JSON.stringify(Q)),E.process.stdin?.end();K=E},complete:()=>{if(K?.exited)V({exitCode:K.exitCode??-1,stdout:K.stdout,stderr:K.stderr});else U(Error("Process did not exit properly"))},error:(E)=>{U(E)}})})}function yE6({exitCode:A,stderr:Q},B){switch(A){case 0:return{action:"allow",matchedEntry:B};case 1:return{action:"ask",matchedEntry:B};default:return{action:"reject",matchedEntry:B,error:Q}}}async function Fv(A,Q,B,$,J,Y,Z,F){let X=0;for(let D of B)try{if(!SE6(D,A,Q,$)){X=X+1;continue}let G=await kE6(D,Q,J,Y,A,F);if(G.matchIndex=X,Z)G.source=Z;return G}catch(G){return{action:null,error:G instanceof Error?G.message:"Unknown error"}}return{action:null}}function K70(A,Q){if(typeof Q==="string"){if(typeof A!=="string")return!1;return fE6(A,Q)}if(Array.isArray(Q))return Q.some((B)=>{if(typeof B==="string")return typeof A==="string"&&Wb0(A,B);return A===B});if(typeof Q==="object"&&Q!==null)return xE6(A,Q);return A===Q}function xE6(A,Q){if(Object.keys(Q).length===0)return typeof A==="object"&&A!==null;if(typeof A!=="object"||A===null)return!1;for(let[B,$]of Object.entries(Q)){let J=Eb0(A,B);if(!K70(J,$))return!1}return!0}function fE6(A,Q){if(typeof Q==="string")return Wb0(A,Q);if(Array.isArray(Q))return Q.some((B)=>typeof B==="string"&&Wb0(A,B));return!1}function Wb0(A,Q){if(Q.length>=3&&Q.startsWith("/")&&Q.endsWith("/"))try{let J=Q.slice(1,-1);return new RegExp(J,"m").test(A)}catch(J){throw Error(`Invalid regex pattern: ${Q}`)}if(Q==="*")return!0;if(!Q.includes("*"))return A===Q;let B=Q.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${B}$`,"m").test(A)}var v24,lc;var Xv=J0(()=>{G70();XW();v24=H4(YW(),1),lc=FW});function ic(A,Q){if(A===Q)return!0;if(A==null||Q==null||typeof A!=="object"||typeof Q!=="object")return!1;let B=Array.isArray(A),$=Array.isArray(Q);if(B!==$)return!1;if(B&&$)return A.length===Q.length&&A.every((Y,Z)=>ic(Y,Q[Z]));let J=new Set([...Object.keys(A),...Object.keys(Q)]);for(let Y of J)if(!ic(A[Y],Q[Y]))return!1;return!0}function Ev(A){let Q=A.length;while(--Q>=0)A[Q]=0}function zb0(A,Q,B,$,J){this.static_tree=A,this.extra_bits=Q,this.extra_base=B,this.elems=$,this.max_length=J,this.has_stree=A&&A.length}function qb0(A,Q){this.dyn_tree=A,this.max_code=0,this.stat_desc=Q}function eV(A,Q,B,$,J){this.good_length=A,this.max_lazy=Q,this.nice_length=B,this.max_chain=$,this.func=J}function uW6(){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=M70,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(_W6*2),this.dyn_dtree=new Uint16Array((2*RW6+1)*2),this.bl_tree=new Uint16Array((2*PW6+1)*2),aq(this.dyn_ltree),aq(this.dyn_dtree),aq(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(TW6+1),this.heap=new Uint16Array(2*vb0+1),aq(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*vb0+1),aq(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 ZH6(){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 Dl(A){this.options=L70.assign({level:UH6,method:EH6,chunkSize:16384,windowBits:15,memLevel:8,strategy:KH6},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 h94,this.strm.avail_out=0;let B=sc.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(B!==C70)throw Error(YO[B]);if(Q.header)sc.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let $;if(typeof Q.dictionary==="string")$=Yl.string2buf(Q.dictionary);else if(g94.call(Q.dictionary)==="[object ArrayBuffer]")$=new Uint8Array(Q.dictionary);else $=Q.dictionary;if(B=sc.deflateSetDictionary(this.strm,$),B!==C70)throw Error(YO[B]);this._dict_set=!0}}function cb0(A,Q){let B=new Dl(Q);if(B.push(A,!0),B.err)throw B.msg||YO[B.err];return B.result}function WH6(A,Q){return Q=Q||{},Q.raw=!0,cb0(A,Q)}function HH6(A,Q){return Q=Q||{},Q.gzip=!0,cb0(A,Q)}function hH6(){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 Bz6(){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 Gl(A){this.options=L70.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 h94,this.strm.avail_out=0;let B=VW.inflateInit2(this.strm,Q.windowBits);if(B!==Zl)throw Error(YO[B]);if(this.header=new $z6,VW.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=Yl.string2buf(Q.dictionary);else if(t94.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(B=VW.inflateSetDictionary(this.strm,Q.dictionary),B!==Zl)throw Error(YO[B])}}}function lb0(A,Q){let B=new Gl(Q);if(B.push(A),B.err)throw B.msg||YO[B.err];return B.result}function Xz6(A,Q){return Q=Q||{},Q.raw=!0,lb0(A,Q)}var bE6=0,q94=1,uE6=2,hE6=3,gE6=258,hb0=29,Fl=256,ec,Vv=30,gb0=19,N94,BO=15,Hb0=16,mE6=7,mb0=256,I94=16,C94=17,w94=18,Tb0,N70,pE6,M94,dE6=512,GW,rc,Al,Ql,pb0,I70,L94,O94,j94,R94=(A)=>{return A<256?Al[A]:Al[256+(A>>>7)]},Bl=(A,Q)=>{A.pending_buf[A.pending++]=Q&255,A.pending_buf[A.pending++]=Q>>>8&255},JJ=(A,Q,B)=>{if(A.bi_valid>Hb0-B)A.bi_buf|=Q<<A.bi_valid&65535,Bl(A,A.bi_buf),A.bi_buf=Q>>Hb0-A.bi_valid,A.bi_valid+=B-Hb0;else A.bi_buf|=Q<<A.bi_valid&65535,A.bi_valid+=B},AU=(A,Q,B)=>{JJ(A,B[Q*2],B[Q*2+1])},P94=(A,Q)=>{let B=0;do B|=A&1,A>>>=1,B<<=1;while(--Q>0);return B>>>1},cE6=(A)=>{if(A.bi_valid===16)Bl(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},lE6=(A,Q)=>{let{dyn_tree:B,max_code:$}=Q,J=Q.stat_desc.static_tree,Y=Q.stat_desc.has_stree,Z=Q.stat_desc.extra_bits,F=Q.stat_desc.extra_base,X=Q.stat_desc.max_length,D,G,V,U,K,E,W=0;for(U=0;U<=BO;U++)A.bl_count[U]=0;B[A.heap[A.heap_max]*2+1]=0;for(D=A.heap_max+1;D<N94;D++){if(G=A.heap[D],U=B[B[G*2+1]*2+1]+1,U>X)U=X,W++;if(B[G*2+1]=U,G>$)continue;if(A.bl_count[U]++,K=0,G>=F)K=Z[G-F];if(E=B[G*2],A.opt_len+=E*(U+K),Y)A.static_len+=E*(J[G*2+1]+K)}if(W===0)return;do{U=X-1;while(A.bl_count[U]===0)U--;A.bl_count[U]--,A.bl_count[U+1]+=2,A.bl_count[X]--,W-=2}while(W>0);for(U=X;U!==0;U--){G=A.bl_count[U];while(G!==0){if(V=A.heap[--D],V>$)continue;if(B[V*2+1]!==U)A.opt_len+=(U-B[V*2+1])*B[V*2],B[V*2+1]=U;G--}}},_94=(A,Q,B)=>{let $=Array(BO+1),J=0,Y,Z;for(Y=1;Y<=BO;Y++)J=J+B[Y-1]<<1,$[Y]=J;for(Z=0;Z<=Q;Z++){let F=A[Z*2+1];if(F===0)continue;A[Z*2]=P94($[F]++,F)}},iE6=()=>{let A,Q,B,$,J,Y=Array(BO+1);B=0;for($=0;$<hb0-1;$++){pb0[$]=B;for(A=0;A<1<<Tb0[$];A++)Ql[B++]=$}Ql[B-1]=$,J=0;for($=0;$<16;$++){I70[$]=J;for(A=0;A<1<<N70[$];A++)Al[J++]=$}J>>=7;for(;$<Vv;$++){I70[$]=J<<7;for(A=0;A<1<<N70[$]-7;A++)Al[256+J++]=$}for(Q=0;Q<=BO;Q++)Y[Q]=0;A=0;while(A<=143)GW[A*2+1]=8,A++,Y[8]++;while(A<=255)GW[A*2+1]=9,A++,Y[9]++;while(A<=279)GW[A*2+1]=7,A++,Y[7]++;while(A<=287)GW[A*2+1]=8,A++,Y[8]++;_94(GW,ec+1,Y);for(A=0;A<Vv;A++)rc[A*2+1]=5,rc[A*2]=P94(A,5);L94=new zb0(GW,Tb0,Fl+1,ec,BO),O94=new zb0(rc,N70,0,Vv,BO),j94=new zb0([],pE6,0,gb0,mE6)},T94=(A)=>{let Q;for(Q=0;Q<ec;Q++)A.dyn_ltree[Q*2]=0;for(Q=0;Q<Vv;Q++)A.dyn_dtree[Q*2]=0;for(Q=0;Q<gb0;Q++)A.bl_tree[Q*2]=0;A.dyn_ltree[mb0*2]=1,A.opt_len=A.static_len=0,A.sym_next=A.matches=0},S94=(A)=>{if(A.bi_valid>8)Bl(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},y24=(A,Q,B,$)=>{let J=Q*2,Y=B*2;return A[J]<A[Y]||A[J]===A[Y]&&$[Q]<=$[B]},Nb0=(A,Q,B)=>{let $=A.heap[B],J=B<<1;while(J<=A.heap_len){if(J<A.heap_len&&y24(Q,A.heap[J+1],A.heap[J],A.depth))J++;if(y24(Q,$,A.heap[J],A.depth))break;A.heap[B]=A.heap[J],B=J,J<<=1}A.heap[B]=$},x24=(A,Q,B)=>{let $,J,Y=0,Z,F;if(A.sym_next!==0)do if($=A.pending_buf[A.sym_buf+Y++]&255,$+=(A.pending_buf[A.sym_buf+Y++]&255)<<8,J=A.pending_buf[A.sym_buf+Y++],$===0)AU(A,J,Q);else{if(Z=Ql[J],AU(A,Z+Fl+1,Q),F=Tb0[Z],F!==0)J-=pb0[Z],JJ(A,J,F);if($--,Z=R94($),AU(A,Z,B),F=N70[Z],F!==0)$-=I70[Z],JJ(A,$,F)}while(Y<A.sym_next);AU(A,mb0,Q)},Sb0=(A,Q)=>{let B=Q.dyn_tree,$=Q.stat_desc.static_tree,J=Q.stat_desc.has_stree,Y=Q.stat_desc.elems,Z,F,X=-1,D;A.heap_len=0,A.heap_max=N94;for(Z=0;Z<Y;Z++)if(B[Z*2]!==0)A.heap[++A.heap_len]=X=Z,A.depth[Z]=0;else B[Z*2+1]=0;while(A.heap_len<2)if(D=A.heap[++A.heap_len]=X<2?++X:0,B[D*2]=1,A.depth[D]=0,A.opt_len--,J)A.static_len-=$[D*2+1];Q.max_code=X;for(Z=A.heap_len>>1;Z>=1;Z--)Nb0(A,B,Z);D=Y;do Z=A.heap[1],A.heap[1]=A.heap[A.heap_len--],Nb0(A,B,1),F=A.heap[1],A.heap[--A.heap_max]=Z,A.heap[--A.heap_max]=F,B[D*2]=B[Z*2]+B[F*2],A.depth[D]=(A.depth[Z]>=A.depth[F]?A.depth[Z]:A.depth[F])+1,B[Z*2+1]=B[F*2+1]=D,A.heap[1]=D++,Nb0(A,B,1);while(A.heap_len>=2);A.heap[--A.heap_max]=A.heap[1],lE6(A,Q),_94(B,X,A.bl_count)},f24=(A,Q,B)=>{let $,J=-1,Y,Z=Q[1],F=0,X=7,D=4;if(Z===0)X=138,D=3;Q[(B+1)*2+1]=65535;for($=0;$<=B;$++){if(Y=Z,Z=Q[($+1)*2+1],++F<X&&Y===Z)continue;else if(F<D)A.bl_tree[Y*2]+=F;else if(Y!==0){if(Y!==J)A.bl_tree[Y*2]++;A.bl_tree[I94*2]++}else if(F<=10)A.bl_tree[C94*2]++;else A.bl_tree[w94*2]++;if(F=0,J=Y,Z===0)X=138,D=3;else if(Y===Z)X=6,D=3;else X=7,D=4}},b24=(A,Q,B)=>{let $,J=-1,Y,Z=Q[1],F=0,X=7,D=4;if(Z===0)X=138,D=3;for($=0;$<=B;$++){if(Y=Z,Z=Q[($+1)*2+1],++F<X&&Y===Z)continue;else if(F<D)do AU(A,Y,A.bl_tree);while(--F!==0);else if(Y!==0){if(Y!==J)AU(A,Y,A.bl_tree),F--;AU(A,I94,A.bl_tree),JJ(A,F-3,2)}else if(F<=10)AU(A,C94,A.bl_tree),JJ(A,F-3,3);else AU(A,w94,A.bl_tree),JJ(A,F-11,7);if(F=0,J=Y,Z===0)X=138,D=3;else if(Y===Z)X=6,D=3;else X=7,D=4}},nE6=(A)=>{let Q;f24(A,A.dyn_ltree,A.l_desc.max_code),f24(A,A.dyn_dtree,A.d_desc.max_code),Sb0(A,A.bl_desc);for(Q=gb0-1;Q>=3;Q--)if(A.bl_tree[M94[Q]*2+1]!==0)break;return A.opt_len+=3*(Q+1)+5+5+4,Q},aE6=(A,Q,B,$)=>{let J;JJ(A,Q-257,5),JJ(A,B-1,5),JJ(A,$-4,4);for(J=0;J<$;J++)JJ(A,A.bl_tree[M94[J]*2+1],3);b24(A,A.dyn_ltree,Q-1),b24(A,A.dyn_dtree,B-1)},oE6=(A)=>{let Q=4093624447,B;for(B=0;B<=31;B++,Q>>>=1)if(Q&1&&A.dyn_ltree[B*2]!==0)return 0;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return 1;for(B=32;B<Fl;B++)if(A.dyn_ltree[B*2]!==0)return 1;return 0},u24=!1,rE6=(A)=>{if(!u24)iE6(),u24=!0;A.l_desc=new qb0(A.dyn_ltree,L94),A.d_desc=new qb0(A.dyn_dtree,O94),A.bl_desc=new qb0(A.bl_tree,j94),A.bi_buf=0,A.bi_valid=0,T94(A)},k94=(A,Q,B,$)=>{if(JJ(A,(bE6<<1)+($?1:0),3),S94(A),Bl(A,B),Bl(A,~B),B)A.pending_buf.set(A.window.subarray(Q,Q+B),A.pending);A.pending+=B},sE6=(A)=>{JJ(A,q94<<1,3),AU(A,mb0,GW),cE6(A)},tE6=(A,Q,B,$)=>{let J,Y,Z=0;if(A.level>0){if(A.strm.data_type===2)A.strm.data_type=oE6(A);if(Sb0(A,A.l_desc),Sb0(A,A.d_desc),Z=nE6(A),J=A.opt_len+3+7>>>3,Y=A.static_len+3+7>>>3,Y<=J)J=Y}else J=Y=B+5;if(B+4<=J&&Q!==-1)k94(A,Q,B,$);else if(A.strategy===4||Y===J)JJ(A,(q94<<1)+($?1:0),3),x24(A,GW,rc);else JJ(A,(uE6<<1)+($?1:0),3),aE6(A,A.l_desc.max_code+1,A.d_desc.max_code+1,Z+1),x24(A,A.dyn_ltree,A.dyn_dtree);if(T94(A),$)S94(A)},eE6=(A,Q,B)=>{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++]=B,Q===0)A.dyn_ltree[B*2]++;else A.matches++,Q--,A.dyn_ltree[(Ql[B]+Fl+1)*2]++,A.dyn_dtree[R94(Q)*2]++;return A.sym_next===A.sym_end},AW6,QW6,BW6,$W6,JW6,YW6,ZW6=(A,Q,B,$)=>{let J=A&65535|0,Y=A>>>16&65535|0,Z=0;while(B!==0){Z=B>2000?2000:B,B-=Z;do J=J+Q[$++]|0,Y=Y+J|0;while(--Z);J%=65521,Y%=65521}return J|Y<<16|0},$l,FW6=()=>{let A,Q=[];for(var B=0;B<256;B++){A=B;for(var $=0;$<8;$++)A=A&1?3988292384^A>>>1:A>>>1;Q[B]=A}return Q},XW6,DW6=(A,Q,B,$)=>{let J=XW6,Y=$+B;A^=-1;for(let Z=$;Z<Y;Z++)A=A>>>8^J[(A^Q[Z])&255];return A^-1},z7,YO,XO,GW6,kb0,VW6,rq,UW6,sq,KW6,EW6,qF,h24,UQ,g24,QU,WW6,Ib0,HW6,zW6,E70,qW6,NW6,IW6,CW6,M70,wW6=9,MW6=15,LW6=8,OW6=29,jW6=256,vb0,RW6=30,PW6=19,_W6,TW6=15,F5=3,oq=258,BU,SW6=32,Uv=42,db0=57,yb0=69,xb0=73,fb0=91,bb0=103,$O=113,ac=666,iB=1,Wv=2,ZO=3,Hv=4,kW6=3,JO=(A,Q)=>{return A.msg=YO[Q],Q},m24=(A)=>{return A*2-(A>4?9:0)},aq=(A)=>{let Q=A.length;while(--Q>=0)A[Q]=0},vW6=(A)=>{let Q,B,$,J=A.w_size;Q=A.hash_size,$=Q;do B=A.head[--$],A.head[$]=B>=J?B-J:0;while(--Q);Q=J,$=Q;do B=A.prev[--$],A.prev[$]=B>=J?B-J:0;while(--Q)},yW6=(A,Q,B)=>(Q<<A.hash_shift^B)&A.hash_mask,tq,RY=(A)=>{let Q=A.state,B=Q.pending;if(B>A.avail_out)B=A.avail_out;if(B===0)return;if(A.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+B),A.next_out),A.next_out+=B,Q.pending_out+=B,A.total_out+=B,A.avail_out-=B,Q.pending-=B,Q.pending===0)Q.pending_out=0},PY=(A,Q)=>{VW6(A,A.block_start>=0?A.block_start:-1,A.strstart-A.block_start,Q),A.block_start=A.strstart,RY(A.strm)},l5=(A,Q)=>{A.pending_buf[A.pending++]=Q},nc=(A,Q)=>{A.pending_buf[A.pending++]=Q>>>8&255,A.pending_buf[A.pending++]=Q&255},ub0=(A,Q,B,$)=>{let J=A.avail_in;if(J>$)J=$;if(J===0)return 0;if(A.avail_in-=J,Q.set(A.input.subarray(A.next_in,A.next_in+J),B),A.state.wrap===1)A.adler=$l(A.adler,Q,J,B);else if(A.state.wrap===2)A.adler=z7(A.adler,Q,J,B);return A.next_in+=J,A.total_in+=J,J},v94=(A,Q)=>{let{max_chain_length:B,strstart:$}=A,J,Y,Z=A.prev_length,F=A.nice_match,X=A.strstart>A.w_size-BU?A.strstart-(A.w_size-BU):0,D=A.window,G=A.w_mask,V=A.prev,U=A.strstart+oq,K=D[$+Z-1],E=D[$+Z];if(A.prev_length>=A.good_match)B>>=2;if(F>A.lookahead)F=A.lookahead;do{if(J=Q,D[J+Z]!==E||D[J+Z-1]!==K||D[J]!==D[$]||D[++J]!==D[$+1])continue;$+=2,J++;do;while(D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&D[++$]===D[++J]&&$<U);if(Y=oq-(U-$),$=U-oq,Y>Z){if(A.match_start=Q,Z=Y,Y>=F)break;K=D[$+Z-1],E=D[$+Z]}}while((Q=V[Q&G])>X&&--B!==0);if(Z<=A.lookahead)return Z;return A.lookahead},Kv=(A)=>{let Q=A.w_size,B,$,J;do{if($=A.window_size-A.lookahead-A.strstart,A.strstart>=Q+(Q-BU)){if(A.window.set(A.window.subarray(Q,Q+Q-$),0),A.match_start-=Q,A.strstart-=Q,A.block_start-=Q,A.insert>A.strstart)A.insert=A.strstart;vW6(A),$+=Q}if(A.strm.avail_in===0)break;if(B=ub0(A.strm,A.window,A.strstart+A.lookahead,$),A.lookahead+=B,A.lookahead+A.insert>=F5){J=A.strstart-A.insert,A.ins_h=A.window[J],A.ins_h=tq(A,A.ins_h,A.window[J+1]);while(A.insert)if(A.ins_h=tq(A,A.ins_h,A.window[J+F5-1]),A.prev[J&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=J,J++,A.insert--,A.lookahead+A.insert<F5)break}}while(A.lookahead<BU&&A.strm.avail_in!==0)},y94=(A,Q)=>{let B=A.pending_buf_size-5>A.w_size?A.w_size:A.pending_buf_size-5,$,J,Y,Z=0,F=A.strm.avail_in;do{if($=65535,Y=A.bi_valid+42>>3,A.strm.avail_out<Y)break;if(Y=A.strm.avail_out-Y,J=A.strstart-A.block_start,$>J+A.strm.avail_in)$=J+A.strm.avail_in;if($>Y)$=Y;if($<B&&($===0&&Q!==qF||Q===sq||$!==J+A.strm.avail_in))break;if(Z=Q===qF&&$===J+A.strm.avail_in?1:0,kb0(A,0,0,Z),A.pending_buf[A.pending-4]=$,A.pending_buf[A.pending-3]=$>>8,A.pending_buf[A.pending-2]=~$,A.pending_buf[A.pending-1]=~$>>8,RY(A.strm),J){if(J>$)J=$;A.strm.output.set(A.window.subarray(A.block_start,A.block_start+J),A.strm.next_out),A.strm.next_out+=J,A.strm.avail_out-=J,A.strm.total_out+=J,A.block_start+=J,$-=J}if($)ub0(A.strm,A.strm.output,A.strm.next_out,$),A.strm.next_out+=$,A.strm.avail_out-=$,A.strm.total_out+=$}while(Z===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(Z)return Hv;if(Q!==sq&&Q!==qF&&A.strm.avail_in===0&&A.strstart===A.block_start)return Wv;if(Y=A.window_size-A.strstart,A.strm.avail_in>Y&&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(Y+=A.w_size,A.insert>A.strstart)A.insert=A.strstart}if(Y>A.strm.avail_in)Y=A.strm.avail_in;if(Y)ub0(A.strm,A.window,A.strstart,Y),A.strstart+=Y,A.insert+=Y>A.w_size-A.insert?A.w_size-A.insert:Y;if(A.high_water<A.strstart)A.high_water=A.strstart;if(Y=A.bi_valid+42>>3,Y=A.pending_buf_size-Y>65535?65535:A.pending_buf_size-Y,B=Y>A.w_size?A.w_size:Y,J=A.strstart-A.block_start,J>=B||(J||Q===qF)&&Q!==sq&&A.strm.avail_in===0&&J<=Y)$=J>Y?Y:J,Z=Q===qF&&A.strm.avail_in===0&&$===J?1:0,kb0(A,A.block_start,$,Z),A.block_start+=$,RY(A.strm);return Z?ZO:iB},Cb0=(A,Q)=>{let B,$;for(;;){if(A.lookahead<BU){if(Kv(A),A.lookahead<BU&&Q===sq)return iB;if(A.lookahead===0)break}if(B=0,A.lookahead>=F5)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart;if(B!==0&&A.strstart-B<=A.w_size-BU)A.match_length=v94(A,B);if(A.match_length>=F5)if($=rq(A,A.strstart-A.match_start,A.match_length-F5),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=F5){A.match_length--;do A.strstart++,A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=tq(A,A.ins_h,A.window[A.strstart+1]);else $=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if($){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=A.strstart<F5-1?A.strstart:F5-1,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},Dv=(A,Q)=>{let B,$,J;for(;;){if(A.lookahead<BU){if(Kv(A),A.lookahead<BU&&Q===sq)return iB;if(A.lookahead===0)break}if(B=0,A.lookahead>=F5)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=F5-1,B!==0&&A.prev_length<A.max_lazy_match&&A.strstart-B<=A.w_size-BU){if(A.match_length=v94(A,B),A.match_length<=5&&(A.strategy===zW6||A.match_length===F5&&A.strstart-A.match_start>4096))A.match_length=F5-1}if(A.prev_length>=F5&&A.match_length<=A.prev_length){J=A.strstart+A.lookahead-F5,$=rq(A,A.strstart-1-A.prev_match,A.prev_length-F5),A.lookahead-=A.prev_length-1,A.prev_length-=2;do if(++A.strstart<=J)A.ins_h=tq(A,A.ins_h,A.window[A.strstart+F5-1]),B=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=F5-1,A.strstart++,$){if(PY(A,!1),A.strm.avail_out===0)return iB}}else if(A.match_available){if($=rq(A,0,A.window[A.strstart-1]),$)PY(A,!1);if(A.strstart++,A.lookahead--,A.strm.avail_out===0)return iB}else A.match_available=1,A.strstart++,A.lookahead--}if(A.match_available)$=rq(A,0,A.window[A.strstart-1]),A.match_available=0;if(A.insert=A.strstart<F5-1?A.strstart:F5-1,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},xW6=(A,Q)=>{let B,$,J,Y,Z=A.window;for(;;){if(A.lookahead<=oq){if(Kv(A),A.lookahead<=oq&&Q===sq)return iB;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=F5&&A.strstart>0){if(J=A.strstart-1,$=Z[J],$===Z[++J]&&$===Z[++J]&&$===Z[++J]){Y=A.strstart+oq;do;while($===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&$===Z[++J]&&J<Y);if(A.match_length=oq-(Y-J),A.match_length>A.lookahead)A.match_length=A.lookahead}}if(A.match_length>=F5)B=rq(A,1,A.match_length-F5),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0;else B=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if(B){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=0,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},fW6=(A,Q)=>{let B;for(;;){if(A.lookahead===0){if(Kv(A),A.lookahead===0){if(Q===sq)return iB;break}}if(A.match_length=0,B=rq(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,B){if(PY(A,!1),A.strm.avail_out===0)return iB}}if(A.insert=0,Q===qF){if(PY(A,!0),A.strm.avail_out===0)return ZO;return Hv}if(A.sym_next){if(PY(A,!1),A.strm.avail_out===0)return iB}return Wv},oc,bW6=(A)=>{A.window_size=2*A.w_size,aq(A.head),A.max_lazy_match=oc[A.level].max_lazy,A.good_match=oc[A.level].good_length,A.nice_match=oc[A.level].nice_length,A.max_chain_length=oc[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=F5-1,A.match_available=0,A.ins_h=0},Xl=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.status!==Uv&&Q.status!==db0&&Q.status!==yb0&&Q.status!==xb0&&Q.status!==fb0&&Q.status!==bb0&&Q.status!==$O&&Q.status!==ac)return 1;return 0},x94=(A)=>{if(Xl(A))return JO(A,QU);A.total_in=A.total_out=0,A.data_type=CW6;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?db0:Q.wrap?Uv:$O,A.adler=Q.wrap===2?0:1,Q.last_flush=-2,GW6(Q),UQ},f94=(A)=>{let Q=x94(A);if(Q===UQ)bW6(A.state);return Q},hW6=(A,Q)=>{if(Xl(A)||A.state.wrap!==2)return QU;return A.state.gzhead=Q,UQ},b94=(A,Q,B,$,J,Y)=>{if(!A)return QU;let Z=1;if(Q===HW6)Q=6;if($<0)Z=0,$=-$;else if($>15)Z=2,$-=16;if(J<1||J>wW6||B!==M70||$<8||$>15||Q<0||Q>9||Y<0||Y>NW6||$===8&&Z!==1)return JO(A,QU);if($===8)$=9;let F=new uW6;return A.state=F,F.strm=A,F.status=Uv,F.wrap=Z,F.gzhead=null,F.w_bits=$,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=J+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+F5-1)/F5),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<<J+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=Y,F.method=B,f94(A)},gW6=(A,Q)=>{return b94(A,Q,M70,MW6,LW6,IW6)},mW6=(A,Q)=>{if(Xl(A)||Q>h24||Q<0)return A?JO(A,QU):QU;let B=A.state;if(!A.output||A.avail_in!==0&&!A.input||B.status===ac&&Q!==qF)return JO(A,A.avail_out===0?Ib0:QU);let $=B.last_flush;if(B.last_flush=Q,B.pending!==0){if(RY(A),A.avail_out===0)return B.last_flush=-1,UQ}else if(A.avail_in===0&&m24(Q)<=m24($)&&Q!==qF)return JO(A,Ib0);if(B.status===ac&&A.avail_in!==0)return JO(A,Ib0);if(B.status===Uv&&B.wrap===0)B.status=$O;if(B.status===Uv){let J=M70+(B.w_bits-8<<4)<<8,Y=-1;if(B.strategy>=E70||B.level<2)Y=0;else if(B.level<6)Y=1;else if(B.level===6)Y=2;else Y=3;if(J|=Y<<6,B.strstart!==0)J|=SW6;if(J+=31-J%31,nc(B,J),B.strstart!==0)nc(B,A.adler>>>16),nc(B,A.adler&65535);if(A.adler=1,B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}if(B.status===db0)if(A.adler=0,l5(B,31),l5(B,139),l5(B,8),!B.gzhead){if(l5(B,0),l5(B,0),l5(B,0),l5(B,0),l5(B,0),l5(B,B.level===9?2:B.strategy>=E70||B.level<2?4:0),l5(B,kW6),B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}else{if(l5(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(!B.gzhead.extra?0:4)+(!B.gzhead.name?0:8)+(!B.gzhead.comment?0:16)),l5(B,B.gzhead.time&255),l5(B,B.gzhead.time>>8&255),l5(B,B.gzhead.time>>16&255),l5(B,B.gzhead.time>>24&255),l5(B,B.level===9?2:B.strategy>=E70||B.level<2?4:0),l5(B,B.gzhead.os&255),B.gzhead.extra&&B.gzhead.extra.length)l5(B,B.gzhead.extra.length&255),l5(B,B.gzhead.extra.length>>8&255);if(B.gzhead.hcrc)A.adler=z7(A.adler,B.pending_buf,B.pending,0);B.gzindex=0,B.status=yb0}if(B.status===yb0){if(B.gzhead.extra){let J=B.pending,Y=(B.gzhead.extra.length&65535)-B.gzindex;while(B.pending+Y>B.pending_buf_size){let F=B.pending_buf_size-B.pending;if(B.pending_buf.set(B.gzhead.extra.subarray(B.gzindex,B.gzindex+F),B.pending),B.pending=B.pending_buf_size,B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(B.gzindex+=F,RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0,Y-=F}let Z=new Uint8Array(B.gzhead.extra);if(B.pending_buf.set(Z.subarray(B.gzindex,B.gzindex+Y),B.pending),B.pending+=Y,B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);B.gzindex=0}B.status=xb0}if(B.status===xb0){if(B.gzhead.name){let J=B.pending,Y;do{if(B.pending===B.pending_buf_size){if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0}if(B.gzindex<B.gzhead.name.length)Y=B.gzhead.name.charCodeAt(B.gzindex++)&255;else Y=0;l5(B,Y)}while(Y!==0);if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);B.gzindex=0}B.status=fb0}if(B.status===fb0){if(B.gzhead.comment){let J=B.pending,Y;do{if(B.pending===B.pending_buf_size){if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J);if(RY(A),B.pending!==0)return B.last_flush=-1,UQ;J=0}if(B.gzindex<B.gzhead.comment.length)Y=B.gzhead.comment.charCodeAt(B.gzindex++)&255;else Y=0;l5(B,Y)}while(Y!==0);if(B.gzhead.hcrc&&B.pending>J)A.adler=z7(A.adler,B.pending_buf,B.pending-J,J)}B.status=bb0}if(B.status===bb0){if(B.gzhead.hcrc){if(B.pending+2>B.pending_buf_size){if(RY(A),B.pending!==0)return B.last_flush=-1,UQ}l5(B,A.adler&255),l5(B,A.adler>>8&255),A.adler=0}if(B.status=$O,RY(A),B.pending!==0)return B.last_flush=-1,UQ}if(A.avail_in!==0||B.lookahead!==0||Q!==sq&&B.status!==ac){let J=B.level===0?y94(B,Q):B.strategy===E70?fW6(B,Q):B.strategy===qW6?xW6(B,Q):oc[B.level].func(B,Q);if(J===ZO||J===Hv)B.status=ac;if(J===iB||J===ZO){if(A.avail_out===0)B.last_flush=-1;return UQ}if(J===Wv){if(Q===KW6)UW6(B);else if(Q!==h24){if(kb0(B,0,0,!1),Q===EW6){if(aq(B.head),B.lookahead===0)B.strstart=0,B.block_start=0,B.insert=0}}if(RY(A),A.avail_out===0)return B.last_flush=-1,UQ}}if(Q!==qF)return UQ;if(B.wrap<=0)return g24;if(B.wrap===2)l5(B,A.adler&255),l5(B,A.adler>>8&255),l5(B,A.adler>>16&255),l5(B,A.adler>>24&255),l5(B,A.total_in&255),l5(B,A.total_in>>8&255),l5(B,A.total_in>>16&255),l5(B,A.total_in>>24&255);else nc(B,A.adler>>>16),nc(B,A.adler&65535);if(RY(A),B.wrap>0)B.wrap=-B.wrap;return B.pending!==0?UQ:g24},pW6=(A)=>{if(Xl(A))return QU;let Q=A.state.status;return A.state=null,Q===$O?JO(A,WW6):UQ},dW6=(A,Q)=>{let B=Q.length;if(Xl(A))return QU;let $=A.state,J=$.wrap;if(J===2||J===1&&$.status!==Uv||$.lookahead)return QU;if(J===1)A.adler=$l(A.adler,Q,B,0);if($.wrap=0,B>=$.w_size){if(J===0)aq($.head),$.strstart=0,$.block_start=0,$.insert=0;let X=new Uint8Array($.w_size);X.set(Q.subarray(B-$.w_size,B),0),Q=X,B=$.w_size}let{avail_in:Y,next_in:Z,input:F}=A;A.avail_in=B,A.next_in=0,A.input=Q,Kv($);while($.lookahead>=F5){let X=$.strstart,D=$.lookahead-(F5-1);do $.ins_h=tq($,$.ins_h,$.window[X+F5-1]),$.prev[X&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=X,X++;while(--D);$.strstart=X,$.lookahead=F5-1,Kv($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=F5-1,$.match_available=0,A.next_in=Z,A.input=F,A.avail_in=Y,$.wrap=J,UQ},cW6,lW6,iW6,nW6,aW6,oW6,rW6,sW6,tW6="pako deflate (from Nodeca project)",sc,eW6=(A,Q)=>{return Object.prototype.hasOwnProperty.call(A,Q)},AH6=function(A){let Q=Array.prototype.slice.call(arguments,1);while(Q.length){let B=Q.shift();if(!B)continue;if(typeof B!=="object")throw TypeError(B+"must be non-object");for(let $ in B)if(eW6(B,$))A[$]=B[$]}return A},QH6=(A)=>{let Q=0;for(let $=0,J=A.length;$<J;$++)Q+=A[$].length;let B=new Uint8Array(Q);for(let $=0,J=0,Y=A.length;$<Y;$++){let Z=A[$];B.set(Z,J),J+=Z.length}return B},L70,u94=!0,Jl,BH6=(A)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(A);let Q,B,$,J,Y,Z=A.length,F=0;for(J=0;J<Z;J++){if(B=A.charCodeAt(J),(B&64512)===55296&&J+1<Z){if($=A.charCodeAt(J+1),($&64512)===56320)B=65536+(B-55296<<10)+($-56320),J++}F+=B<128?1:B<2048?2:B<65536?3:4}Q=new Uint8Array(F);for(Y=0,J=0;Y<F;J++){if(B=A.charCodeAt(J),(B&64512)===55296&&J+1<Z){if($=A.charCodeAt(J+1),($&64512)===56320)B=65536+(B-55296<<10)+($-56320),J++}if(B<128)Q[Y++]=B;else if(B<2048)Q[Y++]=192|B>>>6,Q[Y++]=128|B&63;else if(B<65536)Q[Y++]=224|B>>>12,Q[Y++]=128|B>>>6&63,Q[Y++]=128|B&63;else Q[Y++]=240|B>>>18,Q[Y++]=128|B>>>12&63,Q[Y++]=128|B>>>6&63,Q[Y++]=128|B&63}return Q},$H6=(A,Q)=>{if(Q<65534){if(A.subarray&&u94)return String.fromCharCode.apply(null,A.length===Q?A:A.subarray(0,Q))}let B="";for(let $=0;$<Q;$++)B+=String.fromCharCode(A[$]);return B},JH6=(A,Q)=>{let B=Q||A.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(A.subarray(0,Q));let $,J,Y=Array(B*2);for(J=0,$=0;$<B;){let Z=A[$++];if(Z<128){Y[J++]=Z;continue}let F=Jl[Z];if(F>4){Y[J++]=65533,$+=F-1;continue}Z&=F===2?31:F===3?15:7;while(F>1&&$<B)Z=Z<<6|A[$++]&63,F--;if(F>1){Y[J++]=65533;continue}if(Z<65536)Y[J++]=Z;else Z-=65536,Y[J++]=55296|Z>>10&1023,Y[J++]=56320|Z&1023}return $H6(Y,J)},YH6=(A,Q)=>{if(Q=Q||A.length,Q>A.length)Q=A.length;let B=Q-1;while(B>=0&&(A[B]&192)===128)B--;if(B<0)return Q;if(B===0)return Q;return B+Jl[A[B]]>Q?B:Q},Yl,h94,g94,FH6,XH6,DH6,GH6,C70,VH6,UH6,KH6,EH6,zH6,qH6,NH6,IH6,CH6,wH6,W70=16209,MH6=16191,LH6=function(Q,B){let $,J,Y,Z,F,X,D,G,V,U,K,E,W,H,z,q,N,I,C,w,M,j,P,R,b=Q.state;$=Q.next_in,P=Q.input,J=$+(Q.avail_in-5),Y=Q.next_out,R=Q.output,Z=Y-(B-Q.avail_out),F=Y+(Q.avail_out-257),X=b.dmax,D=b.wsize,G=b.whave,V=b.wnext,U=b.window,K=b.hold,E=b.bits,W=b.lencode,H=b.distcode,z=(1<<b.lenbits)-1,q=(1<<b.distbits)-1;A:do{if(E<15)K+=P[$++]<<E,E+=8,K+=P[$++]<<E,E+=8;N=W[K&z];Q:for(;;){if(I=N>>>24,K>>>=I,E-=I,I=N>>>16&255,I===0)R[Y++]=N&65535;else if(I&16){if(C=N&65535,I&=15,I){if(E<I)K+=P[$++]<<E,E+=8;C+=K&(1<<I)-1,K>>>=I,E-=I}if(E<15)K+=P[$++]<<E,E+=8,K+=P[$++]<<E,E+=8;N=H[K&q];B:for(;;){if(I=N>>>24,K>>>=I,E-=I,I=N>>>16&255,I&16){if(w=N&65535,I&=15,E<I){if(K+=P[$++]<<E,E+=8,E<I)K+=P[$++]<<E,E+=8}if(w+=K&(1<<I)-1,w>X){Q.msg="invalid distance too far back",b.mode=W70;break A}if(K>>>=I,E-=I,I=Y-Z,w>I){if(I=w-I,I>G){if(b.sane){Q.msg="invalid distance too far back",b.mode=W70;break A}}if(M=0,j=U,V===0){if(M+=D-I,I<C){C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}}else if(V<I){if(M+=D+V-I,I-=V,I<C){C-=I;do R[Y++]=U[M++];while(--I);if(M=0,V<C){I=V,C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}}}else if(M+=V-I,I<C){C-=I;do R[Y++]=U[M++];while(--I);M=Y-w,j=R}while(C>2)R[Y++]=j[M++],R[Y++]=j[M++],R[Y++]=j[M++],C-=3;if(C){if(R[Y++]=j[M++],C>1)R[Y++]=j[M++]}}else{M=Y-w;do R[Y++]=R[M++],R[Y++]=R[M++],R[Y++]=R[M++],C-=3;while(C>2);if(C){if(R[Y++]=R[M++],C>1)R[Y++]=R[M++]}}}else if((I&64)===0){N=H[(N&65535)+(K&(1<<I)-1)];continue B}else{Q.msg="invalid distance code",b.mode=W70;break A}break}}else if((I&64)===0){N=W[(N&65535)+(K&(1<<I)-1)];continue Q}else if(I&32){b.mode=MH6;break A}else{Q.msg="invalid literal/length code",b.mode=W70;break A}break}}while($<J&&Y<F);C=E>>3,$-=C,E-=C<<3,K&=(1<<E)-1,Q.next_in=$,Q.next_out=Y,Q.avail_in=$<J?5+(J-$):5-($-J),Q.avail_out=Y<F?257+(F-Y):257-(Y-F),b.hold=K,b.bits=E;return},Gv=15,p24=852,d24=592,c24=0,wb0=1,l24=2,OH6,jH6,RH6,PH6,_H6=(A,Q,B,$,J,Y,Z,F)=>{let X=F.bits,D=0,G=0,V=0,U=0,K=0,E=0,W=0,H=0,z=0,q=0,N,I,C,w,M,j=null,P,R=new Uint16Array(Gv+1),b=new Uint16Array(Gv+1),g=null,f,k,x;for(D=0;D<=Gv;D++)R[D]=0;for(G=0;G<$;G++)R[Q[B+G]]++;K=X;for(U=Gv;U>=1;U--)if(R[U]!==0)break;if(K>U)K=U;if(U===0)return J[Y++]=20971520,J[Y++]=20971520,F.bits=1,0;for(V=1;V<U;V++)if(R[V]!==0)break;if(K<V)K=V;H=1;for(D=1;D<=Gv;D++)if(H<<=1,H-=R[D],H<0)return-1;if(H>0&&(A===c24||U!==1))return-1;b[1]=0;for(D=1;D<Gv;D++)b[D+1]=b[D]+R[D];for(G=0;G<$;G++)if(Q[B+G]!==0)Z[b[Q[B+G]]++]=G;if(A===c24)j=g=Z,P=20;else if(A===wb0)j=OH6,g=jH6,P=257;else j=RH6,g=PH6,P=0;if(q=0,G=0,D=V,M=Y,E=K,W=0,C=-1,z=1<<K,w=z-1,A===wb0&&z>p24||A===l24&&z>d24)return 1;for(;;){if(f=D-W,Z[G]+1<P)k=0,x=Z[G];else if(Z[G]>=P)k=g[Z[G]-P],x=j[Z[G]-P];else k=96,x=0;N=1<<D-W,I=1<<E,V=I;do I-=N,J[M+(q>>W)+I]=f<<24|k<<16|x|0;while(I!==0);N=1<<D-1;while(q&N)N>>=1;if(N!==0)q&=N-1,q+=N;else q=0;if(G++,--R[D]===0){if(D===U)break;D=Q[B+Z[G]]}if(D>K&&(q&w)!==C){if(W===0)W=K;M+=V,E=D-W,H=1<<E;while(E+W<U){if(H-=R[E+W],H<=0)break;E++,H<<=1}if(z+=1<<E,A===wb0&&z>p24||A===l24&&z>d24)return 1;C=q&w,J[C]=K<<24|E<<16|M-Y|0}}if(q!==0)J[M+q]=D-W<<24|4194304|0;return F.bits=K,0},tc,TH6=0,m94=1,p94=2,i24,SH6,H70,FO,kH6,vH6,NF,d94,c94,yH6,n24,O70=16180,a24=16181,o24=16182,r24=16183,s24=16184,t24=16185,e24=16186,A94=16187,Q94=16188,B94=16189,w70=16190,DW=16191,Mb0=16192,$94=16193,Lb0=16194,J94=16195,Y94=16196,Z94=16197,F94=16198,z70=16199,q70=16200,X94=16201,D94=16202,G94=16203,V94=16204,U94=16205,Ob0=16206,K94=16207,E94=16208,C3=16209,l94=16210,i94=16211,xH6=852,fH6=592,bH6=15,uH6,W94=(A)=>{return(A>>>24&255)+(A>>>8&65280)+((A&65280)<<8)+((A&255)<<24)},DO=(A)=>{if(!A)return 1;let Q=A.state;if(!Q||Q.strm!==A||Q.mode<O70||Q.mode>i94)return 1;return 0},n94=(A)=>{if(DO(A))return NF;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=O70,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(xH6),Q.distcode=Q.distdyn=new Int32Array(fH6),Q.sane=1,Q.back=-1,FO},a94=(A)=>{if(DO(A))return NF;let Q=A.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,n94(A)},o94=(A,Q)=>{let B;if(DO(A))return NF;let $=A.state;if(Q<0)B=0,Q=-Q;else if(B=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return NF;if($.window!==null&&$.wbits!==Q)$.window=null;return $.wrap=B,$.wbits=Q,a94(A)},r94=(A,Q)=>{if(!A)return NF;let B=new hH6;A.state=B,B.strm=A,B.window=null,B.mode=O70;let $=o94(A,Q);if($!==FO)A.state=null;return $},gH6=(A)=>{return r94(A,uH6)},H94=!0,jb0,Rb0,mH6=(A)=>{if(H94){jb0=new Int32Array(512),Rb0=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;tc(m94,A.lens,0,288,jb0,0,A.work,{bits:9}),Q=0;while(Q<32)A.lens[Q++]=5;tc(p94,A.lens,0,32,Rb0,0,A.work,{bits:5}),H94=!1}A.lencode=jb0,A.lenbits=9,A.distcode=Rb0,A.distbits=5},s94=(A,Q,B,$)=>{let J,Y=A.state;if(Y.window===null)Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new Uint8Array(Y.wsize);if($>=Y.wsize)Y.window.set(Q.subarray(B-Y.wsize,B),0),Y.wnext=0,Y.whave=Y.wsize;else{if(J=Y.wsize-Y.wnext,J>$)J=$;if(Y.window.set(Q.subarray(B-$,B-$+J),Y.wnext),$-=J,$)Y.window.set(Q.subarray(B-$,B),0),Y.wnext=$,Y.whave=Y.wsize;else{if(Y.wnext+=J,Y.wnext===Y.wsize)Y.wnext=0;if(Y.whave<Y.wsize)Y.whave+=J}}return 0},pH6=(A,Q)=>{let B,$,J,Y,Z,F,X,D,G,V,U,K,E,W,H=0,z,q,N,I,C,w,M,j,P=new Uint8Array(4),R,b,g=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(DO(A)||!A.output||!A.input&&A.avail_in!==0)return NF;if(B=A.state,B.mode===DW)B.mode=Mb0;Z=A.next_out,J=A.output,X=A.avail_out,Y=A.next_in,$=A.input,F=A.avail_in,D=B.hold,G=B.bits,V=F,U=X,j=FO;A:for(;;)switch(B.mode){case O70:if(B.wrap===0){B.mode=Mb0;break}while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&2&&D===35615){if(B.wbits===0)B.wbits=15;B.check=0,P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0),D=0,G=0,B.mode=a24;break}if(B.head)B.head.done=!1;if(!(B.wrap&1)||(((D&255)<<8)+(D>>8))%31){A.msg="incorrect header check",B.mode=C3;break}if((D&15)!==n24){A.msg="unknown compression method",B.mode=C3;break}if(D>>>=4,G-=4,M=(D&15)+8,B.wbits===0)B.wbits=M;if(M>15||M>B.wbits){A.msg="invalid window size",B.mode=C3;break}B.dmax=1<<B.wbits,B.flags=0,A.adler=B.check=1,B.mode=D&512?B94:DW,D=0,G=0;break;case a24:while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.flags=D,(B.flags&255)!==n24){A.msg="unknown compression method",B.mode=C3;break}if(B.flags&57344){A.msg="unknown header flags set",B.mode=C3;break}if(B.head)B.head.text=D>>8&1;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0,B.mode=o24;case o24:while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.head)B.head.time=D;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,P[2]=D>>>16&255,P[3]=D>>>24&255,B.check=z7(B.check,P,4,0);D=0,G=0,B.mode=r24;case r24:while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.head)B.head.xflags=D&255,B.head.os=D>>8;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0,B.mode=s24;case s24:if(B.flags&1024){while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.length=D,B.head)B.head.extra_len=D;if(B.flags&512&&B.wrap&4)P[0]=D&255,P[1]=D>>>8&255,B.check=z7(B.check,P,2,0);D=0,G=0}else if(B.head)B.head.extra=null;B.mode=t24;case t24:if(B.flags&1024){if(K=B.length,K>F)K=F;if(K){if(B.head){if(M=B.head.extra_len-B.length,!B.head.extra)B.head.extra=new Uint8Array(B.head.extra_len);B.head.extra.set($.subarray(Y,Y+K),M)}if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);F-=K,Y+=K,B.length-=K}if(B.length)break A}B.length=0,B.mode=e24;case e24:if(B.flags&2048){if(F===0)break A;K=0;do if(M=$[Y+K++],B.head&&M&&B.length<65536)B.head.name+=String.fromCharCode(M);while(M&&K<F);if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);if(F-=K,Y+=K,M)break A}else if(B.head)B.head.name=null;B.length=0,B.mode=A94;case A94:if(B.flags&4096){if(F===0)break A;K=0;do if(M=$[Y+K++],B.head&&M&&B.length<65536)B.head.comment+=String.fromCharCode(M);while(M&&K<F);if(B.flags&512&&B.wrap&4)B.check=z7(B.check,$,K,Y);if(F-=K,Y+=K,M)break A}else if(B.head)B.head.comment=null;B.mode=Q94;case Q94:if(B.flags&512){while(G<16){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&4&&D!==(B.check&65535)){A.msg="header crc mismatch",B.mode=C3;break}D=0,G=0}if(B.head)B.head.hcrc=B.flags>>9&1,B.head.done=!0;A.adler=B.check=0,B.mode=DW;break;case B94:while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}A.adler=B.check=W94(D),D=0,G=0,B.mode=w70;case w70:if(B.havedict===0)return A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,vH6;A.adler=B.check=1,B.mode=DW;case DW:if(Q===SH6||Q===H70)break A;case Mb0:if(B.last){D>>>=G&7,G-=G&7,B.mode=Ob0;break}while(G<3){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}switch(B.last=D&1,D>>>=1,G-=1,D&3){case 0:B.mode=$94;break;case 1:if(mH6(B),B.mode=z70,Q===H70){D>>>=2,G-=2;break A}break;case 2:B.mode=Y94;break;case 3:A.msg="invalid block type",B.mode=C3}D>>>=2,G-=2;break;case $94:D>>>=G&7,G-=G&7;while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if((D&65535)!==(D>>>16^65535)){A.msg="invalid stored block lengths",B.mode=C3;break}if(B.length=D&65535,D=0,G=0,B.mode=Lb0,Q===H70)break A;case Lb0:B.mode=J94;case J94:if(K=B.length,K){if(K>F)K=F;if(K>X)K=X;if(K===0)break A;J.set($.subarray(Y,Y+K),Z),F-=K,Y+=K,X-=K,Z+=K,B.length-=K;break}B.mode=DW;break;case Y94:while(G<14){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.nlen=(D&31)+257,D>>>=5,G-=5,B.ndist=(D&31)+1,D>>>=5,G-=5,B.ncode=(D&15)+4,D>>>=4,G-=4,B.nlen>286||B.ndist>30){A.msg="too many length or distance symbols",B.mode=C3;break}B.have=0,B.mode=Z94;case Z94:while(B.have<B.ncode){while(G<3){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.lens[g[B.have++]]=D&7,D>>>=3,G-=3}while(B.have<19)B.lens[g[B.have++]]=0;if(B.lencode=B.lendyn,B.lenbits=7,R={bits:B.lenbits},j=tc(TH6,B.lens,0,19,B.lencode,0,B.work,R),B.lenbits=R.bits,j){A.msg="invalid code lengths set",B.mode=C3;break}B.have=0,B.mode=F94;case F94:while(B.have<B.nlen+B.ndist){for(;;){if(H=B.lencode[D&(1<<B.lenbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(N<16)D>>>=z,G-=z,B.lens[B.have++]=N;else{if(N===16){b=z+2;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(D>>>=z,G-=z,B.have===0){A.msg="invalid bit length repeat",B.mode=C3;break}M=B.lens[B.have-1],K=3+(D&3),D>>>=2,G-=2}else if(N===17){b=z+3;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=z,G-=z,M=0,K=3+(D&7),D>>>=3,G-=3}else{b=z+7;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=z,G-=z,M=0,K=11+(D&127),D>>>=7,G-=7}if(B.have+K>B.nlen+B.ndist){A.msg="invalid bit length repeat",B.mode=C3;break}while(K--)B.lens[B.have++]=M}}if(B.mode===C3)break;if(B.lens[256]===0){A.msg="invalid code -- missing end-of-block",B.mode=C3;break}if(B.lenbits=9,R={bits:B.lenbits},j=tc(m94,B.lens,0,B.nlen,B.lencode,0,B.work,R),B.lenbits=R.bits,j){A.msg="invalid literal/lengths set",B.mode=C3;break}if(B.distbits=6,B.distcode=B.distdyn,R={bits:B.distbits},j=tc(p94,B.lens,B.nlen,B.ndist,B.distcode,0,B.work,R),B.distbits=R.bits,j){A.msg="invalid distances set",B.mode=C3;break}if(B.mode=z70,Q===H70)break A;case z70:B.mode=q70;case q70:if(F>=6&&X>=258){if(A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,LH6(A,U),Z=A.next_out,J=A.output,X=A.avail_out,Y=A.next_in,$=A.input,F=A.avail_in,D=B.hold,G=B.bits,B.mode===DW)B.back=-1;break}B.back=0;for(;;){if(H=B.lencode[D&(1<<B.lenbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(q&&(q&240)===0){I=z,C=q,w=N;for(;;){if(H=B.lencode[w+((D&(1<<I+C)-1)>>I)],z=H>>>24,q=H>>>16&255,N=H&65535,I+z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=I,G-=I,B.back+=I}if(D>>>=z,G-=z,B.back+=z,B.length=N,q===0){B.mode=U94;break}if(q&32){B.back=-1,B.mode=DW;break}if(q&64){A.msg="invalid literal/length code",B.mode=C3;break}B.extra=q&15,B.mode=X94;case X94:if(B.extra){b=B.extra;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.length+=D&(1<<B.extra)-1,D>>>=B.extra,G-=B.extra,B.back+=B.extra}B.was=B.length,B.mode=D94;case D94:for(;;){if(H=B.distcode[D&(1<<B.distbits)-1],z=H>>>24,q=H>>>16&255,N=H&65535,z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if((q&240)===0){I=z,C=q,w=N;for(;;){if(H=B.distcode[w+((D&(1<<I+C)-1)>>I)],z=H>>>24,q=H>>>16&255,N=H&65535,I+z<=G)break;if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}D>>>=I,G-=I,B.back+=I}if(D>>>=z,G-=z,B.back+=z,q&64){A.msg="invalid distance code",B.mode=C3;break}B.offset=N,B.extra=q&15,B.mode=G94;case G94:if(B.extra){b=B.extra;while(G<b){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}B.offset+=D&(1<<B.extra)-1,D>>>=B.extra,G-=B.extra,B.back+=B.extra}if(B.offset>B.dmax){A.msg="invalid distance too far back",B.mode=C3;break}B.mode=V94;case V94:if(X===0)break A;if(K=U-X,B.offset>K){if(K=B.offset-K,K>B.whave){if(B.sane){A.msg="invalid distance too far back",B.mode=C3;break}}if(K>B.wnext)K-=B.wnext,E=B.wsize-K;else E=B.wnext-K;if(K>B.length)K=B.length;W=B.window}else W=J,E=Z-B.offset,K=B.length;if(K>X)K=X;X-=K,B.length-=K;do J[Z++]=W[E++];while(--K);if(B.length===0)B.mode=q70;break;case U94:if(X===0)break A;J[Z++]=B.length,X--,B.mode=q70;break;case Ob0:if(B.wrap){while(G<32){if(F===0)break A;F--,D|=$[Y++]<<G,G+=8}if(U-=X,A.total_out+=U,B.total+=U,B.wrap&4&&U)A.adler=B.check=B.flags?z7(B.check,J,U,Z-U):$l(B.check,J,U,Z-U);if(U=X,B.wrap&4&&(B.flags?D:W94(D))!==B.check){A.msg="incorrect data check",B.mode=C3;break}D=0,G=0}B.mode=K94;case K94:if(B.wrap&&B.flags){while(G<32){if(F===0)break A;F--,D+=$[Y++]<<G,G+=8}if(B.wrap&4&&D!==(B.total&4294967295)){A.msg="incorrect length check",B.mode=C3;break}D=0,G=0}B.mode=E94;case E94:j=kH6;break A;case C3:j=d94;break A;case l94:return c94;case i94:default:return NF}if(A.next_out=Z,A.avail_out=X,A.next_in=Y,A.avail_in=F,B.hold=D,B.bits=G,B.wsize||U!==A.avail_out&&B.mode<C3&&(B.mode<Ob0||Q!==i24)){if(s94(A,A.output,A.next_out,U-A.avail_out));}if(V-=A.avail_in,U-=A.avail_out,A.total_in+=V,A.total_out+=U,B.total+=U,B.wrap&4&&U)A.adler=B.check=B.flags?z7(B.check,J,U,A.next_out-U):$l(B.check,J,U,A.next_out-U);if(A.data_type=B.bits+(B.last?64:0)+(B.mode===DW?128:0)+(B.mode===z70||B.mode===Lb0?256:0),(V===0&&U===0||Q===i24)&&j===FO)j=yH6;return j},dH6=(A)=>{if(DO(A))return NF;let Q=A.state;if(Q.window)Q.window=null;return A.state=null,FO},cH6=(A,Q)=>{if(DO(A))return NF;let B=A.state;if((B.wrap&2)===0)return NF;return B.head=Q,Q.done=!1,FO},lH6=(A,Q)=>{let B=Q.length,$,J,Y;if(DO(A))return NF;if($=A.state,$.wrap!==0&&$.mode!==w70)return NF;if($.mode===w70){if(J=1,J=$l(J,Q,B,0),J!==$.check)return d94}if(Y=s94(A,Q,B,B),Y)return $.mode=l94,c94;return $.havedict=1,FO},iH6,nH6,aH6,oH6,rH6,sH6,tH6,eH6,Az6,Qz6="pako inflate (from Nodeca project)",VW,$z6,t94,Jz6,Yz6,Zl,Pb0,_b0,Zz6,z94,Fz6,Dz6,Gz6,Vz6,Uz6,Kz6,Ez6,Wz6,Hz6,zz6,qz6,Nz6,Iz6,Cz6,wz6,Mz6,Lz6,Oz6,jz6,Rz6,Pz6,_z6,Tz6,Sz6,e94;var A74=J0(()=>{/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */ec=Fl+1+hb0,N94=2*ec+1,Tb0=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]),N70=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]),pE6=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),M94=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),GW=Array((ec+2)*2);Ev(GW);rc=Array(Vv*2);Ev(rc);Al=Array(dE6);Ev(Al);Ql=Array(gE6-hE6+1);Ev(Ql);pb0=Array(hb0);Ev(pb0);I70=Array(Vv);Ev(I70);AW6=rE6,QW6=k94,BW6=tE6,$W6=eE6,JW6=sE6,YW6={_tr_init:AW6,_tr_stored_block:QW6,_tr_flush_block:BW6,_tr_tally:$W6,_tr_align:JW6},$l=ZW6,XW6=new Uint32Array(FW6()),z7=DW6,YO={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"},XO={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:GW6,_tr_stored_block:kb0,_tr_flush_block:VW6,_tr_tally:rq,_tr_align:UW6}=YW6,{Z_NO_FLUSH:sq,Z_PARTIAL_FLUSH:KW6,Z_FULL_FLUSH:EW6,Z_FINISH:qF,Z_BLOCK:h24,Z_OK:UQ,Z_STREAM_END:g24,Z_STREAM_ERROR:QU,Z_DATA_ERROR:WW6,Z_BUF_ERROR:Ib0,Z_DEFAULT_COMPRESSION:HW6,Z_FILTERED:zW6,Z_HUFFMAN_ONLY:E70,Z_RLE:qW6,Z_FIXED:NW6,Z_DEFAULT_STRATEGY:IW6,Z_UNKNOWN:CW6,Z_DEFLATED:M70}=XO,vb0=jW6+1+OW6,_W6=2*vb0+1,BU=oq+F5+1,tq=yW6;oc=[new eV(0,0,0,0,y94),new eV(4,4,8,4,Cb0),new eV(4,5,16,8,Cb0),new eV(4,6,32,32,Cb0),new eV(4,4,16,16,Dv),new eV(8,16,32,32,Dv),new eV(8,16,128,128,Dv),new eV(8,32,128,256,Dv),new eV(32,128,258,1024,Dv),new eV(32,258,258,4096,Dv)];cW6=gW6,lW6=b94,iW6=f94,nW6=x94,aW6=hW6,oW6=mW6,rW6=pW6,sW6=dW6,sc={deflateInit:cW6,deflateInit2:lW6,deflateReset:iW6,deflateResetKeep:nW6,deflateSetHeader:aW6,deflate:oW6,deflateEnd:rW6,deflateSetDictionary:sW6,deflateInfo:tW6},L70={assign:AH6,flattenChunks:QH6};try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){u94=!1}Jl=new Uint8Array(256);for(let A=0;A<256;A++)Jl[A]=A>=252?6:A>=248?5:A>=240?4:A>=224?3:A>=192?2:1;Jl[254]=Jl[254]=1;Yl={string2buf:BH6,buf2string:JH6,utf8border:YH6};h94=ZH6,g94=Object.prototype.toString,{Z_NO_FLUSH:FH6,Z_SYNC_FLUSH:XH6,Z_FULL_FLUSH:DH6,Z_FINISH:GH6,Z_OK:C70,Z_STREAM_END:VH6,Z_DEFAULT_COMPRESSION:UH6,Z_DEFAULT_STRATEGY:KH6,Z_DEFLATED:EH6}=XO;Dl.prototype.push=function(A,Q){let B=this.strm,$=this.options.chunkSize,J,Y;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?GH6:FH6;if(typeof A==="string")B.input=Yl.string2buf(A);else if(g94.call(A)==="[object ArrayBuffer]")B.input=new Uint8Array(A);else B.input=A;B.next_in=0,B.avail_in=B.input.length;for(;;){if(B.avail_out===0)B.output=new Uint8Array($),B.next_out=0,B.avail_out=$;if((Y===XH6||Y===DH6)&&B.avail_out<=6){this.onData(B.output.subarray(0,B.next_out)),B.avail_out=0;continue}if(J=sc.deflate(B,Y),J===VH6){if(B.next_out>0)this.onData(B.output.subarray(0,B.next_out));return J=sc.deflateEnd(this.strm),this.onEnd(J),this.ended=!0,J===C70}if(B.avail_out===0){this.onData(B.output);continue}if(Y>0&&B.next_out>0){this.onData(B.output.subarray(0,B.next_out)),B.avail_out=0;continue}if(B.avail_in===0)break}return!0};Dl.prototype.onData=function(A){this.chunks.push(A)};Dl.prototype.onEnd=function(A){if(A===C70)this.result=L70.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};zH6=Dl,qH6=cb0,NH6=WH6,IH6=HH6,CH6=XO,wH6={Deflate:zH6,deflate:qH6,deflateRaw:NH6,gzip:IH6,constants:CH6},OH6=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]),jH6=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]),RH6=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]),PH6=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]),tc=_H6,{Z_FINISH:i24,Z_BLOCK:SH6,Z_TREES:H70,Z_OK:FO,Z_STREAM_END:kH6,Z_NEED_DICT:vH6,Z_STREAM_ERROR:NF,Z_DATA_ERROR:d94,Z_MEM_ERROR:c94,Z_BUF_ERROR:yH6,Z_DEFLATED:n24}=XO,uH6=bH6;iH6=a94,nH6=o94,aH6=n94,oH6=gH6,rH6=r94,sH6=pH6,tH6=dH6,eH6=cH6,Az6=lH6,VW={inflateReset:iH6,inflateReset2:nH6,inflateResetKeep:aH6,inflateInit:oH6,inflateInit2:rH6,inflate:sH6,inflateEnd:tH6,inflateGetHeader:eH6,inflateSetDictionary:Az6,inflateInfo:Qz6};$z6=Bz6,t94=Object.prototype.toString,{Z_NO_FLUSH:Jz6,Z_FINISH:Yz6,Z_OK:Zl,Z_STREAM_END:Pb0,Z_NEED_DICT:_b0,Z_STREAM_ERROR:Zz6,Z_DATA_ERROR:z94,Z_MEM_ERROR:Fz6}=XO;Gl.prototype.push=function(A,Q){let B=this.strm,$=this.options.chunkSize,J=this.options.dictionary,Y,Z,F;if(this.ended)return!1;if(Q===~~Q)Z=Q;else Z=Q===!0?Yz6:Jz6;if(t94.call(A)==="[object ArrayBuffer]")B.input=new Uint8Array(A);else B.input=A;B.next_in=0,B.avail_in=B.input.length;for(;;){if(B.avail_out===0)B.output=new Uint8Array($),B.next_out=0,B.avail_out=$;if(Y=VW.inflate(B,Z),Y===_b0&&J){if(Y=VW.inflateSetDictionary(B,J),Y===Zl)Y=VW.inflate(B,Z);else if(Y===z94)Y=_b0}while(B.avail_in>0&&Y===Pb0&&B.state.wrap>0&&A[B.next_in]!==0)VW.inflateReset(B),Y=VW.inflate(B,Z);switch(Y){case Zz6:case z94:case _b0:case Fz6:return this.onEnd(Y),this.ended=!0,!1}if(F=B.avail_out,B.next_out){if(B.avail_out===0||Y===Pb0)if(this.options.to==="string"){let X=Yl.utf8border(B.output,B.next_out),D=B.next_out-X,G=Yl.buf2string(B.output,X);if(B.next_out=D,B.avail_out=$-D,D)B.output.set(B.output.subarray(X,X+D),0);this.onData(G)}else this.onData(B.output.length===B.next_out?B.output:B.output.subarray(0,B.next_out))}if(Y===Zl&&F===0)continue;if(Y===Pb0)return Y=VW.inflateEnd(this.strm),this.onEnd(Y),this.ended=!0,!0;if(B.avail_in===0)break}return!0};Gl.prototype.onData=function(A){this.chunks.push(A)};Gl.prototype.onEnd=function(A){if(A===Zl)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=L70.flattenChunks(this.chunks);this.chunks=[],this.err=A,this.msg=this.strm.msg};Dz6=Gl,Gz6=lb0,Vz6=Xz6,Uz6=lb0,Kz6=XO,Ez6={Inflate:Dz6,inflate:Gz6,inflateRaw:Vz6,ungzip:Uz6,constants:Kz6},{Deflate:Wz6,deflate:Hz6,deflateRaw:zz6,gzip:qz6}=wH6,{Inflate:Nz6,inflate:Iz6,inflateRaw:Cz6,ungzip:wz6}=Ez6,Mz6=Wz6,Lz6=Hz6,Oz6=zz6,jz6=qz6,Rz6=Nz6,Pz6=Iz6,_z6=Cz6,Tz6=wz6,Sz6=XO,e94={Deflate:Mz6,deflate:Lz6,deflateRaw:Oz6,gzip:jz6,Inflate:Rz6,inflate:Pz6,inflateRaw:_z6,ungzip:Tz6,constants:Sz6}});function kz6(A){if(A.proxy&&!process.env.HTTP_PROXY&&!process.env.http_proxy)process.env.HTTP_PROXY=A.proxy;if(A.proxy&&!process.env.HTTPS_PROXY&&!process.env.https_proxy)process.env.HTTPS_PROXY=A.proxy}function _Y(A,Q,B){let $=B?`/threads/${Q}/${B}`:`/threads/${Q}`;return new URL($,A)}async function q7(A,Q,B){let $=await B.getLatest(Q?.signal??void 0),J=await B74(A,Q,$);return fetch(J)}async function Q74(A,Q,B){let $=await B74(Q,B,A);return fetch($)}async function B74(A,Q,B){if(A.startsWith("http:")||A.startsWith("https:"))throw Error("input must be a path, not an absolute URL");if(!A.startsWith("/"))throw Error("pathAndQuery must start with /");let $=B.settings.url;if(!$)throw Error("amp.url is not set");let J=await B.secrets.getToken("apiKey",$);kz6({proxy:B.settings.proxy});let Y=new URL(A,$);return new Request(Y,{...Q,duplex:"half",headers:{"Content-Type":"application/json",...Q?.headers,...Z9(),...J?{Authorization:`Bearer ${J}`}:{}}})}async function $74(A,Q,B,$){let J=await lA.shareThreadWithOperator({threadID:A,message:B||void 0,ephemeralError:$||void 0},{config:Q});if(!J.ok)throw Error(`Failed to share thread: ${J.error.message}`)}async function j70(A,Q){let B=await q7("/api/telemetry",{method:"POST",redirect:"manual",body:A},Q);if(!B.ok){let $=await B.text(),J;try{J=JSON.parse($).error||`HTTP ${B.status}`}catch{J=$||`HTTP ${B.status}`}throw Error(`Failed to submit telemetry: ${J}`)}}var KQ=J0(()=>{sQ();EQ()});function yz6(A){if(new Blob([A]).size<=vz6)return{body:A};return{body:e94.gzip(A),headers:{"Content-Encoding":"gzip"}}}function xz6(){return new Proxy({},{get:(A,Q)=>{return async(...B)=>{let $=B.at(1),J=B.at(0);if(!$?.config)throw Error("Internal API client requires configService in options. Call with { config: configService }");let{body:Y,headers:Z={}}=yz6(JSON.stringify({method:Q,params:J})),F=await q7("/api/internal?"+encodeURIComponent(Q),{method:"POST",body:Y,headers:Z,signal:$?.signal},$.config);if(!F.ok)throw Error(`API request for ${Q} failed: ${F.status}`);return await F.json()}}})}var vz6=25600,lA;var EQ=J0(()=>{A74();KQ();lA=xz6()});function fz6(A){return A.config.pipe(w1(({settings:Q,secrets:B})=>({url:Q.url,proxy:Q.proxy,secrets:B})),l4(ic),c4((Q)=>B90(600000).pipe(R6(void 0),jk(()=>JA(async(B)=>{let $=await lA.getUserInfo({},{signal:B,config:A});if($.ok)return $.result;if($.error&&$.error.code==="auth-required")return null;throw T.error("getUserInfo failed",{error:$.error}),Error(`getUserInfo error: ${$.error.code}`)})))),w1((Q)=>{return Q instanceof Error?{error:{message:String(Q)}}:Q===dV?"pending":Q?{user:Q,features:Q.features,workspace:Q?.team,mysteriousMessage:Q?.mysteriousMessage}:{error:{message:"User not found"}}}),l4((Q,B)=>ic(Q,B)),sA({shouldCountRefs:!0}))}function YJ(A){let Q=J74.get(A);if(Q)return Q;let B=fz6(A);return J74.set(A,B),B}function gA(A){return Boolean(typeof A==="object"&&"user"in A&&A.user)}function UW(A){return typeof A==="object"&&"error"in A}var J74;var IF=J0(()=>{O1();l0();EQ();J74=new WeakMap});function R70(A,Q,B){if(A.startsWith("mcp__"))return Q.allowMcp??!1;if(A.startsWith("tb__")){if(!(Q.allowToolbox??!1))return!1;let $="subagentType"in Q?Q.subagentType:void 0;if($&&B){if(!B.subagentTypes)return!1;return B.subagentTypes.includes("all")||B.subagentTypes.includes($)}return!0}return Q.includeTools.includes(A)}var ib0,Y74,bz6,nb0,uz6,hz6,gz6=24,mz6=36,pz6,dz6,m3;var $U=J0(()=>{E7();ib0=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],Y74=["read_bitbucket_enterprise","search_bitbucket_enterprise","commit_search_bitbucket_enterprise","diff_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise"],bz6=["Grep","glob","Read"],nb0=["Read","Grep","glob","web_search","read_web_page","read_thread","find_thread"],uz6=["Read","Bash","edit_file","create_file","read_web_page","web_search","finder","skill","task_list","look_at"],hz6=["Read","Grep","glob","web_search","read_web_page","Bash"],pz6=["Read","Grep","glob","web_search","read_web_page","Bash","eval_git_diff","post_explanation"],dz6=["Read","Grep","glob","Bash"],m3={finder:{key:"finder",displayName:"Finder",model:c5("CLAUDE_HAIKU_4_5"),includeTools:bz6,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:c5("GPT_5_4"),includeTools:nb0,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:c5("CLAUDE_SONNET_4_6"),includeTools:ib0,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:uz6,allowMcp:!0,allowToolbox:!0},"code-review":{key:"code-review",displayName:"Code Review",model:c5("GEMINI_3_1_PRO_PREVIEW"),maxTurns:gz6,includeTools:hz6,allowMcp:!1,allowToolbox:!1},"code-tour":{key:"code-tour",displayName:"Code Tour",model:c5("CLAUDE_OPUS_4_6"),includeTools:pz6,allowMcp:!1,allowToolbox:!1},"codereview-check":{key:"codereview-check",displayName:"Codereview Check",model:c5("CLAUDE_HAIKU_4_5"),maxTurns:mz6,includeTools:dz6,allowMcp:!1,allowToolbox:!1}}});function Z74(A,Q){return new g0((B)=>{let $=setTimeout(J,Q);function J(){B.error(Error(`Tool execution timed out after ${Q/1000} seconds`))}function Y(){if($)clearTimeout($);$=setTimeout(J,Q)}let Z=A.subscribe({next:(F)=>{Y(),B.next(F)},error:(F)=>{if($)clearTimeout($),$=null;B.error(F)},complete:()=>{if($)clearTimeout($),$=null;B.complete()}});return()=>{if($)clearTimeout($),$=null;Z.unsubscribe()}})}var F74=J0(()=>{O1()});function D74(A){return{tool:A,action:"allow"}}function cz6(A){if(!A||!("cmd"in A))return A;let{cmd:Q,...B}=A;return{...B,command:Q}}function lz6(A){return A.flatMap((Q)=>{if(Q.tool!==I6)return[];return[{...Q,tool:LY,matches:cz6(Q.matches)}]})}var X74,zv;var P70=J0(()=>{v4();X74=[{tool:"Bash",action:"ask",matches:{cmd:"*git*push*"}},{tool:"mcp__*",action:"allow"},{tool:G90,action:"allow"},{tool:"tb__*",action:"allow"},{tool:"Bash",matches:{cmd:"/^(.*\\s+)?(bazel|ibazel)\\s+.*\\/\\/[^\\s]*.*$/"},action:"allow"},{tool:"Bash",matches:{cmd:["ls","ls *","dir","dir *","cat *","head *","tail *","less *","more *","grep *","egrep *","fgrep *","tree","tree *","file *","wc *","pwd","stat *","du *","df *","ps *","top","htop","echo *","printenv *","id","which *","whereis *","date","cal *","uptime","free *","ping *","dig *","nslookup *","host *","netstat *","ss *","lsof *","ifconfig *","ip *","man *","info *","mkdir *","touch *","uname *","whoami","go version","go env *","go help *","cargo version","cargo --version","cargo help *","rustc --version","rustc --help","rustc --explain *","javac --version","javac -version","javac -help","javac --help","dotnet --info","dotnet --version","dotnet --help","dotnet help *","gcc --version","gcc -v","gcc --help","gcc -dumpversion","g++ --version","g++ -v","g++ --help","g++ -dumpversion","clang --version","clang --help","clang++ --version","clang++ --help","python -V","python --version","python -h","python --help","python3 -V","python3 --version","python3 -h","python3 --help","ruby -v","ruby --version","ruby -h","ruby --help","node -v","node --version","node -h","node --help","npm --help","npm --version","npm -v","npm help *","yarn --help","yarn --version","yarn -v","yarn help *","pnpm --help","pnpm --version","pnpm -v","pnpm help *","pytest -h","pytest --help","pytest --version","jest --help","jest --version","mocha --help","mocha --version","make --version","make --help","docker --version","docker --help","docker version","docker help *","git --version","git --help","git help *","git version"]},action:"allow"},{tool:"Bash",matches:{cmd:["go test *","go run *","go build *","go vet *","go fmt *","go list *","cargo test *","cargo run *","cargo build *","cargo check *","cargo fmt *","cargo tree *","make -n *","make --dry-run *","mvn test *","mvn verify *","mvn dependency:tree *","gradle tasks *","gradle dependencies *","gradle properties *","dotnet test *","dotnet list *","python -c *","ruby -e *","node -e *","npm list *","npm ls *","npm outdated *","npm test*","npm run*","npm view *","npm info *","yarn list*","yarn ls *","yarn info *","yarn test*","yarn run *","yarn why *","pnpm list*","pnpm ls *","pnpm outdated *","pnpm test*","pnpm run *","pytest --collect-only *","jest --listTests *","jest --showConfig *","mocha --list *","git status*","git show *","git diff*","git grep *","git branch *","git tag *","git remote -v *","git rev-parse --is-inside-work-tree *","git rev-parse --show-toplevel *","git config --list *","git log *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./gradlew *","./mvnw *","./build.sh *","./configure *","cmake *","./node_modules/.bin/tsc *","./node_modules/.bin/eslint *","./node_modules/.bin/prettier *","prettier *","./node_modules/.bin/tailwindcss *","./node_modules/.bin/tsx *","./node_modules/.bin/vite *","bun *","tsx *","vite *"]},action:"allow"},{tool:"Bash",matches:{cmd:[".venv/bin/activate *",".venv/Scripts/activate *","source .venv/bin/activate *","source venv/bin/activate *","pip list *","pip show *","pip check *","pip freeze *","uv *","poetry show *","poetry check *","pipenv check *"]},action:"allow"},{tool:"Bash",matches:{cmd:["asdf list *","asdf current *","asdf which *","mise list *","mise current *","mise which *","mise use *","rbenv version *","rbenv versions *","rbenv which *","nvm list *","nvm current *","nvm which *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./test*","./run_tests.sh *","./run_*_tests.sh *","vitest *","bundle exec rspec *","bundle exec rubocop *","rspec *","rubocop *","swiftlint *","clippy *","ruff *","black *","isort *","mypy *","flake8 *","bandit *","safety *","biome check *","biome format *"]},action:"allow"},{tool:"Bash",matches:{cmd:["rails server *","rails s *","bin/rails server *","bin/rails s *","flask run *","django-admin runserver *","python manage.py runserver *","uvicorn *","streamlit run *"]},action:"allow"},{tool:"Bash",matches:{cmd:["bin/rails db:status","bin/rails db:version","rails db:rollback *","rails db:status *","rails db:version *","alembic current *","alembic history *","bundle exec rails db:status","bundle exec rails db:version"]},action:"allow"},{tool:"Bash",matches:{cmd:["docker ps *","docker images *","docker logs *","docker inspect *","docker info *","docker stats *","docker system df *","docker system info *","podman ps *","podman images *","podman logs *","podman inspect *","podman info *"]},action:"allow"},{tool:"Bash",matches:{cmd:["aws --version *","aws configure list *","aws sts get-caller-identity *","aws s3 ls *","gcloud config list *","gcloud auth list *","gcloud projects list *","az account list *","az account show *","kubectl get *","kubectl describe *","kubectl logs *","kubectl version *","helm list *","helm status *","helm version *"]},action:"allow"},{tool:"Bash",matches:{cmd:["swift build *","swift test *","zig build *","zig build test*","kotlinc *","scalac *","javac *","javap *","clang *","jar *","sbt *","gradle *","bazel build *","bazel test *","bazel run *","mix *","lua *","ruby *","php *"]},action:"allow"},{tool:"Bash",matches:{cmd:["mkdir -p *","chmod +x *","dos2unix *","unix2dos *","ln -s *"]},action:"allow"},{tool:"Bash",matches:{cmd:["for *","while *","do *","done *","if *","then *","else *","elif *","fi *","case *","esac *","in *","function *","select *","until *","{ *","} *","[[ *","]] *"]},action:"ask"},{tool:"Bash",matches:{cmd:"/^find(?!.*(-delete|-exec|-execdir)).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(echo|ls|pwd|date|whoami|id|uname)\\s.*[&|;].*\\s*(echo|ls|pwd|date|whoami|id|uname)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(cat|grep|head|tail|less|more|find)\\s.*\\|\\s*(grep|head|tail|less|more|wc|sort|uniq)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^rm\\s+.*(-[rf].*-[rf]|-[rf]{2,}|--recursive.*--force|--force.*--recursive).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^find.*(-delete|-exec|-execdir).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^(ls|cat|grep|head|tail|file|stat)\\s+[^/]*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/(^|\\s)(\\/(?!dev\\/(null|zero|stdout|stderr|stdin))[^\\s]*|\\.\\.\\/)(?![^\\s]*\\.(log|txt|md|json|yml|yaml)$)/"},action:"ask"},{tool:"Bash",action:"ask"},D74("Glob")],zv=[...X74,...lz6(X74),...l64.map(D74)]});class G74{input;position=0;line=1;column=1;tokens=[];constructor(A){this.input=A}current(){return this.position<this.input.length?this.input[this.position]:""}peek(){return this.position+1<this.input.length?this.input[this.position+1]:""}advance(){let A=this.current();if(this.position++,A===`
245
245
  `)this.line++,this.column=1;else this.column++;return A}skipWhitespace(){while(this.current()&&/\s/.test(this.current())&&this.current()!==`
246
246
  `)this.advance()}readString(){let A="",Q=this.current();this.advance();while(this.current()&&this.current()!==Q)if(this.current()==="\\"&&this.peek()===Q)this.advance(),A+=this.advance();else A+=this.advance();if(!this.current())throw Error("Unterminated string");return this.advance(),A}readIdentifier(){let A="";if(this.current()==="-"&&/\d/.test(this.peek()))A+=this.advance();while(this.current()&&/[a-zA-Z0-9_*.-]/.test(this.current()))A+=this.advance();if((this.current()==="e"||this.current()==="E")&&/[-+]?\d/.test(this.peek())){if(A+=this.advance(),this.current()==="+"||this.current()==="-")A+=this.advance();while(this.current()&&/\d/.test(this.current()))A+=this.advance()}return A}readFlag(){let A="";this.advance(),this.advance();while(this.current()&&/[a-zA-Z0-9_*:.-]/.test(this.current()))A+=this.advance();return A}readComment(){let A="";this.advance();while(this.current()&&this.current()!==`
247
247
  `)A+=this.advance();return A.trim()}tokenize(){this.tokens=[];while(this.position<this.input.length){let A={position:this.position,line:this.line,column:this.column};if(this.skipWhitespace(),!this.current())break;if(this.current()==="'"||this.current()==='"'){try{let Q=this.readString();this.tokens.push({type:"STRING",value:Q,...A})}catch(Q){throw Error(`Parse error at line ${this.line}, column ${this.column}: ${Q}`)}continue}if(this.current()===`
@@ -3086,7 +3086,7 @@ Output only the command tags, no explanation.`,messages:[{role:"user",content:A}
3086
3086
  Your task is to perform a code review of the provided diff description. The diff description might be a git or bash command that generates the diff or a description of the diff which can then be used to generate the git or bash command to generate the full diff.
3087
3087
 
3088
3088
  After reading the diff, do the following:
3089
- 1. Generate a high-level summary of the changes in the diff.
3089
+ 1. Write a high-level summary of the changes in the diff.
3090
3090
  2. Go file-by-file and review each changed hunk.
3091
3091
  3. Comment on what changed in that hunk (including the line range) and how it relates to other
3092
3092
  changed hunks and code, reading any other relevant files. Also call out bugs, hackiness,
@@ -3096,12 +3096,56 @@ After reading the diff, do the following:
3096
3096
  locations and recommend exactly one action—simplify/inline or introduce/extract a shared
3097
3097
  concept—only when it improves current code (avoid speculative refactors).
3098
3098
 
3099
- <constraints>
3099
+ Strongly prefer to restrict your use of git commands to these when getting the diff or determining which files were added/changed/removed:
3100
+ <referenceCommands>
3101
+ <command>
3102
+ <description>committed changes on my branch since diverging from the upstream default branch</description>
3103
+ <bash>git diff --merge-base origin/HEAD HEAD</bash>
3104
+ </command>
3105
+ <command>
3106
+ <description>all current checkout changes since diverging from upstream (commits + staged + unstaged tracked)</description>
3107
+ <bash>git diff --merge-base origin/HEAD</bash>
3108
+ </command>
3109
+ <command>
3110
+ <description>changes since diverging from upstream up to and including staged changes</description>
3111
+ <bash>git diff --cached --merge-base origin/HEAD</bash>
3112
+ </command>
3113
+ <command>
3114
+ <description>current checkout tracked changes since divergence, plus a list of newly added untracked files</description>
3115
+ <bash>git diff --merge-base origin/HEAD</bash>
3116
+ <bash>git ls-files --others --exclude-standard</bash>
3117
+ </command>
3118
+ <command>
3119
+ <description>changes on branch foo since divergence from upstream</description>
3120
+ <bash>git diff --merge-base origin/HEAD foo</bash>
3121
+ </command>
3122
+ <command>
3123
+ <description>only filenames changed by this branch since divergence</description>
3124
+ <bash>git diff --name-only --merge-base origin/HEAD HEAD</bash>
3125
+ </command>
3126
+ <command>
3127
+ <description>scope diff to a specific path since diverging from upstream</description>
3128
+ <bash>git diff --merge-base origin/HEAD <ref-or-empty> -- &lt;pathspec&gt;</bash>
3129
+ </command>
3130
+ </referenceCommands>
3131
+
3132
+ Avoid commands in this format, unless explicitly asked for:
3133
+ <avoidCommands>
3134
+ <avoidCommand>git diff <base-ref> <head-ref></avoidCommand>
3135
+ <avoidCommand>git diff <base-ref>..<head-ref></avoidCommand>
3136
+ <avoidCommand>git diff HEAD...origin/HEAD</avoidCommand>
3137
+ </avoidCommands>
3138
+
3139
+ <guidelines>
3100
3140
  - Persistence: Low. Do not retry failed tool calls more than 2 times. If a tool call fails twice, move on.
3101
- - Verbosity: Low. Do not narrate or explain your actions between tool calls. Only produce text for the final review output.
3141
+ - Remember to look at untracked added files.
3102
3142
  - Prefer the most direct path to completing the review. Batch related file reads into as few turns as possible.
3103
- - Do not re-read files you have already read unless the content may have changed.
3104
- </constraints>
3143
+ - Do not edit or modify files or run any commands that edit or modify files or git state.
3144
+ - Do not re-read files you have already read.
3145
+ - Upstream default branch ref: use origin/HEAD. Do not assume main, origin/main, or origin/master.
3146
+ - If a diff is unexpectedly large, double check you are using the right refs in git invocations.
3147
+ - If the diff has more than 100 changed files or is more than 10,000 lines long, abort the review and emit a single critical issue stating the diff is too large.
3148
+ </guidelines>
3105
3149
  `;function AF5(A){let Q=`
3106
3150
  Today's date: ${new Date().toDateString()}`;if(!A)return hk4+Q;return`${hk4}
3107
3151
  Current working directory (cwd): ${A}${Q}`}var QF5=`Emit your final report in the following format:
@@ -4596,12 +4640,12 @@ ${E}`))}},error:(K)=>{if(!U)U=!0,X(Error(`Failed to spawn brew: ${K.message}`))}
4596
4640
  ${E}`;if(Y==="pnpm"&&E.includes("Unable to find the global bin directory"))W+=`
4597
4641
 
4598
4642
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4599
- npm install -g @sourcegraph/amp`;X(Error(W))}},error:(K)=>{if(!V)V=!0,X(Error(`Failed to spawn ${Y}: ${K.message}`))},complete:()=>{if(!V)V=!0,F()}})})}l0();l0();EI();async function cU0(A,Q){let J=`${Q||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,Y=new AbortController,Z=setTimeout(()=>Y.abort(),5000);try{let F=await fetch(J,{signal:Y.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let X=await F.json(),D=X.version??X["dist-tags"]?.latest;if(!D)return{hasUpdate:!1,currentVersion:A,source:"npm"};let G=Be(A,D),V=G<0,U,K;if(X.time){let E=X.time[A],W=X.time[D],H=Date.now();if(E)U=Math.floor((H-new Date(E).getTime())/3600000);if(W)K=Math.floor((H-new Date(W).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:A,latestVersion:D,compareResult:G,hasUpdate:V,currentVersionAge:U,latestVersionAge:K}),{hasUpdate:V,latestVersion:D,currentVersion:A,currentVersionAge:U,latestVersionAge:K,source:"npm"}}catch(F){return T.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(Z)}}var Ei5="https://static.ampcode.com/cli/cli-version.txt";async function lU0(A){let Q=new AbortController,B=setTimeout(()=>Q.abort(),5000);try{let $=await fetch(`${Ei5}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!$.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=(await $.text()).trim();if(!J||!/^\d+\.\d+\.\d+/.test(J))return{hasUpdate:!1,currentVersion:A,source:"bin"};let Y=Be(A,J),Z=Y<0;return T.info("Bin version comparison",{currentVersion:A,latestVersion:J,compareResult:Y,hasUpdate:Z}),{hasUpdate:Z,latestVersion:J,currentVersion:A,source:"bin"}}catch($){return T.debug("Error checking bin version",{error:$}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout(B)}}var Wi5=604800000;function _s4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let B=Date.now()-Q;if(B>Wi5)return{ageMs:B};return null}function Be(A,Q){let B=(Z)=>{let[F,X]=Z.split("-");return{parts:F?.split(".").map(Number)||[],label:X}},$=B(A),J=B(Q),Y=Math.max($.parts.length,J.parts.length);for(let Z=0;Z<Y;Z++){let F=$.parts[Z]||0,X=J.parts[Z]||0;if(F<X)return-1;if(F>X)return 1}if($.label===J.label)return 0;if(!$.label&&J.label)return 1;if($.label&&!J.label)return-1;if($.label&&J.label)return $.label<J.label?-1:1;return 0}function w81(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let B=parseInt(Q[1],10)*1000,$=Q[2],J=B!==0?yU(B):void 0;return{sha:$,age:J}}catch{return null}}O1();l0();import{readFile as Hi5,realpath as zi5}from"node:fs/promises";import{homedir as qi5}from"node:os";import{dirname as Ts4,join as M81}from"node:path";async function Ss4(A){switch(A){case"binary":case"brew":return Ni5(tt());case"npm":case"pnpm":case"yarn":case"bun":return Ii5();case"bootstrap":return Ci5()}}async function Ni5(A){let Q=await PG(A,["--version"],5000);if(Q.reason!=="success")return T.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function Ii5(){try{let A=process.argv[1];if(!A)return null;let Q=await zi5(A),B=Ts4(Ts4(Q));return await ks4(M81(B,"package.json"))}catch(A){return T.debug("failed to read installed version from package.json",{error:A}),null}}async function Ci5(){try{let A=process.env.AMP_HOME??M81(qi5(),".amp");return await ks4(M81(A,"package","package.json"))}catch(A){return T.debug("failed to read installed version from bootstrap package.json",{error:A}),null}}async function ks4(A){let Q=await Hi5(A,"utf8"),B=JSON.parse(Q);if(B.name!=="@sourcegraph/amp")return T.debug("package.json name mismatch",{pkgJsonPath:A,name:B.name}),null;return B.version||null}var wi5=3600000,Mi5=5000;function L81(A,Q,B={}){let $=new WA,J=$.pipe(sA({shouldCountRefs:!1})),Y=B.startDelayMs??0,Z=B.checkIntervalMs??wi5,F=!1,X=()=>{F=!0};return setImmediate(async()=>{let D=new VD().scoped("update");if(Y>0){if(await vU(Y),F)return}let G=J.subscribe({next:(U)=>{D.debug("emit new state",U)}}),V=A;try{while(!F){let U=await Li5(V,Q,D,$);if(U.stop)return;if(U.updatedTo)V=U.updatedTo;if(U.emittedVisibleState){if(await vU(Mi5),F)return;$.next("hidden")}if(Z<=0)return;let K=1000,E=Z;while(E>0&&!F){let W=Math.min(K,E);await vU(W),E-=W}}}finally{G.unsubscribe(),$.complete()}}),{state:J,dispose:X}}async function Li5(A,Q,B,$){let J={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return B.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),J.stop=!0,J;let Y=await Q.get("updates.mode");if(Y==="disabled")return B.debug("checking disabled"),J.stop=!0,J;let Z=await pU0(),F=Z==="binary"||Z==="brew";B.debug("checking",{currentVersion:A,mode:Y,packageManager:Z,isBinaryDistribution:F});let X;if(F)X=await lU0(A);else{let V=await HP();X=await cU0(A,V)}if(!(X.latestVersion&&X.hasUpdate))return B.debug("no update available"),J;let D=(V)=>{$.next(V),J.emittedVisibleState=!0};if(Z){let V=await Ss4(Z);if(V&&Be(V,X.latestVersion)>=0){if(B.debug("on-disk version already up to date",{currentVersion:A,installedVersion:V,latestVersion:X.latestVersion}),J.updatedTo=V,Be(A,V)<0){let U=await xH(V),K={from:A,to:V,externallyUpdated:!0,...U};if(U.status==="same")B.info("on-disk already updated by another instance",K),D("updated");else B.warn("on-disk already updated by another instance, with PATH warning",K),D("updated-with-warning")}return J}}let G=()=>{if(X.currentVersionAge!==void 0&&X.latestVersionAge!==void 0){let V=X.currentVersionAge-X.latestVersionAge,U=0.5;if(Math.abs(V)<0.5)return B.debug("versions too close together, suppressing update warning",{currentVersionAge:X.currentVersionAge,latestVersionAge:X.latestVersionAge,ageDifferenceHours:V}),!0}return!1};if(!Y)Y=Z==="pnpm"?"warn":"auto",B.debug("no configured update mode; selected default based on package manager",{packageManager:Z,mode:Y});if(Z==="brew"){if(!G())D("update-available-brew");return J}if(Z==="binary"&&process.execPath!==tt()){if(B.debug("non-standard binary path, showing warning"),!G())D("update-available-unrecognized-path");return J}if(Y==="warn"){if(!G())D("update-available");return J}if(!Z){if(B.debug("auto-update not supported, falling back to warn mode"),!G())D("update-available");return J}if(Z==="binary"&&process.platform==="win32"){if(B.debug("binary auto-update not supported on Windows, falling back to warn mode"),!G())D("update-available");return J}try{await Qe(X.latestVersion,Z),J.updatedTo=X.latestVersion;let V=await xH(X.latestVersion),U={from:X.currentVersion,to:X.latestVersion,...V};if(V.status==="same")B.info("success",U),D("updated");else B.warn("success with warning",U),D("updated-with-warning")}catch(V){D("update-error")}return J}catch(Y){return B.debug("check failed",{error:Y}),J}}EI();import{stderr as _G}from"node:process";function vs4(A){let Q=new uI().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($)=>{await G81($.force||!1,$.verbose||!1,"0.0.1777072801-g023a81"),process.exit()});A.addCommand(Q,{hidden:!0});let B=new uI("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($)=>{await ji5($.targetVersion)});A.addCommand(B)}function Oi5(A){let Q=Boolean(A.isTTY),B=0,$=!1;function J(){if(!Q||!$)return;A.write(`
4643
+ npm install -g @sourcegraph/amp`;X(Error(W))}},error:(K)=>{if(!V)V=!0,X(Error(`Failed to spawn ${Y}: ${K.message}`))},complete:()=>{if(!V)V=!0,F()}})})}l0();l0();EI();async function cU0(A,Q){let J=`${Q||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,Y=new AbortController,Z=setTimeout(()=>Y.abort(),5000);try{let F=await fetch(J,{signal:Y.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let X=await F.json(),D=X.version??X["dist-tags"]?.latest;if(!D)return{hasUpdate:!1,currentVersion:A,source:"npm"};let G=Be(A,D),V=G<0,U,K;if(X.time){let E=X.time[A],W=X.time[D],H=Date.now();if(E)U=Math.floor((H-new Date(E).getTime())/3600000);if(W)K=Math.floor((H-new Date(W).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:A,latestVersion:D,compareResult:G,hasUpdate:V,currentVersionAge:U,latestVersionAge:K}),{hasUpdate:V,latestVersion:D,currentVersion:A,currentVersionAge:U,latestVersionAge:K,source:"npm"}}catch(F){return T.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(Z)}}var Ei5="https://static.ampcode.com/cli/cli-version.txt";async function lU0(A){let Q=new AbortController,B=setTimeout(()=>Q.abort(),5000);try{let $=await fetch(`${Ei5}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!$.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=(await $.text()).trim();if(!J||!/^\d+\.\d+\.\d+/.test(J))return{hasUpdate:!1,currentVersion:A,source:"bin"};let Y=Be(A,J),Z=Y<0;return T.info("Bin version comparison",{currentVersion:A,latestVersion:J,compareResult:Y,hasUpdate:Z}),{hasUpdate:Z,latestVersion:J,currentVersion:A,source:"bin"}}catch($){return T.debug("Error checking bin version",{error:$}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout(B)}}var Wi5=604800000;function _s4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let B=Date.now()-Q;if(B>Wi5)return{ageMs:B};return null}function Be(A,Q){let B=(Z)=>{let[F,X]=Z.split("-");return{parts:F?.split(".").map(Number)||[],label:X}},$=B(A),J=B(Q),Y=Math.max($.parts.length,J.parts.length);for(let Z=0;Z<Y;Z++){let F=$.parts[Z]||0,X=J.parts[Z]||0;if(F<X)return-1;if(F>X)return 1}if($.label===J.label)return 0;if(!$.label&&J.label)return 1;if($.label&&!J.label)return-1;if($.label&&J.label)return $.label<J.label?-1:1;return 0}function w81(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let B=parseInt(Q[1],10)*1000,$=Q[2],J=B!==0?yU(B):void 0;return{sha:$,age:J}}catch{return null}}O1();l0();import{readFile as Hi5,realpath as zi5}from"node:fs/promises";import{homedir as qi5}from"node:os";import{dirname as Ts4,join as M81}from"node:path";async function Ss4(A){switch(A){case"binary":case"brew":return Ni5(tt());case"npm":case"pnpm":case"yarn":case"bun":return Ii5();case"bootstrap":return Ci5()}}async function Ni5(A){let Q=await PG(A,["--version"],5000);if(Q.reason!=="success")return T.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function Ii5(){try{let A=process.argv[1];if(!A)return null;let Q=await zi5(A),B=Ts4(Ts4(Q));return await ks4(M81(B,"package.json"))}catch(A){return T.debug("failed to read installed version from package.json",{error:A}),null}}async function Ci5(){try{let A=process.env.AMP_HOME??M81(qi5(),".amp");return await ks4(M81(A,"package","package.json"))}catch(A){return T.debug("failed to read installed version from bootstrap package.json",{error:A}),null}}async function ks4(A){let Q=await Hi5(A,"utf8"),B=JSON.parse(Q);if(B.name!=="@sourcegraph/amp")return T.debug("package.json name mismatch",{pkgJsonPath:A,name:B.name}),null;return B.version||null}var wi5=3600000,Mi5=5000;function L81(A,Q,B={}){let $=new WA,J=$.pipe(sA({shouldCountRefs:!1})),Y=B.startDelayMs??0,Z=B.checkIntervalMs??wi5,F=!1,X=()=>{F=!0};return setImmediate(async()=>{let D=new VD().scoped("update");if(Y>0){if(await vU(Y),F)return}let G=J.subscribe({next:(U)=>{D.debug("emit new state",U)}}),V=A;try{while(!F){let U=await Li5(V,Q,D,$);if(U.stop)return;if(U.updatedTo)V=U.updatedTo;if(U.emittedVisibleState){if(await vU(Mi5),F)return;$.next("hidden")}if(Z<=0)return;let K=1000,E=Z;while(E>0&&!F){let W=Math.min(K,E);await vU(W),E-=W}}}finally{G.unsubscribe(),$.complete()}}),{state:J,dispose:X}}async function Li5(A,Q,B,$){let J={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return B.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),J.stop=!0,J;let Y=await Q.get("updates.mode");if(Y==="disabled")return B.debug("checking disabled"),J.stop=!0,J;let Z=await pU0(),F=Z==="binary"||Z==="brew";B.debug("checking",{currentVersion:A,mode:Y,packageManager:Z,isBinaryDistribution:F});let X;if(F)X=await lU0(A);else{let V=await HP();X=await cU0(A,V)}if(!(X.latestVersion&&X.hasUpdate))return B.debug("no update available"),J;let D=(V)=>{$.next(V),J.emittedVisibleState=!0};if(Z){let V=await Ss4(Z);if(V&&Be(V,X.latestVersion)>=0){if(B.debug("on-disk version already up to date",{currentVersion:A,installedVersion:V,latestVersion:X.latestVersion}),J.updatedTo=V,Be(A,V)<0){let U=await xH(V),K={from:A,to:V,externallyUpdated:!0,...U};if(U.status==="same")B.info("on-disk already updated by another instance",K),D("updated");else B.warn("on-disk already updated by another instance, with PATH warning",K),D("updated-with-warning")}return J}}let G=()=>{if(X.currentVersionAge!==void 0&&X.latestVersionAge!==void 0){let V=X.currentVersionAge-X.latestVersionAge,U=0.5;if(Math.abs(V)<0.5)return B.debug("versions too close together, suppressing update warning",{currentVersionAge:X.currentVersionAge,latestVersionAge:X.latestVersionAge,ageDifferenceHours:V}),!0}return!1};if(!Y)Y=Z==="pnpm"?"warn":"auto",B.debug("no configured update mode; selected default based on package manager",{packageManager:Z,mode:Y});if(Z==="brew"){if(!G())D("update-available-brew");return J}if(Z==="binary"&&process.execPath!==tt()){if(B.debug("non-standard binary path, showing warning"),!G())D("update-available-unrecognized-path");return J}if(Y==="warn"){if(!G())D("update-available");return J}if(!Z){if(B.debug("auto-update not supported, falling back to warn mode"),!G())D("update-available");return J}if(Z==="binary"&&process.platform==="win32"){if(B.debug("binary auto-update not supported on Windows, falling back to warn mode"),!G())D("update-available");return J}try{await Qe(X.latestVersion,Z),J.updatedTo=X.latestVersion;let V=await xH(X.latestVersion),U={from:X.currentVersion,to:X.latestVersion,...V};if(V.status==="same")B.info("success",U),D("updated");else B.warn("success with warning",U),D("updated-with-warning")}catch(V){D("update-error")}return J}catch(Y){return B.debug("check failed",{error:Y}),J}}EI();import{stderr as _G}from"node:process";function vs4(A){let Q=new uI().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($)=>{await G81($.force||!1,$.verbose||!1,"0.0.1777076476-ge780d5"),process.exit()});A.addCommand(Q,{hidden:!0});let B=new uI("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($)=>{await ji5($.targetVersion)});A.addCommand(B)}function Oi5(A){let Q=Boolean(A.isTTY),B=0,$=!1;function J(){if(!Q||!$)return;A.write(`
4600
4644
  `),$=!1,B=0}function Y(Z){if(!Q)return;let F=Z.padEnd(B," ");A.write(`\r${F}`),$=!0,B=F.length}return{flushProgressLine:J,renderProgress:Y}}async function ji5(A){let B=process.platform==="win32"&&WP()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:$,renderProgress:J}=Oi5(_G);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")_G.write(n0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4601
4645
 
4602
4646
  `));try{if(!A){_G.write(n0.blue(`Checking for updates...
4603
- `));let F=!1,X;if(WP()){let D=await lU0("0.0.1777072801-g023a81");F=D.hasUpdate,X=D.latestVersion}else{let D=await HP(),G=await cU0("0.0.1777072801-g023a81",D);F=G.hasUpdate,X=G.latestVersion}if(!F){let D=w81("0.0.1777072801-g023a81"),G=D?.age?`released ${D.age} ago`:`built ${yU(new Date("2026-04-24T23:23:49.258Z"))} ago`;_G.write(n0.green(`✓ Amp is already up to date on version ${"0.0.1777072801-g023a81"} (${G})
4604
- `));let V=await xH("0.0.1777072801-g023a81",B);if(V.warning)_G.write(`
4647
+ `));let F=!1,X;if(WP()){let D=await lU0("0.0.1777076476-ge780d5");F=D.hasUpdate,X=D.latestVersion}else{let D=await HP(),G=await cU0("0.0.1777076476-ge780d5",D);F=G.hasUpdate,X=G.latestVersion}if(!F){let D=w81("0.0.1777076476-ge780d5"),G=D?.age?`released ${D.age} ago`:`built ${yU(new Date("2026-04-25T00:25:11.684Z"))} ago`;_G.write(n0.green(`✓ Amp is already up to date on version ${"0.0.1777076476-ge780d5"} (${G})
4648
+ `));let V=await xH("0.0.1777076476-ge780d5",B);if(V.warning)_G.write(`
4605
4649
  `+n0.yellow(V.warning)+`
4606
4650
  `);process.exit(0)}if(!X)_G.write(n0.yellow("[WARN] could not find latest version")),process.exit(0);A=X}_G.write(n0.blue(`Updating to version ${A}...
4607
4651
  `)),await Qe(A,void 0,(F)=>{$(),_G.write(n0.dim(`Running: ${F}
@@ -5112,7 +5156,7 @@ Ctrl-X, Y, Z to unlock`;if(U){let x=D.text.replace(/`([^`]+)`/g,"$1")+`
5112
5156
 
5113
5157
  `,new h({color:$.toolSuccess,bold:!0})),new O(`This thread has been shared with Amp support for debugging and bug prioritization.
5114
5158
  `,new h({color:B.foreground})),new O(`This is not a support request.
5115
- `,new h({color:B.foreground,dim:!0})),new O("If you need a reply, post on X @AmpCode or email amp-devs@ampcode.com.",new h({color:B.foreground,dim:!0}))]),textAlign:"center"})})}}function W9A(A){return new D3({header:A.title,minWidth:80,maxWidth:80,chromePadding:M0.symmetric(1,0),footer:"none",onDismiss:A.onDismiss,child:A.child})}function y78(A,Q,B){return new p1({child:new u0({constraints:new W1(80,80,0,12),child:new eH({commandName:"Share with Support",title:"Share Thread with Support",placeholder:"What went wrong? (Need a reply? Email amp-devs@ampcode.com.)",isRequiredArg:!1,onSubmit:async($)=>{try{await A.shareThreadWithSupport(Q,$||void 0),B.pushResultPane(W9A({title:"Shared with Support",onDismiss:B.dismissFlow,child:new A10}))}catch(J){T.error("Failed to share thread with support",{error:J,threadID:Q}),B.pushResultPane(W9A({title:"Share with Support failed",onDismiss:B.dismissFlow,child:new t({text:new O(`Failed to share thread with support: ${J instanceof Error?J.message:String(J)}`)})}))}},onDismiss:B.dismissFlow})})})}function H9A(A,Q){return{noun:"thread",verb:"share with support",description:"Share with Amp support for debugging",get status(){return Q()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(B,$,J)=>{let Y=Q()?.client.getThreadId();if(!Y)return;B.push(y78(A,Y,{dismissFlow:J,pushResultPane:(Z)=>B.push(Z)}))}}}class Q10 extends y0{props;constructor(A){super();this.props=A}createState(){return new z9A}}class z9A extends v0{result=void 0;isLoading=!1;build(A){let Q=[];if(this.isLoading)Q.push(new fQ({message:"Updating visibility..."}));else if(this.result!==void 0)Q.push(new c7({message:this.result,onDismiss:()=>{this.widget.props.onDismiss()}}));else{let B=["private","workspace","unlisted","public"],$=this.widget.props.workspace?.groups&&this.widget.props.workspace.groups.length>0?["private","workspace","group","unlisted","public"]:B;Q.push(new k5({items:$,getLabel:(J)=>{switch(J){case"private":return"Private - Only you can see this thread";case"workspace":return"Workspace - Visible to workspace members";case"group":return"Group - Visible to group members";case"unlisted":return"Unlisted - Anyone with the link can view";case"public":return"Public - Searchable and on your public profile"}},title:"Select Thread Visibility",onAccept:async(J)=>{this.setState(()=>{this.isLoading=!0});let Y=await this.widget.props.execute(J);this.setState(()=>{this.isLoading=!1,this.result=Y})},onDismiss:this.widget.props.onDismiss}))}return new CA({children:Q,fit:"expand"})}}function x78(A,Q,B){return new p1({child:new u0({constraints:new W1(80,80,0,16),child:new Q10({workspace:null,threadID:Q,execute:($)=>A.setVisibility(Q,$),onDismiss:B})})})}function q9A(A,Q){return{noun:"thread",verb:"set visibility",description:"Set thread visibility",keywords:["share","private","workspace","public","unlisted","team","group"],get status(){return Q()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(B,$,J)=>{let Y=Q()?.client?.getThreadId();if(!Y)return;B.push(x78(A,Y,J))}}}class aQ1 extends y0{initialAgentMode;analyzeContextForThread;listSkillsForThread;threadContext;draftThreadSettings;editorController;history;updateDraftThreadSettings;onNewThread;shareThreadWithSupport;setThreadVisibility;archiveThread;addThreadLabel;removeThreadLabel;configService;connectionErrorMessage;hints;ideStatus;constructor(A){super();this.initialAgentMode=A.initialAgentMode,this.analyzeContextForThread=A.analyzeContextForThread,this.listSkillsForThread=A.listSkillsForThread,this.threadContext=A.threadContext,this.draftThreadSettings=A.draftThreadSettings,this.editorController=A.editorController,this.history=A.history,this.updateDraftThreadSettings=A.updateDraftThreadSettings,this.onNewThread=A.onNewThread,this.shareThreadWithSupport=A.shareThreadWithSupport,this.setThreadVisibility=A.setThreadVisibility,this.archiveThread=A.archiveThread,this.addThreadLabel=A.addThreadLabel,this.removeThreadLabel=A.removeThreadLabel,this.configService=A.configService,this.connectionErrorMessage=A.connectionErrorMessage,this.hints=A.hints,this.ideStatus=A.ideStatus}createState(){return new N9A}}class N9A extends v0{historyIndex=-1;historyDraft=null;promptHistoryPicker=new he(this);agentMode;expansion=new $Q1;previousThreadIDForReference=null;unregisterCommands=null;initState(){this.agentMode=this.widget.initialAgentMode,this.unregisterCommands=this.registerCommands()}didUpdateWidget(A){if(A.threadContext?.client!==this.widget.threadContext?.client)if(this.historyIndex=-1,this.historyDraft=null,!this.widget.threadContext)this.previousThreadIDForReference=A.threadContext?.client.getThreadId()??null;else this.previousThreadIDForReference=null}dispose(){this.unregisterCommands?.(),this.unregisterCommands=null}registerCommands(){let A=OX.of(this.context),Q=xQ.of(this.context),B=this,$=()=>{return B.widget.threadContext??null},J=()=>{let X=B.widget.threadContext?.client.getThreadId();if(!X)return null;return _Y(new URL(Q.ampURL),X).toString()},F=[...r$(void 0,{isInternalUser:Q.isInternalUser}).map(({mode:X})=>({noun:"mode",verb:`use ${X}`,description:`Enable ${X} mode`,get status(){if(B.widget.threadContext)return{type:"disabled",reason:"Mode can only be changed on a new thread"};if(X===B.agentMode)return{type:"disabled",reason:`Already using ${X} mode`};return{type:"enabled"}},run:(D,G,V)=>{B.setAgentMode(X),V()}})),{noun:"speed",verb:"toggle speed",description:"Toggle speed (fast/standard) for this thread",keywords:["anthropic","openai","fast","standard","smart","deep"],get status(){let X=B.currentCommandAgentMode();return X==="smart"||N3(X)?{type:"enabled"}:{type:"hidden"}},run:(X,D,G)=>{B.toggleSpeed(),G()}},{noun:"thread",verb:"toggle thinking blocks",description:"Expand or collapse all thinking blocks",keywords:["thinking","expand","collapse","reasoning"],shortcut:o1.alt("t"),status:{type:"enabled"},run:(X,D,G)=>{B.toggleGlobalThinking(),G()}},{noun:"mode",verb:"toggle deep effort",description:"Cycle deep reasoning effort (medium → high → xhigh)",keywords:["deep","thinking","reasoning","effort","depth"],shortcut:o1.alt("d"),get status(){return N3(B.currentCommandAgentMode())?{type:"enabled"}:{type:"hidden"}},run:(X,D,G)=>{B.toggleDeepReasoningEffort(),G()}},{noun:"prompt",verb:"history",description:"Restore a previous prompt",keywords:["recent","reuse","search"],shortcut:o1.ctrl("r"),status:{type:"enabled"},run:(X,D,G)=>{X.pushWithDismiss((V)=>new uW0({entries:this.widget.history.getAll(),currentCwd:nQ1.cwd(),onAccept:(U)=>{this.restorePromptHistory(U),G()},onDismiss:V}))}},{noun:"thread",verb:"copy ID",description:"Copy thread ID to clipboard",keywords:["identifier","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=$()?.client.getThreadId();if(!V)return;U6.maybeInvoke(D,new hG(V,"Thread ID copied to clipboard","Failed to copy thread ID")),G()}},{noun:"thread",verb:"copy URL",description:"Copy thread URL to clipboard",keywords:["link","share","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=J();if(!V)return;U6.maybeInvoke(D,new hG(V,"Thread URL copied to clipboard","Failed to copy thread URL")),G()}},{noun:"thread",verb:"copy markdown",description:"Copy thread as Markdown",keywords:["markdown","export","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=$()?.client.getThreadId();if(!V)return;(async()=>{try{let U=await Q.getThreadMarkdown(V);if(!U){fK.error(D,"Failed to copy thread markdown");return}U6.maybeInvoke(D,new hG(U,"Thread markdown copied to clipboard","Failed to copy thread markdown"))}catch(U){T.error("Failed to render thread markdown from Neo command palette",{error:U,threadID:V}),fK.error(D,"Failed to copy thread markdown")}finally{G()}})()}},{noun:"thread",verb:"analyze context",description:"Analyze context token usage",keywords:["tokens","usage","window","size","cost"],get status(){let X=B.widget.threadContext;if(!X)return{type:"disabled",reason:"No active thread"};let D=s$(X.observer.agentMode);if(!C3A.includes(D))return{type:"disabled",reason:"Context analysis requires Claude Opus 4.7 (smart) or GPT-5.4 (deep)"};return{type:"enabled"}},run:(X)=>{let D=$()?.client.getThreadId();if(!D)return;X.pushWithDismiss((G)=>{return new D3({header:"Context Usage Analysis",minWidth:60,maxWidth:60,chromePadding:M0.symmetric(1,0),footer:[{keys:["Esc"],label:"close"}],onDismiss:G,child:new d00({embedded:!0,contentWidth:58,thread:null,dtwAnalyze:(K)=>{return B.widget.analyzeContextForThread(D,K)},onDismiss:G})})})}},{noun:"skills",verb:"list",description:"List available skills for this thread",keywords:["agent","show"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X)=>{let D=$()?.client.getThreadId();if(!D)return;X.pushWithDismiss((G)=>new iQ1({listSkills:(V)=>B.widget.listSkillsForThread(D,V),onDismiss:G,cwd:Q.workspaceRoot}))}},{noun:"thread",verb:"new",description:"Start new thread",keywords:["create","start","reset","clear"],sortBoost:101,get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"Already on a new thread"}},run:(X,D)=>{U6.maybeInvoke(D,new f00)}},{noun:"thread",verb:"open in browser",description:"Open thread in browser",keywords:["web","view","launch"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(X,D,G)=>{let V=J();if(!V)return;try{await U5(D,V)}finally{G()}}},H9A({shareThreadWithSupport:(X,D)=>{return this.widget.shareThreadWithSupport(X,D)}},$),q9A({setVisibility:(X,D)=>this.widget.setThreadVisibility(X,D)},$),y2A({archiveThread:(X)=>this.widget.archiveThread(X)},$),E9A($),Q9A({configService:this.widget.configService,addLabel:(X,D)=>this.widget.addThreadLabel(X,D)},$),J9A({configService:this.widget.configService,removeLabel:(X,D)=>this.widget.removeThreadLabel(X,D)},$)].map((X)=>A.register(X));return()=>{for(let X of F)X()}}currentCommandAgentMode(){return this.widget.threadContext?.observer.agentMode??this.agentMode}updateThreadSettings(A){let Q=this.widget.threadContext;if(Q){let B=Q.observer.threadSettings().getValue()??{},$=A(B);return Q.client.sendClientUpdateThreadSettings($),this.widget.updateDraftThreadSettings(()=>$),"handled"}return this.widget.updateDraftThreadSettings(A),"handled"}toggleSpeed(){let A=this.currentCommandAgentMode();if(A==="smart")return this.updateThreadSettings((Q)=>{let B={...Q};if(B["anthropic.speed"]==="fast")delete B["anthropic.speed"];else B["anthropic.speed"]="fast";return B});if(N3(A))return this.updateThreadSettings((Q)=>{let B={...Q};if(B["openai.speed"]==="fast")B["openai.speed"]="standard";else B["openai.speed"]="fast";return B});return"ignored"}toggleGlobalThinking(){return this.expansion.toggle(),"handled"}toggleDeepReasoningEffort(){if(!N3(this.currentCommandAgentMode()))return"ignored";return this.updateThreadSettings((A)=>{let Q=sE(A);return{...A,"agent.deepReasoningEffort":Q==="medium"?"high":Q==="high"?"xhigh":"medium"}})}onPromptSubmitted=(A)=>{this.widget.history.add(A,nQ1.cwd()),this.resetHistory()};restorePromptHistory(A){this.resetHistory(),this.widget.editorController.text=A,this.widget.editorController.moveCursorToEnd()}handlePromptHistorySelection=(A)=>{this.promptHistoryPicker.disable(),this.restorePromptHistory(A)};navigateHistoryPrevious=()=>{let A=this.widget.history.previous();if(A!==null){if(this.historyIndex===-1)this.historyDraft=this.widget.editorController.text;this.historyIndex++,this.widget.editorController.text=A,this.widget.editorController.moveCursorToStart()}return"handled"};navigateHistoryNext=()=>{let A=this.widget.history.next();if(A!==null)this.historyIndex--,this.widget.editorController.text=A,this.widget.editorController.moveCursorToEnd();else if(this.historyIndex>-1)this.historyIndex=-1,this.widget.editorController.text=this.historyDraft||"",this.widget.editorController.moveCursorToEnd(),this.historyDraft=null;return"handled"};resetHistory(){this.widget.history.reset(),this.historyIndex=-1,this.historyDraft=null}setAgentMode(A){if(this.widget.threadContext)return;this.setState(()=>{this.agentMode=A}),NX((Q)=>({...Q,agentMode:A}))}buildActions(){let A=new y4(()=>{return this.promptHistoryPicker.enable(),"handled"}),Q=new y4(()=>{return this.navigateHistoryPrevious()}),B=new y4(()=>{return this.navigateHistoryNext()}),$=new y4((Z)=>{return this.setAgentMode(Z.mode),"handled"}),J=new y4(()=>{return this.toggleDeepReasoningEffort()}),Y=new y4(()=>{return this.toggleGlobalThinking()});return new Map([[gH,A],[NW0,B],[qW0,Q],[g00,$],[IW0,J],[HW0,Y]])}build(A){let Q=this.widget.threadContext,$=[Q?new mQ1({editorController:this.widget.editorController,observingClient:{client:Q.client,observer:Q.observer},hints:this.widget.hints,ideStatus:this.widget.ideStatus,onPromptSubmitted:this.onPromptSubmitted}):new lQ1({agentMode:this.agentMode,threadSettings:this.widget.draftThreadSettings,editorController:this.widget.editorController,onNewThread:this.widget.onNewThread,previousThreadIDForReference:this.previousThreadIDForReference,connectionErrorMessage:this.widget.connectionErrorMessage,hints:this.widget.hints,ideStatus:this.widget.ideStatus})];if(this.promptHistoryPicker.isEnabled())$.push(new uW0({entries:this.widget.history.getAll(),currentCwd:nQ1.cwd(),onAccept:this.handlePromptHistorySelection,onDismiss:this.promptHistoryPicker.disable}));let J=new Map([[o1.ctrl("r"),new gH],[o1.alt("d"),new IW0],[o1.alt("t"),new HW0]]);if(this.promptHistoryPicker.isEnabled())J.set(o1.ctrl("o"),new gH);else J.set(o1.ctrl("n"),new NW0),J.set(o1.ctrl("p"),new qW0);return new U6({actions:this.buildActions(),child:new a3({debugLabel:"NeoThreadShortcuts",shortcuts:J,child:new jX({controller:this.expansion,child:new CA({children:$})})})})}}class oQ1 extends y0{analyzeContextForThread;listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;initialThreadID;isFirstOpen;notificationService;onThreadArchived;initialUserInput;openThreadPickerOnStart;neoContext;constructor(A){super();this.analyzeContextForThread=A.analyzeContextForThread,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.initialThreadID=A.initialThreadID,this.isFirstOpen=A.isFirstOpen??!1,this.notificationService=A.notificationService,this.onThreadArchived=A.onThreadArchived,this.initialUserInput=A.initialUserInput,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.neoContext=A.neoContext}createState(){return new I9A}}class I9A extends v0{editorController=new I2;commandPalette=new he(this);commandRegistry=new i71;toastController=new h31;exitHintTimer=new ue(this,1000);connectionErrorMessage=new o3(this,null);ideStatus=new o3(this,{});draftThreadSettings={};draftThreadSettingsInitPromise=null;activeThreadContext=null;titleSubscription=null;ideErrorSubscription=null;connectingToThreadID=null;switchThreadPickerVisible=!1;firstOpenDialogVisible=!1;focusDebugVisible=!1;unregisterCommands=null;loadThreads=async()=>{return this.widget.neoContext.listThreads()};onSwitchThread=(A)=>{this.clearConnectionError(),this.connectToExistingThread(A)};shareThreadWithSupport=async(A,Q)=>{let B;if(this.activeThreadContext&&this.activeThreadContext.client.getThreadId()===A){let $=this.activeThreadContext.observer.activeError().getValue();if($)B={message:$.message,type:$.code,stack:$.stack,retryAfterSeconds:$.retryAt!==void 0?Math.max(0,Math.ceil(($.retryAt-Date.now())/1000)):void 0}}await g8A({configService:this.widget.configService},A,Q,B)};setThreadVisibility=(A,Q)=>{return m8A({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService},A,Q)};archiveThread=async(A)=>{let Q=await B1A({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let B=await $1A({configService:this.widget.configService},A,Q);if(B instanceof Error)return B;return this.toastController.show(B.message,B.type,2000),null};removeThreadLabel=async(A,Q)=>{let B=await J1A({configService:this.widget.configService},A,Q);if(B instanceof Error)return B;return this.toastController.show(B.message,B.type,2000),null};initState(){if(W$.getInstance().interceptConsole(),this.widget.isFirstOpen)this.firstOpenDialogVisible=!0;if(this.connectionErrorMessage.subscribe(this.widget.clientPool.connectionErrors$.pipe(aE(({threadID:Q,error:B})=>{T.error("Neo failed to connect to thread",{threadID:Q,error:B})}),N5(({threadID:Q})=>this.isConnectionErrorRelevant(Q)),aE(()=>this.clearActiveClientForConnectionError()),w1(({threadID:Q,error:B})=>{return Q?`Connection failed for ${Q}: ${B.message}`:`Connection failed: ${B.message}`}))),this.ideStatus.subscribe(this.widget.ideManager.status),this.ideErrorSubscription=this.widget.ideManager.errors$.subscribe((Q)=>{if(Q)this.setState(()=>{this.connectionErrorMessage.setValue(Q)})}),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput;if(this.widget.initialThreadID)this.connectToExistingThread(this.widget.initialThreadID,A);else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=i4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let Q=[{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["recent","history","open","resume","change"],status:{type:"enabled"},sortBoost:100,run:(B,$,J)=>{B.pushWithDismiss((Y)=>fQ1({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:Y,onThreadSelected:J}))}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",keywords:["servers","tools","plugins","integrations"],status:{type:"enabled"},run:(B)=>{B.pushWithDismiss(($)=>new BQ1({mcpServers:this.widget.neoContext.mcpServers,onDismiss:$}))}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config","preferences","edit"],status:{type:"enabled"},run:()=>{mJ(this.widget.neoContext.settingsFilePath).catch((B)=>{T.error("Failed to open settings file in editor",{error:B})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains","editor","attach"],status:{type:"enabled"},run:(B,$,J)=>{B.pushWithDismiss((Y)=>new AQ1({onCancel:Y,onSelect:(Z)=>{this.handleIdeSelection(Z),J()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["shortcuts","keybindings","docs","manual","?"],status:{type:"enabled"},run:(B,$)=>{B.pushWithDismiss((J)=>new s71({commands:OX.of($).commands,onDismiss:J}))}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["about","release","build"],status:{type:"enabled"},run:(B)=>{B.pushWithDismiss(($)=>new D3({header:"Amp Version",maxWidth:72,onDismiss:$,child:new t({text:new O(v31({version:"0.0.1777072801-g023a81",buildTimestamp:"2026-04-24T23:23:49.258Z",buildType:"'release'"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","leave","bye"],shortcut:o1.ctrl("c"),status:{type:"enabled"},run:(B,$)=>{U6.maybeInvoke($,new cu)}},...h8A(this.widget.neoContext.logFilePath)].map((B)=>this.commandRegistry.register(B));return()=>{for(let B of Q)B()}}build(A){let Q=this.buildHints(),B=this.connectionErrorMessage.getValue(),$=this.ideStatus.getValue(),J=new aQ1({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.widget.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,shareThreadWithSupport:this.shareThreadWithSupport,setThreadVisibility:this.setThreadVisibility,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,connectionErrorMessage:B,hints:Q,ideStatus:$}),Y=F4.of(A),F=[new u0({constraints:W1.tight(Y.size.width,Y.size.height),child:J})];if(this.commandPalette.isEnabled())F.push(new n71({onDismiss:this.commandPalette.disable}));if(this.switchThreadPickerVisible)F.push(fQ1({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.firstOpenDialogVisible)F.push(new t71({onDismiss:this.dismissFirstOpenDialog}));if(this.focusDebugVisible)F.push(new e71);return new xQ({neoContext:this.widget.neoContext,child:new OX({commandRegistry:this.commandRegistry,child:new Aw({completionBuilder:this.widget.completionBuilder,child:new fK({controller:this.toastController,child:new U6({actions:this.buildActions(),child:new a3({debugLabel:"NeoAppShortcuts",shortcuts:new Map([[o1.ctrl("c"),new EW0],[o1.ctrl("o"),new WW0],[o1.ctrl("t"),new zW0]]),child:new a4({debugLabel:"AppShellFocus",child:new g31({controller:this.toastController,child:new CA({children:F})})})})})})})})})}buildActions(){let A=new y4(()=>{return this.onExitPressed(),"handled"}),Q=new y4(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),B=new y4(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),$=new y4(()=>{return this.commandPalette.disable(),this.setState(()=>{this.titleSubscription?.unsubscribe(),this.titleSubscription=null,this.writeTerminalTitle(void 0),this.activeThreadContext=null,this.connectingToThreadID=null,this.connectionErrorMessage.setValue(null)}),"handled"}),J=new y4(()=>{return i4.instance.stop(),"handled"}),Y=new y4((F)=>{if(!F.text)return"ignored";return i4.instance.tuiInstance.clipboard.writeText(F.text).then(()=>{this.toastController.show(F.successMessage,"success",2000)}).catch((X)=>{T.error("Failed to copy Neo text to clipboard",{error:X}),this.toastController.show(F.failureMessage,"error",2000)}),"handled"}),Z=new y4(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[EW0,A],[f00,$],[cu,J],[hG,Y],[h00,B],[WW0,Q],[zW0,Z]])}ensureDraftThreadSettingsInitialized(){if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=await wK0(this.widget.configService);if(!this.mounted)return;this.setState(()=>{this.draftThreadSettings=A})}catch(A){T.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(mu);if(this.exitHintTimer.isActive())A.add(T00);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),i4.instance.stop();else this.exitHintTimer.activate()};dismissFirstOpenDialog=()=>{if(!this.firstOpenDialogVisible)return;this.setState(()=>{this.firstOpenDialogVisible=!1})};closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q)=>{await this.ensureDraftThreadSettingsInitialized();let B=A.find((J)=>J.type==="text");if(B&&B.type==="text")this.widget.history.add(B.text,hW0.cwd()),this.widget.history.reset();let $=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings);this.clearConnectionError(),this.sendUserMessage($,A,Q),this.setActiveClient($)};sendUserMessage(A,Q,B){A.observer.markMessageSent();let $=kX0(this.ideStatus.getValue());A.client.sendUserMessage(Q,B,{userState:$})}async connectToExistingThread(A,Q){this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A);if(this.setActiveClient(B),Q)this.sendUserMessage(B,[{type:"text",text:Q}])}catch(B){T.error("Failed to load thread",{error:B,threadID:A}),this.connectionErrorMessage.setValue(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`)}finally{this.setState(()=>{this.connectingToThreadID=null})}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q},this.connectionErrorMessage.setValue(null),this.subscribeTitleUpdates(Q),this.subscribeNotifications(Q)})}subscribeTitleUpdates(A){this.titleSubscription?.unsubscribe(),this.titleSubscription=A.title().subscribe({next:(Q)=>{this.writeTerminalTitle(Q)}})}subscribeNotifications(A){this.widget.notificationService.attach(A.agentState())}writeTerminalTitle(A){let Q=hW0.cwd().replace(hW0.env.HOME||"","~"),B=A?`amp - ${A} - ${Q}`:"";hW0.stdout.write(PC(B))}handleIdeSelection=async(A)=>{await this.widget.ideManager.connect(A)};dispose(){this.unregisterCommands?.(),this.unregisterCommands=null,this.titleSubscription?.unsubscribe(),this.ideErrorSubscription?.unsubscribe(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}isConnectionErrorRelevant(A){if(!this.activeThreadContext)return!0;if(!A)return!0;return this.activeThreadContext.client.getThreadId()===A}clearConnectionError(){if(!this.connectionErrorMessage.getValue())return;this.setState(()=>{this.connectionErrorMessage.setValue(null)})}clearActiveClientForConnectionError(){if(!this.activeThreadContext)return;this.setState(()=>{this.titleSubscription?.unsubscribe(),this.titleSubscription=null,this.widget.notificationService.detach(),this.writeTerminalTitle(void 0),this.activeThreadContext=null})}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.firstOpenDialogVisible}}e4();function C9A(A,Q,B,$){let J=pk(A),Y="\x1B[0m",Z="\x1B[34m",F="\x1B[90m",X="\x1B[2m",D=[];if(A.archived)D.push("\x1B[90m\x1B[2mArchived\x1B[0m");D.push(`${J}`),D.push(`\x1B[34m${Q}\x1B[0m`),D.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let G=14,V=7,U=new WZ(G,V),K=new gJ(42),E=new kC(G,V,G,V,G,V,0,A.agentMode??"smart","intensity",void 0,void 0,C0.default(),K);E.layout(W1.tight(G,V)),E.paint(U,0,0);let W=U.getBuffer().getCells(),H=0;for(let j=0;j<V;j++)if(W[j].some((P)=>P.char!==" ")){H=j;break}let z=V-1;for(let j=V-1;j>=0;j--)if(W[j].some((P)=>P.char!==" ")){z=j;break}function q(j,P){if(!j)return"";if(j.type==="rgb"){let{r:R,g:b,b:g}=j.value;if(B.getColorDepth()>=24)return`\x1B[${P?38:48};2;${R};${b};${g}m`;let f=IP(R,b,g);return`\x1B[${P?38:48};5;${f}m`}return""}let N=[];if(z>=H)for(let j=H;j<=z;j++){let P="";for(let R=0;R<G;R++){let b=W[j][R],g=b.char,f=q(b.style.fg,!0);P+=f+g+"\x1B[0m"}N.push(P)}let I=N.length,C=Math.max(I,D.length),w=Math.floor((C-I)/2),M=Math.floor((C-D.length)/2);for(let j=0;j<C;j++){let P=" ".repeat(G);if(j>=w&&j<w+I)P=N[j-w];let R=" ",b="";if(j>=M&&j<M+D.length)b=D[j-M];B.write(P+R+b+`
5159
+ `,new h({color:B.foreground,dim:!0})),new O("If you need a reply, post on X @AmpCode or email amp-devs@ampcode.com.",new h({color:B.foreground,dim:!0}))]),textAlign:"center"})})}}function W9A(A){return new D3({header:A.title,minWidth:80,maxWidth:80,chromePadding:M0.symmetric(1,0),footer:"none",onDismiss:A.onDismiss,child:A.child})}function y78(A,Q,B){return new p1({child:new u0({constraints:new W1(80,80,0,12),child:new eH({commandName:"Share with Support",title:"Share Thread with Support",placeholder:"What went wrong? (Need a reply? Email amp-devs@ampcode.com.)",isRequiredArg:!1,onSubmit:async($)=>{try{await A.shareThreadWithSupport(Q,$||void 0),B.pushResultPane(W9A({title:"Shared with Support",onDismiss:B.dismissFlow,child:new A10}))}catch(J){T.error("Failed to share thread with support",{error:J,threadID:Q}),B.pushResultPane(W9A({title:"Share with Support failed",onDismiss:B.dismissFlow,child:new t({text:new O(`Failed to share thread with support: ${J instanceof Error?J.message:String(J)}`)})}))}},onDismiss:B.dismissFlow})})})}function H9A(A,Q){return{noun:"thread",verb:"share with support",description:"Share with Amp support for debugging",get status(){return Q()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(B,$,J)=>{let Y=Q()?.client.getThreadId();if(!Y)return;B.push(y78(A,Y,{dismissFlow:J,pushResultPane:(Z)=>B.push(Z)}))}}}class Q10 extends y0{props;constructor(A){super();this.props=A}createState(){return new z9A}}class z9A extends v0{result=void 0;isLoading=!1;build(A){let Q=[];if(this.isLoading)Q.push(new fQ({message:"Updating visibility..."}));else if(this.result!==void 0)Q.push(new c7({message:this.result,onDismiss:()=>{this.widget.props.onDismiss()}}));else{let B=["private","workspace","unlisted","public"],$=this.widget.props.workspace?.groups&&this.widget.props.workspace.groups.length>0?["private","workspace","group","unlisted","public"]:B;Q.push(new k5({items:$,getLabel:(J)=>{switch(J){case"private":return"Private - Only you can see this thread";case"workspace":return"Workspace - Visible to workspace members";case"group":return"Group - Visible to group members";case"unlisted":return"Unlisted - Anyone with the link can view";case"public":return"Public - Searchable and on your public profile"}},title:"Select Thread Visibility",onAccept:async(J)=>{this.setState(()=>{this.isLoading=!0});let Y=await this.widget.props.execute(J);this.setState(()=>{this.isLoading=!1,this.result=Y})},onDismiss:this.widget.props.onDismiss}))}return new CA({children:Q,fit:"expand"})}}function x78(A,Q,B){return new p1({child:new u0({constraints:new W1(80,80,0,16),child:new Q10({workspace:null,threadID:Q,execute:($)=>A.setVisibility(Q,$),onDismiss:B})})})}function q9A(A,Q){return{noun:"thread",verb:"set visibility",description:"Set thread visibility",keywords:["share","private","workspace","public","unlisted","team","group"],get status(){return Q()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(B,$,J)=>{let Y=Q()?.client?.getThreadId();if(!Y)return;B.push(x78(A,Y,J))}}}class aQ1 extends y0{initialAgentMode;analyzeContextForThread;listSkillsForThread;threadContext;draftThreadSettings;editorController;history;updateDraftThreadSettings;onNewThread;shareThreadWithSupport;setThreadVisibility;archiveThread;addThreadLabel;removeThreadLabel;configService;connectionErrorMessage;hints;ideStatus;constructor(A){super();this.initialAgentMode=A.initialAgentMode,this.analyzeContextForThread=A.analyzeContextForThread,this.listSkillsForThread=A.listSkillsForThread,this.threadContext=A.threadContext,this.draftThreadSettings=A.draftThreadSettings,this.editorController=A.editorController,this.history=A.history,this.updateDraftThreadSettings=A.updateDraftThreadSettings,this.onNewThread=A.onNewThread,this.shareThreadWithSupport=A.shareThreadWithSupport,this.setThreadVisibility=A.setThreadVisibility,this.archiveThread=A.archiveThread,this.addThreadLabel=A.addThreadLabel,this.removeThreadLabel=A.removeThreadLabel,this.configService=A.configService,this.connectionErrorMessage=A.connectionErrorMessage,this.hints=A.hints,this.ideStatus=A.ideStatus}createState(){return new N9A}}class N9A extends v0{historyIndex=-1;historyDraft=null;promptHistoryPicker=new he(this);agentMode;expansion=new $Q1;previousThreadIDForReference=null;unregisterCommands=null;initState(){this.agentMode=this.widget.initialAgentMode,this.unregisterCommands=this.registerCommands()}didUpdateWidget(A){if(A.threadContext?.client!==this.widget.threadContext?.client)if(this.historyIndex=-1,this.historyDraft=null,!this.widget.threadContext)this.previousThreadIDForReference=A.threadContext?.client.getThreadId()??null;else this.previousThreadIDForReference=null}dispose(){this.unregisterCommands?.(),this.unregisterCommands=null}registerCommands(){let A=OX.of(this.context),Q=xQ.of(this.context),B=this,$=()=>{return B.widget.threadContext??null},J=()=>{let X=B.widget.threadContext?.client.getThreadId();if(!X)return null;return _Y(new URL(Q.ampURL),X).toString()},F=[...r$(void 0,{isInternalUser:Q.isInternalUser}).map(({mode:X})=>({noun:"mode",verb:`use ${X}`,description:`Enable ${X} mode`,get status(){if(B.widget.threadContext)return{type:"disabled",reason:"Mode can only be changed on a new thread"};if(X===B.agentMode)return{type:"disabled",reason:`Already using ${X} mode`};return{type:"enabled"}},run:(D,G,V)=>{B.setAgentMode(X),V()}})),{noun:"speed",verb:"toggle speed",description:"Toggle speed (fast/standard) for this thread",keywords:["anthropic","openai","fast","standard","smart","deep"],get status(){let X=B.currentCommandAgentMode();return X==="smart"||N3(X)?{type:"enabled"}:{type:"hidden"}},run:(X,D,G)=>{B.toggleSpeed(),G()}},{noun:"thread",verb:"toggle thinking blocks",description:"Expand or collapse all thinking blocks",keywords:["thinking","expand","collapse","reasoning"],shortcut:o1.alt("t"),status:{type:"enabled"},run:(X,D,G)=>{B.toggleGlobalThinking(),G()}},{noun:"mode",verb:"toggle deep effort",description:"Cycle deep reasoning effort (medium → high → xhigh)",keywords:["deep","thinking","reasoning","effort","depth"],shortcut:o1.alt("d"),get status(){return N3(B.currentCommandAgentMode())?{type:"enabled"}:{type:"hidden"}},run:(X,D,G)=>{B.toggleDeepReasoningEffort(),G()}},{noun:"prompt",verb:"history",description:"Restore a previous prompt",keywords:["recent","reuse","search"],shortcut:o1.ctrl("r"),status:{type:"enabled"},run:(X,D,G)=>{X.pushWithDismiss((V)=>new uW0({entries:this.widget.history.getAll(),currentCwd:nQ1.cwd(),onAccept:(U)=>{this.restorePromptHistory(U),G()},onDismiss:V}))}},{noun:"thread",verb:"copy ID",description:"Copy thread ID to clipboard",keywords:["identifier","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=$()?.client.getThreadId();if(!V)return;U6.maybeInvoke(D,new hG(V,"Thread ID copied to clipboard","Failed to copy thread ID")),G()}},{noun:"thread",verb:"copy URL",description:"Copy thread URL to clipboard",keywords:["link","share","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=J();if(!V)return;U6.maybeInvoke(D,new hG(V,"Thread URL copied to clipboard","Failed to copy thread URL")),G()}},{noun:"thread",verb:"copy markdown",description:"Copy thread as Markdown",keywords:["markdown","export","clipboard"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X,D,G)=>{let V=$()?.client.getThreadId();if(!V)return;(async()=>{try{let U=await Q.getThreadMarkdown(V);if(!U){fK.error(D,"Failed to copy thread markdown");return}U6.maybeInvoke(D,new hG(U,"Thread markdown copied to clipboard","Failed to copy thread markdown"))}catch(U){T.error("Failed to render thread markdown from Neo command palette",{error:U,threadID:V}),fK.error(D,"Failed to copy thread markdown")}finally{G()}})()}},{noun:"thread",verb:"analyze context",description:"Analyze context token usage",keywords:["tokens","usage","window","size","cost"],get status(){let X=B.widget.threadContext;if(!X)return{type:"disabled",reason:"No active thread"};let D=s$(X.observer.agentMode);if(!C3A.includes(D))return{type:"disabled",reason:"Context analysis requires Claude Opus 4.7 (smart) or GPT-5.4 (deep)"};return{type:"enabled"}},run:(X)=>{let D=$()?.client.getThreadId();if(!D)return;X.pushWithDismiss((G)=>{return new D3({header:"Context Usage Analysis",minWidth:60,maxWidth:60,chromePadding:M0.symmetric(1,0),footer:[{keys:["Esc"],label:"close"}],onDismiss:G,child:new d00({embedded:!0,contentWidth:58,thread:null,dtwAnalyze:(K)=>{return B.widget.analyzeContextForThread(D,K)},onDismiss:G})})})}},{noun:"skills",verb:"list",description:"List available skills for this thread",keywords:["agent","show"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:(X)=>{let D=$()?.client.getThreadId();if(!D)return;X.pushWithDismiss((G)=>new iQ1({listSkills:(V)=>B.widget.listSkillsForThread(D,V),onDismiss:G,cwd:Q.workspaceRoot}))}},{noun:"thread",verb:"new",description:"Start new thread",keywords:["create","start","reset","clear"],sortBoost:101,get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"Already on a new thread"}},run:(X,D)=>{U6.maybeInvoke(D,new f00)}},{noun:"thread",verb:"open in browser",description:"Open thread in browser",keywords:["web","view","launch"],get status(){return B.widget.threadContext?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(X,D,G)=>{let V=J();if(!V)return;try{await U5(D,V)}finally{G()}}},H9A({shareThreadWithSupport:(X,D)=>{return this.widget.shareThreadWithSupport(X,D)}},$),q9A({setVisibility:(X,D)=>this.widget.setThreadVisibility(X,D)},$),y2A({archiveThread:(X)=>this.widget.archiveThread(X)},$),E9A($),Q9A({configService:this.widget.configService,addLabel:(X,D)=>this.widget.addThreadLabel(X,D)},$),J9A({configService:this.widget.configService,removeLabel:(X,D)=>this.widget.removeThreadLabel(X,D)},$)].map((X)=>A.register(X));return()=>{for(let X of F)X()}}currentCommandAgentMode(){return this.widget.threadContext?.observer.agentMode??this.agentMode}updateThreadSettings(A){let Q=this.widget.threadContext;if(Q){let B=Q.observer.threadSettings().getValue()??{},$=A(B);return Q.client.sendClientUpdateThreadSettings($),this.widget.updateDraftThreadSettings(()=>$),"handled"}return this.widget.updateDraftThreadSettings(A),"handled"}toggleSpeed(){let A=this.currentCommandAgentMode();if(A==="smart")return this.updateThreadSettings((Q)=>{let B={...Q};if(B["anthropic.speed"]==="fast")delete B["anthropic.speed"];else B["anthropic.speed"]="fast";return B});if(N3(A))return this.updateThreadSettings((Q)=>{let B={...Q};if(B["openai.speed"]==="fast")B["openai.speed"]="standard";else B["openai.speed"]="fast";return B});return"ignored"}toggleGlobalThinking(){return this.expansion.toggle(),"handled"}toggleDeepReasoningEffort(){if(!N3(this.currentCommandAgentMode()))return"ignored";return this.updateThreadSettings((A)=>{let Q=sE(A);return{...A,"agent.deepReasoningEffort":Q==="medium"?"high":Q==="high"?"xhigh":"medium"}})}onPromptSubmitted=(A)=>{this.widget.history.add(A,nQ1.cwd()),this.resetHistory()};restorePromptHistory(A){this.resetHistory(),this.widget.editorController.text=A,this.widget.editorController.moveCursorToEnd()}handlePromptHistorySelection=(A)=>{this.promptHistoryPicker.disable(),this.restorePromptHistory(A)};navigateHistoryPrevious=()=>{let A=this.widget.history.previous();if(A!==null){if(this.historyIndex===-1)this.historyDraft=this.widget.editorController.text;this.historyIndex++,this.widget.editorController.text=A,this.widget.editorController.moveCursorToStart()}return"handled"};navigateHistoryNext=()=>{let A=this.widget.history.next();if(A!==null)this.historyIndex--,this.widget.editorController.text=A,this.widget.editorController.moveCursorToEnd();else if(this.historyIndex>-1)this.historyIndex=-1,this.widget.editorController.text=this.historyDraft||"",this.widget.editorController.moveCursorToEnd(),this.historyDraft=null;return"handled"};resetHistory(){this.widget.history.reset(),this.historyIndex=-1,this.historyDraft=null}setAgentMode(A){if(this.widget.threadContext)return;this.setState(()=>{this.agentMode=A}),NX((Q)=>({...Q,agentMode:A}))}buildActions(){let A=new y4(()=>{return this.promptHistoryPicker.enable(),"handled"}),Q=new y4(()=>{return this.navigateHistoryPrevious()}),B=new y4(()=>{return this.navigateHistoryNext()}),$=new y4((Z)=>{return this.setAgentMode(Z.mode),"handled"}),J=new y4(()=>{return this.toggleDeepReasoningEffort()}),Y=new y4(()=>{return this.toggleGlobalThinking()});return new Map([[gH,A],[NW0,B],[qW0,Q],[g00,$],[IW0,J],[HW0,Y]])}build(A){let Q=this.widget.threadContext,$=[Q?new mQ1({editorController:this.widget.editorController,observingClient:{client:Q.client,observer:Q.observer},hints:this.widget.hints,ideStatus:this.widget.ideStatus,onPromptSubmitted:this.onPromptSubmitted}):new lQ1({agentMode:this.agentMode,threadSettings:this.widget.draftThreadSettings,editorController:this.widget.editorController,onNewThread:this.widget.onNewThread,previousThreadIDForReference:this.previousThreadIDForReference,connectionErrorMessage:this.widget.connectionErrorMessage,hints:this.widget.hints,ideStatus:this.widget.ideStatus})];if(this.promptHistoryPicker.isEnabled())$.push(new uW0({entries:this.widget.history.getAll(),currentCwd:nQ1.cwd(),onAccept:this.handlePromptHistorySelection,onDismiss:this.promptHistoryPicker.disable}));let J=new Map([[o1.ctrl("r"),new gH],[o1.alt("d"),new IW0],[o1.alt("t"),new HW0]]);if(this.promptHistoryPicker.isEnabled())J.set(o1.ctrl("o"),new gH);else J.set(o1.ctrl("n"),new NW0),J.set(o1.ctrl("p"),new qW0);return new U6({actions:this.buildActions(),child:new a3({debugLabel:"NeoThreadShortcuts",shortcuts:J,child:new jX({controller:this.expansion,child:new CA({children:$})})})})}}class oQ1 extends y0{analyzeContextForThread;listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;initialThreadID;isFirstOpen;notificationService;onThreadArchived;initialUserInput;openThreadPickerOnStart;neoContext;constructor(A){super();this.analyzeContextForThread=A.analyzeContextForThread,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.initialThreadID=A.initialThreadID,this.isFirstOpen=A.isFirstOpen??!1,this.notificationService=A.notificationService,this.onThreadArchived=A.onThreadArchived,this.initialUserInput=A.initialUserInput,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.neoContext=A.neoContext}createState(){return new I9A}}class I9A extends v0{editorController=new I2;commandPalette=new he(this);commandRegistry=new i71;toastController=new h31;exitHintTimer=new ue(this,1000);connectionErrorMessage=new o3(this,null);ideStatus=new o3(this,{});draftThreadSettings={};draftThreadSettingsInitPromise=null;activeThreadContext=null;titleSubscription=null;ideErrorSubscription=null;connectingToThreadID=null;switchThreadPickerVisible=!1;firstOpenDialogVisible=!1;focusDebugVisible=!1;unregisterCommands=null;loadThreads=async()=>{return this.widget.neoContext.listThreads()};onSwitchThread=(A)=>{this.clearConnectionError(),this.connectToExistingThread(A)};shareThreadWithSupport=async(A,Q)=>{let B;if(this.activeThreadContext&&this.activeThreadContext.client.getThreadId()===A){let $=this.activeThreadContext.observer.activeError().getValue();if($)B={message:$.message,type:$.code,stack:$.stack,retryAfterSeconds:$.retryAt!==void 0?Math.max(0,Math.ceil(($.retryAt-Date.now())/1000)):void 0}}await g8A({configService:this.widget.configService},A,Q,B)};setThreadVisibility=(A,Q)=>{return m8A({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService},A,Q)};archiveThread=async(A)=>{let Q=await B1A({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let B=await $1A({configService:this.widget.configService},A,Q);if(B instanceof Error)return B;return this.toastController.show(B.message,B.type,2000),null};removeThreadLabel=async(A,Q)=>{let B=await J1A({configService:this.widget.configService},A,Q);if(B instanceof Error)return B;return this.toastController.show(B.message,B.type,2000),null};initState(){if(W$.getInstance().interceptConsole(),this.widget.isFirstOpen)this.firstOpenDialogVisible=!0;if(this.connectionErrorMessage.subscribe(this.widget.clientPool.connectionErrors$.pipe(aE(({threadID:Q,error:B})=>{T.error("Neo failed to connect to thread",{threadID:Q,error:B})}),N5(({threadID:Q})=>this.isConnectionErrorRelevant(Q)),aE(()=>this.clearActiveClientForConnectionError()),w1(({threadID:Q,error:B})=>{return Q?`Connection failed for ${Q}: ${B.message}`:`Connection failed: ${B.message}`}))),this.ideStatus.subscribe(this.widget.ideManager.status),this.ideErrorSubscription=this.widget.ideManager.errors$.subscribe((Q)=>{if(Q)this.setState(()=>{this.connectionErrorMessage.setValue(Q)})}),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput;if(this.widget.initialThreadID)this.connectToExistingThread(this.widget.initialThreadID,A);else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=i4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let Q=[{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["recent","history","open","resume","change"],status:{type:"enabled"},sortBoost:100,run:(B,$,J)=>{B.pushWithDismiss((Y)=>fQ1({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:Y,onThreadSelected:J}))}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",keywords:["servers","tools","plugins","integrations"],status:{type:"enabled"},run:(B)=>{B.pushWithDismiss(($)=>new BQ1({mcpServers:this.widget.neoContext.mcpServers,onDismiss:$}))}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config","preferences","edit"],status:{type:"enabled"},run:()=>{mJ(this.widget.neoContext.settingsFilePath).catch((B)=>{T.error("Failed to open settings file in editor",{error:B})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains","editor","attach"],status:{type:"enabled"},run:(B,$,J)=>{B.pushWithDismiss((Y)=>new AQ1({onCancel:Y,onSelect:(Z)=>{this.handleIdeSelection(Z),J()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["shortcuts","keybindings","docs","manual","?"],status:{type:"enabled"},run:(B,$)=>{B.pushWithDismiss((J)=>new s71({commands:OX.of($).commands,onDismiss:J}))}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["about","release","build"],status:{type:"enabled"},run:(B)=>{B.pushWithDismiss(($)=>new D3({header:"Amp Version",maxWidth:72,onDismiss:$,child:new t({text:new O(v31({version:"0.0.1777076476-ge780d5",buildTimestamp:"2026-04-25T00:25:11.684Z",buildType:"'release'"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","leave","bye"],shortcut:o1.ctrl("c"),status:{type:"enabled"},run:(B,$)=>{U6.maybeInvoke($,new cu)}},...h8A(this.widget.neoContext.logFilePath)].map((B)=>this.commandRegistry.register(B));return()=>{for(let B of Q)B()}}build(A){let Q=this.buildHints(),B=this.connectionErrorMessage.getValue(),$=this.ideStatus.getValue(),J=new aQ1({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.widget.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,shareThreadWithSupport:this.shareThreadWithSupport,setThreadVisibility:this.setThreadVisibility,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,connectionErrorMessage:B,hints:Q,ideStatus:$}),Y=F4.of(A),F=[new u0({constraints:W1.tight(Y.size.width,Y.size.height),child:J})];if(this.commandPalette.isEnabled())F.push(new n71({onDismiss:this.commandPalette.disable}));if(this.switchThreadPickerVisible)F.push(fQ1({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.firstOpenDialogVisible)F.push(new t71({onDismiss:this.dismissFirstOpenDialog}));if(this.focusDebugVisible)F.push(new e71);return new xQ({neoContext:this.widget.neoContext,child:new OX({commandRegistry:this.commandRegistry,child:new Aw({completionBuilder:this.widget.completionBuilder,child:new fK({controller:this.toastController,child:new U6({actions:this.buildActions(),child:new a3({debugLabel:"NeoAppShortcuts",shortcuts:new Map([[o1.ctrl("c"),new EW0],[o1.ctrl("o"),new WW0],[o1.ctrl("t"),new zW0]]),child:new a4({debugLabel:"AppShellFocus",child:new g31({controller:this.toastController,child:new CA({children:F})})})})})})})})})}buildActions(){let A=new y4(()=>{return this.onExitPressed(),"handled"}),Q=new y4(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),B=new y4(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),$=new y4(()=>{return this.commandPalette.disable(),this.setState(()=>{this.titleSubscription?.unsubscribe(),this.titleSubscription=null,this.writeTerminalTitle(void 0),this.activeThreadContext=null,this.connectingToThreadID=null,this.connectionErrorMessage.setValue(null)}),"handled"}),J=new y4(()=>{return i4.instance.stop(),"handled"}),Y=new y4((F)=>{if(!F.text)return"ignored";return i4.instance.tuiInstance.clipboard.writeText(F.text).then(()=>{this.toastController.show(F.successMessage,"success",2000)}).catch((X)=>{T.error("Failed to copy Neo text to clipboard",{error:X}),this.toastController.show(F.failureMessage,"error",2000)}),"handled"}),Z=new y4(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[EW0,A],[f00,$],[cu,J],[hG,Y],[h00,B],[WW0,Q],[zW0,Z]])}ensureDraftThreadSettingsInitialized(){if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=await wK0(this.widget.configService);if(!this.mounted)return;this.setState(()=>{this.draftThreadSettings=A})}catch(A){T.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(mu);if(this.exitHintTimer.isActive())A.add(T00);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),i4.instance.stop();else this.exitHintTimer.activate()};dismissFirstOpenDialog=()=>{if(!this.firstOpenDialogVisible)return;this.setState(()=>{this.firstOpenDialogVisible=!1})};closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q)=>{await this.ensureDraftThreadSettingsInitialized();let B=A.find((J)=>J.type==="text");if(B&&B.type==="text")this.widget.history.add(B.text,hW0.cwd()),this.widget.history.reset();let $=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings);this.clearConnectionError(),this.sendUserMessage($,A,Q),this.setActiveClient($)};sendUserMessage(A,Q,B){A.observer.markMessageSent();let $=kX0(this.ideStatus.getValue());A.client.sendUserMessage(Q,B,{userState:$})}async connectToExistingThread(A,Q){this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A);if(this.setActiveClient(B),Q)this.sendUserMessage(B,[{type:"text",text:Q}])}catch(B){T.error("Failed to load thread",{error:B,threadID:A}),this.connectionErrorMessage.setValue(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`)}finally{this.setState(()=>{this.connectingToThreadID=null})}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q},this.connectionErrorMessage.setValue(null),this.subscribeTitleUpdates(Q),this.subscribeNotifications(Q)})}subscribeTitleUpdates(A){this.titleSubscription?.unsubscribe(),this.titleSubscription=A.title().subscribe({next:(Q)=>{this.writeTerminalTitle(Q)}})}subscribeNotifications(A){this.widget.notificationService.attach(A.agentState())}writeTerminalTitle(A){let Q=hW0.cwd().replace(hW0.env.HOME||"","~"),B=A?`amp - ${A} - ${Q}`:"";hW0.stdout.write(PC(B))}handleIdeSelection=async(A)=>{await this.widget.ideManager.connect(A)};dispose(){this.unregisterCommands?.(),this.unregisterCommands=null,this.titleSubscription?.unsubscribe(),this.ideErrorSubscription?.unsubscribe(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}isConnectionErrorRelevant(A){if(!this.activeThreadContext)return!0;if(!A)return!0;return this.activeThreadContext.client.getThreadId()===A}clearConnectionError(){if(!this.connectionErrorMessage.getValue())return;this.setState(()=>{this.connectionErrorMessage.setValue(null)})}clearActiveClientForConnectionError(){if(!this.activeThreadContext)return;this.setState(()=>{this.titleSubscription?.unsubscribe(),this.titleSubscription=null,this.widget.notificationService.detach(),this.writeTerminalTitle(void 0),this.activeThreadContext=null})}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.firstOpenDialogVisible}}e4();function C9A(A,Q,B,$){let J=pk(A),Y="\x1B[0m",Z="\x1B[34m",F="\x1B[90m",X="\x1B[2m",D=[];if(A.archived)D.push("\x1B[90m\x1B[2mArchived\x1B[0m");D.push(`${J}`),D.push(`\x1B[34m${Q}\x1B[0m`),D.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let G=14,V=7,U=new WZ(G,V),K=new gJ(42),E=new kC(G,V,G,V,G,V,0,A.agentMode??"smart","intensity",void 0,void 0,C0.default(),K);E.layout(W1.tight(G,V)),E.paint(U,0,0);let W=U.getBuffer().getCells(),H=0;for(let j=0;j<V;j++)if(W[j].some((P)=>P.char!==" ")){H=j;break}let z=V-1;for(let j=V-1;j>=0;j--)if(W[j].some((P)=>P.char!==" ")){z=j;break}function q(j,P){if(!j)return"";if(j.type==="rgb"){let{r:R,g:b,b:g}=j.value;if(B.getColorDepth()>=24)return`\x1B[${P?38:48};2;${R};${b};${g}m`;let f=IP(R,b,g);return`\x1B[${P?38:48};5;${f}m`}return""}let N=[];if(z>=H)for(let j=H;j<=z;j++){let P="";for(let R=0;R<G;R++){let b=W[j][R],g=b.char,f=q(b.style.fg,!0);P+=f+g+"\x1B[0m"}N.push(P)}let I=N.length,C=Math.max(I,D.length),w=Math.floor((C-I)/2),M=Math.floor((C-D.length)/2);for(let j=0;j<C;j++){let P=" ".repeat(G);if(j>=w&&j<w+I)P=N[j-w];let R=" ",b="";if(j>=M&&j<M+D.length)b=D[j-M];B.write(P+R+b+`
5116
5160
  `)}if($)B.write(`
5117
5161
  \x1B[90m${$}\x1B[0m
5118
5162
  `)}l0();bK0();var f78=2000;function w9A(A){let Q=!0,B=!0,$=A.configService.config.subscribe((V)=>{Q=V.settings["notifications.enabled"]??!0,B=V.settings["notifications.system.enabled"]!==!1}),J=0,Y=(V)=>{if(!Q)return;let U=Date.now();if(U-J<f78)return;if(J=U,_P())return;if(kU0())vU0();else pr(V)},Z=(V)=>{if(!Q||!B)return;if(_P()&&!Se()&&!QK0())return;process.stdout.write(SG(`\x1B]777;notify;Amp;${V}\x1B\\`))},F=null,X=null,D=()=>{F?.unsubscribe(),F=null,X=null};return{attach:(V)=>{D(),F=V.subscribe({next:(U)=>{try{let K=X!==null&&NC(X),E=X==="awaiting_approval";if(U==="awaiting_approval"&&!E)Y("requires-user-input"),Z("Waiting for approval");else if((U==="idle"||U==="error")&&(K||E))Y("idle"),Z("Agent is ready")}catch(K){T.debug("Neo notification handling failed",{error:K})}finally{X=U}},error:(U)=>{T.debug("Neo notification agent state stream errored",{error:U})}})},detach:D,unsubscribe(){D(),$.unsubscribe()}}}l0();JW();z4();O1();function M9A(A,Q){if(!Q)return A;let B=Q.toLowerCase(),$=[];for(let J of A){let Y=b78(J,B);if(Y>0)$.push({...J,score:Y})}return $.sort((J,Y)=>{let Z=Y.score-J.score;if(Z!==0)return Z;return A.indexOf(J)-A.indexOf(Y)}),$}function b78(A,Q){let B=u78(A,Q),$=h78(A.message.toLowerCase(),Q);return Math.max(B,$)}function u78(A,Q){let B=A.hash.toLowerCase(),$=A.shortHash.toLowerCase();if($===Q)return 1000;if($.startsWith(Q))return 900;if(B.startsWith(Q))return 850;if(B.includes(Q)||$.includes(Q))return 400;return 0}function h78(A,Q){if(A===Q)return 800;if(A.startsWith(Q))return 700;let B=A.indexOf(Q);if(B!==-1)return 600-Math.min(B,500);let $=g78(A,Q);if($>0)return $;return 0}function g78(A,Q){let B=0,$=0,J=-1;while(B<A.length&&$<Q.length){if(A[B]===Q[$]){if(J===-1)J=B;$++}B++}if($===Q.length)return 250-Math.min(J,150);return 0}var L9A=":";function U_(A,Q){if(!UP())return;T.debug("[file mention completions]",{event:A,...Q})}function tu(A){return A.length<=80?A:`${A.slice(0,77)}...`}class K_{fuzzyClient;cachedDirtyFiles=[];cachedCommits=[];refreshPromise;refreshCommitsPromise;constructor(A){this.fuzzyClient=A;this.refreshDirtyFilesInBackground(),this.refreshCommitsInBackground()}async buildOptions(A){if(A.trigger==="@"){let Q=A.query;if(Q.toLowerCase().startsWith(L9A)){let Z=Q.slice(L9A.length);return U_("commit_query_detected",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:Z.length,queryPreview:tu(Z)}),this.buildCommitOptions(Z)}let $=Q.length===0?18:20,J=await this.buildFileOptions(Q,$),Y=this.appendHintOptions(Q,J);return U_("build_options_completed",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:Q.length,queryPreview:tu(Q),maxResults:$,fileOptionCount:J.filter((Z)=>Z.type==="file").length,hintOptionCount:Y.filter((Z)=>Z.type==="hint").length,finalOptionCount:Y.length,firstFilePaths:Y.filter((Z)=>Z.type==="file").slice(0,5).map((Z)=>Z.path)}),Y}return[]}async buildFileOptions(A,Q){try{let B=await this.getOpenFiles(),$=this.cachedDirtyFiles;this.refreshDirtyFilesInBackground();let J=await this.fuzzyClient.queryCompletions(A,Q,B,$),Y=J.map((Z)=>J2A(Z));return U_("file_options_built",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:A.length,queryPreview:tu(A),maxResults:Q,openFilesCount:B?.length??0,dirtyFilesCount:$.length,completionItemCount:J.length,fileOptionCount:Y.length,firstPaths:Y.slice(0,5).map((Z)=>Z.path)}),Y}catch(B){return U_("file_options_failed",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:A.length,queryPreview:tu(A),maxResults:Q,error:B instanceof Error?B.message:String(B)}),[]}}async getOpenFiles(){let A=await k1(i8.status);if(!A.connected)return;let Q=[];if(A.openFile)Q.push(Z1.parse(A.openFile).fsPath);if(A.visibleFiles)for(let B of A.visibleFiles){let $=Z1.parse(B).fsPath;if(!Q.includes($))Q.push($)}if(Q.length===0)return;return Q}refreshDirtyFilesInBackground(){if(this.refreshPromise!==void 0)return;this.refreshPromise=Ik4(this.fuzzyClient.workspaceRoot).then((A)=>{this.cachedDirtyFiles=A}).catch(()=>{}).finally(()=>{this.refreshPromise=void 0})}async buildCommitOptions(A){this.refreshCommitsInBackground();let Q=this.cachedCommits;if(!Q.length)return U_("commit_options_empty_cache",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:A.length,queryPreview:tu(A)}),[];let B=M9A(Q,A).slice(0,20);return U_("commit_options_built",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:A.length,queryPreview:tu(A),commitCacheCount:Q.length,resultCount:B.length,firstCommitHashes:B.slice(0,5).map(($)=>$.shortHash)}),B.map(($)=>({type:"commit",hash:$.hash,shortHash:$.shortHash,message:$.message,relativeDate:$.relativeDate}))}refreshCommitsInBackground(){if(this.refreshCommitsPromise!==void 0)return;this.refreshCommitsPromise=Ck4(this.fuzzyClient.workspaceRoot).then((A)=>{this.cachedCommits=A}).catch(()=>{}).finally(()=>{this.refreshCommitsPromise=void 0})}appendHintOptions(A,Q){if(A.length>0)return Q;let B=[{type:"hint",kind:"commit",message:"mention a commit"},{type:"hint",kind:"thread",message:"mention a thread"}];return U_("hint_options_appended",{workspaceRoot:this.fuzzyClient.workspaceRoot,queryLength:A.length,fileOptionCount:Q.filter(($)=>$.type==="file").length,hintOptionCount:B.length,hintOnly:Q.length===0,firstFilePaths:Q.filter(($)=>$.type==="file").slice(0,5).map(($)=>$.path)}),[...Q,...B]}}var p78=[{long:"neo",description:"Use the Neo TUI",type:"boolean",default:!1},{long:"url",short:"u",description:"Amp server URL",type:"string",default:""},{long:"dangerously-allow-all",description:"Disable all command confirmation prompts (agent will execute all commands without asking)",type:"boolean",default:!1}],Fh2=S0A({name:"amp neo",description:"Start the Neo TUI",options:p78,positionals:[],action:async({options:A})=>rQ1(O9A(A)),subcommands:[{name:"threads",alias:"t",description:"List and manage threads",options:[],positionals:[],subcommands:[{name:"continue",alias:"c",description:"Continue an existing thread",options:[],positionals:[{name:"thread-id",description:"Thread ID to continue"}],action:async({globalOptions:A,positionals:Q})=>{let $=O9A(A);if(!Q["thread-id"]){await rQ1($,{openThreadPickerOnStart:!0});return}let J=Z2(Q["thread-id"]);if(!J)throw"invalid thread ID";await rQ1($,{initialThreadID:J})}}]}]});function d78(A){if(A)return A;if(process.env.AMP_URL)return process.env.AMP_URL;return T9}function c78(A){if(process.env.RIVET_PUBLIC_ENDPOINT)return process.env.RIVET_PUBLIC_ENDPOINT;return xJ(A)}var j9A=Z1.file(m78.homedir()),l78=process.env.XDG_CONFIG_HOME?Z1.file(process.env.XDG_CONFIG_HOME):G1.joinPath(j9A,".config");async function i78(A){await NX((Q)=>PK0(Q,A,"interactive"))}function O9A(A){return{url:A.url,dangerouslyAllowAll:A["dangerously-allow-all"]}}async function rQ1(A,Q={}){let{initialThreadID:B,openThreadPickerOnStart:$=!1}=Q,J=d78(A.url),Y={dataDir:void 0,getHook:(N,I)=>{if(N==="url")return Promise.resolve(J);return I()}},Z=await uU0(Y),F=RK0(await lt(Y,Z)),X=c78(J);if(A.dangerouslyAllowAll)ZQ("dangerouslyAllowAll",!0);let D=await F.get("apiKey",J);if(!D)throw new K4("API key required. Please run `amp login` first.",1);let G=bk({storage:Z,secretStorage:F,workspaceRoot:g0.of(Z1.file(process.cwd())),defaultAmpURL:J,homeDir:j9A,userConfigDir:l78}),V=lO(G),U=ED0({configService:G}),K=i$0({configService:G,filesystem:k8}),E={registerToolsWithToolService:()=>({dispose:()=>{}}),getClient:()=>{return},servers:g0.of([]),getPrompt:async()=>null,searchResources:async()=>[],searchPrompts:()=>g0.of([]),getToolsForServer:async()=>{return}},W=process.cwd(),H=async({uri:N})=>{return IC({fileSystem:k8,workspaceRoot:W},N)},z=new ob(W,{},!0),q=new K_(z);await sQ1({ampURL:J,apiKey:D,rivetEndpoint:X,configService:G,toolService:U.toolService,skillService:K,mcpService:E,readFileSystemDirectory:H,completionBuilder:q,workspaceRoot:W,listThreads:()=>V.listThreads(),getThreadFromServer:(N)=>V.getThread(N),isInternalUser:!1,settingsFilePath:Z.getSettingsFilePath(),dispose:()=>{z.dispose(),U.dispose()}},{initialThreadID:B,openThreadPickerOnStart:$})}async function sQ1(A,Q={}){let{initialThreadID:B,initialUserInput:$,openThreadPickerOnStart:J=!1}=Q,Y=async(W)=>{let H=await A.getThreadFromServer(W);if(!H)return null;return HU0(H)},Z=new G31(A.rivetEndpoint,A.apiKey,A.configService,{clientID:HC.parse(`neo-${crypto.randomUUID()}`),toolService:A.toolService,skillService:A.skillService,invokeTool:async(W,H)=>{let z=typeof H.args==="object"&&H.args!==null?H.args:{},q=await PK({toolName:H.toolName,configService:A.configService,toolService:A.toolService,mcpService:A.mcpService,skillService:A.skillService,toolUseID:H.toolCallId,threadID:W});return A.toolService.invokeTool(H.toolName,{args:z},q)},persistLastThreadID:i78,readFileSystemDirectory:A.readFileSystemDirectory},Y),F=await Zu(),X={ampURL:A.ampURL,configService:A.configService,getThreadMarkdown:async(W)=>{let H=await A.getThreadFromServer(W);return H?UU(H):null},isInternalUser:A.isInternalUser,listThreads:A.listThreads,logFilePath:jt,mcpServers:A.mcpService.servers,sessionAgentMode:F.agentMode,settingsFilePath:A.settingsFilePath,workspaceRoot:A.workspaceRoot},D=(W,H)=>{return Lb({ampURL:A.ampURL,configService:A.configService,threadID:W,signal:H})},G=(W,H)=>{return be4({ampURL:A.ampURL,configService:A.configService,threadID:W,signal:H})},V=new k31,U=pe4(F);NX(de4);let K=w9A({configService:A.configService}),E=new Set;try{await ke(new oQ1({clientPool:Z,analyzeContextForThread:D,listSkillsForThread:G,completionBuilder:A.completionBuilder,history:new ft,ideManager:V,configService:A.configService,initialThreadID:B,notificationService:K,initialUserInput:$,openThreadPickerOnStart:J,neoContext:X,isFirstOpen:U,onThreadArchived:(H)=>{E.add(H)}}));let W=Z.lastActiveObservingClient;if(W){let{client:H,observer:z}=W,q=H.getThreadId();if(q){let N={id:q,title:z.title().getValue(),agentMode:z.agentMode,archived:E.has(q)},I=`${A.ampURL.replace(/\/$/,"")}/threads/${q}`;C9A(N,I,process.stdout)}}}finally{process.stdout.write(PC("")),K.unsubscribe(),Z.dispose(),await A.dispose?.()}process.exit(0)}Ul();mL();async function n78(A,Q,B){let $=T70(A);if(!$.success)throw Error(`Invalid permission format: ${$.error.message}`);if($.data.length===0)throw Error("No permission entry provided");let J=fq($.data);if(!J.success){let X=J.error.issues.map((D)=>D.message).join(", ");throw Error(`Invalid permission entry: ${X}`)}let Y=await Q.get("permissions",B)??[],F=[$.data[0],...Y];await Q.set("permissions",F,B)}async function R9A(A){try{let Q=A.args.map((B)=>{if(/[\s/\\*?[\]{}()"]/.test(B))return`"${B}"`;return B}).join(" ");await n78(Q,A.settings,A.scope),A.exit(0)}catch(Q){let B=Q instanceof Error?Q.message:"Unknown error";A.stderr.write(`Error: ${B}
@@ -5194,24 +5238,84 @@ Interrupted
5194
5238
  `)}if(U.stop(),E){let q=W?`${n0.dim(`(${W.map((N)=>`git ${N.join(" ")}`).join("; ")})`)}
5195
5239
  `:"";Q.write(`${n0.bold("Summary")} ${q}${E}
5196
5240
 
5197
- `)}if(B.summaryOnly)return;let H=$.createStatusLine(Q);H.update(n0.dim(B.checksOnly?"Running checks...":"Reviewing..."));let z=await(async()=>{try{let{threadID:q,worker:N}=await E9.createThread(Z,{newThreadID:K,agentMode:"smart",initialUserMessage:KQ8({diffDescription:B.diffDescription,files:V,instructions:B.instructions,checkScope:B.checkScope,checkFilter:B.checkFilter,checksOnly:B.checksOnly,thinking:B.thinking})}),I=await EQ8(N,Z,q),C=WQ8(I);if(!C){let w=HQ8(I);if(w)throw Error(w);let M=zQ8(I);if(M)throw Error(M);throw Error("Smart mode review completed without a code_review tool result")}return $.extractReviewOutput(C,B)}finally{H.stop()}})();$.writeReviewOutput(Q,z,G)}var h9A=[["diff","HEAD"],["ls-files","--others","--exclude-standard"]],CQ8="git diff HEAD and newly added untracked files";async function m9A(A,Q,B){let Y=(await(await A$({configService:Q},AbortSignal.timeout(30000))).messages.create({model:HU,max_tokens:2000,temperature:0,system:`You generate git diff commands that show the actual diff content. Output commands in XML format: <command>git diff ...</command>
5241
+ `)}if(B.summaryOnly)return;let H=$.createStatusLine(Q);H.update(n0.dim(B.checksOnly?"Running checks...":"Reviewing..."));let z=await(async()=>{try{let{threadID:q,worker:N}=await E9.createThread(Z,{newThreadID:K,agentMode:"smart",initialUserMessage:KQ8({diffDescription:B.diffDescription,files:V,instructions:B.instructions,checkScope:B.checkScope,checkFilter:B.checkFilter,checksOnly:B.checksOnly,thinking:B.thinking})}),I=await EQ8(N,Z,q),C=WQ8(I);if(!C){let w=HQ8(I);if(w)throw Error(w);let M=zQ8(I);if(M)throw Error(M);throw Error("Smart mode review completed without a code_review tool result")}return $.extractReviewOutput(C,B)}finally{H.stop()}})();$.writeReviewOutput(Q,z,G)}var h9A=[["diff","HEAD"],["ls-files","--others","--exclude-standard"]],CQ8="git diff HEAD and newly added untracked files";async function m9A(A,Q,B){let Y=(await(await A$({configService:Q},AbortSignal.timeout(30000))).messages.create({model:HU,max_tokens:2000,temperature:0,system:`You generate git diff commands that show the actual diff content. Output commands in XML format:
5242
+ <command>git command 1</command>
5243
+ <command>git command 2</command>
5198
5244
 
5199
- The commands should use "git diff" to show the full diff output. You may output multiple commands if needed.
5245
+ The commands should use \`git diff\`, \`git ls-files\`, or \`git status\` commands to show the full diff output. Output multiple commands if needed.
5200
5246
 
5201
5247
  Output only standalone git commands that can be executed with execFile argument arrays.
5202
5248
  Do not use shell syntax: no $(...), backticks, pipes, &&, ||, semicolons, or redirection.
5203
5249
  Prefer native git range syntax instead of shell substitution.
5250
+ In <descriptions>, list alternate description phrases on separate lines.
5204
5251
 
5205
5252
  Examples:
5206
- - "since merge base" → <command>git diff --merge-base origin/HEAD</command>
5207
- - "changes since merge base" → <command>git diff --merge-base origin/HEAD</command>
5208
- - "changes since merge base with origin/main" → <command>git diff --merge-base origin/main</command>
5209
- - "diff from main" → <command>git diff main</command>
5210
- - "uncommitted changes" <command>git diff HEAD</command>
5211
- - "changes in last commit" → <command>git diff HEAD~1</command>
5212
- - "changes between v1.0 and v2.0" → <command>git diff v1.0..v2.0</command>
5213
- - "staged changes" → <command>git diff --cached</command>
5214
- - "all uncommitted including untracked" → <command>git diff HEAD</command><command>git ls-files --others --exclude-standard</command>
5253
+ <example>
5254
+ <descriptions>
5255
+ since merge base
5256
+ since upstream
5257
+ changes since merge base
5258
+ changes since merge-base with origin
5259
+ all changes on this branch
5260
+ </descriptions>
5261
+ <expectedOutput>
5262
+ <command>git diff --merge-base origin/HEAD</command>
5263
+ <command>git ls-files --others --exclude-standard</command>
5264
+ </expectedOutput>
5265
+ </example>
5266
+ <example>
5267
+ <descriptions>
5268
+ changes since merge base with $REF
5269
+ since diverging from $REF
5270
+ since $REF
5271
+ </descriptions>
5272
+ <expectedOutput>
5273
+ <command>git diff --merge-base $REF</command>
5274
+ </expectedOutput>
5275
+ </example>
5276
+ <example>
5277
+ <descriptions>
5278
+ uncommitted changes
5279
+ show uncommitted tracked changes
5280
+ </descriptions>
5281
+ <expectedOutput>
5282
+ <command>git diff HEAD</command>
5283
+ </expectedOutput>
5284
+ </example>
5285
+ <example>
5286
+ <descriptions>
5287
+ changes in last commit
5288
+ show changes introduced by the last commit
5289
+ </descriptions>
5290
+ <expectedOutput>
5291
+ <command>git diff HEAD~1</command>
5292
+ </expectedOutput>
5293
+ </example>
5294
+ <example>
5295
+ <descriptions>
5296
+ changes since $MY_REF diverged from $OTHER_REF
5297
+ </descriptions>
5298
+ <expectedOutput>
5299
+ <command>git diff --merge-base $OTHER_REF $MY_REF</command>
5300
+ </expectedOutput>
5301
+ </example>
5302
+ <example>
5303
+ <descriptions>
5304
+ staged changes
5305
+ show staged changes only
5306
+ </descriptions>
5307
+ <expectedOutput>
5308
+ <command>git diff --cached</command>
5309
+ </expectedOutput>
5310
+ </example>
5311
+ <example>
5312
+ <descriptions>
5313
+ newly added files
5314
+ </descriptions>
5315
+ <expectedOutput>
5316
+ <command>git ls-files --others --exclude-standard</command>
5317
+ </expectedOutput>
5318
+ </example>
5215
5319
 
5216
5320
  Output only the command tags, no explanation.`,messages:[{role:"user",content:A}]},B?{headers:X2({id:B})}:void 0)).content.find((X)=>X.type==="text");if(!Y||Y.type!=="text")return h9A;let Z=bI(Y.text,"command"),F=jt0(Z);return F.length>0?F:h9A}function wQ8(A){let Q=A?.join(" ").trim();return Q&&Q.length>0?Q:CQ8}function MQ8(A){if(A==="low"||A==="high")return A;throw new K4(`Invalid thinking level "${A}". Expected "low" or "high".`,1)}function LQ8(A,Q){return A.argument("[diff_description...]","Description of the diff or changes to review (default: uncommitted changes)").option("-f, --files <files...>","Specific files to focus the review on").option("-i, --instructions <text>","Additional instructions to guide the review").option("-s, --check-scope <dir>","Directory to search for checks").option("-c, --check-filter <checks...>","Specific check names to run").option("--checks-only","Only run checks, skip the main review agent").option("--summary-only","Only generate and print the diff summary, skip full review").option("--thinking <level>",'Thinking level: "low" (default) or "high"',MQ8).addHelpText("after",`
5217
5321
  The diff_description tells the tool what changes to review. It can be:
@@ -5837,7 +5941,7 @@ ${J}`,Q);this.line=B,this.column=$,this.codeblock=J}}/*!
5837
5941
  `),Y=[];for(let Z=0;Z<J.length;Z++){let D=J[Z].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 G of D)if(G.startsWith("\x00")&&G.endsWith("\x01"))Y.push(new O(G.slice(1,-1),new h({color:$.app.keybind,bold:!0})));else Y.push(new O(G,new h({color:B.colorScheme.foreground})));if(Z<J.length-1)Y.push(new O(`
5838
5942
  `))}return new u0({decoration:{color:B.colorScheme.background,border:Q4.all(new e1($.app.keybind,1,"rounded"))},child:new x0({padding:M0.symmetric(0,1),child:new t({text:new O(void 0,void 0,Y)})})})}}class U$1 extends n2{chartData;highlightIndex;showAxes;colors;constructor({key:A,chartData:Q,highlightIndex:B=null,showAxes:$=!0,colors:J=Dz0}){super(A?{key:A}:{});this.chartData=Q,this.highlightIndex=B,this.showAxes=$,this.colors=J}createRenderObject(){return new G$1({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 Q$A(A,Q,B,$,J,Y,Z){if(Y<=0)return null;switch(A){case"horizontal-bar":{let F=B;return F>=0&&F<Y?F:null}case"bar":case"stacked-bar":{let F=Z?e3:0,X=$-F;if(X<=0)return null;let D=Q-F;if(D<0||D>=X)return null;let G=Math.max(1,Math.floor(X/Y)),V=Math.floor(D/G);return V>=0&&V<Y?V:null}case"line":case"sparkline":case"stacked-area":{let F=Z?e3:0,X=$-F;if(X<=0)return null;let D=Math.max(0,Math.min(X-1,Q-F));if(Y===1)return 0;let G=X/(Y-1),V=Math.round(D/G);return Math.max(0,Math.min(Y-1,V))}default:return null}}function eF8(A,Q,B,$,J,Y,Z,F){if(J<=0||Q<0||Q>=J)return null;let X=2;switch(A){case"horizontal-bar":return{x:Math.floor(B/2),y:Q};case"bar":case"stacked-bar":{let D=Y?e3:0,G=B-D,V=$-(Y?X:0);if(G<=0||V<=0)return null;let U=Math.max(1,Math.floor(G/J)),K=D+Q*U+Math.floor(U/2),E=F>0?Z/F:0,W=Math.round((1-E)*(V-1));return{x:K,y:W}}case"line":case"sparkline":case"stacked-area":{let D=Y?e3:0,G=B-D,V=$-(Y?X:0);if(G<=0||V<=0)return null;let U=J>1?D+Math.round(Q/(J-1)*(G-1)):D+Math.floor(G/2),K=F>0?Z/F:0,E=Math.round((1-K)*(V-1));return{x:U,y:E}}default:return null}}function AX8(A){let Q=0;for(let B of A)for(let $ of B.points)if($.value>Q)Q=$.value;return Q||1}function QX8(A,Q,B,$,J){if(B.length<=1){let F=$(A.value),X=A.meta?` (${A.meta})`:"";return A.label.length+2+F.length+X.length}let Y=A.label.length,Z=0;for(let F of B){let X=F.points[Q];if(!X)continue;Z+=X.value;let D=2+F.name.length+2+$(X.value).length;Y=Math.max(Y,D)}if(J){let F=9+$(Z).length;Y=Math.max(Y,F)}return Y}function BX8(A,Q,B,$,J,Y,Z){let F;try{let E=S1.of(A),W=S0.of(A);F={foreground:E.colorScheme.foreground,background:E.colorScheme.background,border:W.app.keybind}}catch{F={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let X=new h({color:F.foreground,bold:!0}),D=new h({color:F.foreground}),G=new h({color:F.foreground,dim:!0}),V=[],U=new h({color:F.foreground,underline:!0}),K=(E,W)=>new O(W,U,void 0,tU0(E),()=>{U5(A,E)});if($.length<=1){if(V.push(new O(`${Q.label}: `,X)),Q.link)V.push(K(Q.link,Y(Q.value)));else V.push(new O(Y(Q.value),D));if(Q.meta)V.push(new O(` (${Q.meta})`,G))}else{let E=Z==="stacked-bar"||Z==="stacked-area";V.push(new O(`${Q.label}
5839
5943
  `,X));let W=0;for(let H=0;H<$.length;H++){let z=$[H],q=z.points[B];if(!q)continue;W+=q.value;let N=z.color??J[H%J.length]??F.foreground;if(V.push(new O("● ",new h({color:N}))),V.push(new O(`${z.name}: `,G)),q.link)V.push(K(q.link,Y(q.value)));else V.push(new O(Y(q.value),D));if(H<$.length-1||E)V.push(new O(`
5840
- `))}if(E)V.push(new O(" ",G)),V.push(new O("Total: ",G)),V.push(new O(Y(W),D))}return new u0({decoration:{color:F.background,border:Q4.all(new e1(F.border,1,"rounded"))},child:new t({text:new O(void 0,void 0,V)})})}l0();c8();lL();k9();C8();E7();vo();KF();KQ();EQ();aB();GR();e4();wy();zk();O1();l0();KQ();class K$1{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,B])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1777072801-g023a81"},parameters:{metadata:{count:B}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await j70(Q,this.configService)}catch(Q){T.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 ww extends y0{props;constructor(A){super();this.props=A}createState(){return new B$A}}class B$A extends v0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=(B)=>{this.setState(()=>{this._state=B(this._state)})};return this.widget.props.builder(A,Q,this._state)}}aB();class $$A extends v0{controller=new I2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new K6({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>=TY)return!1;let Q=await RX(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=S0.of(A),{colors:B,app:$}=Q,Y=F4.of(A).size.height,Z=Math.max(Math.floor(Y*0.5),10),F=new mG({controller:this.controller,triggers:[new iJ],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(K)=>{this.widget.props.onSubmit(K.trim(),this.imageAttachments)},theme:B,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:i4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),X=new a4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),D=new u0({constraints:new W1({maxHeight:Z}),padding:M0.symmetric(1,0),child:X}),G=new u0({padding:M0.symmetric(1,0),child:new t({text:new O("",void 0,[new O("Command: ",new h({color:B.foreground})),new O(this.widget.props.commandName,new h({color:$.command,bold:!0}))])})}),V=new u0({padding:M0.symmetric(1,0),child:new t({text:this.isConfirmingClearInput?new O("",void 0,[new O("Esc",new h({color:$.keybind})),new O(" again to clear input",new h({color:B.foreground,dim:!0}))]):new O("",void 0,[new O("Press ",new h({color:B.foreground,dim:!0})),new O("Enter",new h({color:$.keybind})),new O(" to submit, ",new h({color:B.foreground,dim:!0})),new O("Esc",new h({color:$.keybind})),new O(" to clear",new h({color:B.foreground,dim:!0}))])})}),U=[G,new j0({height:1}),new y1({child:D}),new j0({height:1}),V];return new u0({decoration:{border:Q4.all(new e1(B.foreground,1,"solid")),color:B.background},padding:M0.all(1),child:new m0({children:U})})}}class E$1 extends y0{props;constructor(A){super();this.props=A}createState(){return new $$A}}function J$A(A){let B=new Date().getTime()-A.getTime(),$=Math.floor(B/60000),J=Math.floor(B/3600000),Y=Math.floor(B/86400000);if($<1)return"just now";if($<60)return`${$}m ago`;if(J<24)return`${J}h ago`;if(Y<7)return`${Y}d ago`;return A.toLocaleDateString()}class W$1 extends T1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((J,Y)=>Y.pubDate.getTime()-J.pubDate.getTime()),B=Math.max(0,...Q.map((J)=>J$A(J.pubDate).length));return new k5({items:Q,getLabel:(J)=>J.title,onAccept:(J)=>this.props.onSelect?.(J),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(J,Y,Z,F)=>{let X=S0.of(F),{colors:D}=X,G=X.app,V=Y?G.selectionBackground:void 0,U=Y?G.selectionForeground:D.foreground,K=D.mutedForeground,E=(W,H)=>new j0({width:H,child:F1.end([new t({text:new O(W,new h({color:K}))})])});return new u0({decoration:V?{color:V}:void 0,padding:M0.symmetric(2,0),child:new F1({children:[new y1({child:new t({text:new O(J.title,new h({color:U})),overflow:"ellipsis",maxLines:1})}),new j0({width:2}),E(J$A(J.pubDate),B)]})})}})}}class TB{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!TB._instance)TB._instance=new TB;return TB._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()}}c8();class Y$A extends y0{props;constructor(A){super();this.props=A}createState(){return new Z$A}}class Z$A extends v0{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=A.startsWith("file://")?A.slice(7):A,B=this.widget.props.cwd;if(Q.startsWith(B))return Q.slice(B.length+1);return Q}statusIcon(A){let Q=r3.default(),{colors:B,app:$}=Q;switch(A){case"loading":return{icon:"◌",color:B.warning};case"active":return{icon:"✓",color:$.toolSuccess};case"error":return{icon:"✗",color:$.toolError}}}build(A){let Q=S0.of(A),{app:B}=Q;if(this.plugins.length===0)return new t({text:new O("No plugins found.",new h({dim:!0}))});let $=[],J=this.plugins.length,Y=this.plugins.filter((X)=>X.status==="active").length,Z=this.plugins.reduce((X,D)=>X+D.registeredCommands.length,0),F=this.plugins.reduce((X,D)=>X+D.registeredTools.length,0);if($.push(new O(`${Y}/${J} ${w4(J,"plugin")} active`,new h({bold:!0}))),Z>0||F>0)$.push(new O(` (${Z} ${w4(Z,"command")}, ${F} ${w4(F,"tool")})`,new h({dim:!0})));$.push(new O(`
5944
+ `))}if(E)V.push(new O(" ",G)),V.push(new O("Total: ",G)),V.push(new O(Y(W),D))}return new u0({decoration:{color:F.background,border:Q4.all(new e1(F.border,1,"rounded"))},child:new t({text:new O(void 0,void 0,V)})})}l0();c8();lL();k9();C8();E7();vo();KF();KQ();EQ();aB();GR();e4();wy();zk();O1();l0();KQ();class K$1{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,B])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1777076476-ge780d5"},parameters:{metadata:{count:B}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await j70(Q,this.configService)}catch(Q){T.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 ww extends y0{props;constructor(A){super();this.props=A}createState(){return new B$A}}class B$A extends v0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=(B)=>{this.setState(()=>{this._state=B(this._state)})};return this.widget.props.builder(A,Q,this._state)}}aB();class $$A extends v0{controller=new I2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new K6({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>=TY)return!1;let Q=await RX(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=S0.of(A),{colors:B,app:$}=Q,Y=F4.of(A).size.height,Z=Math.max(Math.floor(Y*0.5),10),F=new mG({controller:this.controller,triggers:[new iJ],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(K)=>{this.widget.props.onSubmit(K.trim(),this.imageAttachments)},theme:B,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:i4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),X=new a4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),D=new u0({constraints:new W1({maxHeight:Z}),padding:M0.symmetric(1,0),child:X}),G=new u0({padding:M0.symmetric(1,0),child:new t({text:new O("",void 0,[new O("Command: ",new h({color:B.foreground})),new O(this.widget.props.commandName,new h({color:$.command,bold:!0}))])})}),V=new u0({padding:M0.symmetric(1,0),child:new t({text:this.isConfirmingClearInput?new O("",void 0,[new O("Esc",new h({color:$.keybind})),new O(" again to clear input",new h({color:B.foreground,dim:!0}))]):new O("",void 0,[new O("Press ",new h({color:B.foreground,dim:!0})),new O("Enter",new h({color:$.keybind})),new O(" to submit, ",new h({color:B.foreground,dim:!0})),new O("Esc",new h({color:$.keybind})),new O(" to clear",new h({color:B.foreground,dim:!0}))])})}),U=[G,new j0({height:1}),new y1({child:D}),new j0({height:1}),V];return new u0({decoration:{border:Q4.all(new e1(B.foreground,1,"solid")),color:B.background},padding:M0.all(1),child:new m0({children:U})})}}class E$1 extends y0{props;constructor(A){super();this.props=A}createState(){return new $$A}}function J$A(A){let B=new Date().getTime()-A.getTime(),$=Math.floor(B/60000),J=Math.floor(B/3600000),Y=Math.floor(B/86400000);if($<1)return"just now";if($<60)return`${$}m ago`;if(J<24)return`${J}h ago`;if(Y<7)return`${Y}d ago`;return A.toLocaleDateString()}class W$1 extends T1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((J,Y)=>Y.pubDate.getTime()-J.pubDate.getTime()),B=Math.max(0,...Q.map((J)=>J$A(J.pubDate).length));return new k5({items:Q,getLabel:(J)=>J.title,onAccept:(J)=>this.props.onSelect?.(J),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(J,Y,Z,F)=>{let X=S0.of(F),{colors:D}=X,G=X.app,V=Y?G.selectionBackground:void 0,U=Y?G.selectionForeground:D.foreground,K=D.mutedForeground,E=(W,H)=>new j0({width:H,child:F1.end([new t({text:new O(W,new h({color:K}))})])});return new u0({decoration:V?{color:V}:void 0,padding:M0.symmetric(2,0),child:new F1({children:[new y1({child:new t({text:new O(J.title,new h({color:U})),overflow:"ellipsis",maxLines:1})}),new j0({width:2}),E(J$A(J.pubDate),B)]})})}})}}class TB{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!TB._instance)TB._instance=new TB;return TB._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()}}c8();class Y$A extends y0{props;constructor(A){super();this.props=A}createState(){return new Z$A}}class Z$A extends v0{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=A.startsWith("file://")?A.slice(7):A,B=this.widget.props.cwd;if(Q.startsWith(B))return Q.slice(B.length+1);return Q}statusIcon(A){let Q=r3.default(),{colors:B,app:$}=Q;switch(A){case"loading":return{icon:"◌",color:B.warning};case"active":return{icon:"✓",color:$.toolSuccess};case"error":return{icon:"✗",color:$.toolError}}}build(A){let Q=S0.of(A),{app:B}=Q;if(this.plugins.length===0)return new t({text:new O("No plugins found.",new h({dim:!0}))});let $=[],J=this.plugins.length,Y=this.plugins.filter((X)=>X.status==="active").length,Z=this.plugins.reduce((X,D)=>X+D.registeredCommands.length,0),F=this.plugins.reduce((X,D)=>X+D.registeredTools.length,0);if($.push(new O(`${Y}/${J} ${w4(J,"plugin")} active`,new h({bold:!0}))),Z>0||F>0)$.push(new O(` (${Z} ${w4(Z,"command")}, ${F} ${w4(F,"tool")})`,new h({dim:!0})));$.push(new O(`
5841
5945
 
5842
5946
  `));for(let X of this.plugins){let{icon:D,color:G}=this.statusIcon(X.status),V=this.getRelativePath(X.uri.toString());if($.push(new O(`${D} `,new h({color:G}))),$.push(new O(V,new h({bold:!0}))),$.push(new O(` ${X.status}`,new h({dim:!0}))),$.push(new O(`
5843
5947
  `)),X.status==="active"&&X.registeredEvents.length>0)$.push(new O(" Events: ",new h({dim:!0}))),$.push(new O(X.registeredEvents.join(", "),new h({color:B.link}))),$.push(new O(`
@@ -6019,7 +6123,7 @@ ${o.content||""}`:o.content||"",P0=[],b0=o.baseDir.startsWith("file://")?pz0(o.b
6019
6123
  `)}function JZA(A,Q){A.command("usage").description("Show your current Amp usage and credit balance").action(async(B,$)=>{let J=$.optsWithGlobals(),Y=await Q(J),Z=await Y.settings.get("proxy"),F=J54({settings:{url:Y.ampURL,proxy:Z},secrets:{getToken:(D,G)=>Y.secrets.get(D,G)}}),X=await lA.userDisplayBalanceInfo({},{config:F});if(!X.ok){if(X.error.code==="auth-required")process.stderr.write(n0.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(n0.red("Error: ")+X.error.message+`
6020
6124
  `),process.exit(1)}process.stdout.write(await SU8(X.result.displayText)+`
6021
6125
  `),process.exit(0)})}var tH8=D40.join(UF,"logs","headless.log"),MZ1=D40.join(sb,"device-id.json"),eH8=`cli-tui-${kDA(16).toString("hex")}`;async function Az8(){for(let A of aL)try{if((await A.listConfigs()).length>0)return A}catch(Q){T.debug("Failed to detect query-based IDE integration",{ideName:A.ideName,error:Q})}return}try{if(process.platform==="win32")await Promise.resolve().then(() => H4(oh(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(A){P$.write(`Failed to change directory to ${process.env.AMP_PWD}: ${A}
6022
- `)}function Qz8(A){process.emitWarning=(Q,B,$,J)=>{let Y=typeof Q==="string"?Q:Q.message||String(Q),Z=B||"Warning",F=!1;A.warn(Y,{name:Z,code:$})}}function J7(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")ZQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")ZQ("experimental.agentMode",Q.mode);if(A.getOptionValueSourceWithGlobals("model")==="cli"&&Q.model)ZQ("internal.model",Bz8(Q.model))}function ODA(A){let Q=A.indexOf(":");if(Q===-1)throw new K4(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let B=A.slice(0,Q).trim(),$=A.slice(Q+1).trim();if(!B||!$)throw new K4(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Bz8(A){if(!A.includes("="))return ODA(A),A;let Q={};for(let B of A.split(",")){let $=B.trim();if(!$)continue;let J=$.indexOf("=");if(J===-1)throw new K4(`Invalid mode-specific model entry "${$}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let Y=$.slice(0,J).trim(),Z=$.slice(J+1).trim();if(!Y)throw new K4(`Missing mode name in "${$}". Expected "mode=provider:model".`,1);if(!Z)throw new K4(`Missing model value for mode "${Y}". Expected "${Y}=provider:model".`,1);ODA(Z),Q[Y]=Z}if(Object.keys(Q).length===0)throw new K4("No valid model overrides found in --model flag value.",1);return Q}function $z8(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 Jz8(A){try{return await vDA(A,"utf-8")}catch{return A}}async function jDA(A,Q,B){let $=$z8(A,Q);if(!$)return;let J=gA(B)?B.features:[],Y=gA(B)?B.user.email:void 0;if(!rh(J,J9.HARNESS_SYSTEM_PROMPT)&&!(Y&&U7(Y)))throw new K4("You are not allowed to do this.",1);ZQ("systemPrompt",await Jz8($))}function rh(A,Q){return A?.some((B)=>B.name===Q&&B.enabled)??!1}function Yz8(A){return A!=="pending"}function th(A){if(!gA(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function Zz8(A){let Q=th(A);if(Q)return Q.id;if(UW(A))throw Error(A.error.message);throw Error("unreachable")}function Fz8(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 Xz8(A){let $=Fz8(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 K4(`Couldn't connect to the Amp server at ${A}.`,1,$)}function OZ1(A,Q){let B=F51(Error(A.error.message));if(B.message===u7.networkOffline||B.message===u7.networkTimeout)return Xz8(Q);if(B.message!==u7.internalBug)return new K4(B.message,1,B.suggestion);return new K4(A.error.message.replace(/^Error: /,""),1)}var RDA=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; 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??zX,description:`Custom settings file path (overrides the default location ${zX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${jt})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:w9(),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:cL.SMART.key,description:`Set the agent mode (${r$({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:r$().map((A)=>A.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",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}],PDA=(A)=>("deprecated"in A)&&A.deprecated===!0,Dz8=(A)=>("hidden"in A)&&A.hidden===!0,Gz8=(A)=>("default"in A),Vz8=(A)=>("default"in A)?A.default:void 0,yDA=[{name:"toggle-skills-count",entryPoint:tQ1}];function Uz8(A,Q){let B=Q.args[0],$=Q.commands.map((Y)=>Y.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let Y=$.filter((F)=>B.includes(F)||F.includes(B)),Z="Run amp --help for a list of available commands.";if(Y.length>0)Z=`Did you mean: ${Y.join(", ")}? Or run amp --help for all commands.`;throw new K4(u7.unknownCommand(B),1,Z)}}async function vq0(A){return{...A,getThreadEnvironment:HH,osFileSystem:A.fileSystem,skillService:A.skillService,fileChangeTrackerStorage:new mO(A.fileSystem),generateThreadTitle:zK4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>YJ(A.configService),pluginService:A.pluginService}}function xDA(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:HH,filesystem:A.fileSystem,threadService:A.threadService}}var fDA="code-tour";function LZ1(A){return A.filter((Q)=>Q.name!==fDA)}function Kz8(A){return{...A,skills:A.skills.pipe(w1(LZ1)),getSkills:async()=>LZ1(await A.getSkills()),getSkill:async(Q)=>Q===fDA?void 0:A.getSkill(Q),getSkillsList:async()=>{let Q=LZ1(await A.getSkills());return qy(Q)}}}var Sq0=Z1.file(sH8.homedir()),jZ1=process.env.XDG_CONFIG_HOME?Z1.file(process.env.XDG_CONFIG_HOME):G1.joinPath(Sq0,".config");function Ez8(A){return uy4({playNotificationSound:async(Q)=>{if(A.useNotificationsForService){if(kU0())vU0();else if(process.platform==="darwin"&&Q==="idle"&&A.isTUIVoiceNotifEnabled())by4();else pr(Q);let B=_P(),$=Se();if((!B||$||QK0())&&A.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(SG("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(SG("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(_P()),threadService:A.threadService,configService:A.configService,threadViewStates$:A.threadViewStates$})}async function e2(A,Q,B){let $=B?.deferAuth??!1,J=B?.skipToolProviders??!1;g54("0.0.1777072801-g023a81");let Y=bk({storage:A.settings,secretStorage:A.secrets,workspaceRoot:g0.of(Z1.file(process.cwd())),defaultAmpURL:A.ampURL,homeDir:Sq0,userConfigDir:jZ1});a9A(Y);let Z=await Y.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(Z.settings)});let F=!1;{let m=await A.secrets.get("apiKey",A.ampURL);if(F=Boolean(m),T.info("API key lookup before login",{found:Boolean(m),ampURL:A.ampURL,deferAuth:$}),!m)if($)T.info("No API key found, continuing startup with deferred auth");else{$5.write(`No API key found. Starting login flow...
6126
+ `)}function Qz8(A){process.emitWarning=(Q,B,$,J)=>{let Y=typeof Q==="string"?Q:Q.message||String(Q),Z=B||"Warning",F=!1;A.warn(Y,{name:Z,code:$})}}function J7(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")ZQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")ZQ("experimental.agentMode",Q.mode);if(A.getOptionValueSourceWithGlobals("model")==="cli"&&Q.model)ZQ("internal.model",Bz8(Q.model))}function ODA(A){let Q=A.indexOf(":");if(Q===-1)throw new K4(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let B=A.slice(0,Q).trim(),$=A.slice(Q+1).trim();if(!B||!$)throw new K4(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Bz8(A){if(!A.includes("="))return ODA(A),A;let Q={};for(let B of A.split(",")){let $=B.trim();if(!$)continue;let J=$.indexOf("=");if(J===-1)throw new K4(`Invalid mode-specific model entry "${$}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let Y=$.slice(0,J).trim(),Z=$.slice(J+1).trim();if(!Y)throw new K4(`Missing mode name in "${$}". Expected "mode=provider:model".`,1);if(!Z)throw new K4(`Missing model value for mode "${Y}". Expected "${Y}=provider:model".`,1);ODA(Z),Q[Y]=Z}if(Object.keys(Q).length===0)throw new K4("No valid model overrides found in --model flag value.",1);return Q}function $z8(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 Jz8(A){try{return await vDA(A,"utf-8")}catch{return A}}async function jDA(A,Q,B){let $=$z8(A,Q);if(!$)return;let J=gA(B)?B.features:[],Y=gA(B)?B.user.email:void 0;if(!rh(J,J9.HARNESS_SYSTEM_PROMPT)&&!(Y&&U7(Y)))throw new K4("You are not allowed to do this.",1);ZQ("systemPrompt",await Jz8($))}function rh(A,Q){return A?.some((B)=>B.name===Q&&B.enabled)??!1}function Yz8(A){return A!=="pending"}function th(A){if(!gA(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function Zz8(A){let Q=th(A);if(Q)return Q.id;if(UW(A))throw Error(A.error.message);throw Error("unreachable")}function Fz8(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 Xz8(A){let $=Fz8(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 K4(`Couldn't connect to the Amp server at ${A}.`,1,$)}function OZ1(A,Q){let B=F51(Error(A.error.message));if(B.message===u7.networkOffline||B.message===u7.networkTimeout)return Xz8(Q);if(B.message!==u7.internalBug)return new K4(B.message,1,B.suggestion);return new K4(A.error.message.replace(/^Error: /,""),1)}var RDA=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; 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??zX,description:`Custom settings file path (overrides the default location ${zX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${jt})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:w9(),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:cL.SMART.key,description:`Set the agent mode (${r$({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:r$().map((A)=>A.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",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}],PDA=(A)=>("deprecated"in A)&&A.deprecated===!0,Dz8=(A)=>("hidden"in A)&&A.hidden===!0,Gz8=(A)=>("default"in A),Vz8=(A)=>("default"in A)?A.default:void 0,yDA=[{name:"toggle-skills-count",entryPoint:tQ1}];function Uz8(A,Q){let B=Q.args[0],$=Q.commands.map((Y)=>Y.name());if(B&&!B.includes(" ")&&B.length<30&&!/[./\\]/.test(B)){let Y=$.filter((F)=>B.includes(F)||F.includes(B)),Z="Run amp --help for a list of available commands.";if(Y.length>0)Z=`Did you mean: ${Y.join(", ")}? Or run amp --help for all commands.`;throw new K4(u7.unknownCommand(B),1,Z)}}async function vq0(A){return{...A,getThreadEnvironment:HH,osFileSystem:A.fileSystem,skillService:A.skillService,fileChangeTrackerStorage:new mO(A.fileSystem),generateThreadTitle:zK4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>YJ(A.configService),pluginService:A.pluginService}}function xDA(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:HH,filesystem:A.fileSystem,threadService:A.threadService}}var fDA="code-tour";function LZ1(A){return A.filter((Q)=>Q.name!==fDA)}function Kz8(A){return{...A,skills:A.skills.pipe(w1(LZ1)),getSkills:async()=>LZ1(await A.getSkills()),getSkill:async(Q)=>Q===fDA?void 0:A.getSkill(Q),getSkillsList:async()=>{let Q=LZ1(await A.getSkills());return qy(Q)}}}var Sq0=Z1.file(sH8.homedir()),jZ1=process.env.XDG_CONFIG_HOME?Z1.file(process.env.XDG_CONFIG_HOME):G1.joinPath(Sq0,".config");function Ez8(A){return uy4({playNotificationSound:async(Q)=>{if(A.useNotificationsForService){if(kU0())vU0();else if(process.platform==="darwin"&&Q==="idle"&&A.isTUIVoiceNotifEnabled())by4();else pr(Q);let B=_P(),$=Se();if((!B||$||QK0())&&A.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(SG("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(SG("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(_P()),threadService:A.threadService,configService:A.configService,threadViewStates$:A.threadViewStates$})}async function e2(A,Q,B){let $=B?.deferAuth??!1,J=B?.skipToolProviders??!1;g54("0.0.1777076476-ge780d5");let Y=bk({storage:A.settings,secretStorage:A.secrets,workspaceRoot:g0.of(Z1.file(process.cwd())),defaultAmpURL:A.ampURL,homeDir:Sq0,userConfigDir:jZ1});a9A(Y);let Z=await Y.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(Z.settings)});let F=!1;{let m=await A.secrets.get("apiKey",A.ampURL);if(F=Boolean(m),T.info("API key lookup before login",{found:Boolean(m),ampURL:A.ampURL,deferAuth:$}),!m)if($)T.info("No API key found, continuing startup with deferred auth");else{$5.write(`No API key found. Starting login flow...
6023
6127
  `);let p=await Wz8(A),u=await A.secrets.get("apiKey",A.ampURL);if(T.info("Login flow completed",{success:p,storedKeyPresent:Boolean(u),ampURL:A.ampURL}),!p)await LK(),process.exit(1);F=!0}}{let m=await Y.getLatest(),p=m.settings.url,u=m.secrets.isSet?.[p];T.info("Config secrets state after login",{configURL:p,apiKeySet:u?.apiKey??!1})}let X=k1(YJ(Y).pipe(N5(Yz8))),D=$?"pending":await X;if(!$)T.info("Server status resolved",{status:"ready",isAuthenticated:gA(D),isError:UW(D),errorMessage:UW(D)?D.error.message:void 0});let G=X.then((m)=>Zz8(m));G.catch(()=>{return});let{toolService:V,dispose:U}=ED0({configService:Y}),K=new Map,E=()=>K.clear(),W=new Em0(Y,A.settings.getWorkspaceRootPath()),H=i$0({configService:Y,filesystem:k8}),z=jF4({configService:Y,trustStore:W,skillMCPServers:H.skillMCPServers,createOAuthProvider:async(m,p,u)=>{let a=`${m}:${p}`,c=K.get(a);if(c)return T.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:p}),c;T.debug("Creating OAuth provider for server",{serverName:m,serverUrl:p});let s=(async()=>{let W0=new AO(A.secrets),i=await W0.getClientInfo(m,p),A0=u?.scopes??i?.scopes,D0=qr4();T.info("OAuth headless mode check",{useHeadless:D0,executeMode:A.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:$5.isTTY});let z0;if(D0)z0=A.executeMode?zr4():Hr4(m);let B0=new of0({storage:W0,serverName:m,serverUrl:p,clientId:u?.clientId??i?.clientId,clientSecret:u?.clientSecret??i?.clientSecret,authUrl:u?.authUrl??i?.authUrl,tokenUrl:u?.tokenUrl??i?.tokenUrl,scopes:A0,headlessAuthHandler:z0});return T.debug("OAuth provider created",{serverName:m,serverUrl:p,hasManualClientId:!!(u?.clientId??i?.clientId),willUseDCR:!(u?.clientId??i?.clientId),scopes:A0,headlessMode:D0,executeMode:A.executeMode}),B0})();return K.set(a,s),s}}),q=Kt0({configService:Y,filesystem:k8,spawn:bX0}),N;if(J)N=new Map;else if(A.executeMode){let m=await Ak4({toolService:V,providers:[z,q],initialTimeout:15000});N=m.registrations;for(let[p,u]of m.initErrors)T.warn(`${p} provider initialization slow or failed:`,u)}else N=Et0({toolService:V,providers:[z,q]});if(Q.jetbrains)iL("JetBrains");else if(Q.ide&&Qs4())iL("VS Code");else if(Q.ide&&Bs4())iL("Neovim");else if(Q.ide){let m=await Az8();if(m){let p=p90(m.ideName);if(p)iL(p)}}if(A.executeMode)m54(!0);let I,C=i8.status.pipe(w1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&H84(m.ideName))),l4()).subscribe((m)=>{if(m){if(!I)I=V.registerTool(eS4)}else I?.dispose(),I=void 0}),w;if(!A.executeMode){let m=await A.settings.get("fuzzy.alwaysIncludePaths")??[];w=new ob(process.cwd(),{alwaysIncludePaths:m},!0)}else w=new class extends ob{async start(){}async query(){return[]}async queryCompletions(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let M=new qd0(lO(Y),{maxThreads:200});T.info("Starting Amp background services");let j=new JB1,P=process.env.PLUGINS??"off",R=Q.headless?k9A():void 0,b=R??new gW0({configService:Y}),g=b instanceof gW0?b:void 0;if(g)g.pluginExecutorKind="local";let f=Sm0({configService:Y,fileSystem:k8,platform:b,internalPlugins:yDA,pluginFilter:P}),k=IX4({pluginService:f,toolService:V}),x={configService:Y,toolService:V,mcpService:z,skillService:H,toolboxService:q,trustStore:W,threadService:M,secretStorage:A.secrets,settingsStorage:A.settings,fuzzyServer:w,fileSystem:k8,terminal:j,pluginService:f,pluginPlatform:g,headlessPluginPlatform:R,serverStatus:D,serverStatusPromise:X,viewerUserIDPromise:G,hasAPIKeyAtStartup:F};return{...x,async asyncDispose(){if(x.mcpService.hasAuthenticatingClients())T.info("Waiting for OAuth authentication to complete before exit..."),await x.mcpService.waitForAuthentication();for(let m of N.values())m.dispose();await x.mcpService.dispose(),E(),await x.threadService.asyncDispose(),x.configService.unsubscribe(),U(),x.fuzzyServer.dispose(),x.settingsStorage[Symbol.dispose](),C.unsubscribe(),I?.dispose(),k.dispose(),await x.pluginService.dispose()}}}async function Wz8(A){if(!A.executeMode){if(!await CK0("Would you like to log in to Amp? [(y)es, (n)o]: "))return $5.write(`Login cancelled. Run the command again to retry.
6024
6128
  `),!1}return await bDA(A)}async function bDA(A){let Q=kDA(32).toString("hex"),B=await Yu(A.ampURL,Q),$=new AbortController;try{await UD(B,$.signal)}catch(Y){T.error("Error opening browser",{error:Y})}let J=await Yu(A.ampURL,Q,!1);$5.write(`If your browser does not open automatically, visit:
6025
6129
 
@@ -6027,7 +6131,7 @@ ${n0.blue.bold(J)}
6027
6131
 
6028
6132
  `);try{return await We4(A.ampURL,Q,A.secrets,$),$5.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(Y){return T.error("Login failed",{error:Y}),P$.write(`
6029
6133
  Login failed: ${Y instanceof Error?Y.message:String(Y)}
6030
- `),!1}}function Hz8(A){let Q=new uI().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((E)=>{if(E.code==="commander.help"||E.code==="commander.version"||E.exitCode===0)ZP(),process.exit(0);let W=E.originalError??E;rn4(W)}),v0A(Q,{version:"0.0.1777072801-g023a81",buildTimestamp:"2026-04-24T23:23:49.258Z",buildType:"'release'"}),Q.addHelpText("after",tr4()),Q.configureHelp({formatHelp:er4}),Q.command("logout").description("Log out by removing stored API key").action(async(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await Mz8(z)}),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(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await wz8(z,await lt(H,z.settings))}),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(E,W,H)=>{let z=H.optsWithGlobals(),q=await K8(z);await Xr4(E??"get",q.ampURL,q.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(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await Dr4(z.ampURL,z.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(E)=>{await zt4({raw:E.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(`
6134
+ `),!1}}function Hz8(A){let Q=new uI().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((E)=>{if(E.code==="commander.help"||E.code==="commander.version"||E.exitCode===0)ZP(),process.exit(0);let W=E.originalError??E;rn4(W)}),v0A(Q,{version:"0.0.1777076476-ge780d5",buildTimestamp:"2026-04-25T00:25:11.684Z",buildType:"'release'"}),Q.addHelpText("after",tr4()),Q.configureHelp({formatHelp:er4}),Q.command("logout").description("Log out by removing stored API key").action(async(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await Mz8(z)}),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(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await wz8(z,await lt(H,z.settings))}),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(E,W,H)=>{let z=H.optsWithGlobals(),q=await K8(z);await Xr4(E??"get",q.ampURL,q.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(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await Dr4(z.ampURL,z.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(E)=>{await zt4({raw:E.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(`
6031
6135
  `)).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(E,W,H)=>{if(E&&W.apply)throw new K4("Choose either a positional thread ID/URL or --apply <thread-id>, not both.",1);let z=W.apply??E;if(!z||z.trim().length===0)$5.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.
6032
6136
 
6033
6137
  `),H.outputHelp(),process.exit(0);let q=Z2(z)??UZ(z),N=H.optsWithGlobals(),I=await K8(N);J7(H,N);let C=await e2(I,N),w=!1;try{if(W.checkout&&W.skipCheckout)throw new K4("Choose either --checkout or --skip-checkout, not both.",1);if(UW(C.serverStatus))throw OZ1(C.serverStatus,I.ampURL);let M=gA(C.serverStatus)?C.serverStatus.features:void 0;if(!rh(M,J9.V2))throw new K4("live-sync is not enabled for your user",1);await Je4({ampURL:I.ampURL,threadId:q,configService:C.configService,threadService:C.threadService,apiKey:process.env.AMP_API_KEY,applyOnce:typeof W.apply==="string",checkoutMode:W.checkout?"always":W.skipCheckout?"never":"prompt",promptForYesNo:CK0}),w=!0}finally{if(await C.asyncDispose(),w)process.exit(0)}});let B=async(E,W,H)=>{bk({storage:W.settings,secretStorage:W.secrets,workspaceRoot:g0.of(Z1.file(process.cwd())),defaultAmpURL:W.ampURL,homeDir:Sq0,userConfigDir:jZ1});let z={...W,executeMode:!1};await kq0(z,{...E,openThreadSwitcher:!0},H,A)},$=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").action(async(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await SDA(H,z,W)});$.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(E,W)=>{let H=W.optsWithGlobals(),z=await K8(H);await yz8(H,z,W)}),$.command("continue [threadIDOrURL]").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.").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(E,W,H)=>{let z=H.optsWithGlobals(),q=await K8(z);if(W.pick)P$.write(`${n0.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
@@ -6061,8 +6165,8 @@ ${I}
6061
6165
 
6062
6166
  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 zz8(A){if(A.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof A.execute==="string"){let Q=(await dW0()).trimEnd();return{userInput:A.execute,stdinInput:Q||null}}return{userInput:(await dW0()).trimEnd(),stdinInput:null}}function qz8(A,Q,B){if(A.streamJson&&!Q)throw new K4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(A.streamJsonInput&&!Q)throw new K4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(A.streamJsonInput&&!A.streamJson)throw new K4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(A.stats&&A.streamJson)throw new K4("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 K4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(A.archive&&!Q)throw new K4("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 K4("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&&B===""&&!A.streamJsonInput&&!A.headless)throw new K4("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"
6063
6167
  Or pipe via stdin: echo "your message" | amp --execute`)}async function kq0(A,Q,B,$){let J=process.hrtime.bigint(),Y=(d,n)=>{let o=Number(process.hrtime.bigint()-n)/1e6,e=kd4();T.info("Startup phase",{phase:d,phaseMs:Math.round(o),sinceMainMs:e===null?void 0:Math.round(e)})},{userInput:Z,stdinInput:F}=await zz8(Q),X=!!Q.streamJson||!!Q.streamJsonThinking;qz8({...Q,streamJson:X},A.executeMode,Z),J7(B,Q);let D=process.hrtime.bigint(),G=Boolean(await A.secrets.get("apiKey",A.ampURL)),V=!A.executeMode&&!Q.headless&&G;T.info("Interactive auth startup mode",{deferInteractiveAuth:V,hasAPIKeyAtStartup:G,executeMode:A.executeMode,headless:Boolean(Q.headless)});let U=await e2(A,Q,{deferAuth:V});Y("runMainThread:createThreadDependencies",D);let{serverStatus:K}=U;if(!V&&UW(K))throw OZ1(K,A.ampURL);let E=gA(K)?K:null,W=E?.user.email,H=!!(W&&U7(W));if(!V)await jDA(B,Q,K);let z=th(K),q=z?.features??[],N=z?.team??null,I=CW0(Q,z);if(I instanceof Error)o5(I.message);if(E&&!zc(Q.mode,W))throw new K4(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(Q.headless){if(process.env.AMP_EXECUTOR!=="1"&&(!W||!U7(W)))throw new K4("Headless executor mode is only available for Amp employees",1);let n=await U.secretStorage.get("apiKey",A.ampURL);if(!n)throw new K4("API key required for headless mode. Please run `amp login` first.",1);let o=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(o&&!t$(o))throw new K4(`Invalid thread ID: ${o}`,1);let e=o?void 0:await kz8({dependencies:U,apiKey:n,visibility:I??void 0}),Y0=o??e?.threadId;if(!Y0)throw new K4("Failed to resolve headless thread ID",1);let $0=await wr4(Y0);if($0.status==="already-running")await U.asyncDispose(),await LK(),process.exit(0);try{await Kr4({ampURL:A.ampURL,apiKey:n,workspaceRoot:process.cwd(),threadId:Y0,ownerUserId:e?.ownerUserId,threadVersion:e?.threadVersion,agentMode:e?.agentMode,initialToolDiscovery:Promise.all([U.mcpService.initialized,U.toolboxService.initialized]).then(()=>{return}),configService:U.configService,mcpService:U.mcpService,toolService:U.toolService,skillService:U.skillService,fileSystem:U.fileSystem,pluginService:U.pluginService,pluginPlatform:U.headlessPluginPlatform})}finally{await $0.release(),await U.asyncDispose()}await LK(),process.exit(0)}let C=Q.threadId&&t$(Q.threadId)?Q.threadId:void 0,w=V?await U.serverStatusPromise:K,M=gA(w)&&rh(w.features,J9.NEO_TUI);if((M||Q.neo||!1)&&!A.executeMode&&!Q.takeMeBack){if(Q.neo&&!M&&(!gA(w)||!U7(w.user.email)))throw new K4("--neo is only available for Amp employees",1);let d=await U.secretStorage.get("apiKey",A.ampURL);if(!d)throw new K4("API key required. Please run `amp login` first.",1);let n=lO(U.configService),o=new K_(U.fuzzyServer),e=process.cwd();await sQ1({ampURL:A.ampURL,apiKey:d,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??xJ(A.ampURL),configService:U.configService,toolService:U.toolService,skillService:U.skillService,mcpService:U.mcpService,readFileSystemDirectory:({uri:Y0})=>IC({fileSystem:U.fileSystem,workspaceRoot:e},Y0),completionBuilder:o,workspaceRoot:e,listThreads:()=>n.listThreads(),getThreadFromServer:(Y0)=>n.getThread(Y0),isInternalUser:gA(w)&&U7(w.user.email),settingsFilePath:U.settingsStorage.getSettingsFilePath()},{initialThreadID:C,initialUserInput:Z||void 0,openThreadPickerOnStart:Q.openThreadSwitcher});return}let P=gA(w)&&rh(w.features,J9.THREAD_ACTORS_TUI);if(A.executeMode&&!Q.takeMeBack&&P){let d=await U.secretStorage.get("apiKey",A.ampURL);if(!d)throw new K4("API key required. Please run `amp login` first.",1);J31(U.mcpService,A.settings);try{let n=await So4({apiKey:d,ampURL:A.ampURL,workspaceRoot:process.cwd(),dependencies:U,userInput:Z,stdinInput:F,stats:!!Q.stats,streamJson:X,streamJsonThinking:!!Q.streamJsonThinking,streamJsonInput:!!Q.streamJsonInput,stdin:process.stdin,agentMode:Q.mode,labels:Q.label,initialThreadID:C});if(await sh(n,"execute"),Q.archive)await U.threadService.archive(n,!0)}finally{await U.asyncDispose()}await LK(),process.exit(0)}if(!A.executeMode&&!Q.headless)U.skillService=Kz8(U.skillService);D=process.hrtime.bigint();let b=await vq0(U);Y("runMainThread:createWorkerDeps",D);let g=A.executeMode?void 0:async(d)=>sh(d,"interactive"),f={threadService:U.threadService,workerDeps:b,createThread:async(d)=>{let n=V?await U.serverStatusPromise:K,o=await $U0(A.settings,process.cwd(),th(n),I);if(o instanceof Error)o5(o.message);return rJ1(b,{threadMeta:o?gG(o):void 0,agentMode:d??Q.mode,onFirstAssistantMessage:g})},validateThreadOwnership:async(d,n)=>{if(n?.nonBlockingOwnershipCheck){_DA(d,U.configService,U.viewerUserIDPromise).catch((o)=>{if(o instanceof K4){if(n.onOwnershipError){n.onOwnershipError(o,d);return}kH(o,d);return}T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:o})});return}try{await _DA(d,U.configService,U.viewerUserIDPromise)}catch(o){if(o instanceof K4)throw o;T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:o})}},switchThreadVisibility:I,switchThreadAgentMode:Q.mode,onFirstAssistantMessage:g,handleError:kH},k=async()=>{try{return AZA(f,Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck})}catch(d){if(d instanceof K4)throw d;throw await kH(d,Q.threadId),Error("handleError should have called process.exit()")}};if(Q.format==="jsonl")P$.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
6064
- `),await LK(),process.exit(1);let x=(async()=>{if(V){T.info("Skipping initial free tier status fetch until auth is complete");return}try{let d=await U.configService.getLatest(),n=Yc(d),o=await lA.getUserFreeTierStatus({},{config:U.configService,signal:AbortSignal.timeout(n)});if(o.ok)return T.info("User free tier status:",o),o.result;return}catch(d){T.error("Failed to fetch free tier status:",d);return}})(),p=!A.executeMode?new EB1:null,u,a=null;if(p)u=p,a=(async()=>{let d=V?await U.serverStatusPromise:U.serverStatus;if(UW(d))throw OZ1(d,A.ampURL);await jDA(B,Q,d);let n=process.hrtime.bigint(),o=await k();if(Y("runMainThread:createThreadPool",n),p.attach(o),Z){let e=await k1(o.threadHandles$);if(!e)throw new K4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:Z}]})}})(),a.catch(async(d)=>{let n=d instanceof Error?d:Error(String(d));p.setInitError(n),await kH(d,Q.threadId)});else D=process.hrtime.bigint(),u=await k(),Y("runMainThread:createThreadPool",D);let c=Q.notifications!==void 0?Q.notifications:!A.executeMode,s=E!==null&&rh(E.features,J9.TUI_VOICE_NOTIF);if(V)U.serverStatusPromise.then((d)=>{s=gA(d)&&rh(d.features,J9.TUI_VOICE_NOTIF)}).catch((d)=>{T.debug("Failed to resolve TUI voice notification feature flag",{error:d})});D=process.hrtime.bigint();let W0=await U.configService.getLatest();if(Y("runMainThread:configService.getLatest",D),D=process.hrtime.bigint(),Ez8({configService:U.configService,threadService:U.threadService,config:W0,useNotificationsForService:c,isTUIVoiceNotifEnabled:()=>s,threadViewStates$:()=>u.threadHandles$.pipe(c4((d)=>{if(!d)return g0.of({});return u6(d.thread$,d.threadViewState$).pipe(w1(([n,o])=>({[n.id]:o})))}))}),Y("runMainThread:createCliNotificationService",D),A.executeMode){J31(U.mcpService,A.settings);let d={userInput:Z,stdinInput:F,dependencies:U,streamJson:X,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:H,agentMode:Q.mode,labels:Q.label},n=await za4({threadPool:u,...d});if(await sh(n,"execute"),Q.archive)await U.threadService.archive(n,!0);await U.asyncDispose(),process.exit(0)}let i=!1,A0=!1;if(Q.jetbrains||Q.ide){await d90();let d=await ID({jetbrainsOnly:Q.jetbrains});if(d.length===0){if(Q.jetbrains)i=!await U.configService.get("jetbrains.skipInstall")}else if(d.length===1){let n=d[0];if(n)i8.selectConfig(n)}else A0=!0}D=process.hrtime.bigint();let D0=L81("0.0.1777072801-g023a81",U.settingsStorage,{startDelayMs:3000});Y("runMainThread:createUpdateService",D),D=process.hrtime.bigint();let z0=new Y31(U.mcpService,A.settings.getWorkspaceRootPath());if(Y("runMainThread:createMcpTrustHandler",D),Z&&A.executeMode){let d=await k1(u.threadHandles$);if(!d)throw new K4("No active thread is available yet.",1);await d.sendMessage({content:[{type:"text",text:Z}]})}D=process.hrtime.bigint();let B0=await Zu();Y("runMainThread:loadSessionState",D),T.info("Loaded session state:",B0);let Z0={...B0,launchCount:B0.launchCount+1};NX((d)=>({...d,launchCount:d.launchCount+1}));try{if(D=process.hrtime.bigint(),await s7A({history:new ft,fuzzyServer:U.fuzzyServer,settingsStorage:U.settingsStorage,threadService:U.threadService,skillService:U.skillService,configService:U.configService,secretStorage:U.secretStorage,internalAPIClient:lA,threadPool:u,createSystemPromptDeps:async()=>xDA(U),ideClient:i8,mcpService:U.mcpService,toolboxService:U.toolboxService,mcpTrustHandler:z0,updateService:D0,pluginPlatform:U.pluginPlatform,pluginService:U.pluginService},{initialServerStatus:U.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:U.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:C,showJetBrainsInstaller:i,showIdePickerHint:A0,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:eH8,logFile:{path:$},sessionState:Z0,freeTierStatusPromise:x,workspace:N??null,features:q,isInternalUser:H,initialAgentMode:B.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,buildTimestamp:"2026-04-24T23:23:49.258Z"},(d)=>new CB1({...d,threadPool:d.threadPool},(n)=>new aJ1({...n,threadState:n.threadState}))),Y("runMainThread:mountApp-returned",D),a)await a}finally{await u.dispose().catch((d)=>{T.error("Failed to dispose thread pool during shutdown",d)})}await U.asyncDispose(),Y("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function K8(A){if(T.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)P$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6065
- `);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,B=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let $=await SF4({get:async(F)=>{if(F!==Fi)return;try{let X=await vDA(MZ1,"utf-8");return JSON.parse(X).installationID}catch{return}},set:async(F,X)=>{if(F!==Fi)return;await oH8(D40.dirname(MZ1),{recursive:!0}),await rH8(MZ1,JSON.stringify({installationID:X},null,2),{mode:384})}},{clientType:"cli",platform:_B0()});p54($);let J=await uU0({...A,workspaceTrust:{current:!0,changes:Lx0},getHook:process.env.AMP_URL?(F,X)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return X()}:void 0});if(A.mcpConfig){let F=await Oe4(A.mcpConfig);J=je4(J,F)}let Y=D40.dirname(J.getSettingsFilePath());fy4(sb,Y),J=C64(J);let Z=await J.get("url","admin")??await J.get("url","global");if(!Z)Z=T9;if(T.info("Resolved Amp URL",{ampURL:Z,settingsFile:J.getSettingsFilePath(),workspaceRoot:J.getWorkspaceRootPath()}),!xq(Z))T.info("Targeting custom Amp server",{ampURL:Z});return{executeMode:Q,isTTY:B,ampURL:Z,settings:J,secrets:RK0(await lt(A,J))}}function Nz8(A){let Q={};for(let B=0;B<A.length;B++){let $=A[B];if($?.startsWith("--")){let Y=$.slice(2).replace(/-([a-z])/g,(F,X)=>X.toUpperCase()),Z=A[B+1];if(Z&&!Z.startsWith("--"))Q[Y]=Z,B++}}return Q}function Iz8(A,Q){let B=A.includes("--headless")||A.some((J)=>J.startsWith("--headless=")),$=D40.resolve(Q.logFile??process.env.AMP_LOG_FILE??(B?tH8:jt));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:$}}async function Cz8(){Sd4();let A=Nz8(process.argv),Q=Iz8(process.argv,A),B=mn4(Q),$=process.argv.includes("--no-color"),J=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if($||!J&&!Y)n0.level=0;if(Qz8(T),T.info("Starting Amp CLI.",{version:"0.0.1777072801-g023a81",buildTimestamp:"2026-04-24T23:23:49.258Z"}),process.platform==="win32"&&WP())Is4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new K4(u7.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Hz8(B).parseAsync(process.argv)}yy4().startActiveSpan("main",async(A)=>{process.on("exit",()=>A.end()),await Cz8().catch(kH)});async function wz8(A,Q){let B=A.ampURL.includes("localhost")||A.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!B)await A.settings.set("url",process.env.AMP_URL,"global"),$5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6168
+ `),await LK(),process.exit(1);let x=(async()=>{if(V){T.info("Skipping initial free tier status fetch until auth is complete");return}try{let d=await U.configService.getLatest(),n=Yc(d),o=await lA.getUserFreeTierStatus({},{config:U.configService,signal:AbortSignal.timeout(n)});if(o.ok)return T.info("User free tier status:",o),o.result;return}catch(d){T.error("Failed to fetch free tier status:",d);return}})(),p=!A.executeMode?new EB1:null,u,a=null;if(p)u=p,a=(async()=>{let d=V?await U.serverStatusPromise:U.serverStatus;if(UW(d))throw OZ1(d,A.ampURL);await jDA(B,Q,d);let n=process.hrtime.bigint(),o=await k();if(Y("runMainThread:createThreadPool",n),p.attach(o),Z){let e=await k1(o.threadHandles$);if(!e)throw new K4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:Z}]})}})(),a.catch(async(d)=>{let n=d instanceof Error?d:Error(String(d));p.setInitError(n),await kH(d,Q.threadId)});else D=process.hrtime.bigint(),u=await k(),Y("runMainThread:createThreadPool",D);let c=Q.notifications!==void 0?Q.notifications:!A.executeMode,s=E!==null&&rh(E.features,J9.TUI_VOICE_NOTIF);if(V)U.serverStatusPromise.then((d)=>{s=gA(d)&&rh(d.features,J9.TUI_VOICE_NOTIF)}).catch((d)=>{T.debug("Failed to resolve TUI voice notification feature flag",{error:d})});D=process.hrtime.bigint();let W0=await U.configService.getLatest();if(Y("runMainThread:configService.getLatest",D),D=process.hrtime.bigint(),Ez8({configService:U.configService,threadService:U.threadService,config:W0,useNotificationsForService:c,isTUIVoiceNotifEnabled:()=>s,threadViewStates$:()=>u.threadHandles$.pipe(c4((d)=>{if(!d)return g0.of({});return u6(d.thread$,d.threadViewState$).pipe(w1(([n,o])=>({[n.id]:o})))}))}),Y("runMainThread:createCliNotificationService",D),A.executeMode){J31(U.mcpService,A.settings);let d={userInput:Z,stdinInput:F,dependencies:U,streamJson:X,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:H,agentMode:Q.mode,labels:Q.label},n=await za4({threadPool:u,...d});if(await sh(n,"execute"),Q.archive)await U.threadService.archive(n,!0);await U.asyncDispose(),process.exit(0)}let i=!1,A0=!1;if(Q.jetbrains||Q.ide){await d90();let d=await ID({jetbrainsOnly:Q.jetbrains});if(d.length===0){if(Q.jetbrains)i=!await U.configService.get("jetbrains.skipInstall")}else if(d.length===1){let n=d[0];if(n)i8.selectConfig(n)}else A0=!0}D=process.hrtime.bigint();let D0=L81("0.0.1777076476-ge780d5",U.settingsStorage,{startDelayMs:3000});Y("runMainThread:createUpdateService",D),D=process.hrtime.bigint();let z0=new Y31(U.mcpService,A.settings.getWorkspaceRootPath());if(Y("runMainThread:createMcpTrustHandler",D),Z&&A.executeMode){let d=await k1(u.threadHandles$);if(!d)throw new K4("No active thread is available yet.",1);await d.sendMessage({content:[{type:"text",text:Z}]})}D=process.hrtime.bigint();let B0=await Zu();Y("runMainThread:loadSessionState",D),T.info("Loaded session state:",B0);let Z0={...B0,launchCount:B0.launchCount+1};NX((d)=>({...d,launchCount:d.launchCount+1}));try{if(D=process.hrtime.bigint(),await s7A({history:new ft,fuzzyServer:U.fuzzyServer,settingsStorage:U.settingsStorage,threadService:U.threadService,skillService:U.skillService,configService:U.configService,secretStorage:U.secretStorage,internalAPIClient:lA,threadPool:u,createSystemPromptDeps:async()=>xDA(U),ideClient:i8,mcpService:U.mcpService,toolboxService:U.toolboxService,mcpTrustHandler:z0,updateService:D0,pluginPlatform:U.pluginPlatform,pluginService:U.pluginService},{initialServerStatus:U.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:U.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:C,showJetBrainsInstaller:i,showIdePickerHint:A0,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:eH8,logFile:{path:$},sessionState:Z0,freeTierStatusPromise:x,workspace:N??null,features:q,isInternalUser:H,initialAgentMode:B.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,buildTimestamp:"2026-04-25T00:25:11.684Z"},(d)=>new CB1({...d,threadPool:d.threadPool},(n)=>new aJ1({...n,threadState:n.threadState}))),Y("runMainThread:mountApp-returned",D),a)await a}finally{await u.dispose().catch((d)=>{T.error("Failed to dispose thread pool during shutdown",d)})}await U.asyncDispose(),Y("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function K8(A){if(T.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)P$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6169
+ `);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,B=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let $=await SF4({get:async(F)=>{if(F!==Fi)return;try{let X=await vDA(MZ1,"utf-8");return JSON.parse(X).installationID}catch{return}},set:async(F,X)=>{if(F!==Fi)return;await oH8(D40.dirname(MZ1),{recursive:!0}),await rH8(MZ1,JSON.stringify({installationID:X},null,2),{mode:384})}},{clientType:"cli",platform:_B0()});p54($);let J=await uU0({...A,workspaceTrust:{current:!0,changes:Lx0},getHook:process.env.AMP_URL?(F,X)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return X()}:void 0});if(A.mcpConfig){let F=await Oe4(A.mcpConfig);J=je4(J,F)}let Y=D40.dirname(J.getSettingsFilePath());fy4(sb,Y),J=C64(J);let Z=await J.get("url","admin")??await J.get("url","global");if(!Z)Z=T9;if(T.info("Resolved Amp URL",{ampURL:Z,settingsFile:J.getSettingsFilePath(),workspaceRoot:J.getWorkspaceRootPath()}),!xq(Z))T.info("Targeting custom Amp server",{ampURL:Z});return{executeMode:Q,isTTY:B,ampURL:Z,settings:J,secrets:RK0(await lt(A,J))}}function Nz8(A){let Q={};for(let B=0;B<A.length;B++){let $=A[B];if($?.startsWith("--")){let Y=$.slice(2).replace(/-([a-z])/g,(F,X)=>X.toUpperCase()),Z=A[B+1];if(Z&&!Z.startsWith("--"))Q[Y]=Z,B++}}return Q}function Iz8(A,Q){let B=A.includes("--headless")||A.some((J)=>J.startsWith("--headless=")),$=D40.resolve(Q.logFile??process.env.AMP_LOG_FILE??(B?tH8:jt));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:$}}async function Cz8(){Sd4();let A=Nz8(process.argv),Q=Iz8(process.argv,A),B=mn4(Q),$=process.argv.includes("--no-color"),J=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if($||!J&&!Y)n0.level=0;if(Qz8(T),T.info("Starting Amp CLI.",{version:"0.0.1777076476-ge780d5",buildTimestamp:"2026-04-25T00:25:11.684Z"}),process.platform==="win32"&&WP())Is4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new K4(u7.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Hz8(B).parseAsync(process.argv)}yy4().startActiveSpan("main",async(A)=>{process.on("exit",()=>A.end()),await Cz8().catch(kH)});async function wz8(A,Q){let B=A.ampURL.includes("localhost")||A.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!B)await A.settings.set("url",process.env.AMP_URL,"global"),$5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6066
6170
  `);else if(!xq(A.ampURL))$5.write(`Logging in to ${new URL(A.ampURL).hostname}
6067
6171
  `);let $=process.env.AMP_API_KEY;if($)$5.write(`API key found in environment variable, storing...
6068
6172
  `),await Q.set("apiKey",$,A.ampURL),$5.write(`API key successfully stored.