const LightDomMixin = (superClass)=>{
    class LightDomMixinClass extends superClass {
        createRenderRoot() {
            return this;
        }
        connectedCallback() {
            super.connectedCallback();
            this.injectStyles();
        }
        async injectStyles(dynamicStyles) {
            const parent = this.getRootNode();
            const isDocumentOrShadowRoot = parent instanceof Document || parent instanceof ShadowRoot;
            if (!isDocumentOrShadowRoot) return;
            const constructorStyles = this.constructor.styles;
            const staticStyles = Array.isArray(constructorStyles) ? constructorStyles : [
                constructorStyles
            ];
            const dynamicStylesArray = Array.isArray(dynamicStyles) ? dynamicStyles : [
                dynamicStyles
            ];
            const allStyles = [
                ...staticStyles,
                ...dynamicStylesArray
            ];
            for (const style of allStyles)if (style) {
                const styleSheet = this.getStyleSheet(style);
                if (styleSheet && !parent.adoptedStyleSheets.includes(styleSheet)) parent.adoptedStyleSheets.push(styleSheet);
            }
        }
        getStyleSheet(style) {
            if (style instanceof CSSStyleSheet) return style;
            if (style && 'object' == typeof style && 'styleSheet' in style) return style.styleSheet;
            return null;
        }
    }
    return LightDomMixinClass;
};
export { LightDomMixin };
