/**
 * Single source of truth for injecting the canonical Seekora UI SDK
 * stylesheet (`./components.css`) into the host document.
 *
 * Components call `ensureSeekoraStyles()` once on mount (via useEffect with
 * empty deps). Subsequent calls are idempotent — the `<style id="seekora-ui-sdk-styles">`
 * tag is created once per document and reused.
 *
 * The CSS is imported at build time (rollup) so it's bundled into the
 * UMD/ESM dist as a string. The injector reads that string and writes a
 * <style> element. Consumers using bundlers with CSS-asset support (Vite,
 * Next.js) can alternatively import `./components.css` directly — the
 * injector's no-op path is safe because it bails out if the style element
 * already exists with a populated stylesheet.
 *
 * SCRUM-268.
 */
// rollup-plugin-postcss / rollup-plugin-css inlines the CSS as a string.
// If the bundler doesn't process .css imports as strings, fall back to a
// runtime fetch via <link>.
// @ts-expect-error — CSS imports are resolved by bundler at build time.
import cssText from "./components.css";
const STYLE_TAG_ID = "seekora-ui-sdk-styles";
let injected = false;
export function ensureSeekoraStyles() {
    if (injected)
        return;
    if (typeof document === "undefined")
        return;
    if (document.getElementById(STYLE_TAG_ID)) {
        injected = true;
        return;
    }
    const style = document.createElement("style");
    style.id = STYLE_TAG_ID;
    style.setAttribute("data-seekora-ui-sdk", "components");
    style.textContent = typeof cssText === "string" ? cssText : "";
    document.head.appendChild(style);
    injected = true;
}
