'use strict';

var path = require('path');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var path__default = /*#__PURE__*/_interopDefault(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__default.default.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");
}

exports.createGenHtmlOutputPath = createGenHtmlOutputPath;
exports.formatGenHtmlComponentInputMarkdown = formatGenHtmlComponentInputMarkdown;
exports.normalizeGenHtmlComponentInput = normalizeGenHtmlComponentInput;
exports.normalizeGenHtmlComponentName = normalizeGenHtmlComponentName;
exports.normalizeGenHtmlReferenceInput = normalizeGenHtmlReferenceInput;
exports.slugifyGenHtmlComponentName = slugifyGenHtmlComponentName;
