import{eY as d,fY as X,jY as N}from"./cli-0.5.3-g0svn6bx.mjs";import{D5 as O,V5 as p}from"./cli-0.5.3-vpcrbd8n.mjs";import{Caa as U,Faa as G,H6 as f,Yaa as y,u6 as k,v6 as S,z6 as B}from"./cli-0.5.3-t65dek0m.mjs";import{Zfa as H,kga as E}from"./cli-0.5.3-7wdgps7z.mjs";import{Dga as x,Lga as b}from"./cli-0.5.3-c8bcrqa4.mjs";import{cka as w,gma as P}from"./cli-0.5.3-qrvd6cmy.mjs";import{Tma as M,Xma as R}from"./cli-0.5.3-0df3r78b.mjs";import{mkdir as _,readFile as V,writeFile as A}from"fs/promises";import{dirname as L,join as m}from"path";function W(){return m(H(),"cache","changelog.md")}async function Jq(){let J=G();if(!J.cachedChangelog)return;let q=W();try{await _(L(q),{recursive:!0}),await A(q,J.cachedChangelog,{encoding:"utf-8",flag:"wx"})}catch{}U(({cachedChangelog:Y,...z})=>z)}async function C(){if(w())return;if(k())return;let J=await O.get(v);if(J.status===200){let q=J.data;if(q===$)return;let Y=W();await _(L(Y),{recursive:!0}),await A(Y,q,{encoding:"utf-8"}),$=q;let z=Date.now();U((K)=>({...K,changelogLastFetched:z}))}}async function h(){if($!==null)return $;let J=W();try{let q=await V(J,"utf-8");return $=q,q}catch{return $="",""}}function j(){return $??""}function F(J){try{if(!J)return{};let q={},Y=J.split(/^## /gm).slice(1);for(let z of Y){let K=z.trim().split(`
`);if(K.length===0)continue;let Q=K[0];if(!Q)continue;let Z=Q.split(" - ")[0]?.trim()||"";if(!Z)continue;let D=K.slice(1).filter((I)=>I.trim().startsWith("- ")).map((I)=>I.trim().substring(2).trim()).filter(Boolean);if(D.length>0)q[Z]=D}return q}catch(q){return B(x(q)),{}}}function l(J,q,Y=j()){try{let z=F(Y),K=T.coerce(J),Q=q?T.coerce(q):null;if(!Q||K&&X(K.version,Q.version))return Object.entries(z).filter(([Z])=>!Q||X(Z,Q.version)).sort(([Z],[D])=>X(Z,D)?-1:1).flatMap(([Z,D])=>D).filter(Boolean).slice(0,u)}catch(z){return B(x(z)),[]}return[]}function Kq(J=j()){try{let q=F(J);return Object.keys(q).sort((z,K)=>X(z,K)?1:-1).map((z)=>{let K=q[z];if(!K||K.length===0)return null;let Q=K.filter(Boolean);if(Q.length===0)return null;return[z,Q]}).filter((z)=>z!==null)}catch(q){return B(x(q)),[]}}async function Qq(J,q="99.0.0"){let Y=await h();if(J!==q||!Y)C().catch((Q)=>B(x(Q)));let z=l(q,J,Y);return{hasReleaseNotes:z.length>0,releaseNotes:z}}var T,u=5,zq="https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md",v="https://raw.githubusercontent.com/anthropics/claude-code/refs/heads/main/CHANGELOG.md",$=null;var g=R(()=>{p();P();y();E();b();f();S();N();T=M(d(),1)});
export{zq as af,Jq as bf,C as cf,h as df,Kq as ef,Qq as ff,g as gf};
