import base_default from "../_virtual/inline-css_src/define/base.js";

//#region src/define/skin-mixin.ts
const STYLES_ID = "__media-styles";
function ensureStyles() {
	if (document.getElementById(STYLES_ID)) return;
	const style = document.createElement("style");
	style.id = STYLES_ID;
	style.textContent = base_default;
	document.head.appendChild(style);
}
/**
* Mixin for skin elements that renders the template from a static
* `getTemplateHTML` method into a shadow root. Native `<slot>` elements
* handle light DOM projection automatically.
*
* When `static styles` is set, the stylesheet is adopted into the
* shadow root via `adoptedStyleSheets`.
*/
function SkinMixin(BaseClass) {
	class SkinElement extends BaseClass {
		static {
			this.shadowRootOptions = { mode: "open" };
		}
		constructor(...args) {
			super(...args);
			ensureStyles();
			if (!this.shadowRoot) {
				const ctor = this.constructor;
				this.attachShadow(ctor.shadowRootOptions);
				if (ctor.styles) this.shadowRoot.adoptedStyleSheets = [ctor.styles];
				if (ctor.getTemplateHTML) this.shadowRoot.innerHTML = ctor.getTemplateHTML();
			}
		}
	}
	return SkinElement;
}
/** Create a shared `CSSStyleSheet` from a CSS string. */
function createStyles(css) {
	const sheet = new CSSStyleSheet();
	sheet.replaceSync(css);
	return sheet;
}

//#endregion
export { SkinMixin, createStyles };
//# sourceMappingURL=skin-mixin.js.map