autumn-js 0.0.96 → 0.0.98

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 (135) hide show
  1. package/dist/libraries/backend/better-auth.d.mts +18 -18
  2. package/dist/libraries/backend/better-auth.d.ts +18 -18
  3. package/dist/libraries/backend/express.d.mts +1 -1
  4. package/dist/libraries/backend/express.d.ts +1 -1
  5. package/dist/libraries/backend/{referralTypes-HAk2vTns.d.ts → referralTypes-D1Q2i3mG.d.ts} +28 -27
  6. package/dist/libraries/backend/{referralTypes-Dg9pRvI7.d.mts → referralTypes-Dfg6if8j.d.mts} +28 -27
  7. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  8. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  9. package/dist/libraries/react/AutumnContext.d.mts +4 -4
  10. package/dist/libraries/react/AutumnContext.d.ts +4 -4
  11. package/dist/libraries/react/AutumnContext.mjs +7 -7
  12. package/dist/libraries/react/BaseAutumnProvider.d.mts +4 -4
  13. package/dist/libraries/react/BaseAutumnProvider.d.ts +4 -4
  14. package/dist/libraries/react/BaseAutumnProvider.mjs +12 -12
  15. package/dist/libraries/react/{ReactAutumnClient-iUQGnJyH.d.ts → ReactAutumnClient-ByV3ry6X.d.ts} +3 -3
  16. package/dist/libraries/react/{ReactAutumnClient-CXaaDdjS.d.mts → ReactAutumnClient-Ce34XSNp.d.mts} +3 -3
  17. package/dist/libraries/react/ReactAutumnProvider.d.mts +1 -1
  18. package/dist/libraries/react/ReactAutumnProvider.d.ts +1 -1
  19. package/dist/libraries/react/ReactAutumnProvider.mjs +13 -13
  20. package/dist/libraries/react/{chunk-6CJ3FB74.mjs → chunk-7J5WGHDK.mjs} +2 -2
  21. package/dist/libraries/react/{chunk-DVMVIAZE.mjs → chunk-AISYLQU5.mjs} +1 -1
  22. package/dist/libraries/react/{chunk-T5PIJ4HG.mjs → chunk-BJRHW2WP.mjs} +2 -2
  23. package/dist/libraries/react/{chunk-MZDRIPNS.mjs → chunk-BQUVIPG4.mjs} +2 -2
  24. package/dist/libraries/react/{chunk-CAMHARUX.mjs → chunk-FGNNWWBD.mjs} +2 -2
  25. package/dist/libraries/react/{chunk-G3FBFZLU.mjs → chunk-IJFGEGR2.mjs} +1 -1
  26. package/dist/libraries/react/{chunk-5G3DYUNT.mjs → chunk-RURBN53D.mjs} +1 -1
  27. package/dist/libraries/react/{chunk-LVDONEVF.mjs → chunk-SA4NOOHV.mjs} +2 -2
  28. package/dist/libraries/react/{chunk-AOJCMXVS.mjs → chunk-TKHPR5VW.mjs} +3 -3
  29. package/dist/libraries/react/{chunk-APDR7D6A.mjs → chunk-XSJQQSUT.mjs} +2 -2
  30. package/dist/libraries/react/{chunk-R4BYOLST.mjs → chunk-ZFOSCZKA.mjs} +2 -2
  31. package/dist/libraries/react/{chunk-IN62REVO.mjs → chunk-ZQ5HNM6O.mjs} +278 -278
  32. package/dist/libraries/react/client/ReactAutumnClient.d.mts +4 -4
  33. package/dist/libraries/react/client/ReactAutumnClient.d.ts +4 -4
  34. package/dist/libraries/react/client/ReactAutumnClient.mjs +6 -6
  35. package/dist/libraries/react/client/clientCompMethods.d.mts +4 -4
  36. package/dist/libraries/react/client/clientCompMethods.d.ts +4 -4
  37. package/dist/libraries/react/client/clientCusMethods.d.mts +4 -4
  38. package/dist/libraries/react/client/clientCusMethods.d.ts +4 -4
  39. package/dist/libraries/react/client/clientEntityMethods.d.mts +4 -4
  40. package/dist/libraries/react/client/clientEntityMethods.d.ts +4 -4
  41. package/dist/libraries/react/client/clientGenMethods.d.mts +4 -4
  42. package/dist/libraries/react/client/clientGenMethods.d.ts +4 -4
  43. package/dist/libraries/react/client/clientProdMethods.d.mts +4 -4
  44. package/dist/libraries/react/client/clientProdMethods.d.ts +4 -4
  45. package/dist/libraries/react/client/clientReferralMethods.d.mts +4 -4
  46. package/dist/libraries/react/client/clientReferralMethods.d.ts +4 -4
  47. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.mts +1 -1
  48. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.ts +1 -1
  49. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.mjs +21 -21
  50. package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.mts +1 -1
  51. package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.ts +1 -1
  52. package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.mts +1 -1
  53. package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.ts +1 -1
  54. package/dist/libraries/react/components/check-dialog/lib/check-content.d.mts +1 -1
  55. package/dist/libraries/react/components/check-dialog/lib/check-content.d.ts +1 -1
  56. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
  57. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
  58. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +21 -21
  59. package/dist/libraries/react/{cusTypes-WaPJKeAb.d.ts → cusTypes-cFcAuKk6.d.mts} +2 -1
  60. package/dist/libraries/react/{cusTypes-WaPJKeAb.d.mts → cusTypes-cFcAuKk6.d.ts} +2 -1
  61. package/dist/libraries/react/{entTypes-D01S8gFX.d.ts → entTypes-DPu6Efi2.d.ts} +1 -1
  62. package/dist/libraries/react/{entTypes-aIV0QUCW.d.mts → entTypes-S-Yuznzg.d.mts} +1 -1
  63. package/dist/libraries/react/hooks/handleAllowed.d.mts +2 -2
  64. package/dist/libraries/react/hooks/handleAllowed.d.ts +2 -2
  65. package/dist/libraries/react/hooks/useAutumn.d.mts +2 -2
  66. package/dist/libraries/react/hooks/useAutumn.d.ts +2 -2
  67. package/dist/libraries/react/hooks/useAutumn.mjs +10 -10
  68. package/dist/libraries/react/hooks/useAutumnBase.d.mts +4 -4
  69. package/dist/libraries/react/hooks/useAutumnBase.d.ts +4 -4
  70. package/dist/libraries/react/hooks/useAutumnBase.mjs +9 -9
  71. package/dist/libraries/react/hooks/useCustomer.d.mts +4 -4
  72. package/dist/libraries/react/hooks/useCustomer.d.ts +4 -4
  73. package/dist/libraries/react/hooks/useCustomer.mjs +11 -11
  74. package/dist/libraries/react/hooks/useCustomerBase.d.mts +4 -4
  75. package/dist/libraries/react/hooks/useCustomerBase.d.ts +4 -4
  76. package/dist/libraries/react/hooks/useCustomerBase.mjs +10 -10
  77. package/dist/libraries/react/hooks/useEntity.d.mts +3 -3
  78. package/dist/libraries/react/hooks/useEntity.d.ts +3 -3
  79. package/dist/libraries/react/hooks/useEntity.mjs +11 -11
  80. package/dist/libraries/react/hooks/useEntityBase.d.mts +4 -4
  81. package/dist/libraries/react/hooks/useEntityBase.d.ts +4 -4
  82. package/dist/libraries/react/hooks/useEntityBase.mjs +10 -10
  83. package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
  84. package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
  85. package/dist/libraries/react/hooks/usePricingTable.mjs +9 -9
  86. package/dist/libraries/react/hooks/usePricingTableBase.d.mts +4 -4
  87. package/dist/libraries/react/hooks/usePricingTableBase.d.ts +4 -4
  88. package/dist/libraries/react/hooks/usePricingTableBase.mjs +8 -8
  89. package/dist/libraries/react/hooks/useProductsBase.mjs +7 -7
  90. package/dist/libraries/react/index.d.mts +1 -0
  91. package/dist/libraries/react/index.d.ts +1 -0
  92. package/dist/libraries/react/{response-C0MTZEqT.d.ts → response-BDOGqtuI.d.ts} +2 -2
  93. package/dist/libraries/react/{response-FC9NTmn2.d.mts → response-R1MWYZiA.d.mts} +2 -2
  94. package/dist/next/{AutumnProvider-CCYZC_bN.d.mts → AutumnProvider-Xl1mqxls.d.mts} +1 -0
  95. package/dist/next/{AutumnProvider-CCYZC_bN.d.ts → AutumnProvider-Xl1mqxls.d.ts} +1 -0
  96. package/dist/next/AutumnProvider.d.mts +1 -1
  97. package/dist/next/AutumnProvider.d.ts +1 -1
  98. package/dist/next/client/NextAutumnClient.d.mts +10 -10
  99. package/dist/next/client/NextAutumnClient.d.ts +10 -10
  100. package/dist/next/client/NextAutumnProvider.d.mts +1 -1
  101. package/dist/next/client/NextAutumnProvider.d.ts +1 -1
  102. package/dist/next/client/{clientGenTypes-CpX8Cvjm.d.ts → clientGenTypes-B_LCNkd5.d.ts} +17 -17
  103. package/dist/next/client/{clientGenTypes-BHk25QIO.d.mts → clientGenTypes-BwevGhcx.d.mts} +17 -17
  104. package/dist/next/client/clientUtils.d.mts +2 -2
  105. package/dist/next/client/clientUtils.d.ts +2 -2
  106. package/dist/next/client/{cusTypes-D8lhXGaX.d.mts → cusTypes-Gh2wfcmj.d.mts} +1 -0
  107. package/dist/next/client/{cusTypes-D8lhXGaX.d.ts → cusTypes-Gh2wfcmj.d.ts} +1 -0
  108. package/dist/next/client/{entTypes-Dq2mbehl.d.ts → entTypes-B_w6I3y-.d.ts} +1 -1
  109. package/dist/next/client/{entTypes-B-2_9hzP.d.mts → entTypes-C_xS1VPE.d.mts} +1 -1
  110. package/dist/next/client/hooks/useAutumn.d.mts +2 -2
  111. package/dist/next/client/hooks/useAutumn.d.ts +2 -2
  112. package/dist/next/client/hooks/useCustomer.d.mts +3 -3
  113. package/dist/next/client/hooks/useCustomer.d.ts +3 -3
  114. package/dist/next/client/hooks/useEntity.d.mts +3 -3
  115. package/dist/next/client/hooks/useEntity.d.ts +3 -3
  116. package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
  117. package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
  118. package/dist/next/client/types.d.mts +2 -2
  119. package/dist/next/client/types.d.ts +2 -2
  120. package/dist/next/index.d.mts +2 -2
  121. package/dist/next/index.d.ts +2 -2
  122. package/dist/next/server/auth/withNextAuth.d.mts +1 -1
  123. package/dist/next/server/auth/withNextAuth.d.ts +1 -1
  124. package/dist/next/server/componentActions.d.mts +1 -1
  125. package/dist/next/server/componentActions.d.ts +1 -1
  126. package/dist/next/server/cusActions.d.mts +21 -21
  127. package/dist/next/server/cusActions.d.ts +21 -21
  128. package/dist/next/server/{cusTypes-Cy72qmFx.d.mts → cusTypes-B8u88Vfq.d.mts} +3 -2
  129. package/dist/next/server/{cusTypes-Cy72qmFx.d.ts → cusTypes-B8u88Vfq.d.ts} +3 -2
  130. package/dist/next/server/genActions.d.mts +1 -1
  131. package/dist/next/server/genActions.d.ts +1 -1
  132. package/dist/sdk/index.d.mts +1 -0
  133. package/dist/sdk/index.d.ts +1 -0
  134. package/package.json +1 -1
  135. package/dist/libraries/react/{chunk-ALFXUHDD.mjs → chunk-QRI2TNR7.mjs} +15 -15
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
 
3
- import {
4
- getPricingTableContent
5
- } from "./chunk-QBBE72EF.mjs";
6
3
  import {
7
4
  getAttachContent
8
5
  } from "./chunk-BCMBFJ7E.mjs";
6
+ import {
7
+ getPricingTableContent
8
+ } from "./chunk-QBBE72EF.mjs";
9
9
  import {
10
10
  Button
11
11
  } from "./chunk-AL3VJLFU.mjs";
@@ -21,38 +21,249 @@ import {
21
21
  import {
22
22
  Switch
23
23
  } from "./chunk-OAWFFAKA.mjs";
24
+ import {
25
+ cn
26
+ } from "./chunk-4J6OC4ZQ.mjs";
24
27
  import {
25
28
  loadingStyles,
26
29
  spinnerStyles
27
30
  } from "./chunk-WVKYZYFT.mjs";
28
- import {
29
- usePricingTable
30
- } from "./chunk-CAMHARUX.mjs";
31
- import {
32
- cn
33
- } from "./chunk-4J6OC4ZQ.mjs";
34
31
  import {
35
32
  useCustomer
36
- } from "./chunk-6CJ3FB74.mjs";
33
+ } from "./chunk-7J5WGHDK.mjs";
34
+ import {
35
+ usePricingTable
36
+ } from "./chunk-FGNNWWBD.mjs";
37
+
38
+ // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
39
+ import React2 from "react";
37
40
 
38
41
  // src/libraries/react/components/attach-dialog/attach-dialog-synced.tsx
39
- import { useEffect, useState as useState2 } from "react";
42
+ import { useEffect, useState } from "react";
43
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
44
+ function AttachDialog(params) {
45
+ const { attach } = useCustomer();
46
+ const [loading, setLoading] = useState(false);
47
+ const [optionsInput, setOptionsInput] = useState(
48
+ params?.preview?.options || []
49
+ );
50
+ const getTotalPrice = () => {
51
+ let sum = due_today?.price || 0;
52
+ optionsInput.forEach((option) => {
53
+ if (option.price && option.quantity) {
54
+ sum += option.price * (option.quantity / option.billing_units);
55
+ }
56
+ });
57
+ return sum;
58
+ };
59
+ useEffect(() => {
60
+ setOptionsInput(params?.preview?.options || []);
61
+ }, [params?.preview?.options]);
62
+ if (!params || !params.preview) {
63
+ return /* @__PURE__ */ jsx(Fragment, {});
64
+ }
65
+ const { open, setOpen, preview } = params;
66
+ const { items, due_today } = preview;
67
+ const { title, message } = getAttachContent(preview);
68
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(
69
+ DialogContent,
70
+ {
71
+ className: cn(
72
+ "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm"
73
+ ),
74
+ children: [
75
+ /* @__PURE__ */ jsx(DialogTitle, { className: cn("au-px-6 au-mb-1 "), children: title }),
76
+ /* @__PURE__ */ jsx("div", { className: cn("au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground"), children: message }),
77
+ (items || optionsInput.length > 0) && /* @__PURE__ */ jsxs("div", { className: "au-mb-6 au-px-6", children: [
78
+ items?.map((item) => /* @__PURE__ */ jsxs(PriceItem, { children: [
79
+ /* @__PURE__ */ jsx("span", { className: "au-truncate au-flex-1", children: item.description }),
80
+ /* @__PURE__ */ jsx("span", { children: item.price })
81
+ ] }, item.description)),
82
+ optionsInput?.map((option, index) => {
83
+ return /* @__PURE__ */ jsx(
84
+ OptionsInput,
85
+ {
86
+ option,
87
+ optionsInput,
88
+ setOptionsInput,
89
+ index
90
+ },
91
+ option.feature_name
92
+ );
93
+ })
94
+ ] }),
95
+ /* @__PURE__ */ jsxs(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: [
96
+ due_today && /* @__PURE__ */ jsxs(TotalPrice, { children: [
97
+ /* @__PURE__ */ jsx("span", { children: "Due Today" }),
98
+ /* @__PURE__ */ jsx("span", { children: new Intl.NumberFormat("en-US", {
99
+ style: "currency",
100
+ currency: due_today.currency
101
+ }).format(getTotalPrice()) })
102
+ ] }),
103
+ /* @__PURE__ */ jsx(
104
+ Button,
105
+ {
106
+ size: "sm",
107
+ onClick: async () => {
108
+ setLoading(true);
109
+ await attach({
110
+ productId: preview.product_id,
111
+ options: optionsInput.map((option) => ({
112
+ featureId: option.feature_id,
113
+ quantity: option.quantity || 0
114
+ }))
115
+ });
116
+ setOpen(false);
117
+ setLoading(false);
118
+ },
119
+ disabled: loading,
120
+ className: "au-min-w-16 au-flex au-items-center au-gap-2",
121
+ children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
122
+ }
123
+ )
124
+ ] })
125
+ ]
126
+ }
127
+ ) });
128
+ }
129
+ var PriceItem = ({
130
+ children,
131
+ className,
132
+ ...props
133
+ }) => {
134
+ return /* @__PURE__ */ jsx(
135
+ "div",
136
+ {
137
+ className: cn(
138
+ "au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
139
+ className
140
+ ),
141
+ ...props,
142
+ children
143
+ }
144
+ );
145
+ };
146
+ var OptionsInput = ({
147
+ className,
148
+ option,
149
+ optionsInput,
150
+ setOptionsInput,
151
+ index,
152
+ ...props
153
+ }) => {
154
+ const { feature_name, billing_units, quantity, price } = option;
155
+ return /* @__PURE__ */ jsxs(PriceItem, { children: [
156
+ /* @__PURE__ */ jsx("span", { children: feature_name }),
157
+ /* @__PURE__ */ jsx(
158
+ QuantityInput,
159
+ {
160
+ value: quantity ? quantity / billing_units : "",
161
+ onChange: (e) => {
162
+ const newOptions = [...optionsInput];
163
+ newOptions[index].quantity = parseInt(e.target.value) * billing_units;
164
+ setOptionsInput(newOptions);
165
+ },
166
+ children: /* @__PURE__ */ jsxs("span", { className: "", children: [
167
+ "\xD7 $",
168
+ price,
169
+ " per ",
170
+ billing_units === 1 ? " " : billing_units,
171
+ " ",
172
+ feature_name
173
+ ] })
174
+ },
175
+ feature_name
176
+ )
177
+ ] }, feature_name);
178
+ };
179
+ var QuantityInput = ({
180
+ children,
181
+ onChange,
182
+ value,
183
+ className,
184
+ ...props
185
+ }) => {
186
+ const currentValue = Number(value) || 0;
187
+ const handleValueChange = (newValue) => {
188
+ const syntheticEvent = {
189
+ target: { value: String(newValue) }
190
+ };
191
+ onChange(syntheticEvent);
192
+ };
193
+ return /* @__PURE__ */ jsxs(
194
+ "div",
195
+ {
196
+ className: cn(className, "au-flex au-flex-row au-items-center au-gap-4"),
197
+ ...props,
198
+ children: [
199
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-gap-1", children: [
200
+ /* @__PURE__ */ jsx(
201
+ Button,
202
+ {
203
+ variant: "outline",
204
+ size: "icon",
205
+ onClick: () => currentValue > 0 && handleValueChange(currentValue - 1),
206
+ disabled: currentValue <= 0,
207
+ className: "au-h-6 au-w-6 au-pb-0.5",
208
+ children: "-"
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx("span", { className: "au-w-8 au-text-center au-text-foreground", children: currentValue }),
212
+ /* @__PURE__ */ jsx(
213
+ Button,
214
+ {
215
+ variant: "outline",
216
+ size: "icon",
217
+ onClick: () => handleValueChange(currentValue + 1),
218
+ className: "au-h-6 au-w-6 au-pb-0.5",
219
+ children: "+"
220
+ }
221
+ )
222
+ ] }),
223
+ children
224
+ ]
225
+ }
226
+ );
227
+ };
228
+ var TotalPrice = ({ children }) => {
229
+ return /* @__PURE__ */ jsx("div", { className: "au-w-full au-font-semibold au-flex au-justify-between au-items-center", children });
230
+ };
231
+ var PricingDialogButton = ({
232
+ children,
233
+ size,
234
+ onClick,
235
+ disabled,
236
+ className
237
+ }) => {
238
+ return /* @__PURE__ */ jsxs(
239
+ Button,
240
+ {
241
+ onClick,
242
+ disabled,
243
+ size,
244
+ className: cn(className, "au-shadow-sm au-shadow-stone-400"),
245
+ children: [
246
+ children,
247
+ /* @__PURE__ */ jsx(ArrowRight, { className: "!au-h-3" })
248
+ ]
249
+ }
250
+ );
251
+ };
40
252
 
41
253
  // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
42
- import React from "react";
43
- import { createContext, useContext, useState } from "react";
44
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
254
+ import { createContext, useContext, useState as useState2 } from "react";
255
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
45
256
  function PricingTable({
46
257
  productDetails
47
258
  }) {
48
259
  const { attach } = useCustomer();
49
- const [isAnnual, setIsAnnual] = useState(false);
260
+ const [isAnnual, setIsAnnual] = useState2(false);
50
261
  const { products, isLoading, error } = usePricingTable({ productDetails });
51
262
  if (isLoading) {
52
- return /* @__PURE__ */ jsx("div", { style: loadingStyles, children: /* @__PURE__ */ jsx(LoaderCircle, { style: spinnerStyles }) });
263
+ return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
53
264
  }
54
265
  if (error) {
55
- return /* @__PURE__ */ jsx("div", { children: " Something went wrong..." });
266
+ return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
56
267
  }
57
268
  const intervals = Array.from(
58
269
  new Set(
@@ -73,14 +284,14 @@ function PricingTable({
73
284
  }
74
285
  return true;
75
286
  };
76
- return /* @__PURE__ */ jsx("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx(
287
+ return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
77
288
  PricingTableContainer,
78
289
  {
79
290
  products,
80
291
  isAnnualToggle: isAnnual,
81
292
  setIsAnnualToggle: setIsAnnual,
82
293
  multiInterval,
83
- children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx(
294
+ children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
84
295
  PricingCard,
85
296
  {
86
297
  productId: product.id,
@@ -130,14 +341,14 @@ var PricingTableContainer = ({
130
341
  throw new Error("products is required in <PricingTable />");
131
342
  }
132
343
  if (products.length === 0) {
133
- return /* @__PURE__ */ jsx(Fragment, {});
344
+ return /* @__PURE__ */ jsx2(Fragment2, {});
134
345
  }
135
346
  const hasRecommended = products?.some((p) => p.display?.recommend_text);
136
- return /* @__PURE__ */ jsx(
347
+ return /* @__PURE__ */ jsx2(
137
348
  PricingTableContext.Provider,
138
349
  {
139
350
  value: { isAnnualToggle, setIsAnnualToggle, products, showFeatures },
140
- children: /* @__PURE__ */ jsxs(
351
+ children: /* @__PURE__ */ jsxs2(
141
352
  "div",
142
353
  {
143
354
  className: cn(
@@ -145,13 +356,13 @@ var PricingTableContainer = ({
145
356
  hasRecommended && "!au-py-10"
146
357
  ),
147
358
  children: [
148
- multiInterval && /* @__PURE__ */ jsx(
359
+ multiInterval && /* @__PURE__ */ jsx2(
149
360
  "div",
150
361
  {
151
362
  className: cn(
152
363
  products.some((p) => p.display?.recommend_text) && "au-mb-8"
153
364
  ),
154
- children: /* @__PURE__ */ jsx(
365
+ children: /* @__PURE__ */ jsx2(
155
366
  AnnualSwitch,
156
367
  {
157
368
  isAnnualToggle,
@@ -160,7 +371,7 @@ var PricingTableContainer = ({
160
371
  )
161
372
  }
162
373
  ),
163
- /* @__PURE__ */ jsx(
374
+ /* @__PURE__ */ jsx2(
164
375
  "div",
165
376
  {
166
377
  className: cn(
@@ -193,7 +404,7 @@ var PricingCard = ({
193
404
  primary_text: "Free"
194
405
  } : product.items[0].display;
195
406
  const featureItems = product.properties?.is_free ? product.items : product.items.slice(1);
196
- return /* @__PURE__ */ jsxs(
407
+ return /* @__PURE__ */ jsxs2(
197
408
  "div",
198
409
  {
199
410
  className: cn(
@@ -202,8 +413,8 @@ var PricingCard = ({
202
413
  className
203
414
  ),
204
415
  children: [
205
- productDisplay?.recommend_text && /* @__PURE__ */ jsx(RecommendedBadge, { recommended: productDisplay?.recommend_text }),
206
- /* @__PURE__ */ jsxs(
416
+ productDisplay?.recommend_text && /* @__PURE__ */ jsx2(RecommendedBadge, { recommended: productDisplay?.recommend_text }),
417
+ /* @__PURE__ */ jsxs2(
207
418
  "div",
208
419
  {
209
420
  className: cn(
@@ -211,19 +422,19 @@ var PricingCard = ({
211
422
  isRecommended && "lg:au-translate-y-6"
212
423
  ),
213
424
  children: [
214
- /* @__PURE__ */ jsxs("div", { className: "au-h-full", children: [
215
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col", children: [
216
- /* @__PURE__ */ jsxs("div", { className: "au-pb-4", children: [
217
- /* @__PURE__ */ jsx("h2", { className: "au-text-2xl au-font-semibold au-px-6 au-truncate", children: productDisplay?.name || name }),
218
- productDisplay?.description && /* @__PURE__ */ jsx("div", { className: "au-text-sm au-text-muted-foreground au-px-6 au-h-8", children: /* @__PURE__ */ jsx("p", { className: "au-line-clamp-2", children: productDisplay?.description }) })
425
+ /* @__PURE__ */ jsxs2("div", { className: "au-h-full", children: [
426
+ /* @__PURE__ */ jsxs2("div", { className: "au-flex au-flex-col", children: [
427
+ /* @__PURE__ */ jsxs2("div", { className: "au-pb-4", children: [
428
+ /* @__PURE__ */ jsx2("h2", { className: "au-text-2xl au-font-semibold au-px-6 au-truncate", children: productDisplay?.name || name }),
429
+ productDisplay?.description && /* @__PURE__ */ jsx2("div", { className: "au-text-sm au-text-muted-foreground au-px-6 au-h-8", children: /* @__PURE__ */ jsx2("p", { className: "au-line-clamp-2", children: productDisplay?.description }) })
219
430
  ] }),
220
- /* @__PURE__ */ jsx("div", { className: "au-mb-2", children: /* @__PURE__ */ jsx("h3", { className: "au-font-semibold au-h-16 au-flex au-px-6 au-items-center au-border-y au-mb-4 au-bg-secondary/40", children: /* @__PURE__ */ jsxs("div", { className: "au-line-clamp-2", children: [
431
+ /* @__PURE__ */ jsx2("div", { className: "au-mb-2", children: /* @__PURE__ */ jsx2("h3", { className: "au-font-semibold au-h-16 au-flex au-px-6 au-items-center au-border-y au-mb-4 au-bg-secondary/40", children: /* @__PURE__ */ jsxs2("div", { className: "au-line-clamp-2", children: [
221
432
  mainPriceDisplay?.primary_text,
222
433
  " ",
223
- mainPriceDisplay?.secondary_text && /* @__PURE__ */ jsx("span", { className: "au-font-normal au-text-muted-foreground au-mt-1", children: mainPriceDisplay?.secondary_text })
434
+ mainPriceDisplay?.secondary_text && /* @__PURE__ */ jsx2("span", { className: "au-font-normal au-text-muted-foreground au-mt-1", children: mainPriceDisplay?.secondary_text })
224
435
  ] }) }) })
225
436
  ] }),
226
- showFeatures && featureItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "au-flex-grow au-px-6 au-mb-6", children: /* @__PURE__ */ jsx(
437
+ showFeatures && featureItems.length > 0 && /* @__PURE__ */ jsx2("div", { className: "au-flex-grow au-px-6 au-mb-6", children: /* @__PURE__ */ jsx2(
227
438
  PricingFeatureList,
228
439
  {
229
440
  items: featureItems,
@@ -232,11 +443,11 @@ var PricingCard = ({
232
443
  }
233
444
  ) })
234
445
  ] }),
235
- /* @__PURE__ */ jsx(
446
+ /* @__PURE__ */ jsx2(
236
447
  "div",
237
448
  {
238
449
  className: cn(" au-px-6 ", isRecommended && "lg:au--translate-y-12"),
239
- children: /* @__PURE__ */ jsx(
450
+ children: /* @__PURE__ */ jsx2(
240
451
  PricingCardButton,
241
452
  {
242
453
  recommended: productDisplay?.recommend_text ? true : false,
@@ -259,21 +470,21 @@ var PricingFeatureList = ({
259
470
  everythingFrom,
260
471
  className
261
472
  }) => {
262
- return /* @__PURE__ */ jsxs("div", { className: cn("au-flex-grow", className), children: [
263
- everythingFrom && /* @__PURE__ */ jsxs("p", { className: "au-text-sm au-mb-4", children: [
473
+ return /* @__PURE__ */ jsxs2("div", { className: cn("au-flex-grow", className), children: [
474
+ everythingFrom && /* @__PURE__ */ jsxs2("p", { className: "au-text-sm au-mb-4", children: [
264
475
  "Everything from ",
265
476
  everythingFrom,
266
477
  ", plus:"
267
478
  ] }),
268
- /* @__PURE__ */ jsx("div", { className: "au-space-y-3", children: items.map((item, index) => /* @__PURE__ */ jsxs(
479
+ /* @__PURE__ */ jsx2("div", { className: "au-space-y-3", children: items.map((item, index) => /* @__PURE__ */ jsxs2(
269
480
  "div",
270
481
  {
271
482
  className: "au-flex au-items-start au-gap-2 au-text-sm",
272
483
  children: [
273
- showIcon && /* @__PURE__ */ jsx(Check, { className: "au-h-4 au-w-4 au-text-primary au-flex-shrink-0 au-mt-0.5" }),
274
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col", children: [
275
- /* @__PURE__ */ jsx("span", { children: item.display?.primary_text }),
276
- item.display?.secondary_text && /* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: item.display?.secondary_text })
484
+ showIcon && /* @__PURE__ */ jsx2(Check, { className: "au-h-4 au-w-4 au-text-primary au-flex-shrink-0 au-mt-0.5" }),
485
+ /* @__PURE__ */ jsxs2("div", { className: "au-flex au-flex-col", children: [
486
+ /* @__PURE__ */ jsx2("span", { children: item.display?.primary_text }),
487
+ item.display?.secondary_text && /* @__PURE__ */ jsx2("span", { className: "au-text-sm au-text-muted-foreground", children: item.display?.secondary_text })
277
488
  ] })
278
489
  ]
279
490
  },
@@ -281,8 +492,8 @@ var PricingFeatureList = ({
281
492
  )) })
282
493
  ] });
283
494
  };
284
- var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
285
- const [loading, setLoading] = useState(false);
495
+ var PricingCardButton = React2.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
496
+ const [loading, setLoading] = useState2(false);
286
497
  const handleClick = async (e) => {
287
498
  setLoading(true);
288
499
  try {
@@ -293,7 +504,7 @@ var PricingCardButton = React.forwardRef(({ recommended, children, className, on
293
504
  setLoading(false);
294
505
  }
295
506
  };
296
- return /* @__PURE__ */ jsx(
507
+ return /* @__PURE__ */ jsx2(
297
508
  Button,
298
509
  {
299
510
  className: cn(
@@ -305,14 +516,14 @@ var PricingCardButton = React.forwardRef(({ recommended, children, className, on
305
516
  ref,
306
517
  disabled: loading || props.disabled,
307
518
  onClick: handleClick,
308
- children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-h-4 au-w-4 au-animate-spin" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
309
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-justify-between au-w-full au-transition-transform au-duration-300 group-hover:au-translate-y-[-130%]", children: [
310
- /* @__PURE__ */ jsx("span", { children }),
311
- /* @__PURE__ */ jsx("span", { className: "au-text-sm", children: "\u2192" })
519
+ children: loading ? /* @__PURE__ */ jsx2(LoaderCircle, { className: "au-h-4 au-w-4 au-animate-spin" }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
520
+ /* @__PURE__ */ jsxs2("div", { className: "au-flex au-items-center au-justify-between au-w-full au-transition-transform au-duration-300 group-hover:au-translate-y-[-130%]", children: [
521
+ /* @__PURE__ */ jsx2("span", { children }),
522
+ /* @__PURE__ */ jsx2("span", { className: "au-text-sm", children: "\u2192" })
312
523
  ] }),
313
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-justify-between au-w-full au-absolute au-px-4 au-translate-y-[130%] au-transition-transform au-duration-300 group-hover:au-translate-y-0 au-mt-2 group-hover:au-mt-0", children: [
314
- /* @__PURE__ */ jsx("span", { children }),
315
- /* @__PURE__ */ jsx("span", { className: "au-text-sm", children: "\u2192" })
524
+ /* @__PURE__ */ jsxs2("div", { className: "au-flex au-items-center au-justify-between au-w-full au-absolute au-px-4 au-translate-y-[130%] au-transition-transform au-duration-300 group-hover:au-translate-y-0 au-mt-2 group-hover:au-mt-0", children: [
525
+ /* @__PURE__ */ jsx2("span", { children }),
526
+ /* @__PURE__ */ jsx2("span", { className: "au-text-sm", children: "\u2192" })
316
527
  ] })
317
528
  ] })
318
529
  }
@@ -323,9 +534,9 @@ var AnnualSwitch = ({
323
534
  isAnnualToggle,
324
535
  setIsAnnualToggle
325
536
  }) => {
326
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-space-x-2 au-mb-4", children: [
327
- /* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: "Monthly" }),
328
- /* @__PURE__ */ jsx(
537
+ return /* @__PURE__ */ jsxs2("div", { className: "au-flex au-items-center au-space-x-2 au-mb-4", children: [
538
+ /* @__PURE__ */ jsx2("span", { className: "au-text-sm au-text-muted-foreground", children: "Monthly" }),
539
+ /* @__PURE__ */ jsx2(
329
540
  Switch,
330
541
  {
331
542
  id: "annual-billing",
@@ -333,231 +544,14 @@ var AnnualSwitch = ({
333
544
  onCheckedChange: setIsAnnualToggle
334
545
  }
335
546
  ),
336
- /* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: "Annual" })
547
+ /* @__PURE__ */ jsx2("span", { className: "au-text-sm au-text-muted-foreground", children: "Annual" })
337
548
  ] });
338
549
  };
339
550
  var RecommendedBadge = ({ recommended }) => {
340
- return /* @__PURE__ */ jsx("div", { className: "au-bg-secondary au-absolute au-border au-text-muted-foreground au-text-sm au-font-medium lg:au-rounded-full au-px-3 lg:au-py-0.5 lg:au-top-4 lg:au-right-4 au-top-[-1px] au-right-[-1px] au-rounded-bl-lg", children: recommended });
341
- };
342
-
343
- // src/libraries/react/components/attach-dialog/attach-dialog-synced.tsx
344
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
345
- function AttachDialog(params) {
346
- const { attach } = useCustomer();
347
- const [loading, setLoading] = useState2(false);
348
- const [optionsInput, setOptionsInput] = useState2(
349
- params?.preview?.options || []
350
- );
351
- const getTotalPrice = () => {
352
- let sum = due_today?.price || 0;
353
- optionsInput.forEach((option) => {
354
- if (option.price && option.quantity) {
355
- sum += option.price * (option.quantity / option.billing_units);
356
- }
357
- });
358
- return sum;
359
- };
360
- useEffect(() => {
361
- setOptionsInput(params?.preview?.options || []);
362
- }, [params?.preview?.options]);
363
- if (!params || !params.preview) {
364
- return /* @__PURE__ */ jsx2(Fragment2, {});
365
- }
366
- const { open, setOpen, preview } = params;
367
- const { items, due_today } = preview;
368
- const { title, message } = getAttachContent(preview);
369
- return /* @__PURE__ */ jsx2(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs2(
370
- DialogContent,
371
- {
372
- className: cn(
373
- "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm"
374
- ),
375
- children: [
376
- /* @__PURE__ */ jsx2(DialogTitle, { className: cn("au-px-6 au-mb-1 "), children: title }),
377
- /* @__PURE__ */ jsx2("div", { className: cn("au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground"), children: message }),
378
- (items || optionsInput.length > 0) && /* @__PURE__ */ jsxs2("div", { className: "au-mb-6 au-px-6", children: [
379
- items?.map((item) => /* @__PURE__ */ jsxs2(PriceItem, { children: [
380
- /* @__PURE__ */ jsx2("span", { className: "au-truncate au-flex-1", children: item.description }),
381
- /* @__PURE__ */ jsx2("span", { children: item.price })
382
- ] }, item.description)),
383
- optionsInput?.map((option, index) => {
384
- return /* @__PURE__ */ jsx2(
385
- OptionsInput,
386
- {
387
- option,
388
- optionsInput,
389
- setOptionsInput,
390
- index
391
- },
392
- option.feature_name
393
- );
394
- })
395
- ] }),
396
- /* @__PURE__ */ jsxs2(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: [
397
- due_today && /* @__PURE__ */ jsxs2(TotalPrice, { children: [
398
- /* @__PURE__ */ jsx2("span", { children: "Due Today" }),
399
- /* @__PURE__ */ jsx2("span", { children: new Intl.NumberFormat("en-US", {
400
- style: "currency",
401
- currency: due_today.currency
402
- }).format(getTotalPrice()) })
403
- ] }),
404
- /* @__PURE__ */ jsx2(
405
- Button,
406
- {
407
- size: "sm",
408
- onClick: async () => {
409
- setLoading(true);
410
- await attach({
411
- productId: preview.product_id,
412
- options: optionsInput.map((option) => ({
413
- featureId: option.feature_id,
414
- quantity: option.quantity || 0
415
- }))
416
- });
417
- setOpen(false);
418
- setLoading(false);
419
- },
420
- disabled: loading,
421
- className: "au-min-w-16 au-flex au-items-center au-gap-2",
422
- children: loading ? /* @__PURE__ */ jsx2(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
423
- }
424
- )
425
- ] })
426
- ]
427
- }
428
- ) });
429
- }
430
- var PriceItem = ({
431
- children,
432
- className,
433
- ...props
434
- }) => {
435
- return /* @__PURE__ */ jsx2(
436
- "div",
437
- {
438
- className: cn(
439
- "au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
440
- className
441
- ),
442
- ...props,
443
- children
444
- }
445
- );
446
- };
447
- var OptionsInput = ({
448
- className,
449
- option,
450
- optionsInput,
451
- setOptionsInput,
452
- index,
453
- ...props
454
- }) => {
455
- const { feature_name, billing_units, quantity, price } = option;
456
- return /* @__PURE__ */ jsxs2(PriceItem, { children: [
457
- /* @__PURE__ */ jsx2("span", { children: feature_name }),
458
- /* @__PURE__ */ jsx2(
459
- QuantityInput,
460
- {
461
- value: quantity ? quantity / billing_units : "",
462
- onChange: (e) => {
463
- const newOptions = [...optionsInput];
464
- newOptions[index].quantity = parseInt(e.target.value) * billing_units;
465
- setOptionsInput(newOptions);
466
- },
467
- children: /* @__PURE__ */ jsxs2("span", { className: "", children: [
468
- "\xD7 $",
469
- price,
470
- " per ",
471
- billing_units === 1 ? " " : billing_units,
472
- " ",
473
- feature_name
474
- ] })
475
- },
476
- feature_name
477
- )
478
- ] }, feature_name);
479
- };
480
- var QuantityInput = ({
481
- children,
482
- onChange,
483
- value,
484
- className,
485
- ...props
486
- }) => {
487
- const currentValue = Number(value) || 0;
488
- const handleValueChange = (newValue) => {
489
- const syntheticEvent = {
490
- target: { value: String(newValue) }
491
- };
492
- onChange(syntheticEvent);
493
- };
494
- return /* @__PURE__ */ jsxs2(
495
- "div",
496
- {
497
- className: cn(className, "au-flex au-flex-row au-items-center au-gap-4"),
498
- ...props,
499
- children: [
500
- /* @__PURE__ */ jsxs2("div", { className: "au-flex au-items-center au-gap-1", children: [
501
- /* @__PURE__ */ jsx2(
502
- Button,
503
- {
504
- variant: "outline",
505
- size: "icon",
506
- onClick: () => currentValue > 0 && handleValueChange(currentValue - 1),
507
- disabled: currentValue <= 0,
508
- className: "au-h-6 au-w-6 au-pb-0.5",
509
- children: "-"
510
- }
511
- ),
512
- /* @__PURE__ */ jsx2("span", { className: "au-w-8 au-text-center au-text-foreground", children: currentValue }),
513
- /* @__PURE__ */ jsx2(
514
- Button,
515
- {
516
- variant: "outline",
517
- size: "icon",
518
- onClick: () => handleValueChange(currentValue + 1),
519
- className: "au-h-6 au-w-6 au-pb-0.5",
520
- children: "+"
521
- }
522
- )
523
- ] }),
524
- children
525
- ]
526
- }
527
- );
528
- };
529
- var TotalPrice = ({ children }) => {
530
- return /* @__PURE__ */ jsx2("div", { className: "au-w-full au-font-semibold au-flex au-justify-between au-items-center", children });
531
- };
532
- var PricingDialogButton = ({
533
- children,
534
- size,
535
- onClick,
536
- disabled,
537
- className
538
- }) => {
539
- return /* @__PURE__ */ jsxs2(
540
- Button,
541
- {
542
- onClick,
543
- disabled,
544
- size,
545
- className: cn(className, "au-shadow-sm au-shadow-stone-400"),
546
- children: [
547
- children,
548
- /* @__PURE__ */ jsx2(ArrowRight, { className: "!au-h-3" })
549
- ]
550
- }
551
- );
551
+ return /* @__PURE__ */ jsx2("div", { className: "au-bg-secondary au-absolute au-border au-text-muted-foreground au-text-sm au-font-medium lg:au-rounded-full au-px-3 lg:au-py-0.5 lg:au-top-4 lg:au-right-4 au-top-[-1px] au-right-[-1px] au-rounded-bl-lg", children: recommended });
552
552
  };
553
553
 
554
554
  export {
555
- AttachDialog,
556
- PriceItem,
557
- OptionsInput,
558
- QuantityInput,
559
- TotalPrice,
560
- PricingDialogButton,
561
555
  PricingTable,
562
556
  usePricingTableContext,
563
557
  PricingTableContainer,
@@ -565,5 +559,11 @@ export {
565
559
  PricingFeatureList,
566
560
  PricingCardButton,
567
561
  AnnualSwitch,
568
- RecommendedBadge
562
+ RecommendedBadge,
563
+ AttachDialog,
564
+ PriceItem,
565
+ OptionsInput,
566
+ QuantityInput,
567
+ TotalPrice,
568
+ PricingDialogButton
569
569
  };