@layerfi/components 0.1.4 → 0.1.5

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.
package/dist/index.js CHANGED
@@ -35,7 +35,8 @@ __export(src_exports, {
35
35
  ChartOfAccounts: () => ChartOfAccounts,
36
36
  Hello: () => Hello,
37
37
  LayerProvider: () => LayerProvider,
38
- ProfitAndLoss: () => ProfitAndLoss
38
+ ProfitAndLoss: () => ProfitAndLoss,
39
+ ProfitAndLossView: () => ProfitAndLossView
39
40
  });
40
41
  module.exports = __toCommonJS(src_exports);
41
42
 
@@ -295,6 +296,9 @@ var getBankTransactions = get(
295
296
  var categorizeBankTransaction = put(
296
297
  ({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
297
298
  );
299
+ var matchBankTransaction = put(
300
+ ({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/match`
301
+ );
298
302
 
299
303
  // src/api/layer/categories.ts
300
304
  var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
@@ -309,13 +313,14 @@ var createAccount = post(
309
313
 
310
314
  // src/api/layer/profit_and_loss.ts
311
315
  var getProfitAndLoss = get(
312
- ({ businessId, startDate, endDate }) => `/v1/businesses/${businessId}/reports/profit-and-loss?start_date=${startDate ? encodeURIComponent(startDate) : ""}&end_date=${endDate ? encodeURIComponent(endDate) : ""}`
316
+ ({ businessId, startDate, endDate, tagKey, tagValues, reportingBasis }) => `/v1/businesses/${businessId}/reports/profit-and-loss?start_date=${startDate ? encodeURIComponent(startDate) : ""}&end_date=${endDate ? encodeURIComponent(endDate) : ""}${reportingBasis ? `&reporting_basis=${reportingBasis}` : ""}${tagKey ? `&tag_key=${tagKey}` : ""}${tagValues ? `&tag_values=${tagValues}` : ""}`
313
317
  );
314
318
 
315
319
  // src/api/layer.ts
316
320
  var Layer = {
317
321
  authenticate,
318
322
  categorizeBankTransaction,
323
+ matchBankTransaction,
319
324
  createAccount,
320
325
  getBalanceSheet,
321
326
  getBankTransactions,
@@ -340,7 +345,9 @@ var LayerContext = (0, import_react.createContext)({
340
345
  categories: [],
341
346
  apiUrl: "",
342
347
  theme: void 0,
343
- setTheme: () => void 0
348
+ colors: {},
349
+ setTheme: () => void 0,
350
+ getColor: (_shade) => void 0
344
351
  });
345
352
 
346
353
  // src/hooks/useLayerContext/useLayerContext.tsx
@@ -598,7 +605,10 @@ var BalanceSheet = () => {
598
605
  };
599
606
 
600
607
  // src/components/BankTransactions/BankTransactions.tsx
601
- var import_react30 = __toESM(require("react"));
608
+ var import_react39 = __toESM(require("react"));
609
+
610
+ // src/config/general.ts
611
+ var DATE_FORMAT = "LLL d, yyyy";
602
612
 
603
613
  // src/hooks/useBankTransactions/useBankTransactions.tsx
604
614
  var import_swr2 = __toESM(require("swr"));
@@ -651,6 +661,40 @@ var useBankTransactions = () => {
651
661
  }
652
662
  });
653
663
  };
664
+ const match = (id, matchId) => {
665
+ const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
666
+ if (foundBT) {
667
+ updateOneLocal({ ...foundBT, processing: true, error: void 0 });
668
+ }
669
+ return Layer.matchBankTransaction(apiUrl, auth.access_token, {
670
+ params: { businessId, bankTransactionId: id },
671
+ body: { match_id: matchId, type: "Confirm_Match" /* CONFIRM_MATCH */ }
672
+ }).then(({ data: bt, errors }) => {
673
+ const newBT = data?.find(
674
+ (x) => x.business_id === businessId && x.id === id
675
+ );
676
+ if (newBT) {
677
+ newBT.recently_categorized = true;
678
+ newBT.match = bt;
679
+ updateOneLocal(newBT);
680
+ }
681
+ if (errors) {
682
+ console.error(errors);
683
+ throw errors;
684
+ }
685
+ }).catch((err) => {
686
+ const newBT = data?.find(
687
+ (x) => x.business_id === businessId && x.id === id
688
+ );
689
+ if (newBT) {
690
+ updateOneLocal({
691
+ ...newBT,
692
+ error: err.message,
693
+ processing: false
694
+ });
695
+ }
696
+ });
697
+ };
654
698
  const updateOneLocal = (newBankTransaction) => {
655
699
  const updatedData = data?.map(
656
700
  (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
@@ -668,6 +712,7 @@ var useBankTransactions = () => {
668
712
  refetch,
669
713
  error: responseError || error,
670
714
  categorize,
715
+ match,
671
716
  updateOneLocal
672
717
  };
673
718
  };
@@ -701,7 +746,176 @@ function hasSuggestions(categorization) {
701
746
  }
702
747
 
703
748
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
704
- var import_react24 = __toESM(require("react"));
749
+ var import_react32 = __toESM(require("react"));
750
+
751
+ // src/components/BankTransactionRow/BankTransactionRow.tsx
752
+ var import_react30 = __toESM(require("react"));
753
+
754
+ // src/icons/Scissors.tsx
755
+ var React8 = __toESM(require("react"));
756
+ var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React8.createElement(
757
+ "svg",
758
+ {
759
+ viewBox: "0 0 11 11",
760
+ fill: "none",
761
+ xmlns: "http://www.w3.org/2000/svg",
762
+ ...props,
763
+ width: size,
764
+ height: size
765
+ },
766
+ /* @__PURE__ */ React8.createElement(
767
+ "path",
768
+ {
769
+ d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
770
+ stroke: "currentColor",
771
+ strokeLinecap: "round",
772
+ strokeLinejoin: "round"
773
+ },
774
+ /* @__PURE__ */ React8.createElement(
775
+ "animate",
776
+ {
777
+ attributeName: "d",
778
+ className: "animateOnHover",
779
+ values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
780
+ begin: "indefinite",
781
+ dur: "400ms",
782
+ repeatCount: "1",
783
+ fill: "freeze",
784
+ calcMode: "linear",
785
+ keyTimes: "0;0.5;1"
786
+ }
787
+ )
788
+ ),
789
+ /* @__PURE__ */ React8.createElement(
790
+ "path",
791
+ {
792
+ d: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
793
+ stroke: "currentColor",
794
+ strokeLinecap: "round",
795
+ strokeLinejoin: "round"
796
+ },
797
+ /* @__PURE__ */ React8.createElement(
798
+ "animate",
799
+ {
800
+ attributeName: "d",
801
+ className: "animateOnHover",
802
+ values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
803
+ begin: "indefinite",
804
+ dur: "400ms",
805
+ repeatCount: "1",
806
+ fill: "freeze",
807
+ calcMode: "linear",
808
+ keyTimes: "0;0.5;1"
809
+ }
810
+ )
811
+ ),
812
+ /* @__PURE__ */ React8.createElement(
813
+ "path",
814
+ {
815
+ d: "M9.16668 1.83325L3.72168 7.27825",
816
+ stroke: "currentColor",
817
+ strokeLinecap: "round",
818
+ strokeLinejoin: "round"
819
+ },
820
+ /* @__PURE__ */ React8.createElement(
821
+ "animate",
822
+ {
823
+ attributeName: "d",
824
+ className: "animateOnHover",
825
+ values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
826
+ begin: "indefinite",
827
+ dur: "400ms",
828
+ repeatCount: "1",
829
+ fill: "freeze",
830
+ calcMode: "linear",
831
+ keyTimes: "0;0.5;1"
832
+ }
833
+ )
834
+ ),
835
+ /* @__PURE__ */ React8.createElement(
836
+ "path",
837
+ {
838
+ d: "M6.63232 6.63672L9.16691 9.16672",
839
+ stroke: "currentColor",
840
+ strokeLinecap: "round",
841
+ strokeLinejoin: "round"
842
+ },
843
+ /* @__PURE__ */ React8.createElement(
844
+ "animate",
845
+ {
846
+ attributeName: "d",
847
+ className: "animateOnHover",
848
+ values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
849
+ begin: "indefinite",
850
+ dur: "400ms",
851
+ repeatCount: "1",
852
+ fill: "freeze",
853
+ calcMode: "linear",
854
+ keyTimes: "0;0.5;1"
855
+ }
856
+ )
857
+ ),
858
+ /* @__PURE__ */ React8.createElement(
859
+ "path",
860
+ {
861
+ d: "M3.72168 3.72168L5.50001 5.50001",
862
+ stroke: "currentColor",
863
+ strokeLinecap: "round",
864
+ strokeLinejoin: "round"
865
+ },
866
+ /* @__PURE__ */ React8.createElement(
867
+ "animate",
868
+ {
869
+ attributeName: "d",
870
+ className: "animateOnHover",
871
+ values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
872
+ begin: "indefinite",
873
+ dur: "400ms",
874
+ repeatCount: "1",
875
+ fill: "freeze",
876
+ calcMode: "linear",
877
+ keyTimes: "0;0.5;1"
878
+ }
879
+ )
880
+ )
881
+ );
882
+ var Scissors_default = Scissors;
883
+
884
+ // src/icons/X.tsx
885
+ var React9 = __toESM(require("react"));
886
+ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElement(
887
+ "svg",
888
+ {
889
+ xmlns: "http://www.w3.org/2000/svg",
890
+ viewBox: "0 0 18 18",
891
+ fill: "none",
892
+ ...props,
893
+ width: size,
894
+ height: size
895
+ },
896
+ /* @__PURE__ */ React9.createElement(
897
+ "path",
898
+ {
899
+ d: "M13.5 4.5L4.5 13.5",
900
+ stroke: "currentColor",
901
+ strokeLinecap: "round",
902
+ strokeLinejoin: "round"
903
+ }
904
+ ),
905
+ /* @__PURE__ */ React9.createElement(
906
+ "path",
907
+ {
908
+ d: "M4.5 4.5L13.5 13.5",
909
+ stroke: "currentColor",
910
+ strokeLinecap: "round",
911
+ strokeLinejoin: "round"
912
+ }
913
+ )
914
+ );
915
+ var X_default = X;
916
+
917
+ // src/components/Badge/Badge.tsx
918
+ var import_react16 = __toESM(require("react"));
705
919
 
706
920
  // src/components/Button/Button.tsx
707
921
  var import_react8 = __toESM(require("react"));
@@ -713,6 +927,7 @@ var Button = ({
713
927
  leftIcon,
714
928
  rightIcon,
715
929
  iconOnly,
930
+ iconAsPrimary = false,
716
931
  ...props
717
932
  }) => {
718
933
  const buttonRef = (0, import_react8.useRef)(null);
@@ -728,6 +943,7 @@ var Button = ({
728
943
  "Layer__btn",
729
944
  `Layer__btn--${variant}`,
730
945
  iconOnly ? "Layer__btn--icon-only" : "",
946
+ iconAsPrimary && "Layer__btn--with-primary-icon",
731
947
  className
732
948
  );
733
949
  const startAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
@@ -745,7 +961,25 @@ var Button = ({
745
961
  onMouseLeave: stopAnimation,
746
962
  ref: buttonRef
747
963
  },
748
- /* @__PURE__ */ import_react8.default.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--left" }, leftIcon), !iconOnly && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--right" }, rightIcon))
964
+ /* @__PURE__ */ import_react8.default.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ import_react8.default.createElement(
965
+ "span",
966
+ {
967
+ className: (0, import_classnames.default)(
968
+ "Layer__btn-icon Layer__btn-icon--left",
969
+ iconAsPrimary && "Layer__btn-icon--primary"
970
+ )
971
+ },
972
+ leftIcon
973
+ ), !iconOnly && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ import_react8.default.createElement(
974
+ "span",
975
+ {
976
+ className: (0, import_classnames.default)(
977
+ "Layer__btn-icon Layer__btn-icon--right",
978
+ iconAsPrimary && "Layer__btn-icon--primary"
979
+ )
980
+ },
981
+ rightIcon
982
+ ))
749
983
  );
750
984
  };
751
985
 
@@ -753,8 +987,8 @@ var Button = ({
753
987
  var import_react13 = __toESM(require("react"));
754
988
 
755
989
  // src/icons/AlertCircle.tsx
756
- var React9 = __toESM(require("react"));
757
- var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElement(
990
+ var React11 = __toESM(require("react"));
991
+ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createElement(
758
992
  "svg",
759
993
  {
760
994
  viewBox: "0 0 18 18",
@@ -764,7 +998,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
764
998
  width: size,
765
999
  height: size
766
1000
  },
767
- /* @__PURE__ */ React9.createElement(
1001
+ /* @__PURE__ */ React11.createElement(
768
1002
  "path",
769
1003
  {
770
1004
  d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
@@ -773,7 +1007,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
773
1007
  strokeLinejoin: "round"
774
1008
  }
775
1009
  ),
776
- /* @__PURE__ */ React9.createElement(
1010
+ /* @__PURE__ */ React11.createElement(
777
1011
  "path",
778
1012
  {
779
1013
  d: "M9 6V9",
@@ -782,7 +1016,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
782
1016
  strokeLinejoin: "round"
783
1017
  }
784
1018
  ),
785
- /* @__PURE__ */ React9.createElement(
1019
+ /* @__PURE__ */ React11.createElement(
786
1020
  "path",
787
1021
  {
788
1022
  d: "M9 12H9.0075",
@@ -795,8 +1029,8 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
795
1029
  var AlertCircle_default = AlertCircle;
796
1030
 
797
1031
  // src/icons/Check.tsx
798
- var React10 = __toESM(require("react"));
799
- var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
1032
+ var React12 = __toESM(require("react"));
1033
+ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
800
1034
  "svg",
801
1035
  {
802
1036
  viewBox: "0 0 18 18",
@@ -806,7 +1040,7 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
806
1040
  width: size,
807
1041
  height: size
808
1042
  },
809
- /* @__PURE__ */ React10.createElement(
1043
+ /* @__PURE__ */ React12.createElement(
810
1044
  "path",
811
1045
  {
812
1046
  d: "M15 4.5L6.75 12.75L3 9",
@@ -819,8 +1053,8 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
819
1053
  var Check_default = Check;
820
1054
 
821
1055
  // src/icons/CheckCircle.tsx
822
- var React11 = __toESM(require("react"));
823
- var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createElement(
1056
+ var React13 = __toESM(require("react"));
1057
+ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React13.createElement(
824
1058
  "svg",
825
1059
  {
826
1060
  viewBox: "0 0 18 18",
@@ -830,7 +1064,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
830
1064
  width: size,
831
1065
  height: size
832
1066
  },
833
- /* @__PURE__ */ React11.createElement(
1067
+ /* @__PURE__ */ React13.createElement(
834
1068
  "path",
835
1069
  {
836
1070
  d: "M16.5 8.30999V8.99999C16.4991 10.6173 15.9754 12.191 15.007 13.4864C14.0386 14.7817 12.6775 15.7293 11.1265 16.1879C9.57557 16.6465 7.91794 16.5914 6.40085 16.0309C4.88375 15.4704 3.58848 14.4346 2.70821 13.0778C1.82794 11.721 1.40984 10.116 1.51625 8.50223C1.62266 6.88841 2.2479 5.35223 3.2987 4.12279C4.34951 2.89335 5.76958 2.03653 7.34713 1.6801C8.92469 1.32367 10.5752 1.48674 12.0525 2.14499",
@@ -839,7 +1073,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
839
1073
  strokeLinejoin: "round"
840
1074
  }
841
1075
  ),
842
- /* @__PURE__ */ React11.createElement(
1076
+ /* @__PURE__ */ React13.createElement(
843
1077
  "path",
844
1078
  {
845
1079
  d: "M16.5 3L9 10.5075L6.75 8.2575",
@@ -852,8 +1086,8 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
852
1086
  var CheckCircle_default = CheckCircle;
853
1087
 
854
1088
  // src/icons/Loader.tsx
855
- var React12 = __toESM(require("react"));
856
- var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
1089
+ var React14 = __toESM(require("react"));
1090
+ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React14.createElement(
857
1091
  "svg",
858
1092
  {
859
1093
  viewBox: "0 0 18 18",
@@ -863,7 +1097,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
863
1097
  width: size,
864
1098
  height: size
865
1099
  },
866
- /* @__PURE__ */ React12.createElement(
1100
+ /* @__PURE__ */ React14.createElement(
867
1101
  "path",
868
1102
  {
869
1103
  d: "M9 1.5V4.5",
@@ -872,7 +1106,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
872
1106
  strokeLinejoin: "round"
873
1107
  }
874
1108
  ),
875
- /* @__PURE__ */ React12.createElement(
1109
+ /* @__PURE__ */ React14.createElement(
876
1110
  "path",
877
1111
  {
878
1112
  d: "M9 13.5V16.5",
@@ -881,7 +1115,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
881
1115
  strokeLinejoin: "round"
882
1116
  }
883
1117
  ),
884
- /* @__PURE__ */ React12.createElement(
1118
+ /* @__PURE__ */ React14.createElement(
885
1119
  "path",
886
1120
  {
887
1121
  d: "M3.6975 3.6975L5.82 5.82",
@@ -890,7 +1124,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
890
1124
  strokeLinejoin: "round"
891
1125
  }
892
1126
  ),
893
- /* @__PURE__ */ React12.createElement(
1127
+ /* @__PURE__ */ React14.createElement(
894
1128
  "path",
895
1129
  {
896
1130
  d: "M12.18 12.18L14.3025 14.3025",
@@ -899,7 +1133,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
899
1133
  strokeLinejoin: "round"
900
1134
  }
901
1135
  ),
902
- /* @__PURE__ */ React12.createElement(
1136
+ /* @__PURE__ */ React14.createElement(
903
1137
  "path",
904
1138
  {
905
1139
  d: "M1.5 9H4.5",
@@ -908,7 +1142,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
908
1142
  strokeLinejoin: "round"
909
1143
  }
910
1144
  ),
911
- /* @__PURE__ */ React12.createElement(
1145
+ /* @__PURE__ */ React14.createElement(
912
1146
  "path",
913
1147
  {
914
1148
  d: "M13.5 9H16.5",
@@ -917,7 +1151,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
917
1151
  strokeLinejoin: "round"
918
1152
  }
919
1153
  ),
920
- /* @__PURE__ */ React12.createElement(
1154
+ /* @__PURE__ */ React14.createElement(
921
1155
  "path",
922
1156
  {
923
1157
  d: "M3.6975 14.3025L5.82 12.18",
@@ -926,7 +1160,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
926
1160
  strokeLinejoin: "round"
927
1161
  }
928
1162
  ),
929
- /* @__PURE__ */ React12.createElement(
1163
+ /* @__PURE__ */ React14.createElement(
930
1164
  "path",
931
1165
  {
932
1166
  d: "M12.18 5.82L14.3025 3.6975",
@@ -938,6 +1172,48 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
938
1172
  );
939
1173
  var Loader_default = Loader;
940
1174
 
1175
+ // src/icons/Save.tsx
1176
+ var React15 = __toESM(require("react"));
1177
+ var Save = ({ size = 18, ...props }) => /* @__PURE__ */ React15.createElement(
1178
+ "svg",
1179
+ {
1180
+ xmlns: "http://www.w3.org/2000/svg",
1181
+ viewBox: "0 0 18 18",
1182
+ fill: "none",
1183
+ ...props,
1184
+ width: size,
1185
+ height: size
1186
+ },
1187
+ /* @__PURE__ */ React15.createElement(
1188
+ "path",
1189
+ {
1190
+ d: "M14.25 15.75H3.75C3.35218 15.75 2.97064 15.592 2.68934 15.3107C2.40804 15.0294 2.25 14.6478 2.25 14.25V3.75C2.25 3.35218 2.40804 2.97064 2.68934 2.68934C2.97064 2.40804 3.35218 2.25 3.75 2.25H12L15.75 6V14.25C15.75 14.6478 15.592 15.0294 15.3107 15.3107C15.0294 15.592 14.6478 15.75 14.25 15.75Z",
1191
+ stroke: "currentColor",
1192
+ strokeLinecap: "round",
1193
+ strokeLinejoin: "round"
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ React15.createElement(
1197
+ "path",
1198
+ {
1199
+ d: "M12.75 15.75V9.75H5.25V15.75",
1200
+ stroke: "currentColor",
1201
+ strokeLinecap: "round",
1202
+ strokeLinejoin: "round"
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ React15.createElement(
1206
+ "path",
1207
+ {
1208
+ d: "M5.25 2.25V6H11.25",
1209
+ stroke: "currentColor",
1210
+ strokeLinecap: "round",
1211
+ strokeLinejoin: "round"
1212
+ }
1213
+ )
1214
+ );
1215
+ var Save_default = Save;
1216
+
941
1217
  // src/components/Tooltip/Tooltip.tsx
942
1218
  var import_react11 = __toESM(require("react"));
943
1219
 
@@ -992,9 +1268,11 @@ var useTooltip = ({
992
1268
  const interactions = (0, import_react10.useInteractions)([hover, focus, dismiss, role]);
993
1269
  const { isMounted, styles } = (0, import_react10.useTransitionStyles)(context, {
994
1270
  initial: {
995
- opacity: 0
1271
+ opacity: 0,
1272
+ transform: "scale(0.7)",
1273
+ color: "transparent"
996
1274
  },
997
- duration: 200
1275
+ duration: 300
998
1276
  });
999
1277
  return import_react9.default.useMemo(
1000
1278
  () => ({
@@ -1056,12 +1334,11 @@ var TooltipContent = (0, import_react11.forwardRef)(function TooltipContent2({ s
1056
1334
  ref,
1057
1335
  className,
1058
1336
  style: {
1059
- ...context.styles,
1060
- ...context.floatingStyles,
1061
- ...style
1337
+ ...context.floatingStyles
1062
1338
  },
1063
1339
  ...context.getFloatingProps(props)
1064
- }
1340
+ },
1341
+ /* @__PURE__ */ import_react11.default.createElement("div", { className: "Layer__tooltip-content ", style: { ...context.styles } }, props.children)
1065
1342
  ));
1066
1343
  });
1067
1344
 
@@ -1069,7 +1346,8 @@ var TooltipContent = (0, import_react11.forwardRef)(function TooltipContent2({ s
1069
1346
  var import_classnames2 = __toESM(require("classnames"));
1070
1347
  var buildRightIcon = ({
1071
1348
  processing,
1072
- error
1349
+ error,
1350
+ action
1073
1351
  }) => {
1074
1352
  if (processing) {
1075
1353
  return /* @__PURE__ */ import_react13.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
@@ -1077,6 +1355,9 @@ var buildRightIcon = ({
1077
1355
  if (error) {
1078
1356
  return /* @__PURE__ */ import_react13.default.createElement(Tooltip, { offset: 12 }, /* @__PURE__ */ import_react13.default.createElement(TooltipTrigger, null, /* @__PURE__ */ import_react13.default.createElement(AlertCircle_default, { size: 14 })), /* @__PURE__ */ import_react13.default.createElement(TooltipContent, { className: "Layer__tooltip" }, error));
1079
1357
  }
1358
+ if (action === "update" /* UPDATE */) {
1359
+ return /* @__PURE__ */ import_react13.default.createElement("span", { className: "Layer__pt-2" }, /* @__PURE__ */ import_react13.default.createElement(Save_default, { size: 14 }));
1360
+ }
1080
1361
  return /* @__PURE__ */ import_react13.default.createElement("span", null, /* @__PURE__ */ import_react13.default.createElement(Check_default, { className: "Layer__btn-icon--on-active", size: 14 }), /* @__PURE__ */ import_react13.default.createElement(
1081
1362
  CheckCircle_default,
1082
1363
  {
@@ -1093,6 +1374,7 @@ var SubmitButton = ({
1093
1374
  disabled,
1094
1375
  error,
1095
1376
  children,
1377
+ action = "save" /* SAVE */,
1096
1378
  ...props
1097
1379
  }) => {
1098
1380
  const baseClassName = (0, import_classnames2.default)(
@@ -1106,331 +1388,411 @@ var SubmitButton = ({
1106
1388
  className: baseClassName,
1107
1389
  variant: "primary" /* primary */,
1108
1390
  disabled: processing || disabled,
1109
- rightIcon: buildRightIcon({ processing, error })
1391
+ rightIcon: buildRightIcon({ processing, error, action }),
1392
+ iconAsPrimary: true
1110
1393
  },
1111
1394
  children
1112
1395
  );
1113
1396
  };
1114
1397
 
1115
- // src/components/CategoryMenu/CategoryMenu.tsx
1398
+ // src/components/Button/IconButton.tsx
1116
1399
  var import_react14 = __toESM(require("react"));
1117
- var import_react_select = __toESM(require("react-select"));
1118
- var DropdownIndicator = (props) => {
1119
- return /* @__PURE__ */ import_react14.default.createElement(import_react_select.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react14.default.createElement(ChevronDown_default, null));
1120
- };
1121
- var CategoryMenu = ({
1122
- bankTransaction,
1123
- name,
1124
- value,
1125
- onChange,
1126
- disabled,
1127
- className
1400
+ var import_classnames3 = __toESM(require("classnames"));
1401
+ var IconButton = ({
1402
+ className,
1403
+ children,
1404
+ icon,
1405
+ active,
1406
+ ...props
1128
1407
  }) => {
1129
- const { categories } = useLayerContext();
1130
- const suggestedOptions = hasSuggestions(bankTransaction.categorization_flow) ? [
1131
- {
1132
- label: "Suggested",
1133
- options: bankTransaction.categorization_flow.suggestions
1134
- }
1135
- ] : [];
1136
- const categoryOptions = (categories || []).map((category) => {
1137
- if (category?.subCategories && category?.subCategories?.length > 0) {
1138
- return {
1139
- label: category.display_name,
1140
- options: category.subCategories
1141
- };
1142
- }
1143
- return {
1144
- label: category.display_name,
1145
- options: [category]
1146
- };
1147
- }).filter((x) => x);
1148
- console.log("categoryOptions", categoryOptions);
1149
- const options = [...suggestedOptions, ...categoryOptions];
1150
- return /* @__PURE__ */ import_react14.default.createElement(
1151
- import_react_select.default,
1152
- {
1153
- name,
1154
- className: `Layer__category-menu Layer__select ${className ?? ""}`,
1155
- classNamePrefix: "Layer__select",
1156
- options,
1157
- isSearchable: true,
1158
- value,
1159
- onChange: (newValue) => newValue && onChange(newValue),
1160
- getOptionLabel: (category) => category.display_name,
1161
- getOptionValue: (category) => category.stable_name || category.category,
1162
- menuPortalTarget: document.body,
1163
- styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
1164
- components: { DropdownIndicator },
1165
- isDisabled: disabled
1166
- }
1408
+ const baseClassName = (0, import_classnames3.default)(
1409
+ "Layer__icon-btn",
1410
+ `Layer__icon-btn--${active ? "active" : "inactive"}`,
1411
+ className
1167
1412
  );
1413
+ return /* @__PURE__ */ import_react14.default.createElement("button", { ...props, className: baseClassName }, icon);
1168
1414
  };
1169
1415
 
1170
- // src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
1171
- var import_react22 = __toESM(require("react"));
1416
+ // src/components/Button/TextButton.tsx
1417
+ var import_react15 = __toESM(require("react"));
1418
+ var import_classnames4 = __toESM(require("classnames"));
1419
+ var TextButton = ({
1420
+ className,
1421
+ children,
1422
+ ...props
1423
+ }) => {
1424
+ const baseClassName = (0, import_classnames4.default)("Layer__text-btn", className);
1425
+ return /* @__PURE__ */ import_react15.default.createElement("button", { ...props, className: baseClassName }, children);
1426
+ };
1427
+
1428
+ // src/components/Badge/Badge.tsx
1429
+ var import_classnames5 = __toESM(require("classnames"));
1430
+ var Badge = ({
1431
+ icon,
1432
+ onClick,
1433
+ children,
1434
+ tooltip,
1435
+ size = "medium" /* MEDIUM */
1436
+ }) => {
1437
+ const baseProps = {
1438
+ className: (0, import_classnames5.default)(
1439
+ "Layer__badge",
1440
+ onClick || tooltip ? "Layer__badge--clickable" : "",
1441
+ `Layer__badge--${size}`
1442
+ ),
1443
+ onClick,
1444
+ children
1445
+ };
1446
+ let content = /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, icon && /* @__PURE__ */ import_react16.default.createElement("span", { className: "Layer__badge__icon" }, icon), children);
1447
+ content = onClick ? /* @__PURE__ */ import_react16.default.createElement(Button, { ...baseProps }, content) : /* @__PURE__ */ import_react16.default.createElement("span", { ...baseProps }, content);
1448
+ if (tooltip) {
1449
+ return /* @__PURE__ */ import_react16.default.createElement(Tooltip, { offset: 12 }, /* @__PURE__ */ import_react16.default.createElement(TooltipTrigger, null, content), /* @__PURE__ */ import_react16.default.createElement(TooltipContent, { className: "Layer__tooltip" }, tooltip));
1450
+ }
1451
+ return content;
1452
+ };
1453
+
1454
+ // src/components/CategorySelect/CategorySelect.tsx
1455
+ var import_react17 = __toESM(require("react"));
1456
+ var import_react_select = __toESM(require("react-select"));
1172
1457
 
1173
- // src/icons/FolderPlus.tsx
1174
- var React17 = __toESM(require("react"));
1175
- var FolderPlus = ({ size = 18, ...props }) => /* @__PURE__ */ React17.createElement(
1458
+ // src/icons/MinimizeTwo.tsx
1459
+ var React22 = __toESM(require("react"));
1460
+ var MinimizeTwo = ({ size = 18, ...props }) => /* @__PURE__ */ React22.createElement(
1176
1461
  "svg",
1177
1462
  {
1463
+ xmlns: "http://www.w3.org/2000/svg",
1178
1464
  viewBox: "0 0 18 18",
1179
1465
  fill: "none",
1180
- xmlns: "http://www.w3.org/2000/svg",
1181
1466
  ...props,
1182
1467
  width: size,
1183
1468
  height: size
1184
1469
  },
1185
- /* @__PURE__ */ React17.createElement(
1470
+ /* @__PURE__ */ React22.createElement(
1186
1471
  "path",
1187
1472
  {
1188
- d: "M16.5 14.25C16.5 14.6478 16.342 15.0294 16.0607 15.3107C15.7794 15.592 15.3978 15.75 15 15.75H3C2.60218 15.75 2.22064 15.592 1.93934 15.3107C1.65804 15.0294 1.5 14.6478 1.5 14.25V3.75C1.5 3.35218 1.65804 2.97064 1.93934 2.68934C2.22064 2.40804 2.60218 2.25 3 2.25H6.75L8.25 4.5H15C15.3978 4.5 15.7794 4.65804 16.0607 4.93934C16.342 5.22064 16.5 5.60218 16.5 6V14.25Z",
1473
+ d: "M3 10.5H7.5V15",
1189
1474
  stroke: "currentColor",
1190
1475
  strokeLinecap: "round",
1191
1476
  strokeLinejoin: "round"
1192
1477
  }
1193
1478
  ),
1194
- /* @__PURE__ */ React17.createElement(
1479
+ /* @__PURE__ */ React22.createElement(
1195
1480
  "path",
1196
1481
  {
1197
- d: "M9 8.25V12.75",
1482
+ d: "M15 7.5H10.5V3",
1198
1483
  stroke: "currentColor",
1199
1484
  strokeLinecap: "round",
1200
1485
  strokeLinejoin: "round"
1201
1486
  }
1202
1487
  ),
1203
- /* @__PURE__ */ React17.createElement(
1204
- "path",
1205
- {
1206
- d: "M6.75 10.5H11.25",
1207
- stroke: "currentColor",
1208
- strokeLinecap: "round",
1209
- strokeLinejoin: "round"
1210
- }
1211
- )
1212
- );
1213
- var FolderPlus_default = FolderPlus;
1214
-
1215
- // src/icons/Link.tsx
1216
- var React18 = __toESM(require("react"));
1217
- var Link = ({ size = 18, ...props }) => /* @__PURE__ */ React18.createElement(
1218
- "svg",
1219
- {
1220
- xmlns: "http://www.w3.org/2000/svg",
1221
- viewBox: "0 0 18 18",
1222
- fill: "none",
1223
- ...props,
1224
- width: size,
1225
- height: size
1226
- },
1227
- /* @__PURE__ */ React18.createElement(
1488
+ /* @__PURE__ */ React22.createElement(
1228
1489
  "path",
1229
1490
  {
1230
- d: "M7.5 9.75C7.82209 10.1806 8.23302 10.5369 8.70491 10.7947C9.17681 11.0525 9.69863 11.2058 10.235 11.2442C10.7713 11.2827 11.3097 11.2053 11.8135 11.0173C12.3173 10.8294 12.7748 10.5353 13.155 10.155L15.405 7.905C16.0881 7.19774 16.4661 6.25048 16.4575 5.26724C16.449 4.284 16.0546 3.34346 15.3593 2.64818C14.664 1.9529 13.7235 1.55851 12.7403 1.54997C11.757 1.54143 10.8098 1.9194 10.1025 2.6025L8.8125 3.885",
1491
+ d: "M10.5 7.5L15.75 2.25",
1231
1492
  stroke: "currentColor",
1232
1493
  strokeLinecap: "round",
1233
1494
  strokeLinejoin: "round"
1234
1495
  }
1235
1496
  ),
1236
- /* @__PURE__ */ React18.createElement(
1497
+ /* @__PURE__ */ React22.createElement(
1237
1498
  "path",
1238
1499
  {
1239
- d: "M10.5 8.25C10.1779 7.8194 9.76698 7.46311 9.29508 7.2053C8.82319 6.94748 8.30137 6.79416 7.76501 6.75575C7.22865 6.71734 6.69031 6.79473 6.18649 6.98266C5.68267 7.1706 5.22516 7.4647 4.845 7.845L2.595 10.095C1.9119 10.8023 1.53393 11.7495 1.54247 12.7328C1.55101 13.716 1.9454 14.6565 2.64068 15.3518C3.33596 16.0471 4.2765 16.4415 5.25974 16.45C6.24298 16.4586 7.19024 16.0806 7.8975 15.3975L9.18 14.115",
1500
+ d: "M2.25 15.75L7.5 10.5",
1240
1501
  stroke: "currentColor",
1241
1502
  strokeLinecap: "round",
1242
1503
  strokeLinejoin: "round"
1243
1504
  }
1244
1505
  )
1245
1506
  );
1246
- var Link_default = Link;
1507
+ var MinimizeTwo_default = MinimizeTwo;
1247
1508
 
1248
- // src/icons/RefreshCcw.tsx
1249
- var React19 = __toESM(require("react"));
1250
- var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React19.createElement(
1251
- "svg",
1509
+ // src/components/CategorySelect/CategorySelect.tsx
1510
+ var import_classnames6 = __toESM(require("classnames"));
1511
+ var import_date_fns4 = require("date-fns");
1512
+ var mapCategoryToOption = (category) => {
1513
+ return {
1514
+ type: "category" /* CATEGORY */,
1515
+ payload: {
1516
+ id: category.id,
1517
+ option_type: "category" /* CATEGORY */,
1518
+ display_name: category.display_name,
1519
+ type: category.type,
1520
+ stable_name: category.stable_name,
1521
+ entries: category.entries,
1522
+ subCategories: category.subCategories
1523
+ }
1524
+ };
1525
+ };
1526
+ var mapSuggestedMatchToOption = (record) => {
1527
+ return {
1528
+ type: "match" /* MATCH */,
1529
+ payload: {
1530
+ id: record.id,
1531
+ option_type: "match" /* MATCH */,
1532
+ display_name: record.details.description,
1533
+ amount: record.details.amount
1534
+ }
1535
+ };
1536
+ };
1537
+ var DropdownIndicator = (props) => {
1538
+ return /* @__PURE__ */ import_react17.default.createElement(import_react_select.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react17.default.createElement(ChevronDown_default, null));
1539
+ };
1540
+ var GroupHeading = (props) => {
1541
+ return /* @__PURE__ */ import_react17.default.createElement(
1542
+ import_react_select.components.GroupHeading,
1543
+ {
1544
+ className: (0, import_classnames6.default)(
1545
+ props.className,
1546
+ props.children === "Match" || props.children === "All categories" ? "Layer__select__group-heading--main" : ""
1547
+ ),
1548
+ ...props
1549
+ }
1550
+ );
1551
+ };
1552
+ var Option = (props) => {
1553
+ if (props.data.payload.option_type === "hidden") {
1554
+ return;
1555
+ }
1556
+ if (props.data.type === "match") {
1557
+ return /* @__PURE__ */ import_react17.default.createElement(
1558
+ import_react_select.components.Option,
1559
+ {
1560
+ ...props,
1561
+ className: `${props.className} Layer__select__option-content__match`
1562
+ },
1563
+ /* @__PURE__ */ import_react17.default.createElement("div", { className: "Layer__select__option-content__match__main-row" }, /* @__PURE__ */ import_react17.default.createElement("span", { className: "Layer__select__option-content__match__date" }, props.data.payload.date && (0, import_date_fns4.format)((0, import_date_fns4.parseISO)(props.data.payload.date), DATE_FORMAT)), /* @__PURE__ */ import_react17.default.createElement("span", { className: "Layer__select__option-content__match__description" }, props.data.payload.display_name)),
1564
+ /* @__PURE__ */ import_react17.default.createElement("div", { className: "Layer__select__option-content__match__amount-row" }, /* @__PURE__ */ import_react17.default.createElement("span", { className: "Layer__select__option-content__match__amount" }, "$", centsToDollars(props.data.payload.amount)))
1565
+ );
1566
+ }
1567
+ return /* @__PURE__ */ import_react17.default.createElement(
1568
+ import_react_select.components.Option,
1569
+ {
1570
+ ...props,
1571
+ className: `Layer__select__option-menu-content ${props.className}`
1572
+ },
1573
+ /* @__PURE__ */ import_react17.default.createElement("div", null, props.data.payload.display_name),
1574
+ props.isSelected ? /* @__PURE__ */ import_react17.default.createElement("span", { className: "Layer__select__option-menu-content-check" }, /* @__PURE__ */ import_react17.default.createElement(Check_default, { size: 16 })) : null
1575
+ );
1576
+ };
1577
+ var allCategoriesDivider = [
1252
1578
  {
1253
- viewBox: "0 0 18 18",
1254
- fill: "none",
1255
- xmlns: "http://www.w3.org/2000/svg",
1256
- ...props,
1257
- width: size,
1258
- height: size
1259
- },
1260
- /* @__PURE__ */ React19.createElement(
1261
- "path",
1579
+ label: "All categories",
1580
+ options: [
1581
+ {
1582
+ type: "All categories",
1583
+ disabled: true,
1584
+ payload: {
1585
+ id: "all_categories",
1586
+ option_type: "hidden" /* HIDDEN */,
1587
+ display_name: "ALL CATEGORIES"
1588
+ }
1589
+ }
1590
+ ]
1591
+ }
1592
+ ];
1593
+ function flattenCategories(categories) {
1594
+ const categoryOptions = (categories || []).flatMap((category) => {
1595
+ if (category?.subCategories && category?.subCategories?.length > 0) {
1596
+ if (category?.subCategories?.every((c) => c.subCategories === void 0)) {
1597
+ return [
1598
+ {
1599
+ label: category.display_name,
1600
+ options: category.subCategories.map((x) => mapCategoryToOption(x))
1601
+ }
1602
+ ];
1603
+ }
1604
+ return flattenCategories(category.subCategories);
1605
+ }
1606
+ const resultOption = {
1607
+ label: category.display_name,
1608
+ options: [mapCategoryToOption(category)]
1609
+ };
1610
+ return [resultOption];
1611
+ });
1612
+ return categoryOptions;
1613
+ }
1614
+ var CategorySelect = ({
1615
+ bankTransaction,
1616
+ name,
1617
+ value,
1618
+ onChange,
1619
+ disabled,
1620
+ className
1621
+ }) => {
1622
+ const { categories } = useLayerContext();
1623
+ const matchOptions = bankTransaction?.suggested_matches ? [
1262
1624
  {
1263
- d: "M0.75 3V7.5H5.25",
1264
- stroke: "currentColor",
1265
- strokeLinecap: "round",
1266
- strokeLinejoin: "round"
1625
+ label: "Match",
1626
+ options: bankTransaction.suggested_matches.map((x) => {
1627
+ return {
1628
+ type: "match" /* MATCH */,
1629
+ payload: {
1630
+ id: x.id,
1631
+ option_type: "match" /* MATCH */,
1632
+ display_name: x.details.description,
1633
+ date: x.details.date,
1634
+ amount: x.details.amount
1635
+ }
1636
+ };
1637
+ })
1267
1638
  }
1268
- ),
1269
- /* @__PURE__ */ React19.createElement(
1270
- "path",
1639
+ ] : [];
1640
+ const suggestedOptions = bankTransaction?.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? [
1271
1641
  {
1272
- d: "M17.25 15V10.5H12.75",
1273
- stroke: "currentColor",
1274
- strokeLinecap: "round",
1275
- strokeLinejoin: "round"
1642
+ label: "Suggestions",
1643
+ options: bankTransaction.categorization_flow.suggestions.map(
1644
+ (x) => mapCategoryToOption(x)
1645
+ )
1276
1646
  }
1277
- ),
1278
- /* @__PURE__ */ React19.createElement(
1279
- "path",
1647
+ ] : [];
1648
+ const categoryOptions = flattenCategories(categories);
1649
+ const options = [
1650
+ ...matchOptions,
1651
+ ...suggestedOptions,
1652
+ ...allCategoriesDivider,
1653
+ ...categoryOptions
1654
+ ];
1655
+ const selected = value ? value : matchOptions?.length === 1 && matchOptions[0].options.length === 1 ? matchOptions[0].options[0] : void 0;
1656
+ const placeholder = matchOptions?.length === 1 && matchOptions[0].options.length > 1 ? `${matchOptions[0].options.length} possible matches...` : "Categorize or match...";
1657
+ return /* @__PURE__ */ import_react17.default.createElement(
1658
+ import_react_select.default,
1280
1659
  {
1281
- d: "M15.3675 6.75C14.9871 5.67508 14.3407 4.71405 13.4884 3.95656C12.6361 3.19907 11.6059 2.66982 10.4938 2.41819C9.38167 2.16656 8.22393 2.20075 7.12861 2.51758C6.03328 2.8344 5.03606 3.42353 4.23 4.23L0.75 7.5M17.25 10.5L13.77 13.77C12.9639 14.5765 11.9667 15.1656 10.8714 15.4824C9.77607 15.7992 8.61833 15.8334 7.50621 15.5818C6.3941 15.3302 5.36385 14.8009 4.5116 14.0434C3.65935 13.2859 3.01288 12.3249 2.6325 11.25",
1282
- stroke: "currentColor",
1283
- strokeLinecap: "round",
1284
- strokeLinejoin: "round"
1660
+ name,
1661
+ className: `Layer__category-menu Layer__select ${className ?? ""}`,
1662
+ classNamePrefix: "Layer__select",
1663
+ options,
1664
+ isSearchable: true,
1665
+ placeholder,
1666
+ defaultValue: selected,
1667
+ formatOptionLabel: (props) => /* @__PURE__ */ import_react17.default.createElement("div", { className: "Layer__select__option-label" }, props.type === "match" && /* @__PURE__ */ import_react17.default.createElement(Badge, { size: "small" /* SMALL */, icon: /* @__PURE__ */ import_react17.default.createElement(MinimizeTwo_default, { size: 11 }) }, "Match"), /* @__PURE__ */ import_react17.default.createElement("span", null, props.payload.display_name)),
1668
+ value,
1669
+ onChange: (newValue) => newValue && onChange(newValue),
1670
+ getOptionLabel: (category) => category.payload.display_name,
1671
+ getOptionValue: (category) => category.payload.id,
1672
+ menuPortalTarget: document.body,
1673
+ styles: {
1674
+ menuPortal: (base) => ({ ...base, zIndex: 9999 })
1675
+ },
1676
+ components: { DropdownIndicator, GroupHeading, Option },
1677
+ isDisabled: disabled,
1678
+ isOptionDisabled: (option) => option.disabled ?? false
1285
1679
  }
1286
- )
1287
- );
1288
- var RefreshCcw_default = RefreshCcw;
1680
+ );
1681
+ };
1289
1682
 
1290
- // src/icons/Scissors.tsx
1291
- var React20 = __toESM(require("react"));
1292
- var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React20.createElement(
1683
+ // src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
1684
+ var import_react28 = __toESM(require("react"));
1685
+
1686
+ // src/icons/Link.tsx
1687
+ var React24 = __toESM(require("react"));
1688
+ var Link = ({ size = 18, ...props }) => /* @__PURE__ */ React24.createElement(
1293
1689
  "svg",
1294
1690
  {
1295
- viewBox: "0 0 11 11",
1296
- fill: "none",
1297
1691
  xmlns: "http://www.w3.org/2000/svg",
1692
+ viewBox: "0 0 18 18",
1693
+ fill: "none",
1298
1694
  ...props,
1299
1695
  width: size,
1300
1696
  height: size
1301
1697
  },
1302
- /* @__PURE__ */ React20.createElement(
1303
- "path",
1304
- {
1305
- d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
1306
- stroke: "currentColor",
1307
- strokeLinecap: "round",
1308
- strokeLinejoin: "round"
1309
- },
1310
- /* @__PURE__ */ React20.createElement(
1311
- "animate",
1312
- {
1313
- attributeName: "d",
1314
- className: "animateOnHover",
1315
- values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
1316
- begin: "indefinite",
1317
- dur: "400ms",
1318
- repeatCount: "1",
1319
- fill: "freeze",
1320
- calcMode: "linear",
1321
- keyTimes: "0;0.5;1"
1322
- }
1323
- )
1324
- ),
1325
- /* @__PURE__ */ React20.createElement(
1326
- "path",
1327
- {
1328
- d: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
1329
- stroke: "currentColor",
1330
- strokeLinecap: "round",
1331
- strokeLinejoin: "round"
1332
- },
1333
- /* @__PURE__ */ React20.createElement(
1334
- "animate",
1335
- {
1336
- attributeName: "d",
1337
- className: "animateOnHover",
1338
- values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
1339
- begin: "indefinite",
1340
- dur: "400ms",
1341
- repeatCount: "1",
1342
- fill: "freeze",
1343
- calcMode: "linear",
1344
- keyTimes: "0;0.5;1"
1345
- }
1346
- )
1347
- ),
1348
- /* @__PURE__ */ React20.createElement(
1349
- "path",
1350
- {
1351
- d: "M9.16668 1.83325L3.72168 7.27825",
1352
- stroke: "currentColor",
1353
- strokeLinecap: "round",
1354
- strokeLinejoin: "round"
1355
- },
1356
- /* @__PURE__ */ React20.createElement(
1357
- "animate",
1358
- {
1359
- attributeName: "d",
1360
- className: "animateOnHover",
1361
- values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
1362
- begin: "indefinite",
1363
- dur: "400ms",
1364
- repeatCount: "1",
1365
- fill: "freeze",
1366
- calcMode: "linear",
1367
- keyTimes: "0;0.5;1"
1368
- }
1369
- )
1370
- ),
1371
- /* @__PURE__ */ React20.createElement(
1698
+ /* @__PURE__ */ React24.createElement(
1372
1699
  "path",
1373
1700
  {
1374
- d: "M6.63232 6.63672L9.16691 9.16672",
1701
+ d: "M7.5 9.75C7.82209 10.1806 8.23302 10.5369 8.70491 10.7947C9.17681 11.0525 9.69863 11.2058 10.235 11.2442C10.7713 11.2827 11.3097 11.2053 11.8135 11.0173C12.3173 10.8294 12.7748 10.5353 13.155 10.155L15.405 7.905C16.0881 7.19774 16.4661 6.25048 16.4575 5.26724C16.449 4.284 16.0546 3.34346 15.3593 2.64818C14.664 1.9529 13.7235 1.55851 12.7403 1.54997C11.757 1.54143 10.8098 1.9194 10.1025 2.6025L8.8125 3.885",
1375
1702
  stroke: "currentColor",
1376
1703
  strokeLinecap: "round",
1377
1704
  strokeLinejoin: "round"
1378
- },
1379
- /* @__PURE__ */ React20.createElement(
1380
- "animate",
1381
- {
1382
- attributeName: "d",
1383
- className: "animateOnHover",
1384
- values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
1385
- begin: "indefinite",
1386
- dur: "400ms",
1387
- repeatCount: "1",
1388
- fill: "freeze",
1389
- calcMode: "linear",
1390
- keyTimes: "0;0.5;1"
1391
- }
1392
- )
1705
+ }
1393
1706
  ),
1394
- /* @__PURE__ */ React20.createElement(
1707
+ /* @__PURE__ */ React24.createElement(
1395
1708
  "path",
1396
1709
  {
1397
- d: "M3.72168 3.72168L5.50001 5.50001",
1710
+ d: "M10.5 8.25C10.1779 7.8194 9.76698 7.46311 9.29508 7.2053C8.82319 6.94748 8.30137 6.79416 7.76501 6.75575C7.22865 6.71734 6.69031 6.79473 6.18649 6.98266C5.68267 7.1706 5.22516 7.4647 4.845 7.845L2.595 10.095C1.9119 10.8023 1.53393 11.7495 1.54247 12.7328C1.55101 13.716 1.9454 14.6565 2.64068 15.3518C3.33596 16.0471 4.2765 16.4415 5.25974 16.45C6.24298 16.4586 7.19024 16.0806 7.8975 15.3975L9.18 14.115",
1398
1711
  stroke: "currentColor",
1399
1712
  strokeLinecap: "round",
1400
1713
  strokeLinejoin: "round"
1401
- },
1402
- /* @__PURE__ */ React20.createElement(
1403
- "animate",
1404
- {
1405
- attributeName: "d",
1406
- className: "animateOnHover",
1407
- values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
1408
- begin: "indefinite",
1409
- dur: "400ms",
1410
- repeatCount: "1",
1411
- fill: "freeze",
1412
- calcMode: "linear",
1413
- keyTimes: "0;0.5;1"
1414
- }
1415
- )
1714
+ }
1416
1715
  )
1417
1716
  );
1418
- var Scissors_default = Scissors;
1717
+ var Link_default = Link;
1718
+
1719
+ // src/components/CategoryMenu/CategoryMenu.tsx
1720
+ var import_react18 = __toESM(require("react"));
1721
+ var import_react_select2 = __toESM(require("react-select"));
1722
+ var DropdownIndicator2 = (props) => {
1723
+ return /* @__PURE__ */ import_react18.default.createElement(import_react_select2.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react18.default.createElement(ChevronDown_default, null));
1724
+ };
1725
+ var CategoryMenu = ({
1726
+ bankTransaction,
1727
+ name,
1728
+ value,
1729
+ onChange,
1730
+ disabled,
1731
+ className
1732
+ }) => {
1733
+ const { categories } = useLayerContext();
1734
+ const suggestedOptions = hasSuggestions(bankTransaction.categorization_flow) ? [
1735
+ {
1736
+ label: "Suggested",
1737
+ options: bankTransaction.categorization_flow.suggestions
1738
+ }
1739
+ ] : [];
1740
+ const categoryOptions = (categories || []).map((category) => {
1741
+ if (category?.subCategories && category?.subCategories?.length > 0) {
1742
+ return {
1743
+ label: category.display_name,
1744
+ options: category.subCategories
1745
+ };
1746
+ }
1747
+ return {
1748
+ label: category.display_name,
1749
+ options: [category]
1750
+ };
1751
+ }).filter((x) => x);
1752
+ const options = [...suggestedOptions, ...categoryOptions];
1753
+ return /* @__PURE__ */ import_react18.default.createElement(
1754
+ import_react_select2.default,
1755
+ {
1756
+ name,
1757
+ className: `Layer__category-menu Layer__select ${className ?? ""}`,
1758
+ classNamePrefix: "Layer__select",
1759
+ options,
1760
+ isSearchable: true,
1761
+ value,
1762
+ onChange: (newValue) => newValue && onChange(newValue),
1763
+ getOptionLabel: (category) => category.display_name,
1764
+ getOptionValue: (category) => category.stable_name || category.category,
1765
+ menuPortalTarget: document.body,
1766
+ styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
1767
+ components: { DropdownIndicator: DropdownIndicator2 },
1768
+ isDisabled: disabled
1769
+ }
1770
+ );
1771
+ };
1419
1772
 
1420
1773
  // src/components/Input/Input.tsx
1421
- var import_react15 = __toESM(require("react"));
1422
- var import_classnames3 = __toESM(require("classnames"));
1423
- var Input = ({ className, ...props }) => {
1424
- const baseClassName = (0, import_classnames3.default)("Layer__input", className);
1425
- return /* @__PURE__ */ import_react15.default.createElement("input", { ...props, className: baseClassName });
1774
+ var import_react19 = __toESM(require("react"));
1775
+ var import_classnames7 = __toESM(require("classnames"));
1776
+ var Input = ({
1777
+ className,
1778
+ isInvalid,
1779
+ errorMessage,
1780
+ ...props
1781
+ }) => {
1782
+ const baseClassName = (0, import_classnames7.default)(
1783
+ "Layer__input",
1784
+ isInvalid ? "Layer__input--error" : "",
1785
+ className
1786
+ );
1787
+ return /* @__PURE__ */ import_react19.default.createElement(Tooltip, { disabled: !isInvalid || !errorMessage }, /* @__PURE__ */ import_react19.default.createElement(TooltipTrigger, { className: "Layer__input-tooltip" }, /* @__PURE__ */ import_react19.default.createElement("input", { ...props, className: baseClassName })), /* @__PURE__ */ import_react19.default.createElement(TooltipContent, { className: "Layer__tooltip" }, errorMessage));
1426
1788
  };
1427
1789
 
1428
1790
  // src/components/Input/InputGroup.tsx
1429
- var import_react18 = __toESM(require("react"));
1791
+ var import_react22 = __toESM(require("react"));
1430
1792
 
1431
1793
  // src/components/Typography/Text.tsx
1432
- var import_react16 = __toESM(require("react"));
1433
- var import_classnames4 = __toESM(require("classnames"));
1794
+ var import_react20 = __toESM(require("react"));
1795
+ var import_classnames8 = __toESM(require("classnames"));
1434
1796
  var Text = ({
1435
1797
  as: Component = "p",
1436
1798
  className,
@@ -1440,12 +1802,12 @@ var Text = ({
1440
1802
  withTooltip,
1441
1803
  ...props
1442
1804
  }) => {
1443
- const baseClassName = (0, import_classnames4.default)(
1805
+ const baseClassName = (0, import_classnames8.default)(
1444
1806
  `Layer__text Layer__text--${size} Layer__text--${weight}`,
1445
1807
  className
1446
1808
  );
1447
1809
  if (withTooltip) {
1448
- return /* @__PURE__ */ import_react16.default.createElement(
1810
+ return /* @__PURE__ */ import_react20.default.createElement(
1449
1811
  TextWithTooltip,
1450
1812
  {
1451
1813
  as: Component,
@@ -1458,7 +1820,7 @@ var Text = ({
1458
1820
  children
1459
1821
  );
1460
1822
  }
1461
- return /* @__PURE__ */ import_react16.default.createElement(Component, { ...props, className: baseClassName }, children);
1823
+ return /* @__PURE__ */ import_react20.default.createElement(Component, { ...props, className: baseClassName }, children);
1462
1824
  };
1463
1825
  var TextWithTooltip = ({
1464
1826
  as: Component = "p",
@@ -1470,66 +1832,66 @@ var TextWithTooltip = ({
1470
1832
  tooltipOptions,
1471
1833
  ...props
1472
1834
  }) => {
1473
- const textElementRef = (0, import_react16.useRef)();
1835
+ const textElementRef = (0, import_react20.useRef)();
1474
1836
  const compareSize = () => {
1475
1837
  if (textElementRef.current) {
1476
1838
  const compare = textElementRef.current.children[0].scrollWidth > textElementRef.current.children[0].clientWidth;
1477
1839
  setHover(compare);
1478
1840
  }
1479
1841
  };
1480
- (0, import_react16.useEffect)(() => {
1842
+ (0, import_react20.useEffect)(() => {
1481
1843
  compareSize();
1482
1844
  window.addEventListener("resize", compareSize);
1483
1845
  }, []);
1484
- (0, import_react16.useEffect)(
1846
+ (0, import_react20.useEffect)(
1485
1847
  () => () => {
1486
1848
  window.removeEventListener("resize", compareSize);
1487
1849
  },
1488
1850
  []
1489
1851
  );
1490
- const [hoverStatus, setHover] = (0, import_react16.useState)(false);
1491
- const contentClassName = (0, import_classnames4.default)(
1852
+ const [hoverStatus, setHover] = (0, import_react20.useState)(false);
1853
+ const contentClassName = (0, import_classnames8.default)(
1492
1854
  "Layer__tooltip",
1493
1855
  tooltipOptions?.contentClassName
1494
1856
  );
1495
- return /* @__PURE__ */ import_react16.default.createElement(
1857
+ return /* @__PURE__ */ import_react20.default.createElement(
1496
1858
  Tooltip,
1497
1859
  {
1498
1860
  disabled: !hoverStatus,
1499
1861
  offset: tooltipOptions?.offset,
1500
1862
  shift: tooltipOptions?.shift
1501
1863
  },
1502
- /* @__PURE__ */ import_react16.default.createElement(TooltipTrigger, null, /* @__PURE__ */ import_react16.default.createElement(Component, { className, ref: textElementRef, ...props }, children)),
1503
- /* @__PURE__ */ import_react16.default.createElement(TooltipContent, { className: contentClassName }, children)
1864
+ /* @__PURE__ */ import_react20.default.createElement(TooltipTrigger, null, /* @__PURE__ */ import_react20.default.createElement(Component, { className, ref: textElementRef, ...props }, children)),
1865
+ /* @__PURE__ */ import_react20.default.createElement(TooltipContent, { className: contentClassName }, children)
1504
1866
  );
1505
1867
  };
1506
1868
 
1507
1869
  // src/components/Typography/Heading.tsx
1508
- var import_react17 = __toESM(require("react"));
1509
- var import_classnames5 = __toESM(require("classnames"));
1870
+ var import_react21 = __toESM(require("react"));
1871
+ var import_classnames9 = __toESM(require("classnames"));
1510
1872
  var Heading = ({
1511
1873
  as: Component = "h2",
1512
1874
  className,
1513
1875
  children,
1514
1876
  size = "primary" /* primary */
1515
1877
  }) => {
1516
- const baseClassName = (0, import_classnames5.default)(
1878
+ const baseClassName = (0, import_classnames9.default)(
1517
1879
  `Layer__heading Layer__heading--${size}`,
1518
1880
  className
1519
1881
  );
1520
- return /* @__PURE__ */ import_react17.default.createElement(Component, { className: baseClassName }, children);
1882
+ return /* @__PURE__ */ import_react21.default.createElement(Component, { className: baseClassName }, children);
1521
1883
  };
1522
1884
 
1523
1885
  // src/components/Input/InputGroup.tsx
1524
- var import_classnames6 = __toESM(require("classnames"));
1886
+ var import_classnames10 = __toESM(require("classnames"));
1525
1887
  var InputGroup = ({
1526
1888
  label,
1527
1889
  name,
1528
1890
  className,
1529
1891
  children
1530
1892
  }) => {
1531
- const baseClassName = (0, import_classnames6.default)("Layer__input-group", className);
1532
- return /* @__PURE__ */ import_react18.default.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ import_react18.default.createElement(
1893
+ const baseClassName = (0, import_classnames10.default)("Layer__input-group", className);
1894
+ return /* @__PURE__ */ import_react22.default.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ import_react22.default.createElement(
1533
1895
  Text,
1534
1896
  {
1535
1897
  as: "label",
@@ -1542,11 +1904,11 @@ var InputGroup = ({
1542
1904
  };
1543
1905
 
1544
1906
  // src/components/Input/FileInput.tsx
1545
- var import_react19 = __toESM(require("react"));
1907
+ var import_react23 = __toESM(require("react"));
1546
1908
 
1547
1909
  // src/icons/UploadCloud.tsx
1548
- var React25 = __toESM(require("react"));
1549
- var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createElement(
1910
+ var React30 = __toESM(require("react"));
1911
+ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React30.createElement(
1550
1912
  "svg",
1551
1913
  {
1552
1914
  viewBox: "0 0 18 18",
@@ -1556,7 +1918,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
1556
1918
  width: size,
1557
1919
  height: size
1558
1920
  },
1559
- /* @__PURE__ */ React25.createElement(
1921
+ /* @__PURE__ */ React30.createElement(
1560
1922
  "path",
1561
1923
  {
1562
1924
  d: "M12 12L9 9L6 12",
@@ -1565,7 +1927,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
1565
1927
  strokeLinejoin: "round"
1566
1928
  }
1567
1929
  ),
1568
- /* @__PURE__ */ React25.createElement(
1930
+ /* @__PURE__ */ React30.createElement(
1569
1931
  "path",
1570
1932
  {
1571
1933
  d: "M9 9V15.75",
@@ -1574,7 +1936,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
1574
1936
  strokeLinejoin: "round"
1575
1937
  }
1576
1938
  ),
1577
- /* @__PURE__ */ React25.createElement(
1939
+ /* @__PURE__ */ React30.createElement(
1578
1940
  "path",
1579
1941
  {
1580
1942
  d: "M15.2925 13.7925C16.024 13.3937 16.6019 12.7626 16.9349 11.999C17.2679 11.2353 17.3372 10.3824 17.1317 9.57501C16.9262 8.7676 16.4576 8.05162 15.8 7.54007C15.1424 7.02852 14.3332 6.75054 13.5 6.74999H12.555C12.328 5.87192 11.9049 5.05674 11.3175 4.36573C10.7301 3.67473 9.99364 3.12588 9.16358 2.76044C8.33352 2.39501 7.43141 2.22251 6.52509 2.2559C5.61876 2.28929 4.7318 2.52771 3.93088 2.95324C3.12997 3.37876 2.43593 3.98032 1.90097 4.71267C1.366 5.44503 1.00402 6.28914 0.842236 7.18153C0.680453 8.07393 0.72308 8.99139 0.966911 9.86493C1.21074 10.7385 1.64943 11.5454 2.25 12.225",
@@ -1583,7 +1945,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
1583
1945
  strokeLinejoin: "round"
1584
1946
  }
1585
1947
  ),
1586
- /* @__PURE__ */ React25.createElement(
1948
+ /* @__PURE__ */ React30.createElement(
1587
1949
  "path",
1588
1950
  {
1589
1951
  d: "M12 12L9 9L6 12",
@@ -1597,7 +1959,7 @@ var UploadCloud_default = UploadCloud;
1597
1959
 
1598
1960
  // src/components/Input/FileInput.tsx
1599
1961
  var FileInput = ({ text = "Upload", onUpload }) => {
1600
- const hiddenFileInput = (0, import_react19.useRef)(null);
1962
+ const hiddenFileInput = (0, import_react23.useRef)(null);
1601
1963
  const onClick = () => {
1602
1964
  if (hiddenFileInput.current) {
1603
1965
  hiddenFileInput.current.click();
@@ -1609,15 +1971,15 @@ var FileInput = ({ text = "Upload", onUpload }) => {
1609
1971
  onUpload(fileUploaded);
1610
1972
  }
1611
1973
  };
1612
- return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(
1974
+ return /* @__PURE__ */ import_react23.default.createElement(import_react23.default.Fragment, null, /* @__PURE__ */ import_react23.default.createElement(
1613
1975
  Button,
1614
1976
  {
1615
1977
  onClick,
1616
1978
  variant: "secondary" /* secondary */,
1617
- leftIcon: /* @__PURE__ */ import_react19.default.createElement(UploadCloud_default, null)
1979
+ rightIcon: /* @__PURE__ */ import_react23.default.createElement(UploadCloud_default, null)
1618
1980
  },
1619
1981
  text
1620
- ), /* @__PURE__ */ import_react19.default.createElement(
1982
+ ), /* @__PURE__ */ import_react23.default.createElement(
1621
1983
  "input",
1622
1984
  {
1623
1985
  type: "file",
@@ -1628,20 +1990,102 @@ var FileInput = ({ text = "Upload", onUpload }) => {
1628
1990
  ));
1629
1991
  };
1630
1992
 
1993
+ // src/components/MatchForm/MatchForm.tsx
1994
+ var import_react25 = __toESM(require("react"));
1995
+
1996
+ // src/components/BankTransactionRow/MatchBadge.tsx
1997
+ var import_react24 = __toESM(require("react"));
1998
+ var import_date_fns5 = require("date-fns");
1999
+ var MatchBadge = ({
2000
+ bankTransaction,
2001
+ classNamePrefix,
2002
+ dateFormat,
2003
+ text = "Match"
2004
+ }) => {
2005
+ if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction.match) {
2006
+ const { date, amount, description } = bankTransaction.match.bank_transaction;
2007
+ return /* @__PURE__ */ import_react24.default.createElement(
2008
+ Badge,
2009
+ {
2010
+ icon: /* @__PURE__ */ import_react24.default.createElement(MinimizeTwo_default, { size: 11 }),
2011
+ tooltip: /* @__PURE__ */ import_react24.default.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ import_react24.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, (0, import_date_fns5.format)((0, import_date_fns5.parseISO)(date), dateFormat)), /* @__PURE__ */ import_react24.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ import_react24.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
2012
+ },
2013
+ text
2014
+ );
2015
+ }
2016
+ return;
2017
+ };
2018
+
2019
+ // src/components/MatchForm/MatchForm.tsx
2020
+ var import_classnames11 = __toESM(require("classnames"));
2021
+ var import_date_fns6 = require("date-fns");
2022
+ var MatchForm = ({
2023
+ classNamePrefix,
2024
+ bankTransaction,
2025
+ selectedMatchId,
2026
+ setSelectedMatchId
2027
+ }) => {
2028
+ return /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__status` })), bankTransaction.suggested_matches?.map((match, idx) => {
2029
+ return /* @__PURE__ */ import_react25.default.createElement(
2030
+ "div",
2031
+ {
2032
+ key: idx,
2033
+ className: (0, import_classnames11.default)(
2034
+ `${classNamePrefix}__match-row`,
2035
+ match.id === selectedMatchId ? `${classNamePrefix}__match-row--selected` : ""
2036
+ ),
2037
+ onClick: () => {
2038
+ if (selectedMatchId === match.id) {
2039
+ setSelectedMatchId(void 0);
2040
+ return;
2041
+ }
2042
+ setSelectedMatchId(match.id);
2043
+ }
2044
+ },
2045
+ /* @__PURE__ */ import_react25.default.createElement(
2046
+ "div",
2047
+ {
2048
+ className: `Layer__nowrap ${classNamePrefix}__match-table__date`
2049
+ },
2050
+ (0, import_date_fns6.format)((0, import_date_fns6.parseISO)(match.details.date), DATE_FORMAT)
2051
+ ),
2052
+ /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ import_react25.default.createElement(
2053
+ Text,
2054
+ {
2055
+ className: `${classNamePrefix}__match-table__desc-tooltip`,
2056
+ withTooltip: "whenTruncated" /* whenTruncated */,
2057
+ as: "span"
2058
+ },
2059
+ match.details.description
2060
+ )),
2061
+ /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
2062
+ /* @__PURE__ */ import_react25.default.createElement("div", { className: `${classNamePrefix}__match-table__status` }, match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ import_react25.default.createElement(
2063
+ MatchBadge,
2064
+ {
2065
+ classNamePrefix,
2066
+ bankTransaction,
2067
+ dateFormat: DATE_FORMAT,
2068
+ text: "Matched"
2069
+ }
2070
+ ))
2071
+ );
2072
+ }));
2073
+ };
2074
+
1631
2075
  // src/components/Textarea/Textarea.tsx
1632
- var import_react20 = __toESM(require("react"));
1633
- var import_classnames7 = __toESM(require("classnames"));
2076
+ var import_react26 = __toESM(require("react"));
2077
+ var import_classnames12 = __toESM(require("classnames"));
1634
2078
  var Textarea = ({
1635
2079
  className,
1636
2080
  ...props
1637
2081
  }) => {
1638
- const baseClassName = (0, import_classnames7.default)("Layer__textarea", className);
1639
- return /* @__PURE__ */ import_react20.default.createElement("textarea", { ...props, className: baseClassName });
2082
+ const baseClassName = (0, import_classnames12.default)("Layer__textarea", className);
2083
+ return /* @__PURE__ */ import_react26.default.createElement("textarea", { ...props, className: baseClassName });
1640
2084
  };
1641
2085
 
1642
2086
  // src/components/Toggle/Toggle.tsx
1643
- var import_react21 = __toESM(require("react"));
1644
- var import_classnames8 = __toESM(require("classnames"));
2087
+ var import_react27 = __toESM(require("react"));
2088
+ var import_classnames13 = __toESM(require("classnames"));
1645
2089
  var Toggle = ({
1646
2090
  name,
1647
2091
  options,
@@ -1649,16 +2093,16 @@ var Toggle = ({
1649
2093
  onChange,
1650
2094
  size = "medium" /* medium */
1651
2095
  }) => {
1652
- const [currentWidth, setCurrentWidth] = (0, import_react21.useState)(0);
1653
- const [thumbPos, setThumbPos] = (0, import_react21.useState)({ left: 0, width: 0 });
1654
- const [initialized, setInitialized] = (0, import_react21.useState)(false);
2096
+ const [currentWidth, setCurrentWidth] = (0, import_react27.useState)(0);
2097
+ const [thumbPos, setThumbPos] = (0, import_react27.useState)({ left: 0, width: 0 });
2098
+ const [initialized, setInitialized] = (0, import_react27.useState)(false);
1655
2099
  const toggleRef = useElementSize((a, b, c) => {
1656
2100
  if (c.width && c?.width !== currentWidth) {
1657
2101
  setCurrentWidth(c.width);
1658
2102
  }
1659
2103
  });
1660
2104
  const selectedValue = selected || options[0].value;
1661
- const baseClassName = (0, import_classnames8.default)(
2105
+ const baseClassName = (0, import_classnames13.default)(
1662
2106
  "Layer__toggle",
1663
2107
  `Layer__toggle--${size}`,
1664
2108
  initialized ? "Layer__toggle--initialized" : ""
@@ -1683,17 +2127,17 @@ var Toggle = ({
1683
2127
  width = c.offsetWidth;
1684
2128
  }
1685
2129
  });
1686
- shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1);
2130
+ shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
1687
2131
  setThumbPos({ left: shift2, width });
1688
2132
  };
1689
- (0, import_react21.useEffect)(() => {
2133
+ (0, import_react27.useEffect)(() => {
1690
2134
  const selectedIndex = getSelectedIndex();
1691
2135
  updateThumbPosition(selectedIndex);
1692
2136
  setTimeout(() => {
1693
2137
  setInitialized(true);
1694
2138
  }, 400);
1695
2139
  }, []);
1696
- (0, import_react21.useEffect)(() => {
2140
+ (0, import_react27.useEffect)(() => {
1697
2141
  const selectedIndex = getSelectedIndex();
1698
2142
  updateThumbPosition(selectedIndex);
1699
2143
  }, [currentWidth]);
@@ -1706,7 +2150,7 @@ var Toggle = ({
1706
2150
  }
1707
2151
  return selectedIndex;
1708
2152
  };
1709
- return /* @__PURE__ */ import_react21.default.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ import_react21.default.createElement(
2153
+ return /* @__PURE__ */ import_react27.default.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ import_react27.default.createElement(
1710
2154
  ToggleOption,
1711
2155
  {
1712
2156
  ...option,
@@ -1718,7 +2162,7 @@ var Toggle = ({
1718
2162
  disabled: option.disabled ?? false,
1719
2163
  index
1720
2164
  }
1721
- )), /* @__PURE__ */ import_react21.default.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
2165
+ )), /* @__PURE__ */ import_react27.default.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
1722
2166
  };
1723
2167
  var ToggleOption = ({
1724
2168
  checked,
@@ -1731,7 +2175,7 @@ var ToggleOption = ({
1731
2175
  disabled,
1732
2176
  index
1733
2177
  }) => {
1734
- return /* @__PURE__ */ import_react21.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react21.default.createElement(
2178
+ return /* @__PURE__ */ import_react27.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react27.default.createElement(
1735
2179
  "input",
1736
2180
  {
1737
2181
  type: "radio",
@@ -1742,22 +2186,55 @@ var ToggleOption = ({
1742
2186
  disabled: disabled ?? false,
1743
2187
  "data-idx": index
1744
2188
  }
1745
- ), /* @__PURE__ */ import_react21.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react21.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react21.default.createElement("span", null, label)));
2189
+ ), /* @__PURE__ */ import_react27.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react27.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react27.default.createElement("span", null, label)));
1746
2190
  };
1747
2191
 
1748
2192
  // src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
1749
- var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
2193
+ var import_classnames14 = __toESM(require("classnames"));
2194
+ var hasMatch = (bankTransaction) => {
2195
+ return Boolean(
2196
+ bankTransaction?.suggested_matches && bankTransaction?.suggested_matches?.length > 0 || bankTransaction?.match
2197
+ );
2198
+ };
2199
+ var isAlreadyMatched = (bankTransaction) => {
2200
+ if (bankTransaction?.match) {
2201
+ const foundMatch = bankTransaction.suggested_matches?.find(
2202
+ (x) => x.details.id === bankTransaction?.match?.details.id
2203
+ );
2204
+ return foundMatch?.id;
2205
+ }
2206
+ return void 0;
2207
+ };
2208
+ var ExpandedBankTransactionRow = (0, import_react28.forwardRef)(
1750
2209
  ({
1751
2210
  bankTransaction,
1752
2211
  isOpen = false,
1753
2212
  asListItem = false,
1754
2213
  submitBtnText = "Save"
1755
2214
  }, ref) => {
1756
- const { categorize: categorizeBankTransaction2 } = useBankTransactions();
1757
- const [purpose, setPurpose] = (0, import_react22.useState)("categorize" /* categorize */);
2215
+ const {
2216
+ categorize: categorizeBankTransaction2,
2217
+ match: matchBankTransaction2
2218
+ } = useBankTransactions();
2219
+ const [purpose, setPurpose] = (0, import_react28.useState)(
2220
+ bankTransaction.category ? "categorize" /* categorize */ : hasMatch(bankTransaction) ? "match" /* match */ : "categorize" /* categorize */
2221
+ );
2222
+ const [selectedMatchId, setSelectedMatchId] = (0, import_react28.useState)(
2223
+ isAlreadyMatched(bankTransaction)
2224
+ );
2225
+ const [height, setHeight] = (0, import_react28.useState)(0);
2226
+ const [isOver, setOver] = (0, import_react28.useState)(false);
2227
+ const bodyRef = (0, import_react28.useRef)(null);
2228
+ const [isLoaded, setIsLoaded] = (0, import_react28.useState)(false);
1758
2229
  const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
1759
- const [rowState, updateRowState] = (0, import_react22.useState)({
1760
- splits: [
2230
+ const [rowState, updateRowState] = (0, import_react28.useState)({
2231
+ splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
2232
+ return {
2233
+ amount: c.amount || 0,
2234
+ inputValue: centsToDollars(c.amount),
2235
+ category: c.category
2236
+ };
2237
+ }) : [
1761
2238
  {
1762
2239
  amount: bankTransaction.amount,
1763
2240
  inputValue: centsToDollars(bankTransaction.amount),
@@ -1774,22 +2251,32 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1774
2251
  { amount: 0, inputValue: "0.00", category: defaultCategory }
1775
2252
  ]
1776
2253
  });
1777
- const removeSplit = () => updateRowState({
1778
- ...rowState,
1779
- splits: rowState.splits.slice(0, -1)
1780
- });
2254
+ const removeSplit = (index) => {
2255
+ const newSplits = rowState.splits.filter((_v, idx) => idx !== index);
2256
+ const splitTotal = newSplits.reduce((sum, split, index2) => {
2257
+ const amount = index2 === 0 ? 0 : split.amount;
2258
+ return sum + amount;
2259
+ }, 0);
2260
+ const remaining = bankTransaction.amount - splitTotal;
2261
+ newSplits[0].amount = remaining;
2262
+ newSplits[0].inputValue = centsToDollars(remaining);
2263
+ updateRowState({
2264
+ ...rowState,
2265
+ splits: newSplits
2266
+ });
2267
+ };
1781
2268
  const updateAmounts = (rowNumber) => (event) => {
1782
2269
  const newAmount = dollarsToCents(event.target.value) || 0;
1783
2270
  const newDisplaying = event.target.value;
1784
- const splitTotal = rowState.splits.slice(0, -1).reduce((sum, split, index) => {
1785
- const amount = index === rowNumber ? newAmount : split.amount;
2271
+ const splitTotal = rowState.splits.reduce((sum, split, index) => {
2272
+ const amount = index === 0 ? 0 : index === rowNumber ? newAmount : split.amount;
1786
2273
  return sum + amount;
1787
2274
  }, 0);
1788
2275
  const remaining = bankTransaction.amount - splitTotal;
1789
2276
  rowState.splits[rowNumber].amount = newAmount;
1790
2277
  rowState.splits[rowNumber].inputValue = newDisplaying;
1791
- rowState.splits[rowState.splits.length - 1].amount = remaining;
1792
- rowState.splits[rowState.splits.length - 1].inputValue = centsToDollars(remaining);
2278
+ rowState.splits[0].amount = remaining;
2279
+ rowState.splits[0].inputValue = centsToDollars(remaining);
1793
2280
  updateRowState({ ...rowState });
1794
2281
  };
1795
2282
  const onBlur = (event) => {
@@ -1806,32 +2293,83 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1806
2293
  rowState.splits[index].category = newValue;
1807
2294
  updateRowState({ ...rowState });
1808
2295
  };
1809
- const save = () => categorizeBankTransaction2(
1810
- bankTransaction.id,
1811
- rowState.splits.length === 1 ? {
1812
- type: "Category",
1813
- category: {
1814
- type: "StableName",
1815
- stable_name: rowState?.splits[0].category?.stable_name || rowState?.splits[0].category?.category
2296
+ const save = () => {
2297
+ if (purpose === "match" /* match */) {
2298
+ if (selectedMatchId && selectedMatchId !== isAlreadyMatched(bankTransaction)) {
2299
+ onMatchSubmit(selectedMatchId);
1816
2300
  }
1817
- } : {
1818
- type: "Split",
1819
- entries: rowState.splits.map((split) => ({
1820
- category: split.category?.stable_name || split.category?.category,
1821
- amount: split.amount
1822
- }))
2301
+ return;
1823
2302
  }
1824
- ).catch((e) => console.error(e));
1825
- (0, import_react22.useImperativeHandle)(ref, () => ({
2303
+ categorizeBankTransaction2(
2304
+ bankTransaction.id,
2305
+ rowState.splits.length === 1 ? {
2306
+ type: "Category",
2307
+ category: {
2308
+ type: "StableName",
2309
+ stable_name: rowState?.splits[0].category?.stable_name || rowState?.splits[0].category?.category
2310
+ }
2311
+ } : {
2312
+ type: "Split",
2313
+ entries: rowState.splits.map((split) => ({
2314
+ category: split.category?.stable_name || split.category?.category,
2315
+ amount: split.amount
2316
+ }))
2317
+ }
2318
+ ).catch((e) => console.error(e));
2319
+ };
2320
+ (0, import_react28.useImperativeHandle)(ref, () => ({
1826
2321
  save
1827
2322
  }));
2323
+ const onMatchSubmit = (matchId) => {
2324
+ const foundMatch = bankTransaction.suggested_matches?.find(
2325
+ (x) => x.id === matchId
2326
+ );
2327
+ if (!foundMatch) {
2328
+ return;
2329
+ }
2330
+ matchBankTransaction2(bankTransaction.id, foundMatch.id);
2331
+ };
2332
+ const getDivHeight = (0, import_react28.useCallback)(() => {
2333
+ const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
2334
+ return height2 || 0;
2335
+ }, []);
2336
+ const handleTransitionEnd = (0, import_react28.useCallback)(
2337
+ (e) => {
2338
+ if (e.propertyName === "height") {
2339
+ setHeight(isOpen ? "auto" : 0);
2340
+ if (!isOpen) {
2341
+ setOver(true);
2342
+ }
2343
+ }
2344
+ },
2345
+ [isOpen]
2346
+ );
2347
+ (0, import_react28.useEffect)(() => {
2348
+ if (!isLoaded) {
2349
+ return;
2350
+ }
2351
+ setHeight(getDivHeight());
2352
+ setOver(false);
2353
+ if (!isOpen) {
2354
+ requestAnimationFrame(() => {
2355
+ requestAnimationFrame(() => setHeight(0));
2356
+ });
2357
+ }
2358
+ }, [getDivHeight, isOpen]);
2359
+ (0, import_react28.useEffect)(() => {
2360
+ setIsLoaded(true);
2361
+ setOver(true);
2362
+ }, []);
1828
2363
  const className = "Layer__expanded-bank-transaction-row";
1829
- return /* @__PURE__ */ import_react22.default.createElement(
2364
+ const shouldHide = !isOpen && isOver;
2365
+ return /* @__PURE__ */ import_react28.default.createElement(
1830
2366
  "span",
1831
2367
  {
1832
- className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`
2368
+ className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
2369
+ style: { height },
2370
+ onTransitionEnd: handleTransitionEnd
1833
2371
  },
1834
- /* @__PURE__ */ import_react22.default.createElement("span", { className: `${className}__wrapper` }, /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ import_react22.default.createElement(
2372
+ shouldHide ? null : /* @__PURE__ */ import_react28.default.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ import_react28.default.createElement(
1835
2373
  Toggle,
1836
2374
  {
1837
2375
  name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
@@ -1839,81 +2377,129 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1839
2377
  options: [
1840
2378
  {
1841
2379
  value: "categorize",
1842
- label: "Categorize",
1843
- leftIcon: /* @__PURE__ */ import_react22.default.createElement(FolderPlus_default, { size: 15 })
2380
+ label: "Categorize"
1844
2381
  },
1845
2382
  {
1846
2383
  value: "match",
1847
2384
  label: "Match",
1848
- disabled: true,
1849
- leftIcon: /* @__PURE__ */ import_react22.default.createElement(RefreshCcw_default, { size: 15 })
2385
+ disabled: !hasMatch(bankTransaction)
1850
2386
  }
1851
2387
  ],
1852
2388
  selected: purpose,
1853
2389
  onChange: onChangePurpose
1854
2390
  }
1855
- )), /* @__PURE__ */ import_react22.default.createElement(
2391
+ )), /* @__PURE__ */ import_react28.default.createElement(
1856
2392
  "div",
1857
2393
  {
1858
2394
  className: `${className}__content`,
1859
2395
  id: `expanded-${bankTransaction.id}`
1860
2396
  },
1861
- /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__splits` }, /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ import_react22.default.createElement(
2397
+ /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ import_react28.default.createElement(
1862
2398
  "div",
1863
2399
  {
1864
- className: `${className}__table-cell--split-entry`,
1865
- key: `split-${index}`
2400
+ className: (0, import_classnames14.default)(
2401
+ `${className}__match`,
2402
+ `${className}__content-panel`,
2403
+ purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
2404
+ )
1866
2405
  },
1867
- rowState.splits.length > 1 && /* @__PURE__ */ import_react22.default.createElement(
1868
- Input,
1869
- {
1870
- type: "text",
1871
- name: `split-${index}${asListItem ? "-li" : ""}`,
1872
- disabled: index + 1 === rowState.splits.length,
1873
- onChange: updateAmounts(index),
1874
- value: split.inputValue,
1875
- onBlur,
1876
- className: `${className}__split-amount${split.amount < 0 ? "--negative" : ""}`
1877
- }
1878
- ),
1879
- /* @__PURE__ */ import_react22.default.createElement(
1880
- CategoryMenu,
2406
+ /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react28.default.createElement(
2407
+ MatchForm,
1881
2408
  {
2409
+ classNamePrefix: className,
1882
2410
  bankTransaction,
1883
- name: `category-${index}${asListItem ? "-li" : ""}`,
1884
- value: split.category,
1885
- onChange: (value) => changeCategory(index, value),
1886
- className: "Layer__category-menu--full"
2411
+ selectedMatchId,
2412
+ setSelectedMatchId
1887
2413
  }
1888
- )
1889
- ))), /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length === 1 ? /* @__PURE__ */ import_react22.default.createElement(
1890
- Button,
1891
- {
1892
- onClick: addSplit,
1893
- leftIcon: /* @__PURE__ */ import_react22.default.createElement(Scissors_default, { size: 14 }),
1894
- variant: "secondary" /* secondary */
1895
- },
1896
- "Split"
1897
- ) : /* @__PURE__ */ import_react22.default.createElement(
1898
- Button,
2414
+ ))
2415
+ ), /* @__PURE__ */ import_react28.default.createElement(
2416
+ "div",
1899
2417
  {
1900
- onClick: removeSplit,
1901
- leftIcon: /* @__PURE__ */ import_react22.default.createElement(Link_default, { size: 14 }),
1902
- variant: "secondary" /* secondary */
2418
+ className: (0, import_classnames14.default)(
2419
+ `${className}__splits`,
2420
+ `${className}__content-panel`,
2421
+ purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
2422
+ )
1903
2423
  },
1904
- "Merge"
1905
- ))),
1906
- /* @__PURE__ */ import_react22.default.createElement(
2424
+ /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ import_react28.default.createElement(
2425
+ "div",
2426
+ {
2427
+ className: `${className}__table-cell--split-entry`,
2428
+ key: `split-${index}`
2429
+ },
2430
+ /* @__PURE__ */ import_react28.default.createElement(
2431
+ Input,
2432
+ {
2433
+ type: "text",
2434
+ name: `split-${index}${asListItem ? "-li" : ""}`,
2435
+ disabled: index === 0,
2436
+ onChange: updateAmounts(index),
2437
+ value: split.inputValue,
2438
+ onBlur,
2439
+ isInvalid: split.amount < 0,
2440
+ errorMessage: "Negative values are not allowed"
2441
+ }
2442
+ ),
2443
+ /* @__PURE__ */ import_react28.default.createElement(
2444
+ CategoryMenu,
2445
+ {
2446
+ bankTransaction,
2447
+ name: `category-${index}${asListItem ? "-li" : ""}`,
2448
+ value: split.category,
2449
+ onChange: (value) => changeCategory(index, value),
2450
+ className: "Layer__category-menu--full"
2451
+ }
2452
+ ),
2453
+ index > 0 && /* @__PURE__ */ import_react28.default.createElement(
2454
+ Button,
2455
+ {
2456
+ onClick: () => removeSplit(index),
2457
+ rightIcon: /* @__PURE__ */ import_react28.default.createElement(Link_default, { size: 14 }),
2458
+ variant: "secondary" /* secondary */
2459
+ },
2460
+ "Merge"
2461
+ )
2462
+ ))), /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ import_react28.default.createElement(
2463
+ TextButton,
2464
+ {
2465
+ onClick: addSplit,
2466
+ disabled: rowState.splits.length > 5
2467
+ },
2468
+ "Add new split"
2469
+ ) : /* @__PURE__ */ import_react28.default.createElement(
2470
+ Button,
2471
+ {
2472
+ onClick: addSplit,
2473
+ rightIcon: /* @__PURE__ */ import_react28.default.createElement(Scissors_default, { size: 14 }),
2474
+ variant: "secondary" /* secondary */,
2475
+ disabled: rowState.splits.length > 5
2476
+ },
2477
+ "Split"
2478
+ )), rowState.splits.length > 1 && /* @__PURE__ */ import_react28.default.createElement(
2479
+ Text,
2480
+ {
2481
+ size: "sm" /* sm */,
2482
+ className: `${className}__splits-total`
2483
+ },
2484
+ "Total: $",
2485
+ centsToDollars(
2486
+ rowState.splits.reduce(
2487
+ (x, { amount }) => x + amount,
2488
+ 0
2489
+ )
2490
+ )
2491
+ ))
2492
+ )),
2493
+ /* @__PURE__ */ import_react28.default.createElement(
1907
2494
  InputGroup,
1908
2495
  {
1909
2496
  className: `${className}__description`,
1910
- name: "description",
1911
- label: "Description"
2497
+ name: "description"
1912
2498
  },
1913
- /* @__PURE__ */ import_react22.default.createElement(Textarea, { name: "description", placeholder: "Enter description" })
2499
+ /* @__PURE__ */ import_react28.default.createElement(Textarea, { name: "description", placeholder: "Add description" })
1914
2500
  ),
1915
- /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react22.default.createElement(FileInput, { text: "Upload receipt" })),
1916
- asListItem ? /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react22.default.createElement(
2501
+ /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react28.default.createElement(FileInput, { text: "Upload receipt" })),
2502
+ asListItem ? /* @__PURE__ */ import_react28.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react28.default.createElement(
1917
2503
  SubmitButton,
1918
2504
  {
1919
2505
  onClick: () => {
@@ -1933,134 +2519,62 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1933
2519
  }
1934
2520
  );
1935
2521
 
1936
- // src/components/Pill/Pill.tsx
1937
- var import_react23 = __toESM(require("react"));
1938
- var Pill = ({ children }) => /* @__PURE__ */ import_react23.default.createElement("span", { className: "Layer__pill" }, children);
1939
-
1940
- // src/components/BankTransactionListItem/BankTransactionListItem.tsx
1941
- var import_classnames9 = __toESM(require("classnames"));
1942
- var import_date_fns4 = require("date-fns");
1943
- var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
1944
- var BankTransactionListItem = ({
1945
- dateFormat: dateFormat2,
1946
- bankTransaction,
1947
- isOpen,
1948
- toggleOpen,
1949
- editable
2522
+ // src/components/BankTransactionRow/SplitTooltipDetails.tsx
2523
+ var import_react29 = __toESM(require("react"));
2524
+ var SplitTooltipDetails = ({
2525
+ classNamePrefix,
2526
+ category
1950
2527
  }) => {
1951
- const expandedRowRef = (0, import_react24.useRef)(null);
1952
- const [removed, setRemoved] = (0, import_react24.useState)(false);
1953
- const { categorize: categorizeBankTransaction2 } = useBankTransactions();
1954
- const [selectedCategory, setSelectedCategory] = (0, import_react24.useState)(
1955
- hasSuggestions(bankTransaction.categorization_flow) ? bankTransaction.categorization_flow.suggestions[0] : void 0
1956
- );
1957
- const save = () => {
1958
- if (isOpen && expandedRowRef?.current) {
1959
- expandedRowRef?.current?.save();
1960
- toggleOpen(bankTransaction.id);
1961
- return;
1962
- }
1963
- categorizeBankTransaction2(bankTransaction.id, {
1964
- type: "Category",
1965
- category: {
1966
- type: "StableName",
1967
- stable_name: selectedCategory?.stable_name || selectedCategory?.category || ""
1968
- }
1969
- });
1970
- };
1971
- if (removed) {
1972
- return null;
2528
+ if (!category.entries) {
2529
+ return;
1973
2530
  }
1974
- const className = "Layer__bank-transaction-list-item";
1975
- const openClassName = isOpen ? `${className}--expanded` : "";
1976
- const rowClassName = (0, import_classnames9.default)(
1977
- className,
1978
- bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
1979
- isOpen ? openClassName : ""
1980
- );
1981
- return /* @__PURE__ */ import_react24.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__heading-date` }, (0, import_date_fns4.format)((0, import_date_fns4.parseISO)(bankTransaction.date), dateFormat2)), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__body__name` }, bankTransaction.counterparty_name), /* @__PURE__ */ import_react24.default.createElement(
1982
- "span",
1983
- {
1984
- className: `${className}__amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
1985
- },
1986
- isCredit(bankTransaction) ? "+$" : " $",
1987
- centsToDollars(bankTransaction.amount)
1988
- ), /* @__PURE__ */ import_react24.default.createElement(
1989
- "div",
1990
- {
1991
- onClick: () => toggleOpen(bankTransaction.id),
1992
- className: "Layer__bank-transaction-row__expand-button"
1993
- },
1994
- /* @__PURE__ */ import_react24.default.createElement(
1995
- ChevronDown_default,
1996
- {
1997
- className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
1998
- }
1999
- )
2000
- )), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ import_react24.default.createElement(
2001
- ExpandedBankTransactionRow,
2002
- {
2003
- ref: expandedRowRef,
2004
- bankTransaction,
2005
- close: () => toggleOpen(bankTransaction.id),
2006
- isOpen,
2007
- asListItem: true,
2008
- submitBtnText: editable ? "Approve" : "Save"
2009
- }
2010
- )), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react24.default.createElement(
2011
- CategoryMenu,
2012
- {
2013
- bankTransaction,
2014
- name: `category-${bankTransaction.id}`,
2015
- value: selectedCategory,
2016
- onChange: setSelectedCategory,
2017
- disabled: bankTransaction.processing
2018
- }
2019
- ) : null, !editable ? /* @__PURE__ */ import_react24.default.createElement(Pill, null, bankTransaction?.category?.display_name) : null, editable && /* @__PURE__ */ import_react24.default.createElement(
2020
- SubmitButton,
2021
- {
2022
- onClick: () => {
2023
- if (!bankTransaction.processing) {
2024
- save();
2025
- }
2026
- },
2027
- className: "Layer__bank-transaction__submit-btn",
2028
- processing: bankTransaction.processing,
2029
- error: bankTransaction.error,
2030
- iconOnly: true
2031
- }
2032
- )));
2531
+ return /* @__PURE__ */ import_react29.default.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ import_react29.default.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ import_react29.default.createElement("li", { key: idx }, /* @__PURE__ */ import_react29.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ import_react29.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
2033
2532
  };
2034
2533
 
2035
2534
  // src/components/BankTransactionRow/BankTransactionRow.tsx
2036
- var import_react25 = __toESM(require("react"));
2037
- var import_classnames10 = __toESM(require("classnames"));
2038
- var import_date_fns5 = require("date-fns");
2039
- var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
2535
+ var import_classnames15 = __toESM(require("classnames"));
2536
+ var import_date_fns7 = require("date-fns");
2537
+ var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
2538
+ var extractDescriptionForSplit = (category) => {
2539
+ if (!category.entries) {
2540
+ return "";
2541
+ }
2542
+ return category.entries.map((c) => c.category.display_name).join(", ");
2543
+ };
2544
+ var getDefaultSelectedCategory = (bankTransaction) => {
2545
+ return hasSuggestions(bankTransaction.categorization_flow) ? mapCategoryToOption(bankTransaction.categorization_flow.suggestions[0]) : bankTransaction.suggested_matches?.length === 1 ? mapSuggestedMatchToOption(bankTransaction.suggested_matches[0]) : void 0;
2546
+ };
2040
2547
  var BankTransactionRow = ({
2041
- dateFormat: dateFormat2,
2548
+ dateFormat,
2042
2549
  bankTransaction,
2043
- isOpen,
2044
- toggleOpen,
2045
2550
  editable
2046
2551
  }) => {
2047
- const expandedRowRef = (0, import_react25.useRef)(null);
2048
- const [removed, setRemoved] = (0, import_react25.useState)(false);
2049
- const { categorize: categorizeBankTransaction2 } = useBankTransactions();
2050
- const [selectedCategory, setSelectedCategory] = (0, import_react25.useState)(
2051
- hasSuggestions(bankTransaction.categorization_flow) ? bankTransaction.categorization_flow.suggestions[0] : void 0
2552
+ const expandedRowRef = (0, import_react30.useRef)(null);
2553
+ const [removed, setRemoved] = (0, import_react30.useState)(false);
2554
+ const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
2555
+ const [selectedCategory, setSelectedCategory] = (0, import_react30.useState)(
2556
+ getDefaultSelectedCategory(bankTransaction)
2052
2557
  );
2558
+ const [open, setOpen] = (0, import_react30.useState)(false);
2559
+ const toggleOpen = () => setOpen(!open);
2053
2560
  const save = () => {
2054
- if (isOpen && expandedRowRef?.current) {
2561
+ if (open && expandedRowRef?.current) {
2055
2562
  expandedRowRef?.current?.save();
2056
- toggleOpen(bankTransaction.id);
2563
+ setOpen(false);
2564
+ return;
2565
+ }
2566
+ if (!selectedCategory) {
2567
+ return;
2568
+ }
2569
+ if (selectedCategory.type === "match") {
2570
+ matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
2057
2571
  return;
2058
2572
  }
2059
2573
  categorizeBankTransaction2(bankTransaction.id, {
2060
2574
  type: "Category",
2061
2575
  category: {
2062
2576
  type: "StableName",
2063
- stable_name: selectedCategory?.stable_name || selectedCategory?.category || ""
2577
+ stable_name: selectedCategory?.payload.stable_name || ""
2064
2578
  }
2065
2579
  });
2066
2580
  };
@@ -2068,13 +2582,13 @@ var BankTransactionRow = ({
2068
2582
  return null;
2069
2583
  }
2070
2584
  const className = "Layer__bank-transaction-row";
2071
- const openClassName = isOpen ? `${className}--expanded` : "";
2072
- const rowClassName = (0, import_classnames10.default)(
2585
+ const openClassName = open ? `${className}--expanded` : "";
2586
+ const rowClassName = (0, import_classnames15.default)(
2073
2587
  className,
2074
2588
  bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
2075
- isOpen ? openClassName : ""
2589
+ open ? openClassName : ""
2076
2590
  );
2077
- return /* @__PURE__ */ import_react25.default.createElement(import_react25.default.Fragment, null, /* @__PURE__ */ import_react25.default.createElement(
2591
+ return /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, /* @__PURE__ */ import_react30.default.createElement(
2078
2592
  "tr",
2079
2593
  {
2080
2594
  className: rowClassName,
@@ -2084,8 +2598,8 @@ var BankTransactionRow = ({
2084
2598
  }
2085
2599
  }
2086
2600
  },
2087
- /* @__PURE__ */ import_react25.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react25.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns5.format)((0, import_date_fns5.parseISO)(bankTransaction.date), dateFormat2))),
2088
- /* @__PURE__ */ import_react25.default.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__tx-col" }, /* @__PURE__ */ import_react25.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react25.default.createElement(
2601
+ /* @__PURE__ */ import_react30.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns7.format)((0, import_date_fns7.parseISO)(bankTransaction.date), dateFormat))),
2602
+ /* @__PURE__ */ import_react30.default.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__tx-col" }, /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react30.default.createElement(
2089
2603
  Text,
2090
2604
  {
2091
2605
  as: "span",
@@ -2097,7 +2611,7 @@ var BankTransactionRow = ({
2097
2611
  },
2098
2612
  bankTransaction.counterparty_name ?? bankTransaction.description
2099
2613
  ))),
2100
- /* @__PURE__ */ import_react25.default.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__account-col" }, /* @__PURE__ */ import_react25.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react25.default.createElement(
2614
+ /* @__PURE__ */ import_react30.default.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__account-col" }, /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react30.default.createElement(
2101
2615
  Text,
2102
2616
  {
2103
2617
  as: "span",
@@ -2106,82 +2620,265 @@ var BankTransactionRow = ({
2106
2620
  },
2107
2621
  bankTransaction.account_name ?? ""
2108
2622
  ))),
2109
- /* @__PURE__ */ import_react25.default.createElement(
2623
+ /* @__PURE__ */ import_react30.default.createElement(
2110
2624
  "td",
2111
2625
  {
2112
- className: `Layer__table-cell Layer__table-cell__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
2626
+ className: `Layer__table-cell Layer__table-cell__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
2113
2627
  },
2114
- /* @__PURE__ */ import_react25.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit2(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
2628
+ /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
2115
2629
  ),
2116
- /* @__PURE__ */ import_react25.default.createElement(
2630
+ /* @__PURE__ */ import_react30.default.createElement(
2117
2631
  "td",
2118
2632
  {
2119
- className: (0, import_classnames10.default)(
2120
- "Layer__table-cell",
2121
- "Layer__table-cell__category-col",
2122
- `${className}__actions-cell`,
2123
- `${className}__actions-cell--${isOpen ? "open" : "close"}`
2124
- )
2125
- },
2126
- /* @__PURE__ */ import_react25.default.createElement(
2127
- "span",
2128
- {
2129
- className: `${className}__actions-container Layer__table-cell-content`
2130
- },
2131
- editable && !isOpen ? /* @__PURE__ */ import_react25.default.createElement(
2132
- CategoryMenu,
2133
- {
2134
- bankTransaction,
2135
- name: `category-${bankTransaction.id}`,
2136
- value: selectedCategory,
2137
- onChange: setSelectedCategory,
2138
- disabled: bankTransaction.processing
2139
- }
2140
- ) : null,
2141
- !editable && !isOpen ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
2142
- editable || isOpen ? /* @__PURE__ */ import_react25.default.createElement(
2143
- SubmitButton,
2144
- {
2145
- onClick: () => {
2146
- if (!bankTransaction.processing) {
2147
- save();
2148
- }
2149
- },
2150
- className: "Layer__bank-transaction__submit-btn",
2151
- processing: bankTransaction.processing,
2152
- error: bankTransaction.error,
2153
- active: isOpen
2154
- },
2155
- editable ? "Approve" : "Save"
2156
- ) : null,
2157
- /* @__PURE__ */ import_react25.default.createElement(
2158
- "div",
2159
- {
2160
- onClick: () => toggleOpen(bankTransaction.id),
2161
- className: "Layer__bank-transaction-row__expand-button"
2162
- },
2163
- /* @__PURE__ */ import_react25.default.createElement(
2164
- ChevronDown_default,
2165
- {
2166
- className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
2167
- }
2168
- )
2169
- )
2170
- )
2633
+ className: (0, import_classnames15.default)(
2634
+ "Layer__table-cell",
2635
+ "Layer__table-cell__category-col",
2636
+ `${className}__actions-cell`,
2637
+ `${className}__actions-cell--${open ? "open" : "close"}`
2638
+ )
2639
+ },
2640
+ /* @__PURE__ */ import_react30.default.createElement(
2641
+ "span",
2642
+ {
2643
+ className: `${className}__actions-container Layer__table-cell-content`
2644
+ },
2645
+ editable && !open ? /* @__PURE__ */ import_react30.default.createElement(
2646
+ CategorySelect,
2647
+ {
2648
+ bankTransaction,
2649
+ name: `category-${bankTransaction.id}`,
2650
+ value: selectedCategory,
2651
+ onChange: setSelectedCategory,
2652
+ disabled: bankTransaction.processing
2653
+ }
2654
+ ) : null,
2655
+ !editable && !open ? /* @__PURE__ */ import_react30.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, /* @__PURE__ */ import_react30.default.createElement(
2656
+ Badge,
2657
+ {
2658
+ icon: /* @__PURE__ */ import_react30.default.createElement(Scissors_default, { size: 11 }),
2659
+ tooltip: /* @__PURE__ */ import_react30.default.createElement(
2660
+ SplitTooltipDetails,
2661
+ {
2662
+ classNamePrefix: className,
2663
+ category: bankTransaction.category
2664
+ }
2665
+ )
2666
+ },
2667
+ "Split"
2668
+ ), /* @__PURE__ */ import_react30.default.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, /* @__PURE__ */ import_react30.default.createElement(
2669
+ MatchBadge,
2670
+ {
2671
+ classNamePrefix: className,
2672
+ bankTransaction,
2673
+ dateFormat
2674
+ }
2675
+ ), /* @__PURE__ */ import_react30.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns7.format)(
2676
+ (0, import_date_fns7.parseISO)(bankTransaction.match.bank_transaction.date),
2677
+ dateFormat
2678
+ )}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react30.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
2679
+ editable || open ? /* @__PURE__ */ import_react30.default.createElement(
2680
+ SubmitButton,
2681
+ {
2682
+ onClick: () => {
2683
+ if (!bankTransaction.processing) {
2684
+ save();
2685
+ }
2686
+ },
2687
+ className: "Layer__bank-transaction__submit-btn",
2688
+ processing: bankTransaction.processing,
2689
+ error: bankTransaction.error,
2690
+ active: open,
2691
+ action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
2692
+ },
2693
+ editable ? "Approve" : "Update"
2694
+ ) : null,
2695
+ /* @__PURE__ */ import_react30.default.createElement(
2696
+ IconButton,
2697
+ {
2698
+ onClick: toggleOpen,
2699
+ className: "Layer__bank-transaction-row__expand-button",
2700
+ active: open,
2701
+ icon: open ? /* @__PURE__ */ import_react30.default.createElement(X_default, null) : /* @__PURE__ */ import_react30.default.createElement(ChevronDown_default, { className: "Layer__chevron Layer__chevron__down" })
2702
+ }
2703
+ )
2704
+ )
2705
+ )
2706
+ ), /* @__PURE__ */ import_react30.default.createElement("tr", null, /* @__PURE__ */ import_react30.default.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ import_react30.default.createElement(
2707
+ ExpandedBankTransactionRow,
2708
+ {
2709
+ ref: expandedRowRef,
2710
+ bankTransaction,
2711
+ isOpen: open
2712
+ }
2713
+ ))));
2714
+ };
2715
+
2716
+ // src/components/BankTransactionListItem/Assignment.tsx
2717
+ var import_react31 = __toESM(require("react"));
2718
+ var import_date_fns8 = require("date-fns");
2719
+ var Assignment = ({ bankTransaction }) => {
2720
+ if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
2721
+ return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement(
2722
+ MatchBadge,
2723
+ {
2724
+ classNamePrefix: "Layer__bank-transaction-list-item",
2725
+ bankTransaction,
2726
+ dateFormat: DATE_FORMAT,
2727
+ text: "Matched"
2728
+ }
2729
+ ), /* @__PURE__ */ import_react31.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${(0, import_date_fns8.format)(
2730
+ (0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
2731
+ DATE_FORMAT
2732
+ )}, ${bankTransaction.match.bank_transaction.description}`));
2733
+ }
2734
+ if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
2735
+ return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement(
2736
+ Badge,
2737
+ {
2738
+ icon: /* @__PURE__ */ import_react31.default.createElement(Scissors_default, { size: 11 }),
2739
+ tooltip: /* @__PURE__ */ import_react31.default.createElement(
2740
+ SplitTooltipDetails,
2741
+ {
2742
+ classNamePrefix: "Layer__bank-transaction-list-item",
2743
+ category: bankTransaction.category
2744
+ }
2745
+ )
2746
+ },
2747
+ "Split"
2748
+ ), /* @__PURE__ */ import_react31.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
2749
+ }
2750
+ return /* @__PURE__ */ import_react31.default.createElement(Text, null, bankTransaction?.category?.display_name);
2751
+ };
2752
+
2753
+ // src/components/BankTransactionListItem/BankTransactionListItem.tsx
2754
+ var import_classnames16 = __toESM(require("classnames"));
2755
+ var import_date_fns9 = require("date-fns");
2756
+ var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
2757
+ var BankTransactionListItem = ({
2758
+ dateFormat,
2759
+ bankTransaction,
2760
+ editable
2761
+ }) => {
2762
+ const expandedRowRef = (0, import_react32.useRef)(null);
2763
+ const [removed, setRemoved] = (0, import_react32.useState)(false);
2764
+ const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
2765
+ const [selectedCategory, setSelectedCategory] = (0, import_react32.useState)(
2766
+ getDefaultSelectedCategory(bankTransaction)
2767
+ );
2768
+ const [open, setOpen] = (0, import_react32.useState)(false);
2769
+ const toggleOpen = () => setOpen(!open);
2770
+ const save = () => {
2771
+ if (open && expandedRowRef?.current) {
2772
+ expandedRowRef?.current?.save();
2773
+ setOpen(false);
2774
+ return;
2775
+ }
2776
+ if (!selectedCategory) {
2777
+ return;
2778
+ }
2779
+ if (selectedCategory.type === "match") {
2780
+ matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
2781
+ return;
2782
+ }
2783
+ categorizeBankTransaction2(bankTransaction.id, {
2784
+ type: "Category",
2785
+ category: {
2786
+ type: "StableName",
2787
+ stable_name: selectedCategory?.payload.stable_name || ""
2788
+ }
2789
+ });
2790
+ };
2791
+ if (removed) {
2792
+ return null;
2793
+ }
2794
+ const className = "Layer__bank-transaction-list-item";
2795
+ const openClassName = open ? `${className}--expanded` : "";
2796
+ const rowClassName = (0, import_classnames16.default)(
2797
+ className,
2798
+ bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
2799
+ open ? openClassName : ""
2800
+ );
2801
+ return /* @__PURE__ */ import_react32.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__heading-date` }, (0, import_date_fns9.format)((0, import_date_fns9.parseISO)(bankTransaction.date), dateFormat)), /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__body__name` }, bankTransaction.counterparty_name), /* @__PURE__ */ import_react32.default.createElement(
2802
+ "span",
2803
+ {
2804
+ className: `${className}__amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
2805
+ },
2806
+ isCredit2(bankTransaction) ? "+$" : " $",
2807
+ centsToDollars(bankTransaction.amount)
2808
+ ), /* @__PURE__ */ import_react32.default.createElement(
2809
+ "div",
2810
+ {
2811
+ onClick: toggleOpen,
2812
+ className: "Layer__bank-transaction-row__expand-button"
2813
+ },
2814
+ /* @__PURE__ */ import_react32.default.createElement(
2815
+ ChevronDown_default,
2816
+ {
2817
+ className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
2818
+ }
2171
2819
  )
2172
- ), /* @__PURE__ */ import_react25.default.createElement("tr", null, /* @__PURE__ */ import_react25.default.createElement("td", { colSpan: 5 }, /* @__PURE__ */ import_react25.default.createElement(
2820
+ )), /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ import_react32.default.createElement(
2173
2821
  ExpandedBankTransactionRow,
2174
2822
  {
2175
2823
  ref: expandedRowRef,
2176
2824
  bankTransaction,
2177
- close: () => toggleOpen(bankTransaction.id),
2178
- isOpen
2825
+ close: toggleOpen,
2826
+ isOpen: open,
2827
+ asListItem: true,
2828
+ submitBtnText: editable ? "Approve" : "Save"
2179
2829
  }
2180
- ))));
2830
+ )), /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react32.default.createElement(
2831
+ CategorySelect,
2832
+ {
2833
+ bankTransaction,
2834
+ name: `category-${bankTransaction.id}`,
2835
+ value: selectedCategory,
2836
+ onChange: setSelectedCategory,
2837
+ disabled: bankTransaction.processing
2838
+ }
2839
+ ) : null, !editable ? /* @__PURE__ */ import_react32.default.createElement(Assignment, { bankTransaction }) : null, editable && /* @__PURE__ */ import_react32.default.createElement(
2840
+ SubmitButton,
2841
+ {
2842
+ onClick: () => {
2843
+ if (!bankTransaction.processing) {
2844
+ save();
2845
+ }
2846
+ },
2847
+ className: "Layer__bank-transaction__submit-btn",
2848
+ processing: bankTransaction.processing,
2849
+ error: bankTransaction.error,
2850
+ iconOnly: true
2851
+ }
2852
+ )));
2181
2853
  };
2182
2854
 
2183
2855
  // src/components/Container/Container.tsx
2184
- var import_react26 = __toESM(require("react"));
2856
+ var import_react33 = __toESM(require("react"));
2857
+
2858
+ // src/config/theme.ts
2859
+ var SHADES = {
2860
+ 50: { s: 1, l: 98 },
2861
+ 100: { s: 1, l: 96 },
2862
+ 200: { s: 1, l: 94 },
2863
+ 300: { s: 2, l: 92 },
2864
+ 500: { s: 5, l: 53 },
2865
+ 600: { s: 7, l: 40 },
2866
+ 700: { s: 9, l: 27 },
2867
+ 800: { s: 12, l: 20 },
2868
+ 1e3: { s: 20, l: 7 }
2869
+ };
2870
+ var COLORS = {
2871
+ dark: {
2872
+ h: 0,
2873
+ s: 0,
2874
+ l: 7
2875
+ },
2876
+ light: {
2877
+ h: 0,
2878
+ s: 0,
2879
+ l: 100
2880
+ }
2881
+ };
2185
2882
 
2186
2883
  // src/utils/colors.ts
2187
2884
  var parseStylesFromThemeConfig = (theme) => {
@@ -2237,6 +2934,47 @@ var parseColorFromTheme = (colorName, color) => {
2237
2934
  return {};
2238
2935
  }
2239
2936
  };
2937
+ var parseColorFromThemeToHsl = (color) => {
2938
+ if (!color) {
2939
+ return;
2940
+ }
2941
+ try {
2942
+ if ("h" in color && "s" in color && "l" in color) {
2943
+ return {
2944
+ h: Number(color.h),
2945
+ s: Number(color.s),
2946
+ l: Number(color.l)
2947
+ };
2948
+ }
2949
+ if ("r" in color && "g" in color && "b" in color) {
2950
+ const { h, s, l } = rgbToHsl(color);
2951
+ return {
2952
+ h,
2953
+ s,
2954
+ l
2955
+ };
2956
+ }
2957
+ if ("hex" in color) {
2958
+ const rgb = hexToRgb(color.hex);
2959
+ if (!rgb) {
2960
+ return void 0;
2961
+ }
2962
+ const { h, s, l } = rgbToHsl({
2963
+ r: rgb.r.toString(),
2964
+ g: rgb.g.toString(),
2965
+ b: rgb.b.toString()
2966
+ });
2967
+ return {
2968
+ h,
2969
+ s,
2970
+ l
2971
+ };
2972
+ }
2973
+ return;
2974
+ } catch (_err) {
2975
+ return;
2976
+ }
2977
+ };
2240
2978
  var rgbToHsl = (color) => {
2241
2979
  let r = Number(color.r);
2242
2980
  let g = Number(color.g);
@@ -2267,42 +3005,113 @@ var hexToRgb = (hex) => {
2267
3005
  b: values[2]
2268
3006
  };
2269
3007
  };
3008
+ var buildColorsPalette = (theme) => {
3009
+ const darkColor = parseColorFromThemeToHsl(theme?.colors?.dark) ?? COLORS.dark;
3010
+ const lightColor = parseColorFromThemeToHsl(theme?.colors?.light) ?? COLORS.light;
3011
+ return {
3012
+ 50: buildColorShade(50, darkColor),
3013
+ 100: buildColorShade(100, darkColor),
3014
+ 200: buildColorShade(200, darkColor),
3015
+ 300: buildColorShade(300, darkColor),
3016
+ 400: {
3017
+ hsl: lightColor,
3018
+ rgb: hslToRgb(lightColor),
3019
+ hex: hslToHex(lightColor)
3020
+ },
3021
+ 500: buildColorShade(500, darkColor),
3022
+ 600: buildColorShade(600, darkColor),
3023
+ 700: buildColorShade(700, darkColor),
3024
+ 800: buildColorShade(800, darkColor),
3025
+ 900: {
3026
+ hsl: darkColor,
3027
+ rgb: hslToRgb(darkColor),
3028
+ hex: hslToHex(darkColor)
3029
+ },
3030
+ 1e3: buildColorShade(1e3, darkColor)
3031
+ };
3032
+ };
3033
+ var buildColorShade = (shade, darkColorHsl) => {
3034
+ const hsl = { h: darkColorHsl.h, ...SHADES[shade] };
3035
+ const rgb = hslToRgb(hsl);
3036
+ const hex = hslToHex(hsl);
3037
+ return { hsl, rgb, hex };
3038
+ };
3039
+ var hueToRgb = (p, q, t) => {
3040
+ if (t < 0)
3041
+ t += 1;
3042
+ if (t > 1)
3043
+ t -= 1;
3044
+ if (t < 1 / 6)
3045
+ return p + (q - p) * 6 * t;
3046
+ if (t < 1 / 2)
3047
+ return q;
3048
+ if (t < 2 / 3)
3049
+ return p + (q - p) * (2 / 3 - t) * 6;
3050
+ return p;
3051
+ };
3052
+ var hslToRgb = (hsl) => {
3053
+ let r, g, b;
3054
+ let l = hsl.l / 100;
3055
+ let s = hsl.s / 100;
3056
+ if (hsl.s === 0) {
3057
+ r = g = b = l;
3058
+ } else {
3059
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3060
+ const p = 2 * l - q;
3061
+ r = hueToRgb(p, q, hsl.h + 1 / 3);
3062
+ g = hueToRgb(p, q, hsl.h);
3063
+ b = hueToRgb(p, q, hsl.h - 1 / 3);
3064
+ }
3065
+ return {
3066
+ r: Math.round(r * 255),
3067
+ g: Math.round(g * 255),
3068
+ b: Math.round(b * 255)
3069
+ };
3070
+ };
3071
+ var hslToHex = (hsl) => {
3072
+ const l = hsl.l / 100;
3073
+ const s = hsl.s;
3074
+ const a = s * Math.min(l, 1 - l) / 100;
3075
+ const f = (n) => {
3076
+ const k = (n + hsl.h / 30) % 12;
3077
+ const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
3078
+ return Math.round(255 * color).toString(16).padStart(2, "0");
3079
+ };
3080
+ return `#${f(0)}${f(8)}${f(4)}`;
3081
+ };
2270
3082
 
2271
3083
  // src/components/Container/Container.tsx
2272
- var import_classnames11 = __toESM(require("classnames"));
2273
- var Container = ({
2274
- name,
2275
- className,
2276
- children,
2277
- asWidget
2278
- }) => {
2279
- const baseClassName = (0, import_classnames11.default)(
2280
- "Layer__component Layer__component-container",
2281
- `Layer__${name}`,
2282
- asWidget ? "Layer__component--as-widget" : "",
2283
- className
2284
- );
2285
- const { theme } = useLayerContext();
2286
- const styles = parseStylesFromThemeConfig(theme);
2287
- return /* @__PURE__ */ import_react26.default.createElement("div", { className: baseClassName, style: { ...styles } }, children);
2288
- };
3084
+ var import_classnames17 = __toESM(require("classnames"));
3085
+ var Container = (0, import_react33.forwardRef)(
3086
+ ({ name, className, children, asWidget }, ref) => {
3087
+ const baseClassName = (0, import_classnames17.default)(
3088
+ "Layer__component Layer__component-container",
3089
+ `Layer__${name}`,
3090
+ asWidget ? "Layer__component--as-widget" : "",
3091
+ className
3092
+ );
3093
+ const { theme } = useLayerContext();
3094
+ const styles = parseStylesFromThemeConfig(theme);
3095
+ return /* @__PURE__ */ import_react33.default.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
3096
+ }
3097
+ );
2289
3098
 
2290
3099
  // src/components/Container/Header.tsx
2291
- var import_react27 = __toESM(require("react"));
2292
- var import_classnames12 = __toESM(require("classnames"));
2293
- var Header = (0, import_react27.forwardRef)(
3100
+ var import_react34 = __toESM(require("react"));
3101
+ var import_classnames18 = __toESM(require("classnames"));
3102
+ var Header = (0, import_react34.forwardRef)(
2294
3103
  ({ className, children, style }, ref) => {
2295
- const baseClassName = (0, import_classnames12.default)("Layer__component-header", className);
2296
- return /* @__PURE__ */ import_react27.default.createElement("header", { ref, className: baseClassName, style }, children);
3104
+ const baseClassName = (0, import_classnames18.default)("Layer__component-header", className);
3105
+ return /* @__PURE__ */ import_react34.default.createElement("header", { ref, className: baseClassName, style }, children);
2297
3106
  }
2298
3107
  );
2299
3108
 
2300
3109
  // src/components/DataState/DataState.tsx
2301
- var import_react28 = __toESM(require("react"));
3110
+ var import_react35 = __toESM(require("react"));
2302
3111
 
2303
3112
  // src/icons/AlertOctagon.tsx
2304
- var React35 = __toESM(require("react"));
2305
- var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createElement(
3113
+ var React43 = __toESM(require("react"));
3114
+ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React43.createElement(
2306
3115
  "svg",
2307
3116
  {
2308
3117
  viewBox: "0 0 18 18",
@@ -2312,7 +3121,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
2312
3121
  width: size,
2313
3122
  height: size
2314
3123
  },
2315
- /* @__PURE__ */ React35.createElement(
3124
+ /* @__PURE__ */ React43.createElement(
2316
3125
  "path",
2317
3126
  {
2318
3127
  d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
@@ -2321,7 +3130,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
2321
3130
  strokeLinejoin: "round"
2322
3131
  }
2323
3132
  ),
2324
- /* @__PURE__ */ React35.createElement(
3133
+ /* @__PURE__ */ React43.createElement(
2325
3134
  "path",
2326
3135
  {
2327
3136
  d: "M9 6V9",
@@ -2330,68 +3139,281 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
2330
3139
  strokeLinejoin: "round"
2331
3140
  }
2332
3141
  ),
2333
- /* @__PURE__ */ React35.createElement(
3142
+ /* @__PURE__ */ React43.createElement(
3143
+ "path",
3144
+ {
3145
+ d: "M9 12H9.0075",
3146
+ stroke: "currentColor",
3147
+ strokeLinecap: "round",
3148
+ strokeLinejoin: "round"
3149
+ }
3150
+ )
3151
+ );
3152
+ var AlertOctagon_default = AlertOctagon;
3153
+
3154
+ // src/icons/RefreshCcw.tsx
3155
+ var React44 = __toESM(require("react"));
3156
+ var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React44.createElement(
3157
+ "svg",
3158
+ {
3159
+ viewBox: "0 0 18 18",
3160
+ fill: "none",
3161
+ xmlns: "http://www.w3.org/2000/svg",
3162
+ ...props,
3163
+ width: size,
3164
+ height: size
3165
+ },
3166
+ /* @__PURE__ */ React44.createElement(
3167
+ "path",
3168
+ {
3169
+ d: "M0.75 3V7.5H5.25",
3170
+ stroke: "currentColor",
3171
+ strokeLinecap: "round",
3172
+ strokeLinejoin: "round"
3173
+ }
3174
+ ),
3175
+ /* @__PURE__ */ React44.createElement(
3176
+ "path",
3177
+ {
3178
+ d: "M17.25 15V10.5H12.75",
3179
+ stroke: "currentColor",
3180
+ strokeLinecap: "round",
3181
+ strokeLinejoin: "round"
3182
+ }
3183
+ ),
3184
+ /* @__PURE__ */ React44.createElement(
3185
+ "path",
3186
+ {
3187
+ d: "M15.3675 6.75C14.9871 5.67508 14.3407 4.71405 13.4884 3.95656C12.6361 3.19907 11.6059 2.66982 10.4938 2.41819C9.38167 2.16656 8.22393 2.20075 7.12861 2.51758C6.03328 2.8344 5.03606 3.42353 4.23 4.23L0.75 7.5M17.25 10.5L13.77 13.77C12.9639 14.5765 11.9667 15.1656 10.8714 15.4824C9.77607 15.7992 8.61833 15.8334 7.50621 15.5818C6.3941 15.3302 5.36385 14.8009 4.5116 14.0434C3.65935 13.2859 3.01288 12.3249 2.6325 11.25",
3188
+ stroke: "currentColor",
3189
+ strokeLinecap: "round",
3190
+ strokeLinejoin: "round"
3191
+ }
3192
+ )
3193
+ );
3194
+ var RefreshCcw_default = RefreshCcw;
3195
+
3196
+ // src/components/DataState/DataState.tsx
3197
+ var getIcon = (status) => {
3198
+ switch (status) {
3199
+ case "failed" /* failed */:
3200
+ return /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react35.default.createElement(AlertOctagon_default, { size: 12 }));
3201
+ default:
3202
+ return /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react35.default.createElement(CheckCircle_default, { size: 12 }));
3203
+ }
3204
+ };
3205
+ var DataState = ({
3206
+ status,
3207
+ title,
3208
+ description,
3209
+ onRefresh,
3210
+ isLoading
3211
+ }) => {
3212
+ return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react35.default.createElement(
3213
+ Text,
3214
+ {
3215
+ as: "span",
3216
+ size: "lg" /* lg */,
3217
+ weight: "bold" /* bold */,
3218
+ className: "Layer__data-state__title"
3219
+ },
3220
+ title
3221
+ ), /* @__PURE__ */ import_react35.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react35.default.createElement(
3222
+ Button,
3223
+ {
3224
+ variant: "secondary" /* secondary */,
3225
+ rightIcon: isLoading ? /* @__PURE__ */ import_react35.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react35.default.createElement(RefreshCcw_default, { size: 12 }),
3226
+ onClick: onRefresh,
3227
+ disabled: isLoading
3228
+ },
3229
+ "Refresh"
3230
+ )));
3231
+ };
3232
+
3233
+ // src/components/Loader/Loader.tsx
3234
+ var import_react36 = __toESM(require("react"));
3235
+ var Loader2 = ({ children }) => {
3236
+ return /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react36.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
3237
+ };
3238
+
3239
+ // src/components/Pagination/Pagination.tsx
3240
+ var import_react38 = __toESM(require("react"));
3241
+
3242
+ // src/hooks/usePagination/usePagination.ts
3243
+ var import_react37 = require("react");
3244
+
3245
+ // src/utils/helpers.ts
3246
+ var range = (start, end) => {
3247
+ let length = end - start + 1;
3248
+ return Array.from({ length }, (_, idx) => idx + start);
3249
+ };
3250
+
3251
+ // src/hooks/usePagination/usePagination.ts
3252
+ var DOTS = "...";
3253
+ var usePagination = ({
3254
+ totalCount,
3255
+ pageSize,
3256
+ siblingCount = 1,
3257
+ currentPage
3258
+ }) => {
3259
+ const paginationRange = (0, import_react37.useMemo)(() => {
3260
+ const totalPageCount = Math.ceil(totalCount / pageSize);
3261
+ const totalPageNumbers = siblingCount + 5;
3262
+ if (totalPageNumbers >= totalPageCount) {
3263
+ return range(1, totalPageCount);
3264
+ }
3265
+ const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
3266
+ const rightSiblingIndex = Math.min(
3267
+ currentPage + siblingCount,
3268
+ totalPageCount
3269
+ );
3270
+ const shouldShowLeftDots = leftSiblingIndex > 2;
3271
+ const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
3272
+ const firstPageIndex = 1;
3273
+ const lastPageIndex = totalPageCount;
3274
+ if (!shouldShowLeftDots && shouldShowRightDots) {
3275
+ let leftItemCount = 3 + 2 * siblingCount;
3276
+ let leftRange = range(1, leftItemCount);
3277
+ return [...leftRange, DOTS, totalPageCount];
3278
+ }
3279
+ if (shouldShowLeftDots && !shouldShowRightDots) {
3280
+ let rightItemCount = 3 + 2 * siblingCount;
3281
+ let rightRange = range(
3282
+ totalPageCount - rightItemCount + 1,
3283
+ totalPageCount
3284
+ );
3285
+ return [firstPageIndex, DOTS, ...rightRange];
3286
+ }
3287
+ if (shouldShowLeftDots && shouldShowRightDots) {
3288
+ let middleRange = range(leftSiblingIndex, rightSiblingIndex);
3289
+ return [firstPageIndex, DOTS, ...middleRange, DOTS, lastPageIndex];
3290
+ }
3291
+ }, [totalCount, pageSize, siblingCount, currentPage]);
3292
+ return paginationRange;
3293
+ };
3294
+
3295
+ // src/icons/ChevronLeft.tsx
3296
+ var React47 = __toESM(require("react"));
3297
+ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React47.createElement(
3298
+ "svg",
3299
+ {
3300
+ xmlns: "http://www.w3.org/2000/svg",
3301
+ width: "18",
3302
+ height: "18",
3303
+ viewBox: "0 0 18 18",
3304
+ fill: "none",
3305
+ ...props
3306
+ },
3307
+ /* @__PURE__ */ React47.createElement(
3308
+ "path",
3309
+ {
3310
+ d: "M11.25 13.5L6.75 9L11.25 4.5",
3311
+ stroke: "currentColor",
3312
+ strokeLinecap: "round",
3313
+ strokeLinejoin: "round"
3314
+ }
3315
+ )
3316
+ );
3317
+ var ChevronLeft_default = ChevronLeft;
3318
+
3319
+ // src/icons/ChevronRight.tsx
3320
+ var React48 = __toESM(require("react"));
3321
+ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React48.createElement(
3322
+ "svg",
3323
+ {
3324
+ xmlns: "http://www.w3.org/2000/svg",
3325
+ width: "18",
3326
+ height: "18",
3327
+ viewBox: "0 0 18 18",
3328
+ fill: "none",
3329
+ ...props
3330
+ },
3331
+ /* @__PURE__ */ React48.createElement(
2334
3332
  "path",
2335
3333
  {
2336
- d: "M9 12H9.0075",
3334
+ d: "M6.75 13.5L11.25 9L6.75 4.5",
2337
3335
  stroke: "currentColor",
2338
3336
  strokeLinecap: "round",
2339
3337
  strokeLinejoin: "round"
2340
3338
  }
2341
3339
  )
2342
3340
  );
2343
- var AlertOctagon_default = AlertOctagon;
3341
+ var ChevronRight_default = ChavronRight;
2344
3342
 
2345
- // src/components/DataState/DataState.tsx
2346
- var getIcon = (status) => {
2347
- switch (status) {
2348
- case "failed" /* failed */:
2349
- return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react28.default.createElement(AlertOctagon_default, { size: 12 }));
2350
- default:
2351
- return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react28.default.createElement(CheckCircle_default, { size: 12 }));
2352
- }
2353
- };
2354
- var DataState = ({
2355
- status,
2356
- title,
2357
- description,
2358
- onRefresh,
2359
- isLoading
3343
+ // src/components/Pagination/Pagination.tsx
3344
+ var import_classnames19 = __toESM(require("classnames"));
3345
+ var Pagination = ({
3346
+ onPageChange,
3347
+ totalCount,
3348
+ siblingCount = 1,
3349
+ currentPage,
3350
+ pageSize
2360
3351
  }) => {
2361
- return /* @__PURE__ */ import_react28.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react28.default.createElement(
2362
- Text,
3352
+ const paginationRange = usePagination({
3353
+ currentPage,
3354
+ totalCount,
3355
+ siblingCount,
3356
+ pageSize
3357
+ });
3358
+ if (!paginationRange) {
3359
+ return;
3360
+ }
3361
+ if (currentPage === 0 || paginationRange.length < 2) {
3362
+ return;
3363
+ }
3364
+ let lastPage = paginationRange[paginationRange.length - 1];
3365
+ return /* @__PURE__ */ import_react38.default.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ import_react38.default.createElement(
3366
+ "li",
2363
3367
  {
2364
- as: "span",
2365
- size: "lg" /* lg */,
2366
- weight: "bold" /* bold */,
2367
- className: "Layer__data-state__title"
3368
+ className: (0, import_classnames19.default)(
3369
+ "Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--previous",
3370
+ {
3371
+ disabled: currentPage === 1
3372
+ }
3373
+ ),
3374
+ onClick: () => onPageChange(currentPage - 1)
2368
3375
  },
2369
- title
2370
- ), /* @__PURE__ */ import_react28.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react28.default.createElement(
2371
- Button,
3376
+ /* @__PURE__ */ import_react38.default.createElement(ChevronLeft_default, { size: 12 })
3377
+ ), paginationRange.map((pageNumber) => {
3378
+ if (pageNumber === DOTS) {
3379
+ return /* @__PURE__ */ import_react38.default.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
3380
+ }
3381
+ return /* @__PURE__ */ import_react38.default.createElement(
3382
+ "li",
3383
+ {
3384
+ className: (0, import_classnames19.default)("Layer__pagination-item", {
3385
+ selected: pageNumber === currentPage
3386
+ }),
3387
+ onClick: () => {
3388
+ if (typeof pageNumber === "number") {
3389
+ onPageChange(pageNumber);
3390
+ }
3391
+ }
3392
+ },
3393
+ pageNumber
3394
+ );
3395
+ }), /* @__PURE__ */ import_react38.default.createElement(
3396
+ "li",
2372
3397
  {
2373
- variant: "secondary" /* secondary */,
2374
- rightIcon: isLoading ? /* @__PURE__ */ import_react28.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react28.default.createElement(RefreshCcw_default, { size: 12 }),
2375
- onClick: onRefresh,
2376
- disabled: isLoading
3398
+ className: (0, import_classnames19.default)(
3399
+ "Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--next",
3400
+ {
3401
+ disabled: currentPage === lastPage
3402
+ }
3403
+ ),
3404
+ onClick: () => onPageChange(currentPage + 1)
2377
3405
  },
2378
- "Refresh"
2379
- )));
2380
- };
2381
-
2382
- // src/components/Loader/Loader.tsx
2383
- var import_react29 = __toESM(require("react"));
2384
- var Loader2 = ({ children }) => {
2385
- return /* @__PURE__ */ import_react29.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react29.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
3406
+ /* @__PURE__ */ import_react38.default.createElement(ChevronRight_default, { size: 12 })
3407
+ ));
2386
3408
  };
2387
3409
 
2388
3410
  // src/components/BankTransactions/BankTransactions.tsx
2389
3411
  var COMPONENT_NAME = "bank-transactions";
2390
- var dateFormat = "LLL d, yyyy";
2391
3412
  var CategorizedCategories = [
2392
3413
  "CATEGORIZED" /* CATEGORIZED */,
2393
3414
  "JOURNALING" /* JOURNALING */,
2394
- "SPLIT" /* SPLIT */
3415
+ "SPLIT" /* SPLIT */,
3416
+ "MATCHED" /* MATCHED */
2395
3417
  ];
2396
3418
  var ReviewCategories = [
2397
3419
  "READY_FOR_INPUT" /* READY_FOR_INPUT */,
@@ -2405,18 +3427,27 @@ var filterVisibility = (display) => (bankTransaction) => {
2405
3427
  return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
2406
3428
  };
2407
3429
  var BankTransactions = ({
2408
- asWidget = false
3430
+ asWidget = false,
3431
+ pageSize = 15
2409
3432
  }) => {
2410
- const [display, setDisplay] = (0, import_react30.useState)("review" /* review */);
3433
+ const [display, setDisplay] = (0, import_react39.useState)("review" /* review */);
3434
+ const [currentPage, setCurrentPage] = (0, import_react39.useState)(1);
2411
3435
  const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
2412
- const bankTransactions = data?.filter(filterVisibility(display));
2413
- const onCategorizationDisplayChange = (event) => setDisplay(
2414
- event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
2415
- );
2416
- const [openRows, setOpenRows] = (0, import_react30.useState)({});
2417
- const toggleOpen = (id) => setOpenRows({ ...openRows, [id]: !openRows[id] });
2418
- const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react30.useState)(0);
2419
- const headerRef = useElementSize((_el, _en, size) => {
3436
+ const bankTransactionsByFilter = data?.filter(filterVisibility(display));
3437
+ const bankTransactions = (0, import_react39.useMemo)(() => {
3438
+ const firstPageIndex = (currentPage - 1) * pageSize;
3439
+ const lastPageIndex = firstPageIndex + pageSize;
3440
+ return bankTransactionsByFilter?.slice(firstPageIndex, lastPageIndex);
3441
+ }, [currentPage, bankTransactionsByFilter]);
3442
+ const onCategorizationDisplayChange = (event) => {
3443
+ setDisplay(
3444
+ event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
3445
+ );
3446
+ setCurrentPage(1);
3447
+ };
3448
+ const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react39.useState)(0);
3449
+ const [listView, setListView] = (0, import_react39.useState)(false);
3450
+ const containerRef = useElementSize((_el, _en, size) => {
2420
3451
  if (size?.height && size?.height >= 90) {
2421
3452
  const newShift = -Math.floor(size.height / 2) + 6;
2422
3453
  if (newShift !== shiftStickyHeader) {
@@ -2425,17 +3456,21 @@ var BankTransactions = ({
2425
3456
  } else if (size?.height > 0 && shiftStickyHeader !== 0) {
2426
3457
  setShiftStickyHeader(0);
2427
3458
  }
3459
+ if (size.width > 700 && listView) {
3460
+ setListView(false);
3461
+ } else if (size.width <= 700 && !listView) {
3462
+ setListView(true);
3463
+ }
2428
3464
  });
2429
3465
  const editable = display === "review" /* review */;
2430
- return /* @__PURE__ */ import_react30.default.createElement(Container, { name: COMPONENT_NAME, asWidget }, /* @__PURE__ */ import_react30.default.createElement(
3466
+ return /* @__PURE__ */ import_react39.default.createElement(Container, { name: COMPONENT_NAME, asWidget, ref: containerRef }, /* @__PURE__ */ import_react39.default.createElement(
2431
3467
  Header,
2432
3468
  {
2433
- ref: headerRef,
2434
3469
  className: "Layer__bank-transactions__header",
2435
3470
  style: { top: shiftStickyHeader }
2436
3471
  },
2437
- /* @__PURE__ */ import_react30.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
2438
- /* @__PURE__ */ import_react30.default.createElement(
3472
+ /* @__PURE__ */ import_react39.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
3473
+ /* @__PURE__ */ import_react39.default.createElement(
2439
3474
  Toggle,
2440
3475
  {
2441
3476
  name: "bank-transaction-display",
@@ -2447,35 +3482,31 @@ var BankTransactions = ({
2447
3482
  onChange: onCategorizationDisplayChange
2448
3483
  }
2449
3484
  )
2450
- ), /* @__PURE__ */ import_react30.default.createElement(
3485
+ ), !listView && /* @__PURE__ */ import_react39.default.createElement(
2451
3486
  "table",
2452
3487
  {
2453
3488
  width: "100%",
2454
- className: "Layer__table Layer__bank-transactions__table"
3489
+ className: "Layer__table Layer__bank-transactions__table with-cell-separators"
2455
3490
  },
2456
- /* @__PURE__ */ import_react30.default.createElement("thead", null, /* @__PURE__ */ import_react30.default.createElement("tr", null, /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
2457
- /* @__PURE__ */ import_react30.default.createElement("tbody", null, !isLoading && bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
3491
+ /* @__PURE__ */ import_react39.default.createElement("thead", null, /* @__PURE__ */ import_react39.default.createElement("tr", null, /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react39.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
3492
+ /* @__PURE__ */ import_react39.default.createElement("tbody", null, !isLoading && bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react39.default.createElement(
2458
3493
  BankTransactionRow,
2459
3494
  {
2460
3495
  key: bankTransaction.id,
2461
- dateFormat,
3496
+ dateFormat: DATE_FORMAT,
2462
3497
  bankTransaction,
2463
- isOpen: openRows[bankTransaction.id],
2464
- toggleOpen,
2465
3498
  editable
2466
3499
  }
2467
3500
  )))
2468
- ), isLoading && !bankTransactions ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react30.default.createElement(Loader2, null)) : null, !isLoading && /* @__PURE__ */ import_react30.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
3501
+ ), isLoading && !bankTransactions ? /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react39.default.createElement(Loader2, null)) : null, !isLoading && listView ? /* @__PURE__ */ import_react39.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react39.default.createElement(
2469
3502
  BankTransactionListItem,
2470
3503
  {
2471
3504
  key: bankTransaction.id,
2472
- dateFormat,
3505
+ dateFormat: DATE_FORMAT,
2473
3506
  bankTransaction,
2474
- isOpen: openRows[bankTransaction.id],
2475
- toggleOpen,
2476
3507
  editable
2477
3508
  }
2478
- ))), !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
3509
+ ))) : null, !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react39.default.createElement(
2479
3510
  DataState,
2480
3511
  {
2481
3512
  status: "allDone" /* allDone */,
@@ -2484,7 +3515,7 @@ var BankTransactions = ({
2484
3515
  onRefresh: () => refetch(),
2485
3516
  isLoading: isValidating
2486
3517
  }
2487
- )) : null, !isLoading && error ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
3518
+ )) : null, !isLoading && error ? /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react39.default.createElement(
2488
3519
  DataState,
2489
3520
  {
2490
3521
  status: "failed" /* failed */,
@@ -2493,11 +3524,19 @@ var BankTransactions = ({
2493
3524
  onRefresh: () => refetch(),
2494
3525
  isLoading: isValidating
2495
3526
  }
2496
- )) : null);
3527
+ )) : null, /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ import_react39.default.createElement(
3528
+ Pagination,
3529
+ {
3530
+ currentPage,
3531
+ totalCount: bankTransactionsByFilter?.length || 0,
3532
+ pageSize,
3533
+ onPageChange: (page) => setCurrentPage(page)
3534
+ }
3535
+ )));
2497
3536
  };
2498
3537
 
2499
3538
  // src/components/Hello/Hello.tsx
2500
- var import_react31 = __toESM(require("react"));
3539
+ var import_react40 = __toESM(require("react"));
2501
3540
  var import_swr3 = __toESM(require("swr"));
2502
3541
  var fetcher = (url) => fetch(url).then((res) => res.json());
2503
3542
  var Hello = ({ user }) => {
@@ -2506,38 +3545,50 @@ var Hello = ({ user }) => {
2506
3545
  fetcher
2507
3546
  );
2508
3547
  const name = (isLoading ? "..." : data?.name) || "User";
2509
- return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
3548
+ return /* @__PURE__ */ import_react40.default.createElement(import_react40.default.Fragment, null, /* @__PURE__ */ import_react40.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
2510
3549
  };
2511
3550
 
2512
3551
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
2513
- var import_react39 = __toESM(require("react"));
3552
+ var import_react49 = __toESM(require("react"));
2514
3553
 
2515
3554
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
2516
- var import_react32 = require("react");
2517
- var import_date_fns6 = require("date-fns");
3555
+ var import_react41 = require("react");
3556
+ var import_date_fns10 = require("date-fns");
2518
3557
  var import_swr4 = __toESM(require("swr"));
2519
- var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate } = {
2520
- startDate: (0, import_date_fns6.startOfMonth)(/* @__PURE__ */ new Date()),
2521
- endDate: (0, import_date_fns6.endOfMonth)(/* @__PURE__ */ new Date())
3558
+ var useProfitAndLoss = ({
3559
+ startDate: initialStartDate,
3560
+ endDate: initialEndDate,
3561
+ tagFilter,
3562
+ reportingBasis
3563
+ } = {
3564
+ startDate: (0, import_date_fns10.startOfMonth)(/* @__PURE__ */ new Date()),
3565
+ endDate: (0, import_date_fns10.endOfMonth)(/* @__PURE__ */ new Date())
2522
3566
  }) => {
2523
3567
  const { auth, businessId, apiUrl } = useLayerContext();
2524
- const [startDate, setStartDate] = (0, import_react32.useState)(
2525
- initialStartDate || (0, import_date_fns6.startOfMonth)(Date.now())
3568
+ const [startDate, setStartDate] = (0, import_react41.useState)(
3569
+ initialStartDate || (0, import_date_fns10.startOfMonth)(Date.now())
2526
3570
  );
2527
- const [endDate, setEndDate] = (0, import_react32.useState)(
2528
- initialEndDate || (0, import_date_fns6.endOfMonth)(Date.now())
3571
+ const [endDate, setEndDate] = (0, import_react41.useState)(
3572
+ initialEndDate || (0, import_date_fns10.endOfMonth)(Date.now())
2529
3573
  );
2530
3574
  const {
2531
3575
  data: rawData,
2532
3576
  isLoading,
2533
- error: rawError
3577
+ isValidating,
3578
+ error: rawError,
3579
+ mutate
2534
3580
  } = (0, import_swr4.default)(
2535
- businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}`,
3581
+ businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
3582
+ ","
3583
+ )}-${reportingBasis}`,
2536
3584
  Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
2537
3585
  params: {
2538
3586
  businessId,
2539
- startDate: (0, import_date_fns6.formatISO)(startDate),
2540
- endDate: (0, import_date_fns6.formatISO)(endDate)
3587
+ startDate: (0, import_date_fns10.formatISO)(startDate),
3588
+ endDate: (0, import_date_fns10.formatISO)(endDate),
3589
+ tagKey: tagFilter?.key,
3590
+ tagValues: tagFilter?.values?.join(","),
3591
+ reportingBasis
2541
3592
  }
2542
3593
  })
2543
3594
  );
@@ -2549,20 +3600,28 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
2549
3600
  newStartDate && setStartDate(newStartDate);
2550
3601
  newEndDate && setEndDate(newEndDate);
2551
3602
  };
3603
+ const refetch = () => {
3604
+ mutate();
3605
+ };
2552
3606
  return {
2553
3607
  data,
2554
3608
  isLoading,
3609
+ isValidating,
2555
3610
  error: error || rawError,
2556
3611
  dateRange: { startDate, endDate },
3612
+ refetch,
2557
3613
  changeDateRange
2558
3614
  };
2559
3615
  };
2560
3616
 
2561
3617
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
2562
- var import_react34 = __toESM(require("react"));
3618
+ var import_react43 = __toESM(require("react"));
3619
+
3620
+ // src/utils/format.ts
3621
+ var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
2563
3622
 
2564
3623
  // src/components/ProfitAndLossChart/Indicator.tsx
2565
- var import_react33 = __toESM(require("react"));
3624
+ var import_react42 = __toESM(require("react"));
2566
3625
  var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
2567
3626
  var Indicator = ({
2568
3627
  viewBox = {},
@@ -2573,134 +3632,160 @@ var Indicator = ({
2573
3632
  if (!className?.match(/selected/)) {
2574
3633
  return null;
2575
3634
  }
2576
- const {
2577
- x: animateTo = 0,
2578
- y = 0,
2579
- width = 0,
2580
- height = 0
2581
- } = "x" in viewBox ? viewBox : emptyViewBox;
3635
+ const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
2582
3636
  const boxWidth = width * 2 + 4;
2583
3637
  const multiplier = 1.5;
2584
3638
  const xOffset = (boxWidth * multiplier - boxWidth) / 2;
2585
- (0, import_react33.useEffect)(() => {
3639
+ (0, import_react42.useEffect)(() => {
2586
3640
  setAnimateFrom(animateTo);
2587
3641
  }, [animateTo]);
2588
3642
  const actualX = animateFrom === -1 ? animateTo : animateFrom;
2589
- return /* @__PURE__ */ import_react33.default.createElement(
3643
+ return /* @__PURE__ */ import_react42.default.createElement(
2590
3644
  "rect",
2591
3645
  {
2592
3646
  className: "Layer__profit-and-loss-chart__selection-indicator",
3647
+ rx: "8",
3648
+ ry: "8",
2593
3649
  style: {
2594
3650
  width: `${boxWidth * multiplier}px`,
2595
3651
  // @ts-expect-error -- y is fine but x apparently isn't!
2596
3652
  x: actualX - xOffset,
2597
- y: y + height
3653
+ y: 5,
3654
+ borderRadius: 8,
3655
+ height: "calc(100% - 10px)"
2598
3656
  }
2599
3657
  }
2600
3658
  );
2601
3659
  };
2602
3660
 
2603
3661
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
2604
- var import_date_fns7 = require("date-fns");
3662
+ var import_date_fns11 = require("date-fns");
2605
3663
  var import_recharts = require("recharts");
2606
3664
  var barGap = 4;
2607
3665
  var barSize = 20;
2608
3666
  var ProfitAndLossChart = () => {
2609
- const { changeDateRange, dateRange } = (0, import_react34.useContext)(ProfitAndLoss.Context);
2610
- const thisMonth = (0, import_date_fns7.startOfMonth)(Date.now());
3667
+ const { getColor } = useLayerContext();
3668
+ const { changeDateRange, dateRange } = (0, import_react43.useContext)(ProfitAndLoss.Context);
3669
+ const thisMonth = (0, import_date_fns11.startOfMonth)(Date.now());
2611
3670
  const startSelectionMonth = dateRange.startDate.getMonth();
2612
3671
  const endSelectionMonth = dateRange.endDate.getMonth();
2613
3672
  const monthData = [];
2614
3673
  monthData.push(
2615
3674
  useProfitAndLoss({
2616
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 11 })),
2617
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 11 }))
3675
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 11 })),
3676
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 11 }))
2618
3677
  })?.data
2619
3678
  );
2620
3679
  monthData.push(
2621
3680
  useProfitAndLoss({
2622
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 10 })),
2623
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 10 }))
3681
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 10 })),
3682
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 10 }))
2624
3683
  })?.data
2625
3684
  );
2626
3685
  monthData.push(
2627
3686
  useProfitAndLoss({
2628
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 9 })),
2629
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 9 }))
3687
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 9 })),
3688
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 9 }))
2630
3689
  })?.data
2631
3690
  );
2632
3691
  monthData.push(
2633
3692
  useProfitAndLoss({
2634
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 8 })),
2635
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 8 }))
3693
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 8 })),
3694
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 8 }))
2636
3695
  })?.data
2637
3696
  );
2638
3697
  monthData.push(
2639
3698
  useProfitAndLoss({
2640
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 7 })),
2641
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 7 }))
3699
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 7 })),
3700
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 7 }))
2642
3701
  })?.data
2643
3702
  );
2644
3703
  monthData.push(
2645
3704
  useProfitAndLoss({
2646
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 6 })),
2647
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 6 }))
3705
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 6 })),
3706
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 6 }))
2648
3707
  })?.data
2649
3708
  );
2650
3709
  monthData.push(
2651
3710
  useProfitAndLoss({
2652
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 5 })),
2653
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 5 }))
3711
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 5 })),
3712
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 5 }))
2654
3713
  })?.data
2655
3714
  );
2656
3715
  monthData.push(
2657
3716
  useProfitAndLoss({
2658
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 4 })),
2659
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 4 }))
3717
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 4 })),
3718
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 4 }))
2660
3719
  })?.data
2661
3720
  );
2662
3721
  monthData.push(
2663
3722
  useProfitAndLoss({
2664
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 3 })),
2665
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 3 }))
3723
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 3 })),
3724
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 3 }))
2666
3725
  })?.data
2667
3726
  );
2668
3727
  monthData.push(
2669
3728
  useProfitAndLoss({
2670
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 2 })),
2671
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 2 }))
3729
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 2 })),
3730
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 2 }))
2672
3731
  })?.data
2673
3732
  );
2674
3733
  monthData.push(
2675
3734
  useProfitAndLoss({
2676
- startDate: (0, import_date_fns7.startOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 1 })),
2677
- endDate: (0, import_date_fns7.endOfMonth)((0, import_date_fns7.sub)(thisMonth, { months: 1 }))
3735
+ startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 1 })),
3736
+ endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 1 }))
2678
3737
  })?.data
2679
3738
  );
2680
3739
  monthData.push(
2681
3740
  useProfitAndLoss({
2682
3741
  startDate: thisMonth,
2683
- endDate: (0, import_date_fns7.endOfMonth)(thisMonth)
3742
+ endDate: (0, import_date_fns11.endOfMonth)(thisMonth)
2684
3743
  })?.data
2685
3744
  );
2686
- const getMonthName = (pnl) => pnl ? (0, import_date_fns7.format)((0, import_date_fns7.parseISO)(pnl.start_date), "LLL") : "";
3745
+ const getMonthName = (pnl) => pnl ? (0, import_date_fns11.format)((0, import_date_fns11.parseISO)(pnl.start_date), "LLL") : "";
2687
3746
  const summarizePnL = (pnl) => ({
2688
3747
  name: getMonthName(pnl),
2689
3748
  revenue: pnl?.income.value || 0,
2690
- expenses: (pnl?.income.value || 0) - (pnl?.net_profit || 0),
2691
- selected: !!pnl && (0, import_date_fns7.parseISO)(pnl.start_date).getMonth() >= startSelectionMonth && (0, import_date_fns7.parseISO)(pnl.end_date).getMonth() <= endSelectionMonth
3749
+ expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
3750
+ selected: !!pnl && (0, import_date_fns11.parseISO)(pnl.start_date).getMonth() >= startSelectionMonth && (0, import_date_fns11.parseISO)(pnl.end_date).getMonth() <= endSelectionMonth
2692
3751
  });
2693
3752
  const onClick = ({ activeTooltipIndex }) => {
2694
3753
  const selection = monthData[activeTooltipIndex || -1];
2695
3754
  if (selection) {
2696
3755
  const { start_date: startDate, end_date: endDate } = selection;
2697
3756
  changeDateRange({
2698
- startDate: (0, import_date_fns7.parseISO)(startDate),
2699
- endDate: (0, import_date_fns7.parseISO)(endDate)
3757
+ startDate: (0, import_date_fns11.parseISO)(startDate),
3758
+ endDate: (0, import_date_fns11.parseISO)(endDate)
2700
3759
  });
2701
3760
  }
2702
3761
  };
2703
- const data = (0, import_react34.useMemo)(
3762
+ const CustomTooltip = ({
3763
+ active,
3764
+ payload,
3765
+ label
3766
+ }) => {
3767
+ if (active && payload && payload.length) {
3768
+ return /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ import_react43.default.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ import_react43.default.createElement("li", null, /* @__PURE__ */ import_react43.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ import_react43.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ import_react43.default.createElement("li", null, /* @__PURE__ */ import_react43.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ import_react43.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0))))));
3769
+ }
3770
+ return null;
3771
+ };
3772
+ const CustomizedCursor = (props) => {
3773
+ const { x, y, width, height } = props;
3774
+ return /* @__PURE__ */ import_react43.default.createElement(
3775
+ import_recharts.Rectangle,
3776
+ {
3777
+ fill: getColor(100)?.hex ?? "#F5F4F3",
3778
+ stroke: "none",
3779
+ x,
3780
+ y,
3781
+ radius: 8,
3782
+ width,
3783
+ height: height + 24,
3784
+ className: "Layer__chart__tooltip-cursor"
3785
+ }
3786
+ );
3787
+ };
3788
+ const data = (0, import_react43.useMemo)(
2704
3789
  () => monthData.map(summarizePnL),
2705
3790
  [
2706
3791
  startSelectionMonth,
@@ -2708,172 +3793,149 @@ var ProfitAndLossChart = () => {
2708
3793
  ...monthData.map((m) => m?.net_profit)
2709
3794
  ]
2710
3795
  );
2711
- const [animateFrom, setAnimateFrom] = (0, import_react34.useState)(-1);
2712
- return /* @__PURE__ */ import_react34.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: 250 }, /* @__PURE__ */ import_react34.default.createElement(
2713
- import_recharts.BarChart,
3796
+ const [animateFrom, setAnimateFrom] = (0, import_react43.useState)(-1);
3797
+ return /* @__PURE__ */ import_react43.default.createElement(
3798
+ import_recharts.ResponsiveContainer,
2714
3799
  {
2715
- margin: { left: 24, right: 24, bottom: 24 },
2716
- data,
2717
- onClick,
2718
- barGap,
2719
- className: "Layer__profit-and-loss-chart"
3800
+ className: "Layer__chart-container",
3801
+ width: "100%",
3802
+ height: "100%",
3803
+ minHeight: 200
2720
3804
  },
2721
- /* @__PURE__ */ import_react34.default.createElement(import_recharts.CartesianGrid, { vertical: false }),
2722
- /* @__PURE__ */ import_react34.default.createElement(
2723
- import_recharts.Legend,
2724
- {
2725
- verticalAlign: "top",
2726
- align: "left",
2727
- payload: [
2728
- { value: "Income", type: "circle", id: "IncomeLegend" },
2729
- { value: "Expenses", type: "circle", id: "ExpensesLegend" }
2730
- ]
2731
- }
2732
- ),
2733
- /* @__PURE__ */ import_react34.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
2734
- /* @__PURE__ */ import_react34.default.createElement(
2735
- import_recharts.Bar,
3805
+ /* @__PURE__ */ import_react43.default.createElement(
3806
+ import_recharts.BarChart,
2736
3807
  {
2737
- dataKey: "revenue",
2738
- barSize,
2739
- isAnimationActive: false,
2740
- radius: [barSize / 4, barSize / 4, 0, 0],
2741
- className: "Layer__profit-and-loss-chart__bar--income"
3808
+ margin: { left: 12, right: 12, bottom: 12 },
3809
+ data,
3810
+ onClick,
3811
+ barGap,
3812
+ className: "Layer__profit-and-loss-chart"
2742
3813
  },
2743
- /* @__PURE__ */ import_react34.default.createElement(
2744
- import_recharts.LabelList,
3814
+ /* @__PURE__ */ import_react43.default.createElement(
3815
+ import_recharts.Tooltip,
2745
3816
  {
2746
- content: /* @__PURE__ */ import_react34.default.createElement(
2747
- Indicator,
2748
- {
2749
- animateFrom,
2750
- setAnimateFrom
2751
- }
2752
- )
3817
+ wrapperClassName: "Layer__chart__tooltip-wrapper",
3818
+ content: /* @__PURE__ */ import_react43.default.createElement(CustomTooltip, null),
3819
+ cursor: /* @__PURE__ */ import_react43.default.createElement(CustomizedCursor, null)
2753
3820
  }
2754
3821
  ),
2755
- data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
2756
- import_recharts.Cell,
3822
+ /* @__PURE__ */ import_react43.default.createElement(
3823
+ import_recharts.CartesianGrid,
2757
3824
  {
2758
- key: entry.name,
2759
- className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
3825
+ vertical: false,
3826
+ stroke: getColor(200)?.hex ?? "#fff",
3827
+ strokeDasharray: "5 5"
2760
3828
  }
2761
- ))
2762
- ),
2763
- /* @__PURE__ */ import_react34.default.createElement(
2764
- import_recharts.Bar,
2765
- {
2766
- dataKey: "expenses",
2767
- barSize,
2768
- isAnimationActive: false,
2769
- radius: [barSize / 4, barSize / 4, 0, 0],
2770
- className: "Layer__profit-and-loss-chart__bar--expenses"
2771
- },
2772
- data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
2773
- import_recharts.Cell,
3829
+ ),
3830
+ /* @__PURE__ */ import_react43.default.createElement(
3831
+ import_recharts.Legend,
2774
3832
  {
2775
- key: entry.name,
2776
- className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
3833
+ verticalAlign: "top",
3834
+ align: "left",
3835
+ wrapperStyle: { top: -24 },
3836
+ payload: [
3837
+ {
3838
+ value: "Income",
3839
+ type: "circle",
3840
+ id: "IncomeLegend"
3841
+ },
3842
+ {
3843
+ value: "Expenses",
3844
+ type: "circle",
3845
+ id: "ExpensesLegend"
3846
+ }
3847
+ ]
2777
3848
  }
2778
- ))
3849
+ ),
3850
+ /* @__PURE__ */ import_react43.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
3851
+ /* @__PURE__ */ import_react43.default.createElement(
3852
+ import_recharts.Bar,
3853
+ {
3854
+ dataKey: "revenue",
3855
+ barSize,
3856
+ isAnimationActive: false,
3857
+ radius: [barSize / 4, barSize / 4, 0, 0],
3858
+ className: "Layer__profit-and-loss-chart__bar--income"
3859
+ },
3860
+ /* @__PURE__ */ import_react43.default.createElement(
3861
+ import_recharts.LabelList,
3862
+ {
3863
+ content: /* @__PURE__ */ import_react43.default.createElement(
3864
+ Indicator,
3865
+ {
3866
+ animateFrom,
3867
+ setAnimateFrom
3868
+ }
3869
+ )
3870
+ }
3871
+ ),
3872
+ data.map((entry) => /* @__PURE__ */ import_react43.default.createElement(
3873
+ import_recharts.Cell,
3874
+ {
3875
+ key: entry.name,
3876
+ className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
3877
+ }
3878
+ ))
3879
+ ),
3880
+ /* @__PURE__ */ import_react43.default.createElement(
3881
+ import_recharts.Bar,
3882
+ {
3883
+ dataKey: "expenses",
3884
+ barSize,
3885
+ isAnimationActive: false,
3886
+ radius: [barSize / 4, barSize / 4, 0, 0],
3887
+ className: "Layer__profit-and-loss-chart__bar--expenses"
3888
+ },
3889
+ data.map((entry) => /* @__PURE__ */ import_react43.default.createElement(
3890
+ import_recharts.Cell,
3891
+ {
3892
+ key: entry.name,
3893
+ className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
3894
+ }
3895
+ ))
3896
+ )
2779
3897
  )
2780
- ));
3898
+ );
2781
3899
  };
2782
3900
 
2783
3901
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
2784
- var import_react35 = __toESM(require("react"));
2785
-
2786
- // src/icons/ChevronLeft.tsx
2787
- var React42 = __toESM(require("react"));
2788
- var ChevronLeft = ({
2789
- strokeColor,
2790
- size,
2791
- ...props
2792
- }) => /* @__PURE__ */ React42.createElement(
2793
- "svg",
2794
- {
2795
- xmlns: "http://www.w3.org/2000/svg",
2796
- width: size || 24,
2797
- height: size || 24,
2798
- fill: "none",
2799
- viewBox: "0 0 24 24",
2800
- ...props
2801
- },
2802
- /* @__PURE__ */ React42.createElement(
2803
- "path",
2804
- {
2805
- stroke: strokeColor ?? "#000",
2806
- strokeLinecap: "round",
2807
- strokeLinejoin: "round",
2808
- strokeWidth: 2,
2809
- d: "m15 18-6-6 6-6"
2810
- }
2811
- )
2812
- );
2813
- var ChevronLeft_default = ChevronLeft;
2814
-
2815
- // src/icons/ChevronRight.tsx
2816
- var React43 = __toESM(require("react"));
2817
- var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
2818
- "svg",
2819
- {
2820
- xmlns: "http://www.w3.org/2000/svg",
2821
- width: size || 24,
2822
- height: size || 24,
2823
- fill: "none",
2824
- viewBox: "0 0 24 24",
2825
- ...props
2826
- },
2827
- /* @__PURE__ */ React43.createElement(
2828
- "path",
2829
- {
2830
- stroke: "#000",
2831
- strokeLinecap: "round",
2832
- strokeLinejoin: "round",
2833
- strokeWidth: 2,
2834
- d: "m9 18 6-6-6-6"
2835
- }
2836
- )
2837
- );
2838
- var ChevronRight_default = ChavronRight;
2839
-
2840
- // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
2841
- var import_date_fns8 = require("date-fns");
3902
+ var import_react44 = __toESM(require("react"));
3903
+ var import_date_fns12 = require("date-fns");
2842
3904
  var ProfitAndLossDatePicker = () => {
2843
- const { changeDateRange, dateRange } = (0, import_react35.useContext)(ProfitAndLoss.Context);
3905
+ const { changeDateRange, dateRange } = (0, import_react44.useContext)(ProfitAndLoss.Context);
2844
3906
  const date = dateRange.startDate;
2845
- const label = (0, import_date_fns8.format)(date, "LLLL y");
3907
+ const label = (0, import_date_fns12.format)(date, "LLLL y");
2846
3908
  const change = (duration) => {
2847
- const newDate = (0, import_date_fns8.add)(date, duration);
3909
+ const newDate = (0, import_date_fns12.add)(date, duration);
2848
3910
  changeDateRange({
2849
- startDate: (0, import_date_fns8.startOfMonth)(newDate),
2850
- endDate: (0, import_date_fns8.endOfMonth)(newDate)
3911
+ startDate: (0, import_date_fns12.startOfMonth)(newDate),
3912
+ endDate: (0, import_date_fns12.endOfMonth)(newDate)
2851
3913
  });
2852
3914
  };
2853
3915
  const previousMonth = () => change({ months: -1 });
2854
3916
  const nextMonth = () => change({ months: 1 });
2855
- return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react35.default.createElement(
3917
+ return /* @__PURE__ */ import_react44.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react44.default.createElement(
2856
3918
  "button",
2857
3919
  {
2858
3920
  "aria-label": "View Previous Month",
2859
3921
  className: "Layer__profit-and-loss-date-picker__button",
2860
3922
  onClick: previousMonth
2861
3923
  },
2862
- /* @__PURE__ */ import_react35.default.createElement(
3924
+ /* @__PURE__ */ import_react44.default.createElement(
2863
3925
  ChevronLeft_default,
2864
3926
  {
2865
3927
  className: "Layer__profit-and-loss-date-picker__button-icon",
2866
3928
  size: 18
2867
3929
  }
2868
3930
  )
2869
- ), /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react35.default.createElement(
3931
+ ), /* @__PURE__ */ import_react44.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react44.default.createElement(
2870
3932
  "button",
2871
3933
  {
2872
3934
  "aria-label": "View Next Month",
2873
3935
  className: "Layer__profit-and-loss-date-picker__button",
2874
3936
  onClick: nextMonth
2875
3937
  },
2876
- /* @__PURE__ */ import_react35.default.createElement(
3938
+ /* @__PURE__ */ import_react44.default.createElement(
2877
3939
  ChevronRight_default,
2878
3940
  {
2879
3941
  className: "Layer__profit-and-loss-date-picker__button-icon",
@@ -2884,52 +3946,80 @@ var ProfitAndLossDatePicker = () => {
2884
3946
  };
2885
3947
 
2886
3948
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
2887
- var import_react36 = __toESM(require("react"));
2888
- var ProfitAndLossSummaries = () => {
2889
- const { data: storedData } = (0, import_react36.useContext)(ProfitAndLoss.Context);
3949
+ var import_react46 = __toESM(require("react"));
3950
+
3951
+ // src/components/SkeletonLoader/SkeletonLoader.tsx
3952
+ var import_react45 = __toESM(require("react"));
3953
+ var import_classnames20 = __toESM(require("classnames"));
3954
+ var SkeletonLoader = ({
3955
+ height,
3956
+ width,
3957
+ className
3958
+ }) => {
3959
+ const baseClassName = (0, import_classnames20.default)(
3960
+ "Layer__skeleton-loader Layer__anim--skeleton-loading",
3961
+ className
3962
+ );
3963
+ return /* @__PURE__ */ import_react45.default.createElement("div", { className: baseClassName, style: { width, height } });
3964
+ };
3965
+
3966
+ // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
3967
+ var ProfitAndLossSummaries = ({
3968
+ vertical,
3969
+ revenueLabel = "Revenue"
3970
+ }) => {
3971
+ const { data: storedData, isLoading } = (0, import_react46.useContext)(ProfitAndLoss.Context);
2890
3972
  const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
2891
3973
  const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2892
3974
  const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2893
3975
  const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2894
- return /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries" }, /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Revenue"), /* @__PURE__ */ import_react36.default.createElement(
2895
- "span",
2896
- {
2897
- className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
2898
- },
2899
- centsToDollars(Math.abs(data?.income?.value ?? NaN))
2900
- )), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), /* @__PURE__ */ import_react36.default.createElement(
2901
- "span",
2902
- {
2903
- className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
2904
- },
2905
- centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
2906
- )), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), /* @__PURE__ */ import_react36.default.createElement(
2907
- "span",
3976
+ return /* @__PURE__ */ import_react46.default.createElement(
3977
+ "div",
2908
3978
  {
2909
- className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
3979
+ className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
2910
3980
  },
2911
- centsToDollars(Math.abs(data.net_profit))
2912
- )));
3981
+ /* @__PURE__ */ import_react46.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ import_react46.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react46.default.createElement(SkeletonLoader, null) : /* @__PURE__ */ import_react46.default.createElement(
3982
+ "span",
3983
+ {
3984
+ className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
3985
+ },
3986
+ centsToDollars(Math.abs(data?.income?.value ?? NaN))
3987
+ )),
3988
+ /* @__PURE__ */ import_react46.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ import_react46.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react46.default.createElement(SkeletonLoader, null) : /* @__PURE__ */ import_react46.default.createElement(
3989
+ "span",
3990
+ {
3991
+ className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
3992
+ },
3993
+ centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
3994
+ )),
3995
+ /* @__PURE__ */ import_react46.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react46.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react46.default.createElement(SkeletonLoader, null) : /* @__PURE__ */ import_react46.default.createElement(
3996
+ "span",
3997
+ {
3998
+ className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
3999
+ },
4000
+ centsToDollars(Math.abs(data.net_profit))
4001
+ ))
4002
+ );
2913
4003
  };
2914
4004
 
2915
4005
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
2916
- var import_react38 = __toESM(require("react"));
4006
+ var import_react48 = __toESM(require("react"));
2917
4007
 
2918
4008
  // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
2919
- var import_react37 = __toESM(require("react"));
4009
+ var import_react47 = __toESM(require("react"));
2920
4010
  var ProfitAndLossRow = ({
2921
4011
  variant,
2922
4012
  lineItem,
2923
4013
  depth = 0,
2924
4014
  maxDepth = 1,
2925
4015
  direction = "DEBIT" /* DEBIT */,
2926
- summarize = true
4016
+ lockExpanded = false
2927
4017
  }) => {
2928
4018
  if (!lineItem) {
2929
4019
  return null;
2930
4020
  }
2931
4021
  const { value, display_name, line_items } = lineItem;
2932
- const [expanded, setExpanded] = (0, import_react37.useState)(true);
4022
+ const [expanded, setExpanded] = (0, import_react47.useState)(true);
2933
4023
  const amount = value ?? 0;
2934
4024
  const amountString = centsToDollars(Math.abs(amount));
2935
4025
  const labelClasses = [
@@ -2960,12 +4050,20 @@ var ProfitAndLossRow = ({
2960
4050
  );
2961
4051
  displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
2962
4052
  displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
2963
- return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement("div", { className: labelClasses.join(" "), onClick: toggleExpanded }, /* @__PURE__ */ import_react37.default.createElement(ChevronDown_default, { size: 16 }), display_name), /* @__PURE__ */ import_react37.default.createElement("div", { className: valueClasses.join(" ") }, amountString), canGoDeeper && hasChildren && /* @__PURE__ */ import_react37.default.createElement(
4053
+ return /* @__PURE__ */ import_react47.default.createElement(import_react47.default.Fragment, null, /* @__PURE__ */ import_react47.default.createElement(
4054
+ "div",
4055
+ {
4056
+ className: labelClasses.join(" "),
4057
+ onClick: () => !lockExpanded && toggleExpanded()
4058
+ },
4059
+ !lockExpanded && /* @__PURE__ */ import_react47.default.createElement(ChevronDown_default, { size: 16 }),
4060
+ /* @__PURE__ */ import_react47.default.createElement(Text, null, display_name)
4061
+ ), /* @__PURE__ */ import_react47.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react47.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react47.default.createElement(
2964
4062
  "div",
2965
4063
  {
2966
4064
  className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
2967
4065
  },
2968
- /* @__PURE__ */ import_react37.default.createElement("div", { className: "Layer__balance-sheet-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react37.default.createElement(
4066
+ /* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react47.default.createElement(
2969
4067
  ProfitAndLossRow,
2970
4068
  {
2971
4069
  key: line_item.display_name,
@@ -2974,16 +4072,7 @@ var ProfitAndLossRow = ({
2974
4072
  maxDepth,
2975
4073
  direction
2976
4074
  }
2977
- )), summarize && /* @__PURE__ */ import_react37.default.createElement(
2978
- ProfitAndLossRow,
2979
- {
2980
- key: display_name,
2981
- lineItem: { value, display_name: `Total of ${display_name}` },
2982
- variant: "summation",
2983
- depth: depth + 1,
2984
- maxDepth
2985
- }
2986
- ))
4075
+ )))
2987
4076
  ));
2988
4077
  };
2989
4078
 
@@ -3036,16 +4125,27 @@ var empty_profit_and_loss_report_default = {
3036
4125
  };
3037
4126
 
3038
4127
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
3039
- var ProfitAndLossTable = () => {
3040
- const { data: actualData, isLoading } = (0, import_react38.useContext)(ProfitAndLoss.Context);
4128
+ var ProfitAndLossTable = ({ lockExpanded }) => {
4129
+ const { data: actualData, isLoading } = (0, import_react48.useContext)(ProfitAndLoss.Context);
3041
4130
  const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
3042
- return /* @__PURE__ */ import_react38.default.createElement(import_react38.default.Fragment, null, /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.income, direction: "CREDIT" /* CREDIT */ }), /* @__PURE__ */ import_react38.default.createElement(
4131
+ if (isLoading || actualData === void 0) {
4132
+ return /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react48.default.createElement(Loader2, null));
4133
+ }
4134
+ return /* @__PURE__ */ import_react48.default.createElement(import_react48.default.Fragment, null, /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ import_react48.default.createElement(
4135
+ ProfitAndLossRow,
4136
+ {
4137
+ lineItem: data.income,
4138
+ direction: "CREDIT" /* CREDIT */,
4139
+ lockExpanded
4140
+ }
4141
+ ), /* @__PURE__ */ import_react48.default.createElement(
3043
4142
  ProfitAndLossRow,
3044
4143
  {
3045
4144
  lineItem: data.cost_of_goods_sold,
3046
- direction: "DEBIT" /* DEBIT */
4145
+ direction: "DEBIT" /* DEBIT */,
4146
+ lockExpanded
3047
4147
  }
3048
- ), /* @__PURE__ */ import_react38.default.createElement(
4148
+ ), /* @__PURE__ */ import_react48.default.createElement(
3049
4149
  ProfitAndLossRow,
3050
4150
  {
3051
4151
  lineItem: {
@@ -3053,15 +4153,17 @@ var ProfitAndLossTable = () => {
3053
4153
  display_name: "Gross Profit"
3054
4154
  },
3055
4155
  variant: "summation",
3056
- direction: "CREDIT" /* CREDIT */
4156
+ direction: "CREDIT" /* CREDIT */,
4157
+ lockExpanded
3057
4158
  }
3058
- ), /* @__PURE__ */ import_react38.default.createElement(
4159
+ ), /* @__PURE__ */ import_react48.default.createElement(
3059
4160
  ProfitAndLossRow,
3060
4161
  {
3061
4162
  lineItem: data.expenses,
3062
- direction: "DEBIT" /* DEBIT */
4163
+ direction: "DEBIT" /* DEBIT */,
4164
+ lockExpanded
3063
4165
  }
3064
- ), /* @__PURE__ */ import_react38.default.createElement(
4166
+ ), /* @__PURE__ */ import_react48.default.createElement(
3065
4167
  ProfitAndLossRow,
3066
4168
  {
3067
4169
  lineItem: {
@@ -3069,9 +4171,17 @@ var ProfitAndLossTable = () => {
3069
4171
  display_name: "Profit Before Taxes"
3070
4172
  },
3071
4173
  variant: "summation",
3072
- direction: "CREDIT" /* CREDIT */
4174
+ direction: "CREDIT" /* CREDIT */,
4175
+ lockExpanded
3073
4176
  }
3074
- ), /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.taxes, direction: "DEBIT" /* DEBIT */ }), /* @__PURE__ */ import_react38.default.createElement(
4177
+ ), /* @__PURE__ */ import_react48.default.createElement(
4178
+ ProfitAndLossRow,
4179
+ {
4180
+ lineItem: data.taxes,
4181
+ direction: "DEBIT" /* DEBIT */,
4182
+ lockExpanded
4183
+ }
4184
+ ), /* @__PURE__ */ import_react48.default.createElement(
3075
4185
  ProfitAndLossRow,
3076
4186
  {
3077
4187
  lineItem: {
@@ -3079,39 +4189,45 @@ var ProfitAndLossTable = () => {
3079
4189
  display_name: "Net Profit"
3080
4190
  },
3081
4191
  variant: "summation",
3082
- direction: "CREDIT" /* CREDIT */
4192
+ direction: "CREDIT" /* CREDIT */,
4193
+ lockExpanded
3083
4194
  }
3084
- )), /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react38.default.createElement(
4195
+ )), /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react48.default.createElement(
3085
4196
  ProfitAndLossRow,
3086
4197
  {
3087
4198
  lineItem: data.other_outflows,
3088
- direction: "DEBIT" /* DEBIT */
4199
+ direction: "DEBIT" /* DEBIT */,
4200
+ lockExpanded
3089
4201
  }
3090
- ), /* @__PURE__ */ import_react38.default.createElement(
4202
+ ), /* @__PURE__ */ import_react48.default.createElement(
3091
4203
  ProfitAndLossRow,
3092
4204
  {
3093
4205
  lineItem: data.personal_expenses,
3094
- direction: "DEBIT" /* DEBIT */
4206
+ direction: "DEBIT" /* DEBIT */,
4207
+ lockExpanded
3095
4208
  }
3096
4209
  )));
3097
4210
  };
3098
4211
 
3099
4212
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
3100
- var import_date_fns9 = require("date-fns");
3101
- var PNLContext = (0, import_react39.createContext)({
4213
+ var import_date_fns13 = require("date-fns");
4214
+ var PNLContext = (0, import_react49.createContext)({
3102
4215
  data: void 0,
3103
4216
  isLoading: true,
4217
+ isValidating: false,
3104
4218
  error: void 0,
3105
4219
  dateRange: {
3106
- startDate: (0, import_date_fns9.startOfMonth)(/* @__PURE__ */ new Date()),
3107
- endDate: (0, import_date_fns9.endOfMonth)(/* @__PURE__ */ new Date())
4220
+ startDate: (0, import_date_fns13.startOfMonth)(/* @__PURE__ */ new Date()),
4221
+ endDate: (0, import_date_fns13.endOfMonth)(/* @__PURE__ */ new Date())
3108
4222
  },
3109
4223
  changeDateRange: () => {
4224
+ },
4225
+ refetch: () => {
3110
4226
  }
3111
4227
  });
3112
- var ProfitAndLoss = ({ children }) => {
3113
- const contextData = useProfitAndLoss();
3114
- return /* @__PURE__ */ import_react39.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, /* @__PURE__ */ import_react39.default.createElement("h2", { className: "Layer__profit-and-loss__title" }, "Profit & Loss"), children));
4228
+ var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
4229
+ const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
4230
+ return /* @__PURE__ */ import_react49.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react49.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
3115
4231
  };
3116
4232
  ProfitAndLoss.Chart = ProfitAndLossChart;
3117
4233
  ProfitAndLoss.Context = PNLContext;
@@ -3119,9 +4235,47 @@ ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
3119
4235
  ProfitAndLoss.Summaries = ProfitAndLossSummaries;
3120
4236
  ProfitAndLoss.Table = ProfitAndLossTable;
3121
4237
 
4238
+ // src/components/ProfitAndLossView/ProfitAndLossView.tsx
4239
+ var import_react50 = __toESM(require("react"));
4240
+ var COMPONENT_NAME2 = "profit-and-loss";
4241
+ var ProfitAndLossView = () => {
4242
+ return /* @__PURE__ */ import_react50.default.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ import_react50.default.createElement(Header, { className: `Layer__${COMPONENT_NAME2}__header` }, /* @__PURE__ */ import_react50.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit And Loss")), /* @__PURE__ */ import_react50.default.createElement(ProfitAndLoss, null, /* @__PURE__ */ import_react50.default.createElement(Components, null)));
4243
+ };
4244
+ var Components = () => {
4245
+ const { error, isLoading, isValidating, refetch } = (0, import_react50.useContext)(
4246
+ ProfitAndLoss.Context
4247
+ );
4248
+ if (!isLoading && error) {
4249
+ return /* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react50.default.createElement(
4250
+ DataState,
4251
+ {
4252
+ status: "failed" /* failed */,
4253
+ title: "Something went wrong",
4254
+ description: "We couldn\u2019t load your data.",
4255
+ onRefresh: () => refetch(),
4256
+ isLoading: isValidating
4257
+ }
4258
+ ));
4259
+ }
4260
+ return /* @__PURE__ */ import_react50.default.createElement(import_react50.default.Fragment, null, /* @__PURE__ */ import_react50.default.createElement("div", { className: `Layer__${COMPONENT_NAME2}__chart_with_summaries` }, /* @__PURE__ */ import_react50.default.createElement(
4261
+ "div",
4262
+ {
4263
+ className: `Layer__${COMPONENT_NAME2}__chart_with_summaries__summary-col`
4264
+ },
4265
+ /* @__PURE__ */ import_react50.default.createElement(ProfitAndLoss.DatePicker, null),
4266
+ /* @__PURE__ */ import_react50.default.createElement(ProfitAndLoss.Summaries, { vertical: true })
4267
+ ), /* @__PURE__ */ import_react50.default.createElement(
4268
+ "div",
4269
+ {
4270
+ className: `Layer__${COMPONENT_NAME2}__chart_with_summaries__chart-col`
4271
+ },
4272
+ /* @__PURE__ */ import_react50.default.createElement(ProfitAndLoss.Chart, null)
4273
+ )), /* @__PURE__ */ import_react50.default.createElement(ProfitAndLoss.Table, null));
4274
+ };
4275
+
3122
4276
  // src/providers/LayerProvider/LayerProvider.tsx
3123
- var import_react40 = __toESM(require("react"));
3124
- var import_date_fns10 = require("date-fns");
4277
+ var import_react51 = __toESM(require("react"));
4278
+ var import_date_fns14 = require("date-fns");
3125
4279
  var import_swr5 = __toESM(require("swr"));
3126
4280
  var reducer = (state, action) => {
3127
4281
  switch (action.type) {
@@ -3160,8 +4314,9 @@ var LayerProvider = ({
3160
4314
  revalidateOnReconnect: false,
3161
4315
  revalidateIfStale: false
3162
4316
  };
4317
+ const colors = buildColorsPalette(theme);
3163
4318
  const { url, scope, apiUrl } = LayerEnvironment[environment];
3164
- const [state, dispatch] = (0, import_react40.useReducer)(reducer, {
4319
+ const [state, dispatch] = (0, import_react51.useReducer)(reducer, {
3165
4320
  auth: {
3166
4321
  access_token: "",
3167
4322
  token_type: "",
@@ -3171,10 +4326,11 @@ var LayerProvider = ({
3171
4326
  businessId,
3172
4327
  categories: [],
3173
4328
  apiUrl,
3174
- theme
4329
+ theme,
4330
+ colors
3175
4331
  });
3176
4332
  const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr5.default)(
3177
- businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns10.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
4333
+ businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns14.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
3178
4334
  Layer.authenticate({
3179
4335
  appId,
3180
4336
  appSecret,
@@ -3183,7 +4339,7 @@ var LayerProvider = ({
3183
4339
  }),
3184
4340
  defaultSWRConfig
3185
4341
  ) : { data: void 0 };
3186
- (0, import_react40.useEffect)(() => {
4342
+ (0, import_react51.useEffect)(() => {
3187
4343
  if (businessAccessToken) {
3188
4344
  dispatch({
3189
4345
  type: "LayerContext.setAuth" /* setAuth */,
@@ -3192,7 +4348,7 @@ var LayerProvider = ({
3192
4348
  access_token: businessAccessToken,
3193
4349
  token_type: "Bearer",
3194
4350
  expires_in: 3600,
3195
- expires_at: (0, import_date_fns10.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
4351
+ expires_at: (0, import_date_fns14.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
3196
4352
  }
3197
4353
  }
3198
4354
  });
@@ -3202,34 +4358,42 @@ var LayerProvider = ({
3202
4358
  payload: {
3203
4359
  auth: {
3204
4360
  ...auth,
3205
- expires_at: (0, import_date_fns10.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
4361
+ expires_at: (0, import_date_fns14.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
3206
4362
  }
3207
4363
  }
3208
4364
  });
3209
4365
  }
3210
4366
  }, [businessAccessToken, auth?.access_token]);
3211
- const { data: categories } = (0, import_swr5.default)(
4367
+ (0, import_swr5.default)(
3212
4368
  businessId && auth?.access_token && `categories-${businessId}`,
3213
4369
  Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
3214
- defaultSWRConfig
3215
- );
3216
- (0, import_react40.useEffect)(() => {
3217
- if (categories?.data?.categories?.length) {
3218
- dispatch({
3219
- type: "LayerContext.setCategories" /* setCategories */,
3220
- payload: { categories: categories.data.categories || [] }
3221
- });
4370
+ {
4371
+ ...defaultSWRConfig,
4372
+ onSuccess: (response) => {
4373
+ if (response?.data?.categories?.length) {
4374
+ dispatch({
4375
+ type: "LayerContext.setCategories" /* setCategories */,
4376
+ payload: { categories: response.data.categories || [] }
4377
+ });
4378
+ }
4379
+ }
3222
4380
  }
3223
- }, [categories?.data?.categories?.length]);
4381
+ );
3224
4382
  const setTheme = (theme2) => dispatch({
3225
4383
  type: "LayerContext.setTheme" /* setTheme */,
3226
4384
  payload: { theme: theme2 }
3227
4385
  });
3228
- return /* @__PURE__ */ import_react40.default.createElement(import_swr5.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react40.default.createElement(LayerContext.Provider, { value: { ...state, setTheme } }, children));
4386
+ const getColor = (shade) => {
4387
+ if (colors && shade in colors) {
4388
+ return colors[shade];
4389
+ }
4390
+ return;
4391
+ };
4392
+ return /* @__PURE__ */ import_react51.default.createElement(import_swr5.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react51.default.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
3229
4393
  };
3230
4394
 
3231
4395
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
3232
- var import_react43 = __toESM(require("react"));
4396
+ var import_react54 = __toESM(require("react"));
3233
4397
 
3234
4398
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
3235
4399
  var import_swr6 = __toESM(require("swr"));
@@ -3249,21 +4413,21 @@ var useChartOfAccounts = () => {
3249
4413
  };
3250
4414
 
3251
4415
  // src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
3252
- var import_react41 = __toESM(require("react"));
3253
- var import_react_select2 = __toESM(require("react-select"));
4416
+ var import_react52 = __toESM(require("react"));
4417
+ var import_react_select3 = __toESM(require("react-select"));
3254
4418
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
3255
4419
  var ChartOfAccountsNewForm = () => {
3256
4420
  const { data, create: createAccount2 } = useChartOfAccounts();
3257
- const accountOptions = (0, import_react41.useMemo)(
4421
+ const accountOptions = (0, import_react52.useMemo)(
3258
4422
  () => flattenAccounts(data?.accounts || []).sort(
3259
4423
  (a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
3260
4424
  ),
3261
4425
  [data?.accounts?.length]
3262
4426
  );
3263
- const [name, setName] = (0, import_react41.useState)("");
3264
- const [description, setDescription] = (0, import_react41.useState)("");
3265
- const [normality, setNormality] = (0, import_react41.useState)("DEBIT" /* DEBIT */);
3266
- const [parentAccount, setParentAccount] = (0, import_react41.useState)(
4427
+ const [name, setName] = (0, import_react52.useState)("");
4428
+ const [description, setDescription] = (0, import_react52.useState)("");
4429
+ const [normality, setNormality] = (0, import_react52.useState)("DEBIT" /* DEBIT */);
4430
+ const [parentAccount, setParentAccount] = (0, import_react52.useState)(
3267
4431
  data?.accounts[0]
3268
4432
  );
3269
4433
  const save = () => {
@@ -3277,22 +4441,22 @@ var ChartOfAccountsNewForm = () => {
3277
4441
  description
3278
4442
  });
3279
4443
  };
3280
- return /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react41.default.createElement(
4444
+ return /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react52.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react52.default.createElement(
3281
4445
  "input",
3282
4446
  {
3283
4447
  name: "name",
3284
4448
  value: name,
3285
4449
  onChange: (event) => setName(event.target.value)
3286
4450
  }
3287
- )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react41.default.createElement(
4451
+ )), /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react52.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react52.default.createElement(
3288
4452
  "input",
3289
4453
  {
3290
4454
  name: "description",
3291
4455
  value: description,
3292
4456
  onChange: (event) => setDescription(event.target.value)
3293
4457
  }
3294
- )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react41.default.createElement(
3295
- import_react_select2.default,
4458
+ )), /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react52.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react52.default.createElement(
4459
+ import_react_select3.default,
3296
4460
  {
3297
4461
  isSearchable: false,
3298
4462
  onChange: (value) => value && setNormality(value.value),
@@ -3301,8 +4465,8 @@ var ChartOfAccountsNewForm = () => {
3301
4465
  { label: "Debit", value: "DEBIT" /* DEBIT */ }
3302
4466
  ]
3303
4467
  }
3304
- )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react41.default.createElement(
3305
- import_react_select2.default,
4468
+ )), /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react52.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react52.default.createElement(
4469
+ import_react_select3.default,
3306
4470
  {
3307
4471
  isSearchable: true,
3308
4472
  value: parentAccount,
@@ -3311,49 +4475,49 @@ var ChartOfAccountsNewForm = () => {
3311
4475
  getOptionValue: (a) => a.id,
3312
4476
  options: accountOptions
3313
4477
  }
3314
- )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react41.default.createElement("button", { onClick: save }, "Save")));
4478
+ )), /* @__PURE__ */ import_react52.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react52.default.createElement("button", { onClick: save }, "Save")));
3315
4479
  };
3316
4480
 
3317
4481
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
3318
- var import_react42 = __toESM(require("react"));
4482
+ var import_react53 = __toESM(require("react"));
3319
4483
  var ChartOfAccountsRow = ({ account, depth = 0 }) => {
3320
- const classNames13 = [
4484
+ const classNames20 = [
3321
4485
  "Layer__chart-of-accounts-row__table-cell",
3322
4486
  depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
3323
4487
  ];
3324
- const className = classNames13.filter((id) => id).join(" ");
4488
+ const className = classNames20.filter((id) => id).join(" ");
3325
4489
  const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
3326
- return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(
4490
+ return /* @__PURE__ */ import_react53.default.createElement(import_react53.default.Fragment, null, /* @__PURE__ */ import_react53.default.createElement(
3327
4491
  "div",
3328
4492
  {
3329
4493
  className: `${className} Layer__chart-of-accounts-row__table-cell--name`
3330
4494
  },
3331
4495
  account.name
3332
- ), /* @__PURE__ */ import_react42.default.createElement(
4496
+ ), /* @__PURE__ */ import_react53.default.createElement(
3333
4497
  "div",
3334
4498
  {
3335
4499
  className: `${className} Layer__chart-of-accounts-row__table-cell--type`
3336
4500
  },
3337
4501
  "Assets"
3338
- ), /* @__PURE__ */ import_react42.default.createElement(
4502
+ ), /* @__PURE__ */ import_react53.default.createElement(
3339
4503
  "div",
3340
4504
  {
3341
4505
  className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
3342
4506
  },
3343
4507
  "Cash"
3344
- ), /* @__PURE__ */ import_react42.default.createElement(
4508
+ ), /* @__PURE__ */ import_react53.default.createElement(
3345
4509
  "div",
3346
4510
  {
3347
4511
  className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
3348
4512
  },
3349
4513
  centsToDollars(Math.abs(account.balance || 0))
3350
- ), /* @__PURE__ */ import_react42.default.createElement(
4514
+ ), /* @__PURE__ */ import_react53.default.createElement(
3351
4515
  "div",
3352
4516
  {
3353
4517
  className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
3354
4518
  },
3355
- /* @__PURE__ */ import_react42.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
3356
- ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react42.default.createElement(
4519
+ /* @__PURE__ */ import_react53.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
4520
+ ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react53.default.createElement(
3357
4521
  ChartOfAccountsRow,
3358
4522
  {
3359
4523
  key: subAccount.id,
@@ -3366,15 +4530,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
3366
4530
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
3367
4531
  var ChartOfAccounts = () => {
3368
4532
  const { data, isLoading } = useChartOfAccounts();
3369
- const [showingForm, setShowingForm] = (0, import_react43.useState)(false);
3370
- return /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react43.default.createElement(import_react43.default.Fragment, null, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react43.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react43.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react43.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react43.default.createElement(
4533
+ const [showingForm, setShowingForm] = (0, import_react54.useState)(false);
4534
+ return /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react54.default.createElement(import_react54.default.Fragment, null, /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react54.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react54.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react54.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react54.default.createElement(
3371
4535
  "button",
3372
4536
  {
3373
4537
  className: "Layer__chart-of-accounts__edit-accounts-button",
3374
4538
  onClick: () => setShowingForm(!showingForm)
3375
4539
  },
3376
4540
  "Edit Accounts"
3377
- ))), showingForm && /* @__PURE__ */ import_react43.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react43.default.createElement(
4541
+ ))), showingForm && /* @__PURE__ */ import_react54.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react54.default.createElement(
3378
4542
  ChartOfAccountsRow,
3379
4543
  {
3380
4544
  key: account.id,
@@ -3390,6 +4554,7 @@ var ChartOfAccounts = () => {
3390
4554
  ChartOfAccounts,
3391
4555
  Hello,
3392
4556
  LayerProvider,
3393
- ProfitAndLoss
4557
+ ProfitAndLoss,
4558
+ ProfitAndLossView
3394
4559
  });
3395
4560
  //# sourceMappingURL=index.js.map