{"version":3,"sources":["../../../../src/scripts/CreateTypes/CreateAsyncComponentType/componentMediaOrRef.mts","../../../../src/data/collections.ts","../../../../src/func/Typescript/InterfaceMaker/index.ts","../../../../src/helper/index.ts","../../../../src/func/Typescript/TypeNameMaker/index.ts","../../../../src/func/Typescript/peer/index.ts","../../../../src/func/Typescript/TypeMaker/index.ts"],"sourcesContent":["import {isDuplicate} from '../../../data/collections.ts';\nimport {interfaceMaker} from '../../../func/Typescript/InterfaceMaker/index.ts';\nimport {peer} from '../../../func/Typescript/peer/index.ts';\nimport {typeMaker} from '../../../func/Typescript/TypeMaker/index.ts';\nimport {typeNameMaker} from '../../../func/Typescript/TypeNameMaker/index.ts';\nimport {IAsyncRecursiveComponentResult} from './AsyncRecursiveComponent.mts';\n\nexport function componentMediaOrRef(\n  component: IAsyncRecursiveComponentResult | null\n) {\n  if (component) {\n    if (component.type === 'REF') {\n      return peer(\n        component.name || '___NoNameREF?',\n        typeNameMaker(component.data[0] || 'noNameREF_PARAM?'),\n        component.nullable,\n        component.isArray\n      );\n    }\n    if (component.type === 'PREM') {\n      return peer(\n        component.name || '___NoNamePREM?',\n        component.data[0],\n        component.nullable,\n        component.isArray\n      );\n    }\n    if (component.type === 'COM_PREM') {\n      return typeMaker(\n        typeNameMaker(component.name || '___NoNameENUM'),\n        component.data[0]\n      );\n    }\n    if (component.type === 'ENUM') {\n      const duplicate = isDuplicate(component.name as string);\n      return !duplicate\n        ? typeMaker(\n            typeNameMaker(component.name || '___NoNameENUM'),\n            component.data[0]\n          )\n        : '';\n    }\n    if (component.type === 'MEDIA') {\n      const duplicate = isDuplicate(component.name as string);\n      return !duplicate\n        ? interfaceMaker(\n            typeNameMaker(component.name || '___NoNameMEDIA'),\n            component.data[0]\n          )\n        : '';\n    }\n    if (component.type === 'MEDIA_TYPE') {\n      const duplicate = isDuplicate(component.name as string);\n      return !duplicate\n        ? typeMaker(\n            typeNameMaker(component.name || '___NoNameMEDIA'),\n            component.data[0]\n          )\n        : '';\n    }\n    if (component.type === 'RECORD') {\n      // const duplicate = isDuplicate(component.name as string);\n      // return !duplicate\n      //   ? typeMaker(\n      //       typeNameMaker(component.name || '___NoNameMEDIA'),\n      //       component.data[0]\n      //     )\n      //   : '';\n\n      if (component.data) {\n        const data = component.data[0] || 'any';\n        const type = `Record<PropertyKey,${data}>`;\n        return peer(\n          component.name || '___NoNamePREM?',\n          type,\n          component.nullable,\n          false\n        );\n      }\n    }\n  }\n  return '';\n}\n","const duplications: string[] = [];\nexport {duplications};\n\nexport function isDuplicate(key: string) {\n  const isDuplicate = duplications.includes(key);\n  if (!isDuplicate) {\n    duplications.push(key);\n  }\n  // return isDuplicate;\n  return false;\n}\n","export function interfaceMaker(\n  InterfaceName: string,\n  core: string,\n  extend?: string\n) {\n  if (extend)\n    return (\n      'interface ' +\n      InterfaceName +\n      (extend ? ' extends ' + extend : '') +\n      ' {' +\n      core +\n      '}'\n    );\n  return 'interface ' + InterfaceName + '{' + core + '}';\n}\n","import {OpenAPIV3} from 'openapi-types';\nimport {typeNameMaker} from '../func/Typescript/TypeNameMaker/index.ts';\nimport {Spec, isReference} from '../types.ts';\nconst repoTypes: string[] = [''];\nexport function capitalize(string: string) {\n  return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function camelize(str: string) {\n  return str\n    .replace(/(?:^\\w|[A-Z]|\\b\\w)/g, (word, index) => {\n      return index === 0 ? word.toLowerCase() : word.toUpperCase();\n    })\n    .replace(/\\s+/g, '');\n}\n\nexport const primitiveJs = (\n  key: 'string' | 'number' | 'boolean' | 'integer' | undefined\n) => {\n  switch (key) {\n    case 'integer':\n      return 'number';\n    case 'number':\n      return 'number';\n    case 'boolean':\n      return 'boolean';\n    case 'string':\n      return 'string';\n\n    default:\n      return 'unknown';\n  }\n};\n\nexport const definitionFullName = (defination: Spec) => {\n  return defination.info.title + '_' + defination.info.version;\n};\n\nexport const isDuplication = (name: string, data: string[]): boolean => {\n  const iName = typeNameMaker(name);\n  const include = repoTypes.some(item => item.includes(iName));\n  const dataInclude = data.some(item => item.includes(iName));\n  if (include && dataInclude) {\n    return true;\n  }\n  repoTypes.push(iName);\n  return false;\n};\n\nexport const isNullable = (\n  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject\n): boolean | undefined => {\n  if (!isReference(schema)) {\n    return schema.nullable;\n  }\n  return undefined;\n};\n\nexport const definationComment = (defination: Spec, data: string[][]) => {\n  data.forEach(fileData => {\n    fileData.push(\n      `\\n/* ${defination.info.title} - ${defination.info.version} */\\n`\n    );\n  });\n};\nexport const getDefinationComment = (defination: Spec) => {\n  return ` ${defination.info.title} - ${defination.info.version}`;\n};\n\nexport function statusString(status: string) {\n  const okReg = /2\\d\\d/g;\n  const badReg = /400/g;\n  if (okReg.test(status)) {\n    return 'Ok';\n  }\n\n  if (badReg) {\n    return 'Bad';\n  }\n\n  return;\n}\n\nexport const pathSplit = (path: string) => {\n  const reg = /\\/{\\w*}/g;\n  const regBracketsParams = /{(.*?)}/g;\n  const refinePath = path.replace(reg, '');\n\n  const bracketsParams = path\n    .match(regBracketsParams)\n    ?.map(params => {\n      const name = params.replace(/{|}/g, '');\n      return 'By' + capitalize(name);\n    })\n    .join('');\n\n  const pathScope = refinePath.split('/') as string[];\n  const definationName = pathScope[1] as string;\n  const scopeName = pathScope[3] as string;\n  const itemName =\n    (((pathScope[pathScope.length - 1] as string) +\n      capitalize(pathScope[pathScope.length - 2])) as string) +\n    (bracketsParams || '');\n\n  return {pathScope, definationName, scopeName, itemName};\n};\n","import {camelize, capitalize} from '../../../helper/index.ts';\n\nexport function typeNameMaker(name: string, extra = 'Set') {\n  return 'I' + camelCase(name) + extra;\n}\nexport function typeNameSpaceMaker(\n  name: string,\n  namespace: string,\n  extra = 'Set'\n) {\n  return (\n    namespace + '.I' + capitalize(camelize(nameRefineWithDot(name))) + extra\n  );\n}\n\nexport function nameRefine(name: string) {\n  const reg = /[^a-zA-Z0-9]/g;\n\n  return name.toString().replace(reg, '');\n}\nexport function nameRefineWithDot(name: string) {\n  const reg = /[^a-zA-Z0-9.]/g;\n\n  return name.toString().replace(reg, '');\n}\n\nexport function nameStringify(name: string) {\n  return \"'\" + name + \"'\";\n}\n\nexport function camelCase(name: string) {\n  return capitalize(camelize(nameRefine(name)));\n}\n","import {nameStringify} from '../TypeNameMaker/index.ts';\n\nexport function peer(\n  name: string,\n  type: string,\n  nullable?: boolean,\n  isArray?: boolean\n) {\n  return (\n    nameStringify(name) +\n    (nullable ? '?:' : ':') +\n    type +\n    (isArray ? '[];' : ';')\n  );\n}\nexport function equal(name: string, type: string) {\n  return name + '=' + nameStringify(type) + ',';\n}\n","export function typeMaker(\n  TypeName: string,\n  core: string,\n  object?: boolean,\n  hasExport?: boolean\n) {\n  if (object)\n    return (\n      `${hasExport ? 'export' : ''} type ` + TypeName + '= {' + core + '};'\n    );\n  return `${hasExport ? 'export' : ''} type ` + TypeName + '= ' + core + ';';\n}\n\nexport function enumarateMaker(enumName: string, core: string) {\n  return 'export enum ' + enumName + ' {' + core + '};';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,eAAyB,CAAC;AAGzB,SAAS,YAAY,KAAa;AACvC,QAAMA,eAAc,aAAa,SAAS,GAAG;AAC7C,MAAI,CAACA,cAAa;AAChB,iBAAa,KAAK,GAAG;AAAA,EACvB;AAEA,SAAO;AACT;;;ACVO,SAAS,eACd,eACA,MACA,QACA;AACA,MAAI;AACF,WACE,eACA,iBACC,SAAS,cAAc,SAAS,MACjC,OACA,OACA;AAEJ,SAAO,eAAe,gBAAgB,MAAM,OAAO;AACrD;;;ACXO,SAAS,WAAW,QAAgB;AACzC,SAAO,OAAO,OAAO,CAAC,EAAE,YAAY,IAAI,OAAO,MAAM,CAAC;AACxD;AAEO,SAAS,SAAS,KAAa;AACpC,SAAO,IACJ,QAAQ,uBAAuB,CAAC,MAAM,UAAU;AAC/C,WAAO,UAAU,IAAI,KAAK,YAAY,IAAI,K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