import { GlobalStateService as e } from "../../internal/services/global.service.js";
import { audit as t } from "../../internal/controllers/audit.controller.js";
import { debounce as n } from "../../internal/utils/events.js";
import { LogService as r } from "../../internal/services/log.service.js";
import { attachInternals as i } from "../../internal/utils/a11y.js";
import { useStyles as a } from "../../internal/styles/index.js";
import { __decorate as o } from "../../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/decorate.js";
import s from "./header.js";
import { GridColumn as c } from "../column/column2.js";
import { GridCell as l } from "../cell/cell2.js";
import { GridRow as u } from "../row/row2.js";
import { LitElement as d, html as f } from "lit";
import { queryAssignedElements as p } from "lit/decorators/query-assigned-elements.js";
//#region src/grid/header/header.ts
var m = class extends d {
	static {
		this.styles = a([s]);
	}
	static {
		this.metadata = {
			tag: "nve-grid-header",
			version: "2.0.2",
			children: [c.metadata.tag]
		};
	}
	get #e() {
		return this.parentElement;
	}
	render() {
		return f`<div internal-host><slot @slotchange="${() => this.#r()}"></slot></div>`;
	}
	connectedCallback() {
		super.connectedCallback(), i(this), this._internals.role = "row", this.addEventListener("nve-grid-column-resize", this.#t), this.#n ??= new ResizeObserver(n(() => this.#r(), 100)), this.#n.observe(this);
	}
	disconnectedCallback() {
		super.disconnectedCallback(), this.removeEventListener("nve-grid-column-resize", this.#t), this.#n?.disconnect();
	}
	#t = () => {
		this.#r();
	};
	#n;
	async firstUpdated(e) {
		super.firstUpdated(e), await this.updateComplete, this.#i();
	}
	async #r() {
		await this.updateComplete, this.columns.forEach((e, t) => e.ariaColIndex = `${t + 1}`), this.#e.style.setProperty("--grid-auto-flow", "initial"), this.#e.style.setProperty("--grid-template-column", this.columns.map((e, t) => `var(--c${t})`).join(" ")), this.columns.forEach((e, t) => this.#e.style.setProperty(`--c${t}`, e.width ? e.width : "1fr")), await this.updateComplete, this.columns.map((e) => e.width ? e.width : `minmax(auto, ${e.getBoundingClientRect().width}px)`).forEach((e, t) => this.#e.style.setProperty(`--c${t}`, e));
	}
	#i() {
		if (e.state.env !== "production") {
			let e = this.#e.querySelector(u.metadata.tag)?.querySelectorAll(l.metadata.tag);
			this.columns && e && this.columns.length !== e.length && r.error(`grid-column (${this.columns.length}) and grid-cell (${e.length}) count mismatch`);
		}
	}
};
o([p({
	selector: c.metadata.tag,
	flatten: !0
})], m.prototype, "columns", void 0), m = o([t()], m);
//#endregion
export { m as GridHeader };

//# sourceMappingURL=header2.js.map