import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,s as n,u as r}from"./envUtils-BWeoiL4Y.js";import{n as i,t as a}from"./defineProperty-80gRi2ZW.js";import{Cn as o,t as s}from"./src-Di342QoJ.js";import{Ct as ee,cn as c}from"./state-sIHsFpDu.js";import{A as te,E as ne,_ as l,h as re,l as ie,p as u}from"./debug-otxXY3j-.js";import{n as d,r as f}from"./analytics-DqMQntaB.js";import{a as p,n as m,r as h,s as g}from"./intl-CLeE9DsD.js";import{dirname as ae,join as _}from"path";function v(e,t){if(o(e)<=t)return e;if(t<=0)return`…`;if(t<5)return y(e,t);let n=e.lastIndexOf(`/`),r=n>=0?e.slice(n):e,i=n>=0?e.slice(0,n):``,a=o(r);if(a>=t-1)return b(e,t);let s=t-1-a;return s<=0?b(r,t):x(i,s)+`…`+r}function y(e,t){if(o(e)<=t)return e;if(t<=1)return`…`;let n=0,r=``;for(let{segment:i}of m().segment(e)){let e=o(i);if(n+e>t-1)break;r+=i,n+=e}return r+`…`}function b(e,t){if(o(e)<=t)return e;if(t<=1)return`…`;let n=[...m().segment(e)],r=0,i=n.length;for(let e=n.length-1;e>=0;e--){let a=o(n[e].segment);if(r+a>t-1)break;r+=a,i=e}return`…`+n.slice(i).map(e=>e.segment).join(``)}function x(e,t){if(o(e)<=t)return e;if(t<=0)return``;let n=0,r=``;for(let{segment:i}of m().segment(e)){let e=o(i);if(n+e>t)break;r+=i,n+=e}return r}function S(e,t,n=!1){if(e==null)return``;let r=e;if(n){let n=e.indexOf(`
`);if(n!==-1)return r=e.substring(0,n),o(r)+1>t?y(r,t):`${r}…`}return o(r)<=t?r:y(r,t)}var C=e((()=>{s(),g()}));function w(e){let t=e/1024;if(t<1)return`${e} bytes`;if(t<1024)return`${t.toFixed(1).replace(/\.0$/,``)}KB`;let n=t/1024;return n<1024?`${n.toFixed(1).replace(/\.0$/,``)}MB`:`${(n/1024).toFixed(1).replace(/\.0$/,``)}GB`}function T(e){return`${(e/1e3).toFixed(1)}s`}function E(e,t){if(e<6e4)return e===0?`0s`:e<1?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/1e3).toString()}s`;let n=Math.floor(e/864e5),r=Math.floor(e%864e5/36e5),i=Math.floor(e%36e5/6e4),a=Math.round(e%6e4/1e3);a===60&&(a=0,i++),i===60&&(i=0,r++),r===24&&(r=0,n++);let o=t?.hideTrailingZeros;return t?.mostSignificantOnly?n>0?`${n}d`:r>0?`${r}h`:i>0?`${i}m`:`${a}s`:n>0?o&&r===0&&i===0?`${n}d`:o&&i===0?`${n}d ${r}h`:`${n}d ${r}h ${i}m`:r>0?o&&i===0&&a===0?`${r}h`:o&&a===0?`${r}h ${i}m`:`${r}h ${i}m ${a}s`:i>0?o&&a===0?`${i}m`:`${i}m ${a}s`:`${a}s`}function D(e){return P(e>=1e3).format(e).toLowerCase()}function O(e){return D(e).replace(`.0`,``)}function k(e,t={}){let{style:n=`narrow`,numeric:r=`always`,now:i=new Date}=t,a=e.getTime()-i.getTime(),o=Math.trunc(a/1e3);for(let{unit:e,seconds:t,shortUnit:i}of[{unit:`year`,seconds:31536e3,shortUnit:`y`},{unit:`month`,seconds:2592e3,shortUnit:`mo`},{unit:`week`,seconds:604800,shortUnit:`w`},{unit:`day`,seconds:86400,shortUnit:`d`},{unit:`hour`,seconds:3600,shortUnit:`h`},{unit:`minute`,seconds:60,shortUnit:`m`},{unit:`second`,seconds:1,shortUnit:`s`}])if(Math.abs(o)>=t){let a=Math.trunc(o/t);return n===`narrow`?o<0?`${Math.abs(a)}${i} ago`:`in ${a}${i}`:h(`long`,r).format(a,e)}return n===`narrow`?o<=0?`0s ago`:`in 0s`:h(n,r).format(0,`second`)}function A(e,t={}){let{now:n=new Date,...r}=t;return e>n?k(e,{...r,now:n}):k(e,{...r,numeric:`always`,now:n})}function oe(e){let t=e.fileSize===void 0?`${e.messageCount} messages`:w(e.fileSize),n=[A(e.modified,{style:`short`}),...e.gitBranch?[e.gitBranch]:[],t];return e.tag&&n.push(`#${e.tag}`),e.agentSetting&&n.push(`@${e.agentSetting}`),e.prNumber&&n.push(e.prRepository?`${e.prRepository}#${e.prNumber}`:`#${e.prNumber}`),n.join(` · `)}function j(e,t=!1,n=!0){if(!e)return;let r=new Date(e*1e3),i=new Date,a=r.getMinutes();if((r.getTime()-i.getTime())/(1e3*60*60)>24){let e={month:`short`,day:`numeric`,hour:n?`numeric`:void 0,minute:!n||a===0?void 0:`2-digit`,hour12:n?!0:void 0};return r.getFullYear()!==i.getFullYear()&&(e.year=`numeric`),r.toLocaleString(`en-US`,e).replace(/ ([AP]M)/i,(e,t)=>t.toLowerCase())+(t?` (${p()})`:``)}return r.toLocaleTimeString(`en-US`,{hour:`numeric`,minute:a===0?void 0:`2-digit`,hour12:!0}).replace(/ ([AP]M)/i,(e,t)=>t.toLowerCase())+(t?` (${p()})`:``)}function se(e,t=!1,n=!0){let r=new Date(e);return`${j(Math.floor(r.getTime()/1e3),t,n)}`}var M,N,P,F=e((()=>{g(),C(),M=null,N=null,P=e=>e?(M||(M=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1,minimumFractionDigits:1})),M):(N||(N=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1,minimumFractionDigits:0})),N)}));function I(){return B}function L(e){return e.toFixed(3)}function R(e,t,n,r,i,a,o=``){let s=r?` | RSS: ${w(r.rss)}, Heap: ${w(r.heapUsed)}`:``;return`[+${L(e).padStart(i)}ms] (+${L(t).padStart(a)}ms) ${n}${o}${s}`}var z,B,V=e((()=>{F(),i(),z=class{constructor(){a(this,`marks`,new Map),a(this,`_origin`,void 0),this._origin=Number(process.hrtime.bigint()/1000n)/1e3}mark(e){this.marks.set(e,this.now())}getEntriesByType(e){if(e!==`mark`)return[];let t=[];for(let[e,n]of this.marks)t.push({name:e,startTime:n,entryType:`mark`});return t}clearMarks(e){e===void 0?this.marks.clear():this.marks.delete(e)}now(){return Number(process.hrtime.bigint()/1000n)/1e3-this._origin}},B=new z}));function H(e){X&&(I().mark(e),J&&Z.push(process.memoryUsage()))}function U(){if(!J)return`Startup profiling not enabled`;let e=I().getEntriesByType(`mark`);if(e.length===0)return`No profiling checkpoints recorded`;let t=[];t.push(`=`.repeat(80)),t.push(`STARTUP PROFILING REPORT`),t.push(`=`.repeat(80)),t.push(``);let n=0;for(let[r,i]of e.entries())t.push(R(i.startTime,i.startTime-n,i.name,Z[r],8,7)),n=i.startTime;let r=e[e.length-1];return t.push(``),t.push(`Total startup time: ${L(r?.startTime??0)}ms`),t.push(`=`.repeat(80)),t.join(`
`)}function W(){if(!$){if($=!0,q(),J){let e=K(),t=ae(e);re().mkdirSync(t),te(e,U(),{encoding:`utf8`,flush:!0}),u(`Startup profiling report:`),u(U())}I().clearMarks(),Z.length=0}}function G(){return J}function K(){return _(t(),`startup-perf`,`${ee()}.txt`)}function q(){if(!Y)return;let e=I().getEntriesByType(`mark`);if(e.length===0)return;let t=new Map;for(let n of e)t.set(n.name,n.startTime);let n={};for(let[e,[r,i]]of Object.entries(Q)){let a=t.get(r),o=t.get(i);a!==void 0&&o!==void 0&&(n[`${e}_ms`]=Math.round(o-a))}n.checkpoint_count=e.length,f(`tengu_startup_perf`,n)}var J,Y,X,Z,Q,$,ce=e((()=>{c(),d(),ie(),n(),l(),V(),ne(),J=r(process.env.CLAUDE_CODE_PROFILE_STARTUP),Y=process.env.USER_TYPE===`ant`||Math.random()<.005,X=J||Y,Z=[],Q={import_time:[`cli_entry`,`main_tsx_imports_loaded`],init_time:[`init_function_start`,`init_function_end`],settings_time:[`eagerLoadSettings_start`,`eagerLoadSettings_end`],total_time:[`cli_entry`,`main_after_run`]},X&&H(`profiler_initialized`),$=!1}));export{S as C,x as D,y as E,C as S,b as T,se as _,H as a,O as b,R as c,E as d,w as f,A as g,k as h,q as i,I as l,D as m,ce as n,W as o,oe as p,G as r,L as s,K as t,V as u,j as v,v as w,F as x,T as y};