@layerfi/components 0.1.99 → 0.1.100

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.
@@ -5575,6 +5575,7 @@ __export(index_exports, {
5575
5575
  Direction: () => Direction,
5576
5576
  DisplayState: () => DisplayState,
5577
5577
  GeneralLedgerView: () => GeneralLedgerView,
5578
+ Integrations: () => Integrations,
5578
5579
  Journal: () => Journal,
5579
5580
  LayerProvider: () => LayerProvider,
5580
5581
  LinkAccounts: () => LinkAccounts,
@@ -5584,11 +5585,9 @@ __export(index_exports, {
5584
5585
  ProfitAndLoss: () => ProfitAndLoss,
5585
5586
  ProfitAndLossView: () => ProfitAndLossView,
5586
5587
  ProjectProfitabilityView: () => ProjectProfitabilityView,
5587
- Quickbooks: () => Quickbooks,
5588
5588
  Reports: () => Reports,
5589
5589
  StatementOfCashFlow: () => StatementOfCashFlow,
5590
5590
  Tasks: () => Tasks,
5591
- unstable_Integrations: () => unstable_Integrations,
5592
5591
  useBankTransactionsContext: () => useBankTransactionsContext,
5593
5592
  useDataSync: () => useDataSync,
5594
5593
  useLayerContext: () => useLayerContext
@@ -5602,7 +5601,7 @@ var import_react18 = require("react");
5602
5601
  var import_react16 = require("react");
5603
5602
 
5604
5603
  // package.json
5605
- var version = "0.1.99";
5604
+ var version = "0.1.100";
5606
5605
 
5607
5606
  // src/models/APIError.ts
5608
5607
  var APIError = class _APIError extends Error {
@@ -6009,9 +6008,6 @@ var profitAndLossComparisonCsv = post(
6009
6008
 
6010
6009
  // src/api/layer/quickbooks.ts
6011
6010
  var syncFromQuickbooks = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/sync-from`);
6012
- var statusOfSyncFromQuickbooks = get(
6013
- ({ businessId }) => `/v1/businesses/${businessId}/quickbooks/sync-from/status`
6014
- );
6015
6011
  var initQuickbooksOAuth = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/authorize`);
6016
6012
  var unlinkQuickbooksConnection = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/unlink`);
6017
6013
  var statusOfQuickbooksConnection = get(
@@ -6085,7 +6081,6 @@ var Layer = {
6085
6081
  updateOpeningBalance,
6086
6082
  getStatementOfCashFlow,
6087
6083
  syncFromQuickbooks,
6088
- statusOfSyncFromQuickbooks,
6089
6084
  statusOfQuickbooksConnection,
6090
6085
  initQuickbooksOAuth,
6091
6086
  unlinkQuickbooksConnection,
@@ -14657,17 +14652,22 @@ function LegacyModeProvider({
14657
14652
  }
14658
14653
 
14659
14654
  // src/hooks/bookkeeping/useBookkeepingStatus.ts
14660
- var BOOKKEEPING_STATUSES = [
14661
- "NOT_PURCHASED",
14662
- "ACTIVE",
14663
- "ONBOARDING",
14664
- "BOOKKEEPING_PAUSED"
14665
- ];
14655
+ var BookkeepingStatus = /* @__PURE__ */ ((BookkeepingStatus3) => {
14656
+ BookkeepingStatus3["NOT_PURCHASED"] = "NOT_PURCHASED";
14657
+ BookkeepingStatus3["ACTIVE"] = "ACTIVE";
14658
+ BookkeepingStatus3["ONBOARDING"] = "ONBOARDING";
14659
+ BookkeepingStatus3["BOOKKEEPING_PAUSED"] = "BOOKKEEPING_PAUSED";
14660
+ return BookkeepingStatus3;
14661
+ })(BookkeepingStatus || {});
14662
+ var BOOKKEEPING_STATUSES = Object.values(BookkeepingStatus);
14663
+ function isBookkeepingStatus(status) {
14664
+ return BOOKKEEPING_STATUSES.includes(status);
14665
+ }
14666
14666
  function constrainToKnownBookkeepingStatus(status) {
14667
- if (BOOKKEEPING_STATUSES.includes(status)) {
14667
+ if (isBookkeepingStatus(status)) {
14668
14668
  return status;
14669
14669
  }
14670
- return "NOT_PURCHASED";
14670
+ return "NOT_PURCHASED" /* NOT_PURCHASED */;
14671
14671
  }
14672
14672
  var getBookkeepingStatus = get(({ businessId }) => {
14673
14673
  return `/v1/businesses/${businessId}/bookkeeping/status`;
@@ -14709,26 +14709,29 @@ function useEffectiveBookkeepingStatus() {
14709
14709
  const { overrideMode } = useLegacyMode();
14710
14710
  const { data } = useBookkeepingStatus();
14711
14711
  if (overrideMode === "bookkeeping-client") {
14712
- return "ACTIVE";
14712
+ return "ACTIVE" /* ACTIVE */;
14713
14713
  }
14714
- return (_a = data == null ? void 0 : data.status) != null ? _a : "NOT_PURCHASED";
14714
+ return (_a = data == null ? void 0 : data.status) != null ? _a : "NOT_PURCHASED" /* NOT_PURCHASED */;
14715
14715
  }
14716
14716
 
14717
14717
  // src/utils/bookkeeping/isCategorizationEnabled.ts
14718
14718
  function isCategorizationEnabledForStatus(status) {
14719
14719
  switch (status) {
14720
- case "NOT_PURCHASED":
14721
- case "ONBOARDING":
14722
- case "BOOKKEEPING_PAUSED":
14720
+ case "NOT_PURCHASED" /* NOT_PURCHASED */:
14721
+ case "ONBOARDING" /* ONBOARDING */:
14722
+ case "BOOKKEEPING_PAUSED" /* BOOKKEEPING_PAUSED */: {
14723
14723
  return true;
14724
- case "ACTIVE":
14724
+ }
14725
+ case "ACTIVE" /* ACTIVE */: {
14725
14726
  return false;
14726
- default:
14727
+ }
14728
+ default: {
14727
14729
  return safeAssertUnreachable({
14728
14730
  value: status,
14729
14731
  message: "Unexpected bookkeeping status in `isCategorizationEnabledForStatus`",
14730
14732
  fallbackValue: true
14731
14733
  });
14734
+ }
14732
14735
  }
14733
14736
  }
14734
14737
 
@@ -15888,6 +15891,116 @@ var SplitTooltipDetails = ({
15888
15891
  var import_classnames41 = __toESM(require("classnames"));
15889
15892
  var import_date_fns17 = require("date-fns");
15890
15893
 
15894
+ // src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
15895
+ var import_swr12 = __toESM(require("swr"));
15896
+
15897
+ // src/utils/bookkeeping/bookkeepingStatusFilters.ts
15898
+ function isActiveBookkeepingStatus(status) {
15899
+ return status === "ACTIVE" /* ACTIVE */ || status === "ONBOARDING" /* ONBOARDING */;
15900
+ }
15901
+ function isActiveOrPausedBookkeepingStatus(status) {
15902
+ return isActiveBookkeepingStatus(status) || status === "BOOKKEEPING_PAUSED" /* BOOKKEEPING_PAUSED */;
15903
+ }
15904
+
15905
+ // src/utils/bookkeeping/tasks/bookkeepingTasksFilters.ts
15906
+ function isIncompleteTask(task) {
15907
+ const { status } = task;
15908
+ return status === "TODO";
15909
+ }
15910
+ function getIncompleteTasks(tasks) {
15911
+ return tasks.filter((task) => isIncompleteTask(task));
15912
+ }
15913
+ function isUserVisibleTask(task) {
15914
+ const { status } = task;
15915
+ return status !== "COMPLETED" && status !== "ARCHIVED";
15916
+ }
15917
+ function getUserVisibleTasks(tasks) {
15918
+ return tasks.filter((task) => isUserVisibleTask(task));
15919
+ }
15920
+ function isCompletedTask(task) {
15921
+ const { status } = task;
15922
+ return status === "USER_MARKED_COMPLETED" || status === "COMPLETED" || status === "ARCHIVED";
15923
+ }
15924
+ function getCompletedTasks(tasks) {
15925
+ return tasks.filter((task) => isCompletedTask(task));
15926
+ }
15927
+
15928
+ // src/utils/bookkeeping/periods/getFilteredBookkeepingPeriods.ts
15929
+ function isActiveBookkeepingPeriod(period) {
15930
+ return period.status !== "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */;
15931
+ }
15932
+
15933
+ // src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
15934
+ var BookkeepingPeriodStatus = /* @__PURE__ */ ((BookkeepingPeriodStatus2) => {
15935
+ BookkeepingPeriodStatus2["BOOKKEEPING_NOT_ACTIVE"] = "BOOKKEEPING_NOT_ACTIVE";
15936
+ BookkeepingPeriodStatus2["NOT_STARTED"] = "NOT_STARTED";
15937
+ BookkeepingPeriodStatus2["IN_PROGRESS_AWAITING_BOOKKEEPER"] = "IN_PROGRESS_AWAITING_BOOKKEEPER";
15938
+ BookkeepingPeriodStatus2["IN_PROGRESS_AWAITING_CUSTOMER"] = "IN_PROGRESS_AWAITING_CUSTOMER";
15939
+ BookkeepingPeriodStatus2["CLOSING_IN_REVIEW"] = "CLOSING_IN_REVIEW";
15940
+ BookkeepingPeriodStatus2["CLOSED_OPEN_TASKS"] = "CLOSED_OPEN_TASKS";
15941
+ BookkeepingPeriodStatus2["CLOSED_COMPLETE"] = "CLOSED_COMPLETE";
15942
+ return BookkeepingPeriodStatus2;
15943
+ })(BookkeepingPeriodStatus || {});
15944
+ var BOOKKEEPING_PERIOD_STATUSES = Object.values(BookkeepingPeriodStatus);
15945
+ function isBookkeepingPeriodStatus(status) {
15946
+ return BOOKKEEPING_PERIOD_STATUSES.includes(status);
15947
+ }
15948
+ function constrainToKnownBookkeepingPeriodStatus(status) {
15949
+ if (isBookkeepingPeriodStatus(status)) {
15950
+ return status;
15951
+ }
15952
+ return "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */;
15953
+ }
15954
+ var getBookkeepingPeriods = get(({ businessId }) => {
15955
+ return `/v1/businesses/${businessId}/bookkeeping/periods`;
15956
+ });
15957
+ var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
15958
+ function buildKey12({
15959
+ access_token: accessToken,
15960
+ apiUrl,
15961
+ businessId,
15962
+ isActiveOrPaused
15963
+ }) {
15964
+ if (accessToken && apiUrl && isActiveOrPaused) {
15965
+ return {
15966
+ accessToken,
15967
+ apiUrl,
15968
+ businessId,
15969
+ tags: [BOOKKEEPING_TAG_KEY, BOOKKEEPING_PERIODS_TAG_KEY]
15970
+ };
15971
+ }
15972
+ }
15973
+ function useBookkeepingPeriods() {
15974
+ const { data: auth } = useAuth();
15975
+ const { businessId } = useLayerContext();
15976
+ const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
15977
+ const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
15978
+ const swrResponse = (0, import_swr12.default)(
15979
+ () => buildKey12(__spreadProps(__spreadValues({}, auth), {
15980
+ businessId,
15981
+ isActiveOrPaused
15982
+ })),
15983
+ ({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingPeriods(
15984
+ apiUrl,
15985
+ accessToken,
15986
+ { params: { businessId: businessId2 } }
15987
+ )().then(
15988
+ ({ data: { periods } }) => periods.map((period) => __spreadProps(__spreadValues({}, period), {
15989
+ status: constrainToKnownBookkeepingPeriodStatus(period.status),
15990
+ tasks: getUserVisibleTasks(period.tasks)
15991
+ })).filter((period) => isActiveBookkeepingPeriod(period))
15992
+ )
15993
+ );
15994
+ return new Proxy(swrResponse, {
15995
+ get(target, prop) {
15996
+ if (prop === "isLoading") {
15997
+ return isLoadingBookkeepingStatus || swrResponse.isLoading;
15998
+ }
15999
+ return Reflect.get(target, prop);
16000
+ }
16001
+ });
16002
+ }
16003
+
15891
16004
  // src/utils/date.ts
15892
16005
  var monthNames = [
15893
16006
  "January",
@@ -15952,9 +16065,9 @@ function getBookkeepingStatusConfig({
15952
16065
  const monthName = monthNumber !== void 0 ? getMonthNameFromNumber(monthNumber) : "";
15953
16066
  const actionPhrase = incompleteTasksCount !== void 0 && incompleteTasksCount > 0 ? `Please complete the ${(0, import_pluralize.default)("open task", incompleteTasksCount, true)}.` : "No action is needed from you right now.";
15954
16067
  switch (status) {
15955
- case "IN_PROGRESS_AWAITING_BOOKKEEPER":
15956
- case "NOT_STARTED":
15957
- case "CLOSING_IN_REVIEW": {
16068
+ case "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */:
16069
+ case "NOT_STARTED" /* NOT_STARTED */:
16070
+ case "CLOSING_IN_REVIEW" /* CLOSING_IN_REVIEW */: {
15958
16071
  return {
15959
16072
  label: "Books in progress",
15960
16073
  description: `We're working on your ${monthName} books. ${actionPhrase}`,
@@ -15962,8 +16075,8 @@ function getBookkeepingStatusConfig({
15962
16075
  icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Clock_default, { size: 12 })
15963
16076
  };
15964
16077
  }
15965
- case "IN_PROGRESS_AWAITING_CUSTOMER":
15966
- case "CLOSED_OPEN_TASKS": {
16078
+ case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
16079
+ case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
15967
16080
  return {
15968
16081
  label: "Action required",
15969
16082
  description: `Please respond to the below tasks to help us complete your ${monthName} books.`,
@@ -15971,7 +16084,7 @@ function getBookkeepingStatusConfig({
15971
16084
  icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(AlertCircle_default, { size: 12 })
15972
16085
  };
15973
16086
  }
15974
- case "CLOSED_COMPLETE": {
16087
+ case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
15975
16088
  return {
15976
16089
  label: "Books completed",
15977
16090
  description: `Your ${monthName} books are complete and ready to view!`,
@@ -15979,7 +16092,7 @@ function getBookkeepingStatusConfig({
15979
16092
  icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(CheckCircle_default, { size: 12 })
15980
16093
  };
15981
16094
  }
15982
- case "BOOKKEEPING_NOT_ACTIVE": {
16095
+ case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
15983
16096
  return;
15984
16097
  }
15985
16098
  default: {
@@ -15994,7 +16107,7 @@ function getBookkeepingStatusConfig({
15994
16107
 
15995
16108
  // src/components/BookkeepingStatus/BookkeepingStatus.tsx
15996
16109
  var import_jsx_runtime122 = require("react/jsx-runtime");
15997
- var BookkeepingStatus = ({ status, text, monthNumber, iconOnly }) => {
16110
+ var BookkeepingStatus2 = ({ status, text, monthNumber, iconOnly }) => {
15998
16111
  if (!status) {
15999
16112
  return;
16000
16113
  }
@@ -16019,7 +16132,7 @@ var BookkeepingStatus = ({ status, text, monthNumber, iconOnly }) => {
16019
16132
  // src/components/BankTransactionList/BankTransactionProcessingInfo.tsx
16020
16133
  var import_jsx_runtime123 = require("react/jsx-runtime");
16021
16134
  var BankTransactionProcessingInfo = () => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Tooltip, { offset: 12, children: [
16022
- /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(BookkeepingStatus, { status: "IN_PROGRESS_AWAITING_BOOKKEEPER", text: "Processing" }) }),
16135
+ /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(BookkeepingStatus2, { status: "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */, text: "Processing" }) }),
16023
16136
  /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipContent, { className: "Layer__tooltip", width: "md", children: "Our team will review and categorize this transaction. We'll reach out if we have any questions about it." })
16024
16137
  ] });
16025
16138
 
@@ -18121,7 +18234,7 @@ function TransactionsActions({ children }) {
18121
18234
 
18122
18235
  // src/hooks/useBankTransactions/useBankTransactionsDownload.ts
18123
18236
  var import_mutation6 = __toESM(require("swr/mutation"));
18124
- function buildKey12({
18237
+ function buildKey13({
18125
18238
  access_token: accessToken,
18126
18239
  apiUrl,
18127
18240
  businessId
@@ -18139,7 +18252,7 @@ function useBankTransactionsDownload() {
18139
18252
  const { data } = useAuth();
18140
18253
  const { businessId } = useLayerContext();
18141
18254
  return (0, import_mutation6.default)(
18142
- () => buildKey12(__spreadProps(__spreadValues({}, data), {
18255
+ () => buildKey13(__spreadProps(__spreadValues({}, data), {
18143
18256
  businessId
18144
18257
  })),
18145
18258
  ({
@@ -18526,7 +18639,7 @@ var BankTransactionsContent = ({
18526
18639
  }, [monthlyView, isVisible, isLoading, hasMore]);
18527
18640
  (0, import_react82.useEffect)(() => {
18528
18641
  if (JSON.stringify(inputFilters) !== JSON.stringify(filters)) {
18529
- if (effectiveBookkeepingStatus === "ACTIVE") {
18642
+ if (effectiveBookkeepingStatus === "ACTIVE" /* ACTIVE */) {
18530
18643
  setFilters(__spreadProps(__spreadValues(__spreadValues({}, filters), inputFilters), {
18531
18644
  categorizationStatus: "all" /* all */
18532
18645
  }));
@@ -18697,13 +18810,13 @@ var BankTransactionsContent = ({
18697
18810
  };
18698
18811
 
18699
18812
  // src/components/Integrations/Integrations.tsx
18700
- var import_react90 = require("react");
18813
+ var import_react91 = require("react");
18701
18814
 
18702
18815
  // src/components/Integrations/IntegrationsContent.tsx
18703
- var import_react86 = require("react");
18816
+ var import_react87 = require("react");
18704
18817
 
18705
18818
  // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
18706
- var import_react85 = require("react");
18819
+ var import_react86 = require("react");
18707
18820
 
18708
18821
  // src/icons/QuickbooksIcon.tsx
18709
18822
  var import_jsx_runtime153 = require("react/jsx-runtime");
@@ -18792,214 +18905,326 @@ var Card = ({ children, className }) => {
18792
18905
  var import_react83 = require("react");
18793
18906
  var QuickbooksContext = (0, import_react83.createContext)({
18794
18907
  linkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
18795
- unlinkQuickbooks: () => {
18796
- throw new Error("QuickbooksContext used without Provider");
18797
- },
18908
+ unlinkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
18798
18909
  syncFromQuickbooks: () => {
18799
18910
  throw new Error("QuickbooksContext used without Provider");
18800
18911
  },
18801
- isSyncingFromQuickbooks: false,
18802
- quickbooksIsConnected: false,
18803
- quickbooksLastSyncedAt: void 0
18912
+ quickbooksConnectionStatus: void 0
18804
18913
  });
18805
18914
 
18806
18915
  // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumbFooter.tsx
18807
18916
  var import_react84 = require("react");
18808
18917
  var import_date_fns23 = require("date-fns");
18918
+
18919
+ // src/components/Integrations/IntegrationsQuickbooksItemThumb/utils.ts
18920
+ var getQuickbooksConnectionSyncUiState = (quickbooksConnectionStatus) => {
18921
+ var _a;
18922
+ const isSyncing = (_a = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_syncing) != null ? _a : false;
18923
+ const lastSyncedAt = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_synced_at;
18924
+ const syncFailed = (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_sync_status) === "SYNC_FAILURE" /* SYNC_FAILURE */;
18925
+ if (isSyncing) {
18926
+ return "Syncing" /* Syncing */;
18927
+ }
18928
+ if (lastSyncedAt) {
18929
+ return syncFailed ? "SyncFailed" /* SyncFailed */ : "SyncSuccess" /* SyncSuccess */;
18930
+ }
18931
+ return "Connected" /* Connected */;
18932
+ };
18933
+
18934
+ // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumbFooter.tsx
18809
18935
  var import_jsx_runtime157 = require("react/jsx-runtime");
18810
18936
  var formatLastSyncedAt = (datetime) => {
18811
18937
  const parsed = new Date(datetime);
18812
18938
  if (!(0, import_date_fns23.isValid)(parsed)) return "";
18813
18939
  return `${(0, import_date_fns23.format)(parsed, "MMMM d, yyyy")} at ${(0, import_date_fns23.format)(parsed, "h:mm a")}`;
18814
18940
  };
18815
- var IntegrationsQuickbooksItemThumbFooter = () => {
18816
- const {
18817
- isSyncingFromQuickbooks,
18818
- quickbooksLastSyncedAt
18819
- } = (0, import_react84.useContext)(QuickbooksContext);
18820
- if (isSyncingFromQuickbooks) {
18821
- return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(HStack, { className: "loadingbar", children: [
18822
- /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(VStack, { children: [
18823
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children: "Syncing account data" }),
18824
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children: "This may take up to 5 minutes" })
18825
- ] }),
18826
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Spacer, {}),
18827
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: "info" })
18828
- ] });
18829
- }
18830
- if (quickbooksLastSyncedAt) {
18831
- return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(HStack, { className: "loadingbar", children: [
18832
- /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(VStack, { children: [
18833
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children: "Last synced on" }),
18834
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children: formatLastSyncedAt(quickbooksLastSyncedAt) })
18835
- ] }),
18836
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Spacer, {}),
18837
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: "success" })
18838
- ] });
18941
+ var getFooterConfig = (quickbooksUiState, lastSyncedAt) => {
18942
+ switch (quickbooksUiState) {
18943
+ case "Syncing" /* Syncing */: {
18944
+ return {
18945
+ title: "Syncing account data",
18946
+ description: "This may take up to 5 minutes",
18947
+ badgeVariant: "info"
18948
+ };
18949
+ }
18950
+ case "SyncFailed" /* SyncFailed */: {
18951
+ return {
18952
+ title: "Last sync failed at",
18953
+ description: formatLastSyncedAt(lastSyncedAt),
18954
+ badgeVariant: "error"
18955
+ };
18956
+ }
18957
+ case "SyncSuccess" /* SyncSuccess */: {
18958
+ return {
18959
+ title: "Last synced on",
18960
+ description: formatLastSyncedAt(lastSyncedAt),
18961
+ badgeVariant: "success"
18962
+ };
18963
+ }
18964
+ case "Connected" /* Connected */:
18965
+ default: {
18966
+ return {
18967
+ title: "Connected to QuickBooks",
18968
+ badgeVariant: "success"
18969
+ };
18970
+ }
18839
18971
  }
18972
+ };
18973
+ var IntegrationsQuickbooksItemThumbFooter = ({ quickbooksUiState }) => {
18974
+ const { quickbooksConnectionStatus } = (0, import_react84.useContext)(QuickbooksContext);
18975
+ if (!quickbooksConnectionStatus) return null;
18976
+ const { title, description, badgeVariant } = getFooterConfig(quickbooksUiState, quickbooksConnectionStatus.last_synced_at);
18840
18977
  return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(HStack, { className: "loadingbar", children: [
18841
18978
  /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(VStack, { children: [
18842
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children: "New account" }),
18843
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children: "Please sync your account" })
18979
+ /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children: title }),
18980
+ description && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children: description })
18844
18981
  ] }),
18845
18982
  /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Spacer, {}),
18846
- /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: "warning" })
18983
+ /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: badgeVariant })
18847
18984
  ] });
18848
18985
  };
18849
18986
 
18850
18987
  // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
18988
+ var import_lucide_react6 = require("lucide-react");
18989
+
18990
+ // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksUnlinkConfirmationModal.tsx
18991
+ var import_react85 = require("react");
18851
18992
  var import_jsx_runtime158 = require("react/jsx-runtime");
18993
+ function IntegrationsQuickbooksUnlinkConfirmationModalContent({ onClose }) {
18994
+ const { unlinkQuickbooks } = (0, import_react85.useContext)(QuickbooksContext);
18995
+ const [isProcessing, setIsProcessing] = (0, import_react85.useState)(false);
18996
+ const [hasFailed, setHasFailed] = (0, import_react85.useState)(false);
18997
+ const unlinkErrorText = "Unlink failed. Check connection and retry in few seconds.";
18998
+ const onClickUnlinkQuickbooks = (0, import_react85.useCallback)(() => {
18999
+ setIsProcessing(true);
19000
+ unlinkQuickbooks().then(() => {
19001
+ onClose();
19002
+ }).catch(() => {
19003
+ setHasFailed(true);
19004
+ setIsProcessing(false);
19005
+ });
19006
+ }, [unlinkQuickbooks, onClose]);
19007
+ return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
19008
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalContextBar, { onClose }),
19009
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalHeading, { pbe: "2xs", children: "Unlink QuickBooks" }),
19010
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalContent, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(P, { children: "Please confirm that you want to unlink QuickBooks." }) }),
19011
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalActions, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(HStack, { gap: "md", children: [
19012
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Spacer, {}),
19013
+ /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Button, { variant: "secondary" /* secondary */, onClick: onClose, children: "Cancel" }),
19014
+ !hasFailed ? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
19015
+ Button,
19016
+ {
19017
+ variant: "primary" /* primary */,
19018
+ onClick: onClickUnlinkQuickbooks,
19019
+ isProcessing,
19020
+ disabled: isProcessing,
19021
+ children: "Unlink QuickBooks"
19022
+ }
19023
+ ) : /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
19024
+ RetryButton,
19025
+ {
19026
+ onClick: onClickUnlinkQuickbooks,
19027
+ processing: isProcessing,
19028
+ disabled: isProcessing,
19029
+ error: unlinkErrorText,
19030
+ children: "Retry Unlink QuickBooks"
19031
+ }
19032
+ )
19033
+ ] }) })
19034
+ ] });
19035
+ }
19036
+ function IntegrationsQuickbooksUnlinkConfirmationModal({ isOpen, onOpenChange }) {
19037
+ return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Modal, { flexBlock: true, isOpen, onOpenChange, children: ({ close: close2 }) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(IntegrationsQuickbooksUnlinkConfirmationModalContent, { onClose: close2 }) });
19038
+ }
19039
+
19040
+ // src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
19041
+ var import_jsx_runtime159 = require("react/jsx-runtime");
19042
+ var getBadgeConfig = (quickbooksUiState, hasSynced) => {
19043
+ if (!hasSynced) {
19044
+ return {
19045
+ variant: "info" /* INFO */,
19046
+ text: "Sync",
19047
+ icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RefreshCcw_default, { size: 12 })
19048
+ };
19049
+ }
19050
+ switch (quickbooksUiState) {
19051
+ case "SyncFailed" /* SyncFailed */: {
19052
+ return {
19053
+ variant: "error" /* ERROR */,
19054
+ text: "Retry Sync",
19055
+ icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_lucide_react6.AlertCircle, { size: 12 })
19056
+ };
19057
+ }
19058
+ case "Connected" /* Connected */:
19059
+ case "SyncSuccess" /* SyncSuccess */: {
19060
+ return {
19061
+ variant: "success" /* SUCCESS */,
19062
+ text: "Synced",
19063
+ icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_lucide_react6.CheckIcon, { size: 12 })
19064
+ };
19065
+ }
19066
+ default:
19067
+ case "Syncing" /* Syncing */: {
19068
+ return {
19069
+ variant: "info" /* INFO */,
19070
+ text: "Sync",
19071
+ icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RefreshCcw_default, { size: 12 })
19072
+ };
19073
+ }
19074
+ }
19075
+ };
18852
19076
  var IntegrationsQuickbooksItemThumb = () => {
18853
- const {
18854
- isSyncingFromQuickbooks,
18855
- syncFromQuickbooks: syncFromQuickbooks2,
18856
- unlinkQuickbooks
18857
- } = (0, import_react85.useContext)(QuickbooksContext);
18858
- const menuConfig = (0, import_react85.useMemo)(() => {
19077
+ const { quickbooksConnectionStatus, syncFromQuickbooks: syncFromQuickbooks2 } = (0, import_react86.useContext)(QuickbooksContext);
19078
+ const [hasSynced, setHasSynced] = (0, import_react86.useState)(false);
19079
+ const [isConfirmationModalOpen, setIsConfirmationModalOpen] = (0, import_react86.useState)(false);
19080
+ const onSync = (0, import_react86.useCallback)(() => {
19081
+ setHasSynced(true);
19082
+ syncFromQuickbooks2();
19083
+ }, [syncFromQuickbooks2]);
19084
+ const menuConfig = (0, import_react86.useMemo)(() => {
18859
19085
  return [
18860
19086
  {
18861
19087
  name: "Unlink account",
18862
19088
  action: () => {
18863
- if (confirm("Please confirm you wish to disconnect from Quickbooks")) {
18864
- unlinkQuickbooks();
18865
- }
19089
+ setIsConfirmationModalOpen(true);
18866
19090
  }
18867
19091
  }
18868
19092
  ];
18869
- }, [unlinkQuickbooks]);
18870
- return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(LinkedAccountOptions, { config: menuConfig, children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(Card, { className: "Layer__linked-account-thumb Layer__integrations-quickbooks-item-thumb", children: [
18871
- /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "topbar", children: [
18872
- /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(HStack, { gap: "xs", children: [
18873
- /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Text, { size: "md" /* md */, children: "Quickbooks" }),
18874
- isSyncingFromQuickbooks ? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(BadgeLoader, { variant: "info" /* INFO */ }) : /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
18875
- Badge,
18876
- {
18877
- "aria-role": "button",
18878
- icon: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(RefreshCcw_default, { size: 12 }),
18879
- variant: "info" /* INFO */,
18880
- onClick: syncFromQuickbooks2,
18881
- size: "small" /* SMALL */,
18882
- hoverable: true,
18883
- children: "Sync"
18884
- }
18885
- )
19093
+ }, []);
19094
+ if (!quickbooksConnectionStatus) return null;
19095
+ const quickbooksUiState = getQuickbooksConnectionSyncUiState(quickbooksConnectionStatus);
19096
+ const badgeConfig = getBadgeConfig(quickbooksUiState, hasSynced);
19097
+ return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(LinkedAccountOptions, { config: menuConfig, children: [
19098
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(Card, { className: "Layer__linked-account-thumb Layer__integrations-quickbooks-item-thumb", children: [
19099
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { className: "topbar", children: [
19100
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(HStack, { gap: "xs", children: [
19101
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(Text, { size: "md" /* md */, children: "QuickBooks" }),
19102
+ quickbooksUiState === "Syncing" /* Syncing */ ? /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(BadgeLoader, { variant: "info" /* INFO */ }) : /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
19103
+ Badge,
19104
+ {
19105
+ "aria-role": "button",
19106
+ icon: badgeConfig.icon,
19107
+ variant: badgeConfig.variant,
19108
+ onClick: onSync,
19109
+ size: "small" /* SMALL */,
19110
+ hoverable: true,
19111
+ children: badgeConfig.text
19112
+ }
19113
+ )
19114
+ ] }),
19115
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("div", { className: "topbar-logo", children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(QuickbooksIcon_default, { size: 28 }) })
18886
19116
  ] }),
18887
- /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "topbar-logo", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(QuickbooksIcon_default, { size: 28 }) })
19117
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksItemThumbFooter, { quickbooksUiState })
18888
19118
  ] }),
18889
- /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(IntegrationsQuickbooksItemThumbFooter, {})
18890
- ] }) });
19119
+ /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksUnlinkConfirmationModal, { isOpen: isConfirmationModalOpen, onOpenChange: setIsConfirmationModalOpen })
19120
+ ] });
18891
19121
  };
18892
19122
 
18893
19123
  // src/components/Integrations/IntegrationsContent.tsx
18894
- var import_jsx_runtime159 = require("react/jsx-runtime");
19124
+ var import_jsx_runtime160 = require("react/jsx-runtime");
18895
19125
  var IntegrationsContent = () => {
18896
- const { quickbooksIsConnected } = (0, import_react86.useContext)(QuickbooksContext);
18897
- return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("div", { className: "Layer__linked-accounts__list", children: quickbooksIsConnected && /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksItemThumb, {}) });
19126
+ const { quickbooksConnectionStatus } = (0, import_react87.useContext)(QuickbooksContext);
19127
+ return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "Layer__linked-accounts__list", children: (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(IntegrationsQuickbooksItemThumb, {}) });
18898
19128
  };
18899
19129
 
18900
19130
  // src/hooks/useQuickbooks/useQuickbooks.ts
18901
- var import_react87 = require("react");
19131
+ var import_react88 = require("react");
19132
+ var import_date_fns24 = require("date-fns");
18902
19133
  var useQuickbooks = () => {
19134
+ var _a;
18903
19135
  const { businessId } = useLayerContext();
18904
19136
  const { apiUrl } = useEnvironment();
18905
19137
  const { data: auth } = useAuth();
18906
- const [isSyncingFromQuickbooks, setIsSyncingFromQuickbooks] = (0, import_react87.useState)(false);
18907
- const [quickbooksConnectionStatus, setQuickbooksConnectionStatus] = (0, import_react87.useState)(void 0);
18908
- const syncStatusIntervalRef = (0, import_react87.useRef)(null);
18909
- const wasSyncingFromQuickbooksRef = (0, import_react87.useRef)(false);
18910
- const fetchQuickbooksConnectionStatus = (0, import_react87.useCallback)(() => __async(null, null, function* () {
19138
+ const [quickbooksConnectionStatus, setQuickbooksConnectionStatus] = (0, import_react88.useState)(void 0);
19139
+ const isSyncingFromQuickbooks = (_a = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_syncing) != null ? _a : false;
19140
+ const syncStatusIntervalRef = (0, import_react88.useRef)(null);
19141
+ const fetchQuickbooksConnectionStatus = (0, import_react88.useCallback)(() => __async(null, null, function* () {
18911
19142
  const newQuickbooksConnectionStatus = (yield Layer.statusOfQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
18912
19143
  params: { businessId }
18913
19144
  })()).data;
18914
19145
  setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
18915
19146
  }), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setQuickbooksConnectionStatus]);
18916
- const fetchIsSyncingFromQuickbooks = (0, import_react87.useCallback)(() => __async(null, null, function* () {
18917
- const isSyncing = (yield Layer.statusOfSyncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
18918
- params: { businessId }
18919
- })()).data.is_syncing;
18920
- const wasSyncing = wasSyncingFromQuickbooksRef.current;
18921
- wasSyncingFromQuickbooksRef.current = isSyncing;
18922
- setIsSyncingFromQuickbooks(isSyncing);
18923
- if (!isSyncing && wasSyncing) {
18924
- yield fetchQuickbooksConnectionStatus();
18925
- }
18926
- }), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks, fetchQuickbooksConnectionStatus]);
18927
- (0, import_react87.useEffect)(() => {
19147
+ (0, import_react88.useEffect)(() => {
18928
19148
  if (isSyncingFromQuickbooks && syncStatusIntervalRef.current === null) {
18929
- const interval = window.setInterval(() => void fetchIsSyncingFromQuickbooks(), 2e3);
19149
+ const interval = window.setInterval(() => void fetchQuickbooksConnectionStatus(), 2e3);
18930
19150
  syncStatusIntervalRef.current = interval;
18931
19151
  return () => clearInterval(interval);
18932
19152
  } else if (!isSyncingFromQuickbooks && syncStatusIntervalRef.current) {
18933
19153
  clearInterval(syncStatusIntervalRef.current);
18934
19154
  syncStatusIntervalRef.current = null;
18935
19155
  }
18936
- }, [fetchIsSyncingFromQuickbooks, isSyncingFromQuickbooks]);
18937
- (0, import_react87.useEffect)(() => {
19156
+ }, [fetchQuickbooksConnectionStatus, isSyncingFromQuickbooks]);
19157
+ (0, import_react88.useEffect)(() => {
18938
19158
  if (auth == null ? void 0 : auth.access_token) {
18939
19159
  void fetchQuickbooksConnectionStatus();
18940
19160
  }
18941
19161
  }, [auth == null ? void 0 : auth.access_token, fetchQuickbooksConnectionStatus]);
18942
- const syncFromQuickbooks2 = (0, import_react87.useCallback)(() => {
18943
- setIsSyncingFromQuickbooks(true);
18944
- wasSyncingFromQuickbooksRef.current = true;
19162
+ const handleSyncError = (0, import_react88.useCallback)(() => {
19163
+ setQuickbooksConnectionStatus({
19164
+ is_connected: true,
19165
+ is_syncing: false,
19166
+ last_sync_status: "SYNC_FAILURE" /* SYNC_FAILURE */,
19167
+ last_synced_at: (0, import_date_fns24.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd'T'HH:mm:ss")
19168
+ });
19169
+ }, []);
19170
+ const syncFromQuickbooks2 = (0, import_react88.useCallback)(() => {
19171
+ const newQuickbooksConnectionStatus = quickbooksConnectionStatus ? __spreadProps(__spreadValues({}, quickbooksConnectionStatus), { is_syncing: true }) : void 0;
19172
+ setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
18945
19173
  void Layer.syncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
18946
19174
  params: { businessId }
18947
- });
18948
- }, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks]);
18949
- const linkQuickbooks = (0, import_react87.useCallback)(() => __async(null, null, function* () {
18950
- const res = yield Layer.initQuickbooksOAuth(apiUrl, auth == null ? void 0 : auth.access_token, {
19175
+ }).catch(handleSyncError);
19176
+ }, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, quickbooksConnectionStatus, handleSyncError]);
19177
+ const linkQuickbooks = (0, import_react88.useCallback)(() => __async(null, null, function* () {
19178
+ return Layer.initQuickbooksOAuth(apiUrl, auth == null ? void 0 : auth.access_token, {
18951
19179
  params: { businessId }
18952
- });
18953
- return res.data.redirect_url;
19180
+ }).then((res) => res.data.redirect_url);
18954
19181
  }), [apiUrl, auth == null ? void 0 : auth.access_token, businessId]);
18955
- const unlinkQuickbooks = (0, import_react87.useCallback)(() => {
18956
- void Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
19182
+ const unlinkQuickbooks = (0, import_react88.useCallback)(() => __async(null, null, function* () {
19183
+ return Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
18957
19184
  params: { businessId }
18958
19185
  }).then(() => fetchQuickbooksConnectionStatus());
18959
- }, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
19186
+ }), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
18960
19187
  return {
18961
- isSyncingFromQuickbooks,
18962
19188
  syncFromQuickbooks: syncFromQuickbooks2,
18963
- quickbooksIsConnected: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected,
18964
- quickbooksLastSyncedAt: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_synced_at,
18965
19189
  linkQuickbooks,
18966
- unlinkQuickbooks
19190
+ unlinkQuickbooks,
19191
+ quickbooksConnectionStatus
18967
19192
  };
18968
19193
  };
18969
19194
 
18970
19195
  // src/providers/QuickbooksContextProvider/QuickbooksContextProvider.tsx
18971
- var import_jsx_runtime160 = require("react/jsx-runtime");
19196
+ var import_jsx_runtime161 = require("react/jsx-runtime");
18972
19197
  function QuickbooksContextProvider({ children }) {
18973
19198
  const quickbooksContextData = useQuickbooks();
18974
- return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(QuickbooksContext.Provider, { value: quickbooksContextData, children });
19199
+ return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(QuickbooksContext.Provider, { value: quickbooksContextData, children });
18975
19200
  }
18976
19201
 
18977
19202
  // src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
18978
- var import_react89 = require("react");
19203
+ var import_react90 = require("react");
18979
19204
 
18980
19205
  // src/components/ui/DropdownMenu/DropdownMenu.tsx
18981
19206
  var import_react_aria_components11 = require("react-aria-components");
18982
- var import_jsx_runtime161 = require("react/jsx-runtime");
18983
- var Heading3 = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_react_aria_components11.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Text, { size: "sm" /* sm */, weight: "bold" /* bold */, className: "Layer__dropdown-menu__menu-item__heading", children }) });
18984
- var MenuItem3 = ({ children, onClick, isDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_react_aria_components11.MenuItem, { onAction: onClick, isDisabled, className: "Layer__dropdown-menu__menu-item", children });
18985
- var MenuList = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_react_aria_components11.Menu, { className: "Layer__dropdown-menu__menu-list", children });
19207
+ var import_jsx_runtime162 = require("react/jsx-runtime");
19208
+ var Heading3 = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Text, { size: "sm" /* sm */, weight: "bold" /* bold */, className: "Layer__dropdown-menu__menu-item__heading", children }) });
19209
+ var MenuItem3 = ({ children, onClick, isDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.MenuItem, { onAction: onClick, isDisabled, className: "Layer__dropdown-menu__menu-item", children });
19210
+ var MenuList = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Menu, { className: "Layer__dropdown-menu__menu-list", children });
18986
19211
  var DropdownMenu = ({ children, ariaLabel, slots, slotProps }) => {
18987
19212
  var _a;
18988
19213
  const { Trigger } = slots;
18989
19214
  const width = (_a = slotProps == null ? void 0 : slotProps.Dialog) == null ? void 0 : _a.width;
18990
- return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_react_aria_components11.MenuTrigger, { children: [
18991
- /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Trigger, { "aria-label": "Menu" }),
18992
- /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_react_aria_components11.Popover, { placement: "bottom right", className: "Layer__dropdown-menu__popover Layer__variables", children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_react_aria_components11.Dialog, { className: "Layer__dropdown-menu__menu", "aria-label": ariaLabel, style: { width }, children }) })
19215
+ return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_react_aria_components11.MenuTrigger, { children: [
19216
+ /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Trigger, { "aria-label": "Menu" }),
19217
+ /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Popover, { placement: "bottom right", className: "Layer__dropdown-menu__popover Layer__variables", children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Dialog, { className: "Layer__dropdown-menu__menu", "aria-label": ariaLabel, style: { width }, children }) })
18993
19218
  ] });
18994
19219
  };
18995
19220
 
18996
19221
  // src/icons/Cog.tsx
18997
- var import_react88 = require("react");
18998
- var import_jsx_runtime162 = require("react/jsx-runtime");
19222
+ var import_react89 = require("react");
19223
+ var import_jsx_runtime163 = require("react/jsx-runtime");
18999
19224
  var Cog = (_a) => {
19000
19225
  var _b = _a, { size = 12 } = _b, props = __objRest(_b, ["size"]);
19001
- const id = (0, import_react88.useId)();
19002
- return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(
19226
+ const id = (0, import_react89.useId)();
19227
+ return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
19003
19228
  "svg",
19004
19229
  __spreadProps(__spreadValues({
19005
19230
  xmlns: "http://www.w3.org/2000/svg",
@@ -19009,11 +19234,11 @@ var Cog = (_a) => {
19009
19234
  height: size
19010
19235
  }, props), {
19011
19236
  children: [
19012
- /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)("g", { clipPath: "url(#clip0_6610_12208)", children: [
19013
- /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("path", { d: "M6 7.5C6.82843 7.5 7.5 6.82843 7.5 6C7.5 5.17157 6.82843 4.5 6 4.5C5.17157 4.5 4.5 5.17157 4.5 6C4.5 6.82843 5.17157 7.5 6 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }),
19014
- /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("path", { d: "M9.7 7.5C9.63344 7.65081 9.61359 7.8181 9.643 7.98029C9.67241 8.14249 9.74973 8.29216 9.865 8.41L9.895 8.44C9.98798 8.53287 10.0617 8.64316 10.1121 8.76456C10.1624 8.88596 10.1883 9.01608 10.1883 9.1475C10.1883 9.27892 10.1624 9.40904 10.1121 9.53044C10.0617 9.65184 9.98798 9.76213 9.895 9.855C9.80213 9.94798 9.69184 10.0217 9.57044 10.0721C9.44904 10.1224 9.31892 10.1483 9.1875 10.1483C9.05608 10.1483 8.92596 10.1224 8.80456 10.0721C8.68316 10.0217 8.57287 9.94798 8.48 9.855L8.45 9.825C8.33216 9.70973 8.18249 9.63241 8.02029 9.603C7.8581 9.57359 7.69081 9.59344 7.54 9.66C7.39212 9.72338 7.26599 9.82862 7.17715 9.96277C7.08832 10.0969 7.04064 10.2541 7.04 10.415V10.5C7.04 10.7652 6.93464 11.0196 6.74711 11.2071C6.55957 11.3946 6.30522 11.5 6.04 11.5C5.77478 11.5 5.52043 11.3946 5.33289 11.2071C5.14536 11.0196 5.04 10.7652 5.04 10.5V10.455C5.03613 10.2895 4.98256 10.129 4.88626 9.99435C4.78995 9.8597 4.65537 9.75714 4.5 9.7C4.34919 9.63344 4.1819 9.61359 4.01971 9.643C3.85751 9.67241 3.70784 9.74973 3.59 9.865L3.56 9.895C3.46713 9.98798 3.35684 10.0617 3.23544 10.1121C3.11404 10.1624 2.98392 10.1883 2.8525 10.1883C2.72108 10.1883 2.59096 10.1624 2.46956 10.1121C2.34816 10.0617 2.23787 9.98798 2.145 9.895C2.05202 9.80213 1.97826 9.69184 1.92794 9.57044C1.87762 9.44904 1.85171 9.31892 1.85171 9.1875C1.85171 9.05608 1.87762 8.92596 1.92794 8.80456C1.97826 8.68316 2.05202 8.57287 2.145 8.48L2.175 8.45C2.29027 8.33216 2.36759 8.18249 2.397 8.02029C2.42641 7.8581 2.40656 7.69081 2.34 7.54C2.27662 7.39212 2.17138 7.26599 2.03723 7.17715C1.90309 7.08832 1.74589 7.04064 1.585 7.04H1.5C1.23478 7.04 0.98043 6.93464 0.792893 6.74711C0.605357 6.55957 0.5 6.30522 0.5 6.04C0.5 5.77478 0.605357 5.52043 0.792893 5.33289C0.98043 5.14536 1.23478 5.04 1.5 5.04H1.545C1.7105 5.03613 1.871 4.98256 2.00565 4.88626C2.1403 4.78995 2.24286 4.65537 2.3 4.5C2.36656 4.34919 2.38641 4.1819 2.357 4.01971C2.32759 3.85751 2.25027 3.70784 2.135 3.59L2.105 3.56C2.01202 3.46713 1.93826 3.35684 1.88794 3.23544C1.83762 3.11404 1.81171 2.98392 1.81171 2.8525C1.81171 2.72108 1.83762 2.59096 1.88794 2.46956C1.93826 2.34816 2.01202 2.23787 2.105 2.145C2.19787 2.05202 2.30816 1.97826 2.42956 1.92794C2.55096 1.87762 2.68108 1.85171 2.8125 1.85171C2.94392 1.85171 3.07404 1.87762 3.19544 1.92794C3.31684 1.97826 3.42713 2.05202 3.52 2.145L3.55 2.175C3.66784 2.29027 3.81751 2.36759 3.97971 2.397C4.1419 2.42641 4.30919 2.40656 4.46 2.34H4.5C4.64788 2.27662 4.77401 2.17138 4.86285 2.03723C4.95168 1.90309 4.99936 1.74589 5 1.585V1.5C5 1.23478 5.10536 0.98043 5.29289 0.792893C5.48043 0.605357 5.73478 0.5 6 0.5C6.26522 0.5 6.51957 0.605357 6.70711 0.792893C6.89464 0.98043 7 1.23478 7 1.5V1.545C7.00064 1.70589 7.04832 1.86309 7.13715 1.99723C7.22599 2.13138 7.35212 2.23662 7.5 2.3C7.65081 2.36656 7.8181 2.38641 7.98029 2.357C8.14249 2.32759 8.29216 2.25027 8.41 2.135L8.44 2.105C8.53287 2.01202 8.64316 1.93826 8.76456 1.88794C8.88596 1.83762 9.01608 1.81171 9.1475 1.81171C9.27892 1.81171 9.40904 1.83762 9.53044 1.88794C9.65184 1.93826 9.76213 2.01202 9.855 2.105C9.94798 2.19787 10.0217 2.30816 10.0721 2.42956C10.1224 2.55096 10.1483 2.68108 10.1483 2.8125C10.1483 2.94392 10.1224 3.07404 10.0721 3.19544C10.0217 3.31684 9.94798 3.42713 9.855 3.52L9.825 3.55C9.70973 3.66784 9.63241 3.81751 9.603 3.97971C9.57359 4.1419 9.59344 4.30919 9.66 4.46V4.5C9.72338 4.64788 9.82862 4.77401 9.96277 4.86285C10.0969 4.95168 10.2541 4.99936 10.415 5H10.5C10.7652 5 11.0196 5.10536 11.2071 5.29289C11.3946 5.48043 11.5 5.73478 11.5 6C11.5 6.26522 11.3946 6.51957 11.2071 6.70711C11.0196 6.89464 10.7652 7 10.5 7H10.455C10.2941 7.00064 10.1369 7.04832 10.0028 7.13715C9.86862 7.22599 9.76338 7.35212 9.7 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" })
19237
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("g", { clipPath: "url(#clip0_6610_12208)", children: [
19238
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("path", { d: "M6 7.5C6.82843 7.5 7.5 6.82843 7.5 6C7.5 5.17157 6.82843 4.5 6 4.5C5.17157 4.5 4.5 5.17157 4.5 6C4.5 6.82843 5.17157 7.5 6 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }),
19239
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("path", { d: "M9.7 7.5C9.63344 7.65081 9.61359 7.8181 9.643 7.98029C9.67241 8.14249 9.74973 8.29216 9.865 8.41L9.895 8.44C9.98798 8.53287 10.0617 8.64316 10.1121 8.76456C10.1624 8.88596 10.1883 9.01608 10.1883 9.1475C10.1883 9.27892 10.1624 9.40904 10.1121 9.53044C10.0617 9.65184 9.98798 9.76213 9.895 9.855C9.80213 9.94798 9.69184 10.0217 9.57044 10.0721C9.44904 10.1224 9.31892 10.1483 9.1875 10.1483C9.05608 10.1483 8.92596 10.1224 8.80456 10.0721C8.68316 10.0217 8.57287 9.94798 8.48 9.855L8.45 9.825C8.33216 9.70973 8.18249 9.63241 8.02029 9.603C7.8581 9.57359 7.69081 9.59344 7.54 9.66C7.39212 9.72338 7.26599 9.82862 7.17715 9.96277C7.08832 10.0969 7.04064 10.2541 7.04 10.415V10.5C7.04 10.7652 6.93464 11.0196 6.74711 11.2071C6.55957 11.3946 6.30522 11.5 6.04 11.5C5.77478 11.5 5.52043 11.3946 5.33289 11.2071C5.14536 11.0196 5.04 10.7652 5.04 10.5V10.455C5.03613 10.2895 4.98256 10.129 4.88626 9.99435C4.78995 9.8597 4.65537 9.75714 4.5 9.7C4.34919 9.63344 4.1819 9.61359 4.01971 9.643C3.85751 9.67241 3.70784 9.74973 3.59 9.865L3.56 9.895C3.46713 9.98798 3.35684 10.0617 3.23544 10.1121C3.11404 10.1624 2.98392 10.1883 2.8525 10.1883C2.72108 10.1883 2.59096 10.1624 2.46956 10.1121C2.34816 10.0617 2.23787 9.98798 2.145 9.895C2.05202 9.80213 1.97826 9.69184 1.92794 9.57044C1.87762 9.44904 1.85171 9.31892 1.85171 9.1875C1.85171 9.05608 1.87762 8.92596 1.92794 8.80456C1.97826 8.68316 2.05202 8.57287 2.145 8.48L2.175 8.45C2.29027 8.33216 2.36759 8.18249 2.397 8.02029C2.42641 7.8581 2.40656 7.69081 2.34 7.54C2.27662 7.39212 2.17138 7.26599 2.03723 7.17715C1.90309 7.08832 1.74589 7.04064 1.585 7.04H1.5C1.23478 7.04 0.98043 6.93464 0.792893 6.74711C0.605357 6.55957 0.5 6.30522 0.5 6.04C0.5 5.77478 0.605357 5.52043 0.792893 5.33289C0.98043 5.14536 1.23478 5.04 1.5 5.04H1.545C1.7105 5.03613 1.871 4.98256 2.00565 4.88626C2.1403 4.78995 2.24286 4.65537 2.3 4.5C2.36656 4.34919 2.38641 4.1819 2.357 4.01971C2.32759 3.85751 2.25027 3.70784 2.135 3.59L2.105 3.56C2.01202 3.46713 1.93826 3.35684 1.88794 3.23544C1.83762 3.11404 1.81171 2.98392 1.81171 2.8525C1.81171 2.72108 1.83762 2.59096 1.88794 2.46956C1.93826 2.34816 2.01202 2.23787 2.105 2.145C2.19787 2.05202 2.30816 1.97826 2.42956 1.92794C2.55096 1.87762 2.68108 1.85171 2.8125 1.85171C2.94392 1.85171 3.07404 1.87762 3.19544 1.92794C3.31684 1.97826 3.42713 2.05202 3.52 2.145L3.55 2.175C3.66784 2.29027 3.81751 2.36759 3.97971 2.397C4.1419 2.42641 4.30919 2.40656 4.46 2.34H4.5C4.64788 2.27662 4.77401 2.17138 4.86285 2.03723C4.95168 1.90309 4.99936 1.74589 5 1.585V1.5C5 1.23478 5.10536 0.98043 5.29289 0.792893C5.48043 0.605357 5.73478 0.5 6 0.5C6.26522 0.5 6.51957 0.605357 6.70711 0.792893C6.89464 0.98043 7 1.23478 7 1.5V1.545C7.00064 1.70589 7.04832 1.86309 7.13715 1.99723C7.22599 2.13138 7.35212 2.23662 7.5 2.3C7.65081 2.36656 7.8181 2.38641 7.98029 2.357C8.14249 2.32759 8.29216 2.25027 8.41 2.135L8.44 2.105C8.53287 2.01202 8.64316 1.93826 8.76456 1.88794C8.88596 1.83762 9.01608 1.81171 9.1475 1.81171C9.27892 1.81171 9.40904 1.83762 9.53044 1.88794C9.65184 1.93826 9.76213 2.01202 9.855 2.105C9.94798 2.19787 10.0217 2.30816 10.0721 2.42956C10.1224 2.55096 10.1483 2.68108 10.1483 2.8125C10.1483 2.94392 10.1224 3.07404 10.0721 3.19544C10.0217 3.31684 9.94798 3.42713 9.855 3.52L9.825 3.55C9.70973 3.66784 9.63241 3.81751 9.603 3.97971C9.57359 4.1419 9.59344 4.30919 9.66 4.46V4.5C9.72338 4.64788 9.82862 4.77401 9.96277 4.86285C10.0969 4.95168 10.2541 4.99936 10.415 5H10.5C10.7652 5 11.0196 5.10536 11.2071 5.29289C11.3946 5.48043 11.5 5.73478 11.5 6C11.5 6.26522 11.3946 6.51957 11.2071 6.70711C11.0196 6.89464 10.7652 7 10.5 7H10.455C10.2941 7.00064 10.1369 7.04832 10.0028 7.13715C9.86862 7.22599 9.76338 7.35212 9.7 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" })
19015
19240
  ] }),
19016
- /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("clipPath", { id, children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("rect", { width: "12", height: "12", fill: "white" }) }) })
19241
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("clipPath", { id, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("rect", { width: "12", height: "12", fill: "white" }) }) })
19017
19242
  ]
19018
19243
  })
19019
19244
  );
@@ -19021,38 +19246,42 @@ var Cog = (_a) => {
19021
19246
  var Cog_default = Cog;
19022
19247
 
19023
19248
  // src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
19024
- var import_jsx_runtime163 = require("react/jsx-runtime");
19025
- var MenuTriggerButton = () => /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(Button2, { variant: "ghost", children: [
19249
+ var import_jsx_runtime164 = require("react/jsx-runtime");
19250
+ var MenuTriggerButton = () => /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(Button2, { variant: "ghost", children: [
19026
19251
  "Manage",
19027
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Cog_default, { size: 16 })
19252
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Cog_default, { size: 16 })
19028
19253
  ] });
19029
19254
  var IntegrationsConnectMenu = () => {
19030
- const {
19031
- quickbooksIsConnected,
19032
- linkQuickbooks
19033
- } = (0, import_react89.useContext)(QuickbooksContext);
19034
- const initiateQuickbooksOAuth = (0, import_react89.useCallback)(() => __async(null, null, function* () {
19035
- const authorizationUrl = yield linkQuickbooks();
19036
- window.location.href = authorizationUrl;
19037
- }), [linkQuickbooks]);
19038
- return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
19255
+ const { addToast } = useLayerContext();
19256
+ const { quickbooksConnectionStatus, linkQuickbooks } = (0, import_react90.useContext)(QuickbooksContext);
19257
+ const quickbooksIsConnected = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected;
19258
+ const [isLinkQuickbooksError, setIsLinkQuickbooksError] = (0, import_react90.useState)(false);
19259
+ const initiateQuickbooksOAuth = (0, import_react90.useCallback)(() => {
19260
+ linkQuickbooks().then((res) => {
19261
+ window.location.href = res;
19262
+ }).catch(() => {
19263
+ setIsLinkQuickbooksError(true);
19264
+ addToast({ content: "Failed to connect QuickBooks", type: "error" });
19265
+ });
19266
+ }, [linkQuickbooks, addToast]);
19267
+ return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
19039
19268
  DropdownMenu,
19040
19269
  {
19041
19270
  ariaLabel: "Connect Integration",
19042
19271
  slots: { Trigger: MenuTriggerButton },
19043
19272
  slotProps: { Dialog: { width: 280 } },
19044
19273
  children: [
19045
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Heading3, { children: "Integrations" }),
19046
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(MenuList, { children: quickbooksIsConnected ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(MenuItem3, { isDisabled: true, children: [
19047
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(QuickbooksIcon_default, { size: 20 }),
19048
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Text, { size: "sm" /* sm */, children: "Quickbooks connected" }),
19049
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Spacer, {}),
19050
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Check_default, { size: 16 })
19051
- ] }, "quickbooks-connected") : /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(MenuItem3, { onClick: initiateQuickbooksOAuth, children: [
19052
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(QuickbooksIcon_default, { size: 20 }),
19053
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Text, { size: "sm" /* sm */, children: "Connect Quickbooks" }),
19054
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Spacer, {}),
19055
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Link_default, { size: 12 })
19274
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Heading3, { children: "Integrations" }),
19275
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(MenuList, { children: quickbooksIsConnected ? /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(MenuItem3, { isDisabled: true, children: [
19276
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(QuickbooksIcon_default, { size: 20 }),
19277
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Text, { size: "sm" /* sm */, children: "QuickBooks connected" }),
19278
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Spacer, {}),
19279
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Check_default, { size: 16 })
19280
+ ] }, "quickbooks-connected") : /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(MenuItem3, { onClick: initiateQuickbooksOAuth, children: [
19281
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(QuickbooksIcon_default, { size: 20 }),
19282
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Text, __spreadProps(__spreadValues({}, isLinkQuickbooksError && { status: "error" }), { size: "sm" /* sm */, children: isLinkQuickbooksError ? "Retry Connect QuickBooks" : "Connect QuickBooks" })),
19283
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Spacer, {}),
19284
+ /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Link_default, { size: 12 })
19056
19285
  ] }, "connect-quickbooks") })
19057
19286
  ]
19058
19287
  }
@@ -19060,20 +19289,20 @@ var IntegrationsConnectMenu = () => {
19060
19289
  };
19061
19290
 
19062
19291
  // src/components/Integrations/Integrations.tsx
19063
- var import_jsx_runtime164 = require("react/jsx-runtime");
19292
+ var import_jsx_runtime165 = require("react/jsx-runtime");
19064
19293
  var COMPONENT_NAME3 = "integrations";
19065
- var unstable_Integrations = (props) => {
19066
- return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(QuickbooksContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(IntegrationsComponent, __spreadValues({}, props)) });
19294
+ var Integrations = (props) => {
19295
+ return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(QuickbooksContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsComponent, __spreadValues({}, props)) });
19067
19296
  };
19068
19297
  var IntegrationsComponent = ({
19069
19298
  elevated,
19070
19299
  stringOverrides
19071
19300
  }) => {
19072
- const { quickbooksIsConnected } = (0, import_react90.useContext)(QuickbooksContext);
19073
- const isLoading = quickbooksIsConnected === void 0;
19074
- return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(Container, { name: COMPONENT_NAME3, elevated, children: [
19075
- /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(Header, { className: "Layer__linked-accounts__header", children: [
19076
- /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
19301
+ const { quickbooksConnectionStatus } = (0, import_react91.useContext)(QuickbooksContext);
19302
+ const isLoading = quickbooksConnectionStatus === void 0;
19303
+ return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(Container, { name: COMPONENT_NAME3, elevated, children: [
19304
+ /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(Header, { className: "Layer__linked-accounts__header", children: [
19305
+ /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
19077
19306
  Heading,
19078
19307
  {
19079
19308
  className: "Layer__linked-accounts__title",
@@ -19081,61 +19310,26 @@ var IntegrationsComponent = ({
19081
19310
  children: (stringOverrides == null ? void 0 : stringOverrides.title) || "Integrations"
19082
19311
  }
19083
19312
  ),
19084
- /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(IntegrationsConnectMenu, {})
19313
+ /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsConnectMenu, {})
19085
19314
  ] }),
19086
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)("div", { className: "Layer__linked-accounts__loader-container", children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Loader2, {}) }),
19087
- !isLoading && !quickbooksIsConnected && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
19315
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { className: "Layer__linked-accounts__loader-container", children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(Loader2, {}) }),
19316
+ !isLoading && !quickbooksConnectionStatus.is_connected && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
19088
19317
  DataState,
19089
19318
  {
19090
19319
  status: "info" /* info */,
19091
19320
  title: "No active integrations"
19092
19321
  }
19093
19322
  ),
19094
- quickbooksIsConnected && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(IntegrationsContent, {})
19095
- ] });
19096
- };
19097
-
19098
- // src/components/Quickbooks/Quickbooks.tsx
19099
- var import_jsx_runtime165 = require("react/jsx-runtime");
19100
- var Quickbooks = () => {
19101
- const {
19102
- syncFromQuickbooks: syncFromQuickbooks2,
19103
- isSyncingFromQuickbooks,
19104
- quickbooksIsConnected,
19105
- linkQuickbooks,
19106
- unlinkQuickbooks
19107
- } = useQuickbooks();
19108
- return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
19109
- /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
19110
- "Quickbooks OAuth connection status:",
19111
- " ",
19112
- quickbooksIsConnected === void 0 ? "" : quickbooksIsConnected ? "established" : "not connected"
19113
- ] }),
19114
- /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("br", {}),
19115
- quickbooksIsConnected === void 0 && "Loading...",
19116
- quickbooksIsConnected === false && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
19117
- "button",
19118
- {
19119
- onClick: () => __async(null, null, function* () {
19120
- const authorizationUrl = yield linkQuickbooks();
19121
- window.location.href = authorizationUrl;
19122
- }),
19123
- children: "Link Quickbooks"
19124
- }
19125
- ),
19126
- quickbooksIsConnected === true && (isSyncingFromQuickbooks ? "Syncing data from Quickbooks..." : /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
19127
- /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: syncFromQuickbooks2, children: "Sync Quickbooks" }),
19128
- /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: unlinkQuickbooks, children: "Unlink Quickbooks" })
19129
- ] }))
19323
+ (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsContent, {})
19130
19324
  ] });
19131
19325
  };
19132
19326
 
19133
19327
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
19134
- var import_react118 = require("react");
19328
+ var import_react119 = require("react");
19135
19329
 
19136
19330
  // src/contexts/ProfitAndLossComparisonContext/ProfitAndLossComparisonContext.tsx
19137
- var import_react91 = require("react");
19138
- var PNLComparisonContext = (0, import_react91.createContext)({
19331
+ var import_react92 = require("react");
19332
+ var PNLComparisonContext = (0, import_react92.createContext)({
19139
19333
  data: void 0,
19140
19334
  isLoading: true,
19141
19335
  isValidating: false,
@@ -19156,7 +19350,7 @@ var PNLComparisonContext = (0, import_react91.createContext)({
19156
19350
  });
19157
19351
 
19158
19352
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
19159
- var import_react94 = require("react");
19353
+ var import_react95 = require("react");
19160
19354
 
19161
19355
  // src/utils/profitAndLossUtils.ts
19162
19356
  var doesLineItemQualifies = (item) => {
@@ -19212,15 +19406,15 @@ var applyShare = (items, total) => {
19212
19406
  };
19213
19407
 
19214
19408
  // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
19215
- var import_react92 = require("react");
19216
- var import_date_fns24 = require("date-fns");
19217
- var import_swr12 = __toESM(require("swr"));
19409
+ var import_react93 = require("react");
19410
+ var import_date_fns25 = require("date-fns");
19411
+ var import_swr13 = __toESM(require("swr"));
19218
19412
  var buildDates = ({ currentDate }) => {
19219
19413
  return {
19220
- startYear: (0, import_date_fns24.startOfMonth)(currentDate).getFullYear() - 1,
19221
- startMonth: (0, import_date_fns24.startOfMonth)(currentDate).getMonth() + 1,
19222
- endYear: (0, import_date_fns24.startOfMonth)(currentDate).getFullYear(),
19223
- endMonth: (0, import_date_fns24.startOfMonth)(currentDate).getMonth() + 1
19414
+ startYear: (0, import_date_fns25.startOfMonth)(currentDate).getFullYear() - 1,
19415
+ startMonth: (0, import_date_fns25.startOfMonth)(currentDate).getMonth() + 1,
19416
+ endYear: (0, import_date_fns25.startOfMonth)(currentDate).getFullYear(),
19417
+ endMonth: (0, import_date_fns25.startOfMonth)(currentDate).getMonth() + 1
19224
19418
  };
19225
19419
  };
19226
19420
  var buildMonthsArray = (startDate, endDate) => {
@@ -19234,16 +19428,16 @@ var buildMonthsArray = (startDate, endDate) => {
19234
19428
  return dates;
19235
19429
  };
19236
19430
  var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19237
- currentDate: (0, import_date_fns24.startOfMonth)(Date.now())
19431
+ currentDate: (0, import_date_fns25.startOfMonth)(Date.now())
19238
19432
  }) => {
19239
19433
  var _a, _b;
19240
19434
  const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
19241
19435
  const { apiUrl } = useEnvironment();
19242
19436
  const { data: auth } = useAuth();
19243
- const [date, setDate] = (0, import_react92.useState)(currentDate);
19244
- const [loaded, setLoaded] = (0, import_react92.useState)("initial");
19245
- const [data, setData] = (0, import_react92.useState)([]);
19246
- const { startYear, startMonth, endYear, endMonth } = (0, import_react92.useMemo)(() => {
19437
+ const [date, setDate] = (0, import_react93.useState)(currentDate);
19438
+ const [loaded, setLoaded] = (0, import_react93.useState)("initial");
19439
+ const [data, setData] = (0, import_react93.useState)([]);
19440
+ const { startYear, startMonth, endYear, endMonth } = (0, import_react93.useMemo)(() => {
19247
19441
  return buildDates({ currentDate: date });
19248
19442
  }, [date, businessId, tagFilter, reportingBasis]);
19249
19443
  const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && (auth == null ? void 0 : auth.access_token) && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter == null ? void 0 : tagFilter.key}-${(_a = tagFilter == null ? void 0 : tagFilter.values) == null ? void 0 : _a.join(
@@ -19255,7 +19449,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19255
19449
  isValidating,
19256
19450
  error,
19257
19451
  mutate
19258
- } = (0, import_swr12.default)(
19452
+ } = (0, import_swr13.default)(
19259
19453
  queryKey,
19260
19454
  Layer.getProfitAndLossSummaries(apiUrl, auth == null ? void 0 : auth.access_token, {
19261
19455
  params: {
@@ -19270,9 +19464,9 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19270
19464
  }
19271
19465
  })
19272
19466
  );
19273
- (0, import_react92.useEffect)(() => {
19467
+ (0, import_react93.useEffect)(() => {
19274
19468
  const newData = data.slice();
19275
- const newPeriod = buildMonthsArray((0, import_date_fns24.sub)(date, { years: 1 }), date);
19469
+ const newPeriod = buildMonthsArray((0, import_date_fns25.sub)(date, { years: 1 }), date);
19276
19470
  if (newData && newPeriod) {
19277
19471
  newPeriod.forEach((x) => {
19278
19472
  if (!(newData == null ? void 0 : newData.find(
@@ -19306,7 +19500,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19306
19500
  );
19307
19501
  }
19308
19502
  }, [startYear, startMonth, tagFilter]);
19309
- (0, import_react92.useEffect)(() => {
19503
+ (0, import_react93.useEffect)(() => {
19310
19504
  var _a2, _b2;
19311
19505
  const newData = (_b2 = (_a2 = rawData == null ? void 0 : rawData.data) == null ? void 0 : _a2.months) == null ? void 0 : _b2.slice();
19312
19506
  if (data && newData) {
@@ -19324,7 +19518,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19324
19518
  );
19325
19519
  }
19326
19520
  }, [rawData]);
19327
- (0, import_react92.useEffect)(() => {
19521
+ (0, import_react93.useEffect)(() => {
19328
19522
  if (isLoading && loaded === "initial") {
19329
19523
  setLoaded("loading");
19330
19524
  return;
@@ -19334,12 +19528,12 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19334
19528
  }
19335
19529
  }, [data, isLoading]);
19336
19530
  const pullData = (date2) => setDate(date2);
19337
- (0, import_react92.useEffect)(() => {
19531
+ (0, import_react93.useEffect)(() => {
19338
19532
  if (queryKey && (isLoading || isValidating)) {
19339
19533
  read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
19340
19534
  }
19341
19535
  }, [isLoading, isValidating]);
19342
- (0, import_react92.useEffect)(() => {
19536
+ (0, import_react93.useEffect)(() => {
19343
19537
  if (queryKey && hasBeenTouched(queryKey)) {
19344
19538
  mutate();
19345
19539
  }
@@ -19366,17 +19560,17 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
19366
19560
  };
19367
19561
 
19368
19562
  // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
19369
- var import_react93 = require("react");
19370
- var import_date_fns25 = require("date-fns");
19371
- var import_swr13 = __toESM(require("swr"));
19563
+ var import_react94 = require("react");
19564
+ var import_date_fns26 = require("date-fns");
19565
+ var import_swr14 = __toESM(require("swr"));
19372
19566
  var useProfitAndLossQuery = ({
19373
19567
  startDate,
19374
19568
  endDate,
19375
19569
  tagFilter,
19376
19570
  reportingBasis
19377
19571
  } = {
19378
- startDate: (0, import_date_fns25.startOfMonth)(/* @__PURE__ */ new Date()),
19379
- endDate: (0, import_date_fns25.endOfMonth)(/* @__PURE__ */ new Date())
19572
+ startDate: (0, import_date_fns26.startOfMonth)(/* @__PURE__ */ new Date()),
19573
+ endDate: (0, import_date_fns26.endOfMonth)(/* @__PURE__ */ new Date())
19380
19574
  }) => {
19381
19575
  var _a, _b;
19382
19576
  const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
@@ -19391,7 +19585,7 @@ var useProfitAndLossQuery = ({
19391
19585
  isValidating,
19392
19586
  error: rawError,
19393
19587
  mutate
19394
- } = (0, import_swr13.default)(
19588
+ } = (0, import_swr14.default)(
19395
19589
  queryKey,
19396
19590
  Layer.getProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
19397
19591
  businessId,
@@ -19405,12 +19599,12 @@ var useProfitAndLossQuery = ({
19405
19599
  const refetch = () => {
19406
19600
  mutate();
19407
19601
  };
19408
- (0, import_react93.useEffect)(() => {
19602
+ (0, import_react94.useEffect)(() => {
19409
19603
  if (queryKey && (isLoading || isValidating)) {
19410
19604
  read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
19411
19605
  }
19412
19606
  }, [isLoading, isValidating]);
19413
- (0, import_react93.useEffect)(() => {
19607
+ (0, import_react94.useEffect)(() => {
19414
19608
  if (queryKey && hasBeenTouched(queryKey)) {
19415
19609
  refetch();
19416
19610
  }
@@ -19433,16 +19627,16 @@ var useProfitAndLoss = ({
19433
19627
  }) => {
19434
19628
  const { start, end } = useGlobalDateRange();
19435
19629
  const { setRange } = useGlobalDateRangeActions();
19436
- const dateRange = (0, import_react94.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
19437
- const changeDateRange = (0, import_react94.useCallback)(
19630
+ const dateRange = (0, import_react95.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
19631
+ const changeDateRange = (0, import_react95.useCallback)(
19438
19632
  ({ startDate: start2, endDate: end2 }) => setRange({ start: start2, end: end2 }),
19439
19633
  [setRange]
19440
19634
  );
19441
- const [filters, setFilters] = (0, import_react94.useState)({
19635
+ const [filters, setFilters] = (0, import_react95.useState)({
19442
19636
  expenses: void 0,
19443
19637
  revenue: void 0
19444
19638
  });
19445
- const [sidebarScope, setSidebarScope] = (0, import_react94.useState)(void 0);
19639
+ const [sidebarScope, setSidebarScope] = (0, import_react95.useState)(void 0);
19446
19640
  const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
19447
19641
  startDate: start,
19448
19642
  endDate: end,
@@ -19469,7 +19663,7 @@ var useProfitAndLoss = ({
19469
19663
  })
19470
19664
  }));
19471
19665
  };
19472
- const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react94.useMemo)(() => {
19666
+ const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react95.useMemo)(() => {
19473
19667
  var _a;
19474
19668
  if (!data) {
19475
19669
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
@@ -19521,7 +19715,7 @@ var useProfitAndLoss = ({
19521
19715
  const withShare = applyShare(sorted, total);
19522
19716
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
19523
19717
  }, [data, start, filters, summaryData]);
19524
- const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react94.useMemo)(() => {
19718
+ const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react95.useMemo)(() => {
19525
19719
  var _a;
19526
19720
  if (!data) {
19527
19721
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
@@ -19595,10 +19789,10 @@ var useProfitAndLoss = ({
19595
19789
  };
19596
19790
 
19597
19791
  // src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
19598
- var import_react95 = require("react");
19792
+ var import_react96 = require("react");
19599
19793
 
19600
19794
  // src/hooks/useProfitAndLossComparison/utils.ts
19601
- var import_date_fns26 = require("date-fns");
19795
+ var import_date_fns27 = require("date-fns");
19602
19796
 
19603
19797
  // src/utils/array/range.ts
19604
19798
  function range2(start, end) {
@@ -19656,12 +19850,12 @@ function prepareFiltersBody(compareOptions) {
19656
19850
  return isArrayWithAtLeastOne(allFilters) ? allFilters : void 0;
19657
19851
  }
19658
19852
  function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
19659
- const adjustedStartDate = (0, import_date_fns26.startOfMonth)(dateRange.startDate);
19853
+ const adjustedStartDate = (0, import_date_fns27.startOfMonth)(dateRange.startDate);
19660
19854
  const rawPeriods = range2(0, comparePeriods).map((index) => {
19661
- const currentPeriod = (0, import_date_fns26.subMonths)(adjustedStartDate, index);
19855
+ const currentPeriod = (0, import_date_fns27.subMonths)(adjustedStartDate, index);
19662
19856
  return {
19663
- year: (0, import_date_fns26.getYear)(currentPeriod),
19664
- month: (0, import_date_fns26.getMonth)(currentPeriod) + 1
19857
+ year: (0, import_date_fns27.getYear)(currentPeriod),
19858
+ month: (0, import_date_fns27.getMonth)(currentPeriod) + 1
19665
19859
  };
19666
19860
  });
19667
19861
  const sortedPeriods = rawPeriods.sort((a, b) => {
@@ -19679,11 +19873,11 @@ function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
19679
19873
  };
19680
19874
  }
19681
19875
  function preparePeriodsBodyForYears(dateRange, comparePeriods) {
19682
- const adjustedStartDate = (0, import_date_fns26.startOfYear)(dateRange.startDate);
19876
+ const adjustedStartDate = (0, import_date_fns27.startOfYear)(dateRange.startDate);
19683
19877
  const rawPeriods = range2(0, comparePeriods).map((index) => {
19684
- const currentPeriod = (0, import_date_fns26.subYears)(adjustedStartDate, index);
19878
+ const currentPeriod = (0, import_date_fns27.subYears)(adjustedStartDate, index);
19685
19879
  return {
19686
- year: (0, import_date_fns26.getYear)(currentPeriod)
19880
+ year: (0, import_date_fns27.getYear)(currentPeriod)
19687
19881
  };
19688
19882
  });
19689
19883
  const sortedPeriods = rawPeriods.sort((a, b) => {
@@ -19718,14 +19912,14 @@ function preparePeriodsBody(dateRange, comparePeriods, rangeDisplayMode) {
19718
19912
  }
19719
19913
 
19720
19914
  // src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
19721
- var import_swr14 = __toESM(require("swr"));
19915
+ var import_swr15 = __toESM(require("swr"));
19722
19916
  var COMPARE_MODES_SUPPORTING_MULTI_PERIOD = ["monthPicker", "yearPicker"];
19723
19917
  var isNotOnlyNoneTag = (compareOptions) => {
19724
19918
  return Boolean(
19725
19919
  compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
19726
19920
  );
19727
19921
  };
19728
- function buildKey13({
19922
+ function buildKey14({
19729
19923
  access_token: accessToken,
19730
19924
  apiUrl,
19731
19925
  businessId,
@@ -19749,15 +19943,15 @@ function useProfitAndLossComparison({
19749
19943
  comparisonConfig
19750
19944
  }) {
19751
19945
  var _a, _b;
19752
- const [comparePeriods, setComparePeriods] = (0, import_react95.useState)((_a = comparisonConfig == null ? void 0 : comparisonConfig.defaultPeriods) != null ? _a : 1);
19753
- const [selectedCompareOptions, setSelectedCompareOptionsState] = (0, import_react95.useState)(
19946
+ const [comparePeriods, setComparePeriods] = (0, import_react96.useState)((_a = comparisonConfig == null ? void 0 : comparisonConfig.defaultPeriods) != null ? _a : 1);
19947
+ const [selectedCompareOptions, setSelectedCompareOptionsState] = (0, import_react96.useState)(
19754
19948
  (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
19755
19949
  );
19756
19950
  const { rangeDisplayMode, start, end } = useGlobalDateRange();
19757
19951
  const dateRange = { startDate: start, endDate: end };
19758
19952
  const isPeriodsSelectEnabled = COMPARE_MODES_SUPPORTING_MULTI_PERIOD.includes(rangeDisplayMode);
19759
19953
  const effectiveComparePeriods = isPeriodsSelectEnabled ? comparePeriods : 1;
19760
- const compareModeActive = (0, import_react95.useMemo)(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
19954
+ const compareModeActive = (0, import_react96.useMemo)(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
19761
19955
  const setSelectedCompareOptions = (values) => {
19762
19956
  const options = values.map(
19763
19957
  (option) => comparisonConfig == null ? void 0 : comparisonConfig.tagComparisonOptions.find(
@@ -19775,14 +19969,14 @@ function useProfitAndLossComparison({
19775
19969
  const { data: auth } = useAuth();
19776
19970
  const periods = preparePeriodsBody(dateRange, effectiveComparePeriods, rangeDisplayMode);
19777
19971
  const tagFilters = prepareFiltersBody(selectedCompareOptions);
19778
- const queryKey = buildKey13(__spreadProps(__spreadValues({}, auth), {
19972
+ const queryKey = buildKey14(__spreadProps(__spreadValues({}, auth), {
19779
19973
  businessId,
19780
19974
  periods,
19781
19975
  tagFilters,
19782
19976
  reportingBasis,
19783
19977
  compareModeActive
19784
19978
  }));
19785
- const { data, isLoading, isValidating } = (0, import_swr14.default)(
19979
+ const { data, isLoading, isValidating } = (0, import_swr15.default)(
19786
19980
  queryKey,
19787
19981
  () => __async(null, null, function* () {
19788
19982
  const response = yield Layer.compareProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
@@ -19830,7 +20024,7 @@ function useProfitAndLossComparison({
19830
20024
  }
19831
20025
 
19832
20026
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
19833
- var import_react96 = require("react");
20027
+ var import_react97 = require("react");
19834
20028
 
19835
20029
  // src/icons/BarChart2.tsx
19836
20030
  var import_jsx_runtime166 = require("react/jsx-runtime");
@@ -19940,7 +20134,7 @@ var Indicator = ({
19940
20134
 
19941
20135
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
19942
20136
  var import_classnames53 = __toESM(require("classnames"));
19943
- var import_date_fns27 = require("date-fns");
20137
+ var import_date_fns28 = require("date-fns");
19944
20138
  var import_recharts = require("recharts");
19945
20139
  var import_jsx_runtime169 = require("react/jsx-runtime");
19946
20140
  var getChartWindow = ({
@@ -19948,46 +20142,46 @@ var getChartWindow = ({
19948
20142
  currentYear,
19949
20143
  currentMonth
19950
20144
  }) => {
19951
- const today = (0, import_date_fns27.startOfMonth)(Date.now());
19952
- const yearAgo = (0, import_date_fns27.sub)(today, { months: 11 });
19953
- const current = (0, import_date_fns27.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
19954
- if ((0, import_date_fns27.differenceInMonths)((0, import_date_fns27.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns27.differenceInMonths)((0, import_date_fns27.startOfMonth)(chartWindow.end), current) > 1) {
20145
+ const today = (0, import_date_fns28.startOfMonth)(Date.now());
20146
+ const yearAgo = (0, import_date_fns28.sub)(today, { months: 11 });
20147
+ const current = (0, import_date_fns28.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
20148
+ if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.end), current) > 1) {
19955
20149
  return chartWindow;
19956
20150
  }
19957
- if ((0, import_date_fns27.differenceInMonths)((0, import_date_fns27.startOfMonth)(chartWindow.start), current) === 0) {
20151
+ if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.start), current) === 0) {
19958
20152
  return {
19959
- start: (0, import_date_fns27.startOfMonth)((0, import_date_fns27.sub)(current, { months: 1 })),
19960
- end: (0, import_date_fns27.endOfMonth)((0, import_date_fns27.add)(current, { months: 11 }))
20153
+ start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 1 })),
20154
+ end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 11 }))
19961
20155
  };
19962
20156
  }
19963
- if ((0, import_date_fns27.differenceInMonths)((0, import_date_fns27.endOfMonth)(chartWindow.end), (0, import_date_fns27.endOfMonth)(current)) === 1 && (0, import_date_fns27.differenceInMonths)(today, current) >= 1) {
20157
+ if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.endOfMonth)(chartWindow.end), (0, import_date_fns28.endOfMonth)(current)) === 1 && (0, import_date_fns28.differenceInMonths)(today, current) >= 1) {
19964
20158
  return {
19965
- start: (0, import_date_fns27.startOfMonth)((0, import_date_fns27.sub)(current, { months: 10 })),
19966
- end: (0, import_date_fns27.endOfMonth)((0, import_date_fns27.add)(current, { months: 2 }))
20159
+ start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 10 })),
20160
+ end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 2 }))
19967
20161
  };
19968
20162
  }
19969
- if ((0, import_date_fns27.differenceInMonths)(current, (0, import_date_fns27.startOfMonth)(chartWindow.end)) === 0 && (0, import_date_fns27.differenceInMonths)(current, (0, import_date_fns27.startOfMonth)(today)) > 0) {
20163
+ if ((0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(chartWindow.end)) === 0 && (0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(today)) > 0) {
19970
20164
  return {
19971
- start: (0, import_date_fns27.startOfMonth)((0, import_date_fns27.sub)(current, { months: 11 })),
19972
- end: (0, import_date_fns27.endOfMonth)((0, import_date_fns27.add)(current, { months: 1 }))
20165
+ start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 11 })),
20166
+ end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 1 }))
19973
20167
  };
19974
20168
  }
19975
20169
  if (current >= yearAgo) {
19976
20170
  return {
19977
- start: (0, import_date_fns27.startOfMonth)(yearAgo),
19978
- end: (0, import_date_fns27.endOfMonth)(today)
20171
+ start: (0, import_date_fns28.startOfMonth)(yearAgo),
20172
+ end: (0, import_date_fns28.endOfMonth)(today)
19979
20173
  };
19980
20174
  }
19981
20175
  if (Number(current) > Number(chartWindow.end)) {
19982
20176
  return {
19983
- start: (0, import_date_fns27.startOfMonth)((0, import_date_fns27.sub)(current, { months: 12 })),
19984
- end: (0, import_date_fns27.endOfMonth)(current)
20177
+ start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 12 })),
20178
+ end: (0, import_date_fns28.endOfMonth)(current)
19985
20179
  };
19986
20180
  }
19987
- if ((0, import_date_fns27.differenceInMonths)(current, (0, import_date_fns27.startOfMonth)(chartWindow.start)) < 0) {
20181
+ if ((0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(chartWindow.start)) < 0) {
19988
20182
  return {
19989
- start: (0, import_date_fns27.startOfMonth)(current),
19990
- end: (0, import_date_fns27.endOfMonth)((0, import_date_fns27.add)(current, { months: 11 }))
20183
+ start: (0, import_date_fns28.startOfMonth)(current),
20184
+ end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 11 }))
19991
20185
  };
19992
20186
  }
19993
20187
  return chartWindow;
@@ -20013,41 +20207,41 @@ var ProfitAndLossChart = ({
20013
20207
  tagFilter = void 0
20014
20208
  }) => {
20015
20209
  var _c, _d, _e, _f, _g, _h;
20016
- const [compactView, setCompactView] = (0, import_react96.useState)(false);
20210
+ const [compactView, setCompactView] = (0, import_react97.useState)(false);
20017
20211
  const barSize = compactView ? 10 : 20;
20018
20212
  const { getColor, business } = useLayerContext();
20019
20213
  const { start, end, rangeDisplayMode } = useGlobalDateRange();
20020
20214
  const { setMonth } = useGlobalDateRangeActions();
20021
20215
  const showIndicator = rangeDisplayMode === "monthPicker";
20022
- const dateRange = (0, import_react96.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
20023
- const [localDateRange, setLocalDateRange] = (0, import_react96.useState)(dateRange);
20024
- const [customCursorSize, setCustomCursorSize] = (0, import_react96.useState)({
20216
+ const dateRange = (0, import_react97.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
20217
+ const [localDateRange, setLocalDateRange] = (0, import_react97.useState)(dateRange);
20218
+ const [customCursorSize, setCustomCursorSize] = (0, import_react97.useState)({
20025
20219
  width: 0,
20026
20220
  height: 0,
20027
20221
  x: 0
20028
20222
  });
20029
- const [barAnimActive, setBarAnimActive] = (0, import_react96.useState)(true);
20030
- const [chartWindow, setChartWindow] = (0, import_react96.useState)({
20031
- start: (0, import_date_fns27.startOfMonth)((0, import_date_fns27.sub)(Date.now(), { months: 11 })),
20032
- end: (0, import_date_fns27.endOfMonth)(Date.now())
20223
+ const [barAnimActive, setBarAnimActive] = (0, import_react97.useState)(true);
20224
+ const [chartWindow, setChartWindow] = (0, import_react97.useState)({
20225
+ start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(Date.now(), { months: 11 })),
20226
+ end: (0, import_date_fns28.endOfMonth)(Date.now())
20033
20227
  });
20034
- const selectionMonth = (0, import_react96.useMemo)(
20228
+ const selectionMonth = (0, import_react97.useMemo)(
20035
20229
  () => ({
20036
20230
  year: localDateRange.startDate.getFullYear(),
20037
20231
  month: localDateRange.startDate.getMonth()
20038
20232
  }),
20039
20233
  [localDateRange]
20040
20234
  );
20041
- (0, import_react96.useEffect)(() => {
20235
+ (0, import_react97.useEffect)(() => {
20042
20236
  if (Number(dateRange.startDate) !== Number(localDateRange.startDate) || Number(dateRange.endDate) !== Number(localDateRange.endDate)) {
20043
20237
  setLocalDateRange(dateRange);
20044
20238
  }
20045
20239
  }, [dateRange]);
20046
20240
  const { data, loaded, pullData } = useProfitAndLossLTM({
20047
- currentDate: (0, import_date_fns27.startOfMonth)(Date.now()),
20241
+ currentDate: (0, import_date_fns28.startOfMonth)(Date.now()),
20048
20242
  tagFilter
20049
20243
  });
20050
- const anyData = (0, import_react96.useMemo)(() => {
20244
+ const anyData = (0, import_react97.useMemo)(() => {
20051
20245
  return Boolean(
20052
20246
  data == null ? void 0 : data.find(
20053
20247
  (x) => x.income !== 0 || x.costOfGoodsSold !== 0 || x.grossProfit !== 0 || x.operatingExpenses !== 0 || x.profitBeforeTaxes !== 0 || x.taxes !== 0 || x.totalExpenses !== 0 || x.uncategorizedInflows !== 0 || x.uncategorizedOutflows !== 0
@@ -20055,33 +20249,33 @@ var ProfitAndLossChart = ({
20055
20249
  );
20056
20250
  }, [data]);
20057
20251
  const { data: linkedAccounts } = useLinkedAccounts();
20058
- const isSyncing = (0, import_react96.useMemo)(
20252
+ const isSyncing = (0, import_react97.useMemo)(
20059
20253
  () => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
20060
20254
  [linkedAccounts]
20061
20255
  );
20062
- const loadingValue = (0, import_react96.useMemo)(() => getLoadingValue(data), [data]);
20063
- (0, import_react96.useEffect)(() => {
20256
+ const loadingValue = (0, import_react97.useMemo)(() => getLoadingValue(data), [data]);
20257
+ (0, import_react97.useEffect)(() => {
20064
20258
  if (loaded === "complete" && data) {
20065
20259
  const foundCurrent = data.find(
20066
- (x) => Number((0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number((0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
20260
+ (x) => Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
20067
20261
  );
20068
20262
  if (!foundCurrent) {
20069
- const newDate = (0, import_date_fns27.startOfMonth)(localDateRange.startDate);
20263
+ const newDate = (0, import_date_fns28.startOfMonth)(localDateRange.startDate);
20070
20264
  pullData(newDate);
20071
20265
  return;
20072
20266
  }
20073
20267
  const foundBefore = data.find(
20074
- (x) => Number((0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number((0, import_date_fns27.sub)(localDateRange.startDate, { months: 1 })) && Number((0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number((0, import_date_fns27.sub)(localDateRange.endDate, { months: 1 }))
20268
+ (x) => Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number((0, import_date_fns28.sub)(localDateRange.startDate, { months: 1 })) && Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number((0, import_date_fns28.sub)(localDateRange.endDate, { months: 1 }))
20075
20269
  );
20076
20270
  if (!foundBefore) {
20077
- const newDate = (0, import_date_fns27.startOfMonth)(
20078
- (0, import_date_fns27.sub)(localDateRange.startDate, { months: 1 })
20271
+ const newDate = (0, import_date_fns28.startOfMonth)(
20272
+ (0, import_date_fns28.sub)(localDateRange.startDate, { months: 1 })
20079
20273
  );
20080
20274
  pullData(newDate);
20081
20275
  }
20082
20276
  }
20083
20277
  }, [localDateRange]);
20084
- (0, import_react96.useEffect)(() => {
20278
+ (0, import_react97.useEffect)(() => {
20085
20279
  const newChartWindow = getChartWindow({
20086
20280
  chartWindow,
20087
20281
  currentYear: localDateRange.startDate.getFullYear(),
@@ -20091,14 +20285,14 @@ var ProfitAndLossChart = ({
20091
20285
  setChartWindow(newChartWindow);
20092
20286
  }
20093
20287
  }, [localDateRange]);
20094
- (0, import_react96.useEffect)(() => {
20288
+ (0, import_react97.useEffect)(() => {
20095
20289
  if (loaded === "complete") {
20096
20290
  setTimeout(() => {
20097
20291
  setBarAnimActive(false);
20098
20292
  }, 2e3);
20099
20293
  }
20100
20294
  }, [loaded]);
20101
- const getMonthName = (pnl) => pnl ? (0, import_date_fns27.format)(
20295
+ const getMonthName = (pnl) => pnl ? (0, import_date_fns28.format)(
20102
20296
  new Date(pnl.year, pnl.month - 1, 1),
20103
20297
  compactView ? "LLLLL" : "LLL"
20104
20298
  ) : "";
@@ -20118,15 +20312,15 @@ var ProfitAndLossChart = ({
20118
20312
  loading: (pnl == null ? void 0 : pnl.isLoading) ? loadingValue : 0,
20119
20313
  loadingExpenses: (pnl == null ? void 0 : pnl.isLoading) ? -loadingValue : 0
20120
20314
  });
20121
- const theData = (0, import_react96.useMemo)(() => {
20315
+ const theData = (0, import_react97.useMemo)(() => {
20122
20316
  var _a;
20123
20317
  if (loaded !== "complete" || loaded === "complete" && !anyData) {
20124
20318
  const loadingData = [];
20125
20319
  const today = Date.now();
20126
20320
  for (let i = 11; i >= 0; i--) {
20127
- const currentDate = (0, import_date_fns27.sub)(today, { months: i });
20321
+ const currentDate = (0, import_date_fns28.sub)(today, { months: i });
20128
20322
  loadingData.push({
20129
- name: (0, import_date_fns27.format)(currentDate, compactView ? "LLLLL" : "LLL"),
20323
+ name: (0, import_date_fns28.format)(currentDate, compactView ? "LLLLL" : "LLL"),
20130
20324
  revenue: 0,
20131
20325
  revenueUncategorized: 0,
20132
20326
  totalExpensesInverse: 0,
@@ -20156,18 +20350,18 @@ var ProfitAndLossChart = ({
20156
20350
  }
20157
20351
  return x;
20158
20352
  })) == null ? void 0 : _a.filter(
20159
- (x) => (0, import_date_fns27.differenceInMonths)(
20160
- (0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1)),
20353
+ (x) => (0, import_date_fns28.differenceInMonths)(
20354
+ (0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
20161
20355
  chartWindow.start
20162
- ) >= 0 && (0, import_date_fns27.differenceInMonths)(
20163
- (0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1)),
20356
+ ) >= 0 && (0, import_date_fns28.differenceInMonths)(
20357
+ (0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
20164
20358
  chartWindow.start
20165
- ) < 12 && (0, import_date_fns27.differenceInMonths)(
20359
+ ) < 12 && (0, import_date_fns28.differenceInMonths)(
20166
20360
  chartWindow.end,
20167
- (0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))
20168
- ) >= 0 && (0, import_date_fns27.differenceInMonths)(
20361
+ (0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
20362
+ ) >= 0 && (0, import_date_fns28.differenceInMonths)(
20169
20363
  chartWindow.end,
20170
- (0, import_date_fns27.startOfMonth)(new Date(x.year, x.month - 1, 1))
20364
+ (0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
20171
20365
  ) <= 12
20172
20366
  ).map((x) => summarizePnL(x));
20173
20367
  }, [selectionMonth, chartWindow, data, loaded, compactView]);
@@ -20649,7 +20843,7 @@ var ProfitAndLossChart = ({
20649
20843
  };
20650
20844
 
20651
20845
  // src/components/ProfitAndLossCompareOptions/ProfitAndLossCompareOptions.tsx
20652
- var import_react97 = require("react");
20846
+ var import_react98 = require("react");
20653
20847
  var import_jsx_runtime170 = require("react/jsx-runtime");
20654
20848
  var selectStyles = {
20655
20849
  valueContainer: (styles) => {
@@ -20689,9 +20883,9 @@ var ProfitAndLossCompareOptions = () => {
20689
20883
  compareOptions,
20690
20884
  selectedCompareOptions,
20691
20885
  comparisonConfig
20692
- } = (0, import_react97.useContext)(ProfitAndLoss.ComparisonContext);
20886
+ } = (0, import_react98.useContext)(ProfitAndLoss.ComparisonContext);
20693
20887
  const { rangeDisplayMode } = useGlobalDateRange();
20694
- const periods = (0, import_react97.useMemo)(
20888
+ const periods = (0, import_react98.useMemo)(
20695
20889
  () => comparePeriods !== 0 ? comparePeriods : 1,
20696
20890
  [comparePeriods]
20697
20891
  );
@@ -20784,7 +20978,7 @@ function DatePickerModeSelector({
20784
20978
  }
20785
20979
 
20786
20980
  // src/providers/GlobalDateStore/useGlobalDateRangePicker.ts
20787
- var import_react98 = require("react");
20981
+ var import_react99 = require("react");
20788
20982
  function useGlobalDateRangePicker({
20789
20983
  allowedDatePickerModes,
20790
20984
  defaultDatePickerMode,
@@ -20801,7 +20995,7 @@ function useGlobalDateRangePicker({
20801
20995
  DEFAULT_ALLOWED_PICKER_MODES
20802
20996
  );
20803
20997
  const desiredRangeMode = allowedDateRangePickerModes.includes(rangeDisplayMode) ? rangeDisplayMode : allowedDateRangePickerModes[0];
20804
- const { dateFormat, selected } = (0, import_react98.useMemo)(() => {
20998
+ const { dateFormat, selected } = (0, import_react99.useMemo)(() => {
20805
20999
  if (rangeDisplayMode === "monthPicker") {
20806
21000
  return {
20807
21001
  selected: start,
@@ -20821,7 +21015,7 @@ function useGlobalDateRangePicker({
20821
21015
  end,
20822
21016
  rangeDisplayMode
20823
21017
  ]);
20824
- const { setSelected } = (0, import_react98.useMemo)(() => {
21018
+ const { setSelected } = (0, import_react99.useMemo)(() => {
20825
21019
  if (desiredRangeMode === "monthPicker") {
20826
21020
  return {
20827
21021
  setSelected: ({ start: start2 }) => {
@@ -20901,10 +21095,10 @@ var ProfitAndLossDatePicker = ({
20901
21095
  };
20902
21096
 
20903
21097
  // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
20904
- var import_react100 = require("react");
21098
+ var import_react101 = require("react");
20905
21099
 
20906
21100
  // src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
20907
- var import_react99 = require("react");
21101
+ var import_react100 = require("react");
20908
21102
 
20909
21103
  // src/config/charts.ts
20910
21104
  var DEFAULT_CHART_COLOR_TYPE = [
@@ -21189,7 +21383,7 @@ var DetailedChart = ({
21189
21383
  isLoading,
21190
21384
  showDatePicker = true
21191
21385
  }) => {
21192
- const chartData = (0, import_react99.useMemo)(() => {
21386
+ const chartData = (0, import_react100.useMemo)(() => {
21193
21387
  if (!filteredData) {
21194
21388
  return [];
21195
21389
  }
@@ -21540,7 +21734,7 @@ var Filters = ({
21540
21734
  };
21541
21735
 
21542
21736
  // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
21543
- var import_date_fns28 = require("date-fns");
21737
+ var import_date_fns29 = require("date-fns");
21544
21738
  var import_jsx_runtime177 = require("react/jsx-runtime");
21545
21739
  var ProfitAndLossDetailedCharts = ({
21546
21740
  scope,
@@ -21561,16 +21755,16 @@ var ProfitAndLossDetailedCharts = ({
21561
21755
  sidebarScope,
21562
21756
  setSidebarScope,
21563
21757
  setFilterTypes
21564
- } = (0, import_react100.useContext)(ProfitAndLoss.Context);
21758
+ } = (0, import_react101.useContext)(ProfitAndLoss.Context);
21565
21759
  const theScope = scope ? scope : sidebarScope;
21566
21760
  const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
21567
21761
  const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
21568
- const [hoveredItem, setHoveredItem] = (0, import_react100.useState)();
21762
+ const [hoveredItem, setHoveredItem] = (0, import_react101.useState)();
21569
21763
  return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts", children: [
21570
21764
  /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("header", { className: "Layer__profit-and-loss-detailed-charts__header", children: [
21571
21765
  /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
21572
21766
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
21573
- /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns28.format)(dateRange.startDate, "LLLL, y") }),
21767
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns29.format)(dateRange.startDate, "LLLL, y") }),
21574
21768
  showDatePicker && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(ProfitAndLossDatePicker, {})
21575
21769
  ] }),
21576
21770
  !hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
@@ -21587,7 +21781,7 @@ var ProfitAndLossDetailedCharts = ({
21587
21781
  !hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(BackButton, { onClick: () => setSidebarScope(void 0) }),
21588
21782
  /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
21589
21783
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
21590
- /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns28.format)(dateRange.startDate, "LLLL, y") })
21784
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns29.format)(dateRange.startDate, "LLLL, y") })
21591
21785
  ] })
21592
21786
  ] }),
21593
21787
  /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__content", children: [
@@ -21634,7 +21828,7 @@ var ProfitAndLossDetailedCharts = ({
21634
21828
  };
21635
21829
 
21636
21830
  // src/components/ProfitAndLossDownloadButton/ProfitAndLossDownloadButton.tsx
21637
- var import_react101 = require("react");
21831
+ var import_react102 = require("react");
21638
21832
  var import_jsx_runtime178 = require("react/jsx-runtime");
21639
21833
  var ProfitAndLossDownloadButton = ({
21640
21834
  stringOverrides,
@@ -21642,15 +21836,15 @@ var ProfitAndLossDownloadButton = ({
21642
21836
  moneyFormat,
21643
21837
  view
21644
21838
  }) => {
21645
- const { dateRange, tagFilter } = (0, import_react101.useContext)(ProfitAndLoss.Context);
21646
- const { getProfitAndLossComparisonCsv } = (0, import_react101.useContext)(
21839
+ const { dateRange, tagFilter } = (0, import_react102.useContext)(ProfitAndLoss.Context);
21840
+ const { getProfitAndLossComparisonCsv } = (0, import_react102.useContext)(
21647
21841
  ProfitAndLoss.ComparisonContext
21648
21842
  );
21649
21843
  const { businessId } = useLayerContext();
21650
21844
  const { apiUrl } = useEnvironment();
21651
21845
  const { data: auth } = useAuth();
21652
- const [requestFailed, setRequestFailed] = (0, import_react101.useState)(false);
21653
- const [isDownloading, setIsDownloading] = (0, import_react101.useState)(false);
21846
+ const [requestFailed, setRequestFailed] = (0, import_react102.useState)(false);
21847
+ const [isDownloading, setIsDownloading] = (0, import_react102.useState)(false);
21654
21848
  const handleClick = () => __async(null, null, function* () {
21655
21849
  var _a;
21656
21850
  setIsDownloading(true);
@@ -21694,7 +21888,7 @@ var ProfitAndLossDownloadButton = ({
21694
21888
  };
21695
21889
 
21696
21890
  // src/components/ProfitAndLossHeader/ProfitAndLossHeader.tsx
21697
- var import_react103 = require("react");
21891
+ var import_react104 = require("react");
21698
21892
 
21699
21893
  // src/components/SyncingBadge/SyncingBadge.tsx
21700
21894
  var import_jsx_runtime179 = require("react/jsx-runtime");
@@ -21711,120 +21905,13 @@ var SyncingBadge = () => {
21711
21905
  };
21712
21906
 
21713
21907
  // src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
21714
- var import_react102 = require("react");
21715
-
21716
- // src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
21717
- var import_swr15 = __toESM(require("swr"));
21718
-
21719
- // src/utils/bookkeeping/bookkeepingStatusFilters.ts
21720
- function isActiveBookkeepingStatus(status) {
21721
- return status === "ACTIVE" || status === "ONBOARDING";
21722
- }
21723
- function isActiveOrPausedBookkeepingStatus(status) {
21724
- return isActiveBookkeepingStatus(status) || status === "BOOKKEEPING_PAUSED";
21725
- }
21726
-
21727
- // src/utils/bookkeeping/tasks/bookkeepingTasksFilters.ts
21728
- function isIncompleteTask(task) {
21729
- const { status } = task;
21730
- return status === "TODO";
21731
- }
21732
- function getIncompleteTasks(tasks) {
21733
- return tasks.filter((task) => isIncompleteTask(task));
21734
- }
21735
- function isUserVisibleTask(task) {
21736
- const { status } = task;
21737
- return status !== "COMPLETED" && status !== "ARCHIVED";
21738
- }
21739
- function getUserVisibleTasks(tasks) {
21740
- return tasks.filter((task) => isUserVisibleTask(task));
21741
- }
21742
- function isCompletedTask(task) {
21743
- const { status } = task;
21744
- return status === "USER_MARKED_COMPLETED" || status === "COMPLETED" || status === "ARCHIVED";
21745
- }
21746
- function getCompletedTasks(tasks) {
21747
- return tasks.filter((task) => isCompletedTask(task));
21748
- }
21749
-
21750
- // src/utils/bookkeeping/periods/getFilteredBookkeepingPeriods.ts
21751
- function isActiveBookkeepingPeriod(period) {
21752
- return period.status !== "BOOKKEEPING_NOT_ACTIVE";
21753
- }
21754
-
21755
- // src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
21756
- var BOOKKEEPING_PERIOD_STATUSES = [
21757
- "BOOKKEEPING_NOT_ACTIVE",
21758
- "NOT_STARTED",
21759
- "IN_PROGRESS_AWAITING_BOOKKEEPER",
21760
- "IN_PROGRESS_AWAITING_CUSTOMER",
21761
- "CLOSING_IN_REVIEW",
21762
- "CLOSED_OPEN_TASKS",
21763
- "CLOSED_COMPLETE"
21764
- ];
21765
- function constrainToKnownBookkeepingPeriodStatus(status) {
21766
- if (BOOKKEEPING_PERIOD_STATUSES.includes(status)) {
21767
- return status;
21768
- }
21769
- return "BOOKKEEPING_NOT_ACTIVE";
21770
- }
21771
- var getBookkeepingPeriods = get(({ businessId }) => {
21772
- return `/v1/businesses/${businessId}/bookkeeping/periods`;
21773
- });
21774
- var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
21775
- function buildKey14({
21776
- access_token: accessToken,
21777
- apiUrl,
21778
- businessId,
21779
- isActiveOrPaused
21780
- }) {
21781
- if (accessToken && apiUrl && isActiveOrPaused) {
21782
- return {
21783
- accessToken,
21784
- apiUrl,
21785
- businessId,
21786
- tags: [BOOKKEEPING_TAG_KEY, BOOKKEEPING_PERIODS_TAG_KEY]
21787
- };
21788
- }
21789
- }
21790
- function useBookkeepingPeriods() {
21791
- const { data: auth } = useAuth();
21792
- const { businessId } = useLayerContext();
21793
- const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
21794
- const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
21795
- const swrResponse = (0, import_swr15.default)(
21796
- () => buildKey14(__spreadProps(__spreadValues({}, auth), {
21797
- businessId,
21798
- isActiveOrPaused
21799
- })),
21800
- ({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingPeriods(
21801
- apiUrl,
21802
- accessToken,
21803
- { params: { businessId: businessId2 } }
21804
- )().then(
21805
- ({ data: { periods } }) => periods.map((period) => __spreadProps(__spreadValues({}, period), {
21806
- status: constrainToKnownBookkeepingPeriodStatus(period.status),
21807
- tasks: getUserVisibleTasks(period.tasks)
21808
- })).filter((period) => isActiveBookkeepingPeriod(period))
21809
- )
21810
- );
21811
- return new Proxy(swrResponse, {
21812
- get(target, prop) {
21813
- if (prop === "isLoading") {
21814
- return isLoadingBookkeepingStatus || swrResponse.isLoading;
21815
- }
21816
- return Reflect.get(target, prop);
21817
- }
21818
- });
21819
- }
21820
-
21821
- // src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
21908
+ var import_react103 = require("react");
21822
21909
  function useActiveBookkeepingPeriod() {
21823
21910
  const { date } = useGlobalDate();
21824
21911
  const { data, isLoading } = useBookkeepingPeriods();
21825
21912
  const currentMonth = date.getMonth() + 1;
21826
21913
  const currentYear = date.getFullYear();
21827
- const activePeriod = (0, import_react102.useMemo)(
21914
+ const activePeriod = (0, import_react103.useMemo)(
21828
21915
  () => data == null ? void 0 : data.find((period) => currentYear === period.year && currentMonth === period.month),
21829
21916
  [data, currentMonth, currentYear]
21830
21917
  );
@@ -21843,7 +21930,7 @@ var ProfitAndLossHeader = ({
21843
21930
  const { data: linkedAccounts } = useLinkedAccounts();
21844
21931
  const { activePeriod } = useActiveBookkeepingPeriod();
21845
21932
  const activePeriodStatus = activePeriod == null ? void 0 : activePeriod.status;
21846
- const isSyncing = (0, import_react103.useMemo)(
21933
+ const isSyncing = (0, import_react104.useMemo)(
21847
21934
  () => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
21848
21935
  [linkedAccounts]
21849
21936
  );
@@ -21851,20 +21938,20 @@ var ProfitAndLossHeader = ({
21851
21938
  /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("span", { className: "Layer__component-header__title-wrapper Layer__profit-and-loss__header", children: [
21852
21939
  /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Heading, { size: "secondary" /* secondary */, className: headingClassName, align: "left", children: text || "Profit & Loss" }),
21853
21940
  isSyncing && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SyncingBadge, {}),
21854
- withStatus && activePeriodStatus && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("span", { className: "Layer__profit-and-loss-header__bookkeeping-status", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(BookkeepingStatus, { status: activePeriodStatus, monthNumber: activePeriod.month }) })
21941
+ withStatus && activePeriodStatus && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("span", { className: "Layer__profit-and-loss-header__bookkeeping-status", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(BookkeepingStatus2, { status: activePeriodStatus, monthNumber: activePeriod.month }) })
21855
21942
  ] }),
21856
21943
  withDatePicker && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ProfitAndLoss.DatePicker, {})
21857
21944
  ] });
21858
21945
  };
21859
21946
 
21860
21947
  // src/components/ProfitAndLossReport/ProfitAndLossReport.tsx
21861
- var import_react107 = require("react");
21948
+ var import_react108 = require("react");
21862
21949
 
21863
21950
  // src/components/Header/Header.tsx
21864
- var import_react104 = require("react");
21951
+ var import_react105 = require("react");
21865
21952
  var import_classnames56 = __toESM(require("classnames"));
21866
21953
  var import_jsx_runtime181 = require("react/jsx-runtime");
21867
- var Header3 = (0, import_react104.forwardRef)(
21954
+ var Header3 = (0, import_react105.forwardRef)(
21868
21955
  ({ className, children, style, sticky, asHeader, rounded }, ref) => {
21869
21956
  const baseClassName = (0, import_classnames56.default)(
21870
21957
  "Layer__header",
@@ -21905,7 +21992,7 @@ var HeaderCol = ({ className, children, style, noPadding = false }) => {
21905
21992
  };
21906
21993
 
21907
21994
  // src/components/Panel/Panel.tsx
21908
- var import_react105 = require("react");
21995
+ var import_react106 = require("react");
21909
21996
  var import_classnames59 = __toESM(require("classnames"));
21910
21997
  var import_jsx_runtime184 = require("react/jsx-runtime");
21911
21998
  var Panel = ({
@@ -21919,8 +22006,8 @@ var Panel = ({
21919
22006
  floating = false
21920
22007
  }) => {
21921
22008
  var _a;
21922
- const [sidebarHeight, setSidebarHeight] = (0, import_react105.useState)(0);
21923
- (0, import_react105.useEffect)(() => {
22009
+ const [sidebarHeight, setSidebarHeight] = (0, import_react106.useState)(0);
22010
+ (0, import_react106.useEffect)(() => {
21924
22011
  var _a2, _b;
21925
22012
  if ((_a2 = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _a2.offsetHeight) {
21926
22013
  setSidebarHeight((_b = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _b.offsetHeight);
@@ -21960,7 +22047,7 @@ var Panel = ({
21960
22047
  };
21961
22048
 
21962
22049
  // src/components/View/View.tsx
21963
- var import_react106 = require("react");
22050
+ var import_react107 = require("react");
21964
22051
 
21965
22052
  // src/components/ViewHeader/ViewHeader.tsx
21966
22053
  var import_classnames60 = __toESM(require("classnames"));
@@ -21975,7 +22062,7 @@ var ViewHeader = ({ title, className, children }) => {
21975
22062
  // src/components/View/View.tsx
21976
22063
  var import_classnames61 = __toESM(require("classnames"));
21977
22064
  var import_jsx_runtime186 = require("react/jsx-runtime");
21978
- var View = (0, import_react106.forwardRef)(
22065
+ var View = (0, import_react107.forwardRef)(
21979
22066
  ({
21980
22067
  title,
21981
22068
  showHeader = true,
@@ -22026,8 +22113,8 @@ var ProfitAndLossReport = ({
22026
22113
  view
22027
22114
  }) => {
22028
22115
  var _a, _b;
22029
- const { sidebarScope } = (0, import_react107.useContext)(ProfitAndLoss.Context);
22030
- const { comparisonConfig } = (0, import_react107.useContext)(ProfitAndLoss.ComparisonContext);
22116
+ const { sidebarScope } = (0, import_react108.useContext)(ProfitAndLoss.Context);
22117
+ const { comparisonConfig } = (0, import_react108.useContext)(ProfitAndLoss.ComparisonContext);
22031
22118
  return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
22032
22119
  View,
22033
22120
  {
@@ -22084,10 +22171,10 @@ var ProfitAndLossReport = ({
22084
22171
  };
22085
22172
 
22086
22173
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
22087
- var import_react111 = require("react");
22174
+ var import_react112 = require("react");
22088
22175
 
22089
22176
  // src/components/ProfitAndLossSummaries/internal/ProfitAndLossSummariesList.tsx
22090
- var import_react108 = require("react");
22177
+ var import_react109 = require("react");
22091
22178
  var import_jsx_runtime188 = require("react/jsx-runtime");
22092
22179
  var LIST_ITEM_CLASS_NAME = "Layer__ProfitAndLossSummariesListItem";
22093
22180
  function ProfitAndLossSummariesListItem({
@@ -22095,7 +22182,7 @@ function ProfitAndLossSummariesListItem({
22095
22182
  isActive,
22096
22183
  onClick
22097
22184
  }) {
22098
- const dataProperties = (0, import_react108.useMemo)(
22185
+ const dataProperties = (0, import_react109.useMemo)(
22099
22186
  () => toDataProperties({ active: isActive, clickable: !!onClick }),
22100
22187
  [isActive]
22101
22188
  );
@@ -22106,7 +22193,7 @@ function ProfitAndLossSummariesList({
22106
22193
  children,
22107
22194
  itemCount
22108
22195
  }) {
22109
- const dataProperties = (0, import_react108.useMemo)(
22196
+ const dataProperties = (0, import_react109.useMemo)(
22110
22197
  () => toDataProperties({ ["column-count"]: itemCount }),
22111
22198
  [itemCount]
22112
22199
  );
@@ -22199,10 +22286,10 @@ function ProfitAndLossSummariesMiniChart({
22199
22286
  }
22200
22287
 
22201
22288
  // src/components/ui/Typography/MoneyText.tsx
22202
- var import_react109 = require("react");
22289
+ var import_react110 = require("react");
22203
22290
  var import_jsx_runtime190 = require("react/jsx-runtime");
22204
22291
  var CLASS_NAME10 = "Layer__MoneyText";
22205
- var MoneySpan = (0, import_react109.forwardRef)(
22292
+ var MoneySpan = (0, import_react110.forwardRef)(
22206
22293
  (_a, ref) => {
22207
22294
  var _b = _a, { amount, bold, size } = _b, restProps = __objRest(_b, ["amount", "bold", "size"]);
22208
22295
  const dataProperties = toDataProperties({
@@ -22249,8 +22336,8 @@ function ProfitAndLossSummariesSummary({
22249
22336
  }
22250
22337
 
22251
22338
  // src/views/AccountingOverview/internal/TransactionsToReview.tsx
22252
- var import_react110 = require("react");
22253
- var import_date_fns29 = require("date-fns");
22339
+ var import_react111 = require("react");
22340
+ var import_date_fns30 = require("date-fns");
22254
22341
  var import_jsx_runtime193 = require("react/jsx-runtime");
22255
22342
  var CLASS_NAME12 = "Layer__TransactionsToReview";
22256
22343
  function TransactionsToReview({
@@ -22260,23 +22347,23 @@ function TransactionsToReview({
22260
22347
  variants
22261
22348
  }) {
22262
22349
  const { size = "sm" } = variants != null ? variants : {};
22263
- const { dateRange: contextDateRange } = (0, import_react110.useContext)(ProfitAndLoss.Context);
22350
+ const { dateRange: contextDateRange } = (0, import_react111.useContext)(ProfitAndLoss.Context);
22264
22351
  const dateRange = usePnlDateRange ? contextDateRange : void 0;
22265
- const [toReview, setToReview] = (0, import_react110.useState)(0);
22352
+ const [toReview, setToReview] = (0, import_react111.useState)(0);
22266
22353
  const { data, loaded, error, refetch } = useProfitAndLossLTM({
22267
- currentDate: dateRange ? dateRange.startDate : (0, import_date_fns29.startOfMonth)(/* @__PURE__ */ new Date()),
22354
+ currentDate: dateRange ? dateRange.startDate : (0, import_date_fns30.startOfMonth)(/* @__PURE__ */ new Date()),
22268
22355
  tagFilter
22269
22356
  });
22270
- (0, import_react110.useEffect)(() => {
22357
+ (0, import_react111.useEffect)(() => {
22271
22358
  checkTransactionsToReview();
22272
22359
  }, []);
22273
- (0, import_react110.useEffect)(() => {
22360
+ (0, import_react111.useEffect)(() => {
22274
22361
  checkTransactionsToReview();
22275
22362
  }, [dateRange, loaded]);
22276
22363
  const checkTransactionsToReview = () => {
22277
22364
  if (data && dateRange) {
22278
22365
  const monthTx = data.filter(
22279
- (x) => x.month - 1 === (0, import_date_fns29.getMonth)(dateRange.startDate) && x.year === (0, import_date_fns29.getYear)(dateRange.startDate)
22366
+ (x) => x.month - 1 === (0, import_date_fns30.getMonth)(dateRange.startDate) && x.year === (0, import_date_fns30.getYear)(dateRange.startDate)
22280
22367
  );
22281
22368
  if (monthTx.length > 0) {
22282
22369
  setToReview(monthTx[0].uncategorized_transactions);
@@ -22351,8 +22438,8 @@ function Internal_ProfitAndLossSummaries({
22351
22438
  isLoading,
22352
22439
  setSidebarScope,
22353
22440
  sidebarScope
22354
- } = (0, import_react111.useContext)(ProfitAndLoss.Context);
22355
- const { revenueChartData, expensesChartData } = (0, import_react111.useMemo)(
22441
+ } = (0, import_react112.useContext)(ProfitAndLoss.Context);
22442
+ const { revenueChartData, expensesChartData } = (0, import_react112.useMemo)(
22356
22443
  () => ({
22357
22444
  revenueChartData: toMiniChartData({ scope: "revenue", data }),
22358
22445
  expensesChartData: toMiniChartData({ scope: "expenses", data })
@@ -22454,10 +22541,10 @@ function ProfitAndLossSummaries(_a) {
22454
22541
  }
22455
22542
 
22456
22543
  // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
22457
- var import_react117 = require("react");
22544
+ var import_react118 = require("react");
22458
22545
 
22459
22546
  // src/contexts/TableContext/TableContext.tsx
22460
- var import_react112 = require("react");
22547
+ var import_react113 = require("react");
22461
22548
  var import_jsx_runtime195 = require("react/jsx-runtime");
22462
22549
  var defaultValue = {
22463
22550
  expandedRows: [],
@@ -22469,10 +22556,10 @@ var defaultValue = {
22469
22556
  setExpandedAllRows: () => {
22470
22557
  }
22471
22558
  };
22472
- var TableContext = (0, import_react112.createContext)(defaultValue);
22559
+ var TableContext = (0, import_react113.createContext)(defaultValue);
22473
22560
  var TableProvider = ({ children }) => {
22474
- const [expandedRows, setExpandedRowsState] = (0, import_react112.useState)([]);
22475
- const [expandedAllRows, setExpandedAllRows] = (0, import_react112.useState)(false);
22561
+ const [expandedRows, setExpandedRowsState] = (0, import_react113.useState)([]);
22562
+ const [expandedAllRows, setExpandedAllRows] = (0, import_react113.useState)(false);
22476
22563
  const toggleRow = (rowKey) => {
22477
22564
  setExpandedRowsState((prevRows) => {
22478
22565
  const rows = [...prevRows];
@@ -22498,10 +22585,10 @@ var TableProvider = ({ children }) => {
22498
22585
  };
22499
22586
 
22500
22587
  // src/components/ProfitAndLossTable/ProfitAndLossCompareTable.tsx
22501
- var import_react115 = require("react");
22588
+ var import_react116 = require("react");
22502
22589
 
22503
22590
  // src/hooks/useTableExpandRow/useTableExpandRow.tsx
22504
- var import_react113 = require("react");
22591
+ var import_react114 = require("react");
22505
22592
  var useTableExpandRow = () => {
22506
22593
  const {
22507
22594
  expandedAllRows,
@@ -22509,7 +22596,7 @@ var useTableExpandRow = () => {
22509
22596
  expandAllRows,
22510
22597
  expandedRows,
22511
22598
  setExpandedRows
22512
- } = (0, import_react113.useContext)(TableContext);
22599
+ } = (0, import_react114.useContext)(TableContext);
22513
22600
  const toggleAllRows = () => {
22514
22601
  if (expandedAllRows) {
22515
22602
  setIsOpen([]);
@@ -22537,7 +22624,7 @@ var useTableExpandRow = () => {
22537
22624
  };
22538
22625
 
22539
22626
  // src/utils/profitAndLossComparisonUtils.ts
22540
- var import_date_fns30 = require("date-fns");
22627
+ var import_date_fns31 = require("date-fns");
22541
22628
  var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) => {
22542
22629
  switch (rangeDisplayMode) {
22543
22630
  case "yearPicker":
@@ -22548,14 +22635,14 @@ var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) =
22548
22635
  };
22549
22636
  var generateComparisonMonths = (startDate, numberOfMonths) => {
22550
22637
  return Array.from({ length: numberOfMonths }, (_, index) => {
22551
- const currentMonth = (0, import_date_fns30.subMonths)(startDate, numberOfMonths - index - 1);
22552
- return { date: currentMonth, label: (0, import_date_fns30.format)(currentMonth, "MMM") };
22638
+ const currentMonth = (0, import_date_fns31.subMonths)(startDate, numberOfMonths - index - 1);
22639
+ return { date: currentMonth, label: (0, import_date_fns31.format)(currentMonth, "MMM") };
22553
22640
  });
22554
22641
  };
22555
22642
  var generateComparisonYears = (startDate, numberOfYears) => {
22556
22643
  return Array.from({ length: numberOfYears }, (_, index) => {
22557
- const currentMonth = (0, import_date_fns30.subYears)(startDate, numberOfYears - index - 1);
22558
- return { date: currentMonth, label: (0, import_date_fns30.format)(currentMonth, "yyyy") };
22644
+ const currentMonth = (0, import_date_fns31.subYears)(startDate, numberOfYears - index - 1);
22645
+ return { date: currentMonth, label: (0, import_date_fns31.format)(currentMonth, "yyyy") };
22559
22646
  });
22560
22647
  };
22561
22648
  var getComparisonValue = (name, depth, cellData) => {
@@ -22730,7 +22817,7 @@ var TableRow = ({
22730
22817
  };
22731
22818
 
22732
22819
  // src/components/Table/Table.tsx
22733
- var import_react114 = require("react");
22820
+ var import_react115 = require("react");
22734
22821
  var import_classnames64 = __toESM(require("classnames"));
22735
22822
  var import_jsx_runtime200 = require("react/jsx-runtime");
22736
22823
  var Table = ({
@@ -22739,9 +22826,9 @@ var Table = ({
22739
22826
  borderCollapse = "separate",
22740
22827
  bottomSpacing = true
22741
22828
  }) => {
22742
- const tableRef = (0, import_react114.useRef)(null);
22743
- const prevChildrenRef = (0, import_react114.useRef)([]);
22744
- (0, import_react114.useEffect)(() => {
22829
+ const tableRef = (0, import_react115.useRef)(null);
22830
+ const prevChildrenRef = (0, import_react115.useRef)([]);
22831
+ (0, import_react115.useEffect)(() => {
22745
22832
  if (tableRef.current) {
22746
22833
  const tbody = tableRef.current.querySelector("tbody");
22747
22834
  const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
@@ -22790,17 +22877,17 @@ var import_jsx_runtime201 = require("react/jsx-runtime");
22790
22877
  var ProfitAndLossCompareTable = ({
22791
22878
  stringOverrides
22792
22879
  }) => {
22793
- const { dateRange } = (0, import_react115.useContext)(ProfitAndLoss.Context);
22880
+ const { dateRange } = (0, import_react116.useContext)(ProfitAndLoss.Context);
22794
22881
  const {
22795
22882
  data: comparisonData,
22796
22883
  isLoading,
22797
22884
  comparePeriods,
22798
22885
  selectedCompareOptions
22799
- } = (0, import_react115.useContext)(ProfitAndLoss.ComparisonContext);
22886
+ } = (0, import_react116.useContext)(ProfitAndLoss.ComparisonContext);
22800
22887
  const { isOpen, setIsOpen } = useTableExpandRow();
22801
22888
  const { rangeDisplayMode } = useGlobalDateRange();
22802
22889
  const { data: bookkeepingPeriods } = useBookkeepingPeriods();
22803
- (0, import_react115.useEffect)(() => {
22890
+ (0, import_react116.useEffect)(() => {
22804
22891
  setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
22805
22892
  }, []);
22806
22893
  if (isLoading || comparisonData === void 0) {
@@ -22824,7 +22911,7 @@ var ProfitAndLossCompareTable = ({
22824
22911
  if (!period) {
22825
22912
  return;
22826
22913
  }
22827
- return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BookkeepingStatus, { status: period.status, monthNumber: currentMonth, iconOnly: true });
22914
+ return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BookkeepingStatus2, { status: period.status, monthNumber: currentMonth, iconOnly: true });
22828
22915
  };
22829
22916
  const renderRow = (rowKey, depth, rowDisplayName, lineItem, data) => {
22830
22917
  const rowData = data ? data : [];
@@ -22844,7 +22931,7 @@ var ProfitAndLossCompareTable = ({
22844
22931
  }
22845
22932
  const expandable = (lineItem == null ? void 0 : lineItem.line_items) && lineItem.line_items.length > 0 ? true : false;
22846
22933
  const expanded = expandable ? isOpen(rowKey) : true;
22847
- return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react115.Fragment, { children: [
22934
+ return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react116.Fragment, { children: [
22848
22935
  /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
22849
22936
  TableRow,
22850
22937
  {
@@ -22878,7 +22965,7 @@ var ProfitAndLossCompareTable = ({
22878
22965
  return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(Table, { borderCollapse: "collapse", bottomSpacing: false, children: [
22879
22966
  /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableHead, { children: selectedCompareOptions && selectedCompareOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
22880
22967
  /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
22881
- selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react115.Fragment, { children: [
22968
+ selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react116.Fragment, { children: [
22882
22969
  /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { primary: true, isHeaderCell: true, children: option.displayName }, option.displayName + "-" + i),
22883
22970
  comparePeriods && Array.from({ length: comparePeriods - 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }, option.displayName + "-" + index))
22884
22971
  ] }, option.displayName + "-" + i))
@@ -22886,7 +22973,7 @@ var ProfitAndLossCompareTable = ({
22886
22973
  /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableBody, { children: [
22887
22974
  comparePeriods && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
22888
22975
  /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
22889
- selectedCompareOptions && selectedCompareOptions.length > 0 ? selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react115.Fragment, { children: generateComparisonPeriods(
22976
+ selectedCompareOptions && selectedCompareOptions.length > 0 ? selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react116.Fragment, { children: generateComparisonPeriods(
22890
22977
  dateRange.startDate,
22891
22978
  comparePeriods,
22892
22979
  rangeDisplayMode
@@ -22894,7 +22981,7 @@ var ProfitAndLossCompareTable = ({
22894
22981
  month.label,
22895
22982
  " ",
22896
22983
  getBookkeepingPeriodStatus(month.date)
22897
- ] }) }, option.displayName + "-" + index)) }, option.displayName + "-" + i)) : /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react115.Fragment, { children: generateComparisonPeriods(
22984
+ ] }) }, option.displayName + "-" + index)) }, option.displayName + "-" + i)) : /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react116.Fragment, { children: generateComparisonPeriods(
22898
22985
  dateRange.startDate,
22899
22986
  comparePeriods,
22900
22987
  rangeDisplayMode
@@ -22926,7 +23013,7 @@ var ProfitAndLossCompareTable = ({
22926
23013
  };
22927
23014
 
22928
23015
  // src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
22929
- var import_react116 = require("react");
23016
+ var import_react117 = require("react");
22930
23017
 
22931
23018
  // src/icons/PieChart.tsx
22932
23019
  var import_jsx_runtime202 = require("react/jsx-runtime");
@@ -23025,9 +23112,9 @@ var ProfitAndLossTableComponent = ({
23025
23112
  data: actualData,
23026
23113
  isLoading,
23027
23114
  setSidebarScope
23028
- } = (0, import_react116.useContext)(ProfitAndLoss.Context);
23115
+ } = (0, import_react117.useContext)(ProfitAndLoss.Context);
23029
23116
  const { isOpen, setIsOpen } = useTableExpandRow();
23030
- (0, import_react116.useEffect)(() => {
23117
+ (0, import_react117.useEffect)(() => {
23031
23118
  setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
23032
23119
  }, []);
23033
23120
  const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
@@ -23047,7 +23134,7 @@ var ProfitAndLossTableComponent = ({
23047
23134
  const renderLineItem = (lineItem, depth, rowKey, rowIndex, scope, setSidebarScope2, variant) => {
23048
23135
  const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
23049
23136
  const expanded = expandable ? isOpen(rowKey) : true;
23050
- return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_react116.Fragment, { children: [
23137
+ return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_react117.Fragment, { children: [
23051
23138
  /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
23052
23139
  TableRow,
23053
23140
  {
@@ -23165,14 +23252,14 @@ var ProfitAndLossTableComponent = ({
23165
23252
  // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
23166
23253
  var import_jsx_runtime204 = require("react/jsx-runtime");
23167
23254
  var ProfitAndLossTableWithProvider = (props) => {
23168
- const { compareModeActive } = (0, import_react117.useContext)(ProfitAndLoss.ComparisonContext);
23255
+ const { compareModeActive } = (0, import_react118.useContext)(ProfitAndLoss.ComparisonContext);
23169
23256
  return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(TableProvider, { children: compareModeActive ? /* @__PURE__ */ (0, import_jsx_runtime204.jsx)("div", { className: "Layer__compare__table__wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(ProfitAndLossCompareTable, __spreadValues({}, props)) }) : /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(ProfitAndLossTableComponent, __spreadValues({}, props)) });
23170
23257
  };
23171
23258
 
23172
23259
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
23173
- var import_date_fns31 = require("date-fns");
23260
+ var import_date_fns32 = require("date-fns");
23174
23261
  var import_jsx_runtime205 = require("react/jsx-runtime");
23175
- var PNLContext = (0, import_react118.createContext)({
23262
+ var PNLContext = (0, import_react119.createContext)({
23176
23263
  data: void 0,
23177
23264
  filteredDataRevenue: [],
23178
23265
  filteredTotalRevenue: void 0,
@@ -23182,8 +23269,8 @@ var PNLContext = (0, import_react118.createContext)({
23182
23269
  isValidating: false,
23183
23270
  error: void 0,
23184
23271
  dateRange: {
23185
- startDate: (0, import_date_fns31.startOfMonth)(/* @__PURE__ */ new Date()),
23186
- endDate: (0, import_date_fns31.endOfMonth)(/* @__PURE__ */ new Date())
23272
+ startDate: (0, import_date_fns32.startOfMonth)(/* @__PURE__ */ new Date()),
23273
+ endDate: (0, import_date_fns32.endOfMonth)(/* @__PURE__ */ new Date())
23187
23274
  },
23188
23275
  changeDateRange: () => {
23189
23276
  },
@@ -23227,7 +23314,7 @@ ProfitAndLoss.DownloadButton = ProfitAndLossDownloadButton;
23227
23314
 
23228
23315
  // src/hooks/balanceSheet/useBalanceSheet.ts
23229
23316
  var import_swr16 = __toESM(require("swr"));
23230
- var import_date_fns32 = require("date-fns");
23317
+ var import_date_fns33 = require("date-fns");
23231
23318
  function buildKey15({
23232
23319
  access_token: accessToken,
23233
23320
  apiUrl,
@@ -23245,7 +23332,7 @@ function buildKey15({
23245
23332
  }
23246
23333
  }
23247
23334
  function useBalanceSheet({
23248
- effectiveDate = (0, import_date_fns32.endOfDay)(/* @__PURE__ */ new Date())
23335
+ effectiveDate = (0, import_date_fns33.endOfDay)(/* @__PURE__ */ new Date())
23249
23336
  }) {
23250
23337
  const { data: auth } = useAuth();
23251
23338
  const { apiUrl } = useEnvironment();
@@ -23270,12 +23357,12 @@ function useBalanceSheet({
23270
23357
  }
23271
23358
 
23272
23359
  // src/hooks/useElementViewSize/useElementViewSize.tsx
23273
- var import_react119 = require("react");
23360
+ var import_react120 = require("react");
23274
23361
  var useElementViewSize = () => {
23275
- const containerRef = (0, import_react119.useRef)(null);
23276
- const [view, setView] = (0, import_react119.useState)("desktop");
23277
- const resizeTimeout = (0, import_react119.useRef)(null);
23278
- (0, import_react119.useLayoutEffect)(() => {
23362
+ const containerRef = (0, import_react120.useRef)(null);
23363
+ const [view, setView] = (0, import_react120.useState)("desktop");
23364
+ const resizeTimeout = (0, import_react120.useRef)(null);
23365
+ (0, import_react120.useLayoutEffect)(() => {
23279
23366
  const element = containerRef == null ? void 0 : containerRef.current;
23280
23367
  if (!element) {
23281
23368
  return;
@@ -23344,7 +23431,7 @@ var BalanceSheetExpandAllButton = ({
23344
23431
  };
23345
23432
 
23346
23433
  // src/components/BalanceSheetTable/BalanceSheetTable.tsx
23347
- var import_react120 = require("react");
23434
+ var import_react121 = require("react");
23348
23435
  var import_jsx_runtime208 = require("react/jsx-runtime");
23349
23436
  var BalanceSheetTable = ({
23350
23437
  data,
@@ -23353,12 +23440,12 @@ var BalanceSheetTable = ({
23353
23440
  }) => {
23354
23441
  const { isOpen, setIsOpen, expandedAllRows } = useTableExpandRow();
23355
23442
  const allRowKeys = [];
23356
- (0, import_react120.useEffect)(() => {
23443
+ (0, import_react121.useEffect)(() => {
23357
23444
  if (expandedAllRows) {
23358
23445
  setIsOpen(allRowKeys, true);
23359
23446
  }
23360
23447
  }, [expandedAllRows]);
23361
- (0, import_react120.useEffect)(() => {
23448
+ (0, import_react121.useEffect)(() => {
23362
23449
  setIsOpen(["assets"]);
23363
23450
  }, []);
23364
23451
  const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
@@ -23368,7 +23455,7 @@ var BalanceSheetTable = ({
23368
23455
  if (expandable) {
23369
23456
  allRowKeys.push(rowKey);
23370
23457
  }
23371
- return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_react120.Fragment, { children: [
23458
+ return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_react121.Fragment, { children: [
23372
23459
  /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
23373
23460
  TableRow,
23374
23461
  {
@@ -23419,7 +23506,7 @@ var BalanceSheetTable = ({
23419
23506
  /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, children: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type" }),
23420
23507
  /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, align: "right" /* RIGHT */, children: (stringOverrides == null ? void 0 : stringOverrides.totalColumnHeader) || "Total" })
23421
23508
  ] }) }),
23422
- /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableBody, { children: config.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_react120.Fragment, { children: data[row.lineItem] && renderLineItem(
23509
+ /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableBody, { children: config.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_react121.Fragment, { children: data[row.lineItem] && renderLineItem(
23423
23510
  data[row.lineItem],
23424
23511
  0,
23425
23512
  row.lineItem,
@@ -23593,7 +23680,7 @@ var BalanceSheetView = ({
23593
23680
  };
23594
23681
 
23595
23682
  // src/components/StatementOfCashFlowTable/StatementOfCashFlowTable.tsx
23596
- var import_react121 = require("react");
23683
+ var import_react122 = require("react");
23597
23684
  var import_jsx_runtime211 = require("react/jsx-runtime");
23598
23685
  var StatementOfCashFlowTable = ({
23599
23686
  data,
@@ -23604,7 +23691,7 @@ var StatementOfCashFlowTable = ({
23604
23691
  const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
23605
23692
  const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
23606
23693
  const expanded = expandable ? isOpen(rowKey) : true;
23607
- return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(import_react121.Fragment, { children: [
23694
+ return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(import_react122.Fragment, { children: [
23608
23695
  /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
23609
23696
  TableRow,
23610
23697
  {
@@ -23656,7 +23743,7 @@ var StatementOfCashFlowTable = ({
23656
23743
  ] }) }),
23657
23744
  /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(TableBody, { children: config.map((row, idx) => {
23658
23745
  if (row.type === "line_item") {
23659
- return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_react121.Fragment, { children: data[row.lineItem] && renderLineItem(
23746
+ return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_react122.Fragment, { children: data[row.lineItem] && renderLineItem(
23660
23747
  data[row.lineItem],
23661
23748
  0,
23662
23749
  row.lineItem ? row.lineItem : "",
@@ -23862,7 +23949,7 @@ function StatementOfCashFlowDatePicker({
23862
23949
 
23863
23950
  // src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
23864
23951
  var import_swr17 = __toESM(require("swr"));
23865
- var import_date_fns33 = require("date-fns");
23952
+ var import_date_fns34 = require("date-fns");
23866
23953
  function buildKey18({
23867
23954
  access_token: accessToken,
23868
23955
  apiUrl,
@@ -23882,8 +23969,8 @@ function buildKey18({
23882
23969
  }
23883
23970
  }
23884
23971
  function useStatementOfCashFlow({
23885
- startDate = (0, import_date_fns33.startOfMonth)(/* @__PURE__ */ new Date()),
23886
- endDate = (0, import_date_fns33.endOfMonth)(/* @__PURE__ */ new Date())
23972
+ startDate = (0, import_date_fns34.startOfMonth)(/* @__PURE__ */ new Date()),
23973
+ endDate = (0, import_date_fns34.endOfMonth)(/* @__PURE__ */ new Date())
23887
23974
  }) {
23888
23975
  const { data: auth } = useAuth();
23889
23976
  const { apiUrl } = useEnvironment();
@@ -23958,12 +24045,12 @@ var StatementOfCashFlowView = ({
23958
24045
  };
23959
24046
 
23960
24047
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
23961
- var import_react135 = require("react");
24048
+ var import_react136 = require("react");
23962
24049
 
23963
24050
  // src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
23964
- var import_react122 = require("react");
23965
- var import_date_fns34 = require("date-fns");
23966
- var ChartOfAccountsContext = (0, import_react122.createContext)(
24051
+ var import_react123 = require("react");
24052
+ var import_date_fns35 = require("date-fns");
24053
+ var ChartOfAccountsContext = (0, import_react123.createContext)(
23967
24054
  {
23968
24055
  data: void 0,
23969
24056
  isLoading: false,
@@ -23985,8 +24072,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
23985
24072
  submitForm: () => {
23986
24073
  },
23987
24074
  dateRange: {
23988
- startDate: (0, import_date_fns34.startOfMonth)(/* @__PURE__ */ new Date()),
23989
- endDate: (0, import_date_fns34.endOfMonth)(/* @__PURE__ */ new Date())
24075
+ startDate: (0, import_date_fns35.startOfMonth)(/* @__PURE__ */ new Date()),
24076
+ endDate: (0, import_date_fns35.endOfMonth)(/* @__PURE__ */ new Date())
23990
24077
  },
23991
24078
  changeDateRange: () => {
23992
24079
  }
@@ -23994,8 +24081,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
23994
24081
  );
23995
24082
 
23996
24083
  // src/contexts/LedgerAccountsContext/LedgerAccountsContext.tsx
23997
- var import_react123 = require("react");
23998
- var LedgerAccountsContext = (0, import_react123.createContext)({
24084
+ var import_react124 = require("react");
24085
+ var LedgerAccountsContext = (0, import_react124.createContext)({
23999
24086
  data: void 0,
24000
24087
  entryData: void 0,
24001
24088
  isLoading: false,
@@ -24017,7 +24104,7 @@ var LedgerAccountsContext = (0, import_react123.createContext)({
24017
24104
  });
24018
24105
 
24019
24106
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
24020
- var import_react124 = require("react");
24107
+ var import_react125 = require("react");
24021
24108
 
24022
24109
  // src/components/ChartOfAccountsForm/constants.ts
24023
24110
  var LEDGER_ACCOUNT_TYPES = [
@@ -24221,7 +24308,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
24221
24308
  };
24222
24309
 
24223
24310
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
24224
- var import_date_fns35 = require("date-fns");
24311
+ var import_date_fns36 = require("date-fns");
24225
24312
  var import_swr18 = __toESM(require("swr"));
24226
24313
  var validate = (formData) => {
24227
24314
  const errors = [];
@@ -24305,8 +24392,8 @@ var validateName = (formData) => {
24305
24392
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
24306
24393
  var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
24307
24394
  withDates: false,
24308
- startDate: (0, import_date_fns35.startOfMonth)(/* @__PURE__ */ new Date()),
24309
- endDate: (0, import_date_fns35.endOfMonth)(/* @__PURE__ */ new Date())
24395
+ startDate: (0, import_date_fns36.startOfMonth)(/* @__PURE__ */ new Date()),
24396
+ endDate: (0, import_date_fns36.endOfMonth)(/* @__PURE__ */ new Date())
24310
24397
  }) => {
24311
24398
  const {
24312
24399
  businessId,
@@ -24317,14 +24404,14 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
24317
24404
  } = useLayerContext();
24318
24405
  const { apiUrl } = useEnvironment();
24319
24406
  const { data: auth } = useAuth();
24320
- const [form, setForm] = (0, import_react124.useState)();
24321
- const [sendingForm, setSendingForm] = (0, import_react124.useState)(false);
24322
- const [apiError, setApiError] = (0, import_react124.useState)(void 0);
24323
- const [startDate, setStartDate] = (0, import_react124.useState)(
24324
- initialStartDate != null ? initialStartDate : (0, import_date_fns35.startOfMonth)(Date.now())
24407
+ const [form, setForm] = (0, import_react125.useState)();
24408
+ const [sendingForm, setSendingForm] = (0, import_react125.useState)(false);
24409
+ const [apiError, setApiError] = (0, import_react125.useState)(void 0);
24410
+ const [startDate, setStartDate] = (0, import_react125.useState)(
24411
+ initialStartDate != null ? initialStartDate : (0, import_date_fns36.startOfMonth)(Date.now())
24325
24412
  );
24326
- const [endDate, setEndDate] = (0, import_react124.useState)(
24327
- initialEndDate != null ? initialEndDate : (0, import_date_fns35.endOfMonth)(Date.now())
24413
+ const [endDate, setEndDate] = (0, import_react125.useState)(
24414
+ initialEndDate != null ? initialEndDate : (0, import_date_fns36.endOfMonth)(Date.now())
24328
24415
  );
24329
24416
  const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `chart-of-accounts-${businessId}-${startDate == null ? void 0 : startDate.valueOf()}-${endDate == null ? void 0 : endDate.valueOf()}`;
24330
24417
  const { data, isLoading, isValidating, error, mutate } = (0, import_swr18.default)(
@@ -24332,8 +24419,8 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
24332
24419
  Layer.getLedgerAccountBalances(apiUrl, auth == null ? void 0 : auth.access_token, {
24333
24420
  params: {
24334
24421
  businessId,
24335
- startDate: withDates && startDate ? (0, import_date_fns35.formatISO)(startDate.valueOf()) : void 0,
24336
- endDate: withDates && endDate ? (0, import_date_fns35.formatISO)(endDate.valueOf()) : void 0
24422
+ startDate: withDates && startDate ? (0, import_date_fns36.formatISO)(startDate.valueOf()) : void 0,
24423
+ endDate: withDates && endDate ? (0, import_date_fns36.formatISO)(endDate.valueOf()) : void 0
24337
24424
  }
24338
24425
  })
24339
24426
  );
@@ -24505,12 +24592,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
24505
24592
  newEndDate && setEndDate(newEndDate);
24506
24593
  };
24507
24594
  const refetch = () => mutate();
24508
- (0, import_react124.useEffect)(() => {
24595
+ (0, import_react125.useEffect)(() => {
24509
24596
  if (queryKey && (isLoading || isValidating)) {
24510
24597
  read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */, queryKey);
24511
24598
  }
24512
24599
  }, [isLoading, isValidating]);
24513
- (0, import_react124.useEffect)(() => {
24600
+ (0, import_react125.useEffect)(() => {
24514
24601
  if (queryKey && hasBeenTouched(queryKey)) {
24515
24602
  refetch();
24516
24603
  }
@@ -24538,17 +24625,17 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
24538
24625
  // src/hooks/useChartOfAccounts/useCreateChildAccount.tsx
24539
24626
  var import_mutation9 = __toESM(require("swr/mutation"));
24540
24627
  var import_swr19 = require("swr");
24541
- var import_react125 = require("react");
24628
+ var import_react126 = require("react");
24542
24629
 
24543
24630
  // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
24544
- var import_react126 = require("react");
24631
+ var import_react127 = require("react");
24545
24632
  var import_swr20 = __toESM(require("swr"));
24546
24633
  var useLedgerAccounts = (showReversalEntries = false) => {
24547
24634
  const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
24548
24635
  const { apiUrl } = useEnvironment();
24549
24636
  const { data: auth } = useAuth();
24550
- const [accountId, setAccountId] = (0, import_react126.useState)();
24551
- const [selectedEntryId, setSelectedEntryId] = (0, import_react126.useState)();
24637
+ const [accountId, setAccountId] = (0, import_react127.useState)();
24638
+ const [selectedEntryId, setSelectedEntryId] = (0, import_react127.useState)();
24552
24639
  const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
24553
24640
  const { data, isLoading, isValidating, error, mutate } = (0, import_swr20.default)(
24554
24641
  queryKey,
@@ -24577,12 +24664,12 @@ var useLedgerAccounts = (showReversalEntries = false) => {
24577
24664
  setSelectedEntryId(void 0);
24578
24665
  mutateEntryData();
24579
24666
  };
24580
- (0, import_react126.useEffect)(() => {
24667
+ (0, import_react127.useEffect)(() => {
24581
24668
  if (queryKey && (isLoading || isValidating)) {
24582
24669
  read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
24583
24670
  }
24584
24671
  }, [isLoading, isValidating]);
24585
- (0, import_react126.useEffect)(() => {
24672
+ (0, import_react127.useEffect)(() => {
24586
24673
  if (queryKey && hasBeenTouched(queryKey)) {
24587
24674
  refetch();
24588
24675
  }
@@ -24606,7 +24693,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
24606
24693
  };
24607
24694
 
24608
24695
  // src/components/ChartOfAccountsTable/ChartOfAccountsTableWithPanel.tsx
24609
- var import_react131 = require("react");
24696
+ var import_react132 = require("react");
24610
24697
 
24611
24698
  // src/icons/Plus.tsx
24612
24699
  var import_jsx_runtime215 = require("react/jsx-runtime");
@@ -24647,11 +24734,11 @@ var Plus = (_a) => {
24647
24734
  var Plus_default = Plus;
24648
24735
 
24649
24736
  // src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
24650
- var import_react127 = require("react");
24651
- var import_date_fns36 = require("date-fns");
24737
+ var import_react128 = require("react");
24738
+ var import_date_fns37 = require("date-fns");
24652
24739
  var import_jsx_runtime216 = require("react/jsx-runtime");
24653
24740
  var ChartOfAccountsDatePicker = () => {
24654
- const { changeDateRange, dateRange } = (0, import_react127.useContext)(ChartOfAccountsContext);
24741
+ const { changeDateRange, dateRange } = (0, import_react128.useContext)(ChartOfAccountsContext);
24655
24742
  return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(
24656
24743
  DatePicker,
24657
24744
  {
@@ -24660,8 +24747,8 @@ var ChartOfAccountsDatePicker = () => {
24660
24747
  onChange: (date) => {
24661
24748
  if (!Array.isArray(date)) {
24662
24749
  changeDateRange({
24663
- startDate: (0, import_date_fns36.startOfMonth)(date),
24664
- endDate: (0, import_date_fns36.endOfMonth)(date)
24750
+ startDate: (0, import_date_fns37.startOfMonth)(date),
24751
+ endDate: (0, import_date_fns37.endOfMonth)(date)
24665
24752
  });
24666
24753
  }
24667
24754
  }
@@ -24670,13 +24757,13 @@ var ChartOfAccountsDatePicker = () => {
24670
24757
  };
24671
24758
 
24672
24759
  // src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
24673
- var import_react129 = require("react");
24760
+ var import_react130 = require("react");
24674
24761
 
24675
24762
  // src/components/ChartOfAccountsForm/useParentOptions.ts
24676
- var import_react128 = require("react");
24763
+ var import_react129 = require("react");
24677
24764
  var useParentOptions = (data) => {
24678
24765
  var _a;
24679
- return (0, import_react128.useMemo)(
24766
+ return (0, import_react129.useMemo)(
24680
24767
  () => flattenAccounts((data == null ? void 0 : data.accounts) || []).sort((a, b) => (a == null ? void 0 : a.name) && (b == null ? void 0 : b.name) ? a.name.localeCompare(b.name) : 0).map((x) => {
24681
24768
  return {
24682
24769
  label: x.name,
@@ -24701,9 +24788,9 @@ var ChartOfAccountsForm = ({
24701
24788
  submitForm,
24702
24789
  sendingForm,
24703
24790
  apiError
24704
- } = (0, import_react129.useContext)(ChartOfAccountsContext);
24791
+ } = (0, import_react130.useContext)(ChartOfAccountsContext);
24705
24792
  const parentOptions = useParentOptions(data);
24706
- const entry = (0, import_react129.useMemo)(() => {
24793
+ const entry = (0, import_react130.useMemo)(() => {
24707
24794
  if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
24708
24795
  return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
24709
24796
  (x) => x.id === form.accountId
@@ -24916,7 +25003,7 @@ var ChartOfAccountsSidebar = ({
24916
25003
  };
24917
25004
 
24918
25005
  // src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
24919
- var import_react130 = require("react");
25006
+ var import_react131 = require("react");
24920
25007
 
24921
25008
  // src/icons/Edit2.tsx
24922
25009
  var import_jsx_runtime219 = require("react/jsx-runtime");
@@ -24976,18 +25063,18 @@ var ChartOfAccountsTableContent = ({
24976
25063
  expandAll,
24977
25064
  templateAccountsEditable
24978
25065
  }) => {
24979
- const { setAccountId } = (0, import_react130.useContext)(LedgerAccountsContext);
24980
- const { editAccount } = (0, import_react130.useContext)(ChartOfAccountsContext);
25066
+ const { setAccountId } = (0, import_react131.useContext)(LedgerAccountsContext);
25067
+ const { editAccount } = (0, import_react131.useContext)(ChartOfAccountsContext);
24981
25068
  const { isOpen, setIsOpen } = useTableExpandRow();
24982
- const [accountsRowKeys, setAccountsRowKeys] = (0, import_react130.useState)([]);
24983
- (0, import_react130.useEffect)(() => {
25069
+ const [accountsRowKeys, setAccountsRowKeys] = (0, import_react131.useState)([]);
25070
+ (0, import_react131.useEffect)(() => {
24984
25071
  if (expandAll === "expanded") {
24985
25072
  setIsOpen(accountsRowKeys);
24986
25073
  } else if (expandAll === "collapsed") {
24987
25074
  setIsOpen([]);
24988
25075
  }
24989
25076
  }, [expandAll]);
24990
- (0, import_react130.useEffect)(() => {
25077
+ (0, import_react131.useEffect)(() => {
24991
25078
  const defaultExpanded = data.accounts.map(
24992
25079
  (account) => "coa-row-" + account.id
24993
25080
  );
@@ -25006,7 +25093,7 @@ var ChartOfAccountsTableContent = ({
25006
25093
  var _a, _b;
25007
25094
  const expandable = !!account.sub_accounts && account.sub_accounts.length > 0;
25008
25095
  const expanded = expandable ? isOpen(rowKey) : true;
25009
- return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_react130.Fragment, { children: [
25096
+ return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_react131.Fragment, { children: [
25010
25097
  /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
25011
25098
  TableRow,
25012
25099
  {
@@ -25182,8 +25269,8 @@ var ChartOfAccountsTableWithPanel = ({
25182
25269
  templateAccountsEditable
25183
25270
  }) => {
25184
25271
  var _a;
25185
- const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react131.useContext)(ChartOfAccountsContext);
25186
- const [expandAll, setExpandAll] = (0, import_react131.useState)();
25272
+ const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react132.useContext)(ChartOfAccountsContext);
25273
+ const [expandAll, setExpandAll] = (0, import_react132.useState)();
25187
25274
  const cumulativeIndex = 0;
25188
25275
  const accountsLength = (_a = data == null ? void 0 : data.accounts.length) != null ? _a : 0;
25189
25276
  return /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)(
@@ -25288,10 +25375,10 @@ var ChartOfAccountsTableWithPanel = ({
25288
25375
  };
25289
25376
 
25290
25377
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
25291
- var import_react134 = require("react");
25378
+ var import_react135 = require("react");
25292
25379
 
25293
25380
  // src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
25294
- var import_react132 = require("react");
25381
+ var import_react133 = require("react");
25295
25382
 
25296
25383
  // src/utils/journal.ts
25297
25384
  var getAccountIdentifierPayload = (journalLineItem) => {
@@ -25319,21 +25406,21 @@ var lineEntryNumber = (ledgerEntryLine) => {
25319
25406
  };
25320
25407
 
25321
25408
  // src/components/DateTime/DateTime.tsx
25322
- var import_date_fns37 = require("date-fns");
25409
+ var import_date_fns38 = require("date-fns");
25323
25410
  var import_jsx_runtime223 = require("react/jsx-runtime");
25324
25411
  var DateTime = ({
25325
25412
  value,
25326
- format: format7,
25413
+ format: format8,
25327
25414
  dateFormat,
25328
25415
  timeFormat,
25329
25416
  onlyDate,
25330
25417
  onlyTime
25331
25418
  }) => {
25332
- if (format7) {
25333
- return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0, import_date_fns37.format)((0, import_date_fns37.parseISO)(value), format7) });
25419
+ if (format8) {
25420
+ return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), format8) });
25334
25421
  }
25335
- const date = (0, import_date_fns37.format)((0, import_date_fns37.parseISO)(value), dateFormat != null ? dateFormat : DATE_FORMAT);
25336
- const time = (0, import_date_fns37.format)((0, import_date_fns37.parseISO)(value), timeFormat != null ? timeFormat : TIME_FORMAT);
25422
+ const date = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), dateFormat != null ? dateFormat : DATE_FORMAT);
25423
+ const time = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), timeFormat != null ? timeFormat : TIME_FORMAT);
25337
25424
  return /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)(Text, { className: "Layer__datetime", children: [
25338
25425
  !onlyTime && /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(
25339
25426
  Text,
@@ -25535,8 +25622,8 @@ var LedgerAccountEntryDetails = ({
25535
25622
  stringOverrides
25536
25623
  }) => {
25537
25624
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
25538
- const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react132.useContext)(LedgerAccountsContext);
25539
- const { totalDebit, totalCredit } = (0, import_react132.useMemo)(() => {
25625
+ const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react133.useContext)(LedgerAccountsContext);
25626
+ const { totalDebit, totalCredit } = (0, import_react133.useMemo)(() => {
25540
25627
  var _a2;
25541
25628
  let totalDebit2 = 0;
25542
25629
  let totalCredit2 = 0;
@@ -25682,9 +25769,9 @@ var LedgerAccountEntryDetails = ({
25682
25769
  };
25683
25770
 
25684
25771
  // src/components/LedgerAccount/LedgerAccountRow.tsx
25685
- var import_react133 = require("react");
25772
+ var import_react134 = require("react");
25686
25773
  var import_classnames68 = __toESM(require("classnames"));
25687
- var import_date_fns38 = require("date-fns");
25774
+ var import_date_fns39 = require("date-fns");
25688
25775
  var import_jsx_runtime227 = require("react/jsx-runtime");
25689
25776
  var LedgerAccountRow = ({
25690
25777
  row,
@@ -25693,9 +25780,9 @@ var LedgerAccountRow = ({
25693
25780
  view
25694
25781
  }) => {
25695
25782
  var _a, _b, _c, _d, _e, _f;
25696
- const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react133.useContext)(LedgerAccountsContext);
25697
- const [showComponent, setShowComponent] = (0, import_react133.useState)(false);
25698
- (0, import_react133.useEffect)(() => {
25783
+ const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react134.useContext)(LedgerAccountsContext);
25784
+ const [showComponent, setShowComponent] = (0, import_react134.useState)(false);
25785
+ (0, import_react134.useEffect)(() => {
25699
25786
  if (initialLoad) {
25700
25787
  const timeoutId = setTimeout(() => {
25701
25788
  setShowComponent(true);
@@ -25727,7 +25814,7 @@ var LedgerAccountRow = ({
25727
25814
  children: [
25728
25815
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("span", { className: "Layer__table-cell-content", children: [
25729
25816
  /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
25730
- /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(row.date), DATE_FORMAT) }),
25817
+ /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
25731
25818
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
25732
25819
  Text,
25733
25820
  {
@@ -25767,7 +25854,7 @@ var LedgerAccountRow = ({
25767
25854
  },
25768
25855
  children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("span", { className: "Layer__table-cell-content", children: [
25769
25856
  /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
25770
- /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(row.date), DATE_FORMAT) }),
25857
+ /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
25771
25858
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
25772
25859
  Text,
25773
25860
  {
@@ -25818,7 +25905,7 @@ var LedgerAccountRow = ({
25818
25905
  }
25819
25906
  },
25820
25907
  children: [
25821
- /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(row.date), DATE_FORMAT) }) }),
25908
+ /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }) }),
25822
25909
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
25823
25910
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }) }),
25824
25911
  /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
@@ -25839,9 +25926,9 @@ var LedgerAccount = ({
25839
25926
  stringOverrides
25840
25927
  }) => {
25841
25928
  var _a, _b, _c, _d, _e, _f, _g, _h;
25842
- const [currentPage, setCurrentPage] = (0, import_react134.useState)(1);
25843
- const [initialLoad, setInitialLoad] = (0, import_react134.useState)(true);
25844
- const { data: accountData } = (0, import_react134.useContext)(ChartOfAccountsContext);
25929
+ const [currentPage, setCurrentPage] = (0, import_react135.useState)(1);
25930
+ const [initialLoad, setInitialLoad] = (0, import_react135.useState)(true);
25931
+ const { data: accountData } = (0, import_react135.useContext)(ChartOfAccountsContext);
25845
25932
  const {
25846
25933
  data: rawData,
25847
25934
  error,
@@ -25852,8 +25939,8 @@ var LedgerAccount = ({
25852
25939
  selectedEntryId,
25853
25940
  closeSelectedEntry,
25854
25941
  refetch
25855
- } = (0, import_react134.useContext)(LedgerAccountsContext);
25856
- (0, import_react134.useEffect)(() => {
25942
+ } = (0, import_react135.useContext)(LedgerAccountsContext);
25943
+ (0, import_react135.useEffect)(() => {
25857
25944
  if (!isLoading) {
25858
25945
  const timeoutLoad = setTimeout(() => {
25859
25946
  setInitialLoad(false);
@@ -25865,12 +25952,12 @@ var LedgerAccount = ({
25865
25952
  "Layer__ledger-account__index",
25866
25953
  accountId && "open"
25867
25954
  );
25868
- const account = (0, import_react134.useMemo)(() => {
25955
+ const account = (0, import_react135.useMemo)(() => {
25869
25956
  return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
25870
25957
  (x) => x.id === accountId
25871
25958
  );
25872
25959
  }, [accountId]);
25873
- const data = (0, import_react134.useMemo)(() => {
25960
+ const data = (0, import_react135.useMemo)(() => {
25874
25961
  var _a2;
25875
25962
  const firstPageIndex = (currentPage - 1) * pageSize;
25876
25963
  const lastPageIndex = firstPageIndex + pageSize;
@@ -26008,7 +26095,7 @@ var ChartOfAccountsContent = ({
26008
26095
  templateAccountsEditable,
26009
26096
  showAddAccountButton
26010
26097
  }) => {
26011
- const { accountId } = (0, import_react135.useContext)(LedgerAccountsContext);
26098
+ const { accountId } = (0, import_react136.useContext)(LedgerAccountsContext);
26012
26099
  const { view, containerRef } = useElementViewSize();
26013
26100
  return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(Container, { name: "chart-of-accounts", ref: containerRef, asWidget, children: accountId ? /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
26014
26101
  LedgerAccount,
@@ -26033,8 +26120,8 @@ var ChartOfAccountsContent = ({
26033
26120
  };
26034
26121
 
26035
26122
  // src/contexts/JournalContext/JournalContext.tsx
26036
- var import_react136 = require("react");
26037
- var JournalContext = (0, import_react136.createContext)({
26123
+ var import_react137 = require("react");
26124
+ var JournalContext = (0, import_react137.createContext)({
26038
26125
  data: void 0,
26039
26126
  isLoading: false,
26040
26127
  error: void 0,
@@ -26068,7 +26155,7 @@ var JournalContext = (0, import_react136.createContext)({
26068
26155
  });
26069
26156
 
26070
26157
  // src/hooks/useJournal/useJournal.tsx
26071
- var import_react137 = require("react");
26158
+ var import_react138 = require("react");
26072
26159
  var import_swr21 = __toESM(require("swr"));
26073
26160
  var useJournal = () => {
26074
26161
  const {
@@ -26080,11 +26167,11 @@ var useJournal = () => {
26080
26167
  } = useLayerContext();
26081
26168
  const { apiUrl } = useEnvironment();
26082
26169
  const { data: auth } = useAuth();
26083
- const [selectedEntryId, setSelectedEntryId] = (0, import_react137.useState)();
26084
- const [form, setForm] = (0, import_react137.useState)();
26085
- const [addingEntry, setAddingEntry] = (0, import_react137.useState)(false);
26086
- const [sendingForm, setSendingForm] = (0, import_react137.useState)(false);
26087
- const [apiError, setApiError] = (0, import_react137.useState)(void 0);
26170
+ const [selectedEntryId, setSelectedEntryId] = (0, import_react138.useState)();
26171
+ const [form, setForm] = (0, import_react138.useState)();
26172
+ const [addingEntry, setAddingEntry] = (0, import_react138.useState)(false);
26173
+ const [sendingForm, setSendingForm] = (0, import_react138.useState)(false);
26174
+ const [apiError, setApiError] = (0, import_react138.useState)(void 0);
26088
26175
  const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `journal-lines-${businessId}`;
26089
26176
  const { data, isLoading, isValidating, error, mutate } = (0, import_swr21.default)(
26090
26177
  queryKey,
@@ -26300,12 +26387,12 @@ var useJournal = () => {
26300
26387
  params: { businessId, entryId }
26301
26388
  });
26302
26389
  });
26303
- (0, import_react137.useEffect)(() => {
26390
+ (0, import_react138.useEffect)(() => {
26304
26391
  if (queryKey && (isLoading || isValidating)) {
26305
26392
  read("JOURNAL" /* JOURNAL */, queryKey);
26306
26393
  }
26307
26394
  }, [isLoading, isValidating]);
26308
- (0, import_react137.useEffect)(() => {
26395
+ (0, import_react138.useEffect)(() => {
26309
26396
  if (queryKey && hasBeenTouched(queryKey)) {
26310
26397
  refetch();
26311
26398
  }
@@ -26337,13 +26424,13 @@ var useJournal = () => {
26337
26424
  };
26338
26425
 
26339
26426
  // src/components/JournalTable/JournalTableWithPanel.tsx
26340
- var import_react143 = require("react");
26427
+ var import_react144 = require("react");
26341
26428
 
26342
26429
  // src/components/JournalSidebar/JournalSidebar.tsx
26343
- var import_react141 = require("react");
26430
+ var import_react142 = require("react");
26344
26431
 
26345
26432
  // src/components/JournalEntryDetails/JournalEntryDetails.tsx
26346
- var import_react138 = require("react");
26433
+ var import_react139 = require("react");
26347
26434
  var import_jsx_runtime230 = require("react/jsx-runtime");
26348
26435
  var JournalEntryDetails = () => {
26349
26436
  var _a, _b, _c, _d;
@@ -26355,16 +26442,16 @@ var JournalEntryDetails = () => {
26355
26442
  selectedEntryId,
26356
26443
  reverseEntry,
26357
26444
  refetch
26358
- } = (0, import_react138.useContext)(JournalContext);
26359
- const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react138.useState)(false);
26360
- const [reverseEntryError, setReverseEntryError] = (0, import_react138.useState)();
26361
- const entry = (0, import_react138.useMemo)(() => {
26445
+ } = (0, import_react139.useContext)(JournalContext);
26446
+ const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react139.useState)(false);
26447
+ const [reverseEntryError, setReverseEntryError] = (0, import_react139.useState)();
26448
+ const entry = (0, import_react139.useMemo)(() => {
26362
26449
  if (selectedEntryId && data) {
26363
26450
  return data.find((x) => x.id === selectedEntryId);
26364
26451
  }
26365
26452
  return;
26366
26453
  }, [data, selectedEntryId]);
26367
- const sortedLineItems = (0, import_react138.useMemo)(
26454
+ const sortedLineItems = (0, import_react139.useMemo)(
26368
26455
  () => {
26369
26456
  var _a2;
26370
26457
  return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
@@ -26542,10 +26629,10 @@ var JournalEntryDetails = () => {
26542
26629
  };
26543
26630
 
26544
26631
  // src/components/JournalForm/JournalForm.tsx
26545
- var import_react140 = require("react");
26632
+ var import_react141 = require("react");
26546
26633
 
26547
26634
  // src/components/JournalForm/JournalFormEntryLines.tsx
26548
- var import_react139 = require("react");
26635
+ var import_react140 = require("react");
26549
26636
  var import_jsx_runtime231 = require("react/jsx-runtime");
26550
26637
  function recursiveFlattenCategories(accounts) {
26551
26638
  const flattenedResult = accounts.flatMap((a) => {
@@ -26566,8 +26653,8 @@ var JournalFormEntryLines = ({
26566
26653
  config
26567
26654
  }) => {
26568
26655
  const { data: categories } = useCategories({ mode: "ALL" });
26569
- const { form } = (0, import_react139.useContext)(JournalContext);
26570
- const { flattenedCategories, parentOptions } = (0, import_react139.useMemo)(() => {
26656
+ const { form } = (0, import_react140.useContext)(JournalContext);
26657
+ const { flattenedCategories, parentOptions } = (0, import_react140.useMemo)(() => {
26571
26658
  const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
26572
26659
  const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
26573
26660
  switch (account.type) {
@@ -26779,7 +26866,7 @@ var JournalForm = ({
26779
26866
  changeFormData,
26780
26867
  addEntryLine,
26781
26868
  removeEntryLine
26782
- } = (0, import_react140.useContext)(JournalContext);
26869
+ } = (0, import_react141.useContext)(JournalContext);
26783
26870
  return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
26784
26871
  "form",
26785
26872
  {
@@ -26927,7 +27014,7 @@ var JournalSidebar = ({
26927
27014
  config,
26928
27015
  stringOverrides
26929
27016
  }) => {
26930
- const { selectedEntryId } = (0, import_react141.useContext)(JournalContext);
27017
+ const { selectedEntryId } = (0, import_react142.useContext)(JournalContext);
26931
27018
  if (selectedEntryId !== "new") {
26932
27019
  return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(JournalEntryDetails, {});
26933
27020
  }
@@ -26935,8 +27022,8 @@ var JournalSidebar = ({
26935
27022
  };
26936
27023
 
26937
27024
  // src/components/JournalTable/JournalTable.tsx
26938
- var import_react142 = require("react");
26939
- var import_date_fns39 = require("date-fns");
27025
+ var import_react143 = require("react");
27026
+ var import_date_fns40 = require("date-fns");
26940
27027
  var import_jsx_runtime234 = require("react/jsx-runtime");
26941
27028
  var accountName = (row) => {
26942
27029
  if ("account" in row) {
@@ -26963,9 +27050,9 @@ var JournalTableContent = ({
26963
27050
  data,
26964
27051
  stringOverrides
26965
27052
  }) => {
26966
- const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react142.useContext)(JournalContext);
27053
+ const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react143.useContext)(JournalContext);
26967
27054
  const { isOpen, setIsOpen } = useTableExpandRow();
26968
- (0, import_react142.useEffect)(() => {
27055
+ (0, import_react143.useEffect)(() => {
26969
27056
  if (data.length > 0) {
26970
27057
  setIsOpen(data.map((x) => `journal-row-${x.id}`));
26971
27058
  }
@@ -26973,7 +27060,7 @@ var JournalTableContent = ({
26973
27060
  const renderJournalRow = (row, index, rowKey, depth) => {
26974
27061
  const expandable = !!row.line_items && row.line_items.length > 0;
26975
27062
  const expanded = expandable ? isOpen(rowKey) : true;
26976
- return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_react142.Fragment, { children: [
27063
+ return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_react143.Fragment, { children: [
26977
27064
  /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
26978
27065
  TableRow,
26979
27066
  {
@@ -27003,7 +27090,7 @@ var JournalTableContent = ({
27003
27090
  children: entryNumber(row)
27004
27091
  }
27005
27092
  ),
27006
- /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: row.entry_at && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.entry_at), DATE_FORMAT) }),
27093
+ /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: row.entry_at && (0, import_date_fns40.format)((0, import_date_fns40.parseISO)(row.entry_at), DATE_FORMAT) }),
27007
27094
  /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: humanizeEnum(row.entry_type) }),
27008
27095
  /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(TableCell, { children: [
27009
27096
  "(",
@@ -27149,7 +27236,7 @@ var JournalTableWithPanel = ({
27149
27236
  stringOverrides,
27150
27237
  view
27151
27238
  }) => {
27152
- const [currentPage, setCurrentPage] = (0, import_react143.useState)(1);
27239
+ const [currentPage, setCurrentPage] = (0, import_react144.useState)(1);
27153
27240
  const {
27154
27241
  data: rawData,
27155
27242
  isLoading,
@@ -27158,8 +27245,8 @@ var JournalTableWithPanel = ({
27158
27245
  refetch,
27159
27246
  selectedEntryId,
27160
27247
  addEntry
27161
- } = (0, import_react143.useContext)(JournalContext);
27162
- const data = (0, import_react143.useMemo)(() => {
27248
+ } = (0, import_react144.useContext)(JournalContext);
27249
+ const data = (0, import_react144.useMemo)(() => {
27163
27250
  var _a;
27164
27251
  const firstPageIndex = (currentPage - 1) * pageSize;
27165
27252
  const lastPageIndex = firstPageIndex + pageSize;
@@ -27296,7 +27383,7 @@ var TasksHeader = ({
27296
27383
  };
27297
27384
 
27298
27385
  // src/components/Tasks/TasksList.tsx
27299
- var import_react151 = require("react");
27386
+ var import_react152 = require("react");
27300
27387
 
27301
27388
  // src/icons/SmileIcon.tsx
27302
27389
  var import_jsx_runtime239 = require("react/jsx-runtime");
@@ -27355,7 +27442,7 @@ var SmileIcon = (_a) => {
27355
27442
  var SmileIcon_default = SmileIcon;
27356
27443
 
27357
27444
  // src/components/Tasks/TasksListItem.tsx
27358
- var import_react148 = require("react");
27445
+ var import_react149 = require("react");
27359
27446
  var import_classnames70 = __toESM(require("classnames"));
27360
27447
 
27361
27448
  // src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
@@ -27413,7 +27500,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
27413
27500
  }
27414
27501
 
27415
27502
  // src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
27416
- var import_react144 = require("react");
27503
+ var import_react145 = require("react");
27417
27504
  function buildKey21({
27418
27505
  access_token: accessToken,
27419
27506
  apiUrl,
@@ -27456,7 +27543,7 @@ function useSubmitUserResponseForTask() {
27456
27543
  }
27457
27544
  );
27458
27545
  const { trigger: originalTrigger } = mutationResponse;
27459
- const stableProxiedTrigger = (0, import_react144.useCallback)(
27546
+ const stableProxiedTrigger = (0, import_react145.useCallback)(
27460
27547
  (...triggerParameters) => __async(null, null, function* () {
27461
27548
  const triggerResult = yield originalTrigger(...triggerParameters);
27462
27549
  void mutate((key) => withSWRKeyTags(
@@ -27483,7 +27570,7 @@ function useSubmitUserResponseForTask() {
27483
27570
  // src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
27484
27571
  var import_swr23 = require("swr");
27485
27572
  var import_mutation13 = __toESM(require("swr/mutation"));
27486
- var import_react145 = require("react");
27573
+ var import_react146 = require("react");
27487
27574
  function buildKey22({
27488
27575
  access_token: accessToken,
27489
27576
  apiUrl,
@@ -27522,7 +27609,7 @@ function useUploadDocumentsForTask() {
27522
27609
  }
27523
27610
  );
27524
27611
  const { trigger: originalTrigger } = mutationResponse;
27525
- const stableProxiedTrigger = (0, import_react145.useCallback)(
27612
+ const stableProxiedTrigger = (0, import_react146.useCallback)(
27526
27613
  (...triggerParameters) => __async(null, null, function* () {
27527
27614
  const triggerResult = yield originalTrigger(...triggerParameters);
27528
27615
  void mutate((key) => withSWRKeyTags(
@@ -27549,7 +27636,7 @@ function useUploadDocumentsForTask() {
27549
27636
  // src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
27550
27637
  var import_swr24 = require("swr");
27551
27638
  var import_mutation14 = __toESM(require("swr/mutation"));
27552
- var import_react146 = require("react");
27639
+ var import_react147 = require("react");
27553
27640
  function buildKey23({
27554
27641
  access_token: accessToken,
27555
27642
  apiUrl,
@@ -27585,7 +27672,7 @@ function useDeleteUploadsOnTask() {
27585
27672
  }
27586
27673
  );
27587
27674
  const { trigger: originalTrigger } = mutationResponse;
27588
- const stableProxiedTrigger = (0, import_react146.useCallback)(
27675
+ const stableProxiedTrigger = (0, import_react147.useCallback)(
27589
27676
  (...triggerParameters) => __async(null, null, function* () {
27590
27677
  const triggerResult = yield originalTrigger(...triggerParameters);
27591
27678
  void mutate((key) => withSWRKeyTags(
@@ -27612,7 +27699,7 @@ function useDeleteUploadsOnTask() {
27612
27699
  // src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
27613
27700
  var import_swr25 = require("swr");
27614
27701
  var import_mutation15 = __toESM(require("swr/mutation"));
27615
- var import_react147 = require("react");
27702
+ var import_react148 = require("react");
27616
27703
  function buildKey24({
27617
27704
  access_token: accessToken,
27618
27705
  apiUrl,
@@ -27652,7 +27739,7 @@ function useUpdateTaskUploadDescription() {
27652
27739
  }
27653
27740
  );
27654
27741
  const { trigger: originalTrigger } = mutationResponse;
27655
- const stableProxiedTrigger = (0, import_react147.useCallback)(
27742
+ const stableProxiedTrigger = (0, import_react148.useCallback)(
27656
27743
  (...triggerParameters) => __async(null, null, function* () {
27657
27744
  const triggerResult = yield originalTrigger(...triggerParameters);
27658
27745
  void mutate((key) => withSWRKeyTags(
@@ -27683,9 +27770,9 @@ var TasksListItem = ({
27683
27770
  defaultOpen
27684
27771
  }) => {
27685
27772
  var _a, _b;
27686
- const [isOpen, setIsOpen] = (0, import_react148.useState)(defaultOpen);
27687
- const [userResponse, setUserResponse] = (0, import_react148.useState)((_a = task.user_response) != null ? _a : "");
27688
- const [selectedFiles, setSelectedFiles] = (0, import_react148.useState)();
27773
+ const [isOpen, setIsOpen] = (0, import_react149.useState)(defaultOpen);
27774
+ const [userResponse, setUserResponse] = (0, import_react149.useState)((_a = task.user_response) != null ? _a : "");
27775
+ const [selectedFiles, setSelectedFiles] = (0, import_react149.useState)();
27689
27776
  const { trigger: handleSubmitUserResponseForTask } = useSubmitUserResponseForTask();
27690
27777
  const { trigger: handleUploadDocumentsForTask } = useUploadDocumentsForTask();
27691
27778
  const { trigger: handleDeleteUploadsOnTask } = useDeleteUploadsOnTask();
@@ -27703,7 +27790,7 @@ var TasksListItem = ({
27703
27790
  "Layer__tasks-list-item",
27704
27791
  isOpen && "Layer__tasks-list-item__expanded"
27705
27792
  );
27706
- (0, import_react148.useEffect)(() => {
27793
+ (0, import_react149.useEffect)(() => {
27707
27794
  setIsOpen(defaultOpen);
27708
27795
  }, [defaultOpen]);
27709
27796
  const submit = () => __async(null, null, function* () {
@@ -27718,7 +27805,7 @@ var TasksListItem = ({
27718
27805
  setIsOpen(false);
27719
27806
  setSelectedFiles(void 0);
27720
27807
  });
27721
- const uploadDocumentAction = (0, import_react148.useMemo)(() => {
27808
+ const uploadDocumentAction = (0, import_react149.useMemo)(() => {
27722
27809
  if (task.user_response_type === "UPLOAD_DOCUMENT") {
27723
27810
  if (task.status === "TODO") {
27724
27811
  if (!selectedFiles) {
@@ -27863,7 +27950,7 @@ var MobilePanel = ({ header, children, open: open2, onClose, className }) => {
27863
27950
  };
27864
27951
 
27865
27952
  // src/components/Tasks/TasksListMobile.tsx
27866
- var import_react149 = require("react");
27953
+ var import_react150 = require("react");
27867
27954
  var import_jsx_runtime243 = require("react/jsx-runtime");
27868
27955
  var MOBILE_SHOW_UNRESOLVED_TASKS_COUNT = 2;
27869
27956
  var TasksListMobile = ({
@@ -27874,7 +27961,7 @@ var TasksListMobile = ({
27874
27961
  pageSize,
27875
27962
  setCurrentPage
27876
27963
  }) => {
27877
- const [showMobilePanel, setShowMobilePanel] = (0, import_react149.useState)(false);
27964
+ const [showMobilePanel, setShowMobilePanel] = (0, import_react150.useState)(false);
27878
27965
  const unresolvedTasks = getIncompleteTasks(sortedTasks).slice(0, MOBILE_SHOW_UNRESOLVED_TASKS_COUNT);
27879
27966
  return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)("div", { className: "Layer__tasks-list", children: [
27880
27967
  unresolvedTasks.map((task, index) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
@@ -27922,27 +28009,27 @@ var TasksListMobile = ({
27922
28009
  };
27923
28010
 
27924
28011
  // src/hooks/array/usePaginatedList.ts
27925
- var import_react150 = require("react");
28012
+ var import_react151 = require("react");
27926
28013
  function usePaginatedList(list, pageSize) {
27927
- const [internalPageIndex, setInternalPageIndex] = (0, import_react150.useState)(0);
28014
+ const [internalPageIndex, setInternalPageIndex] = (0, import_react151.useState)(0);
27928
28015
  const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
27929
28016
  const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
27930
- const pageItems = (0, import_react150.useMemo)(() => {
28017
+ const pageItems = (0, import_react151.useMemo)(() => {
27931
28018
  return list.slice(
27932
28019
  effectivePageIndex * pageSize,
27933
28020
  (effectivePageIndex + 1) * pageSize
27934
28021
  );
27935
28022
  }, [list, effectivePageIndex, pageSize]);
27936
- const next = (0, import_react150.useCallback)(() => {
28023
+ const next = (0, import_react151.useCallback)(() => {
27937
28024
  setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
27938
28025
  }, [effectivePageIndex, pageCount]);
27939
- const set2 = (0, import_react150.useCallback)((pageIndex) => {
28026
+ const set2 = (0, import_react151.useCallback)((pageIndex) => {
27940
28027
  setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
27941
28028
  }, [pageCount]);
27942
- const previous = (0, import_react150.useCallback)(() => {
28029
+ const previous = (0, import_react151.useCallback)(() => {
27943
28030
  setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
27944
28031
  }, [effectivePageIndex]);
27945
- const reset = (0, import_react150.useCallback)(() => {
28032
+ const reset = (0, import_react151.useCallback)(() => {
27946
28033
  setInternalPageIndex(0);
27947
28034
  }, []);
27948
28035
  return {
@@ -27970,7 +28057,7 @@ var TasksEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime244.jsxs)("div
27970
28057
  ] });
27971
28058
  function TasksList({ pageSize = 8, mobile }) {
27972
28059
  const { activePeriod } = useActiveBookkeepingPeriod();
27973
- const sortedTasks = (0, import_react151.useMemo)(() => {
28060
+ const sortedTasks = (0, import_react152.useMemo)(() => {
27974
28061
  var _a;
27975
28062
  const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
27976
28063
  return tasksInPeriod.sort((taskA, taskB) => {
@@ -28021,7 +28108,7 @@ function TasksList({ pageSize = 8, mobile }) {
28021
28108
 
28022
28109
  // src/components/Tasks/TasksPending.tsx
28023
28110
  var import_recharts4 = require("recharts");
28024
- var import_date_fns40 = require("date-fns");
28111
+ var import_date_fns41 = require("date-fns");
28025
28112
  var import_classnames72 = __toESM(require("classnames"));
28026
28113
 
28027
28114
  // src/components/BookkeepingStatus/BookkeepingStatusDescription.tsx
@@ -28058,7 +28145,7 @@ var TasksPending = () => {
28058
28145
  );
28059
28146
  return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending", children: [
28060
28147
  /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-header", children: [
28061
- /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0, import_date_fns40.format)(date, "MMMM yyyy") }),
28148
+ /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0, import_date_fns41.format)(date, "MMMM yyyy") }),
28062
28149
  (activePeriod == null ? void 0 : activePeriod.tasks) && activePeriod.tasks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-bar", children: [
28063
28150
  /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(Text, { size: "sm" /* sm */, children: [
28064
28151
  /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("span", { className: taskStatusClassName, children: completedTaskCount }),
@@ -28098,7 +28185,7 @@ var TasksPending = () => {
28098
28185
  ] }) : null
28099
28186
  ] }),
28100
28187
  /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: "Layer__tasks-pending-main", children: activePeriod && /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(import_jsx_runtime246.Fragment, { children: [
28101
- /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(BookkeepingStatus, { status: activePeriod.status, monthNumber: activePeriod.month }),
28188
+ /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(BookkeepingStatus2, { status: activePeriod.status, monthNumber: activePeriod.month }),
28102
28189
  /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
28103
28190
  BookkeepingStatusDescription,
28104
28191
  {
@@ -28112,17 +28199,17 @@ var TasksPending = () => {
28112
28199
  };
28113
28200
 
28114
28201
  // src/components/Tasks/TasksMonthSelector.tsx
28115
- var import_react152 = require("react");
28116
- var import_date_fns41 = require("date-fns");
28202
+ var import_react153 = require("react");
28203
+ var import_date_fns42 = require("date-fns");
28117
28204
 
28118
28205
  // src/components/Tasks/TaskStatusBadge.tsx
28119
28206
  var import_pluralize2 = __toESM(require("pluralize"));
28120
28207
  var import_jsx_runtime247 = require("react/jsx-runtime");
28121
28208
  var buildBadgeConfig = (status, tasksCount) => {
28122
28209
  switch (status) {
28123
- case "IN_PROGRESS_AWAITING_BOOKKEEPER":
28124
- case "NOT_STARTED":
28125
- case "CLOSING_IN_REVIEW": {
28210
+ case "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */:
28211
+ case "NOT_STARTED" /* NOT_STARTED */:
28212
+ case "CLOSING_IN_REVIEW" /* CLOSING_IN_REVIEW */: {
28126
28213
  return {
28127
28214
  color: "info",
28128
28215
  icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(Clock_default, { size: 12 }),
@@ -28130,8 +28217,8 @@ var buildBadgeConfig = (status, tasksCount) => {
28130
28217
  labelShort: tasksCount ? `${tasksCount}` : void 0
28131
28218
  };
28132
28219
  }
28133
- case "IN_PROGRESS_AWAITING_CUSTOMER":
28134
- case "CLOSED_OPEN_TASKS": {
28220
+ case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
28221
+ case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
28135
28222
  return {
28136
28223
  color: "warning",
28137
28224
  label: tasksCount ? (0, import_pluralize2.default)("task", tasksCount, true) : void 0,
@@ -28139,13 +28226,13 @@ var buildBadgeConfig = (status, tasksCount) => {
28139
28226
  icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(AlertCircle_default, { size: 12 })
28140
28227
  };
28141
28228
  }
28142
- case "CLOSED_COMPLETE": {
28229
+ case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
28143
28230
  return {
28144
28231
  color: "success",
28145
28232
  icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(CheckCircle_default, { size: 12 })
28146
28233
  };
28147
28234
  }
28148
- case "BOOKKEEPING_NOT_ACTIVE": {
28235
+ case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
28149
28236
  return;
28150
28237
  }
28151
28238
  default: {
@@ -28213,8 +28300,8 @@ var import_jsx_runtime249 = require("react/jsx-runtime");
28213
28300
  function useActiveYearBookkeepingPeriods() {
28214
28301
  const { date } = useGlobalDate();
28215
28302
  const { data } = useBookkeepingPeriods();
28216
- const activeYear = (0, import_date_fns41.getYear)(date);
28217
- const periodsInActiveYear = (0, import_react152.useMemo)(() => {
28303
+ const activeYear = (0, import_date_fns42.getYear)(date);
28304
+ const periodsInActiveYear = (0, import_react153.useMemo)(() => {
28218
28305
  return data == null ? void 0 : data.filter((period) => period.year === activeYear);
28219
28306
  }, [data, activeYear]);
28220
28307
  return { periodsInActiveYear };
@@ -28223,12 +28310,12 @@ function TasksMonthSelector() {
28223
28310
  const { date } = useGlobalDate();
28224
28311
  const { setMonthByPeriod } = useGlobalDatePeriodAlignedActions();
28225
28312
  const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
28226
- const activeMonthNumber = (0, import_date_fns41.getMonth)(date) + 1;
28227
- const activeYear = (0, import_date_fns41.getYear)(date);
28228
- const monthsData = (0, import_react152.useMemo)(() => {
28313
+ const activeMonthNumber = (0, import_date_fns42.getMonth)(date) + 1;
28314
+ const activeYear = (0, import_date_fns42.getYear)(date);
28315
+ const monthsData = (0, import_react153.useMemo)(() => {
28229
28316
  return Array.from({ length: 12 }, (_, index) => {
28230
28317
  var _a, _b;
28231
- const date2 = (0, import_date_fns41.set)(
28318
+ const date2 = (0, import_date_fns42.set)(
28232
28319
  /* @__PURE__ */ new Date(),
28233
28320
  { year: activeYear, month: index, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }
28234
28321
  );
@@ -28239,12 +28326,12 @@ function TasksMonthSelector() {
28239
28326
  year: activeYear,
28240
28327
  month: index + 1,
28241
28328
  tasks: [],
28242
- status: "BOOKKEEPING_NOT_ACTIVE",
28329
+ status: "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */,
28243
28330
  disabled: true
28244
28331
  };
28245
28332
  const total = (_b = (_a = taskData.tasks) == null ? void 0 : _a.length) != null ? _b : 0;
28246
28333
  return __spreadValues({
28247
- monthStr: (0, import_date_fns41.format)(date2, "MMM"),
28334
+ monthStr: (0, import_date_fns42.format)(date2, "MMM"),
28248
28335
  date: date2,
28249
28336
  completed: getCompletedTasks(taskData.tasks).length,
28250
28337
  total
@@ -28275,14 +28362,14 @@ var import_classnames74 = __toESM(require("classnames"));
28275
28362
  var import_pluralize3 = __toESM(require("pluralize"));
28276
28363
 
28277
28364
  // src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
28278
- var import_react153 = require("react");
28279
- var import_date_fns42 = require("date-fns");
28365
+ var import_react154 = require("react");
28366
+ var import_date_fns43 = require("date-fns");
28280
28367
  var useBookkeepingYearsStatus = () => {
28281
28368
  const { business } = useLayerContext();
28282
28369
  const activationDate = getActivationDate(business);
28283
28370
  const { data, isLoading } = useBookkeepingPeriods();
28284
- const yearStatuses = (0, import_react153.useMemo)(() => {
28285
- const startYear = (0, import_date_fns42.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
28371
+ const yearStatuses = (0, import_react154.useMemo)(() => {
28372
+ const startYear = (0, import_date_fns43.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
28286
28373
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
28287
28374
  const count = currentYear - startYear + 1;
28288
28375
  return Array.from({ length: count }, (_, index) => ({ year: startYear + index })).map(({ year }) => {
@@ -28296,7 +28383,7 @@ var useBookkeepingYearsStatus = () => {
28296
28383
  };
28297
28384
  }).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
28298
28385
  }, [activationDate, data]);
28299
- const earliestIncompletePeriod = (0, import_react153.useMemo)(
28386
+ const earliestIncompletePeriod = (0, import_react154.useMemo)(
28300
28387
  () => [...data != null ? data : []].sort((a, b) => {
28301
28388
  if (a.year === b.year) {
28302
28389
  return b.month - a.month;
@@ -28439,10 +28526,10 @@ var TasksPanelNotification = ({
28439
28526
  };
28440
28527
 
28441
28528
  // src/components/Tasks/TasksYearsTabs.tsx
28442
- var import_react156 = require("react");
28529
+ var import_react157 = require("react");
28443
28530
 
28444
28531
  // src/components/Tabs/Tabs.tsx
28445
- var import_react154 = require("react");
28532
+ var import_react155 = require("react");
28446
28533
 
28447
28534
  // src/components/Tabs/Tab.tsx
28448
28535
  var import_jsx_runtime252 = require("react/jsx-runtime");
@@ -28506,12 +28593,12 @@ var Tab = ({
28506
28593
  // src/components/Tabs/Tabs.tsx
28507
28594
  var import_classnames73 = __toESM(require("classnames"));
28508
28595
  var import_jsx_runtime253 = require("react/jsx-runtime");
28509
- var import_react155 = require("react");
28596
+ var import_react156 = require("react");
28510
28597
  var STARTING_PADDING = 12;
28511
28598
  var Tabs = ({ name, options, selected, onChange }) => {
28512
- const [initialized, setInitialized] = (0, import_react154.useState)(false);
28513
- const [thumbPos, setThumbPos] = (0, import_react154.useState)({ left: 0, width: 0 });
28514
- const [currentWidth, setCurrentWidth] = (0, import_react154.useState)(0);
28599
+ const [initialized, setInitialized] = (0, import_react155.useState)(false);
28600
+ const [thumbPos, setThumbPos] = (0, import_react155.useState)({ left: 0, width: 0 });
28601
+ const [currentWidth, setCurrentWidth] = (0, import_react155.useState)(0);
28515
28602
  const selectedValue = selected || options[0].value;
28516
28603
  const baseClassName = (0, import_classnames73.default)(
28517
28604
  "Layer__tabs",
@@ -28546,14 +28633,14 @@ var Tabs = ({ name, options, selected, onChange }) => {
28546
28633
  shift2 = shift2 + STARTING_PADDING;
28547
28634
  setThumbPos({ left: shift2, width });
28548
28635
  };
28549
- (0, import_react154.useEffect)(() => {
28636
+ (0, import_react155.useEffect)(() => {
28550
28637
  const selectedIndex = getSelectedIndex();
28551
28638
  updateSelectPosition(selectedIndex);
28552
28639
  setTimeout(() => {
28553
28640
  setInitialized(true);
28554
28641
  }, 400);
28555
28642
  }, []);
28556
- (0, import_react154.useEffect)(() => {
28643
+ (0, import_react155.useEffect)(() => {
28557
28644
  const selectedIndex = getSelectedIndex();
28558
28645
  updateSelectPosition(selectedIndex);
28559
28646
  }, [selectedValue, currentWidth]);
@@ -28569,7 +28656,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
28569
28656
  return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)("div", { className: baseClassName, ref: elementRef, children: [
28570
28657
  options.map((option, index) => {
28571
28658
  var _a;
28572
- return /* @__PURE__ */ (0, import_react155.createElement)(
28659
+ return /* @__PURE__ */ (0, import_react156.createElement)(
28573
28660
  Tab,
28574
28661
  __spreadProps(__spreadValues({}, option), {
28575
28662
  key: option.value,
@@ -28587,7 +28674,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
28587
28674
  };
28588
28675
 
28589
28676
  // src/components/Tasks/TasksYearsTabs.tsx
28590
- var import_date_fns43 = require("date-fns");
28677
+ var import_date_fns44 = require("date-fns");
28591
28678
  var import_jsx_runtime254 = require("react/jsx-runtime");
28592
28679
  var TasksYearsTabs = () => {
28593
28680
  const { date } = useGlobalDate();
@@ -28595,13 +28682,13 @@ var TasksYearsTabs = () => {
28595
28682
  const activeYear = date.getFullYear();
28596
28683
  const { yearStatuses } = useBookkeepingYearsStatus();
28597
28684
  const setCurrentYear = (year) => {
28598
- const currentMonth = (0, import_date_fns43.getMonth)(date);
28685
+ const currentMonth = (0, import_date_fns44.getMonth)(date);
28599
28686
  setMonthByPeriod({
28600
28687
  monthNumber: currentMonth + 1,
28601
28688
  yearNumber: Number(year)
28602
28689
  });
28603
28690
  };
28604
- const yearsList = (0, import_react156.useMemo)(() => {
28691
+ const yearsList = (0, import_react157.useMemo)(() => {
28605
28692
  return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
28606
28693
  return {
28607
28694
  value: `${y.year}`,
@@ -28609,7 +28696,7 @@ var TasksYearsTabs = () => {
28609
28696
  badge: !y.completed && y.unresolvedTasks ? /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(
28610
28697
  TaskStatusBadge,
28611
28698
  {
28612
- status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" : "CLOSED_COMPLETE",
28699
+ status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */ : "CLOSED_COMPLETE" /* CLOSED_COMPLETE */,
28613
28700
  tasksCount: y.unresolvedTasks
28614
28701
  }
28615
28702
  ) : null
@@ -28704,40 +28791,40 @@ function Tasks({
28704
28791
  }
28705
28792
 
28706
28793
  // src/components/PlatformOnboarding/LinkAccounts.tsx
28707
- var import_react160 = require("react");
28794
+ var import_react161 = require("react");
28708
28795
 
28709
28796
  // src/components/PlatformOnboarding/Steps/LinkAccountsConfirmationStep.tsx
28710
- var import_react158 = require("react");
28797
+ var import_react159 = require("react");
28711
28798
  var import_react_form2 = require("@tanstack/react-form");
28712
28799
 
28713
28800
  // src/components/Wizard/Wizard.tsx
28714
- var import_react157 = require("react");
28801
+ var import_react158 = require("react");
28715
28802
  var import_jsx_runtime257 = require("react/jsx-runtime");
28716
28803
  function useWizardStep({
28717
28804
  steps,
28718
28805
  onComplete
28719
28806
  }) {
28720
28807
  const stepCount = steps.length;
28721
- const [activeStepIndex, setActiveStepIndex] = (0, import_react157.useState)(0);
28722
- const next = (0, import_react157.useCallback)(() => __async(null, null, function* () {
28808
+ const [activeStepIndex, setActiveStepIndex] = (0, import_react158.useState)(0);
28809
+ const next = (0, import_react158.useCallback)(() => __async(null, null, function* () {
28723
28810
  setActiveStepIndex((stepIndex) => Math.min(stepIndex + 1, stepCount - 1));
28724
28811
  if (activeStepIndex === stepCount - 1 && onComplete) {
28725
28812
  yield onComplete == null ? void 0 : onComplete();
28726
28813
  }
28727
28814
  }), [stepCount, activeStepIndex, onComplete]);
28728
- const previous = (0, import_react157.useCallback)(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
28815
+ const previous = (0, import_react158.useCallback)(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
28729
28816
  const effectiveStepIndex = Math.min(activeStepIndex, stepCount - 1);
28730
28817
  const currentStep = steps.at(effectiveStepIndex);
28731
28818
  return { currentStep, next, previous };
28732
28819
  }
28733
- var WizardContext = (0, import_react157.createContext)({
28820
+ var WizardContext = (0, import_react158.createContext)({
28734
28821
  next: () => {
28735
28822
  },
28736
28823
  previous: () => {
28737
28824
  }
28738
28825
  });
28739
28826
  function useWizard() {
28740
- return (0, import_react157.useContext)(WizardContext);
28827
+ return (0, import_react158.useContext)(WizardContext);
28741
28828
  }
28742
28829
  function Wizard({
28743
28830
  Header: Header4,
@@ -28745,12 +28832,12 @@ function Wizard({
28745
28832
  onComplete,
28746
28833
  children
28747
28834
  }) {
28748
- const childrenArray = import_react157.Children.toArray(children);
28835
+ const childrenArray = import_react158.Children.toArray(children);
28749
28836
  const { currentStep, next, previous } = useWizardStep({
28750
28837
  steps: childrenArray,
28751
28838
  onComplete
28752
28839
  });
28753
- const value = (0, import_react157.useMemo)(() => ({ next, previous }), [next, previous]);
28840
+ const value = (0, import_react158.useMemo)(() => ({ next, previous }), [next, previous]);
28754
28841
  return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(WizardContext.Provider, { value, children: [
28755
28842
  Header4,
28756
28843
  currentStep,
@@ -28791,7 +28878,7 @@ function LinkAccountsConfirmationStep() {
28791
28878
  data: linkedAccounts,
28792
28879
  loadingStatus: linkedAccountsLoadingStatus,
28793
28880
  refetchAccounts
28794
- } = (0, import_react158.useContext)(LinkedAccountsContext);
28881
+ } = (0, import_react159.useContext)(LinkedAccountsContext);
28795
28882
  const effectiveLinkedAccounts = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
28796
28883
  const { trigger } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
28797
28884
  const { previous, next } = useWizard();
@@ -28864,7 +28951,7 @@ function LinkAccountsConfirmationStep() {
28864
28951
  }
28865
28952
 
28866
28953
  // src/components/PlatformOnboarding/Steps/LinkAccountsLinkStep.tsx
28867
- var import_react159 = require("react");
28954
+ var import_react160 = require("react");
28868
28955
  var import_pluralize4 = __toESM(require("pluralize"));
28869
28956
 
28870
28957
  // src/components/Separator/Separator.tsx
@@ -28883,7 +28970,7 @@ function LinkAccountsLinkStep() {
28883
28970
  error,
28884
28971
  refetchAccounts,
28885
28972
  addConnection
28886
- } = (0, import_react159.useContext)(LinkedAccountsContext);
28973
+ } = (0, import_react160.useContext)(LinkedAccountsContext);
28887
28974
  const { next } = useWizard();
28888
28975
  const effectiveAccounts = data != null ? data : [];
28889
28976
  return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_jsx_runtime261.Fragment, { children: [
@@ -28963,7 +29050,7 @@ function LinkAccounts(props) {
28963
29050
  function LinkAccountsContent({
28964
29051
  onComplete
28965
29052
  }) {
28966
- const { data: linkedAccounts, loadingStatus } = (0, import_react160.useContext)(LinkedAccountsContext);
29053
+ const { data: linkedAccounts, loadingStatus } = (0, import_react161.useContext)(LinkedAccountsContext);
28967
29054
  const linkedAccountsNeedingConfirmation = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
28968
29055
  const hideConfirmationStep = loadingStatus === "complete" && linkedAccountsNeedingConfirmation.length === 0;
28969
29056
  return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("section", { className: "Layer__link-accounts Layer__component", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
@@ -28981,7 +29068,7 @@ function LinkAccountsContent({
28981
29068
  }
28982
29069
 
28983
29070
  // src/components/PlatformOnboarding/PlatformOnboarding.tsx
28984
- var import_react165 = require("react");
29071
+ var import_react166 = require("react");
28985
29072
 
28986
29073
  // src/components/ProgressSteps/ProgressSteps.tsx
28987
29074
  var import_jsx_runtime263 = require("react/jsx-runtime");
@@ -29378,7 +29465,7 @@ function useBusinessPersonnel() {
29378
29465
  // src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
29379
29466
  var import_mutation16 = __toESM(require("swr/mutation"));
29380
29467
  var import_swr27 = require("swr");
29381
- var import_react161 = require("react");
29468
+ var import_react162 = require("react");
29382
29469
  var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
29383
29470
  function buildKey26({
29384
29471
  access_token: accessToken,
@@ -29416,7 +29503,7 @@ function useCreateBusinessPersonnel() {
29416
29503
  }
29417
29504
  );
29418
29505
  const { trigger: originalTrigger } = mutationResponse;
29419
- const stableProxiedTrigger = (0, import_react161.useCallback)(
29506
+ const stableProxiedTrigger = (0, import_react162.useCallback)(
29420
29507
  (...triggerParameters) => __async(null, null, function* () {
29421
29508
  const triggerResult = yield originalTrigger(...triggerParameters);
29422
29509
  void mutate((key) => withSWRKeyTags(
@@ -29450,7 +29537,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
29450
29537
  });
29451
29538
 
29452
29539
  // src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
29453
- var import_react162 = require("react");
29540
+ var import_react163 = require("react");
29454
29541
  function buildKey27({
29455
29542
  access_token: accessToken,
29456
29543
  apiUrl,
@@ -29493,7 +29580,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
29493
29580
  }
29494
29581
  );
29495
29582
  const { trigger: originalTrigger } = mutationResponse;
29496
- const stableProxiedTrigger = (0, import_react162.useCallback)(
29583
+ const stableProxiedTrigger = (0, import_react163.useCallback)(
29497
29584
  (...triggerParameters) => __async(null, null, function* () {
29498
29585
  const triggerResult = yield originalTrigger(...triggerParameters);
29499
29586
  void mutate((key) => withSWRKeyTags(
@@ -29520,7 +29607,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
29520
29607
  // src/hooks/business/useUpdateBusiness.ts
29521
29608
  var import_mutation18 = __toESM(require("swr/mutation"));
29522
29609
  var import_swr29 = require("swr");
29523
- var import_react163 = require("react");
29610
+ var import_react164 = require("react");
29524
29611
  var BUSINESS_TAG_KEY = "business";
29525
29612
  function buildKey28({
29526
29613
  access_token: accessToken,
@@ -29558,7 +29645,7 @@ function useUpdateBusiness() {
29558
29645
  }
29559
29646
  );
29560
29647
  const { trigger: originalTrigger } = mutationResponse;
29561
- const stableProxiedTrigger = (0, import_react163.useCallback)(
29648
+ const stableProxiedTrigger = (0, import_react164.useCallback)(
29562
29649
  (...triggerParameters) => __async(null, null, function* () {
29563
29650
  const triggerResult = yield originalTrigger(...triggerParameters);
29564
29651
  void mutate((key) => withSWRKeyTags(
@@ -29583,7 +29670,7 @@ function useUpdateBusiness() {
29583
29670
  }
29584
29671
 
29585
29672
  // src/components/BusinessForm/useBusinessForm.ts
29586
- var import_react164 = require("react");
29673
+ var import_react165 = require("react");
29587
29674
  var getPerson = (personnel) => {
29588
29675
  const owners = personnel == null ? void 0 : personnel.filter((p) => p.roles.find((x) => x.role === "OWNER"));
29589
29676
  if (owners && owners.length > 0) {
@@ -29594,7 +29681,7 @@ var getPerson = (personnel) => {
29594
29681
  var useBusinessForm = ({ onSuccess }) => {
29595
29682
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
29596
29683
  const { business } = useLayerContext();
29597
- const [submitError, setSubmitError] = (0, import_react164.useState)(void 0);
29684
+ const [submitError, setSubmitError] = (0, import_react165.useState)(void 0);
29598
29685
  const { data: personnel } = useBusinessPersonnel();
29599
29686
  const person = getPerson(personnel);
29600
29687
  const { trigger: createBusinessPersonnel2 } = useCreateBusinessPersonnel();
@@ -30010,7 +30097,7 @@ var PLATFORM_ONBOARDING_STEPS = [
30010
30097
  }
30011
30098
  ];
30012
30099
  var PlatformOnboarding = ({ onComplete }) => {
30013
- const [step, setStep] = (0, import_react165.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
30100
+ const [step, setStep] = (0, import_react166.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
30014
30101
  const isFirstStep = PLATFORM_ONBOARDING_STEPS[0].id === step;
30015
30102
  const nextStep = () => {
30016
30103
  const currentStepIndex = PLATFORM_ONBOARDING_STEPS.findIndex((s) => s.id === step);
@@ -30172,7 +30259,7 @@ var BookkeepingUpsellBar = ({
30172
30259
  };
30173
30260
 
30174
30261
  // src/views/BookkeepingOverview/BookkeepingOverview.tsx
30175
- var import_react167 = require("react");
30262
+ var import_react168 = require("react");
30176
30263
 
30177
30264
  // src/views/BookkeepingOverview/internal/BookkeepingProfitAndLossSummariesContainer.tsx
30178
30265
  var import_jsx_runtime277 = require("react/jsx-runtime");
@@ -30187,15 +30274,15 @@ function BookkeepingProfitAndLossSummariesContainer({
30187
30274
  var import_classnames75 = __toESM(require("classnames"));
30188
30275
 
30189
30276
  // src/views/BookkeepingOverview/useKeepInMobileViewport.tsx
30190
- var import_react166 = require("react");
30277
+ var import_react167 = require("react");
30191
30278
  var TASKS_MOBILE_VIEWPORT_WIDTH = 1100;
30192
30279
  var useKeepInMobileViewport = () => {
30193
- const upperContentRef = (0, import_react166.useRef)(null);
30194
- const targetElementRef = (0, import_react166.useRef)(null);
30195
- const lastKnownSizeRef = (0, import_react166.useRef)(null);
30196
- const lastKnownTargetPositionRef = (0, import_react166.useRef)(null);
30197
- const upperElementInFocus = (0, import_react166.useRef)(false);
30198
- (0, import_react166.useEffect)(() => {
30280
+ const upperContentRef = (0, import_react167.useRef)(null);
30281
+ const targetElementRef = (0, import_react167.useRef)(null);
30282
+ const lastKnownSizeRef = (0, import_react167.useRef)(null);
30283
+ const lastKnownTargetPositionRef = (0, import_react167.useRef)(null);
30284
+ const upperElementInFocus = (0, import_react167.useRef)(false);
30285
+ (0, import_react167.useEffect)(() => {
30199
30286
  if (!upperContentRef.current || !targetElementRef.current) return;
30200
30287
  lastKnownSizeRef.current = upperContentRef.current.getBoundingClientRect().height;
30201
30288
  lastKnownTargetPositionRef.current = targetElementRef.current.getBoundingClientRect().top;
@@ -30252,7 +30339,7 @@ var BookkeepingOverview = ({
30252
30339
  slotProps
30253
30340
  }) => {
30254
30341
  var _a, _b, _c, _d, _e, _f;
30255
- const [pnlToggle, setPnlToggle] = (0, import_react167.useState)("expenses");
30342
+ const [pnlToggle, setPnlToggle] = (0, import_react168.useState)("expenses");
30256
30343
  const [width] = useWindowSize();
30257
30344
  const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
30258
30345
  const { upperContentRef, targetElementRef, upperElementInFocus } = useKeepInMobileViewport();
@@ -30383,7 +30470,7 @@ var BookkeepingOverview = ({
30383
30470
  };
30384
30471
 
30385
30472
  // src/views/AccountingOverview/AccountingOverview.tsx
30386
- var import_react168 = require("react");
30473
+ var import_react169 = require("react");
30387
30474
  var import_classnames76 = __toESM(require("classnames"));
30388
30475
  var import_jsx_runtime279 = require("react/jsx-runtime");
30389
30476
  var AccountingOverview = ({
@@ -30399,7 +30486,7 @@ var AccountingOverview = ({
30399
30486
  slotProps
30400
30487
  }) => {
30401
30488
  var _a, _b, _c, _d, _e;
30402
- const [pnlToggle, setPnlToggle] = (0, import_react168.useState)("expenses");
30489
+ const [pnlToggle, setPnlToggle] = (0, import_react169.useState)("expenses");
30403
30490
  const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
30404
30491
  return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
30405
30492
  ProfitAndLoss,
@@ -30566,7 +30653,7 @@ var BankTransactionsWithLinkedAccounts = ({
30566
30653
  };
30567
30654
 
30568
30655
  // src/views/GeneralLedger/GeneralLedger.tsx
30569
- var import_react169 = require("react");
30656
+ var import_react170 = require("react");
30570
30657
  var import_jsx_runtime281 = require("react/jsx-runtime");
30571
30658
  var GeneralLedgerView = ({
30572
30659
  title,
@@ -30575,7 +30662,7 @@ var GeneralLedgerView = ({
30575
30662
  stringOverrides,
30576
30663
  chartOfAccountsOptions
30577
30664
  }) => {
30578
- const [activeTab, setActiveTab] = (0, import_react169.useState)("chartOfAccounts");
30665
+ const [activeTab, setActiveTab] = (0, import_react170.useState)("chartOfAccounts");
30579
30666
  return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(ProfitAndLoss, { asContainer: false, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
30580
30667
  View,
30581
30668
  {
@@ -30617,7 +30704,7 @@ var GeneralLedgerView = ({
30617
30704
  };
30618
30705
 
30619
30706
  // src/views/ProjectProfitability/ProjectProfitability.tsx
30620
- var import_react170 = require("react");
30707
+ var import_react171 = require("react");
30621
30708
  var import_react_select5 = __toESM(require("react-select"));
30622
30709
  var import_jsx_runtime282 = require("react/jsx-runtime");
30623
30710
  var ProjectProfitabilityView = ({
@@ -30627,9 +30714,9 @@ var ProjectProfitabilityView = ({
30627
30714
  datePickerMode = "monthPicker",
30628
30715
  csvMoneyFormat = "DOLLAR_STRING"
30629
30716
  }) => {
30630
- const [activeTab, setActiveTab] = (0, import_react170.useState)("overview");
30631
- const [tagFilter, setTagFilter] = (0, import_react170.useState)(null);
30632
- const [pnlTagFilter, setPnlTagFilter] = (0, import_react170.useState)(
30717
+ const [activeTab, setActiveTab] = (0, import_react171.useState)("overview");
30718
+ const [tagFilter, setTagFilter] = (0, import_react171.useState)(null);
30719
+ const [pnlTagFilter, setPnlTagFilter] = (0, import_react171.useState)(
30633
30720
  void 0
30634
30721
  );
30635
30722
  const isOptionSelected = (option, selectValue) => {
@@ -30728,7 +30815,7 @@ var ProjectProfitabilityView = ({
30728
30815
  };
30729
30816
 
30730
30817
  // src/views/Reports/Reports.tsx
30731
- var import_react171 = require("react");
30818
+ var import_react172 = require("react");
30732
30819
  var import_jsx_runtime283 = require("react/jsx-runtime");
30733
30820
  var getOptions = (enabledReports) => {
30734
30821
  return [
@@ -30756,7 +30843,7 @@ var Reports = ({
30756
30843
  statementOfCashFlowConfig
30757
30844
  }) => {
30758
30845
  var _a;
30759
- const [activeTab, setActiveTab] = (0, import_react171.useState)(enabledReports[0]);
30846
+ const [activeTab, setActiveTab] = (0, import_react172.useState)(enabledReports[0]);
30760
30847
  const { view, containerRef } = useElementViewSize();
30761
30848
  const options = getOptions(enabledReports);
30762
30849
  const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value = enabledReports[0])) == null ? void 0 : _a.label;
@@ -30818,11 +30905,11 @@ var ReportsPanel = ({
30818
30905
  };
30819
30906
 
30820
30907
  // src/components/ProfitAndLossView/ProfitAndLossView.tsx
30821
- var import_react172 = require("react");
30908
+ var import_react173 = require("react");
30822
30909
  var import_jsx_runtime284 = require("react/jsx-runtime");
30823
30910
  var COMPONENT_NAME8 = "profit-and-loss";
30824
30911
  var ProfitAndLossView = (props) => {
30825
- const containerRef = (0, import_react172.useRef)(null);
30912
+ const containerRef = (0, import_react173.useRef)(null);
30826
30913
  return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Container, { name: COMPONENT_NAME8, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ProfitAndLoss, { children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
30827
30914
  };
30828
30915
  var ProfitAndLossPanel = (_a) => {
@@ -30833,7 +30920,7 @@ var ProfitAndLossPanel = (_a) => {
30833
30920
  "containerRef",
30834
30921
  "stringOverrides"
30835
30922
  ]);
30836
- const { sidebarScope } = (0, import_react172.useContext)(ProfitAndLoss.Context);
30923
+ const { sidebarScope } = (0, import_react173.useContext)(ProfitAndLoss.Context);
30837
30924
  return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
30838
30925
  Panel,
30839
30926
  {
@@ -30864,7 +30951,7 @@ var Components = ({
30864
30951
  hideTable = false,
30865
30952
  stringOverrides
30866
30953
  }) => {
30867
- const { error, isLoading, isValidating, refetch } = (0, import_react172.useContext)(
30954
+ const { error, isLoading, isValidating, refetch } = (0, import_react173.useContext)(
30868
30955
  ProfitAndLoss.Context
30869
30956
  );
30870
30957
  if (!isLoading && error) {
@@ -30926,6 +31013,7 @@ var Components = ({
30926
31013
  Direction,
30927
31014
  DisplayState,
30928
31015
  GeneralLedgerView,
31016
+ Integrations,
30929
31017
  Journal,
30930
31018
  LayerProvider,
30931
31019
  LinkAccounts,
@@ -30935,11 +31023,9 @@ var Components = ({
30935
31023
  ProfitAndLoss,
30936
31024
  ProfitAndLossView,
30937
31025
  ProjectProfitabilityView,
30938
- Quickbooks,
30939
31026
  Reports,
30940
31027
  StatementOfCashFlow,
30941
31028
  Tasks,
30942
- unstable_Integrations,
30943
31029
  useBankTransactionsContext,
30944
31030
  useDataSync,
30945
31031
  useLayerContext