import path from 'node:path';

// src/features/gen-html/domain/component-input.ts
var DEFAULT_GEN_HTML_COMPONENT_SLUG = "component";
function normalizeGenHtmlComponentName(componentName) {
  return componentName.trim();
}
function normalizeGenHtmlReferenceInput(reference) {
  return {
    description: reference.description.trim(),
    figmaAddress: reference.figmaAddress.trim()
  };
}
function normalizeGenHtmlComponentInput(component) {
  return {
    componentName: normalizeGenHtmlComponentName(component.componentName),
    references: component.references.map(normalizeGenHtmlReferenceInput).filter((reference) => Boolean(reference.figmaAddress))
  };
}
function slugifyGenHtmlComponentName(componentName) {
  const slug = normalizeGenHtmlComponentName(componentName).toLowerCase().replace(/['"`]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
  return slug || DEFAULT_GEN_HTML_COMPONENT_SLUG;
}
function createGenHtmlOutputPath(componentName, uniqueToken = Date.now()) {
  return path.join(".ju-hong-e", "local-server", "generated", `${slugifyGenHtmlComponentName(componentName)}-${uniqueToken}`);
}
function formatGenHtmlComponentInputMarkdown(component) {
  const normalizedComponent = normalizeGenHtmlComponentInput(component);
  return [
    `- componentName: \`${normalizedComponent.componentName}\``,
    `- referenceCount: \`${normalizedComponent.references.length}\``,
    normalizedComponent.references.length > 0 ? normalizedComponent.references.map(
      (reference, index) => [
        `- [${index + 1}] figmaAddress: \`${reference.figmaAddress}\``,
        reference.description ? `  description: ${reference.description}` : "  description: (\uC5C6\uC74C)"
      ].join("\n")
    ).join("\n") : "- references: (\uC5C6\uC74C)"
  ].join("\n");
}

export { createGenHtmlOutputPath, formatGenHtmlComponentInputMarkdown, normalizeGenHtmlComponentInput, normalizeGenHtmlComponentName, normalizeGenHtmlReferenceInput, slugifyGenHtmlComponentName };
