import { EntityAttributeEnums, LogicalSearchOperatorEnums, UdpEnums } from "../../enums/unitySystemEnums.mjs";
import { useTenantStore } from "../../stores/tenantStore.mjs";
import { useUser } from "../../utilities/auth/useUser.mjs";
import { useShellStore } from "../../stores/shellStore.mjs";
import { useActionState } from "../../hooks/useActions.mjs";
import { getSearchObject } from "../../utilities/search/SearchUtilities.mjs";
import { executeQueryAdHoc, getBaseMethod } from "../utilities/methodUtils.mjs";
import { ListSearch } from "./ListSearch.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect, useState } from "react";
//#region src/udp/ShortcutContent/ShortcutContentFinder.jsx
const ShortcutContentFinder = (props) => {
	const $ = c(14);
	const { onSelect } = props;
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = [];
		$[0] = t0;
	} else t0 = $[0];
	const [shortcutContentOptions, setShortCutContentOptions] = useState(t0);
	const { catalogPromotedEntities } = useActionState();
	const shellHidden = useShellStore(_temp);
	const user = useUser();
	const isProductTenant = useTenantStore(_temp2);
	let t1;
	if ($[1] !== catalogPromotedEntities) {
		t1 = getBaseMethod(UdpEnums.Udp_Shortcut_Content, "unityBaseSearchMethod", catalogPromotedEntities);
		$[1] = catalogPromotedEntities;
		$[2] = t1;
	} else t1 = $[2];
	const shortcutContentSearchApiMethod = t1;
	let t2;
	if ($[3] !== isProductTenant || $[4] !== shortcutContentSearchApiMethod) {
		t2 = () => {
			const getTemplateOptions = async () => {
				let options = [];
				if (shortcutContentSearchApiMethod) {
					const filterElements = [];
					if (isProductTenant) filterElements.push({
						searchField: EntityAttributeEnums.Is_Product_ShortcutContent,
						searchValue: true,
						searchOperator: "="
					});
					const shortcutContentResponse = await executeQueryAdHoc({ data: getSearchObject(filterElements, LogicalSearchOperatorEnums.Or, 200, true) }, shortcutContentSearchApiMethod.apiMethodId);
					if (shortcutContentResponse?.status === 200) options = shortcutContentResponse.data?.pageList;
				}
				setShortCutContentOptions(options);
			};
			getTemplateOptions();
		};
		$[3] = isProductTenant;
		$[4] = shortcutContentSearchApiMethod;
		$[5] = t2;
	} else t2 = $[5];
	let t3;
	if ($[6] !== isProductTenant || $[7] !== shortcutContentSearchApiMethod || $[8] !== user) {
		t3 = [
			shortcutContentSearchApiMethod,
			setShortCutContentOptions,
			user,
			isProductTenant
		];
		$[6] = isProductTenant;
		$[7] = shortcutContentSearchApiMethod;
		$[8] = user;
		$[9] = t3;
	} else t3 = $[9];
	useEffect(t2, t3);
	const t4 = `calc(100vh - ${shellHidden ? "614px" : "669px"})`;
	let t5;
	if ($[10] !== onSelect || $[11] !== shortcutContentOptions || $[12] !== t4) {
		t5 = /* @__PURE__ */ React.createElement(ListSearch, {
			items: shortcutContentOptions,
			onClick: onSelect,
			searchLabel: "Filter Shortcuts",
			includeTags: true,
			maxHeight: t4
		});
		$[10] = onSelect;
		$[11] = shortcutContentOptions;
		$[12] = t4;
		$[13] = t5;
	} else t5 = $[13];
	return t5;
};
function _temp(state) {
	return state.shellHidden;
}
function _temp2(state_0) {
	return state_0.isProductTenant;
}
//#endregion
export { ShortcutContentFinder };

//# sourceMappingURL=ShortcutContentFinder.mjs.map