@layerfi/components 0.1.114 → 0.1.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,12 +65,12 @@ import useSWRInfinite from "swr/infinite";
65
65
  import useSWRMutation from "swr/mutation";
66
66
  import { useStoreWithEqualityFn } from "zustand/traditional";
67
67
  import { useFloating, offset, flip, shift, autoUpdate, useHover, useFocus, useDismiss, useRole, useInteractions, useTransitionStyles, useMergeRefs, FloatingPortal } from "@floating-ui/react";
68
- import { Button as Button$2, Header as Header$3, Label as Label$1, Text as Text$1, ModalOverlay as ModalOverlay$1, Modal as Modal$1, Dialog as Dialog$1, Heading as Heading$2, Group, SearchField as SearchField$1, Input as Input$2, Form as Form$1, TextField as TextField$1, FieldError as FieldError$1, Checkbox as Checkbox$1, DateField as DateField$1, DateInput as DateInput$1, DateSegment as DateSegment$1, DatePicker as DatePicker$2, NumberField as NumberField$1, TextArea as TextArea$1, MenuTrigger, Popover as Popover$1, Menu as Menu$1, MenuItem as MenuItem$2, GridList, GridListItem, DialogTrigger, ToggleButton, SelectionIndicator, ToggleButtonGroup, Table as Table$2, Column as Column$1, Cell as Cell$1, TableHeader as TableHeader$1, TableBody as TableBody$2, Row as Row$1, Switch as Switch$1, Calendar as Calendar$1, CalendarGrid as CalendarGrid$1, CalendarGridBody as CalendarGridBody$1, CalendarCell as CalendarCell$1, CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell as CalendarHeaderCell$1, Meter as Meter$1, Link as Link$3 } from "react-aria-components";
69
- import { LoaderCircle, X as X$1, ChevronDown as ChevronDown$1, Layers2Icon, UploadCloud as UploadCloud$1, Search, ChevronLeft as ChevronLeft$1, CopyIcon, FileSpreadsheet, FileDownIcon, Minus, Check as Check$1, RefreshCcw as RefreshCcw$1, MenuIcon, ChevronRight as ChevronRight$1, PencilRuler, SearchX, Trash2, CheckIcon, AlertCircle as AlertCircle$1, TriangleAlert, List, AlertTriangle, Save as Save$1, Plus as Plus$1, HandCoins, Menu as Menu$2, Trash as Trash$1, Send, Calendar as Calendar$2, Download, Users, Milestone, Video, Clock as Clock$1, Link as Link$4, Car } from "lucide-react";
68
+ import { Button as Button$2, Header as Header$3, Label as Label$1, Text as Text$1, ModalOverlay as ModalOverlay$1, Modal as Modal$1, Dialog as Dialog$1, Heading as Heading$2, Group, SearchField as SearchField$1, Input as Input$2, Form as Form$1, TextField as TextField$1, FieldError as FieldError$1, Checkbox as Checkbox$1, DateField as DateField$1, DateInput as DateInput$1, DateSegment as DateSegment$1, DatePicker as DatePicker$2, NumberField as NumberField$1, Switch as Switch$1, TextArea as TextArea$1, MenuTrigger, Popover as Popover$1, Menu as Menu$1, MenuItem as MenuItem$2, GridList, GridListItem, DialogTrigger, ToggleButton, SelectionIndicator, ToggleButtonGroup, Table as Table$2, Column as Column$1, Cell as Cell$1, TableHeader as TableHeader$1, TableBody as TableBody$2, Row as Row$1, Calendar as Calendar$1, CalendarGrid as CalendarGrid$1, CalendarGridBody as CalendarGridBody$1, CalendarCell as CalendarCell$1, CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell as CalendarHeaderCell$1, Meter as Meter$1, Link as Link$3 } from "react-aria-components";
69
+ import { LoaderCircle, X as X$1, ChevronDown as ChevronDown$1, Layers2Icon, UploadCloud as UploadCloud$1, Search, ChevronLeft as ChevronLeft$1, CopyIcon, FileSpreadsheet, FileDownIcon, Minus, Check as Check$1, RefreshCcw as RefreshCcw$1, MenuIcon, ChevronRight as ChevronRight$1, PencilRuler, SearchX, Trash2, CheckIcon, AlertCircle as AlertCircle$1, TriangleAlert, List, AlertTriangle, Save as Save$1, Plus as Plus$1, HandCoins, Menu as Menu$2, Trash as Trash$1, Send, Calendar as Calendar$2, Download, Users, Milestone, Video, Clock as Clock$1, Link as Link$4, Car, Edit, RotateCcw, Archive } from "lucide-react";
70
70
  import pluralize from "pluralize";
71
71
  import { mergeRefs } from "react-merge-refs";
72
72
  import useResizeObserver from "@react-hook/resize-observer";
73
- import Select$1, { components } from "react-select";
73
+ import ReactSelect, { components } from "react-select";
74
74
  import { useDropzone } from "react-dropzone";
75
75
  import { createFormHookContexts, createFormHook, useForm as useForm$1, useStore as useStore$1, revalidateLogic } from "@tanstack/react-form";
76
76
  import BaseCreatableSelect from "react-select/creatable";
@@ -202,7 +202,7 @@ class ErrorHandlerClass {
202
202
  }
203
203
  const errorHandler = new ErrorHandlerClass();
204
204
  const reportError = (payload) => errorHandler.onError(payload);
205
- const version = "0.1.114";
205
+ const version = "0.1.115";
206
206
  const pkg = {
207
207
  version
208
208
  };
@@ -673,7 +673,7 @@ function requestOAuthToken(_0) {
673
673
  }).then((res) => res.json());
674
674
  });
675
675
  }
676
- function buildKey$10({
676
+ function buildKey$14({
677
677
  appId,
678
678
  appSecret,
679
679
  businessAccessToken,
@@ -716,7 +716,7 @@ function useAuth() {
716
716
  businessAccessToken
717
717
  } = useAuthInput();
718
718
  return useSWR(
719
- () => buildKey$10({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }),
719
+ () => buildKey$14({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }),
720
720
  (key) => {
721
721
  if (key.mode === "explicit") {
722
722
  const { businessAccessToken: businessAccessToken2, apiUrl: apiUrl3 } = key;
@@ -751,7 +751,7 @@ const useLayerContext = () => {
751
751
  return ctx;
752
752
  };
753
753
  const EXTERNAL_ACCOUNTS_TAG_KEY = "#external-accounts";
754
- function buildKey$$({
754
+ function buildKey$13({
755
755
  access_token: accessToken,
756
756
  apiUrl,
757
757
  businessId
@@ -770,7 +770,7 @@ function useListExternalAccounts() {
770
770
  const { apiUrl } = useEnvironment();
771
771
  const { data: auth } = useAuth();
772
772
  return useSWR(
773
- () => buildKey$$(__spreadProps(__spreadValues({}, auth), {
773
+ () => buildKey$13(__spreadProps(__spreadValues({}, auth), {
774
774
  apiUrl,
775
775
  businessId
776
776
  })),
@@ -2603,7 +2603,7 @@ const BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
2603
2603
  const getBankAccounts = get(
2604
2604
  ({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
2605
2605
  );
2606
- function buildKey$_({
2606
+ function buildKey$12({
2607
2607
  access_token: accessToken,
2608
2608
  apiUrl,
2609
2609
  businessId
@@ -2624,7 +2624,7 @@ const useBankAccounts = () => {
2624
2624
  const { apiUrl } = useEnvironment();
2625
2625
  const { data: auth } = useAuth();
2626
2626
  const { data, error, isLoading } = useSWR(
2627
- () => buildKey$_(__spreadProps(__spreadValues({}, auth), {
2627
+ () => buildKey$12(__spreadProps(__spreadValues({}, auth), {
2628
2628
  apiUrl,
2629
2629
  businessId
2630
2630
  })),
@@ -4065,7 +4065,7 @@ class ProfitAndLossReportSWRResponse {
4065
4065
  return this.swrResponse.mutate;
4066
4066
  }
4067
4067
  }
4068
- function buildKey$Z({
4068
+ function buildKey$11({
4069
4069
  access_token: accessToken,
4070
4070
  apiUrl,
4071
4071
  businessId,
@@ -4109,7 +4109,7 @@ function useProfitAndLossReport({ startDate, endDate, tagKey, tagValues, reporti
4109
4109
  const { data } = useAuth();
4110
4110
  const { businessId } = useLayerContext();
4111
4111
  const response = useSWR(
4112
- () => buildKey$Z(__spreadProps(__spreadValues({}, data), {
4112
+ () => buildKey$11(__spreadProps(__spreadValues({}, data), {
4113
4113
  businessId,
4114
4114
  startDate,
4115
4115
  endDate,
@@ -4175,7 +4175,7 @@ class ProfitAndLossSummariesSWRResponse {
4175
4175
  return this.swrResponse.mutate;
4176
4176
  }
4177
4177
  }
4178
- function buildKey$Y({
4178
+ function buildKey$10({
4179
4179
  access_token: accessToken,
4180
4180
  apiUrl,
4181
4181
  businessId,
@@ -4222,7 +4222,7 @@ function useProfitAndLossSummaries({ startYear, startMonth, endYear, endMonth, t
4222
4222
  const { data } = useAuth();
4223
4223
  const { businessId } = useLayerContext();
4224
4224
  const response = useSWR(
4225
- () => buildKey$Y(__spreadProps(__spreadValues({}, data), {
4225
+ () => buildKey$10(__spreadProps(__spreadValues({}, data), {
4226
4226
  businessId,
4227
4227
  startYear,
4228
4228
  startMonth,
@@ -4292,7 +4292,7 @@ const useProfitAndLossGlobalInvalidator = () => {
4292
4292
  return { invalidateProfitAndLoss, debouncedInvalidateProfitAndLoss };
4293
4293
  };
4294
4294
  const CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
4295
- function buildKey$X({
4295
+ function buildKey$$({
4296
4296
  access_token: accessToken,
4297
4297
  apiUrl,
4298
4298
  businessId
@@ -4315,7 +4315,7 @@ function useCategorizeBankTransaction({
4315
4315
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
4316
4316
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
4317
4317
  const mutationResponse = useSWRMutation(
4318
- () => buildKey$X({
4318
+ () => buildKey$$({
4319
4319
  access_token: auth == null ? void 0 : auth.access_token,
4320
4320
  apiUrl: auth == null ? void 0 : auth.apiUrl,
4321
4321
  businessId
@@ -4363,7 +4363,7 @@ function useCategorizeBankTransaction({
4363
4363
  });
4364
4364
  }
4365
4365
  const MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
4366
- function buildKey$W({
4366
+ function buildKey$_({
4367
4367
  access_token: accessToken,
4368
4368
  apiUrl,
4369
4369
  businessId
@@ -4385,7 +4385,7 @@ function useMatchBankTransaction({
4385
4385
  const { mutate } = useSWRConfig();
4386
4386
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
4387
4387
  const mutationResponse = useSWRMutation(
4388
- () => buildKey$W({
4388
+ () => buildKey$_({
4389
4389
  access_token: auth == null ? void 0 : auth.access_token,
4390
4390
  apiUrl: auth == null ? void 0 : auth.apiUrl,
4391
4391
  businessId
@@ -4851,16 +4851,24 @@ const useAugmentedBankTransactions = (params) => {
4851
4851
  }
4852
4852
  return filtered;
4853
4853
  }, [filters, data]);
4854
- const updateOneLocal = (newBankTransaction) => {
4855
- if (newBankTransaction.update_categorization_rules_suggestion) {
4856
- const decodedRuleSuggestion = decodeRulesSuggestion(newBankTransaction.update_categorization_rules_suggestion);
4857
- setRuleSuggestion(decodedRuleSuggestion);
4854
+ const updateLocalBankTransactions = (newBankTransactions) => {
4855
+ const transactionsById = new Map(
4856
+ newBankTransactions.map((bt) => [bt.id, bt])
4857
+ );
4858
+ for (const bt of newBankTransactions) {
4859
+ if (bt.update_categorization_rules_suggestion) {
4860
+ const decodedRuleSuggestion = decodeRulesSuggestion(bt.update_categorization_rules_suggestion);
4861
+ setRuleSuggestion(decodedRuleSuggestion);
4862
+ }
4858
4863
  }
4859
4864
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
4860
4865
  var _a2;
4861
4866
  return __spreadProps(__spreadValues({}, page), {
4862
4867
  data: (_a2 = page.data) == null ? void 0 : _a2.map(
4863
- (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
4868
+ (bt) => {
4869
+ var _a3;
4870
+ return (_a3 = transactionsById.get(bt.id)) != null ? _a3 : bt;
4871
+ }
4864
4872
  )
4865
4873
  });
4866
4874
  });
@@ -4872,25 +4880,29 @@ const useAugmentedBankTransactions = (params) => {
4872
4880
  const categorizeWithOptimisticUpdate = (bankTransactionId, newCategory, notify) => __async(null, null, function* () {
4873
4881
  const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4874
4882
  if (existingTransaction) {
4875
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), { update_categorization_rules_suggestion: void 0, processing: true, error: void 0 }));
4883
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, existingTransaction), {
4884
+ update_categorization_rules_suggestion: void 0,
4885
+ processing: true,
4886
+ error: void 0
4887
+ })]);
4876
4888
  }
4877
4889
  return categorizeBankTransaction2(__spreadValues({
4878
4890
  bankTransactionId
4879
4891
  }, newCategory)).then((updatedTransaction) => {
4880
- updateOneLocal(__spreadProps(__spreadValues({}, updatedTransaction), {
4892
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, updatedTransaction), {
4881
4893
  processing: false,
4882
4894
  recently_categorized: true
4883
- }));
4895
+ })]);
4884
4896
  if (notify) {
4885
4897
  addToast({ content: "Transaction confirmed" });
4886
4898
  }
4887
4899
  }).catch((error) => {
4888
4900
  const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4889
4901
  if (targetedTransaction) {
4890
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
4902
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, targetedTransaction), {
4891
4903
  error: error instanceof Error ? error.message : "An unknown error occurred",
4892
4904
  processing: false
4893
- }));
4905
+ })]);
4894
4906
  }
4895
4907
  }).finally(() => {
4896
4908
  var _a2;
@@ -4900,71 +4912,76 @@ const useAugmentedBankTransactions = (params) => {
4900
4912
  const { trigger: matchBankTransaction2 } = useMatchBankTransaction({
4901
4913
  mutateBankTransactions: mutate
4902
4914
  });
4903
- const matchWithOptimisticUpdate = (bankTransactionId, suggestedMatchId, notify) => __async(null, null, function* () {
4904
- const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4905
- if (existingTransaction) {
4906
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), {
4907
- processing: true,
4908
- error: void 0
4909
- }));
4910
- }
4911
- const transferBankTransaction = data == null ? void 0 : data.find(
4912
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
4915
+ const matchWithOptimisticUpdate = (bankTransaction, suggestedMatchId, notify) => __async(null, null, function* () {
4916
+ var _a2, _b;
4917
+ const suggestedMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
4918
+ (sm) => sm.id === suggestedMatchId
4913
4919
  );
4914
- if (transferBankTransaction) {
4915
- updateOneLocal(__spreadProps(__spreadValues({}, transferBankTransaction), {
4920
+ const matchedTransferBankTransactionId = (_b = suggestedMatch == null ? void 0 : suggestedMatch.details) == null ? void 0 : _b.id;
4921
+ const matchedTransferBankTransaction = matchedTransferBankTransactionId ? data == null ? void 0 : data.find(({ id }) => id === matchedTransferBankTransactionId) : void 0;
4922
+ const transactionsToSetProcessing = [
4923
+ __spreadProps(__spreadValues({}, bankTransaction), { processing: true, error: void 0 })
4924
+ ];
4925
+ if (matchedTransferBankTransaction) {
4926
+ transactionsToSetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4916
4927
  processing: true,
4917
4928
  error: void 0
4918
4929
  }));
4919
4930
  }
4931
+ updateLocalBankTransactions(transactionsToSetProcessing);
4920
4932
  return matchBankTransaction2({
4921
- bankTransactionId,
4933
+ bankTransactionId: bankTransaction.id,
4922
4934
  match_id: suggestedMatchId,
4923
4935
  type: "Confirm_Match"
4924
4936
  }).then((match) => {
4925
- const matchedTransaction = data == null ? void 0 : data.find(({ id }) => id === match.bank_transaction.id);
4926
- if (matchedTransaction) {
4927
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransaction), {
4937
+ const transactionsToUpdate = [
4938
+ __spreadProps(__spreadValues({}, bankTransaction), {
4928
4939
  categorization_status: CategorizationStatus.MATCHED,
4929
4940
  match,
4930
4941
  processing: false,
4931
4942
  recently_categorized: true
4932
- }));
4933
- }
4934
- const matchedTransferTransaction = data == null ? void 0 : data.find(
4935
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
4936
- );
4937
- if (matchedTransferTransaction) {
4938
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransferTransaction), {
4943
+ })
4944
+ ];
4945
+ if (matchedTransferBankTransaction) {
4946
+ transactionsToUpdate.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4947
+ categorization_status: CategorizationStatus.MATCHED,
4948
+ match,
4939
4949
  processing: false,
4940
4950
  recently_categorized: true
4941
4951
  }));
4942
4952
  }
4953
+ updateLocalBankTransactions(transactionsToUpdate);
4943
4954
  if (notify) {
4944
4955
  addToast({ content: "Transaction saved" });
4945
4956
  }
4946
4957
  }).catch((error) => {
4947
- const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4948
- if (targetedTransaction) {
4949
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
4958
+ const transactionsToResetProcessing = [
4959
+ __spreadProps(__spreadValues({}, bankTransaction), {
4950
4960
  error: error instanceof Error ? error.message : "An unknown error occurred",
4951
4961
  processing: false
4962
+ })
4963
+ ];
4964
+ if (matchedTransferBankTransaction) {
4965
+ transactionsToResetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4966
+ error: void 0,
4967
+ processing: false
4952
4968
  }));
4953
4969
  }
4970
+ updateLocalBankTransactions(transactionsToResetProcessing);
4954
4971
  }).finally(() => {
4955
- var _a2;
4956
- (_a2 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a2.call(eventCallbacks);
4972
+ var _a3;
4973
+ (_a3 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a3.call(eventCallbacks);
4957
4974
  });
4958
4975
  });
4959
4976
  const shouldHideAfterCategorize = () => {
4960
4977
  return (filters == null ? void 0 : filters.categorizationStatus) === DisplayState.review;
4961
4978
  };
4962
- const removeAfterCategorize = (bankTransaction) => {
4979
+ const removeAfterCategorize = (transactionIds) => {
4963
4980
  if (shouldHideAfterCategorize()) {
4964
4981
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
4965
4982
  var _a2;
4966
4983
  return __spreadProps(__spreadValues({}, page), {
4967
- data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => bt.id !== bankTransaction.id)
4984
+ data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => !transactionIds.includes(bt.id))
4968
4985
  });
4969
4986
  });
4970
4987
  void mutate(updatedData, { revalidate: false });
@@ -5043,7 +5060,7 @@ const useAugmentedBankTransactions = (params) => {
5043
5060
  isError: !!responseError,
5044
5061
  categorize: categorizeWithOptimisticUpdate,
5045
5062
  match: matchWithOptimisticUpdate,
5046
- updateOneLocal,
5063
+ updateLocalBankTransactions,
5047
5064
  shouldHideAfterCategorize,
5048
5065
  removeAfterCategorize,
5049
5066
  display,
@@ -6411,7 +6428,7 @@ const getBookkeepingStatus = get(({ businessId }) => {
6411
6428
  });
6412
6429
  const BOOKKEEPING_TAG_KEY = "#bookkeeping";
6413
6430
  const BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
6414
- function buildKey$V({
6431
+ function buildKey$Z({
6415
6432
  access_token: accessToken,
6416
6433
  apiUrl,
6417
6434
  businessId
@@ -6429,7 +6446,7 @@ function useBookkeepingStatus() {
6429
6446
  const { data: auth } = useAuth();
6430
6447
  const { businessId } = useLayerContext();
6431
6448
  return useSWR(
6432
- () => buildKey$V(__spreadProps(__spreadValues({}, auth), {
6449
+ () => buildKey$Z(__spreadProps(__spreadValues({}, auth), {
6433
6450
  businessId
6434
6451
  })),
6435
6452
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingStatus(
@@ -6469,6 +6486,50 @@ function isCategorizationEnabledForStatus(status) {
6469
6486
  }
6470
6487
  }
6471
6488
  }
6489
+ const CATEGORIES_TAG_KEY = "#categories";
6490
+ function buildKey$Y({
6491
+ access_token: accessToken,
6492
+ apiUrl,
6493
+ businessId,
6494
+ mode
6495
+ }) {
6496
+ if (accessToken && apiUrl) {
6497
+ return {
6498
+ accessToken,
6499
+ apiUrl,
6500
+ businessId,
6501
+ mode,
6502
+ tags: [CATEGORIES_TAG_KEY]
6503
+ };
6504
+ }
6505
+ }
6506
+ const getCategories = get(({ businessId, mode }) => {
6507
+ const parameters = toDefinedSearchParameters({ mode });
6508
+ return `/v1/businesses/${businessId}/categories?${parameters}`;
6509
+ });
6510
+ function useCategories({ mode } = {}) {
6511
+ const { data: auth } = useAuth();
6512
+ const { businessId } = useLayerContext();
6513
+ return useSWR(
6514
+ () => buildKey$Y(__spreadProps(__spreadValues({}, auth), {
6515
+ businessId,
6516
+ mode
6517
+ })),
6518
+ ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
6519
+ apiUrl,
6520
+ accessToken,
6521
+ {
6522
+ params: {
6523
+ businessId: businessId2,
6524
+ mode: mode2
6525
+ }
6526
+ }
6527
+ )().then(({ data }) => Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
6528
+ );
6529
+ }
6530
+ function usePreloadCategories(options2) {
6531
+ useCategories(options2);
6532
+ }
6472
6533
  const useElementSize = (callback) => {
6473
6534
  const ref = useRef(null);
6474
6535
  const resizeTimeout = useRef(null);
@@ -6596,15 +6657,15 @@ const BankTransactionsContext = createContext({
6596
6657
  isError: false,
6597
6658
  refetch: () => {
6598
6659
  },
6599
- categorize: () => Promise.resolve(void 0),
6600
- match: () => Promise.resolve(void 0),
6660
+ categorize: () => Promise.resolve(),
6661
+ match: () => Promise.resolve(),
6601
6662
  metadata: {
6602
6663
  pagination: {
6603
6664
  cursor: void 0,
6604
6665
  has_more: false
6605
6666
  }
6606
6667
  },
6607
- updateOneLocal: () => void 0,
6668
+ updateLocalBankTransactions: () => void 0,
6608
6669
  shouldHideAfterCategorize: () => false,
6609
6670
  removeAfterCategorize: () => void 0,
6610
6671
  display: DisplayState.review,
@@ -6887,7 +6948,7 @@ const useBusinessActivationDate = () => {
6887
6948
  const { business } = useLayerContext();
6888
6949
  return useMemo(() => getActivationDate(business), [business]);
6889
6950
  };
6890
- function buildKey$U({
6951
+ function buildKey$X({
6891
6952
  access_token: accessToken,
6892
6953
  apiUrl,
6893
6954
  businessId
@@ -6905,7 +6966,7 @@ function useBankTransactionsDownload() {
6905
6966
  const { data } = useAuth();
6906
6967
  const { businessId } = useLayerContext();
6907
6968
  return useSWRMutation(
6908
- () => buildKey$U(__spreadProps(__spreadValues({}, data), {
6969
+ () => buildKey$X(__spreadProps(__spreadValues({}, data), {
6909
6970
  businessId
6910
6971
  })),
6911
6972
  ({
@@ -7063,7 +7124,7 @@ const BulkCategorizeRequestSchema = Schema.Struct({
7063
7124
  transactions: Schema.Array(CategorizeTransactionRequestSchema$1)
7064
7125
  });
7065
7126
  const bulkCategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-categorize`);
7066
- function buildKey$T({
7127
+ function buildKey$W({
7067
7128
  access_token: accessToken,
7068
7129
  apiUrl,
7069
7130
  businessId
@@ -7082,7 +7143,7 @@ const useBulkCategorize = () => {
7082
7143
  const { businessId, eventCallbacks } = useLayerContext();
7083
7144
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
7084
7145
  const mutationResponse = useSWRMutation(
7085
- () => buildKey$T(__spreadProps(__spreadValues({}, data), {
7146
+ () => buildKey$W(__spreadProps(__spreadValues({}, data), {
7086
7147
  businessId
7087
7148
  })),
7088
7149
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkCategorize(
@@ -7326,50 +7387,6 @@ const Span = forwardRef(
7326
7387
  );
7327
7388
  }
7328
7389
  );
7329
- const CATEGORIES_TAG_KEY = "#categories";
7330
- function buildKey$S({
7331
- access_token: accessToken,
7332
- apiUrl,
7333
- businessId,
7334
- mode
7335
- }) {
7336
- if (accessToken && apiUrl) {
7337
- return {
7338
- accessToken,
7339
- apiUrl,
7340
- businessId,
7341
- mode,
7342
- tags: [CATEGORIES_TAG_KEY]
7343
- };
7344
- }
7345
- }
7346
- const getCategories = get(({ businessId, mode }) => {
7347
- const parameters = toDefinedSearchParameters({ mode });
7348
- return `/v1/businesses/${businessId}/categories?${parameters}`;
7349
- });
7350
- function useCategories({ mode } = {}) {
7351
- const { data: auth } = useAuth();
7352
- const { businessId } = useLayerContext();
7353
- return useSWR(
7354
- () => buildKey$S(__spreadProps(__spreadValues({}, auth), {
7355
- businessId,
7356
- mode
7357
- })),
7358
- ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
7359
- apiUrl,
7360
- accessToken,
7361
- {
7362
- params: {
7363
- businessId: businessId2,
7364
- mode: mode2
7365
- }
7366
- }
7367
- )().then(({ data }) => Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
7368
- );
7369
- }
7370
- function usePreloadCategories(options2) {
7371
- useCategories(options2);
7372
- }
7373
7390
  const Check = (_R) => {
7374
7391
  var _S = _R, { size = 18 } = _S, props = __objRest(_S, ["size"]);
7375
7392
  return /* @__PURE__ */ jsx(
@@ -7635,7 +7652,7 @@ function ComboBox(_T) {
7635
7652
  const CustomDropdownIndicatorRef = useRef(buildCustomDropdownIndicator());
7636
7653
  return /* @__PURE__ */ jsxs(VStack, { gap: "3xs", fluid: true, className: className ? `${className}__Container` : void 0, children: [
7637
7654
  /* @__PURE__ */ jsx(
7638
- Select$1,
7655
+ ReactSelect,
7639
7656
  __spreadProps(__spreadValues({
7640
7657
  inputId: effectiveInputId
7641
7658
  }, ariaProps), {
@@ -9048,7 +9065,7 @@ const bulkMatchOrCategorize = post(
9048
9065
  return `/v1/businesses/${businessId}/bank-transactions/bulk-match-or-categorize?${parameters}`;
9049
9066
  }
9050
9067
  );
9051
- function buildKey$R({
9068
+ function buildKey$V({
9052
9069
  access_token: accessToken,
9053
9070
  apiUrl,
9054
9071
  businessId
@@ -9073,7 +9090,7 @@ const useBulkMatchOrCategorize = () => {
9073
9090
  return { transactions };
9074
9091
  }, [selectedIds, transactionCategories]);
9075
9092
  const mutationResponse = useSWRMutation(
9076
- () => buildKey$R(__spreadProps(__spreadValues({}, data), {
9093
+ () => buildKey$V(__spreadProps(__spreadValues({}, data), {
9077
9094
  businessId
9078
9095
  })),
9079
9096
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkMatchOrCategorize(
@@ -9143,7 +9160,7 @@ const BulkUncategorizeRequestSchema = Schema.Struct({
9143
9160
  )
9144
9161
  });
9145
9162
  const bulkUncategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-uncategorize`);
9146
- function buildKey$Q({
9163
+ function buildKey$U({
9147
9164
  access_token: accessToken,
9148
9165
  apiUrl,
9149
9166
  businessId
@@ -9162,7 +9179,7 @@ const useBulkUncategorize = () => {
9162
9179
  const { businessId, eventCallbacks } = useLayerContext();
9163
9180
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
9164
9181
  const mutationResponse = useSWRMutation(
9165
- () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
9182
+ () => buildKey$U(__spreadProps(__spreadValues({}, data), {
9166
9183
  businessId
9167
9184
  })),
9168
9185
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkUncategorize(
@@ -9566,7 +9583,7 @@ const mapRawCustomAccountToCustomAccount = (raw) => ({
9566
9583
  userCreated: raw.user_created
9567
9584
  });
9568
9585
  const CUSTOM_ACCOUNTS_TAG_KEY = "#custom-accounts";
9569
- function buildKey$P({
9586
+ function buildKey$T({
9570
9587
  access_token: accessToken,
9571
9588
  apiUrl,
9572
9589
  businessId,
@@ -9593,7 +9610,7 @@ function useCustomAccounts({ userCreated } = {}) {
9593
9610
  const { data } = useAuth();
9594
9611
  const { businessId } = useLayerContext();
9595
9612
  return useSWR(
9596
- () => buildKey$P(__spreadProps(__spreadValues({}, data), {
9613
+ () => buildKey$T(__spreadProps(__spreadValues({}, data), {
9597
9614
  businessId,
9598
9615
  userCreated
9599
9616
  })),
@@ -9606,7 +9623,7 @@ function useCustomAccounts({ userCreated } = {}) {
9606
9623
  )().then(({ data: data2 }) => data2 == null ? void 0 : data2.custom_accounts.map((account) => mapRawCustomAccountToCustomAccount(account)))
9607
9624
  );
9608
9625
  }
9609
- function buildKey$O({
9626
+ function buildKey$S({
9610
9627
  access_token: accessToken,
9611
9628
  apiUrl,
9612
9629
  businessId
@@ -9639,7 +9656,7 @@ function useCustomAccountParseCsv() {
9639
9656
  const { data } = useAuth();
9640
9657
  const { businessId } = useLayerContext();
9641
9658
  return useSWRMutation(
9642
- () => buildKey$O(__spreadProps(__spreadValues({}, data), {
9659
+ () => buildKey$S(__spreadProps(__spreadValues({}, data), {
9643
9660
  businessId
9644
9661
  })),
9645
9662
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { customAccountId, file } }) => parseCsv(
@@ -9884,7 +9901,7 @@ function flattenValidationErrors(errors) {
9884
9901
  );
9885
9902
  }
9886
9903
  const createCustomAccount = post(({ businessId }) => `/v1/businesses/${businessId}/custom-accounts`);
9887
- function buildKey$N({
9904
+ function buildKey$R({
9888
9905
  access_token: accessToken,
9889
9906
  apiUrl,
9890
9907
  businessId
@@ -9903,7 +9920,7 @@ function useCreateCustomAccount() {
9903
9920
  const { businessId } = useLayerContext();
9904
9921
  const { mutate } = useSWRConfig();
9905
9922
  const mutationResponse = useSWRMutation(
9906
- () => buildKey$N(__spreadProps(__spreadValues({}, data), {
9923
+ () => buildKey$R(__spreadProps(__spreadValues({}, data), {
9907
9924
  businessId
9908
9925
  })),
9909
9926
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createCustomAccount(
@@ -10440,10 +10457,63 @@ function FormNumberField({
10440
10457
  })
10441
10458
  );
10442
10459
  }
10460
+ const SWITCH_CLASS_NAME = "Layer__UI__Switch";
10461
+ const Switch = forwardRef((_Va, ref) => {
10462
+ var _Wa = _Va, {
10463
+ children,
10464
+ className
10465
+ } = _Wa, props = __objRest(_Wa, [
10466
+ "children",
10467
+ "className"
10468
+ ]);
10469
+ return /* @__PURE__ */ jsx(
10470
+ Switch$1,
10471
+ __spreadProps(__spreadValues({}, props), {
10472
+ className: classNames(SWITCH_CLASS_NAME, className),
10473
+ ref,
10474
+ children: withRenderProp(children, (node) => /* @__PURE__ */ jsxs(Fragment, { children: [
10475
+ /* @__PURE__ */ jsx("div", { slot: "indicator" }),
10476
+ node
10477
+ ] }))
10478
+ })
10479
+ );
10480
+ });
10481
+ Switch.displayName = "Switch";
10482
+ const FORM_SWITCH_FIELD_CLASSNAME = "Layer__FormSwitchField";
10483
+ function FormSwitchField({
10484
+ label,
10485
+ className,
10486
+ inline = false,
10487
+ showLabel = true,
10488
+ isReadOnly = false
10489
+ }) {
10490
+ const field = useFieldContext();
10491
+ const { name, state, handleChange } = field;
10492
+ const { value } = state;
10493
+ const additionalAriaProps = !showLabel && { "aria-label": label };
10494
+ const switchClassNames = classNames(
10495
+ FORM_SWITCH_FIELD_CLASSNAME,
10496
+ inline && `${FORM_SWITCH_FIELD_CLASSNAME}--inline`,
10497
+ className
10498
+ );
10499
+ return /* @__PURE__ */ jsx(
10500
+ Switch,
10501
+ __spreadProps(__spreadValues({
10502
+ className: switchClassNames,
10503
+ isSelected: value,
10504
+ onChange: handleChange,
10505
+ name,
10506
+ isReadOnly,
10507
+ slot: "switch"
10508
+ }, additionalAriaProps), {
10509
+ children: showLabel && /* @__PURE__ */ jsx(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
10510
+ })
10511
+ );
10512
+ }
10443
10513
  const TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
10444
10514
  const TextArea = forwardRef(
10445
- function TextArea2(_Va, ref) {
10446
- var _Wa = _Va, { resize = "none" } = _Wa, restProps = __objRest(_Wa, ["resize"]);
10515
+ function TextArea2(_Xa, ref) {
10516
+ var _Ya = _Xa, { resize = "none" } = _Ya, restProps = __objRest(_Ya, ["resize"]);
10447
10517
  const dataProperties = toDataProperties({ resize });
10448
10518
  return /* @__PURE__ */ jsx(
10449
10519
  TextArea$1,
@@ -10454,8 +10524,8 @@ const TextArea = forwardRef(
10454
10524
  );
10455
10525
  }
10456
10526
  );
10457
- function FormTextAreaField(_Xa) {
10458
- var _Ya = _Xa, { placeholder } = _Ya, props = __objRest(_Ya, ["placeholder"]);
10527
+ function FormTextAreaField(_Za) {
10528
+ var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
10459
10529
  const field = useFieldContext();
10460
10530
  const { name, state, handleChange, handleBlur } = field;
10461
10531
  const { value } = state;
@@ -10475,8 +10545,8 @@ function FormTextAreaField(_Xa) {
10475
10545
  }
10476
10546
  ) }));
10477
10547
  }
10478
- function FormTextField(_Za) {
10479
- var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
10548
+ function FormTextField(_$a) {
10549
+ var _ab = _$a, { placeholder } = _ab, props = __objRest(_ab, ["placeholder"]);
10480
10550
  const field = useFieldContext();
10481
10551
  const { name, state, handleChange, handleBlur } = field;
10482
10552
  const { value } = state;
@@ -10504,6 +10574,7 @@ const { useAppForm: useRawAppForm } = createFormHook({
10504
10574
  FormCheckboxField,
10505
10575
  FormDateField,
10506
10576
  FormNumberField,
10577
+ FormSwitchField,
10507
10578
  FormTextAreaField,
10508
10579
  FormTextField
10509
10580
  },
@@ -10564,13 +10635,13 @@ const useCustomAccountForm = ({ onSuccess }) => {
10564
10635
  const isFormValid = useStore$1(form.store, (state) => state.isValid);
10565
10636
  return { form, submitError, isFormValid };
10566
10637
  };
10567
- const Input = (_$a) => {
10568
- var _ab = _$a, {
10638
+ const Input = (_bb) => {
10639
+ var _cb = _bb, {
10569
10640
  className,
10570
10641
  isInvalid,
10571
10642
  errorMessage,
10572
10643
  leftText
10573
- } = _ab, props = __objRest(_ab, [
10644
+ } = _cb, props = __objRest(_cb, [
10574
10645
  "className",
10575
10646
  "isInvalid",
10576
10647
  "errorMessage",
@@ -10616,8 +10687,8 @@ const InputGroup = ({
10616
10687
  children
10617
10688
  ] });
10618
10689
  };
10619
- const ChevronDownFill = (_bb) => {
10620
- var _cb = _bb, { size = 18 } = _cb, props = __objRest(_cb, ["size"]);
10690
+ const ChevronDownFill = (_db) => {
10691
+ var _eb = _db, { size = 18 } = _eb, props = __objRest(_eb, ["size"]);
10621
10692
  return /* @__PURE__ */ jsxs(
10622
10693
  "svg",
10623
10694
  __spreadProps(__spreadValues({
@@ -10642,6 +10713,21 @@ const ChevronDownFill = (_bb) => {
10642
10713
  })
10643
10714
  );
10644
10715
  };
10716
+ const SelectMenuPortal = (_fb) => {
10717
+ var _gb = _fb, {
10718
+ children
10719
+ } = _gb, restProps = __objRest(_gb, [
10720
+ "children"
10721
+ ]);
10722
+ const dataProperties = toDataProperties({ "react-aria-top-layer": true });
10723
+ return /* @__PURE__ */ jsx(
10724
+ components.MenuPortal,
10725
+ __spreadProps(__spreadValues({}, restProps), {
10726
+ innerProps: dataProperties,
10727
+ children
10728
+ })
10729
+ );
10730
+ };
10645
10731
  const Select = ({
10646
10732
  name,
10647
10733
  options: options2,
@@ -10665,7 +10751,7 @@ const Select = ({
10665
10751
  const DropdownIndicator = useCallback((props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDownFill, {}) })), []);
10666
10752
  return /* @__PURE__ */ jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
10667
10753
  /* @__PURE__ */ jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx(
10668
- Select$1,
10754
+ ReactSelect,
10669
10755
  {
10670
10756
  inputId,
10671
10757
  name,
@@ -10678,7 +10764,7 @@ const Select = ({
10678
10764
  onChange: (newValue) => newValue && onChange(newValue),
10679
10765
  menuPortalTarget: document.body,
10680
10766
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
10681
- components: { DropdownIndicator },
10767
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
10682
10768
  isLoading,
10683
10769
  isDisabled: disabled
10684
10770
  }
@@ -10686,8 +10772,8 @@ const Select = ({
10686
10772
  /* @__PURE__ */ jsx(DeprecatedTooltipContent, { className: "Layer__tooltip", children: errorMessage })
10687
10773
  ] });
10688
10774
  };
10689
- const ErrorText = (_db) => {
10690
- var _eb = _db, { className } = _eb, props = __objRest(_eb, ["className"]);
10775
+ const ErrorText = (_hb) => {
10776
+ var _ib = _hb, { className } = _ib, props = __objRest(_ib, ["className"]);
10691
10777
  return /* @__PURE__ */ jsx(Text, __spreadProps(__spreadValues({}, props), { status: "error", className }));
10692
10778
  };
10693
10779
  const accountTypeOptions = [
@@ -10841,7 +10927,7 @@ const CreatableSelect = ({
10841
10927
  formatCreateLabel: formatCreateLabel2,
10842
10928
  menuPortalTarget: document.body,
10843
10929
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
10844
- components: { DropdownIndicator },
10930
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
10845
10931
  isLoading,
10846
10932
  isDisabled: disabled,
10847
10933
  isClearable,
@@ -11026,7 +11112,7 @@ function UploadTransactionsUploadCsvStep({ selectedAccount, onSelectAccount, sel
11026
11112
  const createCustomAccountTransactions = post(
11027
11113
  ({ businessId, customAccountId }) => `/v1/businesses/${businessId}/custom-accounts/${customAccountId}/transactions`
11028
11114
  );
11029
- function buildKey$M({
11115
+ function buildKey$Q({
11030
11116
  access_token: accessToken,
11031
11117
  apiUrl,
11032
11118
  businessId
@@ -11045,7 +11131,7 @@ function useCreateCustomAccountTransactions() {
11045
11131
  const { data } = useAuth();
11046
11132
  const { businessId } = useLayerContext();
11047
11133
  return useSWRMutation(
11048
- () => buildKey$M(__spreadProps(__spreadValues({}, data), {
11134
+ () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
11049
11135
  businessId
11050
11136
  })),
11051
11137
  ({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
@@ -11545,8 +11631,8 @@ const BulkActionsModule = ({ slots }) => {
11545
11631
  /* @__PURE__ */ jsx(slots.BulkActions, {})
11546
11632
  ] });
11547
11633
  };
11548
- const DownloadCloud = (_fb) => {
11549
- var _gb = _fb, { size = 18 } = _gb, props = __objRest(_gb, ["size"]);
11634
+ const DownloadCloud = (_jb) => {
11635
+ var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
11550
11636
  return /* @__PURE__ */ jsxs(
11551
11637
  "svg",
11552
11638
  __spreadProps(__spreadValues({
@@ -11798,8 +11884,8 @@ function MonthCalendar({
11798
11884
  const POPOVER_CLASS_NAME = "Layer__Popover";
11799
11885
  const POPOVER_CLASS_NAMES = `Layer__Portal ${POPOVER_CLASS_NAME}`;
11800
11886
  const Popover = forwardRef(
11801
- function Popover2(_hb, ref) {
11802
- var _ib = _hb, { flexInline = false } = _ib, restProps = __objRest(_ib, ["flexInline"]);
11887
+ function Popover2(_lb, ref) {
11888
+ var _mb = _lb, { flexInline = false } = _mb, restProps = __objRest(_mb, ["flexInline"]);
11803
11889
  const dataProperties = toDataProperties({ "flex-inline": flexInline });
11804
11890
  return /* @__PURE__ */ jsx(
11805
11891
  Popover$1,
@@ -12196,8 +12282,8 @@ const BankTransactionsHeader = ({
12196
12282
  }
12197
12283
  );
12198
12284
  };
12199
- const Inbox = (_jb) => {
12200
- var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
12285
+ const Inbox = (_nb) => {
12286
+ var _ob = _nb, { size = 18 } = _ob, props = __objRest(_ob, ["size"]);
12201
12287
  return /* @__PURE__ */ jsxs(
12202
12288
  "svg",
12203
12289
  __spreadProps(__spreadValues({
@@ -12281,7 +12367,7 @@ function BankTransactionsTableEmptyStates({
12281
12367
  return /* @__PURE__ */ jsx("div", { className: "Layer__table-state-container", children: StateComponent });
12282
12368
  }
12283
12369
  const REJECT_CATEGORIZATION_RULE_SUGGESTION_TAG = "#reject-categorization-rule-suggestion";
12284
- function buildKey$L({
12370
+ function buildKey$P({
12285
12371
  access_token: accessToken,
12286
12372
  apiUrl,
12287
12373
  businessId
@@ -12302,7 +12388,7 @@ function useRejectCategorizationRulesUpdateSuggestion() {
12302
12388
  const { data: auth } = useAuth();
12303
12389
  const { businessId } = useLayerContext();
12304
12390
  const mutationResponse = useSWRMutation(
12305
- () => buildKey$L({
12391
+ () => buildKey$P({
12306
12392
  access_token: auth == null ? void 0 : auth.access_token,
12307
12393
  apiUrl: auth == null ? void 0 : auth.apiUrl,
12308
12394
  businessId
@@ -12521,7 +12607,7 @@ function useCategorizationRulesGlobalCacheActions() {
12521
12607
  return { patchCategorizationRuleByKey, forceReloadCategorizationRules };
12522
12608
  }
12523
12609
  const CREATE_CATEGORIZATION_RULE_TAG = "#create-categorization-rule";
12524
- function buildKey$K({
12610
+ function buildKey$O({
12525
12611
  access_token: accessToken,
12526
12612
  apiUrl,
12527
12613
  businessId
@@ -12549,7 +12635,7 @@ function useCreateCategorizationRule() {
12549
12635
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
12550
12636
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
12551
12637
  const mutationResponse = useSWRMutation(
12552
- () => buildKey$K({
12638
+ () => buildKey$O({
12553
12639
  access_token: auth == null ? void 0 : auth.access_token,
12554
12640
  apiUrl: auth == null ? void 0 : auth.apiUrl,
12555
12641
  businessId
@@ -12679,8 +12765,8 @@ function asMutable(a) {
12679
12765
  const CSS_PREFIX$1 = "Layer__UI__Table";
12680
12766
  const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
12681
12767
  const Table$1 = forwardRef(
12682
- (_lb, ref) => {
12683
- var _mb = _lb, { children, className } = _mb, restProps = __objRest(_mb, ["children", "className"]);
12768
+ (_pb, ref) => {
12769
+ var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
12684
12770
  return /* @__PURE__ */ jsx(
12685
12771
  Table$2,
12686
12772
  __spreadProps(__spreadValues({
@@ -12693,8 +12779,8 @@ const Table$1 = forwardRef(
12693
12779
  }
12694
12780
  );
12695
12781
  Table$1.displayName = "Table";
12696
- const TableHeaderInner = (_nb, ref) => {
12697
- var _ob = _nb, { children, className, hideHeader } = _ob, restProps = __objRest(_ob, ["children", "className", "hideHeader"]);
12782
+ const TableHeaderInner = (_rb, ref) => {
12783
+ var _sb = _rb, { children, className, hideHeader } = _sb, restProps = __objRest(_sb, ["children", "className", "hideHeader"]);
12698
12784
  return /* @__PURE__ */ jsx(
12699
12785
  TableHeader$1,
12700
12786
  __spreadProps(__spreadValues({
@@ -12707,8 +12793,8 @@ const TableHeaderInner = (_nb, ref) => {
12707
12793
  };
12708
12794
  const TableHeader = forwardRef(TableHeaderInner);
12709
12795
  TableHeader.displayName = "TableHeader";
12710
- const TableBodyInner = (_pb, ref) => {
12711
- var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
12796
+ const TableBodyInner = (_tb, ref) => {
12797
+ var _ub = _tb, { children, className } = _ub, restProps = __objRest(_ub, ["children", "className"]);
12712
12798
  return /* @__PURE__ */ jsx(
12713
12799
  TableBody$2,
12714
12800
  __spreadProps(__spreadValues({
@@ -12721,8 +12807,8 @@ const TableBodyInner = (_pb, ref) => {
12721
12807
  };
12722
12808
  const TableBody$1 = forwardRef(TableBodyInner);
12723
12809
  TableBody$1.displayName = "TableBody";
12724
- const RowInner = (_rb, ref) => {
12725
- var _sb = _rb, { children, className, depth = 0 } = _sb, restProps = __objRest(_sb, ["children", "className", "depth"]);
12810
+ const RowInner = (_vb, ref) => {
12811
+ var _wb = _vb, { children, className, depth = 0 } = _wb, restProps = __objRest(_wb, ["children", "className", "depth"]);
12726
12812
  const dataProperties = toDataProperties({ depth });
12727
12813
  return /* @__PURE__ */ jsx(
12728
12814
  Row$1,
@@ -12737,8 +12823,8 @@ const RowInner = (_rb, ref) => {
12737
12823
  const Row = forwardRef(RowInner);
12738
12824
  Row.displayName = "Row";
12739
12825
  const Column = forwardRef(
12740
- (_tb, ref) => {
12741
- var _ub = _tb, { children, className, textAlign = "left" } = _ub, restProps = __objRest(_ub, ["children", "className", "textAlign"]);
12826
+ (_xb, ref) => {
12827
+ var _yb = _xb, { children, className, textAlign = "left" } = _yb, restProps = __objRest(_yb, ["children", "className", "textAlign"]);
12742
12828
  const dataProperties = toDataProperties({ "text-align": textAlign });
12743
12829
  return /* @__PURE__ */ jsx(
12744
12830
  Column$1,
@@ -12753,8 +12839,8 @@ const Column = forwardRef(
12753
12839
  );
12754
12840
  Column.displayName = "Column";
12755
12841
  const Cell = forwardRef(
12756
- (_vb, ref) => {
12757
- var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
12842
+ (_zb, ref) => {
12843
+ var _Ab = _zb, { children, className } = _Ab, restProps = __objRest(_Ab, ["children", "className"]);
12758
12844
  return /* @__PURE__ */ jsx(
12759
12845
  Cell$1,
12760
12846
  __spreadProps(__spreadValues({
@@ -12779,7 +12865,7 @@ const DEFAULT_NUM_ROWS = 15;
12779
12865
  const HEADER_HEIGHT = 52;
12780
12866
  const DEFAULT_TABLE_HEIGHT = DEFAULT_ROW_HEIGHT * DEFAULT_NUM_ROWS + HEADER_HEIGHT - 2;
12781
12867
  const CSS_PREFIX = "Layer__UI__VirtualizedTable";
12782
- const EMPTY_ARRAY$3 = [];
12868
+ const EMPTY_ARRAY$2 = [];
12783
12869
  const VirtualizedDataTable = ({
12784
12870
  columnConfig,
12785
12871
  data,
@@ -12804,7 +12890,7 @@ const VirtualizedDataTable = ({
12804
12890
  }, [data, height, rowHeight, shrinkHeightToFitRows]);
12805
12891
  const columnHelper = createColumnHelper();
12806
12892
  const columns = Object.values(columnConfig);
12807
- const tableData = data != null ? data : EMPTY_ARRAY$3;
12893
+ const tableData = data != null ? data : EMPTY_ARRAY$2;
12808
12894
  const columnDefs = columns.map((col) => {
12809
12895
  return columnHelper.display({
12810
12896
  id: col.id,
@@ -13095,7 +13181,7 @@ const useSaveBankTransactionRow = () => {
13095
13181
  return;
13096
13182
  }
13097
13183
  if (isSuggestedMatchAsOption(selectedCategory)) {
13098
- return matchBankTransaction2(bankTransaction.id, selectedCategory.original.id);
13184
+ return matchBankTransaction2(bankTransaction, selectedCategory.original.id);
13099
13185
  }
13100
13186
  if (isSplitAsOption(selectedCategory)) {
13101
13187
  const splitCategorizationRequest = buildCategorizeBankTransactionPayloadForSplit(selectedCategory.original);
@@ -13131,8 +13217,8 @@ function useDelayedVisibility({
13131
13217
  );
13132
13218
  return { isVisible };
13133
13219
  }
13134
- const File = (_xb) => {
13135
- var _yb = _xb, { size = 12 } = _yb, props = __objRest(_yb, ["size"]);
13220
+ const File = (_Bb) => {
13221
+ var _Cb = _Bb, { size = 12 } = _Cb, props = __objRest(_Cb, ["size"]);
13136
13222
  return /* @__PURE__ */ jsxs(
13137
13223
  "svg",
13138
13224
  __spreadProps(__spreadValues({
@@ -13215,14 +13301,14 @@ const variants = {
13215
13301
  }
13216
13302
  }
13217
13303
  };
13218
- const AnimatedPresenceDiv = (_zb) => {
13219
- var _Ab = _zb, {
13304
+ const AnimatedPresenceDiv = (_Db) => {
13305
+ var _Eb = _Db, {
13220
13306
  children,
13221
13307
  variant,
13222
13308
  isOpen,
13223
13309
  slotProps = { AnimatePresence: { initial: false } },
13224
13310
  key
13225
- } = _Ab, props = __objRest(_Ab, [
13311
+ } = _Eb, props = __objRest(_Eb, [
13226
13312
  "children",
13227
13313
  "variant",
13228
13314
  "isOpen",
@@ -13297,7 +13383,7 @@ const getBookkeepingPeriods = get(({ businessId }) => {
13297
13383
  return `/v1/businesses/${businessId}/bookkeeping/periods`;
13298
13384
  });
13299
13385
  const BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
13300
- function buildKey$J({
13386
+ function buildKey$N({
13301
13387
  access_token: accessToken,
13302
13388
  apiUrl,
13303
13389
  businessId,
@@ -13318,7 +13404,7 @@ function useBookkeepingPeriods() {
13318
13404
  const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
13319
13405
  const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
13320
13406
  const swrResponse = useSWR(
13321
- () => buildKey$J(__spreadProps(__spreadValues({}, auth), {
13407
+ () => buildKey$N(__spreadProps(__spreadValues({}, auth), {
13322
13408
  businessId,
13323
13409
  isActiveOrPaused
13324
13410
  })),
@@ -13342,8 +13428,8 @@ function useBookkeepingPeriods() {
13342
13428
  }
13343
13429
  });
13344
13430
  }
13345
- const Clock = (_Bb) => {
13346
- var _Cb = _Bb, { size = 18 } = _Cb, props = __objRest(_Cb, ["size"]);
13431
+ const Clock = (_Fb) => {
13432
+ var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
13347
13433
  return /* @__PURE__ */ jsxs(
13348
13434
  "svg",
13349
13435
  __spreadProps(__spreadValues({
@@ -13669,8 +13755,8 @@ const useSplitsForm = ({
13669
13755
  saveLocalSplitsToCategoryStore
13670
13756
  };
13671
13757
  };
13672
- const ScissorsFullOpen = (_Db) => {
13673
- var _Eb = _Db, { size = 12 } = _Eb, props = __objRest(_Eb, ["size"]);
13758
+ const ScissorsFullOpen = (_Hb) => {
13759
+ var _Ib = _Hb, { size = 12 } = _Ib, props = __objRest(_Ib, ["size"]);
13674
13760
  return /* @__PURE__ */ jsx(
13675
13761
  "svg",
13676
13762
  __spreadProps(__spreadValues({
@@ -13735,8 +13821,8 @@ const ScissorsFullOpen = (_Db) => {
13735
13821
  })
13736
13822
  );
13737
13823
  };
13738
- const Trash = (_Fb) => {
13739
- var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
13824
+ const Trash = (_Jb) => {
13825
+ var _Kb = _Jb, { size = 18 } = _Kb, props = __objRest(_Kb, ["size"]);
13740
13826
  return /* @__PURE__ */ jsxs(
13741
13827
  "svg",
13742
13828
  __spreadProps(__spreadValues({
@@ -13798,7 +13884,7 @@ const useReceipts = ({
13798
13884
  const { businessId } = useLayerContext();
13799
13885
  const { apiUrl } = useEnvironment();
13800
13886
  const { data: auth } = useAuth();
13801
- const { updateOneLocal: updateBankTransaction } = useBankTransactionsContext();
13887
+ const { updateLocalBankTransactions } = useBankTransactionsContext();
13802
13888
  const [receiptUrls, setReceiptUrls] = useState([]);
13803
13889
  useEffect(() => {
13804
13890
  if (isActive && receiptUrls.length === 0 && hasReceipts(bankTransaction)) {
@@ -13854,10 +13940,10 @@ const useReceipts = ({
13854
13940
  documentType: "RECEIPT"
13855
13941
  });
13856
13942
  yield fetchDocuments();
13857
- if (updateBankTransaction && ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.id) && (bankTransaction == null ? void 0 : bankTransaction.document_ids) && bankTransaction.document_ids.length === 0) {
13858
- updateBankTransaction(__spreadProps(__spreadValues({}, bankTransaction), {
13943
+ if (((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.id) && (bankTransaction == null ? void 0 : bankTransaction.document_ids) && bankTransaction.document_ids.length === 0) {
13944
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, bankTransaction), {
13859
13945
  document_ids: [result.data.id]
13860
- }));
13946
+ })]);
13861
13947
  }
13862
13948
  } catch (_err) {
13863
13949
  const newReceiptUrls = receipts.map((url) => {
@@ -13931,8 +14017,8 @@ const ReceiptsProvider = ({
13931
14017
  const contextData = useReceipts({ bankTransaction, isActive });
13932
14018
  return /* @__PURE__ */ jsx(ReceiptsContext.Provider, { value: contextData, children });
13933
14019
  };
13934
- const Eye = (_Hb) => {
13935
- var _Ib = _Hb, { size = 18 } = _Ib, props = __objRest(_Ib, ["size"]);
14020
+ const Eye = (_Lb) => {
14021
+ var _Mb = _Lb, { size = 18 } = _Mb, props = __objRest(_Mb, ["size"]);
13936
14022
  return /* @__PURE__ */ jsx(
13937
14023
  "svg",
13938
14024
  __spreadProps(__spreadValues({
@@ -14068,11 +14154,11 @@ const FileThumb = ({
14068
14154
  }
14069
14155
  );
14070
14156
  };
14071
- const TextButton = (_Jb) => {
14072
- var _Kb = _Jb, {
14157
+ const TextButton = (_Nb) => {
14158
+ var _Ob = _Nb, {
14073
14159
  className,
14074
14160
  children
14075
- } = _Kb, props = __objRest(_Kb, [
14161
+ } = _Ob, props = __objRest(_Ob, [
14076
14162
  "className",
14077
14163
  "children"
14078
14164
  ]);
@@ -14156,8 +14242,8 @@ const openReceiptInNewTab = (url, index) => (e) => {
14156
14242
  `);
14157
14243
  }
14158
14244
  };
14159
- const BankTransactionReceiptsWithProvider = forwardRef((_Lb, ref) => {
14160
- var _Mb = _Lb, { bankTransaction, isActive } = _Mb, props = __objRest(_Mb, ["bankTransaction", "isActive"]);
14245
+ const BankTransactionReceiptsWithProvider = forwardRef((_Pb, ref) => {
14246
+ var _Qb = _Pb, { bankTransaction, isActive } = _Qb, props = __objRest(_Qb, ["bankTransaction", "isActive"]);
14161
14247
  return /* @__PURE__ */ jsx(ReceiptsProvider, { bankTransaction, isActive, children: /* @__PURE__ */ jsx(BankTransactionReceipts, __spreadProps(__spreadValues({}, props), { ref })) });
14162
14248
  });
14163
14249
  BankTransactionReceiptsWithProvider.displayName = "BankTransactionReceiptsWithProvider";
@@ -14324,8 +14410,8 @@ const transformCurrencyValue = (rawValue) => {
14324
14410
  }
14325
14411
  return cleaned;
14326
14412
  };
14327
- const AmountInput = (_Nb) => {
14328
- var _Ob = _Nb, {
14413
+ const AmountInput = (_Rb) => {
14414
+ var _Sb = _Rb, {
14329
14415
  onChange,
14330
14416
  className,
14331
14417
  leftText,
@@ -14333,7 +14419,7 @@ const AmountInput = (_Nb) => {
14333
14419
  isInvalid,
14334
14420
  badge,
14335
14421
  placeholder = "$0.00"
14336
- } = _Ob, props = __objRest(_Ob, [
14422
+ } = _Sb, props = __objRest(_Sb, [
14337
14423
  "onChange",
14338
14424
  "className",
14339
14425
  "leftText",
@@ -14653,7 +14739,7 @@ const ToggleOption = ({
14653
14739
  ] });
14654
14740
  };
14655
14741
  const GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
14656
- function buildKey$I({
14742
+ function buildKey$M({
14657
14743
  access_token: accessToken,
14658
14744
  apiUrl,
14659
14745
  businessId,
@@ -14673,7 +14759,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
14673
14759
  const { data: auth } = useAuth();
14674
14760
  const { businessId } = useLayerContext();
14675
14761
  return useSWR(
14676
- () => buildKey$I(__spreadProps(__spreadValues({}, auth), {
14762
+ () => buildKey$M(__spreadProps(__spreadValues({}, auth), {
14677
14763
  businessId,
14678
14764
  bankTransactionId
14679
14765
  })),
@@ -14703,7 +14789,7 @@ class UpdateBankTransactionMetadataSWRResponse {
14703
14789
  return this.swrResponse.error !== void 0;
14704
14790
  }
14705
14791
  }
14706
- function buildKey$H({
14792
+ function buildKey$L({
14707
14793
  access_token: accessToken,
14708
14794
  apiUrl,
14709
14795
  businessId,
@@ -14724,7 +14810,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
14724
14810
  const { businessId } = useLayerContext();
14725
14811
  const { mutate } = useSWRConfig();
14726
14812
  const rawMutationResponse = useSWRMutation(
14727
- () => buildKey$H({
14813
+ () => buildKey$L({
14728
14814
  access_token: auth == null ? void 0 : auth.access_token,
14729
14815
  apiUrl: auth == null ? void 0 : auth.apiUrl,
14730
14816
  businessId,
@@ -14807,12 +14893,12 @@ const useBankTransactionMemo = ({ bankTransactionId }) => {
14807
14893
  isSaved
14808
14894
  }), [form, isErrorUpdatingMemo, isUpdatingMemo, isSaved]);
14809
14895
  };
14810
- const Textarea = (_Pb) => {
14811
- var _Qb = _Pb, {
14896
+ const Textarea = (_Tb) => {
14897
+ var _Ub = _Tb, {
14812
14898
  className,
14813
14899
  isInvalid,
14814
14900
  errorMessage
14815
- } = _Qb, props = __objRest(_Qb, [
14901
+ } = _Ub, props = __objRest(_Ub, [
14816
14902
  "className",
14817
14903
  "isInvalid",
14818
14904
  "errorMessage"
@@ -14905,7 +14991,7 @@ function useMinMutatingMutation({
14905
14991
  });
14906
14992
  }
14907
14993
  const SET_METADATA_ON_BANK_TRANSACTION_TAG_KEY = "#set-metadata-on-bank-transaction";
14908
- function buildKey$G({
14994
+ function buildKey$K({
14909
14995
  access_token: accessToken,
14910
14996
  apiUrl,
14911
14997
  businessId,
@@ -14931,7 +15017,7 @@ function useSetMetadataOnBankTransaction({
14931
15017
  const { data } = useAuth();
14932
15018
  const { businessId } = useLayerContext();
14933
15019
  const mutationResponse = useSWRMutation(
14934
- () => buildKey$G(__spreadProps(__spreadValues({}, data), {
15020
+ () => buildKey$K(__spreadProps(__spreadValues({}, data), {
14935
15021
  businessId,
14936
15022
  bankTransactionId
14937
15023
  })),
@@ -15514,7 +15600,7 @@ function BankTransactionCustomerVendorVisibilityProvider({
15514
15600
  }
15515
15601
  const REMOVE_TAG_FROM_BANK_TRANSACTION_TAG_KEY = "#remove-tag-from-bank-transaction";
15516
15602
  const removeTagFromBankTransaction = del(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
15517
- function buildKey$F({
15603
+ function buildKey$J({
15518
15604
  access_token: accessToken,
15519
15605
  apiUrl,
15520
15606
  businessId,
@@ -15534,7 +15620,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
15534
15620
  const { data } = useAuth();
15535
15621
  const { businessId } = useLayerContext();
15536
15622
  const mutationResponse = useSWRMutation(
15537
- () => buildKey$F(__spreadProps(__spreadValues({}, data), {
15623
+ () => buildKey$J(__spreadProps(__spreadValues({}, data), {
15538
15624
  businessId,
15539
15625
  bankTransactionId
15540
15626
  })),
@@ -15593,7 +15679,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
15593
15679
  }
15594
15680
  const TAG_BANK_TRANSACTION_TAG_KEY = "#tag-bank-transaction";
15595
15681
  const tagBankTransaction = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
15596
- function buildKey$E({
15682
+ function buildKey$I({
15597
15683
  access_token: accessToken,
15598
15684
  apiUrl,
15599
15685
  businessId,
@@ -15613,7 +15699,7 @@ function useTagBankTransaction({ bankTransactionId }) {
15613
15699
  const { data } = useAuth();
15614
15700
  const { businessId } = useLayerContext();
15615
15701
  const mutationResponse = useSWRMutation(
15616
- () => buildKey$E(__spreadProps(__spreadValues({}, data), {
15702
+ () => buildKey$I(__spreadProps(__spreadValues({}, data), {
15617
15703
  businessId,
15618
15704
  bankTransactionId
15619
15705
  })),
@@ -15728,7 +15814,7 @@ const FallbackWithSkeletonLoader = ({
15728
15814
  return children;
15729
15815
  };
15730
15816
  const TAG_DIMENSION_BY_KEY_TAG_KEY = "#tag-dimension-by-key";
15731
- function buildKey$D({
15817
+ function buildKey$H({
15732
15818
  access_token: accessToken,
15733
15819
  apiUrl,
15734
15820
  businessId,
@@ -15772,7 +15858,7 @@ function useTagDimensionByKey({ isEnabled = true, dimensionKey }) {
15772
15858
  const { apiUrl } = useEnvironment();
15773
15859
  const { businessId } = useLayerContext();
15774
15860
  const swrResponse = useSWR(
15775
- () => buildKey$D(__spreadProps(__spreadValues({}, auth), {
15861
+ () => buildKey$H(__spreadProps(__spreadValues({}, auth), {
15776
15862
  apiUrl,
15777
15863
  isEnabled,
15778
15864
  businessId,
@@ -16115,7 +16201,7 @@ const ExpandedBankTransactionRow = forwardRef(
16115
16201
  if (!foundMatch) {
16116
16202
  return;
16117
16203
  }
16118
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id);
16204
+ yield matchBankTransaction2(bankTransaction, foundMatch.id);
16119
16205
  deselect(bankTransaction.id);
16120
16206
  close2();
16121
16207
  });
@@ -16395,7 +16481,8 @@ const BankTransactionRow = ({
16395
16481
  const { setTransactionCategory } = useBankTransactionsCategoryActions();
16396
16482
  const { selectedCategory } = useGetBankTransactionCategory(bankTransaction.id);
16397
16483
  const { saveBankTransactionRow } = useSaveBankTransactionRow();
16398
- const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
16484
+ const isBeingRemoved = bankTransaction.recently_categorized && shouldHideAfterCategorize();
16485
+ const displayAsCategorized = isBeingRemoved ? false : categorized;
16399
16486
  useEffect(() => {
16400
16487
  if (bankTransaction.error) {
16401
16488
  setShowRetry(true);
@@ -16429,7 +16516,7 @@ const BankTransactionRow = ({
16429
16516
  const openClassName = open ? `${className}--expanded` : "";
16430
16517
  const rowClassName = classNames(
16431
16518
  className,
16432
- bankTransaction.recently_categorized && editable && shouldHideAfterCategorize() ? "Layer__bank-transaction-row--removing" : "",
16519
+ isBeingRemoved && editable ? "Layer__bank-transaction-row--removing" : "",
16433
16520
  open ? openClassName : "",
16434
16521
  initialLoad ? "initial-load" : "",
16435
16522
  isVisible ? "show" : ""
@@ -16602,7 +16689,7 @@ const BankTransactionRow = ({
16602
16689
  children: "Retry"
16603
16690
  }
16604
16691
  ),
16605
- !displayAsCategorized && categorizationEnabled && !showRetry && /* @__PURE__ */ jsx(
16692
+ !displayAsCategorized && categorizationEnabled && !showRetry && !isBeingRemoved && /* @__PURE__ */ jsx(
16606
16693
  SubmitButton,
16607
16694
  {
16608
16695
  onClick: () => {
@@ -16618,8 +16705,8 @@ const BankTransactionRow = ({
16618
16705
  children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
16619
16706
  }
16620
16707
  ),
16621
- !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16622
- /* @__PURE__ */ jsx(
16708
+ !categorizationEnabled && !displayAsCategorized && !isBeingRemoved && /* @__PURE__ */ jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16709
+ !isBeingRemoved && /* @__PURE__ */ jsx(
16623
16710
  IconButton,
16624
16711
  {
16625
16712
  onClick: toggleOpen,
@@ -16956,26 +17043,6 @@ const BankTransactionsList = ({
16956
17043
  ) })
16957
17044
  ] });
16958
17045
  };
16959
- const SWITCH_CLASS_NAME = "Layer__Switch";
16960
- const Switch = forwardRef((_Rb, ref) => {
16961
- var _Sb = _Rb, {
16962
- children
16963
- } = _Sb, props = __objRest(_Sb, [
16964
- "children"
16965
- ]);
16966
- return /* @__PURE__ */ jsx(
16967
- Switch$1,
16968
- __spreadProps(__spreadValues({}, props), {
16969
- className: SWITCH_CLASS_NAME,
16970
- ref,
16971
- children: withRenderProp(children, (node) => /* @__PURE__ */ jsxs(Fragment, { children: [
16972
- /* @__PURE__ */ jsx("div", { slot: "indicator" }),
16973
- node
16974
- ] }))
16975
- })
16976
- );
16977
- });
16978
- Switch.displayName = "Switch";
16979
17046
  const BankTransactionsMobileBulkActionsHeader = ({
16980
17047
  bankTransactions,
16981
17048
  bulkActionsEnabled,
@@ -17099,8 +17166,8 @@ const BankTransactionsMobileListItemCheckbox = ({
17099
17166
  }
17100
17167
  ) });
17101
17168
  };
17102
- const Paperclip = (_Tb) => {
17103
- var _Ub = _Tb, { size = 20 } = _Ub, props = __objRest(_Ub, ["size"]);
17169
+ const Paperclip = (_Vb) => {
17170
+ var _Wb = _Vb, { size = 20 } = _Wb, props = __objRest(_Wb, ["size"]);
17104
17171
  return /* @__PURE__ */ jsx(
17105
17172
  "svg",
17106
17173
  __spreadProps(__spreadValues({
@@ -17548,7 +17615,7 @@ const BankTransactionsMobileListMatchForm = ({
17548
17615
  if (!foundMatch) {
17549
17616
  return;
17550
17617
  }
17551
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id, true);
17618
+ yield matchBankTransaction2(bankTransaction, foundMatch.id, true);
17552
17619
  });
17553
17620
  const save = () => {
17554
17621
  var _a2;
@@ -18357,8 +18424,8 @@ const BankTransactionsTable = ({
18357
18424
  }
18358
18425
  );
18359
18426
  };
18360
- const BackArrow = (_Vb) => {
18361
- var _Wb = _Vb, { size = 18 } = _Wb, props = __objRest(_Wb, ["size"]);
18427
+ const BackArrow = (_Xb) => {
18428
+ var _Yb = _Xb, { size = 18 } = _Yb, props = __objRest(_Yb, ["size"]);
18362
18429
  return /* @__PURE__ */ jsx(
18363
18430
  "svg",
18364
18431
  __spreadProps(__spreadValues({
@@ -18391,7 +18458,7 @@ const BaseDetailView = ({ name, onGoBack, slots, children, borderless = false })
18391
18458
  ] });
18392
18459
  };
18393
18460
  const ARCHIVE_CATEGORIZATION_RULE_TAG = "#archive-categorization-rule";
18394
- function buildKey$C({
18461
+ function buildKey$G({
18395
18462
  access_token: accessToken,
18396
18463
  apiUrl,
18397
18464
  businessId
@@ -18416,7 +18483,7 @@ function useArchiveCategorizationRule() {
18416
18483
  const { businessId } = useLayerContext();
18417
18484
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
18418
18485
  const mutationResponse = useSWRMutation(
18419
- () => buildKey$C({
18486
+ () => buildKey$G({
18420
18487
  access_token: auth == null ? void 0 : auth.access_token,
18421
18488
  apiUrl: auth == null ? void 0 : auth.apiUrl,
18422
18489
  businessId
@@ -18526,8 +18593,8 @@ const usePaginationRange = ({
18526
18593
  }, [totalCount, pageSize, siblingCount, currentPage]);
18527
18594
  return paginationRange;
18528
18595
  };
18529
- const ChevronLeft = (_Xb) => {
18530
- var props = __objRest(_Xb, []);
18596
+ const ChevronLeft = (_Zb) => {
18597
+ var props = __objRest(_Zb, []);
18531
18598
  return /* @__PURE__ */ jsx(
18532
18599
  "svg",
18533
18600
  __spreadProps(__spreadValues({
@@ -18549,8 +18616,8 @@ const ChevronLeft = (_Xb) => {
18549
18616
  })
18550
18617
  );
18551
18618
  };
18552
- const PaginationButton = (_Yb) => {
18553
- var _Zb = _Yb, { children, isSelected } = _Zb, buttonProps = __objRest(_Zb, ["children", "isSelected"]);
18619
+ const PaginationButton = (__b) => {
18620
+ var _$b = __b, { children, isSelected } = _$b, buttonProps = __objRest(_$b, ["children", "isSelected"]);
18554
18621
  return /* @__PURE__ */ jsx(
18555
18622
  Button,
18556
18623
  __spreadProps(__spreadValues({
@@ -18632,7 +18699,6 @@ const Pagination = ({
18632
18699
  ) }, "page-next")
18633
18700
  ] }) }) });
18634
18701
  };
18635
- const EMPTY_ARRAY$2 = [];
18636
18702
  function PaginatedTable({
18637
18703
  data,
18638
18704
  isLoading,
@@ -18643,7 +18709,8 @@ function PaginatedTable({
18643
18709
  paginationProps,
18644
18710
  slots
18645
18711
  }) {
18646
- const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage } = paginationProps;
18712
+ var _a;
18713
+ const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
18647
18714
  const [pagination, setPagination] = useState({ pageIndex: initialPage, pageSize });
18648
18715
  const columnHelper = createColumnHelper();
18649
18716
  const columns = Object.values(columnConfig);
@@ -18655,7 +18722,7 @@ function PaginatedTable({
18655
18722
  });
18656
18723
  });
18657
18724
  const table2 = useReactTable({
18658
- data: data != null ? data : EMPTY_ARRAY$2,
18725
+ data: data != null ? data : [],
18659
18726
  columns: columnDefs,
18660
18727
  state: { pagination },
18661
18728
  onPaginationChange: (updaterOrValue) => {
@@ -18665,7 +18732,7 @@ function PaginatedTable({
18665
18732
  },
18666
18733
  getPaginationRowModel: getPaginationRowModel(),
18667
18734
  getCoreRowModel: getCoreRowModel(),
18668
- autoResetPageIndex: false
18735
+ autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
18669
18736
  });
18670
18737
  const { rows } = table2.getRowModel();
18671
18738
  const rowData = useMemo(() => rows.map((r) => r.original), [rows]);
@@ -18911,7 +18978,7 @@ const SuggestedCategorizationRuleUpdatesDrawer = ({
18911
18978
  ] }) });
18912
18979
  };
18913
18980
  const TAG_DIMENSIONS_TAG_KEY = "#tag-dimensions";
18914
- function buildKey$B({
18981
+ function buildKey$F({
18915
18982
  access_token: accessToken,
18916
18983
  apiUrl,
18917
18984
  businessId,
@@ -18954,7 +19021,7 @@ function useTagDimensions({ isEnabled = true } = {}) {
18954
19021
  const { apiUrl } = useEnvironment();
18955
19022
  const { businessId } = useLayerContext();
18956
19023
  const swrResponse = useSWR(
18957
- () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
19024
+ () => buildKey$F(__spreadProps(__spreadValues({}, auth), {
18958
19025
  apiUrl,
18959
19026
  businessId,
18960
19027
  isEnabled
@@ -18979,8 +19046,8 @@ function usePreloadTagDimensions(parameters) {
18979
19046
  useTagDimensions(parameters);
18980
19047
  }
18981
19048
  const COMPONENT_NAME$c = "bank-transactions";
18982
- const BankTransactions = (__b) => {
18983
- var _$b = __b, {
19049
+ const BankTransactions = (_ac) => {
19050
+ var _bc = _ac, {
18984
19051
  onError,
18985
19052
  showTags = false,
18986
19053
  showCustomerVendor = false,
@@ -18988,7 +19055,7 @@ const BankTransactions = (__b) => {
18988
19055
  applyGlobalDateRange = false,
18989
19056
  mode,
18990
19057
  renderInAppLink
18991
- } = _$b, props = __objRest(_$b, [
19058
+ } = _bc, props = __objRest(_bc, [
18992
19059
  "onError",
18993
19060
  "showTags",
18994
19061
  "showCustomerVendor",
@@ -19000,6 +19067,7 @@ const BankTransactions = (__b) => {
19000
19067
  usePreloadTagDimensions({ isEnabled: showTags });
19001
19068
  usePreloadCustomers({ isEnabled: showCustomerVendor });
19002
19069
  usePreloadVendors({ isEnabled: showCustomerVendor });
19070
+ usePreloadCategories();
19003
19071
  return /* @__PURE__ */ jsx(ErrorBoundary, { onError, children: /* @__PURE__ */ jsx(CategorizationRulesProvider, { children: /* @__PURE__ */ jsx(BankTransactionsRouteStoreProvider, { children: /* @__PURE__ */ jsx(
19004
19072
  BankTransactionsProvider,
19005
19073
  {
@@ -19146,7 +19214,7 @@ const BankTransactionsTableView = ({
19146
19214
  const [listView, setListView] = useState(false);
19147
19215
  const [containerWidth, setContainerWidth] = useState(0);
19148
19216
  const debounceContainerWidth = debounce(setContainerWidth, 500);
19149
- const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
19217
+ const removeTransaction = (bankTransaction) => removeAfterCategorize([bankTransaction.id]);
19150
19218
  const containerRef = useElementSize((_el, _en, size) => {
19151
19219
  if ((size == null ? void 0 : size.height) && (size == null ? void 0 : size.height) >= 90) {
19152
19220
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -19353,8 +19421,8 @@ function QuickbooksContextProvider({ children }) {
19353
19421
  const quickbooksContextData = useQuickbooks();
19354
19422
  return /* @__PURE__ */ jsx(QuickbooksContext.Provider, { value: quickbooksContextData, children });
19355
19423
  }
19356
- const Cog = (_ac) => {
19357
- var _bc = _ac, { size = 12 } = _bc, props = __objRest(_bc, ["size"]);
19424
+ const Cog = (_cc) => {
19425
+ var _dc = _cc, { size = 12 } = _dc, props = __objRest(_dc, ["size"]);
19358
19426
  const id = useId();
19359
19427
  return /* @__PURE__ */ jsxs(
19360
19428
  "svg",
@@ -19375,8 +19443,8 @@ const Cog = (_ac) => {
19375
19443
  })
19376
19444
  );
19377
19445
  };
19378
- const QuickbooksIcon = (_cc) => {
19379
- var _dc = _cc, { size = 24 } = _dc, props = __objRest(_dc, ["size"]);
19446
+ const QuickbooksIcon = (_ec) => {
19447
+ var _fc = _ec, { size = 24 } = _fc, props = __objRest(_fc, ["size"]);
19380
19448
  return /* @__PURE__ */ jsxs(
19381
19449
  "svg",
19382
19450
  __spreadProps(__spreadValues({
@@ -19535,8 +19603,8 @@ function IntegrationsQuickbooksUnlinkConfirmationModal({ isOpen, onOpenChange })
19535
19603
  }
19536
19604
  );
19537
19605
  }
19538
- const MoreVertical = (_ec) => {
19539
- var _fc = _ec, { size = 18 } = _fc, props = __objRest(_fc, ["size"]);
19606
+ const MoreVertical = (_gc) => {
19607
+ var _hc = _gc, { size = 18 } = _hc, props = __objRest(_hc, ["size"]);
19540
19608
  return /* @__PURE__ */ jsxs(
19541
19609
  "svg",
19542
19610
  __spreadProps(__spreadValues({
@@ -19765,8 +19833,8 @@ const IntegrationsComponent = ({
19765
19833
  (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ jsx(IntegrationsContent, {})
19766
19834
  ] });
19767
19835
  };
19768
- const PlusIcon = (_gc) => {
19769
- var _hc = _gc, { size = 14 } = _hc, props = __objRest(_hc, ["size"]);
19836
+ const PlusIcon = (_ic) => {
19837
+ var _jc = _ic, { size = 14 } = _jc, props = __objRest(_jc, ["size"]);
19770
19838
  return /* @__PURE__ */ jsxs(
19771
19839
  "svg",
19772
19840
  __spreadProps(__spreadValues({
@@ -19808,8 +19876,8 @@ const PlusIcon = (_gc) => {
19808
19876
  })
19809
19877
  );
19810
19878
  };
19811
- const InstitutionIcon = (_ic) => {
19812
- var _jc = _ic, { size = 18 } = _jc, props = __objRest(_jc, ["size"]);
19879
+ const InstitutionIcon = (_kc) => {
19880
+ var _lc = _kc, { size = 18 } = _lc, props = __objRest(_lc, ["size"]);
19813
19881
  return /* @__PURE__ */ jsxs(
19814
19882
  "svg",
19815
19883
  __spreadProps(__spreadValues({
@@ -20169,7 +20237,7 @@ function LinkedAccountToConfirm({
20169
20237
  ) })
20170
20238
  ] });
20171
20239
  }
20172
- function buildKey$A({
20240
+ function buildKey$E({
20173
20241
  access_token: accessToken,
20174
20242
  apiUrl,
20175
20243
  businessId
@@ -20227,7 +20295,7 @@ function useConfirmAndExcludeMultiple({ onSuccess }) {
20227
20295
  const { data: auth } = useAuth();
20228
20296
  const { businessId } = useLayerContext();
20229
20297
  return useSWRMutation(
20230
- () => buildKey$A({
20298
+ () => buildKey$E({
20231
20299
  access_token: auth == null ? void 0 : auth.access_token,
20232
20300
  apiUrl: auth == null ? void 0 : auth.apiUrl,
20233
20301
  businessId
@@ -20427,8 +20495,8 @@ const MenuItem = forwardRef(
20427
20495
  );
20428
20496
  const PILL_CLASS_NAME = "Layer__Pill";
20429
20497
  const Pill = forwardRef(
20430
- function Pill2(_kc, ref) {
20431
- var _lc = _kc, { children, status } = _lc, restProps = __objRest(_lc, ["children", "status"]);
20498
+ function Pill2(_mc, ref) {
20499
+ var _nc = _mc, { children, status } = _nc, restProps = __objRest(_nc, ["children", "status"]);
20432
20500
  const dataProperties = toDataProperties({ status });
20433
20501
  return /* @__PURE__ */ jsx(
20434
20502
  Button$2,
@@ -20791,8 +20859,8 @@ const LinkedAccountsContent = ({
20791
20859
  };
20792
20860
  const CALENDAR_CLASS_NAME = "Layer__UI__Calendar";
20793
20861
  const Calendar = forwardRef(
20794
- function Calendar2(_mc, ref) {
20795
- var _nc = _mc, { className, isReadOnly } = _nc, restProps = __objRest(_nc, ["className", "isReadOnly"]);
20862
+ function Calendar2(_oc, ref) {
20863
+ var _pc = _oc, { className, isReadOnly } = _pc, restProps = __objRest(_pc, ["className", "isReadOnly"]);
20796
20864
  const dataProperties = toDataProperties({ readonly: isReadOnly });
20797
20865
  return /* @__PURE__ */ jsx(
20798
20866
  Calendar$1,
@@ -20806,8 +20874,8 @@ const Calendar = forwardRef(
20806
20874
  );
20807
20875
  const CALENDAR_GRID_CLASS_NAME = "Layer__UI__CalendarGrid";
20808
20876
  const CalendarGrid = forwardRef(
20809
- function CalendarGrid2(_oc, ref) {
20810
- var _pc = _oc, { className } = _pc, restProps = __objRest(_pc, ["className"]);
20877
+ function CalendarGrid2(_qc, ref) {
20878
+ var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
20811
20879
  return /* @__PURE__ */ jsx(
20812
20880
  CalendarGrid$1,
20813
20881
  __spreadProps(__spreadValues({}, restProps), {
@@ -20819,8 +20887,8 @@ const CalendarGrid = forwardRef(
20819
20887
  );
20820
20888
  const CALENDAR_GRID_BODY_CLASS_NAME = "Layer__UI__CalendarGridBody";
20821
20889
  const CalendarGridBody = forwardRef(
20822
- function CalendarGridBody2(_qc, ref) {
20823
- var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
20890
+ function CalendarGridBody2(_sc, ref) {
20891
+ var _tc = _sc, { className } = _tc, restProps = __objRest(_tc, ["className"]);
20824
20892
  return /* @__PURE__ */ jsx(
20825
20893
  CalendarGridBody$1,
20826
20894
  __spreadProps(__spreadValues({}, restProps), {
@@ -20832,8 +20900,8 @@ const CalendarGridBody = forwardRef(
20832
20900
  );
20833
20901
  const CALENDAR_CELL_CLASS_NAME = "Layer__UI__CalendarCell";
20834
20902
  const CalendarCell = forwardRef(
20835
- function CalendarCell2(_sc, ref) {
20836
- var _tc = _sc, { className, size = "sm" } = _tc, restProps = __objRest(_tc, ["className", "size"]);
20903
+ function CalendarCell2(_uc, ref) {
20904
+ var _vc = _uc, { className, size = "sm" } = _vc, restProps = __objRest(_vc, ["className", "size"]);
20837
20905
  const dataProperties = toDataProperties({ size });
20838
20906
  return /* @__PURE__ */ jsx(
20839
20907
  CalendarCell$1,
@@ -20846,8 +20914,8 @@ const CalendarCell = forwardRef(
20846
20914
  );
20847
20915
  const CALENDAR_GRID_HEADER_CLASS_NAME = "Layer__UI__CalendarGridHeader";
20848
20916
  const CalendarGridHeader = forwardRef(
20849
- function CalendarGridHeader2(_uc, ref) {
20850
- var _vc = _uc, { className } = _vc, restProps = __objRest(_vc, ["className"]);
20917
+ function CalendarGridHeader2(_wc, ref) {
20918
+ var _xc = _wc, { className } = _xc, restProps = __objRest(_xc, ["className"]);
20851
20919
  return /* @__PURE__ */ jsx(
20852
20920
  CalendarGridHeader$1,
20853
20921
  __spreadProps(__spreadValues({}, restProps), {
@@ -20859,8 +20927,8 @@ const CalendarGridHeader = forwardRef(
20859
20927
  );
20860
20928
  const CALENDAR_HEADER_CELL_CLASS_NAME = "Layer__UI__CalendarHeaderCell";
20861
20929
  const CalendarHeaderCell = forwardRef(
20862
- function CalendarHeaderCell2(_wc, ref) {
20863
- var _xc = _wc, { className, size = "sm" } = _xc, restProps = __objRest(_xc, ["className", "size"]);
20930
+ function CalendarHeaderCell2(_yc, ref) {
20931
+ var _zc = _yc, { className, size = "sm" } = _zc, restProps = __objRest(_zc, ["className", "size"]);
20864
20932
  const dataProperties = toDataProperties({ size });
20865
20933
  return /* @__PURE__ */ jsx(
20866
20934
  CalendarHeaderCell$1,
@@ -21102,7 +21170,7 @@ const AccountFormBox = ({
21102
21170
  /* @__PURE__ */ jsx("div", { className: `${CLASS_NAME$3}__success-banner`, children: /* @__PURE__ */ jsx(CheckCircle, { size: 36 }) })
21103
21171
  ] }));
21104
21172
  };
21105
- function buildKey$z({
21173
+ function buildKey$D({
21106
21174
  access_token: accessToken,
21107
21175
  apiUrl,
21108
21176
  businessId,
@@ -21158,7 +21226,7 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
21158
21226
  return errors;
21159
21227
  };
21160
21228
  return useSWRMutation(
21161
- () => buildKey$z({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
21229
+ () => buildKey$D({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
21162
21230
  ({ accessToken, apiUrl, businessId: businessId2, data: data2 }) => Promise.allSettled(
21163
21231
  data2.map(
21164
21232
  ({ accountId, openingDate, openingBalance, isDateInvalid }) => {
@@ -21430,6 +21498,33 @@ const applyShare = (items, total) => {
21430
21498
  });
21431
21499
  });
21432
21500
  };
21501
+ const createPnlLineItemComparator = (filters) => {
21502
+ return (a, b) => {
21503
+ switch (filters == null ? void 0 : filters.sortBy) {
21504
+ case "category":
21505
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21506
+ return a.displayName.localeCompare(b.displayName);
21507
+ }
21508
+ return b.displayName.localeCompare(a.displayName);
21509
+ case "type":
21510
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21511
+ return a.type.localeCompare(b.type);
21512
+ }
21513
+ return b.type.localeCompare(a.type);
21514
+ default:
21515
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21516
+ return a.value - b.value;
21517
+ }
21518
+ return b.value - a.value;
21519
+ }
21520
+ };
21521
+ };
21522
+ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
21523
+ const sorted = items.sort(createPnlLineItemComparator(filter));
21524
+ const total = sorted.reduce((x, { value }) => x + value, 0);
21525
+ const withShare = applyShare(sorted, total);
21526
+ return { items: withShare, total };
21527
+ };
21433
21528
  const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21434
21529
  var _a;
21435
21530
  const [displayMode, setDisplayMode] = useState("month");
@@ -21455,85 +21550,20 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21455
21550
  })
21456
21551
  }));
21457
21552
  };
21458
- const setFilterTypes = (scope, types) => {
21459
- setFilters(__spreadProps(__spreadValues({}, filters), {
21460
- [scope]: __spreadProps(__spreadValues({}, filters[scope]), {
21461
- types
21462
- })
21463
- }));
21464
- };
21465
21553
  const { filteredDataRevenue, filteredTotalRevenue } = useMemo(() => {
21466
- var _a2;
21467
21554
  if (!data) {
21468
21555
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
21469
21556
  }
21470
21557
  const items = collectRevenueItems(data);
21471
- const revenueTypeFilters = (_a2 = filters["revenue"]) == null ? void 0 : _a2.types;
21472
- const filtered = items.map((x) => {
21473
- if (revenueTypeFilters && revenueTypeFilters.length > 0 && !revenueTypeFilters.includes(x.type)) {
21474
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
21475
- }
21476
- return x;
21477
- });
21478
- const sorted = filtered.sort((a, b) => {
21479
- var _a3, _b, _c, _d;
21480
- switch ((_a3 = filters["revenue"]) == null ? void 0 : _a3.sortBy) {
21481
- case "category":
21482
- if (((_b = filters["revenue"]) == null ? void 0 : _b.sortDirection) === "asc") {
21483
- return a.displayName.localeCompare(b.displayName);
21484
- }
21485
- return b.displayName.localeCompare(a.displayName);
21486
- case "type":
21487
- if (((_c = filters["revenue"]) == null ? void 0 : _c.sortDirection) === "asc") {
21488
- return a.type.localeCompare(b.type);
21489
- }
21490
- return b.type.localeCompare(a.type);
21491
- default:
21492
- if (((_d = filters["revenue"]) == null ? void 0 : _d.sortDirection) === "asc") {
21493
- return a.value - b.value;
21494
- }
21495
- return b.value - a.value;
21496
- }
21497
- });
21498
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
21499
- const withShare = applyShare(sorted, total);
21558
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["revenue"]);
21500
21559
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
21501
21560
  }, [data, filters]);
21502
21561
  const { filteredDataExpenses, filteredTotalExpenses } = useMemo(() => {
21503
- var _a2;
21504
21562
  if (!data) {
21505
21563
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
21506
21564
  }
21507
21565
  const items = collectExpensesItems(data);
21508
- const expenseTypeFilters = (_a2 = filters["expenses"]) == null ? void 0 : _a2.types;
21509
- const filtered = items.map((x) => {
21510
- if (expenseTypeFilters && expenseTypeFilters.length > 0 && !expenseTypeFilters.includes(x.type)) {
21511
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
21512
- }
21513
- return x;
21514
- });
21515
- const sorted = filtered.sort((a, b) => {
21516
- var _a3, _b, _c, _d;
21517
- switch ((_a3 = filters["expenses"]) == null ? void 0 : _a3.sortBy) {
21518
- case "category":
21519
- if (((_b = filters["expenses"]) == null ? void 0 : _b.sortDirection) === "asc") {
21520
- return a.displayName.localeCompare(b.displayName);
21521
- }
21522
- return b.displayName.localeCompare(a.displayName);
21523
- case "type":
21524
- if (((_c = filters["expenses"]) == null ? void 0 : _c.sortDirection) === "asc") {
21525
- return a.type.localeCompare(b.type);
21526
- }
21527
- return b.type.localeCompare(a.type);
21528
- default:
21529
- if (((_d = filters["expenses"]) == null ? void 0 : _d.sortDirection) === "asc") {
21530
- return a.value - b.value;
21531
- }
21532
- return b.value - a.value;
21533
- }
21534
- });
21535
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
21536
- const withShare = applyShare(sorted, total);
21566
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["expenses"]);
21537
21567
  return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
21538
21568
  }, [data, filters]);
21539
21569
  const refetch = useCallback(() => {
@@ -21553,7 +21583,6 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21553
21583
  setSidebarScope,
21554
21584
  sortBy,
21555
21585
  filters,
21556
- setFilterTypes,
21557
21586
  tagFilter,
21558
21587
  dateRange,
21559
21588
  selectedLineItem,
@@ -21738,8 +21767,6 @@ const ProfitAndLossContext = createContext({
21738
21767
  },
21739
21768
  sortBy: () => {
21740
21769
  },
21741
- setFilterTypes: () => {
21742
- },
21743
21770
  filters: {
21744
21771
  expenses: void 0,
21745
21772
  revenue: void 0
@@ -21757,7 +21784,7 @@ const isNotOnlyNoneTag = (compareOptions) => {
21757
21784
  compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
21758
21785
  );
21759
21786
  };
21760
- function buildKey$y({
21787
+ function buildKey$C({
21761
21788
  access_token: accessToken,
21762
21789
  apiUrl,
21763
21790
  businessId,
@@ -21815,7 +21842,7 @@ function useProfitAndLossComparison({
21815
21842
  const { data: auth } = useAuth();
21816
21843
  const periods = preparePeriodsBody(dateRange, comparePeriods, comparisonPeriodMode);
21817
21844
  const tagFilters = prepareFiltersBody(selectedCompareOptions);
21818
- const queryKey = buildKey$y(__spreadProps(__spreadValues({}, auth), {
21845
+ const queryKey = buildKey$C(__spreadProps(__spreadValues({}, auth), {
21819
21846
  businessId,
21820
21847
  periods,
21821
21848
  tagFilters,
@@ -21975,8 +22002,8 @@ const useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
21975
22002
  refetch
21976
22003
  };
21977
22004
  };
21978
- const BarChart2 = (_yc) => {
21979
- var _zc = _yc, { size = 12 } = _zc, props = __objRest(_zc, ["size"]);
22005
+ const BarChart2 = (_Ac) => {
22006
+ var _Bc = _Ac, { size = 12 } = _Bc, props = __objRest(_Bc, ["size"]);
21980
22007
  return /* @__PURE__ */ jsxs(
21981
22008
  "svg",
21982
22009
  __spreadProps(__spreadValues({
@@ -22766,11 +22793,11 @@ const ProfitAndLossChart = ({
22766
22793
  isSyncing && !hasNonZeroData ? /* @__PURE__ */ jsx(ChartStateCard, {}) : null
22767
22794
  ] });
22768
22795
  };
22769
- const BackButton = (_Ac) => {
22770
- var _Bc = _Ac, {
22796
+ const BackButton = (_Cc) => {
22797
+ var _Dc = _Cc, {
22771
22798
  className,
22772
22799
  textOnly = false
22773
- } = _Bc, props = __objRest(_Bc, [
22800
+ } = _Dc, props = __objRest(_Dc, [
22774
22801
  "className",
22775
22802
  "textOnly"
22776
22803
  ]);
@@ -22818,8 +22845,8 @@ const TASKS_CHARTS_COLORS = {
22818
22845
  done: "#3B9C63",
22819
22846
  pending: "#DFA000"
22820
22847
  };
22821
- const SortArrows = (_Cc) => {
22822
- var _Dc = _Cc, { size = 13 } = _Dc, props = __objRest(_Dc, ["size"]);
22848
+ const SortArrows = (_Ec) => {
22849
+ var _Fc = _Ec, { size = 13 } = _Fc, props = __objRest(_Fc, ["size"]);
22823
22850
  return /* @__PURE__ */ jsxs(
22824
22851
  "svg",
22825
22852
  __spreadProps(__spreadValues({
@@ -22886,39 +22913,12 @@ const SortArrows = (_Cc) => {
22886
22913
  );
22887
22914
  };
22888
22915
  const UNCATEGORIZED_TYPES = ["UNCATEGORIZED_INFLOWS", "UNCATEGORIZED_OUTFLOWS"];
22889
- const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
22890
- const typeToColor = {};
22891
- const typeToLastOpacity = {};
22892
- let colorIndex = 0;
22893
- return data.map((obj) => {
22894
- var _a;
22895
- const type = (_a = obj.name) != null ? _a : obj.type;
22896
- if (type === "Uncategorized") {
22897
- return {
22898
- color: "#EEEEF0",
22899
- opacity: 1
22900
- };
22901
- }
22902
- if (!typeToColor[type]) {
22903
- typeToColor[type] = colorList[colorIndex % colorList.length];
22904
- colorIndex++;
22905
- typeToLastOpacity[type] = 1;
22906
- } else {
22907
- typeToLastOpacity[type] -= 0.1;
22908
- }
22909
- const opacity = typeToLastOpacity[type];
22910
- return {
22911
- color: typeToColor[type],
22912
- opacity
22913
- };
22914
- });
22915
- };
22916
22916
  const ValueIcon = ({
22917
22917
  item,
22918
22918
  typeColorMapping,
22919
22919
  idx
22920
22920
  }) => {
22921
- if (item.type === "Uncategorized") {
22921
+ if (isLineItemUncategorized(item)) {
22922
22922
  return /* @__PURE__ */ jsxs(
22923
22923
  "svg",
22924
22924
  {
@@ -22985,7 +22985,7 @@ const DetailedTable = ({
22985
22985
  );
22986
22986
  };
22987
22987
  const typeColorMapping = mapTypesToColors(filteredData, chartColorsList);
22988
- const positiveTotal = filteredData.filter((x) => !x.isHidden && x.value > 0).reduce((sum, x) => sum + x.value, 0);
22988
+ const positiveTotal = filteredData.filter((x) => x.value > 0).reduce((sum, x) => sum + x.value, 0);
22989
22989
  return /* @__PURE__ */ jsx("div", { className: "details-container", children: /* @__PURE__ */ jsx("div", { className: "table", children: /* @__PURE__ */ jsxs("table", { children: [
22990
22990
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
22991
22991
  /* @__PURE__ */ jsxs(
@@ -23026,16 +23026,16 @@ const DetailedTable = ({
23026
23026
  }
23027
23027
  )
23028
23028
  ] }) }),
23029
- /* @__PURE__ */ jsx("tbody", { children: filteredData.filter((x) => !x.isHidden).map((item, idx) => {
23029
+ /* @__PURE__ */ jsx("tbody", { children: filteredData.map((item, idx) => {
23030
23030
  const share = item.value > 0 ? item.value / positiveTotal : 0;
23031
23031
  return /* @__PURE__ */ jsxs(
23032
23032
  "tr",
23033
23033
  {
23034
23034
  className: classNames(
23035
23035
  "Layer__profit-and-loss-detailed-table__row",
23036
- hoveredItem && hoveredItem === item.displayName ? "active" : ""
23036
+ hoveredItem && hoveredItem.name === item.name ? "active" : ""
23037
23037
  ),
23038
- onMouseEnter: () => setHoveredItem(item.displayName),
23038
+ onMouseEnter: () => setHoveredItem(item),
23039
23039
  onMouseLeave: () => setHoveredItem(void 0),
23040
23040
  children: [
23041
23041
  /* @__PURE__ */ jsx("td", { className: "category-col", children: item.displayName }),
@@ -23067,6 +23067,35 @@ const DetailedTable = ({
23067
23067
  }) })
23068
23068
  ] }) }) });
23069
23069
  };
23070
+ const isLineItemUncategorized = (item) => {
23071
+ return UNCATEGORIZED_TYPES.includes(item.name);
23072
+ };
23073
+ const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
23074
+ const nameToColor = {};
23075
+ const nameToLastOpacity = {};
23076
+ let colorIndex = 0;
23077
+ return data.map((lineItem) => {
23078
+ if (isLineItemUncategorized(lineItem)) {
23079
+ return {
23080
+ color: "#EEEEF0",
23081
+ opacity: 1
23082
+ };
23083
+ }
23084
+ const name = lineItem.name;
23085
+ if (!nameToColor[name]) {
23086
+ nameToColor[name] = colorList[colorIndex % colorList.length];
23087
+ colorIndex++;
23088
+ nameToLastOpacity[name] = 1;
23089
+ } else {
23090
+ nameToLastOpacity[name] -= 0.1;
23091
+ }
23092
+ const opacity = nameToLastOpacity[name];
23093
+ return {
23094
+ color: nameToColor[name],
23095
+ opacity
23096
+ };
23097
+ });
23098
+ };
23070
23099
  const DetailedChart = ({
23071
23100
  filteredData,
23072
23101
  filteredTotal,
@@ -23077,18 +23106,9 @@ const DetailedChart = ({
23077
23106
  showDatePicker = true
23078
23107
  }) => {
23079
23108
  const chartData = useMemo(
23080
- () => filteredData.map((x) => {
23081
- if (x.isHidden) {
23082
- return __spreadProps(__spreadValues({}, x), {
23083
- name: x.displayName,
23084
- value: 0
23085
- });
23086
- }
23087
- return __spreadProps(__spreadValues({}, x), {
23088
- name: x.displayName,
23089
- value: x.value > 0 ? x.value : 0
23090
- });
23091
- }),
23109
+ () => filteredData.map((x) => __spreadProps(__spreadValues({}, x), {
23110
+ value: x.value > 0 ? x.value : 0
23111
+ })),
23092
23112
  [filteredData]
23093
23113
  );
23094
23114
  const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
@@ -23134,7 +23154,7 @@ const DetailedChart = ({
23134
23154
  {
23135
23155
  data: chartData,
23136
23156
  dataKey: "value",
23137
- nameKey: "name",
23157
+ nameKey: "displayName",
23138
23158
  cx: "50%",
23139
23159
  cy: "50%",
23140
23160
  innerRadius: "91%",
@@ -23147,7 +23167,7 @@ const DetailedChart = ({
23147
23167
  chartData.map((entry, index) => {
23148
23168
  let fill = typeColorMapping[index].color;
23149
23169
  let active = true;
23150
- if (hoveredItem && entry.name !== hoveredItem) {
23170
+ if (hoveredItem && entry.name !== hoveredItem.name) {
23151
23171
  active = false;
23152
23172
  fill = void 0;
23153
23173
  }
@@ -23157,13 +23177,13 @@ const DetailedChart = ({
23157
23177
  className: classNames(
23158
23178
  "Layer__profit-and-loss-detailed-charts__pie",
23159
23179
  hoveredItem && active ? "active" : "inactive",
23160
- entry.type === "Uncategorized" && "Layer__profit-and-loss-detailed-charts__pie--border"
23180
+ isLineItemUncategorized(entry) && "Layer__profit-and-loss-detailed-charts__pie--border"
23161
23181
  ),
23162
23182
  style: {
23163
- fill: entry.type === "Uncategorized" && fill ? "url(#layer-pie-dots-pattern)" : fill
23183
+ fill: isLineItemUncategorized(entry) && fill ? "url(#layer-pie-dots-pattern)" : fill
23164
23184
  },
23165
23185
  opacity: typeColorMapping[index].opacity,
23166
- onMouseEnter: () => setHoveredItem(entry.name),
23186
+ onMouseEnter: () => setHoveredItem(entry),
23167
23187
  onMouseLeave: () => setHoveredItem(void 0)
23168
23188
  },
23169
23189
  `cell-${index}`
@@ -23189,7 +23209,7 @@ const DetailedChart = ({
23189
23209
  };
23190
23210
  let text = "Total";
23191
23211
  if (hoveredItem) {
23192
- text = hoveredItem;
23212
+ text = hoveredItem.displayName;
23193
23213
  }
23194
23214
  return /* @__PURE__ */ jsx(
23195
23215
  Text$2,
@@ -23222,7 +23242,7 @@ const DetailedChart = ({
23222
23242
  let value = filteredTotal;
23223
23243
  if (hoveredItem) {
23224
23244
  value = (_b = filteredData.find(
23225
- (x) => x.displayName === hoveredItem
23245
+ (x) => x.name === hoveredItem.name
23226
23246
  )) == null ? void 0 : _b.value;
23227
23247
  }
23228
23248
  return /* @__PURE__ */ jsx(
@@ -23256,7 +23276,7 @@ const DetailedChart = ({
23256
23276
  };
23257
23277
  if (hoveredItem) {
23258
23278
  const item = filteredData.find(
23259
- (x) => x.displayName === hoveredItem
23279
+ (x) => x.name === hoveredItem.name
23260
23280
  );
23261
23281
  const positiveTotal = chartData.reduce((sum, x) => sum + x.value, 0);
23262
23282
  const value = (_b = item == null ? void 0 : item.value) != null ? _b : 0;
@@ -23281,7 +23301,7 @@ const DetailedChart = ({
23281
23301
  {
23282
23302
  data: [{ name: "Total", value: 1 }],
23283
23303
  dataKey: "value",
23284
- nameKey: "name",
23304
+ nameKey: "displayName",
23285
23305
  cx: "50%",
23286
23306
  cy: "50%",
23287
23307
  innerRadius: "91%",
@@ -23311,7 +23331,7 @@ const DetailedChart = ({
23311
23331
  };
23312
23332
  let text = "Total";
23313
23333
  if (hoveredItem) {
23314
- text = hoveredItem;
23334
+ text = hoveredItem.displayName;
23315
23335
  }
23316
23336
  return /* @__PURE__ */ jsx(
23317
23337
  Text$2,
@@ -23344,7 +23364,7 @@ const DetailedChart = ({
23344
23364
  let value = filteredTotal;
23345
23365
  if (hoveredItem) {
23346
23366
  value = (_b = filteredData.find(
23347
- (x) => x.displayName === hoveredItem
23367
+ (x) => x.name === hoveredItem.name
23348
23368
  )) == null ? void 0 : _b.value;
23349
23369
  }
23350
23370
  return /* @__PURE__ */ jsx(
@@ -23365,7 +23385,7 @@ const DetailedChart = ({
23365
23385
  {
23366
23386
  data: [{ name: "loading...", value: 1 }],
23367
23387
  dataKey: "value",
23368
- nameKey: "name",
23388
+ nameKey: "displayName",
23369
23389
  cx: "50%",
23370
23390
  cy: "50%",
23371
23391
  innerRadius: "91%",
@@ -23484,11 +23504,11 @@ const LedgerAccountsContext = createContext({
23484
23504
  fetchMore: () => {
23485
23505
  }
23486
23506
  });
23487
- const CloseButton = (_Ec) => {
23488
- var _Fc = _Ec, {
23507
+ const CloseButton = (_Gc) => {
23508
+ var _Hc = _Gc, {
23489
23509
  className,
23490
23510
  textOnly = false
23491
- } = _Fc, props = __objRest(_Fc, [
23511
+ } = _Hc, props = __objRest(_Hc, [
23492
23512
  "className",
23493
23513
  "textOnly"
23494
23514
  ]);
@@ -24263,44 +24283,6 @@ function DetailReportModal({
24263
24283
  }
24264
24284
  );
24265
24285
  }
24266
- const Filters = ({
24267
- filteredData,
24268
- sidebarScope,
24269
- filters,
24270
- setFilterTypes
24271
- }) => {
24272
- var _a, _b, _c;
24273
- return /* @__PURE__ */ jsxs("div", { className: "filters", children: [
24274
- /* @__PURE__ */ jsx(Text, { size: TextSize.sm, className: "Layer__label", children: "Filters" }),
24275
- /* @__PURE__ */ jsx(
24276
- Select$1,
24277
- {
24278
- className: "Layer__select type-select",
24279
- classNamePrefix: "Layer__select",
24280
- value: sidebarScope && ((_a = filters[sidebarScope]) == null ? void 0 : _a.types) ? sidebarScope && ((_c = (_b = filters[sidebarScope]) == null ? void 0 : _b.types) == null ? void 0 : _c.map((x) => ({
24281
- value: x,
24282
- label: x
24283
- }))) : [],
24284
- isMulti: true,
24285
- isClearable: false,
24286
- options: [...new Set(filteredData == null ? void 0 : filteredData.map((x) => x.type))].map((x) => ({
24287
- label: x,
24288
- value: x
24289
- })),
24290
- onChange: (selected) => {
24291
- setFilterTypes(
24292
- sidebarScope != null ? sidebarScope : "expenses",
24293
- selected.map((x) => x.value)
24294
- );
24295
- },
24296
- components: {
24297
- DropdownIndicator: (props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDown, {}) })),
24298
- Placeholder: (props) => /* @__PURE__ */ jsx(components.Placeholder, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx("div", { className: "Layer__select__multi-all-placeholder-badge", children: "All" }) }))
24299
- }
24300
- }
24301
- )
24302
- ] });
24303
- };
24304
24286
  const ProfitAndLossDetailedCharts = ({
24305
24287
  scope,
24306
24288
  hideClose = false,
@@ -24318,13 +24300,12 @@ const ProfitAndLossDetailedCharts = ({
24318
24300
  filters,
24319
24301
  dateRange,
24320
24302
  sidebarScope,
24321
- setSidebarScope,
24322
- setFilterTypes
24303
+ setSidebarScope
24323
24304
  } = useContext(ProfitAndLossContext);
24324
24305
  const theScope = scope ? scope : sidebarScope;
24325
24306
  const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
24326
24307
  const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
24327
- const [hoveredItem, setHoveredItem] = useState();
24308
+ const [hoveredItem, setHoveredItem] = useState(void 0);
24328
24309
  const [selectedItem, setSelectedItem] = useState(null);
24329
24310
  const [isModalOpen, setIsModalOpen] = useState(false);
24330
24311
  const handleValueClick = useCallback((item) => {
@@ -24373,31 +24354,20 @@ const ProfitAndLossDetailedCharts = ({
24373
24354
  showDatePicker
24374
24355
  }
24375
24356
  ),
24376
- /* @__PURE__ */ jsxs("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: [
24377
- /* @__PURE__ */ jsx(
24378
- Filters,
24379
- {
24380
- filteredData: data,
24381
- sidebarScope: theScope,
24382
- filters,
24383
- setFilterTypes
24384
- }
24385
- ),
24386
- /* @__PURE__ */ jsx(
24387
- DetailedTable,
24388
- {
24389
- filteredData: data,
24390
- sidebarScope: theScope,
24391
- filters,
24392
- sortBy,
24393
- hoveredItem,
24394
- setHoveredItem,
24395
- chartColorsList,
24396
- stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
24397
- onValueClick: handleValueClick
24398
- }
24399
- )
24400
- ] })
24357
+ /* @__PURE__ */ jsx("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: /* @__PURE__ */ jsx(
24358
+ DetailedTable,
24359
+ {
24360
+ filteredData: data,
24361
+ sidebarScope: theScope,
24362
+ filters,
24363
+ sortBy,
24364
+ hoveredItem,
24365
+ setHoveredItem,
24366
+ chartColorsList,
24367
+ stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
24368
+ onValueClick: handleValueClick
24369
+ }
24370
+ ) })
24401
24371
  ] }),
24402
24372
  /* @__PURE__ */ jsx(
24403
24373
  DetailReportModal,
@@ -24660,7 +24630,7 @@ const getProfitAndLossDetailLinesExcel = (apiUrl, accessToken, params) => {
24660
24630
  ({ businessId: businessId2 }) => `/v1/businesses/${businessId2}/reports/profit-and-loss/lines/exports/excel?${queryParams.toString()}`
24661
24631
  )(apiUrl, accessToken, { params: { businessId } });
24662
24632
  };
24663
- function buildKey$x({
24633
+ function buildKey$B({
24664
24634
  access_token: accessToken,
24665
24635
  apiUrl,
24666
24636
  businessId,
@@ -24699,7 +24669,7 @@ function useProfitAndLossDetailLinesExport({
24699
24669
  const { businessId } = useLayerContext();
24700
24670
  const { apiUrl } = useEnvironment();
24701
24671
  return useSWRMutation(
24702
- () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
24672
+ () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
24703
24673
  apiUrl,
24704
24674
  businessId,
24705
24675
  startDate,
@@ -24919,7 +24889,7 @@ const MultiSelect = ({
24919
24889
  const DropdownIndicator = useCallback((props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDownFill, {}) })), []);
24920
24890
  return /* @__PURE__ */ jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
24921
24891
  /* @__PURE__ */ jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx(
24922
- Select$1,
24892
+ ReactSelect,
24923
24893
  {
24924
24894
  inputId,
24925
24895
  name,
@@ -24934,7 +24904,7 @@ const MultiSelect = ({
24934
24904
  styles: __spreadValues({
24935
24905
  menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 })
24936
24906
  }, styles),
24937
- components: { DropdownIndicator },
24907
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
24938
24908
  isLoading,
24939
24909
  isDisabled: disabled,
24940
24910
  isMulti: true
@@ -25735,7 +25705,13 @@ function ProfitAndLossSummariesMiniChart({
25735
25705
  chartColorsList,
25736
25706
  variants: variants2
25737
25707
  }) {
25738
- const typeColorMapping = mapTypesToColors(data, chartColorsList);
25708
+ const chartData = useMemo(
25709
+ () => data.map((x) => __spreadProps(__spreadValues({}, x), {
25710
+ value: x.value > 0 ? x.value : 0
25711
+ })),
25712
+ [data]
25713
+ );
25714
+ const typeColorMapping = mapTypesToColors(chartData, chartColorsList);
25739
25715
  let chartDimension = 52;
25740
25716
  let innerRadius = 10;
25741
25717
  let outerRadius = 16;
@@ -25754,9 +25730,9 @@ function ProfitAndLossSummariesMiniChart({
25754
25730
  return /* @__PURE__ */ jsx(PieChart, { width: chartDimension, height: chartDimension, children: /* @__PURE__ */ jsx(
25755
25731
  Pie,
25756
25732
  {
25757
- data,
25733
+ data: chartData,
25758
25734
  dataKey: "value",
25759
- nameKey: "name",
25735
+ nameKey: "displayName",
25760
25736
  cx: "50%",
25761
25737
  cy: "50%",
25762
25738
  innerRadius,
@@ -25767,7 +25743,7 @@ function ProfitAndLossSummariesMiniChart({
25767
25743
  height: 36,
25768
25744
  animationDuration: 250,
25769
25745
  animationEasing: "ease-in-out",
25770
- children: data.map((entry, index) => {
25746
+ children: chartData.map((entry, index) => {
25771
25747
  const colorConfig = typeColorMapping[index];
25772
25748
  return /* @__PURE__ */ jsx(
25773
25749
  Cell$2,
@@ -25804,7 +25780,7 @@ function ProfitAndLossSummariesSummary({
25804
25780
  const showPercentChange = percentChange !== void 0 && percentChange !== null && comparisonMonth;
25805
25781
  const isGoodChange = showPercentChange && (isExpense ? percentChange < 0 : percentChange >= 0);
25806
25782
  const arrow = showPercentChange && percentChange >= 0 ? "↑" : "↓";
25807
- return /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
25783
+ return /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", overflow: "hidden", children: [
25808
25784
  Chart && /* @__PURE__ */ jsx(
25809
25785
  HStack,
25810
25786
  {
@@ -26056,10 +26032,10 @@ function Internal_ProfitAndLossSummaries({
26056
26032
  unstable_AdditionalListItems.map((item, index) => /* @__PURE__ */ jsx(ProfitAndLossSummariesListItem, { children: item }, index))
26057
26033
  ] }) });
26058
26034
  }
26059
- function ProfitAndLossSummaries(_Gc) {
26060
- var _Hc = _Gc, {
26035
+ function ProfitAndLossSummaries(_Ic) {
26036
+ var _Jc = _Ic, {
26061
26037
  onTransactionsToReviewClick
26062
- } = _Hc, restProps = __objRest(_Hc, [
26038
+ } = _Jc, restProps = __objRest(_Jc, [
26063
26039
  "onTransactionsToReviewClick"
26064
26040
  ]);
26065
26041
  return /* @__PURE__ */ jsx(
@@ -26097,7 +26073,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
26097
26073
  ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
26098
26074
  ProfitAndLoss.Header = ProfitAndLossHeader;
26099
26075
  ProfitAndLoss.Report = ProfitAndLossReport;
26100
- function buildKey$w({
26076
+ function buildKey$A({
26101
26077
  access_token: accessToken,
26102
26078
  apiUrl,
26103
26079
  businessId,
@@ -26120,7 +26096,7 @@ function useBalanceSheet({
26120
26096
  const { apiUrl } = useEnvironment();
26121
26097
  const { businessId } = useLayerContext();
26122
26098
  return useSWR(
26123
- () => buildKey$w(__spreadProps(__spreadValues({}, auth), {
26099
+ () => buildKey$A(__spreadProps(__spreadValues({}, auth), {
26124
26100
  apiUrl,
26125
26101
  businessId,
26126
26102
  effectiveDate
@@ -26186,7 +26162,7 @@ const BALANCE_SHEET_ROWS = [
26186
26162
  }
26187
26163
  ];
26188
26164
  const DOWNLOAD_BALANCE_SHEET_TAG_KEY = "#download-balance-sheet";
26189
- function buildKey$v({
26165
+ function buildKey$z({
26190
26166
  access_token: accessToken,
26191
26167
  apiUrl,
26192
26168
  businessId,
@@ -26209,7 +26185,7 @@ function useBalanceSheetDownload({
26209
26185
  const { data: auth } = useAuth();
26210
26186
  const { businessId } = useLayerContext();
26211
26187
  return useSWRMutation(
26212
- () => buildKey$v(__spreadProps(__spreadValues({}, auth), {
26188
+ () => buildKey$z(__spreadProps(__spreadValues({}, auth), {
26213
26189
  businessId,
26214
26190
  effectiveDate
26215
26191
  })),
@@ -26259,8 +26235,8 @@ function BalanceSheetDownloadButton({
26259
26235
  /* @__PURE__ */ jsx(InvisibleDownload, { ref: invisibleDownloadRef })
26260
26236
  ] });
26261
26237
  }
26262
- const Collapse = (_Ic) => {
26263
- var props = __objRest(_Ic, []);
26238
+ const Collapse = (_Kc) => {
26239
+ var props = __objRest(_Kc, []);
26264
26240
  return /* @__PURE__ */ jsxs(
26265
26241
  "svg",
26266
26242
  __spreadProps(__spreadValues({
@@ -26293,8 +26269,8 @@ const Collapse = (_Ic) => {
26293
26269
  })
26294
26270
  );
26295
26271
  };
26296
- const Expand = (_Jc) => {
26297
- var props = __objRest(_Jc, []);
26272
+ const Expand = (_Lc) => {
26273
+ var props = __objRest(_Lc, []);
26298
26274
  return /* @__PURE__ */ jsxs(
26299
26275
  "svg",
26300
26276
  __spreadProps(__spreadValues({
@@ -26564,7 +26540,7 @@ const BalanceSheetView = ({
26564
26540
  }
26565
26541
  ) });
26566
26542
  };
26567
- function buildKey$u({
26543
+ function buildKey$y({
26568
26544
  access_token: accessToken,
26569
26545
  apiUrl,
26570
26546
  businessId,
@@ -26590,7 +26566,7 @@ function useStatementOfCashFlow({
26590
26566
  const { apiUrl } = useEnvironment();
26591
26567
  const { businessId } = useLayerContext();
26592
26568
  return useSWR(
26593
- buildKey$u(__spreadProps(__spreadValues({}, auth), {
26569
+ buildKey$y(__spreadProps(__spreadValues({}, auth), {
26594
26570
  apiUrl,
26595
26571
  businessId,
26596
26572
  startDate,
@@ -26654,7 +26630,7 @@ const STATEMENT_OF_CASH_FLOW_ROWS = [
26654
26630
  }
26655
26631
  ];
26656
26632
  const DOWNLOAD_CASHFLOW_STATEMENT_TAG_KEY = "#download-cashflow-statement";
26657
- function buildKey$t({
26633
+ function buildKey$x({
26658
26634
  access_token: accessToken,
26659
26635
  apiUrl,
26660
26636
  businessId,
@@ -26680,7 +26656,7 @@ function useCashflowStatementDownload({
26680
26656
  const { data: auth } = useAuth();
26681
26657
  const { businessId } = useLayerContext();
26682
26658
  return useSWRMutation(
26683
- () => buildKey$t(__spreadProps(__spreadValues({}, auth), {
26659
+ () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
26684
26660
  businessId,
26685
26661
  startDate,
26686
26662
  endDate
@@ -26884,7 +26860,7 @@ const getLedgerAccountBalances = get(
26884
26860
  return `/v1/businesses/${businessId}/ledger/balances?${parameters}`;
26885
26861
  }
26886
26862
  );
26887
- function buildKey$s({
26863
+ function buildKey$w({
26888
26864
  access_token: accessToken,
26889
26865
  apiUrl,
26890
26866
  businessId,
@@ -26906,7 +26882,7 @@ function useLedgerBalances(withDates, startDate, endDate) {
26906
26882
  const { data } = useAuth();
26907
26883
  const { businessId } = useLayerContext();
26908
26884
  const response = useSWR(
26909
- () => buildKey$s(__spreadProps(__spreadValues({}, data), {
26885
+ () => buildKey$w(__spreadProps(__spreadValues({}, data), {
26910
26886
  businessId,
26911
26887
  startDate: withDates ? startDate : void 0,
26912
26888
  endDate: withDates ? endDate : void 0
@@ -27248,7 +27224,7 @@ const LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
27248
27224
  EXPENSE: EXPENSE_LEDGER_ACCOUNT_SUBTYPES
27249
27225
  };
27250
27226
  const deleteAccountFromLedger = del(({ businessId, accountId }) => `/v1/businesses/${businessId}/ledger/accounts/${accountId}`);
27251
- function buildKey$r({
27227
+ function buildKey$v({
27252
27228
  access_token: accessToken,
27253
27229
  apiUrl,
27254
27230
  businessId
@@ -27266,7 +27242,7 @@ function useDeleteAccountFromLedger() {
27266
27242
  const { data } = useAuth();
27267
27243
  const { businessId } = useLayerContext();
27268
27244
  const mutationResponse = useSWRMutation(
27269
- () => buildKey$r(__spreadProps(__spreadValues({}, data), {
27245
+ () => buildKey$v(__spreadProps(__spreadValues({}, data), {
27270
27246
  businessId
27271
27247
  })),
27272
27248
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { accountId } }) => deleteAccountFromLedger(
@@ -27942,8 +27918,8 @@ const ChartOfAccountsContext = createContext(
27942
27918
  }
27943
27919
  }
27944
27920
  );
27945
- const Plus = (_Kc) => {
27946
- var _Lc = _Kc, { size = 14 } = _Lc, props = __objRest(_Lc, ["size"]);
27921
+ const Plus = (_Mc) => {
27922
+ var _Nc = _Mc, { size = 14 } = _Nc, props = __objRest(_Nc, ["size"]);
27947
27923
  return /* @__PURE__ */ jsxs(
27948
27924
  "svg",
27949
27925
  __spreadProps(__spreadValues({
@@ -27976,7 +27952,7 @@ const Plus = (_Kc) => {
27976
27952
  })
27977
27953
  );
27978
27954
  };
27979
- function buildKey$q({
27955
+ function buildKey$u({
27980
27956
  access_token: accessToken,
27981
27957
  apiUrl,
27982
27958
  businessId,
@@ -28002,7 +27978,7 @@ function useAccountBalancesDownload({
28002
27978
  const { data: auth } = useAuth();
28003
27979
  const { businessId } = useLayerContext();
28004
27980
  return useSWRMutation(
28005
- () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
27981
+ () => buildKey$u(__spreadProps(__spreadValues({}, auth), {
28006
27982
  businessId,
28007
27983
  startCutoff,
28008
27984
  endCutoff
@@ -28310,8 +28286,8 @@ var LedgerAccountNodeType = /* @__PURE__ */ ((LedgerAccountNodeType2) => {
28310
28286
  LedgerAccountNodeType2["Parent"] = "Parent";
28311
28287
  return LedgerAccountNodeType2;
28312
28288
  })(LedgerAccountNodeType || {});
28313
- const Edit2 = (_Mc) => {
28314
- var _Nc = _Mc, { size = 18 } = _Nc, props = __objRest(_Nc, ["size"]);
28289
+ const Edit2 = (_Oc) => {
28290
+ var _Pc = _Oc, { size = 18 } = _Pc, props = __objRest(_Pc, ["size"]);
28315
28291
  return /* @__PURE__ */ jsx(
28316
28292
  "svg",
28317
28293
  __spreadProps(__spreadValues({
@@ -30034,7 +30010,7 @@ var UpsertJournalEntryMode = /* @__PURE__ */ ((UpsertJournalEntryMode2) => {
30034
30010
  return UpsertJournalEntryMode2;
30035
30011
  })(UpsertJournalEntryMode || {});
30036
30012
  const createJournalEntry = post(({ businessId }) => `/v1/businesses/${businessId}/ledger/journal-entries`);
30037
- function buildKey$p({
30013
+ function buildKey$t({
30038
30014
  access_token: accessToken,
30039
30015
  apiUrl,
30040
30016
  businessId
@@ -30061,7 +30037,7 @@ const useUpsertJournalEntry = (props) => {
30061
30037
  const { debouncedInvalidateProfitAndLossSummaries } = useProfitAndLossSummariesCacheActions();
30062
30038
  const { invalidate } = useGlobalCacheActions();
30063
30039
  const rawMutationResponse = useSWRMutation(
30064
- () => buildKey$p(__spreadProps(__spreadValues({}, data), {
30040
+ () => buildKey$t(__spreadProps(__spreadValues({}, data), {
30065
30041
  businessId
30066
30042
  })),
30067
30043
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => {
@@ -30375,7 +30351,7 @@ const JournalEntryDrawerHeader = ({ onSubmit, formState }) => {
30375
30351
  ] })
30376
30352
  ] });
30377
30353
  };
30378
- function buildKey$o({
30354
+ function buildKey$s({
30379
30355
  access_token: accessToken,
30380
30356
  apiUrl,
30381
30357
  businessId,
@@ -30401,7 +30377,7 @@ function useJournalEntriesDownload({
30401
30377
  const { data: auth } = useAuth();
30402
30378
  const { businessId } = useLayerContext();
30403
30379
  return useSWRMutation(
30404
- () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
30380
+ () => buildKey$s(__spreadProps(__spreadValues({}, auth), {
30405
30381
  businessId,
30406
30382
  startCutoff,
30407
30383
  endCutoff
@@ -30992,8 +30968,8 @@ function usePaginatedList(list, pageSize) {
30992
30968
  reset
30993
30969
  };
30994
30970
  }
30995
- const SmileIcon = (_Oc) => {
30996
- var _Pc = _Oc, { size = 12 } = _Pc, props = __objRest(_Pc, ["size"]);
30971
+ const SmileIcon = (_Qc) => {
30972
+ var _Rc = _Qc, { size = 12 } = _Rc, props = __objRest(_Rc, ["size"]);
30997
30973
  return /* @__PURE__ */ jsxs(
30998
30974
  "svg",
30999
30975
  __spreadProps(__spreadValues({
@@ -31089,7 +31065,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
31089
31065
  accessToken
31090
31066
  );
31091
31067
  }
31092
- function buildKey$n({
31068
+ function buildKey$r({
31093
31069
  access_token: accessToken,
31094
31070
  apiUrl,
31095
31071
  businessId
@@ -31108,7 +31084,7 @@ function useDeleteUploadsOnTask() {
31108
31084
  const { businessId } = useLayerContext();
31109
31085
  const { mutate } = useSWRConfig();
31110
31086
  const mutationResponse = useSWRMutation(
31111
- () => buildKey$n(__spreadProps(__spreadValues({}, auth), {
31087
+ () => buildKey$r(__spreadProps(__spreadValues({}, auth), {
31112
31088
  businessId
31113
31089
  })),
31114
31090
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId } }) => deleteUploadsOnTask(
@@ -31147,7 +31123,7 @@ function useDeleteUploadsOnTask() {
31147
31123
  }
31148
31124
  });
31149
31125
  }
31150
- function buildKey$m({
31126
+ function buildKey$q({
31151
31127
  access_token: accessToken,
31152
31128
  apiUrl,
31153
31129
  businessId
@@ -31166,7 +31142,7 @@ function useSubmitUserResponseForTask() {
31166
31142
  const { businessId } = useLayerContext();
31167
31143
  const { mutate } = useSWRConfig();
31168
31144
  const mutationResponse = useSWRMutation(
31169
- () => buildKey$m(__spreadProps(__spreadValues({}, auth), {
31145
+ () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
31170
31146
  businessId
31171
31147
  })),
31172
31148
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, userResponse } }) => submitUserResponseForTask(
@@ -31212,7 +31188,7 @@ function useSubmitUserResponseForTask() {
31212
31188
  }
31213
31189
  });
31214
31190
  }
31215
- function buildKey$l({
31191
+ function buildKey$p({
31216
31192
  access_token: accessToken,
31217
31193
  apiUrl,
31218
31194
  businessId
@@ -31231,7 +31207,7 @@ function useUpdateTaskUploadDescription() {
31231
31207
  const { businessId } = useLayerContext();
31232
31208
  const { mutate } = useSWRConfig();
31233
31209
  const mutationResponse = useSWRMutation(
31234
- () => buildKey$l(__spreadProps(__spreadValues({}, auth), {
31210
+ () => buildKey$p(__spreadProps(__spreadValues({}, auth), {
31235
31211
  businessId
31236
31212
  })),
31237
31213
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, description } }) => updateTaskUploadsDescription(
@@ -31274,7 +31250,7 @@ function useUpdateTaskUploadDescription() {
31274
31250
  }
31275
31251
  });
31276
31252
  }
31277
- function buildKey$k({
31253
+ function buildKey$o({
31278
31254
  access_token: accessToken,
31279
31255
  apiUrl,
31280
31256
  businessId
@@ -31293,7 +31269,7 @@ function useUploadDocumentsForTask() {
31293
31269
  const { businessId } = useLayerContext();
31294
31270
  const { mutate } = useSWRConfig();
31295
31271
  const mutationResponse = useSWRMutation(
31296
- () => buildKey$k(__spreadProps(__spreadValues({}, auth), {
31272
+ () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
31297
31273
  businessId
31298
31274
  })),
31299
31275
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, files, description } }) => completeTaskWithUpload(
@@ -31838,8 +31814,8 @@ const useBookkeepingYearsStatus = () => {
31838
31814
  isLoading
31839
31815
  };
31840
31816
  };
31841
- const ArrowRightCircle = (_Qc) => {
31842
- var _Rc = _Qc, { size = 18 } = _Rc, props = __objRest(_Rc, ["size"]);
31817
+ const ArrowRightCircle = (_Sc) => {
31818
+ var _Tc = _Sc, { size = 18 } = _Tc, props = __objRest(_Tc, ["size"]);
31843
31819
  return /* @__PURE__ */ jsxs(
31844
31820
  "svg",
31845
31821
  __spreadProps(__spreadValues({
@@ -33321,7 +33297,7 @@ class BookkeepingConfigurationSWRResponse {
33321
33297
  return this.swrResponse.mutate;
33322
33298
  }
33323
33299
  }
33324
- function buildKey$j({
33300
+ function buildKey$n({
33325
33301
  access_token: accessToken,
33326
33302
  apiUrl,
33327
33303
  businessId
@@ -33342,7 +33318,7 @@ function useBookkeepingConfiguration() {
33342
33318
  const { apiUrl } = useEnvironment();
33343
33319
  const { data: auth } = useAuth();
33344
33320
  const { businessId } = useLayerContext();
33345
- const queryKey = buildKey$j(__spreadProps(__spreadValues({}, auth), {
33321
+ const queryKey = buildKey$n(__spreadProps(__spreadValues({}, auth), {
33346
33322
  apiUrl,
33347
33323
  businessId
33348
33324
  }));
@@ -33529,7 +33505,7 @@ const BookOnboardingCallStep = ({ title = defaultTitle$3, description = defaultD
33529
33505
  ] });
33530
33506
  };
33531
33507
  const BUSINESS_TAG_KEY = "business";
33532
- function buildKey$i({
33508
+ function buildKey$m({
33533
33509
  access_token: accessToken,
33534
33510
  apiUrl,
33535
33511
  businessId
@@ -33548,7 +33524,7 @@ function useUpdateBusiness() {
33548
33524
  const { businessId } = useLayerContext();
33549
33525
  const { mutate } = useSWRConfig();
33550
33526
  const mutationResponse = useSWRMutation(
33551
- () => buildKey$i(__spreadProps(__spreadValues({}, data), {
33527
+ () => buildKey$m(__spreadProps(__spreadValues({}, data), {
33552
33528
  businessId
33553
33529
  })),
33554
33530
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => updateBusiness(
@@ -33599,7 +33575,7 @@ function isPersonnelRole(role) {
33599
33575
  return PERSONNEL_ROLES.includes(role);
33600
33576
  }
33601
33577
  const BUSINESS_PERSONNEL_TAG_KEY = "#business-personnel";
33602
- function buildKey$h({
33578
+ function buildKey$l({
33603
33579
  access_token: accessToken,
33604
33580
  apiUrl,
33605
33581
  businessId
@@ -33618,7 +33594,7 @@ function useBusinessPersonnel() {
33618
33594
  const { data } = useAuth();
33619
33595
  const { businessId } = useLayerContext();
33620
33596
  return useSWR(
33621
- () => buildKey$h(__spreadProps(__spreadValues({}, data), {
33597
+ () => buildKey$l(__spreadProps(__spreadValues({}, data), {
33622
33598
  businessId
33623
33599
  })),
33624
33600
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBusinessPersonnel(
@@ -33656,7 +33632,7 @@ function useBusinessPersonnel() {
33656
33632
  );
33657
33633
  }
33658
33634
  const createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
33659
- function buildKey$g({
33635
+ function buildKey$k({
33660
33636
  access_token: accessToken,
33661
33637
  apiUrl,
33662
33638
  businessId
@@ -33675,7 +33651,7 @@ function useCreateBusinessPersonnel() {
33675
33651
  const { businessId } = useLayerContext();
33676
33652
  const { mutate } = useSWRConfig();
33677
33653
  const mutationResponse = useSWRMutation(
33678
- () => buildKey$g(__spreadProps(__spreadValues({}, data), {
33654
+ () => buildKey$k(__spreadProps(__spreadValues({}, data), {
33679
33655
  businessId
33680
33656
  })),
33681
33657
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createBusinessPersonnel(
@@ -33718,7 +33694,7 @@ function useCreateBusinessPersonnel() {
33718
33694
  const updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
33719
33695
  return `/v1/businesses/${businessId}/personnel/${businessPersonnelId}/update`;
33720
33696
  });
33721
- function buildKey$f({
33697
+ function buildKey$j({
33722
33698
  access_token: accessToken,
33723
33699
  apiUrl,
33724
33700
  businessId,
@@ -33739,7 +33715,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
33739
33715
  const { businessId } = useLayerContext();
33740
33716
  const { mutate } = useSWRConfig();
33741
33717
  const mutationResponse = useSWRMutation(
33742
- () => buildKey$f(__spreadProps(__spreadValues({}, data), {
33718
+ () => buildKey$j(__spreadProps(__spreadValues({}, data), {
33743
33719
  businessId,
33744
33720
  businessPersonnelId
33745
33721
  })),
@@ -33887,12 +33863,12 @@ const FormSection = ({ children, title }) => {
33887
33863
  children
33888
33864
  ] });
33889
33865
  };
33890
- const PhoneInput = (_Sc) => {
33891
- var _Tc = _Sc, {
33866
+ const PhoneInput = (_Uc) => {
33867
+ var _Vc = _Uc, {
33892
33868
  value,
33893
33869
  onChange,
33894
33870
  placeholder = "Phone number"
33895
- } = _Tc, props = __objRest(_Tc, [
33871
+ } = _Vc, props = __objRest(_Vc, [
33896
33872
  "value",
33897
33873
  "onChange",
33898
33874
  "placeholder"
@@ -34184,8 +34160,8 @@ const SummaryStep = ({ onNext, title = defaultTitle$1, description = defaultDesc
34184
34160
  /* @__PURE__ */ jsx(Button$1, { onClick: onNext, children: nextBtnText })
34185
34161
  ] });
34186
34162
  };
34187
- const Document = (_Uc) => {
34188
- var _Vc = _Uc, { size = 20 } = _Vc, props = __objRest(_Vc, ["size"]);
34163
+ const Document = (_Wc) => {
34164
+ var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
34189
34165
  return /* @__PURE__ */ jsxs(
34190
34166
  "svg",
34191
34167
  __spreadProps(__spreadValues({
@@ -34290,8 +34266,8 @@ const Document = (_Uc) => {
34290
34266
  })
34291
34267
  );
34292
34268
  };
34293
- const TrendingUp = (_Wc) => {
34294
- var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
34269
+ const TrendingUp = (_Yc) => {
34270
+ var _Zc = _Yc, { size = 20 } = _Zc, props = __objRest(_Zc, ["size"]);
34295
34271
  return /* @__PURE__ */ jsxs(
34296
34272
  "svg",
34297
34273
  __spreadProps(__spreadValues({
@@ -34548,8 +34524,8 @@ const PlatformOnboarding = ({ onComplete }) => {
34548
34524
  /* @__PURE__ */ jsx("div", { className: "Layer__platform-onboarding-layout__footer", children: renderStepFooter() })
34549
34525
  ] }) });
34550
34526
  };
34551
- const CoffeeIcon = (_Yc) => {
34552
- var _Zc = _Yc, { size = 11 } = _Zc, props = __objRest(_Zc, ["size"]);
34527
+ const CoffeeIcon = (__c) => {
34528
+ var _$c = __c, { size = 11 } = _$c, props = __objRest(_$c, ["size"]);
34553
34529
  return /* @__PURE__ */ jsxs(
34554
34530
  "svg",
34555
34531
  __spreadProps(__spreadValues({
@@ -34620,8 +34596,8 @@ const CoffeeIcon = (_Yc) => {
34620
34596
  })
34621
34597
  );
34622
34598
  };
34623
- const Link$1 = (__c) => {
34624
- var _$c = __c, {
34599
+ const Link$1 = (_ad) => {
34600
+ var _bd = _ad, {
34625
34601
  className,
34626
34602
  children,
34627
34603
  variant = ButtonVariant.primary,
@@ -34631,7 +34607,7 @@ const Link$1 = (__c) => {
34631
34607
  iconAsPrimary = false,
34632
34608
  justify = "center",
34633
34609
  fullWidth
34634
- } = _$c, props = __objRest(_$c, [
34610
+ } = _bd, props = __objRest(_bd, [
34635
34611
  "className",
34636
34612
  "children",
34637
34613
  "variant",
@@ -34723,8 +34699,8 @@ const BookkeepingUpsellBar = ({
34723
34699
  onClick ? /* @__PURE__ */ jsx(Button$1, { variant: ButtonVariant.secondary, onClick, children: "Schedule a demo" }) : href ? /* @__PURE__ */ jsx(Link$1, { href, target: "_blank", variant: ButtonVariant.secondary, children: "Schedule a demo" }) : null
34724
34700
  ] });
34725
34701
  };
34726
- const ChevronRightFill = (_ad) => {
34727
- var _bd = _ad, { size = 18 } = _bd, props = __objRest(_bd, ["size"]);
34702
+ const ChevronRightFill = (_cd) => {
34703
+ var _dd = _cd, { size = 18 } = _dd, props = __objRest(_dd, ["size"]);
34728
34704
  return /* @__PURE__ */ jsxs(
34729
34705
  "svg",
34730
34706
  __spreadProps(__spreadValues({
@@ -34751,7 +34727,7 @@ const ChevronRightFill = (_ad) => {
34751
34727
  };
34752
34728
  const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
34753
34729
  const { showCount, totalCount } = count != null ? count : {};
34754
- const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
34730
+ const { Filters, HeaderActions, HeaderFilters } = slots;
34755
34731
  return /* @__PURE__ */ jsxs(VStack, { children: [
34756
34732
  /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "xs", className: "Layer__DataTableHeader__Header", children: [
34757
34733
  /* @__PURE__ */ jsxs(HStack, { pis: "md", align: "center", gap: "xl", children: [
@@ -34766,8 +34742,8 @@ const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
34766
34742
  HeaderActions && /* @__PURE__ */ jsx(HeaderActions, {})
34767
34743
  ] })
34768
34744
  ] }),
34769
- Filters2 && /* @__PURE__ */ jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
34770
- /* @__PURE__ */ jsx(Filters2, {}),
34745
+ Filters && /* @__PURE__ */ jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
34746
+ /* @__PURE__ */ jsx(Filters, {}),
34771
34747
  slotProps.ClearFiltersButton && /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
34772
34748
  ] })
34773
34749
  ] });
@@ -35692,7 +35668,7 @@ class InvoiceSummaryStatsSWRResponse {
35692
35668
  return this.swrResponse.error !== void 0;
35693
35669
  }
35694
35670
  }
35695
- function buildKey$e({
35671
+ function buildKey$i({
35696
35672
  access_token: accessToken,
35697
35673
  apiUrl,
35698
35674
  businessId
@@ -35711,7 +35687,7 @@ function useInvoiceSummaryStats() {
35711
35687
  const { data } = useAuth();
35712
35688
  const { businessId } = useLayerContext();
35713
35689
  const response = useSWR(
35714
- () => buildKey$e(__spreadProps(__spreadValues({}, data), {
35690
+ () => buildKey$i(__spreadProps(__spreadValues({}, data), {
35715
35691
  businessId
35716
35692
  })),
35717
35693
  ({ accessToken, apiUrl, businessId: businessId2 }) => getInvoiceSummaryStats(
@@ -35742,7 +35718,7 @@ var UpsertInvoiceMode = /* @__PURE__ */ ((UpsertInvoiceMode2) => {
35742
35718
  })(UpsertInvoiceMode || {});
35743
35719
  const createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
35744
35720
  const updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
35745
- function buildKey$d({
35721
+ function buildKey$h({
35746
35722
  access_token: accessToken,
35747
35723
  apiUrl,
35748
35724
  businessId,
@@ -35814,7 +35790,7 @@ const useUpsertInvoice = (props) => {
35814
35790
  const { mode } = props;
35815
35791
  const invoiceId = mode === "Update" ? props.invoiceId : void 0;
35816
35792
  const rawMutationResponse = useSWRMutation(
35817
- () => buildKey$d(__spreadProps(__spreadValues({}, data), {
35793
+ () => buildKey$h(__spreadProps(__spreadValues({}, data), {
35818
35794
  businessId,
35819
35795
  invoiceId
35820
35796
  })),
@@ -36083,7 +36059,7 @@ const RefundInvoiceReturnSchema = Schema.Struct({
36083
36059
  data: CustomerRefundSchema
36084
36060
  });
36085
36061
  const refundInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/refund`);
36086
- function buildKey$c({
36062
+ function buildKey$g({
36087
36063
  access_token: accessToken,
36088
36064
  apiUrl,
36089
36065
  businessId,
@@ -36128,7 +36104,7 @@ const useRefundInvoice = ({ invoiceId }) => {
36128
36104
  return updateInvoiceWithRefund(invoice);
36129
36105
  }, [invoiceId]);
36130
36106
  const rawMutationResponse = useSWRMutation(
36131
- () => buildKey$c(__spreadProps(__spreadValues({}, data), {
36107
+ () => buildKey$g(__spreadProps(__spreadValues({}, data), {
36132
36108
  businessId,
36133
36109
  invoiceId
36134
36110
  })),
@@ -36316,7 +36292,7 @@ const ResetInvoiceReturnSchema = Schema.Struct({
36316
36292
  data: InvoiceSchema
36317
36293
  });
36318
36294
  const resetInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/reset`);
36319
- function buildKey$b({
36295
+ function buildKey$f({
36320
36296
  access_token: accessToken,
36321
36297
  apiUrl,
36322
36298
  businessId,
@@ -36354,7 +36330,7 @@ const useResetInvoice = ({ invoiceId }) => {
36354
36330
  const { data } = useAuth();
36355
36331
  const { businessId } = useLayerContext();
36356
36332
  const rawMutationResponse = useSWRMutation(
36357
- () => buildKey$b(__spreadProps(__spreadValues({}, data), {
36333
+ () => buildKey$f(__spreadProps(__spreadValues({}, data), {
36358
36334
  businessId,
36359
36335
  invoiceId
36360
36336
  })),
@@ -36417,7 +36393,7 @@ const VoidInvoiceReturnSchema = Schema.Struct({
36417
36393
  data: InvoiceSchema
36418
36394
  });
36419
36395
  const voidInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/void`);
36420
- function buildKey$a({
36396
+ function buildKey$e({
36421
36397
  access_token: accessToken,
36422
36398
  apiUrl,
36423
36399
  businessId,
@@ -36455,7 +36431,7 @@ const useVoidInvoice = ({ invoiceId }) => {
36455
36431
  const { data } = useAuth();
36456
36432
  const { businessId } = useLayerContext();
36457
36433
  const rawMutationResponse = useSWRMutation(
36458
- () => buildKey$a(__spreadProps(__spreadValues({}, data), {
36434
+ () => buildKey$e(__spreadProps(__spreadValues({}, data), {
36459
36435
  businessId,
36460
36436
  invoiceId
36461
36437
  })),
@@ -36574,7 +36550,7 @@ const InvoiceWriteoffSchema = Schema.Struct({
36574
36550
  });
36575
36551
  const CREATE_INVOICE_WRITEOFF_TAG_KEY = "#writeoff-invoice";
36576
36552
  const writeoffInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/write-off`);
36577
- function buildKey$9({
36553
+ function buildKey$d({
36578
36554
  access_token: accessToken,
36579
36555
  apiUrl,
36580
36556
  businessId,
@@ -36625,7 +36601,7 @@ const useWriteoffInvoice = ({ invoiceId }) => {
36625
36601
  return updateInvoiceWithWriteoff(invoice);
36626
36602
  }, [invoiceId]);
36627
36603
  const rawMutationResponse = useSWRMutation(
36628
- () => buildKey$9(__spreadProps(__spreadValues({}, data), {
36604
+ () => buildKey$d(__spreadProps(__spreadValues({}, data), {
36629
36605
  businessId,
36630
36606
  invoiceId
36631
36607
  })),
@@ -37621,7 +37597,7 @@ var UpsertDedicatedInvoicePaymentMode = /* @__PURE__ */ ((UpsertDedicatedInvoice
37621
37597
  })(UpsertDedicatedInvoicePaymentMode || {});
37622
37598
  const createDedicatedInvoicePayment = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/`);
37623
37599
  const updateDedicatedInvoicePayment = put(({ businessId, invoiceId, invoicePaymentId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/${invoicePaymentId}`);
37624
- function buildKey$8({
37600
+ function buildKey$c({
37625
37601
  access_token: accessToken,
37626
37602
  apiUrl,
37627
37603
  businessId,
@@ -37706,7 +37682,7 @@ const useUpsertDedicatedInvoicePayment = (props) => {
37706
37682
  return updateInvoiceWithPayment(invoice, invoicePayment);
37707
37683
  }, [invoiceId]);
37708
37684
  const rawMutationResponse = useSWRMutation(
37709
- () => buildKey$8(__spreadProps(__spreadValues({}, data), {
37685
+ () => buildKey$c(__spreadProps(__spreadValues({}, data), {
37710
37686
  businessId,
37711
37687
  invoiceId,
37712
37688
  invoicePaymentId
@@ -38006,8 +37982,8 @@ const getClassnameForSubComponent = (className, suffix) => {
38006
37982
  };
38007
37983
  const METER_CLASS_NAME = "Layer__Meter";
38008
37984
  const Meter = forwardRef(
38009
- function Meter2(_cd, ref) {
38010
- var _dd = _cd, { className, label, meterOnly } = _dd, restProps = __objRest(_dd, ["className", "label", "meterOnly"]);
37985
+ function Meter2(_ed, ref) {
37986
+ var _fd = _ed, { className, label, meterOnly } = _fd, restProps = __objRest(_fd, ["className", "label", "meterOnly"]);
38011
37987
  return /* @__PURE__ */ jsx(Meter$1, __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, restProps), { className: classNames(METER_CLASS_NAME, className), ref }), meterOnly && { "aria-label": label }), { children: ({ percentage, valueText }) => /* @__PURE__ */ jsxs(VStack, { gap: "3xs", fluid: true, children: [
38012
37988
  !meterOnly && /* @__PURE__ */ jsxs(HStack, { justify: "space-between", children: [
38013
37989
  /* @__PURE__ */ jsx(Label, { slot: "label", children: label }),
@@ -38122,11 +38098,11 @@ const ProfitAndLossView = (props) => {
38122
38098
  const containerRef = useRef(null);
38123
38099
  return /* @__PURE__ */ jsx(Container, { name: COMPONENT_NAME$3, ref: containerRef, children: /* @__PURE__ */ jsx(ProfitAndLoss, { children: /* @__PURE__ */ jsx(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
38124
38100
  };
38125
- const ProfitAndLossPanel = (_ed) => {
38126
- var _fd = _ed, {
38101
+ const ProfitAndLossPanel = (_gd) => {
38102
+ var _hd = _gd, {
38127
38103
  containerRef,
38128
38104
  stringOverrides
38129
- } = _fd, props = __objRest(_fd, [
38105
+ } = _hd, props = __objRest(_hd, [
38130
38106
  "containerRef",
38131
38107
  "stringOverrides"
38132
38108
  ]);
@@ -38389,13 +38365,13 @@ function ExpandableDataTable({
38389
38365
  );
38390
38366
  }
38391
38367
  const UNIFIED_REPORT_TAG_KEY = "#unified-report";
38392
- function buildKey$7(_gd) {
38393
- var _hd = _gd, {
38368
+ function buildKey$b(_id) {
38369
+ var _jd = _id, {
38394
38370
  access_token: accessToken,
38395
38371
  apiUrl,
38396
38372
  businessId,
38397
38373
  report
38398
- } = _hd, dateParams = __objRest(_hd, [
38374
+ } = _jd, dateParams = __objRest(_jd, [
38399
38375
  "access_token",
38400
38376
  "apiUrl",
38401
38377
  "businessId",
@@ -38411,8 +38387,8 @@ function buildKey$7(_gd) {
38411
38387
  }, dateParams);
38412
38388
  }
38413
38389
  }
38414
- const getUnifiedReport = get((_id) => {
38415
- var _jd = _id, { businessId, report } = _jd, dateParams = __objRest(_jd, ["businessId", "report"]);
38390
+ const getUnifiedReport = get((_kd) => {
38391
+ var _ld = _kd, { businessId, report } = _ld, dateParams = __objRest(_ld, ["businessId", "report"]);
38416
38392
  const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
38417
38393
  return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
38418
38394
  });
@@ -38441,13 +38417,13 @@ class UnifiedReportSWRResponse {
38441
38417
  return this.swrResponse.mutate;
38442
38418
  }
38443
38419
  }
38444
- function useUnifiedReport(_kd) {
38445
- var _ld = _kd, { report } = _ld, dateParams = __objRest(_ld, ["report"]);
38420
+ function useUnifiedReport(_md) {
38421
+ var _nd = _md, { report } = _nd, dateParams = __objRest(_nd, ["report"]);
38446
38422
  const { data: auth } = useAuth();
38447
38423
  const { apiUrl } = useEnvironment();
38448
38424
  const { businessId } = useLayerContext();
38449
38425
  const swrResponse = useSWR(
38450
- () => buildKey$7(__spreadValues(__spreadProps(__spreadValues({}, auth), {
38426
+ () => buildKey$b(__spreadValues(__spreadProps(__spreadValues({}, auth), {
38451
38427
  apiUrl,
38452
38428
  businessId,
38453
38429
  report
@@ -38563,7 +38539,7 @@ class DownloadUnifiedReportSWRResponse {
38563
38539
  return this.swrResponse.error !== void 0;
38564
38540
  }
38565
38541
  }
38566
- function buildKey$6({
38542
+ function buildKey$a({
38567
38543
  access_token: accessToken,
38568
38544
  apiUrl,
38569
38545
  businessId,
@@ -38614,7 +38590,7 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
38614
38590
  const { businessId } = useLayerContext();
38615
38591
  const reportWithDateParams = useUnifiedReportWithDateParams();
38616
38592
  const rawMutationResponse = useSWRMutation(
38617
- () => buildKey$6(__spreadProps(__spreadValues({}, auth), {
38593
+ () => buildKey$a(__spreadProps(__spreadValues({}, auth), {
38618
38594
  businessId,
38619
38595
  reportWithDateParams
38620
38596
  })),
@@ -38990,7 +38966,7 @@ const useBills = () => {
38990
38966
  refetch
38991
38967
  };
38992
38968
  };
38993
- function buildKey$5({
38969
+ function buildKey$9({
38994
38970
  access_token: accessToken,
38995
38971
  apiUrl,
38996
38972
  businessId,
@@ -39124,7 +39100,7 @@ const useBillsRecordPayment = ({ refetchAllBills }) => {
39124
39100
  };
39125
39101
  }, [billsToPay, paymentDate, paymentMethod]);
39126
39102
  const createPaymentMutation = useSWRMutation(
39127
- () => buildKey$5({
39103
+ () => buildKey$9({
39128
39104
  access_token: auth == null ? void 0 : auth.access_token,
39129
39105
  apiUrl: auth == null ? void 0 : auth.apiUrl,
39130
39106
  businessId,
@@ -39453,7 +39429,7 @@ const BillsPaymentRecorded = ({
39453
39429
  ] })
39454
39430
  ] });
39455
39431
  };
39456
- function buildKey$4({
39432
+ function buildKey$8({
39457
39433
  access_token: accessToken,
39458
39434
  apiUrl,
39459
39435
  businessId,
@@ -39474,7 +39450,7 @@ const useUnpaidBillsByVendor = ({ vendorId }) => {
39474
39450
  const { data: auth } = useAuth();
39475
39451
  const { apiUrl } = useEnvironment();
39476
39452
  return useSWR(
39477
- () => buildKey$4(__spreadProps(__spreadValues({}, auth), {
39453
+ () => buildKey$8(__spreadProps(__spreadValues({}, auth), {
39478
39454
  apiUrl,
39479
39455
  businessId,
39480
39456
  vendorId
@@ -39972,19 +39948,19 @@ const VendorsProvider = ({ children }) => {
39972
39948
  const vendors = useVendors();
39973
39949
  return /* @__PURE__ */ jsx(VendorsContext.Provider, { value: vendors, children });
39974
39950
  };
39975
- const SelectVendor = (_md) => {
39976
- var _nd = _md, { withContext = true } = _nd, props = __objRest(_nd, ["withContext"]);
39951
+ const SelectVendor = (_od) => {
39952
+ var _pd = _od, { withContext = true } = _pd, props = __objRest(_pd, ["withContext"]);
39977
39953
  if (withContext) {
39978
39954
  return /* @__PURE__ */ jsx(VendorsProvider, { children: /* @__PURE__ */ jsx(SelectVendorContent, __spreadValues({}, props)) });
39979
39955
  }
39980
39956
  return /* @__PURE__ */ jsx(SelectVendorContent, __spreadValues({}, props));
39981
39957
  };
39982
- const SelectVendorContent = (_od) => {
39983
- var _pd = _od, {
39958
+ const SelectVendorContent = (_qd) => {
39959
+ var _rd = _qd, {
39984
39960
  value,
39985
39961
  onChange,
39986
39962
  placeholder = "Select vendor"
39987
- } = _pd, props = __objRest(_pd, [
39963
+ } = _rd, props = __objRest(_rd, [
39988
39964
  "value",
39989
39965
  "onChange",
39990
39966
  "placeholder"
@@ -40751,8 +40727,8 @@ const BillsTableWithPanel = ({
40751
40727
  }
40752
40728
  );
40753
40729
  };
40754
- const Bills = (_qd) => {
40755
- var _rd = _qd, { context = true } = _rd, props = __objRest(_rd, ["context"]);
40730
+ const Bills = (_sd) => {
40731
+ var _td = _sd, { context = true } = _td, props = __objRest(_td, ["context"]);
40756
40732
  if (context) {
40757
40733
  return /* @__PURE__ */ jsx(BillsProvider, { children: /* @__PURE__ */ jsx(BillsContent, __spreadValues({}, props)) });
40758
40734
  }
@@ -40810,8 +40786,8 @@ const getTimezoneDisplay = (date) => {
40810
40786
  };
40811
40787
  const LINK_CLASS_NAME = "Layer__UI__Link";
40812
40788
  const Link = forwardRef(
40813
- function Link2(_sd, ref) {
40814
- var _td = _sd, {
40789
+ function Link2(_ud, ref) {
40790
+ var _vd = _ud, {
40815
40791
  children,
40816
40792
  size = "md",
40817
40793
  ellipsis,
@@ -40820,7 +40796,7 @@ const Link = forwardRef(
40820
40796
  href,
40821
40797
  target,
40822
40798
  rel
40823
- } = _td, restProps = __objRest(_td, [
40799
+ } = _vd, restProps = __objRest(_vd, [
40824
40800
  "children",
40825
40801
  "size",
40826
40802
  "ellipsis",
@@ -41345,6 +41321,18 @@ const VehicleSchema = Schema.Struct({
41345
41321
  deletedAt: pipe(
41346
41322
  Schema.propertySignature(Schema.NullishOr(Schema.Date)),
41347
41323
  Schema.fromKey("deleted_at")
41324
+ ),
41325
+ archivedAt: pipe(
41326
+ Schema.propertySignature(Schema.NullishOr(Schema.Date)),
41327
+ Schema.fromKey("archived_at")
41328
+ ),
41329
+ isPrimary: pipe(
41330
+ Schema.propertySignature(Schema.Boolean),
41331
+ Schema.fromKey("is_primary")
41332
+ ),
41333
+ isEligibleForDeletion: pipe(
41334
+ Schema.propertySignature(Schema.Boolean),
41335
+ Schema.fromKey("is_eligible_for_deletion")
41348
41336
  )
41349
41337
  });
41350
41338
  Schema.Struct({
@@ -41352,7 +41340,8 @@ Schema.Struct({
41352
41340
  year: Schema.Number,
41353
41341
  licensePlate: Schema.String,
41354
41342
  vin: Schema.String,
41355
- description: Schema.String
41343
+ description: Schema.String,
41344
+ isPrimary: Schema.Boolean
41356
41345
  });
41357
41346
  const UpsertVehicleSchema = Schema.Struct({
41358
41347
  makeAndModel: pipe(
@@ -41365,7 +41354,11 @@ const UpsertVehicleSchema = Schema.Struct({
41365
41354
  Schema.fromKey("license_plate")
41366
41355
  ),
41367
41356
  vin: Schema.NullishOr(Schema.String),
41368
- description: Schema.NullishOr(Schema.String)
41357
+ description: Schema.NullishOr(Schema.String),
41358
+ isPrimary: pipe(
41359
+ Schema.propertySignature(Schema.Boolean),
41360
+ Schema.fromKey("is_primary")
41361
+ )
41369
41362
  });
41370
41363
  const CalendarDateFromSelf = Schema.declare(
41371
41364
  (input) => input instanceof CalendarDate
@@ -41512,6 +41505,7 @@ const TripsRouteStoreContext = createContext(
41512
41505
  selectedVehicle: null,
41513
41506
  purposeFilter: TripPurposeFilterValue.All
41514
41507
  },
41508
+ currentTripsPage: 0,
41515
41509
  setTableFilters: () => {
41516
41510
  },
41517
41511
  navigate: {
@@ -41519,6 +41513,10 @@ const TripsRouteStoreContext = createContext(
41519
41513
  },
41520
41514
  toVehicleManagement: () => {
41521
41515
  }
41516
+ },
41517
+ actions: {
41518
+ setCurrentTripsPage: () => {
41519
+ }
41522
41520
  }
41523
41521
  }))
41524
41522
  );
@@ -41536,6 +41534,15 @@ function useTripsNavigation() {
41536
41534
  const store = useContext(TripsRouteStoreContext);
41537
41535
  return useStore(store, (state) => state.navigate);
41538
41536
  }
41537
+ function useCurrentTripsPage() {
41538
+ const store = useContext(TripsRouteStoreContext);
41539
+ const currentTripsPage = useStore(store, (state) => state.currentTripsPage);
41540
+ const setCurrentTripsPage = useStore(store, (state) => state.actions.setCurrentTripsPage);
41541
+ return useMemo(
41542
+ () => ({ currentTripsPage, setCurrentTripsPage }),
41543
+ [currentTripsPage, setCurrentTripsPage]
41544
+ );
41545
+ }
41539
41546
  function TripsRouteStoreProvider(props) {
41540
41547
  const [store] = useState(
41541
41548
  () => createStore((set2) => ({
@@ -41548,6 +41555,7 @@ function TripsRouteStoreProvider(props) {
41548
41555
  selectedVehicle: null,
41549
41556
  purposeFilter: TripPurposeFilterValue.All
41550
41557
  },
41558
+ currentTripsPage: 0,
41551
41559
  setTableFilters: (patchFilters) => {
41552
41560
  set2((state) => ({
41553
41561
  tableFilters: __spreadValues(__spreadValues({}, state.tableFilters), patchFilters)
@@ -41570,65 +41578,28 @@ function TripsRouteStoreProvider(props) {
41570
41578
  }
41571
41579
  }));
41572
41580
  }
41581
+ },
41582
+ actions: {
41583
+ setCurrentTripsPage: (page) => {
41584
+ set2({ currentTripsPage: page });
41585
+ }
41573
41586
  }
41574
41587
  }))
41575
41588
  );
41576
41589
  return /* @__PURE__ */ jsx(TripsRouteStoreContext.Provider, { value: store, children: props.children });
41577
41590
  }
41578
- const getTripFormDefaultValues = (trip) => {
41579
- if (trip) {
41580
- return {
41581
- vehicle: trip.vehicle,
41582
- tripDate: trip.tripDate,
41583
- distance: trip.distance,
41584
- purpose: trip.purpose,
41585
- startAddress: trip.startAddress || "",
41586
- endAddress: trip.endAddress || "",
41587
- description: trip.description || ""
41588
- };
41589
- }
41590
- return {
41591
- vehicle: null,
41592
- tripDate: today(getLocalTimeZone()),
41593
- distance: BIG_DECIMAL_ZERO,
41594
- purpose: TripPurpose.Business,
41595
- startAddress: "",
41596
- endAddress: "",
41597
- description: ""
41598
- };
41599
- };
41600
- const validateTripForm = ({ trip }) => {
41601
- const { vehicle, tripDate, distance, purpose } = trip;
41602
- const errors = [];
41603
- if (tripDate === null) {
41604
- errors.push({ tripDate: "Trip date is a required field." });
41605
- }
41606
- if (tripDate && tripDate.compare(today(getLocalTimeZone())) > 0) {
41607
- errors.push({ tripDate: "Trip date cannot be in the future." });
41608
- }
41609
- if (!BigDecimal.isPositive(distance)) {
41610
- errors.push({ distance: "Distance must be greater than zero." });
41611
- }
41612
- if (!purpose) {
41613
- errors.push({ purpose: "Purpose is a required field." });
41614
- }
41615
- if (vehicle === null) {
41616
- errors.push({ vehicle: "Vehicle is a required field." });
41591
+ function useAutoResetPageIndex(filters, data) {
41592
+ const autoResetPageIndexRef = useRef(false);
41593
+ const prevFiltersRef = useRef(filters);
41594
+ if (prevFiltersRef.current !== filters) {
41595
+ autoResetPageIndexRef.current = true;
41596
+ prevFiltersRef.current = filters;
41617
41597
  }
41618
- return errors.length > 0 ? errors : null;
41619
- };
41620
- const convertTripFormToUpsertTrip = (form) => {
41621
- var _a;
41622
- return {
41623
- vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
41624
- tripDate: form.tripDate,
41625
- distance: form.distance,
41626
- purpose: form.purpose,
41627
- startAddress: form.startAddress.trim() || null,
41628
- endAddress: form.endAddress.trim() || null,
41629
- description: form.description.trim() || null
41630
- };
41631
- };
41598
+ useEffect(() => {
41599
+ autoResetPageIndexRef.current = false;
41600
+ }, [data]);
41601
+ return autoResetPageIndexRef;
41602
+ }
41632
41603
  const LIST_TRIPS_TAG_KEY = "#list-trips";
41633
41604
  const ListTripsResponseSchema = Schema.Struct({
41634
41605
  data: Schema.Array(TripSchema),
@@ -41752,6 +41723,243 @@ function useTripsGlobalCacheActions() {
41752
41723
  );
41753
41724
  return { patchTripByKey, forceReloadTrips };
41754
41725
  }
41726
+ const ListVehiclesResponseSchema = Schema.Struct({
41727
+ data: Schema.Array(VehicleSchema)
41728
+ });
41729
+ const listVehicles = get(({ businessId, allowArchived }) => {
41730
+ const parameters = toDefinedSearchParameters({ allowArchived });
41731
+ return `/v1/businesses/${businessId}/mileage/vehicles?${parameters}`;
41732
+ });
41733
+ const VEHICLES_TAG_KEY = "#list-vehicles";
41734
+ function buildKey$7({
41735
+ access_token: accessToken,
41736
+ apiUrl,
41737
+ businessId,
41738
+ allowArchived
41739
+ }) {
41740
+ if (accessToken && apiUrl) {
41741
+ return {
41742
+ accessToken,
41743
+ apiUrl,
41744
+ businessId,
41745
+ allowArchived,
41746
+ tags: [VEHICLES_TAG_KEY]
41747
+ };
41748
+ }
41749
+ }
41750
+ class ListVehiclesSWRResponse {
41751
+ constructor(swrResponse) {
41752
+ __publicField(this, "swrResponse");
41753
+ this.swrResponse = swrResponse;
41754
+ }
41755
+ get data() {
41756
+ var _a;
41757
+ return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
41758
+ }
41759
+ get isLoading() {
41760
+ return this.swrResponse.isLoading;
41761
+ }
41762
+ get isValidating() {
41763
+ return this.swrResponse.isValidating;
41764
+ }
41765
+ get isError() {
41766
+ return this.swrResponse.error !== void 0;
41767
+ }
41768
+ }
41769
+ function useListVehicles({ allowArchived } = {}) {
41770
+ const { data } = useAuth();
41771
+ const { businessId } = useLayerContext();
41772
+ const response = useSWR(
41773
+ () => buildKey$7(__spreadProps(__spreadValues({}, data), {
41774
+ businessId,
41775
+ allowArchived
41776
+ })),
41777
+ ({ accessToken, apiUrl, businessId: businessId2, allowArchived: allowArchived2 }) => listVehicles(
41778
+ apiUrl,
41779
+ accessToken,
41780
+ {
41781
+ params: {
41782
+ businessId: businessId2,
41783
+ allowArchived: allowArchived2
41784
+ }
41785
+ }
41786
+ )().then(Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
41787
+ );
41788
+ return new ListVehiclesSWRResponse(response);
41789
+ }
41790
+ const withUpdatedVehicle = (updated) => (vehicle) => vehicle.id === updated.id ? updated : vehicle;
41791
+ function useVehiclesGlobalCacheActions() {
41792
+ const { patchCache, forceReload } = useGlobalCacheActions();
41793
+ const patchVehicleByKey = useCallback(
41794
+ (updatedVehicle) => patchCache(
41795
+ (tags) => tags.includes(VEHICLES_TAG_KEY),
41796
+ (currentData) => {
41797
+ if (!currentData) return currentData;
41798
+ return __spreadProps(__spreadValues({}, currentData), {
41799
+ data: currentData.data.map(withUpdatedVehicle(updatedVehicle))
41800
+ });
41801
+ }
41802
+ ),
41803
+ [patchCache]
41804
+ );
41805
+ const forceReloadVehicles = useCallback(
41806
+ () => forceReload((tags) => tags.includes(VEHICLES_TAG_KEY)),
41807
+ [forceReload]
41808
+ );
41809
+ return { patchVehicleByKey, forceReloadVehicles };
41810
+ }
41811
+ const DELETE_TRIP_TAG_KEY = "#delete-trip";
41812
+ const deleteTrip = del(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
41813
+ function buildKey$6({
41814
+ access_token: accessToken,
41815
+ apiUrl,
41816
+ businessId,
41817
+ tripId
41818
+ }) {
41819
+ if (accessToken && apiUrl) {
41820
+ return {
41821
+ accessToken,
41822
+ apiUrl,
41823
+ businessId,
41824
+ tripId,
41825
+ tags: [DELETE_TRIP_TAG_KEY]
41826
+ };
41827
+ }
41828
+ }
41829
+ class DeleteTripSWRResponse {
41830
+ constructor(swrResponse) {
41831
+ __publicField(this, "swrResponse");
41832
+ this.swrResponse = swrResponse;
41833
+ }
41834
+ get trigger() {
41835
+ return this.swrResponse.trigger;
41836
+ }
41837
+ get isMutating() {
41838
+ return this.swrResponse.isMutating;
41839
+ }
41840
+ get isError() {
41841
+ return this.swrResponse.error !== void 0;
41842
+ }
41843
+ }
41844
+ const useDeleteTrip = ({ tripId }) => {
41845
+ const { data } = useAuth();
41846
+ const { businessId } = useLayerContext();
41847
+ const rawMutationResponse = useSWRMutation(
41848
+ () => buildKey$6(__spreadProps(__spreadValues({}, data), {
41849
+ businessId,
41850
+ tripId
41851
+ })),
41852
+ ({ accessToken, apiUrl, businessId: businessId2, tripId: tripId2 }) => {
41853
+ return deleteTrip(
41854
+ apiUrl,
41855
+ accessToken,
41856
+ { params: { businessId: businessId2, tripId: tripId2 } }
41857
+ );
41858
+ },
41859
+ {
41860
+ revalidate: false,
41861
+ throwOnError: true
41862
+ }
41863
+ );
41864
+ const mutationResponse = new DeleteTripSWRResponse(rawMutationResponse);
41865
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
41866
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
41867
+ const originalTrigger = mutationResponse.trigger;
41868
+ const stableProxiedTrigger = useCallback(
41869
+ (...triggerParameters) => __async(null, null, function* () {
41870
+ const triggerResult = yield originalTrigger(...triggerParameters);
41871
+ void forceReloadTrips();
41872
+ void forceReloadVehicles();
41873
+ return triggerResult;
41874
+ }),
41875
+ [originalTrigger, forceReloadTrips, forceReloadVehicles]
41876
+ );
41877
+ return new Proxy(mutationResponse, {
41878
+ get(target, prop) {
41879
+ if (prop === "trigger") {
41880
+ return stableProxiedTrigger;
41881
+ }
41882
+ return Reflect.get(target, prop);
41883
+ }
41884
+ });
41885
+ };
41886
+ function TripDeleteConfirmationModal({
41887
+ isOpen,
41888
+ onOpenChange,
41889
+ trip
41890
+ }) {
41891
+ const { trigger: deleteTrip2 } = useDeleteTrip({ tripId: trip.id });
41892
+ const onConfirm = useCallback(() => __async(null, null, function* () {
41893
+ yield deleteTrip2();
41894
+ }), [deleteTrip2]);
41895
+ return /* @__PURE__ */ jsx(
41896
+ BaseConfirmationModal,
41897
+ {
41898
+ isOpen,
41899
+ onOpenChange,
41900
+ title: "Delete this trip?",
41901
+ description: "This trip will be permanently deleted. This action cannot be undone.",
41902
+ onConfirm,
41903
+ confirmLabel: "Delete trip",
41904
+ cancelLabel: "Cancel",
41905
+ errorText: "Failed to delete trip. Please check your connection and try again."
41906
+ }
41907
+ );
41908
+ }
41909
+ const getTripFormDefaultValues = (trip) => {
41910
+ if (trip) {
41911
+ return {
41912
+ vehicle: trip.vehicle,
41913
+ tripDate: trip.tripDate,
41914
+ distance: trip.distance,
41915
+ purpose: trip.purpose,
41916
+ startAddress: trip.startAddress || "",
41917
+ endAddress: trip.endAddress || "",
41918
+ description: trip.description || ""
41919
+ };
41920
+ }
41921
+ return {
41922
+ vehicle: null,
41923
+ tripDate: today(getLocalTimeZone()),
41924
+ distance: BIG_DECIMAL_ZERO,
41925
+ purpose: TripPurpose.Business,
41926
+ startAddress: "",
41927
+ endAddress: "",
41928
+ description: ""
41929
+ };
41930
+ };
41931
+ const validateTripForm = ({ trip }) => {
41932
+ const { vehicle, tripDate, distance, purpose } = trip;
41933
+ const errors = [];
41934
+ if (tripDate === null) {
41935
+ errors.push({ tripDate: "Trip date is a required field." });
41936
+ }
41937
+ if (tripDate && tripDate.compare(today(getLocalTimeZone())) > 0) {
41938
+ errors.push({ tripDate: "Trip date cannot be in the future." });
41939
+ }
41940
+ if (!BigDecimal.isPositive(distance)) {
41941
+ errors.push({ distance: "Distance must be greater than zero." });
41942
+ }
41943
+ if (!purpose) {
41944
+ errors.push({ purpose: "Purpose is a required field." });
41945
+ }
41946
+ if (vehicle === null) {
41947
+ errors.push({ vehicle: "Vehicle is a required field." });
41948
+ }
41949
+ return errors.length > 0 ? errors : null;
41950
+ };
41951
+ const convertTripFormToUpsertTrip = (form) => {
41952
+ var _a;
41953
+ return {
41954
+ vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
41955
+ tripDate: form.tripDate,
41956
+ distance: form.distance,
41957
+ purpose: form.purpose,
41958
+ startAddress: form.startAddress.trim() || null,
41959
+ endAddress: form.endAddress.trim() || null,
41960
+ description: form.description.trim() || null
41961
+ };
41962
+ };
41755
41963
  const UPSERT_TRIP_TAG_KEY = "#upsert-trip";
41756
41964
  var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
41757
41965
  UpsertTripMode2["Create"] = "Create";
@@ -41760,7 +41968,7 @@ var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
41760
41968
  })(UpsertTripMode || {});
41761
41969
  const createTrip = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/trips`);
41762
41970
  const updateTrip = patch(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
41763
- function buildKey$3({
41971
+ function buildKey$5({
41764
41972
  access_token: accessToken,
41765
41973
  apiUrl,
41766
41974
  businessId,
@@ -41832,7 +42040,7 @@ const useUpsertTrip = (props) => {
41832
42040
  const { mode } = props;
41833
42041
  const tripId = mode === "Update" ? props.tripId : void 0;
41834
42042
  const rawMutationResponse = useSWRMutation(
41835
- () => buildKey$3(__spreadProps(__spreadValues({}, data), {
42043
+ () => buildKey$5(__spreadProps(__spreadValues({}, data), {
41836
42044
  businessId,
41837
42045
  tripId
41838
42046
  })),
@@ -41851,6 +42059,7 @@ const useUpsertTrip = (props) => {
41851
42059
  );
41852
42060
  const mutationResponse = new UpsertTripSWRResponse(rawMutationResponse);
41853
42061
  const { patchTripByKey, forceReloadTrips } = useTripsGlobalCacheActions();
42062
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
41854
42063
  const originalTrigger = mutationResponse.trigger;
41855
42064
  const stableProxiedTrigger = useCallback(
41856
42065
  (...triggerParameters) => __async(null, null, function* () {
@@ -41860,9 +42069,10 @@ const useUpsertTrip = (props) => {
41860
42069
  } else {
41861
42070
  void forceReloadTrips();
41862
42071
  }
42072
+ void forceReloadVehicles();
41863
42073
  return triggerResult;
41864
42074
  }),
41865
- [originalTrigger, mode, patchTripByKey, forceReloadTrips]
42075
+ [originalTrigger, mode, patchTripByKey, forceReloadTrips, forceReloadVehicles]
41866
42076
  );
41867
42077
  return new Proxy(mutationResponse, {
41868
42078
  get(target, prop) {
@@ -41965,67 +42175,6 @@ const TripPurposeComboBox = ({ value, onValueChange, isReadOnly, className }) =>
41965
42175
  )
41966
42176
  ] });
41967
42177
  };
41968
- const ListVehiclesResponseSchema = Schema.Struct({
41969
- data: Schema.Array(VehicleSchema)
41970
- });
41971
- const listVehicles = get(({ businessId }) => {
41972
- return `/v1/businesses/${businessId}/mileage/vehicles`;
41973
- });
41974
- const VEHICLES_TAG_KEY = "#list-vehicles";
41975
- function buildKey$2({
41976
- access_token: accessToken,
41977
- apiUrl,
41978
- businessId,
41979
- query
41980
- }) {
41981
- if (accessToken && apiUrl) {
41982
- return {
41983
- accessToken,
41984
- apiUrl,
41985
- businessId,
41986
- query,
41987
- tags: [VEHICLES_TAG_KEY]
41988
- };
41989
- }
41990
- }
41991
- class ListVehiclesSWRResponse {
41992
- constructor(swrResponse) {
41993
- __publicField(this, "swrResponse");
41994
- this.swrResponse = swrResponse;
41995
- }
41996
- get data() {
41997
- var _a;
41998
- return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
41999
- }
42000
- get isLoading() {
42001
- return this.swrResponse.isLoading;
42002
- }
42003
- get isValidating() {
42004
- return this.swrResponse.isValidating;
42005
- }
42006
- get isError() {
42007
- return this.swrResponse.error !== void 0;
42008
- }
42009
- }
42010
- function useListVehicles() {
42011
- const { data } = useAuth();
42012
- const { businessId } = useLayerContext();
42013
- const response = useSWR(
42014
- () => buildKey$2(__spreadProps(__spreadValues({}, data), {
42015
- businessId
42016
- })),
42017
- ({ accessToken, apiUrl, businessId: businessId2 }) => listVehicles(
42018
- apiUrl,
42019
- accessToken,
42020
- {
42021
- params: {
42022
- businessId: businessId2
42023
- }
42024
- }
42025
- )().then(Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
42026
- );
42027
- return new ListVehiclesSWRResponse(response);
42028
- }
42029
42178
  const getVehicleDisplayName = (vehicle) => `${vehicle.year} ${vehicle.makeAndModel}`;
42030
42179
  class VehicleAsOption {
42031
42180
  constructor(vehicle) {
@@ -42244,7 +42393,7 @@ const TripsTableHeaderMenu = () => {
42244
42393
  );
42245
42394
  };
42246
42395
  const COMPONENT_NAME = "TripsTable";
42247
- const getColumnConfig = (onSelectTrip) => ({
42396
+ const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => ({
42248
42397
  [
42249
42398
  "TripDate"
42250
42399
  /* TripDate */
@@ -42308,27 +42457,32 @@ const getColumnConfig = (onSelectTrip) => ({
42308
42457
  cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
42309
42458
  },
42310
42459
  [
42311
- "Expand"
42312
- /* Expand */
42460
+ "Actions"
42461
+ /* Actions */
42313
42462
  ]: {
42314
- id: "Expand",
42315
- cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
42463
+ id: "Actions",
42464
+ cell: (row) => /* @__PURE__ */ jsxs(HStack, { gap: "3xs", children: [
42465
+ /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
42466
+ /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
42467
+ ] })
42316
42468
  }
42317
42469
  });
42318
42470
  const TripsTable = () => {
42319
42471
  var _a;
42320
42472
  const [isTripDrawerOpen, setIsTripDrawerOpen] = useState(false);
42321
42473
  const [selectedTrip, setSelectedTrip] = useState(null);
42474
+ const [tripToDelete, setTripToDelete] = useState(null);
42322
42475
  const { tableFilters, setTableFilters } = useTripsTableFilters();
42323
42476
  const { query, selectedVehicle, purposeFilter } = tableFilters;
42477
+ const { currentTripsPage, setCurrentTripsPage } = useCurrentTripsPage();
42324
42478
  const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: query });
42325
42479
  useEffect(() => {
42326
42480
  setTableFilters({ query: searchQuery });
42327
42481
  }, [searchQuery, setTableFilters]);
42328
42482
  const filterParams = useMemo(() => {
42329
42483
  const params = {};
42330
- if (searchQuery) {
42331
- params.query = searchQuery;
42484
+ if (query) {
42485
+ params.query = query;
42332
42486
  }
42333
42487
  if (selectedVehicle) {
42334
42488
  params.vehicleId = selectedVehicle.id;
@@ -42337,9 +42491,10 @@ const TripsTable = () => {
42337
42491
  params.purpose = purposeFilter;
42338
42492
  }
42339
42493
  return params;
42340
- }, [searchQuery, selectedVehicle, purposeFilter]);
42494
+ }, [query, selectedVehicle, purposeFilter]);
42341
42495
  const { data, isLoading, isError, size, setSize } = useListTrips(filterParams);
42342
42496
  const trips = useMemo(() => data == null ? void 0 : data.flatMap(({ data: data2 }) => data2), [data]);
42497
+ const autoResetPageIndexRef = useAutoResetPageIndex(filterParams, data);
42343
42498
  const paginationMeta = (_a = data == null ? void 0 : data[data.length - 1]) == null ? void 0 : _a.meta.pagination;
42344
42499
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
42345
42500
  const fetchMore = useCallback(() => {
@@ -42351,17 +42506,23 @@ const TripsTable = () => {
42351
42506
  setSelectedTrip(trip);
42352
42507
  setIsTripDrawerOpen(true);
42353
42508
  }, []);
42509
+ const onDeleteTrip = useCallback((trip) => {
42510
+ setTripToDelete(trip);
42511
+ }, []);
42354
42512
  const onRecordTrip = useCallback(() => {
42355
42513
  setSelectedTrip(null);
42356
42514
  setIsTripDrawerOpen(true);
42357
42515
  }, []);
42358
42516
  const paginationProps = useMemo(() => {
42359
42517
  return {
42518
+ initialPage: currentTripsPage,
42519
+ onSetPage: setCurrentTripsPage,
42360
42520
  pageSize: 20,
42361
42521
  hasMore,
42362
- fetchMore
42522
+ fetchMore,
42523
+ autoResetPageIndexRef
42363
42524
  };
42364
- }, [fetchMore, hasMore]);
42525
+ }, [currentTripsPage, setCurrentTripsPage, fetchMore, hasMore, autoResetPageIndexRef]);
42365
42526
  const handlePurposeFilterChange = useCallback((newPurposeFilter) => {
42366
42527
  setTableFilters({ purposeFilter: newPurposeFilter });
42367
42528
  }, [setTableFilters]);
@@ -42412,7 +42573,7 @@ const TripsTable = () => {
42412
42573
  spacing: true
42413
42574
  }
42414
42575
  );
42415
- const columnConfig = useMemo(() => getColumnConfig(onSelectTrip), [onSelectTrip]);
42576
+ const columnConfig = useMemo(() => getColumnConfig({ onSelectTrip, onDeleteTrip }), [onSelectTrip, onDeleteTrip]);
42416
42577
  const HeaderFilters = useCallback(() => /* @__PURE__ */ jsxs(HStack, { gap: "sm", align: "center", children: [
42417
42578
  /* @__PURE__ */ jsx(PurposeToggle, {}),
42418
42579
  /* @__PURE__ */ jsx(VehicleFilter, {})
@@ -42481,6 +42642,18 @@ const TripsTable = () => {
42481
42642
  )
42482
42643
  ] })
42483
42644
  }
42645
+ ),
42646
+ tripToDelete && /* @__PURE__ */ jsx(
42647
+ TripDeleteConfirmationModal,
42648
+ {
42649
+ isOpen: !!tripToDelete,
42650
+ onOpenChange: (isOpen) => {
42651
+ if (!isOpen) {
42652
+ setTripToDelete(null);
42653
+ }
42654
+ },
42655
+ trip: tripToDelete
42656
+ }
42484
42657
  )
42485
42658
  ] });
42486
42659
  };
@@ -42491,7 +42664,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
42491
42664
  year: vehicle.year,
42492
42665
  licensePlate: vehicle.licensePlate || "",
42493
42666
  vin: vehicle.vin || "",
42494
- description: vehicle.description || ""
42667
+ description: vehicle.description || "",
42668
+ isPrimary: vehicle.isPrimary
42495
42669
  };
42496
42670
  }
42497
42671
  return {
@@ -42499,7 +42673,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
42499
42673
  year: Number.NaN,
42500
42674
  licensePlate: "",
42501
42675
  vin: "",
42502
- description: ""
42676
+ description: "",
42677
+ isPrimary: false
42503
42678
  };
42504
42679
  };
42505
42680
  const validateVehicleForm = ({ vehicle }) => {
@@ -42523,7 +42698,8 @@ const convertVehicleFormToUpsertVehicle = (form) => {
42523
42698
  year: form.year,
42524
42699
  licensePlate: form.licensePlate.trim() || null,
42525
42700
  vin: form.vin.trim() || null,
42526
- description: form.description.trim() || null
42701
+ description: form.description.trim() || null,
42702
+ isPrimary: form.isPrimary
42527
42703
  };
42528
42704
  };
42529
42705
  const UPSERT_VEHICLE_TAG_KEY = "#upsert-vehicle";
@@ -42534,7 +42710,7 @@ var UpsertVehicleMode = /* @__PURE__ */ ((UpsertVehicleMode2) => {
42534
42710
  })(UpsertVehicleMode || {});
42535
42711
  const createVehicle = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/vehicles`);
42536
42712
  const updateVehicle = patch(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
42537
- function buildKey$1({
42713
+ function buildKey$4({
42538
42714
  access_token: accessToken,
42539
42715
  apiUrl,
42540
42716
  businessId,
@@ -42553,6 +42729,24 @@ function buildKey$1({
42553
42729
  const UpsertVehicleReturnSchema = Schema.Struct({
42554
42730
  data: VehicleSchema
42555
42731
  });
42732
+ class UpsertVehicleSWRResponse {
42733
+ constructor(swrResponse) {
42734
+ __publicField(this, "swrResponse");
42735
+ this.swrResponse = swrResponse;
42736
+ }
42737
+ get trigger() {
42738
+ return this.swrResponse.trigger;
42739
+ }
42740
+ get isMutating() {
42741
+ return this.swrResponse.isMutating;
42742
+ }
42743
+ get data() {
42744
+ return this.swrResponse.data;
42745
+ }
42746
+ get error() {
42747
+ return this.swrResponse.error;
42748
+ }
42749
+ }
42556
42750
  const CreateParamsSchema = Schema.Struct({
42557
42751
  businessId: Schema.UUID,
42558
42752
  vehicleId: Schema.Undefined
@@ -42586,11 +42780,10 @@ function getRequestFn(mode, params) {
42586
42780
  const useUpsertVehicle = (props) => {
42587
42781
  const { data } = useAuth();
42588
42782
  const { businessId } = useLayerContext();
42589
- const { mutate } = useSWRConfig();
42590
42783
  const { mode } = props;
42591
42784
  const vehicleId = mode === "Update" ? props.vehicleId : void 0;
42592
42785
  const rawMutationResponse = useSWRMutation(
42593
- () => buildKey$1(__spreadProps(__spreadValues({}, data), {
42786
+ () => buildKey$4(__spreadProps(__spreadValues({}, data), {
42594
42787
  businessId,
42595
42788
  vehicleId
42596
42789
  })),
@@ -42608,43 +42801,31 @@ const useUpsertVehicle = (props) => {
42608
42801
  }
42609
42802
  );
42610
42803
  const mutationResponse = new UpsertVehicleSWRResponse(rawMutationResponse);
42804
+ const { patchVehicleByKey, forceReloadVehicles } = useVehiclesGlobalCacheActions();
42805
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
42611
42806
  const originalTrigger = mutationResponse.trigger;
42612
42807
  const stableProxiedTrigger = useCallback(
42613
42808
  (...triggerParameters) => __async(null, null, function* () {
42614
42809
  const triggerResult = yield originalTrigger(...triggerParameters);
42615
- void mutate((key) => {
42616
- if (typeof key === "object" && key !== null && "tags" in key) {
42617
- const tags = key.tags;
42618
- return tags.includes(VEHICLES_TAG_KEY);
42619
- }
42620
- return false;
42621
- });
42810
+ if (mode === "Update") {
42811
+ void patchVehicleByKey(triggerResult.data);
42812
+ void forceReloadTrips();
42813
+ } else {
42814
+ void forceReloadVehicles();
42815
+ }
42622
42816
  return triggerResult;
42623
42817
  }),
42624
- [originalTrigger, mutate]
42818
+ [originalTrigger, mode, patchVehicleByKey, forceReloadTrips, forceReloadVehicles]
42625
42819
  );
42626
- return __spreadProps(__spreadValues({}, mutationResponse), {
42627
- trigger: stableProxiedTrigger
42820
+ return new Proxy(mutationResponse, {
42821
+ get(target, prop) {
42822
+ if (prop === "trigger") {
42823
+ return stableProxiedTrigger;
42824
+ }
42825
+ return Reflect.get(target, prop);
42826
+ }
42628
42827
  });
42629
42828
  };
42630
- class UpsertVehicleSWRResponse {
42631
- constructor(swrResponse) {
42632
- __publicField(this, "swrResponse");
42633
- this.swrResponse = swrResponse;
42634
- }
42635
- get trigger() {
42636
- return this.swrResponse.trigger;
42637
- }
42638
- get isMutating() {
42639
- return this.swrResponse.isMutating;
42640
- }
42641
- get data() {
42642
- return this.swrResponse.data;
42643
- }
42644
- get error() {
42645
- return this.swrResponse.error;
42646
- }
42647
- }
42648
42829
  const useVehicleForm = (props) => {
42649
42830
  const [submitError, setSubmitError] = useState(void 0);
42650
42831
  const { onSuccess, vehicle } = props;
@@ -42760,6 +42941,15 @@ const VehicleForm = (props) => {
42760
42941
  className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__Description`
42761
42942
  }
42762
42943
  ) }),
42944
+ /* @__PURE__ */ jsx(form.AppField, { name: "isPrimary", children: (field) => /* @__PURE__ */ jsx(
42945
+ field.FormSwitchField,
42946
+ {
42947
+ label: "Set as primary vehicle",
42948
+ inline: true,
42949
+ isReadOnly,
42950
+ className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__IsPrimary`
42951
+ }
42952
+ ) }),
42763
42953
  /* @__PURE__ */ jsx(VStack, { justify: "end", className: `${VEHICLE_FORM_CSS_PREFIX}__Submit`, children: /* @__PURE__ */ jsx(form.Subscribe, { selector: (state) => [state.canSubmit, state.isSubmitting], children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ jsx(
42764
42954
  Button,
42765
42955
  {
@@ -42774,6 +42964,309 @@ const VehicleForm = (props) => {
42774
42964
  ) }) })
42775
42965
  ] });
42776
42966
  };
42967
+ const ARCHIVE_VEHICLE_TAG_KEY = "#archive-vehicle";
42968
+ const ArchiveVehicleReturnSchema = Schema.Struct({
42969
+ data: VehicleSchema
42970
+ });
42971
+ const archiveVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/archive`);
42972
+ function buildKey$3({
42973
+ access_token: accessToken,
42974
+ apiUrl,
42975
+ businessId,
42976
+ vehicleId
42977
+ }) {
42978
+ if (accessToken && apiUrl) {
42979
+ return {
42980
+ accessToken,
42981
+ apiUrl,
42982
+ businessId,
42983
+ vehicleId,
42984
+ tags: [ARCHIVE_VEHICLE_TAG_KEY]
42985
+ };
42986
+ }
42987
+ }
42988
+ class ArchiveVehicleSWRResponse {
42989
+ constructor(swrResponse) {
42990
+ __publicField(this, "swrResponse");
42991
+ this.swrResponse = swrResponse;
42992
+ }
42993
+ get data() {
42994
+ return this.swrResponse.data;
42995
+ }
42996
+ get trigger() {
42997
+ return this.swrResponse.trigger;
42998
+ }
42999
+ get isMutating() {
43000
+ return this.swrResponse.isMutating;
43001
+ }
43002
+ get isError() {
43003
+ return this.swrResponse.error !== void 0;
43004
+ }
43005
+ }
43006
+ const useArchiveVehicle = ({ vehicleId }) => {
43007
+ const { data } = useAuth();
43008
+ const { businessId } = useLayerContext();
43009
+ const rawMutationResponse = useSWRMutation(
43010
+ () => buildKey$3(__spreadProps(__spreadValues({}, data), {
43011
+ businessId,
43012
+ vehicleId
43013
+ })),
43014
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43015
+ return archiveVehicle(
43016
+ apiUrl,
43017
+ accessToken,
43018
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43019
+ ).then(Schema.decodeUnknownPromise(ArchiveVehicleReturnSchema));
43020
+ },
43021
+ {
43022
+ revalidate: false,
43023
+ throwOnError: true
43024
+ }
43025
+ );
43026
+ const mutationResponse = new ArchiveVehicleSWRResponse(rawMutationResponse);
43027
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
43028
+ const originalTrigger = mutationResponse.trigger;
43029
+ const stableProxiedTrigger = useCallback(
43030
+ (...triggerParameters) => __async(null, null, function* () {
43031
+ const triggerResult = yield originalTrigger(...triggerParameters);
43032
+ void patchVehicleByKey(triggerResult.data);
43033
+ return triggerResult;
43034
+ }),
43035
+ [originalTrigger, patchVehicleByKey]
43036
+ );
43037
+ return new Proxy(mutationResponse, {
43038
+ get(target, prop) {
43039
+ if (prop === "trigger") {
43040
+ return stableProxiedTrigger;
43041
+ }
43042
+ return Reflect.get(target, prop);
43043
+ }
43044
+ });
43045
+ };
43046
+ function VehicleArchiveConfirmationModal({
43047
+ isOpen,
43048
+ onOpenChange,
43049
+ vehicle
43050
+ }) {
43051
+ const { trigger: archiveVehicle2 } = useArchiveVehicle({ vehicleId: vehicle.id });
43052
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43053
+ yield archiveVehicle2();
43054
+ }), [archiveVehicle2]);
43055
+ const vehicleName = getVehicleDisplayName(vehicle);
43056
+ return /* @__PURE__ */ jsx(
43057
+ BaseConfirmationModal,
43058
+ {
43059
+ isOpen,
43060
+ onOpenChange,
43061
+ title: "Archive this vehicle?",
43062
+ description: `${vehicleName} will be hidden from your active vehicles list. You can reactivate it at any time.`,
43063
+ onConfirm,
43064
+ confirmLabel: "Archive vehicle",
43065
+ cancelLabel: "Cancel",
43066
+ errorText: "Failed to archive vehicle. Please check your connection and try again."
43067
+ }
43068
+ );
43069
+ }
43070
+ const DELETE_VEHICLE_TAG_KEY = "#delete-vehicle";
43071
+ const deleteVehicle = del(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
43072
+ function buildKey$2({
43073
+ access_token: accessToken,
43074
+ apiUrl,
43075
+ businessId,
43076
+ vehicleId
43077
+ }) {
43078
+ if (accessToken && apiUrl) {
43079
+ return {
43080
+ accessToken,
43081
+ apiUrl,
43082
+ businessId,
43083
+ vehicleId,
43084
+ tags: [DELETE_VEHICLE_TAG_KEY]
43085
+ };
43086
+ }
43087
+ }
43088
+ class DeleteVehicleSWRResponse {
43089
+ constructor(swrResponse) {
43090
+ __publicField(this, "swrResponse");
43091
+ this.swrResponse = swrResponse;
43092
+ }
43093
+ get trigger() {
43094
+ return this.swrResponse.trigger;
43095
+ }
43096
+ get isMutating() {
43097
+ return this.swrResponse.isMutating;
43098
+ }
43099
+ get isError() {
43100
+ return this.swrResponse.error !== void 0;
43101
+ }
43102
+ }
43103
+ const useDeleteVehicle = ({ vehicleId }) => {
43104
+ const { data } = useAuth();
43105
+ const { businessId } = useLayerContext();
43106
+ const rawMutationResponse = useSWRMutation(
43107
+ () => buildKey$2(__spreadProps(__spreadValues({}, data), {
43108
+ businessId,
43109
+ vehicleId
43110
+ })),
43111
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43112
+ return deleteVehicle(
43113
+ apiUrl,
43114
+ accessToken,
43115
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43116
+ );
43117
+ },
43118
+ {
43119
+ revalidate: false,
43120
+ throwOnError: true
43121
+ }
43122
+ );
43123
+ const mutationResponse = new DeleteVehicleSWRResponse(rawMutationResponse);
43124
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
43125
+ const originalTrigger = mutationResponse.trigger;
43126
+ const stableProxiedTrigger = useCallback(
43127
+ (...triggerParameters) => __async(null, null, function* () {
43128
+ const triggerResult = yield originalTrigger(...triggerParameters);
43129
+ void forceReloadVehicles();
43130
+ return triggerResult;
43131
+ }),
43132
+ [originalTrigger, forceReloadVehicles]
43133
+ );
43134
+ return new Proxy(mutationResponse, {
43135
+ get(target, prop) {
43136
+ if (prop === "trigger") {
43137
+ return stableProxiedTrigger;
43138
+ }
43139
+ return Reflect.get(target, prop);
43140
+ }
43141
+ });
43142
+ };
43143
+ function VehicleDeleteConfirmationModal({
43144
+ isOpen,
43145
+ onOpenChange,
43146
+ vehicle
43147
+ }) {
43148
+ const { trigger: deleteVehicle2 } = useDeleteVehicle({ vehicleId: vehicle.id });
43149
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43150
+ yield deleteVehicle2();
43151
+ }), [deleteVehicle2]);
43152
+ const vehicleName = getVehicleDisplayName(vehicle);
43153
+ return /* @__PURE__ */ jsx(
43154
+ BaseConfirmationModal,
43155
+ {
43156
+ isOpen,
43157
+ onOpenChange,
43158
+ title: "Delete this vehicle?",
43159
+ description: `${vehicleName} will be permanently deleted. This action cannot be undone.`,
43160
+ onConfirm,
43161
+ confirmLabel: "Delete vehicle",
43162
+ cancelLabel: "Cancel",
43163
+ errorText: "Failed to delete vehicle. Please check your connection and try again."
43164
+ }
43165
+ );
43166
+ }
43167
+ const REACTIVATE_VEHICLE_TAG_KEY = "#reactivate-vehicle";
43168
+ const ReactivateVehicleReturnSchema = Schema.Struct({
43169
+ data: VehicleSchema
43170
+ });
43171
+ const reactivateVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/reactivate`);
43172
+ function buildKey$1({
43173
+ access_token: accessToken,
43174
+ apiUrl,
43175
+ businessId,
43176
+ vehicleId
43177
+ }) {
43178
+ if (accessToken && apiUrl) {
43179
+ return {
43180
+ accessToken,
43181
+ apiUrl,
43182
+ businessId,
43183
+ vehicleId,
43184
+ tags: [REACTIVATE_VEHICLE_TAG_KEY]
43185
+ };
43186
+ }
43187
+ }
43188
+ class ReactivateVehicleSWRResponse {
43189
+ constructor(swrResponse) {
43190
+ __publicField(this, "swrResponse");
43191
+ this.swrResponse = swrResponse;
43192
+ }
43193
+ get data() {
43194
+ return this.swrResponse.data;
43195
+ }
43196
+ get trigger() {
43197
+ return this.swrResponse.trigger;
43198
+ }
43199
+ get isMutating() {
43200
+ return this.swrResponse.isMutating;
43201
+ }
43202
+ get isError() {
43203
+ return this.swrResponse.error !== void 0;
43204
+ }
43205
+ }
43206
+ const useReactivateVehicle = ({ vehicleId }) => {
43207
+ const { data } = useAuth();
43208
+ const { businessId } = useLayerContext();
43209
+ const rawMutationResponse = useSWRMutation(
43210
+ () => buildKey$1(__spreadProps(__spreadValues({}, data), {
43211
+ businessId,
43212
+ vehicleId
43213
+ })),
43214
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43215
+ return reactivateVehicle(
43216
+ apiUrl,
43217
+ accessToken,
43218
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43219
+ ).then(Schema.decodeUnknownPromise(ReactivateVehicleReturnSchema));
43220
+ },
43221
+ {
43222
+ revalidate: false,
43223
+ throwOnError: true
43224
+ }
43225
+ );
43226
+ const mutationResponse = new ReactivateVehicleSWRResponse(rawMutationResponse);
43227
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
43228
+ const originalTrigger = mutationResponse.trigger;
43229
+ const stableProxiedTrigger = useCallback(
43230
+ (...triggerParameters) => __async(null, null, function* () {
43231
+ const triggerResult = yield originalTrigger(...triggerParameters);
43232
+ void patchVehicleByKey(triggerResult.data);
43233
+ return triggerResult;
43234
+ }),
43235
+ [originalTrigger, patchVehicleByKey]
43236
+ );
43237
+ return new Proxy(mutationResponse, {
43238
+ get(target, prop) {
43239
+ if (prop === "trigger") {
43240
+ return stableProxiedTrigger;
43241
+ }
43242
+ return Reflect.get(target, prop);
43243
+ }
43244
+ });
43245
+ };
43246
+ function VehicleReactivateConfirmationModal({
43247
+ isOpen,
43248
+ onOpenChange,
43249
+ vehicle
43250
+ }) {
43251
+ const { trigger: reactivateVehicle2 } = useReactivateVehicle({ vehicleId: vehicle.id });
43252
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43253
+ yield reactivateVehicle2();
43254
+ }), [reactivateVehicle2]);
43255
+ const vehicleName = getVehicleDisplayName(vehicle);
43256
+ return /* @__PURE__ */ jsx(
43257
+ BaseConfirmationModal,
43258
+ {
43259
+ isOpen,
43260
+ onOpenChange,
43261
+ title: "Reactivate this vehicle?",
43262
+ description: `${vehicleName} will be restored to your active vehicles list and available for tracking trips.`,
43263
+ onConfirm,
43264
+ confirmLabel: "Reactivate vehicle",
43265
+ cancelLabel: "Cancel",
43266
+ errorText: "Failed to reactivate vehicle. Please check your connection and try again."
43267
+ }
43268
+ );
43269
+ }
42777
43270
  const VEHICLE_CARD_FIELDS = [
42778
43271
  { label: "Make and model", key: "makeAndModel" },
42779
43272
  { label: "Year", key: "year" },
@@ -42782,20 +43275,73 @@ const VEHICLE_CARD_FIELDS = [
42782
43275
  { label: "Description", key: "description" }
42783
43276
  ];
42784
43277
  const VehicleCard = ({ vehicle, onEdit }) => {
42785
- return /* @__PURE__ */ jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", pi: "md", pb: "md", children: [
42786
- /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
42787
- /* @__PURE__ */ jsx(Heading$1, { size: "sm", ellipsis: true, children: getVehicleDisplayName(vehicle) }),
42788
- /* @__PURE__ */ jsx(Car, { size: 20, className: "Layer__VehicleCard__icon" })
42789
- ] }),
42790
- /* @__PURE__ */ jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxs(HStack, { justify: "space-between", gap: "md", children: [
42791
- /* @__PURE__ */ jsx(Span, { size: "sm", variant: "subtle", children: label }),
42792
- /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
42793
- ] }, key)) }),
42794
- /* @__PURE__ */ jsx(Button, { variant: "text", onPress: () => onEdit(vehicle), children: "Edit vehicle" })
42795
- ] }) });
43278
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
43279
+ const [isArchiveModalOpen, setIsArchiveModalOpen] = useState(false);
43280
+ const [isReactivateModalOpen, setIsReactivateModalOpen] = useState(false);
43281
+ const vehicleName = getVehicleDisplayName(vehicle);
43282
+ const isArchived = vehicle.archivedAt !== null && vehicle.archivedAt !== void 0;
43283
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
43284
+ /* @__PURE__ */ jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxs(VStack, { pi: "md", pbs: "md", pbe: "xs", children: [
43285
+ /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
43286
+ /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
43287
+ /* @__PURE__ */ jsxs(HStack, { gap: "xs", className: "Layer__VehicleCard__Header", children: [
43288
+ /* @__PURE__ */ jsx(Heading$1, { size: "sm", ellipsis: true, children: vehicleName }),
43289
+ vehicle.isPrimary && /* @__PURE__ */ jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.INFO, children: "Primary" }),
43290
+ isArchived && /* @__PURE__ */ jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.WARNING, children: "Archived" })
43291
+ ] }),
43292
+ /* @__PURE__ */ jsx(Car, { size: 20, className: "Layer__VehicleCard__Icon" })
43293
+ ] }),
43294
+ /* @__PURE__ */ jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxs(HStack, { justify: "space-between", gap: "md", children: [
43295
+ /* @__PURE__ */ jsx(Span, { size: "sm", variant: "subtle", children: label }),
43296
+ /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
43297
+ ] }, key)) })
43298
+ ] }),
43299
+ /* @__PURE__ */ jsx(VStack, { pbs: "md", pbe: "xs", children: /* @__PURE__ */ jsx(Separator, {}) }),
43300
+ /* @__PURE__ */ jsxs(HStack, { gap: "3xs", justify: "end", children: [
43301
+ !isArchived && /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => onEdit(vehicle), children: [
43302
+ /* @__PURE__ */ jsx(Edit, { size: 16 }),
43303
+ "Edit"
43304
+ ] }),
43305
+ isArchived ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsReactivateModalOpen(true), children: [
43306
+ /* @__PURE__ */ jsx(RotateCcw, { size: 16 }),
43307
+ "Reactivate"
43308
+ ] }) : vehicle.isEligibleForDeletion ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsDeleteModalOpen(true), children: [
43309
+ /* @__PURE__ */ jsx(Trash2, { size: 16 }),
43310
+ "Delete"
43311
+ ] }) : /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsArchiveModalOpen(true), children: [
43312
+ /* @__PURE__ */ jsx(Archive, { size: 16 }),
43313
+ "Archive"
43314
+ ] })
43315
+ ] })
43316
+ ] }) }),
43317
+ /* @__PURE__ */ jsx(
43318
+ VehicleDeleteConfirmationModal,
43319
+ {
43320
+ isOpen: isDeleteModalOpen,
43321
+ onOpenChange: setIsDeleteModalOpen,
43322
+ vehicle
43323
+ }
43324
+ ),
43325
+ /* @__PURE__ */ jsx(
43326
+ VehicleArchiveConfirmationModal,
43327
+ {
43328
+ isOpen: isArchiveModalOpen,
43329
+ onOpenChange: setIsArchiveModalOpen,
43330
+ vehicle
43331
+ }
43332
+ ),
43333
+ /* @__PURE__ */ jsx(
43334
+ VehicleReactivateConfirmationModal,
43335
+ {
43336
+ isOpen: isReactivateModalOpen,
43337
+ onOpenChange: setIsReactivateModalOpen,
43338
+ vehicle
43339
+ }
43340
+ )
43341
+ ] });
42796
43342
  };
42797
- const VehicleManagementGrid = ({ onEditVehicle }) => {
42798
- const { data, isLoading, isError } = useListVehicles();
43343
+ const VehicleManagementGrid = ({ onEditVehicle, showArchived }) => {
43344
+ const { data, isLoading, isError } = useListVehicles({ allowArchived: showArchived });
42799
43345
  const vehicles = useMemo(() => data ? asMutable(data) : void 0, [data]);
42800
43346
  if (isLoading) {
42801
43347
  return /* @__PURE__ */ jsx(VStack, { align: "center", justify: "center", pi: "lg", pb: "lg", children: /* @__PURE__ */ jsx(Loader, {}) });
@@ -42825,9 +43371,12 @@ const VehicleManagementGrid = ({ onEditVehicle }) => {
42825
43371
  }
42826
43372
  return /* @__PURE__ */ jsx(HStack, { className: "Layer__VehicleManagementGrid", children: vehicles.map((vehicle) => /* @__PURE__ */ jsx(VehicleCard, { vehicle, onEdit: onEditVehicle }, vehicle.id)) });
42827
43373
  };
42828
- const VehicleManagementDetailHeader = ({ onAddVehicle }) => {
42829
- return /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
42830
- /* @__PURE__ */ jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
43374
+ const VehicleManagementDetailHeader = ({ onAddVehicle, showArchived, onShowArchivedChange }) => {
43375
+ return /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", gap: "3xl", children: [
43376
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "center", children: [
43377
+ /* @__PURE__ */ jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
43378
+ /* @__PURE__ */ jsx(Switch, { isSelected: showArchived, onChange: onShowArchivedChange, children: /* @__PURE__ */ jsx(Span, { size: "sm", noWrap: true, children: "Show archived" }) })
43379
+ ] }),
42831
43380
  /* @__PURE__ */ jsxs(Button, { variant: "solid", onPress: onAddVehicle, children: [
42832
43381
  "Add Vehicle",
42833
43382
  /* @__PURE__ */ jsx(Plus$1, { size: 14 })
@@ -42838,6 +43387,7 @@ const VehicleManagementDetail = () => {
42838
43387
  const { toTripsTable } = useTripsNavigation();
42839
43388
  const [isVehicleDrawerOpen, setIsVehicleDrawerOpen] = useState(false);
42840
43389
  const [selectedVehicle, setSelectedVehicle] = useState(void 0);
43390
+ const [showArchived, setShowArchived] = useState(false);
42841
43391
  const handleAddVehicle = useCallback(() => {
42842
43392
  setSelectedVehicle(void 0);
42843
43393
  setIsVehicleDrawerOpen(true);
@@ -42850,9 +43400,20 @@ const VehicleManagementDetail = () => {
42850
43400
  setIsVehicleDrawerOpen(false);
42851
43401
  setSelectedVehicle(void 0);
42852
43402
  }, []);
42853
- const Header3 = useCallback(() => {
42854
- return /* @__PURE__ */ jsx(VehicleManagementDetailHeader, { onAddVehicle: handleAddVehicle });
42855
- }, [handleAddVehicle]);
43403
+ const stateRef = useRef({ showArchived, setShowArchived, handleAddVehicle });
43404
+ stateRef.current = { showArchived, setShowArchived, handleAddVehicle };
43405
+ const HeaderRef = useRef(() => {
43406
+ const { showArchived: currentShowArchived, setShowArchived: currentSetShowArchived, handleAddVehicle: currentHandleAddVehicle } = stateRef.current;
43407
+ return /* @__PURE__ */ jsx(
43408
+ VehicleManagementDetailHeader,
43409
+ {
43410
+ onAddVehicle: currentHandleAddVehicle,
43411
+ showArchived: currentShowArchived,
43412
+ onShowArchivedChange: currentSetShowArchived
43413
+ }
43414
+ );
43415
+ });
43416
+ const Header3 = HeaderRef.current;
42856
43417
  return /* @__PURE__ */ jsxs(Fragment, { children: [
42857
43418
  /* @__PURE__ */ jsx(
42858
43419
  BaseDetailView,
@@ -42860,7 +43421,7 @@ const VehicleManagementDetail = () => {
42860
43421
  slots: { Header: Header3, BackIcon: BackArrow },
42861
43422
  name: "VehicleManagementDetail",
42862
43423
  onGoBack: toTripsTable,
42863
- children: /* @__PURE__ */ jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle })
43424
+ children: /* @__PURE__ */ jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle, showArchived })
42864
43425
  }
42865
43426
  ),
42866
43427
  /* @__PURE__ */ jsx(Drawer, { isOpen: isVehicleDrawerOpen, onOpenChange: setIsVehicleDrawerOpen, "aria-label": selectedVehicle ? "Vehicle details" : "Add vehicle", children: ({ close: close2 }) => /* @__PURE__ */ jsxs(VStack, { pb: "lg", children: [
@@ -42939,7 +43500,7 @@ const ProjectProfitabilityView = ({
42939
43500
  }
42940
43501
  ) }),
42941
43502
  /* @__PURE__ */ jsx(
42942
- Select$1,
43503
+ ReactSelect,
42943
43504
  {
42944
43505
  className: "Layer__category-menu Layer__select",
42945
43506
  classNamePrefix: "Layer__select",
@@ -43526,14 +44087,14 @@ const BusinessProvider = ({
43526
44087
  }
43527
44088
  );
43528
44089
  };
43529
- const LayerProvider = (_ud) => {
43530
- var _vd = _ud, {
44090
+ const LayerProvider = (_wd) => {
44091
+ var _xd = _wd, {
43531
44092
  appId,
43532
44093
  appSecret,
43533
44094
  businessAccessToken,
43534
44095
  environment,
43535
44096
  usePlaidSandbox
43536
- } = _vd, restProps = __objRest(_vd, [
44097
+ } = _xd, restProps = __objRest(_xd, [
43537
44098
  "appId",
43538
44099
  "appSecret",
43539
44100
  "businessAccessToken",