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