import { unsafeCSS } from "lit";
import tailwind_global_tw from "../utils/tailwind.global.tw.css";
const tailwindPropertiesSheet = "u" > typeof window ? (()=>{
    const propCss = tailwind_global_tw;
    const fullCss = Array.isArray(propCss) ? propCss.join('') : propCss;
    const match = fullCss.match(/@layer\s+properties\s*{[^{}]*@supports[^{}]*{([^}]*)}|@layer\s+properties\s*{([^}]*)}/);
    const cssString = (match?.[1] || match?.[2] || '').trim();
    if (!cssString) return null;
    const wrappedCss = `@layer properties { ${cssString} }`;
    const sheet = new CSSStyleSheet();
    sheet.replaceSync(wrappedCss);
    return sheet;
})() : null;
function injectTailwindProperties(element) {
    if ("u" < typeof window || !tailwindPropertiesSheet) return;
    const parent = element.getRootNode();
    const isParentDocumentOrShadowRoot = parent instanceof Document || parent instanceof ShadowRoot;
    if (isParentDocumentOrShadowRoot) {
        if (!parent.adoptedStyleSheets.includes(tailwindPropertiesSheet)) parent.adoptedStyleSheets?.push(tailwindPropertiesSheet);
    } else element.adoptedStyleSheets?.push(tailwindPropertiesSheet);
}
const withTailwindStyles = (Base)=>class extends Base {
        connectedCallback() {
            super.connectedCallback();
            injectTailwindProperties(this);
        }
        static get styles() {
            const baseStyles = [
                unsafeCSS(tailwind_global_tw)
            ];
            const customStyles = Base.styles;
            if (Array.isArray(customStyles)) return [
                ...baseStyles,
                ...customStyles
            ];
            if (customStyles) return [
                ...baseStyles,
                customStyles
            ];
            return baseStyles;
        }
    };
export { withTailwindStyles };
