/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@bg-dev/nuxt-naiveui@2.0.0/dist/module.mjs
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import path from"node:path";import{defineNuxtModule,createResolver,addPlugin,addImports,addComponent,extendViteConfig,addTypeTemplate}from"@nuxt/kit";import naive from"naive-ui";import{defu}from"defu";import fs from"node:fs";import{loadIcons,getIcon}from"@iconify/vue";import{mergeThemeConfig}from"../dist/runtime/themes/merge.js";const name="@bg-dev/nuxt-naiveui",version="2.0.0",download=e=>new Promise(((o,n)=>{loadIcons(e,((e,i,a)=>{if(a.length)return;const t=e=>`${e.prefix}:${e.name}`;if(i.length){const e=new Error(`❌ 󠀠 [nuxt-naiveui] download failed of ${i.map(t).join(" ")}`);n(e)}const r=e.map((e=>({prefix:e.prefix,icons:{[e.name]:getIcon(t(e))}})));o(r)}))})),makeDir=e=>{fs.existsSync(e)||fs.mkdirSync(e)},makeFile=(e,o)=>{fs.existsSync(e)||fs.writeFileSync(e,o)},save=(e,o)=>{e.forEach((e=>{const n=e.prefix,i=Object.keys(e.icons)[0],a=path.resolve(o,n),t=path.resolve(a,`${i}.json`);makeDir(a),makeFile(t,JSON.stringify(e))}))},removeSavedIcons=(e,o)=>{e.forEach((e=>{const[n,i]=e.split(":");if(n&&i){const e=path.resolve(o,n),a=path.resolve(e,`${i}.json`);fs.rmSync(a),0===fs.readdirSync(e).length&&fs.rmdirSync(e)}}))},getSavedIcons=e=>fs.readdirSync(e,{recursive:!0}).map((e=>path.parse(e.toString()))).filter((e=>e.dir)).map((e=>`${e.dir}:${e.name}`)),COLLECTIONS_URL="https://raw.githubusercontent.com/iconify/icon-sets/master/collections.json";function iconifyVitePlugin(e,o=COLLECTIONS_URL){if("development"===process.env.NODE_ENV)return;let n;const i=new Set;return makeDir(e),{name:"iconify-download-icons",async buildStart(){if(n)return;const e=new Error(`❌ 󠀠 [nuxt-naiveui] failed to fetch collections from ${o}`),i=await fetch(o).then((o=>{if(o.ok)return o.json();throw e})).catch((()=>{throw e})),a=Object.keys(i);n=new RegExp(`("|'|\`)(${a.join("|")}):[a-z0-9]+(?:-[a-z0-9]+)*("|'|\`)`,"g")},transform:e=>(e.match(n)?.forEach((e=>i.add(e.replace(/['"`]/g,"")))),{code:e,map:null}),async buildEnd(){const o=getSavedIcons(e),n=o.filter((e=>!i.has(e)));removeSavedIcons(n,e);const a=new Set;i.forEach((e=>o.includes(e)||a.add(e))),a.size&&await download([...a.values()]).then((o=>save(o,e))),console.log(`✔️ 󠀠 [nuxt-naiveui] download ${a.size} new icons and remove ${n.length} unused icons`)}}}const module=defineNuxtModule({meta:{name:name,version:"2.0.0",configKey:"naiveui",compatibility:{nuxt:">=3.16.0"}},defaults:{colorModePreference:"light",colorModePreferenceCookieName:"naive_color_mode_preference",iconSize:20,iconDownload:!1,iconCollectionsUrl:"https://iconify-icon-sets.netlify.app",themeConfig:{}},hooks:{"prepare:types":({references:e})=>{e.push({types:"naive-ui/volar"})}},setup(e,o){const{resolve:n}=createResolver(import.meta.url);o.options.css.push(n("./runtime/assets/style.css")),o.options.runtimeConfig.public=defu(o.options.runtimeConfig.public,{naiveui:{colorModePreference:e.colorModePreference,colorModePreferenceCookieName:e.colorModePreferenceCookieName,iconDownload:e.iconDownload,iconCollectionsUrl:e.iconCollectionsUrl,iconSize:e.iconSize,spaLoadingTemplate:e.spaLoadingTemplate,themeConfig:mergeThemeConfig(e.colorModePreference,e.themeConfig)}});const i="light-only"==e.colorModePreference||"dark-only"==e.colorModePreference;addPlugin(n("./runtime/plugins/naive.server")),0==i&&addPlugin(n("./runtime/plugins/colorMode")),addImports({name:"useNaiveColorMode",from:n("./runtime/composables/useNaiveColorMode")}),addImports({name:"useNaiveDevice",from:n("./runtime/composables/useNaiveDevice")}),addImports({name:"useNaiveForm",from:n("./runtime/composables/useNaiveForm")}),addImports({name:"useNaiveLoadingBar",from:n("./runtime/composables/useNaiveLoadingBar")}),addImports({name:"useNaiveNotification",from:n("./runtime/composables/useNaiveNotification")}),addComponent({name:"NaiveColorModeSwitch",filePath:n("./runtime/components/NaiveColorModeSwitch.vue")}),addComponent({name:"NaiveConfig",filePath:n("./runtime/components",i?"NaiveConfigStatic.vue":"NaiveConfig.vue")}),addComponent({name:"NaiveIcon",filePath:n("./runtime/components",e?.iconDownload?"NaiveIconOffline.vue":"NaiveIcon.vue")}),addComponent({name:"NaiveNavbar",filePath:n("./runtime/components/NaiveNavbar.vue")}),addComponent({name:"NaiveTabbar",filePath:n("./runtime/components/NaiveTabbar.vue")}),addComponent({name:"NaiveMenuLink",filePath:n("./runtime/components/NaiveMenuLink.vue")}),addComponent({name:"NaiveLayoutSidebar",filePath:n("./runtime/components/NaiveLayoutSidebar.vue")}),addComponent({name:"NaiveLayoutNavbar",filePath:n("./runtime/components/NaiveLayoutNavbar.vue")}),addComponent({name:"NaiveDrawerLink",filePath:n("./runtime/components/NaiveDrawerLink.client.vue")}),addComponent({name:"NaiveLoadingBar",filePath:n("./runtime/components/NaiveLoadingBar.client.vue")}),addComponent({name:"NaiveNotification",filePath:n("./runtime/components/NaiveNotification.client.vue")});const a=Object.keys(naive).filter((e=>/^N[A-Z]|n-[a-z]/.test(e))),t=["NDrawer","NDrawerContent","NModal"];a.forEach((e=>{addComponent({export:e,name:e,filePath:"naive-ui",mode:t.includes(e)?"client":"all"})}));["useDialog","useMessage","useNotification","useLoadingBar","useDialogReactiveList","useThemeVars","useModal"].forEach((e=>{addImports({name:e,as:e,from:"naive-ui"})})),"development"===process.env.NODE_ENV?(o.options.build.transpile.push("naive-ui"),extendViteConfig((e=>{e.plugins||=[],e.plugins.push({name:"fix-transpile-juggle-resize-observer",enforce:"pre",transform(e,o){if(o.includes("@juggle/resize-observer/lib/algorithms/calculateBoxSize.js"))return e.replace("global.navigator && global.navigator.userAgent","global.navigator?.userAgent")}})}))):o.options.build.transpile.push("naive-ui","vueuc","@css-render/vue3-ssr","@iconify/vue"),e?.iconDownload&&extendViteConfig((n=>{n.plugins||=[];const i=path.resolve(o.options.rootDir,"public/iconify");n.plugins.push(iconifyVitePlugin(i,e.iconCollectionsUrl))})),e.spaLoadingTemplate&&"string"!=typeof o.options.spaLoadingTemplate&&(o.options.spaLoadingTemplate=n(`./runtime/templates/${e.spaLoadingTemplate.name}.html`)),addTypeTemplate({filename:"types/naiveui.d.ts",getContents:()=>"\n      import {RouteLocationRaw} from '#vue-router'\n      export interface MenuLinkRoute {\n        label: string\n        icon?: string\n        to?: RouteLocationRaw\n        children?: MenuLinkRoute[]\n      }\n      export interface TabbarRoute {\n        label: string\n        iconSelected: string\n        iconUnselected: string\n        to: RouteLocationRaw\n      }"})}});export{module as default};
//# sourceMappingURL=/sm/820598f4ec2c8e63246190b167f0c32f2952de11a4d965a8de1d8b0f33eadbd7.map