{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-code-snippet",
  "type": "registry:lib",
  "title": "core/code-snippet",
  "description": "Framework-free behaviour shared by the ui-* components (code-snippet); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/code-snippet.ts",
      "type": "registry:lib",
      "target": "components/ui/core/code-snippet.ts",
      "content": "/**\n * Carbon `CodeSnippet` rules for the multi-line snippet: how tall it may be, collapsed or\n * expanded, and when it needs the \"Show more / less\" button. Shared by `<ui-code-snippet>` and\n * the React CodeSnippet.\n */\n\n/** One line of code (code-01 line height), the unit of the row limits. */\nexport const SNIPPET_ROW = 16;\n\nexport interface SnippetRows {\n    /** Rows visible while collapsed; 0 = no limit (Carbon 15). */\n    maxCollapsedRows: number;\n    /** Rows visible while expanded; 0 = no limit. */\n    maxExpandedRows: number;\n    minCollapsedRows: number;\n    minExpandedRows: number;\n}\n\nexport const DEFAULT_SNIPPET_ROWS: SnippetRows = { maxCollapsedRows: 15, maxExpandedRows: 0, minCollapsedRows: 3, minExpandedRows: 16 };\n\n/** The button appears when the code is taller than the collapsed limit, and expanding would show more. */\nexport function snippetCanExpand(codeHeight: number, rows: SnippetRows): boolean {\n    const limitApplies = rows.maxCollapsedRows > 0 && (rows.maxExpandedRows <= 0 || rows.maxExpandedRows > rows.maxCollapsedRows);\n    return limitApplies && codeHeight > rows.maxCollapsedRows * SNIPPET_ROW;\n}\n\n/** An expanded snippet whose code now fits the expanded minimum folds back (Carbon). */\nexport function snippetShouldCollapse(codeHeight: number, rows: SnippetRows): boolean {\n    return rows.minExpandedRows > 0 && codeHeight <= rows.minExpandedRows * SNIPPET_ROW;\n}\n\n/** The container's height bounds in px (undefined: no bound). */\nexport function snippetHeights(expanded: boolean, rows: SnippetRows): { max?: number; min?: number } {\n    const max = expanded ? rows.maxExpandedRows : rows.maxCollapsedRows;\n    const min = expanded ? rows.minExpandedRows : rows.minCollapsedRows;\n    return { max: max > 0 ? max * SNIPPET_ROW : undefined, min: min > 0 ? min * SNIPPET_ROW : undefined };\n}\n\n/** What gets copied: `text`, else the code with the one leading line break `<pre>` would drop. */\nexport function snippetCopyText(text: string, code: string): string {\n    return text || code.replace(/^\\n/, '');\n}\n"
    }
  ]
}
