import { createChangeEvent, createFocusEvent } from "./utils/formEvents.mjs";
import { createAzureMapsProviders, getDefaultAzureMapsKey } from "./UdpLocationInput.azure.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { UdpFluentLocationInput } from "udp-react-stencil-component-library";
//#region src/UI/fluent-web-components/UdpLocationInput.tsx
const UdpLocationInput = (t0) => {
	const $ = c(39);
	let azureMapsKey;
	let error;
	let helperText;
	let hint;
	let name;
	let onBlur;
	let onChange;
	let onFocus;
	let props;
	let reverseGeocode;
	let searchAddresses;
	let tileUrlTemplate;
	let value;
	if ($[0] !== t0) {
		({onChange, onBlur, onFocus, name, value, error, helperText, hint, azureMapsKey, tileUrlTemplate, searchAddresses, reverseGeocode, ...props} = t0);
		$[0] = t0;
		$[1] = azureMapsKey;
		$[2] = error;
		$[3] = helperText;
		$[4] = hint;
		$[5] = name;
		$[6] = onBlur;
		$[7] = onChange;
		$[8] = onFocus;
		$[9] = props;
		$[10] = reverseGeocode;
		$[11] = searchAddresses;
		$[12] = tileUrlTemplate;
		$[13] = value;
	} else {
		azureMapsKey = $[1];
		error = $[2];
		helperText = $[3];
		hint = $[4];
		name = $[5];
		onBlur = $[6];
		onChange = $[7];
		onFocus = $[8];
		props = $[9];
		reverseGeocode = $[10];
		searchAddresses = $[11];
		tileUrlTemplate = $[12];
		value = $[13];
	}
	let t1;
	if ($[14] !== name || $[15] !== onChange) {
		t1 = (e) => {
			onChange?.(createChangeEvent(e.detail, name, "location"));
		};
		$[14] = name;
		$[15] = onChange;
		$[16] = t1;
	} else t1 = $[16];
	const handleValueChanged = t1;
	let t2;
	if ($[17] !== name || $[18] !== onBlur) {
		t2 = () => {
			onBlur?.(createFocusEvent("blur", name));
		};
		$[17] = name;
		$[18] = onBlur;
		$[19] = t2;
	} else t2 = $[19];
	const handleBlur = t2;
	let t3;
	if ($[20] !== name || $[21] !== onFocus) {
		t3 = () => {
			onFocus?.(createFocusEvent("focus", name));
		};
		$[20] = name;
		$[21] = onFocus;
		$[22] = t3;
	} else t3 = $[22];
	const handleFocus = t3;
	let t4;
	if ($[23] !== azureMapsKey) {
		t4 = azureMapsKey === null ? "" : azureMapsKey ?? getDefaultAzureMapsKey();
		$[23] = azureMapsKey;
		$[24] = t4;
	} else t4 = $[24];
	const resolvedKey = t4;
	let t5;
	if ($[25] !== resolvedKey) {
		t5 = createAzureMapsProviders(resolvedKey);
		$[25] = resolvedKey;
		$[26] = t5;
	} else t5 = $[26];
	const azureProviders = t5;
	const resolvedTileUrl = tileUrlTemplate ?? azureProviders?.tileUrlTemplate;
	const resolvedSearch = searchAddresses ?? azureProviders?.searchAddresses;
	const resolvedReverse = reverseGeocode ?? azureProviders?.reverseGeocode;
	const hintStr = typeof hint === "string" ? hint : void 0;
	let normalizedError;
	let normalizedHint;
	if (typeof error === "string") {
		normalizedError = error;
		normalizedHint = hintStr;
	} else if (typeof error === "boolean") {
		normalizedError = error ? helperText || "" : void 0;
		normalizedHint = !error ? helperText || hintStr : hintStr;
	} else normalizedHint = hintStr ?? helperText;
	let t6;
	if ($[27] !== handleBlur || $[28] !== handleFocus || $[29] !== handleValueChanged || $[30] !== name || $[31] !== normalizedError || $[32] !== normalizedHint || $[33] !== props || $[34] !== resolvedReverse || $[35] !== resolvedSearch || $[36] !== resolvedTileUrl || $[37] !== value) {
		t6 = /* @__PURE__ */ React.createElement(UdpFluentLocationInput, {
			...props,
			name,
			value,
			error: normalizedError,
			hint: normalizedHint,
			tileUrlTemplate: resolvedTileUrl,
			searchAddresses: resolvedSearch,
			reverseGeocode: resolvedReverse,
			onValueChanged: handleValueChanged,
			onInputBlur: handleBlur,
			onInputFocus: handleFocus
		});
		$[27] = handleBlur;
		$[28] = handleFocus;
		$[29] = handleValueChanged;
		$[30] = name;
		$[31] = normalizedError;
		$[32] = normalizedHint;
		$[33] = props;
		$[34] = resolvedReverse;
		$[35] = resolvedSearch;
		$[36] = resolvedTileUrl;
		$[37] = value;
		$[38] = t6;
	} else t6 = $[38];
	return t6;
};
//#endregion
export { UdpLocationInput };

//# sourceMappingURL=UdpLocationInput.mjs.map