import { t as e } from "./vue-i18n-Db_oYfO8.js";
import { t } from "./debounce-Bp3jy7S5.js";
import "./useExpansion-DVdIpoOn.js";
import "./useWtTable-D_PxqVHO.js";
import { computed as n, nextTick as r, onMounted as i, onUnmounted as a, reactive as o, ref as s, watch as c } from "vue";
//#region src/components/_internals/composables/useGalleriaFullscreen/useGalleriaFullscreen.ts
var l = () => {
	let e = s(!1), t = () => {
		e.value ? o() : r();
	}, n = () => {
		e.value = !e.value;
	}, r = () => {
		let e = document.querySelector(".p-galleria");
		e.requestFullscreen ? e.requestFullscreen() : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.webkitRequestFullscreen ? e.webkitRequestFullscreen() : e.msRequestFullscreen && e.msRequestFullscreen();
	}, o = () => {
		document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen ? document.webkitExitFullscreen() : document.msExitFullscreen && document.msExitFullscreen();
	}, c = () => {
		document.addEventListener("fullscreenchange", n), document.addEventListener("mozfullscreenchange", n), document.addEventListener("webkitfullscreenchange", n), document.addEventListener("msfullscreenchange", n);
	}, l = () => {
		document.removeEventListener("fullscreenchange", n), document.removeEventListener("mozfullscreenchange", n), document.removeEventListener("webkitfullscreenchange", n), document.removeEventListener("msfullscreenchange", n);
	};
	return i(() => {
		c();
	}), a(() => {
		l();
	}), {
		fullScreen: e,
		toggleFullScreen: t
	};
}, u = (e) => {
	let t = ({ target: t }) => {
		t.classList.contains("p-galleria-mask") && (e.value = !1);
	};
	return {
		listenMaskElementClick: () => {
			document.querySelector(".p-galleria-mask")?.addEventListener("click", t);
		},
		removeMaskElementClick: () => {
			document.querySelector(".p-galleria-mask")?.removeEventListener("click", t);
		}
	};
}, d = (e) => {
	let t = n(() => e.value?.$el instanceof HTMLInputElement ? e.value?.$el : e.value?.$el?.querySelector("input"));
	return {
		focus: () => {
			t.value?.focus();
		},
		handleKeyup: (e) => e.stopPropagation(),
		removeAutocomplete: () => {
			t.value?.setAttribute("autocomplete", "off");
		}
	};
}, f = (e) => Array.isArray(e) ? e : e ? [e] : [], p = (e, t, n) => {
	let r = (e) => typeof e == "object" && !!e;
	return t.some((t) => n ? r(t) && r(e) ? t[n] === e[n] : !r(t) && r(e) ? t === e[n] : r(t) && !r(e) ? t[n] === e : t === e : t === e);
}, m = (e, t) => {
	if (!t) return [...new Set(e)];
	let n = /* @__PURE__ */ new Map();
	for (let r of e) {
		let e = typeof r == "object" && r ? r[t] : r;
		n.has(e) || n.set(e, r);
	}
	return [...n.values()];
}, h = (e, t, n) => e.filter((e) => n(e).toLowerCase().includes(t.toLowerCase())), g = ({ selected: e, filteredOptions: t, options: n, optionValue: i, dataKey: a, filterText: o, filterOptions: s, updateSelectedOptionsCache: c, selectRef: l, allowCustomValues: u, manualCustomValues: d, isSingle: m, emit: h }) => {
	let g = (e) => {
		let r = n.value.length ? n.value[0] : t.value[0];
		return r && typeof r == "object" ? Object.fromEntries(Object.keys(r).map((t) => [t, e])) : a.value ? { [a.value]: e } : e;
	};
	return { onInputKeydown: () => {
		if (!u.value || !o.value || f(e.value).some((e) => (a.value ? e[a.value] : e) === o.value)) return;
		let n = g(o.value);
		t.value.some((e) => p(e, [n], a.value)) || t.value.unshift(n), m ? (l.value?.hide(), e.value = n) : e.value = [...e.value, n], c(), r(() => {
			o.value = "", s("");
		});
	} };
}, _ = ({ selectId: e, selectRef: t, filterInput: n, searchMethod: r, filteredOptions: i, filterText: a, filterOptions: o, resetAndFetch: c, sortOptions: l, fetchOptions: u, isLoading: d, searchHasNext: f }) => {
	let p = s(!1), m = null, h = null, g = () => document.querySelector(`#${e.value}_list`)?.parentElement, _ = (e) => {
		let t = e.target;
		t.scrollTop + t.clientHeight >= t.scrollHeight - 40 && !d.value && f.value && u();
	};
	return {
		isDropdownOpen: p,
		onDropdownBeforeShow: () => {
			p.value = !0, i.value = l(i.value);
		},
		onDropdownBeforeHide: () => {
			let e = t?.value?.overlay;
			e && (e.style.pointerEvents = "none"), g()?.scrollTo(0, 0);
		},
		onDropdownShow: () => {
			n.value?.focus(), r.value && g()?.addEventListener("scroll", _);
			let e = t?.value?.overlay;
			e && (m = new ResizeObserver(() => {
				t.value?.alignOverlay();
			}), m.observe(e));
			let i = t?.value?.$el;
			if (i) {
				let e = i.getBoundingClientRect().top, n = i.getBoundingClientRect().left, r = () => {
					let a = i.getBoundingClientRect();
					(a.top !== e || a.left !== n) && (e = a.top, n = a.left, t.value?.alignOverlay()), h = requestAnimationFrame(r);
				};
				h = requestAnimationFrame(r);
			}
		},
		onDropdownHide: () => {
			p.value = !1, m?.disconnect(), m = null, h !== null && (cancelAnimationFrame(h), h = null), r.value ? (g()?.removeEventListener("scroll", _), a.value && c()) : o(""), a.value = "";
		}
	};
}, v = (e) => {
	let t = s(!1), n = null;
	return c(e, (e) => {
		e ? (n && clearTimeout(n), t.value = !0) : n = setTimeout(() => {
			t.value = !1;
		}, 500);
	}), { showFooterLoader: t };
}, y = ({ selected: n, options: r, optionLabel: i, optionValue: a, dataKey: l, allowCustomValues: u, searchMethod: d, disabledOptions: g }) => {
	let { t: _ } = e(), v = s(""), y = s(r.value), b = s(!1), x = s(!0), S = o({
		page: 1,
		search: ""
	}), C = (e) => {
		let t = m(e, l.value);
		if (!n.value) return t;
		let r = f(n.value), i = [], a = [];
		for (let e of t) (p(e, r, l.value) ? i : a).push(e);
		return i.concat(a);
	}, w = (e) => {
		if (!e) return "";
		if (u.value && e.isTag) return e.label;
		if (a?.value && typeof e != "object") {
			let t = [...y.value, ...E.value].find((t) => t[a.value] === e);
			return t ? w(t) : String(e);
		}
		return i.value && e[i.value] ? e[i.value] : e.locale ? Array.isArray(e.locale) ? _(...e.locale) : _(e.locale) : e.name || e;
	}, T = (e, t) => h(e, t, w), E = s([]), D = () => {
		if (!n.value) {
			E.value = [];
			return;
		}
		let e = f(n.value), t = (t) => p(t, e, l.value), r = y.value.filter(t), i = m([...E.value, ...r], l.value);
		E.value = i.filter(t);
	}, O = async () => {
		if (!d.value || !a?.value || !n.value) return;
		let e = f(n.value);
		if (!e.length) return;
		b.value = !0;
		let { items: t } = await d.value({
			[l.value]: e,
			size: e.length
		});
		E.value = m([...E.value, ...t], l.value), b.value = !1;
	}, k = async () => {
		if (!d.value) return;
		let { search: e, page: t } = S;
		b.value = !0;
		let { items: r, next: i } = await d.value({
			search: e,
			page: t
		}), a = e ? T(E.value, e) : E.value, o = S.page === 1 ? m([...a, ...r], l.value) : y.value.concat(r);
		y.value = C(o), N(n.value), x.value = i, S.page += 1, b.value = !1;
	}, A = (e = "") => {
		S.search = e, S.page = 1, k();
	}, j = t((e) => A(e)), M = (e) => {
		if (v.value = e, d.value) j(e);
		else {
			let t = T(E.value, e), n = T(r.value, e);
			y.value = C(m([...t, ...n], l.value));
		}
	}, N = (e) => {
		if (!e || !d.value) return;
		let t = f(e).filter((e) => !p(e, y.value, l.value));
		if (t.length) {
			let e = t.map((e) => E.value.find((t) => t[l.value] === e) ?? e);
			y.value = C(m([...T(e, v.value), ...y.value], l.value));
		}
	};
	return c(() => n.value, (e, t) => {
		D(), N(e);
	}), c(() => r.value, (e) => {
		d.value || (y.value = C(e));
	}), {
		filterText: v,
		filteredOptions: y,
		isLoading: b,
		searchHasNext: x,
		sortOptions: C,
		getOptionLabel: w,
		fetchOptions: k,
		fetchSelectedByIds: O,
		resetAndFetch: A,
		filterOptions: M,
		updateSelectedOptionsCache: D,
		isOptionDisabled: (e) => g?.value ? Array.isArray(g.value) ? g.value.some((t) => typeof t == "object" && !!t && typeof e == "object" && !!e && t[l.value] === e[l.value]) : !!g.value : !1
	};
}, b = ({ selected: e, options: t, optionLabel: n, optionValue: r, dataKey: a, allowCustomValues: o, manualCustomValues: s = !1, filterInput: c, selectRef: l, searchMethod: u, selectId: d, isSingle: f, disabledOptions: p = void 0, emit: m = () => {} }) => {
	let { filterText: h, filteredOptions: b, isLoading: x, searchHasNext: S, sortOptions: C, getOptionLabel: w, fetchOptions: T, fetchSelectedByIds: E, resetAndFetch: D, filterOptions: O, updateSelectedOptionsCache: k, isOptionDisabled: A } = y({
		selected: e,
		options: t,
		optionLabel: n,
		optionValue: r,
		dataKey: a,
		allowCustomValues: o,
		searchMethod: u,
		disabledOptions: p
	}), { isDropdownOpen: j, onDropdownBeforeShow: M, onDropdownBeforeHide: N, onDropdownShow: P, onDropdownHide: F } = _({
		selectId: d,
		selectRef: l,
		filterInput: c,
		searchMethod: u,
		filteredOptions: b,
		filterText: h,
		filterOptions: O,
		resetAndFetch: D,
		sortOptions: C,
		fetchOptions: T,
		isLoading: x,
		searchHasNext: S
	}), { showFooterLoader: I } = v(x), { onInputKeydown: L } = g({
		selected: e,
		filteredOptions: b,
		options: t,
		optionValue: r,
		dataKey: a,
		filterText: h,
		filterOptions: O,
		updateSelectedOptionsCache: k,
		selectRef: l,
		allowCustomValues: o,
		manualCustomValues: s,
		isSingle: f,
		emit: m
	});
	return i(async () => {
		await E(), u.value && T();
	}), {
		isLoading: x,
		showFooterLoader: I,
		isDropdownOpen: j,
		filterText: h,
		filteredOptions: b,
		getOptionLabel: w,
		fetchOptions: T,
		filterOptions: O,
		onDropdownBeforeShow: M,
		onDropdownBeforeHide: N,
		onDropdownShow: P,
		onDropdownHide: F,
		onInputKeydown: L,
		clearValue: () => {
			let t = "";
			Array.isArray(e.value) ? t = [] : typeof e.value == "object" && e.value !== null && (t = {}), e.value = t, m("reset", t);
		},
		isOptionDisabled: A
	};
}, x = (e, t) => {
	let n = null, r = null, i = null, a = !1, o = () => {
		if (!r || !a || i === null) return;
		let e = r.getBoundingClientRect(), t = i - e.left, s = e.right - i, c = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2, l = 0, u = 0;
		if (t < 150 && r.scrollLeft > 0 ? (l = -1, u = t) : s < 150 && (l = 1, u = s), l !== 0) {
			let e = 1 + 24 * c(1 - u / 150);
			r.scrollLeft += e * l, n = requestAnimationFrame(o);
		} else n = null;
	}, s = (t) => {
		t.dataTransfer.effectAllowed = "move";
		let n = t.target.cloneNode(!0);
		n.style.position = "absolute", n.style.top = "-9999px", n.style.background = "var(--p-datatable-header-cell-drag-background)", n.style.width = `${t.target.offsetWidth}px`, document.body.appendChild(n), t.dataTransfer.setDragImage(n, t.offsetX, t.offsetY), setTimeout(() => {
			document.body.removeChild(n);
		}, 0), a = !0, r ||= e.value?.$el?.querySelector(".p-datatable-table-container");
	}, c = (e) => {
		i = e.clientX, !n && a && (n = requestAnimationFrame(o));
	}, l = () => {
		n &&= (cancelAnimationFrame(n), null), a = !1, i = null, r = null;
	};
	return {
		addTableDragListener: () => {
			if (!t) return;
			let n = e.value?.$el;
			n?.addEventListener("dragstart", s), n?.addEventListener("dragover", c), n?.addEventListener("dragend", l);
		},
		removeTableDragListener: () => {
			if (!t) return;
			let n = e.value?.$el;
			n?.removeEventListener("dragstart", s), n?.removeEventListener("dragover", c), n?.removeEventListener("dragend", l);
		}
	};
};
//#endregion
export { u as a, d as i, b as n, l as o, f as r, x as t };
