{"version":3,"file":"prop-label-9_f1tTIk.mjs","names":[],"sources":["../src/prop-label.ts"],"sourcesContent":["/**\n * What an author calls a stored key and a block's prop.\n *\n * Its own module, free of React, so the editor's panels and a server answer\n * naming a block's props use one rule: the inspector re-exports it, and the\n * server-safe `@nextlyhq/builder/ops` entry offers it.\n *\n * @module prop-label\n */\nimport type { PropSchema } from \"@nextlyhq/blocks-engine\";\n\n/**\n * A stored key as a human reads it: `backgroundColor` becomes \"Background color\".\n *\n * Here rather than in a panel because both panels label the same way and from\n * the same kind of key — a prop name on the content tab, a catalog key on the\n * style tab — and two spellings of one rule would drift the first time either\n * learned about an acronym or a digit.\n */\nexport function fieldLabel(name: string): string {\n  const spaced = name\n    .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n    .replace(/[-_]+/g, \" \")\n    .trim();\n  const label = spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();\n  // The editor's spelling, which its own words (\"Colour for\", the Colour\n  // form) already use: a key's American \"color\" read beside them as the same\n  // word spelled two ways in one panel.\n  return label.replace(/\\b([Cc])olor\\b/g, \"$1olour\");\n}\n\n/**\n * What an author calls a prop: the label its block gives it, or its name,\n * spaced and capitalised, when the block gives none.\n */\nexport function propLabel(name: string, schema: PropSchema): string {\n  const given = schema.label;\n  return typeof given === \"string\" && given.trim() !== \"\"\n    ? given\n    : fieldLabel(name);\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAgB,WAAW,MAAsB;CAC/C,MAAM,SAAS,KACZ,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,UAAU,GAAG,CAAC,CACtB,KAAK;CAKR,QAJc,OAAO,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,YAAY,EAAA,CAI9D,QAAQ,mBAAmB,SAAS;AACnD;;;;;AAMA,SAAgB,UAAU,MAAc,QAA4B;CAClE,MAAM,QAAQ,OAAO;CACrB,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,KACjD,QACA,WAAW,IAAI;AACrB"}