@onoxm/vite-plugin-auto-router 0.1.5 → 0.2.0
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/dist/core-DIY62STE.js +1 -0
- package/dist/core-Nna-MKEw.js +1 -0
- package/dist/generate-react-routes-hmr.cjs +1 -1
- package/dist/generate-react-routes-hmr.d.ts +3 -3
- package/dist/generate-react-routes-hmr.js +1 -1
- package/dist/generate-react-routes.cjs +1 -1
- package/dist/generate-react-routes.d.ts +3 -13
- package/dist/generate-react-routes.js +1 -1
- package/dist/generate-vue-routes-hmr.cjs +1 -1
- package/dist/generate-vue-routes-hmr.d.ts +3 -3
- package/dist/generate-vue-routes-hmr.js +1 -1
- package/dist/generate-vue-routes.cjs +1 -1
- package/dist/generate-vue-routes.d.ts +3 -3
- package/dist/generate-vue-routes.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +15 -10
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +14 -11
- package/dist/react.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +49 -67
- package/dist/utils.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.ts +14 -11
- package/dist/vue.js +1 -1
- package/package.json +16 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:fs";import n from"node:path";import t from"fast-glob";function o(e){let n=r(e,0),t=!1;if(n+5<=e.length&&"async"===e.slice(n,n+5).toLowerCase()&&(t=!0,n=r(e,n+5)),n<e.length&&"("===e[n]){const t=s(e,n);if(-1!==t){let n=r(e,t+1);if(n+1<e.length&&"="===e[n]&&">"===e[n+1])return e}}const o=e.indexOf("(");if(-1===o)return e;const a=s(e,o);if(-1===a)return e;return(t?"async ":"")+e.slice(o,a+1)+" => "+e.slice(a+1)}function r(e,n){for(;n<e.length&&/\s/.test(e[n]);)n++;return n}function s(e,n){let t=0,o=!1,r="";for(let s=n;s<e.length;s++){const n=e[s];if('"'!==n&&"'"!==n&&"`"!==n){if(!o)if("("===n)t++;else if(")"===n&&(t--,0===t))return s}else o?n===r&&(o=!1):(o=!0,r=n)}return-1}var a=n=>{try{if(!e.existsSync(n))return;e.unlinkSync(n)}catch(t){console.error("删除文件失败:",t)}},i=n=>{try{if(!e.existsSync(n))return;e.rmSync(n,{recursive:!0})}catch(t){console.error("删除目录失败:",t)}},c=(e,n,t)=>{const r={};for(const[s,a]of Object.entries(n))if("function"==typeof a){const n=`${e}-${s}`;r[s]=n,t.set(n,`<start>${o(a.toString())}</end>`)}else r[s]=a;return r},u=e=>e.startsWith("/")?e.slice(1):e.endsWith("/")?e.slice(0,-1):e.startsWith("./")?e.slice(2):e,p=t=>e.existsSync(n.resolve(t,"tsconfig.json")),l={react:{ts:"src/router/autoRouter.tsx",js:"src/router/autoRouter.jsx"},vue:{ts:"src/router/autoRouter.ts",js:"src/router/autoRouter.js"}},h=(e,t,o)=>{let r=o;return r||(r=n.resolve(t,l[e][p(t)?"ts":"js"])),r},f=/[/\\]/,g=/[^a-zA-Z0-9]/g,d=/^(\d)/,m=e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"";function R(e){const t=n.extname(e),o=n.basename(e,t),r=n.dirname(e).split(f).filter(Boolean);return"index"!==o&&"Index"!==o&&r.push(o),r.map(e=>(e=>e.replace(g,"_").replace(d,"_$1"))(e).split("_").map(m).join("")).join("")||"Component"}var P={"/home":"/","/root":"/"},y=(e,n)=>{const t=e.split("/"),o=t[t.length-1];return n&&o.endsWith(n)?o.slice(0,-n.length):o},$=e=>{const n=P[e];return n||("/notfound"===e.toLowerCase()||"/404"===e?"/*":e)},j=(e,n)=>e.endsWith(".config."+(n?"ts":"js"))?"index"===y(e,".config."+(n?"ts":"js"))?e.replace("index.config."+(n?"ts":"js"),"index."+(n?"ts":"js")):e.slice(0,-10)+"."+(n?"tsx":"jsx"):e.replace("index.config."+(n?"ts":"js"),"index."+(n?"ts":"js")),x=(e,n,t)=>{if(e.endsWith(".config."+(t?"ts":"js"))){const o=y(e,".config."+(t?"ts":"js")),r=(e=>{const n=e.split("/");return n.pop(),n.join("/")})(e).replace(n,"");return"index"===o?r||"/":r?`${r}/${o}`:`/${o}`}return e.replace(n,"").replace("/index.config."+(t?"ts":"js"),"")||"/"},C=async(e,n,t,o)=>{const r=[];for(const[s,a]of((e,n,t)=>Object.keys(e).map(e=>{const o=((e,n)=>e.endsWith(n?".tsx":".jsx")?e.slice(0,-4)+".config."+(n?"ts":"js"):e.replace("index."+(n?"ts":"js"),"index.config."+(n?"ts":"js")))(e,t);return[o,n[o]||{}]}))(e,n,o)){const n=j(s,o);if(!e[n])continue;const i=me(x(s,`/${t}`,o)||"/",o,"react"),c=$(i);r.push({...a,path:c,type:a?.type,isRoot:"/root"===i,element:e[n]})}return r},b=e=>{if(e.index)return e;if("wrap"!==e.type){const{path:n,children:t,...o}=e;if(Object.keys(o).length>0)return{path:n,children:[{path:"",index:!0,...o},...(t||[]).map(b)]}}return e.children?{...e,children:e.children.map(b)}:e},w=e=>(e=>e.map(b))((e=>{const n=/* @__PURE__ */new Map,t=[],o=/* @__PURE__ */new Map,r=e=>{let n=o.get(e);return void 0===n&&(n="/"===e?[]:e.split("/").filter(Boolean),o.set(e,n)),n},s=e.slice().sort((e,n)=>e.path.length-n.path.length);for(const a of s){const e=a.path,o=r(e),s={...a,children:[]};if(n.set(e,s),o.length<=1){t.push(s);continue}const i="/"+o.slice(0,-1).join("/"),c=n.get(i);c?(s.path=o[o.length-1],c.children.push(s)):t.push(s)}return t})(e)),M=e=>{const{isRoot:n,type:t,children:o,...r}=e;return o?.length?{...r,children:o.map(M)}:r},O=e=>{const{children:n}=e;if(!n?.length){const{children:n,...t}=e;return t}const t=n.map(O);if("wrap"===e.type)return{...e,children:t};const{path:o,element:r,type:s,children:a,...i}=e;return r?{path:o,children:[{index:!0,element:r,...i},...t]}:{path:o,...i,children:t}},v=e=>M(O(e)),S=e=>w(e).map(v),T=e=>{if(e.some(e=>e.isRoot))return(e=>{let n,t,o;const r=[];for(const i of e)if(i.isRoot){if(n)throw new Error("There cannot be multiple root routes in a route");n=i}else"/"===i.path?t=i:"/*"===i.path?o=i:r.push(i);if(fe(r,"path"))throw new Error("There cannot be duplicate paths in a route");const s=[t&&{...t,index:!0},...S(r)].filter(e=>Boolean(e)),a=[];return n&&a.push(M({...n,children:s})),o&&a.push(M(o)),a})(e);if(fe(e,"path"))throw new Error("There cannot be duplicate paths in a route");return S(e)},k=(e,n)=>({import:`import ${e} from './${n}'`,component:`<start><${e} /></end>`,lazy:`const ${e} = lazy(() => import('${n}'))`,lazyComponent:`<start><Suspense><${e} /></Suspense></end>`});var E="index.tsx",N="index.jsx",F=(e,n,t,o,r,s,a)=>{const i=((e,n)=>e.includes(n?E:N)?e.replace(n?E:N,n?$e:je):e)(pe(e,n),a),c=ue(ie(t,e)),u=se(R(c),s),p=`element(${c})`;o[`/${i}`]=p,r.set(p,{path:c,componentName:u})},W=(e,n,t,o)=>{const r=pe(e,n);t[`/${r}`]=c(r,ae(e),o)};function L(e,n,o,r,s,a,i,c,u){const p={},l=e.replace(/^\/+/,""),h=t.sync(l,{cwd:n,absolute:!0,onlyFiles:!0}).filter(he);for(const t of h)if("component"===s){if(t.includes(".config."))continue;F(t,o,r,p,a,i,u)}else W(t,o,p,c);return p}var B=async(e,n,t,o,r,s)=>{const a=/* @__PURE__ */new Map,i=/* @__PURE__ */new Set,c=/* @__PURE__ */new Map;ye(o,((e,n,t,o)=>{let r=e;for(const[s,a]of n){const e=k(a.componentName,a.path);r=r.replace(s,o?e.lazyComponent:e.component)}for(const[s,a]of t)r=r.replace(s,a);return de(r)})(function(e,n,t,o){const r=t.length>0?`\n${t.join("\n")}\n`:"";return`// Auto-generated by ono-auto-router\n${o?"import type { RouteObject } from 'react-router-dom'\n":""}${n.join("\n")}${o?"\n\ntype PageConfig = Partial<\n Omit<RouteObject, 'path' | 'Component' | 'element' | 'children'> & {\n type?: 'single' | 'wrap'\n }\n>\n":""}${o?"\nexport const defineConfig = (config: PageConfig) => config":""}\n${r}\nexport const routes${o?": RouteObject[]":""} = ${JSON.stringify(e,null,2)}\n`}(T(await C(L("/**/*.{jsx,tsx}",n,t,o,"component",a,i,c,s),L("/**/*.config.{js,ts,jsx,tsx}",n,t,o,"config",a,i,c,s),e,s)),((e,n)=>{if(e)return["import { lazy, Suspense } from 'react'"];const t=[];for(const o of n.values())t.push(k(o.componentName,o.path).import);return t})(r,a),((e,n)=>{if(!e)return[];const t=[];for(const o of n.values())t.push(k(o.componentName,o.path).lazy);return t})(r,a),s),a,c,r))},z=(e,t,o,r)=>{const s=t.split(".")[0],a=(e=>`// Auto-generated by ono-auto-router${e?"\nexport { defineConfig } from './defineConfig'":""}\nexport { routes } from './autoRouter'\n`)(r),i=o?((e,n)=>`\nconst PATH_REPLACEMENTS${n?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst cachedLazyComponents${n?": Record<\n string,\n LazyExoticComponent<ComponentType<unknown>>\n>":""} = {}\n\nconst getConfigFileName = ${n?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${n?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${n?"ts":"js"}'\n }\n return pagePath.replace('index.${n?"ts":"js"}', 'index.config.${n?"ts":"js"}')\n}\n\nconst formatPageModule = (${n?"\n pagesComponent: Record<string, ComponentType<unknown>>,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${n?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${n?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${n?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${n?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${n?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${n?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${n?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${n?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${n?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${n?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${n?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${e}', '').replace('/index.config.${n?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${n?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${n?": Record<string, unknown>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${n?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${n?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${n?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst LazyComponent = ({\n Element\n}${n?": {\n Element: LazyExoticComponent<ComponentType<unknown>>\n}":""}) => {\n return (\n <Suspense>\n <Element />\n </Suspense>\n )\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent({\n ...import.meta.glob('/${e}/**/*.${n?"tsx":"jsx"}')${n?" as PagesComponentType":""}\n })\n\n const pagesString = getFileDefault({\n ...import.meta.glob('/${e}/**/*.${n?"tsx":"jsx"}', {\n eager: true\n })\n })${n?" as Record<string, ComponentType<unknown>>":""}\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${e}/**/*.config.${n?"ts":"js"}', {\n eager: true\n })\n })${n?" as Record<string, PageConfig>":""}\n\n const result${n?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesString, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n let Component${n?": MyRouteObject['element']":""}\n if (!cachedLazyComponents[compPath]) {\n cachedLazyComponents[compPath] = lazy(pagesComponent[compPath])\n }\n Component = <LazyComponent Element={cachedLazyComponents[compPath]} />\n\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: Component\n })\n }\n\n return result\n}`)(e,r):((e,n)=>`\nconst PATH_REPLACEMENTS${n?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst getConfigFileName = ${n?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${n?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${n?"ts":"js"}'\n }\n return pagePath.replace('index.${n?"ts":"js"}', 'index.config.${n?"ts":"js"}')\n}\n\nconst formatPageModule = (${n?"\n pagesComponent: PagesComponentType,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${n?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${n?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${n?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${n?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${n?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${n?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${n?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${n?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${n?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${n?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${n?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${e}', '').replace('/index.config.${n?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${n?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${n?": PagesComponentType | Record<string, PageConfig>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default${n?" as ComponentType<unknown> | PageConfig":""}\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${n?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${n?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${n?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent(\n getFileDefault({\n ...import.meta.glob('/${e}/**/*.${n?"tsx":"jsx"}', { eager: true })\n })${n?" as PagesComponentType":""}\n )\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${e}/**/*.config.${n?"ts":"js"}', {\n eager: true\n })\n })${n?" as Record<string, PageConfig>":""}\n\n const result${n?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesComponent, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n const Component = pagesComponent[compPath]\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: <Component />\n })\n }\n\n return result\n}`)(e,r),c=(e=>`\nconst processRoute = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} =>\n cleanIsRoot(removeEmptyChildren(route))\n\nconst processRoutes = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} =>\n buildRouteTree(routes).map(processRoute)\n\nconst handleRootRoute = ${e?"(routes: (MyRouteObject & { isRoot?: boolean })[])":"(routes)"} => {\n let rootRoute${e?": MyRouteObject | undefined":" = undefined"}\n let homeRoute${e?": MyRouteObject | undefined":" = undefined"}\n let notFoundRoute${e?": MyRouteObject | undefined":" = undefined"}\n const filteredRoutes${e?": MyRouteObject[]":""} = []\n\n for (const route of routes) {\n if (route.isRoot) {\n if (rootRoute)\n throw new Error('There cannot be multiple root routes in a route')\n rootRoute = route\n } else if (route.path === '/') {\n homeRoute = route\n } else if (route.path === '/*') {\n notFoundRoute = route\n } else {\n filteredRoutes.push(route)\n }\n }\n\n if (hasDuplicateProperty(filteredRoutes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n const children = [\n homeRoute && { ...homeRoute, index: true },\n ...processRoutes(filteredRoutes)\n ].filter(${e?"(route): route is NonNullable<typeof route> => Boolean(route)":"Boolean"})\n\n const result${e?": MyRouteObject[]":""} = []\n\n if (rootRoute) {\n result.push(cleanIsRoot({ ...rootRoute, children }))\n }\n\n if (notFoundRoute) {\n result.push(cleanIsRoot(notFoundRoute))\n }\n\n return result\n}\n\nconst formatRoutes = (\n routes${e?": (MyRouteObject & { isRoot?: boolean })[]":""}\n) => {\n if (routes.some(r => r.isRoot)) return handleRootRoute(routes)\n\n if (hasDuplicateProperty(routes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n return processRoutes(routes)\n}`)(r),u=(e=>`\nconst processSingleRoute = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n if (route.index) {\n return route\n }\n\n if (route.type !== 'wrap') {\n const { path: routePath, children, ...extraProps } = route\n const hasExtraProps = Object.keys(extraProps).length > 0\n\n if (hasExtraProps) {\n const indexRoute${e?": MyRouteObject":""} = {\n path: '',\n index: true,\n ...extraProps\n }\n\n return {\n path: routePath,\n children: [indexRoute, ...(children || []).map(processSingleRoute)]\n }\n }\n }\n\n if (route.children) {\n return {\n ...route,\n children: route.children.map(processSingleRoute)\n }\n }\n\n return route\n}\n\nconst formatRouteTree = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n return routes.map(processSingleRoute)\n}\n\nconst buildTreeStructure = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const routeMap = new Map${e?"<string, MyRouteObject>":""}()\n const rootRoutes${e?": MyRouteObject[]":""} = []\n const pathPartsCache = new Map${e?"<string, string[]>":""}()\n\n const getPathParts = ${e?"(pathStr: string): string[]":"(pathStr)"} => {\n let parts = pathPartsCache.get(pathStr)\n if (parts === undefined) {\n parts = pathStr === '/' ? [] : pathStr.split('/').filter(Boolean)\n pathPartsCache.set(pathStr, parts)\n }\n return parts\n }\n\n const sortedRoutes = routes\n .slice()\n .sort((a, b) => a.path.length - b.path.length)\n\n for (const route of sortedRoutes) {\n const routePath = route.path\n const pathParts = getPathParts(routePath)\n const currentRoute = { ...route, children: [] }\n routeMap.set(routePath, currentRoute)\n\n if (pathParts.length <= 1) {\n rootRoutes.push(currentRoute)\n continue\n }\n\n const parentPath = '/' + pathParts.slice(0, -1).join('/')\n const parentRoute = routeMap.get(parentPath)\n\n if (parentRoute) {\n currentRoute.path = pathParts[pathParts.length - 1]\n parentRoute.children${e?"!":""}.push(currentRoute)\n } else {\n rootRoutes.push(currentRoute)\n }\n }\n\n return rootRoutes\n}\n\nconst buildRouteTree = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const treeStructure = buildTreeStructure(routes)\n return formatRouteTree(treeStructure)\n}`)(r),p=(e=>`\nconst cleanIsRoot = ${e?"(route: RouteWithIsRoot): MyRouteObject":"(route)"} => {\n const { isRoot, type, children, ...rest } = route${e?" as RouteWithIsRoot & {\n type?: unknown\n }":""}\n\n if (!children?.length) {\n return rest\n }\n\n return {\n ...rest,\n children: children.map(cleanIsRoot)\n }\n}`)(r),l=(e=>`\nconst removeEmptyChildren = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n const { children } = route\n\n if (!children?.length) {\n const { children: _, ...rest } = route\n return rest\n }\n\n const processedChildren = children.map(removeEmptyChildren)\n\n if (route.type === 'wrap') {\n return { ...route, children: processedChildren }\n }\n\n const { path, element, type, children: _, ...rest } = route\n\n if (!element) {\n return { path, ...rest, children: processedChildren }\n }\n\n return {\n path,\n children: [\n { index: true, element, ...rest }${e?" as MyRouteObject":""},\n ...processedChildren\n ]\n }\n}`)(r),h=r?"// Auto-generated by ono-auto-router\nimport type { PageConfig } from './autoRouter'\nexport const defineConfig = (config: PageConfig) => config\n":"",f=(e=>`\nconst getRoutes = () => {\n const baseRoutes = createBaseRoutes()\n const formattedRoutes = formatRoutes(baseRoutes)${e?" as RouteObject[]":""}\n return formattedRoutes\n}\n\nexport const routes = getRoutes()`)(r),g=((e,n,t,o,r,s,a,i)=>`// Auto-generated by ono-auto-router${e}${n}${t}${o}${r}${s}${a}${i}\n`)(((e,n)=>e?`\n${n?"import {\n lazy,\n Suspense,\n type ComponentType,\n type LazyExoticComponent\n} from 'react'":"import type { ComponentType } from 'react'"}\nimport type { RouteObject } from 'react-router-dom'\n\n${n?"type PagesComponentType = Record<\n string,\n () => Promise<{ default: ComponentType<unknown> }>\n>":"type PagesComponentType = Record<string, ComponentType<unknown>>"}\n\ninterface MyRouteObject extends Omit<RouteObject, 'path' | 'children'> {\n path: string\n type?: 'single' | 'wrap'\n children?: MyRouteObject[]\n}\n\ntype RouteWithIsRoot = MyRouteObject & { isRoot?: boolean }\n\nexport type PageConfig = Partial<\n Omit<MyRouteObject, 'Component' | 'element' | 'children' | 'path'>\n>`:n?"\nimport { lazy, Suspense } from 'react'\n":"")(r,o),(e=>`\nconst hasDuplicateProperty = ${e?"<T, K extends keyof T>(items: T[], propName: K)":"(items, propName)"} => {\n const seenValues = new Set()\n return items.some(item => {\n if (seenValues.has(item[propName])) {\n return true\n }\n seenValues.add(item[propName])\n return false\n })\n}\n\nconst replaceBracketsWithColon = ${e?"(str: string)":"(str)"} => {\n return str.replace(/\\[([^\\]]+)\\]/g, ':$1').replace('.tsx', '')\n}`)(r),l,p,u,c,i,f);r?(ye(n.resolve(s,"./index.ts"),a),ye(n.resolve(s,"./autoRouter.tsx"),g),ye(n.resolve(s,"./defineConfig.ts"),h)):ye(t,g)},A={"/home":"/","/root":"/"},I=(e,n)=>{const t=e.split("/"),o=t[t.length-1];return n&&o.endsWith(n)?o.slice(0,-n.length):o},D=e=>{const n=A[e];return n||("/notfound"===e.toLowerCase()||"/404"===e?"/:pathMatch(.*)*":e)},K=(e,n)=>e.endsWith(".config."+(n?"ts":"js"))?"index"===I(e,".config."+(n?"ts":"js"))?e.replace("index.config."+(n?"ts":"js"),"index."+(n?"ts":"js")):e.slice(0,-10)+".vue":e.replace("index.config."+(n?"ts":"js"),"index."+(n?"ts":"js")),_=(e,n,t)=>{if(e.endsWith(".config."+(t?"ts":"js"))){const o=I(e,".config."+(t?"ts":"js")),r=(e=>{const n=e.split("/");return n.pop(),n.join("/")})(e).replace(n,"");return"index"===o?r||"/":r?`${r}/${o}`:`/${o}`}return e.replace(n,"").replace("/index.config."+(t?"ts":"js"),"")||"/"},H=async(e,n,t,o)=>{const r=[];for(const[s,a]of((e,n,t)=>Object.keys(e).map(e=>{const o=((e,n)=>e.replace("index."+(n?"ts":"js"),"index.config."+(n?"ts":"js")))(e,t);return[o,n[o]||{}]}))(e,n,o)){const n=K(s,o),i=me(_(s,`/${t}`,o)||"/",o,"vue"),c=D(i);r.push({...a,path:c,type:a?.type,isRoot:"/root"===i,component:e[n]})}return r},V=e=>{if(!e.path)return e;if("wrap"!==e.type){const{path:n,children:t,...o}=e;if(Object.keys(o).length>0)return{path:n,children:[{path:"",...o},...(t||[]).map(V)]}}return e.children?{...e,children:e.children.map(V)}:e},U=e=>(e=>e.map(V))((e=>{const n=/* @__PURE__ */new Map,t=[],o=/* @__PURE__ */new Map,r=e=>{let n=o.get(e);return void 0===n&&(n="/"===e?[]:e.split("/").filter(Boolean),o.set(e,n)),n},s=e.slice().sort((e,n)=>e.path.length-n.path.length);for(const a of s){const e=a.path,o=r(e),s={...a,children:[]};if(n.set(e,s),o.length<=1){t.push(s);continue}const i="/"+o.slice(0,-1).join("/"),c=n.get(i);c?(s.path=o[o.length-1],c.children.push(s)):t.push(s)}return t})(e)),J=e=>{const{isRoot:n,type:t,children:o,...r}=e;return o?.length?{...r,children:o.map(J)}:r},Z=e=>{const{children:n}=e;if(!n?.length){const{children:n,...t}=e;return t}const t=n.map(Z);if("wrap"===e.type)return{...e,children:t};const{path:o,component:r,type:s,children:a,...i}=e;return r?{path:o,children:[{path:"",component:r,...i},...t]}:{path:o,...i,children:t}},q=e=>J(Z(e)),G=e=>U(e).map(q),Q=e=>{if(e.some(e=>e.isRoot))return(e=>{let n,t,o;const r=[];for(const i of e)if(i.isRoot){if(n)throw new Error("There cannot be multiple root routes in a route");n=i}else"/"===i.path?t=i:"/:pathMatch(.*)*"===i.path?o=i:r.push(i);if(fe(r,"path"))throw new Error("There cannot be duplicate paths in a route");const s=[t&&{...t,index:!0},...G(r)].filter(e=>Boolean(e)),a=[];return n&&a.push(J({...n,children:s})),o&&a.push(J(o)),a})(e);if(fe(e,"path"))throw new Error("There cannot be duplicate paths in a route");return G(e)},X=(e,n)=>({import:`import ${e} from './${n}'`,component:`<start>${e}</end>`,lazyComponent:`<start>() => import('${n}')</end>`});var Y=(e,n,t,o,r,s,a)=>{const i=((e,n)=>e.replace("index.vue",n?$e:je))(pe(e,n),a),c=ue(ie(t,e)),u=se(R(c),s),p=`component(${c})`;o[`/${i}`]=p,r.set(p,{path:c,componentName:u})},ee=(e,n,t,o)=>{const r=pe(e,n);t[`/${r}`]=c(r,ae(e),o)};function ne(e,n,o,r,s,a,i,c,u){const p={},l=e.replace(/^\/+/,""),h=t.sync(l,{cwd:n,absolute:!0,onlyFiles:!0}),f="component"===s?((e,n)=>n.map(n=>n.includes("index.vue")||2===n.replace(e.replaceAll("\\","/"),"").split("/").length?n:void 0).filter(Boolean))(n,h):h.filter(he);for(const t of f)if("component"===s){if(t.includes(".config."))continue;Y(t,o,r,p,a,i,u)}else ee(t,o,p,c);return p}var te=async(e,n,t,o,r,s)=>{const a=/* @__PURE__ */new Map,i=/* @__PURE__ */new Set,c=/* @__PURE__ */new Map;ye(o,((e,n,t,o)=>{let r=e;for(const[s,a]of n){const e=X(a.componentName,a.path);r=r.replace(s,o?e.lazyComponent:e.component)}for(const[s,a]of t)r=r.replace(s,a);return de(r)})(function(e,n,t,o){return`// Auto-generated by ono-auto-router${t?"\nimport type { RouteRecordRaw } from 'vue-router'":""}${o?"":`\n${n.join("\n")}${t?"":"\n"}`}${t?"\n\ntype PageConfig = Partial<\n Omit<RouteRecordRaw, 'path' | 'component' | 'children'> & {\n type?: 'single' | 'wrap'\n }\n>\n":""}${t?"\nexport const defineConfig = (config: PageConfig) => config\n":""}\nexport const routes${t?": RouteRecordRaw[]":""} = ${JSON.stringify(e,null,2)}\n`}(Q(await H(ne("/**/*.vue",n,t,o,"component",a,i,c,s),ne("/**/*.config.{js,ts}",n,t,o,"config",a,i,c,s),e,s)),((e,n)=>{if(e)return[];const t=[];for(const o of n.values())t.push(X(o.componentName,o.path).import);return t})(r,a),s,r),a,c,r))},oe=(e,t,o,r)=>{const s=t.split(".")[0],a=(e=>`// Auto-generated by ono-auto-router${e?"\nexport { defineConfig } from './defineConfig'":""}\nexport { routes } from './autoRouter'\n`)(o),i=((e,n,t)=>`\nconst pathCache = new Map${n?"<string, { compPath: string; basePath: string }>":""}()\nconst basenameCache = new Map${n?"<string, string>":""}()\n\nconst normalizePagePath = ${n?"(key: string): string":"(key)"} => {\n if (key.includes('index.vue')) return key.replace('index.vue', 'index.${n?"ts":"js"}')\n if (key.includes('root.vue')) return key.replace('root.vue', 'root/index.${n?"ts":"js"}')\n if (key.includes('404.vue')) return key.replace('404.vue', '404/index.${n?"ts":"js"}')\n if (key.toLowerCase().includes('notfound.vue'))\n return key.toLowerCase().replace('notfound.vue', 'notfound/index.${n?"ts":"js"}')\n return key\n}\n\nconst getBasename = ${n?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const cacheKey = ext ? filePath + ':' + ext : filePath\n if (basenameCache.has(cacheKey)) {\n return basenameCache.get(cacheKey)${n?"!":""}\n }\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1] || ''\n let result = lastPart\n if (ext && lastPart.endsWith(ext)) {\n result = lastPart.slice(0, -ext.length)\n }\n basenameCache.set(cacheKey, result)\n return result\n}\n\nconst getDirname = ${n?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getPathsFromConfig = ${n?"(configPath: string)":"(configPath)"} => {\n const cacheKey = configPath\n if (pathCache.has(cacheKey)) {\n return pathCache.get(cacheKey)${n?"!":""}\n }\n\n let compPath${n?": string":" = ''"}\n let basePath${n?": string":" = ''"}\n\n if (configPath.endsWith('.config.${n?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${n?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n\n if (fileName === 'index') {\n compPath = configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"ts":"js"}')\n basePath = dirPath || '/'\n } else {\n compPath = configPath.slice(0, -10) + '.vue'\n basePath = dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n } else {\n compPath = configPath.replace('index.config.${n?"ts":"js"}', 'index.${n?"ts":"js"}')\n basePath =\n configPath.replace('/${e}', '').replace('/index.config.${n?"ts":"js"}', '') ||\n '/'\n }\n\n const result = { compPath, basePath }\n pathCache.set(cacheKey, result)\n return result\n}\n\nconst formatPath = ${n?"(path: string): string":"(path)"} => {\n const lowerPath = path.toLowerCase()\n if (lowerPath === '/home') return '/'\n if (lowerPath === '/notfound' || path === '/404') return '/:pathMatch(.*)*'\n return path.replace('/index.${n?"ts":"js"}', '') || '/'\n}\n\nconst getConfigFileName = ${n?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.vue')) {\n return pagePath.slice(0, -4) + '.config.${n?"ts":"js"}'\n }\n return pagePath.replace('index.${n?"ts":"js"}', 'index.config.${n?"ts":"js"}')\n}\n\nconst createBaseRoutes = ()${n?": MyRouteObject[]":""} => {\n const pagesComponent = Object.fromEntries(\n Object.entries({\n ...import.meta.glob('/${e}/**/index.vue'${t?"":", { eager: true, import: 'default' }"}),\n ...import.meta.glob('/${e}/*.vue'${t?"":", { eager: true, import: 'default' }"})\n }${n?" as PagesComponentType":""}).map(([key, value]) => [\n normalizePagePath(key),\n value\n ])\n )\n\n const pagesModule${n?": Record<string, PageConfig>":""} = import.meta.glob(\n '/${e}/**/*.config.${n?"ts":"js"}',\n { eager: true, import: 'default' }\n )\n\n const result${n?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const pagePath of Object.keys(pagesComponent)) {\n const configPath = getConfigFileName(pagePath)\n const content = pagesModule[configPath] || {}\n const { compPath, basePath } = getPathsFromConfig(configPath)\n const path = replaceBracketsWithColon(basePath || '/')\n const name = path.split('/').filter(Boolean).join('-') || 'index'\n\n result.push({\n path: formatPath(path),\n name,\n component: pagesComponent[compPath],\n isRoot: path === '/root',\n ...content${n?"!":""}\n })\n }\n\n return result\n}\n\nconst processRoutes = ${n?"(\n routes: MyRouteObject[],\n removeLeadingSlash = false\n): MyRouteObject[]":"(routes, removeLeadingSlash)"} =>\n buildRouteTree(routes, removeLeadingSlash)\n .map(removeEmptyChildren)\n .map(cleanIsRoot)\n\nconst handleRootRoute = ${n?"(\n routes: (MyRouteObject & { isRoot?: boolean })[]\n): MyRouteObject[]":"(routes)"} => {\n let rootRoute${n?": (MyRouteObject & { isRoot?: boolean }) | undefined":" = undefined"}\n let homeRoute${n?": MyRouteObject | undefined":" = undefined"}\n let notFoundRoute${n?": MyRouteObject | undefined":" = undefined"}\n const filteredRoutes${n?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const route of routes) {\n if (route.isRoot) {\n if (rootRoute)\n throw new Error('There cannot be multiple root routes in a route')\n rootRoute = route\n } else if (route.path === '/') {\n homeRoute = route\n } else if (route.path === '/:pathMatch(.*)*') {\n notFoundRoute = route\n } else {\n filteredRoutes.push(route)\n }\n }\n\n if (hasDuplicateProperty(filteredRoutes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n const processedRoutes${n?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n if (rootRoute) {\n const children = [\n homeRoute && { ...homeRoute, path: '' },\n ...processRoutes(filteredRoutes, true)\n ].filter(Boolean)${n?" as MyRouteObject[]":""}\n processedRoutes.push({ ...rootRoute, path: '/', children })\n }\n\n if (notFoundRoute) processedRoutes.push(notFoundRoute)\n\n return processedRoutes.map(cleanIsRoot)\n}\n\nconst createRoutes = ()${n?": RouteRecordRaw[]":""} => {\n const routes = createBaseRoutes()\n\n if (routes.some((r${n?": MyRouteObject & { isRoot?: boolean }":""}) => r.isRoot))\n return handleRootRoute(routes)${n?" as RouteRecordRaw[]":""}\n\n if (hasDuplicateProperty(routes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n return processRoutes(routes)${n?" as RouteRecordRaw[]":""}\n}\n`)(e,o,r),c=(e=>`\nconst buildRouteTree = ${e?"(\n routes: MyRouteObject[],\n removeLeadingSlash: boolean = false\n)":"(routes, removeLeadingSlash)"} => {\n const routeMap = new Map${e?"<string, MyRouteObject & { isRoot?: boolean }>":""}()\n const rootRoutes${e?": MyRouteObject[]":""} = []\n\n const sortedRoutes = [...routes].sort((a, b) => a.path.length - b.path.length)\n\n for (const route of sortedRoutes) {\n let path = route.path\n if (removeLeadingSlash && path.startsWith('/')) {\n path = path.slice(1)\n }\n routeMap.set(path, { ...route, path, children: [] })\n }\n\n for (const [path, route] of routeMap) {\n const slashIndex = path.lastIndexOf('/')\n\n if (slashIndex <= 0) {\n const { isRoot, ...rest } = route\n rootRoutes.push(rest)\n continue\n }\n\n const parentPath = path.slice(0, slashIndex)\n const parentRoute = routeMap.get(parentPath)\n\n if (parentRoute) {\n const relativePath = path.slice(slashIndex + 1)\n const childRoute = { ...route, path: relativePath }\n parentRoute.children${e?"!":""}.push(childRoute)\n } else {\n const { isRoot, ...rest } = route\n rootRoutes.push(rest)\n }\n }\n\n return rootRoutes\n}\n`)(o),u=(e=>`\nconst cleanIsRoot = ${e?"(\n route: MyRouteObject & { isRoot?: boolean }\n): MyRouteObject":"(route)"} => {\n const { isRoot, type, children, ...rest } = route\n const result${e?": MyRouteObject":""} = { ...rest }\n\n if (children?.length) {\n result.children = children.map(cleanIsRoot)\n }\n\n return result\n}\n`)(o),p=(e=>`\nconst removeEmptyChildren = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n if (!route.children?.length) {\n const { children, ...rest } = route\n return rest\n }\n\n const hasIndexRoute = route.children.some(\n child => child.path === '' || child.path === '/'\n )\n\n const routeType = route.type || 'single'\n\n if (routeType === 'wrap') {\n const { children, ...rest } = route\n return { ...rest, children: children.map(removeEmptyChildren) }\n }\n\n if (routeType === 'single' || (!hasIndexRoute && route.component)) {\n const { path, component, type, ...rest } = route\n return {\n path,\n children: [\n { path: '', component, ...rest }${e?" as MyRouteObject":""},\n ...route.children.map(removeEmptyChildren)\n ]\n }\n }\n\n if (hasIndexRoute) {\n const { path, ...rest } = route\n const updatedChildren = route.children.map(child =>\n child.path === '' || child.path === '/' ? { ...rest, ...child } : child\n )\n return { path, children: updatedChildren.map(removeEmptyChildren) }\n }\n\n return { ...route, children: route.children.map(removeEmptyChildren) }\n}\n`)(o),l=o?"// Auto-generated by ono-auto-router\nimport type { PageConfig } from './autoRouter'\nexport const defineConfig = (config: PageConfig) => config\n":"",h=((e,n,t,o,r,s,a)=>`// Auto-generated by ono-auto-router${e}${n}${t}${o}${r}${s}${a}\n`)(o?"\nimport type { RouteRecordRaw } from 'vue-router'\n\ntype PagesComponentType = Record<string, () => Promise<unknown>>\n\ninterface MyRouteObject extends Omit<RouteRecordRaw, 'children'> {\n type?: 'single' | 'wrap'\n children?: MyRouteObject[]\n}\n\nexport type PageConfig = Partial<\n Omit<MyRouteObject, 'component' | 'children' | 'path'>\n>\n":"",(e=>`\nconst hasDuplicateProperty = ${e?"<T>(items: T[], propName: keyof T)":"(items, propName)"} => {\n const seenValues = new Set()\n return items.some(item => {\n if (seenValues.has(item[propName])) {\n return true\n }\n seenValues.add(item[propName])\n return false\n })\n}\n\nconst replaceBracketsWithColon = ${e?"(str: string)":"(str)"} => {\n return str.replace(/\\[([^\\]]+)\\]/g, ':$1').replace('.tsx', '')\n}\n`)(o),p,u,c,i,"\nexport const routes = createRoutes()");o?(ye(n.resolve(s,"./index.ts"),a),ye(n.resolve(s,"./autoRouter.ts"),h),ye(n.resolve(s,"./defineConfig.ts"),l)):ye(t,h)},re=(t,o,r,s,c,u)=>{const l=n.resolve(r,o);if(!e.existsSync(l))throw new Error(`Pages directory not found: ${l}`);const f=h(t,r,s),g=p(r),d=f.split(".")[0];a(d+".js"),a(d+".ts"),a(d+".jsx"),a(d+".tsx"),i(d),"react"===t?u?z(o,f,c,g):B(o,l,r,f,c,g):u?oe(o,f,g,c):te(o,l,r,f,c,g),console.log(`[ono-auto-router] Routes file generated: ${f}`)},se=(e,n)=>{if(!n.has(e))return n.add(e),e;let t=1;for(;n.has(`${e}_${t}`);)t++;return`${e}_${t}`};function ae(n){try{const o=e.readFileSync(n,"utf-8").match(/export\s+default\s+([\s\S]*?)(?=\n\w|$)/);if(!o)return console.warn("No export default found in:",n),null;const r=o[1].trim();try{if(r.startsWith("{"))return new Function(`return ${r}`)();if(r.includes("defineConfig(")){const e=r.match(/defineConfig([\s\S]*)$/);if(e)return new Function(`return ${e[1]}`)()}return null}catch(t){return console.error("Error parsing export default content:",t),null}}catch(o){return console.error("Error reading file:",o),null}}function ie(e,t){let o=n.resolve(e);(o.endsWith(".js")||o.endsWith(".jsx")||o.endsWith(".ts")||o.endsWith(".tsx")||o.endsWith(".vue"))&&(o=n.dirname(o));const r=n.resolve(t);return n.relative(o,r)}var ce=/\\/g,ue=e=>e.replace(ce,"/"),pe=(e,t)=>ue(n.relative(t,e)),le=/export\s+default\s+[\w(\[\]\{\})]+/;function he(n){try{if(!e.existsSync(n))return console.warn(`File not found: ${n}`),!1;const t=e.readFileSync(n,"utf-8");return le.test(t)}catch(t){return console.error("Read error:",t),!1}}var fe=(e,n)=>{const t=/* @__PURE__ */new Set;return e.some(e=>!!t.has(e[n])||(t.add(e[n]),!1))};function ge(e){return e.replace(/"<start>([\s\S]*?)<\/end>"/g,"$1")}function de(e){let n=e;for(;;){const e=ge(n);if(e===n)break;n=e}return n}var me=(e,n,t)=>e.replace(/\[([^\]]+)\]/g,":$1").replace("react"===t?n?".tsx":".jsx":".vue","");function Re(n){e.existsSync(n)||e.mkdirSync(n,{recursive:!0})}function Pe(t,o){Re(n.dirname(t)),e.writeFileSync(t,o,"utf-8")}async function ye(t,o){const r=n.dirname(t);await e.promises.mkdir(r,{recursive:!0}),await e.promises.writeFile(t,o,"utf-8")}var $e="index.ts",je="index.js";export{p as C,a as D,i as E,o as O,h as S,c as T,te as _,Pe as a,m as b,fe as c,ue as d,ie as f,oe as g,re as h,ye as i,he as l,se as m,$e as n,me as o,ae as p,Re as r,de as s,je as t,pe as u,z as v,u as w,R as x,B as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(a,i,c)=>(c=null!=a?e(r(a)):{},((e,r,a,i)=>{if(r&&"object"==typeof r||"function"==typeof r)for(var c,u=o(r),p=0,l=u.length;p<l;p++)c=u[p],s.call(e,c)||c===a||t(e,c,{get:(e=>r[e]).bind(null,c),enumerable:!(i=n(r,c))||i.enumerable});return e})(!i&&a&&a.__esModule?c:t(c,"default",{value:a,enumerable:!0}),a));let i=require("node:fs");i=a(i);let c=require("node:path");c=a(c);let u=require("fast-glob");function p(e){let t=l(e,0),n=!1;if(t+5<=e.length&&"async"===e.slice(t,t+5).toLowerCase()&&(n=!0,t=l(e,t+5)),t<e.length&&"("===e[t]){const n=h(e,t);if(-1!==n){let t=l(e,n+1);if(t+1<e.length&&"="===e[t]&&">"===e[t+1])return e}}const o=e.indexOf("(");if(-1===o)return e;const r=h(e,o);if(-1===r)return e;return(n?"async ":"")+e.slice(o,r+1)+" => "+e.slice(r+1)}function l(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function h(e,t){let n=0,o=!1,r="";for(let s=t;s<e.length;s++){const t=e[s];if('"'!==t&&"'"!==t&&"`"!==t){if(!o)if("("===t)n++;else if(")"===t&&(n--,0===n))return s}else o?t===r&&(o=!1):(o=!0,r=t)}return-1}u=a(u);var f=e=>{try{if(!i.default.existsSync(e))return;i.default.unlinkSync(e)}catch(t){console.error("删除文件失败:",t)}},d=e=>{try{if(!i.default.existsSync(e))return;i.default.rmSync(e,{recursive:!0})}catch(t){console.error("删除目录失败:",t)}},g=(e,t,n)=>{const o={};for(const[r,s]of Object.entries(t))if("function"==typeof s){const t=`${e}-${r}`;o[r]=t,n.set(t,`<start>${p(s.toString())}</end>`)}else o[r]=s;return o},m=e=>e.startsWith("/")?e.slice(1):e.endsWith("/")?e.slice(0,-1):e.startsWith("./")?e.slice(2):e,P=e=>i.default.existsSync(c.default.resolve(e,"tsconfig.json")),R={react:{ts:"src/router/autoRouter.tsx",js:"src/router/autoRouter.jsx"},vue:{ts:"src/router/autoRouter.ts",js:"src/router/autoRouter.js"}},y=(e,t,n)=>{let o=n;return o||(o=c.default.resolve(t,R[e][P(t)?"ts":"js"])),o},$=/[/\\]/,j=/[^a-zA-Z0-9]/g,b=/^(\d)/,x=e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"";function C(e){const t=c.default.extname(e),n=c.default.basename(e,t),o=c.default.dirname(e).split($).filter(Boolean);return"index"!==n&&"Index"!==n&&o.push(n),o.map(e=>(e=>e.replace(j,"_").replace(b,"_$1"))(e).split("_").map(x).join("")).join("")||"Component"}var O={"/home":"/","/root":"/"},w=(e,t)=>{const n=e.split("/"),o=n[n.length-1];return t&&o.endsWith(t)?o.slice(0,-t.length):o},M=e=>{const t=O[e];return t||("/notfound"===e.toLowerCase()||"/404"===e?"/*":e)},v=(e,t)=>e.endsWith(".config."+(t?"ts":"js"))?"index"===w(e,".config."+(t?"ts":"js"))?e.replace("index.config."+(t?"ts":"js"),"index."+(t?"ts":"js")):e.slice(0,-10)+"."+(t?"tsx":"jsx"):e.replace("index.config."+(t?"ts":"js"),"index."+(t?"ts":"js")),S=(e,t,n)=>{if(e.endsWith(".config."+(n?"ts":"js"))){const o=w(e,".config."+(n?"ts":"js")),r=(e=>{const t=e.split("/");return t.pop(),t.join("/")})(e).replace(t,"");return"index"===o?r||"/":r?`${r}/${o}`:`/${o}`}return e.replace(t,"").replace("/index.config."+(n?"ts":"js"),"")||"/"},T=async(e,t,n,o)=>{const r=[];for(const[s,a]of((e,t,n)=>Object.keys(e).map(e=>{const o=((e,t)=>e.endsWith(t?".tsx":".jsx")?e.slice(0,-4)+".config."+(t?"ts":"js"):e.replace("index."+(t?"ts":"js"),"index.config."+(t?"ts":"js")))(e,n);return[o,t[o]||{}]}))(e,t,o)){const t=v(s,o);if(!e[t])continue;const i=xe(S(s,`/${n}`,o)||"/",o,"react"),c=M(i);r.push({...a,path:c,type:a?.type,isRoot:"/root"===i,element:e[t]})}return r},E=e=>{if(e.index)return e;if("wrap"!==e.type){const{path:t,children:n,...o}=e;if(Object.keys(o).length>0)return{path:t,children:[{path:"",index:!0,...o},...(n||[]).map(E)]}}return e.children?{...e,children:e.children.map(E)}:e},k=e=>(e=>e.map(E))((e=>{const t=new Map,n=[],o=new Map,r=e=>{let t=o.get(e);return void 0===t&&(t="/"===e?[]:e.split("/").filter(Boolean),o.set(e,t)),t},s=e.slice().sort((e,t)=>e.path.length-t.path.length);for(const a of s){const e=a.path,o=r(e),s={...a,children:[]};if(t.set(e,s),o.length<=1){n.push(s);continue}const i="/"+o.slice(0,-1).join("/"),c=t.get(i);c?(s.path=o[o.length-1],c.children.push(s)):n.push(s)}return n})(e)),N=e=>{const{isRoot:t,type:n,children:o,...r}=e;return o?.length?{...r,children:o.map(N)}:r},F=e=>{const{children:t}=e;if(!t?.length){const{children:t,...n}=e;return n}const n=t.map(F);if("wrap"===e.type)return{...e,children:n};const{path:o,element:r,type:s,children:a,...i}=e;return r?{path:o,children:[{index:!0,element:r,...i},...n]}:{path:o,...i,children:n}},W=e=>N(F(e)),B=e=>k(e).map(W),L=e=>{if(e.some(e=>e.isRoot))return(e=>{let t,n,o;const r=[];for(const i of e)if(i.isRoot){if(t)throw new Error("There cannot be multiple root routes in a route");t=i}else"/"===i.path?n=i:"/*"===i.path?o=i:r.push(i);if($e(r,"path"))throw new Error("There cannot be duplicate paths in a route");const s=[n&&{...n,index:!0},...B(r)].filter(e=>Boolean(e)),a=[];return t&&a.push(N({...t,children:s})),o&&a.push(N(o)),a})(e);if($e(e,"path"))throw new Error("There cannot be duplicate paths in a route");return B(e)},z=(e,t)=>({import:`import ${e} from './${t}'`,component:`<start><${e} /></end>`,lazy:`const ${e} = lazy(() => import('${t}'))`,lazyComponent:`<start><Suspense><${e} /></Suspense></end>`});var D="index.tsx",A="index.jsx",I=(e,t,n,o,r,s,a)=>{const i=((e,t)=>e.includes(t?D:A)?e.replace(t?D:A,t?Me:ve):e)(Pe(e,t),a),c=me(de(n,e)),u=he(C(c),s),p=`element(${c})`;o[`/${i}`]=p,r.set(p,{path:c,componentName:u})},_=(e,t,n,o)=>{const r=Pe(e,t);n[`/${r}`]=g(r,fe(e),o)};function K(e,t,n,o,r,s,a,i,c){const p={},l=e.replace(/^\/+/,""),h=u.default.sync(l,{cwd:t,absolute:!0,onlyFiles:!0}).filter(ye);for(const u of h)if("component"===r){if(u.includes(".config."))continue;I(u,n,o,p,s,a,c)}else _(u,n,p,i);return p}var H=async(e,t,n,o,r,s)=>{const a=new Map,i=new Set,c=new Map;we(o,((e,t,n,o)=>{let r=e;for(const[s,a]of t){const e=z(a.componentName,a.path);r=r.replace(s,o?e.lazyComponent:e.component)}for(const[s,a]of n)r=r.replace(s,a);return be(r)})(function(e,t,n,o){const r=n.length>0?`\n${n.join("\n")}\n`:"";return`// Auto-generated by ono-auto-router\n${o?"import type { RouteObject } from 'react-router-dom'\n":""}${t.join("\n")}${o?"\n\ntype PageConfig = Partial<\n Omit<RouteObject, 'path' | 'Component' | 'element' | 'children'> & {\n type?: 'single' | 'wrap'\n }\n>\n":""}${o?"\nexport const defineConfig = (config: PageConfig) => config":""}\n${r}\nexport const routes${o?": RouteObject[]":""} = ${JSON.stringify(e,null,2)}\n`}(L(await T(K("/**/*.{jsx,tsx}",t,n,o,"component",a,i,c,s),K("/**/*.config.{js,ts,jsx,tsx}",t,n,o,"config",a,i,c,s),e,s)),((e,t)=>{if(e)return["import { lazy, Suspense } from 'react'"];const n=[];for(const o of t.values())n.push(z(o.componentName,o.path).import);return n})(r,a),((e,t)=>{if(!e)return[];const n=[];for(const o of t.values())n.push(z(o.componentName,o.path).lazy);return n})(r,a),s),a,c,r))},U=(e,t,n,o)=>{const r=t.split(".")[0],s=(e=>`// Auto-generated by ono-auto-router${e?"\nexport { defineConfig } from './defineConfig'":""}\nexport { routes } from './autoRouter'\n`)(o),a=n?((e,t)=>`\nconst PATH_REPLACEMENTS${t?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst cachedLazyComponents${t?": Record<\n string,\n LazyExoticComponent<ComponentType<unknown>>\n>":""} = {}\n\nconst getConfigFileName = ${t?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${t?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${t?"ts":"js"}'\n }\n return pagePath.replace('index.${t?"ts":"js"}', 'index.config.${t?"ts":"js"}')\n}\n\nconst formatPageModule = (${t?"\n pagesComponent: Record<string, ComponentType<unknown>>,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${t?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${t?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${t?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${t?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${t?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${t?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${t?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${t?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${t?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${t?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${t?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${e}', '').replace('/index.config.${t?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${t?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${t?": Record<string, unknown>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${t?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${t?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${t?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst LazyComponent = ({\n Element\n}${t?": {\n Element: LazyExoticComponent<ComponentType<unknown>>\n}":""}) => {\n return (\n <Suspense>\n <Element />\n </Suspense>\n )\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent({\n ...import.meta.glob('/${e}/**/*.${t?"tsx":"jsx"}')${t?" as PagesComponentType":""}\n })\n\n const pagesString = getFileDefault({\n ...import.meta.glob('/${e}/**/*.${t?"tsx":"jsx"}', {\n eager: true\n })\n })${t?" as Record<string, ComponentType<unknown>>":""}\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${e}/**/*.config.${t?"ts":"js"}', {\n eager: true\n })\n })${t?" as Record<string, PageConfig>":""}\n\n const result${t?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesString, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n let Component${t?": MyRouteObject['element']":""}\n if (!cachedLazyComponents[compPath]) {\n cachedLazyComponents[compPath] = lazy(pagesComponent[compPath])\n }\n Component = <LazyComponent Element={cachedLazyComponents[compPath]} />\n\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: Component\n })\n }\n\n return result\n}`)(e,o):((e,t)=>`\nconst PATH_REPLACEMENTS${t?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst getConfigFileName = ${t?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${t?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${t?"ts":"js"}'\n }\n return pagePath.replace('index.${t?"ts":"js"}', 'index.config.${t?"ts":"js"}')\n}\n\nconst formatPageModule = (${t?"\n pagesComponent: PagesComponentType,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${t?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${t?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${t?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${t?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${t?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${t?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${t?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${t?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${t?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${t?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${t?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${e}', '').replace('/index.config.${t?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${t?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${t?": PagesComponentType | Record<string, PageConfig>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default${t?" as ComponentType<unknown> | PageConfig":""}\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${t?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${t?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${t?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent(\n getFileDefault({\n ...import.meta.glob('/${e}/**/*.${t?"tsx":"jsx"}', { eager: true })\n })${t?" as PagesComponentType":""}\n )\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${e}/**/*.config.${t?"ts":"js"}', {\n eager: true\n })\n })${t?" as Record<string, PageConfig>":""}\n\n const result${t?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesComponent, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n const Component = pagesComponent[compPath]\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: <Component />\n })\n }\n\n return result\n}`)(e,o),i=(e=>`\nconst processRoute = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} =>\n cleanIsRoot(removeEmptyChildren(route))\n\nconst processRoutes = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} =>\n buildRouteTree(routes).map(processRoute)\n\nconst handleRootRoute = ${e?"(routes: (MyRouteObject & { isRoot?: boolean })[])":"(routes)"} => {\n let rootRoute${e?": MyRouteObject | undefined":" = undefined"}\n let homeRoute${e?": MyRouteObject | undefined":" = undefined"}\n let notFoundRoute${e?": MyRouteObject | undefined":" = undefined"}\n const filteredRoutes${e?": MyRouteObject[]":""} = []\n\n for (const route of routes) {\n if (route.isRoot) {\n if (rootRoute)\n throw new Error('There cannot be multiple root routes in a route')\n rootRoute = route\n } else if (route.path === '/') {\n homeRoute = route\n } else if (route.path === '/*') {\n notFoundRoute = route\n } else {\n filteredRoutes.push(route)\n }\n }\n\n if (hasDuplicateProperty(filteredRoutes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n const children = [\n homeRoute && { ...homeRoute, index: true },\n ...processRoutes(filteredRoutes)\n ].filter(${e?"(route): route is NonNullable<typeof route> => Boolean(route)":"Boolean"})\n\n const result${e?": MyRouteObject[]":""} = []\n\n if (rootRoute) {\n result.push(cleanIsRoot({ ...rootRoute, children }))\n }\n\n if (notFoundRoute) {\n result.push(cleanIsRoot(notFoundRoute))\n }\n\n return result\n}\n\nconst formatRoutes = (\n routes${e?": (MyRouteObject & { isRoot?: boolean })[]":""}\n) => {\n if (routes.some(r => r.isRoot)) return handleRootRoute(routes)\n\n if (hasDuplicateProperty(routes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n return processRoutes(routes)\n}`)(o),u=(e=>`\nconst processSingleRoute = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n if (route.index) {\n return route\n }\n\n if (route.type !== 'wrap') {\n const { path: routePath, children, ...extraProps } = route\n const hasExtraProps = Object.keys(extraProps).length > 0\n\n if (hasExtraProps) {\n const indexRoute${e?": MyRouteObject":""} = {\n path: '',\n index: true,\n ...extraProps\n }\n\n return {\n path: routePath,\n children: [indexRoute, ...(children || []).map(processSingleRoute)]\n }\n }\n }\n\n if (route.children) {\n return {\n ...route,\n children: route.children.map(processSingleRoute)\n }\n }\n\n return route\n}\n\nconst formatRouteTree = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n return routes.map(processSingleRoute)\n}\n\nconst buildTreeStructure = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const routeMap = new Map${e?"<string, MyRouteObject>":""}()\n const rootRoutes${e?": MyRouteObject[]":""} = []\n const pathPartsCache = new Map${e?"<string, string[]>":""}()\n\n const getPathParts = ${e?"(pathStr: string): string[]":"(pathStr)"} => {\n let parts = pathPartsCache.get(pathStr)\n if (parts === undefined) {\n parts = pathStr === '/' ? [] : pathStr.split('/').filter(Boolean)\n pathPartsCache.set(pathStr, parts)\n }\n return parts\n }\n\n const sortedRoutes = routes\n .slice()\n .sort((a, b) => a.path.length - b.path.length)\n\n for (const route of sortedRoutes) {\n const routePath = route.path\n const pathParts = getPathParts(routePath)\n const currentRoute = { ...route, children: [] }\n routeMap.set(routePath, currentRoute)\n\n if (pathParts.length <= 1) {\n rootRoutes.push(currentRoute)\n continue\n }\n\n const parentPath = '/' + pathParts.slice(0, -1).join('/')\n const parentRoute = routeMap.get(parentPath)\n\n if (parentRoute) {\n currentRoute.path = pathParts[pathParts.length - 1]\n parentRoute.children${e?"!":""}.push(currentRoute)\n } else {\n rootRoutes.push(currentRoute)\n }\n }\n\n return rootRoutes\n}\n\nconst buildRouteTree = ${e?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const treeStructure = buildTreeStructure(routes)\n return formatRouteTree(treeStructure)\n}`)(o),p=(e=>`\nconst cleanIsRoot = ${e?"(route: RouteWithIsRoot): MyRouteObject":"(route)"} => {\n const { isRoot, type, children, ...rest } = route${e?" as RouteWithIsRoot & {\n type?: unknown\n }":""}\n\n if (!children?.length) {\n return rest\n }\n\n return {\n ...rest,\n children: children.map(cleanIsRoot)\n }\n}`)(o),l=(e=>`\nconst removeEmptyChildren = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n const { children } = route\n\n if (!children?.length) {\n const { children: _, ...rest } = route\n return rest\n }\n\n const processedChildren = children.map(removeEmptyChildren)\n\n if (route.type === 'wrap') {\n return { ...route, children: processedChildren }\n }\n\n const { path, element, type, children: _, ...rest } = route\n\n if (!element) {\n return { path, ...rest, children: processedChildren }\n }\n\n return {\n path,\n children: [\n { index: true, element, ...rest }${e?" as MyRouteObject":""},\n ...processedChildren\n ]\n }\n}`)(o),h=o?"// Auto-generated by ono-auto-router\nimport type { PageConfig } from './autoRouter'\nexport const defineConfig = (config: PageConfig) => config\n":"",f=(e=>`\nconst getRoutes = () => {\n const baseRoutes = createBaseRoutes()\n const formattedRoutes = formatRoutes(baseRoutes)${e?" as RouteObject[]":""}\n return formattedRoutes\n}\n\nexport const routes = getRoutes()`)(o),d=((e,t,n,o,r,s,a,i)=>`// Auto-generated by ono-auto-router${e}${t}${n}${o}${r}${s}${a}${i}\n`)(((e,t)=>e?`\n${t?"import {\n lazy,\n Suspense,\n type ComponentType,\n type LazyExoticComponent\n} from 'react'":"import type { ComponentType } from 'react'"}\nimport type { RouteObject } from 'react-router-dom'\n\n${t?"type PagesComponentType = Record<\n string,\n () => Promise<{ default: ComponentType<unknown> }>\n>":"type PagesComponentType = Record<string, ComponentType<unknown>>"}\n\ninterface MyRouteObject extends Omit<RouteObject, 'path' | 'children'> {\n path: string\n type?: 'single' | 'wrap'\n children?: MyRouteObject[]\n}\n\ntype RouteWithIsRoot = MyRouteObject & { isRoot?: boolean }\n\nexport type PageConfig = Partial<\n Omit<MyRouteObject, 'Component' | 'element' | 'children' | 'path'>\n>`:t?"\nimport { lazy, Suspense } from 'react'\n":"")(o,n),(e=>`\nconst hasDuplicateProperty = ${e?"<T, K extends keyof T>(items: T[], propName: K)":"(items, propName)"} => {\n const seenValues = new Set()\n return items.some(item => {\n if (seenValues.has(item[propName])) {\n return true\n }\n seenValues.add(item[propName])\n return false\n })\n}\n\nconst replaceBracketsWithColon = ${e?"(str: string)":"(str)"} => {\n return str.replace(/\\[([^\\]]+)\\]/g, ':$1').replace('.tsx', '')\n}`)(o),l,p,u,i,a,f);o?(we(c.default.resolve(r,"./index.ts"),s),we(c.default.resolve(r,"./autoRouter.tsx"),d),we(c.default.resolve(r,"./defineConfig.ts"),h)):we(t,d)},V={"/home":"/","/root":"/"},X=(e,t)=>{const n=e.split("/"),o=n[n.length-1];return t&&o.endsWith(t)?o.slice(0,-t.length):o},q=e=>{const t=V[e];return t||("/notfound"===e.toLowerCase()||"/404"===e?"/:pathMatch(.*)*":e)},J=(e,t)=>e.endsWith(".config."+(t?"ts":"js"))?"index"===X(e,".config."+(t?"ts":"js"))?e.replace("index.config."+(t?"ts":"js"),"index."+(t?"ts":"js")):e.slice(0,-10)+".vue":e.replace("index.config."+(t?"ts":"js"),"index."+(t?"ts":"js")),Z=(e,t,n)=>{if(e.endsWith(".config."+(n?"ts":"js"))){const o=X(e,".config."+(n?"ts":"js")),r=(e=>{const t=e.split("/");return t.pop(),t.join("/")})(e).replace(t,"");return"index"===o?r||"/":r?`${r}/${o}`:`/${o}`}return e.replace(t,"").replace("/index.config."+(n?"ts":"js"),"")||"/"},G=async(e,t,n,o)=>{const r=[];for(const[s,a]of((e,t,n)=>Object.keys(e).map(e=>{const o=((e,t)=>e.replace("index."+(t?"ts":"js"),"index.config."+(t?"ts":"js")))(e,n);return[o,t[o]||{}]}))(e,t,o)){const t=J(s,o),i=xe(Z(s,`/${n}`,o)||"/",o,"vue"),c=q(i);r.push({...a,path:c,type:a?.type,isRoot:"/root"===i,component:e[t]})}return r},Q=e=>{if(!e.path)return e;if("wrap"!==e.type){const{path:t,children:n,...o}=e;if(Object.keys(o).length>0)return{path:t,children:[{path:"",...o},...(n||[]).map(Q)]}}return e.children?{...e,children:e.children.map(Q)}:e},Y=e=>(e=>e.map(Q))((e=>{const t=new Map,n=[],o=new Map,r=e=>{let t=o.get(e);return void 0===t&&(t="/"===e?[]:e.split("/").filter(Boolean),o.set(e,t)),t},s=e.slice().sort((e,t)=>e.path.length-t.path.length);for(const a of s){const e=a.path,o=r(e),s={...a,children:[]};if(t.set(e,s),o.length<=1){n.push(s);continue}const i="/"+o.slice(0,-1).join("/"),c=t.get(i);c?(s.path=o[o.length-1],c.children.push(s)):n.push(s)}return n})(e)),ee=e=>{const{isRoot:t,type:n,children:o,...r}=e;return o?.length?{...r,children:o.map(ee)}:r},te=e=>{const{children:t}=e;if(!t?.length){const{children:t,...n}=e;return n}const n=t.map(te);if("wrap"===e.type)return{...e,children:n};const{path:o,component:r,type:s,children:a,...i}=e;return r?{path:o,children:[{path:"",component:r,...i},...n]}:{path:o,...i,children:n}},ne=e=>ee(te(e)),oe=e=>Y(e).map(ne),re=e=>{if(e.some(e=>e.isRoot))return(e=>{let t,n,o;const r=[];for(const i of e)if(i.isRoot){if(t)throw new Error("There cannot be multiple root routes in a route");t=i}else"/"===i.path?n=i:"/:pathMatch(.*)*"===i.path?o=i:r.push(i);if($e(r,"path"))throw new Error("There cannot be duplicate paths in a route");const s=[n&&{...n,index:!0},...oe(r)].filter(e=>Boolean(e)),a=[];return t&&a.push(ee({...t,children:s})),o&&a.push(ee(o)),a})(e);if($e(e,"path"))throw new Error("There cannot be duplicate paths in a route");return oe(e)},se=(e,t)=>({import:`import ${e} from './${t}'`,component:`<start>${e}</end>`,lazyComponent:`<start>() => import('${t}')</end>`});var ae=(e,t,n,o,r,s,a)=>{const i=((e,t)=>e.replace("index.vue",t?Me:ve))(Pe(e,t),a),c=me(de(n,e)),u=he(C(c),s),p=`component(${c})`;o[`/${i}`]=p,r.set(p,{path:c,componentName:u})},ie=(e,t,n,o)=>{const r=Pe(e,t);n[`/${r}`]=g(r,fe(e),o)};function ce(e,t,n,o,r,s,a,i,c){const p={},l=e.replace(/^\/+/,""),h=u.default.sync(l,{cwd:t,absolute:!0,onlyFiles:!0}),f="component"===r?((e,t)=>t.map(t=>t.includes("index.vue")||2===t.replace(e.replaceAll("\\","/"),"").split("/").length?t:void 0).filter(Boolean))(t,h):h.filter(ye);for(const u of f)if("component"===r){if(u.includes(".config."))continue;ae(u,n,o,p,s,a,c)}else ie(u,n,p,i);return p}var ue=async(e,t,n,o,r,s)=>{const a=new Map,i=new Set,c=new Map;we(o,((e,t,n,o)=>{let r=e;for(const[s,a]of t){const e=se(a.componentName,a.path);r=r.replace(s,o?e.lazyComponent:e.component)}for(const[s,a]of n)r=r.replace(s,a);return be(r)})(function(e,t,n,o){return`// Auto-generated by ono-auto-router${n?"\nimport type { RouteRecordRaw } from 'vue-router'":""}${o?"":`\n${t.join("\n")}${n?"":"\n"}`}${n?"\n\ntype PageConfig = Partial<\n Omit<RouteRecordRaw, 'path' | 'component' | 'children'> & {\n type?: 'single' | 'wrap'\n }\n>\n":""}${n?"\nexport const defineConfig = (config: PageConfig) => config\n":""}\nexport const routes${n?": RouteRecordRaw[]":""} = ${JSON.stringify(e,null,2)}\n`}(re(await G(ce("/**/*.vue",t,n,o,"component",a,i,c,s),ce("/**/*.config.{js,ts}",t,n,o,"config",a,i,c,s),e,s)),((e,t)=>{if(e)return[];const n=[];for(const o of t.values())n.push(se(o.componentName,o.path).import);return n})(r,a),s,r),a,c,r))},pe=(e,t,n,o)=>{const r=t.split(".")[0],s=(e=>`// Auto-generated by ono-auto-router${e?"\nexport { defineConfig } from './defineConfig'":""}\nexport { routes } from './autoRouter'\n`)(n),a=((e,t,n)=>`\nconst pathCache = new Map${t?"<string, { compPath: string; basePath: string }>":""}()\nconst basenameCache = new Map${t?"<string, string>":""}()\n\nconst normalizePagePath = ${t?"(key: string): string":"(key)"} => {\n if (key.includes('index.vue')) return key.replace('index.vue', 'index.${t?"ts":"js"}')\n if (key.includes('root.vue')) return key.replace('root.vue', 'root/index.${t?"ts":"js"}')\n if (key.includes('404.vue')) return key.replace('404.vue', '404/index.${t?"ts":"js"}')\n if (key.toLowerCase().includes('notfound.vue'))\n return key.toLowerCase().replace('notfound.vue', 'notfound/index.${t?"ts":"js"}')\n return key\n}\n\nconst getBasename = ${t?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const cacheKey = ext ? filePath + ':' + ext : filePath\n if (basenameCache.has(cacheKey)) {\n return basenameCache.get(cacheKey)${t?"!":""}\n }\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1] || ''\n let result = lastPart\n if (ext && lastPart.endsWith(ext)) {\n result = lastPart.slice(0, -ext.length)\n }\n basenameCache.set(cacheKey, result)\n return result\n}\n\nconst getDirname = ${t?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getPathsFromConfig = ${t?"(configPath: string)":"(configPath)"} => {\n const cacheKey = configPath\n if (pathCache.has(cacheKey)) {\n return pathCache.get(cacheKey)${t?"!":""}\n }\n\n let compPath${t?": string":" = ''"}\n let basePath${t?": string":" = ''"}\n\n if (configPath.endsWith('.config.${t?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${t?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${e}', '')\n\n if (fileName === 'index') {\n compPath = configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"ts":"js"}')\n basePath = dirPath || '/'\n } else {\n compPath = configPath.slice(0, -10) + '.vue'\n basePath = dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n } else {\n compPath = configPath.replace('index.config.${t?"ts":"js"}', 'index.${t?"ts":"js"}')\n basePath =\n configPath.replace('/${e}', '').replace('/index.config.${t?"ts":"js"}', '') ||\n '/'\n }\n\n const result = { compPath, basePath }\n pathCache.set(cacheKey, result)\n return result\n}\n\nconst formatPath = ${t?"(path: string): string":"(path)"} => {\n const lowerPath = path.toLowerCase()\n if (lowerPath === '/home') return '/'\n if (lowerPath === '/notfound' || path === '/404') return '/:pathMatch(.*)*'\n return path.replace('/index.${t?"ts":"js"}', '') || '/'\n}\n\nconst getConfigFileName = ${t?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.vue')) {\n return pagePath.slice(0, -4) + '.config.${t?"ts":"js"}'\n }\n return pagePath.replace('index.${t?"ts":"js"}', 'index.config.${t?"ts":"js"}')\n}\n\nconst createBaseRoutes = ()${t?": MyRouteObject[]":""} => {\n const pagesComponent = Object.fromEntries(\n Object.entries({\n ...import.meta.glob('/${e}/**/index.vue'${n?"":", { eager: true, import: 'default' }"}),\n ...import.meta.glob('/${e}/*.vue'${n?"":", { eager: true, import: 'default' }"})\n }${t?" as PagesComponentType":""}).map(([key, value]) => [\n normalizePagePath(key),\n value\n ])\n )\n\n const pagesModule${t?": Record<string, PageConfig>":""} = import.meta.glob(\n '/${e}/**/*.config.${t?"ts":"js"}',\n { eager: true, import: 'default' }\n )\n\n const result${t?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const pagePath of Object.keys(pagesComponent)) {\n const configPath = getConfigFileName(pagePath)\n const content = pagesModule[configPath] || {}\n const { compPath, basePath } = getPathsFromConfig(configPath)\n const path = replaceBracketsWithColon(basePath || '/')\n const name = path.split('/').filter(Boolean).join('-') || 'index'\n\n result.push({\n path: formatPath(path),\n name,\n component: pagesComponent[compPath],\n isRoot: path === '/root',\n ...content${t?"!":""}\n })\n }\n\n return result\n}\n\nconst processRoutes = ${t?"(\n routes: MyRouteObject[],\n removeLeadingSlash = false\n): MyRouteObject[]":"(routes, removeLeadingSlash)"} =>\n buildRouteTree(routes, removeLeadingSlash)\n .map(removeEmptyChildren)\n .map(cleanIsRoot)\n\nconst handleRootRoute = ${t?"(\n routes: (MyRouteObject & { isRoot?: boolean })[]\n): MyRouteObject[]":"(routes)"} => {\n let rootRoute${t?": (MyRouteObject & { isRoot?: boolean }) | undefined":" = undefined"}\n let homeRoute${t?": MyRouteObject | undefined":" = undefined"}\n let notFoundRoute${t?": MyRouteObject | undefined":" = undefined"}\n const filteredRoutes${t?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const route of routes) {\n if (route.isRoot) {\n if (rootRoute)\n throw new Error('There cannot be multiple root routes in a route')\n rootRoute = route\n } else if (route.path === '/') {\n homeRoute = route\n } else if (route.path === '/:pathMatch(.*)*') {\n notFoundRoute = route\n } else {\n filteredRoutes.push(route)\n }\n }\n\n if (hasDuplicateProperty(filteredRoutes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n const processedRoutes${t?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n if (rootRoute) {\n const children = [\n homeRoute && { ...homeRoute, path: '' },\n ...processRoutes(filteredRoutes, true)\n ].filter(Boolean)${t?" as MyRouteObject[]":""}\n processedRoutes.push({ ...rootRoute, path: '/', children })\n }\n\n if (notFoundRoute) processedRoutes.push(notFoundRoute)\n\n return processedRoutes.map(cleanIsRoot)\n}\n\nconst createRoutes = ()${t?": RouteRecordRaw[]":""} => {\n const routes = createBaseRoutes()\n\n if (routes.some((r${t?": MyRouteObject & { isRoot?: boolean }":""}) => r.isRoot))\n return handleRootRoute(routes)${t?" as RouteRecordRaw[]":""}\n\n if (hasDuplicateProperty(routes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n return processRoutes(routes)${t?" as RouteRecordRaw[]":""}\n}\n`)(e,n,o),i=(e=>`\nconst buildRouteTree = ${e?"(\n routes: MyRouteObject[],\n removeLeadingSlash: boolean = false\n)":"(routes, removeLeadingSlash)"} => {\n const routeMap = new Map${e?"<string, MyRouteObject & { isRoot?: boolean }>":""}()\n const rootRoutes${e?": MyRouteObject[]":""} = []\n\n const sortedRoutes = [...routes].sort((a, b) => a.path.length - b.path.length)\n\n for (const route of sortedRoutes) {\n let path = route.path\n if (removeLeadingSlash && path.startsWith('/')) {\n path = path.slice(1)\n }\n routeMap.set(path, { ...route, path, children: [] })\n }\n\n for (const [path, route] of routeMap) {\n const slashIndex = path.lastIndexOf('/')\n\n if (slashIndex <= 0) {\n const { isRoot, ...rest } = route\n rootRoutes.push(rest)\n continue\n }\n\n const parentPath = path.slice(0, slashIndex)\n const parentRoute = routeMap.get(parentPath)\n\n if (parentRoute) {\n const relativePath = path.slice(slashIndex + 1)\n const childRoute = { ...route, path: relativePath }\n parentRoute.children${e?"!":""}.push(childRoute)\n } else {\n const { isRoot, ...rest } = route\n rootRoutes.push(rest)\n }\n }\n\n return rootRoutes\n}\n`)(n),u=(e=>`\nconst cleanIsRoot = ${e?"(\n route: MyRouteObject & { isRoot?: boolean }\n): MyRouteObject":"(route)"} => {\n const { isRoot, type, children, ...rest } = route\n const result${e?": MyRouteObject":""} = { ...rest }\n\n if (children?.length) {\n result.children = children.map(cleanIsRoot)\n }\n\n return result\n}\n`)(n),p=(e=>`\nconst removeEmptyChildren = ${e?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n if (!route.children?.length) {\n const { children, ...rest } = route\n return rest\n }\n\n const hasIndexRoute = route.children.some(\n child => child.path === '' || child.path === '/'\n )\n\n const routeType = route.type || 'single'\n\n if (routeType === 'wrap') {\n const { children, ...rest } = route\n return { ...rest, children: children.map(removeEmptyChildren) }\n }\n\n if (routeType === 'single' || (!hasIndexRoute && route.component)) {\n const { path, component, type, ...rest } = route\n return {\n path,\n children: [\n { path: '', component, ...rest }${e?" as MyRouteObject":""},\n ...route.children.map(removeEmptyChildren)\n ]\n }\n }\n\n if (hasIndexRoute) {\n const { path, ...rest } = route\n const updatedChildren = route.children.map(child =>\n child.path === '' || child.path === '/' ? { ...rest, ...child } : child\n )\n return { path, children: updatedChildren.map(removeEmptyChildren) }\n }\n\n return { ...route, children: route.children.map(removeEmptyChildren) }\n}\n`)(n),l=n?"// Auto-generated by ono-auto-router\nimport type { PageConfig } from './autoRouter'\nexport const defineConfig = (config: PageConfig) => config\n":"",h=((e,t,n,o,r,s,a)=>`// Auto-generated by ono-auto-router${e}${t}${n}${o}${r}${s}${a}\n`)(n?"\nimport type { RouteRecordRaw } from 'vue-router'\n\ntype PagesComponentType = Record<string, () => Promise<unknown>>\n\ninterface MyRouteObject extends Omit<RouteRecordRaw, 'children'> {\n type?: 'single' | 'wrap'\n children?: MyRouteObject[]\n}\n\nexport type PageConfig = Partial<\n Omit<MyRouteObject, 'component' | 'children' | 'path'>\n>\n":"",(e=>`\nconst hasDuplicateProperty = ${e?"<T>(items: T[], propName: keyof T)":"(items, propName)"} => {\n const seenValues = new Set()\n return items.some(item => {\n if (seenValues.has(item[propName])) {\n return true\n }\n seenValues.add(item[propName])\n return false\n })\n}\n\nconst replaceBracketsWithColon = ${e?"(str: string)":"(str)"} => {\n return str.replace(/\\[([^\\]]+)\\]/g, ':$1').replace('.tsx', '')\n}\n`)(n),p,u,i,a,"\nexport const routes = createRoutes()");n?(we(c.default.resolve(r,"./index.ts"),s),we(c.default.resolve(r,"./autoRouter.ts"),h),we(c.default.resolve(r,"./defineConfig.ts"),l)):we(t,h)},le=(e,t,n,o,r,s)=>{const a=c.default.resolve(n,t);if(!i.default.existsSync(a))throw new Error(`Pages directory not found: ${a}`);const u=y(e,n,o),p=P(n),l=u.split(".")[0];f(l+".js"),f(l+".ts"),f(l+".jsx"),f(l+".tsx"),d(l),"react"===e?s?U(t,u,r,p):H(t,a,n,u,r,p):s?pe(t,u,p,r):ue(t,a,n,u,r,p),console.log(`[ono-auto-router] Routes file generated: ${u}`)},he=(e,t)=>{if(!t.has(e))return t.add(e),e;let n=1;for(;t.has(`${e}_${n}`);)n++;return`${e}_${n}`};function fe(e){try{const n=i.default.readFileSync(e,"utf-8").match(/export\s+default\s+([\s\S]*?)(?=\n\w|$)/);if(!n)return console.warn("No export default found in:",e),null;const o=n[1].trim();try{if(o.startsWith("{"))return new Function(`return ${o}`)();if(o.includes("defineConfig(")){const e=o.match(/defineConfig([\s\S]*)$/);if(e)return new Function(`return ${e[1]}`)()}return null}catch(t){return console.error("Error parsing export default content:",t),null}}catch(n){return console.error("Error reading file:",n),null}}function de(e,t){let n=c.default.resolve(e);(n.endsWith(".js")||n.endsWith(".jsx")||n.endsWith(".ts")||n.endsWith(".tsx")||n.endsWith(".vue"))&&(n=c.default.dirname(n));const o=c.default.resolve(t);return c.default.relative(n,o)}var ge=/\\/g,me=e=>e.replace(ge,"/"),Pe=(e,t)=>me(c.default.relative(t,e)),Re=/export\s+default\s+[\w(\[\]\{\})]+/;function ye(e){try{if(!i.default.existsSync(e))return console.warn(`File not found: ${e}`),!1;const t=i.default.readFileSync(e,"utf-8");return Re.test(t)}catch(t){return console.error("Read error:",t),!1}}var $e=(e,t)=>{const n=new Set;return e.some(e=>!!n.has(e[t])||(n.add(e[t]),!1))};function je(e){return e.replace(/"<start>([\s\S]*?)<\/end>"/g,"$1")}function be(e){let t=e;for(;;){const e=je(t);if(e===t)break;t=e}return t}var xe=(e,t,n)=>e.replace(/\[([^\]]+)\]/g,":$1").replace("react"===n?t?".tsx":".jsx":".vue","");function Ce(e){i.default.existsSync(e)||i.default.mkdirSync(e,{recursive:!0})}function Oe(e,t){Ce(c.default.dirname(e)),i.default.writeFileSync(e,t,"utf-8")}async function we(e,t){const n=c.default.dirname(e);await i.default.promises.mkdir(n,{recursive:!0}),await i.default.promises.writeFile(e,t,"utf-8")}var Me="index.ts",ve="index.js";Object.defineProperty(exports,"INDEX_JS_SUFFIX",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"INDEX_TS_SUFFIX",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"capitalize",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"convertFunctionToArrow",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"deleteDir",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"deleteFile",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"ensureDirSync",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"formatFunction",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"formatPagesDir",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"formatRoutesFile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"generateComponentName",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"generateReactRoutes",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"generateReactRoutesHMR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"generateRoutesTemplate",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"generateUniqueComponentName",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"generateVueRoutes",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"generateVueRoutesHMR",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"getDefaultExportContent",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"getRelativePath",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"getRelativeProjectPath",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"hasDefaultExport",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"hasDuplicateProperty",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"normalizePathWithWindows",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"removeCustomTagFunctionFromJSXAll",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"replaceBracketsWithColon",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"useTs",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"writeFile",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"writeFileSync",{enumerable:!0,get:function(){return Oe}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=require("node:path"),n=require("node:fs"),r=require("os"),o=require("path"),s=require("util"),i=require("stream"),a=require("events"),u=require("fs"),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l={},p={},f={};function h(){if(t)return f;return t=1,Object.defineProperty(f,"__esModule",{value:!0}),f.splitWhen=f.flatten=void 0,f.flatten=function(t){return t.reduce((t,e)=>[].concat(t,e),[])},f.splitWhen=function(t,e){const n=[[]];let r=0;for(const o of t)e(o)?(r++,n[r]=[]):n[r].push(o);return n},f}var d,g={};function _(){if(d)return g;return d=1,Object.defineProperty(g,"__esModule",{value:!0}),g.isEnoentCodeError=void 0,g.isEnoentCodeError=function(t){return"ENOENT"===t.code},g}var y,m={};var R,S={};function b(){if(R)return S;R=1,Object.defineProperty(S,"__esModule",{value:!0}),S.convertPosixPathToPattern=S.convertWindowsPathToPattern=S.convertPathToPattern=S.escapePosixPath=S.escapeWindowsPath=S.escape=S.removeLeadingDotSegment=S.makeAbsolute=S.unixify=void 0;const t=o,e="win32"===r.platform(),n=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,s=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,i=/^\\\\([.?])/,a=/\\(?![!()+@[\]{}])/g;function u(t){return t.replace(s,"\\$2")}function c(t){return t.replace(n,"\\$2")}function l(t){return u(t).replace(i,"//$1").replace(a,"/")}function p(t){return c(t)}return S.unixify=function(t){return t.replace(/\\/g,"/")},S.makeAbsolute=function(e,n){return t.resolve(e,n)},S.removeLeadingDotSegment=function(t){if("."===t.charAt(0)){const e=t.charAt(1);if("/"===e||"\\"===e)return t.slice(2)}return t},S.escape=e?u:c,S.escapeWindowsPath=u,S.escapePosixPath=c,S.convertPathToPattern=e?l:p,S.convertWindowsPathToPattern=l,S.convertPosixPathToPattern=p,S}var v,E,P,A,C,x,T={};function O(){return E?v:(E=1,v=function(t){if("string"!=typeof t||""===t)return!1;for(var e;e=/(\\).|([@?!+*]\(.*\))/g.exec(t);){if(e[2])return!0;t=t.slice(e.index+e[0].length)}return!1})}function $(){if(A)return P;A=1;var t=O(),e={"{":"}","(":")","[":"]"},n=function(t){if("!"===t[0])return!0;for(var n=0,r=-2,o=-2,s=-2,i=-2,a=-2;n<t.length;){if("*"===t[n])return!0;if("?"===t[n+1]&&/[\].+)]/.test(t[n]))return!0;if(-1!==o&&"["===t[n]&&"]"!==t[n+1]&&(o<n&&(o=t.indexOf("]",n)),o>n)){if(-1===a||a>o)return!0;if(-1===(a=t.indexOf("\\",n))||a>o)return!0}if(-1!==s&&"{"===t[n]&&"}"!==t[n+1]&&(s=t.indexOf("}",n))>n&&(-1===(a=t.indexOf("\\",n))||a>s))return!0;if(-1!==i&&"("===t[n]&&"?"===t[n+1]&&/[:!=]/.test(t[n+2])&&")"!==t[n+3]&&(i=t.indexOf(")",n))>n&&(-1===(a=t.indexOf("\\",n))||a>i))return!0;if(-1!==r&&"("===t[n]&&"|"!==t[n+1]&&(r<n&&(r=t.indexOf("|",n)),-1!==r&&")"!==t[r+1]&&(i=t.indexOf(")",r))>r&&(-1===(a=t.indexOf("\\",r))||a>i)))return!0;if("\\"===t[n]){var u=t[n+1];n+=2;var c=e[u];if(c){var l=t.indexOf(c,n);-1!==l&&(n=l+1)}if("!"===t[n])return!0}else n++}return!1},r=function(t){if("!"===t[0])return!0;for(var n=0;n<t.length;){if(/[*?{}()[\]]/.test(t[n]))return!0;if("\\"===t[n]){var r=t[n+1];n+=2;var o=e[r];if(o){var s=t.indexOf(o,n);-1!==s&&(n=s+1)}if("!"===t[n])return!0}else n++}return!1};return P=function(e,o){if("string"!=typeof e||""===e)return!1;if(t(e))return!0;var s=n;return o&&!1===o.strict&&(s=r),s(e)}}function w(){if(x)return C;x=1;var t=$(),e=o.posix.dirname,n="win32"===r.platform(),s=/\\/g,i=/[\{\[].*[\}\]]$/,a=/(^|[^\\])([\{\[]|\([^\)]+$)/,u=/\\([\!\*\?\|\[\]\(\)\{\}])/g;return C=function(r,o){Object.assign({flipBackslashes:!0},o).flipBackslashes&&n&&r.indexOf("/")<0&&(r=r.replace(s,"/")),i.test(r)&&(r+="/"),r+="a";do{r=e(r)}while(t(r)||a.test(r));return r.replace(u,"$1")}}var k,L,M,H,j,D,F,N,I,B,G,W,U,K,V,q,Q,Y,X,z={};function Z(){return k||(k=1,(t=z).isInteger=t=>"number"==typeof t?Number.isInteger(t):"string"==typeof t&&""!==t.trim()&&Number.isInteger(Number(t)),t.find=(t,e)=>t.nodes.find(t=>t.type===e),t.exceedsLimit=(e,n,r=1,o)=>!1!==o&&!(!t.isInteger(e)||!t.isInteger(n))&&(Number(n)-Number(e))/Number(r)>=o,t.escapeNode=(t,e=0,n)=>{const r=t.nodes[e];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},t.encloseBrace=t=>!("brace"!==t.type||t.commas>>0+t.ranges|0||(t.invalid=!0,0)),t.isInvalidBrace=t=>!("brace"!==t.type||!0!==t.invalid&&!t.dollar&&(t.commas>>0+t.ranges|0&&!0===t.open&&!0===t.close||(t.invalid=!0,0))),t.isOpenOrClose=t=>"open"===t.type||"close"===t.type||!0===t.open||!0===t.close,t.reduce=t=>t.reduce((t,e)=>("text"===e.type&&t.push(e.value),"range"===e.type&&(e.type="text"),t),[]),t.flatten=(...t)=>{const e=[],n=t=>{for(let r=0;r<t.length;r++){const o=t[r];Array.isArray(o)?n(o):void 0!==o&&e.push(o)}return e};return n(t),e}),z;var t}function J(){if(M)return L;M=1;const t=Z();return L=(e,n={})=>{const r=(e,o={})=>{const s=n.escapeInvalid&&t.isInvalidBrace(o),i=!0===e.invalid&&!0===n.escapeInvalid;let a="";if(e.value)return(s||i)&&t.isOpenOrClose(e)?"\\"+e.value:e.value;if(e.value)return e.value;if(e.nodes)for(const t of e.nodes)a+=r(t);return a};return r(e)}}function tt(){return j?H:(j=1,H=function(t){return"number"==typeof t?t-t===0:"string"==typeof t&&""!==t.trim()&&(Number.isFinite?Number.isFinite(+t):isFinite(+t))})}function et(){if(F)return D;F=1;const t=tt(),e=(n,s,i)=>{if(!1===t(n))throw new TypeError("toRegexRange: expected the first argument to be a number");if(void 0===s||n===s)return String(n);if(!1===t(s))throw new TypeError("toRegexRange: expected the second argument to be a number.");let a={relaxZeros:!0,...i};"boolean"==typeof a.strictZeros&&(a.relaxZeros=!1===a.strictZeros);let u=n+":"+s+"="+String(a.relaxZeros)+String(a.shorthand)+String(a.capture)+String(a.wrap);if(e.cache.hasOwnProperty(u))return e.cache[u].result;let c=Math.min(n,s),l=Math.max(n,s);if(1===Math.abs(c-l)){let t=n+"|"+s;return a.capture?`(${t})`:!1===a.wrap?t:`(?:${t})`}let f=p(n)||p(s),h={min:n,max:s,a:c,b:l},d=[],g=[];if(f&&(h.isPadded=f,h.maxLen=String(h.max).length),c<0){g=r(l<0?Math.abs(l):1,Math.abs(c),h,a),c=h.a=0}return l>=0&&(d=r(c,l,h,a)),h.negatives=g,h.positives=d,h.result=function(t,e){let n=o(t,e,"-",!1)||[],r=o(e,t,"",!1)||[],s=o(t,e,"-?",!0)||[];return n.concat(s).concat(r).join("|")}(g,d),!0===a.capture?h.result=`(${h.result})`:!1!==a.wrap&&d.length+g.length>1&&(h.result=`(?:${h.result})`),e.cache[u]=h,h.result};function n(t,e,n){if(t===e)return{pattern:t,count:[],digits:0};let r=function(t,e){let n=[];for(let r=0;r<t.length;r++)n.push([t[r],e[r]]);return n}(t,e),o=r.length,s="",i=0;for(let t=0;t<o;t++){let[e,n]=r[t];e===n?s+=e:"0"!==e||"9"!==n?s+=l(e,n):i++}return i&&(s+=!0===n.shorthand?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function r(t,e,r,o){let i,l=function(t,e){let n=1,r=1,o=a(t,n),i=new Set([e]);for(;t<=o&&o<=e;)i.add(o),n+=1,o=a(t,n);for(o=u(e+1,r)-1;t<o&&o<=e;)i.add(o),r+=1,o=u(e+1,r)-1;return i=[...i],i.sort(s),i}(t,e),p=[],h=t;for(let t=0;t<l.length;t++){let e=l[t],s=n(String(h),String(e),o),a="";r.isPadded||!i||i.pattern!==s.pattern?(r.isPadded&&(a=f(e,r,o)),s.string=a+s.pattern+c(s.count),p.push(s),h=e+1,i=s):(i.count.length>1&&i.count.pop(),i.count.push(s.count[0]),i.string=i.pattern+c(i.count),h=e+1)}return p}function o(t,e,n,r,o){let s=[];for(let o of t){let{string:t}=o;r||i(e,"string",t)||s.push(n+t),r&&i(e,"string",t)&&s.push(n+t)}return s}function s(t,e){return t>e?1:e>t?-1:0}function i(t,e,n){return t.some(t=>t[e]===n)}function a(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function u(t,e){return t-t%Math.pow(10,e)}function c(t){let[e=0,n=""]=t;return n||e>1?`{${e+(n?","+n:"")}}`:""}function l(t,e,n){return`[${t}${e-t===1?"":"-"}${e}]`}function p(t){return/^-?(0+)\d/.test(t)}function f(t,e,n){if(!e.isPadded)return t;let r=Math.abs(e.maxLen-String(t).length),o=!1!==n.relaxZeros;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}return e.cache={},e.clearCache=()=>e.cache={},D=e}function nt(){if(I)return N;I=1;const t=s,e=et(),n=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),r=t=>"number"==typeof t||"string"==typeof t&&""!==t,o=t=>Number.isInteger(+t),i=t=>{let e=`${t}`,n=-1;if("-"===e[0]&&(e=e.slice(1)),"0"===e)return!1;for(;"0"===e[++n];);return n>0},a=(t,e,n)=>{if(e>0){let n="-"===t[0]?"-":"";n&&(t=t.slice(1)),t=n+t.padStart(n?e-1:e,"0")}return!1===n?String(t):t},u=(t,e)=>{let n="-"===t[0]?"-":"";for(n&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return n?"-"+t:t},c=(t,n,r,o)=>{if(r)return e(t,n,{wrap:!1,...o});let s=String.fromCharCode(t);return t===n?s:`[${s}-${String.fromCharCode(n)}]`},l=(t,n,r)=>{if(Array.isArray(t)){let e=!0===r.wrap,n=r.capture?"":"?:";return e?`(${n}${t.join("|")})`:t.join("|")}return e(t,n,r)},p=(...e)=>new RangeError("Invalid range arguments: "+t.inspect(...e)),f=(t,e,n)=>{if(!0===n.strictRanges)throw p([t,e]);return[]},h=(t,e,n=1,r={})=>{let o=Number(t),s=Number(e);if(!Number.isInteger(o)||!Number.isInteger(s)){if(!0===r.strictRanges)throw p([t,e]);return[]}0===o&&(o=0),0===s&&(s=0);let f=o>s,h=String(t),d=String(e),g=String(n);n=Math.max(Math.abs(n),1);let _=i(h)||i(d)||i(g),y=_?Math.max(h.length,d.length,g.length):0,m=!1===_&&!1===((t,e,n)=>"string"==typeof t||"string"==typeof e||!0===n.stringify)(t,e,r),R=r.transform||(t=>e=>!0===t?Number(e):String(e))(m);if(r.toRegex&&1===n)return c(u(t,y),u(e,y),!0,r);let S={negatives:[],positives:[]},b=t=>S[t<0?"negatives":"positives"].push(Math.abs(t)),v=[],E=0;for(;f?o>=s:o<=s;)!0===r.toRegex&&n>1?b(o):v.push(a(R(o,E),y,m)),o=f?o-n:o+n,E++;return!0===r.toRegex?n>1?((t,e,n)=>{t.negatives.sort((t,e)=>t<e?-1:t>e?1:0),t.positives.sort((t,e)=>t<e?-1:t>e?1:0);let r,o=e.capture?"":"?:",s="",i="";return t.positives.length&&(s=t.positives.map(t=>u(String(t),n)).join("|")),t.negatives.length&&(i=`-(${o}${t.negatives.map(t=>u(String(t),n)).join("|")})`),r=s&&i?`${s}|${i}`:s||i,e.wrap?`(${o}${r})`:r})(S,r,y):l(v,null,{wrap:!1,...r}):v},d=(t,e,s,i={})=>{if(null==e&&r(t))return[t];if(!r(t)||!r(e))return f(t,e,i);if("function"==typeof s)return d(t,e,1,{transform:s});if(n(s))return d(t,e,0,s);let a={...i};return!0===a.capture&&(a.wrap=!0),s=s||a.step||1,o(s)?o(t)&&o(e)?h(t,e,s,a):((t,e,n=1,r={})=>{if(!o(t)&&t.length>1||!o(e)&&e.length>1)return f(t,e,r);let s=r.transform||(t=>String.fromCharCode(t)),i=`${t}`.charCodeAt(0),a=`${e}`.charCodeAt(0),u=i>a,p=Math.min(i,a),h=Math.max(i,a);if(r.toRegex&&1===n)return c(p,h,!1,r);let d=[],g=0;for(;u?i>=a:i<=a;)d.push(s(i,g)),i=u?i-n:i+n,g++;return!0===r.toRegex?l(d,null,{wrap:!1,options:r}):d})(t,e,Math.max(Math.abs(s),1),a):null==s||n(s)?d(t,e,1,s):((t,e)=>{if(!0===e.strictRanges)throw new TypeError(`Expected step "${t}" to be a number`);return[]})(s,a)};return N=d}function rt(){if(Q)return q;Q=1;const t=J(),{MAX_LENGTH:e,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_LEFT_PARENTHESES:i,CHAR_RIGHT_PARENTHESES:a,CHAR_LEFT_CURLY_BRACE:u,CHAR_RIGHT_CURLY_BRACE:c,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_RIGHT_SQUARE_BRACKET:p,CHAR_DOUBLE_QUOTE:f,CHAR_SINGLE_QUOTE:h,CHAR_NO_BREAK_SPACE:d,CHAR_ZERO_WIDTH_NOBREAK_SPACE:g}=V?K:(V=1,K={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:"\n",CHAR_NO_BREAK_SPACE:" ",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:"\t",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\ufeff"});return q=(_,y={})=>{if("string"!=typeof _)throw new TypeError("Expected a string");const m=y||{},R="number"==typeof m.maxLength?Math.min(e,m.maxLength):e;if(_.length>R)throw new SyntaxError(`Input length (${_.length}), exceeds max characters (${R})`);const S={type:"root",input:_,nodes:[]},b=[S];let v=S,E=S,P=0;const A=_.length;let C,x=0,T=0;const O=()=>_[x++],$=t=>{if("text"===t.type&&"dot"===E.type&&(E.type="text"),!E||"text"!==E.type||"text"!==t.type)return v.nodes.push(t),t.parent=v,t.prev=E,E=t,t;E.value+=t.value};for($({type:"bos"});x<A;)if(v=b[b.length-1],C=O(),C!==g&&C!==d)if(C!==n)if(C!==p){if(C===l){let t;for(P++;x<A&&(t=O());)if(C+=t,t!==l)if(t!==n){if(t===p&&(P--,0===P))break}else C+=O();else P++;$({type:"text",value:C});continue}if(C!==i)if(C!==a){if(C===f||C===h||C===r){const t=C;let e;for(!0!==y.keepQuotes&&(C="");x<A&&(e=O());)if(e!==n){if(e===t){!0===y.keepQuotes&&(C+=e);break}C+=e}else C+=e+O();$({type:"text",value:C});continue}if(C===u){T++;const t=E.value&&"$"===E.value.slice(-1)||!0===v.dollar;v=$({type:"brace",open:!0,close:!1,dollar:t,depth:T,commas:0,ranges:0,nodes:[]}),b.push(v),$({type:"open",value:C});continue}if(C===c){if("brace"!==v.type){$({type:"text",value:C});continue}const t="close";v=b.pop(),v.close=!0,$({type:t,value:C}),T--,v=b[b.length-1];continue}if(C===o&&T>0){if(v.ranges>0){v.ranges=0;const e=v.nodes.shift();v.nodes=[e,{type:"text",value:t(v)}]}$({type:"comma",value:C}),v.commas++}else{if(C===s&&T>0&&0===v.commas){const t=v.nodes;if(0===T||0===t.length){$({type:"text",value:C});continue}if("dot"===E.type){if(v.range=[],E.value+=C,E.type="range",3!==v.nodes.length&&5!==v.nodes.length){v.invalid=!0,v.ranges=0,E.type="text";continue}v.ranges++,v.args=[];continue}if("range"===E.type){t.pop();const e=t[t.length-1];e.value+=E.value+C,E=e,v.ranges--;continue}$({type:"dot",value:C});continue}$({type:"text",value:C})}}else{if("paren"!==v.type){$({type:"text",value:C});continue}v=b.pop(),$({type:"text",value:C}),v=b[b.length-1]}else v=$({type:"paren",nodes:[]}),b.push(v),$({type:"text",value:C})}else $({type:"text",value:"\\"+C});else $({type:"text",value:(y.keepEscaping?C:"")+O()});do{if(v=b.pop(),"root"!==v.type){v.nodes.forEach(t=>{t.nodes||("open"===t.type&&(t.isOpen=!0),"close"===t.type&&(t.isClose=!0),t.nodes||(t.type="text"),t.invalid=!0)});const t=b[b.length-1],e=t.nodes.indexOf(v);t.nodes.splice(e,1,...v.nodes)}}while(b.length>0);return $({type:"eos"}),S}}function ot(){if(X)return Y;X=1;const t=J(),e=function(){if(G)return B;G=1;const t=nt(),e=Z();return B=(n,r={})=>{const o=(n,s={})=>{const i=e.isInvalidBrace(s),a=!0===n.invalid&&!0===r.escapeInvalid,u=!0===i||!0===a,c=!0===r.escapeInvalid?"\\":"";let l="";if(!0===n.isOpen)return c+n.value;if(!0===n.isClose)return console.log("node.isClose",c,n.value),c+n.value;if("open"===n.type)return u?c+n.value:"(";if("close"===n.type)return u?c+n.value:")";if("comma"===n.type)return"comma"===n.prev.type?"":u?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){const o=e.reduce(n.nodes),s=t(...o,{...r,wrap:!1,toRegex:!0,strictZeros:!0});if(0!==s.length)return o.length>1&&s.length>1?`(${s})`:s}if(n.nodes)for(const t of n.nodes)l+=o(t,n);return l};return o(n)}}(),n=function(){if(U)return W;U=1;const t=nt(),e=J(),n=Z(),r=(t="",e="",o=!1)=>{const s=[];if(t=[].concat(t),!(e=[].concat(e)).length)return t;if(!t.length)return o?n.flatten(e).map(t=>`{${t}}`):e;for(const n of t)if(Array.isArray(n))for(const t of n)s.push(r(t,e,o));else for(let t of e)!0===o&&"string"==typeof t&&(t=`{${t}}`),s.push(Array.isArray(t)?r(n,t,o):n+t);return n.flatten(s)};return W=(o,s={})=>{const i=void 0===s.rangeLimit?1e3:s.rangeLimit,a=(o,u={})=>{o.queue=[];let c=u,l=u.queue;for(;"brace"!==c.type&&"root"!==c.type&&c.parent;)c=c.parent,l=c.queue;if(o.invalid||o.dollar)return void l.push(r(l.pop(),e(o,s)));if("brace"===o.type&&!0!==o.invalid&&2===o.nodes.length)return void l.push(r(l.pop(),["{}"]));if(o.nodes&&o.ranges>0){const a=n.reduce(o.nodes);if(n.exceedsLimit(...a,s.step,i))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let u=t(...a,s);return 0===u.length&&(u=e(o,s)),l.push(r(l.pop(),u)),void(o.nodes=[])}const p=n.encloseBrace(o);let f=o.queue,h=o;for(;"brace"!==h.type&&"root"!==h.type&&h.parent;)h=h.parent,f=h.queue;for(let t=0;t<o.nodes.length;t++){const e=o.nodes[t];"comma"!==e.type||"brace"!==o.type?"close"!==e.type?e.value&&"open"!==e.type?f.push(r(f.pop(),e.value)):e.nodes&&a(e,o):l.push(r(l.pop(),f,p)):(1===t&&f.push(""),f.push(""))}return f};return n.flatten(a(o))},W}(),r=rt(),o=(t,e={})=>{let n=[];if(Array.isArray(t))for(const r of t){const t=o.create(r,e);Array.isArray(t)?n.push(...t):n.push(t)}else n=[].concat(o.create(t,e));return e&&!0===e.expand&&!0===e.nodupes&&(n=[...new Set(n)]),n};return o.parse=(t,e={})=>r(t,e),o.stringify=(e,n={})=>t("string"==typeof e?o.parse(e,n):e,n),o.compile=(t,n={})=>("string"==typeof t&&(t=o.parse(t,n)),e(t,n)),o.expand=(t,e={})=>{"string"==typeof t&&(t=o.parse(t,e));let r=n(t,e);return!0===e.noempty&&(r=r.filter(Boolean)),!0===e.nodupes&&(r=[...new Set(r)]),r},o.create=(t,e={})=>""===t||t.length<3?[t]:!0!==e.expand?o.compile(t,e):o.expand(t,e),Y=o}var st,it,at,ut,ct,lt,pt,ft,ht,dt,gt,_t,yt,mt,Rt={};function St(){if(it)return st;it=1;const t=o,e="\\\\/",n=`[^${e}]`,r="\\.",s="\\/",i="[^/]",a=`(?:${s}|$)`,u=`(?:^|${s})`,c=`${r}{1,2}${a}`,l={DOT_LITERAL:r,PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:s,ONE_CHAR:"(?=.)",QMARK:i,END_ANCHOR:a,DOTS_SLASH:c,NO_DOT:`(?!${r})`,NO_DOTS:`(?!${u}${c})`,NO_DOT_SLASH:`(?!${r}{0,1}${a})`,NO_DOTS_SLASH:`(?!${c})`,QMARK_NO_DOT:`[^.${s}]`,STAR:`${i}*?`,START_ANCHOR:u},p={...l,SLASH_LITERAL:`[${e}]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`${r}{1,2}(?:[${e}]|$)`,NO_DOT:`(?!${r})`,NO_DOTS:`(?!(?:^|[${e}])${r}{1,2}(?:[${e}]|$))`,NO_DOT_SLASH:`(?!${r}{0,1}(?:[${e}]|$))`,NO_DOTS_SLASH:`(?!${r}{1,2}(?:[${e}]|$))`,QMARK_NO_DOT:`[^.${e}]`,START_ANCHOR:`(?:^|[${e}])`,END_ANCHOR:`(?:[${e}]|$)`};return st={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:t.sep,extglobChars:t=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:t=>!0===t?p:l}}function bt(){return at||(at=1,function(t){const e=o,n="win32"===process.platform,{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:s,REGEX_SPECIAL_CHARS:i,REGEX_SPECIAL_CHARS_GLOBAL:a}=St();t.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),t.hasRegexChars=t=>i.test(t),t.isRegexChar=e=>1===e.length&&t.hasRegexChars(e),t.escapeRegex=t=>t.replace(a,"\\$1"),t.toPosixSlashes=t=>t.replace(r,"/"),t.removeBackslashes=t=>t.replace(s,t=>"\\"===t?"":t),t.supportsLookbehinds=()=>{const t=process.version.slice(1).split(".").map(Number);return 3===t.length&&t[0]>=9||8===t[0]&&t[1]>=10},t.isWindows=t=>t&&"boolean"==typeof t.windows?t.windows:!0===n||"\\"===e.sep,t.escapeLast=(e,n,r)=>{const o=e.lastIndexOf(n,r);return-1===o?e:"\\"===e[o-1]?t.escapeLast(e,n,o-1):`${e.slice(0,o)}\\${e.slice(o)}`},t.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n},t.wrapOutput=(t,e={},n={})=>{let r=`${n.contains?"":"^"}(?:${t})${n.contains?"":"$"}`;return!0===e.negated&&(r=`(?:^(?!${r}).*$)`),r}}(Rt)),Rt}function vt(){if(ht)return ft;ht=1;const t=o,e=function(){if(ct)return ut;ct=1;const t=bt(),{CHAR_ASTERISK:e,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:c,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_PLUS:p,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:d,CHAR_RIGHT_SQUARE_BRACKET:g}=St(),_=t=>t===a||t===r,y=t=>{!0!==t.isPrefix&&(t.depth=t.isGlobstar?1/0:1)};return ut=(m,R)=>{const S=R||{},b=m.length-1,v=!0===S.parts||!0===S.scanToEnd,E=[],P=[],A=[];let C,x,T=m,O=-1,$=0,w=0,k=!1,L=!1,M=!1,H=!1,j=!1,D=!1,F=!1,N=!1,I=!1,B=!1,G=0,W={value:"",depth:0,isGlob:!1};const U=()=>O>=b,K=()=>T.charCodeAt(O+1),V=()=>(C=x,T.charCodeAt(++O));for(;O<b;){let t;if(x=V(),x!==r){if(!0===D||x===u){for(G++;!0!==U()&&(x=V());)if(x!==r)if(x!==u){if(!0!==D&&x===s&&(x=V())===s){if(k=W.isBrace=!0,M=W.isGlob=!0,B=!0,!0===v)continue;break}if(!0!==D&&x===o){if(k=W.isBrace=!0,M=W.isGlob=!0,B=!0,!0===v)continue;break}if(x===h&&(G--,0===G)){D=!1,k=W.isBrace=!0,B=!0;break}}else G++;else F=W.backslashes=!0,V();if(!0===v)continue;break}if(x!==a){if(!0!==S.noext&&!0==(x===p||x===n||x===e||x===f||x===i)&&K()===c){if(M=W.isGlob=!0,H=W.isExtglob=!0,B=!0,x===i&&O===$&&(I=!0),!0===v){for(;!0!==U()&&(x=V());)if(x!==r){if(x===d){M=W.isGlob=!0,B=!0;break}}else F=W.backslashes=!0,x=V();continue}break}if(x===e){if(C===e&&(j=W.isGlobstar=!0),M=W.isGlob=!0,B=!0,!0===v)continue;break}if(x===f){if(M=W.isGlob=!0,B=!0,!0===v)continue;break}if(x===l){for(;!0!==U()&&(t=V());)if(t!==r){if(t===g){L=W.isBracket=!0,M=W.isGlob=!0,B=!0;break}}else F=W.backslashes=!0,V();if(!0===v)continue;break}if(!0===S.nonegate||x!==i||O!==$){if(!0!==S.noparen&&x===c){if(M=W.isGlob=!0,!0===v){for(;!0!==U()&&(x=V());)if(x!==c){if(x===d){B=!0;break}}else F=W.backslashes=!0,x=V();continue}break}if(!0===M){if(B=!0,!0===v)continue;break}}else N=W.negated=!0,$++}else{if(E.push(O),P.push(W),W={value:"",depth:0,isGlob:!1},!0===B)continue;if(C===s&&O===$+1){$+=2;continue}w=O+1}}else F=W.backslashes=!0,x=V(),x===u&&(D=!0)}!0===S.noext&&(H=!1,M=!1);let q=T,Q="",Y="";$>0&&(Q=T.slice(0,$),T=T.slice($),w-=$),q&&!0===M&&w>0?(q=T.slice(0,w),Y=T.slice(w)):!0===M?(q="",Y=T):q=T,q&&""!==q&&"/"!==q&&q!==T&&_(q.charCodeAt(q.length-1))&&(q=q.slice(0,-1)),!0===S.unescape&&(Y&&(Y=t.removeBackslashes(Y)),q&&!0===F&&(q=t.removeBackslashes(q)));const X={prefix:Q,input:m,start:$,base:q,glob:Y,isBrace:k,isBracket:L,isGlob:M,isExtglob:H,isGlobstar:j,negated:N,negatedExtglob:I};if(!0===S.tokens&&(X.maxDepth=0,_(x)||P.push(W),X.tokens=P),!0===S.parts||!0===S.tokens){let t;for(let e=0;e<E.length;e++){const n=t?t+1:$,r=E[e],o=m.slice(n,r);S.tokens&&(0===e&&0!==$?(P[e].isPrefix=!0,P[e].value=Q):P[e].value=o,y(P[e]),X.maxDepth+=P[e].depth),0===e&&""===o||A.push(o),t=r}if(t&&t+1<m.length){const e=m.slice(t+1);A.push(e),S.tokens&&(P[P.length-1].value=e,y(P[P.length-1]),X.maxDepth+=P[P.length-1].depth)}X.slashes=E,X.parts=A}return X},ut}(),n=function(){if(pt)return lt;pt=1;const t=St(),e=bt(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:i}=t,a=(t,n)=>{if("function"==typeof n.expandRange)return n.expandRange(...t,n);t.sort();const r=`[${t.join("-")}]`;try{new RegExp(r)}catch(n){return t.map(t=>e.escapeRegex(t)).join("..")}return r},u=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,c=(l,p)=>{if("string"!=typeof l)throw new TypeError("Expected a string");l=i[l]||l;const f={...p},h="number"==typeof f.maxLength?Math.min(n,f.maxLength):n;let d=l.length;if(d>h)throw new SyntaxError(`Input length: ${d}, exceeds maximum allowed length: ${h}`);const g={type:"bos",value:"",output:f.prepend||""},_=[g],y=f.capture?"":"?:",m=e.isWindows(p),R=t.globChars(m),S=t.extglobChars(R),{DOT_LITERAL:b,PLUS_LITERAL:v,SLASH_LITERAL:E,ONE_CHAR:P,DOTS_SLASH:A,NO_DOT:C,NO_DOT_SLASH:x,NO_DOTS_SLASH:T,QMARK:O,QMARK_NO_DOT:$,STAR:w,START_ANCHOR:k}=R,L=t=>`(${y}(?:(?!${k}${t.dot?A:b}).)*?)`,M=f.dot?"":C,H=f.dot?O:$;let j=!0===f.bash?L(f):w;f.capture&&(j=`(${j})`),"boolean"==typeof f.noext&&(f.noextglob=f.noext);const D={input:l,index:-1,start:0,dot:!0===f.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:_};l=e.removePrefix(l,D),d=l.length;const F=[],N=[],I=[];let B,G=g;const W=()=>D.index===d-1,U=D.peek=(t=1)=>l[D.index+t],K=D.advance=()=>l[++D.index]||"",V=()=>l.slice(D.index+1),q=(t="",e=0)=>{D.consumed+=t,D.index+=e},Q=t=>{D.output+=null!=t.output?t.output:t.value,q(t.value)},Y=()=>{let t=1;for(;"!"===U()&&("("!==U(2)||"?"===U(3));)K(),D.start++,t++;return t%2!=0&&(D.negated=!0,D.start++,!0)},X=t=>{D[t]++,I.push(t)},z=t=>{D[t]--,I.pop()},Z=t=>{if("globstar"===G.type){const e=D.braces>0&&("comma"===t.type||"brace"===t.type),n=!0===t.extglob||F.length&&("pipe"===t.type||"paren"===t.type);"slash"===t.type||"paren"===t.type||e||n||(D.output=D.output.slice(0,-G.output.length),G.type="star",G.value="*",G.output=j,D.output+=G.output)}if(F.length&&"paren"!==t.type&&(F[F.length-1].inner+=t.value),(t.value||t.output)&&Q(t),G&&"text"===G.type&&"text"===t.type)return G.value+=t.value,void(G.output=(G.output||"")+t.value);t.prev=G,_.push(t),G=t},J=(t,e)=>{const n={...S[e],conditions:1,inner:""};n.prev=G,n.parens=D.parens,n.output=D.output;const r=(f.capture?"(":"")+n.open;X("parens"),Z({type:t,value:e,output:D.output?"":P}),Z({type:"paren",extglob:!0,value:K(),output:r}),F.push(n)},tt=t=>{let e,n=t.close+(f.capture?")":"");if("negate"===t.type){let r=j;if(t.inner&&t.inner.length>1&&t.inner.includes("/")&&(r=L(f)),(r!==j||W()||/^\)+$/.test(V()))&&(n=t.close=`)$))${r}`),t.inner.includes("*")&&(e=V())&&/^\.[^\\/.]+$/.test(e)){const o=c(e,{...p,fastpaths:!1}).output;n=t.close=`)${o})${r})`}"bos"===t.prev.type&&(D.negatedExtglob=!0)}Z({type:"paren",extglob:!0,value:B,output:n}),z("parens")};if(!1!==f.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(l)){let t=!1,n=l.replace(s,(e,n,r,o,s,i)=>"\\"===o?(t=!0,e):"?"===o?n?n+o+(s?O.repeat(s.length):""):0===i?H+(s?O.repeat(s.length):""):O.repeat(r.length):"."===o?b.repeat(r.length):"*"===o?n?n+o+(s?j:""):j:n?e:`\\${e}`);return!0===t&&(n=!0===f.unescape?n.replace(/\\/g,""):n.replace(/\\+/g,t=>t.length%2==0?"\\\\":t?"\\":"")),n===l&&!0===f.contains?(D.output=l,D):(D.output=e.wrapOutput(n,D,p),D)}for(;!W();){if(B=K(),"\0"===B)continue;if("\\"===B){const t=U();if("/"===t&&!0!==f.bash)continue;if("."===t||";"===t)continue;if(!t){B+="\\",Z({type:"text",value:B});continue}const e=/^\\+/.exec(V());let n=0;if(e&&e[0].length>2&&(n=e[0].length,D.index+=n,n%2!=0&&(B+="\\")),!0===f.unescape?B=K():B+=K(),0===D.brackets){Z({type:"text",value:B});continue}}if(D.brackets>0&&("]"!==B||"["===G.value||"[^"===G.value)){if(!1!==f.posix&&":"===B){const t=G.value.slice(1);if(t.includes("[")&&(G.posix=!0,t.includes(":"))){const t=G.value.lastIndexOf("["),e=G.value.slice(0,t),n=G.value.slice(t+2),o=r[n];if(o){G.value=e+o,D.backtrack=!0,K(),g.output||1!==_.indexOf(G)||(g.output=P);continue}}}("["===B&&":"!==U()||"-"===B&&"]"===U())&&(B=`\\${B}`),"]"!==B||"["!==G.value&&"[^"!==G.value||(B=`\\${B}`),!0===f.posix&&"!"===B&&"["===G.value&&(B="^"),G.value+=B,Q({value:B});continue}if(1===D.quotes&&'"'!==B){B=e.escapeRegex(B),G.value+=B,Q({value:B});continue}if('"'===B){D.quotes=1===D.quotes?0:1,!0===f.keepQuotes&&Z({type:"text",value:B});continue}if("("===B){X("parens"),Z({type:"paren",value:B});continue}if(")"===B){if(0===D.parens&&!0===f.strictBrackets)throw new SyntaxError(u("opening","("));const t=F[F.length-1];if(t&&D.parens===t.parens+1){tt(F.pop());continue}Z({type:"paren",value:B,output:D.parens?")":"\\)"}),z("parens");continue}if("["===B){if(!0!==f.nobracket&&V().includes("]"))X("brackets");else{if(!0!==f.nobracket&&!0===f.strictBrackets)throw new SyntaxError(u("closing","]"));B=`\\${B}`}Z({type:"bracket",value:B});continue}if("]"===B){if(!0===f.nobracket||G&&"bracket"===G.type&&1===G.value.length){Z({type:"text",value:B,output:`\\${B}`});continue}if(0===D.brackets){if(!0===f.strictBrackets)throw new SyntaxError(u("opening","["));Z({type:"text",value:B,output:`\\${B}`});continue}z("brackets");const t=G.value.slice(1);if(!0===G.posix||"^"!==t[0]||t.includes("/")||(B=`/${B}`),G.value+=B,Q({value:B}),!1===f.literalBrackets||e.hasRegexChars(t))continue;const n=e.escapeRegex(G.value);if(D.output=D.output.slice(0,-G.value.length),!0===f.literalBrackets){D.output+=n,G.value=n;continue}G.value=`(${y}${n}|${G.value})`,D.output+=G.value;continue}if("{"===B&&!0!==f.nobrace){X("braces");const t={type:"brace",value:B,output:"(",outputIndex:D.output.length,tokensIndex:D.tokens.length};N.push(t),Z(t);continue}if("}"===B){const t=N[N.length-1];if(!0===f.nobrace||!t){Z({type:"text",value:B,output:B});continue}let e=")";if(!0===t.dots){const t=_.slice(),n=[];for(let e=t.length-1;e>=0&&(_.pop(),"brace"!==t[e].type);e--)"dots"!==t[e].type&&n.unshift(t[e].value);e=a(n,f),D.backtrack=!0}if(!0!==t.comma&&!0!==t.dots){const n=D.output.slice(0,t.outputIndex),r=D.tokens.slice(t.tokensIndex);t.value=t.output="\\{",B=e="\\}",D.output=n;for(const t of r)D.output+=t.output||t.value}Z({type:"brace",value:B,output:e}),z("braces"),N.pop();continue}if("|"===B){F.length>0&&F[F.length-1].conditions++,Z({type:"text",value:B});continue}if(","===B){let t=B;const e=N[N.length-1];e&&"braces"===I[I.length-1]&&(e.comma=!0,t="|"),Z({type:"comma",value:B,output:t});continue}if("/"===B){if("dot"===G.type&&D.index===D.start+1){D.start=D.index+1,D.consumed="",D.output="",_.pop(),G=g;continue}Z({type:"slash",value:B,output:E});continue}if("."===B){if(D.braces>0&&"dot"===G.type){"."===G.value&&(G.output=b);const t=N[N.length-1];G.type="dots",G.output+=B,G.value+=B,t.dots=!0;continue}if(D.braces+D.parens===0&&"bos"!==G.type&&"slash"!==G.type){Z({type:"text",value:B,output:b});continue}Z({type:"dot",value:B,output:b});continue}if("?"===B){if((!G||"("!==G.value)&&!0!==f.noextglob&&"("===U()&&"?"!==U(2)){J("qmark",B);continue}if(G&&"paren"===G.type){const t=U();let n=B;if("<"===t&&!e.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");("("===G.value&&!/[!=<:]/.test(t)||"<"===t&&!/<([!=]|\w+>)/.test(V()))&&(n=`\\${B}`),Z({type:"text",value:B,output:n});continue}if(!0!==f.dot&&("slash"===G.type||"bos"===G.type)){Z({type:"qmark",value:B,output:$});continue}Z({type:"qmark",value:B,output:O});continue}if("!"===B){if(!0!==f.noextglob&&"("===U()&&("?"!==U(2)||!/[!=<:]/.test(U(3)))){J("negate",B);continue}if(!0!==f.nonegate&&0===D.index){Y();continue}}if("+"===B){if(!0!==f.noextglob&&"("===U()&&"?"!==U(2)){J("plus",B);continue}if(G&&"("===G.value||!1===f.regex){Z({type:"plus",value:B,output:v});continue}if(G&&("bracket"===G.type||"paren"===G.type||"brace"===G.type)||D.parens>0){Z({type:"plus",value:B});continue}Z({type:"plus",value:v});continue}if("@"===B){if(!0!==f.noextglob&&"("===U()&&"?"!==U(2)){Z({type:"at",extglob:!0,value:B,output:""});continue}Z({type:"text",value:B});continue}if("*"!==B){"$"!==B&&"^"!==B||(B=`\\${B}`);const t=o.exec(V());t&&(B+=t[0],D.index+=t[0].length),Z({type:"text",value:B});continue}if(G&&("globstar"===G.type||!0===G.star)){G.type="star",G.star=!0,G.value+=B,G.output=j,D.backtrack=!0,D.globstar=!0,q(B);continue}let t=V();if(!0!==f.noextglob&&/^\([^?]/.test(t)){J("star",B);continue}if("star"===G.type){if(!0===f.noglobstar){q(B);continue}const e=G.prev,n=e.prev,r="slash"===e.type||"bos"===e.type,o=n&&("star"===n.type||"globstar"===n.type);if(!0===f.bash&&(!r||t[0]&&"/"!==t[0])){Z({type:"star",value:B,output:""});continue}const s=D.braces>0&&("comma"===e.type||"brace"===e.type),i=F.length&&("pipe"===e.type||"paren"===e.type);if(!r&&"paren"!==e.type&&!s&&!i){Z({type:"star",value:B,output:""});continue}for(;"/**"===t.slice(0,3);){const e=l[D.index+4];if(e&&"/"!==e)break;t=t.slice(3),q("/**",3)}if("bos"===e.type&&W()){G.type="globstar",G.value+=B,G.output=L(f),D.output=G.output,D.globstar=!0,q(B);continue}if("slash"===e.type&&"bos"!==e.prev.type&&!o&&W()){D.output=D.output.slice(0,-(e.output+G.output).length),e.output=`(?:${e.output}`,G.type="globstar",G.output=L(f)+(f.strictSlashes?")":"|$)"),G.value+=B,D.globstar=!0,D.output+=e.output+G.output,q(B);continue}if("slash"===e.type&&"bos"!==e.prev.type&&"/"===t[0]){const n=void 0!==t[1]?"|$":"";D.output=D.output.slice(0,-(e.output+G.output).length),e.output=`(?:${e.output}`,G.type="globstar",G.output=`${L(f)}${E}|${E}${n})`,G.value+=B,D.output+=e.output+G.output,D.globstar=!0,q(B+K()),Z({type:"slash",value:"/",output:""});continue}if("bos"===e.type&&"/"===t[0]){G.type="globstar",G.value+=B,G.output=`(?:^|${E}|${L(f)}${E})`,D.output=G.output,D.globstar=!0,q(B+K()),Z({type:"slash",value:"/",output:""});continue}D.output=D.output.slice(0,-G.output.length),G.type="globstar",G.output=L(f),G.value+=B,D.output+=G.output,D.globstar=!0,q(B);continue}const n={type:"star",value:B,output:j};!0!==f.bash?!G||"bracket"!==G.type&&"paren"!==G.type||!0!==f.regex?(D.index!==D.start&&"slash"!==G.type&&"dot"!==G.type||("dot"===G.type?(D.output+=x,G.output+=x):!0===f.dot?(D.output+=T,G.output+=T):(D.output+=M,G.output+=M),"*"!==U()&&(D.output+=P,G.output+=P)),Z(n)):(n.output=B,Z(n)):(n.output=".*?","bos"!==G.type&&"slash"!==G.type||(n.output=M+n.output),Z(n))}for(;D.brackets>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing","]"));D.output=e.escapeLast(D.output,"["),z("brackets")}for(;D.parens>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing",")"));D.output=e.escapeLast(D.output,"("),z("parens")}for(;D.braces>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing","}"));D.output=e.escapeLast(D.output,"{"),z("braces")}if(!0===f.strictSlashes||"star"!==G.type&&"bracket"!==G.type||Z({type:"maybe_slash",value:"",output:`${E}?`}),!0===D.backtrack){D.output="";for(const t of D.tokens)D.output+=null!=t.output?t.output:t.value,t.suffix&&(D.output+=t.suffix)}return D};return c.fastpaths=(r,o)=>{const s={...o},a="number"==typeof s.maxLength?Math.min(n,s.maxLength):n,u=r.length;if(u>a)throw new SyntaxError(`Input length: ${u}, exceeds maximum allowed length: ${a}`);r=i[r]||r;const c=e.isWindows(o),{DOT_LITERAL:l,SLASH_LITERAL:p,ONE_CHAR:f,DOTS_SLASH:h,NO_DOT:d,NO_DOTS:g,NO_DOTS_SLASH:_,STAR:y,START_ANCHOR:m}=t.globChars(c),R=s.dot?g:d,S=s.dot?_:d,b=s.capture?"":"?:";let v=!0===s.bash?".*?":y;s.capture&&(v=`(${v})`);const E=t=>!0===t.noglobstar?v:`(${b}(?:(?!${m}${t.dot?h:l}).)*?)`,P=t=>{switch(t){case"*":return`${R}${f}${v}`;case".*":return`${l}${f}${v}`;case"*.*":return`${R}${v}${l}${f}${v}`;case"*/*":return`${R}${v}${p}${f}${S}${v}`;case"**":return R+E(s);case"**/*":return`(?:${R}${E(s)}${p})?${S}${f}${v}`;case"**/*.*":return`(?:${R}${E(s)}${p})?${S}${v}${l}${f}${v}`;case"**/.*":return`(?:${R}${E(s)}${p})?${l}${f}${v}`;default:{const e=/^(.*?)\.(\w+)$/.exec(t);if(!e)return;const n=P(e[1]);if(!n)return;return n+l+e[2]}}},A=e.removePrefix(r,{negated:!1,prefix:""});let C=P(A);return C&&!0!==s.strictSlashes&&(C+=`${p}?`),C},lt=c}(),r=bt(),s=St(),i=(t,e,n=!1)=>{if(Array.isArray(t)){const r=t.map(t=>i(t,e,n)),o=t=>{for(const e of r){const n=e(t);if(n)return n}return!1};return o}const o=(s=t)&&"object"==typeof s&&!Array.isArray(s)&&t.tokens&&t.input;var s;if(""===t||"string"!=typeof t&&!o)throw new TypeError("Expected pattern to be a non-empty string");const a=e||{},u=r.isWindows(e),c=o?i.compileRe(t,e):i.makeRe(t,e,!1,!0),l=c.state;delete c.state;let p=()=>!1;if(a.ignore){const t={...e,ignore:null,onMatch:null,onResult:null};p=i(a.ignore,t,n)}const f=(n,r=!1)=>{const{isMatch:o,match:s,output:f}=i.test(n,c,e,{glob:t,posix:u}),h={glob:t,state:l,regex:c,posix:u,input:n,output:f,match:s,isMatch:o};return"function"==typeof a.onResult&&a.onResult(h),!1===o?(h.isMatch=!1,!!r&&h):p(n)?("function"==typeof a.onIgnore&&a.onIgnore(h),h.isMatch=!1,!!r&&h):("function"==typeof a.onMatch&&a.onMatch(h),!r||h)};return n&&(f.state=l),f};return i.test=(t,e,n,{glob:o,posix:s}={})=>{if("string"!=typeof t)throw new TypeError("Expected input to be a string");if(""===t)return{isMatch:!1,output:""};const a=n||{},u=a.format||(s?r.toPosixSlashes:null);let c=t===o,l=c&&u?u(t):t;return!1===c&&(l=u?u(t):t,c=l===o),!1!==c&&!0!==a.capture||(c=!0===a.matchBase||!0===a.basename?i.matchBase(t,e,n,s):e.exec(l)),{isMatch:Boolean(c),match:c,output:l}},i.matchBase=(e,n,o,s=r.isWindows(o))=>(n instanceof RegExp?n:i.makeRe(n,o)).test(t.basename(e)),i.isMatch=(t,e,n)=>i(e,n)(t),i.parse=(t,e)=>Array.isArray(t)?t.map(t=>i.parse(t,e)):n(t,{...e,fastpaths:!1}),i.scan=(t,n)=>e(t,n),i.compileRe=(t,e,n=!1,r=!1)=>{if(!0===n)return t.output;const o=e||{},s=o.contains?"":"^",a=o.contains?"":"$";let u=`${s}(?:${t.output})${a}`;t&&!0===t.negated&&(u=`^(?!${u}).*$`);const c=i.toRegex(u,e);return!0===r&&(c.state=t),c},i.makeRe=(t,e={},r=!1,o=!1)=>{if(!t||"string"!=typeof t)throw new TypeError("Expected a non-empty string");let s={negated:!1,fastpaths:!0};return!1===e.fastpaths||"."!==t[0]&&"*"!==t[0]||(s.output=n.fastpaths(t,e)),s.output||(s=n(t,e)),i.compileRe(s,e,r,o)},i.toRegex=(t,e)=>{try{const n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(t){if(e&&!0===e.debug)throw t;return/$^/}},i.constants=s,ft=i}function Et(){return gt?dt:(gt=1,dt=vt())}function Pt(){if(mt)return T;mt=1,Object.defineProperty(T,"__esModule",{value:!0}),T.isAbsolute=T.partitionAbsoluteAndRelative=T.removeDuplicateSlashes=T.matchAny=T.convertPatternsToRe=T.makeRe=T.getPatternParts=T.expandBraceExpansion=T.expandPatternsWithBraceExpansion=T.isAffectDepthOfReadingPattern=T.endsWithSlashGlobStar=T.hasGlobStar=T.getBaseDirectory=T.isPatternRelatedToParentDirectory=T.getPatternsOutsideCurrentDirectory=T.getPatternsInsideCurrentDirectory=T.getPositivePatterns=T.getNegativePatterns=T.isPositivePattern=T.isNegativePattern=T.convertToNegativePattern=T.convertToPositivePattern=T.isDynamicPattern=T.isStaticPattern=void 0;const t=o,e=w(),n=function(){if(yt)return _t;yt=1;const t=s,e=ot(),n=Et(),r=bt(),o=t=>""===t||"./"===t,i=t=>{const e=t.indexOf("{");return e>-1&&t.indexOf("}",e)>-1},a=(t,e,r)=>{e=[].concat(e),t=[].concat(t);let o=new Set,s=new Set,i=new Set,a=0,u=t=>{i.add(t.output),r&&r.onResult&&r.onResult(t)};for(let i=0;i<e.length;i++){let c=n(String(e[i]),{...r,onResult:u},!0),l=c.state.negated||c.state.negatedExtglob;l&&a++;for(let e of t){let t=c(e,!0);(l?!t.isMatch:t.isMatch)&&(l?o.add(t.output):(o.delete(t.output),s.add(t.output)))}}let c=(a===e.length?[...i]:[...s]).filter(t=>!o.has(t));if(r&&0===c.length){if(!0===r.failglob)throw new Error(`No matches found for "${e.join(", ")}"`);if(!0===r.nonull||!0===r.nullglob)return r.unescape?e.map(t=>t.replace(/\\/g,"")):e}return c};return a.match=a,a.matcher=(t,e)=>n(t,e),a.any=a.isMatch=(t,e,r)=>n(e,r)(t),a.not=(t,e,n={})=>{e=[].concat(e).map(String);let r=new Set,o=[],s=new Set(a(t,e,{...n,onResult:t=>{n.onResult&&n.onResult(t),o.push(t.output)}}));for(let t of o)s.has(t)||r.add(t);return[...r]},a.contains=(e,n,r)=>{if("string"!=typeof e)throw new TypeError(`Expected a string: "${t.inspect(e)}"`);if(Array.isArray(n))return n.some(t=>a.contains(e,t,r));if("string"==typeof n){if(o(e)||o(n))return!1;if(e.includes(n)||e.startsWith("./")&&e.slice(2).includes(n))return!0}return a.isMatch(e,n,{...r,contains:!0})},a.matchKeys=(t,e,n)=>{if(!r.isObject(t))throw new TypeError("Expected the first argument to be an object");let o=a(Object.keys(t),e,n),s={};for(let e of o)s[e]=t[e];return s},a.some=(t,e,r)=>{let o=[].concat(t);for(let t of[].concat(e)){let e=n(String(t),r);if(o.some(t=>e(t)))return!0}return!1},a.every=(t,e,r)=>{let o=[].concat(t);for(let t of[].concat(e)){let e=n(String(t),r);if(!o.every(t=>e(t)))return!1}return!0},a.all=(e,r,o)=>{if("string"!=typeof e)throw new TypeError(`Expected a string: "${t.inspect(e)}"`);return[].concat(r).every(t=>n(t,o)(e))},a.capture=(t,e,o)=>{let s=r.isWindows(o),i=n.makeRe(String(t),{...o,capture:!0}).exec(s?r.toPosixSlashes(e):e);if(i)return i.slice(1).map(t=>void 0===t?"":t)},a.makeRe=(...t)=>n.makeRe(...t),a.scan=(...t)=>n.scan(...t),a.parse=(t,r)=>{let o=[];for(let s of[].concat(t||[]))for(let t of e(String(s),r))o.push(n.parse(t,r));return o},a.braces=(t,n)=>{if("string"!=typeof t)throw new TypeError("Expected a string");return n&&!0===n.nobrace||!i(t)?[t]:e(t,n)},a.braceExpand=(t,e)=>{if("string"!=typeof t)throw new TypeError("Expected a string");return a.braces(t,{...e,expand:!0})},a.hasBraces=i,_t=a}(),r=/[*?]|^!/,i=/\[[^[]*]/,a=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/,u=/[!*+?@]\([^(]*\)/,c=/,|\.\./,l=/(?!^)\/{2,}/g;function p(t,e={}){return!f(t,e)}function f(t,e={}){return""!==t&&(!(!1!==e.caseSensitiveMatch&&!t.includes("\\"))||(!!(r.test(t)||i.test(t)||a.test(t))||(!(!1===e.extglob||!u.test(t))||!(!1===e.braceExpansion||!function(t){const e=t.indexOf("{");if(-1===e)return!1;const n=t.indexOf("}",e+1);if(-1===n)return!1;const r=t.slice(e,n);return c.test(r)}(t)))))}function h(t){return t.startsWith("!")&&"("!==t[1]}function d(t){return!h(t)}function g(t){return t.startsWith("..")||t.startsWith("./..")}function _(t){return t.endsWith("/**")}function y(t){const e=n.braces(t,{expand:!0,nodupes:!0,keepEscaping:!0});return e.sort((t,e)=>t.length-e.length),e.filter(t=>""!==t)}function m(t,e){return n.makeRe(t,e)}function R(e){return t.isAbsolute(e)}return T.isStaticPattern=p,T.isDynamicPattern=f,T.convertToPositivePattern=function(t){return h(t)?t.slice(1):t},T.convertToNegativePattern=function(t){return"!"+t},T.isNegativePattern=h,T.isPositivePattern=d,T.getNegativePatterns=function(t){return t.filter(h)},T.getPositivePatterns=function(t){return t.filter(d)},T.getPatternsInsideCurrentDirectory=function(t){return t.filter(t=>!g(t))},T.getPatternsOutsideCurrentDirectory=function(t){return t.filter(g)},T.isPatternRelatedToParentDirectory=g,T.getBaseDirectory=function(t){return e(t,{flipBackslashes:!1})},T.hasGlobStar=function(t){return t.includes("**")},T.endsWithSlashGlobStar=_,T.isAffectDepthOfReadingPattern=function(e){const n=t.basename(e);return _(e)||p(n)},T.expandPatternsWithBraceExpansion=function(t){return t.reduce((t,e)=>t.concat(y(e)),[])},T.expandBraceExpansion=y,T.getPatternParts=function(t,e){let{parts:r}=n.scan(t,Object.assign(Object.assign({},e),{parts:!0}));return 0===r.length&&(r=[t]),r[0].startsWith("/")&&(r[0]=r[0].slice(1),r.unshift("")),r},T.makeRe=m,T.convertPatternsToRe=function(t,e){return t.map(t=>m(t,e))},T.matchAny=function(t,e){return e.some(e=>e.test(t))},T.removeDuplicateSlashes=function(t){return t.replace(l,"/")},T.partitionAbsoluteAndRelative=function(t){const e=[],n=[];for(const r of t)R(r)?e.push(r):n.push(r);return[e,n]},T.isAbsolute=R,T}var At,Ct,xt,Tt={};function Ot(){if(Ct)return At;Ct=1;const t=i.PassThrough,e=Array.prototype.slice;function n(e,r){if(Array.isArray(e))for(let t=0,o=e.length;t<o;t++)e[t]=n(e[t],r);else{if(!e._readableState&&e.pipe&&(e=e.pipe(t(r))),!e._readableState||!e.pause||!e.pipe)throw new Error("Only readable stream can be merged.");e.pause()}return e}return At=function(){const r=[],o=e.call(arguments);let s=!1,i=o[o.length-1];i&&!Array.isArray(i)&&null==i.pipe?o.pop():i={};const a=!1!==i.end,u=!0===i.pipeError;null==i.objectMode&&(i.objectMode=!0);null==i.highWaterMark&&(i.highWaterMark=65536);const c=t(i);function l(){for(let t=0,e=arguments.length;t<e;t++)r.push(n(arguments[t],i));return p(),this}function p(){if(s)return;s=!0;let t=r.shift();if(!t)return void process.nextTick(f);Array.isArray(t)||(t=[t]);let e=t.length+1;function n(){--e>0||(s=!1,p())}function o(t){function e(){t.removeListener("merge2UnpipeEnd",e),t.removeListener("end",e),u&&t.removeListener("error",r),n()}function r(t){c.emit("error",t)}if(t._readableState.endEmitted)return n();t.on("merge2UnpipeEnd",e),t.on("end",e),u&&t.on("error",r),t.pipe(c,{end:!1}),t.resume()}for(let e=0;e<t.length;e++)o(t[e]);n()}function f(){s=!1,c.emit("queueDrain"),a&&c.end()}c.setMaxListeners(0),c.add=l,c.on("unpipe",function(t){t.emit("merge2UnpipeEnd")}),o.length&&l.apply(null,o);return c},At}var $t,wt,kt,Lt={};function Mt(){if($t)return Lt;return $t=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.isEmpty=Lt.isString=void 0,Lt.isString=function(t){return"string"==typeof t},Lt.isEmpty=function(t){return""===t},Lt}function Ht(){if(wt)return p;wt=1,Object.defineProperty(p,"__esModule",{value:!0}),p.string=p.stream=p.pattern=p.path=p.fs=p.errno=p.array=void 0;const t=h();p.array=t;const e=_();p.errno=e;const n=function(){if(y)return m;y=1,Object.defineProperty(m,"__esModule",{value:!0}),m.createDirentFromStats=void 0;class t{constructor(t,e){this.name=t,this.isBlockDevice=e.isBlockDevice.bind(e),this.isCharacterDevice=e.isCharacterDevice.bind(e),this.isDirectory=e.isDirectory.bind(e),this.isFIFO=e.isFIFO.bind(e),this.isFile=e.isFile.bind(e),this.isSocket=e.isSocket.bind(e),this.isSymbolicLink=e.isSymbolicLink.bind(e)}}return m.createDirentFromStats=function(e,n){return new t(e,n)},m}();p.fs=n;const r=b();p.path=r;const o=Pt();p.pattern=o;const s=function(){if(xt)return Tt;xt=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.merge=void 0;const t=Ot();function e(t){t.forEach(t=>t.emit("close"))}return Tt.merge=function(n){const r=t(n);return n.forEach(t=>{t.once("error",t=>r.emit("error",t))}),r.once("close",()=>e(n)),r.once("end",()=>e(n)),r},Tt}();p.stream=s;const i=Mt();return p.string=i,p}var jt,Dt={},Ft={},Nt={},It={},Bt={},Gt={},Wt={},Ut={},Kt={};function Vt(){if(jt)return Kt;function t(t,e){t(e)}function e(t,e){t(null,e)}return jt=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.read=void 0,Kt.read=function(n,r,o){r.fs.lstat(n,(s,i)=>{null===s?i.isSymbolicLink()&&r.followSymbolicLink?r.fs.stat(n,(n,s)=>{if(null!==n)return r.throwErrorOnBrokenSymbolicLink?void t(o,n):void e(o,i);r.markSymbolicLink&&(s.isSymbolicLink=()=>!0),e(o,s)}):e(o,i):t(o,s)})},Kt}var qt,Qt={};var Yt,Xt,zt,Zt,Jt,te,ee,ne={},re={};function oe(){if(Xt)return ne;Xt=1,Object.defineProperty(ne,"__esModule",{value:!0});const t=(Yt||(Yt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createFileSystemAdapter=t.FILE_SYSTEM_ADAPTER=void 0;const e=u;t.FILE_SYSTEM_ADAPTER={lstat:e.lstat,stat:e.stat,lstatSync:e.lstatSync,statSync:e.statSync},t.createFileSystemAdapter=function(e){return void 0===e?t.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},t.FILE_SYSTEM_ADAPTER),e)}}(re)),re);return ne.default=class{constructor(e={}){this._options=e,this.followSymbolicLink=this._getValue(this._options.followSymbolicLink,!0),this.fs=t.createFileSystemAdapter(this._options.fs),this.markSymbolicLink=this._getValue(this._options.markSymbolicLink,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0)}_getValue(t,e){return null!=t?t:e}},ne}function se(){if(zt)return Ut;zt=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.statSync=Ut.stat=Ut.Settings=void 0;const t=Vt(),e=(qt||(qt=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.read=void 0,Qt.read=function(t,e){const n=e.fs.lstatSync(t);if(!n.isSymbolicLink()||!e.followSymbolicLink)return n;try{const n=e.fs.statSync(t);return e.markSymbolicLink&&(n.isSymbolicLink=()=>!0),n}catch(t){if(!e.throwErrorOnBrokenSymbolicLink)return n;throw t}}),Qt),n=oe();function r(t={}){return t instanceof n.default?t:new n.default(t)}return Ut.Settings=n.default,Ut.stat=function(e,n,o){"function"!=typeof n?t.read(e,r(n),o):t.read(e,r(),n)},Ut.statSync=function(t,n){const o=r(n);return e.read(t,o)},Ut}function ie(){if(Jt)return Zt;let t;return Jt=1,Zt="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:c):e=>(t||(t=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0))}var ae,ue={};function ce(){if(ae)return ue;ae=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;const t=process.versions.node.split(".");if(void 0===t[0]||void 0===t[1])throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);const e=Number.parseInt(t[0],10),n=Number.parseInt(t[1],10),r=e>10,o=10===e&&n>=10;return ue.IS_SUPPORT_READDIR_WITH_FILE_TYPES=r||o,ue}var le,pe,fe={},he={};function de(){if(pe)return fe;pe=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.fs=void 0;const t=function(){if(le)return he;le=1,Object.defineProperty(he,"__esModule",{value:!0}),he.createDirentFromStats=void 0;class t{constructor(t,e){this.name=t,this.isBlockDevice=e.isBlockDevice.bind(e),this.isCharacterDevice=e.isCharacterDevice.bind(e),this.isDirectory=e.isDirectory.bind(e),this.isFIFO=e.isFIFO.bind(e),this.isFile=e.isFile.bind(e),this.isSocket=e.isSocket.bind(e),this.isSymbolicLink=e.isSymbolicLink.bind(e)}}return he.createDirentFromStats=function(e,n){return new t(e,n)},he}();return fe.fs=t,fe}var ge,_e,ye={};function me(){if(ge)return ye;return ge=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.joinPathSegments=void 0,ye.joinPathSegments=function(t,e,n){return t.endsWith(n)?t+e:t+n+e},ye}function Re(){if(_e)return Wt;_e=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.readdir=Wt.readdirWithFileTypes=Wt.read=void 0;const t=se(),e=function(){if(ee)return te;ee=1,te=function(e,n){let r,o,s,i=!0;function a(e){function o(){n&&n(e,r),n=null}i?t(o):o()}function u(t,e,n){r[t]=n,(0===--o||e)&&a(e)}Array.isArray(e)?(r=[],o=e.length):(s=Object.keys(e),r={},o=s.length),o?s?s.forEach(function(t){e[t](function(e,n){u(t,e,n)})}):e.forEach(function(t,e){t(function(t,n){u(e,t,n)})}):a(null),i=!1};const t=ie();return te}(),n=ce(),r=de(),o=me();function s(t,n,s){n.fs.readdir(t,{withFileTypes:!0},(i,c)=>{if(null!==i)return void a(s,i);const l=c.map(e=>({dirent:e,name:e.name,path:o.joinPathSegments(t,e.name,n.pathSegmentSeparator)}));if(!n.followSymbolicLinks)return void u(s,l);const p=l.map(t=>function(t,e){return n=>{t.dirent.isSymbolicLink()?e.fs.stat(t.path,(o,s)=>{if(null!==o)return e.throwErrorOnBrokenSymbolicLink?void n(o):void n(null,t);t.dirent=r.fs.createDirentFromStats(t.name,s),n(null,t)}):n(null,t)}}(t,n));e(p,(t,e)=>{null===t?u(s,e):a(s,t)})})}function i(n,s,i){s.fs.readdir(n,(c,l)=>{if(null!==c)return void a(i,c);const p=l.map(e=>{const i=o.joinPathSegments(n,e,s.pathSegmentSeparator);return n=>{t.stat(i,s.fsStatSettings,(t,o)=>{if(null!==t)return void n(t);const a={name:e,path:i,dirent:r.fs.createDirentFromStats(e,o)};s.stats&&(a.stats=o),n(null,a)})}});e(p,(t,e)=>{null===t?u(i,e):a(i,t)})})}function a(t,e){t(e)}function u(t,e){t(null,e)}return Wt.read=function(t,e,r){e.stats||!n.IS_SUPPORT_READDIR_WITH_FILE_TYPES?i(t,e,r):s(t,e,r)},Wt.readdirWithFileTypes=s,Wt.readdir=i,Wt}var Se,be={};var ve,Ee,Pe,Ae={},Ce={};function xe(){return ve||(ve=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createFileSystemAdapter=t.FILE_SYSTEM_ADAPTER=void 0;const e=u;t.FILE_SYSTEM_ADAPTER={lstat:e.lstat,stat:e.stat,lstatSync:e.lstatSync,statSync:e.statSync,readdir:e.readdir,readdirSync:e.readdirSync},t.createFileSystemAdapter=function(e){return void 0===e?t.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},t.FILE_SYSTEM_ADAPTER),e)}}(Ce)),Ce}function Te(){if(Pe)return Gt;Pe=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.Settings=Gt.scandirSync=Gt.scandir=void 0;const t=Re(),e=function(){if(Se)return be;Se=1,Object.defineProperty(be,"__esModule",{value:!0}),be.readdir=be.readdirWithFileTypes=be.read=void 0;const t=se(),e=ce(),n=de(),r=me();function o(t,e){return e.fs.readdirSync(t,{withFileTypes:!0}).map(o=>{const s={dirent:o,name:o.name,path:r.joinPathSegments(t,o.name,e.pathSegmentSeparator)};if(s.dirent.isSymbolicLink()&&e.followSymbolicLinks)try{const t=e.fs.statSync(s.path);s.dirent=n.fs.createDirentFromStats(s.name,t)}catch(t){if(e.throwErrorOnBrokenSymbolicLink)throw t}return s})}function s(e,o){return o.fs.readdirSync(e).map(s=>{const i=r.joinPathSegments(e,s,o.pathSegmentSeparator),a=t.statSync(i,o.fsStatSettings),u={name:s,path:i,dirent:n.fs.createDirentFromStats(s,a)};return o.stats&&(u.stats=a),u})}return be.read=function(t,n){return!n.stats&&e.IS_SUPPORT_READDIR_WITH_FILE_TYPES?o(t,n):s(t,n)},be.readdirWithFileTypes=o,be.readdir=s,be}(),n=function(){if(Ee)return Ae;Ee=1,Object.defineProperty(Ae,"__esModule",{value:!0});const t=o,e=se(),n=xe();return Ae.default=class{constructor(r={}){this._options=r,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=n.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new e.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(t,e){return null!=t?t:e}},Ae}();function r(t={}){return t instanceof n.default?t:new n.default(t)}return Gt.Settings=n.default,Gt.scandir=function(e,n,o){"function"!=typeof n?t.read(e,r(n),o):t.read(e,r(),n)},Gt.scandirSync=function(t,n){const o=r(n);return e.read(t,o)},Gt}var Oe,$e,we,ke={exports:{}};function Le(){if(we)return ke.exports;we=1;var t=$e?Oe:($e=1,Oe=function(t){var e=new t,n=e;return{get:function(){var r=e;return r.next?e=r.next:(e=new t,n=e),r.next=null,r},release:function(t){n.next=t,n=t}}});function e(e,o,s){if("function"==typeof e&&(s=o,o=e,e=null),!(s>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var i=t(r),a=null,u=null,c=0,l=null,p={push:function(t,r){var h=i.get();h.context=e,h.release=f,h.value=t,h.callback=r||n,h.errorHandler=l,c>=s||p.paused?u?(u.next=h,u=h):(a=h,u=h,p.saturated()):(c++,o.call(e,h.value,h.worked))},drain:n,saturated:n,pause:function(){p.paused=!0},paused:!1,get concurrency(){return s},set concurrency(t){if(!(t>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(s=t,!p.paused)for(;a&&c<s;)c++,f()},running:function(){return c},resume:function(){if(!p.paused)return;if(p.paused=!1,null===a)return c++,void f();for(;a&&c<s;)c++,f()},idle:function(){return 0===c&&0===p.length()},length:function(){var t=a,e=0;for(;t;)t=t.next,e++;return e},getQueue:function(){var t=a,e=[];for(;t;)e.push(t.value),t=t.next;return e},unshift:function(t,r){var h=i.get();h.context=e,h.release=f,h.value=t,h.callback=r||n,h.errorHandler=l,c>=s||p.paused?a?(h.next=a,a=h):(a=h,u=h,p.saturated()):(c++,o.call(e,h.value,h.worked))},empty:n,kill:function(){a=null,u=null,p.drain=n},killAndDrain:function(){a=null,u=null,p.drain(),p.drain=n},error:function(t){l=t},abort:function(){var t=a;a=null,u=null;for(;t;){var e=t.next,r=t.callback,o=t.errorHandler,s=t.value,i=t.context;t.value=null,t.callback=n,t.errorHandler=null,o&&o(new Error("abort"),s),r.call(i,new Error("abort")),t.release(t),t=e}p.drain=n}};return p;function f(t){t&&i.release(t);var n=a;n&&c<=s?p.paused?c--:(u===a&&(u=null),a=n.next,n.next=null,o.call(e,n.value,n.worked),null===u&&p.empty()):0===--c&&p.drain()}}function n(){}function r(){this.value=null,this.callback=n,this.next=null,this.release=n,this.context=null,this.errorHandler=null;var t=this;this.worked=function(e,r){var o=t.callback,s=t.errorHandler,i=t.value;t.value=null,t.callback=n,t.errorHandler&&s(e,i),o.call(t.context,e,r),t.release(t)}}return ke.exports=e,ke.exports.promise=function(t,r,o){"function"==typeof t&&(o=r,r=t,t=null);var s=e(t,function(t,e){r.call(this,t).then(function(t){e(null,t)},e)},o),i=s.push,a=s.unshift;return s.push=function(t){var e=new Promise(function(e,n){i(t,function(t,r){t?n(t):e(r)})});return e.catch(n),e},s.unshift=function(t){var e=new Promise(function(e,n){a(t,function(t,r){t?n(t):e(r)})});return e.catch(n),e},s.drained=function(){return new Promise(function(t){process.nextTick(function(){if(s.idle())t();else{var e=s.drain;s.drain=function(){"function"==typeof e&&e(),t(),s.drain=e}}})})},s},ke.exports}var Me,He={};function je(){if(Me)return He;return Me=1,Object.defineProperty(He,"__esModule",{value:!0}),He.joinPathSegments=He.replacePathSegmentSeparator=He.isAppliedFilter=He.isFatalError=void 0,He.isFatalError=function(t,e){return null===t.errorFilter||!t.errorFilter(e)},He.isAppliedFilter=function(t,e){return null===t||t(e)},He.replacePathSegmentSeparator=function(t,e){return t.split(/[/\\]/).join(e)},He.joinPathSegments=function(t,e,n){return""===t?e:t.endsWith(n)?t+e:t+n+e},He}var De,Fe,Ne,Ie={};function Be(){if(De)return Ie;De=1,Object.defineProperty(Ie,"__esModule",{value:!0});const t=je();return Ie.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}},Ie}function Ge(){if(Fe)return Bt;Fe=1,Object.defineProperty(Bt,"__esModule",{value:!0});const t=a,e=Te(),n=Le(),r=je(),o=Be();class s extends o.default{constructor(r,o){super(r,o),this._settings=o,this._scandir=e.scandir,this._emitter=new t.EventEmitter,this._queue=n(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit("end")}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw new Error("The reader is already destroyed");this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(t){this._emitter.on("entry",t)}onError(t){this._emitter.once("error",t)}onEnd(t){this._emitter.once("end",t)}_pushToQueue(t,e){const n={directory:t,base:e};this._queue.push(n,t=>{null!==t&&this._handleError(t)})}_worker(t,e){this._scandir(t.directory,this._settings.fsScandirSettings,(n,r)=>{if(null===n){for(const e of r)this._handleEntry(e,t.base);e(null,void 0)}else e(n,void 0)})}_handleError(t){!this._isDestroyed&&r.isFatalError(this._settings,t)&&(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit("error",t))}_handleEntry(t,e){if(this._isDestroyed||this._isFatalError)return;const n=t.path;void 0!==e&&(t.path=r.joinPathSegments(e,t.name,this._settings.pathSegmentSeparator)),r.isAppliedFilter(this._settings.entryFilter,t)&&this._emitEntry(t),t.dirent.isDirectory()&&r.isAppliedFilter(this._settings.deepFilter,t)&&this._pushToQueue(n,void 0===e?void 0:t.path)}_emitEntry(t){this._emitter.emit("entry",t)}}return Bt.default=s,Bt}var We,Ue={};var Ke,Ve,qe={},Qe={};function Ye(){if(Ve)return qe;Ve=1,Object.defineProperty(qe,"__esModule",{value:!0});const t=function(){if(Ke)return Qe;Ke=1,Object.defineProperty(Qe,"__esModule",{value:!0});const t=Te(),e=je(),n=Be();class r extends n.default{constructor(){super(...arguments),this._scandir=t.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(t,e){this._queue.add({directory:t,base:e})}_handleQueue(){for(const t of this._queue.values())this._handleDirectory(t.directory,t.base)}_handleDirectory(t,e){try{const n=this._scandir(t,this._settings.fsScandirSettings);for(const t of n)this._handleEntry(t,e)}catch(t){this._handleError(t)}}_handleError(t){if(e.isFatalError(this._settings,t))throw t}_handleEntry(t,n){const r=t.path;void 0!==n&&(t.path=e.joinPathSegments(n,t.name,this._settings.pathSegmentSeparator)),e.isAppliedFilter(this._settings.entryFilter,t)&&this._pushToStorage(t),t.dirent.isDirectory()&&e.isAppliedFilter(this._settings.deepFilter,t)&&this._pushToQueue(r,void 0===n?void 0:t.path)}_pushToStorage(t){this._storage.push(t)}}return Qe.default=r,Qe}();return qe.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings)}read(){return this._reader.read()}},qe}var Xe,ze,Ze={};function Je(){if(ze)return Nt;ze=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.Settings=Nt.walkStream=Nt.walkSync=Nt.walk=void 0;const t=function(){if(Ne)return It;Ne=1,Object.defineProperty(It,"__esModule",{value:!0});const t=Ge();return It.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings),this._storage=[]}read(t){this._reader.onError(e=>{!function(t,e){t(e)}(t,e)}),this._reader.onEntry(t=>{this._storage.push(t)}),this._reader.onEnd(()=>{!function(t,e){t(null,e)}(t,this._storage)}),this._reader.read()}},It}(),e=function(){if(We)return Ue;We=1,Object.defineProperty(Ue,"__esModule",{value:!0});const t=i,e=Ge();return Ue.default=class{constructor(n,r){this._root=n,this._settings=r,this._reader=new e.default(this._root,this._settings),this._stream=new t.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(t=>{this._stream.emit("error",t)}),this._reader.onEntry(t=>{this._stream.push(t)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}},Ue}(),n=Ye(),r=function(){if(Xe)return Ze;Xe=1,Object.defineProperty(Ze,"__esModule",{value:!0});const t=o,e=Te();return Ze.default=class{constructor(n={}){this._options=n,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,Number.POSITIVE_INFINITY),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.fsScandirSettings=new e.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(t,e){return null!=t?t:e}},Ze}();function s(t={}){return t instanceof r.default?t:new r.default(t)}return Nt.Settings=r.default,Nt.walk=function(e,n,r){"function"!=typeof n?new t.default(e,s(n)).read(r):new t.default(e,s()).read(n)},Nt.walkSync=function(t,e){const r=s(e);return new n.default(t,r).read()},Nt.walkStream=function(t,n){const r=s(n);return new e.default(t,r).read()},Nt}var tn,en={};function nn(){if(tn)return en;tn=1,Object.defineProperty(en,"__esModule",{value:!0});const t=o,e=se(),n=Ht();return en.default=class{constructor(t){this._settings=t,this._fsStatSettings=new e.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return t.resolve(this._settings.cwd,e)}_makeEntry(t,e){const r={name:e,path:e,dirent:n.fs.createDirentFromStats(e,t)};return this._settings.stats&&(r.stats=t),r}_isFatalError(t){return!n.errno.isEnoentCodeError(t)&&!this._settings.suppressErrors}},en}var rn,on,sn={};function an(){if(rn)return sn;rn=1,Object.defineProperty(sn,"__esModule",{value:!0});const t=i,e=se(),n=Je(),r=nn();class o extends r.default{constructor(){super(...arguments),this._walkStream=n.walkStream,this._stat=e.stat}dynamic(t,e){return this._walkStream(t,e)}static(e,n){const r=e.map(this._getFullEntryPath,this),o=new t.PassThrough({objectMode:!0});o._write=(t,s,i)=>this._getEntry(r[t],e[t],n).then(e=>{null!==e&&n.entryFilter(e)&&o.push(e),t===r.length-1&&o.end(),i()}).catch(i);for(let t=0;t<r.length;t++)o.write(t);return o}_getEntry(t,e,n){return this._getStat(t).then(t=>this._makeEntry(t,e)).catch(t=>{if(n.errorFilter(t))return null;throw t})}_getStat(t){return new Promise((e,n)=>{this._stat(t,this._fsStatSettings,(t,r)=>null===t?e(r):n(t))})}}return sn.default=o,sn}var un,cn,ln,pn={},fn={},hn={},dn={};function gn(){if(cn)return hn;cn=1,Object.defineProperty(hn,"__esModule",{value:!0});const t=function(){if(un)return dn;un=1,Object.defineProperty(dn,"__esModule",{value:!0});const t=Ht();return dn.default=class{constructor(t,e,n){this._patterns=t,this._settings=e,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(const t of this._patterns){const e=this._getPatternSegments(t),n=this._splitSegmentsIntoSections(e);this._storage.push({complete:n.length<=1,pattern:t,segments:e,sections:n})}}_getPatternSegments(e){return t.pattern.getPatternParts(e,this._micromatchOptions).map(e=>t.pattern.isDynamicPattern(e,this._settings)?{dynamic:!0,pattern:e,patternRe:t.pattern.makeRe(e,this._micromatchOptions)}:{dynamic:!1,pattern:e})}_splitSegmentsIntoSections(e){return t.array.splitWhen(e,e=>e.dynamic&&t.pattern.hasGlobStar(e.pattern))}},dn}();class e extends t.default{match(t){const e=t.split("/"),n=e.length,r=this._storage.filter(t=>!t.complete||t.segments.length>n);for(const t of r){const r=t.sections[0];if(!t.complete&&n>r.length)return!0;if(e.every((e,n)=>{const r=t.segments[n];return!(!r.dynamic||!r.patternRe.test(e))||!r.dynamic&&r.pattern===e}))return!0}return!1}}return hn.default=e,hn}var _n,yn={};var mn,Rn={};var Sn,bn,vn,En={};function Pn(){if(bn)return pn;bn=1,Object.defineProperty(pn,"__esModule",{value:!0});const t=o,e=function(){if(ln)return fn;ln=1,Object.defineProperty(fn,"__esModule",{value:!0});const t=Ht(),e=gn();return fn.default=class{constructor(t,e){this._settings=t,this._micromatchOptions=e}getFilter(t,e,n){const r=this._getMatcher(e),o=this._getNegativePatternsRe(n);return e=>this._filter(t,e,r,o)}_getMatcher(t){return new e.default(t,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){const n=e.filter(t.pattern.isAffectDepthOfReadingPattern);return t.pattern.convertPatternsToRe(n,this._micromatchOptions)}_filter(e,n,r,o){if(this._isSkippedByDeep(e,n.path))return!1;if(this._isSkippedSymbolicLink(n))return!1;const s=t.path.removeLeadingDotSegment(n.path);return!this._isSkippedByPositivePatterns(s,r)&&this._isSkippedByNegativePatterns(s,o)}_isSkippedByDeep(t,e){return this._settings.deep!==1/0&&this._getEntryLevel(t,e)>=this._settings.deep}_getEntryLevel(t,e){const n=e.split("/").length;return""===t?n:n-t.split("/").length}_isSkippedSymbolicLink(t){return!this._settings.followSymbolicLinks&&t.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(t,e){return!this._settings.baseNameMatch&&!e.match(t)}_isSkippedByNegativePatterns(e,n){return!t.pattern.matchAny(e,n)}},fn}(),n=function(){if(_n)return yn;_n=1,Object.defineProperty(yn,"__esModule",{value:!0});const t=Ht();return yn.default=class{constructor(t,e){this._settings=t,this._micromatchOptions=e,this.index=new Map}getFilter(e,n){const[r,o]=t.pattern.partitionAbsoluteAndRelative(n),s={positive:{all:t.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:t.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:t.pattern.convertPatternsToRe(o,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return t=>this._filter(t,s)}_filter(e,n){const r=t.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r))return!1;if(this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;const o=this._isMatchToPatternsSet(r,n,e.dirent.isDirectory());return this._settings.unique&&o&&this._createIndexRecord(r),o}_isDuplicateEntry(t){return this.index.has(t)}_createIndexRecord(t){this.index.set(t,void 0)}_onlyFileFilter(t){return this._settings.onlyFiles&&!t.dirent.isFile()}_onlyDirectoryFilter(t){return this._settings.onlyDirectories&&!t.dirent.isDirectory()}_isMatchToPatternsSet(t,e,n){return!!this._isMatchToPatterns(t,e.positive.all,n)&&(!this._isMatchToPatterns(t,e.negative.relative,n)&&!this._isMatchToAbsoluteNegative(t,e.negative.absolute,n))}_isMatchToAbsoluteNegative(e,n,r){if(0===n.length)return!1;const o=t.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(o,n,r)}_isMatchToPatterns(e,n,r){if(0===n.length)return!1;const o=t.pattern.matchAny(e,n);return!o&&r?t.pattern.matchAny(e+"/",n):o}},yn}(),r=function(){if(mn)return Rn;mn=1,Object.defineProperty(Rn,"__esModule",{value:!0});const t=Ht();return Rn.default=class{constructor(t){this._settings=t}getFilter(){return t=>this._isNonFatalError(t)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}},Rn}(),s=function(){if(Sn)return En;Sn=1,Object.defineProperty(En,"__esModule",{value:!0});const t=Ht();return En.default=class{constructor(t){this._settings=t}getTransformer(){return t=>this._transform(t)}_transform(e){let n=e.path;return this._settings.absolute&&(n=t.path.makeAbsolute(this._settings.cwd,n),n=t.path.unixify(n)),this._settings.markDirectories&&e.dirent.isDirectory()&&(n+="/"),this._settings.objectMode?Object.assign(Object.assign({},e),{path:n}):n}},En}();return pn.default=class{constructor(t){this._settings=t,this.errorFilter=new r.default(this._settings),this.entryFilter=new n.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new e.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new s.default(this._settings)}_getRootDirectory(e){return t.resolve(this._settings.cwd,e.base)}_getReaderOptions(t){const e="."===t.base?"":t.base;return{basePath:e,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(e,t.positive,t.negative),entryFilter:this.entryFilter.getFilter(t.positive,t.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}},pn}function An(){if(vn)return Dt;vn=1,Object.defineProperty(Dt,"__esModule",{value:!0});const t=function(){if(on)return Ft;on=1,Object.defineProperty(Ft,"__esModule",{value:!0});const t=Je(),e=nn(),n=an();class r extends e.default{constructor(){super(...arguments),this._walkAsync=t.walk,this._readerStream=new n.default(this._settings)}dynamic(t,e){return new Promise((n,r)=>{this._walkAsync(t,e,(t,e)=>{null===t?n(e):r(t)})})}async static(t,e){const n=[],r=this._readerStream.static(t,e);return new Promise((t,e)=>{r.once("error",e),r.on("data",t=>n.push(t)),r.once("end",()=>t(n))})}}return Ft.default=r,Ft}(),e=Pn();class n extends e.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}async read(t){const e=this._getRootDirectory(t),n=this._getReaderOptions(t);return(await this.api(e,t,n)).map(t=>n.transform(t))}api(t,e,n){return e.dynamic?this._reader.dynamic(t,n):this._reader.static(e.patterns,n)}}return Dt.default=n,Dt}var Cn,xn={};var Tn,On,$n={},wn={};function kn(){if(On)return $n;On=1,Object.defineProperty($n,"__esModule",{value:!0});const t=function(){if(Tn)return wn;Tn=1,Object.defineProperty(wn,"__esModule",{value:!0});const t=se(),e=Je(),n=nn();class r extends n.default{constructor(){super(...arguments),this._walkSync=e.walkSync,this._statSync=t.statSync}dynamic(t,e){return this._walkSync(t,e)}static(t,e){const n=[];for(const r of t){const t=this._getFullEntryPath(r),o=this._getEntry(t,r,e);null!==o&&e.entryFilter(o)&&n.push(o)}return n}_getEntry(t,e,n){try{const n=this._getStat(t);return this._makeEntry(n,e)}catch(t){if(n.errorFilter(t))return null;throw t}}_getStat(t){return this._statSync(t,this._fsStatSettings)}}return wn.default=r,wn}(),e=Pn();class n extends e.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}read(t){const e=this._getRootDirectory(t),n=this._getReaderOptions(t);return this.api(e,t,n).map(n.transform)}api(t,e,n){return e.dynamic?this._reader.dynamic(t,n):this._reader.static(e.patterns,n)}}return $n.default=n,$n}var Ln,Mn,Hn,jn={};async function Dn(t,r){const o=e.dirname(t);await n.promises.mkdir(o,{recursive:!0}),await n.promises.writeFile(t,r,"utf-8")}!function(){if(Hn)return Mn;Hn=1;const t=function(){if(kt)return l;kt=1,Object.defineProperty(l,"__esModule",{value:!0}),l.convertPatternGroupToTask=l.convertPatternGroupsToTasks=l.groupPatternsByBaseDirectory=l.getNegativePatternsAsPositive=l.getPositivePatterns=l.convertPatternsToTasks=l.generate=void 0;const t=Ht();function e(e,n){let r=e;return n.braceExpansion&&(r=t.pattern.expandPatternsWithBraceExpansion(r)),n.baseNameMatch&&(r=r.map(t=>t.includes("/")?t:`**/${t}`)),r.map(e=>t.pattern.removeDuplicateSlashes(e))}function n(e,n,r){const o=[],u=t.pattern.getPatternsOutsideCurrentDirectory(e),c=t.pattern.getPatternsInsideCurrentDirectory(e),l=s(u),p=s(c);return o.push(...i(l,n,r)),"."in p?o.push(a(".",c,n,r)):o.push(...i(p,n,r)),o}function r(e){return t.pattern.getPositivePatterns(e)}function o(e,n){return t.pattern.getNegativePatterns(e).concat(n).map(t.pattern.convertToPositivePattern)}function s(e){return e.reduce((e,n)=>{const r=t.pattern.getBaseDirectory(n);return r in e?e[r].push(n):e[r]=[n],e},{})}function i(t,e,n){return Object.keys(t).map(r=>a(r,t[r],e,n))}function a(e,n,r,o){return{dynamic:o,positive:n,negative:r,base:e,patterns:[].concat(n,r.map(t.pattern.convertToNegativePattern))}}return l.generate=function(s,i){const a=e(s,i),u=e(i.ignore,i),c=r(a),l=o(a,u),p=c.filter(e=>t.pattern.isStaticPattern(e,i)),f=c.filter(e=>t.pattern.isDynamicPattern(e,i)),h=n(p,l,!1),d=n(f,l,!0);return h.concat(d)},l.convertPatternsToTasks=n,l.getPositivePatterns=r,l.getNegativePatternsAsPositive=o,l.groupPatternsByBaseDirectory=s,l.convertPatternGroupsToTasks=i,l.convertPatternGroupToTask=a,l}(),e=An(),n=function(){if(Cn)return xn;Cn=1,Object.defineProperty(xn,"__esModule",{value:!0});const t=i,e=an(),n=Pn();class r extends n.default{constructor(){super(...arguments),this._reader=new e.default(this._settings)}read(e){const n=this._getRootDirectory(e),r=this._getReaderOptions(e),o=this.api(n,e,r),s=new t.Readable({objectMode:!0,read:()=>{}});return o.once("error",t=>s.emit("error",t)).on("data",t=>s.emit("data",r.transform(t))).once("end",()=>s.emit("end")),s.once("close",()=>o.destroy()),s}api(t,e,n){return e.dynamic?this._reader.dynamic(t,n):this._reader.static(e.patterns,n)}}return xn.default=r,xn}(),o=kn(),s=(Ln||(Ln=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;const e=u,n=r,o=Math.max(n.cpus().length,1);t.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:e.lstat,lstatSync:e.lstatSync,stat:e.stat,statSync:e.statSync,readdir:e.readdir,readdirSync:e.readdirSync},t.default=class{constructor(t={}){this._options=t,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,o),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(t,e){return void 0===t?e:t}_getFileSystemMethods(e={}){return Object.assign(Object.assign({},t.DEFAULT_FILE_SYSTEM_ADAPTER),e)}}}(jn)),jn),a=Ht();async function c(t,n){f(t);const r=p(t,e.default,n),o=await Promise.all(r);return a.array.flatten(o)}function p(e,n,r){const o=[].concat(e),i=new s.default(r),a=t.generate(o,i),u=new n(i);return a.map(u.read,u)}function f(t){if(![].concat(t).every(t=>a.string.isString(t)&&!a.string.isEmpty(t)))throw new TypeError("Patterns must be a string (non empty) or an array of strings")}(function(e){function r(t,e){f(t);const n=p(t,o.default,e);return a.array.flatten(n)}function i(t,e){f(t);const r=p(t,n.default,e);return a.stream.merge(r)}var u,c;e.glob=e,e.globSync=r,e.globStream=i,e.async=e,e.sync=r,e.stream=i,e.generateTasks=function(e,n){f(e);const r=[].concat(e),o=new s.default(n);return t.generate(r,o)},e.isDynamicPattern=function(t,e){f(t);const n=new s.default(e);return a.pattern.isDynamicPattern(t,n)},e.escapePath=function(t){return f(t),a.path.escape(t)},e.convertPathToPattern=function(t){return f(t),a.path.convertPathToPattern(t)},(u=e.posix||(e.posix={})).escapePath=function(t){return f(t),a.path.escapePosixPath(t)},u.convertPathToPattern=function(t){return f(t),a.path.convertPosixPathToPattern(t)},(c=e.win32||(e.win32={})).escapePath=function(t){return f(t),a.path.escapeWindowsPath(t)},c.convertPathToPattern=function(t){return f(t),a.path.convertWindowsPathToPattern(t)}})(c||(c={})),Mn=c}();exports.generateReactRoutesHMR=(t,n,r,o)=>{const s=n.split(".")[0],i=(t=>`// Auto-generated by ono-auto-router${t?"\nexport { defineConfig } from './defineConfig'":""}\nexport { routes } from './autoRouter'\n`)(o),a=r?((t,e)=>`\nconst PATH_REPLACEMENTS${e?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst cachedLazyComponents${e?": Record<\n string,\n LazyExoticComponent<ComponentType<unknown>>\n>":""} = {}\n\nconst getConfigFileName = ${e?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${e?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${e?"ts":"js"}'\n }\n return pagePath.replace('index.${e?"ts":"js"}', 'index.config.${e?"ts":"js"}')\n}\n\nconst formatPageModule = (${e?"\n pagesComponent: Record<string, ComponentType<unknown>>,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${e?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${e?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${e?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${e?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${e?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${e?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${e?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${e?"ts":"js"}', 'index.${e?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${e?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${e?"ts":"js"}', 'index.${e?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${e?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${e?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${e?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${t}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${t}', '').replace('/index.config.${e?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${e?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${e?": Record<string, unknown>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${e?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${e?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${e?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst LazyComponent = ({\n Element\n}${e?": {\n Element: LazyExoticComponent<ComponentType<unknown>>\n}":""}) => {\n return (\n <Suspense>\n <Element />\n </Suspense>\n )\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent({\n ...import.meta.glob('/${t}/**/*.${e?"tsx":"jsx"}')${e?" as PagesComponentType":""}\n })\n\n const pagesString = getFileDefault({\n ...import.meta.glob('/${t}/**/*.${e?"tsx":"jsx"}', {\n eager: true\n })\n })${e?" as Record<string, ComponentType<unknown>>":""}\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${t}/**/*.config.${e?"ts":"js"}', {\n eager: true\n })\n })${e?" as Record<string, PageConfig>":""}\n\n const result${e?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesString, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = page?.path || getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n let Component${e?": MyRouteObject['element']":""}\n if (!cachedLazyComponents[compPath]) {\n cachedLazyComponents[compPath] = lazy(pagesComponent[compPath])\n }\n Component = <LazyComponent Element={cachedLazyComponents[compPath]} />\n\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: Component\n })\n }\n\n return result\n}`)(t,o):((t,e)=>`\nconst PATH_REPLACEMENTS${e?": Record<string, string>":""} = {\n '/home': '/',\n '/root': '/'\n}\n\nconst getConfigFileName = ${e?"(pagePath: string): string":"(pagePath)"} => {\n if (pagePath.endsWith('.${e?"tsx":"jsx"}')) {\n return pagePath.slice(0, -4) + '.config.${e?"ts":"js"}'\n }\n return pagePath.replace('index.${e?"ts":"js"}', 'index.config.${e?"ts":"js"}')\n}\n\nconst formatPageModule = (${e?"\n pagesComponent: PagesComponentType,\n pagesModule: Record<string, PageConfig>\n":"pagesComponent, pagesModule"})${e?": [string, PageConfig][]":""} => {\n return Object.keys(pagesComponent).map(page => {\n const configKey = getConfigFileName(page)\n return [configKey, pagesModule[configKey] || {}]\n })\n}\n\nconst normalizePath = ${e?"(pathStr: string): string":"(pathStr)"} => {\n if (PATH_REPLACEMENTS[pathStr]) {\n return PATH_REPLACEMENTS[pathStr]\n }\n\n const lowerPath = pathStr.toLowerCase()\n if (lowerPath === '/notfound' || pathStr === '/404') {\n return '/*'\n }\n\n return pathStr\n}\n\nconst getBasename = ${e?"(filePath: string, ext?: string): string":"(filePath, ext)"} => {\n const parts = filePath.split('/')\n const lastPart = parts[parts.length - 1]\n if (ext && lastPart.endsWith(ext)) {\n return lastPart.slice(0, -ext.length)\n }\n return lastPart\n}\n\nconst getDirname = ${e?"(filePath: string): string":"(filePath)"} => {\n const parts = filePath.split('/')\n parts.pop()\n return parts.join('/')\n}\n\nconst getCompPathFromConfig = ${e?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${e?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${e?"ts":"js"}')\n if (fileName === 'index') {\n return configPath.replace('index.config.${e?"ts":"js"}', 'index.${e?"tsx":"jsx"}')\n }\n return configPath.slice(0, -10) + '.${e?"tsx":"jsx"}'\n }\n return configPath.replace('index.config.${e?"ts":"js"}', 'index.${e?"tsx":"jsx"}')\n}\n\nconst getRawPathFromConfig = ${e?"(configPath: string): string":"(configPath)"} => {\n if (configPath.endsWith('.config.${e?"ts":"js"}')) {\n const fileName = getBasename(configPath, '.config.${e?"ts":"js"}')\n const dirPath = getDirname(configPath).replace('/${t}', '')\n if (fileName === 'index') {\n return dirPath || '/'\n }\n return dirPath ? dirPath + '/' + fileName : '/' + fileName\n }\n return (\n configPath.replace('/${t}', '').replace('/index.config.${e?"ts":"js"}', '') || '/'\n )\n}\n\nconst getFileDefault = ${e?"(modules: Record<string, { default: unknown }>)":"(modules)"} => {\n const result${e?": PagesComponentType | Record<string, PageConfig>":""} = {}\n\n for (const [path, module] of Object.entries(modules)) {\n if ('default' in module) {\n result[path] = module.default${e?" as ComponentType<unknown> | PageConfig":""}\n }\n }\n\n return result\n}\n\nconst filterUnComponent = ${e?"(pagesComponent: PagesComponentType)":"(pagesComponent)"} => {\n const result${e?": PagesComponentType":""} = {}\n\n for (const key of Object.keys(pagesComponent)) {\n if (!key.includes('.config.${e?"tsx":"jsx"}')) {\n result[key] = pagesComponent[key]\n }\n }\n\n return result\n}\n\nconst createBaseRoutes = () => {\n const pagesComponent = filterUnComponent(\n getFileDefault({\n ...import.meta.glob('/${t}/**/*.${e?"tsx":"jsx"}', { eager: true })\n })${e?" as PagesComponentType":""}\n )\n\n const pagesModule = getFileDefault({\n ...import.meta.glob('/${t}/**/*.config.${e?"ts":"js"}', {\n eager: true\n })\n })${e?" as Record<string, PageConfig>":""}\n\n const result${e?": (MyRouteObject & { isRoot?: boolean })[]":""} = []\n\n for (const [pagePath, page] of formatPageModule(pagesComponent, pagesModule)) {\n const compPath = getCompPathFromConfig(pagePath)\n\n if (!pagesComponent[compPath]) continue\n\n const rawPath = page?.path || getRawPathFromConfig(pagePath) || '/'\n const processedPath = replaceBracketsWithColon(rawPath)\n const routePath = normalizePath(processedPath)\n\n const Component = pagesComponent[compPath]\n result.push({\n ...page,\n path: routePath,\n type: page?.type,\n isRoot: processedPath === '/root',\n element: <Component />\n })\n }\n\n return result\n}`)(t,o),u=(t=>`\nconst processRoute = ${t?"(route: MyRouteObject): MyRouteObject":"(route)"} =>\n cleanIsRoot(removeEmptyChildren(route))\n\nconst processRoutes = ${t?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} =>\n buildRouteTree(routes).map(processRoute)\n\nconst handleRootRoute = ${t?"(routes: (MyRouteObject & { isRoot?: boolean })[])":"(routes)"} => {\n let rootRoute${t?": MyRouteObject | undefined":" = undefined"}\n let homeRoute${t?": MyRouteObject | undefined":" = undefined"}\n let notFoundRoute${t?": MyRouteObject | undefined":" = undefined"}\n const filteredRoutes${t?": MyRouteObject[]":""} = []\n\n for (const route of routes) {\n if (route.isRoot) {\n if (rootRoute)\n throw new Error('There cannot be multiple root routes in a route')\n rootRoute = route\n } else if (route.path === '/') {\n homeRoute = route\n } else if (route.path === '/*') {\n notFoundRoute = route\n } else {\n filteredRoutes.push(route)\n }\n }\n\n if (hasDuplicateProperty(filteredRoutes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n const children = [\n homeRoute && { ...homeRoute, index: true },\n ...processRoutes(filteredRoutes)\n ].filter(${t?"(route): route is NonNullable<typeof route> => Boolean(route)":"Boolean"})\n\n const result${t?": MyRouteObject[]":""} = []\n\n if (rootRoute) {\n result.push(cleanIsRoot({ ...rootRoute, children }))\n }\n\n if (notFoundRoute) {\n result.push(cleanIsRoot(notFoundRoute))\n }\n\n return result\n}\n\nconst formatRoutes = (\n routes${t?": (MyRouteObject & { isRoot?: boolean })[]":""}\n) => {\n if (routes.some(r => r.isRoot)) return handleRootRoute(routes)\n\n if (hasDuplicateProperty(routes, 'path'))\n throw new Error('There cannot be duplicate paths in a route')\n\n return processRoutes(routes)\n}`)(o),c=(t=>`\nconst processSingleRoute = ${t?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n if (route.index) {\n return route\n }\n\n if (route.type !== 'wrap') {\n const { path: routePath, children, ...extraProps } = route\n const hasExtraProps = Object.keys(extraProps).length > 0\n\n if (hasExtraProps) {\n const indexRoute${t?": MyRouteObject":""} = {\n path: '',\n index: true,\n ...extraProps\n }\n\n return {\n path: routePath,\n children: [indexRoute, ...(children || []).map(processSingleRoute)]\n }\n }\n }\n\n if (route.children) {\n return {\n ...route,\n children: route.children.map(processSingleRoute)\n }\n }\n\n return route\n}\n\nconst formatRouteTree = ${t?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n return routes.map(processSingleRoute)\n}\n\nconst buildTreeStructure = ${t?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const routeMap = new Map${t?"<string, MyRouteObject>":""}()\n const rootRoutes${t?": MyRouteObject[]":""} = []\n const pathPartsCache = new Map${t?"<string, string[]>":""}()\n\n const getPathParts = ${t?"(pathStr: string): string[]":"(pathStr)"} => {\n let parts = pathPartsCache.get(pathStr)\n if (parts === undefined) {\n parts = pathStr === '/' ? [] : pathStr.split('/').filter(Boolean)\n pathPartsCache.set(pathStr, parts)\n }\n return parts\n }\n\n const sortedRoutes = routes\n .slice()\n .sort((a, b) => a.path.length - b.path.length)\n\n for (const route of sortedRoutes) {\n const routePath = route.path\n const pathParts = getPathParts(routePath)\n const currentRoute = { ...route, children: [] }\n routeMap.set(routePath, currentRoute)\n\n if (pathParts.length <= 1) {\n rootRoutes.push(currentRoute)\n continue\n }\n\n const parentPath = '/' + pathParts.slice(0, -1).join('/')\n const parentRoute = routeMap.get(parentPath)\n\n if (parentRoute) {\n currentRoute.path = pathParts[pathParts.length - 1]\n parentRoute.children${t?"!":""}.push(currentRoute)\n } else {\n rootRoutes.push(currentRoute)\n }\n }\n\n return rootRoutes\n}\n\nconst buildRouteTree = ${t?"(routes: MyRouteObject[]): MyRouteObject[]":"(routes)"} => {\n const treeStructure = buildTreeStructure(routes)\n return formatRouteTree(treeStructure)\n}`)(o),l=(t=>`\nconst cleanIsRoot = ${t?"(route: RouteWithIsRoot): MyRouteObject":"(route)"} => {\n const { isRoot, type, children, ...rest } = route${t?" as RouteWithIsRoot & {\n type?: unknown\n }":""}\n\n if (!children?.length) {\n return rest\n }\n\n return {\n ...rest,\n children: children.map(cleanIsRoot)\n }\n}`)(o),p=(t=>`\nconst removeEmptyChildren = ${t?"(route: MyRouteObject): MyRouteObject":"(route)"} => {\n const { children } = route\n\n if (!children?.length) {\n const { children: _, ...rest } = route\n return rest\n }\n\n const processedChildren = children.map(removeEmptyChildren)\n\n if (route.type === 'wrap') {\n return { ...route, children: processedChildren }\n }\n\n const { path, element, type, children: _, ...rest } = route\n\n if (!element) {\n return { path, ...rest, children: processedChildren }\n }\n\n return {\n path,\n children: [\n { index: true, element, ...rest }${t?" as MyRouteObject":""},\n ...processedChildren\n ]\n }\n}`)(o),f=o?"// Auto-generated by ono-auto-router\nimport type { PageConfig } from './autoRouter'\nexport const defineConfig = (config: PageConfig) => config\n":"",h=(t=>`\nconst getRoutes = () => {\n const baseRoutes = createBaseRoutes()\n const formattedRoutes = formatRoutes(baseRoutes)${t?" as RouteObject[]":""}\n return formattedRoutes\n}\n\nexport const routes = getRoutes()`)(o),d=((t,e)=>t?`\n${e?"import {\n lazy,\n Suspense,\n type ComponentType,\n type LazyExoticComponent\n} from 'react'":"import type { ComponentType } from 'react'"}\nimport type { RouteObject } from 'react-router'\n\n${e?"type PagesComponentType = Record<\n string,\n () => Promise<{ default: ComponentType<unknown> }>\n>":"type PagesComponentType = Record<string, ComponentType<unknown>>"}\n\ninterface MyRouteObject extends Omit<RouteObject, 'path' | 'children'> {\n path: string\n type?: 'single' | 'wrap'\n children?: MyRouteObject[]\n}\n\ntype RouteWithIsRoot = MyRouteObject & { isRoot?: boolean }\n\nexport type PageConfig = Partial<\n Omit<MyRouteObject, 'Component' | 'element' | 'children'>\n>`:e?"\nimport { lazy, Suspense } from 'react'\n":"")(o,r),g=(t=>`\nconst hasDuplicateProperty = ${t?"<T, K extends keyof T>(items: T[], propName: K)":"(items, propName)"} => {\n const seenValues = new Set()\n return items.some(item => {\n if (seenValues.has(item[propName])) {\n return true\n }\n seenValues.add(item[propName])\n return false\n })\n}\n\nconst replaceBracketsWithColon = ${t?"(str: string)":"(str)"} => {\n return str.replace(/\\[([^\\]]+)\\]/g, ':$1').replace('.tsx', '')\n}`)(o),_=((t,e,n,r,o,s,i,a)=>`// Auto-generated by ono-auto-router${t}${e}${n}${r}${o}${s}${i}${a}\n`)(d,g,p,l,c,u,a,h);o?(Dn(e.resolve(s,"./index.ts"),i),Dn(e.resolve(s,"./autoRouter.tsx"),_),Dn(e.resolve(s,"./defineConfig.ts"),f)):Dn(n,_)};
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./core-Nna-MKEw.js");exports.generateReactRoutesHMR=e.generateReactRoutesHMR;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const generateReactRoutesHMR: (pagesDir: string, routesPath: string, lazy: boolean, useTs: boolean) => void;
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
export declare const generateReactRoutesHMR: (pagesDir: string, routesPath: string, lazy: boolean, useTs: boolean) => void;
|
|
2
|
+
|
|
3
|
+
export { }
|