import{f as P,g as J,r as S,h as R,e as U,j as X,k as h,l as ee,m as ne,n as te,o as le,p as ie,q as oe,s as C,v as re,w as ue,x as se,c as ae}from"./er2hcepb.js";import{_ as de}from"./filepath-item.vue-n2otfocd.js";import{k as E,l as V,b as F,Q as i,S as u,U as e,F as p,ab as G,Y as j,a5 as v,W as x,u as c,a0 as d,$ as a,a6 as f,a8 as A,a9 as I,M as k}from"./vendor/json-editor-vue-gv8v06ez.js";import{_ as me}from"./ncode-block.vue-bvtirmea.js";import{_ as pe}from"./ncheckbox.vue-hj8qatqi.js";import{_ as ve}from"./help-fab.vue-d5mgp1hs.js";import"./vendor/unocss-f0kk6o39.js";import"./vendor/shiki-ml6g43ls.js";import"./client-my5lks1i.js";const fe={"h-full":"",grid:"~ rows-[max-content_1fr]"},ye={flex:"~ wrap","w-full":""},be=["onClick"],ce={key:0,flex:"~ col gap-4 items-center justify-center",p4:""},ge={grid:"~ cols-[30px_1fr] gap-x-2 gap-y-3 items-center justify-center","w-100":""},xe=E({__name:"BuildAnalyzeDetails",props:{current:{},prev:{}},setup(N){const y=N,$=`${J().app.baseURL}/__nuxt_devtools__/analyze/`.replace(/\/+/g,"/"),b=V(()=>{const l=[{name:"Overview",id:"overview"}];return y.current.features.bundleClient&&l.push({name:"Client Bundle",id:"bundle-client"}),y.current.features.bundleNitro&&l.push({name:"Nitro Bundle",id:"bundle-nitro"}),y.current.features.viteInspect&&l.push({name:"Vite Inspect",id:"vite-inspect"}),l}),o=F(b.value[0]);function z(l){return`${((l.endTime-l.startTime)/1e3).toFixed(1)}s`}function m(l){return l<1024?`${l}B`:l<1024*1024?`${(l/1024).toFixed(1)}KB`:l<1024*1024*1024?`${(l/1024/1024).toFixed(1)}MB`:`${(l/1024/1024/1024).toFixed(1)}GB`}async function T(l){return S.clearAnalyzeBuilds(await R(),[l])}return(l,n)=>{const D=de,B=U;return i(),u("div",fe,[e("div",ye,[(i(!0),u(p,null,G(b.value,(r,t)=>(i(),u("button",{key:t,px4:"",py2:"",border:"r base",hover:"bg-active",class:j(r.id===o.value.id?"":"border-b"),onClick:_=>o.value=r},[e("div",{class:j(r.id===o.value.id?"":"op30")},v(r.name),3)],10,be))),128)),n[1]||(n[1]=e("div",{border:"b base","flex-auto":""},null,-1))]),o.value.id==="overview"?(i(),u("div",ce,[n[15]||(n[15]=e("div",{"flex-auto":""},null,-1)),e("div",ge,[n[10]||(n[10]=e("div",{"i-carbon-commit":"","text-xl":""},null,-1)),e("div",null,[n[2]||(n[2]=e("div",{"text-sm":"",op50:""}," Name ",-1)),e("div",null,v(l.current.name),1)]),n[11]||(n[11]=e("div",{"i-carbon-time":"","text-xl":""},null,-1)),e("div",null,[n[3]||(n[3]=e("div",{"text-sm":"",op50:""}," Build duration ",-1)),e("div",null,v(z(l.current)),1)]),l.current.size?.clientBundle?(i(),u(p,{key:0},[n[5]||(n[5]=e("div",{"i-carbon-cics-program":"","text-xl":""},null,-1)),e("div",null,[n[4]||(n[4]=e("div",{"text-sm":"",op50:""}," Client bundle size ",-1)),e("div",null,v(m(l.current.size.clientBundle)),1)])],64)):x("",!0),l.current.size.nitroBundle?(i(),u(p,{key:1},[n[7]||(n[7]=e("div",{"i-carbon-bare-metal-server":"","text-xl":""},null,-1)),e("div",null,[n[6]||(n[6]=e("div",{"text-sm":"",op50:""}," Nitro bundle size ",-1)),e("div",null,v(m(l.current.size.nitroBundle)),1)])],64)):x("",!0),n[12]||(n[12]=e("div",{"i-carbon-edge-node":"","text-xl":""},null,-1)),e("div",null,[n[8]||(n[8]=e("div",{"text-sm":"",op50:""}," Built ",-1)),e("div",null,v(c(P)(new Date(l.current.endTime))),1)]),n[13]||(n[13]=e("div",{"i-carbon:folder-parent":"","text-xl":""},null,-1)),e("div",null,[n[9]||(n[9]=e("div",{"text-sm":"",op50:""}," Report Path ",-1)),d(D,{filepath:l.current.analyzeDir},null,8,["filepath"])])]),n[16]||(n[16]=e("div",{"flex-auto":""},null,-1)),d(B,{n:"rose",icon:"carbon-delete",onClick:n[0]||(n[0]=r=>T(l.current.name))},{default:a(()=>n[14]||(n[14]=[f(" Delete this report ")])),_:1})])):x("",!0),n._lazyshow1||o.value.id==="bundle-client"?(n._lazyshow1=!0,i(),u(p,null,[A(e("iframe",{src:`${c($)}${l.current.slug}/client.html`,"h-full":"","w-full":""},null,8,["src"]),[[I,o.value.id==="bundle-client"]])],64)):x("v-show-if",!0),n._lazyshow2||o.value.id==="bundle-nitro"?(n._lazyshow2=!0,i(),u(p,null,[A(e("iframe",{src:`${c($)}${l.current.slug}/nitro.html`,"h-full":"","w-full":""},null,8,["src"]),[[I,o.value.id==="bundle-nitro"]])],64)):x("v-show-if",!0),n._lazyshow3||o.value.id==="vite-inspect"?(n._lazyshow3=!0,i(),u(p,null,[A(e("iframe",{src:`${c($)}${l.current.slug}/.vite-inspect/`,"h-full":"","w-full":""},null,8,["src"]),[[I,o.value.id==="vite-inspect"]])],64)):x("v-show-if",!0)])}}}),we={class:"markdown-body"},$e={__name:"analyze-build",setup(N,{expose:y}){return y({frontmatter:{}}),($,b)=>(i(),u("div",we,b[0]||(b[0]=[e("h1",null,"Build Analyze",-1),e("p",null,[f("DevTools provides a build analyze tool to help you understand the size of your app in production. Whenever you start a new build, it runs the command "),e("code",null,"nuxt build --analyze"),f(" and present the output data directly in DevTools for easy browsing and comparing.")],-1)])))}},ze={flex:"~ col"},_e=["onClick"],ke={flex:"~ gap-1 items-center wrap","w-full":"","text-sm":"",op60:""},Be={flex:"~ items-center justify-center wrap",p4:""},Ce={flex:"~ col gap-1","w-250":"",p4:""},Ne={flex:"~ gap-3",mt2:"","justify-end":""},Re=E({__name:"analyze-build",setup(N){const y=X(),w=h(),$=ee(),b=ne("analyze-build:slug",""),o=V(()=>w.value?.builds.find(r=>r.slug===b.value)??w.value?.builds[0]),z=F(!1),m=F(""),T=V(()=>w.value?.builds.some(r=>r.name===m.value.trim()));async function l(){m.value=await S.generateAnalyzeBuildName(),await y.start()&&(oe("analyze-build:start"),C.value={name:m.value,processId:await S.startAnalyzeBuild(await R(),m.value)},z.value&&B())}const n=te();function D(r){return`${((r.endTime-r.startTime)/1e3).toFixed(1)}s`}function B(){C.value?.processId&&(n.value=C.value.processId,$.push("/modules/terminals"))}return le(()=>[{id:"action:analyze-build: start",title:"Start a new analyze build",icon:"i-carbon-edge-node",action:l}]),(r,t)=>{const _=U,L=xe,M=ae,O=ie,W=re,Y=ue,q=me,H=pe,K=se,Q=$e,Z=ve;return i(),u(p,null,[d(O,{"left-size":30},{left:a(()=>[e("div",ze,[(i(!0),u(p,null,G(c(w)?.builds,s=>(i(),u(p,{key:s.slug},[e("button",{flex:"~ col gap1","hover:bg-active":"",p3:"",class:j(s.slug===o.value?.slug?"text-primary bg-active":""),onClick:g=>b.value=s.slug},[e("code",null,v(s.name),1),e("div",ke,[t[4]||(t[4]=e("div",{"i-carbon-time":""},null,-1)),e("span",null,v(D(s)),1),t[5]||(t[5]=e("div",{"flex-auto":""},null,-1)),e("span",null,v(c(P)(new Date(s.endTime))),1)])],10,_e),t[6]||(t[6]=e("div",{"x-divider":""},null,-1))],64))),128)),e("div",Be,[c(C)?(i(),k(_,{key:1,n:"primary",icon:"carbon-circle-dash animate-spin",onClick:t[1]||(t[1]=s=>B())},{default:a(()=>t[8]||(t[8]=[f(" Building... ")])),_:1})):(i(),k(_,{key:0,n:"primary",icon:"carbon-edge-node",onClick:t[0]||(t[0]=s=>l())},{default:a(()=>t[7]||(t[7]=[f(" Start a new build ")])),_:1}))])])]),right:a(()=>[o.value?(i(),k(L,{key:0,current:o.value},null,8,["current"])):(i(),k(M,{key:1}))]),_:1}),d(c(y),null,{default:a(({resolve:s})=>[d(K,{"model-value":!0,onClose:g=>s(!1)},{default:a(()=>[e("div",Ce,[t[13]||(t[13]=e("h3",{class:"text-lg font-medium leading-6",mb2:""}," Start analyze build? ",-1)),t[14]||(t[14]=e("p",{op50:""}," Enter the name of the build: ",-1)),d(W,{modelValue:m.value,"onUpdate:modelValue":t[2]||(t[2]=g=>m.value=g),placeholder:"Build name"},null,8,["modelValue"]),T.value?(i(),k(Y,{key:0,"n-orange":""},{default:a(()=>t[9]||(t[9]=[f(" A build with the same name already exists, continue would overrides the previous build result. ")])),_:1})):x("",!0),t[15]||(t[15]=e("div",{my3:"","x-divider":""},null,-1)),t[16]||(t[16]=e("p",{op50:""}," The following command will be executed in your terminal: ",-1)),d(q,{code:`npx nuxi analyze --no-serve --name=${m.value}`,lang:"bash",px4:"",py2:"",border:"~ base rounded",lines:!1},null,8,["code"]),d(H,{modelValue:z.value,"onUpdate:modelValue":t[3]||(t[3]=g=>z.value=g),mt2:"",n:"primary"},{default:a(()=>t[10]||(t[10]=[f(" Navigate to terminal ")])),_:1},8,["modelValue"]),e("div",Ne,[d(_,{onClick:g=>s(!1)},{default:a(()=>t[11]||(t[11]=[f(" Cancel ")])),_:2},1032,["onClick"]),d(_,{n:"solid primary",onClick:g=>s(!0)},{default:a(()=>t[12]||(t[12]=[f(" Start ")])),_:2},1032,["onClick"])])])]),_:2},1032,["onClose"])]),_:1}),d(Z,null,{default:a(()=>[d(Q)]),_:1})],64)}}});export{Re as default};