import { i as require_react, n as require_compiler_runtime, r as require_jsx_runtime, t as theme, u as __toESM } from "./theme.mnyG70gE.chunk.js";
import { Bt as setLastTransaction, En as integerToCurrency, Gt as useDispatch, Kr as send, Kt as useSelector, Mn as reapplyThousandSeparators, Pn as titleFirst, Sn as getChangedValues, Tn as integerToAmount, U as pushModal, Wt as useSavePayeeLocationMutation, Zt as locationService, an as useAccounts, en as addNotification, fi as isIOSAgent, gn as appendDecimals, hn as amountToInteger, ii as useTranslation, mn as amountToCurrency, oi as Trans, v as styles, vn as applyFindReplace, wn as groupById, x as css, xn as diffItems, yn as currencyToAmount } from "./extends.CfN_tLZB.chunk.js";
import { Bi as SvgPencilWriteAlternate, Bn as ToggleField, Bu as format, Ca as SvgTag, Cr as getDayMonthFormat, Dn as calculateDistance, Ei as useSyncedPref, Hi as SvgNotesPaper, Hu as isValid, Io as useLocalPref, Iu as parse, L as useCursorPosition, Ln as FieldLabel, Lr as monthFromDate, N as useTagCSS, P as useFilteredTags, Pa as SvgLocation, Pu as parseISO, R as useRefEventListener, Rn as InputField, U as useNearbyPayees, V as usePayees, W as useLocationPermission, Wl as useNavigate, Xu as q, _ as useDateFormat, _a as SvgWallet, _s as Button, _u as useSearchParams, bo as SvgAdd, ct as useCategories, cu as View, dn as realizeTempTransactions, ei as aqlQuery, es as SvgSplit, fn as splitTransaction, fr as currentDay, gr as dayFromDate, gs as Text, gu as useParams, hn as updateTransaction, hu as useLocation, in as getUpcomingDays, io as SvgCheveronDown, j as useMergedRefs, ja as SvgPiggyBank, ji as Toggle, mn as ungroupTransactions, on as addSplitTransaction, rn as getStatusLabel, ro as SvgCheveronLeft, sn as deleteTransaction, un as makeChild, uo as SvgCalendar, v as AmountInput$1, va as SvgUser, vr as differenceInCalendarDays, wo as Page, wr as getDayMonthRegex, x as createSingleTimeScheduleFromTransaction, xa as SvgTrash, xo as MobilePageHeader, z as useCurrentWordRange, zn as TapField, zt as makeAmountFullStyle } from "./merge.C77XY6IK.chunk.js";
//#region src/components/mobile/MobileBackButton.tsx
var import_compiler_runtime = require_compiler_runtime();
var import_react = /* @__PURE__ */ __toESM(require_react());
var import_jsx_runtime = require_jsx_runtime();
function MobileBackButton(t0) {
	const $ = (0, import_compiler_runtime.c)(15);
	let onPress;
	let props;
	let style;
	if ($[0] !== t0) {
		({onPress, style, ...props} = t0);
		$[0] = t0;
		$[1] = onPress;
		$[2] = props;
		$[3] = style;
	} else {
		onPress = $[1];
		props = $[2];
		style = $[3];
	}
	const navigate = useNavigate();
	let t1;
	if ($[4] !== style) {
		t1 = {
			margin: 10,
			...style
		};
		$[4] = style;
		$[5] = t1;
	} else t1 = $[5];
	let t2;
	if ($[6] !== navigate || $[7] !== onPress) {
		t2 = onPress || (() => navigate(-1));
		$[6] = navigate;
		$[7] = onPress;
		$[8] = t2;
	} else t2 = $[8];
	let t3;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheveronLeft, { style: {
			width: 30,
			height: 30,
			margin: -10,
			marginLeft: -5
		} });
		$[9] = t3;
	} else t3 = $[9];
	let t4;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				...styles.text,
				fontWeight: 500,
				marginLeft: 5,
				marginRight: 5
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Back" })
		});
		$[10] = t4;
	} else t4 = $[10];
	let t5;
	if ($[11] !== props || $[12] !== t1 || $[13] !== t2) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			variant: "bare",
			style: t1,
			onPress: t2,
			...props,
			children: [t3, t4]
		});
		$[11] = props;
		$[12] = t1;
		$[13] = t2;
		$[14] = t5;
	} else t5 = $[14];
	return t5;
}
//#endregion
//#region src/components/mobile/utils.ts
function getPrettyPayee({ t, transaction, payee, transferAccount }) {
	if (!transaction) return "";
	if (transferAccount) return t("Transfer {{direction}} {{accountName}}", {
		direction: transaction?.amount > 0 ? t("from") : t("to"),
		accountName: transferAccount.name
	});
	else if (transaction.is_parent) return t("Split");
	else if (payee) return payee.name;
	return "";
}
//#endregion
//#region src/hooks/useInitialMount.ts
function useInitialMount() {
	const initial = (0, import_react.useRef)(true);
	if (initial.current) {
		initial.current = false;
		return true;
	}
	return false;
}
//#endregion
//#region src/hooks/useInputRefValue.ts
function useInputRefValue(inputRef) {
	const [value, setValue] = (0, import_react.useState)("");
	useRefEventListener(inputRef, "input", (e) => setValue(e.target.value), [setValue]);
	(0, import_react.useEffect)(() => setValue(inputRef.current?.value ?? ""), [inputRef, setValue]);
	function _setValue(newValue) {
		if (!inputRef.current) return;
		(Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set)?.call(inputRef.current, newValue);
		inputRef.current.dispatchEvent(new Event("input", { bubbles: true }));
	}
	return [value, _setValue];
}
//#endregion
//#region src/hooks/useSingleActiveEditForm.tsx
var SingleActiveEditFormContext = (0, import_react.createContext)(void 0);
function SingleActiveEditFormProvider(t0) {
	const $ = (0, import_compiler_runtime.c)(13);
	const { formName, children } = t0;
	const [editingField, setEditingField] = (0, import_react.useState)(null);
	const cleanupRef = (0, import_react.useRef)(null);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = () => {
			const editCleanup = cleanupRef.current;
			if (typeof editCleanup === "function") editCleanup?.();
			cleanupRef.current = null;
		};
		$[0] = t1;
	} else t1 = $[0];
	const runCleanup = t1;
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = (action) => {
			cleanupRef.current = action?.();
		};
		$[1] = t2;
	} else t2 = $[1];
	const runAction = t2;
	let t3;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = (delayMs) => {
			setTimeout(() => {
				runCleanup();
				setEditingField(null);
			}, delayMs);
		};
		$[2] = t3;
	} else t3 = $[2];
	const onClearActiveEdit = t3;
	let t4;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = (field, action_0) => {
			runAction(action_0);
			setEditingField(field);
		};
		$[3] = t4;
	} else t4 = $[3];
	const onActiveEdit = t4;
	let t5;
	if ($[4] !== editingField) {
		t5 = (field_0, action_1, options) => {
			if (editingField === field_0) return;
			if (editingField) onClearActiveEdit(options?.clearActiveEditDelayMs);
			else onActiveEdit(field_0, action_1);
		};
		$[4] = editingField;
		$[5] = t5;
	} else t5 = $[5];
	const onRequestActiveEdit = t5;
	let t6;
	if ($[6] !== editingField || $[7] !== formName || $[8] !== onRequestActiveEdit) {
		t6 = {
			formName,
			editingField,
			onRequestActiveEdit,
			onClearActiveEdit
		};
		$[6] = editingField;
		$[7] = formName;
		$[8] = onRequestActiveEdit;
		$[9] = t6;
	} else t6 = $[9];
	let t7;
	if ($[10] !== children || $[11] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SingleActiveEditFormContext.Provider, {
			value: t6,
			children
		});
		$[10] = children;
		$[11] = t6;
		$[12] = t7;
	} else t7 = $[12];
	return t7;
}
function useSingleActiveEditForm() {
	const $ = (0, import_compiler_runtime.c)(5);
	const context = (0, import_react.useContext)(SingleActiveEditFormContext);
	if (!context) return null;
	let t0;
	if ($[0] !== context.editingField || $[1] !== context.formName || $[2] !== context.onClearActiveEdit || $[3] !== context.onRequestActiveEdit) {
		t0 = {
			formName: context.formName,
			editingField: context.editingField,
			onRequestActiveEdit: context.onRequestActiveEdit,
			onClearActiveEdit: context.onClearActiveEdit
		};
		$[0] = context.editingField;
		$[1] = context.formName;
		$[2] = context.onClearActiveEdit;
		$[3] = context.onRequestActiveEdit;
		$[4] = t0;
	} else t0 = $[4];
	return t0;
}
//#endregion
//#region src/components/mobile/transactions/FocusableAmountInput.tsx
var AmountInput = (0, import_react.memo)(function AmountInput(t0) {
	const $ = (0, import_compiler_runtime.c)(65);
	const { focused, style, textStyle, ...props } = t0;
	const [editing, setEditing] = (0, import_react.useState)(false);
	const [text, setText] = (0, import_react.useState)("");
	const [value, setValue] = (0, import_react.useState)(0);
	const inputRef = (0, import_react.useRef)(null);
	const [hideFraction] = useSyncedPref("hideFraction");
	const mergedInputRef = useMergedRefs(props.inputRef, inputRef);
	const initialValue = Math.abs(props.value);
	let t1;
	let t2;
	if ($[0] !== focused) {
		t1 = () => {
			if (focused) inputRef.current?.focus();
		};
		t2 = [focused];
		$[0] = focused;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	(0, import_react.useEffect)(t1, t2);
	let t3;
	if ($[3] !== initialValue || $[4] !== setEditing || $[5] !== setText || $[6] !== setValue) {
		t3 = () => {
			setEditing(false);
			setText("");
			setValue(initialValue);
		};
		$[3] = initialValue;
		$[4] = setEditing;
		$[5] = setText;
		$[6] = setValue;
		$[7] = t3;
	} else t3 = $[7];
	let t4;
	if ($[8] !== initialValue) {
		t4 = [initialValue];
		$[8] = initialValue;
		$[9] = t4;
	} else t4 = $[9];
	(0, import_react.useEffect)(t3, t4);
	let onFocus;
	let onKeyUp;
	let onUpdate;
	if ($[10] !== editing || $[11] !== props || $[12] !== setEditing || $[13] !== setText || $[14] !== setValue || $[15] !== text || $[16] !== value) {
		onKeyUp = (e) => {
			if (e.key === "Backspace" && text === "") setEditing(true);
			else if (e.key === "Enter") {
				props.onEnter?.(e);
				if (!e.defaultPrevented) onUpdate(e.currentTarget.value);
			}
		};
		let t5;
		if ($[20] !== editing || $[21] !== setEditing || $[22] !== setText || $[23] !== setValue || $[24] !== text || $[25] !== value) {
			t5 = (rawInput) => {
				const domText = rawInput ?? inputRef.current?.value ?? text;
				const parsed = currencyToAmount(domText) || 0;
				const newValue = domText !== "" || editing ? parsed : value;
				setValue(Math.abs(newValue));
				setEditing(false);
				setText("");
				return newValue;
			};
			$[20] = editing;
			$[21] = setEditing;
			$[22] = setText;
			$[23] = setValue;
			$[24] = text;
			$[25] = value;
			$[26] = t5;
		} else t5 = $[26];
		const applyText = t5;
		let t6;
		if ($[27] !== props) {
			t6 = (e_0) => {
				props.onFocus?.(e_0);
			};
			$[27] = props;
			$[28] = t6;
		} else t6 = $[28];
		onFocus = t6;
		onUpdate = (value_0) => {
			const originalAmount = Math.abs(props.value);
			const amount = applyText(value_0);
			if (amount !== originalAmount) {
				props.onUpdate?.(value_0);
				props.onUpdateAmount?.(amount);
			}
		};
		$[10] = editing;
		$[11] = props;
		$[12] = setEditing;
		$[13] = setText;
		$[14] = setValue;
		$[15] = text;
		$[16] = value;
		$[17] = onFocus;
		$[18] = onKeyUp;
		$[19] = onUpdate;
	} else {
		onFocus = $[17];
		onKeyUp = $[18];
		onUpdate = $[19];
	}
	let t5;
	if ($[29] !== onUpdate || $[30] !== props) {
		t5 = (e_1) => {
			props.onBlur?.(e_1);
			if (!e_1.defaultPrevented) onUpdate(e_1.target.value);
		};
		$[29] = onUpdate;
		$[30] = props;
		$[31] = t5;
	} else t5 = $[31];
	const onBlur = t5;
	let t6;
	if ($[32] !== hideFraction || $[33] !== props || $[34] !== setEditing || $[35] !== setText) {
		t6 = (text_0) => {
			text_0 = reapplyThousandSeparators(text_0);
			text_0 = appendDecimals(text_0, String(hideFraction) === "true");
			setEditing(true);
			setText(text_0);
			props.onChangeValue?.(text_0);
		};
		$[32] = hideFraction;
		$[33] = props;
		$[34] = setEditing;
		$[35] = setText;
		$[36] = t6;
	} else t6 = $[36];
	const onChangeText = t6;
	let t7;
	if ($[37] !== onChangeText) {
		t7 = (e_2) => onChangeText(e_2.target.value);
		$[37] = onChangeText;
		$[38] = t7;
	} else t7 = $[38];
	let t8;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = {
			flex: 1,
			textAlign: "center",
			position: "absolute"
		};
		$[39] = t8;
	} else t8 = $[39];
	let t9;
	if ($[40] !== mergedInputRef || $[41] !== onBlur || $[42] !== onFocus || $[43] !== onKeyUp || $[44] !== t7 || $[45] !== text) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
			type: "text",
			ref: mergedInputRef,
			value: text,
			inputMode: "decimal",
			autoCapitalize: "none",
			onChange: t7,
			onFocus,
			onBlur,
			onKeyUp,
			"data-testid": "amount-input",
			style: t8
		});
		$[40] = mergedInputRef;
		$[41] = onBlur;
		$[42] = onFocus;
		$[43] = onKeyUp;
		$[44] = t7;
		$[45] = text;
		$[46] = t9;
	} else t9 = $[46];
	const input = t9;
	let t10;
	if ($[47] !== style) {
		t10 = {
			justifyContent: "center",
			borderWidth: 1,
			borderColor: theme.pillBorderSelected,
			borderRadius: 4,
			padding: 5,
			backgroundColor: theme.tableBackground,
			maxWidth: "calc(100% - 40px)",
			...style
		};
		$[47] = style;
		$[48] = t10;
	} else t10 = $[48];
	let t11;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = {
			overflowY: "auto",
			overflowX: "hidden"
		};
		$[49] = t11;
	} else t11 = $[49];
	let t12;
	if ($[50] !== input) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t11,
			children: input
		});
		$[50] = input;
		$[51] = t12;
	} else t12 = $[51];
	let t13;
	if ($[52] !== textStyle) {
		t13 = {
			pointerEvents: "none",
			...textStyle
		};
		$[52] = textStyle;
		$[53] = t13;
	} else t13 = $[53];
	let t14;
	if ($[54] !== editing || $[55] !== text || $[56] !== value) {
		t14 = editing ? text || amountToCurrency(0) : amountToCurrency(value);
		$[54] = editing;
		$[55] = text;
		$[56] = value;
		$[57] = t14;
	} else t14 = $[57];
	let t15;
	if ($[58] !== t13 || $[59] !== t14) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t13,
			"data-testid": "amount-input-text",
			children: t14
		});
		$[58] = t13;
		$[59] = t14;
		$[60] = t15;
	} else t15 = $[60];
	let t16;
	if ($[61] !== t10 || $[62] !== t12 || $[63] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t10,
			children: [t12, t15]
		});
		$[61] = t10;
		$[62] = t12;
		$[63] = t15;
		$[64] = t16;
	} else t16 = $[64];
	return t16;
});
var FocusableAmountInput = (0, import_react.memo)(function FocusableAmountInput(t0) {
	const $ = (0, import_compiler_runtime.c)(91);
	let buttonProps;
	let disabled;
	let focused;
	let focusedStyle;
	let onBlur;
	let onChangeValue;
	let onFocus;
	let props;
	let sign;
	let style;
	let textStyle;
	let value;
	let zeroSign;
	if ($[0] !== t0) {
		({value, sign, zeroSign, focused, disabled, textStyle, style, focusedStyle, buttonProps, onFocus, onBlur, onChangeValue, ...props} = t0);
		$[0] = t0;
		$[1] = buttonProps;
		$[2] = disabled;
		$[3] = focused;
		$[4] = focusedStyle;
		$[5] = onBlur;
		$[6] = onChangeValue;
		$[7] = onFocus;
		$[8] = props;
		$[9] = sign;
		$[10] = style;
		$[11] = textStyle;
		$[12] = value;
		$[13] = zeroSign;
	} else {
		buttonProps = $[1];
		disabled = $[2];
		focused = $[3];
		focusedStyle = $[4];
		onBlur = $[5];
		onChangeValue = $[6];
		onFocus = $[7];
		props = $[8];
		sign = $[9];
		style = $[10];
		textStyle = $[11];
		value = $[12];
		zeroSign = $[13];
	}
	const [isNegative, setIsNegative] = (0, import_react.useState)(true);
	let t1;
	if ($[14] !== value) {
		t1 = Math.abs(value);
		$[14] = value;
		$[15] = t1;
	} else t1 = $[15];
	const [liveValue, setLiveValue] = (0, import_react.useState)(t1);
	const maybeApplyNegative = _temp$1;
	let t2;
	if ($[16] !== props) {
		t2 = (amount_0, negative_0) => {
			props.onUpdateAmount?.(maybeApplyNegative(amount_0, negative_0));
		};
		$[16] = props;
		$[17] = t2;
	} else t2 = $[17];
	const onUpdateAmount = t2;
	let t3;
	if ($[18] !== onChangeValue) {
		t3 = (text) => {
			setLiveValue(currencyToAmount(text) || 0);
			onChangeValue?.(text);
		};
		$[18] = onChangeValue;
		$[19] = t3;
	} else t3 = $[19];
	const handleChangeValue = t3;
	let t4;
	let t5;
	if ($[20] !== value) {
		t4 = () => {
			setLiveValue(Math.abs(value));
		};
		t5 = [value];
		$[20] = value;
		$[21] = t4;
		$[22] = t5;
	} else {
		t4 = $[21];
		t5 = $[22];
	}
	(0, import_react.useEffect)(t4, t5);
	let t6;
	let t7;
	if ($[23] !== sign || $[24] !== value || $[25] !== zeroSign) {
		t6 = () => {
			if (sign) setIsNegative(sign === "-");
			else if (value > 0 || zeroSign !== "-" && value === 0) setIsNegative(false);
		};
		t7 = [
			sign,
			value,
			zeroSign
		];
		$[23] = sign;
		$[24] = value;
		$[25] = zeroSign;
		$[26] = t6;
		$[27] = t7;
	} else {
		t6 = $[26];
		t7 = $[27];
	}
	(0, import_react.useEffect)(t6, t7);
	let t8;
	if ($[28] !== disabled || $[29] !== isNegative || $[30] !== onUpdateAmount || $[31] !== value) {
		t8 = () => {
			if (disabled) return;
			onUpdateAmount(value, !isNegative);
			setIsNegative(!isNegative);
		};
		$[28] = disabled;
		$[29] = isNegative;
		$[30] = onUpdateAmount;
		$[31] = value;
		$[32] = t8;
	} else t8 = $[32];
	const toggleIsNegative = t8;
	let t9;
	if ($[33] !== isNegative || $[34] !== onUpdateAmount) {
		t9 = (amount_1) => onUpdateAmount(amount_1, isNegative);
		$[33] = isNegative;
		$[34] = onUpdateAmount;
		$[35] = t9;
	} else t9 = $[35];
	const t10 = focused && !disabled;
	let t11;
	if ($[36] !== isNegative || $[37] !== liveValue) {
		t11 = makeAmountFullStyle(maybeApplyNegative(liveValue, isNegative), {
			zeroColor: isNegative ? theme.numberNegative : theme.numberNeutral,
			positiveColor: theme.numberPositive,
			negativeColor: theme.numberNegative
		});
		$[36] = isNegative;
		$[37] = liveValue;
		$[38] = t11;
	} else t11 = $[38];
	let t12;
	if ($[39] !== focused) {
		t12 = !focused && { display: "none" };
		$[39] = focused;
		$[40] = t12;
	} else t12 = $[40];
	let t13;
	if ($[41] !== focusedStyle || $[42] !== style || $[43] !== t11 || $[44] !== t12) {
		t13 = {
			...t11,
			width: 80,
			justifyContent: "center",
			...style,
			...focusedStyle,
			...t12
		};
		$[41] = focusedStyle;
		$[42] = style;
		$[43] = t11;
		$[44] = t12;
		$[45] = t13;
	} else t13 = $[45];
	let t14;
	if ($[46] !== textStyle) {
		t14 = {
			fontSize: 15,
			textAlign: "right",
			...textStyle
		};
		$[46] = textStyle;
		$[47] = t14;
	} else t14 = $[47];
	let t15;
	if ($[48] !== handleChangeValue || $[49] !== onBlur || $[50] !== onFocus || $[51] !== props || $[52] !== t10 || $[53] !== t13 || $[54] !== t14 || $[55] !== t9 || $[56] !== value) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AmountInput, {
			...props,
			value,
			onFocus,
			onBlur,
			onChangeValue: handleChangeValue,
			onUpdateAmount: t9,
			focused: t10,
			style: t13,
			textStyle: t14
		});
		$[48] = handleChangeValue;
		$[49] = onBlur;
		$[50] = onFocus;
		$[51] = props;
		$[52] = t10;
		$[53] = t13;
		$[54] = t14;
		$[55] = t9;
		$[56] = value;
		$[57] = t15;
	} else t15 = $[57];
	let t16;
	if ($[58] !== focused || $[59] !== isNegative || $[60] !== toggleIsNegative) {
		t16 = !focused && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			style: {
				position: "absolute",
				right: "calc(100% + 5px)",
				top: "8px"
			},
			onPress: toggleIsNegative,
			children: isNegative ? "-" : "+"
		});
		$[58] = focused;
		$[59] = isNegative;
		$[60] = toggleIsNegative;
		$[61] = t16;
	} else t16 = $[61];
	const t17 = buttonProps && buttonProps.style;
	let t18;
	if ($[62] !== focused || $[63] !== t17) {
		t18 = css({
			...t17,
			...focused && { display: "none" },
			"&[data-pressed]": { backgroundColor: "transparent" }
		});
		$[62] = focused;
		$[63] = t17;
		$[64] = t18;
	} else t18 = $[64];
	let t19;
	if ($[65] !== style) {
		t19 = {
			borderBottomWidth: 1,
			borderColor: "#e0e0e0",
			justifyContent: "center",
			...style
		};
		$[65] = style;
		$[66] = t19;
	} else t19 = $[66];
	let t20;
	if ($[67] !== value) {
		t20 = makeAmountFullStyle(value, {
			positiveColor: theme.numberPositive,
			negativeColor: theme.numberNegative,
			zeroColor: theme.numberNeutral
		});
		$[67] = value;
		$[68] = t20;
	} else t20 = $[68];
	let t21;
	if ($[69] !== t20 || $[70] !== textStyle) {
		t21 = {
			...t20,
			fontSize: 15,
			userSelect: "none",
			...textStyle
		};
		$[69] = t20;
		$[70] = textStyle;
		$[71] = t21;
	} else t21 = $[71];
	let t22;
	if ($[72] !== value) {
		t22 = amountToCurrency(Math.abs(value));
		$[72] = value;
		$[73] = t22;
	} else t22 = $[73];
	let t23;
	if ($[74] !== t21 || $[75] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t21,
			children: t22
		});
		$[74] = t21;
		$[75] = t22;
		$[76] = t23;
	} else t23 = $[76];
	let t24;
	if ($[77] !== t19 || $[78] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t19,
			children: t23
		});
		$[77] = t19;
		$[78] = t23;
		$[79] = t24;
	} else t24 = $[79];
	let t25;
	if ($[80] !== buttonProps || $[81] !== onFocus || $[82] !== t18 || $[83] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			onPress: onFocus,
			...buttonProps,
			className: t18,
			variant: "bare",
			children: t24
		});
		$[80] = buttonProps;
		$[81] = onFocus;
		$[82] = t18;
		$[83] = t24;
		$[84] = t25;
	} else t25 = $[84];
	let t26;
	if ($[85] !== t16 || $[86] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t16, t25] });
		$[85] = t16;
		$[86] = t25;
		$[87] = t26;
	} else t26 = $[87];
	let t27;
	if ($[88] !== t15 || $[89] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t15, t26] });
		$[88] = t15;
		$[89] = t26;
		$[90] = t27;
	} else t27 = $[90];
	return t27;
});
function _temp$1(amount, negative) {
	const absValue = Math.abs(amount);
	return negative ? -absValue : absValue;
}
//#endregion
//#region src/components/mobile/transactions/TransactionEdit.tsx
function getFieldName(transactionId, field) {
	return `${field}-${transactionId}`;
}
function serializeTransaction(transaction, dateFormat) {
	const { date, amount } = transaction;
	return {
		...transaction,
		date: format(parseISO(date), dateFormat),
		amount: integerToAmount(amount || 0)
	};
}
function deserializeTransaction(transaction, originalTransaction, dateFormat) {
	const { amount, date: originalDate, ...realTransaction } = transaction;
	const dayMonth = getDayMonthRegex(dateFormat);
	let date = originalDate;
	if (dayMonth.test(date)) {
		const test = parse(date, getDayMonthFormat(dateFormat), /* @__PURE__ */ new Date());
		if (isValid(test)) date = dayFromDate(test);
		else date = null;
	} else {
		const test = parse(date, dateFormat, /* @__PURE__ */ new Date());
		if (test.getFullYear() > 2e3 && isValid(test)) date = dayFromDate(test);
		else date = null;
	}
	if (date == null) date = originalTransaction && originalTransaction.date || currentDay();
	return {
		...realTransaction,
		date,
		amount: amountToInteger(amount || 0)
	};
}
function lookupName(items, id) {
	if (!id) return null;
	return items.find((item) => item.id === id)?.name;
}
var dropdownChevron = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheveronDown, {
	width: 14,
	height: 14,
	style: {
		color: theme.pageTextSubdued,
		marginRight: 8
	}
});
function Status(t0) {
	const $ = (0, import_compiler_runtime.c)(9);
	const { status, isSplit: t1 } = t0;
	const isSplit = t1 === void 0 ? false : t1;
	const { t } = useTranslation();
	let color;
	bb0: switch (status) {
		case "missed":
			color = theme.errorText;
			break bb0;
		case "due":
			color = theme.warningText;
			break bb0;
		case "upcoming":
			color = theme.tableHeaderText;
			break bb0;
		default: return null;
	}
	let t2;
	if ($[0] !== color) {
		t2 = {
			fontSize: 11,
			color,
			fontStyle: "italic",
			textAlign: "left"
		};
		$[0] = color;
		$[1] = t2;
	} else t2 = $[1];
	let t3;
	if ($[2] !== isSplit || $[3] !== status || $[4] !== t) {
		t3 = isSplit ? t("{{status}} (Split)", { status: titleFirst(getStatusLabel(status)) }) : titleFirst(getStatusLabel(status));
		$[2] = isSplit;
		$[3] = status;
		$[4] = t;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t2 || $[7] !== t3) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t2,
			children: t3
		});
		$[6] = t2;
		$[7] = t3;
		$[8] = t4;
	} else t4 = $[8];
	return t4;
}
function Footer(t0) {
	const $ = (0, import_compiler_runtime.c)(24);
	const { transactions, isAdding, onAdd, onSave, onSplit, onAddSplit, onEmptySplitFound, editingField, onEditField } = t0;
	let childTransactions;
	let t1;
	let transaction;
	if ($[0] !== transactions) {
		[transaction, ...childTransactions] = transactions;
		t1 = childTransactions.find(_temp);
		$[0] = transactions;
		$[1] = childTransactions;
		$[2] = t1;
		$[3] = transaction;
	} else {
		childTransactions = $[1];
		t1 = $[2];
		transaction = $[3];
	}
	const emptySplitTransaction = t1;
	let t2;
	if ($[4] !== childTransactions.length || $[5] !== emptySplitTransaction || $[6] !== onAddSplit || $[7] !== onEmptySplitFound || $[8] !== onSplit || $[9] !== transaction.id) {
		t2 = () => {
			if (childTransactions.length === 0) onSplit(transaction.id);
			else if (!emptySplitTransaction) onAddSplit(transaction.id);
			else onEmptySplitFound?.(emptySplitTransaction.id);
		};
		$[4] = childTransactions.length;
		$[5] = emptySplitTransaction;
		$[6] = onAddSplit;
		$[7] = onEmptySplitFound;
		$[8] = onSplit;
		$[9] = transaction.id;
		$[10] = t2;
	} else t2 = $[10];
	const onClickRemainingSplit = t2;
	let t3;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			paddingLeft: styles.mobileEditingPadding,
			paddingRight: styles.mobileEditingPadding,
			paddingTop: 10,
			paddingBottom: "calc(10px + env(safe-area-inset-bottom))",
			backgroundColor: theme.tableHeaderBackground,
			borderTopWidth: 1,
			borderColor: theme.tableBorder
		};
		$[11] = t3;
	} else t3 = $[11];
	let t4;
	if ($[12] !== editingField || $[13] !== emptySplitTransaction || $[14] !== isAdding || $[15] !== onAdd || $[16] !== onClickRemainingSplit || $[17] !== onEditField || $[18] !== onSave || $[19] !== transaction.account || $[20] !== transaction.amount || $[21] !== transaction.error || $[22] !== transaction.id) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			"data-testid": "transaction-form-footer",
			style: t3,
			children: transaction.error?.type === "SplitTransactionError" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "primary",
				style: { height: styles.mobileMinHeight },
				isDisabled: !!editingField,
				onPress: onClickRemainingSplit,
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgSplit, {
					width: 17,
					height: 17
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						...styles.text,
						marginLeft: 6
					},
					children: !emptySplitTransaction ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
						"Add new split -",
						" ",
						{ amount: integerToCurrency(transaction.amount > 0 ? transaction.error.difference : -transaction.error.difference) },
						" ",
						"left"
					] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
						"Amount left:",
						" ",
						{ amount: integerToCurrency(transaction.amount > 0 ? transaction.error.difference : -transaction.error.difference) }
					] })
				})]
			}) : !transaction.account ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "primary",
				style: { height: styles.mobileMinHeight },
				isDisabled: !!editingField,
				onPress: () => onEditField(transaction.id, "account"),
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgPiggyBank, {
					width: 17,
					height: 17
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						...styles.text,
						marginLeft: 6
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Select account" })
				})]
			}) : isAdding ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "primary",
				style: { height: styles.mobileMinHeight },
				isDisabled: !!editingField,
				onPress: onAdd,
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgAdd, {
					width: 17,
					height: 17
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						...styles.text,
						marginLeft: 5
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Add transaction" })
				})]
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "primary",
				style: { height: styles.mobileMinHeight },
				isDisabled: !!editingField,
				onPress: onSave,
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgPencilWriteAlternate, {
					width: 16,
					height: 16
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						...styles.text,
						marginLeft: 6
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save changes" })
				})]
			})
		});
		$[12] = editingField;
		$[13] = emptySplitTransaction;
		$[14] = isAdding;
		$[15] = onAdd;
		$[16] = onClickRemainingSplit;
		$[17] = onEditField;
		$[18] = onSave;
		$[19] = transaction.account;
		$[20] = transaction.amount;
		$[21] = transaction.error;
		$[22] = transaction.id;
		$[23] = t4;
	} else t4 = $[23];
	return t4;
}
function _temp(t) {
	return t.amount === 0;
}
var ChildTransactionEdit = (0, import_react.forwardRef)((t0, ref) => {
	const $ = (0, import_compiler_runtime.c)(142);
	const { transaction, amountFocused, amountSign, getCategory, getPayee, getTransferAccount, isOffBudget, isBudgetTransfer, onEditField, onUpdate, onDelete } = t0;
	const { t } = useTranslation();
	const { editingField, onRequestActiveEdit, onClearActiveEdit } = useSingleActiveEditForm();
	const [hideFraction] = useSyncedPref("hideFraction");
	const noteRef = (0, import_react.useRef)(null);
	let t1;
	if ($[0] !== getPayee || $[1] !== getTransferAccount || $[2] !== t || $[3] !== transaction) {
		t1 = getPrettyPayee({
			t,
			transaction,
			payee: getPayee(transaction),
			transferAccount: getTransferAccount(transaction)
		});
		$[0] = getPayee;
		$[1] = getTransferAccount;
		$[2] = t;
		$[3] = transaction;
		$[4] = t1;
	} else t1 = $[4];
	const prettyPayee = t1;
	const t2 = transaction.amount === 0 ? theme.tableBorderSelected : theme.tableBorder;
	let t3;
	if ($[5] !== t2) {
		t3 = {
			backgroundColor: theme.tableBackground,
			borderColor: t2,
			borderWidth: "1px",
			borderRadius: "5px",
			padding: "5px",
			margin: "10px"
		};
		$[5] = t2;
		$[6] = t3;
	} else t3 = $[6];
	let t4;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = { flexDirection: "row" };
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = { flexBasis: "75%" };
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] !== t) {
		t6 = t("Payee");
		$[9] = t;
		$[10] = t6;
	} else t6 = $[10];
	let t7;
	if ($[11] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t6 });
		$[11] = t6;
		$[12] = t7;
	} else t7 = $[12];
	let t8;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgUser, {
			width: 17,
			height: 17
		});
		$[13] = t8;
	} else t8 = $[13];
	let t9;
	if ($[14] !== t) {
		t9 = t("Who did you pay?");
		$[14] = t;
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== editingField || $[17] !== transaction.id) {
		t10 = !!editingField && editingField !== getFieldName(transaction.id, "payee");
		$[16] = editingField;
		$[17] = transaction.id;
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== onEditField || $[20] !== transaction.id) {
		t11 = () => onEditField(transaction.id, "payee");
		$[19] = onEditField;
		$[20] = transaction.id;
		$[21] = t11;
	} else t11 = $[21];
	const t12 = `payee-field-${transaction.id}`;
	let t13;
	if ($[22] !== prettyPayee || $[23] !== t10 || $[24] !== t11 || $[25] !== t12 || $[26] !== t9) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TapField, {
			icon: t8,
			placeholder: t9,
			rightContent: dropdownChevron,
			isDisabled: t10,
			value: prettyPayee,
			onPress: t11,
			"data-testid": t12
		});
		$[22] = prettyPayee;
		$[23] = t10;
		$[24] = t11;
		$[25] = t12;
		$[26] = t9;
		$[27] = t13;
	} else t13 = $[27];
	let t14;
	if ($[28] !== t13 || $[29] !== t7) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t5,
			children: [t7, t13]
		});
		$[28] = t13;
		$[29] = t7;
		$[30] = t14;
	} else t14 = $[30];
	let t15;
	if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = { flexBasis: "25%" };
		$[31] = t15;
	} else t15 = $[31];
	let t16;
	if ($[32] !== t) {
		t16 = t("Amount");
		$[32] = t;
		$[33] = t16;
	} else t16 = $[33];
	let t17;
	if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = { padding: 0 };
		$[34] = t17;
	} else t17 = $[34];
	let t18;
	if ($[35] !== t16) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, {
			title: t16,
			style: t17
		});
		$[35] = t16;
		$[36] = t18;
	} else t18 = $[36];
	let t19;
	if ($[37] !== editingField || $[38] !== transaction.id) {
		t19 = !!editingField && editingField !== getFieldName(transaction.id, "amount");
		$[37] = editingField;
		$[38] = transaction.id;
		$[39] = t19;
	} else t19 = $[39];
	let t20;
	if ($[40] !== transaction.amount) {
		t20 = amountToInteger(transaction.amount);
		$[40] = transaction.amount;
		$[41] = t20;
	} else t20 = $[41];
	let t21;
	let t22;
	if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = { marginRight: 8 };
		t22 = {
			...styles.smallText,
			textAlign: "right",
			minWidth: 0
		};
		$[42] = t21;
		$[43] = t22;
	} else {
		t21 = $[42];
		t22 = $[43];
	}
	let t23;
	if ($[44] !== onRequestActiveEdit || $[45] !== transaction.id) {
		t23 = () => onRequestActiveEdit(getFieldName(transaction.id, "amount"));
		$[44] = onRequestActiveEdit;
		$[45] = transaction.id;
		$[46] = t23;
	} else t23 = $[46];
	let t24;
	if ($[47] !== onClearActiveEdit || $[48] !== onUpdate || $[49] !== transaction) {
		t24 = (value) => {
			const amount = integerToAmount(value);
			if (transaction.amount !== amount) onUpdate(transaction, "amount", amount);
			else onClearActiveEdit();
		};
		$[47] = onClearActiveEdit;
		$[48] = onUpdate;
		$[49] = transaction;
		$[50] = t24;
	} else t24 = $[50];
	const t25 = String(hideFraction) !== "true";
	let t26;
	if ($[51] !== amountFocused || $[52] !== amountSign || $[53] !== t19 || $[54] !== t20 || $[55] !== t23 || $[56] !== t24 || $[57] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AmountInput$1, {
			disabled: t19,
			focused: amountFocused,
			value: t20,
			zeroSign: amountSign,
			style: t21,
			inputStyle: t22,
			onFocus: t23,
			onUpdate: t24,
			autoDecimals: t25
		});
		$[51] = amountFocused;
		$[52] = amountSign;
		$[53] = t19;
		$[54] = t20;
		$[55] = t23;
		$[56] = t24;
		$[57] = t25;
		$[58] = t26;
	} else t26 = $[58];
	let t27;
	if ($[59] !== t18 || $[60] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t15,
			children: [t18, t26]
		});
		$[59] = t18;
		$[60] = t26;
		$[61] = t27;
	} else t27 = $[61];
	let t28;
	if ($[62] !== t14 || $[63] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t4,
			children: [t14, t27]
		});
		$[62] = t14;
		$[63] = t27;
		$[64] = t28;
	} else t28 = $[64];
	let t29;
	if ($[65] !== t) {
		t29 = t("Category");
		$[65] = t;
		$[66] = t29;
	} else t29 = $[66];
	let t30;
	if ($[67] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t29 });
		$[67] = t29;
		$[68] = t30;
	} else t30 = $[68];
	let t31;
	if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTag, {
			width: 17,
			height: 17
		});
		$[69] = t31;
	} else t31 = $[69];
	let t32;
	if ($[70] !== t) {
		t32 = t("Select a category");
		$[70] = t;
		$[71] = t32;
	} else t32 = $[71];
	let t33;
	if ($[72] !== isBudgetTransfer || $[73] !== isOffBudget || $[74] !== transaction) {
		t33 = (isOffBudget || isBudgetTransfer(transaction)) && {
			fontStyle: "italic",
			color: theme.pageTextSubdued,
			fontWeight: 300
		};
		$[72] = isBudgetTransfer;
		$[73] = isOffBudget;
		$[74] = transaction;
		$[75] = t33;
	} else t33 = $[75];
	let t34;
	if ($[76] !== t33) {
		t34 = { ...t33 };
		$[76] = t33;
		$[77] = t34;
	} else t34 = $[77];
	let t35;
	if ($[78] !== getCategory || $[79] !== isOffBudget || $[80] !== transaction) {
		t35 = getCategory(transaction, isOffBudget);
		$[78] = getCategory;
		$[79] = isOffBudget;
		$[80] = transaction;
		$[81] = t35;
	} else t35 = $[81];
	let t36;
	if ($[82] !== editingField || $[83] !== isBudgetTransfer || $[84] !== isOffBudget || $[85] !== transaction) {
		t36 = !!editingField && editingField !== getFieldName(transaction.id, "category") || isOffBudget || isBudgetTransfer(transaction);
		$[82] = editingField;
		$[83] = isBudgetTransfer;
		$[84] = isOffBudget;
		$[85] = transaction;
		$[86] = t36;
	} else t36 = $[86];
	let t37;
	if ($[87] !== onEditField || $[88] !== transaction.id) {
		t37 = () => onEditField(transaction.id, "category");
		$[87] = onEditField;
		$[88] = transaction.id;
		$[89] = t37;
	} else t37 = $[89];
	const t38 = `category-field-${transaction.id}`;
	let t39;
	if ($[90] !== t32 || $[91] !== t34 || $[92] !== t35 || $[93] !== t36 || $[94] !== t37 || $[95] !== t38) {
		t39 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TapField, {
			icon: t31,
			placeholder: t32,
			rightContent: dropdownChevron,
			textStyle: t34,
			value: t35,
			isDisabled: t36,
			onPress: t37,
			"data-testid": t38
		});
		$[90] = t32;
		$[91] = t34;
		$[92] = t35;
		$[93] = t36;
		$[94] = t37;
		$[95] = t38;
		$[96] = t39;
	} else t39 = $[96];
	let t40;
	if ($[97] !== t30 || $[98] !== t39) {
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t30, t39] });
		$[97] = t30;
		$[98] = t39;
		$[99] = t40;
	} else t40 = $[99];
	let t41;
	if ($[100] !== t) {
		t41 = t("Notes");
		$[100] = t;
		$[101] = t41;
	} else t41 = $[101];
	let t42;
	if ($[102] !== t41) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t41 });
		$[102] = t41;
		$[103] = t42;
	} else t42 = $[103];
	let t43;
	if ($[104] === Symbol.for("react.memo_cache_sentinel")) {
		t43 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgNotesPaper, {
			width: 17,
			height: 17
		});
		$[104] = t43;
	} else t43 = $[104];
	let t44;
	if ($[105] !== t) {
		t44 = t("Add a note (optional)");
		$[105] = t;
		$[106] = t44;
	} else t44 = $[106];
	let t45;
	if ($[107] !== editingField || $[108] !== transaction.id) {
		t45 = !!editingField && editingField !== getFieldName(transaction.id, "notes");
		$[107] = editingField;
		$[108] = transaction.id;
		$[109] = t45;
	} else t45 = $[109];
	let t46;
	if ($[110] !== onRequestActiveEdit || $[111] !== transaction.id) {
		t46 = () => onRequestActiveEdit(getFieldName(transaction.id, "notes"));
		$[110] = onRequestActiveEdit;
		$[111] = transaction.id;
		$[112] = t46;
	} else t46 = $[112];
	let t47;
	if ($[113] !== onUpdate || $[114] !== transaction) {
		t47 = (value_0) => onUpdate(transaction, "notes", value_0);
		$[113] = onUpdate;
		$[114] = transaction;
		$[115] = t47;
	} else t47 = $[115];
	let t48;
	if ($[116] !== t44 || $[117] !== t45 || $[118] !== t46 || $[119] !== t47 || $[120] !== transaction.notes) {
		t48 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputField, {
			ref: noteRef,
			icon: t43,
			placeholder: t44,
			disabled: t45,
			defaultValue: transaction.notes,
			onFocus: t46,
			onUpdate: t47
		});
		$[116] = t44;
		$[117] = t45;
		$[118] = t46;
		$[119] = t47;
		$[120] = transaction.notes;
		$[121] = t48;
	} else t48 = $[121];
	let t49;
	if ($[122] === Symbol.for("react.memo_cache_sentinel")) {
		t49 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NoteTagAutocomplete, { inputRef: noteRef });
		$[122] = t49;
	} else t49 = $[122];
	let t50;
	if ($[123] !== t42 || $[124] !== t48) {
		t50 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [
			t42,
			t48,
			t49
		] });
		$[123] = t42;
		$[124] = t48;
		$[125] = t50;
	} else t50 = $[125];
	let t51;
	if ($[126] === Symbol.for("react.memo_cache_sentinel")) {
		t51 = { alignItems: "center" };
		$[126] = t51;
	} else t51 = $[126];
	let t52;
	if ($[127] !== onDelete || $[128] !== transaction.id) {
		t52 = () => onDelete(transaction.id);
		$[127] = onDelete;
		$[128] = transaction.id;
		$[129] = t52;
	} else t52 = $[129];
	let t53;
	if ($[130] === Symbol.for("react.memo_cache_sentinel")) {
		t53 = {
			height: 40,
			borderWidth: 0,
			marginLeft: styles.mobileEditingPadding,
			marginRight: styles.mobileEditingPadding,
			marginTop: 10,
			backgroundColor: "transparent"
		};
		$[130] = t53;
	} else t53 = $[130];
	let t54;
	if ($[131] === Symbol.for("react.memo_cache_sentinel")) {
		t54 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTrash, {
			width: 17,
			height: 17,
			style: { color: theme.errorText }
		});
		$[131] = t54;
	} else t54 = $[131];
	let t55;
	if ($[132] === Symbol.for("react.memo_cache_sentinel")) {
		t55 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				color: theme.errorText,
				marginLeft: 5,
				userSelect: "none"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Delete split" })
		});
		$[132] = t55;
	} else t55 = $[132];
	let t56;
	if ($[133] !== t52) {
		t56 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t51,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "bare",
				onPress: t52,
				style: t53,
				children: [t54, t55]
			})
		});
		$[133] = t52;
		$[134] = t56;
	} else t56 = $[134];
	let t57;
	if ($[135] !== ref || $[136] !== t28 || $[137] !== t3 || $[138] !== t40 || $[139] !== t50 || $[140] !== t56) {
		t57 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			innerRef: ref,
			style: t3,
			children: [
				t28,
				t40,
				t50,
				t56
			]
		});
		$[135] = ref;
		$[136] = t28;
		$[137] = t3;
		$[138] = t40;
		$[139] = t50;
		$[140] = t56;
		$[141] = t57;
	} else t57 = $[141];
	return t57;
});
ChildTransactionEdit.displayName = "ChildTransactionEdit";
var TransactionEditInner = (0, import_react.memo)(function TransactionEditInner(t0) {
	const $ = (0, import_compiler_runtime.c)(267);
	const { isAdding, accounts, categories, payees, dateFormat, transactions: unserializedTransactions, onSave, onUpdate, onDelete, onSplit, onAddSplit, shouldShowSaveLocation, onSaveLocation, onSelectNearestPayee, nearestPayee } = t0;
	const { t } = useTranslation();
	const navigate = useNavigate();
	const dispatch = useDispatch();
	const [showHiddenCategories] = useLocalPref("budget.showHiddenCategories");
	const [t1] = useSyncedPref("upcomingScheduledTransactionLength");
	const upcomingLength = t1 === void 0 ? "7" : t1;
	let t2;
	if ($[0] !== dateFormat || $[1] !== unserializedTransactions) {
		t2 = unserializedTransactions.map((t_0) => serializeTransaction(t_0, dateFormat)) || [];
		$[0] = dateFormat;
		$[1] = unserializedTransactions;
		$[2] = t2;
	} else t2 = $[2];
	const transactions = t2;
	const { data: t3 } = useCategories();
	let t4;
	if ($[3] !== t3) {
		t4 = t3 === void 0 ? { grouped: [] } : t3;
		$[3] = t3;
		$[4] = t4;
	} else t4 = $[4];
	const { grouped: categoryGroups } = t4;
	const noteRef = (0, import_react.useRef)(null);
	let t5;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = [];
		$[5] = t5;
	} else t5 = $[5];
	(0, import_react.useEffect)(_temp2, t5);
	const [transaction, ...childTransactions] = transactions;
	const { editingField, onRequestActiveEdit, onClearActiveEdit } = useSingleActiveEditForm();
	const [totalAmountFocused, setTotalAmountFocused] = (0, import_react.useState)(!isIOSAgent);
	let t6;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = {};
		$[6] = t6;
	} else t6 = $[6];
	const childTransactionElementRefMap = (0, import_react.useRef)(t6);
	const hasAccountChanged = (0, import_react.useRef)(false);
	let t7;
	if ($[7] !== payees) {
		t7 = groupById(payees);
		$[7] = payees;
		$[8] = t7;
	} else t7 = $[8];
	const payeesById = t7;
	let t8;
	if ($[9] !== accounts) {
		t8 = groupById(accounts);
		$[9] = accounts;
		$[10] = t8;
	} else t8 = $[10];
	const accountsById = t8;
	let t9;
	if ($[11] !== onRequestActiveEdit || $[12] !== transaction.id) {
		t9 = () => {
			onRequestActiveEdit?.(getFieldName(transaction.id, "amount"), () => {
				setTotalAmountFocused(true);
				return () => setTotalAmountFocused(false);
			});
		};
		$[11] = onRequestActiveEdit;
		$[12] = transaction.id;
		$[13] = t9;
	} else t9 = $[13];
	const onTotalAmountEdit = t9;
	const isInitialMount = useInitialMount();
	let t10;
	let t11;
	if ($[14] !== isAdding || $[15] !== isInitialMount || $[16] !== onTotalAmountEdit) {
		t10 = () => {
			if (isInitialMount && isAdding && !isIOSAgent) onTotalAmountEdit();
		};
		t11 = [
			isAdding,
			isInitialMount,
			onTotalAmountEdit
		];
		$[14] = isAdding;
		$[15] = isInitialMount;
		$[16] = onTotalAmountEdit;
		$[17] = t10;
		$[18] = t11;
	} else {
		t10 = $[17];
		t11 = $[18];
	}
	(0, import_react.useEffect)(t10, t11);
	let t12;
	if ($[19] !== accountsById) {
		t12 = (trans) => trans?.account ? accountsById?.[trans.account] : void 0;
		$[19] = accountsById;
		$[20] = t12;
	} else t12 = $[20];
	const getAccount = t12;
	let t13;
	if ($[21] !== payeesById) {
		t13 = (trans_0) => trans_0?.payee ? payeesById?.[trans_0.payee] : void 0;
		$[21] = payeesById;
		$[22] = t13;
	} else t13 = $[22];
	const getPayee = t13;
	let t14;
	if ($[23] !== accountsById || $[24] !== getPayee) {
		t14 = (trans_1) => {
			const payee = trans_1 ? getPayee(trans_1) : null;
			return payee && payee?.transfer_acct ? accountsById?.[payee.transfer_acct] : void 0;
		};
		$[23] = accountsById;
		$[24] = getPayee;
		$[25] = t14;
	} else t14 = $[25];
	const getTransferAccount = t14;
	let t15;
	if ($[26] !== getTransferAccount) {
		t15 = (trans_2) => {
			const transferAcct = trans_2 ? getTransferAccount(trans_2) : null;
			return transferAcct ? !transferAcct.offbudget : false;
		};
		$[26] = getTransferAccount;
		$[27] = t15;
	} else t15 = $[27];
	const isBudgetTransfer = t15;
	let t16;
	if ($[28] !== categories || $[29] !== isBudgetTransfer || $[30] !== t) {
		t16 = (trans_3, isOffBudget) => {
			if (isOffBudget) return t("Off budget");
			else if (isBudgetTransfer(trans_3)) return t("Transfer");
			else return lookupName(categories, trans_3.category) ?? "";
		};
		$[28] = categories;
		$[29] = isBudgetTransfer;
		$[30] = t;
		$[31] = t16;
	} else t16 = $[31];
	const getCategory = t16;
	let t17;
	if ($[32] !== dispatch || $[33] !== isAdding || $[34] !== navigate || $[35] !== onSave || $[36] !== t || $[37] !== unserializedTransactions || $[38] !== upcomingLength) {
		t17 = async () => {
			const [unserializedTransaction] = unserializedTransactions;
			const onConfirmSave = () => {
				let transactionsToSave = unserializedTransactions;
				if (isAdding) transactionsToSave = realizeTempTransactions(unserializedTransactions);
				onSave(transactionsToSave);
				navigate(-1);
			};
			const today = currentDay();
			const isFuture = unserializedTransaction.date > today;
			const isLinkedToSchedule = !!unserializedTransaction.schedule;
			if (isFuture && !isLinkedToSchedule) {
				const upcomingDays = getUpcomingDays(upcomingLength, today);
				const daysUntilTransaction = differenceInCalendarDays(unserializedTransaction.date, today);
				dispatch(pushModal({ modal: {
					name: "convert-to-schedule",
					options: {
						isBeyondWindow: daysUntilTransaction > upcomingDays,
						daysUntilTransaction,
						upcomingDays,
						onConfirm: async () => {
							if (!isAdding && unserializedTransaction.id && !unserializedTransaction.id.startsWith("temp")) await send("transaction-delete", { id: unserializedTransaction.id });
							await createSingleTimeScheduleFromTransaction(unserializedTransaction.is_parent ? {
								...unserializedTransaction,
								subtransactions: unserializedTransactions.filter((t_1) => t_1.is_child && t_1.parent_id === unserializedTransaction.id)
							} : unserializedTransaction);
							dispatch(addNotification({ notification: {
								type: "message",
								message: t("Schedule created successfully")
							} }));
							navigate(-1);
						},
						onCancel: onConfirmSave
					}
				} }));
				return;
			}
			if (unserializedTransactions.some(_temp3)) dispatch(pushModal({ modal: {
				name: "confirm-transaction-edit",
				options: {
					onConfirm: onConfirmSave,
					confirmReason: "editReconciled"
				}
			} }));
			else {
				const transferIds = unserializedTransactions.map(_temp4).filter(_temp5);
				if (transferIds.length > 0) {
					const { data } = await aqlQuery(q("transactions").filter({
						id: { $oneof: transferIds },
						reconciled: true
					}).select("id"));
					if (data.length > 0) dispatch(pushModal({ modal: {
						name: "confirm-transaction-edit",
						options: {
							onConfirm: onConfirmSave,
							confirmReason: "batchEditWithReconciledTransfer"
						}
					} }));
					else onConfirmSave();
				} else onConfirmSave();
			}
		};
		$[32] = dispatch;
		$[33] = isAdding;
		$[34] = navigate;
		$[35] = onSave;
		$[36] = t;
		$[37] = unserializedTransactions;
		$[38] = upcomingLength;
		$[39] = t17;
	} else t17 = $[39];
	const onSaveInner = t17;
	let t18;
	if ($[40] !== onClearActiveEdit || $[41] !== onUpdate) {
		t18 = async (serializedTransaction, name, value) => {
			onUpdate({
				...serializedTransaction,
				[name]: value
			}, name);
			onClearActiveEdit();
			if (name === "account") hasAccountChanged.current = serializedTransaction.account !== value;
		};
		$[40] = onClearActiveEdit;
		$[41] = onUpdate;
		$[42] = t18;
	} else t18 = $[42];
	const onUpdateInner = t18;
	let t19;
	if ($[43] !== onUpdateInner || $[44] !== transaction) {
		t19 = (value_0) => {
			if (transaction.amount !== value_0) onUpdateInner(transaction, "amount", value_0);
		};
		$[43] = onUpdateInner;
		$[44] = transaction;
		$[45] = t19;
	} else t19 = $[45];
	const onTotalAmountUpdate = t19;
	let t20;
	if ($[46] !== categoryGroups || $[47] !== dispatch || $[48] !== onClearActiveEdit || $[49] !== onRequestActiveEdit || $[50] !== onUpdateInner || $[51] !== showHiddenCategories || $[52] !== transaction.id || $[53] !== transactions || $[54] !== unserializedTransactions) {
		t20 = (transactionId, name_0) => {
			onRequestActiveEdit?.(getFieldName(transaction.id, name_0), () => {
				const transactionToEdit = transactions.find((t_4) => t_4.id === transactionId);
				const unserializedTransaction_0 = unserializedTransactions.find((t_5) => t_5.id === transactionId);
				if (!unserializedTransaction_0 || !transactionToEdit) throw new Error(`Transaction ${transactionId} not found`);
				bb188: switch (name_0) {
					case "category":
						dispatch(pushModal({ modal: {
							name: "category-autocomplete",
							options: {
								categoryGroups,
								showHiddenCategories,
								showNoneOption: true,
								month: monthFromDate(unserializedTransaction_0.date),
								onSelect: (categoryId) => {
									onUpdateInner(transactionToEdit, name_0, categoryId);
								},
								onClose: () => {
									onClearActiveEdit();
								}
							}
						} }));
						break bb188;
					case "account":
						dispatch(pushModal({ modal: {
							name: "account-autocomplete",
							options: {
								onSelect: (accountId) => {
									onUpdateInner(transactionToEdit, name_0, accountId);
								},
								onClose: () => {
									onClearActiveEdit();
								}
							}
						} }));
						break bb188;
					case "payee":
						dispatch(pushModal({ modal: {
							name: "payee-autocomplete",
							options: {
								onSelect: (payeeId) => {
									onUpdateInner(transactionToEdit, name_0, payeeId);
								},
								onClose: () => {
									onClearActiveEdit();
								}
							}
						} }));
						break bb188;
					default: dispatch(pushModal({ modal: {
						name: "edit-field",
						options: {
							name: name_0,
							onSubmit: (name_1, value_1) => {
								if (typeof value_1 === "object" && "useRegex" in value_1) onUpdateInner(transactionToEdit, name_1, applyFindReplace(transactionToEdit.notes, value_1.find, value_1.replace, value_1.useRegex));
								else onUpdateInner(transactionToEdit, name_1, value_1);
							},
							onClose: () => {
								onClearActiveEdit();
							}
						}
					} }));
				}
			});
		};
		$[46] = categoryGroups;
		$[47] = dispatch;
		$[48] = onClearActiveEdit;
		$[49] = onRequestActiveEdit;
		$[50] = onUpdateInner;
		$[51] = showHiddenCategories;
		$[52] = transaction.id;
		$[53] = transactions;
		$[54] = unserializedTransactions;
		$[55] = t20;
	} else t20 = $[55];
	const onEditFieldInner = t20;
	let t21;
	if ($[56] !== dispatch || $[57] !== navigate || $[58] !== onClearActiveEdit || $[59] !== onDelete || $[60] !== t || $[61] !== unserializedTransactions) {
		t21 = async (id_0) => {
			const [parentTransaction] = unserializedTransactions;
			const targetTransaction = unserializedTransactions.find((t_6) => t_6.id === id_0) ?? parentTransaction;
			const onConfirmDelete = () => {
				dispatch(pushModal({ modal: {
					name: "confirm-delete",
					options: {
						message: t("Are you sure you want to delete the transaction?"),
						onConfirm: () => {
							onDelete(id_0);
							if (parentTransaction.id !== id_0) {
								onClearActiveEdit();
								return;
							}
							navigate(-1);
						}
					}
				} }));
			};
			if (targetTransaction.reconciled) dispatch(pushModal({ modal: {
				name: "confirm-transaction-edit",
				options: {
					onConfirm: onConfirmDelete,
					confirmReason: "deleteReconciled"
				}
			} }));
			else if (targetTransaction.transfer_id) {
				const { data: data_0 } = await aqlQuery(q("transactions").filter({
					id: targetTransaction.transfer_id,
					reconciled: true
				}).select("id"));
				if (data_0.length > 0) dispatch(pushModal({ modal: {
					name: "confirm-transaction-edit",
					options: {
						onConfirm: onConfirmDelete,
						confirmReason: "batchDeleteWithReconciledTransfer"
					}
				} }));
				else onConfirmDelete();
			} else onConfirmDelete();
		};
		$[56] = dispatch;
		$[57] = navigate;
		$[58] = onClearActiveEdit;
		$[59] = onDelete;
		$[60] = t;
		$[61] = unserializedTransactions;
		$[62] = t21;
	} else t21 = $[62];
	const onDeleteInner = t21;
	let t22;
	if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = (id_1) => {
			(childTransactionElementRefMap.current?.[id_1])?.scrollIntoView({ behavior: "smooth" });
		};
		$[63] = t22;
	} else t22 = $[63];
	const scrollChildTransactionIntoView = t22;
	let t23;
	if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = (id_2) => {
			scrollChildTransactionIntoView(id_2);
		};
		$[64] = t23;
	} else t23 = $[64];
	const onEmptySplitFound = t23;
	const childAmountSign = transaction.amount <= 0 ? "-" : "+";
	let t24;
	if ($[65] !== getAccount || $[66] !== transaction) {
		t24 = getAccount(transaction);
		$[65] = getAccount;
		$[66] = transaction;
		$[67] = t24;
	} else t24 = $[67];
	const account = t24;
	const isOffBudget_0 = account ? !!account.offbudget : false;
	let t25;
	if ($[68] !== getPayee || $[69] !== getTransferAccount || $[70] !== t || $[71] !== transaction) {
		t25 = getPrettyPayee({
			t,
			transaction,
			payee: getPayee(transaction),
			transferAccount: getTransferAccount(transaction)
		});
		$[68] = getPayee;
		$[69] = getTransferAccount;
		$[70] = t;
		$[71] = transaction;
		$[72] = t25;
	} else t25 = $[72];
	const title = t25;
	let t26;
	if ($[73] !== dateFormat || $[74] !== transaction.date) {
		t26 = dayFromDate(parse(transaction.date, dateFormat, /* @__PURE__ */ new Date()));
		$[73] = dateFormat;
		$[74] = transaction.date;
		$[75] = t26;
	} else t26 = $[75];
	const dateDefaultValue = t26;
	const T0 = Page;
	let t27;
	if ($[76] !== isAdding || $[77] !== t || $[78] !== title || $[79] !== transaction.payee) {
		t27 = transaction.payee == null ? isAdding ? t("New Transaction") : t("Transaction") : title;
		$[76] = isAdding;
		$[77] = t;
		$[78] = title;
		$[79] = transaction.payee;
		$[80] = t27;
	} else t27 = $[80];
	let t28;
	if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, {});
		$[81] = t28;
	} else t28 = $[81];
	let t29;
	if ($[82] !== t27) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title: t27,
			leftContent: t28
		});
		$[82] = t27;
		$[83] = t29;
	} else t29 = $[83];
	let t30;
	if ($[84] !== editingField || $[85] !== isAdding || $[86] !== onAddSplit || $[87] !== onEditFieldInner || $[88] !== onSaveInner || $[89] !== onSplit || $[90] !== transactions) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Footer, {
			transactions,
			isAdding,
			onAdd: onSaveInner,
			onSave: onSaveInner,
			onSplit,
			onAddSplit,
			onEmptySplitFound,
			editingField,
			onEditField: onEditFieldInner
		});
		$[84] = editingField;
		$[85] = isAdding;
		$[86] = onAddSplit;
		$[87] = onEditFieldInner;
		$[88] = onSaveInner;
		$[89] = onSplit;
		$[90] = transactions;
		$[91] = t30;
	} else t30 = $[91];
	const t31 = 0;
	const T1 = View;
	const t32 = "transaction-form";
	let t33;
	if ($[92] === Symbol.for("react.memo_cache_sentinel")) {
		t33 = {
			flexShrink: 0,
			marginTop: 20,
			marginBottom: 20
		};
		$[92] = t33;
	} else t33 = $[92];
	let t34;
	if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
		t34 = { alignItems: "center" };
		$[93] = t34;
	} else t34 = $[93];
	let t35;
	if ($[94] !== t) {
		t35 = t("Amount");
		$[94] = t;
		$[95] = t35;
	} else t35 = $[95];
	let t36;
	if ($[96] === Symbol.for("react.memo_cache_sentinel")) {
		t36 = { marginBottom: 0 };
		$[96] = t36;
	} else t36 = $[96];
	let t37;
	if ($[97] !== t35) {
		t37 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, {
			title: t35,
			flush: true,
			style: t36
		});
		$[97] = t35;
		$[98] = t37;
	} else t37 = $[98];
	let t38;
	if ($[99] !== onClearActiveEdit) {
		t38 = () => onClearActiveEdit();
		$[99] = onClearActiveEdit;
		$[100] = t38;
	} else t38 = $[100];
	let t39;
	let t40;
	if ($[101] === Symbol.for("react.memo_cache_sentinel")) {
		t39 = {
			width: "auto",
			padding: "5px",
			paddingLeft: "20px",
			paddingRight: "20px",
			minWidth: "100%"
		};
		t40 = {
			...styles.veryLargeText,
			textAlign: "center"
		};
		$[101] = t39;
		$[102] = t40;
	} else {
		t39 = $[101];
		t40 = $[102];
	}
	let t41;
	if ($[103] !== onTotalAmountEdit || $[104] !== onTotalAmountUpdate || $[105] !== t38 || $[106] !== totalAmountFocused || $[107] !== transaction.amount) {
		t41 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusableAmountInput, {
			value: transaction.amount,
			zeroSign: "-",
			focused: totalAmountFocused,
			onFocus: onTotalAmountEdit,
			onBlur: t38,
			onUpdateAmount: onTotalAmountUpdate,
			focusedStyle: t39,
			textStyle: t40
		});
		$[103] = onTotalAmountEdit;
		$[104] = onTotalAmountUpdate;
		$[105] = t38;
		$[106] = totalAmountFocused;
		$[107] = transaction.amount;
		$[108] = t41;
	} else t41 = $[108];
	let t42;
	if ($[109] !== t37 || $[110] !== t41) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t34,
			children: [t37, t41]
		});
		$[109] = t37;
		$[110] = t41;
		$[111] = t42;
	} else t42 = $[111];
	let t43;
	if ($[112] !== t) {
		t43 = t("Payee");
		$[112] = t;
		$[113] = t43;
	} else t43 = $[113];
	let t44;
	if ($[114] !== t43) {
		t44 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t43 });
		$[114] = t43;
		$[115] = t44;
	} else t44 = $[115];
	let t45;
	if ($[116] === Symbol.for("react.memo_cache_sentinel")) {
		t45 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgUser, {
			width: 17,
			height: 17
		});
		$[116] = t45;
	} else t45 = $[116];
	let t46;
	if ($[117] !== t) {
		t46 = t("Who did you pay?");
		$[117] = t;
		$[118] = t46;
	} else t46 = $[118];
	let t47;
	if ($[119] !== transaction.is_parent) {
		t47 = transaction.is_parent && {
			fontStyle: "italic",
			fontWeight: 300
		};
		$[119] = transaction.is_parent;
		$[120] = t47;
	} else t47 = $[120];
	let t48;
	if ($[121] !== t47) {
		t48 = { ...t47 };
		$[121] = t47;
		$[122] = t48;
	} else t48 = $[122];
	let t49;
	if ($[123] !== editingField || $[124] !== transaction.id) {
		t49 = !!editingField && editingField !== getFieldName(transaction.id, "payee");
		$[123] = editingField;
		$[124] = transaction.id;
		$[125] = t49;
	} else t49 = $[125];
	let t50;
	if ($[126] !== onEditFieldInner || $[127] !== transaction.id) {
		t50 = () => onEditFieldInner(transaction.id, "payee");
		$[126] = onEditFieldInner;
		$[127] = transaction.id;
		$[128] = t50;
	} else t50 = $[128];
	const t51 = !!nearestPayee && !transaction.payee && !shouldShowSaveLocation;
	let t52;
	if ($[129] !== nearestPayee || $[130] !== onSaveLocation || $[131] !== onSelectNearestPayee || $[132] !== shouldShowSaveLocation || $[133] !== transaction.payee) {
		t52 = shouldShowSaveLocation ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			variant: "bare",
			onPress: onSaveLocation,
			style: {
				backgroundColor: theme.buttonNormalBackground,
				border: `1px solid ${theme.buttonNormalBorder}`,
				color: theme.buttonNormalText,
				fontSize: "11px",
				padding: "4px 8px",
				borderRadius: 3,
				height: "auto",
				minHeight: "auto"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgLocation, {
				width: 10,
				height: 10,
				style: { marginLeft: 4 }
			})]
		}) : nearestPayee && !transaction.payee ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			variant: "bare",
			onPress: onSelectNearestPayee,
			style: {
				backgroundColor: theme.buttonNormalBackground,
				border: `1px solid ${theme.buttonNormalBorder}`,
				color: theme.buttonNormalText,
				fontSize: "11px",
				padding: "4px 8px",
				borderRadius: 3,
				height: "auto",
				minHeight: "auto"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Nearby" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgLocation, {
				width: 10,
				height: 10,
				style: { marginLeft: 4 }
			})]
		}) : dropdownChevron;
		$[129] = nearestPayee;
		$[130] = onSaveLocation;
		$[131] = onSelectNearestPayee;
		$[132] = shouldShowSaveLocation;
		$[133] = transaction.payee;
		$[134] = t52;
	} else t52 = $[134];
	let t53;
	if ($[135] !== t46 || $[136] !== t48 || $[137] !== t49 || $[138] !== t50 || $[139] !== t51 || $[140] !== t52 || $[141] !== title) {
		t53 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TapField, {
			icon: t45,
			placeholder: t46,
			textStyle: t48,
			value: title,
			isDisabled: t49,
			onPress: t50,
			"data-testid": "payee-field",
			alwaysShowRightContent: t51,
			rightContent: t52
		});
		$[135] = t46;
		$[136] = t48;
		$[137] = t49;
		$[138] = t50;
		$[139] = t51;
		$[140] = t52;
		$[141] = title;
		$[142] = t53;
	} else t53 = $[142];
	let t54;
	if ($[143] !== t44 || $[144] !== t53) {
		t54 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t44, t53] });
		$[143] = t44;
		$[144] = t53;
		$[145] = t54;
	} else t54 = $[145];
	let t55;
	if ($[146] !== editingField || $[147] !== getCategory || $[148] !== isBudgetTransfer || $[149] !== isOffBudget_0 || $[150] !== onEditFieldInner || $[151] !== t || $[152] !== transaction) {
		t55 = !transaction.is_parent && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t("Category") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TapField, {
			icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTag, {
				width: 17,
				height: 17
			}),
			placeholder: t("Select a category"),
			rightContent: dropdownChevron,
			style: { ...(isOffBudget_0 || isBudgetTransfer(transaction)) && {
				fontStyle: "italic",
				color: theme.pageTextSubdued,
				fontWeight: 300
			} },
			value: getCategory(transaction, isOffBudget_0),
			isDisabled: !!editingField && editingField !== getFieldName(transaction.id, "category") || isOffBudget_0 || isBudgetTransfer(transaction),
			onPress: () => onEditFieldInner(transaction.id, "category"),
			"data-testid": "category-field"
		})] });
		$[146] = editingField;
		$[147] = getCategory;
		$[148] = isBudgetTransfer;
		$[149] = isOffBudget_0;
		$[150] = onEditFieldInner;
		$[151] = t;
		$[152] = transaction;
		$[153] = t55;
	} else t55 = $[153];
	const t56 = childTransactions.map((childTrans, i, arr) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChildTransactionEdit, {
		transaction: childTrans,
		amountFocused: arr.findIndex(_temp6) === i,
		amountSign: childAmountSign,
		ref: (r) => {
			childTransactionElementRefMap.current = {
				...childTransactionElementRefMap.current,
				[childTrans.id]: r
			};
		},
		isOffBudget: isOffBudget_0,
		getCategory,
		getPayee,
		getTransferAccount,
		isBudgetTransfer,
		onUpdate: onUpdateInner,
		onEditField: onEditFieldInner,
		onDelete: onDeleteInner
	}, childTrans.id));
	let t57;
	if ($[154] !== childTransactions || $[155] !== editingField || $[156] !== onSplit || $[157] !== transaction.amount || $[158] !== transaction.id) {
		t57 = transaction.amount !== 0 && childTransactions.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { alignItems: "center" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "bare",
				isDisabled: !!editingField,
				style: {
					height: 40,
					borderWidth: 0,
					marginLeft: styles.mobileEditingPadding,
					marginRight: styles.mobileEditingPadding,
					marginTop: 10,
					backgroundColor: "transparent"
				},
				onPress: () => onSplit(transaction.id),
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgSplit, {
					width: 17,
					height: 17,
					style: { color: theme.formLabelText }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						marginLeft: 5,
						userSelect: "none",
						color: theme.formLabelText
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Split" })
				})]
			})
		});
		$[154] = childTransactions;
		$[155] = editingField;
		$[156] = onSplit;
		$[157] = transaction.amount;
		$[158] = transaction.id;
		$[159] = t57;
	} else t57 = $[159];
	let t58;
	if ($[160] !== t) {
		t58 = t("Account");
		$[160] = t;
		$[161] = t58;
	} else t58 = $[161];
	let t59;
	if ($[162] !== t58) {
		t59 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t58 });
		$[162] = t58;
		$[163] = t59;
	} else t59 = $[163];
	let t60;
	if ($[164] === Symbol.for("react.memo_cache_sentinel")) {
		t60 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgWallet, {
			width: 17,
			height: 17
		});
		$[164] = t60;
	} else t60 = $[164];
	let t61;
	if ($[165] !== t) {
		t61 = t("Select an account");
		$[165] = t;
		$[166] = t61;
	} else t61 = $[166];
	let t62;
	if ($[167] !== editingField || $[168] !== transaction.id) {
		t62 = !!editingField && editingField !== getFieldName(transaction.id, "account");
		$[167] = editingField;
		$[168] = transaction.id;
		$[169] = t62;
	} else t62 = $[169];
	const t63 = account?.name;
	let t64;
	if ($[170] !== onEditFieldInner || $[171] !== transaction.id) {
		t64 = () => onEditFieldInner(transaction.id, "account");
		$[170] = onEditFieldInner;
		$[171] = transaction.id;
		$[172] = t64;
	} else t64 = $[172];
	let t65;
	if ($[173] !== t61 || $[174] !== t62 || $[175] !== t63 || $[176] !== t64) {
		t65 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TapField, {
			icon: t60,
			placeholder: t61,
			rightContent: dropdownChevron,
			isDisabled: t62,
			value: t63,
			onPress: t64,
			"data-testid": "account-field"
		});
		$[173] = t61;
		$[174] = t62;
		$[175] = t63;
		$[176] = t64;
		$[177] = t65;
	} else t65 = $[177];
	let t66;
	if ($[178] !== t59 || $[179] !== t65) {
		t66 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t59, t65] });
		$[178] = t59;
		$[179] = t65;
		$[180] = t66;
	} else t66 = $[180];
	let t67;
	if ($[181] === Symbol.for("react.memo_cache_sentinel")) {
		t67 = { flexDirection: "row" };
		$[181] = t67;
	} else t67 = $[181];
	let t68;
	if ($[182] === Symbol.for("react.memo_cache_sentinel")) {
		t68 = { flex: 1 };
		$[182] = t68;
	} else t68 = $[182];
	let t69;
	if ($[183] !== t) {
		t69 = t("Date");
		$[183] = t;
		$[184] = t69;
	} else t69 = $[184];
	let t70;
	if ($[185] !== t69) {
		t70 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t69 });
		$[185] = t69;
		$[186] = t70;
	} else t70 = $[186];
	let t71;
	if ($[187] === Symbol.for("react.memo_cache_sentinel")) {
		t71 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCalendar, {
			width: 17,
			height: 17
		});
		$[187] = t71;
	} else t71 = $[187];
	let t72;
	if ($[188] !== editingField || $[189] !== transaction.id) {
		t72 = !!editingField && editingField !== getFieldName(transaction.id, "date");
		$[188] = editingField;
		$[189] = transaction.id;
		$[190] = t72;
	} else t72 = $[190];
	let t73;
	if ($[191] === Symbol.for("react.memo_cache_sentinel")) {
		t73 = {
			color: theme.tableText,
			minWidth: "150px",
			appearance: "none"
		};
		$[191] = t73;
	} else t73 = $[191];
	let t74;
	if ($[192] !== onClearActiveEdit) {
		t74 = () => onClearActiveEdit();
		$[192] = onClearActiveEdit;
		$[193] = t74;
	} else t74 = $[193];
	let t75;
	if ($[194] !== onRequestActiveEdit || $[195] !== transaction.id) {
		t75 = () => onRequestActiveEdit(getFieldName(transaction.id, "date"));
		$[194] = onRequestActiveEdit;
		$[195] = transaction.id;
		$[196] = t75;
	} else t75 = $[196];
	let t76;
	if ($[197] !== dateFormat || $[198] !== onUpdateInner || $[199] !== transaction) {
		t76 = (event) => onUpdateInner(transaction, "date", format(parseISO(event.target.value), dateFormat));
		$[197] = dateFormat;
		$[198] = onUpdateInner;
		$[199] = transaction;
		$[200] = t76;
	} else t76 = $[200];
	let t77;
	if ($[201] !== dateDefaultValue || $[202] !== t72 || $[203] !== t74 || $[204] !== t75 || $[205] !== t76) {
		t77 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputField, {
			type: "date",
			icon: t71,
			disabled: t72,
			required: true,
			style: t73,
			defaultValue: dateDefaultValue,
			onBlur: t74,
			onFocus: t75,
			onChange: t76
		});
		$[201] = dateDefaultValue;
		$[202] = t72;
		$[203] = t74;
		$[204] = t75;
		$[205] = t76;
		$[206] = t77;
	} else t77 = $[206];
	let t78;
	if ($[207] !== t70 || $[208] !== t77) {
		t78 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t68,
			children: [t70, t77]
		});
		$[207] = t70;
		$[208] = t77;
		$[209] = t78;
	} else t78 = $[209];
	let t79;
	if ($[210] !== onUpdateInner || $[211] !== t || $[212] !== transaction) {
		t79 = transaction.reconciled ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { alignItems: "center" },
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t("Reconciled") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toggle, {
				id: "Reconciled",
				isOn: true,
				isDisabled: true
			})]
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { alignItems: "center" },
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t("Cleared") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleField, {
				id: "cleared",
				isOn: !!transaction.cleared,
				onToggle: (on) => onUpdateInner(transaction, "cleared", on)
			})]
		});
		$[210] = onUpdateInner;
		$[211] = t;
		$[212] = transaction;
		$[213] = t79;
	} else t79 = $[213];
	let t80;
	if ($[214] !== t78 || $[215] !== t79) {
		t80 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t67,
			children: [t78, t79]
		});
		$[214] = t78;
		$[215] = t79;
		$[216] = t80;
	} else t80 = $[216];
	let t81;
	if ($[217] !== t) {
		t81 = t("Notes");
		$[217] = t;
		$[218] = t81;
	} else t81 = $[218];
	let t82;
	if ($[219] !== t81) {
		t82 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldLabel, { title: t81 });
		$[219] = t81;
		$[220] = t82;
	} else t82 = $[220];
	let t83;
	if ($[221] === Symbol.for("react.memo_cache_sentinel")) {
		t83 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgNotesPaper, {
			width: 17,
			height: 17
		});
		$[221] = t83;
	} else t83 = $[221];
	let t84;
	if ($[222] !== t) {
		t84 = t("Add a note (optional)");
		$[222] = t;
		$[223] = t84;
	} else t84 = $[223];
	let t85;
	if ($[224] !== editingField || $[225] !== transaction.id) {
		t85 = !!editingField && editingField !== getFieldName(transaction.id, "notes");
		$[224] = editingField;
		$[225] = transaction.id;
		$[226] = t85;
	} else t85 = $[226];
	let t86;
	if ($[227] !== onRequestActiveEdit || $[228] !== transaction.id) {
		t86 = () => {
			onRequestActiveEdit(getFieldName(transaction.id, "notes"));
		};
		$[227] = onRequestActiveEdit;
		$[228] = transaction.id;
		$[229] = t86;
	} else t86 = $[229];
	let t87;
	if ($[230] !== onClearActiveEdit) {
		t87 = () => onClearActiveEdit();
		$[230] = onClearActiveEdit;
		$[231] = t87;
	} else t87 = $[231];
	let t88;
	if ($[232] !== onUpdateInner || $[233] !== transaction) {
		t88 = (event_0) => onUpdateInner(transaction, "notes", event_0.target.value);
		$[232] = onUpdateInner;
		$[233] = transaction;
		$[234] = t88;
	} else t88 = $[234];
	let t89;
	if ($[235] !== t84 || $[236] !== t85 || $[237] !== t86 || $[238] !== t87 || $[239] !== t88 || $[240] !== transaction.notes) {
		t89 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputField, {
			ref: noteRef,
			icon: t83,
			placeholder: t84,
			disabled: t85,
			defaultValue: transaction.notes,
			onFocus: t86,
			onBlur: t87,
			onChange: t88
		});
		$[235] = t84;
		$[236] = t85;
		$[237] = t86;
		$[238] = t87;
		$[239] = t88;
		$[240] = transaction.notes;
		$[241] = t89;
	} else t89 = $[241];
	let t90;
	if ($[242] === Symbol.for("react.memo_cache_sentinel")) {
		t90 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NoteTagAutocomplete, { inputRef: noteRef });
		$[242] = t90;
	} else t90 = $[242];
	let t91;
	if ($[243] !== t82 || $[244] !== t89) {
		t91 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [
			t82,
			t89,
			t90
		] });
		$[243] = t82;
		$[244] = t89;
		$[245] = t91;
	} else t91 = $[245];
	let t92;
	if ($[246] !== isAdding || $[247] !== onDeleteInner || $[248] !== transaction.id) {
		t92 = !isAdding && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { alignItems: "center" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
				variant: "bare",
				onPress: () => onDeleteInner(transaction.id),
				style: {
					height: 40,
					borderWidth: 0,
					marginLeft: styles.mobileEditingPadding,
					marginRight: styles.mobileEditingPadding,
					marginTop: 10,
					backgroundColor: "transparent"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTrash, {
					width: 17,
					height: 17,
					style: { color: theme.errorText }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						color: theme.errorText,
						marginLeft: 5,
						userSelect: "none"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Delete transaction" })
				})]
			})
		});
		$[246] = isAdding;
		$[247] = onDeleteInner;
		$[248] = transaction.id;
		$[249] = t92;
	} else t92 = $[249];
	let t93;
	if ($[250] !== T1 || $[251] !== t33 || $[252] !== t42 || $[253] !== t54 || $[254] !== t55 || $[255] !== t56 || $[256] !== t57 || $[257] !== t66 || $[258] !== t80 || $[259] !== t91 || $[260] !== t92) {
		t93 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T1, {
			"data-testid": t32,
			style: t33,
			children: [
				t42,
				t54,
				t55,
				t56,
				t57,
				t66,
				t80,
				t91,
				t92
			]
		});
		$[250] = T1;
		$[251] = t33;
		$[252] = t42;
		$[253] = t54;
		$[254] = t55;
		$[255] = t56;
		$[256] = t57;
		$[257] = t66;
		$[258] = t80;
		$[259] = t91;
		$[260] = t92;
		$[261] = t93;
	} else t93 = $[261];
	let t94;
	if ($[262] !== T0 || $[263] !== t29 || $[264] !== t30 || $[265] !== t93) {
		t94 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			header: t29,
			footer: t30,
			padding: t31,
			children: t93
		});
		$[262] = T0;
		$[263] = t29;
		$[264] = t30;
		$[265] = t93;
		$[266] = t94;
	} else t94 = $[266];
	return t94;
});
function NoteTagAutocomplete(t0) {
	const $ = (0, import_compiler_runtime.c)(47);
	const { inputRef } = t0;
	const dispatch = useDispatch();
	const [note, setNote] = useInputRefValue(inputRef);
	const [cursorPosition] = useCursorPosition(inputRef);
	const [startIdx, endIdx] = useCurrentWordRange(note, cursorPosition);
	let currentWord;
	let t1;
	if ($[0] !== endIdx || $[1] !== note || $[2] !== startIdx) {
		currentWord = note.slice(startIdx, endIdx);
		let t2;
		if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
			t2 = /^#+/;
			$[5] = t2;
		} else t2 = $[5];
		t1 = currentWord.replace(t2, "");
		$[0] = endIdx;
		$[1] = note;
		$[2] = startIdx;
		$[3] = currentWord;
		$[4] = t1;
	} else {
		currentWord = $[3];
		t1 = $[4];
	}
	const currentWordNoHash = t1;
	const { data: filteredTags, refetch } = useFilteredTags(currentWord, true);
	let t2;
	if ($[6] !== currentWord || $[7] !== currentWordNoHash || $[8] !== filteredTags) {
		t2 = currentWord.startsWith("#") && currentWordNoHash && !filteredTags.some((tag) => tag.tag === currentWordNoHash);
		$[6] = currentWord;
		$[7] = currentWordNoHash;
		$[8] = filteredTags;
		$[9] = t2;
	} else t2 = $[9];
	const showNewTag = t2;
	let t3;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = { ellipsis: true };
		$[10] = t3;
	} else t3 = $[10];
	const getTagCSS = useTagCSS(t3);
	let T0;
	let T1;
	let handleCreate;
	let t4;
	let t5;
	let t6;
	let t7;
	if ($[11] !== dispatch || $[12] !== endIdx || $[13] !== filteredTags || $[14] !== getTagCSS || $[15] !== inputRef || $[16] !== note || $[17] !== refetch || $[18] !== setNote || $[19] !== showNewTag || $[20] !== startIdx) {
		const handleSelect = function handleSelect(tag_0) {
			if (!inputRef.current) return;
			setNote(note.slice(0, startIdx) + "#" + tag_0 + " " + note.slice(endIdx));
			const newPos = startIdx + tag_0.length + 2;
			inputRef.current.setSelectionRange(newPos, newPos);
			document.dispatchEvent(new Event("selectionchange"));
		};
		handleCreate = async function handleCreate(tag_1) {
			if (!inputRef.current) return;
			try {
				await send("tags-create", { tag: tag_1 });
				refetch();
				handleSelect(tag_1);
			} catch (t8) {
				const e = t8;
				dispatch(addNotification({ notification: {
					type: "error",
					message: "Failed to add tag, check logs"
				} }));
				console.trace(e);
			}
		};
		let t9;
		if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
			t9 = css({
				"scrollbar-width": "none",
				"-ms-overflow-style": "none",
				"&::-webkit-scrollbar": { display: "none" }
			});
			$[28] = t9;
		} else t9 = $[28];
		const hideScrollbar = t9;
		T1 = View;
		const t10 = filteredTags.length || showNewTag ? 30 : 0;
		if ($[29] !== t10) {
			t6 = {
				width: "100%",
				padding: "4px 8px 4px 8px",
				borderRadius: 30,
				overflowX: "auto",
				height: t10,
				transitionProperty: "height",
				transitionDuration: "100ms"
			};
			$[29] = t10;
			$[30] = t6;
		} else t6 = $[30];
		t7 = hideScrollbar;
		T0 = View;
		if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = {
				display: "flex",
				flexDirection: "row",
				alignItems: "end",
				flexWrap: "nowrap",
				gap: 4,
				paddingRight: 8
			};
			$[31] = t4;
		} else t4 = $[31];
		t5 = filteredTags.map((tag_2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
			type: "button",
			style: {
				border: "none",
				height: 22,
				maxWidth: "50dvw"
			},
			className: getTagCSS(tag_2.tag),
			onMouseDown: _temp7,
			onClick: () => handleSelect(tag_2.tag),
			children: ["#", tag_2.tag]
		}) }, tag_2.id));
		$[11] = dispatch;
		$[12] = endIdx;
		$[13] = filteredTags;
		$[14] = getTagCSS;
		$[15] = inputRef;
		$[16] = note;
		$[17] = refetch;
		$[18] = setNote;
		$[19] = showNewTag;
		$[20] = startIdx;
		$[21] = T0;
		$[22] = T1;
		$[23] = handleCreate;
		$[24] = t4;
		$[25] = t5;
		$[26] = t6;
		$[27] = t7;
	} else {
		T0 = $[21];
		T1 = $[22];
		handleCreate = $[23];
		t4 = $[24];
		t5 = $[25];
		t6 = $[26];
		t7 = $[27];
	}
	let t8;
	if ($[32] !== currentWordNoHash || $[33] !== getTagCSS || $[34] !== handleCreate || $[35] !== showNewTag) {
		t8 = showNewTag && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
			type: "button",
			style: {
				padding: "1px 1px 1px 9px",
				borderRadius: 12,
				borderWidth: 0,
				backgroundColor: theme.noticeBackground,
				color: theme.noticeTextDark,
				display: "flex",
				alignItems: "center",
				flexWrap: "nowrap",
				gap: 4
			},
			onMouseDown: _temp8,
			onClick: () => handleCreate(currentWordNoHash),
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgAdd, {
					height: 8,
					width: 8
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
					style: { whiteSpace: "nowrap" },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Create tag" })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					style: {
						borderWidth: 0,
						height: 20,
						maxWidth: "50dvw",
						overflow: "hidden",
						textOverflow: "ellipsis",
						display: "inline-block"
					},
					className: getTagCSS(""),
					children: ["#", currentWordNoHash]
				})
			]
		});
		$[32] = currentWordNoHash;
		$[33] = getTagCSS;
		$[34] = handleCreate;
		$[35] = showNewTag;
		$[36] = t8;
	} else t8 = $[36];
	let t9;
	if ($[37] !== T0 || $[38] !== t4 || $[39] !== t5 || $[40] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T0, {
			style: t4,
			children: [t5, t8]
		});
		$[37] = T0;
		$[38] = t4;
		$[39] = t5;
		$[40] = t8;
		$[41] = t9;
	} else t9 = $[41];
	let t10;
	if ($[42] !== T1 || $[43] !== t6 || $[44] !== t7 || $[45] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T1, {
			style: t6,
			className: t7,
			children: t9
		});
		$[42] = T1;
		$[43] = t6;
		$[44] = t7;
		$[45] = t9;
		$[46] = t10;
	} else t10 = $[46];
	return t10;
}
function _temp8(e_1) {
	return e_1.preventDefault();
}
function _temp7(e_0) {
	return e_0.preventDefault();
}
function isTemporary(transaction) {
	return transaction.id.indexOf("temp") === 0;
}
function TransactionEditUnconnected({ categories, accounts, payees, lastTransaction, dateFormat }) {
	const { t } = useTranslation();
	const { transactionId } = useParams();
	const { state: locationState } = useLocation();
	const [searchParams] = useSearchParams();
	const dispatch = useDispatch();
	const updatePayeeLocationMutation = useSavePayeeLocationMutation();
	const navigate = useNavigate();
	const [transactions, setTransactions] = (0, import_react.useState)([]);
	const [fetchedTransactions, setFetchedTransactions] = (0, import_react.useState)([]);
	const isAdding = (0, import_react.useRef)(false);
	const isDeleted = (0, import_react.useRef)(false);
	const searchParamCategory = (0, import_react.useMemo)(() => categories.find((c) => c.name === searchParams.get("category"))?.id, [categories, searchParams]);
	const searchParamAccount = (0, import_react.useMemo)(() => accounts.find((a) => a.name === searchParams.get("account"))?.id, [accounts, searchParams]);
	const searchParamPayee = (0, import_react.useMemo)(() => payees.find((p) => p.name === searchParams.get("payee"))?.id, [payees, searchParams]);
	const locationAccess = useLocationPermission();
	const [shouldShowSaveLocation, setShouldShowSaveLocation] = (0, import_react.useState)(false);
	const { data: nearbyPayees = [] } = useNearbyPayees();
	const nearestPayee = nearbyPayees[0]?.payee ?? null;
	(0, import_react.useEffect)(() => {
		let unmounted = false;
		async function fetchTransaction() {
			const { data } = await aqlQuery(q("transactions").filter({ id: transactionId }).select("*").options({ splits: "grouped" }));
			if (!unmounted) {
				const fetchedTransactions_0 = ungroupTransactions(data);
				setTransactions(fetchedTransactions_0);
				setFetchedTransactions(fetchedTransactions_0);
			}
		}
		if (transactionId !== "new") fetchTransaction();
		else isAdding.current = true;
		return () => {
			unmounted = true;
		};
	}, [transactionId]);
	(0, import_react.useEffect)(() => {
		if (!locationAccess) setShouldShowSaveLocation(false);
	}, [locationAccess]);
	(0, import_react.useEffect)(() => {
		if (isAdding.current) setTransactions([{
			id: "temp",
			date: (() => {
				const dateParam = searchParams.get("date") || "";
				if (!isNaN(Date.parse(dateParam))) return dateParam;
				return lastTransaction?.date || currentDay();
			})(),
			payee: searchParamPayee,
			account: searchParamAccount || locationState?.accountId || lastTransaction?.account || null,
			category: searchParamCategory || locationState?.categoryId || null,
			amount: -amountToInteger(parseFloat(searchParams.get("amount") || "") || 0),
			cleared: searchParams.get("cleared") === "true",
			notes: searchParams.get("notes") || ""
		}]);
	}, [
		locationState?.accountId,
		locationState?.categoryId,
		lastTransaction,
		searchParamAccount,
		searchParamCategory,
		searchParamPayee,
		searchParams
	]);
	const onUpdate = (0, import_react.useCallback)(async (serializedTransaction, updatedField) => {
		const newTransaction = { ...deserializeTransaction(serializedTransaction, null, dateFormat) };
		if (isTemporary(newTransaction)) {
			const diff = getChangedValues(newTransaction, await send("rules-run", { transaction: newTransaction }));
			if (diff) {
				Object.keys(diff).forEach((key) => {
					const field = key;
					if (newTransaction[field] == null || newTransaction[field] === "" || newTransaction[field] === 0 || newTransaction[field] === false || updatedField === "payee") newTransaction[field] = diff[field];
				});
				if (newTransaction.is_parent && diff.subtransactions !== void 0 && updatedField !== null) newTransaction.subtransactions = diff.subtransactions.map((st, idx) => ({
					...newTransaction.subtransactions?.[idx] || st,
					...st[updatedField] != null && { [updatedField]: st[updatedField] }
				}));
			}
		}
		const { data: newTransactions } = updateTransaction(transactions, newTransaction);
		setTransactions(newTransactions);
		if (updatedField === "payee") {
			setShouldShowSaveLocation(false);
			if (newTransaction.payee && locationAccess) {
				const payeeLocations = await locationService.getPayeeLocations(newTransaction.payee);
				if (payeeLocations.length === 0) setShouldShowSaveLocation(true);
				else {
					const currentPosition = await locationService.getCurrentPosition();
					if (!payeeLocations.some((loc) => calculateDistance(currentPosition, {
						latitude: loc.latitude,
						longitude: loc.longitude
					}) <= 500)) setShouldShowSaveLocation(true);
				}
			}
		}
	}, [
		dateFormat,
		transactions,
		locationAccess
	]);
	const onSave = (0, import_react.useCallback)(async (newTransactions_0) => {
		if (isDeleted.current) return;
		const changes = diffItems(fetchedTransactions || [], newTransactions_0);
		if (changes.added.length > 0 || changes.updated.length > 0 || changes.deleted.length) await send("transactions-batch-update", {
			added: changes.added,
			deleted: changes.deleted,
			updated: changes.updated
		});
		if (isAdding.current) dispatch(setLastTransaction({ transaction: newTransactions_0[0] }));
	}, [dispatch, fetchedTransactions]);
	const onDelete = (0, import_react.useCallback)(async (id) => {
		const changes_0 = deleteTransaction(transactions, id);
		if (isAdding.current) isDeleted.current = true;
		else await send("transactions-batch-update", { deleted: changes_0.diff.deleted });
		setTransactions(changes_0.data);
	}, [transactions]);
	const onAddSplit = (0, import_react.useCallback)((id_0) => {
		setTransactions(addSplitTransaction(transactions, id_0).data);
	}, [transactions]);
	const onSplit = (0, import_react.useCallback)((id_1) => {
		setTransactions(splitTransaction(transactions, id_1, (parent) => [makeChild(parent), makeChild(parent)]).data);
	}, [transactions]);
	const onSaveLocation = (0, import_react.useCallback)(async () => {
		try {
			const [transaction_0] = transactions;
			if (transaction_0.payee) {
				await updatePayeeLocationMutation.mutateAsync(transaction_0.payee);
				setShouldShowSaveLocation(false);
			}
		} catch (error) {
			console.error("Failed to save location", { error });
			dispatch(addNotification({ notification: {
				type: "error",
				message: t("Failed to save location")
			} }));
		}
	}, [
		t,
		transactions,
		dispatch,
		updatePayeeLocationMutation
	]);
	const onSelectNearestPayee = (0, import_react.useCallback)(() => {
		const transaction_1 = transactions[0];
		if (!nearestPayee || !transaction_1 || transaction_1.payee) return;
		onUpdate({
			...serializeTransaction(transaction_1, dateFormat),
			payee: nearestPayee.id
		}, "payee");
	}, [
		transactions,
		nearestPayee,
		onUpdate,
		dateFormat
	]);
	if (accounts.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Page, {
		header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title: t("New Transaction"),
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, {})
		}),
		padding: 0,
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				flex: 1,
				alignItems: "center",
				justifyContent: "center",
				padding: 20,
				backgroundColor: theme.mobilePageBackground
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: {
					fontSize: 15,
					textAlign: "center",
					marginBottom: 20,
					lineHeight: "1.5em"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
					"To add a transaction, you need to",
					" ",
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "create an account first" }),
					". You can add an account from the accounts page."
				] })
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: () => {
					dispatch(pushModal({ modal: {
						name: "add-account",
						options: {}
					} }));
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Add account" })
			})]
		})
	});
	if (categories.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Page, {
		header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title: t("New Transaction"),
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, {})
		}),
		padding: 0,
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				flex: 1,
				alignItems: "center",
				justifyContent: "center",
				padding: 20,
				backgroundColor: theme.mobilePageBackground
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: {
					fontSize: 15,
					textAlign: "center",
					marginBottom: 20,
					lineHeight: "1.5em"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
					"To add a transaction, you need to",
					" ",
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "create a category first" }),
					". You can add categories from the budget page."
				] })
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: () => {
					navigate("/budget");
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Go to budget" })
			})]
		})
	});
	if (transactions.length === 0) return null;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
		style: {
			flex: 1,
			backgroundColor: theme.pageBackground
		},
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TransactionEditInner, {
			transactions,
			isAdding: isAdding.current,
			categories,
			accounts,
			payees,
			dateFormat,
			onUpdate,
			onSave,
			onDelete,
			onSplit,
			onAddSplit,
			shouldShowSaveLocation,
			onSaveLocation,
			onSelectNearestPayee,
			nearestPayee: locationAccess ? nearestPayee : null
		})
	});
}
var TransactionEdit = (props) => {
	const $ = (0, import_compiler_runtime.c)(13);
	const { data: t0 } = useCategories();
	let t1;
	if ($[0] !== t0) {
		t1 = t0 === void 0 ? { list: [] } : t0;
		$[0] = t0;
		$[1] = t1;
	} else t1 = $[1];
	const { list: categories } = t1;
	const { data: t2 } = usePayees();
	let t3;
	if ($[2] !== t2) {
		t3 = t2 === void 0 ? [] : t2;
		$[2] = t2;
		$[3] = t3;
	} else t3 = $[3];
	const payees = t3;
	const lastTransaction = useSelector(_temp9);
	const { data: t4 } = useAccounts();
	let t5;
	if ($[4] !== t4) {
		t5 = t4 === void 0 ? [] : t4;
		$[4] = t4;
		$[5] = t5;
	} else t5 = $[5];
	const accounts = t5;
	const dateFormat = useDateFormat() || "MM/dd/yyyy";
	let t6;
	if ($[6] !== accounts || $[7] !== categories || $[8] !== dateFormat || $[9] !== lastTransaction || $[10] !== payees || $[11] !== props) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SingleActiveEditFormProvider, {
			formName: "mobile-transaction",
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TransactionEditUnconnected, {
				...props,
				categories,
				payees,
				lastTransaction,
				accounts,
				dateFormat
			})
		});
		$[6] = accounts;
		$[7] = categories;
		$[8] = dateFormat;
		$[9] = lastTransaction;
		$[10] = payees;
		$[11] = props;
		$[12] = t6;
	} else t6 = $[12];
	return t6;
};
function _temp2() {
	if (window.history.length === 1) {
		window.history.replaceState(null, "Actual Budget", "/");
		window.history.pushState(null, "Add Transaction", "/transactions/new");
	}
}
function _temp3(t_3) {
	return t_3.reconciled;
}
function _temp4(t_2) {
	return t_2.transfer_id;
}
function _temp5(id) {
	return id != null;
}
function _temp6(c) {
	return c.amount === 0;
}
function _temp9(state) {
	return state.transactions.lastTransaction;
}
//#endregion
export { useInitialMount as a, FocusableAmountInput as i, TransactionEdit as n, MobileBackButton as o, lookupName as r, Status as t };

//# sourceMappingURL=TransactionEdit.D3b8cFIw.chunk.js.map