import { audit as e } from "../internal/controllers/audit.controller.js";
import { onChildListMutation as t } from "../internal/utils/events.js";
import { appendRootNodeStyle as n } from "../internal/utils/dom.js";
import { keyNavigationList as r } from "../internal/controllers/keynav-list.controller.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.130.0/helpers/decorate.js";
import { updateNodeSelection as s } from "./utils.js";
import { TreeNode as c } from "./tree-node2.js";
import l from "./tree.js";
import u from "./tree.global.js";
import { LitElement as d, html as f } from "lit";
import { property as p } from "lit/decorators/property.js";
//#region src/tree/tree.ts
var m = class extends d {
	constructor(...e) {
		super(...e), this.behaviorExpand = !1, this.behaviorSelect = !1, this.border = !1, this.#e = [];
	}
	static {
		this.styles = a([l]);
	}
	static {
		this.metadata = {
			tag: "nve-tree",
			version: "0.2.3",
			children: ["nve-tree-node"]
		};
	}
	get nodes() {
		return Array.from(this.querySelectorAll(c.metadata.tag));
	}
	get keynavListConfig() {
		return {
			items: this.openNodes.map((e) => e.shadowRoot.querySelector("[part=\"_node-header\"]")).filter((e) => e !== null),
			layout: "vertical"
		};
	}
	get openNodes() {
		return this.nodes.filter((e) => e.expanded || e.parentNode.expanded || e.parentNode === this);
	}
	render() {
		return f`<div internal-host><slot name="nodes"></slot></div>`;
	}
	#e;
	connectedCallback() {
		super.connectedCallback(), i(this), n(this, u), this._internals.role = "tree", this.#e.push(t(this, () => {
			this.#t();
		}, { subtree: !0 }));
	}
	disconnectedCallback() {
		super.disconnectedCallback(), this.#e.forEach((e) => e.disconnect());
	}
	async updated(e) {
		super.updated(e), await this.updateComplete, this.#t();
	}
	#t() {
		this.#n(), this.#r();
	}
	#n() {
		this.nodes.forEach((e) => {
			e.selectable = this.selectable, e.behaviorExpand = this.behaviorExpand, e.behaviorSelect = this.behaviorSelect;
		});
	}
	#r() {
		this.behaviorSelect && this.selectable === "multi" && this.nodes.forEach((e) => s(e));
	}
};
o([p({ type: String })], m.prototype, "selectable", void 0), o([p({
	type: Boolean,
	attribute: "behavior-expand"
})], m.prototype, "behaviorExpand", void 0), o([p({
	type: Boolean,
	attribute: "behavior-select"
})], m.prototype, "behaviorSelect", void 0), o([p({
	type: Boolean,
	reflect: !0
})], m.prototype, "border", void 0), m = o([e(), r()], m);
//#endregion
export { m as Tree };

//# sourceMappingURL=tree2.js.map