@donotdev/core 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vite/index.js CHANGED
@@ -1,11 +1,11 @@
1
- var $s=Object.defineProperty;var Ke=(n,e)=>()=>(n&&(e=n(n=0)),e);var Es=(n,e)=>{for(var t in e)$s(n,t,{get:e[t],enumerable:!0})};function wt(n,e=null){let t=se[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function je(n){return vt[n]||vt.base}var Xe,z,H,ue,Qe,Oe,Le,se,me,yt,et,tt,Te,bt,st,vt,W=Ke(()=>{"use strict";Xe={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},z={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env",blog:"@donotdev/blog-content"},H={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},ue={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configEnv:"src/config/dndev-config-env.js",configServer:"src/config/dndev-config-server.js",blogContent:"src/content/blog/blog-content.generated.ts"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},Qe={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},Oe={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},Le={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},se={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${Le.SOURCE_EAGER}/*_*.json`],lazy:[`${Le.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},me={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","zustand/middleware","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async"],optionalFeatures:[],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},yt=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],et=["@donotdev/core/functions","@donotdev/core/server"],tt={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},Te={inter:[300,400,600,700],"playfair-display":[400,500,600,700],roboto:[400,700],"space-grotesk":[300,400,500,600,700],"press-start-2p":[400]},bt={en:["latin"],fr:["latin"],es:["latin"],de:["latin"],it:["latin"],pt:["latin"],nl:["latin"],da:["latin"],sv:["latin"],nb:["latin"],fi:["latin"],pl:["latin"],cs:["latin"],sk:["latin"],hr:["latin"],sl:["latin"],hu:["latin"],ro:["latin"],et:["latin"],lv:["latin"],lt:["latin"],mt:["latin"],ga:["latin"],ca:["latin"],eu:["latin"],gl:["latin"],af:["latin"],sw:["latin"],tr:["latin"],id:["latin"],ms:["latin"],tl:["latin"],vi:["latin","vietnamese"],ru:["latin","cyrillic"],bg:["latin","cyrillic"],uk:["latin","cyrillic"],sr:["latin","cyrillic"],mk:["latin","cyrillic"],be:["latin","cyrillic"],el:["latin","greek"],zh:[],ja:[],ko:[],ar:[],he:[],th:[],hi:[],bn:[],ta:[]},st=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],vt={base:{absolute:!0,onlyFiles:!0,ignore:se.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...se.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...se.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:se.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:se.globalIgnore}}});import*as A from"node:fs";import"node:fs";import{createRequire as Ts}from"node:module";import{resolve as Fe,join as ve,dirname as ye,relative as xt,normalize as Fs,sep as St,extname as Cs}from"node:path";import{fileURLToPath as Is}from"node:url";import Ms from"fast-glob";function Pt(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var Ee,B,Rt,$,U=Ke(()=>{"use strict";W();Ee={getGlobOptionsFor:je||void 0,SCAN_PATTERNS:se||void 0,getPatternsFor:wt||void 0,I18N_PATHS:Le||void 0},B={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};Rt={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},$=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,n._instance=this}normalizePath(e){if(!e)return"";try{return Fs(e).split(St).join("/")}catch{return String(e).split(St).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=xt(t,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(ye(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=Ts(ve(s,"package.json")).resolve(e);return this.normalizePath(o)}catch{return null}}resolveFrameworkPackage(e,t=null){let s=this.resolvePackage(`${e}/package.json`,t);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let a=e.replace("@donotdev/",""),i=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(i))return i;if(["auth","billing","crud","oauth"].includes(a)){let l=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(l))return l}if(a==="firebase"){let l=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(l))return l}}let r=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(r))return r;let o=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(o)?o:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),s=Fe(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=Fe(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=Fe(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=A.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:Cs(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await A.promises.readFile(e);let a=await A.promises.readFile(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&B.warn(`Failed to read file: ${e}`,a),null}}readSync(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return A.readFileSync(e);let a=A.readFileSync(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&B.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),c=this.normalizePath(ye(l)),u=this.pathExists(l);if(u&&!o)return i&&B.info(`Skipping existing file: ${l}`),!1;if(a)return B.info(`[DRY RUN] Would write file: ${l}`),!0;try{await A.promises.mkdir(c,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await Pt(async()=>(Buffer.isBuffer(g)?await A.promises.writeFile(l,g):await A.promises.writeFile(l,g,"utf8"),i&&B.info(`${u?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),c=this.normalizePath(ye(l)),u=this.pathExists(l);if(u&&!o)return i&&B.info(`Skipping existing file: ${l}`),!1;if(a)return B.info(`[DRY RUN] Would write file: ${l}`),!0;try{A.mkdirSync(c,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?A.writeFileSync(l,g):A.writeFileSync(l,g,"utf8"),i&&B.info(`${u?"Updated":"Created"} file: ${l}`),!0}catch(f){throw new Error(`Failed to write file: ${l}: ${f instanceof Error?f.message:String(f)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&B.info(`Skipping existing file: ${i}`),!1;if(o)return B.info(`[DRY RUN] Would copy file: ${i}`),!0;let c=this.normalizePath(ye(i));try{await A.promises.mkdir(c,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return await Pt(async()=>(await A.promises.copyFile(e,i),a&&B.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&B.info(`Skipping existing file: ${i}`),!1;if(o)return B.info(`[DRY RUN] Would copy file: ${i}`),!0;let c=this.normalizePath(ye(i));try{A.mkdirSync(c,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return A.copyFileSync(e,i),a&&B.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return A.existsSync(e)}catch(s){return t||B.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return A.existsSync(t)||A.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return A.readdirSync(e,t)}catch(s){return this.options.debug&&B.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return A.statSync(e)}catch(t){return this.options.debug&&B.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return A.realpathSync(e)}watch(e,t,s){return A.watch(e,t,s)}lstatSync(e){try{return A.lstatSync(e)}catch(t){return this.options.debug&&B.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await A.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{A.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await A.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){A.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return A.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=ve(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(Fe(e)),s=this.getAppRoot(),r=xt(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(ve(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),i=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:Ee.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=Ee.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),r=this.resolveFrameworkPackage("@donotdev/core");if(!r)return null;let o=this.normalizePath(ve(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await Ms(e,t)).map(r=>{let o=typeof r=="string"?r:r.path;return this.normalizePath(o)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let u of s)if(typeof u!="string"||u.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let r=this.getAppRoot(),o=Ee.getGlobOptionsFor?Ee.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),i=e.framework.map(u=>{let p=this.normalizePath(u);return p.startsWith(a)?p.slice(a.length+1):p}),l=e.consumer.map(u=>{let p=this.normalizePath(u);return p.startsWith(a)?p.slice(a.length+1):p}),c={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let u=i.length>0?await this._globWithNormalization(i,c):[],p=await this._globWithNormalization(l,c);return{frameworkFiles:u,consumerFiles:p}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!Ee.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),s=this.getRepoRoot();if(e==="i18n"&&(!t||t===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let r=Ee.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,c={eager:l.eager.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),lazy:l.lazy.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),framework:{eager:o?(l.framework?.eager||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean))},all:[]};return c.all=[...c.eager,...c.lazy,...c.framework.eager,...c.framework.lazy],c}let a=r,i={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=ye(Is(import.meta.url));return this.normalizePath(Fe(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(ve(t,Rt.TOOLING)),a=this.normalizePath(ve(t,Rt.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let i=ve(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(ve(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(ye(t))===t)return t;let c=this.normalizePath(ye(t));if(c===t)break;t=c,s++}return this.normalizePath(e)}}});var ws={};Es(ws,{createDndevPlugin:()=>qr});import{execSync as fe,execFileSync as De,spawn as wr}from"node:child_process";function J(){return $.getInstance()}function ee(){return J().getRepoRoot()}function hs(){return J().resolveRepoPath(".dndev")}function h(n,e,t=200){n.writeHead(t,{"Content-Type":"application/json"}),n.end(JSON.stringify(e))}function he(n,e=xr){return new Promise((t,s)=>{let r="",o=0;n.on("data",a=>{if(o+=a.length,o>e){n.destroy(),s(new Error("Request body too large"));return}r+=a.toString()}),n.on("end",()=>t(r)),n.on("error",s)})}function Sr(n){let e=n.lastIndexOf(".");return e===-1?"":n.slice(e).toLowerCase()}function Pr(){let n=J(),e=[],t=process.env.HOME||process.env.USERPROFILE||"";try{let r=process.platform==="win32"?"where node":"which node",o=fe(r,{encoding:"utf8"}).trim().split(`
2
- `)[0];e.push(o)}catch{}let s=[process.env.NVM_DIR,n.resolvePath(".nvm",t)].filter(Boolean);for(let r of s)try{let o=n.resolvePath("versions/node",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/bin/node`,o))}catch{}if(process.env.NVM_BIN&&e.push(n.resolvePath("node",process.env.NVM_BIN)),process.platform==="win32"){e.push("C:\\Program Files\\nodejs\\node.exe");let r=process.env.APPDATA||"";if(r)try{let o=n.resolvePath("nvm",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/node.exe`,o))}catch{}}else e.push("/usr/local/bin/node","/usr/bin/node");for(let r of e)try{let o=n.realpathSync(r);if(o.includes("bun")||!n.pathExists(o))continue;return r}catch{continue}return"node"}function vs(n){if(!n||typeof n!="string"||n.includes("\0"))return!1;let e=n.split(/[/\\]/).filter(Boolean);for(let t of e)if(t==="."||t===".."||t==="node_modules"||t===".git"||t.startsWith(".")&&t!==".dndev")return!1;return!0}function Rr(n){return n.includes("..")?!1:n.startsWith(".dndev/")||n.startsWith("docs/")||n.startsWith("guides/")}function ys(n){let e=J(),t=e.getRepoRoot(),s=e.resolvePath(n,t),r=e.normalizePath(t),o=e.normalizePath(s);return!o.startsWith(r+"/")&&o!==r?null:s}async function Er(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return h(e,{error:"path parameter required"},400);if(!vs(s))return h(e,{error:"Access denied"},403);let r=ys(s);if(!r)return h(e,{error:"Access denied"},403);let o=J();if(!o.pathExists(r))return h(e,{error:"File not found"},404);let a=Sr(r);if($r.has(a)){let i=o.readSync(r,{format:"buffer"});return i?(e.writeHead(200,{"Content-Type":bs[a]||"application/octet-stream","Content-Length":i.byteLength}),void e.end(Buffer.from(i))):h(e,{error:"Failed to read file"},500)}if(a===".json")try{let i=await o.read(r);return i===null?h(e,{error:"Failed to read file"},500):h(e,{path:s,content:i})}catch{return h(e,{error:"Invalid JSON"},500)}try{let i=await o.read(r,{format:"text"});if(i===null)return h(e,{error:"Failed to read file"},500);h(e,{path:s,content:i})}catch{h(e,{error:"Failed to read file"},500)}}function _r(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("dir"),r=J(),o=r.getRepoRoot(),a=[],i=new Set(["node_modules",".git","dist","build",".next",".expo"]);function l(u,p){try{let g=r.readdirSync(u,{withFileTypes:!0});for(let f of g){let d=p?`${p}/${f.name}`:f.name;f.isDirectory()&&i.has(f.name)||(f.isDirectory()?(a.push({path:d,name:f.name,isDirectory:!0}),l(r.resolvePath(f.name,u),d)):f.name.endsWith(".md")&&a.push({path:d,name:f.name,isDirectory:!1}))}}catch{}}let c=[".dndev","docs","guides"];if(s){if(s.includes("..")||s.includes("\0"))return h(e,{error:"Access denied"},403);if(!c.includes(s)&&!c.some(f=>s.startsWith(f+"/")))return h(e,{error:"Directory not allowed"},403);let u=r.resolvePath(s,o),p=r.normalizePath(o);if(!r.normalizePath(u).startsWith(p+"/"))return h(e,{error:"Access denied"},403);r.pathExists(u)&&(a.push({path:s,name:r.getBasename(s),isDirectory:!0}),l(u,s))}else{for(let u of c){let p=r.resolveRepoPath(u);r.pathExists(p)&&(a.push({path:u,name:u,isDirectory:!0}),l(p,u))}try{let u=r.readdirSync(o,{withFileTypes:!0});for(let p of u)!p.isDirectory()&&p.name.endsWith(".md")&&a.push({path:p.name,name:p.name,isDirectory:!1})}catch{}}h(e,{entries:a})}async function kr(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return h(e,{error:"path parameter required"},400);if(!vs(s))return h(e,{error:"Access denied"},403);if(!Rr(s))return h(e,{error:"Write not allowed to this path"},403);let r=ys(s);if(!r)return h(e,{error:"Access denied"},403);try{let o=await he(n),{content:a}=JSON.parse(o);if(a===void 0)return h(e,{error:"content field required"},400);let i=typeof a=="string"?a:JSON.stringify(a,null,2);await J().write(r,i,{overwrite:!0}),h(e,{ok:!0})}catch{h(e,{error:"Failed to write file"},500)}}async function Dr(n,e){try{let t=await he(n),{line:s,checked:r}=JSON.parse(t);if(typeof s!="number")return h(e,{error:"line number required"},400);let o=J(),a=o.resolveRepoPath(".dndev/implementation.md");if(!o.pathExists(a))return h(e,{error:"implementation.md not found"},404);let i=await o.read(a,{format:"text"});if(i===null)return h(e,{error:"Failed to read file"},500);let l=i.split(`
1
+ var Es=Object.defineProperty;var Ke=(n,e)=>()=>(n&&(e=n(n=0)),e);var _s=(n,e)=>{for(var t in e)Es(n,t,{get:e[t],enumerable:!0})};function wt(n,e=null){let t=re[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function je(n){return vt[n]||vt.base}var Xe,M,q,pe,Qe,Oe,Le,re,me,yt,et,tt,Te,bt,st,vt,G=Ke(()=>{"use strict";Xe={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},M={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env",blog:"@donotdev/blog-content"},q={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},pe={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configEnv:"src/config/dndev-config-env.js",configServer:"src/config/dndev-config-server.js",blogContent:"src/content/blog/blog-content.generated.ts"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},Qe={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},Oe={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},Le={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},re={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${Le.SOURCE_EAGER}/*_*.json`],lazy:[`${Le.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},me={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","zustand/middleware","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async"],optionalFeatures:[],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},yt=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],et=["@donotdev/core/functions","@donotdev/core/server"],tt={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},Te={inter:[300,400,600,700],"playfair-display":[400,500,600,700],roboto:[400,700],"space-grotesk":[300,400,500,600,700],"press-start-2p":[400]},bt={en:["latin"],fr:["latin"],es:["latin"],de:["latin"],it:["latin"],pt:["latin"],nl:["latin"],da:["latin"],sv:["latin"],nb:["latin"],fi:["latin"],pl:["latin"],cs:["latin"],sk:["latin"],hr:["latin"],sl:["latin"],hu:["latin"],ro:["latin"],et:["latin"],lv:["latin"],lt:["latin"],mt:["latin"],ga:["latin"],ca:["latin"],eu:["latin"],gl:["latin"],af:["latin"],sw:["latin"],tr:["latin"],id:["latin"],ms:["latin"],tl:["latin"],vi:["latin","vietnamese"],ru:["latin","cyrillic"],bg:["latin","cyrillic"],uk:["latin","cyrillic"],sr:["latin","cyrillic"],mk:["latin","cyrillic"],be:["latin","cyrillic"],el:["latin","greek"],zh:[],ja:[],ko:[],ar:[],he:[],th:[],hi:[],bn:[],ta:[]},st=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],vt={base:{absolute:!0,onlyFiles:!0,ignore:re.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...re.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...re.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:re.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:re.globalIgnore}}});import*as D from"node:fs";import"node:fs";import{createRequire as Fs}from"node:module";import{resolve as Fe,join as ve,dirname as ye,relative as xt,normalize as Cs,sep as St,extname as Is}from"node:path";import{fileURLToPath as Ms}from"node:url";import zs from"fast-glob";function Pt(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var _e,B,Rt,R,W=Ke(()=>{"use strict";G();_e={getGlobOptionsFor:je||void 0,SCAN_PATTERNS:re||void 0,getPatternsFor:wt||void 0,I18N_PATHS:Le||void 0},B={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};Rt={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},R=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,n._instance=this}normalizePath(e){if(!e)return"";try{return Cs(e).split(St).join("/")}catch{return String(e).split(St).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=xt(t,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(ye(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=Fs(ve(s,"package.json")).resolve(e);return this.normalizePath(o)}catch{return null}}resolveFrameworkPackage(e,t=null){let s=this.resolvePackage(`${e}/package.json`,t);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let a=e.replace("@donotdev/",""),i=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(i))return i;if(["auth","billing","crud","oauth"].includes(a)){let l=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(l))return l}if(a==="firebase"){let l=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(l))return l}}let r=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(r))return r;let o=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(o)?o:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),s=Fe(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=Fe(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=Fe(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=D.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:Is(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await D.promises.readFile(e);let a=await D.promises.readFile(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&B.warn(`Failed to read file: ${e}`,a),null}}readSync(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return D.readFileSync(e);let a=D.readFileSync(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&B.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),c=this.normalizePath(ye(l)),u=this.pathExists(l);if(u&&!o)return i&&B.info(`Skipping existing file: ${l}`),!1;if(a)return B.info(`[DRY RUN] Would write file: ${l}`),!0;try{await D.promises.mkdir(c,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await Pt(async()=>(Buffer.isBuffer(g)?await D.promises.writeFile(l,g):await D.promises.writeFile(l,g,"utf8"),i&&B.info(`${u?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),c=this.normalizePath(ye(l)),u=this.pathExists(l);if(u&&!o)return i&&B.info(`Skipping existing file: ${l}`),!1;if(a)return B.info(`[DRY RUN] Would write file: ${l}`),!0;try{D.mkdirSync(c,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?D.writeFileSync(l,g):D.writeFileSync(l,g,"utf8"),i&&B.info(`${u?"Updated":"Created"} file: ${l}`),!0}catch(f){throw new Error(`Failed to write file: ${l}: ${f instanceof Error?f.message:String(f)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&B.info(`Skipping existing file: ${i}`),!1;if(o)return B.info(`[DRY RUN] Would copy file: ${i}`),!0;let c=this.normalizePath(ye(i));try{await D.promises.mkdir(c,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return await Pt(async()=>(await D.promises.copyFile(e,i),a&&B.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&B.info(`Skipping existing file: ${i}`),!1;if(o)return B.info(`[DRY RUN] Would copy file: ${i}`),!0;let c=this.normalizePath(ye(i));try{D.mkdirSync(c,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return D.copyFileSync(e,i),a&&B.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return D.existsSync(e)}catch(s){return t||B.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return D.existsSync(t)||D.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return D.readdirSync(e,t)}catch(s){return this.options.debug&&B.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return D.statSync(e)}catch(t){return this.options.debug&&B.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return D.realpathSync(e)}watch(e,t,s){return D.watch(e,t,s)}lstatSync(e){try{return D.lstatSync(e)}catch(t){return this.options.debug&&B.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await D.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{D.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await D.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){D.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return D.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=ve(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(Fe(e)),s=this.getAppRoot(),r=xt(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(ve(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),i=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:_e.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=_e.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),r=this.resolveFrameworkPackage("@donotdev/core");if(!r)return null;let o=this.normalizePath(ve(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await zs(e,t)).map(r=>{let o=typeof r=="string"?r:r.path;return this.normalizePath(o)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let u of s)if(typeof u!="string"||u.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let r=this.getAppRoot(),o=_e.getGlobOptionsFor?_e.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),i=e.framework.map(u=>{let p=this.normalizePath(u);return p.startsWith(a)?p.slice(a.length+1):p}),l=e.consumer.map(u=>{let p=this.normalizePath(u);return p.startsWith(a)?p.slice(a.length+1):p}),c={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let u=i.length>0?await this._globWithNormalization(i,c):[],p=await this._globWithNormalization(l,c);return{frameworkFiles:u,consumerFiles:p}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!_e.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),s=this.getRepoRoot();if(e==="i18n"&&(!t||t===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let r=_e.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,c={eager:l.eager.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),lazy:l.lazy.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),framework:{eager:o?(l.framework?.eager||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean))},all:[]};return c.all=[...c.eager,...c.lazy,...c.framework.eager,...c.framework.lazy],c}let a=r,i={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=ye(Ms(import.meta.url));return this.normalizePath(Fe(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(ve(t,Rt.TOOLING)),a=this.normalizePath(ve(t,Rt.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let i=ve(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(ve(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(ye(t))===t)return t;let c=this.normalizePath(ye(t));if(c===t)break;t=c,s++}return this.normalizePath(e)}}});var ws={};_s(ws,{createDndevPlugin:()=>Yr});import{execSync as de,execFileSync as Ae,spawn as xr}from"node:child_process";function Y(){return R.getInstance()}function ee(){return Y().getRepoRoot()}function hs(){return Y().resolveRepoPath(".dndev")}function h(n,e,t=200){n.writeHead(t,{"Content-Type":"application/json"}),n.end(JSON.stringify(e))}function he(n,e=Sr){return new Promise((t,s)=>{let r="",o=0;n.on("data",a=>{if(o+=a.length,o>e){n.destroy(),s(new Error("Request body too large"));return}r+=a.toString()}),n.on("end",()=>t(r)),n.on("error",s)})}function Pr(n){let e=n.lastIndexOf(".");return e===-1?"":n.slice(e).toLowerCase()}function Rr(){let n=Y(),e=[],t=process.env.HOME||process.env.USERPROFILE||"";try{let r=process.platform==="win32"?"where node":"which node",o=de(r,{encoding:"utf8"}).trim().split(`
2
+ `)[0];e.push(o)}catch{}let s=[process.env.NVM_DIR,n.resolvePath(".nvm",t)].filter(Boolean);for(let r of s)try{let o=n.resolvePath("versions/node",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/bin/node`,o))}catch{}if(process.env.NVM_BIN&&e.push(n.resolvePath("node",process.env.NVM_BIN)),process.platform==="win32"){e.push("C:\\Program Files\\nodejs\\node.exe");let r=process.env.APPDATA||"";if(r)try{let o=n.resolvePath("nvm",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/node.exe`,o))}catch{}}else e.push("/usr/local/bin/node","/usr/bin/node");for(let r of e)try{let o=n.realpathSync(r);if(o.includes("bun")||!n.pathExists(o))continue;return r}catch{continue}return"node"}function vs(n){if(!n||typeof n!="string"||n.includes("\0"))return!1;let e=n.split(/[/\\]/).filter(Boolean);for(let t of e)if(t==="."||t===".."||t==="node_modules"||t===".git"||t.startsWith(".")&&t!==".dndev")return!1;return!0}function $r(n){return n.includes("..")?!1:n.startsWith(".dndev/")||n.startsWith("docs/")||n.startsWith("guides/")}function ys(n){let e=Y(),t=e.getRepoRoot(),s=e.resolvePath(n,t),r=e.normalizePath(t),o=e.normalizePath(s);return!o.startsWith(r+"/")&&o!==r?null:s}async function _r(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return h(e,{error:"path parameter required"},400);if(!vs(s))return h(e,{error:"Access denied"},403);let r=ys(s);if(!r)return h(e,{error:"Access denied"},403);let o=Y();if(!o.pathExists(r))return h(e,{error:"File not found"},404);let a=Pr(r);if(Er.has(a)){let i=o.readSync(r,{format:"buffer"});return i?(e.writeHead(200,{"Content-Type":bs[a]||"application/octet-stream","Content-Length":i.byteLength}),void e.end(Buffer.from(i))):h(e,{error:"Failed to read file"},500)}if(a===".json")try{let i=await o.read(r);return i===null?h(e,{error:"Failed to read file"},500):h(e,{path:s,content:i})}catch{return h(e,{error:"Invalid JSON"},500)}try{let i=await o.read(r,{format:"text"});if(i===null)return h(e,{error:"Failed to read file"},500);h(e,{path:s,content:i})}catch{h(e,{error:"Failed to read file"},500)}}function kr(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("dir"),r=Y(),o=r.getRepoRoot(),a=[],i=new Set(["node_modules",".git","dist","build",".next",".expo"]);function l(u,p){try{let g=r.readdirSync(u,{withFileTypes:!0});for(let f of g){let d=p?`${p}/${f.name}`:f.name;f.isDirectory()&&i.has(f.name)||(f.isDirectory()?(a.push({path:d,name:f.name,isDirectory:!0}),l(r.resolvePath(f.name,u),d)):f.name.endsWith(".md")&&a.push({path:d,name:f.name,isDirectory:!1}))}}catch{}}let c=[".dndev","docs","guides"];if(s){if(s.includes("..")||s.includes("\0"))return h(e,{error:"Access denied"},403);if(!c.includes(s)&&!c.some(f=>s.startsWith(f+"/")))return h(e,{error:"Directory not allowed"},403);let u=r.resolvePath(s,o),p=r.normalizePath(o);if(!r.normalizePath(u).startsWith(p+"/"))return h(e,{error:"Access denied"},403);r.pathExists(u)&&(a.push({path:s,name:r.getBasename(s),isDirectory:!0}),l(u,s))}else{for(let u of c){let p=r.resolveRepoPath(u);r.pathExists(p)&&(a.push({path:u,name:u,isDirectory:!0}),l(p,u))}try{let u=r.readdirSync(o,{withFileTypes:!0});for(let p of u)!p.isDirectory()&&p.name.endsWith(".md")&&a.push({path:p.name,name:p.name,isDirectory:!1})}catch{}}h(e,{entries:a})}async function Dr(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return h(e,{error:"path parameter required"},400);if(!vs(s))return h(e,{error:"Access denied"},403);if(!$r(s))return h(e,{error:"Write not allowed to this path"},403);let r=ys(s);if(!r)return h(e,{error:"Access denied"},403);try{let o=await he(n),{content:a}=JSON.parse(o);if(a===void 0)return h(e,{error:"content field required"},400);let i=typeof a=="string"?a:JSON.stringify(a,null,2);await Y().write(r,i,{overwrite:!0}),h(e,{ok:!0})}catch{h(e,{error:"Failed to write file"},500)}}async function Ar(n,e){try{let t=await he(n),{line:s,checked:r}=JSON.parse(t);if(typeof s!="number")return h(e,{error:"line number required"},400);let o=Y(),a=o.resolveRepoPath(".dndev/implementation.md");if(!o.pathExists(a))return h(e,{error:"implementation.md not found"},404);let i=await o.read(a,{format:"text"});if(i===null)return h(e,{error:"Failed to read file"},500);let l=i.split(`
3
3
  `);if(s<0||s>=l.length)return h(e,{error:"Line out of range"},400);let c=l[s];l[s]=r?c.replace("- [ ]","- [x]"):c.replace("- [x]","- [ ]"),await o.write(a,l.join(`
4
- `),{overwrite:!0}),h(e,{ok:!0,line:l[s]})}catch{h(e,{error:"Failed to update progress"},500)}}async function Ar(n,e){try{let t=await he(n),{id:s,data:r}=JSON.parse(t);if(!s||!r)return h(e,{error:"id and data required"},400);if(!/^[\w-]+$/.test(s))return h(e,{error:"Invalid screenshot ID"},400);let o=J(),a=o.resolveRepoPath(".dndev/bugs");o.ensureDirSync(a);let i=Buffer.from(r,"base64"),l=o.resolvePath(`${s}.png`,a);await o.write(l,i,{overwrite:!0}),h(e,{ok:!0,path:`.dndev/bugs/${s}.png`})}catch{h(e,{error:"Failed to save screenshot"},500)}}async function Nr(n,e){try{let t=await he(n),{action:s,phase:r}=JSON.parse(t);if(!s||typeof r!="number")return h(e,{error:"action and phase required"},400);let o=J(),a=hs();o.ensureDirSync(a);let i=o.resolvePath("protocol.json",a),l={currentPhase:0,phases:{}};if(o.pathExists(i))try{let c=await o.read(i);c&&(l=c)}catch{}s==="start"?(l.currentPhase=r,l.phases[r]||(l.phases[r]={}),l.phases[r].status="active",l.phases[r].startedAt=new Date().toISOString()):s==="complete"&&(l.phases[r]||(l.phases[r]={}),l.phases[r].status="completed",l.phases[r].completedAt=new Date().toISOString()),await o.write(i,l,{overwrite:!0}),h(e,{ok:!0,protocol:l})}catch{h(e,{error:"Failed to update phase"},500)}}function Or(n,e){try{let t=ee(),s=fe("git rev-parse --short HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim(),r=fe("git rev-parse --abbrev-ref HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim();h(e,{commit:s,branch:r})}catch{h(e,{commit:"unknown",branch:"unknown"})}}async function Tr(n,e){try{let t=await he(n),s=JSON.parse(t);if(!s.id||!s.type||!s.result)return h(e,{error:"id, type, and result required"},400);let r=J(),o=hs();r.ensureDirSync(o);let a=r.resolvePath("health.json",o),i={actions:[]};if(r.pathExists(a))try{let c=await r.read(a);c&&(i=c)}catch{}Array.isArray(i.actions)||(i.actions=[]);let l=i.actions.findIndex(c=>c.id===s.id);l>=0?i.actions[l]={...i.actions[l],...s}:i.actions.unshift(s),await r.write(a,i,{overwrite:!0}),h(e,{ok:!0})}catch{h(e,{error:"Failed to append action"},500)}}function Fr(n,e){let t=J(),s=t.resolveRepoPath("apps");try{let o=t.readdirSync(s).filter(a=>{if(a==="dndev")return!1;let i=t.resolvePath(a,s);return t.statSync(i)?.isDirectory()&&t.pathExists(t.resolvePath("package.json",i))}).map(a=>{try{let i=t.resolvePath(`${a}/package.json`,s),l=t.readSync(i);return{name:a,packageName:l?.name||a}}catch{return{name:a,packageName:a}}});h(e,{apps:o})}catch{h(e,{apps:[]})}}function Cr(n,e){try{let t=ee(),s=fe("git worktree list --porcelain",{cwd:t,encoding:"utf-8",timeout:5e3}),r=[],o={};for(let a of s.split(`
5
- `))a.startsWith("worktree ")?(o.path&&r.push(o),o={path:a.slice(9)}):a.startsWith("HEAD ")?o.head=a.slice(5):a.startsWith("branch ")?(o.branch=a.slice(7),o.shortBranch=o.branch.replace("refs/heads/","")):a==="detached"&&(o.detached=!0);o.path&&r.push(o),h(e,{worktrees:r})}catch(t){h(e,{error:t.message},500)}}async function Ir(n,e){try{let t=await he(n),{branch:s}=JSON.parse(t);if(!s||typeof s!="string")return h(e,{error:"branch required"},400);if(!/^[\w][\w./-]*$/.test(s))return h(e,{error:"Invalid branch name"},400);let r=ee(),o=J(),a=o.resolvePath("..",r),i=o.getBasename(r),l=o.resolvePath(`${i}-${s.replace(/\//g,"-")}`,a);De("git",["worktree","add",l,"-b",s],{cwd:r,encoding:"utf-8",timeout:3e4}),h(e,{ok:!0,path:l,branch:s})}catch(t){h(e,{error:t.message},500)}}async function Mr(n,e){try{let t=await he(n),{path:s}=JSON.parse(t);if(!s||typeof s!="string")return h(e,{error:"path required"},400);let r=ee();De("git",["worktree","remove",s,"--force"],{cwd:r,encoding:"utf-8",timeout:1e4}),h(e,{ok:!0})}catch(t){h(e,{error:t.message},500)}}function zr(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("branch");if(!s)return h(e,{error:"branch required"},400);if(!/^[\w][\w./-]*$/.test(s))return h(e,{error:"Invalid branch name"},400);let r=ee(),o=De("git",["diff",`main...${s}`,"--stat"],{cwd:r,encoding:"utf-8",timeout:1e4}).trim(),a=De("git",["diff",`main...${s}`],{cwd:r,encoding:"utf-8",timeout:3e4});h(e,{stat:o,diff:a})}catch(t){h(e,{error:t.message},500)}}async function Lr(n,e){try{let t=await he(n),{branch:s,title:r,bodyText:o}=JSON.parse(t);if(!s)return h(e,{error:"branch required"},400);let a=ee(),i=["pr","create","--head",s];r&&i.push("--title",r),o&&i.push("--body",o);let l=De("gh",i,{cwd:a,encoding:"utf-8",timeout:3e4}).trim();h(e,{ok:!0,url:l})}catch(t){h(e,{error:t.message},500)}}function jr(n,e){try{let t=ee(),s=fe("git remote get-url origin",{cwd:t,encoding:"utf-8",timeout:5e3}).trim(),r=null;s.includes("github.com")?r="github":s.includes("gitlab")&&(r="gitlab"),h(e,{platform:r,remoteUrl:s})}catch{h(e,{platform:null,remoteUrl:null})}}function Ur(n,e){try{let t=ee(),s=fe("gh pr list --json number,title,state,author,headRefName,url,isDraft,reviewDecision,statusCheckRollup --limit 50",{cwd:t,encoding:"utf-8",timeout:15e3});h(e,{prs:JSON.parse(s)})}catch(t){h(e,{prs:[],error:t.message})}}function Wr(n,e){try{let t=ee(),s=fe("gh issue list --json number,title,state,labels,assignees --limit 50",{cwd:t,encoding:"utf-8",timeout:15e3});h(e,{issues:JSON.parse(s)})}catch(t){h(e,{issues:[],error:t.message})}}function Gr(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("number");if(!s||!/^\d+$/.test(s))return h(e,{error:"PR number required"},400);let r=ee(),o=fe(`gh pr diff ${s}`,{cwd:r,encoding:"utf-8",timeout:3e4});h(e,{diff:o})}catch(t){h(e,{error:t.message},500)}}function Br(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("number");if(!s||!/^\d+$/.test(s))return h(e,{error:"PR number required"},400);let r=ee(),o=fe(`gh pr checks ${s} --json name,state,status`,{cwd:r,encoding:"utf-8",timeout:15e3});h(e,{checks:JSON.parse(o)})}catch(t){h(e,{checks:[],error:t.message})}}async function Vr(n,e){try{let t=await he(n),{number:s,action:r,comment:o}=JSON.parse(t);if(!s||!r)return h(e,{error:"number and action required"},400);let a=["approve","request-changes","comment"];if(!a.includes(r))return h(e,{error:`Invalid action. Use: ${a.join(", ")}`},400);let i=ee(),l=["pr","review",String(s),`--${r}`];o&&l.push("--body",o),De("gh",l,{cwd:i,encoding:"utf-8",timeout:15e3}),h(e,{ok:!0})}catch(t){h(e,{error:t.message},500)}}function Hr(n){if(ut)return;let e=J(),t=e.normalizePath(n.config.root),s=e.resolvePath("terminal-sidecar.cjs",t);if(!e.pathExists(s))return;try{let i=fe(`fuser ${ms}/tcp 2>/dev/null`,{encoding:"utf8"}).trim();i&&process.kill(Number(i),"SIGKILL")}catch{}ut=!0;let r=e.getRepoRoot(),o=Pr(),a=wr(o,[s],{cwd:r,stdio:["ignore","inherit","inherit","ipc"],env:{...process.env,TERMINAL_PORT:String(ms),TERMINAL_CWD:r}});a.on("message",i=>{i.type}),a.on("exit",i=>{ut=!1}),process.on("exit",()=>{a.kill()})}function Jr(n){let e=J(),t=e.getRepoRoot(),s=[".dndev","docs","guides"];for(let r of s){let o=e.resolveRepoPath(r);if(!e.pathExists(o))continue;let a=e.watch(o,{recursive:!0},(i,l)=>{if(!l||l==="dashboard.json")return;let c=`${r}/${l}`,u=`change:${c}`;pt.has(u)||(pt.set(u,!0),setTimeout(()=>pt.delete(u),300),n.hot.send("dndev:file-changed",{path:c,timestamp:Date.now()}))});n.httpServer?.on("close",()=>a.close())}}function qr(n={}){return{name:"dndev",configureServer(e){let t=ee();n.debug,e.middlewares.use((s,r,o)=>{let a=s.url;if(!a?.startsWith(ds))return o();let l=new URL(a,`http://${s.headers.host}`).pathname.slice(ds.length),c=s.method?.toUpperCase();if(c==="GET")return l==="/file"?void Er(s,r):l==="/tree"?void _r(s,r):l==="/git/head"?void Or(s,r):l==="/apps"?void Fr(s,r):l==="/worktrees"?void Cr(s,r):l==="/worktrees/diff"?void zr(s,r):l==="/git/platform"?void jr(s,r):l==="/git/prs"?void Ur(s,r):l==="/git/issues"?void Wr(s,r):l==="/git/pr/diff"?void Gr(s,r):l==="/git/pr/checks"?void Br(s,r):h(r,{error:"Not found"},404);if(c==="POST")return l==="/file"?void kr(s,r):l==="/progress/toggle"?void Dr(s,r):l==="/bugs/screenshot"?void Ar(s,r):l==="/phase"?void Nr(s,r):l==="/actions/append"?void Tr(s,r):l==="/worktrees/add"?void Ir(s,r):l==="/worktrees/remove"?void Mr(s,r):l==="/worktrees/pr"?void Lr(s,r):l==="/git/pr/review"?void Vr(s,r):h(r,{error:"Not found"},404);h(r,{error:"Method not allowed"},405)}),Hr(e),Jr(e)}}}var ds,xr,bs,$r,ms,ut,pt,xs=Ke(()=>{"use strict";U();ds="/api/dndev";xr=5*1024*1024;bs={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".svg":"image/svg+xml"},$r=new Set(Object.keys(bs));ms=24681,ut=!1;pt=new Map});import Ls from"@rollup/plugin-strip";import{visualizer as js}from"rollup-plugin-visualizer";var Ze=["/react/","/react-dom/","/scheduler/","/react-router","/@radix-ui/","/react-day-picker/","/react-hook-form/","/react-i18next/","/clsx/","/class-variance-authority/"],_s={valibot:["/valibot/"],firebase:["/firebase/","/@firebase/"],lucide:["/lucide-react/","/lucide/"],i18n:["/i18next/","/i18next-browser-languagedetector/","/i18next-http-backend/","/@donotdev/i18n/"],zustand:["/zustand/"],"tanstack-query":["/@tanstack/react-query/","/@tanstack/query-core/"]};function ks(n){let e=n.match(/(?:^|\0)virtual:([^?]+)/);if(e)return e[1]}function dt(n){let e=n.replace(/\\/g,"/");if(e.includes("/node_modules/"))return e.split("?")[0]}function mt(n,e=Ze){return e.some(t=>n.includes(t))}function Ds(n){for(let[e,t]of Object.entries(_s))if(t.some(s=>n.includes(s)))return e}function As(n){let e=ks(n);if(e)return e==="i18n-mapping"?"virtual-i18n-mapping":e.startsWith("i18n-lazy-")?e:"virtual-modules";let t=dt(n);if(!t)return;if(mt(t))return"react-core";let s=Ds(t);if(s)return s}function Ns(n=[]){let e=n.filter(s=>!Ze.includes(s)),t=[...Ze,...e];return function(s){let r=dt(s);if(r&&mt(r,t))return"react-core"}}var ft={development:{manualChunks:void 0},production:{manualChunks:As}};function ht(n,e={}){let t=ft[n]||ft.production,s=e.reactCore||[];return s.length>0?{manualChunks:Ns(s)}:t}U();import*as Q from"@clack/prompts";var le={reset:"\x1B[0m",green:"\x1B[32m",brightGreen:"\x1B[92m",red:"\x1B[31m",brightRed:"\x1B[91m",yellow:"\x1B[33m",brightYellow:"\x1B[93m",blue:"\x1B[34m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",gray:"\x1B[90m",white:"\x1B[37m"};function zs(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function pe(n,e){return zs()?`${e}${n}${le.reset}`:n}function C(n,e,t,s={}){let{logDir:r=".dndev-logs",fileLogging:o=!1}=s,a=$.getInstance(),i=null;if(o){let u=a.resolveAppPath(r);a.pathExists(u)||a.mkdir(u),i=a.resolveAppPath(`${r}/${n.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let p=`=== ${n} Log Started at ${new Date().toISOString()} ===
4
+ `),{overwrite:!0}),h(e,{ok:!0,line:l[s]})}catch{h(e,{error:"Failed to update progress"},500)}}async function Nr(n,e){try{let t=await he(n),{id:s,data:r}=JSON.parse(t);if(!s||!r)return h(e,{error:"id and data required"},400);if(!/^[\w-]+$/.test(s))return h(e,{error:"Invalid screenshot ID"},400);let o=Y(),a=o.resolveRepoPath(".dndev/bugs");o.ensureDirSync(a);let i=Buffer.from(r,"base64"),l=o.resolvePath(`${s}.png`,a);await o.write(l,i,{overwrite:!0}),h(e,{ok:!0,path:`.dndev/bugs/${s}.png`})}catch{h(e,{error:"Failed to save screenshot"},500)}}async function Or(n,e){try{let t=await he(n),{action:s,phase:r}=JSON.parse(t);if(!s||typeof r!="number")return h(e,{error:"action and phase required"},400);let o=Y(),a=hs();o.ensureDirSync(a);let i=o.resolvePath("protocol.json",a),l={currentPhase:0,phases:{}};if(o.pathExists(i))try{let c=await o.read(i);c&&(l=c)}catch{}s==="start"?(l.currentPhase=r,l.phases[r]||(l.phases[r]={}),l.phases[r].status="active",l.phases[r].startedAt=new Date().toISOString()):s==="complete"&&(l.phases[r]||(l.phases[r]={}),l.phases[r].status="completed",l.phases[r].completedAt=new Date().toISOString()),await o.write(i,l,{overwrite:!0}),h(e,{ok:!0,protocol:l})}catch{h(e,{error:"Failed to update phase"},500)}}function Tr(n,e){try{let t=ee(),s=de("git rev-parse --short HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim(),r=de("git rev-parse --abbrev-ref HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim();h(e,{commit:s,branch:r})}catch{h(e,{commit:"unknown",branch:"unknown"})}}async function Fr(n,e){try{let t=await he(n),s=JSON.parse(t);if(!s.id||!s.type||!s.result)return h(e,{error:"id, type, and result required"},400);let r=Y(),o=hs();r.ensureDirSync(o);let a=r.resolvePath("health.json",o),i={actions:[]};if(r.pathExists(a))try{let c=await r.read(a);c&&(i=c)}catch{}Array.isArray(i.actions)||(i.actions=[]);let l=i.actions.findIndex(c=>c.id===s.id);l>=0?i.actions[l]={...i.actions[l],...s}:i.actions.unshift(s),await r.write(a,i,{overwrite:!0}),h(e,{ok:!0})}catch{h(e,{error:"Failed to append action"},500)}}function Cr(n,e){let t=Y(),s=t.resolveRepoPath("apps");try{let o=t.readdirSync(s).filter(a=>{if(a==="dndev")return!1;let i=t.resolvePath(a,s);return t.statSync(i)?.isDirectory()&&t.pathExists(t.resolvePath("package.json",i))}).map(a=>{try{let i=t.resolvePath(`${a}/package.json`,s),l=t.readSync(i);return{name:a,packageName:l?.name||a}}catch{return{name:a,packageName:a}}});h(e,{apps:o})}catch{h(e,{apps:[]})}}function Ir(n,e){try{let t=ee(),s=de("git worktree list --porcelain",{cwd:t,encoding:"utf-8",timeout:5e3}),r=[],o={};for(let a of s.split(`
5
+ `))a.startsWith("worktree ")?(o.path&&r.push(o),o={path:a.slice(9)}):a.startsWith("HEAD ")?o.head=a.slice(5):a.startsWith("branch ")?(o.branch=a.slice(7),o.shortBranch=o.branch.replace("refs/heads/","")):a==="detached"&&(o.detached=!0);o.path&&r.push(o),h(e,{worktrees:r})}catch(t){h(e,{error:t.message},500)}}async function Mr(n,e){try{let t=await he(n),{branch:s}=JSON.parse(t);if(!s||typeof s!="string")return h(e,{error:"branch required"},400);if(!/^[\w][\w./-]*$/.test(s))return h(e,{error:"Invalid branch name"},400);let r=ee(),o=Y(),a=o.resolvePath("..",r),i=o.getBasename(r),l=o.resolvePath(`${i}-${s.replace(/\//g,"-")}`,a);Ae("git",["worktree","add",l,"-b",s],{cwd:r,encoding:"utf-8",timeout:3e4}),h(e,{ok:!0,path:l,branch:s})}catch(t){h(e,{error:t.message},500)}}async function zr(n,e){try{let t=await he(n),{path:s}=JSON.parse(t);if(!s||typeof s!="string")return h(e,{error:"path required"},400);let r=ee();Ae("git",["worktree","remove",s,"--force"],{cwd:r,encoding:"utf-8",timeout:1e4}),h(e,{ok:!0})}catch(t){h(e,{error:t.message},500)}}function Lr(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("branch");if(!s)return h(e,{error:"branch required"},400);if(!/^[\w][\w./-]*$/.test(s))return h(e,{error:"Invalid branch name"},400);let r=ee(),o=Ae("git",["diff",`main...${s}`,"--stat"],{cwd:r,encoding:"utf-8",timeout:1e4}).trim(),a=Ae("git",["diff",`main...${s}`],{cwd:r,encoding:"utf-8",timeout:3e4});h(e,{stat:o,diff:a})}catch(t){h(e,{error:t.message},500)}}async function jr(n,e){try{let t=await he(n),{branch:s,title:r,bodyText:o}=JSON.parse(t);if(!s)return h(e,{error:"branch required"},400);let a=ee(),i=["pr","create","--head",s];r&&i.push("--title",r),o&&i.push("--body",o);let l=Ae("gh",i,{cwd:a,encoding:"utf-8",timeout:3e4}).trim();h(e,{ok:!0,url:l})}catch(t){h(e,{error:t.message},500)}}function Ur(n,e){try{let t=ee(),s=de("git remote get-url origin",{cwd:t,encoding:"utf-8",timeout:5e3}).trim(),r=null;s.includes("github.com")?r="github":s.includes("gitlab")&&(r="gitlab"),h(e,{platform:r,remoteUrl:s})}catch{h(e,{platform:null,remoteUrl:null})}}function Wr(n,e){try{let t=ee(),s=de("gh pr list --json number,title,state,author,headRefName,url,isDraft,reviewDecision,statusCheckRollup --limit 50",{cwd:t,encoding:"utf-8",timeout:15e3});h(e,{prs:JSON.parse(s)})}catch(t){h(e,{prs:[],error:t.message})}}function Gr(n,e){try{let t=ee(),s=de("gh issue list --json number,title,state,labels,assignees --limit 50",{cwd:t,encoding:"utf-8",timeout:15e3});h(e,{issues:JSON.parse(s)})}catch(t){h(e,{issues:[],error:t.message})}}function Br(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("number");if(!s||!/^\d+$/.test(s))return h(e,{error:"PR number required"},400);let r=ee(),o=de(`gh pr diff ${s}`,{cwd:r,encoding:"utf-8",timeout:3e4});h(e,{diff:o})}catch(t){h(e,{error:t.message},500)}}function Vr(n,e){try{let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("number");if(!s||!/^\d+$/.test(s))return h(e,{error:"PR number required"},400);let r=ee(),o=de(`gh pr checks ${s} --json name,state,status`,{cwd:r,encoding:"utf-8",timeout:15e3});h(e,{checks:JSON.parse(o)})}catch(t){h(e,{checks:[],error:t.message})}}async function Hr(n,e){try{let t=await he(n),{number:s,action:r,comment:o}=JSON.parse(t);if(!s||!r)return h(e,{error:"number and action required"},400);let a=["approve","request-changes","comment"];if(!a.includes(r))return h(e,{error:`Invalid action. Use: ${a.join(", ")}`},400);let i=ee(),l=["pr","review",String(s),`--${r}`];o&&l.push("--body",o),Ae("gh",l,{cwd:i,encoding:"utf-8",timeout:15e3}),h(e,{ok:!0})}catch(t){h(e,{error:t.message},500)}}function Jr(n){if(ut)return;let e=Y(),t=e.normalizePath(n.config.root),s=e.resolvePath("terminal-sidecar.cjs",t);if(!e.pathExists(s))return;try{let i=de(`fuser ${ms}/tcp 2>/dev/null`,{encoding:"utf8"}).trim();i&&process.kill(Number(i),"SIGKILL")}catch{}ut=!0;let r=e.getRepoRoot(),o=Rr(),a=xr(o,[s],{cwd:r,stdio:["ignore","inherit","inherit","ipc"],env:{...process.env,TERMINAL_PORT:String(ms),TERMINAL_CWD:r}});a.on("message",i=>{i.type}),a.on("exit",i=>{ut=!1}),process.on("exit",()=>{a.kill()})}function qr(n){let e=Y(),t=e.getRepoRoot(),s=[".dndev","docs","guides"];for(let r of s){let o=e.resolveRepoPath(r);if(!e.pathExists(o))continue;let a=e.watch(o,{recursive:!0},(i,l)=>{if(!l||l==="dashboard.json")return;let c=`${r}/${l}`,u=`change:${c}`;pt.has(u)||(pt.set(u,!0),setTimeout(()=>pt.delete(u),300),n.hot.send("dndev:file-changed",{path:c,timestamp:Date.now()}))});n.httpServer?.on("close",()=>a.close())}}function Yr(n={}){return{name:"dndev",configureServer(e){let t=ee();n.debug,e.middlewares.use((s,r,o)=>{let a=s.url;if(!a?.startsWith(ds))return o();let l=new URL(a,`http://${s.headers.host}`).pathname.slice(ds.length),c=s.method?.toUpperCase();if(c==="GET")return l==="/file"?void _r(s,r):l==="/tree"?void kr(s,r):l==="/git/head"?void Tr(s,r):l==="/apps"?void Cr(s,r):l==="/worktrees"?void Ir(s,r):l==="/worktrees/diff"?void Lr(s,r):l==="/git/platform"?void Ur(s,r):l==="/git/prs"?void Wr(s,r):l==="/git/issues"?void Gr(s,r):l==="/git/pr/diff"?void Br(s,r):l==="/git/pr/checks"?void Vr(s,r):h(r,{error:"Not found"},404);if(c==="POST")return l==="/file"?void Dr(s,r):l==="/progress/toggle"?void Ar(s,r):l==="/bugs/screenshot"?void Nr(s,r):l==="/phase"?void Or(s,r):l==="/actions/append"?void Fr(s,r):l==="/worktrees/add"?void Mr(s,r):l==="/worktrees/remove"?void zr(s,r):l==="/worktrees/pr"?void jr(s,r):l==="/git/pr/review"?void Hr(s,r):h(r,{error:"Not found"},404);h(r,{error:"Method not allowed"},405)}),Jr(e),qr(e)}}}var ds,Sr,bs,Er,ms,ut,pt,xs=Ke(()=>{"use strict";W();ds="/api/dndev";Sr=5*1024*1024;bs={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".svg":"image/svg+xml"},Er=new Set(Object.keys(bs));ms=24681,ut=!1;pt=new Map});import js from"@rollup/plugin-strip";import{visualizer as Us}from"rollup-plugin-visualizer";var Ze=["/react/","/react-dom/","/scheduler/","/react-router","/@radix-ui/","/react-day-picker/","/react-hook-form/","/react-i18next/","/clsx/","/class-variance-authority/"],ks={valibot:["/valibot/"],firebase:["/firebase/","/@firebase/"],lucide:["/lucide-react/","/lucide/"],i18n:["/i18next/","/i18next-browser-languagedetector/","/i18next-http-backend/","/@donotdev/i18n/"],zustand:["/zustand/"],"tanstack-query":["/@tanstack/react-query/","/@tanstack/query-core/"]};function Ds(n){let e=n.match(/(?:^|\0)virtual:([^?]+)/);if(e)return e[1]}function dt(n){let e=n.replace(/\\/g,"/");if(e.includes("/node_modules/"))return e.split("?")[0]}function mt(n,e=Ze){return e.some(t=>n.includes(t))}function As(n){for(let[e,t]of Object.entries(ks))if(t.some(s=>n.includes(s)))return e}function Ns(n){let e=Ds(n);if(e)return e==="i18n-mapping"?"virtual-i18n-mapping":e.startsWith("i18n-lazy-")?e:"virtual-modules";let t=dt(n);if(!t)return;if(mt(t))return"react-core";let s=As(t);if(s)return s}function Os(n=[]){let e=n.filter(s=>!Ze.includes(s)),t=[...Ze,...e];return function(s){let r=dt(s);if(r&&mt(r,t))return"react-core"}}var ft={development:{manualChunks:void 0},production:{manualChunks:Ns}};function ht(n,e={}){let t=ft[n]||ft.production,s=e.reactCore||[];return s.length>0?{manualChunks:Os(s)}:t}W();import*as Q from"@clack/prompts";var ce={reset:"\x1B[0m",green:"\x1B[32m",brightGreen:"\x1B[92m",red:"\x1B[31m",brightRed:"\x1B[91m",yellow:"\x1B[33m",brightYellow:"\x1B[93m",blue:"\x1B[34m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",gray:"\x1B[90m",white:"\x1B[37m"};function Ls(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function ge(n,e){return Ls()?`${e}${n}${ce.reset}`:n}function I(n,e,t,s={}){let{logDir:r=".dndev-logs",fileLogging:o=!1}=s,a=R.getInstance(),i=null;if(o){let u=a.resolveAppPath(r);a.pathExists(u)||a.mkdir(u),i=a.resolveAppPath(`${r}/${n.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let p=`=== ${n} Log Started at ${new Date().toISOString()} ===
6
6
  `;a.writeSync(i,p)}let l=(u,p,g)=>{if(i){let f=new Date().toISOString(),d=g.length>0?" "+g.map(S=>typeof S=="object"?JSON.stringify(S,null,2):String(S)).join(" "):"",m=`${f} [${u}] ${p}${d}
7
- `;a.appendFile(i,m)}},c=(u,p)=>{if(p.length===0)return u;let g=p.map(f=>typeof f=="object"?JSON.stringify(f,null,2):String(f)).join(" ");return`${u} ${g}`};return{debug:(u,...p)=>{e&&(o?l("DEBUG",u,p):Q.log.message(pe(c(u,p),le.gray)))},verbose:(u,...p)=>{t&&(o?l("VERBOSE",u,p):Q.log.message(c(u,p)))},info:(u,...p)=>{o?l("INFO",u,p):Q.log.info(pe(c(u,p),le.brightCyan))},warn:(u,...p)=>{e&&o?l("WARN",u,p):Q.log.warn(pe(c(u,p),le.brightYellow))},error:(u,...p)=>{e&&o?l("ERROR",u,p):Q.log.error(pe(c(u,p),le.brightRed))},success:(u,...p)=>{e&&o?l("SUCCESS",u,p):Q.log.success(pe(c(u,p),le.brightGreen))},when:(u,p="debug")=>(g,...f)=>{if(u){let d=c(g,f);switch(p){case"verbose":t&&(Q.log.message(d),l("VERBOSE",g,f));break;case"info":Q.log.info(pe(d,le.brightCyan)),l("INFO",g,f);break;case"warn":Q.log.warn(pe(d,le.brightYellow)),l("WARN",g,f);break;case"error":Q.log.error(pe(d,le.brightRed)),l("ERROR",g,f);break;case"success":Q.log.success(pe(d,le.brightGreen)),l("SUCCESS",g,f);break;default:e&&(Q.log.message(pe(d,le.gray)),l("DEBUG",g,f))}}},getLogFilePath:()=>i}}U();function $t(n={}){let{mode:e="development",chunkingOptions:t={},debug:s,verbose:r=!0,isDev:o,isDebug:a,shouldAnalyze:i,build:l={}}=n,c=C("build",s,r),u=ht(e,t);return c.debug("\u{1F41B} DEBUG MODE ENABLED:"),c.debug(" - Minification: DISABLED"),c.debug(" - Sourcemaps: ENABLED"),c.debug(" - Console logs: PRESERVED"),c.debug(" - Debugger statements: PRESERVED"),i&&(c.info("\u{1F4CA} Bundle analysis enabled"),c.info(` Visual treemap will open after build (stats.html)
8
- `)),{outDir:"dist",sourcemap:o||a,cacheDir:"node_modules/.vite",target:"baseline-widely-available",minify:a?!1:"esbuild",reportCompressedSize:!1,chunkSizeWarningLimit:2048,assetsInlineLimit:0,esbuild:{format:"esm",drop:a?[]:["console","debugger"],legalComments:"none"},cssMinify:a?!1:"esbuild",cssCodeSplit:!0,rollupOptions:{external:Us(),output:{format:"es",entryFileNames:"assets/[name].[hash].js",chunkFileNames:"assets/[name].[hash].js",assetFileNames:"assets/[name].[hash][extname]",...u.manualChunks&&{manualChunks:u.manualChunks},compact:!0},onwarn(g,f){g.code!=="MODULE_LEVEL_DIRECTIVE"&&f(g)},plugins:[...a?[]:[Ls({include:["**/*.js","**/*.ts","**/*.tsx","**/*.jsx"],functions:["console.*","debugger"],labels:["debug"]})],...i?[(()=>{let g=$.getInstance(),f=g.getAppRoot(),d="dist",m=g.resolveAppPath(`${d}/stats.html`),S=()=>{try{let N=g.resolveAppPath(d);g.pathExists(N)||g.mkdir(N)}catch{}},b=js({filename:m,open:!0,gzipSize:!0,brotliSize:!0,template:"treemap",sourcemap:o||a,projectRoot:f});if(b.buildStart){let N=b.buildStart.bind(b);b.buildStart=function(...F){S();let k=N.apply(this,F);return k&&typeof k.then=="function"?k.catch(x=>{}):k}}else b.buildStart=function(){S()};let E=["generateBundle","writeBundle","closeBundle"];for(let N of E)if(b[N]){let F=b[N];b[N]=function(...k){try{S();let x=F.apply(this,k);return x&&typeof x.then=="function"?x.catch(D=>{let w=D?.message||D?.toString()||String(D)||"Unknown error";c.warn(`Bundle visualizer warning in ${N}: ${w}`),N==="closeBundle"&&c.warn(`You can manually open ${m} to view the bundle analysis`)}):x}catch(x){let D=x?.message||x?.toString()||String(x)||"Unknown error";c.warn(`Bundle visualizer warning in ${N}: ${D}`),N==="closeBundle"&&c.warn(` You can manually open ${m} to view the bundle analysis`)}}}return b})()]:[]]}}}function Us(n){return n?["firebase-admin","gcp-metadata","google-logging-utils","@google-cloud/firestore",/\.node$/,"esbuild",/@esbuild\/.*/]:["gcp-metadata","google-logging-utils","payload","file-type","firebase-admin","firebase-admin/app","firebase-admin/auth","firebase-admin/firestore","firebase-admin/functions","firebase-admin/credential","@google-cloud/firestore","google-auth-library","google-gax","googleapis-common"]}function Ws(){let n=!1,e=$.getInstance();if((e.pathExists("/.dockerenv")||e.pathExists("/run/.containerenv"))&&(n=!0),!n&&(process.env.DOCKER_CONTAINER==="true"||process.env.IS_DOCKER==="true"||process.env.DOCKER_BUILDKIT==="1"||process.env.CI==="true"&&process.env.DOCKER==="true")&&(n=!0),!n&&process.env.DOCKER_HOST&&process.env.DOCKER_HOST.includes("docker")&&(n=!0),!n&&process.platform==="linux"&&e.pathExists("/proc/self/cgroup"))try{let r=e.readSync("/proc/self/cgroup");r&&(r.includes("docker")||r.includes("containerd"))&&(n=!0)}catch{}let t=!1;if((process.env.WSL_DISTRO_NAME||process.env.WSLENV)&&(t=!0),!t&&process.platform==="linux"&&e.pathExists("/proc/version"))try{let r=(e.readSync("/proc/version")||"").toLowerCase();t=r.includes("microsoft")||r.includes("wsl")}catch{}if(!t&&process.platform==="linux"&&e.pathExists("/proc/sys/kernel/osrelease"))try{let r=(e.readSync("/proc/sys/kernel/osrelease")||"").toLowerCase()||"";(r.includes("microsoft")||r.includes("wsl"))&&(t=!0)}catch{}if(!t&&process.platform==="win32"){let r=process.cwd();r&&(r.includes("\\wsl$")||r.includes("\\wsl.localhost"))&&(t=!0)}let s=typeof process.versions?.bun=="string";return{isDocker:n,isWSL2:t,isBun:s}}function Gs(n,e){if(n!==void 0)return n;let{isDocker:t,isWSL2:s,isBun:r}=Ws();if(t||s||r){let o=t?"Docker":s?"WSL2":"Bun";return e.info(`Detected ${o} environment - enabling polling mode for file watching`),!0}}function Et(n,e={},t){let s=$.getInstance(),r=s.getRepoRoot(),{watch:o,hmr:a,host:i,...l}=e||{},c=a||{},u=i===!0?"localhost":i||"localhost",p={...c.port&&{port:c.port},...c.clientPort&&{clientPort:c.clientPort},host:c.host??u,...c.protocol&&{protocol:c.protocol},overlay:c.overlay??!0,timeout:c.timeout??5e3},g=i!==void 0?i:!0,f=l.https===!0;return{port:n,host:g,open:e.open!==void 0?e.open:!0,https:f,fs:{allow:[r,s.resolveRepoPath("packages"),s.resolveRepoPath("node_modules")],strict:!1},watch:(()=>{let d=Gs(e?.watch?.usePolling,t);return{usePolling:d,interval:e?.watch?.interval??2e3,...d&&{awaitWriteFinish:{stabilityThreshold:300,pollInterval:100}},...e?.watch||{}}})(),hmr:{...p,...c},headers:{"Cross-Origin-Opener-Policy":"same-origin-allow-popups","Cross-Origin-Embedder-Policy":"unsafe-none"},middlewareMode:!1,...l}}function _t(n={}){let e=n.https===!0;return{...n,https:e}}W();var kt={debug:!1,verbose:process.env.CI!=="true",seo:{disabled:!1,generateRobotsTxt:!0,generateSitemap:!0,crawlDelay:1,aiCrawlers:"recommended",llmsTxt:!0,speculationRules:!0,hreflang:!0,breadcrumbSchema:!0,websiteSchema:!0,organizationSchema:!0},serverShim:{enabled:!0},discovery:{verbose:!0,cacheTimeout:6e4,fileLogging:!1,logDir:".dndev-logs"},features:{}};var re={CONCATENATE_DEDUPE:"CONCATENATE_DEDUPE",SHALLOW_MERGE:"SHALLOW_MERGE",DEEP_MERGE:"DEEP_MERGE",REPLACE:"REPLACE"};function be(n,e,t,s={}){let{protectedKeys:r=[],onConflict:o}=s;if(e==null)return n;switch(t){case re.CONCATENATE_DEDUPE:{if(!Array.isArray(n)||!Array.isArray(e))return e;let a=[...n,...e];return[...new Set(a)]}case re.SHALLOW_MERGE:return typeof n!="object"||typeof e!="object"||n===null||e===null||Array.isArray(n)||Array.isArray(e)?e:{...n,...e};case re.DEEP_MERGE:{if(typeof n!="object"||typeof e!="object"||n===null||e===null||Array.isArray(n)||Array.isArray(e))return e;let a={...n};for(let i in e){if(r.includes(i)){o&&o(i,n[i],e[i]);continue}typeof a[i]=="object"&&typeof e[i]=="object"&&a[i]!==null&&e[i]!==null&&!Array.isArray(a[i])&&!Array.isArray(e[i])?a[i]=be(a[i],e[i],re.DEEP_MERGE,{protectedKeys:r,onConflict:o}):a[i]=e[i]}return a}case re.REPLACE:default:return e}}function Dt(n,e,t=[],s){let r=[...n,...e||[]],o=[...new Set(r)];return[...new Set([...o,...t])]}var _e={...kt,base:"/",mode:process.env.NODE_ENV==="production"?"production":"development",logLevel:process.env.NODE_ENV==="production"?"warn":"info",server:{port:3e3,strictPort:!0,host:!0,open:!0,cors:!0,https:!1,hmr:{overlay:!0,timeout:5e3,usePolling:void 0,interval:2e3},watch:{usePolling:void 0,interval:2e3}},build:{sourcemap:!0,target:"es2020",minify:"esbuild",cssMinify:"esbuild",analyze:!1},preview:{port:4173,strictPort:!0,host:!0,open:!1,cors:!0,https:!1},routes:{hmr:!0},themes:{},i18n:{},assets:{},pwa:{enabled:!1},prerender:{routes:"auto"},chunking:{reactCore:[]},pluginFactory:{verbose:!0,disableHmr:!1,hmrSmartDetection:!0,hmrDebounceMs:500,hmrCacheTimeout:3e4},resolve:{alias:{"@":"/src"},preserveSymlinks:!1},define:{__DEV__:JSON.stringify(process.env.NODE_ENV==="development"),__PROD__:JSON.stringify(process.env.NODE_ENV==="production")},optimizeDeps:{include:[...me.mandatoryIncludes],exclude:[...me.buildTools,...Object.values(z)],esbuildOptions:{format:"esm",target:"es2020",platform:"browser",define:{"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"development")},external:["next","next/*"]}},plugins:[],css:{},envDir:void 0};function At(n={},e={}){let{onConflict:t}=e,s={..._e},r=[],o=(a,i,l,c)=>{r.push({key:a,frameworkValue:i,userValue:l,reason:c}),t&&t(a,i,l,c)};if("prerender"in n){let a=n.prerender;a===!1?n.prerender={routes:[]}:a===!0?n.prerender={routes:"auto"}:Array.isArray(a)&&(n.prerender={routes:a})}return Object.keys(n).forEach(a=>{let i=n[a],l=s[a];if(a==="optimizeDeps"&&typeof i=="object"&&i!==null){let c=l?.include||[],u=l?.exclude||[],p=i.include||[],g=i.exclude||[],f=c.filter(E=>!E.startsWith("@donotdev/")),d=g.filter(E=>f.includes(E));if(d.length>0)for(let E of d)o("optimizeDeps.exclude",E,"excluded",`Framework requires ${E} to be included. It will be included despite your exclusion.`);let m=Dt(c,p,f),S=be(u,g,re.CONCATENATE_DEDUPE),b=be(l?.esbuildOptions||{},i.esbuildOptions||{},re.DEEP_MERGE,{protectedKeys:["external"],onConflict:E=>o(`optimizeDeps.esbuildOptions.${E}`,l?.esbuildOptions?.[E],i.esbuildOptions?.[E],`Framework requires ${E} to remain as configured.`)});s[a]={...l,include:m,exclude:S,esbuildOptions:b,...Object.fromEntries(Object.entries(i).filter(([E])=>!["include","exclude","esbuildOptions"].includes(E)))};return}if(a==="css"&&typeof i=="object"&&i!==null){s[a]=be(l||{},i,re.DEEP_MERGE,{protectedKeys:["postcss"],onConflict:()=>o("css.postcss","framework PostCSS config",i.postcss,"Framework PostCSS config is required and cannot be overridden. Your postcss config is ignored.")});return}if(a==="define"&&typeof i=="object"&&i!==null){s[a]=be(l||{},i,re.DEEP_MERGE,{protectedKeys:["__DEV__","__PROD__"],onConflict:c=>o(`define.${c}`,l?.[c],i[c],`Framework requires ${c} to remain as configured.`)});return}if(Array.isArray(i)){Array.isArray(l)?s[a]=be(l,i,re.CONCATENATE_DEDUPE):s[a]=i;return}if(typeof i=="object"&&i!==null&&typeof l=="object"&&l!==null&&!Array.isArray(l)){s[a]=be(l,i,re.SHALLOW_MERGE);return}s[a]=i}),s}function Nt(n){let{server:e={},preview:t={},mode:s,build:r={},resolve:o={},routes:a={},themes:i={},i18n:l={},assets:c={},features:u={},seo:p={},prerender:g={},pwa:f={},serverShim:d={},chunking:m={},discovery:S={},pluginFactory:b={},debug:E,verbose:N,base:F,define:k={},optimizeDeps:x={},plugins:D=[],css:w={},envDir:v,...O}=n,P=s==="development",I=E||P,M=s==="production"&&(r.analyze??_e.build.analyze);return{mode:s,debug:E,verbose:N,isDev:P,isDebug:I,shouldAnalyze:M,serverOptions:e,previewOptions:t,buildOverrides:r,resolveOptions:o,routeOptions:a,themeOptions:i,i18nOptions:l,assetOptions:c,featureOptions:u,seoOptions:p,prerenderOptions:g,pwaOptions:f,serverShimOptions:d,chunkingOptions:m,discoveryOptions:S,pluginFactoryOptions:b,base:F,defineOptions:k,optimizeDepsOptions:x,pluginsOptions:D,cssOptions:w,envDir:v,restOptions:O}}U();import Bs from"autoprefixer";import Vs from"postcss-import";import Hs from"postcss-nesting";function Ot({postcssImport:n,postcssNesting:e,autoprefixer:t,resolve:s}){return{plugins:[s?n({resolve:s}):n,e,t({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}function Tt(n={}){if(n.postcss)return n.postcss;let e=$.getInstance();return Ot({postcssImport:Vs,postcssNesting:Hs,autoprefixer:Bs,resolve:(s,r)=>{let o=e.resolvePackage(s,r);if(o)return o;if(s.startsWith("@donotdev/")){let a=s.split("/")[0]+"/"+s.split("/")[1],i=s.split("/").slice(2).join("/"),l=e.resolveFrameworkPackage(a,r);if(l&&i){let c=e.resolvePath(i,l);if(e.pathExists(c))return c}}return e.resolvePath(s,r)}})}import hr from"@vitejs/plugin-basic-ssl";import vr from"@vitejs/plugin-react";import yr from"vite-tsconfig-paths";var X=class{static generateVirtualModule(e,t,s=!1,r=void 0,o=void 0){return t.isEmpty(e)?t.generateEmpty(e,s,r,o):t.generateModule(e,s,o)}static generateInspection(e,t,s,r){return t.generateInspection.length>=3?t.generateInspection(e,s,r):t.generateInspection(e,s)}static wrapVirtualModule(e,t){return`// Virtual module: ${e}
7
+ `;a.appendFile(i,m)}},c=(u,p)=>{if(p.length===0)return u;let g=p.map(f=>typeof f=="object"?JSON.stringify(f,null,2):String(f)).join(" ");return`${u} ${g}`};return{debug:(u,...p)=>{e&&(o?l("DEBUG",u,p):Q.log.message(ge(c(u,p),ce.gray)))},verbose:(u,...p)=>{t&&(o?l("VERBOSE",u,p):Q.log.message(c(u,p)))},info:(u,...p)=>{o?l("INFO",u,p):Q.log.info(ge(c(u,p),ce.brightCyan))},warn:(u,...p)=>{e&&o?l("WARN",u,p):Q.log.warn(ge(c(u,p),ce.brightYellow))},error:(u,...p)=>{e&&o?l("ERROR",u,p):Q.log.error(ge(c(u,p),ce.brightRed))},success:(u,...p)=>{e&&o?l("SUCCESS",u,p):Q.log.success(ge(c(u,p),ce.brightGreen))},when:(u,p="debug")=>(g,...f)=>{if(u){let d=c(g,f);switch(p){case"verbose":t&&(Q.log.message(d),l("VERBOSE",g,f));break;case"info":Q.log.info(ge(d,ce.brightCyan)),l("INFO",g,f);break;case"warn":Q.log.warn(ge(d,ce.brightYellow)),l("WARN",g,f);break;case"error":Q.log.error(ge(d,ce.brightRed)),l("ERROR",g,f);break;case"success":Q.log.success(ge(d,ce.brightGreen)),l("SUCCESS",g,f);break;default:e&&(Q.log.message(ge(d,ce.gray)),l("DEBUG",g,f))}}},getLogFilePath:()=>i}}W();function $t(n={}){let{mode:e="development",chunkingOptions:t={},debug:s,verbose:r=!0,isDev:o,isDebug:a,shouldAnalyze:i,build:l={}}=n,c=I("build",s,r),u=ht(e,t);return c.debug("\u{1F41B} DEBUG MODE ENABLED:"),c.debug(" - Minification: DISABLED"),c.debug(" - Sourcemaps: ENABLED"),c.debug(" - Console logs: PRESERVED"),c.debug(" - Debugger statements: PRESERVED"),i&&(c.info("\u{1F4CA} Bundle analysis enabled"),c.info(` Visual treemap will open after build (stats.html)
8
+ `)),{outDir:"dist",sourcemap:o||a,cacheDir:"node_modules/.vite",target:"baseline-widely-available",minify:a?!1:"esbuild",reportCompressedSize:!1,chunkSizeWarningLimit:2048,assetsInlineLimit:0,esbuild:{format:"esm",drop:a?[]:["console","debugger"],legalComments:"none"},cssMinify:a?!1:"esbuild",cssCodeSplit:!0,rollupOptions:{external:Ws(),output:{format:"es",entryFileNames:"assets/[name].[hash].js",chunkFileNames:"assets/[name].[hash].js",assetFileNames:"assets/[name].[hash][extname]",...u.manualChunks&&{manualChunks:u.manualChunks},compact:!0},onwarn(g,f){g.code!=="MODULE_LEVEL_DIRECTIVE"&&f(g)},plugins:[...a?[]:[js({include:["**/*.js","**/*.ts","**/*.tsx","**/*.jsx"],functions:["console.*","debugger"],labels:["debug"]})],...i?[(()=>{let g=R.getInstance(),f=g.getAppRoot(),d="dist",m=g.resolveAppPath(`${d}/stats.html`),S=()=>{try{let A=g.resolveAppPath(d);g.pathExists(A)||g.mkdir(A)}catch{}},w=Us({filename:m,open:!0,gzipSize:!0,brotliSize:!0,template:"treemap",sourcemap:o||a,projectRoot:f});if(w.buildStart){let A=w.buildStart.bind(w);w.buildStart=function(...T){S();let k=A.apply(this,T);return k&&typeof k.then=="function"?k.catch(N=>{}):k}}else w.buildStart=function(){S()};let $=["generateBundle","writeBundle","closeBundle"];for(let A of $)if(w[A]){let T=w[A];w[A]=function(...k){try{S();let N=T.apply(this,k);return N&&typeof N.then=="function"?N.catch(x=>{let b=x?.message||x?.toString()||String(x)||"Unknown error";c.warn(`Bundle visualizer warning in ${A}: ${b}`),A==="closeBundle"&&c.warn(`You can manually open ${m} to view the bundle analysis`)}):N}catch(N){let x=N?.message||N?.toString()||String(N)||"Unknown error";c.warn(`Bundle visualizer warning in ${A}: ${x}`),A==="closeBundle"&&c.warn(` You can manually open ${m} to view the bundle analysis`)}}}return w})()]:[]]}}}function Ws(n){return n?["firebase-admin","gcp-metadata","google-logging-utils","@google-cloud/firestore",/\.node$/,"esbuild",/@esbuild\/.*/]:["gcp-metadata","google-logging-utils","payload","file-type","firebase-admin","firebase-admin/app","firebase-admin/auth","firebase-admin/firestore","firebase-admin/functions","firebase-admin/credential","@google-cloud/firestore","google-auth-library","google-gax","googleapis-common"]}function Gs(){let n=!1,e=R.getInstance();if((e.pathExists("/.dockerenv")||e.pathExists("/run/.containerenv"))&&(n=!0),!n&&(process.env.DOCKER_CONTAINER==="true"||process.env.IS_DOCKER==="true"||process.env.DOCKER_BUILDKIT==="1"||process.env.CI==="true"&&process.env.DOCKER==="true")&&(n=!0),!n&&process.env.DOCKER_HOST&&process.env.DOCKER_HOST.includes("docker")&&(n=!0),!n&&process.platform==="linux"&&e.pathExists("/proc/self/cgroup"))try{let r=e.readSync("/proc/self/cgroup");r&&(r.includes("docker")||r.includes("containerd"))&&(n=!0)}catch{}let t=!1;if((process.env.WSL_DISTRO_NAME||process.env.WSLENV)&&(t=!0),!t&&process.platform==="linux"&&e.pathExists("/proc/version"))try{let r=(e.readSync("/proc/version")||"").toLowerCase();t=r.includes("microsoft")||r.includes("wsl")}catch{}if(!t&&process.platform==="linux"&&e.pathExists("/proc/sys/kernel/osrelease"))try{let r=(e.readSync("/proc/sys/kernel/osrelease")||"").toLowerCase()||"";(r.includes("microsoft")||r.includes("wsl"))&&(t=!0)}catch{}if(!t&&process.platform==="win32"){let r=process.cwd();r&&(r.includes("\\wsl$")||r.includes("\\wsl.localhost"))&&(t=!0)}let s=typeof process.versions?.bun=="string";return{isDocker:n,isWSL2:t,isBun:s}}function Bs(n,e){if(n!==void 0)return n;let{isDocker:t,isWSL2:s,isBun:r}=Gs();if(t||s||r){let o=t?"Docker":s?"WSL2":"Bun";return e.info(`Detected ${o} environment - enabling polling mode for file watching`),!0}}function Et(n,e={},t){let s=R.getInstance(),r=s.getRepoRoot(),{watch:o,hmr:a,host:i,...l}=e||{},c=a||{},u=i===!0?"localhost":i||"localhost",p={...c.port&&{port:c.port},...c.clientPort&&{clientPort:c.clientPort},host:c.host??u,...c.protocol&&{protocol:c.protocol},overlay:c.overlay??!0,timeout:c.timeout??5e3},g=i!==void 0?i:!0,f=l.https===!0;return{port:n,host:g,open:e.open!==void 0?e.open:!0,https:f,fs:{allow:[r,s.resolveRepoPath("packages"),s.resolveRepoPath("node_modules")],strict:!1},watch:(()=>{let d=Bs(e?.watch?.usePolling,t);return{usePolling:d,interval:e?.watch?.interval??2e3,...d&&{awaitWriteFinish:{stabilityThreshold:300,pollInterval:100}},...e?.watch||{}}})(),hmr:{...p,...c},headers:{"Cross-Origin-Opener-Policy":"same-origin-allow-popups","Cross-Origin-Embedder-Policy":"unsafe-none"},middlewareMode:!1,...l}}function _t(n={}){let e=n.https===!0;return{...n,https:e}}G();var kt={debug:!1,verbose:process.env.CI!=="true",seo:{disabled:!1,generateRobotsTxt:!0,generateSitemap:!0,crawlDelay:1,aiCrawlers:"recommended",llmsTxt:!0,speculationRules:!0,hreflang:!0,breadcrumbSchema:!0,websiteSchema:!0,organizationSchema:!0},serverShim:{enabled:!0},discovery:{verbose:!0,cacheTimeout:6e4,fileLogging:!1,logDir:".dndev-logs"},features:{}};var oe={CONCATENATE_DEDUPE:"CONCATENATE_DEDUPE",SHALLOW_MERGE:"SHALLOW_MERGE",DEEP_MERGE:"DEEP_MERGE",REPLACE:"REPLACE"};function be(n,e,t,s={}){let{protectedKeys:r=[],onConflict:o}=s;if(e==null)return n;switch(t){case oe.CONCATENATE_DEDUPE:{if(!Array.isArray(n)||!Array.isArray(e))return e;let a=[...n,...e];return[...new Set(a)]}case oe.SHALLOW_MERGE:return typeof n!="object"||typeof e!="object"||n===null||e===null||Array.isArray(n)||Array.isArray(e)?e:{...n,...e};case oe.DEEP_MERGE:{if(typeof n!="object"||typeof e!="object"||n===null||e===null||Array.isArray(n)||Array.isArray(e))return e;let a={...n};for(let i in e){if(r.includes(i)){o&&o(i,n[i],e[i]);continue}typeof a[i]=="object"&&typeof e[i]=="object"&&a[i]!==null&&e[i]!==null&&!Array.isArray(a[i])&&!Array.isArray(e[i])?a[i]=be(a[i],e[i],oe.DEEP_MERGE,{protectedKeys:r,onConflict:o}):a[i]=e[i]}return a}case oe.REPLACE:default:return e}}function Dt(n,e,t=[],s){let r=[...n,...e||[]],o=[...new Set(r)];return[...new Set([...o,...t])]}var ke={...kt,reactCompiler:!1,base:"/",mode:process.env.NODE_ENV==="production"?"production":"development",logLevel:process.env.NODE_ENV==="production"?"warn":"info",server:{port:3e3,strictPort:!0,host:!0,open:!0,cors:!0,https:!1,hmr:{overlay:!0,timeout:5e3,usePolling:void 0,interval:2e3},watch:{usePolling:void 0,interval:2e3}},build:{sourcemap:!0,target:"es2020",minify:"esbuild",cssMinify:"esbuild",analyze:!1},preview:{port:4173,strictPort:!0,host:!0,open:!1,cors:!0,https:!1},routes:{hmr:!0},themes:{},i18n:{},assets:{},pwa:{enabled:!1},prerender:{routes:"auto"},chunking:{reactCore:[]},pluginFactory:{verbose:!0,disableHmr:!1,hmrSmartDetection:!0,hmrDebounceMs:500,hmrCacheTimeout:3e4},resolve:{alias:{"@":"/src"},preserveSymlinks:!1},define:{__DEV__:JSON.stringify(process.env.NODE_ENV==="development"),__PROD__:JSON.stringify(process.env.NODE_ENV==="production")},optimizeDeps:{include:[...me.mandatoryIncludes],exclude:[...me.buildTools,...Object.values(M)],esbuildOptions:{format:"esm",target:"es2020",platform:"browser",define:{"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"development")},external:["next","next/*"]}},plugins:[],css:{},envDir:void 0};function At(n={},e={}){let{onConflict:t}=e,s={...ke},r=[],o=(a,i,l,c)=>{r.push({key:a,frameworkValue:i,userValue:l,reason:c}),t&&t(a,i,l,c)};if("prerender"in n){let a=n.prerender;a===!1?n.prerender={routes:[]}:a===!0?n.prerender={routes:"auto"}:Array.isArray(a)&&(n.prerender={routes:a})}return Object.keys(n).forEach(a=>{let i=n[a],l=s[a];if(a==="optimizeDeps"&&typeof i=="object"&&i!==null){let c=l?.include||[],u=l?.exclude||[],p=i.include||[],g=i.exclude||[],f=c.filter($=>!$.startsWith("@donotdev/")),d=g.filter($=>f.includes($));if(d.length>0)for(let $ of d)o("optimizeDeps.exclude",$,"excluded",`Framework requires ${$} to be included. It will be included despite your exclusion.`);let m=Dt(c,p,f),S=be(u,g,oe.CONCATENATE_DEDUPE),w=be(l?.esbuildOptions||{},i.esbuildOptions||{},oe.DEEP_MERGE,{protectedKeys:["external"],onConflict:$=>o(`optimizeDeps.esbuildOptions.${$}`,l?.esbuildOptions?.[$],i.esbuildOptions?.[$],`Framework requires ${$} to remain as configured.`)});s[a]={...l,include:m,exclude:S,esbuildOptions:w,...Object.fromEntries(Object.entries(i).filter(([$])=>!["include","exclude","esbuildOptions"].includes($)))};return}if(a==="css"&&typeof i=="object"&&i!==null){s[a]=be(l||{},i,oe.DEEP_MERGE,{protectedKeys:["postcss"],onConflict:()=>o("css.postcss","framework PostCSS config",i.postcss,"Framework PostCSS config is required and cannot be overridden. Your postcss config is ignored.")});return}if(a==="define"&&typeof i=="object"&&i!==null){s[a]=be(l||{},i,oe.DEEP_MERGE,{protectedKeys:["__DEV__","__PROD__"],onConflict:c=>o(`define.${c}`,l?.[c],i[c],`Framework requires ${c} to remain as configured.`)});return}if(Array.isArray(i)){Array.isArray(l)?s[a]=be(l,i,oe.CONCATENATE_DEDUPE):s[a]=i;return}if(typeof i=="object"&&i!==null&&typeof l=="object"&&l!==null&&!Array.isArray(l)){s[a]=be(l,i,oe.SHALLOW_MERGE);return}s[a]=i}),s}function Nt(n){let{server:e={},preview:t={},mode:s,build:r={},resolve:o={},routes:a={},themes:i={},i18n:l={},assets:c={},features:u={},seo:p={},prerender:g={},pwa:f={},serverShim:d={},chunking:m={},discovery:S={},pluginFactory:w={},debug:$,verbose:A,base:T,define:k={},optimizeDeps:N={},plugins:x=[],css:b={},envDir:C,reactCompiler:y=!1,...E}=n,j=s==="development",F=$||j,U=s==="production"&&(r.analyze??ke.build.analyze);return{mode:s,debug:$,verbose:A,isDev:j,isDebug:F,shouldAnalyze:U,serverOptions:e,previewOptions:t,buildOverrides:r,resolveOptions:o,routeOptions:a,themeOptions:i,i18nOptions:l,assetOptions:c,featureOptions:u,seoOptions:p,prerenderOptions:g,pwaOptions:f,serverShimOptions:d,chunkingOptions:m,discoveryOptions:S,pluginFactoryOptions:w,base:T,defineOptions:k,optimizeDepsOptions:N,pluginsOptions:x,cssOptions:b,envDir:C,reactCompiler:y,restOptions:E}}W();import Vs from"autoprefixer";import Hs from"postcss-import";import Js from"postcss-nesting";function Ot({postcssImport:n,postcssNesting:e,autoprefixer:t,resolve:s}){return{plugins:[s?n({resolve:s}):n,e,t({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}function Tt(n={}){if(n.postcss)return n.postcss;let e=R.getInstance();return Ot({postcssImport:Hs,postcssNesting:Js,autoprefixer:Vs,resolve:(s,r)=>{let o=e.resolvePackage(s,r);if(o)return o;if(s.startsWith("@donotdev/")){let a=s.split("/")[0]+"/"+s.split("/")[1],i=s.split("/").slice(2).join("/"),l=e.resolveFrameworkPackage(a,r);if(l&&i){let c=e.resolvePath(i,l);if(e.pathExists(c))return c}}return e.resolvePath(s,r)}})}import vr from"@vitejs/plugin-basic-ssl";import yr from"@vitejs/plugin-react";import br from"vite-tsconfig-paths";var X=class{static generateVirtualModule(e,t,s=!1,r=void 0,o=void 0){return t.isEmpty(e)?t.generateEmpty(e,s,r,o):t.generateModule(e,s,o)}static generateInspection(e,t,s,r){return t.generateInspection.length>=3?t.generateInspection(e,s,r):t.generateInspection(e,s)}static wrapVirtualModule(e,t){return`// Virtual module: ${e}
9
9
  // Generated by @donotdev/config discovery
10
10
  // Version: 1.0.0
11
11
 
@@ -41,14 +41,14 @@ var $s=Object.defineProperty;var Ke=(n,e)=>()=>(n&&(e=n(n=0)),e);var Es=(n,e)=>{
41
41
  `);return`// Helper functions for ${e}
42
42
  // Generated by @donotdev/config
43
43
 
44
- ${s}`}static validateTemplates(e){return["isEmpty","generateModule","generateEmpty","generateInspection"].every(s=>e[s]&&typeof e[s]=="function")}static createTemplateConfig(e,t){let{isEmpty:s=()=>!1,generateModule:r=()=>"",generateEmpty:o=()=>"",generateInspection:a=()=>"",generateManifest:i=()=>({}),logConfig:l=()=>{},logStats:c=()=>{},logManifest:u=()=>{}}=t;return{isEmpty:s,generateModule:r,generateEmpty:o,generateInspection:a,generateManifest:i,logConfig:l,logStats:c,logManifest:u,pluginName:e,version:"1.0.0",createdAt:new Date().toISOString()}}static getEmptyResultWithError(e,t){let s=t?.message||t||"Unknown error";if(e&&typeof e._getEmptyResult=="function")try{let r=e._getEmptyResult();return r.errors&&Array.isArray(r.errors)?r.errors.push(s):r.errors===void 0&&(r.errors=[s]),r.source==="empty"&&(r.source="error"),r}catch{return{errors:[s],source:"error"}}return{errors:[s],source:"error"}}};U();U();function Js(n){let e=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return{};let t={};for(let s of e[1].split(`
45
- `)){let r=s.indexOf(":");if(r===-1)continue;let o=s.slice(0,r).trim(),a=s.slice(r+1).trim();(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),t[o]=a}return t}function Ue(n,e={}){let{blogPath:t="/blog"}=e,s=$.getInstance(),r=e.appRoot||s.getAppRoot();if(!n.some(a=>{let i=a.path||a;return typeof i=="string"&&i.startsWith(t+"/")&&i.includes(":")}))return[];try{let a=s.resolvePath("src/content/blog",r);if(!s.pathExists(a))return[];let i=s.readdirSync(a).filter(c=>c.endsWith("_en.md"));if(i.length===0)return[];let l=[{path:t,auth:!1,meta:{namespace:"blog"}}];for(let c of i){let u=c.replace(/_en\.md$/,""),p=s.resolvePath(c,a),g=s.readSync(p,{format:"text"}),f=g?Js(g):{};l.push({path:`${t}/${u}`,auth:!1,meta:{namespace:"blog",seo:{title:f.title||u,description:f.description||null,image:f.image||null,type:"article"}}})}return l}catch{return[]}}function we(n={}){let{logger:e}=n,t=$.getInstance(),s=n.appRoot||t.getAppRoot();try{let r=t.resolvePath("public/route-manifest.json",s),o=t.readSync(r,{format:"json"});if(!o)return e?.error?.(`Route manifest not found at ${r}. Routes will be empty.`),{routes:[],errors:[`Route manifest missing: ${r}`],source:"fallback"};let a=o.routes||[];return{routes:a,errors:[],source:o.source||"generated",totalFiles:a.length}}catch(r){return e?.warn?.(`Error parsing route manifest: ${r.message}, falling back to empty routes`),{routes:[],errors:[r.message],source:"fallback"}}}function Ft(n){return n.filter(e=>{let t=e.path||e;return!(e.auth&&e.auth.required||typeof t=="string"&&t.includes(":"))}).map(e=>e.path||e)}function ge(n){let{pluginName:e,icon:t,virtualModuleId:s,DiscoveryClass:r,discoveryMethod:o,filePatterns:a,templates:i,manifestFileName:l,createDiscovery:c,discoveryOptions:u={},configKey:p}=n;return function(f={}){let{debug:d,verbose:m,virtualModuleId:S=s,hmrDebounceMs:b,hmrCacheTimeout:E,hmrSmartDetection:N,disableHmr:F,...k}=f;if(!X.validateTemplates(i))throw new Error(`Invalid templates for plugin ${e}`);let x={..._e.discovery,...u,debug:d,verbose:m,...k},D=p||(()=>{let y=e.match(/dndev-vite-(\w+)-discovery/);return y?y[1]:null})(),w=C(e,d,m,{fileLogging:x.fileLogging,logDir:x.logDir}),v=$.getInstance(),O=()=>{let y=v.getAppRoot(),_=v.getRepoRoot();return y&&y!==_},P=Date.now(),I=c?c(v,x):new r(v,x),M="\0"+S,q="",Y=!1,ae=null,de=0,xe=!1,R=null,T=!1,j=null,L=!1;typeof global<"u"&&(global.__DNDEV_CLEAR_CACHE__=()=>(I.clearCache(),R=null,w.info("Discovery cache cleared manually"),"Cache cleared"));function ie(y){let G=X.generateVirtualModule(y,i,d,x,D).replace(/mode:\s*['"]development['"]/g,"mode: typeof process !== 'undefined' && process.env.NODE_ENV === 'production' ? 'production' : 'development'");return!F&&Y&&(G+=`
44
+ ${s}`}static validateTemplates(e){return["isEmpty","generateModule","generateEmpty","generateInspection"].every(s=>e[s]&&typeof e[s]=="function")}static createTemplateConfig(e,t){let{isEmpty:s=()=>!1,generateModule:r=()=>"",generateEmpty:o=()=>"",generateInspection:a=()=>"",generateManifest:i=()=>({}),logConfig:l=()=>{},logStats:c=()=>{},logManifest:u=()=>{}}=t;return{isEmpty:s,generateModule:r,generateEmpty:o,generateInspection:a,generateManifest:i,logConfig:l,logStats:c,logManifest:u,pluginName:e,version:"1.0.0",createdAt:new Date().toISOString()}}static getEmptyResultWithError(e,t){let s=t?.message||t||"Unknown error";if(e&&typeof e._getEmptyResult=="function")try{let r=e._getEmptyResult();return r.errors&&Array.isArray(r.errors)?r.errors.push(s):r.errors===void 0&&(r.errors=[s]),r.source==="empty"&&(r.source="error"),r}catch{return{errors:[s],source:"error"}}return{errors:[s],source:"error"}}};W();W();function qs(n){let e=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return{};let t={};for(let s of e[1].split(`
45
+ `)){let r=s.indexOf(":");if(r===-1)continue;let o=s.slice(0,r).trim(),a=s.slice(r+1).trim();(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),t[o]=a}return t}function Ue(n,e={}){let{blogPath:t="/blog"}=e,s=R.getInstance(),r=e.appRoot||s.getAppRoot();if(!n.some(a=>{let i=a.path||a;return typeof i=="string"&&i.startsWith(t+"/")&&i.includes(":")}))return[];try{let a=s.resolvePath("src/content/blog",r);if(!s.pathExists(a))return[];let i=s.readdirSync(a).filter(c=>c.endsWith("_en.md"));if(i.length===0)return[];let l=[{path:t,auth:!1,meta:{namespace:"blog"}}];for(let c of i){let u=c.replace(/_en\.md$/,""),p=s.resolvePath(c,a),g=s.readSync(p,{format:"text"}),f=g?qs(g):{};l.push({path:`${t}/${u}`,auth:!1,meta:{namespace:"blog",seo:{title:f.title||u,description:f.description||null,image:f.image||null,type:"article"}}})}return l}catch{return[]}}function we(n={}){let{logger:e}=n,t=R.getInstance(),s=n.appRoot||t.getAppRoot();try{let r=t.resolvePath("public/route-manifest.json",s),o=t.readSync(r,{format:"json"});if(!o)return e?.error?.(`Route manifest not found at ${r}. Routes will be empty.`),{routes:[],errors:[`Route manifest missing: ${r}`],source:"fallback"};let a=o.routes||[];return{routes:a,errors:[],source:o.source||"generated",totalFiles:a.length}}catch(r){return e?.warn?.(`Error parsing route manifest: ${r.message}, falling back to empty routes`),{routes:[],errors:[r.message],source:"fallback"}}}function Ft(n){return n.filter(e=>{let t=e.path||e;return!(e.auth&&e.auth.required||typeof t=="string"&&t.includes(":"))}).map(e=>e.path||e)}function fe(n){let{pluginName:e,icon:t,virtualModuleId:s,DiscoveryClass:r,discoveryMethod:o,filePatterns:a,templates:i,manifestFileName:l,createDiscovery:c,discoveryOptions:u={},configKey:p}=n;return function(f={}){let{debug:d,verbose:m,virtualModuleId:S=s,hmrDebounceMs:w,hmrCacheTimeout:$,hmrSmartDetection:A,disableHmr:T,...k}=f;if(!X.validateTemplates(i))throw new Error(`Invalid templates for plugin ${e}`);let N={...ke.discovery,...u,debug:d,verbose:m,...k},x=p||(()=>{let v=e.match(/dndev-vite-(\w+)-discovery/);return v?v[1]:null})(),b=I(e,d,m,{fileLogging:N.fileLogging,logDir:N.logDir}),C=R.getInstance(),y=()=>{let v=C.getAppRoot(),_=C.getRepoRoot();return v&&v!==_},E=Date.now(),j=c?c(C,N):new r(C,N),F="\0"+S,U="",te=!1,J=null,ie=0,xe=!1,P=null,O=!1,L=null,z=!1;typeof global<"u"&&(global.__DNDEV_CLEAR_CACHE__=()=>(j.clearCache(),P=null,b.info("Discovery cache cleared manually"),"Cache cleared"));function le(v){let H=X.generateVirtualModule(v,i,d,N,x).replace(/mode:\s*['"]development['"]/g,"mode: typeof process !== 'undefined' && process.env.NODE_ENV === 'production' ? 'production' : 'development'");return!T&&te&&(H+=`
46
46
 
47
47
  // HMR boundary for ${e}
48
48
  if (import.meta.hot) {
49
49
  import.meta.hot.accept();
50
50
  }
51
- `),G}function Re(y){let _=y.replace(/\\/g,"/");if(F||_.includes("/node_modules/")||_.includes("/.git/")||_.includes("/dist/")||_.includes("/build/")||_.includes("/coverage/")||_.includes("/.vite/")||_.includes("/.turbo/")||_.endsWith(".d.ts")||_.endsWith(".tsbuildinfo")||_.endsWith(".map")||_.endsWith(".css.map")||_.endsWith(".generated.log")||/\.generated\.[a-z]+$/.test(_))return!1;let G=v.getRelativePath(_);if(G.startsWith("packages/"))return!1;let ce=G.startsWith("src/")&&/\.(ts|tsx)$/.test(G);return ce?Array.isArray(a)&&a.length>0?a.some(K=>typeof K=="function"?K(_):typeof K=="string"?K.startsWith("**/")?_.endsWith(K.slice(3)):_.endsWith(K):!1):ce:!1}function $e(y){if(F)return w.debug("Virtual modules are static - HMR disabled"),[];let _=Date.now();return T?(w.debug("HMR already in progress, skipping update"),[]):_-de<b?(xe||(xe=!0,ae=setTimeout(()=>{xe=!1,de=Date.now(),Se(y)},b)),[]):(de=_,Se(y))}function Se(y){let _=Date.now();if(j===y.file&&_-de<100)return w.debug(`Same file processed too recently: ${y.file}`),[];if(!Re(y.file))return w.debug(`Skipping irrelevant file change: ${y.file}`),[];w.debug(`Relevant file changed: ${y.file}`),T=!0,j=y.file;try{let G=Date.now()-(R?.timestamp||0);if(G<E&&R){w.debug(`Using cached discovery data (age: ${G}ms)`);let K=y.server.moduleGraph.getModuleById(M);return K&&y.server.reloadModule(K),[]}I.clearCache();let ce=y.server.moduleGraph.getModuleById(M);return ce&&y.server.reloadModule(ce),[]}finally{T=!1,setTimeout(()=>{j===y.file&&(j=null)},200)}}return{name:e,enforce:"pre",configResolved(y){q=y.root,Y=y.command==="serve",d&&w.debug(`${t} ${e} initialized`),Y&&w.debug("\u{1F4A1} Dev mode: Press 'r' in terminal to restart, or use global.__DNDEV_CLEAR_CACHE__() in console"),i.logConfig&&i.logConfig(x)},config(y){return y.optimizeDeps||(y.optimizeDeps={}),y.optimizeDeps.exclude||(y.optimizeDeps.exclude=[]),y.optimizeDeps.exclude.includes(S)||y.optimizeDeps.exclude.push(S),y},resolveId(y){return y===S?(w.debug(`Resolving virtual module: ${y}`),{id:M,moduleSideEffects:!0}):null},async load(y){if(y!==M)return null;if(w.debug(`Loading virtual module: ${y}`),!O()){w.warn("\u26A0\uFE0F load() called before appRoot is set - waiting for config resolution");let _=0;for(;!O()&&_<100;)await new Promise(G=>setTimeout(G,10)),_++;if(!O())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let _;return R?(w.debug("Using cached discovery data for virtual module"),_=R):(w.warn(`\u26A0\uFE0F No cached discovery data found for ${e} - running discovery in load() hook. This may indicate buildStart() hook did not run or failed. Performance may be impacted.`),_=await I[o](),R=_,w.debug("Discovery completed for virtual module")),ie(_)}catch(_){return w.error(`${e} virtual module (${M}) failed to load: ${_.message}`),w.error(`Stack: ${_.stack||"No stack trace available"}`),i.generateEmpty({},d,x,D)}},async buildStart(){if(L=!1,!O()){w.warn("\u26A0\uFE0F buildStart() called before appRoot is set - waiting for config resolution");let y=0;for(;!O()&&y<100;)await new Promise(_=>setTimeout(_,10)),y++;if(!O())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let y=await I[o](!R);if(R=y,l&&p==="routes"&&y?.routes)try{let _=Ue(y.routes,{appRoot:v.getAppRoot()}),G=[...y.routes.map(Ae=>({path:Ae.path,auth:Ae.auth,meta:Ae.meta})),..._],ce={routes:G,source:y.source||"auto-discovery",totalRoutes:G.length,generatedAt:new Date().toISOString()},K=v.resolveAppPath(`public/${l}`);await v.write(K,JSON.stringify(ce,null,2)),w.debug(`Generated route manifest: public/${l}`)}catch(_){w.error(`Failed to write route manifest: ${_.message}`)}i.logStats&&i.logStats(y,t,w)}catch(y){w.error(`${e} discovery failed during file scanning: ${y.message}`),w.error(`Stack: ${y.stack||"No stack trace available"}`),R=X.getEmptyResultWithError(I,y)}finally{L=!0}},configureServer(){L=!0},handleHotUpdate(y){return F?[]:L?$e(y):(w.debug("HMR disabled - discovery not complete yet"),[])},generateBundle(){if(!R){w.warn("No cached discovery data for manifest generation - skipping");return}try{let y=X.generateManifest(R,i.generateManifest);this.emitFile({type:"asset",fileName:l,source:JSON.stringify(y,null,2)}),m&&i.logManifest&&i.logManifest(R,e)}catch(y){w.error(`${e} manifest generation failed: ${y.message}`),w.error(`Stack: ${y.stack||"No stack trace available"}`)}},transform(y,_){return _===M?{code:y,map:null}:null}}}}var Mo={generateGlobals:X.generateGlobals,generateExports:X.generateExports,generateDefaultExport:X.generateDefaultExport,wrapVirtualModule:X.wrapVirtualModule,generateInspectionHeader:X.generateInspectionHeader,validateTemplates:X.validateTemplates,createTemplateConfig:X.createTemplateConfig};W();var oe=class n{constructor(e,t={}){if(this.constructor===n)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...t},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=C(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let r=await this._scanFiles(s),o=await this._processFiles(r);this.cache={...o,timestamp:Date.now()};let a=Date.now()-t;return this.logger.debug(`Discovery completed in ${a}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(e){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(e){let t=this._getPatternType();return await this.pathResolver.resolveFiles(e,t)}_extractFileNameInfo(e){let t=e.split("/"),s=t[t.length-1],r=s.split(".")[0],o=s.split(".").pop();return{fileName:s,baseName:r,extension:o,directory:t.slice(0,-1).join("/")}}async _processSingleFile(e,t){try{let s=this.pathResolver.getFileInfo(e);return s?await t(s):(this.logger.debug(`Could not get file info: ${e}`),null)}catch(s){return this.logger.debug(`Error processing file ${e}: ${s.message}`),null}}async _batchProcessFiles(e,t){return(await Promise.all(e.map(r=>this._processSingleFile(r,t)))).filter(r=>r!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};W();var We=class extends oe{constructor(e,t={}){super(e,{assets:se.assets.fallback,assetPatterns:se.assets.patterns,frameworkPackage:Qe.package,assetsPath:Qe.assetsPath,modernFormats:se.assets.modern,...t}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(t),r=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(r)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let a=[],i=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(i)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(t))?.generated||[]);let{consumerFiles:l}=e,c=await this._processAssetFiles(l),u=this._buildAssetManifest(c),p=await this._readLogoSvgContent("/logo.svg",t);return{assets:c,manifest:{...u,logoSvgContent:p},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(c)}}_extractPWAIcons(e){let t=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return e.filter(s=>{let r=s.path.split("/").pop()||"";return t.some(o=>o.test(r))}).map(s=>{let r=s.path.split("/").pop()||"",o=r.match(/(\d+)x(\d+)/),a=o?{width:parseInt(o[1]),height:parseInt(o[2])}:this._getDefaultIconSize(r);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(r)}})}_getDefaultIconSize(e){return e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(e){return e.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(e){return e.includes("maskable")||e.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let e=this.cache?.assets?.length||0,t=this.cache?.copiedAssets?.length||0;return`${e} assets, ${t} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,t){let s=this.getAssets().map(o=>o.path),r=t||this.options.modernFormats;for(let o of r){let a=`/${e}.${o}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let t=[];try{let s=await this._resolveFrameworkAssetsDir(e);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),t;let r=this.pathResolver.resolveAppPath(Oe.public);this.pathResolver.pathExists(r)||(this.pathResolver.mkdir(r),this.logger.debug(`Created public directory: ${r}`));for(let o of this.options.assets)await this._ensureAsset(o,r,s)&&t.push(o);t.length>0&&this.logger.debug(`Added ${t.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return t}async _ensureAsset(e,t,s){let r=this.pathResolver.resolveAppPath(`${Oe.public}/${e}`);if(this.pathResolver.pathExists(r))return this.logger.debug(`Asset exists: ${e}`),!1;let o=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(o)){if(await this.pathResolver.copy(o,r))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _processAssetFiles(e){let t=[];for(let s of e)try{let r=this.pathResolver.getFileInfo(s);if(r&&r.isFile){let o=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(o,r.size);a&&t.push(a)}}catch(r){this.logger.debug(`Error processing asset file ${s}: ${r.message}`)}return this.logger.debug(`Processed ${t.length} assets from ${e.length} files`),t}_analyzeAsset(e,t){let s=this._determineAssetType(e),r=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:r,size:t,sizeFormatted:this._formatBytes(t),isModern:this.options.modernFormats.includes(r)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let t=e.toLowerCase();if(t.includes("favicon"))return"favicon";if(t.includes("logo"))return"logo";if(t.includes("icon"))return"icon";if(t.includes("apple-touch"))return"apple-touch-icon";if(t.includes("android-chrome"))return"android-icon";if(t.includes("manifest"))return"manifest";let s=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(e){return e.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(e){if(e===0)return"0 Bytes";let t=1024,s=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+s[r]}_matchesPattern(e,t){let s=e.toLowerCase(),r=t.toLowerCase();return s.includes(r.replace("*",""))}_buildAssetManifest(e){let t=e.map(r=>r.path);return{logo:{optimal:this._getOptimalAsset("logo",t,this.options.modernFormats),fallback:this._getOptimalAsset("logo",t,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",t,["svg","ico"]),fallback:this._getOptimalAsset("favicon",t,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",t,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",t,["png"]),512:this._getOptimalAsset("android-chrome-512x512",t,["png"])},manifest:t.find(r=>r.includes("manifest.json"))||null,modernFormats:e.filter(r=>r.isModern).map(r=>r.path),fallbackFormats:e.filter(r=>!r.isModern).map(r=>r.path)}}_getOptimalAsset(e,t,s){for(let r of s){let o=`/${e}.${r}`;if(t.includes(o))return o}return null}async _resolveFrameworkAssetsDir(e){try{let t=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",t);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let r=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(r)?(this.logger.debug(`Using framework assets from: ${r}`),r):(this.logger.debug(`Assets directory not found: ${r}`),null)}catch(t){return this.logger.debug(`Error resolving framework assets directory: ${t.message}`),null}}async _resolvePackage(e,t){try{let s=this.pathResolver.resolveFrameworkPackage(e,t);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${e} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${e}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(e,t){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),r=this.pathResolver.resolveAppPath(`${Oe.public}/${s}`);return this.pathResolver.pathExists(r)&&await this.pathResolver.read(r,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let t=await this._resolveFrameworkAssetsDir(e);if(!t)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${t}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let r=this.pathResolver.resolveAppPath(Oe.public);this.pathResolver.pathExists(r)||this.pathResolver.mkdir(r);let o=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,o)}catch(t){return this.logger.debug(`Failed to copy framework logo: ${t.message}`),!1}}async _generateMissingAssets(e){let t=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(t))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let r=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],o=[{name:"favicon.svg",format:"svg"}],a=[],i=[];try{let l=await this.pathResolver.read(t,{format:"text"});if(!l)return{generated:[],skipped:[...o,...r].map(u=>u.name),error:"Failed to read logo.svg"};for(let u of o){let p=`${s}/${u.name}`;if(this.pathResolver.pathExists(p)){i.push(u.name);continue}try{await this.pathResolver.write(`public/${u.name}`,l),a.push(u.name)}catch(g){this.logger.debug(`Failed to copy ${u.name}: ${g.message}`),i.push(u.name)}}let c=await import("sharp").catch(()=>null);if(!c)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),i.push(...r.map(u=>u.name));else for(let u of r){let p=`${s}/${u.name}`;if(this.pathResolver.pathExists(p)){i.push(u.name);continue}try{let g=c.default(t).resize(u.size,u.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),f;u.format==="ico"?f=await g.toFormat("png").toBuffer():f=await g.toFormat(u.format).toBuffer(),await this.pathResolver.write(`public/${u.name}`,f),a.push(u.name)}catch(g){this.logger.debug(`Failed to generate ${u.name}: ${g.message}`),i.push(u.name)}}return{generated:a,skipped:i,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(c=>c.name),error:l.message}}}};U();var Ct={data:null},qs={isEmpty:n=>!n.manifest||n.assets?.length===0,generateModule:(n,e,t="assets")=>{let{manifest:s,assets:r,copiedAssets:o}=n,a=s.logoSvgContent||null,i={totalAssets:r.length,copiedAssets:o.length,hasLogo:s.logo.optimal!==null,hasFavicon:s.favicon.optimal!==null,hasManifest:s.manifest!==null,timestamp:new Date().toISOString()};return`// ${z.assets} - Generated asset manifest
51
+ `),H}function Pe(v){let _=v.replace(/\\/g,"/");if(T||_.includes("/node_modules/")||_.includes("/.git/")||_.includes("/dist/")||_.includes("/build/")||_.includes("/coverage/")||_.includes("/.vite/")||_.includes("/.turbo/")||_.endsWith(".d.ts")||_.endsWith(".tsbuildinfo")||_.endsWith(".map")||_.endsWith(".css.map")||_.endsWith(".generated.log")||/\.generated\.[a-z]+$/.test(_))return!1;let H=C.getRelativePath(_);if(H.startsWith("packages/"))return!1;let ue=H.startsWith("src/")&&/\.(ts|tsx)$/.test(H);return ue?Array.isArray(a)&&a.length>0?a.some(K=>typeof K=="function"?K(_):typeof K=="string"?K.startsWith("**/")?_.endsWith(K.slice(3)):_.endsWith(K):!1):ue:!1}function Re(v){if(T)return b.debug("Virtual modules are static - HMR disabled"),[];let _=Date.now();return O?(b.debug("HMR already in progress, skipping update"),[]):_-ie<w?(xe||(xe=!0,J=setTimeout(()=>{xe=!1,ie=Date.now(),$e(v)},w)),[]):(ie=_,$e(v))}function $e(v){let _=Date.now();if(L===v.file&&_-ie<100)return b.debug(`Same file processed too recently: ${v.file}`),[];if(!Pe(v.file))return b.debug(`Skipping irrelevant file change: ${v.file}`),[];b.debug(`Relevant file changed: ${v.file}`),O=!0,L=v.file;try{let H=Date.now()-(P?.timestamp||0);if(H<$&&P){b.debug(`Using cached discovery data (age: ${H}ms)`);let K=v.server.moduleGraph.getModuleById(F);return K&&v.server.reloadModule(K),[]}j.clearCache();let ue=v.server.moduleGraph.getModuleById(F);return ue&&v.server.reloadModule(ue),[]}finally{O=!1,setTimeout(()=>{L===v.file&&(L=null)},200)}}return{name:e,enforce:"pre",configResolved(v){U=v.root,te=v.command==="serve",d&&b.debug(`${t} ${e} initialized`),te&&b.debug("\u{1F4A1} Dev mode: Press 'r' in terminal to restart, or use global.__DNDEV_CLEAR_CACHE__() in console"),i.logConfig&&i.logConfig(N)},config(v){return v.optimizeDeps||(v.optimizeDeps={}),v.optimizeDeps.exclude||(v.optimizeDeps.exclude=[]),v.optimizeDeps.exclude.includes(S)||v.optimizeDeps.exclude.push(S),v},resolveId(v){return v===S?(b.debug(`Resolving virtual module: ${v}`),{id:F,moduleSideEffects:!0}):null},async load(v){if(v!==F)return null;if(b.debug(`Loading virtual module: ${v}`),!y()){b.warn("\u26A0\uFE0F load() called before appRoot is set - waiting for config resolution");let _=0;for(;!y()&&_<100;)await new Promise(H=>setTimeout(H,10)),_++;if(!y())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let _;return P?(b.debug("Using cached discovery data for virtual module"),_=P):(b.warn(`\u26A0\uFE0F No cached discovery data found for ${e} - running discovery in load() hook. This may indicate buildStart() hook did not run or failed. Performance may be impacted.`),_=await j[o](),P=_,b.debug("Discovery completed for virtual module")),le(_)}catch(_){return b.error(`${e} virtual module (${F}) failed to load: ${_.message}`),b.error(`Stack: ${_.stack||"No stack trace available"}`),i.generateEmpty({},d,N,x)}},async buildStart(){if(z=!1,!y()){b.warn("\u26A0\uFE0F buildStart() called before appRoot is set - waiting for config resolution");let v=0;for(;!y()&&v<100;)await new Promise(_=>setTimeout(_,10)),v++;if(!y())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let v=await j[o](!P);if(P=v,l&&p==="routes"&&v?.routes)try{let _=Ue(v.routes,{appRoot:C.getAppRoot()}),H=[...v.routes.map(Ee=>({path:Ee.path,auth:Ee.auth,meta:Ee.meta})),..._],ue={routes:H,source:v.source||"auto-discovery",totalRoutes:H.length,generatedAt:new Date().toISOString()},K=C.resolveAppPath(`public/${l}`);await C.write(K,JSON.stringify(ue,null,2)),b.debug(`Generated route manifest: public/${l}`)}catch(_){b.error(`Failed to write route manifest: ${_.message}`)}i.logStats&&i.logStats(v,t,b)}catch(v){b.error(`${e} discovery failed during file scanning: ${v.message}`),b.error(`Stack: ${v.stack||"No stack trace available"}`),P=X.getEmptyResultWithError(j,v)}finally{z=!0}},configureServer(){z=!0},handleHotUpdate(v){return T?[]:z?Re(v):(b.debug("HMR disabled - discovery not complete yet"),[])},generateBundle(){if(!P){b.warn("No cached discovery data for manifest generation - skipping");return}try{let v=X.generateManifest(P,i.generateManifest);this.emitFile({type:"asset",fileName:l,source:JSON.stringify(v,null,2)}),m&&i.logManifest&&i.logManifest(P,e)}catch(v){b.error(`${e} manifest generation failed: ${v.message}`),b.error(`Stack: ${v.stack||"No stack trace available"}`)}},transform(v,_){return _===F?{code:v,map:null}:null}}}}var zo={generateGlobals:X.generateGlobals,generateExports:X.generateExports,generateDefaultExport:X.generateDefaultExport,wrapVirtualModule:X.wrapVirtualModule,generateInspectionHeader:X.generateInspectionHeader,validateTemplates:X.validateTemplates,createTemplateConfig:X.createTemplateConfig};G();var ne=class n{constructor(e,t={}){if(this.constructor===n)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...t},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=I(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let r=await this._scanFiles(s),o=await this._processFiles(r);this.cache={...o,timestamp:Date.now()};let a=Date.now()-t;return this.logger.debug(`Discovery completed in ${a}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(e){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(e){let t=this._getPatternType();return await this.pathResolver.resolveFiles(e,t)}_extractFileNameInfo(e){let t=e.split("/"),s=t[t.length-1],r=s.split(".")[0],o=s.split(".").pop();return{fileName:s,baseName:r,extension:o,directory:t.slice(0,-1).join("/")}}async _processSingleFile(e,t){try{let s=this.pathResolver.getFileInfo(e);return s?await t(s):(this.logger.debug(`Could not get file info: ${e}`),null)}catch(s){return this.logger.debug(`Error processing file ${e}: ${s.message}`),null}}async _batchProcessFiles(e,t){return(await Promise.all(e.map(r=>this._processSingleFile(r,t)))).filter(r=>r!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};G();var We=class extends ne{constructor(e,t={}){super(e,{assets:re.assets.fallback,assetPatterns:re.assets.patterns,frameworkPackage:Qe.package,assetsPath:Qe.assetsPath,modernFormats:re.assets.modern,...t}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(t),r=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(r)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let a=[],i=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(i)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(t))?.generated||[]);let{consumerFiles:l}=e,c=await this._processAssetFiles(l),u=this._buildAssetManifest(c),p=await this._readLogoSvgContent("/logo.svg",t);return{assets:c,manifest:{...u,logoSvgContent:p},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(c)}}_extractPWAIcons(e){let t=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return e.filter(s=>{let r=s.path.split("/").pop()||"";return t.some(o=>o.test(r))}).map(s=>{let r=s.path.split("/").pop()||"",o=r.match(/(\d+)x(\d+)/),a=o?{width:parseInt(o[1]),height:parseInt(o[2])}:this._getDefaultIconSize(r);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(r)}})}_getDefaultIconSize(e){return e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(e){return e.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(e){return e.includes("maskable")||e.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let e=this.cache?.assets?.length||0,t=this.cache?.copiedAssets?.length||0;return`${e} assets, ${t} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,t){let s=this.getAssets().map(o=>o.path),r=t||this.options.modernFormats;for(let o of r){let a=`/${e}.${o}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let t=[];try{let s=await this._resolveFrameworkAssetsDir(e);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),t;let r=this.pathResolver.resolveAppPath(Oe.public);this.pathResolver.pathExists(r)||(this.pathResolver.mkdir(r),this.logger.debug(`Created public directory: ${r}`));for(let o of this.options.assets)await this._ensureAsset(o,r,s)&&t.push(o);t.length>0&&this.logger.debug(`Added ${t.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return t}async _ensureAsset(e,t,s){let r=this.pathResolver.resolveAppPath(`${Oe.public}/${e}`);if(this.pathResolver.pathExists(r))return this.logger.debug(`Asset exists: ${e}`),!1;let o=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(o)){if(await this.pathResolver.copy(o,r))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _processAssetFiles(e){let t=[];for(let s of e)try{let r=this.pathResolver.getFileInfo(s);if(r&&r.isFile){let o=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(o,r.size);a&&t.push(a)}}catch(r){this.logger.debug(`Error processing asset file ${s}: ${r.message}`)}return this.logger.debug(`Processed ${t.length} assets from ${e.length} files`),t}_analyzeAsset(e,t){let s=this._determineAssetType(e),r=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:r,size:t,sizeFormatted:this._formatBytes(t),isModern:this.options.modernFormats.includes(r)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let t=e.toLowerCase();if(t.includes("favicon"))return"favicon";if(t.includes("logo"))return"logo";if(t.includes("icon"))return"icon";if(t.includes("apple-touch"))return"apple-touch-icon";if(t.includes("android-chrome"))return"android-icon";if(t.includes("manifest"))return"manifest";let s=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(e){return e.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(e){if(e===0)return"0 Bytes";let t=1024,s=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+s[r]}_matchesPattern(e,t){let s=e.toLowerCase(),r=t.toLowerCase();return s.includes(r.replace("*",""))}_buildAssetManifest(e){let t=e.map(r=>r.path);return{logo:{optimal:this._getOptimalAsset("logo",t,this.options.modernFormats),fallback:this._getOptimalAsset("logo",t,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",t,["svg","ico"]),fallback:this._getOptimalAsset("favicon",t,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",t,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",t,["png"]),512:this._getOptimalAsset("android-chrome-512x512",t,["png"])},manifest:t.find(r=>r.includes("manifest.json"))||null,modernFormats:e.filter(r=>r.isModern).map(r=>r.path),fallbackFormats:e.filter(r=>!r.isModern).map(r=>r.path)}}_getOptimalAsset(e,t,s){for(let r of s){let o=`/${e}.${r}`;if(t.includes(o))return o}return null}async _resolveFrameworkAssetsDir(e){try{let t=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",t);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let r=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(r)?(this.logger.debug(`Using framework assets from: ${r}`),r):(this.logger.debug(`Assets directory not found: ${r}`),null)}catch(t){return this.logger.debug(`Error resolving framework assets directory: ${t.message}`),null}}async _resolvePackage(e,t){try{let s=this.pathResolver.resolveFrameworkPackage(e,t);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${e} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${e}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(e,t){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),r=this.pathResolver.resolveAppPath(`${Oe.public}/${s}`);return this.pathResolver.pathExists(r)&&await this.pathResolver.read(r,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let t=await this._resolveFrameworkAssetsDir(e);if(!t)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${t}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let r=this.pathResolver.resolveAppPath(Oe.public);this.pathResolver.pathExists(r)||this.pathResolver.mkdir(r);let o=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,o)}catch(t){return this.logger.debug(`Failed to copy framework logo: ${t.message}`),!1}}async _generateMissingAssets(e){let t=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(t))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let r=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],o=[{name:"favicon.svg",format:"svg"}],a=[],i=[];try{let l=await this.pathResolver.read(t,{format:"text"});if(!l)return{generated:[],skipped:[...o,...r].map(u=>u.name),error:"Failed to read logo.svg"};for(let u of o){let p=`${s}/${u.name}`;if(this.pathResolver.pathExists(p)){i.push(u.name);continue}try{await this.pathResolver.write(`public/${u.name}`,l),a.push(u.name)}catch(g){this.logger.debug(`Failed to copy ${u.name}: ${g.message}`),i.push(u.name)}}let c=await import("sharp").catch(()=>null);if(!c)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),i.push(...r.map(u=>u.name));else for(let u of r){let p=`${s}/${u.name}`;if(this.pathResolver.pathExists(p)){i.push(u.name);continue}try{let g=c.default(t).resize(u.size,u.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),f;u.format==="ico"?f=await g.toFormat("png").toBuffer():f=await g.toFormat(u.format).toBuffer(),await this.pathResolver.write(`public/${u.name}`,f),a.push(u.name)}catch(g){this.logger.debug(`Failed to generate ${u.name}: ${g.message}`),i.push(u.name)}}return{generated:a,skipped:i,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(c=>c.name),error:l.message}}}};W();var Ct={data:null},Ys={isEmpty:n=>!n.manifest||n.assets?.length===0,generateModule:(n,e,t="assets")=>{let{manifest:s,assets:r,copiedAssets:o}=n,a=s.logoSvgContent||null,i={totalAssets:r.length,copiedAssets:o.length,hasLogo:s.logo.optimal!==null,hasFavicon:s.favicon.optimal!==null,hasManifest:s.manifest!==null,timestamp:new Date().toISOString()};return`// ${M.assets} - Generated asset manifest
52
52
  const assetManifest = ${JSON.stringify(s,null,2)};
53
53
  const assetStats = ${JSON.stringify(i,null,2)};
54
54
 
@@ -66,7 +66,7 @@ if (typeof globalThis !== 'undefined') {
66
66
  }
67
67
 
68
68
  // Populate assets configuration
69
- globalThis._DNDEV_CONFIG_.${H[t]} = {
69
+ globalThis._DNDEV_CONFIG_.${q[t]} = {
70
70
  mapping: assetManifest,
71
71
  logoSvgContent: ${JSON.stringify(a)},
72
72
  manifest: {
@@ -118,7 +118,7 @@ export default {
118
118
  getManifest,
119
119
  getAllAssets
120
120
  };
121
- `},generateEmpty:(n,e,t,s="assets")=>{let r={totalAssets:0,copiedAssets:0,hasLogo:!1,hasFavicon:!1,hasManifest:!1,timestamp:new Date().toISOString()};return`// ${z.assets} - Empty asset manifest
121
+ `},generateEmpty:(n,e,t,s="assets")=>{let r={totalAssets:0,copiedAssets:0,hasLogo:!1,hasFavicon:!1,hasManifest:!1,timestamp:new Date().toISOString()};return`// ${M.assets} - Empty asset manifest
122
122
  const assetManifest = {
123
123
  logo: { optimal: null, fallback: null },
124
124
  favicon: { optimal: null, fallback: null },
@@ -144,7 +144,7 @@ if (typeof globalThis !== 'undefined') {
144
144
  }
145
145
 
146
146
  // Populate empty assets configuration
147
- globalThis._DNDEV_CONFIG_.${H[s]} = {
147
+ globalThis._DNDEV_CONFIG_.${q[s]} = {
148
148
  mapping: assetManifest,
149
149
  logoSvgContent: null,
150
150
  manifest: {
@@ -217,7 +217,7 @@ export default discoveredAssets;
217
217
  `:`/**
218
218
  * Generated Asset Discovery Results
219
219
  * Generated at: ${new Date().toISOString()}
220
- * Import from '${z.assets}'
220
+ * Import from '${M.assets}'
221
221
  */
222
222
 
223
223
  export const discoveredAssets = ${JSON.stringify(e,null,2)};
@@ -234,14 +234,14 @@ export const assetStats = {
234
234
  };
235
235
 
236
236
  export default discoveredAssets;
237
- `},generateManifest:n=>({assets:n.assets?.length||0,copied:n.copiedAssets?.length||0,timestamp:Date.now(),hasLogo:n.manifest?.logo?.optimal!==null,hasFavicon:n.manifest?.favicon?.optimal!==null}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.assets?.length||0,r=n.generatedAssets?.length||0;t&&(r>0?t.info(`${e} Assets: ${s} found, ${r} generated`):t.info(`${e} Assets: ${s} found`))}},Ys=[n=>n.includes("/public/"),n=>n.endsWith(".png")||n.endsWith(".svg")||n.endsWith(".ico"),n=>n.includes("favicon")||n.includes("logo")||n.includes("manifest")];function It(n={}){let e=ge({pluginName:"dndev-vite-asset-discovery",icon:"\u{1F3AF}",virtualModuleId:z.assets,DiscoveryClass:We,discoveryMethod:"discoverAssets",filePatterns:Ys,templates:qs,manifestFileName:ue.manifests.asset,configKey:"assets"})(n),t=$.getInstance(),s=C("asset-plugin",n.debug,n.verbose),r=e.buildStart;return e.buildStart=async function(...o){r&&await r.apply(this,o)},e}W();var zt=z.blog,Mt="\0"+zt;function Lt(){return{name:"dndev-vite-blog",resolveId(n){if(n===zt)return Mt},load(n){if(n===Mt)return`
237
+ `},generateManifest:n=>({assets:n.assets?.length||0,copied:n.copiedAssets?.length||0,timestamp:Date.now(),hasLogo:n.manifest?.logo?.optimal!==null,hasFavicon:n.manifest?.favicon?.optimal!==null}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.assets?.length||0,r=n.generatedAssets?.length||0;t&&(r>0?t.info(`${e} Assets: ${s} found, ${r} generated`):t.info(`${e} Assets: ${s} found`))}},Ks=[n=>n.includes("/public/"),n=>n.endsWith(".png")||n.endsWith(".svg")||n.endsWith(".ico"),n=>n.includes("favicon")||n.includes("logo")||n.includes("manifest")];function It(n={}){let e=fe({pluginName:"dndev-vite-asset-discovery",icon:"\u{1F3AF}",virtualModuleId:M.assets,DiscoveryClass:We,discoveryMethod:"discoverAssets",filePatterns:Ks,templates:Ys,manifestFileName:pe.manifests.asset,configKey:"assets"})(n),t=R.getInstance(),s=I("asset-plugin",n.debug,n.verbose),r=e.buildStart;return e.buildStart=async function(...o){r&&await r.apply(this,o)},e}G();var zt=M.blog,Mt="\0"+zt;function Lt(){return{name:"dndev-vite-blog",resolveId(n){if(n===zt)return Mt},load(n){if(n===Mt)return`
238
238
  const files = import.meta.glob('/src/content/blog/*.md', {
239
239
  query: '?raw',
240
240
  import: 'default',
241
241
  eager: true,
242
242
  });
243
243
  export default files;
244
- `}}}import{loadEnv as Ks}from"vite";W();var jt={isEmpty:n=>!n.env||Object.keys(n.env).length===0,generateModule:(n,e,t="env")=>{let{env:s,mode:r}=n;if(!s||Object.keys(s).length===0)return jt.generateEmpty(n,e,void 0,t);let o={totalVars:Object.keys(s).length,mode:r,source:n.source,generatedAt:new Date().toISOString()};return`// ${z.env} - Generated environment variables
244
+ `}}}import{loadEnv as Zs}from"vite";G();var jt={isEmpty:n=>!n.env||Object.keys(n.env).length===0,generateModule:(n,e,t="env")=>{let{env:s,mode:r}=n;if(!s||Object.keys(s).length===0)return jt.generateEmpty(n,e,void 0,t);let o={totalVars:Object.keys(s).length,mode:r,source:n.source,generatedAt:new Date().toISOString()};return`// ${M.env} - Generated environment variables
245
245
 
246
246
  const envData = ${JSON.stringify(s,null,2)};
247
247
  const envManifest = ${JSON.stringify(o,null,2)};
@@ -270,7 +270,7 @@ if (typeof globalThis !== 'undefined') {
270
270
  }
271
271
 
272
272
  // Populate env configuration (frozen to prevent tampering)
273
- globalThis._DNDEV_CONFIG_.${H[t]} = envData;
273
+ globalThis._DNDEV_CONFIG_.${q[t]} = envData;
274
274
  // Only freeze the env property, not the entire config (other plugins need to add properties)
275
275
  }
276
276
 
@@ -281,7 +281,7 @@ export const source = '${n.source}';
281
281
 
282
282
  // Default export
283
283
  export default envData;
284
- `},generateEmpty:(n,e,t,s="env")=>{let r={totalVars:0,mode:n.mode||"development",source:"empty",generatedAt:new Date().toISOString()};return`// ${z.env} - Empty environment data
284
+ `},generateEmpty:(n,e,t,s="env")=>{let r={totalVars:0,mode:n.mode||"development",source:"empty",generatedAt:new Date().toISOString()};return`// ${M.env} - Empty environment data
285
285
 
286
286
  const envData = {};
287
287
  const envManifest = ${JSON.stringify(r,null,2)};
@@ -310,7 +310,7 @@ if (typeof globalThis !== 'undefined') {
310
310
  }
311
311
 
312
312
  // Populate empty env configuration (frozen to prevent tampering)
313
- globalThis._DNDEV_CONFIG_.${H[s]} = envData;
313
+ globalThis._DNDEV_CONFIG_.${q[s]} = envData;
314
314
  // Only freeze the env property, not the entire config (other plugins need to add properties)
315
315
  }
316
316
 
@@ -320,16 +320,16 @@ export const source = 'empty';
320
320
 
321
321
  export default envData;
322
322
  `},generateInspection:n=>{let{env:e,mode:t}=n;return["/**"," * Generated Environment Variables",` * Mode: ${t}`,` * Generated at: ${new Date().toISOString()}`,` * Total variables: ${Object.keys(e).length}`," */","","```json",JSON.stringify(e,null,2),"```"].join(`
323
- `)},generateManifest:n=>({totalVars:Object.keys(n?.env||{}).length,mode:n?.mode||"development",variables:Object.keys(n?.env||{}),timestamp:Date.now()}),logStats:(n,e,t)=>{let s=Object.keys(n.env).length;t&&t.info(`${e} Env: ${s} VITE_* variables`)}},rt=class{constructor(e,t={}){this.pathResolver=e,this.options=t,this.mode=t.mode||"development",this.appRoot=null}async discoverEnv(){try{let e=this.pathResolver.getAppRoot();if(!e)throw new Error("App root not available in EnvDiscovery");let s={...Ks(this.mode,e,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${e}/.env`,errors:[]}}catch(e){return{env:{},mode:this.mode,source:"error",errors:[e.message]}}}};function Ut(n={}){return ge({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:z.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:jt,manifestFileName:ue.manifests.env,configKey:"env",createDiscovery:(e,t)=>new rt(e,{...t,mode:n.mode||t.mode||"development"})})({...n,disableHmr:!0})}W();W();function ot(n){let e=new Set(Object.keys(Te)),t=new Set(["latin"]);for(let o of n||[]){let a=bt[o];if(a)for(let i of a)t.add(i)}let s=[],r=new Set;for(let o of e){let a=Te[o];for(let i of t)for(let l of a){let c=`@fontsource/${o}/${i}-${l}.css`,u=`${o}-${i}-${l}-normal`;s.push(c),r.add(u)}}return{imports:s,stems:r,subsets:t,fontStems:e}}function Wt(n){return n.replace(/,\s*url\([^)]*\.woff\)\s*format\(['"]woff['"]\)/g,"")}W();U();W();function Zs(n){if(!n)return[];let e=$.getInstance(),t=new Set;try{let s=e.resolvePackage("@donotdev/core",n);if(!s)return[];let r=e.getDirname(e.getDirname(s)),o;try{o=e.readdirSync(r)}catch{return[]}for(let a of o)try{let i=e.resolvePath(`${a}/package.json`,r),l=e.readSync(i,{format:"json"});if(!l?.peerDependenciesMeta)continue;for(let[c,u]of Object.entries(l.peerDependenciesMeta))u?.optional&&t.add(c)}catch{}}catch{}return Array.from(t)}function Xs(n){if(!n)return[];let e=$.getInstance();try{let t=e.resolvePath("package.json",n),s=e.readSync(t,{format:"json"});if(!s)return[];let r=new Set;if(s.peerDependenciesMeta)for(let[o,a]of Object.entries(s.peerDependenciesMeta))a?.optional&&r.add(o);if(s.optionalDependencies)for(let o of Object.keys(s.optionalDependencies))r.add(o);return Array.from(r)}catch{return[]}}function Qs(n){let e=me.optionalFeatures||[],t=Zs(n),s=Xs(n);return[...new Set([...e,...t,...s])]}function er(n){let e=$.getInstance();try{let t=e.resolvePath("package.json",n),s=e.readSync(t,{format:"json"});return s?new Set([...Object.keys(s.dependencies||{}),...Object.keys(s.devDependencies||{})]):new Set}catch{return new Set}}function tr(n,e,t){if(t.resolvePackage(n,e||void 0))return!0;let s=n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0],r=e;for(let o=0;o<10;o++){let a=t.resolvePath(`node_modules/${s}`,r);if(t.pathExists(a))return!0;let i=t.getDirname(r);if(i===r)break;r=i}return!1}function Ge(n){let e=Qs(n),t=[],s=[],r=$.getInstance(),o=er(n);for(let a of e)a.startsWith("@donotdev/")?o.has(a)?s.push(a):t.push(a):o.has(a)&&tr(a,n,r)?s.push(a):t.push(a);return{missing:t,installed:s}}var Pe=class n extends oe{static LANGUAGE_FLAG_OVERRIDES={en:"gb","en-ca":"ca","es-ar":"ar","fr-be":"be",ar:"sa","ar-ma":"ma","ar-dz":"dz","ar-tn":"tn","ar-ly":"ly","ar-mr":"mr",hi:"in",sl:"si",uk:"ua",ga:"ie",gd:"gb-sct",br:"bzh",co:"fr-cor",am:"et",bn:"bd",gu:"in",kn:"in",ml:"in",mr:"in",ne:"np",pa:"pk",ta:"in",te:"in",ur:"pk",fa:"ir",kk:"kz",ky:"kg",tg:"tj",my:"mm",km:"kh",lo:"la",ka:"ge",hy:"am",be:"by",bs:"ba",sq:"al",ms:"my"};constructor(e,t={}){super(e,{fallbackLanguage:"en",additionalPaths:[],...t})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!t||t===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${t}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${t}, repoRoot=${s}`);let r=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${r.eager.length}, lazy: ${r.lazy.length}, framework eager: ${r.framework?.eager?.length||0}, framework lazy: ${r.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let o=je("i18n"),a=r.eager||[],i=r.lazy||[],l=(this.options.additionalPaths||[]).map(R=>{let T=R.endsWith(".json")?R:`${R}/*_*.json`;return this.pathResolver.resolveAppPath(T)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let c=r.framework?.eager||[],u=r.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${a.join(", ")}, lazy: ${i.join(", ")}, framework eager: ${c.join(", ")}, framework lazy: ${u.join(", ")}`),c.length===0&&u.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let p=this.pathResolver.normalizePath(t),g=this.pathResolver.normalizePath(s),f=(R,T)=>{let j=this.pathResolver.normalizePath(R),L=this.pathResolver.normalizePath(T);return j.startsWith(L)?j.slice(L.length+1):j},d=a.map(R=>f(R,t)),S=[...i,...l].map(R=>f(R,t)),b=c.map(R=>f(R,s)),E=u.map(R=>f(R,s)),N={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:t},F=await this.pathResolver._globWithNormalization(d,N),k=await this.pathResolver._globWithNormalization(S,N),x={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:o.ignore?.filter(R=>R!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(x.ignore)}`);let D=await this.pathResolver._globWithNormalization(b,x),w=await this.pathResolver._globWithNormalization(E,x);this.logger.debug(`Found ${F.length} eager, ${k.length} lazy, ${D.length} framework eager, ${w.length} framework lazy files`),D.length>0?this.logger.debug(`Framework eager files (first 3): ${D.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${c.join(", ")}`),w.length>0?this.logger.debug(`Framework lazy files (first 3): ${w.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${u.join(", ")}`);let v=[...new Set([...F,...k,...D,...w])],O=new Set([...F,...D]),P={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},{missing:I}=Ge(t),M=new Set(I.filter(R=>R.startsWith("@donotdev/")).map(R=>R.replace("@donotdev/","")));M.size>0&&this.logger.debug(`I18n namespace filter: excluding [${[...M].join(", ")}] (packages not installed)`);let q=new Map,Y=[...D,...w];for(let R of Y){let T=this._processTranslationFile(R,D.includes(R),t);if(T){if(M.has(T.namespace))continue;let j=`${T.namespace}_${T.language}`;q.set(j,T),P.allNamespaces.add(T.namespace),P.supportedLanguages.add(T.language),D.includes(R)&&P.eagerNamespaces.add(T.namespace)}}let ae=new Set;for(let R of v){if(Y.includes(R))continue;let T=this._processTranslationFile(R,O.has(R),t);if(T){let{namespace:j,language:L,importPath:ie,content:Re}=T,$e=`${T.namespace}_${T.language}`;if(q.has($e)){let Se=q.get($e);T.content=this._mergeTranslations(Se.content,Re)}P.allNamespaces.add(j),P.supportedLanguages.add(L),ae.add(L),O.has(R)&&P.eagerNamespaces.add(j),P.mapping[j]||(P.mapping[j]={}),P.mapping[j][L]=ie,T.content&&(P.content[j]||(P.content[j]={}),P.content[j][L]=T.content),P.files.push({path:R,relativePath:this.pathResolver.getRelativePath(R),namespace:j,language:L,eager:O.has(R),size:T.content?JSON.stringify(T.content).length:0})}}for(let[R,T]of q){let j=R.lastIndexOf("_"),L=R.slice(0,j),ie=R.slice(j+1);ae.size>0&&!ae.has(ie)||(!P.mapping[L]||!P.mapping[L][ie])&&(P.mapping[L]||(P.mapping[L]={}),P.mapping[L][ie]=T.importPath,P.content[L]||(P.content[L]={}),P.content[L][ie]=T.content,P.files.push({path:T.absolutePath,relativePath:this.pathResolver.getRelativePath(T.absolutePath),namespace:L,language:ie,eager:P.eagerNamespaces.has(L),size:T.content?JSON.stringify(T.content).length:0}))}let de=ae.size>0?[...ae].sort():[this.options.fallbackLanguage],xe=[...new Set(de.map(R=>n.LANGUAGE_FLAG_OVERRIDES[R]||R))];return{mapping:P.mapping,content:P.content,eagerNamespaces:[...P.eagerNamespaces].sort(),allNamespaces:[...P.allNamespaces].sort(),supportedLanguages:de,fallbackLanguage:this.options.fallbackLanguage,flagCodes:xe,files:P.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,flagCodes:[n.LANGUAGE_FLAG_OVERRIDES[this.options.fallbackLanguage]||this.options.fallbackLanguage],files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let r=Date.now()-t;return this.logger.debug(`Discovery completed in ${r}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(e=!1){return await this.discover(e)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(e,t,s){let r=e.split("/").pop()||e.split("\\").pop()||"",o,a,i=r.match(/^(.+)_([^_.]+)\.json$/);if(!i)return this.logger.debug(`Invalid translation file name format: ${r}`),null;if([,o,a]=i,!o||!a)return this.logger.debug(`Invalid namespace or language in file: ${r}`),null;let c="./"+this.pathResolver.getRelativePath(e).replace(/\\/g,"/"),u;try{if(u=this.pathResolver.readSync(e,{format:"json"}),!u)return this.logger.debug(`Could not read file: ${e}`),null}catch(p){return this.logger.debug(`Error parsing JSON from ${e}: ${p.message}`),null}return{namespace:o,language:a,importPath:c,absolutePath:e,content:u}}_mergeTranslations(e,t){let s={...e};for(let[r,o]of Object.entries(t))typeof o=="object"&&o!==null&&!Array.isArray(o)?s[r]=this._mergeTranslations(s[r]||{},o):s[r]=o;return s}};U();var sr=3,nt="<!-- DNDEV_FONT_PRELOADS -->",at=Object.keys(Te);function Gt(n={}){let{debug:e=!1}=n,t=C("font-preload",e,!1),s,r={},o=!1,a=new Set,i=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(l){o=l.command==="build",r={root:l.root,base:l.base&&l.base!=="/"?l.base.replace(/\/$/,""):"",outDir:l.build?.outDir??"dist"};try{s=$.getInstance()}catch(c){t.debug(`Font preload: PathResolver not ready: ${c?.message}`)}},async buildStart(){if(!(!o||!s||!s.getAppRoot()))try{let c=["en"];try{let g=await new Pe(s,{fallbackLanguage:"en"}).discoverTranslations();g?.supportedLanguages?.length&&(c=g.supportedLanguages)}catch(p){t.debug(`Font preload: i18n discovery failed, using 'en': ${p?.message}`)}let u=ot(c);a=u.stems,t.debug(`Font filter: ${u.fontStems.size} font(s), ${u.subsets.size} subset(s), ${a.size} allowed stem(s)`)}catch(c){t.debug(`Font preload: discovery failed, using defaults: ${c?.message}`),a=ot(["en"]).stems}},generateBundle(l,c){if(a.size===0)return;let u=0,p=0;for(let d of Object.keys(c)){if(c[d].type!=="asset")continue;let S=d.toLowerCase();d.endsWith(".woff")?at.some(b=>S.includes(b))&&(delete c[d],u++):d.endsWith(".woff2")&&at.some(E=>S.includes(E))&&(Array.from(a).some(N=>S.includes(N))||(delete c[d],p++))}t.debug(`Font filter: deleted ${u} .woff + ${p} .woff2 from bundle`);for(let[d,m]of Object.entries(c)){if(m.type!=="asset"||!d.endsWith(".css")||typeof m.source!="string")continue;let S=m.source,b=S.replace(/@font-face\s*\{[\s\S]*?\}/g,E=>at.some(k=>E.includes(k))?Array.from(a).some(k=>E.includes(k))?Wt(E):"":E);b!==S&&(m.source=b)}let g=r.base||"",f=[];for(let[d,m]of Object.entries(c)){if(m.type!=="asset"||!d.endsWith(".woff2"))continue;let S=d.toLowerCase();if(Array.from(a).some(b=>S.includes(b))){let b=g?`${g}/${d}`:`/${d}`;f.push(b)}}i=f.slice(0,sr)},writeBundle(){if(!o||!i.length)return;let l=s||$.getInstance(),c=r.root||process.cwd(),u=r.outDir||"dist",p=l.resolvePath(`${u}/index.html`,c);try{if(!l.pathExists(p)){t.debug(`Font preload: index.html not found at ${p}`);return}let g=l.readSync(p,{format:"text"}),f=i.map(d=>`<link rel="preload" as="font" href="${d}" type="font/woff2" crossorigin="anonymous" />`).join(`
323
+ `)},generateManifest:n=>({totalVars:Object.keys(n?.env||{}).length,mode:n?.mode||"development",variables:Object.keys(n?.env||{}),timestamp:Date.now()}),logStats:(n,e,t)=>{let s=Object.keys(n.env).length;t&&t.info(`${e} Env: ${s} VITE_* variables`)}},rt=class{constructor(e,t={}){this.pathResolver=e,this.options=t,this.mode=t.mode||"development",this.appRoot=null}async discoverEnv(){try{let e=this.pathResolver.getAppRoot();if(!e)throw new Error("App root not available in EnvDiscovery");let s={...Zs(this.mode,e,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${e}/.env`,errors:[]}}catch(e){return{env:{},mode:this.mode,source:"error",errors:[e.message]}}}};function Ut(n={}){return fe({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:M.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:jt,manifestFileName:pe.manifests.env,configKey:"env",createDiscovery:(e,t)=>new rt(e,{...t,mode:n.mode||t.mode||"development"})})({...n,disableHmr:!0})}G();G();function ot(n){let e=new Set(Object.keys(Te)),t=new Set(["latin"]);for(let o of n||[]){let a=bt[o];if(a)for(let i of a)t.add(i)}let s=[],r=new Set;for(let o of e){let a=Te[o];for(let i of t)for(let l of a){let c=`@fontsource/${o}/${i}-${l}.css`,u=`${o}-${i}-${l}-normal`;s.push(c),r.add(u)}}return{imports:s,stems:r,subsets:t,fontStems:e}}function Wt(n){return n.replace(/,\s*url\([^)]*\.woff\)\s*format\(['"]woff['"]\)/g,"")}G();W();G();function Xs(n){if(!n)return[];let e=R.getInstance(),t=new Set;try{let s=e.resolvePackage("@donotdev/core",n);if(!s)return[];let r=e.getDirname(e.getDirname(s)),o;try{o=e.readdirSync(r)}catch{return[]}for(let a of o)try{let i=e.resolvePath(`${a}/package.json`,r),l=e.readSync(i,{format:"json"});if(!l?.peerDependenciesMeta)continue;for(let[c,u]of Object.entries(l.peerDependenciesMeta))u?.optional&&t.add(c)}catch{}}catch{}return Array.from(t)}function Qs(n){if(!n)return[];let e=R.getInstance();try{let t=e.resolvePath("package.json",n),s=e.readSync(t,{format:"json"});if(!s)return[];let r=new Set;if(s.peerDependenciesMeta)for(let[o,a]of Object.entries(s.peerDependenciesMeta))a?.optional&&r.add(o);if(s.optionalDependencies)for(let o of Object.keys(s.optionalDependencies))r.add(o);return Array.from(r)}catch{return[]}}function er(n){let e=me.optionalFeatures||[],t=Xs(n),s=Qs(n);return[...new Set([...e,...t,...s])]}function tr(n){let e=R.getInstance();try{let t=e.resolvePath("package.json",n),s=e.readSync(t,{format:"json"});return s?new Set([...Object.keys(s.dependencies||{}),...Object.keys(s.devDependencies||{})]):new Set}catch{return new Set}}function sr(n,e,t){if(t.resolvePackage(n,e||void 0))return!0;let s=n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0],r=e;for(let o=0;o<10;o++){let a=t.resolvePath(`node_modules/${s}`,r);if(t.pathExists(a))return!0;let i=t.getDirname(r);if(i===r)break;r=i}return!1}function Ge(n){let e=er(n),t=[],s=[],r=R.getInstance(),o=tr(n);for(let a of e)a.startsWith("@donotdev/")?o.has(a)?s.push(a):t.push(a):o.has(a)&&sr(a,n,r)?s.push(a):t.push(a);return{missing:t,installed:s}}var Se=class n extends ne{static LANGUAGE_FLAG_OVERRIDES={en:"gb","en-ca":"ca","es-ar":"ar","fr-be":"be",ar:"sa","ar-ma":"ma","ar-dz":"dz","ar-tn":"tn","ar-ly":"ly","ar-mr":"mr",hi:"in",sl:"si",uk:"ua",ga:"ie",gd:"gb-sct",br:"bzh",co:"fr-cor",am:"et",bn:"bd",gu:"in",kn:"in",ml:"in",mr:"in",ne:"np",pa:"pk",ta:"in",te:"in",ur:"pk",fa:"ir",kk:"kz",ky:"kg",tg:"tj",my:"mm",km:"kh",lo:"la",ka:"ge",hy:"am",be:"by",bs:"ba",sq:"al",ms:"my"};constructor(e,t={}){super(e,{fallbackLanguage:"en",additionalPaths:[],...t})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!t||t===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${t}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${t}, repoRoot=${s}`);let r=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${r.eager.length}, lazy: ${r.lazy.length}, framework eager: ${r.framework?.eager?.length||0}, framework lazy: ${r.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let o=je("i18n"),a=r.eager||[],i=r.lazy||[],l=(this.options.additionalPaths||[]).map(P=>{let O=P.endsWith(".json")?P:`${P}/*_*.json`;return this.pathResolver.resolveAppPath(O)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let c=r.framework?.eager||[],u=r.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${a.join(", ")}, lazy: ${i.join(", ")}, framework eager: ${c.join(", ")}, framework lazy: ${u.join(", ")}`),c.length===0&&u.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let p=this.pathResolver.normalizePath(t),g=this.pathResolver.normalizePath(s),f=(P,O)=>{let L=this.pathResolver.normalizePath(P),z=this.pathResolver.normalizePath(O);return L.startsWith(z)?L.slice(z.length+1):L},d=a.map(P=>f(P,t)),S=[...i,...l].map(P=>f(P,t)),w=c.map(P=>f(P,s)),$=u.map(P=>f(P,s)),A={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:t},T=await this.pathResolver._globWithNormalization(d,A),k=await this.pathResolver._globWithNormalization(S,A),N={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:o.ignore?.filter(P=>P!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(N.ignore)}`);let x=await this.pathResolver._globWithNormalization(w,N),b=await this.pathResolver._globWithNormalization($,N);this.logger.debug(`Found ${T.length} eager, ${k.length} lazy, ${x.length} framework eager, ${b.length} framework lazy files`),x.length>0?this.logger.debug(`Framework eager files (first 3): ${x.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${c.join(", ")}`),b.length>0?this.logger.debug(`Framework lazy files (first 3): ${b.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${u.join(", ")}`);let C=[...new Set([...T,...k,...x,...b])],y=new Set([...T,...x]),E={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},{missing:j}=Ge(t),F=new Set(j.filter(P=>P.startsWith("@donotdev/")).map(P=>P.replace("@donotdev/","")));F.size>0&&this.logger.debug(`I18n namespace filter: excluding [${[...F].join(", ")}] (packages not installed)`);let U=new Map,te=[...x,...b];for(let P of te){let O=this._processTranslationFile(P,x.includes(P),t);if(O){if(F.has(O.namespace))continue;let L=`${O.namespace}_${O.language}`;U.set(L,O),E.allNamespaces.add(O.namespace),E.supportedLanguages.add(O.language),x.includes(P)&&E.eagerNamespaces.add(O.namespace)}}let J=new Set;for(let P of C){if(te.includes(P))continue;let O=this._processTranslationFile(P,y.has(P),t);if(O){let{namespace:L,language:z,importPath:le,content:Pe}=O,Re=`${O.namespace}_${O.language}`;if(U.has(Re)){let $e=U.get(Re);O.content=this._mergeTranslations($e.content,Pe)}E.allNamespaces.add(L),E.supportedLanguages.add(z),J.add(z),y.has(P)&&E.eagerNamespaces.add(L),E.mapping[L]||(E.mapping[L]={}),E.mapping[L][z]=le,O.content&&(E.content[L]||(E.content[L]={}),E.content[L][z]=O.content),E.files.push({path:P,relativePath:this.pathResolver.getRelativePath(P),namespace:L,language:z,eager:y.has(P),size:O.content?JSON.stringify(O.content).length:0})}}for(let[P,O]of U){let L=P.lastIndexOf("_"),z=P.slice(0,L),le=P.slice(L+1);J.size>0&&!J.has(le)||(!E.mapping[z]||!E.mapping[z][le])&&(E.mapping[z]||(E.mapping[z]={}),E.mapping[z][le]=O.importPath,E.content[z]||(E.content[z]={}),E.content[z][le]=O.content,E.files.push({path:O.absolutePath,relativePath:this.pathResolver.getRelativePath(O.absolutePath),namespace:z,language:le,eager:E.eagerNamespaces.has(z),size:O.content?JSON.stringify(O.content).length:0}))}let ie=J.size>0?[...J].sort():[this.options.fallbackLanguage],xe=[...new Set(ie.map(P=>n.LANGUAGE_FLAG_OVERRIDES[P]||P))];return{mapping:E.mapping,content:E.content,eagerNamespaces:[...E.eagerNamespaces].sort(),allNamespaces:[...E.allNamespaces].sort(),supportedLanguages:ie,fallbackLanguage:this.options.fallbackLanguage,flagCodes:xe,files:E.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,flagCodes:[n.LANGUAGE_FLAG_OVERRIDES[this.options.fallbackLanguage]||this.options.fallbackLanguage],files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let r=Date.now()-t;return this.logger.debug(`Discovery completed in ${r}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(e=!1){return await this.discover(e)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(e,t,s){let r=e.split("/").pop()||e.split("\\").pop()||"",o,a,i=r.match(/^(.+)_([^_.]+)\.json$/);if(!i)return this.logger.debug(`Invalid translation file name format: ${r}`),null;if([,o,a]=i,!o||!a)return this.logger.debug(`Invalid namespace or language in file: ${r}`),null;let c="./"+this.pathResolver.getRelativePath(e).replace(/\\/g,"/"),u;try{if(u=this.pathResolver.readSync(e,{format:"json"}),!u)return this.logger.debug(`Could not read file: ${e}`),null}catch(p){return this.logger.debug(`Error parsing JSON from ${e}: ${p.message}`),null}return{namespace:o,language:a,importPath:c,absolutePath:e,content:u}}_mergeTranslations(e,t){let s={...e};for(let[r,o]of Object.entries(t))typeof o=="object"&&o!==null&&!Array.isArray(o)?s[r]=this._mergeTranslations(s[r]||{},o):s[r]=o;return s}};W();var rr=3,nt="<!-- DNDEV_FONT_PRELOADS -->",at=Object.keys(Te);function Gt(n={}){let{debug:e=!1}=n,t=I("font-preload",e,!1),s,r={},o=!1,a=new Set,i=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(l){o=l.command==="build",r={root:l.root,base:l.base&&l.base!=="/"?l.base.replace(/\/$/,""):"",outDir:l.build?.outDir??"dist"};try{s=R.getInstance()}catch(c){t.debug(`Font preload: PathResolver not ready: ${c?.message}`)}},async buildStart(){if(!(!o||!s||!s.getAppRoot()))try{let c=["en"];try{let g=await new Se(s,{fallbackLanguage:"en"}).discoverTranslations();g?.supportedLanguages?.length&&(c=g.supportedLanguages)}catch(p){t.debug(`Font preload: i18n discovery failed, using 'en': ${p?.message}`)}let u=ot(c);a=u.stems,t.debug(`Font filter: ${u.fontStems.size} font(s), ${u.subsets.size} subset(s), ${a.size} allowed stem(s)`)}catch(c){t.debug(`Font preload: discovery failed, using defaults: ${c?.message}`),a=ot(["en"]).stems}},generateBundle(l,c){if(a.size===0)return;let u=0,p=0;for(let d of Object.keys(c)){if(c[d].type!=="asset")continue;let S=d.toLowerCase();d.endsWith(".woff")?at.some(w=>S.includes(w))&&(delete c[d],u++):d.endsWith(".woff2")&&at.some($=>S.includes($))&&(Array.from(a).some(A=>S.includes(A))||(delete c[d],p++))}t.debug(`Font filter: deleted ${u} .woff + ${p} .woff2 from bundle`);for(let[d,m]of Object.entries(c)){if(m.type!=="asset"||!d.endsWith(".css")||typeof m.source!="string")continue;let S=m.source,w=S.replace(/@font-face\s*\{[\s\S]*?\}/g,$=>at.some(k=>$.includes(k))?Array.from(a).some(k=>$.includes(k))?Wt($):"":$);w!==S&&(m.source=w)}let g=r.base||"",f=[];for(let[d,m]of Object.entries(c)){if(m.type!=="asset"||!d.endsWith(".woff2"))continue;let S=d.toLowerCase();if(Array.from(a).some(w=>S.includes(w))){let w=g?`${g}/${d}`:`/${d}`;f.push(w)}}i=f.slice(0,rr)},writeBundle(){if(!o||!i.length)return;let l=s||R.getInstance(),c=r.root||process.cwd(),u=r.outDir||"dist",p=l.resolvePath(`${u}/index.html`,c);try{if(!l.pathExists(p)){t.debug(`Font preload: index.html not found at ${p}`);return}let g=l.readSync(p,{format:"text"}),f=i.map(d=>`<link rel="preload" as="font" href="${d}" type="font/woff2" crossorigin="anonymous" />`).join(`
324
324
  `);if(g.includes(nt))g=g.replace(nt,`${nt}
325
325
  ${f}`);else{let d=g.indexOf("<!-- Fonts:"),m=d!==-1?g.indexOf("-->",d)+3:g.indexOf("</head>");m!==-1&&(g=g.slice(0,m)+`
326
- ${f}`+g.slice(m))}l.writeSync(p,g,{overwrite:!0}),t.debug(`Font preload: injected ${i.length} link(s)`)}catch(g){t.debug(`Font preload: write failed: ${g?.message}`)}}}}W();U();var Bt={isEmpty:n=>!n.mapping||Object.keys(n.mapping).length===0,generateModule:(n,e,t="i18n",s=!1)=>{let{mapping:r,eagerNamespaces:o,supportedLanguages:a,fallbackLanguage:i,stats:l,content:c={},files:u=[]}=n,p=s?Object.keys(c):o,g={};for(let b of p)c[b]&&(g[b]=c[b]);let f=[...new Set([...o,...Object.keys(c)])],d={mapping:r,languages:a,eager:s?f:o,fallback:i,content:g,storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:l?.totalFiles||0,totalNamespaces:l?.totalNamespaces||0,totalLanguages:l?.totalLanguages||0,eagerNamespaces:l?.eagerNamespaces||0,generatedAt:new Date().toISOString()},debug:e},m=[];if(!s)for(let[b,E]of Object.entries(r)){if(o.includes(b))continue;let N=[];for(let F of Object.keys(E))N.push(` '${F}': () => import('virtual:i18n-lazy-${b}-${F}')`);N.length>0&&m.push(` '${b}': {
327
- ${N.join(`,
326
+ ${f}`+g.slice(m))}l.writeSync(p,g,{overwrite:!0}),t.debug(`Font preload: injected ${i.length} link(s)`)}catch(g){t.debug(`Font preload: write failed: ${g?.message}`)}}}}G();W();var Bt={isEmpty:n=>!n.mapping||Object.keys(n.mapping).length===0,generateModule:(n,e,t="i18n",s=!1)=>{let{mapping:r,eagerNamespaces:o,supportedLanguages:a,fallbackLanguage:i,stats:l,content:c={},files:u=[]}=n,p=s?Object.keys(c):o,g={};for(let w of p)c[w]&&(g[w]=c[w]);let f=[...new Set([...o,...Object.keys(c)])],d={mapping:r,languages:a,eager:s?f:o,fallback:i,content:g,storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:l?.totalFiles||0,totalNamespaces:l?.totalNamespaces||0,totalLanguages:l?.totalLanguages||0,eagerNamespaces:l?.eagerNamespaces||0,generatedAt:new Date().toISOString()},debug:e},m=[];if(!s)for(let[w,$]of Object.entries(r)){if(o.includes(w))continue;let A=[];for(let T of Object.keys($))A.push(` '${T}': () => import('virtual:i18n-lazy-${w}-${T}')`);A.length>0&&m.push(` '${w}': {
327
+ ${A.join(`,
328
328
  `)}
329
329
  }`)}let S=m.length>0?`{
330
330
  ${m.join(`,
331
331
  `)}
332
- }`:"{}";return`// ${z.i18n} - Generated by @donotdev/config
332
+ }`:"{}";return`// ${M.i18n} - Generated by @donotdev/config
333
333
  // Generated at: ${new Date().toISOString()}
334
334
 
335
335
  // ===== STATIC EXPORTS =====
@@ -360,7 +360,7 @@ if (typeof globalThis !== 'undefined') {
360
360
  }
361
361
 
362
362
  // Add i18n plugin configuration + lazy loaders (functions, not serializable)
363
- globalThis._DNDEV_CONFIG_.${H[t]} = {
363
+ globalThis._DNDEV_CONFIG_.${q[t]} = {
364
364
  ...i18nPluginConfig,
365
365
  loaders: _lazyLoaders,
366
366
  };
@@ -454,7 +454,7 @@ export default {
454
454
  getInlineContent,
455
455
  };
456
456
 
457
- `},generateEmpty:(n,e,t,s="i18n")=>{let r=t.fallbackLanguage||"en",o={mapping:{},languages:[r],eager:[],fallback:r,content:{},storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:0,totalNamespaces:0,totalLanguages:1,eagerNamespaces:0,generatedAt:new Date().toISOString()},debug:e};return`// ${z.i18n} - Empty i18n configuration
457
+ `},generateEmpty:(n,e,t,s="i18n")=>{let r=t.fallbackLanguage||"en",o={mapping:{},languages:[r],eager:[],fallback:r,content:{},storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:0,totalNamespaces:0,totalLanguages:1,eagerNamespaces:0,generatedAt:new Date().toISOString()},debug:e};return`// ${M.i18n} - Empty i18n configuration
458
458
  // No translation files found - using fallback configuration
459
459
  // Generated at: ${new Date().toISOString()}
460
460
 
@@ -472,7 +472,7 @@ if (typeof globalThis !== 'undefined') {
472
472
  };
473
473
  }
474
474
 
475
- globalThis._DNDEV_CONFIG_.${H[s]} = i18nPluginConfig;
475
+ globalThis._DNDEV_CONFIG_.${q[s]} = i18nPluginConfig;
476
476
  }
477
477
 
478
478
  // Placeholder functions
@@ -574,9 +574,9 @@ export default {
574
574
  files: translationFiles,
575
575
  manifest: i18nManifest,
576
576
  };
577
- `},generateManifest:n=>({namespaces:n.stats?.totalNamespaces||0,languages:n.stats?.totalLanguages||0,fallbackLanguage:n.fallbackLanguage,eagerNamespaces:n.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.supportedLanguages||[],r=Object.keys(n.mapping||{}).filter(o=>o!=="default").length||0;t&&t.info(`${e} I18n: ${s.length} languages, ${r} namespaces`)}},rr=[n=>n.endsWith(".json")&&n.includes("locale"),n=>/[a-z]+_[a-z]{2}\.json$/i.test(n),n=>n.includes("/locales/")&&n.endsWith(".json")];function Vt(n={}){let e=!1,t=new Map,s=$.getInstance(),r={..._e.discovery,fallbackLanguage:n.fallbackLanguage||"en",...n},o=new Pe(s,r);function a(p){t.clear();let{content:g,eagerNamespaces:f}=p;for(let[d,m]of Object.entries(g||{}))if(!f.includes(d))for(let[S,b]of Object.entries(m))t.set(`virtual:i18n-lazy-${d}-${S}`,b)}let i={...Bt,generateModule:(p,g,f)=>(e||a(p),Bt.generateModule(p,g,f,e))};return[ge({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:z.i18n,DiscoveryClass:Pe,discoveryMethod:"discoverTranslations",filePatterns:rr,templates:i,manifestFileName:ue.manifests.i18n,configKey:"i18n",discoveryOptions:r})({...n,hmrSmartDetection:!1}),{name:"dndev-i18n-lazy-loader",enforce:"pre",configResolved(p){e=p.command==="serve"},async buildStart(){if(e)return;let p=()=>{let d=s.getAppRoot(),m=s.getRepoRoot();return d&&d!==m},g=0;for(;!p()&&g<100;)await new Promise(d=>setTimeout(d,10)),g++;if(!p())return;let f=await o.discoverTranslations();a(f)},resolveId(p){if(!e&&p.startsWith("virtual:i18n-lazy-"))return"\0"+p},load(p){if(!e&&p.startsWith("\0virtual:i18n-lazy-")){let g=p.slice(1),f=t.get(g);return`export default ${JSON.stringify(f||{})};`}}},{name:"dndev-i18n-flag-filter",enforce:"pre",async buildStart(){if(e)return;let p=()=>{let m=s.getAppRoot(),S=s.getRepoRoot();return m&&m!==S},g=0;for(;!p()&&g<100;)await new Promise(m=>setTimeout(m,10)),g++;if(!p())return;let d=(await o.discoverTranslations()).flagCodes||[];this._allowedFlags=new Set(d.map(m=>m.toUpperCase()))},resolveId(p,g){if(e||!g||!p.includes("flag"))return;let f=p.match(/flag([A-Z][A-Z0-9_-]*)\.(tsx|js)$/i);if(!f)return;let d=f[1].toUpperCase();if(d!=="BASE"&&!this._allowedFlags?.has(d))return"\0empty-flag"},load(p){if(p==="\0empty-flag")return"export default () => null;"}}]}U();function Ht(n,e){return e.some(t=>n===t||n.startsWith(t+"/"))}function Jt(n={}){let e=[],t="",s="";return{name:"dndev-optional-dep-resolver",enforce:"pre",config(r){let o={name:"dndev-optional-dep-esbuild",setup(i){i.onResolve({filter:/^[@a-z]/,namespace:"file"},l=>Ht(l.path,e)?{path:s,external:!1}:null)}};return{optimizeDeps:{esbuildOptions:{plugins:[...r.optimizeDeps?.esbuildOptions?.plugins||[],o]}}}},configResolved(r){let o=$.getInstance(),a=o.getAppRoot();if(e=Ge(a).missing,t=o.getEmptyModulePath(),s=o.getEmptyCjsModulePath(),e.length>0){let l=r.optimizeDeps?.exclude||[];r.optimizeDeps.exclude=[...l,...e]}n.debug&&e.length>0},resolveId(r){return Ht(r,e)?{id:t,syntheticNamedExports:!0}:null}}}function it(n){return!n||typeof n!="string"?null:n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0]}function or(n){return!n||typeof n!="string"?!1:!n.startsWith(".")&&!n.startsWith("/")&&!n.startsWith("\\")&&!n.startsWith("\0")}function nr(n,e){if(!n||!e||!e.getRepoRoot())return!1;let s=n;n.startsWith("@fs/")&&(s=n.slice(4));let r=e.resolveRepoPath("packages"),o=e.normalizePath(s);return r&&o.startsWith(r)}function ar(n,e){if(!n||!e)return null;let t=it(n);if(!t)return null;let s=e.resolveAppPath(`node_modules/${t}`);return e.pathExists(s)?e.resolveAppPath(`node_modules/${n}`):null}function qt(n,e,t){return!or(n)||!nr(e,t)?null:ar(n,t)}U();function Yt(n={}){let{debug:e=!1,verbose:t=!0}=n,s=C("peer-dependency-resolver",e,t);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(r){let o=$.getInstance(),a=o.getAppRoot();if(!a){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=o,this.appRoot=a},resolveId(r,o){if(!o||!this.appRoot||!this.pathResolver)return null;if(qt(r,o,this.pathResolver)){let i=it(r),l=this.pathResolver.resolveAppPath(`node_modules/${r}`),c=this.pathResolver.resolveAppPath(`node_modules/${i}`);return this.pathResolver.pathExists(c)?r===i?((e||t)&&s.debug(`[PeerDeps] Resolving bare import "${r}" from app's node_modules: ${c}`),c):((e||t)&&s.debug(`[PeerDeps] Resolving subpath "${r}" from app's node_modules: ${l}`),l):(e&&s.debug(`[PeerDeps] Package directory not found: ${c}, skipping resolution`),null)}return null}}}U();U();function ir(n){return n?String(n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function ne(n){return n?String(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function lr(n,e,t){let s=$.getInstance(),r=new Map,o=`_${e}.json`,a=[s.resolvePath("src/pages/locales",n),s.resolvePath("src/locales",n)];for(let i of a){if(!s.pathExists(i,!0))continue;let l;try{l=s.readdirSync(i)}catch{continue}for(let c of l){if(!c.endsWith(o))continue;let u=c.slice(0,-o.length);if(!r.has(u))try{let p=s.resolvePath(c,i),g=s.readSync(p,{format:"json"});g&&r.set(u,g)}catch(p){t.debug(` Failed to parse locale ${c}: ${p.message}`)}}}return r}function Be(n,e,t){let s=n.get(e);if(!s)return;let r=t.split("."),o=s;for(let a of r){if(o==null||typeof o!="object")return;o=o[a]}return o}var Ve=class{constructor(e){this.routes=e.routes||[],this.outDir=e.outDir,this.base=e.base||"/",this.appRoot=e.appRoot,this.debug=e.debug||!1,this.logger=e.logger}async run(){let e=we({appRoot:this.appRoot,logger:this.logger}),t=this.expandRoutes(e);if(t.length===0)return this.logger.warn("No routes to prerender after expansion."),[];let s=$.getInstance(),r=s.resolvePath("index.html",this.outDir),o=s.readSync(r);if(!o)return this.logger.warn("dist/index.html not found. Skipping prerender."),[];let a="en",i=lr(this.appRoot,a,this.logger);this.debug&&this.logger.debug(` Loaded ${i.size} locale namespace(s) for '${a}'`);let l=this.resolveSiteName(),c=new Map;for(let g of e.routes)g.path&&c.set(g.path,g);let u=process.env.VITE_APP_URL||"",p=[];for(let g of t)try{let f=c.get(g)||{},d=this.resolveRouteSeo(f,g,i,l),m=this.injectMetaTags(o,g,d,u,l);await this.writePrerenderedFile(g,m),this.debug&&this.logger.debug(` ${g} -> "${d.title||"(no title)"}"`),p.push({route:g,ok:!0})}catch(f){this.logger.warn(` Failed: ${g} - ${f.message}`),p.push({route:g,ok:!1,error:f.message})}return p}resolveRouteSeo(e,t,s,r){let o=e.meta||{},a=o.seo||{},i=o.namespace||t.split("/").filter(Boolean)[0]||"home",l=Be(s,i,"meta")||{},c=Be(s,i,"title"),u=Be(s,i,"description"),p=Be(s,i,"subtitle"),g;if(l.fullTitle)g=l.fullTitle;else if(a.fullTitle)g=a.fullTitle;else{let E=a.title!==void 0?a.title:c;g=E?`${E} | ${r}`:r}let f=a.description!==void 0?a.description:u||p||null,d=a.image||l.image||null,m=a.type||l.type||"website",S=a.keywords||l.keywords||null,b=a.noindex||!1;return{title:g,description:f,image:d,type:m,keywords:S,noindex:b}}resolveSiteName(){let e=$.getInstance();try{let t=e.resolvePath("seo-manifest.json",this.outDir),s=e.readSync(t,{format:"json"});if(s?.siteName)return s.siteName}catch{}return process.env.VITE_APP_NAME?process.env.VITE_APP_NAME:""}injectMetaTags(e,t,s,r,o){let a=e,{title:i,description:l,image:c,type:u,keywords:p,noindex:g}=s;i&&(a=a.replace(/<title>[^<]*<\/title>/,`<title>${ir(i)}</title>`)),a=a.replace(/<meta\s+name="description"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+property="og:[^"]*"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="twitter:[^"]*"[^>]*\/?>\s*/gi,""),a=a.replace(/<link\s+rel="canonical"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="robots"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="keywords"[^>]*\/?>\s*/gi,"");let f=[],d=r?`${r.replace(/\/$/,"")}${t}`:"";if(l&&f.push(`<meta name="description" content="${ne(l)}" />`),d&&f.push(`<link rel="canonical" href="${ne(d)}" />`),i&&f.push(`<meta property="og:title" content="${ne(i)}" />`),l&&f.push(`<meta property="og:description" content="${ne(l)}" />`),d&&f.push(`<meta property="og:url" content="${ne(d)}" />`),c&&(f.push(`<meta property="og:image" content="${ne(c)}" />`),f.push('<meta property="og:image:width" content="1200" />'),f.push('<meta property="og:image:height" content="630" />')),u&&f.push(`<meta property="og:type" content="${ne(u)}" />`),o&&f.push(`<meta property="og:site_name" content="${ne(o)}" />`),(i||l||c)&&(f.push('<meta name="twitter:card" content="summary_large_image" />'),i&&f.push(`<meta name="twitter:title" content="${ne(i)}" />`),l&&f.push(`<meta name="twitter:description" content="${ne(l)}" />`),c&&f.push(`<meta name="twitter:image" content="${ne(c)}" />`)),p){let m=Array.isArray(p)?p.join(", "):p;f.push(`<meta name="keywords" content="${ne(m)}" />`)}if(g&&f.push('<meta name="robots" content="noindex, nofollow" />'),f.length>0){let m=f.map(S=>` ${S}`).join(`
577
+ `},generateManifest:n=>({namespaces:n.stats?.totalNamespaces||0,languages:n.stats?.totalLanguages||0,fallbackLanguage:n.fallbackLanguage,eagerNamespaces:n.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.supportedLanguages||[],r=Object.keys(n.mapping||{}).filter(o=>o!=="default").length||0;t&&t.info(`${e} I18n: ${s.length} languages, ${r} namespaces`)}},or=[n=>n.endsWith(".json")&&n.includes("locale"),n=>/[a-z]+_[a-z]{2}\.json$/i.test(n),n=>n.includes("/locales/")&&n.endsWith(".json")];function Vt(n={}){let e=!1,t=new Map,s=R.getInstance(),r={...ke.discovery,fallbackLanguage:n.fallbackLanguage||"en",...n},o=new Se(s,r);function a(p){t.clear();let{content:g,eagerNamespaces:f}=p;for(let[d,m]of Object.entries(g||{}))if(!f.includes(d))for(let[S,w]of Object.entries(m))t.set(`virtual:i18n-lazy-${d}-${S}`,w)}let i={...Bt,generateModule:(p,g,f)=>(e||a(p),Bt.generateModule(p,g,f,e))};return[fe({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:M.i18n,DiscoveryClass:Se,discoveryMethod:"discoverTranslations",filePatterns:or,templates:i,manifestFileName:pe.manifests.i18n,configKey:"i18n",discoveryOptions:r})({...n,hmrSmartDetection:!1}),{name:"dndev-i18n-lazy-loader",enforce:"pre",configResolved(p){e=p.command==="serve"},async buildStart(){if(e)return;let p=()=>{let d=s.getAppRoot(),m=s.getRepoRoot();return d&&d!==m},g=0;for(;!p()&&g<100;)await new Promise(d=>setTimeout(d,10)),g++;if(!p())return;let f=await o.discoverTranslations();a(f)},resolveId(p){if(!e&&p.startsWith("virtual:i18n-lazy-"))return"\0"+p},load(p){if(!e&&p.startsWith("\0virtual:i18n-lazy-")){let g=p.slice(1),f=t.get(g);return`export default ${JSON.stringify(f||{})};`}}},{name:"dndev-i18n-flag-filter",enforce:"pre",async buildStart(){if(e)return;let p=()=>{let m=s.getAppRoot(),S=s.getRepoRoot();return m&&m!==S},g=0;for(;!p()&&g<100;)await new Promise(m=>setTimeout(m,10)),g++;if(!p())return;let d=(await o.discoverTranslations()).flagCodes||[];this._allowedFlags=new Set(d.map(m=>m.toUpperCase()))},resolveId(p,g){if(e||!g||!p.includes("flag"))return;let f=p.match(/flag([A-Z][A-Z0-9_-]*)\.(tsx|js)$/i);if(!f)return;let d=f[1].toUpperCase();if(d!=="BASE"&&!this._allowedFlags?.has(d))return"\0empty-flag"},load(p){if(p==="\0empty-flag")return"export default () => null;"}}]}W();function Ht(n,e){return e.some(t=>n===t||n.startsWith(t+"/"))}function Jt(n={}){let e=[],t="",s="";return{name:"dndev-optional-dep-resolver",enforce:"pre",config(r){let o={name:"dndev-optional-dep-esbuild",setup(i){i.onResolve({filter:/^[@a-z]/,namespace:"file"},l=>Ht(l.path,e)?{path:s,external:!1}:null)}};return{optimizeDeps:{esbuildOptions:{plugins:[...r.optimizeDeps?.esbuildOptions?.plugins||[],o]}}}},configResolved(r){let o=R.getInstance(),a=o.getAppRoot();if(e=Ge(a).missing,t=o.getEmptyModulePath(),s=o.getEmptyCjsModulePath(),e.length>0){let l=r.optimizeDeps?.exclude||[];r.optimizeDeps.exclude=[...l,...e]}n.debug&&e.length>0},resolveId(r){return Ht(r,e)?{id:t,syntheticNamedExports:!0}:null}}}function it(n){return!n||typeof n!="string"?null:n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0]}function nr(n){return!n||typeof n!="string"?!1:!n.startsWith(".")&&!n.startsWith("/")&&!n.startsWith("\\")&&!n.startsWith("\0")}function ar(n,e){if(!n||!e||!e.getRepoRoot())return!1;let s=n;n.startsWith("@fs/")&&(s=n.slice(4));let r=e.resolveRepoPath("packages"),o=e.normalizePath(s);return r&&o.startsWith(r)}function ir(n,e){if(!n||!e)return null;let t=it(n);if(!t)return null;let s=e.resolveAppPath(`node_modules/${t}`);return e.pathExists(s)?e.resolveAppPath(`node_modules/${n}`):null}function qt(n,e,t){return!nr(n)||!ar(e,t)?null:ir(n,t)}W();function Yt(n={}){let{debug:e=!1,verbose:t=!0}=n,s=I("peer-dependency-resolver",e,t);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(r){let o=R.getInstance(),a=o.getAppRoot();if(!a){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=o,this.appRoot=a},resolveId(r,o){if(!o||!this.appRoot||!this.pathResolver)return null;if(qt(r,o,this.pathResolver)){let i=it(r),l=this.pathResolver.resolveAppPath(`node_modules/${r}`),c=this.pathResolver.resolveAppPath(`node_modules/${i}`);return this.pathResolver.pathExists(c)?r===i?((e||t)&&s.debug(`[PeerDeps] Resolving bare import "${r}" from app's node_modules: ${c}`),c):((e||t)&&s.debug(`[PeerDeps] Resolving subpath "${r}" from app's node_modules: ${l}`),l):(e&&s.debug(`[PeerDeps] Package directory not found: ${c}, skipping resolution`),null)}return null}}}W();W();function lr(n){return n?String(n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function ae(n){return n?String(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""}function cr(n,e,t){let s=R.getInstance(),r=new Map,o=`_${e}.json`,a=[s.resolvePath("src/pages/locales",n),s.resolvePath("src/locales",n)];for(let i of a){if(!s.pathExists(i,!0))continue;let l;try{l=s.readdirSync(i)}catch{continue}for(let c of l){if(!c.endsWith(o))continue;let u=c.slice(0,-o.length);if(!r.has(u))try{let p=s.resolvePath(c,i),g=s.readSync(p,{format:"json"});g&&r.set(u,g)}catch(p){t.debug(` Failed to parse locale ${c}: ${p.message}`)}}}return r}function Be(n,e,t){let s=n.get(e);if(!s)return;let r=t.split("."),o=s;for(let a of r){if(o==null||typeof o!="object")return;o=o[a]}return o}var Ve=class{constructor(e){this.routes=e.routes||[],this.outDir=e.outDir,this.base=e.base||"/",this.appRoot=e.appRoot,this.debug=e.debug||!1,this.logger=e.logger}async run(){let e=we({appRoot:this.appRoot,logger:this.logger}),t=this.expandRoutes(e);if(t.length===0)return this.logger.warn("No routes to prerender after expansion."),[];let s=R.getInstance(),r=s.resolvePath("index.html",this.outDir),o=s.readSync(r);if(!o)return this.logger.warn("dist/index.html not found. Skipping prerender."),[];let a="en",i=cr(this.appRoot,a,this.logger);this.debug&&this.logger.debug(` Loaded ${i.size} locale namespace(s) for '${a}'`);let l=this.resolveSiteName(),c=new Map;for(let g of e.routes)g.path&&c.set(g.path,g);let u=process.env.VITE_APP_URL||"",p=[];for(let g of t)try{let f=c.get(g)||{},d=this.resolveRouteSeo(f,g,i,l),m=this.injectMetaTags(o,g,d,u,l);await this.writePrerenderedFile(g,m),this.debug&&this.logger.debug(` ${g} -> "${d.title||"(no title)"}"`),p.push({route:g,ok:!0})}catch(f){this.logger.warn(` Failed: ${g} - ${f.message}`),p.push({route:g,ok:!1,error:f.message})}return p}resolveRouteSeo(e,t,s,r){let o=e.meta||{},a=o.seo||{},i=o.namespace||t.split("/").filter(Boolean)[0]||"home",l=Be(s,i,"meta")||{},c=Be(s,i,"title"),u=Be(s,i,"description"),p=Be(s,i,"subtitle"),g;if(l.fullTitle)g=l.fullTitle;else if(a.fullTitle)g=a.fullTitle;else{let $=a.title!==void 0?a.title:c;g=$?`${$} | ${r}`:r}let f=a.description!==void 0?a.description:u||p||null,d=a.image||l.image||null,m=a.type||l.type||"website",S=a.keywords||l.keywords||null,w=a.noindex||!1;return{title:g,description:f,image:d,type:m,keywords:S,noindex:w}}resolveSiteName(){let e=R.getInstance();try{let t=e.resolvePath("seo-manifest.json",this.outDir),s=e.readSync(t,{format:"json"});if(s?.siteName)return s.siteName}catch{}return process.env.VITE_APP_NAME?process.env.VITE_APP_NAME:""}injectMetaTags(e,t,s,r,o){let a=e,{title:i,description:l,image:c,type:u,keywords:p,noindex:g}=s;i&&(a=a.replace(/<title>[^<]*<\/title>/,`<title>${lr(i)}</title>`)),a=a.replace(/<meta\s+name="description"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+property="og:[^"]*"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="twitter:[^"]*"[^>]*\/?>\s*/gi,""),a=a.replace(/<link\s+rel="canonical"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="robots"[^>]*\/?>\s*/gi,""),a=a.replace(/<meta\s+name="keywords"[^>]*\/?>\s*/gi,"");let f=[],d=r?`${r.replace(/\/$/,"")}${t}`:"";if(l&&f.push(`<meta name="description" content="${ae(l)}" />`),d&&f.push(`<link rel="canonical" href="${ae(d)}" />`),i&&f.push(`<meta property="og:title" content="${ae(i)}" />`),l&&f.push(`<meta property="og:description" content="${ae(l)}" />`),d&&f.push(`<meta property="og:url" content="${ae(d)}" />`),c&&(f.push(`<meta property="og:image" content="${ae(c)}" />`),f.push('<meta property="og:image:width" content="1200" />'),f.push('<meta property="og:image:height" content="630" />')),u&&f.push(`<meta property="og:type" content="${ae(u)}" />`),o&&f.push(`<meta property="og:site_name" content="${ae(o)}" />`),(i||l||c)&&(f.push('<meta name="twitter:card" content="summary_large_image" />'),i&&f.push(`<meta name="twitter:title" content="${ae(i)}" />`),l&&f.push(`<meta name="twitter:description" content="${ae(l)}" />`),c&&f.push(`<meta name="twitter:image" content="${ae(c)}" />`)),p){let m=Array.isArray(p)?p.join(", "):p;f.push(`<meta name="keywords" content="${ae(m)}" />`)}if(g&&f.push('<meta name="robots" content="noindex, nofollow" />'),f.length>0){let m=f.map(S=>` ${S}`).join(`
578
578
  `);a=a.replace("</head>",`${m}
579
- </head>`)}return a}expandRoutes(e){let{routes:t,errors:s}=e;if(t.length===0)return s.length>0&&this.logger.warn("Route manifest unavailable. Using explicit routes only."),this.routes.filter(o=>!o.includes("*"));let r=new Set;for(let o of this.routes)if(o.includes("*")){let a=o.replace(/\/?\*.*$/,"");for(let i of t){let l=i.path||i;l.startsWith(a)&&!this.isAuthProtected(i)&&r.add(l)}if(this.debug){let i=[...r].filter(l=>l.startsWith(a));this.logger.debug(` Pattern "${o}" matched ${i.length} route(s)`)}}else{let a=t.find(i=>(i.path||i)===o);a&&this.isAuthProtected(a)?this.logger.warn(` Skipping auth-protected route: ${o}`):a?r.add(o):(r.add(o),this.debug&&this.logger.debug(` Route "${o}" not in manifest, including anyway`))}return[...r]}isAuthProtected(e){return typeof e=="string"?!1:e.auth?.required===!0}async writePrerenderedFile(e,t){let s=$.getInstance(),r;if(e==="/")r=s.resolvePath("index.html",this.outDir);else{let i=e.replace(/^\//,"").replace(/\/$/,"");r=s.resolvePath(`${i}/index.html`,this.outDir)}let o=s.getDirname(r);if(s.ensureDirSync(o),!s.writeSync(r,t,{overwrite:!0}))throw new Error(`writeSync returned false for ${r}`)}};function Kt(n={}){let{routes:e="auto",debug:t,verbose:s,...r}=n;if(Array.isArray(e)&&e.length===0)return{name:"prerender-disabled"};let o=C("Prerender",t,s),a=$.getInstance(),i=null,l=!1;return{name:"dndev-prerender",enforce:"post",configResolved(c){l=c.command==="build",i={root:c.root,outDir:c.build?.outDir||"dist",base:c.base||"/"}},async closeBundle(){if(!i||!l)return;let c=a.getAppRoot(),u=a.resolveAppPath(i.outDir),p=e;if(e==="auto"){let g=we({appRoot:c,logger:o}),f=Ft(g.routes),m=Ue(g.routes,{appRoot:c}).map(S=>S.path);if(p=[...new Set([...f,...m])],p.length===0){o.warn("No public static routes found for prerendering.");return}o.debug(`Auto-discovered ${p.length} route(s) to prerender`)}try{let f=await new Ve({...r,routes:p,debug:t,outDir:u,base:i.base,appRoot:c,logger:o}).run(),d=f.filter(k=>k.ok).length,m=f.filter(k=>!k.ok),S=f.length,b=f.filter(k=>k.ok&&k.route.startsWith("/blog/")).length,E=d-b,N=[];E>0&&N.push(`${E} static`),b>0&&N.push(`${b} blog`);let F=N.length>0?` (${N.join(", ")})`:"";if(d>0&&o.info(`Prerendered: ${d}/${S} pages${F}`),m.length>0)for(let k of m)o.warn(` Failed: ${k.route} - ${k.error}`)}catch(g){o.warn(`Prerendering failed: ${g.message}`),o.warn("SPA will serve all routes via index.html fallback (no impact on functionality)."),t&&g.stack&&o.debug(g.stack)}}}}import{VitePWA as cr}from"vite-plugin-pwa";var He=class extends oe{constructor(e,t={}){super(e,{...t})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(e){let{frameworkFiles:t,consumerFiles:s}=e,r=[...t,...s];this.logger.debug(`Processing ${r.length} PWA files`);let o=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),o=[...this.options.assetData.pwaIcons]);let a=await this._analyzePWAFiles(r),i=a.filter(g=>g.type==="manifest"||g.type==="service-worker");o.push(...i);let l=a.filter(g=>g.type==="icon"),c=new Set(o.filter(g=>g.type==="icon").map(g=>g.path)),u=l.filter(g=>!c.has(g.path));o.push(...u);let p=this._generatePWAManifest(o);return{assets:o,manifest:p,totalFiles:r.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(e){let t=[];for(let s of e){let r=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,o=await this._analyzePWAAsset(r);o&&t.push(o)}return t}async _analyzePWAAsset(e){let t=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!t)return null;let s=e.relativePath,r=e.fileName;return r.includes("manifest.json")?this._parseManifestFile(t,s):r.includes("service-worker")||r.includes("sw.")?this._parseServiceWorkerFile(t,s):this._isPWAIcon(r)?this._parseIconFile(e,s):null}_parseManifestFile(e,t){try{let s=typeof e=="string"?JSON.parse(e):e;return{type:"manifest",path:t,content:s,size:typeof e=="string"?e.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(e,t){return{type:"service-worker",path:t,size:e.length,hasWorkbox:e.includes("workbox")}}_parseIconFile(e,t){let s=e.fileName,r=this._extractIconSize(s);return{type:"icon",path:t,size:r,format:e.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(e){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>e.includes(s))}_extractIconSize(e){let t=e.match(/(\d+)x(\d+)/);return t?{width:parseInt(t[1]),height:parseInt(t[2])}:e.includes("favicon")?{width:32,height:32}:e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("icon-192")?{width:192,height:192}:e.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(e){return e.includes("maskable")?"maskable":e.includes("apple-touch")?"apple-touch":e.includes("android-chrome")?"android":"any"}_generatePWAManifest(e){let t=e.filter(o=>o.type==="icon"),r=e.find(o=>o.type==="manifest")?.content||this._getDefaultManifest();return t.length>0&&(r.icons=t.map(o=>({src:`/${o.path}`,sizes:`${o.size.width}x${o.size.height}`,type:`image/${o.format}`,purpose:o.purpose}))),r}_getDefaultManifest(){let e=this.options?.app||{};return{name:e.name,short_name:e.shortName,description:e.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(e){let t=e.manifest||this._getDefaultManifest();return JSON.stringify(t,null,2)}generateServiceWorkerContent(e,t={}){let s=this._getWorkboxDefaults(t),r=t.backgroundSync!==!1&&t.backgroundSync,o=t.precacheManifest||[],a=JSON.stringify(o,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
579
+ </head>`)}return a}expandRoutes(e){let{routes:t,errors:s}=e;if(t.length===0)return s.length>0&&this.logger.warn("Route manifest unavailable. Using explicit routes only."),this.routes.filter(o=>!o.includes("*"));let r=new Set;for(let o of this.routes)if(o.includes("*")){let a=o.replace(/\/?\*.*$/,"");for(let i of t){let l=i.path||i;l.startsWith(a)&&!this.isAuthProtected(i)&&r.add(l)}if(this.debug){let i=[...r].filter(l=>l.startsWith(a));this.logger.debug(` Pattern "${o}" matched ${i.length} route(s)`)}}else{let a=t.find(i=>(i.path||i)===o);a&&this.isAuthProtected(a)?this.logger.warn(` Skipping auth-protected route: ${o}`):a?r.add(o):(r.add(o),this.debug&&this.logger.debug(` Route "${o}" not in manifest, including anyway`))}return[...r]}isAuthProtected(e){return typeof e=="string"?!1:e.auth?.required===!0}async writePrerenderedFile(e,t){let s=R.getInstance(),r;if(e==="/")r=s.resolvePath("index.html",this.outDir);else{let i=e.replace(/^\//,"").replace(/\/$/,"");r=s.resolvePath(`${i}/index.html`,this.outDir)}let o=s.getDirname(r);if(s.ensureDirSync(o),!s.writeSync(r,t,{overwrite:!0}))throw new Error(`writeSync returned false for ${r}`)}};function Kt(n={}){let{routes:e="auto",debug:t,verbose:s,...r}=n;if(Array.isArray(e)&&e.length===0)return{name:"prerender-disabled"};let o=I("Prerender",t,s),a=R.getInstance(),i=null,l=!1;return{name:"dndev-prerender",enforce:"post",configResolved(c){l=c.command==="build",i={root:c.root,outDir:c.build?.outDir||"dist",base:c.base||"/"}},async closeBundle(){if(!i||!l)return;let c=a.getAppRoot(),u=a.resolveAppPath(i.outDir),p=e;if(e==="auto"){let g=we({appRoot:c,logger:o}),f=Ft(g.routes),m=Ue(g.routes,{appRoot:c}).map(S=>S.path);if(p=[...new Set([...f,...m])],p.length===0){o.warn("No public static routes found for prerendering.");return}o.debug(`Auto-discovered ${p.length} route(s) to prerender`)}try{let f=await new Ve({...r,routes:p,debug:t,outDir:u,base:i.base,appRoot:c,logger:o}).run(),d=f.filter(k=>k.ok).length,m=f.filter(k=>!k.ok),S=f.length,w=f.filter(k=>k.ok&&k.route.startsWith("/blog/")).length,$=d-w,A=[];$>0&&A.push(`${$} static`),w>0&&A.push(`${w} blog`);let T=A.length>0?` (${A.join(", ")})`:"";if(d>0&&o.info(`Prerendered: ${d}/${S} pages${T}`),m.length>0)for(let k of m)o.warn(` Failed: ${k.route} - ${k.error}`)}catch(g){o.warn(`Prerendering failed: ${g.message}`),o.warn("SPA will serve all routes via index.html fallback (no impact on functionality)."),t&&g.stack&&o.debug(g.stack)}}}}import{VitePWA as ur}from"vite-plugin-pwa";var He=class extends ne{constructor(e,t={}){super(e,{...t})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(e){let{frameworkFiles:t,consumerFiles:s}=e,r=[...t,...s];this.logger.debug(`Processing ${r.length} PWA files`);let o=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),o=[...this.options.assetData.pwaIcons]);let a=await this._analyzePWAFiles(r),i=a.filter(g=>g.type==="manifest"||g.type==="service-worker");o.push(...i);let l=a.filter(g=>g.type==="icon"),c=new Set(o.filter(g=>g.type==="icon").map(g=>g.path)),u=l.filter(g=>!c.has(g.path));o.push(...u);let p=this._generatePWAManifest(o);return{assets:o,manifest:p,totalFiles:r.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(e){let t=[];for(let s of e){let r=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,o=await this._analyzePWAAsset(r);o&&t.push(o)}return t}async _analyzePWAAsset(e){let t=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!t)return null;let s=e.relativePath,r=e.fileName;return r.includes("manifest.json")?this._parseManifestFile(t,s):r.includes("service-worker")||r.includes("sw.")?this._parseServiceWorkerFile(t,s):this._isPWAIcon(r)?this._parseIconFile(e,s):null}_parseManifestFile(e,t){try{let s=typeof e=="string"?JSON.parse(e):e;return{type:"manifest",path:t,content:s,size:typeof e=="string"?e.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(e,t){return{type:"service-worker",path:t,size:e.length,hasWorkbox:e.includes("workbox")}}_parseIconFile(e,t){let s=e.fileName,r=this._extractIconSize(s);return{type:"icon",path:t,size:r,format:e.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(e){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>e.includes(s))}_extractIconSize(e){let t=e.match(/(\d+)x(\d+)/);return t?{width:parseInt(t[1]),height:parseInt(t[2])}:e.includes("favicon")?{width:32,height:32}:e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("icon-192")?{width:192,height:192}:e.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(e){return e.includes("maskable")?"maskable":e.includes("apple-touch")?"apple-touch":e.includes("android-chrome")?"android":"any"}_generatePWAManifest(e){let t=e.filter(o=>o.type==="icon"),r=e.find(o=>o.type==="manifest")?.content||this._getDefaultManifest();return t.length>0&&(r.icons=t.map(o=>({src:`/${o.path}`,sizes:`${o.size.width}x${o.size.height}`,type:`image/${o.format}`,purpose:o.purpose}))),r}_getDefaultManifest(){let e=this.options?.app||{};return{name:e.name,short_name:e.shortName,description:e.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(e){let t=e.manifest||this._getDefaultManifest();return JSON.stringify(t,null,2)}generateServiceWorkerContent(e,t={}){let s=this._getWorkboxDefaults(t),r=t.backgroundSync!==!1&&t.backgroundSync,o=t.precacheManifest||[],a=JSON.stringify(o,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
580
580
  // Generated at ${new Date().toISOString()}
581
581
 
582
582
  importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
@@ -644,7 +644,7 @@ registerRoute(
644
644
  }),
645
645
  'POST'
646
646
  );
647
- `}getPWAHeaders(){return[{source:"/manifest.json",headers:[{key:"Content-Type",value:"application/manifest+json"},{key:"Cache-Control",value:"public, max-age=3600"}]},{source:"/sw.js",headers:[{key:"Content-Type",value:"application/javascript"},{key:"Cache-Control",value:"no-cache"}]}]}getPWARewrites(){return{beforeFiles:[],afterFiles:[{source:"/sw.js",destination:"/sw.js"},{source:"/workbox-:path*",destination:"/workbox-:path*"}],fallback:[]}}async discoverNextBuildAssets(e=".next"){let t=this.pathResolver.resolveAppPath(`${e}/static`),s=this.pathResolver.resolveAppPath(`${e}/static/chunks`),r=this.pathResolver.resolveAppPath(`${e}/static/css`),o=[];try{let a=[`${t}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${r}/**/*.css`];for(let i of a){let l=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),i.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let c of l){let u=this.pathResolver.getRelativePath(c);if(u.startsWith(`${e}/static/`)){let p=`/_next/${u.replace(`${e}/static/`,"")}`;o.push({url:p,revision:null})}}}}catch(a){this.logger?.warn(`Failed to discover Next.js build assets: ${a.message}`)}return o}generatePrecacheManifest(e=[],t=null){let s=e;return t&&typeof t=="function"&&(s=t(s)),s}async discoverPWAAssets(e=!1){return await this.discover(e)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};U();function Zt(n={}){if(!n.enabled)return null;let e=n.app||{},t=[];if(e.name||t.push("name"),e.shortName||t.push("shortName"),e.description||t.push("description"),t.length>0){let u=C("PWA",n.debug,!0);u.warn(`\u26A0\uFE0F PWA is enabled but appConfig.app is missing required fields: ${t.join(", ")}`),u.warn(" Add these to your src/config/app.ts:"),u.warn(" export const appConfig: AppConfig = {"),u.warn(" app: {"),e.name||u.warn(' name: "Your App Name",'),e.shortName||u.warn(' shortName: "App",'),e.description||u.warn(' description: "Your app description",'),u.warn(" },"),u.warn(" // ... rest of config"),u.warn(" };"),u.warn("")}let s=$.getInstance(),r=Ct.data,o=new He(s,{...n,assetData:r}),a=n.devEnabled===!0,i={registerType:n.registerType||"prompt",includeAssets:["favicon.ico","favicon.svg","apple-touch-icon.png"],manifest:async()=>{let u=n.app||{},g=(await o.discoverPWAAssets()).assets.filter(f=>f.type==="icon").map(f=>({src:`/${f.path}`,sizes:`${f.size.width}x${f.size.height}`,type:`image/${f.format}`,purpose:f.purpose}));return{name:u.name,short_name:u.shortName,description:u.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:g.length>0?g:[]}},workbox:{globPatterns:["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:u})=>u.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:!0,skipWaiting:!0,clientsClaim:!0,maximumFileSizeToCacheInBytes:5*1024*1024,navigateFallback:"/index.html",navigateFallbackDenylist:[/^\/api\/.*/],manifestTransforms:[u=>{let p=u.find(g=>g.url==="/index.html"||g.url==="index.html");return p&&!u.find(g=>g.url==="/")&&u.push({url:"/",revision:p.revision}),{manifest:u,warnings:[]}}]},devOptions:{enabled:a,type:"module"}},c={...i,manifest:async()=>{let u=await i.manifest();if(n.manifest){if(typeof n.manifest=="function"){let p=await n.manifest();return{...u,...p}}return{...u,...n.manifest}}return u},workbox:{...i.workbox,...n.workbox||{},runtimeCaching:[...i.workbox.runtimeCaching,...n.workbox?.runtimeCaching||[]],manifestTransforms:[...i.workbox.manifestTransforms||[],...n.workbox?.manifestTransforms||[]]}};return cr(c)}W();W();function Xt(n,e="unknown"){try{let t=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=n.match(t);if(!s)return null;let r=s[1];r=r.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(l,c)=>`icon: '${c}'`);let o=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...n.matchAll(o)].forEach(l=>{let c=l[1],u=l[2];r=r.replace(new RegExp(`\\b${c}\\b`,"g"),`'${u}'`)}),Function(`return ${r}`)()}catch{return null}}var Ce=null,Qt=null;function ur(n){let t=(n.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return t.charAt(0).toUpperCase()+t.slice(1)}var Je=class extends oe{constructor(e,t={}){super(e,{additionalPatterns:[],...t}),this.routes=[],this.errors=[],this.source="auto-discovery"}_getDiscoveryType(){return"Route"}async _getPatterns(){return await this.pathResolver.resolvePatterns("routes")}_getPatternType(){return"routes"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(Ce&&Qt===s)return this.logger.debug("Using cached route discovery results"),this.routes=Ce.routes,this.errors=Ce.errors,this.source=Ce.source,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length};if(this.logger.debug("Route discovery mode: AUTO-DISCOVERY"),this.logger.debug(`App root: ${t}`),this.options.debug){let r=e?.consumerFiles?.length||0;this.logger.debug(`\u{1F50D} Route discovery: Scanning ${r} files in ${t}`);let o=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(o)}`)}return await this._performAutoDiscovery(e,t),this.options.debug&&this.logger.debug(`\u{1F50D} Route discovery: Found ${this.routes.length} routes`),this.routes.length===0&&this.logger.warn("\u26A0\uFE0F No routes discovered! Check that pages exist in src/pages/"),Ce={routes:this.routes,errors:this.errors,source:this.source},Qt=process.env.DNDEV_BUILD_ID,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length}}_getEmptyResult(){return{routes:[],errors:[],source:"empty",totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.routes?.length||0} routes discovered via ${this.cache?.source||"unknown"}`}async discoverRoutes(e=!1){return await this.discover(e)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(e,t){let{consumerFiles:s}=e,r=await this._batchProcessFiles(s,c=>this._analyzePageFile(c,t)),o=await this._scanAdditionalPatterns(t),a=await this._batchProcessFiles(o,c=>this._analyzePageFile(c,t)),i=[...r,...a];this.logger.debug(`Auto-discovering from ${s.length} app + ${o.length} additional files`),this.routes=i.filter(c=>c.path==="home"||c.path==="/home"?(this.logger.debug(`Filtered reserved route: ${c.path} - Use root "/" instead (${c.file})`),!1):!0);let l=new Map;for(let c of this.routes){let u=c.path;if(l.has(u)){let p=l.get(u);throw new Error(`Route conflict: Multiple routes found for path '${u}'. Routes: ${p.file} and ${c.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}l.set(u,c)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+o.length} files`)}async _scanAdditionalPatterns(e){let t=this.options.additionalPatterns.map(s=>this.pathResolver.resolveAppPath(s));if(t.length===0)return[];try{let{consumerFiles:s}=await this.pathResolver.resolveFiles({consumer:t,framework:[]},"routes");return s}catch(s){return this.logger.debug(`Error scanning additional patterns: ${s.message}`),[]}}async _analyzePageFile(e,t){let s=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!s)return null;let r=e.relativePath,o="/src/"+r.replace(/\\/g,"/");o=o.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let a=this._extractMetaExport(s,e.absolutePath),i=ur(o),c=i===Xe.HOMEPAGE_COMPONENT?Xe.HOMEPAGE_PATH:this._resolveRoutePath(a,r,e.absolutePath),u=this._extractPageMeta(r,s),{entity:p,action:g,...f}=a||{};return{path:c,component:i,importPath:o,auth:a?.auth||!1,meta:{...u,...f,entity:u.entity,action:u.action},metaExport:a,file:r}}_extractMetaExport(e,t){try{let s=Xt(e,t);return s?(this.logger.debug(`Extracted meta export from ${t}: ${JSON.stringify(s)}`),s):null}catch(s){return this.logger.debug(`Error parsing meta export from ${t}: ${s.message}`),null}}_generateRoutePath(e){let t=e.replace(/\.tsx$/,"").replace(/Page$/,"").replace(/^src\//,"").replace(/^pages\//,"").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return(t.endsWith("/index")||t==="index")&&(t=t.replace(/\/index$/,"")||"/"),t==="/"?"/":"/"+t.replace(/\/+/g,"/")}_resolveRoutePath(e,t,s){if(!e?.route)return this._generateRoutePath(t);if(typeof e.route=="string"){let r=e.route.trim();return r==="/"?"/":(r=r.replace(/\/+/g,"/"),r.startsWith("/")||(r="/"+r),r)}if(typeof e.route=="object"&&e.route!==null){let r=this._generateRoutePath(t),o=e.route.params;if(Array.isArray(o)&&o.length>0){let a=o.map(i=>`:${i}`).join("/");return`${r}/${a}`}return r}return this.logger.warn(`Invalid route format in ${s}. Use string format: route: "/path/:param" or object format: route: { params: ['id'] }`),this.logger.debug(`Falling back to auto-generated path for ${s}`),this._generateRoutePath(t)}_extractPageMeta(e,t){let s=e.split("/").pop()?.replace(".tsx","")||"",r=s.replace(/Page$/,"");r=r.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").trim(),r=r.charAt(0).toUpperCase()+r.slice(1);let o=e.split("/"),a=null,i=null;return o.length>1&&(a=o[o.length-2],s.includes("List")?i="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?i="form":(s.includes("Detail")||s.includes("View"))&&(i="detail")),{title:r,entity:a,action:i,file:e}}};var pr={isEmpty:n=>!n.routes||n.routes.length===0,generateModule:(n,e,t="routes")=>{let s={totalRoutes:n.routes.length,authRequired:n.routes.filter(o=>o.auth&&o.auth.required).length,publicRoutes:n.routes.filter(o=>!o.auth||o.auth===!1).length,source:n.source,generatedAt:new Date().toISOString(),errors:n.errors.length},r=n.routes.map(o=>` {
647
+ `}getPWAHeaders(){return[{source:"/manifest.json",headers:[{key:"Content-Type",value:"application/manifest+json"},{key:"Cache-Control",value:"public, max-age=3600"}]},{source:"/sw.js",headers:[{key:"Content-Type",value:"application/javascript"},{key:"Cache-Control",value:"no-cache"}]}]}getPWARewrites(){return{beforeFiles:[],afterFiles:[{source:"/sw.js",destination:"/sw.js"},{source:"/workbox-:path*",destination:"/workbox-:path*"}],fallback:[]}}async discoverNextBuildAssets(e=".next"){let t=this.pathResolver.resolveAppPath(`${e}/static`),s=this.pathResolver.resolveAppPath(`${e}/static/chunks`),r=this.pathResolver.resolveAppPath(`${e}/static/css`),o=[];try{let a=[`${t}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${r}/**/*.css`];for(let i of a){let l=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),i.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let c of l){let u=this.pathResolver.getRelativePath(c);if(u.startsWith(`${e}/static/`)){let p=`/_next/${u.replace(`${e}/static/`,"")}`;o.push({url:p,revision:null})}}}}catch(a){this.logger?.warn(`Failed to discover Next.js build assets: ${a.message}`)}return o}generatePrecacheManifest(e=[],t=null){let s=e;return t&&typeof t=="function"&&(s=t(s)),s}async discoverPWAAssets(e=!1){return await this.discover(e)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};W();function Zt(n={}){if(!n.enabled)return null;let e=n.app||{},t=[];if(e.name||t.push("name"),e.shortName||t.push("shortName"),e.description||t.push("description"),t.length>0){let u=I("PWA",n.debug,!0);u.warn(`\u26A0\uFE0F PWA is enabled but appConfig.app is missing required fields: ${t.join(", ")}`),u.warn(" Add these to your src/config/app.ts:"),u.warn(" export const appConfig: AppConfig = {"),u.warn(" app: {"),e.name||u.warn(' name: "Your App Name",'),e.shortName||u.warn(' shortName: "App",'),e.description||u.warn(' description: "Your app description",'),u.warn(" },"),u.warn(" // ... rest of config"),u.warn(" };"),u.warn("")}let s=R.getInstance(),r=Ct.data,o=new He(s,{...n,assetData:r}),a=n.devEnabled===!0,i={registerType:n.registerType||"prompt",includeAssets:["favicon.ico","favicon.svg","apple-touch-icon.png"],manifest:async()=>{let u=n.app||{},g=(await o.discoverPWAAssets()).assets.filter(f=>f.type==="icon").map(f=>({src:`/${f.path}`,sizes:`${f.size.width}x${f.size.height}`,type:`image/${f.format}`,purpose:f.purpose}));return{name:u.name,short_name:u.shortName,description:u.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:g.length>0?g:[]}},workbox:{globPatterns:["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:u})=>u.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:!0,skipWaiting:!0,clientsClaim:!0,maximumFileSizeToCacheInBytes:5*1024*1024,navigateFallback:"/index.html",navigateFallbackDenylist:[/^\/api\/.*/],manifestTransforms:[u=>{let p=u.find(g=>g.url==="/index.html"||g.url==="index.html");return p&&!u.find(g=>g.url==="/")&&u.push({url:"/",revision:p.revision}),{manifest:u,warnings:[]}}]},devOptions:{enabled:a,type:"module"}},c={...i,manifest:async()=>{let u=await i.manifest();if(n.manifest){if(typeof n.manifest=="function"){let p=await n.manifest();return{...u,...p}}return{...u,...n.manifest}}return u},workbox:{...i.workbox,...n.workbox||{},runtimeCaching:[...i.workbox.runtimeCaching,...n.workbox?.runtimeCaching||[]],manifestTransforms:[...i.workbox.manifestTransforms||[],...n.workbox?.manifestTransforms||[]]}};return ur(c)}G();G();function Xt(n,e="unknown"){try{let t=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=n.match(t);if(!s)return null;let r=s[1];r=r.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(l,c)=>`icon: '${c}'`);let o=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...n.matchAll(o)].forEach(l=>{let c=l[1],u=l[2];r=r.replace(new RegExp(`\\b${c}\\b`,"g"),`'${u}'`)}),Function(`return ${r}`)()}catch{return null}}var Ce=null,Qt=null;function pr(n){let t=(n.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return t.charAt(0).toUpperCase()+t.slice(1)}var Je=class extends ne{constructor(e,t={}){super(e,{additionalPatterns:[],...t}),this.routes=[],this.errors=[],this.source="auto-discovery"}_getDiscoveryType(){return"Route"}async _getPatterns(){return await this.pathResolver.resolvePatterns("routes")}_getPatternType(){return"routes"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(Ce&&Qt===s)return this.logger.debug("Using cached route discovery results"),this.routes=Ce.routes,this.errors=Ce.errors,this.source=Ce.source,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length};if(this.logger.debug("Route discovery mode: AUTO-DISCOVERY"),this.logger.debug(`App root: ${t}`),this.options.debug){let r=e?.consumerFiles?.length||0;this.logger.debug(`\u{1F50D} Route discovery: Scanning ${r} files in ${t}`);let o=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(o)}`)}return await this._performAutoDiscovery(e,t),this.options.debug&&this.logger.debug(`\u{1F50D} Route discovery: Found ${this.routes.length} routes`),this.routes.length===0&&this.logger.warn("\u26A0\uFE0F No routes discovered! Check that pages exist in src/pages/"),Ce={routes:this.routes,errors:this.errors,source:this.source},Qt=process.env.DNDEV_BUILD_ID,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length}}_getEmptyResult(){return{routes:[],errors:[],source:"empty",totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.routes?.length||0} routes discovered via ${this.cache?.source||"unknown"}`}async discoverRoutes(e=!1){return await this.discover(e)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(e,t){let{consumerFiles:s}=e,r=await this._batchProcessFiles(s,c=>this._analyzePageFile(c,t)),o=await this._scanAdditionalPatterns(t),a=await this._batchProcessFiles(o,c=>this._analyzePageFile(c,t)),i=[...r,...a];this.logger.debug(`Auto-discovering from ${s.length} app + ${o.length} additional files`),this.routes=i.filter(c=>c.path==="home"||c.path==="/home"?(this.logger.debug(`Filtered reserved route: ${c.path} - Use root "/" instead (${c.file})`),!1):!0);let l=new Map;for(let c of this.routes){let u=c.path;if(l.has(u)){let p=l.get(u);throw new Error(`Route conflict: Multiple routes found for path '${u}'. Routes: ${p.file} and ${c.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}l.set(u,c)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+o.length} files`)}async _scanAdditionalPatterns(e){let t=this.options.additionalPatterns.map(s=>this.pathResolver.resolveAppPath(s));if(t.length===0)return[];try{let{consumerFiles:s}=await this.pathResolver.resolveFiles({consumer:t,framework:[]},"routes");return s}catch(s){return this.logger.debug(`Error scanning additional patterns: ${s.message}`),[]}}async _analyzePageFile(e,t){let s=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!s)return null;let r=e.relativePath,o="/src/"+r.replace(/\\/g,"/");o=o.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let a=this._extractMetaExport(s,e.absolutePath),i=pr(o),c=i===Xe.HOMEPAGE_COMPONENT?Xe.HOMEPAGE_PATH:this._resolveRoutePath(a,r,e.absolutePath),u=this._extractPageMeta(r,s),{entity:p,action:g,...f}=a||{};return{path:c,component:i,importPath:o,auth:a?.auth||!1,meta:{...u,...f,entity:u.entity,action:u.action},metaExport:a,file:r}}_extractMetaExport(e,t){try{let s=Xt(e,t);return s?(this.logger.debug(`Extracted meta export from ${t}: ${JSON.stringify(s)}`),s):null}catch(s){return this.logger.debug(`Error parsing meta export from ${t}: ${s.message}`),null}}_generateRoutePath(e){let t=e.replace(/\.tsx$/,"").replace(/Page$/,"").replace(/^src\//,"").replace(/^pages\//,"").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return(t.endsWith("/index")||t==="index")&&(t=t.replace(/\/index$/,"")||"/"),t==="/"?"/":"/"+t.replace(/\/+/g,"/")}_resolveRoutePath(e,t,s){if(!e?.route)return this._generateRoutePath(t);if(typeof e.route=="string"){let r=e.route.trim();return r==="/"?"/":(r=r.replace(/\/+/g,"/"),r.startsWith("/")||(r="/"+r),r)}if(typeof e.route=="object"&&e.route!==null){let r=this._generateRoutePath(t),o=e.route.params;if(Array.isArray(o)&&o.length>0){let a=o.map(i=>`:${i}`).join("/");return`${r}/${a}`}return r}return this.logger.warn(`Invalid route format in ${s}. Use string format: route: "/path/:param" or object format: route: { params: ['id'] }`),this.logger.debug(`Falling back to auto-generated path for ${s}`),this._generateRoutePath(t)}_extractPageMeta(e,t){let s=e.split("/").pop()?.replace(".tsx","")||"",r=s.replace(/Page$/,"");r=r.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").trim(),r=r.charAt(0).toUpperCase()+r.slice(1);let o=e.split("/"),a=null,i=null;return o.length>1&&(a=o[o.length-2],s.includes("List")?i="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?i="form":(s.includes("Detail")||s.includes("View"))&&(i="detail")),{title:r,entity:a,action:i,file:e}}};var gr={isEmpty:n=>!n.routes||n.routes.length===0,generateModule:(n,e,t="routes")=>{let s={totalRoutes:n.routes.length,authRequired:n.routes.filter(o=>o.auth&&o.auth.required).length,publicRoutes:n.routes.filter(o=>!o.auth||o.auth===!1).length,source:n.source,generatedAt:new Date().toISOString(),errors:n.errors.length},r=n.routes.map(o=>` {
648
648
  path: '${o.path}',
649
649
  component: () => import('${o.importPath}'),
650
650
  auth: ${JSON.stringify(o.auth,null,2).replace(/\n/g,`
@@ -653,7 +653,7 @@ registerRoute(
653
653
  `)}
654
654
  }`).join(`,
655
655
  `);return`
656
- // ${z.routes} - Generated route data
656
+ // ${M.routes} - Generated route data
657
657
  import { lazy } from 'react';
658
658
 
659
659
  const routeData = [
@@ -675,7 +675,7 @@ if (typeof globalThis !== 'undefined') {
675
675
  }
676
676
 
677
677
  // Include all routes in mapping (navigation store will filter by hideFromMenu)
678
- globalThis._DNDEV_CONFIG_.${H[t]} = {
678
+ globalThis._DNDEV_CONFIG_.${q[t]} = {
679
679
  mapping: routeData,
680
680
  manifest: {
681
681
  totalRoutes: ${n.routes.length},
@@ -693,7 +693,7 @@ export const source = '${n.source}';
693
693
 
694
694
  export default { routes: routeData, manifest: routeManifest, source: '${n.source}' };
695
695
  `},generateEmpty:(n,e,t,s="routes")=>{let r={totalRoutes:0,authRequired:0,publicRoutes:0,source:"empty",generatedAt:new Date().toISOString()};return`
696
- // ${z.routes} - Empty route data
696
+ // ${M.routes} - Empty route data
697
697
 
698
698
  const routeData = [];
699
699
  const routeManifest = ${JSON.stringify(r,null,2)};
@@ -712,7 +712,7 @@ if (typeof globalThis !== 'undefined') {
712
712
  }
713
713
 
714
714
  // Populate empty routes configuration
715
- globalThis._DNDEV_CONFIG_.${H[s]} = {
715
+ globalThis._DNDEV_CONFIG_.${q[s]} = {
716
716
  mapping: [],
717
717
  manifest: {
718
718
  totalRoutes: 0,
@@ -757,7 +757,7 @@ export default discoveredRoutes;
757
757
  * Generated Route Discovery Results
758
758
  * Source: ${n.source}
759
759
  * Generated at: ${new Date().toISOString()}
760
- * Import from '${z.routes}'
760
+ * Import from '${M.routes}'
761
761
  */
762
762
 
763
763
  export const discoveredRoutes = [
@@ -771,7 +771,7 @@ export const routeManifest = {
771
771
  };
772
772
 
773
773
  export default discoveredRoutes;
774
- `},generateManifest:n=>({routes:n?.routes?.length||0,source:n?.source||"unknown",timestamp:Date.now(),errors:n?.errors?.length||0}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.routes||[],r=s.filter(a=>a.auth&&a.auth.required).length,o=s.length;t&&t.info(`${e} Routes: ${o} found${r>0?`, ${r} are authguarded`:""}`)}},gr=[n=>n.endsWith("Page.tsx")];function es(n={}){return ge({pluginName:"dndev-vite-route-discovery",icon:"\u{1F6E3}\uFE0F",virtualModuleId:z.routes,DiscoveryClass:Je,discoveryMethod:"discoverRoutes",filePatterns:gr,templates:pr,manifestFileName:ue.manifests.route,configKey:"routes"})({...n,disableHmr:n?.hmr===!1,hmrSmartDetection:!1})}import{loadEnv as mr}from"vite";U();U();function V(n){return n?n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"):""}function ts(n){return n?n.replace(/\]\]>/g,"]]]]><![CDATA[>"):""}var qe=class{constructor(e={}){let{debug:t=!1,generateRobotsTxt:s=!0,generateSitemap:r=!0,baseUrl:o,siteName:a,crawlDelay:i=1,aiCrawlers:l="recommended",routes:c={},...u}=e;if(!o||!a)throw new Error("SEOGenerator requires baseUrl and siteName options");this.options={debug:t,generateRobotsTxt:s,generateSitemap:r,baseUrl:o,siteName:a,crawlDelay:i,aiCrawlers:l,routes:c,defaultImage:"/og-image.jpg",twitterHandle:"@donotdev",defaultAuthor:"DNDev Team",defaultLanguage:"en",blogPath:"/blog",staticTags:{},...u},this.appRoot=u.appRoot||null,this.logger=C("SEO Generator",e.debug,e.verbose)}async generateSEOFiles(e,t){try{let s=this.generateRouteMetaTags(e.routes||[]),r={routes:e.routes||[],routeMetaTags:s,baseUrl:this.options.baseUrl,siteName:this.options.siteName},o=this.discoverBlogPosts(),a={robotsTxt:null,sitemap:null,rss:null,manifest:null,totalRoutes:r.routes.length,publicRoutes:r.routes.filter(i=>!i.auth||i.auth===!1).length,protectedRoutes:r.routes.filter(i=>i.auth&&i.auth.required).length,blogPosts:o.length};return this.options.generateRobotsTxt&&(a.robotsTxt=await this.generateRobotsTxt(r,t)),this.options.generateSitemap&&(a.sitemap=await this.generateSitemap(r,t,o)),o.length>0&&(a.rss=await this.generateRSSFeed(o,t)),a.manifest=await this.generateManifest(r,t),a}catch(s){throw this.logger.error(`SEO generator failed to create files (robots.txt/sitemap.xml/manifest): ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),s}}async generateRobotsTxt(e,t){let s=[];(e.routes||[]).forEach(o=>{if(o.auth&&o.auth.required){let a=o.path.startsWith("/")?o.path:`/${o.path}`;s.push(a)}}),s.push("/admin","/api","/_next","/static");let r=this.generateRobotsTxtContent({disallowedPaths:[...new Set(s)],sitemap:`${this.options.baseUrl}/sitemap.xml`,crawlDelay:this.options.crawlDelay});return await t("robots.txt",r),{fileName:"robots.txt",content:r,disallowedPaths:s.length}}async generateSitemap(e,t,s=[]){let o=(e.routes||[]).filter(i=>!(i.auth&&i.auth!==!1||typeof i.path=="string"&&i.path.includes(":")||s.length>0&&i.path===this.options.blogPath)).map(i=>({url:i.path,lastmod:new Date().toISOString().split("T")[0],changefreq:"weekly",priority:i.path==="/"?"1.0":"0.8"}));if(s.length>0){o.push({url:this.options.blogPath,lastmod:s[0]?.date||new Date().toISOString().split("T")[0],changefreq:"weekly",priority:"0.7"});for(let i of s)o.push({url:`${this.options.blogPath}/${i.slug}`,lastmod:i.date,changefreq:"monthly",priority:"0.6",image:i.image||null})}let a=this.generateSitemapContent(o);return await t("sitemap.xml",a),{fileName:"sitemap.xml",content:a,publicRoutes:o.length}}async generateManifest(e,t){let s={totalRoutes:e.routes?.length||0,publicRoutes:e.routes?.filter(o=>!o.auth||o.auth===!1).length||0,protectedRoutes:e.routes?.filter(o=>o.auth&&o.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString(),routeMetaTags:e.routeMetaTags||[]},r=JSON.stringify(s,null,2);return await t("seo-manifest.json",r),{fileName:"seo-manifest.json",content:r,manifest:s}}generateRobotsTxtContent(e={}){let{allowedPaths:t=["/"],disallowedPaths:s=["/admin","/api"],sitemap:r,crawlDelay:o}=e,a=c=>c?c==="*"?"*":c.startsWith("/")?c:`/${c}`:"/",i=["User-agent: *",...s.map(c=>`Disallow: ${a(c)}`),...t.map(c=>`Allow: ${a(c)}`)];o&&i.push(`Crawl-delay: ${o}`),r&&i.push(`Sitemap: ${r}`);let l=this.options.aiCrawlers;return l&&l!==!1&&(i.push(""),i.push(...fr(l))),i.join(`
774
+ `},generateManifest:n=>({routes:n?.routes?.length||0,source:n?.source||"unknown",timestamp:Date.now(),errors:n?.errors?.length||0}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.routes||[],r=s.filter(a=>a.auth&&a.auth.required).length,o=s.length;t&&t.info(`${e} Routes: ${o} found${r>0?`, ${r} are authguarded`:""}`)}},fr=[n=>n.endsWith("Page.tsx")];function es(n={}){return fe({pluginName:"dndev-vite-route-discovery",icon:"\u{1F6E3}\uFE0F",virtualModuleId:M.routes,DiscoveryClass:Je,discoveryMethod:"discoverRoutes",filePatterns:fr,templates:gr,manifestFileName:pe.manifests.route,configKey:"routes"})({...n,disableHmr:n?.hmr===!1,hmrSmartDetection:!1})}import{loadEnv as hr}from"vite";W();W();function V(n){return n?n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"):""}function ts(n){return n?n.replace(/\]\]>/g,"]]]]><![CDATA[>"):""}var qe=class{constructor(e={}){let{debug:t=!1,generateRobotsTxt:s=!0,generateSitemap:r=!0,baseUrl:o,siteName:a,crawlDelay:i=1,aiCrawlers:l="recommended",routes:c={},...u}=e;if(!o||!a)throw new Error("SEOGenerator requires baseUrl and siteName options");this.options={debug:t,generateRobotsTxt:s,generateSitemap:r,baseUrl:o,siteName:a,crawlDelay:i,aiCrawlers:l,routes:c,defaultImage:"/og-image.jpg",twitterHandle:"@donotdev",defaultAuthor:"DNDev Team",defaultLanguage:"en",blogPath:"/blog",staticTags:{},...u},this.appRoot=u.appRoot||null,this.logger=I("SEO Generator",e.debug,e.verbose)}async generateSEOFiles(e,t){try{let s=this.generateRouteMetaTags(e.routes||[]),r={routes:e.routes||[],routeMetaTags:s,baseUrl:this.options.baseUrl,siteName:this.options.siteName},o=this.discoverBlogPosts(),a={robotsTxt:null,sitemap:null,rss:null,manifest:null,totalRoutes:r.routes.length,publicRoutes:r.routes.filter(i=>!i.auth||i.auth===!1).length,protectedRoutes:r.routes.filter(i=>i.auth&&i.auth.required).length,blogPosts:o.length};return this.options.generateRobotsTxt&&(a.robotsTxt=await this.generateRobotsTxt(r,t)),this.options.generateSitemap&&(a.sitemap=await this.generateSitemap(r,t,o)),o.length>0&&(a.rss=await this.generateRSSFeed(o,t)),a.manifest=await this.generateManifest(r,t),a}catch(s){throw this.logger.error(`SEO generator failed to create files (robots.txt/sitemap.xml/manifest): ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),s}}async generateRobotsTxt(e,t){let s=[];(e.routes||[]).forEach(o=>{if(o.auth&&o.auth.required){let a=o.path.startsWith("/")?o.path:`/${o.path}`;s.push(a)}}),s.push("/admin","/api","/_next","/static");let r=this.generateRobotsTxtContent({disallowedPaths:[...new Set(s)],sitemap:`${this.options.baseUrl}/sitemap.xml`,crawlDelay:this.options.crawlDelay});return await t("robots.txt",r),{fileName:"robots.txt",content:r,disallowedPaths:s.length}}async generateSitemap(e,t,s=[]){let o=(e.routes||[]).filter(i=>!(i.auth&&i.auth!==!1||typeof i.path=="string"&&i.path.includes(":")||s.length>0&&i.path===this.options.blogPath)).map(i=>({url:i.path,lastmod:new Date().toISOString().split("T")[0],changefreq:"weekly",priority:i.path==="/"?"1.0":"0.8"}));if(s.length>0){o.push({url:this.options.blogPath,lastmod:s[0]?.date||new Date().toISOString().split("T")[0],changefreq:"weekly",priority:"0.7"});for(let i of s)o.push({url:`${this.options.blogPath}/${i.slug}`,lastmod:i.date,changefreq:"monthly",priority:"0.6",image:i.image||null})}let a=this.generateSitemapContent(o);return await t("sitemap.xml",a),{fileName:"sitemap.xml",content:a,publicRoutes:o.length}}async generateManifest(e,t){let s={totalRoutes:e.routes?.length||0,publicRoutes:e.routes?.filter(o=>!o.auth||o.auth===!1).length||0,protectedRoutes:e.routes?.filter(o=>o.auth&&o.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString(),routeMetaTags:e.routeMetaTags||[]},r=JSON.stringify(s,null,2);return await t("seo-manifest.json",r),{fileName:"seo-manifest.json",content:r,manifest:s}}generateRobotsTxtContent(e={}){let{allowedPaths:t=["/"],disallowedPaths:s=["/admin","/api"],sitemap:r,crawlDelay:o}=e,a=c=>c?c==="*"?"*":c.startsWith("/")?c:`/${c}`:"/",i=["User-agent: *",...s.map(c=>`Disallow: ${a(c)}`),...t.map(c=>`Allow: ${a(c)}`)];o&&i.push(`Crawl-delay: ${o}`),r&&i.push(`Sitemap: ${r}`);let l=this.options.aiCrawlers;return l&&l!==!1&&(i.push(""),i.push(...dr(l))),i.join(`
775
775
  `)}generateSitemapContent(e){let t=e.some(r=>r.image),s=e.map(({url:r,lastmod:o,changefreq:a,priority:i,image:l})=>{let c=[` <loc>${V(this.options.baseUrl)}${V(r)}</loc>`];return o&&c.push(` <lastmod>${o}</lastmod>`),a&&c.push(` <changefreq>${a}</changefreq>`),i&&c.push(` <priority>${i}</priority>`),l&&c.push(` <image:image>
776
776
  <image:loc>${V(this.options.baseUrl)}${V(l)}</image:loc>
777
777
  </image:image>`),` <url>
@@ -782,7 +782,7 @@ ${c.join(`
782
782
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${t?`
783
783
  xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"`:""}>
784
784
  ${s}
785
- </urlset>`}generateRouteMetaTags(e){return e.map(t=>{let s=this.options.siteName;if(t.meta?.title)s=`${t.meta.title} - ${this.options.siteName}`;else if(t.path!=="/"){let o=t.path.split("/").filter(Boolean);o.length>0&&(s=`${o[o.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")} - ${this.options.siteName}`)}let r=`Welcome to ${this.options.siteName}`;if(t.meta?.description)r=t.meta.description;else if(t.meta?.entity&&t.meta?.action)r=`${t.meta.action} ${t.meta.entity} on ${this.options.siteName}`;else if(t.path!=="/"){let o=t.path.split("/").filter(Boolean);o.length>0&&(r=`Explore ${o[o.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ").toLowerCase()} on ${this.options.siteName}`)}return{path:t.path,meta:{title:s,description:r,canonical:`${this.options.baseUrl}${t.path}`,robots:t.auth&&t.auth.required?"noindex, nofollow":"index, follow"}}})}discoverBlogPosts(){if(!this.appRoot)return[];let e=$.getInstance(),t=e.resolvePath("src/content/blog",this.appRoot);try{if(!e.pathExists(t))return[];let s=e.readdirSync(t).filter(o=>o.endsWith("_en.md"));if(s.length===0)return[];let r=[];for(let o of s){let a=e.resolvePath(o,t),i=e.readSync(a,{format:"text"}),l=o.replace(/_en\.md$/,""),c=i.match(/^---\r?\n([\s\S]*?)\r?\n---/),u={};if(c)for(let g of c[1].split(`
785
+ </urlset>`}generateRouteMetaTags(e){return e.map(t=>{let s=this.options.siteName;if(t.meta?.title)s=`${t.meta.title} - ${this.options.siteName}`;else if(t.path!=="/"){let o=t.path.split("/").filter(Boolean);o.length>0&&(s=`${o[o.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")} - ${this.options.siteName}`)}let r=`Welcome to ${this.options.siteName}`;if(t.meta?.description)r=t.meta.description;else if(t.meta?.entity&&t.meta?.action)r=`${t.meta.action} ${t.meta.entity} on ${this.options.siteName}`;else if(t.path!=="/"){let o=t.path.split("/").filter(Boolean);o.length>0&&(r=`Explore ${o[o.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ").toLowerCase()} on ${this.options.siteName}`)}return{path:t.path,meta:{title:s,description:r,canonical:`${this.options.baseUrl}${t.path}`,robots:t.auth&&t.auth.required?"noindex, nofollow":"index, follow"}}})}discoverBlogPosts(){if(!this.appRoot)return[];let e=R.getInstance(),t=e.resolvePath("src/content/blog",this.appRoot);try{if(!e.pathExists(t))return[];let s=e.readdirSync(t).filter(o=>o.endsWith("_en.md"));if(s.length===0)return[];let r=[];for(let o of s){let a=e.resolvePath(o,t),i=e.readSync(a,{format:"text"}),l=o.replace(/_en\.md$/,""),c=i.match(/^---\r?\n([\s\S]*?)\r?\n---/),u={};if(c)for(let g of c[1].split(`
786
786
  `)){let f=g.indexOf(":");f!==-1&&(u[g.slice(0,f).trim()]=g.slice(f+1).trim())}let p=u.date;if(!p)try{p=e.statSync(a).mtime.toISOString().split("T")[0],this.logger.warn(`Blog post "${l}" has no frontmatter date, using file mtime (${p})`)}catch{p=new Date().toISOString().split("T")[0],this.logger.warn(`Blog post "${l}" has no date and file stat failed, using today`)}r.push({slug:l,title:u.title||l,description:u.description||"",date:p,tags:u.tags?u.tags.split(",").map(g=>g.trim()):[],image:u.image||null})}return r.sort((o,a)=>a.date.localeCompare(o.date)),this.logger.info(`\u{1F4DD} Discovered ${r.length} blog post(s) in src/content/blog/`),r}catch(s){return this.logger.debug(`Blog content discovery skipped: ${s.message}`),[]}}async generateRSSFeed(e,t){let s=e.map(o=>` <item>
787
787
  <title><![CDATA[${ts(o.title)}]]></title>
788
788
  <link>${V(this.options.baseUrl)}${V(this.options.blogPath)}/${V(o.slug)}</link>
@@ -802,17 +802,17 @@ ${c.join(`
802
802
  <atom:link href="${V(this.options.baseUrl)}/rss.xml" rel="self" type="application/rss+xml"/>
803
803
  ${s}
804
804
  </channel>
805
- </rss>`;return await t("rss.xml",r),{fileName:"rss.xml",content:r,postCount:e.length}}getGenerationSummary(e){let t=e.routes?.length||0,s=e.routes?.filter(o=>!o.auth||o.auth===!1).length||0,r=e.routes?.filter(o=>o.auth&&o.auth.required).length||0;return`${t} routes (${s} public, ${r} protected)`}formatAPIResponse(e){return{totalRoutes:e.routes?.length||0,publicRoutes:e.routes?.filter(t=>!t.auth||t.auth===!1).length||0,protectedRoutes:e.routes?.filter(t=>t.auth&&t.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString()}}},lt=["GPTBot","Google-Extended","CCBot","ClaudeBot"],ct=["OAI-SearchBot","ChatGPT-User","Claude-SearchBot","Claude-User","PerplexityBot"];function fr(n){let e=["# AI Crawler Management"];if(n==="block-all"){for(let t of[...lt,...ct])e.push(`User-agent: ${t}`,"Disallow: /","");return e}if(n==="allow-all"){for(let t of[...lt,...ct])e.push(`User-agent: ${t}`,"Allow: /","");return e}for(let t of lt)e.push(`User-agent: ${t}`,"Disallow: /","");for(let t of ct)e.push(`User-agent: ${t}`,"Allow: /","");return e}U();function ss(n={}){let{siteName:e,baseUrl:t,description:s,blogPosts:r=[],blogPath:o="/blog",logger:a}=n;if(!e||!t)return a?.warn?.("llms.txt generation skipped: missing siteName or baseUrl"),null;let l=we({appRoot:n.appRoot,logger:a}).routes||[],c=[];c.push(`# ${e}`),c.push(""),s&&(c.push(`> ${s}`),c.push(""));let u=l.filter(p=>!p.auth||p.auth===!1);if(u.length>0){c.push("## Pages"),c.push("");for(let p of u){let g=p.path||"/",f=p.meta?.title||dr(g),d=p.meta?.description||"",m=`${t}${g}`;d?c.push(`- [${f}](${m}): ${d}`):c.push(`- [${f}](${m})`)}c.push("")}if(r.length>0){c.push("## Blog"),c.push("");for(let p of r){let g=`${t}${o}/${p.slug}`;p.description?c.push(`- [${p.title}](${g}): ${p.description}`):c.push(`- [${p.title}](${g})`)}c.push("")}return c.join(`
806
- `)}function rs(n={}){let{siteName:e,baseUrl:t,blogPosts:s=[],blogPath:r="/blog",appRoot:o,logger:a}=n;if(!e||!t)return null;if(s.length===0)return a?.debug?.("llms-full.txt skipped: no blog posts"),null;let i=$.getInstance(),l=o?i.resolvePath("src/content/blog",o):null;if(!l||!i.pathExists(l))return null;let c=[`# ${e}
805
+ </rss>`;return await t("rss.xml",r),{fileName:"rss.xml",content:r,postCount:e.length}}getGenerationSummary(e){let t=e.routes?.length||0,s=e.routes?.filter(o=>!o.auth||o.auth===!1).length||0,r=e.routes?.filter(o=>o.auth&&o.auth.required).length||0;return`${t} routes (${s} public, ${r} protected)`}formatAPIResponse(e){return{totalRoutes:e.routes?.length||0,publicRoutes:e.routes?.filter(t=>!t.auth||t.auth===!1).length||0,protectedRoutes:e.routes?.filter(t=>t.auth&&t.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString()}}},lt=["GPTBot","Google-Extended","CCBot","ClaudeBot"],ct=["OAI-SearchBot","ChatGPT-User","Claude-SearchBot","Claude-User","PerplexityBot"];function dr(n){let e=["# AI Crawler Management"];if(n==="block-all"){for(let t of[...lt,...ct])e.push(`User-agent: ${t}`,"Disallow: /","");return e}if(n==="allow-all"){for(let t of[...lt,...ct])e.push(`User-agent: ${t}`,"Allow: /","");return e}for(let t of lt)e.push(`User-agent: ${t}`,"Disallow: /","");for(let t of ct)e.push(`User-agent: ${t}`,"Allow: /","");return e}W();function ss(n={}){let{siteName:e,baseUrl:t,description:s,blogPosts:r=[],blogPath:o="/blog",logger:a}=n;if(!e||!t)return a?.warn?.("llms.txt generation skipped: missing siteName or baseUrl"),null;let l=we({appRoot:n.appRoot,logger:a}).routes||[],c=[];c.push(`# ${e}`),c.push(""),s&&(c.push(`> ${s}`),c.push(""));let u=l.filter(p=>!p.auth||p.auth===!1);if(u.length>0){c.push("## Pages"),c.push("");for(let p of u){let g=p.path||"/",f=p.meta?.title||mr(g),d=p.meta?.description||"",m=`${t}${g}`;d?c.push(`- [${f}](${m}): ${d}`):c.push(`- [${f}](${m})`)}c.push("")}if(r.length>0){c.push("## Blog"),c.push("");for(let p of r){let g=`${t}${o}/${p.slug}`;p.description?c.push(`- [${p.title}](${g}): ${p.description}`):c.push(`- [${p.title}](${g})`)}c.push("")}return c.join(`
806
+ `)}function rs(n={}){let{siteName:e,baseUrl:t,blogPosts:s=[],blogPath:r="/blog",appRoot:o,logger:a}=n;if(!e||!t)return null;if(s.length===0)return a?.debug?.("llms-full.txt skipped: no blog posts"),null;let i=R.getInstance(),l=o?i.resolvePath("src/content/blog",o):null;if(!l||!i.pathExists(l))return null;let c=[`# ${e}
807
807
  `];n.description&&c.push(`> ${n.description}
808
808
  `);for(let u of s){let p=i.resolvePath(`${u.slug}_en.md`,l);try{let g=i.readSync(p,{format:"text"});if(!g)continue;let f=g.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,""),d=`${t}${r}/${u.slug}`;c.push(`## ${u.title}
809
809
  `),c.push(`Source: ${d}
810
810
  `),u.date&&c.push(`Date: ${u.date}
811
811
  `),c.push(f.trim()),c.push("")}catch{a?.debug?.(`llms-full.txt: could not read ${u.slug}`)}}return c.join(`
812
- `)}function dr(n){return n==="/"||n===""?"Home":(n.split("/").filter(Boolean).pop()||"Home").split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function os(n={}){let{disabled:e=!1,debug:t,generateRobotsTxt:s,generateSitemap:r,routes:o={},baseUrl:a,siteName:i,siteDescription:l,crawlDelay:c,aiCrawlers:u,llmsTxt:p=!0,redirects:g,isDev:f,...d}=n;if(e)return{name:"seo-disabled"};let m=C("SEO Plugin",t,!0),S=$.getInstance(),b=null,E=null,N=!1;return{name:"vite-seo-plugin",enforce:"pre",configResolved(F){let k=S.getAppRoot(),x=F.mode||"production",w=mr(x,k,"VITE_").VITE_APP_URL||process.env.VITE_APP_URL||null;w&&t&&m.debug(`Using app URL from VITE_APP_URL: ${w}`),b=i||null;let v=a||w||null;E=v?v.trim().replace(/\/+$/,""):null,m.verbose(`Name: ${b||"Not found"}`),m.verbose(`URL: ${E||"Not found"}
813
- `),b&&m.debug(` - Site name from appConfig: "${b}"`);let O=[];if(E||O.push("baseUrl (VITE_APP_URL in .env)"),b||O.push("siteName (APP_NAME in src/config/app.ts)"),O.length>0){N=!0,m.warn("\u26A0\uFE0F SEO Plugin disabled - missing required configuration:"),O.forEach(P=>m.warn(` - ${P}`)),m.warn(""),m.warn(" To fix:"),E||m.warn(" 1. Add VITE_APP_URL=https://yourdomain.com to your .env file"),b||(m.warn(" 2. Add APP_NAME export to src/config/app.ts:"),m.warn(' export const APP_NAME = "Your App Name";')),m.warn(""),m.warn(" robots.txt and sitemap.xml will NOT be generated."),m.warn("");return}m.debug(`Generate robots.txt: ${s}`),m.debug(`Generate sitemap: ${r}`)},async generateBundle(){if(!N)try{let F=new qe({debug:t,generateRobotsTxt:s,generateSitemap:r,baseUrl:E,siteName:b,crawlDelay:c,aiCrawlers:u,routes:o,appRoot:S.getAppRoot(),...d}),k=we({appRoot:S.getAppRoot(),logger:m}),x=async(w,v)=>{this.emitFile({type:"asset",fileName:w,source:v})},D=await F.generateSEOFiles(k,x);if(D.robotsTxt&&!D.robotsTxt.skipped&&m.info(`\u{1F916} robots.txt: ${D.robotsTxt.disallowedPaths||0} disallowed paths`),D.sitemap&&!D.sitemap.skipped&&m.info(`\u{1F5FA}\uFE0F sitemap.xml: ${D.sitemap.publicRoutes||0} routes`),D.rss&&!D.rss.skipped&&m.info(`\u{1F4E1} rss.xml: ${D.rss.postCount||0} blog posts`),D.manifest&&!D.manifest.skipped&&m.info("\u{1F4C4} seo-manifest.json"),p){let w=S.getAppRoot(),v=F.discoverBlogPosts(),O=ss({siteName:b,baseUrl:E,description:l,appRoot:w,blogPosts:v,logger:m});if(O&&(await x("llms.txt",O),m.info("\u{1F4C4} llms.txt")),v.length>0){let P=rs({siteName:b,baseUrl:E,description:l,appRoot:w,blogPosts:v,logger:m});P&&(await x("llms-full.txt",P),m.info("\u{1F4C4} llms-full.txt"))}}if(g?.length>0){let w=new Set,v=[];for(let{from:O,to:P,permanent:I}of g){let M=O.replace(/\/+$/,"")||"/",q=P.replace(/\/+$/,"")||"/";if(M===q){m.warn(`Redirect loop detected: ${O} \u2192 ${P} (skipped)`);continue}if(!O.startsWith("/")){m.warn(`Redirect source must start with /: "${O}" (skipped)`);continue}if(w.has(M)){m.warn(`Duplicate redirect source: "${O}" (skipped)`);continue}w.add(M),v.push(`${O} ${P} ${I===!1?302:301}`)}v.length>0&&(await x("_redirects",v.join(`
812
+ `)}function mr(n){return n==="/"||n===""?"Home":(n.split("/").filter(Boolean).pop()||"Home").split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function os(n={}){let{disabled:e=!1,debug:t,generateRobotsTxt:s,generateSitemap:r,routes:o={},baseUrl:a,siteName:i,siteDescription:l,crawlDelay:c,aiCrawlers:u,llmsTxt:p=!0,redirects:g,isDev:f,...d}=n;if(e)return{name:"seo-disabled"};let m=I("SEO Plugin",t,!0),S=R.getInstance(),w=null,$=null,A=!1;return{name:"vite-seo-plugin",enforce:"pre",configResolved(T){let k=S.getAppRoot(),N=T.mode||"production",b=hr(N,k,"VITE_").VITE_APP_URL||process.env.VITE_APP_URL||null;b&&t&&m.debug(`Using app URL from VITE_APP_URL: ${b}`),w=i||null;let C=a||b||null;$=C?C.trim().replace(/\/+$/,""):null,m.verbose(`Name: ${w||"Not found"}`),m.verbose(`URL: ${$||"Not found"}
813
+ `),w&&m.debug(` - Site name from appConfig: "${w}"`);let y=[];if($||y.push("baseUrl (VITE_APP_URL in .env)"),w||y.push("siteName (APP_NAME in src/config/app.ts)"),y.length>0){A=!0,m.warn("\u26A0\uFE0F SEO Plugin disabled - missing required configuration:"),y.forEach(E=>m.warn(` - ${E}`)),m.warn(""),m.warn(" To fix:"),$||m.warn(" 1. Add VITE_APP_URL=https://yourdomain.com to your .env file"),w||(m.warn(" 2. Add APP_NAME export to src/config/app.ts:"),m.warn(' export const APP_NAME = "Your App Name";')),m.warn(""),m.warn(" robots.txt and sitemap.xml will NOT be generated."),m.warn("");return}m.debug(`Generate robots.txt: ${s}`),m.debug(`Generate sitemap: ${r}`)},async generateBundle(){if(!A)try{let T=new qe({debug:t,generateRobotsTxt:s,generateSitemap:r,baseUrl:$,siteName:w,crawlDelay:c,aiCrawlers:u,routes:o,appRoot:S.getAppRoot(),...d}),k=we({appRoot:S.getAppRoot(),logger:m}),N=async(b,C)=>{this.emitFile({type:"asset",fileName:b,source:C})},x=await T.generateSEOFiles(k,N);if(x.robotsTxt&&!x.robotsTxt.skipped&&m.info(`\u{1F916} robots.txt: ${x.robotsTxt.disallowedPaths||0} disallowed paths`),x.sitemap&&!x.sitemap.skipped&&m.info(`\u{1F5FA}\uFE0F sitemap.xml: ${x.sitemap.publicRoutes||0} routes`),x.rss&&!x.rss.skipped&&m.info(`\u{1F4E1} rss.xml: ${x.rss.postCount||0} blog posts`),x.manifest&&!x.manifest.skipped&&m.info("\u{1F4C4} seo-manifest.json"),p){let b=S.getAppRoot(),C=T.discoverBlogPosts(),y=ss({siteName:w,baseUrl:$,description:l,appRoot:b,blogPosts:C,logger:m});if(y&&(await N("llms.txt",y),m.info("\u{1F4C4} llms.txt")),C.length>0){let E=rs({siteName:w,baseUrl:$,description:l,appRoot:b,blogPosts:C,logger:m});E&&(await N("llms-full.txt",E),m.info("\u{1F4C4} llms-full.txt"))}}if(g?.length>0){let b=new Set,C=[];for(let{from:y,to:E,permanent:j}of g){let F=y.replace(/\/+$/,"")||"/",U=E.replace(/\/+$/,"")||"/";if(F===U){m.warn(`Redirect loop detected: ${y} \u2192 ${E} (skipped)`);continue}if(!y.startsWith("/")){m.warn(`Redirect source must start with /: "${y}" (skipped)`);continue}if(b.has(F)){m.warn(`Duplicate redirect source: "${y}" (skipped)`);continue}b.add(F),C.push(`${y} ${E} ${j===!1?302:301}`)}C.length>0&&(await N("_redirects",C.join(`
814
814
  `)+`
815
- `),m.info(`\u{1F4CE} _redirects: ${v.length} redirect${v.length>1?"s":""}`))}}catch(F){m.error(`SEO plugin failed to generate files (robots.txt/sitemap.xml): ${F.message}`),m.error(`Stack: ${F.stack||"No stack trace available"}`)}}}}W();function ns(n={}){let{debug:e}=n;return{name:"dndev-server-shim",enforce:"pre",resolveId(t,s){return t.startsWith("node:")?(C("server-shim",e,!0).warn(`Blocking Node.js built-in module import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):et.includes(t)||et.some(r=>t.startsWith(`${r}/`))?(C("server-shim",e,!0).warn(`Blocking server-only subpath import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):yt.includes(t)?(C("server-shim",e,!0).warn(`Blocking server-only import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):null},load(t){return t==="\0virtual:empty-server-module"?`
815
+ `),m.info(`\u{1F4CE} _redirects: ${C.length} redirect${C.length>1?"s":""}`))}}catch(T){m.error(`SEO plugin failed to generate files (robots.txt/sitemap.xml): ${T.message}`),m.error(`Stack: ${T.stack||"No stack trace available"}`)}}}}G();function ns(n={}){let{debug:e}=n;return{name:"dndev-server-shim",enforce:"pre",resolveId(t,s){return t.startsWith("node:")?(I("server-shim",e,!0).warn(`Blocking Node.js built-in module import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):et.includes(t)||et.some(r=>t.startsWith(`${r}/`))?(I("server-shim",e,!0).warn(`Blocking server-only subpath import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):yt.includes(t)?(I("server-shim",e,!0).warn(`Blocking server-only import: ${t}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):null},load(t){return t==="\0virtual:empty-server-module"?`
816
816
  // Node.js built-in modules shims for browser compatibility
817
817
  export const URL = globalThis.URL;
818
818
  export const URLSearchParams = globalThis.URLSearchParams;
@@ -1091,7 +1091,7 @@ ${s}
1091
1091
  // Google Logging Utils shims
1092
1092
  export const LoggingWinston = class LoggingWinston {};
1093
1093
  export const LoggingBunyan = class LoggingBunyan {};
1094
- `:null}}}W();W();W();var as=/--(?:font-family|font-headline)\s*:\s*([^;]+);/g,is=/['"]([^'"]+)['"]/g,ke=class{constructor(e,t={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...t},this.logger=t.logger||{debug:(s,...r)=>{this.options.debug}},this.patterns={selectors:{...tt.selectors,...this.options.customPatterns?.selectors},themes:{...tt.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let t=e.replace(/^--/,"");if(!t)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=t.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let r=s.map((a,i)=>{let l=a.replace(/[^a-zA-Z0-9]/g,"");return l?i===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!r||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${r}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(r)?`${r}Var`:r}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,t,s){let r=[],o,a=this.pathResolver.normalizePath(t),i=this._stripComments(e),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(o=l.exec(i))!==null;){let[,c,u,p]=o;if(!c||!p)continue;let g=u.match(this.patterns.themes.themeIcon),f=u.match(this.patterns.themes.themeIsDark),d={name:c,displayName:p,isDark:f?f[1]==="1":!1,meta:{icon:g?.[1]},source:this.pathResolver.getBasename(t)};this._debug(`Discovered theme: ${c} (${p})`),r.push(d),s.themes.set(c,{name:c,displayName:p,isDark:d.isDark,file:a,variables:new Set,meta:d.meta})}return r.length>0&&this._debug(`Extracted ${r.length} themes from ${a}`),r}extractClasses(e,t){(e.match(this.patterns.selectors.class)||[]).forEach(r=>{let o=r.slice(1);o.startsWith("_")||t.classes.add(o)})}extractVariables(e,t,s){(e.match(this.patterns.selectors.variable)||[]).forEach(o=>{o.startsWith("--")&&o.length>2?s==="framework"?t.variables.framework.add(o):t.variables.consumer.add(o):this._debug(`Skipping invalid CSS variable: ${o}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let t=this._stripComments(e),s=new Set,r;for(as.lastIndex=0;(r=as.exec(t))!==null;){let o=r[1],a;for(is.lastIndex=0;(a=is.exec(o))!==null;){let i=a[1].trim();i&&s.add(i)}}return Array.from(s)}extractKeyframes(e,t){(e.match(this.patterns.selectors.keyframe)||[]).forEach(r=>{let o=r.replace("@keyframes","").trim();o&&t.keyframes.add(o)})}validateCSS(e){let t=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(o=>{t.push(`Possible malformed CSS variable: ${o}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(o=>{if(!o.includes("--theme-label")&&o.includes("--")){let a=o.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&t.push(`Theme class "${a}" missing --theme-label`)}}),t}extractAll(e,t,s="consumer"){let r={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},o=this.extractThemes(e,t,r);this.extractClasses(e,r),this.extractVariables(e,r,s),this.extractKeyframes(e,r);let a=this.validateCSS(e);return{themes:o,classes:Array.from(r.classes),variables:{framework:Array.from(r.variables.framework),consumer:Array.from(r.variables.consumer),all:[...Array.from(r.variables.framework),...Array.from(r.variables.consumer)].sort()},keyframes:Array.from(r.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,t){this.logger.debug(e,t||"")}};var Ie=class extends oe{constructor(e,t,s={}){super(t,s),this.cssExtractor=e||new ke(t,{debug:s.debug,logger:this.logger}),this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes()}_getDiscoveryType(){return"Theme"}async _getPatterns(){return await this.pathResolver.resolvePatterns("css")}_getPatternType(){return"css"}async _processFiles(e){this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes();let{frameworkFiles:t,consumerFiles:s}=e;this.logger.debug(`Scanning ${t.length} framework + ${s.length} consumer CSS files`),this.logger.debug("\u{1F50D} FILES DISCOVERED:"),this.logger.debug("Framework files:",t),this.logger.debug("Consumer files:",s),t.length>0?(this.logger.debug(`Framework files found: ${t.length}`),this.logger.debug("Framework files:",t)):this.logger.debug("No framework files found"),s.length>0?(this.logger.debug(`Consumer files found: ${s.length}`),this.logger.debug("Consumer files:",s)):this.logger.debug("No consumer files found"),await this._processFrameworkFiles(t),await this._processConsumerFiles(s);let r=this._serializeThemes();return this.logger.debug(`Discovered ${r.length} themes:`,r.map(o=>o.name)),{themes:r,variables:{framework:Array.from(this.discovered.variables.framework).sort(),consumer:Array.from(this.discovered.variables.consumer).sort(),all:[...Array.from(this.discovered.variables.framework),...Array.from(this.discovered.variables.consumer)].sort()},classes:Array.from(this.discovered.classes).sort(),keyframes:Array.from(this.discovered.keyframes).sort()}}_getEmptyResult(){let e=this._serializeThemes();return{themes:e.length>0?e:this._getEssentialThemesFallback(),variables:{framework:[],consumer:[],all:[]},classes:[],keyframes:[],timestamp:Date.now()}}_getEssentialThemesFallback(){return st.map(e=>({name:e.name,displayName:e.displayName,meta:{icon:e.icon,category:e.isDark?"dark":"light"},essential:!0,isDark:e.isDark,source:"built-in",variableCount:0}))}_getDiscoverySummary(){return""}async discoverThemes(e=!1){return await this.discover(e)}getThemes(){return this.cache?.themes||[]}getVariables(){return this.cache?.variables||{framework:[],consumer:[],all:[]}}getClasses(){return this.cache?.classes||[]}async _processFrameworkFiles(e){for(let t of e)try{let s=await this.pathResolver.read(t,{format:"text"}),r=this.pathResolver.normalizePath(t);this.cssExtractor.extractThemes(s,r,this.discovered),this.cssExtractor.extractClasses(s,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"framework"),this.cssExtractor.extractKeyframes(s,this.discovered),this.logger.debug(`\u2705 Processed framework: ${this.pathResolver.getRelativePath(r)}`)}catch(s){this.logger.debug(`Error scanning framework file ${t}: ${s.message}`)}}async _processConsumerFiles(e){for(let t of e)try{let s=await this.pathResolver.read(t,{format:"text"}),r=this.pathResolver.normalizePath(t);this.cssExtractor.extractThemes(s,r,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"consumer"),this.logger.debug(`\u2705 Processed consumer: ${this.pathResolver.getRelativePath(r)}`)}catch(s){this.logger.debug(`Error scanning consumer file ${t}: ${s.message}`)}}_addEssentialThemes(){st.forEach(e=>{this.discovered.themes.set(e.name,{name:e.name,displayName:e.displayName,meta:{icon:e.icon,category:e.isDark?"dark":"light"},essential:!0,isDark:e.isDark,source:"built-in",variables:new Set})})}_serializeThemes(){return Array.from(this.discovered.themes.values()).map(e=>({name:e.name,displayName:e.displayName,meta:e.meta,source:e.source,essential:e.essential||!1,isDark:e.isDark||!1,variableCount:e.variables?.size||0}))}};var ls={isEmpty:n=>!n.themes||n.themes.length===0,generateModule:(n,e,t="themes")=>{let{themes:s}=n;if(!s||s.length===0)return ls.generateEmpty(n,e,void 0,t);let r=s.find(a=>a.essential&&a.name==="light")||s[0],o={totalThemes:s.length,defaultTheme:r?.name||"light",hasCustomThemes:s.some(a=>!a.essential),timestamp:new Date().toISOString()};return`// Virtual module: ${z.themes}
1094
+ `:null}}}G();G();G();var as=/--(?:font-family|font-headline)\s*:\s*([^;]+);/g,is=/['"]([^'"]+)['"]/g,De=class{constructor(e,t={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...t},this.logger=t.logger||{debug:(s,...r)=>{this.options.debug}},this.patterns={selectors:{...tt.selectors,...this.options.customPatterns?.selectors},themes:{...tt.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let t=e.replace(/^--/,"");if(!t)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=t.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let r=s.map((a,i)=>{let l=a.replace(/[^a-zA-Z0-9]/g,"");return l?i===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!r||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${r}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(r)?`${r}Var`:r}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,t,s){let r=[],o,a=this.pathResolver.normalizePath(t),i=this._stripComments(e),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(o=l.exec(i))!==null;){let[,c,u,p]=o;if(!c||!p)continue;let g=u.match(this.patterns.themes.themeIcon),f=u.match(this.patterns.themes.themeIsDark),d={name:c,displayName:p,isDark:f?f[1]==="1":!1,meta:{icon:g?.[1]},source:this.pathResolver.getBasename(t)};this._debug(`Discovered theme: ${c} (${p})`),r.push(d),s.themes.set(c,{name:c,displayName:p,isDark:d.isDark,file:a,variables:new Set,meta:d.meta})}return r.length>0&&this._debug(`Extracted ${r.length} themes from ${a}`),r}extractClasses(e,t){(e.match(this.patterns.selectors.class)||[]).forEach(r=>{let o=r.slice(1);o.startsWith("_")||t.classes.add(o)})}extractVariables(e,t,s){(e.match(this.patterns.selectors.variable)||[]).forEach(o=>{o.startsWith("--")&&o.length>2?s==="framework"?t.variables.framework.add(o):t.variables.consumer.add(o):this._debug(`Skipping invalid CSS variable: ${o}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let t=this._stripComments(e),s=new Set,r;for(as.lastIndex=0;(r=as.exec(t))!==null;){let o=r[1],a;for(is.lastIndex=0;(a=is.exec(o))!==null;){let i=a[1].trim();i&&s.add(i)}}return Array.from(s)}extractKeyframes(e,t){(e.match(this.patterns.selectors.keyframe)||[]).forEach(r=>{let o=r.replace("@keyframes","").trim();o&&t.keyframes.add(o)})}validateCSS(e){let t=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(o=>{t.push(`Possible malformed CSS variable: ${o}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(o=>{if(!o.includes("--theme-label")&&o.includes("--")){let a=o.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&t.push(`Theme class "${a}" missing --theme-label`)}}),t}extractAll(e,t,s="consumer"){let r={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},o=this.extractThemes(e,t,r);this.extractClasses(e,r),this.extractVariables(e,r,s),this.extractKeyframes(e,r);let a=this.validateCSS(e);return{themes:o,classes:Array.from(r.classes),variables:{framework:Array.from(r.variables.framework),consumer:Array.from(r.variables.consumer),all:[...Array.from(r.variables.framework),...Array.from(r.variables.consumer)].sort()},keyframes:Array.from(r.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,t){this.logger.debug(e,t||"")}};var Ie=class extends ne{constructor(e,t,s={}){super(t,s),this.cssExtractor=e||new De(t,{debug:s.debug,logger:this.logger}),this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes()}_getDiscoveryType(){return"Theme"}async _getPatterns(){return await this.pathResolver.resolvePatterns("css")}_getPatternType(){return"css"}async _processFiles(e){this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes();let{frameworkFiles:t,consumerFiles:s}=e;this.logger.debug(`Scanning ${t.length} framework + ${s.length} consumer CSS files`),this.logger.debug("\u{1F50D} FILES DISCOVERED:"),this.logger.debug("Framework files:",t),this.logger.debug("Consumer files:",s),t.length>0?(this.logger.debug(`Framework files found: ${t.length}`),this.logger.debug("Framework files:",t)):this.logger.debug("No framework files found"),s.length>0?(this.logger.debug(`Consumer files found: ${s.length}`),this.logger.debug("Consumer files:",s)):this.logger.debug("No consumer files found"),await this._processFrameworkFiles(t),await this._processConsumerFiles(s);let r=this._serializeThemes();return this.logger.debug(`Discovered ${r.length} themes:`,r.map(o=>o.name)),{themes:r,variables:{framework:Array.from(this.discovered.variables.framework).sort(),consumer:Array.from(this.discovered.variables.consumer).sort(),all:[...Array.from(this.discovered.variables.framework),...Array.from(this.discovered.variables.consumer)].sort()},classes:Array.from(this.discovered.classes).sort(),keyframes:Array.from(this.discovered.keyframes).sort()}}_getEmptyResult(){let e=this._serializeThemes();return{themes:e.length>0?e:this._getEssentialThemesFallback(),variables:{framework:[],consumer:[],all:[]},classes:[],keyframes:[],timestamp:Date.now()}}_getEssentialThemesFallback(){return st.map(e=>({name:e.name,displayName:e.displayName,meta:{icon:e.icon,category:e.isDark?"dark":"light"},essential:!0,isDark:e.isDark,source:"built-in",variableCount:0}))}_getDiscoverySummary(){return""}async discoverThemes(e=!1){return await this.discover(e)}getThemes(){return this.cache?.themes||[]}getVariables(){return this.cache?.variables||{framework:[],consumer:[],all:[]}}getClasses(){return this.cache?.classes||[]}async _processFrameworkFiles(e){for(let t of e)try{let s=await this.pathResolver.read(t,{format:"text"}),r=this.pathResolver.normalizePath(t);this.cssExtractor.extractThemes(s,r,this.discovered),this.cssExtractor.extractClasses(s,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"framework"),this.cssExtractor.extractKeyframes(s,this.discovered),this.logger.debug(`\u2705 Processed framework: ${this.pathResolver.getRelativePath(r)}`)}catch(s){this.logger.debug(`Error scanning framework file ${t}: ${s.message}`)}}async _processConsumerFiles(e){for(let t of e)try{let s=await this.pathResolver.read(t,{format:"text"}),r=this.pathResolver.normalizePath(t);this.cssExtractor.extractThemes(s,r,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"consumer"),this.logger.debug(`\u2705 Processed consumer: ${this.pathResolver.getRelativePath(r)}`)}catch(s){this.logger.debug(`Error scanning consumer file ${t}: ${s.message}`)}}_addEssentialThemes(){st.forEach(e=>{this.discovered.themes.set(e.name,{name:e.name,displayName:e.displayName,meta:{icon:e.icon,category:e.isDark?"dark":"light"},essential:!0,isDark:e.isDark,source:"built-in",variables:new Set})})}_serializeThemes(){return Array.from(this.discovered.themes.values()).map(e=>({name:e.name,displayName:e.displayName,meta:e.meta,source:e.source,essential:e.essential||!1,isDark:e.isDark||!1,variableCount:e.variables?.size||0}))}};var ls={isEmpty:n=>!n.themes||n.themes.length===0,generateModule:(n,e,t="themes")=>{let{themes:s}=n;if(!s||s.length===0)return ls.generateEmpty(n,e,void 0,t);let r=s.find(a=>a.essential&&a.name==="light")||s[0],o={totalThemes:s.length,defaultTheme:r?.name||"light",hasCustomThemes:s.some(a=>!a.essential),timestamp:new Date().toISOString()};return`// Virtual module: ${M.themes}
1095
1095
  // \u{1F680} STATIC INJECTION PATTERN - Zero Runtime Loading
1096
1096
  // Generated by @donotdev/config at ${new Date().toISOString()}
1097
1097
 
@@ -1119,7 +1119,7 @@ if (typeof globalThis !== 'undefined') {
1119
1119
  }
1120
1120
 
1121
1121
  // Populate themes configuration
1122
- globalThis._DNDEV_CONFIG_.${H[t]} = {
1122
+ globalThis._DNDEV_CONFIG_.${q[t]} = {
1123
1123
  discovered: themeData,
1124
1124
  mapping: themeData.reduce((acc, theme) => {
1125
1125
  acc[theme.name] = theme;
@@ -1166,7 +1166,7 @@ export default {
1166
1166
  getAllThemes,
1167
1167
  getThemeNames
1168
1168
  };
1169
- `},generateEmpty:(n,e,t,s="themes")=>{let r=n.themes&&n.themes.length>0?n.themes:[{name:"light",displayName:"Light",meta:{icon:"Sun",category:"light"},essential:!0,isDark:!1,source:"built-in",variableCount:0}],o=r.find(i=>i.essential&&i.name==="light")||r[0],a={totalThemes:r.length,defaultTheme:o?.name||"light",hasCustomThemes:r.some(i=>!i.essential),timestamp:new Date().toISOString()};return`// ${z.themes} - Using framework essential themes (fallback)
1169
+ `},generateEmpty:(n,e,t,s="themes")=>{let r=n.themes&&n.themes.length>0?n.themes:[{name:"light",displayName:"Light",meta:{icon:"Sun",category:"light"},essential:!0,isDark:!1,source:"built-in",variableCount:0}],o=r.find(i=>i.essential&&i.name==="light")||r[0],a={totalThemes:r.length,defaultTheme:o?.name||"light",hasCustomThemes:r.some(i=>!i.essential),timestamp:new Date().toISOString()};return`// ${M.themes} - Using framework essential themes (fallback)
1170
1170
  // Generated by @donotdev/config at ${new Date().toISOString()}
1171
1171
 
1172
1172
  export const THEMES = ${JSON.stringify(r,null,2)};
@@ -1190,7 +1190,7 @@ if (typeof globalThis !== 'undefined') {
1190
1190
  };
1191
1191
  }
1192
1192
 
1193
- globalThis._DNDEV_CONFIG_.${H[s]} = {
1193
+ globalThis._DNDEV_CONFIG_.${q[s]} = {
1194
1194
  discovered: themeData,
1195
1195
  mapping: themeData.reduce((acc, theme) => {
1196
1196
  acc[theme.name] = theme;
@@ -1252,7 +1252,7 @@ export default discoveredThemes;
1252
1252
  `;let s=t.find(r=>r.essential&&r.name==="light")||t[0];return`/**
1253
1253
  * Generated Theme Discovery Results
1254
1254
  * Generated at: ${new Date().toISOString()}
1255
- * Import from '${z.themes}'
1255
+ * Import from '${M.themes}'
1256
1256
  */
1257
1257
 
1258
1258
  export const discoveredThemes = ${JSON.stringify(t,null,2)};
@@ -1267,9 +1267,9 @@ export const themeManifest = {
1267
1267
  };
1268
1268
 
1269
1269
  export default discoveredThemes;
1270
- `},generateManifest:n=>({themes:n.themes?.length||0,timestamp:Date.now(),hasCustomThemes:n.themes?.some(e=>!e.essential)||!1}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.themes||[],r=s.filter(a=>!a.essential).length,o=s.length;t&&(o===0?t.warn(`${e} No themes discovered - using framework essential themes fallback`):t.info(`${e} Themes: ${o} discovered${r>0?` (${r} custom)`:""}`))}};function cs(n={}){let e=Date.now();return C("theme-plugin",n.debug,n.verbose).debug("\u{1F3A8} Creating theme discovery plugin..."),ge({pluginName:"dndev-theme",icon:"\u{1F3A8}",virtualModuleId:z.themes,DiscoveryClass:Ie,discoveryMethod:"discoverThemes",filePatterns:["**/*.css"],templates:ls,manifestFileName:ue.manifests.theme,configKey:"themes",createDiscovery:(r,o)=>{let a=new ke(r,{debug:o.debug,logger:C("css-extractor",o.debug,o.verbose)});return new Ie(a,r,o)}})(n)}W();U();var Ye=new Set(["@donotdev/functions"]);function us(){try{let n=$.getInstance(),e=n.resolveAppPath("package.json"),t=n.readSync(e,{format:"json"});if(!t)return[];let s={...t.dependencies,...t.devDependencies};return Object.keys(s).filter(r=>r.startsWith("@donotdev/")).filter(r=>!me.buildTimePackages.includes(r)).filter(r=>!Ye.has(r)).sort()}catch{return[]}}U();function ps(n={}){let e=C("vite-plugins",n.debug,n.verbose);try{let{mode:t,debug:s,verbose:r,isDev:o,isPreview:a=!1,server:i={},routes:l={},themes:c={},i18n:u={},assets:p={},seo:g={},prerender:f={},pwa:d={},serverShim:m={},pluginFactory:S={}}=n,b=l.debug??s,E=c.debug??s,N=u.debug??s,F=p.debug??s,k=m.debug??s,x=[];x.push(ns({...m,debug:k}));let D;try{D=$.getInstance()}catch(v){throw new Error(`Failed to initialize PathResolver: ${v.message||v}`)}x.push({name:"dndev-file-watcher-fix",enforce:"pre",configResolved(v){if(s){e.debug("\u{1F4CB} Vite resolved config (configResolved):");let I={root:v.root,mode:v.mode,envDir:v.envDir,base:v.base,build:v.build?{outDir:v.build.outDir,minify:v.build.minify}:void 0,server:v.server?{port:v.server.port,host:v.server.host}:void 0,plugins:v.plugins?{count:v.plugins.length,names:v.plugins.map(M=>M?.name||"unnamed").filter(Boolean)}:void 0};e.debug(JSON.stringify(I,null,2))}D.setAppRoot(v.root);let O=D.getAppRoot(),P=us();if(P.length>0){let I=v.optimizeDeps?.include||[];v.optimizeDeps.include=[...new Set([...I,...P])],e.verbose(`optimizeDeps: added ${P.length} @donotdev packages`)}if(Ye.size>0){let I=v.optimizeDeps?.exclude||[],M=[...Ye];v.optimizeDeps.exclude=[...new Set([...I,...M])],e.verbose(`optimizeDeps: excluded ${M.length} server-only packages`)}if(o&&v.server?.port){let I=v.server.https?"https":"http";process.env.VITE_APP_URL=`${I}://localhost:${v.server.port}`,(s||r)&&e.debug(`VITE_APP_URL set: ${process.env.VITE_APP_URL}`)}else o&&e.warn("VITE_APP_URL not set in dev mode. Server port not available.");try{let I=D.getRepoRoot();e.verbose(`Repo: ${I}`),e.verbose(`App: ${O}`)}catch(I){e.debug(`Could not log PathResolver values: ${I.message}`)}if(v.server&&!a){let I=q=>{let Y=q.replace(/\\/g,"/"),ae=O.replace(/\\/g,"/");return!Y.startsWith(ae)};v.server.watch||(v.server.watch={});let M=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/.next/**","**/.turbo/**","**/.vite/**","**/functions/**","**/.generated/**"];v.server.watch={...v.server.watch,ignored:[...v.server.watch.ignored||[],...M,I]},e.verbose(`Fixed file watcher to use app root: ${O}`)}}}),x.push(Yt({debug:s,verbose:r})),x.push(Jt({debug:s})),x.push(vr({fastRefresh:!0,jsxRuntime:"automatic"})),x.push(yr({ignoreConfigErrors:!0})),i.https===!0&&x.push(hr()),x.push(es({...S,...l,debug:b})),x.push(cs({...S,...c,debug:E})),x.push(...Vt({...S,...u,debug:N})),x.push(It({...S,...p,debug:F})),x.push(Ut({...S,mode:t,debug:s,verbose:r})),x.push(os({...g,debug:s,isDev:o})),d.enabled&&x.push(Zt({...d,debug:s})),x.push(Gt({debug:s})),x.push(Lt());let w=!1;return x.push({name:"dndev-build-summary",enforce:"post",configResolved(v){w=v.command==="build"},closeBundle(){if(!w)return;let v=D,O=v.resolveAppPath("dist/assets");if(v.pathExists(O))try{let P=v.readdirSync(O),I=P.filter(Y=>Y.endsWith(".js")),M=P.filter(Y=>Y.endsWith(".css")),q=P.length-I.length-M.length;e.info(`
1271
- Build output: ${I.length} JS, ${M.length} CSS, ${q} other \u2014 ${P.length} files total`)}catch{}}}),x.push(Kt({...f,debug:s,verbose:r})),x}catch(t){throw C("vite-plugins",!1,!0).error(`Failed to create Vite plugins: ${t.message}`),t}}W();function br(n){if(!n)return{};let e={};return Array.isArray(n)?n.forEach(({find:t,replacement:s})=>{typeof t=="string"&&(e[t]=s)}):typeof n=="object"&&Object.assign(e,n),e}function gs(n={}){let{alias:e,...t}=n,{conditions:s,...r}=t;return{alias:{"@":"/src",...br(e)},dedupe:["react","react-dom","react-router-dom"],preserveSymlinks:!1,conditions:["browser","module","import","vite-app",...s||[]],...r}}function fs(n={}){let{include:e=[],exclude:t=[],esbuildOptions:s={},...r}=n,o=[...e,...me.optionalFeatures],a=[...new Set(o)],i=[...new Set(t)];return{include:a,exclude:i,esbuildOptions:s,...r}}function Yr(n={}){return n==null&&(n={}),async(e={})=>{e==null&&(e={});try{let t=process.env.CI==="true";process.env.DNDEV_BUILD_ID||(process.env.DNDEV_BUILD_ID=t?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9));let s=e.command,r=e.mode,o=e.isPreview??!1,{appConfig:a,dndev:i,...l}=n;if(!a)throw new Error(`appConfig is required. Import appConfig from src/config/app.ts and pass it to defineViteConfig({ appConfig, ... })
1272
- Make sure the import statement in vite.config.ts is: import { appConfig } from "./src/config/app";`);if(typeof a!="object"||a===null)throw new Error(`appConfig must be an object, but got ${typeof a}. Make sure you are exporting appConfig from src/config/app.ts correctly.`);let c=a?.features?{debug:a.features.debug}:void 0,u=a?.seo&&typeof a.seo!="boolean"?{...a.seo,siteName:a.seo.siteName||a.app?.name}:a?.app?.name?{siteName:a.app.name}:void 0,{features:p,seo:g,...f}=l,d=a?.app?{name:a.app.name,shortName:a.app.shortName,description:a.app.description}:void 0,{pwa:m={},...S}=f,b={...m,app:m.app||d},E={...c?{features:c}:{},...u?{seo:u}:{},...Object.keys(b).length>0?{pwa:b}:{},...S,mode:r},N;try{N=At(E)}catch(Z){throw new Error(`mergeOptions failed: ${Z?.message||Z||"Unknown error"}`)}let F;try{F=Nt(N)}catch(Z){throw new Error(`normalizeOptions failed: ${Z?.message||Z||"Unknown error"}`)}if(!F)throw new Error("normalizeOptions returned undefined");let{mode:k,debug:x,verbose:D,isDev:w,isDebug:v,shouldAnalyze:O,serverOptions:P,previewOptions:I,buildOverrides:M,resolveOptions:q,routeOptions:Y,themeOptions:ae,i18nOptions:de,assetOptions:xe,featureOptions:R,seoOptions:T,prerenderOptions:j,pwaOptions:L,serverShimOptions:ie,chunkingOptions:Re,pluginFactoryOptions:$e,base:Se,defineOptions:y,optimizeDepsOptions:_,pluginsOptions:G,cssOptions:ce,envDir:K,restOptions:Ae}=F,Me=C("vite-config",x,D);Me.debug(`Mode: ${k}, Dev: ${w}`);let gt=process.env.DNDEV_BUILD_ID,Ne;s==="build"?Ne=`Building for ${k}`:o?Ne=`Preview server (serving ${k} build)`:s==="serve"?Ne=`Development server (${k})`:Ne=`Running ${s} (${k})`,Me.info(`
1270
+ `},generateManifest:n=>({themes:n.themes?.length||0,timestamp:Date.now(),hasCustomThemes:n.themes?.some(e=>!e.essential)||!1}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.themes||[],r=s.filter(a=>!a.essential).length,o=s.length;t&&(o===0?t.warn(`${e} No themes discovered - using framework essential themes fallback`):t.info(`${e} Themes: ${o} discovered${r>0?` (${r} custom)`:""}`))}};function cs(n={}){let e=Date.now();return I("theme-plugin",n.debug,n.verbose).debug("\u{1F3A8} Creating theme discovery plugin..."),fe({pluginName:"dndev-theme",icon:"\u{1F3A8}",virtualModuleId:M.themes,DiscoveryClass:Ie,discoveryMethod:"discoverThemes",filePatterns:["**/*.css"],templates:ls,manifestFileName:pe.manifests.theme,configKey:"themes",createDiscovery:(r,o)=>{let a=new De(r,{debug:o.debug,logger:I("css-extractor",o.debug,o.verbose)});return new Ie(a,r,o)}})(n)}G();W();var Ye=new Set(["@donotdev/functions"]);function us(){try{let n=R.getInstance(),e=n.resolveAppPath("package.json"),t=n.readSync(e,{format:"json"});if(!t)return[];let s={...t.dependencies,...t.devDependencies};return Object.keys(s).filter(r=>r.startsWith("@donotdev/")).filter(r=>!me.buildTimePackages.includes(r)).filter(r=>!Ye.has(r)).sort()}catch{return[]}}W();function ps(n={}){let e=I("vite-plugins",n.debug,n.verbose);try{let{mode:t,debug:s,verbose:r,isDev:o,isPreview:a=!1,server:i={},routes:l={},themes:c={},i18n:u={},assets:p={},seo:g={},prerender:f={},pwa:d={},serverShim:m={},pluginFactory:S={},reactCompiler:w=!1}=n,$=l.debug??s,A=c.debug??s,T=u.debug??s,k=p.debug??s,N=m.debug??s,x=[];x.push(ns({...m,debug:N}));let b;try{b=R.getInstance()}catch(y){throw new Error(`Failed to initialize PathResolver: ${y.message||y}`)}x.push({name:"dndev-file-watcher-fix",enforce:"pre",configResolved(y){if(s){e.debug("\u{1F4CB} Vite resolved config (configResolved):");let F={root:y.root,mode:y.mode,envDir:y.envDir,base:y.base,build:y.build?{outDir:y.build.outDir,minify:y.build.minify}:void 0,server:y.server?{port:y.server.port,host:y.server.host}:void 0,plugins:y.plugins?{count:y.plugins.length,names:y.plugins.map(U=>U?.name||"unnamed").filter(Boolean)}:void 0};e.debug(JSON.stringify(F,null,2))}b.setAppRoot(y.root);let E=b.getAppRoot(),j=us();if(j.length>0){let F=y.optimizeDeps?.include||[];y.optimizeDeps.include=[...new Set([...F,...j])],e.verbose(`optimizeDeps: added ${j.length} @donotdev packages`)}if(Ye.size>0){let F=y.optimizeDeps?.exclude||[],U=[...Ye];y.optimizeDeps.exclude=[...new Set([...F,...U])],e.verbose(`optimizeDeps: excluded ${U.length} server-only packages`)}if(o&&y.server?.port){let F=y.server.https?"https":"http";process.env.VITE_APP_URL=`${F}://localhost:${y.server.port}`,(s||r)&&e.debug(`VITE_APP_URL set: ${process.env.VITE_APP_URL}`)}else o&&e.warn("VITE_APP_URL not set in dev mode. Server port not available.");try{let F=b.getRepoRoot();e.verbose(`Repo: ${F}`),e.verbose(`App: ${E}`)}catch(F){e.debug(`Could not log PathResolver values: ${F.message}`)}if(y.server&&!a){let F=te=>{let J=te.replace(/\\/g,"/"),ie=E.replace(/\\/g,"/");return!J.startsWith(ie)};y.server.watch||(y.server.watch={});let U=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/.next/**","**/.turbo/**","**/.vite/**","**/functions/**","**/.generated/**"];y.server.watch={...y.server.watch,ignored:[...y.server.watch.ignored||[],...U,F]},e.verbose(`Fixed file watcher to use app root: ${E}`)}}}),x.push(Yt({debug:s,verbose:r})),x.push(Jt({debug:s})),x.push(yr({fastRefresh:!0,jsxRuntime:"automatic",...w?{babel:{plugins:[["babel-plugin-react-compiler",{target:"19"}]]}}:{}})),x.push(br({ignoreConfigErrors:!0})),i.https===!0&&x.push(vr()),x.push(es({...S,...l,debug:$})),x.push(cs({...S,...c,debug:A})),x.push(...Vt({...S,...u,debug:T})),x.push(It({...S,...p,debug:k})),x.push(Ut({...S,mode:t,debug:s,verbose:r})),x.push(os({...g,debug:s,isDev:o})),d.enabled&&x.push(Zt({...d,debug:s})),x.push(Gt({debug:s})),x.push(Lt());let C=!1;return x.push({name:"dndev-build-summary",enforce:"post",configResolved(y){C=y.command==="build"},closeBundle(){if(!C)return;let y=b,E=y.resolveAppPath("dist/assets");if(y.pathExists(E))try{let j=y.readdirSync(E),F=j.filter(J=>J.endsWith(".js")),U=j.filter(J=>J.endsWith(".css")),te=j.length-F.length-U.length;e.info(`
1271
+ Build output: ${F.length} JS, ${U.length} CSS, ${te} other \u2014 ${j.length} files total`)}catch{}}}),x.push(Kt({...f,debug:s,verbose:r})),x}catch(t){throw I("vite-plugins",!1,!0).error(`Failed to create Vite plugins: ${t.message}`),t}}G();function wr(n){if(!n)return{};let e={};return Array.isArray(n)?n.forEach(({find:t,replacement:s})=>{typeof t=="string"&&(e[t]=s)}):typeof n=="object"&&Object.assign(e,n),e}function gs(n={}){let{alias:e,...t}=n,{conditions:s,...r}=t;return{alias:{"@":"/src",...wr(e)},dedupe:["react","react-dom","react-router-dom"],preserveSymlinks:!1,conditions:["browser","module","import","vite-app",...s||[]],...r}}function fs(n={}){let{include:e=[],exclude:t=[],esbuildOptions:s={},...r}=n,o=[...e,...me.optionalFeatures],a=[...new Set(o)],i=[...new Set(t)];return{include:a,exclude:i,esbuildOptions:s,...r}}function Kr(n={}){return n==null&&(n={}),async(e={})=>{e==null&&(e={});try{let t=process.env.CI==="true";process.env.DNDEV_BUILD_ID||(process.env.DNDEV_BUILD_ID=t?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9));let s=e.command,r=e.mode,o=e.isPreview??!1,{appConfig:a,dndev:i,...l}=n;if(!a)throw new Error(`appConfig is required. Import appConfig from src/config/app.ts and pass it to defineViteConfig({ appConfig, ... })
1272
+ Make sure the import statement in vite.config.ts is: import { appConfig } from "./src/config/app";`);if(typeof a!="object"||a===null)throw new Error(`appConfig must be an object, but got ${typeof a}. Make sure you are exporting appConfig from src/config/app.ts correctly.`);let c=a?.features?{debug:a.features.debug}:void 0,u=a?.seo&&typeof a.seo!="boolean"?{...a.seo,siteName:a.seo.siteName||a.app?.name}:a?.app?.name?{siteName:a.app.name}:void 0,{features:p,seo:g,...f}=l,d=a?.app?{name:a.app.name,shortName:a.app.shortName,description:a.app.description}:void 0,{pwa:m={},...S}=f,w={...m,app:m.app||d},$={...c?{features:c}:{},...u?{seo:u}:{},...Object.keys(w).length>0?{pwa:w}:{},...S,mode:r},A;try{A=At($)}catch(Z){throw new Error(`mergeOptions failed: ${Z?.message||Z||"Unknown error"}`)}let T;try{T=Nt(A)}catch(Z){throw new Error(`normalizeOptions failed: ${Z?.message||Z||"Unknown error"}`)}if(!T)throw new Error("normalizeOptions returned undefined");let{mode:k,debug:N,verbose:x,isDev:b,isDebug:C,shouldAnalyze:y,serverOptions:E,previewOptions:j,buildOverrides:F,resolveOptions:U,routeOptions:te,themeOptions:J,i18nOptions:ie,assetOptions:xe,featureOptions:P,seoOptions:O,prerenderOptions:L,pwaOptions:z,serverShimOptions:le,chunkingOptions:Pe,pluginFactoryOptions:Re,reactCompiler:$e,base:v,defineOptions:_,optimizeDepsOptions:H,pluginsOptions:ue,cssOptions:K,envDir:Ee,restOptions:Ss}=T,Me=I("vite-config",N,x);Me.debug(`Mode: ${k}, Dev: ${b}`);let gt=process.env.DNDEV_BUILD_ID,Ne;s==="build"?Ne=`Building for ${k}`:o?Ne=`Preview server (serving ${k} build)`:s==="serve"?Ne=`Development server (${k})`:Ne=`Running ${s} (${k})`,Me.info(`
1273
1273
  \u{1F3D7}\uFE0F DnDev Framework - ${Ne}${gt?` [build:${gt}]`:""}`),Me.info(` Platform: Vite | Command: ${s} | Mode: ${k}
1274
- `);let ze=ps({mode:k,debug:x,verbose:D,isDev:w,isPreview:o,routes:Y,themes:ae,i18n:de,assets:xe,features:R,seo:T,prerender:j,pwa:L,serverShim:ie,chunkingOptions:Re,pluginFactory:$e});if(!Array.isArray(ze))throw new Error(`createVitePlugins returned ${typeof ze}, expected array. Value: ${ze}`);let Ss=$t({mode:k,chunkingOptions:Re,debug:x,isDev:w,isDebug:v,shouldAnalyze:O}),Ps=o?void 0:Et(P.port||3e3,P,Me),Rs=o?_t(I):void 0;if(i)try{let{createDndevPlugin:Z}=await Promise.resolve().then(()=>(xs(),ws));G.push(Z(typeof i=="object"?i:{}))}catch{}return{...Se&&{base:Se},plugins:[...ze,...G],appType:"spa",assetsInclude:["**/*.woff","**/*.woff2","**/*.ttf","**/*.otf","**/*.eot"],...k==="production"&&{build:Ss},...s==="serve"&&!o&&{server:Ps},...o&&{preview:Rs},...K&&{envDir:K},customLogger:k==="production"&&!x?(()=>{let Z={hasWarned:!1,_shouldSuppress(te){return te.includes("dist/")||te.includes("kB")||te.includes("\u2502")||te.includes("gzip:")||te.includes("\u2713 built in")||te.match(/built in \d+\.\d+s/)},info(te){Z._shouldSuppress(te)},warn(te){Z._shouldSuppress(te)},error(te){},warnOnce(te){Z.hasWarned||(Z.hasWarned=!0)},clearScreen(){},hasErrorLogged(){return!1}};return Z})():void 0,css:{postcss:Tt(ce),...ce},optimizeDeps:fs(_),resolve:gs(q),define:{...y,"process.env.NODE_ENV":JSON.stringify(r),__DEV__:JSON.stringify(w),__PROD__:JSON.stringify(!w)},...Ae}}catch(t){let s=t||new Error("Unknown error occurred"),r=s?.message||s?.toString()||String(s)||"Unknown error",o=s?.stack||"",a=new Error(`Failed to create Vite config: ${r}${o?`
1275
- ${o}`:""}`);throw a.stack=o||a.stack,a}}}export{Yr as defineViteConfig};
1274
+ `);let ze=ps({mode:k,debug:N,verbose:x,isDev:b,isPreview:o,routes:te,themes:J,i18n:ie,assets:xe,features:P,seo:O,prerender:L,pwa:z,serverShim:le,chunkingOptions:Pe,pluginFactory:Re,reactCompiler:$e});if(!Array.isArray(ze))throw new Error(`createVitePlugins returned ${typeof ze}, expected array. Value: ${ze}`);let Ps=$t({mode:k,chunkingOptions:Pe,debug:N,isDev:b,isDebug:C,shouldAnalyze:y}),Rs=o?void 0:Et(E.port||3e3,E,Me),$s=o?_t(j):void 0;if(i)try{let{createDndevPlugin:Z}=await Promise.resolve().then(()=>(xs(),ws));ue.push(Z(typeof i=="object"?i:{}))}catch{}return{...v&&{base:v},plugins:[...ze,...ue],appType:"spa",assetsInclude:["**/*.woff","**/*.woff2","**/*.ttf","**/*.otf","**/*.eot"],...k==="production"&&{build:Ps},...s==="serve"&&!o&&{server:Rs},...o&&{preview:$s},...Ee&&{envDir:Ee},customLogger:k==="production"&&!N?(()=>{let Z={hasWarned:!1,_shouldSuppress(se){return se.includes("dist/")||se.includes("kB")||se.includes("\u2502")||se.includes("gzip:")||se.includes("\u2713 built in")||se.match(/built in \d+\.\d+s/)},info(se){Z._shouldSuppress(se)},warn(se){Z._shouldSuppress(se)},error(se){},warnOnce(se){Z.hasWarned||(Z.hasWarned=!0)},clearScreen(){},hasErrorLogged(){return!1}};return Z})():void 0,css:{postcss:Tt(K),...K},optimizeDeps:fs(H),resolve:gs(U),define:{..._,"process.env.NODE_ENV":JSON.stringify(r),__DEV__:JSON.stringify(b),__PROD__:JSON.stringify(!b)},...Ss}}catch(t){let s=t||new Error("Unknown error occurred"),r=s?.message||s?.toString()||String(s)||"Unknown error",o=s?.stack||"",a=new Error(`Failed to create Vite config: ${r}${o?`
1275
+ ${o}`:""}`);throw a.stack=o||a.stack,a}}}export{Kr as defineViteConfig};