import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
import { t } from "./vue-i18n-Db_oYfO8.js";
import { n, t as r } from "./sortQueryAdapters-CyYXvnDN.js";
import { t as i } from "./composables-DEdhzUqN.js";
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createSlots as d, createTextVNode as f, createVNode as p, defineComponent as m, nextTick as h, normalizeStyle as g, onMounted as _, onUnmounted as v, openBlock as y, ref as b, renderList as x, renderSlot as S, resolveComponent as C, resolveDirective as w, toDisplayString as T, useSlots as E, useTemplateRef as D, withCtx as O, withDirectives as k, withModifiers as A } from "vue";
//#region src/components/wt-table/wt-table.vue?vue&type=script&setup=true&lang.ts
var j = { class: "wt-table__th__content typo-body-1-bold" }, M = { class: "wt-table__td__actions" }, N = 10, P = /*#__PURE__*/ e(/* @__PURE__ */ m({
	__name: "wt-table",
	props: {
		headers: { default: () => [] },
		data: { default: () => [] },
		sortable: {
			type: Boolean,
			default: !1
		},
		selectable: {
			type: Boolean,
			default: !0
		},
		selected: {},
		gridActions: {
			type: Boolean,
			default: !0
		},
		fixedActions: {
			type: Boolean,
			default: !1
		},
		headless: {
			type: Boolean,
			default: !1
		},
		rowReorder: {
			type: Boolean,
			default: !1
		},
		dataKey: { default: "" },
		isRowReorderDisabled: {
			type: Function,
			default: () => !1
		},
		rowExpansion: {
			type: Boolean,
			default: !1
		},
		rowClass: {
			type: Function,
			default: () => ""
		},
		rowStyle: {
			type: Function,
			default: () => ({})
		},
		resizableColumns: {
			type: Boolean,
			default: !1
		},
		reorderableColumns: {
			type: Boolean,
			default: !1
		},
		rowExpansionDisabled: {
			type: Function,
			default: () => !1
		},
		lazy: {
			type: Boolean,
			default: !1
		},
		onLoading: {},
		loading: { type: Boolean },
		itemSize: { default: 40 },
		value: {},
		rows: {},
		first: {},
		totalRecords: {},
		paginator: { type: Boolean },
		paginatorPosition: {},
		alwaysShowPaginator: { type: Boolean },
		paginatorTemplate: {},
		pageLinkSize: {},
		rowsPerPageOptions: {},
		currentPageReportTemplate: {},
		loadingIcon: {},
		sortField: {},
		sortOrder: {},
		nullSortOrder: {},
		defaultSortOrder: {},
		multiSortMeta: {},
		sortMode: {},
		removableSort: { type: Boolean },
		filters: {},
		filterDisplay: {},
		globalFilterFields: {},
		filterLocale: {},
		selection: {},
		selectionMode: {},
		compareSelectionBy: {},
		metaKeySelection: { type: Boolean },
		contextMenu: { type: Boolean },
		contextMenuSelection: {},
		selectAll: { type: [Boolean, null] },
		rowHover: { type: Boolean },
		csvSeparator: {},
		exportFilename: {},
		exportFunction: {},
		columnResizeMode: {},
		expandedRows: {},
		expandedRowIcon: {},
		collapsedRowIcon: {},
		rowGroupMode: {},
		groupRowsBy: {},
		expandableRowGroups: { type: Boolean },
		expandedRowGroups: {},
		stateStorage: {},
		stateKey: {},
		editMode: {},
		editingRows: {},
		scrollable: { type: Boolean },
		scrollHeight: {},
		virtualScrollerOptions: {},
		frozenValue: {},
		breakpoint: {},
		showHeaders: { type: Boolean },
		showGridlines: { type: Boolean },
		stripedRows: { type: Boolean },
		highlightOnSelect: { type: Boolean },
		size: {},
		tableStyle: {},
		tableClass: {},
		tableProps: {},
		filterInputProps: {},
		filterButtonProps: {},
		editButtonProps: {},
		dt: {},
		pt: {},
		ptOptions: {},
		unstyled: { type: Boolean }
	},
	emits: [
		"sort",
		"update:selected",
		"reorder:row",
		"column-resize",
		"column-reorder"
	],
	setup(e, { emit: m }) {
		let P = e, { t: F } = t(), I = E(), L = m, R = D("table"), z = b(0), B = b([]), { addTableDragListener: V, removeTableDragListener: H } = i(R, P.reorderableColumns), U = [
			"row-select",
			"row-reorder",
			"row-actions",
			"row-expander"
		], W = o(() => P.selectable ? P.selected || P.data.filter((e) => e._isSelected) : []), G = o(() => P.headers.map((e) => !e.text && e.locale ? {
			...e,
			text: typeof e.locale == "string" ? F(e.locale) : F(...e.locale)
		} : e)), K = (e) => e.show === !1, q = (e) => {
			let t = e.width || "140px";
			return P.lazy ? { width: t } : { minWidth: t };
		}, J = o(() => Object.keys(I).some((e) => e.includes("-footer"))), Y = o(() => Object.keys(I).some((e) => e === "footer")), X = o(() => W.value.length === P.data.length && P.data.length > 0), Z = o(() => P.headers.find((e) => e.sort === r.ASC || e.sort === r.DESC)?.field ?? null), Q = ({ sortField: e }) => {
			let t = G.value.find((t) => t.field === e);
			if (!$(t)) return;
			let r = n(t.sort);
			L("sort", t, r);
		}, $ = ({ sort: e }) => P.sortable && e !== void 0, ee = () => {
			P.selected ? X.value ? L("update:selected", []) : L("update:selected", [...P.data]) : X.value ? P.data.forEach((e) => {
				e._isSelected = !1;
			}) : P.data.forEach((e) => {
				e._isSelected = !0;
			});
		}, te = (e, t) => {
			P.selected ? t ? L("update:selected", [...W.value, e]) : L("update:selected", W.value.filter((t) => t !== e)) : e._isSelected = !e._isSelected;
		}, ne = ({ element: e }) => {
			let t = e.getAttribute("data-column-field"), n = getComputedStyle(e), r = Number.parseFloat(n.paddingLeft), i = Number.parseFloat(n.paddingRight), a = e.offsetWidth - r - i;
			L("column-resize", {
				columnName: t,
				columnWidth: `${a}px`
			});
		}, re = () => {
			let e = R.value.$el.querySelector(".p-datatable-table-container").scrollLeft, t = R.value.d_columnOrder.filter((e) => !U.includes(e));
			z.value += 1, L("column-reorder", t), h(() => {
				V(), R.value.$el.querySelector(".p-datatable-table-container").scrollLeft = e;
			});
		}, ie = (e) => B.value.some((t) => t?.id === e?.id), ae = (e) => {
			let t = B.value.findIndex((t) => t.id === e.id);
			t === -1 ? B.value.push(e) : B.value.splice(t, 1);
		}, oe = o(() => {
			if (P.lazy) return {
				lazy: P.lazy,
				onLazyLoad: P.onLoading,
				itemSize: P.itemSize,
				numToleratedItems: N,
				totalRecords: P.data.length,
				autoSize: !0
			};
		});
		return _(() => {
			V();
		}), v(() => {
			H();
		}), (t, n) => {
			let r = C("wt-icon-btn"), i = C("p-column"), o = C("wt-icon"), m = C("wt-checkbox"), h = C("p-table"), _ = w("tooltip");
			return y(), s(h, {
				key: z.value,
				ref_key: "table",
				ref: R,
				"expanded-rows": B.value,
				"reorderable-columns": e.reorderableColumns,
				"resizable-columns": e.resizableColumns,
				"row-class": e.rowClass,
				"row-style": e.rowStyle,
				"show-headers": !e.headless,
				value: e.data,
				"sort-field": Z.value,
				"data-key": P.dataKey,
				class: "wt-table",
				"column-resize-mode": "expand",
				lazy: "",
				"scroll-height": "flex",
				scrollable: "",
				"virtual-scroller-options": oe.value,
				pt: { tableContainer: "wt-scrollbar" },
				onSort: Q,
				"onUpdate:expandedRows": n[0] ||= (e) => B.value = e,
				onColumnResizeEnd: ne,
				onColumnReorder: re,
				onRowReorder: n[1] ||= ({ dragIndex: e, dropIndex: t }) => L("reorder:row", {
					oldIndex: e,
					newIndex: t
				})
			}, d({
				expansion: O(({ data: e }) => [u("div", null, [S(t.$slots, "expansion", { item: e }, void 0, !0)])]),
				default: O(() => [
					e.rowExpansion ? (y(), s(i, {
						key: 0,
						pt: { columnresizer: { class: { hidden: !0 } } },
						"body-style": "width: 1%;",
						"column-key": "row-expander",
						"header-style": "width: 1%;"
					}, {
						body: O(({ data: e }) => [p(r, {
							disabled: P.rowExpansionDisabled(e),
							icon: ie(e) ? "arrow-down" : "arrow-right",
							onClick: A((t) => ae(e), ["stop"])
						}, null, 8, [
							"disabled",
							"icon",
							"onClick"
						])]),
						_: 1
					})) : c("", !0),
					e.rowReorder ? (y(), s(i, {
						key: 1,
						pt: { columnresizer: { class: { hidden: !0 } } },
						"reorderable-column": !1,
						"body-style": "width: 1%;",
						"column-key": "row-reorder",
						"header-style": "width: 1%;",
						"row-reorder": ""
					}, {
						body: O(({ data: t }) => [e.isRowReorderDisabled(t) ? c("", !0) : (y(), s(o, {
							key: 0,
							"data-pc-section": "reorderablerowhandle",
							icon: "move"
						}))]),
						_: 1
					})) : c("", !0),
					e.selectable ? (y(), s(i, {
						key: 2,
						pt: { columnresizer: { class: { hidden: !0 } } },
						"reorderable-column": !1,
						"body-style": "width: 1%;",
						"column-key": "row-select",
						"header-style": "width: 1%;"
					}, {
						header: O(() => [p(m, {
							selected: X.value,
							"onUpdate:selected": ee
						}, null, 8, ["selected"])]),
						body: O(({ data: e }) => [e ? (y(), s(m, {
							key: 0,
							selected: W.value.includes(e),
							"onUpdate:selected": (t) => te(e, t)
						}, null, 8, ["selected", "onUpdate:selected"])) : c("", !0)]),
						_: 1
					})) : c("", !0),
					(y(!0), l(a, null, x(G.value, (e, n) => (y(), s(i, {
						key: e.value,
						"column-key": e.field,
						field: e.field,
						hidden: K(e),
						pt: { root: { "data-column-field": e.field } },
						sortable: $(e)
					}, d({
						header: O(() => [S(t.$slots, `header-${e.value}`, {
							index: n,
							header: e
						}, () => [u("div", j, [k((y(), l("span", null, [f(T(e.text), 1)])), [[_, e.text]]), e.sort === "asc" ? (y(), s(o, {
							key: 0,
							class: "wt-table__th__sort-arrow wt-table__th__sort-arrow--asc",
							icon: "sort-arrow-up",
							size: "sm"
						})) : e.sort === "desc" ? (y(), s(o, {
							key: 1,
							class: "wt-table__th__sort-arrow wt-table__th__sort-arrow--desc",
							icon: "sort-arrow-down",
							size: "sm"
						})) : c("", !0)])], !0)]),
						body: O(({ data: n, index: r }) => [u("div", {
							style: g(q(e)),
							class: "wt-table__td__content typo-body-1"
						}, [n ? S(t.$slots, e.value, {
							key: 0,
							index: r,
							item: n
						}, () => [f(T(n[e.value]), 1)], !0) : c("", !0)], 4)]),
						sorticon: O(() => []),
						_: 2
					}, [J.value ? {
						name: "footer",
						fn: O(() => [S(t.$slots, `${e.value}-footer`, {}, void 0, !0)]),
						key: "0"
					} : void 0]), 1032, [
						"column-key",
						"field",
						"hidden",
						"pt",
						"sortable"
					]))), 128)),
					e.gridActions ? (y(), s(i, {
						key: 3,
						frozen: e.fixedActions,
						"align-frozen": "right",
						"column-key": "row-actions",
						style: { width: "112px" }
					}, {
						header: O(() => [S(t.$slots, "actions-header", {}, void 0, !0)]),
						body: O(({ data: e, index: n }) => [u("div", M, [e ? S(t.$slots, "actions", {
							key: 0,
							index: n,
							item: e
						}, void 0, !0) : c("", !0)])]),
						_: 3
					}, 8, ["frozen"])) : c("", !0)
				], void 0, !0),
				_: 2
			}, [Y.value ? {
				name: "footer",
				fn: O(() => [S(t.$slots, "footer", {}, void 0, !0)]),
				key: "0"
			} : void 0]), 1032, [
				"expanded-rows",
				"reorderable-columns",
				"resizable-columns",
				"row-class",
				"row-style",
				"show-headers",
				"value",
				"sort-field",
				"data-key",
				"virtual-scroller-options"
			]);
		};
	}
}), [["__scopeId", "data-v-88411100"]]);
//#endregion
export { P as default };
