var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c(e))!u.call(t,n)&&n!==r&&i(t,n,{get:()=>e[n],enumerable:!(a=f(e,n))||a.enumerable});return t};var b=t=>m(i({},"__esModule",{value:!0}),t);var k={};p(k,{default:()=>E});module.exports=b(k);var g=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};g.SENTRY_RELEASE={id:"1.1.30"};(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="b1fb4f68-37d9-46c0-b7cf-bdddf802e677",t._sentryDebugIdIdentifier="sentry-dbid-b1fb4f68-37d9-46c0-b7cf-bdddf802e677")}catch{}})();var o=require("worker_threads"),l=require("child_process");async function w(t,e=1e4){let r=`https://unpkg.com/${t}/package.json`;try{let a=new AbortController,n=setTimeout(()=>a.abort(),e),s=await fetch(r,{signal:a.signal});return clearTimeout(n),s.ok?(await s.json()).version:void 0}catch{return}}async function y(t=6e4){return new Promise((e,r)=>{let a=(0,l.spawn)("npm",["install","-g","@ampt/cli@latest"],{stdio:"ignore"}),n=setTimeout(()=>{a.kill(),r(new Error("npm install timed out"))},t);a.on("close",s=>{clearTimeout(n),s===0?e():r(new Error(`npm install failed with code ${s}`))}),a.on("error",s=>{clearTimeout(n),r(s)})})}o.parentPort.on("message",async({currentVersion:t})=>{try{let e=await w("@ampt/cli");if(!e){o.parentPort.postMessage({err:new Error("Failed to fetch latest version")});return}let r=t.split(".").map(Number),a=e.split(".").map(Number),n=!1;for(let s=0;s<3;s++)if(a[s]>r[s]){n=!0;break}else if(a[s]<r[s])break;if(!n){o.parentPort.postMessage({res:{hasUpdate:!1,currentVersion:t,latestVersion:e}});return}try{await y(),o.parentPort.postMessage({res:{hasUpdate:!0,currentVersion:t,latestVersion:e,installSuccess:!0}})}catch(s){o.parentPort.postMessage({res:{hasUpdate:!0,currentVersion:t,latestVersion:e,installSuccess:!1,installError:s.message}})}}catch(e){o.parentPort.postMessage({err:e})}});var d={};var E=d;
//# sourceMappingURL=cli-update.js.map
