@layerfi/components 0.1.136 → 0.1.137-alpha

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.
@@ -284,7 +284,7 @@ var getIntlLocale = (locale) => {
284
284
  };
285
285
  var package_default = {
286
286
  name: "@layerfi/components",
287
- version: "0.1.136",
287
+ version: "0.1.137-alpha",
288
288
  description: "Layer React Components",
289
289
  main: "dist/cjs/index.cjs",
290
290
  module: "dist/esm/index.mjs",
@@ -729,7 +729,7 @@ function _requestOAuthToken() {
729
729
  return _requestOAuthToken.apply(this, arguments);
730
730
  }
731
731
  var AUTH_TAG_KEY = "#auth";
732
- function buildKey$90({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }) {
732
+ function buildKey$91({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }) {
733
733
  if (businessAccessToken) return {
734
734
  apiUrl,
735
735
  businessAccessToken,
@@ -752,7 +752,7 @@ var FALLBACK_REFRESH_MS = DEFAULT_EXPIRES_IN_SECONDS / 2 * 1e3;
752
752
  function useAuth() {
753
753
  const { apiUrl, authUrl, scope } = useEnvironment();
754
754
  const { appId, appSecret, businessAccessToken } = useAuthInput();
755
- return (0, swr.default)(() => buildKey$90({
755
+ return (0, swr.default)(() => buildKey$91({
756
756
  appId,
757
757
  appSecret,
758
758
  businessAccessToken,
@@ -800,7 +800,7 @@ var useLayerContext = () => {
800
800
  var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
801
801
  var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
802
802
  var listBankAccounts = get$1(({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`);
803
- function buildKey$89({ access_token: accessToken, apiUrl, businessId }) {
803
+ function buildKey$90({ access_token: accessToken, apiUrl, businessId }) {
804
804
  if (accessToken && apiUrl) return {
805
805
  accessToken,
806
806
  apiUrl,
@@ -821,7 +821,7 @@ function useListBankAccounts() {
821
821
  const { businessId } = useLayerContext();
822
822
  const { apiUrl } = useEnvironment();
823
823
  const { data: auth } = useAuth();
824
- return new ListBankAccountsSWRResponse((0, swr.default)(() => buildKey$89(_objectSpread2(_objectSpread2({}, auth), {}, {
824
+ return new ListBankAccountsSWRResponse((0, swr.default)(() => buildKey$90(_objectSpread2(_objectSpread2({}, auth), {}, {
825
825
  apiUrl,
826
826
  businessId
827
827
  })), ({ accessToken, apiUrl, businessId }) => listBankAccounts(apiUrl, accessToken, { params: { businessId } })().then(({ data }) => data)));
@@ -3823,7 +3823,7 @@ var useLocalizedKey = () => {
3823
3823
  var _excluded$119 = ["trigger"];
3824
3824
  var UNLINK_BANK_ACCOUNT_TAG_KEY = "#unlink-bank-account";
3825
3825
  var unlinkBankAccount = del(({ businessId, bankAccountId }) => `/v1/businesses/${businessId}/bank-accounts/${bankAccountId}`);
3826
- function buildKey$88({ access_token: accessToken, apiUrl, businessId }) {
3826
+ function buildKey$89({ access_token: accessToken, apiUrl, businessId }) {
3827
3827
  if (accessToken && apiUrl) return {
3828
3828
  accessToken,
3829
3829
  apiUrl,
@@ -3836,7 +3836,7 @@ function useUnlinkBankAccount() {
3836
3836
  const { businessId } = useLayerContext();
3837
3837
  const { apiUrl } = useEnvironment();
3838
3838
  const { data: auth } = useAuth();
3839
- const _useSWRMutation = (0, swr_mutation.default)(() => withLocale(buildKey$88({
3839
+ const _useSWRMutation = (0, swr_mutation.default)(() => withLocale(buildKey$89({
3840
3840
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
3841
3841
  apiUrl,
3842
3842
  businessId
@@ -7339,7 +7339,7 @@ var BankTransactionsSWRResponse = class extends SWRInfiniteResult {
7339
7339
  return this.data && this.data.length > 0 ? this.data[this.data.length - 1].meta.pagination.has_more : false;
7340
7340
  }
7341
7341
  };
7342
- function keyLoader$10(previousPageData, { access_token: accessToken, apiUrl, businessId, categorized, direction, query, startDate, endDate, tagFilterQueryString }) {
7342
+ function keyLoader$11(previousPageData, { access_token: accessToken, apiUrl, businessId, categorized, direction, query, startDate, endDate, tagFilterQueryString }) {
7343
7343
  if (accessToken && apiUrl) return {
7344
7344
  accessToken,
7345
7345
  apiUrl,
@@ -7358,7 +7358,7 @@ function useBankTransactions({ categorized, direction, query, startDate, endDate
7358
7358
  const withLocale = useLocalizedKey();
7359
7359
  const { data } = useAuth();
7360
7360
  const { businessId } = useLayerContext();
7361
- const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$10(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7361
+ const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$11(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7362
7362
  businessId,
7363
7363
  categorized,
7364
7364
  direction,
@@ -8748,24 +8748,24 @@ var BankTransactionType = /* @__PURE__ */ function(BankTransactionType) {
8748
8748
  var BankTransactionTypeSchema = effect_index.Schema.Enums(BankTransactionType);
8749
8749
  var CreateCategorizationRuleSchema = effect_index.Schema.Struct({
8750
8750
  applyRetroactively: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.Boolean), effect_index.Schema.fromKey("apply_retroactively")),
8751
- createdBySuggestionId: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("created_by_suggestion_id")),
8752
- externalId: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("external_id")),
8753
- name: effect_index.Schema.NullishOr(effect_index.Schema.String),
8754
- category: effect_index.Schema.NullishOr(AccountIdentifierSchema),
8755
- suggestion1: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_1")),
8756
- suggestion2: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_2")),
8757
- suggestion3: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_3")),
8758
- businessNameFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("business_name_filter")),
8759
- clientNameFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("client_name_filter")),
8760
- merchantTypeFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("merchant_type_filter")),
8761
- transactionDescriptionFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_description_filter")),
8762
- transactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_type_filter")),
8763
- bankDirectionFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(BankDirectionFilterSchema)), effect_index.Schema.fromKey("bank_direction_filter")),
8764
- amountMinFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_min_filter")),
8765
- amountMaxFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_max_filter")),
8766
- counterpartyFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.UUID)), effect_index.Schema.fromKey("counterparty_filter")),
8767
- bankTransactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(BankTransactionTypeSchema)), effect_index.Schema.fromKey("bank_transaction_type_filter")),
8768
- mccFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("mcc_filter"))
8751
+ createdBySuggestionId: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("created_by_suggestion_id")),
8752
+ externalId: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("external_id")),
8753
+ name: effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)),
8754
+ category: effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)),
8755
+ suggestion1: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_1")),
8756
+ suggestion2: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_2")),
8757
+ suggestion3: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_3")),
8758
+ businessNameFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("business_name_filter")),
8759
+ clientNameFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("client_name_filter")),
8760
+ merchantTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("merchant_type_filter")),
8761
+ transactionDescriptionFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_description_filter")),
8762
+ transactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_type_filter")),
8763
+ bankDirectionFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(BankDirectionFilterSchema)), effect_index.Schema.fromKey("bank_direction_filter")),
8764
+ amountMinFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_min_filter")),
8765
+ amountMaxFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_max_filter")),
8766
+ counterpartyFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.UUID)), effect_index.Schema.fromKey("counterparty_filter")),
8767
+ bankTransactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(BankTransactionTypeSchema)), effect_index.Schema.fromKey("bank_transaction_type_filter")),
8768
+ mccFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("mcc_filter"))
8769
8769
  });
8770
8770
  var CreateCategorizationRuleForCounterpartySchema = effect_index.Schema.Struct({
8771
8771
  type: effect_index.Schema.Literal("Create_Categorization_Rule_For_Counterparty"),
@@ -8774,6 +8774,25 @@ var CreateCategorizationRuleForCounterpartySchema = effect_index.Schema.Struct({
8774
8774
  suggestionPrompt: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("suggestion_prompt")),
8775
8775
  transactionsThatWillBeAffected: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.Array(MinimalBankTransactionSchema)), effect_index.Schema.fromKey("transactions_that_will_be_affected"))
8776
8776
  });
8777
+ var PatchCategorizationRuleSchema = effect_index.Schema.Struct({
8778
+ externalId: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("external_id")),
8779
+ name: effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)),
8780
+ category: effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)),
8781
+ suggestion1: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_1")),
8782
+ suggestion2: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_2")),
8783
+ suggestion3: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(AccountIdentifierSchema)), effect_index.Schema.fromKey("suggestion_3")),
8784
+ businessNameFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("business_name_filter")),
8785
+ clientNameFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("client_name_filter")),
8786
+ merchantTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("merchant_type_filter")),
8787
+ transactionDescriptionFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_description_filter")),
8788
+ transactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("transaction_type_filter")),
8789
+ bankDirectionFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(BankDirectionFilterSchema)), effect_index.Schema.fromKey("bank_direction_filter")),
8790
+ amountMinFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_min_filter")),
8791
+ amountMaxFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_max_filter")),
8792
+ counterpartyFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.UUID)), effect_index.Schema.fromKey("counterparty_filter")),
8793
+ bankTransactionTypeFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(BankTransactionTypeSchema)), effect_index.Schema.fromKey("bank_transaction_type_filter")),
8794
+ mccFilter: (0, effect_index.pipe)(effect_index.Schema.optional(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("mcc_filter"))
8795
+ });
8777
8796
  var CategorizationRuleSchema = effect_index.Schema.Struct({
8778
8797
  id: effect_index.Schema.String,
8779
8798
  businessId: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.String), effect_index.Schema.fromKey("business_id")),
@@ -8785,6 +8804,8 @@ var CategorizationRuleSchema = effect_index.Schema.Struct({
8785
8804
  counterpartyFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(BankTransactionCounterpartySchema)), effect_index.Schema.fromKey("counterparty_filter")),
8786
8805
  readableTransactionDescriptionFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.String)), effect_index.Schema.fromKey("readable_transaction_description_filter")),
8787
8806
  bankDirectionFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(BankDirectionFilterSchema)), effect_index.Schema.fromKey("bank_direction_filter")),
8807
+ amountMinFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_min_filter")),
8808
+ amountMaxFilter: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.Number)), effect_index.Schema.fromKey("amount_max_filter")),
8788
8809
  createdAt: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.Date), effect_index.Schema.fromKey("created_at")),
8789
8810
  updatedAt: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.Date), effect_index.Schema.fromKey("updated_at")),
8790
8811
  archivedAt: (0, effect_index.pipe)(effect_index.Schema.propertySignature(effect_index.Schema.NullishOr(effect_index.Schema.Date)), effect_index.Schema.fromKey("archived_at"))
@@ -9506,7 +9527,7 @@ var getBookkeepingStatus = get$1(({ businessId }) => {
9506
9527
  });
9507
9528
  var BOOKKEEPING_TAG_KEY = "#bookkeeping";
9508
9529
  var BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
9509
- function buildKey$87({ access_token: accessToken, apiUrl, businessId }) {
9530
+ function buildKey$88({ access_token: accessToken, apiUrl, businessId }) {
9510
9531
  if (accessToken && apiUrl) return {
9511
9532
  accessToken,
9512
9533
  apiUrl,
@@ -9517,7 +9538,7 @@ function buildKey$87({ access_token: accessToken, apiUrl, businessId }) {
9517
9538
  function useBookkeepingStatus() {
9518
9539
  const { data: auth } = useAuth();
9519
9540
  const { businessId } = useLayerContext();
9520
- return (0, swr.default)(() => buildKey$87(_objectSpread2(_objectSpread2({}, auth), {}, { businessId })), ({ accessToken, apiUrl, businessId }) => getBookkeepingStatus(apiUrl, accessToken, { params: { businessId } })().then(effect.Schema.decodeUnknownPromise(BookkeepingStatusResponseSchema)).then(({ data }) => data));
9541
+ return (0, swr.default)(() => buildKey$88(_objectSpread2(_objectSpread2({}, auth), {}, { businessId })), ({ accessToken, apiUrl, businessId }) => getBookkeepingStatus(apiUrl, accessToken, { params: { businessId } })().then(effect.Schema.decodeUnknownPromise(BookkeepingStatusResponseSchema)).then(({ data }) => data));
9521
9542
  }
9522
9543
  function useBookkeepingStatusGlobalCacheActions() {
9523
9544
  const { forceReload } = useGlobalCacheActions();
@@ -10736,7 +10757,7 @@ var BREAKPOINTS = {
10736
10757
  //#endregion
10737
10758
  //#region src/hooks/api/businesses/[business-id]/categories/useCategories.ts
10738
10759
  var CATEGORIES_TAG_KEY = "#categories";
10739
- function buildKey$86({ access_token: accessToken, apiUrl, businessId, mode }) {
10760
+ function buildKey$87({ access_token: accessToken, apiUrl, businessId, mode }) {
10740
10761
  if (accessToken && apiUrl) return {
10741
10762
  accessToken,
10742
10763
  apiUrl,
@@ -10752,7 +10773,7 @@ function useCategories({ mode } = {}) {
10752
10773
  const withLocale = useLocalizedKey();
10753
10774
  const { data: auth } = useAuth();
10754
10775
  const { businessId } = useLayerContext();
10755
- return (0, swr.default)(() => withLocale(buildKey$86(_objectSpread2(_objectSpread2({}, auth), {}, {
10776
+ return (0, swr.default)(() => withLocale(buildKey$87(_objectSpread2(_objectSpread2({}, auth), {}, {
10756
10777
  businessId,
10757
10778
  mode
10758
10779
  }))), ({ accessToken, apiUrl, businessId, mode }) => getCategories(apiUrl, accessToken, { params: {
@@ -10805,7 +10826,7 @@ var listCustomers = get$1(({ businessId, cursor, limit, query }) => {
10805
10826
  })}`;
10806
10827
  });
10807
10828
  var CUSTOMERS_TAG_KEY = "#customers";
10808
- function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
10829
+ function keyLoader$10(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
10809
10830
  if (!isEnabled) return;
10810
10831
  if (accessToken && apiUrl) {
10811
10832
  var _previousPageData$met;
@@ -10828,7 +10849,7 @@ function useListCustomers({ query, isEnabled = true } = {}) {
10828
10849
  const withLocale = useLocalizedKey();
10829
10850
  const { data } = useAuth();
10830
10851
  const { businessId } = useLayerContext();
10831
- const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$9(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
10852
+ const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$10(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
10832
10853
  businessId,
10833
10854
  query,
10834
10855
  isEnabled
@@ -10862,7 +10883,7 @@ function useCustomersGlobalCacheActions() {
10862
10883
  //#endregion
10863
10884
  //#region src/hooks/api/businesses/[business-id]/tags/dimensions/useTagDimensions.ts
10864
10885
  var TAG_DIMENSIONS_TAG_KEY = "#tag-dimensions";
10865
- function buildKey$85({ access_token: accessToken, apiUrl, businessId, isEnabled }) {
10886
+ function buildKey$86({ access_token: accessToken, apiUrl, businessId, isEnabled }) {
10866
10887
  if (!isEnabled) return;
10867
10888
  if (accessToken && apiUrl) return {
10868
10889
  accessToken,
@@ -10878,7 +10899,7 @@ function useTagDimensions({ isEnabled = true } = {}) {
10878
10899
  const { data: auth } = useAuth();
10879
10900
  const { apiUrl } = useEnvironment();
10880
10901
  const { businessId } = useLayerContext();
10881
- return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$85(_objectSpread2(_objectSpread2({}, auth), {}, {
10902
+ return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$86(_objectSpread2(_objectSpread2({}, auth), {}, {
10882
10903
  apiUrl,
10883
10904
  businessId,
10884
10905
  isEnabled
@@ -10902,7 +10923,7 @@ var listVendors = get$1(({ businessId, cursor, limit, query }) => {
10902
10923
  })}`;
10903
10924
  });
10904
10925
  var VENDORS_TAG_KEY = "#vendors";
10905
- function keyLoader$8(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
10926
+ function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
10906
10927
  if (!isEnabled) return;
10907
10928
  if (accessToken && apiUrl) {
10908
10929
  var _previousPageData$met;
@@ -10920,7 +10941,7 @@ function useListVendors({ query, isEnabled = true } = {}) {
10920
10941
  const withLocale = useLocalizedKey();
10921
10942
  const { data } = useAuth();
10922
10943
  const { businessId } = useLayerContext();
10923
- const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$8(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
10944
+ const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$9(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
10924
10945
  businessId,
10925
10946
  query,
10926
10947
  isEnabled
@@ -11281,7 +11302,7 @@ var getBankTransactionsExcel = get$1(({ businessId, categorized, direction, quer
11281
11302
  sortOrder
11282
11303
  })}`;
11283
11304
  });
11284
- function buildKey$84({ access_token: accessToken, apiUrl, businessId }) {
11305
+ function buildKey$85({ access_token: accessToken, apiUrl, businessId }) {
11285
11306
  if (accessToken && apiUrl) return {
11286
11307
  accessToken,
11287
11308
  apiUrl,
@@ -11293,7 +11314,7 @@ function useBankTransactionsDownload() {
11293
11314
  const withLocale = useLocalizedKey();
11294
11315
  const { data } = useAuth();
11295
11316
  const { businessId } = useLayerContext();
11296
- return (0, swr_mutation.default)(() => withLocale(buildKey$84(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { categorized, direction, query, startDate, endDate, tagFilterQueryString } }) => getBankTransactionsExcel(apiUrl, accessToken, { params: {
11317
+ return (0, swr_mutation.default)(() => withLocale(buildKey$85(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { categorized, direction, query, startDate, endDate, tagFilterQueryString } }) => getBankTransactionsExcel(apiUrl, accessToken, { params: {
11297
11318
  businessId,
11298
11319
  categorized,
11299
11320
  query,
@@ -12434,7 +12455,7 @@ var ProfitAndLossReportSchema = effect.Schema.Struct({
12434
12455
  //#endregion
12435
12456
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss/lines/useProfitAndLossDetailLines.tsx
12436
12457
  var LIST_PNL_DETAIL_LINES_TAG_KEY = "#list-pnl-detail-lines";
12437
- function keyLoader$7({ access_token: accessToken, apiUrl, businessId, startDate, endDate, pnlStructureLineItemName, tagFilter, reportingBasis, pnlStructure }) {
12458
+ function keyLoader$8({ access_token: accessToken, apiUrl, businessId, startDate, endDate, pnlStructureLineItemName, tagFilter, reportingBasis, pnlStructure }) {
12438
12459
  if (accessToken && apiUrl && businessId && startDate && endDate && pnlStructureLineItemName) return {
12439
12460
  accessToken,
12440
12461
  apiUrl,
@@ -12454,7 +12475,7 @@ function useProfitAndLossDetailLines({ startDate, endDate, pnlStructureLineItemN
12454
12475
  const { businessId } = useLayerContext();
12455
12476
  const { apiUrl } = useEnvironment();
12456
12477
  const { data: auth } = useAuth();
12457
- return new SWRQueryResult((0, swr.default)(() => withLocale(keyLoader$7(_objectSpread2(_objectSpread2({}, auth), {}, {
12478
+ return new SWRQueryResult((0, swr.default)(() => withLocale(keyLoader$8(_objectSpread2(_objectSpread2({}, auth), {}, {
12458
12479
  apiUrl,
12459
12480
  businessId,
12460
12481
  startDate,
@@ -12497,7 +12518,7 @@ var getProfitAndLossDetailLines = (apiUrl, accessToken, params) => {
12497
12518
  //#endregion
12498
12519
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss/useProfitAndLossReport.tsx
12499
12520
  var PNL_REPORT_TAG_KEY = "#profit-and-loss-report";
12500
- function buildKey$83({ access_token: accessToken, apiUrl, businessId, startDate, endDate, tagKey, tagValues, reportingBasis, includeUncategorized }) {
12521
+ function buildKey$84({ access_token: accessToken, apiUrl, businessId, startDate, endDate, tagKey, tagValues, reportingBasis, includeUncategorized }) {
12501
12522
  if (accessToken && apiUrl) return {
12502
12523
  accessToken,
12503
12524
  apiUrl,
@@ -12525,7 +12546,7 @@ function useProfitAndLossReport({ startDate, endDate, tagKey, tagValues, reporti
12525
12546
  const withLocale = useLocalizedKey();
12526
12547
  const { data } = useAuth();
12527
12548
  const { businessId } = useLayerContext();
12528
- return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$83(_objectSpread2(_objectSpread2({}, data), {}, {
12549
+ return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$84(_objectSpread2(_objectSpread2({}, data), {}, {
12529
12550
  businessId,
12530
12551
  startDate,
12531
12552
  endDate,
@@ -12550,7 +12571,7 @@ var useProfitAndLossReportCacheActions = () => {
12550
12571
  //#endregion
12551
12572
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss-comparison/useProfitAndLossComparisonReport.tsx
12552
12573
  var PNL_COMPARISON_REPORT_TAG_KEY = "#profit-and-loss-comparison-report";
12553
- function buildKey$82({ access_token: accessToken, apiUrl, businessId, periods, tagFilters, reportingBasis }) {
12574
+ function buildKey$83({ access_token: accessToken, apiUrl, businessId, periods, tagFilters, reportingBasis }) {
12554
12575
  if (accessToken && apiUrl && periods) return {
12555
12576
  accessToken,
12556
12577
  apiUrl,
@@ -12567,7 +12588,7 @@ function useProfitAndLossComparisonReport({ periods, tagFilters, reportingBasis
12567
12588
  const { data } = useAuth();
12568
12589
  const { businessId } = useLayerContext();
12569
12590
  const { apiUrl } = useEnvironment();
12570
- return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$82(_objectSpread2(_objectSpread2({}, data), {}, {
12591
+ return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$83(_objectSpread2(_objectSpread2({}, data), {}, {
12571
12592
  apiUrl,
12572
12593
  businessId,
12573
12594
  periods,
@@ -12589,7 +12610,7 @@ var useProfitAndLossComparisonReportCacheActions = () => {
12589
12610
  //#endregion
12590
12611
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss-summaries/useProfitAndLossSummaries.tsx
12591
12612
  var PNL_SUMMARIES_TAG_KEY = "#profit-and-loss-summaries";
12592
- function buildKey$81({ access_token: accessToken, apiUrl, businessId, startMonth, startYear, endMonth, endYear, tagKey, tagValues, reportingBasis }) {
12613
+ function buildKey$82({ access_token: accessToken, apiUrl, businessId, startMonth, startYear, endMonth, endYear, tagKey, tagValues, reportingBasis }) {
12593
12614
  if (accessToken && apiUrl) return {
12594
12615
  accessToken,
12595
12616
  apiUrl,
@@ -12619,7 +12640,7 @@ function useProfitAndLossSummaries({ startYear, startMonth, endYear, endMonth, t
12619
12640
  const withLocale = useLocalizedKey();
12620
12641
  const { data } = useAuth();
12621
12642
  const { businessId } = useLayerContext();
12622
- return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$81(_objectSpread2(_objectSpread2({}, data), {}, {
12643
+ return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$82(_objectSpread2(_objectSpread2({}, data), {}, {
12623
12644
  businessId,
12624
12645
  startYear,
12625
12646
  startMonth,
@@ -12682,7 +12703,7 @@ var CategorizeTransactionRequestSchema$1 = effect.Schema.Struct({
12682
12703
  });
12683
12704
  var BulkCategorizeRequestSchema = effect.Schema.Struct({ transactions: effect.Schema.Array(CategorizeTransactionRequestSchema$1) });
12684
12705
  var bulkCategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-categorize`);
12685
- function buildKey$80({ access_token: accessToken, apiUrl, businessId }) {
12706
+ function buildKey$81({ access_token: accessToken, apiUrl, businessId }) {
12686
12707
  if (accessToken && apiUrl) return {
12687
12708
  accessToken,
12688
12709
  apiUrl,
@@ -12696,7 +12717,7 @@ var useBulkCategorize = () => {
12696
12717
  const { businessId, eventCallbacks } = useLayerContext();
12697
12718
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
12698
12719
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
12699
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$80(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkCategorize(apiUrl, accessToken, {
12720
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$81(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkCategorize(apiUrl, accessToken, {
12700
12721
  params: { businessId },
12701
12722
  body: effect.Schema.encodeSync(BulkCategorizeRequestSchema)(arg)
12702
12723
  }).then(({ data }) => data), {
@@ -13356,7 +13377,7 @@ var AlertCircle$1 = (_ref) => {
13356
13377
  //#endregion
13357
13378
  //#region src/icons/Save.tsx
13358
13379
  var _excluded$97 = ["size"];
13359
- var Save$7 = (_ref) => {
13380
+ var Save$8 = (_ref) => {
13360
13381
  let { size = 18 } = _ref;
13361
13382
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", _objectSpread2(_objectSpread2({
13362
13383
  xmlns: "http://www.w3.org/2000/svg",
@@ -13445,7 +13466,7 @@ var buildRightIcon = ({ processing, error, action, noIcon }) => {
13445
13466
  });
13446
13467
  if (action === SubmitAction.UPLOAD) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.UploadCloud, { size: 12 });
13447
13468
  if (action === SubmitAction.UPDATE) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckCircle$2, { size: 14 });
13448
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Save$7, { size: 16 });
13469
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Save$8, { size: 16 });
13449
13470
  };
13450
13471
  var SubmitButton = (_ref) => {
13451
13472
  let { active, className, processing, disabled, error, children, action = SubmitAction.SAVE, noIcon, variant = ButtonVariant.primary, withRetry, iconAsPrimary = true } = _ref, props = _objectWithoutProperties(_ref, _excluded$95);
@@ -13812,7 +13833,7 @@ function useComboBoxSubcomponents({ placeholder, slots, displayDisabledAsSelecte
13812
13833
  }
13813
13834
  //#endregion
13814
13835
  //#region src/components/ui/ComboBox/useCommonComboBoxProps.ts
13815
- function useCommonComboBoxProps({ className, options, groups, onInputValueChange, inputId, placeholder, slots, displayDisabledAsSelected, isDisabled, isError, isReadOnly = false, isClearable = true, isSearchable = true, isLoading, isMutating, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby }) {
13836
+ function useCommonComboBoxProps({ className, options, groups, onInputValueChange, inputId, placeholder, slots, displayDisabledAsSelected, isDisabled, isError, isReadOnly = false, isClearable = true, isSearchable = true, isLoading, isMutating, filterOption, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby }) {
13816
13837
  const internalInputId = (0, react.useId)();
13817
13838
  const effectiveInputId = inputId !== null && inputId !== void 0 ? inputId : internalInputId;
13818
13839
  const components = useComboBoxSubcomponents({
@@ -13850,6 +13871,7 @@ function useCommonComboBoxProps({ className, options, groups, onInputValueChange
13850
13871
  openMenuOnClick: !isReadOnly,
13851
13872
  menuPlacement: "auto",
13852
13873
  menuShouldScrollIntoView: false,
13874
+ filterOption,
13853
13875
  ["aria-label"]: ariaLabel,
13854
13876
  ["aria-labelledby"]: ariaLabelledby,
13855
13877
  ["aria-describedby"]: ariaDescribedby
@@ -13860,6 +13882,7 @@ function useCommonComboBoxProps({ className, options, groups, onInputValueChange
13860
13882
  className,
13861
13883
  components,
13862
13884
  effectiveInputId,
13885
+ filterOption,
13863
13886
  groups,
13864
13887
  isClearable,
13865
13888
  isDisabled,
@@ -15204,7 +15227,7 @@ effect.Schema.Struct({ businessId: effect.Schema.String });
15204
15227
  var bulkMatchOrCategorize = post(({ businessId }) => {
15205
15228
  return `/v1/businesses/${businessId}/bank-transactions/bulk-match-or-categorize`;
15206
15229
  });
15207
- function buildKey$79({ access_token: accessToken, apiUrl, businessId }) {
15230
+ function buildKey$80({ access_token: accessToken, apiUrl, businessId }) {
15208
15231
  if (accessToken && apiUrl) return {
15209
15232
  accessToken,
15210
15233
  apiUrl,
@@ -15223,7 +15246,7 @@ var useBulkMatchOrCategorize = () => {
15223
15246
  const buildTransactionsPayload = (0, react.useCallback)(() => {
15224
15247
  return { transactions: buildBulkMatchOrCategorizePayload(selectedIds, categorizations) };
15225
15248
  }, [selectedIds, categorizations]);
15226
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$79(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkMatchOrCategorize(apiUrl, accessToken, {
15249
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$80(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkMatchOrCategorize(apiUrl, accessToken, {
15227
15250
  params: { businessId },
15228
15251
  body: effect.Schema.encodeSync(BulkMatchOrCategorizeRequestSchema)(arg)
15229
15252
  }).then(({ data }) => data), {
@@ -15310,7 +15333,7 @@ var BankTransactionsConfirmAllModal = ({ isOpen, onOpenChange, isMobileView = fa
15310
15333
  var BULK_UNCATEGORIZE_BANK_TRANSACTIONS_TAG_KEY = "#bulk-uncategorize-bank-transactions";
15311
15334
  var BulkUncategorizeRequestSchema = effect.Schema.Struct({ transactionIds: effect.Schema.propertySignature(effect.Schema.Array(effect.Schema.UUID)).pipe(effect.Schema.fromKey("transaction_ids")) });
15312
15335
  var bulkUncategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-uncategorize`);
15313
- function buildKey$78({ access_token: accessToken, apiUrl, businessId }) {
15336
+ function buildKey$79({ access_token: accessToken, apiUrl, businessId }) {
15314
15337
  if (accessToken && apiUrl) return {
15315
15338
  accessToken,
15316
15339
  apiUrl,
@@ -15324,7 +15347,7 @@ var useBulkUncategorize = () => {
15324
15347
  const { businessId, eventCallbacks } = useLayerContext();
15325
15348
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
15326
15349
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
15327
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$78(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkUncategorize(apiUrl, accessToken, {
15350
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$79(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkUncategorize(apiUrl, accessToken, {
15328
15351
  params: { businessId },
15329
15352
  body: effect.Schema.encodeSync(BulkUncategorizeRequestSchema)(arg)
15330
15353
  }).then(({ data }) => data), {
@@ -15706,7 +15729,7 @@ var mapRawCustomAccountToCustomAccount = (raw) => ({
15706
15729
  //#endregion
15707
15730
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/useCustomAccounts.ts
15708
15731
  var CUSTOM_ACCOUNTS_TAG_KEY = "#custom-accounts";
15709
- function buildKey$77({ access_token: accessToken, apiUrl, businessId, userCreated }) {
15732
+ function buildKey$78({ access_token: accessToken, apiUrl, businessId, userCreated }) {
15710
15733
  if (accessToken && apiUrl) return {
15711
15734
  accessToken,
15712
15735
  apiUrl,
@@ -15724,7 +15747,7 @@ function useCustomAccounts({ userCreated } = {}) {
15724
15747
  const withLocale = useLocalizedKey();
15725
15748
  const { data } = useAuth();
15726
15749
  const { businessId } = useLayerContext();
15727
- return (0, swr.default)(() => withLocale(buildKey$77(_objectSpread2(_objectSpread2({}, data), {}, {
15750
+ return (0, swr.default)(() => withLocale(buildKey$78(_objectSpread2(_objectSpread2({}, data), {}, {
15728
15751
  businessId,
15729
15752
  userCreated
15730
15753
  }))), ({ accessToken, apiUrl, businessId, userCreated }) => getCustomAccounts(apiUrl, accessToken, { params: {
@@ -15734,7 +15757,7 @@ function useCustomAccounts({ userCreated } = {}) {
15734
15757
  }
15735
15758
  //#endregion
15736
15759
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/[custom-account-id]/parse-csv/useCustomAccountParseCsv.ts
15737
- function buildKey$76({ access_token: accessToken, apiUrl, businessId }) {
15760
+ function buildKey$77({ access_token: accessToken, apiUrl, businessId }) {
15738
15761
  if (accessToken && apiUrl) return {
15739
15762
  accessToken,
15740
15763
  apiUrl,
@@ -15751,7 +15774,7 @@ function useCustomAccountParseCsv() {
15751
15774
  const withLocale = useLocalizedKey();
15752
15775
  const { data } = useAuth();
15753
15776
  const { businessId } = useLayerContext();
15754
- return (0, swr_mutation.default)(() => withLocale(buildKey$76(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { customAccountId, file } }) => parseCsv(apiUrl, accessToken, {
15777
+ return (0, swr_mutation.default)(() => withLocale(buildKey$77(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { customAccountId, file } }) => parseCsv(apiUrl, accessToken, {
15755
15778
  businessId,
15756
15779
  customAccountId,
15757
15780
  file
@@ -16033,7 +16056,7 @@ get$1(({ businessId }) => `/v1/businesses/${businessId}/external-accounts`);
16033
16056
  //#endregion
16034
16057
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/useCreateCustomAccount.ts
16035
16058
  var createCustomAccount = post(({ businessId }) => `/v1/businesses/${businessId}/custom-accounts`);
16036
- function buildKey$75({ access_token: accessToken, apiUrl, businessId }) {
16059
+ function buildKey$76({ access_token: accessToken, apiUrl, businessId }) {
16037
16060
  if (accessToken && apiUrl) return {
16038
16061
  accessToken,
16039
16062
  apiUrl,
@@ -16046,7 +16069,7 @@ function useCreateCustomAccount() {
16046
16069
  const { data } = useAuth();
16047
16070
  const { businessId } = useLayerContext();
16048
16071
  const { mutate } = (0, swr.useSWRConfig)();
16049
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$75(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: body }) => createCustomAccount(apiUrl, accessToken, {
16072
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$76(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: body }) => createCustomAccount(apiUrl, accessToken, {
16050
16073
  params: { businessId },
16051
16074
  body
16052
16075
  }).then(({ data }) => mapRawCustomAccountToCustomAccount(data)), { revalidate: false });
@@ -16766,6 +16789,12 @@ var fromNonRecursiveBigDecimal = (nrbd) => {
16766
16789
  var nrbdEquals = (a, b) => {
16767
16790
  return effect.BigDecimal.equals(fromNonRecursiveBigDecimal(a), fromNonRecursiveBigDecimal(b));
16768
16791
  };
16792
+ var convertCentsToNonRecursiveBigDecimal = (cents) => {
16793
+ return toNonRecursiveBigDecimal(convertCentsToBigDecimal(cents));
16794
+ };
16795
+ var convertNonRecursiveBigDecimalToCents = (nrbd) => {
16796
+ return convertBigDecimalToCents(fromNonRecursiveBigDecimal(nrbd));
16797
+ };
16769
16798
  //#endregion
16770
16799
  //#region src/components/forms/FormNonRecursiveBigDecimalField.tsx
16771
16800
  var _excluded$69 = [
@@ -17622,7 +17651,7 @@ function UploadTransactionsUploadCsvStep({ selectedAccount, onSelectAccount, sel
17622
17651
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/[custom-account-id]/transactions/useCreateCustomAccountTransactions.ts
17623
17652
  var _excluded$58 = ["customAccountId"];
17624
17653
  var createCustomAccountTransactions = post(({ businessId, customAccountId }) => `/v1/businesses/${businessId}/custom-accounts/${customAccountId}/transactions`);
17625
- function buildKey$74({ access_token: accessToken, apiUrl, businessId }) {
17654
+ function buildKey$75({ access_token: accessToken, apiUrl, businessId }) {
17626
17655
  if (accessToken && apiUrl) return {
17627
17656
  accessToken,
17628
17657
  apiUrl,
@@ -17634,7 +17663,7 @@ function useCreateCustomAccountTransactions() {
17634
17663
  const withLocale = useLocalizedKey();
17635
17664
  const { data } = useAuth();
17636
17665
  const { businessId } = useLayerContext();
17637
- return (0, swr_mutation.default)(() => withLocale(buildKey$74(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, _ref) => {
17666
+ return (0, swr_mutation.default)(() => withLocale(buildKey$75(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, _ref) => {
17638
17667
  let { arg: _ref2 } = _ref, { customAccountId } = _ref2, body = _objectWithoutProperties(_ref2, _excluded$58);
17639
17668
  return createCustomAccountTransactions(apiUrl, accessToken, {
17640
17669
  params: {
@@ -19110,7 +19139,7 @@ var useGetBankTransactionMatchOrCategoryWithDefault = (bankTransaction) => {
19110
19139
  var _excluded$56 = ["bankTransactionId"];
19111
19140
  var CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
19112
19141
  var categorizeBankTransaction = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`);
19113
- function buildKey$73({ access_token: accessToken, apiUrl, businessId }) {
19142
+ function buildKey$74({ access_token: accessToken, apiUrl, businessId }) {
19114
19143
  if (accessToken && apiUrl) return {
19115
19144
  accessToken,
19116
19145
  apiUrl,
@@ -19126,7 +19155,7 @@ function useCategorizeBankTransaction() {
19126
19155
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
19127
19156
  const { useBankTransactionsOptions } = useBankTransactionsContext();
19128
19157
  const { forceReloadBackgroundBankTransactions } = useBankTransactionsGlobalCacheActions();
19129
- const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$73({
19158
+ const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$74({
19130
19159
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
19131
19160
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
19132
19161
  businessId
@@ -19204,7 +19233,7 @@ function useCategorizeBankTransactionWithCacheUpdate() {
19204
19233
  var _excluded$55 = ["bankTransactionId"];
19205
19234
  var matchBankTransaction = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/match`);
19206
19235
  var MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
19207
- function buildKey$72({ access_token: accessToken, apiUrl, businessId }) {
19236
+ function buildKey$73({ access_token: accessToken, apiUrl, businessId }) {
19208
19237
  if (accessToken && apiUrl) return {
19209
19238
  accessToken,
19210
19239
  apiUrl,
@@ -19220,7 +19249,7 @@ function useMatchBankTransaction() {
19220
19249
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
19221
19250
  const { useBankTransactionsOptions } = useBankTransactionsContext();
19222
19251
  const { forceReloadBackgroundBankTransactions } = useBankTransactionsGlobalCacheActions();
19223
- const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$72({
19252
+ const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$73({
19224
19253
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
19225
19254
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
19226
19255
  businessId
@@ -19613,7 +19642,7 @@ var getBookkeepingPeriods = get$1(({ businessId }) => {
19613
19642
  return `/v1/businesses/${businessId}/bookkeeping/periods`;
19614
19643
  });
19615
19644
  var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
19616
- function buildKey$71({ access_token: accessToken, apiUrl, businessId, isActiveOrPaused }) {
19645
+ function buildKey$72({ access_token: accessToken, apiUrl, businessId, isActiveOrPaused }) {
19617
19646
  if (accessToken && apiUrl && isActiveOrPaused) return {
19618
19647
  accessToken,
19619
19648
  apiUrl,
@@ -19627,7 +19656,7 @@ function useBookkeepingPeriods() {
19627
19656
  const { businessId } = useLayerContext();
19628
19657
  const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
19629
19658
  const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
19630
- const swrResponse = (0, swr.default)(() => withLocale(buildKey$71(_objectSpread2(_objectSpread2({}, auth), {}, {
19659
+ const swrResponse = (0, swr.default)(() => withLocale(buildKey$72(_objectSpread2(_objectSpread2({}, auth), {}, {
19631
19660
  businessId,
19632
19661
  isActiveOrPaused
19633
19662
  }))), ({ accessToken, apiUrl, businessId }) => getBookkeepingPeriods(apiUrl, accessToken, { params: { businessId } })().then(({ data: { periods } }) => periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, {
@@ -19800,7 +19829,7 @@ function useMinMutatingMutation({ swrMutationResponse, minMutatingMs }) {
19800
19829
  //#endregion
19801
19830
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useSetMetadataOnBankTransaction.ts
19802
19831
  var SET_METADATA_ON_BANK_TRANSACTION_TAG_KEY = "#set-metadata-on-bank-transaction";
19803
- function buildKey$70({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19832
+ function buildKey$71({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19804
19833
  if (accessToken && apiUrl) return {
19805
19834
  accessToken,
19806
19835
  apiUrl,
@@ -19814,7 +19843,7 @@ function useSetMetadataOnBankTransaction({ bankTransactionId }) {
19814
19843
  const withLocale = useLocalizedKey();
19815
19844
  const { data } = useAuth();
19816
19845
  const { businessId } = useLayerContext();
19817
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$70(_objectSpread2(_objectSpread2({}, data), {}, {
19846
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$71(_objectSpread2(_objectSpread2({}, data), {}, {
19818
19847
  businessId,
19819
19848
  bankTransactionId
19820
19849
  }))), ({ accessToken, apiUrl, businessId, bankTransactionId }, { arg: { vendor, customer } }) => {
@@ -19863,7 +19892,7 @@ function useSetMetadataOnBankTransaction({ bankTransactionId }) {
19863
19892
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/tags/useRemoveTagFromBankTransaction.ts
19864
19893
  var REMOVE_TAG_FROM_BANK_TRANSACTION_TAG_KEY = "#remove-tag-from-bank-transaction";
19865
19894
  var removeTagFromBankTransaction = del(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
19866
- function buildKey$69({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19895
+ function buildKey$70({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19867
19896
  if (accessToken && apiUrl) return {
19868
19897
  accessToken,
19869
19898
  apiUrl,
@@ -19876,7 +19905,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
19876
19905
  const withLocale = useLocalizedKey();
19877
19906
  const { data } = useAuth();
19878
19907
  const { businessId } = useLayerContext();
19879
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$69(_objectSpread2(_objectSpread2({}, data), {}, {
19908
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$70(_objectSpread2(_objectSpread2({}, data), {}, {
19880
19909
  businessId,
19881
19910
  bankTransactionId
19882
19911
  }))), ({ accessToken, apiUrl, businessId }, { arg: { tagId } }) => removeTagFromBankTransaction(apiUrl, accessToken, {
@@ -19915,7 +19944,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
19915
19944
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/tags/useTagBankTransaction.ts
19916
19945
  var TAG_BANK_TRANSACTION_TAG_KEY = "#tag-bank-transaction";
19917
19946
  var tagBankTransaction = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
19918
- function buildKey$68({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19947
+ function buildKey$69({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
19919
19948
  if (accessToken && apiUrl) return {
19920
19949
  accessToken,
19921
19950
  apiUrl,
@@ -19928,7 +19957,7 @@ function useTagBankTransaction({ bankTransactionId }) {
19928
19957
  const withLocale = useLocalizedKey();
19929
19958
  const { data } = useAuth();
19930
19959
  const { businessId } = useLayerContext();
19931
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$68(_objectSpread2(_objectSpread2({}, data), {}, {
19960
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$69(_objectSpread2(_objectSpread2({}, data), {}, {
19932
19961
  businessId,
19933
19962
  bankTransactionId
19934
19963
  }))), ({ accessToken, apiUrl, businessId, bankTransactionId }, { arg: { key, value, dimensionDisplayName, valueDisplayName } }) => tagBankTransaction(apiUrl, accessToken, {
@@ -20495,7 +20524,7 @@ function BankTransactionCustomerVendorSelector({ bankTransaction }) {
20495
20524
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useBankTransactionsMetadata.ts
20496
20525
  var getBankTransactionMetadata = get$1(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/metadata`);
20497
20526
  var GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
20498
- function buildKey$67({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
20527
+ function buildKey$68({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
20499
20528
  if (accessToken && apiUrl) return {
20500
20529
  accessToken,
20501
20530
  apiUrl,
@@ -20508,7 +20537,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
20508
20537
  const withLocale = useLocalizedKey();
20509
20538
  const { data: auth } = useAuth();
20510
20539
  const { businessId } = useLayerContext();
20511
- return (0, swr.default)(() => withLocale(buildKey$67(_objectSpread2(_objectSpread2({}, auth), {}, {
20540
+ return (0, swr.default)(() => withLocale(buildKey$68(_objectSpread2(_objectSpread2({}, auth), {}, {
20512
20541
  businessId,
20513
20542
  bankTransactionId
20514
20543
  }))), ({ accessToken, apiUrl, businessId }) => getBankTransactionMetadata(apiUrl, accessToken, { params: {
@@ -20520,7 +20549,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
20520
20549
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useUpdateBankTransactionMetadata.ts
20521
20550
  var updateBankTransactionMetadata = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/metadata`);
20522
20551
  var UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
20523
- function buildKey$66({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
20552
+ function buildKey$67({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
20524
20553
  if (accessToken && apiUrl) return {
20525
20554
  accessToken,
20526
20555
  apiUrl,
@@ -20534,7 +20563,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
20534
20563
  const { data: auth } = useAuth();
20535
20564
  const { businessId } = useLayerContext();
20536
20565
  const { mutate } = (0, swr.useSWRConfig)();
20537
- const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$66({
20566
+ const mutationResponse = new SWRMutationResult((0, swr_mutation.default)(() => withLocale(buildKey$67({
20538
20567
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
20539
20568
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
20540
20569
  businessId,
@@ -20667,7 +20696,7 @@ var BankTransactionMemo = ({ bankTransactionId, isMobile }) => {
20667
20696
  //#endregion
20668
20697
  //#region src/hooks/api/businesses/[business-id]/tags/dimensions/key/[dimension-key]/useTagDimensionByKey.ts
20669
20698
  var TAG_DIMENSION_BY_KEY_TAG_KEY = "#tag-dimension-by-key";
20670
- function buildKey$65({ access_token: accessToken, apiUrl, businessId, isEnabled, dimensionKey }) {
20699
+ function buildKey$66({ access_token: accessToken, apiUrl, businessId, isEnabled, dimensionKey }) {
20671
20700
  if (!isEnabled) return;
20672
20701
  if (accessToken && apiUrl) return {
20673
20702
  accessToken,
@@ -20683,7 +20712,7 @@ function useTagDimensionByKey({ isEnabled = true, dimensionKey }) {
20683
20712
  const { data: auth } = useAuth();
20684
20713
  const { apiUrl } = useEnvironment();
20685
20714
  const { businessId } = useLayerContext();
20686
- return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$65(_objectSpread2(_objectSpread2({}, auth), {}, {
20715
+ return new SWRQueryResult((0, swr.default)(() => withLocale(buildKey$66(_objectSpread2(_objectSpread2({}, auth), {}, {
20687
20716
  apiUrl,
20688
20717
  isEnabled,
20689
20718
  businessId,
@@ -23336,10 +23365,10 @@ var BankTransactionsTable = ({ isLoading, bankTransactions, showDescriptions, sh
23336
23365
  //#endregion
23337
23366
  //#region src/hooks/api/businesses/[business-id]/categorization-rules/useListCategorizationRules.ts
23338
23367
  var LIST_CATEGORIZATION_RULES_TAG_KEY = "#list-categorization-rules";
23339
- var SortBy$1 = /* @__PURE__ */ function(SortBy) {
23368
+ var SortBy$2 = /* @__PURE__ */ function(SortBy) {
23340
23369
  SortBy["CreatedAt"] = "created_at";
23341
23370
  return SortBy;
23342
- }(SortBy$1 || {});
23371
+ }(SortBy$2 || {});
23343
23372
  var ListCategorizationRulesReturnSchema = effect.Schema.Struct({
23344
23373
  data: effect.Schema.Array(CategorizationRuleSchema),
23345
23374
  meta: effect.Schema.Struct({ pagination: PaginatedResponseMetaSchema })
@@ -23366,7 +23395,7 @@ var listCategorizationRules = get$1(({ businessId, externalIds, includeArchived,
23366
23395
  const baseUrl = `/v1/businesses/${businessId}/categorization-rules`;
23367
23396
  return parameters ? `${baseUrl}?${parameters}` : baseUrl;
23368
23397
  });
23369
- function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, includeArchived, sortBy, sortOrder, limit, showTotalCount }) {
23398
+ function keyLoader$7(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, includeArchived, sortBy, sortOrder, limit, showTotalCount }) {
23370
23399
  if (accessToken && apiUrl) {
23371
23400
  var _previousPageData$met;
23372
23401
  return {
@@ -23384,12 +23413,12 @@ function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, busi
23384
23413
  };
23385
23414
  }
23386
23415
  }
23387
- function useListCategorizationRules({ externalIds, includeArchived, sortBy = SortBy$1.CreatedAt, sortOrder = SortOrder.DESC, limit, showTotalCount = true } = {}) {
23416
+ function useListCategorizationRules({ externalIds, includeArchived, sortBy = SortBy$2.CreatedAt, sortOrder = SortOrder.DESC, limit, showTotalCount = true } = {}) {
23388
23417
  const withLocale = useLocalizedKey();
23389
23418
  const { businessId } = useLayerContext();
23390
23419
  const { apiUrl } = useEnvironment();
23391
23420
  const { data: auth } = useAuth();
23392
- const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$6(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
23421
+ const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$7(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
23393
23422
  apiUrl,
23394
23423
  businessId,
23395
23424
  externalIds,
@@ -23429,7 +23458,7 @@ function useCategorizationRulesGlobalCacheActions() {
23429
23458
  //#endregion
23430
23459
  //#region src/hooks/api/businesses/[business-id]/categorization-rules/[categorization-rule-id]/archive/useArchiveCategorizationRule.ts
23431
23460
  var ARCHIVE_CATEGORIZATION_RULE_TAG = "#archive-categorization-rule";
23432
- function buildKey$64({ access_token: accessToken, apiUrl, businessId }) {
23461
+ function buildKey$65({ access_token: accessToken, apiUrl, businessId }) {
23433
23462
  if (accessToken && apiUrl) return {
23434
23463
  accessToken,
23435
23464
  apiUrl,
@@ -23444,7 +23473,7 @@ function useArchiveCategorizationRule() {
23444
23473
  const { data: auth } = useAuth();
23445
23474
  const { businessId } = useLayerContext();
23446
23475
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
23447
- const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$64({
23476
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$65({
23448
23477
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
23449
23478
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
23450
23479
  businessId
@@ -23519,6 +23548,691 @@ var BaseDetailView = ({ name, onGoBack, slots, children, borderless = false }) =
23519
23548
  });
23520
23549
  };
23521
23550
  //#endregion
23551
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategoryMobileDrawer.tsx
23552
+ var CategoryMobileDrawer = ({ label, value, onValueChange, showLabel }) => {
23553
+ const { data: categories } = useCategories();
23554
+ const flatOptions = (0, react.useMemo)(() => {
23555
+ if (!categories) return [];
23556
+ return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
23557
+ }, [categories]);
23558
+ const selectedOption = (0, react.useMemo)(() => {
23559
+ var _flatOptions$find;
23560
+ if (!value) return null;
23561
+ return (_flatOptions$find = flatOptions.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _flatOptions$find !== void 0 ? _flatOptions$find : null;
23562
+ }, [flatOptions, value]);
23563
+ const handleSelectedValueChange = (0, react.useCallback)((option) => {
23564
+ onValueChange(option instanceof CategoryAsOption ? option.classification : null);
23565
+ }, [onValueChange]);
23566
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
23567
+ gap: "3xs",
23568
+ children: [showLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label$1, {
23569
+ size: "sm",
23570
+ children: label
23571
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorySelectDrawerWithTrigger, {
23572
+ selectedValue: selectedOption,
23573
+ onSelectedValueChange: handleSelectedValueChange,
23574
+ showTooltips: false,
23575
+ slotProps: { TriggerSpan: { size: "sm" } }
23576
+ })]
23577
+ });
23578
+ };
23579
+ //#endregion
23580
+ //#region src/components/LedgerAccountCombobox/LedgerAccountCombobox.tsx
23581
+ var LedgerAccountCombobox = ({ label, value, mode, onValueChange, isReadOnly, showLabel, className }) => {
23582
+ const { data: categories, isLoading } = useCategories({ mode });
23583
+ const options = (0, react.useMemo)(() => {
23584
+ if (!categories) return [];
23585
+ return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
23586
+ }, [categories]);
23587
+ const selectedCategory = (0, react.useMemo)(() => {
23588
+ var _options$find;
23589
+ if (!value) return null;
23590
+ return (_options$find = options.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _options$find !== void 0 ? _options$find : null;
23591
+ }, [options, value]);
23592
+ const onSelectedValueChange = (0, react.useCallback)((option) => {
23593
+ var _option$classificatio;
23594
+ onValueChange((_option$classificatio = option === null || option === void 0 ? void 0 : option.classification) !== null && _option$classificatio !== void 0 ? _option$classificatio : null);
23595
+ }, [onValueChange]);
23596
+ const inputId = (0, react.useId)();
23597
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
23598
+ gap: "3xs",
23599
+ className,
23600
+ children: [showLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label$1, {
23601
+ size: "sm",
23602
+ htmlFor: inputId,
23603
+ children: label
23604
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComboBox, _objectSpread2({
23605
+ options,
23606
+ onSelectedValueChange,
23607
+ selectedValue: selectedCategory,
23608
+ inputId,
23609
+ isReadOnly,
23610
+ isLoading,
23611
+ isClearable: false
23612
+ }, !showLabel && { "aria-label": label }))]
23613
+ });
23614
+ };
23615
+ //#endregion
23616
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorySelect.tsx
23617
+ var CategorySelect = (props) => {
23618
+ const { isMobile } = useSizeClass();
23619
+ if (isMobile) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryMobileDrawer, _objectSpread2({}, props));
23620
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerAccountCombobox, {
23621
+ label: props.label,
23622
+ value: props.value,
23623
+ onValueChange: props.onValueChange,
23624
+ mode: CategoriesListMode.All,
23625
+ showLabel: props.showLabel
23626
+ });
23627
+ };
23628
+ //#endregion
23629
+ //#region src/hooks/api/businesses/[business-id]/counterparties/useListCounterparties.ts
23630
+ var LIST_COUNTERPARTIES_TAG_KEY = "#list-counterparties";
23631
+ var SortBy$1 = /* @__PURE__ */ function(SortBy) {
23632
+ SortBy["Name"] = "name";
23633
+ return SortBy;
23634
+ }(SortBy$1 || {});
23635
+ var ListCounterpartiesReturnSchema = effect.Schema.Struct({
23636
+ data: effect.Schema.Array(BankTransactionCounterpartySchema),
23637
+ meta: effect.Schema.Struct({ pagination: PaginatedResponseMetaSchema })
23638
+ });
23639
+ var ListCounterpartiesSWRResponse = class extends SWRInfiniteResult {
23640
+ get paginationMeta() {
23641
+ return this.data && this.data.length > 0 ? this.data[this.data.length - 1].meta.pagination : void 0;
23642
+ }
23643
+ get hasMore() {
23644
+ var _this$paginationMeta;
23645
+ return (_this$paginationMeta = this.paginationMeta) === null || _this$paginationMeta === void 0 ? void 0 : _this$paginationMeta.hasMore;
23646
+ }
23647
+ };
23648
+ var listCounterparties = get$1(({ businessId, externalIds, q, sortBy, sortOrder, cursor, limit, showTotalCount }) => {
23649
+ const parameters = toDefinedSearchParameters({
23650
+ externalIds,
23651
+ q,
23652
+ sortBy,
23653
+ sortOrder,
23654
+ cursor,
23655
+ limit,
23656
+ showTotalCount
23657
+ });
23658
+ const baseUrl = `/v1/businesses/${businessId}/counterparties`;
23659
+ return parameters ? `${baseUrl}?${parameters}` : baseUrl;
23660
+ });
23661
+ function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, q, sortBy, sortOrder, limit, showTotalCount }) {
23662
+ if (accessToken && apiUrl) {
23663
+ var _previousPageData$met;
23664
+ return {
23665
+ accessToken,
23666
+ apiUrl,
23667
+ businessId,
23668
+ externalIds,
23669
+ q,
23670
+ cursor: previousPageData === null || previousPageData === void 0 || (_previousPageData$met = previousPageData.meta) === null || _previousPageData$met === void 0 ? void 0 : _previousPageData$met.pagination.cursor,
23671
+ sortBy,
23672
+ sortOrder,
23673
+ limit,
23674
+ showTotalCount,
23675
+ tags: [LIST_COUNTERPARTIES_TAG_KEY]
23676
+ };
23677
+ }
23678
+ }
23679
+ function useListCounterparties({ externalIds, q, sortBy = SortBy$1.Name, sortOrder = SortOrder.ASC, limit, showTotalCount = true } = {}) {
23680
+ const withLocale = useLocalizedKey();
23681
+ const { businessId } = useLayerContext();
23682
+ const { apiUrl } = useEnvironment();
23683
+ const { data: auth } = useAuth();
23684
+ const swrResponse = (0, swr_infinite.default)((_index, previousPageData) => withLocale(keyLoader$6(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
23685
+ apiUrl,
23686
+ businessId,
23687
+ externalIds,
23688
+ q,
23689
+ sortBy,
23690
+ sortOrder,
23691
+ limit,
23692
+ showTotalCount
23693
+ }))), ({ accessToken, apiUrl, businessId, cursor, externalIds, q, sortBy, sortOrder, limit, showTotalCount }) => listCounterparties(apiUrl, accessToken, { params: {
23694
+ businessId,
23695
+ externalIds,
23696
+ q,
23697
+ sortBy,
23698
+ sortOrder,
23699
+ cursor,
23700
+ limit,
23701
+ showTotalCount
23702
+ } })().then(effect.Schema.decodeUnknownPromise(ListCounterpartiesReturnSchema)), {
23703
+ keepPreviousData: true,
23704
+ revalidateFirstPage: false,
23705
+ initialSize: 1
23706
+ });
23707
+ usePreserveInfiniteSize(swrResponse);
23708
+ return new ListCounterpartiesSWRResponse(swrResponse);
23709
+ }
23710
+ //#endregion
23711
+ //#region src/components/CategorizationRules/CategorizationRuleForm/counterpartyComboBoxOption.ts
23712
+ var CounterpartyComboBoxOption = class extends BaseComboBoxOption {
23713
+ constructor(counterparty) {
23714
+ super(counterparty);
23715
+ }
23716
+ get original() {
23717
+ return this.internalValue;
23718
+ }
23719
+ get label() {
23720
+ var _this$internalValue$n;
23721
+ return (_this$internalValue$n = this.internalValue.name) !== null && _this$internalValue$n !== void 0 ? _this$internalValue$n : this.internalValue.id;
23722
+ }
23723
+ get value() {
23724
+ return this.internalValue.id;
23725
+ }
23726
+ };
23727
+ //#endregion
23728
+ //#region src/components/CategorizationRules/CategorizationRuleForm/useCounterpartyOptions.ts
23729
+ var useCounterpartyOptions = (value) => {
23730
+ const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: "" });
23731
+ const { data, isLoading, isError } = useListCounterparties({
23732
+ q: searchQuery || void 0,
23733
+ limit: 50
23734
+ });
23735
+ const fetchedOptions = (0, react.useMemo)(() => {
23736
+ if (!data) return [];
23737
+ return data.flatMap(({ data: page }) => page.map((counterparty) => new CounterpartyComboBoxOption(counterparty)));
23738
+ }, [data]);
23739
+ const options = (0, react.useMemo)(() => {
23740
+ if (!value) return fetchedOptions;
23741
+ if (fetchedOptions.some((option) => option.value === value.id)) return fetchedOptions;
23742
+ return [new CounterpartyComboBoxOption(value), ...fetchedOptions];
23743
+ }, [fetchedOptions, value]);
23744
+ return {
23745
+ inputValue,
23746
+ searchQuery,
23747
+ handleInputChange,
23748
+ options,
23749
+ selectedOption: (0, react.useMemo)(() => {
23750
+ var _options$find;
23751
+ if (!value) return null;
23752
+ return (_options$find = options.find((option) => option.value === value.id)) !== null && _options$find !== void 0 ? _options$find : null;
23753
+ }, [options, value]),
23754
+ isLoading,
23755
+ isError
23756
+ };
23757
+ };
23758
+ //#endregion
23759
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartyComboBox.tsx
23760
+ var CounterpartyComboBox = ({ label, value, onValueChange, showLabel, isReadOnly, isError, placeholder }) => {
23761
+ const { t } = (0, react_i18next.useTranslation)();
23762
+ const inputId = (0, react.useId)();
23763
+ const { searchQuery, handleInputChange, options, selectedOption, isLoading, isError: isListError } = useCounterpartyOptions(value);
23764
+ const slots = (0, react.useMemo)(() => {
23765
+ let emptyMessageContent = t("categorizationRules:empty.no_matching_counterparties", "No matching counterparties.");
23766
+ if (isListError) emptyMessageContent = t("categorizationRules:error.load_counterparties", "Couldn’t load counterparties. Please try again.");
23767
+ else if (searchQuery === "") emptyMessageContent = t("categorizationRules:empty.no_counterparties_yet", "No counterparties yet. They will appear here automatically as your transactions are processed.");
23768
+ return {
23769
+ EmptyMessage: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VStack, {
23770
+ pi: "md",
23771
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, { children: emptyMessageContent })
23772
+ }),
23773
+ ErrorMessage: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
23774
+ size: "xs",
23775
+ status: "error",
23776
+ children: t("categorizationRules:validation.counterparty_required", "Counterparty is required.")
23777
+ })
23778
+ };
23779
+ }, [
23780
+ isListError,
23781
+ searchQuery,
23782
+ t
23783
+ ]);
23784
+ const additionalAriaProps = (0, react.useMemo)(() => showLabel ? {} : { "aria-label": label }, [showLabel, label]);
23785
+ const handleSelectedValueChange = (0, react.useCallback)((option) => {
23786
+ var _option$original;
23787
+ onValueChange((_option$original = option === null || option === void 0 ? void 0 : option.original) !== null && _option$original !== void 0 ? _option$original : null);
23788
+ }, [onValueChange]);
23789
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
23790
+ gap: "3xs",
23791
+ children: [showLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label$1, {
23792
+ size: "sm",
23793
+ htmlFor: inputId,
23794
+ children: label
23795
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComboBox, _objectSpread2({
23796
+ options,
23797
+ selectedValue: selectedOption,
23798
+ onSelectedValueChange: handleSelectedValueChange,
23799
+ onInputValueChange: handleInputChange,
23800
+ filterOption: null,
23801
+ inputId,
23802
+ isLoading,
23803
+ isReadOnly,
23804
+ isError,
23805
+ placeholder,
23806
+ slots
23807
+ }, additionalAriaProps))]
23808
+ });
23809
+ };
23810
+ //#endregion
23811
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartyMobileDrawer.tsx
23812
+ var CounterpartyMobileDrawer = ({ label, value, onValueChange, showLabel, isReadOnly, placeholder }) => {
23813
+ var _ref, _selectedOption$label;
23814
+ const { t } = (0, react_i18next.useTranslation)();
23815
+ const inputId = (0, react.useId)();
23816
+ const [isOpen, setIsOpen] = (0, react.useState)(false);
23817
+ const { inputValue, handleInputChange, options, selectedOption, isLoading, isError: isListError } = useCounterpartyOptions(value);
23818
+ const Header = (0, react.useCallback)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalTitleWithClose, {
23819
+ heading: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalHeading, {
23820
+ size: "md",
23821
+ weight: "bold",
23822
+ children: label
23823
+ }),
23824
+ hideCloseButton: true,
23825
+ hideBottomPadding: true
23826
+ }), [label]);
23827
+ const drawerSlots = (0, react.useMemo)(() => ({ Header }), [Header]);
23828
+ const openDrawer = (0, react.useCallback)(() => setIsOpen(true), []);
23829
+ const triggerLabel = (_ref = (_selectedOption$label = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _selectedOption$label !== void 0 ? _selectedOption$label : placeholder) !== null && _ref !== void 0 ? _ref : t("common:action.select_label", "Select…");
23830
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
23831
+ gap: "3xs",
23832
+ children: [
23833
+ showLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label$1, {
23834
+ size: "sm",
23835
+ htmlFor: inputId,
23836
+ children: label
23837
+ }),
23838
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
23839
+ id: inputId,
23840
+ onPress: openDrawer,
23841
+ variant: "outlined",
23842
+ isDisabled: isReadOnly,
23843
+ fullWidth: true,
23844
+ flex: true,
23845
+ "aria-label": label,
23846
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
23847
+ fluid: true,
23848
+ justify: "space-between",
23849
+ align: "center",
23850
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
23851
+ size: "sm",
23852
+ ellipsis: true,
23853
+ children: triggerLabel
23854
+ }), !isReadOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronDown$1, { size: 16 })]
23855
+ })
23856
+ }),
23857
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Drawer, {
23858
+ isOpen,
23859
+ onOpenChange: setIsOpen,
23860
+ variant: "mobile-drawer",
23861
+ fixedHeight: true,
23862
+ isDismissable: true,
23863
+ "aria-label": label,
23864
+ slots: drawerSlots,
23865
+ children: ({ close }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
23866
+ pi: "sm",
23867
+ pb: "xs",
23868
+ gap: "md",
23869
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchField, {
23870
+ value: inputValue,
23871
+ onChange: handleInputChange,
23872
+ label: t("common:action.search_label", "Search")
23873
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionDrawerList, {
23874
+ ariaLabel: label,
23875
+ options,
23876
+ selectedValue: selectedOption,
23877
+ onSelectedValueChange: (option) => {
23878
+ var _option$original;
23879
+ onValueChange((_option$original = option === null || option === void 0 ? void 0 : option.original) !== null && _option$original !== void 0 ? _option$original : null);
23880
+ close();
23881
+ },
23882
+ isLoading,
23883
+ isError: isListError
23884
+ })]
23885
+ })
23886
+ })
23887
+ ]
23888
+ });
23889
+ };
23890
+ //#endregion
23891
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartySelect.tsx
23892
+ var CounterpartySelect = (props) => {
23893
+ const { isMobile } = useSizeClass();
23894
+ if (isMobile) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CounterpartyMobileDrawer, _objectSpread2({}, props));
23895
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CounterpartyComboBox, _objectSpread2({}, props));
23896
+ };
23897
+ //#endregion
23898
+ //#region src/hooks/api/businesses/[business-id]/categorization-rules/useUpsertCategorizationRule.ts
23899
+ var UPSERT_CATEGORIZATION_RULE_TAG = "#upsert-categorization-rule";
23900
+ function buildKey$64({ access_token: accessToken, apiUrl, businessId }) {
23901
+ if (accessToken && apiUrl) return {
23902
+ accessToken,
23903
+ apiUrl,
23904
+ businessId,
23905
+ tags: [UPSERT_CATEGORIZATION_RULE_TAG]
23906
+ };
23907
+ }
23908
+ var UpsertCategorizationRuleReturnSchema = effect_index.Schema.Struct({ data: CategorizationRuleSchema });
23909
+ var createCategorizationRule$1 = post(({ businessId }) => `/v1/businesses/${businessId}/categorization-rules`);
23910
+ var updateCategorizationRule = patch(({ businessId, categorizationRuleId }) => `/v1/businesses/${businessId}/categorization-rules/${categorizationRuleId}`);
23911
+ function useUpsertCategorizationRule() {
23912
+ const withLocale = useLocalizedKey();
23913
+ const { data: auth } = useAuth();
23914
+ const { businessId } = useLayerContext();
23915
+ const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
23916
+ const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
23917
+ const { forceReloadCategorizationRules, patchCategorizationRuleByKey } = useCategorizationRulesGlobalCacheActions();
23918
+ const mutationResponse = (0, swr_mutation.default)(() => withLocale(buildKey$64({
23919
+ access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
23920
+ apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
23921
+ businessId
23922
+ })), ({ accessToken, apiUrl, businessId }, { arg }) => {
23923
+ const decode = effect_index.Schema.decodeUnknownPromise(UpsertCategorizationRuleReturnSchema);
23924
+ if (arg.mode === "create") return createCategorizationRule$1(apiUrl, accessToken, {
23925
+ params: { businessId },
23926
+ body: arg.body
23927
+ }).then(decode);
23928
+ return updateCategorizationRule(apiUrl, accessToken, {
23929
+ params: {
23930
+ businessId,
23931
+ categorizationRuleId: arg.categorizationRuleId
23932
+ },
23933
+ body: arg.body
23934
+ }).then(decode);
23935
+ }, {
23936
+ revalidate: false,
23937
+ throwOnError: true
23938
+ });
23939
+ const { trigger: originalTrigger } = mutationResponse;
23940
+ const stableProxiedTrigger = (0, react.useCallback)(function() {
23941
+ var _ref = _asyncToGenerator(function* (arg, options) {
23942
+ const triggerResult = yield originalTrigger(arg, options);
23943
+ if (arg.mode === "create") {
23944
+ forceReloadCategorizationRules();
23945
+ forceReloadBankTransactions();
23946
+ debouncedInvalidateProfitAndLoss();
23947
+ } else if (triggerResult) patchCategorizationRuleByKey(triggerResult.data);
23948
+ return triggerResult;
23949
+ });
23950
+ return function(_x, _x2) {
23951
+ return _ref.apply(this, arguments);
23952
+ };
23953
+ }(), [
23954
+ originalTrigger,
23955
+ forceReloadCategorizationRules,
23956
+ forceReloadBankTransactions,
23957
+ debouncedInvalidateProfitAndLoss,
23958
+ patchCategorizationRuleByKey
23959
+ ]);
23960
+ return new Proxy(mutationResponse, { get(target, prop) {
23961
+ if (prop === "trigger") return stableProxiedTrigger;
23962
+ return Reflect.get(target, prop);
23963
+ } });
23964
+ }
23965
+ //#endregion
23966
+ //#region src/components/CategorizationRules/CategorizationRuleForm/formUtils.ts
23967
+ var centsToFormAmount = (cents) => {
23968
+ if (cents == null) return null;
23969
+ return convertCentsToNonRecursiveBigDecimal(cents);
23970
+ };
23971
+ var formAmountToCents = (amount) => {
23972
+ if (amount == null) return null;
23973
+ return convertNonRecursiveBigDecimalToCents(amount);
23974
+ };
23975
+ var getCategorizationRuleFormDefaultValues = (state) => {
23976
+ if (state.mode === "edit") {
23977
+ var _rule$counterpartyFil, _rule$category, _rule$bankDirectionFi;
23978
+ const { rule } = state;
23979
+ return {
23980
+ counterparty: (_rule$counterpartyFil = rule.counterpartyFilter) !== null && _rule$counterpartyFil !== void 0 ? _rule$counterpartyFil : null,
23981
+ category: (_rule$category = rule.category) !== null && _rule$category !== void 0 ? _rule$category : null,
23982
+ bankDirectionFilter: (_rule$bankDirectionFi = rule.bankDirectionFilter) !== null && _rule$bankDirectionFi !== void 0 ? _rule$bankDirectionFi : "",
23983
+ amountMinFilter: centsToFormAmount(rule.amountMinFilter),
23984
+ amountMaxFilter: centsToFormAmount(rule.amountMaxFilter)
23985
+ };
23986
+ }
23987
+ return {
23988
+ counterparty: null,
23989
+ category: null,
23990
+ bankDirectionFilter: "",
23991
+ amountMinFilter: null,
23992
+ amountMaxFilter: null
23993
+ };
23994
+ };
23995
+ var validateCategorizationRuleForm = (values, t) => {
23996
+ const errors = [];
23997
+ if (!values.counterparty) errors.push({ counterparty: t("categorizationRules:validation.counterparty_required", "Counterparty is required.") });
23998
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) errors.push({ category: t("categorizationRules:validation.category_required", "Category is required.") });
23999
+ if (values.amountMinFilter && values.amountMaxFilter) {
24000
+ const min = fromNonRecursiveBigDecimal(values.amountMinFilter);
24001
+ const max = fromNonRecursiveBigDecimal(values.amountMaxFilter);
24002
+ if (effect.BigDecimal.greaterThan(min, max)) errors.push({ amountMinFilter: t("categorizationRules:validation.amount_min_greater_than_max", "Minimum amount must be less than or equal to maximum amount.") });
24003
+ }
24004
+ return errors.length > 0 ? errors : null;
24005
+ };
24006
+ var convertFormToCreateBody = (values) => {
24007
+ if (!values.counterparty) throw new Error("Counterparty is required to create a categorization rule");
24008
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) throw new Error("Category is required to create a categorization rule");
24009
+ const parsed = {
24010
+ applyRetroactively: false,
24011
+ category: values.category,
24012
+ bankDirectionFilter: values.bankDirectionFilter === "" ? null : values.bankDirectionFilter,
24013
+ amountMinFilter: formAmountToCents(values.amountMinFilter),
24014
+ amountMaxFilter: formAmountToCents(values.amountMaxFilter),
24015
+ counterpartyFilter: values.counterparty.id
24016
+ };
24017
+ return effect.Schema.encodeUnknownSync(CreateCategorizationRuleSchema)(parsed);
24018
+ };
24019
+ var convertFormToPatchBody = (values) => {
24020
+ if (!values.counterparty) throw new Error("Counterparty is required to update a categorization rule");
24021
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) throw new Error("Category is required to update a categorization rule");
24022
+ const parsed = {
24023
+ category: values.category,
24024
+ bankDirectionFilter: values.bankDirectionFilter === "" ? null : values.bankDirectionFilter,
24025
+ counterpartyFilter: values.counterparty.id,
24026
+ amountMinFilter: formAmountToCents(values.amountMinFilter),
24027
+ amountMaxFilter: formAmountToCents(values.amountMaxFilter)
24028
+ };
24029
+ return effect.Schema.encodeUnknownSync(PatchCategorizationRuleSchema)(parsed);
24030
+ };
24031
+ //#endregion
24032
+ //#region src/components/CategorizationRules/CategorizationRuleForm/useCategorizationRuleForm.ts
24033
+ var useCategorizationRuleForm = ({ formState, onSuccess }) => {
24034
+ const { t } = (0, react_i18next.useTranslation)();
24035
+ const [submitError, setSubmitError] = (0, react.useState)(void 0);
24036
+ const { trigger: upsertCategorizationRule } = useUpsertCategorizationRule();
24037
+ const formDefaults = (0, react.useMemo)(() => getCategorizationRuleFormDefaultValues(formState), [formState]);
24038
+ const defaultValues = (0, react.useRef)(formDefaults).current;
24039
+ const onSubmit = (0, react.useCallback)(function() {
24040
+ var _ref = _asyncToGenerator(function* ({ value }) {
24041
+ try {
24042
+ const result = formState.mode === "edit" ? yield upsertCategorizationRule({
24043
+ mode: "update",
24044
+ categorizationRuleId: formState.rule.id,
24045
+ body: convertFormToPatchBody(value)
24046
+ }) : yield upsertCategorizationRule({
24047
+ mode: "create",
24048
+ body: convertFormToCreateBody(value)
24049
+ });
24050
+ setSubmitError(void 0);
24051
+ onSuccess(result.data);
24052
+ } catch (e) {
24053
+ console.error(e);
24054
+ setSubmitError(t("common:error.something_went_wrong_please_try_again", "Something went wrong. Please try again."));
24055
+ }
24056
+ });
24057
+ return function(_x) {
24058
+ return _ref.apply(this, arguments);
24059
+ };
24060
+ }(), [
24061
+ formState,
24062
+ upsertCategorizationRule,
24063
+ onSuccess,
24064
+ t
24065
+ ]);
24066
+ const onDynamic = (0, react.useCallback)(({ value }) => {
24067
+ return validateCategorizationRuleForm(value, t);
24068
+ }, [t]);
24069
+ const form = useAppForm({
24070
+ defaultValues,
24071
+ onSubmit,
24072
+ validators: (0, react.useMemo)(() => ({ onDynamic }), [onDynamic]),
24073
+ validationLogic: (0, _tanstack_react_form.revalidateLogic)({
24074
+ mode: "submit",
24075
+ modeAfterSubmission: "submit"
24076
+ }),
24077
+ canSubmitWhenInvalid: true
24078
+ });
24079
+ (0, react.useEffect)(() => {
24080
+ form.reset(formDefaults);
24081
+ }, [form, formDefaults]);
24082
+ return (0, react.useMemo)(() => ({
24083
+ form,
24084
+ submitError
24085
+ }), [form, submitError]);
24086
+ };
24087
+ //#endregion
24088
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorizationRuleForm.tsx
24089
+ var CategorizationRuleForm = ({ formState, onSuccess }) => {
24090
+ const { t } = (0, react_i18next.useTranslation)();
24091
+ const { form, submitError } = useCategorizationRuleForm({
24092
+ formState,
24093
+ onSuccess
24094
+ });
24095
+ const blockNativeOnSubmit = (0, react.useCallback)((e) => {
24096
+ e.preventDefault();
24097
+ e.stopPropagation();
24098
+ }, []);
24099
+ const directionOptions = (0, react.useMemo)(() => [
24100
+ {
24101
+ value: "",
24102
+ label: t("categorizationRules:label.any", "Any")
24103
+ },
24104
+ {
24105
+ value: BankDirectionFilter.MONEY_IN,
24106
+ label: t("common:label.money_in", "Money in")
24107
+ },
24108
+ {
24109
+ value: BankDirectionFilter.MONEY_OUT,
24110
+ label: t("common:label.money_out", "Money out")
24111
+ }
24112
+ ], [t]);
24113
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Form, {
24114
+ className: "Layer__CategorizationRuleForm",
24115
+ onSubmit: blockNativeOnSubmit,
24116
+ children: [
24117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.Subscribe, {
24118
+ selector: (state) => state.errorMap,
24119
+ children: (errorMap) => {
24120
+ const validationErrors = flattenValidationErrors(errorMap);
24121
+ if (validationErrors.length > 0 || submitError) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HStack, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataState, {
24122
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.AlertTriangle, { size: 16 }),
24123
+ status: DataStateStatus.failed,
24124
+ title: validationErrors[0] || submitError,
24125
+ titleSize: TextSize.md,
24126
+ inline: true
24127
+ }) });
24128
+ }
24129
+ }),
24130
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.Field, {
24131
+ name: "counterparty",
24132
+ children: (field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CounterpartySelect, {
24133
+ label: t("common:label.counterparty", "Counterparty"),
24134
+ value: field.state.value,
24135
+ onValueChange: field.handleChange,
24136
+ placeholder: t("categorizationRules:placeholder.select_counterparty", "Select counterparty"),
24137
+ showLabel: true
24138
+ })
24139
+ }),
24140
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.Field, {
24141
+ name: "category",
24142
+ children: (field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorySelect, {
24143
+ label: t("common:label.category", "Category"),
24144
+ value: field.state.value,
24145
+ onValueChange: field.handleChange,
24146
+ showLabel: true
24147
+ })
24148
+ }),
24149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.AppField, {
24150
+ name: "bankDirectionFilter",
24151
+ children: (field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(field.FormRadioGroupField, {
24152
+ label: t("common:label.direction", "Direction"),
24153
+ orientation: "vertical",
24154
+ options: directionOptions
24155
+ })
24156
+ }),
24157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
24158
+ gap: "md",
24159
+ className: "Layer__CategorizationRuleForm__AmountRow",
24160
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.AppField, {
24161
+ name: "amountMinFilter",
24162
+ children: (field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(field.FormNonRecursiveBigDecimalField, {
24163
+ label: t("categorizationRules:label.amount_min", "Minimum amount"),
24164
+ mode: "currency",
24165
+ allowEmpty: true,
24166
+ placeholder: t("categorizationRules:placeholder.no_minimum", "No minimum")
24167
+ })
24168
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.AppField, {
24169
+ name: "amountMaxFilter",
24170
+ children: (field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(field.FormNonRecursiveBigDecimalField, {
24171
+ label: t("categorizationRules:label.amount_max", "Maximum amount"),
24172
+ mode: "currency",
24173
+ allowEmpty: true,
24174
+ placeholder: t("categorizationRules:placeholder.no_maximum", "No maximum")
24175
+ })
24176
+ })]
24177
+ }),
24178
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VStack, {
24179
+ justify: "end",
24180
+ className: "Layer__CategorizationRuleForm__Submit",
24181
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.Subscribe, {
24182
+ selector: (state) => [state.canSubmit, state.isSubmitting],
24183
+ children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button$1, {
24184
+ type: "submit",
24185
+ isDisabled: !canSubmit,
24186
+ isPending: isSubmitting,
24187
+ onPress: () => {
24188
+ form.handleSubmit();
24189
+ },
24190
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Save, { size: 14 }), formState.mode === "edit" ? t("categorizationRules:action.save_rule", "Save Rule") : t("categorizationRules:action.create_rule", "Create Rule")]
24191
+ })
24192
+ })
24193
+ })
24194
+ ]
24195
+ });
24196
+ };
24197
+ //#endregion
24198
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorizationRuleFormDrawer.tsx
24199
+ var CategorizationRuleFormDrawerHeader = ({ title, close }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalTitleWithClose, {
24200
+ heading: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalHeading, {
24201
+ size: "md",
24202
+ children: title
24203
+ }),
24204
+ onClose: close
24205
+ });
24206
+ var CategorizationRuleFormDrawer = ({ isOpen, onOpenChange, onSuccess, formState }) => {
24207
+ const { t } = (0, react_i18next.useTranslation)();
24208
+ const { isMobile } = useSizeClass();
24209
+ const lastFormStateRef = (0, react.useRef)(formState);
24210
+ if (formState) lastFormStateRef.current = formState;
24211
+ const activeFormState = formState !== null && formState !== void 0 ? formState : lastFormStateRef.current;
24212
+ const title = (activeFormState === null || activeFormState === void 0 ? void 0 : activeFormState.mode) === "edit" ? t("categorizationRules:action.edit_rule", "Edit Rule") : t("categorizationRules:action.new_rule", "New Rule");
24213
+ const Header = (0, react.useCallback)(({ close }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRuleFormDrawerHeader, {
24214
+ title,
24215
+ close
24216
+ }), [title]);
24217
+ const slots = (0, react.useMemo)(() => ({ Header }), [Header]);
24218
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Drawer, {
24219
+ isOpen,
24220
+ onOpenChange,
24221
+ "aria-label": title,
24222
+ variant: isMobile ? "mobile-drawer" : "drawer",
24223
+ flexBlock: isMobile,
24224
+ slots,
24225
+ children: activeFormState && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VStack, {
24226
+ pbe: "lg",
24227
+ pi: "md",
24228
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRuleForm, {
24229
+ formState: activeFormState,
24230
+ onSuccess
24231
+ })
24232
+ })
24233
+ });
24234
+ };
24235
+ //#endregion
23522
24236
  //#region src/hooks/utils/pagination/usePaginatedList.ts
23523
24237
  function usePaginatedList({ data, pageSize, initialPage = 0, onSetPage }) {
23524
24238
  const [internalPageIndex, setInternalPageIndex] = (0, react.useState)(initialPage);
@@ -23701,10 +24415,20 @@ var getCategorizationRuleCounterpartyLabel = (rule) => {
23701
24415
  var _ref, _rule$counterpartyFil, _rule$counterpartyFil2;
23702
24416
  return (_ref = (_rule$counterpartyFil = (_rule$counterpartyFil2 = rule.counterpartyFilter) === null || _rule$counterpartyFil2 === void 0 ? void 0 : _rule$counterpartyFil2.name) !== null && _rule$counterpartyFil !== void 0 ? _rule$counterpartyFil : rule.readableTransactionDescriptionFilter) !== null && _ref !== void 0 ? _ref : void 0;
23703
24417
  };
24418
+ var getCategorizationRuleAmountLabel = (rule, formatCurrencyFromCents, t) => {
24419
+ const { amountMinFilter: min, amountMaxFilter: max } = rule;
24420
+ if (min == null && max == null) return t("categorizationRules:label.any_amount", "Any amount");
24421
+ if (min != null && max != null) return `${formatCurrencyFromCents(min)} – ${formatCurrencyFromCents(max)}`;
24422
+ if (min != null) return `≥ ${formatCurrencyFromCents(min)}`;
24423
+ return `≤ ${formatCurrencyFromCents(max)}`;
24424
+ };
23704
24425
  //#endregion
23705
24426
  //#region src/components/CategorizationRules/CategorizationRulesMobileList/CategorizationRulesMobileList.tsx
23706
- var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
24427
+ var CategorizationRuleMobileListItem = ({ rule, options, onEditPress, onDeletePress }) => {
23707
24428
  const { t } = (0, react_i18next.useTranslation)();
24429
+ const { formatCurrencyFromCents } = useIntlFormatter();
24430
+ const counterpartyLabel = getCategorizationRuleCounterpartyLabel(rule);
24431
+ const hasAmountFilter = rule.amountMinFilter != null || rule.amountMaxFilter != null;
23708
24432
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
23709
24433
  justify: "space-between",
23710
24434
  align: "center",
@@ -23717,7 +24441,7 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
23717
24441
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
23718
24442
  weight: "bold",
23719
24443
  ellipsis: true,
23720
- children: getCategorizationRuleCounterpartyLabel(rule)
24444
+ children: counterpartyLabel
23721
24445
  }),
23722
24446
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
23723
24447
  gap: "3xs",
@@ -23732,6 +24456,19 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
23732
24456
  children: getCategorizationRuleDirectionLabel(rule.bankDirectionFilter, t)
23733
24457
  })]
23734
24458
  }),
24459
+ hasAmountFilter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
24460
+ gap: "3xs",
24461
+ align: "center",
24462
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
24463
+ size: "sm",
24464
+ variant: "subtle",
24465
+ children: t("common:label.amount", "Amount:")
24466
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
24467
+ size: "sm",
24468
+ variant: "subtle",
24469
+ children: getCategorizationRuleAmountLabel(rule, formatCurrencyFromCents, t)
24470
+ })]
24471
+ }),
23735
24472
  rule.category && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
23736
24473
  gap: "3xs",
23737
24474
  align: "center",
@@ -23749,23 +24486,39 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
23749
24486
  })]
23750
24487
  })
23751
24488
  ]
23752
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
23753
- inset: true,
23754
- icon: true,
23755
- onPress: () => onDeletePress(rule),
23756
- "aria-label": t("categorizationRules:action.delete_rule", "Delete rule"),
23757
- variant: "ghost",
23758
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { size: 16 })
24489
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
24490
+ gap: "3xs",
24491
+ align: "center",
24492
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24493
+ inset: true,
24494
+ icon: true,
24495
+ onPress: () => onEditPress(rule),
24496
+ "aria-label": t("categorizationRules:action.edit_rule", "Edit Rule"),
24497
+ variant: "ghost",
24498
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { size: 16 })
24499
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24500
+ inset: true,
24501
+ icon: true,
24502
+ onPress: () => onDeletePress(rule),
24503
+ "aria-label": t("categorizationRules:action.delete_rule", "Delete Rule"),
24504
+ variant: "ghost",
24505
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { size: 16 })
24506
+ })]
23759
24507
  })]
23760
24508
  });
23761
24509
  };
23762
- var CategorizationRulesMobileList = ({ data, isLoading, isError, paginationProps, options, onDeleteRule, slots }) => {
24510
+ var CategorizationRulesMobileList = ({ data, isLoading, isError, paginationProps, options, onEditRule, onDeleteRule, slots }) => {
23763
24511
  const { t } = (0, react_i18next.useTranslation)();
23764
24512
  const renderItem = (0, react.useCallback)((rule) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRuleMobileListItem, {
23765
24513
  rule,
23766
24514
  options,
24515
+ onEditPress: onEditRule,
23767
24516
  onDeletePress: onDeleteRule
23768
- }), [options, onDeleteRule]);
24517
+ }), [
24518
+ options,
24519
+ onEditRule,
24520
+ onDeleteRule
24521
+ ]);
23769
24522
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23770
24523
  className: "Layer__CategorizationRulesMobileList",
23771
24524
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaginatedMobileList, {
@@ -24052,12 +24805,15 @@ var CategorizationRuleColumns = /* @__PURE__ */ function(CategorizationRuleColum
24052
24805
  CategorizationRuleColumns["Category"] = "Category";
24053
24806
  CategorizationRuleColumns["Counterparty"] = "Counterparty";
24054
24807
  CategorizationRuleColumns["Direction"] = "Direction";
24808
+ CategorizationRuleColumns["Amount"] = "Amount";
24809
+ CategorizationRuleColumns["Edit"] = "Edit";
24055
24810
  CategorizationRuleColumns["Delete"] = "Delete";
24056
24811
  return CategorizationRuleColumns;
24057
24812
  }(CategorizationRuleColumns || {});
24058
24813
  var COMPONENT_NAME$14 = "CategorizationRulesTable";
24059
- var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, options, onDeleteRule, slots }) => {
24814
+ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, options, onEditRule, onDeleteRule, slots }) => {
24060
24815
  const { t } = (0, react_i18next.useTranslation)();
24816
+ const { formatCurrencyFromCents } = useIntlFormatter();
24061
24817
  const columnConfig = (0, react.useMemo)(() => [
24062
24818
  {
24063
24819
  id: CategorizationRuleColumns.Counterparty,
@@ -24075,6 +24831,14 @@ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, opt
24075
24831
  children: getCategorizationRuleDirectionLabel(row.original.bankDirectionFilter, t)
24076
24832
  })
24077
24833
  },
24834
+ {
24835
+ id: CategorizationRuleColumns.Amount,
24836
+ header: t("common:label.amount", "Amount"),
24837
+ cell: (row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Span, {
24838
+ ellipsis: true,
24839
+ children: getCategorizationRuleAmountLabel(row.original, formatCurrencyFromCents, t)
24840
+ })
24841
+ },
24078
24842
  {
24079
24843
  id: CategorizationRuleColumns.Category,
24080
24844
  header: t("common:label.category", "Category"),
@@ -24088,20 +24852,33 @@ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, opt
24088
24852
  },
24089
24853
  isRowHeader: true
24090
24854
  },
24855
+ {
24856
+ id: CategorizationRuleColumns.Edit,
24857
+ cell: (row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24858
+ inset: true,
24859
+ icon: true,
24860
+ onPress: () => onEditRule(row.original),
24861
+ "aria-label": t("categorizationRules:action.edit_rule", "Edit Rule"),
24862
+ variant: "ghost",
24863
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { size: 16 })
24864
+ })
24865
+ },
24091
24866
  {
24092
24867
  id: CategorizationRuleColumns.Delete,
24093
24868
  cell: (row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24094
24869
  inset: true,
24095
24870
  icon: true,
24096
24871
  onPress: () => onDeleteRule(row.original),
24097
- "aria-label": t("categorizationRules:action.delete_rule", "Delete rule"),
24872
+ "aria-label": t("categorizationRules:action.delete_rule", "Delete Rule"),
24098
24873
  variant: "ghost",
24099
24874
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { size: 16 })
24100
24875
  })
24101
24876
  }
24102
24877
  ], [
24103
24878
  t,
24879
+ formatCurrencyFromCents,
24104
24880
  options,
24881
+ onEditRule,
24105
24882
  onDeleteRule
24106
24883
  ]);
24107
24884
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaginatedTable, {
@@ -24138,19 +24915,33 @@ var CategorizationRulesErrorState = () => {
24138
24915
  className: "Layer__CategorizationRulesView__ErrorState"
24139
24916
  });
24140
24917
  };
24141
- var CategorizationRulesHeader = ({ onGoBack }) => {
24918
+ var CategorizationRulesHeader = ({ onGoBack, onCreateRule }) => {
24142
24919
  const { t } = (0, react_i18next.useTranslation)();
24143
24920
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
24921
+ fluid: true,
24922
+ justify: "space-between",
24144
24923
  align: "center",
24145
- gap: "md",
24146
- children: [onGoBack && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24147
- variant: "outlined",
24148
- icon: true,
24149
- onPress: onGoBack,
24150
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackArrow, {})
24151
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Heading$1, {
24152
- size: "sm",
24153
- children: t("categorizationRules:label.categorization_rules", "Categorization Rules")
24924
+ gap: "xs",
24925
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
24926
+ align: "center",
24927
+ gap: "md",
24928
+ children: [onGoBack && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button$1, {
24929
+ variant: "outlined",
24930
+ icon: true,
24931
+ onPress: onGoBack,
24932
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackArrow, {})
24933
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Heading$1, {
24934
+ size: "sm",
24935
+ children: t("categorizationRules:label.categorization_rules", "Categorization Rules")
24936
+ })]
24937
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HStack, {
24938
+ pie: "md",
24939
+ align: "center",
24940
+ gap: "xs",
24941
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button$1, {
24942
+ onPress: onCreateRule,
24943
+ children: [t("categorizationRules:action.create_rule", "Create Rule"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { size: 16 })]
24944
+ })
24154
24945
  })]
24155
24946
  });
24156
24947
  };
@@ -24160,9 +24951,19 @@ var ResponsiveCategorizationRulesView = () => {
24160
24951
  const { t } = (0, react_i18next.useTranslation)();
24161
24952
  const [selectedRule, setSelectedRule] = (0, react.useState)(null);
24162
24953
  const [showDeletionConfirmationModal, setShowDeletionConfirmationModal] = (0, react.useState)(false);
24954
+ const [formState, setFormState] = (0, react.useState)(null);
24163
24955
  const { trigger: archiveCategorizationRuleTrigger } = useArchiveCategorizationRule();
24164
24956
  const { addToast } = useLayerContext();
24165
24957
  const { isMobile } = useSizeClass();
24958
+ const onCreateRule = (0, react.useCallback)(() => setFormState({ mode: "create" }), []);
24959
+ const onEditRule = (0, react.useCallback)((rule) => setFormState({
24960
+ mode: "edit",
24961
+ rule
24962
+ }), []);
24963
+ const onFormDrawerOpenChange = (0, react.useCallback)((isOpen) => {
24964
+ if (!isOpen) setFormState(null);
24965
+ }, []);
24966
+ const onFormSuccess = (0, react.useCallback)(() => setFormState(null), []);
24166
24967
  const { data: categories, isLoading: categoriesAreLoading } = useCategories({ mode: CategoriesListMode.All });
24167
24968
  const options = (0, react.useMemo)(() => {
24168
24969
  if (!categories) return [];
@@ -24212,9 +25013,10 @@ var ResponsiveCategorizationRulesView = () => {
24212
25013
  ]);
24213
25014
  const isLoading = data === void 0 || rulesAreLoading || categoriesAreLoading;
24214
25015
  const { toBankTransactionsTable } = useBankTransactionsNavigation();
25016
+ const DesktopHeader = (0, react.useCallback)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRulesHeader, { onCreateRule }), [onCreateRule]);
24215
25017
  const DesktopView = (0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseDetailView, {
24216
25018
  slots: {
24217
- Header: CategorizationRulesHeader,
25019
+ Header: DesktopHeader,
24218
25020
  BackIcon: BackArrow
24219
25021
  },
24220
25022
  name: "CategorizationRulesDrawer",
@@ -24225,6 +25027,7 @@ var ResponsiveCategorizationRulesView = () => {
24225
25027
  isError,
24226
25028
  paginationProps,
24227
25029
  options,
25030
+ onEditRule,
24228
25031
  onDeleteRule,
24229
25032
  slots: {
24230
25033
  EmptyState: CategorizationRulesEmptyState,
@@ -24232,22 +25035,28 @@ var ResponsiveCategorizationRulesView = () => {
24232
25035
  }
24233
25036
  })
24234
25037
  }), [
25038
+ DesktopHeader,
24235
25039
  toBankTransactionsTable,
24236
25040
  categorizationRules,
24237
25041
  isLoading,
24238
25042
  isError,
24239
25043
  paginationProps,
24240
25044
  options,
25045
+ onEditRule,
24241
25046
  onDeleteRule
24242
25047
  ]);
24243
25048
  const MobileView = (0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
24244
25049
  gap: "md",
24245
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRulesHeader, { onGoBack: toBankTransactionsTable }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRulesMobileList, {
25050
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRulesHeader, {
25051
+ onGoBack: toBankTransactionsTable,
25052
+ onCreateRule
25053
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRulesMobileList, {
24246
25054
  data: categorizationRules,
24247
25055
  isLoading,
24248
25056
  isError,
24249
25057
  paginationProps,
24250
25058
  options,
25059
+ onEditRule,
24251
25060
  onDeleteRule,
24252
25061
  slots: {
24253
25062
  EmptyState: CategorizationRulesEmptyState,
@@ -24256,30 +25065,41 @@ var ResponsiveCategorizationRulesView = () => {
24256
25065
  })]
24257
25066
  }), [
24258
25067
  toBankTransactionsTable,
25068
+ onCreateRule,
24259
25069
  categorizationRules,
24260
25070
  isLoading,
24261
25071
  isError,
24262
25072
  paginationProps,
24263
25073
  options,
25074
+ onEditRule,
24264
25075
  onDeleteRule
24265
25076
  ]);
24266
25077
  const selectedRuleCounterpartyLabel = (_ref = selectedRule && getCategorizationRuleCounterpartyLabel(selectedRule)) !== null && _ref !== void 0 ? _ref : t("bankTransactions:label.selected_counterparty", "this counterparty");
24267
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsiveComponent, {
24268
- resolveVariant: resolveVariant$2,
24269
- slots: {
24270
- Desktop: DesktopView,
24271
- Mobile: MobileView
24272
- }
24273
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseConfirmationModal, {
24274
- isOpen: showDeletionConfirmationModal,
24275
- onOpenChange: setShowDeletionConfirmationModal,
24276
- title: t("categorizationRules:prompt.delete_categorization_rule", "Delete categorization rule?"),
24277
- description: t("categorizationRules:label.transaction_no_longer_automatically_categorized", "Transactions will no longer automatically be categorized by this rule. Any transactions previously categorized to {{counterparty}} will not be affected.", { counterparty: selectedRuleCounterpartyLabel }),
24278
- onConfirm: archiveCategorizationRule,
24279
- confirmLabel: t("common:action.delete_label", "Delete"),
24280
- cancelLabel: t("common:action.cancel_label", "Cancel"),
24281
- useDrawer: isMobile
24282
- })] });
25078
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
25079
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsiveComponent, {
25080
+ resolveVariant: resolveVariant$2,
25081
+ slots: (0, react.useMemo)(() => ({
25082
+ Desktop: DesktopView,
25083
+ Mobile: MobileView
25084
+ }), [DesktopView, MobileView])
25085
+ }),
25086
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseConfirmationModal, {
25087
+ isOpen: showDeletionConfirmationModal,
25088
+ onOpenChange: setShowDeletionConfirmationModal,
25089
+ title: t("categorizationRules:prompt.delete_categorization_rule", "Delete categorization rule?"),
25090
+ description: t("categorizationRules:label.transaction_no_longer_automatically_categorized", "Transactions will no longer automatically be categorized by this rule. Any transactions previously categorized to {{counterparty}} will not be affected.", { counterparty: selectedRuleCounterpartyLabel }),
25091
+ onConfirm: archiveCategorizationRule,
25092
+ confirmLabel: t("common:action.delete_label", "Delete"),
25093
+ cancelLabel: t("common:action.cancel_label", "Cancel"),
25094
+ useDrawer: isMobile
25095
+ }),
25096
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategorizationRuleFormDrawer, {
25097
+ isOpen: !!formState,
25098
+ formState,
25099
+ onOpenChange: onFormDrawerOpenChange,
25100
+ onSuccess: onFormSuccess
25101
+ })
25102
+ ] });
24283
25103
  };
24284
25104
  //#endregion
24285
25105
  //#region src/components/ErrorBoundary/ErrorBoundaryMessage.tsx
@@ -34528,42 +35348,6 @@ var DebitCreditPill = ({ value, onChange, isReadOnly = false }) => {
34528
35348
  });
34529
35349
  };
34530
35350
  //#endregion
34531
- //#region src/components/LedgerAccountCombobox/LedgerAccountCombobox.tsx
34532
- var LedgerAccountCombobox = ({ label, value, mode, onValueChange, isReadOnly, showLabel, className }) => {
34533
- const { data: categories, isLoading } = useCategories({ mode });
34534
- const options = (0, react.useMemo)(() => {
34535
- if (!categories) return [];
34536
- return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
34537
- }, [categories]);
34538
- const selectedCategory = (0, react.useMemo)(() => {
34539
- var _options$find;
34540
- if (!value) return null;
34541
- return (_options$find = options.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _options$find !== void 0 ? _options$find : null;
34542
- }, [options, value]);
34543
- const onSelectedValueChange = (0, react.useCallback)((option) => {
34544
- var _option$classificatio;
34545
- onValueChange((_option$classificatio = option === null || option === void 0 ? void 0 : option.classification) !== null && _option$classificatio !== void 0 ? _option$classificatio : null);
34546
- }, [onValueChange]);
34547
- const inputId = (0, react.useId)();
34548
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
34549
- gap: "3xs",
34550
- className,
34551
- children: [showLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label$1, {
34552
- size: "sm",
34553
- htmlFor: inputId,
34554
- children: label
34555
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComboBox, _objectSpread2({
34556
- options,
34557
- onSelectedValueChange,
34558
- selectedValue: selectedCategory,
34559
- inputId,
34560
- isReadOnly,
34561
- isLoading,
34562
- isClearable: false
34563
- }, !showLabel && { "aria-label": label }))]
34564
- });
34565
- };
34566
- //#endregion
34567
35351
  //#region src/components/Journal/JournalEntryForm/JournalEntryLineItem.tsx
34568
35352
  var JOURNAL_ENTRY_FORM_CSS_PREFIX$1 = "Layer__JournalEntryForm";
34569
35353
  var JournalEntryLineItem = ({ form, index, displayIndex, isReadOnly, onDeleteLine, showTags = false }) => {
@@ -41582,7 +42366,7 @@ var getInvoiceFormLineItem = (lineItem) => {
41582
42366
  return {
41583
42367
  description: description || "",
41584
42368
  quantity: toNonRecursiveBigDecimal(quantity),
41585
- unitPrice: toNonRecursiveBigDecimal(convertCentsToBigDecimal(unitPrice)),
42369
+ unitPrice: convertCentsToNonRecursiveBigDecimal(unitPrice),
41586
42370
  amount: toNonRecursiveBigDecimal(getInvoiceLineItemAmount(lineItem)),
41587
42371
  isTaxable: lineItem.salesTaxTotal > 0
41588
42372
  };
@@ -41648,7 +42432,7 @@ var convertInvoiceFormToParams = (form) => {
41648
42432
  lineItems: form.lineItems.filter((item) => !InvoiceFormLineItemEquivalence(EMPTY_LINE_ITEM, item)).map((item) => {
41649
42433
  const baseLineItem = {
41650
42434
  description: item.description.trim(),
41651
- unitPrice: convertBigDecimalToCents(fromNonRecursiveBigDecimal(item.unitPrice)),
42435
+ unitPrice: convertNonRecursiveBigDecimalToCents(item.unitPrice),
41652
42436
  quantity: fromNonRecursiveBigDecimal(item.quantity)
41653
42437
  };
41654
42438
  if (!item.isTaxable || effect.BigDecimal.equals(form.taxRate, BIG_DECIMAL_ZERO)) return baseLineItem;
@@ -50799,7 +51583,7 @@ var getServiceFormDefaultValues = ({ service, initialName }) => {
50799
51583
  var _ref, _service$name;
50800
51584
  return {
50801
51585
  name: (_ref = (_service$name = service === null || service === void 0 ? void 0 : service.name) !== null && _service$name !== void 0 ? _service$name : initialName) !== null && _ref !== void 0 ? _ref : "",
50802
- hourlyRate: (service === null || service === void 0 ? void 0 : service.billableRatePerHourAmount) != null && !Number.isNaN(service.billableRatePerHourAmount) ? toNonRecursiveBigDecimal(convertCentsToBigDecimal(service.billableRatePerHourAmount)) : null
51586
+ hourlyRate: (service === null || service === void 0 ? void 0 : service.billableRatePerHourAmount) != null && !Number.isNaN(service.billableRatePerHourAmount) ? convertCentsToNonRecursiveBigDecimal(service.billableRatePerHourAmount) : null
50803
51587
  };
50804
51588
  };
50805
51589
  function useServiceForm(props) {
@@ -50820,7 +51604,7 @@ function useServiceForm(props) {
50820
51604
  const onSubmit = (0, react.useCallback)(function() {
50821
51605
  var _ref2 = _asyncToGenerator(function* ({ value }) {
50822
51606
  const trimmedName = value.name.trim();
50823
- const billableRatePerHourAmount = value.hourlyRate === null ? void 0 : convertBigDecimalToCents(fromNonRecursiveBigDecimal(value.hourlyRate));
51607
+ const billableRatePerHourAmount = value.hourlyRate === null ? void 0 : convertNonRecursiveBigDecimalToCents(value.hourlyRate);
50824
51608
  setSubmitError(null);
50825
51609
  try {
50826
51610
  if (mode === "edit") yield updateService({