{"version":3,"file":"entry-preview-argtypes.cjs","names":["prop: JsonDocsProp","scalarTypes: SBScalarType['name'][]","docs: string","docsTags?: DocsTag[]","tagSections: string[]","deprecationSections: string[]","data: T[]","category: string","methods: JsonDocsMethod[]","events: JsonDocsEvent[]","chr: string","props: JsonDocsProp[]","tagName: string","manifest: JsonDocs","customElements: JsonDocs","component: any","argTypesEnhancers: ArgTypesEnhancer<StencilRenderer<unknown>>[]","enhanceArgTypes"],"sources":["../src/docs/infer-type.ts","../src/docs/custom-elements.ts","../src/entry-preview-argtypes.ts"],"sourcesContent":["import type { JsonDocsProp } from '@stencil/core/internal';\nimport type { InputType, SBScalarType, SBType } from 'storybook/internal/types';\n\nexport const inferSBType = (prop: JsonDocsProp): SBType => {\n  const scalarTypes: SBScalarType['name'][] = ['string', 'number', 'boolean', 'symbol'];\n  if (prop.type.toLowerCase() in scalarTypes) {\n    return { name: prop.type.toLowerCase(), raw: prop.type, required: prop.required } as SBScalarType;\n  }\n\n  if (/^\\(.*\\)\\s*=>\\s*.*$/.test(prop.type)) {\n    return { name: 'function', raw: prop.type, required: prop.required };\n  }\n\n  return { name: 'other', value: prop.type, raw: prop.type, required: prop.required };\n};\n\nexport const mapPropOptions = (prop: JsonDocsProp) =>\n  prop.values.filter((value) => ['string', 'number'].includes(value.type)).map(({ value }) => value);\n\nexport const inferControlType = (prop: JsonDocsProp): InputType['control'] => {\n  switch (prop.type) {\n    case 'string':\n    case 'string | undefined':\n      return { type: 'text' };\n    case 'number':\n    case 'number | undefined':\n      return { type: 'number' };\n    case 'boolean':\n    case 'boolean | undefined':\n      return { type: 'boolean' };\n    case 'Date':\n    case 'Date | string':\n      return { type: 'date' };\n    case 'function':\n    case 'function | undefined':\n    case 'void':\n    case 'void | undefined':\n      return null;\n    default:\n      const values = mapPropOptions(prop);\n\n      if (values.length === 0) {\n        return { type: 'object' };\n      }\n      if (values.length < 5) {\n        return { type: 'radio' };\n      }\n      return { type: 'select' };\n  }\n};\n","import type {\n  JsonDocs,\n  JsonDocsEvent,\n  JsonDocsMethod,\n  JsonDocsPart,\n  JsonDocsProp,\n  JsonDocsSlot,\n  JsonDocsStyle,\n} from '@stencil/core/internal';\nimport { logger } from 'storybook/internal/client-logger';\nimport type { ArgTypes } from 'storybook/internal/types';\n\nimport { getCustomElements, isValidComponent, isValidMetaData } from '..';\nimport { inferControlType, inferSBType, mapPropOptions } from './infer-type';\n\ninterface DocsTag {\n  name: string;\n  text?: string;\n}\n\n/**\n * Formats docsTags (@deprecated, @see, @since) and appends them to the description\n */\nconst formatDocsTags = (docs: string, docsTags?: DocsTag[]): string => {\n  if (!docsTags || docsTags.length === 0) {\n    return docs;\n  }\n\n  const tagSections: string[] = [];\n  const deprecationSections: string[] = [];\n\n  // Handle @deprecated tags - show at the top with emphasis\n  const deprecatedTags = docsTags.filter((tag) => tag.name === 'deprecated');\n  if (deprecatedTags.length > 0) {\n    deprecatedTags.forEach((tag) => {\n      if (tag.text) {\n        deprecationSections.push(`**⚠️ DEPRECATED:** ${tag.text}`);\n      } else {\n        deprecationSections.push(`**⚠️ DEPRECATED**`);\n      }\n    });\n  }\n\n  // Handle @see tags - create links\n  const seeTags = docsTags.filter((tag) => tag.name === 'see');\n  if (seeTags.length > 0) {\n    const seeLinks = seeTags\n      .map((tag) => {\n        const url = tag.text?.trim();\n        return url ? `[${url}](${url})` : '';\n      })\n      .filter(Boolean)\n      .join(', ');\n    if (seeLinks) {\n      tagSections.push(`**See:** ${seeLinks}`);\n    }\n  }\n\n  // Handle @since tags\n  const sinceTags = docsTags.filter((tag) => tag.name === 'since');\n  if (sinceTags.length > 0) {\n    const sinceText = sinceTags\n      .map((tag) => tag.text)\n      .filter(Boolean)\n      .join(', ');\n    if (sinceText) {\n      tagSections.push(`**Since:** ${sinceText}`);\n    }\n  }\n\n  // Combine all sections - deprecation first, then docs, then other tags\n  const allSections = [...deprecationSections, docs, ...tagSections].filter(Boolean);\n\n  return allSections.join('\\n\\n');\n};\n\nconst mapData = <T extends JsonDocsPart>(data: T[], category: string): ArgTypes =>\n  data.reduce<ArgTypes>((acc, item) => {\n    acc[item.name] = {\n      name: item.name,\n      description: formatDocsTags(item.docs, (item as any).docsTags as DocsTag[]),\n      control: false,\n      table: {\n        category,\n      },\n    };\n    return acc;\n  }, {});\n\nconst mapMethods = (methods: JsonDocsMethod[]): ArgTypes =>\n  methods.reduce<ArgTypes>((acc, method) => {\n    acc[method.name] = {\n      name: method.name,\n      description: formatDocsTags(method.docs, method.docsTags as DocsTag[]),\n      control: null,\n      type: { name: 'function' },\n      table: {\n        category: 'methods',\n        type: { summary: method.signature },\n      },\n    };\n    return acc;\n  }, {});\n\nconst mapEvent = (events: JsonDocsEvent[]): ArgTypes =>\n  events.reduce<ArgTypes>((acc, event) => {\n    let name = event.event\n      .replace(/(-|_|:|\\.|\\s)+(.)?/g, (_match, _separator, chr: string) => {\n        return chr ? chr.toUpperCase() : '';\n      })\n      .replace(/^([A-Z])/, (match) => match.toLowerCase());\n\n    name = `on${name.charAt(0).toUpperCase() + name.slice(1)}`;\n\n    acc[name] = {\n      name,\n      description: formatDocsTags(event.docs, event.docsTags as DocsTag[]),\n      control: null,\n      table: {\n        category: 'events',\n        type: { summary: event.detail },\n      },\n      type: { name: 'function' },\n    };\n\n    return acc;\n  }, {});\n\nconst mapProps = (props: JsonDocsProp[]): ArgTypes =>\n  props.reduce<ArgTypes>((acc, prop) => {\n    acc[prop.name] = {\n      name: prop.attr || prop.name,\n      description: formatDocsTags(prop.docs, prop.docsTags as DocsTag[]),\n      control: inferControlType(prop),\n      table: {\n        category: 'properties',\n        type: { summary: prop.complexType?.original },\n        defaultValue: { summary: prop.default },\n      },\n      options: mapPropOptions(prop),\n      type: inferSBType(prop),\n    };\n\n    return acc;\n  }, {});\n\nconst getMetaData = (tagName: string, manifest: JsonDocs) => {\n  if (!isValidComponent(tagName) || !isValidMetaData(manifest)) {\n    return null;\n  }\n  const metaData = manifest.components.find((component) => component.tag.toUpperCase() === tagName.toUpperCase());\n  if (!metaData) {\n    logger.warn(`Component not found in custom-elements.json: ${tagName}`);\n  }\n  return metaData;\n};\n\nexport const extractArgTypesFromElements = (tagName: string, customElements: JsonDocs) => {\n  const metaData = getMetaData(tagName, customElements);\n  return (\n    metaData && {\n      ...mapProps(metaData.props),\n      ...mapEvent(metaData.events),\n      ...mapMethods(metaData.methods),\n      ...mapData<JsonDocsSlot>(metaData.slots, 'slots'),\n      ...mapData<JsonDocsPart>(metaData.parts, 'parts'),\n      ...mapData<JsonDocsStyle>(metaData.styles, 'styles'),\n    }\n  );\n};\n\nexport const extractArgTypes = (component: any) => {\n  const cem = getCustomElements();\n  // Handle both string references (lazy loading) and class references (auto-define)\n  const tagName = typeof component === 'string' ? component : component?.is;\n  return extractArgTypesFromElements(tagName, cem);\n};\n\nexport const extractComponentDescription = (component: any) => {\n  // Handle both string references (lazy loading) and class references (auto-define)\n  const tagName = typeof component === 'string' ? component : component?.is;\n  const metaData = getMetaData(tagName, getCustomElements());\n  return metaData && metaData.docs;\n};\n","import { enhanceArgTypes } from 'storybook/internal/docs-tools';\nimport type { ArgTypesEnhancer } from 'storybook/internal/types';\n\nimport { extractArgTypes, extractComponentDescription } from './docs/custom-elements';\nimport type { StencilRenderer } from './types';\n\nexport const parameters = {\n  docs: {\n    extractArgTypes,\n    extractComponentDescription,\n  },\n};\n\nexport const argTypesEnhancers: ArgTypesEnhancer<StencilRenderer<unknown>>[] = [enhanceArgTypes];"],"mappings":";;;;;;;AAGA,MAAa,cAAc,CAACA,SAA+B;CACzD,MAAMC,cAAsC;EAAC;EAAU;EAAU;EAAW;CAAS;AACrF,KAAI,KAAK,KAAK,aAAa,IAAI,YAC7B,QAAO;EAAE,MAAM,KAAK,KAAK,aAAa;EAAE,KAAK,KAAK;EAAM,UAAU,KAAK;CAAU;AAGnF,KAAI,qBAAqB,KAAK,KAAK,KAAK,CACtC,QAAO;EAAE,MAAM;EAAY,KAAK,KAAK;EAAM,UAAU,KAAK;CAAU;AAGtE,QAAO;EAAE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