{"version":3,"file":"style-element.mjs","names":[],"sources":["../src/style-element.ts"],"sourcesContent":["/**\n * Browser-safe `<style>` injector. Exported through the\n * `@unpunnyfuns/swatchbook-core/style-element` subpath so the addon's\n * preview decorator, the blocks-side stylesheet path, and any future\n * integration share one implementation — no parallel\n * `getElementById` / `createElement` boilerplate across packages.\n *\n * Idempotent: creates the `<style>` element the first time, then only\n * updates `textContent` when it actually changes. Safe to call from\n * both module-level and effect callsites.\n *\n * No-ops in non-DOM environments (SSR, Node).\n */\nexport const SWATCHBOOK_STYLE_ELEMENT_ID = 'swatchbook-tokens';\n\nexport function ensureStyleElement(elementId: string, text: string): void {\n  if (typeof document === 'undefined') return;\n  let style = document.getElementById(elementId) as HTMLStyleElement | null;\n  if (!style) {\n    style = document.createElement('style');\n    style.id = elementId;\n    document.head.appendChild(style);\n  }\n  if (style.textContent !== text) style.textContent = text;\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,8BAA8B;AAE3C,SAAgB,mBAAmB,WAAmB,MAAoB;AACxE,KAAI,OAAO,aAAa,YAAa;CACrC,IAAI,QAAQ,SAAS,eAAe,UAAU;AAC9C,KAAI,CAAC,OAAO;AACV,UAAQ,SAAS,cAAc,QAAQ;AACvC,QAAM,KAAK;AACX,WAAS,KAAK,YAAY,MAAM;;AAElC,KAAI,MAAM,gBAAgB,KAAM,OAAM,cAAc"}