import{C as e,Ct as t,Mt as n,S as r,T as i,W as a,X as o,_ as s,dt as c,g as l,h as u,m as d,p as f,s as p,tn as m}from"./vendor/json-editor-vue-9tyg6b65.js";import{lt as h}from"./ready-e441jhq2.js";import{B as g,c as _,i as v,m as y,u as b,w as x}from"./utils-ivfwadyv.js";import{C as S,k as C,w}from"./client-kfvz1zfh.js";import{t as T}from"./nbutton-g8ropw1z.js";import{r as E}from"./state-routes-pcpgumo2.js";import{t as D}from"./telemetry-c1eueoux.js";import{T as O,f as k,p as A}from"#entry";import{t as j}from"./ncode-block-cfw508sn.js";import{t as M}from"./ncheckbox-oir9zn2f.js";import{t as N}from"./nbadge-nhg3871m.js";var P={key:0},F={p4:``,flex:`~ col gap-1`},I={class:`text-lg font-medium leading-6`},L={flex:`~ gap-3`,mt2:``,"justify-end":``},R=Object.assign(i({__name:`NpmVersionCheck`,props:{packageName:{},options:{},showVersion:{type:Boolean,default:!0}},setup(i){let f=i,g=h(),{info:_,update:v,state:y,processId:b,restart:x}=O(f.packageName,f.options),w=t(!0),R=t(!0),z=S(),B=C(),V=E();async function H(){let e=await v(async e=>B.start(e));D(`npm:update`,{packageName:f.packageName,oldVersion:_.value?.current}),e&&R.value&&z.value.push({id:e,message:`${f.packageName} has been updated. Do you want to restart the Nuxt server now?`}),e&&w.value&&(V.value=e,g.push(`/modules/terminals`))}return(t,h)=>{let g=N,v=j,S=M,C=A,E=T,D=k;return a(),s(p,null,[o(t.$slots,`default`,{id:n(b),info:n(_),update:H,state:n(y),restart:n(x)},()=>[n(_)&&i.showVersion?(a(),s(`code`,P,m(`v${n(_).current}`),1)):l(``,!0),n(_)?.latest?(a(),s(p,{key:1},[n(_).needsUpdate?(a(),s(`button`,{key:0,onClick:h[0]||=e=>H()},[e(g,{n:`green`,title:`updates available`,textContent:`updates available`})])):(a(),u(g,{key:1,n:`gray`,title:`latest`,textContent:`latest`}))],64)):l(``,!0)]),e(n(B),null,{default:c(({resolve:t,args:n})=>[e(D,{"model-value":!0,onClose:e=>t(!1)},{default:c(()=>[d(`div`,F,[d(`h3`,I,` Update `+m(f.packageName)+`? `,1),h[8]||=d(`p`,{op50:``},` The following command will be executed in your terminal: `,-1),e(v,{code:n[0],lang:`bash`,my3:``,px4:``,py2:``,border:`~ base rounded`,lines:!1},null,8,[`code`]),e(S,{modelValue:w.value,"onUpdate:modelValue":h[1]||=e=>w.value=e,n:`primary`},{default:c(()=>[...h[3]||=[r(` Navigate to terminal `,-1)]]),_:1},8,[`modelValue`]),e(S,{modelValue:R.value,"onUpdate:modelValue":h[2]||=e=>R.value=e,n:`primary`},{default:c(()=>[...h[4]||=[r(` Restart Nuxt server after update `,-1)]]),_:1},8,[`modelValue`]),d(`div`,L,[e(C,{n:`sm amber`,"flex-auto":``,icon:`i-carbon-data-backup`},{default:c(()=>[...h[5]||=[r(` Please make sure to backup your project first. `,-1)]]),_:1}),e(E,{onClick:e=>t(!1)},{default:c(()=>[...h[6]||=[r(` Cancel `,-1)]]),_:1},8,[`onClick`]),e(E,{n:`solid primary`,onClick:e=>t(!0)},{default:c(()=>[...h[7]||=[r(` Update `,-1)]]),_:1},8,[`onClick`])])])]),_:2},1032,[`onClose`])]),_:1})],64)}}}),{__name:`NpmVersionCheck`}),z=[`pages`,`meta`,`components`,`imports`,`nuxt-config-schema`,`@nuxt/devtools`,`@nuxt/telemetry`];function B(){return y(`getModulesList`,async()=>(await g(`https://api.nuxt.com/modules?version=3`)).modules.filter(e=>!z.includes(e.npm)&&e.compatibility.nuxt.includes(`>=3`)))}function V(){return w(`installed-modules`,()=>{let e=x(),t=B();return f(()=>(e.value?._installedModules||[]).map(n=>{if(!n.entryPath)return;let r=!!(n.entryPath&&_(n.entryPath)),i=n.meta?.name?n.meta?.name:n.entryPath?r?v(n.entryPath):e.value?.rootDir?b(n.entryPath,e.value?.rootDir).path:void 0:void 0;return{name:i,isPackageModule:r,isUninstallable:!!e.value?.modules?.includes(i),info:t.value?.find(e=>e.npm===i)||t.value?.find(e=>e.name===i),...n}}).filter(e=>e&&(!e.name||!z.includes(e.name))))})}export{B as n,R as r,V as t};