const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["static/js/FormulaEditor.0HQ2ATyO.chunk.js","static/js/theme.mnyG70gE.chunk.js","static/js/extends.CfN_tLZB.chunk.js","static/js/client.5wdLOPyT.chunk.js"])))=>i.map(i=>d[i]);
import { a as __commonJSMin, 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 { $n as toDate, Br as createSelector, C as keyframes, Gt as useDispatch, Jn as endOfMonth, Kr as send, Qr as v4, Tn as integerToAmount, U as pushModal, Xn as normalizeDates, an as useAccounts, ci as t, cr as useQuery, dr as useQueryClient, en as addNotification, er as constructFrom, hn as amountToInteger, ii as useTranslation, li as __vitePreload, oi as Trans, or as useMutation, qn as differenceInMonths, qr as sendCatch, rn as removeNotification, ti as require_react_dom, v as styles, wr as keepPreviousData, x as css } from "./extends.CfN_tLZB.chunk.js";
import { $r as reportQueries, Ai as Menu, Ar as getYearEnd, Bl as config, Br as parseDate, Bu as format$1, Ca as SvgTag, Cn as mapField, Da as SvgRefresh, Dt as remarkGfm, E as SplitsExpandedProvider, Ei as useSyncedPref, En as HyperFormula, Er as getMonthEnd, Et as sequentialNewlinesPlugin, Fa as SvgList, Fi as SvgUncheckAll, Fn as useTransactions, Fo as require_isObject, Fu as subDays$1, Gr as subDays, Gu as startOfWeek, Hl as useSpring, Hr as prevYear, Hu as isValid, Ia as SvgListBullet, In as Select, Io as useLocalPref, Ir as lastDayOfMonth, Iu as parse, Jr as weekFromDate, Ka as SvgEquals, Kr as subMonths, Ku as addMonths$1, Lo as Checkbox, Lr as monthFromDate, Mi as q, Mr as isAfter, Ni as SvgViewShow, Nr as isBefore, O as DisplayPayeeProvider, Oa as SvgQueue, On as MOBILE_NAV_HEIGHT, Oo as require_debounce, Or as getWeekEnd, Ot as rehypeExternalLinks, Pi as SvgViewHide, Ps as $d3e0e05bdfcf66bd$export$a7fed597f4b8afd8, Pu as parseISO, Qr as dashboardQueries, Rl as Block, Ro as FormField, Rr as months_exports, Ru as isAfter$1, Sr as getDay$1, Ti as useFormat, To as PageHeader, Tr as getMonth, Tt as remarkBreaks, Ur as rangeInclusive, Uu as addWeeks$1, V as usePayees, Vi as SvgPencil1, Vn as Tooltip, Vr as prevMonth, Vu as startOfMonth, Wa as SvgExclamationSolid, Wl as useNavigate, Wn as FinancialText, Wu as differenceInCalendarDays, Xi as SvgDownloadThickBottom, Xr as yearRangeInclusive, Xt as require_prop_types, Xu as q$1, Ya as SvgCopy, Yr as weekRangeInclusive, Zo as Input, Zr as useReports, _ as useDateFormat, _o as SvgArrowThickDown, _r as dayRangeInclusive, _s as Button, _u as useSearchParams, ao as SvgChart, as as SvgExpandArrow, b as TransactionList, bi as SelectedProviderWithItems, br as firstDayOfMonth, bs as $de32f1b87079253c$export$3ddf2d174ce01153, c as GenericInput, co as SvgChartArea, cr as addDays, ct as useCategories, cu as View, do as SvgCalculator, dr as currentDate, dt as useUndo, ei as aqlQuery, fr as currentDay, fu as Route, ga as SvgCloseParenthesis, gr as dayFromDate, gs as Text, gt as useLocale, gu as useParams, ha as SvgOpenParenthesis, hi as usePrivacyMode, ho as SvgArrowThickUp, hr as currentYear, hs as Link, hu as useLocation, io as SvgCheveronDown, j as useMergedRefs, jn as useDrag, jr as getYearStart, ka as SvgQuestion, ki as Popover, ko as require_isSymbol, kt as Markdown, lo as SvgCamera, lr as addMonths, ls as useResponsive, ma as SvgSum, mi as PrivacyFilter, mn as ungroupTransactions, mr as currentWeek, ms as SpaceBetween, mt as useContextMenu, no as SvgCheveronRight, oi as Row, oo as SvgChartPie, pr as currentMonth, pu as Routes, qa as SvgDotsHorizontalTriple, ql as useSpreadsheet, qr as subWeeks, qt as useFeatureFlag, qu as addDays$1, r as FieldSelect, rt as AlignedText, so as SvgChartBar, st as InitialFocus, ta as SvgCheckAll, ti as Cell$1, to as SvgCheveronUp, uo as SvgCalendar, ur as addWeeks, vt as SchedulesProvider, wo as Page, wt as markdownBaseStyles, xa as SvgTrash, xl as clsx, xo as MobilePageHeader, xr as format, xu as m, yo as SvgArrowDown, yr as differenceInCalendarMonths, ys as $de32f1b87079253c$export$2e1e1122cf0cba88, yu as fe, za as SvgLayers, zl as animated, zo as FormLabel, zr as nextMonth, zu as getDay } from "./merge.C77XY6IK.chunk.js";
import { t as TransactionList$1 } from "./TransactionList.CNDU7K2A.chunk.js";
import { i as $216918bed6669f72$export$f5c9f3c2c4054eec, n as useDashboardPageWidgets, r as useDashboardPages, t as useFormatList } from "./useFormatList.QRhmVUki.chunk.js";
import { $ as Tooltip$1, $n as noop$1, $t as selectChartDataWithIndexesIfNotInPanoramaPosition3, A as SetComputedData, An as getCoordinatesOfGrid, At as selectStackGroups, B as SetLegendPayload, Bn as useAppSelector, Bt as isStacked, C as defaultCartesianAxisProps, Cn as selectChartOffsetInternal, Cr as useResizeObserver, Ct as selectAxisWithScale, D as removeLine, Dn as getBaseValueOfBar, Dr as Warning, Dt as selectDomainFromUserPreference, E as addLine, En as getBandSizeOfAxis, Er as Information, Et as selectDomainDefinition, F as replaceXAxis, Fn as isCategoricalAxis, Ft as selectXAxisSettings, G as getClassNameFromUnknown, Gn as getPercentValue, Gt as DefaultZIndexes, H as SetTooltipEntrySettings, Hn as require_identity$1, Ht as pickAxisId, I as Dots, In as truncateByDomain, It as selectXAxisSettingsNoDefaults, J as LabelListFromLabelProp, Jn as isNotNil, Jt as selectRootBarSize, K as CartesianLabelListContextProvider, Kn as interpolate, Kt as selectBarCategoryGap, L as SetCartesianGraphicalItem, Ln as isPositiveNumber, Lt as selectXAxisSize, M as usePlotArea, Mn as getTicksOfAxis, Mt as selectTicksOfGraphicalItem, N as addXAxis, Nn as getTooltipNameProp, Nt as selectUnfilteredCartesianItems, O as rectWithCoords, On as getCateCoordinateOfBar, Or as Paragraph, Ot as selectRealScaleType, P as removeXAxis, Pn as getValueByDataKey, Pt as selectXAxisPosition, Q as Text$1, Qn as mathSign, Qt as selectChartDataSliceIgnoringIndexes, R as SetPolarGraphicalItem, Rn as isWellBehavedNumber, Rt as selectYAxisSettings, S as CartesianAxis, Sn as selectAxisViewBox, Sr as require_isArray, St as selectAxisScale, T as useClipPathId, Tn as DATA_ITEM_INDEX_ATTRIBUTE_NAME, Tt as selectCartesianAxisSize, U as findAllByType, Un as resolveDefaultProps, Ut as pickAxisType, V as SetPolarLegendPayload, Vn as require_iteratee, Vt as getStackSeriesIdentifier, W as isClipDot, Wn as adaptEventsOfChild, Wt as getAxisTypeBasedOnLayout, X as CartesianLabelContextProvider, Xn as isNumOrStr, Xt as selectStackOffsetType, Y as PolarLabelListContextProvider, Yn as isNullish, Yt as selectRootMaxBarSize, Z as CartesianLabelFromLabelProp, Zn as isNumber, Zt as selectChartDataAndAlwaysIgnoreIndexes, _ as selectXAxisIdFromGraphicalItemId, _n as useOffsetInternal, _r as require_isArguments, _t as combineNumericalDomain, a as CartesianChart, an as useAnimationId, ar as Layer, at as selectActiveTooltipIndex, b as GraphicalItemClipPath, bn as warn, br as require__getNative, bt as selectAllErrorBarSettings, c as ReportEventSettings, cn as Curve, cr as svgPropertiesNoEvents, ct as setActiveMouseOverItemIndex, d as RechartsStoreProvider, dn as ReportChartSize, dr as FilterButton, dt as combineAxisDomainWithNiceTicks, en as selectChartDataWithIndexesIfNotInPanoramaPosition4, er as upperFirst, et as arrayTooltipSearcher, f as initialEventSettingsState, fn as selectChartLayout, fr as require__baseIsEqual, ft as combineDisplayedData, g as Area, gn as useChartWidth, gr as require__isIndex, gt as combineNiceTicks, h as axisPropsAreEqual, hn as useChartLayout, hr as require_isLength, ht as combineGraphicalItemsSettings, i as AreaChart, in as Rectangle, ir as constant_default, it as selectActiveTooltipGraphicalItemId, j as ActivePoints, jn as getNormalizedStackId, jt as selectTicksOfAxis, k as ChartDataContextProvider, kn as getCateCoordinateOfLine, kt as selectRenderableAxisSettings, l as ReportChartProps, ln as propsAreEqual, lr as svgPropertiesNoEventsFromUnknown, lt as combineAppliedValues, m as YAxis, mn as useChartHeight, mr as require_isArrayLike, mt as combineGraphicalItemsData, n as useRechartsAnimation, nn as getMaxRadius, nr as require_get$1, nt as ZIndexLayer, o as CategoricalChart, on as JavascriptAnimate, or as Surface, ot as mouseLeaveItem, p as updatePolarOptions, pn as useCartesianChartLayout, pr as require_keys, pt as combineDomainOfAllAppliedNumericalValuesIncludingErrorValues, q as LabelList, qn as isNan, qt as selectBarGap, r as useReducedMotion, rn as polarToCartesian, rr as withPath, rt as selectActiveTooltipDataKey, s as RechartsWrapper, sn as getTransitionVal, sr as svgPropertiesAndEvents, st as setActiveClickItemIndex, t as getColorScale, tn as Sector, tr as roundTemplateLiteral, tt as TooltipPortalContext, u as ReportMainChartProps, un as ReportChartMargin, ur as AppliedFilters, ut as combineAxisDomain, v as selectYAxisIdFromGraphicalItemId, vn as useViewBox, vr as require__Stack, vt as implicitXAxis, w as getTicks, wn as DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME, wr as LoadingIndicator, wt as selectBaseAxis, x as useNeedsClip, xn as useIsPanorama, xr as require_toString, xt as selectAxisPropsNeededForCartesianGridTicksGenerator, y as getRadiusAndStrokeWidthFromDot, yn as ResponsiveContainer, yr as require__MapCache, yt as itemAxisPredicate, z as RegisterGraphicalItemId, zn as useAppDispatch, zt as combineCheckedDomain } from "./chart-theme.CD7eAce3.chunk.js";
import { o as MobileBackButton } from "./TransactionEdit.D3b8cFIw.chunk.js";
//#region ../../node_modules/date-fns/differenceInDays.js
/**
* The {@link differenceInDays} function options.
*/
/**
* @name differenceInDays
* @category Day Helpers
* @summary Get the number of full days between the given dates.
*
* @description
* Get the number of full day periods between two dates. Fractional days are
* truncated towards zero.
*
* One "full day" is the distance between a local time in one day to the same
* local time on the next or previous day. A full day can sometimes be less than
* or more than 24 hours if a daylight savings change happens between two dates.
*
* To ignore DST and only measure exact 24-hour periods, use this instead:
* `Math.trunc(differenceInHours(dateLeft, dateRight)/24)|0`.
*
* @param laterDate - The later date
* @param earlierDate - The earlier date
* @param options - An object with options
*
* @returns The number of full days according to the local timezone
*
* @example
* // How many full days are between
* // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
* const result = differenceInDays(
*   new Date(2012, 6, 2, 0, 0),
*   new Date(2011, 6, 2, 23, 0)
* )
* //=> 365
*
* @example
* // How many full days are between
* // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
* const result = differenceInDays(
*   new Date(2011, 6, 3, 0, 1),
*   new Date(2011, 6, 2, 23, 59)
* )
* //=> 0
*
* @example
* // How many full days are between
* // 1 March 2020 0:00 and 1 June 2020 0:00 ?
* // Note: because local time is used, the
* // result will always be 92 days, even in
* // time zones where DST starts and the
* // period has only 92*24-1 hours.
* const result = differenceInDays(
*   new Date(2020, 5, 1),
*   new Date(2020, 2, 1)
* )
* //=> 92
*/
function differenceInDays(laterDate, earlierDate, options) {
	const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
	const sign = compareLocalAsc(laterDate_, earlierDate_);
	const difference = Math.abs(differenceInCalendarDays(laterDate_, earlierDate_));
	laterDate_.setDate(laterDate_.getDate() - sign * difference);
	const result = sign * (difference - Number(compareLocalAsc(laterDate_, earlierDate_) === -sign));
	return result === 0 ? 0 : result;
}
function compareLocalAsc(laterDate, earlierDate) {
	const diff = laterDate.getFullYear() - earlierDate.getFullYear() || laterDate.getMonth() - earlierDate.getMonth() || laterDate.getDate() - earlierDate.getDate() || laterDate.getHours() - earlierDate.getHours() || laterDate.getMinutes() - earlierDate.getMinutes() || laterDate.getSeconds() - earlierDate.getSeconds() || laterDate.getMilliseconds() - earlierDate.getMilliseconds();
	if (diff < 0) return -1;
	if (diff > 0) return 1;
	return diff;
}
//#endregion
//#region ../../node_modules/date-fns/getDate.js
/**
* The {@link getDate} function options.
*/
/**
* @name getDate
* @category Day Helpers
* @summary Get the day of the month of the given date.
*
* @description
* Get the day of the month of the given date.
*
* @param date - The given date
* @param options - An object with options.
*
* @returns The day of month
*
* @example
* // Which day of the month is 29 February 2012?
* const result = getDate(new Date(2012, 1, 29))
* //=> 29
*/
function getDate(date, options) {
	return toDate(date, options?.in).getDate();
}
//#endregion
//#region ../../node_modules/date-fns/getDaysInMonth.js
/**
* The {@link getDaysInMonth} function options.
*/
/**
* @name getDaysInMonth
* @category Month Helpers
* @summary Get the number of days in a month of the given date.
*
* @description
* Get the number of days in a month of the given date, considering the context if provided.
*
* @param date - The given date
* @param options - An object with options
*
* @returns The number of days in a month
*
* @example
* // How many days are in February 2000?
* const result = getDaysInMonth(new Date(2000, 1))
* //=> 29
*/
function getDaysInMonth(date, options) {
	const _date = toDate(date, options?.in);
	const year = _date.getFullYear();
	const monthIndex = _date.getMonth();
	const lastDayOfMonth = constructFrom(_date, 0);
	lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
	lastDayOfMonth.setHours(0, 0, 0, 0);
	return lastDayOfMonth.getDate();
}
//#endregion
//#region ../../node_modules/date-fns/isSameMonth.js
/**
* The {@link isSameMonth} function options.
*/
/**
* @name isSameMonth
* @category Month Helpers
* @summary Are the given dates in the same month (and year)?
*
* @description
* Are the given dates in the same month (and year)?
*
* @param laterDate - The first date to check
* @param earlierDate - The second date to check
* @param options - An object with options
*
* @returns The dates are in the same month (and year)
*
* @example
* // Are 2 September 2014 and 25 September 2014 in the same month?
* const result = isSameMonth(new Date(2014, 8, 2), new Date(2014, 8, 25))
* //=> true
*
* @example
* // Are 2 September 2014 and 25 September 2015 in the same month?
* const result = isSameMonth(new Date(2014, 8, 2), new Date(2015, 8, 25))
* //=> false
*/
function isSameMonth(laterDate, earlierDate, options) {
	const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
	return laterDate_.getFullYear() === earlierDate_.getFullYear() && laterDate_.getMonth() === earlierDate_.getMonth();
}
//#endregion
//#region ../../node_modules/d3-shape/src/math.js
var cos = Math.cos;
var sin = Math.sin;
var sqrt = Math.sqrt;
var pi = Math.PI;
pi / 2;
var tau = 2 * pi;
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/circle.js
var circle_default = { draw(context, size) {
	const r = sqrt(size / pi);
	context.moveTo(r, 0);
	context.arc(0, 0, r, 0, tau);
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/cross.js
var cross_default = { draw(context, size) {
	const r = sqrt(size / 5) / 2;
	context.moveTo(-3 * r, -r);
	context.lineTo(-r, -r);
	context.lineTo(-r, -3 * r);
	context.lineTo(r, -3 * r);
	context.lineTo(r, -r);
	context.lineTo(3 * r, -r);
	context.lineTo(3 * r, r);
	context.lineTo(r, r);
	context.lineTo(r, 3 * r);
	context.lineTo(-r, 3 * r);
	context.lineTo(-r, r);
	context.lineTo(-3 * r, r);
	context.closePath();
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/diamond.js
var tan30 = sqrt(1 / 3);
var tan30_2 = tan30 * 2;
var diamond_default = { draw(context, size) {
	const y = sqrt(size / tan30_2);
	const x = y * tan30;
	context.moveTo(0, -y);
	context.lineTo(x, 0);
	context.lineTo(0, y);
	context.lineTo(-x, 0);
	context.closePath();
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/square.js
var square_default = { draw(context, size) {
	const w = sqrt(size);
	const x = -w / 2;
	context.rect(x, x, w, w);
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/star.js
var ka = .8908130915292852;
var kr = sin(pi / 10) / sin(7 * pi / 10);
var kx = sin(tau / 10) * kr;
var ky = -cos(tau / 10) * kr;
var star_default = { draw(context, size) {
	const r = sqrt(size * ka);
	const x = kx * r;
	const y = ky * r;
	context.moveTo(0, -r);
	context.lineTo(x, y);
	for (let i = 1; i < 5; ++i) {
		const a = tau * i / 5;
		const c = cos(a);
		const s = sin(a);
		context.lineTo(s * r, -c * r);
		context.lineTo(c * x - s * y, s * x + c * y);
	}
	context.closePath();
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/triangle.js
var sqrt3 = sqrt(3);
var triangle_default = { draw(context, size) {
	const y = -sqrt(size / (sqrt3 * 3));
	context.moveTo(0, y * 2);
	context.lineTo(-sqrt3 * y, -y);
	context.lineTo(sqrt3 * y, -y);
	context.closePath();
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol/wye.js
var c = -.5;
var s = sqrt(3) / 2;
var k = 1 / sqrt(12);
var a = (k / 2 + 1) * 3;
var wye_default = { draw(context, size) {
	const r = sqrt(size / a);
	const x0 = r / 2, y0 = r * k;
	const x1 = x0, y1 = r * k + r;
	const x2 = -x1, y2 = y1;
	context.moveTo(x0, y0);
	context.lineTo(x1, y1);
	context.lineTo(x2, y2);
	context.lineTo(c * x0 - s * y0, s * x0 + c * y0);
	context.lineTo(c * x1 - s * y1, s * x1 + c * y1);
	context.lineTo(c * x2 - s * y2, s * x2 + c * y2);
	context.lineTo(c * x0 + s * y0, c * y0 - s * x0);
	context.lineTo(c * x1 + s * y1, c * y1 - s * x1);
	context.lineTo(c * x2 + s * y2, c * y2 - s * x2);
	context.closePath();
} };
//#endregion
//#region ../../node_modules/d3-shape/src/symbol.js
function Symbol$1(type, size) {
	let context = null, path = withPath(symbol);
	type = typeof type === "function" ? type : constant_default(type || circle_default);
	size = typeof size === "function" ? size : constant_default(size === void 0 ? 64 : +size);
	function symbol() {
		let buffer;
		if (!context) context = buffer = path();
		type.apply(this, arguments).draw(context, +size.apply(this, arguments));
		if (buffer) return context = null, buffer + "" || null;
	}
	symbol.type = function(_) {
		return arguments.length ? (type = typeof _ === "function" ? _ : constant_default(_), symbol) : type;
	};
	symbol.size = function(_) {
		return arguments.length ? (size = typeof _ === "function" ? _ : constant_default(+_), symbol) : size;
	};
	symbol.context = function(_) {
		return arguments.length ? (context = _ == null ? null : _, symbol) : context;
	};
	return symbol;
}
//#endregion
//#region ../../node_modules/recharts/es6/shape/Symbols.js
var import_react = /* @__PURE__ */ __toESM(require_react());
var _excluded$10 = [
	"type",
	"size",
	"sizeType"
];
function _extends$11() {
	return _extends$11 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$11.apply(null, arguments);
}
function ownKeys$13(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$13(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$13(Object(t), !0).forEach(function(r) {
			_defineProperty$13(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$13(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$13(e, r, t) {
	return (r = _toPropertyKey$13(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$13(t) {
	var i = _toPrimitive$13(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$13(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties$10(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$10(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$10(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
var symbolFactories = {
	symbolCircle: circle_default,
	symbolCross: cross_default,
	symbolDiamond: diamond_default,
	symbolSquare: square_default,
	symbolStar: star_default,
	symbolTriangle: triangle_default,
	symbolWye: wye_default
};
var RADIAN$1 = Math.PI / 180;
var getSymbolFactory = (type) => {
	return symbolFactories["symbol".concat(upperFirst(type))] || circle_default;
};
var calculateAreaSize = (size, sizeType, type) => {
	if (sizeType === "area") return size;
	switch (type) {
		case "cross": return 5 * size * size / 9;
		case "diamond": return .5 * size * size / Math.sqrt(3);
		case "square": return size * size;
		case "star":
			var angle = 18 * RADIAN$1;
			return 1.25 * size * size * (Math.tan(angle) - Math.tan(angle * 2) * Math.tan(angle) ** 2);
		case "triangle": return Math.sqrt(3) * size * size / 4;
		case "wye": return (21 - 10 * Math.sqrt(3)) * size * size / 8;
		default: return Math.PI * size * size / 4;
	}
};
var registerSymbol = (key, factory) => {
	symbolFactories["symbol".concat(upperFirst(key))] = factory;
};
/**
* Renders a symbol from a set of predefined shapes.
*/
var Symbols = (_ref) => {
	var { type = "circle", size = 64, sizeType = "area" } = _ref;
	var props = _objectSpread$13(_objectSpread$13({}, _objectWithoutProperties$10(_ref, _excluded$10)), {}, {
		type,
		size,
		sizeType
	});
	var realType = "circle";
	if (typeof type === "string") realType = type;
	/**
	* Calculate the path of curve
	* @return {String} path
	*/
	var getPath = () => {
		var symbolFactory = getSymbolFactory(realType);
		var s = Symbol$1().type(symbolFactory).size(calculateAreaSize(size, sizeType, realType))();
		if (s === null) return;
		return s;
	};
	var { className, cx, cy } = props;
	var filteredProps = svgPropertiesAndEvents(props);
	if (isNumber(cx) && isNumber(cy) && isNumber(size)) return /* @__PURE__ */ import_react.createElement("path", _extends$11({}, filteredProps, {
		className: clsx("recharts-symbols", className),
		transform: "translate(".concat(cx, ", ").concat(cy, ")"),
		d: getPath()
	}));
	return null;
};
Symbols.registerSymbol = registerSymbol;
//#endregion
//#region ../../node_modules/recharts/es6/component/Cell.js
/**
* Cell component used to define colors and styles of chart elements.
*
* This component is now deprecated and will be removed in Recharts 4.0.
*
* Please use the `shape` prop or `content` prop on the respective chart components
* to customize the rendering of chart elements instead of using `Cell`.
*
* @see {@link https://recharts.github.io/en-US/guide/cell/ Guide: Migrate from Cell component to shape prop}
*
* @deprecated
* @consumes CellReader
*/
var Cell = (_props) => null;
Cell.displayName = "Cell";
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/polarSelectors.js
var selectUnfilteredPolarItems = (state) => state.graphicalItems.polarItems;
var selectPolarItemsSettings = createSelector([
	selectUnfilteredPolarItems,
	selectBaseAxis,
	createSelector([pickAxisType, pickAxisId], itemAxisPredicate)
], combineGraphicalItemsSettings);
var selectPolarDisplayedData = createSelector([createSelector([selectPolarItemsSettings], combineGraphicalItemsData), selectChartDataAndAlwaysIgnoreIndexes], combineDisplayedData);
var selectPolarAppliedValues = createSelector([
	selectPolarDisplayedData,
	selectBaseAxis,
	selectPolarItemsSettings
], combineAppliedValues);
createSelector([
	selectPolarDisplayedData,
	selectBaseAxis,
	selectPolarItemsSettings
], (data, axisSettings, items) => {
	if (items.length > 0) return data.flatMap((entry) => {
		return items.flatMap((item) => {
			var _axisSettings$dataKey;
			return {
				value: getValueByDataKey(entry, (_axisSettings$dataKey = axisSettings.dataKey) !== null && _axisSettings$dataKey !== void 0 ? _axisSettings$dataKey : item.dataKey),
				errorDomain: []
			};
		});
	}).filter(Boolean);
	if ((axisSettings === null || axisSettings === void 0 ? void 0 : axisSettings.dataKey) != null) return data.map((item) => ({
		value: getValueByDataKey(item, axisSettings.dataKey),
		errorDomain: []
	}));
	return data.map((entry) => ({
		value: entry,
		errorDomain: []
	}));
});
var unsupportedInPolarChart = () => void 0;
var selectPolarAxisDomain = createSelector([
	selectBaseAxis,
	selectChartLayout,
	selectPolarDisplayedData,
	selectPolarAppliedValues,
	selectStackOffsetType,
	pickAxisType,
	createSelector([
		selectBaseAxis,
		selectDomainDefinition,
		selectDomainFromUserPreference,
		unsupportedInPolarChart,
		createSelector([
			selectPolarDisplayedData,
			selectBaseAxis,
			selectPolarItemsSettings,
			selectAllErrorBarSettings,
			pickAxisType,
			selectChartDataSliceIgnoringIndexes
		], combineDomainOfAllAppliedNumericalValuesIncludingErrorValues),
		unsupportedInPolarChart,
		selectChartLayout,
		pickAxisType
	], combineNumericalDomain)
], combineAxisDomain);
createSelector([selectRealScaleType, createSelector([
	selectBaseAxis,
	selectPolarAxisDomain,
	createSelector([
		selectPolarAxisDomain,
		selectRenderableAxisSettings,
		selectRealScaleType
	], combineNiceTicks),
	pickAxisType
], combineAxisDomainWithNiceTicks)], combineCheckedDomain);
//#endregion
//#region ../../node_modules/es-toolkit/dist/array/maxBy.js
var require_maxBy$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
	function maxBy(items, getValue) {
		if (items.length === 0) return;
		let maxElement = items[0];
		let max = getValue(maxElement);
		for (let i = 1; i < items.length; i++) {
			const element = items[i];
			const value = getValue(element);
			if (value > max) {
				max = value;
				maxElement = element;
			}
		}
		return maxElement;
	}
	exports.maxBy = maxBy;
}));
//#endregion
//#region ../../node_modules/es-toolkit/dist/compat/math/maxBy.js
var require_maxBy$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
	var maxBy$1 = require_maxBy$2();
	var identity = require_identity$1();
	var iteratee = require_iteratee();
	function maxBy(items, iteratee$1) {
		if (items == null) return;
		return maxBy$1.maxBy(Array.from(items), iteratee.iteratee(iteratee$1 ?? identity.identity));
	}
	exports.maxBy = maxBy;
}));
//#endregion
//#region ../../node_modules/es-toolkit/compat/maxBy.js
var require_maxBy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	module.exports = require_maxBy$1().maxBy;
}));
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/pieSelectors.js
function ownKeys$12(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$12(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$12(Object(t), !0).forEach(function(r) {
			_defineProperty$12(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$12(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$12(e, r, t) {
	return (r = _toPropertyKey$12(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$12(t) {
	var i = _toPrimitive$12(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$12(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
var pickId = (_state, id) => id;
var selectSynchronisedPieSettings = createSelector([selectUnfilteredPolarItems, pickId], (graphicalItems, id) => graphicalItems.filter((item) => item.type === "pie").find((item) => item.id === id));
var emptyArray = [];
var pickCells$1 = (_state, _id, cells) => {
	if ((cells === null || cells === void 0 ? void 0 : cells.length) === 0) return emptyArray;
	return cells;
};
var selectDisplayedData = createSelector([
	selectChartDataAndAlwaysIgnoreIndexes,
	selectSynchronisedPieSettings,
	pickCells$1
], (_ref, pieSettings, cells) => {
	var { chartData } = _ref;
	if (pieSettings == null) return;
	var displayedData;
	if ((pieSettings === null || pieSettings === void 0 ? void 0 : pieSettings.data) != null && pieSettings.data.length > 0) displayedData = pieSettings.data;
	else displayedData = chartData;
	if ((!displayedData || !displayedData.length) && cells != null) displayedData = cells.map((cell) => _objectSpread$12(_objectSpread$12({}, pieSettings.presentationProps), cell.props));
	if (displayedData == null) return;
	return displayedData;
});
var selectPieLegend = createSelector([
	selectDisplayedData,
	selectSynchronisedPieSettings,
	pickCells$1
], (displayedData, pieSettings, cells) => {
	if (displayedData == null || pieSettings == null) return;
	return displayedData.map((entry, i) => {
		var _cells$i;
		var name = getValueByDataKey(entry, pieSettings.nameKey, pieSettings.name);
		var color;
		if (cells !== null && cells !== void 0 && (_cells$i = cells[i]) !== null && _cells$i !== void 0 && (_cells$i = _cells$i.props) !== null && _cells$i !== void 0 && _cells$i.fill) color = cells[i].props.fill;
		else if (typeof entry === "object" && entry != null && "fill" in entry) color = entry.fill;
		else color = pieSettings.fill;
		return {
			value: getTooltipNameProp(name, pieSettings.dataKey),
			color,
			payload: entry,
			type: pieSettings.legendType
		};
	});
});
var selectPieSectors = createSelector([
	selectDisplayedData,
	selectSynchronisedPieSettings,
	pickCells$1,
	selectChartOffsetInternal
], (displayedData, pieSettings, cells, offset) => {
	if (pieSettings == null || displayedData == null) return;
	return computePieSectors({
		offset,
		pieSettings,
		displayedData,
		cells
	});
});
//#endregion
//#region ../../node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js
var require_isPlainObject$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
	function isPlainObject(object) {
		if (typeof object !== "object") return false;
		if (object == null) return false;
		if (Object.getPrototypeOf(object) === null) return true;
		if (Object.prototype.toString.call(object) !== "[object Object]") {
			const tag = object[Symbol.toStringTag];
			if (tag == null) return false;
			if (!Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable) return false;
			return object.toString() === `[object ${tag}]`;
		}
		let proto = object;
		while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
		return Object.getPrototypeOf(object) === proto;
	}
	exports.isPlainObject = isPlainObject;
}));
//#endregion
//#region ../../node_modules/es-toolkit/compat/isPlainObject.js
var require_isPlainObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	module.exports = require_isPlainObject$1().isPlainObject;
}));
//#endregion
//#region ../../node_modules/recharts/es6/shape/Trapezoid.js
/**
* @fileOverview Rectangle
*/
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
function ownKeys$11(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$11(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$11(Object(t), !0).forEach(function(r) {
			_defineProperty$11(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$11(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$11(e, r, t) {
	return (r = _toPropertyKey$11(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$11(t) {
	var i = _toPrimitive$11(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$11(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _extends$10() {
	return _extends$10 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$10.apply(null, arguments);
}
function _taggedTemplateLiteral(e, t) {
	return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
}
var getTrapezoidPath = (x, y, upperWidth, lowerWidth, height) => {
	var widthGap = upperWidth - lowerWidth;
	var path = roundTemplateLiteral(_templateObject || (_templateObject = _taggedTemplateLiteral([
		"M ",
		",",
		""
	])), x, y);
	path += roundTemplateLiteral(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral([
		"L ",
		",",
		""
	])), x + upperWidth, y);
	path += roundTemplateLiteral(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([
		"L ",
		",",
		""
	])), x + upperWidth - widthGap / 2, y + height);
	path += roundTemplateLiteral(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral([
		"L ",
		",",
		""
	])), x + upperWidth - widthGap / 2 - lowerWidth, y + height);
	path += roundTemplateLiteral(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral([
		"L ",
		",",
		" Z"
	])), x, y);
	return path;
};
var defaultTrapezoidProps = {
	x: 0,
	y: 0,
	upperWidth: 0,
	lowerWidth: 0,
	height: 0,
	isUpdateAnimationActive: false,
	animationBegin: 0,
	animationDuration: 1500,
	animationEasing: "ease"
};
var Trapezoid = (outsideProps) => {
	var trapezoidProps = resolveDefaultProps(outsideProps, defaultTrapezoidProps);
	var { x, y, upperWidth, lowerWidth, height, className } = trapezoidProps;
	var { animationEasing, animationDuration, animationBegin, isUpdateAnimationActive } = trapezoidProps;
	var pathRef = (0, import_react.useRef)(null);
	var [totalLength, setTotalLength] = (0, import_react.useState)(-1);
	var prevUpperWidthRef = (0, import_react.useRef)(upperWidth);
	var prevLowerWidthRef = (0, import_react.useRef)(lowerWidth);
	var prevHeightRef = (0, import_react.useRef)(height);
	var prevXRef = (0, import_react.useRef)(x);
	var prevYRef = (0, import_react.useRef)(y);
	var animationId = useAnimationId(outsideProps, "trapezoid-");
	(0, import_react.useEffect)(() => {
		if (pathRef.current && pathRef.current.getTotalLength) try {
			var pathTotalLength = pathRef.current.getTotalLength();
			if (pathTotalLength) setTotalLength(pathTotalLength);
		} catch (_unused) {}
	}, []);
	if (x !== +x || y !== +y || upperWidth !== +upperWidth || lowerWidth !== +lowerWidth || height !== +height || upperWidth === 0 && lowerWidth === 0 || height === 0) return null;
	var layerClass = clsx("recharts-trapezoid", className);
	if (!isUpdateAnimationActive) return /* @__PURE__ */ import_react.createElement("g", null, /* @__PURE__ */ import_react.createElement("path", _extends$10({}, svgPropertiesAndEvents(trapezoidProps), {
		className: layerClass,
		d: getTrapezoidPath(x, y, upperWidth, lowerWidth, height)
	})));
	var prevUpperWidth = prevUpperWidthRef.current;
	var prevLowerWidth = prevLowerWidthRef.current;
	var prevHeight = prevHeightRef.current;
	var prevX = prevXRef.current;
	var prevY = prevYRef.current;
	var from = "0px ".concat(totalLength === -1 ? 1 : totalLength, "px");
	var to = "".concat(totalLength, "px ").concat(totalLength, "px");
	var transition = getTransitionVal(["strokeDasharray"], animationDuration, animationEasing);
	return /* @__PURE__ */ import_react.createElement(JavascriptAnimate, {
		animationId,
		key: animationId,
		canBegin: totalLength > 0,
		duration: animationDuration,
		easing: animationEasing,
		isActive: isUpdateAnimationActive,
		begin: animationBegin
	}, (t) => {
		var currUpperWidth = interpolate(prevUpperWidth, upperWidth, t);
		var currLowerWidth = interpolate(prevLowerWidth, lowerWidth, t);
		var currHeight = interpolate(prevHeight, height, t);
		var currX = interpolate(prevX, x, t);
		var currY = interpolate(prevY, y, t);
		if (pathRef.current) {
			prevUpperWidthRef.current = currUpperWidth;
			prevLowerWidthRef.current = currLowerWidth;
			prevHeightRef.current = currHeight;
			prevXRef.current = currX;
			prevYRef.current = currY;
		}
		var animationStyle = t > 0 ? {
			transition,
			strokeDasharray: to
		} : { strokeDasharray: from };
		return /* @__PURE__ */ import_react.createElement("path", _extends$10({}, svgPropertiesAndEvents(trapezoidProps), {
			className: layerClass,
			d: getTrapezoidPath(currX, currY, currUpperWidth, currLowerWidth, currHeight),
			ref: pathRef,
			style: _objectSpread$11(_objectSpread$11({}, animationStyle), trapezoidProps.style)
		}));
	});
};
//#endregion
//#region ../../node_modules/recharts/es6/util/ActiveShapeUtils.js
var import_isPlainObject = /* @__PURE__ */ __toESM(require_isPlainObject());
var _excluded$9 = [
	"option",
	"shapeType",
	"activeClassName",
	"inActiveClassName"
];
function _objectWithoutProperties$9(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$9(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$9(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function ownKeys$10(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$10(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$10(Object(t), !0).forEach(function(r) {
			_defineProperty$10(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$10(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$10(e, r, t) {
	return (r = _toPropertyKey$10(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$10(t) {
	var i = _toPrimitive$10(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$10(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
/**
* This is an abstraction for rendering a user defined prop for a customized shape in several forms.
*
* <Shape /> is the root and will handle taking in:
*  - an object of svg properties
*  - a boolean
*  - a render prop(inline function that returns jsx)
*  - a React element
*
* <ShapeSelector /> is a subcomponent of <Shape /> and used to match a component
* to the value of props.shapeType that is passed to the root.
*
*/
function defaultPropTransformer(option, props) {
	return _objectSpread$10(_objectSpread$10({}, props), option);
}
function isSymbolsProps(shapeType, _elementProps) {
	return shapeType === "symbols";
}
function ShapeSelector(_ref) {
	var { shapeType, elementProps } = _ref;
	switch (shapeType) {
		case "rectangle": return /* @__PURE__ */ import_react.createElement(Rectangle, elementProps);
		case "trapezoid": return /* @__PURE__ */ import_react.createElement(Trapezoid, elementProps);
		case "sector": return /* @__PURE__ */ import_react.createElement(Sector, elementProps);
		case "symbols":
			if (isSymbolsProps(shapeType, elementProps)) return /* @__PURE__ */ import_react.createElement(Symbols, elementProps);
			break;
		case "curve": return /* @__PURE__ */ import_react.createElement(Curve, elementProps);
		default: return null;
	}
}
function getPropsFromShapeOption(option) {
	if (/* @__PURE__ */ (0, import_react.isValidElement)(option)) return option.props;
	return option;
}
function Shape(_ref2) {
	var { option, shapeType, activeClassName = "recharts-active-shape", inActiveClassName = "recharts-shape" } = _ref2, props = _objectWithoutProperties$9(_ref2, _excluded$9);
	var shape;
	if (/* @__PURE__ */ (0, import_react.isValidElement)(option)) shape = /* @__PURE__ */ (0, import_react.cloneElement)(option, _objectSpread$10(_objectSpread$10({}, props), getPropsFromShapeOption(option)));
	else if (typeof option === "function") shape = option(props, props.index);
	else if ((0, import_isPlainObject.default)(option) && typeof option !== "boolean") {
		var nextProps = defaultPropTransformer(option, props);
		shape = /* @__PURE__ */ import_react.createElement(ShapeSelector, {
			shapeType,
			elementProps: nextProps
		});
	} else {
		var elementProps = props;
		shape = /* @__PURE__ */ import_react.createElement(ShapeSelector, {
			shapeType,
			elementProps
		});
	}
	if (props.isActive) return /* @__PURE__ */ import_react.createElement(Layer, { className: activeClassName }, shape);
	return /* @__PURE__ */ import_react.createElement(Layer, { className: inActiveClassName }, shape);
}
//#endregion
//#region ../../node_modules/recharts/es6/context/tooltipContext.js
/**
* Some graphical items choose to provide more information to the tooltip
* and some do not.
*/
var useMouseEnterItemDispatch = (onMouseEnterFromProps, dataKey, graphicalItemId) => {
	var dispatch = useAppDispatch();
	return (data, index) => (event) => {
		onMouseEnterFromProps === null || onMouseEnterFromProps === void 0 || onMouseEnterFromProps(data, index, event);
		dispatch(setActiveMouseOverItemIndex({
			activeIndex: String(index),
			activeDataKey: dataKey,
			activeCoordinate: data.tooltipPosition,
			activeGraphicalItemId: graphicalItemId
		}));
	};
};
var useMouseLeaveItemDispatch = (onMouseLeaveFromProps) => {
	var dispatch = useAppDispatch();
	return (data, index) => (event) => {
		onMouseLeaveFromProps === null || onMouseLeaveFromProps === void 0 || onMouseLeaveFromProps(data, index, event);
		dispatch(mouseLeaveItem());
	};
};
var useMouseClickItemDispatch = (onMouseClickFromProps, dataKey, graphicalItemId) => {
	var dispatch = useAppDispatch();
	return (data, index) => (event) => {
		onMouseClickFromProps === null || onMouseClickFromProps === void 0 || onMouseClickFromProps(data, index, event);
		dispatch(setActiveClickItemIndex({
			activeIndex: String(index),
			activeDataKey: dataKey,
			activeCoordinate: data.tooltipPosition,
			activeGraphicalItemId: graphicalItemId
		}));
	};
};
//#endregion
//#region ../../node_modules/recharts/es6/polar/Pie.js
var import_get = /* @__PURE__ */ __toESM(require_get$1());
var _excluded$8 = ["key"], _excluded2$5 = [
	"onMouseEnter",
	"onClick",
	"onMouseLeave"
], _excluded3$4 = ["id"], _excluded4$2 = ["id"];
function _extends$9() {
	return _extends$9 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$9.apply(null, arguments);
}
function _objectWithoutProperties$8(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$8(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$8(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function ownKeys$9(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$9(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$9(Object(t), !0).forEach(function(r) {
			_defineProperty$9(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$9(e, r, t) {
	return (r = _toPropertyKey$9(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$9(t) {
	var i = _toPrimitive$9(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$9(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
/**
* The `label` prop in Pie accepts a variety of alternatives.
*/
/**
* We spread the data object into the sector data item,
* so we can't really know what is going to be inside.
*
* This type represents our best effort, but it all depends on the input data
* and what is inside of it.
*
* https://github.com/recharts/recharts/issues/6380
* https://github.com/recharts/recharts/discussions/6375
*/
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
function SetPiePayloadLegend(props) {
	var cells = (0, import_react.useMemo)(() => findAllByType(props.children, Cell), [props.children]);
	var legendPayload = useAppSelector((state) => selectPieLegend(state, props.id, cells));
	if (legendPayload == null) return null;
	return /* @__PURE__ */ import_react.createElement(SetPolarLegendPayload, { legendPayload });
}
function getActiveShapeFill(activeShape) {
	if (activeShape == null || typeof activeShape === "boolean" || typeof activeShape === "function") return;
	if (/* @__PURE__ */ import_react.isValidElement(activeShape)) {
		var _activeShape$props;
		var _fill = (_activeShape$props = activeShape.props) === null || _activeShape$props === void 0 ? void 0 : _activeShape$props.fill;
		return typeof _fill === "string" ? _fill : void 0;
	}
	var { fill } = activeShape;
	return typeof fill === "string" ? fill : void 0;
}
var SetPieTooltipEntrySettings = /* @__PURE__ */ import_react.memo((_ref) => {
	var { dataKey, nameKey, sectors, stroke, strokeWidth, fill, name, hide, tooltipType, id, activeShape } = _ref;
	var activeShapeFill = getActiveShapeFill(activeShape);
	var tooltipEntrySettings = {
		dataDefinedOnItem: sectors.map((sector) => {
			var sectorTooltipPayload = sector.tooltipPayload;
			if (activeShapeFill == null || sectorTooltipPayload == null) return sectorTooltipPayload;
			return sectorTooltipPayload.map((item) => _objectSpread$9(_objectSpread$9({}, item), {}, {
				color: activeShapeFill,
				fill: activeShapeFill
			}));
		}),
		getPosition: (index) => {
			var _sectors$Number;
			return (_sectors$Number = sectors[Number(index)]) === null || _sectors$Number === void 0 ? void 0 : _sectors$Number.tooltipPosition;
		},
		settings: {
			stroke,
			strokeWidth,
			fill,
			dataKey,
			nameKey,
			name: getTooltipNameProp(name, dataKey),
			hide,
			type: tooltipType,
			color: fill,
			unit: "",
			graphicalItemId: id
		}
	};
	return /* @__PURE__ */ import_react.createElement(SetTooltipEntrySettings, { tooltipEntrySettings });
});
var getTextAnchor = (x, cx) => {
	if (x > cx) return "start";
	if (x < cx) return "end";
	return "middle";
};
var getOuterRadius = (dataPoint, outerRadius, maxPieRadius) => {
	if (typeof outerRadius === "function") return getPercentValue(outerRadius(dataPoint), maxPieRadius, maxPieRadius * .8);
	return getPercentValue(outerRadius, maxPieRadius, maxPieRadius * .8);
};
var parseCoordinateOfPie = (pieSettings, offset, dataPoint) => {
	var { top, left, width, height } = offset;
	var maxPieRadius = getMaxRadius(width, height);
	return {
		cx: left + getPercentValue(pieSettings.cx, width, width / 2),
		cy: top + getPercentValue(pieSettings.cy, height, height / 2),
		innerRadius: getPercentValue(pieSettings.innerRadius, maxPieRadius, 0),
		outerRadius: getOuterRadius(dataPoint, pieSettings.outerRadius, maxPieRadius),
		maxRadius: pieSettings.maxRadius || Math.sqrt(width * width + height * height) / 2
	};
};
var parseDeltaAngle = (startAngle, endAngle) => {
	return mathSign(endAngle - startAngle) * Math.min(Math.abs(endAngle - startAngle), 360);
};
var renderLabelLineItem = (option, props) => {
	if (/* @__PURE__ */ import_react.isValidElement(option)) return /* @__PURE__ */ import_react.cloneElement(option, props);
	if (typeof option === "function") return option(props);
	var className = clsx("recharts-pie-label-line", typeof option !== "boolean" ? option.className : "");
	var { key } = props, otherProps = _objectWithoutProperties$8(props, _excluded$8);
	return /* @__PURE__ */ import_react.createElement(Curve, _extends$9({}, otherProps, {
		type: "linear",
		className
	}));
};
var renderLabelItem = (option, props, value) => {
	if (/* @__PURE__ */ import_react.isValidElement(option)) return /* @__PURE__ */ import_react.cloneElement(option, props);
	var label = value;
	if (typeof option === "function") {
		label = option(props);
		if (/* @__PURE__ */ import_react.isValidElement(label)) return label;
	}
	var className = clsx("recharts-pie-label-text", getClassNameFromUnknown(option));
	return /* @__PURE__ */ import_react.createElement(Text$1, _extends$9({}, props, {
		alignmentBaseline: "middle",
		className
	}), label);
};
function PieLabels(_ref2) {
	var { sectors, props, showLabels } = _ref2;
	var { label, labelLine, dataKey } = props;
	if (!showLabels || !label || !sectors) return null;
	var pieProps = svgPropertiesNoEvents(props);
	var customLabelProps = svgPropertiesNoEventsFromUnknown(label);
	var customLabelLineProps = svgPropertiesNoEventsFromUnknown(labelLine);
	var offsetRadius = typeof label === "object" && "offsetRadius" in label && typeof label.offsetRadius === "number" && label.offsetRadius || 20;
	var labels = sectors.map((entry, i) => {
		var midAngle = (entry.startAngle + entry.endAngle) / 2;
		var endPoint = polarToCartesian(entry.cx, entry.cy, entry.outerRadius + offsetRadius, midAngle);
		var labelProps = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, pieProps), entry), {}, { stroke: "none" }, customLabelProps), {}, {
			index: i,
			textAnchor: getTextAnchor(endPoint.x, entry.cx)
		}, endPoint);
		var lineProps = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, pieProps), entry), {}, {
			fill: "none",
			stroke: entry.fill
		}, customLabelLineProps), {}, {
			index: i,
			points: [polarToCartesian(entry.cx, entry.cy, entry.outerRadius, midAngle), endPoint],
			key: "line"
		});
		return /* @__PURE__ */ import_react.createElement(ZIndexLayer, {
			zIndex: DefaultZIndexes.label,
			key: "label-".concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
		}, /* @__PURE__ */ import_react.createElement(Layer, null, labelLine && renderLabelLineItem(labelLine, lineProps), renderLabelItem(label, labelProps, getValueByDataKey(entry, dataKey))));
	});
	return /* @__PURE__ */ import_react.createElement(Layer, { className: "recharts-pie-labels" }, labels);
}
function PieLabelList(_ref3) {
	var { sectors, props, showLabels } = _ref3;
	var { label } = props;
	if (typeof label === "object" && label != null && "position" in label) return /* @__PURE__ */ import_react.createElement(LabelListFromLabelProp, { label });
	return /* @__PURE__ */ import_react.createElement(PieLabels, {
		sectors,
		props,
		showLabels
	});
}
function PieSectors(props) {
	var { sectors, activeShape, inactiveShape: inactiveShapeProp, allOtherPieProps, shape, id } = props;
	var activeIndex = useAppSelector(selectActiveTooltipIndex);
	var activeDataKey = useAppSelector(selectActiveTooltipDataKey);
	var activeGraphicalItemId = useAppSelector(selectActiveTooltipGraphicalItemId);
	var { onMouseEnter: onMouseEnterFromProps, onClick: onItemClickFromProps, onMouseLeave: onMouseLeaveFromProps } = allOtherPieProps, restOfAllOtherProps = _objectWithoutProperties$8(allOtherPieProps, _excluded2$5);
	var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherPieProps.dataKey, id);
	var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
	var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherPieProps.dataKey, id);
	if (sectors == null || sectors.length === 0) return null;
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, sectors.map((entry, i) => {
		if ((entry === null || entry === void 0 ? void 0 : entry.startAngle) === 0 && (entry === null || entry === void 0 ? void 0 : entry.endAngle) === 0 && sectors.length !== 1) return null;
		var graphicalItemMatches = activeGraphicalItemId == null || activeGraphicalItemId === id;
		var isActive = String(i) === activeIndex && (activeDataKey == null || allOtherPieProps.dataKey === activeDataKey) && graphicalItemMatches;
		var sectorOptions = activeShape && isActive ? activeShape : activeIndex ? inactiveShapeProp : null;
		var sectorProps = _objectSpread$9(_objectSpread$9({}, entry), {}, {
			stroke: entry.stroke,
			tabIndex: -1,
			[DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
			[DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: id
		});
		return /* @__PURE__ */ import_react.createElement(Layer, _extends$9({
			key: "sector-".concat(entry === null || entry === void 0 ? void 0 : entry.startAngle, "-").concat(entry === null || entry === void 0 ? void 0 : entry.endAngle, "-").concat(entry.midAngle, "-").concat(i),
			tabIndex: -1,
			className: "recharts-pie-sector"
		}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
			onMouseEnter: onMouseEnterFromContext(entry, i),
			onMouseLeave: onMouseLeaveFromContext(entry, i),
			onClick: onClickFromContext(entry, i)
		}), /* @__PURE__ */ import_react.createElement(Shape, _extends$9({
			option: shape !== null && shape !== void 0 ? shape : sectorOptions,
			index: i,
			shapeType: "sector",
			isActive
		}, sectorProps)));
	}));
}
function computePieSectors(_ref4) {
	var _pieSettings$paddingA;
	var { pieSettings, displayedData, cells, offset } = _ref4;
	var { cornerRadius, startAngle, endAngle, dataKey, nameKey, tooltipType } = pieSettings;
	var minAngle = Math.abs(pieSettings.minAngle);
	var deltaAngle = parseDeltaAngle(startAngle, endAngle);
	var absDeltaAngle = Math.abs(deltaAngle);
	var paddingAngle = displayedData.length <= 1 ? 0 : (_pieSettings$paddingA = pieSettings.paddingAngle) !== null && _pieSettings$paddingA !== void 0 ? _pieSettings$paddingA : 0;
	var notZeroItemCount = displayedData.filter((entry) => getValueByDataKey(entry, dataKey, 0) !== 0).length;
	var totalPaddingAngle = (absDeltaAngle >= 360 ? notZeroItemCount : notZeroItemCount - 1) * paddingAngle;
	var sum = displayedData.reduce((result, entry) => {
		var val = getValueByDataKey(entry, dataKey, 0);
		return result + (isNumber(val) ? val : 0);
	}, 0);
	var effectiveMinAngle = minAngle > 0 && sum > 0 && displayedData.some((entry) => {
		var val = getValueByDataKey(entry, dataKey, 0);
		var percent = (isNumber(val) ? val : 0) / sum;
		return val !== 0 && percent * absDeltaAngle < minAngle;
	}) ? minAngle : 0;
	var realTotalAngle = absDeltaAngle - notZeroItemCount * effectiveMinAngle - totalPaddingAngle;
	var sectors;
	if (sum > 0) {
		var prev;
		sectors = displayedData.map((entry, i) => {
			var val = getValueByDataKey(entry, dataKey, 0);
			var name = getValueByDataKey(entry, nameKey, i);
			var coordinate = parseCoordinateOfPie(pieSettings, offset, entry);
			var percent = (isNumber(val) ? val : 0) / sum;
			var tempStartAngle;
			var entryWithCellInfo = _objectSpread$9(_objectSpread$9({}, entry), cells && cells[i] && cells[i].props);
			var sectorColor = entryWithCellInfo != null && "fill" in entryWithCellInfo && typeof entryWithCellInfo.fill === "string" ? entryWithCellInfo.fill : pieSettings.fill;
			if (i) tempStartAngle = prev.endAngle + mathSign(deltaAngle) * paddingAngle * (val !== 0 ? 1 : 0);
			else tempStartAngle = startAngle;
			var tempEndAngle = tempStartAngle + mathSign(deltaAngle) * ((val !== 0 ? effectiveMinAngle : 0) + percent * realTotalAngle);
			var midAngle = (tempStartAngle + tempEndAngle) / 2;
			var middleRadius = (coordinate.innerRadius + coordinate.outerRadius) / 2;
			var tooltipPayload = [{
				name,
				value: val,
				payload: entryWithCellInfo,
				dataKey,
				type: tooltipType,
				color: sectorColor,
				fill: sectorColor,
				graphicalItemId: pieSettings.id
			}];
			var tooltipPosition = polarToCartesian(coordinate.cx, coordinate.cy, middleRadius, midAngle);
			prev = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, pieSettings.presentationProps), {}, {
				percent,
				cornerRadius: typeof cornerRadius === "string" ? parseFloat(cornerRadius) : cornerRadius,
				name,
				tooltipPayload,
				midAngle,
				middleRadius,
				tooltipPosition
			}, entryWithCellInfo), coordinate), {}, {
				value: val,
				dataKey,
				startAngle: tempStartAngle,
				endAngle: tempEndAngle,
				payload: entryWithCellInfo,
				paddingAngle: val !== 0 ? mathSign(deltaAngle) * paddingAngle : 0
			});
			return prev;
		});
	}
	return sectors;
}
function PieLabelListProvider(_ref5) {
	var { showLabels, sectors, children } = _ref5;
	var labelListEntries = (0, import_react.useMemo)(() => {
		if (!showLabels || !sectors) return [];
		return sectors.map((entry) => ({
			value: entry.value,
			payload: entry.payload,
			clockWise: false,
			parentViewBox: void 0,
			viewBox: {
				cx: entry.cx,
				cy: entry.cy,
				innerRadius: entry.innerRadius,
				outerRadius: entry.outerRadius,
				startAngle: entry.startAngle,
				endAngle: entry.endAngle,
				clockWise: false
			},
			fill: entry.fill
		}));
	}, [sectors, showLabels]);
	return /* @__PURE__ */ import_react.createElement(PolarLabelListContextProvider, { value: showLabels ? labelListEntries : void 0 }, children);
}
function SectorsWithAnimation(_ref6) {
	var { props, previousSectorsRef, id } = _ref6;
	var { sectors, isAnimationActive, animationBegin, animationDuration, animationEasing, activeShape, inactiveShape, onAnimationStart, onAnimationEnd } = props;
	var animationId = useAnimationId(props, "recharts-pie-");
	var prevSectors = previousSectorsRef.current;
	var [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
	var handleAnimationEnd = (0, import_react.useCallback)(() => {
		if (typeof onAnimationEnd === "function") onAnimationEnd();
		setIsAnimating(false);
	}, [onAnimationEnd]);
	var handleAnimationStart = (0, import_react.useCallback)(() => {
		if (typeof onAnimationStart === "function") onAnimationStart();
		setIsAnimating(true);
	}, [onAnimationStart]);
	return /* @__PURE__ */ import_react.createElement(PieLabelListProvider, {
		showLabels: !isAnimating,
		sectors
	}, /* @__PURE__ */ import_react.createElement(JavascriptAnimate, {
		animationId,
		begin: animationBegin,
		duration: animationDuration,
		isActive: isAnimationActive,
		easing: animationEasing,
		onAnimationStart: handleAnimationStart,
		onAnimationEnd: handleAnimationEnd,
		key: animationId
	}, (t) => {
		var _first$startAngle;
		var stepData = [];
		var first = sectors && sectors[0];
		var curAngle = (_first$startAngle = first === null || first === void 0 ? void 0 : first.startAngle) !== null && _first$startAngle !== void 0 ? _first$startAngle : 0;
		sectors === null || sectors === void 0 || sectors.forEach((entry, index) => {
			var prev = prevSectors && prevSectors[index];
			var paddingAngle = index > 0 ? (0, import_get.default)(entry, "paddingAngle", 0) : 0;
			if (prev) {
				var angle = interpolate(prev.endAngle - prev.startAngle, entry.endAngle - entry.startAngle, t);
				var latest = _objectSpread$9(_objectSpread$9({}, entry), {}, {
					startAngle: curAngle + paddingAngle,
					endAngle: curAngle + angle + paddingAngle
				});
				stepData.push(latest);
				curAngle = latest.endAngle;
			} else {
				var { endAngle, startAngle } = entry;
				var deltaAngle = interpolate(0, endAngle - startAngle, t);
				var _latest = _objectSpread$9(_objectSpread$9({}, entry), {}, {
					startAngle: curAngle + paddingAngle,
					endAngle: curAngle + deltaAngle + paddingAngle
				});
				stepData.push(_latest);
				curAngle = _latest.endAngle;
			}
		});
		previousSectorsRef.current = stepData;
		return /* @__PURE__ */ import_react.createElement(Layer, null, /* @__PURE__ */ import_react.createElement(PieSectors, {
			sectors: stepData,
			activeShape,
			inactiveShape,
			allOtherPieProps: props,
			shape: props.shape,
			id
		}));
	}), /* @__PURE__ */ import_react.createElement(PieLabelList, {
		showLabels: !isAnimating,
		sectors,
		props
	}), props.children);
}
var defaultPieProps = {
	animationBegin: 400,
	animationDuration: 1500,
	animationEasing: "ease",
	cx: "50%",
	cy: "50%",
	dataKey: "value",
	endAngle: 360,
	fill: "#808080",
	hide: false,
	innerRadius: 0,
	isAnimationActive: "auto",
	label: false,
	labelLine: true,
	legendType: "rect",
	minAngle: 0,
	nameKey: "name",
	outerRadius: "80%",
	paddingAngle: 0,
	rootTabIndex: 0,
	startAngle: 0,
	stroke: "#fff",
	zIndex: DefaultZIndexes.area
};
function PieImpl(props) {
	var { id } = props, propsWithoutId = _objectWithoutProperties$8(props, _excluded3$4);
	var { hide, className, rootTabIndex } = props;
	var cells = (0, import_react.useMemo)(() => findAllByType(props.children, Cell), [props.children]);
	var sectors = useAppSelector((state) => selectPieSectors(state, id, cells));
	var previousSectorsRef = (0, import_react.useRef)(null);
	var layerClass = clsx("recharts-pie", className);
	if (hide || sectors == null) {
		previousSectorsRef.current = null;
		return /* @__PURE__ */ import_react.createElement(Layer, {
			tabIndex: rootTabIndex,
			className: layerClass
		});
	}
	return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: props.zIndex }, /* @__PURE__ */ import_react.createElement(SetPieTooltipEntrySettings, {
		dataKey: props.dataKey,
		nameKey: props.nameKey,
		sectors,
		stroke: props.stroke,
		strokeWidth: props.strokeWidth,
		fill: props.fill,
		name: props.name,
		hide: props.hide,
		tooltipType: props.tooltipType,
		id,
		activeShape: props.activeShape
	}), /* @__PURE__ */ import_react.createElement(Layer, {
		tabIndex: rootTabIndex,
		className: layerClass
	}, /* @__PURE__ */ import_react.createElement(SectorsWithAnimation, {
		props: _objectSpread$9(_objectSpread$9({}, propsWithoutId), {}, { sectors }),
		previousSectorsRef,
		id
	})));
}
/**
* @consumes PolarChartContext
* @provides LabelListContext
* @provides CellReader
*/
function PieFn(outsideProps) {
	var props = resolveDefaultProps(outsideProps, defaultPieProps);
	var { id: externalId } = props, propsWithoutId = _objectWithoutProperties$8(props, _excluded4$2);
	var presentationProps = svgPropertiesNoEvents(propsWithoutId);
	return /* @__PURE__ */ import_react.createElement(RegisterGraphicalItemId, {
		id: externalId,
		type: "pie"
	}, (id) => /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetPolarGraphicalItem, {
		type: "pie",
		id,
		data: propsWithoutId.data,
		dataKey: propsWithoutId.dataKey,
		hide: propsWithoutId.hide,
		angleAxisId: 0,
		radiusAxisId: 0,
		name: propsWithoutId.name,
		nameKey: propsWithoutId.nameKey,
		tooltipType: propsWithoutId.tooltipType,
		legendType: propsWithoutId.legendType,
		fill: propsWithoutId.fill,
		cx: propsWithoutId.cx,
		cy: propsWithoutId.cy,
		startAngle: propsWithoutId.startAngle,
		endAngle: propsWithoutId.endAngle,
		paddingAngle: propsWithoutId.paddingAngle,
		minAngle: propsWithoutId.minAngle,
		innerRadius: propsWithoutId.innerRadius,
		outerRadius: propsWithoutId.outerRadius,
		cornerRadius: propsWithoutId.cornerRadius,
		presentationProps,
		maxRadius: props.maxRadius
	}), /* @__PURE__ */ import_react.createElement(SetPiePayloadLegend, _extends$9({}, propsWithoutId, { id })), /* @__PURE__ */ import_react.createElement(PieImpl, _extends$9({}, propsWithoutId, { id }))));
}
var Pie = PieFn;
Pie.displayName = "Pie";
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/combiners/combineBarSizeList.js
var getBarSize = (globalSize, totalSize, selfSize) => {
	var barSize = selfSize !== null && selfSize !== void 0 ? selfSize : globalSize;
	if (isNullish(barSize)) return;
	return getPercentValue(barSize, totalSize, 0);
};
var combineBarSizeList = (allBars, globalSize, totalSize) => {
	var initialValue = {};
	var stackedBars = allBars.filter(isStacked);
	var unstackedBars = allBars.filter((b) => b.stackId == null);
	var groupByStack = stackedBars.reduce((acc, bar) => {
		var s = acc[bar.stackId];
		if (s == null) s = [];
		s.push(bar);
		acc[bar.stackId] = s;
		return acc;
	}, initialValue);
	var stackedSizeList = Object.entries(groupByStack).map((_ref) => {
		var _bars$;
		var [stackId, bars] = _ref;
		return {
			stackId,
			dataKeys: bars.map((b) => b.dataKey),
			barSize: getBarSize(globalSize, totalSize, (_bars$ = bars[0]) === null || _bars$ === void 0 ? void 0 : _bars$.barSize)
		};
	});
	var unstackedSizeList = unstackedBars.map((b) => {
		return {
			stackId: void 0,
			dataKeys: [b.dataKey].filter((dk) => dk != null),
			barSize: getBarSize(globalSize, totalSize, b.barSize)
		};
	});
	return [...stackedSizeList, ...unstackedSizeList];
};
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/combiners/combineAllBarPositions.js
function ownKeys$8(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$8(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$8(Object(t), !0).forEach(function(r) {
			_defineProperty$8(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$8(e, r, t) {
	return (r = _toPropertyKey$8(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$8(t) {
	var i = _toPrimitive$8(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$8(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function getBarPositions(barGap, barCategoryGap, bandSize, sizeList, maxBarSize) {
	var _sizeList$;
	var len = sizeList.length;
	if (len < 1) return;
	var realBarGap = getPercentValue(barGap, bandSize, 0, true);
	var result;
	var initialValue = [];
	if (isWellBehavedNumber((_sizeList$ = sizeList[0]) === null || _sizeList$ === void 0 ? void 0 : _sizeList$.barSize)) {
		var useFull = false;
		var fullBarSize = bandSize / len;
		var sum = sizeList.reduce((res, entry) => res + (entry.barSize || 0), 0);
		sum += (len - 1) * realBarGap;
		if (sum >= bandSize) {
			sum -= (len - 1) * realBarGap;
			realBarGap = 0;
		}
		if (sum >= bandSize && fullBarSize > 0) {
			useFull = true;
			fullBarSize *= .9;
			sum = len * fullBarSize;
		}
		var prev = {
			offset: ((bandSize - sum) / 2 >> 0) - realBarGap,
			size: 0
		};
		result = sizeList.reduce((res, entry) => {
			var _entry$barSize;
			var newPosition = {
				stackId: entry.stackId,
				dataKeys: entry.dataKeys,
				position: {
					offset: prev.offset + prev.size + realBarGap,
					size: useFull ? fullBarSize : (_entry$barSize = entry.barSize) !== null && _entry$barSize !== void 0 ? _entry$barSize : 0
				}
			};
			var newRes = [...res, newPosition];
			prev = newPosition.position;
			return newRes;
		}, initialValue);
	} else {
		var _offset = getPercentValue(barCategoryGap, bandSize, 0, true);
		if (bandSize - 2 * _offset - (len - 1) * realBarGap <= 0) realBarGap = 0;
		var originalSize = (bandSize - 2 * _offset - (len - 1) * realBarGap) / len;
		if (originalSize > 1) originalSize >>= 0;
		var size = isWellBehavedNumber(maxBarSize) ? Math.min(originalSize, maxBarSize) : originalSize;
		result = sizeList.reduce((res, entry, i) => [...res, {
			stackId: entry.stackId,
			dataKeys: entry.dataKeys,
			position: {
				offset: _offset + (originalSize + realBarGap) * i + (originalSize - size) / 2,
				size
			}
		}], initialValue);
	}
	return result;
}
var combineAllBarPositions = (sizeList, globalMaxBarSize, barGap, barCategoryGap, barBandSize, bandSize, childMaxBarSize) => {
	var maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
	var allBarPositions = getBarPositions(barGap, barCategoryGap, barBandSize !== bandSize ? barBandSize : bandSize, sizeList, maxBarSize);
	if (barBandSize !== bandSize && allBarPositions != null) allBarPositions = allBarPositions.map((pos) => _objectSpread$8(_objectSpread$8({}, pos), {}, { position: _objectSpread$8(_objectSpread$8({}, pos.position), {}, { offset: pos.position.offset - barBandSize / 2 }) }));
	return allBarPositions;
};
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/combiners/combineStackedData.js
var combineStackedData = (stackGroups, barSettings) => {
	var stackSeriesIdentifier = getStackSeriesIdentifier(barSettings);
	if (!stackGroups || stackSeriesIdentifier == null || barSettings == null) return;
	var { stackId } = barSettings;
	if (stackId == null) return;
	var stackGroup = stackGroups[stackId];
	if (!stackGroup) return;
	var { stackedData } = stackGroup;
	if (!stackedData) return;
	return stackedData.find((sd) => sd.key === stackSeriesIdentifier);
};
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/combiners/combineBarPosition.js
var combineBarPosition = (allBarPositions, barSettings) => {
	if (allBarPositions == null || barSettings == null) return;
	var position = allBarPositions.find((p) => p.stackId === barSettings.stackId && barSettings.dataKey != null && p.dataKeys.includes(barSettings.dataKey));
	if (position == null) return;
	return position.position;
};
//#endregion
//#region ../../node_modules/recharts/es6/zIndex/getZIndexFromUnknown.js
function getZIndexFromUnknown(input, defaultZIndex) {
	if (input && typeof input === "object" && "zIndex" in input && typeof input.zIndex === "number" && isWellBehavedNumber(input.zIndex)) return input.zIndex;
	return defaultZIndex;
}
//#endregion
//#region ../../node_modules/recharts/es6/util/scale/CartesianScaleHelper.js
/**
* Groups X and Y scale functions together and provides helper methods.
*/
var CartesianScaleHelperImpl = class {
	constructor(_ref) {
		var { x, y } = _ref;
		this.xAxisScale = x;
		this.yAxisScale = y;
	}
	map(value, _ref2) {
		var _this$xAxisScale$map, _this$yAxisScale$map;
		var { position } = _ref2;
		return {
			x: (_this$xAxisScale$map = this.xAxisScale.map(value.x, { position })) !== null && _this$xAxisScale$map !== void 0 ? _this$xAxisScale$map : 0,
			y: (_this$yAxisScale$map = this.yAxisScale.map(value.y, { position })) !== null && _this$yAxisScale$map !== void 0 ? _this$yAxisScale$map : 0
		};
	}
	mapWithFallback(value, _ref3) {
		var _this$xAxisScale$map2, _this$yAxisScale$map2;
		var { position, fallback } = _ref3;
		var fallbackY, fallbackX;
		if (fallback === "rangeMin") fallbackY = this.yAxisScale.rangeMin();
		else if (fallback === "rangeMax") fallbackY = this.yAxisScale.rangeMax();
		else fallbackY = 0;
		if (fallback === "rangeMin") fallbackX = this.xAxisScale.rangeMin();
		else if (fallback === "rangeMax") fallbackX = this.xAxisScale.rangeMax();
		else fallbackX = 0;
		return {
			x: (_this$xAxisScale$map2 = this.xAxisScale.map(value.x, { position })) !== null && _this$xAxisScale$map2 !== void 0 ? _this$xAxisScale$map2 : fallbackX,
			y: (_this$yAxisScale$map2 = this.yAxisScale.map(value.y, { position })) !== null && _this$yAxisScale$map2 !== void 0 ? _this$yAxisScale$map2 : fallbackY
		};
	}
	isInRange(_ref4) {
		var { x, y } = _ref4;
		var xInRange = x == null || this.xAxisScale.isInRange(x);
		var yInRange = y == null || this.yAxisScale.isInRange(y);
		return xInRange && yInRange;
	}
};
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/ReferenceLine.js
/**
* @fileOverview Reference Line
*/
function ownKeys$7(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$7(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$7(Object(t), !0).forEach(function(r) {
			_defineProperty$7(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$7(e, r, t) {
	return (r = _toPropertyKey$7(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$7(t) {
	var i = _toPrimitive$7(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$7(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _extends$8() {
	return _extends$8 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$8.apply(null, arguments);
}
/**
* Single point that defines one end of a segment.
* These coordinates are in data space, meaning that you should provide
* values that correspond to the data domain of the axes.
* So you would provide a value of `Page A` to indicate the data value `Page A`
* and then recharts will convert that to pixels.
*
* Likewise for numbers. If your x-axis goes from 0 to 100,
* and you want the line to end at 50, you would provide `50` here.
*
* @inline
*/
/**
* This excludes `viewBox` prop from svg for two reasons:
* 1. The components wants viewBox of object type, and svg wants string
*    - so there's a conflict, and the component will throw if it gets string
* 2. Internally the component calls `svgPropertiesNoEvents` which filters the viewBox away anyway
*/
var renderLine = (option, props) => {
	var line;
	if (/* @__PURE__ */ import_react.isValidElement(option)) line = /* @__PURE__ */ import_react.cloneElement(option, props);
	else if (typeof option === "function") line = option(props);
	else {
		if (!isWellBehavedNumber(props.x1) || !isWellBehavedNumber(props.y1) || !isWellBehavedNumber(props.x2) || !isWellBehavedNumber(props.y2)) return null;
		line = /* @__PURE__ */ import_react.createElement("line", _extends$8({}, props, { className: "recharts-reference-line-line" }));
	}
	return line;
};
var getHorizontalLineEndPoints = (yCoord, ifOverflow, position, yAxisOrientation, yAxisScale, viewBox) => {
	var { x, width } = viewBox;
	var coord = yAxisScale.map(yCoord, { position });
	if (!isWellBehavedNumber(coord)) return null;
	if (ifOverflow === "discard" && !yAxisScale.isInRange(coord)) return null;
	var points = [{
		x: x + width,
		y: coord
	}, {
		x,
		y: coord
	}];
	return yAxisOrientation === "left" ? points.reverse() : points;
};
var getVerticalLineEndPoints = (xCoord, ifOverflow, position, xAxisOrientation, xAxisScale, viewBox) => {
	var { y, height } = viewBox;
	var coord = xAxisScale.map(xCoord, { position });
	if (!isWellBehavedNumber(coord)) return null;
	if (ifOverflow === "discard" && !xAxisScale.isInRange(coord)) return null;
	var points = [{
		x: coord,
		y: y + height
	}, {
		x: coord,
		y
	}];
	return xAxisOrientation === "top" ? points.reverse() : points;
};
var getSegmentLineEndPoints = (segment, ifOverflow, position, scales) => {
	var points = [scales.mapWithFallback(segment[0], {
		position,
		fallback: "rangeMin"
	}), scales.mapWithFallback(segment[1], {
		position,
		fallback: "rangeMax"
	})];
	if (ifOverflow === "discard" && points.some((p) => !scales.isInRange(p))) return null;
	return points;
};
var getEndPoints = (xAxisScale, yAxisScale, viewBox, position, xAxisOrientation, yAxisOrientation, props) => {
	var { x: xCoord, y: yCoord, segment, ifOverflow } = props;
	var isFixedX = isNumOrStr(xCoord);
	if (isNumOrStr(yCoord)) return getHorizontalLineEndPoints(yCoord, ifOverflow, position, yAxisOrientation, yAxisScale, viewBox);
	if (isFixedX) return getVerticalLineEndPoints(xCoord, ifOverflow, position, xAxisOrientation, xAxisScale, viewBox);
	if (segment != null && segment.length === 2) return getSegmentLineEndPoints(segment, ifOverflow, position, new CartesianScaleHelperImpl({
		x: xAxisScale,
		y: yAxisScale
	}));
	return null;
};
function ReportReferenceLine(props) {
	var dispatch = useAppDispatch();
	(0, import_react.useEffect)(() => {
		dispatch(addLine(props));
		return () => {
			dispatch(removeLine(props));
		};
	});
	return null;
}
function ReferenceLineImpl(props) {
	var { xAxisId, yAxisId, shape, className, ifOverflow } = props;
	var isPanorama = useIsPanorama();
	var clipPathId = useClipPathId();
	var xAxis = useAppSelector((state) => selectXAxisSettings(state, xAxisId));
	var yAxis = useAppSelector((state) => selectYAxisSettings(state, yAxisId));
	var xAxisScale = useAppSelector((state) => selectAxisScale(state, "xAxis", xAxisId, isPanorama));
	var yAxisScale = useAppSelector((state) => selectAxisScale(state, "yAxis", yAxisId, isPanorama));
	var viewBox = useViewBox();
	if (!clipPathId || !viewBox || xAxis == null || yAxis == null || xAxisScale == null || yAxisScale == null) return null;
	var endPoints = getEndPoints(xAxisScale, yAxisScale, viewBox, props.position, xAxis.orientation, yAxis.orientation, props);
	if (!endPoints) return null;
	var point1 = endPoints[0];
	var point2 = endPoints[1];
	if (point1 == null || point2 == null) return null;
	var { x: x1, y: y1 } = point1;
	var { x: x2, y: y2 } = point2;
	var lineProps = _objectSpread$7(_objectSpread$7({ clipPath: ifOverflow === "hidden" ? "url(#".concat(clipPathId, ")") : void 0 }, svgPropertiesAndEvents(props)), {}, {
		x1,
		y1,
		x2,
		y2
	});
	var rect = rectWithCoords({
		x1,
		y1,
		x2,
		y2
	});
	return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: props.zIndex }, /* @__PURE__ */ import_react.createElement(Layer, { className: clsx("recharts-reference-line", className) }, renderLine(shape, lineProps), /* @__PURE__ */ import_react.createElement(CartesianLabelContextProvider, _extends$8({}, rect, {
		lowerWidth: rect.width,
		upperWidth: rect.width
	}), /* @__PURE__ */ import_react.createElement(CartesianLabelFromLabelProp, { label: props.label }), props.children)));
}
var referenceLineDefaultProps = {
	ifOverflow: "discard",
	xAxisId: 0,
	yAxisId: 0,
	fill: "none",
	label: false,
	stroke: "#ccc",
	fillOpacity: 1,
	strokeWidth: 1,
	position: "middle",
	zIndex: DefaultZIndexes.line
};
/**
* Draws a line on the chart connecting two points.
*
* This component, unlike {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/line line}, is aware of the cartesian coordinate system,
* so you specify the dimensions by using data coordinates instead of pixels.
*
* ReferenceLine will calculate the pixels based on the provided data coordinates.
*
* If you prefer to render using pixels rather than data coordinates,
* consider using the {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/line line SVG element} instead.
*
* @provides CartesianLabelContext
* @consumes CartesianChartContext
*/
function ReferenceLine(outsideProps) {
	var props = resolveDefaultProps(outsideProps, referenceLineDefaultProps);
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(ReportReferenceLine, {
		yAxisId: props.yAxisId,
		xAxisId: props.xAxisId,
		ifOverflow: props.ifOverflow,
		x: props.x,
		y: props.y,
		segment: props.segment
	}), /* @__PURE__ */ import_react.createElement(ReferenceLineImpl, props));
}
ReferenceLine.displayName = "ReferenceLine";
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/CartesianGrid.js
var _excluded$7 = [
	"x1",
	"y1",
	"x2",
	"y2",
	"key"
], _excluded2$4 = ["offset"], _excluded3$3 = ["xAxisId", "yAxisId"], _excluded4$1 = ["xAxisId", "yAxisId"];
function ownKeys$6(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$6(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$6(Object(t), !0).forEach(function(r) {
			_defineProperty$6(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$6(e, r, t) {
	return (r = _toPropertyKey$6(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$6(t) {
	var i = _toPrimitive$6(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$6(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _extends$7() {
	return _extends$7 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$7.apply(null, arguments);
}
function _objectWithoutProperties$7(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$7(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$7(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
/**
* The <CartesianGrid horizontal
*/
var Background = (props) => {
	var { fill } = props;
	if (!fill || fill === "none") return null;
	var { fillOpacity, x, y, width, height, ry } = props;
	return /* @__PURE__ */ import_react.createElement("rect", {
		x,
		y,
		ry,
		width,
		height,
		stroke: "none",
		fill,
		fillOpacity,
		className: "recharts-cartesian-grid-bg"
	});
};
function LineItem(_ref) {
	var { option, lineItemProps } = _ref;
	var lineItem;
	if (/* @__PURE__ */ import_react.isValidElement(option)) lineItem = /* @__PURE__ */ import_react.cloneElement(option, lineItemProps);
	else if (typeof option === "function") lineItem = option(lineItemProps);
	else {
		var _svgPropertiesNoEvent;
		var { x1, y1, x2, y2, key } = lineItemProps;
		var _ref2 = (_svgPropertiesNoEvent = svgPropertiesNoEvents(_objectWithoutProperties$7(lineItemProps, _excluded$7))) !== null && _svgPropertiesNoEvent !== void 0 ? _svgPropertiesNoEvent : {}, { offset: __ } = _ref2, restOfFilteredProps = _objectWithoutProperties$7(_ref2, _excluded2$4);
		lineItem = /* @__PURE__ */ import_react.createElement("line", _extends$7({}, restOfFilteredProps, {
			x1,
			y1,
			x2,
			y2,
			fill: "none",
			key
		}));
	}
	return lineItem;
}
function HorizontalGridLines(props) {
	var { x, width, horizontal = true, horizontalPoints } = props;
	if (!horizontal || !horizontalPoints || !horizontalPoints.length) return null;
	var { xAxisId, yAxisId } = props, otherLineItemProps = _objectWithoutProperties$7(props, _excluded3$3);
	var items = horizontalPoints.map((entry, i) => {
		var lineItemProps = _objectSpread$6(_objectSpread$6({}, otherLineItemProps), {}, {
			x1: x,
			y1: entry,
			x2: x + width,
			y2: entry,
			key: "line-".concat(i),
			index: i
		});
		return /* @__PURE__ */ import_react.createElement(LineItem, {
			key: "line-".concat(i),
			option: horizontal,
			lineItemProps
		});
	});
	return /* @__PURE__ */ import_react.createElement("g", { className: "recharts-cartesian-grid-horizontal" }, items);
}
function VerticalGridLines(props) {
	var { y, height, vertical = true, verticalPoints } = props;
	if (!vertical || !verticalPoints || !verticalPoints.length) return null;
	var { xAxisId, yAxisId } = props, otherLineItemProps = _objectWithoutProperties$7(props, _excluded4$1);
	var items = verticalPoints.map((entry, i) => {
		var lineItemProps = _objectSpread$6(_objectSpread$6({}, otherLineItemProps), {}, {
			x1: entry,
			y1: y,
			x2: entry,
			y2: y + height,
			key: "line-".concat(i),
			index: i
		});
		return /* @__PURE__ */ import_react.createElement(LineItem, {
			option: vertical,
			lineItemProps,
			key: "line-".concat(i)
		});
	});
	return /* @__PURE__ */ import_react.createElement("g", { className: "recharts-cartesian-grid-vertical" }, items);
}
function HorizontalStripes(props) {
	var { horizontalFill, fillOpacity, x, y, width, height, horizontalPoints, horizontal = true } = props;
	if (!horizontal || !horizontalFill || !horizontalFill.length || horizontalPoints == null) return null;
	var roundedSortedHorizontalPoints = horizontalPoints.map((e) => Math.round(e + y - y)).sort((a, b) => a - b);
	if (y !== roundedSortedHorizontalPoints[0]) roundedSortedHorizontalPoints.unshift(0);
	var items = roundedSortedHorizontalPoints.map((entry, i) => {
		var nextPoint = roundedSortedHorizontalPoints[i + 1];
		var lineHeight = nextPoint == null ? y + height - entry : nextPoint - entry;
		if (lineHeight <= 0) return null;
		var colorIndex = i % horizontalFill.length;
		return /* @__PURE__ */ import_react.createElement("rect", {
			key: "react-".concat(i),
			y: entry,
			x,
			height: lineHeight,
			width,
			stroke: "none",
			fill: horizontalFill[colorIndex],
			fillOpacity,
			className: "recharts-cartesian-grid-bg"
		});
	});
	return /* @__PURE__ */ import_react.createElement("g", { className: "recharts-cartesian-gridstripes-horizontal" }, items);
}
function VerticalStripes(props) {
	var { vertical = true, verticalFill, fillOpacity, x, y, width, height, verticalPoints } = props;
	if (!vertical || !verticalFill || !verticalFill.length) return null;
	var roundedSortedVerticalPoints = verticalPoints.map((e) => Math.round(e + x - x)).sort((a, b) => a - b);
	if (x !== roundedSortedVerticalPoints[0]) roundedSortedVerticalPoints.unshift(0);
	var items = roundedSortedVerticalPoints.map((entry, i) => {
		var nextPoint = roundedSortedVerticalPoints[i + 1];
		var lineWidth = nextPoint == null ? x + width - entry : nextPoint - entry;
		if (lineWidth <= 0) return null;
		var colorIndex = i % verticalFill.length;
		return /* @__PURE__ */ import_react.createElement("rect", {
			key: "react-".concat(i),
			x: entry,
			y,
			width: lineWidth,
			height,
			stroke: "none",
			fill: verticalFill[colorIndex],
			fillOpacity,
			className: "recharts-cartesian-grid-bg"
		});
	});
	return /* @__PURE__ */ import_react.createElement("g", { className: "recharts-cartesian-gridstripes-vertical" }, items);
}
var defaultVerticalCoordinatesGenerator = (_ref3, syncWithTicks) => {
	var { xAxis, width, height, offset } = _ref3;
	return getCoordinatesOfGrid(getTicks(_objectSpread$6(_objectSpread$6(_objectSpread$6({}, defaultCartesianAxisProps), xAxis), {}, {
		ticks: getTicksOfAxis(xAxis, true),
		viewBox: {
			x: 0,
			y: 0,
			width,
			height
		}
	})), offset.left, offset.left + offset.width, syncWithTicks);
};
var defaultHorizontalCoordinatesGenerator = (_ref4, syncWithTicks) => {
	var { yAxis, width, height, offset } = _ref4;
	return getCoordinatesOfGrid(getTicks(_objectSpread$6(_objectSpread$6(_objectSpread$6({}, defaultCartesianAxisProps), yAxis), {}, {
		ticks: getTicksOfAxis(yAxis, true),
		viewBox: {
			x: 0,
			y: 0,
			width,
			height
		}
	})), offset.top, offset.top + offset.height, syncWithTicks);
};
var defaultCartesianGridProps = {
	horizontal: true,
	vertical: true,
	horizontalPoints: [],
	verticalPoints: [],
	stroke: "#ccc",
	fill: "none",
	verticalFill: [],
	horizontalFill: [],
	xAxisId: 0,
	yAxisId: 0,
	syncWithTicks: false,
	zIndex: DefaultZIndexes.grid
};
/**
* Renders background grid with lines and fill colors in a Cartesian chart.
*
* @consumes CartesianChartContext
*/
function CartesianGrid(props) {
	var chartWidth = useChartWidth();
	var chartHeight = useChartHeight();
	var offset = useOffsetInternal();
	var propsIncludingDefaults = _objectSpread$6(_objectSpread$6({}, resolveDefaultProps(props, defaultCartesianGridProps)), {}, {
		x: isNumber(props.x) ? props.x : offset.left,
		y: isNumber(props.y) ? props.y : offset.top,
		width: isNumber(props.width) ? props.width : offset.width,
		height: isNumber(props.height) ? props.height : offset.height
	});
	var { xAxisId, yAxisId, x, y, width, height, syncWithTicks, horizontalValues, verticalValues } = propsIncludingDefaults;
	var isPanorama = useIsPanorama();
	var xAxis = useAppSelector((state) => selectAxisPropsNeededForCartesianGridTicksGenerator(state, "xAxis", xAxisId, isPanorama));
	var yAxis = useAppSelector((state) => selectAxisPropsNeededForCartesianGridTicksGenerator(state, "yAxis", yAxisId, isPanorama));
	if (!isPositiveNumber(width) || !isPositiveNumber(height) || !isNumber(x) || !isNumber(y)) return null;
	var verticalCoordinatesGenerator = propsIncludingDefaults.verticalCoordinatesGenerator || defaultVerticalCoordinatesGenerator;
	var horizontalCoordinatesGenerator = propsIncludingDefaults.horizontalCoordinatesGenerator || defaultHorizontalCoordinatesGenerator;
	var { horizontalPoints, verticalPoints } = propsIncludingDefaults;
	if ((!horizontalPoints || !horizontalPoints.length) && typeof horizontalCoordinatesGenerator === "function") {
		var isHorizontalValues = horizontalValues && horizontalValues.length;
		var generatorResult = horizontalCoordinatesGenerator({
			yAxis: yAxis ? _objectSpread$6(_objectSpread$6({}, yAxis), {}, { ticks: isHorizontalValues ? horizontalValues : yAxis.ticks }) : void 0,
			width: chartWidth !== null && chartWidth !== void 0 ? chartWidth : width,
			height: chartHeight !== null && chartHeight !== void 0 ? chartHeight : height,
			offset
		}, isHorizontalValues ? true : syncWithTicks);
		warn(Array.isArray(generatorResult), "horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof generatorResult, "]"));
		if (Array.isArray(generatorResult)) horizontalPoints = generatorResult;
	}
	if ((!verticalPoints || !verticalPoints.length) && typeof verticalCoordinatesGenerator === "function") {
		var isVerticalValues = verticalValues && verticalValues.length;
		var _generatorResult = verticalCoordinatesGenerator({
			xAxis: xAxis ? _objectSpread$6(_objectSpread$6({}, xAxis), {}, { ticks: isVerticalValues ? verticalValues : xAxis.ticks }) : void 0,
			width: chartWidth !== null && chartWidth !== void 0 ? chartWidth : width,
			height: chartHeight !== null && chartHeight !== void 0 ? chartHeight : height,
			offset
		}, isVerticalValues ? true : syncWithTicks);
		warn(Array.isArray(_generatorResult), "verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof _generatorResult, "]"));
		if (Array.isArray(_generatorResult)) verticalPoints = _generatorResult;
	}
	return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: propsIncludingDefaults.zIndex }, /* @__PURE__ */ import_react.createElement("g", { className: "recharts-cartesian-grid" }, /* @__PURE__ */ import_react.createElement(Background, {
		fill: propsIncludingDefaults.fill,
		fillOpacity: propsIncludingDefaults.fillOpacity,
		x: propsIncludingDefaults.x,
		y: propsIncludingDefaults.y,
		width: propsIncludingDefaults.width,
		height: propsIncludingDefaults.height,
		ry: propsIncludingDefaults.ry
	}), /* @__PURE__ */ import_react.createElement(HorizontalStripes, _extends$7({}, propsIncludingDefaults, { horizontalPoints })), /* @__PURE__ */ import_react.createElement(VerticalStripes, _extends$7({}, propsIncludingDefaults, { verticalPoints })), /* @__PURE__ */ import_react.createElement(HorizontalGridLines, _extends$7({}, propsIncludingDefaults, {
		offset,
		horizontalPoints,
		xAxis,
		yAxis
	})), /* @__PURE__ */ import_react.createElement(VerticalGridLines, _extends$7({}, propsIncludingDefaults, {
		offset,
		verticalPoints,
		xAxis,
		yAxis
	}))));
}
CartesianGrid.displayName = "CartesianGrid";
//#endregion
//#region ../../node_modules/recharts/es6/context/ErrorBarContext.js
var _excluded$6 = ["children"];
function _objectWithoutProperties$6(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$6(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$6(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
var ErrorBarContext = /* @__PURE__ */ (0, import_react.createContext)({
	data: [],
	xAxisId: "xAxis-0",
	yAxisId: "yAxis-0",
	dataPointFormatter: () => ({
		x: 0,
		y: 0,
		value: 0
	}),
	errorBarOffset: 0
});
function SetErrorBarContext(props) {
	var { children } = props, rest = _objectWithoutProperties$6(props, _excluded$6);
	return /* @__PURE__ */ import_react.createElement(ErrorBarContext.Provider, { value: rest }, children);
}
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/lineSelectors.js
var selectXAxisWithScale$1 = (state, xAxisId, _yAxisId, isPanorama) => selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
var selectXAxisTicks$1 = (state, xAxisId, _yAxisId, isPanorama) => selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
var selectYAxisWithScale$1 = (state, _xAxisId, yAxisId, isPanorama) => selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
var selectYAxisTicks$1 = (state, _xAxisId, yAxisId, isPanorama) => selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
var selectBandSize = createSelector([
	selectChartLayout,
	selectXAxisWithScale$1,
	selectYAxisWithScale$1,
	selectXAxisTicks$1,
	selectYAxisTicks$1
], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks) => {
	if (isCategoricalAxis(layout, "xAxis")) return getBandSizeOfAxis(xAxis, xAxisTicks, false);
	return getBandSizeOfAxis(yAxis, yAxisTicks, false);
});
var pickLineId = (_state, _xAxisId, _yAxisId, _isPanorama, id) => id;
function isLineSettings(item) {
	return item.type === "line";
}
var selectLinePoints = createSelector([
	selectChartLayout,
	selectXAxisWithScale$1,
	selectYAxisWithScale$1,
	selectXAxisTicks$1,
	selectYAxisTicks$1,
	createSelector([selectUnfilteredCartesianItems, pickLineId], (graphicalItems, id) => graphicalItems.filter(isLineSettings).find((x) => x.id === id)),
	selectBandSize,
	selectChartDataWithIndexesIfNotInPanoramaPosition4
], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks, lineSettings, bandSize, _ref) => {
	var { chartData, dataStartIndex, dataEndIndex } = _ref;
	if (lineSettings == null || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || xAxisTicks.length === 0 || yAxisTicks.length === 0 || bandSize == null || layout !== "horizontal" && layout !== "vertical") return;
	var { dataKey, data } = lineSettings;
	var displayedData;
	if (data != null && data.length > 0) displayedData = data;
	else displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
	if (displayedData == null) return;
	return computeLinePoints({
		layout,
		xAxis,
		yAxis,
		xAxisTicks,
		yAxisTicks,
		dataKey,
		bandSize,
		displayedData
	});
});
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/Line.js
var _excluded$5 = ["id"], _excluded2$3 = [
	"type",
	"layout",
	"connectNulls",
	"needClip",
	"shape"
], _excluded3$2 = [
	"activeDot",
	"animateNewValues",
	"animationBegin",
	"animationDuration",
	"animationEasing",
	"connectNulls",
	"dot",
	"hide",
	"isAnimationActive",
	"label",
	"legendType",
	"xAxisId",
	"yAxisId",
	"id"
];
function _extends$6() {
	return _extends$6 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$6.apply(null, arguments);
}
function ownKeys$5(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$5(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$5(Object(t), !0).forEach(function(r) {
			_defineProperty$5(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$5(e, r, t) {
	return (r = _toPropertyKey$5(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$5(t) {
	var i = _toPrimitive$5(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$5(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties$5(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$5(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$5(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
/**
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
*/
var computeLegendPayloadFromAreaData = (props) => {
	var { dataKey, name, stroke, legendType, hide } = props;
	return [{
		inactive: hide,
		dataKey,
		type: legendType,
		color: stroke,
		value: getTooltipNameProp(name, dataKey),
		payload: props
	}];
};
var SetLineTooltipEntrySettings = /* @__PURE__ */ import_react.memo((_ref) => {
	var { dataKey, data, stroke, strokeWidth, fill, name, hide, unit, tooltipType, id } = _ref;
	var tooltipEntrySettings = {
		dataDefinedOnItem: data,
		getPosition: noop$1,
		settings: {
			stroke,
			strokeWidth,
			fill,
			dataKey,
			nameKey: void 0,
			name: getTooltipNameProp(name, dataKey),
			hide,
			type: tooltipType,
			color: stroke,
			unit,
			graphicalItemId: id
		}
	};
	return /* @__PURE__ */ import_react.createElement(SetTooltipEntrySettings, { tooltipEntrySettings });
});
/**
* Generates a simple stroke-dasharray string for animating a line draw effect.
*
* Uses `totalLength` as the gap (instead of `totalLength - length`) to prevent a floating-point
* precision artifact: when fractional dash and gap values are serialized to a string attribute
* and re-parsed by the SVG renderer, their sum can differ from the actual path length by a ULP,
* causing the dasharray pattern to repeat and render a phantom dot at the path endpoint
* with round or square strokeLinecap.
*
* @param totalLength The total length of the SVG path
* @param length The currently visible portion of the path
* @returns A stroke-dasharray string like "50px 200px"
*/
var generateSimpleStrokeDasharray = (totalLength, length) => {
	return "".concat(length, "px ").concat(totalLength, "px");
};
/**
* Repeats a dash pattern array a given number of times.
*
* If the input array has an odd length, a trailing `0` is appended to make it even
* before repeating, because SVG stroke-dasharray patterns must have an even number
* of values to cycle correctly between dash and gap segments.
*
* @param lines Array of dash/gap lengths to repeat
* @param count Number of times to repeat the pattern
* @returns A new array with the pattern repeated `count` times
*/
function repeat(lines, count) {
	var linesUnit = lines.length % 2 !== 0 ? [...lines, 0] : lines;
	var result = [];
	for (var i = 0; i < count; ++i) result.push(...linesUnit);
	return result;
}
/**
* Computes a stroke-dasharray string for animating a custom-dashed line draw effect.
*
* Given a user-specified dash pattern (e.g. `"7,3"`), this function builds a dasharray
* that reveals exactly `length` pixels of that pattern, followed by a gap of `totalLength`
* to hide the remainder of the path.
*
* Like {@link generateSimpleStrokeDasharray}, the trailing gap uses `totalLength` rather than
* `totalLength - length` to avoid floating-point precision artifacts with round/square strokeLinecap.
*
* @param length The currently visible portion of the path
* @param totalLength The total length of the SVG path
* @param lines The user-specified dash pattern as an array of numbers (e.g. [7, 3])
* @returns A stroke-dasharray string incorporating the custom dash pattern
*/
var getStrokeDasharray = (length, totalLength, lines) => {
	var lineLength = lines.reduce((pre, next) => pre + next, 0);
	if (!lineLength) return generateSimpleStrokeDasharray(totalLength, length);
	var count = Math.floor(length / lineLength);
	var remainLength = length % lineLength;
	var remainLines = [];
	for (var i = 0, sum = 0; i < lines.length; sum += (_lines$i = lines[i]) !== null && _lines$i !== void 0 ? _lines$i : 0, ++i) {
		var _lines$i;
		var lineValue = lines[i];
		if (lineValue != null && sum + lineValue > remainLength) {
			remainLines = [...lines.slice(0, i), remainLength - sum];
			break;
		}
	}
	var emptyLines = remainLines.length % 2 === 0 ? [0, totalLength] : [totalLength];
	return [
		...repeat(lines, count),
		...remainLines,
		...emptyLines
	].map((line) => "".concat(line, "px")).join(", ");
};
function LineDotsWrapper(_ref2) {
	var { clipPathId, points, props } = _ref2;
	var { dot, dataKey, needClip } = props;
	var { id } = props;
	var lineProps = svgPropertiesNoEvents(_objectWithoutProperties$5(props, _excluded$5));
	return /* @__PURE__ */ import_react.createElement(Dots, {
		points,
		dot,
		className: "recharts-line-dots",
		dotClassName: "recharts-line-dot",
		dataKey,
		baseProps: lineProps,
		needClip,
		clipPathId
	});
}
function LineLabelListProvider(_ref3) {
	var { showLabels, children, points } = _ref3;
	var labelListEntries = (0, import_react.useMemo)(() => {
		return points === null || points === void 0 ? void 0 : points.map((point) => {
			var _point$x, _point$y;
			var viewBox = {
				x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
				y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
				width: 0,
				lowerWidth: 0,
				upperWidth: 0,
				height: 0
			};
			return _objectSpread$5(_objectSpread$5({}, viewBox), {}, {
				value: point.value,
				payload: point.payload,
				viewBox,
				parentViewBox: void 0,
				fill: void 0
			});
		});
	}, [points]);
	return /* @__PURE__ */ import_react.createElement(CartesianLabelListContextProvider, { value: showLabels ? labelListEntries : void 0 }, children);
}
function StaticCurve(_ref4) {
	var { clipPathId, pathRef, points, strokeDasharray, props } = _ref4;
	var { type, layout, connectNulls, needClip, shape } = props;
	var curveProps = _objectSpread$5(_objectSpread$5({}, svgPropertiesAndEvents(_objectWithoutProperties$5(props, _excluded2$3))), {}, {
		fill: "none",
		className: "recharts-line-curve",
		clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : void 0,
		points,
		type,
		layout,
		connectNulls,
		strokeDasharray: strokeDasharray !== null && strokeDasharray !== void 0 ? strokeDasharray : props.strokeDasharray
	});
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, (points === null || points === void 0 ? void 0 : points.length) > 1 && /* @__PURE__ */ import_react.createElement(Shape, _extends$6({
		shapeType: "curve",
		option: shape
	}, curveProps, { pathRef })), /* @__PURE__ */ import_react.createElement(LineDotsWrapper, {
		points,
		clipPathId,
		props
	}));
}
function getTotalLength(mainCurve) {
	try {
		return mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength() || 0;
	} catch (_unused) {
		return 0;
	}
}
function CurveWithAnimation(_ref5) {
	var { clipPathId, props, pathRef, previousPointsRef, longestAnimatedLengthRef } = _ref5;
	var { points, strokeDasharray, isAnimationActive, animationBegin, animationDuration, animationEasing, animateNewValues, width, height, onAnimationEnd, onAnimationStart } = props;
	var prevPoints = previousPointsRef.current;
	var animationId = useAnimationId(points, "recharts-line-");
	var animationIdRef = (0, import_react.useRef)(animationId);
	var [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
	var showLabels = !isAnimating;
	var handleAnimationEnd = (0, import_react.useCallback)(() => {
		if (typeof onAnimationEnd === "function") onAnimationEnd();
		setIsAnimating(false);
	}, [onAnimationEnd]);
	var handleAnimationStart = (0, import_react.useCallback)(() => {
		if (typeof onAnimationStart === "function") onAnimationStart();
		setIsAnimating(true);
	}, [onAnimationStart]);
	var totalLength = getTotalLength(pathRef.current);
	var startingPointRef = (0, import_react.useRef)(0);
	if (animationIdRef.current !== animationId) {
		startingPointRef.current = longestAnimatedLengthRef.current;
		animationIdRef.current = animationId;
	}
	var startingPoint = startingPointRef.current;
	return /* @__PURE__ */ import_react.createElement(LineLabelListProvider, {
		points,
		showLabels
	}, props.children, /* @__PURE__ */ import_react.createElement(JavascriptAnimate, {
		animationId,
		begin: animationBegin,
		duration: animationDuration,
		isActive: isAnimationActive,
		easing: animationEasing,
		onAnimationEnd: handleAnimationEnd,
		onAnimationStart: handleAnimationStart,
		key: animationId
	}, (t) => {
		var lengthInterpolated = interpolate(startingPoint, totalLength + startingPoint, t);
		var curLength = Math.min(lengthInterpolated, totalLength);
		var currentStrokeDasharray;
		if (isAnimationActive) if (strokeDasharray) currentStrokeDasharray = getStrokeDasharray(curLength, totalLength, "".concat(strokeDasharray).split(/[,\s]+/gim).map((num) => parseFloat(num)));
		else currentStrokeDasharray = generateSimpleStrokeDasharray(totalLength, curLength);
		else currentStrokeDasharray = strokeDasharray == null ? void 0 : String(strokeDasharray);
		if (t > 0 && totalLength > 0) {
			previousPointsRef.current = points;
			longestAnimatedLengthRef.current = Math.max(longestAnimatedLengthRef.current, curLength);
		}
		if (prevPoints) {
			var prevPointsDiffFactor = prevPoints.length / points.length;
			var stepData = t === 1 ? points : points.map((entry, index) => {
				var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
				if (prevPoints[prevPointIndex]) {
					var prev = prevPoints[prevPointIndex];
					return _objectSpread$5(_objectSpread$5({}, entry), {}, {
						x: interpolate(prev.x, entry.x, t),
						y: interpolate(prev.y, entry.y, t)
					});
				}
				if (animateNewValues) return _objectSpread$5(_objectSpread$5({}, entry), {}, {
					x: interpolate(width * 2, entry.x, t),
					y: interpolate(height / 2, entry.y, t)
				});
				return _objectSpread$5(_objectSpread$5({}, entry), {}, {
					x: entry.x,
					y: entry.y
				});
			});
			previousPointsRef.current = stepData;
			return /* @__PURE__ */ import_react.createElement(StaticCurve, {
				props,
				points: stepData,
				clipPathId,
				pathRef,
				strokeDasharray: currentStrokeDasharray
			});
		}
		return /* @__PURE__ */ import_react.createElement(StaticCurve, {
			props,
			points,
			clipPathId,
			pathRef,
			strokeDasharray: currentStrokeDasharray
		});
	}), /* @__PURE__ */ import_react.createElement(LabelListFromLabelProp, { label: props.label }));
}
function RenderCurve(_ref6) {
	var { clipPathId, props } = _ref6;
	var previousPointsRef = (0, import_react.useRef)(null);
	var longestAnimatedLengthRef = (0, import_react.useRef)(0);
	var pathRef = (0, import_react.useRef)(null);
	return /* @__PURE__ */ import_react.createElement(CurveWithAnimation, {
		props,
		clipPathId,
		previousPointsRef,
		longestAnimatedLengthRef,
		pathRef
	});
}
var errorBarDataPointFormatter$1 = (dataPoint, dataKey) => {
	var _dataPoint$x, _dataPoint$y;
	return {
		x: (_dataPoint$x = dataPoint.x) !== null && _dataPoint$x !== void 0 ? _dataPoint$x : void 0,
		y: (_dataPoint$y = dataPoint.y) !== null && _dataPoint$y !== void 0 ? _dataPoint$y : void 0,
		value: dataPoint.value,
		errorVal: getValueByDataKey(dataPoint.payload, dataKey)
	};
};
var LineWithState = class extends import_react.Component {
	render() {
		var { hide, dot, points, className, xAxisId, yAxisId, top, left, width, height, id, needClip, zIndex } = this.props;
		if (hide) return null;
		var layerClass = clsx("recharts-line", className);
		var clipPathId = id;
		var { r, strokeWidth } = getRadiusAndStrokeWidthFromDot(dot);
		var clipDot = isClipDot(dot);
		var dotSize = r * 2 + strokeWidth;
		var activePointsClipPath = needClip ? "url(#clipPath-".concat(clipDot ? "" : "dots-").concat(clipPathId, ")") : void 0;
		return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex }, /* @__PURE__ */ import_react.createElement(Layer, { className: layerClass }, needClip && /* @__PURE__ */ import_react.createElement("defs", null, /* @__PURE__ */ import_react.createElement(GraphicalItemClipPath, {
			clipPathId,
			xAxisId,
			yAxisId
		}), !clipDot && /* @__PURE__ */ import_react.createElement("clipPath", { id: "clipPath-dots-".concat(clipPathId) }, /* @__PURE__ */ import_react.createElement("rect", {
			x: left - dotSize / 2,
			y: top - dotSize / 2,
			width: width + dotSize,
			height: height + dotSize
		}))), /* @__PURE__ */ import_react.createElement(SetErrorBarContext, {
			xAxisId,
			yAxisId,
			data: points,
			dataPointFormatter: errorBarDataPointFormatter$1,
			errorBarOffset: 0
		}, /* @__PURE__ */ import_react.createElement(RenderCurve, {
			props: this.props,
			clipPathId
		}))), /* @__PURE__ */ import_react.createElement(ActivePoints, {
			activeDot: this.props.activeDot,
			points,
			mainColor: this.props.stroke,
			itemDataKey: this.props.dataKey,
			clipPath: activePointsClipPath
		}));
	}
};
var defaultLineProps = {
	activeDot: true,
	animateNewValues: true,
	animationBegin: 0,
	animationDuration: 1500,
	animationEasing: "ease",
	connectNulls: false,
	dot: true,
	fill: "#fff",
	hide: false,
	isAnimationActive: "auto",
	label: false,
	legendType: "line",
	stroke: "#3182bd",
	strokeWidth: 1,
	xAxisId: 0,
	yAxisId: 0,
	zIndex: DefaultZIndexes.line,
	type: "linear"
};
function LineImpl(props) {
	var _resolveDefaultProps = resolveDefaultProps(props, defaultLineProps), { activeDot, animateNewValues, animationBegin, animationDuration, animationEasing, connectNulls, dot, hide, isAnimationActive, label, legendType, xAxisId, yAxisId, id } = _resolveDefaultProps, everythingElse = _objectWithoutProperties$5(_resolveDefaultProps, _excluded3$2);
	var { needClip } = useNeedsClip(xAxisId, yAxisId);
	var plotArea = usePlotArea();
	var layout = useChartLayout();
	var isPanorama = useIsPanorama();
	var points = useAppSelector((state) => selectLinePoints(state, xAxisId, yAxisId, isPanorama, id));
	if (layout !== "horizontal" && layout !== "vertical" || points == null || plotArea == null) return null;
	var { height, width, x: left, y: top } = plotArea;
	return /* @__PURE__ */ import_react.createElement(LineWithState, _extends$6({}, everythingElse, {
		id,
		connectNulls,
		dot,
		activeDot,
		animateNewValues,
		animationBegin,
		animationDuration,
		animationEasing,
		isAnimationActive,
		hide,
		label,
		legendType,
		xAxisId,
		yAxisId,
		points,
		layout,
		height,
		width,
		left,
		top,
		needClip
	}));
}
function computeLinePoints(_ref7) {
	var { layout, xAxis, yAxis, xAxisTicks, yAxisTicks, dataKey, bandSize, displayedData } = _ref7;
	return displayedData.map((entry, index) => {
		var value = getValueByDataKey(entry, dataKey);
		if (layout === "horizontal") {
			var _x = getCateCoordinateOfLine({
				axis: xAxis,
				ticks: xAxisTicks,
				bandSize,
				entry,
				index
			});
			var _y = isNullish(value) ? null : yAxis.scale.map(value);
			return {
				x: _x,
				y: _y !== null && _y !== void 0 ? _y : null,
				value,
				payload: entry
			};
		}
		var x = isNullish(value) ? null : xAxis.scale.map(value);
		var y = getCateCoordinateOfLine({
			axis: yAxis,
			ticks: yAxisTicks,
			bandSize,
			entry,
			index
		});
		if (x == null || y == null) return null;
		return {
			x,
			y,
			value,
			payload: entry
		};
	}).filter(Boolean);
}
function LineFn(outsideProps) {
	var props = resolveDefaultProps(outsideProps, defaultLineProps);
	var isPanorama = useIsPanorama();
	return /* @__PURE__ */ import_react.createElement(RegisterGraphicalItemId, {
		id: props.id,
		type: "line"
	}, (id) => /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetLegendPayload, { legendPayload: computeLegendPayloadFromAreaData(props) }), /* @__PURE__ */ import_react.createElement(SetLineTooltipEntrySettings, {
		dataKey: props.dataKey,
		data: props.data,
		stroke: props.stroke,
		strokeWidth: props.strokeWidth,
		fill: props.fill,
		name: props.name,
		hide: props.hide,
		unit: props.unit,
		tooltipType: props.tooltipType,
		id
	}), /* @__PURE__ */ import_react.createElement(SetCartesianGraphicalItem, {
		type: "line",
		id,
		data: props.data,
		xAxisId: props.xAxisId,
		yAxisId: props.yAxisId,
		zAxisId: 0,
		dataKey: props.dataKey,
		hide: props.hide,
		isPanorama
	}), /* @__PURE__ */ import_react.createElement(LineImpl, _extends$6({}, props, { id }))));
}
/**
* @provides LabelListContext
* @provides ErrorBarContext
* @consumes CartesianChartContext
*/
var Line = /* @__PURE__ */ import_react.memo(LineFn, propsAreEqual);
Line.displayName = "Line";
//#endregion
//#region ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
var isProduction = true;
var prefix = "Invariant failed";
function invariant(condition, message) {
	if (condition) return;
	if (isProduction) throw new Error(prefix);
	var provided = typeof message === "function" ? message() : message;
	var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
	throw new Error(value);
}
//#endregion
//#region ../../node_modules/recharts/es6/util/BarUtils.js
function _extends$5() {
	return _extends$5 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$5.apply(null, arguments);
}
function BarRectangle(props) {
	return /* @__PURE__ */ import_react.createElement(Shape, _extends$5({
		shapeType: "rectangle",
		activeClassName: "recharts-active-bar",
		inActiveClassName: "recharts-inactive-bar"
	}, props));
}
/**
* Safely gets minPointSize from the minPointSize prop if it is a function
* @param minPointSize minPointSize as passed to the Bar component
* @param defaultValue default minPointSize
* @returns minPointSize
*/
var minPointSizeCallback = function minPointSizeCallback(minPointSize) {
	var defaultValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
	return (value, index) => {
		if (isNumber(minPointSize)) return minPointSize;
		var isValueNumberOrNil = isNumber(value) || isNullish(value);
		if (isValueNumberOrNil) return minPointSize(value, index);
		!isValueNumberOrNil && invariant(false, "minPointSize callback function received a value with type of ".concat(typeof value, ". Currently only numbers or null/undefined are supported."));
		return defaultValue;
	};
};
//#endregion
//#region ../../node_modules/recharts/es6/state/selectors/barSelectors.js
var pickIsPanorama = (_state, _id, isPanorama) => isPanorama;
var pickBarId = (_state, id) => id;
var selectSynchronisedBarSettings = createSelector([selectUnfilteredCartesianItems, pickBarId], (graphicalItems, id) => graphicalItems.filter((item) => item.type === "bar").find((item) => item.id === id));
var selectMaxBarSize = createSelector([selectSynchronisedBarSettings], (barSettings) => barSettings === null || barSettings === void 0 ? void 0 : barSettings.maxBarSize);
var pickCells = (_state, _id, _isPanorama, cells) => cells;
var selectAllVisibleBars = createSelector([
	selectChartLayout,
	selectUnfilteredCartesianItems,
	selectXAxisIdFromGraphicalItemId,
	selectYAxisIdFromGraphicalItemId,
	pickIsPanorama
], (layout, allItems, xAxisId, yAxisId, isPanorama) => allItems.filter((i) => {
	if (layout === "horizontal") return i.xAxisId === xAxisId;
	return i.yAxisId === yAxisId;
}).filter((i) => i.isPanorama === isPanorama).filter((i) => i.hide === false).filter((i) => i.type === "bar"));
var selectBarStackGroups = (state, id, isPanorama) => {
	var layout = selectChartLayout(state);
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null || yAxisId == null) return;
	if (layout === "horizontal") return selectStackGroups(state, "yAxis", yAxisId, isPanorama);
	return selectStackGroups(state, "xAxis", xAxisId, isPanorama);
};
var selectBarCartesianAxisSize = (state, id) => {
	var layout = selectChartLayout(state);
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null || yAxisId == null) return;
	if (layout === "horizontal") return selectCartesianAxisSize(state, "xAxis", xAxisId);
	return selectCartesianAxisSize(state, "yAxis", yAxisId);
};
var selectBarSizeList = createSelector([
	selectAllVisibleBars,
	selectRootBarSize,
	selectBarCartesianAxisSize
], combineBarSizeList);
var selectBarBandSize = (state, id, isPanorama) => {
	var _ref, _getBandSizeOfAxis;
	var barSettings = selectSynchronisedBarSettings(state, id);
	if (barSettings == null) return 0;
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null || yAxisId == null) return 0;
	var layout = selectChartLayout(state);
	var globalMaxBarSize = selectRootMaxBarSize(state);
	var { maxBarSize: childMaxBarSize } = barSettings;
	var maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
	var axis, ticks;
	if (layout === "horizontal") {
		axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
		ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
	} else {
		axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
		ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
	}
	return (_ref = (_getBandSizeOfAxis = getBandSizeOfAxis(axis, ticks, true)) !== null && _getBandSizeOfAxis !== void 0 ? _getBandSizeOfAxis : maxBarSize) !== null && _ref !== void 0 ? _ref : 0;
};
var selectAxisBandSize = (state, id, isPanorama) => {
	var layout = selectChartLayout(state);
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null || yAxisId == null) return;
	var axis, ticks;
	if (layout === "horizontal") {
		axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
		ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
	} else {
		axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
		ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
	}
	return getBandSizeOfAxis(axis, ticks);
};
var selectAllBarPositions = createSelector([
	selectBarSizeList,
	selectRootMaxBarSize,
	selectBarGap,
	selectBarCategoryGap,
	selectBarBandSize,
	selectAxisBandSize,
	selectMaxBarSize
], combineAllBarPositions);
var selectXAxisWithScale = (state, id, isPanorama) => {
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null) return;
	return selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
};
var selectYAxisWithScale = (state, id, isPanorama) => {
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (yAxisId == null) return;
	return selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
};
var selectXAxisTicks = (state, id, isPanorama) => {
	var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
	if (xAxisId == null) return;
	return selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
};
var selectYAxisTicks = (state, id, isPanorama) => {
	var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
	if (yAxisId == null) return;
	return selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
};
var selectBarRectangles = createSelector([
	selectChartOffsetInternal,
	selectAxisViewBox,
	selectXAxisWithScale,
	selectYAxisWithScale,
	selectXAxisTicks,
	selectYAxisTicks,
	createSelector([selectAllBarPositions, selectSynchronisedBarSettings], combineBarPosition),
	selectChartLayout,
	selectChartDataWithIndexesIfNotInPanoramaPosition3,
	selectAxisBandSize,
	createSelector([selectBarStackGroups, selectSynchronisedBarSettings], combineStackedData),
	selectSynchronisedBarSettings,
	pickCells
], (offset, axisViewBox, xAxis, yAxis, xAxisTicks, yAxisTicks, pos, layout, _ref2, bandSize, stackedData, barSettings, cells) => {
	var { chartData, dataStartIndex, dataEndIndex } = _ref2;
	if (barSettings == null || pos == null || axisViewBox == null || layout !== "horizontal" && layout !== "vertical" || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || bandSize == null) return;
	var { data } = barSettings;
	var displayedData;
	if (data != null && data.length > 0) displayedData = data;
	else displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
	if (displayedData == null) return;
	return computeBarRectangles({
		layout,
		barSettings,
		pos,
		parentViewBox: axisViewBox,
		bandSize,
		xAxis,
		yAxis,
		xAxisTicks,
		yAxisTicks,
		stackedData,
		displayedData,
		offset,
		cells,
		dataStartIndex
	});
});
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/BarStack.js
var _excluded$4 = ["index"];
function _extends$4() {
	return _extends$4 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$4.apply(null, arguments);
}
function _objectWithoutProperties$4(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$4(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$4(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
var BarStackContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
/**
* Hook to resolve the stack ID for a Bar component.
* If a stack ID is provided via props, it is used directly.
* Otherwise, this will read stack ID from BarStack context if available.
* If both are undefined, it returns undefined.
* @param childStackId
*/
var useStackId = (childStackId) => {
	var stackSettings = (0, import_react.useContext)(BarStackContext);
	if (stackSettings != null) return stackSettings.stackId;
	if (childStackId == null) return;
	return getNormalizedStackId(childStackId);
};
var getClipPathId = (stackId, index) => {
	return "recharts-bar-stack-clip-path-".concat(stackId, "-").concat(index);
};
var useBarStackClipPathUrl = (index) => {
	var barStackContext = (0, import_react.useContext)(BarStackContext);
	if (barStackContext == null) return;
	var { stackId } = barStackContext;
	return "url(#".concat(getClipPathId(stackId, index), ")");
};
var BarStackClipLayer = (_ref) => {
	var { index } = _ref, rest = _objectWithoutProperties$4(_ref, _excluded$4);
	var clipPathUrl = useBarStackClipPathUrl(index);
	return /* @__PURE__ */ import_react.createElement(Layer, _extends$4({
		className: "recharts-bar-stack-layer",
		clipPath: clipPathUrl
	}, rest));
};
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/Bar.js
var _excluded$3 = [
	"onMouseEnter",
	"onMouseLeave",
	"onClick"
], _excluded2$2 = [
	"value",
	"background",
	"tooltipPosition"
], _excluded3$1 = ["id"], _excluded4 = [
	"onMouseEnter",
	"onClick",
	"onMouseLeave"
];
function _extends$3() {
	return _extends$3 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$3.apply(null, arguments);
}
function ownKeys$4(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$4(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$4(Object(t), !0).forEach(function(r) {
			_defineProperty$4(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$4(e, r, t) {
	return (r = _toPropertyKey$4(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$4(t) {
	var i = _toPrimitive$4(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$4(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties$3(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$3(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$3(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
var computeLegendPayloadFromBarData = (props) => {
	var { dataKey, name, fill, legendType, hide } = props;
	return [{
		inactive: hide,
		dataKey,
		type: legendType,
		color: fill,
		value: getTooltipNameProp(name, dataKey),
		payload: props
	}];
};
var SetBarTooltipEntrySettings = /* @__PURE__ */ import_react.memo((_ref) => {
	var { dataKey, stroke, strokeWidth, fill, name, hide, unit, tooltipType, id } = _ref;
	var tooltipEntrySettings = {
		dataDefinedOnItem: void 0,
		getPosition: noop$1,
		settings: {
			stroke,
			strokeWidth,
			fill,
			dataKey,
			nameKey: void 0,
			name: getTooltipNameProp(name, dataKey),
			hide,
			type: tooltipType,
			color: fill,
			unit,
			graphicalItemId: id
		}
	};
	return /* @__PURE__ */ import_react.createElement(SetTooltipEntrySettings, { tooltipEntrySettings });
});
function BarBackground(props) {
	var activeIndex = useAppSelector(selectActiveTooltipIndex);
	var { data, dataKey, background: backgroundFromProps, allOtherBarProps } = props;
	var { onMouseEnter: onMouseEnterFromProps, onMouseLeave: onMouseLeaveFromProps, onClick: onItemClickFromProps } = allOtherBarProps, restOfAllOtherProps = _objectWithoutProperties$3(allOtherBarProps, _excluded$3);
	var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey, allOtherBarProps.id);
	var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
	var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey, allOtherBarProps.id);
	if (!backgroundFromProps || data == null) return null;
	var backgroundProps = svgPropertiesNoEventsFromUnknown(backgroundFromProps);
	return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: getZIndexFromUnknown(backgroundFromProps, DefaultZIndexes.barBackground) }, data.map((entry, i) => {
		var { value, background: backgroundFromDataEntry, tooltipPosition } = entry, rest = _objectWithoutProperties$3(entry, _excluded2$2);
		if (!backgroundFromDataEntry) return null;
		var onMouseEnter = onMouseEnterFromContext(entry, i);
		var onMouseLeave = onMouseLeaveFromContext(entry, i);
		var onClick = onClickFromContext(entry, i);
		var barRectangleProps = _objectSpread$4(_objectSpread$4(_objectSpread$4(_objectSpread$4(_objectSpread$4({
			option: backgroundFromProps,
			isActive: String(i) === activeIndex
		}, rest), {}, { fill: "#eee" }, backgroundFromDataEntry), backgroundProps), adaptEventsOfChild(restOfAllOtherProps, entry, i)), {}, {
			onMouseEnter,
			onMouseLeave,
			onClick,
			dataKey,
			index: i,
			className: "recharts-bar-background-rectangle"
		});
		return /* @__PURE__ */ import_react.createElement(BarRectangle, _extends$3({ key: "background-bar-".concat(i) }, barRectangleProps));
	}));
}
function BarLabelListProvider(_ref2) {
	var { showLabels, children, rects } = _ref2;
	var labelListEntries = rects === null || rects === void 0 ? void 0 : rects.map((entry) => {
		var viewBox = {
			x: entry.x,
			y: entry.y,
			width: entry.width,
			lowerWidth: entry.width,
			upperWidth: entry.width,
			height: entry.height
		};
		return _objectSpread$4(_objectSpread$4({}, viewBox), {}, {
			value: entry.value,
			payload: entry.payload,
			parentViewBox: entry.parentViewBox,
			viewBox,
			fill: entry.fill
		});
	});
	return /* @__PURE__ */ import_react.createElement(CartesianLabelListContextProvider, { value: showLabels ? labelListEntries : void 0 }, children);
}
function BarRectangleWithActiveState(props) {
	var { shape, activeBar, baseProps, entry, index, dataKey } = props;
	var activeIndex = useAppSelector(selectActiveTooltipIndex);
	var activeDataKey = useAppSelector(selectActiveTooltipDataKey);
	var isActive = activeBar && String(entry.originalDataIndex) === activeIndex && (activeDataKey == null || dataKey === activeDataKey);
	var [stayInLayer, setStayInLayer] = (0, import_react.useState)(false);
	var [hasMountedActive, setHasMountedActive] = (0, import_react.useState)(false);
	(0, import_react.useEffect)(() => {
		var rafId;
		if (isActive) {
			setStayInLayer(true);
			rafId = requestAnimationFrame(() => {
				setHasMountedActive(true);
			});
		} else setHasMountedActive(false);
		return () => {
			cancelAnimationFrame(rafId);
		};
	}, [isActive]);
	var handleTransitionEnd = (0, import_react.useCallback)(() => {
		if (!isActive) setStayInLayer(false);
	}, [isActive]);
	var isVisuallyActive = isActive && hasMountedActive;
	var shouldRenderInLayer = isActive || stayInLayer;
	var option;
	if (isActive) if (activeBar === true) option = shape;
	else option = activeBar;
	else option = shape;
	var content = /* @__PURE__ */ import_react.createElement(BarRectangle, _extends$3({}, baseProps, { name: String(baseProps.name) }, entry, {
		isActive: isVisuallyActive,
		option,
		index,
		dataKey,
		onTransitionEnd: handleTransitionEnd
	}));
	if (shouldRenderInLayer) return /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: DefaultZIndexes.activeBar }, /* @__PURE__ */ import_react.createElement(BarStackClipLayer, { index: entry.originalDataIndex }, content));
	return content;
}
function BarRectangleNeverActive(props) {
	var { shape, baseProps, entry, index, dataKey } = props;
	return /* @__PURE__ */ import_react.createElement(BarRectangle, _extends$3({}, baseProps, { name: String(baseProps.name) }, entry, {
		isActive: false,
		option: shape,
		index,
		dataKey
	}));
}
function BarRectangles(_ref3) {
	var _svgPropertiesNoEvent;
	var { data, props } = _ref3;
	var _ref4 = (_svgPropertiesNoEvent = svgPropertiesNoEvents(props)) !== null && _svgPropertiesNoEvent !== void 0 ? _svgPropertiesNoEvent : {}, { id } = _ref4, baseProps = _objectWithoutProperties$3(_ref4, _excluded3$1);
	var { shape, dataKey, activeBar } = props;
	var { onMouseEnter: onMouseEnterFromProps, onClick: onItemClickFromProps, onMouseLeave: onMouseLeaveFromProps } = props, restOfAllOtherProps = _objectWithoutProperties$3(props, _excluded4);
	var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey, id);
	var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
	var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey, id);
	if (!data) return null;
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, data.map((entry, i) => {
		return /* @__PURE__ */ import_react.createElement(BarStackClipLayer, _extends$3({
			index: entry.originalDataIndex,
			key: "rectangle-".concat(entry === null || entry === void 0 ? void 0 : entry.x, "-").concat(entry === null || entry === void 0 ? void 0 : entry.y, "-").concat(entry === null || entry === void 0 ? void 0 : entry.value, "-").concat(i),
			className: "recharts-bar-rectangle"
		}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
			onMouseEnter: onMouseEnterFromContext(entry, i),
			onMouseLeave: onMouseLeaveFromContext(entry, i),
			onClick: onClickFromContext(entry, i)
		}), activeBar ? /* @__PURE__ */ import_react.createElement(BarRectangleWithActiveState, {
			shape,
			activeBar,
			baseProps,
			entry,
			index: i,
			dataKey
		}) : /* @__PURE__ */ import_react.createElement(BarRectangleNeverActive, {
			shape,
			baseProps,
			entry,
			index: i,
			dataKey
		}));
	}));
}
function RectanglesWithAnimation(_ref5) {
	var { props, previousRectanglesRef } = _ref5;
	var { data, layout, isAnimationActive, animationBegin, animationDuration, animationEasing, onAnimationEnd, onAnimationStart } = props;
	var prevData = previousRectanglesRef.current;
	var animationId = useAnimationId(props, "recharts-bar-");
	var [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
	var showLabels = !isAnimating;
	var handleAnimationEnd = (0, import_react.useCallback)(() => {
		if (typeof onAnimationEnd === "function") onAnimationEnd();
		setIsAnimating(false);
	}, [onAnimationEnd]);
	var handleAnimationStart = (0, import_react.useCallback)(() => {
		if (typeof onAnimationStart === "function") onAnimationStart();
		setIsAnimating(true);
	}, [onAnimationStart]);
	return /* @__PURE__ */ import_react.createElement(BarLabelListProvider, {
		showLabels,
		rects: data
	}, /* @__PURE__ */ import_react.createElement(JavascriptAnimate, {
		animationId,
		begin: animationBegin,
		duration: animationDuration,
		isActive: isAnimationActive,
		easing: animationEasing,
		onAnimationEnd: handleAnimationEnd,
		onAnimationStart: handleAnimationStart,
		key: animationId
	}, (t) => {
		var stepData = t === 1 ? data : data === null || data === void 0 ? void 0 : data.map((entry, index) => {
			var prev = prevData && prevData[index];
			if (prev) return _objectSpread$4(_objectSpread$4({}, entry), {}, {
				x: interpolate(prev.x, entry.x, t),
				y: interpolate(prev.y, entry.y, t),
				width: interpolate(prev.width, entry.width, t),
				height: interpolate(prev.height, entry.height, t)
			});
			if (layout === "horizontal") {
				var height = interpolate(0, entry.height, t);
				var y = interpolate(entry.stackedBarStart, entry.y, t);
				return _objectSpread$4(_objectSpread$4({}, entry), {}, {
					y,
					height
				});
			}
			var w = interpolate(0, entry.width, t);
			var x = interpolate(entry.stackedBarStart, entry.x, t);
			return _objectSpread$4(_objectSpread$4({}, entry), {}, {
				width: w,
				x
			});
		});
		if (t > 0) previousRectanglesRef.current = stepData !== null && stepData !== void 0 ? stepData : null;
		if (stepData == null) return null;
		return /* @__PURE__ */ import_react.createElement(Layer, null, /* @__PURE__ */ import_react.createElement(BarRectangles, {
			props,
			data: stepData
		}));
	}), /* @__PURE__ */ import_react.createElement(LabelListFromLabelProp, { label: props.label }), props.children);
}
function RenderRectangles(props) {
	var previousRectanglesRef = (0, import_react.useRef)(null);
	return /* @__PURE__ */ import_react.createElement(RectanglesWithAnimation, {
		previousRectanglesRef,
		props
	});
}
var defaultMinPointSize = 0;
var errorBarDataPointFormatter = (dataPoint, dataKey) => {
	/**
	* if the value coming from `selectBarRectangles` is an array then this is a stacked bar chart.
	* arr[1] represents end value of the bar since the data is in the form of [startValue, endValue].
	* */
	var value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
	return {
		x: dataPoint.x,
		y: dataPoint.y,
		value,
		errorVal: getValueByDataKey(dataPoint, dataKey)
	};
};
var BarWithState = class extends import_react.PureComponent {
	render() {
		var { hide, data, dataKey, className, xAxisId, yAxisId, needClip, background, id } = this.props;
		if (hide || data == null) return null;
		var layerClass = clsx("recharts-bar", className);
		var clipPathId = id;
		return /* @__PURE__ */ import_react.createElement(Layer, {
			className: layerClass,
			id
		}, needClip && /* @__PURE__ */ import_react.createElement("defs", null, /* @__PURE__ */ import_react.createElement(GraphicalItemClipPath, {
			clipPathId,
			xAxisId,
			yAxisId
		})), /* @__PURE__ */ import_react.createElement(Layer, {
			className: "recharts-bar-rectangles",
			clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : void 0
		}, /* @__PURE__ */ import_react.createElement(BarBackground, {
			data,
			dataKey,
			background,
			allOtherBarProps: this.props
		}), /* @__PURE__ */ import_react.createElement(RenderRectangles, this.props)));
	}
};
var defaultBarProps = {
	activeBar: false,
	animationBegin: 0,
	animationDuration: 400,
	animationEasing: "ease",
	background: false,
	hide: false,
	isAnimationActive: "auto",
	label: false,
	legendType: "rect",
	minPointSize: defaultMinPointSize,
	xAxisId: 0,
	yAxisId: 0,
	zIndex: DefaultZIndexes.bar
};
function BarImpl(props) {
	var { xAxisId, yAxisId, hide, legendType, minPointSize, activeBar, animationBegin, animationDuration, animationEasing, isAnimationActive } = props;
	var { needClip } = useNeedsClip(xAxisId, yAxisId);
	var layout = useChartLayout();
	var isPanorama = useIsPanorama();
	var cells = findAllByType(props.children, Cell);
	var rects = useAppSelector((state) => selectBarRectangles(state, props.id, isPanorama, cells));
	if (layout !== "vertical" && layout !== "horizontal") return null;
	var errorBarOffset;
	var firstDataPoint = rects === null || rects === void 0 ? void 0 : rects[0];
	if (firstDataPoint == null || firstDataPoint.height == null || firstDataPoint.width == null) errorBarOffset = 0;
	else errorBarOffset = layout === "vertical" ? firstDataPoint.height / 2 : firstDataPoint.width / 2;
	return /* @__PURE__ */ import_react.createElement(SetErrorBarContext, {
		xAxisId,
		yAxisId,
		data: rects,
		dataPointFormatter: errorBarDataPointFormatter,
		errorBarOffset
	}, /* @__PURE__ */ import_react.createElement(BarWithState, _extends$3({}, props, {
		layout,
		needClip,
		data: rects,
		xAxisId,
		yAxisId,
		hide,
		legendType,
		minPointSize,
		activeBar,
		animationBegin,
		animationDuration,
		animationEasing,
		isAnimationActive
	})));
}
function computeBarRectangles(_ref6) {
	var { layout, barSettings: { dataKey, minPointSize: minPointSizeProp, hasCustomShape }, pos, bandSize, xAxis, yAxis, xAxisTicks, yAxisTicks, stackedData, displayedData, offset, cells, parentViewBox, dataStartIndex } = _ref6;
	var numericAxis = layout === "horizontal" ? yAxis : xAxis;
	var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
	var baseValue = getBaseValueOfBar({ numericAxis });
	var stackedBarStart = numericAxis.scale.map(baseValue);
	return displayedData.map((entry, index) => {
		var value, x, y, width, height, background;
		if (stackedData) {
			var untruncatedValue = stackedData[index + dataStartIndex];
			if (untruncatedValue == null) return null;
			value = truncateByDomain(untruncatedValue, stackedDomain);
		} else {
			value = getValueByDataKey(entry, dataKey);
			if (!Array.isArray(value)) value = [baseValue, value];
		}
		var minPointSize = minPointSizeCallback(minPointSizeProp, defaultMinPointSize)(value[1], index);
		if (layout === "horizontal") {
			var _ref7;
			var baseValueScale = yAxis.scale.map(value[0]);
			var currentValueScale = yAxis.scale.map(value[1]);
			if (baseValueScale == null || currentValueScale == null) return null;
			x = getCateCoordinateOfBar({
				axis: xAxis,
				ticks: xAxisTicks,
				bandSize,
				offset: pos.offset,
				entry,
				index
			});
			y = (_ref7 = currentValueScale !== null && currentValueScale !== void 0 ? currentValueScale : baseValueScale) !== null && _ref7 !== void 0 ? _ref7 : void 0;
			width = pos.size;
			var computedHeight = baseValueScale - currentValueScale;
			height = isNan(computedHeight) ? 0 : computedHeight;
			background = {
				x,
				y: offset.top,
				width,
				height: offset.height
			};
			if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
				var delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
				y -= delta;
				height += delta;
			}
		} else {
			var _baseValueScale = xAxis.scale.map(value[0]);
			var _currentValueScale = xAxis.scale.map(value[1]);
			if (_baseValueScale == null || _currentValueScale == null) return null;
			x = _baseValueScale;
			y = getCateCoordinateOfBar({
				axis: yAxis,
				ticks: yAxisTicks,
				bandSize,
				offset: pos.offset,
				entry,
				index
			});
			width = _currentValueScale - _baseValueScale;
			height = pos.size;
			background = {
				x: offset.left,
				y,
				width: offset.width,
				height
			};
			if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
				var _delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
				width += _delta;
			}
		}
		if (x == null || y == null || width == null || height == null || !hasCustomShape && (width === 0 || height === 0)) return null;
		return _objectSpread$4(_objectSpread$4({}, entry), {}, {
			stackedBarStart,
			x,
			y,
			width,
			height,
			value: stackedData ? value : value[1],
			payload: entry,
			background,
			tooltipPosition: {
				x: x + width / 2,
				y: y + height / 2
			},
			parentViewBox,
			originalDataIndex: index
		}, cells && cells[index] && cells[index].props);
	}).filter(Boolean);
}
function BarFn(outsideProps) {
	var props = resolveDefaultProps(outsideProps, defaultBarProps);
	var stackId = useStackId(props.stackId);
	var isPanorama = useIsPanorama();
	return /* @__PURE__ */ import_react.createElement(RegisterGraphicalItemId, {
		id: props.id,
		type: "bar"
	}, (id) => /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetLegendPayload, { legendPayload: computeLegendPayloadFromBarData(props) }), /* @__PURE__ */ import_react.createElement(SetBarTooltipEntrySettings, {
		dataKey: props.dataKey,
		stroke: props.stroke,
		strokeWidth: props.strokeWidth,
		fill: props.fill,
		name: props.name,
		hide: props.hide,
		unit: props.unit,
		tooltipType: props.tooltipType,
		id
	}), /* @__PURE__ */ import_react.createElement(SetCartesianGraphicalItem, {
		type: "bar",
		id,
		data: void 0,
		xAxisId: props.xAxisId,
		yAxisId: props.yAxisId,
		zAxisId: 0,
		dataKey: props.dataKey,
		stackId,
		hide: props.hide,
		barSize: props.barSize,
		minPointSize: props.minPointSize,
		maxBarSize: props.maxBarSize,
		isPanorama,
		hasCustomShape: props.shape != null
	}), /* @__PURE__ */ import_react.createElement(ZIndexLayer, { zIndex: props.zIndex }, /* @__PURE__ */ import_react.createElement(BarImpl, _extends$3({}, props, { id })))));
}
/**
* @provides ErrorBarContext
* @provides LabelListContext
* @provides CellReader
* @consumes CartesianChartContext
* @consumes BarStackContext
*/
var Bar = /* @__PURE__ */ import_react.memo(BarFn, propsAreEqual);
Bar.displayName = "Bar";
//#endregion
//#region ../../node_modules/recharts/es6/cartesian/XAxis.js
/**
* @fileOverview X Axis
*/
var _excluded$2 = ["type"], _excluded2$1 = [
	"dangerouslySetInnerHTML",
	"ticks",
	"scale"
], _excluded3 = ["id", "scale"];
function _extends$2() {
	return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$2.apply(null, arguments);
}
function ownKeys$3(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$3(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$3(Object(t), !0).forEach(function(r) {
			_defineProperty$3(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$3(e, r, t) {
	return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$3(t) {
	var i = _toPrimitive$3(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$3(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties$2(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$2(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$2(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function SetXAxisSettings(props) {
	var dispatch = useAppDispatch();
	var prevSettingsRef = (0, import_react.useRef)(null);
	var layout = useCartesianChartLayout();
	var { type: typeFromProps } = props, restProps = _objectWithoutProperties$2(props, _excluded$2);
	var evaluatedType = getAxisTypeBasedOnLayout(layout, "xAxis", typeFromProps);
	var settings = (0, import_react.useMemo)(() => {
		if (evaluatedType == null) return;
		return _objectSpread$3(_objectSpread$3({}, restProps), {}, { type: evaluatedType });
	}, [restProps, evaluatedType]);
	(0, import_react.useLayoutEffect)(() => {
		if (settings == null) return;
		if (prevSettingsRef.current === null) dispatch(addXAxis(settings));
		else if (prevSettingsRef.current !== settings) dispatch(replaceXAxis({
			prev: prevSettingsRef.current,
			next: settings
		}));
		prevSettingsRef.current = settings;
	}, [settings, dispatch]);
	(0, import_react.useLayoutEffect)(() => {
		return () => {
			if (prevSettingsRef.current) {
				dispatch(removeXAxis(prevSettingsRef.current));
				prevSettingsRef.current = null;
			}
		};
	}, [dispatch]);
	return null;
}
var XAxisImpl = (props) => {
	var { xAxisId, className } = props;
	var viewBox = useAppSelector(selectAxisViewBox);
	var isPanorama = useIsPanorama();
	var axisType = "xAxis";
	var cartesianTickItems = useAppSelector((state) => selectTicksOfAxis(state, axisType, xAxisId, isPanorama));
	var axisSize = useAppSelector((state) => selectXAxisSize(state, xAxisId));
	var position = useAppSelector((state) => selectXAxisPosition(state, xAxisId));
	var synchronizedSettings = useAppSelector((state) => selectXAxisSettingsNoDefaults(state, xAxisId));
	if (axisSize == null || position == null || synchronizedSettings == null) return null;
	var { dangerouslySetInnerHTML, ticks, scale: del } = props, allOtherProps = _objectWithoutProperties$2(props, _excluded2$1);
	var { id, scale: del2 } = synchronizedSettings, restSynchronizedSettings = _objectWithoutProperties$2(synchronizedSettings, _excluded3);
	return /* @__PURE__ */ import_react.createElement(CartesianAxis, _extends$2({}, allOtherProps, restSynchronizedSettings, {
		x: position.x,
		y: position.y,
		width: axisSize.width,
		height: axisSize.height,
		className: clsx("recharts-".concat(axisType, " ").concat(axisType), className),
		viewBox,
		ticks: cartesianTickItems,
		axisType,
		axisId: xAxisId
	}));
};
var xAxisDefaultProps = {
	allowDataOverflow: implicitXAxis.allowDataOverflow,
	allowDecimals: implicitXAxis.allowDecimals,
	allowDuplicatedCategory: implicitXAxis.allowDuplicatedCategory,
	angle: implicitXAxis.angle,
	axisLine: defaultCartesianAxisProps.axisLine,
	height: implicitXAxis.height,
	hide: false,
	includeHidden: implicitXAxis.includeHidden,
	interval: implicitXAxis.interval,
	label: false,
	minTickGap: implicitXAxis.minTickGap,
	mirror: implicitXAxis.mirror,
	orientation: implicitXAxis.orientation,
	padding: implicitXAxis.padding,
	reversed: implicitXAxis.reversed,
	scale: implicitXAxis.scale,
	tick: implicitXAxis.tick,
	tickCount: implicitXAxis.tickCount,
	tickLine: defaultCartesianAxisProps.tickLine,
	tickSize: defaultCartesianAxisProps.tickSize,
	type: implicitXAxis.type,
	niceTicks: implicitXAxis.niceTicks,
	xAxisId: 0
};
var XAxisSettingsDispatcher = (outsideProps) => {
	var props = resolveDefaultProps(outsideProps, xAxisDefaultProps);
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetXAxisSettings, {
		allowDataOverflow: props.allowDataOverflow,
		allowDecimals: props.allowDecimals,
		allowDuplicatedCategory: props.allowDuplicatedCategory,
		angle: props.angle,
		dataKey: props.dataKey,
		domain: props.domain,
		height: props.height,
		hide: props.hide,
		id: props.xAxisId,
		includeHidden: props.includeHidden,
		interval: props.interval,
		minTickGap: props.minTickGap,
		mirror: props.mirror,
		name: props.name,
		orientation: props.orientation,
		padding: props.padding,
		reversed: props.reversed,
		scale: props.scale,
		tick: props.tick,
		tickCount: props.tickCount,
		tickFormatter: props.tickFormatter,
		ticks: props.ticks,
		type: props.type,
		unit: props.unit,
		niceTicks: props.niceTicks
	}), /* @__PURE__ */ import_react.createElement(XAxisImpl, props));
};
/**
* @consumes CartesianViewBoxContext
* @provides CartesianLabelContext
*/
var XAxis = /* @__PURE__ */ import_react.memo(XAxisSettingsDispatcher, axisPropsAreEqual);
XAxis.displayName = "XAxis";
//#endregion
//#region ../../node_modules/recharts/es6/chart/LineChart.js
var allowedTooltipTypes$3 = ["axis"];
/**
* @consumes ResponsiveContainerContext
* @provides CartesianViewBoxContext
* @provides CartesianChartContext
*/
var LineChart = /* @__PURE__ */ (0, import_react.forwardRef)((props, ref) => {
	return /* @__PURE__ */ import_react.createElement(CartesianChart, {
		chartName: "LineChart",
		defaultTooltipEventType: "axis",
		validateTooltipEventTypes: allowedTooltipTypes$3,
		tooltipPayloadSearcher: arrayTooltipSearcher,
		categoricalChartProps: props,
		ref
	});
});
//#endregion
//#region ../../node_modules/recharts/es6/chart/BarChart.js
var allowedTooltipTypes$2 = ["axis", "item"];
/**
* @consumes ResponsiveContainerContext
* @provides CartesianViewBoxContext
* @provides CartesianChartContext
*/
var BarChart = /* @__PURE__ */ (0, import_react.forwardRef)((props, ref) => {
	return /* @__PURE__ */ import_react.createElement(CartesianChart, {
		chartName: "BarChart",
		defaultTooltipEventType: "axis",
		validateTooltipEventTypes: allowedTooltipTypes$2,
		tooltipPayloadSearcher: arrayTooltipSearcher,
		categoricalChartProps: props,
		ref
	});
});
//#endregion
//#region ../../node_modules/recharts/es6/state/ReportPolarOptions.js
function ReportPolarOptions(props) {
	var dispatch = useAppDispatch();
	(0, import_react.useEffect)(() => {
		dispatch(updatePolarOptions(props));
	}, [dispatch, props]);
	return null;
}
//#endregion
//#region ../../node_modules/recharts/es6/chart/PolarChart.js
var _excluded$1 = ["layout"];
function _extends$1() {
	return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends$1.apply(null, arguments);
}
function _objectWithoutProperties$1(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose$1(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose$1(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function ownKeys$2(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$2(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$2(Object(t), !0).forEach(function(r) {
			_defineProperty$2(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$2(e, r, t) {
	return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$2(t) {
	var i = _toPrimitive$2(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$2(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
/**
* These default props are the same for all PolarChart components.
*/
var defaultPolarChartProps = _objectSpread$2({
	accessibilityLayer: true,
	stackOffset: "none",
	barCategoryGap: "10%",
	barGap: 4,
	margin: {
		top: 5,
		right: 5,
		bottom: 5,
		left: 5
	},
	reverseStackOrder: false,
	syncMethod: "index",
	layout: "radial",
	responsive: false,
	cx: "50%",
	cy: "50%",
	innerRadius: 0,
	outerRadius: "80%"
}, initialEventSettingsState);
/**
* These props are required for the PolarChart to function correctly.
* Users usually would not need to specify these explicitly,
* because the convenience components like PieChart, RadarChart, etc.
* will provide these defaults.
* We can't have the defaults in this file because each of those convenience components
* have their own opinions about what they should be.
*/
/**
* These are one-time, immutable options that decide the chart's behavior.
* Users who wish to call CartesianChart may decide to pass these options explicitly,
* but usually we would expect that they use one of the convenience components like PieChart, RadarChart, etc.
*/
var PolarChart = /* @__PURE__ */ (0, import_react.forwardRef)(function PolarChart(props, ref) {
	var _polarChartProps$id;
	var polarChartProps = resolveDefaultProps(props.categoricalChartProps, defaultPolarChartProps);
	var { layout } = polarChartProps, otherCategoricalProps = _objectWithoutProperties$1(polarChartProps, _excluded$1);
	var { chartName, defaultTooltipEventType, validateTooltipEventTypes, tooltipPayloadSearcher } = props;
	var options = {
		chartName,
		defaultTooltipEventType,
		validateTooltipEventTypes,
		tooltipPayloadSearcher,
		eventEmitter: void 0
	};
	return /* @__PURE__ */ import_react.createElement(RechartsStoreProvider, {
		preloadedState: { options },
		reduxStoreName: (_polarChartProps$id = polarChartProps.id) !== null && _polarChartProps$id !== void 0 ? _polarChartProps$id : chartName
	}, /* @__PURE__ */ import_react.createElement(ChartDataContextProvider, { chartData: polarChartProps.data }), /* @__PURE__ */ import_react.createElement(ReportMainChartProps, {
		layout,
		margin: polarChartProps.margin
	}), /* @__PURE__ */ import_react.createElement(ReportEventSettings, {
		throttleDelay: polarChartProps.throttleDelay,
		throttledEvents: polarChartProps.throttledEvents
	}), /* @__PURE__ */ import_react.createElement(ReportChartProps, {
		baseValue: void 0,
		accessibilityLayer: polarChartProps.accessibilityLayer,
		barCategoryGap: polarChartProps.barCategoryGap,
		maxBarSize: polarChartProps.maxBarSize,
		stackOffset: polarChartProps.stackOffset,
		barGap: polarChartProps.barGap,
		barSize: polarChartProps.barSize,
		syncId: polarChartProps.syncId,
		syncMethod: polarChartProps.syncMethod,
		className: polarChartProps.className,
		reverseStackOrder: polarChartProps.reverseStackOrder
	}), /* @__PURE__ */ import_react.createElement(ReportPolarOptions, {
		cx: polarChartProps.cx,
		cy: polarChartProps.cy,
		startAngle: polarChartProps.startAngle,
		endAngle: polarChartProps.endAngle,
		innerRadius: polarChartProps.innerRadius,
		outerRadius: polarChartProps.outerRadius
	}), /* @__PURE__ */ import_react.createElement(CategoricalChart, _extends$1({}, otherCategoricalProps, { ref })));
});
//#endregion
//#region ../../node_modules/recharts/es6/chart/PieChart.js
function ownKeys$1(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread$1(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys$1(Object(t), !0).forEach(function(r) {
			_defineProperty$1(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty$1(e, r, t) {
	return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey$1(t) {
	var i = _toPrimitive$1(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive$1(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
var allowedTooltipTypes$1 = ["item"];
var defaultPieChartProps = _objectSpread$1(_objectSpread$1({}, defaultPolarChartProps), {}, {
	layout: "centric",
	startAngle: 0,
	endAngle: 360
});
/**
* @consumes ResponsiveContainerContext
* @provides PolarViewBoxContext
* @provides PolarChartContext
*/
var PieChart = /* @__PURE__ */ (0, import_react.forwardRef)((props, ref) => {
	var propsWithDefaults = resolveDefaultProps(props, defaultPieChartProps);
	return /* @__PURE__ */ import_react.createElement(PolarChart, {
		chartName: "PieChart",
		defaultTooltipEventType: "item",
		validateTooltipEventTypes: allowedTooltipTypes$1,
		tooltipPayloadSearcher: arrayTooltipSearcher,
		categoricalChartProps: propsWithDefaults,
		ref
	});
});
//#endregion
//#region ../../node_modules/es-toolkit/dist/compat/math/sumBy.js
var require_sumBy$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
	var iteratee = require_iteratee();
	function sumBy(array, iteratee$1) {
		if (!array || !array.length) return 0;
		if (iteratee$1 != null) iteratee$1 = iteratee.iteratee(iteratee$1);
		let result = void 0;
		for (let i = 0; i < array.length; i++) {
			const current = iteratee$1 ? iteratee$1(array[i]) : array[i];
			if (current !== void 0) if (result === void 0) result = current;
			else result += current;
		}
		return result;
	}
	exports.sumBy = sumBy;
}));
//#endregion
//#region ../../node_modules/es-toolkit/compat/sumBy.js
var require_sumBy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	module.exports = require_sumBy$1().sumBy;
}));
//#endregion
//#region ../../node_modules/recharts/es6/chart/Sankey.js
var import_maxBy = /* @__PURE__ */ __toESM(require_maxBy());
var import_sumBy = /* @__PURE__ */ __toESM(require_sumBy());
var _excluded = [
	"sourceX",
	"sourceY",
	"sourceControlX",
	"targetX",
	"targetY",
	"targetControlX",
	"linkWidth"
], _excluded2 = [
	"className",
	"style",
	"children",
	"id"
];
function _extends() {
	return _extends = Object.assign ? Object.assign.bind() : function(n) {
		for (var e = 1; e < arguments.length; e++) {
			var t = arguments[e];
			for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
		}
		return n;
	}, _extends.apply(null, arguments);
}
function _objectWithoutProperties(e, t) {
	if (null == e) return {};
	var o, r, i = _objectWithoutPropertiesLoose(e, t);
	if (Object.getOwnPropertySymbols) {
		var n = Object.getOwnPropertySymbols(e);
		for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
	}
	return i;
}
function _objectWithoutPropertiesLoose(r, e) {
	if (null == r) return {};
	var t = {};
	for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
		if (-1 !== e.indexOf(n)) continue;
		t[n] = r[n];
	}
	return t;
}
function ownKeys(e, r) {
	var t = Object.keys(e);
	if (Object.getOwnPropertySymbols) {
		var o = Object.getOwnPropertySymbols(e);
		r && (o = o.filter(function(r) {
			return Object.getOwnPropertyDescriptor(e, r).enumerable;
		})), t.push.apply(t, o);
	}
	return t;
}
function _objectSpread(e) {
	for (var r = 1; r < arguments.length; r++) {
		var t = null != arguments[r] ? arguments[r] : {};
		r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
			_defineProperty(e, r, t[r]);
		}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
			Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
		});
	}
	return e;
}
function _defineProperty(e, r, t) {
	return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
		value: t,
		enumerable: !0,
		configurable: !0,
		writable: !0
	}) : e[r] = t, e;
}
function _toPropertyKey(t) {
	var i = _toPrimitive(t, "string");
	return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive(t, r) {
	if ("object" != typeof t || !t) return t;
	var e = t[Symbol.toPrimitive];
	if (void 0 !== e) {
		var i = e.call(t, r || "default");
		if ("object" != typeof i) return i;
		throw new TypeError("@@toPrimitive must return a primitive value.");
	}
	return ("string" === r ? String : Number)(t);
}
var interpolationGenerator = (a, b) => {
	var ka = +a;
	var kb = b - ka;
	return (t) => ka + kb * t;
};
var centerY = (node) => node.y + node.dy / 2;
var getValue = (entry) => entry && entry.value || 0;
var getSumOfIds = (links, ids) => ids.reduce((result, id) => result + getValue(links[id]), 0);
var getSumWithWeightedSource = (tree, links, ids) => ids.reduce((result, id) => {
	var link = links[id];
	if (link == null) return result;
	var sourceNode = tree[link.source];
	if (sourceNode == null) return result;
	return result + centerY(sourceNode) * getValue(links[id]);
}, 0);
var getSumWithWeightedTarget = (tree, links, ids) => ids.reduce((result, id) => {
	var link = links[id];
	if (link == null) return result;
	var targetNode = tree[link.target];
	if (targetNode == null) return result;
	return result + centerY(targetNode) * getValue(links[id]);
}, 0);
var ascendingY = (a, b) => a.y - b.y;
var searchTargetsAndSources = (links, id) => {
	var sourceNodes = [];
	var sourceLinks = [];
	var targetNodes = [];
	var targetLinks = [];
	for (var i = 0, len = links.length; i < len; i++) {
		var link = links[i];
		if ((link === null || link === void 0 ? void 0 : link.source) === id) {
			targetNodes.push(link.target);
			targetLinks.push(i);
		}
		if ((link === null || link === void 0 ? void 0 : link.target) === id) {
			sourceNodes.push(link.source);
			sourceLinks.push(i);
		}
	}
	return {
		sourceNodes,
		sourceLinks,
		targetLinks,
		targetNodes
	};
};
var updateDepthOfTargets = (tree, curNode) => {
	var { targetNodes } = curNode;
	for (var i = 0, len = targetNodes.length; i < len; i++) {
		var targetNode = targetNodes[i];
		if (targetNode == null) continue;
		var target = tree[targetNode];
		if (target) {
			target.depth = Math.max(curNode.depth + 1, target.depth);
			updateDepthOfTargets(tree, target);
		}
	}
};
var getNodesTree = (_ref, width, nodeWidth, align) => {
	var _maxBy$depth, _maxBy;
	var { nodes, links } = _ref;
	var tree = nodes.map((entry, index) => {
		var result = searchTargetsAndSources(links, index);
		return _objectSpread(_objectSpread(_objectSpread({}, entry), result), {}, {
			value: Math.max(getSumOfIds(links, result.sourceLinks), getSumOfIds(links, result.targetLinks)),
			depth: 0
		});
	});
	for (var i = 0, len = tree.length; i < len; i++) {
		var node = tree[i];
		if (node != null && !node.sourceNodes.length) updateDepthOfTargets(tree, node);
	}
	var maxDepth = (_maxBy$depth = (_maxBy = (0, import_maxBy.default)(tree, (entry) => entry.depth)) === null || _maxBy === void 0 ? void 0 : _maxBy.depth) !== null && _maxBy$depth !== void 0 ? _maxBy$depth : 0;
	if (maxDepth >= 1) {
		var childWidth = (width - nodeWidth) / maxDepth;
		for (var _i = 0, _len = tree.length; _i < _len; _i++) {
			var _node = tree[_i];
			if (_node == null) continue;
			if (!_node.targetNodes.length) {
				if (align === "justify") _node.depth = maxDepth;
			}
			_node.x = _node.depth * childWidth;
			_node.dx = nodeWidth;
		}
	}
	return {
		tree,
		maxDepth
	};
};
var getDepthTree = (tree) => {
	var result = [];
	for (var i = 0, len = tree.length; i < len; i++) {
		var _result$node$depth;
		var node = tree[i];
		if (node == null) continue;
		if (!result[node.depth]) result[node.depth] = [];
		(_result$node$depth = result[node.depth]) === null || _result$node$depth === void 0 || _result$node$depth.push(node);
	}
	return result;
};
var updateYOfTree = (depthTree, height, nodePadding, links, verticalAlign) => {
	var yRatio = Math.min(...depthTree.map((nodes) => (height - (nodes.length - 1) * nodePadding) / (0, import_sumBy.default)(nodes, getValue)));
	for (var d = 0, maxDepth = depthTree.length; d < maxDepth; d++) {
		var nodes = depthTree[d];
		if (nodes == null) continue;
		if (verticalAlign === "top") {
			var currentY = 0;
			for (var i = 0, len = nodes.length; i < len; i++) {
				var node = nodes[i];
				if (node == null) continue;
				node.dy = node.value * yRatio;
				node.y = currentY;
				currentY += node.dy + nodePadding;
			}
		} else for (var _i2 = 0, _len2 = nodes.length; _i2 < _len2; _i2++) {
			var _node2 = nodes[_i2];
			if (_node2 == null) continue;
			_node2.y = _i2;
			_node2.dy = _node2.value * yRatio;
		}
	}
	return links.map((link) => _objectSpread(_objectSpread({}, link), {}, { dy: getValue(link) * yRatio }));
};
var resolveCollisions = function resolveCollisions(depthTree, height, nodePadding) {
	var sort = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : true;
	for (var i = 0, len = depthTree.length; i < len; i++) {
		var nodes = depthTree[i];
		if (nodes == null) continue;
		var n = nodes.length;
		if (sort) nodes.sort(ascendingY);
		var y0 = 0;
		for (var j = 0; j < n; j++) {
			var node = nodes[j];
			if (node == null) continue;
			var dy = y0 - node.y;
			if (dy > 0) node.y += dy;
			y0 = node.y + node.dy + nodePadding;
		}
		y0 = height + nodePadding;
		for (var _j = n - 1; _j >= 0; _j--) {
			var _node3 = nodes[_j];
			if (_node3 == null) continue;
			var _dy = _node3.y + _node3.dy + nodePadding - y0;
			if (_dy > 0) {
				_node3.y -= _dy;
				y0 = _node3.y;
			} else break;
		}
	}
};
var relaxLeftToRight = (tree, depthTree, links, alpha) => {
	for (var i = 0, maxDepth = depthTree.length; i < maxDepth; i++) {
		var nodes = depthTree[i];
		if (nodes == null) continue;
		for (var j = 0, len = nodes.length; j < len; j++) {
			var node = nodes[j];
			if (node == null) continue;
			if (node.sourceLinks.length) {
				var sourceSum = getSumOfIds(links, node.sourceLinks);
				var y = getSumWithWeightedSource(tree, links, node.sourceLinks) / sourceSum;
				node.y += (y - centerY(node)) * alpha;
			}
		}
	}
};
var relaxRightToLeft = (tree, depthTree, links, alpha) => {
	for (var i = depthTree.length - 1; i >= 0; i--) {
		var nodes = depthTree[i];
		if (nodes == null) continue;
		for (var j = 0, len = nodes.length; j < len; j++) {
			var node = nodes[j];
			if (node == null) continue;
			if (node.targetLinks.length) {
				var targetSum = getSumOfIds(links, node.targetLinks);
				var y = getSumWithWeightedTarget(tree, links, node.targetLinks) / targetSum;
				node.y += (y - centerY(node)) * alpha;
			}
		}
	}
};
var updateYOfLinks = (tree, links) => {
	for (var i = 0, len = tree.length; i < len; i++) {
		var node = tree[i];
		if (node == null) continue;
		var sy = 0;
		var ty = 0;
		node.targetLinks.sort((a, b) => {
			var _links$a, _links$b, _tree$targetA, _tree$targetB;
			var targetA = (_links$a = links[a]) === null || _links$a === void 0 ? void 0 : _links$a.target;
			var targetB = (_links$b = links[b]) === null || _links$b === void 0 ? void 0 : _links$b.target;
			if (targetA == null || targetB == null) return 0;
			var yA = (_tree$targetA = tree[targetA]) === null || _tree$targetA === void 0 ? void 0 : _tree$targetA.y;
			var yB = (_tree$targetB = tree[targetB]) === null || _tree$targetB === void 0 ? void 0 : _tree$targetB.y;
			if (yA == null || yB == null) return 0;
			return yA - yB;
		});
		node.sourceLinks.sort((a, b) => {
			var _links$a2, _links$b2, _tree$sourceA, _tree$sourceB;
			var sourceA = (_links$a2 = links[a]) === null || _links$a2 === void 0 ? void 0 : _links$a2.source;
			var sourceB = (_links$b2 = links[b]) === null || _links$b2 === void 0 ? void 0 : _links$b2.source;
			if (sourceA == null || sourceB == null) return 0;
			var yA = (_tree$sourceA = tree[sourceA]) === null || _tree$sourceA === void 0 ? void 0 : _tree$sourceA.y;
			var yB = (_tree$sourceB = tree[sourceB]) === null || _tree$sourceB === void 0 ? void 0 : _tree$sourceB.y;
			if (yA == null || yB == null) return 0;
			return yA - yB;
		});
		for (var j = 0, tLen = node.targetLinks.length; j < tLen; j++) {
			var targetLink = node.targetLinks[j];
			if (targetLink == null) continue;
			var link = links[targetLink];
			if (link) {
				link.sy = sy;
				sy += link.dy;
			}
		}
		for (var _j2 = 0, sLen = node.sourceLinks.length; _j2 < sLen; _j2++) {
			var sourceLink = node.sourceLinks[_j2];
			if (sourceLink == null) continue;
			var _link = links[sourceLink];
			if (_link) {
				_link.ty = ty;
				ty += _link.dy;
			}
		}
	}
};
var computeData = (_ref2) => {
	var { data, width, height, iterations, nodeWidth, nodePadding, sort, verticalAlign, align } = _ref2;
	var { links } = data;
	var { tree } = getNodesTree(data, width, nodeWidth, align);
	var depthTree = getDepthTree(tree);
	var linksWithDy = updateYOfTree(depthTree, height, nodePadding, links, verticalAlign);
	resolveCollisions(depthTree, height, nodePadding, sort);
	if (verticalAlign === "justify") {
		var alpha = 1;
		for (var i = 1; i <= iterations; i++) {
			relaxRightToLeft(tree, depthTree, linksWithDy, alpha *= .99);
			resolveCollisions(depthTree, height, nodePadding, sort);
			relaxLeftToRight(tree, depthTree, linksWithDy, alpha);
			resolveCollisions(depthTree, height, nodePadding, sort);
		}
	}
	updateYOfLinks(tree, linksWithDy);
	return {
		nodes: tree,
		links: linksWithDy
	};
};
var getNodeCoordinateOfTooltip = (item) => {
	return {
		x: +item.x + +item.width / 2,
		y: +item.y + +item.height / 2
	};
};
var getLinkCoordinateOfTooltip = (item) => {
	return "sourceX" in item ? {
		x: (item.sourceX + item.targetX) / 2,
		y: (item.sourceY + item.targetY) / 2
	} : void 0;
};
var getPayloadOfTooltip = (item, type, nameKey) => {
	var { payload } = item;
	if (type === "node") return {
		payload,
		name: getValueByDataKey(payload, nameKey, ""),
		value: getValueByDataKey(payload, "value")
	};
	if ("source" in payload && payload.source && payload.target) {
		var sourceName = getValueByDataKey(payload.source, nameKey, "");
		var targetName = getValueByDataKey(payload.target, nameKey, "");
		return {
			payload,
			name: "".concat(sourceName, " - ").concat(targetName),
			value: getValueByDataKey(payload, "value")
		};
	}
};
var sankeyPayloadSearcher = (_, activeIndex, computedData, nameKey) => {
	if (activeIndex == null || typeof activeIndex !== "string") return;
	if (computedData == null || typeof computedData !== "object") return;
	var [targetType, index] = activeIndex.split("-");
	var item = (0, import_get.default)(computedData, "".concat(targetType, "s[").concat(index, "]"));
	if (item) return getPayloadOfTooltip(item, targetType, nameKey);
};
var options = {
	chartName: "Sankey",
	defaultTooltipEventType: "item",
	validateTooltipEventTypes: ["item"],
	tooltipPayloadSearcher: sankeyPayloadSearcher,
	eventEmitter: void 0
};
var SetSankeyTooltipEntrySettings = /* @__PURE__ */ import_react.memo((_ref3) => {
	var { dataKey, nameKey, stroke, strokeWidth, fill, name, data, id } = _ref3;
	var tooltipEntrySettings = {
		dataDefinedOnItem: data,
		getPosition: noop$1,
		settings: {
			stroke,
			strokeWidth,
			fill,
			dataKey,
			name,
			nameKey,
			hide: false,
			type: void 0,
			color: fill,
			unit: "",
			graphicalItemId: id
		}
	};
	return /* @__PURE__ */ import_react.createElement(SetTooltipEntrySettings, { tooltipEntrySettings });
});
function renderLinkItem(option, props) {
	if (/* @__PURE__ */ import_react.isValidElement(option)) return /* @__PURE__ */ import_react.cloneElement(option, props);
	if (typeof option === "function") return option(props);
	var { sourceX, sourceY, sourceControlX, targetX, targetY, targetControlX, linkWidth } = props, others = _objectWithoutProperties(props, _excluded);
	return /* @__PURE__ */ import_react.createElement("path", _extends({
		className: "recharts-sankey-link",
		d: "\n          M".concat(sourceX, ",").concat(sourceY, "\n          C").concat(sourceControlX, ",").concat(sourceY, " ").concat(targetControlX, ",").concat(targetY, " ").concat(targetX, ",").concat(targetY, "\n        "),
		fill: "none",
		stroke: "#333",
		strokeWidth: linkWidth,
		strokeOpacity: "0.2"
	}, svgPropertiesNoEvents(others)));
}
var buildLinkProps = (_ref4) => {
	var { link, nodes, left, top, i, linkContent, linkCurvature } = _ref4;
	var { sy: sourceRelativeY, ty: targetRelativeY, dy: linkWidth } = link;
	var sourceNode = nodes[link.source];
	var targetNode = nodes[link.target];
	if (sourceNode == null || targetNode == null) return;
	var sourceX = sourceNode.x + sourceNode.dx + left;
	var targetX = targetNode.x + left;
	var interpolationFunc = interpolationGenerator(sourceX, targetX);
	var sourceControlX = interpolationFunc(linkCurvature);
	var targetControlX = interpolationFunc(1 - linkCurvature);
	return _objectSpread({
		sourceX,
		targetX,
		sourceY: sourceNode.y + sourceRelativeY + linkWidth / 2 + top,
		targetY: targetNode.y + targetRelativeY + linkWidth / 2 + top,
		sourceControlX,
		targetControlX,
		sourceRelativeY,
		targetRelativeY,
		linkWidth,
		index: i,
		payload: _objectSpread(_objectSpread({}, link), {}, {
			source: sourceNode,
			target: targetNode
		})
	}, svgPropertiesNoEventsFromUnknown(linkContent));
};
function SankeyLinkElement(_ref5) {
	var { graphicalItemId, props, i, linkContent, onMouseEnter: _onMouseEnter, onMouseLeave: _onMouseLeave, onClick: _onClick, dataKey } = _ref5;
	var activeCoordinate = getLinkCoordinateOfTooltip(props);
	var activeIndex = "link-".concat(i);
	var dispatch = useAppDispatch();
	return /* @__PURE__ */ import_react.createElement(Layer, {
		onMouseEnter: (e) => {
			dispatch(setActiveMouseOverItemIndex({
				activeIndex,
				activeDataKey: dataKey,
				activeCoordinate,
				activeGraphicalItemId: graphicalItemId
			}));
			_onMouseEnter(props, e);
		},
		onMouseLeave: (e) => {
			dispatch(mouseLeaveItem());
			_onMouseLeave(props, e);
		},
		onClick: (e) => {
			dispatch(setActiveClickItemIndex({
				activeIndex,
				activeDataKey: dataKey,
				activeCoordinate,
				activeGraphicalItemId: graphicalItemId
			}));
			_onClick(props, e);
		}
	}, renderLinkItem(linkContent, props));
}
function AllSankeyLinkElements(_ref6) {
	var { graphicalItemId, modifiedLinks, links, linkContent, onMouseEnter, onMouseLeave, onClick, dataKey } = _ref6;
	return /* @__PURE__ */ import_react.createElement(Layer, {
		className: "recharts-sankey-links",
		key: "recharts-sankey-links"
	}, links.map((link, i) => {
		var linkProps = modifiedLinks[i];
		if (linkProps == null) return null;
		return /* @__PURE__ */ import_react.createElement(SankeyLinkElement, {
			graphicalItemId,
			key: "link-".concat(link.source, "-").concat(link.target, "-").concat(link.value),
			props: linkProps,
			linkContent,
			i,
			onMouseEnter,
			onMouseLeave,
			onClick,
			dataKey
		});
	}));
}
function renderNodeItem(option, props) {
	if (/* @__PURE__ */ import_react.isValidElement(option)) return /* @__PURE__ */ import_react.cloneElement(option, props);
	if (typeof option === "function") return option(props);
	return /* @__PURE__ */ import_react.createElement(Rectangle, _extends({
		className: "recharts-sankey-node",
		fill: "#0088fe",
		fillOpacity: "0.8"
	}, svgPropertiesNoEvents(props)));
}
var buildNodeProps = (_ref7) => {
	var { node, nodeContent, top, left, i } = _ref7;
	var { x, y, dx, dy } = node;
	return _objectSpread(_objectSpread({}, svgPropertiesNoEventsFromUnknown(nodeContent)), {}, {
		x: x + left,
		y: y + top,
		width: dx,
		height: dy,
		index: i,
		payload: node
	});
};
function NodeElement(_ref8) {
	var { graphicalItemId, props, nodeContent, i, onMouseEnter: _onMouseEnter2, onMouseLeave: _onMouseLeave2, onClick: _onClick2, dataKey } = _ref8;
	var dispatch = useAppDispatch();
	var activeCoordinate = getNodeCoordinateOfTooltip(props);
	var activeIndex = "node-".concat(i);
	return /* @__PURE__ */ import_react.createElement(Layer, {
		onMouseEnter: (e) => {
			dispatch(setActiveMouseOverItemIndex({
				activeIndex,
				activeDataKey: dataKey,
				activeCoordinate,
				activeGraphicalItemId: graphicalItemId
			}));
			_onMouseEnter2(props, e);
		},
		onMouseLeave: (e) => {
			dispatch(mouseLeaveItem());
			_onMouseLeave2(props, e);
		},
		onClick: (e) => {
			dispatch(setActiveClickItemIndex({
				activeIndex,
				activeDataKey: dataKey,
				activeCoordinate,
				activeGraphicalItemId: graphicalItemId
			}));
			_onClick2(props, e);
		}
	}, renderNodeItem(nodeContent, props));
}
function AllNodeElements(_ref9) {
	var { graphicalItemId, modifiedNodes, nodeContent, onMouseEnter, onMouseLeave, onClick, dataKey } = _ref9;
	return /* @__PURE__ */ import_react.createElement(Layer, {
		className: "recharts-sankey-nodes",
		key: "recharts-sankey-nodes"
	}, modifiedNodes.map((modifiedNode, i) => {
		return /* @__PURE__ */ import_react.createElement(NodeElement, {
			graphicalItemId,
			key: "node-".concat(modifiedNode.index, "-").concat(modifiedNode.x, "-").concat(modifiedNode.y),
			props: modifiedNode,
			nodeContent,
			i,
			onMouseEnter,
			onMouseLeave,
			onClick,
			dataKey
		});
	}));
}
var sankeyDefaultProps = _objectSpread({
	align: "justify",
	dataKey: "value",
	iterations: 32,
	linkCurvature: .5,
	margin: {
		top: 5,
		right: 5,
		bottom: 5,
		left: 5
	},
	nameKey: "name",
	nodePadding: 10,
	nodeWidth: 10,
	sort: true,
	verticalAlign: "justify"
}, initialEventSettingsState);
function SankeyImpl(props) {
	var { className, style, children, id } = props, others = _objectWithoutProperties(props, _excluded2);
	var { link, dataKey, node, onMouseEnter, onMouseLeave, onClick, data, iterations, nodeWidth, nodePadding, sort, linkCurvature, margin, verticalAlign, align } = props;
	var attrs = svgPropertiesNoEvents(others);
	var width = useChartWidth();
	var height = useChartHeight();
	var { links, modifiedLinks, modifiedNodes } = (0, import_react.useMemo)(() => {
		var _margin$left, _margin$right, _margin$top, _margin$bottom;
		if (!data || !width || !height || width <= 0 || height <= 0) return {
			nodes: [],
			links: [],
			modifiedLinks: [],
			modifiedNodes: []
		};
		var computed = computeData({
			data,
			width: width - ((_margin$left = margin.left) !== null && _margin$left !== void 0 ? _margin$left : 0) - ((_margin$right = margin.right) !== null && _margin$right !== void 0 ? _margin$right : 0),
			height: height - ((_margin$top = margin.top) !== null && _margin$top !== void 0 ? _margin$top : 0) - ((_margin$bottom = margin.bottom) !== null && _margin$bottom !== void 0 ? _margin$bottom : 0),
			iterations,
			nodeWidth,
			nodePadding,
			sort,
			verticalAlign,
			align
		});
		var top = margin.top || 0;
		var left = margin.left || 0;
		var newModifiedLinks = computed.links.map((l, i) => {
			return buildLinkProps({
				link: l,
				nodes: computed.nodes,
				i,
				top,
				left,
				linkContent: link,
				linkCurvature
			});
		}).filter(isNotNil);
		var newModifiedNodes = computed.nodes.map((n, i) => {
			return buildNodeProps({
				node: n,
				nodeContent: node,
				i,
				top,
				left
			});
		});
		return {
			nodes: computed.nodes,
			links: computed.links,
			modifiedLinks: newModifiedLinks,
			modifiedNodes: newModifiedNodes
		};
	}, [
		data,
		width,
		height,
		margin,
		iterations,
		nodeWidth,
		nodePadding,
		sort,
		link,
		node,
		linkCurvature,
		align,
		verticalAlign
	]);
	var handleMouseEnter = (0, import_react.useCallback)((item, type, e) => {
		if (onMouseEnter) onMouseEnter(item, type, e);
	}, [onMouseEnter]);
	var handleMouseLeave = (0, import_react.useCallback)((item, type, e) => {
		if (onMouseLeave) onMouseLeave(item, type, e);
	}, [onMouseLeave]);
	var handleClick = (0, import_react.useCallback)((item, type, e) => {
		if (onClick) onClick(item, type, e);
	}, [onClick]);
	if (!isPositiveNumber(width) || !isPositiveNumber(height) || !data || !data.links || !data.nodes) return null;
	return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetComputedData, { computedData: {
		links: modifiedLinks,
		nodes: modifiedNodes
	} }), /* @__PURE__ */ import_react.createElement(Surface, _extends({}, attrs, {
		width,
		height
	}), children, /* @__PURE__ */ import_react.createElement(AllSankeyLinkElements, {
		graphicalItemId: id,
		links,
		modifiedLinks,
		linkContent: link,
		dataKey,
		onMouseEnter: (linkProps, e) => handleMouseEnter(linkProps, "link", e),
		onMouseLeave: (linkProps, e) => handleMouseLeave(linkProps, "link", e),
		onClick: (linkProps, e) => handleClick(linkProps, "link", e)
	}), /* @__PURE__ */ import_react.createElement(AllNodeElements, {
		graphicalItemId: id,
		modifiedNodes,
		nodeContent: node,
		dataKey,
		onMouseEnter: (nodeProps, e) => handleMouseEnter(nodeProps, "node", e),
		onMouseLeave: (nodeProps, e) => handleMouseLeave(nodeProps, "node", e),
		onClick: (nodeProps, e) => handleClick(nodeProps, "node", e)
	})));
}
/**
* Flow diagram in which the width of the arrows is proportional to the flow rate.
* It is typically used to visualize energy or material or cost transfers between processes.
*
* @consumes ResponsiveContainerContext
* @provides TooltipEntrySettings
*/
function Sankey$1(outsideProps) {
	var props = resolveDefaultProps(outsideProps, sankeyDefaultProps);
	var { width, height, style, className, id: externalId, throttleDelay, throttledEvents } = props;
	var [tooltipPortal, setTooltipPortal] = (0, import_react.useState)(null);
	return /* @__PURE__ */ import_react.createElement(RechartsStoreProvider, {
		preloadedState: { options },
		reduxStoreName: className !== null && className !== void 0 ? className : "Sankey"
	}, /* @__PURE__ */ import_react.createElement(ReportChartSize, {
		width,
		height
	}), /* @__PURE__ */ import_react.createElement(ReportChartMargin, { margin: props.margin }), /* @__PURE__ */ import_react.createElement(ReportEventSettings, {
		throttleDelay,
		throttledEvents
	}), /* @__PURE__ */ import_react.createElement(RechartsWrapper, {
		className,
		style,
		width,
		height,
		responsive: false,
		ref: (node) => {
			if (node && !tooltipPortal) setTooltipPortal(node);
		},
		onMouseEnter: void 0,
		onMouseLeave: void 0,
		onClick: void 0,
		onMouseMove: void 0,
		onMouseDown: void 0,
		onMouseUp: void 0,
		onContextMenu: void 0,
		onDoubleClick: void 0,
		onTouchStart: void 0,
		onTouchMove: void 0,
		onTouchEnd: void 0
	}, /* @__PURE__ */ import_react.createElement(TooltipPortalContext.Provider, { value: tooltipPortal }, /* @__PURE__ */ import_react.createElement(RegisterGraphicalItemId, {
		id: externalId,
		type: "sankey"
	}, (id) => /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, /* @__PURE__ */ import_react.createElement(SetSankeyTooltipEntrySettings, {
		dataKey: props.dataKey,
		nameKey: props.nameKey,
		stroke: props.stroke,
		strokeWidth: props.strokeWidth,
		fill: props.fill,
		name: props.name,
		data: props.data,
		id
	}), /* @__PURE__ */ import_react.createElement(SankeyImpl, _extends({}, props, { id })))))));
}
Sankey$1.displayName = "Sankey";
//#endregion
//#region ../../node_modules/recharts/es6/chart/ComposedChart.js
var allowedTooltipTypes = ["axis"];
/**
* @consumes ResponsiveContainerContext
* @provides CartesianViewBoxContext
* @provides CartesianChartContext
*/
var ComposedChart = /* @__PURE__ */ (0, import_react.forwardRef)((props, ref) => {
	return /* @__PURE__ */ import_react.createElement(CartesianChart, {
		chartName: "ComposedChart",
		defaultTooltipEventType: "axis",
		validateTooltipEventTypes: allowedTooltipTypes,
		tooltipPayloadSearcher: arrayTooltipSearcher,
		categoricalChartProps: props,
		ref
	});
});
//#endregion
//#region src/components/EditablePageHeaderTitle.tsx
var import_compiler_runtime = require_compiler_runtime();
var import_jsx_runtime = require_jsx_runtime();
function EditablePageHeaderTitle(t0) {
	const $ = (0, import_compiler_runtime.c)(17);
	const { title: initialTitle, onSave } = t0;
	const [isEditing, setIsEditing] = (0, import_react.useState)(false);
	const [title, setTitle] = (0, import_react.useState)(initialTitle);
	let t1;
	let t2;
	if ($[0] !== initialTitle) {
		t1 = () => setTitle(initialTitle);
		t2 = [initialTitle];
		$[0] = initialTitle;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	(0, import_react.useEffect)(t1, t2);
	let t3;
	if ($[3] !== onSave) {
		t3 = (newValue) => {
			onSave(newValue);
			setTitle(newValue);
			setIsEditing(false);
		};
		$[3] = onSave;
		$[4] = t3;
	} else t3 = $[4];
	const onSaveValue = t3;
	if (isEditing) {
		let t4;
		if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = () => setIsEditing(false);
			$[5] = t4;
		} else t4 = $[5];
		const t5 = Math.max(20, title.length) + "ch";
		let t6;
		if ($[6] !== t5) {
			t6 = {
				fontSize: 25,
				fontWeight: 500,
				marginTop: -3,
				marginBottom: -3,
				marginLeft: -6,
				paddingTop: 2,
				paddingBottom: 2,
				width: t5
			};
			$[6] = t5;
			$[7] = t6;
		} else t6 = $[7];
		let t7;
		if ($[8] !== onSaveValue || $[9] !== t6 || $[10] !== title) {
			t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InitialFocus, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
				defaultValue: title,
				onEnter: onSaveValue,
				onUpdate: onSaveValue,
				onEscape: t4,
				style: t6
			}) });
			$[8] = onSaveValue;
			$[9] = t6;
			$[10] = title;
			$[11] = t7;
		} else t7 = $[11];
		return t7;
	}
	let t4;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			flexDirection: "row",
			alignItems: "center",
			gap: 3,
			"& .hover-visible": {
				opacity: 0,
				transition: "opacity .25s"
			},
			"&:hover .hover-visible": { opacity: 1 }
		};
		$[12] = t4;
	} else t4 = $[12];
	let t5;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = () => setIsEditing(true);
		$[13] = t5;
	} else t5 = $[13];
	let t6;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			className: "hover-visible",
			onPress: t5,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgPencil1, { style: {
				width: 11,
				height: 11,
				color: theme.pageTextSubdued
			} })
		});
		$[14] = t6;
	} else t6 = $[14];
	let t7;
	if ($[15] !== title) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t4,
			children: [title, t6]
		});
		$[15] = title;
		$[16] = t7;
	} else t7 = $[16];
	return t7;
}
//#endregion
//#region src/components/reports/Container.tsx
function Container(t0) {
	const $ = (0, import_compiler_runtime.c)(8);
	const { style, children } = t0;
	const portalHost = (0, import_react.useRef)(null);
	let t1;
	if ($[0] !== style) {
		t1 = {
			height: 300,
			position: "relative",
			flexShrink: 0,
			...style
		};
		$[0] = style;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: portalHost });
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] !== children) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(q, { renderProp: (t4) => {
			const { width: t5, height: t6 } = t4;
			const width = t5 === void 0 ? 0 : t5;
			const height = t6 === void 0 ? 0 : t6;
			if (width === 0 || height === 0) return null;
			return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: {
					width,
					height
				},
				children: children(width, height, portalHost.current)
			});
		} });
		$[3] = children;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== t1 || $[6] !== t3) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t1,
			children: [t2, t3]
		});
		$[5] = t1;
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	return t4;
}
//#endregion
//#region src/components/reports/graphs/AgeOfMoneyGraph.tsx
function CustomTooltip$9(t0) {
	const $ = (0, import_compiler_runtime.c)(13);
	const { active, payload } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		let t2;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t2 = { marginBottom: 5 };
			$[0] = t1;
			$[1] = t2;
		} else {
			t1 = $[0];
			t2 = $[1];
		}
		let t3;
		if ($[2] !== payload[0].payload.date) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
			});
			$[2] = payload[0].payload.date;
			$[3] = t3;
		} else t3 = $[3];
		let t4;
		if ($[4] !== payload[0].payload.ageOfMoney || $[5] !== t) {
			t4 = t("Age of Money: {{days}} days", { days: payload[0].payload.ageOfMoney });
			$[4] = payload[0].payload.ageOfMoney;
			$[5] = t;
			$[6] = t4;
		} else t4 = $[6];
		let t5;
		if ($[7] !== t4) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: t4 });
			$[7] = t4;
			$[8] = t5;
		} else t5 = $[8];
		let t6;
		if ($[9] !== t1 || $[10] !== t3 || $[11] !== t5) {
			t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: t1,
				children: [t3, t5]
			});
			$[9] = t1;
			$[10] = t3;
			$[11] = t5;
			$[12] = t6;
		} else t6 = $[12];
		return t6;
	}
	return null;
}
function AgeOfMoneyGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(19);
	const { style, data, compact: t1, showTooltip: t2 } = t0;
	const compact = t1 === void 0 ? false : t1;
	const showTooltip = t2 === void 0 ? true : t2;
	const { t } = useTranslation();
	const animationProps = useRechartsAnimation();
	const privacyMode = usePrivacyMode();
	const gradientId = `aom-gradient-${(0, import_react.useId)()}`;
	let t3;
	if ($[0] !== data) {
		t3 = Math.max(...data.map(_temp$24), 30);
		$[0] = data;
		$[1] = t3;
	} else t3 = $[1];
	const yAxisMax = Math.ceil(t3 / 10) * 10 + 10;
	let t4;
	if ($[2] !== compact) {
		t4 = compact && { height: "auto" };
		$[2] = compact;
		$[3] = t4;
	} else t4 = $[3];
	let t5;
	if ($[4] !== style || $[5] !== t4) {
		t5 = {
			...style,
			...t4
		};
		$[4] = style;
		$[5] = t4;
		$[6] = t5;
	} else t5 = $[6];
	let t6;
	if ($[7] !== animationProps || $[8] !== compact || $[9] !== data || $[10] !== gradientId || $[11] !== privacyMode || $[12] !== showTooltip || $[13] !== t || $[14] !== yAxisMax) {
		t6 = (width, height) => data && data.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AreaChart, {
			width,
			height,
			data,
			margin: {
				top: 10,
				right: 10,
				left: compact ? 0 : 10,
				bottom: 10
			},
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
					id: gradientId,
					x1: "0",
					y1: "0",
					x2: "0",
					y2: "1",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: "0%",
						stopColor: theme.reportsChartFill,
						stopOpacity: .3
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: "100%",
						stopColor: theme.reportsChartFill,
						stopOpacity: .05
					})]
				}) }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
					strokeDasharray: "3 3",
					vertical: false
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "date",
					tick: {
						fill: theme.reportsLabel,
						fontSize: 12
					},
					tickLine: { stroke: theme.reportsLabel }
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					tickFormatter: (value) => privacyMode ? "•••" : `${value}d`,
					tick: {
						fill: theme.reportsLabel,
						fontSize: 12
					},
					tickLine: { stroke: theme.reportsLabel },
					domain: [0, yAxisMax]
				}),
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$9, {}),
					isAnimationActive: false
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
					y: 30,
					stroke: theme.reportsGreen,
					strokeDasharray: "5 5",
					label: {
						value: t("30 days"),
						position: "insideTopRight",
						fill: theme.reportsGreen,
						fontSize: 10
					}
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
					type: "monotone",
					dataKey: "ageOfMoney",
					stroke: theme.reportsChartFill,
					strokeWidth: 2,
					fill: `url(#${gradientId})`,
					fillOpacity: 1,
					dot: !compact && data.length <= 90,
					activeDot: {
						r: 6,
						fill: theme.reportsChartFill
					},
					...animationProps
				})
			]
		})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			style: {
				display: "flex",
				alignItems: "center",
				justifyContent: "center",
				height: "100%",
				color: theme.pageTextSubdued
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No data available" })
		});
		$[7] = animationProps;
		$[8] = compact;
		$[9] = data;
		$[10] = gradientId;
		$[11] = privacyMode;
		$[12] = showTooltip;
		$[13] = t;
		$[14] = yAxisMax;
		$[15] = t6;
	} else t6 = $[15];
	let t7;
	if ($[16] !== t5 || $[17] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t5,
			children: t6
		});
		$[16] = t5;
		$[17] = t6;
		$[18] = t7;
	} else t7 = $[18];
	return t7;
}
function _temp$24(d) {
	return d.ageOfMoney;
}
var defaultReport = {
	id: "",
	name: "",
	startDate: subMonths(currentMonth(), 5) + "-01",
	endDate: currentDay(),
	isDateStatic: false,
	dateRange: "Last 6 months",
	mode: "total",
	groupBy: "Category",
	interval: "Monthly",
	balanceType: "Payment",
	sortBy: "desc",
	showEmpty: false,
	showOffBudget: false,
	showHiddenCategories: true,
	includeCurrentInterval: true,
	showUncategorized: true,
	trimIntervals: false,
	graphType: "BarGraph",
	conditions: [],
	conditionsOp: "and"
};
var balanceTypeOptions = [
	{
		description: t("Payment"),
		key: "Payment",
		format: "totalDebts"
	},
	{
		description: t("Deposit"),
		key: "Deposit",
		format: "totalAssets"
	},
	{
		description: t("Net"),
		key: "Net",
		format: "totalTotals"
	},
	{
		description: t("Net Payment"),
		key: "Net Payment",
		format: "netDebts"
	},
	{
		description: t("Net Deposit"),
		key: "Net Deposit",
		format: "netAssets"
	},
	{
		description: t("Budgeted"),
		key: "Budgeted",
		format: "totalBudgeted"
	}
];
var groupByOptions = [
	{
		description: t("Category"),
		key: "Category"
	},
	{
		description: t("Group"),
		key: "Group"
	},
	{
		description: t("Category+Group"),
		key: "CategoryGroup"
	},
	{
		description: t("Payee"),
		key: "Payee"
	},
	{
		description: t("Account"),
		key: "Account"
	},
	{
		description: t("Interval"),
		key: "Interval"
	}
];
var sortByOptions = [
	{
		description: t("Ascending"),
		key: "Ascending",
		format: "asc"
	},
	{
		description: t("Descending"),
		key: "Descending",
		format: "desc"
	},
	{
		description: t("Name"),
		key: "Name",
		format: "name"
	},
	{
		description: t("Budget"),
		key: "Budget",
		format: "budget"
	}
];
var dateRangeOptions = [
	{
		description: t("This week"),
		key: "This week",
		name: 0,
		type: "Week",
		Daily: true,
		Weekly: true,
		Monthly: false,
		Yearly: false
	},
	{
		description: t("Last week"),
		key: "Last week",
		name: 1,
		type: "Week",
		Daily: true,
		Weekly: true,
		Monthly: false,
		Yearly: false
	},
	{
		description: t("This month"),
		key: "This month",
		name: 0,
		type: "Month",
		Daily: true,
		Weekly: true,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Last month"),
		key: "Last month",
		name: 1,
		type: "Month",
		Daily: true,
		Weekly: true,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Last 30 days"),
		key: "Last 30 days",
		name: "last30Days",
		type: "Day",
		Daily: true,
		Weekly: true,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Last 3 months"),
		key: "Last 3 months",
		name: 3,
		type: "Month",
		Daily: true,
		Weekly: true,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Last 6 months"),
		key: "Last 6 months",
		name: 6,
		type: "Month",
		Daily: false,
		Weekly: false,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Last 12 months"),
		key: "Last 12 months",
		name: 12,
		type: "Month",
		Daily: false,
		Weekly: false,
		Monthly: true,
		Yearly: false
	},
	{
		description: t("Year to date"),
		key: "Year to date",
		name: "yearToDate",
		type: "Month",
		Daily: false,
		Weekly: true,
		Monthly: true,
		Yearly: true
	},
	{
		description: t("Last year"),
		key: "Last year",
		name: "lastYear",
		type: "Month",
		Daily: false,
		Weekly: true,
		Monthly: true,
		Yearly: true
	},
	{
		description: t("Prior year to date"),
		key: "Prior year to date",
		name: "priorYearToDate",
		type: "Month",
		Daily: false,
		Weekly: true,
		Monthly: true,
		Yearly: true
	},
	{
		description: t("All time"),
		key: "All time",
		name: "allTime",
		type: "Month",
		Daily: false,
		Weekly: true,
		Monthly: true,
		Yearly: true
	}
];
var intervalOptions$1 = [
	{
		description: t("Daily"),
		key: "Daily",
		name: "Day",
		format: "yy-MM-dd",
		range: "dayRangeInclusive"
	},
	{
		description: t("Weekly"),
		key: "Weekly",
		name: "Week",
		format: "yy-MM-dd",
		range: "weekRangeInclusive"
	},
	{
		description: t("Monthly"),
		key: "Monthly",
		name: "Month",
		format: "MMM ''yy",
		range: "rangeInclusive"
	},
	{
		description: t("Yearly"),
		key: "Yearly",
		name: "Year",
		format: "yyyy",
		range: "yearRangeInclusive"
	}
];
var ReportOptions = {
	groupBy: groupByOptions,
	groupByItems: new Set(groupByOptions.map((item) => item.key)),
	balanceType: balanceTypeOptions,
	balanceTypeMap: new Map(balanceTypeOptions.map((item) => [item.key, item.format])),
	sortBy: sortByOptions,
	sortByMap: new Map(sortByOptions.map((item) => [item.key, item.format])),
	dateRange: dateRangeOptions,
	dateRangeMap: new Map(dateRangeOptions.map((item) => [item.key, item.name])),
	dateRangeType: new Map(dateRangeOptions.map((item) => [item.key, item.type])),
	interval: intervalOptions$1,
	intervalMap: new Map(intervalOptions$1.map((item) => [item.key, item.name])),
	intervalFormat: new Map(intervalOptions$1.map((item) => [item.key, item.format])),
	intervalRange: new Map(intervalOptions$1.map((item) => [item.key, item.range]))
};
var uncategorizedCategory = {
	id: "",
	name: t("Uncategorized"),
	uncategorized_id: "other",
	hidden: false
};
var transferCategory = {
	id: "",
	name: t("Transfers"),
	uncategorized_id: "transfer",
	hidden: false
};
var offBudgetCategory = {
	id: "",
	name: t("Off budget"),
	uncategorized_id: "off_budget",
	hidden: false
};
var uncategorizedGroup = {
	name: t("Uncategorized & Off budget"),
	id: "uncategorized",
	hidden: false,
	uncategorized_id: "all",
	categories: [
		uncategorizedCategory,
		transferCategory,
		offBudgetCategory
	]
};
var categoryLists = (categories) => {
	return [[
		...[...categories.list].sort((a, b) => {
			const catGroupA = categories.grouped.find((f) => f.id === a.group);
			const catGroupB = categories.grouped.find((f) => f.id === b.group);
			return a.sort_order && b.sort_order && catGroupA && catGroupB ? Number(catGroupA.is_income) - Number(catGroupB.is_income) || (catGroupA.sort_order ?? 0) - (catGroupB.sort_order ?? 0) || a.sort_order - b.sort_order : 0;
		}),
		uncategorizedCategory,
		offBudgetCategory,
		transferCategory
	], [...categories.grouped, uncategorizedGroup].filter((group) => group !== null)];
};
var groupBySelections = (groupBy, categoryList, categoryGroup, payees, accounts) => {
	let groupByList;
	let groupByLabel;
	switch (groupBy) {
		case "Category":
			groupByList = categoryList;
			groupByLabel = "category";
			break;
		case "Group":
			groupByList = categoryGroup.map((group) => {
				return {
					...group,
					id: group.id,
					name: group.name,
					hidden: group.hidden
				};
			});
			groupByLabel = "categoryGroup";
			break;
		case "CategoryGroup":
			groupByList = categoryGroup.map((group) => {
				return {
					...group,
					id: group.id,
					name: group.name,
					hidden: group.hidden
				};
			});
			groupByLabel = "categoryGroup";
			break;
		case "Payee":
			groupByList = payees.map((payee) => {
				return {
					id: payee.id,
					name: payee.name,
					hidden: false
				};
			});
			groupByLabel = "payee";
			break;
		case "Account":
			groupByList = accounts.map((account) => {
				return {
					id: account.id,
					name: account.name,
					hidden: false
				};
			});
			groupByLabel = "account";
			break;
		case "Interval":
			groupByList = categoryList;
			groupByLabel = "category";
			break;
		default: throw new Error("Error loading data into the spreadsheet.");
	}
	return [groupByList, groupByLabel];
};
//#endregion
//#region src/components/reports/reportRanges.ts
function validateStart(earliest, latest, start, end, interval, firstDayOfWeekIdx) {
	let addDays$2;
	let dateStart;
	switch (interval) {
		case "Monthly":
			dateStart = start + "-01";
			addDays$2 = 180;
			break;
		case "Yearly":
			dateStart = start + "-01-01";
			addDays$2 = 1095;
			break;
		case "Daily":
			dateStart = start;
			addDays$2 = 6;
			break;
		default:
			dateStart = start;
			addDays$2 = 180;
			break;
	}
	if (end < start) end = addDays(dateStart, addDays$2);
	return boundedRange(earliest, latest, dateStart, interval ? end : monthFromDate(end), interval, firstDayOfWeekIdx);
}
function validateEnd(earliest, latest, start, end, interval, firstDayOfWeekIdx) {
	let subDays$2;
	let dateEnd;
	switch (interval) {
		case "Monthly":
			dateEnd = getMonthEnd(end + "-01");
			subDays$2 = 180;
			break;
		case "Yearly":
			dateEnd = end + "-12-31";
			subDays$2 = 1095;
			break;
		case "Daily":
			dateEnd = end;
			subDays$2 = 6;
			break;
		default:
			dateEnd = end;
			subDays$2 = 180;
			break;
	}
	if (start > end) start = subDays(dateEnd, subDays$2);
	return boundedRange(earliest, latest, interval ? start : monthFromDate(start), dateEnd, interval, firstDayOfWeekIdx);
}
function validateRange(earliest, start, end) {
	if (start < earliest) start = earliest;
	return [start, end];
}
function boundedRange(earliest, latest, start, end, interval, _firstDayOfWeekIdx) {
	switch (interval) {
		case "Daily":
			latest = currentDay();
			break;
		case "Weekly":
			latest = currentDay();
			break;
		case "Monthly":
			latest = getMonthEnd(currentDay());
			break;
		case "Yearly":
			latest = currentDay();
			break;
		default: break;
	}
	if (end > latest) end = latest;
	if (start < earliest) start = earliest;
	return [
		start,
		end,
		"static"
	];
}
function getSpecificRange(offset, addNumber, type, firstDayOfWeekIdx) {
	const currentDay$1 = currentDay();
	const currentWeek$1 = currentWeek(firstDayOfWeekIdx);
	let dateStart = subMonths(currentDay$1, offset) + "-01";
	let dateEnd = getMonthEnd(addMonths(dateStart, addNumber === null ? offset : addNumber) + "-01");
	if (type === "Week") {
		dateStart = subWeeks(currentWeek$1, offset);
		dateEnd = getWeekEnd(addWeeks(dateStart, addNumber === null ? offset : addNumber), firstDayOfWeekIdx);
	}
	return [
		dateStart,
		dateEnd,
		"static"
	];
}
function getFullRange(start, end) {
	return [
		start,
		end,
		"full"
	];
}
function getLatestRange(offset) {
	const end = currentMonth();
	return [
		subMonths(end, offset),
		end,
		"sliding-window"
	];
}
function getNextRange(offset) {
	const start = currentMonth();
	return [
		start,
		addMonths(start, offset),
		"static"
	];
}
function getFullFutureRange(latestMonth) {
	const start = currentMonth();
	const defaultEnd = addMonths(start, 24);
	return [
		start,
		latestMonth && isAfter(latestMonth, start) ? latestMonth : defaultEnd,
		"static"
	];
}
function calculateTimeRange(timeFrame, defaultTimeFrame, latestTransaction) {
	const start = timeFrame?.start ?? defaultTimeFrame?.start ?? subMonths(currentMonth(), 5);
	const end = timeFrame?.end ?? defaultTimeFrame?.end ?? currentMonth();
	const mode = timeFrame?.mode ?? defaultTimeFrame?.mode ?? "sliding-window";
	if (mode === "full") {
		const latestTransactionMonth = latestTransaction ? monthFromDate(latestTransaction) : null;
		const currentMonth$13 = currentMonth();
		return getFullRange(start, latestTransactionMonth && isAfter(latestTransactionMonth, currentMonth$13) ? latestTransactionMonth : currentMonth$13);
	}
	if (mode === "sliding-window") {
		const offset = differenceInCalendarMonths(end, start);
		if (start > end) return [
			currentMonth(),
			subMonths(currentMonth(), -offset),
			"sliding-window"
		];
		return getLatestRange(offset);
	}
	if (mode === "lastMonth") {
		const lastMonth = subMonths(currentMonth(), 1);
		return [
			lastMonth,
			lastMonth,
			"lastMonth"
		];
	}
	if (mode === "lastYear") return [
		getYearStart(prevYear(currentMonth())),
		getYearEnd(prevYear(currentDate())),
		"lastYear"
	];
	if (mode === "yearToDate") return [
		currentYear() + "-01",
		currentMonth(),
		"yearToDate"
	];
	if (mode === "priorYearToDate") return [
		getYearStart(prevYear(currentMonth())),
		prevYear(currentDate(), "yyyy-MM-dd"),
		"priorYearToDate"
	];
	return [
		start,
		end,
		"static"
	];
}
function calculateSpendingReportTimeRange({ compare, compareTo, isLive = true, mode = "single-month" }) {
	if (["budget", "average"].includes(mode) && isLive) {
		const month = compare ?? currentMonth();
		return [month, month];
	}
	if (mode === "single-month" && isLive && compare) return [compare, compareTo ?? subMonths(compare, 1)];
	const [start, end] = calculateTimeRange({
		start: compare,
		end: compareTo,
		mode: isLive ?? true ? "sliding-window" : "static"
	}, {
		start: currentMonth(),
		end: subMonths(currentMonth(), 1),
		mode: "sliding-window"
	});
	return [start, end];
}
//#endregion
//#region src/components/reports/getLiveRange.ts
function getLiveRange(cond, earliestTransaction, latestTransaction, includeCurrentInterval, firstDayOfWeekIdx) {
	let dateStart = earliestTransaction;
	let dateEnd = latestTransaction;
	const rangeName = ReportOptions.dateRangeMap.get(cond);
	switch (rangeName) {
		case "yearToDate":
			[dateStart, dateEnd] = validateRange(earliestTransaction, getYearStart(currentMonth()) + "-01", currentDay());
			break;
		case "lastMonth": {
			const prevMonth = subMonths(currentMonth(), 1);
			[dateStart, dateEnd] = validateRange(earliestTransaction, firstDayOfMonth(prevMonth), lastDayOfMonth(prevMonth));
			break;
		}
		case "lastYear":
			[dateStart, dateEnd] = validateRange(earliestTransaction, getYearStart(prevYear(currentMonth())) + "-01", getYearEnd(prevYear(currentDate())) + "-31");
			break;
		case "priorYearToDate":
			[dateStart, dateEnd] = validateRange(earliestTransaction, getYearStart(prevYear(currentMonth())) + "-01", prevYear(currentDate(), "yyyy-MM-dd"));
			break;
		case "last30Days":
			[dateStart, dateEnd] = validateRange(earliestTransaction, subDays(currentDay(), 29), currentDay());
			break;
		case "allTime":
			dateStart = earliestTransaction;
			dateEnd = latestTransaction;
			break;
		default: if (typeof rangeName === "number") [dateStart, dateEnd] = getSpecificRange(rangeName, ["This month", "This week"].includes(cond) ? null : rangeName - (includeCurrentInterval ? 0 : 1), ReportOptions.dateRangeType.get(cond), firstDayOfWeekIdx);
		else break;
	}
	return [
		dateStart,
		dateEnd,
		"sliding-window"
	];
}
//#endregion
//#region src/components/reports/Header.tsx
function PastRangePresets(t0) {
	const $ = (0, import_compiler_runtime.c)(70);
	const { show1Month, earliestTransaction, latestTransaction, firstDayOfWeekIdx, allMonths, onChangeDates, convertToMonth } = t0;
	let t1;
	if ($[0] !== onChangeDates || $[1] !== show1Month) {
		t1 = show1Month && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: () => onChangeDates(...getLatestRange(0)),
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "1 month" })
		});
		$[0] = onChangeDates;
		$[1] = show1Month;
		$[2] = t1;
	} else t1 = $[2];
	let t2;
	if ($[3] !== onChangeDates) {
		t2 = () => onChangeDates(...getLatestRange(2));
		$[3] = onChangeDates;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "3 months" });
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t2) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t2,
			children: t3
		});
		$[6] = t2;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== onChangeDates) {
		t5 = () => onChangeDates(...getLatestRange(5));
		$[8] = onChangeDates;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "6 months" });
		$[10] = t6;
	} else t6 = $[10];
	let t7;
	if ($[11] !== t5) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t5,
			children: t6
		});
		$[11] = t5;
		$[12] = t7;
	} else t7 = $[12];
	let t8;
	if ($[13] !== onChangeDates) {
		t8 = () => onChangeDates(...getLatestRange(11));
		$[13] = onChangeDates;
		$[14] = t8;
	} else t8 = $[14];
	let t9;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "1 year" });
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== t8) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t8,
			children: t9
		});
		$[16] = t8;
		$[17] = t10;
	} else t10 = $[17];
	let t11;
	if ($[18] !== convertToMonth || $[19] !== earliestTransaction || $[20] !== firstDayOfWeekIdx || $[21] !== latestTransaction || $[22] !== onChangeDates) {
		t11 = () => onChangeDates(...convertToMonth(...getLiveRange("Year to date", earliestTransaction, latestTransaction, true, firstDayOfWeekIdx), "yearToDate"));
		$[18] = convertToMonth;
		$[19] = earliestTransaction;
		$[20] = firstDayOfWeekIdx;
		$[21] = latestTransaction;
		$[22] = onChangeDates;
		$[23] = t11;
	} else t11 = $[23];
	let t12;
	if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Year to date" });
		$[24] = t12;
	} else t12 = $[24];
	let t13;
	if ($[25] !== t11) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t11,
			children: t12
		});
		$[25] = t11;
		$[26] = t13;
	} else t13 = $[26];
	let t14;
	if ($[27] !== convertToMonth || $[28] !== earliestTransaction || $[29] !== firstDayOfWeekIdx || $[30] !== latestTransaction || $[31] !== onChangeDates) {
		t14 = () => onChangeDates(...convertToMonth(...getLiveRange("Last month", earliestTransaction, latestTransaction, false, firstDayOfWeekIdx), "lastMonth"));
		$[27] = convertToMonth;
		$[28] = earliestTransaction;
		$[29] = firstDayOfWeekIdx;
		$[30] = latestTransaction;
		$[31] = onChangeDates;
		$[32] = t14;
	} else t14 = $[32];
	let t15;
	if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Last month" });
		$[33] = t15;
	} else t15 = $[33];
	let t16;
	if ($[34] !== t14) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t14,
			children: t15
		});
		$[34] = t14;
		$[35] = t16;
	} else t16 = $[35];
	let t17;
	if ($[36] !== convertToMonth || $[37] !== earliestTransaction || $[38] !== firstDayOfWeekIdx || $[39] !== latestTransaction || $[40] !== onChangeDates) {
		t17 = () => onChangeDates(...convertToMonth(...getLiveRange("Last year", earliestTransaction, latestTransaction, false, firstDayOfWeekIdx), "lastYear"));
		$[36] = convertToMonth;
		$[37] = earliestTransaction;
		$[38] = firstDayOfWeekIdx;
		$[39] = latestTransaction;
		$[40] = onChangeDates;
		$[41] = t17;
	} else t17 = $[41];
	let t18;
	if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Last year" });
		$[42] = t18;
	} else t18 = $[42];
	let t19;
	if ($[43] !== t17) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t17,
			children: t18
		});
		$[43] = t17;
		$[44] = t19;
	} else t19 = $[44];
	let t20;
	if ($[45] !== convertToMonth || $[46] !== earliestTransaction || $[47] !== firstDayOfWeekIdx || $[48] !== latestTransaction || $[49] !== onChangeDates) {
		t20 = () => onChangeDates(...convertToMonth(...getLiveRange("Prior year to date", earliestTransaction, latestTransaction, false, firstDayOfWeekIdx), "priorYearToDate"));
		$[45] = convertToMonth;
		$[46] = earliestTransaction;
		$[47] = firstDayOfWeekIdx;
		$[48] = latestTransaction;
		$[49] = onChangeDates;
		$[50] = t20;
	} else t20 = $[50];
	let t21;
	if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Prior year to date" });
		$[51] = t21;
	} else t21 = $[51];
	let t22;
	if ($[52] !== t20) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t20,
			children: t21
		});
		$[52] = t20;
		$[53] = t22;
	} else t22 = $[53];
	let t23;
	if ($[54] !== allMonths || $[55] !== onChangeDates) {
		t23 = () => onChangeDates(...getFullRange(allMonths[allMonths.length - 1].name, allMonths[0].name));
		$[54] = allMonths;
		$[55] = onChangeDates;
		$[56] = t23;
	} else t23 = $[56];
	let t24;
	if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "All time" });
		$[57] = t24;
	} else t24 = $[57];
	let t25;
	if ($[58] !== t23) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t23,
			children: t24
		});
		$[58] = t23;
		$[59] = t25;
	} else t25 = $[59];
	let t26;
	if ($[60] !== t1 || $[61] !== t10 || $[62] !== t13 || $[63] !== t16 || $[64] !== t19 || $[65] !== t22 || $[66] !== t25 || $[67] !== t4 || $[68] !== t7) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
			t1,
			t4,
			t7,
			t10,
			t13,
			t16,
			t19,
			t22,
			t25
		] });
		$[60] = t1;
		$[61] = t10;
		$[62] = t13;
		$[63] = t16;
		$[64] = t19;
		$[65] = t22;
		$[66] = t25;
		$[67] = t4;
		$[68] = t7;
		$[69] = t26;
	} else t26 = $[69];
	return t26;
}
function FutureRangePresets(t0) {
	const $ = (0, import_compiler_runtime.c)(30);
	const { show1Month, latestTransaction, onChangeDates } = t0;
	let t1;
	if ($[0] !== onChangeDates || $[1] !== show1Month) {
		t1 = show1Month && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: () => onChangeDates(...getNextRange(0)),
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Next month" })
		});
		$[0] = onChangeDates;
		$[1] = show1Month;
		$[2] = t1;
	} else t1 = $[2];
	let t2;
	if ($[3] !== onChangeDates) {
		t2 = () => onChangeDates(...getNextRange(2));
		$[3] = onChangeDates;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Next 3 months" });
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t2) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t2,
			children: t3
		});
		$[6] = t2;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== onChangeDates) {
		t5 = () => onChangeDates(...getNextRange(5));
		$[8] = onChangeDates;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Next 6 months" });
		$[10] = t6;
	} else t6 = $[10];
	let t7;
	if ($[11] !== t5) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t5,
			children: t6
		});
		$[11] = t5;
		$[12] = t7;
	} else t7 = $[12];
	let t8;
	if ($[13] !== onChangeDates) {
		t8 = () => onChangeDates(...getNextRange(11));
		$[13] = onChangeDates;
		$[14] = t8;
	} else t8 = $[14];
	let t9;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Next year" });
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== t8) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t8,
			children: t9
		});
		$[16] = t8;
		$[17] = t10;
	} else t10 = $[17];
	let t11;
	if ($[18] !== latestTransaction || $[19] !== onChangeDates) {
		t11 = () => onChangeDates(...getFullFutureRange(latestTransaction));
		$[18] = latestTransaction;
		$[19] = onChangeDates;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "All future" });
		$[21] = t12;
	} else t12 = $[21];
	let t13;
	if ($[22] !== t11) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t11,
			children: t12
		});
		$[22] = t11;
		$[23] = t13;
	} else t13 = $[23];
	let t14;
	if ($[24] !== t1 || $[25] !== t10 || $[26] !== t13 || $[27] !== t4 || $[28] !== t7) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
			t1,
			t4,
			t7,
			t10,
			t13
		] });
		$[24] = t1;
		$[25] = t10;
		$[26] = t13;
		$[27] = t4;
		$[28] = t7;
		$[29] = t14;
	} else t14 = $[29];
	return t14;
}
function Header(t0) {
	const $ = (0, import_compiler_runtime.c)(85);
	const { start, end, mode, show1Month, showFutureRange, hideModeToggle, allMonths, earliestTransaction, latestTransaction, firstDayOfWeekIdx, onChangeDates, filters, conditionsOp, onApply, onUpdateFilter, onDeleteFilter, onConditionsOpChange, children, inlineContent, filterExclude, filterInclude } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	const { isNarrowWidth } = useResponsive();
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = function convertToMonth(start_0, end_0, _, mode_0) {
			return [
				getMonth(start_0),
				getMonth(end_0),
				mode_0
			];
		};
		$[0] = t1;
	} else t1 = $[0];
	const convertToMonth = t1;
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			padding: 20,
			paddingTop: 15,
			flexShrink: 0
		};
		$[1] = t2;
	} else t2 = $[1];
	const t3 = isNarrowWidth ? "flex-start" : "center";
	let t4;
	if ($[2] !== t3) {
		t4 = {
			display: "grid",
			alignItems: t3
		};
		$[2] = t3;
		$[3] = t4;
	} else t4 = $[3];
	let t5;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = {
			display: "flex",
			flexWrap: "wrap",
			flexDirection: "row"
		};
		$[4] = t5;
	} else t5 = $[4];
	const t6 = isNarrowWidth ? 5 : void 0;
	let t7;
	if ($[5] !== end || $[6] !== hideModeToggle || $[7] !== mode || $[8] !== onChangeDates || $[9] !== start || $[10] !== t) {
		t7 = mode && !hideModeToggle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: mode === "static" ? "normal" : "primary",
			onPress: () => {
				const newMode = mode === "static" ? "sliding-window" : "static";
				const [newStart, newEnd] = calculateTimeRange({
					start,
					end,
					mode: newMode
				});
				onChangeDates(newStart, newEnd, newMode);
			},
			children: mode === "static" ? t("Static") : t("Live")
		});
		$[5] = end;
		$[6] = hideModeToggle;
		$[7] = mode;
		$[8] = onChangeDates;
		$[9] = start;
		$[10] = t;
		$[11] = t7;
	} else t7 = $[11];
	let t8;
	if ($[12] !== allMonths || $[13] !== end || $[14] !== onChangeDates) {
		t8 = (newValue) => onChangeDates(...validateStart(allMonths[allMonths.length - 1].name, allMonths[0].name, newValue, end));
		$[12] = allMonths;
		$[13] = end;
		$[14] = onChangeDates;
		$[15] = t8;
	} else t8 = $[15];
	let t9;
	if ($[16] !== locale || $[17] !== start) {
		t9 = format(start, "MMMM yyyy", locale);
		$[16] = locale;
		$[17] = start;
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	if ($[19] !== allMonths) {
		t10 = allMonths.map(_temp$23);
		$[19] = allMonths;
		$[20] = t10;
	} else t10 = $[20];
	let t11;
	if ($[21] !== start || $[22] !== t10 || $[23] !== t8 || $[24] !== t9) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
			onChange: t8,
			value: start,
			defaultLabel: t9,
			options: t10
		});
		$[21] = start;
		$[22] = t10;
		$[23] = t8;
		$[24] = t9;
		$[25] = t11;
	} else t11 = $[25];
	let t12;
	if ($[26] !== t) {
		t12 = t("to");
		$[26] = t;
		$[27] = t12;
	} else t12 = $[27];
	let t13;
	if ($[28] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: t12 });
		$[28] = t12;
		$[29] = t13;
	} else t13 = $[29];
	let t14;
	if ($[30] !== allMonths || $[31] !== onChangeDates || $[32] !== start) {
		t14 = (newValue_0) => onChangeDates(...validateEnd(allMonths[allMonths.length - 1].name, allMonths[0].name, start, newValue_0));
		$[30] = allMonths;
		$[31] = onChangeDates;
		$[32] = start;
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== allMonths) {
		t15 = allMonths.map(_temp2$15);
		$[34] = allMonths;
		$[35] = t15;
	} else t15 = $[35];
	let t16;
	if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = { marginRight: 10 };
		$[36] = t16;
	} else t16 = $[36];
	let t17;
	if ($[37] !== end || $[38] !== t14 || $[39] !== t15) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
			onChange: t14,
			value: end,
			options: t15,
			style: t16
		});
		$[37] = end;
		$[38] = t14;
		$[39] = t15;
		$[40] = t17;
	} else t17 = $[40];
	let t18;
	if ($[41] !== t11 || $[42] !== t13 || $[43] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			gap: 5,
			children: [
				t11,
				t13,
				t17
			]
		});
		$[41] = t11;
		$[42] = t13;
		$[43] = t17;
		$[44] = t18;
	} else t18 = $[44];
	let t19;
	if ($[45] !== t18 || $[46] !== t6 || $[47] !== t7) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			gap: t6,
			children: [t7, t18]
		});
		$[45] = t18;
		$[46] = t6;
		$[47] = t7;
		$[48] = t19;
	} else t19 = $[48];
	let t20;
	if ($[49] !== allMonths || $[50] !== earliestTransaction || $[51] !== firstDayOfWeekIdx || $[52] !== latestTransaction || $[53] !== onChangeDates || $[54] !== show1Month || $[55] !== showFutureRange) {
		t20 = showFutureRange ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FutureRangePresets, {
			show1Month,
			latestTransaction,
			onChangeDates
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PastRangePresets, {
			show1Month,
			earliestTransaction,
			latestTransaction,
			firstDayOfWeekIdx,
			allMonths,
			onChangeDates,
			convertToMonth
		});
		$[49] = allMonths;
		$[50] = earliestTransaction;
		$[51] = firstDayOfWeekIdx;
		$[52] = latestTransaction;
		$[53] = onChangeDates;
		$[54] = show1Month;
		$[55] = showFutureRange;
		$[56] = t20;
	} else t20 = $[56];
	let t21;
	if ($[57] !== filterExclude || $[58] !== filterInclude || $[59] !== filters || $[60] !== isNarrowWidth || $[61] !== onApply) {
		t21 = filters && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterButton, {
			compact: isNarrowWidth,
			onApply,
			hover: false,
			exclude: filterExclude,
			include: filterInclude
		});
		$[57] = filterExclude;
		$[58] = filterInclude;
		$[59] = filters;
		$[60] = isNarrowWidth;
		$[61] = onApply;
		$[62] = t21;
	} else t21 = $[62];
	let t22;
	if ($[63] !== inlineContent || $[64] !== t20 || $[65] !== t21) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			gap: 3,
			children: [
				t20,
				t21,
				inlineContent
			]
		});
		$[63] = inlineContent;
		$[64] = t20;
		$[65] = t21;
		$[66] = t22;
	} else t22 = $[66];
	let t23;
	if ($[67] !== t19 || $[68] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t5,
			children: [t19, t22]
		});
		$[67] = t19;
		$[68] = t22;
		$[69] = t23;
	} else t23 = $[69];
	let t24;
	if ($[70] !== children) {
		t24 = children && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				gridColumn: 2,
				flexDirection: "row",
				justifySelf: "flex-end",
				alignSelf: "flex-start"
			},
			children
		});
		$[70] = children;
		$[71] = t24;
	} else t24 = $[71];
	let t25;
	if ($[72] !== t23 || $[73] !== t24 || $[74] !== t4) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t4,
			children: [t23, t24]
		});
		$[72] = t23;
		$[73] = t24;
		$[74] = t4;
		$[75] = t25;
	} else t25 = $[75];
	let t26;
	if ($[76] !== conditionsOp || $[77] !== filters || $[78] !== onConditionsOpChange || $[79] !== onDeleteFilter || $[80] !== onUpdateFilter) {
		t26 = filters && filters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { marginTop: 5 },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppliedFilters, {
				conditions: filters,
				onUpdate: onUpdateFilter,
				onDelete: onDeleteFilter,
				conditionsOp,
				onConditionsOpChange
			})
		});
		$[76] = conditionsOp;
		$[77] = filters;
		$[78] = onConditionsOpChange;
		$[79] = onDeleteFilter;
		$[80] = onUpdateFilter;
		$[81] = t26;
	} else t26 = $[81];
	let t27;
	if ($[82] !== t25 || $[83] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t2,
			children: [t25, t26]
		});
		$[82] = t25;
		$[83] = t26;
		$[84] = t27;
	} else t27 = $[84];
	return t27;
}
function _temp2$15(t0) {
	const { name: name_0, pretty: pretty_0 } = t0;
	return [name_0, pretty_0];
}
function _temp$23(t0) {
	const { name, pretty } = t0;
	return [name, pretty];
}
//#endregion
//#region src/components/reports/util.ts
function fromDateRepr(date) {
	return date.slice(0, 7);
}
async function runAll(queries, cb) {
	cb(await Promise.all(queries.map((q) => {
		return aqlQuery(q).then(({ data }) => data);
	})));
}
function indexCashFlow(data) {
	const results = {};
	data.forEach((item) => {
		const findExisting = results?.[item.date]?.[String(item.isTransfer)] ?? 0;
		const result = { [String(item.isTransfer)]: item.amount + findExisting };
		results[item.date] = {
			...results[item.date],
			...result
		};
	});
	return results;
}
/**
* Checks if the given conditions have issues
* (i.e. non-existing category/payee/account being used).
*/
function calculateHasWarning(conditions, { categories, accounts, payees }) {
	const categoryIds = new Set(categories.map(({ id }) => id));
	const payeeIds = new Set(payees.map(({ id }) => id));
	const accountIds = new Set(accounts.map(({ id }) => id));
	if (!conditions) return false;
	for (const cond of conditions) {
		const { field, value, op } = cond;
		const isMultiCondition = Array.isArray(value);
		if (!["is", "isNot"].includes(op) && !isMultiCondition) continue;
		if (!isMultiCondition && !value) continue;
		switch (field) {
			case "account":
				if (isMultiCondition) {
					if (value.find((val) => !accountIds.has(val))) return true;
					break;
				}
				if (!accountIds.has(value)) return true;
				break;
			case "payee":
				if (isMultiCondition) {
					if (value.find((val) => !payeeIds.has(val))) return true;
					break;
				}
				if (!payeeIds.has(value)) return true;
				break;
			case "category":
				if (isMultiCondition) {
					if (value.find((val) => !categoryIds.has(val))) return true;
					break;
				}
				if (!categoryIds.has(value)) return true;
				break;
			default: break;
		}
	}
	return false;
}
//#endregion
//#region src/components/reports/spreadsheets/age-of-money-spreadsheet.ts
/**
* Calculate the age of money for a given set of expense transactions
* using the FIFO (First In, First Out) method.
*
* Income becomes "buckets" sorted by date. When money is spent,
* it's deducted from the oldest bucket first. The age is the
* difference between the expense date and the bucket date.
*/
function calculateAgeOfMoney(incomeTransactions, expenseTransactions) {
	const buckets = [...incomeTransactions].sort((a, b) => a.date.localeCompare(b.date)).map((t) => ({
		date: t.date,
		remainingAmount: t.amount
	}));
	const sortedExpenses = [...expenseTransactions].sort((a, b) => a.date.localeCompare(b.date));
	const ages = [];
	let currentBucketIdx = 0;
	let insufficientData = false;
	for (const expense of sortedExpenses) {
		let remainingExpense = Math.abs(expense.amount);
		let lastBucketDate = null;
		while (remainingExpense > 0 && currentBucketIdx < buckets.length) {
			const bucket = buckets[currentBucketIdx];
			if (bucket.remainingAmount > 0) {
				const deduction = Math.min(bucket.remainingAmount, remainingExpense);
				bucket.remainingAmount -= deduction;
				remainingExpense -= deduction;
				lastBucketDate = bucket.date;
			}
			if (bucket.remainingAmount <= 0) currentBucketIdx++;
		}
		if (remainingExpense > 0) insufficientData = true;
		if (lastBucketDate) {
			const ageInDays = differenceInDays(parseISO(expense.date), parseISO(lastBucketDate));
			ages.push({
				date: expense.date,
				age: Math.max(0, ageInDays)
			});
		}
	}
	return {
		ages,
		insufficientData
	};
}
/**
* Calculate the average of the last N ages
*/
function calculateAverageAge(ages, count = 10) {
	if (ages.length === 0) return null;
	const lastN = ages.slice(-count);
	const sum = lastN.reduce((acc, item) => acc + item.age, 0);
	return Math.round(sum / lastN.length);
}
/**
* Get the period key for a given date based on granularity
*/
function getPeriodKey(date, granularity) {
	const parsed = parseISO(date);
	switch (granularity) {
		case "daily": return date;
		case "weekly": return format$1(startOfWeek(parsed, { weekStartsOn: 1 }), "yyyy-MM-dd");
		default: return getMonth(date);
	}
}
/**
* Format a period key for display based on granularity
*/
function formatPeriodLabel(periodKey, granularity) {
	switch (granularity) {
		case "daily": return format$1(parseISO(periodKey), "MMM d, yyyy");
		case "weekly": return format$1(parseISO(periodKey), "MMM d, yyyy");
		default: return format$1(parseISO(periodKey + "-01"), "MMM yyyy");
	}
}
/**
* Generate all periods between start and end based on granularity
*/
function generatePeriods(startDate, endDate, granularity) {
	const periods = [];
	let current = parseISO(startDate);
	const end = parseISO(endDate);
	switch (granularity) {
		case "daily":
			while (current <= end) {
				periods.push(format$1(current, "yyyy-MM-dd"));
				current = addDays$1(current, 1);
			}
			break;
		case "weekly":
			current = startOfWeek(current, { weekStartsOn: 1 });
			while (current <= end) {
				periods.push(format$1(current, "yyyy-MM-dd"));
				current = addWeeks$1(current, 1);
			}
			break;
		default: return rangeInclusive(getMonth(startDate), getMonth(endDate));
	}
	return periods;
}
/**
* Group ages by period and calculate rolling average for each period
*/
function calculateGraphData(ages, startMonth, endMonth, granularity = "monthly") {
	const startDate = firstDayOfMonth(startMonth);
	let endDate = lastDayOfMonth(endMonth);
	if (granularity === "daily" || granularity === "weekly") {
		const today = currentDay();
		if (isAfter(endDate, today)) endDate = today;
	}
	const periods = generatePeriods(startDate, endDate, granularity);
	const result = [];
	const agesByPeriod = {};
	for (const { date, age } of ages) {
		const periodKey = getPeriodKey(date, granularity);
		if (!agesByPeriod[periodKey]) agesByPeriod[periodKey] = [];
		agesByPeriod[periodKey].push(age);
	}
	let allAgesUpToPeriod = [];
	for (const period of periods) {
		if (agesByPeriod[period]) allAgesUpToPeriod = allAgesUpToPeriod.concat(agesByPeriod[period]);
		if (allAgesUpToPeriod.length > 0) {
			const lastN = allAgesUpToPeriod.slice(-10);
			const avg = Math.round(lastN.reduce((a, b) => a + b, 0) / lastN.length);
			result.push({
				date: formatPeriodLabel(period, granularity),
				ageOfMoney: avg
			});
		}
	}
	return result;
}
/**
* Determine the trend based on the last few data points
*/
function calculateTrend(graphData) {
	if (graphData.length < 2) return "stable";
	const diff = graphData[graphData.length - 1].ageOfMoney - graphData[graphData.length - 2].ageOfMoney;
	const threshold = 2;
	if (diff > threshold) return "up";
	if (diff < -threshold) return "down";
	return "stable";
}
function createAgeOfMoneySpreadsheet({ start, end, conditions = [], conditionsOp = "and", granularity = "monthly" }) {
	return async (spreadsheet, setData) => {
		const endDate = lastDayOfMonth(end);
		const today = currentDay();
		const fixedEnd = endDate > today ? today : endDate;
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		function makeIncomeQuery() {
			return q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({
				date: { $lte: fixedEnd },
				"account.offbudget": false,
				$or: [{ "payee.transfer_acct": null }, { "payee.transfer_acct.offbudget": true }],
				amount: { $gt: 0 }
			}).select([
				"id",
				"date",
				"amount"
			]);
		}
		function makeExpenseQuery() {
			return q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({
				date: { $lte: fixedEnd },
				"account.offbudget": false,
				$or: [{ "payee.transfer_acct": null }, { "payee.transfer_acct.offbudget": true }],
				amount: { $lt: 0 }
			}).select([
				"id",
				"date",
				"amount"
			]);
		}
		return runAll([makeIncomeQuery(), makeExpenseQuery()], (data) => {
			const [incomeData, expenseData] = data;
			const { ages, insufficientData } = calculateAgeOfMoney(incomeData, expenseData);
			const displayStart = firstDayOfMonth(start);
			const filteredAges = ages.filter(({ date }) => date >= displayStart);
			const graphData = calculateGraphData(filteredAges, start, end, granularity);
			setData({
				graphData,
				currentAge: calculateAverageAge(filteredAges, 10),
				trend: calculateTrend(graphData),
				insufficientData
			});
		});
	};
}
//#endregion
//#region src/components/reports/useReport.ts
function useReport$1(sheetName, getData) {
	const spreadsheet = useSpreadsheet();
	const [results, setResults] = (0, import_react.useState)(null);
	(0, import_react.useEffect)(() => {
		let didCancel = false;
		setResults(null);
		getData(spreadsheet, (results) => {
			if (!didCancel) setResults(results);
		});
		return () => {
			didCancel = true;
		};
	}, [getData, spreadsheet]);
	return results;
}
//#endregion
//#region src/hooks/useDashboardWidget.ts
function useDashboardWidget({ id, type }) {
	return useQuery({
		...dashboardQueries.listDashboardWidgets(),
		select: (widgets) => widgets.find((w) => w.id === id && w.type === type),
		enabled: !!id && !!type
	});
}
//#endregion
//#region src/hooks/useRuleConditionFilters.ts
function useRuleConditionFilters(initialConditions = [], initialConditionsOp = "and") {
	const [conditions, setConditions] = (0, import_react.useState)(initialConditions);
	const [conditionsOp, setConditionsOp] = (0, import_react.useState)(initialConditionsOp);
	const [saved, setSaved] = (0, import_react.useState)(null);
	const onApply = (0, import_react.useCallback)((conditionsOrSavedFilter) => {
		if (conditionsOrSavedFilter === null) {
			setConditions([]);
			setSaved(null);
		} else if ("conditions" in conditionsOrSavedFilter) {
			setConditions([...conditionsOrSavedFilter.conditions]);
			setConditionsOp(conditionsOrSavedFilter.conditionsOp);
			setSaved(conditionsOrSavedFilter.id);
		} else {
			setConditions((state) => [...state, conditionsOrSavedFilter]);
			setSaved(null);
		}
	}, [setConditions]);
	const onUpdate = (0, import_react.useCallback)((oldFilter, updatedFilter) => {
		setConditions((state) => state.map((f) => f === oldFilter ? updatedFilter : f));
		setSaved(null);
	}, [setConditions]);
	const onDelete = (0, import_react.useCallback)((deletedFilter) => {
		setConditions((state) => state.filter((f) => f !== deletedFilter));
		setSaved(null);
	}, [setConditions]);
	return (0, import_react.useMemo)(() => ({
		conditions,
		saved,
		conditionsOp,
		onApply,
		onUpdate,
		onDelete,
		onConditionsOpChange: setConditionsOp
	}), [
		conditions,
		saved,
		onApply,
		onUpdate,
		onDelete,
		setConditionsOp,
		conditionsOp
	]);
}
//#endregion
//#region src/components/reports/DateRange.tsx
function checkDate(date) {
	const dateParsed = parseDate(date);
	if (dateParsed) return format$1(dateParsed, "yyyy-MM-dd");
	else return null;
}
function DateRange(t0) {
	const $ = (0, import_compiler_runtime.c)(16);
	const { start, end, type } = t0;
	const { t } = useTranslation();
	const locale = useLocale();
	let content;
	let t1;
	if ($[0] !== end || $[1] !== locale || $[2] !== start || $[3] !== t || $[4] !== type) {
		t1 = Symbol.for("react.early_return_sentinel");
		bb0: {
			const checkStart = checkDate(start);
			const checkEnd = checkDate(end);
			let startDate;
			let endDate;
			if (checkStart && checkEnd) {
				startDate = parseISO(checkStart);
				endDate = parseISO(checkEnd);
			} else {
				let t2;
				if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
					t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							...styles.mediumText,
							color: theme.errorText
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "There was a problem loading your date range" })
					});
					$[7] = t2;
				} else t2 = $[7];
				t1 = t2;
				break bb0;
			}
			const formattedStartDate = format$1(startDate, "MMM yyyy", { locale });
			const formattedEndDate = format$1(endDate, "MMM yyyy", { locale });
			let typeOrFormattedEndDate;
			if (type && ["budget", "average"].includes(type)) {
				let t2;
				if ($[8] !== t || $[9] !== type) {
					t2 = type === "budget" ? t("budgeted") : t("average");
					$[8] = t;
					$[9] = type;
					$[10] = t2;
				} else t2 = $[10];
				typeOrFormattedEndDate = t2;
			} else typeOrFormattedEndDate = formattedEndDate;
			if (["budget", "average"].includes(type || "")) content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
				"Compare ",
				{ formattedStartDate },
				" to ",
				{ typeOrFormattedEndDate }
			] }) });
			else if (startDate.getFullYear() !== endDate.getFullYear() || startDate.getMonth() !== endDate.getMonth()) {
				const t2 = type ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
					"Compare ",
					{ formattedStartDate },
					" to ",
					{ typeOrFormattedEndDate }
				] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
					formattedStartDate,
					" - ",
					formattedEndDate
				] });
				let t3;
				if ($[11] !== t2) {
					t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: t2 });
					$[11] = t2;
					$[12] = t3;
				} else t3 = $[12];
				content = t3;
			} else content = format$1(endDate, "MMMM yyyy", { locale });
		}
		$[0] = end;
		$[1] = locale;
		$[2] = start;
		$[3] = t;
		$[4] = type;
		$[5] = content;
		$[6] = t1;
	} else {
		content = $[5];
		t1 = $[6];
	}
	if (t1 !== Symbol.for("react.early_return_sentinel")) return t1;
	let t2;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = { color: theme.pageTextSubdued };
		$[13] = t2;
	} else t2 = $[13];
	let t3;
	if ($[14] !== content) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
			style: t2,
			children: content
		});
		$[14] = content;
		$[15] = t3;
	} else t3 = $[15];
	return t3;
}
//#endregion
//#region src/hooks/useIsInViewport.ts
/**
* Check if the given element (by ref) is visible in the viewport.
*/
function useIsInViewport(ref) {
	const [isIntersecting, setIsIntersecting] = (0, import_react.useState)(false);
	const observer = (0, import_react.useMemo)(() => new IntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting)), []);
	(0, import_react.useEffect)(() => {
		const view = ref.current;
		if (!view) return;
		observer.observe(view);
		return () => {
			observer.disconnect();
		};
	}, [ref, observer]);
	return isIntersecting;
}
//#endregion
//#region src/components/reports/constants.ts
var NON_DRAGGABLE_AREA_CLASS_NAME = "non-draggable-area";
//#endregion
//#region src/components/reports/ReportCard.tsx
function ReportCard(t0) {
	const $ = (0, import_compiler_runtime.c)(40);
	const { isEditing, disableClick, to, menuItems, onMenuSelect, children, size: t1, style } = t0;
	const size = t1 === void 0 ? 1 : t1;
	const ref = (0, import_react.useRef)(null);
	const isInViewport = useIsInViewport(ref);
	const [hasRendered, setHasRendered] = (0, import_react.useState)(false);
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const t2 = isNarrowWidth ? "1 1" : `0 0 calc(${size * 100}% / 3 - 20px)`;
	let t3;
	if ($[0] !== t2) {
		t3 = { flex: t2 };
		$[0] = t2;
		$[1] = t3;
	} else t3 = $[1];
	const containerProps = t3;
	let t4;
	let t5;
	if ($[2] !== hasRendered || $[3] !== isInViewport) {
		t4 = () => {
			if (isInViewport && !hasRendered) setHasRendered(true);
		};
		t5 = [isInViewport, hasRendered];
		$[2] = hasRendered;
		$[3] = isInViewport;
		$[4] = t4;
		$[5] = t5;
	} else {
		t4 = $[4];
		t5 = $[5];
	}
	(0, import_react.useEffect)(t4, t5);
	let t6;
	if ($[6] !== isEditing || $[7] !== menuItems || $[8] !== onMenuSelect) {
		t6 = {
			isEditing,
			menuItems,
			onMenuSelect
		};
		$[6] = isEditing;
		$[7] = menuItems;
		$[8] = onMenuSelect;
		$[9] = t6;
	} else t6 = $[9];
	const layoutProps = t6;
	let t7;
	if ($[10] !== isEditing) {
		t7 = isEditing ? {
			"& .recharts-surface:hover": {
				cursor: "move",
				":active": { cursor: "grabbing" }
			},
			":active": { cursor: "grabbing" },
			filter: "grayscale(1)"
		} : { "& .recharts-surface:hover": { cursor: "pointer" } };
		$[10] = isEditing;
		$[11] = t7;
	} else t7 = $[11];
	let t8;
	if ($[12] !== to) {
		t8 = to ? { boxShadow: "0 4px 6px rgba(0, 0, 0, .15)" } : null;
		$[12] = to;
		$[13] = t8;
	} else t8 = $[13];
	let t9;
	if ($[14] !== isEditing) {
		t9 = isEditing ? {
			cursor: "move",
			filter: "grayscale(0)"
		} : null;
		$[14] = isEditing;
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== t8 || $[17] !== t9) {
		t10 = {
			...t8,
			...t9
		};
		$[16] = t8;
		$[17] = t9;
		$[18] = t10;
	} else t10 = $[18];
	const t11 = to ? null : containerProps;
	let t12;
	if ($[19] !== style || $[20] !== t10 || $[21] !== t11 || $[22] !== t7) {
		t12 = {
			backgroundColor: theme.tableBackground,
			borderBottomLeftRadius: 2,
			borderBottomRightRadius: 2,
			width: "100%",
			height: "100%",
			boxShadow: "0 2px 6px rgba(0, 0, 0, .15)",
			transition: "box-shadow .25s",
			...t7,
			":hover": t10,
			...t11,
			...style
		};
		$[19] = style;
		$[20] = t10;
		$[21] = t11;
		$[22] = t7;
		$[23] = t12;
	} else t12 = $[23];
	const t13 = isInViewport || hasRendered ? children : null;
	let t14;
	if ($[24] !== t12 || $[25] !== t13) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			ref,
			style: t12,
			children: t13
		});
		$[24] = t12;
		$[25] = t13;
		$[26] = t14;
	} else t14 = $[26];
	const content = t14;
	if (to && !isEditing && !disableClick) {
		let t15;
		if ($[27] !== navigate || $[28] !== to) {
			t15 = () => navigate(to, { state: { goBack: true } });
			$[27] = navigate;
			$[28] = to;
			$[29] = t15;
		} else t15 = $[29];
		let t16;
		if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
			t16 = {
				height: "100%",
				width: "100%",
				background: "transparent",
				padding: 0,
				textAlign: "left",
				overflow: "visible"
			};
			$[30] = t16;
		} else t16 = $[30];
		let t17;
		if ($[31] !== content || $[32] !== t15) {
			t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "bare",
				onPress: t15,
				style: t16,
				children: content
			});
			$[31] = content;
			$[32] = t15;
			$[33] = t17;
		} else t17 = $[33];
		let t18;
		if ($[34] !== layoutProps || $[35] !== t17) {
			t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, {
				...layoutProps,
				children: t17
			});
			$[34] = layoutProps;
			$[35] = t17;
			$[36] = t18;
		} else t18 = $[36];
		return t18;
	}
	let t15;
	if ($[37] !== content || $[38] !== layoutProps) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, {
			...layoutProps,
			children: content
		});
		$[37] = content;
		$[38] = layoutProps;
		$[39] = t15;
	} else t15 = $[39];
	return t15;
}
function Layout(t0) {
	const $ = (0, import_compiler_runtime.c)(15);
	const { children, isEditing, menuItems, onMenuSelect } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const viewRef = (0, import_react.useRef)(null);
	const { setMenuOpen, menuOpen, handleContextMenu, resetPosition, position, asContextMenu } = useContextMenu();
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			display: "block",
			height: "100%",
			"& .hover-visible": {
				opacity: 0,
				transition: "opacity .25s"
			},
			"&:hover .hover-visible": { opacity: 1 }
		};
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] !== asContextMenu || $[2] !== isEditing || $[3] !== menuItems || $[4] !== menuOpen || $[5] !== onMenuSelect || $[6] !== position || $[7] !== resetPosition || $[8] !== setMenuOpen || $[9] !== t) {
		t2 = menuItems && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [isEditing && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			className: [menuOpen ? void 0 : "hover-visible", "non-draggable-area"].join(" "),
			style: {
				position: "absolute",
				top: 7,
				right: 3,
				zIndex: 1
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				ref: triggerRef,
				variant: "bare",
				"aria-label": t("Menu"),
				onPress: () => {
					resetPosition();
					setMenuOpen(true);
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgDotsHorizontalTriple, {
					width: 15,
					height: 15,
					style: { transform: "rotateZ(90deg)" }
				})
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef: asContextMenu ? viewRef : triggerRef,
			isOpen: Boolean(menuOpen),
			onOpenChange: () => setMenuOpen(false),
			isNonModal: true,
			placement: asContextMenu ? "bottom start" : "bottom end",
			...position,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
				className: "non-draggable-area",
				onMenuSelect,
				items: menuItems
			})
		})] });
		$[1] = asContextMenu;
		$[2] = isEditing;
		$[3] = menuItems;
		$[4] = menuOpen;
		$[5] = onMenuSelect;
		$[6] = position;
		$[7] = resetPosition;
		$[8] = setMenuOpen;
		$[9] = t;
		$[10] = t2;
	} else t2 = $[10];
	let t3;
	if ($[11] !== children || $[12] !== handleContextMenu || $[13] !== t2) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			ref: viewRef,
			onContextMenu: handleContextMenu,
			style: t1,
			children: [t2, children]
		});
		$[11] = children;
		$[12] = handleContextMenu;
		$[13] = t2;
		$[14] = t3;
	} else t3 = $[14];
	return t3;
}
//#endregion
//#region src/components/reports/ReportCardName.tsx
var ReportCardName = (t0) => {
	const $ = (0, import_compiler_runtime.c)(10);
	const { name, isEditing, onChange, onClose } = t0;
	if (isEditing) {
		const t1 = Math.max(20, name.length) + "ch";
		let t2;
		if ($[0] !== t1) {
			t2 = {
				...styles.mediumText,
				marginTop: -6,
				marginBottom: -1,
				marginLeft: -6,
				width: t1
			};
			$[0] = t1;
			$[1] = t2;
		} else t2 = $[1];
		let t3;
		if ($[2] !== name || $[3] !== onChange || $[4] !== onClose || $[5] !== t2) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InitialFocus, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
				className: NON_DRAGGABLE_AREA_CLASS_NAME,
				defaultValue: name,
				onEnter: onChange,
				onUpdate: onChange,
				onEscape: onClose,
				style: t2
			}) });
			$[2] = name;
			$[3] = onChange;
			$[4] = onClose;
			$[5] = t2;
			$[6] = t3;
		} else t3 = $[6];
		return t3;
	}
	let t1;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			display: "block",
			margin: 0,
			padding: 0,
			...styles.mediumText,
			marginBottom: 5
		};
		$[7] = t1;
	} else t1 = $[7];
	let t2;
	if ($[8] !== name) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
			style: t1,
			children: name
		});
		$[8] = name;
		$[9] = t2;
	} else t2 = $[9];
	return t2;
};
//#endregion
//#region src/components/reports/useDashboardWidgetCopyMenu.ts
function useDashboardWidgetCopyMenu(onCopy) {
	const { t } = useTranslation();
	const dispatch = useDispatch();
	const menuItems = [{
		name: "copy-to-dashboard",
		text: t("Copy to dashboard")
	}];
	const handleMenuSelect = (item) => {
		switch (item) {
			case "copy-to-dashboard":
				dispatch(pushModal({ modal: {
					name: "copy-widget-to-dashboard",
					options: { onSelect: (targetDashboardId) => {
						onCopy(targetDashboardId);
					} }
				} }));
				return true;
			default: return false;
		}
	};
	return {
		menuItems,
		handleMenuSelect
	};
}
//#endregion
//#region src/components/reports/reports/AgeOfMoneyCard.tsx
function getAgeColor(age) {
	if (age === null) return theme.reportsNumberNeutral;
	if (age >= 30) return theme.reportsNumberPositive;
	if (age >= 14) return theme.warningText;
	return theme.reportsNumberNegative;
}
function getTrendIndicator(trend) {
	switch (trend) {
		case "up": return "↑";
		case "down": return "↓";
		default: return "→";
	}
}
function AgeOfMoneyCard(t0) {
	const $ = (0, import_compiler_runtime.c)(71);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const { t } = useTranslation();
	const { isNarrowWidth } = useResponsive();
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	let t3;
	let t4;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = () => {
			(async function fetchLatestTransaction() {
				const latestTrans = await send("get-latest-transaction");
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
			})();
		};
		t4 = [];
		$[2] = t3;
		$[3] = t4;
	} else {
		t3 = $[2];
		t4 = $[3];
	}
	(0, import_react.useEffect)(t3, t4);
	const t5 = meta?.timeFrame;
	let t6;
	if ($[4] !== latestTransaction || $[5] !== t5) {
		t6 = calculateTimeRange(t5, void 0, latestTransaction);
		$[4] = latestTransaction;
		$[5] = t5;
		$[6] = t6;
	} else t6 = $[6];
	const [start, end] = t6;
	let t7;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = () => setIsCardHovered(true);
		$[7] = t7;
	} else t7 = $[7];
	const onCardHover = t7;
	let t8;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsCardHovered(false);
		$[8] = t8;
	} else t8 = $[8];
	const onCardHoverEnd = t8;
	meta?.conditions;
	meta?.conditionsOp;
	meta?.granularity;
	const t9 = meta?.conditions;
	const t10 = meta?.conditionsOp;
	const t11 = meta?.granularity ?? "monthly";
	let t12;
	if ($[9] !== end || $[10] !== start || $[11] !== t10 || $[12] !== t11 || $[13] !== t9) {
		t12 = createAgeOfMoneySpreadsheet({
			start,
			end,
			conditions: t9,
			conditionsOp: t10,
			granularity: t11
		});
		$[9] = end;
		$[10] = start;
		$[11] = t10;
		$[12] = t11;
		$[13] = t9;
		$[14] = t12;
	} else t12 = $[14];
	const data = useReport$1("age_of_money", t12);
	const t13 = `/reports/age-of-money/${widgetId}`;
	let t14;
	if ($[15] !== t) {
		t14 = t("Rename");
		$[15] = t;
		$[16] = t14;
	} else t14 = $[16];
	let t15;
	if ($[17] !== t14) {
		t15 = {
			name: "rename",
			text: t14
		};
		$[17] = t14;
		$[18] = t15;
	} else t15 = $[18];
	let t16;
	if ($[19] !== t) {
		t16 = t("Remove");
		$[19] = t;
		$[20] = t16;
	} else t16 = $[20];
	let t17;
	if ($[21] !== t16) {
		t17 = {
			name: "remove",
			text: t16
		};
		$[21] = t16;
		$[22] = t17;
	} else t17 = $[22];
	let t18;
	if ($[23] !== copyMenuItems || $[24] !== t15 || $[25] !== t17) {
		t18 = [
			t15,
			t17,
			...copyMenuItems
		];
		$[23] = copyMenuItems;
		$[24] = t15;
		$[25] = t17;
		$[26] = t18;
	} else t18 = $[26];
	let t19;
	if ($[27] !== handleCopyMenuSelect || $[28] !== onRemove) {
		t19 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb53: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb53;
				case "remove":
					onRemove();
					break bb53;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[27] = handleCopyMenuSelect;
		$[28] = onRemove;
		$[29] = t19;
	} else t19 = $[29];
	let t20;
	if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = { flex: 1 };
		$[30] = t20;
	} else t20 = $[30];
	let t21;
	if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			flexDirection: "row",
			padding: 20
		};
		$[31] = t21;
	} else t21 = $[31];
	let t22;
	if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = { flex: 1 };
		$[32] = t22;
	} else t22 = $[32];
	let t23;
	if ($[33] !== meta?.name || $[34] !== t) {
		t23 = meta?.name || t("Age of Money");
		$[33] = meta?.name;
		$[34] = t;
		$[35] = t23;
	} else t23 = $[35];
	let t24;
	if ($[36] !== meta || $[37] !== onMetaChange) {
		t24 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[36] = meta;
		$[37] = onMetaChange;
		$[38] = t24;
	} else t24 = $[38];
	let t25;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = () => setNameMenuOpen(false);
		$[39] = t25;
	} else t25 = $[39];
	let t26;
	if ($[40] !== nameMenuOpen || $[41] !== t23 || $[42] !== t24) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t23,
			isEditing: nameMenuOpen,
			onChange: t24,
			onClose: t25
		});
		$[40] = nameMenuOpen;
		$[41] = t23;
		$[42] = t24;
		$[43] = t26;
	} else t26 = $[43];
	let t27;
	if ($[44] !== end || $[45] !== start) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start,
			end
		});
		$[44] = end;
		$[45] = start;
		$[46] = t27;
	} else t27 = $[46];
	let t28;
	if ($[47] !== t26 || $[48] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t22,
			children: [t26, t27]
		});
		$[47] = t26;
		$[48] = t27;
		$[49] = t28;
	} else t28 = $[49];
	let t29;
	if ($[50] !== data || $[51] !== isCardHovered || $[52] !== t) {
		t29 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { textAlign: "right" },
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
					style: {
						...styles.largeText,
						fontWeight: 500,
						marginBottom: 5,
						color: getAgeColor(data.currentAge)
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
						activationFilters: [!isCardHovered],
						children: data.currentAge !== null ? t("{{days}} days", { days: data.currentAge }) : t("N/A")
					})
				}),
				data.currentAge !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Block, {
					style: {
						fontSize: 12,
						color: theme.pageTextSubdued
					},
					children: [
						getTrendIndicator(data.trend),
						" ",
						data.trend === "up" ? t("Improving") : data.trend === "down" ? t("Declining") : t("Stable")
					]
				}),
				data.insufficientData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
					style: {
						fontSize: 10,
						color: theme.warningText,
						marginTop: 2
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Incomplete data" })
				})
			]
		});
		$[50] = data;
		$[51] = isCardHovered;
		$[52] = t;
		$[53] = t29;
	} else t29 = $[53];
	let t30;
	if ($[54] !== t28 || $[55] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t21,
			children: [t28, t29]
		});
		$[54] = t28;
		$[55] = t29;
		$[56] = t30;
	} else t30 = $[56];
	let t31;
	if ($[57] !== data || $[58] !== isEditing || $[59] !== isNarrowWidth) {
		t31 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoneyGraph, {
			data: data.graphData,
			compact: true,
			showTooltip: !isEditing && !isNarrowWidth,
			style: {
				height: "auto",
				flex: 1
			}
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[57] = data;
		$[58] = isEditing;
		$[59] = isNarrowWidth;
		$[60] = t31;
	} else t31 = $[60];
	let t32;
	if ($[61] !== t30 || $[62] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t20,
			onPointerEnter: onCardHover,
			onPointerLeave: onCardHoverEnd,
			children: [t30, t31]
		});
		$[61] = t30;
		$[62] = t31;
		$[63] = t32;
	} else t32 = $[63];
	let t33;
	if ($[64] !== isEditing || $[65] !== nameMenuOpen || $[66] !== t13 || $[67] !== t18 || $[68] !== t19 || $[69] !== t32) {
		t33 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t13,
			menuItems: t18,
			onMenuSelect: t19,
			children: t32
		});
		$[64] = isEditing;
		$[65] = nameMenuOpen;
		$[66] = t13;
		$[67] = t18;
		$[68] = t19;
		$[69] = t32;
		$[70] = t33;
	} else t33 = $[70];
	return t33;
}
//#endregion
//#region src/components/reports/reports/AgeOfMoney.tsx
function AgeOfMoney() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "age-of-money-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isLoading } = useDashboardWidget(t0);
	if (isLoading) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoneyInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function AgeOfMoneyInner(t0) {
	const $ = (0, import_compiler_runtime.c)(104);
	const { widget } = t0;
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = currentMonth();
		$[0] = t1;
	} else t1 = $[0];
	const [start, setStart] = (0, import_react.useState)(t1);
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = currentMonth();
		$[1] = t2;
	} else t2 = $[1];
	const [end, setEnd] = (0, import_react.useState)(t2);
	const [mode, setMode] = (0, import_react.useState)("sliding-window");
	const [granularity, setGranularity] = (0, import_react.useState)(widget?.meta?.granularity ?? "monthly");
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	let t3;
	if ($[2] !== conditions || $[3] !== conditionsOp || $[4] !== end || $[5] !== granularity || $[6] !== start) {
		t3 = createAgeOfMoneySpreadsheet({
			start,
			end,
			conditions,
			conditionsOp,
			granularity
		});
		$[2] = conditions;
		$[3] = conditionsOp;
		$[4] = end;
		$[5] = granularity;
		$[6] = start;
		$[7] = t3;
	} else t3 = $[7];
	const data = useReport$1("age_of_money", t3);
	let t4;
	let t5;
	if ($[8] !== locale) {
		t4 = () => {
			(async function run() {
				const earliestTrans = await send("get-earliest-transaction");
				setEarliestTransaction(earliestTrans ? earliestTrans.date : currentDay());
				const latestTrans = await send("get-latest-transaction");
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
				const currentMonth$12 = currentMonth();
				let earliestMonth = earliestTrans ? monthFromDate(parseISO(fromDateRepr(earliestTrans.date))) : currentMonth$12;
				const latestTransactionMonth = latestTrans ? monthFromDate(parseISO(fromDateRepr(latestTrans.date))) : currentMonth$12;
				const latestMonth = latestTransactionMonth > currentMonth$12 ? latestTransactionMonth : currentMonth$12;
				const yearAgo = subMonths(latestMonth, 12);
				if (earliestMonth > yearAgo) earliestMonth = yearAgo;
				setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
					name: month,
					pretty: format(month, "MMMM, yyyy", locale)
				})).reverse());
			})();
		};
		t5 = [locale];
		$[8] = locale;
		$[9] = t4;
		$[10] = t5;
	} else {
		t4 = $[9];
		t5 = $[10];
	}
	(0, import_react.useEffect)(t4, t5);
	let t6;
	if ($[11] !== latestTransaction || $[12] !== widget?.meta?.timeFrame) {
		t6 = () => {
			if (latestTransaction) {
				const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, void 0, latestTransaction);
				setStart(initialStart);
				setEnd(initialEnd);
				setMode(initialMode);
			}
		};
		$[11] = latestTransaction;
		$[12] = widget?.meta?.timeFrame;
		$[13] = t6;
	} else t6 = $[13];
	const t7 = widget?.meta?.timeFrame;
	let t8;
	if ($[14] !== latestTransaction || $[15] !== t7) {
		t8 = [latestTransaction, t7];
		$[14] = latestTransaction;
		$[15] = t7;
		$[16] = t8;
	} else t8 = $[16];
	(0, import_react.useEffect)(t6, t8);
	let t9;
	if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = (newStart, newEnd, newMode) => {
			setStart(newStart);
			setEnd(newEnd);
			setMode(newMode);
		};
		$[17] = t9;
	} else t9 = $[17];
	const onChangeDates = t9;
	let t10;
	if ($[18] !== conditions || $[19] !== conditionsOp || $[20] !== dispatch || $[21] !== end || $[22] !== granularity || $[23] !== mode || $[24] !== start || $[25] !== t || $[26] !== widget) {
		t10 = async () => {
			if (!widget) throw new Error("No widget that could be saved.");
			await send("dashboard-update-widget", {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					conditions,
					conditionsOp,
					timeFrame: {
						start,
						end,
						mode
					},
					granularity
				}
			});
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Dashboard widget successfully saved.")
			} }));
		};
		$[18] = conditions;
		$[19] = conditionsOp;
		$[20] = dispatch;
		$[21] = end;
		$[22] = granularity;
		$[23] = mode;
		$[24] = start;
		$[25] = t;
		$[26] = widget;
		$[27] = t10;
	} else t10 = $[27];
	const onSaveWidget = t10;
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	let t11;
	if ($[28] !== t || $[29] !== widget?.meta?.name) {
		t11 = widget?.meta?.name || t("Age of Money");
		$[28] = t;
		$[29] = widget?.meta?.name;
		$[30] = t11;
	} else t11 = $[30];
	const title = t11;
	let t12;
	if ($[31] !== t || $[32] !== widget) {
		t12 = async (newName) => {
			if (!widget) throw new Error("No widget that could be saved.");
			const name = newName || t("Age of Money");
			await send("dashboard-update-widget", {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					name
				}
			});
		};
		$[31] = t;
		$[32] = widget;
		$[33] = t12;
	} else t12 = $[33];
	const onSaveWidgetName = t12;
	if (!allMonths || !data) {
		let t13;
		if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[34] = t13;
		} else t13 = $[34];
		return t13;
	}
	let t13;
	if ($[35] !== isNarrowWidth || $[36] !== navigate || $[37] !== onSaveWidgetName || $[38] !== title || $[39] !== widget) {
		t13 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title });
		$[35] = isNarrowWidth;
		$[36] = navigate;
		$[37] = onSaveWidgetName;
		$[38] = title;
		$[39] = widget;
		$[40] = t13;
	} else t13 = $[40];
	let t14;
	if ($[41] !== granularity) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GranularitySelector, {
			granularity,
			onChange: setGranularity
		});
		$[41] = granularity;
		$[42] = t14;
	} else t14 = $[42];
	let t15;
	if ($[43] !== onSaveWidget || $[44] !== widget) {
		t15 = widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			onPress: onSaveWidget,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
		});
		$[43] = onSaveWidget;
		$[44] = widget;
		$[45] = t15;
	} else t15 = $[45];
	let t16;
	if ($[46] !== allMonths || $[47] !== conditions || $[48] !== conditionsOp || $[49] !== earliestTransaction || $[50] !== end || $[51] !== firstDayOfWeekIdx || $[52] !== latestTransaction || $[53] !== mode || $[54] !== onApplyFilter || $[55] !== onConditionsOpChange || $[56] !== onDeleteFilter || $[57] !== onUpdateFilter || $[58] !== start || $[59] !== t14 || $[60] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			allMonths,
			start,
			end,
			earliestTransaction,
			latestTransaction,
			firstDayOfWeekIdx,
			mode,
			onChangeDates,
			filters: conditions,
			onApply: onApplyFilter,
			onUpdateFilter,
			onDeleteFilter,
			conditionsOp,
			onConditionsOpChange,
			inlineContent: t14,
			children: t15
		});
		$[46] = allMonths;
		$[47] = conditions;
		$[48] = conditionsOp;
		$[49] = earliestTransaction;
		$[50] = end;
		$[51] = firstDayOfWeekIdx;
		$[52] = latestTransaction;
		$[53] = mode;
		$[54] = onApplyFilter;
		$[55] = onConditionsOpChange;
		$[56] = onDeleteFilter;
		$[57] = onUpdateFilter;
		$[58] = start;
		$[59] = t14;
		$[60] = t15;
		$[61] = t16;
	} else t16 = $[61];
	let t17;
	if ($[62] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = {
			backgroundColor: theme.tableBackground,
			padding: 20,
			paddingTop: 0,
			flex: "1 0 auto",
			overflowY: "auto"
		};
		$[62] = t17;
	} else t17 = $[62];
	let t18;
	if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = {
			textAlign: "right",
			paddingTop: 20
		};
		$[63] = t18;
	} else t18 = $[63];
	let t19;
	if ($[64] !== data.currentAge) {
		t19 = getAgeColor(data.currentAge);
		$[64] = data.currentAge;
		$[65] = t19;
	} else t19 = $[65];
	let t20;
	if ($[66] !== t19) {
		t20 = {
			...styles.largeText,
			fontWeight: 400,
			marginBottom: 5,
			color: t19
		};
		$[66] = t19;
		$[67] = t20;
	} else t20 = $[67];
	let t21;
	if ($[68] !== data.currentAge || $[69] !== t) {
		t21 = data.currentAge !== null ? t("{{days}} days", { days: data.currentAge }) : t("N/A");
		$[68] = data.currentAge;
		$[69] = t;
		$[70] = t21;
	} else t21 = $[70];
	let t22;
	if ($[71] !== t21) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: t21 });
		$[71] = t21;
		$[72] = t22;
	} else t22 = $[72];
	let t23;
	if ($[73] !== t20 || $[74] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t20,
			children: t22
		});
		$[73] = t20;
		$[74] = t22;
		$[75] = t23;
	} else t23 = $[75];
	let t24;
	if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = { color: theme.pageTextSubdued };
		$[76] = t24;
	} else t24 = $[76];
	let t25;
	if ($[77] !== data.trend || $[78] !== t) {
		t25 = data.trend === "up" ? t("↑ Improving") : data.trend === "down" ? t("↓ Declining") : t("→ Stable");
		$[77] = data.trend;
		$[78] = t;
		$[79] = t25;
	} else t25 = $[79];
	let t26;
	if ($[80] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t24,
			children: t25
		});
		$[80] = t25;
		$[81] = t26;
	} else t26 = $[81];
	let t27;
	if ($[82] !== data.insufficientData || $[83] !== t) {
		t27 = data.insufficientData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				color: theme.warningText,
				fontSize: 12,
				marginTop: 5
			},
			children: t("Note: Some expenses could not be matched to income (spending exceeded income in this period)")
		});
		$[82] = data.insufficientData;
		$[83] = t;
		$[84] = t27;
	} else t27 = $[84];
	let t28;
	if ($[85] !== t23 || $[86] !== t26 || $[87] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t18,
			children: [
				t23,
				t26,
				t27
			]
		});
		$[85] = t23;
		$[86] = t26;
		$[87] = t27;
		$[88] = t28;
	} else t28 = $[88];
	let t29;
	if ($[89] !== data.graphData) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoneyGraph, { data: data.graphData });
		$[89] = data.graphData;
		$[90] = t29;
	} else t29 = $[90];
	let t30;
	if ($[91] === Symbol.for("react.memo_cache_sentinel")) {
		t30 = {
			marginTop: 30,
			userSelect: "none"
		};
		$[91] = t30;
	} else t30 = $[91];
	let t31;
	if ($[92] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "What is Age of Money?" }) }) });
		$[92] = t31;
	} else t31 = $[92];
	let t32;
	if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Age of Money shows how many days, on average, your money sits in your budget before you spend it. It measures the gap between when you earn money and when you spend it." }) });
		$[93] = t32;
	} else t32 = $[93];
	let t33;
	if ($[94] === Symbol.for("react.memo_cache_sentinel")) {
		t33 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "A higher Age of Money means you're spending older money, which indicates you're living on last month's income rather than paycheck-to-paycheck. An age of 30 days or more is considered ideal—it means you're typically spending money you earned a month ago." }) });
		$[94] = t33;
	} else t33 = $[94];
	let t34;
	if ($[95] === Symbol.for("react.memo_cache_sentinel")) {
		t34 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "How is it calculated?" }) }) });
		$[95] = t34;
	} else t34 = $[95];
	let t35;
	if ($[96] === Symbol.for("react.memo_cache_sentinel")) {
		t35 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t30,
			children: [
				t31,
				t32,
				t33,
				t34,
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "The calculation uses the FIFO (First In, First Out) method: when you spend money, it's considered to come from your oldest income first. The age is the difference in days between when you received that income and when you spent it. The displayed value is the average age of your last 10 expenses." }) })
			]
		});
		$[96] = t35;
	} else t35 = $[96];
	let t36;
	if ($[97] !== t28 || $[98] !== t29) {
		t36 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t17,
			children: [
				t28,
				t29,
				t35
			]
		});
		$[97] = t28;
		$[98] = t29;
		$[99] = t36;
	} else t36 = $[99];
	let t37;
	if ($[100] !== t13 || $[101] !== t16 || $[102] !== t36) {
		t37 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
			header: t13,
			padding: 0,
			children: [t16, t36]
		});
		$[100] = t13;
		$[101] = t16;
		$[102] = t36;
		$[103] = t37;
	} else t37 = $[103];
	return t37;
}
function GranularitySelector(t0) {
	const $ = (0, import_compiler_runtime.c)(40);
	const { granularity, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] !== t) {
		t1 = t("Daily");
		$[0] = t;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== t1) {
		t2 = {
			key: "daily",
			description: t1
		};
		$[2] = t1;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== t) {
		t3 = t("Weekly");
		$[4] = t;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t3) {
		t4 = {
			key: "weekly",
			description: t3
		};
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== t) {
		t5 = t("Monthly");
		$[8] = t;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] !== t5) {
		t6 = {
			key: "monthly",
			description: t5
		};
		$[10] = t5;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== t2 || $[13] !== t4 || $[14] !== t6) {
		t7 = [
			t2,
			t4,
			t6
		];
		$[12] = t2;
		$[13] = t4;
		$[14] = t6;
		$[15] = t7;
	} else t7 = $[15];
	const options = t7;
	const currentLabel = options.find((opt) => opt.key === granularity)?.description ?? granularity;
	let t8;
	if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsOpen(true);
		$[16] = t8;
	} else t8 = $[16];
	let t9;
	if ($[17] !== t) {
		t9 = t("Change granularity");
		$[17] = t;
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	let t11;
	if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCalendar, { style: {
			width: 12,
			height: 12
		} });
		t11 = { marginLeft: 5 };
		$[19] = t10;
		$[20] = t11;
	} else {
		t10 = $[19];
		t11 = $[20];
	}
	let t12;
	if ($[21] !== currentLabel) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t11,
			children: currentLabel
		});
		$[21] = currentLabel;
		$[22] = t12;
	} else t12 = $[22];
	let t13;
	if ($[23] !== t12 || $[24] !== t9) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t8,
			"aria-label": t9,
			children: [t10, t12]
		});
		$[23] = t12;
		$[24] = t9;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = () => setIsOpen(false);
		$[26] = t14;
	} else t14 = $[26];
	let t15;
	if ($[27] !== onChange) {
		t15 = (item) => {
			onChange(item);
			setIsOpen(false);
		};
		$[27] = onChange;
		$[28] = t15;
	} else t15 = $[28];
	let t16;
	if ($[29] !== options) {
		t16 = options.map(_temp$22);
		$[29] = options;
		$[30] = t16;
	} else t16 = $[30];
	let t17;
	if ($[31] !== t15 || $[32] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t15,
			items: t16
		});
		$[31] = t15;
		$[32] = t16;
		$[33] = t17;
	} else t17 = $[33];
	let t18;
	if ($[34] !== isOpen || $[35] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t14,
			children: t17
		});
		$[34] = isOpen;
		$[35] = t17;
		$[36] = t18;
	} else t18 = $[36];
	let t19;
	if ($[37] !== t13 || $[38] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t13, t18] });
		$[37] = t13;
		$[38] = t18;
		$[39] = t19;
	} else t19 = $[39];
	return t19;
}
function _temp$22(t0) {
	const { key, description } = t0;
	return {
		name: key,
		text: description
	};
}
//#endregion
//#region src/components/reports/getCustomTick.ts
var getCustomTick = (value, isPrivacyModeEnabled) => {
	if (isPrivacyModeEnabled) return "...";
	else return value;
};
//#endregion
//#region src/hooks/useBalanceForecast.ts
function useBalanceForecast({ accountIds, conditions, conditionsOp, startDate, endDate, includeAccountlessSchedules, enabled = true }) {
	return useQuery({
		queryKey: ["balance-forecast", {
			accountIds: accountIds ?? null,
			conditions: conditions ?? null,
			conditionsOp: conditionsOp ?? "and",
			startDate,
			endDate,
			includeAccountlessSchedules: includeAccountlessSchedules ?? false
		}],
		queryFn: async () => send("forecast/generate", {
			accountIds,
			conditions,
			conditionsOp,
			startDate,
			endDate,
			includeAccountlessSchedules
		}),
		placeholderData: keepPreviousData,
		enabled
	});
}
//#endregion
//#region src/components/reports/reports/balanceForecastChartData.ts
function getCombinedBalanceByDate(forecastData) {
	const balancesByDateAndAccount = {};
	for (const dataPoint of forecastData.dataPoints) {
		if (!balancesByDateAndAccount[dataPoint.date]) balancesByDateAndAccount[dataPoint.date] = {};
		balancesByDateAndAccount[dataPoint.date][dataPoint.accountId] = dataPoint.balance;
	}
	const combinedBalanceByDate = {};
	for (const [date, balancesByAccount] of Object.entries(balancesByDateAndAccount)) combinedBalanceByDate[date] = Object.values(balancesByAccount).reduce((sum, balance) => sum + balance, 0);
	return combinedBalanceByDate;
}
function getCombinedBalanceByMonth(forecastData) {
	const balancesByMonthAndAccount = {};
	for (const dataPoint of forecastData.dataPoints) {
		const month = dataPoint.date.substring(0, 7);
		if (!balancesByMonthAndAccount[month]) balancesByMonthAndAccount[month] = {};
		balancesByMonthAndAccount[month][dataPoint.accountId] = dataPoint.balance;
	}
	const combinedBalanceByMonth = {};
	for (const [month, balancesByAccount] of Object.entries(balancesByMonthAndAccount)) combinedBalanceByMonth[month] = Object.values(balancesByAccount).reduce((sum, balance) => sum + balance, 0);
	return combinedBalanceByMonth;
}
function buildBalanceForecastChartData({ forecastData, start, end, granularity }) {
	if (!forecastData || forecastData.dataPoints.length === 0) return [];
	if (granularity === "Daily") {
		const result = [];
		let runningBalance = 0;
		const combinedBalanceByDate = getCombinedBalanceByDate(forecastData);
		const startDate = parseDate(start + "-01");
		const endDate = parseDate(lastDayOfMonth(end));
		const current = new Date(startDate);
		while (current <= endDate) {
			const dayStr = format$1(current, "yyyy-MM-dd");
			if (combinedBalanceByDate[dayStr] !== void 0) runningBalance = combinedBalanceByDate[dayStr];
			result.push({
				date: dayStr,
				balance: runningBalance
			});
			current.setDate(current.getDate() + 1);
		}
		return result;
	}
	const result = [];
	let runningBalance = 0;
	const combinedBalanceByMonth = getCombinedBalanceByMonth(forecastData);
	for (let month = start; month <= end; month = addMonths(month, 1)) {
		if (combinedBalanceByMonth[month] !== void 0) runningBalance = combinedBalanceByMonth[month];
		result.push({
			date: month,
			balance: runningBalance
		});
	}
	return result;
}
function countForecastScheduledOccurrences(forecastData) {
	if (!forecastData?.dataPoints.length) return 0;
	const occurrenceKeys = /* @__PURE__ */ new Set();
	for (const dataPoint of forecastData.dataPoints) for (const transaction of dataPoint.transactions) occurrenceKeys.add(`${dataPoint.date}:${transaction.scheduleId}`);
	return occurrenceKeys.size;
}
function getZeroCrossingGradientOffset(chartData) {
	if (chartData.length === 0) return null;
	const balances = chartData.map((point) => point.balance);
	const minBalance = Math.min(...balances);
	const maxBalance = Math.max(...balances);
	if (minBalance >= 0 || maxBalance <= 0) return null;
	return maxBalance / (maxBalance - minBalance) * 100;
}
//#endregion
//#region src/components/reports/reports/BalanceForecast.tsx
function BalanceForecast() {
	const $ = (0, import_compiler_runtime.c)(6);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "balance-forecast-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isLoading } = useDashboardWidget(t0);
	if (isLoading) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	const t1 = widget?.id ?? "new";
	let t2;
	if ($[3] !== t1 || $[4] !== widget) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BalanceForecastInner, { widget }, t1);
		$[3] = t1;
		$[4] = widget;
		$[5] = t2;
	} else t2 = $[5];
	return t2;
}
function BalanceForecastInner({ widget }) {
	const { t } = useTranslation();
	const format$14 = useFormat();
	const privacyMode = usePrivacyMode();
	const locale = useLocale();
	const dispatch = useDispatch();
	const { data: accounts = [] } = useAccounts();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	const currentMonth$11 = currentMonth();
	const [start, setStart] = (0, import_react.useState)(widget?.meta?.timeFrame?.start ?? widget?.meta?.startDate ?? currentMonth$11);
	const [end, setEnd] = (0, import_react.useState)(widget?.meta?.timeFrame?.end ?? widget?.meta?.endDate ?? addMonths(currentMonth$11, 11));
	const [mode, setMode] = (0, import_react.useState)(widget?.meta?.timeFrame?.mode ?? "static");
	const [granularity, setGranularity] = (0, import_react.useState)(widget?.meta?.granularity ?? "Monthly");
	const selectedAccountIds = (0, import_react.useMemo)(() => widget?.meta?.accounts ?? accounts.map((a) => a.id), [accounts, widget?.meta?.accounts]);
	const hasMonthOptions = allMonths != null;
	const startDate = start + "-01";
	const endDate = lastDayOfMonth(end);
	const { data: forecastData, error, isFetching, isPlaceholderData, isPending: isLoading } = useBalanceForecast({
		accountIds: widget ? selectedAccountIds : void 0,
		conditions,
		conditionsOp,
		startDate,
		endDate,
		includeAccountlessSchedules: widget?.meta?.accounts === void 0,
		enabled: hasMonthOptions
	});
	const errorMessage = error instanceof Error ? error.message : error ? t("Failed to load forecast") : null;
	const normalizedForecastData = forecastData ?? null;
	const hasFilters = conditions.length > 0;
	const committedChartRange = (0, import_react.useRef)({
		start,
		end
	});
	async function onSaveWidget() {
		if (!widget) throw new Error("No widget that could be saved.");
		await send("dashboard-update-widget", {
			id: widget.id,
			meta: {
				...widget.meta,
				conditions,
				conditionsOp,
				startDate: start,
				endDate: end,
				granularity,
				timeFrame: {
					start,
					end,
					mode
				}
			}
		});
		dispatch(addNotification({ notification: {
			type: "message",
			message: t("Dashboard widget successfully saved.")
		} }));
	}
	const earliestTransaction = !allMonths || allMonths.length === 0 ? currentMonth$11 : allMonths[allMonths.length - 1]?.name ?? currentMonth$11;
	(0, import_react.useEffect)(() => {
		let cancelled = false;
		async function loadMonths() {
			const currentMonthLocal = currentMonth();
			const earliestTransactionResponse = await send("get-earliest-transaction");
			const earliestMonth = earliestTransactionResponse ? monthFromDate(parseISO(earliestTransactionResponse.date)) : subMonths(currentMonthLocal, 12);
			let futureEndMonth = addMonths(currentMonthLocal, 24);
			if (end > futureEndMonth) futureEndMonth = end;
			if (normalizedForecastData?.forecastEndDate) {
				const forecastEndMonth = monthFromDate(normalizedForecastData.forecastEndDate);
				if (forecastEndMonth > futureEndMonth) futureEndMonth = forecastEndMonth;
			}
			const allMonthsArray = rangeInclusive(earliestMonth, futureEndMonth).map((month) => ({
				name: month,
				pretty: format(month, "MMMM, yyyy", locale)
			})).reverse();
			if (cancelled) return;
			setAllMonths((prev) => {
				if (prev && prev.length === allMonthsArray.length && prev.every((p, i) => p.name === allMonthsArray[i]?.name && p.pretty === allMonthsArray[i]?.pretty)) return prev;
				return allMonthsArray;
			});
		}
		loadMonths();
		return () => {
			cancelled = true;
		};
	}, [
		locale,
		end,
		normalizedForecastData?.forecastEndDate
	]);
	const onChangeDates = (newStart, newEnd, newMode) => {
		setStart(newStart);
		setEnd(newEnd);
		if (newMode) setMode(newMode);
	};
	const chartRange = isPlaceholderData ? committedChartRange.current : {
		start,
		end
	};
	(0, import_react.useEffect)(() => {
		if (normalizedForecastData && !isPlaceholderData) committedChartRange.current = {
			start,
			end
		};
	}, [
		end,
		isPlaceholderData,
		normalizedForecastData,
		start
	]);
	const chartData = buildBalanceForecastChartData({
		forecastData: normalizedForecastData,
		start: chartRange.start,
		end: chartRange.end,
		granularity
	});
	const isUpdatingForecast = isFetching && isPlaceholderData;
	const scheduledOccurrenceCount = countForecastScheduledOccurrences(normalizedForecastData);
	if (!allMonths) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
	if (isLoading && !normalizedForecastData) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
	const lowestPoint = forecastData?.lowestBalance;
	const hasNegativeBalance = chartData.some((d) => d.balance < 0);
	const zeroCrossingGradientOffset = getZeroCrossingGradientOffset(chartData);
	const todayReferenceDate = granularity === "Daily" ? currentDay() : currentMonth();
	const showsTodayReferenceLine = chartData.some((dataPoint) => dataPoint.date === todayReferenceDate);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Balance Forecast" }) }),
		padding: 0,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			allMonths,
			start,
			end,
			earliestTransaction,
			latestTransaction: allMonths[0]?.name ?? addMonths(currentMonth$11, 24),
			mode,
			onChangeDates,
			filters: conditions,
			onApply: onApplyFilter,
			onUpdateFilter,
			onDeleteFilter,
			conditionsOp,
			onConditionsOpChange,
			showFutureRange: true,
			hideModeToggle: true,
			inlineContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
				value: granularity,
				onChange: setGranularity,
				options: [["Monthly", t("Monthly")], ["Daily", t("Daily")]]
			}),
			children: widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: onSaveWidget,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				backgroundColor: theme.tableBackground,
				padding: 20,
				paddingTop: 0,
				flex: "1 0 auto",
				overflowY: "auto"
			},
			children: [
				errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					style: {
						color: theme.errorText,
						marginBottom: 20
					},
					children: errorMessage
				}) : lowestPoint ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						textAlign: "right",
						paddingTop: 20,
						marginBottom: 20
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							...styles.largeText,
							fontWeight: 400,
							marginBottom: 5,
							color: lowestPoint.balance < 0 ? theme.errorText : theme.pageText
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$14(lowestPoint.balance, "financial") })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: { color: theme.pageTextLight },
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Lowest Point" }),
							": ",
							lowestPoint.date,
							lowestPoint.accountName && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
								" (",
								lowestPoint.accountName,
								")"
							] })
						]
					})]
				}) : null,
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					style: {
						flex: 1,
						minHeight: 300
					},
					children: errorMessage ? null : chartData.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, { children: (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResponsiveContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LineChart, {
						width,
						height,
						data: chartData,
						margin: {
							top: 10,
							right: 10,
							left: 5,
							bottom: 10
						},
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("linearGradient", {
								id: "balance-forecast-line-gradient",
								x1: "0",
								y1: "0",
								x2: "0",
								y2: "1",
								children: zeroCrossingGradientOffset == null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
									offset: "0%",
									stopColor: hasNegativeBalance ? theme.errorText : theme.noticeText
								}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
									offset: `${zeroCrossingGradientOffset}%`,
									stopColor: theme.noticeText
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
									offset: `${zeroCrossingGradientOffset}%`,
									stopColor: theme.errorText
								})] })
							}) }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
								dataKey: "date",
								tick: { fill: theme.pageText },
								tickLine: { stroke: theme.pageText },
								interval: granularity === "Daily" ? Math.ceil(chartData.length / 10) : 0,
								tickFormatter: (value) => {
									if (granularity === "Daily") return format$1(parseDate(value), "MMM d");
									return value;
								}
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
								domain: ["auto", "auto"],
								tickFormatter: (value_0) => getCustomTick(format$14(value_0, "financial-no-decimals"), privacyMode),
								tick: { fill: theme.pageText },
								tickLine: { stroke: theme.pageText },
								tickSize: 0
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
								isAnimationActive: false,
								content: ({ active, payload }) => {
									if (active && payload && payload.length) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										style: {
											zIndex: 1e3,
											pointerEvents: "none",
											borderRadius: 2,
											boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
											backgroundColor: theme.menuBackground,
											color: theme.menuItemText,
											padding: 10
										},
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
											style: { marginBottom: 5 },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: format$14(payload[0].value, "financial") })]
									});
									return null;
								}
							}),
							showsTodayReferenceLine && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
								x: todayReferenceDate,
								stroke: theme.noticeText,
								strokeDasharray: "4 4",
								label: {
									value: t("Today"),
									fill: theme.noticeText,
									fontSize: 12,
									position: "insideTop",
									offset: 8
								}
							}),
							hasNegativeBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
								y: 0,
								stroke: theme.pageTextSubdued
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
								type: "monotone",
								dataKey: "balance",
								stroke: "url(#balance-forecast-line-gradient)",
								strokeWidth: 2,
								dot: false,
								activeDot: { r: 6 },
								opacity: isUpdatingForecast ? .45 : 1
							})
						]
					}) }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						style: {
							marginTop: 12,
							fontSize: 12,
							color: theme.pageTextLight
						},
						children: [scheduledOccurrenceCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "This range shows posted transactions only; no scheduled occurrences fall in it." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, {
							count: scheduledOccurrenceCount,
							children: [{ count: scheduledOccurrenceCount }, " scheduled transactions included in this date range"]
						}), isUpdatingForecast ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Updating..." })] }) : null]
					})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						style: {
							flex: 1,
							justifyContent: "center",
							alignItems: "center",
							display: "flex",
							minHeight: 200
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: { color: theme.pageTextLight },
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No transactions are included in this report. Adjust your filters, accounts, or date range to see a balance projection." })
						})
					})
				}),
				!errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					style: {
						marginTop: 20,
						fontSize: 12,
						color: theme.pageTextLight
					},
					children: hasFilters ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "This forecast shows the running total of matching posted transactions, plus upcoming scheduled transactions in the future." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "This forecast shows your running balance from posted transactions, plus upcoming scheduled transactions in the future." })
				})
			]
		})]
	});
}
//#endregion
//#region src/components/reports/Change.tsx
function Change(t0) {
	const $ = (0, import_compiler_runtime.c)(10);
	const { amount, style } = t0;
	const format = useFormat();
	const t1 = amount === 0 ? theme.reportsNumberNeutral : amount < 0 ? theme.reportsNumberNegative : theme.reportsNumberPositive;
	let t2;
	if ($[0] !== style || $[1] !== t1) {
		t2 = {
			...styles.smallText,
			color: t1,
			...style
		};
		$[0] = style;
		$[1] = t1;
		$[2] = t2;
	} else t2 = $[2];
	const t3 = amount >= 0 ? "+" : "";
	let t4;
	if ($[3] !== amount || $[4] !== format) {
		t4 = format(amount, "financial");
		$[3] = amount;
		$[4] = format;
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FinancialText, {
			as: Block,
			style: t2,
			children: [t3, t4]
		});
		$[6] = t2;
		$[7] = t3;
		$[8] = t4;
		$[9] = t5;
	} else t5 = $[9];
	return t5;
}
//#endregion
//#region src/components/reports/graphs/util/computePadding.ts
/**
* Calculates the left padding needed for chart axis based on formatted number length
* @param values Array of numeric values
* @param formatter Function to format numbers to strings
* @returns Padding amount in pixels
*/
function computePadding(values, formatter) {
	if (values.length === 0) return 0;
	const maxLength = Math.max(...values.map((value) => {
		return formatter(Math.round(value)).length;
	}));
	return Math.max(0, (maxLength - 5) * 5);
}
//#endregion
//#region src/components/reports/graphs/BudgetAnalysisGraph.tsx
function CustomTooltip$8(t0) {
	const $ = (0, import_compiler_runtime.c)(50);
	const { active, payload, isConcise, format: format$13, showBalance } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	if (!active || !payload || !Array.isArray(payload) || !payload[0]) return null;
	const [t1] = payload;
	const { payload: data } = t1;
	let t2;
	let t3;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = css({
			pointerEvents: "none",
			borderRadius: 2,
			boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
			backgroundColor: theme.menuBackground,
			color: theme.menuItemText,
			padding: 10
		});
		t3 = { marginBottom: 10 };
		$[0] = t2;
		$[1] = t3;
	} else {
		t2 = $[0];
		t3 = $[1];
	}
	let t4;
	if ($[2] !== data.date || $[3] !== isConcise || $[4] !== locale) {
		t4 = format(data.date, isConcise ? "MMMM yyyy" : "MMMM dd, yyyy", locale);
		$[2] = data.date;
		$[3] = isConcise;
		$[4] = locale;
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			style: t3,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t4 })
		});
		$[6] = t4;
		$[7] = t5;
	} else t5 = $[7];
	let t6;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = { lineHeight: 1.5 };
		$[8] = t6;
	} else t6 = $[8];
	let t7;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
			style: {
				display: "flex",
				alignItems: "center",
				gap: 5
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: {
				width: 10,
				height: 10,
				backgroundColor: theme.reportsNumberPositive,
				display: "inline-block"
			} }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted:" })]
		});
		$[9] = t7;
	} else t7 = $[9];
	let t8;
	if ($[10] !== data.budgeted || $[11] !== format$13) {
		t8 = format$13(data.budgeted, "financial");
		$[10] = data.budgeted;
		$[11] = format$13;
		$[12] = t8;
	} else t8 = $[12];
	let t9;
	if ($[13] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t7,
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t8 })
		});
		$[13] = t8;
		$[14] = t9;
	} else t9 = $[14];
	let t10;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
			style: {
				display: "flex",
				alignItems: "center",
				gap: 5
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: {
				width: 10,
				height: 10,
				backgroundColor: theme.reportsNumberNegative,
				display: "inline-block"
			} }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Spent:" })]
		});
		$[15] = t10;
	} else t10 = $[15];
	let t11;
	if ($[16] !== data.spent || $[17] !== format$13) {
		t11 = format$13(data.spent, "financial");
		$[16] = data.spent;
		$[17] = format$13;
		$[18] = t11;
	} else t11 = $[18];
	let t12;
	if ($[19] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t10,
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t11 })
		});
		$[19] = t11;
		$[20] = t12;
	} else t12 = $[20];
	let t13;
	let t14;
	if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = {
			display: "flex",
			alignItems: "center",
			gap: 5
		};
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: {
			width: 10,
			height: 10,
			backgroundColor: theme.templateNumberUnderFunded,
			display: "inline-block"
		} });
		$[21] = t13;
		$[22] = t14;
	} else {
		t13 = $[21];
		t14 = $[22];
	}
	let t15;
	if ($[23] !== t) {
		t15 = t("Overspending Adjustment:");
		$[23] = t;
		$[24] = t15;
	} else t15 = $[24];
	let t16;
	if ($[25] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
			style: t13,
			children: [t14, t15]
		});
		$[25] = t15;
		$[26] = t16;
	} else t16 = $[26];
	let t17;
	if ($[27] !== data.overspendingAdjustment || $[28] !== format$13) {
		t17 = format$13(data.overspendingAdjustment, "financial");
		$[27] = data.overspendingAdjustment;
		$[28] = format$13;
		$[29] = t17;
	} else t17 = $[29];
	let t18;
	if ($[30] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t17 });
		$[30] = t17;
		$[31] = t18;
	} else t18 = $[31];
	let t19;
	if ($[32] !== t16 || $[33] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t16,
			right: t18
		});
		$[32] = t16;
		$[33] = t18;
		$[34] = t19;
	} else t19 = $[34];
	let t20;
	if ($[35] !== data.balance || $[36] !== format$13 || $[37] !== showBalance) {
		t20 = showBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
				style: {
					display: "flex",
					alignItems: "center",
					gap: 5
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: {
					width: 10,
					height: 10,
					backgroundColor: theme.reportsGray,
					display: "inline-block"
				} }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Balance:" })]
			}),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: format$13(data.balance, "financial") }) })
		});
		$[35] = data.balance;
		$[36] = format$13;
		$[37] = showBalance;
		$[38] = t20;
	} else t20 = $[38];
	let t21;
	if ($[39] !== t12 || $[40] !== t19 || $[41] !== t20 || $[42] !== t9) {
		t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			style: t6,
			children: [
				t9,
				t12,
				t19,
				t20
			]
		});
		$[39] = t12;
		$[40] = t19;
		$[41] = t20;
		$[42] = t9;
		$[43] = t21;
	} else t21 = $[43];
	let t22;
	if ($[44] !== t21 || $[45] !== t5) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t21] });
		$[44] = t21;
		$[45] = t5;
		$[46] = t22;
	} else t22 = $[46];
	let t23;
	if ($[47] !== t2 || $[48] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: t2,
			children: t22
		});
		$[47] = t2;
		$[48] = t22;
		$[49] = t23;
	} else t23 = $[49];
	return t23;
}
function BudgetAnalysisGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(37);
	const { style, data, graphType: t1, showBalance: t2, isConcise: t3 } = t0;
	const graphType = t1 === void 0 ? "Line" : t1;
	const showBalance = t2 === void 0 ? true : t2;
	const isConcise = t3 === void 0 ? true : t3;
	const { t } = useTranslation();
	const format$12 = useFormat();
	const locale = useLocale();
	const privacyMode = usePrivacyMode();
	const [yAxisIsHovered, setYAxisIsHovered] = (0, import_react.useState)(false);
	let t4;
	if ($[0] !== t) {
		t4 = t("Budgeted");
		$[0] = t;
		$[1] = t4;
	} else t4 = $[1];
	const budgetedLabel = t4;
	let t5;
	if ($[2] !== t) {
		t5 = t("Spent");
		$[2] = t;
		$[3] = t5;
	} else t5 = $[3];
	const spentLabel = t5;
	let t6;
	if ($[4] !== t) {
		t6 = t("Balance");
		$[4] = t;
		$[5] = t6;
	} else t6 = $[5];
	const balanceLabel = t6;
	let t7;
	if ($[6] !== t) {
		t7 = t("Overspending Adjustment");
		$[6] = t;
		$[7] = t7;
	} else t7 = $[7];
	const overspendingLabel = t7;
	const graphData = data.intervalData;
	let t8;
	if ($[8] !== isConcise || $[9] !== locale) {
		t8 = (date) => {
			if (isConcise) return format(date, "MMM", locale);
			return format(date, "MMM d", locale);
		};
		$[8] = isConcise;
		$[9] = locale;
		$[10] = t8;
	} else t8 = $[10];
	const formatDate = t8;
	let t9;
	if ($[11] !== format$12 || $[12] !== graphData) {
		const allValues = graphData.flatMap(_temp$21);
		let t10;
		if ($[14] !== format$12) {
			t10 = (value) => format$12(value, "financial-no-decimals");
			$[14] = format$12;
			$[15] = t10;
		} else t10 = $[15];
		t9 = computePadding(allValues, t10);
		$[11] = format$12;
		$[12] = graphData;
		$[13] = t9;
	} else t9 = $[13];
	const t10 = 5 + t9;
	let t11;
	if ($[16] !== t10) {
		t11 = {
			top: 5,
			right: 5,
			left: t10,
			bottom: 5
		};
		$[16] = t10;
		$[17] = t11;
	} else t11 = $[17];
	let t12;
	if ($[18] !== graphData || $[19] !== t11) {
		t12 = {
			width: 0,
			height: 0,
			data: graphData,
			margin: t11
		};
		$[18] = graphData;
		$[19] = t11;
		$[20] = t12;
	} else t12 = $[20];
	const commonProps = t12;
	let t13;
	if ($[21] !== balanceLabel || $[22] !== budgetedLabel || $[23] !== commonProps || $[24] !== format$12 || $[25] !== formatDate || $[26] !== graphType || $[27] !== isConcise || $[28] !== overspendingLabel || $[29] !== privacyMode || $[30] !== showBalance || $[31] !== spentLabel || $[32] !== yAxisIsHovered) {
		t13 = (width, height) => {
			const chartProps = {
				...commonProps,
				width,
				height
			};
			return graphType === "Bar" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ComposedChart, {
				...chartProps,
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
						strokeDasharray: "3 3",
						stroke: theme.pillBorder
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
						dataKey: "date",
						tick: { fill: theme.reportsLabel },
						tickFormatter: formatDate,
						minTickGap: 50
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
						tick: { fill: theme.reportsLabel },
						tickCount: 8,
						tickFormatter: (value_0) => privacyMode && !yAxisIsHovered ? "..." : format$12(value_0, "financial-no-decimals"),
						onMouseEnter: () => setYAxisIsHovered(true),
						onMouseLeave: () => setYAxisIsHovered(false),
						stroke: theme.pageTextSubdued
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
						cursor: { fill: "transparent" },
						content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$8, {
							isConcise,
							format: format$12,
							showBalance
						}),
						isAnimationActive: false
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
						dataKey: "budgeted",
						fill: theme.reportsNumberPositive,
						name: budgetedLabel,
						animationDuration: 1e3
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
						dataKey: "spent",
						fill: theme.reportsNumberNegative,
						name: spentLabel,
						animationDuration: 1e3
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
						dataKey: "overspendingAdjustment",
						fill: theme.templateNumberUnderFunded,
						name: overspendingLabel,
						animationDuration: 1e3
					}),
					showBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
						type: "monotone",
						dataKey: "balance",
						stroke: theme.reportsGray,
						strokeWidth: 2,
						name: balanceLabel,
						dot: false,
						animationDuration: 1e3
					})
				]
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LineChart, {
				...chartProps,
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
						strokeDasharray: "3 3",
						stroke: theme.pillBorder
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
						dataKey: "date",
						tick: { fill: theme.reportsLabel },
						tickFormatter: formatDate,
						minTickGap: 50
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
						tick: { fill: theme.reportsLabel },
						tickCount: 8,
						tickFormatter: (value_1) => privacyMode && !yAxisIsHovered ? "..." : format$12(value_1, "financial-no-decimals"),
						onMouseEnter: () => setYAxisIsHovered(true),
						onMouseLeave: () => setYAxisIsHovered(false),
						stroke: theme.pageTextSubdued
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
						cursor: { fill: "transparent" },
						content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$8, {
							isConcise,
							format: format$12,
							showBalance
						}),
						isAnimationActive: false
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
						type: "monotone",
						dataKey: "budgeted",
						stroke: theme.reportsNumberPositive,
						strokeWidth: 2,
						name: budgetedLabel,
						dot: false,
						animationDuration: 1e3
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
						type: "monotone",
						dataKey: "spent",
						stroke: theme.reportsNumberNegative,
						strokeWidth: 2,
						name: spentLabel,
						dot: false,
						animationDuration: 1e3
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
						type: "monotone",
						dataKey: "overspendingAdjustment",
						stroke: theme.templateNumberUnderFunded,
						strokeWidth: 2,
						name: overspendingLabel,
						dot: false,
						animationDuration: 1e3
					}),
					showBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
						type: "monotone",
						dataKey: "balance",
						stroke: theme.reportsGray,
						strokeWidth: 2,
						name: balanceLabel,
						dot: false,
						animationDuration: 1e3
					})
				]
			});
		};
		$[21] = balanceLabel;
		$[22] = budgetedLabel;
		$[23] = commonProps;
		$[24] = format$12;
		$[25] = formatDate;
		$[26] = graphType;
		$[27] = isConcise;
		$[28] = overspendingLabel;
		$[29] = privacyMode;
		$[30] = showBalance;
		$[31] = spentLabel;
		$[32] = yAxisIsHovered;
		$[33] = t13;
	} else t13 = $[33];
	let t14;
	if ($[34] !== style || $[35] !== t13) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style,
			children: t13
		});
		$[34] = style;
		$[35] = t13;
		$[36] = t14;
	} else t14 = $[36];
	return t14;
}
function _temp$21(item) {
	return [
		item.budgeted,
		item.spent,
		item.balance,
		item.overspendingAdjustment
	];
}
//#endregion
//#region src/components/reports/spreadsheets/budget-analysis-spreadsheet.ts
function createBudgetAnalysisSpreadsheet({ conditions = [], conditionsOp = "and", startDate, endDate }) {
	return async (spreadsheet, setData) => {
		const { list: allCategories, grouped: allCategoryGroups } = await send("get-categories");
		const groupNameById = new Map(allCategoryGroups.map((g) => [g.id, g.name]));
		const relevantConditions = conditions.filter((cond) => !cond.customName && (cond.field === "category" || cond.field === "category_group"));
		const baseCategories = allCategories.filter((cat) => !cat.is_income && !cat.hidden);
		let categoriesToInclude;
		if (relevantConditions.length > 0) {
			const conditionResults = relevantConditions.map((cond) => {
				const getKey = (cat) => cond.field === "category_group" ? cat.group : cat.id;
				const matchesRegex = cond.op === "matches" && typeof cond.value === "string" && cond.value.length <= 256 ? (() => {
					try {
						return new RegExp(cond.value, "i");
					} catch {
						return null;
					}
				})() : null;
				return baseCategories.filter((cat) => {
					const key = getKey(cat);
					const textValue = cond.field === "category_group" ? groupNameById.get(key) ?? key : cat.name;
					if (cond.op === "is") return cond.value === key;
					else if (cond.op === "isNot") return cond.value !== key;
					else if (cond.op === "oneOf") return Array.isArray(cond.value) && cond.value.includes(key);
					else if (cond.op === "notOneOf") return Array.isArray(cond.value) && !cond.value.includes(key);
					else if (cond.op === "contains") return typeof cond.value === "string" && textValue.toLowerCase().includes(cond.value.toLowerCase());
					else if (cond.op === "doesNotContain") return typeof cond.value === "string" && !textValue.toLowerCase().includes(cond.value.toLowerCase());
					else if (cond.op === "matches") return matchesRegex?.test(textValue) ?? false;
					return false;
				});
			});
			if (conditionsOp === "or") {
				const categoryIds = new Set(conditionResults.flat().map((cat) => cat.id));
				categoriesToInclude = baseCategories.filter((cat) => categoryIds.has(cat.id));
			} else if (conditionResults.length === 0) categoriesToInclude = [];
			else {
				const firstSet = new Set(conditionResults[0].map((cat) => cat.id));
				for (let i = 1; i < conditionResults.length; i++) {
					const currentIds = new Set(conditionResults[i].map((cat) => cat.id));
					for (const id of firstSet) if (!currentIds.has(id)) firstSet.delete(id);
				}
				categoriesToInclude = baseCategories.filter((cat) => firstSet.has(cat.id));
			}
		} else categoriesToInclude = baseCategories;
		const intervals = rangeInclusive(getMonth(startDate), getMonth(endDate));
		const intervalData = [];
		let runningBalance = 0;
		const prevMonthData = await send("envelope-budget-month", { month: subMonths(getMonth(startDate), 1) });
		for (const cat of categoriesToInclude) {
			const balanceCell = prevMonthData.find((cell) => cell.name.endsWith(`leftover-${cat.id}`));
			const carryoverCell = prevMonthData.find((cell) => cell.name.endsWith(`carryover-${cat.id}`));
			const catBalance = balanceCell?.value || 0;
			const hasCarryover = Boolean(carryoverCell?.value);
			if (catBalance > 0 || catBalance < 0 && hasCarryover) runningBalance += catBalance;
		}
		let totalBudgeted = 0;
		let totalSpent = 0;
		let totalOverspendingAdjustment = 0;
		let overspendingFromPrevMonth = 0;
		for (const month of intervals) {
			const monthData = await send("envelope-budget-month", { month });
			let budgeted = 0;
			let spent = 0;
			let overspendingThisMonth = 0;
			let carryoverToNextMonth = 0;
			for (const cat of categoriesToInclude) {
				const budgetCell = monthData.find((cell) => cell.name.endsWith(`budget-${cat.id}`));
				const spentCell = monthData.find((cell) => cell.name.endsWith(`sum-amount-${cat.id}`));
				const balanceCell = monthData.find((cell) => cell.name.endsWith(`leftover-${cat.id}`));
				const carryoverCell = monthData.find((cell) => cell.name.endsWith(`carryover-${cat.id}`));
				const catBudgeted = budgetCell?.value || 0;
				const catSpent = spentCell?.value || 0;
				const catBalance = balanceCell?.value || 0;
				const hasCarryover = Boolean(carryoverCell?.value);
				budgeted += catBudgeted;
				spent += catSpent;
				if (catBalance > 0 || catBalance < 0 && hasCarryover) carryoverToNextMonth += catBalance;
				else if (catBalance < 0 && !hasCarryover) overspendingThisMonth += catBalance;
			}
			const overspendingAdjustment = overspendingFromPrevMonth;
			const monthBalance = budgeted + spent + runningBalance;
			totalBudgeted += budgeted;
			totalSpent += spent;
			totalOverspendingAdjustment += Math.abs(overspendingAdjustment);
			intervalData.push({
				date: month,
				budgeted,
				spent,
				balance: monthBalance,
				overspendingAdjustment: Math.abs(overspendingAdjustment)
			});
			runningBalance = carryoverToNextMonth;
			overspendingFromPrevMonth = overspendingThisMonth;
		}
		setData({
			intervalData,
			startDate,
			endDate,
			totalBudgeted,
			totalSpent,
			totalOverspendingAdjustment,
			finalOverspendingAdjustment: overspendingFromPrevMonth
		});
	};
}
//#endregion
//#region src/reports/mutations.ts
var sendThrow = async (name, args) => {
	const { error, data } = await sendCatch(name, args);
	if (error) throw error;
	return data;
};
function invalidateReportQueries(queryClient, queryKey) {
	queryClient.invalidateQueries({ queryKey: queryKey ?? reportQueries.lists() });
}
function invalidateDashboardQueries(queryClient, queryKey) {
	queryClient.invalidateQueries({ queryKey: queryKey ?? dashboardQueries.lists() });
}
function dispatchErrorNotification(dispatch, message, error) {
	dispatch(addNotification({ notification: {
		id: v4(),
		type: "error",
		message,
		pre: error ? error.message : void 0
	} }));
}
function useUpdateReportMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ report }) => {
			return await sendThrow("report/update", report);
		},
		onSuccess: () => invalidateReportQueries(queryClient),
		onError: (error) => {
			console.error("Error updating report:", error);
			dispatchErrorNotification(dispatch, t("There was an error updating the report. Please try again."), error);
		}
	});
}
function useDeleteReportMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id }) => {
			return await sendThrow("report/delete", id);
		},
		onSuccess: () => invalidateReportQueries(queryClient),
		onError: (error) => {
			console.error("Error deleting report:", error);
			dispatchErrorNotification(dispatch, t("There was an error deleting the report. Please try again."), error);
		}
	});
}
function useCreateReportMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ report }) => {
			return await sendThrow("report/create", report);
		},
		onSuccess: () => invalidateReportQueries(queryClient),
		onError: (error) => {
			console.error("Error creating report:", error);
			dispatchErrorNotification(dispatch, t("There was an error creating the report. Please try again."), error);
		}
	});
}
function useCreateDashboardPageMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ name }) => {
			return await sendThrow("dashboard-create", { name });
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error creating dashboard page:", error);
			dispatchErrorNotification(dispatch, t("There was an error creating the dashboard page. Please try again."), error);
		}
	});
}
function useDeleteDashboardPageMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id }) => {
			return await sendThrow("dashboard-delete", id);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error deleting dashboard page:", error);
			dispatchErrorNotification(dispatch, t("There was an error deleting the dashboard page. Please try again."), error);
		}
	});
}
function useRenameDashboardPageMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id, name }) => {
			return await sendThrow("dashboard-rename", {
				id,
				name
			});
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error renaming dashboard page:", error);
			dispatchErrorNotification(dispatch, t("There was an error renaming the dashboard page. Please try again."), error);
		}
	});
}
function useUpdateDashboardWidgetsMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ widgets }) => {
			return await sendThrow("dashboard-update", widgets);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error updating dashboard widgets:", error);
			dispatchErrorNotification(dispatch, t("There was an error updating the dashboard widgets. Please try again."), error);
		}
	});
}
function useUpdateDashboardWidgetMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ widget }) => {
			return await sendThrow("dashboard-update-widget", widget);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error updating dashboard widget:", error);
			dispatchErrorNotification(dispatch, t("There was an error updating the dashboard widget. Please try again."), error);
		}
	});
}
function useResetDashboardPageMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id }) => {
			return await sendThrow("dashboard-reset", id);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error resetting dashboard page:", error);
			dispatchErrorNotification(dispatch, t("There was an error resetting the dashboard page. Please try again."), error);
		}
	});
}
function useAddDashboardWidgetMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ widget }) => {
			return await sendThrow("dashboard-add-widget", widget);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error adding dashboard widget:", error);
			dispatchErrorNotification(dispatch, t("There was an error adding the dashboard widget. Please try again."), error);
		}
	});
}
function useRemoveDashboardWidgetMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id }) => {
			return await sendThrow("dashboard-remove-widget", id);
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error removing dashboard widget:", error);
			dispatchErrorNotification(dispatch, t("There was an error removing the dashboard widget. Please try again."), error);
		}
	});
}
function useCopyDashboardWidgetMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ id, targetDashboardPageId }) => {
			return await sendThrow("dashboard-copy-widget", {
				id,
				targetDashboardPageId
			});
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error copying dashboard widget:", error);
			dispatchErrorNotification(dispatch, t("There was an error copying the dashboard widget. Please try again."), error);
		}
	});
}
function useImportDashboardPageMutation() {
	const queryClient = useQueryClient();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	return useMutation({
		mutationFn: async ({ filePath, dashboardPageId }) => {
			return await sendThrow("dashboard-import", {
				filePath,
				dashboardPageId
			});
		},
		onSuccess: () => invalidateDashboardQueries(queryClient),
		onError: (error) => {
			console.error("Error importing dashboard page:", error);
			dispatchErrorNotification(dispatch, t("There was an error importing the dashboard page. Please try again."), error);
		}
	});
}
//#endregion
//#region src/components/reports/reports/BudgetAnalysis.tsx
function BudgetAnalysis() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "budget-analysis-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysisInternal, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function BudgetAnalysisInternal(t0) {
	const $ = (0, import_compiler_runtime.c)(118);
	const { widget } = t0;
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	const format$11 = useFormat();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = currentMonth();
		$[0] = t1;
	} else t1 = $[0];
	const [start, setStart] = (0, import_react.useState)(t1);
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = currentMonth();
		$[1] = t2;
	} else t2 = $[1];
	const [end, setEnd] = (0, import_react.useState)(t2);
	const [mode, setMode] = (0, import_react.useState)("sliding-window");
	const [graphType, setGraphType] = (0, import_react.useState)(widget?.meta?.graphType || "Bar");
	const [showBalance, setShowBalance] = (0, import_react.useState)(widget?.meta?.showBalance ?? true);
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [isConcise, setIsConcise] = (0, import_react.useState)(_temp$20);
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const calculateIsConcise = _temp2$14;
	let t3;
	if ($[2] !== locale || $[3] !== widget) {
		t3 = () => {
			(async function run() {
				const earliestTrans = await send("get-earliest-transaction");
				const latestTrans = await send("get-latest-transaction");
				const latestTransDate = latestTrans ? fromDateRepr(latestTrans.date) : currentDay();
				setLatestTransaction(latestTransDate);
				const currentMonth$10 = currentMonth();
				let earliestMonth = earliestTrans ? monthFromDate(parseISO(fromDateRepr(earliestTrans.date))) : currentMonth$10;
				const latestTransactionMonth = latestTrans ? monthFromDate(parseISO(fromDateRepr(latestTrans.date))) : currentMonth$10;
				const latestMonth = latestTransactionMonth > currentMonth$10 ? latestTransactionMonth : currentMonth$10;
				const yearAgo = subMonths(latestMonth, 12);
				if (earliestMonth > yearAgo) earliestMonth = yearAgo;
				setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
					name: month,
					pretty: format(month, "MMMM, yyyy", locale)
				})).reverse());
				if (widget?.meta?.timeFrame) {
					const [calculatedStart, calculatedEnd] = calculateTimeRange(widget.meta.timeFrame, void 0, latestTransDate);
					setStart(calculatedStart);
					setEnd(calculatedEnd);
					setMode(widget.meta.timeFrame.mode);
					setIsConcise(calculateIsConcise(calculatedStart, calculatedEnd));
				} else {
					const [liveStart, liveEnd] = calculateTimeRange({
						start: subMonths(currentMonth$10, 5),
						end: currentMonth$10,
						mode: "sliding-window"
					});
					setStart(liveStart);
					setEnd(liveEnd);
					setIsConcise(calculateIsConcise(liveStart, liveEnd));
				}
			})();
		};
		$[2] = locale;
		$[3] = widget;
		$[4] = t3;
	} else t3 = $[4];
	const t4 = widget?.meta?.timeFrame;
	let t5;
	if ($[5] !== locale || $[6] !== t4) {
		t5 = [locale, t4];
		$[5] = locale;
		$[6] = t4;
		$[7] = t5;
	} else t5 = $[7];
	(0, import_react.useEffect)(t3, t5);
	const startDate = start + "-01";
	let t6;
	if ($[8] !== end) {
		t6 = getMonthEnd(end + "-01");
		$[8] = end;
		$[9] = t6;
	} else t6 = $[9];
	const endDate = t6;
	let t7;
	if ($[10] !== conditions || $[11] !== conditionsOp || $[12] !== endDate || $[13] !== startDate) {
		t7 = createBudgetAnalysisSpreadsheet({
			conditions,
			conditionsOp,
			startDate,
			endDate
		});
		$[10] = conditions;
		$[11] = conditionsOp;
		$[12] = endDate;
		$[13] = startDate;
		$[14] = t7;
	} else t7 = $[14];
	const data = useReport$1("default", t7);
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	let t8;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = (newStart, newEnd, newMode) => {
			setStart(newStart);
			setEnd(newEnd);
			setMode(newMode);
			setIsConcise(calculateIsConcise(newStart, newEnd));
		};
		$[15] = t8;
	} else t8 = $[15];
	const onChangeDates = t8;
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	let t9;
	if ($[16] !== conditions || $[17] !== conditionsOp || $[18] !== dispatch || $[19] !== end || $[20] !== graphType || $[21] !== mode || $[22] !== showBalance || $[23] !== start || $[24] !== t || $[25] !== updateDashboardWidgetMutation || $[26] !== widget) {
		t9 = async function onSaveWidget() {
			if (!widget) throw new Error("No widget that could be saved.");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					conditions,
					conditionsOp,
					timeFrame: {
						start,
						end,
						mode
					},
					graphType,
					showBalance
				}
			} }, { onSuccess: () => {
				dispatch(addNotification({ notification: {
					type: "message",
					message: t("Dashboard widget successfully saved.")
				} }));
			} });
		};
		$[16] = conditions;
		$[17] = conditionsOp;
		$[18] = dispatch;
		$[19] = end;
		$[20] = graphType;
		$[21] = mode;
		$[22] = showBalance;
		$[23] = start;
		$[24] = t;
		$[25] = updateDashboardWidgetMutation;
		$[26] = widget;
		$[27] = t9;
	} else t9 = $[27];
	const onSaveWidget = t9;
	if (!data || !allMonths) {
		let t10;
		if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[28] = t10;
		} else t10 = $[28];
		return t10;
	}
	const endingBalance = data.intervalData[data.intervalData.length - 1]?.balance ?? 0;
	let t10;
	if ($[29] !== t || $[30] !== widget?.meta?.name) {
		t10 = widget?.meta?.name || t("Budget Analysis");
		$[29] = t;
		$[30] = widget?.meta?.name;
		$[31] = t10;
	} else t10 = $[31];
	const title = t10;
	let t11;
	if ($[32] !== t || $[33] !== updateDashboardWidgetMutation || $[34] !== widget) {
		t11 = async (newName) => {
			if (!widget) throw new Error("No widget that could be saved.");
			const name = newName || t("Budget Analysis");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					name
				}
			} });
		};
		$[32] = t;
		$[33] = updateDashboardWidgetMutation;
		$[34] = widget;
		$[35] = t11;
	} else t11 = $[35];
	const onSaveWidgetName = t11;
	let t12;
	if ($[36] !== isNarrowWidth || $[37] !== navigate || $[38] !== onSaveWidgetName || $[39] !== title || $[40] !== widget) {
		t12 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title });
		$[36] = isNarrowWidth;
		$[37] = navigate;
		$[38] = onSaveWidgetName;
		$[39] = title;
		$[40] = widget;
		$[41] = t12;
	} else t12 = $[41];
	const t13 = allMonths[allMonths.length - 1];
	let t14;
	if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = ["category", "saved"];
		$[42] = t14;
	} else t14 = $[42];
	let t15;
	if ($[43] !== graphType || $[44] !== t) {
		t15 = graphType === "Line" ? t("Switch to bar chart") : t("Switch to line chart");
		$[43] = graphType;
		$[44] = t;
		$[45] = t15;
	} else t15 = $[45];
	let t16;
	if ($[46] !== graphType) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: () => setGraphType(graphType === "Line" ? "Bar" : "Line"),
			children: graphType === "Line" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChartBar, { style: {
				width: 12,
				height: 12
			} }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChart, { style: {
				width: 12,
				height: 12
			} })
		});
		$[46] = graphType;
		$[47] = t16;
	} else t16 = $[47];
	let t17;
	if ($[48] !== t15 || $[49] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
			content: t15,
			children: t16
		});
		$[48] = t15;
		$[49] = t16;
		$[50] = t17;
	} else t17 = $[50];
	let t18;
	if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = {
			flexDirection: "row",
			gap: 10
		};
		$[51] = t18;
	} else t18 = $[51];
	let t19;
	if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
		t19 = () => setShowBalance(_temp3$12);
		$[52] = t19;
	} else t19 = $[52];
	let t20;
	if ($[53] !== showBalance || $[54] !== t) {
		t20 = showBalance ? t("Hide balance") : t("Show balance");
		$[53] = showBalance;
		$[54] = t;
		$[55] = t20;
	} else t20 = $[55];
	let t21;
	if ($[56] !== t20) {
		t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			onPress: t19,
			children: t20
		});
		$[56] = t20;
		$[57] = t21;
	} else t21 = $[57];
	let t22;
	if ($[58] !== onSaveWidget || $[59] !== widget) {
		t22 = widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			onPress: onSaveWidget,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
		});
		$[58] = onSaveWidget;
		$[59] = widget;
		$[60] = t22;
	} else t22 = $[60];
	let t23;
	if ($[61] !== t21 || $[62] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t18,
			children: [t21, t22]
		});
		$[61] = t21;
		$[62] = t22;
		$[63] = t23;
	} else t23 = $[63];
	let t24;
	if ($[64] !== allMonths || $[65] !== conditions || $[66] !== conditionsOp || $[67] !== end || $[68] !== firstDayOfWeekIdx || $[69] !== latestTransaction || $[70] !== mode || $[71] !== onApplyFilter || $[72] !== onConditionsOpChange || $[73] !== onDeleteFilter || $[74] !== onUpdateFilter || $[75] !== start || $[76] !== t13.name || $[77] !== t17 || $[78] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			start,
			end,
			mode,
			show1Month: true,
			allMonths,
			earliestTransaction: t13.name,
			latestTransaction,
			firstDayOfWeekIdx,
			onChangeDates,
			filters: conditions,
			conditionsOp,
			onApply: onApplyFilter,
			onUpdateFilter,
			onDeleteFilter,
			onConditionsOpChange,
			filterInclude: t14,
			inlineContent: t17,
			children: t23
		});
		$[64] = allMonths;
		$[65] = conditions;
		$[66] = conditionsOp;
		$[67] = end;
		$[68] = firstDayOfWeekIdx;
		$[69] = latestTransaction;
		$[70] = mode;
		$[71] = onApplyFilter;
		$[72] = onConditionsOpChange;
		$[73] = onDeleteFilter;
		$[74] = onUpdateFilter;
		$[75] = start;
		$[76] = t13.name;
		$[77] = t17;
		$[78] = t23;
		$[79] = t24;
	} else t24 = $[79];
	let t25;
	if ($[80] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = {
			display: "flex",
			flexDirection: "row",
			paddingTop: 0,
			flexGrow: 1
		};
		$[80] = t25;
	} else t25 = $[80];
	let t26;
	if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
		t26 = { flexGrow: 1 };
		$[81] = t26;
	} else t26 = $[81];
	let t27;
	if ($[82] === Symbol.for("react.memo_cache_sentinel")) {
		t27 = {
			backgroundColor: theme.tableBackground,
			padding: 20,
			paddingTop: 0,
			flex: "1 0 auto",
			overflowY: "auto"
		};
		$[82] = t27;
	} else t27 = $[82];
	let t28;
	if ($[83] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = {
			flexDirection: "column",
			flexGrow: 1,
			padding: 10,
			paddingTop: 10
		};
		$[83] = t28;
	} else t28 = $[83];
	let t29;
	if ($[84] === Symbol.for("react.memo_cache_sentinel")) {
		t29 = {
			alignItems: "flex-end",
			flexDirection: "row"
		};
		$[84] = t29;
	} else t29 = $[84];
	let t30;
	if ($[85] === Symbol.for("react.memo_cache_sentinel")) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } });
		$[85] = t30;
	} else t30 = $[85];
	let t31;
	if ($[86] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = {
			alignItems: "flex-end",
			color: theme.pageText
		};
		$[86] = t31;
	} else t31 = $[86];
	let t32;
	if ($[87] !== data || $[88] !== endingBalance || $[89] !== format$11 || $[90] !== showBalance) {
		t32 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				style: {
					marginBottom: 5,
					minWidth: 210
				},
				left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted:" }) }),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: { fontWeight: 600 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$11(data.totalBudgeted, "financial") })
				})
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				style: {
					marginBottom: 5,
					minWidth: 210
				},
				left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Spent:" }) }),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: { fontWeight: 600 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$11(data.totalSpent, "financial") })
				})
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				style: {
					marginBottom: 5,
					minWidth: 210
				},
				left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Overspending adj:" }) }),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: { fontWeight: 600 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$11(data.totalOverspendingAdjustment, "financial") })
				})
			}),
			showBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				style: {
					marginBottom: 5,
					minWidth: 210
				},
				left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Ending balance:" }) }),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: { fontWeight: 600 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Change, { amount: endingBalance }) })
				})
			})
		] });
		$[87] = data;
		$[88] = endingBalance;
		$[89] = format$11;
		$[90] = showBalance;
		$[91] = t32;
	} else t32 = $[91];
	let t33;
	if ($[92] !== t32) {
		t33 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t29,
			children: [t30, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: t31,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: t32 })
			})]
		});
		$[92] = t32;
		$[93] = t33;
	} else t33 = $[93];
	let t34;
	if ($[94] === Symbol.for("react.memo_cache_sentinel")) {
		t34 = { flexGrow: 1 };
		$[94] = t34;
	} else t34 = $[94];
	let t35;
	if ($[95] !== data || $[96] !== graphType || $[97] !== isConcise || $[98] !== showBalance) {
		t35 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysisGraph, {
			style: t34,
			data,
			graphType,
			showBalance,
			isConcise
		});
		$[95] = data;
		$[96] = graphType;
		$[97] = isConcise;
		$[98] = showBalance;
		$[99] = t35;
	} else t35 = $[99];
	let t36;
	if ($[100] === Symbol.for("react.memo_cache_sentinel")) {
		t36 = { marginTop: 30 };
		$[100] = t36;
	} else t36 = $[100];
	let t37;
	let t38;
	if ($[101] === Symbol.for("react.memo_cache_sentinel")) {
		t37 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Understanding the Chart" });
		t38 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {});
		$[101] = t37;
		$[102] = t38;
	} else {
		t37 = $[101];
		t38 = $[102];
	}
	let t39;
	if ($[103] === Symbol.for("react.memo_cache_sentinel")) {
		t39 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Budgeted:" });
		$[103] = t39;
	} else t39 = $[103];
	let t40;
	if ($[104] === Symbol.for("react.memo_cache_sentinel")) {
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {});
		$[104] = t40;
	} else t40 = $[104];
	let t41;
	if ($[105] === Symbol.for("react.memo_cache_sentinel")) {
		t41 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Spent:" });
		$[105] = t41;
	} else t41 = $[105];
	let t42;
	if ($[106] === Symbol.for("react.memo_cache_sentinel")) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {});
		$[106] = t42;
	} else t42 = $[106];
	let t43;
	if ($[107] === Symbol.for("react.memo_cache_sentinel")) {
		t43 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Overspending Adjustment:" });
		$[107] = t43;
	} else t43 = $[107];
	let t44;
	if ($[108] === Symbol.for("react.memo_cache_sentinel")) {
		t44 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {});
		$[108] = t44;
	} else t44 = $[108];
	let t45;
	if ($[109] === Symbol.for("react.memo_cache_sentinel")) {
		t45 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Paragraph, { children: [
			t37,
			t38,
			"• ",
			t39,
			" The amount you allocated each month",
			t40,
			"• ",
			t41,
			" Your actual spending",
			t42,
			"• ",
			t43,
			" Amounts from categories without rollover that were reset",
			t44,
			"• ",
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Balance:" }),
			" Your cumulative budget performance, starting with any prior balance. Respects category rollover settings from your budget."
		] });
		$[109] = t45;
	} else t45 = $[109];
	let t46;
	if ($[110] === Symbol.for("react.memo_cache_sentinel")) {
		t46 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t36,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
				t45,
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Paragraph, { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Understanding the Budget Summary" }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
					"The balance starts from the month before your selected period. Budgeted, spent, and overspending adjustments show totals over the period. Ending balance shows the final balance at period end. You can filter by categories to track changes in a specific area."
				] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: "Hint: You can use the icon in the header to toggle between line and bar chart views." })
			] })
		});
		$[110] = t46;
	} else t46 = $[110];
	let t47;
	if ($[111] !== t33 || $[112] !== t35) {
		t47 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t25,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: t26,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: t27,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: t28,
						children: [
							t33,
							t35,
							t46
						]
					})
				})
			})
		});
		$[111] = t33;
		$[112] = t35;
		$[113] = t47;
	} else t47 = $[113];
	let t48;
	if ($[114] !== t12 || $[115] !== t24 || $[116] !== t47) {
		t48 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
			header: t12,
			padding: 0,
			children: [t24, t47]
		});
		$[114] = t12;
		$[115] = t24;
		$[116] = t47;
		$[117] = t48;
	} else t48 = $[117];
	return t48;
}
function _temp3$12(state) {
	return !state;
}
function _temp2$14(startMonth, endMonth) {
	return differenceInCalendarDays(parseISO(endMonth + "-01"), parseISO(startMonth + "-01")) > 93;
}
function _temp$20() {
	return true;
}
//#endregion
//#region src/components/reports/graphs/CalendarGraph.tsx
function CalendarGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(32);
	const { data, start, firstDayOfWeekIdx, isEditing, onDayClick } = t0;
	const format = useFormat();
	let t1;
	if ($[0] !== firstDayOfWeekIdx) {
		t1 = firstDayOfWeekIdx !== void 0 && !Number.isNaN(parseInt(firstDayOfWeekIdx)) && parseInt(firstDayOfWeekIdx) >= 0 && parseInt(firstDayOfWeekIdx) <= 6 ? parseInt(firstDayOfWeekIdx) : 0;
		$[0] = firstDayOfWeekIdx;
		$[1] = t1;
	} else t1 = $[1];
	const startingDate = startOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: t1 });
	const [fontSize, setFontSize] = (0, import_react.useState)(14);
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = (rect) => {
			const newValue = Math.floor(rect.height / 2);
			if (newValue > 14) setFontSize(14);
			else setFontSize(newValue);
		};
		$[2] = t2;
	} else t2 = $[2];
	const buttonRef = useResizeObserver(t2);
	const T0 = View;
	let t3;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			color: theme.pageTextSubdued,
			display: "grid",
			gridTemplateColumns: "repeat(7, 1fr)",
			gridAutoRows: "1fr",
			gap: 2
		};
		$[3] = t3;
	} else t3 = $[3];
	let t4;
	if ($[4] !== onDayClick) {
		t4 = () => onDayClick(null);
		$[4] = onDayClick;
		$[5] = t4;
	} else t4 = $[5];
	const t5 = Array.from({ length: 7 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
		style: {
			textAlign: "center",
			fontSize: 14,
			fontWeight: 500,
			padding: "3px 0",
			height: "100%",
			width: "100%",
			position: "relative",
			marginBottom: 4
		},
		children: format$1(addDays$1(startingDate, index), "EEEEE")
	}, index));
	let t6;
	if ($[6] !== T0 || $[7] !== t3 || $[8] !== t4 || $[9] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			style: t3,
			onClick: t4,
			children: t5
		});
		$[6] = T0;
		$[7] = t3;
		$[8] = t4;
		$[9] = t5;
		$[10] = t6;
	} else t6 = $[10];
	const t7 = isEditing ? -1 : "auto";
	let t8;
	if ($[11] !== t7) {
		t8 = {
			display: "grid",
			gridTemplateColumns: "repeat(7, 1fr)",
			gridAutoRows: "1fr",
			gap: 2,
			width: "100%",
			height: "100%",
			zIndex: t7
		};
		$[11] = t7;
		$[12] = t8;
	} else t8 = $[12];
	let t9;
	if ($[13] !== buttonRef || $[14] !== data || $[15] !== fontSize || $[16] !== format || $[17] !== onDayClick || $[18] !== start) {
		let t10;
		if ($[20] !== buttonRef || $[21] !== fontSize || $[22] !== format || $[23] !== onDayClick || $[24] !== start) {
			t10 = (day, index_0) => !isSameMonth(day.date, startOfMonth(start)) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { onClick: () => onDayClick(null) }, `empty-${day.date.getTime()}`) : day.incomeValue !== 0 || day.expenseValue !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
				content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: { marginBottom: 10 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: format$1(day.date, "MMM dd") })
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: { lineHeight: 1.5 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							display: "grid",
							gridTemplateColumns: "70px 1fr 60px",
							gridAutoRows: "1fr"
						},
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									textAlign: "right",
									marginRight: 4
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Income:" })
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									color: theme.reportsNumberPositive,
									flexDirection: "row"
								},
								children: day.incomeValue !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(day.incomeValue, "financial") }) }) : ""
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
								style: {
									marginLeft: 4,
									flexDirection: "row"
								},
								children: [
									"(",
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: Math.round(day.incomeSize * 100) / 100 + "%" }),
									")"
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									textAlign: "right",
									marginRight: 4
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expenses:" })
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									color: theme.reportsNumberNegative,
									flexDirection: "row"
								},
								children: day.expenseValue !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(day.expenseValue, "financial") }) }) : ""
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
								style: {
									marginLeft: 4,
									flexDirection: "row"
								},
								children: [
									"(",
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: Math.round(day.expenseSize * 100) / 100 + "%" }),
									")"
								]
							})
						]
					})
				})] }),
				placement: "bottom end",
				style: {
					...styles.tooltip,
					lineHeight: 1.5,
					padding: "6px 10px"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DayButton, {
					resizeRef: (el) => {
						if (index_0 === 15 && el) buttonRef(el);
					},
					fontSize,
					day,
					onPress: () => onDayClick(day.date)
				}, day.date.getTime())
			}, day.date.getTime()) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DayButton, {
				resizeRef: (el_0) => {
					if (index_0 === 15 && el_0) buttonRef(el_0);
				},
				fontSize,
				day,
				onPress: () => onDayClick(day.date)
			}, day.date.getTime());
			$[20] = buttonRef;
			$[21] = fontSize;
			$[22] = format;
			$[23] = onDayClick;
			$[24] = start;
			$[25] = t10;
		} else t10 = $[25];
		t9 = data.map(t10);
		$[13] = buttonRef;
		$[14] = data;
		$[15] = fontSize;
		$[16] = format;
		$[17] = onDayClick;
		$[18] = start;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[26] !== t8 || $[27] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t8,
			children: t9
		});
		$[26] = t8;
		$[27] = t9;
		$[28] = t10;
	} else t10 = $[28];
	let t11;
	if ($[29] !== t10 || $[30] !== t6) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t6, t10] });
		$[29] = t10;
		$[30] = t6;
		$[31] = t11;
	} else t11 = $[31];
	return t11;
}
function DayButton(t0) {
	const $ = (0, import_compiler_runtime.c)(32);
	const { day, onPress, fontSize, resizeRef } = t0;
	const [currentFontSize, setCurrentFontSize] = (0, import_react.useState)(fontSize);
	let t1;
	let t2;
	if ($[0] !== fontSize) {
		t1 = () => {
			setCurrentFontSize(fontSize);
		};
		t2 = [fontSize];
		$[0] = fontSize;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	(0, import_react.useEffect)(t1, t2);
	let t3;
	if ($[3] !== day.date) {
		t3 = format$1(day.date, "MMMM d, yyyy");
		$[3] = day.date;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			borderColor: "transparent",
			backgroundColor: theme.calendarCellBackground,
			position: "relative",
			padding: "unset",
			height: "100%",
			minWidth: 0,
			minHeight: 0,
			margin: 0
		};
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] !== onPress) {
		t5 = () => onPress();
		$[6] = onPress;
		$[7] = t5;
	} else t5 = $[7];
	let t6;
	if ($[8] !== day.expenseSize) {
		t6 = day.expenseSize !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			position: "absolute",
			width: "50%",
			height: "100%",
			background: theme.reportsNumberNegative,
			opacity: .2,
			right: 0
		} });
		$[8] = day.expenseSize;
		$[9] = t6;
	} else t6 = $[9];
	let t7;
	if ($[10] !== day.incomeSize) {
		t7 = day.incomeSize !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			position: "absolute",
			width: "50%",
			height: "100%",
			background: theme.reportsNumberPositive,
			opacity: .2,
			left: 0
		} });
		$[10] = day.incomeSize;
		$[11] = t7;
	} else t7 = $[11];
	const t8 = `${Math.ceil(day.incomeSize)}%`;
	let t9;
	if ($[12] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			position: "absolute",
			left: 0,
			bottom: 0,
			opacity: .9,
			height: t8,
			backgroundColor: theme.reportsNumberPositive,
			width: "50%",
			transition: "height 0.5s ease-out"
		} });
		$[12] = t8;
		$[13] = t9;
	} else t9 = $[13];
	const t10 = `${Math.ceil(day.expenseSize)}%`;
	let t11;
	if ($[14] !== t10) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			position: "absolute",
			right: 0,
			bottom: 0,
			opacity: .9,
			height: t10,
			backgroundColor: theme.reportsNumberNegative,
			width: "50%",
			transition: "height 0.5s ease-out"
		} });
		$[14] = t10;
		$[15] = t11;
	} else t11 = $[15];
	const t12 = `${currentFontSize}px`;
	let t13;
	if ($[16] !== t12) {
		t13 = {
			fontSize: t12,
			fontWeight: 500,
			position: "relative"
		};
		$[16] = t12;
		$[17] = t13;
	} else t13 = $[17];
	let t14;
	if ($[18] !== day.date) {
		t14 = getDate(day.date);
		$[18] = day.date;
		$[19] = t14;
	} else t14 = $[19];
	let t15;
	if ($[20] !== t13 || $[21] !== t14) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t13,
			children: t14
		});
		$[20] = t13;
		$[21] = t14;
		$[22] = t15;
	} else t15 = $[22];
	let t16;
	if ($[23] !== resizeRef || $[24] !== t11 || $[25] !== t15 || $[26] !== t3 || $[27] !== t5 || $[28] !== t6 || $[29] !== t7 || $[30] !== t9) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: resizeRef,
			"aria-label": t3,
			style: t4,
			onPress: t5,
			children: [
				t6,
				t7,
				t9,
				t11,
				t15
			]
		});
		$[23] = resizeRef;
		$[24] = t11;
		$[25] = t15;
		$[26] = t3;
		$[27] = t5;
		$[28] = t6;
		$[29] = t7;
		$[30] = t9;
		$[31] = t16;
	} else t16 = $[31];
	return t16;
}
//#endregion
//#region src/components/reports/spreadsheets/calendar-spreadsheet.ts
function calendarSpreadsheet(start, end, conditions = [], conditionsOp = "and", firstDayOfWeekIdx) {
	return async (spreadsheet, setData) => {
		let filters;
		try {
			const { filters: filtersLocal } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
			filters = filtersLocal;
		} catch (error) {
			console.error("Failed to make filters from conditions:", error);
			filters = [];
		}
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		let startDay;
		try {
			startDay = parse(firstDayOfMonth(start), "yyyy-MM-dd", /* @__PURE__ */ new Date());
		} catch (error) {
			console.error("Failed to parse start date:", error);
			throw new Error("Invalid start date format");
		}
		let endDay;
		try {
			endDay = parse(lastDayOfMonth(end), "yyyy-MM-dd", /* @__PURE__ */ new Date());
		} catch (error) {
			console.error("Failed to parse end date:", error);
			throw new Error("Invalid end date format");
		}
		const makeRootQuery = () => q$1("transactions").filter({ $and: [{ date: { $gte: format$1(startDay, "yyyy-MM-dd") } }, { date: { $lte: format$1(endDay, "yyyy-MM-dd") } }] }).filter({ [conditionsOpKey]: filters }).groupBy(["date"]).select(["date", { amount: { $sum: "$amount" } }]);
		let expenseData;
		try {
			expenseData = await aqlQuery(makeRootQuery().filter({ $and: { amount: { $lt: 0 } } }));
		} catch (error) {
			console.error("Failed to fetch expense data:", error);
			expenseData = { data: [] };
		}
		let incomeData;
		try {
			incomeData = await aqlQuery(makeRootQuery().filter({ $and: { amount: { $gt: 0 } } }));
		} catch (error) {
			console.error("Failed to fetch income data:", error);
			incomeData = { data: [] };
		}
		const getOneDatePerMonth = (start, end) => {
			const months = [];
			let currentDate = startOfMonth(start);
			while (!isSameMonth(currentDate, end)) {
				months.push(currentDate);
				currentDate = addMonths$1(currentDate, 1);
			}
			months.push(end);
			return months;
		};
		setData(recalculate$4(incomeData.data, expenseData.data, getOneDatePerMonth(startDay, endDay), start, firstDayOfWeekIdx));
	};
}
function recalculate$4(incomeData, expenseData, months, start, firstDayOfWeekIdx) {
	const incomeDataMap = /* @__PURE__ */ new Map();
	incomeData.forEach((item) => {
		incomeDataMap.set(item.date, item.amount);
	});
	const expenseDataMap = /* @__PURE__ */ new Map();
	expenseData.forEach((item) => {
		expenseDataMap.set(item.date, item.amount);
	});
	const parseAndCacheDate = (() => {
		const cache = /* @__PURE__ */ new Map();
		return (dateStr) => {
			if (!cache.has(dateStr)) cache.set(dateStr, parse(dateStr, "yyyy-MM-dd", /* @__PURE__ */ new Date()));
			return cache.get(dateStr);
		};
	})();
	const getDaysArray = (month) => {
		const expenseValues = expenseData.filter((f) => isSameMonth(parseAndCacheDate(f.date), month)).map((m) => Math.abs(m.amount));
		const incomeValues = incomeData.filter((f) => isSameMonth(parseAndCacheDate(f.date), month)).map((m) => Math.abs(m.amount));
		const totalExpenseValue = expenseValues.length ? expenseValues.reduce((acc, val) => acc + val, 0) : null;
		const totalIncomeValue = incomeValues.length ? incomeValues.reduce((acc, val) => acc + val, 0) : null;
		const getBarLength = (value) => {
			if (value < 0 && typeof totalExpenseValue === "number" && totalExpenseValue > 0) {
				const result = Math.abs(value) / totalExpenseValue * 100;
				return Number.isFinite(result) ? result : 0;
			} else if (value > 0 && typeof totalIncomeValue === "number" && totalIncomeValue > 0) {
				const result = value / totalIncomeValue * 100;
				return Number.isFinite(result) ? result : 0;
			} else return 0;
		};
		const firstDay = startOfMonth(month);
		const beginDay = startOfWeek(firstDay, { weekStartsOn: firstDayOfWeekIdx !== void 0 && !Number.isNaN(parseInt(firstDayOfWeekIdx)) && parseInt(firstDayOfWeekIdx) >= 0 && parseInt(firstDayOfWeekIdx) <= 6 ? parseInt(firstDayOfWeekIdx) : 0 });
		let totalDays = differenceInDays(firstDay, beginDay) + getDaysInMonth(firstDay);
		if (totalDays % 7 !== 0) totalDays += 7 - totalDays % 7;
		const daysArray = [];
		for (let i = 0; i < totalDays; i++) {
			const currentDate = addDays$1(beginDay, i);
			if (!isSameMonth(currentDate, firstDay)) daysArray.push({
				date: currentDate,
				incomeValue: 0,
				expenseValue: 0,
				incomeSize: 0,
				expenseSize: 0
			});
			else {
				const dateKey = format$1(currentDate, "yyyy-MM-dd");
				const currentIncome = incomeDataMap.get(dateKey) ?? 0;
				const currentExpense = expenseDataMap.get(dateKey) ?? 0;
				daysArray.push({
					date: currentDate,
					incomeSize: getBarLength(currentIncome),
					incomeValue: Math.abs(currentIncome),
					expenseSize: getBarLength(currentExpense),
					expenseValue: Math.abs(currentExpense)
				});
			}
		}
		return {
			data: daysArray,
			totalExpense: totalExpenseValue ?? 0,
			totalIncome: totalIncomeValue ?? 0
		};
	};
	return { calendarData: months.map((m) => {
		return {
			...getDaysArray(m),
			start: startOfMonth(m),
			end: endOfMonth(m)
		};
	}) };
}
//#endregion
//#region src/components/reports/reports/Calendar.tsx
var CHEVRON_HEIGHT = 42;
var SUMMARY_HEIGHT = 140;
function Calendar() {
	const $ = (0, import_compiler_runtime.c)(6);
	const params = useParams();
	const [searchParams] = useSearchParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "calendar-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== searchParams || $[4] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarInner, {
			widget,
			parameters: searchParams
		});
		$[3] = searchParams;
		$[4] = widget;
		$[5] = t1;
	} else t1 = $[5];
	return t1;
}
function CalendarInner({ widget, parameters }) {
	const locale = useLocale();
	const { t } = useTranslation();
	const format$10 = useFormat();
	const [start, setStart] = (0, import_react.useState)(dayFromDate(currentMonth()));
	const [end, setEnd] = (0, import_react.useState)(currentDay());
	const [mode, setMode] = (0, import_react.useState)("full");
	const [query, setQuery] = (0, import_react.useState)(void 0);
	const [dirty, setDirty] = (0, import_react.useState)(false);
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const { transactions: transactionsGrouped, fetchNextPage: loadMoreTransactions } = useTransactions({ query });
	const allTransactions = (0, import_react.useMemo)(() => ungroupTransactions(transactionsGrouped), [transactionsGrouped]);
	const { data: accounts = [] } = useAccounts();
	const { data: payees = [] } = usePayees();
	const { data: { grouped: categoryGroups } = { grouped: [] } } = useCategories();
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	(0, import_react.useEffect)(() => {
		const day = parameters.get("day");
		const month = parameters.get("month");
		if (day && onApplyFilter) onApplyFilter({
			conditions: [...widget?.meta?.conditions || [], {
				op: "is",
				field: "date",
				value: day
			}],
			conditionsOp: "and",
			id: []
		});
		if (month && onApplyFilter) onApplyFilter({
			conditions: [...widget?.meta?.conditions || [], {
				field: "date",
				op: "is",
				value: month,
				options: { month: true }
			}],
			conditionsOp: "and",
			id: []
		});
	}, [
		widget?.meta?.conditions,
		onApplyFilter,
		parameters
	]);
	const params = (0, import_react.useMemo)(() => {
		if (dirty === true) setDirty(false);
		return calendarSpreadsheet(start, end, conditions, conditionsOp, firstDayOfWeekIdx);
	}, [
		start,
		end,
		conditions,
		conditionsOp,
		firstDayOfWeekIdx,
		dirty
	]);
	const [sortField, setSortField] = (0, import_react.useState)("");
	const [ascDesc, setAscDesc] = (0, import_react.useState)("desc");
	(0, import_react.useEffect)(() => {
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) }).then((data) => {
			let query_0 = q$1("transactions").filter({ [conditionsOpKey]: data.filters }).filter({ $and: [{ date: { $gte: firstDayOfMonth(start) } }, { date: { $lte: lastDayOfMonth(end) } }] }).select("*");
			if (sortField) query_0 = query_0.orderBy({ [getField(sortField)]: ascDesc });
			setQuery(query_0.options({ splits: "grouped" }));
		}).catch((error) => {
			console.error("Error generating filters:", error);
		});
	}, [
		start,
		end,
		conditions,
		conditionsOp,
		sortField,
		ascDesc
	]);
	const [flexAlignment, setFlexAlignment] = (0, import_react.useState)("center");
	const scrollbarContainer = (0, import_react.useRef)(null);
	const mergedRef = useMergedRefs(useResizeObserver(() => {
		setFlexAlignment(scrollbarContainer.current && scrollbarContainer.current.scrollWidth > scrollbarContainer.current.clientWidth ? "flex-start" : "center");
	}), scrollbarContainer);
	const data_0 = useReport$1("calendar", params);
	const [allMonths, setAllMonths] = (0, import_react.useState)([]);
	(0, import_react.useEffect)(() => {
		async function run() {
			const earliestTransaction = await send("get-earliest-transaction");
			setEarliestTransaction(earliestTransaction ? earliestTransaction.date : currentDay());
			const latestTransaction_0 = await send("get-latest-transaction");
			setLatestTransaction(latestTransaction_0 ? latestTransaction_0.date : currentDay());
			const currentMonth$9 = currentMonth();
			let earliestMonth = earliestTransaction ? monthFromDate(parseISO(fromDateRepr(earliestTransaction.date))) : currentMonth$9;
			const latestTransactionMonth = latestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(latestTransaction_0.date))) : currentMonth$9;
			const latestMonth = latestTransactionMonth > currentMonth$9 ? latestTransactionMonth : currentMonth$9;
			const yearAgo = subMonths(latestMonth, 12);
			if (earliestMonth > yearAgo) earliestMonth = yearAgo;
			setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month_0) => ({
				name: month_0,
				pretty: format(month_0, "MMMM yyyy", locale)
			})).reverse());
		}
		run();
	}, [locale]);
	(0, import_react.useEffect)(() => {
		if (latestTransaction) {
			const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, {
				start: dayFromDate(currentMonth()),
				end: currentDay(),
				mode: "full"
			}, latestTransaction);
			setStart(initialStart);
			setEnd(initialEnd);
			setMode(initialMode);
		}
	}, [latestTransaction, widget?.meta?.timeFrame]);
	const dispatch = useDispatch();
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const title = widget?.meta?.name || t("Calendar");
	const table = (0, import_react.useRef)(null);
	const dateFormat = useDateFormat();
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	const onSaveWidgetName = async (newName) => {
		if (!widget) throw new Error("No widget that could be saved.");
		const name = newName || t("Calendar");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				name
			}
		} });
	};
	function onChangeDates(start_0, end_0, mode_0) {
		setStart(start_0);
		setEnd(end_0);
		setMode(mode_0);
	}
	async function onSaveWidget() {
		if (!widget) throw new Error("No widget that could be saved.");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				conditions,
				conditionsOp,
				timeFrame: {
					start,
					end,
					mode
				}
			}
		} }, {
			onSuccess: () => {
				dispatch(addNotification({ notification: {
					type: "message",
					message: t("Dashboard widget successfully saved.")
				} }));
			},
			onError: (error_0) => {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Failed to save dashboard widget.")
				} }));
				console.error("Error saving widget:", error_0);
			}
		});
	}
	const { totalIncome, totalExpense } = (0, import_react.useMemo)(() => {
		if (!data_0 || !data_0.calendarData) return {
			totalIncome: 0,
			totalExpense: 0
		};
		return {
			totalIncome: data_0.calendarData.reduce((prev, cur) => prev + cur.totalIncome, 0),
			totalExpense: data_0.calendarData.reduce((prev_0, cur_0) => prev_0 + cur_0.totalExpense, 0)
		};
	}, [data_0]);
	const onSort = (0, import_react.useCallback)((headerClicked, ascDesc_0) => {
		if (headerClicked === sortField) setAscDesc(ascDesc_0);
		else {
			setSortField(headerClicked);
			setAscDesc("desc");
		}
	}, [sortField]);
	const onOpenTransaction = (0, import_react.useCallback)((transaction) => {
		navigate(`/transactions/${transaction.id}`);
	}, [navigate]);
	const refContainer = (0, import_react.useRef)(null);
	(0, import_react.useEffect)(() => {
		if (refContainer.current) setTotalHeight(refContainer.current.clientHeight - SUMMARY_HEIGHT);
	}, [query]);
	const [totalHeight, setTotalHeight] = (0, import_react.useState)(0);
	const closeY = (0, import_react.useRef)(3e3);
	const openY = 0;
	const [mobileTransactionsOpen, setMobileTransactionsOpen] = (0, import_react.useState)(false);
	const [{ y }, api] = useSpring(() => ({
		from: { y: closeY.current },
		immediate: false
	}), []);
	(0, import_react.useEffect)(() => {
		closeY.current = totalHeight;
		api.start({
			to: { y: mobileTransactionsOpen ? openY : closeY.current },
			immediate: false
		});
	}, [
		totalHeight,
		mobileTransactionsOpen,
		api
	]);
	const open = (0, import_react.useCallback)(({ canceled }) => {
		api.start({
			to: { y: openY },
			immediate: false,
			config: canceled ? config.wobbly : config.stiff
		});
		setMobileTransactionsOpen(true);
	}, [api]);
	const close = (0, import_react.useCallback)((velocity = 0) => {
		api.start({
			to: { y: closeY.current },
			config: {
				...config.stiff,
				velocity
			}
		});
		setMobileTransactionsOpen(false);
	}, [api]);
	const bind = useDrag(({ offset: [, oy], cancel }) => {
		if (oy < 0) {
			cancel();
			api.start({
				to: { y: 0 },
				immediate: true
			});
			return;
		}
		if (oy > totalHeight * .05 && mobileTransactionsOpen) {
			cancel();
			close();
			setMobileTransactionsOpen(false);
		} else if (!mobileTransactionsOpen) if (oy / totalHeight > .05) {
			cancel();
			open({ canceled: true });
			setMobileTransactionsOpen(true);
		} else api.start({
			to: { y: oy },
			immediate: true
		});
	}, {
		from: () => [0, y.get()],
		filterTaps: true,
		bounds: {
			top: -totalHeight + CHEVRON_HEIGHT,
			bottom: totalHeight - CHEVRON_HEIGHT
		},
		axis: "y",
		rubberband: true
	});
	const [earliestTransaction_0, setEarliestTransaction] = (0, import_react.useState)("");
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title }),
		padding: 0,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { minHeight: !isNarrowWidth ? "120px" : "unset" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
				allMonths,
				start,
				end,
				earliestTransaction: earliestTransaction_0,
				latestTransaction,
				firstDayOfWeekIdx,
				mode,
				onChangeDates,
				filters: conditions,
				onApply: onApplyFilter,
				onUpdateFilter,
				onDeleteFilter,
				conditionsOp,
				onConditionsOpChange,
				show1Month: true,
				children: widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: "primary",
					onPress: onSaveWidget,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
				})
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			ref: refContainer,
			style: { flexGrow: 1 },
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					backgroundColor: theme.pageBackground,
					paddingTop: 0,
					minHeight: "350px",
					overflowY: "auto"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: isNarrowWidth ? "column-reverse" : "row",
						justifyContent: "flex-start",
						flexGrow: 1,
						gap: 16,
						position: "relative",
						marginBottom: 16
					},
					children: [data_0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						ref: mergedRef,
						style: {
							flexGrow: 1,
							flexDirection: "row",
							gap: "20px",
							overflow: "auto",
							height: "100%",
							justifyContent: flexAlignment,
							display: "flex",
							...styles.horizontalScrollbar
						},
						children: data_0.calendarData.map((calendar, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarWithHeader, {
							calendar,
							onApplyFilter,
							firstDayOfWeekIdx,
							conditions,
							conditionsOp,
							format: format$10
						}, index))
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCardHeader, {
						start,
						end,
						totalExpense,
						totalIncome,
						isNarrowWidth,
						format: format$10
					})]
				})
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectedProviderWithItems, {
				name: "transactions",
				items: [],
				fetchAllIds: async () => [],
				registerDispatch: () => {},
				selectAllFilter: (item) => !item._unmatched && !item.is_parent,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchedulesProvider, {
					query: void 0,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							width: "100%",
							flexGrow: 1,
							overflow: isNarrowWidth ? "auto" : "hidden"
						},
						ref: table,
						children: !isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SplitsExpandedProvider, {
							initialMode: "collapse",
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TransactionList, {
								tableRef: table,
								account: void 0,
								transactions: transactionsGrouped,
								allTransactions,
								loadMoreTransactions,
								accounts,
								category: void 0,
								categoryGroups,
								payees,
								balances: null,
								showBalances: false,
								showReconciled: true,
								showCleared: false,
								showAccount: true,
								isAdding: false,
								isNew: () => false,
								isMatched: () => false,
								dateFormat,
								hideFraction: false,
								renderEmpty: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									style: {
										color: theme.tableText,
										marginTop: 20,
										textAlign: "center",
										fontStyle: "italic"
									},
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No transactions" })
								}),
								onSort,
								sortField,
								ascDesc,
								onChange: () => {},
								onRefetch: () => setDirty(true),
								onCloseAddTransaction: () => {},
								onCreatePayee: async () => null,
								onApplyFilter: () => {},
								onBatchDelete: () => {},
								onBatchDuplicate: () => {},
								onBatchLinkSchedule: () => {},
								onBatchUnlinkSchedule: () => {},
								onCreateRule: () => {},
								onScheduleAction: () => {},
								onMakeAsNonSplitTransactions: () => {},
								showSelection: false,
								allowSplitTransaction: false,
								allowReorder: false
							})
						}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(animated.div, {
							...bind(),
							style: {
								y,
								touchAction: "pan-x",
								backgroundColor: theme.mobileNavBackground,
								borderTop: `1px solid ${theme.menuBorder}`,
								...styles.shadow,
								height: totalHeight + CHEVRON_HEIGHT,
								width: "100%",
								position: "fixed",
								zIndex: 100,
								bottom: 0,
								display: "flex",
								flexDirection: "column",
								alignItems: "center"
							},
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
								variant: "bare",
								onPress: () => !mobileTransactionsOpen ? open({ canceled: false }) : close(),
								className: css({
									color: theme.pageTextSubdued,
									height: 42,
									"&[data-pressed]": { backgroundColor: "transparent" }
								}),
								children: [!mobileTransactionsOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheveronUp, {
									width: 16,
									height: 16
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Show transactions" })] }), mobileTransactionsOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheveronDown, {
									width: 16,
									height: 16
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Hide transactions" })] })]
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									height: "100%",
									width: "100%",
									overflow: "auto"
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DisplayPayeeProvider, {
									transactions: allTransactions,
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TransactionList$1, {
										isLoading: false,
										onLoadMore: loadMoreTransactions,
										transactions: allTransactions,
										onOpenTransaction,
										isLoadingMore: false
									})
								})
							})]
						})
					})
				})
			})]
		})]
	});
}
function CalendarWithHeader(t0) {
	const $ = (0, import_compiler_runtime.c)(60);
	const { calendar, onApplyFilter, firstDayOfWeekIdx, conditions, conditionsOp, format } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			minWidth: "300px",
			maxWidth: "300px",
			padding: 10,
			borderRadius: 4,
			backgroundColor: theme.tableBackground
		};
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] !== conditions || $[2] !== conditionsOp || $[3] !== onApplyFilter) {
		t2 = () => onApplyFilter({
			conditions: [...conditions.filter(_temp$19)],
			conditionsOp,
			id: []
		});
		$[1] = conditions;
		$[2] = conditionsOp;
		$[3] = onApplyFilter;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			flexDirection: "row",
			justifyContent: "space-between",
			flexWrap: "wrap",
			marginBottom: 16
		};
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			color: theme.pageTextSubdued,
			fontWeight: "bold",
			fontSize: "14px",
			margin: 0,
			padding: 0,
			display: "inline-block",
			width: "max-content"
		};
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== calendar.start || $[8] !== conditions || $[9] !== onApplyFilter) {
		t5 = () => {
			onApplyFilter({
				conditions: [...conditions.filter(_temp2$13), {
					field: "date",
					op: "is",
					value: format$1(calendar.start, "yyyy-MM"),
					options: { month: true }
				}],
				conditionsOp: "and",
				id: []
			});
		};
		$[7] = calendar.start;
		$[8] = conditions;
		$[9] = onApplyFilter;
		$[10] = t5;
	} else t5 = $[10];
	let t6;
	if ($[11] !== calendar.start) {
		t6 = format$1(calendar.start, "MMMM yyyy");
		$[11] = calendar.start;
		$[12] = t6;
	} else t6 = $[12];
	let t7;
	if ($[13] !== t5 || $[14] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			style: t4,
			onPress: t5,
			children: t6
		});
		$[13] = t5;
		$[14] = t6;
		$[15] = t7;
	} else t7 = $[15];
	let t8;
	if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = {
			display: "grid",
			gridTemplateColumns: "16px 1fr",
			gap: 2
		};
		$[16] = t8;
	} else t8 = $[16];
	let t9;
	if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgArrowThickUp, {
			width: 16,
			height: 16,
			style: {
				color: theme.reportsNumberPositive,
				flexShrink: 0
			}
		});
		$[17] = t9;
	} else t9 = $[17];
	let t10;
	if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = {
			color: theme.reportsNumberPositive,
			flexDirection: "row",
			flexGrow: 1,
			justifyContent: "start"
		};
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== t) {
		t11 = t("Income");
		$[19] = t;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] !== calendar.totalIncome || $[22] !== format) {
		t12 = format(calendar.totalIncome, "financial");
		$[21] = calendar.totalIncome;
		$[22] = format;
		$[23] = t12;
	} else t12 = $[23];
	let t13;
	if ($[24] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t12 }) });
		$[24] = t12;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] !== t11 || $[27] !== t13) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t10,
			"aria-label": t11,
			children: t13
		});
		$[26] = t11;
		$[27] = t13;
		$[28] = t14;
	} else t14 = $[28];
	let t15;
	if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgArrowThickDown, {
			width: 16,
			height: 16,
			style: {
				color: theme.reportsNumberNegative,
				flexShrink: 0
			}
		});
		$[29] = t15;
	} else t15 = $[29];
	let t16;
	if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = {
			color: theme.reportsNumberNegative,
			flexDirection: "row",
			flexGrow: 1,
			justifyContent: "start"
		};
		$[30] = t16;
	} else t16 = $[30];
	let t17;
	if ($[31] !== t) {
		t17 = t("Expenses");
		$[31] = t;
		$[32] = t17;
	} else t17 = $[32];
	let t18;
	if ($[33] !== calendar.totalExpense || $[34] !== format) {
		t18 = format(calendar.totalExpense, "financial");
		$[33] = calendar.totalExpense;
		$[34] = format;
		$[35] = t18;
	} else t18 = $[35];
	let t19;
	if ($[36] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t18 }) });
		$[36] = t18;
		$[37] = t19;
	} else t19 = $[37];
	let t20;
	if ($[38] !== t17 || $[39] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t16,
			"aria-label": t17,
			children: t19
		});
		$[38] = t17;
		$[39] = t19;
		$[40] = t20;
	} else t20 = $[40];
	let t21;
	if ($[41] !== t14 || $[42] !== t20) {
		t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t8,
			children: [
				t9,
				t14,
				t15,
				t20
			]
		});
		$[41] = t14;
		$[42] = t20;
		$[43] = t21;
	} else t21 = $[43];
	let t22;
	if ($[44] !== t21 || $[45] !== t7) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t3,
			children: [t7, t21]
		});
		$[44] = t21;
		$[45] = t7;
		$[46] = t22;
	} else t22 = $[46];
	let t23;
	if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = {
			flexGrow: 1,
			display: "block",
			marginBottom: 20
		};
		$[47] = t23;
	} else t23 = $[47];
	let t24;
	if ($[48] !== conditions || $[49] !== onApplyFilter) {
		t24 = (date) => {
			if (date) onApplyFilter({
				conditions: [...conditions.filter(_temp3$11), {
					field: "date",
					op: "is",
					value: format$1(date, "yyyy-MM-dd")
				}],
				conditionsOp: "and",
				id: []
			});
			else onApplyFilter({
				conditions: [...conditions.filter(_temp4$8)],
				conditionsOp: "and",
				id: []
			});
		};
		$[48] = conditions;
		$[49] = onApplyFilter;
		$[50] = t24;
	} else t24 = $[50];
	let t25;
	if ($[51] !== calendar.data || $[52] !== calendar.start || $[53] !== firstDayOfWeekIdx || $[54] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t23,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarGraph, {
				data: calendar.data,
				start: calendar.start,
				onDayClick: t24,
				firstDayOfWeekIdx
			})
		});
		$[51] = calendar.data;
		$[52] = calendar.start;
		$[53] = firstDayOfWeekIdx;
		$[54] = t24;
		$[55] = t25;
	} else t25 = $[55];
	let t26;
	if ($[56] !== t2 || $[57] !== t22 || $[58] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t1,
			onClick: t2,
			children: [t22, t25]
		});
		$[56] = t2;
		$[57] = t22;
		$[58] = t25;
		$[59] = t26;
	} else t26 = $[59];
	return t26;
}
function _temp4$8(f_2) {
	return f_2.field !== "date";
}
function _temp3$11(f_1) {
	return f_1.field !== "date";
}
function _temp2$13(f_0) {
	return f_0.field !== "date";
}
function _temp$19(f) {
	return f.field !== "date";
}
function CalendarCardHeader(t0) {
	const $ = (0, import_compiler_runtime.c)(33);
	const { start, end, totalIncome, totalExpense, isNarrowWidth, format } = t0;
	const t1 = isNarrowWidth ? 0 : 16;
	const t2 = isNarrowWidth ? 16 : 0;
	const t3 = isNarrowWidth ? "center" : "flex-end";
	let t4;
	if ($[0] !== t1 || $[1] !== t2 || $[2] !== t3) {
		t4 = {
			...styles.smallText,
			marginLeft: t1,
			marginTop: t2,
			justifyContent: t3,
			flexDirection: "row",
			height: "100px",
			minWidth: "210px"
		};
		$[0] = t1;
		$[1] = t2;
		$[2] = t3;
		$[3] = t4;
	} else t4 = $[3];
	let t5;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = {
			width: "200px",
			borderRadius: 4,
			backgroundColor: theme.tableBackground,
			padding: 10
		};
		$[4] = t5;
	} else t5 = $[4];
	let t6;
	if ($[5] !== end || $[6] !== start) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start,
			end
		});
		$[5] = end;
		$[6] = start;
		$[7] = t6;
	} else t6 = $[7];
	let t7;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = { lineHeight: 1.5 };
		$[8] = t7;
	} else t7 = $[8];
	let t8;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = {
			display: "grid",
			gridTemplateColumns: "70px 1fr",
			gridAutoRows: "1fr"
		};
		$[9] = t8;
	} else t8 = $[9];
	let t9;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				textAlign: "right",
				marginRight: 4
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Income:" })
		});
		$[10] = t9;
	} else t9 = $[10];
	let t10;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = { color: theme.reportsNumberPositive };
		$[11] = t10;
	} else t10 = $[11];
	let t11;
	if ($[12] !== format || $[13] !== totalIncome) {
		t11 = format(totalIncome, "financial");
		$[12] = format;
		$[13] = totalIncome;
		$[14] = t11;
	} else t11 = $[14];
	let t12;
	if ($[15] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t10,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: t11 })
		});
		$[15] = t11;
		$[16] = t12;
	} else t12 = $[16];
	let t13;
	if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				textAlign: "right",
				marginRight: 4
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expenses:" })
		});
		$[17] = t13;
	} else t13 = $[17];
	let t14;
	if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = { color: theme.reportsNumberNegative };
		$[18] = t14;
	} else t14 = $[18];
	let t15;
	if ($[19] !== format || $[20] !== totalExpense) {
		t15 = format(totalExpense, "financial");
		$[19] = format;
		$[20] = totalExpense;
		$[21] = t15;
	} else t15 = $[21];
	let t16;
	if ($[22] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t14,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: t15 })
		});
		$[22] = t15;
		$[23] = t16;
	} else t16 = $[23];
	let t17;
	if ($[24] !== t12 || $[25] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t7,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: t8,
				children: [
					t9,
					t12,
					t13,
					t16
				]
			})
		});
		$[24] = t12;
		$[25] = t16;
		$[26] = t17;
	} else t17 = $[26];
	let t18;
	if ($[27] !== t17 || $[28] !== t6) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t5,
			children: [t6, t17]
		});
		$[27] = t17;
		$[28] = t6;
		$[29] = t18;
	} else t18 = $[29];
	let t19;
	if ($[30] !== t18 || $[31] !== t4) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t4,
			children: t18
		});
		$[30] = t18;
		$[31] = t4;
		$[32] = t19;
	} else t19 = $[32];
	return t19;
}
function getField(field) {
	if (!field) return "date";
	switch (field) {
		case "account": return "account.name";
		case "payee": return "payee.name";
		case "category": return "category.name";
		case "payment": return "amount";
		case "deposit": return "amount";
		default: return field;
	}
}
//#endregion
//#region src/components/reports/graphs/CashFlowGraph.tsx
var MAX_BAR_SIZE = 50;
var ANIMATION_DURATION = 1e3;
function CustomTooltip$7(t0) {
	const $ = (0, import_compiler_runtime.c)(65);
	const { active, payload, isConcise, format } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	if (!active || !payload || !Array.isArray(payload) || !payload[0]) return null;
	const [t1] = payload;
	const { payload: data } = t1;
	let t2;
	let t3;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = css({
			pointerEvents: "none",
			borderRadius: 2,
			boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
			backgroundColor: theme.menuBackground,
			color: theme.menuItemText,
			padding: 10
		});
		t3 = { marginBottom: 10 };
		$[0] = t2;
		$[1] = t3;
	} else {
		t2 = $[0];
		t3 = $[1];
	}
	let t4;
	if ($[2] !== data.date || $[3] !== isConcise || $[4] !== locale) {
		t4 = format$1(data.date, isConcise ? "MMMM yyyy" : "MMMM dd, yyyy", { locale });
		$[2] = data.date;
		$[3] = isConcise;
		$[4] = locale;
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			style: t3,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t4 })
		});
		$[6] = t4;
		$[7] = t5;
	} else t5 = $[7];
	let t6;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = { lineHeight: 1.5 };
		$[8] = t6;
	} else t6 = $[8];
	let t7;
	if ($[9] !== t) {
		t7 = t("Income:");
		$[9] = t;
		$[10] = t7;
	} else t7 = $[10];
	let t8;
	if ($[11] !== data.income || $[12] !== format) {
		t8 = format(data.income, "financial");
		$[11] = data.income;
		$[12] = format;
		$[13] = t8;
	} else t8 = $[13];
	let t9;
	if ($[14] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t8 });
		$[14] = t8;
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== t7 || $[17] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t7,
			right: t9
		});
		$[16] = t7;
		$[17] = t9;
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== t) {
		t11 = t("Expenses:");
		$[19] = t;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] !== data.expenses || $[22] !== format) {
		t12 = format(data.expenses, "financial");
		$[21] = data.expenses;
		$[22] = format;
		$[23] = t12;
	} else t12 = $[23];
	let t13;
	if ($[24] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t12 });
		$[24] = t12;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] !== t11 || $[27] !== t13) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t11,
			right: t13
		});
		$[26] = t11;
		$[27] = t13;
		$[28] = t14;
	} else t14 = $[28];
	let t15;
	if ($[29] !== t) {
		t15 = t("Change:");
		$[29] = t;
		$[30] = t15;
	} else t15 = $[30];
	const t16 = data.income + data.expenses;
	let t17;
	if ($[31] !== format || $[32] !== t16) {
		t17 = format(t16, "financial");
		$[31] = format;
		$[32] = t16;
		$[33] = t17;
	} else t17 = $[33];
	let t18;
	if ($[34] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
			as: "strong",
			children: t17
		});
		$[34] = t17;
		$[35] = t18;
	} else t18 = $[35];
	let t19;
	if ($[36] !== t15 || $[37] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t15,
			right: t18
		});
		$[36] = t15;
		$[37] = t18;
		$[38] = t19;
	} else t19 = $[38];
	let t20;
	if ($[39] !== data.transfers || $[40] !== format || $[41] !== t) {
		t20 = data.transfers !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t("Transfers:"),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(data.transfers, "financial") })
		});
		$[39] = data.transfers;
		$[40] = format;
		$[41] = t;
		$[42] = t20;
	} else t20 = $[42];
	let t21;
	if ($[43] !== t) {
		t21 = t("Balance:");
		$[43] = t;
		$[44] = t21;
	} else t21 = $[44];
	let t22;
	if ($[45] !== data.balance || $[46] !== format) {
		t22 = format(data.balance, "financial");
		$[45] = data.balance;
		$[46] = format;
		$[47] = t22;
	} else t22 = $[47];
	let t23;
	if ($[48] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t22 });
		$[48] = t22;
		$[49] = t23;
	} else t23 = $[49];
	let t24;
	if ($[50] !== t21 || $[51] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			left: t21,
			right: t23
		});
		$[50] = t21;
		$[51] = t23;
		$[52] = t24;
	} else t24 = $[52];
	let t25;
	if ($[53] !== t10 || $[54] !== t14 || $[55] !== t19 || $[56] !== t20 || $[57] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			style: t6,
			children: [
				t10,
				t14,
				t19,
				t20,
				t24
			]
		});
		$[53] = t10;
		$[54] = t14;
		$[55] = t19;
		$[56] = t20;
		$[57] = t24;
		$[58] = t25;
	} else t25 = $[58];
	let t26;
	if ($[59] !== t25 || $[60] !== t5) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t25] });
		$[59] = t25;
		$[60] = t5;
		$[61] = t26;
	} else t26 = $[61];
	let t27;
	if ($[62] !== t2 || $[63] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			className: t2,
			children: t26
		});
		$[62] = t2;
		$[63] = t26;
		$[64] = t27;
	} else t27 = $[64];
	return t27;
}
function CashFlowGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(22);
	const { graphData, isConcise, showBalance: t1, style } = t0;
	const showBalance = t1 === void 0 ? true : t1;
	const locale = useLocale();
	const privacyMode = usePrivacyMode();
	const [yAxisIsHovered, setYAxisIsHovered] = (0, import_react.useState)(false);
	const format = useFormat();
	let t2;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = { animationDuration: ANIMATION_DURATION };
		$[0] = t2;
	} else t2 = $[0];
	const animationProps = useRechartsAnimation(t2);
	let t3;
	if ($[1] !== graphData.balances || $[2] !== graphData.expenses || $[3] !== graphData.income || $[4] !== graphData.transfers) {
		let t4;
		if ($[6] !== graphData.balances || $[7] !== graphData.income || $[8] !== graphData.transfers) {
			t4 = (row, idx) => ({
				date: row.x,
				expenses: row.y,
				income: graphData.income[idx].y,
				balance: graphData.balances[idx].y,
				transfers: graphData.transfers[idx].y
			});
			$[6] = graphData.balances;
			$[7] = graphData.income;
			$[8] = graphData.transfers;
			$[9] = t4;
		} else t4 = $[9];
		t3 = graphData.expenses.map(t4);
		$[1] = graphData.balances;
		$[2] = graphData.expenses;
		$[3] = graphData.income;
		$[4] = graphData.transfers;
		$[5] = t3;
	} else t3 = $[5];
	const data = t3;
	let t4;
	if ($[10] !== animationProps || $[11] !== data || $[12] !== format || $[13] !== isConcise || $[14] !== locale || $[15] !== privacyMode || $[16] !== showBalance || $[17] !== yAxisIsHovered) {
		t4 = (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ComposedChart, {
			responsive: true,
			width,
			height,
			stackOffset: "sign",
			data,
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
					strokeDasharray: "3 3",
					vertical: false
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "date",
					tick: { fill: theme.reportsLabel },
					tickFormatter: (x) => format$1(x, isConcise ? "MMM ''yy" : "MMM d", { locale }),
					minTickGap: 50
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					tick: { fill: theme.reportsLabel },
					tickCount: 8,
					tickFormatter: (value) => privacyMode && !yAxisIsHovered ? "..." : format(value, "financial-no-decimals"),
					onMouseEnter: () => setYAxisIsHovered(true),
					onMouseLeave: () => setYAxisIsHovered(false)
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					labelFormatter: (x_0) => format$1(x_0, isConcise ? "MMM ''yy" : "MMM d", { locale }),
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$7, {
						isConcise,
						format
					}),
					isAnimationActive: false
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
					y: 0,
					stroke: "#000"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: "income",
					stackId: "a",
					fill: theme.reportsNumberPositive,
					maxBarSize: MAX_BAR_SIZE,
					...animationProps
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: "expenses",
					stackId: "a",
					fill: theme.reportsNumberNegative,
					maxBarSize: MAX_BAR_SIZE,
					...animationProps
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					type: "monotone",
					dataKey: "balance",
					dot: false,
					hide: !showBalance,
					stroke: theme.pageTextLight,
					strokeWidth: 2,
					...animationProps
				})
			]
		});
		$[10] = animationProps;
		$[11] = data;
		$[12] = format;
		$[13] = isConcise;
		$[14] = locale;
		$[15] = privacyMode;
		$[16] = showBalance;
		$[17] = yAxisIsHovered;
		$[18] = t4;
	} else t4 = $[18];
	let t5;
	if ($[19] !== style || $[20] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style,
			children: t4
		});
		$[19] = style;
		$[20] = t4;
		$[21] = t5;
	} else t5 = $[21];
	return t5;
}
//#endregion
//#region src/components/reports/spreadsheets/cash-flow-spreadsheet.tsx
function simpleCashFlow(startMonth, endMonth, conditions = [], conditionsOp = "and") {
	const start = firstDayOfMonth(startMonth);
	const end = lastDayOfMonth(endMonth);
	return async (spreadsheet, setData) => {
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		function makeQuery() {
			return q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({
				$and: [{ date: { $gte: start } }, { date: { $lte: end > currentDay() ? currentDay() : end } }],
				"account.offbudget": false,
				"payee.transfer_acct": null
			}).calculate({ $sum: "$amount" });
		}
		return runAll([makeQuery().filter({ amount: { $gt: 0 } }), makeQuery().filter({ amount: { $lt: 0 } })], (data) => {
			setData({ graphData: {
				income: data[0],
				expense: data[1]
			} });
		});
	};
}
function cashFlowByDate(startMonth, endMonth, isConcise, conditions = [], conditionsOp, locale, format) {
	const start = firstDayOfMonth(startMonth);
	const end = lastDayOfMonth(endMonth);
	const fixedEnd = end > currentDay() ? currentDay() : end;
	return async (spreadsheet, setData) => {
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		function makeQuery() {
			const query = q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({
				$and: [{ date: {
					$transform: "$month",
					$gte: start
				} }, { date: {
					$transform: "$month",
					$lte: fixedEnd
				} }],
				"account.offbudget": false
			});
			if (isConcise) return query.groupBy([{ $month: "$date" }, "payee.transfer_acct"]).select([
				{ date: { $month: "$date" } },
				{ isTransfer: "payee.transfer_acct" },
				{ amount: { $sum: "$amount" } }
			]);
			return query.groupBy(["date", "payee.transfer_acct"]).select([
				"date",
				{ isTransfer: "payee.transfer_acct" },
				{ amount: { $sum: "$amount" } }
			]);
		}
		return runAll([
			q$1("transactions").filter({
				[conditionsOpKey]: filters,
				date: {
					$transform: "$month",
					$lt: start
				},
				"account.offbudget": false
			}).calculate({ $sum: "$amount" }),
			makeQuery().filter({ amount: { $gt: 0 } }),
			makeQuery().filter({ amount: { $lt: 0 } })
		], (data) => {
			setData(recalculate$3(data, start, fixedEnd, isConcise, locale, format));
		});
	};
}
function recalculate$3(data, start, end, isConcise, locale, format) {
	const [startingBalance, income, expense] = data;
	const convIncome = income.map((trans) => {
		return {
			...trans,
			isTransfer: trans.isTransfer !== null
		};
	});
	const convExpense = expense.map((trans) => {
		return {
			...trans,
			isTransfer: trans.isTransfer !== null
		};
	});
	const dates = isConcise ? rangeInclusive(getMonth(start), getMonth(end)) : dayRangeInclusive(start, end);
	const incomes = indexCashFlow(convIncome);
	const expenses = indexCashFlow(convExpense);
	let balance = startingBalance;
	let totalExpenses = 0;
	let totalIncome = 0;
	let totalTransfers = 0;
	const graphData = dates.reduce((res, date) => {
		let income = 0;
		let expense = 0;
		let creditTransfers = 0;
		let debitTransfers = 0;
		if (incomes[date]) {
			income = !incomes[date].false ? 0 : incomes[date].false;
			creditTransfers = !incomes[date].true ? 0 : incomes[date].true;
		}
		if (expenses[date]) {
			expense = !expenses[date].false ? 0 : expenses[date].false;
			debitTransfers = !expenses[date].true ? 0 : expenses[date].true;
		}
		totalExpenses += expense;
		totalIncome += income;
		balance += income + expense + creditTransfers + debitTransfers;
		totalTransfers += creditTransfers + debitTransfers;
		const x = parseISO(date);
		const label = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			style: { marginBottom: 10 },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: format$1(x, isConcise ? "MMMM yyyy" : "MMMM d, yyyy", { locale }) })
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			style: { lineHeight: 1.5 },
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
					left: t("Income:"),
					right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(income, "financial") })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
					left: t("Expenses:"),
					right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(expense, "financial") })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
					left: t("Change:"),
					right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
						as: "strong",
						children: format(income + expense, "financial")
					})
				}),
				creditTransfers + debitTransfers !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
					left: t("Transfers:"),
					right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(creditTransfers + debitTransfers, "financial") })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
					left: t("Balance:"),
					right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(balance, "financial") })
				})
			]
		})] });
		res.income.push({
			x,
			y: income
		});
		res.expenses.push({
			x,
			y: expense
		});
		res.transfers.push({
			x,
			y: creditTransfers + debitTransfers
		});
		res.balances.push({
			x,
			y: balance,
			premadeLabel: label,
			amount: balance
		});
		return res;
	}, {
		expenses: [],
		income: [],
		transfers: [],
		balances: []
	});
	const { balances } = graphData;
	return {
		graphData,
		balance: balances[balances.length - 1].amount,
		totalExpenses,
		totalIncome,
		totalTransfers,
		totalChange: balances[balances.length - 1].amount - balances[0].amount
	};
}
//#endregion
//#region src/components/reports/reports/CashFlow.tsx
var defaultTimeFrame$1 = {
	start: dayFromDate(currentMonth()),
	end: currentDay(),
	mode: "sliding-window"
};
function CashFlow() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "cash-flow-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CashFlowInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function CashFlowInner({ widget }) {
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	const format$9 = useFormat();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	const [start, setStart] = (0, import_react.useState)(currentMonth());
	const [end, setEnd] = (0, import_react.useState)(currentMonth());
	const [mode, setMode] = (0, import_react.useState)("sliding-window");
	const [showBalance, setShowBalance] = (0, import_react.useState)(widget?.meta?.showBalance ?? true);
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [isConcise, setIsConcise] = (0, import_react.useState)(false);
	(0, import_react.useEffect)(() => {
		setIsConcise(differenceInCalendarDays(parseISO(end), parseISO(start)) > 93);
	}, [start, end]);
	const data = useReport$1("cash_flow", (0, import_react.useMemo)(() => cashFlowByDate(start, end, isConcise, conditions, conditionsOp, locale, format$9), [
		start,
		end,
		isConcise,
		conditions,
		conditionsOp,
		locale,
		format$9
	]));
	(0, import_react.useEffect)(() => {
		async function run() {
			const earliestTransaction = await send("get-earliest-transaction");
			setEarliestTransaction(earliestTransaction ? earliestTransaction.date : currentDay());
			const latestTransaction_0 = await send("get-latest-transaction");
			setLatestTransaction(latestTransaction_0 ? latestTransaction_0.date : currentDay());
			const currentMonth$8 = currentMonth();
			const earliestMonth = earliestTransaction ? monthFromDate(parseISO(earliestTransaction.date)) : currentMonth$8;
			const latestTransactionMonth = latestTransaction_0 ? monthFromDate(parseISO(latestTransaction_0.date)) : currentMonth$8;
			setAllMonths(rangeInclusive(earliestMonth, latestTransactionMonth > currentMonth$8 ? latestTransactionMonth : currentMonth$8).map((month) => ({
				name: month,
				pretty: format(month, "MMMM yyyy", locale)
			})).reverse());
		}
		run();
	}, [locale]);
	(0, import_react.useEffect)(() => {
		if (latestTransaction) {
			const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, defaultTimeFrame$1, latestTransaction);
			setStart(initialStart);
			setEnd(initialEnd);
			setMode(initialMode);
		}
	}, [latestTransaction, widget?.meta?.timeFrame]);
	function onChangeDates(start_0, end_0, mode_0) {
		setStart(start_0);
		setEnd(end_0);
		setMode(mode_0);
	}
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	async function onSaveWidget() {
		if (!widget) throw new Error("No widget that could be saved.");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				conditions,
				conditionsOp,
				timeFrame: {
					start,
					end,
					mode
				},
				showBalance
			}
		} }, { onSuccess: () => {
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Dashboard widget successfully saved.")
			} }));
		} });
	}
	const title = widget?.meta?.name || t("Cash Flow");
	const onSaveWidgetName = async (newName) => {
		if (!widget) throw new Error("No widget that could be saved.");
		const name = newName || t("Cash Flow");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				name
			}
		} });
	};
	const [earliestTransaction_0, setEarliestTransaction] = (0, import_react.useState)("");
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	if (!allMonths || !data) return null;
	const { graphData, totalExpenses, totalIncome, totalTransfers } = data;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title }),
		padding: 0,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			allMonths,
			start,
			end,
			earliestTransaction: earliestTransaction_0,
			latestTransaction,
			firstDayOfWeekIdx,
			mode,
			show1Month: true,
			onChangeDates,
			onApply: onApplyFilter,
			filters: conditions,
			onUpdateFilter,
			onDeleteFilter,
			conditionsOp,
			onConditionsOpChange,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					gap: 10
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					onPress: () => setShowBalance((state) => !state),
					children: showBalance ? t("Hide balance") : t("Show balance")
				}), widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: "primary",
					onPress: onSaveWidget,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
				})]
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				backgroundColor: theme.tableBackground,
				padding: 20,
				paddingTop: 0,
				flex: "1 0 auto",
				overflowY: "auto"
			},
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						paddingTop: 20,
						alignItems: "flex-end",
						color: theme.pageText
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
							style: {
								marginBottom: 5,
								minWidth: 160
							},
							left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Income:" }) }),
							right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
								style: { fontWeight: 600 },
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$9(totalIncome, "financial") })
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
							style: {
								marginBottom: 5,
								minWidth: 160
							},
							left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expenses:" }) }),
							right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
								style: { fontWeight: 600 },
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$9(totalExpenses, "financial") })
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
							style: {
								marginBottom: 5,
								minWidth: 160
							},
							left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Transfers:" }) }),
							right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
								style: { fontWeight: 600 },
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$9(totalTransfers, "financial") })
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
							style: { fontWeight: 600 },
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Change, { amount: totalIncome + totalExpenses + totalTransfers }) })
						})
					]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CashFlowGraph, {
					graphData,
					isConcise,
					showBalance
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						marginTop: 30,
						userSelect: "none"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "How is cash flow calculated?" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: "Cash flow shows the balance of your budgeted accounts over time, and the amount of expenses/income each day or month. Your budgeted accounts are considered to be \"cash on hand,\" so this gives you a picture of how available money fluctuates." })] })
				})
			]
		})]
	});
}
//#endregion
//#region src/components/reports/GraphButton.tsx
var GraphButton = (t0) => {
	const $ = (0, import_compiler_runtime.c)(17);
	const { selected, children, onSelect, title, style, disabled } = t0;
	let t1;
	if ($[0] !== title) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: title });
		$[0] = title;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			...styles.tooltip,
			lineHeight: 1.5,
			padding: "6px 10px"
		};
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] !== selected) {
		t3 = selected && { backgroundColor: theme.buttonBareBackgroundHover };
		$[3] = selected;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== style || $[6] !== t3) {
		t4 = {
			...t3,
			...style
		};
		$[5] = style;
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== children || $[9] !== disabled || $[10] !== onSelect || $[11] !== t4 || $[12] !== title) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			style: t4,
			onPress: onSelect,
			isDisabled: disabled,
			"aria-label": title,
			children
		});
		$[8] = children;
		$[9] = disabled;
		$[10] = onSelect;
		$[11] = t4;
		$[12] = title;
		$[13] = t5;
	} else t5 = $[13];
	let t6;
	if ($[14] !== t1 || $[15] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
			placement: "bottom start",
			content: t1,
			style: t2,
			children: t5
		});
		$[14] = t1;
		$[15] = t5;
		$[16] = t6;
	} else t6 = $[16];
	return t6;
};
//#endregion
//#region src/components/reports/AccountSelector.tsx
function AccountSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(90);
	const { accounts, selectedAccountIds, setSelectedAccountIds } = t0;
	const { t } = useTranslation();
	const [uncheckedHidden, setUncheckedHidden] = (0, import_react.useState)(false);
	let t1;
	if ($[0] !== accounts) {
		t1 = accounts.filter(_temp$18);
		$[0] = accounts;
		$[1] = t1;
	} else t1 = $[1];
	const onBudget = t1;
	let t2;
	if ($[2] !== accounts) {
		t2 = accounts.filter(_temp2$12);
		$[2] = accounts;
		$[3] = t2;
	} else t2 = $[3];
	const offBudget = t2;
	let t3;
	if ($[4] !== accounts) {
		t3 = accounts.filter(_temp3$10);
		$[4] = accounts;
		$[5] = t3;
	} else t3 = $[5];
	const closed = t3;
	let t4;
	if ($[6] !== closed || $[7] !== offBudget || $[8] !== onBudget) {
		t4 = {
			onBudget,
			offBudget,
			closed
		};
		$[6] = closed;
		$[7] = offBudget;
		$[8] = onBudget;
		$[9] = t4;
	} else t4 = $[9];
	const groupedAccounts = t4;
	let t5;
	if ($[10] !== selectedAccountIds) {
		t5 = new Set(selectedAccountIds);
		$[10] = selectedAccountIds;
		$[11] = t5;
	} else t5 = $[11];
	const selectedAccountMap = t5;
	let t6;
	if ($[12] !== groupedAccounts.onBudget || $[13] !== selectedAccountMap) {
		let t7;
		if ($[15] !== selectedAccountMap) {
			t7 = (account_2) => selectedAccountMap.has(account_2.id);
			$[15] = selectedAccountMap;
			$[16] = t7;
		} else t7 = $[16];
		t6 = groupedAccounts.onBudget.every(t7);
		$[12] = groupedAccounts.onBudget;
		$[13] = selectedAccountMap;
		$[14] = t6;
	} else t6 = $[14];
	const onBudgetSelected = t6;
	let t7;
	if ($[17] !== groupedAccounts.offBudget || $[18] !== selectedAccountMap) {
		let t8;
		if ($[20] !== selectedAccountMap) {
			t8 = (account_3) => selectedAccountMap.has(account_3.id);
			$[20] = selectedAccountMap;
			$[21] = t8;
		} else t8 = $[21];
		t7 = groupedAccounts.offBudget.every(t8);
		$[17] = groupedAccounts.offBudget;
		$[18] = selectedAccountMap;
		$[19] = t7;
	} else t7 = $[19];
	const offBudgetSelected = t7;
	let t8;
	if ($[22] !== groupedAccounts.closed || $[23] !== selectedAccountMap) {
		let t9;
		if ($[25] !== selectedAccountMap) {
			t9 = (account_4) => selectedAccountMap.has(account_4.id);
			$[25] = selectedAccountMap;
			$[26] = t9;
		} else t9 = $[26];
		t8 = groupedAccounts.closed.every(t9);
		$[22] = groupedAccounts.closed;
		$[23] = selectedAccountMap;
		$[24] = t8;
	} else t8 = $[24];
	const closedSelected = t8;
	const allAccountsSelected = onBudgetSelected && offBudgetSelected && closedSelected;
	const allAccountsUnselected = !selectedAccountIds.length;
	let t9;
	if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = {
			flexDirection: "row",
			alignItems: "center",
			marginBottom: 5,
			flexShrink: 0
		};
		$[27] = t9;
	} else t9 = $[27];
	let t10;
	let t11;
	if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = () => setUncheckedHidden(_temp4$7);
		t11 = { padding: 8 };
		$[28] = t10;
		$[29] = t11;
	} else {
		t10 = $[28];
		t11 = $[29];
	}
	let t12;
	if ($[30] !== uncheckedHidden) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			onPress: t10,
			style: t11,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: uncheckedHidden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					alignItems: "center"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewShow, {
					width: 15,
					height: 15,
					style: { marginRight: 5 }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Show unchecked" }) })]
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					alignItems: "center"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewHide, {
					width: 15,
					height: 15,
					style: { marginRight: 5 }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						maxWidth: 100,
						whiteSpace: "nowrap",
						overflow: "hidden",
						textOverflow: "ellipsis"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Hide unchecked" })
				})]
			}) })
		});
		$[30] = uncheckedHidden;
		$[31] = t12;
	} else t12 = $[31];
	let t13;
	if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } });
		$[32] = t13;
	} else t13 = $[32];
	let t14;
	if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = {
			flexDirection: "row",
			alignItems: "center"
		};
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== t) {
		t15 = t("Select All");
		$[34] = t;
		$[35] = t15;
	} else t15 = $[35];
	let t16;
	if ($[36] !== accounts || $[37] !== setSelectedAccountIds) {
		t16 = () => {
			setSelectedAccountIds(accounts.map(_temp5$6));
		};
		$[36] = accounts;
		$[37] = setSelectedAccountIds;
		$[38] = t16;
	} else t16 = $[38];
	let t17;
	let t18;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = {
			marginRight: 5,
			padding: 8
		};
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheckAll, {
			width: 15,
			height: 15
		});
		$[39] = t17;
		$[40] = t18;
	} else {
		t17 = $[39];
		t18 = $[40];
	}
	let t19;
	if ($[41] !== allAccountsSelected || $[42] !== t15 || $[43] !== t16) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: allAccountsSelected,
			title: t15,
			onSelect: t16,
			style: t17,
			children: t18
		});
		$[41] = allAccountsSelected;
		$[42] = t15;
		$[43] = t16;
		$[44] = t19;
	} else t19 = $[44];
	let t20;
	if ($[45] !== t) {
		t20 = t("Unselect All");
		$[45] = t;
		$[46] = t20;
	} else t20 = $[46];
	let t21;
	if ($[47] !== setSelectedAccountIds) {
		t21 = () => {
			setSelectedAccountIds([]);
		};
		$[47] = setSelectedAccountIds;
		$[48] = t21;
	} else t21 = $[48];
	let t22;
	let t23;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = { padding: 8 };
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgUncheckAll, {
			width: 15,
			height: 15
		});
		$[49] = t22;
		$[50] = t23;
	} else {
		t22 = $[49];
		t23 = $[50];
	}
	let t24;
	if ($[51] !== allAccountsUnselected || $[52] !== t20 || $[53] !== t21) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: allAccountsUnselected,
			title: t20,
			onSelect: t21,
			style: t22,
			children: t23
		});
		$[51] = allAccountsUnselected;
		$[52] = t20;
		$[53] = t21;
		$[54] = t24;
	} else t24 = $[54];
	let t25;
	if ($[55] !== t19 || $[56] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t14,
			children: [t19, t24]
		});
		$[55] = t19;
		$[56] = t24;
		$[57] = t25;
	} else t25 = $[57];
	let t26;
	if ($[58] !== t12 || $[59] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t9,
			children: [
				t12,
				t13,
				t25
			]
		});
		$[58] = t12;
		$[59] = t25;
		$[60] = t26;
	} else t26 = $[60];
	let t27;
	if ($[61] === Symbol.for("react.memo_cache_sentinel")) {
		t27 = {
			listStyle: "none",
			marginLeft: 0,
			paddingLeft: 0,
			paddingRight: 10,
			flexGrow: 1,
			overflowY: "auto"
		};
		$[61] = t27;
	} else t27 = $[61];
	let t28;
	if ($[62] !== groupedAccounts.onBudget || $[63] !== onBudgetSelected || $[64] !== selectedAccountIds || $[65] !== selectedAccountMap || $[66] !== setSelectedAccountIds || $[67] !== uncheckedHidden) {
		t28 = groupedAccounts.onBudget.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
			style: {
				display: !onBudgetSelected && uncheckedHidden ? "none" : "flex",
				flexDirection: "row",
				marginBottom: 8,
				marginTop: 8
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
				id: "onbudget_group",
				checked: onBudgetSelected,
				onChange: () => {
					const onBudgetAccountIds = groupedAccounts.onBudget.map(_temp6$6);
					if (onBudgetAccountIds.every((id) => selectedAccountIds.includes(id))) setSelectedAccountIds(selectedAccountIds.filter((id_0) => !onBudgetAccountIds.includes(id_0)));
					else {
						const newSelection = [...selectedAccountIds];
						onBudgetAccountIds.forEach((id_1) => {
							if (!newSelection.includes(id_1)) newSelection.push(id_1);
						});
						setSelectedAccountIds(newSelection);
					}
				}
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
				htmlFor: "onbudget_group",
				style: {
					userSelect: "none",
					fontWeight: "bold"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "On Budget" })
			})]
		}), groupedAccounts.onBudget.map((account_7) => {
			const isChecked = selectedAccountMap.has(account_7.id);
			return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
				style: {
					display: !isChecked && uncheckedHidden ? "none" : "flex",
					flexDirection: "row",
					marginBottom: 4,
					marginLeft: 16
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
					id: `account_${account_7.id}`,
					checked: isChecked,
					onChange: () => {
						if (isChecked) setSelectedAccountIds(selectedAccountIds.filter((id_2) => id_2 !== account_7.id));
						else setSelectedAccountIds([...selectedAccountIds, account_7.id]);
					}
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					htmlFor: `account_${account_7.id}`,
					style: { userSelect: "none" },
					children: account_7.name
				})]
			}, account_7.id);
		})] });
		$[62] = groupedAccounts.onBudget;
		$[63] = onBudgetSelected;
		$[64] = selectedAccountIds;
		$[65] = selectedAccountMap;
		$[66] = setSelectedAccountIds;
		$[67] = uncheckedHidden;
		$[68] = t28;
	} else t28 = $[68];
	let t29;
	if ($[69] !== groupedAccounts.offBudget || $[70] !== offBudgetSelected || $[71] !== selectedAccountIds || $[72] !== selectedAccountMap || $[73] !== setSelectedAccountIds || $[74] !== uncheckedHidden) {
		t29 = groupedAccounts.offBudget.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
			style: {
				display: !offBudgetSelected && uncheckedHidden ? "none" : "flex",
				flexDirection: "row",
				marginBottom: 8,
				marginTop: 16
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
				id: "offbudget_group",
				checked: offBudgetSelected,
				onChange: () => {
					const offBudgetAccountIds = groupedAccounts.offBudget.map(_temp7$5);
					if (offBudgetAccountIds.every((id_3) => selectedAccountIds.includes(id_3))) setSelectedAccountIds(selectedAccountIds.filter((id_4) => !offBudgetAccountIds.includes(id_4)));
					else {
						const newSelection_0 = [...selectedAccountIds];
						offBudgetAccountIds.forEach((id_5) => {
							if (!newSelection_0.includes(id_5)) newSelection_0.push(id_5);
						});
						setSelectedAccountIds(newSelection_0);
					}
				}
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
				htmlFor: "offbudget_group",
				style: {
					userSelect: "none",
					fontWeight: "bold"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Off Budget" })
			})]
		}), groupedAccounts.offBudget.map((account_9) => {
			const isChecked_0 = selectedAccountMap.has(account_9.id);
			return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
				style: {
					display: !isChecked_0 && uncheckedHidden ? "none" : "flex",
					flexDirection: "row",
					marginBottom: 4,
					marginLeft: 16
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
					id: `account_${account_9.id}`,
					checked: isChecked_0,
					onChange: () => {
						if (isChecked_0) setSelectedAccountIds(selectedAccountIds.filter((id_6) => id_6 !== account_9.id));
						else setSelectedAccountIds([...selectedAccountIds, account_9.id]);
					}
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					htmlFor: `account_${account_9.id}`,
					style: { userSelect: "none" },
					children: account_9.name
				})]
			}, account_9.id);
		})] });
		$[69] = groupedAccounts.offBudget;
		$[70] = offBudgetSelected;
		$[71] = selectedAccountIds;
		$[72] = selectedAccountMap;
		$[73] = setSelectedAccountIds;
		$[74] = uncheckedHidden;
		$[75] = t29;
	} else t29 = $[75];
	let t30;
	if ($[76] !== closedSelected || $[77] !== groupedAccounts.closed || $[78] !== selectedAccountIds || $[79] !== selectedAccountMap || $[80] !== setSelectedAccountIds || $[81] !== uncheckedHidden) {
		t30 = groupedAccounts.closed.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
			style: {
				display: !closedSelected && uncheckedHidden ? "none" : "flex",
				flexDirection: "row",
				marginBottom: 8,
				marginTop: 16
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
				id: "closed_group",
				checked: closedSelected,
				onChange: () => {
					const closedAccountIds = groupedAccounts.closed.map(_temp8$3);
					if (closedAccountIds.every((id_7) => selectedAccountIds.includes(id_7))) setSelectedAccountIds(selectedAccountIds.filter((id_8) => !closedAccountIds.includes(id_8)));
					else {
						const newSelection_1 = [...selectedAccountIds];
						closedAccountIds.forEach((id_9) => {
							if (!newSelection_1.includes(id_9)) newSelection_1.push(id_9);
						});
						setSelectedAccountIds(newSelection_1);
					}
				}
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
				htmlFor: "closed_group",
				style: {
					userSelect: "none",
					fontWeight: "bold"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Closed" })
			})]
		}), groupedAccounts.closed.map((account_11) => {
			const isChecked_1 = selectedAccountMap.has(account_11.id);
			return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
				style: {
					display: !isChecked_1 && uncheckedHidden ? "none" : "flex",
					flexDirection: "row",
					marginBottom: 4,
					marginLeft: 16
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
					id: `account_${account_11.id}`,
					checked: isChecked_1,
					onChange: () => {
						if (isChecked_1) setSelectedAccountIds(selectedAccountIds.filter((id_10) => id_10 !== account_11.id));
						else setSelectedAccountIds([...selectedAccountIds, account_11.id]);
					}
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					htmlFor: `account_${account_11.id}`,
					style: { userSelect: "none" },
					children: account_11.name
				})]
			}, account_11.id);
		})] });
		$[76] = closedSelected;
		$[77] = groupedAccounts.closed;
		$[78] = selectedAccountIds;
		$[79] = selectedAccountMap;
		$[80] = setSelectedAccountIds;
		$[81] = uncheckedHidden;
		$[82] = t30;
	} else t30 = $[82];
	let t31;
	if ($[83] !== t28 || $[84] !== t29 || $[85] !== t30) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
			style: t27,
			children: [
				t28,
				t29,
				t30
			]
		});
		$[83] = t28;
		$[84] = t29;
		$[85] = t30;
		$[86] = t31;
	} else t31 = $[86];
	let t32;
	if ($[87] !== t26 || $[88] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t26, t31] });
		$[87] = t26;
		$[88] = t31;
		$[89] = t32;
	} else t32 = $[89];
	return t32;
}
function _temp8$3(account_10) {
	return account_10.id;
}
function _temp7$5(account_8) {
	return account_8.id;
}
function _temp6$6(account_6) {
	return account_6.id;
}
function _temp5$6(account_5) {
	return account_5.id;
}
function _temp4$7(state) {
	return !state;
}
function _temp3$10(account_1) {
	return account_1.closed;
}
function _temp2$12(account_0) {
	return account_0.offbudget && !account_0.closed;
}
function _temp$18(account) {
	return !account.offbudget && !account.closed;
}
//#endregion
//#region src/components/reports/CategorySelector.tsx
function CategorySelector({ categoryGroups, selectedCategories, setSelectedCategories, showHiddenCategories = true }) {
	const { t } = useTranslation();
	const [uncheckedHidden, setUncheckedHidden] = (0, import_react.useState)(false);
	const filteredGroup = (categoryGroup) => {
		return categoryGroup.categories.filter((f) => {
			return showHiddenCategories || !f.hidden ? true : false;
		});
	};
	const selectAll = [];
	categoryGroups.map((categoryGroup_0) => filteredGroup(categoryGroup_0).map((category) => selectAll.push(category)));
	if (selectedCategories === void 0) selectedCategories = categoryGroups.flatMap((cg) => cg.categories);
	const selectedCategoryMap = (0, import_react.useMemo)(() => selectedCategories.map((selected) => selected.id), [selectedCategories]);
	const allCategoriesSelected = selectAll.every((category_0) => selectedCategoryMap.includes(category_0.id));
	const allCategoriesUnselected = !selectAll.some((category_1) => selectedCategoryMap.includes(category_1.id));
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: {
			flexDirection: "row",
			alignItems: "center",
			marginBottom: 5,
			flexShrink: 0
		},
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "bare",
				onPress: () => setUncheckedHidden((state) => !state),
				style: { padding: 8 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: uncheckedHidden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewShow, {
						width: 15,
						height: 15,
						style: { marginRight: 5 }
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Show unchecked" }) })]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewHide, {
						width: 15,
						height: 15,
						style: { marginRight: 5 }
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							maxWidth: 100,
							whiteSpace: "nowrap",
							overflow: "hidden",
							textOverflow: "ellipsis"
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Hide unchecked" })
					})]
				}) })
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					alignItems: "center"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
					selected: allCategoriesSelected,
					title: t("Select All"),
					onSelect: () => {
						setSelectedCategories(selectAll);
					},
					style: {
						marginRight: 5,
						padding: 8
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheckAll, {
						width: 15,
						height: 15
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
					selected: allCategoriesUnselected,
					title: t("Unselect All"),
					onSelect: () => {
						setSelectedCategories([]);
					},
					style: { padding: 8 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgUncheckAll, {
						width: 15,
						height: 15
					})
				})]
			})
		]
	}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
		style: {
			listStyle: "none",
			marginLeft: 0,
			paddingLeft: 0,
			paddingRight: 10,
			flexGrow: 1,
			overflowY: "auto"
		},
		children: categoryGroups && categoryGroups.map((categoryGroup_1) => {
			const allCategoriesInGroupSelected = filteredGroup(categoryGroup_1).every((category_2) => selectedCategories.some((selectedCategory) => selectedCategory.id === category_2.id));
			return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
				style: {
					display: filteredGroup(categoryGroup_1).every((category_3) => !selectedCategories.some((selectedCategory_0) => selectedCategory_0.id === category_3.id)) && uncheckedHidden ? "none" : "flex",
					marginBottom: 8,
					flexDirection: "row"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
					id: `form_${categoryGroup_1.id}`,
					checked: allCategoriesInGroupSelected,
					onChange: () => {
						const selectedCategoriesExcludingGroupCategories = selectedCategories.filter((selectedCategory_1) => !filteredGroup(categoryGroup_1).some((groupCategory) => groupCategory.id === selectedCategory_1.id));
						if (allCategoriesInGroupSelected) setSelectedCategories(selectedCategoriesExcludingGroupCategories);
						else setSelectedCategories(selectedCategoriesExcludingGroupCategories.concat(filteredGroup(categoryGroup_1)));
					}
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					htmlFor: `form_${categoryGroup_1.id}`,
					style: {
						userSelect: "none",
						fontWeight: "bold"
					},
					children: categoryGroup_1.name
				})]
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
				style: {
					listStyle: "none",
					marginLeft: 0,
					marginBottom: 10,
					paddingLeft: 10
				},
				children: filteredGroup(categoryGroup_1).map((category_4) => {
					const isChecked = selectedCategories.some((selectedCategory_2) => selectedCategory_2.id === category_4.id);
					return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
						style: {
							display: !isChecked && uncheckedHidden ? "none" : "flex",
							flexDirection: "row",
							marginBottom: 4
						},
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
							id: `form_${category_4.id}`,
							checked: isChecked,
							onChange: () => {
								if (isChecked) setSelectedCategories(selectedCategories.filter((selectedCategory_3) => selectedCategory_3.id !== category_4.id));
								else setSelectedCategories([...selectedCategories, category_4]);
							}
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
							htmlFor: `form_${category_4.id}`,
							style: { userSelect: "none" },
							children: category_4.name
						})]
					}, category_4.id);
				})
			}) })] }, categoryGroup_1.id);
		})
	})] });
}
//#endregion
//#region src/components/reports/graphs/CrossoverGraph.tsx
function CustomTooltip$6(t0) {
	const $ = (0, import_compiler_runtime.c)(55);
	const { active, payload } = t0;
	const { t } = useTranslation();
	const format = useFormat();
	if (active && payload && payload.length) {
		let t1;
		let t2;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t2 = { marginBottom: 10 };
			$[0] = t1;
			$[1] = t2;
		} else {
			t1 = $[0];
			t2 = $[1];
		}
		let t3;
		if ($[2] !== payload[0].payload.x) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.x });
			$[2] = payload[0].payload.x;
			$[3] = t3;
		} else t3 = $[3];
		let t4;
		if ($[4] !== payload[0].payload.isProjection || $[5] !== t) {
			t4 = payload[0].payload.isProjection ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
				style: {
					marginLeft: 8,
					opacity: .7
				},
				children: t("(projected)")
			}) : null;
			$[4] = payload[0].payload.isProjection;
			$[5] = t;
			$[6] = t4;
		} else t4 = $[6];
		let t5;
		if ($[7] !== t3 || $[8] !== t4) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t2,
				children: [t3, t4]
			});
			$[7] = t3;
			$[8] = t4;
			$[9] = t5;
		} else t5 = $[9];
		let t6;
		if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
			t6 = { lineHeight: 1.5 };
			$[10] = t6;
		} else t6 = $[10];
		let t7;
		let t8;
		if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
			t7 = css({
				display: "flex",
				justifyContent: "space-between"
			});
			t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Monthly investment income:" }) });
			$[11] = t7;
			$[12] = t8;
		} else {
			t7 = $[11];
			t8 = $[12];
		}
		let t9;
		if ($[13] !== format || $[14] !== payload[0].payload.investmentIncome) {
			t9 = format(payload[0].payload.investmentIncome, "financial");
			$[13] = format;
			$[14] = payload[0].payload.investmentIncome;
			$[15] = t9;
		} else t9 = $[15];
		let t10;
		if ($[16] !== t9) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t9 }) });
			$[16] = t9;
			$[17] = t10;
		} else t10 = $[17];
		let t11;
		if ($[18] !== t10 || $[19] !== t7) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				className: t7,
				children: [t8, t10]
			});
			$[18] = t10;
			$[19] = t7;
			$[20] = t11;
		} else t11 = $[20];
		let t12;
		let t13;
		if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
			t12 = css({
				display: "flex",
				justifyContent: "space-between"
			});
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Monthly expenses:" }) });
			$[21] = t12;
			$[22] = t13;
		} else {
			t12 = $[21];
			t13 = $[22];
		}
		let t14;
		if ($[23] !== format || $[24] !== payload[0].payload.expenses) {
			t14 = format(payload[0].payload.expenses, "financial");
			$[23] = format;
			$[24] = payload[0].payload.expenses;
			$[25] = t14;
		} else t14 = $[25];
		let t15;
		if ($[26] !== t14) {
			t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t14 }) });
			$[26] = t14;
			$[27] = t15;
		} else t15 = $[27];
		let t16;
		if ($[28] !== t12 || $[29] !== t15) {
			t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				className: t12,
				children: [t13, t15]
			});
			$[28] = t12;
			$[29] = t15;
			$[30] = t16;
		} else t16 = $[30];
		let t17;
		if ($[31] !== format || $[32] !== payload[0].payload.adjustedExpenses) {
			t17 = payload[0].payload.adjustedExpenses != null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				className: css({
					display: "flex",
					justifyContent: "space-between"
				}),
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Target income:" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.adjustedExpenses, "financial") }) })]
			});
			$[31] = format;
			$[32] = payload[0].payload.adjustedExpenses;
			$[33] = t17;
		} else t17 = $[33];
		let t18;
		let t19;
		if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
			t18 = css({
				display: "flex",
				justifyContent: "space-between"
			});
			t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Life savings:" }) });
			$[34] = t18;
			$[35] = t19;
		} else {
			t18 = $[34];
			t19 = $[35];
		}
		let t20;
		if ($[36] !== format || $[37] !== payload[0].payload.nestEgg) {
			t20 = format(payload[0].payload.nestEgg, "financial");
			$[36] = format;
			$[37] = payload[0].payload.nestEgg;
			$[38] = t20;
		} else t20 = $[38];
		let t21;
		if ($[39] !== t20) {
			t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t20 }) });
			$[39] = t20;
			$[40] = t21;
		} else t21 = $[40];
		let t22;
		if ($[41] !== t18 || $[42] !== t21) {
			t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				className: t18,
				children: [t19, t21]
			});
			$[41] = t18;
			$[42] = t21;
			$[43] = t22;
		} else t22 = $[43];
		let t23;
		if ($[44] !== t11 || $[45] !== t16 || $[46] !== t17 || $[47] !== t22) {
			t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t6,
				children: [
					t11,
					t16,
					t17,
					t22
				]
			});
			$[44] = t11;
			$[45] = t16;
			$[46] = t17;
			$[47] = t22;
			$[48] = t23;
		} else t23 = $[48];
		let t24;
		if ($[49] !== t23 || $[50] !== t5) {
			t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t23] });
			$[49] = t23;
			$[50] = t5;
			$[51] = t24;
		} else t24 = $[51];
		let t25;
		if ($[52] !== t1 || $[53] !== t24) {
			t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t1,
				children: t24
			});
			$[52] = t1;
			$[53] = t24;
			$[54] = t25;
		} else t25 = $[54];
		return t25;
	}
	return null;
}
function CrossoverGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(19);
	const { style, graphData, compact: t1, showTooltip: t2 } = t0;
	const compact = t1 === void 0 ? false : t1;
	const showTooltip = t2 === void 0 ? true : t2;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	let t3;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = { animationDuration: 1e3 };
		$[0] = t3;
	} else t3 = $[0];
	const animationProps = useRechartsAnimation(t3);
	let t4;
	if ($[1] !== format || $[2] !== privacyMode) {
		t4 = (tick) => {
			if (privacyMode) return "...";
			return `${format(Math.round(tick), "financial-no-decimals")}`;
		};
		$[1] = format;
		$[2] = privacyMode;
		$[3] = t4;
	} else t4 = $[3];
	const tickFormatter = t4;
	let t5;
	if ($[4] !== compact) {
		t5 = compact && { height: "auto" };
		$[4] = compact;
		$[5] = t5;
	} else t5 = $[5];
	let t6;
	if ($[6] !== style || $[7] !== t5) {
		t6 = {
			...style,
			...t5
		};
		$[6] = style;
		$[7] = t5;
		$[8] = t6;
	} else t6 = $[8];
	let t7;
	if ($[9] !== animationProps || $[10] !== compact || $[11] !== graphData.crossoverXLabel || $[12] !== graphData.data || $[13] !== showTooltip || $[14] !== tickFormatter) {
		t7 = (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LineChart, {
			width,
			height,
			data: graphData.data,
			margin: {
				top: compact ? 0 : 15,
				right: 0,
				left: compact ? 0 : 20,
				bottom: compact ? 0 : 10
			},
			children: [
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "x",
					hide: compact,
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					hide: compact,
					tickFormatter,
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$6, {}),
					isAnimationActive: false
				}),
				graphData.crossoverXLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
					x: graphData.crossoverXLabel,
					stroke: theme.noticeText,
					strokeDasharray: "4 4"
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					type: "monotone",
					dataKey: "investmentIncome",
					dot: false,
					stroke: theme.reportsNumberPositive,
					strokeWidth: 2,
					...animationProps
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					type: "monotone",
					dataKey: "expenses",
					dot: false,
					stroke: theme.reportsNumberNegative,
					strokeWidth: 2,
					...animationProps
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					type: "monotone",
					dataKey: "adjustedExpenses",
					dot: false,
					stroke: theme.reportsNumberNegative,
					strokeWidth: 2,
					strokeDasharray: "5 5",
					...animationProps
				})
			]
		});
		$[9] = animationProps;
		$[10] = compact;
		$[11] = graphData.crossoverXLabel;
		$[12] = graphData.data;
		$[13] = showTooltip;
		$[14] = tickFormatter;
		$[15] = t7;
	} else t7 = $[15];
	let t8;
	if ($[16] !== t6 || $[17] !== t7) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t6,
			children: t7
		});
		$[16] = t6;
		$[17] = t7;
		$[18] = t8;
	} else t8 = $[18];
	return t8;
}
//#endregion
//#region src/components/reports/spreadsheets/crossover-spreadsheet.ts
function calculateMedian(values) {
	if (values.length === 0) return 0;
	if (values.length === 1) return values[0];
	const sorted = [...values].sort((a, b) => a - b);
	const mid = Math.floor(sorted.length / 2);
	return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
}
function calculateMean(values) {
	if (values.length === 0) return 0;
	return values.reduce((acc, val) => acc + val, 0) / values.length;
}
function calculateMAD(values, median) {
	return calculateMedian(values.map((v) => Math.abs(v - median)));
}
function calculateHampelFilteredMedian(expenses) {
	if (expenses.length === 0) return 0;
	if (expenses.length === 1) return expenses[0];
	const median = calculateMedian(expenses);
	const mad = calculateMAD(expenses, median);
	const threshold = 3;
	return calculateMedian(expenses.filter((expense) => {
		const lowerBound = median - 1.4826 * mad * threshold;
		const upperBound = median + 1.4826 * mad * threshold;
		return expense >= lowerBound && expense <= upperBound;
	}));
}
function createCrossoverSpreadsheet({ start, end, expenseCategoryIds, incomeAccountIds, safeWithdrawalRate, estimatedReturn, expectedContribution, projectionType, expenseAdjustmentFactor }) {
	return async (_spreadsheet, setData) => {
		if (!start || !end || incomeAccountIds.length === 0) {
			setData({
				graphData: {
					data: [],
					start: start || "",
					end: end || "",
					crossoverXLabel: null
				},
				lastKnownBalance: 0,
				lastKnownMonthlyIncome: 0,
				lastKnownMonthlyExpenses: 0,
				historicalReturn: null,
				yearsToRetire: null,
				targetMonthlyIncome: null,
				targetNestEgg: null
			});
			return;
		}
		const expensesPromise = (async () => {
			if (!expenseCategoryIds.length) return rangeInclusive(start, end).map((date) => ({
				date,
				amount: 0
			}));
			const { data } = await aqlQuery(q$1("transactions").filter({ $and: [
				{ $or: expenseCategoryIds.map((id) => ({ category: id })) },
				{ date: { $gte: firstDayOfMonth(start) } },
				{ date: { $lte: lastDayOfMonth(end) } }
			] }).groupBy({ $month: "$date" }).select([{ date: { $month: "$date" } }, { amount: { $sum: "$amount" } }]));
			return data;
		})();
		const historicalBalancesPromise = Promise.all(incomeAccountIds.map(async (accountId) => {
			return {
				accountId,
				starting: await aqlQuery(q$1("transactions").filter({ account: accountId }).filter({ date: { $lte: lastDayOfMonth(start) } }).calculate({ $sum: "$amount" })).then(({ data }) => typeof data === "number" ? data : 0),
				balances: (await aqlQuery(q$1("transactions").filter({
					account: accountId,
					date: { $gte: firstDayOfMonth(start) }
				}).filter({ $and: [{ date: { $lte: lastDayOfMonth(end) } }] }).groupBy({ $month: "$date" }).select([{ date: { $month: "$date" } }, { amount: { $sum: "$amount" } }])).then(({ data }) => data)).filter((b) => b.date !== start)
			};
		}));
		const [expenses, historicalBalances] = await Promise.all([expensesPromise, historicalBalancesPromise]);
		setData(recalculate$2({
			start,
			end,
			expenseCategoryIds,
			incomeAccountIds,
			safeWithdrawalRate,
			estimatedReturn,
			expectedContribution,
			projectionType,
			expenseAdjustmentFactor
		}, expenses, historicalBalances));
	};
}
function recalculate$2(params, expenses, historicalAccounts) {
	const months = rangeInclusive(params.start, params.end);
	const expenseMap = /* @__PURE__ */ new Map();
	for (const e of expenses) expenseMap.set(e.date, (expenseMap.get(e.date) || 0) + -e.amount);
	const historicalBalances = months.map(() => 0);
	for (const acct of historicalAccounts) {
		let runningBalance = acct.starting;
		const byMonth = new Map(acct.balances.map((b) => [b.date, b.amount]));
		for (let i = 0; i < months.length; i++) {
			const month = months[i];
			const delta = byMonth.get(month) ?? 0;
			runningBalance += delta;
			historicalBalances[i] += runningBalance;
		}
	}
	const monthlySWR = params.safeWithdrawalRate / 12;
	const data = [];
	let lastBalance = 0;
	let lastExpense = 0;
	let crossoverIndex = null;
	const adjustmentFactor = params.expenseAdjustmentFactor ?? 1;
	months.forEach((month, idx) => {
		const balance = historicalBalances[idx];
		const monthlyIncome = balance * monthlySWR;
		const spend = expenseMap.get(month) || 0;
		data.push({
			x: format$1(parseISO(month + "-01"), "MMM yyyy"),
			investmentIncome: Math.round(monthlyIncome),
			expenses: spend,
			nestEgg: balance
		});
		lastBalance = balance;
		lastExpense = spend;
	});
	const annualReturn = params.estimatedReturn ?? null;
	let monthlyReturn = annualReturn != null ? Math.pow(1 + annualReturn, 1 / 12) - 1 : null;
	let defaultMonthlyReturn = null;
	if (historicalBalances.length >= 2) {
		let startingBalance = historicalBalances[0];
		const finalBalance = historicalBalances[historicalBalances.length - 1];
		const n = historicalBalances.length - 1;
		if (startingBalance === 0) {
			for (let i = 1; i < historicalBalances.length; i++) if (historicalBalances[i] !== 0) {
				startingBalance = historicalBalances[i];
				break;
			}
		}
		if (startingBalance > 0 && finalBalance > 0 && n > 0) {
			const cagrMonthly = Math.pow(finalBalance / startingBalance, 1 / n) - 1;
			if (isFinite(cagrMonthly) && !isNaN(cagrMonthly)) defaultMonthlyReturn = cagrMonthly;
			else defaultMonthlyReturn = 0;
		} else defaultMonthlyReturn = 0;
	}
	const monthlyContribution = params.expectedContribution ?? 0;
	if (months.length > 0) {
		if (monthlyReturn == null) monthlyReturn = defaultMonthlyReturn;
		const maxProjectionMonths = 600;
		let projectedBalance = lastBalance;
		let monthCursor = parseISO(months[months.length - 1] + "-01");
		let flatExpense = 0;
		const y = months.map((m) => expenseMap.get(m) || 0);
		if (params.projectionType === "hampel") flatExpense = calculateHampelFilteredMedian(y);
		else if (params.projectionType === "median") flatExpense = calculateMedian(y);
		else if (params.projectionType === "mean") flatExpense = calculateMean(y);
		for (let i = 1; i <= maxProjectionMonths; i++) {
			monthCursor = addMonths$1(monthCursor, 1);
			projectedBalance = projectedBalance + monthlyContribution;
			if (monthlyReturn != null) projectedBalance = projectedBalance * (1 + monthlyReturn);
			const projectedIncome = projectedBalance * monthlySWR;
			const projectedExpenses = Math.max(0, flatExpense);
			const adjustedProjectedExpenses = projectedExpenses * adjustmentFactor;
			data.push({
				x: format$1(monthCursor, "MMM yyyy"),
				investmentIncome: Math.round(projectedIncome),
				expenses: Math.round(projectedExpenses),
				nestEgg: Math.round(projectedBalance),
				adjustedExpenses: Math.round(adjustedProjectedExpenses),
				isProjection: true
			});
			if (crossoverIndex == null && Math.round(projectedIncome) >= Math.round(adjustedProjectedExpenses)) {
				crossoverIndex = months.length + (i - 1);
				break;
			}
		}
	}
	let yearsToRetire = null;
	let targetMonthlyIncome = null;
	let targetNestEgg = null;
	if (crossoverIndex != null && crossoverIndex < data.length) {
		const crossoverData = data[crossoverIndex];
		if (crossoverData) {
			const currentDate = /* @__PURE__ */ new Date();
			const monthsDiff = differenceInMonths(parse(crossoverData.x, "MMM yyyy", currentDate), currentDate);
			yearsToRetire = monthsDiff > 0 ? monthsDiff / 12 : 0;
			targetMonthlyIncome = crossoverData.adjustedExpenses ?? null;
			targetNestEgg = targetMonthlyIncome != null ? Math.round(targetMonthlyIncome / monthlySWR) : null;
		}
	}
	return {
		graphData: {
			data,
			start: params.start,
			end: params.end,
			crossoverXLabel: crossoverIndex != null ? data[crossoverIndex]?.x ?? null : null
		},
		lastKnownBalance: historicalBalances[historicalBalances.length - 1] || 0,
		lastKnownMonthlyIncome: Math.round((historicalBalances[historicalBalances.length - 1] || 0) * monthlySWR),
		lastKnownMonthlyExpenses: lastExpense,
		historicalReturn: defaultMonthlyReturn != null ? Math.pow(1 + defaultMonthlyReturn, 12) - 1 : null,
		yearsToRetire,
		targetMonthlyIncome,
		targetNestEgg
	};
}
//#endregion
//#region src/components/reports/reports/Crossover.tsx
var defaultTimeFrame = {
	start: subMonths(currentMonth(), 120),
	end: subMonths(currentMonth(), 1),
	mode: "full"
};
function Crossover() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "crossover-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CrossoverInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function CrossoverInner(t0) {
	const $ = (0, import_compiler_runtime.c)(129);
	const { widget } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	const dispatch = useDispatch();
	const { data: t1 } = useAccounts();
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const accounts = t2;
	const { data: t3, isPending: isCategoriesLoading } = useCategories();
	let t4;
	if ($[2] !== t3) {
		t4 = t3 === void 0 ? {
			grouped: [],
			list: []
		} : t3;
		$[2] = t3;
		$[3] = t4;
	} else t4 = $[3];
	const categories = t4;
	const format$8 = useFormat();
	let t5;
	if ($[4] !== categories.grouped) {
		t5 = categories.grouped.filter(_temp$17);
		$[4] = categories.grouped;
		$[5] = t5;
	} else t5 = $[5];
	const expenseCategoryGroups = t5;
	let t6;
	if ($[6] !== categories.list) {
		t6 = categories.list.filter(_temp2$11);
		$[6] = categories.list;
		$[7] = t6;
	} else t6 = $[7];
	const expenseCategories = t6;
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	const [start, setStart] = (0, import_react.useState)("");
	const [end, setEnd] = (0, import_react.useState)("");
	const [mode, setMode] = (0, import_react.useState)("static");
	const [earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [selectedExpenseCategories, setSelectedExpenseCategories] = (0, import_react.useState)(expenseCategories);
	let t7;
	if ($[8] !== accounts) {
		t7 = accounts.map(_temp3$9);
		$[8] = accounts;
		$[9] = t7;
	} else t7 = $[9];
	const [selectedIncomeAccountIds, setSelectedIncomeAccountIds] = (0, import_react.useState)(t7);
	const [swr, setSwr] = (0, import_react.useState)(.04);
	const [useCustomGrowth, setUseCustomGrowth] = (0, import_react.useState)(false);
	const [estimatedReturn, setEstimatedReturn] = (0, import_react.useState)(null);
	const [expectedContribution, setExpectedContribution] = (0, import_react.useState)(null);
	const [projectionType, setProjectionType] = (0, import_react.useState)("hampel");
	const [expenseAdjustmentFactor, setExpenseAdjustmentFactor] = (0, import_react.useState)(1);
	const [showHiddenCategories, setShowHiddenCategories] = (0, import_react.useState)(false);
	const [selectionsInitialized, setSelectionsInitialized] = (0, import_react.useState)(false);
	let t8;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => {
			setSelectionsInitialized(false);
		};
		$[10] = t8;
	} else t8 = $[10];
	const t9 = widget?.id;
	let t10;
	if ($[11] !== t9) {
		t10 = [t9];
		$[11] = t9;
		$[12] = t10;
	} else t10 = $[12];
	(0, import_react.useEffect)(t8, t10);
	let t11;
	if ($[13] !== accounts || $[14] !== categories.list || $[15] !== isCategoriesLoading || $[16] !== selectionsInitialized || $[17] !== widget) {
		t11 = () => {
			if (selectionsInitialized || accounts.length === 0 || isCategoriesLoading) return;
			const initialExpenseCategories = widget?.meta?.expenseCategoryIds !== void 0 ? categories.list.filter((c_0) => widget.meta.expenseCategoryIds.includes(c_0.id)) : categories.list.filter(_temp4$6);
			const initialIncomeAccountIds = widget?.meta?.incomeAccountIds !== void 0 ? widget.meta.incomeAccountIds : accounts.map(_temp5$5);
			setSelectedExpenseCategories(initialExpenseCategories);
			setSelectedIncomeAccountIds(initialIncomeAccountIds);
			setSwr(widget?.meta?.safeWithdrawalRate ?? .04);
			const initialEstimatedReturn = widget?.meta?.estimatedReturn ?? null;
			const initialExpectedContribution = widget?.meta?.expectedContribution ?? null;
			setUseCustomGrowth(initialEstimatedReturn != null || initialExpectedContribution != null);
			setEstimatedReturn(initialEstimatedReturn);
			setExpectedContribution(initialExpectedContribution);
			setProjectionType(widget?.meta?.projectionType ?? "hampel");
			setExpenseAdjustmentFactor(widget?.meta?.expenseAdjustmentFactor ?? 1);
			setShowHiddenCategories(widget?.meta?.showHiddenCategories ?? false);
			setSelectionsInitialized(true);
		};
		$[13] = accounts;
		$[14] = categories.list;
		$[15] = isCategoriesLoading;
		$[16] = selectionsInitialized;
		$[17] = widget;
		$[18] = t11;
	} else t11 = $[18];
	const t12 = widget?.meta;
	let t13;
	if ($[19] !== accounts || $[20] !== categories.list || $[21] !== isCategoriesLoading || $[22] !== selectionsInitialized || $[23] !== t12) {
		t13 = [
			selectionsInitialized,
			accounts,
			categories.list,
			isCategoriesLoading,
			t12
		];
		$[19] = accounts;
		$[20] = categories.list;
		$[21] = isCategoriesLoading;
		$[22] = selectionsInitialized;
		$[23] = t12;
		$[24] = t13;
	} else t13 = $[24];
	(0, import_react.useEffect)(t11, t13);
	let t14;
	let t15;
	if ($[25] !== locale) {
		t14 = () => {
			(async function run() {
				const earliestTransactionData = await send("get-earliest-transaction");
				const previousMonth = subMonths(currentMonth(), 1);
				const earliestDate = earliestTransactionData ? earliestTransactionData.date : firstDayOfMonth(previousMonth);
				setEarliestTransaction(earliestDate);
				const latestDate = lastDayOfMonth(previousMonth);
				setLatestTransaction(latestDate);
				setAllMonths(rangeInclusive(earliestDate, latestDate).map((month) => ({
					name: month,
					pretty: format(month, "MMMM yyyy", locale)
				})).reverse());
			})();
		};
		t15 = [locale];
		$[25] = locale;
		$[26] = t14;
		$[27] = t15;
	} else {
		t14 = $[26];
		t15 = $[27];
	}
	(0, import_react.useEffect)(t14, t15);
	let t16;
	if ($[28] !== allMonths || $[29] !== latestTransaction || $[30] !== widget?.meta?.timeFrame) {
		t16 = () => {
			if (latestTransaction && allMonths?.length) {
				const [initialStart, initialEnd, mode_0] = calculateTimeRange(widget?.meta?.timeFrame, defaultTimeFrame, latestTransaction);
				const earliestMonth = allMonths[allMonths.length - 1].name;
				const latestMonth = allMonths[0].name;
				let start_0 = initialStart;
				let end_0 = initialEnd;
				const clampMonth = (m) => {
					if (isBefore(m, earliestMonth)) return earliestMonth;
					if (isAfter(m, latestMonth)) return latestMonth;
					return m;
				};
				if (mode_0 === "sliding-window") {
					start_0 = clampMonth(subMonths(start_0, 1));
					end_0 = clampMonth(subMonths(end_0, 1));
				} else if (mode_0 === "full") {
					start_0 = earliestMonth;
					end_0 = latestMonth;
				} else {
					start_0 = clampMonth(start_0);
					end_0 = clampMonth(end_0);
				}
				if (isBefore(end_0, start_0)) end_0 = start_0;
				setStart(start_0);
				setEnd(end_0);
				setMode(mode_0);
			}
		};
		$[28] = allMonths;
		$[29] = latestTransaction;
		$[30] = widget?.meta?.timeFrame;
		$[31] = t16;
	} else t16 = $[31];
	const t17 = widget?.meta?.timeFrame;
	let t18;
	if ($[32] !== allMonths || $[33] !== latestTransaction || $[34] !== t17) {
		t18 = [
			latestTransaction,
			t17,
			allMonths
		];
		$[32] = allMonths;
		$[33] = latestTransaction;
		$[34] = t17;
		$[35] = t18;
	} else t18 = $[35];
	(0, import_react.useEffect)(t16, t18);
	let t19;
	if ($[36] !== allMonths) {
		t19 = function onChangeDates(start_1, end_1, mode_1) {
			if (!allMonths?.length) return;
			const earliestMonth_0 = allMonths[allMonths.length - 1].name;
			const latestMonth_0 = allMonths[0].name;
			const clampMonth_0 = (m_0) => {
				if (isBefore(m_0, earliestMonth_0)) return earliestMonth_0;
				if (isAfter(m_0, latestMonth_0)) return latestMonth_0;
				return m_0;
			};
			if (mode_1 === "sliding-window") {
				start_1 = clampMonth_0(subMonths(start_1, 1));
				end_1 = clampMonth_0(subMonths(end_1, 1));
			} else if (mode_1 === "full") {
				start_1 = earliestMonth_0;
				end_1 = latestMonth_0;
			} else {
				start_1 = clampMonth_0(start_1);
				end_1 = clampMonth_0(end_1);
			}
			if (isBefore(end_1, start_1)) end_1 = start_1;
			setStart(start_1);
			setEnd(end_1);
			setMode(mode_1);
		};
		$[36] = allMonths;
		$[37] = t19;
	} else t19 = $[37];
	const onChangeDates = t19;
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	let t20;
	if ($[38] !== dispatch || $[39] !== end || $[40] !== estimatedReturn || $[41] !== expectedContribution || $[42] !== expenseAdjustmentFactor || $[43] !== mode || $[44] !== projectionType || $[45] !== selectedExpenseCategories || $[46] !== selectedIncomeAccountIds || $[47] !== showHiddenCategories || $[48] !== start || $[49] !== swr || $[50] !== t || $[51] !== updateDashboardWidgetMutation || $[52] !== useCustomGrowth || $[53] !== widget) {
		t20 = async function onSaveWidget() {
			if (!widget) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Save failed: No widget found to save.")
				} }));
				return;
			}
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					expenseCategoryIds: selectedExpenseCategories.map(_temp6$5),
					incomeAccountIds: selectedIncomeAccountIds,
					safeWithdrawalRate: swr,
					estimatedReturn: useCustomGrowth ? estimatedReturn ?? 0 : null,
					expectedContribution: useCustomGrowth ? expectedContribution ?? 0 : null,
					projectionType,
					expenseAdjustmentFactor,
					showHiddenCategories,
					timeFrame: {
						start,
						end,
						mode
					}
				}
			} }, { onSuccess: () => {
				dispatch(addNotification({ notification: {
					type: "message",
					message: t("Dashboard widget successfully saved.")
				} }));
			} });
		};
		$[38] = dispatch;
		$[39] = end;
		$[40] = estimatedReturn;
		$[41] = expectedContribution;
		$[42] = expenseAdjustmentFactor;
		$[43] = mode;
		$[44] = projectionType;
		$[45] = selectedExpenseCategories;
		$[46] = selectedIncomeAccountIds;
		$[47] = showHiddenCategories;
		$[48] = start;
		$[49] = swr;
		$[50] = t;
		$[51] = updateDashboardWidgetMutation;
		$[52] = useCustomGrowth;
		$[53] = widget;
		$[54] = t20;
	} else t20 = $[54];
	const onSaveWidget = t20;
	let t21;
	if ($[55] !== selectedExpenseCategories || $[56] !== showHiddenCategories) {
		let t22;
		if ($[58] !== showHiddenCategories) {
			t22 = (c_3) => showHiddenCategories || !c_3.hidden;
			$[58] = showHiddenCategories;
			$[59] = t22;
		} else t22 = $[59];
		t21 = selectedExpenseCategories.filter(t22).map(_temp7$4);
		$[55] = selectedExpenseCategories;
		$[56] = showHiddenCategories;
		$[57] = t21;
	} else t21 = $[57];
	const expenseCategoryIds = t21;
	let t22;
	if ($[60] !== end || $[61] !== estimatedReturn || $[62] !== expectedContribution || $[63] !== expenseAdjustmentFactor || $[64] !== expenseCategoryIds || $[65] !== projectionType || $[66] !== selectedIncomeAccountIds || $[67] !== start || $[68] !== swr || $[69] !== useCustomGrowth) {
		t22 = async (spreadsheet, setData) => {
			if (!start || !end) return;
			await createCrossoverSpreadsheet({
				start,
				end,
				expenseCategoryIds,
				incomeAccountIds: selectedIncomeAccountIds,
				safeWithdrawalRate: swr,
				estimatedReturn: useCustomGrowth ? estimatedReturn ?? 0 : null,
				expectedContribution: useCustomGrowth ? expectedContribution ?? 0 : null,
				projectionType,
				expenseAdjustmentFactor
			})(spreadsheet, setData);
		};
		$[60] = end;
		$[61] = estimatedReturn;
		$[62] = expectedContribution;
		$[63] = expenseAdjustmentFactor;
		$[64] = expenseCategoryIds;
		$[65] = projectionType;
		$[66] = selectedIncomeAccountIds;
		$[67] = start;
		$[68] = swr;
		$[69] = useCustomGrowth;
		$[70] = t22;
	} else t22 = $[70];
	const data = useReport$1("crossover", t22);
	const historicalReturn = data?.historicalReturn ?? null;
	const yearsToRetire = data?.yearsToRetire ?? null;
	const targetMonthlyIncome = data?.targetMonthlyIncome ?? null;
	const targetNestEgg = data?.targetNestEgg ?? null;
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	let t23;
	if ($[71] !== t || $[72] !== widget?.meta?.name) {
		t23 = widget?.meta?.name || t("Crossover Point");
		$[71] = t;
		$[72] = widget?.meta?.name;
		$[73] = t23;
	} else t23 = $[73];
	const title = t23;
	let t24;
	if ($[74] !== dispatch || $[75] !== t || $[76] !== updateDashboardWidgetMutation || $[77] !== widget) {
		t24 = async (newName) => {
			if (!widget) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Save failed: No widget found to save.")
				} }));
				return;
			}
			const name = newName || t("Crossover Point");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					name
				}
			} });
		};
		$[74] = dispatch;
		$[75] = t;
		$[76] = updateDashboardWidgetMutation;
		$[77] = widget;
		$[78] = t24;
	} else t24 = $[78];
	const onSaveWidgetName = t24;
	if (!allMonths || !data || !start || !end || isCategoriesLoading || accounts.length === 0) {
		let t25;
		if ($[79] === Symbol.for("react.memo_cache_sentinel")) {
			t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[79] = t25;
		} else t25 = $[79];
		return t25;
	}
	let t25;
	if ($[80] !== isNarrowWidth || $[81] !== navigate || $[82] !== onSaveWidgetName || $[83] !== title || $[84] !== widget) {
		t25 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title });
		$[80] = isNarrowWidth;
		$[81] = navigate;
		$[82] = onSaveWidgetName;
		$[83] = title;
		$[84] = widget;
		$[85] = t25;
	} else t25 = $[85];
	let t26;
	if ($[86] !== onSaveWidget || $[87] !== widget) {
		t26 = widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			onPress: onSaveWidget,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
		});
		$[86] = onSaveWidget;
		$[87] = widget;
		$[88] = t26;
	} else t26 = $[88];
	let t27;
	if ($[89] !== allMonths || $[90] !== earliestTransaction || $[91] !== end || $[92] !== latestTransaction || $[93] !== mode || $[94] !== onChangeDates || $[95] !== start || $[96] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			start,
			end,
			mode,
			allMonths,
			earliestTransaction,
			latestTransaction,
			onChangeDates,
			children: t26
		});
		$[89] = allMonths;
		$[90] = earliestTransaction;
		$[91] = end;
		$[92] = latestTransaction;
		$[93] = mode;
		$[94] = onChangeDates;
		$[95] = start;
		$[96] = t26;
		$[97] = t27;
	} else t27 = $[97];
	const t28 = !isNarrowWidth ? 20 : void 0;
	let t29;
	if ($[98] !== t28) {
		t29 = {
			flexDirection: "row",
			paddingLeft: t28,
			flex: 1
		};
		$[98] = t28;
		$[99] = t29;
	} else t29 = $[99];
	let t30;
	if ($[100] === Symbol.for("react.memo_cache_sentinel")) {
		t30 = { flex: 1 };
		$[100] = t30;
	} else t30 = $[100];
	let t31;
	if ($[101] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = {
			backgroundColor: theme.tableBackground,
			padding: 20,
			paddingTop: 10,
			marginBottom: 10
		};
		$[101] = t31;
	} else t31 = $[101];
	let t32;
	if ($[102] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = { textAlign: "right" };
		$[102] = t32;
	} else t32 = $[102];
	let t33;
	let t34;
	if ($[103] === Symbol.for("react.memo_cache_sentinel")) {
		t33 = {
			...styles.largeText,
			fontWeight: 400,
			marginBottom: 8,
			whiteSpace: "nowrap"
		};
		t34 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Years to Retire" });
		$[103] = t33;
		$[104] = t34;
	} else {
		t33 = $[103];
		t34 = $[104];
	}
	let t35;
	let t36;
	if ($[105] === Symbol.for("react.memo_cache_sentinel")) {
		t35 = { whiteSpace: "nowrap" };
		t36 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Target Monthly Income" });
		$[105] = t35;
		$[106] = t36;
	} else {
		t35 = $[105];
		t36 = $[106];
	}
	const t37 = targetMonthlyIncome != null && !isNaN(targetMonthlyIncome) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format$8(targetMonthlyIncome, "financial") }) : t("N/A");
	let t38;
	if ($[107] !== t37) {
		t38 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t35,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
				t36,
				":",
				" ",
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: t37 })
			] })
		});
		$[107] = t37;
		$[108] = t38;
	} else t38 = $[108];
	const T0 = View;
	let t39;
	let t40;
	if ($[109] === Symbol.for("react.memo_cache_sentinel")) {
		t39 = { whiteSpace: "nowrap" };
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Target Life Savings" });
		$[109] = t39;
		$[110] = t40;
	} else {
		t39 = $[109];
		t40 = $[110];
	}
	const t41 = ":";
	const t42 = " ";
	const T1 = PrivacyFilter;
	const t43 = targetNestEgg != null && !isNaN(targetNestEgg) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format$8(targetNestEgg, "financial") }) : t("N/A");
	let t44;
	if ($[111] !== T1 || $[112] !== t43) {
		t44 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T1, { children: t43 });
		$[111] = T1;
		$[112] = t43;
		$[113] = t44;
	} else t44 = $[113];
	let t45;
	if ($[114] !== t40 || $[115] !== t44) {
		t45 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
			t40,
			t41,
			t42,
			t44
		] });
		$[114] = t40;
		$[115] = t44;
		$[116] = t45;
	} else t45 = $[116];
	let t46;
	if ($[117] !== T0 || $[118] !== t39 || $[119] !== t45) {
		t46 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			style: t39,
			children: t45
		});
		$[117] = T0;
		$[118] = t39;
		$[119] = t45;
		$[120] = t46;
	} else t46 = $[120];
	let t47;
	if ($[121] === Symbol.for("react.memo_cache_sentinel")) {
		t47 = {
			backgroundColor: theme.tableBackground,
			flexDirection: "row",
			flex: "1 0 auto",
			minHeight: 400
		};
		$[121] = t47;
	} else t47 = $[121];
	let t48;
	if ($[122] === Symbol.for("react.memo_cache_sentinel")) {
		t48 = {
			flex: 1,
			padding: 10,
			height: "100%"
		};
		$[122] = t48;
	} else t48 = $[122];
	let t49;
	if ($[123] === Symbol.for("react.memo_cache_sentinel")) {
		t49 = {
			height: "100%",
			flex: 1
		};
		$[123] = t49;
	} else t49 = $[123];
	let t50;
	if ($[124] !== data.graphData) {
		t50 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t47,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: t48,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CrossoverGraph, {
					graphData: data.graphData,
					style: t49
				})
			})
		});
		$[124] = data.graphData;
		$[125] = t50;
	} else t50 = $[125];
	let t51;
	if ($[126] === Symbol.for("react.memo_cache_sentinel")) {
		t51 = {
			backgroundColor: theme.tableBackground,
			marginTop: 10,
			padding: 20,
			userSelect: "none"
		};
		$[126] = t51;
	} else t51 = $[126];
	let t52;
	if ($[127] === Symbol.for("react.memo_cache_sentinel")) {
		t52 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "What is the Crossover Point?" }) }) });
		$[127] = t52;
	} else t52 = $[127];
	let t53;
	if ($[128] === Symbol.for("react.memo_cache_sentinel")) {
		t53 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t51,
			children: [t52, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "The crossover point is when your monthly investment income (from selected accounts using the safe withdrawal rate) meets or exceeds your total monthly expenses (from selected categories). The chart projects into the future using your estimated return until the lines cross." }) })]
		});
		$[128] = t53;
	} else t53 = $[128];
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: t25,
		padding: 0,
		children: [t27, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t29,
			children: [!isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					minWidth: 225,
					maxWidth: 250,
					paddingTop: 10,
					paddingRight: 10,
					flexShrink: 0,
					overflowY: "auto"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: { flexShrink: 0 },
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontWeight: 600,
								marginBottom: 8
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
								style: {
									flexDirection: "row",
									alignItems: "center",
									justifyContent: "space-between"
								},
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expenses categories" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
									content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: { maxWidth: 300 },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
											"Used to estimate your future expenses.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Select the budget categories that reflect your living expenses in retirement.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Ex: Food, Utilities, Entertainment, Medical",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Exclude categories that will not continue in retirement.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Ex: Retirement Savings"
										] }) })
									}),
									placement: "right top",
									style: { ...styles.tooltip },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
										height: 12,
										width: 12,
										cursor: "pointer"
									})
								})]
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: {
								flexDirection: "row",
								alignItems: "center",
								marginBottom: 5,
								flexShrink: 0
							},
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								variant: "bare",
								onPress: () => setShowHiddenCategories(!showHiddenCategories),
								style: { padding: 8 },
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: showHiddenCategories ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										flexDirection: "row",
										alignItems: "center"
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewHide, {
										width: 15,
										height: 15,
										style: { marginRight: 5 }
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Hide hidden" }) })]
								}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										flexDirection: "row",
										alignItems: "center"
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgViewShow, {
										width: 15,
										height: 15,
										style: { marginRight: 5 }
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
										style: {
											maxWidth: 100,
											whiteSpace: "nowrap",
											overflow: "hidden",
											textOverflow: "ellipsis"
										},
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Show hidden" })
									})]
								}) })
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } })]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								maxHeight: 220,
								overflowY: "auto",
								marginBottom: 12
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CategorySelector, {
								categoryGroups: expenseCategoryGroups,
								selectedCategories: selectedExpenseCategories,
								setSelectedCategories: setSelectedExpenseCategories,
								showHiddenCategories
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontWeight: 600,
								marginBottom: 8
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
								style: {
									flexDirection: "row",
									alignItems: "center",
									justifyContent: "space-between"
								},
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Income accounts" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
									content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: { maxWidth: 300 },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
											"Used to estimate your future income.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Select the accounts that will be used to fund your retirement.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Ex: Retirement Accounts, Savings Accounts",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Exclude accounts that will not.",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
											"Ex: Mortgage Accounts, Child Education Accounts"
										] }) })
									}),
									placement: "right top",
									style: { ...styles.tooltip },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
										height: 12,
										width: 12,
										cursor: "pointer"
									})
								})]
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								maxHeight: 220,
								overflowY: "auto",
								marginBottom: 12
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccountSelector, {
								accounts,
								selectedAccountIds: selectedIncomeAccountIds,
								setSelectedAccountIds: setSelectedIncomeAccountIds
							})
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: { marginBottom: 12 },
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: {
									fontWeight: 600,
									marginBottom: 8
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										flexDirection: "row",
										alignItems: "center",
										justifyContent: "space-between"
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: t("Safe withdrawal rate (%)") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
										content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
											style: { maxWidth: 300 },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
												"The amount you plan to withdraw from your Income Accounts each year to fund your living expenses.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
													variant: "external",
													to: "https://en.wikipedia.org/wiki/Retirement_spend-down#Withdrawal_rate",
													children: "More info."
												})
											] }) })
										}),
										placement: "right top",
										style: { ...styles.tooltip },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
											height: 12,
											width: 12,
											cursor: "pointer"
										})
									})]
								})
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
								type: "number",
								min: 0,
								max: 100,
								step: .1,
								value: swr == null ? "" : Number((swr * 100).toFixed(2)),
								onChange: (e) => setSwr(isNaN(e.target.valueAsNumber) ? 0 : e.target.valueAsNumber / 100),
								style: {
									width: 120,
									marginBottom: 12
								}
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: { marginBottom: 12 },
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: {
									fontWeight: 600,
									marginBottom: 8
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										flexDirection: "row",
										alignItems: "center",
										justifyContent: "space-between"
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: t("Expense Projection Type") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
										content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
											style: { maxWidth: 300 },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
												"How past expenses are projected into the future.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"Hampel Filtered Median: Filters out outliers before calculating the median expense.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"Median: Uses the median of all historical expenses without filtering.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"Mean: Uses the average of all historical expenses."
											] }) })
										}),
										placement: "right top",
										style: { ...styles.tooltip },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
											height: 12,
											width: 12,
											cursor: "pointer"
										})
									})]
								})
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
								value: projectionType,
								onChange: (value) => setProjectionType(value),
								options: [
									["hampel", t("Hampel Filtered Median")],
									["median", t("Median")],
									["mean", t("Mean")]
								],
								style: {
									width: 200,
									marginBottom: 12
								}
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: { marginBottom: 12 },
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: {
									fontWeight: 600,
									marginBottom: 8
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										flexDirection: "row",
										alignItems: "center",
										justifyContent: "space-between"
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: t("Target Income (% of expenses)") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
										content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
											style: { maxWidth: 300 },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
												"Your target retirement income as a percentage of projected expenses.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"100% means you need retirement income equal to your current projected expenses.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"Values above 100% mean you plan to spend more in retirement.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"Values below 100% mean you plan to spend less in retirement.",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
												"The graph shows both the projected expenses (solid red line) and your target income (dashed red line)."
											] }) })
										}),
										placement: "right top",
										style: { ...styles.tooltip },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
											height: 12,
											width: 12,
											cursor: "pointer"
										})
									})]
								})
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
								type: "number",
								min: 0,
								max: 1e3,
								step: 1,
								value: expenseAdjustmentFactor == null ? "" : Number((expenseAdjustmentFactor * 100).toFixed(0)),
								onChange: (e_0) => setExpenseAdjustmentFactor(isNaN(e_0.target.valueAsNumber) ? 1 : e_0.target.valueAsNumber / 100),
								style: {
									width: 120,
									marginBottom: 12
								}
							})]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: { marginBottom: 12 },
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
									htmlFor: "custom-growth",
									style: {
										display: "flex",
										alignItems: "center",
										cursor: "pointer",
										userSelect: "none",
										marginBottom: 8
									},
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
											id: "custom-growth",
											checked: useCustomGrowth,
											onChange: (e_1) => {
												const checked = e_1.target.checked;
												setUseCustomGrowth(checked);
												if (checked && estimatedReturn === null) setEstimatedReturn(.06);
											},
											style: { marginRight: 8 }
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
											style: { fontWeight: 600 },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Use custom growth projections" })
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
											content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
												style: { maxWidth: 300 },
												children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
													"Enable this to specify custom monthly contribution amounts and investment returns that will be used to project your investments into the future.",
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
													"When disabled, uses historical performance from your Income Accounts (which includes both past contributions and investment growth)."
												] }) })
											}),
											placement: "right top",
											style: { ...styles.tooltip },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
												height: 12,
												width: 12,
												cursor: "pointer",
												style: { marginLeft: 4 }
											})
										})
									]
								}),
								useCustomGrowth && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										marginLeft: 24,
										paddingLeft: 12,
										borderLeft: `3px solid ${theme.tableBorder}`
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
										style: { marginBottom: 12 },
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
											style: {
												fontWeight: 600,
												marginBottom: 8
											},
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
												style: {
													flexDirection: "row",
													alignItems: "center",
													justifyContent: "space-between"
												},
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: t("Expected return (annual %)") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
													content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
														style: { maxWidth: 300 },
														children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "The expected annual return rate for your investments, used to project growth of Income Accounts." }) })
													}),
													placement: "right top",
													style: { ...styles.tooltip },
													children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
														height: 12,
														width: 12,
														cursor: "pointer"
													})
												})]
											})
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
											type: "number",
											min: 0,
											max: 100,
											step: .1,
											value: estimatedReturn === null ? "" : Number((estimatedReturn * 100).toFixed(2)),
											onChange: (e_2) => setEstimatedReturn(isNaN(e_2.target.valueAsNumber) ? null : e_2.target.valueAsNumber / 100),
											onBlur: () => {
												if (estimatedReturn === null) setEstimatedReturn(0);
											},
											style: { width: 120 }
										})]
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
										style: { marginBottom: 12 },
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
											style: {
												fontWeight: 600,
												marginBottom: 8
											},
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
												style: {
													flexDirection: "row",
													alignItems: "center",
													justifyContent: "space-between"
												},
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expected monthly contribution" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
													content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
														style: { maxWidth: 300 },
														children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "The amount you plan to contribute to your Income Accounts each month. This amount is added to your balance each month before applying the investment return." }) })
													}),
													placement: "right top",
													style: { ...styles.tooltip },
													children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQuestion, {
														height: 12,
														width: 12,
														cursor: "pointer"
													})
												})]
											})
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
											type: "number",
											min: 0,
											step: 100,
											value: expectedContribution === null ? "" : expectedContribution / 100,
											onChange: (e_3) => setExpectedContribution(isNaN(e_3.target.valueAsNumber) ? null : e_3.target.valueAsNumber * 100),
											onBlur: () => {
												if (expectedContribution === null) setExpectedContribution(0);
											},
											style: { width: 120 }
										})]
									})]
								}),
								!useCustomGrowth && historicalReturn != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
									style: {
										fontSize: 12,
										color: theme.pageTextSubdued,
										marginLeft: 24
									},
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
										"Using calculated historical return of",
										" ",
										(historicalReturn * 100).toFixed(1),
										"%"
									] })
								})
							]
						})
					]
				})
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: t30,
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: t31,
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: t32,
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									style: t33,
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
										t34,
										":",
										" ",
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: yearsToRetire != null ? t("{{years}} years", { years: format$8(yearsToRetire, "number") }) : t("N/A") })
									] })
								}),
								t38,
								t46
							]
						})
					}),
					t50,
					t53
				]
			})]
		})]
	});
}
function _temp7$4(c_4) {
	return c_4.id;
}
function _temp6$5(c_2) {
	return c_2.id;
}
function _temp5$5(a_0) {
	return a_0.id;
}
function _temp4$6(c_1) {
	return !c_1.is_income;
}
function _temp3$9(a) {
	return a.id;
}
function _temp2$11(c) {
	return !c.is_income;
}
function _temp$17(group) {
	return !group.is_income;
}
//#endregion
//#region src/components/reports/graphs/adjustTextSize.ts
var adjustTextSize = ({ sized, type, values = 0 }) => {
	let source = [{
		size: -1,
		font: -1
	}];
	switch (type) {
		case "variable":
			const findLookup = variableLookup.find(({ value }) => values >= value);
			if (!findLookup) break;
			source = findLookup.arr;
			break;
		case "donut":
			source = donutLookup;
			break;
		default: source = defaultLookup;
	}
	const findSource = source.find(({ size }) => sized >= size);
	if (!findSource) return "13px";
	return `${findSource.font}px`;
};
var defaultLookup = [
	{
		size: 600,
		font: 16
	},
	{
		size: 500,
		font: 15
	},
	{
		size: 400,
		font: 14
	},
	{
		size: 300,
		font: 13
	},
	{
		size: 200,
		font: 12
	},
	{
		size: 100,
		font: 11
	},
	{
		size: 0,
		font: 10
	}
];
var donutLookup = [
	{
		size: 300,
		font: 20
	},
	{
		size: 266,
		font: 18
	},
	{
		size: 233,
		font: 16
	},
	{
		size: 200,
		font: 14
	},
	{
		size: 166,
		font: 12
	},
	{
		size: 0,
		font: 10
	}
];
var variableLookup = [
	{
		value: 1e4,
		arr: [
			{
				size: 66,
				font: 16
			},
			{
				size: 60,
				font: 15
			},
			{
				size: 54,
				font: 14
			},
			{
				size: 48,
				font: 13
			},
			{
				size: 42,
				font: 12
			},
			{
				size: 36,
				font: 11
			},
			{
				size: 0,
				font: 10
			}
		]
	},
	{
		value: 1e3,
		arr: [
			{
				size: 55,
				font: 16
			},
			{
				size: 50,
				font: 15
			},
			{
				size: 45,
				font: 14
			},
			{
				size: 40,
				font: 13
			},
			{
				size: 35,
				font: 12
			},
			{
				size: 30,
				font: 11
			},
			{
				size: 0,
				font: 10
			}
		]
	},
	{
		value: 100,
		arr: [
			{
				size: 38,
				font: 16
			},
			{
				size: 35,
				font: 15
			},
			{
				size: 32,
				font: 14
			},
			{
				size: 29,
				font: 13
			},
			{
				size: 26,
				font: 12
			},
			{
				size: 23,
				font: 11
			},
			{
				size: 0,
				font: 10
			}
		]
	},
	{
		value: 0,
		arr: [
			{
				size: 25,
				font: 16
			},
			{
				size: 22,
				font: 15
			},
			{
				size: 19,
				font: 14
			},
			{
				size: 16,
				font: 13
			},
			{
				size: 13,
				font: 12
			},
			{
				size: 9,
				font: 11
			},
			{
				size: 0,
				font: 10
			}
		]
	}
];
//#endregion
//#region src/components/reports/graphs/renderCustomLabel.tsx
var renderCustomLabel = (calcX, calcY, textAnchor, display, textSize, showLabel, showLabelThreshold, fill = theme.pageText) => {
	return !showLabel || Math.abs(showLabel) > showLabelThreshold ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
		as: "text",
		x: calcX,
		y: calcY,
		fill,
		textAnchor,
		dominantBaseline: "middle",
		fontSize: textSize,
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: display })
	}, fill + display) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {});
};
//#endregion
//#region src/components/reports/graphs/AreaGraph.tsx
var CustomTooltip$5 = (t0) => {
	const $ = (0, import_compiler_runtime.c)(44);
	const { active, payload, balanceTypeOp, format } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		let t2;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t2 = { marginBottom: 10 };
			$[0] = t1;
			$[1] = t2;
		} else {
			t1 = $[0];
			t2 = $[1];
		}
		let t3;
		if ($[2] !== payload[0].payload.date) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
			});
			$[2] = payload[0].payload.date;
			$[3] = t3;
		} else t3 = $[3];
		let t4;
		if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = { lineHeight: 1.5 };
			$[4] = t4;
		} else t4 = $[4];
		let t5;
		if ($[5] !== balanceTypeOp || $[6] !== format || $[7] !== payload[0].payload.totalAssets || $[8] !== t) {
			t5 = [
				"totalAssets",
				"totalTotals",
				"totalBudgeted"
			].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Assets:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.totalAssets, "financial") })
			});
			$[5] = balanceTypeOp;
			$[6] = format;
			$[7] = payload[0].payload.totalAssets;
			$[8] = t;
			$[9] = t5;
		} else t5 = $[9];
		let t6;
		if ($[10] !== balanceTypeOp || $[11] !== format || $[12] !== payload[0].payload.totalDebts || $[13] !== t) {
			t6 = [
				"totalDebts",
				"totalTotals",
				"totalBudgeted"
			].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Debts:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.totalDebts, "financial") })
			});
			$[10] = balanceTypeOp;
			$[11] = format;
			$[12] = payload[0].payload.totalDebts;
			$[13] = t;
			$[14] = t6;
		} else t6 = $[14];
		let t7;
		if ($[15] !== balanceTypeOp || $[16] !== format || $[17] !== payload[0].payload.netAssets || $[18] !== t) {
			t7 = ["netAssets"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Net Assets:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.netAssets, "financial") })
			});
			$[15] = balanceTypeOp;
			$[16] = format;
			$[17] = payload[0].payload.netAssets;
			$[18] = t;
			$[19] = t7;
		} else t7 = $[19];
		let t8;
		if ($[20] !== balanceTypeOp || $[21] !== format || $[22] !== payload[0].payload.netDebts || $[23] !== t) {
			t8 = ["netDebts"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Net Debts:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.netDebts, "financial") })
			});
			$[20] = balanceTypeOp;
			$[21] = format;
			$[22] = payload[0].payload.netDebts;
			$[23] = t;
			$[24] = t8;
		} else t8 = $[24];
		let t9;
		if ($[25] !== balanceTypeOp || $[26] !== format || $[27] !== payload[0].payload.totalBudgeted || $[28] !== payload[0].payload.totalTotals || $[29] !== t) {
			t9 = ["totalTotals", "totalBudgeted"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: balanceTypeOp === "totalBudgeted" ? t("Budgeted:") : t("Net:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					as: "strong",
					children: format(balanceTypeOp === "totalBudgeted" ? payload[0].payload.totalBudgeted : payload[0].payload.totalTotals, "financial")
				})
			});
			$[25] = balanceTypeOp;
			$[26] = format;
			$[27] = payload[0].payload.totalBudgeted;
			$[28] = payload[0].payload.totalTotals;
			$[29] = t;
			$[30] = t9;
		} else t9 = $[30];
		let t10;
		if ($[31] !== t5 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8 || $[35] !== t9) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t4,
				children: [
					t5,
					t6,
					t7,
					t8,
					t9
				]
			});
			$[31] = t5;
			$[32] = t6;
			$[33] = t7;
			$[34] = t8;
			$[35] = t9;
			$[36] = t10;
		} else t10 = $[36];
		let t11;
		if ($[37] !== t10 || $[38] !== t3) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t3, t10] });
			$[37] = t10;
			$[38] = t3;
			$[39] = t11;
		} else t11 = $[39];
		let t12;
		if ($[40] !== t1 || $[41] !== t11) {
			t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t1,
				children: t11
			});
			$[40] = t1;
			$[41] = t11;
			$[42] = t12;
		} else t12 = $[42];
		return t12;
	}
	let t1;
	if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {});
		$[43] = t1;
	} else t1 = $[43];
	return t1;
};
var customLabel$3 = ({ props, width, end, format }) => {
	return renderCustomLabel((typeof props.x === "number" ? props.x : 0) + (props.index === end ? -10 : props.index === 0 ? 5 : 0), (typeof props.y === "number" ? props.y : 0) - ((typeof props.value === "number" ? props.value : 0) > 0 ? 10 : -10), props.index === 0 ? "start" : "middle", typeof props.value === "number" && props.value !== 0 ? `${format(props.value, "financial-no-decimals")}` : "", adjustTextSize({
		sized: width,
		type: "area"
	}));
};
function AreaGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(40);
	const { style, data, balanceTypeOp, compact, viewLabels, showTooltip: t1 } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const format = useFormat();
	let t2;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = { animationDuration: 1e3 };
		$[0] = t2;
	} else t2 = $[0];
	const animationProps = useRechartsAnimation(t2);
	const privacyMode = usePrivacyMode();
	let t3;
	if ($[1] !== balanceTypeOp || $[2] !== data.intervalData) {
		let t4;
		if ($[4] !== balanceTypeOp) {
			t4 = (i) => i[balanceTypeOp];
			$[4] = balanceTypeOp;
			$[5] = t4;
		} else t4 = $[5];
		t3 = Math.max(...data.intervalData.map(t4));
		$[1] = balanceTypeOp;
		$[2] = data.intervalData;
		$[3] = t3;
	} else t3 = $[3];
	const dataMax = t3;
	let t4;
	if ($[6] !== balanceTypeOp || $[7] !== data.intervalData) {
		let t5;
		if ($[9] !== balanceTypeOp) {
			t5 = (i_0) => i_0[balanceTypeOp];
			$[9] = balanceTypeOp;
			$[10] = t5;
		} else t5 = $[10];
		t4 = Math.min(...data.intervalData.map(t5));
		$[6] = balanceTypeOp;
		$[7] = data.intervalData;
		$[8] = t4;
	} else t4 = $[8];
	const dataMin = t4;
	const labelsMargin = viewLabels ? 30 : 0;
	const dataDiff = dataMax - dataMin;
	const absDataMax = Math.max(Math.abs(dataMax), Math.abs(dataMin));
	const extendRangeAmount = Math.floor(dataDiff / 20);
	const labelsMin = dataMin === 0 || Math.abs(dataMin) <= extendRangeAmount ? 0 : Math.floor((dataMin - extendRangeAmount) / 100) * 100;
	const labelsMax = dataMax === 0 || Math.abs(dataMax) <= extendRangeAmount ? 0 : Math.ceil((dataMax + extendRangeAmount) / 100) * 100;
	const lastLabel = data.intervalData.length - 1;
	let t5;
	if ($[11] !== format || $[12] !== privacyMode) {
		t5 = (tick) => {
			if (!privacyMode) return `${format(tick, "financial-no-decimals")}`;
			return "...";
		};
		$[11] = format;
		$[12] = privacyMode;
		$[13] = t5;
	} else t5 = $[13];
	const tickFormatter = t5;
	let t6;
	if ($[14] !== dataMax || $[15] !== dataMin) {
		t6 = () => {
			if (dataMax <= 0) return 0;
			if (dataMin >= 0) return 1;
			return dataMax / (dataMax - dataMin);
		};
		$[14] = dataMax;
		$[15] = dataMin;
		$[16] = t6;
	} else t6 = $[16];
	const off = t6();
	const leftMargin = Math.abs(absDataMax) > 1e6 ? 20 : 0;
	let t7;
	if ($[17] !== compact) {
		t7 = compact && { height: "auto" };
		$[17] = compact;
		$[18] = t7;
	} else t7 = $[18];
	let t8;
	if ($[19] !== style || $[20] !== t7) {
		t8 = {
			...style,
			...t7
		};
		$[19] = style;
		$[20] = t7;
		$[21] = t8;
	} else t8 = $[21];
	let t9;
	if ($[22] !== animationProps || $[23] !== balanceTypeOp || $[24] !== compact || $[25] !== data.intervalData || $[26] !== format || $[27] !== labelsMargin || $[28] !== labelsMax || $[29] !== labelsMin || $[30] !== lastLabel || $[31] !== leftMargin || $[32] !== off || $[33] !== showTooltip || $[34] !== tickFormatter || $[35] !== viewLabels) {
		t9 = (width, height) => data.intervalData && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AreaChart, {
			responsive: true,
			width,
			height,
			data: data.intervalData,
			margin: {
				top: 0,
				right: labelsMargin,
				left: leftMargin,
				bottom: 10
			},
			children: [
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
					strokeDasharray: "3 3",
					vertical: false
				}),
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "date",
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					dataKey: balanceTypeOp,
					domain: [viewLabels ? labelsMin : "auto", viewLabels ? labelsMax : "auto"],
					tickFormatter,
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText },
					tickSize: 0
				}),
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$5, {
						balanceTypeOp,
						format
					}),
					isAnimationActive: false
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("defs", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
					id: `fill${balanceTypeOp}`,
					x1: "0",
					y1: "0",
					x2: "0",
					y2: "1",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: off,
						stopColor: theme.reportsNumberPositive,
						stopOpacity: .2
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: off,
						stopColor: theme.reportsNumberNegative,
						stopOpacity: .2
					})]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
					id: `stroke${balanceTypeOp}`,
					x1: "0",
					y1: "0",
					x2: "0",
					y2: "1",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: off,
						stopColor: theme.reportsNumberPositive,
						stopOpacity: 1
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: off,
						stopColor: theme.reportsNumberNegative,
						stopOpacity: 1
					})]
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
					type: "linear",
					dot: false,
					activeDot: false,
					...animationProps,
					dataKey: balanceTypeOp,
					stroke: `url(#stroke${balanceTypeOp})`,
					fill: `url(#fill${balanceTypeOp})`,
					fillOpacity: 1,
					children: viewLabels && !compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelList, {
						dataKey: balanceTypeOp,
						content: (props) => customLabel$3({
							props,
							width,
							end: lastLabel,
							format
						})
					})
				})
			]
		})] });
		$[22] = animationProps;
		$[23] = balanceTypeOp;
		$[24] = compact;
		$[25] = data.intervalData;
		$[26] = format;
		$[27] = labelsMargin;
		$[28] = labelsMax;
		$[29] = labelsMin;
		$[30] = lastLabel;
		$[31] = leftMargin;
		$[32] = off;
		$[33] = showTooltip;
		$[34] = tickFormatter;
		$[35] = viewLabels;
		$[36] = t9;
	} else t9 = $[36];
	let t10;
	if ($[37] !== t8 || $[38] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t8,
			children: t9
		});
		$[37] = t8;
		$[38] = t9;
		$[39] = t10;
	} else t10 = $[39];
	return t10;
}
//#endregion
//#region src/components/reports/numberFormatter.ts
var numberFormatterTooltip = (value) => {
	if (typeof value === "number") return Math.round(value);
	return null;
};
//#endregion
//#region src/components/reports/graphs/showActivity.ts
function showActivity({ navigate, categories, accounts, balanceTypeOp, filters, showHiddenCategories, showOffBudget, type, startDate, endDate, field, id, interval = "Day" }) {
	const isOutFlow = balanceTypeOp === "totalDebts" || type === "debts" ? true : false;
	const hiddenCategories = categories.list.filter((f) => f.hidden).map((e) => e.id);
	const offBudgetAccounts = accounts.filter((f) => f.offbudget).map((e) => e.id);
	const fromDate = interval === "Weekly" ? "dayFromDate" : (ReportOptions.intervalMap.get(interval) || "Day").toLowerCase() + "FromDate";
	const isDateOp = interval === "Weekly" || type !== "time";
	const filterConditions = [
		...filters,
		id && {
			field,
			op: Array.isArray(id) ? "oneOf" : "is",
			value: id,
			type: "id"
		},
		{
			field: "date",
			op: isDateOp ? "gte" : "is",
			value: isDateOp ? startDate : months_exports[fromDate](startDate),
			type: "date"
		},
		isDateOp && {
			field: "date",
			op: "lte",
			value: endDate,
			options: { date: true }
		},
		!(["netAssets", "netDebts"].includes(balanceTypeOp) || ["totalTotals", "totalBudgeted"].includes(balanceTypeOp) && (type === "totals" || type === "time")) && {
			field: "amount",
			op: "gte",
			value: 0,
			options: {
				type: "number",
				inflow: !isOutFlow,
				outflow: isOutFlow
			}
		},
		hiddenCategories.length > 0 && !showHiddenCategories && {
			field: "category",
			op: "notOneOf",
			value: hiddenCategories,
			type: "id"
		},
		offBudgetAccounts.length > 0 && !showOffBudget && {
			field: "account",
			op: "notOneOf",
			value: offBudgetAccounts,
			type: "id"
		}
	].filter((f) => f);
	navigate(balanceTypeOp === "totalBudgeted" ? "/budget" : "/accounts", { state: balanceTypeOp === "totalBudgeted" ? { goBack: true } : {
		goBack: true,
		filterConditions
	} });
}
//#endregion
//#region src/components/reports/graphs/BarGraph.tsx
var CustomTooltip$4 = (t0) => {
	const $ = (0, import_compiler_runtime.c)(43);
	const { active, payload, balanceTypeOp, yAxis, format } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		let t2;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t2 = { marginBottom: 10 };
			$[0] = t1;
			$[1] = t2;
		} else {
			t1 = $[0];
			t2 = $[1];
		}
		const t3 = payload[0].payload[yAxis];
		let t4;
		if ($[2] !== t3) {
			t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t3 })
			});
			$[2] = t3;
			$[3] = t4;
		} else t4 = $[3];
		let t5;
		if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
			t5 = { lineHeight: 1.5 };
			$[4] = t5;
		} else t5 = $[4];
		let t6;
		if ($[5] !== balanceTypeOp || $[6] !== format || $[7] !== payload[0].payload.totalAssets || $[8] !== t) {
			t6 = [
				"totalAssets",
				"totalTotals",
				"totalBudgeted"
			].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Assets:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.totalAssets, "financial") })
			});
			$[5] = balanceTypeOp;
			$[6] = format;
			$[7] = payload[0].payload.totalAssets;
			$[8] = t;
			$[9] = t6;
		} else t6 = $[9];
		let t7;
		if ($[10] !== balanceTypeOp || $[11] !== format || $[12] !== payload[0].payload.totalDebts || $[13] !== t) {
			t7 = [
				"totalDebts",
				"totalTotals",
				"totalBudgeted"
			].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Debts:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.totalDebts, "financial") })
			});
			$[10] = balanceTypeOp;
			$[11] = format;
			$[12] = payload[0].payload.totalDebts;
			$[13] = t;
			$[14] = t7;
		} else t7 = $[14];
		let t8;
		if ($[15] !== balanceTypeOp || $[16] !== format || $[17] !== payload[0].payload.netAssets || $[18] !== t) {
			t8 = ["netAssets"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Net Assets:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.netAssets, "financial") })
			});
			$[15] = balanceTypeOp;
			$[16] = format;
			$[17] = payload[0].payload.netAssets;
			$[18] = t;
			$[19] = t8;
		} else t8 = $[19];
		let t9;
		if ($[20] !== balanceTypeOp || $[21] !== format || $[22] !== payload[0].payload.netDebts || $[23] !== t) {
			t9 = ["netDebts"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Net Debts:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.netDebts, "financial") })
			});
			$[20] = balanceTypeOp;
			$[21] = format;
			$[22] = payload[0].payload.netDebts;
			$[23] = t;
			$[24] = t9;
		} else t9 = $[24];
		let t10;
		if ($[25] !== balanceTypeOp || $[26] !== format || $[27] !== payload[0].payload.totalBudgeted || $[28] !== payload[0].payload.totalTotals || $[29] !== t) {
			t10 = ["totalTotals", "totalBudgeted"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: balanceTypeOp === "totalBudgeted" ? t("Budgeted:") : t("Net:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					as: "strong",
					children: format(balanceTypeOp === "totalBudgeted" ? payload[0].payload.totalBudgeted : payload[0].payload.totalTotals, "financial")
				})
			});
			$[25] = balanceTypeOp;
			$[26] = format;
			$[27] = payload[0].payload.totalBudgeted;
			$[28] = payload[0].payload.totalTotals;
			$[29] = t;
			$[30] = t10;
		} else t10 = $[30];
		let t11;
		if ($[31] !== t10 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8 || $[35] !== t9) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t5,
				children: [
					t6,
					t7,
					t8,
					t9,
					t10
				]
			});
			$[31] = t10;
			$[32] = t6;
			$[33] = t7;
			$[34] = t8;
			$[35] = t9;
			$[36] = t11;
		} else t11 = $[36];
		let t12;
		if ($[37] !== t11 || $[38] !== t4) {
			t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t4, t11] });
			$[37] = t11;
			$[38] = t4;
			$[39] = t12;
		} else t12 = $[39];
		let t13;
		if ($[40] !== t1 || $[41] !== t12) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t1,
				children: t12
			});
			$[40] = t1;
			$[41] = t12;
			$[42] = t13;
		} else t13 = $[42];
		return t13;
	}
};
var customLabel$2 = (props, typeOp, format) => {
	return renderCustomLabel(props.x + props.width / 2, props.y - (props.value > 0 ? 15 : -15), "middle", props.value !== 0 && `${format(props.value, "financial-no-decimals")}`, adjustTextSize({
		sized: props.width,
		type: typeOp === "totalTotals" || typeOp === "totalBudgeted" ? "default" : "variable",
		values: props.value
	}));
};
function BarGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(42);
	const { style, data, filters, groupBy, balanceTypeOp, compact, viewLabels, showHiddenCategories, showOffBudget, showTooltip: t1 } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const animationProps = useRechartsAnimation();
	const navigate = useNavigate();
	const { data: t2 } = useCategories();
	let t3;
	if ($[0] !== t2) {
		t3 = t2 === void 0 ? {
			grouped: [],
			list: []
		} : t2;
		$[0] = t2;
		$[1] = t3;
	} else t3 = $[1];
	const categories = t3;
	const { data: t4 } = useAccounts();
	let t5;
	if ($[2] !== t4) {
		t5 = t4 === void 0 ? [] : t4;
		$[2] = t4;
		$[3] = t5;
	} else t5 = $[3];
	const accounts = t5;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	const [pointer, setPointer] = (0, import_react.useState)("");
	const yAxis = groupBy === "Interval" ? "date" : "name";
	const splitData = groupBy === "Interval" ? "intervalData" : "data";
	const labelsMargin = viewLabels ? 30 : 0;
	let t6;
	if ($[4] !== balanceTypeOp) {
		t6 = (obj) => {
			if (["totalDebts", "netDebts"].includes(balanceTypeOp)) return -1 * obj[balanceTypeOp];
			return obj[balanceTypeOp];
		};
		$[4] = balanceTypeOp;
		$[5] = t6;
	} else t6 = $[5];
	const getVal = t6;
	const t7 = data[splitData];
	let t8;
	if ($[6] !== t7 || $[7] !== yAxis) {
		let t9;
		if ($[9] !== yAxis) {
			t9 = (c) => c[yAxis];
			$[9] = yAxis;
			$[10] = t9;
		} else t9 = $[10];
		t8 = t7.map(t9).reduce(_temp$16, 0);
		$[6] = t7;
		$[7] = yAxis;
		$[8] = t8;
	} else t8 = $[8];
	const longestLabelLength = t8;
	const largestValue = data[splitData].map((c_0) => c_0[balanceTypeOp]).reduce(_temp2$10, 0);
	const leftMargin = Math.abs(largestValue) > 1e6 ? 20 : 0;
	let t9;
	if ($[11] !== compact) {
		t9 = compact && { height: "auto" };
		$[11] = compact;
		$[12] = t9;
	} else t9 = $[12];
	let t10;
	if ($[13] !== style || $[14] !== t9) {
		t10 = {
			...style,
			...t9
		};
		$[13] = style;
		$[14] = t9;
		$[15] = t10;
	} else t10 = $[15];
	let t11;
	if ($[16] !== accounts || $[17] !== animationProps || $[18] !== balanceTypeOp || $[19] !== categories || $[20] !== compact || $[21] !== data || $[22] !== filters || $[23] !== format || $[24] !== getVal || $[25] !== groupBy || $[26] !== labelsMargin || $[27] !== leftMargin || $[28] !== longestLabelLength || $[29] !== navigate || $[30] !== pointer || $[31] !== privacyMode || $[32] !== showHiddenCategories || $[33] !== showOffBudget || $[34] !== showTooltip || $[35] !== splitData || $[36] !== viewLabels || $[37] !== yAxis) {
		t11 = (width, height) => data[splitData] && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(BarChart, {
			responsive: true,
			width,
			height,
			stackOffset: "sign",
			data: data[splitData],
			style: { cursor: pointer },
			margin: {
				top: labelsMargin,
				right: 0,
				left: leftMargin,
				bottom: 0
			},
			children: [
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					cursor: { fill: "transparent" },
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$4, {
						balanceTypeOp,
						yAxis,
						format
					}),
					formatter: numberFormatterTooltip,
					isAnimationActive: false
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: yAxis,
					angle: -35,
					height: Math.sqrt(longestLabelLength) * 25,
					tick: {
						fill: theme.pageText,
						textAnchor: "end"
					},
					tickLine: { stroke: theme.pageText }
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					tickFormatter: (value) => getCustomTick(format(value, "financial-no-decimals"), privacyMode),
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText },
					tickSize: 0
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
					y: 0,
					stroke: theme.pageTextLight
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: (val) => getVal(val),
					stackId: "a",
					...animationProps,
					onMouseLeave: () => setPointer(""),
					onMouseEnter: () => !["Group", "Interval"].includes(groupBy) && setPointer("pointer"),
					onClick: (item) => (compact && showTooltip || !compact) && !["Group", "Interval"].includes(groupBy) && showActivity({
						navigate,
						categories,
						accounts,
						balanceTypeOp,
						filters,
						showHiddenCategories,
						showOffBudget,
						type: "totals",
						startDate: data.startDate,
						endDate: data.endDate,
						field: groupBy.toLowerCase(),
						id: item.id
					}),
					shape: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Rectangle, {
						...props,
						fill: data.legend[props.index]?.color ?? props.fill ?? void 0
					}),
					children: viewLabels && !compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelList, {
						dataKey: (val_0) => getVal(val_0),
						content: (e) => customLabel$2(e, balanceTypeOp, format)
					})
				})
			]
		})] });
		$[16] = accounts;
		$[17] = animationProps;
		$[18] = balanceTypeOp;
		$[19] = categories;
		$[20] = compact;
		$[21] = data;
		$[22] = filters;
		$[23] = format;
		$[24] = getVal;
		$[25] = groupBy;
		$[26] = labelsMargin;
		$[27] = leftMargin;
		$[28] = longestLabelLength;
		$[29] = navigate;
		$[30] = pointer;
		$[31] = privacyMode;
		$[32] = showHiddenCategories;
		$[33] = showOffBudget;
		$[34] = showTooltip;
		$[35] = splitData;
		$[36] = viewLabels;
		$[37] = yAxis;
		$[38] = t11;
	} else t11 = $[38];
	let t12;
	if ($[39] !== t10 || $[40] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t10,
			children: t11
		});
		$[39] = t10;
		$[40] = t11;
		$[41] = t12;
	} else t12 = $[41];
	return t12;
}
function _temp2$10(acc_0, cur_0) {
	return Math.abs(cur_0) > Math.abs(acc_0) ? cur_0 : acc_0;
}
function _temp$16(acc, cur) {
	return cur.length > acc ? cur.length : acc;
}
//#endregion
//#region src/components/reports/graphs/BarLineGraph.tsx
var CustomTooltip$3 = (t0) => {
	const $ = (0, import_compiler_runtime.c)(32);
	const { active, payload } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		let t2;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t2 = { marginBottom: 10 };
			$[0] = t1;
			$[1] = t2;
		} else {
			t1 = $[0];
			t2 = $[1];
		}
		let t3;
		if ($[2] !== payload[0].payload.date) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
			});
			$[2] = payload[0].payload.date;
			$[3] = t3;
		} else t3 = $[3];
		let t4;
		if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = { lineHeight: 1.5 };
			$[4] = t4;
		} else t4 = $[4];
		let t5;
		if ($[5] !== t) {
			t5 = t("Assets:");
			$[5] = t;
			$[6] = t5;
		} else t5 = $[6];
		let t6;
		if ($[7] !== payload[0].payload.assets || $[8] !== t5) {
			t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t5,
				right: payload[0].payload.assets
			});
			$[7] = payload[0].payload.assets;
			$[8] = t5;
			$[9] = t6;
		} else t6 = $[9];
		let t7;
		if ($[10] !== t) {
			t7 = t("Debt:");
			$[10] = t;
			$[11] = t7;
		} else t7 = $[11];
		let t8;
		if ($[12] !== payload[0].payload.debt || $[13] !== t7) {
			t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t7,
				right: payload[0].payload.debt
			});
			$[12] = payload[0].payload.debt;
			$[13] = t7;
			$[14] = t8;
		} else t8 = $[14];
		let t9;
		if ($[15] !== t) {
			t9 = t("Change:");
			$[15] = t;
			$[16] = t9;
		} else t9 = $[16];
		let t10;
		if ($[17] !== payload[0].payload.change) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.change });
			$[17] = payload[0].payload.change;
			$[18] = t10;
		} else t10 = $[18];
		let t11;
		if ($[19] !== t10 || $[20] !== t9) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t9,
				right: t10
			});
			$[19] = t10;
			$[20] = t9;
			$[21] = t11;
		} else t11 = $[21];
		let t12;
		if ($[22] !== t11 || $[23] !== t6 || $[24] !== t8) {
			t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t4,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PrivacyFilter, { children: [
					t6,
					t8,
					t11
				] })
			});
			$[22] = t11;
			$[23] = t6;
			$[24] = t8;
			$[25] = t12;
		} else t12 = $[25];
		let t13;
		if ($[26] !== t12 || $[27] !== t3) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t3, t12] });
			$[26] = t12;
			$[27] = t3;
			$[28] = t13;
		} else t13 = $[28];
		let t14;
		if ($[29] !== t1 || $[30] !== t13) {
			t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t1,
				children: t13
			});
			$[29] = t1;
			$[30] = t13;
			$[31] = t14;
		} else t14 = $[31];
		return t14;
	}
};
function BarLineGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(16);
	const { style, data, compact, showTooltip: t1 } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const format = useFormat();
	const animationProps = useRechartsAnimation();
	let t2;
	if ($[0] !== format) {
		t2 = (tick) => `${format(Math.round(tick), "financial")}`;
		$[0] = format;
		$[1] = t2;
	} else t2 = $[1];
	const tickFormatter = t2;
	let t3;
	if ($[2] !== compact) {
		t3 = compact && { height: "auto" };
		$[2] = compact;
		$[3] = t3;
	} else t3 = $[3];
	let t4;
	if ($[4] !== style || $[5] !== t3) {
		t4 = {
			...style,
			...t3
		};
		$[4] = style;
		$[5] = t3;
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== animationProps || $[8] !== compact || $[9] !== data || $[10] !== showTooltip || $[11] !== tickFormatter) {
		t5 = (width, height) => data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ComposedChart, {
			responsive: true,
			width,
			height,
			data: data.data,
			margin: {
				top: 0,
				right: 0,
				left: 0,
				bottom: 0
			},
			children: [
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$3, {}),
					formatter: numberFormatterTooltip,
					isAnimationActive: false
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, { dataKey: "x" }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					dataKey: "y",
					tickFormatter
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					type: "monotone",
					dataKey: "y",
					fill: "#8884d8",
					...animationProps
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					type: "monotone",
					dataKey: "y",
					stroke: "#8884d8",
					...animationProps
				})
			]
		})] });
		$[7] = animationProps;
		$[8] = compact;
		$[9] = data;
		$[10] = showTooltip;
		$[11] = tickFormatter;
		$[12] = t5;
	} else t5 = $[12];
	let t6;
	if ($[13] !== t4 || $[14] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t4,
			children: t5
		});
		$[13] = t4;
		$[14] = t5;
		$[15] = t6;
	} else t6 = $[15];
	return t6;
}
//#endregion
//#region src/components/reports/graphs/DonutGraph.tsx
var RADIAN = Math.PI / 180;
var canDeviceHover = () => window.matchMedia("(hover: hover)").matches;
var getDonutDimensions = (width, height, twoRings) => {
	const minDim = Math.min(width, height);
	const compact = height <= 300 || width <= 300;
	return {
		chartInnerRadius: minDim * (twoRings && compact ? .16 : .2),
		chartMidRadius: minDim * (compact ? .27 : .31),
		chartOuterRadius: minDim * (compact ? .36 : .42),
		compact
	};
};
var resolveCSSVariable = (color) => {
	if (!color.startsWith("var(")) return color;
	const varName = color.slice(4, -1).trim().split(",")[0].trim();
	return getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
};
var hexToRgb = (hex) => {
	const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
	return result ? {
		r: parseInt(result[1], 16),
		g: parseInt(result[2], 16),
		b: parseInt(result[3], 16)
	} : {
		r: 0,
		g: 0,
		b: 0
	};
};
var shadeColor = (resolvedHex, percent) => {
	const { r, g, b } = hexToRgb(resolvedHex);
	const adjust = (c) => Math.min(255, Math.max(0, Math.round(c + (255 - c) * percent)));
	return `rgb(${adjust(r)}, ${adjust(g)}, ${adjust(b)})`;
};
var buildColorMap = (groupedData, legend) => {
	const legendById = new Map(legend.filter((l) => l.id != null).map((l) => [l.id, resolveCSSVariable(l.color)]));
	return groupedData.reduce((acc, group) => {
		if (!group.id) return acc;
		const groupColor = legendById.get(group.id);
		if (!groupColor) return acc;
		acc.set(group.id, groupColor);
		const cats = group.categories ?? [];
		cats.forEach((cat, i) => {
			if (!cat.id) return;
			const shade = .15 + i / Math.max(cats.length, 1) * .5;
			acc.set(cat.id, shadeColor(groupColor, shade));
		});
		return acc;
	}, /* @__PURE__ */ new Map());
};
var ActiveShapeMobile = (t0) => {
	const $ = (0, import_compiler_runtime.c)(43);
	const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill, payload, percent, value, expandInward, chartInnerRadius, chartOuterRadius } = t0;
	const format = useFormat();
	const yAxis = payload.name ?? payload.date ?? "";
	const expansionInner = expandInward ? chartInnerRadius - 4 : outerRadius + 2;
	const expansionOuter = expandInward ? chartInnerRadius - 2 : outerRadius + 4;
	const ey = cy + chartOuterRadius * Math.sin(-RADIAN * 240) - 5;
	const t1 = cy + chartOuterRadius * Math.sin(-RADIAN * 270) + 17;
	let t2;
	if ($[0] !== cx || $[1] !== fill || $[2] !== t1 || $[3] !== yAxis) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
			x: cx,
			y: t1,
			textAnchor: "middle",
			fill,
			children: yAxis
		});
		$[0] = cx;
		$[1] = fill;
		$[2] = t1;
		$[3] = yAxis;
		$[4] = t2;
	} else t2 = $[4];
	const t3 = cx + chartOuterRadius * Math.cos(-RADIAN * 240) - 30;
	let t4;
	if ($[5] !== format || $[6] !== value) {
		t4 = format(value, "financial");
		$[5] = format;
		$[6] = value;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== ey || $[9] !== fill || $[10] !== t3 || $[11] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
			as: "text",
			x: t3,
			y: ey,
			textAnchor: "end",
			fill,
			children: t4
		});
		$[8] = ey;
		$[9] = fill;
		$[10] = t3;
		$[11] = t4;
		$[12] = t5;
	} else t5 = $[12];
	const t6 = cx + chartOuterRadius * Math.cos(-RADIAN * 330) + 10;
	const t7 = percent * 100;
	let t8;
	if ($[13] !== t7) {
		t8 = t7.toFixed(2);
		$[13] = t7;
		$[14] = t8;
	} else t8 = $[14];
	const t9 = `${t8}%`;
	let t10;
	if ($[15] !== ey || $[16] !== t6 || $[17] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
			x: t6,
			y: ey,
			textAnchor: "start",
			fill: "#999",
			children: t9
		});
		$[15] = ey;
		$[16] = t6;
		$[17] = t9;
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== t10 || $[20] !== t5) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PrivacyFilter, { children: [t5, t10] });
		$[19] = t10;
		$[20] = t5;
		$[21] = t11;
	} else t11 = $[21];
	let t12;
	if ($[22] !== cx || $[23] !== cy || $[24] !== endAngle || $[25] !== fill || $[26] !== innerRadius || $[27] !== outerRadius || $[28] !== startAngle) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
			cx,
			cy,
			innerRadius,
			outerRadius,
			startAngle,
			endAngle,
			fill
		});
		$[22] = cx;
		$[23] = cy;
		$[24] = endAngle;
		$[25] = fill;
		$[26] = innerRadius;
		$[27] = outerRadius;
		$[28] = startAngle;
		$[29] = t12;
	} else t12 = $[29];
	let t13;
	if ($[30] !== cx || $[31] !== cy || $[32] !== endAngle || $[33] !== expansionInner || $[34] !== expansionOuter || $[35] !== fill || $[36] !== startAngle) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
			cx,
			cy,
			startAngle,
			endAngle,
			innerRadius: expansionInner,
			outerRadius: expansionOuter,
			fill
		});
		$[30] = cx;
		$[31] = cy;
		$[32] = endAngle;
		$[33] = expansionInner;
		$[34] = expansionOuter;
		$[35] = fill;
		$[36] = startAngle;
		$[37] = t13;
	} else t13 = $[37];
	let t14;
	if ($[38] !== t11 || $[39] !== t12 || $[40] !== t13 || $[41] !== t2) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
			t2,
			t11,
			t12,
			t13
		] });
		$[38] = t11;
		$[39] = t12;
		$[40] = t13;
		$[41] = t2;
		$[42] = t14;
	} else t14 = $[42];
	return t14;
};
var ActiveShapeDesktop = (t0) => {
	const $ = (0, import_compiler_runtime.c)(55);
	const { cx, cy, midAngle, innerRadius, outerRadius, startAngle, endAngle, fill, payload, percent, value, expandInward, chartInnerRadius } = t0;
	const format = useFormat();
	const yAxis = payload.name ?? payload.date ?? "";
	const sin = Math.sin(-RADIAN * midAngle);
	const cos = Math.cos(-RADIAN * midAngle);
	const expansionInner = expandInward ? chartInnerRadius - 10 : outerRadius + 6;
	const expansionOuter = expandInward ? chartInnerRadius - 6 : outerRadius + 10;
	const lineStart = expandInward ? chartInnerRadius - 20 : chartInnerRadius - 10;
	const lineMid = chartInnerRadius * .7;
	const sx = cx + lineStart * cos;
	const sy = cy + lineStart * sin;
	const mx = cx + lineMid * cos;
	const my = cy + lineMid * sin;
	const ex = cx + (cos >= 0 ? 1 : -1) * yAxis.length * 4;
	const ey = cy + 8;
	const textAnchor = cos <= 0 ? "start" : "end";
	const labelX = ex + (cos <= 0 ? 1 : -1) * 16;
	let t1;
	if ($[0] !== cx || $[1] !== cy || $[2] !== endAngle || $[3] !== fill || $[4] !== innerRadius || $[5] !== outerRadius || $[6] !== startAngle) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
			cx,
			cy,
			innerRadius,
			outerRadius,
			startAngle,
			endAngle,
			fill
		});
		$[0] = cx;
		$[1] = cy;
		$[2] = endAngle;
		$[3] = fill;
		$[4] = innerRadius;
		$[5] = outerRadius;
		$[6] = startAngle;
		$[7] = t1;
	} else t1 = $[7];
	let t2;
	if ($[8] !== cx || $[9] !== cy || $[10] !== endAngle || $[11] !== expansionInner || $[12] !== expansionOuter || $[13] !== fill || $[14] !== startAngle) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
			cx,
			cy,
			startAngle,
			endAngle,
			innerRadius: expansionInner,
			outerRadius: expansionOuter,
			fill
		});
		$[8] = cx;
		$[9] = cy;
		$[10] = endAngle;
		$[11] = expansionInner;
		$[12] = expansionOuter;
		$[13] = fill;
		$[14] = startAngle;
		$[15] = t2;
	} else t2 = $[15];
	const t3 = `M${sx},${sy}L${mx},${my}L${ex},${ey}`;
	let t4;
	if ($[16] !== fill || $[17] !== t3) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
			d: t3,
			stroke: fill,
			fill: "none"
		});
		$[16] = fill;
		$[17] = t3;
		$[18] = t4;
	} else t4 = $[18];
	let t5;
	if ($[19] !== ex || $[20] !== ey || $[21] !== fill) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
			cx: ex,
			cy: ey,
			r: 3,
			fill,
			stroke: "none"
		});
		$[19] = ex;
		$[20] = ey;
		$[21] = fill;
		$[22] = t5;
	} else t5 = $[22];
	let t6;
	if ($[23] !== ey || $[24] !== fill || $[25] !== labelX || $[26] !== textAnchor || $[27] !== yAxis) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
			x: labelX,
			y: ey,
			textAnchor,
			fill,
			children: yAxis
		});
		$[23] = ey;
		$[24] = fill;
		$[25] = labelX;
		$[26] = textAnchor;
		$[27] = yAxis;
		$[28] = t6;
	} else t6 = $[28];
	let t7;
	if ($[29] !== format || $[30] !== value) {
		t7 = format(value, "financial");
		$[29] = format;
		$[30] = value;
		$[31] = t7;
	} else t7 = $[31];
	let t8;
	if ($[32] !== ey || $[33] !== fill || $[34] !== labelX || $[35] !== t7 || $[36] !== textAnchor) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
			as: "text",
			x: labelX,
			y: ey,
			dy: 18,
			textAnchor,
			fill,
			children: t7
		});
		$[32] = ey;
		$[33] = fill;
		$[34] = labelX;
		$[35] = t7;
		$[36] = textAnchor;
		$[37] = t8;
	} else t8 = $[37];
	const t9 = percent * 100;
	let t10;
	if ($[38] !== t9) {
		t10 = t9.toFixed(2);
		$[38] = t9;
		$[39] = t10;
	} else t10 = $[39];
	const t11 = `(${t10}%)`;
	let t12;
	if ($[40] !== ey || $[41] !== labelX || $[42] !== t11 || $[43] !== textAnchor) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
			x: labelX,
			y: ey,
			dy: 36,
			textAnchor,
			fill: "#999",
			children: t11
		});
		$[40] = ey;
		$[41] = labelX;
		$[42] = t11;
		$[43] = textAnchor;
		$[44] = t12;
	} else t12 = $[44];
	let t13;
	if ($[45] !== t12 || $[46] !== t8) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PrivacyFilter, { children: [t8, t12] });
		$[45] = t12;
		$[46] = t8;
		$[47] = t13;
	} else t13 = $[47];
	let t14;
	if ($[48] !== t1 || $[49] !== t13 || $[50] !== t2 || $[51] !== t4 || $[52] !== t5 || $[53] !== t6) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
			t1,
			t2,
			t4,
			t5,
			t6,
			t13
		] });
		$[48] = t1;
		$[49] = t13;
		$[50] = t2;
		$[51] = t4;
		$[52] = t5;
		$[53] = t6;
		$[54] = t14;
	} else t14 = $[54];
	return t14;
};
var customLabel$1 = (props) => {
	const radius = props.innerRadius + (props.outerRadius - props.innerRadius) * .5;
	const size = props.cx > props.cy ? props.cy : props.cx;
	const calcX = props.cx + radius * Math.cos(-props.midAngle * RADIAN);
	const calcY = props.cy + radius * Math.sin(-props.midAngle * RADIAN);
	const textAnchor = calcX > props.cx ? "start" : "end";
	const display = props.value !== 0 && `${(props.percent * 100).toFixed(0)}%`;
	const textSize = adjustTextSize({
		sized: size,
		type: "donut"
	});
	const showLabel = props.percent;
	const showLabelThreshold = .05;
	const fill = theme.reportsInnerLabel;
	return renderCustomLabel(calcX, calcY, textAnchor, display, textSize, showLabel, showLabelThreshold, fill);
};
function DonutGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(50);
	const { style, data, filters, groupBy, balanceTypeOp, viewLabels, showHiddenCategories, showOffBudget, showTooltip: t1 } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	let t2;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = { animationDuration: 500 };
		$[0] = t2;
	} else t2 = $[0];
	const animationProps = useRechartsAnimation(t2);
	const yAxis = groupBy === "Interval" ? "date" : "name";
	const splitData = groupBy === "Interval" ? "intervalData" : "data";
	const navigate = useNavigate();
	const { data: t3 } = useCategories();
	let t4;
	if ($[1] !== t3) {
		t4 = t3 === void 0 ? {
			grouped: [],
			list: []
		} : t3;
		$[1] = t3;
		$[2] = t4;
	} else t4 = $[2];
	const categories = t4;
	const { data: t5 } = useAccounts();
	let t6;
	if ($[3] !== t5) {
		t6 = t5 === void 0 ? [] : t5;
		$[3] = t5;
		$[4] = t6;
	} else t6 = $[4];
	const accounts = t6;
	const [pointer, setPointer] = (0, import_react.useState)("");
	let t7;
	if ($[5] !== balanceTypeOp) {
		t7 = (obj) => {
			if (["totalDebts", "netDebts"].includes(balanceTypeOp)) return -1 * obj[balanceTypeOp];
			return obj[balanceTypeOp];
		};
		$[5] = balanceTypeOp;
		$[6] = t7;
	} else t7 = $[6];
	const getVal = t7;
	const [activeIndex, setActiveIndex] = (0, import_react.useState)(0);
	const [activeGroupIndex, setActiveGroupIndex] = (0, import_react.useState)(0);
	const [activeCategoryIndex, setActiveCategoryIndex] = (0, import_react.useState)(0);
	const [activeRing, setActiveRing] = (0, import_react.useState)("category");
	const isCategoryGroup = groupBy === "CategoryGroup" && !!data.groupedData?.length;
	let t8;
	bb0: {
		if (!isCategoryGroup || !data.groupedData) {
			let t9;
			if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
				t9 = {
					adjustedGroupData: [],
					flatCategories: []
				};
				$[7] = t9;
			} else t9 = $[7];
			t8 = t9;
			break bb0;
		}
		let t9;
		if ($[8] !== balanceTypeOp || $[9] !== data.groupedData) {
			let t10;
			if ($[11] !== balanceTypeOp) {
				t10 = (group_0) => ["totalDebts", "netDebts"].includes(balanceTypeOp) ? -1 * group_0[balanceTypeOp] !== 0 : group_0[balanceTypeOp] !== 0;
				$[11] = balanceTypeOp;
				$[12] = t10;
			} else t10 = $[12];
			t9 = data.groupedData.map(_temp6$4).filter(t10);
			$[8] = balanceTypeOp;
			$[9] = data.groupedData;
			$[10] = t9;
		} else t9 = $[10];
		const adjustedGroups = t9;
		let t10;
		if ($[13] !== data.groupedData) {
			t10 = data.groupedData.flatMap(_temp7$3);
			$[13] = data.groupedData;
			$[14] = t10;
		} else t10 = $[14];
		let t11;
		if ($[15] !== adjustedGroups || $[16] !== t10) {
			t11 = {
				adjustedGroupData: adjustedGroups,
				flatCategories: t10
			};
			$[15] = adjustedGroups;
			$[16] = t10;
			$[17] = t11;
		} else t11 = $[17];
		t8 = t11;
	}
	const { adjustedGroupData, flatCategories } = t8;
	let t9;
	if ($[18] !== data.groupedData || $[19] !== data.legend || $[20] !== isCategoryGroup) {
		t9 = isCategoryGroup ? buildColorMap(data.groupedData ?? [], data.legend ?? []) : /* @__PURE__ */ new Map();
		$[18] = data.groupedData;
		$[19] = data.legend;
		$[20] = isCategoryGroup;
		$[21] = t9;
	} else t9 = $[21];
	const colorMap = t9;
	let t10;
	if ($[22] !== accounts || $[23] !== activeCategoryIndex || $[24] !== activeGroupIndex || $[25] !== activeIndex || $[26] !== activeRing || $[27] !== adjustedGroupData || $[28] !== animationProps || $[29] !== balanceTypeOp || $[30] !== categories || $[31] !== colorMap || $[32] !== data || $[33] !== filters || $[34] !== flatCategories || $[35] !== getVal || $[36] !== groupBy || $[37] !== isCategoryGroup || $[38] !== navigate || $[39] !== pointer || $[40] !== showHiddenCategories || $[41] !== showOffBudget || $[42] !== showTooltip || $[43] !== splitData || $[44] !== viewLabels || $[45] !== yAxis) {
		t10 = (width, height) => {
			const { chartInnerRadius, chartMidRadius, chartOuterRadius, compact } = getDonutDimensions(width, height, isCategoryGroup);
			const showActiveShape = width >= 220 && height >= 130;
			if (isCategoryGroup) return data.groupedData && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PieChart, {
				responsive: true,
				width,
				height,
				style: { cursor: pointer },
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pie, {
					dataKey: (val) => getVal(val),
					nameKey: "name",
					...animationProps,
					animationBegin: 100,
					data: adjustedGroupData,
					innerRadius: chartInnerRadius,
					outerRadius: chartMidRadius,
					startAngle: 90,
					endAngle: -270,
					shape: (props, index) => {
						const item = adjustedGroupData[index];
						const fill = colorMap.get(item?.id ?? item?.name ?? "") ?? props.fill;
						if (activeRing === "group" && index === activeGroupIndex && showActiveShape) return compact ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeMobile, {
							...props,
							fill,
							expandInward: true,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeDesktop, {
							...props,
							fill,
							expandInward: true,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						});
						return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
							...props,
							fill
						});
					},
					onMouseLeave: () => setPointer(""),
					onMouseEnter: (_, index_0) => {
						if (canDeviceHover()) {
							setActiveGroupIndex(index_0);
							setActiveRing("group");
						}
					},
					onClick: (item_0, index_1) => {
						if (!canDeviceHover()) {
							setActiveGroupIndex(index_1);
							setActiveRing("group");
						}
						if ((canDeviceHover() || activeGroupIndex === index_1) && (compact && showTooltip || !compact)) {
							const groupCategoryIds = (data.groupedData?.find((g_0) => g_0.id === item_0.id)?.categories ?? []).map(_temp8$2).filter(_temp9$1);
							showActivity({
								navigate,
								categories,
								accounts,
								balanceTypeOp,
								filters,
								showHiddenCategories,
								showOffBudget,
								type: "totals",
								startDate: data.startDate,
								endDate: data.endDate,
								field: "category",
								id: groupCategoryIds
							});
						}
					}
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pie, {
					dataKey: (val_0) => getVal(val_0),
					nameKey: "name",
					...animationProps,
					animationBegin: 100,
					data: flatCategories,
					innerRadius: chartMidRadius,
					outerRadius: chartOuterRadius,
					startAngle: 90,
					endAngle: -270,
					labelLine: false,
					label: (e) => viewLabels && !compact ? customLabel$1(e) : null,
					shape: (props_0, index_2) => {
						const item_1 = flatCategories[index_2];
						const fill_0 = colorMap.get(item_1?.id ?? item_1?.name ?? "") ?? props_0.fill;
						if (activeRing === "category" && index_2 === activeCategoryIndex && showActiveShape) return compact ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeMobile, {
							...props_0,
							fill: fill_0,
							expandInward: false,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeDesktop, {
							...props_0,
							fill: fill_0,
							expandInward: false,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						});
						return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
							...props_0,
							fill: fill_0
						});
					},
					onMouseLeave: () => setPointer(""),
					onMouseEnter: (__0, index_3) => {
						if (canDeviceHover()) {
							setActiveCategoryIndex(index_3);
							setActiveRing("category");
							setPointer("pointer");
						}
					},
					onClick: (item_2, index_4) => {
						if (!canDeviceHover()) {
							setActiveCategoryIndex(index_4);
							setActiveRing("category");
						}
						if ((canDeviceHover() || activeCategoryIndex === index_4) && (compact && showTooltip || !compact)) showActivity({
							navigate,
							categories,
							accounts,
							balanceTypeOp,
							filters,
							showHiddenCategories,
							showOffBudget,
							type: "totals",
							startDate: data.startDate,
							endDate: data.endDate,
							field: "category",
							id: item_2.id
						});
					}
				})]
			})] });
			return data[splitData] && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PieChart, {
				responsive: true,
				width,
				height,
				style: { cursor: pointer },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pie, {
					dataKey: (val_1) => getVal(val_1),
					nameKey: yAxis,
					...animationProps,
					animationBegin: 100,
					data: data[splitData]?.map(_temp0) ?? [],
					innerRadius: chartInnerRadius,
					labelLine: false,
					label: (e_0) => viewLabels && !compact ? customLabel$1(e_0) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {}),
					startAngle: 90,
					endAngle: -270,
					shape: (props_1, index_5) => {
						const fill_1 = data.legend?.[index_5]?.color ?? props_1.fill;
						if (index_5 === activeIndex && showActiveShape) return compact ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeMobile, {
							...props_1,
							fill: fill_1,
							expandInward: true,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveShapeDesktop, {
							...props_1,
							fill: fill_1,
							expandInward: false,
							chartInnerRadius,
							chartMidRadius,
							chartOuterRadius
						});
						return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sector, {
							...props_1,
							fill: fill_1
						});
					},
					onMouseLeave: () => setPointer(""),
					onMouseEnter: (__1, index_6) => {
						if (canDeviceHover()) {
							setActiveIndex(index_6);
							if (!["Group", "Interval"].includes(groupBy)) setPointer("pointer");
						}
					},
					onClick: (item_4, index_7) => {
						if (!canDeviceHover()) setActiveIndex(index_7);
						if (!["Interval"].includes(groupBy) && (canDeviceHover() || activeIndex === index_7) && (compact && showTooltip || !compact)) {
							const groupCategoryIds_0 = groupBy === "Group" ? (categories.grouped.find((g_1) => g_1.id === item_4.id)?.categories ?? []).map(_temp1).filter(_temp10) : void 0;
							showActivity({
								navigate,
								categories,
								accounts,
								balanceTypeOp,
								filters,
								showHiddenCategories,
								showOffBudget,
								type: "totals",
								startDate: data.startDate,
								endDate: data.endDate,
								field: groupBy === "Group" ? "category" : groupBy.toLowerCase(),
								id: groupBy === "Group" ? groupCategoryIds_0 : item_4.id
							});
						}
					}
				})
			})] });
		};
		$[22] = accounts;
		$[23] = activeCategoryIndex;
		$[24] = activeGroupIndex;
		$[25] = activeIndex;
		$[26] = activeRing;
		$[27] = adjustedGroupData;
		$[28] = animationProps;
		$[29] = balanceTypeOp;
		$[30] = categories;
		$[31] = colorMap;
		$[32] = data;
		$[33] = filters;
		$[34] = flatCategories;
		$[35] = getVal;
		$[36] = groupBy;
		$[37] = isCategoryGroup;
		$[38] = navigate;
		$[39] = pointer;
		$[40] = showHiddenCategories;
		$[41] = showOffBudget;
		$[42] = showTooltip;
		$[43] = splitData;
		$[44] = viewLabels;
		$[45] = yAxis;
		$[46] = t10;
	} else t10 = $[46];
	let t11;
	if ($[47] !== style || $[48] !== t10) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style,
			children: t10
		});
		$[47] = style;
		$[48] = t10;
		$[49] = t11;
	} else t11 = $[49];
	return t11;
}
function _temp10(c_7) {
	return c_7 != null;
}
function _temp1(c_6) {
	return c_6.id;
}
function _temp0(item_3) {
	return { ...item_3 };
}
function _temp9$1(c_5) {
	return c_5 != null;
}
function _temp8$2(c_4) {
	return c_4.id;
}
function _temp7$3(g) {
	return g.categories ?? [];
}
function _temp6$4(group) {
	const visibleCats = group.categories ?? [];
	return {
		...group,
		totalAssets: visibleCats.reduce(_temp$15, 0),
		totalDebts: visibleCats.reduce(_temp2$9, 0),
		totalTotals: visibleCats.reduce(_temp3$8, 0),
		netAssets: visibleCats.reduce(_temp4$5, 0),
		netDebts: visibleCats.reduce(_temp5$4, 0)
	};
}
function _temp5$4(sum_3, c_3) {
	return sum_3 + c_3.netDebts;
}
function _temp4$5(sum_2, c_2) {
	return sum_2 + c_2.netAssets;
}
function _temp3$8(sum_1, c_1) {
	return sum_1 + c_1.totalTotals;
}
function _temp2$9(sum_0, c_0) {
	return sum_0 + c_0.totalDebts;
}
function _temp$15(sum, c) {
	return sum + c.totalAssets;
}
//#endregion
//#region src/components/reports/graphs/LineGraph.tsx
var CustomTooltip$2 = (t0) => {
	const $ = (0, import_compiler_runtime.c)(41);
	const { compact, tooltip, legend, active, payload, format } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== legend) {
		t1 = new Map(legend.map(_temp$14));
		$[0] = legend;
		$[1] = t1;
	} else t1 = $[1];
	const dataKeyToName = t1;
	let t2;
	if ($[2] !== payload) {
		t2 = (payload ?? []).sort(_temp2$8).reduce(_temp3$7, {
			sumTotals: 0,
			items: []
		});
		$[2] = payload;
		$[3] = t2;
	} else t2 = $[3];
	const { sumTotals, items } = t2;
	if (active && items.length) {
		let t3;
		let t4;
		if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
			t3 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t4 = { marginBottom: 10 };
			$[4] = t3;
			$[5] = t4;
		} else {
			t3 = $[4];
			t4 = $[5];
		}
		let t5;
		if ($[6] !== payload[0].payload.date) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t4,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
			});
			$[6] = payload[0].payload.date;
			$[7] = t5;
		} else t5 = $[7];
		let t6;
		if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
			t6 = { lineHeight: 1.5 };
			$[8] = t6;
		} else t6 = $[8];
		let t7;
		if ($[9] !== compact || $[10] !== dataKeyToName || $[11] !== format || $[12] !== items || $[13] !== tooltip) {
			let t8;
			if ($[15] !== compact || $[16] !== dataKeyToName || $[17] !== format || $[18] !== tooltip) {
				t8 = (p, index) => {
					const displayName = dataKeyToName.get(p.dataKey) ?? p.dataKey;
					return (compact ? index < 4 : true) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
						left: displayName,
						right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(p.value, "financial") }),
						style: {
							color: p.color,
							textDecoration: tooltip === p.dataKey ? "underline" : "inherit"
						}
					}, index);
				};
				$[15] = compact;
				$[16] = dataKeyToName;
				$[17] = format;
				$[18] = tooltip;
				$[19] = t8;
			} else t8 = $[19];
			t7 = items.map(t8);
			$[9] = compact;
			$[10] = dataKeyToName;
			$[11] = format;
			$[12] = items;
			$[13] = tooltip;
			$[14] = t7;
		} else t7 = $[14];
		const t8 = payload.length > 5 && compact && "...";
		let t9;
		if ($[20] !== t) {
			t9 = t("Total");
			$[20] = t;
			$[21] = t9;
		} else t9 = $[21];
		let t10;
		if ($[22] !== format || $[23] !== sumTotals) {
			t10 = format(sumTotals, "financial");
			$[22] = format;
			$[23] = sumTotals;
			$[24] = t10;
		} else t10 = $[24];
		let t11;
		if ($[25] !== t10) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t10 });
			$[25] = t10;
			$[26] = t11;
		} else t11 = $[26];
		let t12;
		if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
			t12 = { fontWeight: 600 };
			$[27] = t12;
		} else t12 = $[27];
		let t13;
		if ($[28] !== t11 || $[29] !== t9) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t9,
				right: t11,
				style: t12
			});
			$[28] = t11;
			$[29] = t9;
			$[30] = t13;
		} else t13 = $[30];
		let t14;
		if ($[31] !== t13 || $[32] !== t7 || $[33] !== t8) {
			t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t6,
				children: [
					t7,
					t8,
					t13
				]
			});
			$[31] = t13;
			$[32] = t7;
			$[33] = t8;
			$[34] = t14;
		} else t14 = $[34];
		let t15;
		if ($[35] !== t14 || $[36] !== t5) {
			t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t14] });
			$[35] = t14;
			$[36] = t5;
			$[37] = t15;
		} else t15 = $[37];
		let t16;
		if ($[38] !== t15 || $[39] !== t3) {
			t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t3,
				children: t15
			});
			$[38] = t15;
			$[39] = t3;
			$[40] = t16;
		} else t16 = $[40];
		return t16;
	}
};
function LineGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(34);
	const { style, data, filters, groupBy, compact, balanceTypeOp, showHiddenCategories, showOffBudget, showTooltip: t1, interval } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const animationProps = useRechartsAnimation();
	const navigate = useNavigate();
	const { data: t2 } = useCategories();
	let t3;
	if ($[0] !== t2) {
		t3 = t2 === void 0 ? {
			grouped: [],
			list: []
		} : t2;
		$[0] = t2;
		$[1] = t3;
	} else t3 = $[1];
	const categories = t3;
	const { data: t4 } = useAccounts();
	let t5;
	if ($[2] !== t4) {
		t5 = t4 === void 0 ? [] : t4;
		$[2] = t4;
		$[3] = t5;
	} else t5 = $[3];
	const accounts = t5;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	const [pointer, setPointer] = (0, import_react.useState)("");
	const [tooltip, setTooltip] = (0, import_react.useState)("");
	const largestValue = data.intervalData.map((c) => c[balanceTypeOp]).reduce(_temp4$4, 0);
	const leftMargin = Math.abs(largestValue) > 1e6 ? 20 : 5;
	let t6;
	if ($[4] !== accounts || $[5] !== balanceTypeOp || $[6] !== categories || $[7] !== filters || $[8] !== groupBy || $[9] !== interval || $[10] !== navigate || $[11] !== showHiddenCategories || $[12] !== showOffBudget) {
		t6 = (item, id, payload) => {
			showActivity({
				navigate,
				categories,
				accounts,
				balanceTypeOp,
				filters,
				showHiddenCategories,
				showOffBudget,
				type: "time",
				startDate: payload.payload.intervalStartDate,
				endDate: payload.payload.intervalEndDate,
				field: groupBy.toLowerCase(),
				id,
				interval
			});
		};
		$[4] = accounts;
		$[5] = balanceTypeOp;
		$[6] = categories;
		$[7] = filters;
		$[8] = groupBy;
		$[9] = interval;
		$[10] = navigate;
		$[11] = showHiddenCategories;
		$[12] = showOffBudget;
		$[13] = t6;
	} else t6 = $[13];
	const onShowActivity = t6;
	let t7;
	if ($[14] !== compact) {
		t7 = compact && { height: "auto" };
		$[14] = compact;
		$[15] = t7;
	} else t7 = $[15];
	let t8;
	if ($[16] !== style || $[17] !== t7) {
		t8 = {
			...style,
			...t7
		};
		$[16] = style;
		$[17] = t7;
		$[18] = t8;
	} else t8 = $[18];
	let t9;
	if ($[19] !== animationProps || $[20] !== compact || $[21] !== data || $[22] !== format || $[23] !== groupBy || $[24] !== leftMargin || $[25] !== onShowActivity || $[26] !== pointer || $[27] !== privacyMode || $[28] !== showTooltip || $[29] !== tooltip) {
		t9 = (width, height) => data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LineChart, {
			responsive: true,
			width,
			height,
			data: data.intervalData,
			margin: {
				top: 10,
				right: 10,
				left: leftMargin,
				bottom: 10
			},
			style: { cursor: pointer },
			children: [
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$2, {
						compact,
						tooltip,
						legend: data.legend,
						format
					}),
					formatter: numberFormatterTooltip,
					isAnimationActive: false
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "date",
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					tickFormatter: (value) => getCustomTick(format(value, "financial-no-decimals"), privacyMode),
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText },
					tickSize: 0
				}),
				data.legend.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
					strokeWidth: 2,
					type: "monotone",
					dataKey: entry.dataKey,
					stroke: entry.color,
					...animationProps,
					activeDot: {
						r: entry.dataKey === tooltip && !compact ? 8 : 3,
						onMouseEnter: () => {
							setTooltip(entry.dataKey);
							if (!["Group", "Interval"].includes(groupBy)) setPointer("pointer");
						},
						onMouseLeave: () => {
							setPointer("");
							setTooltip("");
						},
						onClick: (e, payload_0) => (compact && showTooltip || !compact) && !["Group", "Interval"].includes(groupBy) && onShowActivity(e, entry.id, payload_0)
					}
				}, index))
			]
		})] });
		$[19] = animationProps;
		$[20] = compact;
		$[21] = data;
		$[22] = format;
		$[23] = groupBy;
		$[24] = leftMargin;
		$[25] = onShowActivity;
		$[26] = pointer;
		$[27] = privacyMode;
		$[28] = showTooltip;
		$[29] = tooltip;
		$[30] = t9;
	} else t9 = $[30];
	let t10;
	if ($[31] !== t8 || $[32] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t8,
			children: t9
		});
		$[31] = t8;
		$[32] = t9;
		$[33] = t10;
	} else t10 = $[33];
	return t10;
}
function _temp4$4(acc, cur) {
	return Math.abs(cur) > Math.abs(acc) ? cur : acc;
}
function _temp$14(entry) {
	return [entry.dataKey, entry.name];
}
function _temp2$8(p1, p2) {
	return p2.value - p1.value;
}
function _temp3$7(acc, item) {
	acc.sumTotals = acc.sumTotals + item.value;
	acc.items.push(item);
	return acc;
}
//#endregion
//#region src/components/reports/graphs/StackedBarGraph.tsx
var CustomTooltip$1 = (t0) => {
	const $ = (0, import_compiler_runtime.c)(41);
	const { compact, tooltip, legend, active, payload, label, format } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== legend) {
		t1 = new Map(legend.map(_temp$13));
		$[0] = legend;
		$[1] = t1;
	} else t1 = $[1];
	const dataKeyToName = t1;
	let t2;
	if ($[2] !== payload) {
		t2 = (payload ?? []).slice(0).reverse().reduce(_temp2$7, {
			sumTotals: 0,
			items: []
		});
		$[2] = payload;
		$[3] = t2;
	} else t2 = $[3];
	const { sumTotals, items } = t2;
	if (active && items.length) {
		let t3;
		let t4;
		if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
			t3 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t4 = { marginBottom: 10 };
			$[4] = t3;
			$[5] = t4;
		} else {
			t3 = $[4];
			t4 = $[5];
		}
		let t5;
		if ($[6] !== label) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t4,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: label })
			});
			$[6] = label;
			$[7] = t5;
		} else t5 = $[7];
		let t6;
		if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
			t6 = { lineHeight: 1.4 };
			$[8] = t6;
		} else t6 = $[8];
		let t7;
		if ($[9] !== compact || $[10] !== dataKeyToName || $[11] !== format || $[12] !== items || $[13] !== tooltip) {
			let t8;
			if ($[15] !== compact || $[16] !== dataKeyToName || $[17] !== format || $[18] !== tooltip) {
				t8 = (pay, i) => {
					const displayName = dataKeyToName.get(pay.name) ?? pay.name;
					return pay.value !== 0 && (compact ? i < 5 : true) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
						left: displayName,
						right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(pay.value, "financial") }),
						style: {
							color: pay.color,
							textDecoration: tooltip === pay.name ? "underline" : "inherit"
						}
					}, pay.name);
				};
				$[15] = compact;
				$[16] = dataKeyToName;
				$[17] = format;
				$[18] = tooltip;
				$[19] = t8;
			} else t8 = $[19];
			t7 = items.map(t8);
			$[9] = compact;
			$[10] = dataKeyToName;
			$[11] = format;
			$[12] = items;
			$[13] = tooltip;
			$[14] = t7;
		} else t7 = $[14];
		const t8 = payload.length > 5 && compact && "...";
		let t9;
		if ($[20] !== t) {
			t9 = t("Total");
			$[20] = t;
			$[21] = t9;
		} else t9 = $[21];
		let t10;
		if ($[22] !== format || $[23] !== sumTotals) {
			t10 = format(sumTotals, "financial");
			$[22] = format;
			$[23] = sumTotals;
			$[24] = t10;
		} else t10 = $[24];
		let t11;
		if ($[25] !== t10) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: t10 });
			$[25] = t10;
			$[26] = t11;
		} else t11 = $[26];
		let t12;
		if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
			t12 = { fontWeight: 600 };
			$[27] = t12;
		} else t12 = $[27];
		let t13;
		if ($[28] !== t11 || $[29] !== t9) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t9,
				right: t11,
				style: t12
			});
			$[28] = t11;
			$[29] = t9;
			$[30] = t13;
		} else t13 = $[30];
		let t14;
		if ($[31] !== t13 || $[32] !== t7 || $[33] !== t8) {
			t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t6,
				children: [
					t7,
					t8,
					t13
				]
			});
			$[31] = t13;
			$[32] = t7;
			$[33] = t8;
			$[34] = t14;
		} else t14 = $[34];
		let t15;
		if ($[35] !== t14 || $[36] !== t5) {
			t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t14] });
			$[35] = t14;
			$[36] = t5;
			$[37] = t15;
		} else t15 = $[37];
		let t16;
		if ($[38] !== t15 || $[39] !== t3) {
			t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t3,
				children: t15
			});
			$[38] = t15;
			$[39] = t3;
			$[40] = t16;
		} else t16 = $[40];
		return t16;
	}
};
var customLabel = (props) => {
	const calcX = props.x + props.width / 2;
	const calcY = props.y + props.height / 2;
	const textAnchor = "middle";
	const display = props.value && `${props.format(props.value, "financial-no-decimals")}`;
	const textSize = "12px";
	const showLabel = props.height;
	const showLabelThreshold = 20;
	const fill = theme.reportsInnerLabel;
	return renderCustomLabel(calcX, calcY, textAnchor, display, textSize, showLabel, showLabelThreshold, fill);
};
function StackedBarGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(36);
	const { style, data, filters, groupBy, compact, viewLabels, balanceTypeOp, showHiddenCategories, showOffBudget, showTooltip: t1, interval } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const animationProps = useRechartsAnimation();
	const navigate = useNavigate();
	const { data: t2 } = useCategories();
	let t3;
	if ($[0] !== t2) {
		t3 = t2 === void 0 ? {
			grouped: [],
			list: []
		} : t2;
		$[0] = t2;
		$[1] = t3;
	} else t3 = $[1];
	const categories = t3;
	const { data: t4 } = useAccounts();
	let t5;
	if ($[2] !== t4) {
		t5 = t4 === void 0 ? [] : t4;
		$[2] = t4;
		$[3] = t5;
	} else t5 = $[3];
	const accounts = t5;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	let t6;
	if ($[4] !== format) {
		t6 = (props) => customLabel({
			...props,
			format
		});
		$[4] = format;
		$[5] = t6;
	} else t6 = $[5];
	const customLabelWithFormat = t6;
	const [pointer, setPointer] = (0, import_react.useState)("");
	const [tooltip, setTooltip] = (0, import_react.useState)("");
	const largestValue = data.intervalData.map((c) => c[balanceTypeOp]).reduce(_temp3$6, 0);
	const leftMargin = Math.abs(largestValue) > 1e6 ? 20 : 0;
	let t7;
	if ($[6] !== compact) {
		t7 = compact && { height: "auto" };
		$[6] = compact;
		$[7] = t7;
	} else t7 = $[7];
	let t8;
	if ($[8] !== style || $[9] !== t7) {
		t8 = {
			...style,
			...t7
		};
		$[8] = style;
		$[9] = t7;
		$[10] = t8;
	} else t8 = $[10];
	let t9;
	if ($[11] !== accounts || $[12] !== animationProps || $[13] !== balanceTypeOp || $[14] !== categories || $[15] !== compact || $[16] !== customLabelWithFormat || $[17] !== data.intervalData || $[18] !== data.legend || $[19] !== filters || $[20] !== format || $[21] !== groupBy || $[22] !== interval || $[23] !== leftMargin || $[24] !== navigate || $[25] !== pointer || $[26] !== privacyMode || $[27] !== showHiddenCategories || $[28] !== showOffBudget || $[29] !== showTooltip || $[30] !== tooltip || $[31] !== viewLabels) {
		t9 = (width, height) => data.intervalData && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "15px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(BarChart, {
			width,
			height,
			data: data.intervalData,
			margin: {
				top: 0,
				right: 0,
				left: leftMargin,
				bottom: 10
			},
			style: { cursor: pointer },
			stackOffset: "sign",
			children: [
				showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip$1, {
						compact,
						tooltip,
						legend: data.legend,
						format
					}),
					formatter: numberFormatterTooltip,
					isAnimationActive: false,
					cursor: { fill: "transparent" }
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: "date",
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, { strokeDasharray: "3 3" }),
				!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					tickFormatter: (value) => getCustomTick(format(value, "financial-no-decimals"), privacyMode),
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText },
					tickSize: 0
				}),
				data.legend.slice(0).reverse().map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: entry.dataKey,
					stackId: "a",
					fill: entry.color,
					...animationProps,
					onMouseLeave: () => {
						setPointer("");
						setTooltip("");
					},
					onMouseEnter: () => {
						setTooltip(entry.dataKey);
						if (!["Group", "Interval"].includes(groupBy)) setPointer("pointer");
					},
					onClick: (e) => (compact && showTooltip || !compact) && !["Group", "Interval"].includes(groupBy) && showActivity({
						navigate,
						categories,
						accounts,
						balanceTypeOp,
						filters,
						showHiddenCategories,
						showOffBudget,
						type: "time",
						startDate: e.payload?.intervalStartDate,
						endDate: e.payload?.intervalEndDate,
						field: groupBy.toLowerCase(),
						id: entry.id,
						interval
					}),
					children: viewLabels && !compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelList, {
						dataKey: entry.dataKey,
						content: customLabelWithFormat
					})
				}, entry.dataKey))
			]
		})] });
		$[11] = accounts;
		$[12] = animationProps;
		$[13] = balanceTypeOp;
		$[14] = categories;
		$[15] = compact;
		$[16] = customLabelWithFormat;
		$[17] = data.intervalData;
		$[18] = data.legend;
		$[19] = filters;
		$[20] = format;
		$[21] = groupBy;
		$[22] = interval;
		$[23] = leftMargin;
		$[24] = navigate;
		$[25] = pointer;
		$[26] = privacyMode;
		$[27] = showHiddenCategories;
		$[28] = showOffBudget;
		$[29] = showTooltip;
		$[30] = tooltip;
		$[31] = viewLabels;
		$[32] = t9;
	} else t9 = $[32];
	let t10;
	if ($[33] !== t8 || $[34] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t8,
			children: t9
		});
		$[33] = t8;
		$[34] = t9;
		$[35] = t10;
	} else t10 = $[35];
	return t10;
}
function _temp3$6(acc, cur) {
	return Math.abs(cur) > Math.abs(acc) ? cur : acc;
}
function _temp$13(entry) {
	return [entry.dataKey, entry.name];
}
function _temp2$7(acc, item) {
	acc.sumTotals = acc.sumTotals + item.value;
	acc.items.push(item);
	return acc;
}
//#endregion
//#region src/components/reports/graphs/tableGraph/ReportTableHeader.tsx
function ReportTableHeader(t0) {
	const $ = (0, import_compiler_runtime.c)(45);
	const { groupBy, interval, data, balanceTypeOp, headerScrollRef, handleScroll, compact, style, compactStyle, mode } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== style) {
		t1 = {
			justifyContent: "center",
			borderBottomWidth: 1,
			borderColor: theme.tableBorder,
			color: theme.tableHeaderText,
			backgroundColor: theme.tableHeaderBackground,
			fontWeight: 600,
			...style
		};
		$[0] = style;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			overflowX: "auto",
			scrollbarWidth: "none",
			"::-webkit-scrollbar": { display: "none" },
			flexDirection: "row",
			flex: 1
		};
		$[2] = t2;
	} else t2 = $[2];
	const t3 = compact ? 80 : 125;
	let t4;
	if ($[3] !== t3) {
		t4 = {
			width: t3,
			flexShrink: 0,
			flexGrow: 1
		};
		$[3] = t3;
		$[4] = t4;
	} else t4 = $[4];
	let t5;
	if ($[5] !== groupBy || $[6] !== interval) {
		t5 = groupBy === "Interval" ? ReportOptions.intervalMap.get(interval) : groupBy;
		$[5] = groupBy;
		$[6] = interval;
		$[7] = t5;
	} else t5 = $[7];
	let t6;
	if ($[8] !== compactStyle || $[9] !== t4 || $[10] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: t4,
			valueStyle: compactStyle,
			value: t5
		});
		$[8] = compactStyle;
		$[9] = t4;
		$[10] = t5;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== balanceTypeOp || $[13] !== compact || $[14] !== compactStyle || $[15] !== data || $[16] !== mode || $[17] !== t) {
		t7 = mode === "time" ? data.map((header, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: { minWidth: compact ? 50 : 85 },
			valueStyle: compactStyle,
			value: header.date,
			textAlign: "right",
			width: "flex"
		}, index)) : ["totalTotals", "totalBudgeted"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: { minWidth: compact ? 50 : 85 },
			valueStyle: compactStyle,
			value: t("Deposits"),
			textAlign: "right",
			width: "flex"
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: { minWidth: compact ? 50 : 85 },
			valueStyle: compactStyle,
			value: t("Payments"),
			textAlign: "right",
			width: "flex"
		})] });
		$[12] = balanceTypeOp;
		$[13] = compact;
		$[14] = compactStyle;
		$[15] = data;
		$[16] = mode;
		$[17] = t;
		$[18] = t7;
	} else t7 = $[18];
	const t8 = compact ? 50 : 85;
	let t9;
	if ($[19] !== t8) {
		t9 = { minWidth: t8 };
		$[19] = t8;
		$[20] = t9;
	} else t9 = $[20];
	let t10;
	if ($[21] !== t) {
		t10 = t("Totals");
		$[21] = t;
		$[22] = t10;
	} else t10 = $[22];
	let t11;
	if ($[23] !== compactStyle || $[24] !== t10 || $[25] !== t9) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: t9,
			valueStyle: compactStyle,
			value: t10,
			textAlign: "right",
			width: "flex"
		});
		$[23] = compactStyle;
		$[24] = t10;
		$[25] = t9;
		$[26] = t11;
	} else t11 = $[26];
	const t12 = compact ? 50 : 85;
	let t13;
	if ($[27] !== t12) {
		t13 = { minWidth: t12 };
		$[27] = t12;
		$[28] = t13;
	} else t13 = $[28];
	let t14;
	if ($[29] !== t) {
		t14 = t("Average");
		$[29] = t;
		$[30] = t14;
	} else t14 = $[30];
	let t15;
	if ($[31] !== compactStyle || $[32] !== t13 || $[33] !== t14) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			style: t13,
			valueStyle: compactStyle,
			value: t14,
			textAlign: "right",
			width: "flex"
		});
		$[31] = compactStyle;
		$[32] = t13;
		$[33] = t14;
		$[34] = t15;
	} else t15 = $[34];
	let t16;
	if ($[35] !== handleScroll || $[36] !== headerScrollRef || $[37] !== t11 || $[38] !== t15 || $[39] !== t6 || $[40] !== t7) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			innerRef: headerScrollRef,
			onScroll: handleScroll,
			id: "header",
			style: t2,
			children: [
				t6,
				t7,
				t11,
				t15
			]
		});
		$[35] = handleScroll;
		$[36] = headerScrollRef;
		$[37] = t11;
		$[38] = t15;
		$[39] = t6;
		$[40] = t7;
		$[41] = t16;
	} else t16 = $[41];
	let t17;
	if ($[42] !== t1 || $[43] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, {
			collapsed: true,
			style: t1,
			children: t16
		});
		$[42] = t1;
		$[43] = t16;
		$[44] = t17;
	} else t17 = $[44];
	return t17;
}
//#endregion
//#region src/components/reports/graphs/tableGraph/RenderTableRow.tsx
function RenderTableRow(t0) {
	const $ = (0, import_compiler_runtime.c)(12);
	const { index, parent_index, renderRow, mode, metadata, style } = t0;
	const child = metadata[index];
	let T0;
	let t1;
	if ($[0] !== child || $[1] !== index || $[2] !== metadata || $[3] !== mode || $[4] !== parent_index || $[5] !== renderRow || $[6] !== style) {
		const parent = parent_index !== void 0 ? metadata[parent_index] : {};
		const item = parent_index === void 0 ? child : parent.categories && parent.categories[index] || {};
		T0 = View;
		t1 = renderRow({
			item,
			mode,
			style
		});
		$[0] = child;
		$[1] = index;
		$[2] = metadata;
		$[3] = mode;
		$[4] = parent_index;
		$[5] = renderRow;
		$[6] = style;
		$[7] = T0;
		$[8] = t1;
	} else {
		T0 = $[7];
		t1 = $[8];
	}
	let t2;
	if ($[9] !== T0 || $[10] !== t1) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, { children: t1 });
		$[9] = T0;
		$[10] = t1;
		$[11] = t2;
	} else t2 = $[11];
	return t2;
}
//#endregion
//#region src/components/reports/graphs/tableGraph/ReportTableList.tsx
function ReportTableList(t0) {
	const $ = (0, import_compiler_runtime.c)(10);
	const { data, mode, groupBy, renderRow, style } = t0;
	let t1;
	if ($[0] !== data.data || $[1] !== data.groupedData || $[2] !== data.intervalData || $[3] !== groupBy) {
		t1 = groupBy === "Category" ? data.groupedData || [] : groupBy === "Interval" ? data.intervalData.map(_temp$12) : data.data;
		$[0] = data.data;
		$[1] = data.groupedData;
		$[2] = data.intervalData;
		$[3] = groupBy;
		$[4] = t1;
	} else t1 = $[4];
	const metadata = t1;
	let t2;
	if ($[5] !== metadata || $[6] !== mode || $[7] !== renderRow || $[8] !== style) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: metadata ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: metadata.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTableRow, {
			index,
			renderRow,
			mode,
			metadata,
			style: {
				...item.categories && {
					color: theme.tableRowHeaderText,
					backgroundColor: theme.tableRowHeaderBackground,
					fontWeight: 600
				},
				...style
			}
		}), item.categories && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: item.categories.map((category, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTableRow, {
			index: i,
			renderRow,
			mode,
			metadata,
			parent_index: index,
			style
		}, category.id)) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { height: 20 })] })] }, index)) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { width: "flex" }) });
		$[5] = metadata;
		$[6] = mode;
		$[7] = renderRow;
		$[8] = style;
		$[9] = t2;
	} else t2 = $[9];
	return t2;
}
function _temp$12(interval) {
	return {
		id: "",
		name: "",
		date: interval.date,
		totalAssets: interval.totalAssets,
		totalDebts: interval.totalDebts,
		netAssets: interval.netAssets,
		netDebts: interval.netDebts,
		totalTotals: interval.totalTotals,
		totalBudgeted: interval.totalBudgeted,
		intervalData: [],
		categories: []
	};
}
//#endregion
//#region src/components/reports/graphs/tableGraph/ReportTableRow.tsx
var getAmountColor = (amount) => {
	if (amount === 0) return theme.reportsNumberNeutral;
	return amount > 0 ? theme.reportsNumberPositive : theme.reportsNumberNegative;
};
var ReportTableRow = (0, import_react.memo)((t0) => {
	const $ = (0, import_compiler_runtime.c)(105);
	const { item, balanceTypeOp, groupBy, mode, filters: t1, startDate: t2, endDate, intervalsCount, compact, style, compactStyle, totalStyle, showHiddenCategories: t3, showOffBudget: t4, totalScrollRef, handleScroll, height, interval, colorized } = t0;
	let t5;
	if ($[0] !== t1) {
		t5 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t5;
	} else t5 = $[1];
	const filters = t5;
	const startDate = t2 === void 0 ? "" : t2;
	const showHiddenCategories = t3 === void 0 ? false : t3;
	const showOffBudget = t4 === void 0 ? false : t4;
	const average = Math.round(item[balanceTypeOp] / intervalsCount);
	const groupByItem = groupBy === "Interval" ? "date" : "name";
	const format = useFormat();
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const { data: t6 } = useCategories();
	const categories = t6 === void 0 ? {
		grouped: [],
		list: []
	} : t6;
	const { data: t7 } = useAccounts();
	let t8;
	if ($[2] !== t7) {
		t8 = t7 === void 0 ? [] : t7;
		$[2] = t7;
		$[3] = t8;
	} else t8 = $[3];
	const accounts = t8;
	const pointer = !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp$11).includes(item.id) ? "pointer" : "inherit";
	const hoverUnderline = !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp2$6).includes(item.id) ? {
		cursor: pointer,
		":hover": { textDecoration: "underline" },
		flexGrow: 0
	} : {};
	const T0 = Row;
	const t9 = item.id;
	const t10 = true;
	let t11;
	if ($[4] !== style) {
		t11 = {
			color: theme.tableText,
			backgroundColor: theme.tableBackground,
			...style
		};
		$[4] = style;
		$[5] = t11;
	} else t11 = $[5];
	const T1 = View;
	const t12 = totalScrollRef ? "total" : item.id;
	const t13 = style?.backgroundColor;
	let t14;
	if ($[6] !== t13 || $[7] !== totalStyle) {
		t14 = {
			flexDirection: "row",
			flex: 1,
			backgroundColor: t13,
			...totalStyle
		};
		$[6] = t13;
		$[7] = totalStyle;
		$[8] = t14;
	} else t14 = $[8];
	const t15 = item[groupByItem];
	const t16 = item[groupByItem];
	const t17 = compact ? 80 : 125;
	const t18 = style?.backgroundColor;
	let t19;
	if ($[9] !== t17 || $[10] !== t18) {
		t19 = {
			width: t17,
			flexShrink: 0,
			flexGrow: 1,
			backgroundColor: t18
		};
		$[9] = t17;
		$[10] = t18;
		$[11] = t19;
	} else t19 = $[11];
	let t20;
	if ($[12] !== compactStyle || $[13] !== t15 || $[14] !== t16 || $[15] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			value: t15,
			title: t16,
			style: t19,
			valueStyle: compactStyle
		});
		$[12] = compactStyle;
		$[13] = t15;
		$[14] = t16;
		$[15] = t19;
		$[16] = t20;
	} else t20 = $[16];
	let t21;
	if ($[17] !== accounts || $[18] !== balanceTypeOp || $[19] !== categories || $[20] !== colorized || $[21] !== compact || $[22] !== compactStyle || $[23] !== endDate || $[24] !== filters || $[25] !== format || $[26] !== groupBy || $[27] !== hoverUnderline || $[28] !== interval || $[29] !== isNarrowWidth || $[30] !== item.id || $[31] !== item.intervalData || $[32] !== item.totalAssets || $[33] !== item.totalDebts || $[34] !== mode || $[35] !== navigate || $[36] !== showHiddenCategories || $[37] !== showOffBudget || $[38] !== startDate || $[39] !== style?.backgroundColor) {
		t21 = item.intervalData && mode === "time" ? item.intervalData.map((intervalItem, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			textAlign: "right",
			style: {
				minWidth: compact ? 50 : 85,
				backgroundColor: style?.backgroundColor,
				...colorized && { color: getAmountColor(intervalItem[balanceTypeOp]) }
			},
			unexposedContent: (t22) => {
				const { value } = t22;
				return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: {
						...hoverUnderline,
						textAlign: "right",
						flexGrow: 1
					},
					children: value
				});
			},
			valueStyle: compactStyle,
			value: format(intervalItem[balanceTypeOp], "financial"),
			title: Math.abs(intervalItem[balanceTypeOp]) > 1e5 ? format(intervalItem[balanceTypeOp], "financial") : void 0,
			onClick: () => !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp3$5).includes(item.id) && showActivity({
				navigate,
				categories,
				accounts,
				balanceTypeOp,
				filters,
				showHiddenCategories,
				showOffBudget,
				type: "time",
				startDate: intervalItem.intervalStartDate || "",
				endDate: intervalItem.intervalEndDate || "",
				field: groupBy.toLowerCase(),
				id: item.id,
				interval
			}),
			width: "flex",
			privacyFilter: true
		}, index)) : ["totalTotals", "totalBudgeted"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			value: format(item.totalAssets, "financial"),
			title: Math.abs(item.totalAssets) > 1e5 ? format(item.totalAssets, "financial") : void 0,
			textAlign: "right",
			width: "flex",
			privacyFilter: true,
			style: {
				minWidth: compact ? 50 : 85,
				backgroundColor: style?.backgroundColor,
				...colorized && { color: getAmountColor(item.totalAssets) }
			},
			unexposedContent: (t23) => {
				const { value: value_0 } = t23;
				return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: {
						...hoverUnderline,
						textAlign: "right",
						flexGrow: 1
					},
					children: value_0
				});
			},
			valueStyle: compactStyle,
			onClick: () => !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp4$3).includes(item.id) && showActivity({
				navigate,
				categories,
				accounts,
				balanceTypeOp,
				filters,
				showHiddenCategories,
				showOffBudget,
				type: "assets",
				startDate,
				endDate,
				field: groupBy.toLowerCase(),
				id: item.id
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			value: format(item.totalDebts, "financial"),
			title: Math.abs(item.totalDebts) > 1e5 ? format(item.totalDebts, "financial") : void 0,
			textAlign: "right",
			width: "flex",
			privacyFilter: true,
			style: {
				minWidth: compact ? 50 : 85,
				backgroundColor: style?.backgroundColor,
				...colorized && { color: getAmountColor(item.totalDebts) }
			},
			unexposedContent: (t24) => {
				const { value: value_1 } = t24;
				return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
					style: {
						...hoverUnderline,
						textAlign: "right",
						flexGrow: 1
					},
					children: value_1
				});
			},
			valueStyle: compactStyle,
			onClick: () => !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp5$3).includes(item.id) && showActivity({
				navigate,
				categories,
				accounts,
				balanceTypeOp,
				filters,
				showHiddenCategories,
				showOffBudget,
				type: "debts",
				startDate,
				endDate,
				field: groupBy.toLowerCase(),
				id: item.id
			})
		})] });
		$[17] = accounts;
		$[18] = balanceTypeOp;
		$[19] = categories;
		$[20] = colorized;
		$[21] = compact;
		$[22] = compactStyle;
		$[23] = endDate;
		$[24] = filters;
		$[25] = format;
		$[26] = groupBy;
		$[27] = hoverUnderline;
		$[28] = interval;
		$[29] = isNarrowWidth;
		$[30] = item.id;
		$[31] = item.intervalData;
		$[32] = item.totalAssets;
		$[33] = item.totalDebts;
		$[34] = mode;
		$[35] = navigate;
		$[36] = showHiddenCategories;
		$[37] = showOffBudget;
		$[38] = startDate;
		$[39] = style?.backgroundColor;
		$[40] = t21;
	} else t21 = $[40];
	const t22 = item[balanceTypeOp];
	let t23;
	if ($[41] !== format || $[42] !== t22) {
		t23 = format(t22, "financial");
		$[41] = format;
		$[42] = t22;
		$[43] = t23;
	} else t23 = $[43];
	let t24;
	if ($[44] !== balanceTypeOp || $[45] !== format || $[46] !== item) {
		t24 = Math.abs(item[balanceTypeOp]) > 1e5 ? format(item[balanceTypeOp], "financial") : void 0;
		$[44] = balanceTypeOp;
		$[45] = format;
		$[46] = item;
		$[47] = t24;
	} else t24 = $[47];
	const t25 = compact ? 50 : 85;
	const t26 = style?.backgroundColor;
	let t27;
	if ($[48] !== balanceTypeOp || $[49] !== colorized || $[50] !== item) {
		t27 = colorized && { color: getAmountColor(item[balanceTypeOp]) };
		$[48] = balanceTypeOp;
		$[49] = colorized;
		$[50] = item;
		$[51] = t27;
	} else t27 = $[51];
	let t28;
	if ($[52] !== t25 || $[53] !== t26 || $[54] !== t27) {
		t28 = {
			fontWeight: 600,
			minWidth: t25,
			backgroundColor: t26,
			...t27
		};
		$[52] = t25;
		$[53] = t26;
		$[54] = t27;
		$[55] = t28;
	} else t28 = $[55];
	let t29;
	if ($[56] !== hoverUnderline) {
		t29 = (t30) => {
			const { value: value_2 } = t30;
			return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
				style: {
					...hoverUnderline,
					textAlign: "right",
					flexGrow: 1
				},
				children: value_2
			});
		};
		$[56] = hoverUnderline;
		$[57] = t29;
	} else t29 = $[57];
	let t30;
	if ($[58] !== accounts || $[59] !== balanceTypeOp || $[60] !== categories || $[61] !== compact || $[62] !== endDate || $[63] !== filters || $[64] !== groupBy || $[65] !== isNarrowWidth || $[66] !== item.id || $[67] !== navigate || $[68] !== showHiddenCategories || $[69] !== showOffBudget || $[70] !== startDate) {
		t30 = () => !isNarrowWidth && !["Group", "Interval"].includes(groupBy) && !compact && !categories.grouped.map(_temp6$3).includes(item.id) && showActivity({
			navigate,
			categories,
			accounts,
			balanceTypeOp,
			filters,
			showHiddenCategories,
			showOffBudget,
			type: "totals",
			startDate,
			endDate,
			field: groupBy.toLowerCase(),
			id: item.id
		});
		$[58] = accounts;
		$[59] = balanceTypeOp;
		$[60] = categories;
		$[61] = compact;
		$[62] = endDate;
		$[63] = filters;
		$[64] = groupBy;
		$[65] = isNarrowWidth;
		$[66] = item.id;
		$[67] = navigate;
		$[68] = showHiddenCategories;
		$[69] = showOffBudget;
		$[70] = startDate;
		$[71] = t30;
	} else t30 = $[71];
	let t31;
	if ($[72] !== compactStyle || $[73] !== t23 || $[74] !== t24 || $[75] !== t28 || $[76] !== t29 || $[77] !== t30) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Cell$1, {
			value: t23,
			title: t24,
			textAlign: "right",
			style: t28,
			unexposedContent: t29,
			valueStyle: compactStyle,
			onClick: t30,
			width: "flex",
			privacyFilter: true
		});
		$[72] = compactStyle;
		$[73] = t23;
		$[74] = t24;
		$[75] = t28;
		$[76] = t29;
		$[77] = t30;
		$[78] = t31;
	} else t31 = $[78];
	const T2 = Cell$1;
	const t32 = format(average, "financial");
	const t33 = Math.abs(average / 100) > 1e5 ? format(average, "financial") : void 0;
	const t34 = "right";
	const t35 = 600;
	const t36 = compact ? 50 : 85;
	const t37 = style?.backgroundColor;
	const t38 = colorized && { color: getAmountColor(average) };
	let t39;
	if ($[79] !== t36 || $[80] !== t37 || $[81] !== t38) {
		t39 = {
			fontWeight: t35,
			minWidth: t36,
			backgroundColor: t37,
			...t38
		};
		$[79] = t36;
		$[80] = t37;
		$[81] = t38;
		$[82] = t39;
	} else t39 = $[82];
	let t40;
	if ($[83] !== T2 || $[84] !== compactStyle || $[85] !== t32 || $[86] !== t33 || $[87] !== t39) {
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T2, {
			value: t32,
			title: t33,
			textAlign: t34,
			style: t39,
			unexposedContent: _temp7$2,
			valueStyle: compactStyle,
			width: "flex",
			privacyFilter: true
		});
		$[83] = T2;
		$[84] = compactStyle;
		$[85] = t32;
		$[86] = t33;
		$[87] = t39;
		$[88] = t40;
	} else t40 = $[88];
	let t41;
	if ($[89] !== T1 || $[90] !== handleScroll || $[91] !== t12 || $[92] !== t14 || $[93] !== t20 || $[94] !== t21 || $[95] !== t31 || $[96] !== t40 || $[97] !== totalScrollRef) {
		t41 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T1, {
			innerRef: totalScrollRef,
			onScroll: handleScroll,
			id: t12,
			style: t14,
			children: [
				t20,
				t21,
				t31,
				t40
			]
		});
		$[89] = T1;
		$[90] = handleScroll;
		$[91] = t12;
		$[92] = t14;
		$[93] = t20;
		$[94] = t21;
		$[95] = t31;
		$[96] = t40;
		$[97] = totalScrollRef;
		$[98] = t41;
	} else t41 = $[98];
	let t42;
	if ($[99] !== T0 || $[100] !== height || $[101] !== item.id || $[102] !== t11 || $[103] !== t41) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			height,
			collapsed: t10,
			style: t11,
			children: t41
		}, t9);
		$[99] = T0;
		$[100] = height;
		$[101] = item.id;
		$[102] = t11;
		$[103] = t41;
		$[104] = t42;
	} else t42 = $[104];
	return t42;
});
ReportTableRow.displayName = "ReportTableRow";
function _temp$11(g) {
	return g.id;
}
function _temp2$6(g_0) {
	return g_0.id;
}
function _temp3$5(g_1) {
	return g_1.id;
}
function _temp4$3(g_2) {
	return g_2.id;
}
function _temp5$3(g_3) {
	return g_3.id;
}
function _temp6$3(g_4) {
	return g_4.id;
}
function _temp7$2(t0) {
	const { value: value_3 } = t0;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
		style: {
			textAlign: "right",
			flexGrow: 1
		},
		children: value_3
	});
}
//#endregion
//#region src/components/reports/graphs/tableGraph/ReportTableTotals.tsx
function RenderTotalsRow(t0) {
	const $ = (0, import_compiler_runtime.c)(9);
	const { metadata, mode, totalsStyle, testStyle, scrollWidthTotals, renderTotals } = t0;
	let t1;
	if ($[0] !== metadata || $[1] !== mode || $[2] !== renderTotals || $[3] !== scrollWidthTotals || $[4] !== testStyle || $[5] !== totalsStyle) {
		t1 = renderTotals({
			metadata,
			mode,
			totalsStyle,
			testStyle,
			scrollWidthTotals
		});
		$[0] = metadata;
		$[1] = mode;
		$[2] = renderTotals;
		$[3] = scrollWidthTotals;
		$[4] = testStyle;
		$[5] = totalsStyle;
		$[6] = t1;
	} else t1 = $[6];
	let t2;
	if ($[7] !== t1) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: t1 });
		$[7] = t1;
		$[8] = t2;
	} else t2 = $[8];
	return t2;
}
function ReportTableTotals(t0) {
	const $ = (0, import_compiler_runtime.c)(28);
	const { data, mode, totalScrollRef, compact, style, renderTotals } = t0;
	const { t } = useTranslation();
	const [scrollWidthTotals, setScrollWidthTotals] = (0, import_react.useState)(0);
	let t1;
	let t2;
	if ($[0] !== totalScrollRef) {
		t1 = () => {
			if (totalScrollRef.current) {
				const [parent, child] = [totalScrollRef.current.offsetParent ? (totalScrollRef.current.parentElement ? totalScrollRef.current.parentElement.scrollHeight : 0) || 0 : 0, totalScrollRef.current ? totalScrollRef.current.scrollHeight : 0];
				setScrollWidthTotals(parent > 0 && child > 0 ? parent - child : 0);
			}
		};
		t2 = [totalScrollRef];
		$[0] = totalScrollRef;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	(0, import_react.useLayoutEffect)(t1, t2);
	let t3;
	if ($[3] !== t) {
		t3 = t("Totals");
		$[3] = t;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== data.intervalData || $[6] !== data.netAssets || $[7] !== data.netDebts || $[8] !== data.totalAssets || $[9] !== data.totalBudgeted || $[10] !== data.totalDebts || $[11] !== data.totalTotals || $[12] !== t3) {
		t4 = {
			id: "",
			name: t3,
			intervalData: data.intervalData,
			totalAssets: data.totalAssets,
			totalDebts: data.totalDebts,
			netAssets: data.netAssets,
			netDebts: data.netDebts,
			totalTotals: data.totalTotals,
			totalBudgeted: data.totalBudgeted
		};
		$[5] = data.intervalData;
		$[6] = data.netAssets;
		$[7] = data.netDebts;
		$[8] = data.totalAssets;
		$[9] = data.totalBudgeted;
		$[10] = data.totalDebts;
		$[11] = data.totalTotals;
		$[12] = t3;
		$[13] = t4;
	} else t4 = $[13];
	const metadata = t4;
	let t5;
	if ($[14] !== style) {
		t5 = {
			borderTopWidth: 1,
			borderColor: theme.tableBorder,
			justifyContent: "center",
			color: theme.tableRowHeaderText,
			backgroundColor: theme.tableRowHeaderBackground,
			fontWeight: 600,
			...style
		};
		$[14] = style;
		$[15] = t5;
	} else t5 = $[15];
	const totalsStyle = t5;
	const t6 = compact ? "none" : "inherit";
	const t7 = compact && "none";
	let t8;
	if ($[16] !== t7) {
		t8 = {
			backgroundColor: theme.tableBackground,
			height: 12,
			dispaly: t7
		};
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t6 || $[19] !== t8) {
		t9 = {
			overflowX: "auto",
			scrollbarWidth: t6,
			...styles.horizontalScrollbar,
			"::-webkit-scrollbar": t8,
			flexDirection: "row",
			flex: 1
		};
		$[18] = t6;
		$[19] = t8;
		$[20] = t9;
	} else t9 = $[20];
	const testStyle = t9;
	let t10;
	if ($[21] !== metadata || $[22] !== mode || $[23] !== renderTotals || $[24] !== scrollWidthTotals || $[25] !== testStyle || $[26] !== totalsStyle) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTotalsRow, {
			metadata,
			mode,
			totalsStyle,
			testStyle,
			scrollWidthTotals,
			renderTotals
		});
		$[21] = metadata;
		$[22] = mode;
		$[23] = renderTotals;
		$[24] = scrollWidthTotals;
		$[25] = testStyle;
		$[26] = totalsStyle;
		$[27] = t10;
	} else t10 = $[27];
	return t10;
}
//#endregion
//#region src/components/reports/graphs/tableGraph/ReportTable.tsx
function ReportTable(t0) {
	const $ = (0, import_compiler_runtime.c)(63);
	const { saveScrollWidth, headerScrollRef, listScrollRef, totalScrollRef, handleScroll, groupBy, balanceTypeOp, data, filters, mode, intervalsCount, interval, compact, style, compactStyle, showHiddenCategories, showOffBudget } = t0;
	const contentRef = (0, import_react.useRef)(null);
	let t1;
	if ($[0] !== saveScrollWidth) {
		t1 = () => {
			if (contentRef.current && saveScrollWidth) saveScrollWidth(contentRef.current ? contentRef.current.offsetWidth : 0);
		};
		$[0] = saveScrollWidth;
		$[1] = t1;
	} else t1 = $[1];
	(0, import_react.useLayoutEffect)(t1);
	let t2;
	if ($[2] !== balanceTypeOp || $[3] !== compact || $[4] !== compactStyle || $[5] !== data.endDate || $[6] !== data.startDate || $[7] !== filters || $[8] !== groupBy || $[9] !== interval || $[10] !== intervalsCount || $[11] !== showHiddenCategories || $[12] !== showOffBudget) {
		t2 = (t3) => {
			const { item, mode: mode_0, style: style_0 } = t3;
			return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTableRow, {
				item,
				balanceTypeOp,
				groupBy,
				mode: mode_0,
				filters,
				startDate: data.startDate,
				endDate: data.endDate,
				intervalsCount,
				compact,
				style: style_0,
				compactStyle,
				showHiddenCategories,
				showOffBudget,
				interval
			});
		};
		$[2] = balanceTypeOp;
		$[3] = compact;
		$[4] = compactStyle;
		$[5] = data.endDate;
		$[6] = data.startDate;
		$[7] = filters;
		$[8] = groupBy;
		$[9] = interval;
		$[10] = intervalsCount;
		$[11] = showHiddenCategories;
		$[12] = showOffBudget;
		$[13] = t2;
	} else t2 = $[13];
	const renderRow = t2;
	let t3;
	if ($[14] !== balanceTypeOp || $[15] !== compact || $[16] !== compactStyle || $[17] !== data.endDate || $[18] !== data.startDate || $[19] !== filters || $[20] !== groupBy || $[21] !== handleScroll || $[22] !== interval || $[23] !== intervalsCount || $[24] !== showHiddenCategories || $[25] !== showOffBudget || $[26] !== totalScrollRef) {
		t3 = (t4) => {
			const { metadata, mode: mode_1, totalsStyle, testStyle, scrollWidthTotals } = t4;
			return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTableRow, {
				item: metadata,
				balanceTypeOp,
				groupBy,
				mode: mode_1,
				filters,
				startDate: data.startDate,
				endDate: data.endDate,
				intervalsCount,
				compact,
				style: totalsStyle,
				compactStyle,
				showHiddenCategories,
				showOffBudget,
				totalStyle: testStyle,
				totalScrollRef,
				handleScroll,
				height: 32 + scrollWidthTotals,
				interval,
				colorized: true
			});
		};
		$[14] = balanceTypeOp;
		$[15] = compact;
		$[16] = compactStyle;
		$[17] = data.endDate;
		$[18] = data.startDate;
		$[19] = filters;
		$[20] = groupBy;
		$[21] = handleScroll;
		$[22] = interval;
		$[23] = intervalsCount;
		$[24] = showHiddenCategories;
		$[25] = showOffBudget;
		$[26] = totalScrollRef;
		$[27] = t3;
	} else t3 = $[27];
	const renderTotals = t3;
	let t4;
	if ($[28] !== balanceTypeOp || $[29] !== compact || $[30] !== compactStyle || $[31] !== data.intervalData || $[32] !== groupBy || $[33] !== handleScroll || $[34] !== headerScrollRef || $[35] !== interval || $[36] !== mode || $[37] !== style) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTableHeader, {
			headerScrollRef,
			handleScroll,
			data: data.intervalData,
			groupBy,
			interval,
			balanceTypeOp,
			compact,
			style,
			compactStyle,
			mode
		});
		$[28] = balanceTypeOp;
		$[29] = compact;
		$[30] = compactStyle;
		$[31] = data.intervalData;
		$[32] = groupBy;
		$[33] = handleScroll;
		$[34] = headerScrollRef;
		$[35] = interval;
		$[36] = mode;
		$[37] = style;
		$[38] = t4;
	} else t4 = $[38];
	let t5;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = {
			flex: 1,
			flexDirection: "row",
			outline: "none",
			"& .animated .animated-row": { transition: ".25s transform" }
		};
		$[39] = t5;
	} else t5 = $[39];
	let t6;
	if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = { display: "none" };
		$[40] = t6;
	} else t6 = $[40];
	let t7;
	if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			overflowY: "auto",
			scrollbarWidth: "none",
			"::-webkit-scrollbar": t6,
			flex: 1,
			outline: "none",
			"& .animated .animated-row": { transition: ".25s transform" }
		};
		$[41] = t7;
	} else t7 = $[41];
	let t8;
	if ($[42] !== data || $[43] !== groupBy || $[44] !== mode || $[45] !== renderRow || $[46] !== style) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTableList, {
			data,
			mode,
			groupBy,
			renderRow,
			style
		});
		$[42] = data;
		$[43] = groupBy;
		$[44] = mode;
		$[45] = renderRow;
		$[46] = style;
		$[47] = t8;
	} else t8 = $[47];
	let t9;
	if ($[48] !== handleScroll || $[49] !== listScrollRef || $[50] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t5,
			tabIndex: 0,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				innerRef: listScrollRef,
				onScroll: handleScroll,
				id: "list",
				style: t7,
				children: t8
			})
		});
		$[48] = handleScroll;
		$[49] = listScrollRef;
		$[50] = t8;
		$[51] = t9;
	} else t9 = $[51];
	let t10;
	if ($[52] !== compact || $[53] !== data || $[54] !== mode || $[55] !== renderTotals || $[56] !== style || $[57] !== totalScrollRef) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTableTotals, {
			data,
			mode,
			totalScrollRef,
			compact,
			style,
			renderTotals
		});
		$[52] = compact;
		$[53] = data;
		$[54] = mode;
		$[55] = renderTotals;
		$[56] = style;
		$[57] = totalScrollRef;
		$[58] = t10;
	} else t10 = $[58];
	let t11;
	if ($[59] !== t10 || $[60] !== t4 || $[61] !== t9) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [
			t4,
			t9,
			t10
		] });
		$[59] = t10;
		$[60] = t4;
		$[61] = t9;
		$[62] = t11;
	} else t11 = $[62];
	return t11;
}
//#endregion
//#region src/components/reports/ChooseGraph.tsx
function ChooseGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(84);
	const { data, filters: t1, mode, graphType, balanceType, groupBy, interval, setScrollWidth, viewLabels: t2, compact, style, showHiddenCategories: t3, showOffBudget: t4, showTooltip: t5, intervalsCount } = t0;
	let t6;
	if ($[0] !== t1) {
		t6 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t6;
	} else t6 = $[1];
	const filters = t6;
	const viewLabels = t2 === void 0 ? false : t2;
	const showHiddenCategories = t3 === void 0 ? false : t3;
	const showOffBudget = t4 === void 0 ? false : t4;
	const showTooltip = t5 === void 0 ? true : t5;
	let t7;
	if ($[2] !== compact || $[3] !== style) {
		t7 = compact ? { ...style } : {
			flexGrow: 1,
			overflow: "hidden"
		};
		$[2] = compact;
		$[3] = style;
		$[4] = t7;
	} else t7 = $[4];
	const graphStyle = t7;
	let t8;
	if ($[5] !== balanceType) {
		t8 = ReportOptions.balanceTypeMap.get(balanceType) || "totalDebts";
		$[5] = balanceType;
		$[6] = t8;
	} else t8 = $[6];
	const balanceTypeOp = t8;
	let t9;
	if ($[7] !== setScrollWidth) {
		t9 = (value) => {
			setScrollWidth?.(value || 0);
		};
		$[7] = setScrollWidth;
		$[8] = t9;
	} else t9 = $[8];
	const saveScrollWidth = t9;
	let t10;
	if ($[9] !== compact) {
		t10 = compact ? {
			flex: "0 0 20px",
			height: 20
		} : {};
		$[9] = compact;
		$[10] = t10;
	} else t10 = $[10];
	const rowStyle = t10;
	let t11;
	if ($[11] !== compact) {
		t11 = compact ? { ...styles.tinyText } : {};
		$[11] = compact;
		$[12] = t11;
	} else t11 = $[12];
	const compactStyle = t11;
	const headerScrollRef = (0, import_react.useRef)(null);
	const listScrollRef = (0, import_react.useRef)(null);
	const totalScrollRef = (0, import_react.useRef)(null);
	let t12;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = (scroll) => {
			if (scroll.currentTarget.id === "header" && totalScrollRef.current && listScrollRef.current) {
				totalScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
				listScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
			}
			if (scroll.currentTarget.id === "total" && headerScrollRef.current && listScrollRef.current) {
				headerScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
				listScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
			}
			if (scroll.currentTarget.id === "list" && totalScrollRef.current && headerScrollRef.current) {
				headerScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
				totalScrollRef.current.scrollLeft = scroll.currentTarget.scrollLeft;
			}
		};
		$[13] = t12;
	} else t12 = $[13];
	const handleScroll = t12;
	if (graphType === "AreaGraph") {
		let t13;
		if ($[14] !== balanceTypeOp || $[15] !== compact || $[16] !== data || $[17] !== graphStyle || $[18] !== showTooltip || $[19] !== viewLabels) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AreaGraph, {
				style: graphStyle,
				compact,
				data,
				balanceTypeOp,
				viewLabels,
				showTooltip
			});
			$[14] = balanceTypeOp;
			$[15] = compact;
			$[16] = data;
			$[17] = graphStyle;
			$[18] = showTooltip;
			$[19] = viewLabels;
			$[20] = t13;
		} else t13 = $[20];
		return t13;
	}
	if (graphType === "BarGraph") {
		let t13;
		if ($[21] !== balanceTypeOp || $[22] !== compact || $[23] !== data || $[24] !== filters || $[25] !== graphStyle || $[26] !== groupBy || $[27] !== showHiddenCategories || $[28] !== showOffBudget || $[29] !== showTooltip || $[30] !== viewLabels) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarGraph, {
				style: graphStyle,
				compact,
				data,
				filters,
				groupBy,
				balanceTypeOp,
				viewLabels,
				showHiddenCategories,
				showOffBudget,
				showTooltip
			});
			$[21] = balanceTypeOp;
			$[22] = compact;
			$[23] = data;
			$[24] = filters;
			$[25] = graphStyle;
			$[26] = groupBy;
			$[27] = showHiddenCategories;
			$[28] = showOffBudget;
			$[29] = showTooltip;
			$[30] = viewLabels;
			$[31] = t13;
		} else t13 = $[31];
		return t13;
	}
	if (graphType === "BarLineGraph") {
		let t13;
		if ($[32] !== compact || $[33] !== data || $[34] !== graphStyle || $[35] !== showTooltip) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarLineGraph, {
				style: graphStyle,
				compact,
				data,
				showTooltip
			});
			$[32] = compact;
			$[33] = data;
			$[34] = graphStyle;
			$[35] = showTooltip;
			$[36] = t13;
		} else t13 = $[36];
		return t13;
	}
	if (graphType === "DonutGraph") {
		let t13;
		if ($[37] !== balanceTypeOp || $[38] !== data || $[39] !== filters || $[40] !== graphStyle || $[41] !== groupBy || $[42] !== showHiddenCategories || $[43] !== showOffBudget || $[44] !== showTooltip || $[45] !== viewLabels) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DonutGraph, {
				style: graphStyle,
				data,
				filters,
				groupBy,
				balanceTypeOp,
				viewLabels,
				showHiddenCategories,
				showOffBudget,
				showTooltip
			});
			$[37] = balanceTypeOp;
			$[38] = data;
			$[39] = filters;
			$[40] = graphStyle;
			$[41] = groupBy;
			$[42] = showHiddenCategories;
			$[43] = showOffBudget;
			$[44] = showTooltip;
			$[45] = viewLabels;
			$[46] = t13;
		} else t13 = $[46];
		return t13;
	}
	if (graphType === "LineGraph") {
		let t13;
		if ($[47] !== balanceTypeOp || $[48] !== compact || $[49] !== data || $[50] !== filters || $[51] !== graphStyle || $[52] !== groupBy || $[53] !== interval || $[54] !== showHiddenCategories || $[55] !== showOffBudget || $[56] !== showTooltip) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LineGraph, {
				style: graphStyle,
				compact,
				data,
				filters,
				groupBy,
				balanceTypeOp,
				showHiddenCategories,
				showOffBudget,
				showTooltip,
				interval
			});
			$[47] = balanceTypeOp;
			$[48] = compact;
			$[49] = data;
			$[50] = filters;
			$[51] = graphStyle;
			$[52] = groupBy;
			$[53] = interval;
			$[54] = showHiddenCategories;
			$[55] = showOffBudget;
			$[56] = showTooltip;
			$[57] = t13;
		} else t13 = $[57];
		return t13;
	}
	if (graphType === "StackedBarGraph") {
		let t13;
		if ($[58] !== balanceTypeOp || $[59] !== compact || $[60] !== data || $[61] !== filters || $[62] !== graphStyle || $[63] !== groupBy || $[64] !== interval || $[65] !== showHiddenCategories || $[66] !== showOffBudget || $[67] !== showTooltip || $[68] !== viewLabels) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StackedBarGraph, {
				style: graphStyle,
				compact,
				data,
				filters,
				viewLabels,
				balanceTypeOp,
				groupBy,
				showHiddenCategories,
				showOffBudget,
				showTooltip,
				interval
			});
			$[58] = balanceTypeOp;
			$[59] = compact;
			$[60] = data;
			$[61] = filters;
			$[62] = graphStyle;
			$[63] = groupBy;
			$[64] = interval;
			$[65] = showHiddenCategories;
			$[66] = showOffBudget;
			$[67] = showTooltip;
			$[68] = viewLabels;
			$[69] = t13;
		} else t13 = $[69];
		return t13;
	}
	if (graphType === "TableGraph") {
		let t13;
		if ($[70] !== balanceTypeOp || $[71] !== compact || $[72] !== compactStyle || $[73] !== data || $[74] !== filters || $[75] !== groupBy || $[76] !== interval || $[77] !== intervalsCount || $[78] !== mode || $[79] !== rowStyle || $[80] !== saveScrollWidth || $[81] !== showHiddenCategories || $[82] !== showOffBudget) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTable, {
				saveScrollWidth,
				headerScrollRef,
				listScrollRef,
				totalScrollRef,
				handleScroll,
				balanceTypeOp,
				groupBy,
				data,
				filters,
				mode,
				intervalsCount,
				interval,
				compact,
				style: rowStyle,
				compactStyle,
				showHiddenCategories,
				showOffBudget
			});
			$[70] = balanceTypeOp;
			$[71] = compact;
			$[72] = compactStyle;
			$[73] = data;
			$[74] = filters;
			$[75] = groupBy;
			$[76] = interval;
			$[77] = intervalsCount;
			$[78] = mode;
			$[79] = rowStyle;
			$[80] = saveScrollWidth;
			$[81] = showHiddenCategories;
			$[82] = showOffBudget;
			$[83] = t13;
		} else t13 = $[83];
		return t13;
	}
	return null;
}
//#endregion
//#region src/components/reports/disabledList.ts
var intervalOptions = [
	{
		description: t("Daily"),
		key: "Daily",
		defaultRange: "This month"
	},
	{
		description: t("Weekly"),
		key: "Weekly",
		defaultRange: "Last 3 months"
	},
	{
		description: t("Monthly"),
		key: "Monthly",
		defaultRange: "Last 6 months"
	},
	{
		description: t("Yearly"),
		key: "Yearly",
		defaultRange: "Year to date"
	}
];
var currentIntervalOptions = [
	{
		description: t("This week"),
		disableInclude: true
	},
	{
		description: t("This month"),
		disableInclude: true
	},
	{
		description: t("Last 30 days"),
		disableInclude: true
	},
	{
		description: t("Year to date"),
		disableInclude: true
	},
	{
		description: t("Last year"),
		disableInclude: true
	},
	{
		description: t("Prior year to date"),
		disableInclude: true
	},
	{
		description: t("All time"),
		disableInclude: true
	}
];
var modeOptions = [{
	description: "total",
	graphs: [
		{
			description: "TableGraph",
			disabledSplit: ["CategoryGroup"],
			defaultSplit: "Category",
			disabledType: [],
			defaultType: "Payment",
			disableLegend: true,
			disableLabel: true,
			defaultSort: "budget"
		},
		{
			description: "BarGraph",
			disabledSplit: ["CategoryGroup"],
			defaultSplit: "Category",
			disabledType: [],
			defaultType: "Payment",
			defaultSort: "desc"
		},
		{
			description: "AreaGraph",
			disabledSplit: [
				"Category",
				"Group",
				"CategoryGroup",
				"Payee",
				"Account"
			],
			defaultSplit: "Interval",
			disabledType: [],
			defaultType: "Payment",
			disableLegend: true,
			disableSort: true,
			defaultSort: "desc"
		},
		{
			description: "DonutGraph",
			disabledSplit: [],
			defaultSplit: "Category",
			disabledType: ["Net"],
			defaultType: "Payment",
			defaultSort: "desc"
		}
	],
	disabledGraph: ["LineGraph"],
	defaultGraph: "TableGraph"
}, {
	description: "time",
	graphs: [
		{
			description: "TableGraph",
			disabledSplit: ["Interval", "CategoryGroup"],
			defaultSplit: "Category",
			disabledType: ["Net Payment", "Net Deposit"],
			defaultType: "Payment",
			disableLegend: true,
			disableLabel: true,
			disableSort: true,
			defaultSort: "desc"
		},
		{
			description: "StackedBarGraph",
			disabledSplit: ["Interval", "CategoryGroup"],
			defaultSplit: "Category",
			disabledType: [],
			defaultType: "Payment",
			disableSort: true,
			defaultSort: "desc"
		},
		{
			description: "LineGraph",
			disabledSplit: ["Interval", "CategoryGroup"],
			defaultSplit: "Category",
			disabledType: [],
			defaultType: "Payment",
			disableLegend: false,
			disableLabel: true,
			disableSort: true,
			defaultSort: "desc"
		}
	],
	disabledGraph: ["AreaGraph", "DonutGraph"],
	defaultGraph: "TableGraph"
}];
function disabledGraphList(item, newGraph, type) {
	const graphList = modeOptions.find((d) => d.description === item);
	if (!graphList) return [];
	const disabledList = graphList.graphs.find((e) => e.description === newGraph);
	if (!disabledList) return [];
	return disabledList[type];
}
function disabledLegendLabel(item, newGraph, type) {
	const graphList = modeOptions.find((d) => d.description === item);
	if (!graphList) return false;
	const disableLegendLabel = graphList.graphs.find((e) => e.description === newGraph);
	if (!disableLegendLabel) return false;
	return disableLegendLabel[type];
}
function defaultsGraphList(item, newGraph, type) {
	const graphList = modeOptions.find((d) => d.description === item);
	if (!graphList) return "";
	const defaultItem = graphList.graphs.find((e) => e.description === newGraph);
	if (!defaultItem) return "";
	return defaultItem[type];
}
var disabledList = {
	mode: modeOptions,
	modeGraphsMap: new Map(modeOptions.map((item) => [item.description, item.disabledGraph])),
	currentInterval: new Map(currentIntervalOptions.map((item) => [item.description, item.disableInclude]))
};
var defaultsList = {
	mode: modeOptions,
	modeGraphsMap: new Map(modeOptions.map((item) => [item.description, item.defaultGraph])),
	intervalRange: new Map(intervalOptions.map((item) => [item.key, item.defaultRange]))
};
//#endregion
//#region src/components/reports/LegendItem.tsx
function LegendItem(t0) {
	const $ = (0, import_compiler_runtime.c)(11);
	const { color, label, style } = t0;
	let t1;
	if ($[0] !== style) {
		t1 = {
			padding: 10,
			flexDirection: "row",
			alignItems: "center",
			...style
		};
		$[0] = style;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== color) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			marginRight: 5,
			borderRadius: 1e3,
			width: 14,
			height: 14,
			backgroundColor: color
		} });
		$[2] = color;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			whiteSpace: "nowrap",
			textOverflow: "ellipsis",
			flexShrink: 0
		};
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== label) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t3,
			children: label
		});
		$[5] = label;
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== t1 || $[8] !== t2 || $[9] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t1,
			children: [t2, t4]
		});
		$[7] = t1;
		$[8] = t2;
		$[9] = t4;
		$[10] = t5;
	} else t5 = $[10];
	return t5;
}
//#endregion
//#region src/components/reports/ReportLegend.tsx
function ReportLegend(t0) {
	const $ = (0, import_compiler_runtime.c)(14);
	const { legend, groupBy, interval } = t0;
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			backgroundColor: theme.pageBackground,
			alignItems: "center",
			flex: 1,
			overflowY: "auto"
		};
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			...styles.largeText,
			alignItems: "center",
			marginBottom: 2,
			fontWeight: 400,
			paddingTop: 10
		};
		$[1] = t2;
	} else t2 = $[1];
	let t3;
	if ($[2] !== groupBy || $[3] !== interval) {
		t3 = groupBy === "Interval" ? ReportOptions.intervalMap.get(interval) : groupBy;
		$[2] = groupBy;
		$[3] = interval;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== t3) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t2,
			children: t3
		});
		$[5] = t3;
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== legend) {
		t5 = legend && legend.map(_temp$10);
		$[7] = legend;
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: t5 });
		$[9] = t5;
		$[10] = t6;
	} else t6 = $[10];
	let t7;
	if ($[11] !== t4 || $[12] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t1,
			children: [t4, t6]
		});
		$[11] = t4;
		$[12] = t6;
		$[13] = t7;
	} else t7 = $[13];
	return t7;
}
function _temp$10(item) {
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendItem, {
		color: item.color,
		label: item.name
	}, item.name);
}
//#endregion
//#region src/components/reports/ModeButton.tsx
function ModeButton(t0) {
	const $ = (0, import_compiler_runtime.c)(7);
	const { selected, children, style, onSelect } = t0;
	let t1;
	if ($[0] !== selected || $[1] !== style) {
		t1 = css({
			padding: "5px 10px",
			backgroundColor: theme.menuBackground,
			fontSize: "inherit",
			...style,
			...selected && {
				backgroundColor: theme.buttonPrimaryBackground,
				color: theme.buttonPrimaryText,
				":hover": {
					backgroundColor: theme.buttonPrimaryBackgroundHover,
					color: theme.buttonPrimaryTextHover
				}
			}
		});
		$[0] = selected;
		$[1] = style;
		$[2] = t1;
	} else t1 = $[2];
	let t2;
	if ($[3] !== children || $[4] !== onSelect || $[5] !== t1) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			className: t1,
			onPress: onSelect,
			children
		});
		$[3] = children;
		$[4] = onSelect;
		$[5] = t1;
		$[6] = t2;
	} else t2 = $[6];
	return t2;
}
//#endregion
//#region src/components/reports/setSessionReport.ts
var setSessionReport = (propName, propValue) => {
	const storedReport = sessionStorage.report && JSON.parse(sessionStorage.getItem("report") || "");
	const result = {};
	result[propName] = propValue;
	sessionStorage.setItem("report", JSON.stringify({
		...storedReport,
		...result
	}));
};
//#endregion
//#region src/components/reports/ReportSidebar.tsx
function ReportSidebar({ customReportItems, selectedCategories, categories, dateRangeLine, allIntervals, setDateRange, setGraphType, setGroupBy, setInterval, setBalanceType, setSortBy, setMode, setIsDateStatic, setShowEmpty, setShowOffBudget, setShowHiddenCategories, setIncludeCurrentInterval, setShowUncategorized, setTrimIntervals, setSelectedCategories, onChangeDates, onReportChange, disabledItems, defaultItems, defaultModeItems, earliestTransaction, latestTransaction, firstDayOfWeekIdx, isComplexCategoryCondition = false }) {
	const { t } = useTranslation();
	const locale = useLocale();
	const [menuOpen, setMenuOpen] = (0, import_react.useState)(false);
	const triggerRef = (0, import_react.useRef)(null);
	const onSelectRange = (cond) => {
		setSessionReport("dateRange", cond);
		onReportChange({ type: "modify" });
		setDateRange(cond);
		onChangeDates(...getLiveRange(cond, earliestTransaction, latestTransaction, customReportItems.includeCurrentInterval, firstDayOfWeekIdx));
	};
	const [includeCurrentIntervalText, includeCurrentIntervalTooltip] = (0, import_react.useMemo)(() => {
		const rangeType = (ReportOptions.dateRangeType.get(customReportItems.dateRange) || "").toLowerCase();
		let text = t("Include current period");
		let tooltip = t("Include current period in live range");
		if (rangeType === "month") {
			text = t("Include current Month");
			tooltip = t("Include current Month in live range");
		} else if (rangeType === "year") {
			text = t("Include current Year");
			tooltip = t("Include current Year in live range");
		}
		return [text, tooltip];
	}, [customReportItems.dateRange, t]);
	const onChangeMode = (cond_0) => {
		setSessionReport("mode", cond_0);
		onReportChange({ type: "modify" });
		setMode(cond_0);
		let graph = "";
		if (cond_0 === "time") {
			if (customReportItems.graphType === "BarGraph") {
				setSessionReport("graphType", "StackedBarGraph");
				setGraphType("StackedBarGraph");
				graph = "StackedBarGraph";
			}
		} else if (customReportItems.graphType === "StackedBarGraph") {
			setSessionReport("graphType", "BarGraph");
			setGraphType("BarGraph");
			graph = "BarGraph";
		}
		defaultModeItems(graph, cond_0);
	};
	const onChangeSplit = (cond_1) => {
		setSessionReport("groupBy", cond_1);
		onReportChange({ type: "modify" });
		setGroupBy(cond_1);
		defaultItems(cond_1);
	};
	const onChangeBalanceType = (cond_2) => {
		setSessionReport("balanceType", cond_2);
		onReportChange({ type: "modify" });
		setBalanceType(cond_2);
		if (cond_2 === "Budgeted") {
			if (customReportItems.groupBy === "Payee" || customReportItems.groupBy === "Account") {
				setSessionReport("groupBy", "Category");
				setGroupBy("Category");
				defaultItems("Category");
			}
			if (customReportItems.interval === "Daily" || customReportItems.interval === "Weekly") {
				setSessionReport("interval", "Monthly");
				setInterval("Monthly");
				if (ReportOptions.dateRange.filter((d) => !d["Monthly"]).map((int) => int.key).includes(customReportItems.dateRange)) onSelectRange(defaultsList.intervalRange.get("Monthly") || "");
			}
		}
	};
	const onChangeSortBy = (cond_3) => {
		cond_3 ??= "desc";
		setSessionReport("sortBy", cond_3);
		onReportChange({ type: "modify" });
		setSortBy(cond_3);
	};
	const rangeOptions = (0, import_react.useMemo)(() => {
		const options = ReportOptions.dateRange.filter((f) => f[customReportItems.interval]).map((option) => [option.key, option.description]);
		if (dateRangeLine > 0) options.splice(dateRangeLine, 0, Menu.line);
		return options;
	}, [customReportItems, dateRangeLine]);
	const disableSort = customReportItems.graphType !== "TableGraph" && (customReportItems.groupBy === "Interval" || (disabledList?.mode?.find((m) => m.description === customReportItems.mode)?.graphs.find((g) => g.description === customReportItems.graphType)?.disableSort ?? false));
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: {
			minWidth: 225,
			maxWidth: 250,
			paddingTop: 10,
			paddingRight: 10,
			flexShrink: 0,
			overflowY: "auto"
		},
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { flexShrink: 0 },
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						flexDirection: "row",
						marginBottom: 5,
						alignItems: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Display" }) }) })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
					gap: 5,
					style: { padding: 5 },
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
							style: {
								width: 50,
								textAlign: "right"
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Mode:" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: customReportItems.mode === "total",
							onSelect: () => onChangeMode("total"),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Total" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: customReportItems.mode === "time",
							onSelect: () => onChangeMode("time"),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Time" })
						})
					]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Split:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						value: customReportItems.groupBy,
						onChange: (e) => onChangeSplit(e),
						options: ReportOptions.groupBy.map((option_0) => [option_0.key, option_0.description]),
						disabledKeys: customReportItems.balanceType === "Budgeted" ? [...new Set([
							...disabledItems("split"),
							"Payee",
							"Account"
						])] : disabledItems("split")
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Type:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						value: customReportItems.balanceType,
						onChange: (e_0) => onChangeBalanceType(e_0),
						options: ReportOptions.balanceType.map((option_1) => [option_1.key, option_1.description]),
						disabledKeys: disabledItems("type")
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Interval:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						value: customReportItems.interval,
						onChange: (e_1) => {
							setSessionReport("interval", e_1);
							setInterval(e_1);
							onReportChange({ type: "modify" });
							if (ReportOptions.dateRange.filter((d_0) => !d_0[e_1]).map((int_0) => int_0.key).includes(customReportItems.dateRange)) onSelectRange(defaultsList.intervalRange.get(e_1) || "");
						},
						options: ReportOptions.interval.map((option_2) => [option_2.key, option_2.description]),
						disabledKeys: customReportItems.balanceType === "Budgeted" ? ["Daily", "Weekly"] : []
					})]
				}),
				!disableSort && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Sort:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						value: customReportItems.sortBy,
						onChange: (e_2) => onChangeSortBy(e_2),
						options: ReportOptions.sortBy.map((option_3) => [option_3.format, option_3.description]),
						disabledKeys: disabledItems("sort")
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						} }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
							ref: triggerRef,
							onPress: () => {
								setMenuOpen(true);
							},
							style: {
								color: "currentColor",
								padding: "5px 10px"
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Options" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
							triggerRef,
							placement: "bottom start",
							isOpen: menuOpen,
							onOpenChange: () => setMenuOpen(false),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
								onMenuSelect: (type) => {
									onReportChange({ type: "modify" });
									if (type === "include-current-interval") {
										setSessionReport("includeCurrentInterval", !customReportItems.includeCurrentInterval);
										setIncludeCurrentInterval(!customReportItems.includeCurrentInterval);
									} else if (type === "show-hidden-categories") {
										setSessionReport("showHiddenCategories", !customReportItems.showHiddenCategories);
										setShowHiddenCategories(!customReportItems.showHiddenCategories);
									} else if (type === "show-off-budget") {
										setSessionReport("showOffBudget", !customReportItems.showOffBudget);
										setShowOffBudget(!customReportItems.showOffBudget);
									} else if (type === "show-empty-items") {
										setSessionReport("showEmpty", !customReportItems.showEmpty);
										setShowEmpty(!customReportItems.showEmpty);
									} else if (type === "show-uncategorized") {
										setSessionReport("showUncategorized", !customReportItems.showUncategorized);
										setShowUncategorized(!customReportItems.showUncategorized);
									} else if (type === "trim-intervals") {
										setSessionReport("trimIntervals", !customReportItems.trimIntervals);
										setTrimIntervals(!customReportItems.trimIntervals);
									}
								},
								items: [
									{
										name: "include-current-interval",
										text: includeCurrentIntervalText,
										tooltip: includeCurrentIntervalTooltip,
										toggle: customReportItems.includeCurrentInterval,
										disabled: customReportItems.isDateStatic || disabledList.currentInterval.get(customReportItems.dateRange)
									},
									{
										name: "show-hidden-categories",
										text: t("Show hidden categories"),
										tooltip: t("Show hidden categories"),
										toggle: customReportItems.showHiddenCategories
									},
									{
										name: "show-empty-items",
										text: t("Show empty rows"),
										tooltip: t("Show rows that are zero or blank"),
										toggle: customReportItems.showEmpty
									},
									{
										name: "show-off-budget",
										text: t("Show off budget"),
										tooltip: t("Show off budget accounts"),
										toggle: customReportItems.showOffBudget
									},
									{
										name: "show-uncategorized",
										text: t("Show uncategorized"),
										tooltip: t("Show uncategorized transactions"),
										toggle: customReportItems.showUncategorized
									},
									{
										name: "trim-intervals",
										text: t("Trim intervals"),
										tooltip: t("Trim empty intervals at the start and end of the report"),
										toggle: customReportItems.trimIntervals
									}
								]
							})
						})
					]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					height: 1,
					backgroundColor: theme.pillBorderDark,
					marginTop: 10,
					flexShrink: 0
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
					gap: 5,
					style: {
						marginTop: 10,
						marginBottom: 5
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Date filters" }) }) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: !customReportItems.isDateStatic,
							onSelect: () => {
								setSessionReport("isDateStatic", false);
								setIsDateStatic(false);
								onSelectRange(customReportItems.dateRange);
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Live" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: customReportItems.isDateStatic,
							onSelect: () => {
								setSessionReport("isDateStatic", true);
								setIsDateStatic(true);
								onChangeDates(customReportItems.startDate, customReportItems.endDate, "static");
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Static" })
						})
					]
				}),
				!customReportItems.isDateStatic ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
							style: {
								width: 50,
								textAlign: "right",
								marginRight: 5
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Range:" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: customReportItems.dateRange,
							onChange: onSelectRange,
							options: rangeOptions
						}),
						!disabledList.currentInterval.get(customReportItems.dateRange) && customReportItems.includeCurrentInterval && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
							placement: "bottom start",
							content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Current month" }) }),
							style: {
								...styles.tooltip,
								lineHeight: 1.5,
								padding: "6px 10px",
								marginTop: 5
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
								style: { marginLeft: 10 },
								children: "+1"
							})
						})
					]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "From:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						onChange: (newValue) => onChangeDates(...validateStart(earliestTransaction, latestTransaction, newValue, customReportItems.endDate, customReportItems.interval, firstDayOfWeekIdx)),
						value: customReportItems.startDate,
						defaultLabel: format(customReportItems.startDate, ReportOptions.intervalFormat.get(customReportItems.interval) || "", locale),
						options: allIntervals.map(({ name, pretty }) => [name, pretty])
					})]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						padding: 5,
						alignItems: "center"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							width: 50,
							textAlign: "right",
							marginRight: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "To:" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
						onChange: (newValue_0) => onChangeDates(...validateEnd(earliestTransaction, latestTransaction, customReportItems.startDate, newValue_0, customReportItems.interval, firstDayOfWeekIdx)),
						value: customReportItems.endDate,
						defaultLabel: format(customReportItems.endDate, ReportOptions.intervalFormat.get(customReportItems.interval) || "", locale),
						options: allIntervals.map(({ name: name_0, pretty: pretty_0 }) => [name_0, pretty_0])
					})]
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					height: 1,
					backgroundColor: theme.pillBorderDark,
					marginTop: 10,
					flexShrink: 0
				} })
			]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				marginTop: 10,
				minHeight: 200
			},
			children: isComplexCategoryCondition ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Information, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Remove active category filters to show the category selector." }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CategorySelector, {
				categoryGroups: categories.grouped.filter((f_0) => {
					return customReportItems.showHiddenCategories || !f_0.hidden ? true : false;
				}),
				selectedCategories: selectedCategories || [],
				setSelectedCategories: (e_3) => {
					setSelectedCategories(e_3);
					onReportChange({ type: "modify" });
				},
				showHiddenCategories: customReportItems.showHiddenCategories
			})
		})]
	});
}
//#endregion
//#region src/components/reports/ReportSummary.tsx
function ReportSummary({ startDate, endDate, data, balanceTypeOp, interval, intervalsCount }) {
	const locale = useLocale();
	const { t } = useTranslation();
	const format$7 = useFormat();
	const net = balanceTypeOp === "netAssets" ? t("DEPOSIT") : balanceTypeOp === "netDebts" ? t("PAYMENT") : Math.abs(data.totalDebts) > Math.abs(data.totalAssets) ? t("PAYMENT") : t("DEPOSIT");
	const average = Math.round(data[balanceTypeOp] / intervalsCount);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: {
			flexDirection: "column",
			marginBottom: 10
		},
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					backgroundColor: theme.pageBackground,
					padding: 15,
					alignItems: "center",
					justifyContent: "center"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
					style: {
						...styles.largeText,
						alignItems: "center",
						marginBottom: 2,
						fontWeight: 600
					},
					children: [format(startDate, ReportOptions.intervalFormat.get(interval) || "", locale), format(startDate, ReportOptions.intervalFormat.get(interval) || "", locale) !== format(endDate, ReportOptions.intervalFormat.get(interval) || "", locale) && ` ${t("to")} ` + format(endDate, ReportOptions.intervalFormat.get(interval) || "", locale)]
				})
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					backgroundColor: theme.pageBackground,
					padding: 15,
					justifyContent: "center",
					alignItems: "center",
					marginTop: 10
				},
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							...styles.mediumText,
							alignItems: "center",
							marginBottom: 2,
							fontWeight: 400
						},
						children: balanceTypeOp === "totalDebts" ? t("TOTAL SPENDING") : balanceTypeOp === "totalAssets" ? t("TOTAL DEPOSITS") : balanceTypeOp === "totalBudgeted" ? t("TOTAL BUDGETED") : t("NET {{net}}", { net })
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
						style: {
							...styles.veryLargeText,
							alignItems: "center",
							marginBottom: 2,
							fontWeight: 800
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$7(data[balanceTypeOp], "financial") })
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: { fontWeight: 600 },
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "For this time period" })
					})
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					backgroundColor: theme.pageBackground,
					padding: 15,
					justifyContent: "center",
					alignItems: "center",
					marginTop: 10
				},
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							...styles.mediumText,
							alignItems: "center",
							marginBottom: 2,
							fontWeight: 400
						},
						children: balanceTypeOp === "totalDebts" ? t("AVERAGE SPENDING") : balanceTypeOp === "totalAssets" ? t("AVERAGE DEPOSIT") : balanceTypeOp === "totalBudgeted" ? t("AVERAGE BUDGETED") : t("AVERAGE NET")
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
						style: {
							...styles.veryLargeText,
							alignItems: "center",
							marginBottom: 2,
							fontWeight: 800
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: !isNaN(average) && format$7(average, "financial") })
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: { fontWeight: 600 },
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
							"Per",
							" ",
							{ interval: (ReportOptions.intervalMap.get(interval) || "").toLowerCase() }
						] })
					})
				]
			})
		]
	});
}
//#endregion
//#region ../../node_modules/html-to-image/es/util.js
function resolveUrl(url, baseUrl) {
	if (url.match(/^[a-z]+:\/\//i)) return url;
	if (url.match(/^\/\//)) return window.location.protocol + url;
	if (url.match(/^[a-z]+:/i)) return url;
	const doc = document.implementation.createHTMLDocument();
	const base = doc.createElement("base");
	const a = doc.createElement("a");
	doc.head.appendChild(base);
	doc.body.appendChild(a);
	if (baseUrl) base.href = baseUrl;
	a.href = url;
	return a.href;
}
var uuid = (() => {
	let counter = 0;
	const random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
	return () => {
		counter += 1;
		return `u${random()}${counter}`;
	};
})();
function toArray(arrayLike) {
	const arr = [];
	for (let i = 0, l = arrayLike.length; i < l; i++) arr.push(arrayLike[i]);
	return arr;
}
var styleProps = null;
function getStyleProperties(options = {}) {
	if (styleProps) return styleProps;
	if (options.includeStyleProperties) {
		styleProps = options.includeStyleProperties;
		return styleProps;
	}
	styleProps = toArray(window.getComputedStyle(document.documentElement));
	return styleProps;
}
function px(node, styleProperty) {
	const val = (node.ownerDocument.defaultView || window).getComputedStyle(node).getPropertyValue(styleProperty);
	return val ? parseFloat(val.replace("px", "")) : 0;
}
function getNodeWidth(node) {
	const leftBorder = px(node, "border-left-width");
	const rightBorder = px(node, "border-right-width");
	return node.clientWidth + leftBorder + rightBorder;
}
function getNodeHeight(node) {
	const topBorder = px(node, "border-top-width");
	const bottomBorder = px(node, "border-bottom-width");
	return node.clientHeight + topBorder + bottomBorder;
}
function getImageSize(targetNode, options = {}) {
	return {
		width: options.width || getNodeWidth(targetNode),
		height: options.height || getNodeHeight(targetNode)
	};
}
function getPixelRatio() {
	let ratio;
	let FINAL_PROCESS;
	try {
		FINAL_PROCESS = process;
	} catch (e) {}
	const val = FINAL_PROCESS && FINAL_PROCESS.env ? FINAL_PROCESS.env.devicePixelRatio : null;
	if (val) {
		ratio = parseInt(val, 10);
		if (Number.isNaN(ratio)) ratio = 1;
	}
	return ratio || window.devicePixelRatio || 1;
}
var canvasDimensionLimit = 16384;
function checkCanvasDimensions(canvas) {
	if (canvas.width > canvasDimensionLimit || canvas.height > canvasDimensionLimit) if (canvas.width > canvasDimensionLimit && canvas.height > canvasDimensionLimit) if (canvas.width > canvas.height) {
		canvas.height *= canvasDimensionLimit / canvas.width;
		canvas.width = canvasDimensionLimit;
	} else {
		canvas.width *= canvasDimensionLimit / canvas.height;
		canvas.height = canvasDimensionLimit;
	}
	else if (canvas.width > canvasDimensionLimit) {
		canvas.height *= canvasDimensionLimit / canvas.width;
		canvas.width = canvasDimensionLimit;
	} else {
		canvas.width *= canvasDimensionLimit / canvas.height;
		canvas.height = canvasDimensionLimit;
	}
}
function createImage(url) {
	return new Promise((resolve, reject) => {
		const img = new Image();
		img.onload = () => {
			img.decode().then(() => {
				requestAnimationFrame(() => resolve(img));
			});
		};
		img.onerror = reject;
		img.crossOrigin = "anonymous";
		img.decoding = "async";
		img.src = url;
	});
}
async function svgToDataURL(svg) {
	return Promise.resolve().then(() => new XMLSerializer().serializeToString(svg)).then(encodeURIComponent).then((html) => `data:image/svg+xml;charset=utf-8,${html}`);
}
async function nodeToDataURL(node, width, height) {
	const xmlns = "http://www.w3.org/2000/svg";
	const svg = document.createElementNS(xmlns, "svg");
	const foreignObject = document.createElementNS(xmlns, "foreignObject");
	svg.setAttribute("width", `${width}`);
	svg.setAttribute("height", `${height}`);
	svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
	foreignObject.setAttribute("width", "100%");
	foreignObject.setAttribute("height", "100%");
	foreignObject.setAttribute("x", "0");
	foreignObject.setAttribute("y", "0");
	foreignObject.setAttribute("externalResourcesRequired", "true");
	svg.appendChild(foreignObject);
	foreignObject.appendChild(node);
	return svgToDataURL(svg);
}
var isInstanceOfElement = (node, instance) => {
	if (node instanceof instance) return true;
	const nodePrototype = Object.getPrototypeOf(node);
	if (nodePrototype === null) return false;
	return nodePrototype.constructor.name === instance.name || isInstanceOfElement(nodePrototype, instance);
};
//#endregion
//#region ../../node_modules/html-to-image/es/clone-pseudos.js
function formatCSSText(style) {
	const content = style.getPropertyValue("content");
	return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
}
function formatCSSProperties(style, options) {
	return getStyleProperties(options).map((name) => {
		return `${name}: ${style.getPropertyValue(name)}${style.getPropertyPriority(name) ? " !important" : ""};`;
	}).join(" ");
}
function getPseudoElementStyle(className, pseudo, style, options) {
	const selector = `.${className}:${pseudo}`;
	const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style, options);
	return document.createTextNode(`${selector}{${cssText}}`);
}
function clonePseudoElement(nativeNode, clonedNode, pseudo, options) {
	const style = window.getComputedStyle(nativeNode, pseudo);
	const content = style.getPropertyValue("content");
	if (content === "" || content === "none") return;
	const className = uuid();
	try {
		clonedNode.className = `${clonedNode.className} ${className}`;
	} catch (err) {
		return;
	}
	const styleElement = document.createElement("style");
	styleElement.appendChild(getPseudoElementStyle(className, pseudo, style, options));
	clonedNode.appendChild(styleElement);
}
function clonePseudoElements(nativeNode, clonedNode, options) {
	clonePseudoElement(nativeNode, clonedNode, ":before", options);
	clonePseudoElement(nativeNode, clonedNode, ":after", options);
}
//#endregion
//#region ../../node_modules/html-to-image/es/mimes.js
var WOFF = "application/font-woff";
var JPEG = "image/jpeg";
var mimes = {
	woff: WOFF,
	woff2: WOFF,
	ttf: "application/font-truetype",
	eot: "application/vnd.ms-fontobject",
	png: "image/png",
	jpg: JPEG,
	jpeg: JPEG,
	gif: "image/gif",
	tiff: "image/tiff",
	svg: "image/svg+xml",
	webp: "image/webp"
};
function getExtension(url) {
	const match = /\.([^./]*?)$/g.exec(url);
	return match ? match[1] : "";
}
function getMimeType(url) {
	return mimes[getExtension(url).toLowerCase()] || "";
}
//#endregion
//#region ../../node_modules/html-to-image/es/dataurl.js
function getContentFromDataUrl(dataURL) {
	return dataURL.split(/,/)[1];
}
function isDataUrl(url) {
	return url.search(/^(data:)/) !== -1;
}
function makeDataUrl(content, mimeType) {
	return `data:${mimeType};base64,${content}`;
}
async function fetchAsDataURL(url, init, process) {
	const res = await fetch(url, init);
	if (res.status === 404) throw new Error(`Resource "${res.url}" not found`);
	const blob = await res.blob();
	return new Promise((resolve, reject) => {
		const reader = new FileReader();
		reader.onerror = reject;
		reader.onloadend = () => {
			try {
				resolve(process({
					res,
					result: reader.result
				}));
			} catch (error) {
				reject(error);
			}
		};
		reader.readAsDataURL(blob);
	});
}
var cache = {};
function getCacheKey(url, contentType, includeQueryParams) {
	let key = url.replace(/\?.*/, "");
	if (includeQueryParams) key = url;
	if (/ttf|otf|eot|woff2?/i.test(key)) key = key.replace(/.*\//, "");
	return contentType ? `[${contentType}]${key}` : key;
}
async function resourceToDataURL(resourceUrl, contentType, options) {
	const cacheKey = getCacheKey(resourceUrl, contentType, options.includeQueryParams);
	if (cache[cacheKey] != null) return cache[cacheKey];
	if (options.cacheBust) resourceUrl += (/\?/.test(resourceUrl) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
	let dataURL;
	try {
		dataURL = makeDataUrl(await fetchAsDataURL(resourceUrl, options.fetchRequestInit, ({ res, result }) => {
			if (!contentType) contentType = res.headers.get("Content-Type") || "";
			return getContentFromDataUrl(result);
		}), contentType);
	} catch (error) {
		dataURL = options.imagePlaceholder || "";
		let msg = `Failed to fetch resource: ${resourceUrl}`;
		if (error) msg = typeof error === "string" ? error : error.message;
		if (msg) console.warn(msg);
	}
	cache[cacheKey] = dataURL;
	return dataURL;
}
//#endregion
//#region ../../node_modules/html-to-image/es/clone-node.js
async function cloneCanvasElement(canvas) {
	const dataURL = canvas.toDataURL();
	if (dataURL === "data:,") return canvas.cloneNode(false);
	return createImage(dataURL);
}
async function cloneVideoElement(video, options) {
	if (video.currentSrc) {
		const canvas = document.createElement("canvas");
		const ctx = canvas.getContext("2d");
		canvas.width = video.clientWidth;
		canvas.height = video.clientHeight;
		ctx === null || ctx === void 0 || ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
		return createImage(canvas.toDataURL());
	}
	const poster = video.poster;
	return createImage(await resourceToDataURL(poster, getMimeType(poster), options));
}
async function cloneIFrameElement(iframe, options) {
	var _a;
	try {
		if ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.body) return await cloneNode(iframe.contentDocument.body, options, true);
	} catch (_b) {}
	return iframe.cloneNode(false);
}
async function cloneSingleNode(node, options) {
	if (isInstanceOfElement(node, HTMLCanvasElement)) return cloneCanvasElement(node);
	if (isInstanceOfElement(node, HTMLVideoElement)) return cloneVideoElement(node, options);
	if (isInstanceOfElement(node, HTMLIFrameElement)) return cloneIFrameElement(node, options);
	return node.cloneNode(isSVGElement(node));
}
var isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
var isSVGElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SVG";
async function cloneChildren(nativeNode, clonedNode, options) {
	var _a, _b;
	if (isSVGElement(clonedNode)) return clonedNode;
	let children = [];
	if (isSlotElement(nativeNode) && nativeNode.assignedNodes) children = toArray(nativeNode.assignedNodes());
	else if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && ((_a = nativeNode.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) children = toArray(nativeNode.contentDocument.body.childNodes);
	else children = toArray(((_b = nativeNode.shadowRoot) !== null && _b !== void 0 ? _b : nativeNode).childNodes);
	if (children.length === 0 || isInstanceOfElement(nativeNode, HTMLVideoElement)) return clonedNode;
	await children.reduce((deferred, child) => deferred.then(() => cloneNode(child, options)).then((clonedChild) => {
		if (clonedChild) clonedNode.appendChild(clonedChild);
	}), Promise.resolve());
	return clonedNode;
}
function cloneCSSStyle(nativeNode, clonedNode, options) {
	const targetStyle = clonedNode.style;
	if (!targetStyle) return;
	const sourceStyle = window.getComputedStyle(nativeNode);
	if (sourceStyle.cssText) {
		targetStyle.cssText = sourceStyle.cssText;
		targetStyle.transformOrigin = sourceStyle.transformOrigin;
	} else getStyleProperties(options).forEach((name) => {
		let value = sourceStyle.getPropertyValue(name);
		if (name === "font-size" && value.endsWith("px")) value = `${Math.floor(parseFloat(value.substring(0, value.length - 2))) - .1}px`;
		if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && name === "display" && value === "inline") value = "block";
		if (name === "d" && clonedNode.getAttribute("d")) value = `path(${clonedNode.getAttribute("d")})`;
		targetStyle.setProperty(name, value, sourceStyle.getPropertyPriority(name));
	});
}
function cloneInputValue(nativeNode, clonedNode) {
	if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) clonedNode.innerHTML = nativeNode.value;
	if (isInstanceOfElement(nativeNode, HTMLInputElement)) clonedNode.setAttribute("value", nativeNode.value);
}
function cloneSelectValue(nativeNode, clonedNode) {
	if (isInstanceOfElement(nativeNode, HTMLSelectElement)) {
		const clonedSelect = clonedNode;
		const selectedOption = Array.from(clonedSelect.children).find((child) => nativeNode.value === child.getAttribute("value"));
		if (selectedOption) selectedOption.setAttribute("selected", "");
	}
}
function decorate(nativeNode, clonedNode, options) {
	if (isInstanceOfElement(clonedNode, Element)) {
		cloneCSSStyle(nativeNode, clonedNode, options);
		clonePseudoElements(nativeNode, clonedNode, options);
		cloneInputValue(nativeNode, clonedNode);
		cloneSelectValue(nativeNode, clonedNode);
	}
	return clonedNode;
}
async function ensureSVGSymbols(clone, options) {
	const uses = clone.querySelectorAll ? clone.querySelectorAll("use") : [];
	if (uses.length === 0) return clone;
	const processedDefs = {};
	for (let i = 0; i < uses.length; i++) {
		const id = uses[i].getAttribute("xlink:href");
		if (id) {
			const exist = clone.querySelector(id);
			const definition = document.querySelector(id);
			if (!exist && definition && !processedDefs[id]) processedDefs[id] = await cloneNode(definition, options, true);
		}
	}
	const nodes = Object.values(processedDefs);
	if (nodes.length) {
		const ns = "http://www.w3.org/1999/xhtml";
		const svg = document.createElementNS(ns, "svg");
		svg.setAttribute("xmlns", ns);
		svg.style.position = "absolute";
		svg.style.width = "0";
		svg.style.height = "0";
		svg.style.overflow = "hidden";
		svg.style.display = "none";
		const defs = document.createElementNS(ns, "defs");
		svg.appendChild(defs);
		for (let i = 0; i < nodes.length; i++) defs.appendChild(nodes[i]);
		clone.appendChild(svg);
	}
	return clone;
}
async function cloneNode(node, options, isRoot) {
	if (!isRoot && options.filter && !options.filter(node)) return null;
	return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode, options)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
}
//#endregion
//#region ../../node_modules/html-to-image/es/embed-resources.js
var URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
var URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
var FONT_SRC_REGEX = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
function toRegex(url) {
	const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
	return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
}
function parseURLs(cssText) {
	const urls = [];
	cssText.replace(URL_REGEX, (raw, quotation, url) => {
		urls.push(url);
		return raw;
	});
	return urls.filter((url) => !isDataUrl(url));
}
async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl) {
	try {
		const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL;
		const contentType = getMimeType(resourceURL);
		let dataURL;
		if (getContentFromUrl) dataURL = makeDataUrl(await getContentFromUrl(resolvedURL), contentType);
		else dataURL = await resourceToDataURL(resolvedURL, contentType, options);
		return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
	} catch (error) {}
	return cssText;
}
function filterPreferredFontFormat(str, { preferredFontFormat }) {
	return !preferredFontFormat ? str : str.replace(FONT_SRC_REGEX, (match) => {
		while (true) {
			const [src, , format] = URL_WITH_FORMAT_REGEX.exec(match) || [];
			if (!format) return "";
			if (format === preferredFontFormat) return `src: ${src};`;
		}
	});
}
function shouldEmbed(url) {
	return url.search(URL_REGEX) !== -1;
}
async function embedResources(cssText, baseUrl, options) {
	if (!shouldEmbed(cssText)) return cssText;
	const filteredCSSText = filterPreferredFontFormat(cssText, options);
	return parseURLs(filteredCSSText).reduce((deferred, url) => deferred.then((css) => embed(css, url, baseUrl, options)), Promise.resolve(filteredCSSText));
}
//#endregion
//#region ../../node_modules/html-to-image/es/embed-images.js
async function embedProp(propName, node, options) {
	var _a;
	const propValue = (_a = node.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue(propName);
	if (propValue) {
		const cssString = await embedResources(propValue, null, options);
		node.style.setProperty(propName, cssString, node.style.getPropertyPriority(propName));
		return true;
	}
	return false;
}
async function embedBackground(clonedNode, options) {
	await embedProp("background", clonedNode, options) || await embedProp("background-image", clonedNode, options);
	await embedProp("mask", clonedNode, options) || await embedProp("-webkit-mask", clonedNode, options) || await embedProp("mask-image", clonedNode, options) || await embedProp("-webkit-mask-image", clonedNode, options);
}
async function embedImageNode(clonedNode, options) {
	const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
	if (!(isImageElement && !isDataUrl(clonedNode.src)) && !(isInstanceOfElement(clonedNode, SVGImageElement) && !isDataUrl(clonedNode.href.baseVal))) return;
	const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal;
	const dataURL = await resourceToDataURL(url, getMimeType(url), options);
	await new Promise((resolve, reject) => {
		clonedNode.onload = resolve;
		clonedNode.onerror = options.onImageErrorHandler ? (...attributes) => {
			try {
				resolve(options.onImageErrorHandler(...attributes));
			} catch (error) {
				reject(error);
			}
		} : reject;
		const image = clonedNode;
		if (image.decode) image.decode = resolve;
		if (image.loading === "lazy") image.loading = "eager";
		if (isImageElement) {
			clonedNode.srcset = "";
			clonedNode.src = dataURL;
		} else clonedNode.href.baseVal = dataURL;
	});
}
async function embedChildren(clonedNode, options) {
	const deferreds = toArray(clonedNode.childNodes).map((child) => embedImages(child, options));
	await Promise.all(deferreds).then(() => clonedNode);
}
async function embedImages(clonedNode, options) {
	if (isInstanceOfElement(clonedNode, Element)) {
		await embedBackground(clonedNode, options);
		await embedImageNode(clonedNode, options);
		await embedChildren(clonedNode, options);
	}
}
//#endregion
//#region ../../node_modules/html-to-image/es/apply-style.js
function applyStyle(node, options) {
	const { style } = node;
	if (options.backgroundColor) style.backgroundColor = options.backgroundColor;
	if (options.width) style.width = `${options.width}px`;
	if (options.height) style.height = `${options.height}px`;
	const manual = options.style;
	if (manual != null) Object.keys(manual).forEach((key) => {
		style[key] = manual[key];
	});
	return node;
}
//#endregion
//#region ../../node_modules/html-to-image/es/embed-webfonts.js
var cssFetchCache = {};
async function fetchCSS(url) {
	let cache = cssFetchCache[url];
	if (cache != null) return cache;
	cache = {
		url,
		cssText: await (await fetch(url)).text()
	};
	cssFetchCache[url] = cache;
	return cache;
}
async function embedFonts(data, options) {
	let cssText = data.cssText;
	const regexUrl = /url\(["']?([^"')]+)["']?\)/g;
	const loadFonts = (cssText.match(/url\([^)]+\)/g) || []).map(async (loc) => {
		let url = loc.replace(regexUrl, "$1");
		if (!url.startsWith("https://")) url = new URL(url, data.url).href;
		return fetchAsDataURL(url, options.fetchRequestInit, ({ result }) => {
			cssText = cssText.replace(loc, `url(${result})`);
			return [loc, result];
		});
	});
	return Promise.all(loadFonts).then(() => cssText);
}
function parseCSS(source) {
	if (source == null) return [];
	const result = [];
	let cssText = source.replace(/(\/\*[\s\S]*?\*\/)/gi, "");
	const keyframesRegex = /* @__PURE__ */ new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
	while (true) {
		const matches = keyframesRegex.exec(cssText);
		if (matches === null) break;
		result.push(matches[0]);
	}
	cssText = cssText.replace(keyframesRegex, "");
	const importRegex = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
	const unifiedRegex = /* @__PURE__ */ new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
	while (true) {
		let matches = importRegex.exec(cssText);
		if (matches === null) {
			matches = unifiedRegex.exec(cssText);
			if (matches === null) break;
			else importRegex.lastIndex = unifiedRegex.lastIndex;
		} else unifiedRegex.lastIndex = importRegex.lastIndex;
		result.push(matches[0]);
	}
	return result;
}
async function getCSSRules(styleSheets, options) {
	const ret = [];
	const deferreds = [];
	styleSheets.forEach((sheet) => {
		if ("cssRules" in sheet) try {
			toArray(sheet.cssRules || []).forEach((item, index) => {
				if (item.type === CSSRule.IMPORT_RULE) {
					let importIndex = index + 1;
					const url = item.href;
					const deferred = fetchCSS(url).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
						try {
							sheet.insertRule(rule, rule.startsWith("@import") ? importIndex += 1 : sheet.cssRules.length);
						} catch (error) {
							console.error("Error inserting rule from remote css", {
								rule,
								error
							});
						}
					})).catch((e) => {
						console.error("Error loading remote css", e.toString());
					});
					deferreds.push(deferred);
				}
			});
		} catch (e) {
			const inline = styleSheets.find((a) => a.href == null) || document.styleSheets[0];
			if (sheet.href != null) deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
				inline.insertRule(rule, inline.cssRules.length);
			})).catch((err) => {
				console.error("Error loading remote stylesheet", err);
			}));
			console.error("Error inlining remote css file", e);
		}
	});
	return Promise.all(deferreds).then(() => {
		styleSheets.forEach((sheet) => {
			if ("cssRules" in sheet) try {
				toArray(sheet.cssRules || []).forEach((item) => {
					ret.push(item);
				});
			} catch (e) {
				console.error(`Error while reading CSS rules from ${sheet.href}`, e);
			}
		});
		return ret;
	});
}
function getWebFontRules(cssRules) {
	return cssRules.filter((rule) => rule.type === CSSRule.FONT_FACE_RULE).filter((rule) => shouldEmbed(rule.style.getPropertyValue("src")));
}
async function parseWebFontRules(node, options) {
	if (node.ownerDocument == null) throw new Error("Provided element is not within a Document");
	return getWebFontRules(await getCSSRules(toArray(node.ownerDocument.styleSheets), options));
}
function normalizeFontFamily(font) {
	return font.trim().replace(/["']/g, "");
}
function getUsedFonts(node) {
	const fonts = /* @__PURE__ */ new Set();
	function traverse(node) {
		(node.style.fontFamily || getComputedStyle(node).fontFamily).split(",").forEach((font) => {
			fonts.add(normalizeFontFamily(font));
		});
		Array.from(node.children).forEach((child) => {
			if (child instanceof HTMLElement) traverse(child);
		});
	}
	traverse(node);
	return fonts;
}
async function getWebFontCSS(node, options) {
	const rules = await parseWebFontRules(node, options);
	const usedFonts = getUsedFonts(node);
	return (await Promise.all(rules.filter((rule) => usedFonts.has(normalizeFontFamily(rule.style.fontFamily))).map((rule) => {
		const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
		return embedResources(rule.cssText, baseUrl, options);
	}))).join("\n");
}
async function embedWebFonts(clonedNode, options) {
	const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS : options.skipFonts ? null : await getWebFontCSS(clonedNode, options);
	if (cssText) {
		const styleNode = document.createElement("style");
		const sytleContent = document.createTextNode(cssText);
		styleNode.appendChild(sytleContent);
		if (clonedNode.firstChild) clonedNode.insertBefore(styleNode, clonedNode.firstChild);
		else clonedNode.appendChild(styleNode);
	}
}
//#endregion
//#region ../../node_modules/html-to-image/es/index.js
async function toSvg(node, options = {}) {
	const { width, height } = getImageSize(node, options);
	const clonedNode = await cloneNode(node, options, true);
	await embedWebFonts(clonedNode, options);
	await embedImages(clonedNode, options);
	applyStyle(clonedNode, options);
	return await nodeToDataURL(clonedNode, width, height);
}
async function toCanvas(node, options = {}) {
	const { width, height } = getImageSize(node, options);
	const img = await createImage(await toSvg(node, options));
	const canvas = document.createElement("canvas");
	const context = canvas.getContext("2d");
	const ratio = options.pixelRatio || getPixelRatio();
	const canvasWidth = options.canvasWidth || width;
	const canvasHeight = options.canvasHeight || height;
	canvas.width = canvasWidth * ratio;
	canvas.height = canvasHeight * ratio;
	if (!options.skipAutoScale) checkCanvasDimensions(canvas);
	canvas.style.width = `${canvasWidth}`;
	canvas.style.height = `${canvasHeight}`;
	if (options.backgroundColor) {
		context.fillStyle = options.backgroundColor;
		context.fillRect(0, 0, canvas.width, canvas.height);
	}
	context.drawImage(img, 0, 0, canvas.width, canvas.height);
	return canvas;
}
async function toPng(node, options = {}) {
	return (await toCanvas(node, options)).toDataURL();
}
//#endregion
//#region src/components/reports/SaveReportChoose.tsx
function SaveReportChoose(t0) {
	const $ = (0, import_compiler_runtime.c)(21);
	const { onApply } = t0;
	const inputRef = (0, import_react.useRef)(null);
	const [err, setErr] = (0, import_react.useState)("");
	const [value, setValue] = (0, import_react.useState)("");
	let t1;
	let t2;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = () => {
			if (inputRef.current) inputRef.current.focus();
		};
		t2 = [];
		$[0] = t1;
		$[1] = t2;
	} else {
		t1 = $[0];
		t2 = $[1];
	}
	(0, import_react.useEffect)(t1, t2);
	let t3;
	if ($[2] !== onApply || $[3] !== value) {
		t3 = (e) => {
			e.preventDefault();
			if (!value) {
				setErr("Invalid report entered");
				return;
			}
			onApply(value);
		};
		$[2] = onApply;
		$[3] = value;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			flexDirection: "row",
			align: "center"
		};
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				userSelect: "none",
				flex: 1
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Choose Report" })
		});
		$[6] = t5;
	} else t5 = $[6];
	let t6;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t4,
			children: [t5, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } })]
		});
		$[7] = t6;
	} else t6 = $[7];
	let t7;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = { marginTop: 10 };
		$[8] = t7;
	} else t7 = $[8];
	let t8;
	if ($[9] !== value) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GenericInput, {
			ref: inputRef,
			field: "report",
			type: "saved",
			value,
			style: t7,
			onChange: setValue
		});
		$[9] = value;
		$[10] = t8;
	} else t8 = $[10];
	let t9;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = {
			marginTop: 15,
			flexDirection: "row",
			justifyContent: "flex-end",
			alignItems: "center"
		};
		$[11] = t9;
	} else t9 = $[11];
	let t10;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t9,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				type: "submit",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Apply" })
			})
		});
		$[12] = t10;
	} else t10 = $[12];
	let t11;
	if ($[13] !== t3 || $[14] !== t8) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)($d3e0e05bdfcf66bd$export$a7fed597f4b8afd8, {
			onSubmit: t3,
			children: [
				t6,
				t8,
				t10
			]
		});
		$[13] = t3;
		$[14] = t8;
		$[15] = t11;
	} else t11 = $[15];
	let t12;
	if ($[16] !== err) {
		t12 = err !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: 10,
				alignItems: "center"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { color: theme.errorText },
				children: err
			})
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {});
		$[16] = err;
		$[17] = t12;
	} else t12 = $[17];
	let t13;
	if ($[18] !== t11 || $[19] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t11, t12] });
		$[18] = t11;
		$[19] = t12;
		$[20] = t13;
	} else t13 = $[20];
	return t13;
}
//#endregion
//#region src/components/reports/SaveReportDelete.tsx
function SaveReportDelete(t0) {
	const $ = (0, import_compiler_runtime.c)(21);
	const { onDelete, onClose, name } = t0;
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = { align: "center" };
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			color: theme.errorText,
			marginBottom: 5
		};
		$[1] = t2;
	} else t2 = $[1];
	let t3;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = { display: "inline" };
		$[2] = t3;
	} else t3 = $[2];
	let t4;
	if ($[3] !== name) {
		t4 = { name };
		$[3] = name;
		$[4] = t4;
	} else t4 = $[4];
	const t5 = t4;
	let t6;
	if ($[5] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t1,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
					"Are you sure you want to delete the report named",
					" '",
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: t3,
						children: t5
					}),
					"'?"
				] })
			})
		});
		$[5] = t5;
		$[6] = t6;
	} else t6 = $[6];
	let t7;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			marginTop: 15,
			justifyContent: "flex-end",
			alignItems: "center"
		};
		$[7] = t7;
	} else t7 = $[7];
	let t8;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } });
		$[8] = t8;
	} else t8 = $[8];
	let t9;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Yes" });
		$[9] = t9;
	} else t9 = $[9];
	let t10;
	if ($[10] !== onDelete) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			autoFocus: true,
			onPress: onDelete,
			children: t9
		});
		$[10] = onDelete;
		$[11] = t10;
	} else t10 = $[11];
	let t11;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No" });
		$[12] = t11;
	} else t11 = $[12];
	let t12;
	if ($[13] !== onClose) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			onPress: onClose,
			children: t11
		});
		$[13] = onClose;
		$[14] = t12;
	} else t12 = $[14];
	let t13;
	if ($[15] !== t10 || $[16] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			style: t7,
			children: [
				t8,
				t10,
				t12
			]
		});
		$[15] = t10;
		$[16] = t12;
		$[17] = t13;
	} else t13 = $[17];
	let t14;
	if ($[18] !== t13 || $[19] !== t6) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t6, t13] });
		$[18] = t13;
		$[19] = t6;
		$[20] = t14;
	} else t14 = $[20];
	return t14;
}
//#endregion
//#region src/components/reports/SaveReportMenu.tsx
function SaveReportMenu(t0) {
	const $ = (0, import_compiler_runtime.c)(32);
	const { onMenuSelect, savedStatus, listReports } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== savedStatus || $[1] !== t) {
		t1 = savedStatus === "saved" ? [
			{
				name: "rename-report",
				text: t("Rename")
			},
			{
				name: "delete-report",
				text: t("Delete")
			},
			Menu.line
		] : [];
		$[0] = savedStatus;
		$[1] = t;
		$[2] = t1;
	} else t1 = $[2];
	const savedMenu = t1;
	let t2;
	if ($[3] !== savedStatus || $[4] !== t) {
		t2 = savedStatus === "modified" ? [
			{
				name: "rename-report",
				text: t("Rename")
			},
			{
				name: "update-report",
				text: t("Update report")
			},
			{
				name: "reload-report",
				text: t("Revert changes")
			},
			{
				name: "delete-report",
				text: t("Delete")
			},
			Menu.line
		] : [];
		$[3] = savedStatus;
		$[4] = t;
		$[5] = t2;
	} else t2 = $[5];
	const modifiedMenu = t2;
	let t3;
	if ($[6] !== t) {
		t3 = t("Save new report");
		$[6] = t;
		$[7] = t3;
	} else t3 = $[7];
	let t4;
	if ($[8] !== t3) {
		t4 = {
			name: "save-report",
			text: t3
		};
		$[8] = t3;
		$[9] = t4;
	} else t4 = $[9];
	let t5;
	if ($[10] !== t) {
		t5 = t("Reset to default");
		$[10] = t;
		$[11] = t5;
	} else t5 = $[11];
	let t6;
	if ($[12] !== t5) {
		t6 = {
			name: "reset-report",
			text: t5
		};
		$[12] = t5;
		$[13] = t6;
	} else t6 = $[13];
	let t7;
	if ($[14] !== t) {
		t7 = t("Choose Report");
		$[14] = t;
		$[15] = t7;
	} else t7 = $[15];
	const t8 = listReports > 0 ? false : true;
	let t9;
	if ($[16] !== t7 || $[17] !== t8) {
		t9 = {
			name: "choose-report",
			text: t7,
			disabled: t8
		};
		$[16] = t7;
		$[17] = t8;
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	if ($[19] !== t4 || $[20] !== t6 || $[21] !== t9) {
		t10 = [
			t4,
			t6,
			Menu.line,
			t9
		];
		$[19] = t4;
		$[20] = t6;
		$[21] = t9;
		$[22] = t10;
	} else t10 = $[22];
	const unsavedMenu = t10;
	let t11;
	if ($[23] !== onMenuSelect) {
		t11 = (item) => {
			onMenuSelect(item);
		};
		$[23] = onMenuSelect;
		$[24] = t11;
	} else t11 = $[24];
	let t12;
	if ($[25] !== modifiedMenu || $[26] !== savedMenu || $[27] !== unsavedMenu) {
		t12 = [
			...savedMenu,
			...modifiedMenu,
			...unsavedMenu
		];
		$[25] = modifiedMenu;
		$[26] = savedMenu;
		$[27] = unsavedMenu;
		$[28] = t12;
	} else t12 = $[28];
	let t13;
	if ($[29] !== t11 || $[30] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t11,
			items: t12
		});
		$[29] = t11;
		$[30] = t12;
		$[31] = t13;
	} else t13 = $[31];
	return t13;
}
//#endregion
//#region src/components/reports/SaveReportName.tsx
function SaveReportName(t0) {
	const $ = (0, import_compiler_runtime.c)(16);
	const { menuItem, name, setName, inputRef, onAddUpdate, err, report } = t0;
	const { t } = useTranslation();
	let t1;
	let t2;
	if ($[0] !== inputRef) {
		t1 = () => {
			if (inputRef.current) inputRef.current.focus();
		};
		t2 = [inputRef];
		$[0] = inputRef;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	(0, import_react.useEffect)(t1, t2);
	let t3;
	if ($[3] !== inputRef || $[4] !== menuItem || $[5] !== name || $[6] !== onAddUpdate || $[7] !== report || $[8] !== setName || $[9] !== t) {
		t3 = menuItem !== "update-report" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)($d3e0e05bdfcf66bd$export$a7fed597f4b8afd8, {
			onSubmit: (e) => {
				e.preventDefault();
				onAddUpdate({
					menuChoice: menuItem ?? void 0,
					reportData: report ?? void 0
				});
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
				style: {
					padding: 15,
					justifyContent: "flex-end",
					alignItems: "center"
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FormField, {
					style: { flex: 1 },
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormLabel, {
						title: t("Report Name"),
						htmlFor: "name-field",
						style: { userSelect: "none" }
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
						value: name,
						id: "name-field",
						ref: inputRef,
						onChangeValue: setName,
						style: { marginTop: 10 }
					})]
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: "primary",
					type: "submit",
					style: { marginTop: 30 },
					children: menuItem === "save-report" ? t("Add") : t("Update")
				})]
			})
		});
		$[3] = inputRef;
		$[4] = menuItem;
		$[5] = name;
		$[6] = onAddUpdate;
		$[7] = report;
		$[8] = setName;
		$[9] = t;
		$[10] = t3;
	} else t3 = $[10];
	let t4;
	if ($[11] !== err) {
		t4 = err !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: 10,
				alignItems: "center"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { color: theme.errorText },
				children: err
			})
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {});
		$[11] = err;
		$[12] = t4;
	} else t4 = $[12];
	let t5;
	if ($[13] !== t3 || $[14] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t3, t4] });
		$[13] = t3;
		$[14] = t4;
		$[15] = t5;
	} else t5 = $[15];
	return t5;
}
//#endregion
//#region src/components/reports/SaveReport.tsx
function SaveReportWrapper(props) {
	const $ = (0, import_compiler_runtime.c)(9);
	const { t } = useTranslation();
	const { data: t0, isPending } = useDashboardPages();
	let t1;
	if ($[0] !== t0) {
		t1 = t0 === void 0 ? [] : t0;
		$[0] = t0;
		$[1] = t1;
	} else t1 = $[1];
	const data = t1;
	if (isPending) {
		let t2;
		if ($[2] !== t) {
			t2 = t("Loading dashboards...");
			$[2] = t;
			$[3] = t2;
		} else t2 = $[3];
		let t3;
		if ($[4] !== t2) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t2 });
			$[4] = t2;
			$[5] = t3;
		} else t3 = $[5];
		return t3;
	}
	let t2;
	if ($[6] !== data || $[7] !== props) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReport, {
			...props,
			dashboardPages: data
		});
		$[6] = data;
		$[7] = props;
		$[8] = t2;
	} else t2 = $[8];
	return t2;
}
function SaveReport(t0) {
	const $ = (0, import_compiler_runtime.c)(86);
	const { customReportItems, report, savedStatus, onReportChange, dashboardPages } = t0;
	const { data: t1 } = useReports();
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const listReports = t2;
	const triggerRef = (0, import_react.useRef)(null);
	const [deleteMenuOpen, setDeleteMenuOpen] = (0, import_react.useState)(false);
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const [menuOpen, setMenuOpen] = (0, import_react.useState)(false);
	const [chooseMenuOpen, setChooseMenuOpen] = (0, import_react.useState)(false);
	const [menuItem, setMenuItem] = (0, import_react.useState)("");
	const [err, setErr] = (0, import_react.useState)("");
	const [newName, setNewName] = (0, import_react.useState)(report.name ?? "");
	let t3;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = (0, import_react.createRef)();
		$[2] = t3;
	} else t3 = $[2];
	const inputRef = t3;
	const { t } = useTranslation();
	const [saveDashboardId, setSaveDashboardId] = (0, import_react.useState)(dashboardPages.length > 0 ? dashboardPages[0].id : null);
	const createReportMutation = useCreateReportMutation();
	const updateReportMutation = useUpdateReportMutation();
	const addDashboardWidgetMutation = useAddDashboardWidgetMutation();
	let t4;
	if ($[3] !== listReports || $[4] !== onReportChange) {
		t4 = async function onApply(cond) {
			const chooseSavedReport = listReports.find((r) => cond === r.id);
			onReportChange({
				savedReport: chooseSavedReport,
				type: "choose"
			});
			setChooseMenuOpen(false);
			setNewName(chooseSavedReport === void 0 ? "" : chooseSavedReport.name);
		};
		$[3] = listReports;
		$[4] = onReportChange;
		$[5] = t4;
	} else t4 = $[5];
	const onApply = t4;
	let t5;
	if ($[6] !== addDashboardWidgetMutation || $[7] !== createReportMutation || $[8] !== customReportItems || $[9] !== newName || $[10] !== onReportChange || $[11] !== report || $[12] !== saveDashboardId || $[13] !== t || $[14] !== updateReportMutation) {
		t5 = async (t6) => {
			const { menuChoice } = t6;
			if (!menuChoice) return null;
			if (menuChoice === "save-report") {
				const newSavedReport = {
					...report,
					...customReportItems,
					name: newName
				};
				if (!saveDashboardId) {
					setErr(t("Please select a dashboard to save the report"));
					return;
				}
				createReportMutation.mutate({ report: newSavedReport }, {
					onSuccess: async (id) => {
						addDashboardWidgetMutation.mutate({ widget: {
							type: "custom-report",
							width: 4,
							height: 2,
							meta: { id },
							dashboard_page_id: saveDashboardId
						} }, { onSuccess: () => {
							setNameMenuOpen(false);
							onReportChange({
								savedReport: {
									...newSavedReport,
									id
								},
								type: "add-update"
							});
						} });
					},
					onError: (error) => {
						setErr(error.message);
						setNameMenuOpen(true);
					}
				});
				return;
			}
			const { name: _name, id: _id, ...props } = customReportItems;
			const updatedReport = {
				...report,
				...menuChoice === "rename-report" ? { name: newName } : props
			};
			updateReportMutation.mutate({ report: updatedReport }, {
				onSuccess: () => {
					setNameMenuOpen(false);
					onReportChange({
						savedReport: updatedReport,
						type: menuChoice === "rename-report" ? "rename" : "add-update"
					});
				},
				onError: (error_0) => {
					setErr(error_0.message);
					setNameMenuOpen(true);
				}
			});
		};
		$[6] = addDashboardWidgetMutation;
		$[7] = createReportMutation;
		$[8] = customReportItems;
		$[9] = newName;
		$[10] = onReportChange;
		$[11] = report;
		$[12] = saveDashboardId;
		$[13] = t;
		$[14] = updateReportMutation;
		$[15] = t5;
	} else t5 = $[15];
	const onAddUpdate = t5;
	const deleteReportMutation = useDeleteReportMutation();
	let t6;
	if ($[16] !== deleteReportMutation || $[17] !== onReportChange || $[18] !== report.id) {
		t6 = async () => {
			deleteReportMutation.mutate({ id: report.id }, { onSuccess: () => {
				setNewName("");
				onReportChange({ type: "reset" });
				setDeleteMenuOpen(false);
			} });
		};
		$[16] = deleteReportMutation;
		$[17] = onReportChange;
		$[18] = report.id;
		$[19] = t6;
	} else t6 = $[19];
	const onDelete = t6;
	let t7;
	if ($[20] !== onAddUpdate || $[21] !== onReportChange) {
		t7 = async (item) => {
			setMenuItem(item);
			bb46: switch (item) {
				case "rename-report":
					setErr("");
					setMenuOpen(false);
					setNameMenuOpen(true);
					break bb46;
				case "delete-report":
					setMenuOpen(false);
					setDeleteMenuOpen(true);
					break bb46;
				case "update-report":
					setErr("");
					setMenuOpen(false);
					onAddUpdate({ menuChoice: item });
					break bb46;
				case "save-report":
					setErr("");
					setMenuOpen(false);
					setNameMenuOpen(true);
					break bb46;
				case "reload-report":
					setMenuOpen(false);
					onReportChange({ type: "reload" });
					break bb46;
				case "reset-report":
					setMenuOpen(false);
					setNewName("");
					onReportChange({ type: "reset" });
					break bb46;
				case "choose-report":
					setErr("");
					setMenuOpen(false);
					setChooseMenuOpen(true);
					break bb46;
				default:
			}
		};
		$[20] = onAddUpdate;
		$[21] = onReportChange;
		$[22] = t7;
	} else t7 = $[22];
	const onMenuSelect = t7;
	let t8;
	if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = {
			flexDirection: "row",
			alignItems: "center"
		};
		$[23] = t8;
	} else t8 = $[23];
	let t9;
	if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = () => {
			setMenuOpen(true);
		};
		$[24] = t9;
	} else t9 = $[24];
	let t10;
	if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = {
			maxWidth: 150,
			whiteSpace: "nowrap",
			overflow: "hidden",
			textOverflow: "ellipsis",
			flexShrink: 0
		};
		$[25] = t10;
	} else t10 = $[25];
	let t11;
	if ($[26] !== report.id || $[27] !== report.name) {
		t11 = !report.id ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Unsaved report" }) : report.name;
		$[26] = report.id;
		$[27] = report.name;
		$[28] = t11;
	} else t11 = $[28];
	let t12;
	if ($[29] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
			style: t10,
			children: [t11, "\xA0"]
		});
		$[29] = t11;
		$[30] = t12;
	} else t12 = $[30];
	let t13;
	if ($[31] !== savedStatus) {
		t13 = savedStatus === "modified" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "(modified)" }), "\xA0"] });
		$[31] = savedStatus;
		$[32] = t13;
	} else t13 = $[32];
	let t14;
	if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgExpandArrow, {
			width: 8,
			height: 8,
			style: { marginRight: 5 }
		});
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== t12 || $[35] !== t13) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t9,
			children: [
				t12,
				t13,
				t14
			]
		});
		$[34] = t12;
		$[35] = t13;
		$[36] = t15;
	} else t15 = $[36];
	let t16;
	let t17;
	if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = () => setMenuOpen(false);
		t17 = { width: 150 };
		$[37] = t16;
		$[38] = t17;
	} else {
		t16 = $[37];
		t17 = $[38];
	}
	const t18 = listReports && listReports.length;
	let t19;
	if ($[39] !== onMenuSelect || $[40] !== savedStatus || $[41] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReportMenu, {
			onMenuSelect,
			savedStatus,
			listReports: t18
		});
		$[39] = onMenuSelect;
		$[40] = savedStatus;
		$[41] = t18;
		$[42] = t19;
	} else t19 = $[42];
	let t20;
	if ($[43] !== menuOpen || $[44] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			isOpen: menuOpen,
			onOpenChange: t16,
			style: t17,
			children: t19
		});
		$[43] = menuOpen;
		$[44] = t19;
		$[45] = t20;
	} else t20 = $[45];
	let t21;
	let t22;
	if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = () => setNameMenuOpen(false);
		t22 = { width: 325 };
		$[46] = t21;
		$[47] = t22;
	} else {
		t21 = $[46];
		t22 = $[47];
	}
	let t23;
	if ($[48] !== err || $[49] !== menuItem || $[50] !== newName || $[51] !== onAddUpdate) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReportName, {
			menuItem,
			name: newName,
			setName: setNewName,
			inputRef,
			onAddUpdate,
			err
		});
		$[48] = err;
		$[49] = menuItem;
		$[50] = newName;
		$[51] = onAddUpdate;
		$[52] = t23;
	} else t23 = $[52];
	let t24;
	if ($[53] !== dashboardPages || $[54] !== menuItem || $[55] !== saveDashboardId || $[56] !== t) {
		t24 = menuItem === "save-report" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpaceBetween, {
			style: {
				padding: 15,
				justifyContent: "flex-end",
				alignItems: "center"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FormField, {
				style: { flex: 1 },
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormLabel, {
					title: t("Dashboard"),
					htmlFor: "dashboard-select",
					style: { userSelect: "none" }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
					id: "dashboard-select",
					value: saveDashboardId,
					onChange: (v) => setSaveDashboardId(v),
					defaultLabel: t("None"),
					options: dashboardPages.map(_temp$9),
					style: {
						marginTop: 10,
						width: 300
					}
				})]
			})
		}) });
		$[53] = dashboardPages;
		$[54] = menuItem;
		$[55] = saveDashboardId;
		$[56] = t;
		$[57] = t24;
	} else t24 = $[57];
	let t25;
	if ($[58] !== t23 || $[59] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t23, t24] });
		$[58] = t23;
		$[59] = t24;
		$[60] = t25;
	} else t25 = $[60];
	let t26;
	if ($[61] !== nameMenuOpen || $[62] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			isOpen: nameMenuOpen,
			onOpenChange: t21,
			style: t22,
			children: t25
		});
		$[61] = nameMenuOpen;
		$[62] = t25;
		$[63] = t26;
	} else t26 = $[63];
	let t27;
	let t28;
	if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
		t27 = () => setChooseMenuOpen(false);
		t28 = { padding: 15 };
		$[64] = t27;
		$[65] = t28;
	} else {
		t27 = $[64];
		t28 = $[65];
	}
	let t29;
	if ($[66] !== onApply) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReportChoose, { onApply });
		$[66] = onApply;
		$[67] = t29;
	} else t29 = $[67];
	let t30;
	if ($[68] !== chooseMenuOpen || $[69] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			isOpen: chooseMenuOpen,
			onOpenChange: t27,
			style: t28,
			children: t29
		});
		$[68] = chooseMenuOpen;
		$[69] = t29;
		$[70] = t30;
	} else t30 = $[70];
	let t31;
	let t32;
	if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = () => setDeleteMenuOpen(false);
		t32 = {
			width: 275,
			padding: 15
		};
		$[71] = t31;
		$[72] = t32;
	} else {
		t31 = $[71];
		t32 = $[72];
	}
	let t33;
	if ($[73] === Symbol.for("react.memo_cache_sentinel")) {
		t33 = () => setDeleteMenuOpen(false);
		$[73] = t33;
	} else t33 = $[73];
	let t34;
	if ($[74] !== onDelete || $[75] !== report.name) {
		t34 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReportDelete, {
			onDelete,
			onClose: t33,
			name: report.name
		});
		$[74] = onDelete;
		$[75] = report.name;
		$[76] = t34;
	} else t34 = $[76];
	let t35;
	if ($[77] !== deleteMenuOpen || $[78] !== t34) {
		t35 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			isOpen: deleteMenuOpen,
			onOpenChange: t31,
			style: t32,
			children: t34
		});
		$[77] = deleteMenuOpen;
		$[78] = t34;
		$[79] = t35;
	} else t35 = $[79];
	let t36;
	if ($[80] !== t15 || $[81] !== t20 || $[82] !== t26 || $[83] !== t30 || $[84] !== t35) {
		t36 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t8,
			children: [
				t15,
				t20,
				t26,
				t30,
				t35
			]
		});
		$[80] = t15;
		$[81] = t20;
		$[82] = t26;
		$[83] = t30;
		$[84] = t35;
		$[85] = t36;
	} else t36 = $[85];
	return t36;
}
function _temp$9(d) {
	return [d.id, d.name];
}
//#endregion
//#region src/components/reports/SnapshotButton.tsx
function SnapshotButton(t0) {
	const $ = (0, import_compiler_runtime.c)(16);
	const { selected, children, style, onSelect, title } = t0;
	let t1;
	if ($[0] !== title) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: title });
		$[0] = title;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			...styles.tooltip,
			lineHeight: 1.5,
			padding: "6px 10px"
		};
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] !== selected) {
		t3 = selected && { backgroundColor: theme.buttonBareBackgroundHover };
		$[3] = selected;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== style || $[6] !== t3) {
		t4 = {
			...t3,
			...style
		};
		$[5] = style;
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== children || $[9] !== onSelect || $[10] !== t4 || $[11] !== title) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "bare",
			style: t4,
			onPress: onSelect,
			"aria-label": title,
			children
		});
		$[8] = children;
		$[9] = onSelect;
		$[10] = t4;
		$[11] = title;
		$[12] = t5;
	} else t5 = $[12];
	let t6;
	if ($[13] !== t1 || $[14] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
			placement: "bottom start",
			content: t1,
			style: t2,
			children: t5
		});
		$[13] = t1;
		$[14] = t5;
		$[15] = t6;
	} else t6 = $[15];
	return t6;
}
//#endregion
//#region src/components/reports/ReportTopbar.tsx
function ReportTopbar(t0) {
	const $ = (0, import_compiler_runtime.c)(150);
	const { customReportItems, report, savedStatus, setGraphType, viewLegend, viewSummary, viewLabels, onApplyFilter, onChangeViews, onReportChange, isItemDisabled, defaultItems } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== defaultItems || $[1] !== onReportChange || $[2] !== setGraphType) {
		t1 = (cond) => {
			setSessionReport("graphType", cond);
			onReportChange({ type: "modify" });
			setGraphType(cond);
			defaultItems(cond);
		};
		$[0] = defaultItems;
		$[1] = onReportChange;
		$[2] = setGraphType;
		$[3] = t1;
	} else t1 = $[3];
	const onChangeGraph = t1;
	let t2;
	if ($[4] !== report.name) {
		t2 = async () => {
			const reportElement = document.getElementById("custom-report-content");
			const title = report.name;
			if (reportElement) {
				const dataUrl = await toPng(reportElement);
				const link = document.createElement("a");
				link.href = dataUrl;
				link.download = `${currentDay()} - ${title}.png`;
				link.click();
			} else console.error("Report container not found.");
		};
		$[4] = report.name;
		$[5] = t2;
	} else t2 = $[5];
	const downloadSnapshot = t2;
	let t3;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			flexDirection: "row",
			alignItems: "center",
			marginBottom: 10,
			flexShrink: 0,
			overflowY: "auto"
		};
		$[6] = t3;
	} else t3 = $[6];
	const t4 = customReportItems.graphType === "TableGraph";
	let t5;
	if ($[7] !== t) {
		t5 = t("Data Table");
		$[7] = t;
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] !== onChangeGraph) {
		t6 = () => {
			onChangeGraph("TableGraph");
		};
		$[9] = onChangeGraph;
		$[10] = t6;
	} else t6 = $[10];
	let t7;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = { marginRight: 15 };
		$[11] = t7;
	} else t7 = $[11];
	let t8;
	if ($[12] !== isItemDisabled) {
		t8 = isItemDisabled("TableGraph");
		$[12] = isItemDisabled;
		$[13] = t8;
	} else t8 = $[13];
	let t9;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgQueue, {
			width: 15,
			height: 15
		});
		$[14] = t9;
	} else t9 = $[14];
	let t10;
	if ($[15] !== t4 || $[16] !== t5 || $[17] !== t6 || $[18] !== t8) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: t4,
			title: t5,
			onSelect: t6,
			style: t7,
			disabled: t8,
			children: t9
		});
		$[15] = t4;
		$[16] = t5;
		$[17] = t6;
		$[18] = t8;
		$[19] = t10;
	} else t10 = $[19];
	let t11;
	if ($[20] !== customReportItems.mode || $[21] !== t) {
		t11 = customReportItems.mode === "total" ? t("Bar Graph") : t("Stacked Bar Graph");
		$[20] = customReportItems.mode;
		$[21] = t;
		$[22] = t11;
	} else t11 = $[22];
	const t12 = customReportItems.graphType === "BarGraph" || customReportItems.graphType === "StackedBarGraph";
	let t13;
	if ($[23] !== customReportItems.mode || $[24] !== onChangeGraph) {
		t13 = () => {
			onChangeGraph(customReportItems.mode === "total" ? "BarGraph" : "StackedBarGraph");
		};
		$[23] = customReportItems.mode;
		$[24] = onChangeGraph;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = { marginRight: 15 };
		$[26] = t14;
	} else t14 = $[26];
	const t15 = customReportItems.mode === "total" ? "BarGraph" : "StackedBarGraph";
	let t16;
	if ($[27] !== isItemDisabled || $[28] !== t15) {
		t16 = isItemDisabled(t15);
		$[27] = isItemDisabled;
		$[28] = t15;
		$[29] = t16;
	} else t16 = $[29];
	let t17;
	if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChartBar, {
			width: 15,
			height: 15
		});
		$[30] = t17;
	} else t17 = $[30];
	let t18;
	if ($[31] !== t11 || $[32] !== t12 || $[33] !== t13 || $[34] !== t16) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			title: t11,
			selected: t12,
			onSelect: t13,
			style: t14,
			disabled: t16,
			children: t17
		});
		$[31] = t11;
		$[32] = t12;
		$[33] = t13;
		$[34] = t16;
		$[35] = t18;
	} else t18 = $[35];
	let t19;
	if ($[36] !== t) {
		t19 = t("Line Graph");
		$[36] = t;
		$[37] = t19;
	} else t19 = $[37];
	const t20 = customReportItems.graphType === "LineGraph";
	let t21;
	if ($[38] !== onChangeGraph) {
		t21 = () => {
			onChangeGraph("LineGraph");
		};
		$[38] = onChangeGraph;
		$[39] = t21;
	} else t21 = $[39];
	let t22;
	if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = { marginRight: 15 };
		$[40] = t22;
	} else t22 = $[40];
	let t23;
	if ($[41] !== isItemDisabled) {
		t23 = isItemDisabled("LineGraph");
		$[41] = isItemDisabled;
		$[42] = t23;
	} else t23 = $[42];
	let t24;
	if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChart, {
			width: 15,
			height: 15
		});
		$[43] = t24;
	} else t24 = $[43];
	let t25;
	if ($[44] !== t19 || $[45] !== t20 || $[46] !== t21 || $[47] !== t23) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			title: t19,
			selected: t20,
			onSelect: t21,
			style: t22,
			disabled: t23,
			children: t24
		});
		$[44] = t19;
		$[45] = t20;
		$[46] = t21;
		$[47] = t23;
		$[48] = t25;
	} else t25 = $[48];
	let t26;
	if ($[49] !== t) {
		t26 = t("Area Graph");
		$[49] = t;
		$[50] = t26;
	} else t26 = $[50];
	const t27 = customReportItems.graphType === "AreaGraph";
	let t28;
	if ($[51] !== onChangeGraph) {
		t28 = () => {
			onChangeGraph("AreaGraph");
		};
		$[51] = onChangeGraph;
		$[52] = t28;
	} else t28 = $[52];
	let t29;
	if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
		t29 = { marginRight: 15 };
		$[53] = t29;
	} else t29 = $[53];
	let t30;
	if ($[54] !== isItemDisabled) {
		t30 = isItemDisabled("AreaGraph");
		$[54] = isItemDisabled;
		$[55] = t30;
	} else t30 = $[55];
	let t31;
	if ($[56] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChartArea, {
			width: 15,
			height: 15
		});
		$[56] = t31;
	} else t31 = $[56];
	let t32;
	if ($[57] !== t26 || $[58] !== t27 || $[59] !== t28 || $[60] !== t30) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			title: t26,
			selected: t27,
			onSelect: t28,
			style: t29,
			disabled: t30,
			children: t31
		});
		$[57] = t26;
		$[58] = t27;
		$[59] = t28;
		$[60] = t30;
		$[61] = t32;
	} else t32 = $[61];
	let t33;
	if ($[62] !== t) {
		t33 = t("Donut Graph");
		$[62] = t;
		$[63] = t33;
	} else t33 = $[63];
	const t34 = customReportItems.graphType === "DonutGraph";
	let t35;
	if ($[64] !== onChangeGraph) {
		t35 = () => {
			onChangeGraph("DonutGraph");
		};
		$[64] = onChangeGraph;
		$[65] = t35;
	} else t35 = $[65];
	let t36;
	if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
		t36 = { marginRight: 15 };
		$[66] = t36;
	} else t36 = $[66];
	let t37;
	if ($[67] !== isItemDisabled) {
		t37 = isItemDisabled("DonutGraph");
		$[67] = isItemDisabled;
		$[68] = t37;
	} else t37 = $[68];
	let t38;
	if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
		t38 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChartPie, {
			width: 15,
			height: 15
		});
		$[69] = t38;
	} else t38 = $[69];
	let t39;
	if ($[70] !== t33 || $[71] !== t34 || $[72] !== t35 || $[73] !== t37) {
		t39 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			title: t33,
			selected: t34,
			onSelect: t35,
			style: t36,
			disabled: t37,
			children: t38
		});
		$[70] = t33;
		$[71] = t34;
		$[72] = t35;
		$[73] = t37;
		$[74] = t39;
	} else t39 = $[74];
	let t40;
	if ($[75] === Symbol.for("react.memo_cache_sentinel")) {
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			width: 1,
			height: 30,
			backgroundColor: theme.pillBorderDark,
			marginRight: 15,
			flexShrink: 0
		} });
		$[75] = t40;
	} else t40 = $[75];
	let t41;
	if ($[76] !== onChangeViews) {
		t41 = () => {
			onChangeViews("viewLegend");
		};
		$[76] = onChangeViews;
		$[77] = t41;
	} else t41 = $[77];
	let t42;
	if ($[78] === Symbol.for("react.memo_cache_sentinel")) {
		t42 = { marginRight: 15 };
		$[78] = t42;
	} else t42 = $[78];
	let t43;
	if ($[79] !== t) {
		t43 = t("Show Legend");
		$[79] = t;
		$[80] = t43;
	} else t43 = $[80];
	let t44;
	if ($[81] !== isItemDisabled) {
		t44 = isItemDisabled("ShowLegend");
		$[81] = isItemDisabled;
		$[82] = t44;
	} else t44 = $[82];
	let t45;
	if ($[83] === Symbol.for("react.memo_cache_sentinel")) {
		t45 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgListBullet, {
			width: 15,
			height: 15
		});
		$[83] = t45;
	} else t45 = $[83];
	let t46;
	if ($[84] !== t41 || $[85] !== t43 || $[86] !== t44 || $[87] !== viewLegend) {
		t46 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: viewLegend,
			onSelect: t41,
			style: t42,
			title: t43,
			disabled: t44,
			children: t45
		});
		$[84] = t41;
		$[85] = t43;
		$[86] = t44;
		$[87] = viewLegend;
		$[88] = t46;
	} else t46 = $[88];
	let t47;
	if ($[89] !== onChangeViews) {
		t47 = () => {
			onChangeViews("viewSummary");
		};
		$[89] = onChangeViews;
		$[90] = t47;
	} else t47 = $[90];
	let t48;
	if ($[91] === Symbol.for("react.memo_cache_sentinel")) {
		t48 = { marginRight: 15 };
		$[91] = t48;
	} else t48 = $[91];
	let t49;
	if ($[92] !== t) {
		t49 = t("Show Summary");
		$[92] = t;
		$[93] = t49;
	} else t49 = $[93];
	let t50;
	if ($[94] === Symbol.for("react.memo_cache_sentinel")) {
		t50 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCalculator, {
			width: 15,
			height: 15
		});
		$[94] = t50;
	} else t50 = $[94];
	let t51;
	if ($[95] !== t47 || $[96] !== t49 || $[97] !== viewSummary) {
		t51 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: viewSummary,
			onSelect: t47,
			style: t48,
			title: t49,
			children: t50
		});
		$[95] = t47;
		$[96] = t49;
		$[97] = viewSummary;
		$[98] = t51;
	} else t51 = $[98];
	let t52;
	if ($[99] !== onChangeViews) {
		t52 = () => {
			onChangeViews("viewLabels");
		};
		$[99] = onChangeViews;
		$[100] = t52;
	} else t52 = $[100];
	let t53;
	if ($[101] === Symbol.for("react.memo_cache_sentinel")) {
		t53 = { marginRight: 15 };
		$[101] = t53;
	} else t53 = $[101];
	let t54;
	if ($[102] !== t) {
		t54 = t("Show Labels");
		$[102] = t;
		$[103] = t54;
	} else t54 = $[103];
	let t55;
	if ($[104] !== isItemDisabled) {
		t55 = isItemDisabled("ShowLabels");
		$[104] = isItemDisabled;
		$[105] = t55;
	} else t55 = $[105];
	let t56;
	if ($[106] === Symbol.for("react.memo_cache_sentinel")) {
		t56 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTag, {
			width: 15,
			height: 15
		});
		$[106] = t56;
	} else t56 = $[106];
	let t57;
	if ($[107] !== t52 || $[108] !== t54 || $[109] !== t55 || $[110] !== viewLabels) {
		t57 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphButton, {
			selected: viewLabels,
			onSelect: t52,
			style: t53,
			title: t54,
			disabled: t55,
			children: t56
		});
		$[107] = t52;
		$[108] = t54;
		$[109] = t55;
		$[110] = viewLabels;
		$[111] = t57;
	} else t57 = $[111];
	let t58;
	if ($[112] === Symbol.for("react.memo_cache_sentinel")) {
		t58 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			width: 1,
			height: 30,
			backgroundColor: theme.pillBorderDark,
			marginRight: 15,
			flexShrink: 0
		} });
		$[112] = t58;
	} else t58 = $[112];
	let t59;
	if ($[113] === Symbol.for("react.memo_cache_sentinel")) {
		t59 = { marginRight: 15 };
		$[113] = t59;
	} else t59 = $[113];
	let t60;
	if ($[114] !== t) {
		t60 = t("Download Snapshot");
		$[114] = t;
		$[115] = t60;
	} else t60 = $[115];
	let t61;
	if ($[116] === Symbol.for("react.memo_cache_sentinel")) {
		t61 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCamera, {
			width: 15,
			height: 15
		});
		$[116] = t61;
	} else t61 = $[116];
	let t62;
	if ($[117] !== downloadSnapshot || $[118] !== t60) {
		t62 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SnapshotButton, {
			style: t59,
			title: t60,
			onSelect: downloadSnapshot,
			children: t61
		});
		$[117] = downloadSnapshot;
		$[118] = t60;
		$[119] = t62;
	} else t62 = $[119];
	let t63;
	if ($[120] === Symbol.for("react.memo_cache_sentinel")) {
		t63 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
			width: 1,
			height: 30,
			backgroundColor: theme.pillBorderDark,
			marginRight: 15,
			flexShrink: 0
		} });
		$[120] = t63;
	} else t63 = $[120];
	let t64;
	if ($[121] === Symbol.for("react.memo_cache_sentinel")) {
		t64 = {
			flexWrap: "nowrap",
			justifyContent: "space-between",
			flex: 1
		};
		$[121] = t64;
	} else t64 = $[121];
	let t65;
	if ($[122] !== customReportItems.conditions || $[123] !== onApplyFilter || $[124] !== onReportChange) {
		t65 = (e) => {
			setSessionReport("conditions", [...customReportItems.conditions ?? [], e]);
			onApplyFilter(e);
			onReportChange({ type: "modify" });
		};
		$[122] = customReportItems.conditions;
		$[123] = onApplyFilter;
		$[124] = onReportChange;
		$[125] = t65;
	} else t65 = $[125];
	let t66;
	if ($[126] !== customReportItems.balanceType) {
		t66 = customReportItems.balanceType === "Budgeted" ? [
			"date",
			"account",
			"payee",
			"notes",
			"amount",
			"cleared",
			"reconciled",
			"transfer",
			"saved"
		] : [];
		$[126] = customReportItems.balanceType;
		$[127] = t66;
	} else t66 = $[127];
	let t67;
	if ($[128] !== t65 || $[129] !== t66) {
		t67 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterButton, {
			compact: true,
			hover: true,
			onApply: t65,
			exclude: t66
		});
		$[128] = t65;
		$[129] = t66;
		$[130] = t67;
	} else t67 = $[130];
	let t68;
	if ($[131] !== customReportItems || $[132] !== onReportChange || $[133] !== report || $[134] !== savedStatus) {
		t68 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SaveReportWrapper, {
			customReportItems,
			report,
			savedStatus,
			onReportChange
		});
		$[131] = customReportItems;
		$[132] = onReportChange;
		$[133] = report;
		$[134] = savedStatus;
		$[135] = t68;
	} else t68 = $[135];
	let t69;
	if ($[136] !== t67 || $[137] !== t68) {
		t69 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			style: t64,
			children: [t67, t68]
		});
		$[136] = t67;
		$[137] = t68;
		$[138] = t69;
	} else t69 = $[138];
	let t70;
	if ($[139] !== t10 || $[140] !== t18 || $[141] !== t25 || $[142] !== t32 || $[143] !== t39 || $[144] !== t46 || $[145] !== t51 || $[146] !== t57 || $[147] !== t62 || $[148] !== t69) {
		t70 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t3,
			children: [
				t10,
				t18,
				t25,
				t32,
				t39,
				t40,
				t46,
				t51,
				t57,
				t58,
				t62,
				t63,
				t69
			]
		});
		$[139] = t10;
		$[140] = t18;
		$[141] = t25;
		$[142] = t32;
		$[143] = t39;
		$[144] = t46;
		$[145] = t51;
		$[146] = t57;
		$[147] = t62;
		$[148] = t69;
		$[149] = t70;
	} else t70 = $[149];
	return t70;
}
//#endregion
//#region src/components/reports/spreadsheets/calculateLegend.ts
function calculateLegend(intervalData, calcDataFiltered, groupBy, graphType, balanceTypeOp) {
	const colorScale = getColorScale("qualitative");
	const chooseData = groupBy === "Interval" ? intervalData.map((c) => {
		return {
			name: c.date,
			id: null,
			data: c
		};
	}) : calcDataFiltered.map((c) => {
		return {
			name: c.name,
			id: c.id,
			data: c
		};
	});
	function getColor(data, index) {
		if (graphType === "DonutGraph") return colorScale[index % colorScale.length];
		if (groupBy === "Interval") {
			if (balanceTypeOp === "totalDebts") return theme.reportsNumberNegative;
			if (balanceTypeOp === "netDebts") return theme.reportsNumberNegative;
			if (balanceTypeOp === "totalTotals" || balanceTypeOp === "totalBudgeted") {
				if ((balanceTypeOp === "totalBudgeted" ? data.totalBudgeted : data.totalTotals) < 0) return theme.reportsNumberNegative;
				return theme.reportsNumberPositive;
			}
			if (balanceTypeOp === "totalAssets" || balanceTypeOp === "netAssets") return theme.reportsNumberPositive;
			return theme.reportsChartFill;
		}
		return colorScale[index % colorScale.length];
	}
	return chooseData.map((item, index) => {
		return {
			id: item.id || "",
			name: item.name || "",
			color: getColor(item.data, index),
			dataKey: item.id || item.name || ""
		};
	});
}
//#endregion
//#region src/components/reports/spreadsheets/budgetDataQuery.ts
async function mapWithConcurrency(items, concurrency, mapper) {
	if (items.length === 0) return [];
	const results = new Array(items.length);
	const safeConcurrency = Math.max(1, Math.min(concurrency, items.length));
	let nextIndex = 0;
	const workers = Array.from({ length: safeConcurrency }, async () => {
		while (true) {
			const currentIndex = nextIndex;
			nextIndex += 1;
			if (currentIndex >= items.length) return;
			results[currentIndex] = await mapper(items[currentIndex], currentIndex);
		}
	});
	await Promise.all(workers);
	return results;
}
function filterCategoriesByConditions(categories, categoryGroups, conditions, conditionsOp) {
	if (!conditions || conditions.length === 0) return categories;
	const categoryConditions = conditions.filter((cond) => !cond.customName && (cond.field === "category" || cond.field === "category_group"));
	if (categoryConditions.length === 0) return categories;
	const categoryGroupNameById = new Map(categoryGroups.map((group) => [group.id, group.name]));
	const isSupportedCondition = (condition) => {
		if (condition.op === "is" || condition.op === "isNot") return typeof condition.value === "string";
		if (condition.op === "oneOf" || condition.op === "notOneOf") return Array.isArray(condition.value) && condition.value.every((id) => typeof id === "string");
		if (condition.op === "contains" || condition.op === "doesNotContain" || condition.op === "matches") return typeof condition.value === "string";
		return false;
	};
	if (!categoryConditions.every(isSupportedCondition)) return categories;
	const evaluateCondition = (category, condition) => {
		const key = condition.field === "category_group" ? category.group ?? "" : category.id;
		const textValue = condition.field === "category_group" ? categoryGroupNameById.get(key) ?? key : category.name;
		if (condition.op === "is") return key === condition.value;
		if (condition.op === "isNot") return key !== condition.value;
		if (condition.op === "oneOf") return condition.value.includes(key);
		if (condition.op === "notOneOf") return !condition.value.includes(key);
		if (condition.op === "contains") return typeof condition.value === "string" && textValue.toLowerCase().includes(condition.value.toLowerCase());
		if (condition.op === "doesNotContain") return typeof condition.value === "string" && !textValue.toLowerCase().includes(condition.value.toLowerCase());
		if (condition.op === "matches" && typeof condition.value === "string" && condition.value.length <= 256) try {
			return new RegExp(condition.value, "i").test(textValue);
		} catch {
			return false;
		}
		return true;
	};
	const op = conditionsOp === "or" ? "or" : "and";
	return categories.filter((cat) => op === "or" ? categoryConditions.some((cond) => evaluateCondition(cat, cond)) : categoryConditions.every((cond) => evaluateCondition(cat, cond)));
}
async function fetchBudgetData({ startDate, endDate, interval, categories, categoryGroups, conditions, conditionsOp, budgetType = "envelope" }) {
	const groupById = new Map(categoryGroups.map((g) => [g.id, g]));
	const assets = [];
	const debts = [];
	const filteredCategories = filterCategoriesByConditions(categories, categoryGroups, conditions, conditionsOp);
	const months = rangeInclusive(getMonth(startDate), getMonth(endDate));
	const monthFetchConcurrency = 8;
	const endpointName = budgetType === "tracking" ? "tracking-budget-month" : "envelope-budget-month";
	const monthDataList = await mapWithConcurrency(months, monthFetchConcurrency, async (month) => ({
		month,
		monthData: await send(endpointName, { month })
	}));
	for (const { month, monthData } of monthDataList) {
		const dateKey = interval === "Yearly" ? month.slice(0, 4) : month;
		for (const cat of filteredCategories) {
			if (cat.is_income) continue;
			const budgetCell = monthData.find((cell) => cell.name.endsWith(`budget-${cat.id}`));
			const amount = Number(budgetCell?.value) || 0;
			if (amount === 0) continue;
			const group = cat.group ? groupById.get(cat.group) : void 0;
			const entry = {
				date: dateKey,
				category: cat.id,
				categoryHidden: cat.hidden ?? false,
				categoryGroup: cat.group ?? "",
				categoryGroupHidden: group?.hidden ?? false,
				account: "",
				accountOffBudget: false,
				payee: "",
				transferAccount: "",
				amount
			};
			if (amount > 0) assets.push(entry);
			else debts.push(entry);
		}
	}
	return {
		assets,
		debts
	};
}
//#endregion
//#region src/components/reports/spreadsheets/makeQuery.ts
function makeQuery(name, startDate, endDate, interval, conditionsOpKey, filters) {
	const intervalGroup = interval === "Monthly" ? { $month: "$date" } : interval === "Yearly" ? { $year: "$date" } : { $day: "$date" };
	const intervalFilter = interval === "Weekly" ? "$day" : "$" + ReportOptions.intervalMap.get(interval)?.toLowerCase() || "month";
	return q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({ $and: [{ date: {
		$transform: intervalFilter,
		$gte: startDate
	} }, { date: {
		$transform: intervalFilter,
		$lte: endDate
	} }] }).filter(name === "assets" ? { amount: { $gt: 0 } } : { amount: { $lt: 0 } }).groupBy([
		intervalGroup,
		{ $id: "$account" },
		{ $id: "$payee" },
		{ $id: "$category" },
		{ $id: "$payee.transfer_acct.id" }
	]).select([
		{ date: intervalGroup },
		{ category: { $id: "$category.id" } },
		{ categoryHidden: { $id: "$category.hidden" } },
		{ categoryIncome: { $id: "$category.is_income" } },
		{ categoryGroup: { $id: "$category.group.id" } },
		{ categoryGroupHidden: { $id: "$category.group.hidden" } },
		{ account: { $id: "$account.id" } },
		{ accountOffBudget: { $id: "$account.offbudget" } },
		{ payee: { $id: "$payee.id" } },
		{ transferAccount: { $id: "$payee.transfer_acct.id" } },
		{ amount: { $sum: "$amount" } }
	]);
}
//#endregion
//#region src/components/reports/spreadsheets/fetchSpreadsheetQueryData.ts
async function fetchSpreadsheetQueryData({ balanceTypeOp, startDate, endDate, interval, categories, categoryGroups, conditions, conditionsOp, conditionsOpKey, filters, budgetType }) {
	if (balanceTypeOp === "totalBudgeted") return fetchBudgetData({
		startDate,
		endDate,
		interval,
		categories,
		categoryGroups,
		conditions,
		conditionsOp: conditionsOp === "or" ? "or" : "and",
		budgetType
	});
	const [assets, debts] = await Promise.all([aqlQuery(makeQuery("assets", startDate, endDate, interval, conditionsOpKey, filters)).then(({ data }) => data), aqlQuery(makeQuery("debts", startDate, endDate, interval, conditionsOpKey, filters)).then(({ data }) => data)]);
	return {
		assets,
		debts
	};
}
//#endregion
//#region src/components/reports/spreadsheets/filterEmptyRows.ts
function filterEmptyRows({ showEmpty, data, balanceTypeOp = "totalDebts" }) {
	let showHide;
	if (balanceTypeOp === "totalTotals" || balanceTypeOp === "totalBudgeted") showHide = data["totalDebts"] !== 0 || data["totalAssets"] !== 0 || data[balanceTypeOp] !== 0;
	else showHide = data[balanceTypeOp] !== 0;
	return !showEmpty ? showHide : true;
}
//#endregion
//#region src/components/reports/spreadsheets/filterHiddenItems.ts
function filterHiddenItems(item, data, showOffBudget, showHiddenCategories, showUncategorized, groupByCategory) {
	return data.filter((e) => showHiddenCategories || e.categoryHidden === false && e.categoryGroupHidden === false).filter((e) => showOffBudget || e.accountOffBudget === false).filter((e) => showUncategorized || e.category !== null || e.accountOffBudget === true).filter((query) => {
		if (!groupByCategory) return true;
		const hasCategory = !!query.category;
		const isOffBudget = query.accountOffBudget;
		const isTransfer = !!query.transferAccount;
		if (hasCategory && !isOffBudget) return item.uncategorized_id == null;
		switch (item.uncategorized_id) {
			case "off_budget": return isOffBudget;
			case "transfer": return isTransfer && !isOffBudget;
			case "other": return !isOffBudget && !isTransfer;
			case "all": return true;
			default: return false;
		}
	});
}
//#endregion
//#region src/components/reports/spreadsheets/recalculate.ts
function recalculate$1({ item, intervals, assets, debts, groupByLabel, showOffBudget, showHiddenCategories, showUncategorized, startDate, endDate }) {
	let totalAssets = 0;
	let totalDebts = 0;
	const intervalData = intervals.reduce((arr, intervalItem, index) => {
		const last = arr.length === 0 ? null : arr[arr.length - 1];
		const groupsByCategory = groupByLabel === "category" || groupByLabel === "categoryGroup";
		const intervalAssets = filterHiddenItems(item, assets, showOffBudget, showHiddenCategories, showUncategorized, groupsByCategory).filter((asset) => asset.date === intervalItem && (asset[groupByLabel] === (item.id ?? null) || item.uncategorized_id && groupsByCategory)).reduce((a, v) => a + v.amount, 0);
		totalAssets += intervalAssets;
		const intervalDebts = filterHiddenItems(item, debts, showOffBudget, showHiddenCategories, showUncategorized, groupsByCategory).filter((debt) => debt.date === intervalItem && (debt[groupByLabel] === (item.id ?? null) || item.uncategorized_id && groupsByCategory)).reduce((a, v) => a + v.amount, 0);
		totalDebts += intervalDebts;
		const intervalTotals = intervalAssets + intervalDebts;
		const change = last ? intervalTotals - last.totalTotals : 0;
		arr.push({
			totalAssets: intervalAssets,
			totalDebts: intervalDebts,
			netAssets: intervalTotals > 0 ? intervalTotals : 0,
			netDebts: intervalTotals < 0 ? intervalTotals : 0,
			totalTotals: intervalTotals,
			totalBudgeted: intervalTotals,
			change,
			intervalStartDate: index === 0 ? startDate : intervalItem,
			intervalEndDate: index + 1 === intervals.length ? endDate : subDays(intervals[index + 1], 1)
		});
		return arr;
	}, []);
	const totalTotals = totalAssets + totalDebts;
	return {
		id: item.id || "",
		name: item.name,
		totalAssets,
		totalDebts,
		netAssets: totalTotals > 0 ? totalTotals : 0,
		netDebts: totalTotals < 0 ? totalTotals : 0,
		totalTotals,
		totalBudgeted: totalTotals,
		intervalData
	};
}
//#endregion
//#region src/components/reports/spreadsheets/sortData.ts
var reverseSort = {
	asc: "desc",
	desc: "asc"
};
var balanceTypesToReverse = ["totalDebts", "netDebts"];
var shouldReverse = (balanceTypeOp) => balanceTypesToReverse.includes(balanceTypeOp);
function sortData({ balanceTypeOp, sortByOp }) {
	if (!balanceTypeOp || !sortByOp) return () => 0;
	if (shouldReverse(balanceTypeOp)) sortByOp = reverseSort[sortByOp] ?? sortByOp;
	return (a, b) => {
		let comparison = 0;
		if (sortByOp === "asc") comparison = a[balanceTypeOp] - b[balanceTypeOp];
		else if (sortByOp === "desc") comparison = b[balanceTypeOp] - a[balanceTypeOp];
		else if (sortByOp === "name") comparison = (a.name ?? "").localeCompare(b.name ?? "");
		else if (sortByOp === "budget") comparison = 0;
		return comparison;
	};
}
//#endregion
//#region src/components/reports/spreadsheets/trimIntervals.ts
function isEmptyForMetric(interval, metric) {
	switch (metric) {
		case "totalAssets": return interval.totalAssets === 0;
		case "totalDebts": return interval.totalDebts === 0;
		case "netAssets": return interval.netAssets === 0;
		case "netDebts": return interval.netDebts === 0;
		case "totalTotals": return interval.totalTotals === 0;
		case "totalBudgeted": return interval.totalBudgeted === 0;
		default: return interval.totalTotals === 0;
	}
}
function determineIntervalRange(data, intervalData, trimIntervals, balanceTypeOp = "totalTotals") {
	if (!trimIntervals || intervalData.length === 0) return {
		startIndex: 0,
		endIndex: intervalData.length - 1
	};
	let globalStartIndex = intervalData.length;
	let globalEndIndex = -1;
	data.forEach((item) => {
		const startIndex = item.intervalData.findIndex((interval) => !isEmptyForMetric(interval, balanceTypeOp));
		if (startIndex !== -1) {
			globalStartIndex = Math.min(globalStartIndex, startIndex);
			let endIndex = item.intervalData.length - 1;
			while (endIndex >= 0 && isEmptyForMetric(item.intervalData[endIndex], balanceTypeOp)) endIndex--;
			globalEndIndex = Math.max(globalEndIndex, endIndex);
		}
	});
	const mainStartIndex = intervalData.findIndex((interval) => !isEmptyForMetric(interval, balanceTypeOp));
	if (mainStartIndex !== -1) {
		globalStartIndex = Math.min(globalStartIndex, mainStartIndex);
		let mainEndIndex = intervalData.length - 1;
		while (mainEndIndex >= 0 && isEmptyForMetric(intervalData[mainEndIndex], balanceTypeOp)) mainEndIndex--;
		globalEndIndex = Math.max(globalEndIndex, mainEndIndex);
	}
	if (globalStartIndex === intervalData.length || globalEndIndex === -1) return {
		startIndex: 0,
		endIndex: -1
	};
	return {
		startIndex: globalStartIndex,
		endIndex: globalEndIndex
	};
}
function trimIntervalDataToRange(data, startIndex, endIndex) {
	if (startIndex > endIndex || startIndex < 0 || endIndex >= data.length) return [];
	return data.slice(startIndex, endIndex + 1);
}
function trimIntervalsToRange(data, startIndex, endIndex) {
	data.forEach((item) => {
		if (startIndex > endIndex || startIndex < 0 || endIndex >= item.intervalData.length) item.intervalData = [];
		else item.intervalData = item.intervalData.slice(startIndex, endIndex + 1);
	});
}
function trimGroupedDataIntervals(groupedData, startIndex, endIndex) {
	groupedData.forEach((group) => {
		if (startIndex > endIndex || startIndex < 0 || endIndex >= group.intervalData.length) group.intervalData = [];
		else group.intervalData = group.intervalData.slice(startIndex, endIndex + 1);
		if (group.categories) group.categories.forEach((category) => {
			if (startIndex > endIndex || startIndex < 0 || endIndex >= category.intervalData.length) category.intervalData = [];
			else category.intervalData = category.intervalData.slice(startIndex, endIndex + 1);
		});
	});
}
//#endregion
//#region src/components/reports/spreadsheets/custom-spreadsheet.ts
function createCustomSpreadsheet({ startDate, endDate, interval, categories, budgetType = "envelope", conditions = [], conditionsOp, showEmpty, showOffBudget, showHiddenCategories, showUncategorized, trimIntervals, groupBy = "", balanceTypeOp = "totalDebts", sortByOp = "desc", payees = [], accounts = [], graphType, firstDayOfWeekIdx }) {
	const [categoryList, categoryGroup] = categoryLists(categories);
	const [groupByList, groupByLabel] = groupBySelections(groupBy, categoryList, categoryGroup, payees, accounts);
	return async (spreadsheet, setData) => {
		if (groupByList.length === 0) {
			setData({
				data: [],
				intervalData: [],
				legend: [],
				startDate,
				endDate,
				totalAssets: 0,
				totalDebts: 0,
				netAssets: 0,
				netDebts: 0,
				totalTotals: 0,
				totalBudgeted: 0
			});
			return;
		}
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		let assets;
		let debts;
		({assets, debts} = await fetchSpreadsheetQueryData({
			balanceTypeOp,
			startDate,
			endDate,
			interval,
			categories: categories.list,
			categoryGroups: categories.grouped,
			conditions,
			conditionsOp,
			conditionsOpKey,
			filters,
			budgetType
		}));
		if (interval === "Weekly" && balanceTypeOp !== "totalBudgeted") {
			debts = debts.map((d) => {
				return {
					...d,
					date: weekFromDate(d.date, firstDayOfWeekIdx)
				};
			});
			assets = assets.map((d) => {
				return {
					...d,
					date: weekFromDate(d.date, firstDayOfWeekIdx)
				};
			});
		}
		const intervals = interval === "Weekly" ? weekRangeInclusive(startDate, endDate, firstDayOfWeekIdx) : months_exports[ReportOptions.intervalRange.get(interval) || "rangeInclusive"](startDate, endDate);
		let totalAssets = 0;
		let totalDebts = 0;
		let netAssets = 0;
		let netDebts = 0;
		const groupsByCategory = groupByLabel === "category" || groupByLabel === "categoryGroup";
		const intervalData = intervals.reduce((arr, intervalItem, index) => {
			let perIntervalAssets = 0;
			let perIntervalDebts = 0;
			let perIntervalNetAssets = 0;
			let perIntervalNetDebts = 0;
			let perIntervalTotals = 0;
			const stacked = {};
			groupByList.map((item) => {
				let stackAmounts = 0;
				const intervalAssets = filterHiddenItems(item, assets, showOffBudget, showHiddenCategories, showUncategorized, groupsByCategory).filter((asset) => asset.date === intervalItem && (asset[groupByLabel] === (item.id ?? null) || item.uncategorized_id && groupsByCategory)).reduce((a, v) => a + v.amount, 0);
				perIntervalAssets += intervalAssets;
				const intervalDebts = filterHiddenItems(item, debts, showOffBudget, showHiddenCategories, showUncategorized, groupsByCategory).filter((debt) => debt.date === intervalItem && (debt[groupByLabel] === (item.id ?? null) || item.uncategorized_id && groupsByCategory)).reduce((a, v) => a + v.amount, 0);
				perIntervalDebts += intervalDebts;
				const netAmounts = intervalAssets + intervalDebts;
				if (balanceTypeOp === "totalAssets") stackAmounts += intervalAssets;
				if (balanceTypeOp === "totalDebts") stackAmounts += Math.abs(intervalDebts);
				if (balanceTypeOp === "netAssets") stackAmounts += netAmounts > 0 ? netAmounts : 0;
				if (balanceTypeOp === "netDebts") stackAmounts = netAmounts < 0 ? Math.abs(netAmounts) : 0;
				if (balanceTypeOp === "totalTotals" || balanceTypeOp === "totalBudgeted") stackAmounts += netAmounts;
				stacked[item.id || item.name] = stackAmounts;
				perIntervalTotals += netAmounts;
				return null;
			});
			perIntervalNetAssets = perIntervalTotals > 0 ? perIntervalTotals : 0;
			perIntervalNetDebts = perIntervalTotals < 0 ? perIntervalTotals : 0;
			totalAssets += perIntervalAssets;
			totalDebts += perIntervalDebts;
			netAssets += perIntervalNetAssets;
			netDebts += perIntervalNetDebts;
			arr.push({
				date: format$1(parseISO(intervalItem), ReportOptions.intervalFormat.get(interval) || ""),
				...stacked,
				intervalStartDate: index === 0 ? startDate : intervalItem,
				intervalEndDate: index + 1 === intervals.length ? endDate : subDays(intervals[index + 1], 1),
				totalAssets: perIntervalAssets,
				totalDebts: perIntervalDebts,
				netAssets: perIntervalNetAssets,
				netDebts: perIntervalNetDebts,
				totalTotals: perIntervalTotals,
				totalBudgeted: perIntervalTotals
			});
			return arr;
		}, []);
		const calcDataFiltered = groupByList.map((item) => {
			return { ...recalculate$1({
				item,
				intervals,
				assets,
				debts,
				groupByLabel,
				showOffBudget,
				showHiddenCategories,
				showUncategorized,
				startDate,
				endDate
			}) };
		}).filter((i) => filterEmptyRows({
			showEmpty,
			data: i,
			balanceTypeOp
		}));
		const { startIndex, endIndex } = determineIntervalRange(calcDataFiltered, intervalData, trimIntervals, balanceTypeOp);
		const trimmedIntervalData = trimIntervals ? trimIntervalDataToRange(intervalData, startIndex, endIndex) : intervalData;
		if (trimIntervals) trimIntervalsToRange(calcDataFiltered, startIndex, endIndex);
		const sortedCalcDataFiltered = [...calcDataFiltered].sort(sortData({
			balanceTypeOp,
			sortByOp
		}));
		setData({
			data: sortedCalcDataFiltered,
			intervalData: trimmedIntervalData,
			legend: calculateLegend(trimmedIntervalData, sortedCalcDataFiltered, groupBy, graphType, balanceTypeOp),
			startDate,
			endDate,
			totalAssets,
			totalDebts,
			netAssets,
			netDebts,
			totalTotals: totalAssets + totalDebts,
			totalBudgeted: totalAssets + totalDebts
		});
	};
}
//#endregion
//#region src/components/reports/spreadsheets/grouped-spreadsheet.ts
function createGroupedSpreadsheet({ startDate, endDate, interval, categories, budgetType = "envelope", conditions = [], conditionsOp, showEmpty, showOffBudget, showHiddenCategories, showUncategorized, trimIntervals, balanceTypeOp, sortByOp, firstDayOfWeekIdx }) {
	const [categoryList, categoryGroup] = categoryLists(categories);
	return async (spreadsheet, setData) => {
		if (categoryList.length === 0) {
			setData([]);
			return;
		}
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		let assets;
		let debts;
		({assets, debts} = await fetchSpreadsheetQueryData({
			balanceTypeOp,
			startDate,
			endDate,
			interval,
			categories: categories.list,
			categoryGroups: categories.grouped,
			conditions,
			conditionsOp,
			conditionsOpKey,
			filters,
			budgetType
		}));
		if (interval === "Weekly" && balanceTypeOp !== "totalBudgeted") {
			debts = debts.map((d) => {
				return {
					...d,
					date: weekFromDate(d.date, firstDayOfWeekIdx)
				};
			});
			assets = assets.map((d) => {
				return {
					...d,
					date: weekFromDate(d.date, firstDayOfWeekIdx)
				};
			});
		}
		const intervals = interval === "Weekly" ? weekRangeInclusive(startDate, endDate, firstDayOfWeekIdx) : months_exports[ReportOptions.intervalRange.get(interval) || "rangeInclusive"](startDate, endDate);
		const groupedDataFiltered = categoryGroup.map((group) => {
			const grouped = recalculate$1({
				item: group,
				intervals,
				assets,
				debts,
				groupByLabel: "categoryGroup",
				showOffBudget,
				showHiddenCategories,
				showUncategorized,
				startDate,
				endDate
			});
			const stackedCategories = group.categories && group.categories.map((item) => {
				return { ...recalculate$1({
					item,
					intervals,
					assets,
					debts,
					groupByLabel: "category",
					showOffBudget,
					showHiddenCategories,
					showUncategorized,
					startDate,
					endDate
				}) };
			});
			return {
				...grouped,
				categories: stackedCategories && stackedCategories.filter((i) => filterEmptyRows({
					showEmpty,
					data: i,
					balanceTypeOp
				}))
			};
		}, [startDate, endDate]).filter((i) => filterEmptyRows({
			showEmpty,
			data: i,
			balanceTypeOp
		}));
		const allGroupsForTrimming = [];
		groupedDataFiltered.forEach((group) => {
			allGroupsForTrimming.push(group);
			if (group.categories) allGroupsForTrimming.push(...group.categories);
		});
		const { startIndex, endIndex } = determineIntervalRange(allGroupsForTrimming, groupedDataFiltered.length > 0 ? groupedDataFiltered[0].intervalData : [], trimIntervals, balanceTypeOp);
		trimGroupedDataIntervals(groupedDataFiltered, startIndex, endIndex);
		setData([...groupedDataFiltered].sort(sortData({
			balanceTypeOp,
			sortByOp
		})).map((g) => {
			g.categories = [...g.categories ?? []].sort(sortData({
				balanceTypeOp,
				sortByOp
			}));
			return g;
		}));
	};
}
//#endregion
//#region src/hooks/useReport.ts
function useReport(id) {
	return useQuery({
		...reportQueries.list(),
		select: (reports) => reports.find((report) => report.id === id),
		enabled: !!id
	});
}
//#endregion
//#region src/components/reports/reports/CustomReport.tsx
/**
* Transform `selectedCategories` into `conditions`.
*/
function useSelectedCategories(conditions, categories) {
	const $ = (0, import_compiler_runtime.c)(22);
	let t0;
	if ($[0] !== conditions) {
		t0 = conditions.find(_temp$8);
		$[0] = conditions;
		$[1] = t0;
	} else t0 = $[1];
	const existingCategoryCondition = t0;
	let t1;
	bb0: {
		if (!existingCategoryCondition) {
			t1 = categories;
			break bb0;
		}
		switch (existingCategoryCondition.op) {
			case "is": {
				let t2;
				if ($[2] !== categories || $[3] !== existingCategoryCondition.value) {
					let t3;
					if ($[5] !== existingCategoryCondition.value) {
						t3 = (t4) => {
							const { id: id_2 } = t4;
							return id_2 === existingCategoryCondition.value;
						};
						$[5] = existingCategoryCondition.value;
						$[6] = t3;
					} else t3 = $[6];
					t2 = categories.filter(t3);
					$[2] = categories;
					$[3] = existingCategoryCondition.value;
					$[4] = t2;
				} else t2 = $[4];
				t1 = t2;
				break bb0;
			}
			case "isNot": {
				let t2;
				if ($[7] !== categories || $[8] !== existingCategoryCondition.value) {
					let t3;
					if ($[10] !== existingCategoryCondition.value) {
						t3 = (t4) => {
							const { id: id_1 } = t4;
							return existingCategoryCondition.value !== id_1;
						};
						$[10] = existingCategoryCondition.value;
						$[11] = t3;
					} else t3 = $[11];
					t2 = categories.filter(t3);
					$[7] = categories;
					$[8] = existingCategoryCondition.value;
					$[9] = t2;
				} else t2 = $[9];
				t1 = t2;
				break bb0;
			}
			case "oneOf": {
				let t2;
				if ($[12] !== categories || $[13] !== existingCategoryCondition.value) {
					let t3;
					if ($[15] !== existingCategoryCondition.value) {
						t3 = (t4) => {
							const { id: id_0 } = t4;
							return existingCategoryCondition.value.includes(id_0);
						};
						$[15] = existingCategoryCondition.value;
						$[16] = t3;
					} else t3 = $[16];
					t2 = categories.filter(t3);
					$[12] = categories;
					$[13] = existingCategoryCondition.value;
					$[14] = t2;
				} else t2 = $[14];
				t1 = t2;
				break bb0;
			}
			case "notOneOf": {
				let t2;
				if ($[17] !== categories || $[18] !== existingCategoryCondition.value) {
					let t3;
					if ($[20] !== existingCategoryCondition.value) {
						t3 = (t4) => {
							const { id } = t4;
							return !existingCategoryCondition.value.includes(id);
						};
						$[20] = existingCategoryCondition.value;
						$[21] = t3;
					} else t3 = $[21];
					t2 = categories.filter(t3);
					$[17] = categories;
					$[18] = existingCategoryCondition.value;
					$[19] = t2;
				} else t2 = $[19];
				t1 = t2;
				break bb0;
			}
			default:
		}
		t1 = categories;
	}
	return t1;
}
function _temp$8(t0) {
	const { field } = t0;
	return field === "category";
}
var BUDGETED_SUPPORTED_CONDITION_FIELDS = new Set(["category"]);
function CustomReport() {
	const $ = (0, import_compiler_runtime.c)(5);
	const { data: report, isPending } = useReport(useParams().id);
	const [t0] = useSyncedPref("budgetType");
	const budgetType = t0 === void 0 ? "envelope" : t0;
	if (isPending) {
		let t1;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[0] = t1;
		} else t1 = $[0];
		return t1;
	}
	const t1 = report?.id;
	let t2;
	if ($[1] !== budgetType || $[2] !== report || $[3] !== t1) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomReportInner, {
			report,
			budgetType
		}, t1);
		$[1] = budgetType;
		$[2] = report;
		$[3] = t1;
		$[4] = t2;
	} else t2 = $[4];
	return t2;
}
function CustomReportInner(t0) {
	const $ = (0, import_compiler_runtime.c)(314);
	const { report: initialReport, budgetType } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	const format$6 = useFormat();
	const { data: t1 } = useCategories();
	const categories = t1 === void 0 ? {
		grouped: [],
		list: []
	} : t1;
	const { isNarrowWidth } = useResponsive();
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const [t2, setViewLegendPref] = useLocalPref("reportsViewLegend");
	const viewLegend = t2 === void 0 ? false : t2;
	const [t3, setViewSummaryPref] = useLocalPref("reportsViewSummary");
	const viewSummary = t3 === void 0 ? false : t3;
	const [t4, setViewLabelsPref] = useLocalPref("reportsViewLabel");
	const viewLabels = t4 === void 0 ? false : t4;
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters();
	const location = useLocation();
	const prevUrl = sessionStorage.getItem("url") || "";
	sessionStorage.setItem("prevUrl", prevUrl);
	sessionStorage.setItem("url", location.pathname);
	if (prevUrl !== location.pathname) sessionStorage.clear();
	let t5;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		const reportFromSessionStorage = sessionStorage.getItem("report");
		t5 = reportFromSessionStorage ? JSON.parse(reportFromSessionStorage) : {};
		$[0] = t5;
	} else t5 = $[0];
	const session = t5;
	const combine = initialReport ?? defaultReport;
	let t6;
	if ($[1] !== combine) {
		t6 = {
			...combine,
			...session
		};
		$[1] = combine;
		$[2] = t6;
	} else t6 = $[2];
	const loadReport = t6;
	let t7;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = [];
		$[3] = t7;
	} else t7 = $[3];
	const [allIntervals, setAllIntervals] = (0, import_react.useState)(t7);
	let t8;
	if ($[4] !== conditions) {
		t8 = !!conditions.find(_temp2$5) || conditions.filter(_temp3$4).length >= 2 || conditions.filter(_temp4$2).length >= 1;
		$[4] = conditions;
		$[5] = t8;
	} else t8 = $[5];
	const isComplexCategoryCondition = t8;
	const setSelectedCategories = (newCategories) => {
		const newCategoryIdSet = new Set(newCategories.map(_temp5$2));
		const allCategoryIds = categories.list.map(_temp6$2);
		const allCategoriesSelected = !allCategoryIds.find((id_1) => !newCategoryIdSet.has(id_1));
		const newCondition = {
			field: "category",
			op: "oneOf",
			value: newCategories.map(_temp7$1),
			type: "id"
		};
		const existingCategoryCondition = conditions.find(_temp8$1);
		if (existingCategoryCondition) {
			if (allCategoriesSelected) {
				onDeleteFilter(existingCategoryCondition);
				return;
			}
			if (existingCategoryCondition.op === "notOneOf") {
				onUpdateFilter(existingCategoryCondition, {
					...existingCategoryCondition,
					value: allCategoryIds.filter((id_3) => !newCategoryIdSet.has(id_3))
				});
				return;
			}
			onUpdateFilter(existingCategoryCondition, newCondition);
			return;
		}
		if (allCategoriesSelected) return;
		onApplyFilter(newCondition);
	};
	const selectedCategories = useSelectedCategories(conditions, categories.list);
	const [startDate, setStartDate] = (0, import_react.useState)(loadReport.startDate);
	const [endDate, setEndDate] = (0, import_react.useState)(loadReport.endDate);
	const [mode, setMode] = (0, import_react.useState)(loadReport.mode);
	const [isDateStatic, setIsDateStatic] = (0, import_react.useState)(loadReport.isDateStatic);
	const [groupBy, setGroupBy] = (0, import_react.useState)(loadReport.groupBy);
	const [interval, setInterval] = (0, import_react.useState)(loadReport.interval);
	const [balanceType, setBalanceType] = (0, import_react.useState)(loadReport.balanceType);
	const [sortBy, setSortBy] = (0, import_react.useState)(loadReport.sortBy);
	const [showEmpty, setShowEmpty] = (0, import_react.useState)(loadReport.showEmpty);
	const [showOffBudget, setShowOffBudget] = (0, import_react.useState)(loadReport.showOffBudget);
	const [includeCurrentInterval, setIncludeCurrentInterval] = (0, import_react.useState)(loadReport.includeCurrentInterval);
	const [showHiddenCategories, setShowHiddenCategories] = (0, import_react.useState)(loadReport.showHiddenCategories);
	const [showUncategorized, setShowUncategorized] = (0, import_react.useState)(loadReport.showUncategorized);
	const [trimIntervals, setTrimIntervals] = (0, import_react.useState)(loadReport.trimIntervals);
	const [graphType, setGraphType] = (0, import_react.useState)(loadReport.graphType);
	const [dateRange, setDateRange] = (0, import_react.useState)(loadReport.dateRange);
	let t9;
	if ($[6] !== interval) {
		t9 = interval === "Daily" ? 0 : ReportOptions.dateRange.filter((f) => f[interval]).length - 3;
		$[6] = interval;
		$[7] = t9;
	} else t9 = $[7];
	const dateRangeLine = t9;
	let t10;
	if ($[8] !== endDate || $[9] !== startDate) {
		t10 = rangeInclusive(startDate, endDate);
		$[8] = endDate;
		$[9] = startDate;
		$[10] = t10;
	} else t10 = $[10];
	const [intervals, setIntervals] = (0, import_react.useState)(t10);
	const [earliestTransactionDate, setEarliestTransactionDate] = (0, import_react.useState)("");
	const [latestTransactionDate, setLatestTransactionDate] = (0, import_react.useState)("");
	const [report, setReport] = (0, import_react.useState)(loadReport);
	const [savedStatus, setSavedStatus] = (0, import_react.useState)("savedStatus" in session ? session.savedStatus : initialReport ? "saved" : "new");
	let t11;
	if ($[11] !== conditions || $[12] !== conditionsOp || $[13] !== onApplyFilter || $[14] !== onConditionsOpChange || $[15] !== savedStatus) {
		t11 = (currentConditions, currentConditionsOp) => {
			onApplyFilter(null);
			const filtersToApply = savedStatus !== "saved" ? conditions : currentConditions;
			const conditionsOpToApply = savedStatus !== "saved" ? conditionsOp : currentConditionsOp;
			filtersToApply?.forEach(onApplyFilter);
			if (conditionsOpToApply) onConditionsOpChange(conditionsOpToApply);
		};
		$[11] = conditions;
		$[12] = conditionsOp;
		$[13] = onApplyFilter;
		$[14] = onConditionsOpChange;
		$[15] = savedStatus;
		$[16] = t11;
	} else t11 = $[16];
	const onApplyFilterConditions = (0, import_react.useEffectEvent)(t11);
	let t12;
	if ($[17] !== firstDayOfWeekIdx || $[18] !== locale) {
		t12 = async (earliestTransaction, latestTransaction, interval_0) => {
			const fromDate = interval_0 === "Weekly" ? "dayFromDate" : (ReportOptions.intervalMap.get(interval_0) || "Day").toLowerCase() + "FromDate";
			const earliestInterval = interval_0 === "Weekly" ? weekFromDate(parseISO(fromDateRepr(earliestTransaction.date || currentDay())), firstDayOfWeekIdx) : months_exports[fromDate](parseISO(fromDateRepr(earliestTransaction.date || currentDay())));
			const latestInterval = interval_0 === "Weekly" ? weekFromDate(parseISO(fromDateRepr(latestTransaction.date || currentDay())), firstDayOfWeekIdx) : months_exports[fromDate](parseISO(fromDateRepr(latestTransaction.date || currentDay())));
			const currentInterval = interval_0 === "Weekly" ? currentWeek(firstDayOfWeekIdx) : interval_0 === "Daily" ? currentDay() : interval_0 === "Yearly" ? currentYear() : currentMonth();
			const maxInterval = latestInterval > currentInterval ? latestInterval : currentInterval;
			setAllIntervals((interval_0 === "Weekly" ? weekRangeInclusive(earliestInterval, maxInterval, firstDayOfWeekIdx) : months_exports[ReportOptions.intervalRange.get(interval_0) || "rangeInclusive"](earliestInterval, maxInterval)).map((inter) => ({
				name: inter,
				pretty: format(inter, ReportOptions.intervalFormat.get(interval_0) || "", locale)
			})).reverse());
		};
		$[17] = firstDayOfWeekIdx;
		$[18] = locale;
		$[19] = t12;
	} else t12 = $[19];
	const onSetAllIntervals = (0, import_react.useEffectEvent)(t12);
	let t13;
	if ($[20] !== firstDayOfWeekIdx || $[21] !== setEndDate || $[22] !== setStartDate) {
		t13 = (earliestTransaction_0, latestTransaction_0, dateRange_0, isDateStatic_0, includeCurrentInterval_0) => {
			if (!isDateStatic_0) {
				const [dateStart, dateEnd] = getLiveRange(dateRange_0, earliestTransaction_0 ? earliestTransaction_0.date : currentDay(), latestTransaction_0 ? latestTransaction_0.date : currentDay(), includeCurrentInterval_0, firstDayOfWeekIdx);
				setStartDate(dateStart);
				setEndDate(dateEnd);
			}
		};
		$[20] = firstDayOfWeekIdx;
		$[21] = setEndDate;
		$[22] = setStartDate;
		$[23] = t13;
	} else t13 = $[23];
	const onSetStartAndEndDates = (0, import_react.useEffectEvent)(t13);
	let t14;
	if ($[24] !== dateRange || $[25] !== includeCurrentInterval || $[26] !== interval || $[27] !== isDateStatic || $[28] !== onApplyFilterConditions || $[29] !== onSetAllIntervals || $[30] !== onSetStartAndEndDates || $[31] !== report.conditions || $[32] !== report.conditionsOp) {
		t14 = () => {
			(async function run() {
				onApplyFilterConditions(report.conditions, report.conditionsOp);
				const earliestTransaction_1 = await send("get-earliest-transaction");
				setEarliestTransactionDate(earliestTransaction_1 ? earliestTransaction_1.date : currentDay());
				const latestTransaction_1 = await send("get-latest-transaction");
				setLatestTransactionDate(latestTransaction_1 ? latestTransaction_1.date : currentDay());
				onSetAllIntervals(earliestTransaction_1, latestTransaction_1, interval);
				onSetStartAndEndDates(earliestTransaction_1, latestTransaction_1, dateRange, isDateStatic, includeCurrentInterval);
			})();
		};
		$[24] = dateRange;
		$[25] = includeCurrentInterval;
		$[26] = interval;
		$[27] = isDateStatic;
		$[28] = onApplyFilterConditions;
		$[29] = onSetAllIntervals;
		$[30] = onSetStartAndEndDates;
		$[31] = report.conditions;
		$[32] = report.conditionsOp;
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== dateRange || $[35] !== firstDayOfWeekIdx || $[36] !== includeCurrentInterval || $[37] !== interval || $[38] !== isDateStatic || $[39] !== report.conditions || $[40] !== report.conditionsOp || $[41] !== savedStatus) {
		t15 = [
			interval,
			dateRange,
			firstDayOfWeekIdx,
			isDateStatic,
			report.conditions,
			report.conditionsOp,
			includeCurrentInterval,
			savedStatus
		];
		$[34] = dateRange;
		$[35] = firstDayOfWeekIdx;
		$[36] = includeCurrentInterval;
		$[37] = interval;
		$[38] = isDateStatic;
		$[39] = report.conditions;
		$[40] = report.conditionsOp;
		$[41] = savedStatus;
		$[42] = t15;
	} else t15 = $[42];
	(0, import_react.useEffect)(t14, t15);
	let t16;
	let t17;
	if ($[43] !== endDate || $[44] !== firstDayOfWeekIdx || $[45] !== interval || $[46] !== startDate) {
		t16 = () => {
			const [start, end] = [startDate, endDate];
			if (interval === "Weekly") setIntervals(weekRangeInclusive(start, end, firstDayOfWeekIdx));
			else setIntervals(months_exports[ReportOptions.intervalRange.get(interval) || "rangeInclusive"](start, end));
		};
		t17 = [
			interval,
			startDate,
			endDate,
			firstDayOfWeekIdx
		];
		$[43] = endDate;
		$[44] = firstDayOfWeekIdx;
		$[45] = interval;
		$[46] = startDate;
		$[47] = t16;
		$[48] = t17;
	} else {
		t16 = $[47];
		t17 = $[48];
	}
	(0, import_react.useEffect)(t16, t17);
	let t18;
	if ($[49] !== balanceType) {
		t18 = ReportOptions.balanceTypeMap.get(balanceType) || "totalDebts";
		$[49] = balanceType;
		$[50] = t18;
	} else t18 = $[50];
	const balanceTypeOp = t18;
	const sortByOp = sortBy || "desc";
	const { data: t19 } = usePayees();
	const payees = t19 === void 0 ? [] : t19;
	const { data: t20 } = useAccounts();
	const accounts = t20 === void 0 ? [] : t20;
	const hasWarning = calculateHasWarning(conditions, {
		categories: categories.list,
		payees,
		accounts
	});
	let t21;
	let t22;
	if ($[51] !== balanceTypeOp || $[52] !== conditions || $[53] !== onApplyFilter) {
		t21 = () => {
			if (balanceTypeOp !== "totalBudgeted") return;
			const supportedConditions = conditions.filter(_temp9);
			if (supportedConditions.length === conditions.length) return;
			setSessionReport("conditions", supportedConditions);
			onApplyFilter(null);
			supportedConditions.forEach((condition) => {
				onApplyFilter(condition);
			});
		};
		t22 = [
			balanceTypeOp,
			conditions,
			onApplyFilter
		];
		$[51] = balanceTypeOp;
		$[52] = conditions;
		$[53] = onApplyFilter;
		$[54] = t21;
		$[55] = t22;
	} else {
		t21 = $[54];
		t22 = $[55];
	}
	(0, import_react.useEffect)(t21, t22);
	let t23;
	if ($[56] !== balanceTypeOp || $[57] !== budgetType || $[58] !== categories || $[59] !== conditions || $[60] !== conditionsOp || $[61] !== endDate || $[62] !== firstDayOfWeekIdx || $[63] !== interval || $[64] !== showEmpty || $[65] !== showHiddenCategories || $[66] !== showOffBudget || $[67] !== showUncategorized || $[68] !== sortByOp || $[69] !== startDate || $[70] !== trimIntervals) {
		t23 = createGroupedSpreadsheet({
			startDate,
			endDate,
			interval,
			categories,
			budgetType,
			conditions,
			conditionsOp,
			showEmpty,
			showOffBudget,
			showHiddenCategories,
			showUncategorized,
			trimIntervals,
			balanceTypeOp,
			sortByOp,
			firstDayOfWeekIdx
		});
		$[56] = balanceTypeOp;
		$[57] = budgetType;
		$[58] = categories;
		$[59] = conditions;
		$[60] = conditionsOp;
		$[61] = endDate;
		$[62] = firstDayOfWeekIdx;
		$[63] = interval;
		$[64] = showEmpty;
		$[65] = showHiddenCategories;
		$[66] = showOffBudget;
		$[67] = showUncategorized;
		$[68] = sortByOp;
		$[69] = startDate;
		$[70] = trimIntervals;
		$[71] = t23;
	} else t23 = $[71];
	const getGroupData = t23;
	let t24;
	if ($[72] !== accounts || $[73] !== balanceTypeOp || $[74] !== budgetType || $[75] !== categories || $[76] !== conditions || $[77] !== conditionsOp || $[78] !== endDate || $[79] !== firstDayOfWeekIdx || $[80] !== graphType || $[81] !== groupBy || $[82] !== interval || $[83] !== payees || $[84] !== showEmpty || $[85] !== showHiddenCategories || $[86] !== showOffBudget || $[87] !== showUncategorized || $[88] !== sortByOp || $[89] !== startDate || $[90] !== trimIntervals) {
		t24 = createCustomSpreadsheet({
			startDate,
			endDate,
			interval,
			categories,
			budgetType,
			conditions,
			conditionsOp,
			showEmpty,
			showOffBudget,
			showHiddenCategories,
			showUncategorized,
			trimIntervals,
			groupBy,
			balanceTypeOp,
			sortByOp,
			payees,
			accounts,
			graphType,
			firstDayOfWeekIdx
		});
		$[72] = accounts;
		$[73] = balanceTypeOp;
		$[74] = budgetType;
		$[75] = categories;
		$[76] = conditions;
		$[77] = conditionsOp;
		$[78] = endDate;
		$[79] = firstDayOfWeekIdx;
		$[80] = graphType;
		$[81] = groupBy;
		$[82] = interval;
		$[83] = payees;
		$[84] = showEmpty;
		$[85] = showHiddenCategories;
		$[86] = showOffBudget;
		$[87] = showUncategorized;
		$[88] = sortByOp;
		$[89] = startDate;
		$[90] = trimIntervals;
		$[91] = t24;
	} else t24 = $[91];
	const graphData = useReport$1("default", t24);
	const groupedData = useReport$1("grouped", getGroupData);
	const data = graphData ? {
		...graphData,
		groupedData
	} : null;
	let t25;
	if ($[92] !== balanceType || $[93] !== conditions || $[94] !== conditionsOp || $[95] !== dateRange || $[96] !== endDate || $[97] !== graphType || $[98] !== groupBy || $[99] !== includeCurrentInterval || $[100] !== interval || $[101] !== isDateStatic || $[102] !== mode || $[103] !== showEmpty || $[104] !== showHiddenCategories || $[105] !== showOffBudget || $[106] !== showUncategorized || $[107] !== sortBy || $[108] !== startDate || $[109] !== trimIntervals) {
		t25 = {
			id: "",
			name: "",
			startDate,
			endDate,
			isDateStatic,
			dateRange,
			mode,
			groupBy,
			interval,
			balanceType,
			sortBy,
			showEmpty,
			showOffBudget,
			showHiddenCategories,
			includeCurrentInterval,
			showUncategorized,
			trimIntervals,
			graphType,
			conditions,
			conditionsOp
		};
		$[92] = balanceType;
		$[93] = conditions;
		$[94] = conditionsOp;
		$[95] = dateRange;
		$[96] = endDate;
		$[97] = graphType;
		$[98] = groupBy;
		$[99] = includeCurrentInterval;
		$[100] = interval;
		$[101] = isDateStatic;
		$[102] = mode;
		$[103] = showEmpty;
		$[104] = showHiddenCategories;
		$[105] = showOffBudget;
		$[106] = showUncategorized;
		$[107] = sortBy;
		$[108] = startDate;
		$[109] = trimIntervals;
		$[110] = t25;
	} else t25 = $[110];
	const customReportItems = t25;
	const navigate = useNavigate();
	const [, setScrollWidth] = (0, import_react.useState)(0);
	let t26;
	let t27;
	if ($[111] !== graphType || $[112] !== mode || $[113] !== setViewLabelsPref || $[114] !== setViewLegendPref) {
		t26 = () => {
			if (disabledLegendLabel(mode, graphType, "disableLegend")) setViewLegendPref(false);
			if (disabledLegendLabel(mode, graphType, "disableLabel")) setViewLabelsPref(false);
		};
		t27 = [
			setViewLegendPref,
			setViewLabelsPref,
			mode,
			graphType
		];
		$[111] = graphType;
		$[112] = mode;
		$[113] = setViewLabelsPref;
		$[114] = setViewLegendPref;
		$[115] = t26;
		$[116] = t27;
	} else {
		t26 = $[115];
		t27 = $[116];
	}
	(0, import_react.useEffect)(t26, t27);
	if (allIntervals.length === 0) return null;
	let t28;
	if ($[117] !== balanceType || $[118] !== graphType || $[119] !== groupBy || $[120] !== setBalanceType || $[121] !== setGraphType || $[122] !== setGroupBy) {
		t28 = (graph, item) => {
			const chooseGraph = graph || graphType;
			const newGraph = ((disabledList.modeGraphsMap.get(item) || []).includes(chooseGraph) ? defaultsList.modeGraphsMap.get(item) : chooseGraph) ?? chooseGraph;
			if ((disabledList.modeGraphsMap.get(item) || []).includes(graphType)) {
				setSessionReport("graphType", newGraph);
				setGraphType(newGraph);
			}
			if ((disabledGraphList(item, newGraph, "disabledSplit") || []).includes(groupBy)) {
				const cond_0 = defaultsGraphList(item, newGraph, "defaultSplit");
				setSessionReport("groupBy", cond_0);
				setGroupBy(cond_0);
			}
			if ((disabledGraphList(item, newGraph, "disabledType") || []).includes(balanceType)) {
				const cond_1 = defaultsGraphList(item, newGraph, "defaultType");
				setSessionReport("balanceType", cond_1);
				setBalanceType(cond_1);
			}
		};
		$[117] = balanceType;
		$[118] = graphType;
		$[119] = groupBy;
		$[120] = setBalanceType;
		$[121] = setGraphType;
		$[122] = setGroupBy;
		$[123] = t28;
	} else t28 = $[123];
	const defaultModeItems = t28;
	let t29;
	if ($[124] !== balanceType || $[125] !== graphType || $[126] !== groupBy || $[127] !== mode || $[128] !== setBalanceType || $[129] !== setGroupBy || $[130] !== setSortBy) {
		t29 = (item_0) => {
			const chooseGraph_0 = ReportOptions.groupByItems.has(item_0) ? graphType : item_0;
			if ((disabledGraphList(mode, chooseGraph_0, "disabledSplit") || []).includes(groupBy)) {
				const cond_2 = defaultsGraphList(mode, chooseGraph_0, "defaultSplit");
				setSessionReport("groupBy", cond_2);
				setGroupBy(cond_2);
			}
			if ((disabledGraphList(mode, chooseGraph_0, "disabledType") || []).includes(balanceType)) {
				const cond_3 = defaultsGraphList(mode, chooseGraph_0, "defaultType");
				setSessionReport("balanceType", cond_3);
				setBalanceType(cond_3);
			}
			const defaultSort = defaultsGraphList(mode, chooseGraph_0, "defaultSort");
			if (defaultSort) {
				setSessionReport("sortBy", defaultSort);
				setSortBy(defaultSort);
			}
		};
		$[124] = balanceType;
		$[125] = graphType;
		$[126] = groupBy;
		$[127] = mode;
		$[128] = setBalanceType;
		$[129] = setGroupBy;
		$[130] = setSortBy;
		$[131] = t29;
	} else t29 = $[131];
	const defaultItems = t29;
	let t30;
	if ($[132] !== graphType || $[133] !== mode) {
		t30 = (type) => {
			switch (type) {
				case "ShowLegend": return disabledLegendLabel(mode, graphType, "disableLegend") || false;
				case "ShowLabels": return disabledLegendLabel(mode, graphType, "disableLabel") || false;
				default: return (disabledList.modeGraphsMap.get(mode) || []).includes(type) || false;
			}
		};
		$[132] = graphType;
		$[133] = mode;
		$[134] = t30;
	} else t30 = $[134];
	const isItemDisabled = t30;
	let t31;
	if ($[135] !== graphType || $[136] !== groupBy || $[137] !== mode) {
		t31 = (type_0) => {
			switch (type_0) {
				case "split": return disabledGraphList(mode, graphType, "disabledSplit") || [];
				case "type": return graphType === "BarGraph" && groupBy === "Interval" ? [] : disabledGraphList(mode, graphType, "disabledType") || [];
				default: return [];
			}
		};
		$[135] = graphType;
		$[136] = groupBy;
		$[137] = mode;
		$[138] = t31;
	} else t31 = $[138];
	const disabledItems = t31;
	let onChangeDates;
	let onChangeViews;
	let onReportChange;
	if ($[139] !== initialReport || $[140] !== navigate || $[141] !== onApplyFilter || $[142] !== onConditionsOpChange || $[143] !== report || $[144] !== setBalanceType || $[145] !== setDateRange || $[146] !== setEndDate || $[147] !== setGraphType || $[148] !== setGroupBy || $[149] !== setIncludeCurrentInterval || $[150] !== setInterval || $[151] !== setIsDateStatic || $[152] !== setMode || $[153] !== setReport || $[154] !== setSavedStatus || $[155] !== setShowEmpty || $[156] !== setShowHiddenCategories || $[157] !== setShowOffBudget || $[158] !== setShowUncategorized || $[159] !== setSortBy || $[160] !== setStartDate || $[161] !== setTrimIntervals || $[162] !== setViewLabelsPref || $[163] !== setViewLegendPref || $[164] !== setViewSummaryPref || $[165] !== viewLabels || $[166] !== viewLegend || $[167] !== viewSummary) {
		onChangeDates = (dateStart_0, dateEnd_0) => {
			setSessionReport("startDate", dateStart_0);
			setSessionReport("endDate", dateEnd_0);
			setStartDate(dateStart_0);
			setEndDate(dateEnd_0);
			onReportChange({ type: "modify" });
		};
		let t32;
		if ($[171] !== setViewLabelsPref || $[172] !== setViewLegendPref || $[173] !== setViewSummaryPref || $[174] !== viewLabels || $[175] !== viewLegend || $[176] !== viewSummary) {
			t32 = (viewType) => {
				if (viewType === "viewLegend") setViewLegendPref(!viewLegend);
				if (viewType === "viewSummary") setViewSummaryPref(!viewSummary);
				if (viewType === "viewLabels") setViewLabelsPref(!viewLabels);
			};
			$[171] = setViewLabelsPref;
			$[172] = setViewLegendPref;
			$[173] = setViewSummaryPref;
			$[174] = viewLabels;
			$[175] = viewLegend;
			$[176] = viewSummary;
			$[177] = t32;
		} else t32 = $[177];
		onChangeViews = t32;
		let t33;
		if ($[178] !== onApplyFilter || $[179] !== onConditionsOpChange || $[180] !== setBalanceType || $[181] !== setDateRange || $[182] !== setEndDate || $[183] !== setGraphType || $[184] !== setGroupBy || $[185] !== setIncludeCurrentInterval || $[186] !== setInterval || $[187] !== setIsDateStatic || $[188] !== setMode || $[189] !== setShowEmpty || $[190] !== setShowHiddenCategories || $[191] !== setShowOffBudget || $[192] !== setShowUncategorized || $[193] !== setSortBy || $[194] !== setStartDate || $[195] !== setTrimIntervals) {
			t33 = (input) => {
				setStartDate(input.startDate);
				setEndDate(input.endDate);
				setIsDateStatic(input.isDateStatic);
				setDateRange(input.dateRange);
				setMode(input.mode);
				setGroupBy(input.groupBy);
				setInterval(input.interval);
				setBalanceType(input.balanceType);
				setSortBy(input.sortBy);
				setShowEmpty(input.showEmpty);
				setShowOffBudget(input.showOffBudget);
				setShowHiddenCategories(input.showHiddenCategories);
				setIncludeCurrentInterval(input.includeCurrentInterval);
				setShowUncategorized(input.showUncategorized);
				setTrimIntervals(input.trimIntervals);
				setGraphType(input.graphType);
				onApplyFilter(null);
				(input.conditions || []).forEach((condition_0) => {
					onApplyFilter(condition_0);
				});
				onConditionsOpChange(input.conditionsOp);
			};
			$[178] = onApplyFilter;
			$[179] = onConditionsOpChange;
			$[180] = setBalanceType;
			$[181] = setDateRange;
			$[182] = setEndDate;
			$[183] = setGraphType;
			$[184] = setGroupBy;
			$[185] = setIncludeCurrentInterval;
			$[186] = setInterval;
			$[187] = setIsDateStatic;
			$[188] = setMode;
			$[189] = setShowEmpty;
			$[190] = setShowHiddenCategories;
			$[191] = setShowOffBudget;
			$[192] = setShowUncategorized;
			$[193] = setSortBy;
			$[194] = setStartDate;
			$[195] = setTrimIntervals;
			$[196] = t33;
		} else t33 = $[196];
		const setReportData = t33;
		onReportChange = (params) => {
			bb361: switch (params.type) {
				case "add-update":
					sessionStorage.clear();
					setSessionReport("savedStatus", "saved");
					setSavedStatus("saved");
					setReport(params.savedReport);
					if (params.savedReport.id !== initialReport?.id) navigate(`/reports/custom/${params.savedReport.id}`);
					break bb361;
				case "rename":
					setReport({
						...report,
						name: params.savedReport?.name || ""
					});
					break bb361;
				case "modify":
					if (report.name) {
						setSessionReport("savedStatus", "modified");
						setSavedStatus("modified");
					}
					break bb361;
				case "reload":
					sessionStorage.clear();
					setSessionReport("savedStatus", "saved");
					setSavedStatus("saved");
					setReportData(initialReport ?? defaultReport);
					break bb361;
				case "reset":
					sessionStorage.clear();
					setSavedStatus("new");
					setReport(defaultReport);
					setReportData(defaultReport);
					break bb361;
				case "choose": {
					sessionStorage.clear();
					const newReport = params.savedReport || report;
					setSessionReport("savedStatus", "saved");
					setSavedStatus("saved");
					setReport(newReport);
					setReportData(newReport);
					navigate(`/reports/custom/${newReport.id}`);
					break bb361;
				}
				default:
			}
		};
		$[139] = initialReport;
		$[140] = navigate;
		$[141] = onApplyFilter;
		$[142] = onConditionsOpChange;
		$[143] = report;
		$[144] = setBalanceType;
		$[145] = setDateRange;
		$[146] = setEndDate;
		$[147] = setGraphType;
		$[148] = setGroupBy;
		$[149] = setIncludeCurrentInterval;
		$[150] = setInterval;
		$[151] = setIsDateStatic;
		$[152] = setMode;
		$[153] = setReport;
		$[154] = setSavedStatus;
		$[155] = setShowEmpty;
		$[156] = setShowHiddenCategories;
		$[157] = setShowOffBudget;
		$[158] = setShowUncategorized;
		$[159] = setSortBy;
		$[160] = setStartDate;
		$[161] = setTrimIntervals;
		$[162] = setViewLabelsPref;
		$[163] = setViewLegendPref;
		$[164] = setViewSummaryPref;
		$[165] = viewLabels;
		$[166] = viewLegend;
		$[167] = viewSummary;
		$[168] = onChangeDates;
		$[169] = onChangeViews;
		$[170] = onReportChange;
	} else {
		onChangeDates = $[168];
		onChangeViews = $[169];
		onReportChange = $[170];
	}
	let t32;
	if ($[197] !== navigate) {
		t32 = () => {
			navigate("/reports");
		};
		$[197] = navigate;
		$[198] = t32;
	} else t32 = $[198];
	const onBackClick = t32;
	const T0 = Page;
	let t33;
	if ($[199] !== isNarrowWidth || $[200] !== onBackClick || $[201] !== report.name || $[202] !== t) {
		t33 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title: t("Custom Report: {{name}}", { name: report.name ?? t("Unsaved report") }),
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: onBackClick })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Custom Report:" }) }),
			" ",
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: {
					marginLeft: 5,
					color: theme.pageTextPositive
				},
				children: { name: report.name?.length > 0 ? report.name : t("Unsaved report") }
			})
		] }) });
		$[199] = isNarrowWidth;
		$[200] = onBackClick;
		$[201] = report.name;
		$[202] = t;
		$[203] = t33;
	} else t33 = $[203];
	const t34 = 0;
	const T1 = View;
	const t35 = !isNarrowWidth ? 20 : void 0;
	let t36;
	if ($[204] !== t35) {
		t36 = {
			flexDirection: "row",
			paddingLeft: t35,
			flex: 1
		};
		$[204] = t35;
		$[205] = t36;
	} else t36 = $[205];
	let t37;
	if ($[206] !== allIntervals || $[207] !== categories || $[208] !== customReportItems || $[209] !== dateRangeLine || $[210] !== defaultItems || $[211] !== defaultModeItems || $[212] !== disabledItems || $[213] !== earliestTransactionDate || $[214] !== firstDayOfWeekIdx || $[215] !== isComplexCategoryCondition || $[216] !== isNarrowWidth || $[217] !== latestTransactionDate || $[218] !== onChangeDates || $[219] !== onReportChange || $[220] !== selectedCategories || $[221] !== setBalanceType || $[222] !== setDateRange || $[223] !== setGraphType || $[224] !== setGroupBy || $[225] !== setIncludeCurrentInterval || $[226] !== setInterval || $[227] !== setIsDateStatic || $[228] !== setMode || $[229] !== setSelectedCategories || $[230] !== setShowEmpty || $[231] !== setShowHiddenCategories || $[232] !== setShowOffBudget || $[233] !== setShowUncategorized || $[234] !== setSortBy || $[235] !== setTrimIntervals) {
		t37 = !isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportSidebar, {
			customReportItems,
			selectedCategories,
			categories,
			dateRangeLine,
			allIntervals,
			setDateRange,
			setGraphType,
			setGroupBy,
			setInterval,
			setBalanceType,
			setSortBy,
			setMode,
			setIsDateStatic,
			setShowEmpty,
			setShowOffBudget,
			setShowHiddenCategories,
			setIncludeCurrentInterval,
			setShowUncategorized,
			setTrimIntervals,
			setSelectedCategories,
			onChangeDates,
			onReportChange,
			disabledItems,
			defaultItems,
			defaultModeItems,
			earliestTransaction: earliestTransactionDate,
			latestTransaction: latestTransactionDate,
			firstDayOfWeekIdx,
			isComplexCategoryCondition
		});
		$[206] = allIntervals;
		$[207] = categories;
		$[208] = customReportItems;
		$[209] = dateRangeLine;
		$[210] = defaultItems;
		$[211] = defaultModeItems;
		$[212] = disabledItems;
		$[213] = earliestTransactionDate;
		$[214] = firstDayOfWeekIdx;
		$[215] = isComplexCategoryCondition;
		$[216] = isNarrowWidth;
		$[217] = latestTransactionDate;
		$[218] = onChangeDates;
		$[219] = onReportChange;
		$[220] = selectedCategories;
		$[221] = setBalanceType;
		$[222] = setDateRange;
		$[223] = setGraphType;
		$[224] = setGroupBy;
		$[225] = setIncludeCurrentInterval;
		$[226] = setInterval;
		$[227] = setIsDateStatic;
		$[228] = setMode;
		$[229] = setSelectedCategories;
		$[230] = setShowEmpty;
		$[231] = setShowHiddenCategories;
		$[232] = setShowOffBudget;
		$[233] = setShowUncategorized;
		$[234] = setSortBy;
		$[235] = setTrimIntervals;
		$[236] = t37;
	} else t37 = $[236];
	const T2 = View;
	let t38;
	if ($[237] === Symbol.for("react.memo_cache_sentinel")) {
		t38 = { flex: 1 };
		$[237] = t38;
	} else t38 = $[237];
	let t39;
	if ($[238] !== customReportItems || $[239] !== defaultItems || $[240] !== isItemDisabled || $[241] !== isNarrowWidth || $[242] !== onApplyFilter || $[243] !== onChangeViews || $[244] !== onReportChange || $[245] !== report || $[246] !== savedStatus || $[247] !== setGraphType || $[248] !== viewLabels || $[249] !== viewLegend || $[250] !== viewSummary) {
		t39 = !isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportTopbar, {
			customReportItems,
			report,
			savedStatus,
			setGraphType,
			viewLegend,
			viewSummary,
			viewLabels,
			onApplyFilter,
			onChangeViews,
			onReportChange,
			isItemDisabled,
			defaultItems
		});
		$[238] = customReportItems;
		$[239] = defaultItems;
		$[240] = isItemDisabled;
		$[241] = isNarrowWidth;
		$[242] = onApplyFilter;
		$[243] = onChangeViews;
		$[244] = onReportChange;
		$[245] = report;
		$[246] = savedStatus;
		$[247] = setGraphType;
		$[248] = viewLabels;
		$[249] = viewLegend;
		$[250] = viewSummary;
		$[251] = t39;
	} else t39 = $[251];
	let t40;
	if ($[252] !== conditions || $[253] !== conditionsOp || $[254] !== hasWarning || $[255] !== onConditionsOpChange || $[256] !== onDeleteFilter || $[257] !== onReportChange || $[258] !== onUpdateFilter || $[259] !== t) {
		t40 = conditions && conditions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				marginBottom: 10,
				marginLeft: 5,
				marginRight: 5,
				gap: 10,
				flexShrink: 0
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					flexShrink: 0,
					flexDirection: "row",
					alignItems: "flex-start",
					justifyContent: "flex-start"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppliedFilters, {
					conditions,
					onUpdate: (oldFilter, newFilter) => {
						setSessionReport("conditions", conditions.map((f_0) => f_0 === oldFilter ? newFilter : f_0));
						onReportChange({ type: "modify" });
						onUpdateFilter(oldFilter, newFilter);
					},
					onDelete: (deletedFilter) => {
						setSessionReport("conditions", conditions.filter((f_1) => f_1 !== deletedFilter));
						onDeleteFilter(deletedFilter);
						onReportChange({ type: "modify" });
					},
					conditionsOp,
					onConditionsOpChange: (co) => {
						onConditionsOpChange(co);
						onReportChange({ type: "modify" });
					}
				})
			}), hasWarning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warning, {
				style: {
					paddingTop: 5,
					paddingBottom: 5
				},
				children: t("This report is configured to use a non-existing filter value (i.e. category/account/payee).")
			})]
		});
		$[252] = conditions;
		$[253] = conditionsOp;
		$[254] = hasWarning;
		$[255] = onConditionsOpChange;
		$[256] = onDeleteFilter;
		$[257] = onReportChange;
		$[258] = onUpdateFilter;
		$[259] = t;
		$[260] = t40;
	} else t40 = $[260];
	const T3 = View;
	const t41 = "custom-report-content";
	let t42;
	if ($[261] === Symbol.for("react.memo_cache_sentinel")) {
		t42 = {
			backgroundColor: theme.tableBackground,
			flexDirection: "row",
			flex: "1 0 auto"
		};
		$[261] = t42;
	} else t42 = $[261];
	const T4 = View;
	let t43;
	if ($[262] === Symbol.for("react.memo_cache_sentinel")) {
		t43 = {
			flex: 1,
			padding: 10
		};
		$[262] = t43;
	} else t43 = $[262];
	const t44 = graphType !== "TableGraph" && data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
		style: {
			alignItems: "flex-end",
			paddingTop: 10
		},
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				...styles.mediumText,
				fontWeight: 500,
				marginBottom: 5
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Block, { children: [balanceType, ":"] }),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$6(data[balanceTypeOp], "financial") }) })
			})
		})
	});
	let t45;
	if ($[263] === Symbol.for("react.memo_cache_sentinel")) {
		t45 = {
			flex: 1,
			overflow: "auto"
		};
		$[263] = t45;
	} else t45 = $[263];
	let t46;
	if ($[264] !== balanceType || $[265] !== conditions || $[266] !== data || $[267] !== graphType || $[268] !== groupBy || $[269] !== interval || $[270] !== intervals || $[271] !== mode || $[272] !== setScrollWidth || $[273] !== showHiddenCategories || $[274] !== showOffBudget || $[275] !== t || $[276] !== viewLabels) {
		t46 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t45,
			children: data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChooseGraph, {
				data,
				filters: conditions,
				mode,
				graphType,
				balanceType,
				groupBy,
				interval,
				setScrollWidth,
				viewLabels,
				compact: false,
				showHiddenCategories,
				showOffBudget,
				intervalsCount: intervals.length
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t("Loading report...") })
		});
		$[264] = balanceType;
		$[265] = conditions;
		$[266] = data;
		$[267] = graphType;
		$[268] = groupBy;
		$[269] = interval;
		$[270] = intervals;
		$[271] = mode;
		$[272] = setScrollWidth;
		$[273] = showHiddenCategories;
		$[274] = showOffBudget;
		$[275] = t;
		$[276] = viewLabels;
		$[277] = t46;
	} else t46 = $[277];
	let t47;
	if ($[278] !== T4 || $[279] !== t43 || $[280] !== t44 || $[281] !== t46) {
		t47 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T4, {
			style: t43,
			children: [t44, t46]
		});
		$[278] = T4;
		$[279] = t43;
		$[280] = t44;
		$[281] = t46;
		$[282] = t47;
	} else t47 = $[282];
	let t48;
	if ($[283] !== balanceTypeOp || $[284] !== data || $[285] !== endDate || $[286] !== groupBy || $[287] !== interval || $[288] !== intervals || $[289] !== isNarrowWidth || $[290] !== startDate || $[291] !== viewLegend || $[292] !== viewSummary) {
		t48 = (viewLegend || viewSummary) && data && !isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				padding: 10,
				minWidth: 300,
				textAlign: "center"
			},
			children: [viewSummary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportSummary, {
				startDate,
				endDate,
				balanceTypeOp,
				data,
				interval,
				intervalsCount: intervals.length
			}), viewLegend && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportLegend, {
				legend: data.legend,
				groupBy,
				interval
			})]
		});
		$[283] = balanceTypeOp;
		$[284] = data;
		$[285] = endDate;
		$[286] = groupBy;
		$[287] = interval;
		$[288] = intervals;
		$[289] = isNarrowWidth;
		$[290] = startDate;
		$[291] = viewLegend;
		$[292] = viewSummary;
		$[293] = t48;
	} else t48 = $[293];
	let t49;
	if ($[294] !== T3 || $[295] !== t42 || $[296] !== t47 || $[297] !== t48) {
		t49 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T3, {
			id: t41,
			style: t42,
			children: [t47, t48]
		});
		$[294] = T3;
		$[295] = t42;
		$[296] = t47;
		$[297] = t48;
		$[298] = t49;
	} else t49 = $[298];
	let t50;
	if ($[299] !== T2 || $[300] !== t38 || $[301] !== t39 || $[302] !== t40 || $[303] !== t49) {
		t50 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T2, {
			style: t38,
			children: [
				t39,
				t40,
				t49
			]
		});
		$[299] = T2;
		$[300] = t38;
		$[301] = t39;
		$[302] = t40;
		$[303] = t49;
		$[304] = t50;
	} else t50 = $[304];
	let t51;
	if ($[305] !== T1 || $[306] !== t36 || $[307] !== t37 || $[308] !== t50) {
		t51 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(T1, {
			style: t36,
			children: [t37, t50]
		});
		$[305] = T1;
		$[306] = t36;
		$[307] = t37;
		$[308] = t50;
		$[309] = t51;
	} else t51 = $[309];
	let t52;
	if ($[310] !== T0 || $[311] !== t33 || $[312] !== t51) {
		t52 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			header: t33,
			padding: t34,
			children: t51
		});
		$[310] = T0;
		$[311] = t33;
		$[312] = t51;
		$[313] = t52;
	} else t52 = $[313];
	return t52;
}
function _temp9(cond) {
	return BUDGETED_SUPPORTED_CONDITION_FIELDS.has(cond.field);
}
function _temp8$1(t0) {
	const { field: field_2 } = t0;
	return field_2 === "category";
}
function _temp7$1(t0) {
	const { id: id_2 } = t0;
	return id_2;
}
function _temp6$2(t0) {
	const { id: id_0 } = t0;
	return id_0;
}
function _temp5$2(t0) {
	const { id } = t0;
	return id;
}
function _temp4$2(t0) {
	const { field } = t0;
	return field === "category_group";
}
function _temp3$4(t0) {
	const { field: field_0 } = t0;
	return field_0 === "category";
}
function _temp2$5(t0) {
	const { field: field_1, op } = t0;
	return field_1 === "category" && [
		"contains",
		"doesNotContain",
		"matches",
		"hasTags"
	].includes(op);
}
//#endregion
//#region src/components/formula/queryTimeFrame.ts
function isMonthString(dateOrMonth) {
	return dateOrMonth.split("-").length === 2;
}
/**
* Query formulas use day-level filtering in AQL (`$gte/$lte` on YYYY-MM-DD).
* The query editor UI selects months, so we normalize month strings to days.
*/
function normalizeQueryTimeFrameStart(dateOrMonth) {
	return isMonthString(dateOrMonth) ? firstDayOfMonth(dateOrMonth) : dayFromDate(dateOrMonth);
}
function normalizeQueryTimeFrameEnd(dateOrMonth) {
	return isMonthString(dateOrMonth) ? lastDayOfMonth(dateOrMonth) : dayFromDate(dateOrMonth);
}
//#endregion
//#region src/components/formula/QueryManager.tsx
function QueryManager(t0) {
	const $ = (0, import_compiler_runtime.c)(30);
	const { queries, onQueriesChange } = t0;
	const { t } = useTranslation();
	const [newQueryName, setNewQueryName] = (0, import_react.useState)("");
	const [isAddingQuery, setIsAddingQuery] = (0, import_react.useState)(false);
	const dispatch = useDispatch();
	let t1;
	if ($[0] !== dispatch || $[1] !== newQueryName || $[2] !== onQueriesChange || $[3] !== queries || $[4] !== t) {
		t1 = function handleAddQuery() {
			if (!newQueryName.trim()) return;
			if (queries[newQueryName]) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Query with this name already exists")
				} }));
				return;
			}
			onQueriesChange({
				...queries,
				[newQueryName]: {
					conditions: [],
					conditionsOp: "and",
					timeFrame: {
						start: firstDayOfMonth(currentDay()),
						end: currentDay(),
						mode: "sliding-window"
					}
				}
			});
			setNewQueryName("");
			setIsAddingQuery(false);
		};
		$[0] = dispatch;
		$[1] = newQueryName;
		$[2] = onQueriesChange;
		$[3] = queries;
		$[4] = t;
		$[5] = t1;
	} else t1 = $[5];
	const handleAddQuery = t1;
	let t2;
	if ($[6] !== onQueriesChange || $[7] !== queries) {
		t2 = function handleRemoveQuery(queryName) {
			const newQueries = { ...queries };
			delete newQueries[queryName];
			onQueriesChange(newQueries);
		};
		$[6] = onQueriesChange;
		$[7] = queries;
		$[8] = t2;
	} else t2 = $[8];
	const handleRemoveQuery = t2;
	let t3;
	if ($[9] !== onQueriesChange || $[10] !== queries) {
		t3 = function handleUpdateQuery(queryName_0, config) {
			onQueriesChange({
				...queries,
				[queryName_0]: config
			});
		};
		$[9] = onQueriesChange;
		$[10] = queries;
		$[11] = t3;
	} else t3 = $[11];
	const handleUpdateQuery = t3;
	let t4;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			padding: 20,
			flex: 1,
			minWidth: 400
		};
		$[12] = t4;
	} else t4 = $[12];
	let t5;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = {
			display: "flex",
			flexDirection: "row",
			justifyContent: "space-between",
			alignItems: "center",
			marginBottom: 16
		};
		$[13] = t5;
	} else t5 = $[13];
	let t6;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				fontSize: 18,
				fontWeight: 600
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Query Definitions" })
		});
		$[14] = t6;
	} else t6 = $[14];
	let t7;
	if ($[15] !== isAddingQuery) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t5,
			children: [t6, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: () => setIsAddingQuery(!isAddingQuery),
				children: isAddingQuery ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Cancel" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Add Query" })
			})]
		});
		$[15] = isAddingQuery;
		$[16] = t7;
	} else t7 = $[16];
	let t8;
	if ($[17] !== handleAddQuery || $[18] !== isAddingQuery || $[19] !== newQueryName || $[20] !== t) {
		t8 = isAddingQuery && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: 16,
				border: `1px solid ${theme.tableBorder}`,
				borderRadius: 4,
				marginBottom: 16,
				backgroundColor: theme.tableBackground
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					display: "flex",
					flexDirection: "row",
					gap: 8
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
					placeholder: t("Query name (e.g., 'expenses', 'income')"),
					value: newQueryName,
					onChange: (e) => setNewQueryName(e.target.value),
					onKeyDown: (e_0) => {
						if (e_0.key === "Enter") handleAddQuery();
					},
					style: { flex: 1 }
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: "primary",
					onPress: handleAddQuery,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Create" })
				})]
			})
		});
		$[17] = handleAddQuery;
		$[18] = isAddingQuery;
		$[19] = newQueryName;
		$[20] = t;
		$[21] = t8;
	} else t8 = $[21];
	let t9;
	if ($[22] !== handleRemoveQuery || $[23] !== handleUpdateQuery || $[24] !== queries) {
		t9 = Object.entries(queries).length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				padding: 32,
				textAlign: "center",
				color: theme.pageTextSubdued,
				border: `1px dashed ${theme.tableBorder}`,
				borderRadius: 4,
				maxWidth: 400
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No queries defined. Click 'Add Query' to create your first query." }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: {
					fontSize: 12,
					marginTop: 8
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Queries allow you to reference filtered transaction data in your formulas using QUERY('queryName') or QUERY_COUNT('queryName')" })
			})]
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { display: "block" },
			children: Object.entries(queries).map((t10) => {
				const [queryName_1, config_0] = t10;
				return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryItem, {
					queryName: queryName_1,
					defaultConfig: config_0,
					onUpdate: (newConfig) => handleUpdateQuery(queryName_1, newConfig),
					onRemove: () => handleRemoveQuery(queryName_1)
				}, queryName_1);
			})
		});
		$[22] = handleRemoveQuery;
		$[23] = handleUpdateQuery;
		$[24] = queries;
		$[25] = t9;
	} else t9 = $[25];
	let t10;
	if ($[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t4,
			children: [
				t7,
				t8,
				t9
			]
		});
		$[26] = t7;
		$[27] = t8;
		$[28] = t9;
		$[29] = t10;
	} else t10 = $[29];
	return t10;
}
function QueryItem({ queryName, defaultConfig, onUpdate, onRemove }) {
	const locale = useLocale();
	const { t } = useTranslation();
	const [importJsonText, setImportJsonText] = (0, import_react.useState)("");
	const dispatch = useDispatch();
	const timeRangeMenuTriggerRef = (0, import_react.useRef)(null);
	const [timeRangeMenuOpen, setTimeRangeMenuOpen] = (0, import_react.useState)(false);
	const [startDate, setStartDate] = (0, import_react.useState)(defaultConfig.timeFrame?.start || dayFromDate(currentMonth()));
	const [endDate, setEndDate] = (0, import_react.useState)(defaultConfig.timeFrame?.end || currentDay());
	const [allMonths, setAllMonths] = (0, import_react.useState)([]);
	const [_earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [_latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const timeRangeRef = (0, import_react.useRef)(defaultConfig.timeFrame?.mode || "sliding-window");
	const conditionsRef = (0, import_react.useRef)(defaultConfig.conditions || []);
	const conditionsOpRef = (0, import_react.useRef)(defaultConfig.conditionsOp || null);
	(0, import_react.useEffect)(() => {
		if (conditionsRef.current.length === 0) conditionsRef.current = defaultConfig.conditions || [];
		if (conditionsOpRef.current === null) conditionsOpRef.current = defaultConfig.conditionsOp || "and";
	}, [defaultConfig]);
	(0, import_react.useEffect)(() => {
		async function run() {
			const earliestTransaction = await send("get-earliest-transaction");
			setEarliestTransaction(earliestTransaction ? earliestTransaction.date : currentDay());
			const latestTransaction = await send("get-latest-transaction");
			setLatestTransaction(latestTransaction ? latestTransaction.date : currentDay());
			const currentMonth$6 = currentMonth();
			let earliestMonth = earliestTransaction ? monthFromDate(parseISO(fromDateRepr(earliestTransaction.date))) : currentMonth$6;
			const latestMonth = latestTransaction ? monthFromDate(parseISO(fromDateRepr(latestTransaction.date))) : currentMonth$6;
			const yearAgo = subMonths(latestMonth, 12);
			if (earliestMonth > yearAgo) earliestMonth = yearAgo;
			setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
				name: month,
				pretty: format(month, "MMMM yyyy", locale)
			})).reverse());
		}
		run();
	}, [locale]);
	const filters = useRuleConditionFilters(conditionsRef.current, conditionsOpRef.current ?? "and");
	const prevFiltersRef = (0, import_react.useRef)({
		conditions: filters.conditions,
		conditionsOp: filters.conditionsOp,
		startDate,
		endDate
	});
	const sendUpdate = (0, import_react.useCallback)((conditions = filters.conditions, conditionsOp = filters.conditionsOp, newStartDate = startDate, newEndDate = endDate, mode = timeRangeRef.current) => {
		timeRangeRef.current = mode;
		onUpdate({
			conditions,
			conditionsOp,
			timeFrame: {
				start: newStartDate,
				end: newEndDate,
				mode
			}
		});
	}, [
		filters.conditions,
		filters.conditionsOp,
		timeRangeRef,
		startDate,
		endDate,
		onUpdate
	]);
	(0, import_react.useEffect)(() => {
		const prev = prevFiltersRef.current;
		const conditionsChanged = JSON.stringify(prev.conditions) !== JSON.stringify(filters.conditions);
		const conditionsOpChanged = prev.conditionsOp !== filters.conditionsOp;
		if (conditionsChanged || conditionsOpChanged) {
			prevFiltersRef.current = {
				conditions: filters.conditions,
				conditionsOp: filters.conditionsOp,
				startDate,
				endDate
			};
			sendUpdate();
		}
	}, [
		filters.conditions,
		filters.conditionsOp,
		startDate,
		endDate,
		sendUpdate
	]);
	function handleStartDateChange(newStart) {
		setStartDate(normalizeQueryTimeFrameStart(newStart));
		sendUpdate(filters.conditions, filters.conditionsOp, normalizeQueryTimeFrameStart(newStart), endDate, timeRangeRef.current);
	}
	function handleEndDateChange(newEnd) {
		setEndDate(normalizeQueryTimeFrameEnd(newEnd));
		sendUpdate(filters.conditions, filters.conditionsOp, startDate, normalizeQueryTimeFrameEnd(newEnd), timeRangeRef.current);
	}
	async function handleExport() {
		const config = {
			conditions: filters.conditions,
			conditionsOp: filters.conditionsOp,
			timeFrame: {
				start: startDate,
				end: endDate,
				mode: timeRangeRef.current
			}
		};
		const jsonString = JSON.stringify(config, null, 2);
		try {
			await navigator.clipboard.writeText(jsonString);
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Query configuration copied to clipboard")
			} }));
		} catch {
			dispatch(addNotification({ notification: {
				type: "error",
				message: t("Failed to copy to clipboard")
			} }));
		}
	}
	function handleImport() {
		try {
			const config_0 = JSON.parse(importJsonText);
			if (config_0.conditions && config_0.conditionsOp && config_0.timeFrame) {
				conditionsRef.current = config_0.conditions;
				conditionsOpRef.current = config_0.conditionsOp;
				timeRangeRef.current = config_0.timeFrame.mode;
				setStartDate(config_0.timeFrame.start ? normalizeQueryTimeFrameStart(config_0.timeFrame.start) : dayFromDate(currentMonth()));
				setEndDate(config_0.timeFrame.end ? normalizeQueryTimeFrameEnd(config_0.timeFrame.end) : currentDay());
				sendUpdate(config_0.conditions, config_0.conditionsOp, normalizeQueryTimeFrameStart(config_0.timeFrame.start), normalizeQueryTimeFrameEnd(config_0.timeFrame.end), config_0.timeFrame.mode);
				setImportJsonText("");
			} else dispatch(addNotification({ notification: {
				type: "error",
				message: t("Invalid JSON. Please check your input.")
			} }));
		} catch {
			dispatch(addNotification({ notification: {
				type: "error",
				message: t("Invalid JSON. Please check your input.")
			} }));
		}
	}
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: {
			padding: 16,
			marginBottom: 16,
			border: `1px solid ${theme.tableBorder}`,
			borderRadius: 4,
			backgroundColor: theme.tableBackground,
			display: "block",
			flex: 1
		},
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					display: "flex",
					flexDirection: "row",
					justifyContent: "space-between",
					alignItems: "center",
					marginBottom: 12
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						display: "flex",
						flexDirection: "row",
						gap: 8,
						alignItems: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
						style: {
							fontWeight: 600,
							fontFamily: "monospace"
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
							"QUERY('",
							queryName,
							"')"
						] })
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						display: "flex",
						flexDirection: "row",
						gap: 8,
						justifyContent: "flex-end",
						alignItems: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							display: "flex",
							flexDirection: "row",
							gap: 4
						},
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								variant: "bare",
								onPress: handleExport,
								"aria-label": t("Export query configuration"),
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCopy, { style: {
									width: 13,
									height: 13
								} })
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)($de32f1b87079253c$export$2e1e1122cf0cba88, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								variant: "bare",
								"aria-label": t("Import query configuration"),
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgDownloadThickBottom, { style: {
									width: 13,
									height: 13
								} })
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)($de32f1b87079253c$export$3ddf2d174ce01153, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
								style: {
									padding: 16,
									minWidth: 400
								},
								children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
										style: {
											fontSize: 14,
											fontWeight: 600,
											marginBottom: 12
										},
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Import Query Configuration" })
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
										style: {
											fontSize: 12,
											color: theme.pageTextSubdued,
											marginBottom: 8
										},
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Paste the JSON configuration below:" })
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
										value: importJsonText,
										onChange: (e) => setImportJsonText(e.target.value),
										placeholder: JSON.stringify({
											conditions: [],
											conditionsOp: "and",
											timeFrame: {
												start: "",
												end: "",
												mode: "sliding-window"
											}
										}, null, 2),
										style: {
											width: "100%",
											height: 200,
											padding: 8,
											border: `1px solid ${theme.formInputBorder}`,
											borderRadius: 4,
											backgroundColor: theme.tableBackground,
											color: theme.formInputText,
											fontFamily: "monospace",
											fontSize: 12,
											resize: "vertical",
											outline: "none"
										}
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
										style: {
											display: "flex",
											flexDirection: "row",
											gap: 8,
											marginTop: 12,
											justifyContent: "flex-end"
										},
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
											variant: "bare",
											slot: "close",
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Cancel" })
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
											variant: "primary",
											onPress: handleImport,
											slot: "close",
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Import" })
										})]
									})
								]
							}) }) })] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								variant: "bare",
								onPress: onRemove,
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgTrash, { style: {
									width: 13,
									height: 13
								} })
							})
						]
					})
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: { marginBottom: 12 },
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						display: "flex",
						flexDirection: "row",
						justifyContent: "flex-end",
						gap: 8,
						marginTop: 16
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
							style: { width: 50 },
							variant: timeRangeRef.current === "static" ? "normal" : "primary",
							onPress: () => {
								const newMode = timeRangeRef.current === "static" ? "sliding-window" : "static";
								const [newStart_0, newEnd_0] = calculateTimeRange({
									start: startDate,
									end: endDate,
									mode: newMode
								});
								setStartDate(newStart_0);
								setEndDate(newEnd_0);
								timeRangeRef.current = newMode;
								sendUpdate(filters.conditions, filters.conditionsOp, newStart_0, newEnd_0, newMode);
							},
							children: timeRangeRef.current === "static" ? t("Static") : t("Live")
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
							ref: timeRangeMenuTriggerRef,
							variant: "bare",
							onPress: () => setTimeRangeMenuOpen(true),
							children: "⋮"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
							triggerRef: timeRangeMenuTriggerRef,
							placement: "bottom start",
							isOpen: timeRangeMenuOpen,
							onOpenChange: () => setTimeRangeMenuOpen(false),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
								onMenuSelect: (item) => {
									let start, end, mode_0;
									const currentMode_0 = timeRangeRef.current;
									const quickSelectMode = ["static", "sliding-window"].includes(currentMode_0) ? currentMode_0 : "sliding-window";
									switch (item) {
										case "last-month": {
											const prevMonth = subMonths(currentMonth(), 1);
											start = firstDayOfMonth(prevMonth);
											end = lastDayOfMonth(prevMonth);
											mode_0 = "lastMonth";
											break;
										}
										case "1-month": {
											const [startMonth_2, endMonth_2] = getLatestRange(0);
											start = firstDayOfMonth(startMonth_2);
											end = lastDayOfMonth(endMonth_2);
											mode_0 = quickSelectMode;
											break;
										}
										case "3-months": {
											const [startMonth_1, endMonth_1] = getLatestRange(2);
											start = firstDayOfMonth(startMonth_1);
											end = lastDayOfMonth(endMonth_1);
											mode_0 = quickSelectMode;
											break;
										}
										case "6-months": {
											const [startMonth_0, endMonth_0] = getLatestRange(5);
											start = firstDayOfMonth(startMonth_0);
											end = lastDayOfMonth(endMonth_0);
											mode_0 = quickSelectMode;
											break;
										}
										case "1-year": {
											const [startMonth, endMonth] = getLatestRange(11);
											start = firstDayOfMonth(startMonth);
											end = lastDayOfMonth(endMonth);
											mode_0 = quickSelectMode;
											break;
										}
										case "year-to-date":
											[start, end] = getLiveRange("Year to date", _earliestTransaction, _latestTransaction, true);
											mode_0 = "yearToDate";
											break;
										case "last-year":
											[start, end] = getLiveRange("Last year", _earliestTransaction, _latestTransaction, false);
											mode_0 = "lastYear";
											break;
										case "prior-year-to-date":
											[start, end] = getLiveRange("Prior year to date", _earliestTransaction, _latestTransaction, false);
											mode_0 = "priorYearToDate";
											break;
										case "all-time":
											[start, end] = getLiveRange("All time", _earliestTransaction, _latestTransaction, true);
											mode_0 = "full";
											break;
										default: return;
									}
									setStartDate(start);
									setEndDate(end);
									timeRangeRef.current = mode_0;
									sendUpdate(filters.conditions, filters.conditionsOp, start, end, mode_0);
									setTimeRangeMenuOpen(false);
								},
								items: [
									{
										name: "1-month",
										text: t("1 month")
									},
									{
										name: "3-months",
										text: t("3 months")
									},
									{
										name: "6-months",
										text: t("6 months")
									},
									{
										name: "1-year",
										text: t("1 year")
									},
									Menu.line,
									{
										name: "year-to-date",
										text: t("Year to date")
									},
									{
										name: "last-month",
										text: t("Last month")
									},
									{
										name: "last-year",
										text: t("Last year")
									},
									{
										name: "prior-year-to-date",
										text: t("Prior year to date")
									},
									{
										name: "all-time",
										text: t("All time")
									}
								]
							})
						})
					]
				}), allMonths.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						display: "flex",
						flexDirection: "row",
						gap: 10,
						marginTop: 8,
						alignItems: "center"
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: fromDateRepr(startDate),
							onChange: (newValue) => {
								const [validatedStart] = validateStart(allMonths[allMonths.length - 1].name, allMonths[0].name, newValue, fromDateRepr(endDate));
								handleStartDateChange(validatedStart);
							},
							options: allMonths.map(({ name, pretty }) => [name, pretty]),
							style: { flex: 1 }
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
							style: {
								fontSize: 12,
								color: theme.pageTextSubdued
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "to" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: fromDateRepr(endDate),
							onChange: (newValue_0) => {
								const [, validatedEnd] = validateEnd(allMonths[allMonths.length - 1].name, allMonths[0].name, fromDateRepr(startDate), newValue_0);
								handleEndDateChange(validatedEnd);
							},
							options: allMonths.map(({ name: name_0, pretty: pretty_0 }) => [name_0, pretty_0]),
							style: { flex: 1 }
						})
					]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					marginBottom: 8,
					flex: 1
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						fontSize: 12,
						fontWeight: 500,
						marginBottom: 6,
						color: theme.pageTextSubdued
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Filters:" })
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						display: "flex",
						flexDirection: "column",
						alignItems: "center",
						gap: 8,
						maxWidth: 400,
						flex: 1
					},
					children: [filters.conditions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppliedFilters, {
						conditions: filters.conditions,
						onUpdate: filters.onUpdate,
						onDelete: filters.onDelete,
						conditionsOp: filters.conditionsOp,
						onConditionsOpChange: filters.onConditionsOpChange,
						style: { maxWidth: "100%" }
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterButton, {
						compact: false,
						onApply: filters.onApply,
						hover: false
					})]
				})]
			})
		]
	});
}
//#endregion
//#region src/components/reports/ReportCardValueSkeleton.tsx
var import_debounce = /* @__PURE__ */ __toESM(require_debounce());
var pulse$1 = keyframes({
	"0%, 100%": { opacity: .15 },
	"50%": { opacity: .4 }
});
var barBase = {
	width: "55%",
	maxWidth: 160,
	height: 32,
	borderRadius: 6,
	backgroundColor: theme.pageText
};
var staticBar = css({
	...barBase,
	opacity: .25
});
var pulsingBar = css({
	...barBase,
	animationName: pulse$1,
	animationDuration: "1.4s",
	animationTimingFunction: "ease-in-out",
	animationIterationCount: "infinite"
});
function ReportCardValueSkeleton() {
	const $ = (0, import_compiler_runtime.c)(3);
	const reducedMotion = useReducedMotion();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = {
			flex: 1,
			justifyContent: "center",
			alignItems: "center",
			width: "100%"
		};
		$[0] = t0;
	} else t0 = $[0];
	const t1 = reducedMotion ? staticBar : pulsingBar;
	let t2;
	if ($[1] !== t1) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t0,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				"aria-hidden": "true",
				className: t1
			})
		});
		$[1] = t1;
		$[2] = t2;
	} else t2 = $[2];
	return t2;
}
//#endregion
//#region src/components/reports/FormulaResult.tsx
var FONT_SIZE_SCALE_FACTOR$1 = 1.6;
var CONTAINER_MARGIN$1 = 8;
function FormulaResult({ value, animate = false, loading = true, error = null, initialFontSize = 14, fontSizeChanged, fontSizeMode = "dynamic", staticFontSize = 32, customColor = null, containerRef }) {
	const [fontSize, setFontSize] = (0, import_react.useState)(initialFontSize);
	const [hasSized, setHasSized] = (0, import_react.useState)(false);
	const refDiv = (0, import_react.useRef)(null);
	const previousFontSizeRef = (0, import_react.useRef)(initialFontSize);
	const format = useFormat();
	const displayValue = (0, import_react.useMemo)(() => {
		if (error) return error;
		else if (value === null || value === void 0) return "";
		else if (typeof value === "number") return format(amountToInteger(value, format.currency.decimalPlaces), "financial");
		else return String(value);
	}, [
		error,
		value,
		format
	]);
	const calculateFontSize = (0, import_react.useCallback)(() => {
		if (!refDiv.current) return;
		const { clientWidth, clientHeight } = containerRef?.current || refDiv.current.parentElement || refDiv.current;
		const width = clientWidth;
		const height = clientHeight - CONTAINER_MARGIN$1 * 2;
		if (width <= 0 || height <= 0) return;
		const valueLength = displayValue.length || 1;
		const calculatedFontSize = Math.min(width * FONT_SIZE_SCALE_FACTOR$1 / valueLength, height);
		if (calculatedFontSize > 0) {
			setFontSize(calculatedFontSize);
			setHasSized(true);
		}
		if (fontSizeChanged && Math.abs(calculatedFontSize - previousFontSizeRef.current) > .5) {
			previousFontSizeRef.current = calculatedFontSize;
			fontSizeChanged(calculatedFontSize);
		}
	}, [
		displayValue,
		fontSizeChanged,
		containerRef
	]);
	const debouncedCalculateFontSize = (0, import_react.useRef)((0, import_debounce.default)(() => {
		if (fontSizeMode === "dynamic") calculateFontSize();
	}, 100));
	(0, import_react.useEffect)(() => {
		debouncedCalculateFontSize.current.cancel?.();
		debouncedCalculateFontSize.current = (0, import_debounce.default)(() => {
			if (fontSizeMode === "dynamic") calculateFontSize();
		}, 100);
		return () => {
			debouncedCalculateFontSize.current.cancel?.();
		};
	}, [calculateFontSize, fontSizeMode]);
	const mergedRef = useMergedRefs(useResizeObserver(() => {
		if (fontSizeMode === "dynamic") debouncedCalculateFontSize.current();
	}), refDiv);
	(0, import_react.useEffect)(() => {
		if (fontSizeMode === "dynamic") calculateFontSize();
	}, [
		displayValue,
		calculateFontSize,
		fontSizeMode
	]);
	(0, import_react.useEffect)(() => {
		if (fontSizeMode === "static") {
			setFontSize(staticFontSize);
			setHasSized(true);
		}
	}, [fontSizeMode, staticFontSize]);
	const color = customColor ? customColor : error ? theme.errorText : theme.pageText;
	const showContent = hasSized || fontSizeMode === "static";
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: { flex: 1 },
		children: [loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardValueSkeleton, {}), !loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			ref: mergedRef,
			"aria-label": displayValue,
			style: {
				alignItems: "center",
				flexGrow: 1,
				flexShrink: 1,
				width: "100%",
				height: "100%",
				maxWidth: "100%",
				fontSize,
				lineHeight: 1,
				margin: `${CONTAINER_MARGIN$1}px 0`,
				justifyContent: "center",
				transition: animate ? "font-size 0.3s ease" : "",
				color
			},
			children: !showContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardValueSkeleton, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
				"aria-hidden": "true",
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: displayValue })
			})
		})]
	});
}
//#endregion
//#region src/hooks/useFormulaExecution.ts
function escapeRegExp(s) {
	return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function parseBudgetParam(param) {
	param = param.trim();
	const extractMatch = param.match(/^(QUERY_EXTRACT_\w+)\s*\(\s*["']([^"']+)["']\s*\)$/);
	if (extractMatch) return {
		type: "extraction",
		data: {
			funcName: extractMatch[1],
			queryName: extractMatch[2]
		}
	};
	const arrayMatch = param.match(/^\{([^}]*)\}$/);
	if (arrayMatch) return {
		type: "literal",
		data: arrayMatch[1].split(";").map((item) => item.replace(/^["']|["']$/g, "").trim()).filter((item) => item.length > 0)
	};
	const stringMatch = param.match(/^["']([^"']*)["']$/);
	if (stringMatch) return {
		type: "literal",
		data: stringMatch[1]
	};
	return null;
}
function resolveBudgetParam(parsed, extractionResults) {
	if (!parsed || parsed.type === "literal") return parsed?.data;
	const { funcName, queryName } = parsed.data;
	return extractionResults[funcName]?.[`${funcName}(${queryName})`];
}
function useFormulaExecution(formula, queries, queriesVersion, namedExpressions) {
	const locale = useLocale();
	const [result, setResult] = (0, import_react.useState)(null);
	const [isLoading, setIsLoading] = (0, import_react.useState)(false);
	const [error, setError] = (0, import_react.useState)(null);
	(0, import_react.useEffect)(() => {
		let cancelled = false;
		async function executeFormula() {
			let hfInstance = null;
			if (!formula || !formula.startsWith("=")) {
				setResult(null);
				setError("Formula must start with =");
				return;
			}
			setIsLoading(true);
			setError(null);
			try {
				const queryMatches = Array.from(formula.matchAll(/QUERY\s*\(\s*["']([^"']+)["']\s*\)/gi));
				const queryCountMatches = Array.from(formula.matchAll(/QUERY_COUNT\s*\(\s*["']([^"']+)["']\s*\)/gi));
				const queryData = {};
				const queryCountData = {};
				const queryNames = Array.from(new Set(queryMatches.map((m) => m[1])));
				const queryCountNames = Array.from(new Set(queryCountMatches.map((m) => m[1])));
				const extractionFunctions = {
					QUERY_EXTRACT_CATEGORIES: /QUERY_EXTRACT_CATEGORIES\s*\(\s*["']([^"']+)["']\s*\)/gi,
					QUERY_EXTRACT_TIMEFRAME_START: /QUERY_EXTRACT_TIMEFRAME_START\s*\(\s*["']([^"']+)["']\s*\)/gi,
					QUERY_EXTRACT_TIMEFRAME_END: /QUERY_EXTRACT_TIMEFRAME_END\s*\(\s*["']([^"']+)["']\s*\)/gi
				};
				const extractionResults = {
					QUERY_EXTRACT_CATEGORIES: {},
					QUERY_EXTRACT_TIMEFRAME_START: {},
					QUERY_EXTRACT_TIMEFRAME_END: {}
				};
				for (const [funcName, regex] of Object.entries(extractionFunctions)) {
					const matches = Array.from(formula.matchAll(regex));
					for (const match of matches) {
						const queryName = match[1];
						const key = `${funcName}(${queryName})`;
						if (!extractionResults[funcName][key]) try {
							if (funcName === "QUERY_EXTRACT_CATEGORIES") extractionResults[funcName][key] = await extractQueryCategories(queryName, queries);
							else if (funcName === "QUERY_EXTRACT_TIMEFRAME_START") extractionResults[funcName][key] = await extractQueryTimeframeStart(queryName, queries);
							else if (funcName === "QUERY_EXTRACT_TIMEFRAME_END") extractionResults[funcName][key] = await extractQueryTimeframeEnd(queryName, queries);
						} catch (err) {
							console.error(`Error evaluating ${funcName}(${queryName})`, err);
							extractionResults[funcName][key] = null;
						}
					}
				}
				const paramPattern = String.raw`(?:QUERY_EXTRACT_\w+\s*\([^)]*\)|\{[^}]*\}|["'][^"']*["'])`;
				const budgetMatches = Array.from(formula.matchAll(new RegExp(`BUDGET_QUERY\\s*\\(\\s*["']([^"']+)["']\\s*,\\s*(${paramPattern})\\s*,\\s*(${paramPattern})\\s*,\\s*(${paramPattern})\\s*\\)`, "gi")));
				for (const queryName of queryNames) {
					const queryConfig = queries[queryName];
					if (!queryConfig) {
						console.warn(`Query "${queryName}" not found in queries config`);
						queryData[queryName] = 0;
						continue;
					}
					queryData[queryName] = integerToAmount(await fetchQuerySum(queryConfig), 2);
				}
				for (const queryName of queryCountNames) {
					const queryConfig = queries[queryName];
					if (!queryConfig) {
						console.warn(`Query "${queryName}" not found in queries config`);
						queryCountData[queryName] = 0;
						continue;
					}
					queryCountData[queryName] = await fetchQueryCount(queryConfig);
				}
				let processedFormula = formula;
				for (const [queryName, value] of Object.entries(queryData)) {
					const regex = new RegExp(`QUERY\\s*\\(\\s*["']${escapeRegExp(queryName)}["']\\s*\\)`, "gi");
					processedFormula = processedFormula.replace(regex, String(value));
				}
				for (const [queryName, value] of Object.entries(queryCountData)) {
					const regex = new RegExp(`QUERY_COUNT\\s*\\(\\s*["']${escapeRegExp(queryName)}["']\\s*\\)`, "gi");
					processedFormula = processedFormula.replace(regex, String(value));
				}
				if (budgetMatches.length > 0) for (const match of budgetMatches) {
					const dimension = match[1];
					const param1Str = match[2].trim();
					const param2Str = match[3].trim();
					const param3Str = match[4].trim();
					try {
						const param1 = resolveBudgetParam(parseBudgetParam(param1Str), extractionResults);
						const param2 = resolveBudgetParam(parseBudgetParam(param2Str), extractionResults);
						const param3 = resolveBudgetParam(parseBudgetParam(param3Str), extractionResults);
						if (!Array.isArray(param1) || typeof param2 !== "string" || typeof param3 !== "string") {
							console.error("Failed to resolve BUDGET_QUERY parameters:", param1Str, param2Str, param3Str);
							continue;
						}
						const val = await fetchBudgetDimensionValueDirect(dimension, param1, param2, param3);
						processedFormula = processedFormula.replace(match[0], String(val));
					} catch (err) {
						console.error("Error evaluating BUDGET_QUERY", err);
					}
				}
				for (const [funcName, regex] of Object.entries(extractionFunctions)) {
					const matches = Array.from(processedFormula.matchAll(regex));
					for (const match of matches) {
						const queryName = match[1];
						const key = `${funcName}(${queryName})`;
						const value = extractionResults[funcName][key];
						if (value !== null && value !== void 0) {
							const escapedQueryName = escapeRegExp(queryName);
							const replacementRegex = new RegExp(`${funcName}\\s*\\(\\s*["']${escapedQueryName}["']\\s*\\)`, "gi");
							let replacement;
							if (Array.isArray(value)) replacement = `{${value.map((v) => `"${v}"`).join(";")}}`;
							else if (typeof value === "string") replacement = `"${value}"`;
							else replacement = String(value);
							processedFormula = processedFormula.replace(replacementRegex, replacement);
						}
					}
				}
				hfInstance = HyperFormula.buildEmpty({
					licenseKey: "gpl-v3",
					language: "enUS",
					localeLang: typeof locale === "string" ? locale : "en-US",
					dateFormats: [
						"DD/MM/YYYY",
						"YYYY-MM-DD",
						"YYYY/MM/DD"
					]
				});
				const sheetName = hfInstance.addSheet("Sheet1");
				const sheetId = hfInstance.getSheetId(sheetName);
				if (sheetId === void 0) throw new Error("Failed to create sheet");
				if (namedExpressions) for (const [name, value] of Object.entries(namedExpressions)) hfInstance.addNamedExpression(name, typeof value === "number" ? value : String(value));
				hfInstance.setCellContents({
					sheet: sheetId,
					col: 0,
					row: 0
				}, [[processedFormula]]);
				const cellValue = hfInstance.getCellValue({
					sheet: sheetId,
					col: 0,
					row: 0
				});
				if (cancelled) return;
				if (cellValue && typeof cellValue === "object" && "type" in cellValue) {
					setError(`Formula error: ${cellValue.type}`);
					setResult(null);
				} else {
					setResult(cellValue);
					setError(null);
				}
			} catch (err) {
				if (cancelled) return;
				console.error("Formula execution error:", err);
				setError(err instanceof Error ? err.message : "Unknown error");
				setResult(null);
			} finally {
				if (!cancelled) setIsLoading(false);
				try {
					hfInstance?.destroy();
				} catch (err) {
					console.error("Error destroying HyperFormula instance:", err);
					setError("Error destroying HyperFormula instance");
					setResult(null);
				}
			}
		}
		executeFormula();
		return () => {
			cancelled = true;
		};
	}, [
		formula,
		queriesVersion,
		locale,
		queries,
		namedExpressions
	]);
	return {
		result,
		isLoading,
		error
	};
}
function timeFrameModeToCondition(mode) {
	switch (mode) {
		case "full": return "All time";
		case "lastMonth": return "Last month";
		case "lastYear": return "Last year";
		case "yearToDate": return "Year to date";
		case "priorYearToDate": return "Prior year to date";
		case "sliding-window": return null;
		case "static": return null;
		default: return null;
	}
}
function isMonthOnlyDate(s) {
	return s.includes("-") && s.split("-").length === 2;
}
function toMonth(dateOrMonth) {
	return isMonthOnlyDate(dateOrMonth) ? dateOrMonth : monthFromDate(dateOrMonth);
}
async function buildFilteredTransactionsQuery(config) {
	const conditions = config.conditions || [];
	const conditionsOp = config.conditionsOp || "and";
	const timeFrame = config.timeFrame;
	const { filters: queryFilters } = await send("make-filters-from-conditions", { conditions });
	const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
	let transQuery = q$1("transactions");
	if (timeFrame && timeFrame.mode) {
		let startDate;
		let endDate;
		if ((timeFrame.mode === "sliding-window" || timeFrame.mode === "static") && timeFrame.start && timeFrame.end) if (timeFrame.mode === "sliding-window") {
			const startMonth = toMonth(timeFrame.start);
			const offset = differenceInCalendarMonths(toMonth(timeFrame.end), startMonth);
			startDate = firstDayOfMonth(subMonths(currentMonth(), offset));
			endDate = currentDay();
		} else {
			startDate = isMonthOnlyDate(timeFrame.start) ? timeFrame.start + "-01" : timeFrame.start;
			endDate = isMonthOnlyDate(timeFrame.end) ? getMonthEnd(timeFrame.end + "-01") : timeFrame.end;
		}
		else {
			const condition = timeFrameModeToCondition(timeFrame.mode);
			if (condition) {
				const earliestTransaction = await send("get-earliest-transaction");
				const latestTransaction = await send("get-latest-transaction");
				const [calculatedStart, calculatedEnd] = getLiveRange(condition, earliestTransaction ? earliestTransaction.date : currentDay(), latestTransaction ? latestTransaction.date : currentDay(), true);
				startDate = calculatedStart;
				endDate = calculatedEnd;
			}
		}
		if (startDate && endDate) transQuery = transQuery.filter({ $and: [{ date: { $gte: startDate } }, { date: { $lte: endDate } }] });
	}
	if (queryFilters.length > 0) transQuery = transQuery.filter({ [conditionsOpKey]: queryFilters });
	return transQuery;
}
async function fetchQuerySum(config) {
	try {
		const { data } = await send("query", (await buildFilteredTransactionsQuery(config)).calculate({ $sum: "$amount" }).serialize());
		return data || 0;
	} catch (err) {
		console.error("Error fetching query sum:", err);
		return 0;
	}
}
async function fetchQueryCount(config) {
	try {
		const { data } = await send("query", (await buildFilteredTransactionsQuery(config)).calculate({ $count: "*" }).serialize());
		return data || 0;
	} catch (err) {
		console.error("Error fetching query count:", err);
		return 0;
	}
}
function extractCategoryConditions(conditions) {
	return conditions.filter((cond) => !cond.customName && cond.field === "category");
}
async function getCategoriesFromConditions(allCategories, conditions, conditionsOp) {
	if (conditions.length === 0) return allCategories.filter((cat) => !cat.is_income && !cat.hidden).map((cat) => cat.id);
	const conditionResults = conditions.map((cond) => {
		return allCategories.filter((cat) => {
			if (cond.op === "is") return cond.value === cat.id;
			else if (cond.op === "isNot") return cond.value !== cat.id;
			else if (cond.op === "oneOf") return cond.value.includes(cat.id);
			else if (cond.op === "notOneOf") return !cond.value.includes(cat.id);
			else if (cond.op === "contains") return cat.name.includes(cond.value);
			else if (cond.op === "doesNotContain") return !cat.name.includes(cond.value);
			else if (cond.op === "matches") try {
				return new RegExp(cond.value).test(cat.name);
			} catch (e) {
				console.warn("Invalid regexp in matches condition", e);
				return true;
			}
			console.warn(`Unknown category condition operator: ${cond.op}`);
			return true;
		}).map((cat) => cat.id);
	});
	if (conditionsOp === "or") {
		const categoryIds = new Set(conditionResults.flat());
		return Array.from(categoryIds);
	} else {
		if (conditionResults.length === 0) return [];
		const firstSet = new Set(conditionResults[0]);
		for (let i = 1; i < conditionResults.length; i++) {
			const currentIds = new Set(conditionResults[i]);
			const toRemove = [];
			firstSet.forEach((id) => {
				if (!currentIds.has(id)) toRemove.push(id);
			});
			toRemove.forEach((id) => firstSet.delete(id));
		}
		return Array.from(firstSet);
	}
}
async function getMonthBudgetData(month) {
	return await send("envelope-budget-month", { month }) || [];
}
function getMonthDataValue(monthData, pattern, catId) {
	const fieldName = pattern.replace("{catId}", catId);
	return monthData.find((c) => c.name.endsWith(fieldName))?.value ?? 0;
}
async function extractQueryCategories(queryName, queries) {
	const queryConfig = queries[queryName];
	if (!queryConfig) {
		console.warn(`Query "${queryName}" not found in queries config`);
		return [];
	}
	const categoryConditions = extractCategoryConditions(queryConfig.conditions || []);
	const { list: allCategories } = await send("get-categories");
	return getCategoriesFromConditions(allCategories, categoryConditions, queryConfig.conditionsOp || "and");
}
async function extractQueryTimeframeStart(queryName, queries) {
	const queryConfig = queries[queryName];
	if (!queryConfig || !queryConfig.timeFrame) {
		console.warn(`Query "${queryName}" not found or has no timeframe; cannot extract start`);
		return currentMonth();
	}
	const [startMonth] = calculateTimeRange(queryConfig.timeFrame);
	return startMonth;
}
async function extractQueryTimeframeEnd(queryName, queries) {
	const queryConfig = queries[queryName];
	if (!queryConfig || !queryConfig.timeFrame) {
		console.warn(`Query "${queryName}" not found or has no timeframe; cannot extract end`);
		return currentMonth();
	}
	const [, endMonth] = calculateTimeRange(queryConfig.timeFrame);
	return endMonth;
}
async function fetchBudgetDimensionValueDirect(dimension, categoryIds, startMonth, endMonth) {
	const allowed = new Set([
		"budgeted",
		"spent",
		"balance_start",
		"balance_end",
		"goal"
	]);
	const dim = dimension.toLowerCase();
	if (!allowed.has(dim)) throw new Error(`Invalid BUDGET_QUERY dimension: ${dimension}`);
	const intervals = rangeInclusive(startMonth, endMonth);
	const sumDimension = async (fieldPattern) => {
		let total = 0;
		for (const month of intervals) {
			const monthData = await getMonthBudgetData(month);
			for (const catId of categoryIds) total += getMonthDataValue(monthData, fieldPattern, catId);
		}
		return total;
	};
	if (dim === "budgeted") return integerToAmount(await sumDimension("budget-{catId}"), 2);
	if (dim === "spent") return integerToAmount(await sumDimension("sum-amount-{catId}"), 2);
	if (dim === "goal") return integerToAmount(await sumDimension("goal-{catId}"), 2);
	if (dim === "balance_start" || dim === "balance_end") {
		let runningBalance = 0;
		const prevMonthData = await getMonthBudgetData(subMonths(startMonth, 1));
		for (const catId of categoryIds) {
			const catBalance = getMonthDataValue(prevMonthData, "leftover-{catId}", catId);
			const hasCarryover = Boolean(getMonthDataValue(prevMonthData, "carryover-{catId}", catId));
			if (catBalance > 0 || catBalance < 0 && hasCarryover) runningBalance += catBalance;
		}
		const balances = {};
		for (const month of intervals) {
			const monthData = await getMonthBudgetData(month);
			let budgeted = 0;
			let spent = 0;
			let carryoverToNextMonth = 0;
			for (const catId of categoryIds) {
				const catBudgeted = Number(getMonthDataValue(monthData, "budget-{catId}", catId)) || 0;
				const catSpent = Number(getMonthDataValue(monthData, "sum-amount-{catId}", catId)) || 0;
				const catBalance = Number(getMonthDataValue(monthData, "leftover-{catId}", catId)) || 0;
				const hasCarryover = Boolean(getMonthDataValue(monthData, "carryover-{catId}", catId));
				budgeted += catBudgeted;
				spent += catSpent;
				if (catBalance > 0 || catBalance < 0 && hasCarryover) carryoverToNextMonth += catBalance;
			}
			balances[month] = {
				start: runningBalance,
				end: budgeted + spent + runningBalance
			};
			runningBalance = carryoverToNextMonth;
		}
		if (dim === "balance_start") return integerToAmount(balances[intervals[0]]?.start || 0, 2);
		return integerToAmount(balances[intervals[intervals.length - 1]]?.end || 0, 2);
	}
	return 0;
}
//#endregion
//#region src/hooks/useThemeColors.ts
var VAR_STRING_REGEX = /^var\((--.*)\)$/;
function getPropertyValueFromVarString(varString) {
	if (VAR_STRING_REGEX.test(varString)) {
		const match = varString.match(VAR_STRING_REGEX);
		if (match) return window.getComputedStyle(document.documentElement).getPropertyValue(match[1]).trim();
	}
	return varString;
}
function useThemeColors() {
	return (0, import_react.useMemo)(() => {
		const colors = {};
		for (const [key, value] of Object.entries(theme)) {
			const computedValue = getPropertyValueFromVarString(value);
			if (computedValue) colors[key] = computedValue;
		}
		return colors;
	}, []);
}
//#endregion
//#region src/components/reports/reports/Formula.tsx
var FormulaEditor = (0, import_react.lazy)(() => __vitePreload(() => import("./FormulaEditor.0HQ2ATyO.chunk.js").then((module) => ({ default: module.FormulaEditor })), __vite__mapDeps([0,1,2,3])));
function Formula() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "formula-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function FormulaInner({ widget }) {
	const { t } = useTranslation();
	const dispatch = useDispatch();
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const themeColors = useThemeColors();
	const queriesRef = (0, import_react.useRef)(widget?.meta?.queries || {});
	const [queriesVersion, setQueriesVersion] = (0, import_react.useState)(0);
	const [formula, setFormula] = (0, import_react.useState)(widget?.meta?.formula || "=SUM(1, 2, 3)");
	const [fontSizeMode, setFontSizeMode] = (0, import_react.useState)(widget?.meta?.fontSizeMode || "dynamic");
	const [staticFontSize, setStaticFontSize] = (0, import_react.useState)(widget?.meta?.staticFontSize || 32);
	const [colorFormula, setColorFormula] = (0, import_react.useState)(widget?.meta?.colorFormula || "");
	const title = widget?.meta?.name || t("Formula");
	const { result, isLoading: isExecuting, error } = useFormulaExecution(formula, queriesRef.current, queriesVersion);
	const colorVariables = (0, import_react.useMemo)(() => ({
		RESULT: result ?? 0,
		...Object.entries(themeColors).reduce((acc, [key, value]) => {
			acc[`theme_${key}`] = value;
			return acc;
		}, {})
	}), [result, themeColors]);
	const { result: colorResult, error: colorError } = useFormulaExecution(colorFormula, queriesRef.current, queriesVersion, colorVariables);
	const handleQueriesChange = (0, import_react.useCallback)((newQueries) => {
		queriesRef.current = newQueries;
		setQueriesVersion((v) => v + 1);
	}, []);
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	const onSaveWidgetName = async (newName) => {
		if (!widget) {
			dispatch(addNotification({ notification: {
				type: "error",
				message: t("Cannot save: No widget available.")
			} }));
			return;
		}
		const name = newName || t("Formula");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				name,
				formula,
				queries: queriesRef.current,
				fontSizeMode,
				staticFontSize,
				colorFormula
			}
		} });
	};
	async function onSaveWidget() {
		if (!widget) {
			dispatch(addNotification({ notification: {
				type: "error",
				message: t("Cannot save: No widget available.")
			} }));
			return;
		}
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				formula,
				queries: queriesRef.current,
				fontSizeMode,
				staticFontSize,
				colorFormula
			}
		} }, { onSuccess: () => {
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Dashboard widget successfully saved.")
			} }));
		} });
	}
	const customColor = colorFormula && !colorError && colorResult ? String(colorResult) : null;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title }),
		padding: 0,
		children: [widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: 20,
				display: "flex",
				justifyContent: "flex-end",
				flexDirection: "row",
				background: theme.pageBackground
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: onSaveWidget,
				style: { width: 100 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				width: "100%",
				height: "100%",
				background: theme.pageBackground,
				display: "flex",
				flexDirection: "row"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flex: 1,
					display: "flex",
					flexDirection: "column"
				},
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							padding: 20,
							flexDirection: "column",
							justifyContent: "space-between",
							gap: 10,
							minHeight: 120
						},
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontSize: 14,
								color: theme.pageTextSubdued
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Result:" })
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
							style: {
								height: 120,
								width: "100%",
								overflow: "auto",
								backgroundColor: theme.cardBackground,
								borderRadius: 6,
								...styles.horizontalScrollbar,
								"::-webkit-scrollbar": { height: "8px" }
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaResult, {
								value: result,
								error,
								loading: isExecuting,
								fontSizeMode,
								staticFontSize,
								customColor
							})
						})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							flex: 1,
							minHeight: 50,
							margin: 20,
							overflow: "hidden"
						},
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontSize: 13,
								color: theme.pageTextSubdued,
								marginBottom: 5
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Formula:" })
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
							fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: { padding: 10 },
								children: "Loading..."
							}),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaEditor, {
								value: formula,
								onChange: setFormula,
								mode: "query",
								queries: queriesRef.current,
								singleLine: false,
								showLineNumbers: true
							})
						})]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							padding: "0 20px 20px 20px",
							display: "flex",
							flexDirection: "row",
							gap: 20,
							alignItems: "flex-end"
						},
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontSize: 13,
								color: theme.pageTextSubdued,
								marginBottom: 5
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Font size:" })
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: fontSizeMode,
							onChange: (value_0) => setFontSizeMode(value_0),
							options: [["dynamic", t("Dynamic")], ["static", t("Static")]]
						})] }), fontSizeMode === "static" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							style: {
								fontSize: 13,
								color: theme.pageTextSubdued,
								marginBottom: 5
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Font size (px):" })
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
							type: "number",
							value: String(staticFontSize),
							onChange: (e) => setStaticFontSize(Number(e.target.value))
						})] })]
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: {
							padding: 20,
							marginBottom: 20
						},
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: {
									fontSize: 13,
									color: theme.pageTextSubdued,
									marginBottom: 5
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Conditional color (optional):" })
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: {
									border: `1px solid ${theme.formInputBorder}`,
									borderRadius: 4,
									overflow: "hidden",
									backgroundColor: theme.tableBackground
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
									fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { height: 32 } }),
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaEditor, {
										value: colorFormula,
										variables: colorVariables,
										onChange: setColorFormula,
										mode: "query",
										queries: queriesRef.current,
										singleLine: true,
										showLineNumbers: false
									})
								})
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								style: {
									fontSize: 11,
									color: theme.pageTextSubdued,
									marginTop: 5
								},
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Formula that returns a color (e.g., “red”, “#ff0000”). Leave blank for default. Use RESULT variable to access the main formula result." })
							})
						]
					})
				]
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: { overflowY: "auto" },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryManager, {
					queries: queriesRef.current,
					onQueriesChange: handleQueriesChange
				})
			})]
		})]
	});
}
//#endregion
//#region src/components/reports/graphs/NetWorthGraph.tsx
function TrendTooltip(t0) {
	const $ = (0, import_compiler_runtime.c)(45);
	const { active, payload, style } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		if ($[0] !== style) {
			t1 = css([{
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			}, style]);
			$[0] = style;
			$[1] = t1;
		} else t1 = $[1];
		let t2;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t2 = { marginBottom: 10 };
			$[2] = t2;
		} else t2 = $[2];
		let t3;
		if ($[3] !== payload[0].payload.date) {
			t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t2,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
			});
			$[3] = payload[0].payload.date;
			$[4] = t3;
		} else t3 = $[4];
		let t4;
		if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = { lineHeight: 1.5 };
			$[5] = t4;
		} else t4 = $[5];
		let t5;
		if ($[6] !== t) {
			t5 = t("Assets:");
			$[6] = t;
			$[7] = t5;
		} else t5 = $[7];
		let t6;
		if ($[8] !== payload[0].payload.assets) {
			t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: payload[0].payload.assets });
			$[8] = payload[0].payload.assets;
			$[9] = t6;
		} else t6 = $[9];
		let t7;
		if ($[10] !== t5 || $[11] !== t6) {
			t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t5,
				right: t6
			});
			$[10] = t5;
			$[11] = t6;
			$[12] = t7;
		} else t7 = $[12];
		let t8;
		if ($[13] !== t) {
			t8 = t("Debt:");
			$[13] = t;
			$[14] = t8;
		} else t8 = $[14];
		let t9;
		if ($[15] !== payload[0].payload.debt) {
			t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: payload[0].payload.debt });
			$[15] = payload[0].payload.debt;
			$[16] = t9;
		} else t9 = $[16];
		let t10;
		if ($[17] !== t8 || $[18] !== t9) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t8,
				right: t9
			});
			$[17] = t8;
			$[18] = t9;
			$[19] = t10;
		} else t10 = $[19];
		let t11;
		if ($[20] !== t) {
			t11 = t("Net worth:");
			$[20] = t;
			$[21] = t11;
		} else t11 = $[21];
		let t12;
		if ($[22] !== payload[0].payload.networth) {
			t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
				as: "strong",
				children: payload[0].payload.networth
			});
			$[22] = payload[0].payload.networth;
			$[23] = t12;
		} else t12 = $[23];
		let t13;
		if ($[24] !== t11 || $[25] !== t12) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t11,
				right: t12
			});
			$[24] = t11;
			$[25] = t12;
			$[26] = t13;
		} else t13 = $[26];
		let t14;
		if ($[27] !== t) {
			t14 = t("Change:");
			$[27] = t;
			$[28] = t14;
		} else t14 = $[28];
		let t15;
		if ($[29] !== payload[0].payload.change) {
			t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: payload[0].payload.change });
			$[29] = payload[0].payload.change;
			$[30] = t15;
		} else t15 = $[30];
		let t16;
		if ($[31] !== t14 || $[32] !== t15) {
			t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t14,
				right: t15
			});
			$[31] = t14;
			$[32] = t15;
			$[33] = t16;
		} else t16 = $[33];
		let t17;
		if ($[34] !== t10 || $[35] !== t13 || $[36] !== t16 || $[37] !== t7) {
			t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t4,
				children: [
					t7,
					t10,
					t13,
					t16
				]
			});
			$[34] = t10;
			$[35] = t13;
			$[36] = t16;
			$[37] = t7;
			$[38] = t17;
		} else t17 = $[38];
		let t18;
		if ($[39] !== t17 || $[40] !== t3) {
			t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t3, t17] });
			$[39] = t17;
			$[40] = t3;
			$[41] = t18;
		} else t18 = $[41];
		let t19;
		if ($[42] !== t1 || $[43] !== t18) {
			t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t1,
				children: t18
			});
			$[42] = t1;
			$[43] = t18;
			$[44] = t19;
		} else t19 = $[44];
		return t19;
	}
	return null;
}
function StackedTooltip(t0) {
	const $ = (0, import_compiler_runtime.c)(78);
	const { active, payload, sortedAccounts, accounts, hoveredAccountId, format } = t0;
	if (active && payload && payload.length) {
		let T0;
		let showPercentage;
		let t1;
		let t2;
		let t3;
		let t4;
		let t5;
		let t6;
		let t7;
		let t8;
		let t9;
		if ($[0] !== accounts || $[1] !== format || $[2] !== hoveredAccountId || $[3] !== payload || $[4] !== sortedAccounts) {
			const total = payload.reduce(_temp$7, 0);
			if ($[16] !== accounts || $[17] !== format || $[18] !== hoveredAccountId || $[19] !== payload || $[20] !== sortedAccounts || $[21] !== total) {
				let t10;
				if ($[28] !== sortedAccounts) {
					t10 = (a, b) => {
						const indexA = sortedAccounts.findIndex((acc_0) => acc_0.id === a.dataKey);
						return sortedAccounts.findIndex((acc_1) => acc_1.id === b.dataKey) - indexA;
					};
					$[28] = sortedAccounts;
					$[29] = t10;
				} else t10 = $[29];
				const sortedPayload = [...payload].sort(t10);
				let t11;
				if ($[30] !== payload) {
					t11 = payload.some(_temp2$4);
					$[30] = payload;
					$[31] = t11;
				} else t11 = $[31];
				const hasPositive = t11;
				let t12;
				if ($[32] !== payload) {
					t12 = payload.some(_temp3$3);
					$[32] = payload;
					$[33] = t12;
				} else t12 = $[33];
				showPercentage = !(hasPositive && t12);
				let t13;
				if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
					t8 = css([{
						zIndex: 1e3,
						pointerEvents: "auto",
						borderRadius: 2,
						boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
						backgroundColor: theme.menuBackground,
						color: theme.menuItemText,
						padding: 10,
						fontSize: 12,
						maxHeight: "80vh",
						overflowY: "auto"
					}]);
					t13 = {
						marginBottom: 10,
						fontWeight: "bold"
					};
					$[34] = t13;
					$[35] = t8;
				} else {
					t13 = $[34];
					t8 = $[35];
				}
				if ($[36] !== payload[0].payload.date) {
					t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						style: t13,
						children: payload[0].payload.date
					});
					$[36] = payload[0].payload.date;
					$[37] = t9;
				} else t9 = $[37];
				let t14;
				let t15;
				if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
					t6 = {
						borderSpacing: "15px 0",
						marginLeft: "-15px"
					};
					t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
						style: {
							textAlign: "left",
							paddingLeft: 15
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Account" })
					});
					t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
						style: { textAlign: "right" },
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Value" })
					});
					$[38] = t14;
					$[39] = t15;
					$[40] = t6;
				} else {
					t14 = $[38];
					t15 = $[39];
					t6 = $[40];
				}
				let t16;
				if ($[41] !== showPercentage) {
					t16 = showPercentage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
						style: { textAlign: "right" },
						children: "%"
					});
					$[41] = showPercentage;
					$[42] = t16;
				} else t16 = $[42];
				if ($[43] !== t16) {
					t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
						t14,
						t15,
						t16
					] }) });
					$[43] = t16;
					$[44] = t7;
				} else t7 = $[44];
				let t17;
				if ($[45] !== accounts || $[46] !== format || $[47] !== hoveredAccountId || $[48] !== showPercentage || $[49] !== total) {
					t17 = (entry) => {
						const accountId = entry.dataKey;
						const accountName = accounts.find((a_0) => a_0.id === accountId)?.name || accountId;
						const value = Number(entry.value);
						const percent = total !== 0 ? value / total * 100 : 0;
						return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
							style: { color: entry.color },
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
									style: {
										textAlign: "left",
										paddingLeft: 15,
										textDecoration: hoveredAccountId === accountId ? "underline" : void 0
									},
									children: accountName
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
									style: { textAlign: "right" },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
										style: { color: theme.pageText },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(value, "financial") })
									})
								}),
								showPercentage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
									style: { textAlign: "right" },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
										style: { color: theme.pageText },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FinancialText, { children: [percent.toFixed(1), "%"] })
									})
								})
							]
						}, accountId);
					};
					$[45] = accounts;
					$[46] = format;
					$[47] = hoveredAccountId;
					$[48] = showPercentage;
					$[49] = total;
					$[50] = t17;
				} else t17 = $[50];
				t5 = sortedPayload.map(t17);
				$[16] = accounts;
				$[17] = format;
				$[18] = hoveredAccountId;
				$[19] = payload;
				$[20] = sortedAccounts;
				$[21] = total;
				$[22] = showPercentage;
				$[23] = t5;
				$[24] = t6;
				$[25] = t7;
				$[26] = t8;
				$[27] = t9;
			} else {
				showPercentage = $[22];
				t5 = $[23];
				t6 = $[24];
				t7 = $[25];
				t8 = $[26];
				t9 = $[27];
			}
			if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
				t3 = {
					fontWeight: "bold",
					borderTop: "1px solid " + theme.tableBorder
				};
				t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
					style: {
						textAlign: "left",
						paddingLeft: 15,
						paddingTop: 5
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Total" })
				});
				t2 = {
					textAlign: "right",
					paddingTop: 5
				};
				$[51] = t2;
				$[52] = t3;
				$[53] = t4;
			} else {
				t2 = $[51];
				t3 = $[52];
				t4 = $[53];
			}
			T0 = FinancialText;
			t1 = format(total, "financial");
			$[0] = accounts;
			$[1] = format;
			$[2] = hoveredAccountId;
			$[3] = payload;
			$[4] = sortedAccounts;
			$[5] = T0;
			$[6] = showPercentage;
			$[7] = t1;
			$[8] = t2;
			$[9] = t3;
			$[10] = t4;
			$[11] = t5;
			$[12] = t6;
			$[13] = t7;
			$[14] = t8;
			$[15] = t9;
		} else {
			T0 = $[5];
			showPercentage = $[6];
			t1 = $[7];
			t2 = $[8];
			t3 = $[9];
			t4 = $[10];
			t5 = $[11];
			t6 = $[12];
			t7 = $[13];
			t8 = $[14];
			t9 = $[15];
		}
		let t10;
		if ($[54] !== T0 || $[55] !== t1) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, { children: t1 });
			$[54] = T0;
			$[55] = t1;
			$[56] = t10;
		} else t10 = $[56];
		let t11;
		if ($[57] !== t10 || $[58] !== t2) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
				style: t2,
				children: t10
			});
			$[57] = t10;
			$[58] = t2;
			$[59] = t11;
		} else t11 = $[59];
		let t12;
		if ($[60] !== showPercentage) {
			t12 = showPercentage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
				style: {
					textAlign: "right",
					paddingTop: 5
				},
				children: "100.0%"
			});
			$[60] = showPercentage;
			$[61] = t12;
		} else t12 = $[61];
		let t13;
		if ($[62] !== t11 || $[63] !== t12 || $[64] !== t3 || $[65] !== t4) {
			t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
				style: t3,
				children: [
					t4,
					t11,
					t12
				]
			});
			$[62] = t11;
			$[63] = t12;
			$[64] = t3;
			$[65] = t4;
			$[66] = t13;
		} else t13 = $[66];
		let t14;
		if ($[67] !== t13 || $[68] !== t5) {
			t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [t5, t13] });
			$[67] = t13;
			$[68] = t5;
			$[69] = t14;
		} else t14 = $[69];
		let t15;
		if ($[70] !== t14 || $[71] !== t6 || $[72] !== t7) {
			t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
				style: t6,
				children: [t7, t14]
			});
			$[70] = t14;
			$[71] = t6;
			$[72] = t7;
			$[73] = t15;
		} else t15 = $[73];
		let t16;
		if ($[74] !== t15 || $[75] !== t8 || $[76] !== t9) {
			t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: t8,
				children: [t9, t15]
			});
			$[74] = t15;
			$[75] = t8;
			$[76] = t9;
			$[77] = t16;
		} else t16 = $[77];
		return t16;
	}
	return null;
}
function _temp3$3(p_1) {
	return (Number(p_1.value) || 0) < 0;
}
function _temp2$4(p_0) {
	return (Number(p_0.value) || 0) > 0;
}
function _temp$7(acc, p) {
	return acc + (Number(p.value) || 0);
}
function NetWorthGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(50);
	const { style, graphData, accounts: t1, compact: t2, showTooltip: t3, interval: t4, mode: t5 } = t0;
	let t6;
	if ($[0] !== t1) {
		t6 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t6;
	} else t6 = $[1];
	const accounts = t6;
	const compact = t2 === void 0 ? false : t2;
	const showTooltip = t3 === void 0 ? true : t3;
	const interval = t4 === void 0 ? "Monthly" : t4;
	const mode = t5 === void 0 ? "trend" : t5;
	const privacyMode = usePrivacyMode();
	const id = (0, import_react.useId)();
	const format = useFormat();
	let t7;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = { animationDuration: 1e3 };
		$[2] = t7;
	} else t7 = $[2];
	const animationProps = useRechartsAnimation(t7);
	const [isTooltipActive, setIsTooltipActive] = (0, import_react.useState)(false);
	const [hoveredAccountId, setHoveredAccountId] = (0, import_react.useState)(null);
	const { isNarrowWidth } = useResponsive();
	const effectiveShowTooltip = showTooltip && !isNarrowWidth;
	const interpolationType = interval === "Daily" || interval === "Weekly" ? "basis" : "monotone";
	let t8;
	if ($[3] !== format || $[4] !== privacyMode) {
		t8 = (tick) => {
			return privacyMode ? "..." : `${format(Math.round(tick), "financial-no-decimals")}`;
		};
		$[3] = format;
		$[4] = privacyMode;
		$[5] = t8;
	} else t8 = $[5];
	const tickFormatter = t8;
	let t9;
	if ($[6] !== graphData.data) {
		t9 = () => {
			const dataMax = Math.max(...graphData.data.map(_temp4$1));
			const dataMin = Math.min(...graphData.data.map(_temp5$1));
			if (dataMax <= 0) return 0;
			if (dataMin >= 0) return 1;
			return dataMax / (dataMax - dataMin);
		};
		$[6] = graphData.data;
		$[7] = t9;
	} else t9 = $[7];
	const off = t9();
	const gradientId = `splitColor-${id}`;
	let t10;
	bb0: {
		if (!accounts || mode !== "stacked") {
			let t11;
			if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
				t11 = [];
				$[8] = t11;
			} else t11 = $[8];
			t10 = t11;
			break bb0;
		}
		let t11;
		if ($[9] !== accounts || $[10] !== graphData.data) {
			let t12;
			if ($[12] !== graphData.data) {
				t12 = (acc, account) => {
					acc[account.id] = graphData.data.reduce((sum, point) => sum + (Number(point[account.id]) || 0), 0);
					return acc;
				};
				$[12] = graphData.data;
				$[13] = t12;
			} else t12 = $[13];
			t11 = accounts.reduce(t12, {});
			$[9] = accounts;
			$[10] = graphData.data;
			$[11] = t11;
		} else t11 = $[11];
		const totals = t11;
		let t12;
		if ($[14] !== accounts || $[15] !== totals) {
			let t13;
			if ($[17] !== totals) {
				t13 = (a, b) => totals[a.id] - totals[b.id];
				$[17] = totals;
				$[18] = t13;
			} else t13 = $[18];
			t12 = [...accounts].sort(t13);
			$[14] = accounts;
			$[15] = totals;
			$[16] = t12;
		} else t12 = $[16];
		t10 = t12;
	}
	const sortedAccounts = t10;
	let t11;
	bb1: {
		if (mode !== "stacked") {
			let t12;
			if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
				t12 = {};
				$[19] = t12;
			} else t12 = $[19];
			t11 = t12;
			break bb1;
		}
		let t12;
		if ($[20] !== sortedAccounts) {
			const scale = getColorScale("qualitative");
			t12 = sortedAccounts.reduce((acc_0, account_0, index) => {
				acc_0[account_0.id] = scale[index % scale.length];
				return acc_0;
			}, {});
			$[20] = sortedAccounts;
			$[21] = t12;
		} else t12 = $[21];
		t11 = t12;
	}
	const colors = t11;
	let t12;
	bb2: {
		if (interval !== "Daily") {
			t12 = void 0;
			break bb2;
		}
		let t13;
		if ($[22] !== graphData.data) {
			t13 = graphData.data.filter(_temp6$1).map(_temp7);
			$[22] = graphData.data;
			$[23] = t13;
		} else t13 = $[23];
		t12 = t13;
	}
	const weeklyTicks = t12;
	let t13;
	if ($[24] !== compact) {
		t13 = compact && { height: "auto" };
		$[24] = compact;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] !== style || $[27] !== t13) {
		t14 = {
			...style,
			...t13,
			position: "relative"
		};
		$[26] = style;
		$[27] = t13;
		$[28] = t14;
	} else t14 = $[28];
	let t15;
	if ($[29] !== accounts || $[30] !== animationProps || $[31] !== colors || $[32] !== compact || $[33] !== effectiveShowTooltip || $[34] !== format || $[35] !== gradientId || $[36] !== graphData || $[37] !== hoveredAccountId || $[38] !== interpolationType || $[39] !== isTooltipActive || $[40] !== mode || $[41] !== off || $[42] !== sortedAccounts || $[43] !== style || $[44] !== tickFormatter || $[45] !== weeklyTicks) {
		t15 = (width, height) => graphData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			style: {
				...!compact && { marginTop: "15px" },
				position: "relative"
			},
			onMouseLeave: () => {
				setIsTooltipActive(false);
				setHoveredAccountId(null);
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AreaChart, {
				responsive: true,
				width,
				height,
				data: graphData.data,
				margin: {
					top: 0,
					right: 0,
					left: compact ? 0 : computePadding(graphData.data.map(_temp8), (value) => format(value, "financial-no-decimals")),
					bottom: 0
				},
				onMouseMove: () => effectiveShowTooltip && !isTooltipActive && setIsTooltipActive(true),
				children: [
					compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
						strokeDasharray: "3 3",
						vertical: false
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
						dataKey: "x",
						hide: compact,
						tick: { fill: theme.pageText },
						tickLine: { stroke: theme.pageText },
						ticks: weeklyTicks
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
						dataKey: mode === "trend" ? "y" : void 0,
						domain: mode === "trend" ? ["auto", "auto"] : void 0,
						hide: compact,
						tickFormatter,
						tick: { fill: theme.pageText },
						tickLine: { stroke: theme.pageText }
					}),
					effectiveShowTooltip && mode === "trend" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
						content: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrendTooltip, {
							...props,
							style
						}),
						formatter: numberFormatterTooltip,
						isAnimationActive: false
					}),
					effectiveShowTooltip && mode === "stacked" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
						content: (props_0) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StackedTooltip, {
							...props_0,
							sortedAccounts,
							accounts,
							hoveredAccountId,
							format
						}),
						isAnimationActive: false,
						wrapperStyle: {
							zIndex: 9999,
							pointerEvents: "auto"
						}
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
						id: gradientId,
						x1: "0",
						y1: "0",
						x2: "0",
						y2: "1",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
							offset: off,
							stopColor: theme.reportsChartFill,
							stopOpacity: .2
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
							offset: off,
							stopColor: theme.reportsNumberNegative,
							stopOpacity: .2
						})]
					}) }),
					mode === "trend" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
						type: interpolationType,
						dot: false,
						activeDot: false,
						...animationProps,
						dataKey: "y",
						stroke: theme.reportsChartFill,
						strokeWidth: 2,
						fill: `url(#${gradientId})`,
						fillOpacity: 1,
						connectNulls: true
					}) : sortedAccounts.map((account_1) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
						type: interpolationType,
						dataKey: account_1.id,
						stackId: "1",
						stroke: colors[account_1.id],
						fill: colors[account_1.id],
						fillOpacity: .5,
						strokeWidth: 2,
						...animationProps,
						connectNulls: true,
						onMouseEnter: () => setHoveredAccountId(account_1.id),
						onMouseLeave: () => setHoveredAccountId(null)
					}, account_1.id))
				]
			})
		});
		$[29] = accounts;
		$[30] = animationProps;
		$[31] = colors;
		$[32] = compact;
		$[33] = effectiveShowTooltip;
		$[34] = format;
		$[35] = gradientId;
		$[36] = graphData;
		$[37] = hoveredAccountId;
		$[38] = interpolationType;
		$[39] = isTooltipActive;
		$[40] = mode;
		$[41] = off;
		$[42] = sortedAccounts;
		$[43] = style;
		$[44] = tickFormatter;
		$[45] = weeklyTicks;
		$[46] = t15;
	} else t15 = $[46];
	let t16;
	if ($[47] !== t14 || $[48] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: t14,
			children: t15
		});
		$[47] = t14;
		$[48] = t15;
		$[49] = t16;
	} else t16 = $[49];
	return t16;
}
function _temp8(item) {
	return item.y;
}
function _temp7(point_1) {
	return point_1.x;
}
function _temp6$1(point_0) {
	return getDay(parse(point_0.x, "yy-MM-dd", /* @__PURE__ */ new Date())) === 1;
}
function _temp5$1(i_0) {
	return i_0.y;
}
function _temp4$1(i) {
	return i.y;
}
//#endregion
//#region ../../node_modules/lodash/_defineProperty.js
var require__defineProperty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var getNative = require__getNative();
	module.exports = function() {
		try {
			var func = getNative(Object, "defineProperty");
			func({}, "", {});
			return func;
		} catch (e) {}
	}();
}));
//#endregion
//#region ../../node_modules/lodash/_baseAssignValue.js
var require__baseAssignValue = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var defineProperty = require__defineProperty();
	/**
	* The base implementation of `assignValue` and `assignMergeValue` without
	* value checks.
	*
	* @private
	* @param {Object} object The object to modify.
	* @param {string} key The key of the property to assign.
	* @param {*} value The value to assign.
	*/
	function baseAssignValue(object, key, value) {
		if (key == "__proto__" && defineProperty) defineProperty(object, key, {
			"configurable": true,
			"enumerable": true,
			"value": value,
			"writable": true
		});
		else object[key] = value;
	}
	module.exports = baseAssignValue;
}));
//#endregion
//#region ../../node_modules/lodash/_arrayAggregator.js
var require__arrayAggregator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* A specialized version of `baseAggregator` for arrays.
	*
	* @private
	* @param {Array} [array] The array to iterate over.
	* @param {Function} setter The function to set `accumulator` values.
	* @param {Function} iteratee The iteratee to transform keys.
	* @param {Object} accumulator The initial aggregated object.
	* @returns {Function} Returns `accumulator`.
	*/
	function arrayAggregator(array, setter, iteratee, accumulator) {
		var index = -1, length = array == null ? 0 : array.length;
		while (++index < length) {
			var value = array[index];
			setter(accumulator, value, iteratee(value), array);
		}
		return accumulator;
	}
	module.exports = arrayAggregator;
}));
//#endregion
//#region ../../node_modules/lodash/_createBaseFor.js
var require__createBaseFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* Creates a base function for methods like `_.forIn` and `_.forOwn`.
	*
	* @private
	* @param {boolean} [fromRight] Specify iterating from right to left.
	* @returns {Function} Returns the new base function.
	*/
	function createBaseFor(fromRight) {
		return function(object, iteratee, keysFunc) {
			var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
			while (length--) {
				var key = props[fromRight ? length : ++index];
				if (iteratee(iterable[key], key, iterable) === false) break;
			}
			return object;
		};
	}
	module.exports = createBaseFor;
}));
//#endregion
//#region ../../node_modules/lodash/_baseFor.js
var require__baseFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	module.exports = require__createBaseFor()();
}));
//#endregion
//#region ../../node_modules/lodash/_baseForOwn.js
var require__baseForOwn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseFor = require__baseFor(), keys = require_keys();
	/**
	* The base implementation of `_.forOwn` without support for iteratee shorthands.
	*
	* @private
	* @param {Object} object The object to iterate over.
	* @param {Function} iteratee The function invoked per iteration.
	* @returns {Object} Returns `object`.
	*/
	function baseForOwn(object, iteratee) {
		return object && baseFor(object, iteratee, keys);
	}
	module.exports = baseForOwn;
}));
//#endregion
//#region ../../node_modules/lodash/_createBaseEach.js
var require__createBaseEach = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isArrayLike = require_isArrayLike();
	/**
	* Creates a `baseEach` or `baseEachRight` function.
	*
	* @private
	* @param {Function} eachFunc The function to iterate over a collection.
	* @param {boolean} [fromRight] Specify iterating from right to left.
	* @returns {Function} Returns the new base function.
	*/
	function createBaseEach(eachFunc, fromRight) {
		return function(collection, iteratee) {
			if (collection == null) return collection;
			if (!isArrayLike(collection)) return eachFunc(collection, iteratee);
			var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
			while (fromRight ? index-- : ++index < length) if (iteratee(iterable[index], index, iterable) === false) break;
			return collection;
		};
	}
	module.exports = createBaseEach;
}));
//#endregion
//#region ../../node_modules/lodash/_baseEach.js
var require__baseEach = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseForOwn = require__baseForOwn();
	module.exports = require__createBaseEach()(baseForOwn);
}));
//#endregion
//#region ../../node_modules/lodash/_baseAggregator.js
var require__baseAggregator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseEach = require__baseEach();
	/**
	* Aggregates elements of `collection` on `accumulator` with keys transformed
	* by `iteratee` and values set by `setter`.
	*
	* @private
	* @param {Array|Object} collection The collection to iterate over.
	* @param {Function} setter The function to set `accumulator` values.
	* @param {Function} iteratee The iteratee to transform keys.
	* @param {Object} accumulator The initial aggregated object.
	* @returns {Function} Returns `accumulator`.
	*/
	function baseAggregator(collection, setter, iteratee, accumulator) {
		baseEach(collection, function(value, key, collection) {
			setter(accumulator, value, iteratee(value), collection);
		});
		return accumulator;
	}
	module.exports = baseAggregator;
}));
//#endregion
//#region ../../node_modules/lodash/_baseIsMatch.js
var require__baseIsMatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var Stack = require__Stack(), baseIsEqual = require__baseIsEqual();
	/** Used to compose bitmasks for value comparisons. */
	var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
	/**
	* The base implementation of `_.isMatch` without support for iteratee shorthands.
	*
	* @private
	* @param {Object} object The object to inspect.
	* @param {Object} source The object of property values to match.
	* @param {Array} matchData The property names, values, and compare flags to match.
	* @param {Function} [customizer] The function to customize comparisons.
	* @returns {boolean} Returns `true` if `object` is a match, else `false`.
	*/
	function baseIsMatch(object, source, matchData, customizer) {
		var index = matchData.length, length = index, noCustomizer = !customizer;
		if (object == null) return !length;
		object = Object(object);
		while (index--) {
			var data = matchData[index];
			if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) return false;
		}
		while (++index < length) {
			data = matchData[index];
			var key = data[0], objValue = object[key], srcValue = data[1];
			if (noCustomizer && data[2]) {
				if (objValue === void 0 && !(key in object)) return false;
			} else {
				var stack = new Stack();
				if (customizer) var result = customizer(objValue, srcValue, key, object, source, stack);
				if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result)) return false;
			}
		}
		return true;
	}
	module.exports = baseIsMatch;
}));
//#endregion
//#region ../../node_modules/lodash/_isStrictComparable.js
var require__isStrictComparable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isObject = require_isObject();
	/**
	* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
	*
	* @private
	* @param {*} value The value to check.
	* @returns {boolean} Returns `true` if `value` if suitable for strict
	*  equality comparisons, else `false`.
	*/
	function isStrictComparable(value) {
		return value === value && !isObject(value);
	}
	module.exports = isStrictComparable;
}));
//#endregion
//#region ../../node_modules/lodash/_getMatchData.js
var require__getMatchData = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isStrictComparable = require__isStrictComparable(), keys = require_keys();
	/**
	* Gets the property names, values, and compare flags of `object`.
	*
	* @private
	* @param {Object} object The object to query.
	* @returns {Array} Returns the match data of `object`.
	*/
	function getMatchData(object) {
		var result = keys(object), length = result.length;
		while (length--) {
			var key = result[length], value = object[key];
			result[length] = [
				key,
				value,
				isStrictComparable(value)
			];
		}
		return result;
	}
	module.exports = getMatchData;
}));
//#endregion
//#region ../../node_modules/lodash/_matchesStrictComparable.js
var require__matchesStrictComparable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* A specialized version of `matchesProperty` for source values suitable
	* for strict equality comparisons, i.e. `===`.
	*
	* @private
	* @param {string} key The key of the property to get.
	* @param {*} srcValue The value to match.
	* @returns {Function} Returns the new spec function.
	*/
	function matchesStrictComparable(key, srcValue) {
		return function(object) {
			if (object == null) return false;
			return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
		};
	}
	module.exports = matchesStrictComparable;
}));
//#endregion
//#region ../../node_modules/lodash/_baseMatches.js
var require__baseMatches = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseIsMatch = require__baseIsMatch(), getMatchData = require__getMatchData(), matchesStrictComparable = require__matchesStrictComparable();
	/**
	* The base implementation of `_.matches` which doesn't clone `source`.
	*
	* @private
	* @param {Object} source The object of property values to match.
	* @returns {Function} Returns the new spec function.
	*/
	function baseMatches(source) {
		var matchData = getMatchData(source);
		if (matchData.length == 1 && matchData[0][2]) return matchesStrictComparable(matchData[0][0], matchData[0][1]);
		return function(object) {
			return object === source || baseIsMatch(object, source, matchData);
		};
	}
	module.exports = baseMatches;
}));
//#endregion
//#region ../../node_modules/lodash/_isKey.js
var require__isKey = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isArray = require_isArray(), isSymbol = require_isSymbol();
	/** Used to match property names within property paths. */
	var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
	/**
	* Checks if `value` is a property name and not a property path.
	*
	* @private
	* @param {*} value The value to check.
	* @param {Object} [object] The object to query keys on.
	* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
	*/
	function isKey(value, object) {
		if (isArray(value)) return false;
		var type = typeof value;
		if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) return true;
		return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
	}
	module.exports = isKey;
}));
//#endregion
//#region ../../node_modules/lodash/memoize.js
var require_memoize = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var MapCache = require__MapCache();
	/** Error message constants. */
	var FUNC_ERROR_TEXT = "Expected a function";
	/**
	* Creates a function that memoizes the result of `func`. If `resolver` is
	* provided, it determines the cache key for storing the result based on the
	* arguments provided to the memoized function. By default, the first argument
	* provided to the memoized function is used as the map cache key. The `func`
	* is invoked with the `this` binding of the memoized function.
	*
	* **Note:** The cache is exposed as the `cache` property on the memoized
	* function. Its creation may be customized by replacing the `_.memoize.Cache`
	* constructor with one whose instances implement the
	* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
	* method interface of `clear`, `delete`, `get`, `has`, and `set`.
	*
	* @static
	* @memberOf _
	* @since 0.1.0
	* @category Function
	* @param {Function} func The function to have its output memoized.
	* @param {Function} [resolver] The function to resolve the cache key.
	* @returns {Function} Returns the new memoized function.
	* @example
	*
	* var object = { 'a': 1, 'b': 2 };
	* var other = { 'c': 3, 'd': 4 };
	*
	* var values = _.memoize(_.values);
	* values(object);
	* // => [1, 2]
	*
	* values(other);
	* // => [3, 4]
	*
	* object.a = 2;
	* values(object);
	* // => [1, 2]
	*
	* // Modify the result cache.
	* values.cache.set(object, ['a', 'b']);
	* values(object);
	* // => ['a', 'b']
	*
	* // Replace `_.memoize.Cache`.
	* _.memoize.Cache = WeakMap;
	*/
	function memoize(func, resolver) {
		if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError(FUNC_ERROR_TEXT);
		var memoized = function() {
			var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
			if (cache.has(key)) return cache.get(key);
			var result = func.apply(this, args);
			memoized.cache = cache.set(key, result) || cache;
			return result;
		};
		memoized.cache = new (memoize.Cache || MapCache)();
		return memoized;
	}
	memoize.Cache = MapCache;
	module.exports = memoize;
}));
//#endregion
//#region ../../node_modules/lodash/_memoizeCapped.js
var require__memoizeCapped = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var memoize = require_memoize();
	/** Used as the maximum memoize cache size. */
	var MAX_MEMOIZE_SIZE = 500;
	/**
	* A specialized version of `_.memoize` which clears the memoized function's
	* cache when it exceeds `MAX_MEMOIZE_SIZE`.
	*
	* @private
	* @param {Function} func The function to have its output memoized.
	* @returns {Function} Returns the new memoized function.
	*/
	function memoizeCapped(func) {
		var result = memoize(func, function(key) {
			if (cache.size === MAX_MEMOIZE_SIZE) cache.clear();
			return key;
		});
		var cache = result.cache;
		return result;
	}
	module.exports = memoizeCapped;
}));
//#endregion
//#region ../../node_modules/lodash/_stringToPath.js
var require__stringToPath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var memoizeCapped = require__memoizeCapped();
	/** Used to match property names within property paths. */
	var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
	/** Used to match backslashes in property paths. */
	var reEscapeChar = /\\(\\)?/g;
	module.exports = memoizeCapped(function(string) {
		var result = [];
		if (string.charCodeAt(0) === 46) result.push("");
		string.replace(rePropName, function(match, number, quote, subString) {
			result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
		});
		return result;
	});
}));
//#endregion
//#region ../../node_modules/lodash/_castPath.js
var require__castPath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isArray = require_isArray(), isKey = require__isKey(), stringToPath = require__stringToPath(), toString = require_toString();
	/**
	* Casts `value` to a path array if it's not one.
	*
	* @private
	* @param {*} value The value to inspect.
	* @param {Object} [object] The object to query keys on.
	* @returns {Array} Returns the cast property path array.
	*/
	function castPath(value, object) {
		if (isArray(value)) return value;
		return isKey(value, object) ? [value] : stringToPath(toString(value));
	}
	module.exports = castPath;
}));
//#endregion
//#region ../../node_modules/lodash/_toKey.js
var require__toKey = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var isSymbol = require_isSymbol();
	/** Used as references for various `Number` constants. */
	var INFINITY = Infinity;
	/**
	* Converts `value` to a string key if it's not a string or symbol.
	*
	* @private
	* @param {*} value The value to inspect.
	* @returns {string|symbol} Returns the key.
	*/
	function toKey(value) {
		if (typeof value == "string" || isSymbol(value)) return value;
		var result = value + "";
		return result == "0" && 1 / value == -INFINITY ? "-0" : result;
	}
	module.exports = toKey;
}));
//#endregion
//#region ../../node_modules/lodash/_baseGet.js
var require__baseGet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var castPath = require__castPath(), toKey = require__toKey();
	/**
	* The base implementation of `_.get` without support for default values.
	*
	* @private
	* @param {Object} object The object to query.
	* @param {Array|string} path The path of the property to get.
	* @returns {*} Returns the resolved value.
	*/
	function baseGet(object, path) {
		path = castPath(path, object);
		var index = 0, length = path.length;
		while (object != null && index < length) object = object[toKey(path[index++])];
		return index && index == length ? object : void 0;
	}
	module.exports = baseGet;
}));
//#endregion
//#region ../../node_modules/lodash/get.js
var require_get = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseGet = require__baseGet();
	/**
	* Gets the value at `path` of `object`. If the resolved value is
	* `undefined`, the `defaultValue` is returned in its place.
	*
	* @static
	* @memberOf _
	* @since 3.7.0
	* @category Object
	* @param {Object} object The object to query.
	* @param {Array|string} path The path of the property to get.
	* @param {*} [defaultValue] The value returned for `undefined` resolved values.
	* @returns {*} Returns the resolved value.
	* @example
	*
	* var object = { 'a': [{ 'b': { 'c': 3 } }] };
	*
	* _.get(object, 'a[0].b.c');
	* // => 3
	*
	* _.get(object, ['a', '0', 'b', 'c']);
	* // => 3
	*
	* _.get(object, 'a.b.c', 'default');
	* // => 'default'
	*/
	function get(object, path, defaultValue) {
		var result = object == null ? void 0 : baseGet(object, path);
		return result === void 0 ? defaultValue : result;
	}
	module.exports = get;
}));
//#endregion
//#region ../../node_modules/lodash/_baseHasIn.js
var require__baseHasIn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* The base implementation of `_.hasIn` without support for deep paths.
	*
	* @private
	* @param {Object} [object] The object to query.
	* @param {Array|string} key The key to check.
	* @returns {boolean} Returns `true` if `key` exists, else `false`.
	*/
	function baseHasIn(object, key) {
		return object != null && key in Object(object);
	}
	module.exports = baseHasIn;
}));
//#endregion
//#region ../../node_modules/lodash/_hasPath.js
var require__hasPath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var castPath = require__castPath(), isArguments = require_isArguments(), isArray = require_isArray(), isIndex = require__isIndex(), isLength = require_isLength(), toKey = require__toKey();
	/**
	* Checks if `path` exists on `object`.
	*
	* @private
	* @param {Object} object The object to query.
	* @param {Array|string} path The path to check.
	* @param {Function} hasFunc The function to check properties.
	* @returns {boolean} Returns `true` if `path` exists, else `false`.
	*/
	function hasPath(object, path, hasFunc) {
		path = castPath(path, object);
		var index = -1, length = path.length, result = false;
		while (++index < length) {
			var key = toKey(path[index]);
			if (!(result = object != null && hasFunc(object, key))) break;
			object = object[key];
		}
		if (result || ++index != length) return result;
		length = object == null ? 0 : object.length;
		return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
	}
	module.exports = hasPath;
}));
//#endregion
//#region ../../node_modules/lodash/hasIn.js
var require_hasIn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseHasIn = require__baseHasIn(), hasPath = require__hasPath();
	/**
	* Checks if `path` is a direct or inherited property of `object`.
	*
	* @static
	* @memberOf _
	* @since 4.0.0
	* @category Object
	* @param {Object} object The object to query.
	* @param {Array|string} path The path to check.
	* @returns {boolean} Returns `true` if `path` exists, else `false`.
	* @example
	*
	* var object = _.create({ 'a': _.create({ 'b': 2 }) });
	*
	* _.hasIn(object, 'a');
	* // => true
	*
	* _.hasIn(object, 'a.b');
	* // => true
	*
	* _.hasIn(object, ['a', 'b']);
	* // => true
	*
	* _.hasIn(object, 'b');
	* // => false
	*/
	function hasIn(object, path) {
		return object != null && hasPath(object, path, baseHasIn);
	}
	module.exports = hasIn;
}));
//#endregion
//#region ../../node_modules/lodash/_baseMatchesProperty.js
var require__baseMatchesProperty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseIsEqual = require__baseIsEqual(), get = require_get(), hasIn = require_hasIn(), isKey = require__isKey(), isStrictComparable = require__isStrictComparable(), matchesStrictComparable = require__matchesStrictComparable(), toKey = require__toKey();
	/** Used to compose bitmasks for value comparisons. */
	var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
	/**
	* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
	*
	* @private
	* @param {string} path The path of the property to get.
	* @param {*} srcValue The value to match.
	* @returns {Function} Returns the new spec function.
	*/
	function baseMatchesProperty(path, srcValue) {
		if (isKey(path) && isStrictComparable(srcValue)) return matchesStrictComparable(toKey(path), srcValue);
		return function(object) {
			var objValue = get(object, path);
			return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
		};
	}
	module.exports = baseMatchesProperty;
}));
//#endregion
//#region ../../node_modules/lodash/identity.js
var require_identity = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* This method returns the first argument it receives.
	*
	* @static
	* @since 0.1.0
	* @memberOf _
	* @category Util
	* @param {*} value Any value.
	* @returns {*} Returns `value`.
	* @example
	*
	* var object = { 'a': 1 };
	*
	* console.log(_.identity(object) === object);
	* // => true
	*/
	function identity(value) {
		return value;
	}
	module.exports = identity;
}));
//#endregion
//#region ../../node_modules/lodash/_baseProperty.js
var require__baseProperty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* The base implementation of `_.property` without support for deep paths.
	*
	* @private
	* @param {string} key The key of the property to get.
	* @returns {Function} Returns the new accessor function.
	*/
	function baseProperty(key) {
		return function(object) {
			return object == null ? void 0 : object[key];
		};
	}
	module.exports = baseProperty;
}));
//#endregion
//#region ../../node_modules/lodash/_basePropertyDeep.js
var require__basePropertyDeep = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseGet = require__baseGet();
	/**
	* A specialized version of `baseProperty` which supports deep paths.
	*
	* @private
	* @param {Array|string} path The path of the property to get.
	* @returns {Function} Returns the new accessor function.
	*/
	function basePropertyDeep(path) {
		return function(object) {
			return baseGet(object, path);
		};
	}
	module.exports = basePropertyDeep;
}));
//#endregion
//#region ../../node_modules/lodash/property.js
var require_property = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseProperty = require__baseProperty(), basePropertyDeep = require__basePropertyDeep(), isKey = require__isKey(), toKey = require__toKey();
	/**
	* Creates a function that returns the value at `path` of a given object.
	*
	* @static
	* @memberOf _
	* @since 2.4.0
	* @category Util
	* @param {Array|string} path The path of the property to get.
	* @returns {Function} Returns the new accessor function.
	* @example
	*
	* var objects = [
	*   { 'a': { 'b': 2 } },
	*   { 'a': { 'b': 1 } }
	* ];
	*
	* _.map(objects, _.property('a.b'));
	* // => [2, 1]
	*
	* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
	* // => [1, 2]
	*/
	function property(path) {
		return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
	}
	module.exports = property;
}));
//#endregion
//#region ../../node_modules/lodash/_baseIteratee.js
var require__baseIteratee = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseMatches = require__baseMatches(), baseMatchesProperty = require__baseMatchesProperty(), identity = require_identity(), isArray = require_isArray(), property = require_property();
	/**
	* The base implementation of `_.iteratee`.
	*
	* @private
	* @param {*} [value=_.identity] The value to convert to an iteratee.
	* @returns {Function} Returns the iteratee.
	*/
	function baseIteratee(value) {
		if (typeof value == "function") return value;
		if (value == null) return identity;
		if (typeof value == "object") return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
		return property(value);
	}
	module.exports = baseIteratee;
}));
//#endregion
//#region ../../node_modules/lodash/_createAggregator.js
var require__createAggregator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var arrayAggregator = require__arrayAggregator(), baseAggregator = require__baseAggregator(), baseIteratee = require__baseIteratee(), isArray = require_isArray();
	/**
	* Creates a function like `_.groupBy`.
	*
	* @private
	* @param {Function} setter The function to set accumulator values.
	* @param {Function} [initializer] The accumulator object initializer.
	* @returns {Function} Returns the new aggregator function.
	*/
	function createAggregator(setter, initializer) {
		return function(collection, iteratee) {
			var func = isArray(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {};
			return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
		};
	}
	module.exports = createAggregator;
}));
//#endregion
//#region src/components/reports/spreadsheets/net-worth-spreadsheet.ts
var import_keyBy = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
	var baseAssignValue = require__baseAssignValue();
	module.exports = require__createAggregator()(function(result, value, key) {
		baseAssignValue(result, key, value);
	});
})))());
function createSpreadsheet(start, end, accounts, conditions = [], conditionsOp = "and", locale, interval = "Monthly", firstDayOfWeekIdx = "0", format) {
	return async (spreadsheet, setData) => {
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		const rangeStart = parseISO(firstDayOfMonth(start));
		let startDate;
		if (interval === "Daily") startDate = dayFromDate(subDays$1(rangeStart, 1));
		else if (interval === "Weekly") startDate = weekFromDate(subDays$1(rangeStart, 1), firstDayOfWeekIdx);
		else startDate = firstDayOfMonth(prevMonth(start));
		const earliestTransaction = await send("get-earliest-transaction");
		if (earliestTransaction && earliestTransaction.date >= firstDayOfMonth(start)) if (interval === "Daily") startDate = earliestTransaction.date;
		else if (interval === "Weekly") startDate = weekFromDate(earliestTransaction.date, firstDayOfWeekIdx);
		else startDate = firstDayOfMonth(start);
		let endDate = lastDayOfMonth(end);
		if (interval === "Daily") {
			const today = currentDay();
			if (isAfter(endDate, today)) endDate = today;
		} else if (interval === "Weekly") {
			const today = currentDay();
			if (isAfter(endDate, today)) endDate = today;
		}
		setData(recalculate(await Promise.all(accounts.map(async (acct) => {
			const [starting, balances] = await Promise.all([aqlQuery(q$1("transactions").filter({
				[conditionsOpKey]: filters,
				account: acct.id,
				date: { $lt: startDate }
			}).calculate({ $sum: "$amount" })).then(({ data }) => data), aqlQuery(q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({
				account: acct.id,
				$and: [{ date: { $gte: startDate } }, { date: { $lte: endDate } }]
			}).groupBy(interval === "Yearly" ? { $year: "$date" } : interval === "Daily" || interval === "Weekly" ? "date" : { $month: "$date" }).select([{ date: interval === "Yearly" ? { $year: "$date" } : interval === "Daily" || interval === "Weekly" ? "date" : { $month: "$date" } }, { amount: { $sum: "$amount" } }])).then(({ data }) => data)]);
			let processedBalances;
			if (interval === "Weekly") {
				const weeklyBalances = {};
				balances.forEach((b) => {
					const weekDate = weekFromDate(b.date, firstDayOfWeekIdx);
					weeklyBalances[weekDate] = (weeklyBalances[weekDate] || 0) + b.amount;
				});
				processedBalances = {};
				Object.entries(weeklyBalances).forEach(([date, amount]) => {
					processedBalances[date] = {
						date,
						amount
					};
				});
			} else processedBalances = (0, import_keyBy.default)(balances, "date");
			return {
				id: acct.id,
				name: acct.name,
				balances: processedBalances,
				starting
			};
		})), startDate, endDate, locale, interval, firstDayOfWeekIdx, format));
	};
}
function recalculate(data, startDate, endDate, locale, interval = "Monthly", firstDayOfWeekIdx = "0", format) {
	const intervals = interval === "Weekly" ? weekRangeInclusive(startDate, endDate, firstDayOfWeekIdx) : interval === "Daily" ? dayRangeInclusive(startDate, endDate) : interval === "Yearly" ? yearRangeInclusive(startDate, endDate) : rangeInclusive(getMonth(startDate), getMonth(endDate));
	const accountBalances = data.map((account) => {
		let balance = account.starting;
		return intervals.map((intervalItem) => {
			if (account.balances[intervalItem]) balance += account.balances[intervalItem].amount;
			return balance;
		});
	});
	const priorPeriodNetWorth = data.reduce((sum, account) => sum + account.starting, 0);
	let hasNegative = false;
	let startNetWorth = 0;
	let endNetWorth = 0;
	let lowestNetWorth = null;
	let highestNetWorth = null;
	const graphData = intervals.reduce((arr, intervalItem, idx) => {
		let debt = 0;
		let assets = 0;
		let total = 0;
		const last = arr.length === 0 ? null : arr[arr.length - 1];
		const balances = {};
		accountBalances.forEach((acctBalances, i) => {
			const balance = acctBalances[idx];
			balances[data[i].id] = balance;
			if (balance < 0) debt += -balance;
			else assets += balance;
			total += balance;
		});
		if (total < 0) hasNegative = true;
		let x;
		if (interval === "Daily" || interval === "Weekly") x = parseISO(intervalItem);
		else if (interval === "Yearly") x = parseISO(intervalItem + "-01-01");
		else x = parseISO(intervalItem + "-01");
		const change = last ? total - last.y : total - priorPeriodNetWorth;
		if (arr.length === 0) startNetWorth = total;
		endNetWorth = total;
		const displayFormat = ReportOptions.intervalFormat.get(interval) ?? "MMM ''yy";
		const tooltipFormat = interval === "Daily" ? "MMMM d, yyyy" : interval === "Weekly" ? "MMM d, yyyy" : interval === "Yearly" ? "yyyy" : "MMMM yyyy";
		const graphPoint = {
			x: format$1(x, displayFormat, { locale }),
			y: total,
			assets: format(assets, "financial"),
			debt: `-${format(debt, "financial")}`,
			change: format(change, "financial"),
			networth: format(total, "financial"),
			date: format$1(x, tooltipFormat, { locale }),
			...balances
		};
		arr.push(graphPoint);
		if (lowestNetWorth === null || graphPoint.y < lowestNetWorth) lowestNetWorth = graphPoint.y;
		if (highestNetWorth === null || graphPoint.y > highestNetWorth) highestNetWorth = graphPoint.y;
		return arr;
	}, []);
	const hasBalance = accountBalances.map((balances) => balances.some((b) => b !== 0));
	return {
		graphData: {
			data: graphData,
			hasNegative,
			start: startDate,
			end: endDate
		},
		netWorth: endNetWorth,
		totalChange: endNetWorth - startNetWorth,
		lowestNetWorth,
		highestNetWorth,
		accounts: data.filter((_, i) => hasBalance[i]).map((d) => ({
			id: d.id,
			name: d.name
		}))
	};
}
//#endregion
//#region src/components/reports/reports/NetWorth.tsx
function NetWorth() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "net-worth-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isLoading } = useDashboardWidget(t0);
	if (isLoading) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorthInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function NetWorthInner({ widget }) {
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	const format$5 = useFormat();
	const getDefaultIntervalForMode = (0, import_react.useCallback)((mode) => {
		if (mode === "lastMonth") return "Weekly";
		return "Monthly";
	}, []);
	const { data: accounts = [] } = useAccounts();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const [allMonths, setAllMonths] = (0, import_react.useState)(null);
	const [start, setStart] = (0, import_react.useState)(currentMonth());
	const [end, setEnd] = (0, import_react.useState)(currentMonth());
	const [mode_0, setMode] = (0, import_react.useState)("sliding-window");
	const [interval, setInterval] = (0, import_react.useState)(widget?.meta?.interval || getDefaultIntervalForMode(mode_0));
	const [graphMode, setGraphMode] = (0, import_react.useState)(widget?.meta?.mode || "trend");
	const setModeAndInterval = (0, import_react.useCallback)((newMode) => {
		setMode(newMode);
		if (!widget?.meta?.interval) setInterval(getDefaultIntervalForMode(newMode));
	}, [widget?.meta?.interval, getDefaultIntervalForMode]);
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const data = useReport$1("net_worth", (0, import_react.useMemo)(() => createSpreadsheet(start, end, accounts, conditions, conditionsOp, locale, interval, firstDayOfWeekIdx, format$5), [
		start,
		end,
		accounts,
		conditions,
		conditionsOp,
		locale,
		interval,
		firstDayOfWeekIdx,
		format$5
	]));
	(0, import_react.useEffect)(() => {
		async function run() {
			const earliestTransaction = await send("get-earliest-transaction");
			setEarliestTransaction(earliestTransaction ? earliestTransaction.date : currentDay());
			const latestTransaction_0 = await send("get-latest-transaction");
			setLatestTransaction(latestTransaction_0 ? latestTransaction_0.date : currentDay());
			const currentMonth$5 = currentMonth();
			let earliestMonth = earliestTransaction ? monthFromDate(parseISO(fromDateRepr(earliestTransaction.date))) : currentMonth$5;
			const latestTransactionMonth = latestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(latestTransaction_0.date))) : currentMonth$5;
			const latestMonth = latestTransactionMonth > currentMonth$5 ? latestTransactionMonth : currentMonth$5;
			const yearAgo = subMonths(latestMonth, 12);
			if (earliestMonth > yearAgo) earliestMonth = yearAgo;
			setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
				name: month,
				pretty: format(month, "MMMM yyyy", locale)
			})).reverse());
		}
		run();
	}, [locale]);
	(0, import_react.useEffect)(() => {
		if (latestTransaction) {
			const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, void 0, latestTransaction);
			setStart(initialStart);
			setEnd(initialEnd);
			setModeAndInterval(initialMode);
		}
	}, [
		latestTransaction,
		widget?.meta?.timeFrame,
		setModeAndInterval
	]);
	function onChangeDates(start_0, end_0, mode_1) {
		setStart(start_0);
		setEnd(end_0);
		setModeAndInterval(mode_1);
	}
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	async function onSaveWidget() {
		if (!widget) throw new Error("No widget that could be saved.");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				conditions,
				conditionsOp,
				interval,
				mode: graphMode,
				timeFrame: {
					start,
					end,
					mode: mode_0
				}
			}
		} }, { onSuccess: () => {
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Dashboard widget successfully saved.")
			} }));
		} });
	}
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const title = widget?.meta?.name || t("Net Worth");
	const onSaveWidgetName = async (newName) => {
		if (!widget) throw new Error("No widget that could be saved.");
		const name = newName || t("Net Worth");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				name
			}
		} });
	};
	const [earliestTransaction_0, setEarliestTransaction] = (0, import_react.useState)("");
	if (!allMonths || !data) return null;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title }),
		padding: 0,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			allMonths,
			start,
			end,
			earliestTransaction: earliestTransaction_0,
			latestTransaction,
			firstDayOfWeekIdx,
			mode: mode_0,
			onChangeDates,
			filters: conditions,
			onApply: onApplyFilter,
			onUpdateFilter,
			onDeleteFilter,
			conditionsOp,
			onConditionsOpChange,
			inlineContent: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntervalSelector, {
				interval,
				onChange: setInterval
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeSelector, {
				mode: graphMode,
				onChange: setGraphMode
			})] }),
			children: widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: onSaveWidget,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
			})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				backgroundColor: theme.tableBackground,
				padding: 20,
				paddingTop: 0,
				flex: "1 0 auto",
				overflowY: "auto"
			},
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						textAlign: "right",
						paddingTop: 20
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							...styles.largeText,
							fontWeight: 400,
							marginBottom: 5
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format$5(data.netWorth, "financial") }) })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Change, { amount: data.totalChange }) })]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorthGraph, {
					graphData: data.graphData,
					accounts: data.accounts,
					showTooltip: !isNarrowWidth,
					interval,
					mode: graphMode
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						marginTop: 30,
						userSelect: "none"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "How is net worth calculated?" }) }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Net worth shows the balance of all accounts over time, including all of your investments. Your \"net worth\" is considered to be the amount you'd have if you sold all your assets and paid off as much debt as possible. If you hover over the graph, you can also see the amount of assets and debt individually." }) })]
				})
			]
		})]
	});
}
function IntervalSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(24);
	const { interval, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] !== interval) {
		t1 = ReportOptions.interval.find((opt) => opt.key === interval)?.description ?? interval;
		$[0] = interval;
		$[1] = t1;
	} else t1 = $[1];
	const currentLabel = t1;
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = () => setIsOpen(true);
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] !== t) {
		t3 = t("Change interval");
		$[3] = t;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	let t5;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCalendar, { style: {
			width: 12,
			height: 12
		} });
		t5 = { marginLeft: 5 };
		$[5] = t4;
		$[6] = t5;
	} else {
		t4 = $[5];
		t5 = $[6];
	}
	let t6;
	if ($[7] !== currentLabel) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t5,
			children: currentLabel
		});
		$[7] = currentLabel;
		$[8] = t6;
	} else t6 = $[8];
	let t7;
	if ($[9] !== t3 || $[10] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t2,
			"aria-label": t3,
			children: [t4, t6]
		});
		$[9] = t3;
		$[10] = t6;
		$[11] = t7;
	} else t7 = $[11];
	let t8;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsOpen(false);
		$[12] = t8;
	} else t8 = $[12];
	let t9;
	if ($[13] !== onChange) {
		t9 = (item) => {
			onChange(item);
			setIsOpen(false);
		};
		$[13] = onChange;
		$[14] = t9;
	} else t9 = $[14];
	let t10;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = ReportOptions.interval.map(_temp$6);
		$[15] = t10;
	} else t10 = $[15];
	let t11;
	if ($[16] !== t9) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t9,
			items: t10
		});
		$[16] = t9;
		$[17] = t11;
	} else t11 = $[17];
	let t12;
	if ($[18] !== isOpen || $[19] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t8,
			children: t11
		});
		$[18] = isOpen;
		$[19] = t11;
		$[20] = t12;
	} else t12 = $[20];
	let t13;
	if ($[21] !== t12 || $[22] !== t7) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t7, t12] });
		$[21] = t12;
		$[22] = t7;
		$[23] = t13;
	} else t13 = $[23];
	return t13;
}
function _temp$6(t0) {
	const { key, description } = t0;
	return {
		name: key,
		text: description
	};
}
function ModeSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(35);
	const { mode, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] !== t) {
		t1 = t("Trend");
		$[0] = t;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== t1) {
		t2 = {
			key: "trend",
			description: t1
		};
		$[2] = t1;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== t) {
		t3 = t("Stacked");
		$[4] = t;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t3) {
		t4 = {
			key: "stacked",
			description: t3
		};
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== t2 || $[9] !== t4) {
		t5 = [t2, t4];
		$[8] = t2;
		$[9] = t4;
		$[10] = t5;
	} else t5 = $[10];
	const options = t5;
	const currentLabel = options.find((opt) => opt.key === mode)?.description ?? mode;
	let t6;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = () => setIsOpen(true);
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== t) {
		t7 = t("Change mode");
		$[12] = t;
		$[13] = t7;
	} else t7 = $[13];
	let t8;
	let t9;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgChart, { style: {
			width: 12,
			height: 12
		} });
		t9 = { marginLeft: 5 };
		$[14] = t8;
		$[15] = t9;
	} else {
		t8 = $[14];
		t9 = $[15];
	}
	let t10;
	if ($[16] !== currentLabel) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t9,
			children: currentLabel
		});
		$[16] = currentLabel;
		$[17] = t10;
	} else t10 = $[17];
	let t11;
	if ($[18] !== t10 || $[19] !== t7) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t6,
			"aria-label": t7,
			children: [t8, t10]
		});
		$[18] = t10;
		$[19] = t7;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = () => setIsOpen(false);
		$[21] = t12;
	} else t12 = $[21];
	let t13;
	if ($[22] !== onChange) {
		t13 = (item) => {
			onChange(item);
			setIsOpen(false);
		};
		$[22] = onChange;
		$[23] = t13;
	} else t13 = $[23];
	let t14;
	if ($[24] !== options) {
		t14 = options.map(_temp2$3);
		$[24] = options;
		$[25] = t14;
	} else t14 = $[25];
	let t15;
	if ($[26] !== t13 || $[27] !== t14) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t13,
			items: t14
		});
		$[26] = t13;
		$[27] = t14;
		$[28] = t15;
	} else t15 = $[28];
	let t16;
	if ($[29] !== isOpen || $[30] !== t15) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t12,
			children: t15
		});
		$[29] = isOpen;
		$[30] = t15;
		$[31] = t16;
	} else t16 = $[31];
	let t17;
	if ($[32] !== t11 || $[33] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t11, t16] });
		$[32] = t11;
		$[33] = t16;
		$[34] = t17;
	} else t17 = $[34];
	return t17;
}
function _temp2$3(t0) {
	const { key, description } = t0;
	return {
		name: key,
		text: description
	};
}
//#endregion
//#region src/components/reports/graphs/SankeyGraph.tsx
var fadeIn = keyframes({
	from: { opacity: 0 },
	to: { opacity: 1 }
});
var hiddenClass = css({ opacity: 0 });
function fadeInClass(fraction) {
	return css({ animation: `${fadeIn} 0.3s ease-out ${Math.max(0, Math.min(1, fraction)) * .3}s both` });
}
function SankeyLink(t0) {
	const $ = (0, import_compiler_runtime.c)(13);
	const { sourceX, sourceY, sourceControlX, targetX, targetY, targetControlX, linkWidth, containerWidth, phase, payload, isHovered, onMouseEnter, onMouseLeave } = t0;
	const reducedMotion = useReducedMotion();
	if (payload.value <= 0) return null;
	const linkColor = payload.color ?? theme.reportsGray;
	const strokeWidth = linkWidth;
	const strokeOpacity = isHovered ? 1 : .6;
	const fraction = (sourceX + targetX) / 2 / containerWidth;
	let t1;
	if ($[0] !== fraction || $[1] !== phase || $[2] !== reducedMotion) {
		t1 = reducedMotion || phase === "done" ? void 0 : phase === "animating" ? fadeInClass(fraction) : hiddenClass;
		$[0] = fraction;
		$[1] = phase;
		$[2] = reducedMotion;
		$[3] = t1;
	} else t1 = $[3];
	const t2 = `M${sourceX},${sourceY} C${sourceControlX},${sourceY} ${targetControlX},${targetY} ${targetX},${targetY}`;
	let t3;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = { transition: "stroke-opacity 0.2s ease" };
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== linkColor || $[6] !== onMouseEnter || $[7] !== onMouseLeave || $[8] !== strokeOpacity || $[9] !== strokeWidth || $[10] !== t1 || $[11] !== t2) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
			className: t1,
			d: t2,
			fill: "none",
			stroke: linkColor,
			strokeWidth,
			strokeOpacity,
			cursor: "default",
			onMouseEnter,
			onMouseLeave,
			style: t3
		});
		$[5] = linkColor;
		$[6] = onMouseEnter;
		$[7] = onMouseLeave;
		$[8] = strokeOpacity;
		$[9] = strokeWidth;
		$[10] = t1;
		$[11] = t2;
		$[12] = t4;
	} else t4 = $[12];
	return t4;
}
function SankeyNode(t0) {
	const $ = (0, import_compiler_runtime.c)(33);
	const { x, y, width, height, payload, containerWidth, phase, showPercentages } = t0;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	const reducedMotion = useReducedMotion();
	if (payload.value <= 0) return null;
	const isOut = x + width + 6 > containerWidth;
	const fillColor = payload.color ?? theme.reportsBlue;
	let t1;
	if ($[0] !== isOut || $[1] !== width || $[2] !== x || $[3] !== y) {
		t1 = (text, yOffset, t2, t3, fontFamily, t4) => {
			const fontSize = t2 === void 0 ? 13 : t2;
			const opacity = t3 === void 0 ? 1 : t3;
			const yBase = t4 === void 0 ? y : t4;
			return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
				textAnchor: isOut ? "end" : "start",
				x: isOut ? x - 6 : x + width + 6,
				y: yBase + yOffset,
				fontSize,
				strokeOpacity: opacity,
				fill: theme.pageText,
				fontFamily,
				children: text
			});
		};
		$[0] = isOut;
		$[1] = width;
		$[2] = x;
		$[3] = y;
		$[4] = t1;
	} else t1 = $[4];
	const renderText = t1;
	let t2;
	if ($[5] !== containerWidth || $[6] !== phase || $[7] !== reducedMotion || $[8] !== x) {
		t2 = reducedMotion || phase === "done" ? void 0 : phase === "animating" ? fadeInClass(x / containerWidth) : hiddenClass;
		$[5] = containerWidth;
		$[6] = phase;
		$[7] = reducedMotion;
		$[8] = x;
		$[9] = t2;
	} else t2 = $[9];
	let t3;
	if ($[10] !== fillColor || $[11] !== height || $[12] !== width || $[13] !== x || $[14] !== y) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Rectangle, {
			x,
			y,
			width,
			height,
			fill: fillColor
		});
		$[10] = fillColor;
		$[11] = height;
		$[12] = width;
		$[13] = x;
		$[14] = y;
		$[15] = t3;
	} else t3 = $[15];
	const t4 = payload.name || "";
	const t5 = height / 2;
	let t6;
	if ($[16] !== renderText || $[17] !== t4 || $[18] !== t5) {
		t6 = renderText(t4, t5);
		$[16] = renderText;
		$[17] = t4;
		$[18] = t5;
		$[19] = t6;
	} else t6 = $[19];
	let t7;
	if ($[20] !== format || $[21] !== height || $[22] !== payload.percentageLabel || $[23] !== payload.value || $[24] !== privacyMode || $[25] !== renderText || $[26] !== showPercentages) {
		t7 = renderText(showPercentages && payload.percentageLabel ? payload.percentageLabel : format(payload.value, "financial"), height / 2 + 13, 11, .5, privacyMode ? t("Redacted Script") : void 0);
		$[20] = format;
		$[21] = height;
		$[22] = payload.percentageLabel;
		$[23] = payload.value;
		$[24] = privacyMode;
		$[25] = renderText;
		$[26] = showPercentages;
		$[27] = t7;
	} else t7 = $[27];
	let t8;
	if ($[28] !== t2 || $[29] !== t3 || $[30] !== t6 || $[31] !== t7) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Layer, {
			className: t2,
			children: [
				t3,
				t6,
				t7
			]
		});
		$[28] = t2;
		$[29] = t3;
		$[30] = t6;
		$[31] = t7;
		$[32] = t8;
	} else t8 = $[32];
	return t8;
}
function SankeyGraph(t0) {
	const $ = (0, import_compiler_runtime.c)(18);
	const { style, data, showTooltip: t1, showPercentages: t2 } = t0;
	const showTooltip = t1 === void 0 ? true : t1;
	const showPercentages = t2 === void 0 ? false : t2;
	const privacyMode = usePrivacyMode();
	const format = useFormat();
	const [hoveredLinkIndex, setHoveredLinkIndex] = (0, import_react.useState)(null);
	const [viewportEl, setViewportEl] = (0, import_react.useState)(null);
	const [phase, setPhase] = (0, import_react.useState)("waiting");
	let t3;
	let t4;
	if ($[0] !== phase || $[1] !== viewportEl) {
		t3 = () => {
			if (!viewportEl || phase !== "waiting") return;
			const observer = new IntersectionObserver((t5) => {
				const [entry] = t5;
				if (entry.isIntersecting) {
					setPhase("animating");
					observer.disconnect();
				}
			});
			observer.observe(viewportEl);
			return () => observer.disconnect();
		};
		t4 = [viewportEl, phase];
		$[0] = phase;
		$[1] = viewportEl;
		$[2] = t3;
		$[3] = t4;
	} else {
		t3 = $[2];
		t4 = $[3];
	}
	(0, import_react.useEffect)(t3, t4);
	let t5;
	let t6;
	if ($[4] !== phase) {
		t5 = () => {
			if (phase !== "animating") return;
			const timer = setTimeout(() => setPhase("done"), 700);
			return () => clearTimeout(timer);
		};
		t6 = [phase];
		$[4] = phase;
		$[5] = t5;
		$[6] = t6;
	} else {
		t5 = $[5];
		t6 = $[6];
	}
	(0, import_react.useEffect)(t5, t6);
	let t7;
	if ($[7] !== data || $[8] !== format || $[9] !== hoveredLinkIndex || $[10] !== phase || $[11] !== privacyMode || $[12] !== showPercentages || $[13] !== showTooltip) {
		t7 = (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
			ref: setViewportEl,
			style: {
				width: "100%",
				height: "100%"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResponsiveContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sankey$1, {
				data,
				node: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyNode, {
					...props,
					containerWidth: width,
					phase,
					showPercentages
				}),
				link: (props_0) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyLink, {
					...props_0,
					containerWidth: width,
					phase,
					isHovered: hoveredLinkIndex === props_0.index,
					onMouseEnter: () => setHoveredLinkIndex(props_0.index),
					onMouseLeave: () => setHoveredLinkIndex(null)
				}),
				sort: false,
				iterations: 128,
				nodePadding: 23,
				width,
				height,
				margin: {
					left: 0,
					right: 0,
					top: 10,
					bottom: 25
				},
				children: showTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: (t8) => {
						const { active, payload } = t8;
						if (!active || !payload?.length) return null;
						const { value: t9, name: t10 } = payload[0];
						const value = t9 === void 0 ? 0 : t9;
						const name = t10 === void 0 ? "" : t10;
						const tooltipInfo = hoveredLinkIndex !== null ? data.links[hoveredLinkIndex]?.tooltipInfo : void 0;
						return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: css({
								zIndex: 1e3,
								pointerEvents: "none",
								borderRadius: 2,
								boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
								backgroundColor: theme.menuBackground,
								color: theme.menuItemText,
								padding: 10
							}),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								style: { lineHeight: 1.4 },
								children: [
									name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										style: { marginBottom: 5 },
										children: name
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										style: { fontFamily: privacyMode ? t("Redacted Script") : void 0 },
										children: format(value, "financial")
									}),
									tooltipInfo && tooltipInfo.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										style: {
											marginTop: 6,
											fontSize: 11,
											opacity: .7
										},
										children: tooltipInfo.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
											item.name,
											" (",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
												style: { fontFamily: privacyMode ? t("Redacted Script") : void 0 },
												children: format(item.value, "financial")
											}),
											")"
										] }, item.name))
									})
								]
							})
						});
					},
					isAnimationActive: false
				})
			}) })
		});
		$[7] = data;
		$[8] = format;
		$[9] = hoveredLinkIndex;
		$[10] = phase;
		$[11] = privacyMode;
		$[12] = showPercentages;
		$[13] = showTooltip;
		$[14] = t7;
	} else t7 = $[14];
	let t8;
	if ($[15] !== style || $[16] !== t7) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style,
			children: t7
		});
		$[15] = style;
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	return t8;
}
//#endregion
//#region src/components/reports/spreadsheets/sankey-spreadsheet.ts
var SpecialNodeKeys = {
	ToBudget: "to_budget",
	Budgeted: "budgeted",
	LastMonthOverspent: "last_month_overspent",
	ForNextMonth: "for_next_month",
	FromPrevMonth: "from_previous_month",
	AvailableIncome: "available_income",
	AllAccounts: "all_income",
	OtherSuffix: "__OTHER_BUCKET",
	HiddenSuffix: "__HIDDEN",
	NegativeSuffix: "__NEGATIVE"
};
var GraphLayers = {
	IncomePayee: "payee",
	IncomeCategory: "income_category",
	Account: "account",
	Budget: "budget",
	CategoryGroup: "category_group",
	Category: "category"
};
var GRAPH_LAYER_ORDER = [
	GraphLayers.IncomePayee,
	GraphLayers.IncomeCategory,
	GraphLayers.Account,
	GraphLayers.Budget,
	GraphLayers.CategoryGroup,
	GraphLayers.Category
];
function isGraphLayer(value) {
	return typeof value === "string" && Object.values(GraphLayers).includes(value);
}
function createBaseGraphSpreadsheet(start, end, categories, conditions = [], conditionsOp = "and", mode = "spent", groupAccounts = false) {
	return async (_spreadsheet, setData) => {
		setData(await createBaseGraph(start, end, categories, conditions, conditionsOp, mode, groupAccounts));
	};
}
async function createBaseGraph(start, end, categories, conditions = [], conditionsOp = "and", mode = "spent", groupAccounts = false) {
	let data = [];
	let aggregated;
	if (mode === "budgeted") ({data, aggregated} = await createBudgetSpreadsheet(start, end, conditions, conditionsOp)());
	else if (mode === "spent") data = await createTransactionsSpreadsheet(start, end, categories, conditions, conditionsOp, groupAccounts)();
	return aggregated ? createBudgetGraph(data, aggregated) : createTransactionsGraph(data);
}
function buildSankeyData(baseGraph, topNcategories, categories, categorySort, layerFrom, layerTo) {
	const graph = cloneGraph(baseGraph);
	const toolTipInfoMap = groupOtherCategories(graph, topNcategories, categorySort);
	const sortedGraph = sortGraph(graph, categorySort, categories);
	addPercentageLabels(sortedGraph);
	addColors(sortedGraph);
	cleanUpNodes(sortedGraph);
	addHiddenNodes(sortedGraph);
	filterGraphByLayers(sortedGraph, layerFrom, layerTo);
	return convertToSankeyData(sortedGraph, toolTipInfoMap);
}
function createBudgetSpreadsheet(start, end, conditions = [], conditionsOp = "and") {
	return async () => {
		const months = end && end !== start ? rangeInclusive(start, end) : [start];
		const monthResponses = await Promise.all(months.map((m) => send("api/budget-month", { month: m })));
		const accumulate_months = monthResponses.reduce((acc, response, index) => {
			if (index === monthResponses.length - 1) acc.toBudget = response.toBudget;
			if (index === 0) acc.fromPreviousMonth = response.fromLastMonth;
			acc.lastMonthOverspent += response.lastMonthOverspent;
			for (const group of response.categoryGroups) {
				const existingGroup = acc.categoryGroupsMap.get(group.id);
				if (!existingGroup) {
					acc.categoryGroupsMap.set(group.id, {
						...group,
						categories: group.categories.map((cat) => ({ ...cat }))
					});
					continue;
				}
				for (const cat of group.categories) {
					const existingCat = existingGroup.categories.find((c) => c.id === cat.id);
					if (!existingCat) {
						existingGroup.categories.push({ ...cat });
						continue;
					}
					existingCat.budgeted = (existingCat.budgeted ?? 0) + (cat.budgeted ?? 0);
					existingCat.spent = (existingCat.spent ?? 0) + (cat.spent ?? 0);
					existingCat.balance = (existingCat.balance ?? 0) + (cat.balance ?? 0);
					existingCat.received = (existingCat.received ?? 0) + (cat.received ?? 0);
				}
			}
			return acc;
		}, {
			toBudget: 0,
			fromPreviousMonth: 0,
			lastMonthOverspent: 0,
			categoryGroupsMap: /* @__PURE__ */ new Map()
		});
		const categoryData = filterCategoryGroups(Array.from(accumulate_months.categoryGroupsMap.values()), conditions, conditionsOp).flatMap((group) => group.categories.map((cat) => {
			const rawValue = group.is_income ? cat.received ?? 0 : cat.budgeted ?? 0;
			return {
				categoryGroup: group.name,
				categoryGroupId: group.id,
				category: cat.name,
				categoryId: cat.id,
				isIncome: group.is_income,
				isNegative: rawValue < 0,
				value: rawValue
			};
		})).filter((entry) => entry.value !== 0);
		const nextMonthResponse = await send("api/budget-month", { month: nextMonth(end) });
		return {
			data: categoryData,
			aggregated: {
				toBudget: accumulate_months.toBudget,
				forNextMonth: (nextMonthResponse.fromLastMonth ?? 0) - accumulate_months.toBudget,
				fromPreviousMonth: accumulate_months.fromPreviousMonth,
				lastMonthOverspent: accumulate_months.lastMonthOverspent,
				categoryGroupsMap: accumulate_months.categoryGroupsMap,
				startMonth: start,
				endMonth: end
			}
		};
	};
}
function createTransactionsSpreadsheet(start, end, categories, conditions = [], conditionsOp = "and", groupAccounts) {
	return async () => {
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		return await fetchCategoryData(categories, conditionsOp === "or" ? "$or" : "$and", filters, start, end, groupAccounts);
	};
}
function cloneGraph(graph) {
	const clonedGraph = /* @__PURE__ */ new Map();
	for (const [key, node] of graph) clonedGraph.set(key, {
		...node,
		to: new Map(node.to),
		tooltipInfo: node.tooltipInfo?.map((info) => ({ ...info }))
	});
	return clonedGraph;
}
function filterCategoryGroups(categoryGroups, conditions, conditionsOp) {
	const categoryConditions = conditions.filter((cond) => cond.field === GraphLayers.Category);
	const categoryGroupConditions = conditions.filter((cond) => cond.field === GraphLayers.CategoryGroup);
	if (categoryConditions.length === 0 && categoryGroupConditions.length === 0) return categoryGroups;
	const matchesStringCondition = (id, name, cond) => {
		const value = cond.value;
		if (typeof cond.op !== "string") throw new Error("Invalid op");
		const op = cond.op;
		if (op === "is") return id === value;
		if (op === "isNot") return id !== value;
		if (op === "oneOf") return Array.isArray(value) && value.includes(id);
		if (op === "notOneOf") return !Array.isArray(value) || !value.includes(id);
		if (op === "contains") return typeof value === "string" && name.toLowerCase().includes(value.toLowerCase());
		if (op === "doesNotContain") return typeof value === "string" && !name.toLowerCase().includes(value.toLowerCase());
		if (op === "matches") {
			if (typeof value !== "string") return false;
			if (value.length > 256) return false;
			try {
				return (value.startsWith("/") && value.lastIndexOf("/") > 0 ? new RegExp(value.slice(1, value.lastIndexOf("/")), "i") : new RegExp(value, "i")).test(name);
			} catch {
				return false;
			}
		}
		return false;
	};
	const categoryMatchesConditions = (catId, catName, groupId, groupName) => {
		const matchesCat = (cond) => matchesStringCondition(catId, catName, cond);
		const matchesGroup = (cond) => matchesStringCondition(groupId, groupName, cond);
		if (conditionsOp === "or") return categoryConditions.some(matchesCat) || categoryGroupConditions.some(matchesGroup);
		const catMatch = categoryConditions.length === 0 || categoryConditions.every(matchesCat);
		const groupMatch = categoryGroupConditions.length === 0 || categoryGroupConditions.every(matchesGroup);
		return catMatch && groupMatch;
	};
	return categoryGroups.map((group) => ({
		...group,
		categories: group.categories.filter((cat) => categoryMatchesConditions(cat.id, cat.name, group.id, group.name))
	})).filter((group) => group.categories.length > 0);
}
async function fetchCategoryData(categoryGroups, conditionsOpKey = "$and", filters = [], start, end, groupAccounts) {
	const allCategoryData = (await Promise.all(categoryGroups.map(async (categoryGroup) => {
		return (await Promise.all((categoryGroup.categories || []).map(async (category) => {
			return (await aqlQuery(q$1("transactions").filter({ [conditionsOpKey]: filters }).filter({ $and: [{ date: { $gte: firstDayOfMonth(start) } }, { date: { $lte: lastDayOfMonth(end) } }] }).filter({ category: category.id }).groupBy(categoryGroup.is_income ? [
				{ $id: "$category" },
				{ $id: "$account" },
				{ $id: "$payee" }
			] : [{ $id: "$category" }, { $id: "$account" }]).select([
				{ accountId: { $id: "$account.id" } },
				{ accountName: { $id: "$account.name" } },
				{ amount: { $sum: "$amount" } },
				{ payeeId: { $id: "$payee.id" } },
				{ payeeName: { $id: "$payee.name" } }
			]))).data.map((row) => ({
				categoryGroup: categoryGroup.name,
				categoryGroupId: categoryGroup.id,
				category: category.name,
				categoryId: category.id,
				value: Math.abs(row.amount ?? 0),
				isIncome: categoryGroup.is_income ?? false,
				isNegative: row.amount !== void 0 && row.amount < 0,
				accountName: row.accountName ?? "",
				accountId: row.accountId ?? "",
				payeeName: row.payeeName ?? "",
				payeeId: row.payeeId ?? ""
			}));
		}))).flat();
	}))).flat();
	if (groupAccounts) allCategoryData.forEach((entry) => {
		if (entry.accountName && entry.accountId) {
			entry.accountName = SpecialNodeKeys.AllAccounts;
			entry.accountId = SpecialNodeKeys.AllAccounts;
		}
	});
	return allCategoryData;
}
function createBudgetGraph(categoryData, aggregated) {
	const graph = /* @__PURE__ */ new Map();
	addNode(graph, SpecialNodeKeys.Budgeted, GraphLayers.Budget, "Budgeted");
	addNode(graph, SpecialNodeKeys.AvailableIncome, GraphLayers.Account, "Available funds");
	categoryData.forEach((entry) => {
		if (entry.isIncome) {
			addNode(graph, entry.categoryId, GraphLayers.IncomeCategory, entry.category);
			addValueToLink(graph, entry.categoryId, SpecialNodeKeys.AvailableIncome, entry.value);
		} else if (entry.value >= 0) {
			addNode(graph, entry.categoryGroupId, GraphLayers.CategoryGroup, entry.categoryGroup);
			addNode(graph, entry.categoryId, GraphLayers.Category, entry.category);
			addValueToLink(graph, entry.categoryGroupId, entry.categoryId, entry.value);
			addValueToLink(graph, SpecialNodeKeys.Budgeted, entry.categoryGroupId, entry.value);
			addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.Budgeted, entry.value);
		} else {
			addNodeWithLabel(graph, entry.categoryId, GraphLayers.Account, "From {{category}}", { category: entry.category }, true);
			addValueToLink(graph, entry.categoryId, SpecialNodeKeys.Budgeted, Math.abs(entry.value));
			addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.Budgeted, entry.value);
		}
	});
	if (aggregated.toBudget > 0) {
		addNode(graph, SpecialNodeKeys.ToBudget, GraphLayers.Account, "To budget");
		addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.ToBudget, aggregated.toBudget);
	} else {
		addNodeWithLabel(graph, SpecialNodeKeys.ToBudget, GraphLayers.Account, "Overbudgeted", void 0, true);
		addValueToLink(graph, SpecialNodeKeys.ToBudget, SpecialNodeKeys.Budgeted, Math.abs(aggregated.toBudget));
		addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.Budgeted, -Math.abs(aggregated.toBudget));
	}
	addNodeWithLabel(graph, SpecialNodeKeys.FromPrevMonth, GraphLayers.IncomeCategory, "From {{month}}", { month: prevMonth(aggregated.startMonth) });
	addValueToLink(graph, SpecialNodeKeys.FromPrevMonth, SpecialNodeKeys.AvailableIncome, aggregated.fromPreviousMonth);
	addNodeWithLabel(graph, SpecialNodeKeys.ForNextMonth, GraphLayers.Budget, "For {{month}}", { month: nextMonth(aggregated.endMonth) });
	addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.ForNextMonth, aggregated.forNextMonth);
	addNode(graph, SpecialNodeKeys.LastMonthOverspent, GraphLayers.Budget, "Overspent");
	addValueToLink(graph, SpecialNodeKeys.AvailableIncome, SpecialNodeKeys.LastMonthOverspent, Math.abs(aggregated.lastMonthOverspent));
	return graph;
}
function createTransactionsGraph(categoryData) {
	function addAccountNode(accountId, accountName) {
		if (accountId === SpecialNodeKeys.AllAccounts) addNodeWithLabel(graph, accountId, GraphLayers.Account, "Income", void 0);
		else addNode(graph, accountId, GraphLayers.Account, accountName);
	}
	const graph = /* @__PURE__ */ new Map();
	categoryData.forEach((entry) => {
		if (entry.accountId && entry.accountName && entry.categoryId) if (entry.isIncome) if (entry.isNegative) {
			addAccountNode(entry.accountId, entry.accountName);
			addNodeWithLabel(graph, entry.categoryId + SpecialNodeKeys.NegativeSuffix, GraphLayers.CategoryGroup, entry.payeeName ?? entry.category, void 0, true);
			addValueToLink(graph, entry.accountId, entry.categoryId + SpecialNodeKeys.NegativeSuffix, entry.value);
		} else {
			addNode(graph, entry.categoryId, GraphLayers.IncomeCategory, entry.category);
			addAccountNode(entry.accountId, entry.accountName);
			addValueToLink(graph, entry.categoryId, entry.accountId, entry.value);
			if (entry.payeeId) {
				addNode(graph, entry.payeeId, GraphLayers.IncomePayee, entry.payeeName);
				addValueToLink(graph, entry.payeeId, entry.categoryId, entry.value);
			}
		}
		else if (entry.isNegative) {
			addAccountNode(entry.accountId, entry.accountName);
			addNode(graph, entry.categoryGroupId, GraphLayers.CategoryGroup, entry.categoryGroup);
			addNode(graph, entry.categoryId, GraphLayers.Category, entry.category);
			addValueToLink(graph, entry.accountId, entry.categoryGroupId, entry.value);
			addValueToLink(graph, entry.categoryGroupId, entry.categoryId, entry.value);
		} else {
			addNode(graph, entry.categoryId + SpecialNodeKeys.NegativeSuffix, GraphLayers.IncomeCategory, entry.payeeName ?? entry.category);
			addAccountNode(entry.accountId, entry.accountName);
			addValueToLink(graph, entry.categoryId + SpecialNodeKeys.NegativeSuffix, entry.accountId, entry.value);
		}
	});
	return graph;
}
function addNode(graph, key, type, name) {
	if (!graph.has(key)) graph.set(key, {
		to: /* @__PURE__ */ new Map(),
		type,
		name
	});
}
function addNodeWithLabel(graph, key, type, labelKey, labelParams, isNegative) {
	if (!graph.has(key)) graph.set(key, {
		to: /* @__PURE__ */ new Map(),
		type,
		labelKey,
		labelParams,
		isNegative
	});
}
function addValueToLink(graph, from, to, value) {
	const fromNode = graph.get(from);
	if (fromNode) fromNode.to.set(to, (fromNode.to.get(to) ?? 0) + value);
}
function getLayer(graph, key) {
	const parents = [];
	for (const [parentKey, data] of graph) if (data.to.has(key)) parents.push(parentKey);
	if (parents.length === 0) return 0;
	return 1 + Math.max(...parents.map((parentKey) => getLayer(graph, parentKey)));
}
function groupOtherCategories(graph, topN, categorySort = "per-group") {
	const toolTipInfoMap = /* @__PURE__ */ new Map();
	const structuralKeys = new Set(Object.values(SpecialNodeKeys));
	function isGroupableNode(key) {
		const node = graph.get(key);
		return Boolean(node && !key.endsWith(SpecialNodeKeys.OtherSuffix) && !structuralKeys.has(key) && !node.isNegative);
	}
	Object.entries(GraphLayers).forEach(([_, layer]) => {
		let ordinaryNodes = nodesInLayer(graph, layer).filter(isGroupableNode);
		let otherNodes = nodesInLayer(graph, layer).filter((s) => s.endsWith(SpecialNodeKeys.OtherSuffix));
		while (ordinaryNodes.length + otherNodes.length > topN) {
			let minValue = Infinity;
			let nodeToDelete;
			for (const nodeKey of ordinaryNodes) {
				const nodeValue = getNodeValue(graph, nodeKey);
				if (nodeValue < minValue) {
					minValue = nodeValue;
					nodeToDelete = nodeKey;
				}
			}
			if (nodeToDelete === void 0) break;
			moveToOther(graph, nodeToDelete, toolTipInfoMap, categorySort === "global");
			ordinaryNodes = nodesInLayer(graph, layer).filter(isGroupableNode);
			otherNodes = nodesInLayer(graph, layer).filter((s) => s.endsWith(SpecialNodeKeys.OtherSuffix));
		}
	});
	return toolTipInfoMap;
}
function nodesInLayer(graph, layer) {
	return Array.from(graph).filter(([, data]) => data.type === layer).map(([key]) => key);
}
function moveToOther(graph, key, toolTipInfoMap, globalOther = false) {
	const nodeData = graph.get(key);
	if (!nodeData) return;
	const toNodes = Array.from(graph.get(key)?.to.keys() ?? []);
	const fromNodes = Array.from(graph).filter(([, data]) => data.to.has(key));
	let otherKey;
	if (globalOther) otherKey = nodeData.type + SpecialNodeKeys.OtherSuffix;
	else {
		otherKey = nodeData.type + SpecialNodeKeys.OtherSuffix;
		if (nodeData.type === GraphLayers.Category) {
			const categoryGroupResult = getCategoryGroup(graph, key);
			if (categoryGroupResult) otherKey = categoryGroupResult[0] + SpecialNodeKeys.OtherSuffix;
		} else if (nodeData.type === GraphLayers.IncomePayee) {
			const incomeCategoryKey = Array.from(graph.get(key)?.to.keys() ?? []).find((k) => graph.get(k)?.type === GraphLayers.IncomeCategory);
			if (incomeCategoryKey) otherKey = incomeCategoryKey + SpecialNodeKeys.OtherSuffix;
		}
	}
	addNode(graph, otherKey, nodeData.type, "Other");
	fromNodes.forEach(([fromKey, fromData]) => {
		const linkValue = fromData.to.get(key);
		if (linkValue !== void 0) {
			addValueToLink(graph, fromKey, otherKey, linkValue);
			newAddTooltipInfo(toolTipInfoMap, fromKey, otherKey, graph.get(key)?.name ?? key, linkValue);
		}
	});
	toNodes.forEach((toKey) => {
		const linkValue = graph.get(key)?.to.get(toKey);
		if (linkValue !== void 0) {
			addValueToLink(graph, otherKey, toKey, linkValue);
			newAddTooltipInfo(toolTipInfoMap, otherKey, toKey, graph.get(key)?.name ?? key, linkValue);
		}
	});
	toNodes.forEach((toKey) => {
		deleteLink(graph, key, toKey);
	});
	fromNodes.forEach(([fromKey]) => {
		deleteLink(graph, fromKey, key);
	});
	graph.delete(key);
}
function newAddTooltipInfo(toolTipInfoMap, from, to, name, value) {
	if (!toolTipInfoMap.has(from)) toolTipInfoMap.set(from, /* @__PURE__ */ new Map());
	const innerMap = toolTipInfoMap.get(from);
	const existingInfo = innerMap.get(to) ?? [];
	if (!existingInfo.find((info) => info.name === name)) innerMap.set(to, [...existingInfo, {
		name,
		value
	}]);
}
function getCategoryGroup(graph, key) {
	return Array.from(graph).filter(([, data]) => data.to.has(key) && data.type === GraphLayers.CategoryGroup)[0];
}
function deleteLink(graph, from, to) {
	const fromNode = graph.get(from);
	if (fromNode) fromNode.to.delete(to);
}
function sortGraph(graph, categorySort = "per-group", categories) {
	function sortRelatedNodesAroundAnchors(entries, anchorLayer, relatedLayer, placement) {
		nodesInLayer(graph, anchorLayer).forEach((anchorKey) => {
			const anchor = graph.get(anchorKey);
			if (!anchor) return;
			const relatedKeys = placement === "after" ? Array.from(anchor.to.keys()).filter((key) => graph.get(key)?.type === relatedLayer) : Array.from(graph).filter(([, data]) => data.type === relatedLayer && data.to.has(anchorKey)).map(([key]) => key);
			const otherKey = `${anchorKey}${SpecialNodeKeys.OtherSuffix}`;
			const relatedOtherKey = graph.get(otherKey)?.type === relatedLayer ? otherKey : void 0;
			const orderedRelatedKeys = relatedKeys.filter((key) => key !== otherKey);
			const relatedEntries = orderedRelatedKeys.map((key) => entries.find(([entryKey]) => entryKey === key)).filter((entry) => entry !== void 0);
			relatedEntries.sort(([keyA], [keyB]) => getNodeValue(graph, keyB) - getNodeValue(graph, keyA));
			const otherEntry = relatedOtherKey ? entries.find(([entryKey]) => entryKey === relatedOtherKey) : void 0;
			const relatedKeysToMove = new Set(orderedRelatedKeys);
			if (relatedOtherKey) relatedKeysToMove.add(relatedOtherKey);
			const entriesWithoutRelated = entries.filter(([entryKey]) => !relatedKeysToMove.has(entryKey));
			const anchorIndex = entriesWithoutRelated.findIndex(([entryKey]) => entryKey === anchorKey);
			if (anchorIndex === -1) return;
			const insertionIndex = placement === "before" ? anchorIndex : anchorIndex + 1;
			const nodesToInsert = otherEntry ? [...relatedEntries, otherEntry] : relatedEntries;
			entriesWithoutRelated.splice(insertionIndex, 0, ...nodesToInsert);
			entries.length = 0;
			entries.push(...entriesWithoutRelated);
		});
	}
	let sortedEntries;
	if (categorySort === "global") {
		sortedEntries = Array.from(graph.entries()).sort(([keyA], [keyB]) => getNodeValue(graph, keyB) - getNodeValue(graph, keyA));
		sortedEntries.forEach(([key]) => {
			if (key.endsWith(SpecialNodeKeys.OtherSuffix)) moveNodeToEnd(sortedEntries, key);
		});
	} else if (categorySort === "per-group") {
		sortedEntries = Array.from(graph.entries()).sort(([keyA], [keyB]) => getNodeValue(graph, keyB) - getNodeValue(graph, keyA));
		sortRelatedNodesAroundAnchors(sortedEntries, GraphLayers.CategoryGroup, GraphLayers.Category, "after");
		sortRelatedNodesAroundAnchors(sortedEntries, GraphLayers.IncomeCategory, GraphLayers.IncomePayee, "before");
	} else {
		const used = /* @__PURE__ */ new Set();
		sortedEntries = [];
		categories.forEach((group) => {
			const groupNode = graph.get(group.id);
			if (groupNode) {
				sortedEntries.push([group.id, groupNode]);
				used.add(group.id);
			}
			if (group.categories && group.categories.length) group.categories.forEach((cat) => {
				const categoryNode = graph.get(cat.id);
				if (categoryNode) {
					sortedEntries.push([cat.id, categoryNode]);
					used.add(cat.id);
				}
			});
			const otherKey = `${group.id}${SpecialNodeKeys.OtherSuffix}`;
			const otherNode = graph.get(otherKey);
			if (otherNode) {
				sortedEntries.push([otherKey, otherNode]);
				used.add(otherKey);
			}
		});
		for (const [key, data] of graph) if (!used.has(key)) sortedEntries.push([key, data]);
	}
	sortedEntries.filter(([, nodeData]) => nodeData.isNegative).forEach(([key]) => {
		moveNodeToStart(sortedEntries, key);
	});
	const toBudgetNode = graph.get(SpecialNodeKeys.ToBudget);
	if (toBudgetNode) if (toBudgetNode.isNegative) moveNodeToStart(sortedEntries, SpecialNodeKeys.ToBudget);
	else moveNodeToEnd(sortedEntries, SpecialNodeKeys.ToBudget);
	moveNodeToEnd(sortedEntries, SpecialNodeKeys.LastMonthOverspent);
	moveNodeToEnd(sortedEntries, SpecialNodeKeys.ForNextMonth);
	moveNodeToEnd(sortedEntries, SpecialNodeKeys.FromPrevMonth);
	return new Map(sortedEntries);
}
function moveNodeToEnd(entries, key) {
	const nodeIndex = entries.findIndex(([nodekey]) => nodekey === key);
	if (nodeIndex !== -1) {
		const [entry] = entries.splice(nodeIndex, 1);
		entries.push(entry);
	}
}
function moveNodeToStart(entries, key) {
	const nodeIndex = entries.findIndex(([nodekey]) => nodekey === key);
	if (nodeIndex !== -1) {
		const [entry] = entries.splice(nodeIndex, 1);
		entries.unshift(entry);
	}
}
function getNodeValue(graph, key) {
	let nodeValue = 0;
	if (getLayer(graph, key) === 0) {
		const node = graph.get(key);
		if (node) node.to.forEach((value) => {
			nodeValue += value ?? 0;
		});
	} else {
		graph.forEach((data) => {
			nodeValue += data.to.get(key) ?? 0;
		});
		if (nodeValue < 0) {
			nodeValue = 0;
			const node = graph.get(key);
			if (node) node.to.forEach((value) => {
				nodeValue += value;
			});
		}
	}
	return nodeValue;
}
function addPercentageLabels(graph) {
	const layerSums = /* @__PURE__ */ new Map();
	graph.forEach((_, key) => {
		const layer = graph.get(key)?.type;
		if (!layer) return;
		const nodeValue = getNodeValue(graph, key);
		layerSums.set(layer, (layerSums.get(layer) ?? 0) + nodeValue);
	});
	graph.forEach((data, key) => {
		const layer = data.type;
		const nodeValue = getNodeValue(graph, key);
		const layerTotal = layerSums.get(layer) ?? 1;
		data.percentageLabel = `${(layerTotal ? nodeValue / layerTotal * 100 : 0).toFixed(1)}%`;
	});
}
function addColors(graph) {
	const colors = getColorScale("qualitative");
	for (const key of graph.keys()) {
		const node = graph.get(key);
		if (node) node.color = colors[colorIndexFromKey(key, colors.length)];
	}
	setColor(graph, SpecialNodeKeys.ToBudget, theme.toBudgetPositive);
	graph.forEach((node, key) => {
		if (node.isNegative) setColor(graph, key, theme.toBudgetNegative);
	});
	setColor(graph, SpecialNodeKeys.LastMonthOverspent, theme.toBudgetNegative);
	setColor(graph, SpecialNodeKeys.FromPrevMonth, theme.reportsGray);
	setColor(graph, SpecialNodeKeys.ForNextMonth, theme.reportsGray);
	setColor(graph, SpecialNodeKeys.Budgeted, theme.reportsBlue);
	setColor(graph, SpecialNodeKeys.AvailableIncome, theme.reportsBlue);
	setColor(graph, SpecialNodeKeys.AllAccounts, theme.reportsBlue);
}
function colorIndexFromKey(key, colorCount) {
	const hex = key.replace(/[^0-9a-f]/gi, "").slice(0, 3);
	return parseInt(hex || "0", 16) % colorCount;
}
function setColor(graph, key, color) {
	const node = graph.get(key);
	if (node) node.color = color;
}
function addHiddenNodes(graph) {
	const nodesByType = {};
	for (const [key, node] of graph) {
		if (!nodesByType[node.type]) nodesByType[node.type] = [];
		nodesByType[node.type].push([key, node]);
	}
	const { typeHasParent, typeHasChild } = buildTypeConnectivity(graph, nodesByType);
	const activeLayerOrder = GRAPH_LAYER_ORDER.filter((layer) => (nodesByType[layer]?.length ?? 0) > 0);
	const layerIndex = /* @__PURE__ */ new Map();
	activeLayerOrder.forEach((layer, index) => {
		layerIndex.set(layer, index);
	});
	function addHiddenParentChain(key, type) {
		const typeIndex = layerIndex.get(type);
		if (typeIndex === void 0 || typeIndex <= 0) return;
		let childKey = key;
		for (let i = typeIndex - 1; i >= 0; i--) {
			const parentType = activeLayerOrder[i];
			if (!parentType) continue;
			const parentKey = `${key}_${parentType}${SpecialNodeKeys.HiddenSuffix}`;
			addNode(graph, parentKey, parentType, "");
			addValueToLink(graph, parentKey, childKey, -1);
			childKey = parentKey;
		}
	}
	function addHiddenChildChain(key, type) {
		const typeIndex = layerIndex.get(type);
		if (typeIndex === void 0 || typeIndex < 0 || typeIndex >= activeLayerOrder.length - 1) return;
		let parentKey = key;
		for (let i = typeIndex + 1; i < activeLayerOrder.length; i++) {
			const childType = activeLayerOrder[i];
			if (!childType) continue;
			const childKey = `${key}_${childType}${SpecialNodeKeys.HiddenSuffix}`;
			addNode(graph, childKey, childType, "");
			addValueToLink(graph, parentKey, childKey, -1);
			parentKey = childKey;
		}
	}
	for (const typeStr in nodesByType) {
		if (!isGraphLayer(typeStr)) continue;
		const type = typeStr;
		const nodes = nodesByType[type];
		if (!nodes) continue;
		for (const [key, node] of nodes) {
			const nodeHasParent = hasParent(graph, key);
			const nodeHasChild = hasChild(node);
			if (!nodeHasParent && typeHasParent[type]) addHiddenParentChain(key, type);
			if (!nodeHasChild && typeHasChild[type]) addHiddenChildChain(key, type);
		}
	}
}
function buildTypeConnectivity(graph, nodesByType) {
	const typeHasParent = {};
	const typeHasChild = {};
	for (const typeStr in nodesByType) {
		if (!isGraphLayer(typeStr)) continue;
		const type = typeStr;
		const nodes = nodesByType[type];
		if (!nodes) continue;
		typeHasParent[type] = false;
		typeHasChild[type] = false;
		for (const [key, node] of nodes) {
			if (hasParent(graph, key)) typeHasParent[type] = true;
			if (hasChild(node)) typeHasChild[type] = true;
		}
	}
	return {
		typeHasParent,
		typeHasChild
	};
}
function hasParent(graph, key) {
	for (const [_, data] of graph) if (data.to.has(key)) return true;
	return false;
}
function hasChild(node) {
	return node.to.size > 0;
}
function filterGraphByLayers(graph, layerFrom, layerTo) {
	const layerIndices = /* @__PURE__ */ new Map();
	GRAPH_LAYER_ORDER.forEach((layer, index) => {
		layerIndices.set(layer, index);
	});
	const fromIndex = layerIndices.get(layerFrom);
	const toIndex = layerIndices.get(layerTo);
	if (fromIndex !== void 0 && toIndex !== void 0) {
		const keysToDelete = [];
		graph.forEach((data, key) => {
			const nodeLayerIndex = layerIndices.get(data.type);
			if (nodeLayerIndex !== void 0) {
				if (nodeLayerIndex < fromIndex || nodeLayerIndex > toIndex) keysToDelete.push(key);
			}
		});
		keysToDelete.forEach((key) => graph.delete(key));
	}
}
function cleanUpNodes(graph) {
	for (const [, node] of graph) for (const [target, value] of node.to) if (value === 0) node.to.delete(target);
	const hasIncoming = /* @__PURE__ */ new Set();
	for (const [, node] of graph) for (const target of node.to.keys()) hasIncoming.add(target);
	const toDelete = [];
	for (const [key, node] of graph) {
		const hasOutgoing = node.to.size > 0;
		const incoming = hasIncoming.has(key);
		if (!hasOutgoing && !incoming) toDelete.push(key);
	}
	for (const key of toDelete) graph.delete(key);
}
function convertToSankeyData(graph, toolTipInfoMap) {
	const nodes = Array.from(graph, ([key, data]) => ({
		key,
		name: data.labelKey ? t(data.labelKey, data.labelParams) : data.name ?? key,
		percentageLabel: data.percentageLabel ?? "",
		color: data.color ?? void 0
	}));
	return {
		nodes,
		links: Array.from(graph).flatMap(([key, data]) => Array.from(data.to, ([targetKey, value]) => {
			const tooltipInfo = toolTipInfoMap.get(key)?.get(targetKey) ?? [];
			tooltipInfo.sort((a, b) => b.value - a.value);
			let color;
			const sourceLayersWithOwnColor = [
				GraphLayers.IncomePayee,
				GraphLayers.IncomeCategory,
				GraphLayers.Account,
				GraphLayers.CategoryGroup
			];
			const targetLayersWithTargetColor = [GraphLayers.Category, GraphLayers.Budget];
			if (isGraphLayer(data.type) && sourceLayersWithOwnColor.includes(data.type)) color = data.color;
			else if (isGraphLayer(data.type) && targetLayersWithTargetColor.includes(data.type)) {
				const targetNode = graph.get(targetKey);
				color = targetNode ? targetNode.color : void 0;
			}
			if (targetKey === SpecialNodeKeys.LastMonthOverspent) color = graph.get(SpecialNodeKeys.LastMonthOverspent)?.color;
			if (targetKey.endsWith(SpecialNodeKeys.NegativeSuffix)) color = graph.get(targetKey)?.color;
			if (targetKey === SpecialNodeKeys.ToBudget) color = graph.get(SpecialNodeKeys.ToBudget)?.color;
			if (targetKey === SpecialNodeKeys.ForNextMonth) color = graph.get(SpecialNodeKeys.ForNextMonth)?.color;
			if (data.isNegative) color = data.color;
			return {
				source: nodes.findIndex((n) => n.key === key) ?? -1,
				target: nodes.findIndex((n) => n.key === targetKey) ?? -1,
				value,
				tooltipInfo,
				color: color ?? void 0
			};
		}))
	};
}
//#endregion
//#region src/components/reports/reports/Sankey.tsx
function Sankey() {
	const $ = (0, import_compiler_runtime.c)(5);
	const t0 = useParams().id ?? "";
	let t1;
	if ($[0] !== t0) {
		t1 = {
			id: t0,
			type: "sankey-card"
		};
		$[0] = t0;
		$[1] = t1;
	} else t1 = $[1];
	const { data: widget, isLoading } = useDashboardWidget(t1);
	if (isLoading) {
		let t2;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t2;
		} else t2 = $[2];
		return t2;
	}
	let t2;
	if ($[3] !== widget) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyInner, { widget });
		$[3] = widget;
		$[4] = t2;
	} else t2 = $[4];
	return t2;
}
function topNNodes(cardHeight) {
	return Math.max(2, Math.floor(cardHeight / 35));
}
function getAvailableLayers(mode) {
	return GRAPH_LAYER_ORDER.filter((layer) => {
		if (mode === "budgeted") return layer !== GraphLayers.IncomePayee;
		return layer !== GraphLayers.Budget;
	});
}
function getDefaultLayerRange(mode) {
	return {
		from: mode === "budgeted" ? GraphLayers.IncomeCategory : GraphLayers.IncomePayee,
		to: GraphLayers.Category
	};
}
function normalizeLayerRange(mode, candidate, changedDirection) {
	const availableLayers = getAvailableLayers(mode);
	const fallback = getDefaultLayerRange(mode);
	const defaultFromIndex = availableLayers.indexOf(fallback.from);
	const defaultToIndex = availableLayers.indexOf(fallback.to);
	let from = availableLayers.includes(candidate.from) ? candidate.from : fallback.from;
	let to = availableLayers.includes(candidate.to) ? candidate.to : fallback.to;
	let fromIndex = availableLayers.indexOf(from);
	let toIndex = availableLayers.indexOf(to);
	if (fromIndex >= toIndex) {
		if (changedDirection === "from") to = availableLayers[Math.min(availableLayers.length - 1, Math.max(fromIndex + 1, defaultToIndex))] ?? fallback.to;
		else if (changedDirection === "to") from = availableLayers[Math.max(0, Math.min(toIndex - 1, defaultFromIndex))] ?? fallback.from;
		else {
			from = fallback.from;
			to = fallback.to;
		}
		fromIndex = availableLayers.indexOf(from);
		toIndex = availableLayers.indexOf(to);
	}
	if (fromIndex >= toIndex) return fallback;
	return {
		from,
		to
	};
}
function getLayerMenuItems(mode, direction, otherLayer) {
	const availableLayers = getAvailableLayers(mode);
	const otherIndex = availableLayers.indexOf(otherLayer);
	if (otherIndex === -1) return [];
	if (direction === "from") return availableLayers.slice(0, otherIndex);
	return availableLayers.slice(otherIndex + 1);
}
var TOP_N_OPTIONS = [
	1e5,
	10,
	15,
	20,
	25,
	30
];
function displayN(n, t) {
	return n === 1e5 ? t("All") : String(n);
}
function TopNSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(27);
	const { value, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = () => setIsOpen(true);
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] !== t) {
		t2 = t("Change category limit");
		$[1] = t;
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	let t4;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgList, { style: {
			width: 12,
			height: 12
		} });
		t4 = { marginLeft: 5 };
		$[3] = t3;
		$[4] = t4;
	} else {
		t3 = $[3];
		t4 = $[4];
	}
	let t5;
	if ($[5] !== t || $[6] !== value) {
		t5 = t("Show up to {{n}}", { n: displayN(value, t) });
		$[5] = t;
		$[6] = value;
		$[7] = t5;
	} else t5 = $[7];
	let t6;
	if ($[8] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t4,
			children: t5
		});
		$[8] = t5;
		$[9] = t6;
	} else t6 = $[9];
	let t7;
	if ($[10] !== t2 || $[11] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t1,
			"aria-label": t2,
			children: [t3, t6]
		});
		$[10] = t2;
		$[11] = t6;
		$[12] = t7;
	} else t7 = $[12];
	let t8;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsOpen(false);
		$[13] = t8;
	} else t8 = $[13];
	let t9;
	if ($[14] !== onChange) {
		t9 = (item) => {
			onChange(Number(item));
			setIsOpen(false);
		};
		$[14] = onChange;
		$[15] = t9;
	} else t9 = $[15];
	let t10;
	if ($[16] !== t) {
		t10 = TOP_N_OPTIONS.map((n) => ({
			name: String(n),
			text: t("Show up to {{n}}", { n: displayN(n, t) })
		}));
		$[16] = t;
		$[17] = t10;
	} else t10 = $[17];
	let t11;
	if ($[18] !== t10 || $[19] !== t9) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t9,
			items: t10
		});
		$[18] = t10;
		$[19] = t9;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] !== isOpen || $[22] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t8,
			children: t11
		});
		$[21] = isOpen;
		$[22] = t11;
		$[23] = t12;
	} else t12 = $[23];
	let t13;
	if ($[24] !== t12 || $[25] !== t7) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t7, t12] });
		$[24] = t12;
		$[25] = t7;
		$[26] = t13;
	} else t13 = $[26];
	return t13;
}
function CategorySortSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(43);
	const { value, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] !== t) {
		t1 = t("Sort per group");
		$[0] = t;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== t1) {
		t2 = {
			key: "per-group",
			label: t1
		};
		$[2] = t1;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== t) {
		t3 = t("Sort all");
		$[4] = t;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t3) {
		t4 = {
			key: "global",
			label: t3
		};
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== t) {
		t5 = t("Sort as budget");
		$[8] = t;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] !== t5) {
		t6 = {
			key: "budget-order",
			label: t5
		};
		$[10] = t5;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== t2 || $[13] !== t4 || $[14] !== t6) {
		t7 = [
			t2,
			t4,
			t6
		];
		$[12] = t2;
		$[13] = t4;
		$[14] = t6;
		$[15] = t7;
	} else t7 = $[15];
	const options = t7;
	let t8;
	if ($[16] !== t || $[17] !== value) {
		t8 = value === "global" ? t("Sort all") : value === "budget-order" ? t("Sort as budget") : t("Sort per group");
		$[16] = t;
		$[17] = value;
		$[18] = t8;
	} else t8 = $[18];
	const currentLabel = t8;
	let t9;
	if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = () => setIsOpen(true);
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] !== t) {
		t10 = t("Change category sort order");
		$[20] = t;
		$[21] = t10;
	} else t10 = $[21];
	let t11;
	let t12;
	if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgArrowDown, { style: {
			width: 12,
			height: 12
		} });
		t12 = { marginLeft: 5 };
		$[22] = t11;
		$[23] = t12;
	} else {
		t11 = $[22];
		t12 = $[23];
	}
	let t13;
	if ($[24] !== currentLabel) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t12,
			children: currentLabel
		});
		$[24] = currentLabel;
		$[25] = t13;
	} else t13 = $[25];
	let t14;
	if ($[26] !== t10 || $[27] !== t13) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			variant: "bare",
			onPress: t9,
			"aria-label": t10,
			children: [t11, t13]
		});
		$[26] = t10;
		$[27] = t13;
		$[28] = t14;
	} else t14 = $[28];
	let t15;
	if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = () => setIsOpen(false);
		$[29] = t15;
	} else t15 = $[29];
	let t16;
	if ($[30] !== onChange) {
		t16 = (item) => {
			onChange(item);
			setIsOpen(false);
		};
		$[30] = onChange;
		$[31] = t16;
	} else t16 = $[31];
	let t17;
	if ($[32] !== options) {
		t17 = options.map(_temp$5);
		$[32] = options;
		$[33] = t17;
	} else t17 = $[33];
	let t18;
	if ($[34] !== t16 || $[35] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t16,
			items: t17
		});
		$[34] = t16;
		$[35] = t17;
		$[36] = t18;
	} else t18 = $[36];
	let t19;
	if ($[37] !== isOpen || $[38] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t15,
			children: t18
		});
		$[37] = isOpen;
		$[38] = t18;
		$[39] = t19;
	} else t19 = $[39];
	let t20;
	if ($[40] !== t14 || $[41] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t14, t19] });
		$[40] = t14;
		$[41] = t19;
		$[42] = t20;
	} else t20 = $[42];
	return t20;
}
function _temp$5(t0) {
	const { key, label } = t0;
	return {
		name: key,
		text: label
	};
}
function LayerSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(35);
	const { direction, value, layerLabels, menuItems, onChange } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let T0;
	let t1;
	let t2;
	let t3;
	let t4;
	if ($[0] !== direction || $[1] !== t) {
		const translatedDirection = direction === "from" ? t("from") : t("to");
		T0 = Button;
		t1 = triggerRef;
		t2 = "bare";
		if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
			t3 = () => setIsOpen(true);
			$[7] = t3;
		} else t3 = $[7];
		t4 = t("Change layer {{direction}}", { direction: translatedDirection });
		$[0] = direction;
		$[1] = t;
		$[2] = T0;
		$[3] = t1;
		$[4] = t2;
		$[5] = t3;
		$[6] = t4;
	} else {
		T0 = $[2];
		t1 = $[3];
		t2 = $[4];
		t3 = $[5];
		t4 = $[6];
	}
	let t5;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = { marginLeft: 5 };
		$[8] = t5;
	} else t5 = $[8];
	const t6 = layerLabels[value];
	let t7;
	if ($[9] !== t6) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: t5,
			children: t6
		});
		$[9] = t6;
		$[10] = t7;
	} else t7 = $[10];
	let t8;
	if ($[11] !== T0 || $[12] !== t1 || $[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t7) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(T0, {
			ref: t1,
			variant: t2,
			onPress: t3,
			"aria-label": t4,
			children: t7
		});
		$[11] = T0;
		$[12] = t1;
		$[13] = t2;
		$[14] = t3;
		$[15] = t4;
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = () => setIsOpen(false);
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	if ($[19] !== onChange) {
		t10 = (item) => {
			onChange(item);
			setIsOpen(false);
		};
		$[19] = onChange;
		$[20] = t10;
	} else t10 = $[20];
	let t11;
	if ($[21] !== layerLabels || $[22] !== menuItems) {
		let t12;
		if ($[24] !== layerLabels) {
			t12 = (layer) => ({
				name: layer,
				text: layerLabels[layer]
			});
			$[24] = layerLabels;
			$[25] = t12;
		} else t12 = $[25];
		t11 = menuItems.map(t12);
		$[21] = layerLabels;
		$[22] = menuItems;
		$[23] = t11;
	} else t11 = $[23];
	let t12;
	if ($[26] !== t10 || $[27] !== t11) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t10,
			items: t11
		});
		$[26] = t10;
		$[27] = t11;
		$[28] = t12;
	} else t12 = $[28];
	let t13;
	if ($[29] !== isOpen || $[30] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom start",
			isOpen,
			onOpenChange: t9,
			children: t12
		});
		$[29] = isOpen;
		$[30] = t12;
		$[31] = t13;
	} else t13 = $[31];
	let t14;
	if ($[32] !== t13 || $[33] !== t8) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t8, t13] });
		$[32] = t13;
		$[33] = t8;
		$[34] = t14;
	} else t14 = $[34];
	return t14;
}
function GraphModeSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(17);
	const { mode, onChange } = t0;
	const t1 = mode === "spent";
	let t2;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = { backgroundColor: "inherit" };
		$[0] = t2;
	} else t2 = $[0];
	let t3;
	if ($[1] !== onChange) {
		t3 = () => {
			onChange("spent");
		};
		$[1] = onChange;
		$[2] = t3;
	} else t3 = $[2];
	let t4;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Spent" });
		$[3] = t4;
	} else t4 = $[3];
	let t5;
	if ($[4] !== t1 || $[5] !== t3) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
			selected: t1,
			style: t2,
			onSelect: t3,
			children: t4
		});
		$[4] = t1;
		$[5] = t3;
		$[6] = t5;
	} else t5 = $[6];
	const t6 = mode === "budgeted";
	let t7;
	if ($[7] !== onChange) {
		t7 = () => {
			onChange("budgeted");
		};
		$[7] = onChange;
		$[8] = t7;
	} else t7 = $[8];
	let t8;
	let t9;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = { backgroundColor: "inherit" };
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted" });
		$[9] = t8;
		$[10] = t9;
	} else {
		t8 = $[9];
		t9 = $[10];
	}
	let t10;
	if ($[11] !== t6 || $[12] !== t7) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
			selected: t6,
			onSelect: t7,
			style: t8,
			children: t9
		});
		$[11] = t6;
		$[12] = t7;
		$[13] = t10;
	} else t10 = $[13];
	let t11;
	if ($[14] !== t10 || $[15] !== t5) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			gap: 5,
			children: [t5, t10]
		});
		$[14] = t10;
		$[15] = t5;
		$[16] = t11;
	} else t11 = $[16];
	return t11;
}
function OptionsButton(t0) {
	const $ = (0, import_compiler_runtime.c)(24);
	const { showPercentages, onTogglePercentages, groupAccounts, onToggleGroupAccounts } = t0;
	const { t } = useTranslation();
	const triggerRef = (0, import_react.useRef)(null);
	const [isOpen, setIsOpen] = (0, import_react.useState)(false);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			ref: triggerRef,
			onPress: () => setIsOpen(true),
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Options" })
		});
		$[0] = t1;
	} else t1 = $[0];
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = () => setIsOpen(false);
		$[1] = t2;
	} else t2 = $[1];
	let t3;
	if ($[2] !== onToggleGroupAccounts || $[3] !== onTogglePercentages) {
		t3 = (item) => {
			if (item === "show-percentages") onTogglePercentages();
			if (item === "group-accounts") onToggleGroupAccounts();
		};
		$[2] = onToggleGroupAccounts;
		$[3] = onTogglePercentages;
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== t) {
		t4 = t("Show as percentages");
		$[5] = t;
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== showPercentages || $[8] !== t4) {
		t5 = {
			name: "show-percentages",
			text: t4,
			toggle: showPercentages
		};
		$[7] = showPercentages;
		$[8] = t4;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] !== t) {
		t6 = t("Group accounts in Spent view");
		$[10] = t;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== groupAccounts || $[13] !== t6) {
		t7 = {
			name: "group-accounts",
			text: t6,
			toggle: groupAccounts
		};
		$[12] = groupAccounts;
		$[13] = t6;
		$[14] = t7;
	} else t7 = $[14];
	let t8;
	if ($[15] !== t5 || $[16] !== t7) {
		t8 = [t5, t7];
		$[15] = t5;
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t3 || $[19] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
			onMenuSelect: t3,
			items: t8
		});
		$[18] = t3;
		$[19] = t8;
		$[20] = t9;
	} else t9 = $[20];
	let t10;
	if ($[21] !== isOpen || $[22] !== t9) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t1, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			placement: "bottom end",
			isOpen,
			onOpenChange: t2,
			children: t9
		})] });
		$[21] = isOpen;
		$[22] = t9;
		$[23] = t10;
	} else t10 = $[23];
	return t10;
}
function SankeyInner({ widget }) {
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t, i18n } = useTranslation();
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	const currentMonth$4 = currentMonth();
	const [allMonths, setAllMonths] = (0, import_react.useState)([{
		name: currentMonth$4,
		pretty: format(currentMonth$4, "MMMM yyyy", locale)
	}]);
	const [start, setStart] = (0, import_react.useState)(currentMonth());
	const [end, setEnd] = (0, import_react.useState)(currentMonth());
	const [timeFrameMode, setTimeFrameMode] = (0, import_react.useState)(widget?.meta?.timeFrame?.mode ?? "sliding-window");
	const [datesInitialized, setDatesInitialized] = (0, import_react.useState)(false);
	const [earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [graphMode, setGraphMode] = (0, import_react.useState)(widget?.meta?.mode ?? "spent");
	const [topNcategories, settopNcategories] = (0, import_react.useState)(widget?.meta?.topNcategories ?? 15);
	const [cardHeight, setCardHeight] = (0, import_react.useState)(0);
	const throttledSetCardHeight = (0, import_react.useMemo)(() => (0, import_debounce.default)((height) => {
		setCardHeight((prev) => prev === height ? prev : height);
	}, 200, {
		leading: true,
		trailing: true,
		maxWait: 200
	}), []);
	(0, import_react.useEffect)(() => {
		return () => {
			throttledSetCardHeight.cancel();
		};
	}, [throttledSetCardHeight]);
	const containerRef = useResizeObserver((rect) => {
		throttledSetCardHeight(rect.height);
	});
	const heightBasedTopN = topNNodes(cardHeight);
	const topN = Math.min(topNcategories, heightBasedTopN);
	const [categorySort, setCategorySort] = (0, import_react.useState)(widget?.meta?.categorySort ?? "per-group");
	const [showPercentages, setShowPercentages] = (0, import_react.useState)(widget?.meta?.showPercentages ?? false);
	const [groupAccounts, setGroupAccounts] = (0, import_react.useState)(widget?.meta?.groupAccounts ?? false);
	const [layerRange, setLayerRange] = (0, import_react.useState)(() => normalizeLayerRange(widget?.meta?.mode ?? "spent", {
		from: widget?.meta?.layerFrom ?? getDefaultLayerRange(widget?.meta?.mode ?? "spent").from,
		to: widget?.meta?.layerTo ?? getDefaultLayerRange(widget?.meta?.mode ?? "spent").to
	}));
	const layerFrom = layerRange.from;
	const layerTo = layerRange.to;
	(0, import_react.useEffect)(() => {
		setLayerRange((prev_0) => normalizeLayerRange(graphMode, prev_0));
	}, [graphMode]);
	const layerLabels = (0, import_react.useMemo)(() => ({
		[GraphLayers.IncomePayee]: t("Payee"),
		[GraphLayers.IncomeCategory]: t("Income category"),
		[GraphLayers.Account]: t("Account"),
		[GraphLayers.Budget]: t("Budget"),
		[GraphLayers.CategoryGroup]: t("Category group"),
		[GraphLayers.Category]: t("Category")
	}), [t]);
	const fromLayerMenuItems = (0, import_react.useMemo)(() => getLayerMenuItems(graphMode, "from", layerTo), [graphMode, layerTo]);
	const toLayerMenuItems = (0, import_react.useMemo)(() => getLayerMenuItems(graphMode, "to", layerFrom), [graphMode, layerFrom]);
	function onChangeLayer(direction, layer) {
		setLayerRange((prev_1) => {
			return normalizeLayerRange(graphMode, direction === "from" ? {
				...prev_1,
				from: layer
			} : {
				...prev_1,
				to: layer
			}, direction);
		});
	}
	function onResetLayers() {
		setLayerRange(getDefaultLayerRange(graphMode));
	}
	const { data: { grouped: groupedCategories = [] } = { grouped: [] } } = useCategories();
	const baseGraphParams = (0, import_react.useMemo)(() => {
		if (!datesInitialized) return null;
		return createBaseGraphSpreadsheet(start, end, groupedCategories, conditions, conditionsOp, graphMode, groupAccounts);
	}, [
		datesInitialized,
		start,
		end,
		groupedCategories,
		conditions,
		conditionsOp,
		graphMode,
		groupAccounts
	]);
	const defaultGetBaseGraph = async (_spreadsheet, setData) => setData(/* @__PURE__ */ new Map());
	const baseGraph = useReport$1("sankey", baseGraphParams ?? defaultGetBaseGraph);
	const baseGraphRef = (0, import_react.useRef)(baseGraph);
	(0, import_react.useEffect)(() => {
		if (baseGraph) baseGraphRef.current = baseGraph;
	}, [baseGraph]);
	const displayBaseGraph = baseGraph || baseGraphRef.current;
	const displayData = (0, import_react.useMemo)(() => {
		if (!displayBaseGraph) return null;
		return buildSankeyData(displayBaseGraph, topN, groupedCategories, categorySort, layerFrom, layerTo);
	}, [
		displayBaseGraph,
		topN,
		groupedCategories,
		categorySort,
		layerFrom,
		layerTo
	]);
	(0, import_react.useEffect)(() => {
		async function run() {
			const earliestTransaction_0 = await send("get-earliest-transaction");
			setEarliestTransaction(earliestTransaction_0 ? earliestTransaction_0.date : currentDay());
			const latestTransaction_0 = await send("get-latest-transaction");
			const latestTransactionDate = latestTransaction_0 ? latestTransaction_0.date : currentDay();
			setLatestTransaction(latestTransactionDate);
			const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, void 0, latestTransactionDate);
			setStart(initialStart);
			setEnd(initialEnd);
			setTimeFrameMode(initialMode);
			setDatesInitialized(true);
			const currentMonth_0 = currentMonth();
			let earliestMonth = earliestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(earliestTransaction_0.date))) : currentMonth_0;
			const latestTransactionMonth = latestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(latestTransaction_0.date))) : currentMonth_0;
			const latestMonth = latestTransactionMonth > currentMonth_0 ? latestTransactionMonth : currentMonth_0;
			const yearAgo = subMonths(latestMonth, 12);
			if (earliestMonth > yearAgo) earliestMonth = yearAgo;
			setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
				name: month,
				pretty: format(month, "MMMM yyyy", locale)
			})).reverse());
		}
		run();
	}, [locale, widget?.meta?.timeFrame]);
	function onChangeDates(start_0, end_0, mode) {
		setStart(start_0);
		setEnd(end_0);
		setTimeFrameMode(mode);
	}
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	async function onSaveWidget() {
		if (!widget) throw new Error("No widget that could be saved.");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				conditions,
				conditionsOp,
				mode: graphMode,
				topNcategories,
				categorySort,
				showPercentages,
				layerFrom,
				layerTo,
				timeFrame: {
					start,
					end,
					mode: timeFrameMode
				},
				groupAccounts
			}
		} }, { onSuccess: () => {
			dispatch(addNotification({ notification: {
				type: "message",
				message: t("Dashboard widget successfully saved.")
			} }));
		} });
	}
	const onSaveWidgetName = (newName) => {
		if (!widget) throw new Error("No widget that could be saved.");
		const name = newName || t("Sankey");
		updateDashboardWidgetMutation.mutate({ widget: {
			id: widget.id,
			meta: {
				...widget.meta ?? {},
				name
			}
		} });
	};
	const title = widget?.meta?.name || t("Sankey");
	const ignoredFilterFields = graphMode === "budgeted" ? [...new Set(conditions.filter((c) => c.field !== "category" && c.field !== "category_group").map((c_0) => mapField(c_0.field)))] : [];
	const ignoredFilterFieldsList = useFormatList(ignoredFilterFields, i18n.language);
	if (!datesInitialized || !displayData) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
		header: isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title }),
		padding: 0,
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Header, {
			allMonths,
			start,
			end,
			mode: timeFrameMode,
			show1Month: true,
			earliestTransaction,
			latestTransaction,
			onChangeDates,
			filters: conditions,
			onApply: onApplyFilter,
			onUpdateFilter,
			onDeleteFilter,
			conditionsOp,
			onConditionsOpChange,
			filterExclude: ["date"],
			inlineContent: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 10,
					marginLeft: 10
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphModeSelector, {
					mode: graphMode,
					onChange: setGraphMode
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 10,
					marginLeft: 10
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TopNSelector, {
					value: topNcategories,
					onChange: settopNcategories
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CategorySortSelector, {
					value: categorySort,
					onChange: setCategorySort
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 10,
					marginLeft: 10
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgLayers, { style: {
					width: 12,
					height: 12
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LayerSelector, {
					direction: "from",
					value: layerFrom,
					layerLabels,
					menuItems: fromLayerMenuItems,
					onChange: (layer_0) => onChangeLayer("from", layer_0)
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCheveronRight, { style: {
					width: 12,
					height: 12
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LayerSelector, {
					direction: "to",
					value: layerTo,
					layerLabels,
					menuItems: toLayerMenuItems,
					onChange: (layer_1) => onChangeLayer("to", layer_1)
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: "bare",
					onPress: onResetLayers,
					"aria-label": t("Reset layers"),
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgRefresh, { style: {
						width: 12,
						height: 12
					} })
				})
			] }),
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: { marginRight: 4 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OptionsButton, {
					showPercentages,
					onTogglePercentages: () => setShowPercentages((v) => !v),
					groupAccounts,
					onToggleGroupAccounts: () => setGroupAccounts((v_0) => !v_0)
				})
			}), widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "primary",
				onPress: onSaveWidget,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
			})]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				backgroundColor: theme.tableBackground,
				padding: 20,
				paddingTop: 0,
				flex: "1 0 auto",
				overflowY: "visible"
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					display: "flex",
					flexDirection: "row",
					paddingTop: 0,
					flexGrow: 1
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: { flexGrow: 1 },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							backgroundColor: theme.tableBackground,
							padding: 20,
							paddingTop: 0,
							flex: "1 0 auto",
							overflowY: "auto"
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
							style: {
								flexDirection: "column",
								flexGrow: 1,
								padding: 10,
								paddingTop: 10
							},
							children: [
								displayData && displayData.links && displayData.links.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									ref: containerRef,
									style: {
										flexDirection: "column",
										flexGrow: 1
									},
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyGraph, {
										style: { flexGrow: 1 },
										data: displayData,
										showPercentages
									})
								}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									style: {
										flexGrow: 1,
										alignItems: "center",
										justifyContent: "center",
										color: theme.pageTextSubdued
									},
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
										style: {
											fontSize: 16,
											textAlign: "center"
										},
										children: [graphMode === "budgeted" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No data available for this period. Try budgeting categories or selecting a different period." }), graphMode === "spent" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No data available for this period. Try adding transactions or selecting a different period." })]
									})
								}),
								ignoredFilterFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									style: {
										marginTop: 10,
										padding: "8px 12px",
										backgroundColor: theme.warningBackground,
										borderRadius: 4,
										color: theme.warningText
									},
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
										style: { fontSize: 13 },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
											"Filters on ",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: ignoredFilterFieldsList }),
											" ",
											"are ignored in ",
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Budgeted" }),
											" mode."
										] })
									})
								}),
								!isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
									style: { marginTop: 30 },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "What is a Sankey plot?" }) }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: "A Sankey plot visualizes the flow of quantities between multiple categories, emphasizing the distribution and proportional relationships of data streams." }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "View options:" }) }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Paragraph, { children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
												style: {
													marginTop: 0,
													paddingLeft: 20
												},
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
													style: { marginBottom: 5 },
													children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Spent:" }), " Displays actual spending by category from transactions."]
												}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
													style: { marginBottom: 5 },
													children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Budgeted:" }), " Shows how your budget is allocated across categories."]
												})]
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Disclaimer:" }),
											" A Sankey chart cannot directly represent negative numbers. In some cases, such as when funds are reallocated from categories with negative budgeting (e.g. using savings to cover overspending), the chart structure may differ from the main budget overview. As a result, some category totals and flows in this diagram may not exactly match the summary figures elsewhere in the app."
										] })
									] })
								})
							]
						})
					})
				})
			})
		})]
	});
}
//#endregion
//#region src/components/reports/graphs/SpendingGraph.tsx
var CustomTooltip = (t0) => {
	const $ = (0, import_compiler_runtime.c)(38);
	const { active, payload, balanceTypeOp, selection, compare, format } = t0;
	const { t } = useTranslation();
	if (active && payload && payload.length) {
		let t1;
		if ($[0] !== payload[0].payload || $[1] !== selection) {
			t1 = ["average", "budget"].includes(selection) ? payload[0].payload[selection] * -1 : (payload[0].payload.months[selection]?.cumulative ?? 0) * -1;
			$[0] = payload[0].payload;
			$[1] = selection;
			$[2] = t1;
		} else t1 = $[2];
		const comparison = t1;
		let t2;
		let t3;
		if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
			t2 = css({
				zIndex: 1e3,
				pointerEvents: "none",
				borderRadius: 2,
				boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
				backgroundColor: theme.menuBackground,
				color: theme.menuItemText,
				padding: 10
			});
			t3 = { marginBottom: 10 };
			$[3] = t2;
			$[4] = t3;
		} else {
			t2 = $[3];
			t3 = $[4];
		}
		let t4;
		if ($[5] !== payload[0].payload.day || $[6] !== t) {
			t4 = Number(payload[0].payload.day) >= 28 ? t("28+") : payload[0].payload.day;
			$[5] = payload[0].payload.day;
			$[6] = t;
			$[7] = t4;
		} else t4 = $[7];
		let t5;
		if ($[8] !== t4) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				style: t3,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [
					"Day:",
					" ",
					{ dayOfMonth: t4 }
				] }) })
			});
			$[8] = t4;
			$[9] = t5;
		} else t5 = $[9];
		let t6;
		if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
			t6 = { lineHeight: 1.5 };
			$[10] = t6;
		} else t6 = $[10];
		let t7;
		if ($[11] !== compare || $[12] !== format || $[13] !== payload[0].payload.months || $[14] !== t) {
			t7 = payload[0].payload.months[compare]?.cumulative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Compare:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(payload[0].payload.months[compare]?.cumulative * -1, "financial") })
			}) : null;
			$[11] = compare;
			$[12] = format;
			$[13] = payload[0].payload.months;
			$[14] = t;
			$[15] = t7;
		} else t7 = $[15];
		let t8;
		if ($[16] !== balanceTypeOp || $[17] !== comparison || $[18] !== format || $[19] !== selection || $[20] !== t) {
			t8 = ["cumulative"].includes(balanceTypeOp) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: selection === "average" ? t("Average:") : selection === "budget" ? t("Budgeted:") : t("To:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(Math.round(comparison), "financial") })
			});
			$[16] = balanceTypeOp;
			$[17] = comparison;
			$[18] = format;
			$[19] = selection;
			$[20] = t;
			$[21] = t8;
		} else t8 = $[21];
		let t9;
		if ($[22] !== compare || $[23] !== comparison || $[24] !== format || $[25] !== payload[0].payload.months || $[26] !== t) {
			t9 = payload[0].payload.months[compare]?.cumulative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
				left: t("Difference:"),
				right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(Math.round(payload[0].payload.months[compare]?.cumulative * -1 - comparison), "financial") })
			}) : null;
			$[22] = compare;
			$[23] = comparison;
			$[24] = format;
			$[25] = payload[0].payload.months;
			$[26] = t;
			$[27] = t9;
		} else t9 = $[27];
		let t10;
		if ($[28] !== t7 || $[29] !== t8 || $[30] !== t9) {
			t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				style: t6,
				children: [
					t7,
					t8,
					t9
				]
			});
			$[28] = t7;
			$[29] = t8;
			$[30] = t9;
			$[31] = t10;
		} else t10 = $[31];
		let t11;
		if ($[32] !== t10 || $[33] !== t5) {
			t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [t5, t10] });
			$[32] = t10;
			$[33] = t5;
			$[34] = t11;
		} else t11 = $[34];
		let t12;
		if ($[35] !== t11 || $[36] !== t2) {
			t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: t2,
				children: t11
			});
			$[35] = t11;
			$[36] = t2;
			$[37] = t12;
		} else t12 = $[37];
		return t12;
	}
};
function SpendingGraph({ style, data, compact, mode, compare, compareTo }) {
	const privacyMode = usePrivacyMode();
	const animationProps = useRechartsAnimation({ animationDuration: 1e3 });
	const balanceTypeOp = "cumulative";
	const format = useFormat();
	const selection = mode === "single-month" ? compareTo : mode;
	const thisMonthMax = data.intervalData.reduce((a, b) => a.months[compare]?.[balanceTypeOp] < b.months[compare]?.[balanceTypeOp] ? a : b).months[compare]?.[balanceTypeOp];
	const maxYAxis = (["average", "budget"].includes(selection) ? data.intervalData[27][selection] : data.intervalData.reduce((a_0, b_0) => a_0.months[selection]?.[balanceTypeOp] < b_0.months[selection]?.[balanceTypeOp] ? a_0 : b_0).months[selection]?.[balanceTypeOp]) > thisMonthMax;
	const dataMax = Math.max(...data.intervalData.map((i) => i.months[compare]?.cumulative));
	const dataMin = Math.min(...data.intervalData.map((i_0) => i_0.months[compare]?.cumulative));
	const tickFormatter = (tick) => {
		if (!privacyMode) return `${format(tick, "financial-no-decimals")}`;
		return "...";
	};
	const gradientOffset = () => {
		if (!dataMax || dataMax <= 0) return 0;
		if (!dataMin || dataMin >= 0) return 1;
		return dataMax / (dataMax - dataMin);
	};
	const getVal = (obj, month) => {
		if (["average", "budget"].includes(month)) return obj[month] && -1 * obj[month];
		else return obj.months[month]?.[balanceTypeOp] && -1 * obj.months[month][balanceTypeOp];
	};
	const getDate = (obj_0) => {
		return Number(obj_0.day) >= 28 ? "28+" : obj_0.day;
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
		style: {
			...style,
			...compact && { height: "auto" }
		},
		children: (width, height) => data.intervalData && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [!compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "5px" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AreaChart, {
			responsive: true,
			width,
			height,
			data: data.intervalData,
			margin: {
				top: 0,
				right: 0,
				left: computePadding(data.intervalData.map((item) => getVal(item, maxYAxis ? compare : selection)).filter((value) => value !== void 0), (value_0) => format(value_0, "financial-no-decimals")),
				bottom: 0
			},
			children: [
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartesianGrid, {
					strokeDasharray: "3 3",
					vertical: false
				}),
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XAxis, {
					dataKey: (val) => getDate(val),
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText }
				}),
				compact ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YAxis, {
					dataKey: (val_0) => getVal(val_0, maxYAxis ? compare : selection),
					domain: [0, "auto"],
					tickFormatter,
					tick: { fill: theme.pageText },
					tickLine: { stroke: theme.pageText },
					tickSize: 0
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
					content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip, {
						balanceTypeOp,
						selection,
						compare,
						format
					}),
					formatter: numberFormatterTooltip,
					isAnimationActive: false
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("defs", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("linearGradient", {
					id: `fill${balanceTypeOp}`,
					x1: "0",
					y1: "0",
					x2: "0",
					y2: "1",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: gradientOffset(),
						stopColor: theme.reportsChartFill,
						stopOpacity: .2
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("linearGradient", {
					id: `stroke${balanceTypeOp}`,
					x1: "0",
					y1: "0",
					x2: "0",
					y2: "1",
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
						offset: gradientOffset(),
						stopColor: theme.reportsChartFill,
						stopOpacity: 1
					})
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
					type: "linear",
					dot: false,
					activeDot: {
						fill: theme.reportsChartFill,
						fillOpacity: 1,
						r: 10
					},
					...animationProps,
					dataKey: (val_1) => getVal(val_1, compare),
					stroke: `url(#stroke${balanceTypeOp})`,
					strokeWidth: 3,
					fill: `url(#fill${balanceTypeOp})`,
					fillOpacity: 1
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Area, {
					type: "linear",
					dot: false,
					activeDot: false,
					...animationProps,
					dataKey: (val_2) => getVal(val_2, selection),
					stroke: theme.reportsGray,
					strokeDasharray: "10 10",
					strokeWidth: 3,
					fill: theme.reportsGray,
					fillOpacity: .2
				})
			]
		})] })
	});
}
//#endregion
//#region src/components/reports/spreadsheets/spending-spreadsheet.ts
function createSpendingSpreadsheet({ conditions = [], conditionsOp, compare, compareTo, budgetType = "envelope" }) {
	const startDate = subMonths(compare, 3) + "-01";
	const endDate = getMonthEnd(compare + "-01");
	const startDateTo = compareTo + "-01";
	const endDateTo = getMonthEnd(compareTo + "-01");
	const interval = "Daily";
	const compareInterval = dayRangeInclusive(compare + "-01", endDate);
	return async (spreadsheet, setData) => {
		const { filters } = await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) });
		const { filters: budgetFilters } = await send("make-filters-from-conditions", {
			conditions: conditions.filter((cond) => !cond.customName && cond.field === "category"),
			applySpecialCases: false
		});
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		const [assets, debts] = await Promise.all([aqlQuery(makeQuery("assets", startDate, endDate, interval, conditionsOpKey, filters)).then(({ data }) => data), aqlQuery(makeQuery("debts", startDate, endDate, interval, conditionsOpKey, filters)).then(({ data }) => data)]);
		const [assetsTo, debtsTo] = await Promise.all([aqlQuery(makeQuery("assets", startDateTo, endDateTo, interval, conditionsOpKey, filters)).then(({ data }) => data), aqlQuery(makeQuery("debts", startDateTo, endDateTo, interval, conditionsOpKey, filters)).then(({ data }) => data)]);
		const overlapAssets = endDateTo < startDate || startDateTo > endDate ? assetsTo : [];
		const overlapDebts = endDateTo < startDate || startDateTo > endDate ? debtsTo : [];
		const combineAssets = [...assets, ...overlapAssets];
		const combineDebts = [...debts, ...overlapDebts];
		const budgetMonth = parseInt(compare.replace("-", ""));
		const budgetTable = budgetType === "tracking" ? "reflect_budgets" : "zero_budgets";
		const [budgets] = await Promise.all([aqlQuery(q$1(budgetTable).filter({ $and: [{ month: { $eq: budgetMonth } }] }).filter({ [conditionsOpKey]: budgetFilters }).groupBy([{ $id: "$category" }]).select([{ category: { $id: "$category" } }, { amount: { $sum: "$amount" } }])).then(({ data }) => data)]);
		const dailyBudget = budgets && budgets.reduce((a, v) => a + v.amount, 0) / compareInterval.length;
		const intervals = dayRangeInclusive(startDate, endDate);
		if (endDateTo < startDate || startDateTo > endDate) intervals.push(...dayRangeInclusive(startDateTo, endDateTo));
		const days = [...Array(29).keys()].filter((f) => f > 0).map((n) => n.toString().padStart(2, "0"));
		let totalAssets = 0;
		let totalDebts = 0;
		let totalBudget = 0;
		const months = rangeInclusive(startDate, endDate).map((month) => {
			return {
				month,
				perMonthAssets: 0,
				perMonthDebts: 0
			};
		});
		if (endDateTo < startDate || startDateTo > endDate) months.unshift({
			month: compareTo,
			perMonthAssets: 0,
			perMonthDebts: 0
		});
		setData({
			intervalData: days.map((day) => {
				let averageSum = 0;
				let monthCount = 0;
				const dayData = months.map((month) => {
					const data = intervals.reduce((arr, intervalItem) => {
						const offsetDay = Number(intervalItem.substring(8, 10)) >= 28 ? "28" : intervalItem.substring(8, 10);
						let perIntervalAssets = 0;
						let perIntervalDebts = 0;
						if (month.month === getMonth(intervalItem) && day === offsetDay) {
							const intervalAssets = combineAssets.filter((e) => !e.categoryIncome && !e.accountOffBudget).filter((asset) => asset.date === intervalItem).reduce((a, v) => a + v.amount, 0);
							perIntervalAssets += intervalAssets;
							const intervalDebts = combineDebts.filter((e) => !e.categoryIncome && !e.accountOffBudget).filter((debt) => debt.date === intervalItem).reduce((a, v) => a + v.amount, 0);
							perIntervalDebts += intervalDebts;
							totalAssets += perIntervalAssets;
							totalDebts += perIntervalDebts;
							let cumulativeAssets = 0;
							let cumulativeDebts = 0;
							if (month.month === compare) totalBudget -= dailyBudget;
							months.map((m) => {
								if (m.month === month.month) {
									cumulativeAssets = m.perMonthAssets += perIntervalAssets;
									cumulativeDebts = m.perMonthDebts += perIntervalDebts;
								}
								return null;
							});
							if (month.month >= monthFromDate(startDate) && month.month < compare) if (day === "28") {
								if (getMonthEnd(intervalItem) === intervalItem) {
									averageSum += cumulativeAssets + cumulativeDebts;
									monthCount += 1;
								}
							} else {
								averageSum += cumulativeAssets + cumulativeDebts;
								monthCount += 1;
							}
							arr.push({
								date: intervalItem,
								totalDebts: perIntervalDebts,
								totalAssets: perIntervalAssets,
								totalTotals: perIntervalDebts + perIntervalAssets,
								cumulative: intervalItem <= currentDay() ? cumulativeDebts + cumulativeAssets : null
							});
						}
						return arr;
					}, []);
					const maxCumulative = data.reduce((a, b) => b.cumulative === null ? a : b).cumulative;
					const totalDaily = data.reduce((a, v) => a + v.totalTotals, 0);
					return {
						date: data[0].date,
						cumulative: maxCumulative,
						daily: totalDaily,
						month: month.month
					};
				});
				return {
					months: (0, import_keyBy.default)(dayData, "month"),
					day,
					average: Math.round(averageSum / monthCount),
					compare: dayData.filter((c) => c.month === compare)[0].cumulative,
					compareTo: dayData.filter((c) => c.month === compareTo)[0].cumulative,
					budget: totalBudget
				};
			}),
			startDate,
			endDate,
			totalDebts,
			totalAssets,
			totalTotals: totalAssets + totalDebts
		});
	};
}
//#endregion
//#region src/components/reports/reports/Spending.tsx
function Spending() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "spending-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpendingInternal, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function SpendingInternal(t0) {
	const $ = (0, import_compiler_runtime.c)(150);
	const { widget } = t0;
	const locale = useLocale();
	const dispatch = useDispatch();
	const { t } = useTranslation();
	const format$4 = useFormat();
	const [budgetTypePref] = useSyncedPref("budgetType");
	const budgetType = budgetTypePref === "tracking" ? "tracking" : "envelope";
	const { conditions, conditionsOp, onApply: onApplyFilter, onDelete: onDeleteFilter, onUpdate: onUpdateFilter, onConditionsOpChange } = useRuleConditionFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = [];
		$[0] = t1;
	} else t1 = $[0];
	const [allIntervals, setAllIntervals] = (0, import_react.useState)(t1);
	const initialReportMode = widget?.meta?.mode ?? "single-month";
	let t2;
	if ($[1] !== widget?.meta) {
		t2 = widget?.meta ?? {};
		$[1] = widget?.meta;
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] !== t2) {
		t3 = calculateSpendingReportTimeRange(t2);
		$[3] = t2;
		$[4] = t3;
	} else t3 = $[4];
	const [initialCompare, initialCompareTo] = t3;
	const [compare, setCompare] = (0, import_react.useState)(initialCompare);
	const [compareTo, setCompareTo] = (0, import_react.useState)(initialCompareTo);
	const [isLive, setIsLive] = (0, import_react.useState)(widget?.meta?.isLive ?? true);
	const [reportMode, setReportMode] = (0, import_react.useState)(initialReportMode);
	let t4;
	let t5;
	if ($[5] !== locale) {
		t4 = () => {
			(async function run() {
				const earliestTrans = await send("get-earliest-transaction");
				const latestTrans = await send("get-latest-transaction");
				const currentMonth$3 = currentMonth();
				let earliestMonth = earliestTrans ? monthFromDate(parseISO(fromDateRepr(earliestTrans.date))) : currentMonth$3;
				const latestTransactionMonth = latestTrans ? monthFromDate(parseISO(fromDateRepr(latestTrans.date))) : currentMonth$3;
				const latestMonth = latestTransactionMonth > currentMonth$3 ? latestTransactionMonth : currentMonth$3;
				const yearAgo = subMonths(latestMonth, 12);
				if (earliestMonth > yearAgo) earliestMonth = yearAgo;
				setAllIntervals(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
					name: month,
					pretty: format(month, "MMMM yyyy", locale)
				})).reverse());
			})();
		};
		t5 = [locale];
		$[5] = locale;
		$[6] = t4;
		$[7] = t5;
	} else {
		t4 = $[6];
		t5 = $[7];
	}
	(0, import_react.useEffect)(t4, t5);
	let t6;
	if ($[8] !== budgetType || $[9] !== compare || $[10] !== compareTo || $[11] !== conditions || $[12] !== conditionsOp) {
		t6 = createSpendingSpreadsheet({
			conditions,
			conditionsOp,
			compare,
			compareTo,
			budgetType
		});
		$[8] = budgetType;
		$[9] = compare;
		$[10] = compareTo;
		$[11] = conditions;
		$[12] = conditionsOp;
		$[13] = t6;
	} else t6 = $[13];
	const data = useReport$1("default", t6);
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	let t7;
	if ($[14] !== compare || $[15] !== compareTo || $[16] !== conditions || $[17] !== conditionsOp || $[18] !== dispatch || $[19] !== isLive || $[20] !== reportMode || $[21] !== t || $[22] !== updateDashboardWidgetMutation || $[23] !== widget) {
		t7 = async function onSaveWidget() {
			if (!widget) throw new Error("No widget that could be saved.");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					conditions,
					conditionsOp,
					compare,
					compareTo,
					isLive,
					mode: reportMode
				}
			} }, { onSuccess: () => {
				dispatch(addNotification({ notification: {
					type: "message",
					message: t("Dashboard widget successfully saved.")
				} }));
			} });
		};
		$[14] = compare;
		$[15] = compareTo;
		$[16] = conditions;
		$[17] = conditionsOp;
		$[18] = dispatch;
		$[19] = isLive;
		$[20] = reportMode;
		$[21] = t;
		$[22] = updateDashboardWidgetMutation;
		$[23] = widget;
		$[24] = t7;
	} else t7 = $[24];
	const onSaveWidget = t7;
	if (!data) return null;
	let t8;
	if ($[25] !== compare || $[26] !== data.intervalData[27].months) {
		t8 = data.intervalData[27].months[subMonths(compare, 3)] && Math.abs(data.intervalData[27].months[subMonths(compare, 3)].cumulative) > 0;
		$[25] = compare;
		$[26] = data.intervalData[27].months;
		$[27] = t8;
	} else t8 = $[27];
	const showAverage = t8;
	let t9;
	if ($[28] !== compare) {
		t9 = compare !== currentMonth() ? 27 : getDay$1(currentDay()) - 1 >= 28 ? 27 : getDay$1(currentDay()) - 1;
		$[28] = compare;
		$[29] = t9;
	} else t9 = $[29];
	const todayDay = t9;
	let t10;
	if ($[30] !== compareTo || $[31] !== data.intervalData[27].compareTo) {
		t10 = compareTo === currentMonth() || Math.abs(data.intervalData[27].compareTo) > 0;
		$[30] = compareTo;
		$[31] = data.intervalData[27].compareTo;
		$[32] = t10;
	} else t10 = $[32];
	const showCompareTo = t10;
	let t11;
	if ($[33] !== compare || $[34] !== data.intervalData[27].compare) {
		t11 = compare === currentMonth() || Math.abs(data.intervalData[27].compare) > 0;
		$[33] = compare;
		$[34] = data.intervalData[27].compare;
		$[35] = t11;
	} else t11 = $[35];
	const showCompare = t11;
	let t12;
	if ($[36] !== t || $[37] !== widget?.meta?.name) {
		t12 = widget?.meta?.name || t("Monthly Spending");
		$[36] = t;
		$[37] = widget?.meta?.name;
		$[38] = t12;
	} else t12 = $[38];
	const title = t12;
	let t13;
	if ($[39] !== t || $[40] !== updateDashboardWidgetMutation || $[41] !== widget) {
		t13 = async (newName) => {
			if (!widget) throw new Error("No widget that could be saved.");
			const name = newName || t("Monthly Spending");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					name
				}
			} });
		};
		$[39] = t;
		$[40] = updateDashboardWidgetMutation;
		$[41] = widget;
		$[42] = t13;
	} else t13 = $[42];
	const onSaveWidgetName = t13;
	let t14;
	if ($[43] !== isNarrowWidth || $[44] !== navigate || $[45] !== onSaveWidgetName || $[46] !== title || $[47] !== widget) {
		t14 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title });
		$[43] = isNarrowWidth;
		$[44] = navigate;
		$[45] = onSaveWidgetName;
		$[46] = title;
		$[47] = widget;
		$[48] = t14;
	} else t14 = $[48];
	let t15;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = {
			paddingLeft: 20,
			paddingRight: 20,
			paddingTop: 15,
			paddingBottom: 20,
			flexShrink: 0
		};
		$[49] = t15;
	} else t15 = $[49];
	let t16;
	if ($[50] !== allIntervals || $[51] !== compare || $[52] !== compareTo || $[53] !== isLive || $[54] !== isNarrowWidth || $[55] !== onApplyFilter || $[56] !== onSaveWidget || $[57] !== reportMode || $[58] !== t || $[59] !== widget) {
		t16 = !isNarrowWidth && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
			gap: 0,
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
					variant: isLive ? "primary" : "normal",
					onPress: () => setIsLive(_temp$4),
					children: isLive ? t("Live") : t("Static")
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 10,
					marginLeft: 10
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
					gap: 5,
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Compare" }) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: compare,
							onChange: setCompare,
							options: allIntervals.map(_temp2$2),
							style: { width: 150 },
							popoverStyle: { width: 150 }
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "to" }) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, {
							value: reportMode === "single-month" ? compareTo : "label",
							onChange: setCompareTo,
							options: reportMode === "single-month" ? allIntervals.map(_temp3$2) : [["label", reportMode === "budget" ? t("Budgeted") : t("Average spent")]],
							disabled: reportMode !== "single-month",
							style: { width: 150 },
							popoverStyle: { width: 150 }
						})
					]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 15,
					marginLeft: 15
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SpaceBetween, {
					gap: 5,
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: reportMode === "single-month",
							style: { backgroundColor: "inherit" },
							onSelect: () => {
								setReportMode("single-month");
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Single month" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: reportMode === "budget",
							onSelect: () => {
								setReportMode("budget");
							},
							style: { backgroundColor: "inherit" },
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModeButton, {
							selected: reportMode === "average",
							onSelect: () => {
								setReportMode("average");
							},
							style: { backgroundColor: "inherit" },
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Average" })
						})
					]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
					width: 1,
					height: 28,
					backgroundColor: theme.pillBorderDark,
					marginRight: 10,
					marginLeft: 10
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						alignItems: "center",
						flexDirection: "row",
						flex: 1
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterButton, {
							onApply: onApplyFilter,
							compact: isNarrowWidth,
							hover: false,
							exclude: ["date"]
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } }),
						widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
							placement: "top end",
							content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save compare and filter options" }) }),
							style: {
								...styles.tooltip,
								lineHeight: 1.5,
								padding: "6px 10px",
								marginLeft: 10
							},
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								variant: "primary",
								style: { marginLeft: 10 },
								onPress: onSaveWidget,
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save" })
							})
						})
					]
				})
			]
		});
		$[50] = allIntervals;
		$[51] = compare;
		$[52] = compareTo;
		$[53] = isLive;
		$[54] = isNarrowWidth;
		$[55] = onApplyFilter;
		$[56] = onSaveWidget;
		$[57] = reportMode;
		$[58] = t;
		$[59] = widget;
		$[60] = t16;
	} else t16 = $[60];
	let t17;
	if ($[61] !== conditions || $[62] !== conditionsOp || $[63] !== onConditionsOpChange || $[64] !== onDeleteFilter || $[65] !== onUpdateFilter) {
		t17 = conditions && conditions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				marginTop: 5,
				flexShrink: 0,
				flexDirection: "row",
				spacing: 2
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppliedFilters, {
				conditions,
				onUpdate: onUpdateFilter,
				onDelete: onDeleteFilter,
				conditionsOp,
				onConditionsOpChange
			})
		});
		$[61] = conditions;
		$[62] = conditionsOp;
		$[63] = onConditionsOpChange;
		$[64] = onDeleteFilter;
		$[65] = onUpdateFilter;
		$[66] = t17;
	} else t17 = $[66];
	let t18;
	if ($[67] !== t16 || $[68] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t15,
			children: [t16, t17]
		});
		$[67] = t16;
		$[68] = t17;
		$[69] = t18;
	} else t18 = $[69];
	let t19;
	if ($[70] === Symbol.for("react.memo_cache_sentinel")) {
		t19 = {
			display: "flex",
			flexDirection: "row",
			paddingTop: 0,
			flexGrow: 1
		};
		$[70] = t19;
	} else t19 = $[70];
	let t20;
	if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = { flexGrow: 1 };
		$[71] = t20;
	} else t20 = $[71];
	let t21;
	if ($[72] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			backgroundColor: theme.tableBackground,
			padding: 20,
			paddingTop: 0,
			flex: "1 0 auto",
			overflowY: "auto"
		};
		$[72] = t21;
	} else t21 = $[72];
	let t22;
	if ($[73] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = {
			flexDirection: "column",
			flexGrow: 1,
			padding: 10,
			paddingTop: 10
		};
		$[73] = t22;
	} else t22 = $[73];
	let t23;
	if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = {
			alignItems: "center",
			flexDirection: "row"
		};
		$[74] = t23;
	} else t23 = $[74];
	let t24;
	if ($[75] !== compare || $[76] !== locale) {
		t24 = format(compare, "MMM yyyy", locale);
		$[75] = compare;
		$[76] = locale;
		$[77] = t24;
	} else t24 = $[77];
	let t25;
	if ($[78] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = {
			padding: 0,
			paddingBottom: 10
		};
		$[78] = t25;
	} else t25 = $[78];
	let t26;
	if ($[79] !== t24) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendItem, {
			color: theme.reportsGreen,
			label: t24,
			style: t25
		});
		$[79] = t24;
		$[80] = t26;
	} else t26 = $[80];
	let t27;
	if ($[81] !== compareTo || $[82] !== locale || $[83] !== reportMode || $[84] !== t) {
		t27 = reportMode === "single-month" ? format(compareTo, "MMM yyyy", locale) : reportMode === "budget" ? t("Budgeted") : t("Average");
		$[81] = compareTo;
		$[82] = locale;
		$[83] = reportMode;
		$[84] = t;
		$[85] = t27;
	} else t27 = $[85];
	let t28;
	if ($[86] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = {
			padding: 0,
			paddingBottom: 10
		};
		$[86] = t28;
	} else t28 = $[86];
	let t29;
	if ($[87] !== t27) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendItem, {
			color: theme.reportsGray,
			label: t27,
			style: t28
		});
		$[87] = t27;
		$[88] = t29;
	} else t29 = $[88];
	let t30;
	if ($[89] !== t26 || $[90] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t26, t29] });
		$[89] = t26;
		$[90] = t29;
		$[91] = t30;
	} else t30 = $[91];
	let t31;
	if ($[92] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: { flex: 1 } });
		$[92] = t31;
	} else t31 = $[92];
	let t32;
	if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = {
			alignItems: "flex-end",
			color: theme.pageText
		};
		$[93] = t32;
	} else t32 = $[93];
	let t33;
	if ($[94] !== compare || $[95] !== data.intervalData || $[96] !== format$4 || $[97] !== locale || $[98] !== showCompare || $[99] !== t || $[100] !== todayDay) {
		t33 = showCompare && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			style: {
				marginBottom: 5,
				minWidth: 210
			},
			left: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Block, { children: [compare === currentMonth() ? t("Spent {{monthYearFormatted}} MTD", { monthYearFormatted: format(compare, "MMM yyyy", locale) }) : t("Spent {{monthYearFormatted}}", { monthYearFormatted: format(compare, "MMM yyyy", locale) }), ":"] }),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { fontWeight: 600 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$4(Math.abs(data.intervalData[todayDay].compare), "financial") })
			})
		});
		$[94] = compare;
		$[95] = data.intervalData;
		$[96] = format$4;
		$[97] = locale;
		$[98] = showCompare;
		$[99] = t;
		$[100] = todayDay;
		$[101] = t33;
	} else t33 = $[101];
	let t34;
	if ($[102] !== compareTo || $[103] !== data.intervalData || $[104] !== format$4 || $[105] !== locale || $[106] !== reportMode || $[107] !== showCompareTo || $[108] !== t || $[109] !== todayDay) {
		t34 = reportMode === "single-month" && showCompareTo && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			style: {
				marginBottom: 5,
				minWidth: 210
			},
			left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: compareTo === currentMonth() ? t("Spent {{monthYearFormatted}} MTD:", { monthYearFormatted: format(compareTo, "MMM yyyy", locale) }) : t("Spent {{monthYearFormatted}}:", { monthYearFormatted: format(compareTo, "MMM yyyy", locale) }) }),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { fontWeight: 600 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$4(Math.abs(data.intervalData[todayDay].compareTo), "financial") })
			})
		});
		$[102] = compareTo;
		$[103] = data.intervalData;
		$[104] = format$4;
		$[105] = locale;
		$[106] = reportMode;
		$[107] = showCompareTo;
		$[108] = t;
		$[109] = todayDay;
		$[110] = t34;
	} else t34 = $[110];
	let t35;
	if ($[111] !== t33 || $[112] !== t34) {
		t35 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [t33, t34] });
		$[111] = t33;
		$[112] = t34;
		$[113] = t35;
	} else t35 = $[113];
	let t36;
	if ($[114] !== compare || $[115] !== data.intervalData || $[116] !== format$4 || $[117] !== todayDay) {
		t36 = Math.abs(data.intervalData[todayDay].budget) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			style: {
				marginBottom: 5,
				minWidth: 210
			},
			left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: compare === currentMonth() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted MTD" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Budgeted" }) }),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { fontWeight: 600 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$4(Math.round(Math.abs(data.intervalData[todayDay].budget)), "financial") })
			})
		});
		$[114] = compare;
		$[115] = data.intervalData;
		$[116] = format$4;
		$[117] = todayDay;
		$[118] = t36;
	} else t36 = $[118];
	let t37;
	if ($[119] !== compare || $[120] !== data.intervalData || $[121] !== format$4 || $[122] !== locale || $[123] !== showAverage || $[124] !== t || $[125] !== todayDay) {
		t37 = showAverage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignedText, {
			style: {
				marginBottom: 5,
				minWidth: 210
			},
			left: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, { children: compare === currentMonth() ? t("Spent Average {{monthYearFormatted}} MTD:", { monthYearFormatted: format(compare, "MMM yyyy", locale) }) : t("Spent Average {{monthYearFormatted}}:", { monthYearFormatted: format(compare, "MMM yyyy", locale) }) }),
			right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: { fontWeight: 600 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: format$4(Math.abs(data.intervalData[todayDay].average), "financial") })
			})
		});
		$[119] = compare;
		$[120] = data.intervalData;
		$[121] = format$4;
		$[122] = locale;
		$[123] = showAverage;
		$[124] = t;
		$[125] = todayDay;
		$[126] = t37;
	} else t37 = $[126];
	let t38;
	if ($[127] !== t35 || $[128] !== t36 || $[129] !== t37) {
		t38 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t32,
			children: [
				t35,
				t36,
				t37
			]
		});
		$[127] = t35;
		$[128] = t36;
		$[129] = t37;
		$[130] = t38;
	} else t38 = $[130];
	let t39;
	if ($[131] !== t30 || $[132] !== t38) {
		t39 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t23,
			children: [
				t30,
				t31,
				t38
			]
		});
		$[131] = t30;
		$[132] = t38;
		$[133] = t39;
	} else t39 = $[133];
	let t40;
	if ($[134] !== compare || $[135] !== compareTo || $[136] !== data || $[137] !== reportMode || $[138] !== t) {
		t40 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpendingGraph, {
			style: { flexGrow: 1 },
			compact: false,
			data,
			mode: reportMode,
			compare,
			compareTo
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t("Loading report...") });
		$[134] = compare;
		$[135] = compareTo;
		$[136] = data;
		$[137] = reportMode;
		$[138] = t;
		$[139] = t40;
	} else t40 = $[139];
	let t41;
	if ($[140] !== showAverage) {
		t41 = showAverage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { marginTop: 30 },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "How are \"Average\" and \"Spent Average MTD\" calculated?" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Paragraph, { children: "They are both the average cumulative spending by day for the three months before the selected \"compare\" month." })] })
		});
		$[140] = showAverage;
		$[141] = t41;
	} else t41 = $[141];
	let t42;
	if ($[142] !== t39 || $[143] !== t40 || $[144] !== t41) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t19,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: t20,
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: t21,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
						style: t22,
						children: [
							t39,
							t40,
							t41
						]
					})
				})
			})
		});
		$[142] = t39;
		$[143] = t40;
		$[144] = t41;
		$[145] = t42;
	} else t42 = $[145];
	let t43;
	if ($[146] !== t14 || $[147] !== t18 || $[148] !== t42) {
		t43 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
			header: t14,
			padding: 0,
			children: [t18, t42]
		});
		$[146] = t14;
		$[147] = t18;
		$[148] = t42;
		$[149] = t43;
	} else t43 = $[149];
	return t43;
}
function _temp3$2(t0) {
	const { name: name_1, pretty: pretty_0 } = t0;
	return [name_1, pretty_0];
}
function _temp2$2(t0) {
	const { name: name_0, pretty } = t0;
	return [name_0, pretty];
}
function _temp$4(state) {
	return !state;
}
//#endregion
//#region src/components/reports/spreadsheets/summary-spreadsheet.ts
function summarySpreadsheet(start, end, conditions = [], conditionsOp = "and", summaryContent, locale) {
	return async (spreadsheet, setData) => {
		let filters = [];
		try {
			filters = (await send("make-filters-from-conditions", { conditions: conditions.filter((cond) => !cond.customName) })).filters;
		} catch (error) {
			console.error("Error fetching filters:", error);
		}
		const conditionsOpKey = conditionsOp === "or" ? "$or" : "$and";
		let startDay;
		let endDay;
		try {
			startDay = parse(firstDayOfMonth(start), "yyyy-MM-dd", /* @__PURE__ */ new Date());
			endDay = parse(getMonth(end) === getMonth(currentDay()) ? currentDay() : lastDayOfMonth(end), "yyyy-MM-dd", /* @__PURE__ */ new Date());
		} catch (error) {
			console.error("Error parsing dates:", error);
			throw new Error("Invalid date format provided");
		}
		if (!isValid(startDay) || !isValid(endDay)) throw new Error("Invalid date values provided");
		if (isAfter$1(startDay, endDay)) throw new Error("Start date must be before or equal to end date.");
		const getOneDatePerMonth = (start, end) => {
			const months = [];
			let currentDate = startOfMonth(start);
			while (!isSameMonth(currentDate, end)) {
				months.push(currentDate);
				currentDate = addMonths$1(currentDate, 1);
			}
			months.push(end);
			return months;
		};
		const makeRootQuery = () => q$1("transactions").filter({ $and: [{ date: { $gte: format$1(startDay, "yyyy-MM-dd") } }, { date: { $lte: format$1(endDay, "yyyy-MM-dd") } }] }).filter({ [conditionsOpKey]: filters }).select([
			"date",
			{ amount: { $sum: "$amount" } },
			{ count: { $count: "*" } }
		]);
		let query = makeRootQuery();
		if (summaryContent.type === "avgPerMonth" || summaryContent.type === "avgPerYear") query = query.groupBy(["date"]);
		let data;
		try {
			data = await aqlQuery(query);
		} catch (error) {
			console.error("Error executing query:", error);
			return;
		}
		const dateRanges = {
			fromRange: format$1(startDay, "MMM yy", { locale }),
			toRange: format$1(endDay, "MMM yy", { locale })
		};
		switch (summaryContent.type) {
			case "sum":
				setData({
					...dateRanges,
					total: data.data[0]?.amount ?? 0,
					dividend: data.data[0]?.amount ?? 0,
					divisor: 0
				});
				break;
			case "avgPerTransact":
				setData({
					...dateRanges,
					total: data.data[0]?.count ?? 0 ? (data.data[0]?.amount ?? 0) / data.data[0].count : 0,
					dividend: data.data[0]?.amount ?? 0,
					divisor: data.data[0].count
				});
				break;
			case "avgPerMonth": {
				const months = getOneDatePerMonth(startDay, endDay);
				setData({
					...dateRanges,
					...calculatePerMonth(data.data, months)
				});
				break;
			}
			case "avgPerYear":
				setData({
					...dateRanges,
					...calculatePerYear(data.data, startDay, endDay)
				});
				break;
			case "percentage":
				setData({
					...dateRanges,
					...await calculatePercentage(data.data, summaryContent, startDay, endDay)
				});
				break;
			default: throw new Error(`Unsupported summary type`);
		}
	};
}
function calculatePerMonth(data, months) {
	if (!data.length || !months.length) return {
		total: 0,
		dividend: 0,
		divisor: 0
	};
	const monthlyData = data.reduce((acc, day) => {
		const monthKey = format$1(parse(day.date, "yyyy-MM-dd", /* @__PURE__ */ new Date()), "yyyy-MM");
		acc[monthKey] = (acc[monthKey] || 0) + day.amount;
		return acc;
	}, {});
	const monthsSum = months.map((m) => ({ amount: monthlyData[format$1(m, "yyyy-MM")] || 0 }));
	const lastMonth = months.at(-1);
	const dayOfMonth = lastMonth.getDate();
	const daysInMonth = getDay$1(lastDayOfMonth(lastMonth));
	const numMonths = months.length - 1 + dayOfMonth / daysInMonth;
	const totalAmount = monthsSum.reduce((sum, month) => sum + month.amount, 0);
	return {
		total: totalAmount / numMonths,
		dividend: totalAmount,
		divisor: numMonths
	};
}
function calculatePerYear(data, startDate, endDate) {
	if (!data.length) return {
		total: 0,
		dividend: 0,
		divisor: 0
	};
	const totalAmount = data.reduce((sum, day) => sum + day.amount, 0);
	const numYears = (differenceInDays(endDate, startDate) + 1) / 365.25;
	return {
		total: totalAmount / numYears,
		dividend: totalAmount,
		divisor: numYears
	};
}
async function calculatePercentage(data, summaryContent, startDay, endDay) {
	if (summaryContent.type !== "percentage") return {
		total: 0,
		dividend: 0,
		divisor: 0
	};
	const conditionsOpKey = summaryContent.divisorConditionsOp === "or" ? "$or" : "$and";
	let filters = [];
	try {
		filters = (await send("make-filters-from-conditions", { conditions: summaryContent?.divisorConditions?.filter((cond) => !cond.customName) })).filters;
	} catch (error) {
		console.error("Error creating filters:", error);
		return {
			total: 0,
			dividend: 0,
			divisor: 0
		};
	}
	const makeDivisorQuery = () => q$1("transactions").filter({ [conditionsOpKey]: filters }).select([{ amount: { $sum: "$amount" } }]);
	let query = makeDivisorQuery();
	if (!(summaryContent.divisorAllTimeDateRange ?? false)) query = query.filter({ $and: [{ date: { $gte: format$1(startDay, "yyyy-MM-dd") } }, { date: { $lte: format$1(endDay, "yyyy-MM-dd") } }] });
	let divisorData;
	try {
		divisorData = await aqlQuery(query);
	} catch (error) {
		console.error("Error executing divisor query:", error);
		return {
			total: 0,
			dividend: 0,
			divisor: 0
		};
	}
	const divisorValue = divisorData?.data?.[0]?.amount ?? 0;
	const dividend = data.reduce((prev, ac) => prev + (ac?.amount ?? 0), 0);
	return {
		total: Math.round((dividend ?? 0) / (divisorValue ?? 1) * 1e4) / 100,
		divisor: divisorValue ?? 0,
		dividend: dividend ?? 0
	};
}
//#endregion
//#region src/components/reports/reports/Summary.tsx
function Summary() {
	const $ = (0, import_compiler_runtime.c)(5);
	const params = useParams();
	let t0;
	if ($[0] !== params.id) {
		t0 = {
			id: params.id,
			type: "summary-card"
		};
		$[0] = params.id;
		$[1] = t0;
	} else t0 = $[1];
	const { data: widget, isPending } = useDashboardWidget(t0);
	if (isPending) {
		let t1;
		if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
			$[2] = t1;
		} else t1 = $[2];
		return t1;
	}
	let t1;
	if ($[3] !== widget) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SummaryInner, { widget });
		$[3] = widget;
		$[4] = t1;
	} else t1 = $[4];
	return t1;
}
function SummaryInner(t0) {
	const $ = (0, import_compiler_runtime.c)(148);
	const { widget } = t0;
	const locale = useLocale();
	const { t } = useTranslation();
	const format$3 = useFormat();
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = dayFromDate(currentMonth());
		$[0] = t1;
	} else t1 = $[0];
	const [start, setStart] = (0, import_react.useState)(t1);
	let t2;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = currentDay();
		$[1] = t2;
	} else t2 = $[1];
	const [end, setEnd] = (0, import_react.useState)(t2);
	const [mode, setMode] = (0, import_react.useState)("full");
	let t3;
	if ($[2] !== widget?.meta?.conditions) {
		t3 = widget?.meta?.conditions ?? [];
		$[2] = widget?.meta?.conditions;
		$[3] = t3;
	} else t3 = $[3];
	const dividendFilters = useRuleConditionFilters(t3, widget?.meta?.conditionsOp ?? "and");
	let t4;
	if ($[4] !== widget) {
		t4 = widget?.meta?.content ? (() => {
			try {
				return JSON.parse(widget.meta.content);
			} catch (t5) {
				console.error("Failed to parse widget meta content:", t5);
				return {
					type: "sum",
					divisorAllTimeDateRange: false,
					divisorConditions: [],
					divisorConditionsOp: "and"
				};
			}
		})() : {
			type: "sum",
			divisorAllTimeDateRange: false,
			divisorConditions: [],
			divisorConditionsOp: "and"
		};
		$[4] = widget;
		$[5] = t4;
	} else t4 = $[5];
	const [content, setContent] = (0, import_react.useState)(t4);
	let t5;
	if ($[6] !== content.divisorConditions || $[7] !== content.type) {
		t5 = content.type === "percentage" ? content?.divisorConditions ?? [] : [];
		$[6] = content.divisorConditions;
		$[7] = content.type;
		$[8] = t5;
	} else t5 = $[8];
	const divisorFilters = useRuleConditionFilters(t5, content.type === "percentage" ? content?.divisorConditionsOp ?? "and" : "and");
	let t6;
	if ($[9] !== content || $[10] !== dividendFilters.conditions || $[11] !== dividendFilters.conditionsOp || $[12] !== end || $[13] !== locale || $[14] !== start) {
		t6 = summarySpreadsheet(start, end, dividendFilters.conditions, dividendFilters.conditionsOp, content, locale);
		$[9] = content;
		$[10] = dividendFilters.conditions;
		$[11] = dividendFilters.conditionsOp;
		$[12] = end;
		$[13] = locale;
		$[14] = start;
		$[15] = t6;
	} else t6 = $[15];
	const data = useReport$1("summary", t6);
	let t7;
	let t8;
	if ($[16] !== divisorFilters.conditions || $[17] !== divisorFilters.conditionsOp) {
		t7 = () => {
			setContent((prev) => ({
				...prev,
				divisorConditions: divisorFilters.conditions,
				divisorConditionsOp: divisorFilters.conditionsOp
			}));
		};
		t8 = [divisorFilters.conditions, divisorFilters.conditionsOp];
		$[16] = divisorFilters.conditions;
		$[17] = divisorFilters.conditionsOp;
		$[18] = t7;
		$[19] = t8;
	} else {
		t7 = $[18];
		t8 = $[19];
	}
	(0, import_react.useEffect)(t7, t8);
	let t9;
	if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = [];
		$[20] = t9;
	} else t9 = $[20];
	const [allMonths, setAllMonths] = (0, import_react.useState)(t9);
	const [earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	let t10;
	let t11;
	if ($[21] !== locale) {
		t10 = () => {
			(async function run() {
				const earliestTransaction_0 = await send("get-earliest-transaction");
				setEarliestTransaction(earliestTransaction_0 ? earliestTransaction_0.date : currentDay());
				const latestTransaction_0 = await send("get-latest-transaction");
				setLatestTransaction(latestTransaction_0 ? latestTransaction_0.date : currentDay());
				const currentMonth$2 = currentMonth();
				let earliestMonth = earliestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(earliestTransaction_0.date))) : currentMonth$2;
				const latestTransactionMonth = latestTransaction_0 ? monthFromDate(parseISO(fromDateRepr(latestTransaction_0.date))) : currentMonth$2;
				const latestMonth = latestTransactionMonth > currentMonth$2 ? latestTransactionMonth : currentMonth$2;
				const yearAgo = subMonths(latestMonth, 12);
				if (earliestMonth > yearAgo) earliestMonth = yearAgo;
				setAllMonths(rangeInclusive(earliestMonth, latestMonth).map((month) => ({
					name: month,
					pretty: format(month, "MMMM yyyy", locale)
				})).reverse());
			})();
		};
		t11 = [locale];
		$[21] = locale;
		$[22] = t10;
		$[23] = t11;
	} else {
		t10 = $[22];
		t11 = $[23];
	}
	(0, import_react.useEffect)(t10, t11);
	let t12;
	if ($[24] !== latestTransaction || $[25] !== widget?.meta?.timeFrame) {
		t12 = () => {
			if (latestTransaction) {
				const [initialStart, initialEnd, initialMode] = calculateTimeRange(widget?.meta?.timeFrame, {
					start: dayFromDate(currentMonth()),
					end: currentDay(),
					mode: "full"
				}, latestTransaction);
				setStart(initialStart);
				setEnd(initialEnd);
				setMode(initialMode);
			}
		};
		$[24] = latestTransaction;
		$[25] = widget?.meta?.timeFrame;
		$[26] = t12;
	} else t12 = $[26];
	const t13 = widget?.meta?.timeFrame;
	let t14;
	if ($[27] !== latestTransaction || $[28] !== t13) {
		t14 = [latestTransaction, t13];
		$[27] = latestTransaction;
		$[28] = t13;
		$[29] = t14;
	} else t14 = $[29];
	(0, import_react.useEffect)(t12, t14);
	const dispatch = useDispatch();
	const navigate = useNavigate();
	const { isNarrowWidth } = useResponsive();
	let t15;
	if ($[30] !== t || $[31] !== widget?.meta?.name) {
		t15 = widget?.meta?.name || t("Summary");
		$[30] = t;
		$[31] = widget?.meta?.name;
		$[32] = t15;
	} else t15 = $[32];
	const title = t15;
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	let t16;
	if ($[33] !== content || $[34] !== dispatch || $[35] !== t || $[36] !== updateDashboardWidgetMutation || $[37] !== widget) {
		t16 = async (newName) => {
			if (!widget) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Cannot save: No widget available.")
				} }));
				return;
			}
			const name = newName || t("Summary");
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					name,
					content: JSON.stringify(content)
				}
			} });
		};
		$[33] = content;
		$[34] = dispatch;
		$[35] = t;
		$[36] = updateDashboardWidgetMutation;
		$[37] = widget;
		$[38] = t16;
	} else t16 = $[38];
	const onSaveWidgetName = t16;
	let t17;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = function onChangeDates(start_0, end_0, mode_0) {
			setStart(start_0);
			setEnd(end_0);
			setMode(mode_0);
		};
		$[39] = t17;
	} else t17 = $[39];
	const onChangeDates = t17;
	let t18;
	if ($[40] !== content || $[41] !== dispatch || $[42] !== dividendFilters.conditions || $[43] !== dividendFilters.conditionsOp || $[44] !== end || $[45] !== mode || $[46] !== start || $[47] !== t || $[48] !== updateDashboardWidgetMutation || $[49] !== widget) {
		t18 = async function onSaveWidget() {
			if (!widget) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Cannot save: No widget available.")
				} }));
				return;
			}
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget.id,
				meta: {
					...widget.meta ?? {},
					conditions: dividendFilters.conditions,
					conditionsOp: dividendFilters.conditionsOp,
					timeFrame: {
						start,
						end,
						mode
					},
					content: JSON.stringify(content)
				}
			} }, { onSuccess: () => {
				dispatch(addNotification({ notification: {
					type: "message",
					message: t("Dashboard widget successfully saved.")
				} }));
			} });
		};
		$[40] = content;
		$[41] = dispatch;
		$[42] = dividendFilters.conditions;
		$[43] = dividendFilters.conditionsOp;
		$[44] = end;
		$[45] = mode;
		$[46] = start;
		$[47] = t;
		$[48] = updateDashboardWidgetMutation;
		$[49] = widget;
		$[50] = t18;
	} else t18 = $[50];
	const onSaveWidget = t18;
	let t19;
	if ($[51] !== format$3) {
		t19 = (contentType, value) => {
			if (contentType === "avgPerMonth") return format$3(value, "number");
			else if (contentType === "avgPerYear") return format$3(value, "number");
			else if (contentType === "avgPerTransact") return format$3(value, "number");
			return format$3(Math.round(value), "financial");
		};
		$[51] = format$3;
		$[52] = t19;
	} else t19 = $[52];
	const getDivisorFormatted = t19;
	let t20;
	if ($[53] !== isNarrowWidth || $[54] !== navigate || $[55] !== onSaveWidgetName || $[56] !== title || $[57] !== widget) {
		t20 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, {
			title,
			leftContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileBackButton, { onPress: () => navigate("/reports") })
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: widget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditablePageHeaderTitle, {
			title,
			onSave: onSaveWidgetName
		}) : title });
		$[53] = isNarrowWidth;
		$[54] = navigate;
		$[55] = onSaveWidgetName;
		$[56] = title;
		$[57] = widget;
		$[58] = t20;
	} else t20 = $[58];
	let t21;
	if ($[59] !== onSaveWidget || $[60] !== widget) {
		t21 = widget && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "primary",
			onPress: onSaveWidget,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Save widget" })
		});
		$[59] = onSaveWidget;
		$[60] = widget;
		$[61] = t21;
	} else t21 = $[61];
	let t22;
	if ($[62] !== allMonths || $[63] !== earliestTransaction || $[64] !== end || $[65] !== firstDayOfWeekIdx || $[66] !== latestTransaction || $[67] !== mode || $[68] !== start || $[69] !== t21) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
			allMonths,
			start,
			end,
			earliestTransaction,
			latestTransaction,
			firstDayOfWeekIdx,
			mode,
			onChangeDates,
			show1Month: true,
			children: t21
		});
		$[62] = allMonths;
		$[63] = earliestTransaction;
		$[64] = end;
		$[65] = firstDayOfWeekIdx;
		$[66] = latestTransaction;
		$[67] = mode;
		$[68] = start;
		$[69] = t21;
		$[70] = t22;
	} else t22 = $[70];
	let t23;
	if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = {
			width: "100%",
			background: theme.pageBackground
		};
		$[71] = t23;
	} else t23 = $[71];
	let t24;
	let t25;
	if ($[72] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = {
			width: "100%",
			alignContent: "center",
			justifyContent: "flex-start",
			alignItems: "center",
			flexDirection: "row",
			padding: 16
		};
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
			style: { marginRight: 4 },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Show as" })
		});
		$[72] = t24;
		$[73] = t25;
	} else {
		t24 = $[72];
		t25 = $[73];
	}
	let t26;
	if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
		t26 = { marginRight: 16 };
		$[74] = t26;
	} else t26 = $[74];
	let t27;
	if ($[75] !== t) {
		t27 = t("Sum");
		$[75] = t;
		$[76] = t27;
	} else t27 = $[76];
	let t28;
	if ($[77] !== t27) {
		t28 = ["sum", t27];
		$[77] = t27;
		$[78] = t28;
	} else t28 = $[78];
	let t29;
	if ($[79] !== t) {
		t29 = t("Average per month");
		$[79] = t;
		$[80] = t29;
	} else t29 = $[80];
	let t30;
	if ($[81] !== t29) {
		t30 = ["avgPerMonth", t29];
		$[81] = t29;
		$[82] = t30;
	} else t30 = $[82];
	let t31;
	if ($[83] !== t) {
		t31 = t("Average per year");
		$[83] = t;
		$[84] = t31;
	} else t31 = $[84];
	let t32;
	if ($[85] !== t31) {
		t32 = ["avgPerYear", t31];
		$[85] = t31;
		$[86] = t32;
	} else t32 = $[86];
	let t33;
	if ($[87] !== t) {
		t33 = t("Average per transaction");
		$[87] = t;
		$[88] = t33;
	} else t33 = $[88];
	let t34;
	if ($[89] !== t33) {
		t34 = ["avgPerTransact", t33];
		$[89] = t33;
		$[90] = t34;
	} else t34 = $[90];
	let t35;
	if ($[91] !== t) {
		t35 = t("Percentage");
		$[91] = t;
		$[92] = t35;
	} else t35 = $[92];
	let t36;
	if ($[93] !== t35) {
		t36 = ["percentage", t35];
		$[93] = t35;
		$[94] = t36;
	} else t36 = $[94];
	let t37;
	if ($[95] !== t28 || $[96] !== t30 || $[97] !== t32 || $[98] !== t34 || $[99] !== t36) {
		t37 = [
			t28,
			t30,
			t32,
			t34,
			t36
		];
		$[95] = t28;
		$[96] = t30;
		$[97] = t32;
		$[98] = t34;
		$[99] = t36;
		$[100] = t37;
	} else t37 = $[100];
	const t38 = content.type ?? "sum";
	let t39;
	if ($[101] === Symbol.for("react.memo_cache_sentinel")) {
		t39 = (newValue) => setContent((prev_0) => ({
			...prev_0,
			type: newValue
		}));
		$[101] = t39;
	} else t39 = $[101];
	let t40;
	if ($[102] !== t37 || $[103] !== t38) {
		t40 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t24,
			children: [t25, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldSelect, {
				style: t26,
				fields: t37,
				value: t38,
				onChange: t39
			})]
		});
		$[102] = t37;
		$[103] = t38;
		$[104] = t40;
	} else t40 = $[104];
	let t41;
	if ($[105] !== content.divisorAllTimeDateRange || $[106] !== content.type) {
		t41 = content.type === "percentage" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				flexDirection: "row",
				marginLeft: 16
			},
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
					id: "enabled-field",
					checked: content.divisorAllTimeDateRange ?? false,
					onChange: () => {
						const currentValue = content.divisorAllTimeDateRange ?? false;
						setContent((prev_1) => ({
							...prev_1,
							divisorAllTimeDateRange: !currentValue
						}));
					}
				}),
				" ",
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "All time divisor" })
			]
		});
		$[105] = content.divisorAllTimeDateRange;
		$[106] = content.type;
		$[107] = t41;
	} else t41 = $[107];
	let t42;
	if ($[108] !== t40 || $[109] !== t41) {
		t42 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t23,
			children: [t40, t41]
		});
		$[108] = t40;
		$[109] = t41;
		$[110] = t42;
	} else t42 = $[110];
	let t43;
	if ($[111] === Symbol.for("react.memo_cache_sentinel")) {
		t43 = {
			background: theme.pageBackground,
			padding: 20,
			paddingTop: 0,
			flexGrow: 1
		};
		$[111] = t43;
	} else t43 = $[111];
	let t44;
	if ($[112] === Symbol.for("react.memo_cache_sentinel")) {
		t44 = {
			flexDirection: "row",
			justifyContent: "center",
			width: "100%",
			alignItems: "center"
		};
		$[112] = t44;
	} else t44 = $[112];
	const t45 = content.type === "percentage" ? !(content.divisorAllTimeDateRange ?? false) : false;
	const t46 = data?.fromRange ?? "";
	const t47 = data?.toRange ?? "";
	let t48;
	if ($[113] !== content.type || $[114] !== dividendFilters || $[115] !== divisorFilters || $[116] !== t45 || $[117] !== t46 || $[118] !== t47) {
		t48 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Operator, {
			type: content.type,
			dividendFilterObject: dividendFilters,
			divisorFilterObject: divisorFilters,
			showDivisorDateRange: t45,
			fromRange: t46,
			toRange: t47
		});
		$[113] = content.type;
		$[114] = dividendFilters;
		$[115] = divisorFilters;
		$[116] = t45;
		$[117] = t46;
		$[118] = t47;
		$[119] = t48;
	} else t48 = $[119];
	let t49;
	if ($[120] !== content.type || $[121] !== data?.dividend || $[122] !== data?.divisor || $[123] !== format$3 || $[124] !== getDivisorFormatted) {
		t49 = content.type !== "sum" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgEquals, {
			width: 50,
			style: { marginLeft: 56 }
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { padding: 16 },
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						fontSize: "50px",
						width: "100%",
						textAlign: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format$3(data?.dividend ?? 0, "financial") }) })
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: {
					width: "100%",
					marginTop: 32,
					marginBottom: 32,
					borderTop: "2px solid",
					borderBottom: "2px solid"
				} }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
					style: {
						fontSize: "50px",
						width: "100%",
						textAlign: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: getDivisorFormatted(content.type, data?.divisor ?? 0) })
				})
			]
		})] });
		$[120] = content.type;
		$[121] = data?.dividend;
		$[122] = data?.divisor;
		$[123] = format$3;
		$[124] = getDivisorFormatted;
		$[125] = t49;
	} else t49 = $[125];
	let t50;
	if ($[126] === Symbol.for("react.memo_cache_sentinel")) {
		t50 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgEquals, {
			width: 50,
			style: { marginLeft: 16 }
		});
		$[126] = t50;
	} else t50 = $[126];
	const t51 = (data?.total ?? 0) === 0 ? theme.reportsNumberNeutral : (data?.total ?? 0) < 0 ? theme.reportsNumberNegative : theme.reportsNumberPositive;
	let t52;
	if ($[127] !== t51) {
		t52 = {
			flexGrow: 1,
			textAlign: "center",
			width: "250px",
			maxWidth: "250px",
			justifyItems: "center",
			alignItems: "center",
			marginLeft: 16,
			fontSize: "50px",
			justifyContent: "center",
			color: t51
		};
		$[127] = t51;
		$[128] = t52;
	} else t52 = $[128];
	let t53;
	if ($[129] !== content.type || $[130] !== data?.total || $[131] !== format$3) {
		t53 = content.type === "percentage" ? format$3(Math.abs(data?.total ?? 0), "number") : format$3(Math.abs(Math.round(data?.total ?? 0)), "financial");
		$[129] = content.type;
		$[130] = data?.total;
		$[131] = format$3;
		$[132] = t53;
	} else t53 = $[132];
	const t54 = content.type === "percentage" ? "%" : "";
	let t55;
	if ($[133] !== t53 || $[134] !== t54) {
		t55 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PrivacyFilter, { children: [t53, t54] });
		$[133] = t53;
		$[134] = t54;
		$[135] = t55;
	} else t55 = $[135];
	let t56;
	if ($[136] !== t52 || $[137] !== t55) {
		t56 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t52,
			children: t55
		});
		$[136] = t52;
		$[137] = t55;
		$[138] = t56;
	} else t56 = $[138];
	let t57;
	if ($[139] !== t48 || $[140] !== t49 || $[141] !== t56) {
		t57 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t43,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: t44,
				children: [
					t48,
					t49,
					t50,
					t56
				]
			})
		});
		$[139] = t48;
		$[140] = t49;
		$[141] = t56;
		$[142] = t57;
	} else t57 = $[142];
	let t58;
	if ($[143] !== t20 || $[144] !== t22 || $[145] !== t42 || $[146] !== t57) {
		t58 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Page, {
			header: t20,
			padding: 0,
			children: [
				t22,
				t42,
				t57
			]
		});
		$[143] = t20;
		$[144] = t22;
		$[145] = t42;
		$[146] = t57;
		$[147] = t58;
	} else t58 = $[147];
	return t58;
}
function Operator(t0) {
	const $ = (0, import_compiler_runtime.c)(17);
	const { type, dividendFilterObject, divisorFilterObject, fromRange, toRange, showDivisorDateRange } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== dividendFilterObject || $[1] !== fromRange || $[2] !== toRange) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SumWithRange, {
			from: fromRange,
			to: toRange,
			filterObject: dividendFilterObject
		});
		$[0] = dividendFilterObject;
		$[1] = fromRange;
		$[2] = toRange;
		$[3] = t1;
	} else t1 = $[3];
	let t2;
	if ($[4] !== divisorFilterObject || $[5] !== fromRange || $[6] !== showDivisorDateRange || $[7] !== toRange || $[8] !== type) {
		t2 = type === "percentage" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: {
			width: "100%",
			marginTop: 32,
			marginBottom: 32,
			borderTop: "2px solid",
			borderBottom: "2px solid"
		} }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SumWithRange, {
			from: !showDivisorDateRange ? "" : fromRange,
			to: !showDivisorDateRange ? "" : toRange,
			filterObject: divisorFilterObject
		})] });
		$[4] = divisorFilterObject;
		$[5] = fromRange;
		$[6] = showDivisorDateRange;
		$[7] = toRange;
		$[8] = type;
		$[9] = t2;
	} else t2 = $[9];
	let t3;
	if ($[10] !== t || $[11] !== type) {
		t3 = type !== "percentage" && type !== "sum" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: {
			width: "100%",
			marginTop: 32,
			marginBottom: 32,
			borderTop: "2px solid",
			borderBottom: "2px solid"
		} }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				fontSize: "32px",
				width: "100%",
				textAlign: "center"
			},
			children: type === "avgPerMonth" ? t("number of months") : type === "avgPerYear" ? t("number of years") : t("number of transactions")
		})] });
		$[10] = t;
		$[11] = type;
		$[12] = t3;
	} else t3 = $[12];
	let t4;
	if ($[13] !== t1 || $[14] !== t2 || $[15] !== t3) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [
			t1,
			t2,
			t3
		] });
		$[13] = t1;
		$[14] = t2;
		$[15] = t3;
		$[16] = t4;
	} else t4 = $[16];
	return t4;
}
function SumWithRange(t0) {
	const $ = (0, import_compiler_runtime.c)(31);
	const { from, to, containerStyle, filterObject } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== containerStyle) {
		t1 = {
			...containerStyle,
			height: "100%",
			flexDirection: "row",
			alignItems: "center",
			position: "relative",
			display: "grid",
			gridTemplateColumns: "70px 15px 1fr 15px"
		};
		$[0] = containerStyle;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	let t3;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			position: "relative",
			height: "50px",
			marginRight: 50
		};
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgSum, {
			width: 50,
			height: 50
		});
		$[2] = t2;
		$[3] = t3;
	} else {
		t2 = $[2];
		t3 = $[3];
	}
	let t4;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			position: "absolute",
			right: -30,
			top: -20
		};
		$[4] = t4;
	} else t4 = $[4];
	let t5;
	if ($[5] !== to) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t4,
			children: to
		});
		$[5] = to;
		$[6] = t5;
	} else t5 = $[6];
	let t6;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = {
			position: "absolute",
			right: -30,
			bottom: -20
		};
		$[7] = t6;
	} else t6 = $[7];
	let t7;
	if ($[8] !== from) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: t6,
			children: from
		});
		$[8] = from;
		$[9] = t7;
	} else t7 = $[9];
	let t8;
	if ($[10] !== t5 || $[11] !== t7) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t2,
			children: [
				t3,
				t5,
				t7
			]
		});
		$[10] = t5;
		$[11] = t7;
		$[12] = t8;
	} else t8 = $[12];
	let t9;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgOpenParenthesis, {
			width: 15,
			style: { height: "100%" }
		});
		$[13] = t9;
	} else t9 = $[13];
	let t10;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = {
			marginLeft: 16,
			maxWidth: "220px",
			marginRight: 16
		};
		$[14] = t10;
	} else t10 = $[14];
	let t11;
	if ($[15] !== filterObject.conditions || $[16] !== filterObject.conditionsOp || $[17] !== filterObject.onConditionsOpChange || $[18] !== filterObject.onDelete || $[19] !== filterObject.onUpdate || $[20] !== t) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t10,
			children: (filterObject.conditions?.length ?? 0) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
				style: {
					fontSize: "25px",
					color: theme.pageTextPositive
				},
				children: t("all transactions")
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppliedFilters, {
				conditions: filterObject.conditions,
				onUpdate: filterObject.onUpdate,
				onDelete: filterObject.onDelete,
				conditionsOp: filterObject.conditionsOp,
				onConditionsOpChange: filterObject.onConditionsOpChange
			})
		});
		$[15] = filterObject.conditions;
		$[16] = filterObject.conditionsOp;
		$[17] = filterObject.onConditionsOpChange;
		$[18] = filterObject.onDelete;
		$[19] = filterObject.onUpdate;
		$[20] = t;
		$[21] = t11;
	} else t11 = $[21];
	let t12;
	if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgCloseParenthesis, {
			width: 15,
			style: { height: "100%" }
		});
		$[22] = t12;
	} else t12 = $[22];
	let t13;
	if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = {
			position: "absolute",
			top: -15,
			right: -55
		};
		$[23] = t13;
	} else t13 = $[23];
	let t14;
	if ($[24] !== filterObject.onApply) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t13,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterButton, {
				compact: false,
				onApply: filterObject.onApply,
				hover: false
			})
		});
		$[24] = filterObject.onApply;
		$[25] = t14;
	} else t14 = $[25];
	let t15;
	if ($[26] !== t1 || $[27] !== t11 || $[28] !== t14 || $[29] !== t8) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t1,
			children: [
				t8,
				t9,
				t11,
				t12,
				t14
			]
		});
		$[26] = t1;
		$[27] = t11;
		$[28] = t14;
		$[29] = t8;
		$[30] = t15;
	} else t15 = $[30];
	return t15;
}
//#endregion
//#region ../../node_modules/react-grid-layout/dist/chunk-76RTO6EO.mjs
function calcGridColWidth(positionParams) {
	const { margin, containerPadding, containerWidth, cols } = positionParams;
	return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
}
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
	if (!Number.isFinite(gridUnits)) return gridUnits;
	return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
}
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
	const { margin, containerPadding, rowHeight } = positionParams;
	const colWidth = calcGridColWidth(positionParams);
	let width;
	let height;
	let top;
	let left;
	if (resizePosition) {
		width = Math.round(resizePosition.width);
		height = Math.round(resizePosition.height);
	} else {
		width = calcGridItemWHPx(w, colWidth, margin[0]);
		height = calcGridItemWHPx(h, rowHeight, margin[1]);
	}
	if (dragPosition) {
		top = Math.round(dragPosition.top);
		left = Math.round(dragPosition.left);
	} else if (resizePosition) {
		top = Math.round(resizePosition.top);
		left = Math.round(resizePosition.left);
	} else {
		top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
		left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
	}
	if (!dragPosition && !resizePosition) {
		if (Number.isFinite(w)) {
			const actualMarginRight = Math.round((colWidth + margin[0]) * (x + w) + containerPadding[0]) - left - width;
			if (actualMarginRight !== margin[0]) width += actualMarginRight - margin[0];
		}
		if (Number.isFinite(h)) {
			const actualMarginBottom = Math.round((rowHeight + margin[1]) * (y + h) + containerPadding[1]) - top - height;
			if (actualMarginBottom !== margin[1]) height += actualMarginBottom - margin[1];
		}
	}
	return {
		top,
		left,
		width,
		height
	};
}
function calcXY(positionParams, top, left, w, h) {
	const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
	const colWidth = calcGridColWidth(positionParams);
	let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
	let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
	x = clamp$1(x, 0, cols - w);
	y = clamp$1(y, 0, maxRows - h);
	return {
		x,
		y
	};
}
function calcXYRaw(positionParams, top, left) {
	const { margin, containerPadding, rowHeight } = positionParams;
	const colWidth = calcGridColWidth(positionParams);
	return {
		x: Math.round((left - containerPadding[0]) / (colWidth + margin[0])),
		y: Math.round((top - containerPadding[1]) / (rowHeight + margin[1]))
	};
}
function calcWHRaw(positionParams, width, height) {
	const { margin, rowHeight } = positionParams;
	const colWidth = calcGridColWidth(positionParams);
	return {
		w: Math.max(1, Math.round((width + margin[0]) / (colWidth + margin[0]))),
		h: Math.max(1, Math.round((height + margin[1]) / (rowHeight + margin[1])))
	};
}
function clamp$1(num, lowerBound, upperBound) {
	return Math.max(Math.min(num, upperBound), lowerBound);
}
function collides(l1, l2) {
	if (l1.i === l2.i) return false;
	if (l1.x + l1.w <= l2.x) return false;
	if (l1.x >= l2.x + l2.w) return false;
	if (l1.y + l1.h <= l2.y) return false;
	if (l1.y >= l2.y + l2.h) return false;
	return true;
}
function getFirstCollision(layout, layoutItem) {
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0 && collides(item, layoutItem)) return item;
	}
}
function getAllCollisions(layout, layoutItem) {
	return layout.filter((l) => collides(l, layoutItem));
}
function sortLayoutItems(layout, compactType) {
	if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
	if (compactType === "vertical") return sortLayoutItemsByRowCol(layout);
	if (compactType === "wrap") return sortLayoutItemsByRowCol(layout);
	return [...layout];
}
function sortLayoutItemsByRowCol(layout) {
	return [...layout].sort((a, b) => {
		if (a.y !== b.y) return a.y - b.y;
		return a.x - b.x;
	});
}
function sortLayoutItemsByColRow(layout) {
	return [...layout].sort((a, b) => {
		if (a.x !== b.x) return a.x - b.x;
		return a.y - b.y;
	});
}
function bottom(layout) {
	let max = 0;
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0) {
			const bottomY = item.y + item.h;
			if (bottomY > max) max = bottomY;
		}
	}
	return max;
}
function getLayoutItem(layout, id) {
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0 && item.i === id) return item;
	}
}
function getStatics(layout) {
	return layout.filter((l) => l.static === true);
}
function cloneLayoutItem(layoutItem) {
	return {
		i: layoutItem.i,
		x: layoutItem.x,
		y: layoutItem.y,
		w: layoutItem.w,
		h: layoutItem.h,
		minW: layoutItem.minW,
		maxW: layoutItem.maxW,
		minH: layoutItem.minH,
		maxH: layoutItem.maxH,
		moved: Boolean(layoutItem.moved),
		static: Boolean(layoutItem.static),
		isDraggable: layoutItem.isDraggable,
		isResizable: layoutItem.isResizable,
		resizeHandles: layoutItem.resizeHandles,
		constraints: layoutItem.constraints,
		isBounded: layoutItem.isBounded
	};
}
function cloneLayout(layout) {
	const newLayout = new Array(layout.length);
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0) newLayout[i] = cloneLayoutItem(item);
	}
	return newLayout;
}
function modifyLayout(layout, layoutItem) {
	const newLayout = new Array(layout.length);
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0) if (layoutItem.i === item.i) newLayout[i] = layoutItem;
		else newLayout[i] = item;
	}
	return newLayout;
}
function withLayoutItem(layout, itemKey, cb) {
	let item = getLayoutItem(layout, itemKey);
	if (!item) return [[...layout], null];
	item = cb(cloneLayoutItem(item));
	return [modifyLayout(layout, item), item];
}
function correctBounds(layout, bounds) {
	const collidesWith = getStatics(layout);
	for (let i = 0; i < layout.length; i++) {
		const l = layout[i];
		if (l === void 0) continue;
		if (l.x + l.w > bounds.cols) l.x = bounds.cols - l.w;
		if (l.x < 0) {
			l.x = 0;
			l.w = bounds.cols;
		}
		if (!l.static) collidesWith.push(l);
		else while (getFirstCollision(collidesWith, l)) l.y++;
	}
	return layout;
}
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
	if (l.static && l.isDraggable !== true) return [...layout];
	if (l.y === y && l.x === x) return [...layout];
	const oldX = l.x;
	const oldY = l.y;
	if (typeof x === "number") l.x = x;
	if (typeof y === "number") l.y = y;
	l.moved = true;
	let sorted = sortLayoutItems(layout, compactType);
	if (compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false) sorted = sorted.reverse();
	const collisions = getAllCollisions(sorted, l);
	const hasCollisions = collisions.length > 0;
	if (hasCollisions && allowOverlap) return cloneLayout(layout);
	if (hasCollisions && preventCollision) {
		l.x = oldX;
		l.y = oldY;
		l.moved = false;
		return layout;
	}
	let resultLayout = [...layout];
	for (let i = 0; i < collisions.length; i++) {
		const collision = collisions[i];
		if (collision === void 0) continue;
		if (collision.moved) continue;
		if (collision.static) resultLayout = moveElementAwayFromCollision(resultLayout, collision, l, isUserAction, compactType);
		else resultLayout = moveElementAwayFromCollision(resultLayout, l, collision, isUserAction, compactType);
	}
	return resultLayout;
}
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
	const compactH = compactType === "horizontal";
	const compactV = compactType === "vertical";
	const preventCollision = collidesWith.static;
	if (isUserAction) {
		isUserAction = false;
		const fakeItem = {
			x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
			y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
			w: itemToMove.w,
			h: itemToMove.h,
			i: "-1"
		};
		const firstCollision = getFirstCollision(layout, fakeItem);
		const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
		const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
		if (!firstCollision) return moveElement(layout, itemToMove, compactH ? fakeItem.x : void 0, compactV ? fakeItem.y : void 0, isUserAction, preventCollision, compactType);
		if (collisionNorth && compactV) return moveElement(layout, itemToMove, void 0, itemToMove.y + 1, isUserAction, preventCollision, compactType);
		if (collisionNorth && compactType === null) {
			collidesWith.y = itemToMove.y;
			itemToMove.y = itemToMove.y + itemToMove.h;
			return [...layout];
		}
		if (collisionWest && compactH) return moveElement(layout, collidesWith, itemToMove.x, void 0, isUserAction, preventCollision, compactType);
	}
	const newX = compactH ? itemToMove.x + 1 : void 0;
	const newY = compactV ? itemToMove.y + 1 : void 0;
	if (newX === void 0 && newY === void 0) return [...layout];
	return moveElement(layout, itemToMove, newX, newY, isUserAction, preventCollision, compactType);
}
//#endregion
//#region ../../node_modules/react-grid-layout/dist/chunk-KDANGDDL.mjs
function clamp(value, min, max) {
	return Math.max(min, Math.min(max, value));
}
var defaultConstraints = [{
	name: "gridBounds",
	constrainPosition(item, x, y, { cols, maxRows }) {
		return {
			x: clamp(x, 0, Math.max(0, cols - item.w)),
			y: clamp(y, 0, Math.max(0, maxRows - item.h))
		};
	},
	constrainSize(item, w, h, handle, { cols, maxRows }) {
		const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
		const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
		return {
			w: clamp(w, 1, Math.max(1, maxW)),
			h: clamp(h, 1, Math.max(1, maxH))
		};
	}
}, {
	name: "minMaxSize",
	constrainSize(item, w, h) {
		return {
			w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
			h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
		};
	}
}];
function applyPositionConstraints(constraints, item, x, y, context) {
	let result = {
		x,
		y
	};
	for (const constraint of constraints) if (constraint.constrainPosition) result = constraint.constrainPosition(item, result.x, result.y, context);
	if (item.constraints) {
		for (const constraint of item.constraints) if (constraint.constrainPosition) result = constraint.constrainPosition(item, result.x, result.y, context);
	}
	return result;
}
function applySizeConstraints(constraints, item, w, h, handle, context) {
	let result = {
		w,
		h
	};
	for (const constraint of constraints) if (constraint.constrainSize) result = constraint.constrainSize(item, result.w, result.h, handle, context);
	if (item.constraints) {
		for (const constraint of item.constraints) if (constraint.constrainSize) result = constraint.constrainSize(item, result.w, result.h, handle, context);
	}
	return result;
}
function setTransform({ top, left, width, height }) {
	const translate = `translate(${left}px,${top}px)`;
	return {
		transform: translate,
		WebkitTransform: translate,
		MozTransform: translate,
		msTransform: translate,
		OTransform: translate,
		width: `${width}px`,
		height: `${height}px`,
		position: "absolute"
	};
}
function setTopLeft({ top, left, width, height }) {
	return {
		top: `${top}px`,
		left: `${left}px`,
		width: `${width}px`,
		height: `${height}px`,
		position: "absolute"
	};
}
function perc(num) {
	return num * 100 + "%";
}
function constrainWidth(left, currentWidth, newWidth, containerWidth) {
	return left + newWidth > containerWidth ? currentWidth : newWidth;
}
function constrainHeight(top, currentHeight, newHeight) {
	return top < 0 ? currentHeight : newHeight;
}
function constrainLeft(left) {
	return Math.max(0, left);
}
function constrainTop(top) {
	return Math.max(0, top);
}
var resizeNorth = (currentSize, newSize, _containerWidth) => {
	const { left, height, width } = newSize;
	const top = currentSize.top - (height - currentSize.height);
	return {
		left,
		width,
		height: constrainHeight(top, currentSize.height, height),
		top: constrainTop(top)
	};
};
var resizeEast = (currentSize, newSize, containerWidth) => {
	const { top, left, height, width } = newSize;
	return {
		top,
		height,
		width: constrainWidth(currentSize.left, currentSize.width, width, containerWidth),
		left: constrainLeft(left)
	};
};
var resizeWest = (currentSize, newSize, _containerWidth) => {
	const { top, height, width } = newSize;
	const left = currentSize.left + currentSize.width - width;
	if (left < 0) return {
		height,
		width: currentSize.left + currentSize.width,
		top: constrainTop(top),
		left: 0
	};
	return {
		height,
		width,
		top: constrainTop(top),
		left
	};
};
var resizeSouth = (currentSize, newSize, _containerWidth) => {
	const { top, left, height, width } = newSize;
	return {
		width,
		left,
		height: constrainHeight(top, currentSize.height, height),
		top: constrainTop(top)
	};
};
var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(currentSize, resizeEast(currentSize, newSize, containerWidth));
var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(currentSize, resizeWest(currentSize, newSize));
var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(currentSize, resizeEast(currentSize, newSize, containerWidth));
var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(currentSize, resizeWest(currentSize, newSize));
var resizeHandlerMap = {
	n: resizeNorth,
	ne: resizeNorthEast,
	e: resizeEast,
	se: resizeSouthEast,
	s: resizeSouth,
	sw: resizeSouthWest,
	w: resizeWest,
	nw: resizeNorthWest
};
function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
	const handler = resizeHandlerMap[direction];
	if (!handler) return newSize;
	return handler(currentSize, {
		...currentSize,
		...newSize
	}, containerWidth);
}
var defaultPositionStrategy = {
	type: "transform",
	scale: 1,
	calcStyle(pos) {
		return setTransform(pos);
	}
};
var defaultGridConfig = {
	cols: 12,
	rowHeight: 150,
	margin: [10, 10],
	containerPadding: null,
	maxRows: Infinity
};
var defaultDragConfig = {
	enabled: true,
	bounded: false,
	threshold: 3
};
var defaultResizeConfig = {
	enabled: true,
	handles: ["se"]
};
var defaultDropConfig = {
	enabled: false,
	defaultItem: {
		w: 1,
		h: 1
	}
};
function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
	const sizeProp = axis === "x" ? "w" : "h";
	item[axis] += 1;
	const itemIndex = layout.findIndex((l) => l.i === item.i);
	const layoutHasStatics = hasStatics ?? getStatics(layout).length > 0;
	for (let i = itemIndex + 1; i < layout.length; i++) {
		const otherItem = layout[i];
		if (otherItem === void 0) continue;
		if (otherItem.static) continue;
		if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
		if (collides(item, otherItem)) resolveCompactionCollision(layout, otherItem, moveToCoord + item[sizeProp], axis, layoutHasStatics);
	}
	item[axis] = moveToCoord;
}
function compactItemVertical(compareWith, l, fullLayout, maxY) {
	l.x = Math.max(l.x, 0);
	l.y = Math.max(l.y, 0);
	l.y = Math.min(maxY, l.y);
	while (l.y > 0 && !getFirstCollision(compareWith, l)) l.y--;
	let collision;
	while ((collision = getFirstCollision(compareWith, l)) !== void 0) resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
	l.y = Math.max(l.y, 0);
	return l;
}
function compactItemHorizontal(compareWith, l, cols, fullLayout) {
	l.x = Math.max(l.x, 0);
	l.y = Math.max(l.y, 0);
	while (l.x > 0 && !getFirstCollision(compareWith, l)) l.x--;
	let collision;
	while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
		resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
		if (l.x + l.w > cols) {
			l.x = cols - l.w;
			l.y++;
			while (l.x > 0 && !getFirstCollision(compareWith, l)) l.x--;
		}
	}
	l.x = Math.max(l.x, 0);
	return l;
}
var verticalCompactor = {
	type: "vertical",
	allowOverlap: false,
	compact(layout, _cols) {
		const compareWith = getStatics(layout);
		let maxY = bottom(compareWith);
		const sorted = sortLayoutItemsByRowCol(layout);
		const out = new Array(layout.length);
		for (let i = 0; i < sorted.length; i++) {
			const sortedItem = sorted[i];
			if (sortedItem === void 0) continue;
			let l = cloneLayoutItem(sortedItem);
			if (!l.static) {
				l = compactItemVertical(compareWith, l, sorted, maxY);
				maxY = Math.max(maxY, l.y + l.h);
				compareWith.push(l);
			}
			const originalIndex = layout.indexOf(sortedItem);
			out[originalIndex] = l;
			l.moved = false;
		}
		return out;
	}
};
var horizontalCompactor = {
	type: "horizontal",
	allowOverlap: false,
	compact(layout, cols) {
		const compareWith = getStatics(layout);
		const sorted = sortLayoutItemsByColRow(layout);
		const out = new Array(layout.length);
		for (let i = 0; i < sorted.length; i++) {
			const sortedItem = sorted[i];
			if (sortedItem === void 0) continue;
			let l = cloneLayoutItem(sortedItem);
			if (!l.static) {
				l = compactItemHorizontal(compareWith, l, cols, sorted);
				compareWith.push(l);
			}
			const originalIndex = layout.indexOf(sortedItem);
			out[originalIndex] = l;
			l.moved = false;
		}
		return out;
	}
};
var noCompactor = {
	type: null,
	allowOverlap: false,
	compact(layout, _cols) {
		return cloneLayout(layout);
	}
};
var verticalOverlapCompactor = {
	...verticalCompactor,
	allowOverlap: true,
	compact(layout, _cols) {
		return cloneLayout(layout);
	}
};
var horizontalOverlapCompactor = {
	...horizontalCompactor,
	allowOverlap: true,
	compact(layout, _cols) {
		return cloneLayout(layout);
	}
};
var noOverlapCompactor = {
	...noCompactor,
	allowOverlap: true
};
function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
	let baseCompactor;
	if (allowOverlap) if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
	else if (compactType === "horizontal") baseCompactor = horizontalOverlapCompactor;
	else baseCompactor = noOverlapCompactor;
	else if (compactType === "vertical") baseCompactor = verticalCompactor;
	else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
	else baseCompactor = noCompactor;
	if (preventCollision) return {
		...baseCompactor,
		preventCollision
	};
	return baseCompactor;
}
//#endregion
//#region ../../node_modules/fast-equals/dist/fast-equals.js
var require_fast_equals = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	(function(global, factory) {
		typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["fast-equals"] = {}));
	})(exports, (function(exports$1) {
		"use strict";
		/**
		* Default equality comparator pass-through, used as the standard `isEqual` creator for
		* use inside the built comparator.
		*/
		function createDefaultIsNestedEqual(comparator) {
			return function isEqual(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, meta) {
				return comparator(a, b, meta);
			};
		}
		/**
		* Wrap the provided `areItemsEqual` method to manage the circular cache, allowing
		* for circular references to be safely included in the comparison without creating
		* stack overflows.
		*/
		function createIsCircular(areItemsEqual) {
			return function isCircular(a, b, isEqual, cache) {
				if (!a || !b || typeof a !== "object" || typeof b !== "object") return areItemsEqual(a, b, isEqual, cache);
				var cachedA = cache.get(a);
				var cachedB = cache.get(b);
				if (cachedA && cachedB) return cachedA === b && cachedB === a;
				cache.set(a, b);
				cache.set(b, a);
				var result = areItemsEqual(a, b, isEqual, cache);
				cache.delete(a);
				cache.delete(b);
				return result;
			};
		}
		/**
		* Targeted shallow merge of two objects.
		*
		* @NOTE
		* This exists as a tinier compiled version of the `__assign` helper that
		* `tsc` injects in case of `Object.assign` not being present.
		*/
		function merge(a, b) {
			var merged = {};
			for (var key in a) merged[key] = a[key];
			for (var key in b) merged[key] = b[key];
			return merged;
		}
		/**
		* Whether the value is a plain object.
		*
		* @NOTE
		* This is a same-realm compariosn only.
		*/
		function isPlainObject(value) {
			return value.constructor === Object || value.constructor == null;
		}
		/**
		* When the value is `Promise`-like, aka "then-able".
		*/
		function isPromiseLike(value) {
			return typeof value.then === "function";
		}
		/**
		* Whether the values passed are strictly equal or both NaN.
		*/
		function sameValueZeroEqual(a, b) {
			return a === b || a !== a && b !== b;
		}
		var ARGUMENTS_TAG = "[object Arguments]";
		var BOOLEAN_TAG = "[object Boolean]";
		var DATE_TAG = "[object Date]";
		var REG_EXP_TAG = "[object RegExp]";
		var MAP_TAG = "[object Map]";
		var NUMBER_TAG = "[object Number]";
		var OBJECT_TAG = "[object Object]";
		var SET_TAG = "[object Set]";
		var STRING_TAG = "[object String]";
		var toString = Object.prototype.toString;
		function createComparator(_a) {
			var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areMapsEqual = _a.areMapsEqual, areObjectsEqual = _a.areObjectsEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, createIsNestedEqual = _a.createIsNestedEqual;
			var isEqual = createIsNestedEqual(comparator);
			/**
			* compare the value of the two objects and return true if they are equivalent in values
			*/
			function comparator(a, b, meta) {
				if (a === b) return true;
				if (!a || !b || typeof a !== "object" || typeof b !== "object") return a !== a && b !== b;
				if (isPlainObject(a) && isPlainObject(b)) return areObjectsEqual(a, b, isEqual, meta);
				var aArray = Array.isArray(a);
				var bArray = Array.isArray(b);
				if (aArray || bArray) return aArray === bArray && areArraysEqual(a, b, isEqual, meta);
				var aTag = toString.call(a);
				if (aTag !== toString.call(b)) return false;
				if (aTag === DATE_TAG) return areDatesEqual(a, b, isEqual, meta);
				if (aTag === REG_EXP_TAG) return areRegExpsEqual(a, b, isEqual, meta);
				if (aTag === MAP_TAG) return areMapsEqual(a, b, isEqual, meta);
				if (aTag === SET_TAG) return areSetsEqual(a, b, isEqual, meta);
				if (aTag === OBJECT_TAG || aTag === ARGUMENTS_TAG) return isPromiseLike(a) || isPromiseLike(b) ? false : areObjectsEqual(a, b, isEqual, meta);
				if (aTag === BOOLEAN_TAG || aTag === NUMBER_TAG || aTag === STRING_TAG) return sameValueZeroEqual(a.valueOf(), b.valueOf());
				return false;
			}
			return comparator;
		}
		/**
		* Whether the arrays are equal in value.
		*/
		function areArraysEqual(a, b, isEqual, meta) {
			var index = a.length;
			if (b.length !== index) return false;
			while (index-- > 0) if (!isEqual(a[index], b[index], index, index, a, b, meta)) return false;
			return true;
		}
		/**
		* Whether the arrays are equal in value, including circular references.
		*/
		var areArraysEqualCircular = createIsCircular(areArraysEqual);
		/**
		* Whether the dates passed are equal in value.
		*
		* @NOTE
		* This is a standalone function instead of done inline in the comparator
		* to allow for overrides.
		*/
		function areDatesEqual(a, b) {
			return sameValueZeroEqual(a.valueOf(), b.valueOf());
		}
		/**
		* Whether the `Map`s are equal in value.
		*/
		function areMapsEqual(a, b, isEqual, meta) {
			var isValueEqual = a.size === b.size;
			if (!isValueEqual) return false;
			if (!a.size) return true;
			var matchedIndices = {};
			var indexA = 0;
			a.forEach(function(aValue, aKey) {
				if (!isValueEqual) return;
				var hasMatch = false;
				var matchIndexB = 0;
				b.forEach(function(bValue, bKey) {
					if (!hasMatch && !matchedIndices[matchIndexB] && (hasMatch = isEqual(aKey, bKey, indexA, matchIndexB, a, b, meta) && isEqual(aValue, bValue, aKey, bKey, a, b, meta))) matchedIndices[matchIndexB] = true;
					matchIndexB++;
				});
				indexA++;
				isValueEqual = hasMatch;
			});
			return isValueEqual;
		}
		/**
		* Whether the `Map`s are equal in value, including circular references.
		*/
		var areMapsEqualCircular = createIsCircular(areMapsEqual);
		var OWNER = "_owner";
		var hasOwnProperty = Object.prototype.hasOwnProperty;
		/**
		* Whether the objects are equal in value.
		*/
		function areObjectsEqual(a, b, isEqual, meta) {
			var keysA = Object.keys(a);
			var index = keysA.length;
			if (Object.keys(b).length !== index) return false;
			var key;
			while (index-- > 0) {
				key = keysA[index];
				if (key === OWNER) {
					var reactElementA = !!a.$$typeof;
					var reactElementB = !!b.$$typeof;
					if ((reactElementA || reactElementB) && reactElementA !== reactElementB) return false;
				}
				if (!hasOwnProperty.call(b, key) || !isEqual(a[key], b[key], key, key, a, b, meta)) return false;
			}
			return true;
		}
		/**
		* Whether the objects are equal in value, including circular references.
		*/
		var areObjectsEqualCircular = createIsCircular(areObjectsEqual);
		/**
		* Whether the regexps passed are equal in value.
		*
		* @NOTE
		* This is a standalone function instead of done inline in the comparator
		* to allow for overrides. An example of this would be supporting a
		* pre-ES2015 environment where the `flags` property is not available.
		*/
		function areRegExpsEqual(a, b) {
			return a.source === b.source && a.flags === b.flags;
		}
		/**
		* Whether the `Set`s are equal in value.
		*/
		function areSetsEqual(a, b, isEqual, meta) {
			var isValueEqual = a.size === b.size;
			if (!isValueEqual) return false;
			if (!a.size) return true;
			var matchedIndices = {};
			a.forEach(function(aValue, aKey) {
				if (!isValueEqual) return;
				var hasMatch = false;
				var matchIndex = 0;
				b.forEach(function(bValue, bKey) {
					if (!hasMatch && !matchedIndices[matchIndex] && (hasMatch = isEqual(aValue, bValue, aKey, bKey, a, b, meta))) matchedIndices[matchIndex] = true;
					matchIndex++;
				});
				isValueEqual = hasMatch;
			});
			return isValueEqual;
		}
		/**
		* Whether the `Set`s are equal in value, including circular references.
		*/
		var areSetsEqualCircular = createIsCircular(areSetsEqual);
		var DEFAULT_CONFIG = Object.freeze({
			areArraysEqual,
			areDatesEqual,
			areMapsEqual,
			areObjectsEqual,
			areRegExpsEqual,
			areSetsEqual,
			createIsNestedEqual: createDefaultIsNestedEqual
		});
		var DEFAULT_CIRCULAR_CONFIG = Object.freeze({
			areArraysEqual: areArraysEqualCircular,
			areDatesEqual,
			areMapsEqual: areMapsEqualCircular,
			areObjectsEqual: areObjectsEqualCircular,
			areRegExpsEqual,
			areSetsEqual: areSetsEqualCircular,
			createIsNestedEqual: createDefaultIsNestedEqual
		});
		var isDeepEqual = createComparator(DEFAULT_CONFIG);
		/**
		* Whether the items passed are deeply-equal in value.
		*/
		function deepEqual(a, b) {
			return isDeepEqual(a, b, void 0);
		}
		var isShallowEqual = createComparator(merge(DEFAULT_CONFIG, { createIsNestedEqual: function() {
			return sameValueZeroEqual;
		} }));
		/**
		* Whether the items passed are shallowly-equal in value.
		*/
		function shallowEqual(a, b) {
			return isShallowEqual(a, b, void 0);
		}
		var isCircularDeepEqual = createComparator(DEFAULT_CIRCULAR_CONFIG);
		/**
		* Whether the items passed are deeply-equal in value, including circular references.
		*/
		function circularDeepEqual(a, b) {
			return isCircularDeepEqual(a, b, /* @__PURE__ */ new WeakMap());
		}
		var isCircularShallowEqual = createComparator(merge(DEFAULT_CIRCULAR_CONFIG, { createIsNestedEqual: function() {
			return sameValueZeroEqual;
		} }));
		/**
		* Whether the items passed are shallowly-equal in value, including circular references.
		*/
		function circularShallowEqual(a, b) {
			return isCircularShallowEqual(a, b, /* @__PURE__ */ new WeakMap());
		}
		/**
		* Create a custom equality comparison method.
		*
		* This can be done to create very targeted comparisons in extreme hot-path scenarios
		* where the standard methods are not performant enough, but can also be used to provide
		* support for legacy environments that do not support expected features like
		* `RegExp.prototype.flags` out of the box.
		*/
		function createCustomEqual(getComparatorOptions) {
			return createComparator(merge(DEFAULT_CONFIG, getComparatorOptions(DEFAULT_CONFIG)));
		}
		/**
		* Create a custom equality comparison method that handles circular references. This is very
		* similar to `createCustomEqual`, with the only difference being that `meta` expects to be
		* populated with a `WeakMap`-like contract.
		*
		* This can be done to create very targeted comparisons in extreme hot-path scenarios
		* where the standard methods are not performant enough, but can also be used to provide
		* support for legacy environments that do not support expected features like
		* `WeakMap` out of the box.
		*/
		function createCustomCircularEqual(getComparatorOptions) {
			var comparator = createComparator(merge(DEFAULT_CIRCULAR_CONFIG, getComparatorOptions(DEFAULT_CIRCULAR_CONFIG)));
			return (function(a, b, meta) {
				if (meta === void 0) meta = /* @__PURE__ */ new WeakMap();
				return comparator(a, b, meta);
			});
		}
		exports$1.circularDeepEqual = circularDeepEqual;
		exports$1.circularShallowEqual = circularShallowEqual;
		exports$1.createCustomCircularEqual = createCustomCircularEqual;
		exports$1.createCustomEqual = createCustomEqual;
		exports$1.deepEqual = deepEqual;
		exports$1.sameValueZeroEqual = sameValueZeroEqual;
		exports$1.shallowEqual = shallowEqual;
		Object.defineProperty(exports$1, "__esModule", { value: true });
	}));
}));
//#endregion
//#region ../../node_modules/clsx/dist/clsx.js
var require_clsx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	function r(e) {
		var o, t, f = "";
		if ("string" == typeof e || "number" == typeof e) f += e;
		else if ("object" == typeof e) if (Array.isArray(e)) {
			var n = e.length;
			for (o = 0; o < n; o++) e[o] && (t = r(e[o])) && (f && (f += " "), f += t);
		} else for (t in e) e[t] && (f && (f += " "), f += t);
		return f;
	}
	function e() {
		for (var e, o, t = 0, f = "", n = arguments.length; t < n; t++) (e = arguments[t]) && (o = r(e)) && (f && (f += " "), f += o);
		return f;
	}
	module.exports = e, module.exports.clsx = e;
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/utils/shims.js
var require_shims = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.dontSetMe = dontSetMe;
	exports.findInArray = findInArray;
	exports.int = int;
	exports.isFunction = isFunction;
	exports.isNum = isNum;
	function findInArray(array, callback) {
		for (let i = 0, length = array.length; i < length; i++) if (callback.apply(callback, [
			array[i],
			i,
			array
		])) return array[i];
	}
	function isFunction(func) {
		return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
	}
	function isNum(num) {
		return typeof num === "number" && !isNaN(num);
	}
	function int(a) {
		return parseInt(a, 10);
	}
	function dontSetMe(props, propName, componentName) {
		if (props[propName]) return /* @__PURE__ */ new Error(`Invalid prop ${propName} passed to ${componentName} - do not set this, set it on the child.`);
	}
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/utils/getPrefix.js
var require_getPrefix = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.browserPrefixToKey = browserPrefixToKey;
	exports.browserPrefixToStyle = browserPrefixToStyle;
	exports.default = void 0;
	exports.getPrefix = getPrefix;
	var prefixes = [
		"Moz",
		"Webkit",
		"O",
		"ms"
	];
	function getPrefix() {
		let prop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "transform";
		if (typeof window === "undefined") return "";
		const style = window.document?.documentElement?.style;
		if (!style) return "";
		if (prop in style) return "";
		for (let i = 0; i < prefixes.length; i++) if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
		return "";
	}
	function browserPrefixToKey(prop, prefix) {
		return prefix ? `${prefix}${kebabToTitleCase(prop)}` : prop;
	}
	function browserPrefixToStyle(prop, prefix) {
		return prefix ? `-${prefix.toLowerCase()}-${prop}` : prop;
	}
	function kebabToTitleCase(str) {
		let out = "";
		let shouldCapitalize = true;
		for (let i = 0; i < str.length; i++) if (shouldCapitalize) {
			out += str[i].toUpperCase();
			shouldCapitalize = false;
		} else if (str[i] === "-") shouldCapitalize = true;
		else out += str[i];
		return out;
	}
	exports.default = getPrefix();
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/utils/domFns.js
var require_domFns = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.addClassName = addClassName;
	exports.addEvent = addEvent;
	exports.addUserSelectStyles = addUserSelectStyles;
	exports.createCSSTransform = createCSSTransform;
	exports.createSVGTransform = createSVGTransform;
	exports.getTouch = getTouch;
	exports.getTouchIdentifier = getTouchIdentifier;
	exports.getTranslation = getTranslation;
	exports.innerHeight = innerHeight;
	exports.innerWidth = innerWidth;
	exports.matchesSelector = matchesSelector;
	exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
	exports.offsetXYFromParent = offsetXYFromParent;
	exports.outerHeight = outerHeight;
	exports.outerWidth = outerWidth;
	exports.removeClassName = removeClassName;
	exports.removeEvent = removeEvent;
	exports.scheduleRemoveUserSelectStyles = scheduleRemoveUserSelectStyles;
	var _shims = require_shims();
	var _getPrefix = _interopRequireWildcard(require_getPrefix());
	function _interopRequireWildcard(e, t) {
		if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
		return (_interopRequireWildcard = function(e, t) {
			if (!t && e && e.__esModule) return e;
			var o, i, f = {
				__proto__: null,
				default: e
			};
			if (null === e || "object" != typeof e && "function" != typeof e) return f;
			if (o = t ? n : r) {
				if (o.has(e)) return o.get(e);
				o.set(e, f);
			}
			for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
			return f;
		})(e, t);
	}
	var matchesSelectorFunc = "";
	function matchesSelector(el, selector) {
		if (!matchesSelectorFunc) matchesSelectorFunc = (0, _shims.findInArray)([
			"matches",
			"webkitMatchesSelector",
			"mozMatchesSelector",
			"msMatchesSelector",
			"oMatchesSelector"
		], function(method) {
			return (0, _shims.isFunction)(el[method]);
		});
		if (!(0, _shims.isFunction)(el[matchesSelectorFunc])) return false;
		return el[matchesSelectorFunc](selector);
	}
	function matchesSelectorAndParentsTo(el, selector, baseNode) {
		let node = el;
		do {
			if (matchesSelector(node, selector)) return true;
			if (node === baseNode) return false;
			node = node.parentNode;
		} while (node);
		return false;
	}
	function addEvent(el, event, handler, inputOptions) {
		if (!el) return;
		const options = {
			capture: true,
			...inputOptions
		};
		if (el.addEventListener) el.addEventListener(event, handler, options);
		else if (el.attachEvent) el.attachEvent("on" + event, handler);
		else el["on" + event] = handler;
	}
	function removeEvent(el, event, handler, inputOptions) {
		if (!el) return;
		const options = {
			capture: true,
			...inputOptions
		};
		if (el.removeEventListener) el.removeEventListener(event, handler, options);
		else if (el.detachEvent) el.detachEvent("on" + event, handler);
		else el["on" + event] = null;
	}
	function outerHeight(node) {
		let height = node.clientHeight;
		const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
		height += (0, _shims.int)(computedStyle.borderTopWidth);
		height += (0, _shims.int)(computedStyle.borderBottomWidth);
		return height;
	}
	function outerWidth(node) {
		let width = node.clientWidth;
		const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
		width += (0, _shims.int)(computedStyle.borderLeftWidth);
		width += (0, _shims.int)(computedStyle.borderRightWidth);
		return width;
	}
	function innerHeight(node) {
		let height = node.clientHeight;
		const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
		height -= (0, _shims.int)(computedStyle.paddingTop);
		height -= (0, _shims.int)(computedStyle.paddingBottom);
		return height;
	}
	function innerWidth(node) {
		let width = node.clientWidth;
		const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
		width -= (0, _shims.int)(computedStyle.paddingLeft);
		width -= (0, _shims.int)(computedStyle.paddingRight);
		return width;
	}
	function offsetXYFromParent(evt, offsetParent, scale) {
		const offsetParentRect = offsetParent === offsetParent.ownerDocument.body ? {
			left: 0,
			top: 0
		} : offsetParent.getBoundingClientRect();
		return {
			x: (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale,
			y: (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale
		};
	}
	function createCSSTransform(controlPos, positionOffset) {
		const translation = getTranslation(controlPos, positionOffset, "px");
		return { [(0, _getPrefix.browserPrefixToKey)("transform", _getPrefix.default)]: translation };
	}
	function createSVGTransform(controlPos, positionOffset) {
		return getTranslation(controlPos, positionOffset, "");
	}
	function getTranslation(_ref, positionOffset, unitSuffix) {
		let { x, y } = _ref;
		let translation = `translate(${x}${unitSuffix},${y}${unitSuffix})`;
		if (positionOffset) translation = `translate(${`${typeof positionOffset.x === "string" ? positionOffset.x : positionOffset.x + unitSuffix}`}, ${`${typeof positionOffset.y === "string" ? positionOffset.y : positionOffset.y + unitSuffix}`})` + translation;
		return translation;
	}
	function getTouch(e, identifier) {
		return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, (t) => identifier === t.identifier) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, (t) => identifier === t.identifier);
	}
	function getTouchIdentifier(e) {
		if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
		if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
	}
	function addUserSelectStyles(doc) {
		if (!doc) return;
		let styleEl = doc.getElementById("react-draggable-style-el");
		if (!styleEl) {
			styleEl = doc.createElement("style");
			styleEl.type = "text/css";
			styleEl.id = "react-draggable-style-el";
			styleEl.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n";
			styleEl.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n";
			doc.getElementsByTagName("head")[0].appendChild(styleEl);
		}
		if (doc.body) addClassName(doc.body, "react-draggable-transparent-selection");
	}
	function scheduleRemoveUserSelectStyles(doc) {
		if (window.requestAnimationFrame) window.requestAnimationFrame(() => {
			removeUserSelectStyles(doc);
		});
		else removeUserSelectStyles(doc);
	}
	function removeUserSelectStyles(doc) {
		if (!doc) return;
		try {
			if (doc.body) removeClassName(doc.body, "react-draggable-transparent-selection");
			if (doc.selection) doc.selection.empty();
			else {
				const selection = (doc.defaultView || window).getSelection();
				if (selection && selection.type !== "Caret") selection.removeAllRanges();
			}
		} catch (e) {}
	}
	function addClassName(el, className) {
		if (el.classList) el.classList.add(className);
		else if (!el.className.match(new RegExp(`(?:^|\\s)${className}(?!\\S)`))) el.className += ` ${className}`;
	}
	function removeClassName(el, className) {
		if (el.classList) el.classList.remove(className);
		else el.className = el.className.replace(new RegExp(`(?:^|\\s)${className}(?!\\S)`, "g"), "");
	}
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/utils/positionFns.js
var require_positionFns = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.canDragX = canDragX;
	exports.canDragY = canDragY;
	exports.createCoreData = createCoreData;
	exports.createDraggableData = createDraggableData;
	exports.getBoundPosition = getBoundPosition;
	exports.getControlPosition = getControlPosition;
	exports.snapToGrid = snapToGrid;
	var _shims = require_shims();
	var _domFns = require_domFns();
	function getBoundPosition(draggable, x, y) {
		if (!draggable.props.bounds) return [x, y];
		let { bounds } = draggable.props;
		bounds = typeof bounds === "string" ? bounds : cloneBounds(bounds);
		const node = findDOMNode(draggable);
		if (typeof bounds === "string") {
			const { ownerDocument } = node;
			const ownerWindow = ownerDocument.defaultView;
			let boundNode;
			if (bounds === "parent") boundNode = node.parentNode;
			else boundNode = node.getRootNode().querySelector(bounds);
			if (!(boundNode instanceof ownerWindow.HTMLElement)) throw new Error("Bounds selector \"" + bounds + "\" could not find an element.");
			const boundNodeEl = boundNode;
			const nodeStyle = ownerWindow.getComputedStyle(node);
			const boundNodeStyle = ownerWindow.getComputedStyle(boundNodeEl);
			bounds = {
				left: -node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingLeft) + (0, _shims.int)(nodeStyle.marginLeft),
				top: -node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingTop) + (0, _shims.int)(nodeStyle.marginTop),
				right: (0, _domFns.innerWidth)(boundNodeEl) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingRight) - (0, _shims.int)(nodeStyle.marginRight),
				bottom: (0, _domFns.innerHeight)(boundNodeEl) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingBottom) - (0, _shims.int)(nodeStyle.marginBottom)
			};
		}
		if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
		if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom);
		if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
		if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
		return [x, y];
	}
	function snapToGrid(grid, pendingX, pendingY) {
		return [Math.round(pendingX / grid[0]) * grid[0], Math.round(pendingY / grid[1]) * grid[1]];
	}
	function canDragX(draggable) {
		return draggable.props.axis === "both" || draggable.props.axis === "x";
	}
	function canDragY(draggable) {
		return draggable.props.axis === "both" || draggable.props.axis === "y";
	}
	function getControlPosition(e, touchIdentifier, draggableCore) {
		const touchObj = typeof touchIdentifier === "number" ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
		if (typeof touchIdentifier === "number" && !touchObj) return null;
		const node = findDOMNode(draggableCore);
		const offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
		return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
	}
	function createCoreData(draggable, x, y) {
		const isStart = !(0, _shims.isNum)(draggable.lastX);
		const node = findDOMNode(draggable);
		if (isStart) return {
			node,
			deltaX: 0,
			deltaY: 0,
			lastX: x,
			lastY: y,
			x,
			y
		};
		else return {
			node,
			deltaX: x - draggable.lastX,
			deltaY: y - draggable.lastY,
			lastX: draggable.lastX,
			lastY: draggable.lastY,
			x,
			y
		};
	}
	function createDraggableData(draggable, coreData) {
		const scale = draggable.props.scale;
		return {
			node: coreData.node,
			x: draggable.state.x + coreData.deltaX / scale,
			y: draggable.state.y + coreData.deltaY / scale,
			deltaX: coreData.deltaX / scale,
			deltaY: coreData.deltaY / scale,
			lastX: draggable.state.x,
			lastY: draggable.state.y
		};
	}
	function cloneBounds(bounds) {
		return {
			left: bounds.left,
			top: bounds.top,
			right: bounds.right,
			bottom: bounds.bottom
		};
	}
	function findDOMNode(draggable) {
		const node = draggable.findDOMNode();
		if (!node) throw new Error("<DraggableCore>: Unmounted during event!");
		return node;
	}
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/utils/log.js
var require_log = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.default = log;
	function log() {}
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/DraggableCore.js
var require_DraggableCore = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.default = void 0;
	var React = _interopRequireWildcard(require_react());
	var _propTypes = _interopRequireDefault(require_prop_types());
	var _reactDom = _interopRequireDefault(require_react_dom());
	var _domFns = require_domFns();
	var _positionFns = require_positionFns();
	var _shims = require_shims();
	var _log = _interopRequireDefault(require_log());
	function _interopRequireDefault(e) {
		return e && e.__esModule ? e : { default: e };
	}
	function _interopRequireWildcard(e, t) {
		if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
		return (_interopRequireWildcard = function(e, t) {
			if (!t && e && e.__esModule) return e;
			var o, i, f = {
				__proto__: null,
				default: e
			};
			if (null === e || "object" != typeof e && "function" != typeof e) return f;
			if (o = t ? n : r) {
				if (o.has(e)) return o.get(e);
				o.set(e, f);
			}
			for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
			return f;
		})(e, t);
	}
	function _defineProperty(e, r, t) {
		return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
			value: t,
			enumerable: !0,
			configurable: !0,
			writable: !0
		}) : e[r] = t, e;
	}
	function _toPropertyKey(t) {
		var i = _toPrimitive(t, "string");
		return "symbol" == typeof i ? i : i + "";
	}
	function _toPrimitive(t, r) {
		if ("object" != typeof t || !t) return t;
		var e = t[Symbol.toPrimitive];
		if (void 0 !== e) {
			var i = e.call(t, r || "default");
			if ("object" != typeof i) return i;
			throw new TypeError("@@toPrimitive must return a primitive value.");
		}
		return ("string" === r ? String : Number)(t);
	}
	var eventsFor = {
		touch: {
			start: "touchstart",
			move: "touchmove",
			stop: "touchend"
		},
		mouse: {
			start: "mousedown",
			move: "mousemove",
			stop: "mouseup"
		}
	};
	var dragEventFor = eventsFor.mouse;
	var DraggableCore = class extends React.Component {
		constructor() {
			super(...arguments);
			_defineProperty(this, "dragging", false);
			_defineProperty(this, "lastX", NaN);
			_defineProperty(this, "lastY", NaN);
			_defineProperty(this, "touchIdentifier", null);
			_defineProperty(this, "mounted", false);
			_defineProperty(this, "handleDragStart", (e) => {
				this.props.onMouseDown(e);
				if (!this.props.allowAnyClick && typeof e.button === "number" && e.button !== 0) return false;
				const thisNode = this.findDOMNode();
				if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) throw new Error("<DraggableCore> not mounted on DragStart!");
				const { ownerDocument } = thisNode;
				if (this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.handle, thisNode) || this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.cancel, thisNode)) return;
				if (e.type === "touchstart" && !this.props.allowMobileScroll) e.preventDefault();
				const touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
				this.touchIdentifier = touchIdentifier;
				const position = (0, _positionFns.getControlPosition)(e, touchIdentifier, this);
				if (position == null) return;
				const { x, y } = position;
				const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
				(0, _log.default)("DraggableCore: handleDragStart: %j", coreEvent);
				(0, _log.default)("calling", this.props.onStart);
				if (this.props.onStart(e, coreEvent) === false || this.mounted === false) return;
				if (this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
				this.dragging = true;
				this.lastX = x;
				this.lastY = y;
				(0, _domFns.addEvent)(ownerDocument, dragEventFor.move, this.handleDrag);
				(0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, this.handleDragStop);
			});
			_defineProperty(this, "handleDrag", (e) => {
				const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
				if (position == null) return;
				let { x, y } = position;
				if (Array.isArray(this.props.grid)) {
					let deltaX = x - this.lastX, deltaY = y - this.lastY;
					[deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
					if (!deltaX && !deltaY) return;
					x = this.lastX + deltaX, y = this.lastY + deltaY;
				}
				const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
				(0, _log.default)("DraggableCore: handleDrag: %j", coreEvent);
				if (this.props.onDrag(e, coreEvent) === false || this.mounted === false) {
					try {
						this.handleDragStop(new MouseEvent("mouseup"));
					} catch (err) {
						const event = document.createEvent("MouseEvents");
						event.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
						this.handleDragStop(event);
					}
					return;
				}
				this.lastX = x;
				this.lastY = y;
			});
			_defineProperty(this, "handleDragStop", (e) => {
				if (!this.dragging) return;
				const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
				if (position == null) return;
				let { x, y } = position;
				if (Array.isArray(this.props.grid)) {
					let deltaX = x - this.lastX || 0;
					let deltaY = y - this.lastY || 0;
					[deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
					x = this.lastX + deltaX, y = this.lastY + deltaY;
				}
				const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
				if (this.props.onStop(e, coreEvent) === false || this.mounted === false) return false;
				const thisNode = this.findDOMNode();
				if (thisNode) {
					if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(thisNode.ownerDocument);
				}
				(0, _log.default)("DraggableCore: handleDragStop: %j", coreEvent);
				this.dragging = false;
				this.lastX = NaN;
				this.lastY = NaN;
				if (thisNode) {
					(0, _log.default)("DraggableCore: Removing handlers");
					(0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, this.handleDrag);
					(0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, this.handleDragStop);
				}
			});
			_defineProperty(this, "onMouseDown", (e) => {
				dragEventFor = eventsFor.mouse;
				return this.handleDragStart(e);
			});
			_defineProperty(this, "onMouseUp", (e) => {
				dragEventFor = eventsFor.mouse;
				return this.handleDragStop(e);
			});
			_defineProperty(this, "onTouchStart", (e) => {
				dragEventFor = eventsFor.touch;
				return this.handleDragStart(e);
			});
			_defineProperty(this, "onTouchEnd", (e) => {
				dragEventFor = eventsFor.touch;
				return this.handleDragStop(e);
			});
		}
		componentDidMount() {
			this.mounted = true;
			const thisNode = this.findDOMNode();
			if (thisNode) (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
		}
		componentWillUnmount() {
			this.mounted = false;
			const thisNode = this.findDOMNode();
			if (thisNode) {
				const { ownerDocument } = thisNode;
				(0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
				(0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
				(0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
				(0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
				(0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
				if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(ownerDocument);
			}
		}
		findDOMNode() {
			return this.props?.nodeRef ? this.props?.nodeRef?.current : _reactDom.default.findDOMNode(this);
		}
		render() {
			return /* @__PURE__ */ React.cloneElement(React.Children.only(this.props.children), {
				onMouseDown: this.onMouseDown,
				onMouseUp: this.onMouseUp,
				onTouchEnd: this.onTouchEnd
			});
		}
	};
	exports.default = DraggableCore;
	_defineProperty(DraggableCore, "displayName", "DraggableCore");
	_defineProperty(DraggableCore, "propTypes", {
		allowAnyClick: _propTypes.default.bool,
		allowMobileScroll: _propTypes.default.bool,
		children: _propTypes.default.node.isRequired,
		disabled: _propTypes.default.bool,
		enableUserSelectHack: _propTypes.default.bool,
		offsetParent: function(props, propName) {
			if (props[propName] && props[propName].nodeType !== 1) throw new Error("Draggable's offsetParent must be a DOM Node.");
		},
		grid: _propTypes.default.arrayOf(_propTypes.default.number),
		handle: _propTypes.default.string,
		cancel: _propTypes.default.string,
		nodeRef: _propTypes.default.object,
		onStart: _propTypes.default.func,
		onDrag: _propTypes.default.func,
		onStop: _propTypes.default.func,
		onMouseDown: _propTypes.default.func,
		scale: _propTypes.default.number,
		className: _shims.dontSetMe,
		style: _shims.dontSetMe,
		transform: _shims.dontSetMe
	});
	_defineProperty(DraggableCore, "defaultProps", {
		allowAnyClick: false,
		allowMobileScroll: false,
		disabled: false,
		enableUserSelectHack: true,
		onStart: function() {},
		onDrag: function() {},
		onStop: function() {},
		onMouseDown: function() {},
		scale: 1
	});
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/Draggable.js
var require_Draggable = /* @__PURE__ */ __commonJSMin(((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	Object.defineProperty(exports, "DraggableCore", {
		enumerable: true,
		get: function() {
			return _DraggableCore.default;
		}
	});
	exports.default = void 0;
	var React = _interopRequireWildcard(require_react());
	var _propTypes = _interopRequireDefault(require_prop_types());
	var _reactDom = _interopRequireDefault(require_react_dom());
	var _clsx = require_clsx();
	var _domFns = require_domFns();
	var _positionFns = require_positionFns();
	var _shims = require_shims();
	var _DraggableCore = _interopRequireDefault(require_DraggableCore());
	var _log = _interopRequireDefault(require_log());
	function _interopRequireDefault(e) {
		return e && e.__esModule ? e : { default: e };
	}
	function _interopRequireWildcard(e, t) {
		if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
		return (_interopRequireWildcard = function(e, t) {
			if (!t && e && e.__esModule) return e;
			var o, i, f = {
				__proto__: null,
				default: e
			};
			if (null === e || "object" != typeof e && "function" != typeof e) return f;
			if (o = t ? n : r) {
				if (o.has(e)) return o.get(e);
				o.set(e, f);
			}
			for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
			return f;
		})(e, t);
	}
	function _extends() {
		return _extends = Object.assign ? Object.assign.bind() : function(n) {
			for (var e = 1; e < arguments.length; e++) {
				var t = arguments[e];
				for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
			}
			return n;
		}, _extends.apply(null, arguments);
	}
	function _defineProperty(e, r, t) {
		return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
			value: t,
			enumerable: !0,
			configurable: !0,
			writable: !0
		}) : e[r] = t, e;
	}
	function _toPropertyKey(t) {
		var i = _toPrimitive(t, "string");
		return "symbol" == typeof i ? i : i + "";
	}
	function _toPrimitive(t, r) {
		if ("object" != typeof t || !t) return t;
		var e = t[Symbol.toPrimitive];
		if (void 0 !== e) {
			var i = e.call(t, r || "default");
			if ("object" != typeof i) return i;
			throw new TypeError("@@toPrimitive must return a primitive value.");
		}
		return ("string" === r ? String : Number)(t);
	}
	var Draggable = class extends React.Component {
		static getDerivedStateFromProps(_ref, _ref2) {
			let { position } = _ref;
			let { prevPropsPosition } = _ref2;
			if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
				(0, _log.default)("Draggable: getDerivedStateFromProps %j", {
					position,
					prevPropsPosition
				});
				return {
					x: position.x,
					y: position.y,
					prevPropsPosition: { ...position }
				};
			}
			return null;
		}
		constructor(props) {
			super(props);
			_defineProperty(this, "onDragStart", (e, coreData) => {
				(0, _log.default)("Draggable: onDragStart: %j", coreData);
				if (this.props.onStart(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
				this.setState({
					dragging: true,
					dragged: true
				});
			});
			_defineProperty(this, "onDrag", (e, coreData) => {
				if (!this.state.dragging) return false;
				(0, _log.default)("Draggable: onDrag: %j", coreData);
				const uiData = (0, _positionFns.createDraggableData)(this, coreData);
				const newState = {
					x: uiData.x,
					y: uiData.y,
					slackX: 0,
					slackY: 0
				};
				if (this.props.bounds) {
					const { x, y } = newState;
					newState.x += this.state.slackX;
					newState.y += this.state.slackY;
					const [newStateX, newStateY] = (0, _positionFns.getBoundPosition)(this, newState.x, newState.y);
					newState.x = newStateX;
					newState.y = newStateY;
					newState.slackX = this.state.slackX + (x - newState.x);
					newState.slackY = this.state.slackY + (y - newState.y);
					uiData.x = newState.x;
					uiData.y = newState.y;
					uiData.deltaX = newState.x - this.state.x;
					uiData.deltaY = newState.y - this.state.y;
				}
				if (this.props.onDrag(e, uiData) === false) return false;
				this.setState(newState);
			});
			_defineProperty(this, "onDragStop", (e, coreData) => {
				if (!this.state.dragging) return false;
				if (this.props.onStop(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
				(0, _log.default)("Draggable: onDragStop: %j", coreData);
				const newState = {
					dragging: false,
					slackX: 0,
					slackY: 0
				};
				if (Boolean(this.props.position)) {
					const { x, y } = this.props.position;
					newState.x = x;
					newState.y = y;
				}
				this.setState(newState);
			});
			this.state = {
				dragging: false,
				dragged: false,
				x: props.position ? props.position.x : props.defaultPosition.x,
				y: props.position ? props.position.y : props.defaultPosition.y,
				prevPropsPosition: { ...props.position },
				slackX: 0,
				slackY: 0,
				isElementSVG: false
			};
			if (props.position && !(props.onDrag || props.onStop)) console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.");
		}
		componentDidMount() {
			if (typeof window.SVGElement !== "undefined" && this.findDOMNode() instanceof window.SVGElement) this.setState({ isElementSVG: true });
		}
		componentWillUnmount() {
			if (this.state.dragging) this.setState({ dragging: false });
		}
		findDOMNode() {
			return this.props?.nodeRef?.current ?? _reactDom.default.findDOMNode(this);
		}
		render() {
			const { axis, bounds, children, defaultPosition, defaultClassName, defaultClassNameDragging, defaultClassNameDragged, position, positionOffset, scale, ...draggableCoreProps } = this.props;
			let style = {};
			let svgTransform = null;
			const draggable = !Boolean(position) || this.state.dragging;
			const validPosition = position || defaultPosition;
			const transformOpts = {
				x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
				y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
			};
			if (this.state.isElementSVG) svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
			else style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
			const className = (0, _clsx.clsx)(children.props.className || "", defaultClassName, {
				[defaultClassNameDragging]: this.state.dragging,
				[defaultClassNameDragged]: this.state.dragged
			});
			return /* @__PURE__ */ React.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
				onStart: this.onDragStart,
				onDrag: this.onDrag,
				onStop: this.onDragStop
			}), /* @__PURE__ */ React.cloneElement(React.Children.only(children), {
				className,
				style: {
					...children.props.style,
					...style
				},
				transform: svgTransform
			}));
		}
	};
	exports.default = Draggable;
	_defineProperty(Draggable, "displayName", "Draggable");
	_defineProperty(Draggable, "propTypes", {
		..._DraggableCore.default.propTypes,
		axis: _propTypes.default.oneOf([
			"both",
			"x",
			"y",
			"none"
		]),
		bounds: _propTypes.default.oneOfType([
			_propTypes.default.shape({
				left: _propTypes.default.number,
				right: _propTypes.default.number,
				top: _propTypes.default.number,
				bottom: _propTypes.default.number
			}),
			_propTypes.default.string,
			_propTypes.default.oneOf([false])
		]),
		defaultClassName: _propTypes.default.string,
		defaultClassNameDragging: _propTypes.default.string,
		defaultClassNameDragged: _propTypes.default.string,
		defaultPosition: _propTypes.default.shape({
			x: _propTypes.default.number,
			y: _propTypes.default.number
		}),
		positionOffset: _propTypes.default.shape({
			x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
			y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
		}),
		position: _propTypes.default.shape({
			x: _propTypes.default.number,
			y: _propTypes.default.number
		}),
		className: _shims.dontSetMe,
		style: _shims.dontSetMe,
		transform: _shims.dontSetMe
	});
	_defineProperty(Draggable, "defaultProps", {
		..._DraggableCore.default.defaultProps,
		axis: "both",
		bounds: false,
		defaultClassName: "react-draggable",
		defaultClassNameDragging: "react-draggable-dragging",
		defaultClassNameDragged: "react-draggable-dragged",
		defaultPosition: {
			x: 0,
			y: 0
		},
		scale: 1
	});
}));
//#endregion
//#region ../../node_modules/react-draggable/build/cjs/cjs.js
var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	var { default: Draggable, DraggableCore } = require_Draggable();
	module.exports = Draggable;
	module.exports.default = Draggable;
	module.exports.DraggableCore = DraggableCore;
}));
//#endregion
//#region ../../node_modules/react-resizable/build/utils.js
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.__esModule = true;
	exports.cloneElement = cloneElement;
	var _react = _interopRequireDefault(require_react());
	function _interopRequireDefault(e) {
		return e && e.__esModule ? e : { default: e };
	}
	function ownKeys(e, r) {
		var t = Object.keys(e);
		if (Object.getOwnPropertySymbols) {
			var o = Object.getOwnPropertySymbols(e);
			r && (o = o.filter(function(r) {
				return Object.getOwnPropertyDescriptor(e, r).enumerable;
			})), t.push.apply(t, o);
		}
		return t;
	}
	function _objectSpread(e) {
		for (var r = 1; r < arguments.length; r++) {
			var t = null != arguments[r] ? arguments[r] : {};
			r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
				_defineProperty(e, r, t[r]);
			}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
				Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
			});
		}
		return e;
	}
	function _defineProperty(e, r, t) {
		return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
			value: t,
			enumerable: !0,
			configurable: !0,
			writable: !0
		}) : e[r] = t, e;
	}
	function _toPropertyKey(t) {
		var i = _toPrimitive(t, "string");
		return "symbol" == typeof i ? i : i + "";
	}
	function _toPrimitive(t, r) {
		if ("object" != typeof t || !t) return t;
		var e = t[Symbol.toPrimitive];
		if (void 0 !== e) {
			var i = e.call(t, r || "default");
			if ("object" != typeof i) return i;
			throw new TypeError("@@toPrimitive must return a primitive value.");
		}
		return ("string" === r ? String : Number)(t);
	}
	function cloneElement(element, props) {
		if (props.style && element.props.style) props.style = _objectSpread(_objectSpread({}, element.props.style), props.style);
		if (props.className && element.props.className) props.className = `${element.props.className} ${props.className}`;
		return /* @__PURE__ */ _react.default.cloneElement(element, props);
	}
}));
//#endregion
//#region ../../node_modules/react-resizable/build/propTypes.js
var require_propTypes = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.__esModule = true;
	exports.resizableProps = void 0;
	var _propTypes = _interopRequireDefault(require_prop_types());
	require_cjs();
	function _interopRequireDefault(e) {
		return e && e.__esModule ? e : { default: e };
	}
	exports.resizableProps = {
		axis: _propTypes.default.oneOf([
			"both",
			"x",
			"y",
			"none"
		]),
		className: _propTypes.default.string,
		children: _propTypes.default.element.isRequired,
		draggableOpts: _propTypes.default.shape({
			allowAnyClick: _propTypes.default.bool,
			cancel: _propTypes.default.string,
			children: _propTypes.default.node,
			disabled: _propTypes.default.bool,
			enableUserSelectHack: _propTypes.default.bool,
			offsetParent: typeof Element !== "undefined" ? _propTypes.default.instanceOf(Element) : _propTypes.default.any,
			grid: _propTypes.default.arrayOf(_propTypes.default.number),
			handle: _propTypes.default.string,
			nodeRef: _propTypes.default.object,
			onStart: _propTypes.default.func,
			onDrag: _propTypes.default.func,
			onStop: _propTypes.default.func,
			onMouseDown: _propTypes.default.func,
			scale: _propTypes.default.number
		}),
		height: function() {
			for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
			const [props] = args;
			if (props.axis === "both" || props.axis === "y") return _propTypes.default.number.isRequired(...args);
			return _propTypes.default.number(...args);
		},
		handle: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
		handleSize: _propTypes.default.arrayOf(_propTypes.default.number),
		lockAspectRatio: _propTypes.default.bool,
		maxConstraints: _propTypes.default.arrayOf(_propTypes.default.number),
		minConstraints: _propTypes.default.arrayOf(_propTypes.default.number),
		onResizeStop: _propTypes.default.func,
		onResizeStart: _propTypes.default.func,
		onResize: _propTypes.default.func,
		resizeHandles: _propTypes.default.arrayOf(_propTypes.default.oneOf([
			"s",
			"w",
			"e",
			"n",
			"sw",
			"nw",
			"se",
			"ne"
		])),
		transformScale: _propTypes.default.number,
		width: function() {
			for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) args[_key2] = arguments[_key2];
			const [props] = args;
			if (props.axis === "both" || props.axis === "x") return _propTypes.default.number.isRequired(...args);
			return _propTypes.default.number(...args);
		}
	};
}));
//#endregion
//#region ../../node_modules/react-resizable/build/Resizable.js
var require_Resizable = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.__esModule = true;
	exports.default = void 0;
	var React = _interopRequireWildcard(require_react());
	var _reactDraggable = require_cjs();
	var _utils = require_utils();
	var _propTypes = require_propTypes();
	var _excluded = [
		"children",
		"className",
		"draggableOpts",
		"width",
		"height",
		"handle",
		"handleSize",
		"lockAspectRatio",
		"axis",
		"minConstraints",
		"maxConstraints",
		"onResize",
		"onResizeStop",
		"onResizeStart",
		"resizeHandles",
		"transformScale"
	];
	function _interopRequireWildcard(e, t) {
		if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
		return (_interopRequireWildcard = function(e, t) {
			if (!t && e && e.__esModule) return e;
			var o, i, f = {
				__proto__: null,
				default: e
			};
			if (null === e || "object" != typeof e && "function" != typeof e) return f;
			if (o = t ? n : r) {
				if (o.has(e)) return o.get(e);
				o.set(e, f);
			}
			for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
			return f;
		})(e, t);
	}
	function _extends() {
		return _extends = Object.assign ? Object.assign.bind() : function(n) {
			for (var e = 1; e < arguments.length; e++) {
				var t = arguments[e];
				for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
			}
			return n;
		}, _extends.apply(null, arguments);
	}
	function _objectWithoutProperties(e, t) {
		if (null == e) return {};
		var o, r, i = _objectWithoutPropertiesLoose(e, t);
		if (Object.getOwnPropertySymbols) {
			var n = Object.getOwnPropertySymbols(e);
			for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
		}
		return i;
	}
	function _objectWithoutPropertiesLoose(r, e) {
		if (null == r) return {};
		var t = {};
		for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
			if (-1 !== e.indexOf(n)) continue;
			t[n] = r[n];
		}
		return t;
	}
	function ownKeys(e, r) {
		var t = Object.keys(e);
		if (Object.getOwnPropertySymbols) {
			var o = Object.getOwnPropertySymbols(e);
			r && (o = o.filter(function(r) {
				return Object.getOwnPropertyDescriptor(e, r).enumerable;
			})), t.push.apply(t, o);
		}
		return t;
	}
	function _objectSpread(e) {
		for (var r = 1; r < arguments.length; r++) {
			var t = null != arguments[r] ? arguments[r] : {};
			r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
				_defineProperty(e, r, t[r]);
			}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
				Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
			});
		}
		return e;
	}
	function _defineProperty(e, r, t) {
		return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
			value: t,
			enumerable: !0,
			configurable: !0,
			writable: !0
		}) : e[r] = t, e;
	}
	function _toPropertyKey(t) {
		var i = _toPrimitive(t, "string");
		return "symbol" == typeof i ? i : i + "";
	}
	function _toPrimitive(t, r) {
		if ("object" != typeof t || !t) return t;
		var e = t[Symbol.toPrimitive];
		if (void 0 !== e) {
			var i = e.call(t, r || "default");
			if ("object" != typeof i) return i;
			throw new TypeError("@@toPrimitive must return a primitive value.");
		}
		return ("string" === r ? String : Number)(t);
	}
	var Resizable = class extends React.Component {
		constructor() {
			super(...arguments);
			this.handleRefs = {};
			this.lastHandleRect = null;
			this.slack = null;
			this.lastSize = null;
		}
		componentWillUnmount() {
			this.resetData();
		}
		resetData() {
			this.lastHandleRect = this.slack = this.lastSize = null;
		}
		runConstraints(width, height) {
			const { minConstraints, maxConstraints, lockAspectRatio } = this.props;
			if (!minConstraints && !maxConstraints && !lockAspectRatio) return [width, height];
			if (lockAspectRatio) {
				const ratio = this.props.width / this.props.height;
				const deltaW = width - this.props.width;
				const deltaH = height - this.props.height;
				if (Math.abs(deltaW) > Math.abs(deltaH * ratio)) height = width / ratio;
				else width = height * ratio;
			}
			const [oldW, oldH] = [width, height];
			let [slackW, slackH] = this.slack || [0, 0];
			width += slackW;
			height += slackH;
			if (minConstraints) {
				width = Math.max(minConstraints[0], width);
				height = Math.max(minConstraints[1], height);
			}
			if (maxConstraints) {
				width = Math.min(maxConstraints[0], width);
				height = Math.min(maxConstraints[1], height);
			}
			this.slack = [slackW + (oldW - width), slackH + (oldH - height)];
			return [width, height];
		}
		/**
		* Wrapper around drag events to provide more useful data.
		*
		* @param  {String} handlerName Handler name to wrap.
		* @return {Function}           Handler function.
		*/
		resizeHandler(handlerName, axis) {
			return (e, _ref) => {
				let { node, deltaX, deltaY } = _ref;
				if (handlerName === "onResizeStart") this.resetData();
				const canDragX = (this.props.axis === "both" || this.props.axis === "x") && axis !== "n" && axis !== "s";
				const canDragY = (this.props.axis === "both" || this.props.axis === "y") && axis !== "e" && axis !== "w";
				if (!canDragX && !canDragY) return;
				const axisV = axis[0];
				const axisH = axis[axis.length - 1];
				const handleRect = node.getBoundingClientRect();
				if (this.lastHandleRect != null) {
					if (axisH === "w") {
						const deltaLeftSinceLast = handleRect.left - this.lastHandleRect.left;
						deltaX += deltaLeftSinceLast;
					}
					if (axisV === "n") {
						const deltaTopSinceLast = handleRect.top - this.lastHandleRect.top;
						deltaY += deltaTopSinceLast;
					}
				}
				this.lastHandleRect = handleRect;
				if (axisH === "w") deltaX = -deltaX;
				if (axisV === "n") deltaY = -deltaY;
				let width = this.props.width + (canDragX ? deltaX / this.props.transformScale : 0);
				let height = this.props.height + (canDragY ? deltaY / this.props.transformScale : 0);
				[width, height] = this.runConstraints(width, height);
				if (handlerName === "onResizeStop" && this.lastSize) ({width, height} = this.lastSize);
				const dimensionsChanged = width !== this.props.width || height !== this.props.height;
				if (handlerName !== "onResizeStop") this.lastSize = {
					width,
					height
				};
				const cb = typeof this.props[handlerName] === "function" ? this.props[handlerName] : null;
				if (cb && !(handlerName === "onResize" && !dimensionsChanged)) {
					e.persist?.();
					cb(e, {
						node,
						size: {
							width,
							height
						},
						handle: axis
					});
				}
				if (handlerName === "onResizeStop") this.resetData();
			};
		}
		renderResizeHandle(handleAxis, ref) {
			const { handle } = this.props;
			if (!handle) return /* @__PURE__ */ React.createElement("span", {
				className: `react-resizable-handle react-resizable-handle-${handleAxis}`,
				ref
			});
			if (typeof handle === "function") return handle(handleAxis, ref);
			const isDOMElement = typeof handle.type === "string";
			const props = _objectSpread({ ref }, isDOMElement ? {} : { handleAxis });
			return /* @__PURE__ */ React.cloneElement(handle, props);
		}
		render() {
			const _this$props = this.props, { children, className, draggableOpts, width, height, handle, handleSize, lockAspectRatio, axis, minConstraints, maxConstraints, onResize, onResizeStop, onResizeStart, resizeHandles, transformScale } = _this$props, p = _objectWithoutProperties(_this$props, _excluded);
			return (0, _utils.cloneElement)(children, _objectSpread(_objectSpread({}, p), {}, {
				className: `${className ? `${className} ` : ""}react-resizable`,
				children: [...React.Children.toArray(children.props.children), ...resizeHandles.map((handleAxis) => {
					const ref = this.handleRefs[handleAxis] ?? (this.handleRefs[handleAxis] = /* @__PURE__ */ React.createRef());
					return /* @__PURE__ */ React.createElement(_reactDraggable.DraggableCore, _extends({}, draggableOpts, {
						nodeRef: ref,
						key: `resizableHandle-${handleAxis}`,
						onStop: this.resizeHandler("onResizeStop", handleAxis),
						onStart: this.resizeHandler("onResizeStart", handleAxis),
						onDrag: this.resizeHandler("onResize", handleAxis)
					}), this.renderResizeHandle(handleAxis, ref));
				})]
			}));
		}
	};
	exports.default = Resizable;
	Resizable.propTypes = _propTypes.resizableProps;
	Resizable.defaultProps = {
		axis: "both",
		handleSize: [20, 20],
		lockAspectRatio: false,
		minConstraints: [20, 20],
		maxConstraints: [Infinity, Infinity],
		resizeHandles: ["se"],
		transformScale: 1
	};
}));
//#endregion
//#region ../../node_modules/react-resizable/build/ResizableBox.js
var require_ResizableBox = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.__esModule = true;
	exports.default = void 0;
	var React = _interopRequireWildcard(require_react());
	var _propTypes = _interopRequireDefault(require_prop_types());
	var _Resizable = _interopRequireDefault(require_Resizable());
	var _propTypes2 = require_propTypes();
	var _excluded = [
		"handle",
		"handleSize",
		"onResize",
		"onResizeStart",
		"onResizeStop",
		"draggableOpts",
		"minConstraints",
		"maxConstraints",
		"lockAspectRatio",
		"axis",
		"width",
		"height",
		"resizeHandles",
		"style",
		"transformScale"
	];
	function _interopRequireDefault(e) {
		return e && e.__esModule ? e : { default: e };
	}
	function _interopRequireWildcard(e, t) {
		if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
		return (_interopRequireWildcard = function(e, t) {
			if (!t && e && e.__esModule) return e;
			var o, i, f = {
				__proto__: null,
				default: e
			};
			if (null === e || "object" != typeof e && "function" != typeof e) return f;
			if (o = t ? n : r) {
				if (o.has(e)) return o.get(e);
				o.set(e, f);
			}
			for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
			return f;
		})(e, t);
	}
	function _extends() {
		return _extends = Object.assign ? Object.assign.bind() : function(n) {
			for (var e = 1; e < arguments.length; e++) {
				var t = arguments[e];
				for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
			}
			return n;
		}, _extends.apply(null, arguments);
	}
	function ownKeys(e, r) {
		var t = Object.keys(e);
		if (Object.getOwnPropertySymbols) {
			var o = Object.getOwnPropertySymbols(e);
			r && (o = o.filter(function(r) {
				return Object.getOwnPropertyDescriptor(e, r).enumerable;
			})), t.push.apply(t, o);
		}
		return t;
	}
	function _objectSpread(e) {
		for (var r = 1; r < arguments.length; r++) {
			var t = null != arguments[r] ? arguments[r] : {};
			r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
				_defineProperty(e, r, t[r]);
			}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
				Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
			});
		}
		return e;
	}
	function _defineProperty(e, r, t) {
		return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
			value: t,
			enumerable: !0,
			configurable: !0,
			writable: !0
		}) : e[r] = t, e;
	}
	function _toPropertyKey(t) {
		var i = _toPrimitive(t, "string");
		return "symbol" == typeof i ? i : i + "";
	}
	function _toPrimitive(t, r) {
		if ("object" != typeof t || !t) return t;
		var e = t[Symbol.toPrimitive];
		if (void 0 !== e) {
			var i = e.call(t, r || "default");
			if ("object" != typeof i) return i;
			throw new TypeError("@@toPrimitive must return a primitive value.");
		}
		return ("string" === r ? String : Number)(t);
	}
	function _objectWithoutProperties(e, t) {
		if (null == e) return {};
		var o, r, i = _objectWithoutPropertiesLoose(e, t);
		if (Object.getOwnPropertySymbols) {
			var n = Object.getOwnPropertySymbols(e);
			for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
		}
		return i;
	}
	function _objectWithoutPropertiesLoose(r, e) {
		if (null == r) return {};
		var t = {};
		for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
			if (-1 !== e.indexOf(n)) continue;
			t[n] = r[n];
		}
		return t;
	}
	var ResizableBox = class extends React.Component {
		constructor() {
			super(...arguments);
			this.state = {
				width: this.props.width,
				height: this.props.height,
				propsWidth: this.props.width,
				propsHeight: this.props.height
			};
			this.onResize = (e, data) => {
				const { size } = data;
				if (this.props.onResize) {
					e.persist?.();
					this.setState(size, () => this.props.onResize && this.props.onResize(e, data));
				} else this.setState(size);
			};
		}
		static getDerivedStateFromProps(props, state) {
			if (state.propsWidth !== props.width || state.propsHeight !== props.height) return {
				width: props.width,
				height: props.height,
				propsWidth: props.width,
				propsHeight: props.height
			};
			return null;
		}
		render() {
			const _this$props = this.props, { handle, handleSize, onResize, onResizeStart, onResizeStop, draggableOpts, minConstraints, maxConstraints, lockAspectRatio, axis, width, height, resizeHandles, style, transformScale } = _this$props, props = _objectWithoutProperties(_this$props, _excluded);
			return /* @__PURE__ */ React.createElement(_Resizable.default, {
				axis,
				draggableOpts,
				handle,
				handleSize,
				height: this.state.height,
				lockAspectRatio,
				maxConstraints,
				minConstraints,
				onResizeStart,
				onResize: this.onResize,
				onResizeStop,
				resizeHandles,
				transformScale,
				width: this.state.width
			}, /* @__PURE__ */ React.createElement("div", _extends({}, props, { style: _objectSpread(_objectSpread({}, style), {}, {
				width: this.state.width + "px",
				height: this.state.height + "px"
			}) })));
		}
	};
	exports.default = ResizableBox;
	ResizableBox.propTypes = _objectSpread(_objectSpread({}, _propTypes2.resizableProps), {}, { children: _propTypes.default.element });
}));
//#endregion
//#region ../../node_modules/react-resizable/index.js
var require_react_resizable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	module.exports = function() {
		throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable");
	};
	module.exports.Resizable = require_Resizable().default;
	module.exports.ResizableBox = require_ResizableBox().default;
}));
//#endregion
//#region ../../node_modules/react-grid-layout/dist/chunk-WGL5FSZH.mjs
var import_cjs = require_cjs();
var import_react_resizable = require_react_resizable();
var import_fast_equals = require_fast_equals();
function GridItem(props) {
	const { children, cols, containerWidth, margin, containerPadding, rowHeight, maxRows, isDraggable, isResizable, isBounded, static: isStatic, useCSSTransforms = true, usePercentages = false, transformScale = 1, positionStrategy, dragThreshold = 0, droppingPosition, className = "", style, handle = "", cancel = "", x, y, w, h, minW = 1, maxW = Infinity, minH = 1, maxH = Infinity, i, resizeHandles, resizeHandle, constraints = defaultConstraints, layoutItem, layout = [], onDragStart: onDragStartProp, onDrag: onDragProp, onDragStop: onDragStopProp, onResizeStart: onResizeStartProp, onResize: onResizeProp, onResizeStop: onResizeStopProp } = props;
	const [dragging, setDragging] = (0, import_react.useState)(false);
	const [resizing, setResizing] = (0, import_react.useState)(false);
	const elementRef = (0, import_react.useRef)(null);
	const dragPositionRef = (0, import_react.useRef)({
		left: 0,
		top: 0
	});
	const resizePositionRef = (0, import_react.useRef)({
		top: 0,
		left: 0,
		width: 0,
		height: 0
	});
	const prevDroppingPositionRef = (0, import_react.useRef)(void 0);
	const layoutRef = (0, import_react.useRef)(layout);
	layoutRef.current = layout;
	const onDragStartRef = (0, import_react.useRef)(null);
	const onDragRef = (0, import_react.useRef)(null);
	const dragPendingRef = (0, import_react.useRef)(false);
	const initialDragClientRef = (0, import_react.useRef)({
		x: 0,
		y: 0
	});
	const thresholdExceededRef = (0, import_react.useRef)(false);
	const positionParams = (0, import_react.useMemo)(() => ({
		cols,
		containerPadding,
		containerWidth,
		margin,
		maxRows,
		rowHeight
	}), [
		cols,
		containerPadding,
		containerWidth,
		margin,
		maxRows,
		rowHeight
	]);
	const constraintContext = (0, import_react.useMemo)(() => ({
		cols,
		maxRows,
		containerWidth,
		containerHeight: 0,
		rowHeight,
		margin,
		layout: []
	}), [
		cols,
		maxRows,
		containerWidth,
		rowHeight,
		margin
	]);
	const getConstraintContext = (0, import_react.useCallback)(() => ({
		...constraintContext,
		layout: layoutRef.current
	}), [constraintContext]);
	const effectiveLayoutItem = (0, import_react.useMemo)(() => layoutItem ?? {
		i,
		x,
		y,
		w,
		h,
		minW,
		maxW,
		minH,
		maxH
	}, [
		layoutItem,
		i,
		x,
		y,
		w,
		h,
		minW,
		maxW,
		minH,
		maxH
	]);
	const createStyle = (0, import_react.useCallback)((pos2) => {
		if (positionStrategy?.calcStyle) return positionStrategy.calcStyle(pos2);
		if (useCSSTransforms) return setTransform(pos2);
		const styleObj = setTopLeft(pos2);
		if (usePercentages) return {
			...styleObj,
			left: perc(pos2.left / containerWidth),
			width: perc(pos2.width / containerWidth)
		};
		return styleObj;
	}, [
		positionStrategy,
		useCSSTransforms,
		usePercentages,
		containerWidth
	]);
	const onDragStart = (0, import_react.useCallback)((e, { node }) => {
		if (!onDragStartProp) return;
		const { offsetParent } = node;
		if (!offsetParent) return;
		const parentRect = offsetParent.getBoundingClientRect();
		const clientRect = node.getBoundingClientRect();
		const cLeft = clientRect.left / transformScale;
		const pLeft = parentRect.left / transformScale;
		const cTop = clientRect.top / transformScale;
		const pTop = parentRect.top / transformScale;
		let newPosition;
		if (positionStrategy?.calcDragPosition) {
			const mouseEvent = e;
			newPosition = positionStrategy.calcDragPosition(mouseEvent.clientX, mouseEvent.clientY, mouseEvent.clientX - clientRect.left, mouseEvent.clientY - clientRect.top);
		} else newPosition = {
			left: cLeft - pLeft + offsetParent.scrollLeft,
			top: cTop - pTop + offsetParent.scrollTop
		};
		dragPositionRef.current = newPosition;
		if (dragThreshold > 0) {
			const mouseEvent = e;
			initialDragClientRef.current = {
				x: mouseEvent.clientX,
				y: mouseEvent.clientY
			};
			dragPendingRef.current = true;
			thresholdExceededRef.current = false;
			setDragging(true);
			return;
		}
		setDragging(true);
		const rawPos = calcXYRaw(positionParams, newPosition.top, newPosition.left);
		const { x: newX, y: newY } = applyPositionConstraints(constraints, effectiveLayoutItem, rawPos.x, rawPos.y, getConstraintContext());
		onDragStartProp(i, newX, newY, {
			e,
			node,
			newPosition
		});
	}, [
		onDragStartProp,
		transformScale,
		positionParams,
		positionStrategy,
		dragThreshold,
		constraints,
		effectiveLayoutItem,
		getConstraintContext,
		i
	]);
	const onDrag = (0, import_react.useCallback)((e, { node, deltaX, deltaY }) => {
		if (!onDragProp || !dragging) return;
		const mouseEvent = e;
		if (dragPendingRef.current && !thresholdExceededRef.current) {
			const dx = mouseEvent.clientX - initialDragClientRef.current.x;
			const dy = mouseEvent.clientY - initialDragClientRef.current.y;
			if (Math.hypot(dx, dy) < dragThreshold) return;
			thresholdExceededRef.current = true;
			dragPendingRef.current = false;
			if (onDragStartProp) {
				const rawPos2 = calcXYRaw(positionParams, dragPositionRef.current.top, dragPositionRef.current.left);
				const { x: startX, y: startY } = applyPositionConstraints(constraints, effectiveLayoutItem, rawPos2.x, rawPos2.y, getConstraintContext());
				onDragStartProp(i, startX, startY, {
					e,
					node,
					newPosition: dragPositionRef.current
				});
			}
		}
		let top = dragPositionRef.current.top + deltaY;
		let left = dragPositionRef.current.left + deltaX;
		if (isBounded) {
			const { offsetParent } = node;
			if (offsetParent) {
				const bottomBoundary = offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
				top = clamp$1(top, 0, bottomBoundary);
				const rightBoundary = containerWidth - calcGridItemWHPx(w, calcGridColWidth(positionParams), margin[0]);
				left = clamp$1(left, 0, rightBoundary);
			}
		}
		const newPosition = {
			top,
			left
		};
		dragPositionRef.current = newPosition;
		const rawPos = calcXYRaw(positionParams, top, left);
		const { x: newX, y: newY } = applyPositionConstraints(constraints, effectiveLayoutItem, rawPos.x, rawPos.y, getConstraintContext());
		onDragProp(i, newX, newY, {
			e,
			node,
			newPosition
		});
	}, [
		onDragProp,
		onDragStartProp,
		dragging,
		dragThreshold,
		isBounded,
		h,
		rowHeight,
		margin,
		positionParams,
		containerWidth,
		w,
		i,
		constraints,
		effectiveLayoutItem,
		getConstraintContext
	]);
	const onDragStop = (0, import_react.useCallback)((e, { node }) => {
		if (!onDragStopProp || !dragging) return;
		const wasPending = dragPendingRef.current;
		dragPendingRef.current = false;
		thresholdExceededRef.current = false;
		initialDragClientRef.current = {
			x: 0,
			y: 0
		};
		if (wasPending) {
			setDragging(false);
			dragPositionRef.current = {
				left: 0,
				top: 0
			};
			return;
		}
		const { left, top } = dragPositionRef.current;
		const newPosition = {
			top,
			left
		};
		setDragging(false);
		dragPositionRef.current = {
			left: 0,
			top: 0
		};
		const rawPos = calcXYRaw(positionParams, top, left);
		const { x: newX, y: newY } = applyPositionConstraints(constraints, effectiveLayoutItem, rawPos.x, rawPos.y, getConstraintContext());
		onDragStopProp(i, newX, newY, {
			e,
			node,
			newPosition
		});
	}, [
		onDragStopProp,
		dragging,
		positionParams,
		constraints,
		effectiveLayoutItem,
		getConstraintContext,
		i
	]);
	onDragStartRef.current = onDragStart;
	onDragRef.current = onDrag;
	const onResizeHandler = (0, import_react.useCallback)((e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
		const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
		if (!handler) return;
		let updatedSize;
		if (node) updatedSize = resizeItemInDirection(resizeHandle2, position, size, containerWidth);
		else updatedSize = {
			...size,
			top: position.top,
			left: position.left
		};
		resizePositionRef.current = updatedSize;
		const rawSize = calcWHRaw(positionParams, updatedSize.width, updatedSize.height);
		const { w: newW, h: newH } = applySizeConstraints(constraints, effectiveLayoutItem, rawSize.w, rawSize.h, resizeHandle2, getConstraintContext());
		handler(i, newW, newH, {
			e: e.nativeEvent,
			node,
			size: updatedSize,
			handle: resizeHandle2
		});
	}, [
		onResizeStartProp,
		onResizeProp,
		onResizeStopProp,
		containerWidth,
		positionParams,
		i,
		constraints,
		effectiveLayoutItem,
		getConstraintContext
	]);
	const handleResizeStart = (0, import_react.useCallback)((e, data) => {
		setResizing(true);
		const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
		onResizeHandler(e, {
			...data,
			handle: data.handle
		}, pos2, "onResizeStart");
	}, [
		onResizeHandler,
		positionParams,
		x,
		y,
		w,
		h
	]);
	const handleResize = (0, import_react.useCallback)((e, data) => {
		const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
		onResizeHandler(e, {
			...data,
			handle: data.handle
		}, pos2, "onResize");
	}, [
		onResizeHandler,
		positionParams,
		x,
		y,
		w,
		h
	]);
	const handleResizeStop = (0, import_react.useCallback)((e, data) => {
		setResizing(false);
		resizePositionRef.current = {
			top: 0,
			left: 0,
			width: 0,
			height: 0
		};
		const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
		onResizeHandler(e, {
			...data,
			handle: data.handle
		}, pos2, "onResizeStop");
	}, [
		onResizeHandler,
		positionParams,
		x,
		y,
		w,
		h
	]);
	(0, import_react.useEffect)(() => {
		if (!droppingPosition) return;
		const node = elementRef.current;
		if (!node) return;
		const prevDroppingPosition = prevDroppingPositionRef.current || {
			left: 0,
			top: 0
		};
		const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
		if (!dragging) {
			const fakeData = {
				node,
				deltaX: droppingPosition.left,
				deltaY: droppingPosition.top,
				lastX: 0,
				lastY: 0,
				x: droppingPosition.left,
				y: droppingPosition.top
			};
			onDragStartRef.current?.(droppingPosition.e, fakeData);
		} else if (shouldDrag) {
			const fakeData = {
				node,
				deltaX: droppingPosition.left - dragPositionRef.current.left,
				deltaY: droppingPosition.top - dragPositionRef.current.top,
				lastX: dragPositionRef.current.left,
				lastY: dragPositionRef.current.top,
				x: droppingPosition.left,
				y: droppingPosition.top
			};
			onDragRef.current?.(droppingPosition.e, fakeData);
		}
		prevDroppingPositionRef.current = droppingPosition;
	}, [
		droppingPosition,
		dragging,
		i
	]);
	const pos = calcGridItemPosition(positionParams, x, y, w, h, dragging ? dragPositionRef.current : null, resizing ? resizePositionRef.current : null);
	const child = import_react.Children.only(children);
	const colWidth = calcGridColWidth(positionParams);
	const minConstraints = [calcGridItemWHPx(minW, colWidth, margin[0]), calcGridItemWHPx(minH, rowHeight, margin[1])];
	const maxConstraints = [calcGridItemWHPx(maxW, colWidth, margin[0]), calcGridItemWHPx(maxH, rowHeight, margin[1])];
	const childProps = child.props;
	const childClassName = childProps["className"];
	const childStyle = childProps["style"];
	let newChild = import_react.cloneElement(child, {
		ref: elementRef,
		className: clsx("react-grid-item", childClassName, className, {
			static: isStatic,
			resizing,
			"react-draggable": isDraggable,
			"react-draggable-dragging": dragging,
			dropping: Boolean(droppingPosition),
			cssTransforms: useCSSTransforms
		}),
		style: {
			...style,
			...childStyle,
			...createStyle(pos)
		}
	});
	const resizableHandle = resizeHandle;
	newChild = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable.Resizable, {
		draggableOpts: { disabled: !isResizable },
		className: isResizable ? void 0 : "react-resizable-hide",
		width: pos.width,
		height: pos.height,
		minConstraints,
		maxConstraints,
		onResizeStart: handleResizeStart,
		onResize: handleResize,
		onResizeStop: handleResizeStop,
		transformScale,
		resizeHandles,
		handle: resizableHandle,
		children: newChild
	});
	newChild = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cjs.DraggableCore, {
		disabled: !isDraggable,
		onStart: onDragStart,
		onDrag,
		onStop: onDragStop,
		handle,
		cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
		scale: transformScale,
		nodeRef: elementRef,
		children: newChild
	});
	return newChild;
}
var noop = () => {};
var layoutClassName = "react-grid-layout";
var isFirefox = false;
try {
	isFirefox = /firefox/i.test(navigator.userAgent);
} catch {}
function childrenEqual(a, b) {
	const aArr = import_react.Children.toArray(a);
	const bArr = import_react.Children.toArray(b);
	if (aArr.length !== bArr.length) return false;
	for (let i = 0; i < aArr.length; i++) {
		const aChild = aArr[i];
		const bChild = bArr[i];
		if (aChild?.key !== bChild?.key) return false;
	}
	return true;
}
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
	const layout = [];
	const childKeys = /* @__PURE__ */ new Set();
	import_react.Children.forEach(children, (child) => {
		if (!import_react.isValidElement(child) || child.key === null) return;
		const key = String(child.key);
		childKeys.add(key);
		const existingItem = initialLayout.find((l) => l.i === key);
		if (existingItem) layout.push(cloneLayoutItem(existingItem));
		else {
			const dataGrid = child.props["data-grid"];
			if (dataGrid) layout.push({
				i: key,
				x: dataGrid.x ?? 0,
				y: dataGrid.y ?? 0,
				w: dataGrid.w ?? 1,
				h: dataGrid.h ?? 1,
				minW: dataGrid.minW,
				maxW: dataGrid.maxW,
				minH: dataGrid.minH,
				maxH: dataGrid.maxH,
				static: dataGrid.static,
				isDraggable: dataGrid.isDraggable,
				isResizable: dataGrid.isResizable,
				resizeHandles: dataGrid.resizeHandles,
				isBounded: dataGrid.isBounded
			});
			else layout.push({
				i: key,
				x: 0,
				y: bottom(layout),
				w: 1,
				h: 1
			});
		}
	});
	const corrected = correctBounds(layout, { cols });
	return compactor.compact(corrected, cols);
}
function GridLayout(props) {
	const { children, width, gridConfig: gridConfigProp, dragConfig: dragConfigProp, resizeConfig: resizeConfigProp, dropConfig: dropConfigProp, positionStrategy = defaultPositionStrategy, compactor: compactorProp, constraints = defaultConstraints, layout: propsLayout = [], droppingItem: droppingItemProp, autoSize = true, className = "", style = {}, innerRef, onLayoutChange = noop, onDragStart: onDragStartProp = noop, onDrag: onDragProp = noop, onDragStop: onDragStopProp = noop, onResizeStart: onResizeStartProp = noop, onResize: onResizeProp = noop, onResizeStop: onResizeStopProp = noop, onDrop: onDropProp = noop, onDropDragOver: onDropDragOverProp = noop } = props;
	const gridConfig = (0, import_react.useMemo)(() => ({
		...defaultGridConfig,
		...gridConfigProp
	}), [gridConfigProp]);
	const dragConfig = (0, import_react.useMemo)(() => ({
		...defaultDragConfig,
		...dragConfigProp
	}), [dragConfigProp]);
	const resizeConfig = (0, import_react.useMemo)(() => ({
		...defaultResizeConfig,
		...resizeConfigProp
	}), [resizeConfigProp]);
	const dropConfig = (0, import_react.useMemo)(() => ({
		...defaultDropConfig,
		...dropConfigProp
	}), [dropConfigProp]);
	const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
	const { enabled: isDraggable, bounded: isBounded, handle: draggableHandle, cancel: draggableCancel, threshold: dragThreshold } = dragConfig;
	const { enabled: isResizable, handles: resizeHandles, handleComponent: resizeHandle } = resizeConfig;
	const { enabled: isDroppable, defaultItem: defaultDropItem, onDragOver: dropConfigOnDragOver } = dropConfig;
	const compactor = compactorProp ?? getCompactor("vertical");
	const compactType = compactor.type;
	const allowOverlap = compactor.allowOverlap;
	const preventCollision = compactor.preventCollision ?? false;
	const droppingItem = (0, import_react.useMemo)(() => droppingItemProp ?? {
		i: "__dropping-elem__",
		...defaultDropItem
	}, [droppingItemProp, defaultDropItem]);
	const useCSSTransforms = positionStrategy.type === "transform";
	const transformScale = positionStrategy.scale;
	const effectiveContainerPadding = containerPadding ?? margin;
	const [mounted, setMounted] = (0, import_react.useState)(false);
	const [layout, setLayout] = (0, import_react.useState)(() => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor));
	const [activeDrag, setActiveDrag] = (0, import_react.useState)(null);
	const [resizing, setResizing] = (0, import_react.useState)(false);
	const [droppingDOMNode, setDroppingDOMNode] = (0, import_react.useState)(null);
	const [droppingPosition, setDroppingPosition] = (0, import_react.useState)();
	const oldDragItemRef = (0, import_react.useRef)(null);
	const oldResizeItemRef = (0, import_react.useRef)(null);
	const oldLayoutRef = (0, import_react.useRef)(null);
	const dragEnterCounterRef = (0, import_react.useRef)(0);
	const prevLayoutRef = (0, import_react.useRef)(layout);
	const prevPropsLayoutRef = (0, import_react.useRef)(propsLayout);
	const prevChildrenRef = (0, import_react.useRef)(children);
	const prevCompactTypeRef = (0, import_react.useRef)(compactType);
	const layoutRef = (0, import_react.useRef)(layout);
	layoutRef.current = layout;
	(0, import_react.useEffect)(() => {
		setMounted(true);
		if (!(0, import_fast_equals.deepEqual)(layout, propsLayout)) onLayoutChange(layout);
	}, []);
	(0, import_react.useEffect)(() => {
		if (activeDrag) return;
		if (droppingDOMNode) return;
		const layoutChanged = !(0, import_fast_equals.deepEqual)(propsLayout, prevPropsLayoutRef.current);
		const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
		const compactTypeChanged = compactType !== prevCompactTypeRef.current;
		if (layoutChanged || childrenChanged || compactTypeChanged) {
			const newLayout = synchronizeLayoutWithChildren(layoutChanged ? propsLayout : layout, children, cols, compactor);
			if (!(0, import_fast_equals.deepEqual)(newLayout, layout)) setLayout(newLayout);
		}
		prevPropsLayoutRef.current = propsLayout;
		prevChildrenRef.current = children;
		prevCompactTypeRef.current = compactType;
	}, [
		propsLayout,
		children,
		cols,
		compactType,
		compactor,
		activeDrag,
		droppingDOMNode,
		layout
	]);
	(0, import_react.useEffect)(() => {
		if (!activeDrag && !(0, import_fast_equals.deepEqual)(layout, prevLayoutRef.current)) {
			prevLayoutRef.current = layout;
			onLayoutChange(layout.filter((l) => l.i !== droppingItem.i));
		}
	}, [
		layout,
		activeDrag,
		onLayoutChange,
		droppingItem.i
	]);
	const containerHeight = (0, import_react.useMemo)(() => {
		if (!autoSize) return void 0;
		const nbRow = bottom(layout);
		const containerPaddingY = effectiveContainerPadding[1];
		return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
	}, [
		autoSize,
		layout,
		rowHeight,
		margin,
		effectiveContainerPadding
	]);
	const onDragStart = (0, import_react.useCallback)((i, _x, _y, data) => {
		const currentLayout = layoutRef.current;
		const l = getLayoutItem(currentLayout, i);
		if (!l) return;
		const placeholder = {
			w: l.w,
			h: l.h,
			x: l.x,
			y: l.y,
			i
		};
		oldDragItemRef.current = cloneLayoutItem(l);
		oldLayoutRef.current = currentLayout;
		setActiveDrag(placeholder);
		onDragStartProp(currentLayout, l, l, null, data.e, data.node);
	}, [onDragStartProp]);
	const onDrag = (0, import_react.useCallback)((i, x, y, data) => {
		const currentLayout = layoutRef.current;
		const oldDragItem = oldDragItemRef.current;
		const l = getLayoutItem(currentLayout, i);
		if (!l) return;
		const placeholder = {
			w: l.w,
			h: l.h,
			x: l.x,
			y: l.y,
			i
		};
		const newLayout = moveElement(currentLayout, l, x, y, true, preventCollision, compactType, cols, allowOverlap);
		onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
		setLayout(compactor.compact(newLayout, cols));
		setActiveDrag(placeholder);
	}, [
		preventCollision,
		compactType,
		cols,
		allowOverlap,
		compactor,
		onDragProp
	]);
	const onDragStop = (0, import_react.useCallback)((i, x, y, data) => {
		if (!activeDrag) return;
		const currentLayout = layoutRef.current;
		const oldDragItem = oldDragItemRef.current;
		const l = getLayoutItem(currentLayout, i);
		if (!l) return;
		const newLayout = moveElement(currentLayout, l, x, y, true, preventCollision, compactType, cols, allowOverlap);
		const finalLayout = compactor.compact(newLayout, cols);
		onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
		const oldLayout = oldLayoutRef.current;
		oldDragItemRef.current = null;
		oldLayoutRef.current = null;
		setActiveDrag(null);
		setLayout(finalLayout);
		if (oldLayout && !(0, import_fast_equals.deepEqual)(oldLayout, finalLayout)) onLayoutChange(finalLayout);
	}, [
		activeDrag,
		preventCollision,
		compactType,
		cols,
		allowOverlap,
		compactor,
		onDragStopProp,
		onLayoutChange
	]);
	const onResizeStart = (0, import_react.useCallback)((i, _w, _h, data) => {
		const currentLayout = layoutRef.current;
		const l = getLayoutItem(currentLayout, i);
		if (!l) return;
		oldResizeItemRef.current = cloneLayoutItem(l);
		oldLayoutRef.current = currentLayout;
		setResizing(true);
		onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
	}, [onResizeStartProp]);
	const onResize = (0, import_react.useCallback)((i, w, h, data) => {
		const currentLayout = layoutRef.current;
		const oldResizeItem = oldResizeItemRef.current;
		const { handle } = data;
		let shouldMoveItem = false;
		let newX;
		let newY;
		const [newLayout, l] = withLayoutItem(currentLayout, i, (item) => {
			newX = item.x;
			newY = item.y;
			if ([
				"sw",
				"w",
				"nw",
				"n",
				"ne"
			].includes(handle)) {
				if ([
					"sw",
					"nw",
					"w"
				].includes(handle)) {
					newX = item.x + (item.w - w);
					w = item.x !== newX && newX < 0 ? item.w : w;
					newX = newX < 0 ? 0 : newX;
				}
				if ([
					"ne",
					"n",
					"nw"
				].includes(handle)) {
					newY = item.y + (item.h - h);
					h = item.y !== newY && newY < 0 ? item.h : h;
					newY = newY < 0 ? 0 : newY;
				}
				shouldMoveItem = true;
			}
			if (preventCollision && !allowOverlap) {
				if (getAllCollisions(currentLayout, {
					...item,
					w,
					h,
					x: newX ?? item.x,
					y: newY ?? item.y
				}).filter((layoutItem) => layoutItem.i !== item.i).length > 0) {
					newY = item.y;
					h = item.h;
					newX = item.x;
					w = item.w;
					shouldMoveItem = false;
				}
			}
			item.w = w;
			item.h = h;
			return item;
		});
		if (!l) return;
		let finalLayout = newLayout;
		if (shouldMoveItem && newX !== void 0 && newY !== void 0) finalLayout = moveElement(newLayout, l, newX, newY, true, preventCollision, compactType, cols, allowOverlap);
		const placeholder = {
			w: l.w,
			h: l.h,
			x: l.x,
			y: l.y,
			i,
			static: true
		};
		onResizeProp(finalLayout, oldResizeItem, l, placeholder, data.e, data.node);
		setLayout(compactor.compact(finalLayout, cols));
		setActiveDrag(placeholder);
	}, [
		preventCollision,
		compactType,
		cols,
		allowOverlap,
		compactor,
		onResizeProp
	]);
	const onResizeStop = (0, import_react.useCallback)((i, _w, _h, data) => {
		const currentLayout = layoutRef.current;
		const oldResizeItem = oldResizeItemRef.current;
		const l = getLayoutItem(currentLayout, i);
		const finalLayout = compactor.compact(currentLayout, cols);
		onResizeStopProp(finalLayout, oldResizeItem, l ?? null, null, data.e, data.node);
		const oldLayout = oldLayoutRef.current;
		oldResizeItemRef.current = null;
		oldLayoutRef.current = null;
		setActiveDrag(null);
		setResizing(false);
		setLayout(finalLayout);
		if (oldLayout && !(0, import_fast_equals.deepEqual)(oldLayout, finalLayout)) onLayoutChange(finalLayout);
	}, [
		cols,
		compactor,
		onResizeStopProp,
		onLayoutChange
	]);
	const removeDroppingPlaceholder = (0, import_react.useCallback)(() => {
		const currentLayout = layoutRef.current;
		if (!currentLayout.some((l) => l.i === droppingItem.i)) {
			setDroppingDOMNode(null);
			setActiveDrag(null);
			setDroppingPosition(void 0);
			return;
		}
		setLayout(compactor.compact(currentLayout.filter((l) => l.i !== droppingItem.i), cols));
		setDroppingDOMNode(null);
		setActiveDrag(null);
		setDroppingPosition(void 0);
	}, [
		droppingItem.i,
		cols,
		compactor
	]);
	const handleDragOver = (0, import_react.useCallback)((e) => {
		e.preventDefault();
		e.stopPropagation();
		if (isFirefox && !e.nativeEvent.target?.classList.contains(layoutClassName)) return false;
		const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
		if (rawResult === false) {
			if (droppingDOMNode) removeDroppingPlaceholder();
			return false;
		}
		const { dragOffsetX = 0, dragOffsetY = 0, ...onDragOverResult } = rawResult ?? {};
		const finalDroppingItem = {
			...droppingItem,
			...onDragOverResult
		};
		const gridRect = e.currentTarget.getBoundingClientRect();
		const positionParams = {
			cols,
			margin,
			maxRows,
			rowHeight,
			containerWidth: width,
			containerPadding: effectiveContainerPadding
		};
		const actualColWidth = calcGridColWidth(positionParams);
		const itemPixelWidth = calcGridItemWHPx(finalDroppingItem.w, actualColWidth, margin[0]);
		const itemPixelHeight = calcGridItemWHPx(finalDroppingItem.h, rowHeight, margin[1]);
		const itemCenterOffsetX = itemPixelWidth / 2;
		const itemCenterOffsetY = itemPixelHeight / 2;
		const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
		const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
		const clampedGridX = Math.max(0, rawGridX);
		const clampedGridY = Math.max(0, rawGridY);
		const newDroppingPosition = {
			left: clampedGridX / transformScale,
			top: clampedGridY / transformScale,
			e: e.nativeEvent
		};
		if (!droppingDOMNode) {
			const calculatedPosition = calcXY(positionParams, clampedGridY, clampedGridX, finalDroppingItem.w, finalDroppingItem.h);
			setDroppingDOMNode(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {}, finalDroppingItem.i));
			setDroppingPosition(newDroppingPosition);
			setLayout([...layoutRef.current.filter((l) => l.i !== finalDroppingItem.i), {
				...finalDroppingItem,
				x: calculatedPosition.x,
				y: calculatedPosition.y,
				static: false,
				isDraggable: true
			}]);
		} else if (droppingPosition) {
			if (droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top) setDroppingPosition(newDroppingPosition);
		}
	}, [
		droppingDOMNode,
		droppingPosition,
		droppingItem,
		dropConfigOnDragOver,
		onDropDragOverProp,
		removeDroppingPlaceholder,
		transformScale,
		cols,
		margin,
		maxRows,
		rowHeight,
		width,
		effectiveContainerPadding
	]);
	const handleDragLeave = (0, import_react.useCallback)((e) => {
		e.preventDefault();
		e.stopPropagation();
		dragEnterCounterRef.current--;
		if (dragEnterCounterRef.current < 0) dragEnterCounterRef.current = 0;
		if (dragEnterCounterRef.current === 0) removeDroppingPlaceholder();
	}, [removeDroppingPlaceholder]);
	const handleDragEnter = (0, import_react.useCallback)((e) => {
		e.preventDefault();
		e.stopPropagation();
		dragEnterCounterRef.current++;
	}, []);
	const handleDrop = (0, import_react.useCallback)((e) => {
		e.preventDefault();
		e.stopPropagation();
		const currentLayout = layoutRef.current;
		const item = currentLayout.find((l) => l.i === droppingItem.i);
		dragEnterCounterRef.current = 0;
		removeDroppingPlaceholder();
		onDropProp(currentLayout, item, e.nativeEvent);
	}, [
		droppingItem.i,
		removeDroppingPlaceholder,
		onDropProp
	]);
	const processGridItem = (0, import_react.useCallback)((child, isDroppingItem) => {
		if (!child || !child.key) return null;
		const l = getLayoutItem(layout, String(child.key));
		if (!l) return null;
		const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
		const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
		const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
		const bounded = draggable && isBounded && l.isBounded !== false;
		const resizeHandleElement = resizeHandle;
		return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GridItem, {
			containerWidth: width,
			cols,
			margin,
			containerPadding: effectiveContainerPadding,
			maxRows,
			rowHeight,
			cancel: draggableCancel,
			handle: draggableHandle,
			onDragStart,
			onDrag,
			onDragStop,
			onResizeStart,
			onResize,
			onResizeStop,
			isDraggable: draggable,
			isResizable: resizable,
			isBounded: bounded,
			useCSSTransforms: useCSSTransforms && mounted,
			usePercentages: !mounted,
			transformScale,
			positionStrategy,
			dragThreshold,
			w: l.w,
			h: l.h,
			x: l.x,
			y: l.y,
			i: l.i,
			minH: l.minH,
			minW: l.minW,
			maxH: l.maxH,
			maxW: l.maxW,
			static: l.static,
			droppingPosition: isDroppingItem ? droppingPosition : void 0,
			resizeHandles: resizeHandlesOptions,
			resizeHandle: resizeHandleElement,
			constraints,
			layoutItem: l,
			layout,
			children: child
		}, l.i);
	}, [
		layout,
		width,
		cols,
		margin,
		effectiveContainerPadding,
		maxRows,
		rowHeight,
		draggableCancel,
		draggableHandle,
		onDragStart,
		onDrag,
		onDragStop,
		onResizeStart,
		onResize,
		onResizeStop,
		isDraggable,
		isResizable,
		isBounded,
		useCSSTransforms,
		mounted,
		transformScale,
		positionStrategy,
		dragThreshold,
		droppingPosition,
		resizeHandles,
		resizeHandle,
		constraints
	]);
	const renderPlaceholder = () => {
		if (!activeDrag) return null;
		return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GridItem, {
			w: activeDrag.w,
			h: activeDrag.h,
			x: activeDrag.x,
			y: activeDrag.y,
			i: activeDrag.i,
			className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
			containerWidth: width,
			cols,
			margin,
			containerPadding: effectiveContainerPadding,
			maxRows,
			rowHeight,
			isDraggable: false,
			isResizable: false,
			isBounded: false,
			useCSSTransforms,
			transformScale,
			constraints,
			layout,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {})
		});
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		ref: innerRef,
		className: clsx(layoutClassName, className),
		style: {
			height: containerHeight,
			...style
		},
		onDrop: isDroppable ? handleDrop : void 0,
		onDragLeave: isDroppable ? handleDragLeave : void 0,
		onDragEnter: isDroppable ? handleDragEnter : void 0,
		onDragOver: isDroppable ? handleDragOver : void 0,
		children: [
			import_react.Children.map(children, (child) => {
				if (!import_react.isValidElement(child)) return null;
				return processGridItem(child);
			}),
			isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
			renderPlaceholder()
		]
	});
}
//#endregion
//#region src/components/reports/DashboardHeader.tsx
function DashboardHeader(t0) {
	const $ = (0, import_compiler_runtime.c)(11);
	const { dashboard } = t0;
	const { t } = useTranslation();
	const [editingName, setEditingName] = (0, import_react.useState)(false);
	const renameDashboardPageMutation = useRenameDashboardPageMutation();
	let t1;
	if ($[0] !== dashboard.id || $[1] !== dashboard.name || $[2] !== renameDashboardPageMutation) {
		t1 = async (newName) => {
			const trimmedName = newName.trim();
			if (!trimmedName || trimmedName === dashboard.name) {
				setEditingName(false);
				return;
			}
			renameDashboardPageMutation.mutate({
				id: dashboard.id,
				name: trimmedName
			}, { onSuccess: () => {
				setEditingName(false);
			} });
		};
		$[0] = dashboard.id;
		$[1] = dashboard.name;
		$[2] = renameDashboardPageMutation;
		$[3] = t1;
	} else t1 = $[3];
	const handleSaveName = t1;
	let t2;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = {
			flexDirection: "row",
			alignItems: "center",
			whiteSpace: "nowrap",
			marginLeft: 20,
			gap: 3,
			"& .hover-visible": {
				opacity: 0,
				transition: "opacity .25s"
			},
			"&:hover .hover-visible": { opacity: 1 },
			flexGrow: 1,
			flexShrink: 1,
			flexBasis: "auto",
			minWidth: 0,
			display: "flex",
			justifyContent: "flex-start"
		};
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				fontSize: 25,
				fontWeight: 500,
				flexGrow: 0,
				flexShrink: 0,
				flexBasis: "auto"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Reports" }), ":"]
		});
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== dashboard.name || $[7] !== editingName || $[8] !== handleSaveName || $[9] !== t) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t2,
			children: [t3, editingName ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InitialFocus, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
				defaultValue: dashboard.name,
				onEnter: handleSaveName,
				onUpdate: handleSaveName,
				onEscape: () => setEditingName(false),
				style: {
					fontSize: 25,
					fontWeight: 500,
					marginTop: -3,
					marginBottom: -4,
					paddingTop: 2,
					paddingBottom: 2
				}
			}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					fontSize: 25,
					fontWeight: 500,
					marginRight: 5,
					flexGrow: 0,
					flexShrink: 1,
					flexBasis: "auto",
					whiteSpace: "nowrap",
					overflow: "hidden",
					textOverflow: "ellipsis",
					minWidth: 0
				},
				children: dashboard.name
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "bare",
				"aria-label": t("Rename dashboard"),
				className: "hover-visible",
				style: { marginRight: 5 },
				onPress: () => setEditingName(true),
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgPencil1, { style: {
					width: 11,
					height: 11,
					flexGrow: 0,
					flexShrink: 0,
					flexBasis: "auto",
					color: theme.pageTextSubdued
				} })
			})] })]
		});
		$[6] = dashboard.name;
		$[7] = editingName;
		$[8] = handleSaveName;
		$[9] = t;
		$[10] = t4;
	} else t4 = $[10];
	return t4;
}
//#endregion
//#region src/components/reports/DashboardSelector.tsx
function DashboardSelector(t0) {
	const $ = (0, import_compiler_runtime.c)(21);
	const { dashboards, currentDashboard } = t0;
	const { t } = useTranslation();
	const navigate = useNavigate();
	const triggerRef = (0, import_react.useRef)(null);
	const [menuOpen, setMenuOpen] = (0, import_react.useState)(false);
	const createDashboardPageMutation = useCreateDashboardPageMutation();
	let t1;
	if ($[0] !== createDashboardPageMutation || $[1] !== navigate || $[2] !== t) {
		t1 = async () => {
			const defaultName = t("New dashboard");
			createDashboardPageMutation.mutate({ name: defaultName }, { onSuccess: (id) => {
				navigate(`/reports/${id}`);
			} });
		};
		$[0] = createDashboardPageMutation;
		$[1] = navigate;
		$[2] = t;
		$[3] = t1;
	} else t1 = $[3];
	const handleAddDashboard = t1;
	let t2;
	let t3;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = () => setMenuOpen(true);
		t3 = {
			flexGrow: 1,
			flexShrink: 1,
			flexBasis: "auto",
			whiteSpace: "nowrap",
			overflow: "hidden",
			textOverflow: "ellipsis",
			minWidth: 0,
			display: "flex",
			alignItems: "center",
			gap: "5px"
		};
		$[4] = t2;
		$[5] = t3;
	} else {
		t2 = $[4];
		t3 = $[5];
	}
	let t4;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			flexGrow: 1,
			flexShrink: 1,
			flexBasis: "auto",
			whiteSpace: "nowrap",
			overflow: "hidden",
			textOverflow: "ellipsis",
			minWidth: 0,
			textAlign: "center"
		};
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== currentDashboard.name) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t4,
			children: currentDashboard.name
		});
		$[7] = currentDashboard.name;
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgExpandArrow, {
			width: 7,
			height: 7,
			style: {
				flexGrow: 0,
				flexShrink: 0,
				flexBasis: "auto",
				marginLeft: 5
			}
		});
		$[9] = t6;
	} else t6 = $[9];
	let t7;
	if ($[10] !== t5) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
			ref: triggerRef,
			onPress: t2,
			style: t3,
			children: [t5, t6]
		});
		$[10] = t5;
		$[11] = t7;
	} else t7 = $[11];
	let t8;
	if ($[12] !== dashboards || $[13] !== handleAddDashboard || $[14] !== menuOpen || $[15] !== navigate || $[16] !== t) {
		t8 = menuOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, {
			triggerRef,
			isOpen: true,
			onOpenChange: setMenuOpen,
			placement: "bottom start",
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)($de32f1b87079253c$export$3ddf2d174ce01153, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
				slot: "close",
				onMenuSelect: (item) => {
					if (item === "add-new") handleAddDashboard();
					else navigate(`/reports/${item}`);
					setMenuOpen(false);
				},
				items: [
					...dashboards.map(_temp$3),
					Menu.line,
					{
						name: "add-new",
						text: t("Add new dashboard")
					}
				]
			}) })
		});
		$[12] = dashboards;
		$[13] = handleAddDashboard;
		$[14] = menuOpen;
		$[15] = navigate;
		$[16] = t;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t7 || $[19] !== t8) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)($de32f1b87079253c$export$2e1e1122cf0cba88, { children: [t7, t8] });
		$[18] = t7;
		$[19] = t8;
		$[20] = t9;
	} else t9 = $[20];
	return t9;
}
function _temp$3(dashboard) {
	return {
		name: dashboard.id,
		text: dashboard.name
	};
}
//#endregion
//#region src/components/reports/reports/BalanceForecastCard.tsx
function BalanceForecastCard({ widgetId, isEditing, accounts, meta, onMetaChange, onRemove, onCopy }) {
	const { t } = useTranslation();
	const format = useFormat();
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	const defaultTimeFrame = {
		start: currentMonth(),
		end: addMonths(currentMonth(), 11),
		mode: "static"
	};
	const [start, end] = calculateTimeRange(meta?.timeFrame, defaultTimeFrame);
	const selectedAccountIds = (0, import_react.useMemo)(() => meta?.accounts ?? accounts.map((a) => a.id), [accounts, meta?.accounts]);
	const startDate = start + "-01";
	const endDate = lastDayOfMonth(end);
	const { data: forecastData, error, isFetching, isPlaceholderData, isPending: isLoading } = useBalanceForecast({
		accountIds: selectedAccountIds,
		conditions: meta?.conditions,
		conditionsOp: meta?.conditionsOp,
		startDate,
		endDate,
		includeAccountlessSchedules: meta?.accounts === void 0
	});
	const errorMessage = error instanceof Error ? error.message : error ? t("Failed to load forecast") : null;
	const normalizedForecastData = forecastData ?? null;
	const committedChartRange = (0, import_react.useRef)({
		start,
		end
	});
	const onCardHover = () => setIsCardHovered(true);
	const onCardHoverEnd = () => setIsCardHovered(false);
	const lowestPoint = forecastData?.lowestBalance;
	const hasNegative = lowestPoint && lowestPoint.balance < 0;
	const chartRange = isPlaceholderData ? committedChartRange.current : {
		start,
		end
	};
	(0, import_react.useEffect)(() => {
		if (normalizedForecastData && !isPlaceholderData) committedChartRange.current = {
			start,
			end
		};
	}, [
		end,
		isPlaceholderData,
		normalizedForecastData,
		start
	]);
	const chartData = buildBalanceForecastChartData({
		forecastData: normalizedForecastData,
		start: chartRange.start,
		end: chartRange.end,
		granularity: "Monthly"
	});
	const hasNegativeBalance = chartData.some((d) => d.balance < 0);
	const zeroCrossingGradientOffset = getZeroCrossingGradientOffset(chartData);
	const gradientId = `balance-forecast-card-line-gradient-${widgetId}`;
	const isUpdatingForecast = isFetching && isPlaceholderData;
	const todayReferenceDate = currentMonth();
	const showsTodayReferenceLine = chartData.some((dataPoint) => dataPoint.date === todayReferenceDate);
	const scheduledOccurrenceCount = countForecastScheduledOccurrences(normalizedForecastData);
	const hasFilters = (meta?.conditions?.length ?? 0) > 0;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
		isEditing,
		disableClick: nameMenuOpen,
		to: `/reports/forecast/${widgetId}`,
		menuItems: [
			{
				name: "rename",
				text: t("Rename")
			},
			{
				name: "remove",
				text: t("Remove")
			},
			...copyMenuItems
		],
		onMenuSelect: (item) => {
			if (handleCopyMenuSelect(item)) return;
			switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break;
				case "remove":
					onRemove();
					break;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		},
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { flex: 1 },
			onPointerEnter: onCardHover,
			onPointerLeave: onCardHoverEnd,
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					padding: 20
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: { flex: 1 },
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
						name: meta?.name || t("Balance Forecast"),
						isEditing: nameMenuOpen,
						onChange: (newName) => {
							onMetaChange({
								...meta,
								name: newName
							});
							setNameMenuOpen(false);
						},
						onClose: () => setNameMenuOpen(false)
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
						start,
						end
					})]
				}), lowestPoint && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: { textAlign: "right" },
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
						style: {
							...styles.mediumText,
							fontWeight: 500,
							marginBottom: 5,
							color: hasNegative ? theme.errorText : theme.pageText
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PrivacyFilter, {
							activationFilters: [!isCardHovered],
							children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Lowest" }),
								":",
								" ",
								format(lowestPoint.balance, "financial")
							]
						})
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
						activationFilters: [!isCardHovered],
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
							style: {
								fontSize: 12,
								color: theme.pageTextLight
							},
							children: lowestPoint.date
						})
					})]
				})]
			}), isLoading && !normalizedForecastData ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {}) : errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					height: 120,
					padding: 20
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
					style: {
						fontSize: 13,
						color: theme.errorText,
						textAlign: "center"
					},
					children: errorMessage
				})
			}) : forecastData && forecastData.dataPoints.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
				style: {
					height: "auto",
					flex: 1
				},
				children: (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResponsiveContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LineChart, {
					width,
					height,
					data: chartData,
					margin: {
						top: 5,
						right: 5,
						left: 5,
						bottom: 5
					},
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("linearGradient", {
							id: gradientId,
							x1: "0",
							y1: "0",
							x2: "0",
							y2: "1",
							children: zeroCrossingGradientOffset == null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
								offset: "0%",
								stopColor: hasNegativeBalance ? theme.errorText : theme.noticeText
							}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
								offset: `${zeroCrossingGradientOffset}%`,
								stopColor: theme.noticeText
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
								offset: `${zeroCrossingGradientOffset}%`,
								stopColor: theme.errorText
							})] })
						}) }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1, {
							isAnimationActive: false,
							content: ({ active, payload }) => {
								if (active && payload && payload.length) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									style: {
										zIndex: 1e3,
										pointerEvents: "none",
										borderRadius: 2,
										boxShadow: "0 1px 6px rgba(0, 0, 0, .20)",
										backgroundColor: theme.menuBackground,
										color: theme.menuItemText,
										padding: 10
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										style: { marginBottom: 5 },
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: payload[0].payload.date })
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: format(payload[0].value, "financial") })]
								});
								return null;
							}
						}),
						showsTodayReferenceLine && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
							x: todayReferenceDate,
							stroke: theme.noticeText,
							strokeDasharray: "4 4"
						}),
						hasNegativeBalance && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferenceLine, {
							y: 0,
							stroke: theme.pageTextSubdued
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Line, {
							type: "monotone",
							dataKey: "balance",
							stroke: `url(#${gradientId})`,
							strokeWidth: 2,
							dot: false,
							activeDot: { r: 4 },
							opacity: isUpdatingForecast ? .45 : 1
						})
					]
				}) })
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Block, {
				style: {
					padding: "0 20px 16px",
					fontSize: 12,
					color: theme.pageTextLight
				},
				children: [scheduledOccurrenceCount === 0 ? hasFilters ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Filtered running total only; no scheduled occurrences in this range" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No scheduled transactions in this range" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Trans, {
					count: scheduledOccurrenceCount,
					children: [{ count: scheduledOccurrenceCount }, " scheduled transactions included"]
				}), hasFilters ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "(filtered running total)" })] }) : null] }), isUpdatingForecast ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Updating..." })] }) : null]
			})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					height: 120,
					padding: 20
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
					style: {
						fontSize: 13,
						color: theme.pageTextLight,
						textAlign: "center"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "No transactions are included in this report. Adjust your filters, accounts, or date range to see a balance projection." })
				})
			})]
		})
	});
}
//#endregion
//#region src/components/reports/reports/BudgetAnalysisCard.tsx
function BudgetAnalysisCard(t0) {
	const $ = (0, import_compiler_runtime.c)(75);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	const meta = t1 === void 0 ? {} : t1;
	const { t } = useTranslation();
	const format = useFormat();
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const [startMonth, endMonth] = calculateTimeRange(meta?.timeFrame ?? {
		start: subMonths(currentMonth(), 5),
		end: currentMonth(),
		mode: "sliding-window"
	});
	const startDate = monthFromDate(startMonth) + "-01";
	const endDate = getMonthEnd(monthFromDate(endMonth) + "-01");
	meta?.conditions;
	meta?.conditionsOp;
	const t2 = meta?.conditions;
	const t3 = meta?.conditionsOp;
	let t4;
	if ($[0] !== endDate || $[1] !== startDate || $[2] !== t2 || $[3] !== t3) {
		t4 = createBudgetAnalysisSpreadsheet({
			conditions: t2,
			conditionsOp: t3,
			startDate,
			endDate
		});
		$[0] = endDate;
		$[1] = startDate;
		$[2] = t2;
		$[3] = t3;
		$[4] = t4;
	} else t4 = $[4];
	const data = useReport$1("default", t4);
	const balance = (data && data.intervalData.length > 0 ? data.intervalData[data.intervalData.length - 1] : void 0)?.balance ?? 0;
	const t5 = `/reports/budget-analysis/${widgetId}`;
	let t6;
	if ($[5] !== t) {
		t6 = t("Rename");
		$[5] = t;
		$[6] = t6;
	} else t6 = $[6];
	let t7;
	if ($[7] !== t6) {
		t7 = {
			name: "rename",
			text: t6
		};
		$[7] = t6;
		$[8] = t7;
	} else t7 = $[8];
	let t8;
	if ($[9] !== t) {
		t8 = t("Remove");
		$[9] = t;
		$[10] = t8;
	} else t8 = $[10];
	let t9;
	if ($[11] !== t8) {
		t9 = {
			name: "remove",
			text: t8
		};
		$[11] = t8;
		$[12] = t9;
	} else t9 = $[12];
	let t10;
	if ($[13] !== copyMenuItems || $[14] !== t7 || $[15] !== t9) {
		t10 = [
			t7,
			t9,
			...copyMenuItems
		];
		$[13] = copyMenuItems;
		$[14] = t7;
		$[15] = t9;
		$[16] = t10;
	} else t10 = $[16];
	let t11;
	if ($[17] !== handleCopyMenuSelect || $[18] !== onRemove || $[19] !== setNameMenuOpen) {
		t11 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb51: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb51;
				case "remove":
					onRemove();
					break bb51;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[17] = handleCopyMenuSelect;
		$[18] = onRemove;
		$[19] = setNameMenuOpen;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = { flex: 1 };
		$[21] = t12;
	} else t12 = $[21];
	let t13;
	let t14;
	if ($[22] !== setIsCardHovered) {
		t13 = () => setIsCardHovered(true);
		t14 = () => setIsCardHovered(false);
		$[22] = setIsCardHovered;
		$[23] = t13;
		$[24] = t14;
	} else {
		t13 = $[23];
		t14 = $[24];
	}
	let t15;
	if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = {
			flexDirection: "row",
			padding: 20
		};
		$[25] = t15;
	} else t15 = $[25];
	let t16;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = { flex: 1 };
		$[26] = t16;
	} else t16 = $[26];
	let t17;
	if ($[27] !== meta?.name || $[28] !== t) {
		t17 = meta?.name || t("Budget Analysis");
		$[27] = meta?.name;
		$[28] = t;
		$[29] = t17;
	} else t17 = $[29];
	let t18;
	if ($[30] !== meta || $[31] !== onMetaChange || $[32] !== setNameMenuOpen) {
		t18 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[30] = meta;
		$[31] = onMetaChange;
		$[32] = setNameMenuOpen;
		$[33] = t18;
	} else t18 = $[33];
	let t19;
	if ($[34] !== setNameMenuOpen) {
		t19 = () => setNameMenuOpen(false);
		$[34] = setNameMenuOpen;
		$[35] = t19;
	} else t19 = $[35];
	let t20;
	if ($[36] !== nameMenuOpen || $[37] !== t17 || $[38] !== t18 || $[39] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t17,
			isEditing: nameMenuOpen,
			onChange: t18,
			onClose: t19
		});
		$[36] = nameMenuOpen;
		$[37] = t17;
		$[38] = t18;
		$[39] = t19;
		$[40] = t20;
	} else t20 = $[40];
	let t21;
	if ($[41] !== startDate) {
		t21 = getMonth(startDate);
		$[41] = startDate;
		$[42] = t21;
	} else t21 = $[42];
	let t22;
	if ($[43] !== endDate) {
		t22 = getMonth(endDate);
		$[43] = endDate;
		$[44] = t22;
	} else t22 = $[44];
	let t23;
	if ($[45] !== t21 || $[46] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start: t21,
			end: t22
		});
		$[45] = t21;
		$[46] = t22;
		$[47] = t23;
	} else t23 = $[47];
	let t24;
	if ($[48] !== t20 || $[49] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t16,
			children: [t20, t23]
		});
		$[48] = t20;
		$[49] = t23;
		$[50] = t24;
	} else t24 = $[50];
	let t25;
	if ($[51] !== balance || $[52] !== data || $[53] !== format || $[54] !== isCardHovered) {
		t25 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { textAlign: "right" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				style: {
					...styles.mediumText,
					fontWeight: 500,
					marginBottom: 5,
					color: balance >= 0 ? theme.noticeTextLight : theme.errorText
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
					activationFilters: [!isCardHovered],
					children: format(balance, "financial")
				}) })
			})
		});
		$[51] = balance;
		$[52] = data;
		$[53] = format;
		$[54] = isCardHovered;
		$[55] = t25;
	} else t25 = $[55];
	let t26;
	if ($[56] !== t24 || $[57] !== t25) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t15,
			children: [t24, t25]
		});
		$[56] = t24;
		$[57] = t25;
		$[58] = t26;
	} else t26 = $[58];
	let t27;
	if ($[59] !== data || $[60] !== meta?.graphType || $[61] !== meta?.showBalance) {
		t27 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysisGraph, {
			style: { flex: 1 },
			data,
			graphType: meta?.graphType || "Bar",
			showBalance: meta?.showBalance ?? true
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[59] = data;
		$[60] = meta?.graphType;
		$[61] = meta?.showBalance;
		$[62] = t27;
	} else t27 = $[62];
	let t28;
	if ($[63] !== t13 || $[64] !== t14 || $[65] !== t26 || $[66] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t12,
			onPointerEnter: t13,
			onPointerLeave: t14,
			children: [t26, t27]
		});
		$[63] = t13;
		$[64] = t14;
		$[65] = t26;
		$[66] = t27;
		$[67] = t28;
	} else t28 = $[67];
	let t29;
	if ($[68] !== isEditing || $[69] !== nameMenuOpen || $[70] !== t10 || $[71] !== t11 || $[72] !== t28 || $[73] !== t5) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t5,
			menuItems: t10,
			onMenuSelect: t11,
			children: t28
		});
		$[68] = isEditing;
		$[69] = nameMenuOpen;
		$[70] = t10;
		$[71] = t11;
		$[72] = t28;
		$[73] = t5;
		$[74] = t29;
	} else t29 = $[74];
	return t29;
}
//#endregion
//#region src/components/reports/CalendarCardSkeleton.tsx
var pulse = keyframes({
	"0%, 100%": { opacity: .4 },
	"50%": { opacity: 1 }
});
var cellBase = {
	borderRadius: 4,
	backgroundColor: theme.calendarCellBackground
};
var staticCell = css({
	...cellBase,
	opacity: .7
});
var pulsingCell = css({
	...cellBase,
	animationName: pulse,
	animationDuration: "1.6s",
	animationTimingFunction: "ease-in-out",
	animationIterationCount: "infinite"
});
function CalendarCardSkeleton() {
	const $ = (0, import_compiler_runtime.c)(10);
	const cell = useReducedMotion() ? staticCell : pulsingCell;
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = {
			flex: 1,
			gap: 4
		};
		$[0] = t0;
	} else t0 = $[0];
	let t1;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			display: "grid",
			gridTemplateColumns: "repeat(7, 1fr)",
			gap: 2
		};
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== cell) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t1,
			children: Array.from({ length: 7 }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					alignItems: "center",
					padding: "3px 0"
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: cell,
					style: {
						width: 14,
						height: 10,
						backgroundColor: theme.pageTextSubdued
					}
				})
			}, i))
		});
		$[2] = cell;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			flex: 1,
			display: "grid",
			gridTemplateColumns: "repeat(7, 1fr)",
			gridTemplateRows: "repeat(6, 1fr)",
			gap: 2
		};
		$[4] = t3;
	} else t3 = $[4];
	let t4;
	if ($[5] !== cell) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t3,
			children: Array.from({ length: 42 }, (__0, i_0) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
				className: cell,
				style: { animationDelay: `${(i_0 % 7 + Math.floor(i_0 / 7)) * .04}s` }
			}, i_0))
		});
		$[5] = cell;
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== t2 || $[8] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t0,
			"aria-hidden": "true",
			children: [t2, t4]
		});
		$[7] = t2;
		$[8] = t4;
		$[9] = t5;
	} else t5 = $[9];
	return t5;
}
//#endregion
//#region src/components/reports/reports/CalendarCard.tsx
function CalendarCard({ widgetId, isEditing, meta = {}, onMetaChange, onRemove, onCopy, firstDayOfWeekIdx }) {
	const { t } = useTranslation();
	const format = useFormat();
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	(0, import_react.useEffect)(() => {
		async function fetchLatestTransaction() {
			const latestTrans = await send("get-latest-transaction");
			setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
		}
		fetchLatestTransaction();
	}, []);
	const [start, end] = calculateTimeRange(meta?.timeFrame, {
		start: dayFromDate(currentMonth()),
		end: currentDay(),
		mode: "full"
	}, latestTransaction);
	const params = (0, import_react.useMemo)(() => calendarSpreadsheet(start, end, meta?.conditions, meta?.conditionsOp, firstDayOfWeekIdx), [
		start,
		end,
		meta?.conditions,
		meta?.conditionsOp,
		firstDayOfWeekIdx
	]);
	const [cardOrientation, setCardOrientation] = (0, import_react.useState)("row");
	const { isNarrowWidth } = useResponsive();
	const cardRef = useResizeObserver((rect) => {
		if (rect.height > rect.width) setCardOrientation("column");
		else setCardOrientation("row");
	});
	const data = useReport$1("calendar", params);
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { totalIncome, totalExpense } = (0, import_react.useMemo)(() => {
		if (!data) return {
			totalIncome: 0,
			totalExpense: 0
		};
		return {
			totalIncome: data.calendarData.reduce((prev, cur) => prev + cur.totalIncome, 0),
			totalExpense: data.calendarData.reduce((prev_0, cur_0) => prev_0 + cur_0.totalExpense, 0)
		};
	}, [data]);
	const [monthNameFormats, setMonthNameFormats] = (0, import_react.useState)([]);
	const [selectedMonthNameFormat, setSelectedMonthNameFormat] = (0, import_react.useState)("MMMM yyyy");
	(0, import_react.useEffect)(() => {
		if (data) setMonthNameFormats(Array(data.calendarData.length).map(() => "MMMM yyyy"));
		else setMonthNameFormats([]);
	}, [data]);
	(0, import_react.useEffect)(() => {
		if (monthNameFormats.length) setSelectedMonthNameFormat(monthNameFormats.reduce((a, b) => (a?.length ?? 0) <= (b?.length ?? 0) ? a : b, "MMMM yyyy"));
		else setSelectedMonthNameFormat("MMMM yyyy");
	}, [monthNameFormats]);
	const calendarLenSize = (0, import_react.useMemo)(() => {
		if (!data) return 0;
		return data?.calendarData.length;
	}, [data]);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
		isEditing,
		disableClick: nameMenuOpen,
		to: `/reports/calendar/${widgetId}`,
		menuItems: [
			{
				name: "rename",
				text: t("Rename")
			},
			{
				name: "remove",
				text: t("Remove")
			},
			...copyMenuItems
		],
		onMenuSelect: (item) => {
			if (handleCopyMenuSelect(item)) return;
			switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break;
				case "remove":
					onRemove();
					break;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		},
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			ref: (el) => el ? cardRef(el) : void 0,
			style: {
				flex: 1,
				margin: 2,
				overflow: "hidden",
				width: "100%"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					padding: 20,
					paddingBottom: 0
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						flex: 1,
						marginBottom: -5
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
						name: meta?.name || t("Calendar"),
						isEditing: nameMenuOpen,
						onChange: (newName) => {
							onMetaChange({
								...meta,
								name: newName
							});
							setNameMenuOpen(false);
						},
						onClose: () => setNameMenuOpen(false)
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: { textAlign: "right" },
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
						style: {
							...styles.mediumText,
							fontWeight: 500
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
							content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
								style: { lineHeight: 1.5 },
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
									style: {
										display: "grid",
										gridTemplateColumns: "70px 1fr",
										gridAutoRows: "1fr"
									},
									children: [totalIncome !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: {
											textAlign: "right",
											marginRight: 4
										},
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Income:" })
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: { color: theme.reportsNumberPositive },
										children: totalIncome !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(totalIncome, "financial") }) }) : ""
									})] }), totalExpense !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: {
											textAlign: "right",
											marginRight: 4
										},
										children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Expenses:" })
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
										style: { color: theme.reportsNumberNegative },
										children: totalExpense !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(totalExpense, "financial") }) }) : ""
									})] })]
								})
							}),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
								start,
								end
							})
						})
					})
				})]
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					height: "100%",
					margin: 6,
					overflowX: cardOrientation === "row" ? isNarrowWidth ? "auto" : calendarLenSize > 4 ? "auto" : "hidden" : "hidden",
					...styles.horizontalScrollbar
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: {
						flex: 1,
						flexDirection: cardOrientation,
						gap: 16,
						marginTop: 10,
						textAlign: "left",
						marginBottom: isNarrowWidth ? 4 : 0,
						width: cardOrientation === "row" ? isNarrowWidth ? `${calendarLenSize * 100}%` : calendarLenSize > 4 ? `${100 + (calendarLenSize - 4) % 4 * 25}%` : "auto" : "auto"
					},
					children: data ? data.calendarData.map((calendar, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCardInner, {
						calendar,
						firstDayOfWeekIdx: firstDayOfWeekIdx ?? "0",
						setMonthNameFormats,
						selectedMonthNameFormat,
						index,
						widgetId,
						isEditing,
						format
					}, index)) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCardSkeleton, {})
				})
			})]
		})
	});
}
function CalendarCardInner({ calendar, firstDayOfWeekIdx, setMonthNameFormats, selectedMonthNameFormat, index, widgetId, isEditing, format }) {
	const { t } = useTranslation();
	const [monthNameVisible, setMonthNameVisible] = (0, import_react.useState)(true);
	const monthFormatSizeContainers = (0, import_react.useRef)(new Array(5));
	const monthNameContainerRef = (0, import_react.useRef)(null);
	const measureMonthFormats = (0, import_react.useCallback)(() => {
		return monthFormatSizeContainers.current.map((container) => ({
			width: container?.clientWidth ?? 0,
			format: container?.getAttribute("data-format") ?? ""
		}));
	}, []);
	const debouncedResizeCallback = (0, import_react.useMemo)(() => (0, import_debounce.default)(() => {
		const measurements_0 = measureMonthFormats();
		const containerWidth = monthNameContainerRef.current?.clientWidth ?? 0;
		const suitableFormat = measurements_0.find((m) => containerWidth > m.width);
		if (suitableFormat) {
			if (monthNameContainerRef.current && containerWidth > suitableFormat.width) {
				setMonthNameFormats((prev) => {
					if (prev[index] === suitableFormat.format) return prev;
					const newArray = [...prev];
					newArray[index] = suitableFormat.format;
					return newArray;
				});
				setMonthNameVisible(true);
				return;
			}
		}
		if (monthNameContainerRef.current && monthNameContainerRef.current.scrollWidth > monthNameContainerRef.current.clientWidth) setMonthNameVisible(false);
		else setMonthNameVisible(true);
	}, 20), [
		measureMonthFormats,
		monthNameContainerRef,
		index,
		setMonthNameFormats
	]);
	const monthNameResizeRef = useResizeObserver(debouncedResizeCallback);
	(0, import_react.useEffect)(() => {
		const toCancel = debouncedResizeCallback;
		return () => {
			toCancel.cancel();
		};
	}, [debouncedResizeCallback]);
	const mergedRef = useMergedRefs(monthNameContainerRef, monthNameResizeRef);
	const navigate = useNavigate();
	const monthFormats = [
		{
			format: "MMMM yyyy",
			text: format$1(calendar.start, "MMMM yyyy")
		},
		{
			format: "MMM yyyy",
			text: format$1(calendar.start, "MMM yyyy")
		},
		{
			format: "MMM yy",
			text: format$1(calendar.start, "MMM yy")
		},
		{
			format: "MMM",
			text: format$1(calendar.start, "MMM")
		},
		{
			format: "",
			text: ""
		}
	];
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
		style: {
			flex: 1,
			overflow: "visible"
		},
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: {
					flexDirection: "row",
					marginLeft: 5,
					marginRight: 5
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					ref: mergedRef,
					style: {
						color: theme.pageTextSubdued,
						fontWeight: "bold",
						flex: 1,
						overflow: "hidden",
						display: "block",
						width: "100%"
					},
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
						variant: "bare",
						style: {
							visibility: monthNameVisible ? "visible" : "hidden",
							overflow: "visible",
							whiteSpace: "nowrap",
							display: "inline-block",
							width: "max-content",
							margin: 0,
							padding: 0,
							color: theme.pageTextSubdued,
							fontWeight: "bold",
							fontSize: "12px",
							marginBottom: 6
						},
						onPress: () => {
							navigate(`/reports/calendar/${widgetId}?month=${format$1(calendar.start, "yyyy-MM")}`);
						},
						children: selectedMonthNameFormat && format$1(calendar.start, selectedMonthNameFormat)
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: {
						flexDirection: "row",
						justifyContent: "flex-end"
					},
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							color: theme.reportsNumberPositive,
							flexDirection: "row",
							fontSize: "10px",
							marginRight: 10
						},
						"aria-label": t("Income"),
						children: calendar.totalIncome !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgArrowThickUp, {
							width: 16,
							height: 16,
							style: { flexShrink: 0 }
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(calendar.totalIncome, "financial") }) })] }) : ""
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
						style: {
							color: theme.reportsNumberNegative,
							flexDirection: "row",
							fontSize: "10px"
						},
						"aria-label": t("Expenses"),
						children: calendar.totalExpense !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgArrowThickDown, {
							width: 16,
							height: 16,
							style: { flexShrink: 0 }
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(calendar.totalExpense, "financial") }) })] }) : ""
					})]
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarGraph, {
				data: calendar.data,
				start: calendar.start,
				firstDayOfWeekIdx,
				isEditing,
				onDayClick: (date) => {
					if (date) navigate(`/reports/calendar/${widgetId}?day=${format$1(date, "yyyy-MM-dd")}`);
					else navigate(`/reports/calendar/${widgetId}`);
				}
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					fontWeight: "bold",
					fontSize: "12px"
				},
				children: monthFormats.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
					ref: (node) => {
						if (node) monthFormatSizeContainers.current[idx] = node;
					},
					style: {
						position: "fixed",
						top: -9999,
						left: -9999
					},
					"data-format": item.format,
					children: [item.text, item.text && ":"]
				}, item.format))
			})
		]
	});
}
//#endregion
//#region src/components/reports/reports/CashFlowCard.tsx
function CustomLabel(t0) {
	const $ = (0, import_compiler_runtime.c)(21);
	const { value: t1, name, position: t2, x: t3, y: t4, width: t5, height: t6 } = t0;
	const value = t1 === void 0 ? 0 : t1;
	const position = t2 === void 0 ? "left" : t2;
	const x = t3 === void 0 ? 0 : t3;
	const y = t4 === void 0 ? 0 : t4;
	const barWidth = t5 === void 0 ? 0 : t5;
	const barHeight = t6 === void 0 ? 0 : t6;
	const format = useFormat();
	const yOffset = barHeight < 25 ? 105 : y;
	let t7;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			right: 6,
			left: -19
		};
		$[0] = t7;
	} else t7 = $[0];
	const labelXOffsets = t7;
	let t8;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = {
			right: 6,
			left: -18
		};
		$[1] = t8;
	} else t8 = $[1];
	const valueXOffsets = t8;
	let t9;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = {
			right: "start",
			left: "end"
		};
		$[2] = t9;
	} else t9 = $[2];
	const anchorValue = t9;
	const t10 = x + barWidth + labelXOffsets[position];
	const t11 = yOffset + 10;
	const t12 = anchorValue[position];
	let t13;
	if ($[3] !== name || $[4] !== t10 || $[5] !== t11 || $[6] !== t12) {
		t13 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
			x: t10,
			y: t11,
			textAnchor: t12,
			fill: theme.tableText,
			children: name
		});
		$[3] = name;
		$[4] = t10;
		$[5] = t11;
		$[6] = t12;
		$[7] = t13;
	} else t13 = $[7];
	const t14 = x + barWidth + valueXOffsets[position];
	const t15 = yOffset + 26;
	const t16 = anchorValue[position];
	let t17;
	if ($[8] !== format || $[9] !== value) {
		t17 = format(value, "financial");
		$[8] = format;
		$[9] = value;
		$[10] = t17;
	} else t17 = $[10];
	let t18;
	if ($[11] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: t17 });
		$[11] = t17;
		$[12] = t18;
	} else t18 = $[12];
	let t19;
	if ($[13] !== t14 || $[14] !== t15 || $[15] !== t16 || $[16] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
			as: "text",
			x: t14,
			y: t15,
			textAnchor: t16,
			fill: theme.tableText,
			children: t18
		});
		$[13] = t14;
		$[14] = t15;
		$[15] = t16;
		$[16] = t18;
		$[17] = t19;
	} else t19 = $[17];
	let t20;
	if ($[18] !== t13 || $[19] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t13, t19] });
		$[18] = t13;
		$[19] = t19;
		$[20] = t20;
	} else t20 = $[20];
	return t20;
}
function CashFlowCard(t0) {
	const $ = (0, import_compiler_runtime.c)(75);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const { t } = useTranslation();
	const animationProps = useRechartsAnimation();
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	let t3;
	let t4;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = () => {
			(async function fetchLatestTransaction() {
				const latestTrans = await send("get-latest-transaction");
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
			})();
		};
		t4 = [];
		$[2] = t3;
		$[3] = t4;
	} else {
		t3 = $[2];
		t4 = $[3];
	}
	(0, import_react.useEffect)(t3, t4);
	const t5 = meta?.timeFrame;
	let t6;
	if ($[4] !== latestTransaction || $[5] !== t5) {
		t6 = calculateTimeRange(t5, defaultTimeFrame$1, latestTransaction);
		$[4] = latestTransaction;
		$[5] = t5;
		$[6] = t6;
	} else t6 = $[6];
	const [start, end] = t6;
	meta?.conditions;
	meta?.conditionsOp;
	const t7 = meta?.conditions;
	const t8 = meta?.conditionsOp;
	let t9;
	if ($[7] !== end || $[8] !== start || $[9] !== t7 || $[10] !== t8) {
		t9 = simpleCashFlow(start, end, t7, t8);
		$[7] = end;
		$[8] = start;
		$[9] = t7;
		$[10] = t8;
		$[11] = t9;
	} else t9 = $[11];
	const data = useReport$1("cash_flow_simple", t9);
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	let t10;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = () => setIsCardHovered(true);
		$[12] = t10;
	} else t10 = $[12];
	const onCardHover = t10;
	let t11;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = () => setIsCardHovered(false);
		$[13] = t11;
	} else t11 = $[13];
	const onCardHoverEnd = t11;
	let t12;
	if ($[14] !== data) {
		t12 = data || {};
		$[14] = data;
		$[15] = t12;
	} else t12 = $[15];
	const { graphData } = t12;
	const expenses = -(graphData?.expense || 0);
	const income = graphData?.income || 0;
	const t13 = `/reports/cash-flow/${widgetId}`;
	let t14;
	if ($[16] !== t) {
		t14 = t("Rename");
		$[16] = t;
		$[17] = t14;
	} else t14 = $[17];
	let t15;
	if ($[18] !== t14) {
		t15 = {
			name: "rename",
			text: t14
		};
		$[18] = t14;
		$[19] = t15;
	} else t15 = $[19];
	let t16;
	if ($[20] !== t) {
		t16 = t("Remove");
		$[20] = t;
		$[21] = t16;
	} else t16 = $[21];
	let t17;
	if ($[22] !== t16) {
		t17 = {
			name: "remove",
			text: t16
		};
		$[22] = t16;
		$[23] = t17;
	} else t17 = $[23];
	let t18;
	if ($[24] !== copyMenuItems || $[25] !== t15 || $[26] !== t17) {
		t18 = [
			t15,
			t17,
			...copyMenuItems
		];
		$[24] = copyMenuItems;
		$[25] = t15;
		$[26] = t17;
		$[27] = t18;
	} else t18 = $[27];
	let t19;
	if ($[28] !== handleCopyMenuSelect || $[29] !== onRemove) {
		t19 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb61: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb61;
				case "remove":
					onRemove();
					break bb61;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[28] = handleCopyMenuSelect;
		$[29] = onRemove;
		$[30] = t19;
	} else t19 = $[30];
	let t20;
	if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = { flex: 1 };
		$[31] = t20;
	} else t20 = $[31];
	let t21;
	if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			flexDirection: "row",
			padding: 20
		};
		$[32] = t21;
	} else t21 = $[32];
	let t22;
	if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = { flex: 1 };
		$[33] = t22;
	} else t22 = $[33];
	let t23;
	if ($[34] !== meta?.name || $[35] !== t) {
		t23 = meta?.name || t("Cash Flow");
		$[34] = meta?.name;
		$[35] = t;
		$[36] = t23;
	} else t23 = $[36];
	let t24;
	if ($[37] !== meta || $[38] !== onMetaChange) {
		t24 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[37] = meta;
		$[38] = onMetaChange;
		$[39] = t24;
	} else t24 = $[39];
	let t25;
	if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = () => setNameMenuOpen(false);
		$[40] = t25;
	} else t25 = $[40];
	let t26;
	if ($[41] !== nameMenuOpen || $[42] !== t23 || $[43] !== t24) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t23,
			isEditing: nameMenuOpen,
			onChange: t24,
			onClose: t25
		});
		$[41] = nameMenuOpen;
		$[42] = t23;
		$[43] = t24;
		$[44] = t26;
	} else t26 = $[44];
	let t27;
	if ($[45] !== end || $[46] !== start) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start,
			end
		});
		$[45] = end;
		$[46] = start;
		$[47] = t27;
	} else t27 = $[47];
	let t28;
	if ($[48] !== t26 || $[49] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t22,
			children: [t26, t27]
		});
		$[48] = t26;
		$[49] = t27;
		$[50] = t28;
	} else t28 = $[50];
	let t29;
	if ($[51] !== data || $[52] !== expenses || $[53] !== income || $[54] !== isCardHovered) {
		t29 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { textAlign: "right" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
				activationFilters: [!isCardHovered],
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Change, { amount: income - expenses })
			})
		});
		$[51] = data;
		$[52] = expenses;
		$[53] = income;
		$[54] = isCardHovered;
		$[55] = t29;
	} else t29 = $[55];
	let t30;
	if ($[56] !== t28 || $[57] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t21,
			children: [t28, t29]
		});
		$[56] = t28;
		$[57] = t29;
		$[58] = t30;
	} else t30 = $[58];
	let t31;
	if ($[59] !== animationProps || $[60] !== data || $[61] !== expenses || $[62] !== income || $[63] !== t) {
		t31 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, {
			style: {
				height: "auto",
				flex: 1
			},
			children: (width, height) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(BarChart, {
				responsive: true,
				width,
				height,
				data: [{
					income,
					expenses
				}],
				margin: {
					top: 10,
					bottom: 0
				},
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: "income",
					fill: theme.reportsNumberPositive,
					barSize: 14,
					...animationProps,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelList, {
						dataKey: "income",
						position: "left",
						content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomLabel, { name: t("Income") })
					})
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, {
					dataKey: "expenses",
					fill: theme.reportsNumberNegative,
					barSize: 14,
					...animationProps,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelList, {
						dataKey: "expenses",
						position: "right",
						content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomLabel, { name: t("Expenses") })
					})
				})]
			})
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[59] = animationProps;
		$[60] = data;
		$[61] = expenses;
		$[62] = income;
		$[63] = t;
		$[64] = t31;
	} else t31 = $[64];
	let t32;
	if ($[65] !== t30 || $[66] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t20,
			onPointerEnter: onCardHover,
			onPointerLeave: onCardHoverEnd,
			children: [t30, t31]
		});
		$[65] = t30;
		$[66] = t31;
		$[67] = t32;
	} else t32 = $[67];
	let t33;
	if ($[68] !== isEditing || $[69] !== nameMenuOpen || $[70] !== t13 || $[71] !== t18 || $[72] !== t19 || $[73] !== t32) {
		t33 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t13,
			menuItems: t18,
			onMenuSelect: t19,
			children: t32
		});
		$[68] = isEditing;
		$[69] = nameMenuOpen;
		$[70] = t13;
		$[71] = t18;
		$[72] = t19;
		$[73] = t32;
		$[74] = t33;
	} else t33 = $[74];
	return t33;
}
//#endregion
//#region src/components/reports/reports/CrossoverCard.tsx
function CrossoverCard(t0) {
	const $ = (0, import_compiler_runtime.c)(85);
	const { widgetId, isEditing, accounts, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const locale = useLocale();
	const { t } = useTranslation();
	const { data: t3 } = useCategories();
	let t4;
	if ($[2] !== t3) {
		t4 = t3 === void 0 ? {
			grouped: [],
			list: []
		} : t3;
		$[2] = t3;
		$[3] = t4;
	} else t4 = $[3];
	const categories = t4;
	const { isNarrowWidth } = useResponsive();
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const [start, setStart] = (0, import_react.useState)("");
	const [end, setEnd] = (0, import_react.useState)("");
	const format$2 = useFormat();
	let t5;
	if ($[4] !== locale || $[5] !== meta?.timeFrame) {
		t5 = () => {
			let isMounted = true;
			(async function calculateDateRange() {
				const previousMonth = subMonths(currentMonth(), 1);
				const earliestTransactionData = await send("get-earliest-transaction");
				if (!isMounted) return;
				const allMonths = rangeInclusive(earliestTransactionData ? earliestTransactionData.date : firstDayOfMonth(previousMonth), lastDayOfMonth(previousMonth)).map((month) => ({
					name: month,
					pretty: format(month, "MMMM yyyy", locale)
				})).reverse();
				const [initialStart, initialEnd, mode] = calculateTimeRange(meta?.timeFrame, defaultTimeFrame, previousMonth);
				const earliestMonth = allMonths[allMonths.length - 1].name;
				const latestMonth = allMonths[0].name;
				let start_0 = initialStart;
				let end_0 = initialEnd;
				const clampMonth = (m) => {
					if (isBefore(m, earliestMonth)) return earliestMonth;
					if (isAfter(m, latestMonth)) return latestMonth;
					return m;
				};
				if (mode === "sliding-window") {
					start_0 = clampMonth(subMonths(start_0, 1));
					end_0 = clampMonth(subMonths(end_0, 1));
				} else if (mode === "full") {
					start_0 = earliestMonth;
					end_0 = latestMonth;
				} else {
					start_0 = clampMonth(start_0);
					end_0 = clampMonth(end_0);
				}
				if (isBefore(end_0, start_0)) end_0 = start_0;
				if (isMounted) {
					setStart(start_0);
					setEnd(end_0);
				}
			})();
			return () => {
				isMounted = false;
			};
		};
		$[4] = locale;
		$[5] = meta?.timeFrame;
		$[6] = t5;
	} else t5 = $[6];
	const t6 = meta?.timeFrame;
	let t7;
	if ($[7] !== locale || $[8] !== t6) {
		t7 = [t6, locale];
		$[7] = locale;
		$[8] = t6;
		$[9] = t7;
	} else t7 = $[9];
	(0, import_react.useEffect)(t5, t7);
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	let t8;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsCardHovered(true);
		$[10] = t8;
	} else t8 = $[10];
	const onCardHover = t8;
	let t9;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = () => setIsCardHovered(false);
		$[11] = t9;
	} else t9 = $[11];
	const onCardHoverEnd = t9;
	const showHiddenCategories = meta?.showHiddenCategories ?? false;
	meta?.expenseCategoryIds;
	const storedIds = meta?.expenseCategoryIds;
	let t10;
	if ($[12] !== categories.list || $[13] !== showHiddenCategories || $[14] !== storedIds) {
		const base = storedIds !== void 0 ? categories.list.filter((c) => storedIds.includes(c.id)) : categories.list.filter(_temp$2);
		let t11;
		if ($[16] !== showHiddenCategories) {
			t11 = (c_1) => showHiddenCategories || !c_1.hidden;
			$[16] = showHiddenCategories;
			$[17] = t11;
		} else t11 = $[17];
		t10 = base.filter(t11).map(_temp2$1);
		$[12] = categories.list;
		$[13] = showHiddenCategories;
		$[14] = storedIds;
		$[15] = t10;
	} else t10 = $[15];
	const expenseCategoryIds = t10;
	let t11;
	if ($[18] !== accounts || $[19] !== meta?.incomeAccountIds) {
		t11 = () => meta?.incomeAccountIds ?? accounts.map(_temp3$1);
		$[18] = accounts;
		$[19] = meta?.incomeAccountIds;
		$[20] = t11;
	} else t11 = $[20];
	meta?.incomeAccountIds;
	let t12;
	if ($[21] !== t11) {
		t12 = t11();
		$[21] = t11;
		$[22] = t12;
	} else t12 = $[22];
	const incomeAccountIds = t12;
	const swr = meta?.safeWithdrawalRate ?? .04;
	const estimatedReturn = meta?.estimatedReturn ?? null;
	const expectedContribution = meta?.expectedContribution ?? null;
	const projectionType = meta?.projectionType ?? "hampel";
	const expenseAdjustmentFactor = meta?.expenseAdjustmentFactor ?? 1;
	let t13;
	if ($[23] !== end || $[24] !== estimatedReturn || $[25] !== expectedContribution || $[26] !== expenseAdjustmentFactor || $[27] !== expenseCategoryIds || $[28] !== incomeAccountIds || $[29] !== projectionType || $[30] !== start || $[31] !== swr) {
		t13 = createCrossoverSpreadsheet({
			start,
			end,
			expenseCategoryIds,
			incomeAccountIds,
			safeWithdrawalRate: swr,
			estimatedReturn,
			expectedContribution,
			projectionType,
			expenseAdjustmentFactor
		});
		$[23] = end;
		$[24] = estimatedReturn;
		$[25] = expectedContribution;
		$[26] = expenseAdjustmentFactor;
		$[27] = expenseCategoryIds;
		$[28] = incomeAccountIds;
		$[29] = projectionType;
		$[30] = start;
		$[31] = swr;
		$[32] = t13;
	} else t13 = $[32];
	const data = useReport$1("crossover", t13);
	const yearsToRetire = data?.yearsToRetire ?? null;
	const t14 = `/reports/crossover/${widgetId}`;
	let t15;
	if ($[33] !== t) {
		t15 = t("Rename");
		$[33] = t;
		$[34] = t15;
	} else t15 = $[34];
	let t16;
	if ($[35] !== t15) {
		t16 = {
			name: "rename",
			text: t15
		};
		$[35] = t15;
		$[36] = t16;
	} else t16 = $[36];
	let t17;
	if ($[37] !== t) {
		t17 = t("Remove");
		$[37] = t;
		$[38] = t17;
	} else t17 = $[38];
	let t18;
	if ($[39] !== t17) {
		t18 = {
			name: "remove",
			text: t17
		};
		$[39] = t17;
		$[40] = t18;
	} else t18 = $[40];
	let t19;
	if ($[41] !== copyMenuItems || $[42] !== t16 || $[43] !== t18) {
		t19 = [
			t16,
			t18,
			...copyMenuItems
		];
		$[41] = copyMenuItems;
		$[42] = t16;
		$[43] = t18;
		$[44] = t19;
	} else t19 = $[44];
	let t20;
	if ($[45] !== handleCopyMenuSelect || $[46] !== onRemove) {
		t20 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb156: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb156;
				case "remove":
					onRemove();
					break bb156;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[45] = handleCopyMenuSelect;
		$[46] = onRemove;
		$[47] = t20;
	} else t20 = $[47];
	let t21;
	if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = { flex: 1 };
		$[48] = t21;
	} else t21 = $[48];
	let t22;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = {
			flexDirection: "row",
			padding: 20
		};
		$[49] = t22;
	} else t22 = $[49];
	let t23;
	if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = { flex: 1 };
		$[50] = t23;
	} else t23 = $[50];
	let t24;
	if ($[51] !== meta?.name || $[52] !== t) {
		t24 = meta?.name || t("Crossover Point");
		$[51] = meta?.name;
		$[52] = t;
		$[53] = t24;
	} else t24 = $[53];
	let t25;
	if ($[54] !== meta || $[55] !== onMetaChange) {
		t25 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[54] = meta;
		$[55] = onMetaChange;
		$[56] = t25;
	} else t25 = $[56];
	let t26;
	if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
		t26 = () => setNameMenuOpen(false);
		$[57] = t26;
	} else t26 = $[57];
	let t27;
	if ($[58] !== nameMenuOpen || $[59] !== t24 || $[60] !== t25) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t23,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
				name: t24,
				isEditing: nameMenuOpen,
				onChange: t25,
				onClose: t26
			})
		});
		$[58] = nameMenuOpen;
		$[59] = t24;
		$[60] = t25;
		$[61] = t27;
	} else t27 = $[61];
	let t28;
	if ($[62] !== data || $[63] !== format$2 || $[64] !== isCardHovered || $[65] !== t || $[66] !== yearsToRetire) {
		t28 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				textAlign: "right",
				whiteSpace: "nowrap"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				style: {
					...styles.mediumText,
					fontWeight: 500,
					marginBottom: 5
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
					activationFilters: [!isCardHovered],
					children: yearsToRetire != null ? t("{{years}} years", { years: format$2(yearsToRetire, "number") }) : t("N/A")
				})
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				style: {
					fontSize: 12,
					color: theme.pageTextSubdued
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Years to Retire" })
			})]
		});
		$[62] = data;
		$[63] = format$2;
		$[64] = isCardHovered;
		$[65] = t;
		$[66] = yearsToRetire;
		$[67] = t28;
	} else t28 = $[67];
	let t29;
	if ($[68] !== t27 || $[69] !== t28) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t22,
			children: [t27, t28]
		});
		$[68] = t27;
		$[69] = t28;
		$[70] = t29;
	} else t29 = $[70];
	let t30;
	if ($[71] !== data || $[72] !== isEditing || $[73] !== isNarrowWidth) {
		t30 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CrossoverGraph, {
			graphData: data.graphData,
			compact: true,
			showTooltip: !isEditing && !isNarrowWidth,
			style: {
				height: "auto",
				flex: 1
			}
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[71] = data;
		$[72] = isEditing;
		$[73] = isNarrowWidth;
		$[74] = t30;
	} else t30 = $[74];
	let t31;
	if ($[75] !== t29 || $[76] !== t30) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t21,
			onPointerEnter: onCardHover,
			onPointerLeave: onCardHoverEnd,
			children: [t29, t30]
		});
		$[75] = t29;
		$[76] = t30;
		$[77] = t31;
	} else t31 = $[77];
	let t32;
	if ($[78] !== isEditing || $[79] !== nameMenuOpen || $[80] !== t14 || $[81] !== t19 || $[82] !== t20 || $[83] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t14,
			menuItems: t19,
			onMenuSelect: t20,
			children: t31
		});
		$[78] = isEditing;
		$[79] = nameMenuOpen;
		$[80] = t14;
		$[81] = t19;
		$[82] = t20;
		$[83] = t31;
		$[84] = t32;
	} else t32 = $[84];
	return t32;
}
function _temp3$1(a) {
	return a.id;
}
function _temp2$1(c_2) {
	return c_2.id;
}
function _temp$2(c_0) {
	return !c_0.is_income;
}
//#endregion
//#region src/components/reports/reports/GetCardData.tsx
function ErrorFallback() {
	const $ = (0, import_compiler_runtime.c)(2);
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}) });
		$[0] = t0;
	} else t0 = $[0];
	let t1;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [t0, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: {
				...styles.mediumText,
				color: theme.errorText
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "There was a problem loading your report" })
		})] });
		$[1] = t1;
	} else t1 = $[1];
	return t1;
}
function convertFromDate(interval) {
	switch (interval) {
		case "Monthly": return "monthFromDate";
		case "Yearly": return "yearFromDate";
		default: return "dayFromDate";
	}
}
function convertRangeInclusive(interval) {
	switch (interval) {
		case "Monthly": return "rangeInclusive";
		case "Yearly": return "yearRangeInclusive";
		default: return "dayRangeInclusive";
	}
}
function GetCardData(t0) {
	const $ = (0, import_compiler_runtime.c)(61);
	const { report, payees, accounts, categories, earliestTransaction, latestTransaction, firstDayOfWeekIdx, showTooltip } = t0;
	const { isNarrowWidth } = useResponsive();
	const [t1] = useSyncedPref("budgetType");
	const budgetType = t1 === void 0 ? "envelope" : t1;
	let endDate;
	let intervals;
	let startDate;
	if ($[0] !== earliestTransaction || $[1] !== firstDayOfWeekIdx || $[2] !== latestTransaction || $[3] !== report.dateRange || $[4] !== report.endDate || $[5] !== report.includeCurrentInterval || $[6] !== report.interval || $[7] !== report.isDateStatic || $[8] !== report.startDate) {
		startDate = report.startDate;
		endDate = report.endDate;
		if (!report.isDateStatic) {
			const [dateStart, dateEnd] = getLiveRange(report.dateRange, earliestTransaction, latestTransaction, report.includeCurrentInterval, firstDayOfWeekIdx);
			startDate = dateStart || report.startDate;
			endDate = dateEnd || report.endDate;
		}
		const fromDate = convertFromDate(report.interval);
		const rangeInclusive = convertRangeInclusive(report.interval);
		let intervalDateStart;
		let intervalDateEnd;
		if (report.interval === "Weekly") {
			intervalDateStart = weekFromDate(startDate, firstDayOfWeekIdx);
			intervalDateEnd = weekFromDate(endDate, firstDayOfWeekIdx);
			intervals = weekRangeInclusive(intervalDateStart, intervalDateEnd, firstDayOfWeekIdx);
		} else {
			intervalDateStart = months_exports[fromDate](startDate);
			intervalDateEnd = months_exports[fromDate](endDate);
			intervals = months_exports[rangeInclusive](intervalDateStart, intervalDateEnd);
		}
		$[0] = earliestTransaction;
		$[1] = firstDayOfWeekIdx;
		$[2] = latestTransaction;
		$[3] = report.dateRange;
		$[4] = report.endDate;
		$[5] = report.includeCurrentInterval;
		$[6] = report.interval;
		$[7] = report.isDateStatic;
		$[8] = report.startDate;
		$[9] = endDate;
		$[10] = intervals;
		$[11] = startDate;
	} else {
		endDate = $[9];
		intervals = $[10];
		startDate = $[11];
	}
	let t2;
	if ($[12] !== budgetType || $[13] !== categories || $[14] !== endDate || $[15] !== firstDayOfWeekIdx || $[16] !== report.balanceType || $[17] !== report.conditions || $[18] !== report.conditionsOp || $[19] !== report.interval || $[20] !== report.showEmpty || $[21] !== report.showHiddenCategories || $[22] !== report.showOffBudget || $[23] !== report.showUncategorized || $[24] !== report.sortBy || $[25] !== report.trimIntervals || $[26] !== startDate) {
		t2 = createGroupedSpreadsheet({
			startDate,
			endDate,
			interval: report.interval,
			categories,
			budgetType,
			conditions: report.conditions ?? [],
			conditionsOp: report.conditionsOp,
			showEmpty: report.showEmpty,
			showOffBudget: report.showOffBudget,
			showHiddenCategories: report.showHiddenCategories,
			showUncategorized: report.showUncategorized,
			trimIntervals: report.trimIntervals,
			balanceTypeOp: ReportOptions.balanceTypeMap.get(report.balanceType),
			firstDayOfWeekIdx,
			sortByOp: report.sortBy
		});
		$[12] = budgetType;
		$[13] = categories;
		$[14] = endDate;
		$[15] = firstDayOfWeekIdx;
		$[16] = report.balanceType;
		$[17] = report.conditions;
		$[18] = report.conditionsOp;
		$[19] = report.interval;
		$[20] = report.showEmpty;
		$[21] = report.showHiddenCategories;
		$[22] = report.showOffBudget;
		$[23] = report.showUncategorized;
		$[24] = report.sortBy;
		$[25] = report.trimIntervals;
		$[26] = startDate;
		$[27] = t2;
	} else t2 = $[27];
	const getGroupData = t2;
	let t3;
	if ($[28] !== accounts || $[29] !== budgetType || $[30] !== categories || $[31] !== endDate || $[32] !== firstDayOfWeekIdx || $[33] !== payees || $[34] !== report.balanceType || $[35] !== report.conditions || $[36] !== report.conditionsOp || $[37] !== report.graphType || $[38] !== report.groupBy || $[39] !== report.interval || $[40] !== report.showEmpty || $[41] !== report.showHiddenCategories || $[42] !== report.showOffBudget || $[43] !== report.showUncategorized || $[44] !== report.sortBy || $[45] !== report.trimIntervals || $[46] !== startDate) {
		t3 = createCustomSpreadsheet({
			startDate,
			endDate,
			interval: report.interval,
			categories,
			budgetType,
			conditions: report.conditions ?? [],
			conditionsOp: report.conditionsOp,
			showEmpty: report.showEmpty,
			showOffBudget: report.showOffBudget,
			showHiddenCategories: report.showHiddenCategories,
			showUncategorized: report.showUncategorized,
			trimIntervals: report.trimIntervals,
			groupBy: report.groupBy,
			balanceTypeOp: ReportOptions.balanceTypeMap.get(report.balanceType),
			payees,
			accounts,
			graphType: report.graphType,
			firstDayOfWeekIdx,
			sortByOp: report.sortBy
		});
		$[28] = accounts;
		$[29] = budgetType;
		$[30] = categories;
		$[31] = endDate;
		$[32] = firstDayOfWeekIdx;
		$[33] = payees;
		$[34] = report.balanceType;
		$[35] = report.conditions;
		$[36] = report.conditionsOp;
		$[37] = report.graphType;
		$[38] = report.groupBy;
		$[39] = report.interval;
		$[40] = report.showEmpty;
		$[41] = report.showHiddenCategories;
		$[42] = report.showOffBudget;
		$[43] = report.showUncategorized;
		$[44] = report.sortBy;
		$[45] = report.trimIntervals;
		$[46] = startDate;
		$[47] = t3;
	} else t3 = $[47];
	const getGraphData = t3;
	const graphData = useReport$1("default" + report.name, getGraphData);
	const groupedData = useReport$1("grouped" + report.name, getGroupData);
	let t4;
	if ($[48] !== graphData || $[49] !== groupedData) {
		t4 = graphData && groupedData ? {
			...graphData,
			groupedData
		} : graphData;
		$[48] = graphData;
		$[49] = groupedData;
		$[50] = t4;
	} else t4 = $[50];
	const data = t4;
	let t5;
	if ($[51] !== data || $[52] !== intervals || $[53] !== isNarrowWidth || $[54] !== report.balanceType || $[55] !== report.graphType || $[56] !== report.groupBy || $[57] !== report.interval || $[58] !== report.mode || $[59] !== showTooltip) {
		t5 = data?.data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(m, {
			FallbackComponent: ErrorFallback,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChooseGraph, {
				data,
				mode: report.mode,
				graphType: report.graphType,
				balanceType: report.balanceType,
				groupBy: report.groupBy,
				interval: report.interval,
				compact: true,
				style: {
					height: "auto",
					flex: 1
				},
				intervalsCount: intervals.length,
				showTooltip: !isNarrowWidth && showTooltip
			})
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[51] = data;
		$[52] = intervals;
		$[53] = isNarrowWidth;
		$[54] = report.balanceType;
		$[55] = report.graphType;
		$[56] = report.groupBy;
		$[57] = report.interval;
		$[58] = report.mode;
		$[59] = showTooltip;
		$[60] = t5;
	} else t5 = $[60];
	return t5;
}
//#endregion
//#region src/components/reports/reports/MissingReportCard.tsx
function MissingReportCard(t0) {
	const $ = (0, import_compiler_runtime.c)(14);
	const { isEditing, onRemove, children } = t0;
	const { t } = useTranslation();
	let t1;
	if ($[0] !== t) {
		t1 = t("Remove");
		$[0] = t;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== t1) {
		t2 = [{
			name: "remove",
			text: t1
		}];
		$[2] = t1;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== onRemove) {
		t3 = (item) => {
			bb2: switch (item) {
				case "remove":
					onRemove();
					break bb2;
				default: throw new Error(`Unrecognized menu option: ${item}`);
			}
		};
		$[4] = onRemove;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			flex: 1,
			alignItems: "center",
			justifyContent: "center",
			padding: 10
		};
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== children) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t4,
			children
		});
		$[7] = children;
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] !== isEditing || $[10] !== t2 || $[11] !== t3 || $[12] !== t5) {
		t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			menuItems: t2,
			onMenuSelect: t3,
			children: t5
		});
		$[9] = isEditing;
		$[10] = t2;
		$[11] = t3;
		$[12] = t5;
		$[13] = t6;
	} else t6 = $[13];
	return t6;
}
//#endregion
//#region src/components/reports/reports/CustomReportListCards.tsx
function CustomReportListCards(t0) {
	const $ = (0, import_compiler_runtime.c)(9);
	const { isEditing, report, onRemove, onCopy } = t0;
	if (!report) {
		let t1;
		if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
			t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "This custom report has been deleted." });
			$[0] = t1;
		} else t1 = $[0];
		let t2;
		if ($[1] !== isEditing || $[2] !== onRemove) {
			t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MissingReportCard, {
				isEditing,
				onRemove,
				children: t1
			});
			$[1] = isEditing;
			$[2] = onRemove;
			$[3] = t2;
		} else t2 = $[3];
		return t2;
	}
	let t1;
	if ($[4] !== isEditing || $[5] !== onCopy || $[6] !== onRemove || $[7] !== report) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomReportListCardsInner, {
			isEditing,
			report,
			onRemove,
			onCopy
		});
		$[4] = isEditing;
		$[5] = onCopy;
		$[6] = onRemove;
		$[7] = report;
		$[8] = t1;
	} else t1 = $[8];
	return t1;
}
function CustomReportListCardsInner(t0) {
	const $ = (0, import_compiler_runtime.c)(62);
	const { isEditing, report, onRemove, onCopy } = t0;
	const { t } = useTranslation();
	const dispatch = useDispatch();
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const [earliestTransaction, setEarliestTransaction] = (0, import_react.useState)("");
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const { data: t1 } = usePayees();
	const payees = t1 === void 0 ? [] : t1;
	const { data: t2 } = useAccounts();
	const accounts = t2 === void 0 ? [] : t2;
	const { data: t3 } = useCategories();
	const categories = t3 === void 0 ? {
		list: [],
		grouped: []
	} : t3;
	const hasWarning = calculateHasWarning(report.conditions ?? [], {
		categories: categories.list,
		payees,
		accounts
	});
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	let t4;
	let t5;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = () => {
			(async function run() {
				const earliestTrans = await send("get-earliest-transaction");
				const latestTrans = await send("get-latest-transaction");
				setEarliestTransaction(earliestTrans ? earliestTrans.date : currentDay());
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
			})();
		};
		t5 = [];
		$[0] = t4;
		$[1] = t5;
	} else {
		t4 = $[0];
		t5 = $[1];
	}
	(0, import_react.useEffect)(t4, t5);
	const updateReportMutation = useUpdateReportMutation();
	let t6;
	if ($[2] !== dispatch || $[3] !== report || $[4] !== t || $[5] !== updateReportMutation) {
		t6 = async (name) => {
			const updatedReport = {
				...report,
				name
			};
			updateReportMutation.mutate({ report: updatedReport }, {
				onSuccess: () => {
					setNameMenuOpen(false);
				},
				onError: (error) => {
					dispatch(addNotification({ notification: {
						type: "error",
						message: t("Failed saving report name: {{error}}", { error: error.message })
					} }));
					setNameMenuOpen(true);
				}
			});
		};
		$[2] = dispatch;
		$[3] = report;
		$[4] = t;
		$[5] = updateReportMutation;
		$[6] = t6;
	} else t6 = $[6];
	const onSaveName = t6;
	const t7 = `/reports/custom/${report.id}`;
	let t8;
	if ($[7] !== t) {
		t8 = t("Rename");
		$[7] = t;
		$[8] = t8;
	} else t8 = $[8];
	let t9;
	if ($[9] !== t8) {
		t9 = {
			name: "rename",
			text: t8
		};
		$[9] = t8;
		$[10] = t9;
	} else t9 = $[10];
	let t10;
	if ($[11] !== t) {
		t10 = t("Remove");
		$[11] = t;
		$[12] = t10;
	} else t10 = $[12];
	let t11;
	if ($[13] !== t10) {
		t11 = {
			name: "remove",
			text: t10
		};
		$[13] = t10;
		$[14] = t11;
	} else t11 = $[14];
	let t12;
	if ($[15] !== copyMenuItems || $[16] !== t11 || $[17] !== t9) {
		t12 = [
			t9,
			t11,
			...copyMenuItems
		];
		$[15] = copyMenuItems;
		$[16] = t11;
		$[17] = t9;
		$[18] = t12;
	} else t12 = $[18];
	let t13;
	if ($[19] !== handleCopyMenuSelect || $[20] !== onRemove) {
		t13 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb38: switch (item) {
				case "remove":
					onRemove();
					break bb38;
				case "rename":
					setNameMenuOpen(true);
					break bb38;
				default: throw new Error(`Unrecognized menu option: ${item}`);
			}
		};
		$[19] = handleCopyMenuSelect;
		$[20] = onRemove;
		$[21] = t13;
	} else t13 = $[21];
	let t14;
	if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = {
			flex: 1,
			padding: 10
		};
		$[22] = t14;
	} else t14 = $[22];
	let t15;
	if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = {
			flexShrink: 0,
			paddingBottom: 5
		};
		$[23] = t15;
	} else t15 = $[23];
	let t16;
	if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = { flex: 1 };
		$[24] = t16;
	} else t16 = $[24];
	let t17;
	if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = () => setNameMenuOpen(false);
		$[25] = t17;
	} else t17 = $[25];
	let t18;
	if ($[26] !== nameMenuOpen || $[27] !== onSaveName || $[28] !== report.name) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: report.name,
			isEditing: nameMenuOpen,
			onChange: onSaveName,
			onClose: t17
		});
		$[26] = nameMenuOpen;
		$[27] = onSaveName;
		$[28] = report.name;
		$[29] = t18;
	} else t18 = $[29];
	let t19;
	if ($[30] !== report.dateRange || $[31] !== report.endDate || $[32] !== report.isDateStatic || $[33] !== report.startDate || $[34] !== t) {
		t19 = report.isDateStatic ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start: report.startDate,
			end: report.endDate
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			style: { color: theme.pageTextSubdued },
			children: t(report.dateRange)
		});
		$[30] = report.dateRange;
		$[31] = report.endDate;
		$[32] = report.isDateStatic;
		$[33] = report.startDate;
		$[34] = t;
		$[35] = t19;
	} else t19 = $[35];
	let t20;
	if ($[36] !== t18 || $[37] !== t19) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t15,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
				style: t16,
				children: [t18, t19]
			})
		});
		$[36] = t18;
		$[37] = t19;
		$[38] = t20;
	} else t20 = $[38];
	const t21 = !isEditing;
	let t22;
	if ($[39] !== accounts || $[40] !== categories || $[41] !== earliestTransaction || $[42] !== firstDayOfWeekIdx || $[43] !== latestTransaction || $[44] !== payees || $[45] !== report || $[46] !== t21) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GetCardData, {
			report,
			payees,
			accounts,
			categories,
			earliestTransaction,
			latestTransaction,
			firstDayOfWeekIdx,
			showTooltip: t21
		});
		$[39] = accounts;
		$[40] = categories;
		$[41] = earliestTransaction;
		$[42] = firstDayOfWeekIdx;
		$[43] = latestTransaction;
		$[44] = payees;
		$[45] = report;
		$[46] = t21;
		$[47] = t22;
	} else t22 = $[47];
	let t23;
	if ($[48] !== t20 || $[49] !== t22) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t14,
			children: [t20, t22]
		});
		$[48] = t20;
		$[49] = t22;
		$[50] = t23;
	} else t23 = $[50];
	let t24;
	if ($[51] !== hasWarning || $[52] !== t) {
		t24 = hasWarning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: 5,
				position: "absolute",
				bottom: 0
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
				content: t("The widget is configured to use a non-existing filter value (i.e. category/account/payee). Edit the filters used in this report widget to remove the warning."),
				placement: "bottom start",
				style: {
					...styles.tooltip,
					maxWidth: 300
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgExclamationSolid, {
					width: 20,
					height: 20,
					style: { color: theme.warningText }
				})
			})
		});
		$[51] = hasWarning;
		$[52] = t;
		$[53] = t24;
	} else t24 = $[53];
	let t25;
	if ($[54] !== isEditing || $[55] !== nameMenuOpen || $[56] !== t12 || $[57] !== t13 || $[58] !== t23 || $[59] !== t24 || $[60] !== t7) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t7,
			menuItems: t12,
			onMenuSelect: t13,
			children: [t23, t24]
		});
		$[54] = isEditing;
		$[55] = nameMenuOpen;
		$[56] = t12;
		$[57] = t13;
		$[58] = t23;
		$[59] = t24;
		$[60] = t7;
		$[61] = t25;
	} else t25 = $[61];
	return t25;
}
//#endregion
//#region src/components/reports/reports/FormulaCard.tsx
function FormulaCard(t0) {
	const $ = (0, import_compiler_runtime.c)(63);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const { t } = useTranslation();
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const themeColors = useThemeColors();
	const containerRef = (0, import_react.useRef)(null);
	const formula = meta?.formula || "=SUM(1, 2, 3)";
	const fontSize = meta?.fontSize;
	const fontSizeMode = meta?.fontSizeMode || "dynamic";
	const staticFontSize = meta?.staticFontSize || 32;
	const colorFormula = meta?.colorFormula || "";
	let t3;
	if ($[2] !== meta?.queries) {
		t3 = meta?.queries || {};
		$[2] = meta?.queries;
		$[3] = t3;
	} else t3 = $[3];
	const { result, isLoading, error } = useFormulaExecution(formula, t3, meta?.queriesVersion);
	const t4 = result ?? 0;
	let t5;
	if ($[4] !== themeColors) {
		t5 = Object.entries(themeColors).reduce(_temp$1, {});
		$[4] = themeColors;
		$[5] = t5;
	} else t5 = $[5];
	let t6;
	if ($[6] !== t4 || $[7] !== t5) {
		t6 = {
			RESULT: t4,
			...t5
		};
		$[6] = t4;
		$[7] = t5;
		$[8] = t6;
	} else t6 = $[8];
	const colorVariables = t6;
	let t7;
	if ($[9] !== meta?.queries) {
		t7 = meta?.queries || {};
		$[9] = meta?.queries;
		$[10] = t7;
	} else t7 = $[10];
	const { result: colorResult, error: colorError } = useFormulaExecution(colorFormula, t7, meta?.queriesVersion, colorVariables);
	const customColor = colorFormula && !colorError && colorResult ? String(colorResult) : null;
	const t8 = `/reports/formula/${widgetId}`;
	let t9;
	if ($[11] !== t) {
		t9 = t("Rename");
		$[11] = t;
		$[12] = t9;
	} else t9 = $[12];
	let t10;
	if ($[13] !== t9) {
		t10 = {
			name: "rename",
			text: t9
		};
		$[13] = t9;
		$[14] = t10;
	} else t10 = $[14];
	let t11;
	if ($[15] !== t) {
		t11 = t("Remove");
		$[15] = t;
		$[16] = t11;
	} else t11 = $[16];
	let t12;
	if ($[17] !== t11) {
		t12 = {
			name: "remove",
			text: t11
		};
		$[17] = t11;
		$[18] = t12;
	} else t12 = $[18];
	let t13;
	if ($[19] !== copyMenuItems || $[20] !== t10 || $[21] !== t12) {
		t13 = [
			t10,
			t12,
			...copyMenuItems
		];
		$[19] = copyMenuItems;
		$[20] = t10;
		$[21] = t12;
		$[22] = t13;
	} else t13 = $[22];
	let t14;
	if ($[23] !== handleCopyMenuSelect || $[24] !== onRemove) {
		t14 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb89: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb89;
				case "remove":
					onRemove();
					break bb89;
				default:
			}
		};
		$[23] = handleCopyMenuSelect;
		$[24] = onRemove;
		$[25] = t14;
	} else t14 = $[25];
	let t15;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = {
			flex: 1,
			overflow: "hidden"
		};
		$[26] = t15;
	} else t15 = $[26];
	let t16;
	if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = {
			flexGrow: 0,
			flexShrink: 0,
			padding: 20
		};
		$[27] = t16;
	} else t16 = $[27];
	let t17;
	if ($[28] !== meta?.name || $[29] !== t) {
		t17 = meta?.name || t("Formula");
		$[28] = meta?.name;
		$[29] = t;
		$[30] = t17;
	} else t17 = $[30];
	let t18;
	if ($[31] !== meta || $[32] !== onMetaChange) {
		t18 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[31] = meta;
		$[32] = onMetaChange;
		$[33] = t18;
	} else t18 = $[33];
	let t19;
	if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
		t19 = () => setNameMenuOpen(false);
		$[34] = t19;
	} else t19 = $[34];
	let t20;
	if ($[35] !== nameMenuOpen || $[36] !== t17 || $[37] !== t18) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t16,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
				name: t17,
				isEditing: nameMenuOpen,
				onChange: t18,
				onClose: t19
			})
		});
		$[35] = nameMenuOpen;
		$[36] = t17;
		$[37] = t18;
		$[38] = t20;
	} else t20 = $[38];
	let t21;
	if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			justifyContent: "center",
			alignItems: "center",
			flexGrow: 1,
			flexShrink: 1
		};
		$[39] = t21;
	} else t21 = $[39];
	let t22;
	if ($[40] !== meta || $[41] !== onMetaChange) {
		t22 = (newSize) => {
			onMetaChange({
				...meta,
				fontSize: newSize
			});
		};
		$[40] = meta;
		$[41] = onMetaChange;
		$[42] = t22;
	} else t22 = $[42];
	const t23 = isEditing ?? false;
	let t24;
	if ($[43] !== customColor || $[44] !== error || $[45] !== fontSize || $[46] !== fontSizeMode || $[47] !== isLoading || $[48] !== result || $[49] !== staticFontSize || $[50] !== t22 || $[51] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			ref: containerRef,
			style: t21,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaResult, {
				value: result,
				error,
				loading: isLoading,
				initialFontSize: fontSize,
				fontSizeChanged: t22,
				fontSizeMode,
				staticFontSize,
				customColor,
				animate: t23,
				containerRef
			})
		});
		$[43] = customColor;
		$[44] = error;
		$[45] = fontSize;
		$[46] = fontSizeMode;
		$[47] = isLoading;
		$[48] = result;
		$[49] = staticFontSize;
		$[50] = t22;
		$[51] = t23;
		$[52] = t24;
	} else t24 = $[52];
	let t25;
	if ($[53] !== t20 || $[54] !== t24) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t15,
			children: [t20, t24]
		});
		$[53] = t20;
		$[54] = t24;
		$[55] = t25;
	} else t25 = $[55];
	let t26;
	if ($[56] !== isEditing || $[57] !== nameMenuOpen || $[58] !== t13 || $[59] !== t14 || $[60] !== t25 || $[61] !== t8) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t8,
			menuItems: t13,
			onMenuSelect: t14,
			children: t25
		});
		$[56] = isEditing;
		$[57] = nameMenuOpen;
		$[58] = t13;
		$[59] = t14;
		$[60] = t25;
		$[61] = t8;
		$[62] = t26;
	} else t26 = $[62];
	return t26;
}
function _temp$1(acc, t0) {
	const [key, value] = t0;
	acc[`theme_${key}`] = value;
	return acc;
}
//#endregion
//#region src/components/reports/reports/MarkdownCard.tsx
var remarkPlugins = [
	sequentialNewlinesPlugin,
	remarkGfm,
	remarkBreaks
];
var markdownStyles = css(markdownBaseStyles, {
	paddingRight: 20,
	"& table": {
		display: "inline-table",
		":not(:last-child)": { marginBottom: "0.75rem" }
	}
});
function MarkdownCard(t0) {
	const $ = (0, import_compiler_runtime.c)(52);
	const { isEditing, meta, onMetaChange, onRemove, onCopy } = t0;
	const { t } = useTranslation();
	const [isVisibleTextArea, setIsVisibleTextArea] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	let t1;
	if ($[0] !== t) {
		t1 = t("Text position:");
		$[0] = t;
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] !== t1) {
		t2 = {
			type: Menu.label,
			name: t1,
			text: ""
		};
		$[2] = t1;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== t) {
		t3 = t("Left");
		$[4] = t;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t3) {
		t4 = {
			name: "text-left",
			text: t3
		};
		$[6] = t3;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== t) {
		t5 = t("Center");
		$[8] = t;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] !== t5) {
		t6 = {
			name: "text-center",
			text: t5
		};
		$[10] = t5;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] !== t) {
		t7 = t("Right");
		$[12] = t;
		$[13] = t7;
	} else t7 = $[13];
	let t8;
	if ($[14] !== t7) {
		t8 = {
			name: "text-right",
			text: t7
		};
		$[14] = t7;
		$[15] = t8;
	} else t8 = $[15];
	let t9;
	if ($[16] !== t) {
		t9 = t("Edit content");
		$[16] = t;
		$[17] = t9;
	} else t9 = $[17];
	let t10;
	if ($[18] !== t9) {
		t10 = {
			name: "edit",
			text: t9
		};
		$[18] = t9;
		$[19] = t10;
	} else t10 = $[19];
	let t11;
	if ($[20] !== t) {
		t11 = t("Remove");
		$[20] = t;
		$[21] = t11;
	} else t11 = $[21];
	let t12;
	if ($[22] !== t11) {
		t12 = {
			name: "remove",
			text: t11
		};
		$[22] = t11;
		$[23] = t12;
	} else t12 = $[23];
	let t13;
	if ($[24] !== copyMenuItems || $[25] !== t10 || $[26] !== t12 || $[27] !== t2 || $[28] !== t4 || $[29] !== t6 || $[30] !== t8) {
		t13 = [
			t2,
			t4,
			t6,
			t8,
			Menu.line,
			t10,
			t12,
			...copyMenuItems
		];
		$[24] = copyMenuItems;
		$[25] = t10;
		$[26] = t12;
		$[27] = t2;
		$[28] = t4;
		$[29] = t6;
		$[30] = t8;
		$[31] = t13;
	} else t13 = $[31];
	let t14;
	if ($[32] !== handleCopyMenuSelect || $[33] !== meta || $[34] !== onMetaChange || $[35] !== onRemove) {
		t14 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb5: switch (item) {
				case "text-left":
					onMetaChange({
						...meta,
						text_align: "left"
					});
					break bb5;
				case "text-center":
					onMetaChange({
						...meta,
						text_align: "center"
					});
					break bb5;
				case "text-right":
					onMetaChange({
						...meta,
						text_align: "right"
					});
					break bb5;
				case "edit":
					setIsVisibleTextArea(true);
					break bb5;
				case "remove":
					onRemove();
					break bb5;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[32] = handleCopyMenuSelect;
		$[33] = meta;
		$[34] = onMetaChange;
		$[35] = onRemove;
		$[36] = t14;
	} else t14 = $[36];
	let t15;
	if ($[37] !== meta.text_align) {
		t15 = {
			flex: 1,
			paddingTop: 5,
			paddingLeft: 20,
			overflowY: "auto",
			height: "100%",
			textAlign: meta.text_align
		};
		$[37] = meta.text_align;
		$[38] = t15;
	} else t15 = $[38];
	let t16;
	if ($[39] !== isVisibleTextArea || $[40] !== meta || $[41] !== onMetaChange) {
		t16 = isVisibleTextArea ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)($216918bed6669f72$export$f5c9f3c2c4054eec, {
			style: {
				height: "100%",
				border: 0,
				marginTop: 11,
				marginBottom: 11,
				marginRight: 20,
				color: theme.formInputText,
				backgroundColor: theme.tableBackground
			},
			className: NON_DRAGGABLE_AREA_CLASS_NAME,
			autoFocus: true,
			defaultValue: meta.content,
			onBlur: (event) => {
				onMetaChange({
					...meta,
					content: event.currentTarget.value
				});
				setIsVisibleTextArea(false);
			}
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
			className: markdownStyles,
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, {
				remarkPlugins,
				rehypePlugins: [[rehypeExternalLinks, {
					target: "_blank",
					rel: ["noopener", "noreferrer"]
				}]],
				children: meta.content
			})
		});
		$[39] = isVisibleTextArea;
		$[40] = meta;
		$[41] = onMetaChange;
		$[42] = t16;
	} else t16 = $[42];
	let t17;
	if ($[43] !== t15 || $[44] !== t16) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t15,
			children: t16
		});
		$[43] = t15;
		$[44] = t16;
		$[45] = t17;
	} else t17 = $[45];
	let t18;
	if ($[46] !== isEditing || $[47] !== isVisibleTextArea || $[48] !== t13 || $[49] !== t14 || $[50] !== t17) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: isVisibleTextArea,
			menuItems: t13,
			onMenuSelect: t14,
			children: t17
		});
		$[46] = isEditing;
		$[47] = isVisibleTextArea;
		$[48] = t13;
		$[49] = t14;
		$[50] = t17;
		$[51] = t18;
	} else t18 = $[51];
	return t18;
}
//#endregion
//#region src/components/reports/reports/NetWorthCard.tsx
function NetWorthCard(t0) {
	const $ = (0, import_compiler_runtime.c)(77);
	const { widgetId, isEditing, accounts, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const locale = useLocale();
	const { t } = useTranslation();
	const { isNarrowWidth } = useResponsive();
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const format = useFormat();
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	let t3;
	let t4;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = () => {
			(async function fetchLatestTransaction() {
				const latestTrans = await send("get-latest-transaction");
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
			})();
		};
		t4 = [];
		$[2] = t3;
		$[3] = t4;
	} else {
		t3 = $[2];
		t4 = $[3];
	}
	(0, import_react.useEffect)(t3, t4);
	const t5 = meta?.timeFrame;
	let t6;
	if ($[4] !== latestTransaction || $[5] !== t5) {
		t6 = calculateTimeRange(t5, void 0, latestTransaction);
		$[4] = latestTransaction;
		$[5] = t5;
		$[6] = t6;
	} else t6 = $[6];
	const [start, end] = t6;
	let t7;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = () => setIsCardHovered(true);
		$[7] = t7;
	} else t7 = $[7];
	const onCardHover = t7;
	let t8;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = () => setIsCardHovered(false);
		$[8] = t8;
	} else t8 = $[8];
	const onCardHoverEnd = t8;
	meta?.conditions;
	meta?.conditionsOp;
	meta?.interval;
	const t9 = meta?.conditions;
	const t10 = meta?.conditionsOp;
	const t11 = meta?.interval || "Monthly";
	let t12;
	if ($[9] !== accounts || $[10] !== end || $[11] !== firstDayOfWeekIdx || $[12] !== format || $[13] !== locale || $[14] !== start || $[15] !== t10 || $[16] !== t11 || $[17] !== t9) {
		t12 = createSpreadsheet(start, end, accounts, t9, t10, locale, t11, firstDayOfWeekIdx, format);
		$[9] = accounts;
		$[10] = end;
		$[11] = firstDayOfWeekIdx;
		$[12] = format;
		$[13] = locale;
		$[14] = start;
		$[15] = t10;
		$[16] = t11;
		$[17] = t9;
		$[18] = t12;
	} else t12 = $[18];
	const data = useReport$1("net_worth", t12);
	const t13 = `/reports/net-worth/${widgetId}`;
	let t14;
	if ($[19] !== t) {
		t14 = t("Rename");
		$[19] = t;
		$[20] = t14;
	} else t14 = $[20];
	let t15;
	if ($[21] !== t14) {
		t15 = {
			name: "rename",
			text: t14
		};
		$[21] = t14;
		$[22] = t15;
	} else t15 = $[22];
	let t16;
	if ($[23] !== t) {
		t16 = t("Remove");
		$[23] = t;
		$[24] = t16;
	} else t16 = $[24];
	let t17;
	if ($[25] !== t16) {
		t17 = {
			name: "remove",
			text: t16
		};
		$[25] = t16;
		$[26] = t17;
	} else t17 = $[26];
	let t18;
	if ($[27] !== copyMenuItems || $[28] !== t15 || $[29] !== t17) {
		t18 = [
			t15,
			t17,
			...copyMenuItems
		];
		$[27] = copyMenuItems;
		$[28] = t15;
		$[29] = t17;
		$[30] = t18;
	} else t18 = $[30];
	let t19;
	if ($[31] !== handleCopyMenuSelect || $[32] !== onRemove) {
		t19 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb57: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb57;
				case "remove":
					onRemove();
					break bb57;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[31] = handleCopyMenuSelect;
		$[32] = onRemove;
		$[33] = t19;
	} else t19 = $[33];
	let t20;
	if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = { flex: 1 };
		$[34] = t20;
	} else t20 = $[34];
	let t21;
	if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			flexDirection: "row",
			padding: 20
		};
		$[35] = t21;
	} else t21 = $[35];
	let t22;
	if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = { flex: 1 };
		$[36] = t22;
	} else t22 = $[36];
	let t23;
	if ($[37] !== meta?.name || $[38] !== t) {
		t23 = meta?.name || t("Net Worth");
		$[37] = meta?.name;
		$[38] = t;
		$[39] = t23;
	} else t23 = $[39];
	let t24;
	if ($[40] !== meta || $[41] !== onMetaChange) {
		t24 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[40] = meta;
		$[41] = onMetaChange;
		$[42] = t24;
	} else t24 = $[42];
	let t25;
	if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = () => setNameMenuOpen(false);
		$[43] = t25;
	} else t25 = $[43];
	let t26;
	if ($[44] !== nameMenuOpen || $[45] !== t23 || $[46] !== t24) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t23,
			isEditing: nameMenuOpen,
			onChange: t24,
			onClose: t25
		});
		$[44] = nameMenuOpen;
		$[45] = t23;
		$[46] = t24;
		$[47] = t26;
	} else t26 = $[47];
	let t27;
	if ($[48] !== end || $[49] !== start) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start,
			end
		});
		$[48] = end;
		$[49] = start;
		$[50] = t27;
	} else t27 = $[50];
	let t28;
	if ($[51] !== t26 || $[52] !== t27) {
		t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t22,
			children: [t26, t27]
		});
		$[51] = t26;
		$[52] = t27;
		$[53] = t28;
	} else t28 = $[53];
	let t29;
	if ($[54] !== data || $[55] !== format || $[56] !== isCardHovered) {
		t29 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { textAlign: "right" },
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				style: {
					...styles.mediumText,
					fontWeight: 500,
					marginBottom: 5
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
					activationFilters: [!isCardHovered],
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: format(data.netWorth, "financial") })
				})
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
				activationFilters: [!isCardHovered],
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Change, { amount: data.totalChange })
			})]
		});
		$[54] = data;
		$[55] = format;
		$[56] = isCardHovered;
		$[57] = t29;
	} else t29 = $[57];
	let t30;
	if ($[58] !== t28 || $[59] !== t29) {
		t30 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t21,
			children: [t28, t29]
		});
		$[58] = t28;
		$[59] = t29;
		$[60] = t30;
	} else t30 = $[60];
	let t31;
	if ($[61] !== data || $[62] !== isEditing || $[63] !== isNarrowWidth || $[64] !== meta?.interval || $[65] !== meta?.mode) {
		t31 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorthGraph, {
			graphData: data.graphData,
			accounts: data.accounts,
			compact: true,
			showTooltip: !isEditing && !isNarrowWidth,
			interval: meta?.interval || "Monthly",
			mode: meta?.mode || "trend",
			style: {
				height: "auto",
				flex: 1
			}
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[61] = data;
		$[62] = isEditing;
		$[63] = isNarrowWidth;
		$[64] = meta?.interval;
		$[65] = meta?.mode;
		$[66] = t31;
	} else t31 = $[66];
	let t32;
	if ($[67] !== t30 || $[68] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t20,
			onPointerEnter: onCardHover,
			onPointerLeave: onCardHoverEnd,
			children: [t30, t31]
		});
		$[67] = t30;
		$[68] = t31;
		$[69] = t32;
	} else t32 = $[69];
	let t33;
	if ($[70] !== isEditing || $[71] !== nameMenuOpen || $[72] !== t13 || $[73] !== t18 || $[74] !== t19 || $[75] !== t32) {
		t33 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t13,
			menuItems: t18,
			onMenuSelect: t19,
			children: t32
		});
		$[70] = isEditing;
		$[71] = nameMenuOpen;
		$[72] = t13;
		$[73] = t18;
		$[74] = t19;
		$[75] = t32;
		$[76] = t33;
	} else t33 = $[76];
	return t33;
}
//#endregion
//#region src/components/reports/reports/SankeyCard.tsx
function SankeyCard({ widgetId, isEditing, meta, onMetaChange, onRemove, onCopy }) {
	const { t } = useTranslation();
	const locale = useLocale();
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const { data: { grouped: groupedCategories = [] } = { grouped: [] } } = useCategories();
	const [start, end] = calculateTimeRange(meta?.timeFrame);
	const mode = meta?.mode ?? "spent";
	const [cardHeight, setCardHeight] = (0, import_react.useState)(0);
	const throttledSetCardHeight = (0, import_react.useMemo)(() => (0, import_debounce.default)((height) => {
		setCardHeight((prev) => prev === height ? prev : height);
	}, 200, {
		leading: true,
		trailing: true,
		maxWait: 100
	}), []);
	(0, import_react.useEffect)(() => {
		return () => {
			throttledSetCardHeight.cancel();
		};
	}, [throttledSetCardHeight]);
	const containerRef = useResizeObserver((rect) => {
		throttledSetCardHeight(rect.height);
	});
	const heightBasedTopN = topNNodes(cardHeight);
	const configuredTopN = meta?.topNcategories ?? 15;
	const topN = Math.min(configuredTopN, heightBasedTopN);
	const defaultLayerRange = getDefaultLayerRange(mode);
	let layerFrom;
	let layerTo;
	if (isGraphLayer(meta?.layerFrom) && isGraphLayer(meta?.layerTo)) {
		layerFrom = meta.layerFrom;
		layerTo = meta.layerTo;
	} else {
		layerFrom = defaultLayerRange.from;
		layerTo = defaultLayerRange.to;
	}
	const groupAccounts = meta?.groupAccounts ?? false;
	const baseGraphParams = (0, import_react.useMemo)(() => createBaseGraphSpreadsheet(start, end, groupedCategories, meta?.conditions ?? [], meta?.conditionsOp ?? "and", mode, groupAccounts), [
		start,
		end,
		groupedCategories,
		meta?.conditions,
		meta?.conditionsOp,
		mode,
		groupAccounts
	]);
	const defaultGetBaseGraph = async (_spreadsheet, setData) => setData(/* @__PURE__ */ new Map());
	const baseGraph = useReport$1("sankey", baseGraphParams ?? defaultGetBaseGraph);
	const baseGraphRef = (0, import_react.useRef)(baseGraph);
	(0, import_react.useEffect)(() => {
		if (baseGraph) baseGraphRef.current = baseGraph;
	}, [baseGraph]);
	const displayBaseGraph = baseGraph || baseGraphRef.current;
	const compactData = (0, import_react.useMemo)(() => {
		if (!displayBaseGraph) return null;
		return buildSankeyData(displayBaseGraph, topN, groupedCategories, meta?.categorySort ?? "per-group", layerFrom, layerTo);
	}, [
		displayBaseGraph,
		topN,
		groupedCategories,
		meta?.categorySort,
		layerFrom,
		layerTo
	]);
	const startDate = parseISO(start);
	const endDate = parseISO(end);
	const formattedStartDate = format$1(startDate, "MMM yyyy", { locale });
	const formattedEndDate = format$1(endDate, "MMM yyyy", { locale });
	let dateDescription;
	if (startDate.getFullYear() !== endDate.getFullYear() || startDate.getMonth() !== endDate.getMonth()) dateDescription = formattedStartDate + " - " + formattedEndDate;
	else dateDescription = formattedEndDate;
	const modeLabel = mode === "budgeted" ? t("Budgeted") : t("Spent");
	dateDescription += ` (${modeLabel})`;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
		isEditing,
		disableClick: nameMenuOpen,
		to: `/reports/sankey/${widgetId}`,
		menuItems: [
			{
				name: "rename",
				text: t("Rename")
			},
			{
				name: "remove",
				text: t("Remove")
			},
			...copyMenuItems
		],
		onMenuSelect: (item) => {
			if (handleCopyMenuSelect(item)) return;
			switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break;
				case "remove":
					onRemove();
					break;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		},
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: { flex: 1 },
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					flexDirection: "row",
					padding: 20
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
					style: { flex: 1 },
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
						name: meta?.name || t("Sankey"),
						isEditing: nameMenuOpen,
						onChange: (newName) => {
							onMetaChange({
								...meta,
								name: newName
							});
							setNameMenuOpen(false);
						},
						onClose: () => setNameMenuOpen(false)
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
						style: { color: theme.pageTextSubdued },
						children: dateDescription
					})]
				})
			}), compactData ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				ref: containerRef,
				style: { flexGrow: 1 },
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyGraph, {
					data: compactData,
					showPercentages: meta?.showPercentages,
					showTooltip: !isEditing,
					style: { flex: 1 }
				})
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {})]
		})
	});
}
//#endregion
//#region src/components/reports/reports/SpendingCard.tsx
function SpendingCard(t0) {
	const $ = (0, import_compiler_runtime.c)(79);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? {} : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const meta = t2;
	const { t } = useTranslation();
	const format = useFormat();
	const [budgetTypePref] = useSyncedPref("budgetType");
	const budgetType = budgetTypePref === "tracking" ? "tracking" : "envelope";
	const [isCardHovered, setIsCardHovered] = (0, import_react.useState)(false);
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	const spendingReportMode = meta?.mode ?? "single-month";
	let t3;
	if ($[2] !== meta) {
		t3 = meta ?? {};
		$[2] = meta;
		$[3] = t3;
	} else t3 = $[3];
	let t4;
	if ($[4] !== t3) {
		t4 = calculateSpendingReportTimeRange(t3);
		$[4] = t3;
		$[5] = t4;
	} else t4 = $[5];
	const [compare, compareTo] = t4;
	const selection = spendingReportMode === "single-month" ? "compareTo" : spendingReportMode;
	meta?.conditions;
	meta?.conditionsOp;
	const t5 = meta?.conditions;
	const t6 = meta?.conditionsOp;
	let t7;
	if ($[6] !== budgetType || $[7] !== compare || $[8] !== compareTo || $[9] !== t5 || $[10] !== t6) {
		t7 = createSpendingSpreadsheet({
			conditions: t5,
			conditionsOp: t6,
			compare,
			compareTo,
			budgetType
		});
		$[6] = budgetType;
		$[7] = compare;
		$[8] = compareTo;
		$[9] = t5;
		$[10] = t6;
		$[11] = t7;
	} else t7 = $[11];
	const data = useReport$1("default", t7);
	let t8;
	if ($[12] !== compare) {
		t8 = compare !== currentMonth() ? 27 : getDay$1(currentDay()) - 1 >= 28 ? 27 : getDay$1(currentDay()) - 1;
		$[12] = compare;
		$[13] = t8;
	} else t8 = $[13];
	const todayDay = t8;
	let t9;
	if ($[14] !== data || $[15] !== selection || $[16] !== todayDay) {
		t9 = data && Math.round(data.intervalData[todayDay][selection] - data.intervalData[todayDay].compare);
		$[14] = data;
		$[15] = selection;
		$[16] = todayDay;
		$[17] = t9;
	} else t9 = $[17];
	const difference = t9;
	const t10 = `/reports/spending/${widgetId}`;
	let t11;
	if ($[18] !== t) {
		t11 = t("Rename");
		$[18] = t;
		$[19] = t11;
	} else t11 = $[19];
	let t12;
	if ($[20] !== t11) {
		t12 = {
			name: "rename",
			text: t11
		};
		$[20] = t11;
		$[21] = t12;
	} else t12 = $[21];
	let t13;
	if ($[22] !== t) {
		t13 = t("Remove");
		$[22] = t;
		$[23] = t13;
	} else t13 = $[23];
	let t14;
	if ($[24] !== t13) {
		t14 = {
			name: "remove",
			text: t13
		};
		$[24] = t13;
		$[25] = t14;
	} else t14 = $[25];
	let t15;
	if ($[26] !== copyMenuItems || $[27] !== t12 || $[28] !== t14) {
		t15 = [
			t12,
			t14,
			...copyMenuItems
		];
		$[26] = copyMenuItems;
		$[27] = t12;
		$[28] = t14;
		$[29] = t15;
	} else t15 = $[29];
	let t16;
	if ($[30] !== handleCopyMenuSelect || $[31] !== onRemove) {
		t16 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb59: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb59;
				case "remove":
					onRemove();
					break bb59;
				default: throw new Error(`Unrecognized selection: ${item}`);
			}
		};
		$[30] = handleCopyMenuSelect;
		$[31] = onRemove;
		$[32] = t16;
	} else t16 = $[32];
	let t17;
	let t18;
	let t19;
	if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = { flex: 1 };
		t18 = () => setIsCardHovered(true);
		t19 = () => setIsCardHovered(false);
		$[33] = t17;
		$[34] = t18;
		$[35] = t19;
	} else {
		t17 = $[33];
		t18 = $[34];
		t19 = $[35];
	}
	let t20;
	if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = {
			flexDirection: "row",
			padding: 20
		};
		$[36] = t20;
	} else t20 = $[36];
	let t21;
	if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = { flex: 1 };
		$[37] = t21;
	} else t21 = $[37];
	let t22;
	if ($[38] !== meta?.name || $[39] !== t) {
		t22 = meta?.name || t("Monthly Spending");
		$[38] = meta?.name;
		$[39] = t;
		$[40] = t22;
	} else t22 = $[40];
	let t23;
	if ($[41] !== meta || $[42] !== onMetaChange) {
		t23 = (newName) => {
			onMetaChange({
				...meta,
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[41] = meta;
		$[42] = onMetaChange;
		$[43] = t23;
	} else t23 = $[43];
	let t24;
	if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = () => setNameMenuOpen(false);
		$[44] = t24;
	} else t24 = $[44];
	let t25;
	if ($[45] !== nameMenuOpen || $[46] !== t22 || $[47] !== t23) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t22,
			isEditing: nameMenuOpen,
			onChange: t23,
			onClose: t24
		});
		$[45] = nameMenuOpen;
		$[46] = t22;
		$[47] = t23;
		$[48] = t25;
	} else t25 = $[48];
	let t26;
	if ($[49] !== compare || $[50] !== compareTo || $[51] !== spendingReportMode) {
		t26 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start: compare,
			end: compareTo,
			type: spendingReportMode
		});
		$[49] = compare;
		$[50] = compareTo;
		$[51] = spendingReportMode;
		$[52] = t26;
	} else t26 = $[52];
	let t27;
	if ($[53] !== t25 || $[54] !== t26) {
		t27 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t21,
			children: [t25, t26]
		});
		$[53] = t25;
		$[54] = t26;
		$[55] = t27;
	} else t27 = $[55];
	let t28;
	if ($[56] !== data || $[57] !== difference || $[58] !== format || $[59] !== isCardHovered) {
		t28 = data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: { textAlign: "right" },
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
				style: {
					...styles.mediumText,
					fontWeight: 500,
					marginBottom: 5,
					color: difference === 0 || difference == null ? theme.reportsNumberNeutral : difference > 0 ? theme.reportsNumberNegative : theme.reportsNumberPositive
				},
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, {
					activationFilters: [!isCardHovered],
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, { children: data && (difference && difference > 0 ? "+" : "") + format(difference || 0, "financial") })
				})
			})
		});
		$[56] = data;
		$[57] = difference;
		$[58] = format;
		$[59] = isCardHovered;
		$[60] = t28;
	} else t28 = $[60];
	let t29;
	if ($[61] !== t27 || $[62] !== t28) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t20,
			children: [t27, t28]
		});
		$[61] = t27;
		$[62] = t28;
		$[63] = t29;
	} else t29 = $[63];
	let t30;
	if ($[64] !== compare || $[65] !== compareTo || $[66] !== data || $[67] !== spendingReportMode) {
		t30 = data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpendingGraph, {
			style: { flex: 1 },
			compact: true,
			data,
			mode: spendingReportMode,
			compare,
			compareTo
		}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, {});
		$[64] = compare;
		$[65] = compareTo;
		$[66] = data;
		$[67] = spendingReportMode;
		$[68] = t30;
	} else t30 = $[68];
	let t31;
	if ($[69] !== t29 || $[70] !== t30) {
		t31 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t17,
			onPointerEnter: t18,
			onPointerLeave: t19,
			children: [t29, t30]
		});
		$[69] = t29;
		$[70] = t30;
		$[71] = t31;
	} else t31 = $[71];
	let t32;
	if ($[72] !== isEditing || $[73] !== nameMenuOpen || $[74] !== t10 || $[75] !== t15 || $[76] !== t16 || $[77] !== t31) {
		t32 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t10,
			menuItems: t15,
			onMenuSelect: t16,
			children: t31
		});
		$[72] = isEditing;
		$[73] = nameMenuOpen;
		$[74] = t10;
		$[75] = t15;
		$[76] = t16;
		$[77] = t31;
		$[78] = t32;
	} else t32 = $[78];
	return t32;
}
//#endregion
//#region src/components/reports/SummaryNumber.tsx
var FONT_SIZE_SCALE_FACTOR = 1.6;
var CONTAINER_MARGIN = 8;
function SummaryNumber({ value, contentType, animate = false, suffix = "", loading = true, initialFontSize = 14, fontSizeChanged }) {
	const { t } = useTranslation();
	const [fontSize, setFontSize] = (0, import_react.useState)(initialFontSize);
	const [hasSized, setHasSized] = (0, import_react.useState)(false);
	const refDiv = (0, import_react.useRef)(null);
	const format = useFormat();
	const isNumericValue = Number.isFinite(value);
	let displayAmount = contentType === "percentage" ? format(Math.abs(value), "number") : format(Math.abs(Math.round(value)), "financial");
	displayAmount += suffix;
	const mergedRef = useMergedRefs(useResizeObserver((0, import_debounce.default)(() => {
		if (!refDiv.current) return;
		const { clientWidth, clientHeight } = refDiv.current;
		const width = clientWidth;
		const height = clientHeight - CONTAINER_MARGIN * 2;
		const calculatedFontSize = Math.min(width * FONT_SIZE_SCALE_FACTOR / displayAmount.toString().length, height);
		if (calculatedFontSize > 0) {
			setFontSize(calculatedFontSize);
			setHasSized(true);
		}
		if (calculatedFontSize !== initialFontSize && fontSizeChanged) fontSizeChanged(calculatedFontSize);
	}, 100)), refDiv);
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardValueSkeleton, {}), !loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
		ref: mergedRef,
		"aria-label": !isNumericValue ? t("Unknown amount") : value === 0 ? t("Zero amount") : value < 0 ? t("Negative amount: {{amount}}", { amount: displayAmount }) : t("Positive amount: {{amount}}", { amount: displayAmount }),
		style: {
			alignItems: "center",
			flexGrow: 1,
			flexShrink: 1,
			width: "100%",
			height: "100%",
			maxWidth: "100%",
			fontSize,
			lineHeight: 1,
			margin: `${CONTAINER_MARGIN}px 0`,
			justifyContent: "center",
			transition: animate ? "font-size 0.3s ease" : "",
			color: !isNumericValue ? theme.reportsNumberNeutral : value === 0 ? theme.reportsNumberNeutral : value < 0 ? theme.reportsNumberNegative : theme.reportsNumberPositive
		},
		children: !hasSized ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardValueSkeleton, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FinancialText, {
			"aria-hidden": "true",
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrivacyFilter, { children: displayAmount })
		})
	})] });
}
//#endregion
//#region src/components/reports/reports/SummaryCard.tsx
function SummaryCard(t0) {
	const $ = (0, import_compiler_runtime.c)(67);
	const { widgetId, isEditing, meta: t1, onMetaChange, onRemove, onCopy } = t0;
	const meta = t1 === void 0 ? {} : t1;
	const locale = useLocale();
	const { t } = useTranslation();
	const [latestTransaction, setLatestTransaction] = (0, import_react.useState)("");
	const [nameMenuOpen, setNameMenuOpen] = (0, import_react.useState)(false);
	const { menuItems: copyMenuItems, handleMenuSelect: handleCopyMenuSelect } = useDashboardWidgetCopyMenu(onCopy);
	let t2;
	let t3;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = () => {
			(async function fetchLatestTransaction() {
				const latestTrans = await send("get-latest-transaction");
				setLatestTransaction(latestTrans ? latestTrans.date : currentDay());
			})();
		};
		t3 = [];
		$[0] = t2;
		$[1] = t3;
	} else {
		t2 = $[0];
		t3 = $[1];
	}
	(0, import_react.useEffect)(t2, t3);
	const [start, end] = calculateTimeRange(meta?.timeFrame, {
		start: dayFromDate(currentMonth()),
		end: currentDay(),
		mode: "full"
	}, latestTransaction);
	let t4;
	if ($[2] !== meta) {
		t4 = meta?.content ? (() => {
			try {
				return JSON.parse(meta.content);
			} catch (t5) {
				console.error("Failed to parse meta.content:", t5);
				return { type: "sum" };
			}
		})() : { type: "sum" };
		$[2] = meta;
		$[3] = t4;
	} else t4 = $[3];
	const content = t4;
	let t5;
	if ($[4] !== content || $[5] !== end || $[6] !== locale || $[7] !== meta?.conditions || $[8] !== meta?.conditionsOp || $[9] !== start) {
		t5 = () => summarySpreadsheet(start, end, meta?.conditions, meta?.conditionsOp, content, locale);
		$[4] = content;
		$[5] = end;
		$[6] = locale;
		$[7] = meta?.conditions;
		$[8] = meta?.conditionsOp;
		$[9] = start;
		$[10] = t5;
	} else t5 = $[10];
	meta?.conditions;
	meta?.conditionsOp;
	let t6;
	if ($[11] !== t5) {
		t6 = t5();
		$[11] = t5;
		$[12] = t6;
	} else t6 = $[12];
	const data = useReport$1("summary", t6);
	const t7 = `/reports/summary/${widgetId}`;
	let t8;
	if ($[13] !== t) {
		t8 = t("Rename");
		$[13] = t;
		$[14] = t8;
	} else t8 = $[14];
	let t9;
	if ($[15] !== t8) {
		t9 = {
			name: "rename",
			text: t8
		};
		$[15] = t8;
		$[16] = t9;
	} else t9 = $[16];
	let t10;
	if ($[17] !== t) {
		t10 = t("Remove");
		$[17] = t;
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== t10) {
		t11 = {
			name: "remove",
			text: t10
		};
		$[19] = t10;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] !== copyMenuItems || $[22] !== t11 || $[23] !== t9) {
		t12 = [
			t9,
			t11,
			...copyMenuItems
		];
		$[21] = copyMenuItems;
		$[22] = t11;
		$[23] = t9;
		$[24] = t12;
	} else t12 = $[24];
	let t13;
	if ($[25] !== handleCopyMenuSelect || $[26] !== onRemove || $[27] !== setNameMenuOpen) {
		t13 = (item) => {
			if (handleCopyMenuSelect(item)) return;
			bb58: switch (item) {
				case "rename":
					setNameMenuOpen(true);
					break bb58;
				case "remove":
					onRemove();
					break bb58;
				default: throw new Error(`Unrecognized menu selection: ${item}`);
			}
		};
		$[25] = handleCopyMenuSelect;
		$[26] = onRemove;
		$[27] = setNameMenuOpen;
		$[28] = t13;
	} else t13 = $[28];
	let t14;
	if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = {
			flex: 1,
			overflow: "hidden"
		};
		$[29] = t14;
	} else t14 = $[29];
	let t15;
	if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = {
			flexGrow: 0,
			flexShrink: 0,
			padding: 20
		};
		$[30] = t15;
	} else t15 = $[30];
	let t16;
	if ($[31] !== meta?.name || $[32] !== t) {
		t16 = meta?.name || t("Summary");
		$[31] = meta?.name;
		$[32] = t;
		$[33] = t16;
	} else t16 = $[33];
	let t17;
	if ($[34] !== content || $[35] !== meta || $[36] !== onMetaChange || $[37] !== setNameMenuOpen) {
		t17 = (newName) => {
			onMetaChange({
				...meta,
				content: JSON.stringify(content),
				name: newName
			});
			setNameMenuOpen(false);
		};
		$[34] = content;
		$[35] = meta;
		$[36] = onMetaChange;
		$[37] = setNameMenuOpen;
		$[38] = t17;
	} else t17 = $[38];
	let t18;
	if ($[39] !== setNameMenuOpen) {
		t18 = () => setNameMenuOpen(false);
		$[39] = setNameMenuOpen;
		$[40] = t18;
	} else t18 = $[40];
	let t19;
	if ($[41] !== nameMenuOpen || $[42] !== t16 || $[43] !== t17 || $[44] !== t18) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardName, {
			name: t16,
			isEditing: nameMenuOpen,
			onChange: t17,
			onClose: t18
		});
		$[41] = nameMenuOpen;
		$[42] = t16;
		$[43] = t17;
		$[44] = t18;
		$[45] = t19;
	} else t19 = $[45];
	let t20;
	if ($[46] !== end || $[47] !== start) {
		t20 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DateRange, {
			start,
			end
		});
		$[46] = end;
		$[47] = start;
		$[48] = t20;
	} else t20 = $[48];
	let t21;
	if ($[49] !== t19 || $[50] !== t20) {
		t21 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t15,
			children: [t19, t20]
		});
		$[49] = t19;
		$[50] = t20;
		$[51] = t21;
	} else t21 = $[51];
	let t22;
	if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = {
			justifyContent: "center",
			alignItems: "center",
			flexGrow: 1,
			flexShrink: 1
		};
		$[52] = t22;
	} else t22 = $[52];
	let t23;
	if ($[53] !== content || $[54] !== data || $[55] !== isEditing) {
		t23 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: t22,
			children: data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SummaryNumber, {
				value: data?.total ?? 0,
				contentType: content.type,
				suffix: content.type === "percentage" ? "%" : "",
				loading: !data,
				initialFontSize: content.fontSize,
				animate: isEditing ?? false
			}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCardValueSkeleton, {})
		});
		$[53] = content;
		$[54] = data;
		$[55] = isEditing;
		$[56] = t23;
	} else t23 = $[56];
	let t24;
	if ($[57] !== t21 || $[58] !== t23) {
		t24 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: t14,
			children: [t21, t23]
		});
		$[57] = t21;
		$[58] = t23;
		$[59] = t24;
	} else t24 = $[59];
	let t25;
	if ($[60] !== isEditing || $[61] !== nameMenuOpen || $[62] !== t12 || $[63] !== t13 || $[64] !== t24 || $[65] !== t7) {
		t25 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportCard, {
			isEditing,
			disableClick: nameMenuOpen,
			to: t7,
			menuItems: t12,
			onMenuSelect: t13,
			children: t24
		});
		$[60] = isEditing;
		$[61] = nameMenuOpen;
		$[62] = t12;
		$[63] = t13;
		$[64] = t24;
		$[65] = t7;
		$[66] = t25;
	} else t25 = $[66];
	return t25;
}
//#endregion
//#region src/components/reports/Overview.tsx
function isCustomReportWidget(widget) {
	return widget.type === "custom-report";
}
function getWidgetMinHeight(widget) {
	if (isCustomReportWidget(widget) || widget.type === "markdown-card") return 1;
	if (widget.type === "sankey-card") return 3;
	return 2;
}
function getWidgetMinWidth(widget) {
	if (isCustomReportWidget(widget) || widget.type === "markdown-card") return 2;
	return 3;
}
function Overview(t0) {
	const $ = (0, import_compiler_runtime.c)(110);
	const { dashboard } = t0;
	const { t } = useTranslation();
	const dispatch = useDispatch();
	const [_firstDayOfWeekIdx] = useSyncedPref("firstDayOfWeekIdx");
	const firstDayOfWeekIdx = _firstDayOfWeekIdx || "0";
	const ageOfMoneyReportEnabled = useFeatureFlag("ageOfMoneyReport");
	const budgetAnalysisReportEnabled = useFeatureFlag("budgetAnalysisReport");
	const balanceForecastReportEnabled = useFeatureFlag("balanceForecastReport");
	const formulaMode = useFeatureFlag("formulaMode");
	const [isImporting, setIsImporting] = (0, import_react.useState)(false);
	const [isEditing, setIsEditing] = (0, import_react.useState)(false);
	const { isNarrowWidth } = useResponsive();
	const currentBreakpoint = isNarrowWidth ? "mobile" : "desktop";
	const { data: t1, isPending: isCustomReportsLoading } = useReports();
	let t2;
	if ($[0] !== t1) {
		t2 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const customReports = t2;
	const sankeyFeatureFlag = useFeatureFlag("sankeyReport");
	let t3;
	if ($[2] !== customReports) {
		t3 = new Map(customReports.map(_temp));
		$[2] = customReports;
		$[3] = t3;
	} else t3 = $[3];
	const customReportMap = t3;
	const { data: t4, isPending: isDashboardPageLoading } = useDashboardPages();
	let t5;
	if ($[4] !== t4) {
		t5 = t4 === void 0 ? [] : t4;
		$[4] = t4;
		$[5] = t5;
	} else t5 = $[5];
	const dashboardPages = t5;
	const { data: t6, isPending: isWidgetsLoading } = useDashboardPageWidgets(dashboard.id);
	let t7;
	if ($[6] !== t6) {
		t7 = t6 === void 0 ? [] : t6;
		$[6] = t6;
		$[7] = t7;
	} else t7 = $[7];
	const widgets = t7;
	const isLoading = isCustomReportsLoading || isWidgetsLoading || isDashboardPageLoading;
	const navigate = useNavigate();
	const location = useLocation();
	sessionStorage.setItem("url", location.pathname);
	const [containerWidth, setContainerWidth] = (0, import_react.useState)(0);
	let t8;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = (contentRect) => {
			setContainerWidth(Math.floor(contentRect.width));
		};
		$[8] = t8;
	} else t8 = $[8];
	const containerRef = useResizeObserver(t8);
	const isMounted = containerWidth > 0;
	let t9;
	bb0: {
		if (!widgets || widgets.length === 0) {
			let t10;
			if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
				t10 = [];
				$[9] = t10;
			} else t10 = $[9];
			t9 = t10;
			break bb0;
		}
		let t10;
		if ($[10] !== widgets) {
			const sortedDesktopItems = [...widgets];
			sortedDesktopItems.sort(_temp2);
			let currentY = 0;
			t10 = sortedDesktopItems.map((widget) => {
				const itemY = currentY;
				currentY = currentY + widget.height;
				return {
					i: widget.id,
					x: 0,
					y: itemY,
					w: 1,
					h: widget.height
				};
			});
			$[10] = widgets;
			$[11] = t10;
		} else t10 = $[11];
		t9 = t10;
	}
	const mobileLayout = t9;
	let t10;
	bb1: {
		if (!widgets) {
			let t11;
			if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
				t11 = [];
				$[12] = t11;
			} else t11 = $[12];
			t10 = t11;
			break bb1;
		}
		let t11;
		if ($[13] !== widgets) {
			t11 = widgets.map(_temp3);
			$[13] = widgets;
			$[14] = t11;
		} else t11 = $[14];
		t10 = t11;
	}
	const desktopLayout = t10;
	const currentLayout = currentBreakpoint === "desktop" ? desktopLayout : mobileLayout;
	let t11;
	if ($[15] !== widgets) {
		t11 = new Map((widgets ?? []).map(_temp4));
		$[15] = widgets;
		$[16] = t11;
	} else t11 = $[16];
	const widgetMap = t11;
	let t12;
	if ($[17] !== dispatch) {
		t12 = () => {
			dispatch(removeNotification({ id: "import" }));
		};
		$[17] = dispatch;
		$[18] = t12;
	} else t12 = $[18];
	const closeNotifications = t12;
	let t13;
	if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = { scopes: ["app"] };
		$[19] = t13;
	} else t13 = $[19];
	let t14;
	if ($[20] !== closeNotifications) {
		t14 = [closeNotifications];
		$[20] = closeNotifications;
		$[21] = t14;
	} else t14 = $[21];
	fe("ctrl+z, cmd+z, meta+z", closeNotifications, t13, t14);
	const { undo } = useUndo();
	let t15;
	if ($[22] !== closeNotifications || $[23] !== dispatch || $[24] !== undo) {
		t15 = (message) => {
			dispatch(addNotification({ notification: {
				id: "import",
				type: "message",
				sticky: true,
				timeout: 3e4,
				message,
				messageActions: { undo: () => {
					closeNotifications();
					undo();
				} }
			} }));
		};
		$[22] = closeNotifications;
		$[23] = dispatch;
		$[24] = undo;
		$[25] = t15;
	} else t15 = $[25];
	const onDispatchSucessNotification = t15;
	const resetDashboardPageMutation = useResetDashboardPageMutation();
	let t16;
	if ($[26] !== dashboard.id || $[27] !== onDispatchSucessNotification || $[28] !== resetDashboardPageMutation || $[29] !== t) {
		t16 = async () => {
			setIsImporting(true);
			resetDashboardPageMutation.mutate({ id: dashboard.id }, {
				onSettled: () => {
					setIsImporting(false);
				},
				onSuccess: () => {
					onDispatchSucessNotification(t("Dashboard has been successfully reset to default state. Don't like what you see? You can always press [ctrl+z](#undo) to undo."));
				}
			});
		};
		$[26] = dashboard.id;
		$[27] = onDispatchSucessNotification;
		$[28] = resetDashboardPageMutation;
		$[29] = t;
		$[30] = t16;
	} else t16 = $[30];
	const onResetDashboard = t16;
	const updateDashboardWidgetsMutation = useUpdateDashboardWidgetsMutation();
	let t17;
	if ($[31] !== isEditing || $[32] !== updateDashboardWidgetsMutation) {
		t17 = (newLayout) => {
			if (!isEditing) return;
			updateDashboardWidgetsMutation.mutate({ widgets: newLayout.map(_temp5) });
		};
		$[31] = isEditing;
		$[32] = updateDashboardWidgetsMutation;
		$[33] = t17;
	} else t17 = $[33];
	const onLayoutChange = t17;
	const addDashboardWidgetMutation = useAddDashboardWidgetMutation();
	let t18;
	if ($[34] !== addDashboardWidgetMutation || $[35] !== dashboard.id) {
		t18 = (type, t19) => {
			const meta = t19 === void 0 ? null : t19;
			addDashboardWidgetMutation.mutate({ widget: {
				type,
				width: 4,
				height: type === "sankey-card" ? 3 : 2,
				meta,
				dashboard_page_id: dashboard.id
			} });
		};
		$[34] = addDashboardWidgetMutation;
		$[35] = dashboard.id;
		$[36] = t18;
	} else t18 = $[36];
	const onAddWidget = t18;
	const removeDashboardWidgetMutation = useRemoveDashboardWidgetMutation();
	let t19;
	if ($[37] !== removeDashboardWidgetMutation) {
		t19 = (widgetId) => {
			removeDashboardWidgetMutation.mutate({ id: widgetId });
		};
		$[37] = removeDashboardWidgetMutation;
		$[38] = t19;
	} else t19 = $[38];
	const onRemoveWidget = t19;
	let t20;
	if ($[39] !== customReportMap || $[40] !== desktopLayout || $[41] !== t || $[42] !== widgetMap) {
		t20 = () => {
			const data = {
				version: 1,
				widgets: desktopLayout.map((item_0) => {
					const widget_2 = widgetMap.get(item_0.i);
					if (!widget_2) throw new Error(`Unable to query widget: ${item_0.i}`);
					if (isCustomReportWidget(widget_2)) {
						const customReport = customReportMap.get(widget_2.meta.id);
						if (!customReport) throw new Error(`Custom report not found for widget: ${item_0.i}`);
						return {
							...widget_2,
							meta: customReport,
							id: void 0,
							tombstone: void 0
						};
					}
					return {
						...widget_2,
						id: void 0,
						tombstone: void 0
					};
				})
			};
			window.Actual.saveFile(JSON.stringify(data, null, 2), "dashboard.json", t("Export Dashboard"));
		};
		$[39] = customReportMap;
		$[40] = desktopLayout;
		$[41] = t;
		$[42] = widgetMap;
		$[43] = t20;
	} else t20 = $[43];
	const onExport = t20;
	const importDashboardPageMutation = useImportDashboardPageMutation();
	let t21;
	if ($[44] !== closeNotifications || $[45] !== dashboard.id || $[46] !== dispatch || $[47] !== importDashboardPageMutation || $[48] !== onDispatchSucessNotification || $[49] !== t) {
		t21 = async () => {
			const openFileDialog = window.Actual.openFileDialog;
			if (!openFileDialog) {
				dispatch(addNotification({ notification: {
					type: "error",
					message: t("Fatal error occurred: unable to open import file dialog.")
				} }));
				return;
			}
			const [filePath] = await openFileDialog({
				properties: ["openFile"],
				filters: [{
					name: "JSON files",
					extensions: ["json"]
				}]
			});
			closeNotifications();
			setIsImporting(true);
			importDashboardPageMutation.mutate({
				filePath,
				dashboardPageId: dashboard.id
			}, {
				onSettled: () => {
					setIsImporting(false);
				},
				onSuccess: () => {
					onDispatchSucessNotification(t("Dashboard has been successfully imported. Don't like what you see? You can always press [ctrl+z](#undo) to undo."));
				},
				onError: (error) => {
					const originalError = error.cause;
					if (originalError instanceof Error) bb123: switch (originalError.cause) {
						case "json-parse-error":
							dispatch(addNotification({ notification: {
								id: "import",
								type: "error",
								message: t("Failed parsing the imported JSON.")
							} }));
							break bb123;
						case "validation-error":
							dispatch(addNotification({ notification: {
								id: "import",
								type: "error",
								message: error.message
							} }));
							break bb123;
						default: dispatch(addNotification({ notification: {
							id: "import",
							type: "error",
							message: t("Failed importing the dashboard file.")
						} }));
					}
				}
			});
		};
		$[44] = closeNotifications;
		$[45] = dashboard.id;
		$[46] = dispatch;
		$[47] = importDashboardPageMutation;
		$[48] = onDispatchSucessNotification;
		$[49] = t;
		$[50] = t21;
	} else t21 = $[50];
	const onImport = t21;
	const updateDashboardWidgetMutation = useUpdateDashboardWidgetMutation();
	let t22;
	if ($[51] !== updateDashboardWidgetMutation) {
		t22 = (widget_3, newMeta) => {
			updateDashboardWidgetMutation.mutate({ widget: {
				id: widget_3.i,
				meta: newMeta
			} });
		};
		$[51] = updateDashboardWidgetMutation;
		$[52] = t22;
	} else t22 = $[52];
	const onMetaChange = t22;
	const copyDashboardWidgetMutation = useCopyDashboardWidgetMutation();
	let t23;
	if ($[53] !== copyDashboardWidgetMutation) {
		t23 = (widgetId_0, targetDashboardId) => {
			copyDashboardWidgetMutation.mutate({
				id: widgetId_0,
				targetDashboardPageId: targetDashboardId
			});
		};
		$[53] = copyDashboardWidgetMutation;
		$[54] = t23;
	} else t23 = $[54];
	const onCopyWidget = t23;
	const deleteDashboardPageMutation = useDeleteDashboardPageMutation();
	let t24;
	if ($[55] !== dashboardPages || $[56] !== deleteDashboardPageMutation || $[57] !== navigate) {
		t24 = async (id) => {
			deleteDashboardPageMutation.mutate({ id }, { onSuccess: () => {
				const nextDashboard = dashboardPages.find((d) => d.id !== id);
				if (nextDashboard) navigate(`/reports/${nextDashboard.id}`);
			} });
		};
		$[55] = dashboardPages;
		$[56] = deleteDashboardPageMutation;
		$[57] = navigate;
		$[58] = t24;
	} else t24 = $[58];
	const onDeleteDashboard = t24;
	const { data: t25 } = useAccounts();
	let t26;
	if ($[59] !== t25) {
		t26 = t25 === void 0 ? [] : t25;
		$[59] = t25;
		$[60] = t26;
	} else t26 = $[60];
	const accounts = t26;
	if (isLoading) {
		let t27;
		if ($[61] !== t) {
			t27 = t("Loading reports...");
			$[61] = t;
			$[62] = t27;
		} else t27 = $[62];
		let t28;
		if ($[63] !== t27) {
			t28 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t27 });
			$[63] = t27;
			$[64] = t28;
		} else t28 = $[64];
		return t28;
	}
	let t27;
	if ($[65] !== ageOfMoneyReportEnabled || $[66] !== balanceForecastReportEnabled || $[67] !== budgetAnalysisReportEnabled || $[68] !== currentBreakpoint || $[69] !== customReports || $[70] !== dashboard || $[71] !== dashboardPages || $[72] !== formulaMode || $[73] !== isEditing || $[74] !== isImporting || $[75] !== isNarrowWidth || $[76] !== navigate || $[77] !== onAddWidget || $[78] !== onDeleteDashboard || $[79] !== onExport || $[80] !== onImport || $[81] !== onResetDashboard || $[82] !== sankeyFeatureFlag || $[83] !== t) {
		t27 = isNarrowWidth ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobilePageHeader, { title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				overflow: "hidden",
				textOverflow: "ellipsis",
				whiteSpace: "nowrap"
			},
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Reports" }),
				": ",
				dashboard.name
			]
		}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			style: {
				padding: "5px",
				borderBottom: "1px solid " + theme.pillBorder,
				backgroundColor: theme.mobilePageBackground
			},
			children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DashboardSelector, {
				dashboards: dashboardPages,
				currentDashboard: dashboard
			})
		})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(View, {
			style: {
				flexDirection: "row",
				justifyContent: "space-between",
				marginRight: 15,
				alignItems: "center"
			},
			children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DashboardHeader, { dashboard }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
				style: {
					flexDirection: "row",
					justifyContent: "space-between",
					gap: 5,
					alignItems: "stretch"
				},
				children: currentBreakpoint === "desktop" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DashboardSelector, {
						dashboards: dashboardPages,
						currentDashboard: dashboard
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { style: {
						height: "auto",
						borderLeft: `1.5px solid ${theme.pillBorderDark}`,
						borderRadius: .75,
						marginLeft: 7,
						marginRight: 7
					} }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)($de32f1b87079253c$export$2e1e1122cf0cba88, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
						variant: "primary",
						isDisabled: isImporting,
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Add new widget" })
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)($de32f1b87079253c$export$3ddf2d174ce01153, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
						slot: "close",
						onMenuSelect: (item_1) => {
							if (item_1 === "custom-report") {
								navigate("/reports/custom");
								return;
							}
							if (function isExistingCustomReport(name) {
								return name.startsWith("custom-report-");
							}(item_1)) {
								const [, reportId] = item_1.split("custom-report-");
								onAddWidget("custom-report", { id: reportId });
								return;
							}
							if (item_1 === "markdown-card") {
								onAddWidget(item_1, { content: `### ${t("Text Widget")}\n\n${t("Edit this widget to change the **markdown** content.")}` });
								return;
							}
							onAddWidget(item_1);
						},
						items: [
							{
								name: "cash-flow-card",
								text: t("Cash flow graph")
							},
							{
								name: "net-worth-card",
								text: t("Net worth graph")
							},
							{
								name: "crossover-card",
								text: t("Crossover point")
							},
							...ageOfMoneyReportEnabled ? [{
								name: "age-of-money-card",
								text: t("Age of Money")
							}] : [],
							{
								name: "spending-card",
								text: t("Spending analysis")
							},
							...budgetAnalysisReportEnabled ? [{
								name: "budget-analysis-card",
								text: t("Budget analysis")
							}] : [],
							...balanceForecastReportEnabled ? [{
								name: "balance-forecast-card",
								text: t("Balance forecast")
							}] : [],
							{
								name: "markdown-card",
								text: t("Text widget")
							},
							{
								name: "summary-card",
								text: t("Summary card")
							},
							{
								name: "calendar-card",
								text: t("Calendar card")
							},
							...formulaMode ? [{
								name: "formula-card",
								text: t("Formula card")
							}] : [],
							...sankeyFeatureFlag ? [{
								name: "sankey-card",
								text: t("Sankey card")
							}] : [],
							{
								name: "custom-report",
								text: t("New custom report")
							},
							...customReports.length ? [Menu.line] : [],
							...customReports.map(_temp6)
						]
					}) }) })] }),
					isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
						isDisabled: isImporting,
						onPress: () => setIsEditing(false),
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Finish editing dashboard" })
					}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
						isDisabled: isImporting,
						onPress: () => setIsEditing(true),
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Edit dashboard" })
					}),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)($de32f1b87079253c$export$2e1e1122cf0cba88, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
						variant: "bare",
						"aria-label": t("Menu"),
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SvgDotsHorizontalTriple, {
							width: 15,
							height: 15,
							style: { transform: "rotateZ(90deg)" }
						})
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)($de32f1b87079253c$export$3ddf2d174ce01153, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, {
						slot: "close",
						onMenuSelect: (item_2) => {
							bb200: switch (item_2) {
								case "reset":
									onResetDashboard();
									break bb200;
								case "export":
									onExport();
									break bb200;
								case "import":
									onImport();
									break bb200;
								case "delete":
									onDeleteDashboard(dashboard.id);
									break bb200;
								default: throw new Error(`Unrecognized menu option: ${String(item_2)}`);
							}
						},
						items: [
							{
								name: "reset",
								text: t("Reset to default"),
								disabled: isImporting
							},
							Menu.line,
							{
								name: "import",
								text: t("Import"),
								disabled: isImporting
							},
							{
								name: "export",
								text: t("Export"),
								disabled: isImporting
							},
							Menu.line,
							{
								name: "delete",
								text: t("Delete dashboard"),
								disabled: isImporting || dashboardPages.length <= 1
							}
						]
					}) }) })] })
				] })
			})]
		});
		$[65] = ageOfMoneyReportEnabled;
		$[66] = balanceForecastReportEnabled;
		$[67] = budgetAnalysisReportEnabled;
		$[68] = currentBreakpoint;
		$[69] = customReports;
		$[70] = dashboard;
		$[71] = dashboardPages;
		$[72] = formulaMode;
		$[73] = isEditing;
		$[74] = isImporting;
		$[75] = isNarrowWidth;
		$[76] = navigate;
		$[77] = onAddWidget;
		$[78] = onDeleteDashboard;
		$[79] = onExport;
		$[80] = onImport;
		$[81] = onResetDashboard;
		$[82] = sankeyFeatureFlag;
		$[83] = t;
		$[84] = t27;
	} else t27 = $[84];
	let t28;
	if ($[85] !== accounts || $[86] !== ageOfMoneyReportEnabled || $[87] !== balanceForecastReportEnabled || $[88] !== budgetAnalysisReportEnabled || $[89] !== containerRef || $[90] !== containerWidth || $[91] !== currentBreakpoint || $[92] !== currentLayout || $[93] !== customReportMap || $[94] !== firstDayOfWeekIdx || $[95] !== formulaMode || $[96] !== isEditing || $[97] !== isImporting || $[98] !== isMounted || $[99] !== onCopyWidget || $[100] !== onLayoutChange || $[101] !== onMetaChange || $[102] !== onRemoveWidget || $[103] !== sankeyFeatureFlag || $[104] !== t || $[105] !== widgetMap) {
		t28 = isImporting ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t("Import is running...") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
			"data-testid": "reports-overview",
			innerRef: containerRef,
			style: {
				userSelect: "none",
				paddingBottom: MOBILE_NAV_HEIGHT
			},
			children: isMounted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GridLayout, {
				width: containerWidth,
				layout: currentLayout,
				gridConfig: {
					cols: currentBreakpoint === "desktop" ? 12 : 1,
					rowHeight: 100
				},
				dragConfig: {
					enabled: currentBreakpoint === "desktop" && isEditing,
					cancel: `.non-draggable-area`
				},
				resizeConfig: { enabled: currentBreakpoint === "desktop" && isEditing },
				onLayoutChange: currentBreakpoint === "desktop" ? onLayoutChange : void 0,
				children: currentLayout.map((item_3) => {
					const widget_4 = widgetMap.get(item_3.i);
					if (!widget_4) return null;
					return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(m, {
						fallbackRender: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MissingReportCard, {
							isEditing,
							onRemove: () => onRemoveWidget(item_3.i),
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "This widget has failed to load." })
						}),
						children: widget_4.type === "net-worth-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorthCard, {
							widgetId: item_3.i,
							isEditing,
							accounts,
							meta: widget_4.meta,
							onMetaChange: (newMeta_0) => onMetaChange(item_3, newMeta_0),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_0) => onCopyWidget(item_3.i, targetDashboardId_0)
						}) : widget_4.type === "crossover-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CrossoverCard, {
							widgetId: item_3.i,
							isEditing,
							accounts,
							meta: widget_4.meta,
							onMetaChange: (newMeta_1) => onMetaChange(item_3, newMeta_1),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_1) => onCopyWidget(item_3.i, targetDashboardId_1)
						}) : widget_4.type === "age-of-money-card" && ageOfMoneyReportEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoneyCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_2) => onMetaChange(item_3, newMeta_2),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_2) => onCopyWidget(item_3.i, targetDashboardId_2)
						}) : widget_4.type === "cash-flow-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CashFlowCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_3) => onMetaChange(item_3, newMeta_3),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_3) => onCopyWidget(item_3.i, targetDashboardId_3)
						}) : widget_4.type === "spending-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpendingCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_4) => onMetaChange(item_3, newMeta_4),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_4) => onCopyWidget(item_3.i, targetDashboardId_4)
						}) : widget_4.type === "budget-analysis-card" && budgetAnalysisReportEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysisCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_5) => onMetaChange(item_3, newMeta_5),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_5) => onCopyWidget(item_3.i, targetDashboardId_5)
						}) : widget_4.type === "balance-forecast-card" && balanceForecastReportEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BalanceForecastCard, {
							widgetId: item_3.i,
							isEditing,
							accounts,
							meta: widget_4.meta,
							onMetaChange: (newMeta_6) => onMetaChange(item_3, newMeta_6),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_6) => onCopyWidget(item_3.i, targetDashboardId_6)
						}) : widget_4.type === "markdown-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownCard, {
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_7) => onMetaChange(item_3, newMeta_7),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_7) => onCopyWidget(item_3.i, targetDashboardId_7)
						}) : widget_4.type === "custom-report" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomReportListCards, {
							isEditing,
							report: customReportMap.get(widget_4.meta.id),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_8) => onCopyWidget(item_3.i, targetDashboardId_8)
						}) : widget_4.type === "summary-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SummaryCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_8) => onMetaChange(item_3, newMeta_8),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_9) => onCopyWidget(item_3.i, targetDashboardId_9)
						}) : widget_4.type === "calendar-card" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							firstDayOfWeekIdx,
							onMetaChange: (newMeta_9) => onMetaChange(item_3, newMeta_9),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_10) => onCopyWidget(item_3.i, targetDashboardId_10)
						}) : widget_4.type === "formula-card" && formulaMode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormulaCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_10) => onMetaChange(item_3, newMeta_10),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_11) => onCopyWidget(item_3.i, targetDashboardId_11)
						}) : widget_4.type === "sankey-card" && sankeyFeatureFlag ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SankeyCard, {
							widgetId: item_3.i,
							isEditing,
							meta: widget_4.meta,
							onMetaChange: (newMeta_11) => onMetaChange(item_3, newMeta_11),
							onRemove: () => onRemoveWidget(item_3.i),
							onCopy: (targetDashboardId_12) => onCopyWidget(item_3.i, targetDashboardId_12)
						}) : null
					}) }, item_3.i);
				})
			})
		}) });
		$[85] = accounts;
		$[86] = ageOfMoneyReportEnabled;
		$[87] = balanceForecastReportEnabled;
		$[88] = budgetAnalysisReportEnabled;
		$[89] = containerRef;
		$[90] = containerWidth;
		$[91] = currentBreakpoint;
		$[92] = currentLayout;
		$[93] = customReportMap;
		$[94] = firstDayOfWeekIdx;
		$[95] = formulaMode;
		$[96] = isEditing;
		$[97] = isImporting;
		$[98] = isMounted;
		$[99] = onCopyWidget;
		$[100] = onLayoutChange;
		$[101] = onMetaChange;
		$[102] = onRemoveWidget;
		$[103] = sankeyFeatureFlag;
		$[104] = t;
		$[105] = widgetMap;
		$[106] = t28;
	} else t28 = $[106];
	let t29;
	if ($[107] !== t27 || $[108] !== t28) {
		t29 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Page, {
			header: t27,
			padding: 10,
			children: t28
		});
		$[107] = t27;
		$[108] = t28;
		$[109] = t29;
	} else t29 = $[109];
	return t29;
}
function _temp6(report_0) {
	return {
		name: `custom-report-${report_0.id}`,
		text: report_0.name
	};
}
function _temp5(item) {
	return {
		id: item.i,
		width: item.w,
		height: item.h,
		x: item.x,
		y: item.y
	};
}
function _temp4(widget_1) {
	return [widget_1.id, widget_1];
}
function _temp3(widget_0) {
	return {
		i: widget_0.id,
		x: widget_0.x,
		y: widget_0.y,
		w: widget_0.width,
		h: widget_0.height,
		minW: getWidgetMinWidth(widget_0),
		minH: getWidgetMinHeight(widget_0)
	};
}
function _temp2(a, b) {
	if (a.y < b.y) return -1;
	if (a.y > b.y) return 1;
	if (a.x < b.x) return -1;
	if (a.x > b.x) return 1;
	return 0;
}
function _temp(report) {
	return [report.id, report];
}
//#endregion
//#region src/components/reports/ReportsDashboardRouter.tsx
function ReportsDashboardRouter() {
	const $ = (0, import_compiler_runtime.c)(25);
	const { t } = useTranslation();
	const { dashboardId } = useParams();
	const navigate = useNavigate();
	const { data: t0, isPending } = useDashboardPages();
	let t1;
	if ($[0] !== t0) {
		t1 = t0 === void 0 ? [] : t0;
		$[0] = t0;
		$[1] = t1;
	} else t1 = $[1];
	const dashboardPages = t1;
	let t2;
	let t3;
	if ($[2] !== dashboardId || $[3] !== dashboardPages || $[4] !== isPending || $[5] !== navigate) {
		t2 = () => {
			if (!dashboardId && !isPending && dashboardPages.length > 0) navigate(`/reports/${dashboardPages[0].id}`, { replace: true });
		};
		t3 = [
			dashboardId,
			isPending,
			dashboardPages,
			navigate
		];
		$[2] = dashboardId;
		$[3] = dashboardPages;
		$[4] = isPending;
		$[5] = navigate;
		$[6] = t2;
		$[7] = t3;
	} else {
		t2 = $[6];
		t3 = $[7];
	}
	(0, import_react.useEffect)(t2, t3);
	if (isPending || !dashboardId && dashboardPages.length > 0) {
		let t4;
		if ($[8] !== t) {
			t4 = t("Loading dashboards...");
			$[8] = t;
			$[9] = t4;
		} else t4 = $[9];
		let t5;
		if ($[10] !== t4) {
			t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t4 });
			$[10] = t4;
			$[11] = t5;
		} else t5 = $[11];
		return t5;
	}
	if (dashboardId) {
		let t4;
		if ($[12] !== dashboardId || $[13] !== dashboardPages) {
			let t5;
			if ($[15] !== dashboardId) {
				t5 = (d) => d.id === dashboardId;
				$[15] = dashboardId;
				$[16] = t5;
			} else t5 = $[16];
			t4 = dashboardPages.find(t5);
			$[12] = dashboardId;
			$[13] = dashboardPages;
			$[14] = t4;
		} else t4 = $[14];
		const dashboard = t4;
		if (dashboard) {
			let t5;
			if ($[17] !== dashboard) {
				t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Overview, { dashboard });
				$[17] = dashboard;
				$[18] = t5;
			} else t5 = $[18];
			return t5;
		} else {
			let t5;
			if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
				t5 = {
					flex: 1,
					gap: 20,
					justifyContent: "center",
					alignItems: "center"
				};
				$[19] = t5;
			} else t5 = $[19];
			let t6;
			if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
				t6 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
					style: t5,
					children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Block, {
						style: {
							marginBottom: 20,
							fontSize: 18
						},
						children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trans, { children: "Dashboard not found" })
					})
				});
				$[20] = t6;
			} else t6 = $[20];
			return t6;
		}
	}
	let t4;
	if ($[21] !== t) {
		t4 = t("No dashboards available");
		$[21] = t;
		$[22] = t4;
	} else t4 = $[22];
	let t5;
	if ($[23] !== t4) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { message: t4 });
		$[23] = t4;
		$[24] = t5;
	} else t5 = $[24];
	return t5;
}
//#endregion
//#region src/components/reports/ReportRouter.tsx
function ReportRouter() {
	const $ = (0, import_compiler_runtime.c)(31);
	const ageOfMoneyReportEnabled = useFeatureFlag("ageOfMoneyReport");
	const balanceForecastReportEnabled = useFeatureFlag("balanceForecastReport");
	const budgetAnalysisReportEnabled = useFeatureFlag("budgetAnalysisReport");
	const sankeyReportEnabled = useFeatureFlag("sankeyReport");
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportsDashboardRouter, {})
		});
		$[0] = t0;
	} else t0 = $[0];
	let t1;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/:dashboardId",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportsDashboardRouter, {})
		});
		$[1] = t1;
	} else t1 = $[1];
	let t2;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/net-worth",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorth, {})
		});
		$[2] = t2;
	} else t2 = $[2];
	let t3;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/net-worth/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NetWorth, {})
		});
		$[3] = t3;
	} else t3 = $[3];
	let t4;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/crossover",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Crossover, {})
		});
		$[4] = t4;
	} else t4 = $[4];
	let t5;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/crossover/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Crossover, {})
		});
		$[5] = t5;
	} else t5 = $[5];
	let t6;
	if ($[6] !== ageOfMoneyReportEnabled) {
		t6 = ageOfMoneyReportEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/age-of-money",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoney, {})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/age-of-money/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgeOfMoney, {})
		})] });
		$[6] = ageOfMoneyReportEnabled;
		$[7] = t6;
	} else t6 = $[7];
	let t7;
	if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/cash-flow",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CashFlow, {})
		});
		$[8] = t7;
	} else t7 = $[8];
	let t8;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/cash-flow/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CashFlow, {})
		});
		$[9] = t8;
	} else t8 = $[9];
	let t9;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/custom",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomReport, {})
		});
		$[10] = t9;
	} else t9 = $[10];
	let t10;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/custom/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomReport, {})
		});
		$[11] = t10;
	} else t10 = $[11];
	let t11;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/spending",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spending, {})
		});
		$[12] = t11;
	} else t11 = $[12];
	let t12;
	if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/spending/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spending, {})
		});
		$[13] = t12;
	} else t12 = $[13];
	let t13;
	if ($[14] !== budgetAnalysisReportEnabled) {
		t13 = budgetAnalysisReportEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/budget-analysis",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysis, {})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/budget-analysis/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BudgetAnalysis, {})
		})] });
		$[14] = budgetAnalysisReportEnabled;
		$[15] = t13;
	} else t13 = $[15];
	let t14;
	if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/summary",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Summary, {})
		});
		$[16] = t14;
	} else t14 = $[16];
	let t15;
	if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/summary/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Summary, {})
		});
		$[17] = t15;
	} else t15 = $[17];
	let t16;
	if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
		t16 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/calendar",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Calendar, {})
		});
		$[18] = t16;
	} else t16 = $[18];
	let t17;
	if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/calendar/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Calendar, {})
		});
		$[19] = t17;
	} else t17 = $[19];
	let t18;
	if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/formula",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Formula, {})
		});
		$[20] = t18;
	} else t18 = $[20];
	let t19;
	if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
		t19 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/formula/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Formula, {})
		});
		$[21] = t19;
	} else t19 = $[21];
	let t20;
	if ($[22] !== balanceForecastReportEnabled) {
		t20 = balanceForecastReportEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/forecast",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BalanceForecast, {})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/forecast/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BalanceForecast, {})
		})] });
		$[22] = balanceForecastReportEnabled;
		$[23] = t20;
	} else t20 = $[23];
	let t21;
	if ($[24] !== sankeyReportEnabled) {
		t21 = sankeyReportEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/sankey",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sankey, {})
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Route, {
			path: "/sankey/:id",
			element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sankey, {})
		})] });
		$[24] = sankeyReportEnabled;
		$[25] = t21;
	} else t21 = $[25];
	let t22;
	if ($[26] !== t13 || $[27] !== t20 || $[28] !== t21 || $[29] !== t6) {
		t22 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Routes, { children: [
			t0,
			t1,
			t2,
			t3,
			t4,
			t5,
			t6,
			t7,
			t8,
			t9,
			t10,
			t11,
			t12,
			t13,
			t14,
			t15,
			t16,
			t17,
			t18,
			t19,
			t20,
			t21
		] });
		$[26] = t13;
		$[27] = t20;
		$[28] = t21;
		$[29] = t6;
		$[30] = t22;
	} else t22 = $[30];
	return t22;
}
//#endregion
export { ReportRouter };

//# sourceMappingURL=ReportRouter.DWloFi3y.chunk.js.map