@create-ui/cli 0.5.3 → 0.5.5

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.
@@ -1,6 +1,6 @@
1
1
  import {m,l,d,b,a,c,n,s,o,q as q$1,r,w as w$1,e}from'./chunk-Y7WZRQWW.js';import {Project,SyntaxKind,ScriptKind}from'ts-morph';import {z as z$1}from'zod';import*as h from'path';import h__default,{basename}from'path';import*as z from'fs/promises';import {tmpdir,homedir}from'os';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import me from'fast-glob';import pe from'fs-extra';import {existsSync,statSync,promises}from'fs';import Wt from'ora';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Bt from'@babel/plugin-transform-typescript';import*as he from'recast';import sr from'prompts';import q from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import Pr from'node-fetch';import {createHash}from'crypto';var Ke=async({sourceFile:e,config:t})=>{let s=t.menuColor==="inverted"?"dark":"";for(let n of e.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(n.getNameNode().getText()!=="className")continue;let o=n.getInitializer();if(!o)continue;let a=o.getText();if(!a.includes("cn-menu-target"))continue;let l=a.replace(/cn-menu-target/g,s);s||(l=l.replace(/\s{2,}/g," "),l=l.replace(/"\s+/g,'"'),l=l.replace(/\s+"/g,'"'),l=l.replace(/,\s*""\s*,/g,","),l=l.replace(/\(\s*""\s*,/g,"("),l=l.replace(/,\s*""\s*\)/g,")")),n.setInitializer(l);}return e};var U={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},O=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||U.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,context:this.context,suggestion:this.suggestion,timestamp:this.timestamp,stack:this.stack}}},se=class extends O{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:U.NOT_FOUND,statusCode:404,cause:s,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},ne=class extends O{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:U.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},ie=class extends O{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:U.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},oe=class extends O{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,l="Check your network connection and try again.";s===404?l="The requested resource was not found. Check the URL or item name.":s===500?l="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(l="There was a client error. Check your request parameters.");super(a,{code:U.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:l});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},Z=class extends O{constructor(r,s){super(`Failed to read local registry file: ${r}`,{code:U.LOCAL_FILE_ERROR,cause:s,context:{filePath:r},suggestion:"Check if the file exists and you have read permissions."});this.filePath=r;this.name="RegistryLocalFileError";}},$=class extends O{constructor(r,s){let n=`Failed to parse registry item: ${r}`;s instanceof z$1.ZodError&&(n=`Failed to parse registry item: ${r}
2
2
  ${s.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
3
- `)}`);super(n,{code:U.PARSE_ERROR,cause:s,context:{item:r},suggestion:"The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See https://createui.co/schema/registry-item.json."});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError};var ae=process.env.REGISTRY_URL??"https://createui.co/r",gt=[{name:"indigo",label:"Indigo"},{name:"lime",label:"Lime"},{name:"green",label:"Green"},{name:"red",label:"Red"},{name:"orange",label:"Orange"},{name:"yellow",label:"Yellow"},{name:"cyan",label:"Cyan"},{name:"blue",label:"Blue"}],dt=gt,ht=[{name:"gray",label:"Gray"},{name:"slate",label:"Slate"},{name:"zinc",label:"Zinc"},{name:"base",label:"Base"},{name:"stone",label:"Stone"}];dt.map(e=>e.name);var Mr=ht.map(e=>e.name),Br="gray",ce=[{name:"v1",label:"Default (Geist + JetBrains Mono)"}],Gr=ce.map(e=>e.name),Hr="v1";var Jr=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];var P={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:"https://createui.co/docs/installation",tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation"}}};var T={error:red,warn:yellow,info:cyan,success:green};async function k(e,t){return createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"])}var cs="@/components",ls="@/lib/utils",fs="app/globals.css",ps="tailwind.config.js";var It=cosmiconfig("components",{searchPlaces:["components.json"]});async function le(e){let t=await St(e);return t?(t.iconLibrary||(t.iconLibrary="lucide"),await Ee(e,t)):null}async function Ee(e,t){let r=await loadConfig(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());return b.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?h__default.resolve(e,t.tailwind.config):"",tailwindCss:h__default.resolve(e,t.tailwind.css),utils:await k(t.aliases.utils,r),components:await k(t.aliases.components,r),ui:t.aliases.ui?await k(t.aliases.ui,r):h__default.resolve(await k(t.aliases.components,r)??e,"ui"),lib:t.aliases.lib?await k(t.aliases.lib,r):h__default.resolve(await k(t.aliases.utils,r)??e,".."),hooks:t.aliases.hooks?await k(t.aliases.hooks,r):h__default.resolve(await k(t.aliases.components,r)??e,"..","hooks")}})}async function St(e){try{let t=await It.search(e);return t?a.parse(t.config):null}catch{let r=`${e}/components.json`;throw new Error(`Invalid configuration found in ${T.info(r)}.`)}}async function ms(e){let t={};for(let s of Object.keys(e.aliases)){if(!Tt(s,e))continue;let n=e.resolvedPaths[s],i=await Pt(e.resolvedPaths.cwd,n);if(!i){t[s]=e;continue}t[s]=await le(i);}let r=c.safeParse(t);return r.success?r.data:null}async function Pt(e,t){let r=kt(e,t),s=h__default.relative(r,t),i=(await me.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>h__default.dirname(o)).find(o=>s.startsWith(o));return i?h__default.join(r,i):null}function Tt(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function kt(e,t){let r=e.split(h__default.sep),s=t.split(h__default.sep),n=[];for(let i=0;i<Math.min(r.length,s.length)&&r[i]===s[i];i++)n.push(r[i]);return n.join(h__default.sep)}function Me(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:"",tailwindCss:"",utils:"",components:"",ui:"",lib:"",hooks:""},tailwind:{config:"",css:"",baseColor:"",cssVariables:false},rsc:false,tsx:true,aliases:{components:"",utils:""}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths||{}},tailwind:{...t.tailwind,...e.tailwind||{}},aliases:{...t.aliases,...e.aliases||{}}}:t}function Ce(e="",t=true){let r=h__default.join(e,"package.json");return pe.readJSONSync(r,{throws:t})}var ue=["**/node_modules/**",".next","public","dist","build"];z$1.object({compilerOptions:z$1.object({paths:z$1.record(z$1.string().or(z$1.array(z$1.string())))})});async function B(e){let[t,r,s,n,i,o,a,l]=await Promise.all([me.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:ue}),pe.pathExists(h__default.resolve(e,"src")),Lt(e),At(e),Dt(e),$t(e),_t(e),Ce(e,false)]),f=await pe.pathExists(h__default.resolve(e,`${r?"src/":""}app`)),c={framework:P.manual,isSrcDir:r,isRSC:false,isTsx:s,tailwindConfigFile:n,tailwindCssFile:i,tailwindVersion:o,frameworkVersion:null,aliasPrefix:a};if(t.find(m=>m.startsWith("next.config."))?.length)return c.framework=f?P["next-app"]:P["next-pages"],c.isRSC=f,c.frameworkVersion=await Ot(c.framework,l),c;if(t.find(m=>m.startsWith("astro.config."))?.length)return c.framework=P.astro,c;if(t.find(m=>m.startsWith("gatsby-config."))?.length)return c.framework=P.gatsby,c;if(t.find(m=>m.startsWith("composer.json"))?.length)return c.framework=P.laravel,c;if(Object.keys(l?.dependencies??{}).find(m=>m.startsWith("@remix-run/")))return c.framework=P.remix,c;if([...Object.keys(l?.dependencies??{}),...Object.keys(l?.devDependencies??{})].find(m=>m.startsWith("@tanstack/react-start")))return c.framework=P["tanstack-start"],c;if(t.find(m=>m.startsWith("react-router.config."))?.length)return c.framework=P["react-router"],c;if(t.find(m=>m.startsWith("vite.config."))?.length)return c.framework=P.vite,c;let d=t.find(m=>m.startsWith("app.config"));return d?.length&&(await pe.readFile(h__default.resolve(e,d),"utf8")).includes("defineConfig")?(c.framework=P.vite,c):(l?.dependencies?.expo&&(c.framework=P.expo),c)}async function Ot(e,t){if(!t||!["next-app","next-pages"].includes(e.name))return null;let r=t.dependencies?.next||t.devDependencies?.next;if(!r)return null;let s=r.match(/^[\^~]?(\d+\.\d+\.\d+)/);if(s)return s[1];let n=r.match(/(\d+\.\d+\.\d+)/);return n?n[1]:r}async function $t(e){let[t,r]=await Promise.all([Ce(e,false),le(e)]);return r?.tailwind?.config===""?"v4":!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:"v4"}async function Dt(e){let t=await me.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:ue});if(!t.length)return null;for(let r of t){let s=await pe.readFile(h__default.resolve(e,r),"utf8");if(s.includes('@import "tailwindcss"')||s.includes("@import 'tailwindcss'"))return r}return null}async function At(e){let t=await me.glob("tailwind.config.*",{cwd:e,deep:3,ignore:ue});return t.length?t[0]:null}async function _t(e){let t=await loadConfig(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[r,s]of Object.entries(t.paths))if(s.includes("./*")||s.includes("./src/*")||s.includes("./app/*")||s.includes("./resources/js/*"))return r.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function Lt(e){return (await me.glob("tsconfig.*",{cwd:e,deep:1,ignore:ue})).length>0}async function Ts(e,t=null){let[r,s]=await Promise.all([le(e),t?Promise.resolve(t):B(e)]);if(r)return r;if(!s||!s.tailwindCssFile)return null;let n={$schema:"https://createui.co/schema.json",rsc:s.isRSC,tsx:s.isTsx,tailwind:{config:s.tailwindConfigFile??"",baseColor:"zinc",css:s.tailwindCssFile,cssVariables:true,prefix:""},iconLibrary:"lucide",aliases:{components:`${s.aliasPrefix}/components`,ui:`${s.aliasPrefix}/components/ui`,hooks:`${s.aliasPrefix}/hooks`,lib:`${s.aliasPrefix}/lib`,utils:`${s.aliasPrefix}/lib/utils`}};return await Ee(e,n)}function Be(e,t,r={}){let{ignoreImports:s=false}=r,n=e.replace(/\r\n/g,`
3
+ `)}`);super(n,{code:U.PARSE_ERROR,cause:s,context:{item:r},suggestion:"The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See https://createui.co/schema/registry-item.json."});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError};var ae=process.env.REGISTRY_URL??"https://createui.co/r",gt=[{name:"indigo",label:"Indigo"},{name:"lime",label:"Lime"},{name:"green",label:"Green"},{name:"red",label:"Red"},{name:"orange",label:"Orange"},{name:"yellow",label:"Yellow"},{name:"cyan",label:"Cyan"},{name:"blue",label:"Blue"}],dt=gt,ht=[{name:"gray",label:"Gray"},{name:"slate",label:"Slate"},{name:"zinc",label:"Zinc"},{name:"base",label:"Base"},{name:"stone",label:"Stone"}];dt.map(e=>e.name);var Mr=ht.map(e=>e.name),Br="gray",ce=[{name:"v1",label:"Default (Geist + JetBrains Mono)"}],Gr=ce.map(e=>e.name),Hr="v1";var Jr=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];var P={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:"https://createui.co/docs/installation",tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation"}}};var T={error:red,warn:yellow,info:cyan,success:green};async function k(e,t){return createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"])}var cs="@/components",ls="@/lib/utils",fs="app/globals.css",ps="tailwind.config.js";var It=cosmiconfig("components",{searchPlaces:["components.json"]});async function le(e){let t=await St(e);return t?(t.iconLibrary||(t.iconLibrary="createui"),await Ee(e,t)):null}async function Ee(e,t){let r=await loadConfig(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());return b.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?h__default.resolve(e,t.tailwind.config):"",tailwindCss:h__default.resolve(e,t.tailwind.css),utils:await k(t.aliases.utils,r),components:await k(t.aliases.components,r),ui:t.aliases.ui?await k(t.aliases.ui,r):h__default.resolve(await k(t.aliases.components,r)??e,"ui"),lib:t.aliases.lib?await k(t.aliases.lib,r):h__default.resolve(await k(t.aliases.utils,r)??e,".."),hooks:t.aliases.hooks?await k(t.aliases.hooks,r):h__default.resolve(await k(t.aliases.components,r)??e,"..","hooks")}})}async function St(e){try{let t=await It.search(e);return t?a.parse(t.config):null}catch{let r=`${e}/components.json`;throw new Error(`Invalid configuration found in ${T.info(r)}.`)}}async function ms(e){let t={};for(let s of Object.keys(e.aliases)){if(!Tt(s,e))continue;let n=e.resolvedPaths[s],i=await Pt(e.resolvedPaths.cwd,n);if(!i){t[s]=e;continue}t[s]=await le(i);}let r=c.safeParse(t);return r.success?r.data:null}async function Pt(e,t){let r=kt(e,t),s=h__default.relative(r,t),i=(await me.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>h__default.dirname(o)).find(o=>s.startsWith(o));return i?h__default.join(r,i):null}function Tt(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function kt(e,t){let r=e.split(h__default.sep),s=t.split(h__default.sep),n=[];for(let i=0;i<Math.min(r.length,s.length)&&r[i]===s[i];i++)n.push(r[i]);return n.join(h__default.sep)}function Me(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:"",tailwindCss:"",utils:"",components:"",ui:"",lib:"",hooks:""},tailwind:{config:"",css:"",baseColor:"",cssVariables:false},rsc:false,tsx:true,aliases:{components:"",utils:""}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths||{}},tailwind:{...t.tailwind,...e.tailwind||{}},aliases:{...t.aliases,...e.aliases||{}}}:t}function Ce(e="",t=true){let r=h__default.join(e,"package.json");return pe.readJSONSync(r,{throws:t})}var ue=["**/node_modules/**",".next","public","dist","build"];z$1.object({compilerOptions:z$1.object({paths:z$1.record(z$1.string().or(z$1.array(z$1.string())))})});async function B(e){let[t,r,s,n,i,o,a,l]=await Promise.all([me.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:ue}),pe.pathExists(h__default.resolve(e,"src")),Lt(e),At(e),Dt(e),$t(e),_t(e),Ce(e,false)]),f=await pe.pathExists(h__default.resolve(e,`${r?"src/":""}app`)),c={framework:P.manual,isSrcDir:r,isRSC:false,isTsx:s,tailwindConfigFile:n,tailwindCssFile:i,tailwindVersion:o,frameworkVersion:null,aliasPrefix:a};if(t.find(m=>m.startsWith("next.config."))?.length)return c.framework=f?P["next-app"]:P["next-pages"],c.isRSC=f,c.frameworkVersion=await Ot(c.framework,l),c;if(t.find(m=>m.startsWith("astro.config."))?.length)return c.framework=P.astro,c;if(t.find(m=>m.startsWith("gatsby-config."))?.length)return c.framework=P.gatsby,c;if(t.find(m=>m.startsWith("composer.json"))?.length)return c.framework=P.laravel,c;if(Object.keys(l?.dependencies??{}).find(m=>m.startsWith("@remix-run/")))return c.framework=P.remix,c;if([...Object.keys(l?.dependencies??{}),...Object.keys(l?.devDependencies??{})].find(m=>m.startsWith("@tanstack/react-start")))return c.framework=P["tanstack-start"],c;if(t.find(m=>m.startsWith("react-router.config."))?.length)return c.framework=P["react-router"],c;if(t.find(m=>m.startsWith("vite.config."))?.length)return c.framework=P.vite,c;let d=t.find(m=>m.startsWith("app.config"));return d?.length&&(await pe.readFile(h__default.resolve(e,d),"utf8")).includes("defineConfig")?(c.framework=P.vite,c):(l?.dependencies?.expo&&(c.framework=P.expo),c)}async function Ot(e,t){if(!t||!["next-app","next-pages"].includes(e.name))return null;let r=t.dependencies?.next||t.devDependencies?.next;if(!r)return null;let s=r.match(/^[\^~]?(\d+\.\d+\.\d+)/);if(s)return s[1];let n=r.match(/(\d+\.\d+\.\d+)/);return n?n[1]:r}async function $t(e){let[t,r]=await Promise.all([Ce(e,false),le(e)]);return r?.tailwind?.config===""?"v4":!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:"v4"}async function Dt(e){let t=await me.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:ue});if(!t.length)return null;for(let r of t){let s=await pe.readFile(h__default.resolve(e,r),"utf8");if(s.includes('@import "tailwindcss"')||s.includes("@import 'tailwindcss'"))return r}return null}async function At(e){let t=await me.glob("tailwind.config.*",{cwd:e,deep:3,ignore:ue});return t.length?t[0]:null}async function _t(e){let t=await loadConfig(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[r,s]of Object.entries(t.paths))if(s.includes("./*")||s.includes("./src/*")||s.includes("./app/*")||s.includes("./resources/js/*"))return r.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function Lt(e){return (await me.glob("tsconfig.*",{cwd:e,deep:1,ignore:ue})).length>0}async function Ts(e,t=null){let[r,s]=await Promise.all([le(e),t?Promise.resolve(t):B(e)]);if(r)return r;if(!s||!s.tailwindCssFile)return null;let n={$schema:"https://createui.co/schema.json",rsc:s.isRSC,tsx:s.isTsx,tailwind:{config:s.tailwindConfigFile??"",baseColor:"zinc",css:s.tailwindCssFile,cssVariables:true,prefix:""},iconLibrary:"createui",aliases:{components:`${s.aliasPrefix}/components`,ui:`${s.aliasPrefix}/components/ui`,hooks:`${s.aliasPrefix}/hooks`,lib:`${s.aliasPrefix}/lib`,utils:`${s.aliasPrefix}/lib/utils`}};return await Ee(e,n)}function Be(e,t,r={}){let{ignoreImports:s=false}=r,n=e.replace(/\r\n/g,`
4
4
  `).trim(),i=t.replace(/\r\n/g,`
5
5
  `).trim();if(n===i)return true;if(!s)return false;let o=/^(import\s+(?:type\s+)?(?:\*\s+as\s+\w+|\{[^}]*\}|\w+)?(?:\s*,\s*(?:\{[^}]*\}|\w+))?\s+from\s+["'])([^"']+)(["'])/gm,a=c=>c.replace(o,(d,m,u,y)=>{if(u.startsWith("."))return `${m}${u}${y}`;let g=u.split("/"),v=g[g.length-1];return `${m}@normalized/${v}${y}`}),l=a(n),f=a(i);return l===f}function V(e){let t=h__default.basename(e);return /^\.env(\.|$)/.test(t)}function He(e){let t=[".env.local",".env",".env.development.local",".env.development"];for(let r of t){let s=h__default.join(e,r);if(existsSync(s))return s}return null}function G(e){let t=e.split(`
6
6
  `),r={};for(let s of t){let n=s.trim();if(!n||n.startsWith("#"))continue;let i=n.indexOf("=");if(i===-1)continue;let o=n.substring(0,i).trim(),a=n.substring(i+1).trim();o&&(r[o]=a.replace(/^["']|["']$/g,""));}return r}function Je(e,t){let r=G(e),s=G(t),n=[];for(let i of Object.keys(s))i in r||n.push(i);return n}function qe(e,t){let r=G(e),s=G(t),n=e.trimEnd();n&&!n.endsWith(`
@@ -14,5 +14,5 @@ ${s.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
14
14
  `);});let y={};s$1.forEach(p=>{y=q(y,p.envVars??{});});let g=await ot(s$1.map(p=>p.files??[]),t),v=[];for(let p of s$1)if(p.type==="registry:font-variant"&&p.fontVariant)for(let x of ["display","body","numeric"]){let b=p.fontVariant[x];b&&v.push({name:`${p.name}-${x}`,type:"registry:font",role:x,font:b});}let C=s.parse({dependencies:q.all(s$1.map(p=>p.dependencies??[])),devDependencies:q.all(s$1.map(p=>p.devDependencies??[])),files:g,tailwind:c,cssVars:d,css:m,docs:u,fonts:v.length>0?v:void 0});return Object.keys(y).length>0&&(C.envVars=y),C}async function ve(e,t,r={},s=new Set){let n=[],i=[];for(let o of e)if(!s.has(o))if(s.add(o),F(o)||we(o)){let[a]=await ee([o],r);if(a&&(n.push(a),a.registryDependencies)){let l=await ve(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}else {i.push(o);try{let[a]=await ee([o],r);if(a&&a.registryDependencies){let l=await ve(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}catch{}}return {items:n,registryNames:i}}async function jr(e,t,r={}){if(F(e))return [e];let{registryNames:s}=await ve([e],t,r,new Set),n=s.map(i=>J(F(i)?i:`${i}.json`));return Array.from(new Set(n))}function W(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function Fr(e){if(F(e)){let r=new URL(e).pathname,s=r.match(/\/([^/]+)\.json$/),n=s?s[1]:h__default.basename(r,".json");return {name:n,hash:W({name:n},e)}}if(we(e)){let t=e.match(/\/([^/]+)\.json$/),r=t?t[1]:h__default.basename(e,".json");return {name:r,hash:W({name:r},e)}}return {name:e,hash:W({name:e},e)}}function Nr(e,t){let r=new Map,s=new Map,n=new Map,i=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);r.set(d,f),s.set(d,f),n.set(d,0),i.set(d,[]);});let o=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);o.has(f.name)||o.set(f.name,[]),o.get(f.name).push(d),c!==f.name&&(o.has(c)||o.set(c,[]),o.get(c).push(d));}),e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);f.registryDependencies&&f.registryDependencies.forEach(m=>{let u,y=o.get(m)||[];if(y.length===1)u=y[0];else if(y.length>1)u=y[0];else {let{name:g}=Fr(m),v=o.get(g)||[];v.length>0&&(u=v[0]);}u&&r.has(u)&&(i.get(u).push(d),n.set(d,n.get(d)+1));});});let a=[],l=[];for(n.forEach((f,c)=>{f===0&&a.push(c);});a.length>0;){let f=a.shift(),c=r.get(f);l.push(c),i.get(f).forEach(d=>{let m=n.get(d)-1;n.set(d,m),m===0&&a.push(d);});}if(l.length!==e.length){console.warn("Circular dependency detected in registry items");let f=new Set(l.map(c=>{let d=t.get(c)||c.name;return W(c,d)}));e.forEach(c=>{let d=t.get(c)||c.name,m=W(c,d);f.has(m)||l.push(c);});}return l}function Re(e){if(w.break(),w.error("Something went wrong. Please check the error below for more details."),w.error("If the problem persists, please open an issue on GitHub."),w.error(""),typeof e=="string"&&(w.error(e),w.break(),process.exit(1)),e instanceof O&&(e.message&&(w.error(e.cause?"Error:":"Message:"),w.error(e.message)),e.cause&&(w.error(`
15
15
  Message:`),w.error(e.cause)),e.suggestion&&(w.error(`
16
16
  Suggestion:`),w.error(e.suggestion)),w.break(),process.exit(1)),e instanceof z$1.ZodError){w.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))w.error(`- ${T.info(t)}: ${r}`);w.break(),process.exit(1);}e instanceof Error&&(w.error(e.message),w.break(),process.exit(1)),w.break(),process.exit(1);}async function Dr(e,t){let{useCache:r}=t||{},s=F(e)?e:J("registry.json"),[n]=await D([s],{useCache:r});try{return o.parse(n)}catch(i){throw new $(e,i)}}async function zi(e,t){let{useCache:r=false}=t||{};return ee(e,{useCache:r})}async function Wi(e,t){let{config:r,useCache:s=false}=t||{};return pt(e,at(r),{useCache:s})}async function ke(){try{return (await Dr("registry.json")).items}catch(e){w.error(`
17
- `),Re(e);}}async function Ui(){try{let[e]=await D(["styles/index.json"]);return q$1.parse(e)}catch{return []}}async function Vi(){try{let[e]=await D(["icons/index.json"]);return r.parse(e)}catch(e){return Re(e),{}}}async function Ar(e,t){let r=[];for(let s of t){let n=e.find(i=>i.name===s);if(n&&(r.push(n),n.registryDependencies)){let i=await Ar(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Ki(e,t){try{let r=t.map(n=>`${n.name}.json`);return (await D(r)).map(n$1=>n.parse(n$1))}catch(r){return Re(r),[]}}async function Mi(e,t,r){if(r)return r;if(t.type==="registry:ui")return e.resolvedPaths.ui??e.resolvedPaths.components;let[s,n]=t.type?.split(":")??[];return s in e.resolvedPaths?h__default.join(e.resolvedPaths[s],n):null}async function _r(e){e={useCache:true,...e};let t=`${ae}/config.json`,[r]=await D([t],{useCache:e.useCache});return w$1.parse(r).presets}async function Bi(e,t){return (await _r(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}function Lr(e){return (e.split(",")[0]?.trim().replace(/^['"]|['"]$/g,"")??e).replace(/\s*variable$/i,"").trim()}async function Gi(){try{let e=await ke()??[],t=[];for(let r of e){if(r.type!=="registry:font-variant"||!r.fontVariant)continue;let s=Array.from(new Set([r.fontVariant.display?.family,r.fontVariant.numeric?.family].filter(i=>!!i).map(Lr))),n=r.title??r.name;t.push({name:r.name.replace(/^font-variant-/,""),label:s.length?`${n} (${s.join(" + ")})`:n});}return t.length?t:[...ce]}catch{return [...ce]}}export{Bi as $,Xe as A,Ke as B,kn as C,vr as D,F as E,Vn as F,at as G,O as H,se as I,ne as J,ie as K,oe as L,Z as M,$ as N,D as O,pt as P,Re as Q,Dr as R,zi as S,Wi as T,ke as U,Ui as V,Vi as W,Ar as X,Ki as Y,Mi as Z,_r as _,T as a,Gi as aa,cs as b,ls as c,fs as d,ps as e,le as f,Ee as g,ms as h,Pt as i,kt as j,Me as k,Ce as l,B as m,Ts as n,w as o,X as p,gt as q,ht as r,Mr as s,Br as t,Gr as u,Hr as v,Jr as w,He as x,Je as y,qe as z};//# sourceMappingURL=chunk-EWAP55CF.js.map
18
- //# sourceMappingURL=chunk-EWAP55CF.js.map
17
+ `),Re(e);}}async function Ui(){try{let[e]=await D(["styles/index.json"]);return q$1.parse(e)}catch{return []}}async function Vi(){try{let[e]=await D(["icons/index.json"]);return r.parse(e)}catch(e){return Re(e),{}}}async function Ar(e,t){let r=[];for(let s of t){let n=e.find(i=>i.name===s);if(n&&(r.push(n),n.registryDependencies)){let i=await Ar(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Ki(e,t){try{let r=t.map(n=>`${n.name}.json`);return (await D(r)).map(n$1=>n.parse(n$1))}catch(r){return Re(r),[]}}async function Mi(e,t,r){if(r)return r;if(t.type==="registry:ui")return e.resolvedPaths.ui??e.resolvedPaths.components;let[s,n]=t.type?.split(":")??[];return s in e.resolvedPaths?h__default.join(e.resolvedPaths[s],n):null}async function _r(e){e={useCache:true,...e};let t=`${ae}/config.json`,[r]=await D([t],{useCache:e.useCache});return w$1.parse(r).presets}async function Bi(e,t){return (await _r(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}function Lr(e){return (e.split(",")[0]?.trim().replace(/^['"]|['"]$/g,"")??e).replace(/\s*variable$/i,"").trim()}async function Gi(){try{let e=await ke()??[],t=[];for(let r of e){if(r.type!=="registry:font-variant"||!r.fontVariant)continue;let s=Array.from(new Set([r.fontVariant.display?.family,r.fontVariant.numeric?.family].filter(i=>!!i).map(Lr))),n=r.title??r.name;t.push({name:r.name.replace(/^font-variant-/,""),label:s.length?`${n} (${s.join(" + ")})`:n});}return t.length?t:[...ce]}catch{return [...ce]}}export{Bi as $,Xe as A,Ke as B,kn as C,vr as D,F as E,Vn as F,at as G,O as H,se as I,ne as J,ie as K,oe as L,Z as M,$ as N,D as O,pt as P,Re as Q,Dr as R,zi as S,Wi as T,ke as U,Ui as V,Vi as W,Ar as X,Ki as Y,Mi as Z,_r as _,T as a,Gi as aa,cs as b,ls as c,fs as d,ps as e,le as f,Ee as g,ms as h,Pt as i,kt as j,Me as k,Ce as l,B as m,Ts as n,w as o,X as p,gt as q,ht as r,Mr as s,Br as t,Gr as u,Hr as v,Jr as w,He as x,Je as y,qe as z};//# sourceMappingURL=chunk-5YX4Z2U3.js.map
18
+ //# sourceMappingURL=chunk-5YX4Z2U3.js.map