@tesouro/embedded-components-react 0.5.225 → 0.5.227

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.
Files changed (142) hide show
  1. package/README.md +21 -21
  2. package/dist/index.d.ts +23 -2
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +23 -2
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index3.js +41 -39
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index12.js +2 -2
  8. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index2.js +2 -2
  9. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index3.js +2 -2
  10. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index4.js +2 -2
  11. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js +150 -147
  12. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/data-access/dist/index5.js +46 -51
  13. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js +130 -128
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index18.js +31 -32
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index19.js +2 -2
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index2.js +2 -2
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index21.js +2 -2
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index22.js +2 -2
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index3.js +2 -2
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index4.js +36 -37
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/data-access/dist/index2.js +2 -2
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index4.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index2.js +6 -10
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index3.js +2 -2
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index4.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index5.js +2 -2
  27. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js +2 -2
  28. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index7.js +2 -2
  29. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index8.js +2 -2
  30. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index13.js +154 -150
  31. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index7.js +2 -2
  32. package/dist/libs/tesouro-embedded-components-react/cards-widget/data-access/dist/index2.js +2 -2
  33. package/dist/libs/tesouro-embedded-components-react/cards-widget/data-access/dist/index3.js +2 -2
  34. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +151 -149
  35. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/data-access/dist/index2.js +4 -4
  36. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/data-access/dist/index3.js +4 -4
  37. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index15.js +2 -2
  38. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index17.js +2 -2
  39. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index18.js +2 -2
  40. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index19.js +2 -2
  41. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index2.js +2 -2
  42. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index3.js +2 -2
  43. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index4.js +2 -2
  44. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index5.js +2 -2
  45. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index6.js +2 -2
  46. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index8.js +2 -2
  47. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index9.js +2 -2
  48. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index24.js +1 -0
  49. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index27.js +89 -87
  50. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +133 -130
  51. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index8.js +36 -34
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +50 -36
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +6 -6
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +2 -2
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +40 -39
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +51 -32
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +20 -1
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +17 -202
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +220 -31
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +32 -145
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -44
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +145 -117
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +46 -58
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +113 -87
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +58 -116
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +98 -225
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +111 -27
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +225 -462
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +34 -41
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +627 -34
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +39 -77
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -112
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +75 -310
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +124 -0
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +324 -0
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +20 -15
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +56 -53
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +33 -29
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +184 -162
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +1 -3
  83. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +78 -69
  84. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/data-access/dist/index4.js +2 -2
  85. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js +209 -207
  86. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index4.js +10 -5
  87. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index5.js +10 -5
  88. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index6.js +11 -6
  89. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index2.js +2 -2
  90. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index3.js +2 -2
  91. package/dist/libs/tesouro-embedded-components-react/settings-widget/profile/data-access/dist/index2.js +2 -2
  92. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index12.js +2 -2
  93. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index13.js +2 -2
  94. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index14.js +30 -28
  95. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index17.js +28 -26
  96. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index18.js +37 -34
  97. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index21.js +28 -26
  98. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index22.js +37 -34
  99. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index17.js +294 -292
  100. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index5.js +58 -58
  101. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js +47 -48
  102. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index3.js +4 -4
  103. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index5.js +2 -2
  104. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index7.js +4 -4
  105. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +7 -6
  106. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +20 -19
  107. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -39
  108. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/EmbedApiContext.js +14 -13
  109. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/allPages.js +1 -1
  110. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/applicationStatusQueryOptions.js +16 -15
  111. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js +7 -5
  112. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/debit-card/useAllDebitCardsQuery.js +7 -5
  113. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js +2 -2
  114. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.js +7 -5
  115. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/merchant-category-group/useAllMerchantCategoryGroupsQuery.js +28 -29
  116. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/organizationStatus.js +10 -0
  117. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js +26 -27
  118. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js +2 -2
  119. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +210 -199
  120. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +60 -52
  121. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js +31 -32
  122. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/role/useRolePermissionsQueries.js +2 -2
  123. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useCurrentUserQuery.js +2 -2
  124. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useGetUserDataQuery.js +2 -2
  125. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useMailboxAddress.js +2 -2
  126. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useMyEntityQuery.js +2 -2
  127. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js +33 -34
  128. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/withAuthEpoch.js +33 -22
  129. package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/data-access/dist/index3.js +2 -2
  130. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +43 -32
  131. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +138 -127
  132. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/deriveOrganizationStatus.js +6 -0
  133. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/useWidgetFetch.js +1 -1
  134. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  135. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index10.js +2 -2
  136. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index2.js +2 -2
  137. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index3.js +2 -2
  138. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index4.js +2 -2
  139. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js +2 -2
  140. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index6.js +2 -2
  141. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index6.js +60 -58
  142. package/package.json +1 -1
@@ -9,7 +9,7 @@ import "../../../shared/data-access/dist/index.js";
9
9
  import { useQuery as r } from "@tanstack/react-query";
10
10
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index9.js
11
11
  function i({ transactionId: i, enabled: a } = {}) {
12
- let { client: o, organizationId: s, widgetToken: c, authEpoch: l, organizationPending: u } = n(), d = !!(s && c && i) && (a === !0 || a === void 0), f = e({
12
+ let { client: o, organizationId: s, widgetToken: c, authEpoch: l, organizationStatus: u } = n(), d = !!(s && c && i) && (a === !0 || a === void 0), f = e({
13
13
  client: o,
14
14
  headers: { "x-organization-id": s ?? "" },
15
15
  path: { transaction_id: i ?? "" }
@@ -17,7 +17,7 @@ function i({ transactionId: i, enabled: a } = {}) {
17
17
  return r({
18
18
  ...t(f, {
19
19
  authEpoch: l,
20
- organizationPending: u
20
+ organizationStatus: u
21
21
  }),
22
22
  enabled: d
23
23
  });
@@ -246,6 +246,7 @@ function b(t = {}) {
246
246
  return {
247
247
  rules: T,
248
248
  isLoading: x.isFetching,
249
+ hasLoaded: x.data !== void 0,
249
250
  saveStatus: _,
250
251
  createRule: D,
251
252
  updateRule: O,
@@ -3,15 +3,17 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
6
+ import { isOrganizationOnItsWay as t } from "../../../shared/data-access/dist/lib/organizationStatus.js";
7
+ import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { Scope as r } from "../../../shared/data-access/dist/lib/scopes.js";
9
+ import { useAllOrganizationRolesQuery as i } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
8
10
  import "../../../shared/data-access/dist/index.js";
9
- import { EmbeddedToaster as r } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
10
- import { ErrorState as i } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
11
+ import { EmbeddedToaster as a } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
12
+ import { ErrorState as o } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
11
13
  import "../../../shared/ui/dist/index.js";
12
- import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
13
- import { WidgetProvider as o } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
14
- import { useWidgetConfig as s, useWidgetLoading as c } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
+ import { useAnalyticsTrack as s } from "../../../shared/feature/dist/lib/analytics/hooks.js";
15
+ import { WidgetProvider as c } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
16
+ import { useWidgetConfig as ee, useWidgetLoading as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
15
17
  import "../../../shared/feature/dist/index.js";
16
18
  import { AmountConditionType as l, ApprovalOutcomeType as u } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js";
17
19
  import { ApprovalRuleToastLabels as d } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js";
@@ -22,26 +24,26 @@ import { ExpenseApprovalPoliciesAnalyticsEvent as g, WIDGET_NAME as _ } from "./
22
24
  import { useApprovalPolicies as v } from "./index24.js";
23
25
  import { expenseApprovalPoliciesTestIds as y } from "./index26.js";
24
26
  import { useEffect as b, useMemo as x, useState as S } from "react";
25
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
27
+ import { Fragment as C, jsx as w, jsxs as ne } from "react/jsx-runtime";
26
28
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index27.js
27
- var E = {
29
+ var T = {
28
30
  minAmount: "",
29
31
  maxAmount: "",
30
32
  outcome: u.AutoApprove,
31
33
  approvers: []
32
34
  };
33
- function D(e, t) {
35
+ function E(e, t) {
34
36
  let n = (e ?? "").trim().toLowerCase();
35
37
  return n === t || n === `embedded:${t}`;
36
38
  }
37
- function O(e, t) {
39
+ function D(e, t) {
38
40
  return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
39
41
  }
40
- function k(e) {
41
- return D(e, "cfo") || D(e, "finance_admin") || D(e, "finance-admin");
42
+ function O(e) {
43
+ return E(e, "cfo") || E(e, "finance_admin") || E(e, "finance-admin");
42
44
  }
43
- function A(e) {
44
- let t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !O(e.key, "employee") && !O(e.key, "bookkeeper")).map((e) => ({
45
+ function k(e) {
46
+ let t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !D(e.key, "employee") && !D(e.key, "bookkeeper")).map((e) => ({
45
47
  id: e.id,
46
48
  label: e.name
47
49
  })), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
@@ -68,16 +70,16 @@ function A(e) {
68
70
  ...i
69
71
  ];
70
72
  }
71
- function j(e) {
73
+ function A(e) {
72
74
  let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
73
75
  return t && n ? l.InRange : t ? l.GreaterThanOrEqual : n ? l.LessThan : l.All;
74
76
  }
75
- function M(e) {
77
+ function j(e) {
76
78
  return [e.conditionType === l.LessThan || e.conditionType === l.All ? 0 : e.minAmount ?? 0, e.conditionType === l.GreaterThanOrEqual || e.conditionType === l.All ? Infinity : e.maxAmount ?? 0];
77
79
  }
78
- function N(e) {
80
+ function M(e) {
79
81
  if (e.length === 0) return !1;
80
- let t = e.map(M).sort((e, t) => e[0] - t[0]);
82
+ let t = e.map(j).sort((e, t) => e[0] - t[0]);
81
83
  if (t[0][0] > 0) return !1;
82
84
  let n = 0;
83
85
  for (let [e, r] of t) {
@@ -86,9 +88,9 @@ function N(e) {
86
88
  }
87
89
  return n === Infinity;
88
90
  }
89
- function P(e) {
91
+ function N(e) {
90
92
  if (e.length === 0) return [];
91
- let t = e.map(M).sort((e, t) => e[0] - t[0]), n = [], r = 0;
93
+ let t = e.map(j).sort((e, t) => e[0] - t[0]), n = [], r = 0;
92
94
  for (let [e, i] of t) e > r && n.push({
93
95
  from: r,
94
96
  to: e
@@ -98,23 +100,23 @@ function P(e) {
98
100
  to: null
99
101
  }), n;
100
102
  }
101
- function F(e) {
102
- let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = j(e);
103
+ function P(e) {
104
+ let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = A(e);
103
105
  return [r === l.LessThan || r === l.All ? 0 : t, r === l.GreaterThanOrEqual || r === l.All ? Infinity : n];
104
106
  }
105
- function I(e, t, n) {
106
- let [r, i] = F(e);
107
+ function F(e, t, n) {
108
+ let [r, i] = P(e);
107
109
  return t.filter((e) => e.id !== n).some((e) => {
108
- let [t, n] = M(e);
110
+ let [t, n] = j(e);
109
111
  return r < n && t < i;
110
112
  });
111
113
  }
112
- function L(e, t, n) {
114
+ function I(e, t, n) {
113
115
  let r = {}, i = e.minAmount.trim() !== "", a = e.maxAmount.trim() !== "", o = Number(e.minAmount.trim()), s = Number(e.maxAmount.trim());
114
- return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = h.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = h.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = h.MaxLessThanOrEqualToMin), e.outcome === u.RequireApproval && e.approvers.length === 0 && (r.approvers = h.ApproversRequired), !r.minAmount && !r.maxAmount && I(e, t, n) && (a ? r.maxAmount = h.ConflictsWithAnotherRule : r.minAmount = h.ConflictsWithAnotherRule), r;
116
+ return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = h.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = h.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = h.MaxLessThanOrEqualToMin), e.outcome === u.RequireApproval && e.approvers.length === 0 && (r.approvers = h.ApproversRequired), !r.minAmount && !r.maxAmount && F(e, t, n) && (a ? r.maxAmount = h.ConflictsWithAnotherRule : r.minAmount = h.ConflictsWithAnotherRule), r;
115
117
  }
116
- function R(e, t) {
117
- let n = j(t);
118
+ function L(e, t) {
119
+ let n = A(t);
118
120
  return {
119
121
  id: e,
120
122
  conditionType: n,
@@ -124,7 +126,7 @@ function R(e, t) {
124
126
  approvers: t.outcome === u.RequireApproval ? t.approvers : []
125
127
  };
126
128
  }
127
- function z(e) {
129
+ function R(e) {
128
130
  return {
129
131
  minAmount: e.minAmount == null ? "" : String(e.minAmount),
130
132
  maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
@@ -132,73 +134,73 @@ function z(e) {
132
134
  approvers: e.approvers
133
135
  };
134
136
  }
135
- function B() {
136
- let o = a();
137
+ function z() {
138
+ let c = s();
137
139
  b(() => {
138
- o(g.Mounted);
139
- }, [o]);
140
- let { initResponse: l } = s(), u = c(), h = l?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: _, isResolving: O, isError: j } = n({ enabled: h }), M = x(() => A(_?.data ?? []), [_]), F = x(() => {
141
- let e = _?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = { reporting_manager: p.ReportingManagerLabel };
140
+ c(g.Mounted);
141
+ }, [c]);
142
+ let { initResponse: l } = ee(), u = te(), h = t(n().organizationStatus), _ = l?.scopes?.includes(r.RoleReadOrg) ?? !1, { data: D, isResolving: A, isError: j } = i({ enabled: _ }), P = x(() => k(D?.data ?? []), [D]), F = x(() => {
143
+ let e = D?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = { reporting_manager: p.ReportingManagerLabel };
142
144
  t && (r[t.id] = p.AdminLabel), n && (r[n.id] = p.CfoLabel);
143
145
  for (let t of e) r[t.id] || (r[t.id] = t.name);
144
146
  return r;
145
- }, [_]), { rules: I, isLoading: B, saveStatus: V, createRule: ee, updateRule: te, deleteRule: H } = v(F), [U, W] = S(!1), [G, K] = S(E), [q, J] = S(null), [Y, X] = S(null);
147
+ }, [D]), { rules: z, isLoading: B, hasLoaded: re, saveStatus: V, createRule: ie, updateRule: H, deleteRule: U } = v(F), [W, G] = S(!1), [K, q] = S(T), [J, Y] = S(null), [X, Z] = S(null);
146
148
  b(() => {
147
149
  V === "success" && e.success(d.Saved), V === "error" && e.error(d.FailedToSave);
148
150
  }, [V]);
149
- let Z = B || u && !l, ne = N(I), re = P(I), Q = Z || O || V === "saving", ie = U ? L(G, I) : {}, ae = Y && q ? L(Y, I, q) : {}, oe = () => {
150
- W(!0), K(E);
151
- }, se = () => {
152
- W(!1);
153
- }, $ = async () => {
154
- let e = L(G, I);
155
- if (Object.keys(e).length > 0) return;
156
- let t = crypto.randomUUID();
157
- await ee(R(t, G)) && (W(!1), K(E));
158
- }, ce = (e) => {
159
- K(e);
160
- }, le = (e) => {
161
- let t = I.find((t) => t.id === e);
162
- t && (W(!1), K(E), J(e), X(z(t)));
151
+ let Q = B || u && !l || h && !re, ae = M(z), oe = N(z), $ = Q || A || V === "saving", se = W ? I(K, z) : {}, ce = X && J ? I(X, z, J) : {}, le = () => {
152
+ G(!0), q(T);
163
153
  }, ue = () => {
164
- J(null), X(null);
154
+ G(!1);
165
155
  }, de = async () => {
166
- if (!q || !Y) return;
167
- let e = L(Y, I, q);
168
- Object.keys(e).length > 0 || await te(q, R(q, Y)) && (J(null), X(null));
156
+ let e = I(K, z);
157
+ if (Object.keys(e).length > 0) return;
158
+ let t = crypto.randomUUID();
159
+ await ie(L(t, K)) && (G(!1), q(T));
169
160
  }, fe = (e) => {
170
- X(e);
171
- }, pe = async (e) => {
172
- await H(e), q === e && (J(null), X(null));
161
+ q(e);
162
+ }, pe = (e) => {
163
+ let t = z.find((t) => t.id === e);
164
+ t && (G(!1), q(T), Y(e), Z(R(t)));
165
+ }, me = () => {
166
+ Y(null), Z(null);
167
+ }, he = async () => {
168
+ if (!J || !X) return;
169
+ let e = I(X, z, J);
170
+ Object.keys(e).length > 0 || await H(J, L(J, X)) && (Y(null), Z(null));
171
+ }, ge = (e) => {
172
+ Z(e);
173
+ }, _e = async (e) => {
174
+ await U(e), J === e && (Y(null), Z(null));
173
175
  };
174
- return l !== void 0 && !h ? /* @__PURE__ */ w(i, {
176
+ return l !== void 0 && !_ ? /* @__PURE__ */ w(o, {
175
177
  title: m.MissingRolePermissionTitle,
176
178
  description: m.MissingRolePermissionDescription
177
- }) : j ? /* @__PURE__ */ w(i, {
179
+ }) : j ? /* @__PURE__ */ w(o, {
178
180
  title: m.RolesUnavailableTitle,
179
181
  description: m.RolesUnavailableDescription
180
- }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(r, {}), /* @__PURE__ */ w(f, {
181
- rules: I,
182
- isBusy: Q,
183
- isLoading: Z,
184
- isAddingRule: U,
185
- newRuleFormValues: G,
186
- newRuleValidationErrors: ie,
187
- editingRuleId: q,
188
- editingRuleFormValues: Y,
189
- editingRuleValidationErrors: ae,
190
- approverOptions: Q ? [] : M,
191
- allExpensesAreCovered: ne,
192
- gapIntervals: re,
193
- onAddRuleClick: oe,
194
- onCancelAddRule: se,
195
- onSaveNewRule: () => void $(),
196
- onNewRuleFormChange: ce,
197
- onEditRule: le,
198
- onCancelEditRule: ue,
199
- onSaveEditRule: () => void de(),
200
- onEditRuleFormChange: fe,
201
- onDeleteRule: (e) => void pe(e),
182
+ }) : /* @__PURE__ */ ne(C, { children: [/* @__PURE__ */ w(a, {}), /* @__PURE__ */ w(f, {
183
+ rules: z,
184
+ isBusy: $,
185
+ isLoading: Q,
186
+ isAddingRule: W,
187
+ newRuleFormValues: K,
188
+ newRuleValidationErrors: se,
189
+ editingRuleId: J,
190
+ editingRuleFormValues: X,
191
+ editingRuleValidationErrors: ce,
192
+ approverOptions: $ ? [] : P,
193
+ allExpensesAreCovered: ae,
194
+ gapIntervals: oe,
195
+ onAddRuleClick: le,
196
+ onCancelAddRule: ue,
197
+ onSaveNewRule: () => void de(),
198
+ onNewRuleFormChange: fe,
199
+ onEditRule: pe,
200
+ onCancelEditRule: me,
201
+ onSaveEditRule: () => void he(),
202
+ onEditRuleFormChange: ge,
203
+ onDeleteRule: (e) => void _e(e),
202
204
  testIds: {
203
205
  ruleCard: { root: y.ruleCard },
204
206
  ruleForm: {
@@ -210,14 +212,14 @@ function B() {
210
212
  }
211
213
  })] });
212
214
  }
213
- function V({ token: e, orgId: t, widgetToken: n, organizationId: r, ...i } = {}) {
214
- return /* @__PURE__ */ w(o, {
215
+ function B({ token: e, orgId: t, widgetToken: n, organizationId: r, ...i } = {}) {
216
+ return /* @__PURE__ */ w(c, {
215
217
  ...i,
216
218
  widgetName: _,
217
219
  widgetToken: n === void 0 ? e : n,
218
220
  organizationId: r === void 0 ? t : r,
219
- children: /* @__PURE__ */ w(B, {})
221
+ children: /* @__PURE__ */ w(z, {})
220
222
  });
221
223
  }
222
224
  //#endregion
223
- export { V as ExpenseApprovalPoliciesWidget, V as default, A as buildApproverOptions, D as isEmbeddedSystemRoleKey, O as roleKeyHasSegment };
225
+ export { B as ExpenseApprovalPoliciesWidget, B as default, k as buildApproverOptions, E as isEmbeddedSystemRoleKey, D as roleKeyHasSegment };