import{appendFileSync as P,mkdirSync as p,writeFileSync as a}from"fs";import e from"path";import{CUSTOM_MARKDOC_TAGS_PATH as d,CUSTOM_MARKDOC_OPTIONS_PATH as l}from"../../constants/common.js";import{USER_THEME_ALIAS as C}from"../../constants/common.js";import{logger as T}from"../../server/tools/notifiers/logger.js";import{getComponentTemplate as O}from"./get-component-template.js";import{getComponentsFileTemplate as D}from"./get-components-file-template.js";import{getSchemaTemplate as E}from"./get-schema-template.js";import{isValidFilePath as f}from"./is-valid-file-path.js";import{capitalize as F}from"./string-utils.js";async function I(h,o,m){const t=F(o),s=e.resolve(h,C),c=e.resolve(s,l,d),i=e.resolve(s,t),S=e.resolve(s,l,"components.ts"),n=e.resolve(i,`${t}.tsx`),r=e.resolve(c,`${o}.markdoc.ts`),g=!await f(n,m),u=!await f(r,m);if((g||u)&&!m)return;const v=O(t),_=E(o),A=D(t);p(i,{recursive:!0}),p(c,{recursive:!0}),a(r,_),T.success(`Generated schema: file://${r}`),a(n,v),T.success(`Generated component: file://${n}`),P(S,A)}export{I as generateTag};
